typebulb 0.57.1 → 0.57.2
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/README.md +2 -2
- package/SKILL.md +4 -4
- package/dist/agents/claude/client.js +18 -1
- package/dist/agents/codex/client.js +18 -1
- package/dist/agents/pi/client.js +18 -1
- package/dist/index.js +277 -261
- package/dist/render.js +18 -1
- package/dist/servers.js +103 -86
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,176 +1,176 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
|
|
3
|
-
var
|
|
4
|
-
`),t=0;if(e[t]?.trim()!=="---")return{reason:
|
|
5
|
-
`)),a.set(f,h),l=t}else t++}return{bulb:{frontmatter:i,files:o,warnings:c,bodyEndLine:l,starts:a}}}catch(e){return{reason:`unexpected parse error: ${e instanceof Error?e.message:String(e)}`}}}function
|
|
6
|
-
`),t=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s
|
|
3
|
+
var Dv=Object.create;var nc=Object.defineProperty;var jv=Object.getOwnPropertyDescriptor;var Fv=Object.getOwnPropertyNames;var Uv=Object.getPrototypeOf,qv=Object.prototype.hasOwnProperty;var oi=(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),ai=(n,e)=>{for(var t in e)nc(n,t,{get:e[t],enumerable:!0})},Jv=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Fv(e))!qv.call(n,s)&&s!==t&&nc(n,s,{get:()=>e[s],enumerable:!(r=jv(e,s))||r.enumerable});return n};var Kv=(n,e,t)=>(t=n!=null?Dv(Uv(n)):{},Jv(e||!n||!n.__esModule?nc(t,"default",{value:n,enumerable:!0}):t,n));import*as Cf from"fs/promises";import{existsSync as _n,readFileSync as Wv}from"fs";import*as oe from"path";import{pathToFileURL as Hv}from"url";import{resolve as sc}from"resolve.exports";import{init as _f,parse as Rf}from"es-module-lexer";function If(n,e){let t=oe.join(n,"package.json");try{return JSON.parse(Wv(t,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${t}`)}}function Nf(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:oe.resolve(r)}}async function $f(n){let{name:e,dir:t}=n;if(!_n(t))throw new Error(`--replace path for '${e}' does not exist: ${t}`);let r=If(t,e),s=Yv(r,e),i=oe.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=oe.dirname(i),a=`/local/${e}/${oe.basename(i)}`,c=Vv(r,t);return await zv(e,i,o),{name:e,dir:t,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:c}}function Yv(n,e){if(n.exports!==void 0){let r;try{r=sc(n,".",{browser:!0,conditions:rc})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${rc.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=ic(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${rc.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 Vv(n,e){if(n.exports!==void 0)try{let r=sc(n,".",{conditions:["types"]}),s=ic(r);if(s){let i=oe.resolve(e,s);if(_n(i))return i}}catch{}let t=n.types??n.typings;if(t){let r=oe.resolve(e,t);if(_n(r))return r}}function ic(n){if(typeof n=="string")return n;if(Array.isArray(n))return n.find(e=>typeof e=="string")}async function zv(n,e,t){await _f;let r=oe.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 Cf.readFile(o,"utf8")}catch{continue}let c,l;try{[c,,,l]=Rf(a,o)}catch{continue}if(o===e&&!l)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 d of c){if(d.d===-2)continue;let u=d.n;if(u&&!u.startsWith("node:")){if(u.startsWith("./")||u.startsWith("../")||u.startsWith("/")){let f=Gv(o,u,r);f&&!s.has(f)&&i.push(f);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${n} externalizes '${u}'`)}}}}function Gv(n,e,t){let r=e.replace(/[?#].*$/,""),s=oe.resolve(oe.dirname(n),r),i=[s,s+".js",s+".mjs",oe.join(s,"index.js"),oe.join(s,"index.mjs")];for(let o of i)if(oe.normalize(o).startsWith(t)&&_n(o))return o}function Xv(n,e,t){let r=If(n,e),s;if(r.exports!==void 0)try{s=ic(sc(r,t,{conditions:Of}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${t}' (conditions: ${Of.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=oe.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 Hv(i).href}async function Lf(n,e){await _f;let t;try{[t]=Rf(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),c=Xv(e.dir,e.name,a);r+=n.slice(s,i.s)+c,s=i.e}return r+n.slice(s)}var rc,Of,ci=v(()=>{"use strict";rc=["browser","import","default"],Of=["node","import","default"]});function Mf(n){return De.find(e=>ue[e].path===n)}function Df(n){return!!n?.startsWith("typebulb")}var ue,De,Bf,li=v(()=>{ue={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"}},De=["code","css","html","data","infer","insight","config","notes"];Bf="typebulb/v1"});function oc(n){return/[:\n"']/.test(n)||n.startsWith(" ")||n.endsWith(" ")?`"${n.replace(/"/g,'\\"')}"`:n}function ac(n){return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1).replace(/\\"/g,'"'):n.startsWith("'")&&n.endsWith("'")?n.slice(1,-1):n}var ui=v(()=>{});function Rn(n){let e=Ff(n);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function je(n){let e=Ff(n);return"bulb"in e?e.bulb:void 0}function Ff(n){try{let e=n.split(`
|
|
4
|
+
`),t=0;if(e[t]?.trim()!=="---")return{reason:Zv(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=nS(r);if(!Df(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,c=[],l=t;for(;t<e.length;){let u=e[t]?.trim()?.match(jf);if(u){let f=u[1].trim();for(t++;t<e.length&&e[t]?.trim()==="";)t++;let p=e[t]?.match(di);if(!p){c.push(`**${f}** has no code fence \u2014 block skipped`);continue}let m=p[1];t++;let h=t+1,y=[],x=cc(m);for(;t<e.length&&!e[t]?.match(x);)y.push(e[t]),t++;let T=t<e.length;t++,c.push(...eS(f,y,T)),o.set(f,y.join(`
|
|
5
|
+
`)),a.set(f,h),l=t}else t++}return{bulb:{frontmatter:i,files:o,warnings:c,bodyEndLine:l,starts:a}}}catch(e){return{reason:`unexpected parse error: ${e instanceof Error?e.message:String(e)}`}}}function Zv(n,e){let t=rS(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 eS(n,e,t){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(jf);i&&Qv.has(i[1].trim())&&tS(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 tS(n,e){let t=e+1;for(;t<n.length&&n[t]?.trim()==="";)t++;return!!n[t]?.match(di)}function nS(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=ac(i);break}}return e}function Uf(n){return je(n)?.warnings??[]}function rS(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(`
|
|
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
|
|
8
|
+
`)}),r=i}else r++}return t}function qf(n){let e=Object.fromEntries(De.map(t=>[t,n.files.get(ue[t].path)||""]));return{name:n.frontmatter.name,...e}}var jf,di,Qv,cc,lc=v(()=>{li();ui();jf=/^\*\*(.+)\*\*$/,di=/^(`{3,})(\w*)\s*$/,Qv=new Set(De.map(n=>ue[n].path)),cc=n=>new RegExp(`^${n}\\s*$`)});function Jf(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 Kf(n,e){let{path:t}=ue[n],r=t.split(".").pop(),s=Jf(e);return`**${t}**
|
|
9
9
|
|
|
10
10
|
${s}${r}
|
|
11
11
|
${e}
|
|
12
|
-
${s}`}function
|
|
13
|
-
`)}function
|
|
14
|
-
`),s=
|
|
12
|
+
${s}`}function Wf(n){let e=De.filter(t=>n[t]).map(t=>Kf(t,n[t]));return["---",`format: ${Bf}`,`name: ${oc(n.name)}`,"---","",...e].join(`
|
|
13
|
+
`)}function Hf(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(di);if(!s)continue;let i=cc(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 _r(n,e,t){let r=n.split(`
|
|
14
|
+
`),s=Hf(r,ue[e].path);if(s==="unterminated")return n;if(!s)return`${n.replace(/\s*$/,"")}
|
|
15
15
|
|
|
16
|
-
${
|
|
17
|
-
`;let i=
|
|
16
|
+
${Kf(e,t)}
|
|
17
|
+
`;let i=Jf(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
|
|
20
|
-
`),r=
|
|
19
|
+
`)}function Yf(n,e){let t=n.split(`
|
|
20
|
+
`),r=Hf(t,ue[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
|
|
23
|
-
>/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=n.slice(o+e.length),c=
|
|
24
|
-
>]`),h+=
|
|
25
|
-
`)}};
|
|
22
|
+
`}var Vf=v(()=>{li();lc();ui()});function Rr(n){if(!n.trim())return{};try{return JSON.parse(n)}catch{return{}}}function Gf(n){switch(zf(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 Xf(n){let e=zf(n);return e!==void 0&&iS.has(e)?e:void 0}function aS(n){return n.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function uc(n){let e=Rr(n??"").description?.trim();if(!e)return oS;let t=aS(e);return(t.length>200?t.slice(0,197)+"...":t).replace(/\n/g," ")}var sS,fi,zf,iS,oS,Qf=v(()=>{sS="https://assets.typebulb.com",fi=(n,e)=>`${sS}/u/${encodeURIComponent(n)}/${encodeURIComponent(e)}/`,zf=n=>/\.[^./\\]+$/.exec(n)?.[0]?.toLowerCase();iS=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);oS="A Typebulb bulb."});var Zf=v(()=>{});function dc(n,e,t){let s=new RegExp(e).exec(n.slice(t));return s?t+s.index:-1}var ep=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 tp=v(()=>{});function pi(n,e){let t=new RegExp(e,"g"),r=n.match(t);return r?r.length:0}var np=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=dc(n,`<${e}[
|
|
23
|
+
>/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=n.slice(o+e.length),c=Ir(a,"^[^<]*[ /]>",0),l=c!==-1&&a[c-1]==="/";if(r&&console.log("[xml-utils] selfClosing:",l),l===!1)if(s){let p=0,m=1,h=0;for(;(c=Ir(a,"[ /]"+e+">",p))!==-1;){let y=a.substring(p,c+1);if(m+=pi(y,"<"+e+`[
|
|
24
|
+
>]`),h+=pi(y,"</"+e+">"),h>=m)break;p=c}}else c=Ir(a,"[ /]"+e+">",0);let d=o+e.length+c+1;if(r&&console.log("[xml-utils] end:",d),d===-1)return;let u=n.slice(o,d),f;return l?f=null:f=u.slice(u.indexOf(">")+1,u.lastIndexOf("<")),{inner:f,outer:u,start:o,end:d}}var fc=v(()=>{ep();tp();np()});var pc=v(()=>{fc()});var hc=v(()=>{pc()});var rp=v(()=>{hc()});var sp=v(()=>{});var ip=v(()=>{Zf();fc();pc();rp();hc();sp()});var U=C(fe=>{"use strict";var mc=Symbol.for("yaml.alias"),op=Symbol.for("yaml.document"),hi=Symbol.for("yaml.map"),ap=Symbol.for("yaml.pair"),gc=Symbol.for("yaml.scalar"),mi=Symbol.for("yaml.seq"),ct=Symbol.for("yaml.node.type"),uS=n=>!!n&&typeof n=="object"&&n[ct]===mc,dS=n=>!!n&&typeof n=="object"&&n[ct]===op,fS=n=>!!n&&typeof n=="object"&&n[ct]===hi,pS=n=>!!n&&typeof n=="object"&&n[ct]===ap,cp=n=>!!n&&typeof n=="object"&&n[ct]===gc,hS=n=>!!n&&typeof n=="object"&&n[ct]===mi;function lp(n){if(n&&typeof n=="object")switch(n[ct]){case hi:case mi:return!0}return!1}function mS(n){if(n&&typeof n=="object")switch(n[ct]){case mc:case hi:case gc:case mi:return!0}return!1}var gS=n=>(cp(n)||lp(n))&&!!n.anchor;fe.ALIAS=mc;fe.DOC=op;fe.MAP=hi;fe.NODE_TYPE=ct;fe.PAIR=ap;fe.SCALAR=gc;fe.SEQ=mi;fe.hasAnchor=gS;fe.isAlias=uS;fe.isCollection=lp;fe.isDocument=dS;fe.isMap=fS;fe.isNode=mS;fe.isPair=pS;fe.isScalar=cp;fe.isSeq=hS});var $r=C(yc=>{"use strict";var ae=U(),ve=Symbol("break visit"),up=Symbol("skip children"),Ze=Symbol("remove node");function gi(n,e){let t=dp(e);ae.isDocument(n)?In(null,n.contents,t,Object.freeze([n]))===Ze&&(n.contents=null):In(null,n,t,Object.freeze([]))}gi.BREAK=ve;gi.SKIP=up;gi.REMOVE=Ze;function In(n,e,t,r){let s=fp(n,e,t,r);if(ae.isNode(s)||ae.isPair(s))return pp(n,r,s),In(n,s,t,r);if(typeof s!="symbol"){if(ae.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=In(i,e.items[i],t,r);if(typeof o=="number")i=o-1;else{if(o===ve)return ve;o===Ze&&(e.items.splice(i,1),i-=1)}}}else if(ae.isPair(e)){r=Object.freeze(r.concat(e));let i=In("key",e.key,t,r);if(i===ve)return ve;i===Ze&&(e.key=null);let o=In("value",e.value,t,r);if(o===ve)return ve;o===Ze&&(e.value=null)}}return s}async function yi(n,e){let t=dp(e);ae.isDocument(n)?await Nn(null,n.contents,t,Object.freeze([n]))===Ze&&(n.contents=null):await Nn(null,n,t,Object.freeze([]))}yi.BREAK=ve;yi.SKIP=up;yi.REMOVE=Ze;async function Nn(n,e,t,r){let s=await fp(n,e,t,r);if(ae.isNode(s)||ae.isPair(s))return pp(n,r,s),Nn(n,s,t,r);if(typeof s!="symbol"){if(ae.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Nn(i,e.items[i],t,r);if(typeof o=="number")i=o-1;else{if(o===ve)return ve;o===Ze&&(e.items.splice(i,1),i-=1)}}}else if(ae.isPair(e)){r=Object.freeze(r.concat(e));let i=await Nn("key",e.key,t,r);if(i===ve)return ve;i===Ze&&(e.key=null);let o=await Nn("value",e.value,t,r);if(o===ve)return ve;o===Ze&&(e.value=null)}}return s}function dp(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 fp(n,e,t,r){if(typeof t=="function")return t(n,e,r);if(ae.isMap(e))return t.Map?.(n,e,r);if(ae.isSeq(e))return t.Seq?.(n,e,r);if(ae.isPair(e))return t.Pair?.(n,e,r);if(ae.isScalar(e))return t.Scalar?.(n,e,r);if(ae.isAlias(e))return t.Alias?.(n,e,r)}function pp(n,e,t){let r=e[e.length-1];if(ae.isCollection(r))r.items[n]=t;else if(ae.isPair(r))n==="key"?r.key=t:r.value=t;else if(ae.isDocument(r))r.contents=t;else{let s=ae.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}yc.visit=gi;yc.visitAsync=yi});var bc=C(mp=>{"use strict";var hp=U(),yS=$r(),bS={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},wS=n=>n.replace(/[!,[\]{}]/g,e=>bS[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+wS(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&&hp.isNode(e.contents)){let i={};yS.visit(e.contents,(o,a)=>{hp.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:"};mp.Directives=Lr});var bi=C(Mr=>{"use strict";var gp=U(),vS=$r();function SS(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 yp(n){let e=new Set;return vS.visit(n,{Value(t,r){r.anchor&&e.add(r.anchor)}}),e}function bp(n,e){for(let t=1;;++t){let r=`${n}${t}`;if(!e.has(r))return r}}function kS(n,e){let t=[],r=new Map,s=null;return{onAnchor:i=>{t.push(i),s??(s=yp(n));let o=bp(e,s);return s.add(o),o},setAnchors:()=>{for(let i of t){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(gp.isScalar(o.node)||gp.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=SS;Mr.anchorNames=yp;Mr.createNodeAnchors=kS;Mr.findNewAnchor=bp});var wc=C(wp=>{"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)}wp.applyReviver=Br});var Et=C(Sp=>{"use strict";var xS=U();function vp(n,e,t){if(Array.isArray(n))return n.map((r,s)=>vp(r,String(s),t));if(n&&typeof n.toJSON=="function"){if(!t||!xS.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}Sp.toJS=vp});var wi=C(xp=>{"use strict";var ES=wc(),kp=U(),AS=Et(),vc=class{constructor(e){Object.defineProperty(this,kp.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(!kp.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=AS.toJS(this,"",o);if(typeof s=="function")for(let{count:c,res:l}of o.anchors.values())s(l,c);return typeof i=="function"?ES.applyReviver(i,{"":a},"",a):a}};xp.NodeBase=vc});var Dr=C(Ep=>{"use strict";var TS=bi(),PS=$r(),$n=U(),OS=wi(),CS=Et(),Sc=class extends OS.NodeBase{constructor(e){super($n.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=[],PS.visit(e,{Node:(i,o)=>{($n.isAlias(o)||$n.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 c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=r.get(o);if(a||(CS.toJS(o,null,t),a=r.get(o)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=vi(s,o,r)),a.count*a.aliasCount>i)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(e,t,r){let s=`*${this.source}`;if(e){if(TS.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 vi(n,e,t){if($n.isAlias(e)){let r=e.resolve(n),s=t&&r&&t.get(r);return s?s.count*s.aliasCount:0}else if($n.isCollection(e)){let r=0;for(let s of e.items){let i=vi(n,s,t);i>r&&(r=i)}return r}else if($n.isPair(e)){let r=vi(n,e.key,t),s=vi(n,e.value,t);return Math.max(r,s)}return 1}Ep.Alias=Sc});var re=C(kc=>{"use strict";var _S=U(),RS=wi(),IS=Et(),NS=n=>!n||typeof n!="function"&&typeof n!="object",At=class extends RS.NodeBase{constructor(e){super(_S.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:IS.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";kc.Scalar=At;kc.isScalarValue=NS});var jr=C(Tp=>{"use strict";var $S=Dr(),Zt=U(),Ap=re(),LS="tag:yaml.org,2002:";function MS(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 BS(n,e,t){if(Zt.isDocument(n)&&(n=n.contents),Zt.isNode(n))return n;if(Zt.isPair(n)){let u=t.schema[Zt.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,c;if(r&&n&&typeof n=="object"){if(c=a.get(n),c)return c.anchor??(c.anchor=s(n)),new $S.Alias(c.anchor);c={anchor:null,node:null},a.set(n,c)}e?.startsWith("!!")&&(e=LS+e.slice(2));let l=MS(n,e,o.tags);if(!l){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){let u=new Ap.Scalar(n);return c&&(c.node=u),u}l=n instanceof Map?o[Zt.MAP]:Symbol.iterator in Object(n)?o[Zt.SEQ]:o[Zt.MAP]}i&&(i(l),delete t.onTagObj);let d=l?.createNode?l.createNode(t.schema,n,t):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(t.schema,n,t):new Ap.Scalar(n);return e?d.tag=e:l.default||(d.tag=l.tag),c&&(c.node=d),d}Tp.createNode=BS});var ki=C(Si=>{"use strict";var DS=jr(),et=U(),jS=wi();function xc(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 DS.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 Pp=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done,Ec=class extends jS.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(Pp(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,xc(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,xc(this.schema,s,t));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};Si.Collection=Ec;Si.collectionFromPath=xc;Si.isEmptyPath=Pp});var Fr=C(xi=>{"use strict";var FS=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function Ac(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}var US=(n,e,t)=>n.endsWith(`
|
|
26
26
|
`)?Ac(t,e):t.includes(`
|
|
27
27
|
`)?`
|
|
28
|
-
`+Ac(t,e):(n.endsWith(" ")?"":" ")+t;
|
|
29
|
-
`)t===Tc&&(h=
|
|
30
|
-
`&&p!==" "){let
|
|
31
|
-
`&&
|
|
32
|
-
${e}${n.slice(0,
|
|
33
|
-
${e}${n.slice(
|
|
34
|
-
`);r=e,s=e+1,i=n[s]}return r}
|
|
35
|
-
`){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function
|
|
28
|
+
`+Ac(t,e):(n.endsWith(" ")?"":" ")+t;xi.indentComment=Ac;xi.lineComment=US;xi.stringifyComment=FS});var Cp=C(Ur=>{"use strict";var qS="flow",Tc="block",Ei="quoted";function JS(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 c=Math.max(1+i,1+s-e.length);if(n.length<=c)return n;let l=[],d={},u=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?l.push(0):u=s-r);let f,p,m=!1,h=-1,y=-1,x=-1;t===Tc&&(h=Op(n,h,e.length),h!==-1&&(u=h+c));for(let O;O=n[h+=1];){if(t===Ei&&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}x=h}if(O===`
|
|
29
|
+
`)t===Tc&&(h=Op(n,h,e.length)),u=h+e.length+c,f=void 0;else{if(O===" "&&p&&p!==" "&&p!==`
|
|
30
|
+
`&&p!==" "){let E=n[h+1];E&&E!==" "&&E!==`
|
|
31
|
+
`&&E!==" "&&(f=h)}if(h>=u)if(f)l.push(f),u=f+c,f=void 0;else if(t===Ei){for(;p===" "||p===" ";)p=O,O=n[h+=1],m=!0;let E=h>x+1?h-2:y-1;if(d[E])return n;l.push(E),d[E]=!0,u=E+c,f=void 0}else m=!0}p=O}if(m&&a&&a(),l.length===0)return n;o&&o();let T=n.slice(0,l[0]);for(let O=0;O<l.length;++O){let E=l[O],I=l[O+1]||n.length;E===0?T=`
|
|
32
|
+
${e}${n.slice(0,I)}`:(t===Ei&&d[E]&&(T+=`${n[E]}\\`),T+=`
|
|
33
|
+
${e}${n.slice(E+1,I)}`)}return T}function Op(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=Tc;Ur.FOLD_FLOW=qS;Ur.FOLD_QUOTED=Ei;Ur.foldFlowLines=JS});var Jr=C(_p=>{"use strict";var Fe=re(),Tt=Cp(),Ti=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),Pi=n=>/^(%|---|\.\.\.)/m.test(n);function KS(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||(Pi(n)?" ":""),o="",a=0;for(let c=0,l=t[c];l;l=t[++c])if(l===" "&&t[c+1]==="\\"&&t[c+2]==="n"&&(o+=t.slice(a,c)+"\\ ",c+=1,a=c,l="\\"),l==="\\")switch(t[c+1]){case"u":{o+=t.slice(a,c);let d=t.substr(c+2,4);switch(d){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:d.substr(0,2)==="00"?o+="\\x"+d.substr(2):o+=t.substr(c,6)}c+=5,a=c+1}break;case"n":if(r||t[c+2]==='"'||t.length<s)c+=1;else{for(o+=t.slice(a,c)+`
|
|
36
36
|
|
|
37
37
|
`;t[c+2]==="\\"&&t[c+3]==="n"&&t[c+4]!=='"';)o+=`
|
|
38
|
-
`,c+=2;o+=i,t[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+t.slice(a):t,r?o:
|
|
39
|
-
`)||/[ \t]\n|\n[ \t]/.test(n))return
|
|
40
|
-
${t}`)+"'";return e.implicitKey?r:
|
|
38
|
+
`,c+=2;o+=i,t[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+t.slice(a):t,r?o:Tt.foldFlowLines(o,i,Tt.FOLD_QUOTED,Ti(e,!1))}function Pc(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||(Pi(n)?" ":""),r="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
40
|
+
${t}`)+"'";return e.implicitKey?r:Tt.foldFlowLines(r,t,Tt.FOLD_FLOW,Ti(e,!1))}function Ln(n,e){let{singleQuote:t}=e.options,r;if(t===!1)r=qr;else{let s=n.includes('"'),i=n.includes("'");s&&!i?r=Pc:i&&!s?r=qr:r=t?Pc:qr}return r(n,e)}var Oc;try{Oc=new RegExp(`(^|(?<!
|
|
41
41
|
))
|
|
42
42
|
+(?!
|
|
43
|
-
|$)`,"g")}catch{
|
|
43
|
+
|$)`,"g")}catch{Oc=/\n+(?!\n|$)/g}function Ai({comment:n,type:e,value:t},r,s,i){let{blockQuote:o,commentString:a,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(t))return Ln(t,r);let l=r.indent||(r.forceBlockIndent||Pi(t)?" ":""),d=o==="literal"?!0:o==="folded"||e===Fe.Scalar.BLOCK_FOLDED?!1:e===Fe.Scalar.BLOCK_LITERAL?!0:!KS(t,c,l.length);if(!t)return d?`|
|
|
44
44
|
`:`>
|
|
45
|
-
`;let u,f;for(f=t.length;f>0;--f){let
|
|
46
|
-
`&&
|
|
47
|
-
`);
|
|
48
|
-
`&&(p=p.slice(0,-1)),p=p.replace(
|
|
49
|
-
`)
|
|
50
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),
|
|
51
|
-
${l}${
|
|
52
|
-
${l}${
|
|
53
|
-
`)||d&&/[[\]{},]/.test(i))return
|
|
54
|
-
`)?
|
|
55
|
-
`))return
|
|
56
|
-
${c}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:p,tags:
|
|
57
|
-
${e.indent}${a}`:a}
|
|
58
|
-
${a}:`):(
|
|
59
|
-
`:"",
|
|
60
|
-
${
|
|
61
|
-
`&&
|
|
62
|
-
|
|
63
|
-
`):
|
|
64
|
-
${t.indent}`}else if(!p&&
|
|
65
|
-
`),
|
|
66
|
-
${t.indent}`)}}else(
|
|
67
|
-
`)&&(
|
|
45
|
+
`;let u,f;for(f=t.length;f>0;--f){let I=t[f-1];if(I!==`
|
|
46
|
+
`&&I!==" "&&I!==" ")break}let p=t.substring(f),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(Oc,`$&${l}`));let h=!1,y,x=-1;for(y=0;y<t.length;++y){let I=t[y];if(I===" ")h=!0;else if(I===`
|
|
49
|
+
`)x=y;else break}let T=t.substring(0,x<y?x+1:y);T&&(t=t.substring(T.length),T=T.replace(/\n+/g,`$&${l}`));let E=(h?l?"2":"1":"")+u;if(n&&(E+=" "+a(n.replace(/ ?[\r\n]+/g," ")),s&&s()),!d){let I=t.replace(/\n+/g,`
|
|
50
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),R=!1,$=Ti(r,!0);o!=="folded"&&e!==Fe.Scalar.BLOCK_FOLDED&&($.onOverflow=()=>{R=!0});let A=Tt.foldFlowLines(`${T}${I}${p}`,l,Tt.FOLD_BLOCK,$);if(!R)return`>${E}
|
|
51
|
+
${l}${A}`}return t=t.replace(/\n+/g,`$&${l}`),`|${E}
|
|
52
|
+
${l}${T}${t}${p}`}function WS(n,e,t,r){let{type:s,value:i}=n,{actualString:o,implicitKey:a,indent:c,indentStep:l,inFlow:d}=e;if(a&&i.includes(`
|
|
53
|
+
`)||d&&/[[\]{},]/.test(i))return Ln(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||d||!i.includes(`
|
|
54
|
+
`)?Ln(i,e):Ai(n,e,t,r);if(!a&&!d&&s!==Fe.Scalar.PLAIN&&i.includes(`
|
|
55
|
+
`))return Ai(n,e,t,r);if(Pi(i)){if(c==="")return e.forceBlockIndent=!0,Ai(n,e,t,r);if(a&&c===l)return Ln(i,e)}let u=i.replace(/\n+/g,`$&
|
|
56
|
+
${c}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:p,tags:m}=e.doc.schema;if(m.some(f)||p?.some(f))return Ln(i,e)}return a?u:Tt.foldFlowLines(u,c,Tt.FOLD_FLOW,Ti(e,!1))}function HS(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!==Fe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Fe.Scalar.QUOTE_DOUBLE);let c=d=>{switch(d){case Fe.Scalar.BLOCK_FOLDED:case Fe.Scalar.BLOCK_LITERAL:return s||i?Ln(o.value,e):Ai(o,e,t,r);case Fe.Scalar.QUOTE_DOUBLE:return qr(o.value,e);case Fe.Scalar.QUOTE_SINGLE:return Pc(o.value,e);case Fe.Scalar.PLAIN:return WS(o,e,t,r);default:return null}},l=c(a);if(l===null){let{defaultKeyType:d,defaultStringType:u}=e.options,f=s&&d||u;if(l=c(f),l===null)throw new Error(`Unsupported default string type ${f}`)}return l}_p.stringifyString=HS});var Kr=C(Cc=>{"use strict";var YS=bi(),Pt=U(),VS=Fr(),zS=Jr();function GS(n,e){let t=Object.assign({blockQuote:!0,commentString:VS.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 XS(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 QS(n,e,{anchors:t,doc:r}){if(!r.directives)return"";let s=[],i=(Pt.isScalar(n)||Pt.isCollection(n))&&n.anchor;i&&YS.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 ZS(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:c=>s=c});s??(s=XS(e.doc.schema.tags,i));let o=QS(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)?zS.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}Cc.createStringifyContext=GS;Cc.stringify=ZS});var $p=C(Np=>{"use strict";var lt=U(),Rp=re(),Ip=Kr(),Wr=Fr();function ek({key:n,value:e},t,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:c,options:{commentString:l,indentSeq:d,simpleKeys:u}}=t,f=lt.isNode(n)&&n.comment||null;if(u){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(lt.isCollection(n)||!lt.isNode(n)&&typeof n=="object"){let $="With simple keys, collection cannot be used as a key value";throw new Error($)}}let p=!u&&(!n||f&&e==null&&!t.inFlow||lt.isCollection(n)||(lt.isScalar(n)?n.type===Rp.Scalar.BLOCK_FOLDED||n.type===Rp.Scalar.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!p&&(u||!i),indent:a+c});let m=!1,h=!1,y=Ip.stringify(n,t,()=>m=!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 m&&r&&r(),y===""?"?":p?`? ${y}`:y}else if(i&&!u||e==null&&p)return y=`? ${y}`,f&&!m?y+=Wr.lineComment(y,t.indent,l(f)):h&&s&&s(),y;m&&(f=null),p?(f&&(y+=Wr.lineComment(y,t.indent,l(f))),y=`? ${y}
|
|
58
|
+
${a}:`):(y=`${y}:`,f&&(y+=Wr.lineComment(y,t.indent,l(f))));let x,T,O;lt.isNode(e)?(x=!!e.spaceBefore,T=e.commentBefore,O=e.comment):(x=!1,T=null,O=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!p&&!f&<.isScalar(e)&&(t.indentAtStart=y.length+1),h=!1,!d&&c.length>=2&&!t.inFlow&&!p&<.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let E=!1,I=Ip.stringify(e,t,()=>E=!0,()=>h=!0),R=" ";if(f||x||T){if(R=x?`
|
|
59
|
+
`:"",T){let $=l(T);R+=`
|
|
60
|
+
${Wr.indentComment($,t.indent)}`}I===""&&!t.inFlow?R===`
|
|
61
|
+
`&&O&&(R=`
|
|
62
|
+
|
|
63
|
+
`):R+=`
|
|
64
|
+
${t.indent}`}else if(!p&<.isCollection(e)){let $=I[0],A=I.indexOf(`
|
|
65
|
+
`),J=A!==-1,Q=t.inFlow??e.flow??e.items.length===0;if(J||!Q){let Z=!1;if(J&&($==="&"||$==="!")){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 y+=R+I,t.inFlow?E&&r&&r():O&&!E?y+=Wr.lineComment(y,t.indent,l(O)):h&&s&&s(),y}Np.stringifyPair=ek});var Rc=C(_c=>{"use strict";var Lp=oi("process");function tk(n,...e){n==="debug"&&console.log(...e)}function nk(n,e){(n==="debug"||n==="warn")&&(typeof Lp.emitWarning=="function"?Lp.emitWarning(e):console.warn(e))}_c.debug=tk;_c.warn=nk});var Ri=C(_i=>{"use strict";var Hr=U(),Mp=re(),Oi="<<",Ci={identify:n=>n===Oi||typeof n=="symbol"&&n.description===Oi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Mp.Scalar(Symbol(Oi)),{addToJSMap:Bp}),stringify:()=>Oi},rk=(n,e)=>(Ci.identify(e)||Hr.isScalar(e)&&(!e.type||e.type===Mp.Scalar.PLAIN)&&Ci.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===Ci.tag&&t.default);function Bp(n,e,t){if(t=n&&Hr.isAlias(t)?t.resolve(n.doc):t,Hr.isSeq(t))for(let r of t.items)Ic(n,e,r);else if(Array.isArray(t))for(let r of t)Ic(n,e,r);else Ic(n,e,t)}function Ic(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}_i.addMergeToJSMap=Bp;_i.isMergeKey=rk;_i.merge=Ci});var $c=C(Fp=>{"use strict";var sk=Rc(),Dp=Ri(),ik=Kr(),jp=U(),Nc=Et();function ok(n,e,{key:t,value:r}){if(jp.isNode(t)&&t.addToJSMap)t.addToJSMap(n,e,r);else if(Dp.isMergeKey(n,t))Dp.addMergeToJSMap(n,e,r);else{let s=Nc.toJS(t,"",n);if(e instanceof Map)e.set(s,Nc.toJS(r,s,n));else if(e instanceof Set)e.add(s);else{let i=ak(t,s,n),o=Nc.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 ak(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(jp.isNode(n)&&t?.doc){let r=ik.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)+'..."'),sk.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)}Fp.addPairToJSMap=ok});var Ot=C(Lc=>{"use strict";var Up=jr(),ck=$p(),lk=$c(),Ii=U();function uk(n,e,t){let r=Up.createNode(n,void 0,t),s=Up.createNode(e,void 0,t);return new Ni(r,s)}var Ni=class n{constructor(e,t=null){Object.defineProperty(this,Ii.NODE_TYPE,{value:Ii.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;return Ii.isNode(t)&&(t=t.clone(e)),Ii.isNode(r)&&(r=r.clone(e)),new n(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return lk.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?ck.stringifyPair(this,e,t,r):JSON.stringify(this)}};Lc.Pair=Ni;Lc.createPair=uk});var Mc=C(Jp=>{"use strict";var en=U(),qp=Kr(),$i=Fr();function dk(n,e,t){return(e.inFlow??n.flow?pk:fk)(n,e,t)}function fk({comment:n,items:e},t,{blockItemPrefix:r,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:c,options:{commentString:l}}=t,d=Object.assign({},t,{indent:i,type:null}),u=!1,f=[];for(let m=0;m<e.length;++m){let h=e[m],y=null;if(en.isNode(h))!u&&h.spaceBefore&&f.push(""),Li(t,f,h.commentBefore,u),h.comment&&(y=h.comment);else if(en.isPair(h)){let T=en.isNode(h.key)?h.key:null;T&&(!u&&T.spaceBefore&&f.push(""),Li(t,f,T.commentBefore,u))}u=!1;let x=qp.stringify(h,d,()=>y=null,()=>u=!0);y&&(x+=$i.lineComment(x,i,l(y))),u&&y&&(u=!1),f.push(r+x)}let p;if(f.length===0)p=s.start+s.end;else{p=f[0];for(let m=1;m<f.length;++m){let h=f[m];p+=h?`
|
|
68
68
|
${c}${h}`:`
|
|
69
69
|
`}}return n?(p+=`
|
|
70
|
-
|
|
71
|
-
`))&&(l=!0),u.push(
|
|
70
|
+
`+$i.indentComment(l(n),c),a&&a()):u&&o&&o(),p}function pk({items:n},e,{flowChars:t,itemIndent:r}){let{indent:s,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;r+=i;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),l=!1,d=0,u=[];for(let m=0;m<n.length;++m){let h=n[m],y=null;if(en.isNode(h))h.spaceBefore&&u.push(""),Li(e,u,h.commentBefore,!1),h.comment&&(y=h.comment);else if(en.isPair(h)){let T=en.isNode(h.key)?h.key:null;T&&(T.spaceBefore&&u.push(""),Li(e,u,T.commentBefore,!1),T.comment&&(l=!0));let O=en.isNode(h.value)?h.value:null;O?(O.comment&&(y=O.comment),O.commentBefore&&(l=!0)):h.value==null&&T?.comment&&(y=T.comment)}y&&(l=!0);let x=qp.stringify(h,c,()=>y=null);m<n.length-1&&(x+=","),y&&(x+=$i.lineComment(x,r,a(y))),!l&&(u.length>d||x.includes(`
|
|
71
|
+
`))&&(l=!0),u.push(x),d=u.length}let{start:f,end:p}=t;if(u.length===0)return f+p;if(!l){let m=u.reduce((h,y)=>h+y.length+2,2);l=e.options.lineWidth>0&&m>e.options.lineWidth}if(l){let m=f;for(let h of u)m+=h?`
|
|
72
72
|
${i}${s}${h}`:`
|
|
73
|
-
`;return`${
|
|
74
|
-
${s}${p}`}else return`${f}${o}${u.join(" ")}${o}${p}`}function
|
|
75
|
-
`:" ")}return
|
|
73
|
+
`;return`${m}
|
|
74
|
+
${s}${p}`}else return`${f}${o}${u.join(" ")}${o}${p}`}function Li({indent:n,options:{commentString:e}},t,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=$i.indentComment(e(r),n);t.push(i.trimStart())}}Jp.stringifyCollection=dk});var _t=C(Dc=>{"use strict";var hk=Mc(),mk=$c(),gk=ki(),Ct=U(),Mi=Ot(),yk=re();function Yr(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 Bc=class extends gk.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=(c,l)=>{if(typeof i=="function")l=i.call(t,c,l);else if(Array.isArray(i)&&!i.includes(c))return;(l!==void 0||s)&&o.items.push(Mi.createPair(c,l,r))};if(t instanceof Map)for(let[c,l]of t)a(c,l);else if(t&&typeof t=="object")for(let c of Object.keys(t))a(c,t[c]);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 Mi.Pair(e,e?.value):r=new Mi.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`);Ct.isScalar(s.value)&&yk.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&&Ct.isScalar(s)?s.value:s)??void 0}has(e){return!!Yr(this.items,e)}set(e,t){this.add(new Mi.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)mk.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})),hk.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}};Dc.YAMLMap=Bc;Dc.findPair=Yr});var Mn=C(Wp=>{"use strict";var bk=U(),Kp=_t(),wk={collection:"map",default:!0,nodeClass:Kp.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(n,e){return bk.isMap(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>Kp.YAMLMap.from(n,e,t)};Wp.map=wk});var Rt=C(Hp=>{"use strict";var vk=jr(),Sk=Mc(),kk=ki(),Di=U(),xk=re(),Ek=Et(),jc=class extends kk.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Di.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Bi(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let r=Bi(e);if(typeof r!="number")return;let s=this.items[r];return!t&&Di.isScalar(s)?s.value:s}has(e){let t=Bi(e);return typeof t=="number"&&t<this.items.length}set(e,t){let r=Bi(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];Di.isScalar(s)&&xk.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(Ek.toJS(i,String(s++),t));return r}toString(e,t,r){return e?Sk.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 c=t instanceof Set?a:String(o++);a=s.call(t,c,a)}i.items.push(vk.createNode(a,void 0,r))}}return i}};function Bi(n){let e=Di.isScalar(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Hp.YAMLSeq=jc});var Bn=C(Vp=>{"use strict";var Ak=U(),Yp=Rt(),Tk={collection:"seq",default:!0,nodeClass:Yp.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(n,e){return Ak.isSeq(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>Yp.YAMLSeq.from(n,e,t)};Vp.seq=Tk});var Vr=C(zp=>{"use strict";var Pk=Jr(),Ok={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),Pk.stringifyString(n,e,t,r)}};zp.string=Ok});var ji=C(Qp=>{"use strict";var Gp=re(),Xp={identify:n=>n==null,createNode:()=>new Gp.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Gp.Scalar(null),stringify:({source:n},e)=>typeof n=="string"&&Xp.test.test(n)?n:e.options.nullStr};Qp.nullTag=Xp});var Fc=C(eh=>{"use strict";var Ck=re(),Zp={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new Ck.Scalar(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&Zp.test.test(n)){let r=n[0]==="t"||n[0]==="T";if(e===r)return n}return e?t.options.trueStr:t.options.falseStr}};eh.boolTag=Zp});var Dn=C(th=>{"use strict";function _k({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}th.stringifyNumber=_k});var qc=C(Fi=>{"use strict";var Rk=re(),Uc=Dn(),Ik={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:Uc.stringifyNumber},Nk={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():Uc.stringifyNumber(n)}},$k={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 Rk.Scalar(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:Uc.stringifyNumber};Fi.float=$k;Fi.floatExp=Nk;Fi.floatNaN=Ik});var Kc=C(qi=>{"use strict";var nh=Dn(),Ui=n=>typeof n=="bigint"||Number.isInteger(n),Jc=(n,e,t,{intAsBigInt:r})=>r?BigInt(n):parseInt(n.substring(e),t);function rh(n,e,t){let{value:r}=n;return Ui(r)&&r>=0?t+r.toString(e):nh.stringifyNumber(n)}var Lk={identify:n=>Ui(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>Jc(n,2,8,t),stringify:n=>rh(n,8,"0o")},Mk={identify:Ui,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>Jc(n,0,10,t),stringify:nh.stringifyNumber},Bk={identify:n=>Ui(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>Jc(n,2,16,t),stringify:n=>rh(n,16,"0x")};qi.int=Mk;qi.intHex=Bk;qi.intOct=Lk});var ih=C(sh=>{"use strict";var Dk=Mn(),jk=ji(),Fk=Bn(),Uk=Vr(),qk=Fc(),Wc=qc(),Hc=Kc(),Jk=[Dk.map,Fk.seq,Uk.string,jk.nullTag,qk.boolTag,Hc.intOct,Hc.int,Hc.intHex,Wc.floatNaN,Wc.floatExp,Wc.float];sh.schema=Jk});var ch=C(ah=>{"use strict";var Kk=re(),Wk=Mn(),Hk=Bn();function oh(n){return typeof n=="bigint"||Number.isInteger(n)}var Ji=({value:n})=>JSON.stringify(n),Yk=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:Ji},{identify:n=>n==null,createNode:()=>new Kk.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Ji},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:Ji},{identify:oh,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})=>oh(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:Ji}],Vk={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},zk=[Wk.map,Hk.seq].concat(Yk,Vk);ah.schema=zk});var Vc=C(lh=>{"use strict";var zr=oi("buffer"),Yc=re(),Gk=Jr(),Xk={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 c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);a=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Yc.Scalar.BLOCK_LITERAL),e!==Yc.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(a.length/c),d=new Array(l);for(let u=0,f=0;u<l;++u,f+=c)d[u]=a.substr(f,c);a=d.join(e===Yc.Scalar.BLOCK_LITERAL?`
|
|
75
|
+
`:" ")}return Gk.stringifyString({comment:n,type:e,value:a},r,s,i)}};lh.binary=Xk});var Hi=C(Wi=>{"use strict";var Ki=U(),zc=Ot(),Qk=re(),Zk=Rt();function uh(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 zc.Pair(new Qk.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]=Ji.isPair(r)?r:new zc.Pair(r)}}else e("Expected a sequence for this tag");return n}function lh(n,e,t){let{replacer:r}=t,s=new Vk.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,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)a=l[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=o;s.items.push(zc.createPair(a,c,t))}return s}var zk={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ch,createNode:lh};Ki.createPairs=lh;Ki.pairs=zk;Ki.resolvePairs=ch});var Qc=P(Xc=>{"use strict";var uh=J(),Gc=wt(),Wr=At(),Gk=Tt(),dh=Wi(),Gt=class n extends Gk.YAMLSeq{constructor(){super(),this.add=Wr.YAMLMap.prototype.add.bind(this),this.delete=Wr.YAMLMap.prototype.delete.bind(this),this.get=Wr.YAMLMap.prototype.get.bind(this),this.has=Wr.YAMLMap.prototype.has.bind(this),this.set=Wr.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(uh.isPair(s)?(i=Gc.toJS(s.key,"",t),o=Gc.toJS(s.value,i,t)):i=Gc.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=dh.createPairs(e,t,r),i=new this;return i.items=s.items,i}};Gt.tag="tag:yaml.org,2002:omap";var Xk={collection:"seq",identify:n=>n instanceof Map,nodeClass:Gt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){let t=dh.resolvePairs(n,e),r=[];for(let{key:s}of t.items)uh.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new Gt,t)},createNode:(n,e,t)=>Gt.from(n,e,t)};Xc.YAMLOMap=Gt;Xc.omap=Xk});var gh=P(Zc=>{"use strict";var fh=re();function ph({value:n,source:e},t){return e&&(n?hh:mh).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}var hh={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 fh.Scalar(!0),stringify:ph},mh={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 fh.Scalar(!1),stringify:ph};Zc.falseTag=mh;Zc.trueTag=hh});var yh=P(Hi=>{"use strict";var Qk=re(),el=$n(),Zk={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:el.stringifyNumber},ex={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():el.stringifyNumber(n)}},tx={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 Qk.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:el.stringifyNumber};Hi.float=tx;Hi.floatExp=ex;Hi.floatNaN=Zk});var wh=P(Yr=>{"use strict";var bh=$n(),Hr=n=>typeof n=="bigint"||Number.isInteger(n);function Yi(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 tl(n,e,t){let{value:r}=n;if(Hr(r)){let s=r.toString(e);return r<0?"-"+t+s.substr(1):t+s}return bh.stringifyNumber(n)}var nx={identify:Hr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>Yi(n,2,2,t),stringify:n=>tl(n,2,"0b")},rx={identify:Hr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>Yi(n,1,8,t),stringify:n=>tl(n,8,"0")},sx={identify:Hr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>Yi(n,0,10,t),stringify:bh.stringifyNumber},ix={identify:Hr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>Yi(n,2,16,t),stringify:n=>tl(n,16,"0x")};Yr.int=sx;Yr.intBin=nx;Yr.intHex=ix;Yr.intOct=rx});var rl=P(nl=>{"use strict";var Gi=J(),Vi=xt(),zi=At(),Xt=class n extends zi.YAMLMap{constructor(e){super(e),this.tag=n.tag}add(e){let t;Gi.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new Vi.Pair(e.key,null):t=new Vi.Pair(e,null),zi.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=zi.findPair(this.items,e);return!t&&Gi.isPair(r)?Gi.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=zi.findPair(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new Vi.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(Vi.createPair(o,null,r));return i}};Xt.tag="tag:yaml.org,2002:set";var ox={collection:"map",identify:n=>n instanceof Set,nodeClass:Xt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>Xt.from(n,e,t),resolve(n,e){if(Gi.isMap(n)){if(n.hasAllNullValues(!0))return Object.assign(new Xt,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};nl.YAMLSet=Xt;nl.set=ox});var il=P(Xi=>{"use strict";var ax=$n();function sl(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 vh(n){let{value:e}=n,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return ax.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 cx={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})=>sl(n,t),stringify:vh},lx={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=>sl(n,!1),stringify:vh},Sh={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(Sh.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),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(t,r-1,s,i||0,o||0,a||0,c),d=e[8];if(d&&d!=="Z"){let u=sl(d,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Xi.floatTime=lx;Xi.intTime=cx;Xi.timestamp=Sh});var Eh=P(xh=>{"use strict";var ux=In(),dx=Di(),fx=Nn(),px=Jr(),hx=Vc(),kh=gh(),ol=yh(),Qi=wh(),mx=Ci(),gx=Qc(),yx=Wi(),bx=rl(),al=il(),wx=[ux.map,fx.seq,px.string,dx.nullTag,kh.trueTag,kh.falseTag,Qi.intBin,Qi.intOct,Qi.int,Qi.intHex,ol.floatNaN,ol.floatExp,ol.float,hx.binary,mx.merge,gx.omap,yx.pairs,bx.set,al.intTime,al.floatTime,al.timestamp];xh.schema=wx});var $h=P(ul=>{"use strict";var Ph=In(),vx=Di(),_h=Nn(),Sx=Jr(),kx=Fc(),cl=qc(),ll=Kc(),xx=rh(),Ex=oh(),Ch=Vc(),Vr=Ci(),Rh=Qc(),Ih=Wi(),Ah=Eh(),Nh=rl(),Zi=il(),Th=new Map([["core",xx.schema],["failsafe",[Ph.map,_h.seq,Sx.string]],["json",Ex.schema],["yaml11",Ah.schema],["yaml-1.1",Ah.schema]]),Oh={binary:Ch.binary,bool:kx.boolTag,float:cl.float,floatExp:cl.floatExp,floatNaN:cl.floatNaN,floatTime:Zi.floatTime,int:ll.int,intHex:ll.intHex,intOct:ll.intOct,intTime:Zi.intTime,map:Ph.map,merge:Vr.merge,null:vx.nullTag,omap:Rh.omap,pairs:Ih.pairs,seq:_h.seq,set:Nh.set,timestamp:Zi.timestamp},Ax={"tag:yaml.org,2002:binary":Ch.binary,"tag:yaml.org,2002:merge":Vr.merge,"tag:yaml.org,2002:omap":Rh.omap,"tag:yaml.org,2002:pairs":Ih.pairs,"tag:yaml.org,2002:set":Nh.set,"tag:yaml.org,2002:timestamp":Zi.timestamp};function Tx(n,e,t){let r=Th.get(e);if(r&&!n)return t&&!r.includes(Vr.merge)?r.concat(Vr.merge):r.slice();let s=r;if(!s)if(Array.isArray(n))s=[];else{let i=Array.from(Th.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(Vr.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Oh[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(Oh).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return i.includes(a)||i.push(a),i},[])}ul.coreKnownTags=Ax;ul.getTags=Tx});var pl=P(Lh=>{"use strict";var dl=J(),Ox=In(),Px=Nn(),_x=Jr(),eo=$h(),Cx=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0,fl=class n{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?eo.getTags(e,"compat"):e?eo.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?eo.coreKnownTags:{},this.tags=eo.getTags(t,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,dl.MAP,{value:Ox.map}),Object.defineProperty(this,dl.SCALAR,{value:_x.string}),Object.defineProperty(this,dl.SEQ,{value:Px.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Cx:null}clone(){let e=Object.create(n.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Lh.Schema=fl});var Bh=P(Mh=>{"use strict";var Rx=J(),hl=jr(),zr=Lr();function Ix(n,e){let t=[],r=e.directives===!0;if(e.directives!==!1&&n.directives){let c=n.directives.toString(n);c?(t.push(c),r=!0):n.directives.docStart&&(r=!0)}r&&t.push("---");let s=hl.createStringifyContext(n,e),{commentString:i}=s.options;if(n.commentBefore){t.length!==1&&t.unshift("");let c=i(n.commentBefore);t.unshift(zr.indentComment(c,""))}let o=!1,a=null;if(n.contents){if(Rx.isNode(n.contents)){if(n.contents.spaceBefore&&r&&t.push(""),n.contents.commentBefore){let d=i(n.contents.commentBefore);t.push(zr.indentComment(d,""))}s.forceBlockIndent=!!n.comment,a=n.contents.comment}let c=a?void 0:()=>o=!0,l=hl.stringify(n.contents,s,()=>a=null,c);a&&(l+=zr.lineComment(l,"",i(a))),(l[0]==="|"||l[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${l}`:t.push(l)}else t.push(hl.stringify(n.contents,s));if(n.directives?.docEnd)if(n.comment){let c=i(n.comment);c.includes(`
|
|
78
|
-
`)?(t.push("..."),t.push(
|
|
77
|
+
${i.comment}`:r.comment}r=s}n.items[t]=Ki.isPair(r)?r:new zc.Pair(r)}}else e("Expected a sequence for this tag");return n}function dh(n,e,t){let{replacer:r}=t,s=new Zk.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,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)a=l[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=o;s.items.push(zc.createPair(a,c,t))}return s}var ex={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:uh,createNode:dh};Wi.createPairs=dh;Wi.pairs=ex;Wi.resolvePairs=uh});var Qc=C(Xc=>{"use strict";var fh=U(),Gc=Et(),Gr=_t(),tx=Rt(),ph=Hi(),tn=class n extends tx.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(fh.isPair(s)?(i=Gc.toJS(s.key,"",t),o=Gc.toJS(s.value,i,t)):i=Gc.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=ph.createPairs(e,t,r),i=new this;return i.items=s.items,i}};tn.tag="tag:yaml.org,2002:omap";var nx={collection:"seq",identify:n=>n instanceof Map,nodeClass:tn,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){let t=ph.resolvePairs(n,e),r=[];for(let{key:s}of t.items)fh.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new tn,t)},createNode:(n,e,t)=>tn.from(n,e,t)};Xc.YAMLOMap=tn;Xc.omap=nx});var bh=C(Zc=>{"use strict";var hh=re();function mh({value:n,source:e},t){return e&&(n?gh:yh).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}var gh={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 hh.Scalar(!0),stringify:mh},yh={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 hh.Scalar(!1),stringify:mh};Zc.falseTag=yh;Zc.trueTag=gh});var wh=C(Yi=>{"use strict";var rx=re(),el=Dn(),sx={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:el.stringifyNumber},ix={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():el.stringifyNumber(n)}},ox={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 rx.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:el.stringifyNumber};Yi.float=ox;Yi.floatExp=ix;Yi.floatNaN=sx});var Sh=C(Qr=>{"use strict";var vh=Dn(),Xr=n=>typeof n=="bigint"||Number.isInteger(n);function Vi(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 tl(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 vh.stringifyNumber(n)}var ax={identify:Xr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>Vi(n,2,2,t),stringify:n=>tl(n,2,"0b")},cx={identify:Xr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>Vi(n,1,8,t),stringify:n=>tl(n,8,"0")},lx={identify:Xr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>Vi(n,0,10,t),stringify:vh.stringifyNumber},ux={identify:Xr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>Vi(n,2,16,t),stringify:n=>tl(n,16,"0x")};Qr.int=lx;Qr.intBin=ax;Qr.intHex=ux;Qr.intOct=cx});var rl=C(nl=>{"use strict";var Xi=U(),zi=Ot(),Gi=_t(),nn=class n extends Gi.YAMLMap{constructor(e){super(e),this.tag=n.tag}add(e){let t;Xi.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new zi.Pair(e.key,null):t=new zi.Pair(e,null),Gi.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=Gi.findPair(this.items,e);return!t&&Xi.isPair(r)?Xi.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=Gi.findPair(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new zi.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(zi.createPair(o,null,r));return i}};nn.tag="tag:yaml.org,2002:set";var dx={collection:"map",identify:n=>n instanceof Set,nodeClass:nn,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>nn.from(n,e,t),resolve(n,e){if(Xi.isMap(n)){if(n.hasAllNullValues(!0))return Object.assign(new nn,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};nl.YAMLSet=nn;nl.set=dx});var il=C(Qi=>{"use strict";var fx=Dn();function sl(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 kh(n){let{value:e}=n,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return fx.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 px={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})=>sl(n,t),stringify:kh},hx={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=>sl(n,!1),stringify:kh},xh={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(xh.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),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(t,r-1,s,i||0,o||0,a||0,c),d=e[8];if(d&&d!=="Z"){let u=sl(d,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Qi.floatTime=hx;Qi.intTime=px;Qi.timestamp=xh});var Th=C(Ah=>{"use strict";var mx=Mn(),gx=ji(),yx=Bn(),bx=Vr(),wx=Vc(),Eh=bh(),ol=wh(),Zi=Sh(),vx=Ri(),Sx=Qc(),kx=Hi(),xx=rl(),al=il(),Ex=[mx.map,yx.seq,bx.string,gx.nullTag,Eh.trueTag,Eh.falseTag,Zi.intBin,Zi.intOct,Zi.int,Zi.intHex,ol.floatNaN,ol.floatExp,ol.float,wx.binary,vx.merge,Sx.omap,kx.pairs,xx.set,al.intTime,al.floatTime,al.timestamp];Ah.schema=Ex});var Mh=C(ul=>{"use strict";var _h=Mn(),Ax=ji(),Rh=Bn(),Tx=Vr(),Px=Fc(),cl=qc(),ll=Kc(),Ox=ih(),Cx=ch(),Ih=Vc(),Zr=Ri(),Nh=Qc(),$h=Hi(),Ph=Th(),Lh=rl(),eo=il(),Oh=new Map([["core",Ox.schema],["failsafe",[_h.map,Rh.seq,Tx.string]],["json",Cx.schema],["yaml11",Ph.schema],["yaml-1.1",Ph.schema]]),Ch={binary:Ih.binary,bool:Px.boolTag,float:cl.float,floatExp:cl.floatExp,floatNaN:cl.floatNaN,floatTime:eo.floatTime,int:ll.int,intHex:ll.intHex,intOct:ll.intOct,intTime:eo.intTime,map:_h.map,merge:Zr.merge,null:Ax.nullTag,omap:Nh.omap,pairs:$h.pairs,seq:Rh.seq,set:Lh.set,timestamp:eo.timestamp},_x={"tag:yaml.org,2002:binary":Ih.binary,"tag:yaml.org,2002:merge":Zr.merge,"tag:yaml.org,2002:omap":Nh.omap,"tag:yaml.org,2002:pairs":$h.pairs,"tag:yaml.org,2002:set":Lh.set,"tag:yaml.org,2002:timestamp":eo.timestamp};function Rx(n,e,t){let r=Oh.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(Oh.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"?Ch[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(Ch).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return i.includes(a)||i.push(a),i},[])}ul.coreKnownTags=_x;ul.getTags=Rx});var pl=C(Bh=>{"use strict";var dl=U(),Ix=Mn(),Nx=Bn(),$x=Vr(),to=Mh(),Lx=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0,fl=class n{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?to.getTags(e,"compat"):e?to.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?to.coreKnownTags:{},this.tags=to.getTags(t,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,dl.MAP,{value:Ix.map}),Object.defineProperty(this,dl.SCALAR,{value:$x.string}),Object.defineProperty(this,dl.SEQ,{value:Nx.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Lx:null}clone(){let e=Object.create(n.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Bh.Schema=fl});var jh=C(Dh=>{"use strict";var Mx=U(),hl=Kr(),es=Fr();function Bx(n,e){let t=[],r=e.directives===!0;if(e.directives!==!1&&n.directives){let c=n.directives.toString(n);c?(t.push(c),r=!0):n.directives.docStart&&(r=!0)}r&&t.push("---");let s=hl.createStringifyContext(n,e),{commentString:i}=s.options;if(n.commentBefore){t.length!==1&&t.unshift("");let c=i(n.commentBefore);t.unshift(es.indentComment(c,""))}let o=!1,a=null;if(n.contents){if(Mx.isNode(n.contents)){if(n.contents.spaceBefore&&r&&t.push(""),n.contents.commentBefore){let d=i(n.contents.commentBefore);t.push(es.indentComment(d,""))}s.forceBlockIndent=!!n.comment,a=n.contents.comment}let c=a?void 0:()=>o=!0,l=hl.stringify(n.contents,s,()=>a=null,c);a&&(l+=es.lineComment(l,"",i(a))),(l[0]==="|"||l[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${l}`:t.push(l)}else t.push(hl.stringify(n.contents,s));if(n.directives?.docEnd)if(n.comment){let c=i(n.comment);c.includes(`
|
|
78
|
+
`)?(t.push("..."),t.push(es.indentComment(c,""))):t.push(`... ${c}`)}else t.push("...");else{let c=n.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||a)&&t[t.length-1]!==""&&t.push(""),t.push(es.indentComment(i(c),"")))}return t.join(`
|
|
79
79
|
`)+`
|
|
80
|
-
`}
|
|
80
|
+
`}Dh.stringifyDocument=Bx});var ts=C(Fh=>{"use strict";var Dx=Dr(),jn=ki(),Oe=U(),jx=Ot(),Fx=Et(),Ux=pl(),qx=jh(),ml=bi(),Jx=wc(),Kx=jr(),gl=bc(),yl=class n{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Oe.NODE_TYPE,{value:Oe.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 gl.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,{[Oe.NODE_TYPE]:{value:Oe.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=Oe.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Fn(this.contents)&&this.contents.add(e)}addIn(e,t){Fn(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=ml.anchorNames(this);e.anchor=!t||r.has(t)?ml.findNewAnchor(t||"a",r):t}return new Dx.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=T=>typeof T=="number"||T instanceof String||T instanceof Number,x=t.filter(y).map(String);x.length>0&&(t=t.concat(x)),s=t}else r===void 0&&t&&(r=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:c,onTagObj:l,tag:d}=r??{},{onAnchor:u,setAnchors:f,sourceObjects:p}=ml.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:i??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:s,schema:this.schema,sourceObjects:p},h=Kx.createNode(e,d,m);return a&&Oe.isCollection(h)&&(h.flow=!0),f(),h}createPair(e,t,r={}){let s=this.createNode(e,null,r),i=this.createNode(t,null,r);return new jx.Pair(s,i)}delete(e){return Fn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return jn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Fn(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Oe.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return jn.isEmptyPath(e)?!t&&Oe.isScalar(this.contents)?this.contents.value:this.contents:Oe.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Oe.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return jn.isEmptyPath(e)?this.contents!==void 0:Oe.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=jn.collectionFromPath(this.schema,[e],t):Fn(this.contents)&&this.contents.set(e,t)}setIn(e,t){jn.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=jn.collectionFromPath(this.schema,Array.from(e),t):Fn(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 gl.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 gl.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 Ux.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},c=Fx.toJS(this.contents,t??"",a);if(typeof i=="function")for(let{count:l,res:d}of a.anchors.values())i(d,l);return typeof o=="function"?Jx.applyReviver(o,{"":c},"",c):c}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 qx.stringifyDocument(this,e)}};function Fn(n){if(Oe.isCollection(n))return!0;throw new Error("Expected a YAML collection as document contents")}Fh.Document=yl});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}},bl=class extends ns{constructor(e,t,r){super("YAMLParseError",e,t,r)}},wl=class extends ns{constructor(e,t,r){super("YAMLWarning",e,t,r)}},Wx=(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,c=t.linePos[1];c?.line===r&&c.col>s&&(a=Math.max(1,Math.min(c.col-s,80-i)));let l=" ".repeat(i)+"^".repeat(a);t.message+=`:
|
|
82
82
|
|
|
83
83
|
${o}
|
|
84
84
|
${l}
|
|
85
|
-
`}};
|
|
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(vl(e.key)||vl(e.value))return!0}return!1;default:return!0}}
|
|
87
|
-
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||
|
|
88
|
-
`+
|
|
89
|
-
`+
|
|
90
|
-
|
|
91
|
-
`+
|
|
92
|
-
`+
|
|
93
|
-
`.repeat(Math.max(1,o.length-1)):"",
|
|
94
|
-
`;for(let h=d;h<a;++h){let[
|
|
95
|
-
`):
|
|
85
|
+
`}};rs.YAMLError=ns;rs.YAMLParseError=bl;rs.YAMLWarning=wl;rs.prettifyError=Wx});var is=C(Uh=>{"use strict";function Hx(n,{flow:e,indicator:t,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let c=!1,l=a,d=a,u="",f="",p=!1,m=!1,h=null,y=null,x=null,T=null,O=null,E=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&&(l&&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),d=!0;break;case"comment":{d||i(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let J=A.source.substring(1)||" ";u?u+=f+J:u=J,f="",l=!1;break}case"newline":l?u?u+=A.source:(!E||t!=="seq-item-ind")&&(c=!0):f+=A.source,l=!0,p=!0,(y||x)&&(T=A),d=!0;break;case"anchor":y&&i(A,"MULTIPLE_ANCHORS","A node can have at most one anchor"),A.source.endsWith(":")&&i(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=A,I??(I=A.offset),l=!1,d=!1,m=!0;break;case"tag":{x&&i(A,"MULTIPLE_TAGS","A node can have at most one tag"),x=A,I??(I=A.offset),l=!1,d=!1,m=!0;break}case t:(y||x)&&i(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`),E&&i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${e??"collection"}`),E=A,l=t==="seq-item-ind"||t==="explicit-key-ind",d=!1;break;case"comma":if(e){O&&i(A,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),O=A,l=!1,d=!1;break}default:i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),l=!1,d=!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&&(l&&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:E,spaceBefore:c,comment:u,hasNewline:p,anchor:y,tag:x,newlineAfterProp:T,end:$,start:I??$}}Uh.resolveProps=Hx});var no=C(qh=>{"use strict";function vl(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(vl(e.key)||vl(e.value))return!0}return!1;default:return!0}}qh.containsNewline=vl});var Sl=C(Jh=>{"use strict";var Yx=no();function Vx(n,e,t){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===n&&(r.source==="]"||r.source==="}")&&Yx.containsNewline(e)&&t(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Jh.flowIndentCheck=Vx});var kl=C(Wh=>{"use strict";var Kh=U();function zx(n,e,t){let{uniqueKeys:r}=n.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||Kh.isScalar(i)&&Kh.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,t))}Wh.mapIncludes=zx});var Xh=C(Gh=>{"use strict";var Hh=Ot(),Gx=_t(),Yh=is(),Xx=no(),Vh=Sl(),Qx=kl(),zh="All mapping items must start at the same column";function Zx({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=i?.nodeClass??Gx.YAMLMap,a=new o(t.schema);t.atRoot&&(t.atRoot=!1);let c=r.offset,l=null;for(let d of r.items){let{start:u,key:f,sep:p,value:m}=d,h=Yh.resolveProps(u,{indicator:"explicit-key-ind",next:f??p?.[0],offset:c,onError:s,parentIndent:r.indent,startOnNewline:!0}),y=!h.found;if(y){if(f&&(f.type==="block-seq"?s(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==r.indent&&s(c,"BAD_INDENT",zh)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(a.comment?a.comment+=`
|
|
87
|
+
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||Xx.containsNewline(f))&&s(f??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&s(c,"BAD_INDENT",zh);t.atKey=!0;let x=h.end,T=f?n(t,f,h,s):e(t,x,u,null,h,s);t.schema.compat&&Vh.flowIndentCheck(r.indent,f,s),t.atKey=!1,Qx.mapIncludes(t,a.items,T)&&s(x,"DUPLICATE_KEY","Map keys must be unique");let O=Yh.resolveProps(p??[],{indicator:"map-value-ind",next:m,offset:T.range[2],onError:s,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=O.end,O.found){y&&(m?.type==="block-map"&&!O.hasNewline&&s(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&h.start<O.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 E=m?n(t,m,O,s):e(t,c,p,null,O,s);t.schema.compat&&Vh.flowIndentCheck(r.indent,m,s),c=E.range[2];let I=new Hh.Pair(T,E);t.options.keepSourceTokens&&(I.srcToken=d),a.items.push(I)}else{y&&s(T.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),O.comment&&(T.comment?T.comment+=`
|
|
88
|
+
`+O.comment:T.comment=O.comment);let E=new Hh.Pair(T);t.options.keepSourceTokens&&(E.srcToken=d),a.items.push(E)}}return l&&l<c&&s(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,c,l??c],a}Gh.resolveBlockMap=Zx});var Zh=C(Qh=>{"use strict";var e0=Rt(),t0=is(),n0=Sl();function r0({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=i?.nodeClass??e0.YAMLSeq,a=new o(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let c=r.offset,l=null;for(let{start:d,value:u}of r.items){let f=t0.resolveProps(d,{indicator:"seq-item-ind",next:u,offset:c,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||u)u?.type==="block-seq"?s(f.end,"BAD_INDENT","All sequence items must start at the same column"):s(c,"MISSING_CHAR","Sequence item without - indicator");else{l=f.end,f.comment&&(a.comment=f.comment);continue}let p=u?n(t,u,f,s):e(t,f.end,d,null,f,s);t.schema.compat&&n0.flowIndentCheck(r.indent,u,s),c=p.range[2],a.items.push(p)}return a.range=[r.offset,c,l??c],a}Qh.resolveBlockSeq=r0});var Un=C(em=>{"use strict";function s0(n,e,t,r){let s="";if(n){let i=!1,o="";for(let a of n){let{source:c,type:l}=a;switch(l){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 d=c.substring(1)||" ";s?s+=o+d:s=d,o="";break}case"newline":s&&(o+=c),i=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:s,offset:e}}em.resolveEnd=s0});var sm=C(rm=>{"use strict";var i0=U(),o0=Ot(),tm=_t(),a0=Rt(),c0=Un(),nm=is(),l0=no(),u0=kl(),xl="Block collections are not allowed within flow collections",El=n=>n&&(n.type==="block-map"||n.type==="block-seq");function d0({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",c=i?.nodeClass??(o?tm.YAMLMap:a0.YAMLSeq),l=new c(t.schema);l.flow=!0;let d=t.atRoot;d&&(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 x=r.items[y],{start:T,key:O,sep:E,value:I}=x,R=nm.resolveProps(T,{flow:a,indicator:"explicit-key-ind",next:O??E?.[0],offset:u,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!R.found){if(!R.anchor&&!R.tag&&!E&&!I){y===0&&R.comma?s(R.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):y<r.items.length-1&&s(R.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),R.comment&&(l.comment?l.comment+=`
|
|
89
|
+
`+R.comment:l.comment=R.comment),u=R.end;continue}!o&&t.options.strict&&l0.containsNewline(O)&&s(O,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===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=l.items[l.items.length-1];i0.isPair(A)&&(A=A.value??A.key),A.comment?A.comment+=`
|
|
90
|
+
`+$:A.comment=$,R.comment=R.comment.substring($.length+1)}}if(!o&&!E&&!R.found){let $=I?n(t,I,R,s):e(t,R.end,E,null,R,s);l.items.push($),u=$.range[2],El(I)&&s($.range,"BLOCK_IN_FLOW",xl)}else{t.atKey=!0;let $=R.end,A=O?n(t,O,R,s):e(t,$,T,null,R,s);El(O)&&s(A.range,"BLOCK_IN_FLOW",xl),t.atKey=!1;let J=nm.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:I,offset:A.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(J.found){if(!o&&!R.found&&t.options.strict){if(E)for(let F of E){if(F===J.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<J.found.offset-1024&&s(J.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(J.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let Q=I?n(t,I,J,s):J.found?e(t,J.end,E,null,J,s):null;Q?El(I)&&s(Q.range,"BLOCK_IN_FLOW",xl):J.comment&&(A.comment?A.comment+=`
|
|
91
|
+
`+J.comment:A.comment=J.comment);let Z=new o0.Pair(A,Q);if(t.options.keepSourceTokens&&(Z.srcToken=x),o){let F=l;u0.mapIncludes(t,F.items,A)&&s($,"DUPLICATE_KEY","Map keys must be unique"),F.items.push(Z)}else{let F=new tm.YAMLMap(t.schema);F.flow=!0,F.items.push(Z);let ye=(Q??A).range;F.range=[A.range[0],ye[1],ye[2]],l.items.push(F)}u=Q?Q.range[2]:J.end}}let f=o?"}":"]",[p,...m]=r.end,h=u;if(p?.source===f)h=p.offset+p.source.length;else{let y=a[0].toUpperCase()+a.substring(1),x=d?`${y} must end with a ${f}`:`${y} in block collection must be sufficiently indented and end with a ${f}`;s(u,d?"MISSING_CHAR":"BAD_INDENT",x),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){let y=c0.resolveEnd(m,h,t.options.strict,s);y.comment&&(l.comment?l.comment+=`
|
|
92
|
+
`+y.comment:l.comment=y.comment),l.range=[r.offset,h,y.offset]}else l.range=[r.offset,h,h];return l}rm.resolveFlowCollection=d0});var om=C(im=>{"use strict";var f0=U(),p0=re(),h0=_t(),m0=Rt(),g0=Xh(),y0=Zh(),b0=sm();function Al(n,e,t,r,s,i){let o=t.type==="block-map"?g0.resolveBlockMap(n,e,t,r,i):t.type==="block-seq"?y0.resolveBlockSeq(n,e,t,r,i):b0.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 w0(n,e,t,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,f=>s(i,"TAG_RESOLVE_FAILED",f)):null;if(t.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,m=f&&i?f.offset>i.offset?f:i:f??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===h0.YAMLMap.tagName&&a==="map"||o===m0.YAMLSeq.tagName&&a==="seq")return Al(n,e,t,s,o);let c=e.schema.tags.find(f=>f.tag===o&&f.collection===a);if(!c){let f=e.schema.knownTags[o];if(f?.collection===a)e.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?s(i,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Al(n,e,t,s,o)}let l=Al(n,e,t,s,o,c),d=c.resolve?.(l,f=>s(i,"TAG_RESOLVE_FAILED",f),e.options)??l,u=f0.isNode(d)?d:new p0.Scalar(d);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}im.composeCollection=w0});var Pl=C(am=>{"use strict";var Tl=re();function v0(n,e,t){let r=e.offset,s=S0(e,n.options.strict,t);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?Tl.Scalar.BLOCK_FOLDED:Tl.Scalar.BLOCK_LITERAL,o=e.source?k0(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 c=e.indent+s.indent,l=e.offset+s.length,d=0;for(let h=0;h<a;++h){let[y,x]=o[h];if(x===""||x==="\r")s.indent===0&&y.length>c&&(c=y.length);else{y.length<c&&t(l+y.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(c=y.length),d=h,c===0&&!n.atRoot&&t(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=y.length+x.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>c&&(a=h+1);let u="",f="",p=!1;for(let h=0;h<d;++h)u+=o[h][0].slice(c)+`
|
|
94
|
+
`;for(let h=d;h<a;++h){let[y,x]=o[h];l+=y.length+x.length+1;let T=x[x.length-1]==="\r";if(T&&(x=x.slice(0,-1)),x&&y.length<c){let E=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;t(l-x.length-(T?2:1),"BAD_INDENT",E),y=""}i===Tl.Scalar.BLOCK_LITERAL?(u+=f+y.slice(c)+x,f=`
|
|
95
|
+
`):y.length>c||x[0]===" "?(f===" "?f=`
|
|
96
96
|
`:!p&&f===`
|
|
97
97
|
`&&(f=`
|
|
98
98
|
|
|
99
|
-
`),u+=f+
|
|
100
|
-
`,p=!0):
|
|
99
|
+
`),u+=f+y.slice(c)+x,f=`
|
|
100
|
+
`,p=!0):x===""?f===`
|
|
101
101
|
`?u+=`
|
|
102
102
|
`:f=`
|
|
103
|
-
`:(u+=f+
|
|
103
|
+
`:(u+=f+x,f=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let h=a;h<o.length;++h)u+=`
|
|
104
104
|
`+o[h][0].slice(c);u[u.length-1]!==`
|
|
105
105
|
`&&(u+=`
|
|
106
106
|
`);break;default:u+=`
|
|
107
|
-
`}let
|
|
107
|
+
`}let m=r+s.length+e.source.length;return{value:u,type:i,comment:s.comment,range:[r,m,m]}}function S0({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="",c=-1;for(let f=1;f<s.length;++f){let p=s[f];if(!a&&(p==="-"||p==="+"))a=p;else{let m=Number(p);!o&&m?o=m:c===-1&&(c=n+f)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let l=!1,d="",u=s.length;for(let f=1;f<e.length;++f){let p=e[f];switch(p.type){case"space":l=!0;case"newline":u+=p.source.length;break;case"comment":t&&!l&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,d=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:d,length:u}}function k0(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}am.resolveBlockScalar=v0});var Cl=C(lm=>{"use strict";var Ol=re(),x0=Un();function E0(n,e,t){let{offset:r,type:s,source:i,end:o}=n,a,c,l=(f,p,m)=>t(r+f,p,m);switch(s){case"scalar":a=Ol.Scalar.PLAIN,c=A0(i,l);break;case"single-quoted-scalar":a=Ol.Scalar.QUOTE_SINGLE,c=T0(i,l);break;case"double-quoted-scalar":a=Ol.Scalar.QUOTE_DOUBLE,c=P0(i,l);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 d=r+i.length,u=x0.resolveEnd(o,d,e,t);return{value:c,type:a,comment:u.comment,range:[r,d,u.offset]}}function A0(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}`),cm(n)}function T0(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),cm(n.slice(1,-1)).replace(/''/g,"'")}function cm(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
|
|
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 P0(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}=
|
|
113
|
+
`){let{fold:i,offset:o}=O0(n,r);t+=i,r=o}else if(s==="\\"){let i=n[++r],o=C0[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+=
|
|
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+=_0(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
|
|
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 O0(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
|
|
122
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
121
|
+
`),e+=1,r=n[e+1];return t||(t=" "),{fold:t,offset:e}}var C0={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 _0(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)}lm.resolveFlowScalar=E0});var fm=C(dm=>{"use strict";var rn=U(),um=re(),R0=Pl(),I0=Cl();function N0(n,e,t,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?R0.resolveBlockScalar(n,e,r):I0.resolveFlowScalar(e,n.options.strict,r),c=t?n.directives.tagName(t.source,u=>r(t,"TAG_RESOLVE_FAILED",u)):null,l;n.options.stringKeys&&n.atKey?l=n.schema[rn.SCALAR]:c?l=$0(n.schema,s,c,t,r):e.type==="scalar"?l=L0(n,s,e,r):l=n.schema[rn.SCALAR];let d;try{let u=l.resolve(s,f=>r(t??e,"TAG_RESOLVE_FAILED",f),n.options);d=rn.isScalar(u)?u:new um.Scalar(u)}catch(u){let f=u instanceof Error?u.message:String(u);r(t??e,"TAG_RESOLVE_FAILED",f),d=new um.Scalar(s)}return d.range=a,d.source=s,i&&(d.type=i),c&&(d.tag=c),l.format&&(d.format=l.format),o&&(d.comment=o),d}function $0(n,e,t,r,s){if(t==="!")return n[rn.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[rn.SCALAR])}function L0({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[rn.SCALAR];if(t.compat){let a=t.compat.find(c=>c.default&&c.test?.test(r))??t[rn.SCALAR];if(o.tag!==a.tag){let c=e.tagString(o.tag),l=e.tagString(a.tag),d=`Value may be parsed as either ${c} or ${l}`;i(s,"TAG_RESOLVE_FAILED",d,!0)}}return o}dm.composeScalar=N0});var hm=C(pm=>{"use strict";function M0(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}pm.emptyScalarPosition=M0});var ym=C(Rl=>{"use strict";var B0=Dr(),D0=U(),j0=om(),mm=fm(),F0=Un(),U0=hm(),q0={composeNode:gm,composeEmptyNode:_l};function gm(n,e,t,r){let s=n.atKey,{spaceBefore:i,comment:o,anchor:a,tag:c}=t,l,d=!0;switch(e.type){case"alias":l=J0(n,e,r),(a||c)&&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":l=mm.composeScalar(n,e,c,r),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":l=j0.composeCollection(q0,n,e,t,r),a&&(l.anchor=a.source.substring(1));break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",u),l=_l(n,e.offset,void 0,null,t,r),d=!1}}return a&&l.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&n.options.stringKeys&&(!D0.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(l.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?l.comment=o:l.commentBefore=o),n.options.keepSourceTokens&&d&&(l.srcToken=e),l}function _l(n,e,t,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:c},l){let d={type:"scalar",offset:U0.emptyScalarPosition(e,t,r),indent:-1,source:""},u=mm.composeScalar(n,d,a,l);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(u.spaceBefore=!0),i&&(u.comment=i,u.range[2]=c),u}function J0({options:n},{offset:e,source:t,end:r},s){let i=new B0.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=F0.resolveEnd(r,o,n.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Rl.composeEmptyNode=_l;Rl.composeNode=gm});var vm=C(wm=>{"use strict";var K0=ts(),bm=ym(),W0=Un(),H0=is();function Y0(n,e,{offset:t,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},n),c=new K0.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=H0.resolveProps(r,{indicator:"doc-start",next:s??i?.[0],offset:t,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=s?bm.composeNode(l,s,d,o):bm.composeEmptyNode(l,d.end,r,null,d,o);let u=c.contents.range[2],f=W0.resolveEnd(i,u,!1,o);return f.comment&&(c.comment=f.comment),c.range=[t,u,f.offset],c}wm.composeDoc=Y0});var Nl=C(xm=>{"use strict";var V0=oi("process"),z0=bc(),G0=ts(),os=ss(),Sm=U(),X0=vm(),Q0=Un();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 km(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 Il=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,s,i)=>{let o=
|
|
126
|
-
${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(
|
|
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 Il=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 z0.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:s}=km(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(Sm.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];Sm.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:
|
|
129
|
-
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new
|
|
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:km(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(V0.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=X0.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=Q0.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 G0.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}}};xm.Composer=Il});var Tm=C(ro=>{"use strict";var Z0=Pl(),eE=Cl(),tE=ss(),Em=Jr();function nE(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 tE.YAMLParseError([a,a+1],i,o)};switch(n.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return eE.resolveFlowScalar(n,e,r);case"block-scalar":return Z0.resolveBlockScalar({options:{strict:e}},n,r)}}return null}function rE(n,e){let{implicitKey:t=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=Em.stringifyString({type:o,value:n},{implicitKey:t,indent:r>0?" ".repeat(r):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:r,source:`
|
|
130
130
|
`}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
|
|
131
131
|
`),d=a.substring(0,l),u=a.substring(l+1)+`
|
|
132
|
-
`,f=[{type:"block-scalar-header",offset:i,indent:r,source:d}];return
|
|
133
|
-
`}),{type:"block-scalar",offset:i,indent:r,props:f,source:u}}case'"':return{type:"double-quoted-scalar",offset:i,indent:r,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:r,source:a,end:c};default:return{type:"scalar",offset:i,indent:r,source:a,end:c}}}function
|
|
132
|
+
`,f=[{type:"block-scalar-header",offset:i,indent:r,source:d}];return Am(f,c)||f.push({type:"newline",offset:-1,indent:r,source:`
|
|
133
|
+
`}),{type:"block-scalar",offset:i,indent:r,props:f,source:u}}case'"':return{type:"double-quoted-scalar",offset:i,indent:r,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:r,source:a,end:c};default:return{type:"scalar",offset:i,indent:r,source:a,end:c}}}function sE(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 l=n.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=Em.stringifyString({type:o,value:e},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":iE(n,c);break;case'"':$l(n,c,"double-quoted-scalar");break;case"'":$l(n,c,"single-quoted-scalar");break;default:$l(n,c,"scalar")}}function iE(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}];
|
|
136
|
-
`});for(let c of Object.keys(n))c!=="type"&&c!=="offset"&&delete n[c];Object.assign(n,{type:"block-scalar",indent:o,props:a,source:s})}}function
|
|
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})}}}
|
|
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}];Am(a,"end"in n?n.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
|
|
136
|
+
`});for(let c of Object.keys(n))c!=="type"&&c!=="offset"&&delete n[c];Object.assign(n,{type:"block-scalar",indent:o,props:a,source:s})}}function Am(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 $l(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})}}}ro.createScalarToken=rE;ro.resolveAsScalar=nE;ro.setScalarValue=sE});var Om=C(Pm=>{"use strict";var oE=n=>"type"in n?io(n):so(n);function io(n){switch(n.type){case"block-scalar":{let e="";for(let t of n.props)e+=io(t);return e+n.source}case"block-map":case"block-seq":{let e="";for(let t of n.items)e+=so(t);return e}case"flow-collection":{let e=n.start.source;for(let t of n.items)e+=so(t);for(let t of n.end)e+=t.source;return e}case"document":{let e=so(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 so({start:n,key:e,sep:t,value:r}){let s="";for(let i of n)s+=i.source;if(e&&(s+=io(e)),t)for(let i of t)s+=i.source;return r&&(s+=io(r)),s}Pm.stringify=oE});var Im=C(Rm=>{"use strict";var Ll=Symbol("break visit"),aE=Symbol("skip children"),Cm=Symbol("remove item");function sn(n,e){"type"in n&&n.type==="document"&&(n={start:n.start,value:n.value}),_m(Object.freeze([]),n,e)}sn.BREAK=Ll;sn.SKIP=aE;sn.REMOVE=Cm;sn.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};sn.parentCollection=(n,e)=>{let t=sn.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 _m(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=_m(Object.freeze(n.concat([[s,o]])),i.items[o],t);if(typeof a=="number")o=a-1;else{if(a===Ll)return Ll;a===Cm&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,n))}}return typeof r=="function"?r(e,n):r}Rm.visit=sn});var oo=C(Se=>{"use strict";var Ml=Tm(),cE=Om(),lE=Im(),Bl="\uFEFF",Dl="",jl="",Fl="",uE=n=>!!n&&"items"in n,dE=n=>!!n&&(n.type==="scalar"||n.type==="single-quoted-scalar"||n.type==="double-quoted-scalar"||n.type==="block-scalar");function fE(n){switch(n){case Bl:return"<BOM>";case Dl:return"<DOC>";case jl:return"<FLOW_END>";case Fl:return"<SCALAR>";default:return JSON.stringify(n)}}function pE(n){switch(n){case Bl:return"byte-order-mark";case Dl:return"doc-mode";case jl:return"flow-error-end";case Fl: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}
|
|
140
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
141
|
-
\r `),Ul=n=>!n||
|
|
139
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(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=Ml.createScalarToken;Se.resolveAsScalar=Ml.resolveAsScalar;Se.setScalarValue=Ml.setScalarValue;Se.stringify=cE.stringify;Se.visit=lE.visit;Se.BOM=Bl;Se.DOCUMENT=Dl;Se.FLOW_END=jl;Se.SCALAR=Fl;Se.isCollection=uE;Se.isScalar=dE;Se.prettyToken=fE;Se.tokenType=pE});var Jl=C($m=>{"use strict";var cs=oo();function Ue(n){switch(n){case void 0:case" ":case`
|
|
140
|
+
`:case"\r":case" ":return!0;default:return!1}}var Nm=new Set("0123456789ABCDEFabcdef"),hE=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ao=new Set(",[]{}"),mE=new Set(` ,[]{}
|
|
141
|
+
\r `),Ul=n=>!n||mE.has(n),ql=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==="...")&&
|
|
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]===
|
|
145
|
+
`||r>=this.indentNext||!t&&!this.atEnd?e+r:-1}if(t==="-"||t==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&Ue(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]===cs.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 cs.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==="...")&&Ue(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&&!Ue(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===":")&&Ue(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(Ul),"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("..."))&&Ue(s[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield cs.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(Ul),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Ue(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=>
|
|
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=>Ue(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
|
|
153
|
+
`&&i>=this.pos&&i+1+t>a)e=i;else break}while(!0);return yield cs.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(Ue(i)||e&&ao.has(i))break;t=r}else if(Ue(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&&
|
|
156
|
-
`){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&
|
|
155
|
+
`,i=this.buffer[r+1]):t=r),i==="#"||e&&ao.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&&ao.has(s))break;t=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield cs.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(Ul))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,t=this.charAt(1);if(Ue(t)||e&&ao.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(;!Ue(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(hE.has(t))t=this.buffer[++e];else if(t==="%"&&Nm.has(this.buffer[e+1])&&Nm.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)}}
|
|
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)}};$m.Lexer=ql});var Wl=C(Lm=>{"use strict";var Kl=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}}}};Lm.LineCounter=Kl});var Yl=C(Fm=>{"use strict";var gE=oi("process"),Mm=oo(),yE=Jl();function It(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function Bm(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 jm(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 qn(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 Dm(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,jm(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 Hl=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 yE.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,gE.env.LOG_TOKENS&&console.log("|",Mm.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Mm.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"&&Dm(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&&Bm(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":{Bm(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=qn(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 c=t.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.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(
|
|
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 c=t.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.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(jm(t.key)&&!It(t.sep,"newline")){let o=qn(t.start),a=t.key,c=t.sep;c.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:c}]})}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=qn(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=co(r),i=qn(s);Dm(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=
|
|
163
|
-
`),t=e.trim();if(
|
|
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=qn(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=qn(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())}}};Fm.Parser=Hl});var Wm=C(us=>{"use strict";var Um=Nl(),bE=ts(),ls=ss(),wE=Rc(),vE=U(),SE=Wl(),qm=Yl();function Jm(n){let e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new SE.LineCounter||null,prettyErrors:e}}function kE(n,e={}){let{lineCounter:t,prettyErrors:r}=Jm(e),s=new qm.Parser(t?.addNewLine),i=new Um.Composer(e),o=Array.from(i.compose(s.parse(n)));if(r&&t)for(let a of o)a.errors.forEach(ls.prettifyError(n,t)),a.warnings.forEach(ls.prettifyError(n,t));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Km(n,e={}){let{lineCounter:t,prettyErrors:r}=Jm(e),s=new qm.Parser(t?.addNewLine),i=new Um.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 ls.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&t&&(o.errors.forEach(ls.prettifyError(n,t)),o.warnings.forEach(ls.prettifyError(n,t))),o}function xE(n,e,t){let r;typeof e=="function"?r=e:t===void 0&&e&&typeof e=="object"&&(t=e);let s=Km(n,t);if(!s)return null;if(s.warnings.forEach(i=>wE.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 EE(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 vE.isDocument(n)&&!r?n.toString(t):new bE.Document(n,r,t).toString(t)}us.parse=xE;us.parseAllDocuments=kE;us.parseDocument=Km;us.stringify=EE});var Ym=C(K=>{"use strict";var AE=Nl(),TE=ts(),PE=pl(),Vl=ss(),OE=Dr(),Nt=U(),CE=Ot(),_E=re(),RE=_t(),IE=Rt(),NE=oo(),$E=Jl(),LE=Wl(),ME=Yl(),lo=Wm(),Hm=$r();K.Composer=AE.Composer;K.Document=TE.Document;K.Schema=PE.Schema;K.YAMLError=Vl.YAMLError;K.YAMLParseError=Vl.YAMLParseError;K.YAMLWarning=Vl.YAMLWarning;K.Alias=OE.Alias;K.isAlias=Nt.isAlias;K.isCollection=Nt.isCollection;K.isDocument=Nt.isDocument;K.isMap=Nt.isMap;K.isNode=Nt.isNode;K.isPair=Nt.isPair;K.isScalar=Nt.isScalar;K.isSeq=Nt.isSeq;K.Pair=CE.Pair;K.Scalar=_E.Scalar;K.YAMLMap=RE.YAMLMap;K.YAMLSeq=IE.YAMLSeq;K.CST=NE;K.Lexer=$E.Lexer;K.LineCounter=LE.LineCounter;K.Parser=ME.Parser;K.parse=lo.parse;K.parseAllDocuments=lo.parseAllDocuments;K.parseDocument=lo.parseDocument;K.stringify=lo.stringify;K.visit=Hm.visit;K.visitAsync=Hm.visitAsync});function DE(n){try{return JSON.parse(n.trim()),!0}catch{return!1}}function jE(n){let e=n.trim();if(!e.startsWith("<"))return!1;let t=e.match(BE);return t?Nr(e,t[1])!==null:!1}function FE(n){let e=n.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let t=Vm.parse(e);return t!==null&&typeof t=="object"}catch{return!1}}function zm(n){return DE(n)||jE(n)||FE(n)}var Vm,BE,zl=v(()=>{ip();Vm=Kv(Ym(),1),BE=/<([a-zA-Z_][\w.-]*)/});function UE(n){if(!n?.trim())return[];let e=n.replace(/\r\n/g,`
|
|
163
|
+
`),t=e.trim();if(zm(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,c=()=>{if(o>=i){let l=r.slice(i,o+1).join(`
|
|
166
|
-
`).trim();l&&s.push({text:l,startLine:i+1,endLine:o+1})}};for(let l=0;l<r.length;l++)r[l].trim()?(a>=2&&o>=i&&(c(),i=l),a=0,o=l):a++;return c(),s}function
|
|
166
|
+
`).trim();l&&s.push({text:l,startLine:i+1,endLine:o+1})}};for(let l=0;l<r.length;l++)r[l].trim()?(a>=2&&o>=i&&(c(),i=l),a=0,o=l):a++;return c(),s}function uo(n){return UE(n).map(e=>e.text)}var Gm,Xm=v(()=>{zl();Gm=`
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
`});function uo(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Gm=v(()=>{});var BE,DE,Gl,Xm=v(()=>{BE=[["\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","-"]],DE=new Map(BE),Gl=DE});var Qm,fo,Xl,Zm=v(()=>{Qm=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],fo={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:Qm,nb:Qm,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(fo))fo[n]=new Map(fo[n]);Xl=fo});function Ql(n,e){if(typeof n!="string")throw new TypeError(`Expected a string, got \`${typeof n}\``);e={customReplacements:[],...e};let t=FE(e.locale),r=Gl,s=e.customReplacements.length>0||e.customReplacements.size>0;if(t||s){if(r=new Map(Gl),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=jE(n,r),n=n.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),n=n.replaceAll(/\p{Dash_Punctuation}/gu,"-"),n}var jE,FE,eg=v(()=>{Xm();Zm();jE=(n,e)=>{for(let[t,r]of e)n=n.replaceAll(t,r);return n},FE=n=>{if(!n)return;let e=n.toLowerCase().replace(/^no(-|$)/,"nb$1");return Xl[e]||Xl[e.split("-")[0]]||void 0}});var UE,tg,ng=v(()=>{UE=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],tg=UE});function Zl(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([...tg,...e.customReplacements]);n=Ql(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=qE(n));let s=KE(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=JE(n,e.separator)),t&&(n=`_${n}`),r&&(n=`${n}-`),n}var qE,JE,KE,rg=v(()=>{Gm();eg();ng();qE=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"),JE=(n,e)=>{let t=uo(e);return n.replaceAll(new RegExp(`(?:${t}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${t})|(?:${t})$`,"g"),"")},KE=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+=uo(r)}let t=n.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,t)}});function jn(n){return Zl(n)}var sg=v(()=>{rg()});var Fn,ig,og=v(()=>{Fn={local:"local",ide:"ide",published:"published",inline:"inline"},ig=Object.values(Fn).map(n=>`'${n}'`).join(" | ")});var os,eu,ag=v(()=>{os=` *, *::before, *::after { box-sizing: border-box; }
|
|
169
|
+
`});function fo(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Qm=v(()=>{});var qE,JE,Gl,Zm=v(()=>{qE=[["\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","-"]],JE=new Map(qE),Gl=JE});var eg,po,Xl,tg=v(()=>{eg=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],po={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:eg,nb:eg,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(po))po[n]=new Map(po[n]);Xl=po});function Ql(n,e){if(typeof n!="string")throw new TypeError(`Expected a string, got \`${typeof n}\``);e={customReplacements:[],...e};let t=WE(e.locale),r=Gl,s=e.customReplacements.length>0||e.customReplacements.size>0;if(t||s){if(r=new Map(Gl),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=KE(n,r),n=n.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),n=n.replaceAll(/\p{Dash_Punctuation}/gu,"-"),n}var KE,WE,ng=v(()=>{Zm();tg();KE=(n,e)=>{for(let[t,r]of e)n=n.replaceAll(t,r);return n},WE=n=>{if(!n)return;let e=n.toLowerCase().replace(/^no(-|$)/,"nb$1");return Xl[e]||Xl[e.split("-")[0]]||void 0}});var HE,rg,sg=v(()=>{HE=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],rg=HE});function Zl(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([...rg,...e.customReplacements]);n=Ql(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=YE(n));let s=zE(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=VE(n,e.separator)),t&&(n=`_${n}`),r&&(n=`${n}-`),n}var YE,VE,zE,ig=v(()=>{Qm();ng();sg();YE=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"),VE=(n,e)=>{let t=fo(e);return n.replaceAll(new RegExp(`(?:${t}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${t})|(?:${t})$`,"g"),"")},zE=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+=fo(r)}let t=n.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,t)}});function Jn(n){return Zl(n)}var og=v(()=>{ig()});var Kn,ag,cg=v(()=>{Kn={local:"local",ide:"ide",published:"published",inline:"inline"},ag=Object.values(Kn).map(n=>`'${n}'`).join(" | ")});var ds,eu,lg=v(()=>{ds=` *, *::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; }`,eu=" html, body { height: 100%; }"});var
|
|
173
|
+
html[data-theme="light"] { color-scheme: light; }`,eu=" html, body { height: 100%; }"});var ug,dg=v(()=>{ug=`(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,27 +238,27 @@ ${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
|
|
242
|
-
\u2026[${n.length-5e4} more characters truncated]`:n}function
|
|
243
|
-
`).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
|
|
244
|
-
`):n==null?"":
|
|
245
|
-
`).length,"line")}`;if(t.mode==="content")return
|
|
246
|
-
`)){if(!p.includes(`"${d}"`))continue;let
|
|
247
|
-
`)){if(!l.trim())continue;let d;try{d=JSON.parse(l)}catch{continue}if(!d||
|
|
248
|
-
`),c=i.filter(u=>u.type==="tool_use").map(u=>({id:u.id??"",name:u.name??"",input:u.input??{}}));if(o||a||c.length){let u=Date.parse(e.timestamp??""),f=!isNaN(u)&&u>=t;r.push({type:"assistant",text:o,thinking:a,tools:c,live:f})}let l=e.message?.usage??e.usage,d=l&&{in:l.input_tokens??0,out:l.output_tokens??0,cached:l.cache_read_input_tokens??0,cacheCreate:l.cache_creation_input_tokens??0};return{events:r,usage:d,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(l=>l&&l.type==="text").map(l=>l.text??"").join(""):"";if(!(Array.isArray(o)&&o.some(l=>l&&l.type==="tool_result"))&&a.trim()&&
|
|
249
|
-
`):""}function
|
|
250
|
-
`);if(r<0)return t.bytes>=65536?"":void 0;try{let s=JSON.parse(t.text.slice(0,r));return s?.type==="session_meta"&&typeof s.payload?.cwd=="string"?s.payload.cwd:""}catch{return""}}var
|
|
251
|
-
`))if(r.includes('"user_message"'))try{let s=JSON.parse(r);if(s?.type==="event_msg"&&s.payload?.type==="user_message"&&typeof s.payload.message=="string"){let i=s.payload.message.replace(/\s+/g," ").trim();if(i)return i.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"?"":
|
|
252
|
-
`),r=[];if(t.forEach((o,a)=>{let c=
|
|
253
|
-
`)}function
|
|
241
|
+
})();`});var ee=v(()=>{li();lc();Vf();Qf();zl();Xm();og();cg();lg();dg();ui()});function Ee(n){return n.length>5e4?n.slice(0,5e4)+`
|
|
242
|
+
\u2026[${n.length-5e4} more characters truncated]`:n}function qe(n){let e=n.replace(GE,"").split(`
|
|
243
|
+
`).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 GE,ho,fs=v(()=>{"use strict";GE=/\u001b\[[0-9;]*m/g;ho=(n,e)=>``});import{existsSync as XE,readdirSync as QE,statSync as ZE}from"fs";import{join as eA}from"path";function mo(n){if(!XE(n))return[];let e;try{e=QE(n)}catch{return[]}let t=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=eA(n,r);try{let i=ZE(s);i.isFile()&&t.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return t}var nu=v(()=>{"use strict"});var $t,go=v(()=>{"use strict";$t=class{ensureHarnessSupport(){}}});import{openSync as tA,readSync as nA,closeSync as rA,statSync as sA,readdirSync as iA,readFileSync as oA,existsSync as aA}from"fs";import{join as hs}from"path";import{homedir as iu}from"os";function cA(n){return n.replace(/[^a-zA-Z0-9]/g,"-")}function yo(n){let e=n?.type==="image"?n.source:void 0;return e?.type==="base64"&&e.data?ho(e.data,e.media_type):""}function ru(n){return typeof n=="string"?Ee(n):Array.isArray(n)?n.map(e=>{if(typeof e=="string")return Ee(e);let t=e;return typeof t?.text=="string"?Ee(t.text):t?.content!=null?ru(t.content):yo(t)}).join(`
|
|
244
|
+
`):n==null?"":Ee(JSON.stringify(n))}function uA(n){let e=n.trim();return!!e&&gg.some(t=>t.test(e))}function dA(n){let e=n.trim();return e?gg.some(t=>{let r=t.exec(e);return!!r&&r.index===0}):!0}function pA(n){return n.replace(fA,"")}function hA(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=pA(n).trim();return e?hA(e)??(uA(e)?"":e):""}function su(n){return n?.type==="text"&&typeof n.text=="string"?Lt(n.text):""}function ou(n,e){if(typeof n=="string")return qe(n);if(!n||typeof n!="object")return qe(e);let t=n;if(t.type==="text"&&typeof t.file?.numLines=="number")return Je(t.file.numLines,"line");if(t.type==="image"){let r=hg(t.file?.originalSize);return r?`image (${r})`:"image"}if(t.type==="pdf"){let r=hg(t.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(t.type==="parts"&&typeof t.file?.count=="number")return Je(t.file.count,"page");if(t.type==="file_unchanged")return"unchanged since last read";if(t.type==="create"&&typeof t.content=="string")return`created, ${Je(t.content.split(`
|
|
245
|
+
`).length,"line")}`;if(t.mode==="content")return Je(t.numLines??0,"line");if(t.mode==="count")return`${Je(t.numMatches??0,"match","matches")} (${Je(t.numFiles??0,"file")})`;if(t.mode==="files_with_matches")return Je(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":qe(t.stdout||t.stderr||"")||"no output":typeof t.code=="number"&&typeof t.codeText=="string"?`${t.code} ${t.codeText}`:typeof t.searchCount=="number"?Je(t.searchCount,"search","searches"):Array.isArray(t.matches)&&typeof t.total_deferred_tools=="number"?Je(t.matches.length,"tool"):Array.isArray(t.newTodos)?Je(t.newTodos.length,"todo"):typeof t.numFiles=="number"?Je(t.numFiles,"file"):qe(e)}function ps(n){return!!n.isSidechain||!!n.isMeta}function mA(n){let e;try{e=tA(n,"r")}catch{return""}try{let r=65536;try{r=sA(n).size}catch{}let s=(l,d)=>{if(d<=0)return"";let u=Buffer.alloc(d),f=nA(e,u,0,d,l);return u.subarray(0,f).toString("utf8")},i=(l,d,u)=>{let f="";for(let p of l.split(`
|
|
246
|
+
`)){if(!p.includes(`"${d}"`))continue;let m;try{m=JSON.parse(p)}catch{continue}let h=m?.[u];m?.type===d&&typeof h=="string"&&h&&(f=h)}return f},o=s(0,Math.min(65536,r)),a=r>65536?s(r-65536,65536):"",c=i(a,"custom-title","customTitle")||i(o,"custom-title","customTitle")||i(a,"ai-title","aiTitle")||i(o,"ai-title","aiTitle");if(c)return c.replace(/\s+/g," ").trim().slice(0,200);for(let l of o.split(`
|
|
247
|
+
`)){if(!l.trim())continue;let d;try{d=JSON.parse(l)}catch{continue}if(!d||ps(d)||d.type!=="user")continue;let u=d.message?.content,f="";typeof u=="string"?f=Lt(u):Array.isArray(u)&&(f=u.map(su).filter(Boolean).join(" "));let p=f.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{rA(e)}}function gA(n){let e;try{e=iA(mg)}catch{return!1}for(let t of e)if(t.endsWith(".json"))try{let r=JSON.parse(oA(hs(mg,t),"utf8"));if(r?.sessionId!==n)continue;return process.kill(r.pid,0),!0}catch{}return!1}var lA,pg,gg,fA,Je,hg,mg,Wn,bo=v(()=>{"use strict";fs();nu();go();lA=hs(iu(),".claude","projects"),pg=n=>hs(lA,cA(n));gg=[/\[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];fA=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;Je=(n,e,t=e+"s")=>`${n} ${n===1?e:t}`,hg=n=>typeof n!="number"?"":n<1024?`${n}B`:n<1048576?`${Math.round(n/1024)}KB`:`${(n/1048576).toFixed(1)}MB`;mg=hs(iu(),".claude","sessions");Wn=class extends $t{displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return aA(hs(iu(),".claude"))}sessionsDir(e){return pg(e)}listSessionFiles(e){return mo(pg(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=Lt(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=ru(i.content);r.push({type:"tool_result",id:i.tool_use_id??"",content:o,isError:!!i.is_error,digest:ou(e.toolUseResult,o)})}else{let o=su(i)||yo(i);o&&r.push({type:"user",text:o})}return{events:r}}if(e.type==="attachment"&&e.attachment?.type==="queued_command"){let s=Lt(ru(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=>!dA(u)).join(""),a=i.filter(u=>u.type==="thinking").map(u=>u.thinking??"").join(`
|
|
248
|
+
`),c=i.filter(u=>u.type==="tool_use").map(u=>({id:u.id??"",name:u.name??"",input:u.input??{}}));if(o||a||c.length){let u=Date.parse(e.timestamp??""),f=!isNaN(u)&&u>=t;r.push({type:"assistant",text:o,thinking:a,tools:c,live:f})}let l=e.message?.usage??e.usage,d=l&&{in:l.input_tokens??0,out:l.output_tokens??0,cached:l.cache_read_input_tokens??0,cacheCreate:l.cache_creation_input_tokens??0};return{events:r,usage:d,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(l=>l&&l.type==="text").map(l=>l.text??"").join(""):"";if(!(Array.isArray(o)&&o.some(l=>l&&l.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 c of a)c.type==="tool_result"&&c.tool_use_id&&i.add(c.tool_use_id)}return s.some(o=>o&&!i.has(o))}sessionAlive(e){return gA(e)}readPreview(e){return mA(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=Lt(t);else if(Array.isArray(t)){let s=t;r=e.type==="user"?s.map(su).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 yA,readdirSync as bA,openSync as wA,readSync as vA,closeSync as SA,existsSync as kA}from"fs";import{basename as xA,join as au,resolve as EA}from"path";import{homedir as yg}from"os";function TA(n){let e=n.trimStart();return AA.some(t=>e.startsWith(t))}function ms(n,e){return Array.isArray(n)?n.map(t=>typeof t?.text=="string"?e&&TA(t.text)?"":Ee(t.text):t?.type==="input_image"&&typeof t.image_url=="string"&&t.image_url.startsWith("data:")?``:"").filter(Boolean).join(`
|
|
249
|
+
`):""}function PA(n){return typeof n=="string"?Ee(n):ms(n,!1)}function OA(n){let e=n??"";for(let t of[/tools\.shell_command\((\{[\s\S]*?\})\)/,/tools\.shell_command\((\{[\s\S]*\})\)/]){let r=t.exec(e);if(r)try{return JSON.parse(r[1])}catch{}}return{script:e}}function CA(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 wg(n,e){let t;try{t=wA(n,"r")}catch{return}try{let r=Buffer.alloc(e),s=vA(t,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{SA(t)}}function _A(n){let t=wg(n,65536);if(t===void 0)return;let r=t.text.indexOf(`
|
|
250
|
+
`);if(r<0)return t.bytes>=65536?"":void 0;try{let s=JSON.parse(t.text.slice(0,r));return s?.type==="session_meta"&&typeof s.payload?.cwd=="string"?s.payload.cwd:""}catch{return""}}var AA,bg,Hn,cu=v(()=>{"use strict";fs();go();AA=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<user_instructions>"];bg=n=>{let e=EA(n);return process.platform==="win32"?e.toLowerCase():e},Hn=class extends $t{constructor(t=au(yg(),".codex","sessions")){super();this.root=t}displayName="Codex Mirror";#e=0;#s;#t=new Map;detectsSelf(){return!!process.env.CODEX_THREAD_ID}detectsInstalled(){return kA(au(yg(),".codex"))}sessionsDir(t){return this.root}listSessionFiles(t){let r=bg(t),s=[];for(let i of this.#r()){let o;try{let c=yA(i);if(!c.isFile())continue;o=c.mtimeMs}catch{continue}let a=this.#t.get(i);if(a===void 0){if(a=_A(i),a===void 0)continue;this.#t.set(i,a)}bg(a)===r&&s.push({sessionId:xA(i,".jsonl"),file:i,mtime:o})}return s}#r(){let t=[],r=s=>{try{return bA(s).map(i=>au(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.#s,this.#s=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=ms(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=ms(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=ms(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.type==="custom_tool_call"?OA(i.input):CA(i.arguments);return s.push({type:"assistant",text:"",thinking:"",tools:[{id:i.call_id??"",name:i.name??"",input:a}],live:o()}),{events:s}}if(i.type==="custom_tool_call_output"||i.type==="function_call_output"){let a=PA(i.output);return s.push({type:"tool_result",id:i.call_id??"",content:a,isError:!1,digest:qe(a)}),{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 c={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:c}}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(){}readPreview(t){for(let r of(wg(t,256*1024)?.text??"").split(`
|
|
251
|
+
`))if(r.includes('"user_message"'))try{let s=JSON.parse(r);if(s?.type==="event_msg"&&s.payload?.type==="user_message"&&typeof s.payload.message=="string"){let i=s.payload.message.replace(/\s+/g," ").trim();if(i)return i.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"?"":ms(t.payload.content,r==="user").replace(/\s+/g," ").trim()}}});import{realpathSync as RA}from"fs";import{createHash as IA}from"crypto";import{join as wo,resolve as NA}from"path";import{homedir as $A}from"os";function Mt(){let n=process.env.TYPEBULB_SERVERS_DIR;return n?wo(n,".."):wo($A(),".typebulb")}function ut(){vg||(vg=!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||wo(Mt(),"servers")}function Sg(n){let e=se(n),t=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return wo(Mt(),"canvas",`${t}-${gs(n)}.png`)}function gs(n){return IA("sha1").update(se(n)).digest("hex").slice(0,8)}function se(n){let e=NA(n),t=e;try{t=RA.native(e)}catch{}return(process.platform==="win32"?t.toLowerCase():t).replace(/\\/g,"/")}function kg(n,e){let t=se(n),r=se(e);return t.startsWith(r.endsWith("/")?r:r+"/")?!t.includes("/node_modules/"):!1}var vg,tt=v(()=>{"use strict";vg=!1});import*as Ag from"net";import{mkdir as LA,readFile as MA,writeFile as Tg}from"fs/promises";import{existsSync as BA}from"fs";import{join as Pg}from"path";function _g(){return Pg(Mt(),"blocks")}function lu(n){return Pg(_g(),`${n}.json`)}function So(n){return new Promise(e=>{let t=Ag.createServer();t.once("error",()=>e(!1)),t.listen(n,"127.0.0.1",()=>t.close(()=>e(!0)))})}async function UA(n){for(let e=n;e<65535;e++)if(await So(e))return e;throw new Error(`No free port found above ${n}`)}async function uu(n){let{listBulbServers:e}=await Promise.resolve().then(()=>(Ce(),Rg)),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 ko(n){try{let e=JSON.parse(await MA(lu(n),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function xo(n,e){try{return await Tg(lu(n),JSON.stringify(e,null,2)),!0}catch{return ut(),!1}}async function qA(n){let e=se(n);try{await LA(_g(),{recursive:!0})}catch{return}let t=[];for(let o=0;o<Cg;o++)t.push(Og+o*on);let r=await Promise.all(t.map(async o=>({base:o,block:await ko(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 Tg(lu(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(c){if((await ko(o))?.cwd===e)return o;c.code!=="EEXIST"&&ut();continue}if(!BA(a.cwd))return await xo(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>xg(o.block)-xg(a.block))[0];if(i)return await xo(i.base,s)?i.base:void 0}function xg(n){return Object.values(n.slots).reduce((e,t)=>Math.max(e,t.usedAt??0),0)}async function JA(n,e){let t=await ko(n)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=t.mirrors[e.agent];if(i!==void 0)return i;let o=Eg(t),a=o.has(0)?jA:0;for(;a>vo&&o.has(a);)a--;return t.mirrors[e.agent]=a,await xo(n,t),a}let r=se(e.file),s=t.slots[r]?.offset;if(s===void 0){let i=Eg(t);for(s=vo;s<on&&i.has(s);)s++;if(s>=on){let o=Object.entries(t.slots).sort((a,c)=>(a[1].usedAt??0)-(c[1].usedAt??0))[0];s=o?o[1].offset:vo,o&&delete t.slots[o[0]]}}return t.slots[r]={offset:s,usedAt:Date.now()},await xo(n,t),s}function Eg(n){return new Set([...Object.values(n.mirrors),...Object.values(n.slots).map(e=>e.offset)])}async function Yn(n,e){let t=await qA(e);return t===void 0?void 0:t+await JA(t,n)}async function an(n){let e=se(n);for(let t=0;t<Cg;t++){let r=await ko(Og+t*on);if(r?.cwd===e)return s=>r.slots[se(s)]?.usedAt??0}return()=>0}async function Eo(n){if(n.explicit!==void 0)return await So(n.explicit)||await uu(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%on,s=Date.now()+FA;do{if(await So(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=vo;i<on;i++){let o=r+i;if(o!==e&&await So(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await UA(DA),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var Og,on,Cg,DA,vo,jA,FA,cn=v(()=>{"use strict";tt();Og=20100,on=100,Cg=19,DA=23e3,vo=1,jA=on-1,FA=3e3});var _e,Ao=v(()=>{"use strict";_e="0.57.2"});var Rg={};ai(Rg,{agentViewerCommand:()=>Ug,bulbServerCommand:()=>Fg,clearServerLog:()=>mu,findProjectViewer:()=>Oo,isAlive:()=>Vn,isMirror:()=>me,isProjectBulb:()=>vu,isProjectMirror:()=>Xn,launchAgentViewer:()=>xu,launchBulbServer:()=>ws,listBulbServers:()=>X,probePageCount:()=>ku,readServerLog:()=>Ke,readWaitCursor:()=>Po,recordDenial:()=>wu,registerServer:()=>bu,relayOpen:()=>Su,runMarker:()=>gu,serverLogPath:()=>Gn,serversForBulb:()=>un,sliceRunLog:()=>yu,startServerLog:()=>bs,stopBulbServer:()=>zn,stopServer:()=>Bt,stopServersForBulb:()=>Co,typebulbBinPath:()=>Qn,unregisterServer:()=>ln,writeWaitCursor:()=>ys});import{spawn as Ig}from"child_process";import{readdir as KA,readFile as Lg,writeFile as Mg,unlink as du,mkdir as WA}from"fs/promises";import{mkdirSync as Bg,writeFileSync as To,appendFileSync as HA,readFileSync as fu}from"fs";import*as Ae from"path";import{fileURLToPath as YA}from"url";function pu(n){return Ae.join(dt(),`${n}.json`)}function Gn(n){return Ae.join(dt(),`${n}.log`)}function hu(n){return Ae.join(dt(),`${n}.wait.json`)}function Dg(n){try{let e=JSON.parse(fu(hu(n),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function Po(n,e=""){let t=Dg(n)[e];return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0}function ys(n,e,t=""){try{Bg(dt(),{recursive:!0});let r=Dg(n);r[t]=e,To(hu(n),JSON.stringify({cursors:r}))}catch{}}function bs(n){let e=Gn(n);try{Bg(dt(),{recursive:!0}),To(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 c=typeof a=="string"?Buffer.from(a,"utf8"):Buffer.from(a);if(HA(e,c),s+=c.length,s>2*Ng){let l=fu(e),d=l.subarray(Math.max(0,l.length-Ng));To(e,d),s=d.length}}catch{i=!0}};return process.stdout.write=((a,...c)=>(o(a),t(a,...c))),process.stderr.write=((a,...c)=>(o(a),r(a,...c))),()=>{process.stdout.write=t,process.stderr.write=r}}function mu(n){try{To(Gn(n),"")}catch{}}function Ke(n,e=0){try{let t=fu(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 gu(n){return`\u2500\u2500 run ${n} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function zA(n){let e=VA.exec(n);return e?Number(e[1]):void 0}function yu(n,e){let t=n.split(`
|
|
252
|
+
`),r=[];if(t.forEach((o,a)=>{let c=zA(o);c!==void 0&&r.push({id:c,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(`
|
|
253
|
+
`)}function Vn(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}async function bu(n){try{await WA(dt(),{recursive:!0}),await Mg(pu(n.pid),JSON.stringify({version:_e,...n}))}catch{ut()}}async function wu(n,e){let t=pu(n);try{let r=JSON.parse(await Lg(t,"utf8"));if(r.denied===e)return;r.denied=e,await Mg(t,JSON.stringify(r))}catch{}}async function ln(n){await du(pu(n)).catch(()=>{}),await du(Gn(n)).catch(()=>{}),await du(hu(n)).catch(()=>{})}function me(n){return n.agent!=null}function Xn(n,e){return me(n)&&n.cwd!=null&&se(n.cwd)===se(e)}function vu(n,e){return!me(n)&&kg(n.file,e)}async function X(n){let e;try{e=await KA(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 Lg(Ae.join(dt(),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=>vu(s,n)):t).sort((s,i)=>s.startedAt-i.startedAt)}async function Oo(n,e){return(await X()).find(t=>Xn(t,n)&&(e?t.agent===e:!0))}async function Su(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=>vu(a,e)),o=0;for(let a of[...s,...i])try{let c=await fetch(`${a.url}/__open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:n}),signal:AbortSignal.timeout(2e3)});if(!c.ok)continue;let{opened:l,pages:d}=await c.json();if(l)return{where:"editor",via:a.agent?"the agent mirror":`${Ae.basename(a.file)}'s page`};me(a)&&(o+=d??0)}catch{}return o>0?{where:"external"}:void 0}async function zn(n){try{process.kill(n,"SIGTERM")}catch{}await ln(n)}async function ku(n){try{let e=await fetch(`${n.url}/__pages`,{signal:AbortSignal.timeout(GA)});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($g)});if(!t.ok)throw new Error(`/__stop ${t.status}`);let{closed:r=0,stuck:s=0}=await t.json(),i=Date.now()+$g;for(;Vn(n.pid)&&Date.now()<i;)await jg(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 un(n,e){let t=se(e);return n.filter(r=>!me(r)&&r.pid!==process.pid&&se(r.file)===t)}async function Co(n,e){let t=un(await X(),n);for(let r of t)await Bt(r,e!==void 0&&r.port===e?"keep":"close");return t}function XA(n,e,t){(process.platform==="win32"?Ig("cmd",["/c","start","","/b",n,...e],{cwd:t,stdio:"ignore",windowsHide:!0}):Ig(n,e,{cwd:t,detached:!0,stdio:"ignore"})).unref()}function Qn(){return Ae.join(Ae.dirname(YA(import.meta.url)),"index.js")}function Fg(n,e={}){return{command:process.execPath,args:[Qn(),...e.trust?["--trust"]:[],...e.batch?["--batch",e.batch]:[],...e.mode?["--mode",e.mode]:[],n,...e.open===!1?["--no-open"]:[]]}}function Ug(n){return{command:process.execPath,args:[Qn(),`agent:${n}`,"--no-open"]}}async function qg(n,e,t,r){let s=await n();if(s)return s;XA(e.command,e.args,t);let i=Date.now()+2e4;for(;Date.now()<i;){await jg(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=Ae.resolve(t,n),s=await Yn({kind:"bulb",file:r},t),[i]=await Co(r,s),o={...e,batch:e.batch??i?.batch,mode:e.mode??i?.mode};return qg(async()=>un(await X(),r)[0],Fg(n,o),t,Ae.basename(n))}async function xu(n,e=process.cwd()){return qg(()=>Oo(e,n),Ug(n),e,`the ${n} mirror`)}var Ng,VA,$g,GA,jg,Ce=v(()=>{"use strict";tt();cn();Ao();Ng=1e6;VA=/^── run (\d+) ── /;$g=6e3,GA=500;jg=n=>new Promise(e=>setTimeout(e,n))});function Zn(n){return{...qf(n),server:n.files.get("server.ts")??""}}function _o(n){return!!n.server&&!n.code}var vs=v(()=>{"use strict";ee();ee()});function Ro(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 Eu(n){return Jn(Ro(n)??"bulb")||"bulb"}var Au=v(()=>{"use strict";ee()});import{transform as QA}from"sucrase";function Tu(n,e={}){let t=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=QA(n,{transforms:t,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var Jg=v(()=>{});function Pu(n){let e=n.split(""),t=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
|
|
254
254
|
`&&(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]!==`
|
|
255
|
-
`;)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==="/"&&
|
|
255
|
+
`;)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==="/"&&ZA.has(s)){let a=r+1,c=!1;for(;a<n.length&&n[a]!==`
|
|
256
256
|
`;){let l=n[a];if(l==="\\")a++;else if(l==="[")c=!0;else if(l==="]")c=!1;else if(l==="/"&&!c)break;a++}r=a+1,s="/"}else if(i==='"'||i==="'"){let a=r+1;for(;a<n.length&&n[a]!==i&&n[a]!==`
|
|
257
|
-
`;)n[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=
|
|
258
|
-
`).length-1}));return r}function
|
|
259
|
-
`),a=
|
|
260
|
-
`);for(let c=0;c<o.length;c++){let l=a[c],d=c+1+s;for(let u of
|
|
261
|
-
`)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:
|
|
257
|
+
`;)n[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=Kg(n,r);t(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function Kg(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=Kg(n,t);continue}if(s==="$"&&n[t+1]==="{"){r++,t+=2;continue}if(s==="}"&&r>0){r--,t++;continue}t++}return n.length}var ZA,Wg=v(()=>{ZA=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function nT(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 Hg(n){let e=[];for(let s of tT)for(let i of n.matchAll(s)){let o=nT(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(`
|
|
258
|
+
`).length-1}));return r}function Yg(n){return Hg(Pu(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(`
|
|
259
|
+
`),a=Pu(n).split(`
|
|
260
|
+
`);for(let c=0;c<o.length;c++){let l=a[c],d=c+1+s;for(let u of eT)u.targets.includes(t)&&u.pattern.test(l)&&i.push({type:u.type,severity:"error",message:iT(u.type,d),lineNumber:d,lineContent:o[c]})}return t==="client"&&r&&i.push(...rT(a,o,r,s)),i}function rT(n,e,t,r){let s=new Set(Object.keys(t));return Hg(n.join(`
|
|
261
|
+
`)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:sT(i,a),lineNumber:a,lineContent:e[o]}})}function sT(n,e){return`Import "${n}" is not declared in config.json dependencies! Found on line ${e}.
|
|
262
262
|
|
|
263
263
|
**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.
|
|
264
264
|
|
|
@@ -272,7 +272,7 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
|
|
|
272
272
|
}
|
|
273
273
|
\`\`\`
|
|
274
274
|
|
|
275
|
-
**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
|
|
275
|
+
**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 iT(n,e){return n==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
|
|
276
276
|
|
|
277
277
|
**CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
|
|
278
278
|
|
|
@@ -426,12 +426,12 @@ import { something } from 'module-name'
|
|
|
426
426
|
const something = require('module-name') // NOT SUPPORTED!
|
|
427
427
|
\`\`\`
|
|
428
428
|
|
|
429
|
-
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var
|
|
429
|
+
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var dn,fn,eT,tT,Io=v(()=>{Wg();dn=["client"],fn=["client","server"],eT=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:dn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:fn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:dn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:dn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:dn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:fn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:fn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:fn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:fn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:fn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:fn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:dn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:dn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:dn}],tT=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function oT(n){return n.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
|
|
430
430
|
`)[0]}`).join(`
|
|
431
|
-
`)}function
|
|
432
|
-
${tT(t)}`)}var Yg=v(()=>{"use strict";Io()});var Nt,ys,Ou,bs=v(()=>{Nt="https://esm.sh",ys="https://cdn.jsdelivr.net/npm/",Ou="https://data.jsdelivr.com/v1/package/npm/"});function Vg(n){let e=(n||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var j,Gn,zg,ws=v(()=>{bs();j=class n{constructor(e,t,r){let s=typeof e=="string"?n.parse(e):e;this.name=s.name,this.version=Gn(t??s.version),this.subpath=Gn(r??s.subpath)}static parse(e){let t=Vg(e||"");if(!t.length)return new n({name:""});if(t[0].startsWith("@")){let s=t[0],[i,o]=zg(t[1]??""),a=Gn(t.slice(2).join("/"));return new n({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=zg(t[0]),o=Gn(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(Nt).host,s=new URL(ys).host;if(t.host===r){let i=Vg(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:Gn(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},Gn=n=>n&&n.length?n:void 0,zg=n=>{let e=n.indexOf("@");return e<0?[n,void 0]:[n.slice(0,e),Gn(n.slice(e+1))]}});async function be(n){try{return await n()}catch{return}}var No=v(()=>{});function cn(n){let e=n||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function Pu(n){return n.startsWith("./")?n:`./${n}`}var vs,_u=v(()=>{ws();No();bs();vs=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 j(e):e;return`${ys}${t.name}${t.version?`@${t.version}`:""}/`}file(e,t){return new URL(cn(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(",")),`${Nt}/${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),`${Nt}/${e}`]);return this.pinCache.set(e,{value:s,ts:t}),s}async tryResolveFromUrls(e){for(let t of e){let r=await be(()=>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 be(()=>this.http.getJson(`${Ou}${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=j.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:d,peerDependencies:u,peerDependenciesMeta:f}=r;return{name:e,version:t,dependencies:d,peerDependencies:u,peerDependenciesMeta:f}}let s=this.packageJson(new j(`${e}@${t}`)),i=await be(()=>this.http.getJson(s));if(!i)return;let o=d=>d&&Object.keys(d).length?d:void 0,a=o(i.dependencies),c=o(i.peerDependencies),l=o(i.peerDependenciesMeta);return await this.cache.setMeta(e,t,a,c,l),{name:e,version:t,dependencies:a,peerDependencies:c,peerDependenciesMeta:l}}}});var Gg,Ss,Cu,nT,ks,$o=v(()=>{Gg=n=>n.startsWith("@types/"),Ss=n=>Object.keys(n?.peerDependencies||{}).filter(e=>!Gg(e)),Cu=n=>Object.keys(n?.dependencies||{}).filter(e=>!Gg(e)),nT=n=>Ss(n).filter(e=>!n?.peerDependenciesMeta?.[e]?.optional),ks=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 nT(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),c=await this.cdn.fetchPackageMeta(i,a);r.set(i,{name:i,version:a,meta:c})}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=>Ss(i.meta))),r=new Map;for(let i of e)for(let o of Cu(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:Ss(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var xs,Ru=v(()=>{ws();No();xs=class{constructor(e,t,r){this.cache=e,this.cdn=t,this.semver=r}async learnExactVersion(e){let t=await be(()=>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 be(()=>this.cdn.fetchVersionsIndex(e));if(o?.versions?.length){let a=this.semver.selectBestVersion(o.versions,{range:t,distTags:o.distTags});if(a){let c=await i(a);if(c)return c}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 c=await be(()=>this.cdn.fetchVersionsIndex(e));if(c?.versions?.length){let l=await i(this.semver.selectBestVersion(c.versions,{range:t,distTags:c.distTags}));if(l)return l}}}return i(await this.cdn.resolveExactVersion(`${e}@${t}`))}async effectivePackage(e,t){let r=new j(e),s=r.root(),i=t[s],o=i?await be(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as rT,parse as sT}from"es-module-lexer";var Xn,Iu=v(()=>{ws();bs();$o();Xn=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))j.isBare(s[1])&&t.add(s[1])}return Array.from(t)}async extractImports(e){let t=new Set,r=s=>{j.isBare(s)&&t.add(s)};try{await rT;let[s]=sT(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(j.rootOf(u))),i=[...new Set(s.map(j.rootOf))],o=await Promise.all(i.map(async u=>({name:u,version:await this.resolveVersion(u,t)}))),{allRoots:a,flags:c,autoAddedPeers:l}=await this.peer.resolve(o,u=>this.resolveVersion(u,t)),d=this.buildEntries([...s,...l.map(u=>u.name)],a,c);return{importMap:{imports:Object.fromEntries(d)},prefetchUrls:d.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 y=s.get(j.rootOf(p));return new j(p).withVersion(y.version).format()},o=new Set([...r.entries()].filter(([,p])=>p.isPeerRoot||p.isSharedDep).map(([p])=>p)),a=new Set(e.filter(p=>p!==j.rootOf(p)).map(j.rootOf)),c=[],l=new Set,d=new Set(e.filter(p=>p===j.rootOf(p))),u=new Set;for(let p of e){let y=j.rootOf(p),h=s.get(y),{isPeerRoot:m,hasPeers:E,isSharedDep:A}=r.get(y),_=a.has(y),S=p!==y,I=!(m||A)&&(_||!E),M=this.singletonDepsOf(h,o),T=S&&d.has(y);T&&u.add(y);let B=T?[...M,y]:M.length?M:void 0;c.push([p,this.cdn.buildEsmUrl(i(p),{bundle:I,external:B})]),l.add(p)}let f=new Set([...o,...u]);for(let p of f)s.has(p)&&(l.has(p)||c.push([p,this.cdn.buildEsmUrl(i(p),{})]),c.push([`${p}/`,`${Nt}/${i(p)}/`]));return c}singletonDepsOf(e,t){return[...new Set([...Ss(e.meta),...Cu(e.meta)])].filter(r=>t.has(r))}};Xn.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as Xg,satisfies as iT,maxSatisfying as Qg,major as oT,valid as aT,validRange as cT}from"semver";var Lo,ln,Nu=v(()=>{Lo=class{cmp(e,t){return e===t?0:Xg(e,t)?1:Xg(t,e)?-1:0}satisfies(e,t){return!e||!e.trim()?!0:!!iT(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=Qg(e,r,{includePrerelease:!1});if(a)return a}return Qg(e,r,{includePrerelease:!0})??void 0}majorOf(e){return oT(e)}isExactVersion(e){return aT(e)!==null}isRange(e){return cT(e)!==null}},ln=new Lo});function lT(n){return Math.min(9e5*Math.pow(2,Math.max(0,n-1)),864e5)}var un,Zg=v(()=>{No();un=class{constructor(e){this.store=e}async isNegative(e){let t=await be(()=>this.store.get(e));return!!t&&t.until>Date.now()}async recordNegative(e){let r=((await be(()=>this.store.get(e)))?.attempts||0)+1;await be(()=>this.store.set(e,{until:Date.now()+lT(r),attempts:r}))}async clearNegative(e){await be(()=>this.store.delete(e))}}});function ey(n,e){let t=new vs(n,e),r=new ks(t),s=new xs(n,t,ln);return{packageService:new Xn(s,t,r),versionResolver:s,cdnClient:t,peerResolver:r}}var ot=v(()=>{_u();$o();Ru();Iu();Nu();ws();Nu();bs();_u();$o();Ru();Iu();Zg()});import*as $u from"fs/promises";import*as ty from"crypto";function Fe(n){return ty.createHash("sha1").update(n).digest("hex")}async function at(n){try{return JSON.parse(await $u.readFile(n,"utf8"))}catch{return}}async function Mo(n){try{return await $u.readFile(n,"utf8")}catch{return}}var Qn=v(()=>{"use strict"});import*as Lt from"fs/promises";import*as ct from"path";import*as ry from"os";function ne(){return Lu||(Lu=dT().catch(()=>st())),Lu}function Do(n,e){return ct.join(uT,Fe(n),e)}async function dT(){await Lt.mkdir($t,{recursive:!0});let n=ct.join($t,"version.json");if((await at(n))?.version===ny)return;let t=await Lt.readdir($t).catch(()=>[]);await Promise.all(t.map(r=>Lt.rm(ct.join($t,r),{recursive:!0,force:!0}))),await Lt.writeFile(n,JSON.stringify({version:ny})+`
|
|
433
|
-
`,"utf8")}var
|
|
434
|
-
${
|
|
431
|
+
`)}function Vg(n,e){let t=Ss(n,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(t.length)throw new Error(`Lint failed:
|
|
432
|
+
${oT(t)}`)}var zg=v(()=>{"use strict";Io()});var Dt,ks,Ou,xs=v(()=>{Dt="https://esm.sh",ks="https://cdn.jsdelivr.net/npm/",Ou="https://data.jsdelivr.com/v1/package/npm/"});function Gg(n){let e=(n||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var D,er,Xg,Es=v(()=>{xs();D=class n{constructor(e,t,r){let s=typeof e=="string"?n.parse(e):e;this.name=s.name,this.version=er(t??s.version),this.subpath=er(r??s.subpath)}static parse(e){let t=Gg(e||"");if(!t.length)return new n({name:""});if(t[0].startsWith("@")){let s=t[0],[i,o]=Xg(t[1]??""),a=er(t.slice(2).join("/"));return new n({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=Xg(t[0]),o=er(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(Dt).host,s=new URL(ks).host;if(t.host===r){let i=Gg(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:er(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},er=n=>n&&n.length?n:void 0,Xg=n=>{let e=n.indexOf("@");return e<0?[n,void 0]:[n.slice(0,e),er(n.slice(e+1))]}});async function ke(n){try{return await n()}catch{return}}var No=v(()=>{});function pn(n){let e=n||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function Cu(n){return n.startsWith("./")?n:`./${n}`}var As,_u=v(()=>{Es();No();xs();As=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`${ks}${t.name}${t.version?`@${t.version}`:""}/`}file(e,t){return new URL(pn(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(",")),`${Dt}/${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),`${Dt}/${e}`]);return this.pinCache.set(e,{value:s,ts:t}),s}async tryResolveFromUrls(e){for(let t of e){let r=await ke(()=>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 ke(()=>this.http.getJson(`${Ou}${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:d,peerDependencies:u,peerDependenciesMeta:f}=r;return{name:e,version:t,dependencies:d,peerDependencies:u,peerDependenciesMeta:f}}let s=this.packageJson(new D(`${e}@${t}`)),i=await ke(()=>this.http.getJson(s));if(!i)return;let o=d=>d&&Object.keys(d).length?d:void 0,a=o(i.dependencies),c=o(i.peerDependencies),l=o(i.peerDependenciesMeta);return await this.cache.setMeta(e,t,a,c,l),{name:e,version:t,dependencies:a,peerDependencies:c,peerDependenciesMeta:l}}}});var Qg,Ts,Ru,aT,Ps,$o=v(()=>{Qg=n=>n.startsWith("@types/"),Ts=n=>Object.keys(n?.peerDependencies||{}).filter(e=>!Qg(e)),Ru=n=>Object.keys(n?.dependencies||{}).filter(e=>!Qg(e)),aT=n=>Ts(n).filter(e=>!n?.peerDependenciesMeta?.[e]?.optional),Ps=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 aT(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),c=await this.cdn.fetchPackageMeta(i,a);r.set(i,{name:i,version:a,meta:c})}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=>Ts(i.meta))),r=new Map;for(let i of e)for(let o of Ru(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:Ts(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Os,Iu=v(()=>{Es();No();Os=class{constructor(e,t,r){this.cache=e,this.cdn=t,this.semver=r}async learnExactVersion(e){let t=await ke(()=>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 ke(()=>this.cdn.fetchVersionsIndex(e));if(o?.versions?.length){let a=this.semver.selectBestVersion(o.versions,{range:t,distTags:o.distTags});if(a){let c=await i(a);if(c)return c}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 c=await ke(()=>this.cdn.fetchVersionsIndex(e));if(c?.versions?.length){let l=await i(this.semver.selectBestVersion(c.versions,{range:t,distTags:c.distTags}));if(l)return l}}}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 ke(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as cT,parse as lT}from"es-module-lexer";var tr,Nu=v(()=>{Es();xs();$o();tr=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 cT;let[s]=lT(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:c,autoAddedPeers:l}=await this.peer.resolve(o,u=>this.resolveVersion(u,t)),d=this.buildEntries([...s,...l.map(u=>u.name)],a,c);return{importMap:{imports:Object.fromEntries(d)},prefetchUrls:d.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)),c=[],l=new Set,d=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:y,hasPeers:x,isSharedDep:T}=r.get(m),O=a.has(m),E=p!==m,R=!(y||T)&&(O||!x),$=this.singletonDepsOf(h,o),A=E&&d.has(m);A&&u.add(m);let J=A?[...$,m]:$.length?$:void 0;c.push([p,this.cdn.buildEsmUrl(i(p),{bundle:R,external:J})]),l.add(p)}let f=new Set([...o,...u]);for(let p of f)s.has(p)&&(l.has(p)||c.push([p,this.cdn.buildEsmUrl(i(p),{})]),c.push([`${p}/`,`${Dt}/${i(p)}/`]));return c}singletonDepsOf(e,t){return[...new Set([...Ts(e.meta),...Ru(e.meta)])].filter(r=>t.has(r))}};tr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as Zg,satisfies as uT,maxSatisfying as ey,major as dT,valid as fT,validRange as pT}from"semver";var Lo,hn,$u=v(()=>{Lo=class{cmp(e,t){return e===t?0:Zg(e,t)?1:Zg(t,e)?-1:0}satisfies(e,t){return!e||!e.trim()?!0:!!uT(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=ey(e,r,{includePrerelease:!1});if(a)return a}return ey(e,r,{includePrerelease:!0})??void 0}majorOf(e){return dT(e)}isExactVersion(e){return fT(e)!==null}isRange(e){return pT(e)!==null}},hn=new Lo});function hT(n){return Math.min(9e5*Math.pow(2,Math.max(0,n-1)),864e5)}var mn,ty=v(()=>{No();mn=class{constructor(e){this.store=e}async isNegative(e){let t=await ke(()=>this.store.get(e));return!!t&&t.until>Date.now()}async recordNegative(e){let r=((await ke(()=>this.store.get(e)))?.attempts||0)+1;await ke(()=>this.store.set(e,{until:Date.now()+hT(r),attempts:r}))}async clearNegative(e){await ke(()=>this.store.delete(e))}}});function ny(n,e){let t=new As(n,e),r=new Ps(t),s=new Os(n,t,hn);return{packageService:new tr(s,t,r),versionResolver:s,cdnClient:t,peerResolver:r}}var ft=v(()=>{_u();$o();Iu();Nu();$u();Es();$u();xs();_u();$o();Iu();Nu();ty()});import*as Lu from"fs/promises";import*as ry from"crypto";function We(n){return ry.createHash("sha1").update(n).digest("hex")}async function pt(n){try{return JSON.parse(await Lu.readFile(n,"utf8"))}catch{return}}async function Mo(n){try{return await Lu.readFile(n,"utf8")}catch{return}}var nr=v(()=>{"use strict"});import*as Ft from"fs/promises";import*as ht from"path";import*as iy from"os";function te(){return Mu||(Mu=gT().catch(()=>ut())),Mu}function Do(n,e){return ht.join(mT,We(n),e)}async function gT(){await Ft.mkdir(jt,{recursive:!0});let n=ht.join(jt,"version.json");if((await pt(n))?.version===sy)return;let t=await Ft.readdir(jt).catch(()=>[]);await Promise.all(t.map(r=>Ft.rm(ht.join(jt,r),{recursive:!0,force:!0}))),await Ft.writeFile(n,JSON.stringify({version:sy})+`
|
|
433
|
+
`,"utf8")}var sy,jt,Cs,_s,Bo,mT,Mu,rr=v(()=>{"use strict";nr();tt();sy=1,jt=ht.join(iy.homedir(),".typebulb","cache"),Cs=ht.join(jt,"packages"),_s=ht.join(jt,"proxy"),Bo=ht.join(jt,"dts"),mT=ht.join(jt,"emit")});import*as Ut from"fs/promises";import*as oy from"path";async function Re(n,e){let t=`${n}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await Ut.mkdir(oy.dirname(n),{recursive:!0}),await Ut.writeFile(t,e,"utf8")}catch{ut();return}await Ut.rename(t,n).catch(async()=>{await Ut.rm(t,{force:!0}).catch(()=>{})})}var Rs=v(()=>{"use strict";tt()});var sr,Bu=v(()=>{"use strict";Rs();nr();sr=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=pt(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 Re(this.filePath,JSON.stringify(Object.fromEntries(e)))}}});import*as ly from"fs/promises";import*as He from"path";function cy(n,e){return He.join(yT,jo(n),encodeURIComponent(e)+".json")}function jo(n){return n.replace(/\//g,"__")}var Du,ay,yT,bT,Fo,uy=v(()=>{"use strict";ft();rr();Rs();Bu();nr();Du=He.join(Cs,"indexes"),ay=He.join(Cs,"pinned"),yT=He.join(Cs,"meta"),bT=He.join(Cs,"negative.json"),Fo=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new mn(new sr(bT));async getPinnedExact(e,t){let r=`${e}@${t}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await te();let s=await Mo(He.join(ay,We(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 Re(He.join(ay,We(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await te();let t=await pt(He.join(Du,jo(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 Re(He.join(Du,jo(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await ly.rm(He.join(Du,jo(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 pt(cy(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 Re(cy(e,t),JSON.stringify(o))}}});var dy,fy=v(()=>{"use strict";dy={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 wT,Uo,py,hy,TL,ju=v(()=>{"use strict";ft();uy();fy();wT=new Fo,{packageService:Uo,versionResolver:py,cdnClient:hy,peerResolver:TL}=ny(wT,dy)});function qo(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function my(){return` <script>
|
|
434
|
+
${ug}
|
|
435
435
|
(function () {
|
|
436
436
|
try {
|
|
437
437
|
var key = function () { return 'tb-scroll:' + location.pathname + location.search; };
|
|
@@ -447,11 +447,11 @@ ${cg}
|
|
|
447
447
|
</script>`}function Jo(n,e){return` <script>
|
|
448
448
|
(function() {
|
|
449
449
|
try {
|
|
450
|
-
var KEY = ${
|
|
450
|
+
var KEY = ${mt(JSON.stringify("tb-theme:"+n))};
|
|
451
451
|
var doc = document.documentElement;
|
|
452
452
|
var mq = window.matchMedia('(prefers-color-scheme: dark)');
|
|
453
453
|
var os = function() { return mq.matches ? 'dark' : 'light'; };
|
|
454
|
-
var FORCED = ${
|
|
454
|
+
var FORCED = ${mt(JSON.stringify(e??null))};
|
|
455
455
|
var stored = function() {
|
|
456
456
|
try { var v = localStorage.getItem(KEY); return (v === 'dark' || v === 'light') ? v : undefined; }
|
|
457
457
|
catch (e) { return undefined; }
|
|
@@ -489,7 +489,7 @@ ${cg}
|
|
|
489
489
|
});
|
|
490
490
|
} catch (e) {}
|
|
491
491
|
})();
|
|
492
|
-
</script>`}var
|
|
492
|
+
</script>`}var mt,gy,Fu,vT,ST,Ko,ir=v(()=>{"use strict";ee();ee();mt=n=>n.replace(/<\/script/gi,"<\\/script");gy=30*6e4,Fu=1e3,vT=6e4,ST=3e4,Ko=(n="'/__reload'")=>`
|
|
493
493
|
let es = null;
|
|
494
494
|
let bootId = null;
|
|
495
495
|
let firstErrorAt = 0;
|
|
@@ -504,9 +504,9 @@ ${cg}
|
|
|
504
504
|
es.onerror = () => {
|
|
505
505
|
if (!firstErrorAt) firstErrorAt = Date.now();
|
|
506
506
|
// Inside the replace window, EventSource's own retry is faster than anything we'd schedule.
|
|
507
|
-
if (Date.now() - firstErrorAt <= ${
|
|
507
|
+
if (Date.now() - firstErrorAt <= ${vT}) return;
|
|
508
508
|
es.close();
|
|
509
|
-
backoff = Math.min(${
|
|
509
|
+
backoff = Math.min(${ST}, backoff ? backoff * 2 : ${Fu} * 2);
|
|
510
510
|
setTimeout(tbConnect, backoff);
|
|
511
511
|
};
|
|
512
512
|
};
|
|
@@ -522,7 +522,7 @@ ${cg}
|
|
|
522
522
|
// A relay open (TB-VSCode-Browser.md): the CLI asks a page of ours inside VS Code to open a URL,
|
|
523
523
|
// since its integrated browser honors a gesture-less window.open and keeps the new tab in-editor.
|
|
524
524
|
tbOn('open-url', (e) => { window.open(e.data, '_blank', 'noopener'); });
|
|
525
|
-
tbConnect();`});var
|
|
525
|
+
tbConnect();`});var yy,by=v(()=>{"use strict";ir();ee();yy=`
|
|
526
526
|
(() => {
|
|
527
527
|
// Inline (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
|
|
528
528
|
// bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
|
|
@@ -899,7 +899,7 @@ ${cg}
|
|
|
899
899
|
},
|
|
900
900
|
|
|
901
901
|
// Environment ('inline' when running as a bulb-in-a-bulb)
|
|
902
|
-
mode: isFramed ? '${
|
|
902
|
+
mode: isFramed ? '${Kn.inline}' : '${Kn.local}',
|
|
903
903
|
|
|
904
904
|
// Theme accessor - delegates to the head-script engine (window.__tbTheme).
|
|
905
905
|
// Get: override slot ('dark'|'light'|undefined). Set applies + persists
|
|
@@ -1353,7 +1353,20 @@ ${Ko("tbStreamUrl")}
|
|
|
1353
1353
|
} catch (err) { location.replace('about:blank'); }
|
|
1354
1354
|
}, 250);
|
|
1355
1355
|
});
|
|
1356
|
-
|
|
1356
|
+
// The stream attaches during this script's own eval, in <head> \u2014 before the bulb's module (and
|
|
1357
|
+
// its import graph) have run, so before a single \`tb.onMessage\` handler exists. The server now
|
|
1358
|
+
// delivers the instant the stream attaches (it holds a send for the page it opened), so a
|
|
1359
|
+
// message can beat the page's own code by the width of a CDN fetch. A page that is attached but
|
|
1360
|
+
// has not yet run is not a page with no handlers, so hold the message until the deferred module
|
|
1361
|
+
// scripts have executed (DOMContentLoaded waits for them). Page-side and bounded by one load:
|
|
1362
|
+
// the server still never buffers, and a page that is awake handles inline as before.
|
|
1363
|
+
let pageAwake = document.readyState !== 'loading';
|
|
1364
|
+
const beforeAwake = [];
|
|
1365
|
+
if (!pageAwake) document.addEventListener('DOMContentLoaded', () => {
|
|
1366
|
+
pageAwake = true;
|
|
1367
|
+
for (const run of beforeAwake.splice(0)) run();
|
|
1368
|
+
});
|
|
1369
|
+
const onMessageEvent = async (e) => {
|
|
1357
1370
|
// Wire envelope { id?, payload } (JSON \u2014 SSE-line-safe). tb:* payloads are the shim's reserved
|
|
1358
1371
|
// namespace (TB-Interrogation.md): answered by a built-in handler, never delivered to
|
|
1359
1372
|
// tb.onMessage. Each settled non-undefined return is a reply candidate \u2014 the CLI enforces the
|
|
@@ -1395,51 +1408,55 @@ ${Ko("tbStreamUrl")}
|
|
|
1395
1408
|
if (env.id !== undefined) {
|
|
1396
1409
|
try { fetch('/__send-reply', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: env.id, results, errors }) }); } catch {}
|
|
1397
1410
|
}
|
|
1411
|
+
};
|
|
1412
|
+
tbOn('message', (e) => {
|
|
1413
|
+
if (pageAwake) { void onMessageEvent(e); return; }
|
|
1414
|
+
beforeAwake.push(() => { void onMessageEvent(e); });
|
|
1398
1415
|
});
|
|
1399
1416
|
}
|
|
1400
1417
|
})();
|
|
1401
|
-
`});function
|
|
1402
|
-
`+eu,
|
|
1418
|
+
`});function wy(n){let{name:e,code:t,css:r,html:s,data:i,insight:o,importMap:a,theme:c,inline:l,dir:d,source:u,bulbKey:f,compileError:p}=n,m=s.trim()||'<div id="app"></div>',h=l?"":`
|
|
1419
|
+
`+eu,y={imports:TT(a.imports)};return`<!DOCTYPE html>
|
|
1403
1420
|
<html>
|
|
1404
1421
|
<head>
|
|
1405
1422
|
<meta charset="utf-8">
|
|
1406
1423
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1407
1424
|
<title>${qo(e)} - typebulb</title>
|
|
1408
1425
|
${Jo(e,c)}
|
|
1409
|
-
${l?"":
|
|
1426
|
+
${l?"":my()}
|
|
1410
1427
|
<script type="importmap">
|
|
1411
|
-
${JSON.stringify(
|
|
1428
|
+
${JSON.stringify(y,null,2)}
|
|
1412
1429
|
</script>
|
|
1413
1430
|
<style>
|
|
1414
|
-
${
|
|
1431
|
+
${ds}${h}
|
|
1415
1432
|
</style>
|
|
1416
1433
|
<style>
|
|
1417
1434
|
${r}
|
|
1418
1435
|
</style>
|
|
1419
1436
|
</head>
|
|
1420
1437
|
<body>
|
|
1421
|
-
${
|
|
1438
|
+
${m}
|
|
1422
1439
|
|
|
1423
|
-
${i.length>0?`<script>window.__TB_DATA__ = ${
|
|
1424
|
-
${o?`<script>window.__TB_INSIGHT__ = ${
|
|
1425
|
-
${d?`<script>window.__TB_DIR__ = ${
|
|
1426
|
-
${f?`<script>window.__TB_BULB__ = ${
|
|
1427
|
-
${p?`<script>window.__TB_COMPILE_ERROR__ = ${
|
|
1440
|
+
${i.length>0?`<script>window.__TB_DATA__ = ${mt(JSON.stringify(i))};</script>`:""}
|
|
1441
|
+
${o?`<script>window.__TB_INSIGHT__ = ${mt(JSON.stringify(o))};</script>`:""}
|
|
1442
|
+
${d?`<script>window.__TB_DIR__ = ${mt(JSON.stringify(d))};</script>`:""}
|
|
1443
|
+
${f?`<script>window.__TB_BULB__ = ${mt(JSON.stringify(f))};</script>`:""}
|
|
1444
|
+
${p?`<script>window.__TB_COMPILE_ERROR__ = ${mt(JSON.stringify(p))};</script>`:""}
|
|
1428
1445
|
|
|
1429
1446
|
<script>
|
|
1430
|
-
${
|
|
1447
|
+
${yy}
|
|
1431
1448
|
</script>
|
|
1432
1449
|
|
|
1433
|
-
${
|
|
1450
|
+
${AT}
|
|
1434
1451
|
|
|
1435
|
-
${
|
|
1452
|
+
${xT(t,u)}
|
|
1436
1453
|
</body>
|
|
1437
|
-
</html>`}function
|
|
1438
|
-
`);return`<script type="module">${s}${
|
|
1439
|
-
</script>`}function
|
|
1454
|
+
</html>`}function xT(n,e){let t=["",...kT],r=e?Array(Math.max(0,e.codeLine-t.length-1)).fill(""):[],s=[...t,...r,mt(n)].join(`
|
|
1455
|
+
`);return`<script type="module">${s}${ET(e,s)}
|
|
1456
|
+
</script>`}function ET(n,e){if(!n)return"";let t=e.split(`
|
|
1440
1457
|
`).length,r={version:3,file:n.file,sources:[`/__source/${n.file}`],names:[],mappings:["AAAA",...Array(Math.max(0,t-1)).fill("AACA")].join(";")};return`
|
|
1441
1458
|
//# sourceURL=${n.file.replace(/\s/g,"%20")}
|
|
1442
|
-
//# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function
|
|
1459
|
+
//# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function TT(n){let e={};for(let[t,r]of Object.entries(n))e[t]=r.startsWith("https://")?"/proxy/"+r:r;return e}var kT,AT,vy=v(()=>{"use strict";by();ir();kT=["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) */"];AT=`<script>
|
|
1443
1460
|
(function () {
|
|
1444
1461
|
var framed = window.parent !== window;
|
|
1445
1462
|
var post = function (m) { try { parent.postMessage(m, '*'); } catch (e) {} }; /* framed only */
|
|
@@ -1538,22 +1555,22 @@ ${bT(t,u)}
|
|
|
1538
1555
|
}
|
|
1539
1556
|
});
|
|
1540
1557
|
})();
|
|
1541
|
-
</script>`});import*as Ho from"fs/promises";import*as Wo from"path";import{existsSync as
|
|
1542
|
-
Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await Ho.mkdir(e,{recursive:!0});let a=Wo.join(e,"package.json");
|
|
1558
|
+
</script>`});import*as Ho from"fs/promises";import*as Wo from"path";import{existsSync as Sy,readFileSync as PT}from"fs";import{execFile as OT}from"child_process";import{promisify as CT}from"util";import{builtinModules as _T}from"node:module";import{satisfies as RT}from"semver";async function Yo(n,e,t,r){let i=n.map(l=>LT(l,t)).filter(l=>!MT(l,e));if(i.length===0)return;let o=i.filter(l=>!$T.test(l));if(o.length)throw new Error(`Refusing to install npm spec(s) with unsupported characters: ${o.join(", ")}
|
|
1559
|
+
Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await Ho.mkdir(e,{recursive:!0});let a=Wo.join(e,"package.json");Sy(a)||await Ho.writeFile(a,JSON.stringify({name:"typebulb-server",private:!0})),console.log(` Installing: ${i.join(", ")}`);let c=["--no-audit","--no-fund",...r?.ignoreScripts?["--ignore-scripts"]:[]];await IT("npm",["install",...c,...i],{cwd:e,shell:!0})}function LT(n,e){if(!e||D.parse(n).version)return n;let t=e[n];return t?`${n}@${t}`:n}function MT(n,e){let{name:t,version:r}=D.parse(n),s=Wo.join(e,"node_modules",t);if(!Sy(s))return!1;if(!r)return!0;try{let i=JSON.parse(PT(Wo.join(s,"package.json"),"utf-8")).version;return RT(i,r)}catch{return!1}}function Vo(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);NT.has(i)||e.add(i)}return[...e]}var IT,NT,$T,Uu=v(()=>{"use strict";ft();IT=CT(OT),NT=new Set(_T),$T=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});var ky,xy,nt,gn=v(()=>{ky=n=>n!=null&&n>=0&&n<=4?n:void 0,xy=(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 Te,Ye,or=v(()=>{Te=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=`
|
|
1543
1560
|
|
|
1544
|
-
`){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
|
|
1545
|
-
`)),!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
|
|
1561
|
+
`){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 Te(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 Te(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 zo,qu=v(()=>{gn();or();zo=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(`
|
|
1562
|
+
`)),!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 Te(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(`
|
|
1546
1563
|
|
|
1547
|
-
`)}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
|
|
1564
|
+
`)}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 ar,Go=v(()=>{gn();or();ar=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 Xo,Ju=v(()=>{Go();Xo=class extends ar{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,t){let r={Authorization:`Bearer ${e}`,"x-api-key":e,"Content-Type":"application/json",Accept:"application/json","X-Title":"Typebulb"};return t&&(r["HTTP-Referer"]=t,r.Referer=t,r.Origin=t),r}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,Ku=v(()=>{gn();or();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 c=r?.effort;if(c!==void 0){if(this.isModernModel(t))if(c===0)this.alwaysThinks(t)||(a.thinking={type:"disabled"}),a.output_config={effort:"low"};else{let l={1:"low",2:"medium",3:"high",4:"max"};a.thinking={type:"adaptive",display:"summarized"},a.output_config={effort:l[c]}}else if(c!==0){let l={1:2048,2:4096,3:8192,4:16384};a.thinking={type:"enabled",budget_tokens:l[c]}}}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(`
|
|
1548
1565
|
|
|
1549
|
-
`);return{text:t,reasoning:r||void 0,usage:
|
|
1566
|
+
`);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=l=>typeof l=="number"?l: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),c=s!==void 0||i!==void 0||o!==void 0?(s??0)+(i??0)+(o??0):void 0;if(!(c===void 0&&a===void 0))return{input:c,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 Zo,Wu=v(()=>{gn();or();Zo=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,`
|
|
1550
1567
|
`),c={contents:o.map(d=>({role:d.role==="assistant"?"model":"user",parts:[{text:d.content}]}))};r?.webSearch===!0&&(c.tools=[{google_search:{}}]),i&&(c.systemInstruction={role:"system",parts:[{text:i}]});let l=r?.effort;if(l!==void 0){let d=this.geminiVersion(t),u=d!==void 0&&d>=3?{thinkingLevel:this.thinkingLevelFor(d,l)}:{thinkingBudget:this.budgetMap[l]};c.generationConfig={thinkingConfig:l===0?u:{includeThoughts:!0,...u}}}return r?.maxOutputTokens!==void 0&&(c.generationConfig={...c.generationConfig,maxOutputTokens:r.maxOutputTokens}),c}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(`
|
|
1551
|
-
`)[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
|
|
1568
|
+
`)[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 Te(`Prompt blocked: ${t}`)}}}});var ea,Hu=v(()=>{Go();ea=class extends ar{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=BT.get(n);if(!e)throw new Error(`Unsupported protocol: ${n}`);return e}function DT(n,e){return n.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function Yu(n,e){let t=yn(n.protocol),r=t.getPath(n.model,e.stream),s=DT(n.baseUrl,r),i=t.buildHeaders(n.apiKey,e.origin),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 jT(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||jT(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var Ey,BT,Vu=v(()=>{qu();Ju();Ku();Wu();Hu();Ey=new ea,BT=new Map([["openai",new zo],["openrouter",new Xo],["anthropic",new Qo],["gemini",new Zo],["ollama",Ey],["openai-compat",Ey]])});function Ay(n){let e=n.indexOf(`\r
|
|
1552
1569
|
\r
|
|
1553
1570
|
`),t=n.indexOf(`
|
|
1554
1571
|
|
|
1555
|
-
`);return e!==-1&&(t===-1||e<t)?{pos:e,len:4}:t!==-1?{pos:t,len:2}:{pos:-1,len:0}}function
|
|
1556
|
-
`).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*
|
|
1572
|
+
`);return e!==-1&&(t===-1||e<t)?{pos:e,len:4}:t!==-1?{pos:t,len:2}:{pos:-1,len:0}}function zu(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(`
|
|
1573
|
+
`).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*Ty(n,e,t){let r=new TextDecoder,s="",i,o=e?new Promise((a,c)=>{e.aborted&&c(new Error("Aborted")),i=()=>c(new Error("Aborted")),e.addEventListener("abort",i,{once:!0})}):void 0;o?.catch(()=>{});try{for(;;){let{done:a,value:c}=o?await Promise.race([n.read(),o]):await n.read();if(a){if(s.trim()){let u=zu(s);u!==void 0&&u!=="done"&&(yield u)}return}t?.(),s+=r.decode(c,{stream:!0});let{pos:l,len:d}=Ay(s);for(;l!==-1;){let u=s.slice(0,l);s=s.slice(l+d);let f=zu(u);if(f==="done")return;f!==void 0&&(yield f),{pos:l,len:d}=Ay(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await n.cancel()}catch{}}}async function Gu(n,e){return(await lr(n,e)).text}async function lr(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 Ty(s)){let c=r.parseStreamChunk(a);c?.reasoning&&(yield{kind:"reasoning",text:c.reasoning}),c?.text&&(yield{kind:"text",text:c.text}),c?.usage&&(i=xy(i,c.usage))}let o=nt(i);o&&(yield{kind:"usage",usage:o})}var Py=v(()=>{gn();Vu()});import{strToU8 as FT,strFromU8 as UT,deflateSync as qT,inflateSync as JT}from"fflate";function Qu(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.
|
|
1557
1574
|
|
|
1558
1575
|
---
|
|
1559
1576
|
Instructions:
|
|
@@ -1571,21 +1588,21 @@ ${r}
|
|
|
1571
1588
|
</data>`)}return t.push(`
|
|
1572
1589
|
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(`
|
|
1573
1590
|
|
|
1574
|
-
`)}function
|
|
1575
|
-
`)){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 ta(n,e=process.cwd()){for(let t of
|
|
1576
|
-
`)}var or,zT,GT,XT,QT,Ps,na,_s,mn=v(()=>{"use strict";or={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};zT="https://api.typebulb.com/api/models",GT=1440*60*1e3,XT=5e3,QT=60*1e3});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=fn(t)}catch{return`Unknown provider '${t}'.`}if(t==="ollama")return{apiKey:"",baseUrl:`${ar(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=or[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 ${Iy()}.`}function Dt(n,e){let t=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return Hu(n,{messages:t,stream:!0,effort:vy(e.effort),webSearch:e.webSearch,signal:e.signal})}var sa=v(()=>{"use strict";hn();hn();ut();mn()});import*as cr from"fs/promises";import*as pt from"path";function ia(n,e,t=e){let r=pt.resolve(e,n),s=pt.normalize(t),i=pt.normalize(r);if(i!==s&&!i.startsWith(s+pt.sep))throw new Error("Path traversal detected - access denied");return r}async function Cs(n,e,t){return cr.readFile(ia(n,e,t))}async function oa(n,e,t,r){let s=ia(n,t,r);await cr.mkdir(pt.dirname(s),{recursive:!0}),await cr.writeFile(s,typeof e=="string"?e:Buffer.from(e))}var rd=v(()=>{"use strict"});async function My(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 sr(t,e.protocol);throw new Error(r.message)}return{response:t,protocol:e.protocol}}async function nO(n){let{response:e,protocol:t}=await My(n);return ir(e,t)}async function*rO(n){let{response:e,protocol:t}=await My(n);yield*pn(e,t)}function By(n,e=process.cwd()){let t=Object.assign(nO,{stream:rO}),r={read:async s=>{let i=await Cs(s,n,e);try{return new TextDecoder("utf-8",{fatal:!0}).decode(i)}catch{throw new Error(`File is not valid UTF-8 text: ${s} \u2014 use tb.fs.readBytes() for binary files.`)}},readBytes:async s=>new Uint8Array(await Cs(s,n,e)),write:async(s,i)=>(await oa(s,i,n,e),!0)};globalThis.tb=Object.freeze({log:(...s)=>{console.log(...s)},ai:t,fs:r,dir:n,models:()=>dt(),aiAccess:ra,mode:Fn.local})}var Dy=v(()=>{"use strict";hn();te();sa();mn();rd()});import*as Je from"fs/promises";import*as ce from"path";import{pathToFileURL as sO}from"url";async function jy(n){let t=(await Je.readdir(n)).find(r=>r.endsWith(".bulb.md"));return t?ce.join(n,t):void 0}function jt(n,e){let t=ce.resolve(n),r=ce.join(ce.dirname(t),ce.basename(t).replace(/\.bulb\.md$/,""));return e?ce.join(r,"batches",e):r}async function lr(n,e){let t=jt(n,e);await Je.mkdir(t,{recursive:!0});let r=new Date;await Je.utimes(t,r,r).catch(()=>{})}function ur(n){let[e,t,r,s]=n.split(ce.sep).slice(-4);if(!(e!=="typebulbs"||t!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function Ke(n){let e=await Je.readFile(n,"utf-8"),t=On(e),r=zn(t);return{bulb:r,config:Tr(r.config),warnings:jf(e),starts:t.starts}}function sd(n){let e=ce.basename(n).replace(/\.bulb\.md$/i,"");return ce.join(ce.dirname(n),".typebulb",`${e}.server.mjs`)}async function Rs(n,e,t,r,s){let i=Au(n,{serverOnly:!0});if(i.error)throw new Error(`Server compilation error: ${i.error}`);let o=i.code;t&&(o=await Nf(o,t));let a=ce.join(ce.dirname(e),".typebulb");await Je.mkdir(a,{recursive:!0});let c=Vo(o);c.length>0&&await Yo(c,a,r);let l=sd(e);return await Je.writeFile(l,o,"utf-8"),By(jt(e,s)),await import(`${sO(l).href}?t=${Date.now()}`)}async function id(n,e,t,r,s){let{bulb:i,config:o,starts:a}=await Ke(n),c=lo(i.data),l,d=h=>{l??=h instanceof Error?h.message:String(h)};try{Hg(i.code,o.dependencies??{})}catch(h){d(h)}let u=Au(i.code,{jsxImportSource:o.ts?.jsxImportSource});u.error&&d(u.error);let f={imports:{}};if(!l)try{({importMap:f}=await Uo.buildImportMap(u.code,o.dependencies??{},r?new Set([r.name]):void 0))}catch(h){d(`Dependency resolution failed: ${h instanceof Error?h.message:String(h)}`)}l&&console.error("Build error:",l),r&&(f.imports[r.name]=r.entryUrl);let p=yy({name:i.name,code:l?"":u.code,css:i.css,html:i.html,data:c,insight:i.insight,importMap:f,dir:jt(n,s),watch:e,source:{file:ce.basename(n),codeLine:a.get("code.tsx")??1},bulbKey:ds(n),compileError:l}),y;return i.server&&t&&(y=await Rs(i.server,n,r,o.dependencies,s)),{html:p,bulb:i,serverExports:y,buildError:l}}var Ft,Qe=v(()=>{"use strict";ms();Ug();Yg();Du();by();Fu();ai();ze();Dy();Ft=(n,e)=>ce.join(jt(n,e),"assets")});import{readdirSync as Uy,readFileSync as iO,statSync as qy}from"fs";import{join as aa,basename as oO}from"path";function Jy(n,e,t){if(e>8)return t;let r;try{r=Uy(n,{withFileTypes:!0})}catch{return t}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;Jy(aa(n,s.name),e+1,t)}else s.isFile()&&s.name.endsWith(".bulb.md")&&t.push(aa(n,s.name));return t}function od(n){let e=aa(jt(n),"batches"),t;try{t=Uy(e,{withFileTypes:!0})}catch{return[]}return t.filter(r=>r.isDirectory()).map(r=>{let s=0;try{s=qy(aa(e,r.name)).mtimeMs}catch{}return{name:r.name,mtime:s}}).sort((r,s)=>s.mtime-r.mtime).map(r=>r.name)}function aO(n,e){let t,r=!1;try{let s=iO(n,"utf8");t=Ro(s.slice(0,1024));let i=$e(s);r=!!i&&Co(zn(i))}catch{}return{mtime:e,name:t??oO(n).replace(/\.bulb\.md$/,""),serverOnly:r}}function ca(n){let e=new Map,t=Jy(n,0,[]).map(r=>{let s=0;try{s=qy(r).mtimeMs}catch{}let i=s?Fy.get(r):void 0,o=i?.mtime===s?i:aO(r,s);return s&&e.set(r,o),{path:r,...o}});return Fy=e,t}var Fy,Ky=v(()=>{"use strict";te();ms();Eu();Qe();Fy=new Map});function dr(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 la=v(()=>{"use strict"});import{readFile as cO}from"fs/promises";async function ad(n){try{let e=$e(await cO(n,"utf-8"));return e?dr(zn(e)):void 0}catch{return}}var Wy=v(()=>{"use strict";ms();la()});function cd(n){let e=$e(n);if(!e)return n;let t=e.files.get("code.tsx");if(!t)return n;let r=Wg(t);if(!r.length)return n;let s=e.files.get("config.json"),i={};if(s)try{let l=JSON.parse(s);l&&typeof l=="object"&&(i=l)}catch{}let o=i.dependencies&&typeof i.dependencies=="object"?{...i.dependencies}:{},a=r.filter(l=>!(l in o));if(!a.length)return n;for(let l of a)o[l]="latest";i.dependencies=o;let c={name:e.frontmatter.name};for(let[l,d]of e.files){let u=$f(l);u&&(c[u]=d)}return c.config=JSON.stringify(i,null,2),Jf(c)}var Hy=v(()=>{"use strict";te();Io()});import{spawn as Yy}from"child_process";import{basename as lO}from"path";function uO(){return process.env.TYPEBULB_EDITOR||"code"}function fO(n,e,t){return t==null?[e]:dO.test(lO(n))?["-g",`${e}:${t}`]:[`+${t}`,e]}function pO(n,e){let t=uO();return{command:t,args:fO(t,n,e)}}function ld(n,e){let{command:t,args:r}=pO(n,e),s=process.platform==="win32"?Yy("cmd.exe",["/d","/s","/c",t,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):Yy(t,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var dO,Vy=v(()=>{"use strict";dO=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as hO,writeFileSync as mO,mkdirSync as gO,statSync as yO}from"fs";import{join as bO}from"path";function ud(){return bO(Rt(),"trust.json")}function dd(){try{let n=ud(),e=yO(n).mtimeMs;if(Is?.mtime!==e){let t=JSON.parse(hO(n,"utf8"));Is={mtime:e,set:new Set(Array.isArray(t)?t:[])}}return Is.set}catch{return Is=void 0,new Set}}function wO(n){try{gO(Rt(),{recursive:!0}),mO(ud(),JSON.stringify([...n])),Is=void 0}catch(e){throw new Error(`can't write ${ud()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function gn(n){return dd().has(se(n))}function fr(n,e){let t=new Set(dd()),r=se(n);(e?t.has(r):!t.has(r))||(e?t.add(r):t.delete(r),wO(t))}function fd(){return[...dd()]}var Is,Ns=v(()=>{"use strict";ze()});import{readFileSync as EB,existsSync as vO}from"fs";import*as pr from"path";import{fileURLToPath as SO}from"url";function kO(){let n=pr.dirname(SO(import.meta.url));for(;!vO(pr.join(n,"package.json"));){let e=pr.dirname(n);if(e===n)break;n=e}return n}function $s(){return pr.join(kO(),"SKILL.md")}var pd=v(()=>{"use strict"});import*as xe from"fs/promises";import*as _e from"path";import{createHash as xO}from"crypto";async function md(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 hr(n){try{return JSON.parse(n).error||n}catch{return n}}async function yd(n,e){try{let t=await fetch(Ls(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}): ${hr(await t.text())}`}}catch(t){return{error:t instanceof Error?t.message:String(t)}}}function bd(n,e){Pe(e);let t=process.env.TYPEBULB_ORIGIN||EO;try{return fa(n,process.cwd(),t)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function fa(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}
|
|
1577
|
-
Expected <origin>/u/<user>/<slug>`);let c=a[1],l=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:c,slug:l,dest:
|
|
1578
|
-
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
|
|
1579
|
-
`),r
|
|
1591
|
+
`)}function Is(n){try{return JSON.parse(n)}catch{return}}function Oy(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 WT(n){let e=Oy(n,t=>t.replace(/,(\s*[}\]])/g,"$1"));return e!==n?e:void 0}function HT(n){let e=Oy(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 YT(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 VT(n){let e,t=0;for(;t<n.length;){let r=n[t];if(r==="{"||r==="["){let s=YT(n,t);if(s!==-1){let i=n.slice(t,s+1),o=Is(i);o!==void 0&&(e={parsed:o,json:i}),t=s+1;continue}}t++}return e}function Zu(n){let e=[],t=n.trim();t.startsWith("```")&&(t=t.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Is(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=Is(t),r!==void 0))return{parsed:r,json:t,fixesApplied:e};if(!t.startsWith("{")&&!t.startsWith("[")){let o=t.indexOf("{"),a=t.indexOf("["),c=o>=0&&a>=0?Math.min(o,a):o>=0?o:a;if(c>0&&(t=t.slice(c),e.push("preamble text"),r=Is(t),r!==void 0))return{parsed:r,json:t,fixesApplied:e}}for(let[o,a]of KT){let c=a(t);if(c!==void 0){let l=Is(c);if(l!==void 0)return{parsed:l,json:c,fixesApplied:[...e,o]}}}let i=VT(n);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:t,fixesApplied:e}}function ed(n){try{let e={i:n.insight,d:n.data},t=JSON.stringify(e),r=qT(FT(t),{level:9}),s=GT(r),i=`${Cy}:${s}`;return i.length>zT?"":"#"+Xu+i}catch{return""}}function td(n){try{let e=n.startsWith("#")?n.slice(1):n;if(!e.startsWith(Xu))return;let t=e.slice(Xu.length),r=t.indexOf(":");if(r===-1||t.slice(0,r)!==Cy)return;let s=XT(t.slice(r+1)),i=JSON.parse(UT(JT(s)));return!i||typeof i.i>"u"||!Array.isArray(i.d)?void 0:{insight:i.i,insightJson:JSON.stringify(i.i,null,2),data:i.d}}catch{return}}function GT(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 XT(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 KT,Xu,Cy,zT,_y=v(()=>{KT=[["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",WT],["arithmetic constants",HT]];Xu="tb=",Cy="1",zT=6e4});var wn=v(()=>{gn();or();Vu();Py();_y();Go();Ku();Wu();qu();Ju();Hu()});import{readFileSync as Ry,existsSync as QT}from"fs";import*as rt from"path";function Iy(n){return[...n?[`.env.${n}.local`,`.env.${n}`]:[],".env.local",".env"]}function Ie(n,e=process.cwd()){let t={},r=[];for(let s of Iy(n)){let i;try{i=Ry(rt.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of Ny(i))process.env[o]===void 0&&(process.env[o]=a,t[o]=s)}return{mode:n,sources:t,loaded:r}}function*Ny(n){for(let e of n.split(`
|
|
1592
|
+
`)){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 ta(n,e=process.cwd()){for(let t of Iy()){let r;try{r=Ry(rt.resolve(e,t),"utf-8")}catch{continue}for(let[s,i]of Ny(r))if(s===n)return i}return process.env[n]}function ZT(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 qt(n,e,t){let{sources:r,mode:s,loaded:i}=n,o=process.cwd(),a=rt.dirname(e),c=`(mode: ${s??"none"})`,l=t?ZT(t):[],d=l.filter(p=>r[p]).map(p=>`${p} \u2190 ${r[p]}`);d.length?console.log(`env: ${d.join(", ")} ${c}`):i.length&&console.log(`env: loaded ${i.join(", ")} ${c}`),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"])QT(rt.join(a,p))&&console.log(`env: ${rt.join(a,p)} present but not loaded (cwd is ${o})`);let f=l.filter(p=>process.env[p]===void 0);if(f.length){let p=u?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${f.join(", ")} but ${f.length>1?"they are":"it's"} unset${p}`)}}var gt=v(()=>{"use strict"});function dr(n){return(n.includes("://")?n:`http://${n}`).replace(/\/+$/,"")}function nd(){return $s}async function yt(){let[n,e]=await Promise.all([My(),iP()]);return sP([...oP(e),...n],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function sP(n,e,t){return!e||!t?n:n.map(r=>r.provider===e&&r.name===t?{...r,default:!0}:r)}async function Ly(){let n;try{n=await fetch(eP,{signal:AbortSignal.timeout(nP)})}catch(e){$s=`catalog fetch failed: ${e?.message??e}`;return}if(!n.ok){$s=`catalog fetch failed: HTTP ${n.status}`;return}try{return await n.json()}catch(e){$s=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function iP(){if(Ns&&Date.now()-Ns.fetchedAt<=tP)return Ns.models;let n=await Ly()??await Ly();return n?(Ns={models:n,fetchedAt:Date.now()},$s=void 0,n):Ns?.models??[]}async function My(){if(na&&Date.now()-na.fetchedAt<=rP)return na.models;let n=dr(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 na={models:e,fetchedAt:Date.now()},e}function oP(n){let e=new Set(Object.entries(ur).filter(([,t])=>!!process.env[t]).map(([t])=>t));return n.filter(t=>e.has(t.provider))}function rd(){return Object.values(ur).some(n=>!!process.env[n])}async function ra(){return rd()||process.env.TB_AI_BASE_URL||(await My()).length>0?"own":"none"}function By(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(`
|
|
1593
|
+
`)}var ur,eP,tP,nP,rP,Ns,na,$s,vn=v(()=>{"use strict";ur={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};eP="https://api.typebulb.com/api/models",tP=1440*60*1e3,nP=5e3,rP=60*1e3});function bt(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:`${dr(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=ur[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 Jt(n,e){let t=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return Yu(n,{messages:t,stream:!0,effort:ky(e.effort),webSearch:e.webSearch,signal:e.signal})}var sa=v(()=>{"use strict";wn();wn();gt();vn()});import*as fr from"fs/promises";import*as wt from"path";function ia(n,e,t=e){let r=wt.resolve(e,n),s=wt.normalize(t),i=wt.normalize(r);if(i!==s&&!i.startsWith(s+wt.sep))throw new Error("Path traversal detected - access denied");return r}async function Ls(n,e,t){return fr.readFile(ia(n,e,t))}async function oa(n,e,t,r){let s=ia(n,t,r);await fr.mkdir(wt.dirname(s),{recursive:!0}),await fr.writeFile(s,typeof e=="string"?e:Buffer.from(e))}var sd=v(()=>{"use strict"});async function Dy(n){let e=bt(n.provider,n.model);if(typeof e=="string")throw new Error(e);let t=await Jt(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 aP(n){let{response:e,protocol:t}=await Dy(n);return lr(e,t)}async function*cP(n){let{response:e,protocol:t}=await Dy(n);yield*bn(e,t)}function jy(n,e=process.cwd()){let t=Object.assign(aP,{stream:cP}),r={read:async s=>{let i=await Ls(s,n,e);try{return new TextDecoder("utf-8",{fatal:!0}).decode(i)}catch{throw new Error(`File is not valid UTF-8 text: ${s} \u2014 use tb.fs.readBytes() for binary files.`)}},readBytes:async s=>new Uint8Array(await Ls(s,n,e)),write:async(s,i)=>(await oa(s,i,n,e),!0)};globalThis.tb=Object.freeze({log:(...s)=>{console.log(...s)},ai:t,fs:r,dir:n,models:()=>yt(),aiAccess:ra,mode:Kn.local})}var Fy=v(()=>{"use strict";wn();ee();sa();vn();sd()});import*as Ve from"fs/promises";import*as ce from"path";import{pathToFileURL as lP}from"url";async function Uy(n){let t=(await Ve.readdir(n)).find(r=>r.endsWith(".bulb.md"));return t?ce.join(n,t):void 0}function Kt(n,e){let t=ce.resolve(n),r=ce.join(ce.dirname(t),ce.basename(t).replace(/\.bulb\.md$/,""));return e?ce.join(r,"batches",e):r}async function pr(n,e){let t=Kt(n,e);await Ve.mkdir(t,{recursive:!0});let r=new Date;await Ve.utimes(t,r,r).catch(()=>{})}function hr(n){let[e,t,r,s]=n.split(ce.sep).slice(-4);if(!(e!=="typebulbs"||t!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function ze(n){let e=await Ve.readFile(n,"utf-8"),t=Rn(e),r=Zn(t);return{bulb:r,config:Rr(r.config),warnings:Uf(e),starts:t.starts}}function id(n){let e=ce.basename(n).replace(/\.bulb\.md$/i,"");return ce.join(ce.dirname(n),".typebulb",`${e}.server.mjs`)}async function Ms(n,e,t,r,s){let i=Tu(n,{serverOnly:!0});if(i.error)throw new Error(`Server compilation error: ${i.error}`);let o=i.code;t&&(o=await Lf(o,t));let a=ce.join(ce.dirname(e),".typebulb");await Ve.mkdir(a,{recursive:!0});let c=Vo(o);c.length>0&&await Yo(c,a,r);let l=id(e);return await Ve.writeFile(l,o,"utf-8"),jy(Kt(e,s)),await import(`${lP(l).href}?t=${Date.now()}`)}async function od(n,e,t,r,s){let{bulb:i,config:o,starts:a}=await ze(n),c=uo(i.data),l,d=h=>{l??=h instanceof Error?h.message:String(h)};try{Vg(i.code,o.dependencies??{})}catch(h){d(h)}let u=Tu(i.code,{jsxImportSource:o.ts?.jsxImportSource});u.error&&d(u.error);let f={imports:{}};if(!l)try{({importMap:f}=await Uo.buildImportMap(u.code,o.dependencies??{},r?new Set([r.name]):void 0))}catch(h){d(`Dependency resolution failed: ${h instanceof Error?h.message:String(h)}`)}l&&console.error("Build error:",l),r&&(f.imports[r.name]=r.entryUrl);let p=wy({name:i.name,code:l?"":u.code,css:i.css,html:i.html,data:c,insight:i.insight,importMap:f,dir:Kt(n,s),watch:e,source:{file:ce.basename(n),codeLine:a.get("code.tsx")??1},bulbKey:gs(n),compileError:l}),m;return i.server&&t&&(m=await Ms(i.server,n,r,o.dependencies,s)),{html:p,bulb:i,serverExports:m,buildError:l}}var Wt,st=v(()=>{"use strict";vs();Jg();zg();ju();vy();Uu();ci();tt();Fy();Wt=(n,e)=>ce.join(Kt(n,e),"assets")});import{readdirSync as Jy,readFileSync as uP,statSync as Ky}from"fs";import{join as aa,basename as dP}from"path";function Wy(n,e,t){if(e>8)return t;let r;try{r=Jy(n,{withFileTypes:!0})}catch{return t}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;Wy(aa(n,s.name),e+1,t)}else s.isFile()&&s.name.endsWith(".bulb.md")&&t.push(aa(n,s.name));return t}function ad(n){let e=aa(Kt(n),"batches"),t;try{t=Jy(e,{withFileTypes:!0})}catch{return[]}return t.filter(r=>r.isDirectory()).map(r=>{let s=0;try{s=Ky(aa(e,r.name)).mtimeMs}catch{}return{name:r.name,mtime:s}}).sort((r,s)=>s.mtime-r.mtime).map(r=>r.name)}function fP(n,e){let t,r=!1;try{let s=uP(n,"utf8");t=Ro(s.slice(0,1024));let i=je(s);r=!!i&&_o(Zn(i))}catch{}return{mtime:e,name:t??dP(n).replace(/\.bulb\.md$/,""),serverOnly:r}}function ca(n){let e=new Map,t=Wy(n,0,[]).map(r=>{let s=0;try{s=Ky(r).mtimeMs}catch{}let i=s?qy.get(r):void 0,o=i?.mtime===s?i:fP(r,s);return s&&e.set(r,o),{path:r,...o}});return qy=e,t}var qy,Hy=v(()=>{"use strict";ee();vs();Au();st();qy=new Map});function mr(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 la=v(()=>{"use strict"});import{readFile as pP}from"fs/promises";async function cd(n){try{let e=je(await pP(n,"utf-8"));return e?mr(Zn(e)):void 0}catch{return}}var Yy=v(()=>{"use strict";vs();la()});function ld(n){let e=je(n);if(!e)return n;let t=e.files.get("code.tsx");if(!t)return n;let r=Yg(t);if(!r.length)return n;let s=e.files.get("config.json"),i={};if(s)try{let l=JSON.parse(s);l&&typeof l=="object"&&(i=l)}catch{}let o=i.dependencies&&typeof i.dependencies=="object"?{...i.dependencies}:{},a=r.filter(l=>!(l in o));if(!a.length)return n;for(let l of a)o[l]="latest";i.dependencies=o;let c={name:e.frontmatter.name};for(let[l,d]of e.files){let u=Mf(l);u&&(c[u]=d)}return c.config=JSON.stringify(i,null,2),Wf(c)}var Vy=v(()=>{"use strict";ee();Io()});import{spawn as zy}from"child_process";import{basename as hP}from"path";function mP(){return process.env.TYPEBULB_EDITOR||"code"}function yP(n,e,t){return t==null?[e]:gP.test(hP(n))?["-g",`${e}:${t}`]:[`+${t}`,e]}function bP(n,e){let t=mP();return{command:t,args:yP(t,n,e)}}function ud(n,e){let{command:t,args:r}=bP(n,e),s=process.platform==="win32"?zy("cmd.exe",["/d","/s","/c",t,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):zy(t,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var gP,Gy=v(()=>{"use strict";gP=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as wP,writeFileSync as vP,mkdirSync as SP,statSync as kP}from"fs";import{join as xP}from"path";function dd(){return xP(Mt(),"trust.json")}function fd(){try{let n=dd(),e=kP(n).mtimeMs;if(Bs?.mtime!==e){let t=JSON.parse(wP(n,"utf8"));Bs={mtime:e,set:new Set(Array.isArray(t)?t:[])}}return Bs.set}catch{return Bs=void 0,new Set}}function EP(n){try{SP(Mt(),{recursive:!0}),vP(dd(),JSON.stringify([...n])),Bs=void 0}catch(e){throw new Error(`can't write ${dd()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function Sn(n){return fd().has(se(n))}function gr(n,e){let t=new Set(fd()),r=se(n);(e?t.has(r):!t.has(r))||(e?t.add(r):t.delete(r),EP(t))}function pd(){return[...fd()]}var Bs,Ds=v(()=>{"use strict";tt()});import{readFileSync as OB,existsSync as AP}from"fs";import*as yr from"path";import{fileURLToPath as TP}from"url";function PP(){let n=yr.dirname(TP(import.meta.url));for(;!AP(yr.join(n,"package.json"));){let e=yr.dirname(n);if(e===n)break;n=e}return n}function js(){return yr.join(PP(),"SKILL.md")}var hd=v(()=>{"use strict"});import*as Pe from"fs/promises";import*as Ne from"path";import{createHash as OP}from"crypto";async function gd(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 br(n){try{return JSON.parse(n).error||n}catch{return n}}async function bd(n,e){try{let t=await fetch(Fs(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}): ${br(await t.text())}`}}catch(t){return{error:t instanceof Error?t.message:String(t)}}}function wd(n,e){Ie(e);let t=process.env.TYPEBULB_ORIGIN||CP;try{return fa(n,process.cwd(),t)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function fa(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}
|
|
1594
|
+
Expected <origin>/u/<user>/<slug>`);let c=a[1],l=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:c,slug:l,dest:Ne.join(e,ua(c,l))}}let r=Ne.resolve(e,n),s=hr(r);if(!s)throw new Error(`Not a conventional bulb path: ${n}
|
|
1595
|
+
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 _P(n,e){let t=await bd(n,e);if("error"in t||!t.entries.length)return{kind:"none"};let r=t.entries,s=Wt(n.dest),i=[],o=[],a=0;for(let c of r){let l=await Pe.readFile(Ne.join(s,...c.path.split("/"))).catch(()=>{});l===void 0?i.push(c.path):yd(l)===c.md5?a++:e.force?i.push(c.path):o.push(c.path)}return o.length?{kind:"conflict",paths:o}:{kind:"plan",toGet:i,unchanged:a}}async function RP(n,e,t){let r=Wt(n.dest),s=[],i=0;return await gd(e.toGet,4,async o=>{try{let a=await fetch(`${Fs(n)}/${da(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 c=Ne.join(r,...o.split("/"));await Pe.mkdir(Ne.dirname(c),{recursive:!0}),await Pe.writeFile(c,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 pa(n,e={}){let t=await fetch(md(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 Pe.readFile(n.dest,"utf-8")}catch{}let o=i!==void 0&&IP(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:l}=await Pe.stat(n.dest);return{kind:"conflict",dest:n.dest,localMtime:l,remoteLastModified:t.headers.get("last-modified")??void 0}}let a=await _P(n,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:n.dest,paths:a.paths};if(!o){await Pe.mkdir(Ne.dirname(n.dest),{recursive:!0}),await Pe.writeFile(n.dest,s);let l=new Date(t.headers.get("last-modified")??"");isNaN(l.getTime())||await Pe.utimes(n.dest,new Date,l)}let c=a.kind==="plan"?await RP(n,a,e):void 0;return o?{kind:"up-to-date",dest:n.dest,assets:c}:{kind:"written",dest:n.dest,created:i===void 0,assets:c}}function IP(n,e){let t=i=>i.replace(/\r\n/g,`
|
|
1596
|
+
`),r=je(t(n)),s=je(t(e));return!r||!s?t(n)===t(e):r.frontmatter.name===s.frontmatter.name&&De.every(i=>(r.files.get(ue[i].path)||"")===(s.files.get(ue[i].path)||""))}async function Qy(n,e){n||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let t=wd(n,e.mode),r=`${t.origin}/u/${t.userSlug}/${t.slug}`,s;try{s=await pa(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=Ne.relative(process.cwd(),t.dest)||t.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),Xy(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),Xy(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
|
|
1580
1597
|
local file modified ${s.localMtime.toISOString()}
|
|
1581
1598
|
remote last saved ${s.remoteLastModified??"unknown"}
|
|
1582
1599
|
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:
|
|
1583
1600
|
`+s.paths.map(o=>` assets/${o}`).join(`
|
|
1584
1601
|
`)+`
|
|
1585
|
-
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
|
|
1602
|
+
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 Xy(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 CP,ua,md,da,Fs,yd,ha=v(()=>{"use strict";gt();ee();st();CP="https://typebulb.com",ua=(n,e)=>Ne.join("typebulbs","u",n,`${e}.bulb.md`),md=n=>`${n.origin}/u/${encodeURIComponent(n.userSlug)}/${encodeURIComponent(n.slug)}.md`,da=n=>n.split("/").map(encodeURIComponent).join("/"),Fs=n=>`${n.origin}/u/${encodeURIComponent(n.userSlug)}/${encodeURIComponent(n.slug)}/assets`;yd=n=>OP("md5").update(n).digest("hex")});import*as it from"fs/promises";import*as Us from"path";async function Zy(n,e=""){let t=await it.readdir(n,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of t)s.isDirectory()?r.push(...await Zy(Us.join(n,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function NP(n,e){let t=e.timeoutMs??3e4,r=Fs(n),s={Authorization:`Bearer ${e.token}`},i=Wt(n.dest);if(!await it.stat(i).then(m=>m.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await Zy(i),a=await bd(n,{token:e.token,timeoutMs:t});if("error"in a)return{kind:"sync-error",message:a.error};let c=a.entries;if(!o.length&&!c.length)return{kind:"skipped"};let l=new Map(c.map(m=>[m.path,m.md5])),d=new Set(o),u=c.map(m=>m.path).filter(m=>!d.has(m)),f=0,p=0;try{await gd(o,4,async m=>{let h=await it.readFile(Us.join(i,...m.split("/")));if(l.get(m)===yd(h)){p++;return}let y=await fetch(`${r}/${da(m)}`,{method:"PUT",body:new Uint8Array(h),headers:s,signal:AbortSignal.timeout(t)});if(!y.ok)throw new Error(`upload of '${m}' refused (${y.status}): ${br(await y.text())}`);f++})}catch(m){return{kind:"sync-error",message:m instanceof Error?m.message:String(m)}}return{kind:"synced",uploaded:f,unchanged:p,toDelete:u,base:fi(n.userSlug,n.slug)}}async function $P(n,e,t){let r=t.timeoutMs??3e4,s=Fs(n),i=[];for(let o of e)try{let a=await fetch(`${s}/${da(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}): ${br(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function ma(n,e){let t=await it.readFile(n.dest,"utf-8"),{mtime:r}=await it.stat(n.dest),s=await NP(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(md(n),{method:"PUT",body:t,headers:o,signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0}),c=await a.text();if(a.status===409)return{kind:"conflict",message:br(c),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:br(c),assets:i};let l=JSON.parse(c);if(await it.utimes(n.dest,new Date,new Date(l.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let d=await $P(n,s.toDelete,{token:e.token,timeoutMs:e.timeoutMs});i.deleted=d.deleted,d.error&&(i.pruneError=d.error)}return{kind:"pushed",created:l.created,serverStripped:l.serverStripped,updatedAt:l.updatedAt,assets:i}}async function eb(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=wd(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=Us.relative(process.cwd(),t.dest)||t.dest,o;try{o=await ma(t,{token:r,force:e.force})}catch(a){let c=a instanceof Error?a.message:String(a);console.error(a?.code==="ENOENT"?`File not found: ${i}`:`Could not push to ${t.origin}: ${c}`),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}
|
|
1586
1603
|
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}
|
|
1587
1604
|
pull to see the remote: typebulb pull ${i}
|
|
1588
|
-
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
|
|
1605
|
+
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 vd=v(()=>{"use strict";ee();ha();st()});var wr=v(()=>{"use strict";Ce();Hy();cn();Yy();Au();Vy();Gy();Ds();vn();vn();sa();hd();Ce();ha();vd();gt()});import{existsSync as LP,mkdirSync as MP,readFileSync as BP,rmSync as DP,writeFileSync as jP}from"fs";import{homedir as FP}from"os";import*as vr from"path";function KP(){return JP.replace('"__TB_SKILL_PATH__"',JSON.stringify(js())).replace('"__TB_BIN_PATH__"',JSON.stringify(Qn()))}function tb(){try{if(!LP(Sd()))return}catch{return}try{let n=UP(),e=KP(),t;try{t=BP(n,"utf8")}catch{}t!==e&&(MP(vr.dirname(n),{recursive:!0}),jP(n,e))}catch{}for(let n of qP())try{DP(n,{force:!0})}catch{}}var Sd,UP,qP,JP,nb=v(()=>{"use strict";wr();Sd=()=>vr.join(FP(),".pi","agent"),UP=()=>vr.join(Sd(),"extensions","typebulb.ts"),qP=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(n=>vr.join(Sd(),"extensions",n)),JP=String.raw`// Generated by typebulb — do not edit; overwritten on each run.
|
|
1589
1606
|
import { spawn } from "node:child_process";
|
|
1590
1607
|
import { existsSync } from "node:fs";
|
|
1591
1608
|
|
|
@@ -1853,23 +1870,23 @@ export default function (pi) {
|
|
|
1853
1870
|
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) {}
|
|
1854
1871
|
} catch (e) { logErr("load", e && e.message); }
|
|
1855
1872
|
}
|
|
1856
|
-
`});function
|
|
1857
|
-
`))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var
|
|
1858
|
-
`)}catch{}await Promise.race([this.#k,ob
|
|
1859
|
-
`)}catch{}}#
|
|
1860
|
-
`),tool:e?.kind==="tool"?e.name:void 0}}#E(e){let t=Array.isArray(e?.content)?e.content:[];this.#c=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.#
|
|
1861
|
-
`)}catch(c){clearTimeout(a),this.#l.delete(s),o(new Error(
|
|
1862
|
-
`).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function
|
|
1863
|
-
`),c=i.filter(f=>f.type==="toolCall").map(f=>({id:f.id??"",name:f.name??"",input:f.arguments??{}}));if(o||a||c.length){let f=Date.parse(e.timestamp??""),p=!isNaN(f)&&f>=t;r.push({type:"assistant",text:o,thinking:a,tools:c,live:p})}let l=s.usage,d=l?(l.input??0)+(l.output??0)+(l.cacheRead??0)+(l.cacheWrite??0):0,u=l&&d>0&&s.stopReason!=="aborted"&&s.stopReason!=="error"?{in:l.input??0,out:l.output??0,cached:l.cacheRead??0,cacheCreate:l.cacheWrite??0}:void 0;return{events:r,usage:u,model:s.model,cost:l?.cost?.total}}return{events:r}}chainWorking(e){let t;for(let a of e)
|
|
1864
|
-
`))if(p.includes('"session_info"'))try{let
|
|
1865
|
-
`))if(!(l||!u.includes('"type"')))try{let f=JSON.parse(u);f?.type==="message"&&f.message?.role==="user"&&(l=this.contentText(f.message.content).replace(/\s+/g," ").trim())}catch{}let d=c(a)||c(o)||l;return d?d.slice(0,200):""}finally{
|
|
1866
|
-
`):""}}});var wa,
|
|
1867
|
-
|
|
1868
|
-
${n.slice(0,
|
|
1869
|
-
`+
|
|
1873
|
+
`});function V(n){return n?.message??String(n)}var G,Ht=v(()=>{"use strict";G=process.cwd()});import{spawn as rb}from"child_process";import{StringDecoder as WP}from"string_decoder";function XP(n,e){let t=new WP("utf8"),r="";n.on("data",s=>{r+=typeof s=="string"?s:t.write(s);let i;for(;(i=r.indexOf(`
|
|
1874
|
+
`))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var HP,sb,ib,kd,ob,YP,VP,zP,ab,GP,ga,ya,cb,lb=v(()=>{"use strict";Ht();HP=3e4,sb=18e4,ib="starting pi\u2026",kd=5e3,ob=2e3,YP=2e3,VP=12e4,zP=8e3,ab=15e3,GP=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"]),ga=new Set;process.on("exit",()=>{for(let n of ga)try{n.kill()}catch{}});ya=class{#e;#s=!1;#t=0;#r=!1;#T=0;#a=!1;#m=null;#c=[];#g=null;#n=null;#i=null;#d=new Map;#o=[];#y=null;#S=null;#b=null;#f;#p;#w="";#_=1;#l=new Map;#k;#v;constructor(e,t,r=(s,i)=>rb(s,{cwd:i,shell:!0,stdio:["pipe","pipe","pipe"],env:{...process.env,TYPEBULB_MIRROR:"1"}})){if(this.#k=new Promise(o=>{this.#v=o}),t?.includes('"')){this.#p="session path contains a quote \u2014 cannot drive it",this.#v();return}let s=t?`pi --mode rpc --session "${t}"`:"pi --mode rpc",i;try{i=r(s,e)}catch(o){this.#p=`could not start pi: ${V(o)}`,this.#v();return}this.#e=i,this.#f=t,this.#r=!0,this.#T=Date.now()+sb,this.#n={text:ib,kind:"info"},ga.add(i),i.stdout&&XP(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#w=(this.#w+o.toString()).slice(-YP)}),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.#w.trim()?`: ${this.#w.trim()}`:""}`:"pi exited"),ga.delete(i),this.#v()}),this.#u({type:"get_state"}).then(o=>{let a=o.data?.sessionFile;typeof a=="string"&&a&&(this.#f=a);let c=o.data?.model;c&&typeof c.id=="string"&&c.id&&(this.#b=c.id)}).catch(()=>{}).finally(()=>this.#R())}#R(){this.#r&&(this.#r=!1,this.#n?.text===ib&&(this.#n=null),this.#i&&(this.#i.until=Date.now()+ab),!this.#s&&Date.now()<this.#t&&(this.#t=Date.now()+kd),this.#A())}get streaming(){return this.#s||Date.now()<this.#t}get draft(){return this.#m}get echo(){return this.#g}get queue(){return this.#y}get stats(){return this.#S}get model(){return this.#b}get sessionFile(){return this.#f}get error(){return this.#p}get status(){if(this.#n)return this.#n;if(this.#i){if(Date.now()<this.#i.until)return{text:this.#i.text,kind:this.#i.kind};this.#i=null}return this.#d.size?{text:[...this.#d.values()].join(" \xB7 "),kind:"info"}:null}get dialog(){let e=Date.now();for(;this.#o.length;){let t=this.#o[0];if(e<t.until)return t.req;this.#o.shift(),t.ownTimeout||this.#x({type:"extension_ui_response",id:t.req.id,cancelled:!0})}return null}notice(e,t){this.#h(e,t)}respondUi(e,t){let r=this.#o.findIndex(o=>o.req.id===e);if(r<0)return{ok:!1,error:"dialog expired or already answered"};let[s]=this.#o.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.#x(i),{ok:!0}}async rpc(e){if(!GP.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let t=await this.#u(e);if(t.success&&e.type==="set_model"){let r=t.data?.id;typeof r=="string"&&r&&(this.#b=r)}if(t.success&&(e.type==="fork"||e.type==="clone")){try{let s=(await this.#u({type:"get_state"})).data?.sessionFile;typeof s=="string"&&s&&(this.#f=s)}catch{}return{ok:!0,data:{...t.data??{},sessionFile:this.#f}}}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=c=>{r||(this.#t=c,s||(this.#g=e))};if(this.#r)return this.#u(i).catch(()=>{}),o(this.#T+kd),{ok:!0};let a;try{a=await this.#u(i)}catch(c){return{ok:!1,error:V(c)}}return a.success&&o(Date.now()+kd),a.success?{ok:!0}:{ok:!1,error:a.error??"pi rejected the message"}}async stop(){if(this.#e){if(this.#r){this.#x({type:"abort"}),this.#t=0;return}try{await this.#u({type:"abort"})}catch{}}}clearCompletedDraft(){this.#a||(this.#m=null)}clearEcho(){this.#g=null}async dispose(){let e=this.#e;if(e){if(this.#e=void 0,this.#r=!1,this.#s){try{e.stdin?.write(JSON.stringify({type:"abort"})+`
|
|
1875
|
+
`)}catch{}await Promise.race([this.#k,cb(ob)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#k,cb(ob)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{rb("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}ga.delete(e),this.#o=[],this.#C("pi was shut down")}}#x(e){try{this.#e?.stdin?.write(JSON.stringify(e)+`
|
|
1876
|
+
`)}catch{}}#P(){let e=this.#c[this.#c.length-1];this.#m={text:this.#c.filter(t=>t?.kind==="text").map(t=>t.text).join(""),thinking:this.#c.filter(t=>t?.kind==="thinking").map(t=>t.text).join(`
|
|
1877
|
+
`),tool:e?.kind==="tool"?e.name:void 0}}#E(e){let t=Array.isArray(e?.content)?e.content:[];this.#c=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()}#h(e,t){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#i={text:r,kind:t,until:Date.now()+(t==="info"?zP:ab)})}#A(){this.#u({type:"get_session_stats"}).then(e=>{if(!e.success||!e.data)return;let t=e.data;this.#S={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(()=>{})}#u(e){let t=this.#e;if(!t?.stdin?.writable)return Promise.reject(new Error(this.#p??"pi is not running"));let r=this.#r?sb:HP,s=`tb-${this.#_++}`;return new Promise((i,o)=>{let a=setTimeout(()=>{this.#l.delete(s),o(new Error(`pi did not respond (${Math.round(r/1e3)}s)`))},r);a.unref?.(),this.#l.set(s,{resolve:i,timer:a});try{t.stdin.write(JSON.stringify({id:s,...e})+`
|
|
1878
|
+
`)}catch(c){clearTimeout(a),this.#l.delete(s),o(new Error(V(c)))}})}#I(e){let t;try{t=JSON.parse(e)}catch{return}switch(t.type){case"response":{let r=t,s=r.id?this.#l.get(r.id):void 0;s&&(this.#l.delete(r.id),clearTimeout(s.timer),s.resolve(r));return}case"agent_start":this.#s=!0,this.#t=0;return;case"agent_end":this.#s=!1,this.#t=0,this.#a=!1,this.#n=null,this.#y=null,this.#A();return;case"message_start":{let r=t.message;if(r?.role!=="assistant")return;this.#a=!0,this.#E(r);return}case"message_update":{if(!this.#a)return;if(t.message){this.#E(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.#c[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.#a)return;t.message&&this.#E(t.message),this.#a=!1;return;case"auto_retry_start":this.#n={text:`retrying after a transient error (attempt ${Number(t.attempt)||1}/${Number(t.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#n=null,t.success===!1&&this.#h(`retries exhausted: ${String(t.finalError??"unknown error")}`,"error");return;case"compaction_start":this.#n={text:"compacting context\u2026",kind:"info"};return;case"compaction_end":{this.#n=null;let r=t.result;typeof t.errorMessage=="string"&&t.errorMessage?this.#h(`compaction failed: ${t.errorMessage}`,"error"):r?.tokensBefore&&this.#h(`compacted: ~${Math.round(r.tokensBefore/1e3)}k \u2192 ~${Math.round((r.estimatedTokensAfter??0)/1e3)}k tokens`,"info"),this.#A();return}case"queue_update":{let r=Array.isArray(t.steering)?t.steering.map(String):[],s=Array.isArray(t.followUp)?t.followUp.map(String):[];this.#y=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.#o.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??VP),ownTimeout:s!==void 0})}else if(r==="notify"){let s=t.notifyType==="warning"?"warning":t.notifyType==="error"?"error":"info";this.#h(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.#d.set(s,t.statusText):this.#d.delete(s)}return}default:return}}#O(e){this.#p=e,this.#r=!1,this.#s=!1,this.#t=0,this.#a=!1,this.#m=null,this.#c=[],this.#g=null,this.#n=null,this.#i=null,this.#d.clear(),this.#o=[],this.#y=null,this.#S=null,this.#b=null,this.#e=void 0,this.#C(e)}#C(e){for(let[,t]of this.#l)clearTimeout(t.timer),t.resolve({type:"response",success:!1,error:e});this.#l.clear()}},cb=n=>new Promise(e=>{setTimeout(e,n).unref?.()})});import{existsSync as ub,readFileSync as QP,realpathSync as ZP}from"fs";import{join as kn,dirname as hb,resolve as eO}from"path";import{homedir as db}from"os";function nO(n,e){let t=kn(n,".pi");if(tO.some(s=>ub(kn(t,s))))return!0;let r=kn(e,".agents","skills");for(let s=n;;){let i=kn(s,".agents","skills");if(i!==r&&ub(i))return!0;let o=hb(s);if(o===s)return!1;s=o}}function rO(n,e){for(let t=e;;){if(n[t]===!0||n[t]===!1)return!0;let r=hb(t);if(r===t)return!1;t=r}}function mb(n,e){try{let t=e?.agentDir??kn(db(),".pi","agent"),r=fb(e?.home??process.env.HOME??db()),s=fb(eO(n));if(!nO(s,r))return null;let i=pb(kn(t,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||rO(pb(kn(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 tO,fb,pb,gb=v(()=>{"use strict";tO=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],fb=n=>{try{return ZP(n)}catch{return n}},pb=n=>{try{return JSON.parse(QP(n,"utf8"))}catch{return{}}}});import{statSync as sO,openSync as iO,readSync as oO,closeSync as aO,existsSync as bb}from"fs";import{join as ba}from"path";import{homedir as xd}from"os";import{execFile as cO}from"child_process";async function uO(n){let e=ba(xd(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let t of["fd","fdfind",...bb(e)?[e]:[]]){let r=await new Promise(s=>{cO(t,["--base-directory",n,"--type","f","--follow","--hidden","--exclude",".git"],{maxBuffer:67108864},(i,o)=>s(i?null:o))});if(r!==null)return r.split(`
|
|
1879
|
+
`).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function dO(n){return`--${n.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function yb(n){return n.type==="message"?fO(n.message?.role):n.type==="custom_message"?n.display!==!1:!1}var lO,fO,Sr,Ed=v(()=>{"use strict";fs();nu();go();nb();lb();gb();lO=ba(xd(),".pi","agent","sessions");fO=n=>n==="user"||n==="assistant"||n==="toolResult"||n==="bashExecution";Sr=class extends $t{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return bb(ba(xd(),".pi","agent"))}ensureHarnessSupport(){tb()}createDriver(e,t){let r=new ya(e,t),s=mb(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return uO(e)}sessionsDir(e){return ba(lO,dO(e))}listSessionFiles(e){return mo(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 yb(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:qe(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(f=>f.type==="text").map(f=>f.text??"").join(""),a=i.filter(f=>f.type==="thinking").map(f=>f.thinking??"").join(`
|
|
1880
|
+
`),c=i.filter(f=>f.type==="toolCall").map(f=>({id:f.id??"",name:f.name??"",input:f.arguments??{}}));if(o||a||c.length){let f=Date.parse(e.timestamp??""),p=!isNaN(f)&&f>=t;r.push({type:"assistant",text:o,thinking:a,tools:c,live:p})}let l=s.usage,d=l?(l.input??0)+(l.output??0)+(l.cacheRead??0)+(l.cacheWrite??0):0,u=l&&d>0&&s.stopReason!=="aborted"&&s.stopReason!=="error"?{in:l.input??0,out:l.output??0,cached:l.cacheRead??0,cacheCreate:l.cacheWrite??0}:void 0;return{events:r,usage:u,model:s.model,cost:l?.cost?.total}}return{events:r}}chainWorking(e){let t;for(let a of e)yb(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=iO(e,"r")}catch{return""}try{let s=65536;try{s=sO(e).size}catch{}let i=(u,f)=>{let p=Buffer.alloc(f),m=oO(t,p,0,f,u);return p.subarray(0,m).toString("utf8")},o=i(0,Math.min(65536,s)),a=s>65536?i(s-65536,65536):"",c=u=>{let f="";for(let p of u.split(`
|
|
1881
|
+
`))if(p.includes('"session_info"'))try{let m=JSON.parse(p);m?.type==="session_info"&&typeof m.name=="string"&&m.name&&(f=m.name)}catch{}return f},l="";for(let u of o.split(`
|
|
1882
|
+
`))if(!(l||!u.includes('"type"')))try{let f=JSON.parse(u);f?.type==="message"&&f.message?.role==="user"&&(l=this.contentText(f.message.content).replace(/\s+/g," ").trim())}catch{}let d=c(a)||c(o)||l;return d?d.slice(0,200):""}finally{aO(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"?Ee(e):Array.isArray(e)?e.map(t=>typeof t?.text=="string"?Ee(t.text):t?.type==="image"&&t.data?ho(t.data,t.mimeType):"").filter(Boolean).join(`
|
|
1883
|
+
`):""}}});var wa,wb=v(()=>{"use strict";wa=class{#e=new Map;accept(e,t){return this.#e.get(e)===t?!1:(this.#e.set(e,t),!0)}}});import{execFile as pO}from"child_process";import{promisify as hO}from"util";import{readFile as mO}from"fs/promises";import{resolve as vb,sep as gO}from"path";async function Ge(n,e){let{stdout:t}=await yO("git",n,{cwd:e,maxBuffer:67108864});return t}async function xn(){if(va)return va;try{va=(await Ge(["rev-parse","--show-toplevel"],G)).trim()}catch{}return va}function bO(n,e){let t=e===" "?n:e;return t==="?"?"U":t}async function Td(){let n=await xn();if(!n)return{repo:!1,root:"",files:[]};try{let e=await Ge(["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:bO(i[0],i[1])}))}try{let s=await Ge(["diff","--numstat","-z","HEAD"],n),i=new Map,o=s.split("\0");for(let a=0;a<o.length;a++){let c=/^(\d+|-)\t(\d+|-)\t(.*)$/.exec(o[a]);if(!c)continue;let l=c[3]||o[a+=2];l&&i.set(l,{add:+c[1]||0,del:+c[2]||0,binary:c[1]==="-"})}for(let a of t){let c=i.get(a.path);c&&(c.binary?a.binary=!0:(a.add=c.add,a.del=c.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 Pd(n){let e=await xn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await Ge(["status","--porcelain","-z","--",n],e)).startsWith("??")){let s=vb(e,n);if(!s.startsWith(vb(e)+gO))return{ok:!1,error:"outside repository"};let i=await mO(s);return i.includes(0)?Ad("Binary file (not shown)",!1):Ad(i.toString("utf8"),!0)}let r;try{r=await Ge(["diff","--no-color","--unified=999999","HEAD","--",n],e)}catch{r=await Ge(["diff","--no-color","--unified=999999","--",n],e)}return Ad(r,!1)}catch(t){return{ok:!1,error:V(t)}}}var yO,Sb,va,Ad,qs=v(()=>{"use strict";Ht();yO=hO(pO),Sb=2e6;Ad=(n,e)=>({ok:!0,text:n.slice(0,Sb),untracked:e,truncated:n.length>Sb})});function Sa(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 Od=v(()=>{"use strict"});function kb(){return wO.map(([n,e])=>bt(n,e)).filter(n=>typeof n!="string")}function xb(){return kb().length>0}async function ka(n,e,t=0){let r=AbortSignal.timeout(e);for(let s of kb()){try{let i=await Jt(s,{messages:[{role:"user",content:n}],effort:t,webSearch:!1,signal:r});if(i.ok){let o=(await Gu(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var wO,Cd=v(()=>{"use strict";wn();wr();wO=[["openrouter","openai/gpt-5.6-luna"],["openai","gpt-5.6-luna"]]});var xa,Ea,Eb=v(()=>{"use strict";xa=".typebulb/paste",Ea={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 vO,mkdirSync as SO,writeFileSync as kO,readFileSync as xO}from"fs";import{join as Aa}from"path";function Ab(){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 TO(n){return n.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function PO(n){let e=await ka(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
|
|
1884
|
+
|
|
1885
|
+
${n.slice(0,AO)}`,EO);return e&&TO(e)||void 0}async function Tb(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=Aa(n,xa);try{SO(t,{recursive:!0})}catch(a){return{ok:!1,error:V(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${Ab()}`,s=Object.keys(Ea).find(a=>Ea[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await PO(e.data)??`paste-${Ab()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;vO(Aa(t,o));a++)o=`${r}-${a}.${s}`;try{kO(Aa(t,o),i)}catch(a){return{ok:!1,error:V(a)}}return{ok:!0,path:`${xa}/${o}`}}function Pb(n,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let t=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=Ea[t];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:xO(Aa(n,xa,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var EO,AO,Ob=v(()=>{"use strict";Cd();Ht();Eb();EO=4e3,AO=4e3});async function Rb(n,e=""){let t=n.trim();if(!t)return{ok:!1,error:"nothing to summarize"};if(!xb())return{ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0};let r=e.trim()?_b+`CONTEXT \u2014 the user message this reply answers. It is context only: never summarize it, and never report it as the reply's content.
|
|
1886
|
+
`+CO(e.trim())+`
|
|
1870
1887
|
|
|
1871
1888
|
REPLY TO SUMMARIZE:
|
|
1872
|
-
`+t.slice(0,
|
|
1889
|
+
`+t.slice(0,Cb):_b+t.slice(0,Cb),s=await ka(r,OO,1);return s?{ok:!0,text:s}:{ok:!1,error:"the model call failed or timed out"}}var OO,Cb,_b,CO,Ib=v(()=>{"use strict";Cd();OO=2e4,Cb=24e3,_b=`Summarize this assistant reply for someone who wants its substance without the prose.
|
|
1873
1890
|
|
|
1874
1891
|
- 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.
|
|
1875
1892
|
- 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.
|
|
@@ -1884,23 +1901,23 @@ Reply with the summary alone.
|
|
|
1884
1901
|
|
|
1885
1902
|
---
|
|
1886
1903
|
|
|
1887
|
-
`,
|
|
1904
|
+
`,CO=(n,e=4e3)=>{if(n.length<=e)return n;let t=Math.floor(e/2)-20;return n.slice(0,t)+`
|
|
1888
1905
|
|
|
1889
1906
|
[snipped for brevity]
|
|
1890
1907
|
|
|
1891
|
-
`+n.slice(n.length-t)}});function
|
|
1892
|
-
`))>=0;){let
|
|
1893
|
-
`).filter(Boolean):await n.walkFiles?.(e.cwd)??[];return(await Promise.all(
|
|
1894
|
-
`)){if(!
|
|
1895
|
-
`)){if(!
|
|
1896
|
-
`)){let l=c.replace(/\s+/g," ").trim();l&&i.push({text:l,lower:l.toLowerCase()})}let{hitCount:o,snippet:a}=Sa(i,e);o&&t.push({path:r.path,hitCount:o,snippet:a})}return t}async function
|
|
1897
|
-
${n}`;return
|
|
1898
|
-
`)}function
|
|
1908
|
+
`+n.slice(n.length-t)}});function _O(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 Nb,$b=v(()=>{"use strict";Nb=(n,e)=>_O(n,{key:e,desc:!0})});import{existsSync as Lb,openSync as RO,readSync as IO,closeSync as NO,statSync as kr,readdirSync as Mb,watchFile as $O,unwatchFile as Bb,mkdirSync as LO,writeFileSync as MO,readFileSync as Ta,unlinkSync as BO,rmSync as DO}from"fs";import{stat as jO}from"fs/promises";import{dirname as FO,join as En,resolve as Db}from"path";function KO(n){if(!Number.isInteger(n))return!0;try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}function xr(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 S={d:n.createDriver(e.cwd,g),file:g,id:`new:${++s}`,startedAt:Date.now()};return t.add(S),e.file||(r=S),S}function a(){let g=[...t].filter(w=>w.file);if(!g.length)return[];let S=new Map(n.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return g.map(w=>{let P=S.get(w.file);return{rec:w,sessionId:P??w.id,pending:P===void 0}})}let c=()=>a().filter(g=>g.pending&&g.rec.prompt!==void 0);async function l(g){t.delete(g),r===g&&(r=void 0);try{await g.d.dispose()}catch(S){console.error("[composer] dispose:",V(S))}}function d(){let g=i(),S=new Set(c().map(w=>w.rec));for(let w of[...t])w!==g&&(S.has(w)||w.d.streaming||w.d.queue||w.d.error||l(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(S=>S.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 f=g=>En(g,qO),p=(g,S)=>En(f(g),`${S}.lock`);function m(g,S){try{let w=p(g,S);if(Date.now()-kr(w).mtimeMs>=jb)return!1;try{let P=parseInt(Ta(w,"utf8").trim(),10);if(P===process.pid||!KO(P))return!1}catch{}return!0}catch{return!1}}function h(g,S){if(S)try{LO(f(g),{recursive:!0}),MO(p(g,S),String(process.pid))}catch(w){console.error("[lock] claim failed:",V(w))}}function y(g){try{DO(En(g,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function x(g){let S=f(g);if(!Lb(S))return;let w;try{w=Mb(S)}catch{return}let P=Date.now();for(let M of w){if(!M.endsWith(".lock"))continue;let j=En(S,M);try{let B=kr(j);P-B.mtimeMs>JO&&BO(j)}catch{}}}function T(g){try{return kr(g),!1}catch(S){return S.code==="ENOENT"}}function O(){let g=e;if(g.file&&!T(g.file)){h(g.cwd,g.sessionId);return}let S=E(g);S&&A(S)}function E(g){if(!g.everAttached)return I(g.cwd)??R(g.cwd,()=>!0)}function I(g){let S=f(g);if(!Lb(S))return;let w;try{w=Mb(S)}catch{return}let P;for(let j of w)if(j.endsWith(".lock"))try{let B=kr(En(S,j));if(Date.now()-B.mtimeMs>=jb||parseInt(Ta(En(S,j),"utf8").trim(),10)!==process.pid)continue;(!P||B.mtimeMs>P.mtime)&&(P={sessionId:j.slice(0,-5),mtime:B.mtimeMs})}catch{}if(!P)return;let M=n.listSessionFiles(g).find(j=>j.sessionId===P.sessionId);if(!(!M||T(M.file)))return M}function R(g,S){return n.listSessionFiles(g).sort((w,P)=>P.mtime-w.mtime).find(w=>!m(g,w.sessionId)&&S(w))}function $(g,S){let w=e;if(w.file)try{Bb(w.file)}catch{}w.file=g,w.sessionId=S,w.partial="",w.offset=0,w.latest={in:0,out:0,cached:0,cacheCreate:0},w.latestModel=null,w.entries=new Map,w.chainLastId=void 0,w.buffer.push({type:"cleared"}),w.buffer.push({type:"session",sessionId:S})}function A(g){let S=e;r=void 0,$(g.file,g.sessionId),S.everAttached=!0,h(S.cwd,g.sessionId),Q();try{Bb(g.file)}catch{}$O(g.file,{interval:200},()=>Q())}function J(){$(void 0,"")}function Q(){let g=e;if(!g.file)return;let S;try{S=kr(g.file).size}catch{return}if(S<=g.offset)return;let w;try{w=RO(g.file,"r")}catch{return}try{let Y=S-g.offset,xe=Buffer.alloc(Y),le=0;for(;le<Y;){let Pf=IO(w,xe,le,Y-le,g.offset+le);if(!Pf)break;le+=Pf}g.offset+=le,g.partial+=xe.subarray(0,le).toString("utf8")}finally{NO(w)}let P,M;for(;(M=g.partial.indexOf(`
|
|
1909
|
+
`))>=0;){let Y=g.partial.slice(0,M);if(g.partial=g.partial.slice(M+1),!Y.trim())continue;let xe=n.parseEntry(Y);if(!xe)continue;let le=n.idOf(xe);le&&(g.entries.set(le,xe),!n.isSidechain(xe)&&n.isLeafType(xe)&&(P=le))}if(!P)return;let j=[],B=g.entries.get(P),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))),xe=Z(g.entries);for(let le=j.length-1;le>=0;le--)de(j[le]),F(n.idOf(j[le]),xe,Y)}g.chainLastId=P}function Z(g){let S=new Map;for(let w of g.values()){let P=n.parentOf(w);if(!P)continue;let M=S.get(P);M?M.push(w):S.set(P,[w])}return S}function F(g,S,w){if(!g)return;let P=S.get(g);if(!P)return;let M=P.filter(Y=>!n.isSidechain(Y));if(M.length<2)return;let j=M.filter(Y=>!w.has(n.idOf(Y)));if(!j.length)return;let B=[],z=0;for(let Y of j){let xe=ye(Y,S);B.push(...xe.events),z+=xe.count}z>0&&e.buffer.push({type:"fork",atId:g,count:z,events:B})}function ye(g,S){let w=[],P=[g];for(;P.length;){let B=P.pop();if(n.isSidechain(B))continue;w.push(B);let z=S.get(n.idOf(B)??"");if(z)for(let Y of z)P.push(Y)}w.sort((B,z)=>(Date.parse(n.timestampOf(B)??"")||0)-(Date.parse(n.timestampOf(z)??"")||0));let M=[];for(let B of w)n.isRecoveryNoise(B)||M.push(...n.apply(B,e.sessionStartMs).events);return{count:M.reduce((B,z)=>B+(z.type==="user"||z.type==="assistant"?1:0),0),events:M}}function de(g){try{let{events:S,usage:w,model:P,cost:M}=n.apply(g,e.sessionStartMs);for(let j of S)e.buffer.push(j);S.some(j=>j.type==="assistant")&&i()?.d.clearCompletedDraft(),S.some(j=>j.type==="user")&&i()?.d.clearEcho(),P&&(e.latestModel=P),w&&(e.latest=w),(w||M)&&e.buffer.push({type:"usage",...e.latest,cost:M})}catch(S){console.error("[mirror] skipped malformed entry:",V(S))}}async function Me(){return{cwd:e.cwd,pid:process.pid,composer:!!n.createDriver,elsewhere:await be()}}async function be(){if(n.listSessionFiles(e.cwd).length)return;let g=await xn();if(!g)return;let S=Db(g).toLowerCase();for(let w=Db(e.cwd);w.toLowerCase()!==S;){let P=FO(w);if(P===w)return;w=P;let M=n.listSessionFiles(w).length;if(M)return{dir:w,count:M}}}be().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 ne=new wa;async function ri(g,S){ne.accept(g,S)&&console.log(S)}function si(){let g=n.sessionAlive(e.sessionId,e.cwd);if(g!==void 0)return g;if(!e.file)return!1;try{return Date.now()-kr(e.file).mtimeMs<1e4}catch{return!1}}function at(){return n.chainWorking([...e.entries.values()])&&si()}function b(){!n.createDriver||i()||e.latestModel||at()||o(e.file)}async function k(g){let S=e;O(),u(),b(),d();let w=i();for(let B of t)B!==w&&B.d.dialog;let P=a().filter(B=>B.rec.d.streaming).map(B=>B.sessionId),M=at(),j=n.createDriver?{streaming:!!w?.d.streaming,foreign:!w&&M,draft:w?.d.draft??null,echo:w?.d.echo??null,status:w?.d.status??null,dialog:w?.d.dialog??null,queue:w?.d.queue??null,stats:w?.d.stats??null,model:w?.d.model??null,error:w?.d.error}:void 0;return{events:S.buffer.slice(g),cursor:S.buffer.length,working:!!w?.d.streaming||M,latestModel:S.latestModel,composer:j,busy:P}}async function _(){O(),u();let g=i();if(g?.d.error&&!g.d.streaming&&(await l(g),g=void 0),!g){if(at())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};g=o(e.file)}let S=g;return{ok:!0,d:S.d,markSent:w=>{S.prompt===void 0&&(S.prompt=w)}}}async function N(g,S){if(!n.createDriver)return{ok:!1,error:"not supported"};let w=String(g??"").trim();if(!w)return{ok:!1,error:"empty message"};let P=await _();if(!P.ok)return P;let M=await P.d.send(w,S);return M.ok&&P.markSent(w),M}async function L(g,S){let w=i();return w?w.d.respondUi(String(g??""),S??{}):{ok:!1,error:"no dialog pending"}}async function W(g,S){if(!n.createDriver)return{ok:!1,error:"not supported"};if(!g||typeof g.type!="string")return{ok:!1,error:"bad command"};if(S?.spawn){let P=await _();return P.ok?P.d.rpc(g):P}let w=i();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(g)}async function q(){let g=i();if(g)try{await g.d.stop()}catch(S){console.error("[composer] stop:",V(S))}return{ok:!0}}async function we(){return n.createDriver?(u(),!e.file&&r&&r.prompt===void 0&&!r.d.streaming&&!r.d.error?{ok:!0}:(r?.d.error&&await l(r),r=void 0,J(),o(void 0),d(),{ok:!0})):{ok:!1,error:"not supported"}}async function H(){if(!n.createDriver)return[];let g=await Ge(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),S=g!==null?g.split(`
|
|
1910
|
+
`).filter(Boolean):await n.walkFiles?.(e.cwd)??[];return(await Promise.all(S.map(async P=>{try{return{f:P,m:(await jO(En(e.cwd,P))).mtimeMs}}catch{return{f:P,m:0}}}))).sort((P,M)=>M.m-P.m).map(P=>P.f)}function ie(){for(let g of[...t])l(g)}async function Be(g){return n.createDriver?Tb(e.cwd,g):{ok:!1,error:"not supported"}}async function Qe(g){return Pb(e.cwd,String(g??""))}async function Qt(g,S){return Rb(String(g??""),String(S??""))}async function xt(){let g=n.listSessionFiles(e.cwd).map(({sessionId:w,file:P,mtime:M})=>({sessionId:w,mtime:M,preview:n.readPreview(P)})),S=c().map(w=>({sessionId:w.sessionId,mtime:w.rec.startedAt,preview:w.rec.prompt??"",pending:!0}));return Nb([...g,...S],w=>w.mtime)}let ii=new Map;function tc(g,S){let w=ii.get(g);if(w&&w.mtime===S)return w.turns;let P=[],M="";try{M=Ta(g,"utf8")}catch{return[]}for(let j of M.split(`
|
|
1911
|
+
`)){if(!j.trim())continue;let B=n.parseEntry(j);if(!B)continue;let z=n.searchText(B);z&&P.push({text:z,lower:z.toLowerCase()})}return ii.set(g,{mtime:S,turns:P}),P}async function $v(g){let S=g.toLowerCase(),w=[];for(let{sessionId:P,file:M,mtime:j}of n.listSessionFiles(e.cwd).sort((B,z)=>z.mtime-B.mtime)){let{hitCount:B,snippet:z}=Sa(tc(M,j),S);if(B&&(w.push({sessionId:P,mtime:j,preview:n.readPreview(M),hitCount:B,snippet:z}),w.length>=WO))break}return w}let Af=800,Tf=new Map;function Lv(g,S){let w=Tf.get(g);if(w&&w.mtime===S)return w.text;let P="";try{P=Ta(g,"utf8")}catch{return""}let M="";for(let B of P.split(`
|
|
1912
|
+
`)){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()&&(M=Y.text.trim())}let j=M.length>Af?M.slice(0,Af).trimEnd()+"\u2026":M;return Tf.set(g,{mtime:S,text:j}),j}async function Mv(g){let S=n.listSessionFiles(e.cwd).find(w=>w.sessionId===g);return{text:S?Lv(S.file,S.mtime):""}}async function Bv(g){let S=e,w=n.listSessionFiles(S.cwd).find(P=>P.sessionId===g);if(!w){let P=c().find(M=>M.sessionId===g)?.rec;return P?((r!==P||S.sessionId!==P.id)&&(r=P,$(void 0,P.id),S.everAttached=!0,d()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===S.file?{ok:!0}:(A(w),u(),d(),{ok:!0})}return y(e.cwd),x(e.cwd),O(),{info:Me,poll:k,logInlineStatus:ri,listSessions:xt,searchSessions:$v,sessionPeek:Mv,attach:Bv,composerSend:N,composerStop:q,composerNew:we,composerFiles:H,composerUiRespond:L,composerRpc:W,composerPaste:Be,composerPasteRead:Qe,summarizeTurn:Qt,shutdownComposer:ie}}var UO,qO,jb,JO,WO,Pa=v(()=>{"use strict";Ht();wb();qs();Od();Ob();Ib();$b();UO=".typebulb",qO=`${UO}/locks`,jb=5e3,JO=6e4;WO=50});import{existsSync as Nd,mkdirSync as HO,readFileSync as Fb,writeFileSync as YO}from"fs";import{join as An,isAbsolute as VO}from"path";async function Ld(n,e){let t=VO(n)?n:An(G,n);return Nd(t)?(ud(t,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Md(n){let e=G,t=ld(n),r=An(e,"typebulbs");HO(r,{recursive:!0});let s=Eu(t),i=`${s}.bulb.md`;for(let l=2;Nd(An(r,i))&&Fb(An(r,i),"utf8")!==t;l++)i=`${s}-${l}.bulb.md`;let o=An(r,i);Nd(o)||YO(o,t);let a=An("typebulbs",i),c=await ws(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:c.pid,url:c.url}}async function Bd(){return X(G)}async function Dd(n){let e=(await X()).find(t=>t.pid===n);return e?{ok:!0,outcome:await Bt(e)}:(await zn(n),{ok:!0})}async function jd(){let n=await an(G);return ca(G).filter(e=>!e.serverOnly).map(e=>({...e,trusted:Sn(e.path),batches:ad(e.path),lastRunAt:n(e.path)}))}async function Fd(n){let e=n.toLowerCase(),t=[];for(let r of ca(G).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Fb(r.path,"utf8")}catch{continue}let i=[];for(let c of s.split(`
|
|
1913
|
+
`)){let l=c.replace(/\s+/g," ").trim();l&&i.push({text:l,lower:l.toLowerCase()})}let{hitCount:o,snippet:a}=Sa(i,e);o&&t.push({path:r.path,hitCount:o,snippet:a})}return t}async function Ud(n,e,t){let r=G;e!=null&&gr(n,e);let s=await ws(n,{cwd:r,open:!1,trust:e,batch:t??void 0});return{ok:!0,file:s.file,pid:s.pid,url:s.url,trust:!!s.trust}}async function qd(n){return{cap:await cd(n)}}async function Jd(n,e){return gr(n,e),{ok:!0}}async function Kd(n,e){return Ke(n,e)}async function Wd(){return Js&&Date.now()-Js.fetchedAt<=GO?Js.samples:(_d??=XO().finally(()=>{_d=null}),_d)}async function XO(){try{let n=await fetch(`${zO}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(qb)});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:uc(i.config)}));return Js={samples:s,fetchedAt:Date.now()},s}catch{return Js?.samples??[]}}async function Hd(n){return $d.test(n)?Kb(Ub,"samples",n,!0):{ok:!1,error:"bad slug"}}async function Vd(){let n=Yd();if(!n)return{bulbs:[]};let e=`${Oa()}
|
|
1914
|
+
${n}`;return Yt?.key===e&&Date.now()-Yt.fetchedAt<=QO?{user:Yt.user,bulbs:Yt.bulbs}:(Rd??=ZO(e,n).finally(()=>{Rd=null}),Rd)}async function Id(n,e,t){let r=await fetch(`${n}${e}`,{headers:t,signal:AbortSignal.timeout(qb)});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 ZO(n,e){let t={Authorization:`Bearer ${e}`};try{let r=Oa(),s;try{s=await Id(r,"/api/me",t)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await Id(r,"/api/me",t)}let o=(await Id(r,"/api/scripts/list",t)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:uc(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 zd(n,e,t=!1){return!$d.test(e)||!$d.test(n)?{ok:!1,error:"bad slug"}:Kb(Oa(),n,e,t)}async function Kb(n,e,t,r){let s=ua(e,t);try{let i=await pa({origin:n,userSlug:e,slug:t,dest:An(G,s)},{force:r,token:Yd(),timeoutMs:Jb});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 Gd(n,e=!1){let t=Yd();if(!t)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=fa(n,G,Oa()),s=await ma(r,{token:t,force:e,timeoutMs:Jb});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 zO,Ub,GO,qb,Jb,Js,_d,$d,QO,Yt,Rd,Oa,Yd,Ca=v(()=>{"use strict";wr();Ht();Od();ee();zO="https://api.typebulb.com",Ub="https://typebulb.com",GO=3600*1e3,qb=5e3,Jb=15e3,Js=null,_d=null;$d=/^[a-z0-9][a-z0-9-]*$/,QO=300*1e3,Yt=null,Rd=null,Oa=()=>ta("TYPEBULB_ORIGIN",G)||Ub,Yd=()=>ta("TYPEBULB_TOKEN",G)});import{readFileSync as Zd,writeFileSync as Hb,mkdirSync as eC,appendFileSync as Yb,rmSync as Wb}from"fs";import{join as Ia,dirname as tC}from"path";import{createServer as nC}from"http";function Vt(n){try{return JSON.parse(Zd(n,"utf8"))}catch{return null}}function Ra(n,e){eC(tC(n),{recursive:!0}),Hb(n,JSON.stringify(e,null,2)+`
|
|
1915
|
+
`)}function zb(n,e,t){let r=Ia(n,".gitignore"),s="";try{s=Zd(r,"utf8")}catch{}let i=new Set(s.split(/\r?\n/).map(c=>c.trim())),o=e.filter(c=>!i.has(c));if(!o.length)return;let a=s&&!s.endsWith(`
|
|
1899
1916
|
`)?`
|
|
1900
|
-
`:"";try{
|
|
1917
|
+
`:"";try{Yb(r,a+t+`
|
|
1901
1918
|
`+o.join(`
|
|
1902
1919
|
`)+`
|
|
1903
|
-
`)}catch(c){console.error("[switcher] .gitignore update failed",
|
|
1920
|
+
`)}catch(c){console.error("[switcher] .gitignore update failed",V(c))}}function aC(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?Hs="live":s>oC&&(Hs="uncached")}function Xb(n,e){let t={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":n.headers["anthropic-version"]||"2023-06-01"},r=n.headers["anthropic-beta"];return typeof r=="string"&&(t["anthropic-beta"]=r),t}function cC(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 Qb(n){let e;try{e=JSON.parse(n)}catch{return n}Ws=typeof e?.model=="string"?e.model:null,ot&&(e.model=ot),Pn&&(e.provider=Gb(Pn));let t=/haiku/i.test(Ws||"");return Ys!=null&&!t&&(e.reasoning={effort:Xd[Ys]}),delete e.thinking,e.output_config&&delete e.output_config.effort,cC(e),JSON.stringify(e)}function lC(){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 c=e++;return t.set(a.index,c),a.index=c,`event: ${a.type}
|
|
1904
1921
|
data: ${JSON.stringify(a)}
|
|
1905
1922
|
|
|
1906
1923
|
`}case"content_block_delta":case"content_block_stop":{let c=t.get(a.index);return c==null?null:(a.index=c,`event: ${a.type}
|
|
@@ -1908,11 +1925,11 @@ data: ${JSON.stringify(a)}
|
|
|
1908
1925
|
|
|
1909
1926
|
`)}default:return i}};return i=>{n+=i;let o="",a;for(;(a=n.indexOf(`
|
|
1910
1927
|
|
|
1911
|
-
`))!==-1;){let c=n.slice(0,a);if(n=n.slice(a+2),!c.trim())continue;let l=s(c);l!==null&&(o+=l)}return o}}function
|
|
1928
|
+
`))!==-1;){let c=n.slice(0,a);if(n=n.slice(a+2),!c.trim())continue;let l=s(c);l!==null&&(o+=l)}return o}}function uC(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 dC(n,e,t){if(!ot){Ks(e,400,"invalid_request_error",iC);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(ef,{method:"POST",headers:Xb(n,r),body:Qb(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"),c=i.body.getReader(),l=new TextDecoder,d=a?lC():null;try{for(;;){let{done:u,value:f}=await c.read();if(u)break;if(f)if(d){let p=l.decode(f,{stream:!0});aC(p);let m=d(p);m&&e.write(m)}else e.write(Buffer.from(f))}}catch{}finally{e.writableEnded||e.end()}}async function fC(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(`${ef}/count_tokens`,{method:"POST",headers:Xb(n,r),body:Qb(t)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function pC(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}uC(n).then(r=>{if(t.includes("count_tokens"))return fC(n,e,r);if(t.includes("/v1/messages"))return dC(n,e,r);Ks(e,404,"not_found_error",t)})}function hC(){return Er&&Tn?Promise.resolve(Tn):new Promise((n,e)=>{let t=nC(pC);t.on("error",e),t.listen(0,"127.0.0.1",()=>{Er=t,Tn=t.address().port,console.log(`[switcher] wire proxy listening on ${_a(Tn)}`),n(Tn)})})}function mC(){try{Er?.close()}catch{}Er=null,Tn=null}function gC(n,e){let t=Na(n),r=Vt(t),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===_a(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=$a(n);if(!Vt(i)){let a={};for(let c of Vb)a[c]=c in s.env?s.env[c]:null;Ra(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=_a(e),s.env.ANTHROPIC_AUTH_TOKEN=sC,Ra(t,s),zb(n,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function yC(n,e,t){let r=$a(n),s=Vt(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:t},Ra(r,s)}function Zb(n){let e=Na(n),t=$a(n),r=Vt(t),s=Vt(e);if(s?.env){let i=r?.snapshot||{};for(let o of Vb){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{Wb(e,{force:!0})}catch{}else Ra(e,s)}try{Wb(t,{force:!0})}catch{}}async function bC(){let n=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await yt()).filter(r=>r.provider==="openrouter"&&!tf(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:nd()??void 0;return{hasKey:n,models:e,error:t}}async function wC(){if(Er&&ot)return{active:!0,managed:!0,model:ot,port:Tn,provider:Pn,routedModel:Ws,caching:Hs,reasoning:Ys,externalBaseUrl:null};let n=Vt(Na(G))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:Ys,externalBaseUrl:n.ANTHROPIC_BASE_URL||null}}async function ew(n,e){let t=await hC();return ot=n,Pn=e,gC(G,t),t}async function vC({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(tf(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 ew(n,nf[n]??null),Ws=null,Hs="unknown",yC(G,n,Pn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${V(e)}`}}return{ok:!0}}async function SC({level:n}){return n!=null&&(!Number.isInteger(n)||n<0||n>=Xd.length)?{ok:!1,error:`reasoning level must be 0\u2013${Xd.length-1} or null`}:(Ys=n,{ok:!0,level:n})}async function kC(){return Zb(G),ot=null,Pn=null,Ws=null,Hs="unknown",{ok:!0}}async function xC({key:n}){let e=(n||"").trim();if(!e)return{ok:!1,error:"empty key"};let t=G,r=Ia(t,".env"),s="";try{s=Zd(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))Hb(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
|
|
1912
1929
|
`)?`
|
|
1913
|
-
`:"";
|
|
1914
|
-
`)}}catch(i){return{ok:!1,error:
|
|
1915
|
-
`)}catch(o){return{ok:!1,error:`could not write ${n}: ${
|
|
1930
|
+
`:"";Yb(r,i+`OPENROUTER_API_KEY=${e}
|
|
1931
|
+
`)}}catch(i){return{ok:!1,error:V(i)}}return process.env.OPENROUTER_API_KEY=e,zb(t,[".env"],"# secrets"),{ok:!0}}function EC(){if(!(!Er&&!ot)){try{Zb(G)}catch{}mC()}}function AC(n,e){return tw.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 TC(n){if(tw.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 PC(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=Qd(e?.cache_read_input_tokens)||Qd(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 OC({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(tf(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 c=new AbortController,l=setTimeout(()=>c.abort(),2e4);try{let d=JSON.stringify(a?{...i,provider:Gb(a)}:i),u=await fetch(ef,{method:"POST",signal:c.signal,headers:s,body:d}),f=await u.json().catch(()=>({}));return{r:u,j:f}}finally{clearTimeout(l)}};try{let{r:a,j:c}=await o();if(!a.ok){let x=c?.error?.message||c?.message||JSON.stringify(c).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-t,error:AC(a.status,x),restriction:TC(x)}}let l=typeof c?.provider=="string"?c.provider:void 0,d=c?.content?.find?.(x=>x.type==="text")?.text??c?.content?.[0]?.text??"ok",u=Qd(c?.usage?.cache_creation_input_tokens),{r:f,j:p}=await o(l),{works:m,read:h,note:y}=PC(f.ok,p?.usage,l);return m===!0&&l&&(nf[n]=l,ot===n&&(Pn=l)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-t,provider:l,sample:String(d).trim().slice(0,60),cache:{works:m,created:u,read:h,note:y}}}catch(a){let c=V(a);return{ok:!0,callable:!1,ms:Date.now()-t,error:/abort/i.test(c)?"timed out (20s)":c}}}var rC,ef,sC,iC,Vb,oC,Xd,Na,$a,_a,tf,Er,Tn,ot,Pn,Ws,Hs,Ys,nf,Qd,Gb,tw,nw=v(()=>{"use strict";wr();Ht();rC="https://openrouter.ai/api",ef=`${rC}/v1/messages`,sC="typebulb-proxy-managed",iC="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.",Vb=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],oC=5e3,Xd=["low","medium","high"],Na=n=>Ia(n,".claude","settings.local.json"),$a=n=>Ia(n,".claude",".cc-switcher.json"),_a=n=>`http://127.0.0.1:${n}`;tf=n=>/^anthropic\//i.test(n)||/claude/i.test(n),Er=null,Tn=null,ot=null,Pn=null,Ws=null,Hs="unknown",Ys=1,nf={},Qd=n=>typeof n=="number"?n:0,Gb=n=>({order:[n],allow_fallbacks:!1});tw=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=Vt($a(G)),t=e?.active?.model;if(!t)return;let s=(Vt(Na(G))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await ew(t,e.active.provider??nf[t]??null);console.log(`[switcher] re-adopted override after restart: ${t} via ${_a(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",V(e))}})()});var sw={};ai(sw,{attach:()=>MC,blockToMarkdown:()=>yo,breakout:()=>Md,capText:()=>Ee,cleanUserText:()=>Lt,clearSwitchModel:()=>kC,composerPasteRead:()=>BC,displayName:()=>CC,downloadSample:()=>Hd,firstLineDigest:()=>qe,git:()=>Ge,gitChangedFiles:()=>Td,gitDiff:()=>Pd,info:()=>_C,isHiddenTurn:()=>ps,launchBulb:()=>Ud,listBreakouts:()=>Bd,listBulbFiles:()=>jd,listMyBulbs:()=>Vd,listSamples:()=>Wd,listSessions:()=>NC,listSwitchModels:()=>bC,logInlineStatus:()=>IC,openFile:()=>Ld,poll:()=>RC,predictTrustOf:()=>qd,probeModel:()=>OC,pullRemoteBulb:()=>zd,pushLocalBulb:()=>Gd,readBulbLog:()=>Kd,repoRoot:()=>xn,saveOpenRouterKey:()=>xC,searchBulbs:()=>Fd,searchSessions:()=>$C,sessionPeek:()=>LC,setBulbTrust:()=>Jd,setReasoning:()=>SC,setSwitchModel:()=>vC,shutdownSwitcher:()=>EC,stopBreakout:()=>Dd,summarizeTurn:()=>DC,switchState:()=>wC,toolResultDigest:()=>ou});var rw,CC,_C,RC,IC,NC,$C,LC,MC,BC,DC,iw=v(()=>{"use strict";Pa();bo();Ca();qs();nw();bo();fs();rw=new Wn,CC=rw.displayName,{info:_C,poll:RC,logInlineStatus:IC,listSessions:NC,searchSessions:$C,sessionPeek:LC,attach:MC,composerPasteRead:BC,summarizeTurn:DC}=xr(rw)});var aw={};ai(aw,{attach:()=>HC,breakout:()=>Md,composerPasteRead:()=>YC,displayName:()=>jC,downloadSample:()=>Hd,git:()=>Ge,gitChangedFiles:()=>Td,gitDiff:()=>Pd,info:()=>FC,launchBulb:()=>Ud,listBreakouts:()=>Bd,listBulbFiles:()=>jd,listMyBulbs:()=>Vd,listSamples:()=>Wd,listSessions:()=>JC,logInlineStatus:()=>qC,openFile:()=>Ld,poll:()=>UC,predictTrustOf:()=>qd,pullRemoteBulb:()=>zd,pushLocalBulb:()=>Gd,readBulbLog:()=>Kd,repoRoot:()=>xn,searchBulbs:()=>Fd,searchSessions:()=>KC,sessionPeek:()=>WC,setBulbTrust:()=>Jd,stopBreakout:()=>Dd,summarizeTurn:()=>VC});var ow,jC,FC,UC,qC,JC,KC,WC,HC,YC,VC,cw=v(()=>{"use strict";Pa();cu();Ca();qs();ow=new Hn,jC=ow.displayName,{info:FC,poll:UC,logInlineStatus:qC,listSessions:JC,searchSessions:KC,sessionPeek:WC,attach:HC,composerPasteRead:YC,summarizeTurn:VC}=xr(ow)});import{readFileSync as zC,writeFileSync as GC,mkdirSync as XC}from"fs";import{homedir as QC}from"os";import*as La from"path";async function dw(){try{let n=await fetch(new URL("/api/tags",uw()).toString(),{signal:AbortSignal.timeout(ZC)});return n.ok?((await n.json()).models??[]).map(t=>t.name).filter(t=>!!t):[]}catch{return[]}}function fw(n){let e;try{e=zC(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&&!rf(r)}}}catch{}return{json:void 0,unreadable:!0}}function rf(n){let e=n?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function e_(n){let e=rf(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 pw(){let{json:n,unreadable:e}=fw(lw());return e?{installed:[],configured:null}:{installed:await dw(),configured:e_(n)}}async function hw(){let n=await dw();return n.length?t_(lw(),n,uw()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function t_(n,e,t){let{json:r,unreadable:s}=fw(n);if(s)return{ok:!1,error:`could not parse ${n} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...rf(r)??{},ollama:{baseUrl:`${t}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{XC(La.dirname(n),{recursive:!0}),GC(n,JSON.stringify(i,null,2)+`
|
|
1932
|
+
`)}catch(o){return{ok:!1,error:`could not write ${n}: ${V(o)}`}}return{ok:!0,count:e.length}}var ZC,lw,uw,mw=v(()=>{"use strict";Ht();wr();ZC=1500,lw=()=>La.join(QC(),".pi","agent","models.json"),uw=()=>dr(process.env.OLLAMA_HOST??"http://localhost:11434")});var yw={};ai(yw,{attach:()=>l_,breakout:()=>Md,composerFiles:()=>p_,composerNew:()=>f_,composerPaste:()=>g_,composerPasteRead:()=>y_,composerRpc:()=>m_,composerSend:()=>u_,composerStop:()=>d_,composerUiRespond:()=>h_,displayName:()=>n_,downloadSample:()=>Hd,git:()=>Ge,gitChangedFiles:()=>Td,gitDiff:()=>Pd,info:()=>r_,launchBulb:()=>Ud,listBreakouts:()=>Bd,listBulbFiles:()=>jd,listMyBulbs:()=>Vd,listSamples:()=>Wd,listSessions:()=>o_,logInlineStatus:()=>i_,ollamaOffer:()=>pw,ollamaSync:()=>hw,openFile:()=>Ld,poll:()=>s_,predictTrustOf:()=>qd,pullRemoteBulb:()=>zd,pushLocalBulb:()=>Gd,readBulbLog:()=>Kd,repoRoot:()=>xn,searchBulbs:()=>Fd,searchSessions:()=>a_,sessionPeek:()=>c_,setBulbTrust:()=>Jd,shutdownComposer:()=>w_,stopBreakout:()=>Dd,summarizeTurn:()=>b_});var gw,n_,r_,s_,i_,o_,a_,c_,l_,u_,d_,f_,p_,h_,m_,g_,y_,b_,w_,bw=v(()=>{"use strict";Pa();Ed();Ca();qs();mw();gw=new Sr,n_=gw.displayName,{info:r_,poll:s_,logInlineStatus:i_,listSessions:o_,searchSessions:a_,sessionPeek:c_,attach:l_,composerSend:u_,composerStop:d_,composerNew:f_,composerFiles:p_,composerUiRespond:h_,composerRpc:m_,composerPaste:g_,composerPasteRead:y_,summarizeTurn:b_,shutdownComposer:w_}=xr(gw)});import*as Nv from"fs/promises";import*as kt from"path";ci();ee();function tu(n){if(!De.includes(n))throw new Error(`Unknown block kind '${n}' (one of: ${De.join(", ")})`);return n}function fg(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=tu(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}bo();cu();Ed();var Ma={claude:{adapter:()=>new Wn,server:()=>Promise.resolve().then(()=>(iw(),sw))},codex:{adapter:()=>new Hn,server:()=>Promise.resolve().then(()=>(cw(),aw))},pi:{adapter:()=>new Sr,server:()=>Promise.resolve().then(()=>(bw(),yw))}};function ww(n){return n in Ma}function Ar(){return Object.keys(Ma)}function vw(){return Object.fromEntries(Object.entries(Ma).map(([n,e])=>[n,e.adapter]))}function Sw(n){return Ma[n].server()}var Vs=vw();function kw(){for(let n of Object.values(Vs))try{n().ensureHarnessSupport()}catch{}}function On(){for(let n of Object.keys(Vs))try{if(Vs[n]().detectsSelf())return n}catch{}}function xw(n){let e=Ar(),t=new Map(e.filter(i=>Vs[i]).map(i=>[i,Vs[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 of=5e3;function sf(n){try{return n()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function Ew(n){let t={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||On()!==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 c=n[++o];(!c||c.startsWith("-"))&&(console.error("Missing value for --mode (e.g. --mode staging)"),process.exit(1)),t.mode=c}else if(a==="--batch"){let c=n[++o];(!c||c.startsWith("-"))&&(console.error("Missing value for --batch (a batch name, e.g. --batch pilot)"),process.exit(1));let l=c.replace(/[\\/]+$/,"");(!l||/[\\/]/.test(l)||l==="."||l==="..")&&(console.error(`Invalid --batch value: ${c} (a single folder name \u2014 no path separators or dot segments)`),process.exit(1)),t.batch=l}else if(a==="--follow"||a==="-f")t.follow=!0;else if(a==="--clear")t.clear=!0;else if(a==="--run"){let c=n[++o];if(c==="latest")t.run="latest";else{let l=parseInt(c,10);(isNaN(l)||l<1)&&(console.error(`Invalid --run value: ${c} (a run number, or 'latest')`),process.exit(1)),t.run=l}}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 c=n[++o];c===void 0&&(console.error("Missing value for --match (a literal substring new log lines must contain)"),process.exit(1)),t.match=c}else if(a==="--timeout"){let c=parseInt(n[++o],10);(isNaN(c)||c<=0)&&(console.error(`Invalid --timeout value: ${n[o]} (seconds)`),process.exit(1)),t.timeoutSec=c}else if(a==="--wait"||a.startsWith("--wait="))if(a.startsWith("--wait=")){let c=parseInt(a.slice(7),10);(isNaN(c)||c<=0)&&(console.error(`Invalid --wait value: ${a.slice(7)} (milliseconds)`),process.exit(1)),t.sendWaitMs=c}else t.sendWaitMs=of;else if(a==="--lines"||a==="-n"){let c=parseInt(n[++o],10);(isNaN(c)||c<0)&&(console.error(`Invalid --lines value: ${n[o]}`),process.exit(1)),t.lines=c}else if(a==="--port"||a==="-p"){let c=n[++o],l=parseInt(c,10);isNaN(l)&&(console.error(`Invalid port: ${c}`),process.exit(1)),t.port=l}else if(a==="--replace"||a.startsWith("--replace=")){let c=a.startsWith("--replace=")?a.slice(10):n[++o]??"",l=sf(()=>Nf(c));t.local&&(console.error(`--replace can only be used once (got '${t.local.name}' and '${l.name}')`),process.exit(1)),t.local=l}else if(a==="--args"||a.startsWith("--args=")){t.hasArgsFlag=!0;let c=a.startsWith("--args=")?a.slice(7):n[++o];c===void 0&&(console.error("Missing value for --args (a JSON array, or - to read it from stdin)"),process.exit(1)),t.argsJson=c}else if(!a.startsWith("-")||a==="-"&&t.subcommand==="send")["call","send","get","put","slug"].includes(t.subcommand)?i.push(a):t.file=a;else{let c=t.subcommand==="call"?" (for a negative or dash-leading argument, use --args '<json-array>')":"";console.error(`Unknown option: ${a}${c}`),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=sf(()=>tu(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=sf(()=>fg(i.slice(1)))),t}function Aw(){console.log(`
|
|
1916
1933
|
typebulb - Local bulb runner for Typebulb
|
|
1917
1934
|
|
|
1918
1935
|
Usage:
|
|
@@ -2090,7 +2107,7 @@ Examples:
|
|
|
2090
2107
|
typebulb my-editor.bulb.md
|
|
2091
2108
|
typebulb --no-watch my-editor.bulb.md
|
|
2092
2109
|
typebulb .
|
|
2093
|
-
`)}
|
|
2110
|
+
`)}st();vs();ci();Ds();st();import*as Le from"path";import{spawn as H_,execSync as Y_}from"child_process";import{createRequire as V_}from"module";import{existsSync as z_}from"fs";import*as ge from"fs/promises";import*as he from"path";var af=[{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"}],cf=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function lf(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 v_=`
|
|
2094
2111
|
/**
|
|
2095
2112
|
* Get raw data chunk from the Data tab.
|
|
2096
2113
|
* @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
|
|
@@ -2101,7 +2118,7 @@ Examples:
|
|
|
2101
2118
|
* @param index - Chunk index (0-based)
|
|
2102
2119
|
* @throws If chunk is not valid JSON/JSON-ish
|
|
2103
2120
|
*/
|
|
2104
|
-
json<T = unknown>(index: number): T;`,
|
|
2121
|
+
json<T = unknown>(index: number): T;`,S_=`
|
|
2105
2122
|
/**
|
|
2106
2123
|
* Get the insight data produced by the inference layer.
|
|
2107
2124
|
*
|
|
@@ -2110,7 +2127,7 @@ Examples:
|
|
|
2110
2127
|
*
|
|
2111
2128
|
* @returns The parsed insight JSON, or undefined if no insight is available
|
|
2112
2129
|
*/
|
|
2113
|
-
insight<T = unknown>(): T | undefined;`,
|
|
2130
|
+
insight<T = unknown>(): T | undefined;`,Tw=`options: {
|
|
2114
2131
|
messages: Array<{ role: "user" | "assistant"; content: string }>;
|
|
2115
2132
|
system?: string;
|
|
2116
2133
|
/** 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. */
|
|
@@ -2121,7 +2138,7 @@ Examples:
|
|
|
2121
2138
|
webSearch?: boolean;
|
|
2122
2139
|
/** Abort the request. On abort the promise rejects / the stream ends. */
|
|
2123
2140
|
signal?: AbortSignal;
|
|
2124
|
-
}`,
|
|
2141
|
+
}`,Pw=`
|
|
2125
2142
|
/** Provider-reported token counts for one call \u2014 real usage from the API, never an estimate.
|
|
2126
2143
|
* \`output\` is total billed output (reasoning included); \`reasoning\` is the itemized subset where
|
|
2127
2144
|
* the provider splits it (OpenAI, Gemini, OpenRouter \u2014 Anthropic doesn't); \`cacheRead\` is the
|
|
@@ -2133,10 +2150,10 @@ type AiChunk =
|
|
|
2133
2150
|
| { kind: "text"; text: string }
|
|
2134
2151
|
| { kind: "reasoning"; text: string }
|
|
2135
2152
|
| { kind: "usage"; usage: AiUsage };
|
|
2136
|
-
`,
|
|
2153
|
+
`,Ow=`
|
|
2137
2154
|
/** What backs \`tb.ai\`: the user's own keys, the quota-limited courtesy model, or nothing. */
|
|
2138
2155
|
type AiAccess = "own" | "courtesy" | "none";
|
|
2139
|
-
`,
|
|
2156
|
+
`,Cw=`
|
|
2140
2157
|
/**
|
|
2141
2158
|
* General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
|
|
2142
2159
|
* returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
|
|
@@ -2146,7 +2163,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2146
2163
|
* @throws On rate limit, network error, or provider error
|
|
2147
2164
|
*/
|
|
2148
2165
|
ai: {
|
|
2149
|
-
(${
|
|
2166
|
+
(${Tw}): Promise<{ text: string; usage?: AiUsage }>;
|
|
2150
2167
|
/**
|
|
2151
2168
|
* Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
|
|
2152
2169
|
* as they arrive, then one final \`{ kind: "usage", usage }\` chunk with the call's token
|
|
@@ -2163,8 +2180,8 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2163
2180
|
* if (c.kind === "text") answer += c.text;
|
|
2164
2181
|
* }
|
|
2165
2182
|
*/
|
|
2166
|
-
stream(${
|
|
2167
|
-
};`,
|
|
2183
|
+
stream(${Tw}): AsyncIterable<AiChunk>;
|
|
2184
|
+
};`,_w=`
|
|
2168
2185
|
/**
|
|
2169
2186
|
* Returns AI models available to the current user.
|
|
2170
2187
|
* Models are filtered by the user's configured API keys.
|
|
@@ -2194,7 +2211,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2194
2211
|
* \`tb.mode\` or the length of \`tb.models()\` \u2014 which hosts offer a courtesy
|
|
2195
2212
|
* model is the host's business and changes without your bulb changing.
|
|
2196
2213
|
*/
|
|
2197
|
-
aiAccess(): Promise<AiAccess>;`,
|
|
2214
|
+
aiAccess(): Promise<AiAccess>;`,k_="\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;",Rw=`
|
|
2198
2215
|
/**
|
|
2199
2216
|
* The mode this bulb is running in.
|
|
2200
2217
|
*
|
|
@@ -2204,7 +2221,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2204
2221
|
* - \`'inline'\` \u2014 Running inline in an agent's transcript, rendered by the mirror
|
|
2205
2222
|
* (sandboxed, client-only: AI, filesystem, and server RPC are unavailable)
|
|
2206
2223
|
*/
|
|
2207
|
-
mode: ${
|
|
2224
|
+
mode: ${ag};`,Iw=`
|
|
2208
2225
|
/**
|
|
2209
2226
|
* Local filesystem access (CLI only).
|
|
2210
2227
|
*
|
|
@@ -2221,7 +2238,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2221
2238
|
readBytes(path: string): Promise<Uint8Array>;
|
|
2222
2239
|
/** Write text or raw bytes to a file. Creates parent directories if needed. */
|
|
2223
2240
|
write(path: string, content: string | Uint8Array): Promise<boolean>;
|
|
2224
|
-
};`,
|
|
2241
|
+
};`,Nw="\n /**\n * The bulb's folder \u2014 absolute path to `<bulb-dir>/<filename-stem>/`\n * (or its `batches/<name>/` folder when the run is scoped with `--batch`).\n *\n * For interop only (handing a path to `server.ts` or a spawned tool):\n * `tb.fs` already resolves relative paths against it, so bulb code writing\n * its own files never needs it. CLI only \u2014 throws in ide/published/inline mode.\n */\n readonly dir: string;",x_=`
|
|
2225
2242
|
/**
|
|
2226
2243
|
* Async value inspector for tensor-like objects.
|
|
2227
2244
|
*
|
|
@@ -2272,44 +2289,47 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2272
2289
|
*
|
|
2273
2290
|
* @returns The full canonical URL
|
|
2274
2291
|
*/
|
|
2275
|
-
url(): Promise<string>;`,
|
|
2292
|
+
url(): Promise<string>;`,E_="\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;",A_="\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;",T_="\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>>;",uf=`${Pw}${Ow}
|
|
2276
2293
|
/**
|
|
2277
2294
|
* Typebulb utilities namespace.
|
|
2278
2295
|
* Type \`tb.\` to discover available helpers.
|
|
2279
2296
|
*/
|
|
2280
|
-
declare const tb: {${
|
|
2297
|
+
declare const tb: {${v_}${x_}${S_}${A_}${T_}${E_}${Cw}${Iw}${Nw}${_w}${k_}${Rw}
|
|
2281
2298
|
};
|
|
2282
|
-
`,
|
|
2299
|
+
`,P_=`
|
|
2283
2300
|
/**
|
|
2284
2301
|
* Print to the CLI's stdout \u2014 the same channel as \`console.log\` here (the server's console IS
|
|
2285
2302
|
* the bulb's log). One log verb across blocks: page-side \`tb.log\` reaches this same stdout.
|
|
2286
2303
|
*/
|
|
2287
|
-
log(...args: any[]): void;`,
|
|
2304
|
+
log(...args: any[]): void;`,df=`${Pw}${Ow}
|
|
2288
2305
|
/**
|
|
2289
2306
|
* Typebulb utilities namespace (server-side).
|
|
2290
2307
|
* Type \`tb.\` to discover available helpers.
|
|
2291
2308
|
*/
|
|
2292
|
-
declare const tb: {${
|
|
2309
|
+
declare const tb: {${P_}${Cw}${Iw}${Nw}${_w}${Rw}
|
|
2293
2310
|
};
|
|
2294
|
-
`;
|
|
2311
|
+
`;ft();import R_ from"p-limit";ft();import{resolve as Lw}from"resolve.exports";var vt={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},zs=["index.d.ts","index.d.mts"],ff=/\.d\.(ts|mts|cts)$/i;function Ba(n){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(n)||/[?&]dts(?:[&#]|$)/i.test(n)}function $w(n){return[`${n}.d.ts`,`${n}.d.mts`]}function zt(n){if(!n||n==="./"||n==="/")return[...zs];let e=n.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),t=$w(e),r=e.endsWith("/")?e:`${e}/`;return t.push(...$w(`${r}index`)),t}async function Tr(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(O_(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function O_(n){return n===408||n===429||n>=500&&n<600}var Da=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)||Ba(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 Tr(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=pn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...zs],t);if(!ff.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,...zs]:[...zs,...s];return this.tryUntilSuccess(i,t)}toResolutionResult(e){return{kind:ff.test(e)?"types":"probe",path:e}}resolveExportsPath(e,t){let r=t||".",s=e;try{let i=this.extractPathFromResult(Lw(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(Lw(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(),c=u=>this.fetchCandidateFrom(s,t.name,u);if(t.subpath){let u=Cu(t.subpath),f=this.resolveExportsPath(r,u);if(f){let m=await this.resolveFromSelected(this.toResolutionResult(f),c,{subpath:!0});if(m)return{...m,resolvedPkg:a}}let p=await this.tryUntilSuccess(zt(u),c);if(p)return{...p,resolvedPkg:a}}let l=r.types??r.typings;if(l){let u=await this.resolveFromSelected({kind:"types",path:l},c);if(u)return{...u,resolvedPkg:o}}let d=this.resolveExportsPath(r,".");if(d){let u=await this.resolveFromSelected(this.toResolutionResult(d),c);if(u)return{...u,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,t,r){let s=pn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:t}:void 0}};ft();import{gunzipSync as C_}from"fflate";var ja=class{async fetchAndExtract(e,t){let r=this.getTarballUrl(e,t),s=await Tr(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=C_(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),c=a.indexOf(0),l=s.decode(a.slice(0,c>0?c:100)).trim(),d=o.slice(124,136),u=s.decode(d).trim().replace(/\0/g,""),f=parseInt(u,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(l.endsWith(".d.ts")||l.endsWith(".d.mts"))){let m=r.slice(i,i+f);t.set(this.normalizeTarPath(l),s.decode(m))}i+=Math.ceil(f/512)*512}}catch{}return t}};var Fa=class{constructor(e,t,r=new ja){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=hn.majorOf(r),o=e.filter(a=>hn.majorOf(a)===i);if(o.length)return o.sort((a,c)=>hn.cmp(c,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 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,c]of i.entries()){let l=this.cdnClient.file(e,a);try{await this.cache.setCachedFile(l,c)}catch{}}let o=t.subpath?this.subpathCandidates(t.subpath):["index.d.ts"];for(let a of o){let c=i.get(a);if(c)return{dts:c,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 Ua=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(`
|
|
2295
2312
|
`).filter(s=>{let i=s.trimStart();return!(i.startsWith("*")||i.startsWith("//")||i.startsWith("/*"))}).join(`
|
|
2296
|
-
`),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://"))}};
|
|
2297
|
-
`);await this.prefetchBareDeps(
|
|
2298
|
-
`,"utf8"),await
|
|
2299
|
-
`,"utf8"),{dir:e}}function
|
|
2300
|
-
`))console.log(`${e} ${r}`);return n.length>0}function
|
|
2313
|
+
`),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://"))}};ft();var Mw="file:///node_modules",qa=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${Mw}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,t){let r=pn(t);return`${Mw}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as __}from"lru-cache";function Bw(n){let e=new __({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 c=await Tr(s,{init:{cache:"no-store"}});if(!c?.ok){c?.status===404&&(e.set(s,!0),await n.recordNegative(s));return}let l=await c.text(),d=c.url||s;return await n.clearNegative(s),await n.setCachedFile(d,l),{dts:l,url:d}})();return t.set(s,a),await a.finally(()=>t.delete(s))}catch{return}}}var Gs=class{constructor(e){this.inFlight=new Map,this.scanner=new Ua,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=Bw(e.cache),this.typescriptProvider=new Da(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new Fa(e.cdnClient,e.cache),this.virtualFs=new qa}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 c=o.url??this.cdnClient.file(i?`${s}@${i}`:s,"index.d.ts");return{dts:o.content,url:c,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>vt.maxRelativeTypeRefs)))try{let a=new URL(t),c=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let l=this.scanner.collectRelativeTypeRefs(e).slice(0,vt.maxRelativeTypeRefs);for(let d of l)await this.tryRelativeRef(d,c,o,r,s,i)}catch{}}async tryRelativeRef(e,t,r,s,i,o){try{let a=new URL(e,t),c=a.pathname+a.search,l=Ba(c)?[c]:zt(c);for(let d of l){let f=new URL(d,a).toString();if(o.has(f))return;let p=await this.fetchDts(f);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,vt.maxBareDeps).filter(l=>this.isDifferentPackage(l,t));if(!o.length)return;let a=new Set([t]),c=R_(vt.prefetchConcurrency);await Promise.all(o.map(l=>c(()=>this.prefetchBareDepsRecursive(l,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 c=a.resolvedPkg||e,l=this.virtualFs.pathForMain(c);this.pushFileIfNew(t,l,a.dts),this.ambientlyDeclares(a.dts,e)?this.markFileAmbient(t,l):r.push({module:e,path:l}),a.url&&await this.expandRelativeRefs(a.dts,a.url,c,t);let d=this.scanner.collectBareModuleRefs(a.dts).slice(0,vt.maxBareDeps).filter(u=>!i.has(u));for(let u of d)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,c=new D(a||r),l=c.version?`${c.name}@${c.version}`:c.name,{mainPath:d,packageRootUrl:u}=this.computeEntryPath(o,l),f=[{path:d,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,l,f,void 0,u);let m=f.map(T=>T.content).join(`
|
|
2314
|
+
`);await this.prefetchBareDeps(m,l,f,p,s);let h=c.format(),y=e===h?[e]:[e,h],x=y.some(T=>this.ambientlyDeclares(i,T));return x?this.markFileAmbient(f,d):p.push(...y.map(T=>({module:T,path:d}))),{pkg:e,mainPath:d,files:f,shims:p,ambient:x}}};ju();ft();rr();Rs();Bu();nr();import*as Pr from"path";var I_=Pr.join(Bo,"pkg"),N_=Pr.join(Bo,"files"),$_=Pr.join(Bo,"negative.json"),Ka=class{pkgMem=new Map;fileMem=new Map;negativeCache=new mn(new sr($_));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await te();let t=await pt(Dw(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 Ja(async()=>{await te(),await Re(Dw(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await te();let t=await Mo(jw(e));return this.fileMem.set(e,t),t}async setCachedFile(e,t){this.fileMem.set(e,t),await Ja(async()=>{await te(),await Re(jw(e),t)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await Ja(async()=>{await te(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return Ja(()=>this.negativeCache.clearNegative(e))}};async function Ja(n){try{await n()}catch{}}function Dw(n){return Pr.join(I_,We(n)+".json")}function jw(n){return Pr.join(N_,We(n)+".txt")}rr();var pf;function L_(){return pf||(pf=new Gs({cache:new Ka,cdnClient:hy,packageService:Uo,versionResolver:py})),pf}var Fw="file:///node_modules/";async function Uw(n){let e=Do(n.emitKey,"typecheck");await te(),await ge.rm(e,{recursive:!0,force:!0}),await ge.mkdir(e,{recursive:!0});let t=j_(n.jsxImportSource,n.dependencies),r=await L_().resolve(n.code,n.dependencies,t),s=n.local?.name,i=s?r.filter(d=>d.pkg!==s):r,o=new Set;for(let d of i)for(let u of d.files){let f=Wa(u.path);if(!f||o.has(f))continue;o.add(f);let p=he.join(e,"node_modules",f);await ge.mkdir(he.dirname(p),{recursive:!0}),await ge.writeFile(p,u.content,"utf8")}let a={};for(let d of i)for(let u of d.shims){let f=Wa(u.path);f&&(a[u.module]=[`./node_modules/${f}`])}for(let d of i){if(d.ambient)continue;let u=Wa(d.mainPath);u&&(a[d.pkg]=[`./node_modules/${u}`])}let c=new Set;for(let d of i)for(let u of d.files){if(!u.ambient)continue;let f=Wa(u.path);f&&c.add(`node_modules/${f}`)}if(n.local){delete a[n.local.name];let d=await F_(n.local,e);d?a[n.local.name]=[`./node_modules/${n.local.name}/${d}`]:console.warn(` local: '${n.local.name}' ships no type defs; check cannot type against it.`)}let l=M_(n.jsxImportSource,a,[...c]);return await ge.writeFile(he.join(e,"tsconfig.json"),JSON.stringify(l,null,2)+`
|
|
2315
|
+
`,"utf8"),await ge.writeFile(he.join(e,"code.tsx"),n.code,"utf8"),await ge.writeFile(he.join(e,"tb.d.ts"),uf,"utf8"),{dir:e}}var hf={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function M_(n,e,t=[]){return{compilerOptions:{...hf,lib:B_([...af,...cf]),jsx:"react-jsx",jsxImportSource:n??"react",paths:e},include:["code.tsx","tb.d.ts",...t]}}function B_(n){return lf(n).map(e=>D_(e.name))}function D_(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 j_(n,e){let t=n??("react"in e?"react":void 0);return t?[`${t}/jsx-runtime`,`${t}/jsx-dev-runtime`]:[]}function Wa(n){if(!n.startsWith(Fw))return;let e=n.slice(Fw.length),t=e.indexOf("/");if(!(t<0))return e.slice(t+1)}async function F_(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 U_(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 U_(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 $e from"fs/promises";import*as St from"path";import{existsSync as q_}from"fs";rr();Uu();var J_="^22";async function qw(n){let e=Do(n.emitKey,"typecheck-server");await te(),await $e.rm(e,{recursive:!0,force:!0}),await $e.mkdir(e,{recursive:!0});let t=St.join(n.bulbDir,".typebulb"),r=Vo(n.server).filter(o=>o!==n.local?.name);await Yo([`@types/node@${J_}`,...r],t,n.dependencies,{ignoreScripts:!0});let s=St.join(t,"node_modules"),i=St.join(e,"node_modules");return await W_(s,i),await $e.writeFile(St.join(e,"server.ts"),n.server,"utf8"),await $e.writeFile(St.join(e,"tb.d.ts"),df,"utf8"),await $e.writeFile(St.join(e,"tsconfig.json"),JSON.stringify(K_(n.local),null,2)+`
|
|
2316
|
+
`,"utf8"),{dir:e}}function K_(n){let e={...hf,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 W_(n,e){if(!q_(n)){await $e.mkdir(e,{recursive:!0});return}await $e.rm(e,{recursive:!0,force:!0});let t=process.platform==="win32"?"junction":"dir";await $e.symlink(n,e,t)}Io();ee();async function Kw(n,e){let{bulb:t,config:r,warnings:s,starts:i}=await ze(n),o=Le.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 c=!1,l=!1;for(let h of s)console.log(`structure ${h}`);s.length&&(c=!0);let d=hr(Le.resolve(n)),u=d?Jn(t.name):"";d&&u&&u!==d.slug&&(console.log(`naming filename '${d.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.`),l=!0),t.code&&(c=Jw(Ss(t.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||c),t.server&&(c=Jw(Ss(t.server,{target:"server",lineOffset:a("server.ts")}),"server")||c);let f=Z_([process.cwd(),Le.dirname(n)]);if(!f){let h=Le.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 Uw({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 qw({server:t.server,bulbDir:Le.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:x,exitCode:T}=await X_(f,y);for(let O of x.split(/\r?\n/))O.trim()&&console.log(`${h} ${G_(O,o,a)}`);T!==0&&(c=!0)}c&&process.exit(1);let m=[t.code&&"code.tsx",t.server&&"server.ts"].filter(Boolean).join(", ");console.error(l?`\u2713 type-checks (${m}) \u2014 see the naming warning above`:`\u2713 no issues (${m})`)}function Jw(n,e){for(let t of n)for(let r of t.message.split(`
|
|
2317
|
+
`))console.log(`${e} ${r}`);return n.length>0}function G_(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 X_(n,e){return new Promise(t=>{let r=H_(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 Q_=V_(import.meta.url);function Z_(n){let e=r=>{try{let s=Q_.resolve("typescript/package.json",{paths:r}),i=Le.join(Le.dirname(s),"lib","tsc.js");return z_(i)?i:void 0}catch{return}},t=e(n);if(t)return t;try{let r=Y_("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}st();la();Ds();async function Ww(n,e){let{bulb:t}=await ze(n),r=mr(t);if(Sn(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.)")}Ds();import*as Xs from"path";async function Hw(n,e){if(!n){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=pd();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=Xs.resolve(n);t.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{gr(t,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${Xs.basename(t)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${Xs.basename(t)} \u2014 runs Restricted.`),console.log(` ${t}`)}Ce();import*as zw from"readline";hd();function mf(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 eR=5e3,Ha=()=>Math.round(performance.now()),Yw=n=>n>=1e3?`${(n/1e3).toFixed(1)}s`:`${n}ms`;async function Gw(n){let e=xw(process.cwd()),t=Ha();if("ambiguous"in e){let r=await tR(n,e.ambiguous);return r?Vw(n,r,{boot:t,from:Ha()}):nR(n,e.ambiguous)}return Vw(n,e.name,{boot:t,from:Ha()})}async function Vw(n,e,t){let r,s;try{r=await xu(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=Ha()-t.from,{lit:o,litLink:a,brand:c}=mf(process.stdout.isTTY===!0),l=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(js())}`],d=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>"')}`],...l," 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:",...l],u=t.boot+i>eR?[` slow launch: boot ${Yw(t.boot)} \xB7 mirror ${Yw(i)}`]:[],f=[` ${c(`typebulb v${n}`)}`,...u,...d,""];process.stdout.write(f.join(`
|
|
2301
2318
|
`)+`
|
|
2302
|
-
`)}async function
|
|
2319
|
+
`)}async function tR(n,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:t,brand:r}=mf(!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(`
|
|
2303
2320
|
`)+`
|
|
2304
|
-
`);let i=
|
|
2321
|
+
`);let i=zw.createInterface({input:process.stdin,output:process.stdout});try{let o=(await new Promise(c=>i.question(" Open which? [1]: ",c))).trim();if(o==="")return e[0];let a=Number(o);return Number.isInteger(a)&&a>=1&&a<=e.length?e[a-1]:e.find(c=>c===o.toLowerCase())}finally{i.close()}}function nR(n,e){let{lit:t,brand:r}=mf(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(`
|
|
2305
2322
|
`)+`
|
|
2306
|
-
`)}
|
|
2307
|
-
`+e)}function
|
|
2323
|
+
`)}gt();vn();async function Xw(n){Ie(n);let e=await yt();if(e.length>0){console.log(By(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!rd()){console.log("No AI provider keys found in this directory's .env, and no local Ollama server detected."),console.log("Set one of these to use a cloud model with tb.ai:");for(let[t,r]of Object.entries(ur))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 Qw(n){n?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=Jn(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 tv from"path";import{valid as ev,lt as sR}from"semver";Ce();var Xe={connected:"[page] connected",disconnected:"[page] disconnected",closed:n=>`[page] closed: ${n}`},gf=3e3,Zw=1e4,rR=2500,Ya=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?.()},gf).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,rR);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()}};Ao();function iR(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=>se(i.file)===se(e))}var Or=n=>n.agent??tv.basename(n.file);function nv(n){return n===_e?!1:n&&ev(n)&&ev(_e)?sR(n,_e):!0}function oR(n){return n===_e?"":n?nv(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 aR(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 rv(n,e,t){n.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${r.batch?` --batch ${r.batch}`:""}${t?aR(r,t[s]):""}${oR(r.version)} ${r.file}`))}async function yf(n,e){if(!n.length){console.log("No running bulb servers.");return}let t=await Promise.all(n.map(ku));console.log("Running bulb servers:"),rv(n,r=>console.log(r),t),console.log(`
|
|
2324
|
+
`+e)}function bf(n,e,t,r,s){let i=iR(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>\`):`),rv(n,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function sv(n,e){if(!n){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await yf(await X(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let t=bf(await X(),n,"logs",process.cwd(),On());if(e.clear){mu(t.pid),console.log(`Cleared log for ${Or(t)} (pid ${t.pid}).`);return}let r=Ke(t.pid),s=r.text;if(e.run!==void 0?(s=yu(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(`
|
|
2308
2325
|
`);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
|
|
2309
2326
|
`)}if(process.stdout.write(s),s&&!s.endsWith(`
|
|
2310
2327
|
`)&&process.stdout.write(`
|
|
2311
|
-
`),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let c=
|
|
2312
|
-
`);
|
|
2328
|
+
`),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let c=Ke(t.pid,i);i=c.offset,c.text&&process.stdout.write(c.text)},500),a=()=>{clearInterval(o),process.exit(0)};process.on("SIGINT",a),process.on("SIGTERM",a),await new Promise(()=>{})}}var cR=n=>new Promise(e=>setTimeout(e,n));async function iv(n,e){if(!n){yf(await X(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let t=bf(await X(),n,"wait",process.cwd(),On()),r=process.env.TYPEBULB_WAIT_SHIM==="1",s=process.env.TYPEBULB_WAIT_FOLLOW==="1",i=r||s,o=e.timeoutSec??1800,a=e.match??"",c=Ke(t.pid).offset,l=s?void 0:Po(t.pid,a)??(a?Po(t.pid):void 0),d=s?c:l!==void 0&&l<=c?l:a?0:c,u=Date.now()+o*1e3,f=me(t)?1e4:1e3,p=2e3,m=!me(t)&&!s,h,y="",x=0;for(;;){let T=d>=c,O=Ke(t.pid,d);if(d=O.offset,O.text){y+=O.text;let E=y.split(`
|
|
2329
|
+
`);y=E.pop()??"";let I=!1;for(let R of E)R.trim()&&(m&&T&&R.startsWith(Xe.disconnected)&&(I=!0),!(e.match&&!R.includes(e.match))&&(console.log(R),!s&&(h??=Date.now()+f,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 ${Or(t)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`),x=3;break}}if(h&&Date.now()>=h)break;if(!i&&!h&&Date.now()>=u){console.error(`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${Or(t)} within ${o}s`),x=2;break}if(!Vn(t.pid)){h||(console.error(`server ${Or(t)} (pid ${t.pid}) exited while waiting`),process.exit(3));break}await cR(400)}s||ys(t.pid,d,a),process.exit(x)}function ov(n,e){if(e==="killed")return` \u2014 forced (${nv(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 av(n){if(!n){await yf(await X(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=bf(await X(),n,"stop",process.cwd(),On()),t=await Bt(e);console.log(`Stopped ${Or(e)} (pid ${e.pid}, ${e.url}).${ov(e,t)}`)}async function cv(n){let e=process.cwd(),t=n==="agent"?On():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=>Bt(o)));console.log(`Stopped ${r.length} ${s}${r.length===1?"":"s"}:`),r.forEach((o,a)=>console.log(` ${o.url} pid ${o.pid} ${Or(o)}${ov(o,i[a])}`))}Ce();tt();cn();import*as Va from"path";import*as lv from"http";import{mkdir as lR,writeFile as uR}from"fs/promises";async function Cr(){let n=[];for await(let e of process.stdin)n.push(e);return Buffer.concat(n).toString("utf-8")}function Qs(n){return(n.charCodeAt(0)===65279?n.slice(1):n).replace(/\r\n/g,`
|
|
2330
|
+
`).trimEnd()}function dR(n,e){return new Promise((t,r)=>{let s=new URL(n),i=lv.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",c=>{a+=c}),o.on("end",()=>t({status:o.statusCode??0,text:a}))});i.setTimeout(0),i.on("error",r),i.end(e)})}var fR=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 uv(n,e,t=0){e==="-"&&(e=Qs(await Cr()));let r=e!==void 0&&e.startsWith("tb:");r&&t<=0&&(t=of);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=Va.resolve(n),o=un(await X(),i)[0];if(!o){let m=(await an(process.cwd()))(i);console.error(m?`No running server for '${n}' \u2014 it last ran ${fR(m)}. Relaunching reuses the same URL (a stale tab is one reload from live): npx typebulb ${n}`:`No running server for '${n}'. Start it first: npx typebulb ${n}`),process.exit(1)}let a=async m=>{let h=[m>0?`reply=${m}`:"",s?"solo=1":"","open=1"].filter(Boolean).join("&"),y=await dR(`${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{}}},c={},l=Date.now();try{c=await a(t)}catch(m){console.error(`send failed: ${m instanceof Error?m.message:String(m)}`),process.exit(1)}let d=c.clients??0,u=`${d} page${d===1?"":"s"}`;if(c.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)),d===0){let m=c.droppedMsAgo,h=c.opening==="none"?" and no agent mirror page is open to open one through":"",y=c.opening==="unreached"?` \u2014 the page was opened ${c.via?`in VS Code via ${c.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 "${Xe.connected}"`;console.error(`No page connected after ${((Date.now()-l)/1e3).toFixed(1)}s, so nothing was delivered${y}`),process.exit(1)}c.opening==="editor"?console.error(`Opened in VS Code via ${c.via}.`):c.opening==="external"&&console.error("Opened in your browser, where the agent mirror is."),console.error(`Sent to ${u}.`);let f=c.results??[],p=c.errors??[];for(let m of p)console.error(`handler error: ${m}`);if(p.length&&process.exit(1),f.length>1&&(console.error(`${f.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)),f.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let h={};try{h=JSON.parse(f[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=Sg(i);await lR(Va.dirname(y),{recursive:!0}),await uR(y,Buffer.from(h.png,"base64"));let x=[h.via?`inside "${h.via}"`:"",h.backdrop?`backdrop ${h.backdrop}`:""].filter(Boolean);console.error(`canvas ${h.width}\xD7${h.height} \u2192 PNG${x.length?` (${x.join("; ")})`:""}`),console.log(y);return}let m;try{m=JSON.parse(f[0])}catch{m=void 0}console.log(typeof m=="string"?m:f[0])}else c.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)`))}ha();vd();ee();import*as dv from"fs/promises";async function fv(n,e){let t=await dv.readFile(n,"utf-8"),r=Rn(t),s=ue[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(`
|
|
2331
|
+
`)?i:i+`
|
|
2332
|
+
`)}ee();import*as Zs from"fs/promises";async function mv(n,e){let t=await Zs.readFile(n,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await Cr():await Zs.readFile(o,"utf-8")}catch(c){hv(`Cannot read ${i}'s source: ${c instanceof Error?c.message:String(c)}`)}r.push({kind:i,content:Qs(a),label:o==="-"?"stdin":o})}let s;try{s=pR(t,r)}catch(i){hv(`${n}: ${i instanceof Error?i.message:String(i)}`)}for(let i of s.upToDate)console.log(`${ue[i].path}: already up to date`);if(s.written.length){await Zs.writeFile(n,s.text);for(let i of s.written)console.log(i.action==="removed"?`${ue[i.kind].path}: removed (${i.label} is empty)`:`${ue[i.kind].path}: ${i.action} from ${i.label} (${i.chars.toLocaleString()} chars)`)}}function pR(n,e){let t=Rn(n),r=n,s=[],i=[];for(let{kind:o,content:a,label:c}of e){let l=ue[o].path,d=t.files.get(l);if(!a){if(d===void 0){i.push(o);continue}r=pv(Yf(r,o),r,l),s.push({kind:o,action:"removed",chars:0,label:c});continue}if(d!==void 0&&Qs(d)===a){i.push(o);continue}r=pv(_r(r,o,a),r,l),s.push({kind:o,action:d===void 0?"created":"replaced",chars:a.length,label:c})}return{text:r,written:s,upToDate:i}}function pv(n,e,t){if(n===e)throw new Error(`the **${t}** block's fence is unterminated; refusing to rewrite inside it`);return n}function hv(n){console.error(n),process.exit(1)}gt();st();ee();la();import*as Xt from"fs/promises";import*as Cn from"path";import{EventEmitter as NR}from"events";wn();ee();import{Hono as wR}from"hono";import{serve as vR}from"@hono/node-server";import{streamSSE as SR}from"hono/streaming";import*as kf from"fs/promises";import kR from"open";rr();Rs();nr();import*as wf from"fs/promises";import*as ei from"path";var za=class{async get(e){let t=We(e),r=ei.join(_s,t+".bin"),s=ei.join(_s,t+".json");try{let[i,o]=await Promise.all([wf.readFile(r),wf.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=We(e),s=ei.join(_s,r+".bin"),i=ei.join(_s,r+".json"),o={url:e,contentType:t.contentType,cacheControl:t.cacheControl};await Promise.all([Re(s,t.body),Re(i,JSON.stringify(o))])}};var gv=`
|
|
2313
2333
|
const CSS = '\\n' +
|
|
2314
2334
|
/* The agent mirror's token set, verbatim (agents/core/client/styles.css) \u2014 one system across CLI
|
|
2315
2335
|
chrome: app chrome sits on --panel, content wells paint --veil, grays ride one neutral tint.
|
|
@@ -2630,27 +2650,22 @@ export function runInference(ctx) {
|
|
|
2630
2650
|
showConfirm();
|
|
2631
2651
|
document.body.appendChild(host);
|
|
2632
2652
|
}
|
|
2633
|
-
`;
|
|
2634
|
-
${f}`:"";return b.text(`Forbidden: this capability requires --trust.${
|
|
2635
|
-
`+
|
|
2636
|
-
|
|
2637
|
-
`)?
|
|
2638
|
-
`)
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
`):S.how==="editor"?console.log(` Opened in VS Code via ${S.via}.
|
|
2642
|
-
`):S.how==="external"?console.log(` Opened in your browser.
|
|
2643
|
-
`):S.how==="none"&&console.log(` ${d?"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."}
|
|
2653
|
+
`;ir();Ce();vn();sa();wn();import{stream as hR}from"hono/streaming";var mR="X-TB-Stream";function ti(n){return n instanceof Te?{message:n.message,code:n.code,retryable:n.retryable}:{message:n instanceof Error?n.message:"Unknown error",code:"unknown",retryable:!1}}function Ga(n,e){return n.header("Content-Type","application/x-ndjson; charset=utf-8"),n.header("Cache-Control","no-cache"),n.header(mR,"1"),hR(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:ti(s)}))}finally{try{await r.return?.()}catch{}}})}var Xa={log:(...n)=>console.log(...n)};function Qa(n,e){let t=n?.[e]??(Object.hasOwn(Xa,e)?Xa[e]:void 0);return typeof t=="function"?t:void 0}function Za(n){return n.constructor?.name==="AsyncGeneratorFunction"}sd();var gR=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,yR=/[?&]target=/,bR=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function yv(n,e=""){return gR.test(n)?!0:bR.test(n)&&yR.test(e)}var xR="127.0.0.1",ER=new Set(["localhost","127.0.0.1","::1"]),AR=0;function TR(n){if(n)try{return new URL(n.includes("://")?n:`http://${n}`).hostname}catch{return}}function vv(n){let e=TR(n);return!!e&&ER.has(e)}function PR(n){try{let e=new URL(n);return(e.protocol==="http:"||e.protocol==="https:")&&vv(e.host)}catch{return!1}}function OR(n){return!!n&&/\bCode\/\d/.test(n)&&/\bElectron\//.test(n)}function CR(n,e){if(!e)return!1;try{return new URL(n).host===e}catch{return!1}}function vf(n){return n instanceof Error?n.message:"Unknown error"}var bv=n=>n.how==="editor"||n.how==="unreached"?n.via:void 0,_R=2e3;async function Sv(n){let{getHtml:e,basePath:t,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:c,saveInferenceResult:l,localOverride:d,trusted:u=!1,trustHint:f,staticAssets:p,bulbAssets:m,sourceFile:h,bulbKey:y,onStop:x}=n,T=`${process.pid}-${++AR}-${Date.now()}`,O=r??t,E=new wR;E.use("*",async(b,k)=>{if(!vv(b.req.header("host")))return b.text("Forbidden: untrusted Host",403);await k()}),E.use("*",async(b,k)=>{await k(),b.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),b.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let 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(b,k)=>{if(!u){let _=new URL(b.req.url).pathname,N=I.find(([W])=>W.endsWith("/*")?_.startsWith(W.slice(0,-2)):_===W)?.[1]??"server-side code (server.ts)";wu(process.pid,N);let L=f?`
|
|
2654
|
+
${f}`:"";return b.text(`Forbidden: this capability requires --trust.${L}`,403)}await k()},$=async(b,k)=>{let _=b.req.header("sec-fetch-site");if(_){if(_!=="same-origin")return b.text(`Forbidden: ${_} request`,403)}else{let N=b.req.header("origin");if(N&&!CR(N,b.req.header("host")))return b.text("Forbidden: cross-origin request",403)}await k()};for(let[b]of I)E.use(b,R),E.use(b,$);E.use("/__log",$),E.post("/__log",async b=>{try{let{args:k}=await b.req.json();console.log(...k||[])}catch{}return b.json({ok:!0})});let A=new Ya,J=new Set,Q=new Set,Z=Date.now();A.onArrival(({page:b,firstAttach:k,count:_})=>{o&&_===1&&console.log(Xe.connected),k&&_>1&&b.close("yielded").catch(()=>{})}),o&&A.onSettledEmpty(()=>console.log(Xe.disconnected));let F,ye=0,de=async b=>{let k=Math.max(b.fresh?0:Z,A.lastDropAt);if(await A.whenArrives(gf-(Date.now()-k)))return{how:"attached"};if(Date.now()-ye<_R)return{how:"none"};let _=`http://localhost:${s}#tb-relay`,N=await Su(_,t),L;return N?.where==="editor"?L={how:"editor",via:N.via}:(b.external==="force"||b.external==="follow"&&N?.where==="external")&&(await kR(_),L={how:"external"}),L?await A.whenArrives(Zw)?L:{how:"unreached",via:bv(L)}:(ye=Date.now(),{how:"none"})},Me=b=>A.count>0?Promise.resolve({how:"attached"}):F??=de(b).finally(()=>{F=void 0});if(o){let b=0,k=new Map;E.use("/__send",$),E.post("/__send",async _=>{let N="";try{N=await _.req.text()}catch{}let L=Number(_.req.query("reply"))||0,W=A.count===0&&_.req.query("open")!==void 0?await Me({external:"follow",fresh:!1}):void 0,q=A.count,we=q===0&&A.lastDropAt?Date.now()-A.lastDropAt:void 0,H={clients:q,droppedMsAgo:we,...W?{opening:W.how,via:bv(W)}:{}};if(_.req.query("solo")!==void 0&&q!==1)return _.json({...H,refused:q>1});if(q===0)return _.json(H);let ie=Qt=>{for(let xt of A)xt.send(Qt).catch(()=>{})};if(L<=0)return ie({payload:N}),_.json(H);let Be=++b,Qe=await new Promise(Qt=>{let xt={expected:q,received:0,results:[],errors:[],finish:tc=>{clearTimeout(ii),k.delete(Be),Qt({results:xt.results,errors:xt.errors,timedOut:tc})}},ii=setTimeout(()=>xt.finish(!0),L);k.set(Be,xt),ie({id:Be,payload:N})});return _.json({...H,...Qe})}),E.use("/__send-reply",$),E.post("/__send-reply",async _=>{try{let{id:N,results:L,errors:W}=await _.req.json(),q=k.get(N);q&&(q.results.push(...L??[]),q.errors.push(...W??[]),++q.received>=q.expected&&q.finish(!1))}catch{}return _.json({ok:!0})})}E.get("/",b=>b.html(e())),E.post("/__fs/read",async b=>{try{let{path:k}=await b.req.json(),_=await Ls(k,O,t);return new Response(new Uint8Array(_),{headers:{"Content-Type":"application/octet-stream"}})}catch(k){let _=vf(k);return b.json({error:_},400)}}),E.post("/__fs/write",async b=>{try{let k=b.req.query("path");return k?(await oa(k,new Uint8Array(await b.req.arrayBuffer()),O,t),b.json({success:!0})):b.json({error:"Missing path"},400)}catch(k){let _=vf(k);return b.json({error:_},400)}}),E.post("/__api/:name",async b=>{try{let k=b.req.param("name"),_=Qa(a?.(),k);if(!_)return b.json({error:`API function '${k}' not found`},404);let{args:N}=await b.req.json();if(Za(_))return Ga(b,_(...N||[]));let L=await _(...N||[]);return b.json({result:L})}catch(k){let _=vf(k);return b.json({error:_},500)}}),E.post("/__ai",async b=>{try{let{messages:k,system:_,effort:N,provider:L,model:W,webSearch:q,stream:we}=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=bt(L,W);if(typeof H=="string")return b.json({message:H,code:"unknown",retryable:!1},400);let ie=await Jt(H,{messages:k,system:_,effort:N,webSearch:q,signal:b.req.raw.signal});if(!ie.ok){let Qt=await cr(ie,H.protocol);return b.json(Qt,ie.status)}if(we)return Ga(b,bn(ie,H.protocol));let{text:Be,usage:Qe}=await lr(ie,H.protocol);return Be||console.warn("[tb.ai] Empty response from provider"),b.json({text:Be,usage:Qe})}catch(k){return b.json(ti(k),500)}}),E.post("/__infer",async b=>{try{let{data:k}=await b.req.json().catch(()=>({})),_=c?.();if(!_?.infer.trim())return b.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let N=bt();if(typeof N=="string")return b.json({message:N,code:"unknown",retryable:!1},400);let L=Array.isArray(k)?k.map(String):[],W=Qu(_,L),q=await Jt(N,{messages:[{role:"user",content:W}],signal:b.req.raw.signal});if(!q.ok){let H=await cr(q,N.protocol);return b.json(H,q.status)}let we=(async function*(){let H="";for await(let Qe of bn(q,N.protocol))Qe.kind!=="text"||!Qe.text||(H+=Qe.text,yield{kind:"delta",text:Qe.text});let ie=Zu(H);if(ie.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
|
|
2655
|
+
`+H.slice(-4e3)),new Te("LLM output is not valid JSON","parse_error",!0);ie.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",ie.fixesApplied.join(", "));let Be={insight:ie.parsed,insightJson:ie.json,data:L};yield{kind:"complete",...Be,fixesApplied:ie.fixesApplied,hash:ed(Be)}})();return Ga(b,we)}catch(k){return b.json(ti(k),500)}});let be=async b=>{let{hash:k}=await b.req.json().catch(()=>({}));return typeof k=="string"?td(k):void 0};E.post("/__infer-save",async b=>{try{if(!l)return b.json({message:"Save is not available for this server.",code:"unknown",retryable:!1},400);let k=await be(b);return k?(await l(k.data,k.insightJson),b.json({ok:!0})):b.json({message:"No decodable #tb= fragment to save.",code:"unknown",retryable:!1},400)}catch(k){return b.json(ti(k),500)}}),E.get("/__infer-info",b=>{let k=c?.(),_=Rr(k?.config??"").inference,N=uo(k?.data??""),L=bt();return typeof L=="string"?b.json({error:L,inference:_,data:N}):b.json({provider:L.protocol,model:L.model,inference:_,data:N})}),E.use("/__infer-decode",$),E.post("/__infer-decode",async b=>b.json(await be(b)??{error:"invalid fragment"})),E.get("/__infer-ui.js",b=>b.body(gv,200,{"Content-Type":"text/javascript; charset=utf-8"})),E.get("/__models",async b=>{try{let k=await yt();return b.json(k)}catch{return b.json([],200)}}),E.get("/__ai-access",async b=>{try{return b.json(await ra())}catch{return b.json("none",200)}}),h&&E.get("/__source/*",async b=>{let k=await kf.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 ne=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],ri=new za;E.get("/proxy/*",async b=>{let k=new URL(b.req.url),N=(k.pathname+k.search).slice(7),L=N.lastIndexOf("https://");return L===-1?b.text("Invalid proxy URL",400):si(b,N.slice(L))}),d&&wv(E,`/local/${d.name}/`,d.serveDir),p&&wv(E,p.mount,p.dir),m&&E.get("/assets/*",async b=>{let{pathname:k}=new URL(b.req.url),_=k.slice(8),N;try{N=decodeURIComponent(_)}catch{return b.text("Not Found",404)}let L=Xf(N);if(L)return b.text(`${L} is not an asset type: a bulb's code and markup live in the bulb; assets are media and data`,403);try{for(let q of m.dirs){let we=await kv(N,q,{"Cache-Control":"no-cache"});if(we)return we}}catch{return b.text("Not Found",404)}let W=m.remoteBase;return W?b.redirect(W+_,302):b.text("Not Found",404)});async function si(b,k){let _;try{_=new URL(k)}catch{return b.text("Invalid URL",400)}if(_.protocol!=="https:")return b.text("HTTPS only",400);if(!ne.includes(_.hostname))return b.text("Host not allowed",403);let N=await ri.get(k);if(N)return new Response(N.body,{status:200,headers:Sf(N.contentType,N.cacheControl)});try{let L=await fetch(k,{headers:{Accept:b.req.header("Accept")||"*/*"},redirect:"follow"});if(!L.ok)return b.text(`Upstream ${L.status}`,L.status);let W=L.headers.get("Content-Type")||void 0,q=L.headers.get("Cache-Control")||void 0;if(L.body){let[we,H]=L.body.tee();return(async()=>{try{let ie=await new Response(H).arrayBuffer();await ri.set(k,{body:Buffer.from(ie),contentType:W,cacheControl:q})}catch{}})(),new Response(we,{status:L.status,headers:Sf(W,q)})}return new Response(null,{status:L.status,headers:Sf(W,q)})}catch(L){return b.text(`Proxy fetch failed: ${L instanceof Error?L.message:L}`,502)}}(i||o)&&(E.get("/__reload",b=>SR(b,async k=>{let _=b.req.query("bulb")||void 0;if(y&&_&&_!==y){J.has(_)||(J.add(_),console.log(Xe.closed("foreign"))),await k.writeSSE({event:"close",data:"foreign"});return}let N=()=>{k.writeSSE({event:"reload",data:""})};i?.on("reload",N);let L=()=>i?.removeListener("reload",N),W=b.req.query("relay")||void 0,q={inEditor:OR(b.req.header("user-agent")),doc:W,open:H=>k.writeSSE({event:"open-url",data:H}),send:H=>k.writeSSE({event:"message",data:JSON.stringify(H)}),close:H=>(L(),A.closing(q),console.log(Xe.closed(H)),k.writeSSE({event:"close",data:H}))},we=!!W&&!Q.has(W);for(W&&Q.add(W),A.add(q,we),k.onAbort(()=>{L(),A.dropped(q)}),await k.writeSSE({event:"hello",data:T,retry:Fu});!k.aborted;)await k.sleep(3e4)})),E.use("/__open",$),E.post("/__open",async b=>{let k="";try{k=String((await b.req.json()).url??"")}catch{}if(!PR(k))return b.json({error:"a local http URL is required"},400);let _=[...A].find(N=>N.inEditor);return await _?.open(k),b.json({opened:!!_,pages:A.count})})),E.use("/__stop",$),E.post("/__stop",async b=>{if(b.req.header("sec-fetch-site")||b.req.header("origin"))return b.text("Forbidden: browser request",403);let k="close";try{let N=await b.req.json();(N?.pages==="keep"||N?.pages==="close")&&(k=N.pages)}catch{}let _=k==="close"?await A.closeAll("stopped"):{told:0,gone:0};return x&&setTimeout(()=>{x({pages:k})},50),b.json({closed:_.gone,stuck:_.told-_.gone,exiting:!!x})}),E.get("/__pages",b=>b.json({pages:A.count})),E.notFound(async b=>{if(b.req.method!=="GET")return b.text("Not Found",404);let k=new URL(b.req.url);return yv(k.pathname,k.search)?si(b,"https://esm.sh"+k.pathname+k.search):b.text("Not Found",404)});let at=vR({fetch:E.fetch,port:s,hostname:xR});return at.listening||await new Promise((b,k)=>{let _=N=>k(N);at.once("error",_),at.once("listening",()=>{at.removeListener("error",_),b()})}),{port:s,close:()=>at.close(),requestPage:Me,closePages:b=>A.closeAll(b),pageCount:()=>A.count}}function Sf(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 wv(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 kv(decodeURIComponent(s.slice(e.length)),t)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function kv(n,e,t={}){let r=ia(n,e),s=await kf.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":Gf(r),...t}})}Ce();cn();async function ec(n){let{port:e,portNote:t,makeServerOptions:r,makeEntry:s,displayName:i,waitTarget:o,stopLog:a}=n,c=`http://localhost:${e}`,l=s(e,c),d=[],u,f=!1,p=async h=>{if(!f){f=!0,console.log(`
|
|
2656
|
+
Shutting down...`),(h?.pages??(me(l)?"keep":"close"))==="close"&&await u?.closePages("stopped"),u?.close();for(let y of d)try{await y()}catch{}a(),await ln(process.pid),process.exit(0)}},m=await Sv({...r(e),onStop:p}).catch(async h=>{if(h?.code!=="EADDRINUSE")throw h;return uu(e)});return u=m,await bu(l),console.log(`
|
|
2657
|
+
${i}`),console.log(` ${c}`),t&&console.log(` ${t}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:c,pageCount:()=>m.pageCount(),async handOver({mode:h,fresh:y,replacedLive:x}){if(h==="none")return;let T={fresh:y,external:x?"never":h==="window"?"force":"follow"},O=await m.requestPage(T);O.how==="attached"?console.log(` Reusing the open browser tab.
|
|
2658
|
+
`):O.how==="editor"?console.log(` Opened in VS Code via ${O.via}.
|
|
2659
|
+
`):O.how==="external"?console.log(` Opened in your browser.
|
|
2660
|
+
`):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(l)?"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."}
|
|
2644
2661
|
Share ${c}, and wake on the arrival:
|
|
2645
|
-
typebulb wait ${o} --match "
|
|
2646
|
-
`)},onCleanup(
|
|
2647
|
-
Port ${l} 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
|
|
2662
|
+
typebulb wait ${o} --match "${Xe.connected}"
|
|
2663
|
+
`)},onCleanup(h){d.push(h)}}}cn();import RR from"chokidar";var IR={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=RR.watch(e,IR);o.on("error",c=>console.warn(`watch: ${c instanceof Error?c.message:c} \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()}}Ce();tt();ir();async function xv(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 NR:void 0,a=Ie(e.mode),c=(await an(process.cwd()))(n),l=await Yn({kind:"bulb",file:n},process.cwd()),d=await Co(n,l);d.length&&console.log(`Replacing the running server for this bulb (pid ${d.map(de=>de.pid).join(", ")})`);let u=d.length>0||Date.now()-c<gy,{port:f,note:p}=await Eo({target:{kind:"bulb",file:n},cwd:process.cwd()});l!==void 0&&f!==l&&u&&(console.error(`
|
|
2664
|
+
Port ${l} 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(gu(++m));h(),e.batch&&await pr(n,e.batch),console.log(`Loading ${Cn.basename(n)}...`);let{html:y,bulb:x,serverExports:T}=await od(n,e.watch,e.trust,r,e.batch);qt(a,n,x.server);let O=[...e.batch?[Wt(n,e.batch)]:[],Wt(n)],E=hr(Cn.resolve(n)),I=e.trust?void 0:mr(x),{port:R,onCleanup:$,handOver:A,pageCount:J}=await ec({port:f,portNote:p,displayName:x.name,stopLog:i,makeServerOptions:de=>({getHtml:()=>y,basePath:s,fsBase:Kt(n,e.batch),port:de,reloadEmitter:o,sendChannel:!0,getServerExports:()=>T,getBulbBlocks:()=>({infer:x.infer,insight:x.insight,code:x.code,config:x.config,data:x.data}),saveInferenceResult:async(Me,be)=>{let ne=await Xt.readFile(n,"utf-8");ne=_r(ne,"data",Me.join(Gm)),ne=_r(ne,"insight",be),await Xt.writeFile(n,ne)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dirs:O,remoteBase:E&&fi(E.userSlug,E.slug)},sourceFile:n,bulbKey:gs(n),trusted:e.trust,trustHint:t}),makeEntry:(de,Me)=>({pid:process.pid,port:de,url:Me,file:n,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,batch:e.batch,mode:e.mode,predicted:I}),waitTarget:Cn.relative(process.cwd(),n)||Cn.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:
|
|
2648
2665
|
${t}
|
|
2649
2666
|
`:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
|
|
2650
2667
|
`),e.watch&&console.log(` Watching for changes...
|
|
2651
|
-
`);let
|
|
2652
|
-
`),o.emit("reload")}})}for(let U of A)await Ht.stat(U).then(Z=>Z.isDirectory()).catch(()=>!1)&&I(Wt({target:U,events:"all",onChange:()=>{console.log(`Assets changed. Browser reloading...
|
|
2653
|
-
`),o.emit("reload")}}))}T&&I(T),B&&I(B),I(()=>Ht.rm(sd(n),{force:!0})),await M({mode:e.open,fresh:!u,replacedLive:d.some(q=>q.port===N)})}ut();import{readFileSync as xf,copyFileSync as RR,existsSync as IR}from"fs";import*as pe from"path";import{fileURLToPath as NR}from"url";import{EventEmitter as $R}from"events";import LR from"open";nn();Ae();tr();var kf=n=>`/agents/${n}/client.js`,CR=`
|
|
2668
|
+
`);let Q,Z,F=()=>{J()===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,Me=Promise.resolve();if(Q=Gt({target:n,onChange:()=>{let be=++de;Me=Me.then(async()=>{if(be===de)try{console.log("Recompiling...");let ne=await od(n,!0,e.trust,r,e.batch);y=ne.html,T=ne.serverExports,x=ne.bulb,ne.buildError||h(),F()}catch(ne){console.error("Recompile failed:",ne)}})}}),r){let{name:be,serveDir:ne}=r;Z=Gt({target:ne,events:"all",onChange:()=>ye(`Local package '${be}' changed.`)})}for(let be of O)await Xt.stat(be).then(ne=>ne.isDirectory()).catch(()=>!1)&&$(Gt({target:be,events:"all",onChange:()=>ye("Assets changed.")}))}Q&&$(Q),Z&&$(Z),$(()=>Xt.rm(id(n),{force:!0})),await A({mode:e.open,fresh:!u,replacedLive:d.some(de=>de.port===R)})}gt();import{readFileSync as Ef,copyFileSync as LR,existsSync as MR}from"fs";import*as pe from"path";import{fileURLToPath as BR}from"url";import{EventEmitter as DR}from"events";import jR from"open";cn();Ce();ir();var xf=n=>`/agents/${n}/client.js`,$R=`
|
|
2654
2669
|
(() => {
|
|
2655
2670
|
const api = async (name, ...args) => {
|
|
2656
2671
|
const resp = await fetch('/__api/' + name, {
|
|
@@ -2682,7 +2697,7 @@ Port ${l} is this bulb's, and a page of it may be waiting there, but something e
|
|
|
2682
2697
|
${Ko()}
|
|
2683
2698
|
}
|
|
2684
2699
|
})();
|
|
2685
|
-
`;function
|
|
2700
|
+
`;function Ev(n){let{name:e,agent:t,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=n,c=xf(t);return`<!DOCTYPE html>
|
|
2686
2701
|
<html>
|
|
2687
2702
|
<head>
|
|
2688
2703
|
<meta charset="utf-8">
|
|
@@ -2690,7 +2705,7 @@ ${Ko()}
|
|
|
2690
2705
|
<title>${qo(e)} - typebulb</title>
|
|
2691
2706
|
${Jo(e,a)}
|
|
2692
2707
|
<style>
|
|
2693
|
-
${
|
|
2708
|
+
${ds}
|
|
2694
2709
|
</style>
|
|
2695
2710
|
<style>
|
|
2696
2711
|
${r}
|
|
@@ -2705,17 +2720,18 @@ ${i}
|
|
|
2705
2720
|
${o?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
|
|
2706
2721
|
|
|
2707
2722
|
<script>
|
|
2708
|
-
${
|
|
2723
|
+
${$R}
|
|
2709
2724
|
</script>
|
|
2710
2725
|
|
|
2711
2726
|
<script type="module" src="${c}"></script>
|
|
2712
2727
|
</body>
|
|
2713
|
-
</html>`}async function
|
|
2714
|
-
${r.url}`),n.open==="window"&&await
|
|
2715
|
-
`);let
|
|
2716
|
-
|
|
2717
|
-
`)
|
|
2718
|
-
`)}catch(
|
|
2719
|
-
`)
|
|
2720
|
-
`),
|
|
2721
|
-
|
|
2728
|
+
</html>`}async function Av(n){let e=process.cwd(),t=n.agentTarget;ww(t)||(console.error(`Unknown agent '${t}'. Known: ${Ar().join(", ")}.`),process.exit(1));let r=await Oo(e,t);if(r){console.log(`Mirror '${t}' is already running for this project:
|
|
2729
|
+
${r.url}`),n.open==="window"&&await jR(r.url);return}let s=bs(process.pid),i=n.watch?new DR:void 0,o=Ie(n.mode),a=await Sw(t),c=a.displayName||`${t} mirror`;qt(o,pe.join(e,"mirror"));let l=pe.dirname(BR(import.meta.url)),d=pe.join(l,"agents",t),u=pe.join(l,"..","cli","agents"),f=pe.join(d,"styles.css"),p=pe.join(d,"katex.min.css"),m=pe.join(d,"index.html"),h=()=>Ev({name:c,agent:t,styles:Ef(f,"utf8"),katex:Ef(p,"utf8"),mountHtml:Ef(m,"utf8"),watch:n.watch}),{port:y,note:x}=await Eo({explicit:n.port,target:{kind:"mirror",agent:t},cwd:e}),{port:T,url:O,onCleanup:E,handOver:I,pageCount:R}=await ec({port:y,portNote:x,displayName:c,stopLog:s,waitTarget:"agent",makeServerOptions:Z=>({getHtml:h,basePath:e,port:Z,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${pe.posix.dirname(xf(t))}/`,dir:d}}),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...
|
|
2730
|
+
`);let $=pe.join(u,t,"client"),A=pe.join(u,"core","client");async function J(){await(await import("esbuild")).build({entryPoints:[pe.join($,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:pe.join(d,"client.js")});for(let F of["styles.css","index.html","typebulb.png","typebulb-inv.png"])LR(pe.join(A,F),pe.join(d,F))}let Q;if(n.watch&&i){let Z=MR($),F=!1;Q=Gt({target:Z?u:d,events:"all",onChange:async()=>{if(!F){F=!0;try{Z&&await J(),console.log(R()?`Mirror rebuilt. Reloading.
|
|
2731
|
+
`:`Mirror rebuilt. No tab open on it \u2014 nobody is reading this.
|
|
2732
|
+
`),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}),E(()=>a.shutdownSwitcher?.()),E(()=>a.shutdownComposer?.()),Q&&E(Q)}gt();st();import*as Tv from"path";async function Pv(n,e,t,r,s){let i=Ie(t),o=!1;s&&await pr(n,s);let a=async()=>{let{bulb:c,config:l}=await ze(n);o||(qt(i,n,c.server),o=!0),await Ms(c.server,n,r,l.dependencies,s)};if(console.log(`Running ${Tv.basename(n)}...`),await a(),e){console.log(`Watching for changes...
|
|
2733
|
+
`);let c=0,l=Promise.resolve();Gt({target:n,onChange:()=>{let d=++c;l=l.then(async()=>{if(d===c)try{console.log("Re-running..."),await a()}catch(u){console.error("Error:",u)}})}})}}gt();st();import{Console as FR}from"node:console";Ce();async function _v(n,e,t,r,s){WR();try{let p=un(await X(),n)[0];p&&(ys(p.pid,Ke(p.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${p.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let i=Ie(t),{bulb:o,config:a}=await ze(n);o.server||ni("This bulb has no **server.ts** block; nothing to call."),qt(i,n,o.server),s&&await pr(n,s);let c;try{c=await Ms(o.server,n,r,a.dependencies,s)}catch(p){ni(p instanceof Error?p.message:String(p))}let l=Qa(c,e.fn);if(!l){let p=[...Object.keys(c).filter(m=>typeof c[m]=="function"),...Object.keys(Xa)];ni(`Function '${e.fn}' not found. Available: ${p.length?p.join(", "):"(none)"}.`)}let d=await UR(e);if(Za(l)){try{for await(let p of l(...d))await Cv(JSON.stringify(p,Rv)+`
|
|
2734
|
+
`)}catch(p){ni(p instanceof Error?p.stack??p.message:String(p))}return Ov(0)}let u;try{u=await l(...d)}catch(p){ni(p instanceof Error?p.stack??p.message:String(p))}let f=KR(u);f!==void 0&&await Cv(f+`
|
|
2735
|
+
`),Ov(0)}function Ov(n){process.exitCode=n,setTimeout(()=>process.exit(n),2e3).unref?.()}async function UR(n){if(n.hasArgsFlag){let e=n.argsJson??"";return e==="-"&&(e=await Cr()),JR(e)}return qR(n.positional)}function qR(n){return n.map(e=>{try{return JSON.parse(e)}catch{return e}})}function JR(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 KR(n){if(n!==void 0)return JSON.stringify(n,Rv,2)}function Rv(n,e){return typeof e=="bigint"?e.toString():e}function ni(n){process.stderr.write(n+`
|
|
2736
|
+
`),process.exit(1)}function WR(){let n=new FR(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 Cv(n){return new Promise((e,t)=>{process.stdout.write(n,r=>r?t(r):e())})}Ao();for(let n of[process.stdout,process.stderr])n.on("error",e=>{if(e?.code!=="EPIPE")throw e});function Iv(n,e){n||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
|
|
2737
|
+
${e}`),process.exit(1))}async function HR(){let n=Ew(process.argv.slice(2));if(n.version&&(console.log(`typebulb ${_e}`),process.exit(0)),n.help&&(Aw(),process.exit(0)),kw(),n.subcommand==="logs"){await sv(n.file||void 0,{follow:n.follow,clear:n.clear,run:n.run,lines:n.lines});return}if(n.subcommand==="wait"){await iv(n.file||void 0,{match:n.match,timeoutSec:n.timeoutSec});return}if(n.subcommand==="stop"){n.stopScope?await cv(n.stopScope):await av(n.file||void 0);return}if(n.subcommand==="send"){await uv(n.file,n.sendMessage,n.sendWaitMs??0);return}if(n.subcommand==="models"){await Xw(n.mode);return}if(n.subcommand==="slug"){Qw(n.slugName);return}if(n.subcommand==="pull"){await Qy(n.file||void 0,{force:n.force,mode:n.mode});return}if(n.subcommand==="push"){await eb(n.file||void 0,{force:n.force,mode:n.mode});return}if(n.subcommand==="agent"){await(n.agentTarget?Av(n):Gw(_e));return}if(n.subcommand==="trust"||n.subcommand==="untrust"){await Hw(n.file||void 0,n.subcommand==="trust");return}let e;if(!n.file||n.file==="."){let c=await Uy(process.cwd());c||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=c}else e=kt.resolve(n.file);if(await Nv.access(e).then(()=>!0,()=>!1)||(Ar().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 fv(e,n.blockKind);return}if(n.subcommand==="put"){await mv(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 Ww(e,s);return}let i=!n.noTrust&&Sn(e);i&&!n.trust&&console.error("trust: granted from memory (run `typebulb untrust` to revoke)"),n.trust=n.noTrust?!1:n.trust||i;let o;try{o=await ze(e)}catch{}let a;if(n.local){o&&!(n.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${n.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&n.subcommand!=="call"&&(!o.bulb.code||n.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await $f(n.local)}catch(c){console.error(c instanceof Error?c.message:String(c)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${kt.relative(process.cwd(),a.dir)||"."}`)}if(n.subcommand==="check"){await Kw(e,a);return}if(n.subcommand==="call"){Iv(n.trust,s),await _v(e,{fn:n.fn,positional:n.callArgs,argsJson:n.argsJson,hasArgsFlag:n.hasArgsFlag},n.mode,a,n.batch);return}if(o&&o.bulb.server&&(_o(o.bulb)||n.server)){Iv(n.trust,s),await Pv(e,n.watch,n.mode,a,n.batch);return}await xv(e,n,s,a)}HR().catch(n=>{console.error("Error:",n.message),process.exit(1)});
|