typebulb 0.59.7 → 0.60.1

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,102 +1,102 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
3
- var eS=Object.create;var sl=Object.defineProperty;var tS=Object.getOwnPropertyDescriptor;var nS=Object.getOwnPropertyNames;var rS=Object.getPrototypeOf,sS=Object.prototype.hasOwnProperty;var ai=(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 v=(n,e)=>()=>(n&&(e=n(n=0)),e);var C=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),li=(n,e)=>{for(var t in e)sl(n,t,{get:e[t],enumerable:!0})},iS=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of nS(e))!sS.call(n,s)&&s!==t&&sl(n,s,{get:()=>e[s],enumerable:!(r=tS(e,s))||r.enumerable});return n};var oS=(n,e,t)=>(t=n!=null?eS(rS(n)):{},iS(e||!n||!n.__esModule?sl(t,"default",{value:n,enumerable:!0}):t,n));import*as Rf from"fs/promises";import{existsSync as _n,readFileSync as aS}from"fs";import*as ie from"path";import{pathToFileURL as lS}from"url";import{resolve as ol}from"resolve.exports";import{init as If,parse as Nf}from"es-module-lexer";function $f(n,e){let t=ie.join(n,"package.json");try{return JSON.parse(aS(t,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${t}`)}}function Lf(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:ie.resolve(r)}}async function Mf(n){let{name:e,dir:t}=n;if(!_n(t))throw new Error(`--replace path for '${e}' does not exist: ${t}`);let r=$f(t,e),s=cS(r,e),i=ie.resolve(t,s);if(!_n(i))throw new Error(`--replace package '${e}' entry not found on disk: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);let o=ie.dirname(i),a=`/local/${e}/${ie.basename(i)}`,l=uS(r,t);return await dS(e,i,o),{name:e,dir:t,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function cS(n,e){if(n.exports!==void 0){let r;try{r=ol(n,".",{browser:!0,conditions:il})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${il.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=al(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${il.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 uS(n,e){if(n.exports!==void 0)try{let r=ol(n,".",{conditions:["types"]}),s=al(r);if(s){let i=ie.resolve(e,s);if(_n(i))return i}}catch{}let t=n.types??n.typings;if(t){let r=ie.resolve(e,t);if(_n(r))return r}}function al(n){if(typeof n=="string")return n;if(Array.isArray(n))return n.find(e=>typeof e=="string")}async function dS(n,e,t){await If;let r=ie.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 Rf.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=Nf(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 u=f.n;if(u&&!u.startsWith("node:")){if(u.startsWith("./")||u.startsWith("../")||u.startsWith("/")){let d=fS(o,u,r);d&&!s.has(d)&&i.push(d);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${n} externalizes '${u}'`)}}}}function fS(n,e,t){let r=e.replace(/[?#].*$/,""),s=ie.resolve(ie.dirname(n),r),i=[s,s+".js",s+".mjs",ie.join(s,"index.js"),ie.join(s,"index.mjs")];for(let o of i)if(ie.normalize(o).startsWith(t)&&_n(o))return o}function pS(n,e,t){let r=$f(n,e),s;if(r.exports!==void 0)try{s=al(ol(r,t,{conditions:Cf}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${t}' (conditions: ${Cf.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=ie.resolve(n,s);if(!_n(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return lS(i).href}async function Bf(n,e){await If;let t;try{[t]=Nf(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=pS(e.dir,e.name,a);r+=n.slice(s,i.s)+l,s=i.e}return r+n.slice(s)}var il,Cf,ci=v(()=>{"use strict";il=["browser","import","default"],Cf=["node","import","default"]});function Df(n){return qe.find(e=>ce[e].path===n)}function Ff(n){return!!n?.startsWith("typebulb")}var ce,qe,jf,ui=v(()=>{ce={code:{path:"code.tsx",language:"typescript"},css:{path:"styles.css",language:"css"},html:{path:"index.html",language:"html"},config:{path:"config.json",language:"json"},notes:{path:"notes.md",language:"markdown"},data:{path:"data.txt",language:"text"},infer:{path:"infer.md",language:"markdown"},insight:{path:"insight.json",language:"json"}},qe=["code","css","html","data","infer","insight","config","notes"];jf="typebulb/v1"});function ll(n){return/[:\n"']/.test(n)||n.startsWith(" ")||n.endsWith(" ")?`"${n.replace(/"/g,'\\"')}"`:n}function cl(n){return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1).replace(/\\"/g,'"'):n.startsWith("'")&&n.endsWith("'")?n.slice(1,-1):n}var di=v(()=>{});function Cn(n){let e=qf(n);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function Je(n){let e=qf(n);return"bulb"in e?e.bulb:void 0}function qf(n){try{let e=n.split(`
4
- `),t=0;if(e[t]?.trim()!=="---")return{reason:mS(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=bS(r);if(!Ff(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 u=e[t]?.trim()?.match(Uf);if(u){let d=u[1].trim();for(t++;t<e.length&&e[t]?.trim()==="";)t++;let p=e[t]?.match(fi);if(!p){l.push(`**${d}** has no code fence \u2014 block skipped`);continue}let m=p[1];t++;let h=t+1,b=[],E=ul(m);for(;t<e.length&&!e[t]?.match(E);)b.push(e[t]),t++;let T=t<e.length;t++,l.push(...gS(d,b,T)),o.set(d,b.join(`
5
- `)),a.set(d,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 mS(n,e){let t=wS(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 gS(n,e,t){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Uf);i&&hS.has(i[1].trim())&&yS(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 yS(n,e){let t=e+1;for(;t<n.length&&n[t]?.trim()==="";)t++;return!!n[t]?.match(fi)}function bS(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=cl(i);break}}return e}function Jf(n){return Je(n)?.warnings??[]}function wS(n){let e=n.split(`
6
- `),t=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=Je(e.slice(r).join(`
3
+ var kS=Object.create;var cl=Object.defineProperty;var xS=Object.getOwnPropertyDescriptor;var ES=Object.getOwnPropertyNames;var AS=Object.getPrototypeOf,TS=Object.prototype.hasOwnProperty;var li=(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 S=(n,e)=>()=>(n&&(e=n(n=0)),e);var R=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),ci=(n,e)=>{for(var t in e)cl(n,t,{get:e[t],enumerable:!0})},PS=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ES(e))!TS.call(n,s)&&s!==t&&cl(n,s,{get:()=>e[s],enumerable:!(r=xS(e,s))||r.enumerable});return n};var OS=(n,e,t)=>(t=n!=null?kS(AS(n)):{},PS(e||!n||!n.__esModule?cl(t,"default",{value:n,enumerable:!0}):t,n));import*as Ff from"fs/promises";import{existsSync as In,readFileSync as CS}from"fs";import*as ie from"path";import{pathToFileURL as _S}from"url";import{resolve as dl}from"resolve.exports";import{init as Uf,parse as qf}from"es-module-lexer";function Jf(n,e){let t=ie.join(n,"package.json");try{return JSON.parse(CS(t,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${t}`)}}function Wf(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:ie.resolve(r)}}async function Kf(n){let{name:e,dir:t}=n;if(!In(t))throw new Error(`--replace path for '${e}' does not exist: ${t}`);let r=Jf(t,e),s=RS(r,e),i=ie.resolve(t,s);if(!In(i))throw new Error(`--replace package '${e}' entry not found on disk: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);let o=ie.dirname(i),a=`/local/${e}/${ie.basename(i)}`,l=IS(r,t);return await NS(e,i,o),{name:e,dir:t,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function RS(n,e){if(n.exports!==void 0){let r;try{r=dl(n,".",{browser:!0,conditions:ul})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${ul.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=fl(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${ul.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 IS(n,e){if(n.exports!==void 0)try{let r=dl(n,".",{conditions:["types"]}),s=fl(r);if(s){let i=ie.resolve(e,s);if(In(i))return i}}catch{}let t=n.types??n.typings;if(t){let r=ie.resolve(e,t);if(In(r))return r}}function fl(n){if(typeof n=="string")return n;if(Array.isArray(n))return n.find(e=>typeof e=="string")}async function NS(n,e,t){await Uf;let r=ie.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 Ff.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=qf(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 u=f.n;if(u&&!u.startsWith("node:")){if(u.startsWith("./")||u.startsWith("../")||u.startsWith("/")){let d=$S(o,u,r);d&&!s.has(d)&&i.push(d);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${n} externalizes '${u}'`)}}}}function $S(n,e,t){let r=e.replace(/[?#].*$/,""),s=ie.resolve(ie.dirname(n),r),i=[s,s+".js",s+".mjs",ie.join(s,"index.js"),ie.join(s,"index.mjs")];for(let o of i)if(ie.normalize(o).startsWith(t)&&In(o))return o}function LS(n,e,t){let r=Jf(n,e),s;if(r.exports!==void 0)try{s=fl(dl(r,t,{conditions:jf}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${t}' (conditions: ${jf.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=ie.resolve(n,s);if(!In(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return _S(i).href}async function Hf(n,e){await Uf;let t;try{[t]=qf(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=LS(e.dir,e.name,a);r+=n.slice(s,i.s)+l,s=i.e}return r+n.slice(s)}var ul,jf,ui=S(()=>{"use strict";ul=["browser","import","default"],jf=["node","import","default"]});function Yf(n){return Je.find(e=>ce[e].path===n)}function zf(n){return!!n?.startsWith("typebulb")}var ce,Je,Vf,di=S(()=>{ce={code:{path:"code.tsx",language:"typescript"},css:{path:"styles.css",language:"css"},html:{path:"index.html",language:"html"},config:{path:"config.json",language:"json"},notes:{path:"notes.md",language:"markdown"},data:{path:"data.txt",language:"text"},infer:{path:"infer.md",language:"markdown"},insight:{path:"insight.json",language:"json"}},Je=["code","css","html","data","infer","insight","config","notes"];Vf="typebulb/v1"});function pl(n){return/[:\n"']/.test(n)||n.startsWith(" ")||n.endsWith(" ")?`"${n.replace(/"/g,'\\"')}"`:n}function hl(n){return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1).replace(/\\"/g,'"'):n.startsWith("'")&&n.endsWith("'")?n.slice(1,-1):n}var fi=S(()=>{});function Nn(n){let e=Xf(n);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function We(n){let e=Xf(n);return"bulb"in e?e.bulb:void 0}function Xf(n){try{let e=n.split(`
4
+ `),t=0;if(e[t]?.trim()!=="---")return{reason:BS(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=FS(r);if(!zf(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 u=e[t]?.trim()?.match(Gf);if(u){let d=u[1].trim();for(t++;t<e.length&&e[t]?.trim()==="";)t++;let p=e[t]?.match(pi);if(!p){l.push(`**${d}** has no code fence \u2014 block skipped`);continue}let g=p[1];t++;let h=t+1,y=[],E=ml(g);for(;t<e.length&&!e[t]?.match(E);)y.push(e[t]),t++;let P=t<e.length;t++,l.push(...DS(d,y,P)),o.set(d,y.join(`
5
+ `)),a.set(d,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 BS(n,e){let t=US(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 DS(n,e,t){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Gf);i&&MS.has(i[1].trim())&&jS(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 jS(n,e){let t=e+1;for(;t<n.length&&n[t]?.trim()==="";)t++;return!!n[t]?.match(pi)}function FS(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=hl(i);break}}return e}function Qf(n){return We(n)?.warnings??[]}function US(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
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 Wf(n){let e=Object.fromEntries(qe.map(t=>[t,n.files.get(ce[t].path)||""]));return{name:n.frontmatter.name,...e}}var Uf,fi,hS,ul,dl=v(()=>{ui();di();Uf=/^\*\*(.+)\*\*$/,fi=/^(`{3,})(\w*)\s*$/,hS=new Set(qe.map(n=>ce[n].path)),ul=n=>new RegExp(`^${n}\\s*$`)});function Kf(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 Hf(n,e){let{path:t}=ce[n],r=t.split(".").pop(),s=Kf(e);return`**${t}**
8
+ `)}),r=i}else r++}return t}function Zf(n){let e=Object.fromEntries(Je.map(t=>[t,n.files.get(ce[t].path)||""]));return{name:n.frontmatter.name,...e}}var Gf,pi,MS,ml,gl=S(()=>{di();fi();Gf=/^\*\*(.+)\*\*$/,pi=/^(`{3,})(\w*)\s*$/,MS=new Set(Je.map(n=>ce[n].path)),ml=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 tp(n,e){let{path:t}=ce[n],r=t.split(".").pop(),s=ep(e);return`**${t}**
9
9
 
10
10
  ${s}${r}
11
11
  ${e}
12
- ${s}`}function Yf(n){let e=qe.filter(t=>n[t]).map(t=>Hf(t,n[t]));return["---",`format: ${jf}`,`name: ${ll(n.name)}`,"---","",...e].join(`
13
- `)}function Vf(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(fi);if(!s)continue;let i=ul(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 Cr(n,e,t){let r=n.split(`
14
- `),s=Vf(r,ce[e].path);if(s==="unterminated")return n;if(!s)return`${n.replace(/\s*$/,"")}
12
+ ${s}`}function np(n){let e=Je.filter(t=>n[t]).map(t=>tp(t,n[t]));return["---",`format: ${Vf}`,`name: ${pl(n.name)}`,"---","",...e].join(`
13
+ `)}function rp(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(pi);if(!s)continue;let i=ml(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 Nr(n,e,t){let r=n.split(`
14
+ `),s=rp(r,ce[e].path);if(s==="unterminated")return n;if(!s)return`${n.replace(/\s*$/,"")}
15
15
 
16
- ${Hf(e,t)}
17
- `;let i=Kf(t),o=i.length>s.fence.length?i:s.fence;return[...r.slice(0,s.open),o+s.lang,...t.split(`
16
+ ${tp(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(`
18
18
  `),o,...r.slice(s.close+1)].join(`
19
- `)}function zf(n,e){let t=n.split(`
20
- `),r=Vf(t,ce[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 sp(n,e){let t=n.split(`
20
+ `),r=rp(t,ce[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(`
21
21
  `).replace(/\s*$/,"")+`
22
- `}var Gf=v(()=>{ui();dl();di()});function Rr(n){if(!n.trim())return{};try{return JSON.parse(n)}catch{return{}}}function Qf(n){switch(Xf(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 Zf(n){let e=Xf(n);return e!==void 0&&SS.has(e)?e:void 0}function xS(n){return n.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function fl(n){let e=Rr(n??"").description?.trim();if(!e)return kS;let t=xS(e);return(t.length>200?t.slice(0,197)+"...":t).replace(/\n/g," ")}var vS,pi,Xf,SS,kS,ep=v(()=>{vS="https://assets.typebulb.com",pi=(n,e)=>`${vS}/u/${encodeURIComponent(n)}/${encodeURIComponent(e)}/`,Xf=n=>/\.[^./\\]+$/.exec(n)?.[0]?.toLowerCase();SS=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);kS="A Typebulb bulb."});var tp=v(()=>{});function pl(n,e,t){let s=new RegExp(e).exec(n.slice(t));return s?t+s.index:-1}var np=v(()=>{});function Ir(n,e,t){let s=new RegExp(e).exec(n.slice(t));return s?t+s.index+s[0].length-1:-1}var rp=v(()=>{});function hi(n,e){let t=new RegExp(e,"g"),r=n.match(t);return r?r.length:0}var sp=v(()=>{});function Nr(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=pl(n,`<${e}[
23
- >/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=n.slice(o+e.length),l=Ir(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=Ir(a,"[ /]"+e+">",p))!==-1;){let b=a.substring(p,l+1);if(m+=hi(b,"<"+e+`[
24
- >]`),h+=hi(b,"</"+e+">"),h>=m)break;p=l}}else l=Ir(a,"[ /]"+e+">",0);let f=o+e.length+l+1;if(r&&console.log("[xml-utils] end:",f),f===-1)return;let u=n.slice(o,f),d;return c?d=null:d=u.slice(u.indexOf(">")+1,u.lastIndexOf("<")),{inner:d,outer:u,start:o,end:f}}var hl=v(()=>{np();rp();sp()});var ml=v(()=>{hl()});var gl=v(()=>{ml()});var ip=v(()=>{gl()});var op=v(()=>{});var ap=v(()=>{tp();hl();ml();ip();gl();op()});var U=C(fe=>{"use strict";var yl=Symbol.for("yaml.alias"),lp=Symbol.for("yaml.document"),mi=Symbol.for("yaml.map"),cp=Symbol.for("yaml.pair"),bl=Symbol.for("yaml.scalar"),gi=Symbol.for("yaml.seq"),ot=Symbol.for("yaml.node.type"),TS=n=>!!n&&typeof n=="object"&&n[ot]===yl,PS=n=>!!n&&typeof n=="object"&&n[ot]===lp,OS=n=>!!n&&typeof n=="object"&&n[ot]===mi,_S=n=>!!n&&typeof n=="object"&&n[ot]===cp,up=n=>!!n&&typeof n=="object"&&n[ot]===bl,CS=n=>!!n&&typeof n=="object"&&n[ot]===gi;function dp(n){if(n&&typeof n=="object")switch(n[ot]){case mi:case gi:return!0}return!1}function RS(n){if(n&&typeof n=="object")switch(n[ot]){case yl:case mi:case bl:case gi:return!0}return!1}var IS=n=>(up(n)||dp(n))&&!!n.anchor;fe.ALIAS=yl;fe.DOC=lp;fe.MAP=mi;fe.NODE_TYPE=ot;fe.PAIR=cp;fe.SCALAR=bl;fe.SEQ=gi;fe.hasAnchor=IS;fe.isAlias=TS;fe.isCollection=dp;fe.isDocument=PS;fe.isMap=OS;fe.isNode=RS;fe.isPair=_S;fe.isScalar=up;fe.isSeq=CS});var $r=C(wl=>{"use strict";var oe=U(),be=Symbol("break visit"),fp=Symbol("skip children"),Ze=Symbol("remove node");function yi(n,e){let t=pp(e);oe.isDocument(n)?Rn(null,n.contents,t,Object.freeze([n]))===Ze&&(n.contents=null):Rn(null,n,t,Object.freeze([]))}yi.BREAK=be;yi.SKIP=fp;yi.REMOVE=Ze;function Rn(n,e,t,r){let s=hp(n,e,t,r);if(oe.isNode(s)||oe.isPair(s))return mp(n,r,s),Rn(n,s,t,r);if(typeof s!="symbol"){if(oe.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=Rn(i,e.items[i],t,r);if(typeof o=="number")i=o-1;else{if(o===be)return be;o===Ze&&(e.items.splice(i,1),i-=1)}}}else if(oe.isPair(e)){r=Object.freeze(r.concat(e));let i=Rn("key",e.key,t,r);if(i===be)return be;i===Ze&&(e.key=null);let o=Rn("value",e.value,t,r);if(o===be)return be;o===Ze&&(e.value=null)}}return s}async function bi(n,e){let t=pp(e);oe.isDocument(n)?await In(null,n.contents,t,Object.freeze([n]))===Ze&&(n.contents=null):await In(null,n,t,Object.freeze([]))}bi.BREAK=be;bi.SKIP=fp;bi.REMOVE=Ze;async function In(n,e,t,r){let s=await hp(n,e,t,r);if(oe.isNode(s)||oe.isPair(s))return mp(n,r,s),In(n,s,t,r);if(typeof s!="symbol"){if(oe.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await In(i,e.items[i],t,r);if(typeof o=="number")i=o-1;else{if(o===be)return be;o===Ze&&(e.items.splice(i,1),i-=1)}}}else if(oe.isPair(e)){r=Object.freeze(r.concat(e));let i=await In("key",e.key,t,r);if(i===be)return be;i===Ze&&(e.key=null);let o=await In("value",e.value,t,r);if(o===be)return be;o===Ze&&(e.value=null)}}return s}function pp(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 hp(n,e,t,r){if(typeof t=="function")return t(n,e,r);if(oe.isMap(e))return t.Map?.(n,e,r);if(oe.isSeq(e))return t.Seq?.(n,e,r);if(oe.isPair(e))return t.Pair?.(n,e,r);if(oe.isScalar(e))return t.Scalar?.(n,e,r);if(oe.isAlias(e))return t.Alias?.(n,e,r)}function mp(n,e,t){let r=e[e.length-1];if(oe.isCollection(r))r.items[n]=t;else if(oe.isPair(r))n==="key"?r.key=t:r.value=t;else if(oe.isDocument(r))r.contents=t;else{let s=oe.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}wl.visit=yi;wl.visitAsync=bi});var vl=C(yp=>{"use strict";var gp=U(),NS=$r(),$S={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},LS=n=>n.replace(/[!,[\]{}]/g,e=>$S[e]),Lr=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+LS(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&&gp.isNode(e.contents)){let i={};NS.visit(e.contents,(o,a)=>{gp.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
- `)}};Lr.defaultYaml={explicit:!1,version:"1.2"};Lr.defaultTags={"!!":"tag:yaml.org,2002:"};yp.Directives=Lr});var wi=C(Mr=>{"use strict";var bp=U(),MS=$r();function BS(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 wp(n){let e=new Set;return MS.visit(n,{Value(t,r){r.anchor&&e.add(r.anchor)}}),e}function vp(n,e){for(let t=1;;++t){let r=`${n}${t}`;if(!e.has(r))return r}}function DS(n,e){let t=[],r=new Map,s=null;return{onAnchor:i=>{t.push(i),s??(s=wp(n));let o=vp(e,s);return s.add(o),o},setAnchors:()=>{for(let i of t){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(bp.isScalar(o.node)||bp.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}}Mr.anchorIsValid=BS;Mr.anchorNames=wp;Mr.createNodeAnchors=DS;Mr.findNewAnchor=vp});var Sl=C(Sp=>{"use strict";function Br(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=Br(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=Br(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=Br(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=Br(n,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return n.call(e,t,r)}Sp.applyReviver=Br});var kt=C(xp=>{"use strict";var jS=U();function kp(n,e,t){if(Array.isArray(n))return n.map((r,s)=>kp(r,String(s),t));if(n&&typeof n.toJSON=="function"){if(!t||!jS.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}xp.toJS=kp});var vi=C(Ap=>{"use strict";var FS=Sl(),Ep=U(),US=kt(),kl=class{constructor(e){Object.defineProperty(this,Ep.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(!Ep.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=US.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?FS.applyReviver(i,{"":a},"",a):a}};Ap.NodeBase=kl});var Dr=C(Tp=>{"use strict";var qS=wi(),JS=$r(),Nn=U(),WS=vi(),KS=kt(),xl=class extends WS.NodeBase{constructor(e){super(Nn.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=[],JS.visit(e,{Node:(i,o)=>{(Nn.isAlias(o)||Nn.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||(KS.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=Si(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(qS.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 Si(n,e,t){if(Nn.isAlias(e)){let r=e.resolve(n),s=t&&r&&t.get(r);return s?s.count*s.aliasCount:0}else if(Nn.isCollection(e)){let r=0;for(let s of e.items){let i=Si(n,s,t);i>r&&(r=i)}return r}else if(Nn.isPair(e)){let r=Si(n,e.key,t),s=Si(n,e.value,t);return Math.max(r,s)}return 1}Tp.Alias=xl});var ne=C(El=>{"use strict";var HS=U(),YS=vi(),VS=kt(),zS=n=>!n||typeof n!="function"&&typeof n!="object",xt=class extends YS.NodeBase{constructor(e){super(HS.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:VS.toJS(this.value,e,t)}toString(){return String(this.value)}};xt.BLOCK_FOLDED="BLOCK_FOLDED";xt.BLOCK_LITERAL="BLOCK_LITERAL";xt.PLAIN="PLAIN";xt.QUOTE_DOUBLE="QUOTE_DOUBLE";xt.QUOTE_SINGLE="QUOTE_SINGLE";El.Scalar=xt;El.isScalarValue=zS});var jr=C(Op=>{"use strict";var GS=Dr(),Qt=U(),Pp=ne(),XS="tag:yaml.org,2002:";function QS(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 ZS(n,e,t){if(Qt.isDocument(n)&&(n=n.contents),Qt.isNode(n))return n;if(Qt.isPair(n)){let u=t.schema[Qt.MAP].createNode?.(t.schema,null,t);return u.items.push(n),u}(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 GS.Alias(l.anchor);l={anchor:null,node:null},a.set(n,l)}e?.startsWith("!!")&&(e=XS+e.slice(2));let c=QS(n,e,o.tags);if(!c){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){let u=new Pp.Scalar(n);return l&&(l.node=u),u}c=n instanceof Map?o[Qt.MAP]:Symbol.iterator in Object(n)?o[Qt.SEQ]:o[Qt.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 Pp.Scalar(n);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}Op.createNode=ZS});var xi=C(ki=>{"use strict";var ek=jr(),et=U(),tk=vi();function Al(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 ek.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 _p=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done,Tl=class extends tk.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=>et.isNode(r)||et.isPair(r)?r.clone(e):r),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(_p(e))this.add(t);else{let[r,...s]=e,i=this.get(r,!0);if(et.isCollection(i))i.addIn(s,t);else if(i===void 0&&this.schema)this.set(r,Al(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(et.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&&et.isScalar(i)?i.value:i:et.isCollection(i)?i.getIn(s,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!et.isPair(t))return!1;let r=t.value;return r==null||e&&et.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 et.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(et.isCollection(i))i.setIn(s,t);else if(i===void 0&&this.schema)this.set(r,Al(this.schema,s,t));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};ki.Collection=Tl;ki.collectionFromPath=Al;ki.isEmptyPath=_p});var Fr=C(Ei=>{"use strict";var nk=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function Pl(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}var rk=(n,e,t)=>n.endsWith(`
26
- `)?Pl(t,e):t.includes(`
22
+ `}var ip=S(()=>{di();gl();fi()});function $r(n){if(!n.trim())return{};try{return JSON.parse(n)}catch{return{}}}function ap(n){switch(op(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 lp(n){let e=op(n);return e!==void 0&&JS.has(e)?e:void 0}function KS(n){return n.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function yl(n){let e=$r(n??"").description?.trim();if(!e)return WS;let t=KS(e);return(t.length>200?t.slice(0,197)+"...":t).replace(/\n/g," ")}var qS,hi,op,JS,WS,cp=S(()=>{qS="https://assets.typebulb.com",hi=(n,e)=>`${qS}/u/${encodeURIComponent(n)}/${encodeURIComponent(e)}/`,op=n=>/\.[^./\\]+$/.exec(n)?.[0]?.toLowerCase();JS=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);WS="A Typebulb bulb."});var up=S(()=>{});function bl(n,e,t){let s=new RegExp(e).exec(n.slice(t));return s?t+s.index:-1}var dp=S(()=>{});function Lr(n,e,t){let s=new RegExp(e).exec(n.slice(t));return s?t+s.index+s[0].length-1:-1}var fp=S(()=>{});function mi(n,e){let t=new RegExp(e,"g"),r=n.match(t);return r?r.length:0}var pp=S(()=>{});function Mr(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=bl(n,`<${e}[
23
+ >/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=n.slice(o+e.length),l=Lr(a,"^[^<]*[ /]>",0),c=l!==-1&&a[l-1]==="/";if(r&&console.log("[xml-utils] selfClosing:",c),c===!1)if(s){let p=0,g=1,h=0;for(;(l=Lr(a,"[ /]"+e+">",p))!==-1;){let y=a.substring(p,l+1);if(g+=mi(y,"<"+e+`[
24
+ >]`),h+=mi(y,"</"+e+">"),h>=g)break;p=l}}else l=Lr(a,"[ /]"+e+">",0);let f=o+e.length+l+1;if(r&&console.log("[xml-utils] end:",f),f===-1)return;let u=n.slice(o,f),d;return c?d=null:d=u.slice(u.indexOf(">")+1,u.lastIndexOf("<")),{inner:d,outer:u,start:o,end:f}}var wl=S(()=>{dp();fp();pp()});var vl=S(()=>{wl()});var Sl=S(()=>{vl()});var hp=S(()=>{Sl()});var mp=S(()=>{});var gp=S(()=>{up();wl();vl();hp();Sl();mp()});var q=R(de=>{"use strict";var kl=Symbol.for("yaml.alias"),yp=Symbol.for("yaml.document"),gi=Symbol.for("yaml.map"),bp=Symbol.for("yaml.pair"),xl=Symbol.for("yaml.scalar"),yi=Symbol.for("yaml.seq"),at=Symbol.for("yaml.node.type"),VS=n=>!!n&&typeof n=="object"&&n[at]===kl,zS=n=>!!n&&typeof n=="object"&&n[at]===yp,GS=n=>!!n&&typeof n=="object"&&n[at]===gi,XS=n=>!!n&&typeof n=="object"&&n[at]===bp,wp=n=>!!n&&typeof n=="object"&&n[at]===xl,QS=n=>!!n&&typeof n=="object"&&n[at]===yi;function vp(n){if(n&&typeof n=="object")switch(n[at]){case gi:case yi:return!0}return!1}function ZS(n){if(n&&typeof n=="object")switch(n[at]){case kl:case gi:case xl:case yi:return!0}return!1}var ek=n=>(wp(n)||vp(n))&&!!n.anchor;de.ALIAS=kl;de.DOC=yp;de.MAP=gi;de.NODE_TYPE=at;de.PAIR=bp;de.SCALAR=xl;de.SEQ=yi;de.hasAnchor=ek;de.isAlias=VS;de.isCollection=vp;de.isDocument=zS;de.isMap=GS;de.isNode=ZS;de.isPair=XS;de.isScalar=wp;de.isSeq=QS});var Br=R(El=>{"use strict";var oe=q(),ve=Symbol("break visit"),Sp=Symbol("skip children"),et=Symbol("remove node");function bi(n,e){let t=kp(e);oe.isDocument(n)?$n(null,n.contents,t,Object.freeze([n]))===et&&(n.contents=null):$n(null,n,t,Object.freeze([]))}bi.BREAK=ve;bi.SKIP=Sp;bi.REMOVE=et;function $n(n,e,t,r){let s=xp(n,e,t,r);if(oe.isNode(s)||oe.isPair(s))return Ep(n,r,s),$n(n,s,t,r);if(typeof s!="symbol"){if(oe.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=$n(i,e.items[i],t,r);if(typeof o=="number")i=o-1;else{if(o===ve)return ve;o===et&&(e.items.splice(i,1),i-=1)}}}else if(oe.isPair(e)){r=Object.freeze(r.concat(e));let i=$n("key",e.key,t,r);if(i===ve)return ve;i===et&&(e.key=null);let o=$n("value",e.value,t,r);if(o===ve)return ve;o===et&&(e.value=null)}}return s}async function wi(n,e){let t=kp(e);oe.isDocument(n)?await Ln(null,n.contents,t,Object.freeze([n]))===et&&(n.contents=null):await Ln(null,n,t,Object.freeze([]))}wi.BREAK=ve;wi.SKIP=Sp;wi.REMOVE=et;async function Ln(n,e,t,r){let s=await xp(n,e,t,r);if(oe.isNode(s)||oe.isPair(s))return Ep(n,r,s),Ln(n,s,t,r);if(typeof s!="symbol"){if(oe.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Ln(i,e.items[i],t,r);if(typeof o=="number")i=o-1;else{if(o===ve)return ve;o===et&&(e.items.splice(i,1),i-=1)}}}else if(oe.isPair(e)){r=Object.freeze(r.concat(e));let i=await Ln("key",e.key,t,r);if(i===ve)return ve;i===et&&(e.key=null);let o=await Ln("value",e.value,t,r);if(o===ve)return ve;o===et&&(e.value=null)}}return s}function kp(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 xp(n,e,t,r){if(typeof t=="function")return t(n,e,r);if(oe.isMap(e))return t.Map?.(n,e,r);if(oe.isSeq(e))return t.Seq?.(n,e,r);if(oe.isPair(e))return t.Pair?.(n,e,r);if(oe.isScalar(e))return t.Scalar?.(n,e,r);if(oe.isAlias(e))return t.Alias?.(n,e,r)}function Ep(n,e,t){let r=e[e.length-1];if(oe.isCollection(r))r.items[n]=t;else if(oe.isPair(r))n==="key"?r.key=t:r.value=t;else if(oe.isDocument(r))r.contents=t;else{let s=oe.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}El.visit=bi;El.visitAsync=wi});var Al=R(Tp=>{"use strict";var Ap=q(),tk=Br(),nk={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},rk=n=>n.replace(/[!,[\]{}]/g,e=>nk[e]),Dr=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+rk(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&&Ap.isNode(e.contents)){let i={};tk.visit(e.contents,(o,a)=>{Ap.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
+ `)}};Dr.defaultYaml={explicit:!1,version:"1.2"};Dr.defaultTags={"!!":"tag:yaml.org,2002:"};Tp.Directives=Dr});var vi=R(jr=>{"use strict";var Pp=q(),sk=Br();function ik(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 Op(n){let e=new Set;return sk.visit(n,{Value(t,r){r.anchor&&e.add(r.anchor)}}),e}function Cp(n,e){for(let t=1;;++t){let r=`${n}${t}`;if(!e.has(r))return r}}function ok(n,e){let t=[],r=new Map,s=null;return{onAnchor:i=>{t.push(i),s??(s=Op(n));let o=Cp(e,s);return s.add(o),o},setAnchors:()=>{for(let i of t){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(Pp.isScalar(o.node)||Pp.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:r}}jr.anchorIsValid=ik;jr.anchorNames=Op;jr.createNodeAnchors=ok;jr.findNewAnchor=Cp});var Tl=R(_p=>{"use strict";function Fr(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=Fr(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=Fr(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=Fr(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=Fr(n,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return n.call(e,t,r)}_p.applyReviver=Fr});var Et=R(Ip=>{"use strict";var ak=q();function Rp(n,e,t){if(Array.isArray(n))return n.map((r,s)=>Rp(r,String(s),t));if(n&&typeof n.toJSON=="function"){if(!t||!ak.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}Ip.toJS=Rp});var Si=R($p=>{"use strict";var lk=Tl(),Np=q(),ck=Et(),Pl=class{constructor(e){Object.defineProperty(this,Np.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(!Np.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=ck.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?lk.applyReviver(i,{"":a},"",a):a}};$p.NodeBase=Pl});var Ur=R(Lp=>{"use strict";var uk=vi(),dk=Br(),Mn=q(),fk=Si(),pk=Et(),Ol=class extends fk.NodeBase{constructor(e){super(Mn.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=[],dk.visit(e,{Node:(i,o)=>{(Mn.isAlias(o)||Mn.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||(pk.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=ki(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(uk.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 ki(n,e,t){if(Mn.isAlias(e)){let r=e.resolve(n),s=t&&r&&t.get(r);return s?s.count*s.aliasCount:0}else if(Mn.isCollection(e)){let r=0;for(let s of e.items){let i=ki(n,s,t);i>r&&(r=i)}return r}else if(Mn.isPair(e)){let r=ki(n,e.key,t),s=ki(n,e.value,t);return Math.max(r,s)}return 1}Lp.Alias=Ol});var re=R(Cl=>{"use strict";var hk=q(),mk=Si(),gk=Et(),yk=n=>!n||typeof n!="function"&&typeof n!="object",At=class extends mk.NodeBase{constructor(e){super(hk.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:gk.toJS(this.value,e,t)}toString(){return String(this.value)}};At.BLOCK_FOLDED="BLOCK_FOLDED";At.BLOCK_LITERAL="BLOCK_LITERAL";At.PLAIN="PLAIN";At.QUOTE_DOUBLE="QUOTE_DOUBLE";At.QUOTE_SINGLE="QUOTE_SINGLE";Cl.Scalar=At;Cl.isScalarValue=yk});var qr=R(Bp=>{"use strict";var bk=Ur(),en=q(),Mp=re(),wk="tag:yaml.org,2002:";function vk(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 Sk(n,e,t){if(en.isDocument(n)&&(n=n.contents),en.isNode(n))return n;if(en.isPair(n)){let u=t.schema[en.MAP].createNode?.(t.schema,null,t);return u.items.push(n),u}(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 bk.Alias(l.anchor);l={anchor:null,node:null},a.set(n,l)}e?.startsWith("!!")&&(e=wk+e.slice(2));let c=vk(n,e,o.tags);if(!c){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){let u=new Mp.Scalar(n);return l&&(l.node=u),u}c=n instanceof Map?o[en.MAP]:Symbol.iterator in Object(n)?o[en.SEQ]:o[en.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 Mp.Scalar(n);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}Bp.createNode=Sk});var Ei=R(xi=>{"use strict";var kk=qr(),tt=q(),xk=Si();function _l(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 kk.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 Dp=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done,Rl=class extends xk.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=>tt.isNode(r)||tt.isPair(r)?r.clone(e):r),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Dp(e))this.add(t);else{let[r,...s]=e,i=this.get(r,!0);if(tt.isCollection(i))i.addIn(s,t);else if(i===void 0&&this.schema)this.set(r,_l(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(tt.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&&tt.isScalar(i)?i.value:i:tt.isCollection(i)?i.getIn(s,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!tt.isPair(t))return!1;let r=t.value;return r==null||e&&tt.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 tt.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(tt.isCollection(i))i.setIn(s,t);else if(i===void 0&&this.schema)this.set(r,_l(this.schema,s,t));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};xi.Collection=Rl;xi.collectionFromPath=_l;xi.isEmptyPath=Dp});var Jr=R(Ai=>{"use strict";var Ek=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function Il(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}var Ak=(n,e,t)=>n.endsWith(`
26
+ `)?Il(t,e):t.includes(`
27
27
  `)?`
28
- `+Pl(t,e):(n.endsWith(" ")?"":" ")+t;Ei.indentComment=Pl;Ei.lineComment=rk;Ei.stringifyComment=nk});var Rp=C(Ur=>{"use strict";var sk="flow",Ol="block",Ai="quoted";function ik(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={},u=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):u=s-r);let d,p,m=!1,h=-1,b=-1,E=-1;t===Ol&&(h=Cp(n,h,e.length),h!==-1&&(u=h+l));for(let P;P=n[h+=1];){if(t===Ai&&P==="\\"){switch(b=h,n[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}E=h}if(P===`
29
- `)t===Ol&&(h=Cp(n,h,e.length)),u=h+e.length+l,d=void 0;else{if(P===" "&&p&&p!==" "&&p!==`
28
+ `+Il(t,e):(n.endsWith(" ")?"":" ")+t;Ai.indentComment=Il;Ai.lineComment=Ak;Ai.stringifyComment=Ek});var Fp=R(Wr=>{"use strict";var Tk="flow",Nl="block",Ti="quoted";function Pk(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={},u=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):u=s-r);let d,p,g=!1,h=-1,y=-1,E=-1;t===Nl&&(h=jp(n,h,e.length),h!==-1&&(u=h+l));for(let O;O=n[h+=1];){if(t===Ti&&O==="\\"){switch(y=h,n[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}E=h}if(O===`
29
+ `)t===Nl&&(h=jp(n,h,e.length)),u=h+e.length+l,d=void 0;else{if(O===" "&&p&&p!==" "&&p!==`
30
30
  `&&p!==" "){let x=n[h+1];x&&x!==" "&&x!==`
31
- `&&x!==" "&&(d=h)}if(h>=u)if(d)c.push(d),u=d+l,d=void 0;else if(t===Ai){for(;p===" "||p===" ";)p=P,P=n[h+=1],m=!0;let x=h>E+1?h-2:b-1;if(f[x])return n;c.push(x),f[x]=!0,u=x+l,d=void 0}else m=!0}p=P}if(m&&a&&a(),c.length===0)return n;o&&o();let T=n.slice(0,c[0]);for(let P=0;P<c.length;++P){let x=c[P],I=c[P+1]||n.length;x===0?T=`
32
- ${e}${n.slice(0,I)}`:(t===Ai&&f[x]&&(T+=`${n[x]}\\`),T+=`
33
- ${e}${n.slice(x+1,I)}`)}return T}function Cp(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}Ur.FOLD_BLOCK=Ol;Ur.FOLD_FLOW=sk;Ur.FOLD_QUOTED=Ai;Ur.foldFlowLines=ik});var Jr=C(Ip=>{"use strict";var We=ne(),Et=Rp(),Pi=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),Oi=n=>/^(%|---|\.\.\.)/m.test(n);function ok(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 qr(n,e){let t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Oi(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)+`
31
+ `&&x!==" "&&(d=h)}if(h>=u)if(d)c.push(d),u=d+l,d=void 0;else if(t===Ti){for(;p===" "||p===" ";)p=O,O=n[h+=1],g=!0;let x=h>E+1?h-2:y-1;if(f[x])return n;c.push(x),f[x]=!0,u=x+l,d=void 0}else g=!0}p=O}if(g&&a&&a(),c.length===0)return n;o&&o();let P=n.slice(0,c[0]);for(let O=0;O<c.length;++O){let x=c[O],N=c[O+1]||n.length;x===0?P=`
32
+ ${e}${n.slice(0,N)}`:(t===Ti&&f[x]&&(P+=`${n[x]}\\`),P+=`
33
+ ${e}${n.slice(x+1,N)}`)}return P}function jp(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}Wr.FOLD_BLOCK=Nl;Wr.FOLD_FLOW=Tk;Wr.FOLD_QUOTED=Ti;Wr.foldFlowLines=Pk});var Hr=R(Up=>{"use strict";var Ke=re(),Tt=Fp(),Oi=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),Ci=n=>/^(%|---|\.\.\.)/m.test(n);function Ok(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 Kr(n,e){let t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Ci(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
36
 
37
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:Et.foldFlowLines(o,i,Et.FOLD_QUOTED,Pi(e,!1))}function _l(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
39
- `)||/[ \t]\n|\n[ \t]/.test(n))return qr(n,e);let t=e.indent||(Oi(n)?" ":""),r="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
40
- ${t}`)+"'";return e.implicitKey?r:Et.foldFlowLines(r,t,Et.FOLD_FLOW,Pi(e,!1))}function $n(n,e){let{singleQuote:t}=e.options,r;if(t===!1)r=qr;else{let s=n.includes('"'),i=n.includes("'");s&&!i?r=_l:i&&!s?r=qr:r=t?_l:qr}return r(n,e)}var Cl;try{Cl=new RegExp(`(^|(?<!
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:Tt.foldFlowLines(o,i,Tt.FOLD_QUOTED,Oi(e,!1))}function $l(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
39
+ `)||/[ \t]\n|\n[ \t]/.test(n))return Kr(n,e);let t=e.indent||(Ci(n)?" ":""),r="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
40
+ ${t}`)+"'";return e.implicitKey?r:Tt.foldFlowLines(r,t,Tt.FOLD_FLOW,Oi(e,!1))}function Bn(n,e){let{singleQuote:t}=e.options,r;if(t===!1)r=Kr;else{let s=n.includes('"'),i=n.includes("'");s&&!i?r=$l:i&&!s?r=Kr:r=t?$l:Kr}return r(n,e)}var Ll;try{Ll=new RegExp(`(^|(?<!
41
41
  ))
42
42
  +(?!
43
- |$)`,"g")}catch{Cl=/\n+(?!\n|$)/g}function Ti({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 $n(t,r);let c=r.indent||(r.forceBlockIndent||Oi(t)?" ":""),f=o==="literal"?!0:o==="folded"||e===We.Scalar.BLOCK_FOLDED?!1:e===We.Scalar.BLOCK_LITERAL?!0:!ok(t,l,c.length);if(!t)return f?`|
43
+ |$)`,"g")}catch{Ll=/\n+(?!\n|$)/g}function Pi({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 Bn(t,r);let c=r.indent||(r.forceBlockIndent||Ci(t)?" ":""),f=o==="literal"?!0:o==="folded"||e===Ke.Scalar.BLOCK_FOLDED?!1:e===Ke.Scalar.BLOCK_LITERAL?!0:!Ok(t,l,c.length);if(!t)return f?`|
44
44
  `:`>
45
- `;let u,d;for(d=t.length;d>0;--d){let I=t[d-1];if(I!==`
46
- `&&I!==" "&&I!==" ")break}let p=t.substring(d),m=p.indexOf(`
47
- `);m===-1?u="-":t===p||m!==p.length-1?(u="+",i&&i()):u="",p&&(t=t.slice(0,-p.length),p[p.length-1]===`
48
- `&&(p=p.slice(0,-1)),p=p.replace(Cl,`$&${c}`));let h=!1,b,E=-1;for(b=0;b<t.length;++b){let I=t[b];if(I===" ")h=!0;else if(I===`
49
- `)E=b;else break}let T=t.substring(0,E<b?E+1:b);T&&(t=t.substring(T.length),T=T.replace(/\n+/g,`$&${c}`));let x=(h?c?"2":"1":"")+u;if(n&&(x+=" "+a(n.replace(/ ?[\r\n]+/g," ")),s&&s()),!f){let I=t.replace(/\n+/g,`
50
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),R=!1,$=Pi(r,!0);o!=="folded"&&e!==We.Scalar.BLOCK_FOLDED&&($.onOverflow=()=>{R=!0});let A=Et.foldFlowLines(`${T}${I}${p}`,c,Et.FOLD_BLOCK,$);if(!R)return`>${x}
51
- ${c}${A}`}return t=t.replace(/\n+/g,`$&${c}`),`|${x}
52
- ${c}${T}${t}${p}`}function ak(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(`
53
- `)||f&&/[[\]{},]/.test(i))return $n(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||f||!i.includes(`
54
- `)?$n(i,e):Ti(n,e,t,r);if(!a&&!f&&s!==We.Scalar.PLAIN&&i.includes(`
55
- `))return Ti(n,e,t,r);if(Oi(i)){if(l==="")return e.forceBlockIndent=!0,Ti(n,e,t,r);if(a&&l===c)return $n(i,e)}let u=i.replace(/\n+/g,`$&
56
- ${l}`);if(o){let d=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:p,tags:m}=e.doc.schema;if(m.some(d)||p?.some(d))return $n(i,e)}return a?u:Et.foldFlowLines(u,l,Et.FOLD_FLOW,Pi(e,!1))}function lk(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!==We.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=We.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case We.Scalar.BLOCK_FOLDED:case We.Scalar.BLOCK_LITERAL:return s||i?$n(o.value,e):Ti(o,e,t,r);case We.Scalar.QUOTE_DOUBLE:return qr(o.value,e);case We.Scalar.QUOTE_SINGLE:return _l(o.value,e);case We.Scalar.PLAIN:return ak(o,e,t,r);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=s&&f||u;if(c=l(d),c===null)throw new Error(`Unsupported default string type ${d}`)}return c}Ip.stringifyString=lk});var Wr=C(Rl=>{"use strict";var ck=wi(),At=U(),uk=Fr(),dk=Jr();function fk(n,e){let t=Object.assign({blockQuote:!0,commentString:uk.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 pk(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(At.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 hk(n,e,{anchors:t,doc:r}){if(!r.directives)return"";let s=[],i=(At.isScalar(n)||At.isCollection(n))&&n.anchor;i&&ck.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 mk(n,e,t,r){if(At.isPair(n))return n.toString(e,t,r);if(At.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=At.isNode(n)?n:e.doc.createNode(n,{onTagObj:l=>s=l});s??(s=pk(e.doc.schema.tags,i));let o=hk(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):At.isScalar(i)?dk.stringifyString(i,e,t,r):i.toString(e,t,r);return o?At.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
57
- ${e.indent}${a}`:a}Rl.createStringifyContext=fk;Rl.stringify=mk});var Mp=C(Lp=>{"use strict";var at=U(),Np=ne(),$p=Wr(),Kr=Fr();function gk({key:n,value:e},t,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:u}}=t,d=at.isNode(n)&&n.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(at.isCollection(n)||!at.isNode(n)&&typeof n=="object"){let $="With simple keys, collection cannot be used as a key value";throw new Error($)}}let p=!u&&(!n||d&&e==null&&!t.inFlow||at.isCollection(n)||(at.isScalar(n)?n.type===Np.Scalar.BLOCK_FOLDED||n.type===Np.Scalar.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!p&&(u||!i),indent:a+l});let m=!1,h=!1,b=$p.stringify(n,t,()=>m=!0,()=>h=!0);if(!p&&!t.inFlow&&b.length>1024){if(u)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(),b===""?"?":p?`? ${b}`:b}else if(i&&!u||e==null&&p)return b=`? ${b}`,d&&!m?b+=Kr.lineComment(b,t.indent,c(d)):h&&s&&s(),b;m&&(d=null),p?(d&&(b+=Kr.lineComment(b,t.indent,c(d))),b=`? ${b}
58
- ${a}:`):(b=`${b}:`,d&&(b+=Kr.lineComment(b,t.indent,c(d))));let E,T,P;at.isNode(e)?(E=!!e.spaceBefore,T=e.commentBefore,P=e.comment):(E=!1,T=null,P=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!p&&!d&&at.isScalar(e)&&(t.indentAtStart=b.length+1),h=!1,!f&&l.length>=2&&!t.inFlow&&!p&&at.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let x=!1,I=$p.stringify(e,t,()=>x=!0,()=>h=!0),R=" ";if(d||E||T){if(R=E?`
59
- `:"",T){let $=c(T);R+=`
60
- ${Kr.indentComment($,t.indent)}`}I===""&&!t.inFlow?R===`
61
- `&&P&&(R=`
62
-
63
- `):R+=`
64
- ${t.indent}`}else if(!p&&at.isCollection(e)){let $=I[0],A=I.indexOf(`
65
- `),W=A!==-1,Q=t.inFlow??e.flow??e.items.length===0;if(W||!Q){let Z=!1;if(W&&($==="&"||$==="!")){let F=I.indexOf(" ");$==="&"&&F!==-1&&F<A&&I[F+1]==="!"&&(F=I.indexOf(" ",F+1)),(F===-1||A<F)&&(Z=!0)}Z||(R=`
66
- ${t.indent}`)}}else(I===""||I[0]===`
67
- `)&&(R="");return b+=R+I,t.inFlow?x&&r&&r():P&&!x?b+=Kr.lineComment(b,t.indent,c(P)):h&&s&&s(),b}Lp.stringifyPair=gk});var Nl=C(Il=>{"use strict";var Bp=ai("process");function yk(n,...e){n==="debug"&&console.log(...e)}function bk(n,e){(n==="debug"||n==="warn")&&(typeof Bp.emitWarning=="function"?Bp.emitWarning(e):console.warn(e))}Il.debug=yk;Il.warn=bk});var Ii=C(Ri=>{"use strict";var Hr=U(),Dp=ne(),_i="<<",Ci={identify:n=>n===_i||typeof n=="symbol"&&n.description===_i,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Dp.Scalar(Symbol(_i)),{addToJSMap:jp}),stringify:()=>_i},wk=(n,e)=>(Ci.identify(e)||Hr.isScalar(e)&&(!e.type||e.type===Dp.Scalar.PLAIN)&&Ci.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===Ci.tag&&t.default);function jp(n,e,t){if(t=n&&Hr.isAlias(t)?t.resolve(n.doc):t,Hr.isSeq(t))for(let r of t.items)$l(n,e,r);else if(Array.isArray(t))for(let r of t)$l(n,e,r);else $l(n,e,t)}function $l(n,e,t){let r=n&&Hr.isAlias(t)?t.resolve(n.doc):t;if(!Hr.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}Ri.addMergeToJSMap=jp;Ri.isMergeKey=wk;Ri.merge=Ci});var Ml=C(qp=>{"use strict";var vk=Nl(),Fp=Ii(),Sk=Wr(),Up=U(),Ll=kt();function kk(n,e,{key:t,value:r}){if(Up.isNode(t)&&t.addToJSMap)t.addToJSMap(n,e,r);else if(Fp.isMergeKey(n,t))Fp.addMergeToJSMap(n,e,r);else{let s=Ll.toJS(t,"",n);if(e instanceof Map)e.set(s,Ll.toJS(r,s,n));else if(e instanceof Set)e.add(s);else{let i=xk(t,s,n),o=Ll.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 xk(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(Up.isNode(n)&&t?.doc){let r=Sk.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)+'..."'),vk.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)}qp.addPairToJSMap=kk});var Tt=C(Bl=>{"use strict";var Jp=jr(),Ek=Mp(),Ak=Ml(),Ni=U();function Tk(n,e,t){let r=Jp.createNode(n,void 0,t),s=Jp.createNode(e,void 0,t);return new $i(r,s)}var $i=class n{constructor(e,t=null){Object.defineProperty(this,Ni.NODE_TYPE,{value:Ni.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;return Ni.isNode(t)&&(t=t.clone(e)),Ni.isNode(r)&&(r=r.clone(e)),new n(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return Ak.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?Ek.stringifyPair(this,e,t,r):JSON.stringify(this)}};Bl.Pair=$i;Bl.createPair=Tk});var Dl=C(Kp=>{"use strict";var Zt=U(),Wp=Wr(),Li=Fr();function Pk(n,e,t){return(e.inFlow??n.flow?_k:Ok)(n,e,t)}function Ok({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}),u=!1,d=[];for(let m=0;m<e.length;++m){let h=e[m],b=null;if(Zt.isNode(h))!u&&h.spaceBefore&&d.push(""),Mi(t,d,h.commentBefore,u),h.comment&&(b=h.comment);else if(Zt.isPair(h)){let T=Zt.isNode(h.key)?h.key:null;T&&(!u&&T.spaceBefore&&d.push(""),Mi(t,d,T.commentBefore,u))}u=!1;let E=Wp.stringify(h,f,()=>b=null,()=>u=!0);b&&(E+=Li.lineComment(E,i,c(b))),u&&b&&(u=!1),d.push(r+E)}let p;if(d.length===0)p=s.start+s.end;else{p=d[0];for(let m=1;m<d.length;++m){let h=d[m];p+=h?`
45
+ `;let u,d;for(d=t.length;d>0;--d){let N=t[d-1];if(N!==`
46
+ `&&N!==" "&&N!==" ")break}let p=t.substring(d),g=p.indexOf(`
47
+ `);g===-1?u="-":t===p||g!==p.length-1?(u="+",i&&i()):u="",p&&(t=t.slice(0,-p.length),p[p.length-1]===`
48
+ `&&(p=p.slice(0,-1)),p=p.replace(Ll,`$&${c}`));let h=!1,y,E=-1;for(y=0;y<t.length;++y){let N=t[y];if(N===" ")h=!0;else if(N===`
49
+ `)E=y;else break}let P=t.substring(0,E<y?E+1:y);P&&(t=t.substring(P.length),P=P.replace(/\n+/g,`$&${c}`));let x=(h?c?"2":"1":"")+u;if(n&&(x+=" "+a(n.replace(/ ?[\r\n]+/g," ")),s&&s()),!f){let N=t.replace(/\n+/g,`
50
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),I=!1,L=Oi(r,!0);o!=="folded"&&e!==Ke.Scalar.BLOCK_FOLDED&&(L.onOverflow=()=>{I=!0});let T=Tt.foldFlowLines(`${P}${N}${p}`,c,Tt.FOLD_BLOCK,L);if(!I)return`>${x}
51
+ ${c}${T}`}return t=t.replace(/\n+/g,`$&${c}`),`|${x}
52
+ ${c}${P}${t}${p}`}function Ck(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(`
53
+ `)||f&&/[[\]{},]/.test(i))return Bn(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||f||!i.includes(`
54
+ `)?Bn(i,e):Pi(n,e,t,r);if(!a&&!f&&s!==Ke.Scalar.PLAIN&&i.includes(`
55
+ `))return Pi(n,e,t,r);if(Ci(i)){if(l==="")return e.forceBlockIndent=!0,Pi(n,e,t,r);if(a&&l===c)return Bn(i,e)}let u=i.replace(/\n+/g,`$&
56
+ ${l}`);if(o){let d=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:p,tags:g}=e.doc.schema;if(g.some(d)||p?.some(d))return Bn(i,e)}return a?u:Tt.foldFlowLines(u,l,Tt.FOLD_FLOW,Oi(e,!1))}function _k(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?Bn(o.value,e):Pi(o,e,t,r);case Ke.Scalar.QUOTE_DOUBLE:return Kr(o.value,e);case Ke.Scalar.QUOTE_SINGLE:return $l(o.value,e);case Ke.Scalar.PLAIN:return Ck(o,e,t,r);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=s&&f||u;if(c=l(d),c===null)throw new Error(`Unsupported default string type ${d}`)}return c}Up.stringifyString=_k});var Yr=R(Ml=>{"use strict";var Rk=vi(),Pt=q(),Ik=Jr(),Nk=Hr();function $k(n,e){let t=Object.assign({blockQuote:!0,commentString:Ik.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 Lk(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(Pt.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 Mk(n,e,{anchors:t,doc:r}){if(!r.directives)return"";let s=[],i=(Pt.isScalar(n)||Pt.isCollection(n))&&n.anchor;i&&Rk.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 Bk(n,e,t,r){if(Pt.isPair(n))return n.toString(e,t,r);if(Pt.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=Pt.isNode(n)?n:e.doc.createNode(n,{onTagObj:l=>s=l});s??(s=Lk(e.doc.schema.tags,i));let o=Mk(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):Pt.isScalar(i)?Nk.stringifyString(i,e,t,r):i.toString(e,t,r);return o?Pt.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
57
+ ${e.indent}${a}`:a}Ml.createStringifyContext=$k;Ml.stringify=Bk});var Kp=R(Wp=>{"use strict";var lt=q(),qp=re(),Jp=Yr(),Vr=Jr();function Dk({key:n,value:e},t,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:u}}=t,d=lt.isNode(n)&&n.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(lt.isCollection(n)||!lt.isNode(n)&&typeof n=="object"){let L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let p=!u&&(!n||d&&e==null&&!t.inFlow||lt.isCollection(n)||(lt.isScalar(n)?n.type===qp.Scalar.BLOCK_FOLDED||n.type===qp.Scalar.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!p&&(u||!i),indent:a+l});let g=!1,h=!1,y=Jp.stringify(n,t,()=>g=!0,()=>h=!0);if(!p&&!t.inFlow&&y.length>1024){if(u)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 g&&r&&r(),y===""?"?":p?`? ${y}`:y}else if(i&&!u||e==null&&p)return y=`? ${y}`,d&&!g?y+=Vr.lineComment(y,t.indent,c(d)):h&&s&&s(),y;g&&(d=null),p?(d&&(y+=Vr.lineComment(y,t.indent,c(d))),y=`? ${y}
58
+ ${a}:`):(y=`${y}:`,d&&(y+=Vr.lineComment(y,t.indent,c(d))));let E,P,O;lt.isNode(e)?(E=!!e.spaceBefore,P=e.commentBefore,O=e.comment):(E=!1,P=null,O=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!p&&!d&&lt.isScalar(e)&&(t.indentAtStart=y.length+1),h=!1,!f&&l.length>=2&&!t.inFlow&&!p&&lt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let x=!1,N=Jp.stringify(e,t,()=>x=!0,()=>h=!0),I=" ";if(d||E||P){if(I=E?`
59
+ `:"",P){let L=c(P);I+=`
60
+ ${Vr.indentComment(L,t.indent)}`}N===""&&!t.inFlow?I===`
61
+ `&&O&&(I=`
62
+
63
+ `):I+=`
64
+ ${t.indent}`}else if(!p&&lt.isCollection(e)){let L=N[0],T=N.indexOf(`
65
+ `),K=T!==-1,X=t.inFlow??e.flow??e.items.length===0;if(K||!X){let Z=!1;if(K&&(L==="&"||L==="!")){let U=N.indexOf(" ");L==="&"&&U!==-1&&U<T&&N[U+1]==="!"&&(U=N.indexOf(" ",U+1)),(U===-1||T<U)&&(Z=!0)}Z||(I=`
66
+ ${t.indent}`)}}else(N===""||N[0]===`
67
+ `)&&(I="");return y+=I+N,t.inFlow?x&&r&&r():O&&!x?y+=Vr.lineComment(y,t.indent,c(O)):h&&s&&s(),y}Wp.stringifyPair=Dk});var Dl=R(Bl=>{"use strict";var Hp=li("process");function jk(n,...e){n==="debug"&&console.log(...e)}function Fk(n,e){(n==="debug"||n==="warn")&&(typeof Hp.emitWarning=="function"?Hp.emitWarning(e):console.warn(e))}Bl.debug=jk;Bl.warn=Fk});var Ni=R(Ii=>{"use strict";var zr=q(),Yp=re(),_i="<<",Ri={identify:n=>n===_i||typeof n=="symbol"&&n.description===_i,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Yp.Scalar(Symbol(_i)),{addToJSMap:Vp}),stringify:()=>_i},Uk=(n,e)=>(Ri.identify(e)||zr.isScalar(e)&&(!e.type||e.type===Yp.Scalar.PLAIN)&&Ri.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===Ri.tag&&t.default);function Vp(n,e,t){if(t=n&&zr.isAlias(t)?t.resolve(n.doc):t,zr.isSeq(t))for(let r of t.items)jl(n,e,r);else if(Array.isArray(t))for(let r of t)jl(n,e,r);else jl(n,e,t)}function jl(n,e,t){let r=n&&zr.isAlias(t)?t.resolve(n.doc):t;if(!zr.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}Ii.addMergeToJSMap=Vp;Ii.isMergeKey=Uk;Ii.merge=Ri});var Ul=R(Xp=>{"use strict";var qk=Dl(),zp=Ni(),Jk=Yr(),Gp=q(),Fl=Et();function Wk(n,e,{key:t,value:r}){if(Gp.isNode(t)&&t.addToJSMap)t.addToJSMap(n,e,r);else if(zp.isMergeKey(n,t))zp.addMergeToJSMap(n,e,r);else{let s=Fl.toJS(t,"",n);if(e instanceof Map)e.set(s,Fl.toJS(r,s,n));else if(e instanceof Set)e.add(s);else{let i=Kk(t,s,n),o=Fl.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 Kk(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(Gp.isNode(n)&&t?.doc){let r=Jk.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)+'..."'),qk.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)}Xp.addPairToJSMap=Wk});var Ot=R(ql=>{"use strict";var Qp=qr(),Hk=Kp(),Yk=Ul(),$i=q();function Vk(n,e,t){let r=Qp.createNode(n,void 0,t),s=Qp.createNode(e,void 0,t);return new Li(r,s)}var Li=class n{constructor(e,t=null){Object.defineProperty(this,$i.NODE_TYPE,{value:$i.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;return $i.isNode(t)&&(t=t.clone(e)),$i.isNode(r)&&(r=r.clone(e)),new n(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return Yk.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?Hk.stringifyPair(this,e,t,r):JSON.stringify(this)}};ql.Pair=Li;ql.createPair=Vk});var Jl=R(eh=>{"use strict";var tn=q(),Zp=Yr(),Mi=Jr();function zk(n,e,t){return(e.inFlow??n.flow?Xk:Gk)(n,e,t)}function Gk({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}),u=!1,d=[];for(let g=0;g<e.length;++g){let h=e[g],y=null;if(tn.isNode(h))!u&&h.spaceBefore&&d.push(""),Bi(t,d,h.commentBefore,u),h.comment&&(y=h.comment);else if(tn.isPair(h)){let P=tn.isNode(h.key)?h.key:null;P&&(!u&&P.spaceBefore&&d.push(""),Bi(t,d,P.commentBefore,u))}u=!1;let E=Zp.stringify(h,f,()=>y=null,()=>u=!0);y&&(E+=Mi.lineComment(E,i,c(y))),u&&y&&(u=!1),d.push(r+E)}let p;if(d.length===0)p=s.start+s.end;else{p=d[0];for(let g=1;g<d.length;++g){let h=d[g];p+=h?`
68
68
  ${l}${h}`:`
69
69
  `}}return n?(p+=`
70
- `+Li.indentComment(c(n),l),a&&a()):u&&o&&o(),p}function _k({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,u=[];for(let m=0;m<n.length;++m){let h=n[m],b=null;if(Zt.isNode(h))h.spaceBefore&&u.push(""),Mi(e,u,h.commentBefore,!1),h.comment&&(b=h.comment);else if(Zt.isPair(h)){let T=Zt.isNode(h.key)?h.key:null;T&&(T.spaceBefore&&u.push(""),Mi(e,u,T.commentBefore,!1),T.comment&&(c=!0));let P=Zt.isNode(h.value)?h.value:null;P?(P.comment&&(b=P.comment),P.commentBefore&&(c=!0)):h.value==null&&T?.comment&&(b=T.comment)}b&&(c=!0);let E=Wp.stringify(h,l,()=>b=null);m<n.length-1&&(E+=","),b&&(E+=Li.lineComment(E,r,a(b))),!c&&(u.length>f||E.includes(`
71
- `))&&(c=!0),u.push(E),f=u.length}let{start:d,end:p}=t;if(u.length===0)return d+p;if(!c){let m=u.reduce((h,b)=>h+b.length+2,2);c=e.options.lineWidth>0&&m>e.options.lineWidth}if(c){let m=d;for(let h of u)m+=h?`
70
+ `+Mi.indentComment(c(n),l),a&&a()):u&&o&&o(),p}function Xk({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,u=[];for(let g=0;g<n.length;++g){let h=n[g],y=null;if(tn.isNode(h))h.spaceBefore&&u.push(""),Bi(e,u,h.commentBefore,!1),h.comment&&(y=h.comment);else if(tn.isPair(h)){let P=tn.isNode(h.key)?h.key:null;P&&(P.spaceBefore&&u.push(""),Bi(e,u,P.commentBefore,!1),P.comment&&(c=!0));let O=tn.isNode(h.value)?h.value:null;O?(O.comment&&(y=O.comment),O.commentBefore&&(c=!0)):h.value==null&&P?.comment&&(y=P.comment)}y&&(c=!0);let E=Zp.stringify(h,l,()=>y=null);g<n.length-1&&(E+=","),y&&(E+=Mi.lineComment(E,r,a(y))),!c&&(u.length>f||E.includes(`
71
+ `))&&(c=!0),u.push(E),f=u.length}let{start:d,end:p}=t;if(u.length===0)return d+p;if(!c){let g=u.reduce((h,y)=>h+y.length+2,2);c=e.options.lineWidth>0&&g>e.options.lineWidth}if(c){let g=d;for(let h of u)g+=h?`
72
72
  ${i}${s}${h}`:`
73
- `;return`${m}
74
- ${s}${p}`}else return`${d}${o}${u.join(" ")}${o}${p}`}function Mi({indent:n,options:{commentString:e}},t,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=Li.indentComment(e(r),n);t.push(i.trimStart())}}Kp.stringifyCollection=Pk});var Ot=C(Fl=>{"use strict";var Ck=Dl(),Rk=Ml(),Ik=xi(),Pt=U(),Bi=Tt(),Nk=ne();function Yr(n,e){let t=Pt.isScalar(e)?e.value:e;for(let r of n)if(Pt.isPair(r)&&(r.key===e||r.key===t||Pt.isScalar(r.key)&&r.key.value===t))return r}var jl=class extends Ik.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Pt.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(Bi.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;Pt.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new Bi.Pair(e,e?.value):r=new Bi.Pair(e.key,e.value);let s=Yr(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!t)throw new Error(`Key ${r.key} already set`);Pt.isScalar(s.value)&&Nk.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=Yr(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let s=Yr(this.items,e)?.value;return(!t&&Pt.isScalar(s)?s.value:s)??void 0}has(e){return!!Yr(this.items,e)}set(e,t){this.add(new Bi.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)Rk.addPairToJSMap(t,s,i);return s}toString(e,t,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Pt.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})),Ck.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}};Fl.YAMLMap=jl;Fl.findPair=Yr});var Ln=C(Yp=>{"use strict";var $k=U(),Hp=Ot(),Lk={collection:"map",default:!0,nodeClass:Hp.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(n,e){return $k.isMap(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>Hp.YAMLMap.from(n,e,t)};Yp.map=Lk});var _t=C(Vp=>{"use strict";var Mk=jr(),Bk=Dl(),Dk=xi(),ji=U(),jk=ne(),Fk=kt(),Ul=class extends Dk.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ji.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Di(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let r=Di(e);if(typeof r!="number")return;let s=this.items[r];return!t&&ji.isScalar(s)?s.value:s}has(e){let t=Di(e);return typeof t=="number"&&t<this.items.length}set(e,t){let r=Di(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];ji.isScalar(s)&&jk.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(Fk.toJS(i,String(s++),t));return r}toString(e,t,r){return e?Bk.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(Mk.createNode(a,void 0,r))}}return i}};function Di(n){let e=ji.isScalar(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Vp.YAMLSeq=Ul});var Mn=C(Gp=>{"use strict";var Uk=U(),zp=_t(),qk={collection:"seq",default:!0,nodeClass:zp.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(n,e){return Uk.isSeq(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>zp.YAMLSeq.from(n,e,t)};Gp.seq=qk});var Vr=C(Xp=>{"use strict";var Jk=Jr(),Wk={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),Jk.stringifyString(n,e,t,r)}};Xp.string=Wk});var Fi=C(eh=>{"use strict";var Qp=ne(),Zp={identify:n=>n==null,createNode:()=>new Qp.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Qp.Scalar(null),stringify:({source:n},e)=>typeof n=="string"&&Zp.test.test(n)?n:e.options.nullStr};eh.nullTag=Zp});var ql=C(nh=>{"use strict";var Kk=ne(),th={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new Kk.Scalar(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&th.test.test(n)){let r=n[0]==="t"||n[0]==="T";if(e===r)return n}return e?t.options.trueStr:t.options.falseStr}};nh.boolTag=th});var Bn=C(rh=>{"use strict";function Hk({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}rh.stringifyNumber=Hk});var Wl=C(Ui=>{"use strict";var Yk=ne(),Jl=Bn(),Vk={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:Jl.stringifyNumber},zk={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():Jl.stringifyNumber(n)}},Gk={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 Yk.Scalar(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:Jl.stringifyNumber};Ui.float=Gk;Ui.floatExp=zk;Ui.floatNaN=Vk});var Hl=C(Ji=>{"use strict";var sh=Bn(),qi=n=>typeof n=="bigint"||Number.isInteger(n),Kl=(n,e,t,{intAsBigInt:r})=>r?BigInt(n):parseInt(n.substring(e),t);function ih(n,e,t){let{value:r}=n;return qi(r)&&r>=0?t+r.toString(e):sh.stringifyNumber(n)}var Xk={identify:n=>qi(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>Kl(n,2,8,t),stringify:n=>ih(n,8,"0o")},Qk={identify:qi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>Kl(n,0,10,t),stringify:sh.stringifyNumber},Zk={identify:n=>qi(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>Kl(n,2,16,t),stringify:n=>ih(n,16,"0x")};Ji.int=Qk;Ji.intHex=Zk;Ji.intOct=Xk});var ah=C(oh=>{"use strict";var ex=Ln(),tx=Fi(),nx=Mn(),rx=Vr(),sx=ql(),Yl=Wl(),Vl=Hl(),ix=[ex.map,nx.seq,rx.string,tx.nullTag,sx.boolTag,Vl.intOct,Vl.int,Vl.intHex,Yl.floatNaN,Yl.floatExp,Yl.float];oh.schema=ix});var uh=C(ch=>{"use strict";var ox=ne(),ax=Ln(),lx=Mn();function lh(n){return typeof n=="bigint"||Number.isInteger(n)}var Wi=({value:n})=>JSON.stringify(n),cx=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:Wi},{identify:n=>n==null,createNode:()=>new ox.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Wi},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:Wi},{identify:lh,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})=>lh(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:Wi}],ux={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},dx=[ax.map,lx.seq].concat(cx,ux);ch.schema=dx});var Gl=C(dh=>{"use strict";var zr=ai("buffer"),zl=ne(),fx=Jr(),px={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof zr.Buffer=="function")return zr.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 zr.Buffer=="function")a=o instanceof zr.Buffer?o.toString("base64"):zr.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=zl.Scalar.BLOCK_LITERAL),e!==zl.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 u=0,d=0;u<c;++u,d+=l)f[u]=a.substr(d,l);a=f.join(e===zl.Scalar.BLOCK_LITERAL?`
75
- `:" ")}return fx.stringifyString({comment:n,type:e,value:a},r,s,i)}};dh.binary=px});var Yi=C(Hi=>{"use strict";var Ki=U(),Xl=Tt(),hx=ne(),mx=_t();function fh(n,e){if(Ki.isSeq(n))for(let t=0;t<n.items.length;++t){let r=n.items[t];if(!Ki.isPair(r)){if(Ki.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new Xl.Pair(new hx.Scalar(null));if(r.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${r.commentBefore}
73
+ `;return`${g}
74
+ ${s}${p}`}else return`${d}${o}${u.join(" ")}${o}${p}`}function Bi({indent:n,options:{commentString:e}},t,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=Mi.indentComment(e(r),n);t.push(i.trimStart())}}eh.stringifyCollection=zk});var _t=R(Kl=>{"use strict";var Qk=Jl(),Zk=Ul(),ex=Ei(),Ct=q(),Di=Ot(),tx=re();function Gr(n,e){let t=Ct.isScalar(e)?e.value:e;for(let r of n)if(Ct.isPair(r)&&(r.key===e||r.key===t||Ct.isScalar(r.key)&&r.key.value===t))return r}var Wl=class extends ex.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Ct.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(Di.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;Ct.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new Di.Pair(e,e?.value):r=new Di.Pair(e.key,e.value);let s=Gr(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!t)throw new Error(`Key ${r.key} already set`);Ct.isScalar(s.value)&&tx.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=Gr(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let s=Gr(this.items,e)?.value;return(!t&&Ct.isScalar(s)?s.value:s)??void 0}has(e){return!!Gr(this.items,e)}set(e,t){this.add(new Di.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)Zk.addPairToJSMap(t,s,i);return s}toString(e,t,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Ct.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})),Qk.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}};Kl.YAMLMap=Wl;Kl.findPair=Gr});var Dn=R(nh=>{"use strict";var nx=q(),th=_t(),rx={collection:"map",default:!0,nodeClass:th.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(n,e){return nx.isMap(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>th.YAMLMap.from(n,e,t)};nh.map=rx});var Rt=R(rh=>{"use strict";var sx=qr(),ix=Jl(),ox=Ei(),Fi=q(),ax=re(),lx=Et(),Hl=class extends ox.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Fi.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=ji(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let r=ji(e);if(typeof r!="number")return;let s=this.items[r];return!t&&Fi.isScalar(s)?s.value:s}has(e){let t=ji(e);return typeof t=="number"&&t<this.items.length}set(e,t){let r=ji(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];Fi.isScalar(s)&&ax.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(lx.toJS(i,String(s++),t));return r}toString(e,t,r){return e?ix.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(sx.createNode(a,void 0,r))}}return i}};function ji(n){let e=Fi.isScalar(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}rh.YAMLSeq=Hl});var jn=R(ih=>{"use strict";var cx=q(),sh=Rt(),ux={collection:"seq",default:!0,nodeClass:sh.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(n,e){return cx.isSeq(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>sh.YAMLSeq.from(n,e,t)};ih.seq=ux});var Xr=R(oh=>{"use strict";var dx=Hr(),fx={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),dx.stringifyString(n,e,t,r)}};oh.string=fx});var Ui=R(ch=>{"use strict";var ah=re(),lh={identify:n=>n==null,createNode:()=>new ah.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ah.Scalar(null),stringify:({source:n},e)=>typeof n=="string"&&lh.test.test(n)?n:e.options.nullStr};ch.nullTag=lh});var Yl=R(dh=>{"use strict";var px=re(),uh={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new px.Scalar(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&uh.test.test(n)){let r=n[0]==="t"||n[0]==="T";if(e===r)return n}return e?t.options.trueStr:t.options.falseStr}};dh.boolTag=uh});var Fn=R(fh=>{"use strict";function hx({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}fh.stringifyNumber=hx});var zl=R(qi=>{"use strict";var mx=re(),Vl=Fn(),gx={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:Vl.stringifyNumber},yx={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():Vl.stringifyNumber(n)}},bx={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 mx.Scalar(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:Vl.stringifyNumber};qi.float=bx;qi.floatExp=yx;qi.floatNaN=gx});var Xl=R(Wi=>{"use strict";var ph=Fn(),Ji=n=>typeof n=="bigint"||Number.isInteger(n),Gl=(n,e,t,{intAsBigInt:r})=>r?BigInt(n):parseInt(n.substring(e),t);function hh(n,e,t){let{value:r}=n;return Ji(r)&&r>=0?t+r.toString(e):ph.stringifyNumber(n)}var wx={identify:n=>Ji(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>Gl(n,2,8,t),stringify:n=>hh(n,8,"0o")},vx={identify:Ji,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>Gl(n,0,10,t),stringify:ph.stringifyNumber},Sx={identify:n=>Ji(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>Gl(n,2,16,t),stringify:n=>hh(n,16,"0x")};Wi.int=vx;Wi.intHex=Sx;Wi.intOct=wx});var gh=R(mh=>{"use strict";var kx=Dn(),xx=Ui(),Ex=jn(),Ax=Xr(),Tx=Yl(),Ql=zl(),Zl=Xl(),Px=[kx.map,Ex.seq,Ax.string,xx.nullTag,Tx.boolTag,Zl.intOct,Zl.int,Zl.intHex,Ql.floatNaN,Ql.floatExp,Ql.float];mh.schema=Px});var wh=R(bh=>{"use strict";var Ox=re(),Cx=Dn(),_x=jn();function yh(n){return typeof n=="bigint"||Number.isInteger(n)}var Ki=({value:n})=>JSON.stringify(n),Rx=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:Ki},{identify:n=>n==null,createNode:()=>new Ox.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Ki},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:Ki},{identify:yh,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})=>yh(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:Ki}],Ix={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},Nx=[Cx.map,_x.seq].concat(Rx,Ix);bh.schema=Nx});var tc=R(vh=>{"use strict";var Qr=li("buffer"),ec=re(),$x=Hr(),Lx={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof Qr.Buffer=="function")return Qr.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 Qr.Buffer=="function")a=o instanceof Qr.Buffer?o.toString("base64"):Qr.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=ec.Scalar.BLOCK_LITERAL),e!==ec.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 u=0,d=0;u<c;++u,d+=l)f[u]=a.substr(d,l);a=f.join(e===ec.Scalar.BLOCK_LITERAL?`
75
+ `:" ")}return $x.stringifyString({comment:n,type:e,value:a},r,s,i)}};vh.binary=Lx});var Vi=R(Yi=>{"use strict";var Hi=q(),nc=Ot(),Mx=re(),Bx=Rt();function Sh(n,e){if(Hi.isSeq(n))for(let t=0;t<n.items.length;++t){let r=n.items[t];if(!Hi.isPair(r)){if(Hi.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new nc.Pair(new Mx.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]=Ki.isPair(r)?r:new Xl.Pair(r)}}else e("Expected a sequence for this tag");return n}function ph(n,e,t){let{replacer:r}=t,s=new mx.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(Xl.createPair(a,l,t))}return s}var gx={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:fh,createNode:ph};Hi.createPairs=ph;Hi.pairs=gx;Hi.resolvePairs=fh});var ec=C(Zl=>{"use strict";var hh=U(),Ql=kt(),Gr=Ot(),yx=_t(),mh=Yi(),en=class n extends yx.YAMLSeq{constructor(){super(),this.add=Gr.YAMLMap.prototype.add.bind(this),this.delete=Gr.YAMLMap.prototype.delete.bind(this),this.get=Gr.YAMLMap.prototype.get.bind(this),this.has=Gr.YAMLMap.prototype.has.bind(this),this.set=Gr.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(hh.isPair(s)?(i=Ql.toJS(s.key,"",t),o=Ql.toJS(s.value,i,t)):i=Ql.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=mh.createPairs(e,t,r),i=new this;return i.items=s.items,i}};en.tag="tag:yaml.org,2002:omap";var bx={collection:"seq",identify:n=>n instanceof Map,nodeClass:en,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){let t=mh.resolvePairs(n,e),r=[];for(let{key:s}of t.items)hh.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new en,t)},createNode:(n,e,t)=>en.from(n,e,t)};Zl.YAMLOMap=en;Zl.omap=bx});var vh=C(tc=>{"use strict";var gh=ne();function yh({value:n,source:e},t){return e&&(n?bh:wh).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}var bh={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 gh.Scalar(!0),stringify:yh},wh={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 gh.Scalar(!1),stringify:yh};tc.falseTag=wh;tc.trueTag=bh});var Sh=C(Vi=>{"use strict";var wx=ne(),nc=Bn(),vx={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:nc.stringifyNumber},Sx={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():nc.stringifyNumber(n)}},kx={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 wx.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:nc.stringifyNumber};Vi.float=kx;Vi.floatExp=Sx;Vi.floatNaN=vx});var xh=C(Qr=>{"use strict";var kh=Bn(),Xr=n=>typeof n=="bigint"||Number.isInteger(n);function zi(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 rc(n,e,t){let{value:r}=n;if(Xr(r)){let s=r.toString(e);return r<0?"-"+t+s.substr(1):t+s}return kh.stringifyNumber(n)}var xx={identify:Xr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>zi(n,2,2,t),stringify:n=>rc(n,2,"0b")},Ex={identify:Xr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>zi(n,1,8,t),stringify:n=>rc(n,8,"0")},Ax={identify:Xr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>zi(n,0,10,t),stringify:kh.stringifyNumber},Tx={identify:Xr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>zi(n,2,16,t),stringify:n=>rc(n,16,"0x")};Qr.int=Ax;Qr.intBin=xx;Qr.intHex=Tx;Qr.intOct=Ex});var ic=C(sc=>{"use strict";var Qi=U(),Gi=Tt(),Xi=Ot(),tn=class n extends Xi.YAMLMap{constructor(e){super(e),this.tag=n.tag}add(e){let t;Qi.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new Gi.Pair(e.key,null):t=new Gi.Pair(e,null),Xi.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=Xi.findPair(this.items,e);return!t&&Qi.isPair(r)?Qi.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=Xi.findPair(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new Gi.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(Gi.createPair(o,null,r));return i}};tn.tag="tag:yaml.org,2002:set";var Px={collection:"map",identify:n=>n instanceof Set,nodeClass:tn,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>tn.from(n,e,t),resolve(n,e){if(Qi.isMap(n)){if(n.hasAllNullValues(!0))return Object.assign(new tn,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};sc.YAMLSet=tn;sc.set=Px});var ac=C(Zi=>{"use strict";var Ox=Bn();function oc(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 Eh(n){let{value:e}=n,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Ox.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 _x={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})=>oc(n,t),stringify:Eh},Cx={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=>oc(n,!1),stringify:Eh},Ah={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(Ah.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 u=oc(f,!1);Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Zi.floatTime=Cx;Zi.intTime=_x;Zi.timestamp=Ah});var Oh=C(Ph=>{"use strict";var Rx=Ln(),Ix=Fi(),Nx=Mn(),$x=Vr(),Lx=Gl(),Th=vh(),lc=Sh(),eo=xh(),Mx=Ii(),Bx=ec(),Dx=Yi(),jx=ic(),cc=ac(),Fx=[Rx.map,Nx.seq,$x.string,Ix.nullTag,Th.trueTag,Th.falseTag,eo.intBin,eo.intOct,eo.int,eo.intHex,lc.floatNaN,lc.floatExp,lc.float,Lx.binary,Mx.merge,Bx.omap,Dx.pairs,jx.set,cc.intTime,cc.floatTime,cc.timestamp];Ph.schema=Fx});var Dh=C(fc=>{"use strict";var Ih=Ln(),Ux=Fi(),Nh=Mn(),qx=Vr(),Jx=ql(),uc=Wl(),dc=Hl(),Wx=ah(),Kx=uh(),$h=Gl(),Zr=Ii(),Lh=ec(),Mh=Yi(),_h=Oh(),Bh=ic(),to=ac(),Ch=new Map([["core",Wx.schema],["failsafe",[Ih.map,Nh.seq,qx.string]],["json",Kx.schema],["yaml11",_h.schema],["yaml-1.1",_h.schema]]),Rh={binary:$h.binary,bool:Jx.boolTag,float:uc.float,floatExp:uc.floatExp,floatNaN:uc.floatNaN,floatTime:to.floatTime,int:dc.int,intHex:dc.intHex,intOct:dc.intOct,intTime:to.intTime,map:Ih.map,merge:Zr.merge,null:Ux.nullTag,omap:Lh.omap,pairs:Mh.pairs,seq:Nh.seq,set:Bh.set,timestamp:to.timestamp},Hx={"tag:yaml.org,2002:binary":$h.binary,"tag:yaml.org,2002:merge":Zr.merge,"tag:yaml.org,2002:omap":Lh.omap,"tag:yaml.org,2002:pairs":Mh.pairs,"tag:yaml.org,2002:set":Bh.set,"tag:yaml.org,2002:timestamp":to.timestamp};function Yx(n,e,t){let r=Ch.get(e);if(r&&!n)return t&&!r.includes(Zr.merge)?r.concat(Zr.merge):r.slice();let s=r;if(!s)if(Array.isArray(n))s=[];else{let i=Array.from(Ch.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(Zr.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Rh[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Rh).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},[])}fc.coreKnownTags=Hx;fc.getTags=Yx});var mc=C(jh=>{"use strict";var pc=U(),Vx=Ln(),zx=Mn(),Gx=Vr(),no=Dh(),Xx=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0,hc=class n{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?no.getTags(e,"compat"):e?no.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?no.coreKnownTags:{},this.tags=no.getTags(t,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,pc.MAP,{value:Vx.map}),Object.defineProperty(this,pc.SCALAR,{value:Gx.string}),Object.defineProperty(this,pc.SEQ,{value:zx.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Xx:null}clone(){let e=Object.create(n.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};jh.Schema=hc});var Uh=C(Fh=>{"use strict";var Qx=U(),gc=Wr(),es=Fr();function Zx(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=gc.createStringifyContext(n,e),{commentString:i}=s.options;if(n.commentBefore){t.length!==1&&t.unshift("");let l=i(n.commentBefore);t.unshift(es.indentComment(l,""))}let o=!1,a=null;if(n.contents){if(Qx.isNode(n.contents)){if(n.contents.spaceBefore&&r&&t.push(""),n.contents.commentBefore){let f=i(n.contents.commentBefore);t.push(es.indentComment(f,""))}s.forceBlockIndent=!!n.comment,a=n.contents.comment}let l=a?void 0:()=>o=!0,c=gc.stringify(n.contents,s,()=>a=null,l);a&&(c+=es.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(gc.stringify(n.contents,s));if(n.directives?.docEnd)if(n.comment){let l=i(n.comment);l.includes(`
78
- `)?(t.push("..."),t.push(es.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(es.indentComment(i(l),"")))}return t.join(`
77
+ ${i.comment}`:r.comment}r=s}n.items[t]=Hi.isPair(r)?r:new nc.Pair(r)}}else e("Expected a sequence for this tag");return n}function kh(n,e,t){let{replacer:r}=t,s=new Bx.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(nc.createPair(a,l,t))}return s}var Dx={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Sh,createNode:kh};Yi.createPairs=kh;Yi.pairs=Dx;Yi.resolvePairs=Sh});var ic=R(sc=>{"use strict";var xh=q(),rc=Et(),Zr=_t(),jx=Rt(),Eh=Vi(),nn=class n extends jx.YAMLSeq{constructor(){super(),this.add=Zr.YAMLMap.prototype.add.bind(this),this.delete=Zr.YAMLMap.prototype.delete.bind(this),this.get=Zr.YAMLMap.prototype.get.bind(this),this.has=Zr.YAMLMap.prototype.has.bind(this),this.set=Zr.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(xh.isPair(s)?(i=rc.toJS(s.key,"",t),o=rc.toJS(s.value,i,t)):i=rc.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=Eh.createPairs(e,t,r),i=new this;return i.items=s.items,i}};nn.tag="tag:yaml.org,2002:omap";var Fx={collection:"seq",identify:n=>n instanceof Map,nodeClass:nn,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){let t=Eh.resolvePairs(n,e),r=[];for(let{key:s}of t.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 nn,t)},createNode:(n,e,t)=>nn.from(n,e,t)};sc.YAMLOMap=nn;sc.omap=Fx});var Ch=R(oc=>{"use strict";var Ah=re();function Th({value:n,source:e},t){return e&&(n?Ph:Oh).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}var Ph={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 Ah.Scalar(!0),stringify:Th},Oh={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 Ah.Scalar(!1),stringify:Th};oc.falseTag=Oh;oc.trueTag=Ph});var _h=R(zi=>{"use strict";var Ux=re(),ac=Fn(),qx={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:ac.stringifyNumber},Jx={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():ac.stringifyNumber(n)}},Wx={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 Ux.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:ac.stringifyNumber};zi.float=Wx;zi.floatExp=Jx;zi.floatNaN=qx});var Ih=R(ts=>{"use strict";var Rh=Fn(),es=n=>typeof n=="bigint"||Number.isInteger(n);function Gi(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 lc(n,e,t){let{value:r}=n;if(es(r)){let s=r.toString(e);return r<0?"-"+t+s.substr(1):t+s}return Rh.stringifyNumber(n)}var Kx={identify:es,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>Gi(n,2,2,t),stringify:n=>lc(n,2,"0b")},Hx={identify:es,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>Gi(n,1,8,t),stringify:n=>lc(n,8,"0")},Yx={identify:es,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>Gi(n,0,10,t),stringify:Rh.stringifyNumber},Vx={identify:es,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>Gi(n,2,16,t),stringify:n=>lc(n,16,"0x")};ts.int=Yx;ts.intBin=Kx;ts.intHex=Vx;ts.intOct=Hx});var uc=R(cc=>{"use strict";var Zi=q(),Xi=Ot(),Qi=_t(),rn=class n extends Qi.YAMLMap{constructor(e){super(e),this.tag=n.tag}add(e){let t;Zi.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new Xi.Pair(e.key,null):t=new Xi.Pair(e,null),Qi.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=Qi.findPair(this.items,e);return!t&&Zi.isPair(r)?Zi.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=Qi.findPair(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new Xi.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(Xi.createPair(o,null,r));return i}};rn.tag="tag:yaml.org,2002:set";var zx={collection:"map",identify:n=>n instanceof Set,nodeClass:rn,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>rn.from(n,e,t),resolve(n,e){if(Zi.isMap(n)){if(n.hasAllNullValues(!0))return Object.assign(new rn,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};cc.YAMLSet=rn;cc.set=zx});var fc=R(eo=>{"use strict";var Gx=Fn();function dc(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 Nh(n){let{value:e}=n,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Gx.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 Xx={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})=>dc(n,t),stringify:Nh},Qx={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=>dc(n,!1),stringify:Nh},$h={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($h.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 u=dc(f,!1);Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};eo.floatTime=Qx;eo.intTime=Xx;eo.timestamp=$h});var Bh=R(Mh=>{"use strict";var Zx=Dn(),e0=Ui(),t0=jn(),n0=Xr(),r0=tc(),Lh=Ch(),pc=_h(),to=Ih(),s0=Ni(),i0=ic(),o0=Vi(),a0=uc(),hc=fc(),l0=[Zx.map,t0.seq,n0.string,e0.nullTag,Lh.trueTag,Lh.falseTag,to.intBin,to.intOct,to.int,to.intHex,pc.floatNaN,pc.floatExp,pc.float,r0.binary,s0.merge,i0.omap,o0.pairs,a0.set,hc.intTime,hc.floatTime,hc.timestamp];Mh.schema=l0});var Yh=R(yc=>{"use strict";var Uh=Dn(),c0=Ui(),qh=jn(),u0=Xr(),d0=Yl(),mc=zl(),gc=Xl(),f0=gh(),p0=wh(),Jh=tc(),ns=Ni(),Wh=ic(),Kh=Vi(),Dh=Bh(),Hh=uc(),no=fc(),jh=new Map([["core",f0.schema],["failsafe",[Uh.map,qh.seq,u0.string]],["json",p0.schema],["yaml11",Dh.schema],["yaml-1.1",Dh.schema]]),Fh={binary:Jh.binary,bool:d0.boolTag,float:mc.float,floatExp:mc.floatExp,floatNaN:mc.floatNaN,floatTime:no.floatTime,int:gc.int,intHex:gc.intHex,intOct:gc.intOct,intTime:no.intTime,map:Uh.map,merge:ns.merge,null:c0.nullTag,omap:Wh.omap,pairs:Kh.pairs,seq:qh.seq,set:Hh.set,timestamp:no.timestamp},h0={"tag:yaml.org,2002:binary":Jh.binary,"tag:yaml.org,2002:merge":ns.merge,"tag:yaml.org,2002:omap":Wh.omap,"tag:yaml.org,2002:pairs":Kh.pairs,"tag:yaml.org,2002:set":Hh.set,"tag:yaml.org,2002:timestamp":no.timestamp};function m0(n,e,t){let r=jh.get(e);if(r&&!n)return t&&!r.includes(ns.merge)?r.concat(ns.merge):r.slice();let s=r;if(!s)if(Array.isArray(n))s=[];else{let i=Array.from(jh.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(ns.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Fh[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Fh).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},[])}yc.coreKnownTags=h0;yc.getTags=m0});var vc=R(Vh=>{"use strict";var bc=q(),g0=Dn(),y0=jn(),b0=Xr(),ro=Yh(),w0=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0,wc=class n{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?ro.getTags(e,"compat"):e?ro.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?ro.coreKnownTags:{},this.tags=ro.getTags(t,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,bc.MAP,{value:g0.map}),Object.defineProperty(this,bc.SCALAR,{value:b0.string}),Object.defineProperty(this,bc.SEQ,{value:y0.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?w0:null}clone(){let e=Object.create(n.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Vh.Schema=wc});var Gh=R(zh=>{"use strict";var v0=q(),Sc=Yr(),rs=Jr();function S0(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=Sc.createStringifyContext(n,e),{commentString:i}=s.options;if(n.commentBefore){t.length!==1&&t.unshift("");let l=i(n.commentBefore);t.unshift(rs.indentComment(l,""))}let o=!1,a=null;if(n.contents){if(v0.isNode(n.contents)){if(n.contents.spaceBefore&&r&&t.push(""),n.contents.commentBefore){let f=i(n.contents.commentBefore);t.push(rs.indentComment(f,""))}s.forceBlockIndent=!!n.comment,a=n.contents.comment}let l=a?void 0:()=>o=!0,c=Sc.stringify(n.contents,s,()=>a=null,l);a&&(c+=rs.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(Sc.stringify(n.contents,s));if(n.directives?.docEnd)if(n.comment){let l=i(n.comment);l.includes(`
78
+ `)?(t.push("..."),t.push(rs.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(rs.indentComment(i(l),"")))}return t.join(`
79
79
  `)+`
80
- `}Fh.stringifyDocument=Zx});var ts=C(qh=>{"use strict";var e0=Dr(),Dn=xi(),Re=U(),t0=Tt(),n0=kt(),r0=mc(),s0=Uh(),yc=wi(),i0=Sl(),o0=jr(),bc=vl(),wc=class n{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Re.NODE_TYPE,{value:Re.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 bc.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,{[Re.NODE_TYPE]:{value:Re.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=Re.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){jn(this.contents)&&this.contents.add(e)}addIn(e,t){jn(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=yc.anchorNames(this);e.anchor=!t||r.has(t)?yc.findNewAnchor(t||"a",r):t}return new e0.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 b=T=>typeof T=="number"||T instanceof String||T instanceof Number,E=t.filter(b).map(String);E.length>0&&(t=t.concat(E)),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:u,setAnchors:d,sourceObjects:p}=yc.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:u,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},h=o0.createNode(e,f,m);return a&&Re.isCollection(h)&&(h.flow=!0),d(),h}createPair(e,t,r={}){let s=this.createNode(e,null,r),i=this.createNode(t,null,r);return new t0.Pair(s,i)}delete(e){return jn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Dn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):jn(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Re.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Dn.isEmptyPath(e)?!t&&Re.isScalar(this.contents)?this.contents.value:this.contents:Re.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Re.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Dn.isEmptyPath(e)?this.contents!==void 0:Re.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Dn.collectionFromPath(this.schema,[e],t):jn(this.contents)&&this.contents.set(e,t)}setIn(e,t){Dn.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=Dn.collectionFromPath(this.schema,Array.from(e),t):jn(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 bc.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 bc.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 r0.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=n0.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"?i0.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 s0.stringifyDocument(this,e)}};function jn(n){if(Re.isCollection(n))return!0;throw new Error("Expected a YAML collection as document contents")}qh.Document=wc});var ss=C(rs=>{"use strict";var ns=class extends Error{constructor(e,t,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=t}},vc=class extends ns{constructor(e,t,r){super("YAMLParseError",e,t,r)}},Sc=class extends ns{constructor(e,t,r){super("YAMLWarning",e,t,r)}},a0=(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
80
+ `}zh.stringifyDocument=S0});var ss=R(Xh=>{"use strict";var k0=Ur(),Un=Ei(),Ie=q(),x0=Ot(),E0=Et(),A0=vc(),T0=Gh(),kc=vi(),P0=Tl(),O0=qr(),xc=Al(),Ec=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 xc.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){qn(this.contents)&&this.contents.add(e)}addIn(e,t){qn(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=kc.anchorNames(this);e.anchor=!t||r.has(t)?kc.findNewAnchor(t||"a",r):t}return new k0.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=P=>typeof P=="number"||P instanceof String||P instanceof Number,E=t.filter(y).map(String);E.length>0&&(t=t.concat(E)),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:u,setAnchors:d,sourceObjects:p}=kc.createNodeAnchors(this,o||"a"),g={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:u,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},h=O0.createNode(e,f,g);return a&&Ie.isCollection(h)&&(h.flow=!0),d(),h}createPair(e,t,r={}){let s=this.createNode(e,null,r),i=this.createNode(t,null,r);return new x0.Pair(s,i)}delete(e){return qn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Un.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):qn(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 Un.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 Un.isEmptyPath(e)?this.contents!==void 0:Ie.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Un.collectionFromPath(this.schema,[e],t):qn(this.contents)&&this.contents.set(e,t)}setIn(e,t){Un.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=Un.collectionFromPath(this.schema,Array.from(e),t):qn(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 xc.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 xc.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 A0.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=E0.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"?P0.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 T0.stringifyDocument(this,e)}};function qn(n){if(Ie.isCollection(n))return!0;throw new Error("Expected a YAML collection as document contents")}Xh.Document=Ec});var as=R(os=>{"use strict";var is=class extends Error{constructor(e,t,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=t}},Ac=class extends is{constructor(e,t,r){super("YAMLParseError",e,t,r)}},Tc=class extends is{constructor(e,t,r){super("YAMLWarning",e,t,r)}},C0=(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
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+=`:
82
82
 
83
83
  ${o}
84
84
  ${c}
85
- `}};rs.YAMLError=ns;rs.YAMLParseError=vc;rs.YAMLWarning=Sc;rs.prettifyError=a0});var is=C(Jh=>{"use strict";function l0(n,{flow:e,indicator:t,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,u="",d="",p=!1,m=!1,h=null,b=null,E=null,T=null,P=null,x=null,I=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 W=A.source.substring(1)||" ";u?u+=d+W:u=W,d="",c=!1;break}case"newline":c?u?u+=A.source:(!x||t!=="seq-item-ind")&&(l=!0):d+=A.source,c=!0,p=!0,(b||E)&&(T=A),f=!0;break;case"anchor":b&&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),b=A,I??(I=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,I??(I=A.offset),c=!1,f=!1,m=!0;break}case t:(b||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=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 R=n[n.length-1],$=R?R.offset+R.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:x,spaceBefore:l,comment:u,hasNewline:p,anchor:b,tag:E,newlineAfterProp:T,end:$,start:I??$}}Jh.resolveProps=l0});var ro=C(Wh=>{"use strict";function kc(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(kc(e.key)||kc(e.value))return!0}return!1;default:return!0}}Wh.containsNewline=kc});var xc=C(Kh=>{"use strict";var c0=ro();function u0(n,e,t){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===n&&(r.source==="]"||r.source==="}")&&c0.containsNewline(e)&&t(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Kh.flowIndentCheck=u0});var Ec=C(Yh=>{"use strict";var Hh=U();function d0(n,e,t){let{uniqueKeys:r}=n.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||Hh.isScalar(i)&&Hh.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,t))}Yh.mapIncludes=d0});var Zh=C(Qh=>{"use strict";var Vh=Tt(),f0=Ot(),zh=is(),p0=ro(),Gh=xc(),h0=Ec(),Xh="All mapping items must start at the same column";function m0({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=i?.nodeClass??f0.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:u,key:d,sep:p,value:m}=f,h=zh.resolveProps(u,{indicator:"explicit-key-ind",next:d??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),b=!h.found;if(b){if(d&&(d.type==="block-seq"?s(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==r.indent&&s(l,"BAD_INDENT",Xh)),!h.anchor&&!h.tag&&!p){c=h.end,h.comment&&(a.comment?a.comment+=`
87
- `+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||p0.containsNewline(d))&&s(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&s(l,"BAD_INDENT",Xh);t.atKey=!0;let E=h.end,T=d?n(t,d,h,s):e(t,E,u,null,h,s);t.schema.compat&&Gh.flowIndentCheck(r.indent,d,s),t.atKey=!1,h0.mapIncludes(t,a.items,T)&&s(E,"DUPLICATE_KEY","Map keys must be unique");let P=zh.resolveProps(p??[],{indicator:"map-value-ind",next:m,offset:T.range[2],onError:s,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(l=P.end,P.found){b&&(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(T.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?n(t,m,P,s):e(t,l,p,null,P,s);t.schema.compat&&Gh.flowIndentCheck(r.indent,m,s),l=x.range[2];let I=new Vh.Pair(T,x);t.options.keepSourceTokens&&(I.srcToken=f),a.items.push(I)}else{b&&s(T.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),P.comment&&(T.comment?T.comment+=`
88
- `+P.comment:T.comment=P.comment);let x=new Vh.Pair(T);t.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}Qh.resolveBlockMap=m0});var tm=C(em=>{"use strict";var g0=_t(),y0=is(),b0=xc();function w0({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=i?.nodeClass??g0.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:u}of r.items){let d=y0.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?s(d.end,"BAD_INDENT","All sequence items must start at the same column"):s(l,"MISSING_CHAR","Sequence item without - indicator");else{c=d.end,d.comment&&(a.comment=d.comment);continue}let p=u?n(t,u,d,s):e(t,d.end,f,null,d,s);t.schema.compat&&b0.flowIndentCheck(r.indent,u,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}em.resolveBlockSeq=w0});var Fn=C(nm=>{"use strict";function v0(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}}nm.resolveEnd=v0});var om=C(im=>{"use strict";var S0=U(),k0=Tt(),rm=Ot(),x0=_t(),E0=Fn(),sm=is(),A0=ro(),T0=Ec(),Ac="Block collections are not allowed within flow collections",Tc=n=>n&&(n.type==="block-map"||n.type==="block-seq");function P0({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?rm.YAMLMap:x0.YAMLSeq),c=new l(t.schema);c.flow=!0;let f=t.atRoot;f&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let u=r.offset+r.start.source.length;for(let b=0;b<r.items.length;++b){let E=r.items[b],{start:T,key:P,sep:x,value:I}=E,R=sm.resolveProps(T,{flow:a,indicator:"explicit-key-ind",next:P??x?.[0],offset:u,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!R.found){if(!R.anchor&&!R.tag&&!x&&!I){b===0&&R.comma?s(R.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):b<r.items.length-1&&s(R.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),R.comment&&(c.comment?c.comment+=`
89
- `+R.comment:c.comment=R.comment),u=R.end;continue}!o&&t.options.strict&&A0.containsNewline(P)&&s(P,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(b===0)R.comma&&s(R.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(R.comma||s(R.start,"MISSING_CHAR",`Missing , between ${a} items`),R.comment){let $="";e:for(let A of T)switch(A.type){case"comma":case"space":break;case"comment":$=A.source.substring(1);break e;default:break e}if($){let A=c.items[c.items.length-1];S0.isPair(A)&&(A=A.value??A.key),A.comment?A.comment+=`
90
- `+$:A.comment=$,R.comment=R.comment.substring($.length+1)}}if(!o&&!x&&!R.found){let $=I?n(t,I,R,s):e(t,R.end,x,null,R,s);c.items.push($),u=$.range[2],Tc(I)&&s($.range,"BLOCK_IN_FLOW",Ac)}else{t.atKey=!0;let $=R.end,A=P?n(t,P,R,s):e(t,$,T,null,R,s);Tc(P)&&s(A.range,"BLOCK_IN_FLOW",Ac),t.atKey=!1;let W=sm.resolveProps(x??[],{flow:a,indicator:"map-value-ind",next:I,offset:A.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(W.found){if(!o&&!R.found&&t.options.strict){if(x)for(let F of x){if(F===W.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}}R.start<W.found.offset-1024&&s(W.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else I&&("source"in I&&I.source?.[0]===":"?s(I,"MISSING_CHAR",`Missing space after : in ${a}`):s(W.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let Q=I?n(t,I,W,s):W.found?e(t,W.end,x,null,W,s):null;Q?Tc(I)&&s(Q.range,"BLOCK_IN_FLOW",Ac):W.comment&&(A.comment?A.comment+=`
91
- `+W.comment:A.comment=W.comment);let Z=new k0.Pair(A,Q);if(t.options.keepSourceTokens&&(Z.srcToken=E),o){let F=c;T0.mapIncludes(t,F.items,A)&&s($,"DUPLICATE_KEY","Map keys must be unique"),F.items.push(Z)}else{let F=new rm.YAMLMap(t.schema);F.flow=!0,F.items.push(Z);let ye=(Q??A).range;F.range=[A.range[0],ye[1],ye[2]],c.items.push(F)}u=Q?Q.range[2]:W.end}}let d=o?"}":"]",[p,...m]=r.end,h=u;if(p?.source===d)h=p.offset+p.source.length;else{let b=a[0].toUpperCase()+a.substring(1),E=f?`${b} must end with a ${d}`:`${b} in block collection must be sufficiently indented and end with a ${d}`;s(u,f?"MISSING_CHAR":"BAD_INDENT",E),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){let b=E0.resolveEnd(m,h,t.options.strict,s);b.comment&&(c.comment?c.comment+=`
92
- `+b.comment:c.comment=b.comment),c.range=[r.offset,h,b.offset]}else c.range=[r.offset,h,h];return c}im.resolveFlowCollection=P0});var lm=C(am=>{"use strict";var O0=U(),_0=ne(),C0=Ot(),R0=_t(),I0=Zh(),N0=tm(),$0=om();function Pc(n,e,t,r,s,i){let o=t.type==="block-map"?I0.resolveBlockMap(n,e,t,r,i):t.type==="block-seq"?N0.resolveBlockSeq(n,e,t,r,i):$0.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 L0(n,e,t,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,d=>s(i,"TAG_RESOLVE_FAILED",d)):null;if(t.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=r,m=d&&i?d.offset>i.offset?d:i:d??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===C0.YAMLMap.tagName&&a==="map"||o===R0.YAMLSeq.tagName&&a==="seq")return Pc(n,e,t,s,o);let l=e.schema.tags.find(d=>d.tag===o&&d.collection===a);if(!l){let d=e.schema.knownTags[o];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),l=d;else return d?s(i,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Pc(n,e,t,s,o)}let c=Pc(n,e,t,s,o,l),f=l.resolve?.(c,d=>s(i,"TAG_RESOLVE_FAILED",d),e.options)??c,u=O0.isNode(f)?f:new _0.Scalar(f);return u.range=c.range,u.tag=o,l?.format&&(u.format=l.format),u}am.composeCollection=L0});var _c=C(cm=>{"use strict";var Oc=ne();function M0(n,e,t){let r=e.offset,s=B0(e,n.options.strict,t);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?Oc.Scalar.BLOCK_FOLDED:Oc.Scalar.BLOCK_LITERAL,o=e.source?D0(e.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let b=o[h][1];if(b===""||b==="\r")a=h;else break}if(a===0){let h=s.chomp==="+"&&o.length>0?`
93
- `.repeat(Math.max(1,o.length-1)):"",b=r+s.length;return e.source&&(b+=e.source.length),{value:h,type:i,comment:s.comment,range:[r,b,b]}}let l=e.indent+s.indent,c=e.offset+s.length,f=0;for(let h=0;h<a;++h){let[b,E]=o[h];if(E===""||E==="\r")s.indent===0&&b.length>l&&(l=b.length);else{b.length<l&&t(c+b.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(l=b.length),f=h,l===0&&!n.atRoot&&t(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=b.length+E.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>l&&(a=h+1);let u="",d="",p=!1;for(let h=0;h<f;++h)u+=o[h][0].slice(l)+`
94
- `;for(let h=f;h<a;++h){let[b,E]=o[h];c+=b.length+E.length+1;let T=E[E.length-1]==="\r";if(T&&(E=E.slice(0,-1)),E&&b.length<l){let x=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;t(c-E.length-(T?2:1),"BAD_INDENT",x),b=""}i===Oc.Scalar.BLOCK_LITERAL?(u+=d+b.slice(l)+E,d=`
95
- `):b.length>l||E[0]===" "?(d===" "?d=`
85
+ `}};os.YAMLError=is;os.YAMLParseError=Ac;os.YAMLWarning=Tc;os.prettifyError=C0});var ls=R(Qh=>{"use strict";function _0(n,{flow:e,indicator:t,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,u="",d="",p=!1,g=!1,h=null,y=null,E=null,P=null,O=null,x=null,N=null;for(let T of n)switch(g&&(T.type!=="space"&&T.type!=="newline"&&T.type!=="comma"&&i(T.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),h&&(c&&T.type!=="comment"&&T.type!=="newline"&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),T.type){case"space":!e&&(t!=="doc-start"||r?.type!=="flow-collection")&&T.source.includes(" ")&&(h=T),f=!0;break;case"comment":{f||i(T,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let K=T.source.substring(1)||" ";u?u+=d+K:u=K,d="",c=!1;break}case"newline":c?u?u+=T.source:(!x||t!=="seq-item-ind")&&(l=!0):d+=T.source,c=!0,p=!0,(y||E)&&(P=T),f=!0;break;case"anchor":y&&i(T,"MULTIPLE_ANCHORS","A node can have at most one anchor"),T.source.endsWith(":")&&i(T.offset+T.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=T,N??(N=T.offset),c=!1,f=!1,g=!0;break;case"tag":{E&&i(T,"MULTIPLE_TAGS","A node can have at most one tag"),E=T,N??(N=T.offset),c=!1,f=!1,g=!0;break}case t:(y||E)&&i(T,"BAD_PROP_ORDER",`Anchors and tags must be after the ${T.source} indicator`),x&&i(T,"UNEXPECTED_TOKEN",`Unexpected ${T.source} in ${e??"collection"}`),x=T,c=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){O&&i(T,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),O=T,c=!1,f=!1;break}default:i(T,"UNEXPECTED_TOKEN",`Unexpected ${T.type} token`),c=!1,f=!1}let I=n[n.length-1],L=I?I.offset+I.source.length:s;return g&&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:O,found:x,spaceBefore:l,comment:u,hasNewline:p,anchor:y,tag:E,newlineAfterProp:P,end:L,start:N??L}}Qh.resolveProps=_0});var so=R(Zh=>{"use strict";function Pc(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(Pc(e.key)||Pc(e.value))return!0}return!1;default:return!0}}Zh.containsNewline=Pc});var Oc=R(em=>{"use strict";var R0=so();function I0(n,e,t){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===n&&(r.source==="]"||r.source==="}")&&R0.containsNewline(e)&&t(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}em.flowIndentCheck=I0});var Cc=R(nm=>{"use strict";var tm=q();function N0(n,e,t){let{uniqueKeys:r}=n.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||tm.isScalar(i)&&tm.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,t))}nm.mapIncludes=N0});var lm=R(am=>{"use strict";var rm=Ot(),$0=_t(),sm=ls(),L0=so(),im=Oc(),M0=Cc(),om="All mapping items must start at the same column";function B0({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=i?.nodeClass??$0.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:u,key:d,sep:p,value:g}=f,h=sm.resolveProps(u,{indicator:"explicit-key-ind",next:d??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),y=!h.found;if(y){if(d&&(d.type==="block-seq"?s(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==r.indent&&s(l,"BAD_INDENT",om)),!h.anchor&&!h.tag&&!p){c=h.end,h.comment&&(a.comment?a.comment+=`
87
+ `+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||L0.containsNewline(d))&&s(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&s(l,"BAD_INDENT",om);t.atKey=!0;let E=h.end,P=d?n(t,d,h,s):e(t,E,u,null,h,s);t.schema.compat&&im.flowIndentCheck(r.indent,d,s),t.atKey=!1,M0.mapIncludes(t,a.items,P)&&s(E,"DUPLICATE_KEY","Map keys must be unique");let O=sm.resolveProps(p??[],{indicator:"map-value-ind",next:g,offset:P.range[2],onError:s,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(l=O.end,O.found){y&&(g?.type==="block-map"&&!O.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&h.start<O.found.offset-1024&&s(P.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let x=g?n(t,g,O,s):e(t,l,p,null,O,s);t.schema.compat&&im.flowIndentCheck(r.indent,g,s),l=x.range[2];let N=new rm.Pair(P,x);t.options.keepSourceTokens&&(N.srcToken=f),a.items.push(N)}else{y&&s(P.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),O.comment&&(P.comment?P.comment+=`
88
+ `+O.comment:P.comment=O.comment);let x=new rm.Pair(P);t.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}am.resolveBlockMap=B0});var um=R(cm=>{"use strict";var D0=Rt(),j0=ls(),F0=Oc();function U0({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=i?.nodeClass??D0.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:u}of r.items){let d=j0.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?s(d.end,"BAD_INDENT","All sequence items must start at the same column"):s(l,"MISSING_CHAR","Sequence item without - indicator");else{c=d.end,d.comment&&(a.comment=d.comment);continue}let p=u?n(t,u,d,s):e(t,d.end,f,null,d,s);t.schema.compat&&F0.flowIndentCheck(r.indent,u,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}cm.resolveBlockSeq=U0});var Jn=R(dm=>{"use strict";function q0(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}}dm.resolveEnd=q0});var mm=R(hm=>{"use strict";var J0=q(),W0=Ot(),fm=_t(),K0=Rt(),H0=Jn(),pm=ls(),Y0=so(),V0=Cc(),_c="Block collections are not allowed within flow collections",Rc=n=>n&&(n.type==="block-map"||n.type==="block-seq");function z0({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?fm.YAMLMap:K0.YAMLSeq),c=new l(t.schema);c.flow=!0;let f=t.atRoot;f&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let u=r.offset+r.start.source.length;for(let y=0;y<r.items.length;++y){let E=r.items[y],{start:P,key:O,sep:x,value:N}=E,I=pm.resolveProps(P,{flow:a,indicator:"explicit-key-ind",next:O??x?.[0],offset:u,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!I.found){if(!I.anchor&&!I.tag&&!x&&!N){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),u=I.end;continue}!o&&t.options.strict&&Y0.containsNewline(O)&&s(O,"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 T of P)switch(T.type){case"comma":case"space":break;case"comment":L=T.source.substring(1);break e;default:break e}if(L){let T=c.items[c.items.length-1];J0.isPair(T)&&(T=T.value??T.key),T.comment?T.comment+=`
90
+ `+L:T.comment=L,I.comment=I.comment.substring(L.length+1)}}if(!o&&!x&&!I.found){let L=N?n(t,N,I,s):e(t,I.end,x,null,I,s);c.items.push(L),u=L.range[2],Rc(N)&&s(L.range,"BLOCK_IN_FLOW",_c)}else{t.atKey=!0;let L=I.end,T=O?n(t,O,I,s):e(t,L,P,null,I,s);Rc(O)&&s(T.range,"BLOCK_IN_FLOW",_c),t.atKey=!1;let K=pm.resolveProps(x??[],{flow:a,indicator:"map-value-ind",next:N,offset:T.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(K.found){if(!o&&!I.found&&t.options.strict){if(x)for(let U of x){if(U===K.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<K.found.offset-1024&&s(K.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else N&&("source"in N&&N.source?.[0]===":"?s(N,"MISSING_CHAR",`Missing space after : in ${a}`):s(K.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let X=N?n(t,N,K,s):K.found?e(t,K.end,x,null,K,s):null;X?Rc(N)&&s(X.range,"BLOCK_IN_FLOW",_c):K.comment&&(T.comment?T.comment+=`
91
+ `+K.comment:T.comment=K.comment);let Z=new W0.Pair(T,X);if(t.options.keepSourceTokens&&(Z.srcToken=E),o){let U=c;V0.mapIncludes(t,U.items,T)&&s(L,"DUPLICATE_KEY","Map keys must be unique"),U.items.push(Z)}else{let U=new fm.YAMLMap(t.schema);U.flow=!0,U.items.push(Z);let ye=(X??T).range;U.range=[T.range[0],ye[1],ye[2]],c.items.push(U)}u=X?X.range[2]:K.end}}let d=o?"}":"]",[p,...g]=r.end,h=u;if(p?.source===d)h=p.offset+p.source.length;else{let y=a[0].toUpperCase()+a.substring(1),E=f?`${y} must end with a ${d}`:`${y} in block collection must be sufficiently indented and end with a ${d}`;s(u,f?"MISSING_CHAR":"BAD_INDENT",E),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let y=H0.resolveEnd(g,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}hm.resolveFlowCollection=z0});var ym=R(gm=>{"use strict";var G0=q(),X0=re(),Q0=_t(),Z0=Rt(),eE=lm(),tE=um(),nE=mm();function Ic(n,e,t,r,s,i){let o=t.type==="block-map"?eE.resolveBlockMap(n,e,t,r,i):t.type==="block-seq"?tE.resolveBlockSeq(n,e,t,r,i):nE.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 rE(n,e,t,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,d=>s(i,"TAG_RESOLVE_FAILED",d)):null;if(t.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=r,g=d&&i?d.offset>i.offset?d:i:d??i;g&&(!p||p.offset<g.offset)&&s(g,"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===Q0.YAMLMap.tagName&&a==="map"||o===Z0.YAMLSeq.tagName&&a==="seq")return Ic(n,e,t,s,o);let l=e.schema.tags.find(d=>d.tag===o&&d.collection===a);if(!l){let d=e.schema.knownTags[o];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),l=d;else return d?s(i,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Ic(n,e,t,s,o)}let c=Ic(n,e,t,s,o,l),f=l.resolve?.(c,d=>s(i,"TAG_RESOLVE_FAILED",d),e.options)??c,u=G0.isNode(f)?f:new X0.Scalar(f);return u.range=c.range,u.tag=o,l?.format&&(u.format=l.format),u}gm.composeCollection=rE});var $c=R(bm=>{"use strict";var Nc=re();function sE(n,e,t){let r=e.offset,s=iE(e,n.options.strict,t);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?Nc.Scalar.BLOCK_FOLDED:Nc.Scalar.BLOCK_LITERAL,o=e.source?oE(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,E]=o[h];if(E===""||E==="\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+E.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>l&&(a=h+1);let u="",d="",p=!1;for(let h=0;h<f;++h)u+=o[h][0].slice(l)+`
94
+ `;for(let h=f;h<a;++h){let[y,E]=o[h];c+=y.length+E.length+1;let P=E[E.length-1]==="\r";if(P&&(E=E.slice(0,-1)),E&&y.length<l){let x=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;t(c-E.length-(P?2:1),"BAD_INDENT",x),y=""}i===Nc.Scalar.BLOCK_LITERAL?(u+=d+y.slice(l)+E,d=`
95
+ `):y.length>l||E[0]===" "?(d===" "?d=`
96
96
  `:!p&&d===`
97
97
  `&&(d=`
98
98
 
99
- `),u+=d+b.slice(l)+E,d=`
99
+ `),u+=d+y.slice(l)+E,d=`
100
100
  `,p=!0):E===""?d===`
101
101
  `?u+=`
102
102
  `:d=`
@@ -104,73 +104,73 @@ ${c}
104
104
  `+o[h][0].slice(l);u[u.length-1]!==`
105
105
  `&&(u+=`
106
106
  `);break;default:u+=`
107
- `}let m=r+s.length+e.source.length;return{value:u,type:i,comment:s.comment,range:[r,m,m]}}function B0({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 d=1;d<s.length;++d){let p=s[d];if(!a&&(p==="-"||p==="+"))a=p;else{let m=Number(p);!o&&m?o=m:l===-1&&(l=n+d)}}l!==-1&&r(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,f="",u=s.length;for(let d=1;d<e.length;++d){let p=e[d];switch(p.type){case"space":c=!0;case"newline":u+=p.source.length;break;case"comment":t&&!c&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,f=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),u+=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"&&(u+=h.length)}}}return{mode:i,indent:o,chomp:a,comment:f,length:u}}function D0(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}cm.resolveBlockScalar=M0});var Rc=C(dm=>{"use strict";var Cc=ne(),j0=Fn();function F0(n,e,t){let{offset:r,type:s,source:i,end:o}=n,a,l,c=(d,p,m)=>t(r+d,p,m);switch(s){case"scalar":a=Cc.Scalar.PLAIN,l=U0(i,c);break;case"single-quoted-scalar":a=Cc.Scalar.QUOTE_SINGLE,l=q0(i,c);break;case"double-quoted-scalar":a=Cc.Scalar.QUOTE_DOUBLE,l=J0(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,u=j0.resolveEnd(o,f,e,t);return{value:l,type:a,comment:u.comment,range:[r,f,u.offset]}}function U0(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}`),um(n)}function q0(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),um(n.slice(1,-1)).replace(/''/g,"'")}function um(n){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
107
+ `}let g=r+s.length+e.source.length;return{value:u,type:i,comment:s.comment,range:[r,g,g]}}function iE({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 d=1;d<s.length;++d){let p=s[d];if(!a&&(p==="-"||p==="+"))a=p;else{let g=Number(p);!o&&g?o=g:l===-1&&(l=n+d)}}l!==-1&&r(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,f="",u=s.length;for(let d=1;d<e.length;++d){let p=e[d];switch(p.type){case"space":c=!0;case"newline":u+=p.source.length;break;case"comment":t&&!c&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,f=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),u+=p.source.length;break;default:{let g=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",g);let h=p.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:i,indent:o,chomp:a,comment:f,length:u}}function oE(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}bm.resolveBlockScalar=sE});var Mc=R(vm=>{"use strict";var Lc=re(),aE=Jn();function lE(n,e,t){let{offset:r,type:s,source:i,end:o}=n,a,l,c=(d,p,g)=>t(r+d,p,g);switch(s){case"scalar":a=Lc.Scalar.PLAIN,l=cE(i,c);break;case"single-quoted-scalar":a=Lc.Scalar.QUOTE_SINGLE,l=uE(i,c);break;case"double-quoted-scalar":a=Lc.Scalar.QUOTE_DOUBLE,l=dE(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,u=aE.resolveEnd(o,f,e,t);return{value:l,type:a,comment:u.comment,range:[r,f,u.offset]}}function cE(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}`),wm(n)}function uE(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),wm(n.slice(1,-1)).replace(/''/g,"'")}function wm(n){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
108
108
  `,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
109
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===`
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 J0(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=t.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,r=a.exec(n),s+i+(r?.[1]??"")}function dE(n,e){let t="";for(let r=1;r<n.length-1;++r){let s=n[r];if(!(s==="\r"&&n[r+1]===`
112
112
  `))if(s===`
113
- `){let{fold:i,offset:o}=W0(n,r);t+=i,r=o}else if(s==="\\"){let i=n[++r],o=K0[i];if(o)t+=o;else if(i===`
113
+ `){let{fold:i,offset:o}=fE(n,r);t+=i,r=o}else if(s==="\\"){let i=n[++r],o=pE[i];if(o)t+=o;else if(i===`
114
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+=H0(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!==`
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+=hE(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
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 W0(n,e){let t="",r=n[e+1];for(;(r===" "||r===" "||r===`
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 fE(n,e){let t="",r=n[e+1];for(;(r===" "||r===" "||r===`
118
118
  `||r==="\r")&&!(r==="\r"&&n[e+2]!==`
119
119
  `);)r===`
120
120
  `&&(t+=`
121
- `),e+=1,r=n[e+1];return t||(t=" "),{fold:t,offset:e}}var K0={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 H0(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)}dm.resolveFlowScalar=F0});var hm=C(pm=>{"use strict";var nn=U(),fm=ne(),Y0=_c(),V0=Rc();function z0(n,e,t,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?Y0.resolveBlockScalar(n,e,r):V0.resolveFlowScalar(e,n.options.strict,r),l=t?n.directives.tagName(t.source,u=>r(t,"TAG_RESOLVE_FAILED",u)):null,c;n.options.stringKeys&&n.atKey?c=n.schema[nn.SCALAR]:l?c=G0(n.schema,s,l,t,r):e.type==="scalar"?c=X0(n,s,e,r):c=n.schema[nn.SCALAR];let f;try{let u=c.resolve(s,d=>r(t??e,"TAG_RESOLVE_FAILED",d),n.options);f=nn.isScalar(u)?u:new fm.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);r(t??e,"TAG_RESOLVE_FAILED",d),f=new fm.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 G0(n,e,t,r,s){if(t==="!")return n[nn.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[nn.SCALAR])}function X0({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[nn.SCALAR];if(t.compat){let a=t.compat.find(l=>l.default&&l.test?.test(r))??t[nn.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}pm.composeScalar=z0});var gm=C(mm=>{"use strict";function Q0(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}mm.emptyScalarPosition=Q0});var wm=C(Nc=>{"use strict";var Z0=Dr(),eE=U(),tE=lm(),ym=hm(),nE=Fn(),rE=gm(),sE={composeNode:bm,composeEmptyNode:Ic};function bm(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=iE(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=ym.composeScalar(n,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=tE.composeCollection(sE,n,e,t,r),a&&(c.anchor=a.source.substring(1));break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",u),c=Ic(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&&(!eE.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 Ic(n,e,t,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:rE.emptyScalarPosition(e,t,r),indent:-1,source:""},u=ym.composeScalar(n,f,a,c);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(u.spaceBefore=!0),i&&(u.comment=i,u.range[2]=l),u}function iE({options:n},{offset:e,source:t,end:r},s){let i=new Z0.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=nE.resolveEnd(r,o,n.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Nc.composeEmptyNode=Ic;Nc.composeNode=bm});var km=C(Sm=>{"use strict";var oE=ts(),vm=wm(),aE=Fn(),lE=is();function cE(n,e,{offset:t,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},n),l=new oE.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=lE.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?vm.composeNode(c,s,f,o):vm.composeEmptyNode(c,f.end,r,null,f,o);let u=l.contents.range[2],d=aE.resolveEnd(i,u,!1,o);return d.comment&&(l.comment=d.comment),l.range=[t,u,d.offset],l}Sm.composeDoc=cE});var Lc=C(Am=>{"use strict";var uE=ai("process"),dE=vl(),fE=ts(),os=ss(),xm=U(),pE=km(),hE=Fn();function as(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 Em(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?`
121
+ `),e+=1,r=n[e+1];return t||(t=" "),{fold:t,offset:e}}var pE={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 hE(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)}vm.resolveFlowScalar=lE});var xm=R(km=>{"use strict";var sn=q(),Sm=re(),mE=$c(),gE=Mc();function yE(n,e,t,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?mE.resolveBlockScalar(n,e,r):gE.resolveFlowScalar(e,n.options.strict,r),l=t?n.directives.tagName(t.source,u=>r(t,"TAG_RESOLVE_FAILED",u)):null,c;n.options.stringKeys&&n.atKey?c=n.schema[sn.SCALAR]:l?c=bE(n.schema,s,l,t,r):e.type==="scalar"?c=wE(n,s,e,r):c=n.schema[sn.SCALAR];let f;try{let u=c.resolve(s,d=>r(t??e,"TAG_RESOLVE_FAILED",d),n.options);f=sn.isScalar(u)?u:new Sm.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);r(t??e,"TAG_RESOLVE_FAILED",d),f=new Sm.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 bE(n,e,t,r,s){if(t==="!")return n[sn.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[sn.SCALAR])}function wE({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[sn.SCALAR];if(t.compat){let a=t.compat.find(l=>l.default&&l.test?.test(r))??t[sn.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}km.composeScalar=yE});var Am=R(Em=>{"use strict";function vE(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}Em.emptyScalarPosition=vE});var Om=R(Dc=>{"use strict";var SE=Ur(),kE=q(),xE=ym(),Tm=xm(),EE=Jn(),AE=Am(),TE={composeNode:Pm,composeEmptyNode:Bc};function Pm(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=PE(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=Tm.composeScalar(n,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=xE.composeCollection(TE,n,e,t,r),a&&(c.anchor=a.source.substring(1));break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",u),c=Bc(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&&(!kE.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 Bc(n,e,t,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:AE.emptyScalarPosition(e,t,r),indent:-1,source:""},u=Tm.composeScalar(n,f,a,c);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(u.spaceBefore=!0),i&&(u.comment=i,u.range[2]=l),u}function PE({options:n},{offset:e,source:t,end:r},s){let i=new SE.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=EE.resolveEnd(r,o,n.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Dc.composeEmptyNode=Bc;Dc.composeNode=Pm});var Rm=R(_m=>{"use strict";var OE=ss(),Cm=Om(),CE=Jn(),_E=ls();function RE(n,e,{offset:t,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},n),l=new OE.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=_E.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?Cm.composeNode(c,s,f,o):Cm.composeEmptyNode(c,f.end,r,null,f,o);let u=l.contents.range[2],d=CE.resolveEnd(i,u,!1,o);return d.comment&&(l.comment=d.comment),l.range=[t,u,d.offset],l}_m.composeDoc=RE});var Fc=R($m=>{"use strict";var IE=li("process"),NE=Al(),$E=ss(),cs=as(),Im=q(),LE=Rm(),ME=Jn();function us(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 Nm(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?`
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 $c=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,s,i)=>{let o=as(t);i?this.warnings.push(new os.YAMLWarning(o,r,s)):this.errors.push(new os.YAMLParseError(o,r,s))},this.directives=new dE.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:s}=Em(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(xm.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];xm.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${r}
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 jc=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,s,i)=>{let o=us(t);i?this.warnings.push(new cs.YAMLWarning(o,r,s)):this.errors.push(new cs.YAMLParseError(o,r,s))},this.directives=new NE.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:s}=Nm(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(Im.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];Im.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:Em(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(uE.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,r,s)=>{let i=as(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=pE.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 os.YAMLParseError(as(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 os.YAMLParseError(as(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let t=hE.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 os.YAMLParseError(as(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 fE.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}}};Am.Composer=$c});var Om=C(so=>{"use strict";var mE=_c(),gE=Rc(),yE=ss(),Tm=Jr();function bE(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 yE.YAMLParseError([a,a+1],i,o)};switch(n.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return gE.resolveFlowScalar(n,e,r);case"block-scalar":return mE.resolveBlockScalar({options:{strict:e}},n,r)}}return null}function wE(n,e){let{implicitKey:t=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=Tm.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}}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:Nm(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(IE.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,r,s)=>{let i=us(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=LE.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 cs.YAMLParseError(us(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 cs.YAMLParseError(us(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let t=ME.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 cs.YAMLParseError(us(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 $E.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}}};$m.Composer=jc});var Bm=R(io=>{"use strict";var BE=$c(),DE=Mc(),jE=as(),Lm=Hr();function FE(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 jE.YAMLParseError([a,a+1],i,o)};switch(n.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return DE.resolveFlowScalar(n,e,r);case"block-scalar":return BE.resolveBlockScalar({options:{strict:e}},n,r)}}return null}function UE(n,e){let{implicitKey:t=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=Lm.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:`
130
130
  `}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
131
131
  `),f=a.substring(0,c),u=a.substring(c+1)+`
132
- `,d=[{type:"block-scalar-header",offset:i,indent:r,source:f}];return Pm(d,l)||d.push({type:"newline",offset:-1,indent:r,source:`
133
- `}),{type:"block-scalar",offset:i,indent:r,props:d,source:u}}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 vE(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=Tm.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">":SE(n,l);break;case'"':Mc(n,l,"double-quoted-scalar");break;case"'":Mc(n,l,"single-quoted-scalar");break;default:Mc(n,l,"scalar")}}function SE(n,e){let t=e.indexOf(`
132
+ `,d=[{type:"block-scalar-header",offset:i,indent:r,source:f}];return Mm(d,l)||d.push({type:"newline",offset:-1,indent:r,source:`
133
+ `}),{type:"block-scalar",offset:i,indent:r,props:d,source:u}}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 qE(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=Lm.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">":JE(n,l);break;case'"':Uc(n,l,"double-quoted-scalar");break;case"'":Uc(n,l,"single-quoted-scalar");break;default:Uc(n,l,"scalar")}}function JE(n,e){let t=e.indexOf(`
134
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}];Pm(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 Pm(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 Mc(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})}}}so.createScalarToken=wE;so.resolveAsScalar=bE;so.setScalarValue=vE});var Cm=C(_m=>{"use strict";var kE=n=>"type"in n?oo(n):io(n);function oo(n){switch(n.type){case"block-scalar":{let e="";for(let t of n.props)e+=oo(t);return e+n.source}case"block-map":case"block-seq":{let e="";for(let t of n.items)e+=io(t);return e}case"flow-collection":{let e=n.start.source;for(let t of n.items)e+=io(t);for(let t of n.end)e+=t.source;return e}case"document":{let e=io(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 io({start:n,key:e,sep:t,value:r}){let s="";for(let i of n)s+=i.source;if(e&&(s+=oo(e)),t)for(let i of t)s+=i.source;return r&&(s+=oo(r)),s}_m.stringify=kE});var $m=C(Nm=>{"use strict";var Bc=Symbol("break visit"),xE=Symbol("skip children"),Rm=Symbol("remove item");function rn(n,e){"type"in n&&n.type==="document"&&(n={start:n.start,value:n.value}),Im(Object.freeze([]),n,e)}rn.BREAK=Bc;rn.SKIP=xE;rn.REMOVE=Rm;rn.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};rn.parentCollection=(n,e)=>{let t=rn.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 Im(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=Im(Object.freeze(n.concat([[s,o]])),i.items[o],t);if(typeof a=="number")o=a-1;else{if(a===Bc)return Bc;a===Rm&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,n))}}return typeof r=="function"?r(e,n):r}Nm.visit=rn});var ao=C(we=>{"use strict";var Dc=Om(),EE=Cm(),AE=$m(),jc="\uFEFF",Fc="",Uc="",qc="",TE=n=>!!n&&"items"in n,PE=n=>!!n&&(n.type==="scalar"||n.type==="single-quoted-scalar"||n.type==="double-quoted-scalar"||n.type==="block-scalar");function OE(n){switch(n){case jc:return"<BOM>";case Fc:return"<DOC>";case Uc:return"<FLOW_END>";case qc:return"<SCALAR>";default:return JSON.stringify(n)}}function _E(n){switch(n){case jc:return"byte-order-mark";case Fc:return"doc-mode";case Uc:return"flow-error-end";case qc:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
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}];Mm(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 Mm(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 Uc(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})}}}io.createScalarToken=UE;io.resolveAsScalar=FE;io.setScalarValue=qE});var jm=R(Dm=>{"use strict";var WE=n=>"type"in n?ao(n):oo(n);function ao(n){switch(n.type){case"block-scalar":{let e="";for(let t of n.props)e+=ao(t);return e+n.source}case"block-map":case"block-seq":{let e="";for(let t of n.items)e+=oo(t);return e}case"flow-collection":{let e=n.start.source;for(let t of n.items)e+=oo(t);for(let t of n.end)e+=t.source;return e}case"document":{let e=oo(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 oo({start:n,key:e,sep:t,value:r}){let s="";for(let i of n)s+=i.source;if(e&&(s+=ao(e)),t)for(let i of t)s+=i.source;return r&&(s+=ao(r)),s}Dm.stringify=WE});var Jm=R(qm=>{"use strict";var qc=Symbol("break visit"),KE=Symbol("skip children"),Fm=Symbol("remove item");function on(n,e){"type"in n&&n.type==="document"&&(n={start:n.start,value:n.value}),Um(Object.freeze([]),n,e)}on.BREAK=qc;on.SKIP=KE;on.REMOVE=Fm;on.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};on.parentCollection=(n,e)=>{let t=on.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 Um(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=Um(Object.freeze(n.concat([[s,o]])),i.items[o],t);if(typeof a=="number")o=a-1;else{if(a===qc)return qc;a===Fm&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,n))}}return typeof r=="function"?r(e,n):r}qm.visit=on});var lo=R(Se=>{"use strict";var Jc=Bm(),HE=jm(),YE=Jm(),Wc="\uFEFF",Kc="",Hc="",Yc="",VE=n=>!!n&&"items"in n,zE=n=>!!n&&(n.type==="scalar"||n.type==="single-quoted-scalar"||n.type==="double-quoted-scalar"||n.type==="block-scalar");function GE(n){switch(n){case Wc:return"<BOM>";case Kc:return"<DOC>";case Hc:return"<FLOW_END>";case Yc:return"<SCALAR>";default:return JSON.stringify(n)}}function XE(n){switch(n){case Wc:return"byte-order-mark";case Kc:return"doc-mode";case Hc:return"flow-error-end";case Yc: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}we.createScalarToken=Dc.createScalarToken;we.resolveAsScalar=Dc.resolveAsScalar;we.setScalarValue=Dc.setScalarValue;we.stringify=EE.stringify;we.visit=AE.visit;we.BOM=jc;we.DOCUMENT=Fc;we.FLOW_END=Uc;we.SCALAR=qc;we.isCollection=TE;we.isScalar=PE;we.prettyToken=OE;we.tokenType=_E});var Kc=C(Mm=>{"use strict";var ls=ao();function Ke(n){switch(n){case void 0:case" ":case`
140
- `:case"\r":case" ":return!0;default:return!1}}var Lm=new Set("0123456789ABCDEFabcdef"),CE=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),lo=new Set(",[]{}"),RE=new Set(` ,[]{}
141
- \r `),Jc=n=>!n||RE.has(n),Wc=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===`
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}Se.createScalarToken=Jc.createScalarToken;Se.resolveAsScalar=Jc.resolveAsScalar;Se.setScalarValue=Jc.setScalarValue;Se.stringify=HE.stringify;Se.visit=YE.visit;Se.BOM=Wc;Se.DOCUMENT=Kc;Se.FLOW_END=Hc;Se.SCALAR=Yc;Se.isCollection=VE;Se.isScalar=zE;Se.prettyToken=GE;Se.tokenType=XE});var Gc=R(Km=>{"use strict";var ds=lo();function He(n){switch(n){case void 0:case" ":case`
140
+ `:case"\r":case" ":return!0;default:return!1}}var Wm=new Set("0123456789ABCDEFabcdef"),QE=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),co=new Set(",[]{}"),ZE=new Set(` ,[]{}
141
+ \r `),Vc=n=>!n||ZE.has(n),zc=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
142
  `?!0:t==="\r"?this.buffer[e+1]===`
143
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
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==="...")&&Ke(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]===ls.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 ls.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==="...")&&Ke(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&&!Ke(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===":")&&Ke(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(Jc),"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("..."))&&Ke(s[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield ls.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(Jc),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Ke(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(`
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]===ds.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 ds.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(Vc),"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 ds.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(Vc),"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(`
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=>Ke(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`
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
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
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(`
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 ls.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(Ke(i)||e&&lo.has(i))break;t=r}else if(Ke(s)){let i=this.buffer[r+1];if(s==="\r"&&(i===`
153
+ `&&i>=this.pos&&i+1+t>a)e=i;else break}while(!0);return yield ds.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&&co.has(i))break;t=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&&lo.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&&lo.has(s))break;t=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield ls.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(Jc))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,t=this.charAt(1);if(Ke(t)||e&&lo.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(;!Ke(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(CE.has(t))t=this.buffer[++e];else if(t==="%"&&Lm.has(this.buffer[e+1])&&Lm.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]):t=r),i==="#"||e&&co.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&&co.has(s))break;t=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield ds.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(Vc))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,t=this.charAt(1);if(He(t)||e&&co.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(QE.has(t))t=this.buffer[++e];else if(t==="%"&&Wm.has(this.buffer[e+1])&&Wm.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===`
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)}};Mm.Lexer=Wc});var Yc=C(Bm=>{"use strict";var Hc=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}}}};Bm.LineCounter=Hc});var zc=C(qm=>{"use strict";var IE=ai("process"),Dm=ao(),NE=Kc();function Ct(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function jm(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 Um(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 co(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 Un(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 Fm(n){if(n.start.type==="flow-seq-start")for(let e of n.items)e.sep&&!e.value&&!Ct(e.start,"explicit-key-ind")&&!Ct(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Um(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 Vc=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 NE.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,IE.env.LOG_TOKENS&&console.log("|",Dm.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Dm.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"&&Fm(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&&jm(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":{jm(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=co(this.peek(2)),r=Un(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(`
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)}};Km.Lexer=zc});var Qc=R(Hm=>{"use strict";var Xc=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}}}};Hm.LineCounter=Xc});var eu=R(Xm=>{"use strict";var eA=li("process"),Ym=lo(),tA=Gc();function It(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function Vm(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 Gm(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 uo(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 Wn(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 zm(n){if(n.start.type==="flow-seq-start")for(let e of n.items)e.sep&&!e.value&&!It(e.start,"explicit-key-ind")&&!It(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Gm(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 Zc=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 tA.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,eA.env.LOG_TOKENS&&console.log("|",Ym.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Ym.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"&&zm(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&&Vm(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":{Vm(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=uo(this.peek(2)),r=Wn(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
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(Ct(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(Um(t.key)&&!Ct(t.sep,"newline")){let o=Un(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(Ct(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=Un(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]}):Ct(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&&!Ct(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||Ct(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=co(r),i=Un(s);Fm(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(`
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(It(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(Gm(t.key)&&!It(t.sep,"newline")){let o=Wn(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(It(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=Wn(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]}):It(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&&!It(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||It(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=uo(r),i=Wn(s);zm(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
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=co(e),r=Un(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=co(e),r=Un(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())}}};qm.Parser=Vc});var Ym=C(us=>{"use strict";var Jm=Lc(),$E=ts(),cs=ss(),LE=Nl(),ME=U(),BE=Yc(),Wm=zc();function Km(n){let e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new BE.LineCounter||null,prettyErrors:e}}function DE(n,e={}){let{lineCounter:t,prettyErrors:r}=Km(e),s=new Wm.Parser(t?.addNewLine),i=new Jm.Composer(e),o=Array.from(i.compose(s.parse(n)));if(r&&t)for(let a of o)a.errors.forEach(cs.prettifyError(n,t)),a.warnings.forEach(cs.prettifyError(n,t));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Hm(n,e={}){let{lineCounter:t,prettyErrors:r}=Km(e),s=new Wm.Parser(t?.addNewLine),i=new Jm.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 cs.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&t&&(o.errors.forEach(cs.prettifyError(n,t)),o.warnings.forEach(cs.prettifyError(n,t))),o}function jE(n,e,t){let r;typeof e=="function"?r=e:t===void 0&&e&&typeof e=="object"&&(t=e);let s=Hm(n,t);if(!s)return null;if(s.warnings.forEach(i=>LE.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 FE(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 ME.isDocument(n)&&!r?n.toString(t):new $E.Document(n,r,t).toString(t)}us.parse=jE;us.parseAllDocuments=DE;us.parseDocument=Hm;us.stringify=FE});var zm=C(K=>{"use strict";var UE=Lc(),qE=ts(),JE=mc(),Gc=ss(),WE=Dr(),Rt=U(),KE=Tt(),HE=ne(),YE=Ot(),VE=_t(),zE=ao(),GE=Kc(),XE=Yc(),QE=zc(),uo=Ym(),Vm=$r();K.Composer=UE.Composer;K.Document=qE.Document;K.Schema=JE.Schema;K.YAMLError=Gc.YAMLError;K.YAMLParseError=Gc.YAMLParseError;K.YAMLWarning=Gc.YAMLWarning;K.Alias=WE.Alias;K.isAlias=Rt.isAlias;K.isCollection=Rt.isCollection;K.isDocument=Rt.isDocument;K.isMap=Rt.isMap;K.isNode=Rt.isNode;K.isPair=Rt.isPair;K.isScalar=Rt.isScalar;K.isSeq=Rt.isSeq;K.Pair=KE.Pair;K.Scalar=HE.Scalar;K.YAMLMap=YE.YAMLMap;K.YAMLSeq=VE.YAMLSeq;K.CST=zE;K.Lexer=GE.Lexer;K.LineCounter=XE.LineCounter;K.Parser=QE.Parser;K.parse=uo.parse;K.parseAllDocuments=uo.parseAllDocuments;K.parseDocument=uo.parseDocument;K.stringify=uo.stringify;K.visit=Vm.visit;K.visitAsync=Vm.visitAsync});function eA(n){try{return JSON.parse(n.trim()),!0}catch{return!1}}function tA(n){let e=n.trim();if(!e.startsWith("<"))return!1;let t=e.match(ZE);return t?Nr(e,t[1])!==null:!1}function nA(n){let e=n.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let t=Gm.parse(e);return t!==null&&typeof t=="object"}catch{return!1}}function Xm(n){return eA(n)||tA(n)||nA(n)}var Gm,ZE,Xc=v(()=>{ap();Gm=oS(zm(),1),ZE=/<([a-zA-Z_][\w.-]*)/});function rA(n){if(!n?.trim())return[];let e=n.replace(/\r\n/g,`
163
- `),t=e.trim();if(Xm(t))return[{text:t,startLine:1,endLine:e.split(`
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=uo(e),r=Wn(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=uo(e),r=Wn(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())}}};Xm.Parser=Zc});var ng=R(ps=>{"use strict";var Qm=Fc(),nA=ss(),fs=as(),rA=Dl(),sA=q(),iA=Qc(),Zm=eu();function eg(n){let e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new iA.LineCounter||null,prettyErrors:e}}function oA(n,e={}){let{lineCounter:t,prettyErrors:r}=eg(e),s=new Zm.Parser(t?.addNewLine),i=new Qm.Composer(e),o=Array.from(i.compose(s.parse(n)));if(r&&t)for(let a of o)a.errors.forEach(fs.prettifyError(n,t)),a.warnings.forEach(fs.prettifyError(n,t));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function tg(n,e={}){let{lineCounter:t,prettyErrors:r}=eg(e),s=new Zm.Parser(t?.addNewLine),i=new Qm.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 fs.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&t&&(o.errors.forEach(fs.prettifyError(n,t)),o.warnings.forEach(fs.prettifyError(n,t))),o}function aA(n,e,t){let r;typeof e=="function"?r=e:t===void 0&&e&&typeof e=="object"&&(t=e);let s=tg(n,t);if(!s)return null;if(s.warnings.forEach(i=>rA.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 lA(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 sA.isDocument(n)&&!r?n.toString(t):new nA.Document(n,r,t).toString(t)}ps.parse=aA;ps.parseAllDocuments=oA;ps.parseDocument=tg;ps.stringify=lA});var sg=R(Y=>{"use strict";var cA=Fc(),uA=ss(),dA=vc(),tu=as(),fA=Ur(),Nt=q(),pA=Ot(),hA=re(),mA=_t(),gA=Rt(),yA=lo(),bA=Gc(),wA=Qc(),vA=eu(),fo=ng(),rg=Br();Y.Composer=cA.Composer;Y.Document=uA.Document;Y.Schema=dA.Schema;Y.YAMLError=tu.YAMLError;Y.YAMLParseError=tu.YAMLParseError;Y.YAMLWarning=tu.YAMLWarning;Y.Alias=fA.Alias;Y.isAlias=Nt.isAlias;Y.isCollection=Nt.isCollection;Y.isDocument=Nt.isDocument;Y.isMap=Nt.isMap;Y.isNode=Nt.isNode;Y.isPair=Nt.isPair;Y.isScalar=Nt.isScalar;Y.isSeq=Nt.isSeq;Y.Pair=pA.Pair;Y.Scalar=hA.Scalar;Y.YAMLMap=mA.YAMLMap;Y.YAMLSeq=gA.YAMLSeq;Y.CST=yA;Y.Lexer=bA.Lexer;Y.LineCounter=wA.LineCounter;Y.Parser=vA.Parser;Y.parse=fo.parse;Y.parseAllDocuments=fo.parseAllDocuments;Y.parseDocument=fo.parseDocument;Y.stringify=fo.stringify;Y.visit=rg.visit;Y.visitAsync=rg.visitAsync});function kA(n){try{return JSON.parse(n.trim()),!0}catch{return!1}}function xA(n){let e=n.trim();if(!e.startsWith("<"))return!1;let t=e.match(SA);return t?Mr(e,t[1])!==null:!1}function EA(n){let e=n.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let t=ig.parse(e);return t!==null&&typeof t=="object"}catch{return!1}}function og(n){return kA(n)||xA(n)||EA(n)}var ig,SA,nu=S(()=>{gp();ig=OS(sg(),1),SA=/<([a-zA-Z_][\w.-]*)/});function AA(n){if(!n?.trim())return[];let e=n.replace(/\r\n/g,`
163
+ `),t=e.trim();if(og(t))return[{text:t,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 fo(n){return rA(n).map(e=>e.text)}var Qm,Zm=v(()=>{Xc();Qm=`
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 po(n){return AA(n).map(e=>e.text)}var ag,lg=S(()=>{nu();ag=`
167
167
 
168
168
 
169
- `});function po(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var eg=v(()=>{});var sA,iA,Qc,tg=v(()=>{sA=[["\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","-"]],iA=new Map(sA),Qc=iA});var ng,ho,Zc,rg=v(()=>{ng=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],ho={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:ng,nb:ng,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(ho))ho[n]=new Map(ho[n]);Zc=ho});function eu(n,e){if(typeof n!="string")throw new TypeError(`Expected a string, got \`${typeof n}\``);e={customReplacements:[],...e};let t=aA(e.locale),r=Qc,s=e.customReplacements.length>0||e.customReplacements.size>0;if(t||s){if(r=new Map(Qc),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=oA(n,r),n=n.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),n=n.replaceAll(/\p{Dash_Punctuation}/gu,"-"),n}var oA,aA,sg=v(()=>{tg();rg();oA=(n,e)=>{for(let[t,r]of e)n=n.replaceAll(t,r);return n},aA=n=>{if(!n)return;let e=n.toLowerCase().replace(/^no(-|$)/,"nb$1");return Zc[e]||Zc[e.split("-")[0]]||void 0}});var lA,ig,og=v(()=>{lA=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],ig=lA});function tu(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([...ig,...e.customReplacements]);n=eu(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=cA(n));let s=dA(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=uA(n,e.separator)),t&&(n=`_${n}`),r&&(n=`${n}-`),n}var cA,uA,dA,ag=v(()=>{eg();sg();og();cA=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"),uA=(n,e)=>{let t=po(e);return n.replaceAll(new RegExp(`(?:${t}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${t})|(?:${t})$`,"g"),"")},dA=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+=po(r)}let t=n.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,t)}});function qn(n){return tu(n)}var lg=v(()=>{ag()});var Jn,cg,ug=v(()=>{Jn={local:"local",ide:"ide",published:"published",inline:"inline"},cg=Object.values(Jn).map(n=>`'${n}'`).join(" | ")});var ds,nu,dg=v(()=>{ds=` *, *::before, *::after { box-sizing: border-box; }
169
+ `});function ho(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var cg=S(()=>{});var TA,PA,ru,ug=S(()=>{TA=[["\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","-"]],PA=new Map(TA),ru=PA});var dg,mo,su,fg=S(()=>{dg=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],mo={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:dg,nb:dg,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(mo))mo[n]=new Map(mo[n]);su=mo});function iu(n,e){if(typeof n!="string")throw new TypeError(`Expected a string, got \`${typeof n}\``);e={customReplacements:[],...e};let t=CA(e.locale),r=ru,s=e.customReplacements.length>0||e.customReplacements.size>0;if(t||s){if(r=new Map(ru),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=OA(n,r),n=n.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),n=n.replaceAll(/\p{Dash_Punctuation}/gu,"-"),n}var OA,CA,pg=S(()=>{ug();fg();OA=(n,e)=>{for(let[t,r]of e)n=n.replaceAll(t,r);return n},CA=n=>{if(!n)return;let e=n.toLowerCase().replace(/^no(-|$)/,"nb$1");return su[e]||su[e.split("-")[0]]||void 0}});var _A,hg,mg=S(()=>{_A=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],hg=_A});function ou(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([...hg,...e.customReplacements]);n=iu(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=RA(n));let s=NA(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=IA(n,e.separator)),t&&(n=`_${n}`),r&&(n=`${n}-`),n}var RA,IA,NA,gg=S(()=>{cg();pg();mg();RA=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"),IA=(n,e)=>{let t=ho(e);return n.replaceAll(new RegExp(`(?:${t}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${t})|(?:${t})$`,"g"),"")},NA=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+=ho(r)}let t=n.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,t)}});function Kn(n){return ou(n)}var yg=S(()=>{gg()});var Hn,bg,wg=S(()=>{Hn={local:"local",ide:"ide",published:"published",inline:"inline"},bg=Object.values(Hn).map(n=>`'${n}'`).join(" | ")});var hs,au,vg=S(()=>{hs=` *, *::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; }`,nu=" html, body { height: 100%; }"});var fg,pg=v(()=>{fg=`(function () {
173
+ html[data-theme="light"] { color-scheme: light; }`,au=" html, body { height: 100%; }"});var Sg,kg=S(()=>{Sg=`(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 hg,mg=v(()=>{hg=`(function () {
241
+ })();`});var xg,Eg=S(()=>{xg=`(function () {
242
242
  var W = window;
243
243
  var rtData, rtInsight, rtHasInsight = false;
244
244
  var applyData, applyInsight, send;
@@ -292,33 +292,36 @@ ${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=v(()=>{ui();dl();Gf();ep();Xc();Zm();lg();ug();dg();pg();mg();di()});function Ae(n){return n.length>5e4?n.slice(0,5e4)+`
296
- \u2026[${n.length-5e4} more characters truncated]`:n}function Ie(n){let e=n.replace(fA,"").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 ve,fA,mo,fs=v(()=>{"use strict";ve=(n,e,t=e+"s")=>`${n} ${n===1?e:t}`;fA=/\u001b\[[0-9;]*m/g;mo=(n,e)=>`![pasted image](data:${e||"image/png"};base64,${n})`});import{existsSync as pA,readdirSync as hA,statSync as mA}from"fs";import{join as gA}from"path";function go(n){if(!pA(n))return[];let e;try{e=hA(n)}catch{return[]}let t=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=gA(n,r);try{let i=mA(s);i.isFile()&&t.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return t}var su=v(()=>{"use strict"});var It,yo=v(()=>{"use strict";It=class{ensureHarnessSupport(){}}});import{openSync as yA,readSync as bA,closeSync as wA,statSync as vA,readdirSync as SA,readFileSync as kA,existsSync as xA}from"fs";import{join as hs}from"path";import{homedir as au}from"os";function EA(n){return n.replace(/[^a-zA-Z0-9]/g,"-")}function bo(n){let e=n?.type==="image"?n.source:void 0;return e?.type==="base64"&&e.data?mo(e.data,e.media_type):""}function iu(n){return typeof n=="string"?Ae(n):Array.isArray(n)?n.map(e=>{if(typeof e=="string")return Ae(e);let t=e;return typeof t?.text=="string"?Ae(t.text):t?.content!=null?iu(t.content):bo(t)}).join(`
298
- `):n==null?"":Ae(JSON.stringify(n))}function TA(n){let e=n.trim();return!!e&&vg.some(t=>t.test(e))}function PA(n){let e=n.trim();return e?vg.some(t=>{let r=t.exec(e);return!!r&&r.index===0}):!0}function _A(n){return n.replace(OA,"")}function CA(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 Nt(n){let e=_A(n).trim();return e?CA(e)??(TA(e)?"":e):""}function ou(n){return n?.type==="text"&&typeof n.text=="string"?Nt(n.text):""}function lu(n,e){if(typeof n=="string")return Ie(n);if(!n||typeof n!="object")return Ie(e);let t=n;if(t.type==="text"&&typeof t.file?.numLines=="number")return ve(t.file.numLines,"line");if(t.type==="image"){let r=bg(t.file?.originalSize);return r?`image (${r})`:"image"}if(t.type==="pdf"){let r=bg(t.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(t.type==="parts"&&typeof t.file?.count=="number")return ve(t.file.count,"page");if(t.type==="file_unchanged")return"unchanged since last read";if(t.type==="create"&&typeof t.content=="string")return`created, ${ve(t.content.split(`
299
- `).length,"line")}`;if(t.mode==="content")return ve(t.numLines??0,"line");if(t.mode==="count")return`${ve(t.numMatches??0,"match","matches")} (${ve(t.numFiles??0,"file")})`;if(t.mode==="files_with_matches")return ve(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":Ie(t.stdout||t.stderr||"")||"no output":typeof t.code=="number"&&typeof t.codeText=="string"?`${t.code} ${t.codeText}`:typeof t.searchCount=="number"?ve(t.searchCount,"search","searches"):Array.isArray(t.matches)&&typeof t.total_deferred_tools=="number"?ve(t.matches.length,"tool"):Array.isArray(t.newTodos)?ve(t.newTodos.length,"todo"):typeof t.numFiles=="number"?ve(t.numFiles,"file"):Ie(e)}function ps(n){return!!n.isSidechain||!!n.isMeta}function RA(n){let e;try{e=yA(n,"r")}catch{return""}try{let r=65536;try{r=vA(n).size}catch{}let s=(c,f)=>{if(f<=0)return"";let u=Buffer.alloc(f),d=bA(e,u,0,f,c);return u.subarray(0,d).toString("utf8")},i=(c,f,u)=>{let d="";for(let p of c.split(`
300
- `)){if(!p.includes(`"${f}"`))continue;let m;try{m=JSON.parse(p)}catch{continue}let h=m?.[u];m?.type===f&&typeof h=="string"&&h&&(d=h)}return d},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(`
301
- `)){if(!c.trim())continue;let f;try{f=JSON.parse(c)}catch{continue}if(!f||ps(f)||f.type!=="user")continue;let u=f.message?.content,d="";typeof u=="string"?d=Nt(u):Array.isArray(u)&&(d=u.map(ou).filter(Boolean).join(" "));let p=d.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{wA(e)}}function IA(n){let e;try{e=SA(wg)}catch{return!1}for(let t of e)if(t.endsWith(".json"))try{let r=JSON.parse(kA(hs(wg,t),"utf8"));if(r?.sessionId!==n)continue;return process.kill(r.pid,0),!0}catch{}return!1}var AA,yg,vg,OA,bg,wg,Wn,wo=v(()=>{"use strict";fs();su();yo();AA=hs(au(),".claude","projects"),yg=n=>hs(AA,EA(n));vg=[/\[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];OA=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;bg=n=>typeof n!="number"?"":n<1024?`${n}B`:n<1048576?`${Math.round(n/1024)}KB`:`${(n/1048576).toFixed(1)}MB`;wg=hs(au(),".claude","sessions");Wn=class extends It{displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return xA(hs(au(),".claude"))}sessionsDir(e){return yg(e)}listSessionFiles(e){return go(yg(e))}parseEntry(e){try{return JSON.parse(e)}catch{return null}}idOf(e){return e.uuid}parentOf(e){return e.parentUuid}timestampOf(e){return e.timestamp}isSidechain(e){return!!e.isSidechain}isLeafType(e){return e.type==="user"||e.type==="assistant"}isRecoveryNoise(e){return!!e.isApiErrorMessage}apply(e,t){if(ps(e))return{events:[]};let r=[];if(e.type==="user"){let s=e.message?.content;if(typeof s=="string"){let i=Nt(s);i&&r.push({type:"user",text:i})}else if(Array.isArray(s))for(let i of s)if(i?.type==="tool_result"){let o=iu(i.content);r.push({type:"tool_result",id:i.tool_use_id??"",content:o,isError:!!i.is_error,digest:lu(e.toolUseResult,o)})}else{let o=ou(i)||bo(i);o&&r.push({type:"user",text:o})}return{events:r}}if(e.type==="attachment"&&e.attachment?.type==="queued_command"){let s=Nt(iu(e.attachment.prompt));return s&&r.push({type:"user",text:s}),{events:r}}if(e.type==="assistant"){let s=e.message?.content,i=Array.isArray(s)?s:[],o=i.filter(u=>u.type==="text").map(u=>u.text??"").filter(u=>!PA(u)).join(""),a=i.filter(u=>u.type==="thinking").map(u=>u.thinking??"").join(`
302
- `),l=i.filter(u=>u.type==="tool_use").map(u=>({id:u.id??"",name:u.name??"",input:u.input??{}}));if(o||a||l.length){let u=Date.parse(e.timestamp??""),d=!isNaN(u)&&u>=t;r.push({type:"assistant",text:o,thinking:a,tools:l,live:d})}let c=e.message?.usage??e.usage,f=c&&{in:c.input_tokens??0,out:c.output_tokens??0,cached:c.cache_read_input_tokens??0,cacheCreate:c.cache_creation_input_tokens??0};return{events:r,usage:f,model:e.message?.model}}return{events:r}}chainWorking(e){let t;for(let o of e)(o.type==="user"||o.type==="assistant")&&(t=o);if(!t)return!1;if(t.type==="user"){try{let o=t.message?.content,a=typeof o=="string"?o:Array.isArray(o)?o.filter(c=>c&&c.type==="text").map(c=>c.text??"").join(""):"";if(!(Array.isArray(o)&&o.some(c=>c&&c.type==="tool_result"))&&a.trim()&&Nt(a)==="")return!1}catch{}return!0}let s=(Array.isArray(t.message?.content)?t.message.content:[]).filter(o=>o.type==="tool_use").map(o=>o.id);if(s.length===0)return!1;let i=new Set;for(let o of e){let a=o.message?.content;if(Array.isArray(a))for(let l of a)l.type==="tool_result"&&l.tool_use_id&&i.add(l.tool_use_id)}return s.some(o=>o&&!i.has(o))}sessionAlive(e){return IA(e)}readPreview(e){return RA(e)}searchText(e){if(!e||ps(e)||e.type!=="user"&&e.type!=="assistant")return"";let t=e.message?.content,r="";if(typeof t=="string")r=Nt(t);else if(Array.isArray(t)){let s=t;r=e.type==="user"?s.map(ou).filter(Boolean).join(" "):s.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(" ")}return r.replace(/\s+/g," ").trim()}}});import{statSync as Sg,fstatSync as NA,readdirSync as $A,openSync as Tg,readSync as Pg,closeSync as Og,existsSync as LA}from"fs";import{basename as MA,join as cu,resolve as BA}from"path";import{homedir as kg}from"os";function jA(n){let e=n.trimStart();return DA.some(t=>e.startsWith(t))}function Kn(n,e){return Array.isArray(n)?n.map(t=>typeof t?.text=="string"?e&&jA(t.text)?"":Ae(t.text):t?.type==="input_image"&&typeof t.image_url=="string"&&t.image_url.startsWith("data:")?`![image](${t.image_url})`:"").filter(Boolean).join(`
303
- `):""}function FA(n){return typeof n=="string"?Ae(n):Kn(n,!1)}function UA(n,e){let t=e??"",r=ZA(t);if(!r.length)return{name:n,input:{script:t}};let s=r.map(i=>uu(i.fn)&&ms(i.arg)?zA(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:xg(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}=Eg(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:WA(l)}}}return ms(o)?uu(i)?{name:n,input:JA(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:n,input:{script:t}}}return{name:n,input:xg(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",Eg(o).diff]:uu(i)&&ms(o)?["command",o.cmd??o.command]:[i,o]))}}function JA(n){let e=Object.fromEntries(Object.entries(n).filter(([r])=>r!=="cmd"&&r!=="command"&&!qA.has(r))),t=n.command??n.cmd;return t===void 0?e:{command:t,...e}}function xg(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 WA(n){let e=0,t=0;for(let r of n.split(`
304
- `))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&t++;return`+${e} \u2212${t}`}function zA(n){let e=XA(n),t=e.map(GA);return e.length&&t.every(r=>r!==void 0)?t:void 0}function GA(n){let[e,...t]=n.split("|");if(!t.every(i=>VA.test(i.trim())))return;let r=QA(e);if(!KA.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(HA.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(YA.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}function XA(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===`
305
- `||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 QA(n){return(n.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e)}function ZA(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=Cg(n,s);if(i<0)break;e.push({fn:r[1],arg:_g(n.slice(s+1,i).trim(),n)}),t.lastIndex=i+1}return e}function _g(n,e){let t=n[0];if(t==='"'||t==="'"||t==="`")return vo(n,0)===n.length-1?Rg(n.slice(1,-1)):n;if(t==="{"){for(let r of[n,tT(n)])try{let s=JSON.parse(r);if(ms(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==="`"?vo(e,s):i==="{"?Cg(e,s):-1;if(o>s)return _g(e.slice(s,o+1),"")}}return n}function Cg(n,e){let t=0;for(let r=e;r<n.length;r++){let s=n[r];if(s==='"'||s==="'"||s==="`"){if(r=vo(n,r),r<0)return-1}else if(s==="("||s==="["||s==="{")t++;else if((s===")"||s==="]"||s==="}")&&--t===0)return r}return-1}function vo(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 Rg(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)):eT[i]??i)}function tT(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=vo(n,i);if(l<0)return n;r+=JSON.stringify(Rg(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 Eg(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(`
306
- `)}}function nT(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:Ie(n)};let r=t[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=t[1]==="failed",i=rT(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:ve(sT(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:Ie(r)}}function rT(n){if(n.startsWith("{"))try{let e=JSON.parse(n);if(ms(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function iT(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 Ig(n,e){let t;try{t=Tg(n,"r")}catch{return}try{let r=Buffer.alloc(e),s=Pg(t,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{Og(t)}}function aT(n,e){let t;try{t=Tg(n,"r")}catch{return}try{let r=Math.max(0,NA(t).size-e),s=Buffer.alloc(e),i=Pg(t,s,0,e,r);return{text:s.subarray(0,i).toString("utf8"),partial:r>0}}finally{Og(t)}}function cT(n){for(let e of lT){let t=aT(n,e);if(t===void 0)return;let r=t.text.split(`
307
- `);t.partial&&r.shift();for(let s=r.length-1;s>=0;s--)if(r[s].trim())try{let i=Date.parse(JSON.parse(r[s]).timestamp??"");if(!Number.isNaN(i))return i}catch{}if(!t.partial)break}}function uT(n){let t=Ig(n,65536);if(t===void 0)return;let r=t.text.indexOf(`
308
- `);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;return typeof i?.cwd!="string"?{cwd:"",subagent:!1}:{cwd:i.cwd,subagent:typeof i.source=="object"&&!!i.source?.subagent}}catch{return{cwd:"",subagent:!1}}}var DA,ms,uu,qA,KA,HA,YA,VA,eT,sT,Ag,oT,Hn,lT,du=v(()=>{"use strict";fs();yo();DA=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];ms=n=>!!n&&typeof n=="object"&&!Array.isArray(n),uu=n=>n==="shell_command"||n==="exec_command",qA=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);KA=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,HA=/^-(Path|LiteralPath)$/i,YA=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,VA=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;eT={n:`
309
- `,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};sT=n=>n?n.replace(/\r?\n$/,"").split(`
310
- `).length:0;Ag=n=>{let e=BA(n);return process.platform==="win32"?e.toLowerCase():e},oT=12e4,Hn=class extends It{constructor(t=cu(kg(),".codex","sessions")){super();this.root=t}displayName="Codex Mirror";#e=0;#i;#t=new Map;#n=new Map;#f=new Map;#r=new Map;detectsSelf(){return!!process.env.CODEX_THREAD_ID}detectsInstalled(){return LA(cu(kg(),".codex"))}sessionsDir(t){return this.root}listSessionFiles(t){let r=Ag(t),s=[];for(let i of this.#o()){let o=0,a=0;try{let f=Sg(i);if(!f.isFile())continue;o=f.size,a=f.mtimeMs}catch{continue}let l=this.#t.get(i);if(l===void 0){if(l=uT(i),l===void 0)continue;this.#t.set(i,l)}if(l.subagent||Ag(l.cwd)!==r)continue;let c=MA(i,".jsonl");this.#f.set(c,i),s.push({sessionId:c,file:i,mtime:this.#c(i,o,a)})}return s}#c(t,r,s){let i=this.#n.get(t);if(i&&i.size===r&&i.mtime===s)return i.ms;let o=Math.max(s,cT(t)??0);return this.#n.set(t,{size:r,mtime:s,ms:o}),o}#o(){let t=[],r=s=>{try{return $A(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&&(t.ord=String(this.#e++),t.parent=this.#i,this.#i=t.ord),t.ord}parentOf(t){return t.parent}timestampOf(t){return t.timestamp}isSidechain(t){return!1}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=Kn(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=Kn(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=Kn(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"?UA(i.name??"",i.input):{name:i.name??"",input:iT(i.arguments)};return l&&this.#r.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.#r.get(a);return this.#r.delete(a),s.push({type:"tool_result",id:a,...nT(FA(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;if(!a)return{events:s};let l={in:Math.max(0,(a.input_tokens??0)-(a.cached_input_tokens??0)),out:a.output_tokens??0,cached:a.cached_input_tokens??0,cacheCreate:a.cache_write_input_tokens??0};return{events:s,usage:l}}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.#f.get(t);if(!r)return;let s;try{let i=Sg(r);s=this.#c(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<oT}readPreview(t){for(let r of(Ig(t,256*1024)?.text??"").split(`
311
- `))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"?Kn(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"?"":Kn(t.payload.content,r==="user").replace(/\s+/g," ").trim()}};lT=[64*1024,1024*1024]});import{realpathSync as dT}from"fs";import{createHash as fT}from"crypto";import{join as So,resolve as pT}from"path";import{homedir as hT}from"os";function $t(){let n=process.env.TYPEBULB_SERVERS_DIR;return n?So(n,".."):So(hT(),".typebulb")}function lt(){Ng||(Ng=!0,console.error(`${$t()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function ct(){return process.env.TYPEBULB_SERVERS_DIR||So($t(),"servers")}function $g(n){let e=re(n),t=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return So($t(),"canvas",`${t}-${gs(n)}.png`)}function gs(n){return fT("sha1").update(re(n)).digest("hex").slice(0,8)}function re(n){let e=pT(n),t=e;try{t=dT.native(e)}catch{}return(process.platform==="win32"?t.toLowerCase():t).replace(/\\/g,"/")}function Lg(n,e){let t=re(n),r=re(e);return t.startsWith(r.endsWith("/")?r:r+"/")?!t.includes("/node_modules/"):!1}var Ng,tt=v(()=>{"use strict";Ng=!1});import*as Dg from"net";import{mkdir as mT,readFile as gT,writeFile as jg}from"fs/promises";import{existsSync as yT}from"fs";import{join as Fg}from"path";function Jg(){return Fg($t(),"blocks")}function fu(n){return Fg(Jg(),`${n}.json`)}function xo(n){return new Promise(e=>{let t=Dg.createServer();t.once("error",()=>e(!1)),t.listen(n,"127.0.0.1",()=>t.close(()=>e(!0)))})}async function ST(n){for(let e=n;e<65535;e++)if(await xo(e))return e;throw new Error(`No free port found above ${n}`)}async function pu(n){let{listBulbServers:e}=await Promise.resolve().then(()=>(Ne(),Wg)),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 Eo(n){try{let e=JSON.parse(await gT(fu(n),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function Ao(n,e){try{return await jg(fu(n),JSON.stringify(e,null,2)),!0}catch{return lt(),!1}}async function kT(n){let e=re(n);try{await mT(Jg(),{recursive:!0})}catch{return}let t=[];for(let o=0;o<qg;o++)t.push(Ug+o*sn);let r=await Promise.all(t.map(async o=>({base:o,block:await Eo(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 jg(fu(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await Eo(o))?.cwd===e)return o;l.code!=="EEXIST"&&lt();continue}if(!yT(a.cwd))return await Ao(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>Mg(o.block)-Mg(a.block))[0];if(i)return await Ao(i.base,s)?i.base:void 0}function Mg(n){return Object.values(n.slots).reduce((e,t)=>Math.max(e,t.usedAt??0),0)}async function xT(n,e){let t=await Eo(n)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=t.mirrors[e.agent];if(i!==void 0)return i;let o=Bg(t),a=o.has(0)?wT:0;for(;a>ko&&o.has(a);)a--;return t.mirrors[e.agent]=a,await Ao(n,t),a}let r=re(e.file),s=t.slots[r]?.offset;if(s===void 0){let i=Bg(t);for(s=ko;s<sn&&i.has(s);)s++;if(s>=sn){let o=Object.entries(t.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:ko,o&&delete t.slots[o[0]]}}return t.slots[r]={offset:s,usedAt:Date.now()},await Ao(n,t),s}function Bg(n){return new Set([...Object.values(n.mirrors),...Object.values(n.slots).map(e=>e.offset)])}async function Yn(n,e){let t=await kT(e);return t===void 0?void 0:t+await xT(t,n)}async function on(n){let e=re(n);for(let t=0;t<qg;t++){let r=await Eo(Ug+t*sn);if(r?.cwd===e)return s=>r.slots[re(s)]?.usedAt??0}return()=>0}async function To(n){if(n.explicit!==void 0)return await xo(n.explicit)||await pu(n.explicit),n.target.kind==="bulb"&&await Yn(n.target,n.cwd),{port:n.explicit};let e=await Yn(n.target,n.cwd);if(e!==void 0){let r=e-e%sn,s=Date.now()+vT;do{if(await xo(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=ko;i<sn;i++){let o=r+i;if(o!==e&&await xo(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await ST(bT),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var Ug,sn,qg,bT,ko,wT,vT,an=v(()=>{"use strict";tt();Ug=20100,sn=100,qg=19,bT=23e3,ko=1,wT=sn-1,vT=3e3});var $e,Po=v(()=>{"use strict";$e="0.59.7"});var Wg={};li(Wg,{agentViewerCommand:()=>ey,bulbServerCommand:()=>Zg,clearServerLog:()=>bu,findProjectViewer:()=>Co,isAlive:()=>Vn,isMirror:()=>me,isProjectBulb:()=>xu,isProjectMirror:()=>Xn,launchAgentViewer:()=>Tu,launchBulbServer:()=>ws,listBulbServers:()=>X,probePageCount:()=>Au,readServerLog:()=>He,readWaitCursor:()=>_o,recordDenial:()=>ku,registerServer:()=>Su,relayOpen:()=>Eu,runMarker:()=>wu,serverLogPath:()=>Gn,serversForBulb:()=>cn,sliceRunLog:()=>vu,startServerLog:()=>bs,stopBulbServer:()=>zn,stopServer:()=>Lt,stopServersForBulb:()=>Ro,typebulbBinPath:()=>Qn,unregisterServer:()=>ln,writeWaitCursor:()=>ys});import{spawn as Kg}from"child_process";import{readdir as ET,readFile as Vg,writeFile as zg,unlink as hu,mkdir as AT}from"fs/promises";import{mkdirSync as Gg,writeFileSync as Oo,appendFileSync as TT,readFileSync as mu}from"fs";import*as Te from"path";import{fileURLToPath as PT}from"url";function gu(n){return Te.join(ct(),`${n}.json`)}function Gn(n){return Te.join(ct(),`${n}.log`)}function yu(n){return Te.join(ct(),`${n}.wait.json`)}function Xg(n){try{let e=JSON.parse(mu(yu(n),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function _o(n,e=""){let t=Xg(n)[e];return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0}function ys(n,e,t=""){try{Gg(ct(),{recursive:!0});let r=Xg(n);r[t]=e,Oo(yu(n),JSON.stringify({cursors:r}))}catch{}}function bs(n){let e=Gn(n);try{Gg(ct(),{recursive:!0}),Oo(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(TT(e,l),s+=l.length,s>2*Hg){let c=mu(e),f=c.subarray(Math.max(0,c.length-Hg));Oo(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{Oo(Gn(n),"")}catch{}}function He(n,e=0){try{let t=mu(Gn(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 wu(n){return`\u2500\u2500 run ${n} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function _T(n){let e=OT.exec(n);return e?Number(e[1]):void 0}function vu(n,e){let t=n.split(`
312
- `),r=[];if(t.forEach((o,a)=>{let l=_T(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(`
313
- `)}function Vn(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}async function Su(n){try{await AT(ct(),{recursive:!0}),await zg(gu(n.pid),JSON.stringify({version:$e,...n}))}catch{lt()}}async function ku(n,e){let t=gu(n);try{let r=JSON.parse(await Vg(t,"utf8"));if(r.denied===e)return;r.denied=e,await zg(t,JSON.stringify(r))}catch{}}async function ln(n){await hu(gu(n)).catch(()=>{}),await hu(Gn(n)).catch(()=>{}),await hu(yu(n)).catch(()=>{})}function me(n){return n.agent!=null}function Xn(n,e){return me(n)&&n.cwd!=null&&re(n.cwd)===re(e)}function xu(n,e){return!me(n)&&Lg(n.file,e)}async function X(n){let e;try{e=await ET(ct())}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 Vg(Te.join(ct(),s),"utf8"))}catch{await ln(i);return}o&&typeof o.pid=="number"&&Vn(o.pid)?t.push(o):await ln(i)})),(n?t.filter(s=>xu(s,n)):t).sort((s,i)=>s.startedAt-i.startedAt)}async function Co(n,e){return(await X()).find(t=>Xn(t,n)&&(e?t.agent===e:!0))}async function Eu(n,e){let t=new URL(n).port,r=(await X()).filter(a=>String(a.port)!==t),s=r.filter(a=>Xn(a,e)),i=r.filter(a=>xu(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":`${Te.basename(a.file)}'s page`};me(a)&&(o+=f??0)}catch{}return o>0?{where:"external"}:void 0}async function zn(n){try{process.kill(n,"SIGTERM")}catch{}await ln(n)}async function Au(n){try{let e=await fetch(`${n.url}/__pages`,{signal:AbortSignal.timeout(CT)});if(!e.ok)return;let{pages:t}=await e.json();return typeof t=="number"?t:void 0}catch{return}}async function Lt(n,e=me(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(Yg)});if(!t.ok)throw new Error(`/__stop ${t.status}`);let{closed:r=0,stuck:s=0}=await t.json(),i=Date.now()+Yg;for(;Vn(n.pid)&&Date.now()<i;)await Qg(100);return Vn(n.pid)?(await zn(n.pid),"killed"):(await ln(n.pid),{closed:r,stuck:s})}catch{return await zn(n.pid),"killed"}}function cn(n,e){let t=re(e);return n.filter(r=>!me(r)&&r.pid!==process.pid&&re(r.file)===t)}async function Ro(n,e){let t=cn(await X(),n);for(let r of t)await Lt(r,e!==void 0&&r.port===e?"keep":"close");return t}function RT(n,e,t){(process.platform==="win32"?Kg("cmd",["/c","start","","/b",n,...e],{cwd:t,stdio:"ignore",windowsHide:!0}):Kg(n,e,{cwd:t,detached:!0,stdio:"ignore"})).unref()}function Qn(){return Te.join(Te.dirname(PT(import.meta.url)),"index.js")}function Zg(n,e={}){return{command:process.execPath,args:[Qn(),...e.trust?["--trust"]:[],...e.mode?["--mode",e.mode]:[],n,...e.open===!1?["--no-open"]:[]]}}function ey(n){return{command:process.execPath,args:[Qn(),`agent:${n}`,"--no-open"]}}async function ty(n,e,t,r){let s=await n();if(s)return s;RT(e.command,e.args,t);let i=Date.now()+2e4;for(;Date.now()<i;){await Qg(150);let o=await n();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function ws(n,e={}){let t=e.cwd??process.cwd(),r=Te.resolve(t,n),s=await Yn({kind:"bulb",file:r},t),[i]=await Ro(r,s),o={...e,mode:e.mode??i?.mode};return ty(async()=>cn(await X(),r)[0],Zg(n,o),t,Te.basename(n))}async function Tu(n,e=process.cwd()){return ty(()=>Co(e,n),ey(n),e,`the ${n} mirror`)}var Hg,OT,Yg,CT,Qg,Ne=v(()=>{"use strict";tt();an();Po();Hg=1e6;OT=/^── run (\d+) ── /;Yg=6e3,CT=500;Qg=n=>new Promise(e=>setTimeout(e,n))});function Zn(n){return{...Wf(n),server:n.files.get("server.ts")??""}}function Io(n){return!!n.server&&!n.code}var vs=v(()=>{"use strict";ee();ee()});function No(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 Pu(n){return qn(No(n)??"bulb")||"bulb"}var Ou=v(()=>{"use strict";ee()});import{readdirSync as IT,readFileSync as NT,statSync as $T}from"fs";import{join as ny,basename as LT}from"path";function sy(n,e,t){if(e>8)return t;let r;try{r=IT(n,{withFileTypes:!0})}catch{return t}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;sy(ny(n,s.name),e+1,t)}else s.isFile()&&s.name.endsWith(".bulb.md")&&t.push(ny(n,s.name));return t}function MT(n,e){let t,r=!1;try{let s=NT(n,"utf8");t=No(s.slice(0,1024));let i=Je(s);r=!!i&&Io(Zn(i))}catch{}return{mtime:e,name:t??LT(n).replace(/\.bulb\.md$/,""),serverOnly:r}}function $o(n){let e=new Map,t=sy(n,0,[]).map(r=>{let s=0;try{s=$T(r).mtimeMs}catch{}let i=s?ry.get(r):void 0,o=i?.mtime===s?i:MT(r,s);return s&&e.set(r,o),{path:r,...o}});return ry=e,t}var ry,iy=v(()=>{"use strict";ee();vs();Ou();ry=new Map});function er(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 Lo=v(()=>{"use strict"});import{readFile as BT}from"fs/promises";async function _u(n){try{let e=Je(await BT(n,"utf-8"));return e?er(Zn(e)):void 0}catch{return}}var oy=v(()=>{"use strict";vs();Lo()});function Cu(n){let e=n.split(""),t=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
295
+ })();`});var ee=S(()=>{di();gl();ip();cp();nu();lg();yg();wg();vg();kg();Eg();fi()});function Ae(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($A,"").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 ke,$A,go,ms=S(()=>{"use strict";ke=(n,e,t=e+"s")=>`${n} ${n===1?e:t}`;$A=/\u001b\[[0-9;]*m/g;go=(n,e)=>`![pasted image](data:${e||"image/png"};base64,${n})`});import{existsSync as LA,readdirSync as MA,statSync as BA}from"fs";import{join as DA}from"path";function yo(n){if(!LA(n))return[];let e;try{e=MA(n)}catch{return[]}let t=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=DA(n,r);try{let i=BA(s);i.isFile()&&t.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return t}var cu=S(()=>{"use strict"});var $t,bo=S(()=>{"use strict";$t=class{ensureHarnessSupport(){}}});import{openSync as jA,readSync as FA,closeSync as UA,statSync as Pg,readdirSync as pu,readFileSync as hu,existsSync as qA}from"fs";import{join as ct}from"path";import{homedir as mu}from"os";function JA(n){return n.replace(/[^a-zA-Z0-9]/g,"-")}function HA(n,e){let t=ct(du(n),e,KA),r;try{r=pu(t)}catch{return[]}let s=[];for(let i of r){if(!i.endsWith(".jsonl"))continue;let o=ct(t,i),a;try{a=Pg(o).mtimeMs}catch{continue}let l=i.slice(0,-6),c={};try{c=JSON.parse(hu(ct(t,`${l}.meta.json`),"utf8"))}catch{}s.push({id:l.startsWith("agent-")?l.slice(6):l,file:o,mtime:a,label:c.description??"",kind:c.agentType??"agent",model:c.model,spawnId:c.toolUseId,parentId:c.parentAgentId,depth:c.spawnDepth??1,stopped:!!c.stoppedByUser})}return s}function YA(n){if(!n||typeof n!="object")return!1;let e=n;return e.status==="async_launched"||e.isAsync===!0}function VA(n){return n.type==="attachment"&&n.attachment?.type==="queued_command"?wo(n.attachment.prompt):n.type==="user"&&typeof n.message?.content=="string"?n.message.content:n.type==="queue-operation"&&typeof n.content=="string"?n.content:""}function zA(n){if(!n.includes("<task-notification>"))return[];let e=[];for(let t of[/<tool-use-id>\s*([^<\s]+)/g,/<task-id>\s*([^<\s]+)/g])for(let r of n.matchAll(t))e.push(r[1]);return e}function So(n){let e=n?.type==="image"?n.source:void 0;return e?.type==="base64"&&e.data?go(e.data,e.media_type):""}function wo(n){return typeof n=="string"?Ae(n):Array.isArray(n)?n.map(e=>{if(typeof e=="string")return Ae(e);let t=e;return typeof t?.text=="string"?Ae(t.text):t?.content!=null?wo(t.content):So(t)}).join(`
298
+ `):n==null?"":Ae(JSON.stringify(n))}function GA(n){let e=n.trim();return!!e&&Og.some(t=>t.test(e))}function XA(n){let e=n.trim();return e?Og.some(t=>{let r=t.exec(e);return!!r&&r.index===0}):!0}function ZA(n){return n.replace(QA,"")}function eT(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 Lt(n){let e=ZA(n).trim();return e?eT(e)??(GA(e)?"":e):""}function ko(n){let e=tT.exec(n.trim());if(e)return{from:e[1],body:rT(e[2].replace(nT,""))}}function rT(n){let e=n.split(`
299
+ `).filter(r=>r.trim()).map(r=>r.length-r.trimStart().length),t=e.length?Math.min(...e):0;return t?n.split(`
300
+ `).map(r=>r.slice(t)).join(`
301
+ `):n}function uu(n){let e=ko(n);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:n}}function sT(n){let e=n.message?.content;return typeof e=="string"&&!!ko(e)}function fu(n){return n?.type==="text"&&typeof n.text=="string"?Lt(n.text):""}function gu(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 ke(t.file.numLines,"line");if(t.type==="image"){let r=Tg(t.file?.originalSize);return r?`image (${r})`:"image"}if(t.type==="pdf"){let r=Tg(t.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(t.type==="parts"&&typeof t.file?.count=="number")return ke(t.file.count,"page");if(t.type==="file_unchanged")return"unchanged since last read";if(t.type==="create"&&typeof t.content=="string")return`created, ${ke(t.content.split(`
302
+ `).length,"line")}`;if(t.mode==="content")return ke(t.numLines??0,"line");if(t.mode==="count")return`${ke(t.numMatches??0,"match","matches")} (${ke(t.numFiles??0,"file")})`;if(t.mode==="files_with_matches")return ke(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"?ke(t.searchCount,"search","searches"):Array.isArray(t.matches)&&typeof t.total_deferred_tools=="number"?ke(t.matches.length,"tool"):Array.isArray(t.newTodos)?ke(t.newTodos.length,"todo"):typeof t.numFiles=="number"?ke(t.numFiles,"file"):Ne(e)}function gs(n){return!!n.isMeta}function iT(n){let e;try{e=jA(n,"r")}catch{return""}try{let r=65536;try{r=Pg(n).size}catch{}let s=(c,f)=>{if(f<=0)return"";let u=Buffer.alloc(f),d=FA(e,u,0,f,c);return u.subarray(0,d).toString("utf8")},i=(c,f,u)=>{let d="";for(let p of c.split(`
303
+ `)){if(!p.includes(`"${f}"`))continue;let g;try{g=JSON.parse(p)}catch{continue}let h=g?.[u];g?.type===f&&typeof h=="string"&&h&&(d=h)}return d},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(`
304
+ `)){if(!c.trim())continue;let f;try{f=JSON.parse(c)}catch{continue}if(!f||gs(f)||f.type!=="user")continue;let u=f.message?.content,d="";typeof u=="string"?d=Lt(u):Array.isArray(u)&&(d=u.map(fu).filter(Boolean).join(" "));let p=d.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{UA(e)}}function oT(n){let e;try{e=pu(vo)}catch{return!1}for(let t of e)if(t.endsWith(".json"))try{let r=JSON.parse(hu(ct(vo,t),"utf8"));if(r?.sessionId!==n)continue;return process.kill(r.pid,0),!0}catch{}return!1}function aT(){let n=new Set,e;try{e=pu(vo)}catch{return n}for(let t of e)if(t.endsWith(".json"))try{let r=JSON.parse(hu(ct(vo,t),"utf8"));if(!r?.sessionId||r.status!=="busy")continue;process.kill(r.pid,0),n.add(r.sessionId)}catch{}return n}var WA,du,KA,Og,QA,tT,nT,Tg,vo,Yn,xo=S(()=>{"use strict";ms();cu();bo();WA=ct(mu(),".claude","projects"),du=n=>ct(WA,JA(n)),KA="subagents";Og=[/\[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];QA=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;tT=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,nT=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;Tg=n=>typeof n!="number"?"":n<1024?`${n}B`:n<1048576?`${Math.round(n/1024)}KB`:`${(n/1048576).toFixed(1)}MB`;vo=ct(mu(),".claude","sessions");Yn=class extends $t{displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return qA(ct(mu(),".claude"))}sessionsDir(e){return du(e)}listSessionFiles(e){return yo(du(e))}listChildren(e,t){return HA(e,t)}parseEntry(e){try{return JSON.parse(e)}catch{return null}}idOf(e){return e.uuid}parentOf(e){return e.parentUuid}timestampOf(e){return e.timestamp}isSidechain(e,t){return!!e.isSidechain!=(t==="child")}isLeafType(e){return e.type==="user"||e.type==="assistant"}isRecoveryNoise(e){return!!e.isApiErrorMessage}apply(e,t){if(gs(e)&&!sT(e))return{events:[]};let r=[];if(e.type==="user"){let s=e.message?.content;if(typeof s=="string"){let i=Lt(s);i&&r.push(uu(i))}else if(Array.isArray(s))for(let i of s)if(i?.type==="tool_result"){let o=wo(i.content);r.push({type:"tool_result",id:i.tool_use_id??"",content:o,isError:!!i.is_error,digest:gu(e.toolUseResult,o)})}else{let o=fu(i)||So(i);o&&r.push(uu(o))}return{events:r}}if(e.type==="attachment"&&e.attachment?.type==="queued_command"){let s=Lt(wo(e.attachment.prompt));return s&&r.push(uu(s)),{events:r}}if(e.type==="assistant"){let s=e.message?.content,i=Array.isArray(s)?s:[],o=i.filter(u=>u.type==="text").map(u=>u.text??"").filter(u=>!XA(u)).join(""),a=i.filter(u=>u.type==="thinking").map(u=>u.thinking??"").join(`
305
+ `),l=i.filter(u=>u.type==="tool_use").map(u=>({id:u.id??"",name:u.name??"",input:u.input??{}}));if(o||a||l.length){let u=Date.parse(e.timestamp??""),d=!isNaN(u)&&u>=t;r.push({type:"assistant",text:o,thinking:a,tools:l,live:d})}let c=e.message?.usage??e.usage,f=c&&{in:c.input_tokens??0,out:c.output_tokens??0,cached:c.cache_read_input_tokens??0,cacheCreate:c.cache_creation_input_tokens??0};return{events:r,usage:f,model:e.message?.model}}return{events:r}}chainWorking(e){let t;for(let o of e)(o.type==="user"||o.type==="assistant")&&(t=o);if(!t)return!1;if(t.type==="user"){try{let o=t.message?.content,a=typeof o=="string"?o:Array.isArray(o)?o.filter(c=>c&&c.type==="text").map(c=>c.text??"").join(""):"";if(!(Array.isArray(o)&&o.some(c=>c&&c.type==="tool_result"))&&a.trim()&&Lt(a)==="")return!1}catch{}return!0}let s=(Array.isArray(t.message?.content)?t.message.content:[]).filter(o=>o.type==="tool_use").map(o=>o.id);if(s.length===0)return!1;let i=new Set;for(let o of e){let a=o.message?.content;if(Array.isArray(a))for(let l of a)l.type==="tool_result"&&l.tool_use_id&&i.add(l.tool_use_id)}return s.some(o=>o&&!i.has(o))}sessionAlive(e){return oT(e)}sessionsWorking(e){return aT()}settlesSpawns(e){let t=zA(VA(e));if(t.length)return t;if(e.type==="user"){if(YA(e.toolUseResult))return[];let r=e.message?.content;return Array.isArray(r)?r.filter(s=>s?.type==="tool_result").map(s=>s.tool_use_id??"").filter(Boolean):[]}return[]}readPreview(e){return iT(e)}searchText(e){if(!e||gs(e)||e.type!=="user"&&e.type!=="assistant")return"";let t=e.message?.content,r="";if(typeof t=="string")r=Lt(t);else if(Array.isArray(t)){let s=t;r=e.type==="user"?s.map(fu).filter(Boolean).join(" "):s.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(" ")}return r.replace(/\s+/g," ").trim()}}});import{statSync as Cg,fstatSync as lT,readdirSync as cT,openSync as $g,readSync as Lg,closeSync as Mg,existsSync as uT}from"fs";import{basename as dT,join as yu,resolve as fT}from"path";import{homedir as _g}from"os";function hT(n){let e=n.trimStart();return pT.some(t=>e.startsWith(t))}function Vn(n,e){return Array.isArray(n)?n.map(t=>typeof t?.text=="string"?e&&hT(t.text)?"":Ae(t.text):t?.type==="input_image"&&typeof t.image_url=="string"&&t.image_url.startsWith("data:")?`![image](${t.image_url})`:"").filter(Boolean).join(`
306
+ `):""}function mT(n){return typeof n=="string"?Ae(n):Vn(n,!1)}function gT(n,e){let t=e??"",r=OT(t);if(!r.length)return{name:n,input:{script:t}};let s=r.map(i=>bu(i.fn)&&ys(i.arg)?ET(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:Rg(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}=Ig(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:wT(l)}}}return ys(o)?bu(i)?{name:n,input:bT(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:n,input:{script:t}}}return{name:n,input:Rg(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",Ig(o).diff]:bu(i)&&ys(o)?["command",o.cmd??o.command]:[i,o]))}}function bT(n){let e=Object.fromEntries(Object.entries(n).filter(([r])=>r!=="cmd"&&r!=="command"&&!yT.has(r))),t=n.command??n.cmd;return t===void 0?e:{command:t,...e}}function Rg(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 wT(n){let e=0,t=0;for(let r of n.split(`
307
+ `))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&t++;return`+${e} \u2212${t}`}function ET(n){let e=TT(n),t=e.map(AT);return e.length&&t.every(r=>r!==void 0)?t:void 0}function AT(n){let[e,...t]=n.split("|");if(!t.every(i=>xT.test(i.trim())))return;let r=PT(e);if(!vT.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(ST.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(kT.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}function TT(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===`
308
+ `||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 PT(n){return(n.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e)}function OT(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=Dg(n,s);if(i<0)break;e.push({fn:r[1],arg:Bg(n.slice(s+1,i).trim(),n)}),t.lastIndex=i+1}return e}function Bg(n,e){let t=n[0];if(t==='"'||t==="'"||t==="`")return Eo(n,0)===n.length-1?jg(n.slice(1,-1)):n;if(t==="{"){for(let r of[n,_T(n)])try{let s=JSON.parse(r);if(ys(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==="`"?Eo(e,s):i==="{"?Dg(e,s):-1;if(o>s)return Bg(e.slice(s,o+1),"")}}return n}function Dg(n,e){let t=0;for(let r=e;r<n.length;r++){let s=n[r];if(s==='"'||s==="'"||s==="`"){if(r=Eo(n,r),r<0)return-1}else if(s==="("||s==="["||s==="{")t++;else if((s===")"||s==="]"||s==="}")&&--t===0)return r}return-1}function Eo(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 jg(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)):CT[i]??i)}function _T(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=Eo(n,i);if(l<0)return n;r+=JSON.stringify(jg(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 Ig(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(`
309
+ `)}}function RT(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=IT(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:ke(NT(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:Ne(r)}}function IT(n){if(n.startsWith("{"))try{let e=JSON.parse(n);if(ys(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function $T(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 Fg(n,e){let t;try{t=$g(n,"r")}catch{return}try{let r=Buffer.alloc(e),s=Lg(t,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{Mg(t)}}function MT(n,e){let t;try{t=$g(n,"r")}catch{return}try{let r=Math.max(0,lT(t).size-e),s=Buffer.alloc(e),i=Lg(t,s,0,e,r);return{text:s.subarray(0,i).toString("utf8"),partial:r>0}}finally{Mg(t)}}function DT(n){for(let e of BT){let t=MT(n,e);if(t===void 0)return;let r=t.text.split(`
310
+ `);t.partial&&r.shift();for(let s=r.length-1;s>=0;s--)if(r[s].trim())try{let i=Date.parse(JSON.parse(r[s]).timestamp??"");if(!Number.isNaN(i))return i}catch{}if(!t.partial)break}}function jT(n){let t=Fg(n,65536);if(t===void 0)return;let r=t.text.indexOf(`
311
+ `);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;return typeof i?.cwd!="string"?{cwd:"",subagent:!1}:{cwd:i.cwd,subagent:typeof i.source=="object"&&!!i.source?.subagent}}catch{return{cwd:"",subagent:!1}}}var pT,ys,bu,yT,vT,ST,kT,xT,CT,NT,Ng,LT,zn,BT,wu=S(()=>{"use strict";ms();bo();pT=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];ys=n=>!!n&&typeof n=="object"&&!Array.isArray(n),bu=n=>n==="shell_command"||n==="exec_command",yT=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);vT=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,ST=/^-(Path|LiteralPath)$/i,kT=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,xT=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;CT={n:`
312
+ `,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};NT=n=>n?n.replace(/\r?\n$/,"").split(`
313
+ `).length:0;Ng=n=>{let e=fT(n);return process.platform==="win32"?e.toLowerCase():e},LT=12e4,zn=class extends $t{constructor(t=yu(_g(),".codex","sessions")){super();this.root=t}displayName="Codex Mirror";#e=0;#i;#t=new Map;#n=new Map;#f=new Map;#r=new Map;detectsSelf(){return!!process.env.CODEX_THREAD_ID}detectsInstalled(){return uT(yu(_g(),".codex"))}sessionsDir(t){return this.root}listSessionFiles(t){let r=Ng(t),s=[];for(let i of this.#o()){let o=0,a=0;try{let f=Cg(i);if(!f.isFile())continue;o=f.size,a=f.mtimeMs}catch{continue}let l=this.#t.get(i);if(l===void 0){if(l=jT(i),l===void 0)continue;this.#t.set(i,l)}if(l.subagent||Ng(l.cwd)!==r)continue;let c=dT(i,".jsonl");this.#f.set(c,i),s.push({sessionId:c,file:i,mtime:this.#c(i,o,a)})}return s}#c(t,r,s){let i=this.#n.get(t);if(i&&i.size===r&&i.mtime===s)return i.ms;let o=Math.max(s,DT(t)??0);return this.#n.set(t,{size:r,mtime:s,ms:o}),o}#o(){let t=[],r=s=>{try{return cT(s).map(i=>yu(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&&(t.ord=String(this.#e++),t.parent=this.#i,this.#i=t.ord),t.ord}parentOf(t){return t.parent}timestampOf(t){return t.timestamp}isSidechain(t){return!1}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=Vn(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=Vn(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=Vn(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"?gT(i.name??"",i.input):{name:i.name??"",input:$T(i.arguments)};return l&&this.#r.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.#r.get(a);return this.#r.delete(a),s.push({type:"tool_result",id:a,...RT(mT(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;if(!a)return{events:s};let l={in:Math.max(0,(a.input_tokens??0)-(a.cached_input_tokens??0)),out:a.output_tokens??0,cached:a.cached_input_tokens??0,cacheCreate:a.cache_write_input_tokens??0};return{events:s,usage:l}}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.#f.get(t);if(!r)return;let s;try{let i=Cg(r);s=this.#c(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<LT}readPreview(t){for(let r of(Fg(t,256*1024)?.text??"").split(`
314
+ `))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"?Vn(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"?"":Vn(t.payload.content,r==="user").replace(/\s+/g," ").trim()}};BT=[64*1024,1024*1024]});import{realpathSync as FT}from"fs";import{createHash as UT}from"crypto";import{join as Ao,resolve as qT}from"path";import{homedir as JT}from"os";function Mt(){let n=process.env.TYPEBULB_SERVERS_DIR;return n?Ao(n,".."):Ao(JT(),".typebulb")}function ut(){Ug||(Ug=!0,console.error(`${Mt()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function dt(){return process.env.TYPEBULB_SERVERS_DIR||Ao(Mt(),"servers")}function qg(n){let e=se(n),t=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Ao(Mt(),"canvas",`${t}-${bs(n)}.png`)}function bs(n){return UT("sha1").update(se(n)).digest("hex").slice(0,8)}function se(n){let e=qT(n),t=e;try{t=FT.native(e)}catch{}return(process.platform==="win32"?t.toLowerCase():t).replace(/\\/g,"/")}function Jg(n,e){let t=se(n),r=se(e);return t.startsWith(r.endsWith("/")?r:r+"/")?!t.includes("/node_modules/"):!1}var Ug,nt=S(()=>{"use strict";Ug=!1});import*as Hg from"net";import{mkdir as WT,readFile as KT,writeFile as Yg}from"fs/promises";import{existsSync as HT}from"fs";import{join as Vg}from"path";function Xg(){return Vg(Mt(),"blocks")}function vu(n){return Vg(Xg(),`${n}.json`)}function Po(n){return new Promise(e=>{let t=Hg.createServer();t.once("error",()=>e(!1)),t.listen(n,"127.0.0.1",()=>t.close(()=>e(!0)))})}async function GT(n){for(let e=n;e<65535;e++)if(await Po(e))return e;throw new Error(`No free port found above ${n}`)}async function Su(n){let{listBulbServers:e}=await Promise.resolve().then(()=>($e(),Qg)),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 Oo(n){try{let e=JSON.parse(await KT(vu(n),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function Co(n,e){try{return await Yg(vu(n),JSON.stringify(e,null,2)),!0}catch{return ut(),!1}}async function XT(n){let e=se(n);try{await WT(Xg(),{recursive:!0})}catch{return}let t=[];for(let o=0;o<Gg;o++)t.push(zg+o*an);let r=await Promise.all(t.map(async o=>({base:o,block:await Oo(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 Yg(vu(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await Oo(o))?.cwd===e)return o;l.code!=="EEXIST"&&ut();continue}if(!HT(a.cwd))return await Co(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>Wg(o.block)-Wg(a.block))[0];if(i)return await Co(i.base,s)?i.base:void 0}function Wg(n){return Object.values(n.slots).reduce((e,t)=>Math.max(e,t.usedAt??0),0)}async function QT(n,e){let t=await Oo(n)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=t.mirrors[e.agent];if(i!==void 0)return i;let o=Kg(t),a=o.has(0)?VT:0;for(;a>To&&o.has(a);)a--;return t.mirrors[e.agent]=a,await Co(n,t),a}let r=se(e.file),s=t.slots[r]?.offset;if(s===void 0){let i=Kg(t);for(s=To;s<an&&i.has(s);)s++;if(s>=an){let o=Object.entries(t.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:To,o&&delete t.slots[o[0]]}}return t.slots[r]={offset:s,usedAt:Date.now()},await Co(n,t),s}function Kg(n){return new Set([...Object.values(n.mirrors),...Object.values(n.slots).map(e=>e.offset)])}async function Gn(n,e){let t=await XT(e);return t===void 0?void 0:t+await QT(t,n)}async function ln(n){let e=se(n);for(let t=0;t<Gg;t++){let r=await Oo(zg+t*an);if(r?.cwd===e)return s=>r.slots[se(s)]?.usedAt??0}return()=>0}async function _o(n){if(n.explicit!==void 0)return await Po(n.explicit)||await Su(n.explicit),n.target.kind==="bulb"&&await Gn(n.target,n.cwd),{port:n.explicit};let e=await Gn(n.target,n.cwd);if(e!==void 0){let r=e-e%an,s=Date.now()+zT;do{if(await Po(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=To;i<an;i++){let o=r+i;if(o!==e&&await Po(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await GT(YT),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var zg,an,Gg,YT,To,VT,zT,cn=S(()=>{"use strict";nt();zg=20100,an=100,Gg=19,YT=23e3,To=1,VT=an-1,zT=3e3});var Le,Ro=S(()=>{"use strict";Le="0.60.1"});var Qg={};ci(Qg,{agentViewerCommand:()=>ly,bulbServerCommand:()=>ay,clearServerLog:()=>Tu,findProjectViewer:()=>$o,isAlive:()=>Xn,isMirror:()=>me,isProjectBulb:()=>Ru,isProjectMirror:()=>er,launchAgentViewer:()=>$u,launchBulbServer:()=>Ss,listBulbServers:()=>Q,probePageCount:()=>Nu,readServerLog:()=>Ye,readWaitCursor:()=>No,recordDenial:()=>_u,registerServer:()=>Cu,relayOpen:()=>Iu,runMarker:()=>Pu,serverLogPath:()=>Zn,serversForBulb:()=>dn,sliceRunLog:()=>Ou,startServerLog:()=>vs,stopBulbServer:()=>Qn,stopServer:()=>Bt,stopServersForBulb:()=>Lo,typebulbBinPath:()=>tr,unregisterServer:()=>un,writeWaitCursor:()=>ws});import{spawn as Zg}from"child_process";import{readdir as ZT,readFile as ny,writeFile as ry,unlink as ku,mkdir as eP}from"fs/promises";import{mkdirSync as sy,writeFileSync as Io,appendFileSync as tP,readFileSync as xu}from"fs";import*as Te from"path";import{fileURLToPath as nP}from"url";function Eu(n){return Te.join(dt(),`${n}.json`)}function Zn(n){return Te.join(dt(),`${n}.log`)}function Au(n){return Te.join(dt(),`${n}.wait.json`)}function iy(n){try{let e=JSON.parse(xu(Au(n),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function No(n,e=""){let t=iy(n)[e];return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0}function ws(n,e,t=""){try{sy(dt(),{recursive:!0});let r=iy(n);r[t]=e,Io(Au(n),JSON.stringify({cursors:r}))}catch{}}function vs(n){let e=Zn(n);try{sy(dt(),{recursive:!0}),Io(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(tP(e,l),s+=l.length,s>2*ey){let c=xu(e),f=c.subarray(Math.max(0,c.length-ey));Io(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 Tu(n){try{Io(Zn(n),"")}catch{}}function Ye(n,e=0){try{let t=xu(Zn(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 Pu(n){return`\u2500\u2500 run ${n} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function sP(n){let e=rP.exec(n);return e?Number(e[1]):void 0}function Ou(n,e){let t=n.split(`
315
+ `),r=[];if(t.forEach((o,a)=>{let l=sP(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(`
316
+ `)}function Xn(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}async function Cu(n){try{await eP(dt(),{recursive:!0}),await ry(Eu(n.pid),JSON.stringify({version:Le,...n}))}catch{ut()}}async function _u(n,e){let t=Eu(n);try{let r=JSON.parse(await ny(t,"utf8"));if(r.denied===e)return;r.denied=e,await ry(t,JSON.stringify(r))}catch{}}async function un(n){await ku(Eu(n)).catch(()=>{}),await ku(Zn(n)).catch(()=>{}),await ku(Au(n)).catch(()=>{})}function me(n){return n.agent!=null}function er(n,e){return me(n)&&n.cwd!=null&&se(n.cwd)===se(e)}function Ru(n,e){return!me(n)&&Jg(n.file,e)}async function Q(n){let e;try{e=await ZT(dt())}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 ny(Te.join(dt(),s),"utf8"))}catch{await un(i);return}o&&typeof o.pid=="number"&&Xn(o.pid)?t.push(o):await un(i)})),(n?t.filter(s=>Ru(s,n)):t).sort((s,i)=>s.startedAt-i.startedAt)}async function $o(n,e){return(await Q()).find(t=>er(t,n)&&(e?t.agent===e:!0))}async function Iu(n,e){let t=new URL(n).port,r=(await Q()).filter(a=>String(a.port)!==t),s=r.filter(a=>er(a,e)),i=r.filter(a=>Ru(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":`${Te.basename(a.file)}'s page`};me(a)&&(o+=f??0)}catch{}return o>0?{where:"external"}:void 0}async function Qn(n){try{process.kill(n,"SIGTERM")}catch{}await un(n)}async function Nu(n){try{let e=await fetch(`${n.url}/__pages`,{signal:AbortSignal.timeout(iP)});if(!e.ok)return;let{pages:t}=await e.json();return typeof t=="number"?t:void 0}catch{return}}async function Bt(n,e=me(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(ty)});if(!t.ok)throw new Error(`/__stop ${t.status}`);let{closed:r=0,stuck:s=0}=await t.json(),i=Date.now()+ty;for(;Xn(n.pid)&&Date.now()<i;)await oy(100);return Xn(n.pid)?(await Qn(n.pid),"killed"):(await un(n.pid),{closed:r,stuck:s})}catch{return await Qn(n.pid),"killed"}}function dn(n,e){let t=se(e);return n.filter(r=>!me(r)&&r.pid!==process.pid&&se(r.file)===t)}async function Lo(n,e){let t=dn(await Q(),n);for(let r of t)await Bt(r,e!==void 0&&r.port===e?"keep":"close");return t}function oP(n,e,t){(process.platform==="win32"?Zg("cmd",["/c","start","","/b",n,...e],{cwd:t,stdio:"ignore",windowsHide:!0}):Zg(n,e,{cwd:t,detached:!0,stdio:"ignore"})).unref()}function tr(){return Te.join(Te.dirname(nP(import.meta.url)),"index.js")}function ay(n,e={}){return{command:process.execPath,args:[tr(),...e.trust?["--trust"]:[],...e.mode?["--mode",e.mode]:[],n,...e.open===!1?["--no-open"]:[]]}}function ly(n){return{command:process.execPath,args:[tr(),`agent:${n}`,"--no-open"]}}async function cy(n,e,t,r){let s=await n();if(s)return s;oP(e.command,e.args,t);let i=Date.now()+2e4;for(;Date.now()<i;){await oy(150);let o=await n();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function Ss(n,e={}){let t=e.cwd??process.cwd(),r=Te.resolve(t,n),s=await Gn({kind:"bulb",file:r},t),[i]=await Lo(r,s),o={...e,mode:e.mode??i?.mode};return cy(async()=>dn(await Q(),r)[0],ay(n,o),t,Te.basename(n))}async function $u(n,e=process.cwd()){return cy(()=>$o(e,n),ly(n),e,`the ${n} mirror`)}var ey,rP,ty,iP,oy,$e=S(()=>{"use strict";nt();cn();Ro();ey=1e6;rP=/^── run (\d+) ── /;ty=6e3,iP=500;oy=n=>new Promise(e=>setTimeout(e,n))});function nr(n){return{...Zf(n),server:n.files.get("server.ts")??""}}function Mo(n){return!!n.server&&!n.code}var ks=S(()=>{"use strict";ee();ee()});function Bo(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 Lu(n){return Kn(Bo(n)??"bulb")||"bulb"}var Mu=S(()=>{"use strict";ee()});import{readdirSync as aP,readFileSync as lP,statSync as cP}from"fs";import{join as uy,basename as uP}from"path";function fy(n,e,t){if(e>8)return t;let r;try{r=aP(n,{withFileTypes:!0})}catch{return t}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;fy(uy(n,s.name),e+1,t)}else s.isFile()&&s.name.endsWith(".bulb.md")&&t.push(uy(n,s.name));return t}function dP(n,e){let t,r=!1;try{let s=lP(n,"utf8");t=Bo(s.slice(0,1024));let i=We(s);r=!!i&&Mo(nr(i))}catch{}return{mtime:e,name:t??uP(n).replace(/\.bulb\.md$/,""),serverOnly:r}}function Do(n){let e=new Map,t=fy(n,0,[]).map(r=>{let s=0;try{s=cP(r).mtimeMs}catch{}let i=s?dy.get(r):void 0,o=i?.mtime===s?i:dP(r,s);return s&&e.set(r,o),{path:r,...o}});return dy=e,t}var dy,py=S(()=>{"use strict";ee();ks();Mu();dy=new Map});function rr(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 jo=S(()=>{"use strict"});import{readFile as fP}from"fs/promises";async function Bu(n){try{let e=We(await fP(n,"utf-8"));return e?rr(nr(e)):void 0}catch{return}}var hy=S(()=>{"use strict";ks();jo()});function Du(n){let e=n.split(""),t=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
314
317
  `&&(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]!==`
315
- `;)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==="/"&&DT.has(s)){let a=r+1,l=!1;for(;a<n.length&&n[a]!==`
318
+ `;)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==="/"&&pP.has(s)){let a=r+1,l=!1;for(;a<n.length&&n[a]!==`
316
319
  `;){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]!==`
317
- `;)n[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=ay(n,r);t(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function ay(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=ay(n,t);continue}if(s==="$"&&n[t+1]==="{"){r++,t+=2;continue}if(s==="}"&&r>0){r--,t++;continue}t++}return n.length}var DT,ly=v(()=>{DT=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function UT(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 cy(n){let e=[];for(let s of FT)for(let i of n.matchAll(s)){let o=UT(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(`
318
- `).length-1}));return r}function uy(n){return cy(Cu(n)).map(e=>e.root)}function Ss(n,e){if(!n)return[];let{target:t,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=n.split(`
319
- `),a=Cu(n).split(`
320
- `);for(let l=0;l<o.length;l++){let c=a[l],f=l+1+s;for(let u of jT)u.targets.includes(t)&&u.pattern.test(c)&&i.push({type:u.type,severity:"error",message:WT(u.type,f),lineNumber:f,lineContent:o[l]})}return t==="client"&&r&&i.push(...qT(a,o,r,s)),i}function qT(n,e,t,r){let s=new Set(Object.keys(t));return cy(n.join(`
321
- `)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:JT(i,a),lineNumber:a,lineContent:e[o]}})}function JT(n,e){return`Import "${n}" is not declared in config.json dependencies! Found on line ${e}.
320
+ `;)n[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=my(n,r);t(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function my(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=my(n,t);continue}if(s==="$"&&n[t+1]==="{"){r++,t+=2;continue}if(s==="}"&&r>0){r--,t++;continue}t++}return n.length}var pP,gy=S(()=>{pP=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function gP(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 yy(n){let e=[];for(let s of mP)for(let i of n.matchAll(s)){let o=gP(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(`
321
+ `).length-1}));return r}function by(n){return yy(Du(n)).map(e=>e.root)}function xs(n,e){if(!n)return[];let{target:t,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=n.split(`
322
+ `),a=Du(n).split(`
323
+ `);for(let l=0;l<o.length;l++){let c=a[l],f=l+1+s;for(let u of hP)u.targets.includes(t)&&u.pattern.test(c)&&i.push({type:u.type,severity:"error",message:wP(u.type,f),lineNumber:f,lineContent:o[l]})}return t==="client"&&r&&i.push(...yP(a,o,r,s)),i}function yP(n,e,t,r){let s=new Set(Object.keys(t));return yy(n.join(`
324
+ `)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:bP(i,a),lineNumber:a,lineContent:e[o]}})}function bP(n,e){return`Import "${n}" is not declared in config.json dependencies! Found on line ${e}.
322
325
 
323
326
  **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.
324
327
 
@@ -332,7 +335,7 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
332
335
  }
333
336
  \`\`\`
334
337
 
335
- **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 WT(n,e){return n==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
338
+ **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 wP(n,e){return n==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
336
339
 
337
340
  **CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
338
341
 
@@ -486,22 +489,22 @@ import { something } from 'module-name'
486
489
  const something = require('module-name') // NOT SUPPORTED!
487
490
  \`\`\`
488
491
 
489
- **Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var un,dn,jT,FT,Mo=v(()=>{ly();un=["client"],dn=["client","server"],jT=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:un},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:dn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:un},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:un},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:un},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:dn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:dn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:dn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:dn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:dn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:dn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:un},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:un},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:un}],FT=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function Ru(n){let e=Je(n);if(!e)return n;let t=e.files.get("code.tsx");if(!t)return n;let r=uy(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 u=Df(c);u&&(l[u]=f)}return l.config=JSON.stringify(i,null,2),Yf(l)}var dy=v(()=>{"use strict";ee();Mo()});import{spawn as fy}from"child_process";import{basename as KT}from"path";function HT(){return process.env.TYPEBULB_EDITOR||"code"}function VT(n,e,t){return t==null?[e]:YT.test(KT(n))?["-g",`${e}:${t}`]:[`+${t}`,e]}function zT(n,e){let t=HT();return{command:t,args:VT(t,n,e)}}function Iu(n,e){let{command:t,args:r}=zT(n,e),s=process.platform==="win32"?fy("cmd.exe",["/d","/s","/c",t,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):fy(t,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var YT,py=v(()=>{"use strict";YT=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as GT,writeFileSync as XT,mkdirSync as QT,statSync as ZT}from"fs";import{join as eP}from"path";function Nu(){return eP($t(),"trust.json")}function $u(){try{let n=Nu(),e=ZT(n).mtimeMs;if(ks?.mtime!==e){let t=JSON.parse(GT(n,"utf8"));ks={mtime:e,set:new Set(Array.isArray(t)?t:[])}}return ks.set}catch{return ks=void 0,new Set}}function tP(n){try{QT($t(),{recursive:!0}),XT(Nu(),JSON.stringify([...n])),ks=void 0}catch(e){throw new Error(`can't write ${Nu()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function fn(n){return $u().has(re(n))}function tr(n,e){let t=new Set($u()),r=re(n);(e?t.has(r):!t.has(r))||(e?t.add(r):t.delete(r),tP(t))}function Lu(){return[...$u()]}var ks,xs=v(()=>{"use strict";tt()});function rr(n){return(n.includes("://")?n:`http://${n}`).replace(/\/+$/,"")}function Mu(){return As}async function ut(){let[n,e]=await Promise.all([my(),aP()]);return oP([...lP(e),...n],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function oP(n,e,t){return!e||!t?n:n.map(r=>r.provider===e&&r.name===t?{...r,default:!0}:r)}async function hy(){let n;try{n=await fetch(nP,{signal:AbortSignal.timeout(sP)})}catch(e){As=`catalog fetch failed: ${e?.message??e}`;return}if(!n.ok){As=`catalog fetch failed: HTTP ${n.status}`;return}try{return await n.json()}catch(e){As=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function aP(){if(Es&&Date.now()-Es.fetchedAt<=rP)return Es.models;let n=await hy()??await hy();return n?(Es={models:n,fetchedAt:Date.now()},As=void 0,n):Es?.models??[]}async function my(){if(Bo&&Date.now()-Bo.fetchedAt<=iP)return Bo.models;let n=rr(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let t=await fetch(new URL("/api/tags",n).toString());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 Bo={models:e,fetchedAt:Date.now()},e}function lP(n){let e=new Set(Object.entries(nr).filter(([,t])=>!!process.env[t]).map(([t])=>t));return n.filter(t=>e.has(t.provider))}function Bu(){return Object.values(nr).some(n=>!!process.env[n])}async function Do(){return Bu()||process.env.TB_AI_BASE_URL||(await my()).length>0?"own":"none"}function gy(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(`
490
- `)}var nr,nP,rP,sP,iP,Es,Bo,As,pn=v(()=>{"use strict";nr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};nP="https://api.typebulb.com/api/models",rP=1440*60*1e3,sP=5e3,iP=60*1e3});var yy,by,nt,hn=v(()=>{yy=n=>n!=null&&n>=0&&n<=4?n:void 0,by=(n,e)=>{let t={...n};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(t[r]=e[r]);return t},nt=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,Ye,sr=v(()=>{Pe=class extends Error{constructor(e,t="unknown",r=!1){super(e),this.code=t,this.retryable=r}},Ye=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=`
492
+ **Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var fn,pn,hP,mP,Fo=S(()=>{gy();fn=["client"],pn=["client","server"],hP=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:fn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:pn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:fn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:fn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:fn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:pn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:pn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:pn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:pn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:pn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:pn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:fn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:fn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:fn}],mP=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function ju(n){let e=We(n);if(!e)return n;let t=e.files.get("code.tsx");if(!t)return n;let r=by(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 u=Yf(c);u&&(l[u]=f)}return l.config=JSON.stringify(i,null,2),np(l)}var wy=S(()=>{"use strict";ee();Fo()});import{spawn as vy}from"child_process";import{basename as vP}from"path";function SP(){return process.env.TYPEBULB_EDITOR||"code"}function xP(n,e,t){return t==null?[e]:kP.test(vP(n))?["-g",`${e}:${t}`]:[`+${t}`,e]}function EP(n,e){let t=SP();return{command:t,args:xP(t,n,e)}}function Fu(n,e){let{command:t,args:r}=EP(n,e),s=process.platform==="win32"?vy("cmd.exe",["/d","/s","/c",t,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):vy(t,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var kP,Sy=S(()=>{"use strict";kP=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as AP,writeFileSync as TP,mkdirSync as PP,statSync as OP}from"fs";import{join as CP}from"path";function Uu(){return CP(Mt(),"trust.json")}function qu(){try{let n=Uu(),e=OP(n).mtimeMs;if(Es?.mtime!==e){let t=JSON.parse(AP(n,"utf8"));Es={mtime:e,set:new Set(Array.isArray(t)?t:[])}}return Es.set}catch{return Es=void 0,new Set}}function _P(n){try{PP(Mt(),{recursive:!0}),TP(Uu(),JSON.stringify([...n])),Es=void 0}catch(e){throw new Error(`can't write ${Uu()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function hn(n){return qu().has(se(n))}function sr(n,e){let t=new Set(qu()),r=se(n);(e?t.has(r):!t.has(r))||(e?t.add(r):t.delete(r),_P(t))}function Ju(){return[...qu()]}var Es,As=S(()=>{"use strict";nt()});function or(n){return(n.includes("://")?n:`http://${n}`).replace(/\/+$/,"")}function Wu(){return Ps}async function ft(){let[n,e]=await Promise.all([xy(),BP()]);return MP([...DP(e),...n],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function MP(n,e,t){return!e||!t?n:n.map(r=>r.provider===e&&r.name===t?{...r,default:!0}:r)}async function ky(){let n;try{n=await fetch(RP,{signal:AbortSignal.timeout(NP)})}catch(e){Ps=`catalog fetch failed: ${e?.message??e}`;return}if(!n.ok){Ps=`catalog fetch failed: HTTP ${n.status}`;return}try{return await n.json()}catch(e){Ps=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function BP(){if(Ts&&Date.now()-Ts.fetchedAt<=IP)return Ts.models;let n=await ky()??await ky();return n?(Ts={models:n,fetchedAt:Date.now()},Ps=void 0,n):Ts?.models??[]}async function xy(){if(Uo&&Date.now()-Uo.fetchedAt<=$P)return Uo.models;let n=or(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let t=await fetch(new URL("/api/tags",n).toString(),{signal:AbortSignal.timeout(LP)});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 Uo={models:e,fetchedAt:Date.now()},e}function DP(n){let e=new Set(Object.entries(ir).filter(([,t])=>!!process.env[t]).map(([t])=>t));return n.filter(t=>e.has(t.provider))}function Ku(){return Object.values(ir).some(n=>!!process.env[n])}async function qo(){return Ku()||process.env.TB_AI_BASE_URL||(await xy()).length>0?"own":"none"}function Ey(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(`
493
+ `)}var ir,RP,IP,NP,$P,LP,Ts,Uo,Ps,mn=S(()=>{"use strict";ir={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};RP="https://api.typebulb.com/api/models",IP=1440*60*1e3,NP=5e3,$P=60*1e3,LP=1500});var Ay,Ty,rt,gn=S(()=>{Ay=n=>n!=null&&n>=0&&n<=4?n:void 0,Ty=(n,e)=>{let t={...n};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(t[r]=e[r]);return t},rt=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,Ve,ar=S(()=>{Pe=class extends Error{constructor(e,t="unknown",r=!1){super(e),this.code=t,this.retryable=r}},Ve=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=`
491
494
 
492
- `){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 jo,Du=v(()=>{hn();sr();jo=class extends Ye{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(`
493
- `)),!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 nt({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(`
495
+ `){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 Jo,Hu=S(()=>{gn();ar();Jo=class extends Ve{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(`
496
+ `)),!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 rt({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(`
494
497
 
495
- `)}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 ir,Fo=v(()=>{hn();sr();ir=class extends Ye{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 nt({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var ju,Uo,Fu=v(()=>{Fo();ju={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},Uo=class extends ir{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",...ju}}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 qo,Uu=v(()=>{hn();sr();qo=class extends Ye{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(`
498
+ `)}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 lr,Wo=S(()=>{gn();ar();lr=class extends Ve{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 rt({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var Yu,Ko,Vu=S(()=>{Wo();Yu={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},Ko=class extends lr{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",...Yu}}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 Ho,zu=S(()=>{gn();ar();Ho=class extends Ve{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(`
496
499
 
497
- `);return{text:t,reasoning:r||void 0,usage:nt(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 Jo,qu=v(()=>{hn();sr();Jo=class extends Ye{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,`
500
+ `);return{text:t,reasoning:r||void 0,usage:rt(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 Yo,Gu=S(()=>{gn();ar();Yo=class extends Ve{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,`
498
501
  `),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),u=f!==void 0&&f>=3?{thinkingLevel:this.thinkingLevelFor(f,c)}:{thinkingBudget:this.budgetMap[c]};l.generationConfig={thinkingConfig:c===0?u:{includeThoughts:!0,...u}}}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(`
499
- `)[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 nt({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 Wo,Ju=v(()=>{Fo();Wo=class extends ir{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 mn(n){let e=cP.get(n);if(!e)throw new Error(`Unsupported protocol: ${n}`);return e}function uP(n,e){return n.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function Wu(n,e){let t=mn(n.protocol),r=t.getPath(n.model,e.stream),s=uP(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 dP(n){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(n)}async function or(n,e){let t=mn(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||dP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var wy,cP,Ku=v(()=>{Du();Fu();Uu();qu();Ju();wy=new Wo,cP=new Map([["openai",new jo],["openrouter",new Uo],["anthropic",new qo],["gemini",new Jo],["ollama",wy],["openai-compat",wy]])});function vy(n){let e=n.indexOf(`\r
502
+ `)[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 rt({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 Vo,Xu=S(()=>{Wo();Vo=class extends lr{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 yn(n){let e=jP.get(n);if(!e)throw new Error(`Unsupported protocol: ${n}`);return e}function FP(n,e){return n.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function Qu(n,e){let t=yn(n.protocol),r=t.getPath(n.model,e.stream),s=FP(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 UP(n){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(n)}async function cr(n,e){let t=yn(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||UP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var Py,jP,Zu=S(()=>{Hu();Vu();zu();Gu();Xu();Py=new Vo,jP=new Map([["openai",new Jo],["openrouter",new Ko],["anthropic",new Ho],["gemini",new Yo],["ollama",Py],["openai-compat",Py]])});function Oy(n){let e=n.indexOf(`\r
500
503
  \r
501
504
  `),t=n.indexOf(`
502
505
 
503
- `);return e!==-1&&(t===-1||e<t)?{pos:e,len:4}:t!==-1?{pos:t,len:2}:{pos:-1,len:0}}function Hu(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(`
504
- `).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*Sy(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 u=Hu(s);u!==void 0&&u!=="done"&&(yield u)}return}t?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:f}=vy(s);for(;c!==-1;){let u=s.slice(0,c);s=s.slice(c+f);let d=Hu(u);if(d==="done")return;d!==void 0&&(yield d),{pos:c,len:f}=vy(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await n.cancel()}catch{}}}async function Yu(n,e){return(await ar(n,e)).text}async function ar(n,e){if(!n.body)throw new Error("Response body is missing");let t="",r;for await(let s of gn(n,e))s.kind==="text"?t+=s.text:s.kind==="usage"&&(r=s.usage);return{text:t,usage:r}}async function*gn(n,e){let t=e??(n.headers.get("X-Provider-Protocol")||"openai"),r=mn(t);if(!n.body)return;let s=n.body.getReader(),i;for await(let a of Sy(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=by(i,l.usage))}let o=nt(i);o&&(yield{kind:"usage",usage:o})}var ky=v(()=>{hn();Ku()});import{strToU8 as fP,strFromU8 as pP,deflateSync as hP,inflateSync as mP}from"fflate";function zu(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.
506
+ `);return e!==-1&&(t===-1||e<t)?{pos:e,len:4}:t!==-1?{pos:t,len:2}:{pos:-1,len:0}}function ed(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(`
507
+ `).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*Cy(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 u=ed(s);u!==void 0&&u!=="done"&&(yield u)}return}t?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:f}=Oy(s);for(;c!==-1;){let u=s.slice(0,c);s=s.slice(c+f);let d=ed(u);if(d==="done")return;d!==void 0&&(yield d),{pos:c,len:f}=Oy(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await n.cancel()}catch{}}}async function td(n,e){return(await ur(n,e)).text}async function ur(n,e){if(!n.body)throw new Error("Response body is missing");let t="",r;for await(let s of bn(n,e))s.kind==="text"?t+=s.text:s.kind==="usage"&&(r=s.usage);return{text:t,usage:r}}async function*bn(n,e){let t=e??(n.headers.get("X-Provider-Protocol")||"openai"),r=yn(t);if(!n.body)return;let s=n.body.getReader(),i;for await(let a of Cy(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=Ty(i,l.usage))}let o=rt(i);o&&(yield{kind:"usage",usage:o})}var _y=S(()=>{gn();Zu()});import{strToU8 as qP,strFromU8 as JP,deflateSync as WP,inflateSync as KP}from"fflate";function rd(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.
505
508
 
506
509
  ---
507
510
  Instructions:
@@ -519,13 +522,13 @@ ${r}
519
522
  </data>`)}return t.push(`
520
523
  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(`
521
524
 
522
- `)}function Ts(n){try{return JSON.parse(n)}catch{return}}function xy(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 yP(n){let e=xy(n,t=>t.replace(/,(\s*[}\]])/g,"$1"));return e!==n?e:void 0}function bP(n){let e=xy(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 wP(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 vP(n){let e,t=0;for(;t<n.length;){let r=n[t];if(r==="{"||r==="["){let s=wP(n,t);if(s!==-1){let i=n.slice(t,s+1),o=Ts(i);o!==void 0&&(e={parsed:o,json:i}),t=s+1;continue}}t++}return e}function Gu(n){let e=[],t=n.trim();t.startsWith("```")&&(t=t.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Ts(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=Ts(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=Ts(t),r!==void 0))return{parsed:r,json:t,fixesApplied:e}}for(let[o,a]of gP){let l=a(t);if(l!==void 0){let c=Ts(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=vP(n);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:t,fixesApplied:e}}function Xu(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=hP(fP(t),{level:9}),s=kP(r),i=`${Ey}:${s}`;return i.length>SP?"":"#"+Vu+i}catch{return""}}function Qu(n){try{let e=n.startsWith("#")?n.slice(1):n;if(!e.startsWith(Vu))return;let t=e.slice(Vu.length),r=t.indexOf(":");if(r===-1||t.slice(0,r)!==Ey)return;let s=xP(t.slice(r+1)),i=JSON.parse(pP(mP(s)));if(!i||typeof i!="object")return;let o=i.i!==void 0,a=Array.isArray(i.d);if(!o&&!a)return;let l={};return o&&(l.insight=i.i,l.insightJson=JSON.stringify(i.i,null,2)),a&&(l.data=i.d),l}catch{return}}function kP(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 xP(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 gP,Vu,Ey,SP,Ay=v(()=>{gP=[["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",yP],["arithmetic constants",bP]];Vu="tb=",Ey="1",SP=6e4});var Mt=v(()=>{hn();sr();Ku();ky();Ay();Fo();Uu();qu();Du();Fu();Ju()});import{readFileSync as Ty,existsSync as EP}from"fs";import*as rt from"path";function Py(n){return[...n?[`.env.${n}.local`,`.env.${n}`]:[],".env.local",".env"]}function Le(n,e=process.cwd()){let t={},r=[];for(let s of Py(n)){let i;try{i=Ty(rt.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of Oy(i))process.env[o]===void 0&&(process.env[o]=a,t[o]=s)}return{mode:n,sources:t,loaded:r}}function*Oy(n){for(let e of n.split(`
523
- `)){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 Ko(n,e=process.cwd()){for(let t of Py()){let r;try{r=Ty(rt.resolve(e,t),"utf-8")}catch{continue}for(let[s,i]of Oy(r))if(s===n)return i}return process.env[n]}function AP(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 _y(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function Bt(n,e,t){let{sources:r,mode:s,loaded:i}=n,o=process.cwd(),a=rt.dirname(e),l=`(mode: ${s??"none"})`,c=t?AP(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 u=rt.resolve(a)!==rt.resolve(o);if(u)for(let p of[".env.local",".env"])EP(rt.join(a,p))&&console.log(`env: ${rt.join(a,p)} present but not loaded (cwd is ${o})`);let d=c.filter(p=>process.env[p]===void 0);if(d.length){let p=u?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${d.join(", ")} but ${d.length>1?"they are":"it's"} unset${p}`)}}var dt=v(()=>{"use strict"});function ft(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=mn(t)}catch{return`Unknown provider '${t}'.`}if(t==="ollama")return{apiKey:"",baseUrl:`${rr(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=nr[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 ${_y()}.`}function Dt(n,e){let t=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return Wu(n,{messages:t,stream:!0,effort:yy(e.effort),webSearch:e.webSearch,signal:e.signal})}var Ho=v(()=>{"use strict";Mt();Mt();dt();pn()});import{readFileSync as TM,existsSync as TP}from"fs";import*as lr from"path";import{fileURLToPath as PP}from"url";function OP(){let n=lr.dirname(PP(import.meta.url));for(;!TP(lr.join(n,"package.json"));){let e=lr.dirname(n);if(e===n)break;n=e}return n}function Ps(){return lr.join(OP(),"SKILL.md")}var Zu=v(()=>{"use strict"});import{transform as _P}from"sucrase";function ed(n,e={}){let t=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=_P(n,{transforms:t,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var Cy=v(()=>{});function CP(n){return n.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
525
+ `)}function Os(n){try{return JSON.parse(n)}catch{return}}function Ry(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 YP(n){let e=Ry(n,t=>t.replace(/,(\s*[}\]])/g,"$1"));return e!==n?e:void 0}function VP(n){let e=Ry(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 zP(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 GP(n){let e,t=0;for(;t<n.length;){let r=n[t];if(r==="{"||r==="["){let s=zP(n,t);if(s!==-1){let i=n.slice(t,s+1),o=Os(i);o!==void 0&&(e={parsed:o,json:i}),t=s+1;continue}}t++}return e}function sd(n){let e=[],t=n.trim();t.startsWith("```")&&(t=t.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Os(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=Os(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=Os(t),r!==void 0))return{parsed:r,json:t,fixesApplied:e}}for(let[o,a]of HP){let l=a(t);if(l!==void 0){let c=Os(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=GP(n);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:t,fixesApplied:e}}function id(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=WP(qP(t),{level:9}),s=QP(r),i=`${Iy}:${s}`;return i.length>XP?"":"#"+nd+i}catch{return""}}function od(n){try{let e=n.startsWith("#")?n.slice(1):n;if(!e.startsWith(nd))return;let t=e.slice(nd.length),r=t.indexOf(":");if(r===-1||t.slice(0,r)!==Iy)return;let s=ZP(t.slice(r+1)),i=JSON.parse(JP(KP(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 QP(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 ZP(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 HP,nd,Iy,XP,Ny=S(()=>{HP=[["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",YP],["arithmetic constants",VP]];nd="tb=",Iy="1",XP=6e4});var Dt=S(()=>{gn();ar();Zu();_y();Ny();Wo();zu();Gu();Hu();Vu();Xu()});import{readFileSync as $y,existsSync as eO}from"fs";import*as st from"path";function Ly(n){return[...n?[`.env.${n}.local`,`.env.${n}`]:[],".env.local",".env"]}function Me(n,e=process.cwd()){let t={},r=[];for(let s of Ly(n)){let i;try{i=$y(st.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of My(i))process.env[o]===void 0&&(process.env[o]=a,t[o]=s)}return{mode:n,sources:t,loaded:r}}function*My(n){for(let e of n.split(`
526
+ `)){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 zo(n,e=process.cwd()){for(let t of Ly()){let r;try{r=$y(st.resolve(e,t),"utf-8")}catch{continue}for(let[s,i]of My(r))if(s===n)return i}return process.env[n]}function tO(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 By(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function jt(n,e,t){let{sources:r,mode:s,loaded:i}=n,o=process.cwd(),a=st.dirname(e),l=`(mode: ${s??"none"})`,c=t?tO(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 u=st.resolve(a)!==st.resolve(o);if(u)for(let p of[".env.local",".env"])eO(st.join(a,p))&&console.log(`env: ${st.join(a,p)} present but not loaded (cwd is ${o})`);let d=c.filter(p=>process.env[p]===void 0);if(d.length){let p=u?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${d.join(", ")} but ${d.length>1?"they are":"it's"} unset${p}`)}}var pt=S(()=>{"use strict"});function ht(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=yn(t)}catch{return`Unknown provider '${t}'.`}if(t==="ollama")return{apiKey:"",baseUrl:`${or(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=ir[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 ${By()}.`}function Ft(n,e){let t=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return Qu(n,{messages:t,stream:!0,effort:Ay(e.effort),webSearch:e.webSearch,signal:e.signal})}var Go=S(()=>{"use strict";Dt();Dt();pt();mn()});import{readFileSync as pB,existsSync as nO}from"fs";import*as dr from"path";import{fileURLToPath as rO}from"url";function sO(){let n=dr.dirname(rO(import.meta.url));for(;!nO(dr.join(n,"package.json"));){let e=dr.dirname(n);if(e===n)break;n=e}return n}function Cs(){return dr.join(sO(),"SKILL.md")}var ad=S(()=>{"use strict"});import{transform as iO}from"sucrase";function ld(n,e={}){let t=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=iO(n,{transforms:t,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var Dy=S(()=>{});function oO(n){return n.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
524
527
  `)[0]}`).join(`
525
- `)}function Ry(n,e){let t=Ss(n,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(t.length)throw new Error(`Lint failed:
526
- ${CP(t)}`)}var Iy=v(()=>{"use strict";Mo()});var jt,Os,td,_s=v(()=>{jt="https://esm.sh",Os="https://cdn.jsdelivr.net/npm/",td="https://data.jsdelivr.com/v1/package/npm/"});function Ny(n){let e=(n||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var D,cr,$y,Cs=v(()=>{_s();D=class n{constructor(e,t,r){let s=typeof e=="string"?n.parse(e):e;this.name=s.name,this.version=cr(t??s.version),this.subpath=cr(r??s.subpath)}static parse(e){let t=Ny(e||"");if(!t.length)return new n({name:""});if(t[0].startsWith("@")){let s=t[0],[i,o]=$y(t[1]??""),a=cr(t.slice(2).join("/"));return new n({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=$y(t[0]),o=cr(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(jt).host,s=new URL(Os).host;if(t.host===r){let i=Ny(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:cr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},cr=n=>n&&n.length?n:void 0,$y=n=>{let e=n.indexOf("@");return e<0?[n,void 0]:[n.slice(0,e),cr(n.slice(e+1))]}});async function Se(n){try{return await n()}catch{return}}var Yo=v(()=>{});function yn(n){let e=n||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function nd(n){return n.startsWith("./")?n:`./${n}`}var Rs,rd=v(()=>{Cs();Yo();_s();Rs=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 D(e):e;return`${Os}${t.name}${t.version?`@${t.version}`:""}/`}file(e,t){return new URL(yn(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(",")),`${jt}/${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),`${jt}/${e}`]);return this.pinCache.set(e,{value:s,ts:t}),s}async tryResolveFromUrls(e){for(let t of e){let r=await Se(()=>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 Se(()=>this.http.getJson(`${td}${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=D.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:u,peerDependenciesMeta:d}=r;return{name:e,version:t,dependencies:f,peerDependencies:u,peerDependenciesMeta:d}}let s=this.packageJson(new D(`${e}@${t}`)),i=await Se(()=>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 Ly,Is,sd,RP,Ns,Vo=v(()=>{Ly=n=>n.startsWith("@types/"),Is=n=>Object.keys(n?.peerDependencies||{}).filter(e=>!Ly(e)),sd=n=>Object.keys(n?.dependencies||{}).filter(e=>!Ly(e)),RP=n=>Is(n).filter(e=>!n?.peerDependenciesMeta?.[e]?.optional),Ns=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 RP(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=>Is(i.meta))),r=new Map;for(let i of e)for(let o of sd(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:Is(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var $s,id=v(()=>{Cs();Yo();$s=class{constructor(e,t,r){this.cache=e,this.cdn=t,this.semver=r}async learnExactVersion(e){let t=await Se(()=>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 Se(()=>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 Se(()=>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 D(e),s=r.root(),i=t[s],o=i?await Se(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as IP,parse as NP}from"es-module-lexer";var ur,od=v(()=>{Cs();_s();Vo();ur=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))D.isBare(s[1])&&t.add(s[1])}return Array.from(t)}async extractImports(e){let t=new Set,r=s=>{D.isBare(s)&&t.add(s)};try{await IP;let[s]=NP(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(u=>!r?.has(D.rootOf(u))),i=[...new Set(s.map(D.rootOf))],o=await Promise.all(i.map(async u=>({name:u,version:await this.resolveVersion(u,t)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,u=>this.resolveVersion(u,t)),f=this.buildEntries([...s,...c.map(u=>u.name)],a,l);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,u])=>u)}}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(D.rootOf(p));return new D(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!==D.rootOf(p)).map(D.rootOf)),l=[],c=new Set,f=new Set(e.filter(p=>p===D.rootOf(p))),u=new Set;for(let p of e){let m=D.rootOf(p),h=s.get(m),{isPeerRoot:b,hasPeers:E,isSharedDep:T}=r.get(m),P=a.has(m),x=p!==m,R=!(b||T)&&(P||!E),$=this.singletonDepsOf(h,o),A=x&&f.has(m);A&&u.add(m);let W=A?[...$,m]:$.length?$:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:R,external:W})]),c.add(p)}let d=new Set([...o,...u]);for(let p of d)s.has(p)&&(c.has(p)||l.push([p,this.cdn.buildEsmUrl(i(p),{})]),l.push([`${p}/`,`${jt}/${i(p)}/`]));return l}singletonDepsOf(e,t){return[...new Set([...Is(e.meta),...sd(e.meta)])].filter(r=>t.has(r))}};ur.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as My,satisfies as $P,maxSatisfying as By,major as LP,valid as MP,validRange as BP}from"semver";var zo,bn,ad=v(()=>{zo=class{cmp(e,t){return e===t?0:My(e,t)?1:My(t,e)?-1:0}satisfies(e,t){return!e||!e.trim()?!0:!!$P(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=By(e,r,{includePrerelease:!1});if(a)return a}return By(e,r,{includePrerelease:!0})??void 0}majorOf(e){return LP(e)}isExactVersion(e){return MP(e)!==null}isRange(e){return BP(e)!==null}},bn=new zo});function DP(n){return Math.min(9e5*Math.pow(2,Math.max(0,n-1)),864e5)}var wn,Dy=v(()=>{Yo();wn=class{constructor(e){this.store=e}async isNegative(e){let t=await Se(()=>this.store.get(e));return!!t&&t.until>Date.now()}async recordNegative(e){let r=((await Se(()=>this.store.get(e)))?.attempts||0)+1;await Se(()=>this.store.set(e,{until:Date.now()+DP(r),attempts:r}))}async clearNegative(e){await Se(()=>this.store.delete(e))}}});function jy(n,e){let t=new Rs(n,e),r=new Ns(t),s=new $s(n,t,bn);return{packageService:new ur(s,t,r),versionResolver:s,cdnClient:t,peerResolver:r}}var pt=v(()=>{rd();Vo();id();od();ad();Cs();ad();_s();rd();Vo();id();od();Dy()});import*as ld from"fs/promises";import*as Fy from"crypto";function Ve(n){return Fy.createHash("sha1").update(n).digest("hex")}async function ht(n){try{return JSON.parse(await ld.readFile(n,"utf8"))}catch{return}}async function Go(n){try{return await ld.readFile(n,"utf8")}catch{return}}var dr=v(()=>{"use strict"});import*as Ut from"fs/promises";import*as mt from"path";import*as qy from"os";function te(){return cd||(cd=FP().catch(()=>lt())),cd}function Qo(n,e){return mt.join(jP,Ve(n),e)}async function FP(){await Ut.mkdir(Ft,{recursive:!0});let n=mt.join(Ft,"version.json");if((await ht(n))?.version===Uy)return;let t=await Ut.readdir(Ft).catch(()=>[]);await Promise.all(t.map(r=>Ut.rm(mt.join(Ft,r),{recursive:!0,force:!0}))),await Ut.writeFile(n,JSON.stringify({version:Uy})+`
527
- `,"utf8")}var Uy,Ft,Ls,Ms,Xo,jP,cd,fr=v(()=>{"use strict";dr();tt();Uy=1,Ft=mt.join(qy.homedir(),".typebulb","cache"),Ls=mt.join(Ft,"packages"),Ms=mt.join(Ft,"proxy"),Xo=mt.join(Ft,"dts"),jP=mt.join(Ft,"emit")});import*as qt from"fs/promises";import*as Jy from"path";async function Me(n,e){let t=`${n}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await qt.mkdir(Jy.dirname(n),{recursive:!0}),await qt.writeFile(t,e,"utf8")}catch{lt();return}await qt.rename(t,n).catch(async()=>{await qt.rm(t,{force:!0}).catch(()=>{})})}var Bs=v(()=>{"use strict";tt()});var pr,ud=v(()=>{"use strict";Bs();dr();pr=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=ht(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 Hy from"fs/promises";import*as ze from"path";function Ky(n,e){return ze.join(UP,Zo(n),encodeURIComponent(e)+".json")}function Zo(n){return n.replace(/\//g,"__")}var dd,Wy,UP,qP,ea,Yy=v(()=>{"use strict";pt();fr();Bs();ud();dr();dd=ze.join(Ls,"indexes"),Wy=ze.join(Ls,"pinned"),UP=ze.join(Ls,"meta"),qP=ze.join(Ls,"negative.json"),ea=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new wn(new pr(qP));async getPinnedExact(e,t){let r=`${e}@${t}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await te();let s=await Go(ze.join(Wy,Ve(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(ze.join(Wy,Ve(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await te();let t=await ht(ze.join(dd,Zo(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(ze.join(dd,Zo(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await Hy.rm(ze.join(dd,Zo(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 ht(Ky(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(Ky(e,t),JSON.stringify(o))}}});var Vy,zy=v(()=>{"use strict";Vy={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 JP,ta,Gy,Xy,NB,fd=v(()=>{"use strict";pt();Yy();zy();JP=new ea,{packageService:ta,versionResolver:Gy,cdnClient:Xy,peerResolver:NB}=jy(JP,Vy)});function na(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Qy(){return` <script>
528
- ${fg}
528
+ `)}function jy(n,e){let t=xs(n,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(t.length)throw new Error(`Lint failed:
529
+ ${oO(t)}`)}var Fy=S(()=>{"use strict";Fo()});var Ut,_s,cd,Rs=S(()=>{Ut="https://esm.sh",_s="https://cdn.jsdelivr.net/npm/",cd="https://data.jsdelivr.com/v1/package/npm/"});function Uy(n){let e=(n||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var F,fr,qy,Is=S(()=>{Rs();F=class n{constructor(e,t,r){let s=typeof e=="string"?n.parse(e):e;this.name=s.name,this.version=fr(t??s.version),this.subpath=fr(r??s.subpath)}static parse(e){let t=Uy(e||"");if(!t.length)return new n({name:""});if(t[0].startsWith("@")){let s=t[0],[i,o]=qy(t[1]??""),a=fr(t.slice(2).join("/"));return new n({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=qy(t[0]),o=fr(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(Ut).host,s=new URL(_s).host;if(t.host===r){let i=Uy(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:fr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},fr=n=>n&&n.length?n:void 0,qy=n=>{let e=n.indexOf("@");return e<0?[n,void 0]:[n.slice(0,e),fr(n.slice(e+1))]}});async function xe(n){try{return await n()}catch{return}}var Xo=S(()=>{});function wn(n){let e=n||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function ud(n){return n.startsWith("./")?n:`./${n}`}var Ns,dd=S(()=>{Is();Xo();Rs();Ns=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 F(e):e;return`${_s}${t.name}${t.version?`@${t.version}`:""}/`}file(e,t){return new URL(wn(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(",")),`${Ut}/${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),`${Ut}/${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(`${cd}${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=F.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:u,peerDependenciesMeta:d}=r;return{name:e,version:t,dependencies:f,peerDependencies:u,peerDependenciesMeta:d}}let s=this.packageJson(new F(`${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 Jy,$s,fd,aO,Ls,Qo=S(()=>{Jy=n=>n.startsWith("@types/"),$s=n=>Object.keys(n?.peerDependencies||{}).filter(e=>!Jy(e)),fd=n=>Object.keys(n?.dependencies||{}).filter(e=>!Jy(e)),aO=n=>$s(n).filter(e=>!n?.peerDependenciesMeta?.[e]?.optional),Ls=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 aO(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=>$s(i.meta))),r=new Map;for(let i of e)for(let o of fd(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:$s(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Ms,pd=S(()=>{Is();Xo();Ms=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 F(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 lO,parse as cO}from"es-module-lexer";var pr,hd=S(()=>{Is();Rs();Qo();pr=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))F.isBare(s[1])&&t.add(s[1])}return Array.from(t)}async extractImports(e){let t=new Set,r=s=>{F.isBare(s)&&t.add(s)};try{await lO;let[s]=cO(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(u=>!r?.has(F.rootOf(u))),i=[...new Set(s.map(F.rootOf))],o=await Promise.all(i.map(async u=>({name:u,version:await this.resolveVersion(u,t)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,u=>this.resolveVersion(u,t)),f=this.buildEntries([...s,...c.map(u=>u.name)],a,l);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,u])=>u)}}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 g=s.get(F.rootOf(p));return new F(p).withVersion(g.version).format()},o=new Set([...r.entries()].filter(([,p])=>p.isPeerRoot||p.isSharedDep).map(([p])=>p)),a=new Set(e.filter(p=>p!==F.rootOf(p)).map(F.rootOf)),l=[],c=new Set,f=new Set(e.filter(p=>p===F.rootOf(p))),u=new Set;for(let p of e){let g=F.rootOf(p),h=s.get(g),{isPeerRoot:y,hasPeers:E,isSharedDep:P}=r.get(g),O=a.has(g),x=p!==g,I=!(y||P)&&(O||!E),L=this.singletonDepsOf(h,o),T=x&&f.has(g);T&&u.add(g);let K=T?[...L,g]:L.length?L:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:I,external:K})]),c.add(p)}let d=new Set([...o,...u]);for(let p of d)s.has(p)&&(c.has(p)||l.push([p,this.cdn.buildEsmUrl(i(p),{})]),l.push([`${p}/`,`${Ut}/${i(p)}/`]));return l}singletonDepsOf(e,t){return[...new Set([...$s(e.meta),...fd(e.meta)])].filter(r=>t.has(r))}};pr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as Wy,satisfies as uO,maxSatisfying as Ky,major as dO,valid as fO,validRange as pO}from"semver";var Zo,vn,md=S(()=>{Zo=class{cmp(e,t){return e===t?0:Wy(e,t)?1:Wy(t,e)?-1:0}satisfies(e,t){return!e||!e.trim()?!0:!!uO(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=Ky(e,r,{includePrerelease:!1});if(a)return a}return Ky(e,r,{includePrerelease:!0})??void 0}majorOf(e){return dO(e)}isExactVersion(e){return fO(e)!==null}isRange(e){return pO(e)!==null}},vn=new Zo});function hO(n){return Math.min(9e5*Math.pow(2,Math.max(0,n-1)),864e5)}var Sn,Hy=S(()=>{Xo();Sn=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()+hO(r),attempts:r}))}async clearNegative(e){await xe(()=>this.store.delete(e))}}});function Yy(n,e){let t=new Ns(n,e),r=new Ls(t),s=new Ms(n,t,vn);return{packageService:new pr(s,t,r),versionResolver:s,cdnClient:t,peerResolver:r}}var mt=S(()=>{dd();Qo();pd();hd();md();Is();md();Rs();dd();Qo();pd();hd();Hy()});import*as gd from"fs/promises";import*as Vy from"crypto";function ze(n){return Vy.createHash("sha1").update(n).digest("hex")}async function gt(n){try{return JSON.parse(await gd.readFile(n,"utf8"))}catch{return}}async function ea(n){try{return await gd.readFile(n,"utf8")}catch{return}}var hr=S(()=>{"use strict"});import*as Jt from"fs/promises";import*as yt from"path";import*as Gy from"os";function ne(){return yd||(yd=gO().catch(()=>ut())),yd}function na(n,e){return yt.join(mO,ze(n),e)}async function gO(){await Jt.mkdir(qt,{recursive:!0});let n=yt.join(qt,"version.json");if((await gt(n))?.version===zy)return;let t=await Jt.readdir(qt).catch(()=>[]);await Promise.all(t.map(r=>Jt.rm(yt.join(qt,r),{recursive:!0,force:!0}))),await Jt.writeFile(n,JSON.stringify({version:zy})+`
530
+ `,"utf8")}var zy,qt,Bs,Ds,ta,mO,yd,mr=S(()=>{"use strict";hr();nt();zy=1,qt=yt.join(Gy.homedir(),".typebulb","cache"),Bs=yt.join(qt,"packages"),Ds=yt.join(qt,"proxy"),ta=yt.join(qt,"dts"),mO=yt.join(qt,"emit")});import*as Wt from"fs/promises";import*as Xy from"path";async function Be(n,e){let t=`${n}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await Wt.mkdir(Xy.dirname(n),{recursive:!0}),await Wt.writeFile(t,e,"utf8")}catch{ut();return}await Wt.rename(t,n).catch(async()=>{await Wt.rm(t,{force:!0}).catch(()=>{})})}var js=S(()=>{"use strict";nt()});var gr,bd=S(()=>{"use strict";js();hr();gr=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=gt(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 Be(this.filePath,JSON.stringify(Object.fromEntries(e)))}}});import*as eb from"fs/promises";import*as Ge from"path";function Zy(n,e){return Ge.join(yO,ra(n),encodeURIComponent(e)+".json")}function ra(n){return n.replace(/\//g,"__")}var wd,Qy,yO,bO,sa,tb=S(()=>{"use strict";mt();mr();js();bd();hr();wd=Ge.join(Bs,"indexes"),Qy=Ge.join(Bs,"pinned"),yO=Ge.join(Bs,"meta"),bO=Ge.join(Bs,"negative.json"),sa=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new Sn(new gr(bO));async getPinnedExact(e,t){let r=`${e}@${t}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await ne();let s=await ea(Ge.join(Qy,ze(r)+".txt"));return this.pinnedMem.set(r,s),s}async setPinnedExact(e,t,r){let s=`${e}@${t}`;this.pinnedMem.set(s,r),await ne(),await Be(Ge.join(Qy,ze(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await ne();let t=await gt(Ge.join(wd,ra(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 ne(),await Be(Ge.join(wd,ra(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await eb.rm(Ge.join(wd,ra(e)+".json"),{force:!0}).catch(()=>{})}async isNegative(e){return await ne(),this.negativeCache.isNegative(e)}async recordNegative(e){await ne(),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 ne();let s=await gt(Zy(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 ne(),await Be(Zy(e,t),JSON.stringify(o))}}});var nb,rb=S(()=>{"use strict";nb={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 wO,ia,sb,ib,vD,vd=S(()=>{"use strict";mt();tb();rb();wO=new sa,{packageService:ia,versionResolver:sb,cdnClient:ib,peerResolver:vD}=Yy(wO,nb)});function oa(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function ob(){return` <script>
531
+ ${Sg}
529
532
  (function () {
530
533
  try {
531
534
  var key = function () { return 'tb-scroll:' + location.pathname + location.search; };
@@ -538,14 +541,14 @@ ${fg}
538
541
  });
539
542
  } catch (e) {}
540
543
  })();
541
- </script>`}function ra(n,e){return` <script>
544
+ </script>`}function aa(n,e){return` <script>
542
545
  (function() {
543
546
  try {
544
- var KEY = ${gt(JSON.stringify("tb-theme:"+n))};
547
+ var KEY = ${bt(JSON.stringify("tb-theme:"+n))};
545
548
  var doc = document.documentElement;
546
549
  var mq = window.matchMedia('(prefers-color-scheme: dark)');
547
550
  var os = function() { return mq.matches ? 'dark' : 'light'; };
548
- var FORCED = ${gt(JSON.stringify(e??null))};
551
+ var FORCED = ${bt(JSON.stringify(e??null))};
549
552
  var stored = function() {
550
553
  try { var v = localStorage.getItem(KEY); return (v === 'dark' || v === 'light') ? v : undefined; }
551
554
  catch (e) { return undefined; }
@@ -583,7 +586,7 @@ ${fg}
583
586
  });
584
587
  } catch (e) {}
585
588
  })();
586
- </script>`}var gt,Zy,pd,WP,KP,sa,hr=v(()=>{"use strict";ee();ee();gt=n=>n.replace(/<\/script/gi,"<\\/script");Zy=30*6e4,pd=1e3,WP=6e4,KP=3e4,sa=(n="'/__reload'")=>`
589
+ </script>`}var bt,ab,Sd,vO,SO,la,yr=S(()=>{"use strict";ee();ee();bt=n=>n.replace(/<\/script/gi,"<\\/script");ab=30*6e4,Sd=1e3,vO=6e4,SO=3e4,la=(n="'/__reload'")=>`
587
590
  let es = null;
588
591
  let bootId = null;
589
592
  let firstErrorAt = 0;
@@ -598,9 +601,9 @@ ${fg}
598
601
  es.onerror = () => {
599
602
  if (!firstErrorAt) firstErrorAt = Date.now();
600
603
  // Inside the replace window, EventSource's own retry is faster than anything we'd schedule.
601
- if (Date.now() - firstErrorAt <= ${WP}) return;
604
+ if (Date.now() - firstErrorAt <= ${vO}) return;
602
605
  es.close();
603
- backoff = Math.min(${KP}, backoff ? backoff * 2 : ${pd} * 2);
606
+ backoff = Math.min(${SO}, backoff ? backoff * 2 : ${Sd} * 2);
604
607
  setTimeout(tbConnect, backoff);
605
608
  };
606
609
  };
@@ -616,7 +619,7 @@ ${fg}
616
619
  // A relay open (TB-VSCode-Browser.md): the CLI asks a page of ours inside VS Code to open a URL,
617
620
  // since its integrated browser honors a gesture-less window.open and keeps the new tab in-editor.
618
621
  tbOn('open-url', (e) => { window.open(e.data, '_blank', 'noopener'); });
619
- tbConnect();`});var eb,tb=v(()=>{"use strict";hr();ee();eb=`
622
+ tbConnect();`});var lb,cb=S(()=>{"use strict";yr();ee();lb=`
620
623
  (() => {
621
624
  // Inline (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
622
625
  // bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
@@ -1060,7 +1063,7 @@ ${fg}
1060
1063
  },
1061
1064
 
1062
1065
  // Environment ('inline' when running as a bulb-in-a-bulb)
1063
- mode: isFramed ? '${Jn.inline}' : '${Jn.local}',
1066
+ mode: isFramed ? '${Hn.inline}' : '${Hn.local}',
1064
1067
 
1065
1068
  // Theme accessor - delegates to the head-script engine (window.__tbTheme).
1066
1069
  // Get: override slot ('dark'|'light'|undefined). Set applies + persists
@@ -1489,7 +1492,7 @@ ${fg}
1489
1492
  if (relayed) history.replaceState(null, '', location.pathname + location.search);
1490
1493
  const tbStreamUrl = '/__reload?bulb=' + encodeURIComponent(window.__TB_BULB__ || '')
1491
1494
  + (relayed ? '&relay=' + Math.random().toString(36).slice(2) : '');
1492
- ${sa("tbStreamUrl")}
1495
+ ${la("tbStreamUrl")}
1493
1496
  // Told to go, the page goes: it closes the tab, and where the browser refuses a script the close
1494
1497
  // (a tab that wasn't script-opened and has history) it replaces itself with a note naming the
1495
1498
  // reason. The note is a blob document, never a served route \u2014 a note that needs the server
@@ -1576,49 +1579,49 @@ ${sa("tbStreamUrl")}
1576
1579
  });
1577
1580
  }
1578
1581
  })();
1579
- `});function nb(n){let{name:e,code:t,css:r,html:s,data:i,insight:o,importMap:a,theme:l,inline:c,dir:f,source:u,bulbKey:d,compileError:p}=n,m=s.trim()||'<div id="app"></div>',h=c?"":`
1580
- `+nu,b={imports:GP(a.imports)};return`<!DOCTYPE html>
1582
+ `});function ub(n){let{name:e,code:t,css:r,html:s,data:i,insight:o,importMap:a,theme:l,inline:c,dir:f,source:u,bulbKey:d,compileError:p}=n,g=s.trim()||'<div id="app"></div>',h=c?"":`
1583
+ `+au,y={imports:TO(a.imports)};return`<!DOCTYPE html>
1581
1584
  <html>
1582
1585
  <head>
1583
1586
  <meta charset="utf-8">
1584
1587
  <meta name="viewport" content="width=device-width, initial-scale=1">
1585
- <title>${na(e)} - typebulb</title>
1586
- ${ra(e,l)}
1587
- ${c?"":Qy()}
1588
+ <title>${oa(e)} - typebulb</title>
1589
+ ${aa(e,l)}
1590
+ ${c?"":ob()}
1588
1591
  <script type="importmap">
1589
- ${JSON.stringify(b,null,2)}
1592
+ ${JSON.stringify(y,null,2)}
1590
1593
  </script>
1591
1594
  <style>
1592
- ${ds}${h}
1595
+ ${hs}${h}
1593
1596
  </style>
1594
1597
  <style>
1595
1598
  ${r}
1596
1599
  </style>
1597
1600
  </head>
1598
1601
  <body>
1599
- ${m}
1602
+ ${g}
1600
1603
 
1601
- ${i.length>0?`<script>window.__TB_DATA__ = ${gt(JSON.stringify(i))};</script>`:""}
1602
- ${o?`<script>window.__TB_INSIGHT__ = ${gt(JSON.stringify(o))};</script>`:""}
1603
- ${f?`<script>window.__TB_DIR__ = ${gt(JSON.stringify(f))};</script>`:""}
1604
- ${d?`<script>window.__TB_BULB__ = ${gt(JSON.stringify(d))};</script>`:""}
1605
- ${p?`<script>window.__TB_COMPILE_ERROR__ = ${gt(JSON.stringify(p))};</script>`:""}
1604
+ ${i.length>0?`<script>window.__TB_DATA__ = ${bt(JSON.stringify(i))};</script>`:""}
1605
+ ${o?`<script>window.__TB_INSIGHT__ = ${bt(JSON.stringify(o))};</script>`:""}
1606
+ ${f?`<script>window.__TB_DIR__ = ${bt(JSON.stringify(f))};</script>`:""}
1607
+ ${d?`<script>window.__TB_BULB__ = ${bt(JSON.stringify(d))};</script>`:""}
1608
+ ${p?`<script>window.__TB_COMPILE_ERROR__ = ${bt(JSON.stringify(p))};</script>`:""}
1606
1609
 
1607
1610
  <script>
1608
- ${hg}
1609
- ${eb}
1611
+ ${xg}
1612
+ ${lb}
1610
1613
  </script>
1611
1614
 
1612
- ${zP}
1615
+ ${AO}
1613
1616
 
1614
- ${YP(t,u)}
1617
+ ${xO(t,u)}
1615
1618
  </body>
1616
- </html>`}function YP(n,e){let t=["",...HP],r=e?Array(Math.max(0,e.codeLine-t.length-1)).fill(""):[],s=[...t,...r,gt(n)].join(`
1617
- `);return`<script type="module">${s}${VP(e,s)}
1618
- </script>`}function VP(n,e){if(!n)return"";let t=e.split(`
1619
+ </html>`}function xO(n,e){let t=["",...kO],r=e?Array(Math.max(0,e.codeLine-t.length-1)).fill(""):[],s=[...t,...r,bt(n)].join(`
1620
+ `);return`<script type="module">${s}${EO(e,s)}
1621
+ </script>`}function EO(n,e){if(!n)return"";let t=e.split(`
1619
1622
  `).length,r={version:3,file:n.file,sources:[`/__source/${n.file}`],names:[],mappings:["AAAA",...Array(Math.max(0,t-1)).fill("AACA")].join(";")};return`
1620
1623
  //# sourceURL=${n.file.replace(/\s/g,"%20")}
1621
- //# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function GP(n){let e={};for(let[t,r]of Object.entries(n))e[t]=r.startsWith("https://")?"/proxy/"+r:r;return e}var HP,zP,rb=v(()=>{"use strict";ee();tb();hr();HP=["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) */"];zP=`<script>
1624
+ //# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function TO(n){let e={};for(let[t,r]of Object.entries(n))e[t]=r.startsWith("https://")?"/proxy/"+r:r;return e}var kO,AO,db=S(()=>{"use strict";ee();cb();yr();kO=["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) */"];AO=`<script>
1622
1625
  (function () {
1623
1626
  var framed = window.parent !== window;
1624
1627
  var post = function (m) { try { parent.postMessage(m, '*'); } catch (e) {} }; /* framed only */
@@ -1717,20 +1720,20 @@ ${YP(t,u)}
1717
1720
  }
1718
1721
  });
1719
1722
  })();
1720
- </script>`});import*as oa from"fs/promises";import*as ia from"path";import{existsSync as sb,readFileSync as XP}from"fs";import{execFile as QP}from"child_process";import{promisify as ZP}from"util";import{builtinModules as eO}from"node:module";import{satisfies as tO}from"semver";async function aa(n,e,t,r){let i=n.map(c=>iO(c,t)).filter(c=>!oO(c,e));if(i.length===0)return;let o=i.filter(c=>!sO.test(c));if(o.length)throw new Error(`Refusing to install npm spec(s) with unsupported characters: ${o.join(", ")}
1721
- Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await oa.mkdir(e,{recursive:!0});let a=ia.join(e,"package.json");sb(a)||await oa.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 nO("npm",["install",...l,...i],{cwd:e,shell:!0})}function iO(n,e){if(!e||D.parse(n).version)return n;let t=e[n];return t?`${n}@${t}`:n}function oO(n,e){let{name:t,version:r}=D.parse(n),s=ia.join(e,"node_modules",t);if(!sb(s))return!1;if(!r)return!0;try{let i=JSON.parse(XP(ia.join(s,"package.json"),"utf-8")).version;return tO(i,r)}catch{return!1}}function la(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=D.rootOf(s);rO.has(i)||e.add(i)}return[...e]}var nO,rO,sO,hd=v(()=>{"use strict";pt();nO=ZP(QP),rO=new Set(eO),sO=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as Be from"fs/promises";import*as Oe from"path";function mr(n,e){let t=Oe.resolve(e,n),r=Oe.normalize(e),s=Oe.normalize(t);if(s!==r&&!s.startsWith(r+Oe.sep))throw new Error("Path traversal detected - access denied");return t}async function Ds(n,e){return Be.readFile(mr(n,e))}async function ca(n,e,t){let r=mr(n,t);await Be.mkdir(Oe.dirname(r),{recursive:!0}),await Be.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function ua(n,e){let t=mr(n,e),r=await Be.readdir(t,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await Be.stat(Oe.join(t,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function da(n,e){let t=mr(n,e);if(Oe.normalize(t)===Oe.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await Be.rm(t,{recursive:!0})}var md=v(()=>{"use strict"});async function ib(n){let e=ft(n.provider,n.model);if(typeof e=="string")throw new Error(e);let t=await Dt(e,n);if(!t.ok){let r=await or(t,e.protocol);throw new Error(r.message)}return{response:t,protocol:e.protocol}}async function aO(n){let{response:e,protocol:t}=await ib(n);return ar(e,t)}async function*lO(n){let{response:e,protocol:t}=await ib(n);yield*gn(e,t)}function ob(n){let e=Object.assign(aO,{stream:lO}),t={read:async r=>{let s=await Ds(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 Ds(r,n)),write:async(r,s)=>(await ca(r,s,n),!0),list:async(r=".")=>ua(r,n),remove:async r=>(await da(r,n),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:t,dir:n,models:()=>ut(),aiAccess:Do,mode:Jn.local})}var ab=v(()=>{"use strict";Mt();ee();Ho();pn();md()});import*as Jt from"fs/promises";import*as ue from"path";import{pathToFileURL as cO}from"url";async function lb(n){let t=(await Jt.readdir(n)).find(r=>r.endsWith(".bulb.md"));return t?ue.join(n,t):void 0}function js(n){let e=ue.resolve(n);return ue.join(ue.dirname(e),ue.basename(e).replace(/\.bulb\.md$/,""))}function gr(n){let[e,t,r,s]=n.split(ue.sep).slice(-4);if(!(e!=="typebulbs"||t!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function Ge(n){let e=await Jt.readFile(n,"utf-8"),t=Cn(e),r=Zn(t);return{bulb:r,config:Rr(r.config),warnings:Jf(e),starts:t.starts}}function gd(n){let e=ue.basename(n).replace(/\.bulb\.md$/i,"");return ue.join(ue.dirname(n),".typebulb",`${e}.server.mjs`)}async function Fs(n,e,t,r){let s=ed(n,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;t&&(i=await Bf(i,t));let o=ue.join(ue.dirname(e),".typebulb");await Jt.mkdir(o,{recursive:!0});let a=la(i);a.length>0&&await aa(a,o,r);let l=gd(e);return await Jt.writeFile(l,i,"utf-8"),ob(js(e)),await import(`${cO(l).href}?t=${Date.now()}`)}async function yd(n,e,t,r){let{bulb:s,config:i,starts:o}=await Ge(n),a=fo(s.data),l,c=m=>{l??=m instanceof Error?m.message:String(m)};try{Ry(s.code,i.dependencies??{})}catch(m){c(m)}let f=ed(s.code,{jsxImportSource:i.ts?.jsxImportSource});f.error&&c(f.error);let u={imports:{}};if(!l)try{({importMap:u}=await ta.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&&(u.imports[r.name]=r.entryUrl);let d=nb({name:s.name,code:l?"":f.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:u,dir:js(n),watch:e,source:{file:ue.basename(n),codeLine:o.get("code.tsx")??1},bulbKey:gs(n),compileError:l}),p;return s.server&&t&&(p=await Fs(s.server,n,r,i.dependencies)),{html:d,bulb:s,serverExports:p,buildError:l}}var vn,yt=v(()=>{"use strict";vs();Cy();Iy();fd();rb();hd();ci();tt();ab();vn=n=>ue.join(js(n),"assets")});import*as _e from"fs/promises";import*as De from"path";import{createHash as uO}from"crypto";async function wd(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 yr(n){try{return JSON.parse(n).error||n}catch{return n}}async function Sd(n,e){try{let t=await fetch(Us(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}): ${yr(await t.text())}`}}catch(t){return{error:t instanceof Error?t.message:String(t)}}}function kd(n,e){Le(e);let t=process.env.TYPEBULB_ORIGIN||dO;try{return ha(n,process.cwd(),t)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function ha(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}
1722
- Expected <origin>/u/<user>/<slug>`);let l=a[1],c=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:l,slug:c,dest:De.join(e,fa(l,c))}}let r=De.resolve(e,n),s=gr(r);if(!s)throw new Error(`Not a conventional bulb path: ${n}
1723
- 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 fO(n,e){let t=await Sd(n,e);if("error"in t||!t.entries.length)return{kind:"none"};let r=t.entries,s=vn(n.dest),i=[],o=[],a=0;for(let l of r){let c=await _e.readFile(De.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):vd(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 pO(n,e,t){let r=vn(n.dest),s=[],i=0;return await wd(e.toGet,4,async o=>{try{let a=await fetch(`${Us(n)}/${pa(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=De.join(r,...o.split("/"));await _e.mkdir(De.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 ma(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&&hO(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 fO(n,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:n.dest,paths:a.paths};if(!o){await _e.mkdir(De.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 pO(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 hO(n,e){let t=i=>i.replace(/\r\n/g,`
1724
- `),r=Je(t(n)),s=Je(t(e));return!r||!s?t(n)===t(e):r.frontmatter.name===s.frontmatter.name&&qe.every(i=>(r.files.get(ce[i].path)||"")===(s.files.get(ce[i].path)||""))}async function ub(n,e){n||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let t=kd(n,e.mode),r=`${t.origin}/u/${t.userSlug}/${t.slug}`,s;try{s=await ma(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=De.relative(process.cwd(),t.dest)||t.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),cb(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),cb(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
1723
+ </script>`});import*as ua from"fs/promises";import*as ca from"path";import{existsSync as fb,readFileSync as PO}from"fs";import{execFile as OO}from"child_process";import{promisify as CO}from"util";import{builtinModules as _O}from"node:module";import{satisfies as RO}from"semver";async function da(n,e,t,r){let i=n.map(c=>LO(c,t)).filter(c=>!MO(c,e));if(i.length===0)return;let o=i.filter(c=>!$O.test(c));if(o.length)throw new Error(`Refusing to install npm spec(s) with unsupported characters: ${o.join(", ")}
1724
+ Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await ua.mkdir(e,{recursive:!0});let a=ca.join(e,"package.json");fb(a)||await ua.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 IO("npm",["install",...l,...i],{cwd:e,shell:!0})}function LO(n,e){if(!e||F.parse(n).version)return n;let t=e[n];return t?`${n}@${t}`:n}function MO(n,e){let{name:t,version:r}=F.parse(n),s=ca.join(e,"node_modules",t);if(!fb(s))return!1;if(!r)return!0;try{let i=JSON.parse(PO(ca.join(s,"package.json"),"utf-8")).version;return RO(i,r)}catch{return!1}}function fa(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=F.rootOf(s);NO.has(i)||e.add(i)}return[...e]}var IO,NO,$O,kd=S(()=>{"use strict";mt();IO=CO(OO),NO=new Set(_O),$O=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as De from"fs/promises";import*as Oe from"path";function br(n,e){let t=Oe.resolve(e,n),r=Oe.normalize(e),s=Oe.normalize(t);if(s!==r&&!s.startsWith(r+Oe.sep))throw new Error("Path traversal detected - access denied");return t}async function Fs(n,e){return De.readFile(br(n,e))}async function pa(n,e,t){let r=br(n,t);await De.mkdir(Oe.dirname(r),{recursive:!0}),await De.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function ha(n,e){let t=br(n,e),r=await De.readdir(t,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await De.stat(Oe.join(t,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function ma(n,e){let t=br(n,e);if(Oe.normalize(t)===Oe.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await De.rm(t,{recursive:!0})}var xd=S(()=>{"use strict"});async function pb(n){let e=ht(n.provider,n.model);if(typeof e=="string")throw new Error(e);let t=await Ft(e,n);if(!t.ok){let r=await cr(t,e.protocol);throw new Error(r.message)}return{response:t,protocol:e.protocol}}async function BO(n){let{response:e,protocol:t}=await pb(n);return ur(e,t)}async function*DO(n){let{response:e,protocol:t}=await pb(n);yield*bn(e,t)}function hb(n){let e=Object.assign(BO,{stream:DO}),t={read:async r=>{let s=await Fs(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 Fs(r,n)),write:async(r,s)=>(await pa(r,s,n),!0),list:async(r=".")=>ha(r,n),remove:async r=>(await ma(r,n),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:t,dir:n,models:()=>ft(),aiAccess:qo,mode:Hn.local})}var mb=S(()=>{"use strict";Dt();ee();Go();mn();xd()});import*as Kt from"fs/promises";import*as ue from"path";import{pathToFileURL as jO}from"url";async function gb(n){let t=(await Kt.readdir(n)).find(r=>r.endsWith(".bulb.md"));return t?ue.join(n,t):void 0}function wr(n){let e=ue.resolve(n);return ue.join(ue.dirname(e),ue.basename(e).replace(/\.bulb\.md$/,""))}function vr(n){let[e,t,r,s]=n.split(ue.sep).slice(-4);if(!(e!=="typebulbs"||t!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function Xe(n){let e=await Kt.readFile(n,"utf-8"),t=Nn(e),r=nr(t);return{bulb:r,config:$r(r.config),warnings:Qf(e),starts:t.starts}}function Ed(n){let e=ue.basename(n).replace(/\.bulb\.md$/i,"");return ue.join(ue.dirname(n),".typebulb",`${e}.server.mjs`)}async function Us(n,e,t,r){let s=ld(n,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;t&&(i=await Hf(i,t));let o=ue.join(ue.dirname(e),".typebulb");await Kt.mkdir(o,{recursive:!0});let a=fa(i);a.length>0&&await da(a,o,r);let l=Ed(e);return await Kt.writeFile(l,i,"utf-8"),hb(wr(e)),await import(`${jO(l).href}?t=${Date.now()}`)}async function Ad(n,e,t,r){let{bulb:s,config:i,starts:o}=await Xe(n),a=po(s.data),l,c=g=>{l??=g instanceof Error?g.message:String(g)};try{jy(s.code,i.dependencies??{})}catch(g){c(g)}let f=ld(s.code,{jsxImportSource:i.ts?.jsxImportSource});f.error&&c(f.error);let u={imports:{}};if(!l)try{({importMap:u}=await ia.buildImportMap(f.code,i.dependencies??{},r?new Set([r.name]):void 0))}catch(g){c(`Dependency resolution failed: ${g instanceof Error?g.message:String(g)}`)}l&&console.error("Build error:",l),r&&(u.imports[r.name]=r.entryUrl);let d=ub({name:s.name,code:l?"":f.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:u,dir:wr(n),watch:e,source:{file:ue.basename(n),codeLine:o.get("code.tsx")??1},bulbKey:bs(n),compileError:l}),p;return s.server&&t&&(p=await Us(s.server,n,r,i.dependencies)),{html:d,bulb:s,serverExports:p,buildError:l}}var kn,wt=S(()=>{"use strict";ks();Dy();Fy();vd();db();kd();ui();nt();mb();kn=n=>ue.join(wr(n),"assets")});import*as Ce from"fs/promises";import*as je from"path";import{createHash as FO}from"crypto";async function Pd(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 Sr(n){try{return JSON.parse(n).error||n}catch{return n}}async function Cd(n,e){try{let t=await fetch(qs(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}): ${Sr(await t.text())}`}}catch(t){return{error:t instanceof Error?t.message:String(t)}}}function _d(n,e){Me(e);let t=process.env.TYPEBULB_ORIGIN||UO;try{return ba(n,process.cwd(),t)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function ba(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}
1725
+ 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,ga(l,c))}}let r=je.resolve(e,n),s=vr(r);if(!s)throw new Error(`Not a conventional bulb path: ${n}
1726
+ 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 qO(n,e){let t=await Cd(n,e);if("error"in t||!t.entries.length)return{kind:"none"};let r=t.entries,s=kn(n.dest),i=[],o=[],a=0;for(let l of r){let c=await Ce.readFile(je.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):Od(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 JO(n,e,t){let r=kn(n.dest),s=[],i=0;return await Pd(e.toGet,4,async o=>{try{let a=await fetch(`${qs(n)}/${ya(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=je.join(r,...o.split("/"));await Ce.mkdir(je.dirname(l),{recursive:!0}),await Ce.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 wa(n,e={}){let t=await fetch(Td(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 Ce.readFile(n.dest,"utf-8")}catch{}let o=i!==void 0&&WO(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await Ce.stat(n.dest);return{kind:"conflict",dest:n.dest,localMtime:c,remoteLastModified:t.headers.get("last-modified")??void 0}}let a=await qO(n,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:n.dest,paths:a.paths};if(!o){await Ce.mkdir(je.dirname(n.dest),{recursive:!0}),await Ce.writeFile(n.dest,s);let c=new Date(t.headers.get("last-modified")??"");isNaN(c.getTime())||await Ce.utimes(n.dest,new Date,c)}let l=a.kind==="plan"?await JO(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 WO(n,e){let t=i=>i.replace(/\r\n/g,`
1727
+ `),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(ce[i].path)||"")===(s.files.get(ce[i].path)||""))}async function bb(n,e){n||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let t=_d(n,e.mode),r=`${t.origin}/u/${t.userSlug}/${t.slug}`,s;try{s=await wa(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=je.relative(process.cwd(),t.dest)||t.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),yb(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),yb(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
1725
1728
  local file modified ${s.localMtime.toISOString()}
1726
1729
  remote last saved ${s.remoteLastModified??"unknown"}
1727
1730
  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:
1728
1731
  `+s.paths.map(o=>` assets/${o}`).join(`
1729
1732
  `)+`
1730
- 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 cb(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 dO,fa,bd,pa,Us,vd,ga=v(()=>{"use strict";dt();ee();yt();dO="https://typebulb.com",fa=(n,e)=>De.join("typebulbs","u",n,`${e}.bulb.md`),bd=n=>`${n.origin}/u/${encodeURIComponent(n.userSlug)}/${encodeURIComponent(n.slug)}.md`,pa=n=>n.split("/").map(encodeURIComponent).join("/"),Us=n=>`${n.origin}/u/${encodeURIComponent(n.userSlug)}/${encodeURIComponent(n.slug)}/assets`;vd=n=>uO("md5").update(n).digest("hex")});import*as st from"fs/promises";import*as qs from"path";async function db(n,e=""){let t=await st.readdir(n,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of t)s.isDirectory()?r.push(...await db(qs.join(n,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function mO(n,e){let t=e.timeoutMs??3e4,r=Us(n),s={Authorization:`Bearer ${e.token}`},i=vn(n.dest);if(!await st.stat(i).then(m=>m.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await db(i),a=await Sd(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),u=l.map(m=>m.path).filter(m=>!f.has(m)),d=0,p=0;try{await wd(o,4,async m=>{let h=await st.readFile(qs.join(i,...m.split("/")));if(c.get(m)===vd(h)){p++;return}let b=await fetch(`${r}/${pa(m)}`,{method:"PUT",body:new Uint8Array(h),headers:s,signal:AbortSignal.timeout(t)});if(!b.ok)throw new Error(`upload of '${m}' refused (${b.status}): ${yr(await b.text())}`);d++})}catch(m){return{kind:"sync-error",message:m instanceof Error?m.message:String(m)}}return{kind:"synced",uploaded:d,unchanged:p,toDelete:u,base:pi(n.userSlug,n.slug)}}async function gO(n,e,t){let r=t.timeoutMs??3e4,s=Us(n),i=[];for(let o of e)try{let a=await fetch(`${s}/${pa(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}): ${yr(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function ya(n,e){let t=await st.readFile(n.dest,"utf-8"),{mtime:r}=await st.stat(n.dest),s=await mO(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:yr(l),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:yr(l),assets:i};let c=JSON.parse(l);if(await st.utimes(n.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let f=await gO(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 fb(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=kd(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=qs.relative(process.cwd(),t.dest)||t.dest,o;try{o=await ya(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}
1733
+ 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 yb(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 UO,ga,Td,ya,qs,Od,va=S(()=>{"use strict";pt();ee();wt();UO="https://typebulb.com",ga=(n,e)=>je.join("typebulbs","u",n,`${e}.bulb.md`),Td=n=>`${n.origin}/u/${encodeURIComponent(n.userSlug)}/${encodeURIComponent(n.slug)}.md`,ya=n=>n.split("/").map(encodeURIComponent).join("/"),qs=n=>`${n.origin}/u/${encodeURIComponent(n.userSlug)}/${encodeURIComponent(n.slug)}/assets`;Od=n=>FO("md5").update(n).digest("hex")});import*as it from"fs/promises";import*as Js from"path";async function wb(n,e=""){let t=await it.readdir(n,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of t)s.isDirectory()?r.push(...await wb(Js.join(n,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function KO(n,e){let t=e.timeoutMs??3e4,r=qs(n),s={Authorization:`Bearer ${e.token}`},i=kn(n.dest);if(!await it.stat(i).then(g=>g.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await wb(i),a=await Cd(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(g=>[g.path,g.md5])),f=new Set(o),u=l.map(g=>g.path).filter(g=>!f.has(g)),d=0,p=0;try{await Pd(o,4,async g=>{let h=await it.readFile(Js.join(i,...g.split("/")));if(c.get(g)===Od(h)){p++;return}let y=await fetch(`${r}/${ya(g)}`,{method:"PUT",body:new Uint8Array(h),headers:s,signal:AbortSignal.timeout(t)});if(!y.ok)throw new Error(`upload of '${g}' refused (${y.status}): ${Sr(await y.text())}`);d++})}catch(g){return{kind:"sync-error",message:g instanceof Error?g.message:String(g)}}return{kind:"synced",uploaded:d,unchanged:p,toDelete:u,base:hi(n.userSlug,n.slug)}}async function HO(n,e,t){let r=t.timeoutMs??3e4,s=qs(n),i=[];for(let o of e)try{let a=await fetch(`${s}/${ya(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}): ${Sr(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function Sa(n,e){let t=await it.readFile(n.dest,"utf-8"),{mtime:r}=await it.stat(n.dest),s=await KO(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(Td(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:Sr(l),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:Sr(l),assets:i};let c=JSON.parse(l);if(await it.utimes(n.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let f=await HO(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 vb(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=_d(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=Js.relative(process.cwd(),t.dest)||t.dest,o;try{o=await Sa(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}
1731
1734
  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}
1732
1735
  pull to see the remote: typebulb pull ${i}
1733
- 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 xd=v(()=>{"use strict";ee();ga();yt()});var br=v(()=>{"use strict";Ne();iy();an();oy();Ou();dy();py();xs();pn();pn();Ho();Zu();Ne();ga();xd();dt()});import{existsSync as yO,mkdirSync as bO,readFileSync as wO,rmSync as vO,writeFileSync as SO}from"fs";import{homedir as kO}from"os";import*as wr from"path";function TO(){return AO.replace('"__TB_SKILL_PATH__"',JSON.stringify(Ps())).replace('"__TB_BIN_PATH__"',JSON.stringify(Qn()))}function pb(){try{if(!yO(Ed()))return}catch{return}try{let n=xO(),e=TO(),t;try{t=wO(n,"utf8")}catch{}t!==e&&(bO(wr.dirname(n),{recursive:!0}),SO(n,e))}catch{}for(let n of EO())try{vO(n,{force:!0})}catch{}}var Ed,xO,EO,AO,hb=v(()=>{"use strict";br();Ed=()=>wr.join(kO(),".pi","agent"),xO=()=>wr.join(Ed(),"extensions","typebulb.ts"),EO=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(n=>wr.join(Ed(),"extensions",n)),AO=String.raw`// Generated by typebulb — do not edit; overwritten on each run.
1736
+ 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 Rd=S(()=>{"use strict";ee();va();wt()});var kr=S(()=>{"use strict";$e();py();cn();hy();Mu();wy();Sy();As();mn();mn();Go();ad();$e();va();Rd();pt()});import{existsSync as YO,mkdirSync as VO,readFileSync as zO,rmSync as GO,writeFileSync as XO}from"fs";import{homedir as QO}from"os";import*as xr from"path";function nC(){return tC.replace('"__TB_SKILL_PATH__"',JSON.stringify(Cs())).replace('"__TB_BIN_PATH__"',JSON.stringify(tr()))}function Sb(){try{if(!YO(Id()))return}catch{return}try{let n=ZO(),e=nC(),t;try{t=zO(n,"utf8")}catch{}t!==e&&(VO(xr.dirname(n),{recursive:!0}),XO(n,e))}catch{}for(let n of eC())try{GO(n,{force:!0})}catch{}}var Id,ZO,eC,tC,kb=S(()=>{"use strict";kr();Id=()=>xr.join(QO(),".pi","agent"),ZO=()=>xr.join(Id(),"extensions","typebulb.ts"),eC=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(n=>xr.join(Id(),"extensions",n)),tC=String.raw`// Generated by typebulb — do not edit; overwritten on each run.
1734
1737
  import { spawn } from "node:child_process";
1735
1738
  import { existsSync } from "node:fs";
1736
1739
 
@@ -1998,23 +2001,23 @@ export default function (pi) {
1998
2001
  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) {}
1999
2002
  } catch (e) { logErr("load", e && e.message); }
2000
2003
  }
2001
- `});function V(n){return n?.message??String(n)}var G,Wt=v(()=>{"use strict";G=process.cwd()});import{spawn as mb}from"child_process";import{StringDecoder as PO}from"string_decoder";function NO(n,e){let t=new PO("utf8"),r="";n.on("data",s=>{r+=typeof s=="string"?s:t.write(s);let i;for(;(i=r.indexOf(`
2002
- `))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var OO,gb,yb,Ad,bb,_O,CO,RO,wb,IO,ba,wa,vb,Sb=v(()=>{"use strict";Wt();OO=3e4,gb=18e4,yb="starting pi\u2026",Ad=5e3,bb=2e3,_O=2e3,CO=12e4,RO=8e3,wb=15e3,IO=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 n of ba)try{n.kill()}catch{}});wa=class{#e;#i=!1;#t=0;#n=!1;#f=0;#r=!1;#c=null;#o=[];#y=null;#s=null;#a=null;#p=new Map;#l=[];#b=null;#k=null;#w=null;#h;#m;#v="";#C=1;#u=new Map;#x;#S;constructor(e,t,r=(s,i)=>mb(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.#m="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.#m=`could not start pi: ${V(o)}`,this.#S();return}this.#e=i,this.#h=t,this.#n=!0,this.#f=Date.now()+gb,this.#s={text:yb,kind:"info"},ba.add(i),i.stdout&&NO(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-_O)}),i.on("error",o=>this.#O(`could not start pi: ${o.message}`)),i.on("exit",o=>{this.#e===i&&this.#O(o?`pi exited (code ${o})${this.#v.trim()?`: ${this.#v.trim()}`:""}`:"pi exited"),ba.delete(i),this.#S()}),this.#d({type:"get_state"}).then(o=>{let a=o.data?.sessionFile;typeof a=="string"&&a&&(this.#h=a);let l=o.data?.model;l&&typeof l.id=="string"&&l.id&&(this.#w=l.id)}).catch(()=>{}).finally(()=>this.#R())}#R(){this.#n&&(this.#n=!1,this.#s?.text===yb&&(this.#s=null),this.#a&&(this.#a.until=Date.now()+wb),!this.#i&&Date.now()<this.#t&&(this.#t=Date.now()+Ad),this.#T())}get streaming(){return this.#i||Date.now()<this.#t}get draft(){return this.#c}get echo(){return this.#y}get queue(){return this.#b}get stats(){return this.#k}get model(){return this.#w}get sessionFile(){return this.#h}get error(){return this.#m}get status(){if(this.#s)return this.#s;if(this.#a){if(Date.now()<this.#a.until)return{text:this.#a.text,kind:this.#a.kind};this.#a=null}return this.#p.size?{text:[...this.#p.values()].join(" \xB7 "),kind:"info"}:null}get dialog(){let e=Date.now();for(;this.#l.length;){let t=this.#l[0];if(e<t.until)return t.req;this.#l.shift(),t.ownTimeout||this.#E({type:"extension_ui_response",id:t.req.id,cancelled:!0})}return null}notice(e,t){this.#g(e,t)}respondUi(e,t){let r=this.#l.findIndex(o=>o.req.id===e);if(r<0)return{ok:!1,error:"dialog expired or already answered"};let[s]=this.#l.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(!IO.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let t=await this.#d(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.#d({type:"get_state"})).data?.sessionFile;typeof s=="string"&&s&&(this.#h=s)}catch{}return{ok:!0,data:{...t.data??{},sessionFile:this.#h}}}return t.success?{ok:!0,data:t.data}:{ok:!1,error:t.error??`pi rejected ${e.type}`}}catch(t){return{ok:!1,error:V(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.#t=l,s||(this.#y=e))};if(this.#n)return this.#d(i).catch(()=>{}),o(this.#f+Ad),{ok:!0};let a;try{a=await this.#d(i)}catch(l){return{ok:!1,error:V(l)}}return a.success&&o(Date.now()+Ad),a.success?{ok:!0}:{ok:!1,error:a.error??"pi rejected the message"}}async stop(){if(this.#e){if(this.#n){this.#E({type:"abort"}),this.#t=0;return}try{await this.#d({type:"abort"})}catch{}}}clearCompletedDraft(){this.#r||(this.#c=null)}clearEcho(){this.#y=null}async dispose(){let e=this.#e;if(e){if(this.#e=void 0,this.#n=!1,this.#i){try{e.stdin?.write(JSON.stringify({type:"abort"})+`
2003
- `)}catch{}await Promise.race([this.#x,vb(bb)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,vb(bb)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{mb("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}ba.delete(e),this.#l=[],this.#_("pi was shut down")}}#E(e){try{this.#e?.stdin?.write(JSON.stringify(e)+`
2004
+ `});function z(n){return n?.message??String(n)}var G,Ht=S(()=>{"use strict";G=process.cwd()});import{spawn as xb}from"child_process";import{StringDecoder as rC}from"string_decoder";function cC(n,e){let t=new rC("utf8"),r="";n.on("data",s=>{r+=typeof s=="string"?s:t.write(s);let i;for(;(i=r.indexOf(`
2005
+ `))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var sC,Eb,Ab,Nd,Tb,iC,oC,aC,Pb,lC,ka,xa,Ob,Cb=S(()=>{"use strict";Ht();sC=3e4,Eb=18e4,Ab="starting pi\u2026",Nd=5e3,Tb=2e3,iC=2e3,oC=12e4,aC=8e3,Pb=15e3,lC=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"]),ka=new Set;process.on("exit",()=>{for(let n of ka)try{n.kill()}catch{}});xa=class{#e;#i=!1;#t=0;#n=!1;#f=0;#r=!1;#c=null;#o=[];#y=null;#s=null;#a=null;#p=new Map;#l=[];#b=null;#k=null;#w=null;#h;#m;#v="";#_=1;#u=new Map;#x;#S;constructor(e,t,r=(s,i)=>xb(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.#m="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.#m=`could not start pi: ${z(o)}`,this.#S();return}this.#e=i,this.#h=t,this.#n=!0,this.#f=Date.now()+Eb,this.#s={text:Ab,kind:"info"},ka.add(i),i.stdout&&cC(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-iC)}),i.on("error",o=>this.#O(`could not start pi: ${o.message}`)),i.on("exit",o=>{this.#e===i&&this.#O(o?`pi exited (code ${o})${this.#v.trim()?`: ${this.#v.trim()}`:""}`:"pi exited"),ka.delete(i),this.#S()}),this.#d({type:"get_state"}).then(o=>{let a=o.data?.sessionFile;typeof a=="string"&&a&&(this.#h=a);let l=o.data?.model;l&&typeof l.id=="string"&&l.id&&(this.#w=l.id)}).catch(()=>{}).finally(()=>this.#R())}#R(){this.#n&&(this.#n=!1,this.#s?.text===Ab&&(this.#s=null),this.#a&&(this.#a.until=Date.now()+Pb),!this.#i&&Date.now()<this.#t&&(this.#t=Date.now()+Nd),this.#T())}get streaming(){return this.#i||Date.now()<this.#t}get draft(){return this.#c}get echo(){return this.#y}get queue(){return this.#b}get stats(){return this.#k}get model(){return this.#w}get sessionFile(){return this.#h}get error(){return this.#m}get status(){if(this.#s)return this.#s;if(this.#a){if(Date.now()<this.#a.until)return{text:this.#a.text,kind:this.#a.kind};this.#a=null}return this.#p.size?{text:[...this.#p.values()].join(" \xB7 "),kind:"info"}:null}get dialog(){let e=Date.now();for(;this.#l.length;){let t=this.#l[0];if(e<t.until)return t.req;this.#l.shift(),t.ownTimeout||this.#E({type:"extension_ui_response",id:t.req.id,cancelled:!0})}return null}notice(e,t){this.#g(e,t)}respondUi(e,t){let r=this.#l.findIndex(o=>o.req.id===e);if(r<0)return{ok:!1,error:"dialog expired or already answered"};let[s]=this.#l.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(!lC.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let t=await this.#d(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.#d({type:"get_state"})).data?.sessionFile;typeof s=="string"&&s&&(this.#h=s)}catch{}return{ok:!0,data:{...t.data??{},sessionFile:this.#h}}}return t.success?{ok:!0,data:t.data}:{ok:!1,error:t.error??`pi rejected ${e.type}`}}catch(t){return{ok:!1,error:z(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.#t=l,s||(this.#y=e))};if(this.#n)return this.#d(i).catch(()=>{}),o(this.#f+Nd),{ok:!0};let a;try{a=await this.#d(i)}catch(l){return{ok:!1,error:z(l)}}return a.success&&o(Date.now()+Nd),a.success?{ok:!0}:{ok:!1,error:a.error??"pi rejected the message"}}async stop(){if(this.#e){if(this.#n){this.#E({type:"abort"}),this.#t=0;return}try{await this.#d({type:"abort"})}catch{}}}clearCompletedDraft(){this.#r||(this.#c=null)}clearEcho(){this.#y=null}async dispose(){let e=this.#e;if(e){if(this.#e=void 0,this.#n=!1,this.#i){try{e.stdin?.write(JSON.stringify({type:"abort"})+`
2006
+ `)}catch{}await Promise.race([this.#x,Ob(Tb)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,Ob(Tb)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{xb("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}ka.delete(e),this.#l=[],this.#C("pi was shut down")}}#E(e){try{this.#e?.stdin?.write(JSON.stringify(e)+`
2004
2007
  `)}catch{}}#P(){let e=this.#o[this.#o.length-1];this.#c={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(`
2005
- `),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.#P()}#g(e,t){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#a={text:r,kind:t,until:Date.now()+(t==="info"?RO:wb)})}#T(){this.#d({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(()=>{})}#d(e){let t=this.#e;if(!t?.stdin?.writable)return Promise.reject(new Error(this.#m??"pi is not running"));let r=this.#n?gb:OO,s=`tb-${this.#C++}`;return new Promise((i,o)=>{let a=setTimeout(()=>{this.#u.delete(s),o(new Error(`pi did not respond (${Math.round(r/1e3)}s)`))},r);a.unref?.(),this.#u.set(s,{resolve:i,timer:a});try{t.stdin.write(JSON.stringify({id:s,...e})+`
2006
- `)}catch(l){clearTimeout(a),this.#u.delete(s),o(new Error(V(l)))}})}#I(e){let t;try{t=JSON.parse(e)}catch{return}switch(t.type){case"response":{let r=t,s=r.id?this.#u.get(r.id):void 0;s&&(this.#u.delete(r.id),clearTimeout(s.timer),s.resolve(r));return}case"agent_start":this.#i=!0,this.#t=0;return;case"agent_end":this.#i=!1,this.#t=0,this.#r=!1,this.#s=null,this.#b=null,this.#T();return;case"message_start":{let r=t.message;if(r?.role!=="assistant")return;this.#r=!0,this.#A(r);return}case"message_update":{if(!this.#r)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.#P();return}case"message_end":if(!this.#r)return;t.message&&this.#A(t.message),this.#r=!1;return;case"auto_retry_start":this.#s={text:`retrying after a transient error (attempt ${Number(t.attempt)||1}/${Number(t.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#s=null,t.success===!1&&this.#g(`retries exhausted: ${String(t.finalError??"unknown error")}`,"error");return;case"compaction_start":this.#s={text:"compacting context\u2026",kind:"info"};return;case"compaction_end":{this.#s=null;let r=t.result;typeof t.errorMessage=="string"&&t.errorMessage?this.#g(`compaction failed: ${t.errorMessage}`,"error"):r?.tokensBefore&&this.#g(`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.#l.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??CO),ownTimeout:s!==void 0})}else if(r==="notify"){let s=t.notifyType==="warning"?"warning":t.notifyType==="error"?"error":"info";this.#g(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.#p.set(s,t.statusText):this.#p.delete(s)}return}default:return}}#O(e){this.#m=e,this.#n=!1,this.#i=!1,this.#t=0,this.#r=!1,this.#c=null,this.#o=[],this.#y=null,this.#s=null,this.#a=null,this.#p.clear(),this.#l=[],this.#b=null,this.#k=null,this.#w=null,this.#e=void 0,this.#_(e)}#_(e){for(let[,t]of this.#u)clearTimeout(t.timer),t.resolve({type:"response",success:!1,error:e});this.#u.clear()}},vb=n=>new Promise(e=>{setTimeout(e,n).unref?.()})});import{existsSync as kb,readFileSync as $O,realpathSync as LO}from"fs";import{join as Sn,dirname as Tb,resolve as MO}from"path";import{homedir as xb}from"os";function DO(n,e){let t=Sn(n,".pi");if(BO.some(s=>kb(Sn(t,s))))return!0;let r=Sn(e,".agents","skills");for(let s=n;;){let i=Sn(s,".agents","skills");if(i!==r&&kb(i))return!0;let o=Tb(s);if(o===s)return!1;s=o}}function jO(n,e){for(let t=e;;){if(n[t]===!0||n[t]===!1)return!0;let r=Tb(t);if(r===t)return!1;t=r}}function Pb(n,e){try{let t=e?.agentDir??Sn(xb(),".pi","agent"),r=Eb(e?.home??process.env.HOME??xb()),s=Eb(MO(n));if(!DO(s,r))return null;let i=Ab(Sn(t,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||jO(Ab(Sn(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 BO,Eb,Ab,Ob=v(()=>{"use strict";BO=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],Eb=n=>{try{return LO(n)}catch{return n}},Ab=n=>{try{return JSON.parse($O(n,"utf8"))}catch{return{}}}});import{statSync as FO,openSync as UO,readSync as qO,closeSync as JO,existsSync as Cb}from"fs";import{join as va}from"path";import{homedir as Td}from"os";import{execFile as WO}from"child_process";async function HO(n){let e=va(Td(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let t of["fd","fdfind",...Cb(e)?[e]:[]]){let r=await new Promise(s=>{WO(t,["--base-directory",n,"--type","f","--follow","--hidden","--exclude",".git"],{maxBuffer:67108864},(i,o)=>s(i?null:o))});if(r!==null)return r.split(`
2007
- `).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function YO(n){return`--${n.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function _b(n){return n.type==="message"?VO(n.message?.role):n.type==="custom_message"?n.display!==!1:!1}var KO,VO,vr,Pd=v(()=>{"use strict";fs();su();yo();hb();Sb();Ob();KO=va(Td(),".pi","agent","sessions");VO=n=>n==="user"||n==="assistant"||n==="toolResult"||n==="bashExecution";vr=class extends It{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return Cb(va(Td(),".pi","agent"))}ensureHarnessSupport(){pb()}createDriver(e,t){let r=new wa(e,t),s=Pb(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return HO(e)}sessionsDir(e){return va(KO,YO(e))}listSessionFiles(e){return go(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 _b(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:Ie(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(d=>d.type==="text").map(d=>d.text??"").join(""),a=i.filter(d=>d.type==="thinking").map(d=>d.thinking??"").join(`
2008
- `),l=i.filter(d=>d.type==="toolCall").map(d=>({id:d.id??"",name:d.name??"",input:d.arguments??{}}));if(o||a||l.length){let d=Date.parse(e.timestamp??""),p=!isNaN(d)&&d>=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,u=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:u,model:s.model,cost:c?.cost?.total}}return{events:r}}chainWorking(e){let t;for(let a of e)_b(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=UO(e,"r")}catch{return""}try{let s=65536;try{s=FO(e).size}catch{}let i=(u,d)=>{let p=Buffer.alloc(d),m=qO(t,p,0,d,u);return p.subarray(0,m).toString("utf8")},o=i(0,Math.min(65536,s)),a=s>65536?i(s-65536,65536):"",l=u=>{let d="";for(let p of u.split(`
2009
- `))if(p.includes('"session_info"'))try{let m=JSON.parse(p);m?.type==="session_info"&&typeof m.name=="string"&&m.name&&(d=m.name)}catch{}return d},c="";for(let u of o.split(`
2010
- `))if(!(c||!u.includes('"type"')))try{let d=JSON.parse(u);d?.type==="message"&&d.message?.role==="user"&&(c=this.contentText(d.message.content).replace(/\s+/g," ").trim())}catch{}let f=l(a)||l(o)||c;return f?f.slice(0,200):""}finally{JO(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"?Ae(e):Array.isArray(e)?e.map(t=>typeof t?.text=="string"?Ae(t.text):t?.type==="image"&&t.data?mo(t.data,t.mimeType):"").filter(Boolean).join(`
2011
- `):""}}});var Sa,Rb=v(()=>{"use strict";Sa=class{#e=new Map;accept(e,t){return this.#e.get(e)===t?!1:(this.#e.set(e,t),!0)}}});import{execFile as zO}from"child_process";import{promisify as GO}from"util";import{readFile as XO}from"fs/promises";import{resolve as Ib,sep as QO}from"path";async function Xe(n,e){let{stdout:t}=await ZO("git",n,{cwd:e,maxBuffer:67108864});return t}async function kn(){if(ka)return ka;try{ka=(await Xe(["rev-parse","--show-toplevel"],G)).trim()}catch{}return ka}function e_(n,e){let t=e===" "?n:e;return t==="?"?"U":t}async function _d(){let n=await kn();if(!n)return{repo:!1,root:"",files:[]};try{let e=await Xe(["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:e_(i[0],i[1])}))}try{let s=await Xe(["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:V(e)}}}async function Cd(n){let e=await kn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await Xe(["status","--porcelain","-z","--",n],e)).startsWith("??")){let s=Ib(e,n);if(!s.startsWith(Ib(e)+QO))return{ok:!1,error:"outside repository"};let i=await XO(s);return i.includes(0)?Od("Binary file (not shown)",!1):Od(i.toString("utf8"),!0)}let r;try{r=await Xe(["diff","--no-color","--unified=999999","HEAD","--",n],e)}catch{r=await Xe(["diff","--no-color","--unified=999999","--",n],e)}return Od(r,!1)}catch(t){return{ok:!1,error:V(t)}}}var ZO,Nb,ka,Od,Js=v(()=>{"use strict";Wt();ZO=GO(zO),Nb=2e6;Od=(n,e)=>({ok:!0,text:n.slice(0,Nb),untracked:e,truncated:n.length>Nb})});function xa(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 Rd=v(()=>{"use strict"});function $b(){return t_.map(([n,e])=>ft(n,e)).filter(n=>typeof n!="string")}function Lb(){return $b().length>0}async function Ea(n,e,t=0){let r=AbortSignal.timeout(e);for(let s of $b()){try{let i=await Dt(s,{messages:[{role:"user",content:n}],effort:t,webSearch:!1,signal:r});if(i.ok){let o=(await Yu(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var t_,Id=v(()=>{"use strict";Mt();br();t_=[["openrouter","openai/gpt-5.6-luna"],["openai","gpt-5.6-luna"]]});var Aa,Ta,Mb=v(()=>{"use strict";Aa=".typebulb/paste",Ta={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"}});import{existsSync as n_,mkdirSync as r_,writeFileSync as s_,readFileSync as i_}from"fs";import{join as Pa}from"path";function Bb(){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 l_(n){return n.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function c_(n){let e=await Ea(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
2008
+ `),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.#P()}#g(e,t){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#a={text:r,kind:t,until:Date.now()+(t==="info"?aC:Pb)})}#T(){this.#d({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(()=>{})}#d(e){let t=this.#e;if(!t?.stdin?.writable)return Promise.reject(new Error(this.#m??"pi is not running"));let r=this.#n?Eb:sC,s=`tb-${this.#_++}`;return new Promise((i,o)=>{let a=setTimeout(()=>{this.#u.delete(s),o(new Error(`pi did not respond (${Math.round(r/1e3)}s)`))},r);a.unref?.(),this.#u.set(s,{resolve:i,timer:a});try{t.stdin.write(JSON.stringify({id:s,...e})+`
2009
+ `)}catch(l){clearTimeout(a),this.#u.delete(s),o(new Error(z(l)))}})}#I(e){let t;try{t=JSON.parse(e)}catch{return}switch(t.type){case"response":{let r=t,s=r.id?this.#u.get(r.id):void 0;s&&(this.#u.delete(r.id),clearTimeout(s.timer),s.resolve(r));return}case"agent_start":this.#i=!0,this.#t=0;return;case"agent_end":this.#i=!1,this.#t=0,this.#r=!1,this.#s=null,this.#b=null,this.#T();return;case"message_start":{let r=t.message;if(r?.role!=="assistant")return;this.#r=!0,this.#A(r);return}case"message_update":{if(!this.#r)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.#P();return}case"message_end":if(!this.#r)return;t.message&&this.#A(t.message),this.#r=!1;return;case"auto_retry_start":this.#s={text:`retrying after a transient error (attempt ${Number(t.attempt)||1}/${Number(t.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#s=null,t.success===!1&&this.#g(`retries exhausted: ${String(t.finalError??"unknown error")}`,"error");return;case"compaction_start":this.#s={text:"compacting context\u2026",kind:"info"};return;case"compaction_end":{this.#s=null;let r=t.result;typeof t.errorMessage=="string"&&t.errorMessage?this.#g(`compaction failed: ${t.errorMessage}`,"error"):r?.tokensBefore&&this.#g(`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.#l.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??oC),ownTimeout:s!==void 0})}else if(r==="notify"){let s=t.notifyType==="warning"?"warning":t.notifyType==="error"?"error":"info";this.#g(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.#p.set(s,t.statusText):this.#p.delete(s)}return}default:return}}#O(e){this.#m=e,this.#n=!1,this.#i=!1,this.#t=0,this.#r=!1,this.#c=null,this.#o=[],this.#y=null,this.#s=null,this.#a=null,this.#p.clear(),this.#l=[],this.#b=null,this.#k=null,this.#w=null,this.#e=void 0,this.#C(e)}#C(e){for(let[,t]of this.#u)clearTimeout(t.timer),t.resolve({type:"response",success:!1,error:e});this.#u.clear()}},Ob=n=>new Promise(e=>{setTimeout(e,n).unref?.()})});import{existsSync as _b,readFileSync as uC,realpathSync as dC}from"fs";import{join as xn,dirname as $b,resolve as fC}from"path";import{homedir as Rb}from"os";function hC(n,e){let t=xn(n,".pi");if(pC.some(s=>_b(xn(t,s))))return!0;let r=xn(e,".agents","skills");for(let s=n;;){let i=xn(s,".agents","skills");if(i!==r&&_b(i))return!0;let o=$b(s);if(o===s)return!1;s=o}}function mC(n,e){for(let t=e;;){if(n[t]===!0||n[t]===!1)return!0;let r=$b(t);if(r===t)return!1;t=r}}function Lb(n,e){try{let t=e?.agentDir??xn(Rb(),".pi","agent"),r=Ib(e?.home??process.env.HOME??Rb()),s=Ib(fC(n));if(!hC(s,r))return null;let i=Nb(xn(t,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||mC(Nb(xn(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 pC,Ib,Nb,Mb=S(()=>{"use strict";pC=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],Ib=n=>{try{return dC(n)}catch{return n}},Nb=n=>{try{return JSON.parse(uC(n,"utf8"))}catch{return{}}}});import{statSync as gC,openSync as yC,readSync as bC,closeSync as wC,existsSync as Db}from"fs";import{join as Ea}from"path";import{homedir as $d}from"os";import{execFile as vC}from"child_process";async function kC(n){let e=Ea($d(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let t of["fd","fdfind",...Db(e)?[e]:[]]){let r=await new Promise(s=>{vC(t,["--base-directory",n,"--type","f","--follow","--hidden","--exclude",".git"],{maxBuffer:67108864},(i,o)=>s(i?null:o))});if(r!==null)return r.split(`
2010
+ `).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function xC(n){return`--${n.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function Bb(n){return n.type==="message"?EC(n.message?.role):n.type==="custom_message"?n.display!==!1:!1}var SC,EC,Er,Ld=S(()=>{"use strict";ms();cu();bo();kb();Cb();Mb();SC=Ea($d(),".pi","agent","sessions");EC=n=>n==="user"||n==="assistant"||n==="toolResult"||n==="bashExecution";Er=class extends $t{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return Db(Ea($d(),".pi","agent"))}ensureHarnessSupport(){Sb()}createDriver(e,t){let r=new xa(e,t),s=Lb(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return kC(e)}sessionsDir(e){return Ea(SC,xC(e))}listSessionFiles(e){return yo(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 Bb(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(d=>d.type==="text").map(d=>d.text??"").join(""),a=i.filter(d=>d.type==="thinking").map(d=>d.thinking??"").join(`
2011
+ `),l=i.filter(d=>d.type==="toolCall").map(d=>({id:d.id??"",name:d.name??"",input:d.arguments??{}}));if(o||a||l.length){let d=Date.parse(e.timestamp??""),p=!isNaN(d)&&d>=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,u=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:u,model:s.model,cost:c?.cost?.total}}return{events:r}}chainWorking(e){let t;for(let a of e)Bb(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=yC(e,"r")}catch{return""}try{let s=65536;try{s=gC(e).size}catch{}let i=(u,d)=>{let p=Buffer.alloc(d),g=bC(t,p,0,d,u);return p.subarray(0,g).toString("utf8")},o=i(0,Math.min(65536,s)),a=s>65536?i(s-65536,65536):"",l=u=>{let d="";for(let p of u.split(`
2012
+ `))if(p.includes('"session_info"'))try{let g=JSON.parse(p);g?.type==="session_info"&&typeof g.name=="string"&&g.name&&(d=g.name)}catch{}return d},c="";for(let u of o.split(`
2013
+ `))if(!(c||!u.includes('"type"')))try{let d=JSON.parse(u);d?.type==="message"&&d.message?.role==="user"&&(c=this.contentText(d.message.content).replace(/\s+/g," ").trim())}catch{}let f=l(a)||l(o)||c;return f?f.slice(0,200):""}finally{wC(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"?Ae(e):Array.isArray(e)?e.map(t=>typeof t?.text=="string"?Ae(t.text):t?.type==="image"&&t.data?go(t.data,t.mimeType):"").filter(Boolean).join(`
2014
+ `):""}}});var Aa,jb=S(()=>{"use strict";Aa=class{#e=new Map;accept(e,t){return this.#e.get(e)===t?!1:(this.#e.set(e,t),!0)}}});import{execFile as AC}from"child_process";import{promisify as TC}from"util";import{readFile as PC}from"fs/promises";import{resolve as Fb,sep as OC}from"path";async function Qe(n,e){let{stdout:t}=await CC("git",n,{cwd:e,maxBuffer:67108864});return t}async function En(){if(Ta)return Ta;try{Ta=(await Qe(["rev-parse","--show-toplevel"],G)).trim()}catch{}return Ta}function _C(n,e){let t=e===" "?n:e;return t==="?"?"U":t}async function Bd(){let n=await En();if(!n)return{repo:!1,root:"",files:[]};try{let e=await Qe(["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:_C(i[0],i[1])}))}try{let s=await Qe(["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:z(e)}}}async function Dd(n){let e=await En();if(!e)return{ok:!1,error:"not a git repository"};try{if((await Qe(["status","--porcelain","-z","--",n],e)).startsWith("??")){let s=Fb(e,n);if(!s.startsWith(Fb(e)+OC))return{ok:!1,error:"outside repository"};let i=await PC(s);return i.includes(0)?Md("Binary file (not shown)",!1):Md(i.toString("utf8"),!0)}let r;try{r=await Qe(["diff","--no-color","--unified=999999","HEAD","--",n],e)}catch{r=await Qe(["diff","--no-color","--unified=999999","--",n],e)}return Md(r,!1)}catch(t){return{ok:!1,error:z(t)}}}var CC,Ub,Ta,Md,Ws=S(()=>{"use strict";Ht();CC=TC(AC),Ub=2e6;Md=(n,e)=>({ok:!0,text:n.slice(0,Ub),untracked:e,truncated:n.length>Ub})});function Ks(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 jd=S(()=>{"use strict"});function qb(){return RC.map(([n,e])=>ht(n,e)).filter(n=>typeof n!="string")}function Jb(){return qb().length>0}async function Pa(n,e,t=0){let r=AbortSignal.timeout(e);for(let s of qb()){try{let i=await Ft(s,{messages:[{role:"user",content:n}],effort:t,webSearch:!1,signal:r});if(i.ok){let o=(await td(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var RC,Fd=S(()=>{"use strict";Dt();kr();RC=[["openrouter","openai/gpt-5.6-luna"],["openai","gpt-5.6-luna"]]});var Oa,Ca,Wb=S(()=>{"use strict";Oa=".typebulb/paste",Ca={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"}});import{existsSync as IC,mkdirSync as NC,writeFileSync as $C,readFileSync as LC}from"fs";import{join as _a}from"path";function Kb(){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 DC(n){return n.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function jC(n){let e=await Pa(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
2012
2015
 
2013
- ${n.slice(0,a_)}`,o_);return e&&l_(e)||void 0}async function Db(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=Pa(n,Aa);try{r_(t,{recursive:!0})}catch(a){return{ok:!1,error:V(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${Bb()}`,s=Object.keys(Ta).find(a=>Ta[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await c_(e.data)??`paste-${Bb()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;n_(Pa(t,o));a++)o=`${r}-${a}.${s}`;try{s_(Pa(t,o),i)}catch(a){return{ok:!1,error:V(a)}}return{ok:!0,path:`${Aa}/${o}`}}function jb(n,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let t=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=Ta[t];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:i_(Pa(n,Aa,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var o_,a_,Fb=v(()=>{"use strict";Id();Wt();Mb();o_=4e3,a_=4e3});async function Jb(n,e=""){let t=n.trim();if(!t)return{ok:!1,error:"nothing to summarize"};if(!Lb())return{ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0};let r=e.trim()?qb+`CONTEXT \u2014 the user message this reply answers. It is context only: never summarize it, and never report it as the reply's content.
2014
- `+d_(e.trim())+`
2016
+ ${n.slice(0,BC)}`,MC);return e&&DC(e)||void 0}async function Hb(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=_a(n,Oa);try{NC(t,{recursive:!0})}catch(a){return{ok:!1,error:z(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${Kb()}`,s=Object.keys(Ca).find(a=>Ca[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await jC(e.data)??`paste-${Kb()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;IC(_a(t,o));a++)o=`${r}-${a}.${s}`;try{$C(_a(t,o),i)}catch(a){return{ok:!1,error:z(a)}}return{ok:!0,path:`${Oa}/${o}`}}function Yb(n,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let t=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=Ca[t];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:LC(_a(n,Oa,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var MC,BC,Vb=S(()=>{"use strict";Fd();Ht();Wb();MC=4e3,BC=4e3});async function Xb(n,e=""){let t=n.trim();if(!t)return{ok:!1,error:"nothing to summarize"};if(!Jb())return{ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0};let r=e.trim()?Gb+`CONTEXT \u2014 the user message this reply answers. It is context only: never summarize it, and never report it as the reply's content.
2017
+ `+UC(e.trim())+`
2015
2018
 
2016
2019
  REPLY TO SUMMARIZE:
2017
- `+t.slice(0,Ub):qb+t.slice(0,Ub),s=await Ea(r,u_,1);return s?{ok:!0,text:s}:{ok:!1,error:"the model call failed or timed out"}}var u_,Ub,qb,d_,Wb=v(()=>{"use strict";Id();u_=2e4,Ub=24e3,qb=`Summarize this assistant reply for someone who wants its substance without the prose.
2020
+ `+t.slice(0,zb):Gb+t.slice(0,zb),s=await Pa(r,FC,1);return s?{ok:!0,text:s}:{ok:!1,error:"the model call failed or timed out"}}var FC,zb,Gb,UC,Qb=S(()=>{"use strict";Fd();FC=2e4,zb=24e3,Gb=`Summarize this assistant reply for someone who wants its substance without the prose.
2018
2021
 
2019
2022
  - 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.
2020
2023
  - 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.
@@ -2029,23 +2032,24 @@ Reply with the summary alone.
2029
2032
 
2030
2033
  ---
2031
2034
 
2032
- `,d_=(n,e=4e3)=>{if(n.length<=e)return n;let t=Math.floor(e/2)-20;return n.slice(0,t)+`
2035
+ `,UC=(n,e=4e3)=>{if(n.length<=e)return n;let t=Math.floor(e/2)-20;return n.slice(0,t)+`
2033
2036
 
2034
2037
  [snipped for brevity]
2035
2038
 
2036
- `+n.slice(n.length-t)}});function f_(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 Kb,Hb=v(()=>{"use strict";Kb=(n,e)=>f_(n,{key:e,desc:!0})});import{existsSync as Yb,openSync as p_,readSync as h_,closeSync as m_,statSync as Sr,readdirSync as Vb,watchFile as g_,unwatchFile as zb,mkdirSync as y_,writeFileSync as b_,readFileSync as Oa,unlinkSync as w_,rmSync as v_}from"fs";import{stat as S_}from"fs/promises";import{dirname as k_,join as xn,resolve as Gb}from"path";function T_(n){if(!Number.isInteger(n))return!0;try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}function kr(n){let e={cwd:G,sessionId:"",sessionStartMs:Date.now(),buffer:[],partial:"",offset:0,latest:{in:0,out:0,cached:0,cacheCreate:0},latestModel:null,everAttached:!1,entries:new Map},t=new Set,r,s=0;function i(){if(e.file){for(let g of t)if(g.file===e.file)return g;return}return r}function o(g){let k={d:n.createDriver(e.cwd,g),file:g,id:`new:${++s}`,startedAt:Date.now()};return t.add(k),e.file||(r=k),k}function a(){let g=[...t].filter(w=>w.file);if(!g.length)return[];let k=new Map(n.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return g.map(w=>{let _=k.get(w.file);return{rec:w,sessionId:_??w.id,pending:_===void 0}})}let l=()=>a().filter(g=>g.pending&&g.rec.prompt!==void 0);async function c(g){t.delete(g),r===g&&(r=void 0);try{await g.d.dispose()}catch(k){console.error("[composer] dispose:",V(k))}}function f(){let g=i(),k=new Set(l().map(w=>w.rec));for(let w of[...t])w!==g&&(k.has(w)||w.d.streaming||w.d.queue||w.d.error||c(w))}function u(){for(let g of t)g.d.sessionFile&&g.file!==g.d.sessionFile&&(g.file=g.d.sessionFile);if(r&&!e.file&&r.file){let g=n.listSessionFiles(e.cwd).find(k=>k.file===r.file);g&&A(g)}r&&!e.file&&r.prompt!==void 0&&e.sessionId!==r.id&&($(void 0,r.id),e.everAttached=!0)}let d=g=>xn(g,E_),p=(g,k)=>xn(d(g),`${k}.lock`);function m(g,k){try{let w=p(g,k);if(Date.now()-Sr(w).mtimeMs>=Xb)return!1;try{let _=parseInt(Oa(w,"utf8").trim(),10);if(_===process.pid||!T_(_))return!1}catch{}return!0}catch{return!1}}function h(g,k){if(k)try{y_(d(g),{recursive:!0}),b_(p(g,k),String(process.pid))}catch(w){console.error("[lock] claim failed:",V(w))}}function b(g){try{v_(xn(g,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function E(g){let k=d(g);if(!Yb(k))return;let w;try{w=Vb(k)}catch{return}let _=Date.now();for(let L of w){if(!L.endsWith(".lock"))continue;let j=xn(k,L);try{let B=Sr(j);_-B.mtimeMs>A_&&w_(j)}catch{}}}function T(g){try{return Sr(g),!1}catch(k){return k.code==="ENOENT"}}function P(){let g=e;if(g.file&&!T(g.file)){h(g.cwd,g.sessionId);return}let k=x(g);k&&A(k)}function x(g){if(!g.everAttached)return I(g.cwd)??R(g.cwd,()=>!0)}function I(g){let k=d(g);if(!Yb(k))return;let w;try{w=Vb(k)}catch{return}let _;for(let j of w)if(j.endsWith(".lock"))try{let B=Sr(xn(k,j));if(Date.now()-B.mtimeMs>=Xb||parseInt(Oa(xn(k,j),"utf8").trim(),10)!==process.pid)continue;(!_||B.mtimeMs>_.mtime)&&(_={sessionId:j.slice(0,-5),mtime:B.mtimeMs})}catch{}if(!_)return;let L=n.listSessionFiles(g).find(j=>j.sessionId===_.sessionId);if(!(!L||T(L.file)))return L}function R(g,k){return n.listSessionFiles(g).sort((w,_)=>_.mtime-w.mtime).find(w=>!m(g,w.sessionId)&&k(w))}function $(g,k){let w=e;if(w.file)try{zb(w.file)}catch{}w.file=g,w.sessionId=k,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:k})}function A(g){let k=e;r=void 0,$(g.file,g.sessionId),k.everAttached=!0,h(k.cwd,g.sessionId),Q();try{zb(g.file)}catch{}g_(g.file,{interval:200},()=>Q())}function W(){$(void 0,"")}function Q(){let g=e;if(!g.file)return;let k;try{k=Sr(g.file).size}catch{return}if(k<=g.offset)return;let w;try{w=p_(g.file,"r")}catch{return}try{let Y=k-g.offset,Ee=Buffer.alloc(Y),le=0;for(;le<Y;){let _f=h_(w,Ee,le,Y-le,g.offset+le);if(!_f)break;le+=_f}g.offset+=le,g.partial+=Ee.subarray(0,le).toString("utf8")}finally{m_(w)}let _,L;for(;(L=g.partial.indexOf(`
2037
- `))>=0;){let Y=g.partial.slice(0,L);if(g.partial=g.partial.slice(L+1),!Y.trim())continue;let Ee=n.parseEntry(Y);if(!Ee)continue;let le=n.idOf(Ee);le&&(g.entries.set(le,Ee),!n.isSidechain(Ee)&&n.isLeafType(Ee)&&(_=le))}if(!_)return;let j=[],B=g.entries.get(_),z=!1;for(;B;){if(j.push(B),n.idOf(B)===g.chainLastId){z=!0;break}let Y=n.parentOf(B);B=Y?g.entries.get(Y):void 0}if(z)for(let Y=j.length-2;Y>=0;Y--)de(j[Y]);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 Y=new Set(j.map(le=>n.idOf(le))),Ee=Z(g.entries);for(let le=j.length-1;le>=0;le--)de(j[le]),F(n.idOf(j[le]),Ee,Y)}g.chainLastId=_}function Z(g){let k=new Map;for(let w of g.values()){let _=n.parentOf(w);if(!_)continue;let L=k.get(_);L?L.push(w):k.set(_,[w])}return k}function F(g,k,w){if(!g)return;let _=k.get(g);if(!_)return;let L=_.filter(Y=>!n.isSidechain(Y));if(L.length<2)return;let j=L.filter(Y=>!w.has(n.idOf(Y)));if(!j.length)return;let B=[],z=0;for(let Y of j){let Ee=ye(Y,k);B.push(...Ee.events),z+=Ee.count}z>0&&e.buffer.push({type:"fork",atId:g,count:z,events:B})}function ye(g,k){let w=[],_=[g];for(;_.length;){let B=_.pop();if(n.isSidechain(B))continue;w.push(B);let z=k.get(n.idOf(B)??"");if(z)for(let Y of z)_.push(Y)}w.sort((B,z)=>(Date.parse(n.timestampOf(B)??"")||0)-(Date.parse(n.timestampOf(z)??"")||0));let L=[];for(let B of w)n.isRecoveryNoise(B)||L.push(...n.apply(B,e.sessionStartMs).events);return{count:L.reduce((B,z)=>B+(z.type==="user"||z.type==="assistant"?1:0),0),events:L}}function de(g){try{let{events:k,usage:w,model:_,cost:L}=n.apply(g,e.sessionStartMs);for(let j of k)e.buffer.push(j);k.some(j=>j.type==="assistant")&&i()?.d.clearCompletedDraft(),k.some(j=>j.type==="user")&&i()?.d.clearEcho(),_&&(e.latestModel=_),w&&(e.latest=w),(w||L)&&e.buffer.push({type:"usage",...e.latest,cost:L})}catch(k){console.error("[mirror] skipped malformed entry:",V(k))}}async function Ce(){return{cwd:e.cwd,pid:process.pid,composer:!!n.createDriver,elsewhere:await ke()}}async function ke(){if(n.listSessionFiles(e.cwd).length)return;let g=await kn();if(!g)return;let k=Gb(g).toLowerCase();for(let w=Gb(e.cwd);w.toLowerCase()!==k;){let _=k_(w);if(_===w)return;w=_;let L=n.listSessionFiles(w).length;if(L)return{dir:w,count:L}}}ke().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 se=new Sa;async function ii(g,k){se.accept(g,k)&&console.log(k)}function Gt(){let g=n.sessionAlive(e.sessionId,e.cwd);if(g!==void 0)return g;if(!e.file)return!1;try{return Date.now()-Sr(e.file).mtimeMs<1e4}catch{return!1}}function y(){return n.chainWorking([...e.entries.values()])&&Gt()}function S(){!n.createDriver||i()||e.latestModel||y()||o(e.file)}async function O(g){let k=e;P(),u(),S(),f();let w=i();for(let B of t)B!==w&&B.d.dialog;let _=a().filter(B=>B.rec.d.streaming).map(B=>B.sessionId),L=y(),j=n.createDriver?{streaming:!!w?.d.streaming,foreign:!w&&L,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:k.buffer.slice(g),cursor:k.buffer.length,working:!!w?.d.streaming||L,latestModel:k.latestModel,composer:j,busy:_}}async function N(){P(),u();let g=i();if(g?.d.error&&!g.d.streaming&&(await c(g),g=void 0),!g){if(y())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};g=o(e.file)}let k=g;return{ok:!0,d:k.d,markSent:w=>{k.prompt===void 0&&(k.prompt=w)}}}async function M(g,k){if(!n.createDriver)return{ok:!1,error:"not supported"};let w=String(g??"").trim();if(!w)return{ok:!1,error:"empty message"};let _=await N();if(!_.ok)return _;let L=await _.d.send(w,k);return L.ok&&_.markSent(w),L}async function q(g,k){let w=i();return w?w.d.respondUi(String(g??""),k??{}):{ok:!1,error:"no dialog pending"}}async function J(g,k){if(!n.createDriver)return{ok:!1,error:"not supported"};if(!g||typeof g.type!="string")return{ok:!1,error:"bad command"};if(k?.spawn){let _=await N();return _.ok?_.d.rpc(g):_}let w=i();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(g)}async function Ue(){let g=i();if(g)try{await g.d.stop()}catch(k){console.error("[composer] stop:",V(k))}return{ok:!0}}async function H(){return n.createDriver?(u(),!e.file&&r&&r.prompt===void 0&&!r.d.streaming&&!r.d.error?{ok:!0}:(r?.d.error&&await c(r),r=void 0,W(),o(void 0),f(),{ok:!0})):{ok:!1,error:"not supported"}}async function ae(){if(!n.createDriver)return[];let g=await Xe(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),k=g!==null?g.split(`
2038
- `).filter(Boolean):await n.walkFiles?.(e.cwd)??[];return(await Promise.all(k.map(async _=>{try{return{f:_,m:(await S_(xn(e.cwd,_))).mtimeMs}}catch{return{f:_,m:0}}}))).sort((_,L)=>L.m-_.m).map(_=>_.f)}function xe(){for(let g of[...t])c(g)}async function _r(g){return n.createDriver?Db(e.cwd,g):{ok:!1,error:"not supported"}}async function Xt(g){return jb(e.cwd,String(g??""))}async function St(g,k){return Jb(String(g??""),String(k??""))}async function rl(){let g=n.listSessionFiles(e.cwd).map(({sessionId:w,file:_,mtime:L})=>({sessionId:w,mtime:L,preview:n.readPreview(_)})),k=l().map(w=>({sessionId:w.sessionId,mtime:w.rec.startedAt,preview:w.rec.prompt??"",pending:!0}));return Kb([...g,...k],w=>w.mtime)}let oi=new Map;function zv(g,k){let w=oi.get(g);if(w&&w.mtime===k)return w.turns;let _=[],L="";try{L=Oa(g,"utf8")}catch{return[]}for(let j of L.split(`
2039
- `)){if(!j.trim())continue;let B=n.parseEntry(j);if(!B)continue;let z=n.searchText(B);z&&_.push({text:z,lower:z.toLowerCase()})}return oi.set(g,{mtime:k,turns:_}),_}async function Gv(g){let k=g.toLowerCase(),w=[];for(let{sessionId:_,file:L,mtime:j}of n.listSessionFiles(e.cwd).sort((B,z)=>z.mtime-B.mtime)){let{hitCount:B,snippet:z}=xa(zv(L,j),k);if(B&&(w.push({sessionId:_,mtime:j,preview:n.readPreview(L),hitCount:B,snippet:z}),w.length>=P_))break}return w}let Pf=800,Of=new Map;function Xv(g,k){let w=Of.get(g);if(w&&w.mtime===k)return w.text;let _="";try{_=Oa(g,"utf8")}catch{return""}let L="";for(let B of _.split(`
2040
- `)){if(!B.trim())continue;let z=n.parseEntry(B);if(z)for(let Y of n.apply(z,e.sessionStartMs).events)Y.type==="assistant"&&Y.text.trim()&&(L=Y.text.trim())}let j=L.length>Pf?L.slice(0,Pf).trimEnd()+"\u2026":L;return Of.set(g,{mtime:k,text:j}),j}async function Qv(g){let k=n.listSessionFiles(e.cwd).find(w=>w.sessionId===g);return{text:k?Xv(k.file,k.mtime):""}}async function Zv(g){let k=e,w=n.listSessionFiles(k.cwd).find(_=>_.sessionId===g);if(!w){let _=l().find(L=>L.sessionId===g)?.rec;return _?((r!==_||k.sessionId!==_.id)&&(r=_,$(void 0,_.id),k.everAttached=!0,f()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===k.file?{ok:!0}:(A(w),u(),f(),{ok:!0})}return b(e.cwd),E(e.cwd),P(),{info:Ce,poll:O,logInlineStatus:ii,listSessions:rl,searchSessions:Gv,sessionPeek:Qv,attach:Zv,composerSend:M,composerStop:Ue,composerNew:H,composerFiles:ae,composerUiRespond:q,composerRpc:J,composerPaste:_r,composerPasteRead:Xt,summarizeTurn:St,shutdownComposer:xe}}var x_,E_,Xb,A_,P_,_a=v(()=>{"use strict";Wt();Rb();Js();Rd();Fb();Wb();Hb();x_=".typebulb",E_=`${x_}/locks`,Xb=5e3,A_=6e4;P_=50});import{existsSync as Md,mkdirSync as O_,readFileSync as Qb,writeFileSync as __}from"fs";import{join as En,isAbsolute as C_}from"path";async function Dd(n,e){let t=C_(n)?n:En(G,n);return Md(t)?(Iu(t,e),{ok:!0}):{ok:!1,error:"file not found"}}async function jd(n){let e=G,t=Ru(n),r=En(e,"typebulbs");O_(r,{recursive:!0});let s=Pu(t),i=`${s}.bulb.md`;for(let c=2;Md(En(r,i))&&Qb(En(r,i),"utf8")!==t;c++)i=`${s}-${c}.bulb.md`;let o=En(r,i);Md(o)||__(o,t);let a=En("typebulbs",i),l=await ws(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Fd(){return X(G)}async function Ud(n){let e=(await X()).find(t=>t.pid===n);return e?{ok:!0,outcome:await Lt(e)}:(await zn(n),{ok:!0})}async function qd(){let n=await on(G);return $o(G).filter(e=>!e.serverOnly).map(e=>({...e,trusted:fn(e.path),lastRunAt:n(e.path)}))}async function Jd(n){let e=n.toLowerCase(),t=[];for(let r of $o(G).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Qb(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
2041
- `)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=xa(i,e);o&&t.push({path:r.path,hitCount:o,snippet:a})}return t}async function Wd(n,e){let t=G;e!=null&&tr(n,e);let r=await ws(n,{cwd:t,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function Kd(n){return{cap:await _u(n)}}async function Hd(n,e){return tr(n,e),{ok:!0}}async function Yd(n,e){return He(n,e)}async function Vd(){return Ws&&Date.now()-Ws.fetchedAt<=I_?Ws.samples:(Nd??=N_().finally(()=>{Nd=null}),Nd)}async function N_(){try{let n=await fetch(`${R_}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(ew)});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:fl(i.config)}));return Ws={samples:s,fetchedAt:Date.now()},s}catch{return Ws?.samples??[]}}async function zd(n){return Bd.test(n)?nw(Zb,"samples",n,!0):{ok:!1,error:"bad slug"}}async function Xd(){let n=Gd();if(!n)return{bulbs:[]};let e=`${Ca()}
2042
- ${n}`;return Kt?.key===e&&Date.now()-Kt.fetchedAt<=$_?{user:Kt.user,bulbs:Kt.bulbs}:($d??=L_(e,n).finally(()=>{$d=null}),$d)}async function Ld(n,e,t){let r=await fetch(`${n}${e}`,{headers:t,signal:AbortSignal.timeout(ew)});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 L_(n,e){let t={Authorization:`Bearer ${e}`};try{let r=Ca(),s;try{s=await Ld(r,"/api/me",t)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await Ld(r,"/api/me",t)}let o=(await Ld(r,"/api/scripts/list",t)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:fl(a.config)}));return Kt={key:n,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return Kt?.key===n?{user:Kt.user,bulbs:Kt.bulbs}:{bulbs:[]}}}async function Qd(n,e,t=!1){return!Bd.test(e)||!Bd.test(n)?{ok:!1,error:"bad slug"}:nw(Ca(),n,e,t)}async function nw(n,e,t,r){let s=fa(e,t);try{let i=await ma({origin:n,userSlug:e,slug:t,dest:En(G,s)},{force:r,token:Gd(),timeoutMs:tw});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 Zd(n,e=!1){let t=Gd();if(!t)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=ha(n,G,Ca()),s=await ya(r,{token:t,force:e,timeoutMs:tw});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_,Zb,I_,ew,tw,Ws,Nd,Bd,$_,Kt,$d,Ca,Gd,Ra=v(()=>{"use strict";br();Wt();Rd();ee();R_="https://api.typebulb.com",Zb="https://typebulb.com",I_=3600*1e3,ew=5e3,tw=15e3,Ws=null,Nd=null;Bd=/^[a-z0-9][a-z0-9-]*$/,$_=300*1e3,Kt=null,$d=null,Ca=()=>Ko("TYPEBULB_ORIGIN",G)||Zb,Gd=()=>Ko("TYPEBULB_TOKEN",G)});import{readFileSync as nf,writeFileSync as sw,mkdirSync as M_,appendFileSync as iw,rmSync as rw}from"fs";import{join as $a,dirname as B_}from"path";import{createServer as D_}from"http";function Ht(n){try{return JSON.parse(nf(n,"utf8"))}catch{return null}}function Na(n,e){M_(B_(n),{recursive:!0}),sw(n,JSON.stringify(e,null,2)+`
2043
- `)}function aw(n,e,t){let r=$a(n,".gitignore"),s="";try{s=nf(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(`
2039
+ `+n.slice(n.length-t)}});function qC(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 Ra,Zb=S(()=>{"use strict";Ra=(n,e)=>qC(n,{key:e,desc:!0})});import{existsSync as ew,openSync as JC,readSync as WC,closeSync as KC,statSync as Ar,readdirSync as tw,watchFile as HC,unwatchFile as nw,mkdirSync as YC,writeFileSync as VC,readFileSync as Ia,unlinkSync as zC,rmSync as GC}from"fs";import{stat as XC}from"fs/promises";import{dirname as QC,join as An,resolve as rw}from"path";function n_(n){if(!Number.isInteger(n))return!0;try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}function Tr(n){let e={cwd:G,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=new Set,r,s=0,i="";function o(m){t.clear(),r=m,s=0,i=""}function a(){if(!r||!n.settlesSpawns)return;let m=l(r,s);if(!m.text)return;s=m.offset,i+=m.text;let v;for(;(v=i.indexOf(`
2040
+ `))>=0;){let w=i.slice(0,v);if(i=i.slice(v+1),!w.trim())continue;let A=n.parseEntry(w);if(A)for(let _ of n.settlesSpawns(A))t.add(_)}}function l(m,v){let w={offset:v,text:""},A;try{A=Ar(m).size}catch{return w}if(A<=v)return w;let _;try{_=JC(m,"r")}catch{return w}try{let B=A-v,D=Buffer.alloc(B),j=0;for(;j<B;){let V=WC(_,D,j,B-j,v+j);if(!V)break;j+=V}return{offset:v+j,text:D.subarray(0,j).toString("utf8")}}finally{KC(_)}}let c=new Set,f,u=0;function d(){if(e.file){for(let m of c)if(m.file===e.file)return m;return}return f}function p(m){let v={d:n.createDriver(e.cwd,m),file:m,id:`new:${++u}`,startedAt:Date.now()};return c.add(v),e.file||(f=v),v}function g(){let m=[...c].filter(w=>w.file);if(!m.length)return[];let v=new Map(n.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return m.map(w=>{let A=v.get(w.file);return{rec:w,sessionId:A??w.id,pending:A===void 0}})}let h=()=>g().filter(m=>m.pending&&m.rec.prompt!==void 0);async function y(m){c.delete(m),f===m&&(f=void 0);try{await m.d.dispose()}catch(v){console.error("[composer] dispose:",z(v))}}function E(){let m=d(),v=new Set(h().map(w=>w.rec));for(let w of[...c])w!==m&&(v.has(w)||w.d.streaming||w.d.queue||w.d.error||y(w))}function P(){for(let m of c)m.d.sessionFile&&m.file!==m.d.sessionFile&&(m.file=m.d.sessionFile);if(f&&!e.file&&f.file){let m=n.listSessionFiles(e.cwd).find(v=>v.file===f.file);m&&be(m)}f&&!e.file&&f.prompt!==void 0&&e.sessionId!==f.id&&(te(void 0,f.id),e.everAttached=!0)}let O=m=>An(m,e_),x=(m,v)=>An(O(m),`${v}.lock`);function N(m,v){try{let w=x(m,v);if(Date.now()-Ar(w).mtimeMs>=sw)return!1;try{let A=parseInt(Ia(w,"utf8").trim(),10);if(A===process.pid||!n_(A))return!1}catch{}return!0}catch{return!1}}function I(m,v){if(v)try{YC(O(m),{recursive:!0}),VC(x(m,v),String(process.pid))}catch(w){console.error("[lock] claim failed:",z(w))}}function L(m){try{GC(An(m,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function T(m){let v=O(m);if(!ew(v))return;let w;try{w=tw(v)}catch{return}let A=Date.now();for(let _ of w){if(!_.endsWith(".lock"))continue;let B=An(v,_);try{let D=Ar(B);A-D.mtimeMs>t_&&zC(B)}catch{}}}function K(m){try{return Ar(m),!1}catch(v){return v.code==="ENOENT"}}function X(){let m=e;if(m.file&&!K(m.file)){I(m.cwd,m.sessionId);return}let v=Z(m);v&&be(v)}function Z(m){if(!m.everAttached)return U(m.cwd)??ye(m.cwd,()=>!0)}function U(m){let v=O(m);if(!ew(v))return;let w;try{w=tw(v)}catch{return}let A;for(let B of w)if(B.endsWith(".lock"))try{let D=Ar(An(v,B));if(Date.now()-D.mtimeMs>=sw||parseInt(Ia(An(v,B),"utf8").trim(),10)!==process.pid)continue;(!A||D.mtimeMs>A.mtime)&&(A={sessionId:B.slice(0,-5),mtime:D.mtimeMs})}catch{}if(!A)return;let _=n.listSessionFiles(m).find(B=>B.sessionId===A.sessionId);if(!(!_||K(_.file)))return _}function ye(m,v){return n.listSessionFiles(m).sort((w,A)=>A.mtime-w.mtime).find(w=>!N(m,w.sessionId)&&v(w))}function te(m,v){let w=e;if(w.file)try{nw(w.file)}catch{}w.file=m,w.sessionId=v,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:v})}function be(m){let v=e;f=void 0,ai(),o(m.file),te(m.file,m.sessionId),v.everAttached=!0,I(v.cwd,m.sessionId),qe(m.file)}function qe(m){if(we(),!!m){try{nw(m)}catch{}HC(m,{interval:200},()=>we())}}function pe(){ai(),o(void 0),te(void 0,"")}function we(){let m=e;if(!m.file)return;let v=l(m.file,m.offset);if(!v.text)return;m.offset=v.offset,m.partial+=v.text;let w,A;for(;(A=m.partial.indexOf(`
2041
+ `))>=0;){let j=m.partial.slice(0,A);if(m.partial=m.partial.slice(A+1),!j.trim())continue;let V=n.parseEntry(j);if(!V)continue;let le=n.idOf(V);le&&(m.entries.set(le,V),!n.isSidechain(V,m.thread)&&n.isLeafType(V)&&(w=le))}if(!w)return;let _=[],B=m.entries.get(w),D=!1;for(;B;){if(_.push(B),n.idOf(B)===m.chainLastId){D=!0;break}let j=n.parentOf(B);B=j?m.entries.get(j):void 0}if(D)for(let j=_.length-2;j>=0;j--)C(_[j]);else{m.chainLastId!==void 0&&(m.buffer.push({type:"cleared"}),m.buffer.push({type:"session",sessionId:m.sessionId}),m.latest={in:0,out:0,cached:0,cacheCreate:0});let j=new Set(_.map(le=>n.idOf(le))),V=Qt(m.entries);for(let le=_.length-1;le>=0;le--)C(_[le]),b(n.idOf(_[le]),V,j)}m.chainLastId=w}function Qt(m){let v=new Map;for(let w of m.values()){let A=n.parentOf(w);if(!A)continue;let _=v.get(A);_?_.push(w):v.set(A,[w])}return v}function b(m,v,w){if(!m)return;let A=v.get(m);if(!A)return;let _=A.filter(V=>!n.isSidechain(V,e.thread));if(_.length<2)return;let B=_.filter(V=>!w.has(n.idOf(V)));if(!B.length)return;let D=[],j=0;for(let V of B){let le=k(V,v);D.push(...le.events),j+=le.count}j>0&&e.buffer.push({type:"fork",atId:m,count:j,events:D})}function k(m,v){let w=[],A=[m];for(;A.length;){let D=A.pop();if(n.isSidechain(D,e.thread))continue;w.push(D);let j=v.get(n.idOf(D)??"");if(j)for(let V of j)A.push(V)}w.sort((D,j)=>(Date.parse(n.timestampOf(D)??"")||0)-(Date.parse(n.timestampOf(j)??"")||0));let _=[];for(let D of w)n.isRecoveryNoise(D)||_.push(...n.apply(D,e.sessionStartMs).events);return{count:_.reduce((D,j)=>D+(j.type==="user"||j.type==="assistant"?1:0),0),events:_}}function C(m){try{let{events:v,usage:w,model:A,cost:_}=n.apply(m,e.sessionStartMs);for(let B of v)e.buffer.push(B);v.some(B=>B.type==="assistant")&&d()?.d.clearCompletedDraft(),v.some(B=>B.type==="user")&&d()?.d.clearEcho(),A&&(e.latestModel=A),w&&(e.latest=w),(w||_)&&e.buffer.push({type:"usage",...e.latest,cost:_})}catch(v){console.error("[mirror] skipped malformed entry:",z(v))}}async function $(){return{cwd:e.cwd,pid:process.pid,composer:!!n.createDriver,children:!!n.listChildren,elsewhere:await M()}}async function M(){if(n.listSessionFiles(e.cwd).length)return;let m=await En();if(!m)return;let v=rw(m).toLowerCase();for(let w=rw(e.cwd);w.toLowerCase()!==v;){let A=QC(w);if(A===w)return;w=A;let _=n.listSessionFiles(w).length;if(_)return{dir:w,count:_}}}M().then(m=>{m&&console.log(`No sessions for ${e.cwd} \u2014 ${m.count} exist for ${m.dir}. Launched from a subfolder? Relaunch from the project root.`)}).catch(()=>{});let J=new Aa;async function W(m,v){e.thread!=="child"&&J.accept(m,v)&&console.log(v)}function _e(){let m=n.sessionAlive(e.sessionId,e.cwd);if(m!==void 0)return m;if(!e.file)return!1;try{return Date.now()-Ar(e.file).mtimeMs<1e4}catch{return!1}}function H(){return n.chainWorking([...e.entries.values()])&&_e()}function ae(){!n.createDriver||d()||e.latestModel||H()||p(e.file)}async function Ee(m){let v=e;X(),P(),ae(),E();let w=d();for(let D of c)D!==w&&D.d.dialog;let A=g().filter(D=>D.rec.d.streaming).map(D=>D.sessionId),_=H(),B=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:v.buffer.slice(m),cursor:v.buffer.length,working:!!w?.d.streaming||_,latestModel:v.latestModel,child:v.child?.id??null,composer:B,busy:A}}async function Rn(){X(),P();let m=d();if(m?.d.error&&!m.d.streaming&&(await y(m),m=void 0),!m){if(H())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};m=p(e.file)}let v=m;return{ok:!0,d:v.d,markSent:w=>{v.prompt===void 0&&(v.prompt=w)}}}async function Zt(m,v){if(!n.createDriver)return{ok:!1,error:"not supported"};let w=String(m??"").trim();if(!w)return{ok:!1,error:"empty message"};let A=await Rn();if(!A.ok)return A;let _=await A.d.send(w,v);return _.ok&&A.markSent(w),_}async function xt(m,v){let w=d();return w?w.d.respondUi(String(m??""),v??{}):{ok:!1,error:"no dialog pending"}}async function al(m,v){if(!n.createDriver)return{ok:!1,error:"not supported"};if(!m||typeof m.type!="string")return{ok:!1,error:"bad command"};if(v?.spawn){let A=await Rn();return A.ok?A.d.rpc(m):A}let w=d();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(m)}async function ll(){let m=d();if(m)try{await m.d.stop()}catch(v){console.error("[composer] stop:",z(v))}return{ok:!0}}async function sS(){return n.createDriver?(P(),!e.file&&f&&f.prompt===void 0&&!f.d.streaming&&!f.d.error?{ok:!0}:(f?.d.error&&await y(f),f=void 0,pe(),p(void 0),E(),{ok:!0})):{ok:!1,error:"not supported"}}async function iS(){if(!n.createDriver)return[];let m=await Qe(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),v=m!==null?m.split(`
2042
+ `).filter(Boolean):await n.walkFiles?.(e.cwd)??[];return(await Promise.all(v.map(async A=>{try{return{f:A,m:(await XC(An(e.cwd,A))).mtimeMs}}catch{return{f:A,m:0}}}))).sort((A,_)=>_.m-A.m).map(A=>A.f)}function oS(){for(let m of[...c])y(m)}async function aS(m){return n.createDriver?Hb(e.cwd,m):{ok:!1,error:"not supported"}}async function lS(m){return Yb(e.cwd,String(m??""))}async function cS(m,v){return Xb(String(m??""),String(v??""))}async function uS(){let m=n.sessionsWorking?.(e.cwd),v=n.listSessionFiles(e.cwd).map(({sessionId:A,file:_,mtime:B})=>({sessionId:A,mtime:B,preview:n.readPreview(_),working:m?.has(A)})),w=h().map(A=>({sessionId:A.sessionId,mtime:A.rec.startedAt,preview:A.rec.prompt??"",pending:!0}));return Ra([...v,...w],A=>A.mtime)}let Lf=new Map;function Mf(m,v){let w=Lf.get(m);if(w&&w.mtime===v)return w.turns;let A=[],_="";try{_=Ia(m,"utf8")}catch{return[]}for(let B of _.split(`
2043
+ `)){if(!B.trim())continue;let D=n.parseEntry(B);if(!D)continue;let j=n.searchText(D);j&&A.push({text:j,lower:j.toLowerCase()})}return Lf.set(m,{mtime:v,turns:A}),A}async function dS(m){let v=m.toLowerCase(),w=[],A=0,_=n.sessionsWorking?.(e.cwd);for(let{sessionId:B,file:D,mtime:j}of n.listSessionFiles(e.cwd).sort((V,le)=>le.mtime-V.mtime)){let V=Ks(Mf(D,j),v),le=(n.listChildren?.(e.cwd,B)??[]).map(Re=>({c:Re,hit:Ks(Mf(Re.file,Re.mtime),v)})).filter(Re=>Re.hit.hitCount);if(!(!V.hitCount&&!le.length)){for(let{c:Re,hit:vS}of Ra(le,SS=>SS.c.mtime))w.push({sessionId:B,mtime:Re.mtime,preview:Re.label||Re.kind,...vS,child:{id:Re.id,kind:Re.kind,depth:Re.depth}});if(w.push({sessionId:B,mtime:j,preview:n.readPreview(D),working:_?.has(B),...V}),++A>=r_)break}}return w}let Bf=800,Df=new Map;function fS(m,v){let w=Df.get(m);if(w&&w.mtime===v)return w.text;let A="";try{A=Ia(m,"utf8")}catch{return""}let _="";for(let D of A.split(`
2044
+ `)){if(!D.trim())continue;let j=n.parseEntry(D);if(j)for(let V of n.apply(j,e.sessionStartMs).events)V.type==="assistant"&&V.text.trim()&&(_=V.text.trim())}let B=_.length>Bf?_.slice(0,Bf).trimEnd()+"\u2026":_;return Df.set(m,{mtime:v,text:B}),B}async function pS(m){let v=n.listSessionFiles(e.cwd).find(w=>w.sessionId===m);return{text:v?fS(v.file,v.mtime):""}}async function hS(m){let v=e,w=n.listSessionFiles(v.cwd).find(A=>A.sessionId===m);if(!w){let A=h().find(_=>_.sessionId===m)?.rec;return A?((f!==A||v.sessionId!==A.id)&&(f=A,ai(),o(void 0),te(void 0,A.id),v.everAttached=!0,E()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===v.file?{ok:!0}:(be(w),P(),E(),{ok:!0})}async function mS(){if(!n.listChildren||!e.sessionId)return[];a();let m=_e(),v=n.listChildren(e.cwd,e.sessionId),w=new Map(v.map(_=>[_.id,_])),A=(_,B=new Set)=>{if(_.stopped||gS(_))return!0;if(!_.parentId||B.has(_.id))return!1;B.add(_.id);let D=w.get(_.parentId);return D?A(D,B):!1};return Ra(v,_=>_.mtime).map(_=>({..._,state:yS(_,m,A(_))}))}function gS(m){return!!m.spawnId&&t.has(m.spawnId)||t.has(m.id)}function yS(m,v,w){return m.stopped?"stopped":w?"done":v?"running":"done"}async function bS(m){let v=e;if(!n.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let w=n.listChildren(v.cwd,v.sessionId).find(A=>A.id===m);return w?(v.thread="child",v.child=w,te(w.file,v.sessionId),qe(w.file),{ok:!0}):{ok:!1,error:"child not found"}}async function wS(){let m=r;return!ai()||!m?{ok:!0}:(te(m,e.sessionId),qe(m),{ok:!0})}function ai(){let m=e;return m.thread==="main"?!1:(m.thread="main",m.child=void 0,!0)}return L(e.cwd),T(e.cwd),X(),{info:$,poll:Ee,logInlineStatus:W,listSessions:uS,searchSessions:dS,sessionPeek:pS,attach:hS,listChildren:mS,openChild:bS,closeChild:wS,composerSend:Zt,composerStop:ll,composerNew:sS,composerFiles:iS,composerUiRespond:xt,composerRpc:al,composerPaste:aS,composerPasteRead:lS,summarizeTurn:cS,shutdownComposer:oS}}var ZC,e_,sw,t_,r_,Na=S(()=>{"use strict";Ht();jb();Ws();jd();Vb();Qb();Zb();ZC=".typebulb",e_=`${ZC}/locks`,sw=5e3,t_=6e4;r_=50});import{existsSync as Wd,mkdirSync as s_,readFileSync as iw,writeFileSync as i_}from"fs";import{join as Tn,isAbsolute as o_}from"path";async function Hd(n,e){let t=o_(n)?n:Tn(G,n);return Wd(t)?(Fu(t,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Yd(n){let e=G,t=ju(n),r=Tn(e,"typebulbs");s_(r,{recursive:!0});let s=Lu(t),i=`${s}.bulb.md`;for(let c=2;Wd(Tn(r,i))&&iw(Tn(r,i),"utf8")!==t;c++)i=`${s}-${c}.bulb.md`;let o=Tn(r,i);Wd(o)||i_(o,t);let a=Tn("typebulbs",i),l=await Ss(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Vd(){return Q(G)}async function zd(n){let e=(await Q()).find(t=>t.pid===n);return e?{ok:!0,outcome:await Bt(e)}:(await Qn(n),{ok:!0})}async function Gd(){let n=await ln(G);return Do(G).filter(e=>!e.serverOnly).map(e=>({...e,trusted:hn(e.path),lastRunAt:n(e.path)}))}async function Xd(n){let e=n.toLowerCase(),t=[];for(let r of Do(G).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=iw(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
2045
+ `)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=Ks(i,e);o&&t.push({path:r.path,hitCount:o,snippet:a})}return t}async function Qd(n,e){let t=G;e!=null&&sr(n,e);let r=await Ss(n,{cwd:t,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function Zd(n){return{cap:await Bu(n)}}async function ef(n,e){return sr(n,e),{ok:!0}}async function tf(n,e){return Ye(n,e)}async function nf(){return Hs&&Date.now()-Hs.fetchedAt<=l_?Hs.samples:(Ud??=c_().finally(()=>{Ud=null}),Ud)}async function c_(){try{let n=await fetch(`${a_}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(aw)});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:yl(i.config)}));return Hs={samples:s,fetchedAt:Date.now()},s}catch{return Hs?.samples??[]}}async function rf(n){return Kd.test(n)?cw(ow,"samples",n,!0):{ok:!1,error:"bad slug"}}async function of(){let n=sf();if(!n)return{bulbs:[]};let e=`${$a()}
2046
+ ${n}`;return Yt?.key===e&&Date.now()-Yt.fetchedAt<=u_?{user:Yt.user,bulbs:Yt.bulbs}:(qd??=d_(e,n).finally(()=>{qd=null}),qd)}async function Jd(n,e,t){let r=await fetch(`${n}${e}`,{headers:t,signal:AbortSignal.timeout(aw)});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 d_(n,e){let t={Authorization:`Bearer ${e}`};try{let r=$a(),s;try{s=await Jd(r,"/api/me",t)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await Jd(r,"/api/me",t)}let o=(await Jd(r,"/api/scripts/list",t)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:yl(a.config)}));return Yt={key:n,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return Yt?.key===n?{user:Yt.user,bulbs:Yt.bulbs}:{bulbs:[]}}}async function af(n,e,t=!1){return!Kd.test(e)||!Kd.test(n)?{ok:!1,error:"bad slug"}:cw($a(),n,e,t)}async function cw(n,e,t,r){let s=ga(e,t);try{let i=await wa({origin:n,userSlug:e,slug:t,dest:Tn(G,s)},{force:r,token:sf(),timeoutMs:lw});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 lf(n,e=!1){let t=sf();if(!t)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=ba(n,G,$a()),s=await Sa(r,{token:t,force:e,timeoutMs:lw});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 a_,ow,l_,aw,lw,Hs,Ud,Kd,u_,Yt,qd,$a,sf,La=S(()=>{"use strict";kr();Ht();jd();ee();a_="https://api.typebulb.com",ow="https://typebulb.com",l_=3600*1e3,aw=5e3,lw=15e3,Hs=null,Ud=null;Kd=/^[a-z0-9][a-z0-9-]*$/,u_=300*1e3,Yt=null,qd=null,$a=()=>zo("TYPEBULB_ORIGIN",G)||ow,sf=()=>zo("TYPEBULB_TOKEN",G)});import{readFileSync as df,writeFileSync as dw,mkdirSync as f_,appendFileSync as fw,rmSync as uw}from"fs";import{join as Da,dirname as p_}from"path";import{createServer as h_}from"http";function Vt(n){try{return JSON.parse(df(n,"utf8"))}catch{return null}}function Ba(n,e){f_(p_(n),{recursive:!0}),dw(n,JSON.stringify(e,null,2)+`
2047
+ `)}function hw(n,e,t){let r=Da(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(`
2044
2048
  `)?`
2045
- `:"";try{iw(r,a+t+`
2049
+ `:"";try{fw(r,a+t+`
2046
2050
  `+o.join(`
2047
2051
  `)+`
2048
- `)}catch(l){console.error("[switcher] .gitignore update failed",V(l))}}function J_(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?Ys="live":s>q_&&(Ys="uncached")}function cw(n,e){let t={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":n.headers["anthropic-version"]||"2023-06-01",...ju},r=n.headers["anthropic-beta"];return typeof r=="string"&&(t["anthropic-beta"]=r),t}function W_(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 uw(n){let e;try{e=JSON.parse(n)}catch{return n}Hs=typeof e?.model=="string"?e.model:null,it&&(e.model=it),Tn&&(e.provider=lw(Tn));let t=/haiku/i.test(Hs||"");return Vs!=null&&!t&&(e.reasoning={effort:ef[Vs]}),delete e.thinking,e.output_config&&delete e.output_config.effort,W_(e),JSON.stringify(e)}function K_(){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}
2052
+ `)}catch(l){console.error("[switcher] .gitignore update failed",z(l))}}function w_(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?zs="live":s>b_&&(zs="uncached")}function gw(n,e){let t={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":n.headers["anthropic-version"]||"2023-06-01",...Yu},r=n.headers["anthropic-beta"];return typeof r=="string"&&(t["anthropic-beta"]=r),t}function v_(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 yw(n){let e;try{e=JSON.parse(n)}catch{return n}Vs=typeof e?.model=="string"?e.model:null,ot&&(e.model=ot),On&&(e.provider=mw(On));let t=/haiku/i.test(Vs||"");return Gs!=null&&!t&&(e.reasoning={effort:cf[Gs]}),delete e.thinking,e.output_config&&delete e.output_config.effort,v_(e),JSON.stringify(e)}function S_(){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}
2049
2053
  data: ${JSON.stringify(a)}
2050
2054
 
2051
2055
  `}case"content_block_delta":case"content_block_stop":{let l=t.get(a.index);return l==null?null:(a.index=l,`event: ${a.type}
@@ -2053,11 +2057,11 @@ data: ${JSON.stringify(a)}
2053
2057
 
2054
2058
  `)}default:return i}};return i=>{n+=i;let o="",a;for(;(a=n.indexOf(`
2055
2059
 
2056
- `))!==-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 H_(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 Ks(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 Y_(n,e,t){if(!it){Ks(e,400,"invalid_request_error",U_);return}let r=process.env.OPENROUTER_API_KEY;if(!r){Ks(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(rf,{method:"POST",headers:cw(n,r),body:uw(t),signal:s.signal})}catch(u){Ks(e,502,"api_error",`proxy upstream failed: ${V(u)}`);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?K_():null;try{for(;;){let{done:u,value:d}=await l.read();if(u)break;if(d)if(f){let p=c.decode(d,{stream:!0});J_(p);let m=f(p);m&&e.write(m)}else e.write(Buffer.from(d))}}catch{}finally{e.writableEnded||e.end()}}async function V_(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(!it||!r)return s();try{let i=await fetch(`${rf}/count_tokens`,{method:"POST",headers:cw(n,r),body:uw(t)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function z_(n,e){let t=n.url||"/";if(n.method==="HEAD"){e.writeHead(200),e.end();return}if(n.method!=="POST"){Ks(e,404,"not_found_error",t);return}H_(n).then(r=>{if(t.includes("count_tokens"))return V_(n,e,r);if(t.includes("/v1/messages"))return Y_(n,e,r);Ks(e,404,"not_found_error",t)})}function G_(){return xr&&An?Promise.resolve(An):new Promise((n,e)=>{let t=D_(z_);t.on("error",e),t.listen(0,"127.0.0.1",()=>{xr=t,An=t.address().port,console.log(`[switcher] wire proxy listening on ${Ia(An)}`),n(An)})})}function X_(){try{xr?.close()}catch{}xr=null,An=null}function Q_(n,e){let t=La(n),r=Ht(t),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===Ia(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=Ma(n);if(!Ht(i)){let a={};for(let l of ow)a[l]=l in s.env?s.env[l]:null;Na(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=Ia(e),s.env.ANTHROPIC_AUTH_TOKEN=F_,Na(t,s),aw(n,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function Z_(n,e,t){let r=Ma(n),s=Ht(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:t},Na(r,s)}function dw(n){let e=La(n),t=Ma(n),r=Ht(t),s=Ht(e);if(s?.env){let i=r?.snapshot||{};for(let o of ow){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{rw(e,{force:!0})}catch{}else Na(e,s)}try{rw(t,{force:!0})}catch{}}async function eC(){let n=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await ut()).filter(r=>r.provider==="openrouter"&&!sf(r.name)).map(r=>({id:r.name,label:r.friendlyName||r.name}))}catch(r){console.error("[switcher] model list failed",V(r))}let t=e.length?void 0:Mu()??void 0;return{hasKey:n,models:e,error:t}}async function tC(){if(xr&&it)return{active:!0,managed:!0,model:it,port:An,provider:Tn,routedModel:Hs,caching:Ys,reasoning:Vs,externalBaseUrl:null};let n=Ht(La(G))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:Vs,externalBaseUrl:n.ANTHROPIC_BASE_URL||null}}async function fw(n,e){let t=await G_();return it=n,Tn=e,Q_(G,t),t}async function nC({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(sf(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 fw(n,of[n]??null),Hs=null,Ys="unknown",Z_(G,n,Tn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${V(e)}`}}return{ok:!0}}async function rC({level:n}){return n!=null&&(!Number.isInteger(n)||n<0||n>=ef.length)?{ok:!1,error:`reasoning level must be 0\u2013${ef.length-1} or null`}:(Vs=n,{ok:!0,level:n})}async function sC(){return dw(G),it=null,Tn=null,Hs=null,Ys="unknown",{ok:!0}}async function iC({key:n}){let e=(n||"").trim();if(!e)return{ok:!1,error:"empty key"};let t=G,r=$a(t,".env"),s="";try{s=nf(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))sw(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
2060
+ `))!==-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 k_(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 Ys(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 x_(n,e,t){if(!ot){Ys(e,400,"invalid_request_error",y_);return}let r=process.env.OPENROUTER_API_KEY;if(!r){Ys(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(ff,{method:"POST",headers:gw(n,r),body:yw(t),signal:s.signal})}catch(u){Ys(e,502,"api_error",`proxy upstream failed: ${z(u)}`);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?S_():null;try{for(;;){let{done:u,value:d}=await l.read();if(u)break;if(d)if(f){let p=c.decode(d,{stream:!0});w_(p);let g=f(p);g&&e.write(g)}else e.write(Buffer.from(d))}}catch{}finally{e.writableEnded||e.end()}}async function E_(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(!ot||!r)return s();try{let i=await fetch(`${ff}/count_tokens`,{method:"POST",headers:gw(n,r),body:yw(t)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function A_(n,e){let t=n.url||"/";if(n.method==="HEAD"){e.writeHead(200),e.end();return}if(n.method!=="POST"){Ys(e,404,"not_found_error",t);return}k_(n).then(r=>{if(t.includes("count_tokens"))return E_(n,e,r);if(t.includes("/v1/messages"))return x_(n,e,r);Ys(e,404,"not_found_error",t)})}function T_(){return Pr&&Pn?Promise.resolve(Pn):new Promise((n,e)=>{let t=h_(A_);t.on("error",e),t.listen(0,"127.0.0.1",()=>{Pr=t,Pn=t.address().port,console.log(`[switcher] wire proxy listening on ${Ma(Pn)}`),n(Pn)})})}function P_(){try{Pr?.close()}catch{}Pr=null,Pn=null}function O_(n,e){let t=ja(n),r=Vt(t),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===Ma(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=Fa(n);if(!Vt(i)){let a={};for(let l of pw)a[l]=l in s.env?s.env[l]:null;Ba(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=Ma(e),s.env.ANTHROPIC_AUTH_TOKEN=g_,Ba(t,s),hw(n,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function C_(n,e,t){let r=Fa(n),s=Vt(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:t},Ba(r,s)}function bw(n){let e=ja(n),t=Fa(n),r=Vt(t),s=Vt(e);if(s?.env){let i=r?.snapshot||{};for(let o of pw){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{uw(e,{force:!0})}catch{}else Ba(e,s)}try{uw(t,{force:!0})}catch{}}async function __(){let n=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await ft()).filter(r=>r.provider==="openrouter"&&!pf(r.name)).map(r=>({id:r.name,label:r.friendlyName||r.name}))}catch(r){console.error("[switcher] model list failed",z(r))}let t=e.length?void 0:Wu()??void 0;return{hasKey:n,models:e,error:t}}async function R_(){if(Pr&&ot)return{active:!0,managed:!0,model:ot,port:Pn,provider:On,routedModel:Vs,caching:zs,reasoning:Gs,externalBaseUrl:null};let n=Vt(ja(G))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:Gs,externalBaseUrl:n.ANTHROPIC_BASE_URL||null}}async function ww(n,e){let t=await T_();return ot=n,On=e,O_(G,t),t}async function I_({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(pf(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 ww(n,hf[n]??null),Vs=null,zs="unknown",C_(G,n,On)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${z(e)}`}}return{ok:!0}}async function N_({level:n}){return n!=null&&(!Number.isInteger(n)||n<0||n>=cf.length)?{ok:!1,error:`reasoning level must be 0\u2013${cf.length-1} or null`}:(Gs=n,{ok:!0,level:n})}async function $_(){return bw(G),ot=null,On=null,Vs=null,zs="unknown",{ok:!0}}async function L_({key:n}){let e=(n||"").trim();if(!e)return{ok:!1,error:"empty key"};let t=G,r=Da(t,".env"),s="";try{s=df(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))dw(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
2057
2061
  `)?`
2058
- `:"";iw(r,i+`OPENROUTER_API_KEY=${e}
2059
- `)}}catch(i){return{ok:!1,error:V(i)}}return process.env.OPENROUTER_API_KEY=e,aw(t,[".env"],"# secrets"),{ok:!0}}function oC(){if(!(!xr&&!it)){try{dw(G)}catch{}X_()}}function aC(n,e){return pw.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 lC(n){if(pw.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 cC(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=tf(e?.cache_read_input_tokens)||tf(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 uC({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(sf(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:lw(a)}:i),u=await fetch(rf,{method:"POST",signal:l.signal,headers:s,body:f}),d=await u.json().catch(()=>({}));return{r:u,j:d}}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()-t,error:aC(a.status,E),restriction:lC(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",u=tf(l?.usage?.cache_creation_input_tokens),{r:d,j:p}=await o(c),{works:m,read:h,note:b}=cC(d.ok,p?.usage,c);return m===!0&&c&&(of[n]=c,it===n&&(Tn=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:u,read:h,note:b}}}catch(a){let l=V(a);return{ok:!0,callable:!1,ms:Date.now()-t,error:/abort/i.test(l)?"timed out (20s)":l}}}var j_,rf,F_,U_,ow,q_,ef,La,Ma,Ia,sf,xr,An,it,Tn,Hs,Ys,Vs,of,tf,lw,pw,hw=v(()=>{"use strict";br();Wt();Mt();j_="https://openrouter.ai/api",rf=`${j_}/v1/messages`,F_="typebulb-proxy-managed",U_="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.",ow=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],q_=5e3,ef=["low","medium","high"],La=n=>$a(n,".claude","settings.local.json"),Ma=n=>$a(n,".claude",".cc-switcher.json"),Ia=n=>`http://127.0.0.1:${n}`;sf=n=>/^anthropic\//i.test(n)||/claude/i.test(n),xr=null,An=null,it=null,Tn=null,Hs=null,Ys="unknown",Vs=1,of={},tf=n=>typeof n=="number"?n:0,lw=n=>({order:[n],allow_fallbacks:!1});pw=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=Ht(Ma(G)),t=e?.active?.model;if(!t)return;let s=(Ht(La(G))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await fw(t,e.active.provider??of[t]??null);console.log(`[switcher] re-adopted override after restart: ${t} via ${Ia(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",V(e))}})()});var gw={};li(gw,{attach:()=>bC,blockToMarkdown:()=>bo,breakout:()=>jd,capText:()=>Ae,cleanUserText:()=>Nt,clearSwitchModel:()=>sC,composerPasteRead:()=>wC,displayName:()=>dC,downloadSample:()=>zd,firstLineDigest:()=>Ie,git:()=>Xe,gitChangedFiles:()=>_d,gitDiff:()=>Cd,info:()=>fC,isHiddenTurn:()=>ps,launchBulb:()=>Wd,listBreakouts:()=>Fd,listBulbFiles:()=>qd,listMyBulbs:()=>Xd,listSamples:()=>Vd,listSessions:()=>mC,listSwitchModels:()=>eC,logInlineStatus:()=>hC,openFile:()=>Dd,poll:()=>pC,predictTrustOf:()=>Kd,probeModel:()=>uC,pullRemoteBulb:()=>Qd,pushLocalBulb:()=>Zd,readBulbLog:()=>Yd,repoRoot:()=>kn,saveOpenRouterKey:()=>iC,searchBulbs:()=>Jd,searchSessions:()=>gC,sessionPeek:()=>yC,setBulbTrust:()=>Hd,setReasoning:()=>rC,setSwitchModel:()=>nC,shutdownSwitcher:()=>oC,stopBreakout:()=>Ud,summarizeTurn:()=>vC,switchState:()=>tC,toolResultDigest:()=>lu});var mw,dC,fC,pC,hC,mC,gC,yC,bC,wC,vC,yw=v(()=>{"use strict";_a();wo();Ra();Js();hw();wo();fs();mw=new Wn,dC=mw.displayName,{info:fC,poll:pC,logInlineStatus:hC,listSessions:mC,searchSessions:gC,sessionPeek:yC,attach:bC,composerPasteRead:wC,summarizeTurn:vC}=kr(mw)});var ww={};li(ww,{attach:()=>OC,breakout:()=>jd,composerPasteRead:()=>_C,displayName:()=>SC,downloadSample:()=>zd,git:()=>Xe,gitChangedFiles:()=>_d,gitDiff:()=>Cd,info:()=>kC,launchBulb:()=>Wd,listBreakouts:()=>Fd,listBulbFiles:()=>qd,listMyBulbs:()=>Xd,listSamples:()=>Vd,listSessions:()=>AC,logInlineStatus:()=>EC,openFile:()=>Dd,poll:()=>xC,predictTrustOf:()=>Kd,pullRemoteBulb:()=>Qd,pushLocalBulb:()=>Zd,readBulbLog:()=>Yd,repoRoot:()=>kn,searchBulbs:()=>Jd,searchSessions:()=>TC,sessionPeek:()=>PC,setBulbTrust:()=>Hd,stopBreakout:()=>Ud,summarizeTurn:()=>CC});var bw,SC,kC,xC,EC,AC,TC,PC,OC,_C,CC,vw=v(()=>{"use strict";_a();du();Ra();Js();bw=new Hn,SC=bw.displayName,{info:kC,poll:xC,logInlineStatus:EC,listSessions:AC,searchSessions:TC,sessionPeek:PC,attach:OC,composerPasteRead:_C,summarizeTurn:CC}=kr(bw)});import{readFileSync as RC,writeFileSync as IC,mkdirSync as NC}from"fs";import{homedir as $C}from"os";import*as Ba from"path";async function xw(){try{let n=await fetch(new URL("/api/tags",kw()).toString(),{signal:AbortSignal.timeout(LC)});return n.ok?((await n.json()).models??[]).map(t=>t.name).filter(t=>!!t):[]}catch{return[]}}function Ew(n){let e;try{e=RC(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&&!af(r)}}}catch{}return{json:void 0,unreadable:!0}}function af(n){let e=n?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function MC(n){let e=af(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 Aw(){let{json:n,unreadable:e}=Ew(Sw());return e?{installed:[],configured:null}:{installed:await xw(),configured:MC(n)}}async function Tw(){let n=await xw();return n.length?BC(Sw(),n,kw()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function BC(n,e,t){let{json:r,unreadable:s}=Ew(n);if(s)return{ok:!1,error:`could not parse ${n} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...af(r)??{},ollama:{baseUrl:`${t}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{NC(Ba.dirname(n),{recursive:!0}),IC(n,JSON.stringify(i,null,2)+`
2060
- `)}catch(o){return{ok:!1,error:`could not write ${n}: ${V(o)}`}}return{ok:!0,count:e.length}}var LC,Sw,kw,Pw=v(()=>{"use strict";Wt();br();LC=1500,Sw=()=>Ba.join($C(),".pi","agent","models.json"),kw=()=>rr(process.env.OLLAMA_HOST??"http://localhost:11434")});var _w={};li(_w,{attach:()=>KC,breakout:()=>jd,composerFiles:()=>zC,composerNew:()=>VC,composerPaste:()=>QC,composerPasteRead:()=>ZC,composerRpc:()=>XC,composerSend:()=>HC,composerStop:()=>YC,composerUiRespond:()=>GC,displayName:()=>DC,downloadSample:()=>zd,git:()=>Xe,gitChangedFiles:()=>_d,gitDiff:()=>Cd,info:()=>jC,launchBulb:()=>Wd,listBreakouts:()=>Fd,listBulbFiles:()=>qd,listMyBulbs:()=>Xd,listSamples:()=>Vd,listSessions:()=>qC,logInlineStatus:()=>UC,ollamaOffer:()=>Aw,ollamaSync:()=>Tw,openFile:()=>Dd,poll:()=>FC,predictTrustOf:()=>Kd,pullRemoteBulb:()=>Qd,pushLocalBulb:()=>Zd,readBulbLog:()=>Yd,repoRoot:()=>kn,searchBulbs:()=>Jd,searchSessions:()=>JC,sessionPeek:()=>WC,setBulbTrust:()=>Hd,shutdownComposer:()=>tR,stopBreakout:()=>Ud,summarizeTurn:()=>eR});var Ow,DC,jC,FC,UC,qC,JC,WC,KC,HC,YC,VC,zC,GC,XC,QC,ZC,eR,tR,Cw=v(()=>{"use strict";_a();Pd();Ra();Js();Pw();Ow=new vr,DC=Ow.displayName,{info:jC,poll:FC,logInlineStatus:UC,listSessions:qC,searchSessions:JC,sessionPeek:WC,attach:KC,composerSend:HC,composerStop:YC,composerNew:VC,composerFiles:zC,composerUiRespond:GC,composerRpc:XC,composerPaste:QC,composerPasteRead:ZC,summarizeTurn:eR,shutdownComposer:tR}=kr(Ow)});import*as Vv from"fs/promises";import*as vt from"path";ci();ee();function ru(n){if(!qe.includes(n))throw new Error(`Unknown block kind '${n}' (one of: ${qe.join(", ")})`);return n}function gg(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=ru(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}wo();du();Pd();var Da={claude:{adapter:()=>new Wn,server:()=>Promise.resolve().then(()=>(yw(),gw))},codex:{adapter:()=>new Hn,server:()=>Promise.resolve().then(()=>(vw(),ww))},pi:{adapter:()=>new vr,server:()=>Promise.resolve().then(()=>(Cw(),_w))}};function Rw(n){return n in Da}function Er(){return Object.keys(Da)}function Iw(){return Object.fromEntries(Object.entries(Da).map(([n,e])=>[n,e.adapter]))}function Nw(n){return Da[n].server()}var zs=Iw();function $w(){for(let n of Object.values(zs))try{n().ensureHarnessSupport()}catch{}}function Pn(){for(let n of Object.keys(zs))try{if(zs[n]().detectsSelf())return n}catch{}}function Lw(n){let e=Er(),t=new Map(e.filter(i=>zs[i]).map(i=>[i,zs[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 cf=5e3;function lf(n){try{return n()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function Mw(n){let t={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||Pn()!==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"],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=cf;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=lf(()=>Lf(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"].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==="get"&&(i.length!==2&&(console.error("Usage: typebulb get <file> <kind>"),process.exit(1)),t.file=i[0],t.blockKind=lf(()=>ru(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=lf(()=>gg(i.slice(1)))),t}function Bw(){console.log(`
2062
+ `:"";fw(r,i+`OPENROUTER_API_KEY=${e}
2063
+ `)}}catch(i){return{ok:!1,error:z(i)}}return process.env.OPENROUTER_API_KEY=e,hw(t,[".env"],"# secrets"),{ok:!0}}function M_(){if(!(!Pr&&!ot)){try{bw(G)}catch{}P_()}}function B_(n,e){return vw.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 D_(n){if(vw.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 j_(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=uf(e?.cache_read_input_tokens)||uf(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 F_({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(pf(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:mw(a)}:i),u=await fetch(ff,{method:"POST",signal:l.signal,headers:s,body:f}),d=await u.json().catch(()=>({}));return{r:u,j:d}}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()-t,error:B_(a.status,E),restriction:D_(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",u=uf(l?.usage?.cache_creation_input_tokens),{r:d,j:p}=await o(c),{works:g,read:h,note:y}=j_(d.ok,p?.usage,c);return g===!0&&c&&(hf[n]=c,ot===n&&(On=c)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-t,provider:c,sample:String(f).trim().slice(0,60),cache:{works:g,created:u,read:h,note:y}}}catch(a){let l=z(a);return{ok:!0,callable:!1,ms:Date.now()-t,error:/abort/i.test(l)?"timed out (20s)":l}}}var m_,ff,g_,y_,pw,b_,cf,ja,Fa,Ma,pf,Pr,Pn,ot,On,Vs,zs,Gs,hf,uf,mw,vw,Sw=S(()=>{"use strict";kr();Ht();Dt();m_="https://openrouter.ai/api",ff=`${m_}/v1/messages`,g_="typebulb-proxy-managed",y_="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.",pw=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],b_=5e3,cf=["low","medium","high"],ja=n=>Da(n,".claude","settings.local.json"),Fa=n=>Da(n,".claude",".cc-switcher.json"),Ma=n=>`http://127.0.0.1:${n}`;pf=n=>/^anthropic\//i.test(n)||/claude/i.test(n),Pr=null,Pn=null,ot=null,On=null,Vs=null,zs="unknown",Gs=1,hf={},uf=n=>typeof n=="number"?n:0,mw=n=>({order:[n],allow_fallbacks:!1});vw=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=Vt(Fa(G)),t=e?.active?.model;if(!t)return;let s=(Vt(ja(G))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await ww(t,e.active.provider??hf[t]??null);console.log(`[switcher] re-adopted override after restart: ${t} via ${Ma(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",z(e))}})()});var xw={};ci(xw,{agentMessage:()=>ko,attach:()=>V_,blockToMarkdown:()=>So,breakout:()=>Yd,capText:()=>Ae,cleanUserText:()=>Lt,clearSwitchModel:()=>$_,closeChild:()=>X_,composerPasteRead:()=>Q_,displayName:()=>U_,downloadSample:()=>rf,firstLineDigest:()=>Ne,git:()=>Qe,gitChangedFiles:()=>Bd,gitDiff:()=>Dd,info:()=>q_,isHiddenTurn:()=>gs,launchBulb:()=>Qd,listBreakouts:()=>Vd,listBulbFiles:()=>Gd,listChildren:()=>z_,listMyBulbs:()=>of,listSamples:()=>nf,listSessions:()=>K_,listSwitchModels:()=>__,logInlineStatus:()=>W_,openChild:()=>G_,openFile:()=>Hd,poll:()=>J_,predictTrustOf:()=>Zd,probeModel:()=>F_,pullRemoteBulb:()=>af,pushLocalBulb:()=>lf,readBulbLog:()=>tf,repoRoot:()=>En,saveOpenRouterKey:()=>L_,searchBulbs:()=>Xd,searchSessions:()=>H_,sessionPeek:()=>Y_,setBulbTrust:()=>ef,setReasoning:()=>N_,setSwitchModel:()=>I_,shutdownSwitcher:()=>M_,stopBreakout:()=>zd,summarizeTurn:()=>Z_,switchState:()=>R_,toolResultDigest:()=>gu});var kw,U_,q_,J_,W_,K_,H_,Y_,V_,z_,G_,X_,Q_,Z_,Ew=S(()=>{"use strict";Na();xo();La();Ws();Sw();xo();ms();kw=new Yn,U_=kw.displayName,{info:q_,poll:J_,logInlineStatus:W_,listSessions:K_,searchSessions:H_,sessionPeek:Y_,attach:V_,listChildren:z_,openChild:G_,closeChild:X_,composerPasteRead:Q_,summarizeTurn:Z_}=Tr(kw)});var Tw={};ci(Tw,{attach:()=>aR,breakout:()=>Yd,closeChild:()=>uR,composerPasteRead:()=>dR,displayName:()=>eR,downloadSample:()=>rf,git:()=>Qe,gitChangedFiles:()=>Bd,gitDiff:()=>Dd,info:()=>tR,launchBulb:()=>Qd,listBreakouts:()=>Vd,listBulbFiles:()=>Gd,listChildren:()=>lR,listMyBulbs:()=>of,listSamples:()=>nf,listSessions:()=>sR,logInlineStatus:()=>rR,openChild:()=>cR,openFile:()=>Hd,poll:()=>nR,predictTrustOf:()=>Zd,pullRemoteBulb:()=>af,pushLocalBulb:()=>lf,readBulbLog:()=>tf,repoRoot:()=>En,searchBulbs:()=>Xd,searchSessions:()=>iR,sessionPeek:()=>oR,setBulbTrust:()=>ef,stopBreakout:()=>zd,summarizeTurn:()=>fR});var Aw,eR,tR,nR,rR,sR,iR,oR,aR,lR,cR,uR,dR,fR,Pw=S(()=>{"use strict";Na();wu();La();Ws();Aw=new zn,eR=Aw.displayName,{info:tR,poll:nR,logInlineStatus:rR,listSessions:sR,searchSessions:iR,sessionPeek:oR,attach:aR,listChildren:lR,openChild:cR,closeChild:uR,composerPasteRead:dR,summarizeTurn:fR}=Tr(Aw)});import{readFileSync as pR,writeFileSync as hR,mkdirSync as mR}from"fs";import{homedir as gR}from"os";import*as Ua from"path";async function _w(){try{let n=await fetch(new URL("/api/tags",Cw()).toString(),{signal:AbortSignal.timeout(yR)});return n.ok?((await n.json()).models??[]).map(t=>t.name).filter(t=>!!t):[]}catch{return[]}}function Rw(n){let e;try{e=pR(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&&!mf(r)}}}catch{}return{json:void 0,unreadable:!0}}function mf(n){let e=n?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function bR(n){let e=mf(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 Iw(){let{json:n,unreadable:e}=Rw(Ow());return e?{installed:[],configured:null}:{installed:await _w(),configured:bR(n)}}async function Nw(){let n=await _w();return n.length?wR(Ow(),n,Cw()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function wR(n,e,t){let{json:r,unreadable:s}=Rw(n);if(s)return{ok:!1,error:`could not parse ${n} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...mf(r)??{},ollama:{baseUrl:`${t}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{mR(Ua.dirname(n),{recursive:!0}),hR(n,JSON.stringify(i,null,2)+`
2064
+ `)}catch(o){return{ok:!1,error:`could not write ${n}: ${z(o)}`}}return{ok:!0,count:e.length}}var yR,Ow,Cw,$w=S(()=>{"use strict";Ht();kr();yR=1500,Ow=()=>Ua.join(gR(),".pi","agent","models.json"),Cw=()=>or(process.env.OLLAMA_HOST??"http://localhost:11434")});var Mw={};ci(Mw,{attach:()=>PR,breakout:()=>Yd,closeChild:()=>_R,composerFiles:()=>$R,composerNew:()=>NR,composerPaste:()=>BR,composerPasteRead:()=>DR,composerRpc:()=>MR,composerSend:()=>RR,composerStop:()=>IR,composerUiRespond:()=>LR,displayName:()=>vR,downloadSample:()=>rf,git:()=>Qe,gitChangedFiles:()=>Bd,gitDiff:()=>Dd,info:()=>SR,launchBulb:()=>Qd,listBreakouts:()=>Vd,listBulbFiles:()=>Gd,listChildren:()=>OR,listMyBulbs:()=>of,listSamples:()=>nf,listSessions:()=>ER,logInlineStatus:()=>xR,ollamaOffer:()=>Iw,ollamaSync:()=>Nw,openChild:()=>CR,openFile:()=>Hd,poll:()=>kR,predictTrustOf:()=>Zd,pullRemoteBulb:()=>af,pushLocalBulb:()=>lf,readBulbLog:()=>tf,repoRoot:()=>En,searchBulbs:()=>Xd,searchSessions:()=>AR,sessionPeek:()=>TR,setBulbTrust:()=>ef,shutdownComposer:()=>FR,stopBreakout:()=>zd,summarizeTurn:()=>jR});var Lw,vR,SR,kR,xR,ER,AR,TR,PR,OR,CR,_R,RR,IR,NR,$R,LR,MR,BR,DR,jR,FR,Bw=S(()=>{"use strict";Na();Ld();La();Ws();$w();Lw=new Er,vR=Lw.displayName,{info:SR,poll:kR,logInlineStatus:xR,listSessions:ER,searchSessions:AR,sessionPeek:TR,attach:PR,listChildren:OR,openChild:CR,closeChild:_R,composerSend:RR,composerStop:IR,composerNew:NR,composerFiles:$R,composerUiRespond:LR,composerRpc:MR,composerPaste:BR,composerPasteRead:DR,summarizeTurn:jR,shutdownComposer:FR}=Tr(Lw)});import*as rS from"fs/promises";import*as kt from"path";ui();ee();function lu(n){if(!Je.includes(n))throw new Error(`Unknown block kind '${n}' (one of: ${Je.join(", ")})`);return n}function Ag(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=lu(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}xo();wu();Ld();var qa={claude:{adapter:()=>new Yn,server:()=>Promise.resolve().then(()=>(Ew(),xw))},codex:{adapter:()=>new zn,server:()=>Promise.resolve().then(()=>(Pw(),Tw))},pi:{adapter:()=>new Er,server:()=>Promise.resolve().then(()=>(Bw(),Mw))}};function Dw(n){return n in qa}function Or(){return Object.keys(qa)}function jw(){return Object.fromEntries(Object.entries(qa).map(([n,e])=>[n,e.adapter]))}function Fw(n){return qa[n].server()}var Xs=jw();function Uw(){for(let n of Object.values(Xs))try{n().ensureHarnessSupport()}catch{}}function Cn(){for(let n of Object.keys(Xs))try{if(Xs[n]().detectsSelf())return n}catch{}}function qw(n){let e=Or(),t=new Map(e.filter(i=>Xs[i]).map(i=>[i,Xs[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 yf=5e3;function gf(n){try{return n()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function Jw(n){let t={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||Cn()!==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"],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=yf;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=gf(()=>Wf(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"].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==="get"&&(i.length!==2&&(console.error("Usage: typebulb get <file> <kind>"),process.exit(1)),t.file=i[0],t.blockKind=gf(()=>lu(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=gf(()=>Ag(i.slice(1)))),t}function Ww(){console.log(`
2061
2065
  typebulb - Local bulb runner for Typebulb
2062
2066
 
2063
2067
  Usage:
@@ -2230,7 +2234,7 @@ Examples:
2230
2234
  typebulb my-editor.bulb.md
2231
2235
  typebulb --no-watch my-editor.bulb.md
2232
2236
  typebulb .
2233
- `)}yt();vs();ci();xs();yt();import*as Fe from"path";import{spawn as _R,execSync as CR}from"child_process";import{createRequire as RR}from"module";import{existsSync as IR}from"fs";import*as ge from"fs/promises";import*as he from"path";var uf=[{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"}],df=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function ff(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 nR=`
2237
+ `)}wt();ks();ui();As();wt();import*as Ue from"path";import{spawn as hI,execSync as mI}from"child_process";import{createRequire as gI}from"module";import{existsSync as yI}from"fs";import*as ge from"fs/promises";import*as he from"path";var bf=[{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"}],wf=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function vf(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 UR=`
2234
2238
  /**
2235
2239
  * Get raw data chunk from the Data tab.
2236
2240
  * @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
@@ -2241,7 +2245,7 @@ Examples:
2241
2245
  * @param index - Chunk index (0-based)
2242
2246
  * @throws If chunk is not valid JSON/JSON-ish
2243
2247
  */
2244
- json<T = unknown>(index: number): T;`,rR=`
2248
+ json<T = unknown>(index: number): T;`,qR=`
2245
2249
  /**
2246
2250
  * Get the insight data produced by the inference layer.
2247
2251
  *
@@ -2250,7 +2254,7 @@ Examples:
2250
2254
  *
2251
2255
  * @returns The parsed insight JSON, or undefined if no insight is available
2252
2256
  */
2253
- insight<T = unknown>(): T | undefined;`,sR=`
2257
+ insight<T = unknown>(): T | undefined;`,JR=`
2254
2258
  /**
2255
2259
  * Replace the data this run is working on.
2256
2260
  *
@@ -2273,7 +2277,7 @@ Examples:
2273
2277
  *
2274
2278
  * @param value - Any JSON-serializable value
2275
2279
  */
2276
- setInsight(value: unknown): Promise<void>;`,Dw=`options: {
2280
+ setInsight(value: unknown): Promise<void>;`,Kw=`options: {
2277
2281
  messages: Array<{ role: "user" | "assistant"; content: string }>;
2278
2282
  system?: string;
2279
2283
  /** 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. */
@@ -2284,7 +2288,7 @@ Examples:
2284
2288
  webSearch?: boolean;
2285
2289
  /** Abort the request. On abort the promise rejects / the stream ends. */
2286
2290
  signal?: AbortSignal;
2287
- }`,jw=`
2291
+ }`,Hw=`
2288
2292
  /** Provider-reported token counts for one call \u2014 real usage from the API, never an estimate.
2289
2293
  * \`output\` is total billed output (reasoning included); \`reasoning\` is the itemized subset where
2290
2294
  * the provider splits it (OpenAI, Gemini, OpenRouter \u2014 Anthropic doesn't); \`cacheRead\` is the
@@ -2296,10 +2300,10 @@ type AiChunk =
2296
2300
  | { kind: "text"; text: string }
2297
2301
  | { kind: "reasoning"; text: string }
2298
2302
  | { kind: "usage"; usage: AiUsage };
2299
- `,Fw=`
2303
+ `,Yw=`
2300
2304
  /** What backs \`tb.ai\`: the user's own keys, the quota-limited courtesy model, or nothing. */
2301
2305
  type AiAccess = "own" | "courtesy" | "none";
2302
- `,Uw=`
2306
+ `,Vw=`
2303
2307
  /**
2304
2308
  * General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
2305
2309
  * returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
@@ -2309,7 +2313,7 @@ type AiAccess = "own" | "courtesy" | "none";
2309
2313
  * @throws On rate limit, network error, or provider error
2310
2314
  */
2311
2315
  ai: {
2312
- (${Dw}): Promise<{ text: string; usage?: AiUsage }>;
2316
+ (${Kw}): Promise<{ text: string; usage?: AiUsage }>;
2313
2317
  /**
2314
2318
  * Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
2315
2319
  * as they arrive, then one final \`{ kind: "usage", usage }\` chunk with the call's token
@@ -2326,8 +2330,8 @@ type AiAccess = "own" | "courtesy" | "none";
2326
2330
  * if (c.kind === "text") answer += c.text;
2327
2331
  * }
2328
2332
  */
2329
- stream(${Dw}): AsyncIterable<AiChunk>;
2330
- };`,qw=`
2333
+ stream(${Kw}): AsyncIterable<AiChunk>;
2334
+ };`,zw=`
2331
2335
  /**
2332
2336
  * Returns AI models available to the current user.
2333
2337
  * Models are filtered by the user's configured API keys.
@@ -2357,7 +2361,7 @@ type AiAccess = "own" | "courtesy" | "none";
2357
2361
  * \`tb.mode\` or the length of \`tb.models()\` \u2014 which hosts offer a courtesy
2358
2362
  * model is the host's business and changes without your bulb changing.
2359
2363
  */
2360
- aiAccess(): Promise<AiAccess>;`,iR="\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;",Jw=`
2364
+ aiAccess(): Promise<AiAccess>;`,WR="\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;",Gw=`
2361
2365
  /**
2362
2366
  * The mode this bulb is running in.
2363
2367
  *
@@ -2367,7 +2371,7 @@ type AiAccess = "own" | "courtesy" | "none";
2367
2371
  * - \`'inline'\` \u2014 Running inline in an agent's transcript, rendered by the mirror
2368
2372
  * (sandboxed, client-only: AI, filesystem, and server RPC are unavailable)
2369
2373
  */
2370
- mode: ${cg};`,Ww=`
2374
+ mode: ${bg};`,Xw=`
2371
2375
  /**
2372
2376
  * Local filesystem access (CLI only).
2373
2377
  *
@@ -2388,7 +2392,7 @@ type AiAccess = "own" | "courtesy" | "none";
2388
2392
  list(path?: string): Promise<Array<{ name: string; dir: boolean; mtime: number }>>;
2389
2393
  /** 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. */
2390
2394
  remove(path: string): Promise<boolean>;
2391
- };`,Kw=`
2395
+ };`,Qw=`
2392
2396
  /**
2393
2397
  * The bulb's folder \u2014 absolute path to \`<bulb-dir>/<filename-stem>/\`
2394
2398
  *
@@ -2396,7 +2400,7 @@ type AiAccess = "own" | "courtesy" | "none";
2396
2400
  * \`tb.fs\` already resolves relative paths against it, so bulb code writing
2397
2401
  * its own files never needs it. CLI only \u2014 throws in ide/published/inline mode.
2398
2402
  */
2399
- readonly dir: string;`,oR=`
2403
+ readonly dir: string;`,KR=`
2400
2404
  /**
2401
2405
  * Async value inspector for tensor-like objects.
2402
2406
  *
@@ -2449,47 +2453,47 @@ type AiAccess = "own" | "courtesy" | "none";
2449
2453
  *
2450
2454
  * @returns The full canonical URL
2451
2455
  */
2452
- url(): Promise<string>;`,aR="\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;",lR="\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;",cR="\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>>;",pf=`${jw}${Fw}
2456
+ url(): Promise<string>;`,HR="\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;",YR="\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;",VR="\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>>;",Sf=`${Hw}${Yw}
2453
2457
  /**
2454
2458
  * Typebulb utilities namespace.
2455
2459
  * Type \`tb.\` to discover available helpers.
2456
2460
  */
2457
- declare const tb: {${nR}${oR}${rR}${sR}${lR}${cR}${aR}${Uw}${Ww}${Kw}${qw}${iR}${Jw}
2461
+ declare const tb: {${UR}${KR}${qR}${JR}${YR}${VR}${HR}${Vw}${Xw}${Qw}${zw}${WR}${Gw}
2458
2462
  };
2459
- `,uR=`
2463
+ `,zR=`
2460
2464
  /**
2461
2465
  * Print to the CLI's stdout \u2014 the same channel as \`console.log\` here (the server's console IS
2462
2466
  * the bulb's log). One log verb across blocks: page-side \`tb.log\` reaches this same stdout.
2463
2467
  */
2464
- log(...args: any[]): void;`,hf=`${jw}${Fw}
2468
+ log(...args: any[]): void;`,kf=`${Hw}${Yw}
2465
2469
  /**
2466
2470
  * Typebulb utilities namespace (server-side).
2467
2471
  * Type \`tb.\` to discover available helpers.
2468
2472
  */
2469
- declare const tb: {${uR}${Uw}${Ww}${Kw}${qw}${Jw}
2473
+ declare const tb: {${zR}${Vw}${Xw}${Qw}${zw}${Gw}
2470
2474
  };
2471
- `;pt();import hR from"p-limit";pt();import{resolve as Yw}from"resolve.exports";var bt={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},Gs=["index.d.ts","index.d.mts"],mf=/\.d\.(ts|mts|cts)$/i;function ja(n){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(n)||/[?&]dts(?:[&#]|$)/i.test(n)}function Hw(n){return[`${n}.d.ts`,`${n}.d.mts`]}function Yt(n){if(!n||n==="./"||n==="/")return[...Gs];let e=n.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),t=Hw(e),r=e.endsWith("/")?e:`${e}/`;return t.push(...Hw(`${r}index`)),t}async function Ar(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(dR(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function dR(n){return n===408||n===429||n>=500&&n<600}var Fa=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)||ja(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 D({name:e,version:t})),s=await Ar(r);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new D({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=yn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...Gs],t);if(!mf.test(o)){let a=await this.tryUntilSuccess(Yt(o),t);if(a)return a}return t(o)}let s=Yt(e.path),i=r?.subpath?[...s,...Gs]:[...Gs,...s];return this.tryUntilSuccess(i,t)}toResolutionResult(e){return{kind:mf.test(e)?"types":"probe",path:e}}resolveExportsPath(e,t){let r=t||".",s=e;try{let i=this.extractPathFromResult(Yw(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(Yw(s,r,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let t=D.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 D(i).format(),a=new D({...i,subpath:t.subpath}).format(),l=u=>this.fetchCandidateFrom(s,t.name,u);if(t.subpath){let u=nd(t.subpath),d=this.resolveExportsPath(r,u);if(d){let m=await this.resolveFromSelected(this.toResolutionResult(d),l,{subpath:!0});if(m)return{...m,resolvedPkg:a}}let p=await this.tryUntilSuccess(Yt(u),l);if(p)return{...p,resolvedPkg:a}}let c=r.types??r.typings;if(c){let u=await this.resolveFromSelected({kind:"types",path:c},l);if(u)return{...u,resolvedPkg:o}}let f=this.resolveExportsPath(r,".");if(f){let u=await this.resolveFromSelected(this.toResolutionResult(f),l);if(u)return{...u,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,t,r){let s=yn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:t}:void 0}};pt();import{gunzipSync as fR}from"fflate";var Ua=class{async fetchAndExtract(e,t){let r=this.getTarballUrl(e,t),s=await Ar(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=fR(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),u=s.decode(f).trim().replace(/\0/g,""),d=parseInt(u,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+d);t.set(this.normalizeTarPath(c),s.decode(m))}i+=Math.ceil(d/512)*512}}catch{}return t}};var qa=class{constructor(e,t,r=new Ua){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=bn.majorOf(r),o=e.filter(a=>bn.majorOf(a)===i);if(o.length)return o.sort((a,l)=>bn.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=Yt(e);return t!==e&&r.push(`${e}.d.ts`,`${e}/index.d.ts`),r}async fetchFromVersionedRoot(e,t){let r=new D(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 D(t).format():t.name}}}async resolve(e){let t=D.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 Ja=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(`
2475
+ `;mt();import ZR from"p-limit";mt();import{resolve as ev}from"resolve.exports";var vt={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},Qs=["index.d.ts","index.d.mts"],xf=/\.d\.(ts|mts|cts)$/i;function Ja(n){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(n)||/[?&]dts(?:[&#]|$)/i.test(n)}function Zw(n){return[`${n}.d.ts`,`${n}.d.mts`]}function zt(n){if(!n||n==="./"||n==="/")return[...Qs];let e=n.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),t=Zw(e),r=e.endsWith("/")?e:`${e}/`;return t.push(...Zw(`${r}index`)),t}async function Cr(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(GR(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function GR(n){return n===408||n===429||n>=500&&n<600}var Wa=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)||Ja(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 F({name:e,version:t})),s=await Cr(r);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new F({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=wn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...Qs],t);if(!xf.test(o)){let a=await this.tryUntilSuccess(zt(o),t);if(a)return a}return t(o)}let s=zt(e.path),i=r?.subpath?[...s,...Qs]:[...Qs,...s];return this.tryUntilSuccess(i,t)}toResolutionResult(e){return{kind:xf.test(e)?"types":"probe",path:e}}resolveExportsPath(e,t){let r=t||".",s=e;try{let i=this.extractPathFromResult(ev(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(ev(s,r,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let t=F.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 F(i).format(),a=new F({...i,subpath:t.subpath}).format(),l=u=>this.fetchCandidateFrom(s,t.name,u);if(t.subpath){let u=ud(t.subpath),d=this.resolveExportsPath(r,u);if(d){let g=await this.resolveFromSelected(this.toResolutionResult(d),l,{subpath:!0});if(g)return{...g,resolvedPkg:a}}let p=await this.tryUntilSuccess(zt(u),l);if(p)return{...p,resolvedPkg:a}}let c=r.types??r.typings;if(c){let u=await this.resolveFromSelected({kind:"types",path:c},l);if(u)return{...u,resolvedPkg:o}}let f=this.resolveExportsPath(r,".");if(f){let u=await this.resolveFromSelected(this.toResolutionResult(f),l);if(u)return{...u,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,t,r){let s=wn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:t}:void 0}};mt();import{gunzipSync as XR}from"fflate";var Ka=class{async fetchAndExtract(e,t){let r=this.getTarballUrl(e,t),s=await Cr(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=XR(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),u=s.decode(f).trim().replace(/\0/g,""),d=parseInt(u,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(c.endsWith(".d.ts")||c.endsWith(".d.mts"))){let g=r.slice(i,i+d);t.set(this.normalizeTarPath(c),s.decode(g))}i+=Math.ceil(d/512)*512}}catch{}return t}};var Ha=class{constructor(e,t,r=new Ka){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=vn.majorOf(r),o=e.filter(a=>vn.majorOf(a)===i);if(o.length)return o.sort((a,l)=>vn.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=zt(e);return t!==e&&r.push(`${e}.d.ts`,`${e}/index.d.ts`),r}async fetchFromVersionedRoot(e,t){let r=new F(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 F(t).format():t.name}}}async resolve(e){let t=F.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 Ya=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(`
2472
2476
  `).filter(s=>{let i=s.trimStart();return!(i.startsWith("*")||i.startsWith("//")||i.startsWith("/*"))}).join(`
2473
- `),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://"))}};pt();var Vw="file:///node_modules",Wa=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${Vw}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,t){let r=yn(t);return`${Vw}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as pR}from"lru-cache";function zw(n){let e=new pR({ttl:bt.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 Ar(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 Xs=class{constructor(e){this.inFlight=new Map,this.scanner=new Ja,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=zw(e.cache),this.typescriptProvider=new Fa(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new qa(e.cdnClient,e.cache),this.virtualFs=new Wa}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 D(r).subpath===new D(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>bt.maxRelativeTypeRefs)))try{let a=new URL(t),l=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let c=this.scanner.collectRelativeTypeRefs(e).slice(0,bt.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=ja(l)?[l]:Yt(l);for(let f of c){let d=new URL(f,a).toString();if(o.has(d))return;let p=await this.fetchDts(d);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 D(e).name!==new D(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,bt.maxBareDeps).filter(c=>this.isDifferentPackage(c,t));if(!o.length)return;let a=new Set([t]),l=hR(bt.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,bt.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,bt.maxBareDeps).filter(u=>!i.has(u));for(let u of f)await this.prefetchBareDepsRecursive(u,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 D(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 D(a||r),c=l.version?`${l.name}@${l.version}`:l.name,{mainPath:f,packageRootUrl:u}=this.computeEntryPath(o,c),d=[{path:f,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,c,d,void 0,u);let m=d.map(T=>T.content).join(`
2474
- `);await this.prefetchBareDeps(m,c,d,p,s);let h=l.format(),b=e===h?[e]:[e,h],E=b.some(T=>this.ambientlyDeclares(i,T));return E?this.markFileAmbient(d,f):p.push(...b.map(T=>({module:T,path:f}))),{pkg:e,mainPath:f,files:d,shims:p,ambient:E}}};fd();pt();fr();Bs();ud();dr();import*as Tr from"path";var mR=Tr.join(Xo,"pkg"),gR=Tr.join(Xo,"files"),yR=Tr.join(Xo,"negative.json"),Ha=class{pkgMem=new Map;fileMem=new Map;negativeCache=new wn(new pr(yR));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await te();let t=await ht(Gw(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 Ka(async()=>{await te(),await Me(Gw(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await te();let t=await Go(Xw(e));return this.fileMem.set(e,t),t}async setCachedFile(e,t){this.fileMem.set(e,t),await Ka(async()=>{await te(),await Me(Xw(e),t)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await Ka(async()=>{await te(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return Ka(()=>this.negativeCache.clearNegative(e))}};async function Ka(n){try{await n()}catch{}}function Gw(n){return Tr.join(mR,Ve(n)+".json")}function Xw(n){return Tr.join(gR,Ve(n)+".txt")}fr();var gf;function bR(){return gf||(gf=new Xs({cache:new Ha,cdnClient:Xy,packageService:ta,versionResolver:Gy})),gf}var Qw="file:///node_modules/";async function Zw(n){let e=Qo(n.emitKey,"typecheck");await te(),await ge.rm(e,{recursive:!0,force:!0}),await ge.mkdir(e,{recursive:!0});let t=kR(n.jsxImportSource,n.dependencies),r=await bR().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 u of f.files){let d=Ya(u.path);if(!d||o.has(d))continue;o.add(d);let p=he.join(e,"node_modules",d);await ge.mkdir(he.dirname(p),{recursive:!0}),await ge.writeFile(p,u.content,"utf8")}let a={};for(let f of i)for(let u of f.shims){let d=Ya(u.path);d&&(a[u.module]=[`./node_modules/${d}`])}for(let f of i){if(f.ambient)continue;let u=Ya(f.mainPath);u&&(a[f.pkg]=[`./node_modules/${u}`])}let l=new Set;for(let f of i)for(let u of f.files){if(!u.ambient)continue;let d=Ya(u.path);d&&l.add(`node_modules/${d}`)}if(n.local){delete a[n.local.name];let f=await xR(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=wR(n.jsxImportSource,a,[...l]);return await ge.writeFile(he.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
2475
- `,"utf8"),await ge.writeFile(he.join(e,"code.tsx"),n.code,"utf8"),await ge.writeFile(he.join(e,"tb.d.ts"),pf,"utf8"),{dir:e}}var yf={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function wR(n,e,t=[]){return{compilerOptions:{...yf,lib:vR([...uf,...df]),jsx:"react-jsx",jsxImportSource:n??"react",paths:e},include:["code.tsx","tb.d.ts",...t]}}function vR(n){return ff(n).map(e=>SR(e.name))}function SR(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 kR(n,e){let t=n??("react"in e?"react":void 0);return t?[`${t}/jsx-runtime`,`${t}/jsx-dev-runtime`]:[]}function Ya(n){if(!n.startsWith(Qw))return;let e=n.slice(Qw.length),t=e.indexOf("/");if(!(t<0))return e.slice(t+1)}async function xR(n,e){if(!n.typesAbs)return;let t=he.dirname(n.typesAbs),r=he.join(e,"node_modules",n.name);for(let s of await ER(t)){let i=he.join(r,he.relative(t,s));await ge.mkdir(he.dirname(i),{recursive:!0}),await ge.copyFile(s,i)}return he.basename(n.typesAbs)}async function ER(n){let e=[];async function t(r){let s=await ge.readdir(r,{withFileTypes:!0});for(let i of s){let o=he.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 wt from"path";import{existsSync as AR}from"fs";fr();hd();var TR="^22";async function ev(n){let e=Qo(n.emitKey,"typecheck-server");await te(),await je.rm(e,{recursive:!0,force:!0}),await je.mkdir(e,{recursive:!0});let t=wt.join(n.bulbDir,".typebulb"),r=la(n.server).filter(o=>o!==n.local?.name);await aa([`@types/node@${TR}`,...r],t,n.dependencies,{ignoreScripts:!0});let s=wt.join(t,"node_modules"),i=wt.join(e,"node_modules");return await OR(s,i),await je.writeFile(wt.join(e,"server.ts"),n.server,"utf8"),await je.writeFile(wt.join(e,"tb.d.ts"),hf,"utf8"),await je.writeFile(wt.join(e,"tsconfig.json"),JSON.stringify(PR(n.local),null,2)+`
2476
- `,"utf8"),{dir:e}}function PR(n){let e={...yf,lib:["ES2023"],types:["node"]};if(n?.typesAbs){let t=i=>i.replace(/\\/g,"/"),r=t(wt.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 OR(n,e){if(!AR(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)}Mo();ee();async function nv(n,e){let{bulb:t,config:r,warnings:s,starts:i}=await Ge(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=gr(Fe.resolve(n)),u=f?qn(t.name):"";f&&u&&u!==f.slug&&(console.log(`naming filename '${f.slug}.bulb.md' doesn't match the title '${t.name}' \u2014 its slug derives to '${u}'. Rename the file to '${u}.bulb.md', or change name: to suit the filename.`),c=!0),t.code&&(l=tv(Ss(t.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),t.server&&(l=tv(Ss(t.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let d=MR([process.cwd(),Fe.dirname(n)]);if(!d){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 Zw({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 ev({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:b}of p){let{stdout:E,exitCode:T}=await $R(d,b);for(let P of E.split(/\r?\n/))P.trim()&&console.log(`${h} ${NR(P,o,a)}`);T!==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 tv(n,e){for(let t of n)for(let r of t.message.split(`
2477
- `))console.log(`${e} ${r}`);return n.length>0}function NR(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 $R(n,e){return new Promise(t=>{let r=_R(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 LR=RR(import.meta.url);function MR(n){let e=r=>{try{let s=LR.resolve("typescript/package.json",{paths:r}),i=Fe.join(Fe.dirname(s),"lib","tsc.js");return IR(i)?i:void 0}catch{return}},t=e(n);if(t)return t;try{let r=CR("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}yt();Lo();xs();async function rv(n,e){let{bulb:t}=await Ge(n),r=er(t);if(fn(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.)")}xs();import*as Qs from"path";async function sv(n,e){if(!n){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=Lu();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=Qs.resolve(n);t.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{tr(t,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${Qs.basename(t)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${Qs.basename(t)} \u2014 runs Restricted.`),console.log(` ${t}`)}Ne();import*as av from"readline";Zu();function bf(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 BR=5e3,Va=()=>Math.round(performance.now()),iv=n=>n>=1e3?`${(n/1e3).toFixed(1)}s`:`${n}ms`;async function lv(n){let e=Lw(process.cwd()),t=Va();if("ambiguous"in e){let r=await DR(n,e.ambiguous);return r?ov(n,r,{boot:t,from:Va()}):jR(n,e.ambiguous)}return ov(n,e.name,{boot:t,from:Va()})}async function ov(n,e,t){let r,s;try{r=await Tu(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=Va()-t.from,{lit:o,litLink:a,brand:l}=bf(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(Ps())}`],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],u=t.boot+i>BR?[` slow launch: boot ${iv(t.boot)} \xB7 mirror ${iv(i)}`]:[],d=[` ${l(`typebulb v${n}`)}`,...u,...f,""];process.stdout.write(d.join(`
2477
+ `),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://"))}};mt();var tv="file:///node_modules",Va=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${tv}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,t){let r=wn(t);return`${tv}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as QR}from"lru-cache";function nv(n){let e=new QR({ttl:vt.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 Cr(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 Zs=class{constructor(e){this.inFlight=new Map,this.scanner=new Ya,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=nv(e.cache),this.typescriptProvider=new Wa(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new Ha(e.cdnClient,e.cache),this.virtualFs=new Va}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 F(r).subpath===new F(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>vt.maxRelativeTypeRefs)))try{let a=new URL(t),l=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let c=this.scanner.collectRelativeTypeRefs(e).slice(0,vt.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=Ja(l)?[l]:zt(l);for(let f of c){let d=new URL(f,a).toString();if(o.has(d))return;let p=await this.fetchDts(d);if(p?.dts){let g=this.toVirtualPath(r,new URL(p.url),s);this.pushFileIfNew(i,g,p.dts),await this.expandRelativeRefs(p.dts,p.url,s,i,o,r);return}}}catch{}}isDifferentPackage(e,t){return e===t?!1:new F(e).name!==new F(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,vt.maxBareDeps).filter(c=>this.isDifferentPackage(c,t));if(!o.length)return;let a=new Set([t]),l=ZR(vt.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,vt.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,vt.maxBareDeps).filter(u=>!i.has(u));for(let u of f)await this.prefetchBareDepsRecursive(u,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 F(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 F(a||r),c=l.version?`${l.name}@${l.version}`:l.name,{mainPath:f,packageRootUrl:u}=this.computeEntryPath(o,c),d=[{path:f,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,c,d,void 0,u);let g=d.map(P=>P.content).join(`
2478
+ `);await this.prefetchBareDeps(g,c,d,p,s);let h=l.format(),y=e===h?[e]:[e,h],E=y.some(P=>this.ambientlyDeclares(i,P));return E?this.markFileAmbient(d,f):p.push(...y.map(P=>({module:P,path:f}))),{pkg:e,mainPath:f,files:d,shims:p,ambient:E}}};vd();mt();mr();js();bd();hr();import*as _r from"path";var eI=_r.join(ta,"pkg"),tI=_r.join(ta,"files"),nI=_r.join(ta,"negative.json"),Ga=class{pkgMem=new Map;fileMem=new Map;negativeCache=new Sn(new gr(nI));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await ne();let t=await gt(rv(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 za(async()=>{await ne(),await Be(rv(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await ne();let t=await ea(sv(e));return this.fileMem.set(e,t),t}async setCachedFile(e,t){this.fileMem.set(e,t),await za(async()=>{await ne(),await Be(sv(e),t)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await za(async()=>{await ne(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return za(()=>this.negativeCache.clearNegative(e))}};async function za(n){try{await n()}catch{}}function rv(n){return _r.join(eI,ze(n)+".json")}function sv(n){return _r.join(tI,ze(n)+".txt")}mr();var Ef;function rI(){return Ef||(Ef=new Zs({cache:new Ga,cdnClient:ib,packageService:ia,versionResolver:sb})),Ef}var iv="file:///node_modules/";async function ov(n){let e=na(n.emitKey,"typecheck");await ne(),await ge.rm(e,{recursive:!0,force:!0}),await ge.mkdir(e,{recursive:!0});let t=aI(n.jsxImportSource,n.dependencies),r=await rI().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 u of f.files){let d=Xa(u.path);if(!d||o.has(d))continue;o.add(d);let p=he.join(e,"node_modules",d);await ge.mkdir(he.dirname(p),{recursive:!0}),await ge.writeFile(p,u.content,"utf8")}let a={};for(let f of i)for(let u of f.shims){let d=Xa(u.path);d&&(a[u.module]=[`./node_modules/${d}`])}for(let f of i){if(f.ambient)continue;let u=Xa(f.mainPath);u&&(a[f.pkg]=[`./node_modules/${u}`])}let l=new Set;for(let f of i)for(let u of f.files){if(!u.ambient)continue;let d=Xa(u.path);d&&l.add(`node_modules/${d}`)}if(n.local){delete a[n.local.name];let f=await lI(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=sI(n.jsxImportSource,a,[...l]);return await ge.writeFile(he.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
2479
+ `,"utf8"),await ge.writeFile(he.join(e,"code.tsx"),n.code,"utf8"),await ge.writeFile(he.join(e,"tb.d.ts"),Sf,"utf8"),{dir:e}}var Af={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function sI(n,e,t=[]){return{compilerOptions:{...Af,lib:iI([...bf,...wf]),jsx:"react-jsx",jsxImportSource:n??"react",paths:e},include:["code.tsx","tb.d.ts",...t]}}function iI(n){return vf(n).map(e=>oI(e.name))}function oI(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 aI(n,e){let t=n??("react"in e?"react":void 0);return t?[`${t}/jsx-runtime`,`${t}/jsx-dev-runtime`]:[]}function Xa(n){if(!n.startsWith(iv))return;let e=n.slice(iv.length),t=e.indexOf("/");if(!(t<0))return e.slice(t+1)}async function lI(n,e){if(!n.typesAbs)return;let t=he.dirname(n.typesAbs),r=he.join(e,"node_modules",n.name);for(let s of await cI(t)){let i=he.join(r,he.relative(t,s));await ge.mkdir(he.dirname(i),{recursive:!0}),await ge.copyFile(s,i)}return he.basename(n.typesAbs)}async function cI(n){let e=[];async function t(r){let s=await ge.readdir(r,{withFileTypes:!0});for(let i of s){let o=he.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 Fe from"fs/promises";import*as St from"path";import{existsSync as uI}from"fs";mr();kd();var dI="^22";async function av(n){let e=na(n.emitKey,"typecheck-server");await ne(),await Fe.rm(e,{recursive:!0,force:!0}),await Fe.mkdir(e,{recursive:!0});let t=St.join(n.bulbDir,".typebulb"),r=fa(n.server).filter(o=>o!==n.local?.name);await da([`@types/node@${dI}`,...r],t,n.dependencies,{ignoreScripts:!0});let s=St.join(t,"node_modules"),i=St.join(e,"node_modules");return await pI(s,i),await Fe.writeFile(St.join(e,"server.ts"),n.server,"utf8"),await Fe.writeFile(St.join(e,"tb.d.ts"),kf,"utf8"),await Fe.writeFile(St.join(e,"tsconfig.json"),JSON.stringify(fI(n.local),null,2)+`
2480
+ `,"utf8"),{dir:e}}function fI(n){let e={...Af,lib:["ES2023"],types:["node"]};if(n?.typesAbs){let t=i=>i.replace(/\\/g,"/"),r=t(St.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 pI(n,e){if(!uI(n)){await Fe.mkdir(e,{recursive:!0});return}await Fe.rm(e,{recursive:!0,force:!0});let t=process.platform==="win32"?"junction":"dir";await Fe.symlink(n,e,t)}Fo();ee();async function cv(n,e){let{bulb:t,config:r,warnings:s,starts:i}=await Xe(n),o=Ue.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=vr(Ue.resolve(n)),u=f?Kn(t.name):"";f&&u&&u!==f.slug&&(console.log(`naming filename '${f.slug}.bulb.md' doesn't match the title '${t.name}' \u2014 its slug derives to '${u}'. Rename the file to '${u}.bulb.md', or change name: to suit the filename.`),c=!0),t.code&&(l=lv(xs(t.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),t.server&&(l=lv(xs(t.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let d=SI([process.cwd(),Ue.dirname(n)]);if(!d){let h=Ue.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 ov({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 av({server:t.server,bulbDir:Ue.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:E,exitCode:P}=await wI(d,y);for(let O of E.split(/\r?\n/))O.trim()&&console.log(`${h} ${bI(O,o,a)}`);P!==0&&(l=!0)}l&&process.exit(1);let g=[t.code&&"code.tsx",t.server&&"server.ts"].filter(Boolean).join(", ");console.error(c?`\u2713 type-checks (${g}) \u2014 see the naming warning above`:`\u2713 no issues (${g})`)}function lv(n,e){for(let t of n)for(let r of t.message.split(`
2481
+ `))console.log(`${e} ${r}`);return n.length>0}function bI(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 wI(n,e){return new Promise(t=>{let r=hI(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 vI=gI(import.meta.url);function SI(n){let e=r=>{try{let s=vI.resolve("typescript/package.json",{paths:r}),i=Ue.join(Ue.dirname(s),"lib","tsc.js");return yI(i)?i:void 0}catch{return}},t=e(n);if(t)return t;try{let r=mI("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}wt();jo();As();async function uv(n,e){let{bulb:t}=await Xe(n),r=rr(t);if(hn(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.)")}As();import*as ei from"path";async function dv(n,e){if(!n){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=Ju();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=ei.resolve(n);t.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{sr(t,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${ei.basename(t)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${ei.basename(t)} \u2014 runs Restricted.`),console.log(` ${t}`)}$e();import*as hv from"readline";ad();function Tf(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 kI=5e3,Qa=()=>Math.round(performance.now()),fv=n=>n>=1e3?`${(n/1e3).toFixed(1)}s`:`${n}ms`;async function mv(n){let e=qw(process.cwd()),t=Qa();if("ambiguous"in e){let r=await xI(n,e.ambiguous);return r?pv(n,r,{boot:t,from:Qa()}):EI(n,e.ambiguous)}return pv(n,e.name,{boot:t,from:Qa()})}async function pv(n,e,t){let r,s;try{r=await $u(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=Qa()-t.from,{lit:o,litLink:a,brand:l}=Tf(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(Cs())}`],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],u=t.boot+i>kI?[` slow launch: boot ${fv(t.boot)} \xB7 mirror ${fv(i)}`]:[],d=[` ${l(`typebulb v${n}`)}`,...u,...f,""];process.stdout.write(d.join(`
2478
2482
  `)+`
2479
- `)}async function DR(n,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:t,brand:r}=bf(!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(`
2483
+ `)}async function xI(n,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:t,brand:r}=Tf(!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(`
2480
2484
  `)+`
2481
- `);let i=av.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 jR(n,e){let{lit:t,brand:r}=bf(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(`
2485
+ `);let i=hv.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 EI(n,e){let{lit:t,brand:r}=Tf(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(`
2482
2486
  `)+`
2483
- `)}dt();pn();async function cv(n){Le(n);let e=await ut();if(e.length>0){console.log(gy(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!Bu()){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(nr))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 uv(n){n?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=qn(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)}tt();import*as pv from"path";import{valid as fv,lt as UR}from"semver";Ne();var Qe={connected:"[page] connected",disconnected:"[page] disconnected",closed:n=>`[page] closed: ${n}`},wf=3e3,dv=1e4,FR=2500,za=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?.()},wf).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,FR);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()}};Po();function qR(n,e,t,r){if(/^\d+$/.test(e))return n.find(i=>i.pid===parseInt(e,10));let s=e==="agent"?n.filter(me):n.filter(i=>i.agent===e);if(s.length){if(!t)return s[0];let i=s.filter(o=>Xn(o,t));return r&&i.find(o=>o.agent===r)||i[0]}return n.find(i=>re(i.file)===re(e))}var Pr=n=>n.agent??pv.basename(n.file);function hv(n){return n===$e?!1:n&&fv(n)&&fv($e)?UR(n,$e):!0}function JR(n){return n===$e?"":n?hv(n)?` STALE runtime v${n} (this CLI is v${$e} \u2014 relaunch to update)`:` runtime v${n} (newer than this CLI's v${$e})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function WR(n,e){return e===void 0?" pages ?":e>0?` ${e} page${e===1?"":"s"}`:me(n)?" NO PAGE (no tab open on it)":" NO PAGE (nothing of it is running)"}function mv(n,e,t){n.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${t?WR(r,t[s]):""}${JR(r.version)} ${r.file}`))}async function vf(n,e){if(!n.length){console.log("No running bulb servers.");return}let t=await Promise.all(n.map(Au));console.log("Running bulb servers:"),mv(n,r=>console.log(r),t),console.log(`
2484
- `+e)}function Sf(n,e,t,r,s){let i=qR(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>\`):`),mv(n,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function gv(n,e){if(!n){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await vf(await X(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let t=Sf(await X(),n,"logs",process.cwd(),Pn());if(e.clear){bu(t.pid),console.log(`Cleared log for ${Pr(t)} (pid ${t.pid}).`);return}let r=He(t.pid),s=r.text;if(e.run!==void 0?(s=vu(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(`
2487
+ `)}pt();mn();async function gv(n){Me(n);let e=await ft();if(e.length>0){console.log(Ey(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!Ku()){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(ir))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 yv(n){n?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=Kn(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)}nt();import*as vv from"path";import{valid as wv,lt as TI}from"semver";$e();var Ze={connected:"[page] connected",disconnected:"[page] disconnected",closed:n=>`[page] closed: ${n}`},Pf=3e3,bv=1e4,AI=2500,Za=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?.()},Pf).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,AI);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()}};Ro();function PI(n,e,t,r){if(/^\d+$/.test(e))return n.find(i=>i.pid===parseInt(e,10));let s=e==="agent"?n.filter(me):n.filter(i=>i.agent===e);if(s.length){if(!t)return s[0];let i=s.filter(o=>er(o,t));return r&&i.find(o=>o.agent===r)||i[0]}return n.find(i=>se(i.file)===se(e))}var Rr=n=>n.agent??vv.basename(n.file);function Sv(n){return n===Le?!1:n&&wv(n)&&wv(Le)?TI(n,Le):!0}function OI(n){return n===Le?"":n?Sv(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 CI(n,e){return e===void 0?" pages ?":e>0?` ${e} page${e===1?"":"s"}`:me(n)?" NO PAGE (no tab open on it)":" NO PAGE (nothing of it is running)"}function kv(n,e,t){n.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${t?CI(r,t[s]):""}${OI(r.version)} ${r.file}`))}async function Of(n,e){if(!n.length){console.log("No running bulb servers.");return}let t=await Promise.all(n.map(Nu));console.log("Running bulb servers:"),kv(n,r=>console.log(r),t),console.log(`
2488
+ `+e)}function Cf(n,e,t,r,s){let i=PI(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>\`):`),kv(n,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function xv(n,e){if(!n){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await Of(await Q(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let t=Cf(await Q(),n,"logs",process.cwd(),Cn());if(e.clear){Tu(t.pid),console.log(`Cleared log for ${Rr(t)} (pid ${t.pid}).`);return}let r=Ye(t.pid),s=r.text;if(e.run!==void 0?(s=Ou(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(`
2485
2489
  `);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
2486
2490
  `)}if(process.stdout.write(s),s&&!s.endsWith(`
2487
2491
  `)&&process.stdout.write(`
2488
- `),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=He(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 KR=n=>new Promise(e=>setTimeout(e,n));async function yv(n,e){if(!n){vf(await X(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let t=Sf(await X(),n,"wait",process.cwd(),Pn()),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=He(t.pid).offset,c=s?void 0:_o(t.pid,a)??(a?_o(t.pid):void 0),f=s?l:c!==void 0&&c<=l?c:a?0:l,u=Date.now()+o*1e3,d=me(t)?1e4:1e3,p=2e3,m=!me(t)&&!s,h,b="",E=0;for(;;){let T=f>=l,P=He(t.pid,f);if(f=P.offset,P.text){b+=P.text;let x=b.split(`
2489
- `);b=x.pop()??"";let I=!1;for(let R of x)R.trim()&&(m&&T&&R.startsWith(Qe.disconnected)&&(I=!0),!(e.match&&!R.includes(e.match))&&(console.log(R),!s&&(h??=Date.now()+d,me(t)&&(R.includes("] compile error")||R.includes("] runtime error"))&&(h=Math.min(h,Date.now()+p)))));if(I&&!h){console.error(`the last page of ${Pr(t)} 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()>=u){console.error(`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${Pr(t)} within ${o}s`),E=2;break}if(!Vn(t.pid)){h||(console.error(`server ${Pr(t)} (pid ${t.pid}) exited while waiting`),process.exit(3));break}await KR(400)}s||ys(t.pid,f,a),process.exit(E)}function bv(n,e){if(e==="killed")return` \u2014 forced (${hv(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 wv(n){if(!n){await vf(await X(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Sf(await X(),n,"stop",process.cwd(),Pn()),t=await Lt(e);console.log(`Stopped ${Pr(e)} (pid ${e.pid}, ${e.url}).${bv(e,t)}`)}async function vv(n){let e=process.cwd(),t=n==="agent"?Pn():void 0,r=n==="global"?await X():n==="bulbs"?await X(e):(await X()).filter(o=>Xn(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=>Lt(o)));console.log(`Stopped ${r.length} ${s}${r.length===1?"":"s"}:`),r.forEach((o,a)=>console.log(` ${o.url} pid ${o.pid} ${Pr(o)}${bv(o,i[a])}`))}Ne();tt();an();import*as Ga from"path";import*as Sv from"http";import{mkdir as HR,writeFile as YR}from"fs/promises";async function Or(){let n=[];for await(let e of process.stdin)n.push(e);return Buffer.concat(n).toString("utf-8")}function Zs(n){return(n.charCodeAt(0)===65279?n.slice(1):n).replace(/\r\n/g,`
2490
- `).trimEnd()}function VR(n,e){return new Promise((t,r)=>{let s=new URL(n),i=Sv.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 zR=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 kv(n,e,t=0){e==="-"&&(e=Zs(await Or()));let r=e!==void 0&&e.startsWith("tb:");r&&t<=0&&(t=cf);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=Ga.resolve(n),o=cn(await X(),i)[0];if(!o){let m=(await on(process.cwd()))(i);console.error(m?`No running server for '${n}' \u2014 it last ran ${zR(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("&"),b=await VR(`${o.url}/__send${h?`?${h}`:""}`,e??"");(b.status<200||b.status>=300)&&(console.error(`send failed: HTTP ${b.status} from ${o.url}/__send`),process.exit(1));try{return JSON.parse(b.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,u=`${f} page${f===1?"":"s"}`;if(l.refused&&(console.error(`Actuation needs exactly one connected page; ${u} 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":"",b=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 "${Qe.connected}"`;console.error(`No page connected after ${((Date.now()-c)/1e3).toFixed(1)}s, so nothing was delivered${b}`),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 ${u}.`);let d=l.results??[],p=l.errors??[];for(let m of p)console.error(`handler error: ${m}`);if(p.length&&process.exit(1),d.length>1&&(console.error(`${d.length} replies from ${u} \u2014 one reply owns stdout: at most one tb.onMessage handler, in one page, may return a value.`),process.exit(1)),d.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let h={};try{h=JSON.parse(d[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 b=$g(i);await HR(Ga.dirname(b),{recursive:!0}),await YR(b,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(b);return}let m;try{m=JSON.parse(d[0])}catch{m=void 0}console.log(typeof m=="string"?m:d[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)`))}ga();xd();ee();import*as xv from"fs/promises";async function Ev(n,e){let t=await xv.readFile(n,"utf-8"),r=Cn(t),s=ce[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(`
2492
+ `),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=Ye(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 _I=n=>new Promise(e=>setTimeout(e,n));async function Ev(n,e){if(!n){Of(await Q(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let t=Cf(await Q(),n,"wait",process.cwd(),Cn()),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=Ye(t.pid).offset,c=s?void 0:No(t.pid,a)??(a?No(t.pid):void 0),f=s?l:c!==void 0&&c<=l?c:a?0:l,u=Date.now()+o*1e3,d=me(t)?1e4:1e3,p=2e3,g=!me(t)&&!s,h,y="",E=0;for(;;){let P=f>=l,O=Ye(t.pid,f);if(f=O.offset,O.text){y+=O.text;let x=y.split(`
2493
+ `);y=x.pop()??"";let N=!1;for(let I of x)I.trim()&&(g&&P&&I.startsWith(Ze.disconnected)&&(N=!0),!(e.match&&!I.includes(e.match))&&(console.log(I),!s&&(h??=Date.now()+d,me(t)&&(I.includes("] compile error")||I.includes("] runtime error"))&&(h=Math.min(h,Date.now()+p)))));if(N&&!h){console.error(`the last page of ${Rr(t)} 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()>=u){console.error(`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${Rr(t)} within ${o}s`),E=2;break}if(!Xn(t.pid)){h||(console.error(`server ${Rr(t)} (pid ${t.pid}) exited while waiting`),process.exit(3));break}await _I(400)}s||ws(t.pid,f,a),process.exit(E)}function Av(n,e){if(e==="killed")return` \u2014 forced (${Sv(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 Tv(n){if(!n){await Of(await Q(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Cf(await Q(),n,"stop",process.cwd(),Cn()),t=await Bt(e);console.log(`Stopped ${Rr(e)} (pid ${e.pid}, ${e.url}).${Av(e,t)}`)}async function Pv(n){let e=process.cwd(),t=n==="agent"?Cn():void 0,r=n==="global"?await Q():n==="bulbs"?await Q(e):(await Q()).filter(o=>er(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=>Bt(o)));console.log(`Stopped ${r.length} ${s}${r.length===1?"":"s"}:`),r.forEach((o,a)=>console.log(` ${o.url} pid ${o.pid} ${Rr(o)}${Av(o,i[a])}`))}$e();nt();cn();import*as el from"path";import*as Ov from"http";import{mkdir as RI,writeFile as II}from"fs/promises";async function Ir(){let n=[];for await(let e of process.stdin)n.push(e);return Buffer.concat(n).toString("utf-8")}function ti(n){return(n.charCodeAt(0)===65279?n.slice(1):n).replace(/\r\n/g,`
2494
+ `).trimEnd()}function NI(n,e){return new Promise((t,r)=>{let s=new URL(n),i=Ov.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 $I=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 Cv(n,e,t=0){e==="-"&&(e=ti(await Ir()));let r=e!==void 0&&e.startsWith("tb:");r&&t<=0&&(t=yf);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=el.resolve(n),o=dn(await Q(),i)[0];if(!o){let g=(await ln(process.cwd()))(i);console.error(g?`No running server for '${n}' \u2014 it last ran ${$I(g)}. 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 g=>{let h=[g>0?`reply=${g}`:"",s?"solo=1":"","open=1"].filter(Boolean).join("&"),y=await NI(`${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(g){console.error(`send failed: ${g instanceof Error?g.message:String(g)}`),process.exit(1)}let f=l.clients??0,u=`${f} page${f===1?"":"s"}`;if(l.refused&&(console.error(`Actuation needs exactly one connected page; ${u} are open on ${o.url} \u2014 the reset is \`typebulb stop ${n}\` then relaunch.`),process.exit(1)),f===0){let g=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?`:g!==void 0?` \u2014 a page disconnected ${Math.round(g/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 "${Ze.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 ${u}.`);let d=l.results??[],p=l.errors??[];for(let g of p)console.error(`handler error: ${g}`);if(p.length&&process.exit(1),d.length>1&&(console.error(`${d.length} replies from ${u} \u2014 one reply owns stdout: at most one tb.onMessage handler, in one page, may return a value.`),process.exit(1)),d.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let h={};try{h=JSON.parse(d[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=qg(i);await RI(el.dirname(y),{recursive:!0}),await II(y,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(y);return}let g;try{g=JSON.parse(d[0])}catch{g=void 0}console.log(typeof g=="string"?g:d[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)`))}va();Rd();ee();import*as _v from"fs/promises";async function Rv(n,e){let t=await _v.readFile(n,"utf-8"),r=Nn(t),s=ce[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(`
2491
2495
  `)?i:i+`
2492
- `)}ee();import*as ei from"fs/promises";async function Pv(n,e){let t=await ei.readFile(n,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await Or():await ei.readFile(o,"utf-8")}catch(l){Tv(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:Zs(a),label:o==="-"?"stdin":o})}let s;try{s=GR(t,r)}catch(i){Tv(`${n}: ${i instanceof Error?i.message:String(i)}`)}for(let i of s.upToDate)console.log(`${ce[i].path}: already up to date`);if(s.written.length){await ei.writeFile(n,s.text);for(let i of s.written)console.log(i.action==="removed"?`${ce[i.kind].path}: removed (${i.label} is empty)`:`${ce[i.kind].path}: ${i.action} from ${i.label} (${i.chars.toLocaleString()} chars)`)}}function GR(n,e){let t=Cn(n),r=n,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=ce[o].path,f=t.files.get(c);if(!a){if(f===void 0){i.push(o);continue}r=Av(zf(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(f!==void 0&&Zs(f)===a){i.push(o);continue}r=Av(Cr(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 Av(n,e,t){if(n===e)throw new Error(`the **${t}** block's fence is unterminated; refusing to rewrite inside it`);return n}function Tv(n){console.error(n),process.exit(1)}dt();yt();ee();Lo();import*as zt from"fs/promises";import*as On from"path";import{EventEmitter as gI}from"events";Mt();ee();import{Hono as nI}from"hono";import{serve as rI}from"@hono/node-server";import{streamSSE as sI}from"hono/streaming";import*as Ef from"fs/promises";import iI from"open";fr();Bs();dr();import*as kf from"fs/promises";import*as ti from"path";var Xa=class{async get(e){let t=Ve(e),r=ti.join(Ms,t+".bin"),s=ti.join(Ms,t+".json");try{let[i,o]=await Promise.all([kf.readFile(r),kf.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=Ve(e),s=ti.join(Ms,r+".bin"),i=ti.join(Ms,r+".json"),o={url:e,contentType:t.contentType,cacheControl:t.cacheControl};await Promise.all([Me(s,t.body),Me(i,JSON.stringify(o))])}};var Ov=`
2496
+ `)}ee();import*as ni from"fs/promises";async function $v(n,e){let t=await ni.readFile(n,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await Ir():await ni.readFile(o,"utf-8")}catch(l){Nv(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:ti(a),label:o==="-"?"stdin":o})}let s;try{s=LI(t,r)}catch(i){Nv(`${n}: ${i instanceof Error?i.message:String(i)}`)}for(let i of s.upToDate)console.log(`${ce[i].path}: already up to date`);if(s.written.length){await ni.writeFile(n,s.text);for(let i of s.written)console.log(i.action==="removed"?`${ce[i.kind].path}: removed (${i.label} is empty)`:`${ce[i.kind].path}: ${i.action} from ${i.label} (${i.chars.toLocaleString()} chars)`)}}function LI(n,e){let t=Nn(n),r=n,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=ce[o].path,f=t.files.get(c);if(!a){if(f===void 0){i.push(o);continue}r=Iv(sp(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(f!==void 0&&ti(f)===a){i.push(o);continue}r=Iv(Nr(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 Iv(n,e,t){if(n===e)throw new Error(`the **${t}** block's fence is unterminated; refusing to rewrite inside it`);return n}function Nv(n){console.error(n),process.exit(1)}pt();wt();ee();jo();import*as Xt from"fs/promises";import*as _n from"path";import{EventEmitter as rN}from"events";Dt();ee();import{Hono as UI}from"hono";import{serve as qI}from"@hono/node-server";import{streamSSE as JI}from"hono/streaming";import*as If from"fs/promises";import WI from"open";mr();js();hr();import*as _f from"fs/promises";import*as ri from"path";var tl=class{async get(e){let t=ze(e),r=ri.join(Ds,t+".bin"),s=ri.join(Ds,t+".json");try{let[i,o]=await Promise.all([_f.readFile(r),_f.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,t){await ne();let r=ze(e),s=ri.join(Ds,r+".bin"),i=ri.join(Ds,r+".json"),o={url:e,contentType:t.contentType,cacheControl:t.cacheControl};await Promise.all([Be(s,t.body),Be(i,JSON.stringify(o))])}};var Lv=`
2493
2497
  const CSS = '\\n' +
2494
2498
  /* The agent mirror's token set, verbatim (agents/core/client/styles.css) \u2014 one system across CLI
2495
2499
  chrome: app chrome sits on --panel, content wells paint --veil, grays ride one neutral tint.
@@ -2872,22 +2876,22 @@ export function runInference(ctx) {
2872
2876
  showConfirm();
2873
2877
  document.body.appendChild(host);
2874
2878
  }
2875
- `;hr();Ne();pn();Ho();Mt();import{stream as XR}from"hono/streaming";var QR="X-TB-Stream";function ni(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 Qa(n,e){return n.header("Content-Type","application/x-ndjson; charset=utf-8"),n.header("Cache-Control","no-cache"),n.header(QR,"1"),XR(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:ni(s)}))}finally{try{await r.return?.()}catch{}}})}var Za={log:(...n)=>console.log(...n)};function el(n,e){let t=n?.[e]??(Object.hasOwn(Za,e)?Za[e]:void 0);return typeof t=="function"?t:void 0}function tl(n){return n.constructor?.name==="AsyncGeneratorFunction"}md();var ZR=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,eI=/[?&]target=/,tI=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function _v(n,e=""){return ZR.test(n)?!0:tI.test(n)&&eI.test(e)}var oI="127.0.0.1",aI=new Set(["localhost","127.0.0.1","::1"]),$v=(n,e)=>!!n&&typeof n=="object"&&e in n,Cv=n=>{let e={};return Array.isArray(n.data)&&(e.data=n.data),$v(n,"insight")&&(e.insight=n.insight),e},Rv=8*1024*1024,lI=0;function cI(n){if(n)try{return new URL(n.includes("://")?n:`http://${n}`).hostname}catch{return}}function Lv(n){let e=cI(n);return!!e&&aI.has(e)}function uI(n){try{let e=new URL(n);return(e.protocol==="http:"||e.protocol==="https:")&&Lv(e.host)}catch{return!1}}function dI(n){return!!n&&/\bCode\/\d/.test(n)&&/\bElectron\//.test(n)}function fI(n,e){if(!e)return!1;try{return new URL(n).host===e}catch{return!1}}function ri(n){return n instanceof Error?n.message:"Unknown error"}var Iv=n=>n.how==="editor"||n.how==="unreached"?n.via:void 0,pI=2e3;async function Mv(n){let{getHtml:e,basePath:t,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:l,saveInferenceResult:c,localOverride:f,trusted:u=!1,trustHint:d,staticAssets:p,bulbAssets:m,sourceFile:h,bulbKey:b,onStop:E}=n,T=`${process.pid}-${++lI}-${Date.now()}`,P=r??t,x=new nI;x.use("*",async(y,S)=>{if(!Lv(y.req.header("host")))return y.text("Forbidden: untrusted Host",403);await S()}),x.use("*",async(y,S)=>{await S(),y.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),y.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let I=[["/__fs/*","the filesystem"],["/__api/*","server-side code (server.ts)"],["/__ai","AI (your API keys)"],["/__infer","AI (your API keys)"],["/__infer-save","the filesystem"]],R=async(y,S)=>{if(!u){let O=new URL(y.req.url).pathname,N=I.find(([q])=>q.endsWith("/*")?O.startsWith(q.slice(0,-2)):O===q)?.[1]??"server-side code (server.ts)";ku(process.pid,N);let M=d?`
2876
- ${d}`:"";return y.text(`Forbidden: this capability requires --trust.${M}`,403)}await S()},$=async(y,S)=>{let O=y.req.header("sec-fetch-site");if(O){if(O!=="same-origin")return y.text(`Forbidden: ${O} request`,403)}else{let N=y.req.header("origin");if(N&&!fI(N,y.req.header("host")))return y.text("Forbidden: cross-origin request",403)}await S()};for(let[y]of I)x.use(y,R),x.use(y,$);x.use("/__log",$),x.post("/__log",async y=>{try{let{args:S}=await y.req.json();console.log(...S||[])}catch{}return y.json({ok:!0})});let A=new za,W=new Set,Q=new Set,Z=Date.now();A.onArrival(({page:y,firstAttach:S,count:O})=>{o&&O===1&&console.log(Qe.connected),S&&O>1&&y.close("yielded").catch(()=>{})}),o&&A.onSettledEmpty(()=>console.log(Qe.disconnected));let F,ye=0,de=async y=>{let S=Math.max(y.fresh?0:Z,A.lastDropAt);if(await A.whenArrives(wf-(Date.now()-S)))return{how:"attached"};if(Date.now()-ye<pI)return{how:"none"};let O=`http://localhost:${s}#tb-relay`,N=await Eu(O,t),M;return N?.where==="editor"?M={how:"editor",via:N.via}:(y.external==="force"||y.external==="follow"&&N?.where==="external")&&(await iI(O),M={how:"external"}),M?await A.whenArrives(dv)?M:{how:"unreached",via:Iv(M)}:(ye=Date.now(),{how:"none"})},Ce=y=>A.count>0?Promise.resolve({how:"attached"}):F??=de(y).finally(()=>{F=void 0});if(o){let y=0,S=new Map;x.use("/__send",$),x.post("/__send",async O=>{let N="";try{N=await O.req.text()}catch{}let M=Number(O.req.query("reply"))||0,q=A.count===0&&O.req.query("open")!==void 0?await Ce({external:"follow",fresh:!1}):void 0,J=A.count,Ue=J===0&&A.lastDropAt?Date.now()-A.lastDropAt:void 0,H={clients:J,droppedMsAgo:Ue,...q?{opening:q.how,via:Iv(q)}:{}};if(O.req.query("solo")!==void 0&&J!==1)return O.json({...H,refused:J>1});if(J===0)return O.json(H);let ae=Xt=>{for(let St of A)St.send(Xt).catch(()=>{})};if(M<=0)return ae({payload:N}),O.json(H);let xe=++y,_r=await new Promise(Xt=>{let St={expected:J,received:0,results:[],errors:[],finish:oi=>{clearTimeout(rl),S.delete(xe),Xt({results:St.results,errors:St.errors,timedOut:oi})}},rl=setTimeout(()=>St.finish(!0),M);S.set(xe,St),ae({id:xe,payload:N})});return O.json({...H,..._r})}),x.use("/__send-reply",$),x.post("/__send-reply",async O=>{try{let{id:N,results:M,errors:q}=await O.req.json(),J=S.get(N);J&&(J.results.push(...M??[]),J.errors.push(...q??[]),++J.received>=J.expected&&J.finish(!1))}catch{}return O.json({ok:!0})})}x.get("/",y=>y.html(e())),x.post("/__fs/read",async y=>{try{let{path:S}=await y.req.json(),O=await Ds(S,P);return new Response(new Uint8Array(O),{headers:{"Content-Type":"application/octet-stream"}})}catch(S){let O=ri(S);return y.json({error:O},400)}}),x.post("/__fs/write",async y=>{try{let S=y.req.query("path");return S?(await ca(S,new Uint8Array(await y.req.arrayBuffer()),P),y.json({success:!0})):y.json({error:"Missing path"},400)}catch(S){let O=ri(S);return y.json({error:O},400)}}),x.post("/__fs/list",async y=>{try{let{path:S}=await y.req.json();return y.json(await ua(S??".",P))}catch(S){return y.json({error:ri(S)},400)}}),x.post("/__fs/remove",async y=>{try{let{path:S}=await y.req.json();return await da(S,P),y.json({success:!0})}catch(S){return y.json({error:ri(S)},400)}}),x.post("/__api/:name",async y=>{try{let S=y.req.param("name"),O=el(a?.(),S);if(!O)return y.json({error:`API function '${S}' not found`},404);let{args:N}=await y.req.json();if(tl(O))return Qa(y,O(...N||[]));let M=await O(...N||[]);return y.json({result:M})}catch(S){let O=ri(S);return y.json({error:O},500)}}),x.post("/__ai",async y=>{try{let{messages:S,system:O,effort:N,provider:M,model:q,webSearch:J,stream:Ue}=await y.req.json();if(!S||!Array.isArray(S)||S.length===0)return y.json({message:"messages array is required",code:"unknown",retryable:!1},400);let H=ft(M,q);if(typeof H=="string")return y.json({message:H,code:"unknown",retryable:!1},400);let ae=await Dt(H,{messages:S,system:O,effort:N,webSearch:J,signal:y.req.raw.signal});if(!ae.ok){let Xt=await or(ae,H.protocol);return y.json(Xt,ae.status)}if(Ue)return Qa(y,gn(ae,H.protocol));let{text:xe,usage:_r}=await ar(ae,H.protocol);return xe||console.warn("[tb.ai] Empty response from provider"),y.json({text:xe,usage:_r})}catch(S){return y.json(ni(S),500)}}),x.post("/__infer",async y=>{try{let{data:S}=await y.req.json().catch(()=>({})),O=l?.();if(!O?.infer.trim())return y.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let N=ft();if(typeof N=="string")return y.json({message:N,code:"unknown",retryable:!1},400);let M=Array.isArray(S)?S.map(String):[],q=zu(O,M),J=await Dt(N,{messages:[{role:"user",content:q}],signal:y.req.raw.signal});if(!J.ok){let H=await or(J,N.protocol);return y.json(H,J.status)}let Ue=(async function*(){let H="";for await(let xe of gn(J,N.protocol))xe.kind!=="text"||!xe.text||(H+=xe.text,yield{kind:"delta",text:xe.text});let ae=Gu(H);if(ae.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
2877
- `+H.slice(-4e3)),new Pe("LLM output is not valid JSON","parse_error",!0);ae.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",ae.fixesApplied.join(", ")),yield{kind:"complete",insight:ae.parsed,data:M,fixesApplied:ae.fixesApplied}})();return Qa(y,Ue)}catch(S){return y.json(ni(S),500)}}),x.post("/__infer-save",async y=>{try{if(!c)return y.json({message:"Save is not available for this server.",code:"unknown",retryable:!1},400);let S=Cv(await y.req.json().catch(()=>({})));return Object.keys(S).length?(await c(S.data,$v(S,"insight")?JSON.stringify(S.insight,null,2):void 0),y.json({ok:!0})):y.json({message:"Nothing to save \u2014 this page holds no runtime state.",code:"unknown",retryable:!1},400)}catch(S){return y.json(ni(S),500)}}),x.get("/__infer-info",y=>{let S=l?.(),O=Rr(S?.config??"").inference,N=fo(S?.data??""),M=!!S?.infer.trim(),q=ft();return typeof q=="string"?y.json({error:q,inference:O,data:N,hasInfer:M}):y.json({provider:q.protocol,model:q.model,inference:O,data:N,hasInfer:M})}),x.use("/__tb-decode",$),x.post("/__tb-decode",async y=>{let{hash:S}=await y.req.json().catch(()=>({})),O=typeof S=="string"?Qu(S):void 0;return y.json(O??{error:"invalid fragment"})}),x.use("/__tb-encode",$),x.post("/__tb-encode",async y=>{let S=Number(y.req.header("content-length"));if(Number.isFinite(S)&&S>Rv)return y.json({hash:""});let O=await y.req.text().catch(()=>"");if(O.length>Rv)return y.json({hash:""});let N;try{N=JSON.parse(O)}catch{return y.json({hash:""})}return y.json({hash:Xu(Cv(N))})}),x.get("/__infer-ui.js",y=>y.body(Ov,200,{"Content-Type":"text/javascript; charset=utf-8"})),x.get("/__models",async y=>{try{let S=await ut();return y.json(S)}catch{return y.json([],200)}}),x.get("/__ai-access",async y=>{try{return y.json(await Do())}catch{return y.json("none",200)}}),h&&x.get("/__source/*",async y=>{let S=await Ef.readFile(h,"utf-8").catch(()=>{});return S===void 0?y.text("Not Found",404):new Response(S,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let ke=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],se=new Xa;x.get("/proxy/*",async y=>{let S=new URL(y.req.url),N=(S.pathname+S.search).slice(7),M=N.lastIndexOf("https://");return M===-1?y.text("Invalid proxy URL",400):ii(y,N.slice(M))}),f&&Nv(x,`/local/${f.name}/`,f.serveDir),p&&Nv(x,p.mount,p.dir),m&&x.get("/assets/*",async y=>{let{pathname:S}=new URL(y.req.url),O=S.slice(8),N;try{N=decodeURIComponent(O)}catch{return y.text("Not Found",404)}let M=Zf(N);if(M)return y.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 Bv(N,m.dir,{"Cache-Control":"no-cache"});if(J)return J}catch{return y.text("Not Found",404)}let q=m.remoteBase;return q?y.redirect(q+O,302):y.text("Not Found",404)});async function ii(y,S){let O;try{O=new URL(S)}catch{return y.text("Invalid URL",400)}if(O.protocol!=="https:")return y.text("HTTPS only",400);if(!ke.includes(O.hostname))return y.text("Host not allowed",403);let N=await se.get(S);if(N)return new Response(N.body,{status:200,headers:xf(N.contentType,N.cacheControl)});try{let M=await fetch(S,{headers:{Accept:y.req.header("Accept")||"*/*"},redirect:"follow"});if(!M.ok)return y.text(`Upstream ${M.status}`,M.status);let q=M.headers.get("Content-Type")||void 0,J=M.headers.get("Cache-Control")||void 0;if(M.body){let[Ue,H]=M.body.tee();return(async()=>{try{let ae=await new Response(H).arrayBuffer();await se.set(S,{body:Buffer.from(ae),contentType:q,cacheControl:J})}catch{}})(),new Response(Ue,{status:M.status,headers:xf(q,J)})}return new Response(null,{status:M.status,headers:xf(q,J)})}catch(M){return y.text(`Proxy fetch failed: ${M instanceof Error?M.message:M}`,502)}}(i||o)&&(x.get("/__reload",y=>sI(y,async S=>{let O=y.req.query("bulb")||void 0;if(b&&O&&O!==b){W.has(O)||(W.add(O),console.log(Qe.closed("foreign"))),await S.writeSSE({event:"close",data:"foreign"});return}let N=()=>{S.writeSSE({event:"reload",data:""})};i?.on("reload",N);let M=()=>i?.removeListener("reload",N),q=y.req.query("relay")||void 0,J={inEditor:dI(y.req.header("user-agent")),doc:q,open:H=>S.writeSSE({event:"open-url",data:H}),send:H=>S.writeSSE({event:"message",data:JSON.stringify(H)}),close:H=>(M(),A.closing(J),console.log(Qe.closed(H)),S.writeSSE({event:"close",data:H}))},Ue=!!q&&!Q.has(q);for(q&&Q.add(q),A.add(J,Ue),S.onAbort(()=>{M(),A.dropped(J)}),await S.writeSSE({event:"hello",data:T,retry:pd});!S.aborted;)await S.sleep(3e4)})),x.use("/__open",$),x.post("/__open",async y=>{let S="";try{S=String((await y.req.json()).url??"")}catch{}if(!uI(S))return y.json({error:"a local http URL is required"},400);let O=[...A].find(N=>N.inEditor);return await O?.open(S),y.json({opened:!!O,pages:A.count})})),x.use("/__stop",$),x.post("/__stop",async y=>{if(y.req.header("sec-fetch-site")||y.req.header("origin"))return y.text("Forbidden: browser request",403);let S="close";try{let N=await y.req.json();(N?.pages==="keep"||N?.pages==="close")&&(S=N.pages)}catch{}let O=S==="close"?await A.closeAll("stopped"):{told:0,gone:0};return E&&setTimeout(()=>{E({pages:S})},50),y.json({closed:O.gone,stuck:O.told-O.gone,exiting:!!E})}),x.get("/__pages",y=>y.json({pages:A.count})),x.notFound(async y=>{if(y.req.method!=="GET")return y.text("Not Found",404);let S=new URL(y.req.url);return _v(S.pathname,S.search)?ii(y,"https://esm.sh"+S.pathname+S.search):y.text("Not Found",404)});let Gt=rI({fetch:x.fetch,port:s,hostname:oI});return Gt.listening||await new Promise((y,S)=>{let O=N=>S(N);Gt.once("error",O),Gt.once("listening",()=>{Gt.removeListener("error",O),y()})}),{port:s,close:()=>Gt.close(),requestPage:Ce,closePages:y=>A.closeAll(y),pageCount:()=>A.count}}function xf(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 Nv(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 Bv(decodeURIComponent(s.slice(e.length)),t)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function Bv(n,e,t={}){let r=mr(n,e),s=await Ef.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":Qf(r),...t}})}Ne();an();async function nl(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=[],u,d=!1,p=async h=>{if(!d){d=!0,console.log(`
2878
- Shutting down...`),(h?.pages??(me(c)?"keep":"close"))==="close"&&await u?.closePages("stopped"),u?.close();for(let b of f)try{await b()}catch{}a(),await ln(process.pid),process.exit(0)}},m=await Mv({...r(e),onStop:p}).catch(async h=>{if(h?.code!=="EADDRINUSE")throw h;return pu(e)});return u=m,await Su(c),console.log(`
2879
- ${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:b,replacedLive:E}){if(h==="none")return;let T={fresh:b,external:E?"never":h==="window"?"force":"follow"},P=await m.requestPage(T);P.how==="attached"?console.log(` Reusing the open browser tab.
2880
- `):P.how==="editor"?console.log(` Opened in VS Code via ${P.via}.
2881
- `):P.how==="external"?console.log(` Opened in your browser.
2882
- `):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?`:me(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."}
2879
+ `;yr();$e();mn();Go();Dt();import{stream as MI}from"hono/streaming";var BI="X-TB-Stream";function si(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 nl(n,e){return n.header("Content-Type","application/x-ndjson; charset=utf-8"),n.header("Cache-Control","no-cache"),n.header(BI,"1"),MI(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:si(s)}))}finally{try{await r.return?.()}catch{}}})}var rl={log:(...n)=>console.log(...n)};function sl(n,e){let t=n?.[e]??(Object.hasOwn(rl,e)?rl[e]:void 0);return typeof t=="function"?t:void 0}function il(n){return n.constructor?.name==="AsyncGeneratorFunction"}xd();var DI=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,jI=/[?&]target=/,FI=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function Mv(n,e=""){return DI.test(n)?!0:FI.test(n)&&jI.test(e)}var KI="127.0.0.1",HI=new Set(["localhost","127.0.0.1","::1"]),Uv=(n,e)=>!!n&&typeof n=="object"&&e in n,Bv=n=>{let e={};return Array.isArray(n.data)&&(e.data=n.data),Uv(n,"insight")&&(e.insight=n.insight),e},Dv=8*1024*1024,YI=0;function VI(n){if(n)try{return new URL(n.includes("://")?n:`http://${n}`).hostname}catch{return}}function qv(n){let e=VI(n);return!!e&&HI.has(e)}function zI(n){try{let e=new URL(n);return(e.protocol==="http:"||e.protocol==="https:")&&qv(e.host)}catch{return!1}}function GI(n){return!!n&&/\bCode\/\d/.test(n)&&/\bElectron\//.test(n)}function XI(n,e){if(!e)return!1;try{return new URL(n).host===e}catch{return!1}}function ii(n){return n instanceof Error?n.message:"Unknown error"}var jv=n=>n.how==="editor"||n.how==="unreached"?n.via:void 0,QI=2e3;async function Jv(n){let{getHtml:e,basePath:t,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:l,saveInferenceResult:c,localOverride:f,trusted:u=!1,trustHint:d,staticAssets:p,bulbAssets:g,sourceFile:h,bulbKey:y,onStop:E}=n,P=`${process.pid}-${++YI}-${Date.now()}`,O=r??t,x=new UI;x.use("*",async(b,k)=>{if(!qv(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 N=[["/__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(!u){let C=new URL(b.req.url).pathname,$=N.find(([J])=>J.endsWith("/*")?C.startsWith(J.slice(0,-2)):C===J)?.[1]??"server-side code (server.ts)";_u(process.pid,$);let M=d?`
2880
+ ${d}`:"";return b.text(`Forbidden: this capability requires --trust.${M}`,403)}await k()},L=async(b,k)=>{let C=b.req.header("sec-fetch-site");if(C){if(C!=="same-origin")return b.text(`Forbidden: ${C} request`,403)}else{let $=b.req.header("origin");if($&&!XI($,b.req.header("host")))return b.text("Forbidden: cross-origin request",403)}await k()};for(let[b]of N)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 T=new Za,K=new Set,X=new Set,Z=Date.now();T.onArrival(({page:b,firstAttach:k,count:C})=>{o&&C===1&&console.log(Ze.connected),k&&C>1&&b.close("yielded").catch(()=>{})}),o&&T.onSettledEmpty(()=>console.log(Ze.disconnected));let U,ye=0,te=async b=>{let k=Math.max(b.fresh?0:Z,T.lastDropAt);if(await T.whenArrives(Pf-(Date.now()-k)))return{how:"attached"};if(Date.now()-ye<QI)return{how:"none"};let C=`http://localhost:${s}#tb-relay`,$=await Iu(C,t),M;return $?.where==="editor"?M={how:"editor",via:$.via}:(b.external==="force"||b.external==="follow"&&$?.where==="external")&&(await WI(C),M={how:"external"}),M?await T.whenArrives(bv)?M:{how:"unreached",via:jv(M)}:(ye=Date.now(),{how:"none"})},be=b=>T.count>0?Promise.resolve({how:"attached"}):U??=te(b).finally(()=>{U=void 0});if(o){let b=0,k=new Map;x.use("/__send",L),x.post("/__send",async C=>{let $="";try{$=await C.req.text()}catch{}let M=Number(C.req.query("reply"))||0,J=T.count===0&&C.req.query("open")!==void 0?await be({external:"follow",fresh:!1}):void 0,W=T.count,_e=W===0&&T.lastDropAt?Date.now()-T.lastDropAt:void 0,H={clients:W,droppedMsAgo:_e,...J?{opening:J.how,via:jv(J)}:{}};if(C.req.query("solo")!==void 0&&W!==1)return C.json({...H,refused:W>1});if(W===0)return C.json(H);let ae=Zt=>{for(let xt of T)xt.send(Zt).catch(()=>{})};if(M<=0)return ae({payload:$}),C.json(H);let Ee=++b,Rn=await new Promise(Zt=>{let xt={expected:W,received:0,results:[],errors:[],finish:ll=>{clearTimeout(al),k.delete(Ee),Zt({results:xt.results,errors:xt.errors,timedOut:ll})}},al=setTimeout(()=>xt.finish(!0),M);k.set(Ee,xt),ae({id:Ee,payload:$})});return C.json({...H,...Rn})}),x.use("/__send-reply",L),x.post("/__send-reply",async C=>{try{let{id:$,results:M,errors:J}=await C.req.json(),W=k.get($);W&&(W.results.push(...M??[]),W.errors.push(...J??[]),++W.received>=W.expected&&W.finish(!1))}catch{}return C.json({ok:!0})})}x.get("/",b=>b.html(e())),x.post("/__fs/read",async b=>{try{let{path:k}=await b.req.json(),C=await Fs(k,O);return new Response(new Uint8Array(C),{headers:{"Content-Type":"application/octet-stream"}})}catch(k){let C=ii(k);return b.json({error:C},400)}}),x.post("/__fs/write",async b=>{try{let k=b.req.query("path");return k?(await pa(k,new Uint8Array(await b.req.arrayBuffer()),O),b.json({success:!0})):b.json({error:"Missing path"},400)}catch(k){let C=ii(k);return b.json({error:C},400)}}),x.post("/__fs/list",async b=>{try{let{path:k}=await b.req.json();return b.json(await ha(k??".",O))}catch(k){return b.json({error:ii(k)},400)}}),x.post("/__fs/remove",async b=>{try{let{path:k}=await b.req.json();return await ma(k,O),b.json({success:!0})}catch(k){return b.json({error:ii(k)},400)}}),x.post("/__api/:name",async b=>{try{let k=b.req.param("name"),C=sl(a?.(),k);if(!C)return b.json({error:`API function '${k}' not found`},404);let{args:$}=await b.req.json();if(il(C))return nl(b,C(...$||[]));let M=await C(...$||[]);return b.json({result:M})}catch(k){let C=ii(k);return b.json({error:C},500)}}),x.post("/__ai",async b=>{try{let{messages:k,system:C,effort:$,provider:M,model:J,webSearch:W,stream:_e}=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 H=ht(M,J);if(typeof H=="string")return b.json({message:H,code:"unknown",retryable:!1},400);let ae=await Ft(H,{messages:k,system:C,effort:$,webSearch:W,signal:b.req.raw.signal});if(!ae.ok){let Zt=await cr(ae,H.protocol);return b.json(Zt,ae.status)}if(_e)return nl(b,bn(ae,H.protocol));let{text:Ee,usage:Rn}=await ur(ae,H.protocol);return Ee||console.warn("[tb.ai] Empty response from provider"),b.json({text:Ee,usage:Rn})}catch(k){return b.json(si(k),500)}}),x.post("/__infer",async b=>{try{let{data:k}=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 $=ht();if(typeof $=="string")return b.json({message:$,code:"unknown",retryable:!1},400);let M=Array.isArray(k)?k.map(String):[],J=rd(C,M),W=await Ft($,{messages:[{role:"user",content:J}],signal:b.req.raw.signal});if(!W.ok){let H=await cr(W,$.protocol);return b.json(H,W.status)}let _e=(async function*(){let H="";for await(let Ee of bn(W,$.protocol))Ee.kind!=="text"||!Ee.text||(H+=Ee.text,yield{kind:"delta",text:Ee.text});let ae=sd(H);if(ae.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
2881
+ `+H.slice(-4e3)),new Pe("LLM output is not valid JSON","parse_error",!0);ae.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",ae.fixesApplied.join(", ")),yield{kind:"complete",insight:ae.parsed,data:M,fixesApplied:ae.fixesApplied}})();return nl(b,_e)}catch(k){return b.json(si(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=Bv(await b.req.json().catch(()=>({})));return Object.keys(k).length?(await c(k.data,Uv(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(si(k),500)}}),x.get("/__infer-info",b=>{let k=l?.(),C=$r(k?.config??"").inference,$=po(k?.data??""),M=!!k?.infer.trim(),J=ht();return typeof J=="string"?b.json({error:J,inference:C,data:$,hasInfer:M}):b.json({provider:J.protocol,model:J.model,inference:C,data:$,hasInfer:M})}),x.use("/__tb-decode",L),x.post("/__tb-decode",async b=>{let{hash:k}=await b.req.json().catch(()=>({})),C=typeof k=="string"?od(k):void 0;return b.json(C??{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>Dv)return b.json({hash:""});let C=await b.req.text().catch(()=>"");if(C.length>Dv)return b.json({hash:""});let $;try{$=JSON.parse(C)}catch{return b.json({hash:""})}return b.json({hash:id(Bv($))})}),x.get("/__infer-ui.js",b=>b.body(Lv,200,{"Content-Type":"text/javascript; charset=utf-8"})),x.get("/__models",async b=>{try{let k=await ft();return b.json(k)}catch{return b.json([],200)}}),x.get("/__ai-access",async b=>{try{return b.json(await qo())}catch{return b.json("none",200)}}),h&&x.get("/__source/*",async b=>{let k=await If.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 qe=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],pe=new tl;x.get("/proxy/*",async b=>{let k=new URL(b.req.url),$=(k.pathname+k.search).slice(7),M=$.lastIndexOf("https://");return M===-1?b.text("Invalid proxy URL",400):we(b,$.slice(M))}),f&&Fv(x,`/local/${f.name}/`,f.serveDir),p&&Fv(x,p.mount,p.dir),g&&x.get("/assets/*",async b=>{let{pathname:k}=new URL(b.req.url),C=k.slice(8),$;try{$=decodeURIComponent(C)}catch{return b.text("Not Found",404)}let M=lp($);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 W=await Wv($,g.dir,{"Cache-Control":"no-cache"});if(W)return W}catch{return b.text("Not Found",404)}let J=g.remoteBase;return J?b.redirect(J+C,302):b.text("Not Found",404)});async function we(b,k){let C;try{C=new URL(k)}catch{return b.text("Invalid URL",400)}if(C.protocol!=="https:")return b.text("HTTPS only",400);if(!qe.includes(C.hostname))return b.text("Host not allowed",403);let $=await pe.get(k);if($)return new Response($.body,{status:200,headers:Rf($.contentType,$.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 J=M.headers.get("Content-Type")||void 0,W=M.headers.get("Cache-Control")||void 0;if(M.body){let[_e,H]=M.body.tee();return(async()=>{try{let ae=await new Response(H).arrayBuffer();await pe.set(k,{body:Buffer.from(ae),contentType:J,cacheControl:W})}catch{}})(),new Response(_e,{status:M.status,headers:Rf(J,W)})}return new Response(null,{status:M.status,headers:Rf(J,W)})}catch(M){return b.text(`Proxy fetch failed: ${M instanceof Error?M.message:M}`,502)}}(i||o)&&(x.get("/__reload",b=>JI(b,async k=>{let C=b.req.query("bulb")||void 0;if(y&&C&&C!==y){K.has(C)||(K.add(C),console.log(Ze.closed("foreign"))),await k.writeSSE({event:"close",data:"foreign"});return}let $=()=>{k.writeSSE({event:"reload",data:""})};i?.on("reload",$);let M=()=>i?.removeListener("reload",$),J=b.req.query("relay")||void 0,W={inEditor:GI(b.req.header("user-agent")),doc:J,open:H=>k.writeSSE({event:"open-url",data:H}),send:H=>k.writeSSE({event:"message",data:JSON.stringify(H)}),close:H=>(M(),T.closing(W),console.log(Ze.closed(H)),k.writeSSE({event:"close",data:H}))},_e=!!J&&!X.has(J);for(J&&X.add(J),T.add(W,_e),k.onAbort(()=>{M(),T.dropped(W)}),await k.writeSSE({event:"hello",data:P,retry:Sd});!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(!zI(k))return b.json({error:"a local http URL is required"},400);let C=[...T].find($=>$.inEditor);return await C?.open(k),b.json({opened:!!C,pages:T.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 $=await b.req.json();($?.pages==="keep"||$?.pages==="close")&&(k=$.pages)}catch{}let C=k==="close"?await T.closeAll("stopped"):{told:0,gone:0};return E&&setTimeout(()=>{E({pages:k})},50),b.json({closed:C.gone,stuck:C.told-C.gone,exiting:!!E})}),x.get("/__pages",b=>b.json({pages:T.count})),x.notFound(async b=>{if(b.req.method!=="GET")return b.text("Not Found",404);let k=new URL(b.req.url);return Mv(k.pathname,k.search)?we(b,"https://esm.sh"+k.pathname+k.search):b.text("Not Found",404)});let Qt=qI({fetch:x.fetch,port:s,hostname:KI});return Qt.listening||await new Promise((b,k)=>{let C=$=>k($);Qt.once("error",C),Qt.once("listening",()=>{Qt.removeListener("error",C),b()})}),{port:s,close:()=>Qt.close(),requestPage:be,closePages:b=>T.closeAll(b),pageCount:()=>T.count}}function Rf(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 Fv(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 Wv(decodeURIComponent(s.slice(e.length)),t)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function Wv(n,e,t={}){let r=br(n,e),s=await If.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":ap(r),...t}})}$e();cn();async function ol(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=[],u,d=!1,p=async h=>{if(!d){d=!0,console.log(`
2882
+ Shutting down...`),(h?.pages??(me(c)?"keep":"close"))==="close"&&await u?.closePages("stopped"),u?.close();for(let y of f)try{await y()}catch{}a(),await un(process.pid),process.exit(0)}},g=await Jv({...r(e),onStop:p}).catch(async h=>{if(h?.code!=="EADDRINUSE")throw h;return Su(e)});return u=g,await Cu(c),console.log(`
2883
+ ${i}`),console.log(` ${l}`),t&&console.log(` ${t}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:l,pageCount:()=>g.pageCount(),async handOver({mode:h,fresh:y,replacedLive:E}){if(h==="none")return;let P={fresh:y,external:E?"never":h==="window"?"force":"follow"},O=await g.requestPage(P);O.how==="attached"?console.log(` Reusing the open browser tab.
2884
+ `):O.how==="editor"?console.log(` Opened in VS Code via ${O.via}.
2885
+ `):O.how==="external"?console.log(` Opened in your browser.
2886
+ `):console.log(` ${O.how==="unreached"?`Opened ${O.via?`in VS Code via ${O.via}`:"in your browser"}, but no page attached \u2014 is the browser it opened in still there?`:me(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."}
2883
2887
  Share ${l}, and wake on the arrival:
2884
- typebulb wait ${o} --match "${Qe.connected}"
2885
- `)},onCleanup(h){f.push(h)}}}an();import hI from"chokidar";var mI={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function Vt(n){let{target:e,onChange:t,events:r="change",debounceMs:s=150}=n,i,o=hI.watch(e,mI);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()}}Ne();tt();hr();async function Dv(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=bs(process.pid),o=e.watch?new gI:void 0,a=Le(e.mode),l=(await on(process.cwd()))(n),c=await Yn({kind:"bulb",file:n},process.cwd()),f=await Ro(n,c);f.length&&console.log(`Replacing the running server for this bulb (pid ${f.map(de=>de.pid).join(", ")})`);let u=f.length>0||Date.now()-l<Zy,{port:d,note:p}=await To({target:{kind:"bulb",file:n},cwd:process.cwd()});c!==void 0&&d!==c&&u&&(console.error(`
2886
- 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(wu(++m));h(),console.log(`Loading ${On.basename(n)}...`);let{html:b,bulb:E,serverExports:T}=await yd(n,e.watch,e.trust,r);Bt(a,n,E.server);let P=vn(n),x=gr(On.resolve(n)),I=e.trust?void 0:er(E),{port:R,onCleanup:$,handOver:A,pageCount:W}=await nl({port:d,portNote:p,displayName:E.name,stopLog:i,makeServerOptions:de=>({getHtml:()=>b,basePath:s,fsBase:js(n),port:de,reloadEmitter:o,sendChannel:!0,getServerExports:()=>T,getBulbBlocks:()=>({infer:E.infer,insight:E.insight,code:E.code,config:E.config,data:E.data}),saveInferenceResult:async(Ce,ke)=>{let se=await zt.readFile(n,"utf-8");Ce!==void 0&&(se=Cr(se,"data",Ce.join(Qm))),ke!==void 0&&(se=Cr(se,"insight",ke)),await zt.writeFile(n,se)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:P,remoteBase:x&&pi(x.userSlug,x.slug)},sourceFile:n,bulbKey:gs(n),trusted:e.trust,trustHint:t}),makeEntry:(de,Ce)=>({pid:process.pid,port:de,url:Ce,file:n,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:I}),waitTarget:On.relative(process.cwd(),n)||On.basename(n)});e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log(I?` trust: restricted \u2014 this bulb appears to use ${I}; re-run with --trust to enable it:
2888
+ typebulb wait ${o} --match "${Ze.connected}"
2889
+ `)},onCleanup(h){f.push(h)}}}cn();import ZI from"chokidar";import Kv from"node:fs";import eN from"node:path";var tN={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function Gt(n){let{target:e,onChange:t,events:r="change",debounceMs:s=150}=n,i,o=ZI.watch(e,tN);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 nN=n=>process.platform==="win32"||process.platform==="darwin"?n.toLowerCase()==="assets":n==="assets";function Hv(n,e,t=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,t)};try{let i=Kv.watch(n,{recursive:!0},(o,a)=>{a&&nN(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=eN.join(n,"assets");return Kv.existsSync(i)?Gt({target:i,onChange:e,events:"all",debounceMs:t}):()=>{}}}$e();nt();yr();async function Yv(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=vs(process.pid),o=e.watch?new rN:void 0,a=Me(e.mode),l=(await ln(process.cwd()))(n),c=await Gn({kind:"bulb",file:n},process.cwd()),f=await Lo(n,c);f.length&&console.log(`Replacing the running server for this bulb (pid ${f.map(te=>te.pid).join(", ")})`);let u=f.length>0||Date.now()-l<ab,{port:d,note:p}=await _o({target:{kind:"bulb",file:n},cwd:process.cwd()});c!==void 0&&d!==c&&u&&(console.error(`
2890
+ 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 g=0,h=()=>console.log(Pu(++g));h(),console.log(`Loading ${_n.basename(n)}...`);let{html:y,bulb:E,serverExports:P}=await Ad(n,e.watch,e.trust,r);jt(a,n,E.server);let O=kn(n),x=vr(_n.resolve(n)),N=e.trust?void 0:rr(E),{port:I,onCleanup:L,handOver:T,pageCount:K}=await ol({port:d,portNote:p,displayName:E.name,stopLog:i,makeServerOptions:te=>({getHtml:()=>y,basePath:s,fsBase:wr(n),port:te,reloadEmitter:o,sendChannel:!0,getServerExports:()=>P,getBulbBlocks:()=>({infer:E.infer,insight:E.insight,code:E.code,config:E.config,data:E.data}),saveInferenceResult:async(be,qe)=>{let pe=await Xt.readFile(n,"utf-8");be!==void 0&&(pe=Nr(pe,"data",be.join(ag))),qe!==void 0&&(pe=Nr(pe,"insight",qe)),await Xt.writeFile(n,pe)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:O,remoteBase:x&&hi(x.userSlug,x.slug)},sourceFile:n,bulbKey:bs(n),trusted:e.trust,trustHint:t}),makeEntry:(te,be)=>({pid:process.pid,port:te,url:be,file:n,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:N}),waitTarget:_n.relative(process.cwd(),n)||_n.basename(n)});e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log(N?` trust: restricted \u2014 this bulb appears to use ${N}; re-run with --trust to enable it:
2887
2891
  ${t}
2888
2892
  `:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
2889
2893
  `),e.watch&&console.log(` Watching for changes...
2890
- `);let Q,Z,F=()=>{W()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},ye=de=>{console.log(de),h(),F()};if(e.watch&&o){let de=0,Ce=Promise.resolve();if(Q=Vt({target:n,onChange:()=>{let ke=++de;Ce=Ce.then(async()=>{if(ke===de)try{console.log("Recompiling...");let se=await yd(n,!0,e.trust,r);b=se.html,T=se.serverExports,E=se.bulb,se.buildError||h(),F()}catch(se){console.error("Recompile failed:",se)}})}}),r){let{name:ke,serveDir:se}=r;Z=Vt({target:se,events:"all",onChange:()=>ye(`Local package '${ke}' changed.`)})}await zt.stat(P).then(ke=>ke.isDirectory()).catch(()=>!1)&&$(Vt({target:P,events:"all",onChange:()=>ye("Assets changed.")}))}Q&&$(Q),Z&&$(Z),$(()=>zt.rm(gd(n),{force:!0})),await A({mode:e.open,fresh:!u,replacedLive:f.some(de=>de.port===R)})}dt();import{readFileSync as Tf,copyFileSync as bI,existsSync as wI}from"fs";import*as pe from"path";import{fileURLToPath as vI}from"url";import{EventEmitter as SI}from"events";import kI from"open";an();Ne();hr();var Af=n=>`/agents/${n}/client.js`,yI=`
2894
+ `);let X,Z,U=()=>{K()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},ye=te=>{console.log(te),h(),U()};if(e.watch&&o){let te=0,be=Promise.resolve();if(X=Gt({target:n,onChange:()=>{let pe=++te;be=be.then(async()=>{if(pe===te)try{console.log("Recompiling...");let we=await Ad(n,!0,e.trust,r);y=we.html,P=we.serverExports,E=we.bulb,we.buildError||h(),U()}catch(we){console.error("Recompile failed:",we)}})}}),r){let{name:pe,serveDir:we}=r;Z=Gt({target:we,events:"all",onChange:()=>ye(`Local package '${pe}' changed.`)})}let qe=wr(n);await Xt.stat(qe).then(pe=>pe.isDirectory()).catch(()=>!1)&&L(Hv(qe,()=>ye("Assets changed.")))}X&&L(X),Z&&L(Z),L(()=>Xt.rm(Ed(n),{force:!0})),await T({mode:e.open,fresh:!u,replacedLive:f.some(te=>te.port===I)})}pt();import{readFileSync as $f,copyFileSync as iN,existsSync as oN}from"fs";import*as fe from"path";import{fileURLToPath as aN}from"url";import{EventEmitter as lN}from"events";import cN from"open";cn();$e();yr();var Nf=n=>`/agents/${n}/client.js`,sN=`
2891
2895
  (() => {
2892
2896
  const api = async (name, ...args) => {
2893
2897
  const resp = await fetch('/__api/' + name, {
@@ -2916,18 +2920,18 @@ Port ${c} is this bulb's, and a page of it may be waiting there, but something e
2916
2920
  })
2917
2921
  });
2918
2922
  if (window.__TYPEBULB_WATCH__) {
2919
- ${sa()}
2923
+ ${la()}
2920
2924
  }
2921
2925
  })();
2922
- `;function jv(n){let{name:e,agent:t,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=n,l=Af(t);return`<!DOCTYPE html>
2926
+ `;function Vv(n){let{name:e,agent:t,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=n,l=Nf(t);return`<!DOCTYPE html>
2923
2927
  <html>
2924
2928
  <head>
2925
2929
  <meta charset="utf-8">
2926
2930
  <meta name="viewport" content="width=device-width, initial-scale=1">
2927
- <title>${na(e)} - typebulb</title>
2928
- ${ra(e,a)}
2931
+ <title>${oa(e)} - typebulb</title>
2932
+ ${aa(e,a)}
2929
2933
  <style>
2930
- ${ds}
2934
+ ${hs}
2931
2935
  </style>
2932
2936
  <style>
2933
2937
  ${r}
@@ -2942,18 +2946,18 @@ ${i}
2942
2946
  ${o?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
2943
2947
 
2944
2948
  <script>
2945
- ${yI}
2949
+ ${sN}
2946
2950
  </script>
2947
2951
 
2948
2952
  <script type="module" src="${l}"></script>
2949
2953
  </body>
2950
- </html>`}async function Fv(n){let e=process.cwd(),t=n.agentTarget;Rw(t)||(console.error(`Unknown agent '${t}'. Known: ${Er().join(", ")}.`),process.exit(1));let r=await Co(e,t);if(r){console.log(`Mirror '${t}' is already running for this project:
2951
- ${r.url}`),n.open==="window"&&await kI(r.url);return}let s=bs(process.pid),i=n.watch?new SI:void 0,o=Le(n.mode),a=await Nw(t),l=a.displayName||`${t} mirror`;Bt(o,pe.join(e,"mirror"));let c=pe.dirname(vI(import.meta.url)),f=pe.join(c,"agents",t),u=pe.join(c,"..","cli","agents"),d=pe.join(f,"styles.css"),p=pe.join(f,"katex.min.css"),m=pe.join(f,"index.html"),h=()=>jv({name:l,agent:t,styles:Tf(d,"utf8"),katex:Tf(p,"utf8"),mountHtml:Tf(m,"utf8"),watch:n.watch}),{port:b,note:E}=await To({explicit:n.port,target:{kind:"mirror",agent:t},cwd:e}),{port:T,url:P,onCleanup:x,handOver:I,pageCount:R}=await nl({port:b,portNote:E,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:Z=>({getHtml:h,basePath:e,port:Z,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${pe.posix.dirname(Af(t))}/`,dir:f}}),makeEntry:(Z,F)=>({pid:process.pid,port:Z,url:F,file:`agent:${t}`,cwd:e,startedAt:Date.now(),trust:!0,agent:t})});n.watch&&console.log(` Watching for changes...
2952
- `);let $=pe.join(u,t,"client"),A=pe.join(u,"core","client");async function W(){await(await import("esbuild")).build({entryPoints:[pe.join($,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:pe.join(f,"client.js")});for(let F of["styles.css","index.html","typebulb.png","typebulb-inv.png"])bI(pe.join(A,F),pe.join(f,F))}let Q;if(n.watch&&i){let Z=wI($),F=!1;Q=Vt({target:Z?u:f,events:"all",onChange:async()=>{if(!F){F=!0;try{Z&&await W(),console.log(R()?`Mirror rebuilt. Reloading.
2954
+ </html>`}async function zv(n){let e=process.cwd(),t=n.agentTarget;Dw(t)||(console.error(`Unknown agent '${t}'. Known: ${Or().join(", ")}.`),process.exit(1));let r=await $o(e,t);if(r){console.log(`Mirror '${t}' is already running for this project:
2955
+ ${r.url}`),n.open==="window"&&await cN(r.url);return}let s=vs(process.pid),i=n.watch?new lN:void 0,o=Me(n.mode),a=await Fw(t),l=a.displayName||`${t} mirror`;jt(o,fe.join(e,"mirror"));let c=fe.dirname(aN(import.meta.url)),f=fe.join(c,"agents",t),u=fe.join(c,"..","cli","agents"),d=fe.join(f,"styles.css"),p=fe.join(f,"katex.min.css"),g=fe.join(f,"index.html"),h=()=>Vv({name:l,agent:t,styles:$f(d,"utf8"),katex:$f(p,"utf8"),mountHtml:$f(g,"utf8"),watch:n.watch}),{port:y,note:E}=await _o({explicit:n.port,target:{kind:"mirror",agent:t},cwd:e}),{port:P,url:O,onCleanup:x,handOver:N,pageCount:I}=await ol({port:y,portNote:E,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:Z=>({getHtml:h,basePath:e,port:Z,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${fe.posix.dirname(Nf(t))}/`,dir:f}}),makeEntry:(Z,U)=>({pid:process.pid,port:Z,url:U,file:`agent:${t}`,cwd:e,startedAt:Date.now(),trust:!0,agent:t})});n.watch&&console.log(` Watching for changes...
2956
+ `);let L=fe.join(u,t,"client"),T=fe.join(u,"core","client");async function K(){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 U of["styles.css","index.html","typebulb.png","typebulb-inv.png"])iN(fe.join(T,U),fe.join(f,U))}let X;if(n.watch&&i){let Z=oN(L),U=!1;X=Gt({target:Z?u:f,events:"all",onChange:async()=>{if(!U){U=!0;try{Z&&await K(),console.log(I()?`Mirror rebuilt. Reloading.
2953
2957
  `:`Mirror rebuilt. No tab open on it \u2014 nobody is reading this.
2954
- `),i.emit("reload")}catch(ye){console.error("Mirror rebuild failed:",ye instanceof Error?ye.message:ye)}finally{F=!1}}}})}await I({mode:n.open,fresh:!1,replacedLive:!1}),x(()=>a.shutdownSwitcher?.()),x(()=>a.shutdownComposer?.()),Q&&x(Q)}dt();yt();import*as Uv from"path";async function qv(n,e,t,r){let s=Le(t),i=!1,o=async()=>{let{bulb:a,config:l}=await Ge(n);i||(Bt(s,n,a.server),i=!0),await Fs(a.server,n,r,l.dependencies)};if(console.log(`Running ${Uv.basename(n)}...`),await o(),e){console.log(`Watching for changes...
2955
- `);let a=0,l=Promise.resolve();Vt({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)}})}})}}dt();yt();import{Console as xI}from"node:console";Ne();async function Kv(n,e,t,r){OI();try{let d=cn(await X(),n)[0];d&&(ys(d.pid,He(d.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${d.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=Le(t),{bulb:i,config:o}=await Ge(n);i.server||si("This bulb has no **server.ts** block; nothing to call."),Bt(s,n,i.server);let a;try{a=await Fs(i.server,n,r,o.dependencies)}catch(d){si(d instanceof Error?d.message:String(d))}let l=el(a,e.fn);if(!l){let d=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(Za)];si(`Function '${e.fn}' not found. Available: ${d.length?d.join(", "):"(none)"}.`)}let c=await EI(e);if(tl(l)){try{for await(let d of l(...c))await Wv(JSON.stringify(d,Hv)+`
2956
- `)}catch(d){si(d instanceof Error?d.stack??d.message:String(d))}return Jv(0)}let f;try{f=await l(...c)}catch(d){si(d instanceof Error?d.stack??d.message:String(d))}let u=PI(f);u!==void 0&&await Wv(u+`
2957
- `),Jv(0)}function Jv(n){process.exitCode=n,setTimeout(()=>process.exit(n),2e3).unref?.()}async function EI(n){if(n.hasArgsFlag){let e=n.argsJson??"";return e==="-"&&(e=await Or()),TI(e)}return AI(n.positional)}function AI(n){return n.map(e=>{try{return JSON.parse(e)}catch{return e}})}function TI(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 PI(n){if(n!==void 0)return JSON.stringify(n,Hv,2)}function Hv(n,e){return typeof e=="bigint"?e.toString():e}function si(n){process.stderr.write(n+`
2958
- `),process.exit(1)}function OI(){let n=new xI(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 Wv(n){return new Promise((e,t)=>{process.stdout.write(n,r=>r?t(r):e())})}Po();for(let n of[process.stdout,process.stderr])n.on("error",e=>{if(e?.code!=="EPIPE")throw e});function Yv(n,e){n||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
2959
- ${e}`),process.exit(1))}async function _I(){let n=Mw(process.argv.slice(2));if(n.version&&(console.log(`typebulb ${$e}`),process.exit(0)),n.help&&(Bw(),process.exit(0)),$w(),n.subcommand==="logs"){await gv(n.file||void 0,{follow:n.follow,clear:n.clear,run:n.run,lines:n.lines});return}if(n.subcommand==="wait"){await yv(n.file||void 0,{match:n.match,timeoutSec:n.timeoutSec});return}if(n.subcommand==="stop"){n.stopScope?await vv(n.stopScope):await wv(n.file||void 0);return}if(n.subcommand==="send"){await kv(n.file,n.sendMessage,n.sendWaitMs??0);return}if(n.subcommand==="models"){await cv(n.mode);return}if(n.subcommand==="slug"){uv(n.slugName);return}if(n.subcommand==="pull"){await ub(n.file||void 0,{force:n.force,mode:n.mode});return}if(n.subcommand==="push"){await fb(n.file||void 0,{force:n.force,mode:n.mode});return}if(n.subcommand==="agent"){await(n.agentTarget?Fv(n):lv($e));return}if(n.subcommand==="trust"||n.subcommand==="untrust"){await sv(n.file||void 0,n.subcommand==="trust");return}let e;if(!n.file||n.file==="."){let l=await lb(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=vt.resolve(n.file);if(await Vv.access(e).then(()=>!0,()=>!1)||(Er().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}`+(vt.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 Ev(e,n.blockKind);return}if(n.subcommand==="put"){await Pv(e,n.blockPairs);return}let r=n.file&&n.file!=="."?n.file:vt.relative(process.cwd(),e)||vt.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(n.subcommand==="predict"){await rv(e,s);return}let i=!n.noTrust&&fn(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 Ge(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 Mf(n.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${vt.relative(process.cwd(),a.dir)||"."}`)}if(n.subcommand==="check"){await nv(e,a);return}if(n.subcommand==="call"){Yv(n.trust,s),await Kv(e,{fn:n.fn,positional:n.callArgs,argsJson:n.argsJson,hasArgsFlag:n.hasArgsFlag},n.mode,a);return}if(o&&o.bulb.server&&(Io(o.bulb)||n.server)){Yv(n.trust,s),await qv(e,n.watch,n.mode,a);return}await Dv(e,n,s,a)}_I().catch(n=>{console.error("Error:",n.message),process.exit(1)});
2958
+ `),i.emit("reload")}catch(ye){console.error("Mirror rebuild failed:",ye instanceof Error?ye.message:ye)}finally{U=!1}}}})}await N({mode:n.open,fresh:!1,replacedLive:!1}),x(()=>a.shutdownSwitcher?.()),x(()=>a.shutdownComposer?.()),X&&x(X)}pt();wt();import*as Gv from"path";async function Xv(n,e,t,r){let s=Me(t),i=!1,o=async()=>{let{bulb:a,config:l}=await Xe(n);i||(jt(s,n,a.server),i=!0),await Us(a.server,n,r,l.dependencies)};if(console.log(`Running ${Gv.basename(n)}...`),await o(),e){console.log(`Watching for changes...
2959
+ `);let a=0,l=Promise.resolve();Gt({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)}})}})}}pt();wt();import{Console as uN}from"node:console";$e();async function eS(n,e,t,r){mN();try{let d=dn(await Q(),n)[0];d&&(ws(d.pid,Ye(d.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${d.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=Me(t),{bulb:i,config:o}=await Xe(n);i.server||oi("This bulb has no **server.ts** block; nothing to call."),jt(s,n,i.server);let a;try{a=await Us(i.server,n,r,o.dependencies)}catch(d){oi(d instanceof Error?d.message:String(d))}let l=sl(a,e.fn);if(!l){let d=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(rl)];oi(`Function '${e.fn}' not found. Available: ${d.length?d.join(", "):"(none)"}.`)}let c=await dN(e);if(il(l)){try{for await(let d of l(...c))await Zv(JSON.stringify(d,tS)+`
2960
+ `)}catch(d){oi(d instanceof Error?d.stack??d.message:String(d))}return Qv(0)}let f;try{f=await l(...c)}catch(d){oi(d instanceof Error?d.stack??d.message:String(d))}let u=hN(f);u!==void 0&&await Zv(u+`
2961
+ `),Qv(0)}function Qv(n){process.exitCode=n,setTimeout(()=>process.exit(n),2e3).unref?.()}async function dN(n){if(n.hasArgsFlag){let e=n.argsJson??"";return e==="-"&&(e=await Ir()),pN(e)}return fN(n.positional)}function fN(n){return n.map(e=>{try{return JSON.parse(e)}catch{return e}})}function pN(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 hN(n){if(n!==void 0)return JSON.stringify(n,tS,2)}function tS(n,e){return typeof e=="bigint"?e.toString():e}function oi(n){process.stderr.write(n+`
2962
+ `),process.exit(1)}function mN(){let n=new uN(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 Zv(n){return new Promise((e,t)=>{process.stdout.write(n,r=>r?t(r):e())})}Ro();for(let n of[process.stdout,process.stderr])n.on("error",e=>{if(e?.code!=="EPIPE")throw e});function nS(n,e){n||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
2963
+ ${e}`),process.exit(1))}async function gN(){let n=Jw(process.argv.slice(2));if(n.version&&(console.log(`typebulb ${Le}`),process.exit(0)),n.help&&(Ww(),process.exit(0)),Uw(),n.subcommand==="logs"){await xv(n.file||void 0,{follow:n.follow,clear:n.clear,run:n.run,lines:n.lines});return}if(n.subcommand==="wait"){await Ev(n.file||void 0,{match:n.match,timeoutSec:n.timeoutSec});return}if(n.subcommand==="stop"){n.stopScope?await Pv(n.stopScope):await Tv(n.file||void 0);return}if(n.subcommand==="send"){await Cv(n.file,n.sendMessage,n.sendWaitMs??0);return}if(n.subcommand==="models"){await gv(n.mode);return}if(n.subcommand==="slug"){yv(n.slugName);return}if(n.subcommand==="pull"){await bb(n.file||void 0,{force:n.force,mode:n.mode});return}if(n.subcommand==="push"){await vb(n.file||void 0,{force:n.force,mode:n.mode});return}if(n.subcommand==="agent"){await(n.agentTarget?zv(n):mv(Le));return}if(n.subcommand==="trust"||n.subcommand==="untrust"){await dv(n.file||void 0,n.subcommand==="trust");return}let e;if(!n.file||n.file==="."){let l=await gb(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=kt.resolve(n.file);if(await rS.access(e).then(()=>!0,()=>!1)||(Or().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}`+(kt.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 Rv(e,n.blockKind);return}if(n.subcommand==="put"){await $v(e,n.blockPairs);return}let r=n.file&&n.file!=="."?n.file:kt.relative(process.cwd(),e)||kt.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(n.subcommand==="predict"){await uv(e,s);return}let i=!n.noTrust&&hn(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 Xe(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 Kf(n.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${kt.relative(process.cwd(),a.dir)||"."}`)}if(n.subcommand==="check"){await cv(e,a);return}if(n.subcommand==="call"){nS(n.trust,s),await eS(e,{fn:n.fn,positional:n.callArgs,argsJson:n.argsJson,hasArgsFlag:n.hasArgsFlag},n.mode,a);return}if(o&&o.bulb.server&&(Mo(o.bulb)||n.server)){nS(n.trust,s),await Xv(e,n.watch,n.mode,a);return}await Yv(e,n,s,a)}gN().catch(n=>{console.error("Error:",n.message),process.exit(1)});