typebulb 0.17.1 → 0.17.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 +1 -1
- package/dist/agents/claude/client.js +174 -160
- package/dist/index.js +319 -302
- package/dist/lint/index.d.ts +11 -1
- package/dist/lint/index.d.ts.map +1 -1
- package/dist/lint/index.js +80 -1
- package/dist/lint/index.js.map +1 -1
- package/dist/render.js +83 -69
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
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 null;t++;let n=[];for(;t<e.length&&e[t]?.trim()!=="---";)n.push(e[t]),t++;if(e[t]?.trim()!=="---")return null;t++;let s=
|
|
5
|
-
`)),a=t}else t++}return{frontmatter:s,files:i,warnings:o,bodyEndLine:a}}catch{return null}}function
|
|
6
|
-
>/]`,i);if(n&&console.log("[xml-utils] start:",o),o===-1)return;let a=r.slice(o+e.length),c=jt(a,"^[^<]*[ /]>",0),l=c!==-1&&a[c-1]==="/";if(n&&console.log("[xml-utils] selfClosing:",l),l===!1)if(s){let p=0,m=1,h=0;for(;(c=jt(a,"[ /]"+e+">",p))!==-1;){let y=a.substring(p,c+1);if(m+=
|
|
7
|
-
>]`),h+=
|
|
8
|
-
`)}};Ut.defaultYaml={explicit:!1,version:"1.2"};Ut.defaultTags={"!!":"tag:yaml.org,2002:"};Jc.Directives=Ut});var
|
|
9
|
-
`)?
|
|
3
|
+
var Zp=Object.create;var ai=Object.defineProperty;var eh=Object.getOwnPropertyDescriptor;var th=Object.getOwnPropertyNames;var rh=Object.getPrototypeOf,nh=Object.prototype.hasOwnProperty;var zr=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var O=(r,e)=>()=>(r&&(e=r(r=0)),e);var x=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),sh=(r,e)=>{for(var t in e)ai(r,t,{get:e[t],enumerable:!0})},ih=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of th(e))!nh.call(r,s)&&s!==t&&ai(r,s,{get:()=>e[s],enumerable:!(n=eh(e,s))||n.enumerable});return r};var oh=(r,e,t)=>(t=r!=null?Zp(rh(r)):{},ih(e||!r||!r.__esModule?ai(t,"default",{value:r,enumerable:!0}):t,r));function bc(r){return!!r?.startsWith("typebulb")}var Qr,Xr,Zr=O(()=>{Qr={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"}},Xr=["code","css","html","data","infer","insight","config","notes"]});function fi(r){return r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1).replace(/\\"/g,'"'):r.startsWith("'")&&r.endsWith("'")?r.slice(1,-1):r}var en=O(()=>{});function Bt(r){try{let e=r.split(`
|
|
4
|
+
`),t=0;if(e[t]?.trim()!=="---")return null;t++;let n=[];for(;t<e.length&&e[t]?.trim()!=="---";)n.push(e[t]),t++;if(e[t]?.trim()!=="---")return null;t++;let s=yh(n);if(!s)return null;let i=new Map,o=[],a=t;for(;t<e.length;){let l=e[t]?.trim()?.match(wc);if(l){let f=l[1].trim();for(t++;t<e.length&&e[t]?.trim()==="";)t++;let u=e[t]?.match(vc);if(!u){t++;continue}let d=u[1];t++;let p=[];for(;t<e.length&&!e[t]?.match(new RegExp(`^${d}\\s*$`));)p.push(e[t]),t++;let m=t<e.length;t++,o.push(...mh(f,p,m)),i.set(f,p.join(`
|
|
5
|
+
`)),a=t}else t++}return{frontmatter:s,files:i,warnings:o,bodyEndLine:a}}catch{return null}}function mh(r,e,t){let n=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(wc);i&&hh.has(i[1].trim())&&gh(e,s)&&n.push(i[1].trim())}return n.length?n.map(s=>`**${r}** block has an unterminated code fence \u2014 it swallowed the **${s}** block.`):t?[]:[`**${r}** block has an unterminated code fence (it runs to the end of the file).`]}function gh(r,e){let t=e+1;for(;t<r.length&&r[t]?.trim()==="";)t++;return!!r[t]?.match(vc)}function yh(r){let e={};for(let t of r){let n=t.indexOf(":");if(n===-1)continue;let s=t.slice(0,n).trim(),i=t.slice(n+1).trim();switch(s){case"format":e.format=i;break;case"name":e.name=fi(i);break}}return!bc(e.format)||!e.name?null:e}function Sc(r){return Bt(r)?.warnings??[]}function kc(r){let e=Object.fromEntries(Xr.map(t=>[t,r.files.get(Qr[t].path)||""]));return{name:r.frontmatter.name,...e}}var wc,vc,hh,xc=O(()=>{Zr();en();wc=/^\*\*(.+)\*\*$/,vc=/^(`{3,})(\w*)\s*$/,hh=new Set(Xr.map(r=>Qr[r].path))});var Ec=O(()=>{Zr();en()});function Ac(r){if(!r.trim())return{};try{return JSON.parse(r)}catch{return{}}}var Tc=O(()=>{});var Oc=O(()=>{});function di(r,e,t){let s=new RegExp(e).exec(r.slice(t));return s?t+s.index:-1}var Pc=O(()=>{});function jt(r,e,t){let s=new RegExp(e).exec(r.slice(t));return s?t+s.index+s[0].length-1:-1}var Rc=O(()=>{});function tn(r,e){let t=new RegExp(e,"g"),n=r.match(t);return n?n.length:0}var Nc=O(()=>{});function qt(r,e,t){let n=t&&t.debug||!1,s=!(t&&typeof t.nested===!1),i=t&&t.startIndex||0;n&&console.log("[xml-utils] starting findTagByName with",e," and ",t);let o=di(r,`<${e}[
|
|
6
|
+
>/]`,i);if(n&&console.log("[xml-utils] start:",o),o===-1)return;let a=r.slice(o+e.length),c=jt(a,"^[^<]*[ /]>",0),l=c!==-1&&a[c-1]==="/";if(n&&console.log("[xml-utils] selfClosing:",l),l===!1)if(s){let p=0,m=1,h=0;for(;(c=jt(a,"[ /]"+e+">",p))!==-1;){let y=a.substring(p,c+1);if(m+=tn(y,"<"+e+`[
|
|
7
|
+
>]`),h+=tn(y,"</"+e+">"),h>=m)break;p=c}}else c=jt(a,"[ /]"+e+">",0);let f=o+e.length+c+1;if(n&&console.log("[xml-utils] end:",f),f===-1)return;let u=r.slice(o,f),d;return l?d=null:d=u.slice(u.indexOf(">")+1,u.lastIndexOf("<")),{inner:d,outer:u,start:o,end:f}}var pi=O(()=>{Pc();Rc();Nc()});var hi=O(()=>{pi()});var mi=O(()=>{hi()});var Cc=O(()=>{mi()});var _c=O(()=>{});var Ic=O(()=>{Oc();pi();hi();Cc();mi();_c()});var P=x(j=>{"use strict";var gi=Symbol.for("yaml.alias"),Lc=Symbol.for("yaml.document"),rn=Symbol.for("yaml.map"),$c=Symbol.for("yaml.pair"),yi=Symbol.for("yaml.scalar"),nn=Symbol.for("yaml.seq"),ge=Symbol.for("yaml.node.type"),Sh=r=>!!r&&typeof r=="object"&&r[ge]===gi,kh=r=>!!r&&typeof r=="object"&&r[ge]===Lc,xh=r=>!!r&&typeof r=="object"&&r[ge]===rn,Eh=r=>!!r&&typeof r=="object"&&r[ge]===$c,Mc=r=>!!r&&typeof r=="object"&&r[ge]===yi,Ah=r=>!!r&&typeof r=="object"&&r[ge]===nn;function Dc(r){if(r&&typeof r=="object")switch(r[ge]){case rn:case nn:return!0}return!1}function Th(r){if(r&&typeof r=="object")switch(r[ge]){case gi:case rn:case yi:case nn:return!0}return!1}var Oh=r=>(Mc(r)||Dc(r))&&!!r.anchor;j.ALIAS=gi;j.DOC=Lc;j.MAP=rn;j.NODE_TYPE=ge;j.PAIR=$c;j.SCALAR=yi;j.SEQ=nn;j.hasAnchor=Oh;j.isAlias=Sh;j.isCollection=Dc;j.isDocument=kh;j.isMap=xh;j.isNode=Th;j.isPair=Eh;j.isScalar=Mc;j.isSeq=Ah});var Ft=x(bi=>{"use strict";var D=P(),K=Symbol("break visit"),Bc=Symbol("skip children"),le=Symbol("remove node");function sn(r,e){let t=jc(e);D.isDocument(r)?ut(null,r.contents,t,Object.freeze([r]))===le&&(r.contents=null):ut(null,r,t,Object.freeze([]))}sn.BREAK=K;sn.SKIP=Bc;sn.REMOVE=le;function ut(r,e,t,n){let s=qc(r,e,t,n);if(D.isNode(s)||D.isPair(s))return Fc(r,n,s),ut(r,s,t,n);if(typeof s!="symbol"){if(D.isCollection(e)){n=Object.freeze(n.concat(e));for(let i=0;i<e.items.length;++i){let o=ut(i,e.items[i],t,n);if(typeof o=="number")i=o-1;else{if(o===K)return K;o===le&&(e.items.splice(i,1),i-=1)}}}else if(D.isPair(e)){n=Object.freeze(n.concat(e));let i=ut("key",e.key,t,n);if(i===K)return K;i===le&&(e.key=null);let o=ut("value",e.value,t,n);if(o===K)return K;o===le&&(e.value=null)}}return s}async function on(r,e){let t=jc(e);D.isDocument(r)?await ft(null,r.contents,t,Object.freeze([r]))===le&&(r.contents=null):await ft(null,r,t,Object.freeze([]))}on.BREAK=K;on.SKIP=Bc;on.REMOVE=le;async function ft(r,e,t,n){let s=await qc(r,e,t,n);if(D.isNode(s)||D.isPair(s))return Fc(r,n,s),ft(r,s,t,n);if(typeof s!="symbol"){if(D.isCollection(e)){n=Object.freeze(n.concat(e));for(let i=0;i<e.items.length;++i){let o=await ft(i,e.items[i],t,n);if(typeof o=="number")i=o-1;else{if(o===K)return K;o===le&&(e.items.splice(i,1),i-=1)}}}else if(D.isPair(e)){n=Object.freeze(n.concat(e));let i=await ft("key",e.key,t,n);if(i===K)return K;i===le&&(e.key=null);let o=await ft("value",e.value,t,n);if(o===K)return K;o===le&&(e.value=null)}}return s}function jc(r){return typeof r=="object"&&(r.Collection||r.Node||r.Value)?Object.assign({Alias:r.Node,Map:r.Node,Scalar:r.Node,Seq:r.Node},r.Value&&{Map:r.Value,Scalar:r.Value,Seq:r.Value},r.Collection&&{Map:r.Collection,Seq:r.Collection},r):r}function qc(r,e,t,n){if(typeof t=="function")return t(r,e,n);if(D.isMap(e))return t.Map?.(r,e,n);if(D.isSeq(e))return t.Seq?.(r,e,n);if(D.isPair(e))return t.Pair?.(r,e,n);if(D.isScalar(e))return t.Scalar?.(r,e,n);if(D.isAlias(e))return t.Alias?.(r,e,n)}function Fc(r,e,t){let n=e[e.length-1];if(D.isCollection(n))n.items[r]=t;else if(D.isPair(n))r==="key"?n.key=t:n.value=t;else if(D.isDocument(n))n.contents=t;else{let s=D.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}bi.visit=sn;bi.visitAsync=on});var wi=x(Jc=>{"use strict";var Uc=P(),Ph=Ft(),Rh={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Nh=r=>r.replace(/[!,[\]{}]/g,e=>Rh[e]),Ut=class r{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},r.defaultYaml,e),this.tags=Object.assign({},r.defaultTags,t)}clone(){let e=new r(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new r(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:r.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},r.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:r.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},r.defaultTags),this.atNextDocument=!1);let n=e.trim().split(/[ \t]+/),s=n.shift();switch(s){case"%TAG":{if(n.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[i,o]=n;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[i]=n;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[,n,s]=e.match(/^(.*!)([^!]*)$/s);s||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(s)}catch(o){return t(String(o)),null}return n==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+Nh(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),s;if(e&&n.length>0&&Uc.isNode(e.contents)){let i={};Ph.visit(e.contents,(o,a)=>{Uc.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of n)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(o)))&&t.push(`%TAG ${i} ${o}`);return t.join(`
|
|
8
|
+
`)}};Ut.defaultYaml={explicit:!1,version:"1.2"};Ut.defaultTags={"!!":"tag:yaml.org,2002:"};Jc.Directives=Ut});var an=x(Jt=>{"use strict";var Kc=P(),Ch=Ft();function _h(r){if(/[\x00-\x19\s,[\]{}]/.test(r)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(r)}`;throw new Error(t)}return!0}function Wc(r){let e=new Set;return Ch.visit(r,{Value(t,n){n.anchor&&e.add(n.anchor)}}),e}function Vc(r,e){for(let t=1;;++t){let n=`${r}${t}`;if(!e.has(n))return n}}function Ih(r,e){let t=[],n=new Map,s=null;return{onAnchor:i=>{t.push(i),s??(s=Wc(r));let o=Vc(e,s);return s.add(o),o},setAnchors:()=>{for(let i of t){let o=n.get(i);if(typeof o=="object"&&o.anchor&&(Kc.isScalar(o.node)||Kc.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:n}}Jt.anchorIsValid=_h;Jt.anchorNames=Wc;Jt.createNodeAnchors=Ih;Jt.findNewAnchor=Vc});var vi=x(Hc=>{"use strict";function Kt(r,e,t,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let s=0,i=n.length;s<i;++s){let o=n[s],a=Kt(r,n,String(s),o);a===void 0?delete n[s]:a!==o&&(n[s]=a)}else if(n instanceof Map)for(let s of Array.from(n.keys())){let i=n.get(s),o=Kt(r,n,s,i);o===void 0?n.delete(s):o!==i&&n.set(s,o)}else if(n instanceof Set)for(let s of Array.from(n)){let i=Kt(r,n,s,s);i===void 0?n.delete(s):i!==s&&(n.delete(s),n.add(i))}else for(let[s,i]of Object.entries(n)){let o=Kt(r,n,s,i);o===void 0?delete n[s]:o!==i&&(n[s]=o)}return r.call(e,t,n)}Hc.applyReviver=Kt});var Ee=x(Gc=>{"use strict";var Lh=P();function Yc(r,e,t){if(Array.isArray(r))return r.map((n,s)=>Yc(n,String(s),t));if(r&&typeof r.toJSON=="function"){if(!t||!Lh.hasAnchor(r))return r.toJSON(e,t);let n={aliasCount:0,count:1,res:void 0};t.anchors.set(r,n),t.onCreate=i=>{n.res=i,delete t.onCreate};let s=r.toJSON(e,t);return t.onCreate&&t.onCreate(s),s}return typeof r=="bigint"&&!t?.keep?Number(r):r}Gc.toJS=Yc});var cn=x(Qc=>{"use strict";var $h=vi(),zc=P(),Mh=Ee(),Si=class{constructor(e){Object.defineProperty(this,zc.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:n,onAnchor:s,reviver:i}={}){if(!zc.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 n=="number"?n:100},a=Mh.toJS(this,"",o);if(typeof s=="function")for(let{count:c,res:l}of o.anchors.values())s(l,c);return typeof i=="function"?$h.applyReviver(i,{"":a},"",a):a}};Qc.NodeBase=Si});var Wt=x(Xc=>{"use strict";var Dh=an(),Bh=Ft(),dt=P(),jh=cn(),qh=Ee(),ki=class extends jh.NodeBase{constructor(e){super(dt.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],Bh.visit(e,{Node:(i,o)=>{(dt.isAlias(o)||dt.hasAnchor(o))&&n.push(o)}}),t&&(t.aliasResolveCache=n));let s;for(let i of n){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,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=n.get(o);if(a||(qh.toJS(o,null,t),a=n.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=ln(s,o,n)),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,n){let s=`*${this.source}`;if(e){if(Dh.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 ln(r,e,t){if(dt.isAlias(e)){let n=e.resolve(r),s=t&&n&&t.get(n);return s?s.count*s.aliasCount:0}else if(dt.isCollection(e)){let n=0;for(let s of e.items){let i=ln(r,s,t);i>n&&(n=i)}return n}else if(dt.isPair(e)){let n=ln(r,e.key,t),s=ln(r,e.value,t);return Math.max(n,s)}return 1}Xc.Alias=ki});var I=x(xi=>{"use strict";var Fh=P(),Uh=cn(),Jh=Ee(),Kh=r=>!r||typeof r!="function"&&typeof r!="object",Ae=class extends Uh.NodeBase{constructor(e){super(Fh.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:Jh.toJS(this.value,e,t)}toString(){return String(this.value)}};Ae.BLOCK_FOLDED="BLOCK_FOLDED";Ae.BLOCK_LITERAL="BLOCK_LITERAL";Ae.PLAIN="PLAIN";Ae.QUOTE_DOUBLE="QUOTE_DOUBLE";Ae.QUOTE_SINGLE="QUOTE_SINGLE";xi.Scalar=Ae;xi.isScalarValue=Kh});var Vt=x(el=>{"use strict";var Wh=Wt(),Fe=P(),Zc=I(),Vh="tag:yaml.org,2002:";function Hh(r,e,t){if(e){let n=t.filter(i=>i.tag===e),s=n.find(i=>!i.format)??n[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return t.find(n=>n.identify?.(r)&&!n.format)}function Yh(r,e,t){if(Fe.isDocument(r)&&(r=r.contents),Fe.isNode(r))return r;if(Fe.isPair(r)){let u=t.schema[Fe.MAP].createNode?.(t.schema,null,t);return u.items.push(r),u}(r instanceof String||r instanceof Number||r instanceof Boolean||typeof BigInt<"u"&&r instanceof BigInt)&&(r=r.valueOf());let{aliasDuplicateObjects:n,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=t,c;if(n&&r&&typeof r=="object"){if(c=a.get(r),c)return c.anchor??(c.anchor=s(r)),new Wh.Alias(c.anchor);c={anchor:null,node:null},a.set(r,c)}e?.startsWith("!!")&&(e=Vh+e.slice(2));let l=Hh(r,e,o.tags);if(!l){if(r&&typeof r.toJSON=="function"&&(r=r.toJSON()),!r||typeof r!="object"){let u=new Zc.Scalar(r);return c&&(c.node=u),u}l=r instanceof Map?o[Fe.MAP]:Symbol.iterator in Object(r)?o[Fe.SEQ]:o[Fe.MAP]}i&&(i(l),delete t.onTagObj);let f=l?.createNode?l.createNode(t.schema,r,t):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(t.schema,r,t):new Zc.Scalar(r);return e?f.tag=e:l.default||(f.tag=l.tag),c&&(c.node=f),f}el.createNode=Yh});var fn=x(un=>{"use strict";var Gh=Vt(),ue=P(),zh=cn();function Ei(r,e,t){let n=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]=n,n=o}else n=new Map([[i,n]])}return Gh.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:r,sourceObjects:new Map})}var tl=r=>r==null||typeof r=="object"&&!!r[Symbol.iterator]().next().done,Ai=class extends zh.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(n=>ue.isNode(n)||ue.isPair(n)?n.clone(e):n),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(tl(e))this.add(t);else{let[n,...s]=e,i=this.get(n,!0);if(ue.isCollection(i))i.addIn(s,t);else if(i===void 0&&this.schema)this.set(n,Ei(this.schema,s,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let s=this.get(t,!0);if(ue.isCollection(s))return s.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...s]=e,i=this.get(n,!0);return s.length===0?!t&&ue.isScalar(i)?i.value:i:ue.isCollection(i)?i.getIn(s,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!ue.isPair(t))return!1;let n=t.value;return n==null||e&&ue.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let s=this.get(t,!0);return ue.isCollection(s)?s.hasIn(n):!1}setIn(e,t){let[n,...s]=e;if(s.length===0)this.set(n,t);else{let i=this.get(n,!0);if(ue.isCollection(i))i.setIn(s,t);else if(i===void 0&&this.schema)this.set(n,Ei(this.schema,s,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}};un.Collection=Ai;un.collectionFromPath=Ei;un.isEmptyPath=tl});var Ht=x(dn=>{"use strict";var Qh=r=>r.replace(/^(?!$)(?: $)?/gm,"#");function Ti(r,e){return/^\n+$/.test(r)?r.substring(1):e?r.replace(/^(?! *$)/gm,e):r}var Xh=(r,e,t)=>r.endsWith(`
|
|
9
|
+
`)?Ti(t,e):t.includes(`
|
|
10
10
|
`)?`
|
|
11
|
-
`+
|
|
12
|
-
`)t===
|
|
11
|
+
`+Ti(t,e):(r.endsWith(" ")?"":" ")+t;dn.indentComment=Ti;dn.lineComment=Xh;dn.stringifyComment=Qh});var nl=x(Yt=>{"use strict";var Zh="flow",Oi="block",pn="quoted";function em(r,e,t="flow",{indentAtStart:n,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return r;s<i&&(i=0);let c=Math.max(1+i,1+s-e.length);if(r.length<=c)return r;let l=[],f={},u=s-e.length;typeof n=="number"&&(n>s-Math.max(2,i)?l.push(0):u=s-n);let d,p,m=!1,h=-1,y=-1,v=-1;t===Oi&&(h=rl(r,h,e.length),h!==-1&&(u=h+c));for(let g;g=r[h+=1];){if(t===pn&&g==="\\"){switch(y=h,r[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}v=h}if(g===`
|
|
12
|
+
`)t===Oi&&(h=rl(r,h,e.length)),u=h+e.length+c,d=void 0;else{if(g===" "&&p&&p!==" "&&p!==`
|
|
13
13
|
`&&p!==" "){let b=r[h+1];b&&b!==" "&&b!==`
|
|
14
|
-
`&&b!==" "&&(d=h)}if(h>=u)if(d)l.push(d),u=d+c,d=void 0;else if(t===
|
|
15
|
-
${e}${r.slice(0,w)}`:(t===
|
|
14
|
+
`&&b!==" "&&(d=h)}if(h>=u)if(d)l.push(d),u=d+c,d=void 0;else if(t===pn){for(;p===" "||p===" ";)p=g,g=r[h+=1],m=!0;let b=h>v+1?h-2:y-1;if(f[b])return r;l.push(b),f[b]=!0,u=b+c,d=void 0}else m=!0}p=g}if(m&&a&&a(),l.length===0)return r;o&&o();let k=r.slice(0,l[0]);for(let g=0;g<l.length;++g){let b=l[g],w=l[g+1]||r.length;b===0?k=`
|
|
15
|
+
${e}${r.slice(0,w)}`:(t===pn&&f[b]&&(k+=`${r[b]}\\`),k+=`
|
|
16
16
|
${e}${r.slice(b+1,w)}`)}return k}function rl(r,e,t){let n=e,s=e+1,i=r[s];for(;i===" "||i===" ";)if(e<s+t)i=r[++e];else{do i=r[++e];while(i&&i!==`
|
|
17
|
-
`);n=e,s=e+1,i=r[s]}return n}Yt.FOLD_BLOCK=
|
|
18
|
-
`){if(i-o>n)return!0;if(o=i+1,s-o<=n)return!1}return!0}function Gt(r,e){let t=JSON.stringify(r);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:n}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(
|
|
17
|
+
`);n=e,s=e+1,i=r[s]}return n}Yt.FOLD_BLOCK=Oi;Yt.FOLD_FLOW=Zh;Yt.FOLD_QUOTED=pn;Yt.foldFlowLines=em});var zt=x(sl=>{"use strict";var re=I(),Te=nl(),mn=(r,e)=>({indentAtStart:e?r.indent.length:r.indentAtStart,lineWidth:r.options.lineWidth,minContentWidth:r.options.minContentWidth}),gn=r=>/^(%|---|\.\.\.)/m.test(r);function tm(r,e,t){if(!e||e<0)return!1;let n=e-t,s=r.length;if(s<=n)return!1;for(let i=0,o=0;i<s;++i)if(r[i]===`
|
|
18
|
+
`){if(i-o>n)return!0;if(o=i+1,s-o<=n)return!1}return!0}function Gt(r,e){let t=JSON.stringify(r);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:n}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(gn(r)?" ":""),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 f=t.substr(c+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=t.substr(c,6)}c+=5,a=c+1}break;case"n":if(n||t[c+2]==='"'||t.length<s)c+=1;else{for(o+=t.slice(a,c)+`
|
|
19
19
|
|
|
20
20
|
`;t[c+2]==="\\"&&t[c+3]==="n"&&t[c+4]!=='"';)o+=`
|
|
21
|
-
`,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,n?o:Te.foldFlowLines(o,i,Te.FOLD_QUOTED,
|
|
22
|
-
`)||/[ \t]\n|\n[ \t]/.test(r))return Gt(r,e);let t=e.indent||(
|
|
23
|
-
${t}`)+"'";return e.implicitKey?n:Te.foldFlowLines(n,t,Te.FOLD_FLOW,
|
|
21
|
+
`,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,n?o:Te.foldFlowLines(o,i,Te.FOLD_QUOTED,mn(e,!1))}function Pi(r,e){if(e.options.singleQuote===!1||e.implicitKey&&r.includes(`
|
|
22
|
+
`)||/[ \t]\n|\n[ \t]/.test(r))return Gt(r,e);let t=e.indent||(gn(r)?" ":""),n="'"+r.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
23
|
+
${t}`)+"'";return e.implicitKey?n:Te.foldFlowLines(n,t,Te.FOLD_FLOW,mn(e,!1))}function pt(r,e){let{singleQuote:t}=e.options,n;if(t===!1)n=Gt;else{let s=r.includes('"'),i=r.includes("'");s&&!i?n=Pi:i&&!s?n=Gt:n=t?Pi:Gt}return n(r,e)}var Ri;try{Ri=new RegExp(`(^|(?<!
|
|
24
24
|
))
|
|
25
25
|
+(?!
|
|
26
|
-
|$)`,"g")}catch{
|
|
26
|
+
|$)`,"g")}catch{Ri=/\n+(?!\n|$)/g}function hn({comment:r,type:e,value:t},n,s,i){let{blockQuote:o,commentString:a,lineWidth:c}=n.options;if(!o||/\n[\t ]+$/.test(t))return pt(t,n);let l=n.indent||(n.forceBlockIndent||gn(t)?" ":""),f=o==="literal"?!0:o==="folded"||e===re.Scalar.BLOCK_FOLDED?!1:e===re.Scalar.BLOCK_LITERAL?!0:!tm(t,c,l.length);if(!t)return f?`|
|
|
27
27
|
`:`>
|
|
28
28
|
`;let u,d;for(d=t.length;d>0;--d){let w=t[d-1];if(w!==`
|
|
29
29
|
`&&w!==" "&&w!==" ")break}let p=t.substring(d),m=p.indexOf(`
|
|
30
30
|
`);m===-1?u="-":t===p||m!==p.length-1?(u="+",i&&i()):u="",p&&(t=t.slice(0,-p.length),p[p.length-1]===`
|
|
31
|
-
`&&(p=p.slice(0,-1)),p=p.replace(
|
|
31
|
+
`&&(p=p.slice(0,-1)),p=p.replace(Ri,`$&${l}`));let h=!1,y,v=-1;for(y=0;y<t.length;++y){let w=t[y];if(w===" ")h=!0;else if(w===`
|
|
32
32
|
`)v=y;else break}let k=t.substring(0,v<y?v+1:y);k&&(t=t.substring(k.length),k=k.replace(/\n+/g,`$&${l}`));let b=(h?l?"2":"1":"")+u;if(r&&(b+=" "+a(r.replace(/ ?[\r\n]+/g," ")),s&&s()),!f){let w=t.replace(/\n+/g,`
|
|
33
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),S=!1,A=
|
|
33
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),S=!1,A=mn(n,!0);o!=="folded"&&e!==re.Scalar.BLOCK_FOLDED&&(A.onOverflow=()=>{S=!0});let E=Te.foldFlowLines(`${k}${w}${p}`,l,Te.FOLD_BLOCK,A);if(!S)return`>${b}
|
|
34
34
|
${l}${E}`}return t=t.replace(/\n+/g,`$&${l}`),`|${b}
|
|
35
|
-
${l}${k}${t}${p}`}function
|
|
35
|
+
${l}${k}${t}${p}`}function rm(r,e,t,n){let{type:s,value:i}=r,{actualString:o,implicitKey:a,indent:c,indentStep:l,inFlow:f}=e;if(a&&i.includes(`
|
|
36
36
|
`)||f&&/[[\]{},]/.test(i))return pt(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||f||!i.includes(`
|
|
37
|
-
`)?pt(i,e):
|
|
38
|
-
`))return
|
|
39
|
-
${c}`);if(o){let d=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:p,tags:m}=e.doc.schema;if(m.some(d)||p?.some(d))return pt(i,e)}return a?u:Te.foldFlowLines(u,c,Te.FOLD_FLOW,
|
|
40
|
-
${e.indent}${a}`:a}Ni.createStringifyContext=
|
|
37
|
+
`)?pt(i,e):hn(r,e,t,n);if(!a&&!f&&s!==re.Scalar.PLAIN&&i.includes(`
|
|
38
|
+
`))return hn(r,e,t,n);if(gn(i)){if(c==="")return e.forceBlockIndent=!0,hn(r,e,t,n);if(a&&c===l)return pt(i,e)}let u=i.replace(/\n+/g,`$&
|
|
39
|
+
${c}`);if(o){let d=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:p,tags:m}=e.doc.schema;if(m.some(d)||p?.some(d))return pt(i,e)}return a?u:Te.foldFlowLines(u,c,Te.FOLD_FLOW,mn(e,!1))}function nm(r,e,t,n){let{implicitKey:s,inFlow:i}=e,o=typeof r.value=="string"?r:Object.assign({},r,{value:String(r.value)}),{type:a}=r;a!==re.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=re.Scalar.QUOTE_DOUBLE);let c=f=>{switch(f){case re.Scalar.BLOCK_FOLDED:case re.Scalar.BLOCK_LITERAL:return s||i?pt(o.value,e):hn(o,e,t,n);case re.Scalar.QUOTE_DOUBLE:return Gt(o.value,e);case re.Scalar.QUOTE_SINGLE:return Pi(o.value,e);case re.Scalar.PLAIN:return rm(o,e,t,n);default:return null}},l=c(a);if(l===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=s&&f||u;if(l=c(d),l===null)throw new Error(`Unsupported default string type ${d}`)}return l}sl.stringifyString=nm});var Qt=x(Ni=>{"use strict";var sm=an(),Oe=P(),im=Ht(),om=zt();function am(r,e){let t=Object.assign({blockQuote:!0,commentString:im.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},r.schema.toStringOptions,e),n;switch(t.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:r,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:n,options:t}}function cm(r,e){if(e.tag){let s=r.filter(i=>i.tag===e.tag);if(s.length>0)return s.find(i=>i.format===e.format)??s[0]}let t,n;if(Oe.isScalar(e)){n=e.value;let s=r.filter(i=>i.identify?.(n));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 n=e,t=r.find(s=>s.nodeClass&&n instanceof s.nodeClass);if(!t){let s=n?.constructor?.name??(n===null?"null":typeof n);throw new Error(`Tag not resolved for ${s} value`)}return t}function lm(r,e,{anchors:t,doc:n}){if(!n.directives)return"";let s=[],i=(Oe.isScalar(r)||Oe.isCollection(r))&&r.anchor;i&&sm.anchorIsValid(i)&&(t.add(i),s.push(`&${i}`));let o=r.tag??(e.default?null:e.tag);return o&&s.push(n.directives.tagString(o)),s.join(" ")}function um(r,e,t,n){if(Oe.isPair(r))return r.toString(e,t,n);if(Oe.isAlias(r)){if(e.doc.directives)return r.toString(e);if(e.resolvedAliases?.has(r))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(r):e.resolvedAliases=new Set([r]),r=r.resolve(e.doc)}let s,i=Oe.isNode(r)?r:e.doc.createNode(r,{onTagObj:c=>s=c});s??(s=cm(e.doc.schema.tags,i));let o=lm(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,n):Oe.isScalar(i)?om.stringifyString(i,e,t,n):i.toString(e,t,n);return o?Oe.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
40
|
+
${e.indent}${a}`:a}Ni.createStringifyContext=am;Ni.stringify=um});var cl=x(al=>{"use strict";var ye=P(),il=I(),ol=Qt(),Xt=Ht();function fm({key:r,value:e},t,n,s){let{allNullValues:i,doc:o,indent:a,indentStep:c,options:{commentString:l,indentSeq:f,simpleKeys:u}}=t,d=ye.isNode(r)&&r.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(ye.isCollection(r)||!ye.isNode(r)&&typeof r=="object"){let A="With simple keys, collection cannot be used as a key value";throw new Error(A)}}let p=!u&&(!r||d&&e==null&&!t.inFlow||ye.isCollection(r)||(ye.isScalar(r)?r.type===il.Scalar.BLOCK_FOLDED||r.type===il.Scalar.BLOCK_LITERAL:typeof r=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!p&&(u||!i),indent:a+c});let m=!1,h=!1,y=ol.stringify(r,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&&n&&n(),y===""?"?":p?`? ${y}`:y}else if(i&&!u||e==null&&p)return y=`? ${y}`,d&&!m?y+=Xt.lineComment(y,t.indent,l(d)):h&&s&&s(),y;m&&(d=null),p?(d&&(y+=Xt.lineComment(y,t.indent,l(d))),y=`? ${y}
|
|
41
41
|
${a}:`):(y=`${y}:`,d&&(y+=Xt.lineComment(y,t.indent,l(d))));let v,k,g;ye.isNode(e)?(v=!!e.spaceBefore,k=e.commentBefore,g=e.comment):(v=!1,k=null,g=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!p&&!d&&ye.isScalar(e)&&(t.indentAtStart=y.length+1),h=!1,!f&&c.length>=2&&!t.inFlow&&!p&&ye.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let b=!1,w=ol.stringify(e,t,()=>b=!0,()=>h=!0),S=" ";if(d||v||k){if(S=v?`
|
|
42
42
|
`:"",k){let A=l(k);S+=`
|
|
43
43
|
${Xt.indentComment(A,t.indent)}`}w===""&&!t.inFlow?S===`
|
|
@@ -45,36 +45,36 @@ ${Xt.indentComment(A,t.indent)}`}w===""&&!t.inFlow?S===`
|
|
|
45
45
|
|
|
46
46
|
`):S+=`
|
|
47
47
|
${t.indent}`}else if(!p&&ye.isCollection(e)){let A=w[0],E=w.indexOf(`
|
|
48
|
-
`),
|
|
48
|
+
`),N=E!==-1,J=t.inFlow??e.flow??e.items.length===0;if(N||!J){let q=!1;if(N&&(A==="&"||A==="!")){let C=w.indexOf(" ");A==="&"&&C!==-1&&C<E&&w[C+1]==="!"&&(C=w.indexOf(" ",C+1)),(C===-1||E<C)&&(q=!0)}q||(S=`
|
|
49
49
|
${t.indent}`)}}else(w===""||w[0]===`
|
|
50
|
-
`)&&(S="");return y+=S+w,t.inFlow?b&&n&&n():g&&!b?y+=Xt.lineComment(y,t.indent,l(g)):h&&s&&s(),y}al.stringifyPair=
|
|
50
|
+
`)&&(S="");return y+=S+w,t.inFlow?b&&n&&n():g&&!b?y+=Xt.lineComment(y,t.indent,l(g)):h&&s&&s(),y}al.stringifyPair=fm});var _i=x(Ci=>{"use strict";var ll=zr("process");function dm(r,...e){r==="debug"&&console.log(...e)}function pm(r,e){(r==="debug"||r==="warn")&&(typeof ll.emitWarning=="function"?ll.emitWarning(e):console.warn(e))}Ci.debug=dm;Ci.warn=pm});var vn=x(wn=>{"use strict";var Zt=P(),ul=I(),yn="<<",bn={identify:r=>r===yn||typeof r=="symbol"&&r.description===yn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ul.Scalar(Symbol(yn)),{addToJSMap:fl}),stringify:()=>yn},hm=(r,e)=>(bn.identify(e)||Zt.isScalar(e)&&(!e.type||e.type===ul.Scalar.PLAIN)&&bn.identify(e.value))&&r?.doc.schema.tags.some(t=>t.tag===bn.tag&&t.default);function fl(r,e,t){if(t=r&&Zt.isAlias(t)?t.resolve(r.doc):t,Zt.isSeq(t))for(let n of t.items)Ii(r,e,n);else if(Array.isArray(t))for(let n of t)Ii(r,e,n);else Ii(r,e,t)}function Ii(r,e,t){let n=r&&Zt.isAlias(t)?t.resolve(r.doc):t;if(!Zt.isMap(n))throw new Error("Merge sources must be maps or map aliases");let s=n.toJSON(null,r,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}wn.addMergeToJSMap=fl;wn.isMergeKey=hm;wn.merge=bn});var $i=x(hl=>{"use strict";var mm=_i(),dl=vn(),gm=Qt(),pl=P(),Li=Ee();function ym(r,e,{key:t,value:n}){if(pl.isNode(t)&&t.addToJSMap)t.addToJSMap(r,e,n);else if(dl.isMergeKey(r,t))dl.addMergeToJSMap(r,e,n);else{let s=Li.toJS(t,"",r);if(e instanceof Map)e.set(s,Li.toJS(n,s,r));else if(e instanceof Set)e.add(s);else{let i=bm(t,s,r),o=Li.toJS(n,i,r);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function bm(r,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(pl.isNode(r)&&t?.doc){let n=gm.createStringifyContext(t.doc,{});n.anchors=new Set;for(let i of t.anchors.keys())n.anchors.add(i.anchor);n.inFlow=!0,n.inStringifyKey=!0;let s=r.toString(n);if(!t.mapKeyWarned){let i=JSON.stringify(s);i.length>40&&(i=i.substring(0,36)+'..."'),mm.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)}hl.addPairToJSMap=ym});var Pe=x(Mi=>{"use strict";var ml=Vt(),wm=cl(),vm=$i(),Sn=P();function Sm(r,e,t){let n=ml.createNode(r,void 0,t),s=ml.createNode(e,void 0,t);return new kn(n,s)}var kn=class r{constructor(e,t=null){Object.defineProperty(this,Sn.NODE_TYPE,{value:Sn.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;return Sn.isNode(t)&&(t=t.clone(e)),Sn.isNode(n)&&(n=n.clone(e)),new r(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return vm.addPairToJSMap(t,n,this)}toString(e,t,n){return e?.doc?wm.stringifyPair(this,e,t,n):JSON.stringify(this)}};Mi.Pair=kn;Mi.createPair=Sm});var Di=x(yl=>{"use strict";var Ue=P(),gl=Qt(),xn=Ht();function km(r,e,t){return(e.inFlow??r.flow?Em:xm)(r,e,t)}function xm({comment:r,items:e},t,{blockItemPrefix:n,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:c,options:{commentString:l}}=t,f=Object.assign({},t,{indent:i,type:null}),u=!1,d=[];for(let m=0;m<e.length;++m){let h=e[m],y=null;if(Ue.isNode(h))!u&&h.spaceBefore&&d.push(""),En(t,d,h.commentBefore,u),h.comment&&(y=h.comment);else if(Ue.isPair(h)){let k=Ue.isNode(h.key)?h.key:null;k&&(!u&&k.spaceBefore&&d.push(""),En(t,d,k.commentBefore,u))}u=!1;let v=gl.stringify(h,f,()=>y=null,()=>u=!0);y&&(v+=xn.lineComment(v,i,l(y))),u&&y&&(u=!1),d.push(n+v)}let p;if(d.length===0)p=s.start+s.end;else{p=d[0];for(let m=1;m<d.length;++m){let h=d[m];p+=h?`
|
|
51
51
|
${c}${h}`:`
|
|
52
52
|
`}}return r?(p+=`
|
|
53
|
-
`+
|
|
53
|
+
`+xn.indentComment(l(r),c),a&&a()):u&&o&&o(),p}function Em({items:r},e,{flowChars:t,itemIndent:n}){let{indent:s,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;n+=i;let c=Object.assign({},e,{indent:n,inFlow:!0,type:null}),l=!1,f=0,u=[];for(let m=0;m<r.length;++m){let h=r[m],y=null;if(Ue.isNode(h))h.spaceBefore&&u.push(""),En(e,u,h.commentBefore,!1),h.comment&&(y=h.comment);else if(Ue.isPair(h)){let k=Ue.isNode(h.key)?h.key:null;k&&(k.spaceBefore&&u.push(""),En(e,u,k.commentBefore,!1),k.comment&&(l=!0));let g=Ue.isNode(h.value)?h.value:null;g?(g.comment&&(y=g.comment),g.commentBefore&&(l=!0)):h.value==null&&k?.comment&&(y=k.comment)}y&&(l=!0);let v=gl.stringify(h,c,()=>y=null);m<r.length-1&&(v+=","),y&&(v+=xn.lineComment(v,n,a(y))),!l&&(u.length>f||v.includes(`
|
|
54
54
|
`))&&(l=!0),u.push(v),f=u.length}let{start:d,end:p}=t;if(u.length===0)return d+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=d;for(let h of u)m+=h?`
|
|
55
55
|
${i}${s}${h}`:`
|
|
56
56
|
`;return`${m}
|
|
57
|
-
${s}${p}`}else return`${d}${o}${u.join(" ")}${o}${p}`}function
|
|
58
|
-
`:" ")}return
|
|
57
|
+
${s}${p}`}else return`${d}${o}${u.join(" ")}${o}${p}`}function En({indent:r,options:{commentString:e}},t,n,s){if(n&&s&&(n=n.replace(/^\n+/,"")),n){let i=xn.indentComment(e(n),r);t.push(i.trimStart())}}yl.stringifyCollection=km});var Ne=x(ji=>{"use strict";var Am=Di(),Tm=$i(),Om=fn(),Re=P(),An=Pe(),Pm=I();function er(r,e){let t=Re.isScalar(e)?e.value:e;for(let n of r)if(Re.isPair(n)&&(n.key===e||n.key===t||Re.isScalar(n.key)&&n.key.value===t))return n}var Bi=class extends Om.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Re.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:s,replacer:i}=n,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(An.createPair(c,l,n))};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 n;Re.isPair(e)?n=e:!e||typeof e!="object"||!("key"in e)?n=new An.Pair(e,e?.value):n=new An.Pair(e.key,e.value);let s=er(this.items,n.key),i=this.schema?.sortMapEntries;if(s){if(!t)throw new Error(`Key ${n.key} already set`);Re.isScalar(s.value)&&Pm.isScalarValue(n.value)?s.value.value=n.value:s.value=n.value}else if(i){let o=this.items.findIndex(a=>i(n,a)<0);o===-1?this.items.push(n):this.items.splice(o,0,n)}else this.items.push(n)}delete(e){let t=er(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let s=er(this.items,e)?.value;return(!t&&Re.isScalar(s)?s.value:s)??void 0}has(e){return!!er(this.items,e)}set(e,t){this.add(new An.Pair(e,t),!0)}toJSON(e,t,n){let s=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(s);for(let i of this.items)Tm.addPairToJSMap(t,s,i);return s}toString(e,t,n){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Re.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})),Am.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}};ji.YAMLMap=Bi;ji.findPair=er});var ht=x(wl=>{"use strict";var Rm=P(),bl=Ne(),Nm={collection:"map",default:!0,nodeClass:bl.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(r,e){return Rm.isMap(r)||e("Expected a mapping for this tag"),r},createNode:(r,e,t)=>bl.YAMLMap.from(r,e,t)};wl.map=Nm});var Ce=x(vl=>{"use strict";var Cm=Vt(),_m=Di(),Im=fn(),On=P(),Lm=I(),$m=Ee(),qi=class extends Im.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(On.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Tn(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let n=Tn(e);if(typeof n!="number")return;let s=this.items[n];return!t&&On.isScalar(s)?s.value:s}has(e){let t=Tn(e);return typeof t=="number"&&t<this.items.length}set(e,t){let n=Tn(e);if(typeof n!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[n];On.isScalar(s)&&Lm.isScalarValue(t)?s.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let s=0;for(let i of this.items)n.push($m.toJS(i,String(s++),t));return n}toString(e,t,n){return e?_m.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:s}=n,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(Cm.createNode(a,void 0,n))}}return i}};function Tn(r){let e=On.isScalar(r)?r.value:r;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}vl.YAMLSeq=qi});var mt=x(kl=>{"use strict";var Mm=P(),Sl=Ce(),Dm={collection:"seq",default:!0,nodeClass:Sl.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(r,e){return Mm.isSeq(r)||e("Expected a sequence for this tag"),r},createNode:(r,e,t)=>Sl.YAMLSeq.from(r,e,t)};kl.seq=Dm});var tr=x(xl=>{"use strict";var Bm=zt(),jm={identify:r=>typeof r=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:r=>r,stringify(r,e,t,n){return e=Object.assign({actualString:!0},e),Bm.stringifyString(r,e,t,n)}};xl.string=jm});var Pn=x(Tl=>{"use strict";var El=I(),Al={identify:r=>r==null,createNode:()=>new El.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new El.Scalar(null),stringify:({source:r},e)=>typeof r=="string"&&Al.test.test(r)?r:e.options.nullStr};Tl.nullTag=Al});var Fi=x(Pl=>{"use strict";var qm=I(),Ol={identify:r=>typeof r=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:r=>new qm.Scalar(r[0]==="t"||r[0]==="T"),stringify({source:r,value:e},t){if(r&&Ol.test.test(r)){let n=r[0]==="t"||r[0]==="T";if(e===n)return r}return e?t.options.trueStr:t.options.falseStr}};Pl.boolTag=Ol});var gt=x(Rl=>{"use strict";function Fm({format:r,minFractionDigits:e,tag:t,value:n}){if(typeof n=="bigint")return String(n);let s=typeof n=="number"?n:Number(n);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let i=Object.is(n,-0)?"-0":JSON.stringify(n);if(!r&&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}Rl.stringifyNumber=Fm});var Ji=x(Rn=>{"use strict";var Um=I(),Ui=gt(),Jm={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:r=>r.slice(-3).toLowerCase()==="nan"?NaN:r[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ui.stringifyNumber},Km={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:r=>parseFloat(r),stringify(r){let e=Number(r.value);return isFinite(e)?e.toExponential():Ui.stringifyNumber(r)}},Wm={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(r){let e=new Um.Scalar(parseFloat(r)),t=r.indexOf(".");return t!==-1&&r[r.length-1]==="0"&&(e.minFractionDigits=r.length-t-1),e},stringify:Ui.stringifyNumber};Rn.float=Wm;Rn.floatExp=Km;Rn.floatNaN=Jm});var Wi=x(Cn=>{"use strict";var Nl=gt(),Nn=r=>typeof r=="bigint"||Number.isInteger(r),Ki=(r,e,t,{intAsBigInt:n})=>n?BigInt(r):parseInt(r.substring(e),t);function Cl(r,e,t){let{value:n}=r;return Nn(n)&&n>=0?t+n.toString(e):Nl.stringifyNumber(r)}var Vm={identify:r=>Nn(r)&&r>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(r,e,t)=>Ki(r,2,8,t),stringify:r=>Cl(r,8,"0o")},Hm={identify:Nn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(r,e,t)=>Ki(r,0,10,t),stringify:Nl.stringifyNumber},Ym={identify:r=>Nn(r)&&r>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(r,e,t)=>Ki(r,2,16,t),stringify:r=>Cl(r,16,"0x")};Cn.int=Hm;Cn.intHex=Ym;Cn.intOct=Vm});var Il=x(_l=>{"use strict";var Gm=ht(),zm=Pn(),Qm=mt(),Xm=tr(),Zm=Fi(),Vi=Ji(),Hi=Wi(),eg=[Gm.map,Qm.seq,Xm.string,zm.nullTag,Zm.boolTag,Hi.intOct,Hi.int,Hi.intHex,Vi.floatNaN,Vi.floatExp,Vi.float];_l.schema=eg});var Ml=x($l=>{"use strict";var tg=I(),rg=ht(),ng=mt();function Ll(r){return typeof r=="bigint"||Number.isInteger(r)}var _n=({value:r})=>JSON.stringify(r),sg=[{identify:r=>typeof r=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:r=>r,stringify:_n},{identify:r=>r==null,createNode:()=>new tg.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:_n},{identify:r=>typeof r=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:r=>r==="true",stringify:_n},{identify:Ll,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(r,e,{intAsBigInt:t})=>t?BigInt(r):parseInt(r,10),stringify:({value:r})=>Ll(r)?r.toString():JSON.stringify(r)},{identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:r=>parseFloat(r),stringify:_n}],ig={default:!0,tag:"",test:/^/,resolve(r,e){return e(`Unresolved plain scalar ${JSON.stringify(r)}`),r}},og=[rg.map,ng.seq].concat(sg,ig);$l.schema=og});var Gi=x(Dl=>{"use strict";var rr=zr("buffer"),Yi=I(),ag=zt(),cg={identify:r=>r instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(r,e){if(typeof rr.Buffer=="function")return rr.Buffer.from(r,"base64");if(typeof atob=="function"){let t=atob(r.replace(/[\n\r]/g,"")),n=new Uint8Array(t.length);for(let s=0;s<t.length;++s)n[s]=t.charCodeAt(s);return n}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),r},stringify({comment:r,type:e,value:t},n,s,i){if(!t)return"";let o=t,a;if(typeof rr.Buffer=="function")a=o instanceof rr.Buffer?o.toString("base64"):rr.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=Yi.Scalar.BLOCK_LITERAL),e!==Yi.Scalar.QUOTE_DOUBLE){let c=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),l=Math.ceil(a.length/c),f=new Array(l);for(let u=0,d=0;u<l;++u,d+=c)f[u]=a.substr(d,c);a=f.join(e===Yi.Scalar.BLOCK_LITERAL?`
|
|
58
|
+
`:" ")}return ag.stringifyString({comment:r,type:e,value:a},n,s,i)}};Dl.binary=cg});var $n=x(Ln=>{"use strict";var In=P(),zi=Pe(),lg=I(),ug=Ce();function Bl(r,e){if(In.isSeq(r))for(let t=0;t<r.items.length;++t){let n=r.items[t];if(!In.isPair(n)){if(In.isMap(n)){n.items.length>1&&e("Each pair must have its own sequence indicator");let s=n.items[0]||new zi.Pair(new lg.Scalar(null));if(n.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${n.commentBefore}
|
|
59
59
|
${s.key.commentBefore}`:n.commentBefore),n.comment){let i=s.value??s.key;i.comment=i.comment?`${n.comment}
|
|
60
|
-
${i.comment}`:n.comment}n=s}r.items[t]=_n.isPair(n)?n:new Gi.Pair(n)}}else e("Expected a sequence for this tag");return r}function jl(r,e,t){let{replacer:n}=t,s=new lg.YAMLSeq(r);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof n=="function"&&(o=n.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(Gi.createPair(a,c,t))}return s}var ug={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Bl,createNode:jl};In.createPairs=jl;In.pairs=ug;In.resolvePairs=Bl});var Xi=x(Qi=>{"use strict";var ql=P(),zi=Ee(),nr=Ce(),fg=Re(),Fl=Ln(),Je=class r extends fg.YAMLSeq{constructor(){super(),this.add=nr.YAMLMap.prototype.add.bind(this),this.delete=nr.YAMLMap.prototype.delete.bind(this),this.get=nr.YAMLMap.prototype.get.bind(this),this.has=nr.YAMLMap.prototype.has.bind(this),this.set=nr.YAMLMap.prototype.set.bind(this),this.tag=r.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let s of this.items){let i,o;if(ql.isPair(s)?(i=zi.toJS(s.key,"",t),o=zi.toJS(s.value,i,t)):i=zi.toJS(s,"",t),n.has(i))throw new Error("Ordered maps must not include duplicate keys");n.set(i,o)}return n}static from(e,t,n){let s=Fl.createPairs(e,t,n),i=new this;return i.items=s.items,i}};Je.tag="tag:yaml.org,2002:omap";var dg={collection:"seq",identify:r=>r instanceof Map,nodeClass:Je,default:!1,tag:"tag:yaml.org,2002:omap",resolve(r,e){let t=Fl.resolvePairs(r,e),n=[];for(let{key:s}of t.items)ql.isScalar(s)&&(n.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):n.push(s.value));return Object.assign(new Je,t)},createNode:(r,e,t)=>Je.from(r,e,t)};Qi.YAMLOMap=Je;Qi.omap=dg});var Vl=x(Zi=>{"use strict";var Ul=I();function Jl({value:r,source:e},t){return e&&(r?Kl:Wl).test.test(e)?e:r?t.options.trueStr:t.options.falseStr}var Kl={identify:r=>r===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ul.Scalar(!0),stringify:Jl},Wl={identify:r=>r===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ul.Scalar(!1),stringify:Jl};Zi.falseTag=Wl;Zi.trueTag=Kl});var Hl=x($n=>{"use strict";var pg=I(),eo=gt(),hg={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:r=>r.slice(-3).toLowerCase()==="nan"?NaN:r[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:eo.stringifyNumber},mg={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:r=>parseFloat(r.replace(/_/g,"")),stringify(r){let e=Number(r.value);return isFinite(e)?e.toExponential():eo.stringifyNumber(r)}},gg={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(r){let e=new pg.Scalar(parseFloat(r.replace(/_/g,""))),t=r.indexOf(".");if(t!==-1){let n=r.substring(t+1).replace(/_/g,"");n[n.length-1]==="0"&&(e.minFractionDigits=n.length)}return e},stringify:eo.stringifyNumber};$n.float=gg;$n.floatExp=mg;$n.floatNaN=hg});var Gl=x(ir=>{"use strict";var Yl=gt(),sr=r=>typeof r=="bigint"||Number.isInteger(r);function Mn(r,e,t,{intAsBigInt:n}){let s=r[0];if((s==="-"||s==="+")&&(e+=1),r=r.substring(e).replace(/_/g,""),n){switch(t){case 2:r=`0b${r}`;break;case 8:r=`0o${r}`;break;case 16:r=`0x${r}`;break}let o=BigInt(r);return s==="-"?BigInt(-1)*o:o}let i=parseInt(r,t);return s==="-"?-1*i:i}function to(r,e,t){let{value:n}=r;if(sr(n)){let s=n.toString(e);return n<0?"-"+t+s.substr(1):t+s}return Yl.stringifyNumber(r)}var yg={identify:sr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(r,e,t)=>Mn(r,2,2,t),stringify:r=>to(r,2,"0b")},bg={identify:sr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(r,e,t)=>Mn(r,1,8,t),stringify:r=>to(r,8,"0")},wg={identify:sr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(r,e,t)=>Mn(r,0,10,t),stringify:Yl.stringifyNumber},vg={identify:sr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(r,e,t)=>Mn(r,2,16,t),stringify:r=>to(r,16,"0x")};ir.int=wg;ir.intBin=yg;ir.intHex=vg;ir.intOct=bg});var no=x(ro=>{"use strict";var jn=P(),Dn=Pe(),Bn=Ce(),Ke=class r extends Bn.YAMLMap{constructor(e){super(e),this.tag=r.tag}add(e){let t;jn.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new Dn.Pair(e.key,null):t=new Dn.Pair(e,null),Bn.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let n=Bn.findPair(this.items,e);return!t&&jn.isPair(n)?jn.isScalar(n.key)?n.key.value:n.key:n}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 n=Bn.findPair(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new Dn.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw new Error("Set items must all have null values")}static from(e,t,n){let{replacer:s}=n,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(Dn.createPair(o,null,n));return i}};Ke.tag="tag:yaml.org,2002:set";var Sg={collection:"map",identify:r=>r instanceof Set,nodeClass:Ke,default:!1,tag:"tag:yaml.org,2002:set",createNode:(r,e,t)=>Ke.from(r,e,t),resolve(r,e){if(jn.isMap(r)){if(r.hasAllNullValues(!0))return Object.assign(new Ke,r);e("Set items must all have null values")}else e("Expected a mapping for this tag");return r}};ro.YAMLSet=Ke;ro.set=Sg});var io=x(qn=>{"use strict";var kg=gt();function so(r,e){let t=r[0],n=t==="-"||t==="+"?r.substring(1):r,s=o=>e?BigInt(o):Number(o),i=n.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return t==="-"?s(-1)*i:i}function zl(r){let{value:e}=r,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return kg.stringifyNumber(r);let n="";e<0&&(n="-",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))),n+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var xg={identify:r=>typeof r=="bigint"||Number.isInteger(r),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(r,e,{intAsBigInt:t})=>so(r,t),stringify:zl},Eg={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:r=>so(r,!1),stringify:zl},Ql={identify:r=>r 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(r){let e=r.match(Ql.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,n,s,i,o,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(t,n-1,s,i||0,o||0,a||0,c),f=e[8];if(f&&f!=="Z"){let u=so(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:r})=>r?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};qn.floatTime=Eg;qn.intTime=xg;qn.timestamp=Ql});var eu=x(Zl=>{"use strict";var Ag=ht(),Tg=On(),Og=mt(),Pg=tr(),Ng=Yi(),Xl=Vl(),oo=Hl(),Fn=Gl(),Cg=wn(),Rg=Xi(),_g=Ln(),Ig=no(),ao=io(),Lg=[Ag.map,Og.seq,Pg.string,Tg.nullTag,Xl.trueTag,Xl.falseTag,Fn.intBin,Fn.intOct,Fn.int,Fn.intHex,oo.floatNaN,oo.floatExp,oo.float,Ng.binary,Cg.merge,Rg.omap,_g.pairs,Ig.set,ao.intTime,ao.floatTime,ao.timestamp];Zl.schema=Lg});var uu=x(uo=>{"use strict";var su=ht(),$g=On(),iu=mt(),Mg=tr(),Dg=qi(),co=Ui(),lo=Ki(),Bg=Il(),jg=Ml(),ou=Yi(),or=wn(),au=Xi(),cu=Ln(),tu=eu(),lu=no(),Un=io(),ru=new Map([["core",Bg.schema],["failsafe",[su.map,iu.seq,Mg.string]],["json",jg.schema],["yaml11",tu.schema],["yaml-1.1",tu.schema]]),nu={binary:ou.binary,bool:Dg.boolTag,float:co.float,floatExp:co.floatExp,floatNaN:co.floatNaN,floatTime:Un.floatTime,int:lo.int,intHex:lo.intHex,intOct:lo.intOct,intTime:Un.intTime,map:su.map,merge:or.merge,null:$g.nullTag,omap:au.omap,pairs:cu.pairs,seq:iu.seq,set:lu.set,timestamp:Un.timestamp},qg={"tag:yaml.org,2002:binary":ou.binary,"tag:yaml.org,2002:merge":or.merge,"tag:yaml.org,2002:omap":au.omap,"tag:yaml.org,2002:pairs":cu.pairs,"tag:yaml.org,2002:set":lu.set,"tag:yaml.org,2002:timestamp":Un.timestamp};function Fg(r,e,t){let n=ru.get(e);if(n&&!r)return t&&!n.includes(or.merge)?n.concat(or.merge):n.slice();let s=n;if(!s)if(Array.isArray(r))s=[];else{let i=Array.from(ru.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(r))for(let i of r)s=s.concat(i);else typeof r=="function"&&(s=r(s.slice()));return t&&(s=s.concat(or.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?nu[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(nu).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return i.includes(a)||i.push(a),i},[])}uo.coreKnownTags=qg;uo.getTags=Fg});var ho=x(fu=>{"use strict";var fo=P(),Ug=ht(),Jg=mt(),Kg=tr(),Jn=uu(),Wg=(r,e)=>r.key<e.key?-1:r.key>e.key?1:0,po=class r{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?Jn.getTags(e,"compat"):e?Jn.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?Jn.coreKnownTags:{},this.tags=Jn.getTags(t,this.name,n),this.toStringOptions=a??null,Object.defineProperty(this,fo.MAP,{value:Ug.map}),Object.defineProperty(this,fo.SCALAR,{value:Kg.string}),Object.defineProperty(this,fo.SEQ,{value:Jg.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Wg:null}clone(){let e=Object.create(r.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};fu.Schema=po});var pu=x(du=>{"use strict";var Vg=P(),mo=Qt(),ar=Ht();function Hg(r,e){let t=[],n=e.directives===!0;if(e.directives!==!1&&r.directives){let c=r.directives.toString(r);c?(t.push(c),n=!0):r.directives.docStart&&(n=!0)}n&&t.push("---");let s=mo.createStringifyContext(r,e),{commentString:i}=s.options;if(r.commentBefore){t.length!==1&&t.unshift("");let c=i(r.commentBefore);t.unshift(ar.indentComment(c,""))}let o=!1,a=null;if(r.contents){if(Vg.isNode(r.contents)){if(r.contents.spaceBefore&&n&&t.push(""),r.contents.commentBefore){let f=i(r.contents.commentBefore);t.push(ar.indentComment(f,""))}s.forceBlockIndent=!!r.comment,a=r.contents.comment}let c=a?void 0:()=>o=!0,l=mo.stringify(r.contents,s,()=>a=null,c);a&&(l+=ar.lineComment(l,"",i(a))),(l[0]==="|"||l[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${l}`:t.push(l)}else t.push(mo.stringify(r.contents,s));if(r.directives?.docEnd)if(r.comment){let c=i(r.comment);c.includes(`
|
|
60
|
+
${i.comment}`:n.comment}n=s}r.items[t]=In.isPair(n)?n:new zi.Pair(n)}}else e("Expected a sequence for this tag");return r}function jl(r,e,t){let{replacer:n}=t,s=new ug.YAMLSeq(r);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof n=="function"&&(o=n.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(zi.createPair(a,c,t))}return s}var fg={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Bl,createNode:jl};Ln.createPairs=jl;Ln.pairs=fg;Ln.resolvePairs=Bl});var Zi=x(Xi=>{"use strict";var ql=P(),Qi=Ee(),nr=Ne(),dg=Ce(),Fl=$n(),Je=class r extends dg.YAMLSeq{constructor(){super(),this.add=nr.YAMLMap.prototype.add.bind(this),this.delete=nr.YAMLMap.prototype.delete.bind(this),this.get=nr.YAMLMap.prototype.get.bind(this),this.has=nr.YAMLMap.prototype.has.bind(this),this.set=nr.YAMLMap.prototype.set.bind(this),this.tag=r.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let s of this.items){let i,o;if(ql.isPair(s)?(i=Qi.toJS(s.key,"",t),o=Qi.toJS(s.value,i,t)):i=Qi.toJS(s,"",t),n.has(i))throw new Error("Ordered maps must not include duplicate keys");n.set(i,o)}return n}static from(e,t,n){let s=Fl.createPairs(e,t,n),i=new this;return i.items=s.items,i}};Je.tag="tag:yaml.org,2002:omap";var pg={collection:"seq",identify:r=>r instanceof Map,nodeClass:Je,default:!1,tag:"tag:yaml.org,2002:omap",resolve(r,e){let t=Fl.resolvePairs(r,e),n=[];for(let{key:s}of t.items)ql.isScalar(s)&&(n.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):n.push(s.value));return Object.assign(new Je,t)},createNode:(r,e,t)=>Je.from(r,e,t)};Xi.YAMLOMap=Je;Xi.omap=pg});var Vl=x(eo=>{"use strict";var Ul=I();function Jl({value:r,source:e},t){return e&&(r?Kl:Wl).test.test(e)?e:r?t.options.trueStr:t.options.falseStr}var Kl={identify:r=>r===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ul.Scalar(!0),stringify:Jl},Wl={identify:r=>r===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ul.Scalar(!1),stringify:Jl};eo.falseTag=Wl;eo.trueTag=Kl});var Hl=x(Mn=>{"use strict";var hg=I(),to=gt(),mg={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:r=>r.slice(-3).toLowerCase()==="nan"?NaN:r[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:to.stringifyNumber},gg={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:r=>parseFloat(r.replace(/_/g,"")),stringify(r){let e=Number(r.value);return isFinite(e)?e.toExponential():to.stringifyNumber(r)}},yg={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(r){let e=new hg.Scalar(parseFloat(r.replace(/_/g,""))),t=r.indexOf(".");if(t!==-1){let n=r.substring(t+1).replace(/_/g,"");n[n.length-1]==="0"&&(e.minFractionDigits=n.length)}return e},stringify:to.stringifyNumber};Mn.float=yg;Mn.floatExp=gg;Mn.floatNaN=mg});var Gl=x(ir=>{"use strict";var Yl=gt(),sr=r=>typeof r=="bigint"||Number.isInteger(r);function Dn(r,e,t,{intAsBigInt:n}){let s=r[0];if((s==="-"||s==="+")&&(e+=1),r=r.substring(e).replace(/_/g,""),n){switch(t){case 2:r=`0b${r}`;break;case 8:r=`0o${r}`;break;case 16:r=`0x${r}`;break}let o=BigInt(r);return s==="-"?BigInt(-1)*o:o}let i=parseInt(r,t);return s==="-"?-1*i:i}function ro(r,e,t){let{value:n}=r;if(sr(n)){let s=n.toString(e);return n<0?"-"+t+s.substr(1):t+s}return Yl.stringifyNumber(r)}var bg={identify:sr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(r,e,t)=>Dn(r,2,2,t),stringify:r=>ro(r,2,"0b")},wg={identify:sr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(r,e,t)=>Dn(r,1,8,t),stringify:r=>ro(r,8,"0")},vg={identify:sr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(r,e,t)=>Dn(r,0,10,t),stringify:Yl.stringifyNumber},Sg={identify:sr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(r,e,t)=>Dn(r,2,16,t),stringify:r=>ro(r,16,"0x")};ir.int=vg;ir.intBin=bg;ir.intHex=Sg;ir.intOct=wg});var so=x(no=>{"use strict";var qn=P(),Bn=Pe(),jn=Ne(),Ke=class r extends jn.YAMLMap{constructor(e){super(e),this.tag=r.tag}add(e){let t;qn.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new Bn.Pair(e.key,null):t=new Bn.Pair(e,null),jn.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let n=jn.findPair(this.items,e);return!t&&qn.isPair(n)?qn.isScalar(n.key)?n.key.value:n.key:n}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 n=jn.findPair(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new Bn.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw new Error("Set items must all have null values")}static from(e,t,n){let{replacer:s}=n,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(Bn.createPair(o,null,n));return i}};Ke.tag="tag:yaml.org,2002:set";var kg={collection:"map",identify:r=>r instanceof Set,nodeClass:Ke,default:!1,tag:"tag:yaml.org,2002:set",createNode:(r,e,t)=>Ke.from(r,e,t),resolve(r,e){if(qn.isMap(r)){if(r.hasAllNullValues(!0))return Object.assign(new Ke,r);e("Set items must all have null values")}else e("Expected a mapping for this tag");return r}};no.YAMLSet=Ke;no.set=kg});var oo=x(Fn=>{"use strict";var xg=gt();function io(r,e){let t=r[0],n=t==="-"||t==="+"?r.substring(1):r,s=o=>e?BigInt(o):Number(o),i=n.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return t==="-"?s(-1)*i:i}function zl(r){let{value:e}=r,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return xg.stringifyNumber(r);let n="";e<0&&(n="-",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))),n+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Eg={identify:r=>typeof r=="bigint"||Number.isInteger(r),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(r,e,{intAsBigInt:t})=>io(r,t),stringify:zl},Ag={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:r=>io(r,!1),stringify:zl},Ql={identify:r=>r 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(r){let e=r.match(Ql.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,n,s,i,o,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(t,n-1,s,i||0,o||0,a||0,c),f=e[8];if(f&&f!=="Z"){let u=io(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:r})=>r?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Fn.floatTime=Ag;Fn.intTime=Eg;Fn.timestamp=Ql});var eu=x(Zl=>{"use strict";var Tg=ht(),Og=Pn(),Pg=mt(),Rg=tr(),Ng=Gi(),Xl=Vl(),ao=Hl(),Un=Gl(),Cg=vn(),_g=Zi(),Ig=$n(),Lg=so(),co=oo(),$g=[Tg.map,Pg.seq,Rg.string,Og.nullTag,Xl.trueTag,Xl.falseTag,Un.intBin,Un.intOct,Un.int,Un.intHex,ao.floatNaN,ao.floatExp,ao.float,Ng.binary,Cg.merge,_g.omap,Ig.pairs,Lg.set,co.intTime,co.floatTime,co.timestamp];Zl.schema=$g});var uu=x(fo=>{"use strict";var su=ht(),Mg=Pn(),iu=mt(),Dg=tr(),Bg=Fi(),lo=Ji(),uo=Wi(),jg=Il(),qg=Ml(),ou=Gi(),or=vn(),au=Zi(),cu=$n(),tu=eu(),lu=so(),Jn=oo(),ru=new Map([["core",jg.schema],["failsafe",[su.map,iu.seq,Dg.string]],["json",qg.schema],["yaml11",tu.schema],["yaml-1.1",tu.schema]]),nu={binary:ou.binary,bool:Bg.boolTag,float:lo.float,floatExp:lo.floatExp,floatNaN:lo.floatNaN,floatTime:Jn.floatTime,int:uo.int,intHex:uo.intHex,intOct:uo.intOct,intTime:Jn.intTime,map:su.map,merge:or.merge,null:Mg.nullTag,omap:au.omap,pairs:cu.pairs,seq:iu.seq,set:lu.set,timestamp:Jn.timestamp},Fg={"tag:yaml.org,2002:binary":ou.binary,"tag:yaml.org,2002:merge":or.merge,"tag:yaml.org,2002:omap":au.omap,"tag:yaml.org,2002:pairs":cu.pairs,"tag:yaml.org,2002:set":lu.set,"tag:yaml.org,2002:timestamp":Jn.timestamp};function Ug(r,e,t){let n=ru.get(e);if(n&&!r)return t&&!n.includes(or.merge)?n.concat(or.merge):n.slice();let s=n;if(!s)if(Array.isArray(r))s=[];else{let i=Array.from(ru.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(r))for(let i of r)s=s.concat(i);else typeof r=="function"&&(s=r(s.slice()));return t&&(s=s.concat(or.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?nu[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(nu).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return i.includes(a)||i.push(a),i},[])}fo.coreKnownTags=Fg;fo.getTags=Ug});var mo=x(fu=>{"use strict";var po=P(),Jg=ht(),Kg=mt(),Wg=tr(),Kn=uu(),Vg=(r,e)=>r.key<e.key?-1:r.key>e.key?1:0,ho=class r{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?Kn.getTags(e,"compat"):e?Kn.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?Kn.coreKnownTags:{},this.tags=Kn.getTags(t,this.name,n),this.toStringOptions=a??null,Object.defineProperty(this,po.MAP,{value:Jg.map}),Object.defineProperty(this,po.SCALAR,{value:Wg.string}),Object.defineProperty(this,po.SEQ,{value:Kg.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Vg:null}clone(){let e=Object.create(r.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};fu.Schema=ho});var pu=x(du=>{"use strict";var Hg=P(),go=Qt(),ar=Ht();function Yg(r,e){let t=[],n=e.directives===!0;if(e.directives!==!1&&r.directives){let c=r.directives.toString(r);c?(t.push(c),n=!0):r.directives.docStart&&(n=!0)}n&&t.push("---");let s=go.createStringifyContext(r,e),{commentString:i}=s.options;if(r.commentBefore){t.length!==1&&t.unshift("");let c=i(r.commentBefore);t.unshift(ar.indentComment(c,""))}let o=!1,a=null;if(r.contents){if(Hg.isNode(r.contents)){if(r.contents.spaceBefore&&n&&t.push(""),r.contents.commentBefore){let f=i(r.contents.commentBefore);t.push(ar.indentComment(f,""))}s.forceBlockIndent=!!r.comment,a=r.contents.comment}let c=a?void 0:()=>o=!0,l=go.stringify(r.contents,s,()=>a=null,c);a&&(l+=ar.lineComment(l,"",i(a))),(l[0]==="|"||l[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${l}`:t.push(l)}else t.push(go.stringify(r.contents,s));if(r.directives?.docEnd)if(r.comment){let c=i(r.comment);c.includes(`
|
|
61
61
|
`)?(t.push("..."),t.push(ar.indentComment(c,""))):t.push(`... ${c}`)}else t.push("...");else{let c=r.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||a)&&t[t.length-1]!==""&&t.push(""),t.push(ar.indentComment(i(c),"")))}return t.join(`
|
|
62
62
|
`)+`
|
|
63
|
-
`}du.stringifyDocument=
|
|
63
|
+
`}du.stringifyDocument=Yg});var cr=x(hu=>{"use strict";var Gg=Wt(),yt=fn(),X=P(),zg=Pe(),Qg=Ee(),Xg=mo(),Zg=pu(),yo=an(),ey=vi(),ty=Vt(),bo=wi(),wo=class r{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,X.NODE_TYPE,{value:X.DOC});let s=null;typeof t=="function"||Array.isArray(t)?s=t:n===void 0&&t&&(n=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"},n);this.options=i;let{version:o}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new bo.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,s,n)}clone(){let e=Object.create(r.prototype,{[X.NODE_TYPE]:{value:X.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=X.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){bt(this.contents)&&this.contents.add(e)}addIn(e,t){bt(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=yo.anchorNames(this);e.anchor=!t||n.has(t)?yo.findNewAnchor(t||"a",n):t}return new Gg.Alias(e.anchor)}createNode(e,t,n){let s;if(typeof t=="function")e=t.call({"":e},"",e),s=t;else if(Array.isArray(t)){let y=k=>typeof k=="number"||k instanceof String||k instanceof Number,v=t.filter(y).map(String);v.length>0&&(t=t.concat(v)),s=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:c,onTagObj:l,tag:f}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:p}=yo.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:i??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:s,schema:this.schema,sourceObjects:p},h=ty.createNode(e,f,m);return a&&X.isCollection(h)&&(h.flow=!0),d(),h}createPair(e,t,n={}){let s=this.createNode(e,null,n),i=this.createNode(t,null,n);return new zg.Pair(s,i)}delete(e){return bt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return yt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):bt(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return X.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return yt.isEmptyPath(e)?!t&&X.isScalar(this.contents)?this.contents.value:this.contents:X.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return X.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return yt.isEmptyPath(e)?this.contents!==void 0:X.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=yt.collectionFromPath(this.schema,[e],t):bt(this.contents)&&this.contents.set(e,t)}setIn(e,t){yt.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=yt.collectionFromPath(this.schema,Array.from(e),t):bt(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let n;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new bo.Directives({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new bo.Directives({version:e}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=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(n)this.schema=new Xg.Schema(Object.assign(n,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:s,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},c=Qg.toJS(this.contents,t??"",a);if(typeof i=="function")for(let{count:l,res:f}of a.anchors.values())i(f,l);return typeof o=="function"?ey.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 Zg.stringifyDocument(this,e)}};function bt(r){if(X.isCollection(r))return!0;throw new Error("Expected a YAML collection as document contents")}hu.Document=wo});var fr=x(ur=>{"use strict";var lr=class extends Error{constructor(e,t,n,s){super(),this.name=e,this.code=n,this.message=s,this.pos=t}},vo=class extends lr{constructor(e,t,n){super("YAMLParseError",e,t,n)}},So=class extends lr{constructor(e,t,n){super("YAMLWarning",e,t,n)}},ry=(r,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(a=>e.linePos(a));let{line:n,col:s}=t.linePos[0];t.message+=` at line ${n}, column ${s}`;let i=s-1,o=r.substring(e.lineStarts[n-1],e.lineStarts[n]).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"),n>1&&/^ *$/.test(o.substring(0,i))){let a=r.substring(e.lineStarts[n-2],e.lineStarts[n-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
64
64
|
`),o=a+o}if(/[^ ]/.test(o)){let a=1,c=t.linePos[1];c?.line===n&&c.col>s&&(a=Math.max(1,Math.min(c.col-s,80-i)));let l=" ".repeat(i)+"^".repeat(a);t.message+=`:
|
|
65
65
|
|
|
66
66
|
${o}
|
|
67
67
|
${l}
|
|
68
|
-
`}};ur.YAMLError=lr;ur.YAMLParseError=
|
|
69
|
-
`))return!0;if(r.end){for(let e of r.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of r.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(
|
|
70
|
-
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||
|
|
71
|
-
`+g.comment:k.comment=g.comment);let b=new vu.Pair(k);t.options.keepSourceTokens&&(b.srcToken=f),a.items.push(b)}}return l&&l<c&&s(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[n.offset,c,l??c],a}Eu.resolveBlockMap=
|
|
72
|
-
`+S.comment:l.comment=S.comment),u=S.end;continue}!o&&t.options.strict&&
|
|
73
|
-
`+A:E.comment=A,S.comment=S.comment.substring(A.length+1)}}if(!o&&!b&&!S.found){let A=w?r(t,w,S,s):e(t,S.end,b,null,S,s);l.items.push(A),u=A.range[2],
|
|
74
|
-
`+
|
|
75
|
-
`+y.comment:l.comment=y.comment),l.range=[n.offset,h,y.offset]}else l.range=[n.offset,h,h];return l}
|
|
68
|
+
`}};ur.YAMLError=lr;ur.YAMLParseError=vo;ur.YAMLWarning=So;ur.prettifyError=ry});var dr=x(mu=>{"use strict";function ny(r,{flow:e,indicator:t,next:n,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let c=!1,l=a,f=a,u="",d="",p=!1,m=!1,h=null,y=null,v=null,k=null,g=null,b=null,w=null;for(let E of r)switch(m&&(E.type!=="space"&&E.type!=="newline"&&E.type!=="comma"&&i(E.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),h&&(l&&E.type!=="comment"&&E.type!=="newline"&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),E.type){case"space":!e&&(t!=="doc-start"||n?.type!=="flow-collection")&&E.source.includes(" ")&&(h=E),f=!0;break;case"comment":{f||i(E,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let N=E.source.substring(1)||" ";u?u+=d+N:u=N,d="",l=!1;break}case"newline":l?u?u+=E.source:(!b||t!=="seq-item-ind")&&(c=!0):d+=E.source,l=!0,p=!0,(y||v)&&(k=E),f=!0;break;case"anchor":y&&i(E,"MULTIPLE_ANCHORS","A node can have at most one anchor"),E.source.endsWith(":")&&i(E.offset+E.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=E,w??(w=E.offset),l=!1,f=!1,m=!0;break;case"tag":{v&&i(E,"MULTIPLE_TAGS","A node can have at most one tag"),v=E,w??(w=E.offset),l=!1,f=!1,m=!0;break}case t:(y||v)&&i(E,"BAD_PROP_ORDER",`Anchors and tags must be after the ${E.source} indicator`),b&&i(E,"UNEXPECTED_TOKEN",`Unexpected ${E.source} in ${e??"collection"}`),b=E,l=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){g&&i(E,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),g=E,l=!1,f=!1;break}default:i(E,"UNEXPECTED_TOKEN",`Unexpected ${E.type} token`),l=!1,f=!1}let S=r[r.length-1],A=S?S.offset+S.source.length:s;return m&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!=="")&&i(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=o||n?.type==="block-map"||n?.type==="block-seq")&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:g,found:b,spaceBefore:c,comment:u,hasNewline:p,anchor:y,tag:v,newlineAfterProp:k,end:A,start:w??A}}mu.resolveProps=ny});var Wn=x(gu=>{"use strict";function ko(r){if(!r)return null;switch(r.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(r.source.includes(`
|
|
69
|
+
`))return!0;if(r.end){for(let e of r.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of r.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(ko(e.key)||ko(e.value))return!0}return!1;default:return!0}}gu.containsNewline=ko});var xo=x(yu=>{"use strict";var sy=Wn();function iy(r,e,t){if(e?.type==="flow-collection"){let n=e.end[0];n.indent===r&&(n.source==="]"||n.source==="}")&&sy.containsNewline(e)&&t(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}yu.flowIndentCheck=iy});var Eo=x(wu=>{"use strict";var bu=P();function oy(r,e,t){let{uniqueKeys:n}=r.options;if(n===!1)return!1;let s=typeof n=="function"?n:(i,o)=>i===o||bu.isScalar(i)&&bu.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,t))}wu.mapIncludes=oy});var Au=x(Eu=>{"use strict";var vu=Pe(),ay=Ne(),Su=dr(),cy=Wn(),ku=xo(),ly=Eo(),xu="All mapping items must start at the same column";function uy({composeNode:r,composeEmptyNode:e},t,n,s,i){let o=i?.nodeClass??ay.YAMLMap,a=new o(t.schema);t.atRoot&&(t.atRoot=!1);let c=n.offset,l=null;for(let f of n.items){let{start:u,key:d,sep:p,value:m}=f,h=Su.resolveProps(u,{indicator:"explicit-key-ind",next:d??p?.[0],offset:c,onError:s,parentIndent:n.indent,startOnNewline:!0}),y=!h.found;if(y){if(d&&(d.type==="block-seq"?s(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==n.indent&&s(c,"BAD_INDENT",xu)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(a.comment?a.comment+=`
|
|
70
|
+
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||cy.containsNewline(d))&&s(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==n.indent&&s(c,"BAD_INDENT",xu);t.atKey=!0;let v=h.end,k=d?r(t,d,h,s):e(t,v,u,null,h,s);t.schema.compat&&ku.flowIndentCheck(n.indent,d,s),t.atKey=!1,ly.mapIncludes(t,a.items,k)&&s(v,"DUPLICATE_KEY","Map keys must be unique");let g=Su.resolveProps(p??[],{indicator:"map-value-ind",next:m,offset:k.range[2],onError:s,parentIndent:n.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=g.end,g.found){y&&(m?.type==="block-map"&&!g.hasNewline&&s(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&h.start<g.found.offset-1024&&s(k.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let b=m?r(t,m,g,s):e(t,c,p,null,g,s);t.schema.compat&&ku.flowIndentCheck(n.indent,m,s),c=b.range[2];let w=new vu.Pair(k,b);t.options.keepSourceTokens&&(w.srcToken=f),a.items.push(w)}else{y&&s(k.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),g.comment&&(k.comment?k.comment+=`
|
|
71
|
+
`+g.comment:k.comment=g.comment);let b=new vu.Pair(k);t.options.keepSourceTokens&&(b.srcToken=f),a.items.push(b)}}return l&&l<c&&s(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[n.offset,c,l??c],a}Eu.resolveBlockMap=uy});var Ou=x(Tu=>{"use strict";var fy=Ce(),dy=dr(),py=xo();function hy({composeNode:r,composeEmptyNode:e},t,n,s,i){let o=i?.nodeClass??fy.YAMLSeq,a=new o(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let c=n.offset,l=null;for(let{start:f,value:u}of n.items){let d=dy.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:c,onError:s,parentIndent:n.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?s(d.end,"BAD_INDENT","All sequence items must start at the same column"):s(c,"MISSING_CHAR","Sequence item without - indicator");else{l=d.end,d.comment&&(a.comment=d.comment);continue}let p=u?r(t,u,d,s):e(t,d.end,f,null,d,s);t.schema.compat&&py.flowIndentCheck(n.indent,u,s),c=p.range[2],a.items.push(p)}return a.range=[n.offset,c,l??c],a}Tu.resolveBlockSeq=hy});var wt=x(Pu=>{"use strict";function my(r,e,t,n){let s="";if(r){let i=!1,o="";for(let a of r){let{source:c,type:l}=a;switch(l){case"space":i=!0;break;case"comment":{t&&!i&&n(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=c.substring(1)||" ";s?s+=o+f:s=f,o="";break}case"newline":s&&(o+=c),i=!0;break;default:n(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:s,offset:e}}Pu.resolveEnd=my});var _u=x(Cu=>{"use strict";var gy=P(),yy=Pe(),Ru=Ne(),by=Ce(),wy=wt(),Nu=dr(),vy=Wn(),Sy=Eo(),Ao="Block collections are not allowed within flow collections",To=r=>r&&(r.type==="block-map"||r.type==="block-seq");function ky({composeNode:r,composeEmptyNode:e},t,n,s,i){let o=n.start.source==="{",a=o?"flow map":"flow sequence",c=i?.nodeClass??(o?Ru.YAMLMap:by.YAMLSeq),l=new c(t.schema);l.flow=!0;let f=t.atRoot;f&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let u=n.offset+n.start.source.length;for(let y=0;y<n.items.length;++y){let v=n.items[y],{start:k,key:g,sep:b,value:w}=v,S=Nu.resolveProps(k,{flow:a,indicator:"explicit-key-ind",next:g??b?.[0],offset:u,onError:s,parentIndent:n.indent,startOnNewline:!1});if(!S.found){if(!S.anchor&&!S.tag&&!b&&!w){y===0&&S.comma?s(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):y<n.items.length-1&&s(S.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),S.comment&&(l.comment?l.comment+=`
|
|
72
|
+
`+S.comment:l.comment=S.comment),u=S.end;continue}!o&&t.options.strict&&vy.containsNewline(g)&&s(g,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0)S.comma&&s(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(S.comma||s(S.start,"MISSING_CHAR",`Missing , between ${a} items`),S.comment){let A="";e:for(let E of k)switch(E.type){case"comma":case"space":break;case"comment":A=E.source.substring(1);break e;default:break e}if(A){let E=l.items[l.items.length-1];gy.isPair(E)&&(E=E.value??E.key),E.comment?E.comment+=`
|
|
73
|
+
`+A:E.comment=A,S.comment=S.comment.substring(A.length+1)}}if(!o&&!b&&!S.found){let A=w?r(t,w,S,s):e(t,S.end,b,null,S,s);l.items.push(A),u=A.range[2],To(w)&&s(A.range,"BLOCK_IN_FLOW",Ao)}else{t.atKey=!0;let A=S.end,E=g?r(t,g,S,s):e(t,A,k,null,S,s);To(g)&&s(E.range,"BLOCK_IN_FLOW",Ao),t.atKey=!1;let N=Nu.resolveProps(b??[],{flow:a,indicator:"map-value-ind",next:w,offset:E.range[2],onError:s,parentIndent:n.indent,startOnNewline:!1});if(N.found){if(!o&&!S.found&&t.options.strict){if(b)for(let C of b){if(C===N.found)break;if(C.type==="newline"){s(C,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}S.start<N.found.offset-1024&&s(N.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else w&&("source"in w&&w.source?.[0]===":"?s(w,"MISSING_CHAR",`Missing space after : in ${a}`):s(N.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let J=w?r(t,w,N,s):N.found?e(t,N.end,b,null,N,s):null;J?To(w)&&s(J.range,"BLOCK_IN_FLOW",Ao):N.comment&&(E.comment?E.comment+=`
|
|
74
|
+
`+N.comment:E.comment=N.comment);let q=new yy.Pair(E,J);if(t.options.keepSourceTokens&&(q.srcToken=v),o){let C=l;Sy.mapIncludes(t,C.items,E)&&s(A,"DUPLICATE_KEY","Map keys must be unique"),C.items.push(q)}else{let C=new Ru.YAMLMap(t.schema);C.flow=!0,C.items.push(q);let xe=(J??E).range;C.range=[E.range[0],xe[1],xe[2]],l.items.push(C)}u=J?J.range[2]:N.end}}let d=o?"}":"]",[p,...m]=n.end,h=u;if(p?.source===d)h=p.offset+p.source.length;else{let y=a[0].toUpperCase()+a.substring(1),v=f?`${y} must end with a ${d}`:`${y} in block collection must be sufficiently indented and end with a ${d}`;s(u,f?"MISSING_CHAR":"BAD_INDENT",v),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){let y=wy.resolveEnd(m,h,t.options.strict,s);y.comment&&(l.comment?l.comment+=`
|
|
75
|
+
`+y.comment:l.comment=y.comment),l.range=[n.offset,h,y.offset]}else l.range=[n.offset,h,h];return l}Cu.resolveFlowCollection=ky});var Lu=x(Iu=>{"use strict";var xy=P(),Ey=I(),Ay=Ne(),Ty=Ce(),Oy=Au(),Py=Ou(),Ry=_u();function Oo(r,e,t,n,s,i){let o=t.type==="block-map"?Oy.resolveBlockMap(r,e,t,n,i):t.type==="block-seq"?Py.resolveBlockSeq(r,e,t,n,i):Ry.resolveFlowCollection(r,e,t,n,i),a=o.constructor;return s==="!"||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function Ny(r,e,t,n,s){let i=n.tag,o=i?e.directives.tagName(i.source,d=>s(i,"TAG_RESOLVE_FAILED",d)):null;if(t.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=n,m=d&&i?d.offset>i.offset?d:i:d??i;m&&(!p||p.offset<m.offset)&&s(m,"MISSING_CHAR","Missing newline after block sequence props")}let a=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===Ay.YAMLMap.tagName&&a==="map"||o===Ty.YAMLSeq.tagName&&a==="seq")return Oo(r,e,t,s,o);let c=e.schema.tags.find(d=>d.tag===o&&d.collection===a);if(!c){let d=e.schema.knownTags[o];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else return d?s(i,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Oo(r,e,t,s,o)}let l=Oo(r,e,t,s,o,c),f=c.resolve?.(l,d=>s(i,"TAG_RESOLVE_FAILED",d),e.options)??l,u=xy.isNode(f)?f:new Ey.Scalar(f);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}Iu.composeCollection=Ny});var Ro=x($u=>{"use strict";var Po=I();function Cy(r,e,t){let n=e.offset,s=_y(e,r.options.strict,t);if(!s)return{value:"",type:null,comment:"",range:[n,n,n]};let i=s.mode===">"?Po.Scalar.BLOCK_FOLDED:Po.Scalar.BLOCK_LITERAL,o=e.source?Iy(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?`
|
|
76
76
|
`.repeat(Math.max(1,o.length-1)):"",y=n+s.length;return e.source&&(y+=e.source.length),{value:h,type:i,comment:s.comment,range:[n,y,y]}}let c=e.indent+s.indent,l=e.offset+s.length,f=0;for(let h=0;h<a;++h){let[y,v]=o[h];if(v===""||v==="\r")s.indent===0&&y.length>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),f=h,c===0&&!r.atRoot&&t(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=y.length+v.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>c&&(a=h+1);let u="",d="",p=!1;for(let h=0;h<f;++h)u+=o[h][0].slice(c)+`
|
|
77
|
-
`;for(let h=f;h<a;++h){let[y,v]=o[h];l+=y.length+v.length+1;let k=v[v.length-1]==="\r";if(k&&(v=v.slice(0,-1)),v&&y.length<c){let b=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;t(l-v.length-(k?2:1),"BAD_INDENT",b),y=""}i===
|
|
77
|
+
`;for(let h=f;h<a;++h){let[y,v]=o[h];l+=y.length+v.length+1;let k=v[v.length-1]==="\r";if(k&&(v=v.slice(0,-1)),v&&y.length<c){let b=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;t(l-v.length-(k?2:1),"BAD_INDENT",b),y=""}i===Po.Scalar.BLOCK_LITERAL?(u+=d+y.slice(c)+v,d=`
|
|
78
78
|
`):y.length>c||v[0]===" "?(d===" "?d=`
|
|
79
79
|
`:!p&&d===`
|
|
80
80
|
`&&(d=`
|
|
@@ -87,83 +87,83 @@ ${l}
|
|
|
87
87
|
`+o[h][0].slice(c);u[u.length-1]!==`
|
|
88
88
|
`&&(u+=`
|
|
89
89
|
`);break;default:u+=`
|
|
90
|
-
`}let m=n+s.length+e.source.length;return{value:u,type:i,comment:s.comment,range:[n,m,m]}}function
|
|
90
|
+
`}let m=n+s.length+e.source.length;return{value:u,type:i,comment:s.comment,range:[n,m,m]}}function _y({offset:r,props:e},t,n){if(e[0].type!=="block-scalar-header")return n(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=e[0],i=s[0],o=0,a="",c=-1;for(let d=1;d<s.length;++d){let p=s[d];if(!a&&(p==="-"||p==="+"))a=p;else{let m=Number(p);!o&&m?o=m:c===-1&&(c=r+d)}}c!==-1&&n(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let l=!1,f="",u=s.length;for(let d=1;d<e.length;++d){let p=e[d];switch(p.type){case"space":l=!0;case"newline":u+=p.source.length;break;case"comment":t&&!l&&n(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,f=p.source.substring(1);break;case"error":n(p,"UNEXPECTED_TOKEN",p.message),u+=p.source.length;break;default:{let m=`Unexpected token in block scalar header: ${p.type}`;n(p,"UNEXPECTED_TOKEN",m);let h=p.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:i,indent:o,chomp:a,comment:f,length:u}}function Iy(r){let e=r.split(/\n( *)/),t=e[0],n=t.match(/^( *)/),i=[n?.[1]?[n[1],t.slice(n[1].length)]:["",t]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}$u.resolveBlockScalar=Cy});var Co=x(Du=>{"use strict";var No=I(),Ly=wt();function $y(r,e,t){let{offset:n,type:s,source:i,end:o}=r,a,c,l=(d,p,m)=>t(n+d,p,m);switch(s){case"scalar":a=No.Scalar.PLAIN,c=My(i,l);break;case"single-quoted-scalar":a=No.Scalar.QUOTE_SINGLE,c=Dy(i,l);break;case"double-quoted-scalar":a=No.Scalar.QUOTE_DOUBLE,c=By(i,l);break;default:return t(r,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[n,n+i.length,n+i.length]}}let f=n+i.length,u=Ly.resolveEnd(o,f,e,t);return{value:c,type:a,comment:u.comment,range:[n,f,u.offset]}}function My(r,e){let t="";switch(r[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 ${r[0]}`;break}case"@":case"`":{t=`reserved character ${r[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),Mu(r)}function Dy(r,e){return(r[r.length-1]!=="'"||r.length===1)&&e(r.length,"MISSING_CHAR","Missing closing 'quote"),Mu(r.slice(1,-1)).replace(/''/g,"'")}function Mu(r){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
91
91
|
`,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
92
92
|
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=e.exec(r);if(!n)return r;let s=n[1],i=" ",o=e.lastIndex;for(t.lastIndex=o;n=t.exec(r);)n[1]===""?i===`
|
|
93
93
|
`?s+=i:i=`
|
|
94
|
-
`:(s+=i+n[1],i=" "),o=t.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,n=a.exec(r),s+i+(n?.[1]??"")}function
|
|
94
|
+
`:(s+=i+n[1],i=" "),o=t.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,n=a.exec(r),s+i+(n?.[1]??"")}function By(r,e){let t="";for(let n=1;n<r.length-1;++n){let s=r[n];if(!(s==="\r"&&r[n+1]===`
|
|
95
95
|
`))if(s===`
|
|
96
|
-
`){let{fold:i,offset:o}=
|
|
96
|
+
`){let{fold:i,offset:o}=jy(r,n);t+=i,n=o}else if(s==="\\"){let i=r[++n],o=qy[i];if(o)t+=o;else if(i===`
|
|
97
97
|
`)for(i=r[n+1];i===" "||i===" ";)i=r[++n+1];else if(i==="\r"&&r[n+1]===`
|
|
98
|
-
`)for(i=r[++n+1];i===" "||i===" ";)i=r[++n+1];else if(i==="x"||i==="u"||i==="U"){let a={x:2,u:4,U:8}[i];t+=
|
|
98
|
+
`)for(i=r[++n+1];i===" "||i===" ";)i=r[++n+1];else if(i==="x"||i==="u"||i==="U"){let a={x:2,u:4,U:8}[i];t+=Fy(r,n+1,a,e),n+=a}else{let a=r.substr(n-1,2);e(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),t+=a}}else if(s===" "||s===" "){let i=n,o=r[n+1];for(;o===" "||o===" ";)o=r[++n+1];o!==`
|
|
99
99
|
`&&!(o==="\r"&&r[n+2]===`
|
|
100
|
-
`)&&(t+=n>i?r.slice(i,n+1):s)}else t+=s}return(r[r.length-1]!=='"'||r.length===1)&&e(r.length,"MISSING_CHAR",'Missing closing "quote'),t}function
|
|
100
|
+
`)&&(t+=n>i?r.slice(i,n+1):s)}else t+=s}return(r[r.length-1]!=='"'||r.length===1)&&e(r.length,"MISSING_CHAR",'Missing closing "quote'),t}function jy(r,e){let t="",n=r[e+1];for(;(n===" "||n===" "||n===`
|
|
101
101
|
`||n==="\r")&&!(n==="\r"&&r[e+2]!==`
|
|
102
102
|
`);)n===`
|
|
103
103
|
`&&(t+=`
|
|
104
|
-
`),e+=1,n=r[e+1];return t||(t=" "),{fold:t,offset:e}}var
|
|
105
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
104
|
+
`),e+=1,n=r[e+1];return t||(t=" "),{fold:t,offset:e}}var qy={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
105
|
+
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Fy(r,e,t,n){let s=r.substr(e,t),o=s.length===t&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;if(isNaN(o)){let a=r.substr(e-2,t+2);return n(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}Du.resolveFlowScalar=$y});var qu=x(ju=>{"use strict";var We=P(),Bu=I(),Uy=Ro(),Jy=Co();function Ky(r,e,t,n){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?Uy.resolveBlockScalar(r,e,n):Jy.resolveFlowScalar(e,r.options.strict,n),c=t?r.directives.tagName(t.source,u=>n(t,"TAG_RESOLVE_FAILED",u)):null,l;r.options.stringKeys&&r.atKey?l=r.schema[We.SCALAR]:c?l=Wy(r.schema,s,c,t,n):e.type==="scalar"?l=Vy(r,s,e,n):l=r.schema[We.SCALAR];let f;try{let u=l.resolve(s,d=>n(t??e,"TAG_RESOLVE_FAILED",d),r.options);f=We.isScalar(u)?u:new Bu.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);n(t??e,"TAG_RESOLVE_FAILED",d),f=new Bu.Scalar(s)}return f.range=a,f.source=s,i&&(f.type=i),c&&(f.tag=c),l.format&&(f.format=l.format),o&&(f.comment=o),f}function Wy(r,e,t,n,s){if(t==="!")return r[We.SCALAR];let i=[];for(let a of r.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=r.knownTags[t];return o&&!o.collection?(r.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),r[We.SCALAR])}function Vy({atKey:r,directives:e,schema:t},n,s,i){let o=t.tags.find(a=>(a.default===!0||r&&a.default==="key")&&a.test?.test(n))||t[We.SCALAR];if(t.compat){let a=t.compat.find(c=>c.default&&c.test?.test(n))??t[We.SCALAR];if(o.tag!==a.tag){let c=e.tagString(o.tag),l=e.tagString(a.tag),f=`Value may be parsed as either ${c} or ${l}`;i(s,"TAG_RESOLVE_FAILED",f,!0)}}return o}ju.composeScalar=Ky});var Uu=x(Fu=>{"use strict";function Hy(r,e,t){if(e){t??(t=e.length);for(let n=t-1;n>=0;--n){let s=e[n];switch(s.type){case"space":case"comment":case"newline":r-=s.source.length;continue}for(s=e[++n];s?.type==="space";)r+=s.source.length,s=e[++n];break}}return r}Fu.emptyScalarPosition=Hy});var Wu=x(Io=>{"use strict";var Yy=Wt(),Gy=P(),zy=Lu(),Ju=qu(),Qy=wt(),Xy=Uu(),Zy={composeNode:Ku,composeEmptyNode:_o};function Ku(r,e,t,n){let s=r.atKey,{spaceBefore:i,comment:o,anchor:a,tag:c}=t,l,f=!0;switch(e.type){case"alias":l=eb(r,e,n),(a||c)&&n(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=Ju.composeScalar(r,e,c,n),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":l=zy.composeCollection(Zy,r,e,t,n),a&&(l.anchor=a.source.substring(1));break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;n(e,"UNEXPECTED_TOKEN",u),l=_o(r,e.offset,void 0,null,t,n),f=!1}}return a&&l.anchor===""&&n(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&r.options.stringKeys&&(!Gy.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&n(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),r.options.keepSourceTokens&&f&&(l.srcToken=e),l}function _o(r,e,t,n,{spaceBefore:s,comment:i,anchor:o,tag:a,end:c},l){let f={type:"scalar",offset:Xy.emptyScalarPosition(e,t,n),indent:-1,source:""},u=Ju.composeScalar(r,f,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 eb({options:r},{offset:e,source:t,end:n},s){let i=new Yy.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=Qy.resolveEnd(n,o,r.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Io.composeEmptyNode=_o;Io.composeNode=Ku});var Yu=x(Hu=>{"use strict";var tb=cr(),Vu=Wu(),rb=wt(),nb=dr();function sb(r,e,{offset:t,start:n,value:s,end:i},o){let a=Object.assign({_directives:e},r),c=new tb.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},f=nb.resolveProps(n,{indicator:"doc-start",next:s??i?.[0],offset:t,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(c.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=s?Vu.composeNode(l,s,f,o):Vu.composeEmptyNode(l,f.end,n,null,f,o);let u=c.contents.range[2],d=rb.resolveEnd(i,u,!1,o);return d.comment&&(c.comment=d.comment),c.range=[t,u,d.offset],c}Hu.composeDoc=sb});var $o=x(Qu=>{"use strict";var ib=zr("process"),ob=wi(),ab=cr(),pr=fr(),Gu=P(),cb=Yu(),lb=wt();function hr(r){if(typeof r=="number")return[r,r+1];if(Array.isArray(r))return r.length===2?r:[r[0],r[1]];let{offset:e,source:t}=r;return[e,e+(typeof t=="string"?t.length:1)]}function zu(r){let e="",t=!1,n=!1;for(let s=0;s<r.length;++s){let i=r[s];switch(i[0]){case"#":e+=(e===""?"":n?`
|
|
106
106
|
|
|
107
107
|
`:`
|
|
108
|
-
`)+(i.substring(1)||" "),t=!0,n=!1;break;case"%":r[s+1]?.[0]!=="#"&&(s+=1),t=!1;break;default:t||(n=!0),t=!1}}return{comment:e,afterEmptyLine:n}}var
|
|
108
|
+
`)+(i.substring(1)||" "),t=!0,n=!1;break;case"%":r[s+1]?.[0]!=="#"&&(s+=1),t=!1;break;default:t||(n=!0),t=!1}}return{comment:e,afterEmptyLine:n}}var Lo=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,s,i)=>{let o=hr(t);i?this.warnings.push(new pr.YAMLWarning(o,n,s)):this.errors.push(new pr.YAMLParseError(o,n,s))},this.directives=new ob.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:s}=zu(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
109
109
|
${n}`:n;else if(s||e.directives.docStart||!i)e.commentBefore=n;else if(Gu.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];Gu.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${n}
|
|
110
110
|
${a}`:n}else{let o=i.commentBefore;i.commentBefore=o?`${n}
|
|
111
|
-
${o}`:n}}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:zu(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let s of e)yield*this.next(s);yield*this.end(t,n)}*next(e){switch(
|
|
112
|
-
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new pr.YAMLParseError(hr(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 n=Object.assign({_directives:this.directives},this.options),s=new
|
|
111
|
+
${o}`:n}}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:zu(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let s of e)yield*this.next(s);yield*this.end(t,n)}*next(e){switch(ib.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,n,s)=>{let i=hr(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",n,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=cb.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,n=new pr.YAMLParseError(hr(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){let n="Unexpected doc-end without preceding document";this.errors.push(new pr.YAMLParseError(hr(e),"UNEXPECTED_TOKEN",n));break}this.doc.directives.docEnd=!0;let t=lb.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
|
|
112
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new pr.YAMLParseError(hr(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 n=Object.assign({_directives:this.directives},this.options),s=new ab.Document(void 0,n);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,t,t],this.decorate(s,!1),yield s}}};Qu.Composer=Lo});var ef=x(Vn=>{"use strict";var ub=Ro(),fb=Co(),db=fr(),Xu=zt();function pb(r,e=!0,t){if(r){let n=(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 db.YAMLParseError([a,a+1],i,o)};switch(r.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return fb.resolveFlowScalar(r,e,n);case"block-scalar":return ub.resolveBlockScalar({options:{strict:e}},r,n)}}return null}function hb(r,e){let{implicitKey:t=!1,indent:n,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=Xu.stringifyString({type:o,value:r},{implicitKey:t,indent:n>0?" ".repeat(n):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:n,source:`
|
|
113
113
|
`}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
|
|
114
114
|
`),f=a.substring(0,l),u=a.substring(l+1)+`
|
|
115
115
|
`,d=[{type:"block-scalar-header",offset:i,indent:n,source:f}];return Zu(d,c)||d.push({type:"newline",offset:-1,indent:n,source:`
|
|
116
|
-
`}),{type:"block-scalar",offset:i,indent:n,props:d,source:u}}case'"':return{type:"double-quoted-scalar",offset:i,indent:n,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:n,source:a,end:c};default:return{type:"scalar",offset:i,indent:n,source:a,end:c}}}function
|
|
116
|
+
`}),{type:"block-scalar",offset:i,indent:n,props:d,source:u}}case'"':return{type:"double-quoted-scalar",offset:i,indent:n,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:n,source:a,end:c};default:return{type:"scalar",offset:i,indent:n,source:a,end:c}}}function mb(r,e,t={}){let{afterKey:n=!1,implicitKey:s=!1,inFlow:i=!1,type:o}=t,a="indent"in r?r.indent:null;if(n&&typeof a=="number"&&(a+=2),!o)switch(r.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=r.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=Xu.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">":gb(r,c);break;case'"':Mo(r,c,"double-quoted-scalar");break;case"'":Mo(r,c,"single-quoted-scalar");break;default:Mo(r,c,"scalar")}}function gb(r,e){let t=e.indexOf(`
|
|
117
117
|
`),n=e.substring(0,t),s=e.substring(t+1)+`
|
|
118
118
|
`;if(r.type==="block-scalar"){let i=r.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=n,r.source=s}else{let{offset:i}=r,o="indent"in r?r.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:n}];Zu(a,"end"in r?r.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
|
|
119
|
-
`});for(let c of Object.keys(r))c!=="type"&&c!=="offset"&&delete r[c];Object.assign(r,{type:"block-scalar",indent:o,props:a,source:s})}}function Zu(r,e){if(e)for(let t of e)switch(t.type){case"space":case"comment":r.push(t);break;case"newline":return r.push(t),!0}return!1}function
|
|
120
|
-
`};delete r.items,Object.assign(r,{type:t,source:e,end:[s]});break}default:{let n="indent"in r?r.indent:-1,s="end"in r&&Array.isArray(r.end)?r.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(r))i!=="type"&&i!=="offset"&&delete r[i];Object.assign(r,{type:t,indent:n,source:e,end:s})}}}
|
|
119
|
+
`});for(let c of Object.keys(r))c!=="type"&&c!=="offset"&&delete r[c];Object.assign(r,{type:"block-scalar",indent:o,props:a,source:s})}}function Zu(r,e){if(e)for(let t of e)switch(t.type){case"space":case"comment":r.push(t);break;case"newline":return r.push(t),!0}return!1}function Mo(r,e,t){switch(r.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":r.type=t,r.source=e;break;case"block-scalar":{let n=r.props.slice(1),s=e.length;r.props[0].type==="block-scalar-header"&&(s-=r.props[0].source.length);for(let i of n)i.offset+=s;delete r.props,Object.assign(r,{type:t,source:e,end:n});break}case"block-map":case"block-seq":{let s={type:"newline",offset:r.offset+e.length,indent:r.indent,source:`
|
|
120
|
+
`};delete r.items,Object.assign(r,{type:t,source:e,end:[s]});break}default:{let n="indent"in r?r.indent:-1,s="end"in r&&Array.isArray(r.end)?r.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(r))i!=="type"&&i!=="offset"&&delete r[i];Object.assign(r,{type:t,indent:n,source:e,end:s})}}}Vn.createScalarToken=hb;Vn.resolveAsScalar=pb;Vn.setScalarValue=mb});var rf=x(tf=>{"use strict";var yb=r=>"type"in r?Yn(r):Hn(r);function Yn(r){switch(r.type){case"block-scalar":{let e="";for(let t of r.props)e+=Yn(t);return e+r.source}case"block-map":case"block-seq":{let e="";for(let t of r.items)e+=Hn(t);return e}case"flow-collection":{let e=r.start.source;for(let t of r.items)e+=Hn(t);for(let t of r.end)e+=t.source;return e}case"document":{let e=Hn(r);if(r.end)for(let t of r.end)e+=t.source;return e}default:{let e=r.source;if("end"in r&&r.end)for(let t of r.end)e+=t.source;return e}}}function Hn({start:r,key:e,sep:t,value:n}){let s="";for(let i of r)s+=i.source;if(e&&(s+=Yn(e)),t)for(let i of t)s+=i.source;return n&&(s+=Yn(n)),s}tf.stringify=yb});var af=x(of=>{"use strict";var Do=Symbol("break visit"),bb=Symbol("skip children"),nf=Symbol("remove item");function Ve(r,e){"type"in r&&r.type==="document"&&(r={start:r.start,value:r.value}),sf(Object.freeze([]),r,e)}Ve.BREAK=Do;Ve.SKIP=bb;Ve.REMOVE=nf;Ve.itemAtPath=(r,e)=>{let t=r;for(let[n,s]of e){let i=t?.[n];if(i&&"items"in i)t=i.items[s];else return}return t};Ve.parentCollection=(r,e)=>{let t=Ve.itemAtPath(r,e.slice(0,-1)),n=e[e.length-1][0],s=t?.[n];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function sf(r,e,t){let n=t(e,r);if(typeof n=="symbol")return n;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=sf(Object.freeze(r.concat([[s,o]])),i.items[o],t);if(typeof a=="number")o=a-1;else{if(a===Do)return Do;a===nf&&(i.items.splice(o,1),o-=1)}}typeof n=="function"&&s==="key"&&(n=n(e,r))}}return typeof n=="function"?n(e,r):n}of.visit=Ve});var Gn=x(W=>{"use strict";var Bo=ef(),wb=rf(),vb=af(),jo="\uFEFF",qo="",Fo="",Uo="",Sb=r=>!!r&&"items"in r,kb=r=>!!r&&(r.type==="scalar"||r.type==="single-quoted-scalar"||r.type==="double-quoted-scalar"||r.type==="block-scalar");function xb(r){switch(r){case jo:return"<BOM>";case qo:return"<DOC>";case Fo:return"<FLOW_END>";case Uo:return"<SCALAR>";default:return JSON.stringify(r)}}function Eb(r){switch(r){case jo:return"byte-order-mark";case qo:return"doc-mode";case Fo:return"flow-error-end";case Uo:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
121
121
|
`:case`\r
|
|
122
|
-
`: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(r[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}W.createScalarToken=
|
|
123
|
-
`:case"\r":case" ":return!0;default:return!1}}var cf=new Set("0123456789ABCDEFabcdef"),
|
|
124
|
-
\r `),
|
|
122
|
+
`: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(r[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}W.createScalarToken=Bo.createScalarToken;W.resolveAsScalar=Bo.resolveAsScalar;W.setScalarValue=Bo.setScalarValue;W.stringify=wb.stringify;W.visit=vb.visit;W.BOM=jo;W.DOCUMENT=qo;W.FLOW_END=Fo;W.SCALAR=Uo;W.isCollection=Sb;W.isScalar=kb;W.prettyToken=xb;W.tokenType=Eb});var Wo=x(lf=>{"use strict";var mr=Gn();function ne(r){switch(r){case void 0:case" ":case`
|
|
123
|
+
`:case"\r":case" ":return!0;default:return!1}}var cf=new Set("0123456789ABCDEFabcdef"),Ab=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),zn=new Set(",[]{}"),Tb=new Set(` ,[]{}
|
|
124
|
+
\r `),Jo=r=>!r||Tb.has(r),Ko=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 n=this.next??"stream";for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
|
|
125
125
|
`?!0:t==="\r"?this.buffer[e+1]===`
|
|
126
126
|
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===" ";)t=this.buffer[++n+e];if(t==="\r"){let s=this.buffer[n+e+1];if(s===`
|
|
127
127
|
`||!s&&!this.atEnd)return e+n+1}return t===`
|
|
128
128
|
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&ne(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(`
|
|
129
|
-
`,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]===mr.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,n=e.indexOf("#");for(;n!==-1;){let i=e[n-1];if(i===" "||i===" "){t=n-1;break}else n=e.indexOf("#",n+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 mr.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==="...")&&ne(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&&!ne(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===":")&&ne(t)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,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(
|
|
129
|
+
`,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]===mr.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,n=e.indexOf("#");for(;n!==-1;){let i=e[n-1];if(i===" "||i===" "){t=n-1;break}else n=e.indexOf("#",n+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 mr.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==="...")&&ne(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&&!ne(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===":")&&ne(t)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,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(Jo),"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,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let s=this.getLine();if(s===null)return this.setNext("flow");if((n!==-1&&n<this.indentNext&&s[0]!=="#"||n===0&&(s.startsWith("---")||s.startsWith("..."))&&ne(s[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield mr.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(Jo),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ne(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 n=this.buffer.substring(0,t),s=n.indexOf(`
|
|
130
130
|
`,this.pos);if(s!==-1){for(;s!==-1;){let i=this.continueScalar(s+1);if(i===-1)break;s=n.indexOf(`
|
|
131
131
|
`,i)}s!==-1&&(t=s-(n[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=>ne(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,n;e:for(let i=this.pos;n=this.buffer[i];++i)switch(n){case" ":t+=1;break;case`
|
|
132
132
|
`:e=i,t=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
133
133
|
`)break}default:break e}if(!n&&!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(`
|
|
134
134
|
`,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let s=e+1;for(n=this.buffer[s];n===" ";)n=this.buffer[++s];if(n===" "){for(;n===" "||n===" "||n==="\r"||n===`
|
|
135
135
|
`;)n=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===`
|
|
136
|
-
`&&i>=this.pos&&i+1+t>a)e=i;else break}while(!0);return yield mr.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,s;for(;s=this.buffer[++n];)if(s===":"){let i=this.buffer[n+1];if(ne(i)||e&&
|
|
136
|
+
`&&i>=this.pos&&i+1+t>a)e=i;else break}while(!0);return yield mr.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,s;for(;s=this.buffer[++n];)if(s===":"){let i=this.buffer[n+1];if(ne(i)||e&&zn.has(i))break;t=n}else if(ne(s)){let i=this.buffer[n+1];if(s==="\r"&&(i===`
|
|
137
137
|
`?(n+=1,s=`
|
|
138
|
-
`,i=this.buffer[n+1]):t=n),i==="#"||e&&
|
|
139
|
-
`){let o=this.continueScalar(n+1);if(o===-1)break;n=Math.max(n,o-2)}}else{if(e&&
|
|
138
|
+
`,i=this.buffer[n+1]):t=n),i==="#"||e&&zn.has(i))break;if(s===`
|
|
139
|
+
`){let o=this.continueScalar(n+1);if(o===-1)break;n=Math.max(n,o-2)}}else{if(e&&zn.has(s))break;t=n}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield mr.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 n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.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(Jo))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,t=this.charAt(1);if(ne(t)||e&&zn.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(;!ne(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(Ab.has(t))t=this.buffer[++e];else if(t==="%"&&cf.has(this.buffer[e+1])&&cf.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===`
|
|
140
140
|
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
141
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===" "||e&&n===" ");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,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};lf.Lexer=
|
|
141
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===" "||e&&n===" ");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,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};lf.Lexer=Ko});var Ho=x(uf=>{"use strict";var Vo=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let i=t+n>>1;this.lineStarts[i]<e?t=i+1:n=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}}}};uf.LineCounter=Vo});var Go=x(mf=>{"use strict";var Ob=zr("process"),ff=Gn(),Pb=Wo();function _e(r,e){for(let t=0;t<r.length;++t)if(r[t].type===e)return!0;return!1}function df(r){for(let e=0;e<r.length;++e)switch(r[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function hf(r){switch(r?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Qn(r){switch(r.type){case"document":return r.start;case"block-map":{let e=r.items[r.items.length-1];return e.sep??e.start}case"block-seq":return r.items[r.items.length-1].start;default:return[]}}function vt(r){if(r.length===0)return[];let e=r.length;e:for(;--e>=0;)switch(r[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;r[++e]?.type==="space";);return r.splice(e,r.length)}function pf(r){if(r.start.type==="flow-seq-start")for(let e of r.items)e.sep&&!e.value&&!_e(e.start,"explicit-key-ind")&&!_e(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,hf(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 Yo=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 Pb.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,Ob.env.LOG_TOKENS&&console.log("|",ff.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=ff.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 n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,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 n=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in n?n.indent:0:t.type==="flow-collection"&&n.type==="document"&&(t.indent=0),t.type==="flow-collection"&&pf(t),n.type){case"document":n.value=t;break;case"block-scalar":n.props.push(t);break;case"block-map":{let s=n.items[n.items.length-1];if(s.value){n.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=n.items[n.items.length-1];s.value?n.items.push({start:[],value:t}):s.value=t;break}case"flow-collection":{let s=n.items[n.items.length-1];!s||s.value?n.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((n.type==="document"||n.type==="block-map"||n.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&&df(s.start)===-1&&(t.indent===0||s.start.every(i=>i.type!=="comment"||i.indent<t.indent))&&(n.type==="document"?n.end=s.start:n.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":{df(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=Qn(this.peek(2)),n=vt(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:n,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(`
|
|
142
142
|
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
143
|
-
`,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 n="end"in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.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 n=!this.onKeyLine&&this.indent===e.indent,s=n&&(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(_e(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(hf(t.key)&&!_e(t.sep,"newline")){let o=vt(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(_e(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=vt(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]}):_e(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&&!_e(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 n&&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 n="end"in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.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||_e(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.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 n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let s=
|
|
143
|
+
`,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 n="end"in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.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 n=!this.onKeyLine&&this.indent===e.indent,s=n&&(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(_e(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(hf(t.key)&&!_e(t.sep,"newline")){let o=vt(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(_e(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=vt(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]}):_e(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&&!_e(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 n&&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 n="end"in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.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||_e(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.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 n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let s=Qn(n),i=vt(s);pf(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(`
|
|
144
144
|
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
145
|
-
`,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=
|
|
145
|
+
`,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=Qn(e),n=vt(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Qn(e),n=vt(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(n=>n.type==="newline"||n.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())}}};mf.Parser=Yo});var vf=x(yr=>{"use strict";var gf=$o(),Rb=cr(),gr=fr(),Nb=_i(),Cb=P(),_b=Ho(),yf=Go();function bf(r){let e=r.prettyErrors!==!1;return{lineCounter:r.lineCounter||e&&new _b.LineCounter||null,prettyErrors:e}}function Ib(r,e={}){let{lineCounter:t,prettyErrors:n}=bf(e),s=new yf.Parser(t?.addNewLine),i=new gf.Composer(e),o=Array.from(i.compose(s.parse(r)));if(n&&t)for(let a of o)a.errors.forEach(gr.prettifyError(r,t)),a.warnings.forEach(gr.prettifyError(r,t));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function wf(r,e={}){let{lineCounter:t,prettyErrors:n}=bf(e),s=new yf.Parser(t?.addNewLine),i=new gf.Composer(e),o=null;for(let a of i.compose(s.parse(r),!0,r.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new gr.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&t&&(o.errors.forEach(gr.prettifyError(r,t)),o.warnings.forEach(gr.prettifyError(r,t))),o}function Lb(r,e,t){let n;typeof e=="function"?n=e:t===void 0&&e&&typeof e=="object"&&(t=e);let s=wf(r,t);if(!s)return null;if(s.warnings.forEach(i=>Nb.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:n},t))}function $b(r,e,t){let n=null;if(typeof e=="function"||Array.isArray(e)?n=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(r===void 0){let{keepUndefined:s}=t??e??{};if(!s)return}return Cb.isDocument(r)&&!n?r.toString(t):new Rb.Document(r,n,t).toString(t)}yr.parse=Lb;yr.parseAllDocuments=Ib;yr.parseDocument=wf;yr.stringify=$b});var kf=x(R=>{"use strict";var Mb=$o(),Db=cr(),Bb=mo(),zo=fr(),jb=Wt(),Ie=P(),qb=Pe(),Fb=I(),Ub=Ne(),Jb=Ce(),Kb=Gn(),Wb=Wo(),Vb=Ho(),Hb=Go(),Xn=vf(),Sf=Ft();R.Composer=Mb.Composer;R.Document=Db.Document;R.Schema=Bb.Schema;R.YAMLError=zo.YAMLError;R.YAMLParseError=zo.YAMLParseError;R.YAMLWarning=zo.YAMLWarning;R.Alias=jb.Alias;R.isAlias=Ie.isAlias;R.isCollection=Ie.isCollection;R.isDocument=Ie.isDocument;R.isMap=Ie.isMap;R.isNode=Ie.isNode;R.isPair=Ie.isPair;R.isScalar=Ie.isScalar;R.isSeq=Ie.isSeq;R.Pair=qb.Pair;R.Scalar=Fb.Scalar;R.YAMLMap=Ub.YAMLMap;R.YAMLSeq=Jb.YAMLSeq;R.CST=Kb;R.Lexer=Wb.Lexer;R.LineCounter=Vb.LineCounter;R.Parser=Hb.Parser;R.parse=Xn.parse;R.parseAllDocuments=Xn.parseAllDocuments;R.parseDocument=Xn.parseDocument;R.stringify=Xn.stringify;R.visit=Sf.visit;R.visitAsync=Sf.visitAsync});function Gb(r){try{return JSON.parse(r.trim()),!0}catch{return!1}}function zb(r){let e=r.trim();if(!e.startsWith("<"))return!1;let t=e.match(Yb);return t?qt(e,t[1])!==null:!1}function Qb(r){let e=r.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let t=xf.parse(e);return t!==null&&typeof t=="object"}catch{return!1}}function Ef(r){return Gb(r)||zb(r)||Qb(r)}var xf,Yb,Qo=O(()=>{Ic();xf=oh(kf(),1),Yb=/<([a-zA-Z_][\w.-]*)/});function Xb(r){if(!r?.trim())return[];let e=r.replace(/\r\n/g,`
|
|
146
146
|
`),t=e.trim();if(Ef(t))return[{text:t,startLine:1,endLine:e.split(`
|
|
147
147
|
`).length}];let n=e.split(`
|
|
148
148
|
`),s=[],i=0,o=-1,a=0,c=()=>{if(o>=i){let l=n.slice(i,o+1).join(`
|
|
149
|
-
`).trim();l&&s.push({text:l,startLine:i+1,endLine:o+1})}};for(let l=0;l<n.length;l++)n[l].trim()?(a>=2&&o>=i&&(c(),i=l),a=0,o=l):a++;return c(),s}function
|
|
150
|
-
`),n=[];if(t.forEach((o,a)=>{let c=
|
|
151
|
-
`)}function xa(r){try{return process.kill(r,0),!0}catch(e){return e.code==="EPERM"}}async function
|
|
152
|
-
`)}var Lt,
|
|
153
|
-
\u2026[${r.length-Fa} more characters truncated]`:r}function Ua(r){return typeof r=="string"?
|
|
154
|
-
`):r==null?"":
|
|
155
|
-
`))>=0;){let c=r.partial.slice(0,s);if(r.partial=r.partial.slice(s+1),!c.trim())continue;let l;try{l=JSON.parse(c)}catch{continue}l&&l.uuid&&(r.entries.set(l.uuid,l),!l.isSidechain&&(l.type==="user"||l.type==="assistant")&&(n=l.uuid))}if(!n)return;let i=[],o=r.entries.get(n),a=!1;for(;o;){if(i.push(o),o.uuid===r.chainLastUuid){a=!0;break}o=o.parentUuid?r.entries.get(o.parentUuid):void 0}if(a)for(let c=i.length-2;c>=0;c--)
|
|
156
|
-
`),c=i.filter(f=>f.type==="tool_use").map(f=>({id:f.id??"",name:f.name??"",input:f.input??{}}));if(o||a||c.length){let f=Date.parse(r.timestamp??""),u=!isNaN(f)&&f>=n.sessionStartMs;e.push({type:"assistant",text:o,thinking:a,tools:c,live:u})}if(!t)return;r.message?.model&&(n.latestModel=r.message.model);let l=r.message?.usage??r.usage;l&&(n.latest={in:l.input_tokens??0,out:l.output_tokens??0,cached:l.cache_read_input_tokens??0,cacheCreate:l.cache_creation_input_tokens??0},e.push({type:"usage",...n.latest}))}}async function
|
|
149
|
+
`).trim();l&&s.push({text:l,startLine:i+1,endLine:o+1})}};for(let l=0;l<n.length;l++)n[l].trim()?(a>=2&&o>=i&&(c(),i=l),a=0,o=l):a++;return c(),s}function Xo(r){return Xb(r).map(e=>e.text)}var Af=O(()=>{Qo()});var Zn=O(()=>{Zr();xc();Ec();Tc();Qo();Af();en()});function es(r){return{...kc(r),server:r.files.get("server.ts")??""}}var Zo=O(()=>{Zn();Zn();Zn()});import{realpathSync as Jw}from"fs";import{join as ma,resolve as Kw}from"path";import{homedir as Ww}from"os";function bs(){let r=process.env.TYPEBULB_SERVERS_DIR;return r?ma(r,".."):ma(Ww(),".typebulb")}function we(){return process.env.TYPEBULB_SERVERS_DIR||ma(bs(),"servers")}function L(r){let e=Kw(r),t=e;try{t=Jw.native(e)}catch{}return(process.platform==="win32"?t.toLowerCase():t).replace(/\\/g,"/")}function sd(r,e){let t=L(r),n=L(e);return t.startsWith(n.endsWith("/")?n:n+"/")?!t.includes("/node_modules/"):!1}var $r=O(()=>{});import{readFileSync as Vw,writeFileSync as Hw,mkdirSync as Yw}from"fs";import{join as Gw}from"path";function id(){return Gw(bs(),"trust.json")}function ga(){try{let r=JSON.parse(Vw(id(),"utf8"));return new Set(Array.isArray(r)?r:[])}catch{return new Set}}function zw(r){Yw(bs(),{recursive:!0}),Hw(id(),JSON.stringify([...r]))}function Xe(r){return ga().has(L(r))}function Pt(r,e){let t=ga(),n=L(r);(e?t.has(n):!t.has(n))||(e?t.add(n):t.delete(n),zw(t))}function ya(){return[...ga()]}var Mr=O(()=>{$r()});function Ct(r){if(r.server.trim())return"server-side code (server.ts)";let e=r.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"))return"AI (your API keys)";if(/\btb\s*\.\s*server\s*\.\s*(?!log\b)\w/.test(e)||e.includes("/__api"))return"server-side code (server.ts)"}var ks=O(()=>{});import{spawn as yd}from"child_process";import{readdir as wv,readFile as wd,writeFile as vd,unlink as Ze,mkdir as vv}from"fs/promises";import{mkdirSync as Sd,writeFileSync as xs,appendFileSync as Sv,readFileSync as wa}from"fs";import*as te from"path";import{fileURLToPath as kv}from"url";function va(r){return te.join(we(),`${r}.json`)}function _t(r){return te.join(we(),`${r}.log`)}function Es(r){return te.join(we(),`${r}.wait.json`)}function kd(r){try{let e=JSON.parse(wa(Es(r),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:typeof e.offset=="number"?{"":e.offset}:{}}catch{return{}}}function Sa(r,e=""){let t=kd(r)[e];return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0}function As(r,e,t=""){try{Sd(we(),{recursive:!0});let n=kd(r);n[t]=e,xs(Es(r),JSON.stringify({cursors:n}))}catch{}}function Ts(r){let e=_t(r);try{Sd(we(),{recursive:!0}),xs(e,"")}catch{return()=>{}}let t=process.stdout.write.bind(process.stdout),n=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(Sv(e,c),s+=c.length,s>2*bd){let l=wa(e),f=l.subarray(Math.max(0,l.length-bd));xs(e,f),s=f.length}}catch{i=!0}};return process.stdout.write=((a,...c)=>(o(a),t(a,...c))),process.stderr.write=((a,...c)=>(o(a),n(a,...c))),()=>{process.stdout.write=t,process.stderr.write=n}}function xd(r){try{xs(_t(r),"")}catch{}}function de(r,e=0){try{let t=wa(_t(r)),n=e>=0&&e<=t.length?e:0;return{text:t.subarray(n).toString("utf8"),offset:t.length}}catch{return{text:"",offset:0}}}function ka(r){return`\u2500\u2500 run ${r} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function Ev(r){let e=xv.exec(r);return e?Number(e[1]):void 0}function Ed(r,e){let t=r.split(`
|
|
150
|
+
`),n=[];if(t.forEach((o,a)=>{let c=Ev(o);c!==void 0&&n.push({id:c,idx:a})}),!n.length)return e==="latest"?r:"";let s=e==="latest"?n[n.length-1]:n.find(o=>o.id===e);if(!s)return"";let i=n.find(o=>o.idx>s.idx);return t.slice(s.idx,i?i.idx:t.length).join(`
|
|
151
|
+
`)}function xa(r){try{return process.kill(r,0),!0}catch(e){return e.code==="EPERM"}}async function Os(r){await vv(we(),{recursive:!0}),await vd(va(r.pid),JSON.stringify(r))}async function Ad(r,e){let t=va(r);try{let n=JSON.parse(await wd(t,"utf8"));if(n.denied===e)return;n.denied=e,await vd(t,JSON.stringify(n))}catch{}}async function jr(r){await Ze(va(r)).catch(()=>{}),await Ze(_t(r)).catch(()=>{}),await Ze(Es(r)).catch(()=>{})}async function $(r){let e;try{e=await wv(we())}catch{return[]}let t=[];return await Promise.all(e.map(async s=>{if(!/^\d+\.json$/.test(s))return;let i=te.join(we(),s),o;try{o=JSON.parse(await wd(i,"utf8"))}catch{await Ze(i).catch(()=>{});return}o&&typeof o.pid=="number"&&xa(o.pid)?t.push(o):(await Ze(i).catch(()=>{}),o?.pid&&(await Ze(_t(o.pid)).catch(()=>{}),await Ze(Es(o.pid)).catch(()=>{})))})),(r?t.filter(s=>s.agent==null&&sd(s.file,r)):t).sort((s,i)=>s.startedAt-i.startedAt)}async function Ea(r,e){let t=L(r);return(await $()).find(n=>n.cwd!=null&&L(n.cwd)===t&&(e?n.agent===e:n.agent!=null))}async function et(r){try{process.kill(r,"SIGTERM")}catch{}await jr(r)}function Ps(r,e){let t=L(e);return r.filter(n=>n.agent==null&&n.pid!==process.pid&&L(n.file)===t)}async function Aa(r){let e=Ps(await $(),r);for(let t of e)await et(t.pid);return e}function Tv(r,e,t){(process.platform==="win32"?yd("cmd",["/c","start","","/b",r,...e],{cwd:t,stdio:"ignore",windowsHide:!0}):yd(r,e,{cwd:t,detached:!0,stdio:"ignore"})).unref()}function Td(){return te.join(te.dirname(kv(import.meta.url)),"index.js")}function Ov(r,e={}){return{command:process.execPath,args:[Td(),...e.trust?["--trust"]:[],r,...e.open===!1?["--no-open"]:[]]}}function Pv(r){return{command:process.execPath,args:[Td(),`agent:${r}`,"--no-open"]}}async function Od(r,e,t,n){let s=await r();if(s)return s;Tv(e.command,e.args,t);let i=Date.now()+2e4;for(;Date.now()<i;){await Av(150);let o=await r();if(o)return o}throw new Error(`Launched ${n} but it did not register within 20s.`)}async function Rs(r,e={}){let t=e.cwd??process.cwd(),n=te.resolve(t,r);return await Aa(n),Od(async()=>Ps(await $(),n)[0],Ov(r,e),t,te.basename(r))}async function Pd(r,e=process.cwd()){return Od(()=>Ea(e,r),Pv(r),e,`the ${r} mirror`)}var bd,xv,Av,pe=O(()=>{$r();bd=1e6;xv=/^── run (\d+) ── /;Av=r=>new Promise(e=>setTimeout(e,r))});function Oa(r){return(r.includes("://")?r:`http://${r}`).replace(/\/+$/,"")}async function rt(){let[r,e]=await Promise.all([Jv(),Uv()]);return[...Kv(e),...r]}async function Uv(){if(It&&Date.now()-It.fetchedAt<=qv)return It.models;let r=await fetch(jv).catch(()=>null);return!r||!r.ok?It?.models??[]:(It={models:await r.json(),fetchedAt:Date.now()},It.models)}async function Jv(){if(Cs&&Date.now()-Cs.fetchedAt<=Fv)return Cs.models;let r=Oa(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let t=await fetch(new URL("/api/tags",r).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 Cs={models:e,fetchedAt:Date.now()},e}function Kv(r){let e=new Set(Object.entries(Lt).filter(([,t])=>!!process.env[t]).map(([t])=>t));return r.filter(t=>e.has(t.provider))}function _d(){return Object.values(Lt).some(r=>!!process.env[r])}function Id(r,e,t){let n=Math.max(...r.map(o=>o.name.length)),s=Math.max(...r.map(o=>o.friendlyName.length)),i=["Models available to tb.ai (filtered by your .env keys):",""];for(let o of r)i.push(` ${o.name.padEnd(n)} ${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(`
|
|
152
|
+
`)}var Lt,jv,qv,Fv,It,Cs,_s=O(()=>{Lt={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};jv="https://api.typebulb.com/api/models",qv=1440*60*1e3,Fv=60*1e3,It=null,Cs=null});function ce(r){return r?.message??String(r)}var B,Vs=O(()=>{B=process.cwd()});var Hs,rp=O(()=>{Hs=class{#e=new Map;accept(e,t){return this.#e.get(e)===t?!1:(this.#e.set(e,t),!0)}}});import{existsSync as Ys,openSync as lp,readSync as up,closeSync as fp,statSync as ot,readdirSync as Gs,watchFile as fS,unwatchFile as np,mkdirSync as dS,writeFileSync as pS,readFileSync as zs,unlinkSync as hS,rmSync as mS}from"fs";import{join as z}from"path";import{homedir as dp}from"os";function gS(r){return r.replace(/[^a-zA-Z0-9]/g,"-")}function Ka(r){let e=Ja(r);if(!Ys(e))return[];let t;try{t=Gs(e)}catch{return[]}let n=[];for(let s of t){if(!s.endsWith(".jsonl"))continue;let i=z(e,s);try{let o=ot(i);o.isFile()&&n.push({sessionId:s.slice(0,-6),file:i,mtime:o.mtimeMs})}catch{}}return n}function Qs(r){return z(r,wS)}function hp(r,e){return z(Qs(r),`${e}.lock`)}function SS(r,e){try{let t=hp(r,e);if(Date.now()-ot(t).mtimeMs>=pp)return!1;try{if(parseInt(zs(t,"utf8").trim(),10)===process.pid)return!1}catch{}return!0}catch{return!1}}function mp(r,e){if(e)try{dS(Qs(r),{recursive:!0}),pS(hp(r,e),String(process.pid))}catch(t){console.error("[lock] claim failed:",ce(t))}}function kS(r){try{mS(z(r,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function xS(r){let e=Qs(r);if(!Ys(e))return;let t;try{t=Gs(e)}catch{return}let n=Date.now();for(let s of t){if(!s.endsWith(".lock"))continue;let i=z(e,s);try{let o=ot(i);n-o.mtimeMs>vS&&hS(i)}catch{}}}function Wa(r){let e=r?.type==="image"?r.source:void 0;return e?.type==="base64"&&e.data?``:""}function Jr(r){return r.length>Fa?r.slice(0,Fa)+`
|
|
153
|
+
\u2026[${r.length-Fa} more characters truncated]`:r}function Ua(r){return typeof r=="string"?Jr(r):Array.isArray(r)?r.map(e=>{if(typeof e=="string")return Jr(e);let t=e;return typeof t?.text=="string"?Jr(t.text):t?.content!=null?Ua(t.content):Wa(t)}).join(`
|
|
154
|
+
`):r==null?"":Jr(JSON.stringify(r))}function gp(r){try{return ot(r),!1}catch(e){return e.code==="ENOENT"}}function yp(){let r=Q;if(r.file&&!gp(r.file)){mp(r.cwd,r.sessionId);return}let e=ES(r);e&&bp(e)}function ES(r){if(!r.everAttached)return AS(r.cwd)??TS(r.cwd,()=>!0)}function AS(r){let e=Qs(r);if(!Ys(e))return;let t;try{t=Gs(e)}catch{return}let n;for(let i of t)if(i.endsWith(".lock"))try{let o=ot(z(e,i));if(Date.now()-o.mtimeMs>=pp||parseInt(zs(z(e,i),"utf8").trim(),10)!==process.pid)continue;(!n||o.mtimeMs>n.mtime)&&(n={sessionId:i.slice(0,-5),mtime:o.mtimeMs})}catch{}if(!n)return;let s=z(Ja(r),`${n.sessionId}.jsonl`);if(!gp(s))return{sessionId:n.sessionId,file:s,mtime:n.mtime}}function TS(r,e){return Ka(r).sort((t,n)=>n.mtime-t.mtime).find(t=>!SS(r,t.sessionId)&&e(t))}function bp(r){let e=Q;if(e.file)try{np(e.file)}catch{}e.file=r.file,e.sessionId=r.sessionId,e.everAttached=!0,e.partial="",e.offset=0,e.latest={in:0,out:0,cached:0,cacheCreate:0},e.latestModel=null,e.entries=new Map,e.chainLastUuid=void 0,e.buffer.push({type:"cleared"}),e.buffer.push({type:"session",sessionId:r.sessionId}),mp(e.cwd,r.sessionId),sp();try{np(r.file)}catch{}fS(r.file,{interval:200},()=>sp())}function sp(){let r=Q;if(!r.file)return;let e;try{e=ot(r.file).size}catch{return}if(e<=r.offset)return;let t;try{t=lp(r.file,"r")}catch{return}try{let c=e-r.offset,l=Buffer.alloc(c),f=0;for(;f<c;){let u=up(t,l,f,c-f,r.offset+f);if(!u)break;f+=u}r.offset+=f,r.partial+=l.subarray(0,f).toString("utf8")}finally{fp(t)}let n,s;for(;(s=r.partial.indexOf(`
|
|
155
|
+
`))>=0;){let c=r.partial.slice(0,s);if(r.partial=r.partial.slice(s+1),!c.trim())continue;let l;try{l=JSON.parse(c)}catch{continue}l&&l.uuid&&(r.entries.set(l.uuid,l),!l.isSidechain&&(l.type==="user"||l.type==="assistant")&&(n=l.uuid))}if(!n)return;let i=[],o=r.entries.get(n),a=!1;for(;o;){if(i.push(o),o.uuid===r.chainLastUuid){a=!0;break}o=o.parentUuid?r.entries.get(o.parentUuid):void 0}if(a)for(let c=i.length-2;c>=0;c--)ip(i[c]);else{r.chainLastUuid!==void 0&&(r.buffer.push({type:"cleared"}),r.buffer.push({type:"session",sessionId:r.sessionId}),r.latest={in:0,out:0,cached:0,cacheCreate:0});let c=new Set(i.map(f=>f.uuid)),l=OS(r.entries);for(let f=i.length-1;f>=0;f--)ip(i[f]),PS(i[f].uuid,l,c)}r.chainLastUuid=n}function OS(r){let e=new Map;for(let t of r.values()){if(!t.parentUuid)continue;let n=e.get(t.parentUuid);n?n.push(t):e.set(t.parentUuid,[t])}return e}function PS(r,e,t){let n=e.get(r);if(!n)return;let s=n.filter(c=>!c.isSidechain);if(s.length<2)return;let i=s.filter(c=>!t.has(c.uuid));if(!i.length)return;let o=[],a=0;for(let c of i){let l=RS(c,e);o.push(...l.events),a+=l.count}a>0&&Q.buffer.push({type:"fork",atUuid:r,count:a,events:o})}function RS(r,e){let t=[],n=[r];for(;n.length;){let o=n.pop();if(o.isSidechain)continue;t.push(o);let a=e.get(o.uuid);if(a)for(let c of a)n.push(c)}t.sort((o,a)=>(Date.parse(o.timestamp??"")||0)-(Date.parse(a.timestamp??"")||0));let s=[];for(let o of t)o.isApiErrorMessage||vp(o,s,!1);return{count:s.reduce((o,a)=>o+(a.type==="user"||a.type==="assistant"?1:0),0),events:s}}function NS(r){let e=r.trim();return!!e&&wp.some(t=>t.test(e))}function CS(r){let e=r.trim();return e?wp.some(t=>{let n=t.exec(e);return!!n&&n.index===0}):!0}function IS(r){return r.replace(_S,"")}function LS(r){let e=/^<command-name>([\s\S]*?)<\/command-name>/.exec(r)?.[1]?.trim();if(!e)return;let t=/<command-args>([\s\S]*?)<\/command-args>/.exec(r)?.[1]?.trim();return t?`${e} ${t}`:e}function it(r){let e=IS(r).trim();return e?LS(e)??(NS(e)?"":e):""}function Va(r){return r?.type==="text"&&typeof r.text=="string"?it(r.text):""}function Xs(r){return!!r.isSidechain||!!r.isMeta}function ip(r){try{vp(r)}catch(e){console.error("[mirror] skipped malformed entry:",ce(e))}}function vp(r,e=Q.buffer,t=!0){if(Xs(r))return;let n=Q;if(r.type==="user"){let s=r.message?.content;if(typeof s=="string"){let i=it(s);i&&e.push({type:"user",text:i})}else if(Array.isArray(s))for(let i of s)if(i?.type==="tool_result")e.push({type:"tool_result",id:i.tool_use_id??"",content:Ua(i.content),isError:!!i.is_error});else{let o=Va(i)||Wa(i);o&&e.push({type:"user",text:o})}}else if(r.type==="attachment"&&r.attachment?.type==="queued_command"){let s=it(Ua(r.attachment.prompt));s&&e.push({type:"user",text:s})}else if(r.type==="assistant"){let s=r.message?.content,i=Array.isArray(s)?s:[],o=i.filter(f=>f.type==="text").map(f=>f.text??"").filter(f=>!CS(f)).join(""),a=i.filter(f=>f.type==="thinking").map(f=>f.thinking??"").join(`
|
|
156
|
+
`),c=i.filter(f=>f.type==="tool_use").map(f=>({id:f.id??"",name:f.name??"",input:f.input??{}}));if(o||a||c.length){let f=Date.parse(r.timestamp??""),u=!isNaN(f)&&f>=n.sessionStartMs;e.push({type:"assistant",text:o,thinking:a,tools:c,live:u})}if(!t)return;r.message?.model&&(n.latestModel=r.message.model);let l=r.message?.usage??r.usage;l&&(n.latest={in:l.input_tokens??0,out:l.output_tokens??0,cached:l.cache_read_input_tokens??0,cacheCreate:l.cache_creation_input_tokens??0},e.push({type:"usage",...n.latest}))}}async function $S(){return{cwd:Q.cwd,pid:process.pid}}async function MS(r){let e=Q;return yp(),{events:e.buffer.slice(r),cursor:e.buffer.length,working:jS(e)&&qS(e.sessionId),latestModel:e.latestModel}}async function BS(r,e){DS.accept(r,e)&&console.log(e)}function jS(r){let e;for(let i of r.entries.values())(i.type==="user"||i.type==="assistant")&&(e=i);if(!e)return!1;if(e.type==="user"){try{let i=e.message?.content,o=typeof i=="string"?i:Array.isArray(i)?i.filter(c=>c&&c.type==="text").map(c=>c.text??"").join(""):"";if(!(Array.isArray(i)&&i.some(c=>c&&c.type==="tool_result"))&&o.trim()&&it(o)==="")return!1}catch{}return!0}let n=(Array.isArray(e.message?.content)?e.message.content:[]).filter(i=>i.type==="tool_use").map(i=>i.id);if(n.length===0)return!1;let s=new Set;for(let i of r.entries.values()){let o=i.message?.content;if(Array.isArray(o))for(let a of o)a.type==="tool_result"&&a.tool_use_id&&s.add(a.tool_use_id)}return n.some(i=>i&&!s.has(i))}function qS(r){let e;try{e=Gs(op)}catch{return!1}for(let t of e)if(t.endsWith(".json"))try{let n=JSON.parse(zs(z(op,t),"utf8"));if(n?.sessionId!==r)continue;return process.kill(n.pid,0),!0}catch{}return!1}function Sp(r){let e;try{e=lp(r,"r")}catch{return""}try{let n=65536;try{n=ot(r).size}catch{}let s=(l,f)=>{if(f<=0)return"";let u=Buffer.alloc(f),d=up(e,u,0,f,l);return u.subarray(0,d).toString("utf8")},i=(l,f,u)=>{let d="";for(let p of l.split(`
|
|
157
157
|
`)){if(!p.includes(`"${f}"`))continue;let m;try{m=JSON.parse(p)}catch{continue}let h=m?.[u];m?.type===f&&typeof h=="string"&&h&&(d=h)}return d},o=s(0,Math.min(65536,n)),a=n>65536?s(n-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(`
|
|
158
|
-
`)){if(!l.trim())continue;let f;try{f=JSON.parse(l)}catch{continue}if(!f||
|
|
159
|
-
`)){if(!i)continue;let o;try{o=JSON.parse(i)}catch{continue}if(!o||
|
|
160
|
-
`)){let l=c.replace(/\s+/g," ").trim();l&&i.push({text:l,lower:l.toLowerCase()})}let{hitCount:o,snippet:a}=
|
|
161
|
-
`)}function
|
|
158
|
+
`)){if(!l.trim())continue;let f;try{f=JSON.parse(l)}catch{continue}if(!f||Xs(f)||f.type!=="user")continue;let u=f.message?.content,d="";typeof u=="string"?d=it(u):Array.isArray(u)&&(d=u.map(Va).filter(Boolean).join(" "));let p=d.replace(/\s+/g," ").trim();if(p)return(p.replace(/^Continuing from a prior session\. Here is the summary of our work so far:\s*/i,"").trim()||p).slice(0,200)}return""}finally{fp(e)}}async function FS(){return Ka(Q.cwd).sort((r,e)=>e.mtime-r.mtime).map(({sessionId:r,file:e,mtime:t})=>({sessionId:r,mtime:t,preview:Sp(e)}))}function US(r,e){let t=ap.get(r);if(t&&t.mtime===e)return t.turns;let n=[],s="";try{s=zs(r,"utf8")}catch{return[]}for(let i of s.split(`
|
|
159
|
+
`)){if(!i)continue;let o;try{o=JSON.parse(i)}catch{continue}if(!o||Xs(o)||o.type!=="user"&&o.type!=="assistant")continue;let a=o.message?.content,c="";if(typeof a=="string")c=it(a);else if(Array.isArray(a)){let l=a;c=o.type==="user"?l.map(Va).filter(Boolean).join(" "):l.filter(f=>f.type==="text"&&typeof f.text=="string").map(f=>f.text).join(" ")}c=c.replace(/\s+/g," ").trim(),c&&n.push({text:c,lower:c.toLowerCase()})}return ap.set(r,{mtime:e,turns:n}),n}function Zs(r,e){let t=0,n="";for(let s of r){let i=s.lower.indexOf(e);if(!(i<0)&&(t++,!n)){let o=Math.max(0,i-cp),a=Math.min(s.text.length,i+e.length+cp);n=(o>0?"\u2026":"")+s.text.slice(o,a)+(a<s.text.length?"\u2026":"")}}return{hitCount:t,snippet:n}}async function KS(r){let e=r.toLowerCase(),t=[];for(let{sessionId:n,file:s,mtime:i}of Ka(Q.cwd).sort((o,a)=>a.mtime-o.mtime)){let{hitCount:o,snippet:a}=Zs(US(s,i),e);if(o&&(t.push({sessionId:n,mtime:i,preview:Sp(s),hitCount:o,snippet:a}),t.length>=JS))break}return t}async function WS(r){let e=Q,t=z(Ja(e.cwd),`${r}.jsonl`);return Ys(t)?t===e.file?{ok:!0}:(bp({sessionId:r,file:t}),{ok:!0}):{ok:!1,error:"session not found"}}var yS,bS,Ja,wS,pp,vS,Fa,Q,wp,_S,DS,op,ap,JS,cp,Ha=O(()=>{Vs();rp();yS=".typebulb",bS=z(dp(),".claude","projects"),Ja=r=>z(bS,gS(r));wS=`${yS}/locks`,pp=5e3,vS=6e4;Fa=5e4;Q={cwd:B,sessionId:"",sessionStartMs:Date.now(),buffer:[],partial:"",offset:0,latest:{in:0,out:0,cached:0,cacheCreate:0},latestModel:null,everAttached:!1,entries:new Map};wp=[/\[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];_S=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;DS=new Hs;op=z(dp(),".claude","sessions");ap=new Map;JS=50,cp=110;kS(Q.cwd);xS(Q.cwd);yp()});function ei(r){let e=/^---[^\n]*\n([\s\S]*?)\n---/.exec(r),t=e?/^\s*name:\s*(.+?)\s*$/m.exec(e[1]):null;return t?t[1].replace(/^["']|["']$/g,""):void 0}function Ya(r){return(ei(r)??"bulb").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"bulb"}var Ga=O(()=>{});import{readdirSync as VS,readFileSync as HS,statSync as YS}from"fs";import{join as kp,basename as GS}from"path";function xp(r,e,t){if(e>8)return t;let n;try{n=VS(r,{withFileTypes:!0})}catch{return t}for(let s of n)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;xp(kp(r,s.name),e+1,t)}else s.isFile()&&s.name.endsWith(".bulb.md")&&t.push(kp(r,s.name));return t}function ti(r){return xp(r,0,[]).map(e=>{let t=0;try{t=YS(e).mtimeMs}catch{}let n;try{n=ei(HS(e,"utf8").slice(0,1024))}catch{}return{path:e,name:n??GS(e).replace(/\.bulb\.md$/,""),mtime:t}})}var Ep=O(()=>{Ga()});import{readFile as zS}from"fs/promises";async function za(r){try{let e=Bt(await zS(r,"utf-8"));return e?Ct(es(e)):void 0}catch{return}}var Ap=O(()=>{Zo();ks()});import{spawn as Tp}from"child_process";import{basename as QS}from"path";function XS(){return process.env.TYPEBULB_EDITOR||"code"}function ek(r,e,t){return t==null?[e]:ZS.test(QS(r))?["-g",`${e}:${t}`]:[`+${t}`,e]}function tk(r,e){let t=XS();return{command:t,args:ek(t,r,e)}}function Qa(r,e){let{command:t,args:n}=tk(r,e),s=process.platform==="win32"?Tp("cmd.exe",["/d","/s","/c",t,...n],{detached:!0,stdio:"ignore",windowsHide:!0}):Tp(t,n,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var ZS,Op=O(()=>{ZS=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});var Xa=O(()=>{pe();Ep();Ap();Ga();Op();Mr();_s()});import{existsSync as Za,mkdirSync as rk,readFileSync as Pp,writeFileSync as nk}from"fs";import{join as Mt,isAbsolute as sk}from"path";async function ik(r,e){let t=sk(r)?r:Mt(B,r);return Za(t)?(Qa(t,e),{ok:!0}):{ok:!1,error:"file not found"}}async function ok(r){let e=B,t=Mt(e,"typebulbs");rk(t,{recursive:!0});let n=Ya(r),s=`${n}.bulb.md`;for(let c=2;Za(Mt(t,s))&&Pp(Mt(t,s),"utf8")!==r;c++)s=`${n}-${c}.bulb.md`;let i=Mt(t,s);Za(i)||nk(i,r);let o=Mt("typebulbs",s),a=await Rs(o,{cwd:e,open:!1});return{ok:!0,file:o,pid:a.pid,url:a.url}}async function ak(){return $(B)}async function ck(r){return await et(r),{ok:!0}}async function lk(){return ti(B).map(r=>({...r,trusted:Xe(r.path)}))}async function uk(r){let e=r.toLowerCase(),t=[];for(let n of ti(B).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Pp(n.path,"utf8")}catch{continue}let i=[];for(let c of s.split(`
|
|
160
|
+
`)){let l=c.replace(/\s+/g," ").trim();l&&i.push({text:l,lower:l.toLowerCase()})}let{hitCount:o,snippet:a}=Zs(i,e);o&&t.push({path:n.path,hitCount:o,snippet:a})}return t}async function fk(r,e){let t=B;e!=null&&Pt(r,e);let n=await Rs(r,{cwd:t,open:!1,trust:e});return{ok:!0,file:n.file,pid:n.pid,url:n.url,trust:!!n.trust}}async function dk(r){return{cap:await za(r)}}async function pk(r,e){return Pt(r,e),{ok:!0}}async function hk(r,e){return de(r,e)}var Rp=O(()=>{Xa();Vs();Ha()});import{readFileSync as rc,writeFileSync as Cp,mkdirSync as mk,appendFileSync as _p,rmSync as Np}from"fs";import{join as si,dirname as gk}from"path";import{createServer as yk}from"http";function qe(r){try{return JSON.parse(rc(r,"utf8"))}catch{return null}}function ni(r,e){mk(gk(r),{recursive:!0}),Cp(r,JSON.stringify(e,null,2)+`
|
|
161
|
+
`)}function Lp(r,e,t){let n=si(r,".gitignore"),s="";try{s=rc(n,"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(`
|
|
162
162
|
`)?`
|
|
163
|
-
`:"";try{
|
|
163
|
+
`:"";try{_p(n,a+t+`
|
|
164
164
|
`+o.join(`
|
|
165
165
|
`)+`
|
|
166
|
-
`)}catch(c){console.error("[switcher] .gitignore update failed",ce(c))}}function
|
|
166
|
+
`)}catch(c){console.error("[switcher] .gitignore update failed",ce(c))}}function kk(r){let e=i=>{let o=i.exec(r);return o?Number(o[1]):0},t=e(/"cache_read_input_tokens":\s*(\d+)/),n=e(/"cache_creation_input_tokens":\s*(\d+)/),s=e(/"input_tokens":\s*(\d+)/);t>0||n>0?Vr="live":s>Sk&&(Vr="uncached")}function Mp(r,e){let t={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":r.headers["anthropic-version"]||"2023-06-01"},n=r.headers["anthropic-beta"];return typeof n=="string"&&(t["anthropic-beta"]=n),t}function xk(r){if(Array.isArray(r?.messages))for(let e of r.messages){if(!Array.isArray(e?.content))continue;let t=e.content.filter(n=>n?.type!=="thinking"&&n?.type!=="redacted_thinking");t.length&&t.length!==e.content.length&&(e.content=t)}}function Dp(r){let e;try{e=JSON.parse(r)}catch{return r}Wr=typeof e?.model=="string"?e.model:null,me&&(e.model=me),ct&&(e.provider=$p(ct));let t=/haiku/i.test(Wr||"");return Hr!=null&&!t&&(e.reasoning={effort:ec[Hr]}),delete e.thinking,e.output_config&&delete e.output_config.effort,xk(e),JSON.stringify(e)}function Ek(){let r="",e=0,t=new Map,n=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(n.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}
|
|
167
167
|
data: ${JSON.stringify(a)}
|
|
168
168
|
|
|
169
169
|
`}case"content_block_delta":case"content_block_stop":{let c=t.get(a.index);return c==null?null:(a.index=c,`event: ${a.type}
|
|
@@ -171,10 +171,10 @@ data: ${JSON.stringify(a)}
|
|
|
171
171
|
|
|
172
172
|
`)}default:return i}};return i=>{r+=i;let o="",a;for(;(a=r.indexOf(`
|
|
173
173
|
|
|
174
|
-
`))!==-1;){let c=r.slice(0,a);if(r=r.slice(a+2),!c.trim())continue;let l=s(c);l!==null&&(o+=l)}return o}}function
|
|
174
|
+
`))!==-1;){let c=r.slice(0,a);if(r=r.slice(a+2),!c.trim())continue;let l=s(c);l!==null&&(o+=l)}return o}}function Ak(r){return new Promise(e=>{let t=[];r.on("data",n=>t.push(n)),r.on("end",()=>e(Buffer.concat(t).toString("utf8"))),r.on("error",()=>e(Buffer.concat(t).toString("utf8")))})}function Kr(r,e,t,n){r.writableEnded||(r.writeHead(e,{"content-type":"application/json"}),r.end(JSON.stringify({type:"error",error:{type:t,message:n}})))}async function Tk(r,e,t){if(!me){Kr(e,400,"invalid_request_error",vk);return}let n=process.env.OPENROUTER_API_KEY;if(!n){Kr(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(nc,{method:"POST",headers:Mp(r,n),body:Dp(t),signal:s.signal})}catch(u){Kr(e,502,"api_error",`proxy upstream failed: ${ce(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,f=a?Ek():null;try{for(;;){let{done:u,value:d}=await c.read();if(u)break;if(d)if(f){let p=l.decode(d,{stream:!0});kk(p);let m=f(p);m&&e.write(m)}else e.write(Buffer.from(d))}}catch{}finally{e.writableEnded||e.end()}}async function Ok(r,e,t){let n=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(!me||!n)return s();try{let i=await fetch(`${nc}/count_tokens`,{method:"POST",headers:Mp(r,n),body:Dp(t)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function Pk(r,e){let t=r.url||"/";if(r.method==="HEAD"){e.writeHead(200),e.end();return}if(r.method!=="POST"){Kr(e,404,"not_found_error",t);return}Ak(r).then(n=>{if(t.includes("count_tokens"))return Ok(r,e,n);if(t.includes("/v1/messages"))return Tk(r,e,n);Kr(e,404,"not_found_error",t)})}function Rk(){return Dt&&at?Promise.resolve(at):new Promise((r,e)=>{let t=yk(Pk);t.on("error",e),t.listen(0,"127.0.0.1",()=>{Dt=t,at=t.address().port,console.log(`[switcher] wire proxy listening on ${ri(at)}`),r(at)})})}function Nk(){try{Dt?.close()}catch{}Dt=null,at=null}function Ck(r,e){let t=ii(r),n=qe(t),s=n||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===ri(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=oi(r);if(!qe(i)){let a={};for(let c of Ip)a[c]=c in s.env?s.env[c]:null;ni(i,{managedBy:"agent-switcher",fileExisted:n!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=ri(e),s.env.ANTHROPIC_AUTH_TOKEN=wk,ni(t,s),Lp(r,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function _k(r,e,t){let n=oi(r),s=qe(n)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:t},ni(n,s)}function Bp(r){let e=ii(r),t=oi(r),n=qe(t),s=qe(e);if(s?.env){let i=n?.snapshot||{};for(let o of Ip){let a=i[o];a==null?delete s.env[o]:s.env[o]=a}if(Object.keys(s.env).length===0&&delete s.env,n?.fileExisted===!1&&Object.keys(s).length===0)try{Np(e,{force:!0})}catch{}else ni(e,s)}try{Np(t,{force:!0})}catch{}}async function Ik(){let r=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await rt()).filter(t=>t.provider==="openrouter"&&!sc(t.name)).map(t=>({id:t.name,label:t.friendlyName||t.name}))}catch(t){console.error("[switcher] model list failed",ce(t))}return{hasKey:r,models:e}}async function Lk(){if(Dt&&me)return{active:!0,managed:!0,model:me,port:at,provider:ct,routedModel:Wr,caching:Vr,reasoning:Hr,externalBaseUrl:null};let r=qe(ii(B))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:Hr,externalBaseUrl:r.ANTHROPIC_BASE_URL||null}}async function jp(r,e){let t=await Rk();return me=r,ct=e,Ck(B,t),t}async function $k({model:r}){if(!process.env.OPENROUTER_API_KEY)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!r)return{ok:!1,error:"no model given"};if(sc(r))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 jp(r,ic[r]??null),Wr=null,Vr="unknown",_k(B,r,ct)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${ce(e)}`}}return{ok:!0}}async function Mk({level:r}){return r!=null&&(!Number.isInteger(r)||r<0||r>=ec.length)?{ok:!1,error:`reasoning level must be 0\u2013${ec.length-1} or null`}:(Hr=r,{ok:!0,level:r})}async function Dk(){return Bp(B),me=null,ct=null,Wr=null,Vr="unknown",{ok:!0}}async function Bk({key:r}){let e=(r||"").trim();if(!e)return{ok:!1,error:"empty key"};let t=B,n=si(t,".env"),s="";try{s=rc(n,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))Cp(n,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
|
|
175
175
|
`)?`
|
|
176
|
-
`:"";
|
|
177
|
-
`)}}catch(i){return{ok:!1,error:ce(i)}}return process.env.OPENROUTER_API_KEY=e,Ip(t,[".env"],"# secrets"),{ok:!0}}function Ik(){if(!(!Dt&&!me)){try{Dp(B)}catch{}Ek()}}function Lk(r,e){return jp.test(e)?"blocked by your OpenRouter data policy":r===401||r===403||/unauthor|invalid api key|no auth|forbidden/i.test(e)?"auth rejected \u2014 check your OpenRouter key":r===404||/not a valid model|no such model|unknown model|model not found/i.test(e)?"model not found on this route":r===429||/rate limit/i.test(e)?"rate limited":r===402||/insufficient|credit|quota|balance/i.test(e)?"out of credits / quota":e.slice(0,160)}function $k(r){if(jp.test(r))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 Mk(r,e,t){if(!r)return{works:null,read:0,note:t?`couldn't re-test on ${t} \u2014 caching unconfirmed`:"caching unconfirmed"};let n=tc(e?.cache_read_input_tokens)||tc(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 n>0?{works:!0,read:n,note:`${n} tokens read from cache on the 2nd call`}:s?{works:!1,read:n,note:"no cache reads after a warm call \u2014 every turn re-bills the full context"}:{works:null,read:n,note:"route doesn't report cache usage \u2014 caching almost certainly not honored"}}async function Dk({model:r}){let e=process.env.OPENROUTER_API_KEY;if(!e)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!r)return{ok:!1,error:"no model given"};if(sc(r))return{ok:!1,error:"Anthropic model \u2014 not offered or probed via OpenRouter"};let t=Date.now(),n=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:r,max_tokens:8,system:[{type:"text",text:n,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 f=JSON.stringify(a?{...i,provider:Lp(a)}:i),u=await fetch(nc,{method:"POST",signal:c.signal,headers:s,body:f}),d=await u.json().catch(()=>({}));return{r:u,j:d}}finally{clearTimeout(l)}};try{let{r:a,j:c}=await o();if(!a.ok){let v=c?.error?.message||c?.message||JSON.stringify(c).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-t,error:Lk(a.status,v),restriction:$k(v)}}let l=typeof c?.provider=="string"?c.provider:void 0,f=c?.content?.find?.(v=>v.type==="text")?.text??c?.content?.[0]?.text??"ok",u=tc(c?.usage?.cache_creation_input_tokens),{r:d,j:p}=await o(l),{works:m,read:h,note:y}=Mk(d.ok,p?.usage,l);return m===!0&&l&&(ic[r]=l,me===r&&(ct=l)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-t,provider:l,sample:String(f).trim().slice(0,60),cache:{works:m,created:u,read:h,note:y}}}catch(a){let c=ce(a);return{ok:!0,callable:!1,ms:Date.now()-t,error:/abort/i.test(c)?"timed out (20s)":c}}}var dk,nc,pk,hk,_p,mk,ec,si,ii,ti,sc,Dt,at,me,ct,Kr,Wr,Vr,ic,tc,Lp,jp,qp=O(()=>{Xa();Ws();dk="https://openrouter.ai/api",nc=`${dk}/v1/messages`,pk="typebulb-proxy-managed",hk="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.",_p=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],mk=5e3,ec=["low","medium","high"],si=r=>ni(r,".claude","settings.local.json"),ii=r=>ni(r,".claude",".cc-switcher.json"),ti=r=>`http://127.0.0.1:${r}`;sc=r=>/^anthropic\//i.test(r)||/claude/i.test(r),Dt=null,at=null,me=null,ct=null,Kr=null,Wr="unknown",Vr=1,ic={},tc=r=>typeof r=="number"?r:0,Lp=r=>({order:[r],allow_fallbacks:!1});jp=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=qe(ii(B)),t=e?.active?.model;if(!t)return;let s=(qe(si(B))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await Bp(t,e.active.provider??ic[t]??null);console.log(`[switcher] re-adopted override after restart: ${t} via ${ti(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",ce(e))}})()});var Fp={};nh(Fp,{attach:()=>jS,blockToMarkdown:()=>Wa,breakout:()=>ek,capText:()=>Ur,cleanUserText:()=>it,clearSwitchModel:()=>Rk,info:()=>NS,isHiddenTurn:()=>Qs,launchBulb:()=>ik,listBreakouts:()=>tk,listBulbFiles:()=>nk,listSessions:()=>$S,listSwitchModels:()=>Ok,logEmbedStatus:()=>_S,openFile:()=>ZS,poll:()=>CS,predictTrustOf:()=>ok,probeModel:()=>Dk,readBulbLog:()=>ck,saveOpenRouterKey:()=>_k,searchBulbs:()=>sk,searchHits:()=>Xs,searchSessions:()=>BS,setBulbTrust:()=>ak,setReasoning:()=>Ck,setSwitchModel:()=>Nk,shutdownSwitcher:()=>Ik,stopBreakout:()=>rk,switchState:()=>Pk});var Up=O(()=>{Ha();Pp();qp()});import*as Qp from"fs/promises";import*as ke from"path";import*as lc from"fs/promises";import{existsSync as lt,readFileSync as oh}from"fs";import*as M from"path";import{pathToFileURL as ah}from"url";import{resolve as ci}from"resolve.exports";import{init as uc,parse as fc}from"es-module-lexer";function dc(r,e){let t=M.join(r,"package.json");try{return JSON.parse(oh(t,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${t}`)}}var ai=["browser","import","default"],cc=["node","import","default"];function pc(r){let e=r.indexOf("=");if(e===-1)throw new Error(`--replace must be <name>=<path> (got '${r}')`);let t=r.slice(0,e).trim(),n=r.slice(e+1).trim();if(!t)throw new Error(`--replace missing package name (got '${r}')`);if(!n)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:M.resolve(n)}}async function hc(r){let{name:e,dir:t}=r;if(!lt(t))throw new Error(`--replace path for '${e}' does not exist: ${t}`);let n=dc(t,e),s=ch(n,e),i=M.resolve(t,s);if(!lt(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=M.dirname(i),a=`/local/${e}/${M.basename(i)}`,c=lh(n,t);return await uh(e,i,o),{name:e,dir:t,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:c}}function ch(r,e){if(r.exports!==void 0){let n;try{n=ci(r,".",{browser:!0,conditions:ai})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${ai.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=li(n);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${ai.join(", ")}); too complex to override.`);return s}let t=r.module??r.main;if(!t)throw new Error(`--replace package '${e}' has no "exports", "module", or "main" entry to resolve.`);return t}function lh(r,e){if(r.exports!==void 0)try{let n=ci(r,".",{conditions:["types"]}),s=li(n);if(s){let i=M.resolve(e,s);if(lt(i))return i}}catch{}let t=r.types??r.typings;if(t){let n=M.resolve(e,t);if(lt(n))return n}}function li(r){if(typeof r=="string")return r;if(Array.isArray(r))return r.find(e=>typeof e=="string")}async function uh(r,e,t){await uc;let n=M.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 lc.readFile(o,"utf8")}catch{continue}let c,l;try{[c,,,l]=fc(a,o)}catch{continue}if(o===e&&!l)throw new Error(`override package '${r}' entry is not an ES module (no import/export syntax); CommonJS or non-module entries aren't supported (esm.sh would have to transform it).`);for(let f of c){if(f.d===-2)continue;let u=f.n;if(u&&!u.startsWith("node:")){if(u.startsWith("./")||u.startsWith("../")||u.startsWith("/")){let d=fh(o,u,n);d&&!s.has(d)&&i.push(d);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${r} externalizes '${u}'`)}}}}function fh(r,e,t){let n=e.replace(/[?#].*$/,""),s=M.resolve(M.dirname(r),n),i=[s,s+".js",s+".mjs",M.join(s,"index.js"),M.join(s,"index.mjs")];for(let o of i)if(M.normalize(o).startsWith(t)&<(o))return o}function dh(r,e,t){let n=dc(r,e),s;if(n.exports!==void 0)try{s=li(ci(n,t,{conditions:cc}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${t}' (conditions: ${cc.join(", ")}): ${o instanceof Error?o.message:o}`)}else t==="."&&(s=n.main??n.module);if(!s)throw new Error(`--replace package '${e}' has no node export for '${t}'.`);let i=M.resolve(r,s);if(!lt(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return ah(i).href}async function mc(r,e){await uc;let t;try{[t]=fc(r)}catch{return r}let n="",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=dh(e.dir,e.name,a);n+=r.slice(s,i.s)+c,s=i.e}return n+r.slice(s)}function gc(r){let t={subcommand:"run",file:"",port:3e3,watch:!0,open:!(process.env.TERM_PROGRAM==="vscode"),server:!1,trust:!1,noTrust:!1,follow:!1,clear:!1,help:!1,version:!1,callArgs:[],hasArgsFlag:!1},n=["call","check","predict","logs","wait","stop","trust","untrust","skill","models","send"],s=r[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)}r=r.slice(1)}else s&&n.includes(s)&&(t.subcommand=s,r=r.slice(1));let i=[];for(let o=0;o<r.length;o++){let a=r[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=!0;else if(a==="--no-open")t.open=!1;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==="--mode"){let c=r[++o];(!c||c.startsWith("-"))&&(console.error("Missing value for --mode (e.g. --mode staging)"),process.exit(1)),t.mode=c}else if(a==="--follow"||a==="-f")t.follow=!0;else if(a==="--clear")t.clear=!0;else if(a==="--run"){let c=r[++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=r[++o];c===void 0&&(console.error("Missing value for --match (a substring new log lines must contain)"),process.exit(1)),t.match=c}else if(a==="--timeout"){let c=parseInt(r[++o],10);(isNaN(c)||c<=0)&&(console.error(`Invalid --timeout value: ${r[o]} (seconds)`),process.exit(1)),t.timeoutSec=c}else if(a==="--lines"||a==="-n"){let c=parseInt(r[++o],10);(isNaN(c)||c<0)&&(console.error(`Invalid --lines value: ${r[o]}`),process.exit(1)),t.lines=c}else if(a==="--port"||a==="-p"){let c=r[++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):r[++o]??"";try{let l=pc(c);if(t.local)throw new Error(`--replace can only be used once (got '${t.local.name}' and '${l.name}')`);t.local=l}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}}else if(a==="--args"||a.startsWith("--args=")){t.hasArgsFlag=!0;let c=a.startsWith("--args=")?a.slice(7):r[++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 a.startsWith("-")||(t.subcommand==="call"||t.subcommand==="send"?i.push(a):t.file=a)}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}function yc(){console.log(`
|
|
176
|
+
`:"";_p(n,i+`OPENROUTER_API_KEY=${e}
|
|
177
|
+
`)}}catch(i){return{ok:!1,error:ce(i)}}return process.env.OPENROUTER_API_KEY=e,Lp(t,[".env"],"# secrets"),{ok:!0}}function jk(){if(!(!Dt&&!me)){try{Bp(B)}catch{}Nk()}}function qk(r,e){return qp.test(e)?"blocked by your OpenRouter data policy":r===401||r===403||/unauthor|invalid api key|no auth|forbidden/i.test(e)?"auth rejected \u2014 check your OpenRouter key":r===404||/not a valid model|no such model|unknown model|model not found/i.test(e)?"model not found on this route":r===429||/rate limit/i.test(e)?"rate limited":r===402||/insufficient|credit|quota|balance/i.test(e)?"out of credits / quota":e.slice(0,160)}function Fk(r){if(qp.test(r))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 Uk(r,e,t){if(!r)return{works:null,read:0,note:t?`couldn't re-test on ${t} \u2014 caching unconfirmed`:"caching unconfirmed"};let n=tc(e?.cache_read_input_tokens)||tc(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 n>0?{works:!0,read:n,note:`${n} tokens read from cache on the 2nd call`}:s?{works:!1,read:n,note:"no cache reads after a warm call \u2014 every turn re-bills the full context"}:{works:null,read:n,note:"route doesn't report cache usage \u2014 caching almost certainly not honored"}}async function Jk({model:r}){let e=process.env.OPENROUTER_API_KEY;if(!e)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!r)return{ok:!1,error:"no model given"};if(sc(r))return{ok:!1,error:"Anthropic model \u2014 not offered or probed via OpenRouter"};let t=Date.now(),n=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:r,max_tokens:8,system:[{type:"text",text:n,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 f=JSON.stringify(a?{...i,provider:$p(a)}:i),u=await fetch(nc,{method:"POST",signal:c.signal,headers:s,body:f}),d=await u.json().catch(()=>({}));return{r:u,j:d}}finally{clearTimeout(l)}};try{let{r:a,j:c}=await o();if(!a.ok){let v=c?.error?.message||c?.message||JSON.stringify(c).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-t,error:qk(a.status,v),restriction:Fk(v)}}let l=typeof c?.provider=="string"?c.provider:void 0,f=c?.content?.find?.(v=>v.type==="text")?.text??c?.content?.[0]?.text??"ok",u=tc(c?.usage?.cache_creation_input_tokens),{r:d,j:p}=await o(l),{works:m,read:h,note:y}=Uk(d.ok,p?.usage,l);return m===!0&&l&&(ic[r]=l,me===r&&(ct=l)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-t,provider:l,sample:String(f).trim().slice(0,60),cache:{works:m,created:u,read:h,note:y}}}catch(a){let c=ce(a);return{ok:!0,callable:!1,ms:Date.now()-t,error:/abort/i.test(c)?"timed out (20s)":c}}}var bk,nc,wk,vk,Ip,Sk,ec,ii,oi,ri,sc,Dt,at,me,ct,Wr,Vr,Hr,ic,tc,$p,qp,Fp=O(()=>{Xa();Vs();bk="https://openrouter.ai/api",nc=`${bk}/v1/messages`,wk="typebulb-proxy-managed",vk="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.",Ip=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],Sk=5e3,ec=["low","medium","high"],ii=r=>si(r,".claude","settings.local.json"),oi=r=>si(r,".claude",".cc-switcher.json"),ri=r=>`http://127.0.0.1:${r}`;sc=r=>/^anthropic\//i.test(r)||/claude/i.test(r),Dt=null,at=null,me=null,ct=null,Wr=null,Vr="unknown",Hr=1,ic={},tc=r=>typeof r=="number"?r:0,$p=r=>({order:[r],allow_fallbacks:!1});qp=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=qe(oi(B)),t=e?.active?.model;if(!t)return;let s=(qe(ii(B))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await jp(t,e.active.provider??ic[t]??null);console.log(`[switcher] re-adopted override after restart: ${t} via ${ri(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",ce(e))}})()});var Up={};sh(Up,{attach:()=>WS,blockToMarkdown:()=>Wa,breakout:()=>ok,capText:()=>Jr,cleanUserText:()=>it,clearSwitchModel:()=>Dk,info:()=>$S,isHiddenTurn:()=>Xs,launchBulb:()=>fk,listBreakouts:()=>ak,listBulbFiles:()=>lk,listSessions:()=>FS,listSwitchModels:()=>Ik,logEmbedStatus:()=>BS,openFile:()=>ik,poll:()=>MS,predictTrustOf:()=>dk,probeModel:()=>Jk,readBulbLog:()=>hk,saveOpenRouterKey:()=>Bk,searchBulbs:()=>uk,searchHits:()=>Zs,searchSessions:()=>KS,setBulbTrust:()=>pk,setReasoning:()=>Mk,setSwitchModel:()=>$k,shutdownSwitcher:()=>jk,stopBreakout:()=>ck,switchState:()=>Lk});var Jp=O(()=>{Ha();Rp();Fp()});import*as Xp from"fs/promises";import*as ke from"path";import*as lc from"fs/promises";import{existsSync as lt,readFileSync as ah}from"fs";import*as M from"path";import{pathToFileURL as ch}from"url";import{resolve as li}from"resolve.exports";import{init as uc,parse as fc}from"es-module-lexer";function dc(r,e){let t=M.join(r,"package.json");try{return JSON.parse(ah(t,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${t}`)}}var ci=["browser","import","default"],cc=["node","import","default"];function pc(r){let e=r.indexOf("=");if(e===-1)throw new Error(`--replace must be <name>=<path> (got '${r}')`);let t=r.slice(0,e).trim(),n=r.slice(e+1).trim();if(!t)throw new Error(`--replace missing package name (got '${r}')`);if(!n)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:M.resolve(n)}}async function hc(r){let{name:e,dir:t}=r;if(!lt(t))throw new Error(`--replace path for '${e}' does not exist: ${t}`);let n=dc(t,e),s=lh(n,e),i=M.resolve(t,s);if(!lt(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=M.dirname(i),a=`/local/${e}/${M.basename(i)}`,c=uh(n,t);return await fh(e,i,o),{name:e,dir:t,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:c}}function lh(r,e){if(r.exports!==void 0){let n;try{n=li(r,".",{browser:!0,conditions:ci})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${ci.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=ui(n);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${ci.join(", ")}); too complex to override.`);return s}let t=r.module??r.main;if(!t)throw new Error(`--replace package '${e}' has no "exports", "module", or "main" entry to resolve.`);return t}function uh(r,e){if(r.exports!==void 0)try{let n=li(r,".",{conditions:["types"]}),s=ui(n);if(s){let i=M.resolve(e,s);if(lt(i))return i}}catch{}let t=r.types??r.typings;if(t){let n=M.resolve(e,t);if(lt(n))return n}}function ui(r){if(typeof r=="string")return r;if(Array.isArray(r))return r.find(e=>typeof e=="string")}async function fh(r,e,t){await uc;let n=M.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 lc.readFile(o,"utf8")}catch{continue}let c,l;try{[c,,,l]=fc(a,o)}catch{continue}if(o===e&&!l)throw new Error(`override package '${r}' entry is not an ES module (no import/export syntax); CommonJS or non-module entries aren't supported (esm.sh would have to transform it).`);for(let f of c){if(f.d===-2)continue;let u=f.n;if(u&&!u.startsWith("node:")){if(u.startsWith("./")||u.startsWith("../")||u.startsWith("/")){let d=dh(o,u,n);d&&!s.has(d)&&i.push(d);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${r} externalizes '${u}'`)}}}}function dh(r,e,t){let n=e.replace(/[?#].*$/,""),s=M.resolve(M.dirname(r),n),i=[s,s+".js",s+".mjs",M.join(s,"index.js"),M.join(s,"index.mjs")];for(let o of i)if(M.normalize(o).startsWith(t)&<(o))return o}function ph(r,e,t){let n=dc(r,e),s;if(n.exports!==void 0)try{s=ui(li(n,t,{conditions:cc}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${t}' (conditions: ${cc.join(", ")}): ${o instanceof Error?o.message:o}`)}else t==="."&&(s=n.main??n.module);if(!s)throw new Error(`--replace package '${e}' has no node export for '${t}'.`);let i=M.resolve(r,s);if(!lt(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return ch(i).href}async function mc(r,e){await uc;let t;try{[t]=fc(r)}catch{return r}let n="",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=ph(e.dir,e.name,a);n+=r.slice(s,i.s)+c,s=i.e}return n+r.slice(s)}function gc(r){let t={subcommand:"run",file:"",port:3e3,watch:!0,open:!(process.env.TERM_PROGRAM==="vscode"),server:!1,trust:!1,noTrust:!1,follow:!1,clear:!1,help:!1,version:!1,callArgs:[],hasArgsFlag:!1},n=["call","check","predict","logs","wait","stop","trust","untrust","skill","models","send"],s=r[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)}r=r.slice(1)}else s&&n.includes(s)&&(t.subcommand=s,r=r.slice(1));let i=[];for(let o=0;o<r.length;o++){let a=r[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=!0;else if(a==="--no-open")t.open=!1;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==="--mode"){let c=r[++o];(!c||c.startsWith("-"))&&(console.error("Missing value for --mode (e.g. --mode staging)"),process.exit(1)),t.mode=c}else if(a==="--follow"||a==="-f")t.follow=!0;else if(a==="--clear")t.clear=!0;else if(a==="--run"){let c=r[++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=r[++o];c===void 0&&(console.error("Missing value for --match (a substring new log lines must contain)"),process.exit(1)),t.match=c}else if(a==="--timeout"){let c=parseInt(r[++o],10);(isNaN(c)||c<=0)&&(console.error(`Invalid --timeout value: ${r[o]} (seconds)`),process.exit(1)),t.timeoutSec=c}else if(a==="--lines"||a==="-n"){let c=parseInt(r[++o],10);(isNaN(c)||c<0)&&(console.error(`Invalid --lines value: ${r[o]}`),process.exit(1)),t.lines=c}else if(a==="--port"||a==="-p"){let c=r[++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):r[++o]??"";try{let l=pc(c);if(t.local)throw new Error(`--replace can only be used once (got '${t.local.name}' and '${l.name}')`);t.local=l}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}}else if(a==="--args"||a.startsWith("--args=")){t.hasArgsFlag=!0;let c=a.startsWith("--args=")?a.slice(7):r[++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 a.startsWith("-")||(t.subcommand==="call"||t.subcommand==="send"?i.push(a):t.file=a)}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}function yc(){console.log(`
|
|
178
178
|
typebulb - Local bulb runner for Typebulb
|
|
179
179
|
|
|
180
180
|
Usage:
|
|
@@ -296,7 +296,179 @@ Examples:
|
|
|
296
296
|
typebulb my-editor.bulb.md
|
|
297
297
|
typebulb --no-watch --port 8080 my-editor.bulb.md
|
|
298
298
|
typebulb .
|
|
299
|
-
`)}Xo();import*as De from"fs/promises";import*as gs from"path";import{pathToFileURL as Lw}from"url";import{transform as Xb}from"sucrase";function Zo(r,e={}){let t=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:n}=Xb(r,{transforms:t,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:n}}catch(n){return{code:"",error:String(n)}}}var br="https://esm.sh",wr="https://cdn.jsdelivr.net/npm/",ea="https://data.jsdelivr.com/v1/package/npm/";function Tf(r){let e=(r||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var T=class r{constructor(e,t,n){let s=typeof e=="string"?r.parse(e):e;this.name=s.name,this.version=St(t??s.version),this.subpath=St(n??s.subpath)}static parse(e){let t=Tf(e||"");if(!t.length)return new r({name:""});if(t[0].startsWith("@")){let s=t[0],[i,o]=Of(t[1]??""),a=St(t.slice(2).join("/"));return new r({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=Of(t[0]),o=St(t.slice(1).join("/"));return new r({name:s,version:i,subpath:o})}}static fromUrl(e){try{let t=new URL(e),n=new URL(br).host,s=new URL(wr).host;if(t.host===n){let i=Tf(t.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return r.parse(o)}if(t.host===s){let i=t.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return r.parse(o)}return}catch{return}}static versionFromUrl(e){return r.fromUrl(e)?.version}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 r.parse(e).name}withVersion(e){return new r({name:this.name,version:St(e),subpath:this.subpath})}withPreferredVersion(e,t){let n=e||t;return n?this.withVersion(n):this}static isBare(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;let t=e.toLowerCase();return!t.startsWith("http://")&&!t.startsWith("https://")}},St=r=>r&&r.length?r:void 0,Of=r=>{let e=r.indexOf("@");return e<0?[r,void 0]:[r.slice(0,e),St(r.slice(e+1))]};async function V(r){try{return await r()}catch{return}}var vr=class{constructor(e,t){this.cache=e,this.http=t,this.esmHost=br,this.jsDelivrBase=wr,this.jsDelivrMeta=ea,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}normalizeRelative(e){let t=e||"";return t.startsWith("./")?t.slice(2):t.replace(/^\/+/,"")}ensureLeadingDotSlash(e){return e.startsWith("./")?e:`./${e}`}baseDir(e){let t=typeof e=="string"?new T(e):e;return`${this.jsDelivrBase}${t.name}${t.version?`@${t.version}`:""}/`}file(e,t){return new URL(this.normalizeRelative(t),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,t={}){let{target:n="es2022",bundle:s=!1,external:i}=t,o=new URLSearchParams({target:n});return s&&o.append("bundle",""),i?.length&&o.append("external",i.join(",")),`${this.esmHost}/${e}?${o.toString()}`}async pinEsmUrl(e,t="es2022"){let n=this.buildEsmUrl(e,{target:t}),s=await V(()=>this.http.head(n));return s?.ok?s.url||n:void 0}async resolveExactVersion(e){let t=Date.now(),n=this.pinCache.get(e);if(n&&t-n.ts<this.pinMs)return n.value;let s=await this.tryResolveFromUrls([this.buildEsmUrl(e),`${this.esmHost}/${e}`]);return this.pinCache.set(e,{value:s,ts:t}),s}async tryResolveFromUrls(e){for(let t of e){let n=await V(()=>this.http.head(t)),s=this.parseVersionFromUrl(n?.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 n=await V(()=>this.http.getJson(`${this.jsDelivrMeta}${encodeURIComponent(e)}`));if(!n?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let s=n.distTags&&Object.keys(n.distTags).length?n.distTags:void 0;return await this.cache.setIndex(e,n.versions,s),n}parseVersionFromUrl(e){let t=T.fromUrl(e)?.version;return t&&/\d+\.\d+\.\d+/.test(t)?t:void 0}async fetchPackageMeta(e,t){let n=await this.cache.getMeta(e,t);if(n&&Date.now()-n.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:u,peerDependenciesMeta:d}=n;return{name:e,version:t,dependencies:f,peerDependencies:u,peerDependenciesMeta:d}}let s=this.packageJson(new T(`${e}@${t}`)),i=await V(()=>this.http.getJson(s));if(!i)return;let o=f=>f&&Object.keys(f).length?f: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 Pf=r=>r.startsWith("@types/"),Sr=r=>Object.keys(r?.peerDependencies||{}).filter(e=>!Pf(e)),ta=r=>Object.keys(r?.dependencies||{}).filter(e=>!Pf(e)),Zb=r=>Sr(r).filter(e=>!r?.peerDependenciesMeta?.[e]?.optional),kr=class{constructor(e){this.cdn=e}async resolve(e,t){let n=await this.fetchMeta(e),{allRoots:s,autoAddedPeers:i}=await this.expandWithPeers(n,t),o=this.computeFlags(s);return{allRoots:s,flags:o,autoAddedPeers:i}}async fetchMeta(e){return Promise.all(e.map(async({name:t,version:n})=>({name:t,version:n,meta:await this.cdn.fetchPackageMeta(t,n)})))}async expandWithPeers(e,t){let n=new Map(e.map(i=>[i.name,i])),s=[];for(let i of e)for(let o of Zb(i.meta))!n.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);n.set(i,{name:i,version:a,meta:c})}catch(a){console.warn(`[typebulb] Failed to resolve peer "${i}" for "${o}":`,a)}return{allRoots:[...n.values()],autoAddedPeers:s.filter(i=>n.has(i.name))}}computeFlags(e){let t=new Set(e.flatMap(i=>Sr(i.meta))),n=new Map;for(let i of e)for(let o of ta(i.meta))n.set(o,(n.get(o)||0)+1);let s=new Set([...n.entries()].filter(([,i])=>i>=2).map(([i])=>i));return new Map(e.map(i=>[i.name,{isPeerRoot:t.has(i.name),hasPeers:Sr(i.meta).length>0,isSharedDep:s.has(i.name)}]))}};var xr=class{constructor(e,t,n){this.cache=e,this.cdn=t,this.semver=n}selectVersionFromIndex(e,t,n){return this.semver.selectBestVersion(e,{range:t,distTags:n})}async learnExactVersion(e){let t=await V(()=>this.cdn.fetchVersionsIndex(e));if(t?.versions?.length){let n=this.semver.selectBestVersion(t.versions,{distTags:t.distTags});if(n)return n}return this.cdn.resolveExactVersion(e)}async resolveExactForRoot(e,t){if(!t)return this.learnExactVersion(e);let n=await this.cache.getPinnedExact(e,t);if(n){if(this.semver.isExactVersion(n))return n;console.debug("[typebulb] cached version for",e,"is not exact (",n,"); re-resolving from registry")}let s=await V(()=>this.cdn.fetchVersionsIndex(e));if(s?.versions?.length){let o=this.selectVersionFromIndex(s.versions,t,s.distTags);if(o){if(this.semver.isExactVersion(o))return await this.cache.setPinnedExact(e,t,o),o}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 a=await V(()=>this.cdn.fetchVersionsIndex(e));if(a?.versions?.length){let c=this.selectVersionFromIndex(a.versions,t,a.distTags);if(c&&this.semver.isExactVersion(c))return await this.cache.setPinnedExact(e,t,c),c}}}let i=await this.cdn.resolveExactVersion(`${e}@${t}`);if(i&&this.semver.isExactVersion(i))return await this.cache.setPinnedExact(e,t,i),i}async effectivePackage(e,t){let n=new T(e),s=n.root(),i=t[s],o=i?await V(()=>this.cache.getPinnedExact(s,i))??await V(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?n.withVersion(o).format():e,root:s,range:i,pinned:o}}};import{init as ew,parse as tw}from"es-module-lexer";var kt=class r{constructor(e,t,n,s){this.version=e,this.cdn=t,this.peer=n,this.cache=s}extractImportsSync(e){let t=new Set;for(let n of r.importPatterns){n.lastIndex=0;for(let s of e.matchAll(n))T.isBare(s[1])&&t.add(s[1])}return Array.from(t)}async extractImports(e){let t=new Set,n=s=>{T.isBare(s)&&t.add(s)};try{await ew;let[s]=tw(e);s.forEach(i=>n(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(t)}async buildImportMap(e,t,n){let s=(await this.extractImports(e)).filter(u=>!n?.has(T.rootOf(u))),i=[...new Set(s.map(T.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)),f=this.buildEntries([...s,...l.map(u=>u.name)],a,c,t);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,u])=>u)}}async resolveVersion(e,t){let n=t[e],s=n?`${e}@${n}`:e,i=await this.version.resolveExactForRoot(e,n);if(!i){let o=await V(()=>this.cdn.pinEsmUrl(s));if(!o)throw new Error(`Cannot resolve ${s}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);i=T.versionFromUrl(o),i&&n&&await V(()=>this.cache.setPinnedExact(e,n,i))}if(!i)throw new Error(`Cannot resolve ${s}: no concrete version found.`);return i}buildEntries(e,t,n,s){let i=new Map(t.map(m=>[m.name,m])),o=m=>{let h=i.get(T.rootOf(m));return new T(m).withPreferredVersion(h.version,s[h.name]).format()},a=new Set([...n.entries()].filter(([,m])=>m.isPeerRoot||m.isSharedDep).map(([m])=>m)),c=new Set(e.filter(m=>m!==T.rootOf(m)).map(T.rootOf)),l=[],f=new Set,u=new Set(e.filter(m=>m===T.rootOf(m))),d=new Set;for(let m of e){let h=T.rootOf(m),y=i.get(h),{isPeerRoot:v,hasPeers:k,isSharedDep:g}=n.get(h),b=c.has(h),w=m!==h,A=!(v||g)&&(b||!k),E=this.singletonDepsOf(y,a),C=w&&u.has(h);C&&d.add(h);let J=C?[...E,h]:E.length?E:void 0;l.push([m,this.cdn.buildEsmUrl(o(m),{bundle:A,external:J})]),f.add(m)}let p=new Set([...a,...d]);for(let m of p)i.has(m)&&(f.has(m)||l.push([m,this.cdn.buildEsmUrl(o(m),{})]),l.push([`${m}/`,`${this.cdn.esmHost}/${o(m)}/`]));return l}singletonDepsOf(e,t){return[...new Set([...Sr(e.meta),...ta(e.meta)])].filter(n=>t.has(n))}};kt.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g];import{gt as Nf,satisfies as rw,maxSatisfying as ra,major as nw,prerelease as sw,rsort as iw,valid as ow}from"semver";var es=class{cmp(e,t){return e===t?0:Nf(e,t)?1:Nf(t,e)?-1:0}satisfies(e,t){return!e||!e.trim()?!0:!!rw(t,e,{includePrerelease:!0})}pickMaxSatisfying(e,t){if(!e?.length)return;let n=ra(e,t,{includePrerelease:!0});return n===null?void 0:n}pickLatest(e){return e?.length?iw(e)[0]:void 0}selectBestVersion(e,t){if(!e?.length)return;let n=t?.range?.trim()||"*",s=t?.preferStable??!0,i=t?.distTags?.latest;if(i&&e.includes(i)&&this.satisfies(n,i))return i;if(s){let a=ra(e,n,{includePrerelease:!1});if(a)return a}return ra(e,n,{includePrerelease:!0})??void 0}majorOf(e){return nw(e)}isPrerelease(e){return sw(e)!==null}isExactVersion(e){return ow(e)!==null}},He=new es;function Cf(r,e){let t=new vr(r,e),n=new kr(t),s=new xr(r,t,He);return{packageService:new kt(s,t,n,r),versionResolver:s,cdnClient:t,peerResolver:n}}import*as Hf from"fs/promises";import*as ie from"path";var na=[{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"}],sa=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];var _f=`
|
|
299
|
+
`)}Zo();import*as De from"fs/promises";import*as ys from"path";import{pathToFileURL as Uw}from"url";import{transform as Zb}from"sucrase";function ea(r,e={}){let t=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:n}=Zb(r,{transforms:t,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:n}}catch(n){return{code:"",error:String(n)}}}var He=["client"],Ye=["client","server"],ew=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:He},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:Ye},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:He},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:He},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:He},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:Ye},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:Ye},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:Ye},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:Ye},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:Ye},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:Ye},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:He},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:He},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:He}],tw=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g];function rw(r){if(/^[./]/.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))return null;let e=r.split("/");return r.startsWith("@")?e.slice(0,2).join("/"):e[0]}function br(r,e){if(!r)return[];let{target:t,dependencies:n}=e,s=[],i=r.split(`
|
|
300
|
+
`);for(let o=0;o<i.length;o++){let a=i[o],c=o+1;for(let l of ew)l.targets.includes(t)&&l.pattern.test(a)&&s.push({type:l.type,severity:"error",message:iw(l.type,c),lineNumber:c,lineContent:a})}return t==="client"&&n&&s.push(...nw(i,n)),s}function nw(r,e){let t=new Set(Object.keys(e)),n=new Set,s=[];for(let i=0;i<r.length;i++)for(let o of tw)for(let a of r[i].matchAll(o)){let c=rw(a[1]);!c||t.has(c)||n.has(c)||(n.add(c),s.push({type:"UNDECLARED_IMPORT",severity:"error",message:sw(c,i+1),lineNumber:i+1,lineContent:r[i]}))}return s}function sw(r,e){return`Import "${r}" is not declared in config.json dependencies! Found on line ${e}.
|
|
301
|
+
|
|
302
|
+
**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.
|
|
303
|
+
|
|
304
|
+
\u2705 CORRECT - declare every import:
|
|
305
|
+
\`\`\`json
|
|
306
|
+
{
|
|
307
|
+
"description": "\u2026",
|
|
308
|
+
"dependencies": {
|
|
309
|
+
"${r}": "*"
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
\`\`\`
|
|
313
|
+
|
|
314
|
+
**Fix:** Add a **config.json** block (or extend the existing one) with a "dependencies" entry for "${r}" \u2014 and for every other bare import in code.tsx. Pin a real version where you can (e.g. "react": "^19.2.7").`}function iw(r,e){return r==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
|
|
315
|
+
|
|
316
|
+
**CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
|
|
317
|
+
|
|
318
|
+
\u2705 CORRECT - Package name only:
|
|
319
|
+
\`\`\`typescript
|
|
320
|
+
import React from "react"
|
|
321
|
+
import _ from "lodash"
|
|
322
|
+
\`\`\`
|
|
323
|
+
|
|
324
|
+
\u274C WRONG - Direct URL imports:
|
|
325
|
+
\`\`\`typescript
|
|
326
|
+
import React from "https://esm.sh/react"
|
|
327
|
+
import _ from "https://cdn.skypack.dev/lodash"
|
|
328
|
+
import x from "https://unpkg.com/some-package"
|
|
329
|
+
\`\`\`
|
|
330
|
+
|
|
331
|
+
**Fix:** Use the package name only. Package resolution is handled automatically.`:r==="VERSION_SPECIFIER_IMPORT"?`Version specifiers in imports are not supported! Found on line ${e}.
|
|
332
|
+
|
|
333
|
+
**CRITICAL**: Import packages by name only. Do NOT include version numbers:
|
|
334
|
+
|
|
335
|
+
\u2705 CORRECT - Package name only:
|
|
336
|
+
\`\`\`typescript
|
|
337
|
+
import React from "react"
|
|
338
|
+
import _ from "lodash"
|
|
339
|
+
import { something } from "@scope/package"
|
|
340
|
+
\`\`\`
|
|
341
|
+
|
|
342
|
+
\u274C WRONG - Version in import path:
|
|
343
|
+
\`\`\`typescript
|
|
344
|
+
import React from "react@18.2.0"
|
|
345
|
+
import _ from "lodash@^4.17.0"
|
|
346
|
+
import { x } from "@scope/package@1.0.0"
|
|
347
|
+
\`\`\`
|
|
348
|
+
|
|
349
|
+
**Fix:** Remove the version specifier (everything from @ onwards). Versions are managed separately.`:r==="JS_EXTENSION_IMPORT"?`Deep import paths must NOT include \`.js\` extension! Found on line ${e}.
|
|
350
|
+
|
|
351
|
+
**CRITICAL**: Remove the \`.js\` extension from deep import paths (paths with \`/\`):
|
|
352
|
+
|
|
353
|
+
\u2705 CORRECT - No extension in deep import:
|
|
354
|
+
\`\`\`typescript
|
|
355
|
+
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"
|
|
356
|
+
\`\`\`
|
|
357
|
+
|
|
358
|
+
\u274C WRONG - Has .js extension in deep import:
|
|
359
|
+
\`\`\`typescript
|
|
360
|
+
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js"
|
|
361
|
+
\`\`\`
|
|
362
|
+
|
|
363
|
+
**Note:** Package names that literally end with ".js" (like \`decimal.js\`) are fine - this rule only applies to file paths within packages.
|
|
364
|
+
|
|
365
|
+
**Fix:** Remove \`.js\` from the end of the import path.`:r==="DYNAMIC_IMPORT"?`Dynamic imports are not supported! You used \`import('...')\` on line ${e}.
|
|
366
|
+
|
|
367
|
+
**CRITICAL**: All imports MUST be at the TOP of the file using standard ES6 import syntax:
|
|
368
|
+
|
|
369
|
+
\u2705 CORRECT - Static import at top of file:
|
|
370
|
+
\`\`\`typescript
|
|
371
|
+
import { createRoot } from 'react-dom/client'
|
|
372
|
+
|
|
373
|
+
// Later in code...
|
|
374
|
+
const root = createRoot(rootElement)
|
|
375
|
+
root.render(<App />)
|
|
376
|
+
\`\`\`
|
|
377
|
+
|
|
378
|
+
\u274C WRONG - Dynamic import() in code:
|
|
379
|
+
\`\`\`typescript
|
|
380
|
+
// This is completely invalid!
|
|
381
|
+
import('react-dom/client').then(({ createRoot }) => {
|
|
382
|
+
const root = createRoot(rootElement)
|
|
383
|
+
root.render(<App />)
|
|
384
|
+
})
|
|
385
|
+
\`\`\`
|
|
386
|
+
|
|
387
|
+
**Fix:** Move ALL import statements to the top of the file using standard \`import\` syntax.`:r==="REDUNDANT_TB_DECLARATION"?`Redundant \`declare const tb\` found on line ${e}.
|
|
388
|
+
The \`tb\` global is already provided by the environment. Remove this declaration.`:r==="CONST_ENUM"?`\`const enum\` is not supported! Found on line ${e}.
|
|
389
|
+
|
|
390
|
+
**Fix:** Use a regular \`enum\` or an object with \`as const\`:
|
|
391
|
+
|
|
392
|
+
\`\`\`typescript
|
|
393
|
+
// Option 1: Regular enum
|
|
394
|
+
enum Direction { Up, Down, Left, Right }
|
|
395
|
+
|
|
396
|
+
// Option 2: Object literal (often better)
|
|
397
|
+
const Direction = { Up: 0, Down: 1, Left: 2, Right: 3 } as const
|
|
398
|
+
\`\`\`
|
|
399
|
+
|
|
400
|
+
\`const enum\` requires the full TypeScript compiler to inline values at compile time. Regular \`enum\` and object literals work identically at runtime.`:r==="NAMESPACE_DECLARATION"?`TypeScript \`namespace\` is not supported! Found on line ${e}.
|
|
401
|
+
|
|
402
|
+
**Fix:** Use ES modules instead:
|
|
403
|
+
|
|
404
|
+
\`\`\`typescript
|
|
405
|
+
// Instead of: namespace MyLib { export function foo() {} }
|
|
406
|
+
// Just use top-level exports:
|
|
407
|
+
export function foo() {}
|
|
408
|
+
\`\`\`
|
|
409
|
+
|
|
410
|
+
Namespaces are a legacy TypeScript pattern. Use standard ES module imports/exports instead.`:r==="COMMONJS_EXPORT_EQUALS"?`\`export =\` syntax is not supported! Found on line ${e}.
|
|
411
|
+
|
|
412
|
+
**Fix:** Use ES module \`export default\` instead:
|
|
413
|
+
|
|
414
|
+
\`\`\`typescript
|
|
415
|
+
// Instead of: export = myValue
|
|
416
|
+
export default myValue
|
|
417
|
+
\`\`\``:r==="COMMONJS_IMPORT_EQUALS"?`\`import x =\` syntax is not supported! Found on line ${e}.
|
|
418
|
+
|
|
419
|
+
**Fix:** Use ES module \`import\` instead:
|
|
420
|
+
|
|
421
|
+
\`\`\`typescript
|
|
422
|
+
// Instead of: import x = require('module')
|
|
423
|
+
import x from 'module'
|
|
424
|
+
\`\`\``:r==="MODULE_DECLARATION"?`TypeScript \`module\` declarations are not supported! Found on line ${e}.
|
|
425
|
+
|
|
426
|
+
**Fix:** Use ES modules instead. The \`module Foo {}\` syntax is a legacy TypeScript pattern \u2014 use standard imports/exports.`:r==="CSS_FILE_IMPORT"?`Importing CSS files is not supported! Found on line ${e}.
|
|
427
|
+
|
|
428
|
+
**CRITICAL**: CSS imports don't work here. The styles.css block is already applied to the page automatically.
|
|
429
|
+
|
|
430
|
+
\u2705 CORRECT - Just remove the import. CSS from the styles.css block is already applied to the page.
|
|
431
|
+
|
|
432
|
+
\u274C WRONG - Importing CSS as a file:
|
|
433
|
+
\`\`\`typescript
|
|
434
|
+
import "./styles.css"
|
|
435
|
+
import styles from "./styles.css"
|
|
436
|
+
\`\`\`
|
|
437
|
+
|
|
438
|
+
**Fix:** Delete the CSS import line entirely. Write styles in the styles.css block \u2014 they are loaded automatically.`:r==="NAVIGATION"?`Navigation is forbidden in this sandboxed environment! Found on line ${e}.
|
|
439
|
+
|
|
440
|
+
**CRITICAL**: \`window.location\` changes, \`window.open()\`, and page reloads will break the app.
|
|
441
|
+
|
|
442
|
+
\u2705 CORRECT - Reset application state programmatically:
|
|
443
|
+
\`\`\`typescript
|
|
444
|
+
setState(initialState)
|
|
445
|
+
\`\`\`
|
|
446
|
+
|
|
447
|
+
\u274C WRONG - Browser navigation:
|
|
448
|
+
\`\`\`typescript
|
|
449
|
+
window.location.reload()
|
|
450
|
+
window.location.href = "..."
|
|
451
|
+
window.open("...")
|
|
452
|
+
\`\`\`
|
|
453
|
+
|
|
454
|
+
**Fix:** Remove the navigation call. To "restart", reset your state variables instead.`:`CommonJS \`require()\` is not supported! Found on line ${e}.
|
|
455
|
+
|
|
456
|
+
**CRITICAL**: Use ES6 \`import\` statements at the TOP of the file:
|
|
457
|
+
|
|
458
|
+
\u2705 CORRECT - ES6 import:
|
|
459
|
+
\`\`\`typescript
|
|
460
|
+
import { something } from 'module-name'
|
|
461
|
+
\`\`\`
|
|
462
|
+
|
|
463
|
+
\u274C WRONG - CommonJS require:
|
|
464
|
+
\`\`\`typescript
|
|
465
|
+
const something = require('module-name') // NOT SUPPORTED!
|
|
466
|
+
\`\`\`
|
|
467
|
+
|
|
468
|
+
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}function ow(r){return r.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
|
|
469
|
+
`)[0]}`).join(`
|
|
470
|
+
`)}function Tf(r,e){let t=br(r,{target:"client",dependencies:e}).filter(n=>n.type==="UNDECLARED_IMPORT");if(t.length)throw new Error(`Lint failed:
|
|
471
|
+
${ow(t)}`)}var wr="https://esm.sh",vr="https://cdn.jsdelivr.net/npm/",ta="https://data.jsdelivr.com/v1/package/npm/";function Of(r){let e=(r||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var T=class r{constructor(e,t,n){let s=typeof e=="string"?r.parse(e):e;this.name=s.name,this.version=St(t??s.version),this.subpath=St(n??s.subpath)}static parse(e){let t=Of(e||"");if(!t.length)return new r({name:""});if(t[0].startsWith("@")){let s=t[0],[i,o]=Pf(t[1]??""),a=St(t.slice(2).join("/"));return new r({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=Pf(t[0]),o=St(t.slice(1).join("/"));return new r({name:s,version:i,subpath:o})}}static fromUrl(e){try{let t=new URL(e),n=new URL(wr).host,s=new URL(vr).host;if(t.host===n){let i=Of(t.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return r.parse(o)}if(t.host===s){let i=t.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return r.parse(o)}return}catch{return}}static versionFromUrl(e){return r.fromUrl(e)?.version}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 r.parse(e).name}withVersion(e){return new r({name:this.name,version:St(e),subpath:this.subpath})}withPreferredVersion(e,t){let n=e||t;return n?this.withVersion(n):this}static isBare(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;let t=e.toLowerCase();return!t.startsWith("http://")&&!t.startsWith("https://")}},St=r=>r&&r.length?r:void 0,Pf=r=>{let e=r.indexOf("@");return e<0?[r,void 0]:[r.slice(0,e),St(r.slice(e+1))]};async function V(r){try{return await r()}catch{return}}var Sr=class{constructor(e,t){this.cache=e,this.http=t,this.esmHost=wr,this.jsDelivrBase=vr,this.jsDelivrMeta=ta,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}normalizeRelative(e){let t=e||"";return t.startsWith("./")?t.slice(2):t.replace(/^\/+/,"")}ensureLeadingDotSlash(e){return e.startsWith("./")?e:`./${e}`}baseDir(e){let t=typeof e=="string"?new T(e):e;return`${this.jsDelivrBase}${t.name}${t.version?`@${t.version}`:""}/`}file(e,t){return new URL(this.normalizeRelative(t),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,t={}){let{target:n="es2022",bundle:s=!1,external:i}=t,o=new URLSearchParams({target:n});return s&&o.append("bundle",""),i?.length&&o.append("external",i.join(",")),`${this.esmHost}/${e}?${o.toString()}`}async pinEsmUrl(e,t="es2022"){let n=this.buildEsmUrl(e,{target:t}),s=await V(()=>this.http.head(n));return s?.ok?s.url||n:void 0}async resolveExactVersion(e){let t=Date.now(),n=this.pinCache.get(e);if(n&&t-n.ts<this.pinMs)return n.value;let s=await this.tryResolveFromUrls([this.buildEsmUrl(e),`${this.esmHost}/${e}`]);return this.pinCache.set(e,{value:s,ts:t}),s}async tryResolveFromUrls(e){for(let t of e){let n=await V(()=>this.http.head(t)),s=this.parseVersionFromUrl(n?.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 n=await V(()=>this.http.getJson(`${this.jsDelivrMeta}${encodeURIComponent(e)}`));if(!n?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let s=n.distTags&&Object.keys(n.distTags).length?n.distTags:void 0;return await this.cache.setIndex(e,n.versions,s),n}parseVersionFromUrl(e){let t=T.fromUrl(e)?.version;return t&&/\d+\.\d+\.\d+/.test(t)?t:void 0}async fetchPackageMeta(e,t){let n=await this.cache.getMeta(e,t);if(n&&Date.now()-n.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:u,peerDependenciesMeta:d}=n;return{name:e,version:t,dependencies:f,peerDependencies:u,peerDependenciesMeta:d}}let s=this.packageJson(new T(`${e}@${t}`)),i=await V(()=>this.http.getJson(s));if(!i)return;let o=f=>f&&Object.keys(f).length?f: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 Rf=r=>r.startsWith("@types/"),kr=r=>Object.keys(r?.peerDependencies||{}).filter(e=>!Rf(e)),ra=r=>Object.keys(r?.dependencies||{}).filter(e=>!Rf(e)),aw=r=>kr(r).filter(e=>!r?.peerDependenciesMeta?.[e]?.optional),xr=class{constructor(e){this.cdn=e}async resolve(e,t){let n=await this.fetchMeta(e),{allRoots:s,autoAddedPeers:i}=await this.expandWithPeers(n,t),o=this.computeFlags(s);return{allRoots:s,flags:o,autoAddedPeers:i}}async fetchMeta(e){return Promise.all(e.map(async({name:t,version:n})=>({name:t,version:n,meta:await this.cdn.fetchPackageMeta(t,n)})))}async expandWithPeers(e,t){let n=new Map(e.map(i=>[i.name,i])),s=[];for(let i of e)for(let o of aw(i.meta))!n.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);n.set(i,{name:i,version:a,meta:c})}catch(a){console.warn(`[typebulb] Failed to resolve peer "${i}" for "${o}":`,a)}return{allRoots:[...n.values()],autoAddedPeers:s.filter(i=>n.has(i.name))}}computeFlags(e){let t=new Set(e.flatMap(i=>kr(i.meta))),n=new Map;for(let i of e)for(let o of ra(i.meta))n.set(o,(n.get(o)||0)+1);let s=new Set([...n.entries()].filter(([,i])=>i>=2).map(([i])=>i));return new Map(e.map(i=>[i.name,{isPeerRoot:t.has(i.name),hasPeers:kr(i.meta).length>0,isSharedDep:s.has(i.name)}]))}};var Er=class{constructor(e,t,n){this.cache=e,this.cdn=t,this.semver=n}selectVersionFromIndex(e,t,n){return this.semver.selectBestVersion(e,{range:t,distTags:n})}async learnExactVersion(e){let t=await V(()=>this.cdn.fetchVersionsIndex(e));if(t?.versions?.length){let n=this.semver.selectBestVersion(t.versions,{distTags:t.distTags});if(n)return n}return this.cdn.resolveExactVersion(e)}async resolveExactForRoot(e,t){if(!t)return this.learnExactVersion(e);let n=await this.cache.getPinnedExact(e,t);if(n){if(this.semver.isExactVersion(n))return n;console.debug("[typebulb] cached version for",e,"is not exact (",n,"); re-resolving from registry")}let s=await V(()=>this.cdn.fetchVersionsIndex(e));if(s?.versions?.length){let o=this.selectVersionFromIndex(s.versions,t,s.distTags);if(o){if(this.semver.isExactVersion(o))return await this.cache.setPinnedExact(e,t,o),o}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 a=await V(()=>this.cdn.fetchVersionsIndex(e));if(a?.versions?.length){let c=this.selectVersionFromIndex(a.versions,t,a.distTags);if(c&&this.semver.isExactVersion(c))return await this.cache.setPinnedExact(e,t,c),c}}}let i=await this.cdn.resolveExactVersion(`${e}@${t}`);if(i&&this.semver.isExactVersion(i))return await this.cache.setPinnedExact(e,t,i),i}async effectivePackage(e,t){let n=new T(e),s=n.root(),i=t[s],o=i?await V(()=>this.cache.getPinnedExact(s,i))??await V(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?n.withVersion(o).format():e,root:s,range:i,pinned:o}}};import{init as cw,parse as lw}from"es-module-lexer";var kt=class r{constructor(e,t,n,s){this.version=e,this.cdn=t,this.peer=n,this.cache=s}extractImportsSync(e){let t=new Set;for(let n of r.importPatterns){n.lastIndex=0;for(let s of e.matchAll(n))T.isBare(s[1])&&t.add(s[1])}return Array.from(t)}async extractImports(e){let t=new Set,n=s=>{T.isBare(s)&&t.add(s)};try{await cw;let[s]=lw(e);s.forEach(i=>n(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(t)}async buildImportMap(e,t,n){let s=(await this.extractImports(e)).filter(u=>!n?.has(T.rootOf(u))),i=[...new Set(s.map(T.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)),f=this.buildEntries([...s,...l.map(u=>u.name)],a,c,t);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,u])=>u)}}async resolveVersion(e,t){let n=t[e],s=n?`${e}@${n}`:e,i=await this.version.resolveExactForRoot(e,n);if(!i){let o=await V(()=>this.cdn.pinEsmUrl(s));if(!o)throw new Error(`Cannot resolve ${s}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);i=T.versionFromUrl(o),i&&n&&await V(()=>this.cache.setPinnedExact(e,n,i))}if(!i)throw new Error(`Cannot resolve ${s}: no concrete version found.`);return i}buildEntries(e,t,n,s){let i=new Map(t.map(m=>[m.name,m])),o=m=>{let h=i.get(T.rootOf(m));return new T(m).withPreferredVersion(h.version,s[h.name]).format()},a=new Set([...n.entries()].filter(([,m])=>m.isPeerRoot||m.isSharedDep).map(([m])=>m)),c=new Set(e.filter(m=>m!==T.rootOf(m)).map(T.rootOf)),l=[],f=new Set,u=new Set(e.filter(m=>m===T.rootOf(m))),d=new Set;for(let m of e){let h=T.rootOf(m),y=i.get(h),{isPeerRoot:v,hasPeers:k,isSharedDep:g}=n.get(h),b=c.has(h),w=m!==h,A=!(v||g)&&(b||!k),E=this.singletonDepsOf(y,a),N=w&&u.has(h);N&&d.add(h);let J=N?[...E,h]:E.length?E:void 0;l.push([m,this.cdn.buildEsmUrl(o(m),{bundle:A,external:J})]),f.add(m)}let p=new Set([...a,...d]);for(let m of p)i.has(m)&&(f.has(m)||l.push([m,this.cdn.buildEsmUrl(o(m),{})]),l.push([`${m}/`,`${this.cdn.esmHost}/${o(m)}/`]));return l}singletonDepsOf(e,t){return[...new Set([...kr(e.meta),...ra(e.meta)])].filter(n=>t.has(n))}};kt.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g];import{gt as Nf,satisfies as uw,maxSatisfying as na,major as fw,prerelease as dw,rsort as pw,valid as hw}from"semver";var ts=class{cmp(e,t){return e===t?0:Nf(e,t)?1:Nf(t,e)?-1:0}satisfies(e,t){return!e||!e.trim()?!0:!!uw(t,e,{includePrerelease:!0})}pickMaxSatisfying(e,t){if(!e?.length)return;let n=na(e,t,{includePrerelease:!0});return n===null?void 0:n}pickLatest(e){return e?.length?pw(e)[0]:void 0}selectBestVersion(e,t){if(!e?.length)return;let n=t?.range?.trim()||"*",s=t?.preferStable??!0,i=t?.distTags?.latest;if(i&&e.includes(i)&&this.satisfies(n,i))return i;if(s){let a=na(e,n,{includePrerelease:!1});if(a)return a}return na(e,n,{includePrerelease:!0})??void 0}majorOf(e){return fw(e)}isPrerelease(e){return dw(e)!==null}isExactVersion(e){return hw(e)!==null}},Ge=new ts;function Cf(r,e){let t=new Sr(r,e),n=new xr(t),s=new Er(r,t,Ge);return{packageService:new kt(s,t,n,r),versionResolver:s,cdnClient:t,peerResolver:n}}import*as Yf from"fs/promises";import*as ie from"path";var sa=[{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"}],ia=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];var If=`
|
|
300
472
|
/**
|
|
301
473
|
* Get raw data chunk from the Data tab.
|
|
302
474
|
* @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
|
|
@@ -307,7 +479,7 @@ Examples:
|
|
|
307
479
|
* @param index - Chunk index (0-based)
|
|
308
480
|
* @throws If chunk is not valid JSON/JSON-ish
|
|
309
481
|
*/
|
|
310
|
-
json<T = unknown>(index: number): T;`,
|
|
482
|
+
json<T = unknown>(index: number): T;`,Lf=`
|
|
311
483
|
/**
|
|
312
484
|
* Get the insight data produced by the inference layer.
|
|
313
485
|
*
|
|
@@ -316,7 +488,7 @@ Examples:
|
|
|
316
488
|
*
|
|
317
489
|
* @returns The parsed insight JSON, or undefined if no insight is available
|
|
318
490
|
*/
|
|
319
|
-
insight<T = unknown>(): T | undefined;`,
|
|
491
|
+
insight<T = unknown>(): T | undefined;`,_f=`options: {
|
|
320
492
|
messages: Array<{ role: "user" | "assistant"; content: string }>;
|
|
321
493
|
system?: string;
|
|
322
494
|
/** Reasoning depth hint (0=min, 1=low, 2=med, 3=high). Mapped to provider-specific parameters (e.g. Anthropic adaptive thinking, OpenAI reasoning effort). Default: 0. */
|
|
@@ -327,12 +499,12 @@ Examples:
|
|
|
327
499
|
webSearch?: boolean;
|
|
328
500
|
/** Abort the request. On abort the promise rejects / the stream ends. */
|
|
329
501
|
signal?: AbortSignal;
|
|
330
|
-
}
|
|
502
|
+
}`,$f=`
|
|
331
503
|
/** A single streamed delta from \`tb.ai.stream()\`. Discriminated by \`kind\`. */
|
|
332
504
|
type AiChunk =
|
|
333
505
|
| { kind: "text"; text: string }
|
|
334
506
|
| { kind: "reasoning"; text: string };
|
|
335
|
-
|
|
507
|
+
`,Mf=`
|
|
336
508
|
/**
|
|
337
509
|
* General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
|
|
338
510
|
* returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
|
|
@@ -341,7 +513,7 @@ type AiChunk =
|
|
|
341
513
|
* @throws On rate limit, network error, or provider error
|
|
342
514
|
*/
|
|
343
515
|
ai: {
|
|
344
|
-
(${
|
|
516
|
+
(${_f}): Promise<{ text: string }>;
|
|
345
517
|
/**
|
|
346
518
|
* Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
|
|
347
519
|
* as they arrive; break the loop (or abort \`signal\`) to cancel and stop the upstream.
|
|
@@ -355,8 +527,8 @@ type AiChunk =
|
|
|
355
527
|
* if (c.kind === "text") answer += c.text;
|
|
356
528
|
* }
|
|
357
529
|
*/
|
|
358
|
-
stream(${
|
|
359
|
-
};`,
|
|
530
|
+
stream(${_f}): AsyncIterable<AiChunk>;
|
|
531
|
+
};`,Df=`
|
|
360
532
|
/**
|
|
361
533
|
* Returns AI models available to the current user.
|
|
362
534
|
* Models are filtered by the user's configured API keys.
|
|
@@ -371,7 +543,7 @@ type AiChunk =
|
|
|
371
543
|
friendlyName: string;
|
|
372
544
|
/** Provider display name, e.g. "Anthropic" */
|
|
373
545
|
providerName: string;
|
|
374
|
-
}>>;`,
|
|
546
|
+
}>>;`,mw="\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;",Bf=`
|
|
375
547
|
/**
|
|
376
548
|
* The mode this bulb is running in.
|
|
377
549
|
*
|
|
@@ -381,7 +553,7 @@ type AiChunk =
|
|
|
381
553
|
* - \`'embedded'\` \u2014 Running as a bulb embedded inside another bulb (sandboxed,
|
|
382
554
|
* client-only: AI, filesystem, and server RPC are unavailable)
|
|
383
555
|
*/
|
|
384
|
-
mode: 'local' | 'editor' | 'published' | 'embedded';`,
|
|
556
|
+
mode: 'local' | 'editor' | 'published' | 'embedded';`,jf=`
|
|
385
557
|
/**
|
|
386
558
|
* Local filesystem access (CLI only).
|
|
387
559
|
*
|
|
@@ -396,7 +568,7 @@ type AiChunk =
|
|
|
396
568
|
readBytes(path: string): Promise<Uint8Array>;
|
|
397
569
|
/** Write text or raw bytes to a file. Creates parent directories if needed. */
|
|
398
570
|
write(path: string, content: string | Uint8Array): Promise<boolean>;
|
|
399
|
-
};`,
|
|
571
|
+
};`,gw=`
|
|
400
572
|
/**
|
|
401
573
|
* Server-side function proxy. The built-in \`log\` prints to CLI stdout
|
|
402
574
|
* (falls back to console.log on web). On the server side, this object only
|
|
@@ -404,7 +576,7 @@ type AiChunk =
|
|
|
404
576
|
*/
|
|
405
577
|
server: {
|
|
406
578
|
log(...args: any[]): Promise<void>;
|
|
407
|
-
};`,
|
|
579
|
+
};`,yw=`
|
|
408
580
|
/**
|
|
409
581
|
* Async value inspector for tensor-like objects.
|
|
410
582
|
*
|
|
@@ -471,7 +643,7 @@ type AiChunk =
|
|
|
471
643
|
*
|
|
472
644
|
* @returns The full canonical URL
|
|
473
645
|
*/
|
|
474
|
-
url(): Promise<string>;`,
|
|
646
|
+
url(): Promise<string>;`,bw=`
|
|
475
647
|
/**
|
|
476
648
|
* Subscribe to a value pushed from the terminal via \`typebulb send <file> [message]\`.
|
|
477
649
|
*
|
|
@@ -486,23 +658,23 @@ type AiChunk =
|
|
|
486
658
|
* @param handler - Called with each pushed message.
|
|
487
659
|
* @returns An unsubscribe function.
|
|
488
660
|
*/
|
|
489
|
-
onMessage(handler: (message: any) => void): () => void;`,
|
|
661
|
+
onMessage(handler: (message: any) => void): () => void;`,ww="\n /**\n * Server-side function proxy.\n *\n * In the CLI, calls exported functions from the `**server.ts**` section.\n * `tb.server.log(...)` is a built-in that prints to CLI stdout (falls back to console.log on web).\n * User exports override built-ins of the same name.\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>>;",oa=`${$f}
|
|
490
662
|
/**
|
|
491
663
|
* Typebulb utilities namespace.
|
|
492
664
|
* Type \`tb.\` to discover available helpers.
|
|
493
665
|
*/
|
|
494
|
-
declare const tb: {${
|
|
666
|
+
declare const tb: {${If}${yw}${Lf}${ww}${bw}${Mf}${jf}${Df}${mw}${Bf}
|
|
495
667
|
};
|
|
496
|
-
`,
|
|
668
|
+
`,aa=`${$f}
|
|
497
669
|
/**
|
|
498
670
|
* Typebulb utilities namespace (server-side).
|
|
499
671
|
* Type \`tb.\` to discover available helpers.
|
|
500
672
|
*/
|
|
501
|
-
declare const tb: {${
|
|
673
|
+
declare const tb: {${If}${Lf}${Mf}${jf}${gw}${Df}${Bf}
|
|
502
674
|
};
|
|
503
|
-
`;var Ye=class{constructor(e){this.store=e}async isNegative(e){let t=await ts(()=>this.store.get(e));return!!t&&t.until>Date.now()}async recordNegative(e){let n=((await ts(()=>this.store.get(e)))?.attempts||0)+1;await ts(()=>this.store.set(e,{until:Date.now()+dw(n),attempts:n}))}async clearNegative(e){await ts(()=>this.store.delete(e))}};function dw(r){return Math.min(9e5*Math.pow(2,Math.max(0,r-1)),864e5)}async function ts(r){try{return await r()}catch{return}}import bw from"p-limit";import{resolve as jf}from"resolve.exports";var xt=class{constructor(e){this.fetchDts=e}fetchDtsText(e){return this.tryUrls([e])}async tryUrls(e){for(let t of e){let n=await this.fetchDts(t);if(n&&(this.looksLikeDts(n.dts)||/\.(d\.ts|d\.mts)(?:[?#].*)?$/i.test(n.url)||/[?&]dts(?:[&#]|$)/i.test(n.url)))return n}}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)}};var Le={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},Er=["index.d.ts","index.d.mts"],Ar=/\.d\.(ts|mts)$/i;function aa(r){if(Ar.test(r))return!0;try{return new URL(r,"file://").search.includes("dts")}catch{return r.includes("?")&&r.includes("dts")}}function Et(r){return[`${r}.d.ts`,`${r}.d.mts`]}async function Tr(r,{retries:e=2,timeoutMs:t=15e3,init:n}={}){for(let s=0;s<=e;s++){let i=new AbortController,o=setTimeout(()=>i.abort(),t);try{let a=await fetch(r,{...n,signal:i.signal});if(pw(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function pw(r){return r===408||r===429||r>=500&&r<600}var Or=class extends xt{constructor(e,t){super(e),this.cdnClient=t}async loadPackageAtVersionedRoot(e,t){let n=this.cdnClient.packageJson(new T({name:e,version:t})),s=await Tr(n);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new T({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 n of e){let s=await t(n);if(s)return s}}async resolveFromSelected(e,t){if(e.kind==="types"){let s=this.cdnClient.normalizeRelative(e.path);if(!s||s==="/"||s===".")return this.tryUntilSuccess([...Er],t);if(!Ar.test(s)){let i=await this.tryUntilSuccess(this.declarationCandidatesFor(s),t);if(i)return i}return t(s)}let n=this.declarationCandidatesFor(e.path);return this.tryUntilSuccess([...Er,...n],t)}toResolutionResult(e){return{kind:Ar.test(e)?"types":"probe",path:e}}resolveExportsPath(e,t){let n=t||".",s=e;try{let i=this.extractPathFromResult(jf(s,n,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(jf(s,n,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let t=T.parse(e),{pkg:n,baseDir:s}=await this.loadPackageAtVersionedRoot(t.name,t.version)||{};if(!n||!s)return;let i={name:t.name,version:t.version},o=new T(i).format(),a=new T({...i,subpath:t.subpath}).format(),c=u=>this.fetchCandidateFrom(s,t.name,u);if(t.subpath){let u=this.cdnClient.ensureLeadingDotSlash(t.subpath),d=this.resolveExportsPath(n,u);if(d){let m=await this.resolveFromSelected(this.toResolutionResult(d),c);if(m)return{...m,resolvedPkg:a}}let p=await this.tryUntilSuccess(this.declarationCandidatesFor(u),c);if(p)return{...p,resolvedPkg:a}}let l=n.types??n.typings;if(l){let u=await this.resolveFromSelected({kind:"types",path:l},c);if(u)return{...u,resolvedPkg:o}}let f=this.resolveExportsPath(n,".");if(f){let u=await this.resolveFromSelected(this.toResolutionResult(f),c);if(u)return{...u,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,t,n){let s=this.cdnClient.normalizeRelative(n),i=new URL(s,e).toString(),o=await this.fetchDtsText(i);return o?{dts:o.dts,url:o.url,resolvedPkg:t}:void 0}declarationCandidatesFor(e){if(!e||e==="./"||e==="/")return[...Er];let t=e.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=Et(t),s=t.endsWith("/")?t:`${t}/`;return n.push(...Et(`${s}index`)),n}};import{gunzipSync as hw}from"fflate";var At=class{async fetchAndExtract(e,t){let n=this.getTarballUrl(e,t),s=await Tr(n,{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\//,""),n=t.indexOf("/");return n>0?t.substring(n+1):t}extractDtsFiles(e){let t=new Map;try{let n=hw(e),s=new TextDecoder("utf-8"),i=0;for(;i<n.length-512;){let o=n.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(),f=o.slice(124,136),u=s.decode(f).trim().replace(/\0/g,""),d=parseInt(u,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(l.endsWith(".d.ts")||l.endsWith(".d.mts"))){let m=n.slice(i,i+d);t.set(this.normalizeTarPath(l),s.decode(m))}i+=Math.ceil(d/512)*512}}catch{}return t}},mw=new At;var Pr=class extends xt{constructor(e,t,n,s=new At){super(e),this.cdnClient=t,this.cache=n,this.tarballFetcher=s}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,n){try{if(n){let i=He.majorOf(n),o=e.filter(a=>He.majorOf(a)===i);if(o.length)return o.sort((a,c)=>He.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,""),n=[...Et(t),`${t}/index.d.ts`,`${t}/index.d.mts`];return t!==e&&n.push(`${e}.d.ts`,`${e}/index.d.ts`),n}async fetchFromVersionedRoot(e,t){let n=new T(e),s=n.version;if(!s)return;let i;try{i=await this.tarballFetcher.fetchAndExtract(n.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 T(t).format():t.name}}}async resolve(e){let t=T.parse(e);if(t.name)for(let n of this.typesNameCandidates(t.name)){let s=`@types/${n}`,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 Nr=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=new Set,n=(s,i)=>(t.add(s[i]),null);return this.matchAll(e,/(import|export)\s+[^'"\n]*from\s*['"]([^'"\n]+)['"]/,s=>n(s,2)),this.matchAll(e,/export\s*\*\s*from\s*['"]([^'"\n]+)['"]/,s=>n(s,1)),Array.from(t)}matchAll(e,t,n){let s=[];try{let i=new RegExp(t.source,"g"),o;for(;o=i.exec(e);){let a=n(o);a!==null&&s.push(a)}}catch{}return s}isBare(e){return!(e.startsWith("./")||e.startsWith("../")||e.startsWith("file:")||e.startsWith("http://")||e.startsWith("https://"))}};var qf="file:///node_modules",Cr=class{constructor(){this.epoch=0,this.listeners=new Set}getEpoch(){return this.epoch}bumpEpoch(){this.epoch+=1;for(let e of this.listeners)try{e(this.epoch)}catch{}return this.epoch}onEpochChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${qf}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,t){let n=gw(t);return`${qf}/${this.epochDir()}/${e}/${n}`}};function gw(r){let e=r||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}import{LRUCache as yw}from"lru-cache";function ca(r){let e=new yw({ttl:1e4,max:500}),t=new Map;return async function(s){try{if(await r.isNegative(s))return;let i=e.get(s);if(i&&Date.now()-i<1e4)return;let o=await r.getCachedFile(s);if(o)return{dts:o,url:s};let a=t.get(s);if(a)return a;let c=(async()=>{let l=await fetch(s,{cache:"no-store"});if(!l.ok){l.status===404&&(e.set(s,Date.now()),await r.recordNegative(s));return}let f=await l.text(),u=l.url||s;return await r.clearNegative(s),await r.setCachedFile(u,f),{dts:f,url:u}})();return t.set(s,c),await c.finally(()=>t.delete(s))}catch{return}}}var rs=class{constructor(e){this.inFlight=new Map,this.scanner=new Nr,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=ca(e.cache),this.typescriptProvider=new Or(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new Pr(this.fetchDts,e.cdnClient,e.cache),this.virtualFs=new Cr}withInFlight(e,t){let n=this.inFlight.get(e);if(n)return n;let s=t().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,s),s}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}capArray(e,t){return e.length<=t?e:e.slice(0,t)}pushFileIfNew(e,t,n){e.some(s=>s.path===t)||e.push({path:t,content:n})}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 trySubpathWithRootFallback(e,t){let n=new T(e);return n.subpath?this.fetchRootDts(n.name,t):void 0}async fetchViaProviders(e){for(let t of[this.typescriptProvider,this.definitelyTypedProvider])try{let n=await t.resolve(e);if(n?.dts)return n}catch{}}subpathsMatch(e,t){return new T(e).subpath===new T(t).subpath}async fetchRootDts(e,t){let{effectivePackage:n,root:s,pinned:i}=await this.versionResolver.effectivePackage(e,t),o=await this.cache.getCachedDts(n);if(o?.content){let c=o.url??this.cdnClient.file(i?`${s}@${i}`:s,"index.d.ts");return{dts:o.content,url:c,resolvedPkg:n}}let a;try{a=await this.fetchViaProviders(n)}catch{return}if(!(!a?.dts||!a.url)){try{await this.cache.setCachedFile(a.url,a.dts)}catch{}if(this.subpathsMatch(n,a.resolvedPkg||n)){try{await this.cache.setCachedDts(n,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,n){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(n,s)}computeEntryPath(e,t){if(!e)return{mainPath:this.virtualFs.pathForMain(t),packageRootUrl:void 0};let n=new URL(e),s=this.extractPackageRootUrl(n);return{mainPath:this.toVirtualPath(s,n,t),packageRootUrl:s}}async expandRelativeRefs(e,t,n,s,i=new Set,o){if(!i.has(t)&&(i.add(t),!(i.size>Le.maxRelativeTypeRefs)))try{let a=new URL(t),c=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let l=this.capArray(this.scanner.collectRelativeTypeRefs(e),Le.maxRelativeTypeRefs);for(let f of l)await this.tryRelativeRef(f,c,o,n,s,i)}catch{}}async tryRelativeRef(e,t,n,s,i,o){try{let a=new URL(e,t),c=a.pathname+a.search,l=aa(c)?[c]:this.typescriptProvider.declarationCandidatesFor(c);for(let f of l){let d=new URL(f,a).toString();if(o.has(d))return;let p=await this.fetchDts(d);if(p?.dts){let m=this.toVirtualPath(n,new URL(p.url),s);this.pushFileIfNew(i,m,p.dts),await this.expandRelativeRefs(p.dts,p.url,s,i,o,n);return}}}catch{}}isDifferentPackage(e,t){return e===t?!1:new T(e).name!==new T(t).name}ambientlyDeclares(e,t){for(let n of e.matchAll(/declare\s+module\s+['"]([^'"]+)['"]/g)){let s=n[1];if(s===t||s.endsWith("/*")&&t.startsWith(s.slice(0,-1)))return!0}return!1}markFileAmbient(e,t){let n=e.find(s=>s.path===t);n&&(n.ambient=!0)}async prefetchBareDeps(e,t,n,s,i){try{let o=this.capArray(this.scanner.collectBareModuleRefs(e),Le.maxBareDeps).filter(l=>this.isDifferentPackage(l,t));if(!o.length)return;let a=new Set([t]),c=bw(Le.prefetchConcurrency);await Promise.all(o.map(l=>c(()=>this.prefetchBareDepsRecursive(l,n,s,Le.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,t,n,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):n.push({module:e,path:l}),a.url&&await this.expandRelativeRefs(a.dts,a.url,c,t);let f=this.capArray(this.scanner.collectBareModuleRefs(a.dts),Le.maxBareDeps).filter(u=>!i.has(u));for(let u of f)await this.prefetchBareDepsRecursive(u,t,n,s-1,i,o)}async resolve(e,t,n){let s=await this.packageService.extractImports(e),i=n?[...s,...n]:s;return(await Promise.all(i.map(a=>this.resolveOne(a,t)))).filter(a=>!!a)}async resolveOne(e,t){let{effectivePackage:n}=await this.versionResolver.effectivePackage(e,t);return this.withInFlight(n,async()=>{let s=await this.fetchRootDts(e,t)??await this.trySubpathWithRootFallback(e,t);return s?this.buildDefFromContent(e,s,s.resolvedPkg||e,t):this.createStubDef(e)})}async buildDefFromContent(e,t,n,s){let{dts:i,url:o,resolvedPkg:a}=t,c=new T(a||n),l=c.version?`${c.name}@${c.version}`:c.name,{mainPath:f,packageRootUrl:u}=this.computeEntryPath(o,l),d=[{path:f,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,l,d,void 0,u);let m=d.map(k=>k.content).join(`
|
|
504
|
-
`);await this.prefetchBareDeps(m,l,d,p,s);let h=c.format(),y=e===h?[e]:[e,h],v=y.some(k=>this.ambientlyDeclares(i,k));return v?this.markFileAmbient(d,f):p.push(...y.map(k=>({module:k,path:f}))),{pkg:e,mainPath:f,files:d,shims:p,ambient:v}}};function
|
|
505
|
-
`,"utf8")}async function
|
|
675
|
+
`;var ze=class{constructor(e){this.store=e}async isNegative(e){let t=await rs(()=>this.store.get(e));return!!t&&t.until>Date.now()}async recordNegative(e){let n=((await rs(()=>this.store.get(e)))?.attempts||0)+1;await rs(()=>this.store.set(e,{until:Date.now()+vw(n),attempts:n}))}async clearNegative(e){await rs(()=>this.store.delete(e))}};function vw(r){return Math.min(9e5*Math.pow(2,Math.max(0,r-1)),864e5)}async function rs(r){try{return await r()}catch{return}}import Tw from"p-limit";import{resolve as qf}from"resolve.exports";var xt=class{constructor(e){this.fetchDts=e}fetchDtsText(e){return this.tryUrls([e])}async tryUrls(e){for(let t of e){let n=await this.fetchDts(t);if(n&&(this.looksLikeDts(n.dts)||/\.(d\.ts|d\.mts)(?:[?#].*)?$/i.test(n.url)||/[?&]dts(?:[&#]|$)/i.test(n.url)))return n}}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)}};var Le={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},Ar=["index.d.ts","index.d.mts"],Tr=/\.d\.(ts|mts)$/i;function ca(r){if(Tr.test(r))return!0;try{return new URL(r,"file://").search.includes("dts")}catch{return r.includes("?")&&r.includes("dts")}}function Et(r){return[`${r}.d.ts`,`${r}.d.mts`]}async function Or(r,{retries:e=2,timeoutMs:t=15e3,init:n}={}){for(let s=0;s<=e;s++){let i=new AbortController,o=setTimeout(()=>i.abort(),t);try{let a=await fetch(r,{...n,signal:i.signal});if(Sw(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function Sw(r){return r===408||r===429||r>=500&&r<600}var Pr=class extends xt{constructor(e,t){super(e),this.cdnClient=t}async loadPackageAtVersionedRoot(e,t){let n=this.cdnClient.packageJson(new T({name:e,version:t})),s=await Or(n);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new T({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 n of e){let s=await t(n);if(s)return s}}async resolveFromSelected(e,t){if(e.kind==="types"){let s=this.cdnClient.normalizeRelative(e.path);if(!s||s==="/"||s===".")return this.tryUntilSuccess([...Ar],t);if(!Tr.test(s)){let i=await this.tryUntilSuccess(this.declarationCandidatesFor(s),t);if(i)return i}return t(s)}let n=this.declarationCandidatesFor(e.path);return this.tryUntilSuccess([...Ar,...n],t)}toResolutionResult(e){return{kind:Tr.test(e)?"types":"probe",path:e}}resolveExportsPath(e,t){let n=t||".",s=e;try{let i=this.extractPathFromResult(qf(s,n,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(qf(s,n,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let t=T.parse(e),{pkg:n,baseDir:s}=await this.loadPackageAtVersionedRoot(t.name,t.version)||{};if(!n||!s)return;let i={name:t.name,version:t.version},o=new T(i).format(),a=new T({...i,subpath:t.subpath}).format(),c=u=>this.fetchCandidateFrom(s,t.name,u);if(t.subpath){let u=this.cdnClient.ensureLeadingDotSlash(t.subpath),d=this.resolveExportsPath(n,u);if(d){let m=await this.resolveFromSelected(this.toResolutionResult(d),c);if(m)return{...m,resolvedPkg:a}}let p=await this.tryUntilSuccess(this.declarationCandidatesFor(u),c);if(p)return{...p,resolvedPkg:a}}let l=n.types??n.typings;if(l){let u=await this.resolveFromSelected({kind:"types",path:l},c);if(u)return{...u,resolvedPkg:o}}let f=this.resolveExportsPath(n,".");if(f){let u=await this.resolveFromSelected(this.toResolutionResult(f),c);if(u)return{...u,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,t,n){let s=this.cdnClient.normalizeRelative(n),i=new URL(s,e).toString(),o=await this.fetchDtsText(i);return o?{dts:o.dts,url:o.url,resolvedPkg:t}:void 0}declarationCandidatesFor(e){if(!e||e==="./"||e==="/")return[...Ar];let t=e.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=Et(t),s=t.endsWith("/")?t:`${t}/`;return n.push(...Et(`${s}index`)),n}};import{gunzipSync as kw}from"fflate";var At=class{async fetchAndExtract(e,t){let n=this.getTarballUrl(e,t),s=await Or(n,{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\//,""),n=t.indexOf("/");return n>0?t.substring(n+1):t}extractDtsFiles(e){let t=new Map;try{let n=kw(e),s=new TextDecoder("utf-8"),i=0;for(;i<n.length-512;){let o=n.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(),f=o.slice(124,136),u=s.decode(f).trim().replace(/\0/g,""),d=parseInt(u,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(l.endsWith(".d.ts")||l.endsWith(".d.mts"))){let m=n.slice(i,i+d);t.set(this.normalizeTarPath(l),s.decode(m))}i+=Math.ceil(d/512)*512}}catch{}return t}},xw=new At;var Rr=class extends xt{constructor(e,t,n,s=new At){super(e),this.cdnClient=t,this.cache=n,this.tarballFetcher=s}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,n){try{if(n){let i=Ge.majorOf(n),o=e.filter(a=>Ge.majorOf(a)===i);if(o.length)return o.sort((a,c)=>Ge.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,""),n=[...Et(t),`${t}/index.d.ts`,`${t}/index.d.mts`];return t!==e&&n.push(`${e}.d.ts`,`${e}/index.d.ts`),n}async fetchFromVersionedRoot(e,t){let n=new T(e),s=n.version;if(!s)return;let i;try{i=await this.tarballFetcher.fetchAndExtract(n.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 T(t).format():t.name}}}async resolve(e){let t=T.parse(e);if(t.name)for(let n of this.typesNameCandidates(t.name)){let s=`@types/${n}`,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 Nr=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=new Set,n=(s,i)=>(t.add(s[i]),null);return this.matchAll(e,/(import|export)\s+[^'"\n]*from\s*['"]([^'"\n]+)['"]/,s=>n(s,2)),this.matchAll(e,/export\s*\*\s*from\s*['"]([^'"\n]+)['"]/,s=>n(s,1)),Array.from(t)}matchAll(e,t,n){let s=[];try{let i=new RegExp(t.source,"g"),o;for(;o=i.exec(e);){let a=n(o);a!==null&&s.push(a)}}catch{}return s}isBare(e){return!(e.startsWith("./")||e.startsWith("../")||e.startsWith("file:")||e.startsWith("http://")||e.startsWith("https://"))}};var Ff="file:///node_modules",Cr=class{constructor(){this.epoch=0,this.listeners=new Set}getEpoch(){return this.epoch}bumpEpoch(){this.epoch+=1;for(let e of this.listeners)try{e(this.epoch)}catch{}return this.epoch}onEpochChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${Ff}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,t){let n=Ew(t);return`${Ff}/${this.epochDir()}/${e}/${n}`}};function Ew(r){let e=r||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}import{LRUCache as Aw}from"lru-cache";function la(r){let e=new Aw({ttl:1e4,max:500}),t=new Map;return async function(s){try{if(await r.isNegative(s))return;let i=e.get(s);if(i&&Date.now()-i<1e4)return;let o=await r.getCachedFile(s);if(o)return{dts:o,url:s};let a=t.get(s);if(a)return a;let c=(async()=>{let l=await fetch(s,{cache:"no-store"});if(!l.ok){l.status===404&&(e.set(s,Date.now()),await r.recordNegative(s));return}let f=await l.text(),u=l.url||s;return await r.clearNegative(s),await r.setCachedFile(u,f),{dts:f,url:u}})();return t.set(s,c),await c.finally(()=>t.delete(s))}catch{return}}}var ns=class{constructor(e){this.inFlight=new Map,this.scanner=new Nr,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=la(e.cache),this.typescriptProvider=new Pr(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new Rr(this.fetchDts,e.cdnClient,e.cache),this.virtualFs=new Cr}withInFlight(e,t){let n=this.inFlight.get(e);if(n)return n;let s=t().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,s),s}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}capArray(e,t){return e.length<=t?e:e.slice(0,t)}pushFileIfNew(e,t,n){e.some(s=>s.path===t)||e.push({path:t,content:n})}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 trySubpathWithRootFallback(e,t){let n=new T(e);return n.subpath?this.fetchRootDts(n.name,t):void 0}async fetchViaProviders(e){for(let t of[this.typescriptProvider,this.definitelyTypedProvider])try{let n=await t.resolve(e);if(n?.dts)return n}catch{}}subpathsMatch(e,t){return new T(e).subpath===new T(t).subpath}async fetchRootDts(e,t){let{effectivePackage:n,root:s,pinned:i}=await this.versionResolver.effectivePackage(e,t),o=await this.cache.getCachedDts(n);if(o?.content){let c=o.url??this.cdnClient.file(i?`${s}@${i}`:s,"index.d.ts");return{dts:o.content,url:c,resolvedPkg:n}}let a;try{a=await this.fetchViaProviders(n)}catch{return}if(!(!a?.dts||!a.url)){try{await this.cache.setCachedFile(a.url,a.dts)}catch{}if(this.subpathsMatch(n,a.resolvedPkg||n)){try{await this.cache.setCachedDts(n,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,n){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(n,s)}computeEntryPath(e,t){if(!e)return{mainPath:this.virtualFs.pathForMain(t),packageRootUrl:void 0};let n=new URL(e),s=this.extractPackageRootUrl(n);return{mainPath:this.toVirtualPath(s,n,t),packageRootUrl:s}}async expandRelativeRefs(e,t,n,s,i=new Set,o){if(!i.has(t)&&(i.add(t),!(i.size>Le.maxRelativeTypeRefs)))try{let a=new URL(t),c=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let l=this.capArray(this.scanner.collectRelativeTypeRefs(e),Le.maxRelativeTypeRefs);for(let f of l)await this.tryRelativeRef(f,c,o,n,s,i)}catch{}}async tryRelativeRef(e,t,n,s,i,o){try{let a=new URL(e,t),c=a.pathname+a.search,l=ca(c)?[c]:this.typescriptProvider.declarationCandidatesFor(c);for(let f of l){let d=new URL(f,a).toString();if(o.has(d))return;let p=await this.fetchDts(d);if(p?.dts){let m=this.toVirtualPath(n,new URL(p.url),s);this.pushFileIfNew(i,m,p.dts),await this.expandRelativeRefs(p.dts,p.url,s,i,o,n);return}}}catch{}}isDifferentPackage(e,t){return e===t?!1:new T(e).name!==new T(t).name}ambientlyDeclares(e,t){for(let n of e.matchAll(/declare\s+module\s+['"]([^'"]+)['"]/g)){let s=n[1];if(s===t||s.endsWith("/*")&&t.startsWith(s.slice(0,-1)))return!0}return!1}markFileAmbient(e,t){let n=e.find(s=>s.path===t);n&&(n.ambient=!0)}async prefetchBareDeps(e,t,n,s,i){try{let o=this.capArray(this.scanner.collectBareModuleRefs(e),Le.maxBareDeps).filter(l=>this.isDifferentPackage(l,t));if(!o.length)return;let a=new Set([t]),c=Tw(Le.prefetchConcurrency);await Promise.all(o.map(l=>c(()=>this.prefetchBareDepsRecursive(l,n,s,Le.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,t,n,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):n.push({module:e,path:l}),a.url&&await this.expandRelativeRefs(a.dts,a.url,c,t);let f=this.capArray(this.scanner.collectBareModuleRefs(a.dts),Le.maxBareDeps).filter(u=>!i.has(u));for(let u of f)await this.prefetchBareDepsRecursive(u,t,n,s-1,i,o)}async resolve(e,t,n){let s=await this.packageService.extractImports(e),i=n?[...s,...n]:s;return(await Promise.all(i.map(a=>this.resolveOne(a,t)))).filter(a=>!!a)}async resolveOne(e,t){let{effectivePackage:n}=await this.versionResolver.effectivePackage(e,t);return this.withInFlight(n,async()=>{let s=await this.fetchRootDts(e,t)??await this.trySubpathWithRootFallback(e,t);return s?this.buildDefFromContent(e,s,s.resolvedPkg||e,t):this.createStubDef(e)})}async buildDefFromContent(e,t,n,s){let{dts:i,url:o,resolvedPkg:a}=t,c=new T(a||n),l=c.version?`${c.name}@${c.version}`:c.name,{mainPath:f,packageRootUrl:u}=this.computeEntryPath(o,l),d=[{path:f,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,l,d,void 0,u);let m=d.map(k=>k.content).join(`
|
|
676
|
+
`);await this.prefetchBareDeps(m,l,d,p,s);let h=c.format(),y=e===h?[e]:[e,h],v=y.some(k=>this.ambientlyDeclares(i,k));return v?this.markFileAmbient(d,f):p.push(...y.map(k=>({module:k,path:f}))),{pkg:e,mainPath:f,files:d,shims:p,ambient:v}}};function ua(r){return new ns(r)}import*as fe from"fs/promises";import*as be from"path";import*as Kf from"os";import*as fa from"fs/promises";import*as Uf from"crypto";function se(r){return Uf.createHash("sha1").update(r).digest("hex")}async function Qe(r){try{return JSON.parse(await fa.readFile(r,"utf8"))}catch{return}}async function ss(r){try{return await fa.readFile(r,"utf8")}catch{return}}var Jf=1,$e=be.join(Kf.homedir(),".typebulb","cache"),_r=be.join($e,"packages"),Ir=be.join($e,"proxy"),is=be.join($e,"dts"),Ow=be.join($e,"emit"),da;function _(){return da||(da=Pw()),da}function os(r,e){return be.join(Ow,se(r),e)}async function Pw(){await fe.mkdir($e,{recursive:!0});let r=be.join($e,"version.json");if((await Rw(r))?.version===Jf)return;let t=await fe.readdir($e).catch(()=>[]);await Promise.all(t.map(n=>fe.rm(be.join($e,n),{recursive:!0,force:!0}))),await fe.writeFile(r,JSON.stringify({version:Jf})+`
|
|
677
|
+
`,"utf8")}async function Rw(r){try{let e=await fe.readFile(r,"utf8");return JSON.parse(e)}catch{return}}import*as Me from"fs/promises";import*as Wf from"path";async function Z(r,e){await Me.mkdir(Wf.dirname(r),{recursive:!0});let t=`${r}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await Me.writeFile(t,e,"utf8"),await Me.rename(t,r).catch(async n=>{throw await Me.rm(t,{force:!0}).catch(()=>{}),n})}var Tt=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=Qe(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 n=await this.load();n.set(e,t),await this.persist(n)}async delete(e){let t=await this.load();t.delete(e)&&await this.persist(t)}async persist(e){await Z(this.filePath,JSON.stringify(Object.fromEntries(e)))}};var pa=ie.join(_r,"indexes"),Vf=ie.join(_r,"pinned"),Nw=ie.join(_r,"meta"),Cw=ie.join(_r,"negative.json"),Ot=Symbol("missing"),cs=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new ze(new Tt(Cw));async getPinnedExact(e,t){let n=`${e}@${t}`,s=this.pinnedMem.get(n);if(s!==void 0)return s===Ot?void 0:s;await _();let i=await ss(ie.join(Vf,se(n)+".txt"));return this.pinnedMem.set(n,i??Ot),i}async setPinnedExact(e,t,n){let s=`${e}@${t}`;this.pinnedMem.set(s,n),await _(),await Z(ie.join(Vf,se(s)+".txt"),n)}async getIndex(e){let t=this.indexMem.get(e);if(t!==void 0)return t===Ot?void 0:t;await _();let n=await Qe(ie.join(pa,as(e)+".json"));return this.indexMem.set(e,n??Ot),n}async setIndex(e,t,n){let s={versions:t,distTags:n,updatedAt:Date.now()};this.indexMem.set(e,s),await _(),await Z(ie.join(pa,as(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await Yf.rm(ie.join(pa,as(e)+".json"),{force:!0})}async isNegative(e){return await _(),this.negativeCache.isNegative(e)}async recordNegative(e){await _(),await this.negativeCache.recordNegative(e)}async clearNegative(e){await this.negativeCache.clearNegative(e)}async getMeta(e,t){let n=`${e}@${t}`,s=this.metaMem.get(n);if(s!==void 0)return s===Ot?void 0:s;await _();let i=await Qe(Hf(e,t));return this.metaMem.set(n,i??Ot),i}async setMeta(e,t,n,s,i){let o={dependencies:n,peerDependencies:s,peerDependenciesMeta:i,updatedAt:Date.now()};this.metaMem.set(`${e}@${t}`,o),await _(),await Z(Hf(e,t),JSON.stringify(o))}};function Hf(r,e){return ie.join(Nw,as(r),encodeURIComponent(e)+".json")}function as(r){return r.replace(/\//g,"__")}var Gf={async getJson(r){try{let e=await fetch(r,{redirect:"follow"});return e.ok?await e.json():void 0}catch{return}},async head(r){try{let e=await fetch(r,{method:"HEAD",redirect:"follow"});return{ok:e.ok,url:e.url}}catch{return}}};var _w=new cs,{packageService:ls,versionResolver:zf,cdnClient:Qf,peerResolver:vT}=Cf(_w,Gf);var Xf=`
|
|
506
678
|
(() => {
|
|
507
679
|
// Embedded (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
|
|
508
680
|
// bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
|
|
@@ -830,11 +1002,11 @@ declare const tb: {${_f}${If}${$f}${Bf}${cw}${Mf}${Df}
|
|
|
830
1002
|
};
|
|
831
1003
|
}
|
|
832
1004
|
})();
|
|
833
|
-
`;function
|
|
1005
|
+
`;function us(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var fs=` *, *::before, *::after { box-sizing: border-box; }
|
|
834
1006
|
canvas { max-width: 100%; }
|
|
835
1007
|
body { margin: 0; display: flow-root; font-family: system-ui, -apple-system, sans-serif; }
|
|
836
1008
|
html[data-theme="dark"] { color-scheme: dark; }
|
|
837
|
-
html[data-theme="light"] { color-scheme: light; }`;function
|
|
1009
|
+
html[data-theme="light"] { color-scheme: light; }`;function ds(r,e){let t=n=>n.replace(/<\/script/gi,"<\\/script");return` <script>
|
|
838
1010
|
(function() {
|
|
839
1011
|
try {
|
|
840
1012
|
var KEY = ${t(JSON.stringify("tb-theme:"+r))};
|
|
@@ -869,19 +1041,19 @@ declare const tb: {${_f}${If}${$f}${Bf}${cw}${Mf}${Df}
|
|
|
869
1041
|
});
|
|
870
1042
|
} catch (e) {}
|
|
871
1043
|
})();
|
|
872
|
-
</script>`}function
|
|
873
|
-
html, body { height: 100%; }`,d=m=>m.replace(/<\/script/gi,"<\\/script"),p={imports:
|
|
1044
|
+
</script>`}function Zf(r){let{name:e,code:t,css:n,html:s,data:i,insight:o,importMap:a,theme:c,embedded:l}=r,f=s.trim()||'<div id="app"></div>',u=l?"":`
|
|
1045
|
+
html, body { height: 100%; }`,d=m=>m.replace(/<\/script/gi,"<\\/script"),p={imports:Lw(a.imports)};return`<!DOCTYPE html>
|
|
874
1046
|
<html>
|
|
875
1047
|
<head>
|
|
876
1048
|
<meta charset="utf-8">
|
|
877
1049
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
878
|
-
<title>${
|
|
879
|
-
${
|
|
1050
|
+
<title>${us(e)} - typebulb</title>
|
|
1051
|
+
${ds(e,c)}
|
|
880
1052
|
<script type="importmap">
|
|
881
1053
|
${JSON.stringify(p,null,2)}
|
|
882
1054
|
</script>
|
|
883
1055
|
<style>
|
|
884
|
-
${
|
|
1056
|
+
${fs}${u}
|
|
885
1057
|
</style>
|
|
886
1058
|
<style>
|
|
887
1059
|
${n}
|
|
@@ -894,17 +1066,17 @@ ${i.length>0?`<script>window.__TB_DATA__ = ${d(JSON.stringify(i))};</script>`:""
|
|
|
894
1066
|
${o?`<script>window.__TB_INSIGHT__ = ${d(JSON.stringify(o))};</script>`:""}
|
|
895
1067
|
|
|
896
1068
|
<script>
|
|
897
|
-
${
|
|
1069
|
+
${Xf}
|
|
898
1070
|
</script>
|
|
899
1071
|
|
|
900
|
-
${
|
|
1072
|
+
${Iw}
|
|
901
1073
|
|
|
902
1074
|
<script type="module">
|
|
903
1075
|
${d(t)}
|
|
904
1076
|
globalThis.__tbEntryRan = true; /* load-failure backstop \u2014 see embedProtocol */
|
|
905
1077
|
</script>
|
|
906
1078
|
</body>
|
|
907
|
-
</html>`}var
|
|
1079
|
+
</html>`}var Iw=`<script>
|
|
908
1080
|
(function () {
|
|
909
1081
|
var framed = window.parent !== window;
|
|
910
1082
|
var post = function (m) { try { parent.postMessage(m, '*'); } catch (e) {} }; /* framed only */
|
|
@@ -1000,206 +1172,51 @@ globalThis.__tbEntryRan = true; /* load-failure backstop \u2014 see embedProtoco
|
|
|
1000
1172
|
}
|
|
1001
1173
|
});
|
|
1002
1174
|
})();
|
|
1003
|
-
</script>`;function
|
|
1004
|
-
`,"utf8"),await U.writeFile(F.join(e,"code.tsx"),r.code,"utf8"),await U.writeFile(F.join(e,"tb.d.ts"),
|
|
1005
|
-
`,"utf8"),{dir:e}}function
|
|
1006
|
-
`);
|
|
1007
|
-
|
|
1008
|
-
**CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
|
|
1009
|
-
|
|
1010
|
-
\u2705 CORRECT - Package name only:
|
|
1011
|
-
\`\`\`typescript
|
|
1012
|
-
import React from "react"
|
|
1013
|
-
import _ from "lodash"
|
|
1014
|
-
\`\`\`
|
|
1015
|
-
|
|
1016
|
-
\u274C WRONG - Direct URL imports:
|
|
1017
|
-
\`\`\`typescript
|
|
1018
|
-
import React from "https://esm.sh/react"
|
|
1019
|
-
import _ from "https://cdn.skypack.dev/lodash"
|
|
1020
|
-
import x from "https://unpkg.com/some-package"
|
|
1021
|
-
\`\`\`
|
|
1022
|
-
|
|
1023
|
-
**Fix:** Use the package name only. Package resolution is handled automatically.`:r==="VERSION_SPECIFIER_IMPORT"?`Version specifiers in imports are not supported! Found on line ${e}.
|
|
1024
|
-
|
|
1025
|
-
**CRITICAL**: Import packages by name only. Do NOT include version numbers:
|
|
1026
|
-
|
|
1027
|
-
\u2705 CORRECT - Package name only:
|
|
1028
|
-
\`\`\`typescript
|
|
1029
|
-
import React from "react"
|
|
1030
|
-
import _ from "lodash"
|
|
1031
|
-
import { something } from "@scope/package"
|
|
1032
|
-
\`\`\`
|
|
1033
|
-
|
|
1034
|
-
\u274C WRONG - Version in import path:
|
|
1035
|
-
\`\`\`typescript
|
|
1036
|
-
import React from "react@18.2.0"
|
|
1037
|
-
import _ from "lodash@^4.17.0"
|
|
1038
|
-
import { x } from "@scope/package@1.0.0"
|
|
1039
|
-
\`\`\`
|
|
1040
|
-
|
|
1041
|
-
**Fix:** Remove the version specifier (everything from @ onwards). Versions are managed separately.`:r==="JS_EXTENSION_IMPORT"?`Deep import paths must NOT include \`.js\` extension! Found on line ${e}.
|
|
1042
|
-
|
|
1043
|
-
**CRITICAL**: Remove the \`.js\` extension from deep import paths (paths with \`/\`):
|
|
1044
|
-
|
|
1045
|
-
\u2705 CORRECT - No extension in deep import:
|
|
1046
|
-
\`\`\`typescript
|
|
1047
|
-
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"
|
|
1048
|
-
\`\`\`
|
|
1049
|
-
|
|
1050
|
-
\u274C WRONG - Has .js extension in deep import:
|
|
1051
|
-
\`\`\`typescript
|
|
1052
|
-
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js"
|
|
1053
|
-
\`\`\`
|
|
1054
|
-
|
|
1055
|
-
**Note:** Package names that literally end with ".js" (like \`decimal.js\`) are fine - this rule only applies to file paths within packages.
|
|
1056
|
-
|
|
1057
|
-
**Fix:** Remove \`.js\` from the end of the import path.`:r==="DYNAMIC_IMPORT"?`Dynamic imports are not supported! You used \`import('...')\` on line ${e}.
|
|
1058
|
-
|
|
1059
|
-
**CRITICAL**: All imports MUST be at the TOP of the file using standard ES6 import syntax:
|
|
1060
|
-
|
|
1061
|
-
\u2705 CORRECT - Static import at top of file:
|
|
1062
|
-
\`\`\`typescript
|
|
1063
|
-
import { createRoot } from 'react-dom/client'
|
|
1064
|
-
|
|
1065
|
-
// Later in code...
|
|
1066
|
-
const root = createRoot(rootElement)
|
|
1067
|
-
root.render(<App />)
|
|
1068
|
-
\`\`\`
|
|
1069
|
-
|
|
1070
|
-
\u274C WRONG - Dynamic import() in code:
|
|
1071
|
-
\`\`\`typescript
|
|
1072
|
-
// This is completely invalid!
|
|
1073
|
-
import('react-dom/client').then(({ createRoot }) => {
|
|
1074
|
-
const root = createRoot(rootElement)
|
|
1075
|
-
root.render(<App />)
|
|
1076
|
-
})
|
|
1077
|
-
\`\`\`
|
|
1078
|
-
|
|
1079
|
-
**Fix:** Move ALL import statements to the top of the file using standard \`import\` syntax.`:r==="REDUNDANT_TB_DECLARATION"?`Redundant \`declare const tb\` found on line ${e}.
|
|
1080
|
-
The \`tb\` global is already provided by the environment. Remove this declaration.`:r==="CONST_ENUM"?`\`const enum\` is not supported! Found on line ${e}.
|
|
1081
|
-
|
|
1082
|
-
**Fix:** Use a regular \`enum\` or an object with \`as const\`:
|
|
1083
|
-
|
|
1084
|
-
\`\`\`typescript
|
|
1085
|
-
// Option 1: Regular enum
|
|
1086
|
-
enum Direction { Up, Down, Left, Right }
|
|
1087
|
-
|
|
1088
|
-
// Option 2: Object literal (often better)
|
|
1089
|
-
const Direction = { Up: 0, Down: 1, Left: 2, Right: 3 } as const
|
|
1090
|
-
\`\`\`
|
|
1091
|
-
|
|
1092
|
-
\`const enum\` requires the full TypeScript compiler to inline values at compile time. Regular \`enum\` and object literals work identically at runtime.`:r==="NAMESPACE_DECLARATION"?`TypeScript \`namespace\` is not supported! Found on line ${e}.
|
|
1093
|
-
|
|
1094
|
-
**Fix:** Use ES modules instead:
|
|
1095
|
-
|
|
1096
|
-
\`\`\`typescript
|
|
1097
|
-
// Instead of: namespace MyLib { export function foo() {} }
|
|
1098
|
-
// Just use top-level exports:
|
|
1099
|
-
export function foo() {}
|
|
1100
|
-
\`\`\`
|
|
1101
|
-
|
|
1102
|
-
Namespaces are a legacy TypeScript pattern. Use standard ES module imports/exports instead.`:r==="COMMONJS_EXPORT_EQUALS"?`\`export =\` syntax is not supported! Found on line ${e}.
|
|
1103
|
-
|
|
1104
|
-
**Fix:** Use ES module \`export default\` instead:
|
|
1105
|
-
|
|
1106
|
-
\`\`\`typescript
|
|
1107
|
-
// Instead of: export = myValue
|
|
1108
|
-
export default myValue
|
|
1109
|
-
\`\`\``:r==="COMMONJS_IMPORT_EQUALS"?`\`import x =\` syntax is not supported! Found on line ${e}.
|
|
1110
|
-
|
|
1111
|
-
**Fix:** Use ES module \`import\` instead:
|
|
1112
|
-
|
|
1113
|
-
\`\`\`typescript
|
|
1114
|
-
// Instead of: import x = require('module')
|
|
1115
|
-
import x from 'module'
|
|
1116
|
-
\`\`\``:r==="MODULE_DECLARATION"?`TypeScript \`module\` declarations are not supported! Found on line ${e}.
|
|
1117
|
-
|
|
1118
|
-
**Fix:** Use ES modules instead. The \`module Foo {}\` syntax is a legacy TypeScript pattern \u2014 use standard imports/exports.`:r==="CSS_FILE_IMPORT"?`Importing CSS files is not supported! Found on line ${e}.
|
|
1119
|
-
|
|
1120
|
-
**CRITICAL**: CSS imports don't work here. The styles.css block is already applied to the page automatically.
|
|
1121
|
-
|
|
1122
|
-
\u2705 CORRECT - Just remove the import. CSS from the styles.css block is already applied to the page.
|
|
1123
|
-
|
|
1124
|
-
\u274C WRONG - Importing CSS as a file:
|
|
1125
|
-
\`\`\`typescript
|
|
1126
|
-
import "./styles.css"
|
|
1127
|
-
import styles from "./styles.css"
|
|
1128
|
-
\`\`\`
|
|
1129
|
-
|
|
1130
|
-
**Fix:** Delete the CSS import line entirely. Write styles in the styles.css block \u2014 they are loaded automatically.`:r==="NAVIGATION"?`Navigation is forbidden in this sandboxed environment! Found on line ${e}.
|
|
1131
|
-
|
|
1132
|
-
**CRITICAL**: \`window.location\` changes, \`window.open()\`, and page reloads will break the app.
|
|
1133
|
-
|
|
1134
|
-
\u2705 CORRECT - Reset application state programmatically:
|
|
1135
|
-
\`\`\`typescript
|
|
1136
|
-
setState(initialState)
|
|
1137
|
-
\`\`\`
|
|
1138
|
-
|
|
1139
|
-
\u274C WRONG - Browser navigation:
|
|
1140
|
-
\`\`\`typescript
|
|
1141
|
-
window.location.reload()
|
|
1142
|
-
window.location.href = "..."
|
|
1143
|
-
window.open("...")
|
|
1144
|
-
\`\`\`
|
|
1145
|
-
|
|
1146
|
-
**Fix:** Remove the navigation call. To "restart", reset your state variables instead.`:`CommonJS \`require()\` is not supported! Found on line ${e}.
|
|
1147
|
-
|
|
1148
|
-
**CRITICAL**: Use ES6 \`import\` statements at the TOP of the file:
|
|
1149
|
-
|
|
1150
|
-
\u2705 CORRECT - ES6 import:
|
|
1151
|
-
\`\`\`typescript
|
|
1152
|
-
import { something } from 'module-name'
|
|
1153
|
-
\`\`\`
|
|
1154
|
-
|
|
1155
|
-
\u274C WRONG - CommonJS require:
|
|
1156
|
-
\`\`\`typescript
|
|
1157
|
-
const something = require('module-name') // NOT SUPPORTED!
|
|
1158
|
-
\`\`\`
|
|
1159
|
-
|
|
1160
|
-
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}async function pd(r,e){let{bulb:t,config:n,warnings:s}=await oe(r);!t.code&&!t.server&&(console.error("Bulb has neither **code.tsx** nor **server.ts**; nothing to check."),process.exit(1));let i=!1;for(let l of s)console.log(`structure ${l}`);s.length&&(i=!0),t.code&&(i=dd(ba(t.code,{target:"client"}),"client")||i),t.server&&(i=dd(ba(t.server,{target:"server"}),"server")||i);let o=dv([process.cwd(),Be.dirname(r)]);if(!o){let l=Be.relative(process.cwd(),r)||r;console.error("check: TypeScript not found \u2014 install it once, then re-run:"),console.error(" npm i -g typescript"),console.error(` typebulb check ${l}`),process.exit(2)}let a=[];if(t.code){let{dir:l}=await ud({code:t.code,dependencies:n.dependencies??{},jsxImportSource:n.ts?.jsxImportSource,emitKey:r,local:e});a.push({role:"client",dir:l})}if(t.server){let{dir:l}=await fd({server:t.server,bulbDir:Be.dirname(r),emitKey:r,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:n.dependencies});a.push({role:"server",dir:l})}for(let{role:l,dir:f}of a){let{stdout:u,exitCode:d}=await uv(o,f);for(let p of u.split(/\r?\n/))p.trim()&&console.log(`${l} ${p}`);d!==0&&(i=!0)}i&&process.exit(1);let c=[t.code&&"code.tsx",t.server&&"server.ts"].filter(Boolean).join(", ");console.error(`\u2713 no issues (${c})`)}function dd(r,e){for(let t of r)for(let n of t.message.split(`
|
|
1161
|
-
`))console.log(`${e} ${n}`);return r.length>0}function uv(r,e){return new Promise(t=>{let n=ov(process.execPath,[r,"--noEmit"],{cwd:e}),s="";n.stdout?.on("data",i=>{s+=i.toString()}),n.stderr?.on("data",i=>{s+=i.toString()}),n.on("close",i=>t({stdout:s,exitCode:i??1}))})}var fv=cv(import.meta.url);function dv(r){let e=n=>{try{let s=fv.resolve("typescript/package.json",{paths:n}),i=Be.join(Be.dirname(s),"lib","tsc.js");return lv(i)?i:void 0}catch{return}},t=e(r);if(t)return t;try{let n=av("npm root -g",{encoding:"utf8"}).trim();return e([n])}catch{return}}Ss();$r();async function hd(r,e){let{bulb:t}=await oe(r),n=Rt(t);if(ze(r)){console.log("remembered-trusted \u2014 runs with filesystem / AI / server.ts automatically (`typebulb untrust` to revoke)."),n&&console.log(` (it uses ${n})`);return}n?(console.log(`This bulb appears to use ${n}; 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.)")}$r();import*as Dr from"path";async function md(r,e){if(!r){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let n=ga();if(!n.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 n)console.log(` ${s}`);return}let t=Dr.resolve(r);t.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),Pt(t,e),console.log(e?`Trusted ${Dr.basename(t)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${Dr.basename(t)} \u2014 runs Restricted.`),console.log(` ${t}`)}pe();import{readFileSync as xv,existsSync as Ev}from"fs";import*as tt from"path";import{fileURLToPath as Av}from"url";function Pd(){let r=tt.dirname(Av(import.meta.url));for(;!Ev(tt.join(r,"package.json"));){let e=tt.dirname(r);if(e===r)break;r=e}return r}function Ns(){return tt.join(Pd(),"README.md")}function Ta(){return tt.join(Pd(),"description.md")}function Tv(r){return`---
|
|
1175
|
+
</script>`;function Lw(r){let e={};for(let[t,n]of Object.entries(r))e[t]=n.startsWith("https://")?"/proxy/"+n:n;return e}import*as hs from"fs/promises";import*as ps from"path";import{existsSync as ed,readFileSync as $w}from"fs";import{execFile as Mw}from"child_process";import{promisify as Dw}from"util";import{satisfies as Bw}from"semver";var jw=Dw(Mw);async function ms(r,e,t){let s=r.map(o=>qw(o,t)).filter(o=>!Fw(o,e));if(s.length===0)return;await hs.mkdir(e,{recursive:!0});let i=ps.join(e,"package.json");ed(i)||await hs.writeFile(i,JSON.stringify({name:"typebulb-server",private:!0})),console.log(` Installing: ${s.join(", ")}`),await jw("npm",["install","--no-audit","--no-fund",...s],{cwd:e,shell:!0})}function qw(r,e){if(!e||rd(r))return r;let t=e[r];return t?`${r}@${t}`:r}function Fw(r,e){let t=ps.join(e,"node_modules",td(r));if(!ed(t))return!1;let n=rd(r);if(!n)return!0;try{let s=JSON.parse($w(ps.join(t,"package.json"),"utf-8")).version;return Bw(s,n)}catch{return!1}}function gs(r){let e=new Set,t=/\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^./][^'"]*)['"]/g,n;for(;n=t.exec(r);){let s=n[1];if(s.includes(":"))continue;let i=s.startsWith("@")?s.split("/").slice(0,2).join("/"):s.split("/")[0];e.add(i)}return[...e]}function td(r){if(r.startsWith("@")){let t=r.indexOf("/");if(t<0)return r;let n=r.indexOf("@",t+1);return n<0?r:r.slice(0,n)}let e=r.indexOf("@");return e<0?r:r.slice(0,e)}function rd(r){let e=td(r);return r.length>e.length?r.slice(e.length+1):""}async function nd(r){let t=(await De.readdir(r)).find(n=>n.endsWith(".bulb.md"));return t?ys.join(r,t):null}async function oe(r){let e=await De.readFile(r,"utf-8"),t=Bt(e);if(!t)throw new Error("Invalid .bulb.md file format");let n=es(t);return{bulb:n,config:Ac(n.config),warnings:Sc(e)}}async function Lr(r,e,t,n){let s=ea(r,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;t&&(i=await mc(i,t));let o=ys.join(e,".typebulb");await De.mkdir(o,{recursive:!0});let a=gs(i);a.length>0&&await ms(a,o,n);let c=ys.join(o,"server.mjs");return await De.writeFile(c,i,"utf-8"),await import(`${Uw(c).href}?t=${Date.now()}`)}async function ha(r,e,t,n,s){let{bulb:i,config:o}=await oe(r),a=Xo(i.data);Tf(i.code,o.dependencies??{});let c=ea(i.code,{jsxImportSource:o.ts?.jsxImportSource});c.error&&console.error("Compilation error:",c.error);let{importMap:l}=await ls.buildImportMap(c.code,o.dependencies??{},n?new Set([n.name]):void 0);n&&(l.imports[n.name]=n.entryUrl);let f=Zf({name:i.name,code:c.code,css:i.css,html:i.html,data:a,insight:i.insight,importMap:l,watch:e}),u=null;return i.server&&t&&(u=await Lr(i.server,s,n,o.dependencies)),{html:f,bulb:i,serverExports:u}}Mr();import Qw from"open";async function Rt(r){await Qw(r)}var od=new Set(["claude"]);function ad(r){return od.has(r)}function Dr(){return[...od]}import*as Be from"path";import{spawn as dv,execSync as pv}from"child_process";import{createRequire as hv}from"module";import{existsSync as mv}from"fs";import*as U from"fs/promises";import*as F from"path";import*as Nt from"path";var Xw=Nt.join(is,"pkg"),Zw=Nt.join(is,"files"),ev=Nt.join(is,"negative.json"),vs=class{pkgMem=new Map;fileMem=new Map;negativeCache=new ze(new Tt(ev));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await _();let t=await Qe(cd(e));return this.pkgMem.set(e,t),t}async setCachedDts(e,t,n){let s={content:t,url:n};this.pkgMem.set(e,s),await ws(async()=>{await _(),await Z(cd(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await _();let t=await ss(ld(e));return this.fileMem.set(e,t),t}async setCachedFile(e,t){this.fileMem.set(e,t),await ws(async()=>{await _(),await Z(ld(e),t)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await ws(async()=>{await _(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return ws(()=>this.negativeCache.clearNegative(e))}};async function ws(r){try{await r()}catch{}}function cd(r){return Nt.join(Xw,se(r)+".json")}function ld(r){return Nt.join(Zw,se(r)+".txt")}var ba;function tv(){return ba||(ba=ua({cache:new vs,cdnClient:Qf,packageService:ls,versionResolver:zf})),ba}var ud="file:///node_modules/";async function fd(r){let e=os(r.emitKey,"typecheck");await _(),await U.rm(e,{recursive:!0,force:!0}),await U.mkdir(e,{recursive:!0});let t=iv(r.jsxImportSource,r.dependencies),n=await tv().resolve(r.code,r.dependencies,t),s=r.local?.name,i=s?n.filter(f=>f.pkg!==s):n,o=new Set;for(let f of i)for(let u of f.files){let d=Ss(u.path);if(!d||o.has(d))continue;o.add(d);let p=F.join(e,"node_modules",d);await U.mkdir(F.dirname(p),{recursive:!0}),await U.writeFile(p,u.content,"utf8")}let a={};for(let f of i)for(let u of f.shims){let d=Ss(u.path);d&&(a[u.module]=[`./node_modules/${d}`])}for(let f of i){if(f.ambient)continue;let u=Ss(f.mainPath);u&&(a[f.pkg]=[`./node_modules/${u}`])}let c=new Set;for(let f of i)for(let u of f.files){if(!u.ambient)continue;let d=Ss(u.path);d&&c.add(`node_modules/${d}`)}if(r.local){delete a[r.local.name];let f=await ov(r.local,e);f?a[r.local.name]=[`./node_modules/${r.local.name}/${f}`]:console.warn(` local: '${r.local.name}' ships no type defs; check cannot type against it.`)}let l=rv(r.jsxImportSource,a,[...c]);return await U.writeFile(F.join(e,"tsconfig.json"),JSON.stringify(l,null,2)+`
|
|
1176
|
+
`,"utf8"),await U.writeFile(F.join(e,"code.tsx"),r.code,"utf8"),await U.writeFile(F.join(e,"tb.d.ts"),oa,"utf8"),{dir:e}}function rv(r,e,t=[]){return{compilerOptions:{target:"es2023",module:"esnext",moduleResolution:"bundler",lib:nv([...sa,...ia]),jsx:"react-jsx",jsxImportSource:r??"react",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0,paths:e},include:["code.tsx","tb.d.ts",...t]}}function nv(r){return r.filter(e=>!e.since).map(e=>sv(e.name))}function sv(r){return r.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 iv(r,e){let t=r??("react"in e?"react":void 0);return t?[`${t}/jsx-runtime`,`${t}/jsx-dev-runtime`]:[]}function Ss(r){if(!r.startsWith(ud))return;let e=r.slice(ud.length),t=e.indexOf("/");if(!(t<0))return e.slice(t+1)}async function ov(r,e){if(!r.typesAbs)return;let t=F.dirname(r.typesAbs),n=F.join(e,"node_modules",r.name);for(let s of await av(t)){let i=F.join(n,F.relative(t,s));await U.mkdir(F.dirname(i),{recursive:!0}),await U.copyFile(s,i)}return F.basename(r.typesAbs)}async function av(r){let e=[];async function t(n){let s=await U.readdir(n,{withFileTypes:!0});for(let i of s){let o=F.join(n,i.name);i.isDirectory()?await t(o):/\.d\.ts(\.map)?$/.test(i.name)&&e.push(o)}}return await t(r),e}import*as ee from"fs/promises";import*as ve from"path";import{existsSync as cv}from"fs";var lv="^22";async function dd(r){let e=os(r.emitKey,"typecheck-server");await _(),await ee.rm(e,{recursive:!0,force:!0}),await ee.mkdir(e,{recursive:!0});let t=ve.join(r.bulbDir,".typebulb"),n=gs(r.server).filter(o=>o!==r.local?.name);await ms([`@types/node@${lv}`,...n],t,r.dependencies);let s=ve.join(t,"node_modules"),i=ve.join(e,"node_modules");return await fv(s,i),await ee.writeFile(ve.join(e,"server.ts"),r.server,"utf8"),await ee.writeFile(ve.join(e,"tb.d.ts"),aa,"utf8"),await ee.writeFile(ve.join(e,"tsconfig.json"),JSON.stringify(uv(r.local),null,2)+`
|
|
1177
|
+
`,"utf8"),{dir:e}}function uv(r){let e={target:"es2023",module:"esnext",moduleResolution:"bundler",lib:["ES2023"],types:["node"],strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};if(r?.typesAbs){let t=i=>i.replace(/\\/g,"/"),n=t(ve.dirname(r.typesAbs)),s=t(r.typesAbs).replace(/\.d\.ts$/,"");e.paths={[r.name]:[s],[`${r.name}/*`]:[`${n}/*`]}}return{compilerOptions:e,include:["server.ts","tb.d.ts"]}}async function fv(r,e){if(!cv(r)){await ee.mkdir(e,{recursive:!0});return}await ee.rm(e,{recursive:!0,force:!0});let t=process.platform==="win32"?"junction":"dir";await ee.symlink(r,e,t)}async function hd(r,e){let{bulb:t,config:n,warnings:s}=await oe(r);!t.code&&!t.server&&(console.error("Bulb has neither **code.tsx** nor **server.ts**; nothing to check."),process.exit(1));let i=!1;for(let l of s)console.log(`structure ${l}`);s.length&&(i=!0),t.code&&(i=pd(br(t.code,{target:"client",dependencies:n.dependencies??{}}),"client")||i),t.server&&(i=pd(br(t.server,{target:"server"}),"server")||i);let o=bv([process.cwd(),Be.dirname(r)]);if(!o){let l=Be.relative(process.cwd(),r)||r;console.error("check: TypeScript not found \u2014 install it once, then re-run:"),console.error(" npm i -g typescript"),console.error(` typebulb check ${l}`),process.exit(2)}let a=[];if(t.code){let{dir:l}=await fd({code:t.code,dependencies:n.dependencies??{},jsxImportSource:n.ts?.jsxImportSource,emitKey:r,local:e});a.push({role:"client",dir:l})}if(t.server){let{dir:l}=await dd({server:t.server,bulbDir:Be.dirname(r),emitKey:r,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:n.dependencies});a.push({role:"server",dir:l})}for(let{role:l,dir:f}of a){let{stdout:u,exitCode:d}=await gv(o,f);for(let p of u.split(/\r?\n/))p.trim()&&console.log(`${l} ${p}`);d!==0&&(i=!0)}i&&process.exit(1);let c=[t.code&&"code.tsx",t.server&&"server.ts"].filter(Boolean).join(", ");console.error(`\u2713 no issues (${c})`)}function pd(r,e){for(let t of r)for(let n of t.message.split(`
|
|
1178
|
+
`))console.log(`${e} ${n}`);return r.length>0}function gv(r,e){return new Promise(t=>{let n=dv(process.execPath,[r,"--noEmit"],{cwd:e}),s="";n.stdout?.on("data",i=>{s+=i.toString()}),n.stderr?.on("data",i=>{s+=i.toString()}),n.on("close",i=>t({stdout:s,exitCode:i??1}))})}var yv=hv(import.meta.url);function bv(r){let e=n=>{try{let s=yv.resolve("typescript/package.json",{paths:n}),i=Be.join(Be.dirname(s),"lib","tsc.js");return mv(i)?i:void 0}catch{return}},t=e(r);if(t)return t;try{let n=pv("npm root -g",{encoding:"utf8"}).trim();return e([n])}catch{return}}ks();Mr();async function md(r,e){let{bulb:t}=await oe(r),n=Ct(t);if(Xe(r)){console.log("remembered-trusted \u2014 runs with filesystem / AI / server.ts automatically (`typebulb untrust` to revoke)."),n&&console.log(` (it uses ${n})`);return}n?(console.log(`This bulb appears to use ${n}; 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.)")}Mr();import*as Br from"path";async function gd(r,e){if(!r){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let n=ya();if(!n.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 n)console.log(` ${s}`);return}let t=Br.resolve(r);t.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),Pt(t,e),console.log(e?`Trusted ${Br.basename(t)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${Br.basename(t)} \u2014 runs Restricted.`),console.log(` ${t}`)}pe();import{readFileSync as Rv,existsSync as Nv}from"fs";import*as tt from"path";import{fileURLToPath as Cv}from"url";function Rd(){let r=tt.dirname(Cv(import.meta.url));for(;!Nv(tt.join(r,"package.json"));){let e=tt.dirname(r);if(e===r)break;r=e}return r}function Ns(){return tt.join(Rd(),"README.md")}function Ta(){return tt.join(Rd(),"description.md")}function _v(r){return`---
|
|
1162
1179
|
name: typebulb
|
|
1163
|
-
description: ${
|
|
1180
|
+
description: ${Rv(Ta(),"utf8").trim().replace(/\s+/g," ")}
|
|
1164
1181
|
version: ${r}
|
|
1165
|
-
---`}function
|
|
1182
|
+
---`}function Iv(r){return`> Generated from typebulb v${r}. If \`npx typebulb --version\` reports a newer version, re-run \`npx typebulb skill\` to refresh this file.`}function Nd(r,e){return`${_v(e)}
|
|
1166
1183
|
|
|
1167
|
-
${
|
|
1184
|
+
${Iv(e)}
|
|
1168
1185
|
|
|
1169
1186
|
${r.trim()}
|
|
1170
|
-
`}async function Cd(r){let[e]=
|
|
1187
|
+
`}async function Cd(r){let[e]=Dr(),t,n;try{t=await Pd(e)}catch(m){n=m instanceof Error?m.message:String(m)}let s=process.stdout.isTTY===!0,i=m=>h=>s?`\x1B[${m}m${h}\x1B[0m`:h,o=i("1"),a=i("2"),c=i("32"),l=i("33"),f=i("1;4;36"),u=[" Read the authoring skill before writing a bulb:",` ${a("\u2022")} npx typebulb skill ${a("\u2014 assembles one SKILL.md")}`,` ${a("\u2022")} or, open its parts:`,` ${a(Ta())}`,` ${a(Ns())}`],d=t?[" Agent mirror is live",` ${c("\u25CF")} ${f(t.url)}`,` ${a("Embedded bulbs in CC sessions render live here.")}`," Agents:",...u," End your reply with the mirror link above",` ${a("\u2022")} ${a("easy to miss the link mid-message")}`]:[` The mirror did not start ${a(`(${n})`)}`,` ${l("\u25CF")} Start it manually: ${o(`npx typebulb agent:${e}`)}`," Agents:",...u],p=[` ${a(`typebulb v${r}`)}`,...d,""];process.stdout.write(p.join(`
|
|
1171
1188
|
`)+`
|
|
1172
|
-
`)}import{readFileSync as
|
|
1173
|
-
`)){let t=e.trim();if(!t||t.startsWith("#"))continue;let n=t.indexOf("=");if(n===-1)continue;let s=t.slice(0,n).trim(),i=t.slice(n+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),yield[s,i]}}function
|
|
1174
|
-
`+e)}function
|
|
1189
|
+
`)}import{readFileSync as Lv,existsSync as $v}from"fs";import*as Se from"path";function Mv(r){return[...r?[`.env.${r}.local`,`.env.${r}`]:[],".env.local",".env"]}function he(r,e=process.cwd()){let t={},n=[];for(let s of Mv(r)){let i;try{i=Lv(Se.resolve(e,s),"utf-8")}catch{continue}n.push(s);for(let[o,a]of Dv(i))process.env[o]===void 0&&(process.env[o]=a,t[o]=s)}return{mode:r,sources:t,loaded:n}}function*Dv(r){for(let e of r.split(`
|
|
1190
|
+
`)){let t=e.trim();if(!t||t.startsWith("#"))continue;let n=t.indexOf("=");if(n===-1)continue;let s=t.slice(0,n).trim(),i=t.slice(n+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),yield[s,i]}}function Bv(r){let e=new Set,t=/process\.env\.([A-Za-z_$][\w$]*)|process\.env\[\s*['"]([^'"]+)['"]\s*\]/g;for(let n;n=t.exec(r);)e.add(n[1]??n[2]);return[...e]}function je(r,e,t){let{sources:n,mode:s,loaded:i}=r,o=process.cwd(),a=Se.dirname(e),c=`(mode: ${s??"none"})`,l=t?Bv(t):[],f=l.filter(p=>n[p]).map(p=>`${p} \u2190 ${n[p]}`);f.length?console.log(`env: ${f.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=Se.resolve(a)!==Se.resolve(o);if(u)for(let p of[".env.local",".env"])$v(Se.join(a,p))&&console.log(`env: ${Se.join(a,p)} present but not loaded (cwd is ${o})`);let d=l.filter(p=>process.env[p]===void 0);if(d.length){let p=u?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${d.join(", ")} but ${d.length>1?"they are":"it's"} unset${p}`)}}_s();async function Ld(r){he(r);let e=await rt();if(e.length>0){console.log(Id(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!_d()){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,n]of Object.entries(Lt))console.log(` ${n.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.")}import*as $d from"fs/promises";async function Md(r){let e=Ns(),t;try{t=await $d.readFile(e,"utf8")}catch{console.error(`Could not read the bundled README (expected at ${e}).`),process.exit(1)}process.stdout.write(Nd(t,r))}$r();pe();import*as Dd from"path";function Wv(r,e,t){if(/^\d+$/.test(e))return r.find(s=>s.pid===parseInt(e,10));let n=r.filter(s=>s.agent===e);return n.length?(t?n.find(i=>i.cwd&&L(i.cwd)===L(t)):void 0)??n[0]:r.find(s=>L(s.file)===L(e))}var qr=r=>r.agent??Dd.basename(r.file);function Bd(r,e){for(let t of r)e(` ${t.url} pid ${t.pid} ${t.trust?"trusted":"restricted"} ${t.file}`)}function Pa(r,e){if(!r.length){console.log("No running bulb servers.");return}console.log("Running bulb servers:"),Bd(r,t=>console.log(t)),console.log(`
|
|
1191
|
+
`+e)}function Ra(r,e,t,n){let s=Wv(r,e,n);if(s)return s;console.error(`No running server for '${e}'.`),r.length?(console.error(`Running servers (try \`typebulb ${t} <file|pid>\`):`),Bd(r,i=>console.error(i))):console.error("No bulb servers are running."),process.exit(1)}async function jd(r,e){if(!r){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),Pa(await $(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let t=Ra(await $(),r,"logs",process.cwd());if(e.clear){xd(t.pid),console.log(`Cleared log for ${qr(t)} (pid ${t.pid}).`);return}let n=de(t.pid),s=n.text;if(e.run!==void 0&&(s=Ed(s,e.run),!s&&e.run!=="latest"&&console.error(`No output for run ${e.run} (it hasn't started, or was trimmed from the log).`)),e.lines&&e.lines>0){let i=s.split(`
|
|
1175
1192
|
`);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
|
|
1176
1193
|
`)}if(process.stdout.write(s),s&&!s.endsWith(`
|
|
1177
1194
|
`)&&process.stdout.write(`
|
|
1178
|
-
`),e.follow&&e.run===void 0){let i=n.offset,o=setInterval(()=>{let c=de(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
|
|
1179
|
-
`);f=p.pop()??"";for(let m of p)m.trim()&&(e.match&&!m.includes(e.match)||(console.log(m),l??=Date.now()+c))}if(l&&Date.now()>=l)break;if(!l&&Date.now()>=a){console.error(`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${
|
|
1195
|
+
`),e.follow&&e.run===void 0){let i=n.offset,o=setInterval(()=>{let c=de(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 Vv=r=>new Promise(e=>setTimeout(e,r));async function qd(r,e){if(!r){Pa(await $(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let t=Ra(await $(),r,"wait",process.cwd()),n=e.match??"",s=de(t.pid).offset,i=Sa(t.pid,n)??(n?Sa(t.pid):void 0),o=i!==void 0&&i<=s?i:s,a=Date.now()+e.timeoutSec*1e3,c=1e3,l,f="",u=0;for(;;){let d=de(t.pid,o);if(o=d.offset,d.text){f+=d.text;let p=f.split(`
|
|
1196
|
+
`);f=p.pop()??"";for(let m of p)m.trim()&&(e.match&&!m.includes(e.match)||(console.log(m),l??=Date.now()+c))}if(l&&Date.now()>=l)break;if(!l&&Date.now()>=a){console.error(`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${qr(t)} within ${e.timeoutSec}s`),u=2;break}if(!xa(t.pid)){l||(console.error(`server ${qr(t)} (pid ${t.pid}) exited while waiting`),process.exit(3));break}await Vv(400)}As(t.pid,o,n),process.exit(u)}async function Fd(r){if(!r){Pa(await $(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Ra(await $(),r,"stop",process.cwd());await et(e.pid),console.log(`Stopped ${qr(e)} (pid ${e.pid}, ${e.url}).`)}async function Ud(r){let e=process.cwd(),t=r==="global"?await $():r==="bulbs"?await $(e):(await $()).filter(s=>s.agent!=null&&s.cwd!=null&&L(s.cwd)===L(e)),n=r==="global"?"server":r==="agent"?"mirror":"bulb";if(!t.length){console.log(r==="global"?"No running bulb servers.":`No running ${n}s for this project.`);return}await Promise.all(t.map(s=>et(s.pid))),console.log(`Stopped ${t.length} ${n}${t.length===1?"":"s"}:`);for(let s of t)console.log(` ${s.url} pid ${s.pid} ${qr(s)}`)}pe();import*as Jd from"path";async function Kd(r,e){let t=Jd.resolve(r),n=Ps(await $(),t)[0];n||(console.error(`No running server for '${r}'. Start it first: npx typebulb ${r}`),process.exit(1));let s=0;try{let i=await fetch(`${n.url}/__send`,{method:"POST",headers:{"Content-Type":"text/plain"},body:e??""});i.ok||(console.error(`send failed: HTTP ${i.status} from ${n.url}/__send`),process.exit(1)),s=(await i.json().catch(()=>({}))).clients??0}catch(i){console.error(`send failed: ${i instanceof Error?i.message:String(i)}`),process.exit(1)}s>0?console.log(`Sent to ${s} page${s===1?"":"s"}.`):console.log("Sent, but no page is connected yet \u2014 open the bulb and retry.")}pe();import*as Zd from"fs/promises";import*as $t from"path";import{EventEmitter as ja}from"events";ks();import{Hono as tS}from"hono";import{serve as rS}from"@hono/node-server";import{streamSSE as nS}from"hono/streaming";import*as st from"fs/promises";import*as ae from"path";var H=class extends Error{constructor(e,t="unknown",n=!1){super(e),this.code=t,this.retryable=n}},G=class{getPath(e,t){return this.path}parseStreamChunk(e){return this.checkAndThrowError(e),this.parseProviderStreamChunk(e)}isReasoningEnabled(e){return e?.reasoning!==void 0&&e.reasoning>0}extractSystemMessages(e,t=`
|
|
1180
1197
|
|
|
1181
|
-
`){let n=e.filter(s=>s.role==="system").map(s=>s.content);return{system:n.length?n.join(t):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,t,n=!1){if(!e)return{message:`HTTP ${t}`};try{let s=JSON.parse(e);if(s.error&&typeof s.error=="object"){let i={message:s.error.message||`HTTP ${t}`,type:s.error.type};return n&&(i.code=s.error.code),i}return s.message?{message:s.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 n=t.code||"unknown";throw new H(t.message,n,!!t.retryable)}if(t.error)throw new H(this.extractErrorMessage(t.error))}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
|
|
1198
|
+
`){let n=e.filter(s=>s.role==="system").map(s=>s.content);return{system:n.length?n.join(t):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,t,n=!1){if(!e)return{message:`HTTP ${t}`};try{let s=JSON.parse(e);if(s.error&&typeof s.error=="object"){let i={message:s.error.message||`HTTP ${t}`,type:s.error.type};return n&&(i.code=s.error.code),i}return s.message?{message:s.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 n=t.code||"unknown";throw new H(t.message,n,!!t.retryable)}if(t.error)throw new H(this.extractErrorMessage(t.error))}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 Is=class extends G{constructor(){super(...arguments),this.providerName="OpenAI",this.defaultBaseUrl="https://api.openai.com",this.path="/v1/responses",this.effortMap={0:"minimal",1:"low",2:"medium",3:"high"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,t,n,s){let i=this.convertMessagesToInput(e),o={model:t,input:i,stream:s};return n?.webSearch!==!1&&(o.tools=[{type:"web_search"}]),this.isReasoningEnabled(n)&&(o.reasoning={effort:this.effortMap[n.reasoning],summary:"auto"}),o}parseError(e,t){return this.parseJsonError(e,t,!0)}parseNonStreamingResponse(e){if(!this.isResponsesApiResponse(e))return{text:""};let t=e.output_text||"",n;if(e.output&&Array.isArray(e.output))for(let s of e.output)s.type==="reasoning"&&s.summary&&(n=s.summary.map(i=>i.text).join(`
|
|
1182
1199
|
`)),!t&&s.type==="message"&&s.content&&(t=s.content.filter(i=>i.type==="output_text").map(i=>i.text).join(""));return{text:t,reasoning:n}}parseProviderStreamChunk(e){if(!this.isResponsesApiEvent(e))return null;switch(e.type){case"error":return null;case"response.failed":{let s=e.response?.error,i=s?.message||"Response failed",o=s?.code==="insufficient_quota"||s?.code==="rate_limit_exceeded";throw new H(i,o?"rate_limit":"unknown",o)}case"response.output_text.delta":return{text:e.delta};case"response.reasoning_summary_text.delta":return{reasoning:e.delta};case"response.created":case"response.in_progress":case"response.output_item.added":case"response.output_item.done":case"response.content_part.added":case"response.content_part.done":case"response.output_text.done":case"response.output_text.annotation.added":case"response.reasoning_summary_text.done":case"response.completed":case"response.web_search_call.in_progress":case"response.web_search_call.searching":case"response.web_search_call.completed":return null;default:return null}}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(`
|
|
1183
1200
|
|
|
1184
|
-
`)}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
|
|
1201
|
+
`)}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 Ls=class extends G{constructor(){super(...arguments),this.providerName="OpenRouter",this.defaultBaseUrl="https://openrouter.ai",this.path="/api/v1/chat/completions",this.effortMap={0:"low",1:"low",2:"medium",3:"high"}}buildHeaders(e,t){let n={Authorization:`Bearer ${e}`,"x-api-key":e,"Content-Type":"application/json",Accept:"application/json","X-Title":"Typebulb"};return t&&(n["HTTP-Referer"]=t,n.Referer=t,n.Origin=t),n}buildPayload(e,t,n,s){let i={model:t,messages:e,stream:s};return n?.webSearch===!0&&(i.plugins=[{id:"web"}]),this.isReasoningEnabled(n)&&(i.reasoning={effort:this.effortMap[n.reasoning]}),i}parseError(e,t){return this.parseJsonError(e,t,!0)}parseNonStreamingResponse(e){if(!this.hasChoices(e))return{text:""};let t=e,n=t.choices[0],s=n?.message?.content??n?.text??"",i=n?.message?.reasoning??t.reasoning;return{text:s,reasoning:i}}parseProviderStreamChunk(e){if(!this.hasChoices(e))return null;let t=e.choices[0];if(!t)return null;let n=t.delta||t.message;if(!n)return null;let s=n.content||void 0,i=n.reasoning||void 0;return!s&&!i?null:{text:s,reasoning:i}}hasChoices(e){return typeof e=="object"&&e!==null&&"choices"in e&&Array.isArray(e.choices)}};var $s=class extends G{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,n,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e),a={model:t,max_tokens:this.getMaxTokens(t),messages:this.withLastMessageCached(o),stream:s};if(n?.webSearch!==!1&&(a.tools=[{type:"web_search_20250305",name:"web_search"}]),i&&(a.system=[{type:"text",text:i,cache_control:{type:"ephemeral"}}]),this.isReasoningEnabled(n)){let c=n.reasoning;if(this.isModernModel(t)){let l={0:"low",1:"low",2:"medium",3:"high"};a.thinking={type:"adaptive"},a.output_config={effort:l[c]}}else{let l={0:0,1:2048,2:4096,3:8192};a.thinking={type:"enabled",budget_tokens:l[c]}}}return a}parseError(e,t){return this.parseJsonError(e,t)}parseNonStreamingResponse(e){if(!this.isAnthropicResponse(e))return{text:""};let t=e.content.filter(s=>s.type==="text").map(s=>s.text).join(""),n=e.content.filter(s=>s.type==="thinking").map(s=>s.thinking).join(`
|
|
1185
1202
|
|
|
1186
|
-
`);return{text:t,reasoning:n||void 0}}parseProviderStreamChunk(e){if(!this.isAnthropicEvent(e))return null;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||""}:null;case"message_start":case"content_block_start":case"content_block_stop":case"message_delta":case"message_stop":case"ping":return null;default:return null}}withLastMessageCached(e){let t=e.length-1;return e.map((n,s)=>s===t?{role:n.role,content:[{type:"text",text:n.content,cache_control:{type:"ephemeral"}}]}:n)}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-\w+-(\d+)-(\d+)/);return!!t&&(+t[1]>4||+t[1]==4&&+t[2]>=6)}getMaxTokens(e){return this.isModernModel(e)?64e3:32e3}};var
|
|
1203
|
+
`);return{text:t,reasoning:n||void 0}}parseProviderStreamChunk(e){if(!this.isAnthropicEvent(e))return null;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||""}:null;case"message_start":case"content_block_start":case"content_block_stop":case"message_delta":case"message_stop":case"ping":return null;default:return null}}withLastMessageCached(e){let t=e.length-1;return e.map((n,s)=>s===t?{role:n.role,content:[{type:"text",text:n.content,cache_control:{type:"ephemeral"}}]}:n)}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-\w+-(\d+)-(\d+)/);return!!t&&(+t[1]>4||+t[1]==4&&+t[2]>=6)}getMaxTokens(e){return this.isModernModel(e)?64e3:32e3}};var Ms=class extends G{constructor(){super(...arguments),this.providerName="Gemini",this.defaultBaseUrl="https://generativelanguage.googleapis.com",this.path="/v1beta/models"}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,n,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e,`
|
|
1187
1204
|
`),c={contents:o.map(l=>({role:l.role==="assistant"?"model":"user",parts:[{text:l.content}]}))};return n?.webSearch!==!1&&(c.tools=[{google_search:{}}]),i&&(c.systemInstruction={role:"system",parts:[{text:i}]}),this.isReasoningEnabled(n)&&(c.generationConfig={thinkingConfig:{includeThoughts:!0,thinkingBudget:-1}}),c}parseError(e,t){if(!e)return{message:`HTTP ${t}`};try{let n=JSON.parse(e),s=Array.isArray(n)?n[0]?.error:n?.error;return s&&typeof s=="object"?{message:(s.message||`HTTP ${t}`).split(`
|
|
1188
|
-
`)[0],type:s.status,code:s.code?.toString()}:n.message?{message:n.message}:{message:e}}catch{return{message:e}}}parseNonStreamingResponse(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return{text:"",status:"failed",error:"Invalid response format"};let t=this.extractParts(e).text||"",n=e.candidates?.[0]?.finishReason,s="complete";return n==="MAX_TOKENS"?s="interrupted":(n==="SAFETY"||n==="RECITATION")&&(s="failed"),{text:t,status:s}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return null;let t=this.extractParts(e);return t.text||t.reasoning?t:null}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 n="",s="";for(let i of t)i.text&&(i.thought?s+=i.text:n+=i.text);return{text:n||void 0,reasoning:s||void 0}}checkGeminiError(e){if(typeof e=="object"&&e!==null&&"error"in e){let t=e.error,n;if(typeof t=="string")n=t;else if(typeof t=="object"&&t!==null){let s=t;n=s.message||s.status||"Gemini returned an error"}else n="Gemini returned an error";throw new H(n)}if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let t=e.promptFeedback.blockReason;throw new H(`Prompt blocked: ${t}`)}}};var
|
|
1205
|
+
`)[0],type:s.status,code:s.code?.toString()}:n.message?{message:n.message}:{message:e}}catch{return{message:e}}}parseNonStreamingResponse(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return{text:"",status:"failed",error:"Invalid response format"};let t=this.extractParts(e).text||"",n=e.candidates?.[0]?.finishReason,s="complete";return n==="MAX_TOKENS"?s="interrupted":(n==="SAFETY"||n==="RECITATION")&&(s="failed"),{text:t,status:s}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return null;let t=this.extractParts(e);return t.text||t.reasoning?t:null}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 n="",s="";for(let i of t)i.text&&(i.thought?s+=i.text:n+=i.text);return{text:n||void 0,reasoning:s||void 0}}checkGeminiError(e){if(typeof e=="object"&&e!==null&&"error"in e){let t=e.error,n;if(typeof t=="string")n=t;else if(typeof t=="object"&&t!==null){let s=t;n=s.message||s.status||"Gemini returned an error"}else n="Gemini returned an error";throw new H(n)}if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let t=e.promptFeedback.blockReason;throw new H(`Prompt blocked: ${t}`)}}};var Ds=class extends G{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,n,s){return{model:t,messages:e,stream:s}}parseError(e,t){return this.parseJsonError(e,t,!0)}parseNonStreamingResponse(e){if(!this.hasChoices(e))return{text:""};let n=e.choices[0]?.message,s=n?.content??"",i=n?.reasoning??n?.reasoning_content;return{text:s,reasoning:i}}parseProviderStreamChunk(e){if(!this.hasChoices(e))return null;let t=e.choices[0];if(!t)return null;let n=t.delta||t.message;if(!n)return null;let s=n.content||void 0,i=n.reasoning||n.reasoning_content||void 0;return!s&&!i?null:{text:s,reasoning:i}}hasChoices(e){return typeof e=="object"&&e!==null&&"choices"in e&&Array.isArray(e.choices)}};var Wd=new Ds,Hv=new Map([["openai",new Is],["openrouter",new Ls],["anthropic",new $s],["gemini",new Ms],["ollama",Wd],["openai-compat",Wd]]);function nt(r){let e=Hv.get(r);if(!e)throw new Error(`Unsupported protocol: ${r}`);return e}function Yv(r,e){return r.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function Na(r,e){let t=nt(r.protocol),n=t.getPath(e.model,e.stream),s=Yv(r.baseUrl,n),i=t.buildHeaders(r.apiKey,e.origin),o=t.buildPayload(e.messages,e.model,{reasoning:e.reasoning,webSearch:e.webSearch},e.stream);return e.modifyPayload?.(o),fetch(s,{method:"POST",headers:i,body:JSON.stringify(o),signal:e.signal})}async function Ca(r,e){let t=nt(e),n=await r.text().catch(()=>""),{message:s}=t.parseError(n,r.status),i=r.status,o="unknown";return i===429?o="rate_limit":i===413&&(o="context_exceeded"),{code:o,message:s,retryable:i===429}}function Vd(r){let e=r.indexOf(`\r
|
|
1189
1206
|
\r
|
|
1190
1207
|
`),t=r.indexOf(`
|
|
1191
1208
|
|
|
1192
1209
|
`);return e!==-1&&(t===-1||e<t)?{pos:e,len:4}:t!==-1?{pos:t,len:2}:{pos:-1,len:0}}function _a(r){let t=r.split(/\r?\n/).filter(s=>s.startsWith("data:"));if(!t.length)return null;let n=t.map(s=>s.replace(/^data:\s?/,"")).join(`
|
|
1193
|
-
`).trim();if(!n)return null;if(n==="[DONE]")return"done";try{return JSON.parse(n)}catch{return null}}async function*
|
|
1194
|
-
${l}`:"";return g.text(`Forbidden: this capability requires --trust.${A}`,403)}await b()},m=async(g,b)=>{let w=g.req.header("sec-fetch-site");if(w){if(w!=="same-origin")return g.text(`Forbidden: ${w} request`,403)}else{let S=g.req.header("origin");if(S&&!
|
|
1210
|
+
`).trim();if(!n)return null;if(n==="[DONE]")return"done";try{return JSON.parse(n)}catch{return null}}async function*Hd(r,e){let t=new TextDecoder,n="";try{for(;;){if(e?.aborted)return;let{done:s,value:i}=await r.read();if(s){if(n.trim()){let c=_a(n);c!==null&&c!=="done"&&(yield c)}return}n+=t.decode(i,{stream:!0});let{pos:o,len:a}=Vd(n);for(;o!==-1;){let c=n.slice(0,o);n=n.slice(o+a);let l=_a(c);if(l==="done")return;l!==null&&(yield l),{pos:o,len:a}=Vd(n)}}}finally{try{await r.cancel()}catch{}}}async function Ia(r,e){if(!r.body)throw new Error("Response body is missing");let t="";for await(let n of Bs(r,e))n.kind==="text"&&(t+=n.text);return t}async function*Bs(r,e){let t=e??(r.headers.get("X-Provider-Protocol")||"openai"),n=nt(t);if(!r.body)return;let s=r.body.getReader();for await(let i of Hd(s)){let o=n.parseStreamChunk(i);o?.reasoning&&(yield{kind:"reasoning",text:o.reasoning}),o?.text&&(yield{kind:"text",text:o.text})}}import*as La from"fs/promises";import*as Fr from"path";var js=class{async get(e){let t=se(e),n=Fr.join(Ir,t+".bin"),s=Fr.join(Ir,t+".json");try{let[i,o]=await Promise.all([La.readFile(n),La.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,t){await _();let n=se(e),s=Fr.join(Ir,n+".bin"),i=Fr.join(Ir,n+".json"),o={url:e,contentType:t.contentType,cacheControl:t.cacheControl};await Promise.all([Z(s,t.body),Z(i,JSON.stringify(o))])}};pe();_s();import{stream as Gv}from"hono/streaming";var zv="X-TB-Stream";function Qv(r){return r instanceof H?{message:r.message,code:r.code,retryable:r.retryable}:{message:r instanceof Error?r.message:"Unknown error",code:"unknown",retryable:!1}}function $a(r,e){return r.header("Content-Type","application/x-ndjson; charset=utf-8"),r.header("Cache-Control","no-cache"),r.header(zv,"1"),Gv(r,async t=>{let n=e[Symbol.asyncIterator]();t.onAbort(()=>{n.return?.()});try{for(;;){let{done:s,value:i}=await n.next();if(s)break;await t.writeln(JSON.stringify({type:"chunk",value:i}))}}catch(s){await t.writeln(JSON.stringify({type:"error",error:Qv(s)}))}finally{try{await n.return?.()}catch{}}})}var Ma={log:(...r)=>console.log(...r)};function qs(r,e){let t=r?.[e]??Ma[e];return typeof t=="function"?t:void 0}function Fs(r){return r.constructor?.name==="AsyncGeneratorFunction"}var Xv=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,Zv=/[?&]target=/,eS=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function Yd(r,e=""){return Xv.test(r)?!0:eS.test(r)&&Zv.test(e)}var zd="127.0.0.1",sS=new Set(["localhost","127.0.0.1","::1"]);function iS(r){if(r)try{return new URL(r.includes("://")?r:`http://${r}`).hostname}catch{return}}function oS(r){let e=iS(r);return!!e&&sS.has(e)}function aS(r,e){if(!e)return!1;try{return new URL(r).host===e}catch{return!1}}function Us(r){return r instanceof Error?r.message:"Unknown error"}async function Js(r){let{getHtml:e,basePath:t,port:n,reloadEmitter:s,messageEmitter:i,getServerExports:o,localOverride:a,trusted:c=!1,trustHint:l,staticAssets:f}=r,u=new tS;u.use("*",async(g,b)=>{if(!oS(g.req.header("host")))return g.text("Forbidden: untrusted Host",403);await b()}),u.use("*",async(g,b)=>{await b(),g.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),g.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let d=["/__fs/*","/__api/*","/__ai"],p=async(g,b)=>{if(!c){let w=new URL(g.req.url).pathname,S=w.startsWith("/__fs")?"the filesystem":w==="/__ai"?"AI (your API keys)":"server-side code (server.ts)";Ad(process.pid,S);let A=l?`
|
|
1211
|
+
${l}`:"";return g.text(`Forbidden: this capability requires --trust.${A}`,403)}await b()},m=async(g,b)=>{let w=g.req.header("sec-fetch-site");if(w){if(w!=="same-origin")return g.text(`Forbidden: ${w} request`,403)}else{let S=g.req.header("origin");if(S&&!aS(S,g.req.header("host")))return g.text("Forbidden: cross-origin request",403)}await b()};for(let g of d)u.use(g,p),u.use(g,m);u.use("/__log",m),u.post("/__log",async g=>{try{let{args:b}=await g.req.json();console.log(...b||[])}catch{}return g.json({ok:!0})}),i&&(u.use("/__send",m),u.post("/__send",async g=>{let b="";try{b=await g.req.text()}catch{}let w=i.listenerCount("message");return i.emit("message",b),g.json({clients:w})})),u.get("/",g=>g.html(e())),u.post("/__fs/read",async g=>{try{let{path:b}=await g.req.json(),w=Ba(b,t),S=await st.readFile(w);return new Response(new Uint8Array(S),{headers:{"Content-Type":"application/octet-stream"}})}catch(b){let w=Us(b);return g.json({error:w},400)}}),u.post("/__fs/write",async g=>{try{let b=g.req.query("path");if(!b)return g.json({error:"Missing path"},400);let w=Ba(b,t);return await st.mkdir(ae.dirname(w),{recursive:!0}),await st.writeFile(w,Buffer.from(await g.req.arrayBuffer())),g.json({success:!0})}catch(b){let w=Us(b);return g.json({error:w},400)}}),u.post("/__api/:name",async g=>{try{let b=g.req.param("name"),w=qs(o?.(),b);if(!w)return g.json({error:`API function '${b}' not found`},404);let{args:S}=await g.req.json();if(Fs(w))return $a(g,w(...S||[]));let A=await w(...S||[]);return g.json({result:A})}catch(b){let w=Us(b);return g.json({error:w},500)}}),u.post("/__ai",async g=>{try{let{messages:b,system:w,reasoning:S,provider:A,model:E,webSearch:N,stream:J}=await g.req.json();if(!b||!Array.isArray(b)||b.length===0)return g.json({message:"messages array is required",code:"unknown",retryable:!1},400);let q=cS(A,E);if(typeof q=="string")return g.json({message:q,code:"unknown",retryable:!1},400);let C=[...w?[{role:"system",content:w}]:[],...b.map(Gr=>({role:Gr.role,content:Gr.content}))],xe=await Na(q,{model:q.model,messages:C,stream:!0,reasoning:S??0,webSearch:N??!0});if(!xe.ok){let Gr=await Ca(xe,q.protocol);return g.json(Gr,xe.status)}if(J)return $a(g,Bs(xe,q.protocol));let ac=await Ia(xe,q.protocol);return ac||console.warn("[tb.ai] Empty response from provider"),g.json({text:ac})}catch(b){if(b instanceof H)return g.json({message:b.message,code:b.code,retryable:b.retryable},500);let w=Us(b);return g.json({message:w,code:"unknown",retryable:!1},500)}}),u.get("/__models",async g=>{try{let b=await rt();return g.json(b)}catch{return g.json([],200)}});let h=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],y=new js;u.get("/proxy/*",async g=>{let b=new URL(g.req.url),S=(b.pathname+b.search).slice(7),A=S.lastIndexOf("https://");return A===-1?g.text("Invalid proxy URL",400):v(g,S.slice(A))}),a&&Gd(u,`/local/${a.name}/`,a.serveDir),f&&Gd(u,f.mount,f.dir);async function v(g,b){let w;try{w=new URL(b)}catch{return g.text("Invalid URL",400)}if(w.protocol!=="https:")return g.text("HTTPS only",400);if(!h.includes(w.hostname))return g.text("Host not allowed",403);let S=await y.get(b);if(S)return new Response(S.body,{status:200,headers:Da(S.contentType,S.cacheControl)});try{let A=await fetch(b,{headers:{Accept:g.req.header("Accept")||"*/*"},redirect:"follow"});if(!A.ok)return g.text(`Upstream ${A.status}`,A.status);let E=A.headers.get("Content-Type")||void 0,N=A.headers.get("Cache-Control")||void 0;if(A.body){let[J,q]=A.body.tee();return(async()=>{try{let C=await new Response(q).arrayBuffer();await y.set(b,{body:Buffer.from(C),contentType:E,cacheControl:N})}catch{}})(),new Response(J,{status:A.status,headers:Da(E,N)})}return new Response(null,{status:A.status,headers:Da(E,N)})}catch(A){return g.text(`Proxy fetch failed: ${A instanceof Error?A.message:A}`,502)}}(s||i)&&u.get("/__reload",g=>nS(g,async b=>{let w=()=>{b.writeSSE({event:"reload",data:""})},S=A=>{b.writeSSE({event:"message",data:JSON.stringify(A)})};for(s?.on("reload",w),i?.on("message",S),b.onAbort(()=>{s?.removeListener("reload",w),i?.removeListener("message",S)});;)await b.sleep(3e4)})),u.notFound(async g=>{if(g.req.method!=="GET")return g.text("Not Found",404);let b=new URL(g.req.url);return Yd(b.pathname,b.search)?v(g,"https://esm.sh"+b.pathname+b.search):g.text("Not Found",404)});let k=rS({fetch:u.fetch,port:n,hostname:zd});return{port:n,close:()=>k.close()}}function cS(r,e){let t=r??process.env.TB_AI_PROVIDER,n=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(!n)return"No model specified. Set TB_AI_MODEL in your .env file or pass model in the tb.ai() call.";let s;try{s=nt(t)}catch{return`Unknown provider '${t}'.`}if(t==="ollama")return{apiKey:"",baseUrl:`${Oa(process.env.OLLAMA_HOST??s.defaultBaseUrl)}/v1`,protocol:t,model:n,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:n,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=Lt[t];if(!i)return`Unknown provider '${t}'.`;let o=process.env[i];return o?{apiKey:o,baseUrl:s.defaultBaseUrl,protocol:t,model:n,isFreeModel:!1}:`No API key for '${t}'. Set ${i} in your .env file.`}function Da(r,e){let t=new Headers;return r&&t.set("Content-Type",r),e&&t.set("Cache-Control",e),t.set("Access-Control-Allow-Origin","*"),t.set("Cross-Origin-Resource-Policy","cross-origin"),t}function Gd(r,e,t){r.get(`${e}*`,async n=>{let{pathname:s}=new URL(n.req.url);if(!s.startsWith(e))return n.text("Not Found",404);let i=decodeURIComponent(s.slice(e.length));try{let o=Ba(i,t),a=await st.readFile(o);return new Response(a,{headers:{"Content-Type":lS(o)}})}catch{return n.text("Not Found",404)}})}function lS(r){switch(ae.extname(r).toLowerCase()){case".js":case".mjs":return"text/javascript";case".wasm":return"application/wasm";case".json":case".map":return"application/json";default:return"application/octet-stream"}}function Ba(r,e){let t=ae.resolve(e,r),n=ae.normalize(e),s=ae.normalize(t);if(s!==n&&!s.startsWith(n+ae.sep))throw new Error("Path traversal detected - access denied");return t}async function Ur(r){let e=await import("net");return new Promise(t=>{let n=e.createServer();n.listen(r,zd,()=>{let s=n.address(),i=typeof s=="object"&&s?s.port:r;n.close(()=>t(i))}),n.on("error",()=>{t(Ur(r+1))})})}import Qd from"chokidar";var Xd={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function Ks(r){let{bulbPath:e,emitter:t,debounceMs:n=150}=r,s,i=Qd.watch(e,Xd);return i.on("change",()=>{s&&clearTimeout(s),s=setTimeout(()=>t.emit("reload"),n)}),()=>{s&&clearTimeout(s),i.close()}}function Ws(r){let{dir:e,onChange:t,debounceMs:n=150}=r,s,i=Qd.watch(e,Xd);return i.on("all",()=>{s&&clearTimeout(s),s=setTimeout(t,n)}),()=>{s&&clearTimeout(s),i.close()}}pe();async function ep(r,e,t,n,s){let i=process.cwd(),o=Ts(process.pid),a=e.watch?new ja:void 0,c=new ja;c.setMaxListeners(0);let l=he(e.mode),f=await Aa(r);f.length&&console.log(`Replacing the running server for this bulb (pid ${f.map(S=>S.pid).join(", ")})`);let u=1;console.log(ka(u)),console.log(`Loading ${$t.basename(r)}...`);let{html:d,bulb:p,serverExports:m}=await ha(r,e.watch,e.trust,n,s);je(l,r,p.server);let h=await Ur(e.port),y=await Js({getHtml:()=>d,basePath:i,port:h,reloadEmitter:a,messageEmitter:c,getServerExports:()=>m,localOverride:n?{name:n.name,serveDir:n.serveDir}:void 0,trusted:e.trust,trustHint:t}),v=`http://localhost:${h}`,k=e.trust?void 0:Ct(p);await Os({pid:process.pid,port:h,url:v,file:r,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,predicted:k}),console.log(`
|
|
1195
1212
|
${p.name}`),console.log(` ${v}`),h!==e.port&&console.log(` (port ${e.port} was busy)`),e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log(k?` trust: restricted \u2014 this bulb appears to use ${k}; re-run with --trust to enable it:
|
|
1196
1213
|
${t}
|
|
1197
1214
|
`:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
|
|
1198
1215
|
`),e.watch&&console.log(` Watching for changes...
|
|
1199
|
-
`);let g,b;if(e.watch&&a){let S=new ja;if(S.on("reload",async()=>{try{console.log("Recompiling...");let A=await
|
|
1216
|
+
`);let g,b;if(e.watch&&a){let S=new ja;if(S.on("reload",async()=>{try{console.log("Recompiling...");let A=await ha(r,!0,e.trust,n,s);d=A.html,m=A.serverExports,u++,console.log(ka(u)),a.emit("reload")}catch(A){console.error("Compile error:",A)}}),g=Ks({bulbPath:r,emitter:S}),n){let{name:A,serveDir:E}=n;b=Ws({dir:E,onChange:()=>{console.log(`Local package '${A}' changed. Browser reloading...
|
|
1200
1217
|
`),a.emit("reload")}})}}e.open&&(f.some(S=>S.port===h)?console.log(` Reusing the open browser tab.
|
|
1201
|
-
`):await
|
|
1202
|
-
Shutting down...`),y.close(),g?.(),b?.(),o(),await
|
|
1218
|
+
`):await Rt(v));let w=async()=>{console.log(`
|
|
1219
|
+
Shutting down...`),y.close(),g?.(),b?.(),o(),await jr(process.pid);let S=$t.join($t.dirname(r),".typebulb","server.mjs");await Zd.rm(S,{force:!0}).catch(()=>{}),process.exit(0)};process.on("SIGINT",w),process.on("SIGTERM",w)}import{readFileSync as Kp,copyFileSync as Kk,existsSync as Wk}from"fs";import*as Y from"path";import{fileURLToPath as Vk}from"url";import{EventEmitter as Hk}from"events";pe();var qa="/agents/claude/client.js",uS=`
|
|
1203
1220
|
(() => {
|
|
1204
1221
|
const api = async (name, ...args) => {
|
|
1205
1222
|
const resp = await fetch('/__api/' + name, {
|
|
@@ -1234,15 +1251,15 @@ Shutting down...`),y.close(),g?.(),b?.(),o(),await Br(process.pid);let S=$t.join
|
|
|
1234
1251
|
es.onerror = () => { es.close(); };
|
|
1235
1252
|
}
|
|
1236
1253
|
})();
|
|
1237
|
-
`;function
|
|
1254
|
+
`;function tp(r){let{name:e,styles:t,mountHtml:n,watch:s,theme:i}=r;return`<!DOCTYPE html>
|
|
1238
1255
|
<html>
|
|
1239
1256
|
<head>
|
|
1240
1257
|
<meta charset="utf-8">
|
|
1241
1258
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1242
|
-
<title>${
|
|
1243
|
-
${
|
|
1259
|
+
<title>${us(e)} - typebulb</title>
|
|
1260
|
+
${ds(e,i)}
|
|
1244
1261
|
<style>
|
|
1245
|
-
${
|
|
1262
|
+
${fs}
|
|
1246
1263
|
</style>
|
|
1247
1264
|
<style>
|
|
1248
1265
|
${t}
|
|
@@ -1254,19 +1271,19 @@ ${n}
|
|
|
1254
1271
|
${s?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
|
|
1255
1272
|
|
|
1256
1273
|
<script>
|
|
1257
|
-
${
|
|
1274
|
+
${uS}
|
|
1258
1275
|
</script>
|
|
1259
1276
|
|
|
1260
1277
|
<script type="module" src="${qa}"></script>
|
|
1261
1278
|
</body>
|
|
1262
|
-
</html>`}async function
|
|
1279
|
+
</html>`}async function Wp(r){let e=process.cwd(),t=Ts(process.pid),n=r.watch?new Hk:void 0,s=he(r.mode),i=await Promise.resolve().then(()=>(Jp(),Up));je(s,Y.join(e,"mirror"));let o=Y.dirname(Vk(import.meta.url)),a=Y.join(o,"agents","claude"),c=Y.join(o,"..","cli","agents","claude"),l=Y.join(a,"styles.css"),f=Y.join(a,"index.html"),u=()=>tp({name:"Claude Mirror",styles:Kp(l,"utf8"),mountHtml:Kp(f,"utf8"),watch:r.watch}),d=await Ur(r.port),p=await Js({getHtml:u,basePath:e,port:d,reloadEmitter:n,getServerExports:()=>i,trusted:!0,staticAssets:{mount:`${Y.posix.dirname(qa)}/`,dir:a}}),m=`http://localhost:${d}`;await Os({pid:process.pid,port:d,url:m,file:"agent:claude",cwd:e,startedAt:Date.now(),trust:!0,agent:"claude"}),console.log(`
|
|
1263
1280
|
Claude Mirror`),console.log(` ${m}`),d!==r.port&&console.log(` (port ${r.port} was busy)`),r.watch&&console.log(` Watching for changes...
|
|
1264
|
-
`);async function h(){await(await import("esbuild")).build({entryPoints:[Y.join(c,"client","index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:Y.join(a,"client.js")});for(let g of["styles.css","index.html"])
|
|
1265
|
-
`),n.emit("reload")}catch(b){console.error("Mirror rebuild failed:",b instanceof Error?b.message:b)}finally{g=!1}}}})}r.open&&await
|
|
1266
|
-
Shutting down...`);try{i.shutdownSwitcher?.()}catch{}p.close(),y?.(),t(),await
|
|
1267
|
-
`);let c=new
|
|
1268
|
-
`)}catch(p){
|
|
1269
|
-
`),process.exit(0)}async function
|
|
1270
|
-
`),process.exit(1)}function
|
|
1271
|
-
${e}`),process.exit(1))}async function
|
|
1272
|
-
${l.url}`),r.open&&await
|
|
1281
|
+
`);async function h(){await(await import("esbuild")).build({entryPoints:[Y.join(c,"client","index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:Y.join(a,"client.js")});for(let g of["styles.css","index.html"])Kk(Y.join(c,g),Y.join(a,g))}let y;if(r.watch&&n){let k=Wk(c),g=!1;y=Ws({dir:k?c:a,onChange:async()=>{if(!g){g=!0;try{k&&await h(),console.log(`Mirror rebuilt. Browser reloading...
|
|
1282
|
+
`),n.emit("reload")}catch(b){console.error("Mirror rebuild failed:",b instanceof Error?b.message:b)}finally{g=!1}}}})}r.open&&await Rt(m);let v=async()=>{console.log(`
|
|
1283
|
+
Shutting down...`);try{i.shutdownSwitcher?.()}catch{}p.close(),y?.(),t(),await jr(process.pid),process.exit(0)};process.on("SIGINT",v),process.on("SIGTERM",v)}import*as Vp from"path";import{EventEmitter as Yk}from"events";async function Hp(r,e,t,n,s){let i=he(t),o=!1,a=async()=>{let{bulb:c,config:l}=await oe(r);o||(je(i,r,c.server),o=!0),await Lr(c.server,s,n,l.dependencies)};if(console.log(`Running ${Vp.basename(r)}...`),await a(),e){console.log(`Watching for changes...
|
|
1284
|
+
`);let c=new Yk;c.on("reload",async()=>{try{console.log("Re-running..."),await a()}catch(l){console.error("Error:",l)}}),Ks({bulbPath:r,emitter:c})}}import{Console as Gk}from"node:console";pe();$r();async function Gp(r,e,t,n,s){ex();try{let p=L(r),m=(await $()).find(h=>L(h.file)===p);m&&As(m.pid,de(m.pid).offset)}catch{}let i=he(t),{bulb:o,config:a}=await oe(r);o.server||Yr("This bulb has no **server.ts** block; nothing to call."),je(i,r,o.server);let c;try{c=await Lr(o.server,s,n,a.dependencies)}catch(p){Yr(p instanceof Error?p.message:String(p))}let l=qs(c,e.fn);if(!l){let p=[...Object.keys(c).filter(m=>typeof c[m]=="function"),...Object.keys(Ma)];Yr(`Function '${e.fn}' not found. Available: ${p.length?p.join(", "):"(none)"}.`)}let f=await zk(e);if(Fs(l)){try{for await(let p of l(...f))await Yp(JSON.stringify(p,zp)+`
|
|
1285
|
+
`)}catch(p){Yr(p instanceof Error?p.stack??p.message:String(p))}process.exit(0)}let u;try{u=await l(...f)}catch(p){Yr(p instanceof Error?p.stack??p.message:String(p))}let d=Zk(u);d!==void 0&&await Yp(d+`
|
|
1286
|
+
`),process.exit(0)}async function zk(r){if(r.hasArgsFlag){let e=r.argsJson??"";return e==="-"&&(e=await tx()),Xk(e)}return Qk(r.positional)}function Qk(r){return r.map(e=>{try{return JSON.parse(e)}catch{return e}})}function Xk(r){let e;try{e=JSON.parse(r)}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 Zk(r){if(r!==void 0)return JSON.stringify(r,zp,2)}function zp(r,e){return typeof e=="bigint"?e.toString():e}function Yr(r){process.stderr.write(r+`
|
|
1287
|
+
`),process.exit(1)}function ex(){let r=new Gk(process.stderr,process.stderr);console.log=r.log.bind(r),console.info=r.info.bind(r),console.debug=r.debug.bind(r),console.dir=r.dir.bind(r)}function Yp(r){return new Promise((e,t)=>{process.stdout.write(r,n=>n?t(n):e())})}async function tx(){let r=[];for await(let e of process.stdin)r.push(e);return Buffer.concat(r).toString("utf-8")}var oc="0.17.2";function Qp(r,e){r||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
|
|
1288
|
+
${e}`),process.exit(1))}async function rx(){let r=gc(process.argv.slice(2));if(r.version&&(console.log(`typebulb ${oc}`),process.exit(0)),r.help&&(yc(),process.exit(0)),r.subcommand==="logs"){await jd(r.file||void 0,{follow:r.follow,clear:r.clear,run:r.run,lines:r.lines});return}if(r.subcommand==="wait"){await qd(r.file||void 0,{match:r.match,timeoutSec:r.timeoutSec??1800});return}if(r.subcommand==="stop"){r.stopScope?await Ud(r.stopScope):await Fd(r.file||void 0);return}if(r.subcommand==="send"){await Kd(r.file,r.sendMessage);return}if(r.subcommand==="skill"){await Md(oc);return}if(r.subcommand==="models"){await Ld(r.mode);return}if(r.subcommand==="agent"){if(!r.agentTarget){await Cd(oc);return}ad(r.agentTarget)||(console.error(`Unknown agent '${r.agentTarget}'. Known: ${Dr().join(", ")}.`),process.exit(1));let l=await Ea(process.cwd(),r.agentTarget);if(l){console.log(`Mirror '${r.agentTarget}' is already running for this project:
|
|
1289
|
+
${l.url}`),r.open&&await Rt(l.url);return}await Wp(r);return}if(r.subcommand==="trust"||r.subcommand==="untrust"){await gd(r.file||void 0,r.subcommand==="trust");return}let e;if(!r.file||r.file==="."){let l=await nd(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=ke.resolve(r.file);await Xp.access(e).then(()=>!0,()=>!1)||(Dr().includes(r.file)&&(console.error(`To open the ${r.file} agent mirror, run: npx typebulb agent:${r.file}`),process.exit(1)),console.error(`File not found: ${e}`),process.exit(1)),e.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));let n=r.file&&r.file!=="."?r.file:ke.relative(process.cwd(),e)||ke.basename(e),s=`npx typebulb --trust ${n.includes(" ")?`"${n}"`:n}`;if(r.subcommand==="predict"){await md(e,s);return}let i=!r.noTrust&&Xe(e);i&&!r.trust&&console.log("trust: granted from memory (run `typebulb untrust` to revoke)"),r.trust=r.noTrust?!1:r.trust||i;let o;try{o=await oe(e)}catch{}let a;if(r.local){o&&!(r.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${r.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&r.subcommand!=="call"&&(!o.bulb.code||r.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await hc(r.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.log(`replace: ${a.name} \u2192 ${ke.relative(process.cwd(),a.dir)||"."}`)}if(r.subcommand==="check"){await hd(e,a);return}let c=ke.dirname(e);if(r.subcommand==="call"){Qp(r.trust,s),await Gp(e,{fn:r.fn,positional:r.callArgs,argsJson:r.argsJson,hasArgsFlag:r.hasArgsFlag},r.mode,a,c);return}if(o&&o.bulb.server&&(!o.bulb.code||r.server)){Qp(r.trust,s),await Hp(e,r.watch,r.mode,a,c);return}await ep(e,r,s,a,c)}rx().catch(r=>{console.error("Error:",r.message),process.exit(1)});
|