@visulima/packem 2.0.0-alpha.89 → 2.0.0-alpha.90
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/CHANGELOG.md +14 -0
- package/dist/builder/typedoc/index.d.ts +1 -1
- package/dist/cli/index.js +37 -37
- package/dist/config/index.d.ts +1 -1
- package/dist/config/preset/preact.d.ts +1 -1
- package/dist/config/preset/react.d.ts +1 -1
- package/dist/config/preset/solid.d.ts +1 -1
- package/dist/config/preset/svelte.d.ts +1 -1
- package/dist/config/preset/vue.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/packem_shared/default-mHB0zin0.js +1 -0
- package/dist/packem_shared/index-bcxmFLOh.js +249 -0
- package/dist/packem_shared/{oxcTransformPlugin-Dwvbw2jE-DgTjbGep.js → oxcTransformPlugin-Dwvbw2jE-BsmmBg7q.js} +1 -1
- package/dist/packem_shared/{types.d-ICL9GlqC.d.ts → types.d-BkLP91NJ.d.ts} +36 -1
- package/dist/rollup/plugins/oxc/oxc-transformer.js +1 -1
- package/package.json +4 -4
- package/dist/packem_shared/default-BKj8akkL.js +0 -1
- package/dist/packem_shared/index-BnalE1Ho.js +0 -245
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import{createRequire as Me,builtinModules as Em}from"node:module";import{g as uo,o as Sm,a as Hu,P as Fi,b as km,T as po,N as ft,F as dt,u as qu,t as fo,c as Hi,J as Ju,S as jm,d as Ct,s as rt,i as zu,q as ne,j as Ae,e as De,h as Tn,I as qi,k as Yt,m as gi,l as Uu,_ as Am,H as Nn,E as Gu,n as qt,K as Om,p as Rm,f as Cm,r as Tm}from"./create-or-update-key-storage-DHOKZmnD.js";import ut,{env as Nm,versions as Fn,platform as er}from"node:process";import{H as Z,_ as ke,B as Fr,w as G,v as Tt,P as X,E as Pm,G as tr,V as Fe,k as _m,W as Vu,Z as Ku}from"./utils-Bsoe7qJG.js";import{installPackage as Yu,detectPackageManager as Mm}from"@antfu/install-pkg";import{E as Hn,L as Xu,p as Im,i as Zu,s as Wm,P as Qu,T as Bm,A as Dm,a as Xt,f as Lm,M as Fm,b as Nt,r as Oe,c as Xr,d as mo,e as Ji,g as ep,h as tp,k as Hm,l as rp,m as qm,S as Jm,n as yi,v as zm,o as Zr,j as Um}from"./oxcTransformPlugin-Dwvbw2jE-BsmmBg7q.js";import{importTrace as zi,replace as Ui,alias as Gi,purePlugin as Gm,pureNewExpressionPlugin as nl,browserslistToEsbuild as ol,polyfillNode as Vm,chunkSplitter as Km,wasm as Ym,preserveDirectivesPlugin as Xm,dynamicImportVars as Zm,commonjs as Qm,jsxRemoveAttributes as eh,visualizer as th,patchErrorWithTrace as rh}from"@visulima/packem-rollup";import{ENDING_REGEX as nh,svgToCssDataUri as oh,svgToTinyDataUri as sh,memoizeByKey as Vi,arrayify as ih,enhanceRollupError as np,FileCache as ah}from"@visulima/packem-share";import{RUNTIME_EXPORT_CONVENTIONS as op,SPECIAL_EXPORT_CONVENTIONS as sp,DEFAULT_EXTENSIONS as ho,ENDING_REGEX as Ki,PRODUCTION_ENV as Wr,DEVELOPMENT_ENV as sl,EXCLUDE_REGEXP as kt,ALLOWED_TRANSFORM_EXTENSIONS_REGEX as Et,VALID_EXPORT_EXTENSIONS as lh}from"@visulima/packem-share/constants";import{getCacheHash as Ve,memoize as ch,isFromNodeModules as Vo,isBareSpecifier as Tr,parseSpecifier as $i,isOutsideProject as uh,getPackageName as ph,replaceContentWithinMarker as fh,arrayify as bi,svgEncoder as dh,sortUserPlugins as Yi,getDtsExtension as Ke,getChunkFilename as Br,getEntryFileNames as mh,getOutputExtension as Pe,warn as Y}from"@visulima/packem-share/utils";import hh from"browserslist";import{createHooks as gh}from"hookable";import{createJiti as yh}from"jiti";import{x as qn,exec as $h}from"tinyexec";import Se from"magic-string";import{fileURLToPath as ip}from"node:url";import bh,{existsSync as Xi,createReadStream as Zi,createWriteStream as wh,watch as il}from"node:fs";import{isNodeBuiltin as mn,parseNodeModulePath as al,findStaticImports as go,parseStaticImport as vh,findExports as xh,fileURLToPath as Eh,resolveModuleExportNames as Sh,resolvePath as ap,pathToFileURL as kh}from"mlly";import{parseSync as yo}from"oxc-parser";import jh from"rollup-plugin-license";import lp,{stat as Qr,chmod as cp,readFile as Jn,copyFile as Ah,readdir as Oh,rm as $o,mkdtemp as up,mkdir as pp,writeFile as fp,rename as Rh}from"node:fs/promises";import{walk as Ch}from"estree-walker";import{isAbsolute as Th,dirname as wi,join as dp,resolve as Nh}from"node:path";import{cjsInteropPlugin as Qi}from"@visulima/packem-rollup/plugin/cjs-interop";import{cpus as Ph,tmpdir as mp,homedir as _h}from"node:os";import{createFilter as Ze,normalizePath as Hr}from"@rollup/pluginutils";import Mh from"workerpool";import{transformAsync as Ih}from"@babel/core";import hp from"mime";import*as Wh from"rs-module-lexer";import it from"typescript";import Bh from"clean-css";import{minify as Dh}from"html-minifier-next";import{init as gp,parse as Lh}from"cjs-module-lexer";import Fh,{createHash as Hh,randomUUID as qh}from"node:crypto";import{JsonPlugin as Jh}from"@visulima/packem-rollup/plugin/json";import{confirm as zh,isCancel as Uh,spinner as Gh}from"@clack/prompts";import ll from"node:path/posix";import{readTsConfig as Vh,findTsConfig as Kh}from"@visulima/tsconfig";import{createDefu as Yh}from"defu";import Xh from"child_process";import Zh from"node:child_process";import{promisify as Qh,debuglog as eg}from"node:util";import{distance as tg}from"fastest-levenshtein";import{createBrotliCompress as rg,constants as ng,createGzip as og}from"node:zlib";import{Buffer as sg}from"node:buffer";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
|
+
const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
|
|
3
|
+
const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
|
|
4
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
5
|
+
var ig=Object.defineProperty,oe=(e,t)=>ig(e,"name",{value:t,configurable:!0});const ag=Me(import.meta.url),Jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,bo=oe(e=>{if(typeof Jt<"u"&&Jt.versions&&Jt.versions.node){const[t,r]=Jt.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Jt.getBuiltinModule(e)}return ag(e)},"__cjs_getBuiltinModule"),{createRequire:lg}=bo("node:module"),jt=Jt,{execFileSync:cg}=bo("node:child_process"),Nr=bo("node:fs"),ug=bo("node:tty"),OO={alert:7,critical:6,debug:1,emergency:8,error:5,informational:2,notice:3,trace:2,warning:4},pg={alert:{color:"red",label:"alert",logLevel:"alert"},await:{color:"blue",label:"awaiting",logLevel:"informational"},complete:{color:"cyan",label:"complete",logLevel:"informational"},critical:{color:"redBright",label:"critical",logLevel:"critical"},debug:{color:"gray",label:"debug",logLevel:"debug"},emergency:{color:"redBright",label:"emergency",logLevel:"emergency"},error:{color:"red",label:"error",logLevel:"error"},info:{color:"blueBright",label:"info",logLevel:"informational"},log:{label:"",logLevel:"informational"},notice:{color:"magentaBright",label:"notice",logLevel:"notice"},pending:{color:"magenta",label:"pending",logLevel:"informational"},start:{color:"greenBright",label:"start",logLevel:"informational"},stop:{color:"red",label:"stop",logLevel:"informational"},success:{color:"green",label:"success",logLevel:"informational"},trace:{color:"cyanBright",label:"trace",logLevel:"trace"},wait:{color:"blue",label:"waiting",logLevel:"informational"},warn:{color:"yellow",label:"warning",logLevel:"warning"},warning:{color:"yellow",label:"warning",logLevel:"warning"},watch:{color:"yellowBright",label:"watching",logLevel:"informational"}},fg=Symbol("EMPTY");var dg=Object.defineProperty,mg=oe((e,t)=>dg(e,"name",{value:t,configurable:!0}),"g$6");const hg=mg(e=>{const t=Object.keys(e).map(r=>e[r].label??"");return t.length===0?"":t.reduce((r,n)=>r.length>n.length?r:n,"")},"getLongestLabel");var gg=Object.defineProperty,yp=oe((e,t)=>gg(e,"name",{value:t,configurable:!0}),"T$5"),yg=Object.defineProperty,ae=yp((e,t)=>yg(e,"name",{value:t,configurable:!0}),"l"),$g=Object.defineProperty,bg=ae((e,t)=>$g(e,"name",{value:t,configurable:!0}),"L");const He=bg((e,t,r,n,o,s=", ")=>{const i=e.length;if(i===0)return"";let a=n;o!==void 0&&(a=o);const l=r.truncate;let u="",c="",p="";for(let f=0;f<i;f+=1){const d=f+1===e.length,m=f+2===e.length;p=`…(${String(e.length-f)})`;let h=e[f];r.truncate=l-u.length-(d?0:s.length);const $=c||a(h,t,r,n)+(d?"":s),y=u.length+$.length,g=y+p.length;if(d&&y>l&&u.length+p.length<=l||!d&&!m&&g>l)break;h=e[f+1];const w=m?"":s;if(d?c="":c=a(h,t,r,n)+w,!d&&m&&g>l&&y+c.length>l)break;if(u+=$,!d&&!m&&y+c.length>=l){p=`…(${String(e.length-f-1)})`;break}p=""}return`${u}${p}`},"inspectList");var wg=Object.defineProperty,wo=ae((e,t)=>wg(e,"name",{value:t,configurable:!0}),"s$6");const vg=wo(([e,t],r,n)=>(n.truncate-=3,t?`${n.stylize(String(e),"yellow")}=${n.stylize(`"${t}"`,"string")}`:n.stylize(String(e),"yellow")),"inspectAttribute"),xg=wo((e,t,r)=>{switch(e.nodeType){case 1:return $p(e,e,r,t);case 3:return t(e.data,t,r);default:return t(e,t,r)}},"inspectNode"),vi=wo((e,t,r,n)=>He(e,e,t,r,xg,`
|
|
6
|
+
`),"inspectNodeCollection"),$p=wo((e,t,r,n)=>{const o=e.getAttributeNames(),s=e.tagName.toLowerCase(),i=r.stylize(`<${s}`,"special"),a=r.stylize(">","special"),l=r.stylize(`</${s}>`,"special");r.truncate-=s.length*2+5;let u="";o.length>0&&(u+=" ",u+=He(o.map(f=>[f,e.getAttribute(f)]),t,r,n,vg," ")),r.truncate-=u.length;const{truncate:c}=r;let p=vi(e.children,r,n,void 0);return p&&p.length>c&&(p=`…(${String(e.children.length)})`),`${i}${u}${a}${p}${l}`},"inspectHTMLElement");var Eg=Object.defineProperty,Sg=ae((e,t)=>Eg(e,"name",{value:t,configurable:!0}),"n$4");const kg=Sg((e,t,r)=>e.length===0?"Arguments []":(t.truncate-=13,`Arguments [ ${He(e,e,t,r)} ]`),"inspectArguments");var jg=Object.defineProperty,bp=ae((e,t)=>jg(e,"name",{value:t,configurable:!0}),"r$3");const Ag=bp((e,t)=>{let r;if(e===" ")r=" ";else if(typeof e=="number"&&e>0)r=Array.from({length:e+1}).join(" ");else return;return{base:r,prev:`
|
|
7
|
+
${Array.from({length:t+1}).join(r)}`}},"getIndent"),vo=bp((e,t)=>{if(e.length===0)return"";const r=t.prev+t.base;return r+e.split(", ").join(`,${r}`)+t.prev},"indentedJoin");var Og=Object.defineProperty,wp=ae((e,t)=>Og(e,"name",{value:t,configurable:!0}),"i$5");const Rg=/^[a-z_]\w*$/i,Cg=/^"|"$/g,Tg=wp((e,t)=>{if(Rg.test(e))return e;const r=JSON.stringify(e);return t.quoteStyle==="double"?r.replaceAll('"',String.raw`\"`):r.replaceAll("'",String.raw`\'`).replaceAll(String.raw`\"`,'"').replaceAll(Cg,"'")},"quoteComplexKey"),qr=wp(([e,t],r,n,o)=>{n.truncate-=2;let s;typeof e=="string"?s=Tg(e,n):typeof e=="number"?s=String(e):s=`[${o(e,r,n)}]`,n.truncate-=s.length;const i=o(t,r,n);return`${s}: ${i}`},"inspectProperty");var Ng=Object.defineProperty,vp=ae((e,t)=>Ng(e,"name",{value:t,configurable:!0}),"p$4");const Pg=vp(e=>{for(const t of e)if(Array.isArray(t)||typeof t=="object"&&t!==null)return!0;return!1},"multiLineValues"),_g=vp((e,t,r,n)=>{const o=Object.keys(e).slice(e.length);if(e.length===0&&o.length===0)return"[]";t.truncate-=4;let s=He(e,e,t,r);t.truncate-=s.length;let i="";o.length>0&&(i=He(o.map(l=>[l,e[l]]),e,t,r,qr));const a=n&&Pg(e);return a&&(s=vo(s,n)),`[${a?"":" "}${s}${i?`, ${i}`:""}${a?"":" "}]`},"inspectArray");var Mg=Object.defineProperty,Ig=ae((e,t)=>Mg(e,"name",{value:t,configurable:!0}),"o$7");const cl=/\d(?=(?:\d{3})+(?!\d))/g,Wg=/\d{3}/g,Bg=/_$/,xp=Ig((e,t)=>{if(e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY||t.includes("e"))return t;if(typeof e=="number"){const r=e<0?-Math.floor(-e):Math.floor(e);if(r!==e){const n=String(r),o=t.slice(n.length+1);return`${n.replace(cl,"$&_")}.${o.replace(Wg,"$&_").replace(Bg,"")}`}}return t.replace(cl,"$&_")},"addNumericSeparator");var Dg=Object.defineProperty,Ep=ae((e,t)=>Dg(e,"name",{value:t,configurable:!0}),"i$4");const Lg=Ep(e=>e>="\uD800"&&e<="\uDBFF","isHighSurrogate"),yt=Ep((e,t,r="…")=>{e=String(e);const n=r.length,o=e.length;if(n>t&&o>n)return r;if(o>t&&o>n){let s=t-n;return s>0&&Lg(e[s-1])&&(s-=1),`${e.slice(0,s)}${r}`}return e},"truncate");var Fg=Object.defineProperty,Hg=ae((e,t)=>Fg(e,"name",{value:t,configurable:!0}),"e$4");const ul=Hg((e,t)=>{let r=yt(e.toString(),t.truncate-1);return r!=="…"&&(r+="n"),t.stylize(t.numericSeparator?xp(e,r):r,"bigint")},"inspectBigInt");var qg=Object.defineProperty,Jg=ae((e,t)=>qg(e,"name",{value:t,configurable:!0}),"y");const zg=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:void 0),Pn=Jg((e,t,r,n)=>{if("window"in globalThis&&e===globalThis)return"{ [object Window] }";if(e===globalThis||"global"in globalThis&&e===globalThis)return"{ [object globalThis] }";const o=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e),i=zg(e)===Object.prototype||e.constructor===Object,a=e instanceof Object?"":"null prototype";let l;!i&&Symbol.toStringTag in e?l=e[Symbol.toStringTag]:l=a?"Object":"";const u=l||a?`[${[l,a].filter(Boolean).join(": ")}] `:"";if(o.length===0&&s.length===0)return`${u}{}`;t.truncate-=4;const c=He(o.map(d=>[d,e[d]]),e,t,r,qr),p=He(s.map(d=>[d,e[d]]),e,t,r,qr);let f="";return c&&p&&(f=", "),n?`${u}{${vo(c+f+p,n)}}`:`${u}{ ${c}${f}${p} }`},"inspectObject");var Ug=Object.defineProperty,Gg=ae((e,t)=>Ug(e,"name",{value:t,configurable:!0}),"s$3");const Vg=Gg((e,t,r,n)=>{let o="";return o=o||e.constructor.name,(!o||o==="_class")&&(o="<Anonymous Class>"),t.truncate-=o.length,`${o} ${Pn(e,t,r,n)}`},"inspectClass");var Kg=Object.defineProperty,Yg=ae((e,t)=>Kg(e,"name",{value:t,configurable:!0}),"i$3");const Xg=Yg((e,t)=>{const r=e.toJSON();if(r===null)return"Invalid Date";const n=r.split("T"),o=n[0];return t.stylize(`${o}T${yt(n[1],t.truncate-o.length-1)}`,"date")},"inspectDate");var Zg=Object.defineProperty,Qg=ae((e,t)=>Zg(e,"name",{value:t,configurable:!0}),"c$4");const ey=new Set(["column","columnNumber","description","fileName","line","lineNumber","message","name","number","stack"]),ty=Qg((e,t,r)=>{const n=Object.getOwnPropertyNames(e).filter(a=>!ey.has(a)),{name:o}=e;t.truncate-=o.length;let s="";typeof e.message=="string"?s=yt(e.message,t.truncate):n.unshift("message"),s=s?`: ${s}`:"",t.truncate-=s.length+5;const i=He(n.map(a=>[a,e[a]]),e,t,r,qr);return`${o}${s}${i?` { ${i} }`:""}`},"inspectObject");var ry=Object.defineProperty,ny=ae((e,t)=>ry(e,"name",{value:t,configurable:!0}),"c$3");const pl=ny((e,t)=>{const r=e[Symbol.toStringTag]||"Function",n=e.toString();if(n.length<t.truncate-12)return t.stylize(`[${r}: ${n}]`,"special");const{name:o}=e;return o?t.stylize(`[${r} ${yt(o,t.truncate-11)}]`,"special"):t.stylize(`[${r}]`,"special")},"inspectFunction");var oy=Object.defineProperty,Sp=ae((e,t)=>oy(e,"name",{value:t,configurable:!0}),"p$3");const sy=Sp(([e,t],r,n,o)=>(n.truncate-=4,e=o(e,r,n),n.truncate-=e.length,`${e} => ${o(t,r,n)}`),"inspectMapEntry"),iy=Sp((e,t,r,n)=>{if(e.size<=0)return"Map (0) {}";t.truncate-=7;let o=He([...e.entries()],e,t,r,sy);return n&&(o=vo(o,n)),`Map (${String(e.size)}) {${n?"":" "}${o}${n?"":" "}}`},"inspectMap");var ay=Object.defineProperty,ly=ae((e,t)=>ay(e,"name",{value:t,configurable:!0}),"e$3");function rr(e,t){return Number.isNaN(e)?t.stylize("NaN","number"):e===Number.POSITIVE_INFINITY?t.stylize("Infinity","number"):e===Number.NEGATIVE_INFINITY?t.stylize("-Infinity","number"):e===0?t.stylize(1/e===Number.POSITIVE_INFINITY?"+0":"-0","number"):t.stylize(yt(t.numericSeparator?xp(e,e.toString()):e.toString(),t.truncate),"number")}oe(rr,"j$5");yp(rr,"P");ae(rr,"u$3");ly(rr,"inspectNumber");var cy=Object.defineProperty,uy=ae((e,t)=>cy(e,"name",{value:t,configurable:!0}),"e$2");const py=uy(()=>"Promise{…}","getPromiseValue");var fy=Object.defineProperty,dy=ae((e,t)=>fy(e,"name",{value:t,configurable:!0}),"p$1");const my=dy((e,t)=>{const r=t.truncate-(2+e.flags.length);return t.stylize(`/${yt(e.source,r)}/${e.flags}`,"regexp")},"inspectRegExp");var hy=Object.defineProperty,gy=ae((e,t)=>hy(e,"name",{value:t,configurable:!0}),"i$1");const yy=gy((e,t,r,n)=>{if(e.size===0)return"Set (0) {}";t.truncate-=7;let o=He([...e],e,t,r);return n&&(o=vo(o,n)),`Set (${String(e.size)}) {${n?"":" "}${o}${n?"":" "}}`},"inspectSet");var $y=Object.defineProperty,by=ae((e,t)=>$y(e,"name",{value:t,configurable:!0}),"l");const wy=by((e,t)=>{const r=t.quoteStyle==="double"?'"':"'";return t.quoteStyle==="double"&&(e=e.replaceAll('"','"')),r+e+r},"wrapQuotes");var vy=Object.defineProperty,kp=ae((e,t)=>vy(e,"name",{value:t,configurable:!0}),"e$1");const fl=new RegExp(String.raw`['\0-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5`+String.raw`\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]`,"g"),xy={" ":String.raw`\t`,"\n":String.raw`\n`,"\f":String.raw`\f`,"\r":String.raw`\r`,"\b":String.raw`\b`,"'":String.raw`\'`,"\\":"\\\\"},Ey=16,Sy=kp(e=>xy[e]||String.raw`\u${`0000${e.codePointAt(0).toString(Ey)}`.slice(-4)}`,"escape"),dl=kp((e,t)=>(fl.test(e)&&(e=e.replaceAll(fl,Sy)),t.stylize(wy(yt(e,t.truncate-2),t),"string")),"inspectString");var ky=Object.defineProperty,jy=ae((e,t)=>ky(e,"name",{value:t,configurable:!0}),"o");const ml=jy(e=>"description"in Symbol.prototype?e.description?`Symbol(${e.description})`:"Symbol()":e.toString(),"inspectSymbol");var Ay=Object.defineProperty,jp=ae((e,t)=>Ay(e,"name",{value:t,configurable:!0}),"f");const Oy=jp(e=>typeof Buffer=="function"&&e instanceof Buffer?"Buffer":e[Symbol.toStringTag],"getArrayName"),et=jp((e,t,r)=>{const n=Oy(e);t.truncate-=n.length+4;const o=Object.keys(e).slice(e.length);if(e.length===0&&o.length===0)return`${n}[]`;let s="";for(let a=0;a<e.length;a++){const l=`${t.stylize(yt(e[a],t.truncate),"number")}${a===e.length-1?"":", "}`;if(t.truncate-=l.length,e[a]!==e.length&&t.truncate<=3){s+=`…(${String(e.length-e[a]+1)})`;break}s+=l}let i="";return o.length>0&&(i=He(o.map(a=>[a,e[a]]),e,t,r,qr)),`${n}[ ${s}${i?`, ${i}`:""} ]`},"inspectTypedArray");var Ry=Object.defineProperty,Ee=ae((e,t)=>Ry(e,"name",{value:t,configurable:!0}),"r");const zn=new WeakMap,xi={},Cy={Arguments:kg,Array:_g,ArrayBuffer:Ee(()=>"","ArrayBuffer"),BigInt:ul,bigint:ul,Boolean:Ee((e,t)=>t.stylize(String(e),"boolean"),"Boolean"),boolean:Ee((e,t)=>t.stylize(String(e),"boolean"),"boolean"),DataView:Ee(()=>"","DataView"),Date:Xg,Error:ty,Float32Array:et,Float64Array:et,Function:pl,function:pl,Generator:Ee(()=>"","Generator"),HTMLCollection:vi,Int8Array:et,Int16Array:et,Int32Array:et,Map:iy,NodeList:vi,null:Ee((e,t)=>t.stylize("null","null"),"null"),Number:rr,number:rr,Promise:py,RegExp:my,Set:yy,String:dl,string:dl,Symbol:ml,symbol:ml,Uint8Array:et,Uint8ClampedArray:et,Uint16Array:et,Uint32Array:et,undefined:Ee((e,t)=>t.stylize("undefined","undefined"),"undefined"),WeakMap:Ee((e,t)=>t.stylize("WeakMap{…}","special"),"WeakMap"),WeakSet:Ee((e,t)=>t.stylize("WeakSet{…}","special"),"WeakSet")},hl=Symbol.for("nodejs.util.inspect.custom"),Ty=Ee((e,t,r,n)=>{if(!("window"in globalThis)&&typeof e[hl]=="function")return e[hl](n,t);if("inspect"in e&&typeof e.inspect=="function")return e.inspect(n,t);if("constructor"in e&&zn.has(e.constructor))return zn.get(e.constructor)?.(e,t)??"unknown";const o=xi[r];return o?o(e,t):""},"inspectCustom"),Ap=Ee((e,t,r,n)=>{if(n.includes(e))return"[Circular]";if(r>=t.depth&&t.depth>0&&typeof e=="object")return Array.isArray(e)?"[Array]":"[Object]";const o=Ee((u,c,p)=>(c&&(n=[...n,c]),Ap(u,p,r+1,n)),"inspect"),s=t.indent?Ag(t.indent,r):void 0;let i=e===null?"null":typeof e;i==="object"&&(i=Object.prototype.toString.call(e).slice(8,-1));const a=Cy[i];if(a!==void 0)return a(e,t,o,s);if(t.customInspect&&e){const u=Ty(e,t,i,t.depth-r);if(u)return typeof u=="string"?u:o(u,e,t)}const l=e?Object.getPrototypeOf(e):!1;return l===Object.prototype||l===null?Pn(e,t,o,s):e&&typeof HTMLElement=="function"&&e instanceof HTMLElement?$p(e,e,t,o):"constructor"in e?e.constructor!==Object?Vg(e,t,o,s):Pn(e,t,o,s):e===Object(e)?Pn(e,t,o,s):t.stylize(String(e),i)},"internalInspect"),gl=Ee((e,t={})=>{const r={breakLength:Number.POSITIVE_INFINITY,customInspect:!0,depth:5,indent:void 0,maxArrayLength:Number.POSITIVE_INFINITY,numericSeparator:!0,quoteStyle:"single",showHidden:!1,showProxy:!1,stylize:Ee(n=>n,"stylize"),truncate:Number.POSITIVE_INFINITY,...t};if(r.indent!==void 0&&r.indent!==" "&&!(Number.parseInt(r.indent,10)===r.indent&&r.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `undefined`');return Ap(e,r,0,[])},"inspect");Ee((e,t)=>zn.has(e)?!1:(zn.set(e,t),!0),"registerConstructor");Ee((e,t)=>e in xi?!1:(xi[e]=t,!0),"registerStringTag");var Ny=Object.defineProperty,Py=oe((e,t)=>Ny(e,"name",{value:t,configurable:!0}),"r$6");const _y=Py((e,t)=>(t.__write??t.write.bind(t)).call(t,e),"writeStream");var My=Object.defineProperty,Iy=oe((e,t)=>My(e,"name",{value:t,configurable:!0}),"A$4"),Wy=Object.defineProperty,ea=Iy((e,t)=>Wy(e,"name",{value:t,configurable:!0}),"$"),By=Object.defineProperty,Dy=ea((e,t)=>By(e,"name",{value:t,configurable:!0}),"r$1");const Ly=Dy(e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
8
|
+
`),"normalizeLF"),Fy=globalThis.process??Object.create(null),yl={versions:{}},$l=new Proxy(Fy,{get(e,t){if(t in e)return e[t];if(t in yl)return yl[t]}});var Hy=Object.defineProperty,qy=ea((e,t)=>Hy(e,"name",{value:t,configurable:!0}),"b");const Jy=qy((e,t,r,n)=>{const o={column:0,line:-1,...e.start},s={...o,...e.end},i=o.line,a=o.column,l=s.line,u=s.column;let c=Math.max(i-(r+1),0),p=Math.min(t.length,l+n);i===-1&&(c=0),l===-1&&(p=t.length);const f=l-i,d={};if(f)for(let m=0;m<=f;m++){const h=m+i;if(!a)d[h]=!0;else if(m===0){const $=t[h-1]?.length;d[h]=[a,($??0)-a+1]}else if(m===f)d[h]=[0,u];else{const $=t[h-m]?.length;d[h]=[0,$]}}else a===u?d[i]=a?[a,0]:!0:d[i]=[a,(u??0)-(a??0)];return{end:p,markerLines:d,start:c}},"getMarkerLines");var zy=Object.defineProperty,hn=ea((e,t)=>zy(e,"name",{value:t,configurable:!0}),"t");const Uy=$l.platform==="win32"&&!$l.env?.WT_SESSION?">":"❯",Gy=hn((e,t,r)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...r,color:{gutter:hn(m=>m,"gutter"),marker:hn(m=>m,"marker"),message:hn(m=>m,"message"),...r?.color}},o=typeof t.start.column=="number";let s=Ly(e).split(`
|
|
9
|
+
`);typeof n.tabWidth=="number"&&(s=s.map(m=>m.replaceAll(" "," ".repeat(n.tabWidth))));const{end:i,markerLines:a,start:l}=Jy(t,s,n.linesAbove,n.linesBelow),u=String(i).length,{gutter:c,marker:p,message:f}=n.color;let d=s.slice(l,i).map((m,h)=>{const $=l+1+h,y=a[$],g=` ${String($)}`.slice(-u),w=!a[$+1],b=` ${g}${n.showGutter?" |":""}`;if(y){let v="";if(Array.isArray(y)){const S=m.replaceAll(/[^\t]/g," ").slice(0,Math.max(y[0]-1,0)),x=y[1]||1;v=[`
|
|
10
|
+
`,n.prefix+c(b.replaceAll(/\d/g," "))," ",S,p("^").repeat(x)].join(""),w&&n.message&&(v+=` ${f(n.message)}`)}return[n.prefix+p(Uy),c(b),m.length>0?` ${m}`:"",v].join("")}return`${n.prefix} ${c(b)}${m.length>0?` ${m}`:""}`}).join(`
|
|
11
|
+
`);return n.message&&!o&&(d=`${n.prefix+" ".repeat(u+1)+n.message}
|
|
12
|
+
${d}`),d},"codeFrame");var Vy=Object.defineProperty,Ky=oe((e,t)=>Vy(e,"name",{value:t,configurable:!0}),"x$3"),Yy=Object.defineProperty,Xy=Ky((e,t)=>Yy(e,"name",{value:t,configurable:!0}),"x"),Zy=Object.defineProperty,ot=Xy((e,t)=>Zy(e,"name",{value:t,configurable:!0}),"u");const Pt=ot((e,...t)=>{process.env.DEBUG&&process.env.DEBUG==="true"&&console.debug(`error:parse-stacktrace: ${e}`,...t)},"debugLog"),_t="<unknown>",Qy=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,e$=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,t$=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,r$=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,n$=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,o$=/in\s(.*)\s\(at\s(.+)\)\sat/,s$=/^(?:.*@)?(.*):(\d+):(\d+)$/,i$=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,a$=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,l$=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,bl=/\(error: (.*)\)/,c$=/at\s/,u$=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,p$=/^\s+|\s+$/g,f$=/\S*(?:Error: |AggregateError:)/,Op=/^Anonymous function$/,d$=/^\s*in\s.*/,m$=/^.*?\s*at\s.*/,h$=/^.*?\s*@.*|\[native code\]/,Rp=ot((e,t)=>{const r=e.includes("safari-extension"),n=e.includes("safari-web-extension");return r||n?[e.includes("@")?e.split("@")[0]:_t,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},"extractSafariExtensionDetails"),Cp=ot((e,t)=>{const r=t$.exec(t);r&&(e.file=r[1],e.line=+r[2],e.column=+r[3])},"parseMapped"),g$=ot(e=>{const t=o$.exec(e);if(t){Pt(`parse nested node error stack line: "${e}"`,`found: ${JSON.stringify(t)}`);const n=t[2].split(":");return{column:n[2]?+n[2]:void 0,file:n[0],line:n[1]?+n[1]:void 0,methodName:t[1]??_t,raw:e,type:void 0}}const r=n$.exec(e);if(r){Pt(`parse node error stack line: "${e}"`,`found: ${JSON.stringify(r)}`);const n={column:r[4]?+r[4]:void 0,file:r[2]?r[2].replace(c$,""):void 0,line:r[3]?+r[3]:void 0,methodName:r[1]??_t,raw:e,type:e.startsWith("internal")?"internal":void 0};return Cp(n,`${r[2]}:${r[3]}:${r[4]}`),n}},"parseNode"),y$=ot(e=>{const t=Qy.exec(e);if(t){Pt(`parse chrome error stack line: "${e}"`,`found: ${JSON.stringify(t)}`);const r=t[2]?.startsWith("native"),n=t[2]?.startsWith("eval")||t[1]?.startsWith("eval");let o,s;if(n){const u=e$.exec(e);if(u){const c=u$.exec(u[1]);c?(t[2]=c[4]??c[1],t[3]=c[5]??c[2],t[4]=c[3]):u[2]&&(t[2]=u[1]),u[2]&&(o={column:u[4]?+u[4]:void 0,file:u[2],line:u[3]?+u[3]:void 0,methodName:"eval",raw:e,type:"eval"})}else{const c=r$.exec(e);c&&(s={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0},o={column:c[6]?+c[6]:void 0,file:c[1],line:c[5]?+c[5]:void 0,methodName:"eval",raw:c[0],type:"eval"})}}const[i,a]=Rp(t[1]?t[1].replace(Op,"<anonymous>"):_t,t[2]),l={column:t[4]?+t[4]:void 0,evalOrigin:o,file:a,line:t[3]?+t[3]:void 0,methodName:i,raw:e,type:n?"eval":r?"native":void 0};return s?(l.column=s.column,l.file=s.file,l.line=s.line):Cp(l,`${a}:${t[3]}:${t[4]}`),l}},"parseChromium"),$$=ot((e,t)=>{const r=i$.exec(e);if(r){Pt(`parse gecko error stack line: "${e}"`,`found: ${JSON.stringify(r)}`);const n=r[3]?.includes(" > eval"),o=n&&r[3]&&a$.exec(r[3]);let s;n&&o&&(r[3]=o[1],s={column:r[5]?+r[5]:void 0,file:r[3],line:r[4]?+r[4]:void 0,methodName:"eval",raw:e,type:"eval"},r[4]=o[2]);const[i,a]=Rp(r[1]?r[1].replace(Op,"<anonymous>"):_t,r[3]);let l;(t?.type==="safari"||!n&&t?.type==="firefox")&&t.column?l=t.column:!n&&r[5]&&(l=+r[5]);let u;return(t?.type==="safari"||!n&&t?.type==="firefox")&&t.line?u=t.line:r[4]&&(u=+r[4]),{column:l,evalOrigin:s,file:a,line:u,methodName:i,raw:e,type:n?"eval":a.includes("[native code]")?"native":void 0}}},"parseGecko"),b$=ot((e,t)=>{const r=l$.exec(e);if(!(r&&r[2].includes(" > eval"))&&r)return Pt(`parse firefox error stack line: "${e}"`,`found: ${JSON.stringify(r)}`),{column:r[4]?+r[4]:t?.column??void 0,file:r[2],line:r[3]?+r[3]:t?.line??void 0,methodName:r[1]||_t,raw:e,type:void 0}},"parseFirefox"),w$=ot(e=>{const t=s$.exec(e);if(t)return Pt(`parse react android native error stack line: "${e}"`,`found: ${JSON.stringify(t)}`),{column:t[3]?+t[3]:void 0,file:t[1],line:t[2]?+t[2]:void 0,methodName:_t,raw:e,type:void 0}},"parseReactAndroidNative"),Tp=ot((e,{filter:t,frameLimit:r=50}={})=>{const n=e;let o=(typeof n.stacktrace=="string"?n.stacktrace:e.stack??"").split(`
|
|
13
|
+
`).map(s=>(bl.test(s)?s.replace(bl,"$1"):s).replaceAll(p$,"")).filter(s=>!f$.test(s)&&s!=="eval code");return t&&(o=o.filter(s=>t(s))),o=o.slice(0,r),o.reduce((s,i,a)=>{if(!i||i.length>1024)return s;let l;if(d$.test(i))l=g$(i);else if(m$.test(i))l=y$(i);else if(h$.test(i)){let u;if(a===0){const c=e,p=c.columnNumber,f=c.lineNumber,d=c.line,m=c.column;p||f?u={column:p,line:f,type:"firefox"}:(d||m)&&(u={column:m,line:d,type:"safari"})}l=b$(i,u)??$$(i,u)}else l=w$(i);return l?s.push(l):Pt(`parse error stack line: "${i}"`,"not parser found"),s},[])},"parseStacktrace");var v$=Object.defineProperty,x$=oe((e,t)=>v$(e,"name",{value:t,configurable:!0}),"p$6"),E$=Object.defineProperty,Np=x$((e,t)=>E$(e,"name",{value:t,configurable:!0}),"m");const S$=lg(import.meta.url),zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ta=Np(e=>{if(typeof zt<"u"&&zt.versions&&zt.versions.node){const[t,r]=zt.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return zt.getBuiltinModule(e)}return S$(e)},"__cjs_getBuiltinModule"),{existsSync:k$,readFileSync:j$}=ta("node:fs"),{relative:A$}=ta("node:path"),{cwd:O$}=zt,{fileURLToPath:R$}=ta("node:url");var C$=Object.defineProperty,ge=Np((e,t)=>C$(e,"name",{value:t,configurable:!0}),"o");const ir=ge((e,t,r)=>r===0?e:t===" "?e+" ".repeat(r):e+" ".repeat(t*r),"getPrefix"),T$=ge((e,t)=>{const r=e.replace("async file:","file:");return A$(t,r.startsWith("file:")?R$(r):r)},"getRelativePath"),N$=ge((e,t,r)=>{if(t)return r.title(e.message);const n=e.message?`: ${e.message}`:"";return r.title(e.name+n)},"getTitleText"),Pp=ge((e,{color:t,hideErrorTitle:r,indentation:n,prefix:o},s)=>`${ir(o,n,s)}${N$(e,r,t)}
|
|
14
|
+
`,"getMessage"),_p=ge((e,{color:t,indentation:r,prefix:n},o)=>{if(e.hint===void 0)return;const s=ir(n,r,o);let i="";if(Array.isArray(e.hint))for(const a of e.hint)i+=`${s+a}
|
|
15
|
+
`;else i+=s+e.hint;return t.hint(i)},"getHint"),ra=ge((e,{color:t,cwd:r,displayShortPath:n,indentation:o,prefix:s},i=0)=>{const a=n?T$(e.file,r):e.file,{fileLine:l,method:u}=t;return`${ir(s,o,i)}at ${e.methodName?`${u(e.methodName)} `:""}${l(a)}:${l(e.line?.toString()??"")}`},"getMainFrame"),Mp=ge((e,{color:t,indentation:r,linesAbove:n,linesBelow:o,prefix:s,showGutter:i,showLineNumbers:a,tabWidth:l},u)=>{if(e.file===void 0)return;const c=e.file.replace("file://","");if(!k$(c))return;const p=j$(c,"utf8");return Gy(p,{start:{column:e.column,line:e.line}},{color:t,linesAbove:n,linesBelow:o,prefix:ir(s,r,u),showGutter:i,showLineNumbers:a,tabWidth:l})},"getCode"),Ip=ge((e,t,r)=>{if(e.errors.length===0)return;let n=`${ir(t.prefix,t.indentation,r)}Errors:
|
|
16
|
+
|
|
17
|
+
`,o=!0;for(const s of e.errors)o?o=!1:n+=`
|
|
18
|
+
|
|
19
|
+
`,n+=Bp(s,{...t,framesMaxLimit:1,hideErrorCodeView:t.hideErrorErrorsCodeView},r+1);return`
|
|
20
|
+
${n}`},"getErrors"),Wp=ge((e,t,r)=>{let n=`${ir(t.prefix,t.indentation,r)}Caused by:
|
|
21
|
+
|
|
22
|
+
`;const o=e.cause;n+=Pp(o,t,r);const s=Tp(o).shift(),i=_p(o,t,r);if(i&&(n+=`${i}
|
|
23
|
+
`),s&&(n+=ra(s,t,r),!t.hideErrorCauseCodeView)){const a=Mp(s,t,r);a!==void 0&&(n+=`
|
|
24
|
+
${a}`)}if(o.cause)n+=`
|
|
25
|
+
${Wp(o,t,r+1)}`;else if(o instanceof AggregateError){const a=Ip(o,t,r);a!==void 0&&(n+=`
|
|
26
|
+
${a}`)}return`
|
|
27
|
+
${n}`},"getCause"),P$=ge((e,t)=>(e.length>0?`
|
|
28
|
+
`:"")+e.map(r=>ra(r,t)).join(`
|
|
29
|
+
`),"getStacktrace"),Bp=ge((e,t,r)=>{const n={cwd:O$(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...t,color:{fileLine:ge(i=>i,"fileLine"),gutter:ge(i=>i,"gutter"),hint:ge(i=>i,"hint"),marker:ge(i=>i,"marker"),message:ge(i=>i,"message"),method:ge(i=>i,"method"),title:ge(i=>i,"title"),...t.color}},o=Tp(e,{filter:t.filterStacktrace,frameLimit:n.framesMaxLimit}),s=o.shift();return[t.hideMessage?void 0:Pp(e,n,r),_p(e,n,r),s?ra(s,n,r):void 0,s&&!n.hideErrorCodeView?Mp(s,n,r):void 0,e instanceof AggregateError?Ip(e,n,r):void 0,e.cause===void 0?void 0:Wp(e,n,r),o.length>0?P$(o,n):void 0].filter(Boolean).join(`
|
|
30
|
+
`).replaceAll("\\","/")},"internalRenderError"),Ko=ge((e,t={})=>{if(t.framesMaxLimit!==void 0&&t.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return Bp(e,t,0)},"renderError");var _$=Object.defineProperty,na=oe((e,t)=>_$(e,"name",{value:t,configurable:!0}),"s$3"),M$=Object.defineProperty,xo=na((e,t)=>M$(e,"name",{value:t,configurable:!0}),"l");const oa=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],sa=[12288,12288,65281,65376,65504,65510],ia=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],aa=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Eo=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var I$=Object.defineProperty,W$=xo((e,t)=>I$(e,"name",{value:t,configurable:!0}),"r$1");const en=W$((e,t)=>{let r=0,n=Math.floor(e.length/2)-1;for(;r<=n;){const o=Math.floor((r+n)/2),s=o*2;if(t<e[s])n=o-1;else if(t>e[s+1])r=o+1;else return!0}return!1},"isInRange");var B$=Object.defineProperty,It=xo((e,t)=>B$(e,"name",{value:t,configurable:!0}),"r");const D$=oa[0],L$=oa.at(-1),F$=sa[0],H$=sa.at(-1),q$=ia[0],J$=ia.at(-1),z$=aa[0],U$=aa.at(-1),G$=Eo[0],V$=Eo.at(-1),wl=19968,[K$,Y$]=tn(Eo);function tn(e){let t=e[0],r=e[1];for(let n=0;n<e.length;n+=2){const o=e[n],s=e[n+1];if(wl>=o&&wl<=s)return[o,s];s-o>r-t&&(t=o,r=s)}return[t,r]}oe(tn,"b$2");na(tn,"b");xo(tn,"N");It(tn,"findWideFastPathRange");const Dp=It(e=>e<D$||e>L$?!1:en(oa,e),"isAmbiguous"),Lp=It(e=>e<F$||e>H$?!1:en(sa,e),"isFullWidth"),X$=It(e=>e<q$||e>J$?!1:en(ia,e),"isHalfWidth"),Z$=It(e=>e<z$||e>U$?!1:en(aa,e),"isNarrow"),Fp=It(e=>e>=K$&&e<=Y$?!0:e<G$||e>V$?!1:en(Eo,e),"isWide");function rn(e){return Dp(e)?"ambiguous":Lp(e)?"fullwidth":X$(e)?"halfwidth":Z$(e)?"narrow":Fp(e)?"wide":"neutral"}oe(rn,"v$2");na(rn,"q");xo(rn,"getCategory");It(rn,"getCategory");var Q$=Object.defineProperty,So=oe((e,t)=>Q$(e,"name",{value:t,configurable:!0}),"i$3"),e0=Object.defineProperty,ko=So((e,t)=>e0(e,"name",{value:t,configurable:!0}),"a"),t0=Object.defineProperty,la=ko((e,t)=>t0(e,"name",{value:t,configurable:!0}),"e");function ar(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}oe(ar,"s$2");So(ar,"s");ko(ar,"r");la(ar,"validate");function lr(e){return ar(e),rn(e)}oe(lr,"r$5");So(lr,"p");ko(lr,"eastAsianWidthType");la(lr,"eastAsianWidthType");function jo(e,{ambiguousAsWide:t=!1}={}){return ar(e),Lp(e)||Fp(e)||t&&Dp(e)?2:1}oe(jo,"o$5");So(jo,"W");ko(jo,"eastAsianWidth");la(jo,"eastAsianWidth");var r0=Object.defineProperty,n0=oe((e,t)=>r0(e,"name",{value:t,configurable:!0}),"p$3"),o0=Object.defineProperty,Hp=n0((e,t)=>o0(e,"name",{value:t,configurable:!0}),"e"),s0=Object.defineProperty,i0=Hp((e,t)=>s0(e,"name",{value:t,configurable:!0}),"E");const qp=String.raw,vl=qp`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,a0=i0(()=>new RegExp(qp`\p{RI}{2}|(?)${vl}(?:\u200D${vl})*`,"gu"),"default");var l0=Object.defineProperty,c0=Hp((e,t)=>l0(e,"name",{value:t,configurable:!0}),"p");const cr=new Set(["\x1B",""]),Ao="\x07",Jp="[",ca="m",Un="]8;;",u0=39,p0=/[\u200B\uFEFF\u2060-\u2064]/g,f0=new RegExp(`(?:\\${Jp}(?<code>\\d+)m|\\${Un}(?<uri>.*)${Ao})`),d0=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),gr=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,gn=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,_n=a0();c0(e=>e.replace(_n,""),"stripEmoji");var m0=Object.defineProperty,h0=oe((e,t)=>m0(e,"name",{value:t,configurable:!0}),"E"),g0=Object.defineProperty,y0=h0((e,t)=>g0(e,"name",{value:t,configurable:!0}),"A"),$0=Object.defineProperty,Oo=y0((e,t)=>$0(e,"name",{value:t,configurable:!0}),"d");const xl=new Map,yn=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Mn=Oo(e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other","getCharType"),b0=Oo((e,t)=>{const r=Math.floor(e/65536),n=e%65536;let o=xl.get(r);if(o||(o=new Map,xl.set(r,o)),o.has(n))return o.get(n);let s;if(Mn(e)==="latin")s=t.width.regular;else if(Mn(e)==="control")s=t.width.control;else if(Mn(e)==="wide")s=t.width.wide;else switch(lr(e)){case"ambiguous":{s=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{s=t.width.fullWidth;break}case"wide":{s=t.width.wide;break}default:s=t.width.regular}return o.set(n,s),s},"getCachedCharWidth"),w0=Oo(e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,"isCombiningCharacter"),Ei=Oo((e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?Ei(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},n=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:o}=e,s=o>1e4;let i=0,a=0,l=o,u=!1;const c=e.includes("\x1B")||e.includes("");for(;i<o;){if(c&&(e[i]==="\x1B"||e[i]==="")){if(e.startsWith("\x1B]8;;",i)){const $="\x1B]8;;\x07",y=$.length,g=e.indexOf("\x07",i+5);if(g!==-1){const w=e.indexOf($,g+1);if(w!==-1){const b=w+y,v=e.slice(g+1,w).replace(gr,""),S=Ei(v,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,n-a),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),x=S.width;if(S.truncated)u=!0,l=Math.min(l,i);else if(a+x>n&&(l=Math.min(l,i),u=!0,a+x>r.truncation.limit))break;if(a+=x,i=b,u&&a>=r.truncation.limit)break;continue}}}if(gr.lastIndex=i,gr.test(e)){const $=gr.lastIndex-i,y=r.truncation.countAnsiEscapeCodes?$:r.width.ansi;if(a+y>n&&(l=Math.min(l,i),a+y>r.truncation.limit)){u=!0;break}a+=y,i=gr.lastIndex;continue}}const d=e.codePointAt(i);if(d===8203||d===65279||d>=8288&&d<=8292){i+=1;continue}if(d===9){if(a+r.width.tab>n&&(l=Math.min(l,i),a+r.width.tab>r.truncation.limit)){u=!0;break}a+=r.width.tab,i+=1;continue}if(yn.lastIndex=i,yn.test(e)){const $=(yn.lastIndex-i)*r.width.regular;if(a+$>n){const y=Math.floor((n-a)/r.width.regular);if(l=Math.min(l,i+y),a+$>r.truncation.limit){u=!0;break}}a+=$,i=yn.lastIndex;continue}if((d<=31||d>=127&&d<=159)&&(gn.lastIndex=i,gn.test(e))){const $=(gn.lastIndex-i)*r.width.control;if(a+$>n&&(l=Math.min(l,i+Math.floor((n-a)/r.width.control)),a+$>r.truncation.limit)){u=!0;break}a+=$,i=gn.lastIndex;continue}if(_n.lastIndex=i,_n.test(e)){if(a+r.width.emoji>n&&(l=Math.min(l,i),a+r.width.emoji>r.truncation.limit)){u=!0;break}a+=r.width.emoji,i=_n.lastIndex;continue}const m=e.codePointAt(i)??0;if(w0(m)){i+=m>65535?2:1;continue}let h;if(s)h=b0(m,r);else switch(Mn(m)){case"control":{h=r.width.control;break}case"latin":{h=r.width.regular;break}case"wide":{h=r.width.wide;break}case"zero":{h=0;break}default:switch(lr(m)){case"ambiguous":{h=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{h=r.width.fullWidth;break}case"wide":{h=r.width.wide;break}default:h=r.width.regular}}if(a+h>n&&(l=Math.min(l,i),a+h>r.truncation.limit)){u=!0;break}a+=h,i+=m>65535?2:1}let p=a,f=!1;return u&&r.truncation.limit>=r.truncation.ellipsisWidth&&(p=r.truncation.limit,f=!0),{ellipsed:f,index:u?l:o,truncated:u,width:p}},"getStringTruncatedWidth");var v0=Object.defineProperty,x0=oe((e,t)=>v0(e,"name",{value:t,configurable:!0}),"i$1"),E0=Object.defineProperty,S0=x0((e,t)=>E0(e,"name",{value:t,configurable:!0}),"e"),k0=Object.defineProperty,j0=S0((e,t)=>k0(e,"name",{value:t,configurable:!0}),"r");const Ne=j0((e,t={})=>Ei(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"getStringWidth");var A0=Object.defineProperty,zp=oe((e,t)=>A0(e,"name",{value:t,configurable:!0}),"b"),O0=Object.defineProperty,Wt=zp((e,t)=>O0(e,"name",{value:t,configurable:!0}),"d"),R0=Object.defineProperty,C0=Wt((e,t)=>R0(e,"name",{value:t,configurable:!0}),"a");const T0=/\x1B\[(\d+)m/;let Up=class{static{oe(this,"T")}static{zp(this,"T")}static{Wt(this,"d")}static{C0(this,"AnsiStateTracker")}activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const r=T0.exec(t);if(!r)return;const n=Number.parseInt(r[1],10);switch(n){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(n>=30&&n<=37||n>=90&&n<=97)this.activeForeground=t;else if(n>=40&&n<=47||n>=100&&n<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(n))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(n)){const o={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[n];o&&(this.activeFormatting=this.activeFormatting.filter(s=>!s.includes(o)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const r={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(n=>{const o=r[n];o&&t.push(o)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};var N0=Object.defineProperty,Gp=Wt((e,t)=>N0(e,"name",{value:t,configurable:!0}),"o");const Vp=Gp((e,t)=>{if(!cr.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const r=!0,n=e.slice(t+1,t+1+Un.length).join("")===Un;return{isInsideEscape:r,isInsideLinkEscape:n}},"checkEscapeSequence"),P0=Gp((e,t={})=>{const r=new Up;let n="",o=!1,s="",i="",a=!1;const l=[...e];for(let u=0;u<l.length;u++){const c=l[u];if(c&&cr.has(c)){if(n){const h=t.getWidth?.(n)??0,$={isEscapeSequence:!1,isGrapheme:!0,text:n,width:h};if(a&&($.isHyperlink=!0,$.hyperlinkUrl=i),t.onSegment?.($,r)===!1)return;n=""}o=!0,s=c;const d=Vp(l,u),{isInsideLinkEscape:m}=d;if(m){let h=u+1;for(i="";h<l.length;){const y=l[h];if(y===Ao)break;i+=y,h+=1}i=i.slice(4);const $={hyperlinkUrl:i,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.($,r)===!1)return;u=h,a=!0,o=!1,s="";continue}if(u+1<l.length&&l[u+1]==="\\"&&a){const h={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(h,r)===!1)return;a=!1,i="",u+=1,o=!1,s="";continue}}if(o){if(s!==c&&(s+=c),c===ca){o=!1,r.processEscape(s);const d={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};if(t.onSegment?.(d,r)===!1)return;s=""}continue}n+=c;const p=t.getWidth?.(n)??0,f={isEscapeSequence:!1,isGrapheme:!0,text:n,width:p};if(a&&(f.isHyperlink=!0,f.hyperlinkUrl=i),t.onSegment?.(f,r)===!1)return;n=""}if(n){const u=t.getWidth?.(n)??0,c={isEscapeSequence:!1,isGrapheme:!0,text:n,width:u};a&&(c.isHyperlink=!0,c.hyperlinkUrl=i),t.onSegment?.(c,r)}if(s){const u={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};t.onSegment?.(u,r)}},"processAnsiString");var _0=Object.defineProperty,M0=Wt((e,t)=>_0(e,"name",{value:t,configurable:!0}),"t$1");const El=M0(e=>`${cr.values().next().value}${Jp}${String(e)}${ca}`,"wrapAnsiCode");var I0=Object.defineProperty,W0=Wt((e,t)=>I0(e,"name",{value:t,configurable:!0}),"s");const Sl=W0(e=>`${cr.values().next().value}${Un}${e}${Ao}`,"wrapAnsiHyperlink");var B0=Object.defineProperty,D0=Wt((e,t)=>B0(e,"name",{value:t,configurable:!0}),"l");const L0=D0(e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",r,n;const o=e.join(`
|
|
31
|
+
`),s=[...o];let i=0;for(const[a,l]of s.entries()){if(t+=l,cr.has(l)){const c=f0.exec(o.slice(i))?.groups??{};if(c.code!==void 0){const p=Number.parseFloat(c.code);r=p===u0?void 0:p}else c.uri!==void 0&&(n=c.uri.length===0?void 0:c.uri)}const u=d0.get(Number(r));s[a+1]===`
|
|
32
|
+
`?(n&&(t+=Sl("")),r&&u&&(t+=El(u))):l===`
|
|
33
|
+
`&&(r&&u&&(t+=El(r)),n&&(t+=Sl(n))),i+=l.length}return t},"preserveAnsi");var F0=Object.defineProperty,mt=Wt((e,t)=>F0(e,"name",{value:t,configurable:!0}),"f");const Kp=/(?=\s)|(?<=\s)/,Yp=/^\s+$/,Yo=mt(e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},"resetAnsiAtLineBreak"),At=mt(e=>{const t=e.split(" ");let r=t.length;for(;r>0&&Ne(t[r-1])===0;)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},"stringVisibleTrimSpacesRight"),Xp=mt((e,t,r)=>{if(e.length===0)return[""];if(t<=0)return[e];const n=[],o=new Up;let s="",i=0,a=!1,l=!1,u="",c=0;for(;c<e.length;){const p=e[c];if(cr.has(p)){a=!0,u=p,s+=p,l=Vp([...e],c).isInsideLinkEscape,c+=1;continue}if(a){u+=p,s+=p,l?p===Ao&&(a=l=!1):p===ca&&(a=!1,o.processEscape(u)),c+=1;continue}const f=Ne(p),d=p===" ";if(f===0){s+=p,c+=1;continue}if(i+f>t&&(s&&n.push(s+o.getEndEscapesForAllActiveAttributes()),s=o.getStartEscapesForAllActiveAttributes(),i=Ne(s),d&&r)){for(;c<e.length&&e[c]===" ";)c+=1;continue}if(s+=p,i+=f,i===t&&c<e.length-1&&(n.push(s+o.getEndEscapesForAllActiveAttributes()),s=o.getStartEscapesForAllActiveAttributes(),i=Ne(s),c+1<e.length&&e[c+1]===" "&&r)){for(c+=1;c<e.length&&e[c]===" ";)c+=1;continue}c+=1}return s&&n.push(s+o.getEndEscapesForAllActiveAttributes()),r?n.map(p=>At(p)):n},"wrapWithBreakAtWidth"),H0=mt((e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=[];let s="",i=0;return P0(n,{getWidth:Ne,onSegment:mt((a,l)=>{const u=a.text??"";if(a.isEscapeSequence)s+=u;else{const c=u===" ";if(a.width===0)return s+=u,!0;if(i+a.width>t&&(s&&o.push(s),s=l.getStartEscapesForAllActiveAttributes(),i=0,c))return r||o.push(l.getStartEscapesForAllActiveAttributes()+u),!0;s+=u,i+=a.width}return!0},"onSegment")}),s&&o.push(s),r?o.map(a=>At(a)):o},"wrapCharByChar"),q0=mt((e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=n.split(Kp),s=[];let i="",a=0,l=0;for(;l<o.length;){const u=o[l],c=Yp.test(u),p=Ne(u);if(u.length===0){l+=1;continue}if(r&&c&&a===0){l+=1;continue}if(a+p>t&&a>0){r?s.push(At(i)):s.push(i),i="",a=0;continue}i+=u,a+=p,l+=1}return i&&(r?s.push(At(i)):s.push(i)),s},"wrapWithWordBoundaries"),J0=mt((e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=n.split(Kp),s=[];let i="",a=0,l=0;for(;l<o.length;){const u=o[l],c=Yp.test(u),p=Ne(u);if(u.length===0){l+=1;continue}if(r&&c&&a===0){l+=1;continue}if(p>t){i&&s.push(Yo(r?At(i):i));const f=Xp(u,t,r);if(f.length>0){for(let d=0;d<f.length-1;d+=1)s.push(f[d]);i=f.at(-1),a=Ne(i)}else i="",a=0;l+=1;continue}if(a+p>t&&a>0&&(s.push(Yo(r?At(i):i)),i="",a=0,r&&c)){l+=1;continue}i+=u,a+=p,l+=1}return i&&s.push(Yo(r?At(i):i)),s},"wrapAndBreakWords"),Pr={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},z0=mt((e,t={})=>{const{removeZeroWidthCharacters:r=!0,trim:n=!0,width:o=80,wrapMode:s=Pr.PRESERVE_WORDS}=t;if(n&&e.trim()==="")return"";let i=e.normalize("NFC").replaceAll(`\r
|
|
34
|
+
`,`
|
|
35
|
+
`);return r&&(i=i.replaceAll(p0,"")),i.split(`
|
|
36
|
+
`).map(a=>{if(n&&a.trim()==="")return"";let l;switch(s){case Pr.BREAK_AT_CHARACTERS:{l=H0(a,o,n);break}case Pr.BREAK_WORDS:{l=J0(a,o,n);break}case Pr.STRICT_WIDTH:{l=Xp(a,o,n);break}default:l=q0(a,o,n)}return L0(l)}).join(`
|
|
37
|
+
`)},"wordWrap");var U0=Object.defineProperty,$t=oe((e,t)=>U0(e,"name",{value:t,configurable:!0}),"n$2");const Zp=80,Qp=24,Si=$t((e,t,{shell:r,env:n}={})=>cg(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:r,env:n}).trim(),"exec"),In=$t((e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),"create"),ef=$t((e,t)=>{const{columns:r,rows:n}=In(e,t);if(!(Number.isNaN(r)||Number.isNaN(n))&&!(r===Zp&&n===Qp))return{columns:r,rows:n}},"createIfNotDefault"),G0=$t(()=>{if(jt.platform!=="linux")return!0;try{const e=Nr.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const r=e.slice(t+2).trim().split(/\s+/),n=Number.parseInt(r[2],10),o=Number.parseInt(r[5],10);return Number.isNaN(n)||Number.isNaN(o)||o<=0?!1:n===o}catch{return!1}},"isForegroundProcess");function ua(){const{env:e,stdout:t,stderr:r}=jt;if(t?.columns&&t?.rows)return In(t.columns,t.rows);if(r?.columns&&r?.rows)return In(r.columns,r.rows);if(e.COLUMNS&&e.LINES)return In(e.COLUMNS,e.LINES);const n={columns:Zp,rows:Qp};return jt.platform==="win32"?Xo()??n:jt.platform==="darwin"?kl()??Xo()??n:kl()??Xo()??V0()??n}oe(ua,"O");$t(ua,"terminalSize");const kl=$t(()=>{try{const e=jt.platform==="darwin"?Nr.constants.O_EVTONLY|Nr.constants.O_NONBLOCK:Nr.constants.O_NONBLOCK,{columns:t,rows:r}=ug.WriteStream(Nr.openSync("/dev/tty",e));return{columns:t,rows:r}}catch{}},"devTty"),Xo=$t(()=>{try{const e=Si("tput",["cols"],{env:{TERM:"dumb",...jt.env}}),t=Si("tput",["lines"],{env:{TERM:"dumb",...jt.env}});if(e&&t)return ef(e,t)}catch{}},"tput"),V0=$t(()=>{try{if(!G0())return;const e=Si("resize",["-u"]).match(/\d+/g);if(e.length===2)return ef(e[0],e[1])}catch{}},"resize");var K0=Object.defineProperty,Y0=oe((e,t)=>K0(e,"name",{value:t,configurable:!0}),"r$2");const X0=Y0(e=>{const t=Object.keys(e).map(r=>e[r].badge??"");return t.length===0?"":t.reduce((r,n)=>r.length>n.length?r:n,"")},"getLongestBadge");var Z0=Object.defineProperty,Q0=oe((e,t)=>Z0(e,"name",{value:t,configurable:!0}),"r$1");const{bold:eb,cyan:tb,green:jl,grey:rb,magenta:nb,red:ob,yellow:Zo}=uo,sb={indent:2,quoteStyle:"single",stylize:Q0((e,t)=>{const r={bigint:Zo,boolean:Zo,date:nb,null:eb,number:Zo,regexp:ob,special:tb,string:jl,symbol:jl,undefined:rb};return Object.hasOwn(r,t)?r[t](e):e},"stylize")};var ib=Object.defineProperty,ab=oe((e,t)=>ib(e,"name",{value:t,configurable:!0}),"o$1");const{bold:lb,underline:cb}=uo,ub=ab((e,t)=>{let r=t.uppercase.label?e.toUpperCase():e;return r=t.underline.label?cb(r):r,t.bold.label&&(r=lb(r)),r},"formatLabel");var pb=Object.defineProperty,tf=oe((e,t)=>pb(e,"name",{value:t,configurable:!0}),"o");const fb=tf(e=>[e.getHours(),e.getMinutes(),e.getSeconds()].map(t=>String(t).padStart(2,"0")).join(":"),"dateFormatter");class db{static{oe(this,"AbstractPrettyReporter")}static{tf(this,"AbstractPrettyReporter")}styles;loggerTypes;constructor(t){this.styles={bold:{label:!1},dateFormatter:fb,underline:{label:!1,message:!1,prefix:!1,suffix:!1},uppercase:{label:!1},...t},this.loggerTypes=pg}setLoggerTypes(t){this.loggerTypes=t}}var mb=Object.defineProperty,rf=(e,t)=>mb(e,"name",{value:t,configurable:!0});Me(import.meta.url);const hb=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:gb,stderr:yb}=hb;var $b=Object.defineProperty,nf=rf((e,t)=>$b(e,"name",{value:t,configurable:!0}),"b");const{bgGrey:bb,bold:Al,cyan:wb,green:vb,greenBright:xb,grey:vt,red:Qo,underline:Ol,white:Eb}=uo,Sb=/[\\/]pail[\\/]dist/,es=nf(e=>!Sb.test(e),"pailFileFilter");let CO=class extends db{static{rf(this,"SimpleReporter")}static{nf(this,"SimpleReporter")}#e;#o;#t;#s=!1;#r;#n;constructor(t={}){const{error:r,inspect:n,...o}=t;super({uppercase:{label:!0,...o.uppercase},...o}),this.#r={...sb,indent:void 0,...n},this.#n={...r,color:{fileLine:vb,hint:wb,marker:Qo,message:Qo,method:xb,title:Qo}},this.#e=gb,this.#o=yb}setStdout(t){this.#e=t}setStderr(t){this.#o=t}setInteractiveManager(t){this.#t=t}setIsInteractive(t){this.#s=t}log(t){const r=this.formatMessage(t),n=t.type.level,o=["error","trace","warn"].includes(n)?"stderr":"stdout",s=o==="stderr"?this.#o:this.#e;this.#s&&this.#t!==void 0&&s.isTTY?this.#t.update(o,r.split(`
|
|
38
|
+
`),0):_y(`${r}
|
|
39
|
+
`,s)}formatMessage(t){const{columns:r}=ua();let n=r;typeof this.styles.messageLength=="number"&&(n=this.styles.messageLength);const{badge:o,context:s,date:i,error:a,file:l,groups:u,label:c,message:p,prefix:f,repeated:d,scope:m,suffix:h,traceError:$,type:y}=t,{color:g}=this.loggerTypes[y.name],w=g?uo[g]:Eb,b=u.map(()=>" ").join(""),v=[];if(u.length>0&&v.push(`${b+vt(`[${u.at(-1)??""}]`)} `),i&&v.push(`${vt(this.styles.dateFormatter(typeof i=="string"?new Date(i):i))} `),o)v.push(Al(w(o)));else{const j=X0(this.loggerTypes);j.length>0&&v.push(vt(" ".repeat(j.length)))}const S=hg(this.loggerTypes),x=Ne(S);if(c){const j=Ne(c),k=Math.max(0,x-j);v.push(`${Al(w(ub(c,this.styles)))} `," ".repeat(k))}else v.push(" ".repeat(x+1));d&&v.push(`${bb.white(`[${String(d)}x]`)} `),Array.isArray(m)&&m.length>0&&v.push(`${vt(`[${m.join(" > ")}]`)} `),f&&v.push(`${vt(`[${this.styles.underline.prefix?Ol(f):f}]`)} `);const E=Ne(v.join(""));if(p!==fg){const j=typeof p=="string"?p:gl(p,this.#r);v.push(b+z0(j,{trim:!1,width:n-3,wrapMode:Pr.STRICT_WIDTH}))}if(s){let j=!1;v.push(...s.map(k=>{if(k instanceof Error)return j=!0,`
|
|
40
|
+
|
|
41
|
+
${Ko(k,{...this.#n,filterStacktrace:es,prefix:b})}`;if(typeof k=="object")return` ${gl(k,this.#r)}`;const R=(j?`
|
|
42
|
+
|
|
43
|
+
`:" ")+String(k);return j=!1,R}))}if(a&&v.push(Ko(a,{...this.#n,filterStacktrace:es,prefix:b})),$&&v.push(`
|
|
44
|
+
|
|
45
|
+
${Ko($,{...this.#n,filterStacktrace:es,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:b})}`),h&&v.push(` ${b}${vt(this.styles.underline.suffix?Ol(h):h)}`),l){const j=(l.name??"")+(l.line?`:${String(l.line)}`:""),k=Math.max(0,E-Ne("Caller: "));v.push(`
|
|
46
|
+
`,vt("Caller: ")," ".repeat(k),j,`
|
|
47
|
+
`)}return v.join("")}};var NO="@visulima/packem",of="2.0.0-alpha.89";const PO={version:of};var kb=Object.defineProperty,sf=(e,t)=>kb(e,"name",{value:t,configurable:!0}),jb=Object.defineProperty,Ab=sf((e,t)=>jb(e,"name",{value:t,configurable:!0}),"o");let _O=class extends Error{static{sf(this,"n")}static{Ab(this,"DirectoryError")}constructor(t){super(`EISDIR: Illegal operation on a directory, ${t}`)}get code(){return"EISDIR"}set code(t){throw new Error("Cannot overwrite code EISDIR")}get name(){return"DirectoryError"}set name(t){throw new Error("Cannot overwrite name of DirectoryError")}};var Ob=Object.defineProperty,af=(e,t)=>Ob(e,"name",{value:t,configurable:!0}),Rb=Object.defineProperty,Cb=af((e,t)=>Rb(e,"name",{value:t,configurable:!0}),"t");let IO=class extends Error{static{af(this,"n")}static{Cb(this,"NotEmptyError")}constructor(t){super(`ENOTEMPTY: Directory not empty, ${t}`)}get code(){return"ENOTEMPTY"}set code(t){throw new Error("Cannot overwrite code ENOTEMPTY")}get name(){return"NotEmptyError"}set name(t){throw new Error("Cannot overwrite name of NotEmptyError")}};var Tb=Object.defineProperty,lf=(e,t)=>Tb(e,"name",{value:t,configurable:!0}),Nb=Object.defineProperty,Pb=lf((e,t)=>Nb(e,"name",{value:t,configurable:!0}),"o");let Mt=class extends Error{static{lf(this,"n")}static{Pb(this,"NotFoundError")}constructor(t){super(`ENOENT: ${t}`)}get code(){return"ENOENT"}set code(t){throw new Error("Cannot overwrite code ENOENT")}get name(){return"NotFoundError"}set name(t){throw new Error("Cannot overwrite name of NotFoundError")}};var _b=Object.defineProperty,Mb=(e,t)=>_b(e,"name",{value:t,configurable:!0}),Ib=Object.defineProperty,Wb=Mb((e,t)=>Ib(e,"name",{value:t,configurable:!0}),"n");Wb((e,{whitespace:t=!0}={})=>e.replace(Sm,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:t?r.replaceAll(/\S/g," "):""),"stripJsonComments");var Bb=Object.defineProperty,cf=(e,t)=>Bb(e,"name",{value:t,configurable:!0}),Db=Object.defineProperty,Lb=cf((e,t)=>Db(e,"name",{value:t,configurable:!0}),"r");async function Ro(e,t,r){const{buffer:n,compression:o,encoding:s="utf8",flag:i,...a}=r??{},l=await Hu(e,{buffer:n,compression:o,encoding:s,flag:i});return typeof t=="function"?Hn(l,t,a):Hn(l,a)}cf(Ro,"l");Lb(Ro,"readYaml");var Fb=Object.defineProperty,uf=(e,t)=>Fb(e,"name",{value:t,configurable:!0}),Hb=Object.defineProperty,qb=uf((e,t)=>Hb(e,"name",{value:t,configurable:!0}),"t");function Co(e,t,r){const{buffer:n,compression:o,encoding:s="utf8",flag:i,...a}=r??{},l=Fi(e,{buffer:n,compression:o,encoding:s,flag:i});return typeof t=="function"?Hn(l,t,a):Hn(l,a)}uf(Co,"l");qb(Co,"readYamlSync");var Jb=Object.defineProperty,pf=(e,t)=>Jb(e,"name",{value:t,configurable:!0}),zb=Object.defineProperty,Ub=pf((e,t)=>zb(e,"name",{value:t,configurable:!0}),"a");async function ff(e,t,r,n){let o,s,i;typeof r=="object"&&r!==null&&!Array.isArray(r)&&typeof r!="function"?(o=r,s=o.replacer,i=o.space):typeof n=="object"?(o=n,s=r,i=o.space):(s=r,i=n);const a=Xu(t,s,i??o);await km(e,a,o)}pf(ff,"c");Ub(ff,"writeYaml");var Gb=Object.defineProperty,df=(e,t)=>Gb(e,"name",{value:t,configurable:!0}),Vb=Object.defineProperty,Kb=df((e,t)=>Vb(e,"name",{value:t,configurable:!0}),"a");function mf(e,t,r,n){let o,s,i;typeof r=="object"&&r!==null&&!Array.isArray(r)&&typeof r!="function"?(o=r,s=o.replacer,i=o.space):typeof n=="object"?(o=n,s=r,i=o.space):(s=r,i=n);const a=Xu(t,s,i??o);po(e,a,o)}df(mf,"c");Kb(mf,"writeYamlSync");var Yb=Object.defineProperty,Xb=(e,t)=>Yb(e,"name",{value:t,configurable:!0}),Zb=Object.defineProperty,ur=Xb((e,t)=>Zb(e,"name",{value:t,configurable:!0}),"c");const hf=ur((e,t,r)=>{const n=Z(e),o=Z(t),s=o===n?".":ke(n,o);return r.some(i=>{const a=i.startsWith("./")?i.slice(2):i,l=s.startsWith("./")?s.slice(2):s;if(a==="."&&l===".")return!0;if(a.endsWith("/**")){const u=a.slice(0,-3);return l===u||l.startsWith(`${u}/`)}if(a.endsWith("/*")){const u=a.slice(0,-2);return u===""?l!=="."&&!l.includes("/"):l.startsWith(`${u}/`)||l===u}return l===a||l.startsWith(`${a}/`)})},"isPackageInWorkspace"),gf=ur(async e=>{const t=await ft("pnpm-workspace.yaml",{cwd:Z(e),type:"file"});if(!t)return;const r=await Ro(t),n=Array.isArray(r.packages)?r.packages:[];if(!hf(t,e,n))return;const o={};return r.catalog&&typeof r.catalog=="object"&&(o.catalog=r.catalog),r.catalogs&&typeof r.catalogs=="object"&&(o.catalogs=r.catalogs),Object.keys(o).length>0?o:void 0},"readPnpmCatalogs"),yf=ur(e=>{const t=dt("pnpm-workspace.yaml",{cwd:Z(e),type:"file"});if(!t)return;const r=Co(t),n=Array.isArray(r.packages)?r.packages:[];if(!hf(t,e,n))return;const o={};return r.catalog&&typeof r.catalog=="object"&&(o.catalog=r.catalog),r.catalogs&&typeof r.catalogs=="object"&&(o.catalogs=r.catalogs),Object.keys(o).length>0?o:void 0},"readPnpmCatalogsSync"),Qb=ur((e,t,r)=>{if(t==="catalog:")return r.catalog?.[e];if(t.startsWith("catalog:")){const n=t.slice(8);return r.catalogs?.[n]?.[e]}},"resolveCatalogReference"),e1=ur((e,t)=>{for(const[r,n]of Object.entries(e)){if(typeof n!="string")continue;const o=Qb(r,n,t);o&&(e[r]=o)}},"resolveDependenciesCatalogReferences"),To=ur((e,t)=>{const r=["dependencies","devDependencies","peerDependencies","optionalDependencies"];for(const n of r){if(!e[n]||typeof e[n]!="object")continue;const o=e[n];e1(o,t)}},"resolveCatalogReferences");var t1=Object.defineProperty,ye=(e,t)=>t1(e,"name",{value:t,configurable:!0});const r1=Me(import.meta.url),yr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pa=ye(e=>{if(typeof yr<"u"&&yr.versions&&yr.versions.node){const[t,r]=yr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return yr.getBuiltinModule(e)}return r1(e)},"__cjs_getBuiltinModule"),{existsSync:$f}=pa("node:fs"),{createInterface:n1}=pa("node:readline"),{styleText:Te}=pa("node:util");var o1=Object.defineProperty,we=ye((e,t)=>o1(e,"name",{value:t,configurable:!0}),"f");const Ye=we(e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},"isObject"),s1=we(e=>{if(!Ye(e))return!1;for(const t in e)if(Object.hasOwn(e,t))return!1;return!0},"isEmptyObject"),bf=new Set(["__proto__","prototype","constructor"]),wf=1e6,i1=we(e=>e>="0"&&e<="9","isDigit");function pr(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=wf}return!1}ye(pr,"p$1");we(pr,"shouldCoerceToNumber");function Dr(e,t){return bf.has(e)?!1:(e&&pr(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}ye(Dr,"y");we(Dr,"processSegment");function fa(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let r="",n="start",o=!1,s=0;for(const i of e){if(s++,o){r+=i,o=!1;continue}if(i==="\\"){if(n==="index")throw new Error(`Invalid character '${i}' in an index at position ${s}`);if(n==="indexEnd")throw new Error(`Invalid character '${i}' after an index at position ${s}`);o=!0,n=n==="start"?"property":n;continue}switch(i){case".":{if(n==="index")throw new Error(`Invalid character '${i}' in an index at position ${s}`);if(n==="indexEnd"){n="property";break}if(!Dr(r,t))return[];r="",n="property";break}case"[":{if(n==="index")throw new Error(`Invalid character '${i}' in an index at position ${s}`);if(n==="indexEnd"){n="index";break}if(n==="property"||n==="start"){if((r||n==="property")&&!Dr(r,t))return[];r=""}n="index";break}case"]":{if(n==="index"){if(r==="")r=(t.pop()||"")+"[]",n="property";else{const a=Number.parseInt(r,10);!Number.isNaN(a)&&Number.isFinite(a)&&a>=0&&a<=Number.MAX_SAFE_INTEGER&&a<=wf&&r===String(a)?t.push(a):t.push(r),r="",n="indexEnd"}break}if(n==="indexEnd")throw new Error(`Invalid character '${i}' after an index at position ${s}`);r+=i;break}default:{if(n==="index"&&!i1(i))throw new Error(`Invalid character '${i}' in an index at position ${s}`);if(n==="indexEnd")throw new Error(`Invalid character '${i}' after an index at position ${s}`);n==="start"&&(n="property"),r+=i}}}switch(o&&(r+="\\"),n){case"property":{if(!Dr(r,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}ye(fa,"parsePath");we(fa,"parsePath");function fr(e){if(typeof e=="string")return fa(e);if(Array.isArray(e)){const t=[];for(const[r,n]of e.entries()){if(typeof n!="string"&&typeof n!="number")throw new TypeError(`Expected a string or number for path segment at index ${r}, got ${typeof n}`);if(typeof n=="number"&&!Number.isFinite(n))throw new TypeError(`Path segment at index ${r} must be a finite number, got ${n}`);if(bf.has(n))return[];typeof n=="string"&&pr(n)?t.push(Number.parseInt(n,10)):t.push(n)}return t}return[]}ye(fr,"d");we(fr,"normalizePath");function nt(e,t,r){if(!Ye(e)||typeof t!="string"&&!Array.isArray(t))return r===void 0?e:r;const n=fr(t);if(n.length===0)return r;for(let o=0;o<n.length;o++){const s=n[o];if(e=e[s],e==null){if(o!==n.length-1)return r;break}}return e===void 0?r:e}ye(nt,"getProperty");we(nt,"getProperty");function da(e,t,r){if(!Ye(e)||typeof t!="string"&&!Array.isArray(t))return e;const n=e,o=fr(t);if(o.length===0)return e;for(let s=0;s<o.length;s++){const i=o[s];if(s===o.length-1)e[i]=r;else if(!Ye(e[i])){const a=typeof o[s+1]=="number";e[i]=a?[]:{}}e=e[i]}return n}ye(da,"setProperty");we(da,"setProperty");function vf(e,t){if(!Ye(e)||typeof t!="string"&&!Array.isArray(t))return!1;const r=fr(t);if(r.length===0)return!1;for(let n=0;n<r.length;n++){const o=r[n];if(n===r.length-1)return Object.hasOwn(e,o)?(delete e[o],!0):!1;if(e=e[o],!Ye(e))return!1}}ye(vf,"deleteProperty");we(vf,"deleteProperty");function Ot(e,t){if(!Ye(e)||typeof t!="string"&&!Array.isArray(t))return!1;const r=fr(t);if(r.length===0)return!1;for(const n of r){if(!Ye(e)||!(n in e))return!1;e=e[n]}return!0}ye(Ot,"hasProperty");we(Ot,"hasProperty");function Gn(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return e.replaceAll(/[\\.[]/g,String.raw`\$&`)}ye(Gn,"escapePath");we(Gn,"escapePath");function ma(e){const t=Object.entries(e);return Array.isArray(e)?t.map(([r,n])=>[pr(r)?Number.parseInt(r,10):r,n]):t}ye(ma,"m$2");we(ma,"normalizeEntries");function ha(e,t={}){if(!Array.isArray(e))throw new TypeError(`Expected an array, got ${typeof e}`);const{preferDotForIndices:r=!1}=t,n=[];for(const[o,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${o}, got ${typeof s}`);if(typeof s=="number")if(!Number.isInteger(s)||s<0){const i=Gn(String(s));n.push(o===0?i:`.${i}`)}else r&&o>0?n.push(`.${s}`):n.push(`[${s}]`);else if(typeof s=="string")if(s==="")o===0||n.push(".");else if(pr(s)){const i=Number.parseInt(s,10);r&&o>0?n.push(`.${i}`):n.push(`[${i}]`)}else{const i=Gn(s);n.push(o===0?i:`.${i}`)}}return n.join("")}ye(ha,"stringifyPath");we(ha,"stringifyPath");function*No(e,t=[],r=new Set){if(!Ye(e)||s1(e)){t.length>0&&(yield ha(t));return}if(!r.has(e)){r.add(e);for(const[n,o]of ma(e))t.push(n),yield*No(o,t,r),t.pop();r.delete(e)}}ye(No,"x");we(No,"deepKeysIterator");function xf(e){return[...No(e)]}ye(xf,"deepKeys");we(xf,"deepKeys");function Ef(e){const t={};if(!Ye(e))return t;for(const[r,n]of Object.entries(e))da(t,r,n);return t}ye(Ef,"unflatten");we(Ef,"unflatten");var a1=Object.defineProperty,ts=ye((e,t)=>a1(e,"name",{value:t,configurable:!0}),"i");const l1=ts(async e=>{const{default:t=!1,message:r,transformer:n}=e,o=ts(i=>{const a=Te(["cyan","bold"],"?"),l=Te(["bold"],i),u=t?`${Te(["greenBright"],"Y")}${Te(["gray"],"/n")}`:`y/${Te(["yellowBright"],"N")}`;return`${a} ${l} ${Te(["gray"],`(${u})`)}`},"formatMessage"),s=ts(i=>n?n(i):i?Te(["greenBright"],"Yes"):Te(["yellowBright"],"No"),"formatAnswer");return new Promise(i=>{const a=n1({input:process.stdin,output:process.stdout}),l=o(r);a.question(l,u=>{a.close();const c=u.trim().toLowerCase();if(c===""){i(t);return}if(c==="y"||c==="yes"){console.log(`${Te(["greenBright"],"✓")} ${s(!0)}`),i(!0);return}if(c==="n"||c==="no"){console.log(`${Te(["yellowBright"],"✗")} ${s(!1)}`),i(!1);return}console.log(`${Te(["gray"],"→")} ${s(t)}`),i(t)}),a.on("SIGINT",()=>{a.close(),console.log(`
|
|
48
|
+
${Te(["gray"],"→")} ${s(t)}`),i(t)})})},"confirm"),c1=typeof process.stdout<"u"&&!process.versions.deno&&!globalThis.window;var u1=Object.defineProperty,be=ye((e,t)=>u1(e,"name",{value:t,configurable:!0}),"l");const Sf=/, ([^,]*)$/,Vn=new Map,kf=new Map;let p1=class extends Error{static{ye(this,"M")}static{be(this,"PackageJsonValidationError")}constructor(t){super(`The following warnings were encountered while normalizing package data:
|
|
49
|
+
- ${t.join(`
|
|
50
|
+
- `)}`),this.name="PackageJsonValidationError"}};const Po=be((e,t,r=[])=>{const n=[];if(Im(e,o=>{n.push(o)},t),t&&n.length>0){const o=n.filter(s=>!r.some(i=>i instanceof RegExp?i.test(s):i===s));if(o.length>0)throw new p1(o)}return e},"normalizeInput"),f1=be(async e=>await Ro(e),"parseYamlFile"),d1=be(e=>Co(e),"parseYamlFileSync"),m1=be(async e=>{const t=await Hu(e);return Zu.parse(t)},"parseJson5File"),h1=be(e=>{const t=Fi(e);return Zu.parse(t)},"parseJson5FileSync"),jf=be(async(e,t)=>t?.yaml!==!1&&(e.endsWith(".yaml")||e.endsWith(".yml"))?f1(e):t?.json5!==!1&&e.endsWith(".json5")?m1(e):fo(e),"parsePackageFile"),Af=be((e,t)=>t?.yaml!==!1&&(e.endsWith(".yaml")||e.endsWith(".yml"))?d1(e):t?.json5!==!1&&e.endsWith(".json5")?h1(e):Hi(e),"parsePackageFileSync");be(async(e,t={})=>{const r={type:"file"};e&&(r.cwd=e);const n=["package.json"];t.yaml!==!1&&n.push("package.yaml","package.yml"),t.json5!==!1&&n.push("package.json5");let o;for(const l of n)if(o=await ft(l,r),o)break;if(!o)throw new Mt(`No such file or directory, for ${n.join(", ").replace(Sf," or $1")} found.`);const s=t.cache&&typeof t.cache!="boolean"?t.cache:kf;if(t.cache&&s.has(o))return s.get(o);const i=await jf(o,t);if(t.resolveCatalogs){const l=await gf(o);l&&To(i,l)}Po(i,t.strict??!1,t.ignoreWarnings);const a={packageJson:i,path:o};return t.cache&&s.set(o,a),a},"findPackageJson");be((e,t={})=>{const r={type:"file"};e&&(r.cwd=e);const n=["package.json"];t.yaml!==!1&&n.push("package.yaml","package.yml"),t.json5!==!1&&n.push("package.json5");let o;for(const l of n)if(o=dt(l,r),o)break;if(!o)throw new Mt(`No such file or directory, for ${n.join(", ").replace(Sf," or $1")} found.`);const s=t.cache&&typeof t.cache!="boolean"?t.cache:kf;if(t.cache&&s.has(o))return s.get(o);const i=Af(o,t);if(t.resolveCatalogs){const l=yf(o);l&&To(i,l)}Po(i,t.strict??!1,t.ignoreWarnings);const a={packageJson:i,path:o};return t.cache&&s.set(o,a),a},"findPackageJsonSync");be(async(e,t={})=>{const{cwd:r,...n}=t,o=Fr(r??process.cwd());await Ju(G(o,"package.json"),e,n)},"writePackageJson");be((e,t={})=>{const{cwd:r,...n}=t,o=Fr(r??process.cwd());jm(G(o,"package.json"),e,n)},"writePackageJsonSync");const ga=be((e,t)=>{const r=typeof e=="object"&&!Array.isArray(e);if(!r&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let n,o=!1,s;if(r)n=structuredClone(e);else if($f(e)){s=e;const a=t?.cache&&typeof t.cache!="boolean"?t.cache:Vn;if(t?.cache&&a.has(s))return a.get(s);n=Af(s,t),o=!0}else n=qu(e);if(t?.resolveCatalogs)if(o){const a=yf(e);a&&To(n,a)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");Po(n,t?.strict??!1,t?.ignoreWarnings);const i=n;return o&&t?.cache&&(typeof t.cache=="boolean"?Vn:t.cache).set(s,i),i},"parsePackageJsonSync"),LO=be(async(e,t)=>{const r=typeof e=="object"&&!Array.isArray(e);if(!r&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let n,o=!1,s;if(r)n=structuredClone(e);else if($f(e)){s=e;const a=t?.cache&&typeof t.cache!="boolean"?t.cache:Vn;if(t?.cache&&a.has(s))return a.get(s);n=await jf(s,t),o=!0}else n=qu(e);if(t?.resolveCatalogs)if(o){const a=await gf(e);a&&To(n,a)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");Po(n,t?.strict??!1,t?.ignoreWarnings);const i=n;return o&&t?.cache&&(typeof t.cache=="boolean"?Vn:t.cache).set(s,i),i},"parsePackageJson");be((e,t,r)=>nt(e,t,r),"getPackageJsonProperty");be((e,t)=>Ot(e,t),"hasPackageJsonProperty");const Of=be((e,t,r)=>{const n=nt(e,"dependencies",{}),o=nt(e,"devDependencies",{}),s=nt(e,"peerDependencies",{}),i={...n,...o,...r?.peerDeps===!1?{}:s};for(const a of t)if(Ot(i,a))return!0;return!1},"hasPackageJsonAnyDependency"),g1=be(async(e,t,r="dependencies",n={})=>{const o=nt(e,"dependencies",{}),s=nt(e,"devDependencies",{}),i=nt(e,"peerDependencies",{}),a=[],l={deps:!0,devDeps:!0,peerDeps:!1,...n};for(const u of t)l.deps&&Ot(o,u)||l.devDeps&&Ot(s,u)||l.peerDeps&&Ot(i,u)||a.push(u);if(a.length!==0){if(process.env.CI||c1&&!process.stdout.isTTY){const u=`Skipping package installation for [${t.join(", ")}] because the process is not interactive.`;if(n.throwOnWarn)throw new Error(u);n.logger?.warn?n.logger.warn(u):console.warn(u);return}if(typeof l.confirm?.message=="function"&&(l.confirm.message=l.confirm.message(a)),l.confirm?.message===void 0){const u=`${a.length===1?"Package is":"Packages are"} required for this config: ${a.join(", ")}. Do you want to install them?`;l.confirm===void 0?l.confirm={message:u}:l.confirm.message=u}await l1(l.confirm)&&await Yu(a,{...l.installPackage,cwd:l.cwd?Fr(l.cwd):void 0,dev:r==="devDependencies"})}},"ensurePackages"),Kn=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"],y1=/\.(?:js|mjs|cjs|ts|cts|mts)$/,FO=async(e,t="")=>{if(t){const r=Tt(t)?t:G(e,t);if(!y1.test(r))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");if(!await Ct(r))throw new Error(`The packem config file "${t}" could not be found at "${r}".`);return r}for(const r of Kn){const n=G(e,r);if(await Ct(n))return n}throw new Error(`No packem config file found in "${e}". Expected one of: ${Kn.join(", ")}.`)},HO=async e=>{for(const t of Kn)if(await Ct(G(e,t)))return!0;return!1},$1={esbuild:"esbuild",oxc:"oxc-transform",sucrase:"sucrase",swc:"@swc/core"},Rl=async(e,t)=>{const r=Array.isArray(e)?e:[e],n=await Mm(t).catch(()=>{});let o;return n==="yarn"||n==="bun"?o=`${n} add -D`:n==="pnpm"?o="pnpm add -D":o="npm install -D",`${o} ${r.join(" ")}`},Yn=e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},ki=(e,t,r,n)=>{if(e==="module-sync")return"esm";if(n){const i=Yn(n);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return r;const[o,...s]=t;return ki(o,s,r,n)},b1=new Set(["browser","bun","default","deno","electron","import","module-sync","node","node-addons","require","types","workerd",...op,...sp]),ya=(e,t,r,n,o)=>{if(!e)return[];if(typeof e=="string"){const s=Yn(e);if(s&&s!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:s??t}]}if(typeof e=="object"){const s=Object.entries(e).filter(([a])=>!a.endsWith(".json"));let i=[];for(const[a,l]of s){const u=a.replace("./",""),c=o.some(p=>u===p||u.startsWith(`${p}/`));if(typeof l=="string"){let p;Number.isInteger(+a)?p={exportKey:"*"}:a.startsWith("./")?p={exportKey:a.replace("./","")}:p={exportKey:a==="."?".":"*",subKey:a},i.push({...p,file:l,key:"exports",type:ki(a,n,t,l),...c&&{ignored:!0}})}else if(typeof l=="object"&&l!==null)for(const[p,f]of Object.entries(l)){if(r===!1&&p==="types")continue;const d=Number.isInteger(+a)?p:a;if(typeof f=="string")i.push({exportKey:d.replace("./",""),file:f,key:"exports",...b1.has(p)?{subKey:p}:{},type:ki(p,n,t,f),...c&&{ignored:!0}});else{const m=d.replace("./",""),h=c||o.some(y=>m===y||m.startsWith(`${y}/`)),$=ya({[d]:f},t,r,[...n,p],o);h&&$.forEach(y=>{y.ignored=!0}),i=[...i,...$]}}}return i}return[]},ji=new Map,nr=/\.[^./]+$/,Ce=/\.d\.[mc]?ts$/,Ai=/\.d\.mts$/,Oi=/\.d\.cts$/,Cl=/\.d\.[mc]ts$/,w1=/^\.\/dist\//,Ri=/^dist\//,v1=/^\//,_r=/^\.\//,x1=/\/$/,Tl=/\.\w+$/,Nl=/\*.*$/,E1=/\.(?:tsx?|cts|mts)$/,S1=/\.[cm]?tsx?$/,k1=/^(.+?)\.[^.]*$/,j1=/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,Re=e=>e===void 0||e==="node16",Rf=(e,t)=>{const r=Ce.exec(e);if(r!==null)return r[0];if(t)for(const n of Object.values(t)){const o=n.startsWith(".")?n:`.${n}`;if(e.endsWith(o))return o}return tr(e)},A1=async e=>{try{return await lp.readdir(e,{withFileTypes:!0})}catch(t){const{code:r}=t;if(r==="ENOENT")return[];throw t}},Cf=async(e,t)=>{const r=await A1(e);return(await Promise.all(r.map(async n=>{const o=ll.join(e,n.name);return n.isDirectory()?Cf(o,t):n.isFile()?ll.relative(t,o):[]}))).flat()},O1=async e=>{let t=ji.get(e);return t||(t=Cf(e,e),ji.set(e,t)),t},Pl=(e,t,r)=>{const n=e.replace(nr,"");if(t==="*"){const i=n.split("/").filter(Boolean);return i.length===0?void 0:r&&r>1?i:[i[0]]}const o=t.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`).replaceAll("*","(.*)"),s=new RegExp(`^${o}$`).exec(n);return s?s.slice(1):void 0},xt=(e,t)=>{let r=e;for(const n of t)r=r.replace("*",n);return r},R1=e=>e.endsWith(".d.mts")?"d.mts":e.endsWith(".d.cts")?"d.cts":"d.ts",C1=(e,t)=>e.key==="exports"&&e.subKey===Wr?Wr:e.key==="exports"&&e.subKey===sl?sl:t,T1=e=>{const t=e.replace(w1,"").replace(Ri,"").replace(nr,"").split("/"),r=t.at(-1)??"",n=[".browser",".server",".development",".production",".node",".workerd"];for(const s of n)if(r.includes(s)){const i=r.replace(s,""),a=t.length>1?t.slice(0,-1).join("/"):"";return{baseName:a?`${a}/${i}`:i,pattern:s}}const o=r.split(".");if(o.length>2){const s=o.slice(0,-2).join("."),i=`.${o[o.length-2]}`,a=t.length>1?t.slice(0,-1).join("/"):"";return{baseName:a?`${a}/${s}`:s,pattern:i}}},N1=(e,t,r,n)=>{const o=`${t.replace(new RegExp(`^${n}/?`),"")}${r}`,s=o.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),i=new RegExp(String.raw`${s}\.([cm]?[tj]sx?|ts|js)$`),a=e.find(u=>{const c=u.replace(n,"").replace(v1,"");return i.test(c)});if(a)return a;const l=`${n}/${o}`;return e.find(u=>{const c=u.replace(nr,"");return c===l||c.endsWith(`/${o}`)})??void 0},at=(e,t,r,n,o,s,i,a)=>{const l=C1(o,s.environment);let{runtime:u}=s.options;const c=o.subKey==="browser"||typeof o.subKey=="string"&&o.subKey.includes("browser"),p=o.file.includes(".browser");if(c||p)u="browser";else{for(const b of op)if(o.file.includes(`.${b}.`)||o.subKey===b){u=b;break}(o.subKey==="node"||o.subKey==="workerd"||o.file.includes(".node")||o.file.includes(".workerd")||o.file.includes(".server"))&&(u="node")}const f=Rf(o.file,s.options.outputExtensionMap),d=o.file.replace(f,""),m=s.options.outDir.replace(_r,""),h=d.replace(new RegExp(`^(./)?${m}/`),""),$=t.replace(nr,"").split("/").pop()??"",y=h.split("/").pop()??"",g=!t.includes(h)&&$!==y;let w=e.find(b=>b.input===t&&b.environment===l&&b.runtime===u&&b.fileAlias===(g?h:void 0));if(w===void 0?w=e[e.push({environment:l,exportKey:new Set([o.exportKey].filter(Boolean)),fileAlias:g?h:void 0,input:t,runtime:u})-1]:w.exportKey&&o.exportKey&&w.exportKey.add(o.exportKey),i&&(w.isGlob=!0),r&&(w.outDir=n),o.isExecutable)w.executable=!0,w.declaration=!1,o.type==="cjs"?w.cjs=!0:o.type==="esm"&&(w.esm=!0);else{const b=Ce.test(o.file),v=a.filter(x=>x.exportKey===o.exportKey),S=v.length>0&&v.every(x=>Ce.test(x.file));if(b&&s.options.declaration!==!1){w.declaration=s.options.declaration;const x=R1(o.file);w.declarationExtensions??=new Set,w.declarationExtensions.add(x)}if(b||S){S&&s.options.declaration!==!1&&(w.declaration=s.options.declaration);const x=v.some(j=>Ai.test(j.file)),E=v.some(j=>Oi.test(j.file));if(x&&E?(Re(s.options.declaration)&&(s.options.declaration="compatible"),s.options.emitCJS=!0,s.options.emitESM=!0):E?(s.options.emitCJS=!0,Re(s.options.declaration)&&(s.options.declaration="compatible")):x&&(s.options.emitESM=!0,Re(s.options.declaration)&&(s.options.declaration="compatible")),S){const j=a.filter(P=>Ce.test(P.file)),k=j.some(P=>Ai.test(P.file)),R=j.some(P=>Oi.test(P.file));v.every(P=>!P.subKey||P.subKey==="types")?(R&&(w.cjs=!0),k&&(w.esm=!0)):(R&&(w.declarationCjs=!0),k&&(w.declarationEsm=!0))}}else o.type==="cjs"?w.cjs=!0:o.type==="esm"&&(w.esm=!0)}g&&!w.fileAlias&&(w.fileAlias=h)};let rs=!1;const _l=e=>{if(e.pkg.dependencies?.typescript===void 0&&e.pkg.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},P1=async(e,t,r)=>{const n=e.types||e.typings;ji.clear(),rs=!1;const o=[];t.sort((d,m)=>d.split("/").length-m.split("/").length);const s=e.type==="module"?"esm":"cjs",i=r.options.declaration??"node16",a=ya(e.exports,s,i,[],r.options.ignoreExportKeys??[]).filter(d=>!d.ignored),l=new Set;for(const d of a){const m=a.filter(h=>h.exportKey===d.exportKey);if(m.length>0&&m.every(h=>Ce.test(h.file))&&!l.has(d.exportKey)){l.add(d.exportKey);const h=m.some(y=>y.file.endsWith(".d.mts")),$=m.some(y=>y.file.endsWith(".d.cts"));h&&$?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0,r.options.emitESM=!0):$?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0):h&&(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitESM=!0)}}r.options.declaration??="node16";const u=a.some(d=>d.type==="esm"&&!Ai.test(d.file)),c=a.some(d=>d.type==="cjs"&&!Oi.test(d.file));u&&c?(r.options.emitESM=!0,r.options.emitCJS=!0):u?r.options.emitESM=!0:c?r.options.emitCJS=!0:s==="esm"?r.options.emitESM=!0:r.options.emitCJS=!0;const p=r.options.emitCJS&&r.options.emitESM;if(r.options.declaration==="node16"&&p&&(r.options.declaration="compatible"),e.bin){const d=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const m of d){const h=Yn(m);if(h&&h!==s)throw new Error(`Exported file "${m}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);a.push({file:m,isExecutable:!0,key:"bin",type:h??s})}}e.main&&a.push({file:e.main,key:"main",type:Yn(e.main)??s}),e.module&&a.push({file:e.module,key:"module",type:"esm"}),n&&(_l(r),Re(r.options.declaration)&&p&&(r.options.declaration="compatible"),a.push({file:n,key:"types"}));const f=[];if(!r.options.outputExtensionMap){const d=a.some($=>!$.isExecutable&&!Ce.test($.file)&&$.file.endsWith(".mjs")),m=a.some($=>!$.isExecutable&&!Ce.test($.file)&&$.file.endsWith(".cjs")),h=a.some($=>!$.isExecutable&&!Ce.test($.file)&&$.file.endsWith(".js"));d&&!m&&!h?r.options.outputExtensionMap={esm:"mjs"}:m&&!d&&!h&&(r.options.outputExtensionMap={cjs:"cjs"})}for(const d of a){const m=Ce.test(d.file),h=Rf(d.file,r.options.outputExtensionMap),$=[...ho];if(r.options.outputExtensionMap)for(const k of Object.values(r.options.outputExtensionMap)){const R=k.startsWith(".")?k:`.${k}`;$.includes(R)||$.push(R)}if(!m&&h!==""&&!$.includes(h)||!m&&E1.test(d.file))continue;let y=d.type;if(!y&&m){if(d.file.endsWith(".d.mts"))y="esm";else if(d.file.endsWith(".d.cts"))y="cjs";else if(d.file.endsWith(".d.ts")){const k=a.some(P=>P.subKey==="import"&&P.file.endsWith(".d.mts")),R=a.some(P=>P.subKey==="require"&&P.file.endsWith(".d.cts"));k&&R?y=void 0:y=r.pkg.type==="module"?"esm":"cjs"}}if(Ce.test(d.file)||(r.options.emitCJS===void 0&&(y==="cjs"||d.type==="cjs")&&(r.options.emitCJS=!0),r.options.emitESM===void 0&&(y==="esm"||d.type==="esm")&&(r.options.emitESM=!0)),Re(r.options.declaration)){const k=r.options.emitCJS&&r.options.emitESM;r.options.declaration=k?"compatible":"node16"}let g=d.file;if(r.options.outputExtensionMap)for(const k of Object.values(r.options.outputExtensionMap)){const R=k.startsWith(".")?k:`.${k}`;if(d.file.endsWith(R)){g=d.file.slice(0,-R.length);break}}g===d.file&&(g=d.file.replace(j1,""));const w=g.endsWith("/");if(w&&["./","/"].includes(g))continue;const b=g.replace(new RegExp(`(./)?${r.options.outDir}`),r.options.sourceDir).replace("./",""),v=w?"":String.raw`(\.d\.[cm]?ts|(\.[cm]?[tj]sx?))$`,S="(?:^|/)";if((d.file.includes("/*")||g.includes("*"))&&d.key==="exports"){rs||(r.logger?.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),rs=!0);let k;d.exportKey?k=d.exportKey.startsWith("./")?d.exportKey.slice(2):d.exportKey:k=(d.file.startsWith("./")?d.file.slice(2):d.file).replace(Ri,"");const R=d.file,P=Tl.exec(R);if(R.includes("*")&&!P&&d.exportKey&&!d.subKey){const _=R.replace(Nl,"").replace(_r,""),M=k.replace(Nl,"").replace(_r,"");if(_!==M){const H=`package.json#exports["${d.exportKey==="."?".":`./${d.exportKey}`}"]`;o.push(`Wildcard pattern must include a file extension: ${R} at ${H}`);continue}}const z=r.options.sourceDir.replace(_r,""),U=X(r.options.rootDir,z),J=[],N=await O1(U),O=R.split("*").length-1,F=k.split("*").length-1;for(const _ of N){const M=Pl(_,k,O);if(M){if(O>F&&O>1){if(M.length>=O){const B=M[0];if(M.every(D=>D===B)){const D=xt(R,M.slice(0,O));D.includes("*")||J.push({input:X(U,_),output:D})}continue}const V=_.replace(nr,"").split("/").filter(Boolean);if(V.length>=O){const B=Math.floor(V.length/O),D=[];for(let q=0;q<O;q+=1){const A=q*B,le=q===O-1?V.length:(q+1)*B;D.push(V.slice(A,le).join("/"))}const K=D[0];if(D.every(q=>q===K)){const q=xt(R,D);q.includes("*")||J.push({input:X(U,_),output:q})}}else if(V.length>0){const B=V[0];if(V.every(D=>D===B)){const D=Array.from({length:O}).fill(B),K=xt(R,D);K.includes("*")||J.push({input:X(U,_),output:K})}}continue}if(M.length<O)continue;if(F>0&&F<O&&O>1&&M.length>1){const V=M[0];if(!M.every(B=>B===V))continue}const H=xt(R,M);if(H.includes("*"))continue;J.push({input:X(U,_),output:H})}}if(J.length===0&&R.includes("*")){let _=(d.file.startsWith("./")?d.file.slice(2):d.file).replace(Ri,"");_=_.replace(Tl,"");for(const M of N){const H=Pl(M,_,O);if(H){if(O>1&&F<O){if(H.length>=O){const D=H[0];if(H.every(K=>K===D)){const K=xt(R,H);K.includes("*")||J.push({input:X(U,M),output:K});continue}}const V=M.replace(nr,""),B=_.split("*");if(B.length>=2){const D=B.map(A=>A.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`));let K=`${D[0]}(.+)`;for(let A=1;A<D.length;A+=1)K+=D[A],A<D.length-1&&(K+=String.raw`\1`);const q=new RegExp(`^${K}$`).exec(V);if(q){const A=q[1],le=xt(R,Array.from({length:O}).fill(A));le.includes("*")||J.push({input:X(U,M),output:le})}}continue}if(H.length>=O){if(F>0&&F<O&&O>1&&H.length>1){const B=H[0];if(!H.every(D=>D===B))continue}const V=xt(R,H);V.includes("*")||J.push({input:X(U,M),output:V})}}}}if(J.length===0){a.length>1||o.push(`Could not find entrypoints matching pattern \`${k}\` for output \`${R}\``);continue}const I=a.filter(_=>_.exportKey===d.exportKey);if(I.length>0&&I.every(_=>Ce.test(_.file))){const _=I.some(D=>D.file.endsWith(".d.ts")),M=I.some(D=>D.file.endsWith(".d.mts")),H=I.some(D=>D.file.endsWith(".d.cts"));M&&H?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0,r.options.emitESM=!0):H?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0):M&&(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitESM=!0);const V=I.find(D=>D.file.endsWith(".d.ts")),B=V??I.find(D=>D.file.endsWith(".d.mts"))??I.find(D=>D.file.endsWith(".d.cts"))??d;if(!(B===d||V!==void 0&&d===V||V===void 0&&B===d))continue;for(const{input:D,output:K}of J){let q=K;if(K.endsWith(".d.mts")||K.endsWith(".d.cts"))q=K.replace(Cl,".d.ts");else if(!K.endsWith(".d.ts")){const le=K.replace(Cl,".d.ts");_&&(q=le)}const A={...B,file:q,subKey:"types",type:void 0};at(f,D,!1,g,A,r,!0,a)}}else for(const{input:_,output:M}of J){const H=Ce.test(M);let V=d.type;H||(M.endsWith(".mjs")?V="esm":M.endsWith(".cjs")?V="cjs":M.endsWith(".js")&&!V&&(V=r.pkg.type==="module"?"esm":"cjs"));const B={...d,file:M,...!H&&V&&{type:V}};at(f,_,!1,g,B,r,!0,a)}continue}const x=new RegExp(S+b.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+v);let E=t.find(k=>x.test(k));if(E===void 0){const k=r.options.sourceDir.replace(_r,""),R=X(r.options.rootDir,k),P=T1(d.file);if(P){const z=N1(t,P.baseName,P.pattern,R);if(z)E=z;else{const U=P.baseName,J=new RegExp(S+U.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+v);E=t.find(N=>J.test(N))}}else{const z=b.replace(k1,"$1").replace(x1,"");if(sp.has(d.subKey)){const U=new RegExp(S+z.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+v);E=t.find(J=>U.test(J))}}}if(E===void 0){rt(X(r.options.rootDir,d.file))||o.push(`Could not find entrypoint for \`${d.file}\``);continue}rt(E)&&S1.test(E)&&_l(r);const j=a.filter(k=>k.exportKey===d.exportKey);if(j.length>0&&j.every(k=>Ce.test(k.file))){const k=j.some(z=>z.file.endsWith(".d.mts")),R=j.some(z=>z.file.endsWith(".d.cts"));k&&R?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0,r.options.emitESM=!0):R?(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitCJS=!0):k&&(Re(r.options.declaration)&&(r.options.declaration="compatible"),r.options.emitESM=!0);const P={...d,subKey:"types",type:void 0};at(f,E,w,g,P,r,!1,a)}else{const k=Pm(E.replace(Ki,"")),R=`${k}.cts`,P=`${k}.mts`,z=rt(R),U=rt(P),J=d.file.endsWith(".d.mts")||d.file.endsWith(".mjs"),N=d.file.endsWith(".d.cts")||d.file.endsWith(".cjs");J&&U?at(f,P,w,g,{...d,type:"esm"},r,!1,a):N&&z?at(f,R,w,g,{...d,type:"cjs"},r,!1,a):z&&U?(at(f,R,w,g,{...d,type:"cjs"},r,!1,a),at(f,P,w,g,{...d,type:"esm"},r,!1,a)):at(f,E,w,g,d,r,!1,a)}}return{entries:f,warnings:o}},$r=e=>typeof e=="string"&&e!=="",_1=(e,t)=>{const{publishConfig:r}=e;return r&&(r.bin&&(typeof r.bin=="object"||typeof r.bin=="string")&&(e.bin=r.bin),$r(r.type)&&(e.type=r.type),$r(r.main)&&(e.main=r.main),$r(r.module)&&(e.module=r.module),t===void 0&&$r(r.types)?e.types=r.types:t===void 0&&$r(r.typings)&&(e.typings=r.typings),r.exports&&typeof r.exports=="object"&&(e.exports=r.exports)),e},Tf=/.*\/dist\/.*/,Ml=/\/$/,M1=/\.mjs$/,I1=/\.cjs$/,W1=/\.d\.[mc]?ts$/,B1=/(?<!\.d)\.js$/,D1=e=>{const t=[],r=new Set,n=o=>{if(typeof o=="string"){t.push(o);return}if(Array.isArray(o)){for(const s of o)n(s);return}if(o&&typeof o=="object")for(const[s,i]of Object.entries(o))s.startsWith(".")||r.add(s),n(i)};e.exports&&n(e.exports);for(const o of[e.main,e.module,e.types])typeof o=="string"&&t.push(o);return{conditions:r,files:t}},L1=(e,t,r)=>{if(e.options.emitESM!==void 0||e.options.emitCJS!==void 0)return;const n=e.pkg.type==="module"?"esm":"cjs",o=r.some(a=>B1.test(a));let s=r.some(a=>M1.test(a))||t.has("import")||t.has("module"),i=r.some(a=>I1.test(a))||t.has("require");(o||!s&&!i)&&n==="esm"?s=!0:(o||!s&&!i)&&(i=!0),e.options.emitESM=s,e.options.emitCJS=i},F1=(e,t,r)=>{if(e.options.declaration!==void 0)return;const n=!!e.pkg.types||t.has("types")||r.some(o=>W1.test(o));e.options.declaration=n?"node16":!1},H1=e=>{e.options.entries.length=0;const t=G(e.options.rootDir,e.options.sourceDir);if(!rt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const r=zu(t,{extensions:[],includeDirs:!1,includeSymlinks:!1,skip:[kt,Tf]}).filter(u=>Et.test(u)&&!u.endsWith(".d.ts")),{conditions:n,files:o}=D1(e.pkg);L1(e,n,o),F1(e,n,o);const s=e.options.emitESM??!1,i=e.options.emitCJS??!1;for(const u of r){const c=u.replace(`${t}/`,"").replace(Et,"").replaceAll("\\","/");e.options.entries.push({cjs:i,declaration:e.options.declaration,esm:s,input:u,name:c})}const a=[];s&&a.push("[esm]"),i&&a.push("[cjs]"),e.options.declaration&&a.push("[dts]");const l=e.options.entries.length;e.logger.info("Unbundle mode: preserving source structure for",ne(`${String(l)} ${l===1?"entry":"entries"}`),De(a.join(" ")))},q1={hooks:{"build:prepare":async function(e){if(e.options.unbundle){H1(e);return}if(e.options.entries.length>0)return;const t=G(e.options.rootDir,e.options.sourceDir);if(!rt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const r=zu(t,{extensions:[],includeDirs:!1,includeSymlinks:!1,skip:[kt,Tf]});if(r.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");const n=e.logger;let o={...e.pkg};o.publishConfig&&(n.info(`Using publishConfig found in package.json, to override the default key-value pairs of "${Object.keys(o.publishConfig).join(", ")}".`),n.debug(o.publishConfig),o=_1(o,e.options.declaration));const s=await P1(o,r,e);for(const i of s.warnings)n.warn(i);if(e.options.entries.push(...s.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");n.info("Automatically detected entries:",ne(e.options.entries.map(i=>i.fileAlias?`${Ae(i.fileAlias)} => ${Ae(i.input.replace(`${e.options.rootDir}/`,"").replace(Ml,"/*"))}`:Ae(i.input.replace(`${e.options.rootDir}/`,"").replace(Ml,"/*"))).join(", ")),De([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))}}},J1=Me(import.meta.url),Ut=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$a=e=>{if(typeof Ut<"u"&&Ut.versions&&Ut.versions.node){const[t,r]=Ut.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Ut.getBuiltinModule(e)}return J1(e)},{existsSync:ns}=$a("node:fs"),{env:os,cwd:z1}=Ut,{createRequire:nn}=$a("node:module"),U1=0,ss=2,G1=Symbol("findUpStop"),Nf=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},Il=e=>{if(e.isFile())return"file";if(e.isDirectory())return"dir";if(e.isSymbolicLink())return"symlink"},V1=nn(import.meta.url),br=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,K1=e=>{if(typeof br<"u"&&br.versions&&br.versions.node){const[t,r]=br.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return br.getBuiltinModule(e)}return V1(e)},{lstatSync:Wl,mkdirSync:Y1}=K1("node:fs"),X1=e=>{Nf(e);try{const t=Wl(e);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(Il(t))}'`);return}catch(t){if(t.code!=="ENOENT")throw t}try{Y1(e,{recursive:!0})}catch(t){if(t.code!=="EEXIST")throw t;const r=Wl(e);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(Il(r))}'`,{cause:t})}},Z1=/^[A-Z]:\//i,on=(e="")=>e&&e.replaceAll("\\","/").replace(Z1,t=>t.toUpperCase()),Q1=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,ew=/^[A-Z]:$/i,tw=/.(\.[^./]+)$/,rw=/^[/\\]|^[a-z]:[/\\]/i,nw=/\/$/,ow=()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/",sw=(e,t)=>{let r="",n=0,o=-1,s=0,i;for(let a=0;a<=e.length;++a){if(a<e.length)i=e[a];else{if(i==="/")break;i="/"}if(i==="/"){if(!(o===a-1||s===1))if(s===2){if(r.length<2||n!==2||!r.endsWith(".")||r.at(-2)!=="."){if(r.length>2){const l=r.lastIndexOf("/");l===-1?(r="",n=0):(r=r.slice(0,l),n=r.length-1-r.lastIndexOf("/")),o=a,s=0;continue}else if(r.length>0){r="",n=0,o=a,s=0;continue}}t&&(r+=r.length>0?"/..":"..",n=2)}else r.length>0?r+=`/${e.slice(o+1,a)}`:r=e.slice(o+1,a),n=a-o-1;o=a,s=0}else i==="."&&s!==-1?++s:s=-1}return r},Xn=e=>Q1.test(e),is=function(...e){e=e.map(n=>on(n));let t="",r=!1;for(let n=e.length-1;n>=-1&&!r;n--){const o=n>=0?e[n]:ow();!o||o.length===0||(t=`${o}/${t}`,r=Xn(o))}return t=sw(t,!r),r&&!Xn(t)?`/${t}`:t.length>0?t:"."},iw=function(e){return tw.exec(on(e))?.[1]??""},Pf=e=>{const t=on(e).replace(nw,"").split("/").slice(0,-1);return t.length===1&&ew.test(t[0])&&(t[0]=`${t[0]}/`),t.join("/")||(Xn(e)?"/":".")},aw=(e,t)=>on(e).split("/").pop(),lw=function(e){const t=rw.exec(e)?.[0]?.replaceAll("\\","/")??"",r=aw(e),n=iw(r);return{base:r,dir:Pf(e),ext:n,name:r.slice(0,r.length-n.length),root:t}},cw=nn(import.meta.url),wr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,uw=e=>{if(typeof wr<"u"&&wr.versions&&wr.versions.node){const[t,r]=wr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return wr.getBuiltinModule(e)}return cw(e)},{fileURLToPath:pw}=uw("node:url");function fw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Bl,Dl;function dw(){return Dl||(Dl=1,Bl=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Bl}var mw=dw();const hw=fw(mw);new Set(hw);const Ci=e=>on(e instanceof URL?pw(e):e),gw=nn(import.meta.url),vr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_f=e=>{if(typeof vr<"u"&&vr.versions&&vr.versions.node){const[t,r]=vr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return vr.getBuiltinModule(e)}return gw(e)};_f("node:fs/promises");_f("node:url");const yw=nn(import.meta.url),xr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Mf=e=>{if(typeof xr<"u"&&xr.versions&&xr.versions.node){const[t,r]=xr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return xr.getBuiltinModule(e)}return yw(e)},{statSync:$w,lstatSync:bw}=Mf("node:fs"),{fileURLToPath:ww}=Mf("node:url"),vw=(e,t={})=>{const r=t.cwd?Ci(t.cwd):process.cwd();let n=is(r);const{root:o}=lw(n),s=Ci(t.stopAt??o),i=is(n,s),a=t.type??"file",l=function(c){return[e]};t.allowSymlinks??=!0;const u=t.allowSymlinks?$w:bw;for(;n&&n!==i&&n!==o;){for(let c of l()){if(c===G1)return;if(c===void 0)continue;Buffer.isBuffer(c)?c=c.toString():c instanceof URL&&(c=ww(c));const p=Xn(c)?c:is(n,c);try{const f=u(p);if(a==="file"&&f.isFile()||a==="directory"&&f.isDirectory())return p}catch{}}n=Pf(n)}},xw=nn(import.meta.url),Er=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ew=e=>{if(typeof Er<"u"&&Er.versions&&Er.versions.node){const[t,r]=Er.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Er.getBuiltinModule(e)}return xw(e)};Ew("node:fs/promises");const{accessSync:Sw}=$a("node:fs");function as(e,t=U1){Nf(e),e=Ci(e);try{return Sw(e,t),!0}catch{return!1}}let kw=class extends Error{constructor(t){super(`ENOENT: ${t}`)}get code(){return"ENOENT"}set code(t){throw new Error("Cannot overwrite code ENOENT")}get name(){return"NotFoundError"}set name(t){throw new Error("Cannot overwrite name of NotFoundError")}};const jw=/^[A-Z]:\//i,If=(e="")=>e&&e.replaceAll("\\","/").replace(jw,t=>t.toUpperCase()),Aw=/^[/\\]{2}/,Ow=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Wf=/^[A-Z]:$/i,Rw=/\/$/,Cw=(e,t)=>{let r="",n=0,o=-1,s=0,i;for(let a=0;a<=e.length;++a){if(a<e.length)i=e[a];else{if(i==="/")break;i="/"}if(i==="/"){if(!(o===a-1||s===1))if(s===2){if(r.length<2||n!==2||!r.endsWith(".")||r.at(-2)!=="."){if(r.length>2){const l=r.lastIndexOf("/");l===-1?(r="",n=0):(r=r.slice(0,l),n=r.length-1-r.lastIndexOf("/")),o=a,s=0;continue}else if(r.length>0){r="",n=0,o=a,s=0;continue}}t&&(r+=r.length>0?"/..":"..",n=2)}else r.length>0?r+=`/${e.slice(o+1,a)}`:r=e.slice(o+1,a),n=a-o-1;o=a,s=0}else i==="."&&s!==-1?++s:s=-1}return r},Ti=e=>Ow.test(e),Tw=function(e){if(e.length===0)return".";e=If(e);const t=Aw.exec(e),r=Ti(e),n=e.at(-1)==="/";return e=Cw(e,!r),e.length===0?r?"/":n?"./":".":(n&&(e+="/"),Wf.test(e)&&(e+="/"),t?r?`//${e}`:`//./${e}`:r&&!Ti(e)?`/${e}`:e)},$n=(...e)=>{let t="";for(const r of e)if(r)if(t.length>0){const n=t.at(-1)==="/",o=r[0]==="/";n&&o?t+=r.slice(1):t+=n||o?r:`/${r}`}else t+=r;return Tw(t)},Nw=e=>{const t=If(e).replace(Rw,"").split("/").slice(0,-1);return t.length===1&&Wf.test(t[0])&&(t[0]=`${t[0]}/`),t.join("/")||(Ti(e)?"/":".")},Ll=(e,t)=>(t?.create&&X1(e),e),Pw=(e,t)=>{if(os.CACHE_DIR&&!["0","1","false","true"].includes(os.CACHE_DIR))return Ll($n(os.CACHE_DIR,e),t);const r=vw("package.json",{cwd:t?.cwd??z1(),type:"file"});if(!r){if(t?.throwError)throw new kw("No such file or directory found.");return}const n=$n(Nw(r),"node_modules"),o=$n(n,".cache"),s=$n(o,e);if(!(ns(s)&&!as(s,ss))&&!(ns(o)&&!as(o,ss))&&!(ns(n)&&!as(n,ss)))return Ll(s,t)},_w=Pw,Mw=/^(?<value>-?\d+(?:[.,]\d+)*) *(?<type>[a-z]+)?$/i,Iw=/^KIBI/,Ww=/^MIBI/,Bw=/^GIBI/,Dw=/^TEBI/,Lw=/^PEBI/,Fw=/^EXBI/,Hw=/^ZEBI/,qw=/^YIBI/,Jw=/^(.)IB$/,Bf={iec:[{long:"Bytes",short:"B"},{long:"Kibibytes",short:"KiB"},{long:"Mebibytes",short:"MiB"},{long:"Gibibytes",short:"GiB"},{long:"Tebibytes",short:"TiB"},{long:"Pebibytes",short:"PiB"},{long:"Exbibytes",short:"EiB"},{long:"Zebibytes",short:"ZiB"},{long:"Yobibytes",short:"YiB"}],iec_octet:[{long:"Octets",short:"o"},{long:"Kibioctets",short:"Kio"},{long:"Mebioctets",short:"Mio"},{long:"Gibioctets",short:"Gio"},{long:"Tebioctets",short:"Tio"},{long:"Pebioctets",short:"Pio"},{long:"Exbioctets",short:"Eio"},{long:"Zebioctets",short:"Zio"},{long:"Yobioctets",short:"Yio"}],metric:[{long:"Bytes",short:"Bytes"},{long:"Kilobytes",short:"KB"},{long:"Megabytes",short:"MB"},{long:"Gigabytes",short:"GB"},{long:"Terabytes",short:"TB"},{long:"Petabytes",short:"PB"},{long:"Exabytes",short:"EB"},{long:"Zettabytes",short:"ZB"},{long:"Yottabytes",short:"YB"}],metric_octet:[{long:"Octets",short:"o"},{long:"Kilo-octets",short:"ko"},{long:"Mega-octets",short:"Mo"},{long:"Giga-octets",short:"Go"},{long:"Tera-octets",short:"To"},{long:"Peta-octets",short:"Po"},{long:"Exa-octets",short:"Eo"},{long:"Zetta-octets",short:"Zo"},{long:"Yotta-octets",short:"Yo"}]},zw=(e,t)=>{const r=new Intl.NumberFormat(t).format(11111).replaceAll(new RegExp("\\p{Number}","gu"),""),n=new Intl.NumberFormat(t).format(1.1).replaceAll(new RegExp("\\p{Number}","gu"),"");return Number.parseFloat(e.replaceAll(new RegExp(`\\${r}`,"g"),"").replace(new RegExp(`\\${n}`),"."))},Df=e=>{switch(e){case 2:return 1024;case 10:return 1e3;default:throw new Error("Unsupported base.")}},Uw=(e,t)=>{const r={base:2,locale:"en-US",units:"metric",...t};if(typeof e!="string"||e.length===0)throw new TypeError("Value is not a string or is empty.");if(e.length>100)throw new TypeError("Value exceeds the maximum length of 100 characters.");const n=Mw.exec(e)?.groups;if(!n)return Number.NaN;const o=zw(n.value,r.locale),s=(n.type??"Bytes").toUpperCase().replace(Iw,"KILO").replace(Ww,"MEGA").replace(Bw,"GIGA").replace(Dw,"TERA").replace(Lw,"PETA").replace(Fw,"EXA").replace(Hw,"ZETTA").replace(qw,"YOTTA").replace(Jw,"$1B"),i=Bf[r.units].findIndex(l=>l.short[0].toUpperCase()===s[0]),a=Df(r.base);return o*a**i},je=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("Bytesize is not a number.");const{base:r,decimals:n,locale:o,long:s,unit:i,units:a,...l}={base:2,decimals:0,locale:"en-US",long:!1,units:"metric",...t},u=Df(r),c=Math.abs(e),p=t?.space??!0?" ":"",f=Bf[a],d=f.findIndex(g=>g.short===i);if(e===0){const g=Math.min(0,Math.max(d,f.length-1));return"0"+p+f[g][s?"long":"short"]}const m=d===-1?Math.min(Math.floor(Math.log(c)/Math.log(u)),f.length-1):d,h=f[m][s?"long":"short"],$=e/u**m,y=n<0?void 0:n;return new Intl.NumberFormat(o,{maximumFractionDigits:y,minimumFractionDigits:y,...l}).format($)+p+h},Gw=(e,t,r,n,o,s,i,a,l,u,c,p,f,d)=>{const m={d:n,h:o,m:s,mo:t,ms:a,s:i,w:r,y:e};return m.future=l,m.past=u,m.decimal=c,p!==void 0&&(m.unitMap=p),m.groupSeparator=f,m.placeholderSeparator=d,m},Vw={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},Kw=Gw(e=>`year${e===1?"":"s"}`,e=>`month${e===1?"":"s"}`,e=>`week${e===1?"":"s"}`,e=>`day${e===1?"":"s"}`,e=>`hour${e===1?"":"s"}`,e=>`minute${e===1?"":"s"}`,e=>`second${e===1?"":"s"}`,e=>`millisecond${e===1?"":"s"}`,"in %s","%s ago",".",Vw,",","_"),Yw=e=>{const t=["y","mo","w","d","h","m","s","ms","future","past"];for(const n of t)if(!Object.hasOwn(e,n))throw new TypeError(`Missing required property: ${n}`);if(typeof e.future!="string"||typeof e.past!="string")throw new TypeError("Properties future and past must be of type string");const r=["y","mo","w","d","h","m","s","ms"];for(const n of r)if(typeof e[n]!="string"&&typeof e[n]!="function")throw new TypeError(`Property ${n} must be of type string or function`);if(e.decimal&&typeof e.decimal!="string")throw new TypeError("Property decimal must be of type string");if(e.delimiter&&typeof e.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(e._digitReplacements&&!Array.isArray(e._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(e._numberFirst&&typeof e._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(e.unitMap&&typeof e.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(e.unitMap&&Object.values(e.unitMap).some(n=>typeof n!="string"))throw new TypeError("All values in unitMap must be of type string")},Lf=(e,t)=>{t=t||-1;const r=new RegExp(String.raw`^-?\d+(?:.\d{0,${String(t)}})?`).exec(e.toString());return r===null?e:Number.parseFloat(r[0])},Fl=({unitCount:e,unitName:t},r,n)=>{let{spacer:o}=n;const{maxDecimalPoints:s}=n;let i=".";n.decimal!==void 0?i=n.decimal:r.decimal!==void 0&&(i=r.decimal);let a;"digitReplacements"in n?a=n.digitReplacements:"_digitReplacements"in r&&(a=r._digitReplacements);let l,u=e;s!==void 0&&(u=Lf(e,s));const c=u.toString();if(!r._hideCountIf2||e!==2)if(a){l="";for(const d of c)l+=d==="."?i:a[d]}else l=c.replace(".",i);else l="";const p=r[t];let f=p;return typeof p=="function"&&(f=p(e)),r._hideCountIf2&&e===2&&(o=""),r._numberFirst?f+o+l:l+o+f},Xw=(e,t)=>{const{units:r}=t;if(r.length===0)return[];const{unitMeasures:n}=t,o=t.largest??Number.POSITIVE_INFINITY,s={};let i,a,l,u=e;for(a=0;a<r.length;a++){i=r[a];const p=n[i];l=a===r.length-1?u/p:Math.floor(u/p),s[i]=l,u-=l*p}if(t.round){let p=o;for(a=0;a<r.length;a++)if(i=r[a],l=s[i],l!==0&&(p--,p===0)){for(let f=a+1;f<r.length;f++){const d=r[f],m=s[d];s[i]=(s[i]??0)+m*n[d]/n[i],s[d]=0}break}for(a=r.length-1;a>=0;a--){if(i=r[a],l=s[i],l===0)continue;const f=Math.round(l);if(s[i]=f,a===0)break;const d=r[a-1],m=n[d],h=Math.floor(f*n[i]/m);if(h)s[d]=(s[d]??0)+h,s[i]=0;else break}}const c=[];for(a=0;a<r.length&&c.length<o;a++){if(i=r[a],l=s[i],l&&!t.round&&c.length===o-1){let p,f=0;for(p=a+1,r.length;p<r.length;p++){const d=r[p];f+=s[d]*(t.unitMeasures[d]/t.unitMeasures[i])}l+=f,t.maxDecimalPoints!==void 0&&(l=Lf(l,t.maxDecimalPoints))}l&&c.push({unitCount:l,unitName:i})}return c},Zw=(e,t,r)=>{const{language:n,units:o}=t;if(e.length===0){const p=o.at(-1);return Fl({unitCount:0,unitName:p},n,t)}const{conjunction:s,serialComma:i}=t;let a=", ";t.delimiter!==void 0?a=t.delimiter:n.delimiter!==void 0&&(a=n.delimiter);let l="";t.timeAdverb&&r!==0&&(l=n.future??"",r<0&&(l=n.past??""));const u=e.map(p=>Fl(p,n,t));let c;return!s||e.length===1?c=u.join(a):e.length===2?c=u.join(s):c=u.slice(0,-1).join(a)+(i?",":"")+s+(u.at(-1)??""),l&&(c=l.replace("%s",c)),c},Hl=(e,t)=>{if(Number.isNaN(e))throw new TypeError("Expected a valid number");if(typeof e!="number")throw new TypeError("Expected a number for milliseconds input");const r={conjunction:"",language:Kw,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...t};Yw(r.language);const n=Math.abs(e),o=Xw(n,r);return Zw(o,r,e)};var Qw=Object.defineProperty,Ff=(e,t)=>Qw(e,"name",{value:t,configurable:!0});const ev=Me(import.meta.url),Sr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Hf=Ff(e=>{if(typeof Sr<"u"&&Sr.versions&&Sr.versions.node){const[t,r]=Sr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Sr.getBuiltinModule(e)}return ev(e)},"__cjs_getBuiltinModule"),{execSync:tv}=Hf("node:child_process"),{existsSync:ql,readFileSync:rv}=Hf("node:fs");var nv=Object.defineProperty,Xe=Ff((e,t)=>nv(e,"name",{value:t,configurable:!0}),"r");const ba=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],qf=Xe(e=>{let t;if(ba.forEach(n=>{!t&&ql(G(e,n))&&(t=G(e,n))}),t)return t;const r=G(e,"package.json");if(ql(r)&&ga(rv(r,"utf8")).packageManager!==void 0)return r},"packageMangerFindUpMatcher"),Jf=Xe(e=>{if(!e)throw new Mt("Could not find a package manager");if(e.endsWith("package.json")){const t=ga(e);if(t.packageManager){const r=["npm","yarn","pnpm","bun"].find(n=>t.packageManager.startsWith(n));if(r)return{packageManager:r,path:Z(e)}}}if(e.endsWith("yarn.lock"))return{packageManager:"yarn",path:Z(e)};if(e.endsWith("package-lock.json")||e.endsWith("npm-shrinkwrap.json"))return{packageManager:"npm",path:Z(e)};if(e.endsWith("pnpm-lock.yaml"))return{packageManager:"pnpm",path:Z(e)};if(e.endsWith("bun.lockb"))return{packageManager:"bun",path:Z(e)};throw new Mt("Could not find a package manager")},"resolvePackageManagerFromFile"),ov=Xe(async e=>{const t=await ft(ba,{type:"file",...e&&{cwd:e}});if(!t)throw new Error("Could not find lock file");return t},"findLockFile"),sv=Xe(e=>{const t=dt(ba,{type:"file",...e&&{cwd:e}});if(!t)throw new Error("Could not find lock file");return t},"findLockFileSync"),iv=Xe(async e=>{const t=await ft(qf,{...e&&{cwd:e}});return Jf(t)},"findPackageManager"),zf=Xe(e=>{const t=dt(qf,{...e&&{cwd:e}});return Jf(t)},"findPackageManagerSync");Xe(e=>tv(`${e} --version`).toString("utf8").trim(),"getPackageManagerVersion");Xe(()=>{if(!process.env.npm_config_user_agent)return;const e=process.env.npm_config_user_agent.split(" ")[0],t=e.lastIndexOf("/"),r=e.slice(0,Math.max(0,t));return{name:r==="npminstall"?"cnpm":r,version:e.slice(Math.max(0,t+1))}},"identifyInitiatingPackageManager");Xe((e,t,r)=>{const n=t.length===1?"":"s";if(r.packageManagers??=["npm","pnpm","yarn"],r.packageManagers.length===0)throw new Error("No package managers provided, please provide at least one package manager");if(t.length===0)throw new Error("No missing packages provided, please provide at least one missing package");let o=`
|
|
51
|
+
${r.preMessage??""}
|
|
52
|
+
${e} could not find the following package${n}
|
|
53
|
+
|
|
54
|
+
${t.join(`
|
|
55
|
+
`)}
|
|
56
|
+
|
|
57
|
+
To install the missing package${n}, please run the following command:
|
|
58
|
+
`;const s=Xe(a=>a.split("@").includes("@")?a:`${a}@latest`,"atLatest"),i=r.packageManagers.map(a=>{const l=t.map(u=>s(u)).join(" ");switch(a){case"bun":return` bun add ${l} -D`;case"npm":return` npm install ${l} --save-dev`;case"pnpm":return` pnpm add ${l} -D`;case"yarn":return` yarn add ${l} --dev`;default:throw new Error("Unknown package manager")}});return o+=i.join(`
|
|
59
|
+
|
|
60
|
+
or
|
|
61
|
+
|
|
62
|
+
`),r.postMessage&&(o+=r.postMessage),o},"generateMissingPackagesInstallMessage");var av=Object.defineProperty,Uf=(e,t)=>av(e,"name",{value:t,configurable:!0}),lv=Object.defineProperty,cv=Uf((e,t)=>lv(e,"name",{value:t,configurable:!0}),"t");let JO=class extends Error{static{Uf(this,"s")}static{cv(this,"PackageNotFoundError")}constructor(t,r){if(typeof t=="string"&&(t=[t]),t.length===0){super("Package was not found.");return}if(r===void 0)try{r=zf().packageManager}catch{}r??="npm",super(`Package '${t.join(" ")}' was not found. Please install it using '${r} install ${t.join(" ")}'`)}get code(){return"PACKAGE_NOT_FOUND"}set code(t){throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND")}get name(){return"PackageNotFoundError"}set name(t){throw new Error("Cannot overwrite name of PackageNotFoundError")}};var uv=Object.defineProperty,Gf=(e,t)=>uv(e,"name",{value:t,configurable:!0});const pv=Me(import.meta.url),kr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Vf=Gf(e=>{if(typeof kr<"u"&&kr.versions&&kr.versions.node){const[t,r]=kr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return kr.getBuiltinModule(e)}return pv(e)},"__cjs_getBuiltinModule"),{readFileSync:fv}=Vf("node:fs"),{readFile:dv}=Vf("node:fs/promises");var mv=Object.defineProperty,ve=Gf((e,t)=>mv(e,"name",{value:t,configurable:!0}),"g");const hv={sha256:"sha256",sha384:"sha384",sha512:"sha512"},gv=1024,yv=/^[A-Z0-9+/]+={0,2}$/i,$v=/.*node_modules\/((?:@[^/]+\/)?[^/]+)$/,Jr=/^['"]/,zr=/['"]$/,bv=/^[a-z][a-zA-Z0-9]*:\s*$/m,wv=/resolution:\s*\{[^}]*integrity:\s*([^,}\s]+)/,vv=/^["']?((?:@[^/@"']+\/)?[^@"'\n]+)@[^"'\n]+["']?:?[\t\v\f\r \u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\n((?:[\t ][^\n]*\n?)+)/gm,xv=/^\s+version:?\s+"?([^"\n]+)"?/m,Ev=/^\s+integrity[\s:]+"?([^"\s]+)"?/m,_o=ve(e=>{if(e.length>gv)return;const t=e.indexOf("-");if(t<=0)return;const r=hv[e.slice(0,t).toLowerCase()];if(!r)return;const n=e.slice(t+1);if(yv.test(n))try{const o=Buffer.from(n,"base64");return o.length===0?void 0:{algorithm:r,hex:o.toString("hex")}}catch{return}},"decodeSriIntegrity"),Mo=ve((e,t,r)=>{const n=`${r.name}@${r.version}`;t.has(n)||(t.add(n),e.push(r))},"pushUniqueEntry"),_e=ve((e,t,r)=>{r&&Object.keys(r).length>0&&(e[t]={...r})},"copyDepMap"),Zt=ve(e=>{if(!e)return;const t={};for(const[r,n]of Object.entries(e))t[r]=[n];return Object.keys(t).length>0?t:void 0},"liftDepMap"),Sv=ve(e=>{const t=[],r=new Set;let n;try{n=JSON.parse(e)}catch{return t}if(!n.packages)return t;for(const[o,s]of Object.entries(n.packages)){if(!o||!s.version)continue;const i=$v.exec(o);if(!i?.[1])continue;const a=s.name??i[1];if(a.startsWith("."))continue;const l={name:a,version:s.version};if(s.integrity){const u=_o(s.integrity);u&&(l.integrity=u)}_e(l,"dependencies",Zt(s.dependencies)),_e(l,"peerDependencies",Zt(s.peerDependencies)),_e(l,"optionalDependencies",Zt(s.optionalDependencies)),Mo(t,r,l)}return t},"parseNpmLockFile"),Kf=ve(e=>{let t=e.trim();t.startsWith("/")&&(t=t.slice(1)),t=t.replace(Jr,"").replace(zr,"");const r=t.indexOf("(");r>0&&(t=t.slice(0,r));const n=t.lastIndexOf("@");if(n<=0)return;const o=t.slice(0,n),s=t.slice(n+1);if(!(!o||!s||s.startsWith("link:")||s.startsWith("workspace:")||s.startsWith("file:")))return{name:o,version:s}},"splitPnpmPackageKey"),Yf=ve((e,t)=>{const r=new RegExp(String.raw`^${t}:\s*$`,"m").exec(e);if(!r)return;const n=r.index+r[0].length,o=bv.exec(e.slice(n));return e.slice(n,o?n+o.index:e.length)},"sliceTopLevelSection"),kv=ve(e=>{const t=new Map,r=Yf(e,"snapshots");if(!r)return t;const n=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let o;for(;(o=n.exec(r)??void 0)!==void 0;){const s=Kf(o[1]);if(!s)continue;const i=`${s.name}@${s.version}`,a=o[2],l=t.get(i)??{};for(const u of["dependencies","peerDependencies","optionalDependencies"]){const c=Wn(a,u);if(!c)continue;const p=l[u]??{};for(const[f,d]of Object.entries(c)){const m=p[f]??[];for(const h of d)m.includes(h)||m.push(h);p[f]=m}l[u]=p}t.set(i,l)}return t},"parsePnpmSnapshotEdges"),jv=ve(e=>{const t=[],r=new Set,n=Yf(e,"packages");if(!n)return t;const o=kv(e),s=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let i;for(;(i=s.exec(n)??void 0)!==void 0;){const a=Kf(i[1]);if(!a)continue;const l=i[2],u=wv.exec(l),c={name:a.name,version:a.version};if(u?.[1]){const f=_o(u[1]);f&&(c.integrity=f)}const p=o.get(`${a.name}@${a.version}`);_e(c,"dependencies",p?.dependencies??Wn(l,"dependencies")),_e(c,"peerDependencies",p?.peerDependencies??Wn(l,"peerDependencies")),_e(c,"optionalDependencies",p?.optionalDependencies??Wn(l,"optionalDependencies")),Mo(t,r,c)}return t},"parsePnpmLockFile"),Wn=ve((e,t)=>{const r=new RegExp(String.raw`^ {4}${t}:\s*\n((?: {6,}[^\n]*\n?)+)`,"m").exec(e);if(!r?.[1])return;const n={},o=/^ {6}([^\s:]+):\s*([^\n]+)/gm;let s;for(;(s=o.exec(r[1])??void 0)!==void 0;){const i=s[1].replace(Jr,"").replace(zr,"");let a=s[2].trim();a=a.replace(Jr,"").replace(zr,"");const l=a.indexOf("(");if(l>0&&(a=a.slice(0,l).trim()),!i||!a)continue;const u=n[i]??[];u.includes(a)||u.push(a),n[i]=u}return Object.keys(n).length>0?n:void 0},"extractPnpmDependencyMap"),Av=ve(e=>{const t=[],r=new Set,n=vv;n.lastIndex=0;let o;for(;(o=n.exec(e)??void 0)!==void 0;){const s=o[1].replace(Jr,"").replace(zr,"");if(!s)continue;const i=o[2],a=xv.exec(i);if(!a?.[1])continue;const l={name:s,version:a[1].trim()},u=Ev.exec(i);if(u?.[1]){const c=_o(u[1]);c&&(l.integrity=c)}_e(l,"dependencies",ls(i,"dependencies")),_e(l,"peerDependencies",ls(i,"peerDependencies")),_e(l,"optionalDependencies",ls(i,"optionalDependencies")),Mo(t,r,l)}return t},"parseYarnLockFile"),ls=ve((e,t)=>{const r=new RegExp(String.raw`^ {2}${t}:\s*\n((?: {4,}[^\n]*\n?)+)`,"m").exec(e);if(!r?.[1])return;const n={},o=/^ {4}(['"]?[^\s:'"]+['"]?)\s*(?::\s*)?['"]([^'"\n]+)['"]/gm;let s;for(;(s=o.exec(r[1])??void 0)!==void 0;){const i=s[1].replace(Jr,"").replace(zr,""),a=s[2];if(i&&a){const l=n[i]??[];l.includes(a)||l.push(a),n[i]=l}}return Object.keys(n).length>0?n:void 0},"extractYarnDependencyMap"),Ov=/,(?=\s*[}\]])/g,Rv=ve(e=>{const t=[],r=new Set;let n;try{n=JSON.parse(e.replaceAll(Ov,""))}catch{return t}if(!n.packages)return t;for(const o of Object.values(n.packages)){const s=o[0];if(typeof s!="string")continue;const i=s.indexOf("@",1);if(i<=0)continue;const a=s.slice(0,i),l=s.slice(i+1);if(!a||!l||l.startsWith("workspace:")||l.startsWith("link:")||l.startsWith("file:"))continue;const u={name:a,version:l},c=o[3];if(typeof c=="string"&&c.length>0){const f=_o(c);f&&(u.integrity=f)}const p=o[2];if(p&&typeof p=="object"&&!Array.isArray(p)){const f=p;_e(u,"dependencies",Zt(f.dependencies)),_e(u,"peerDependencies",Zt(f.peerDependencies)),_e(u,"optionalDependencies",Zt(f.optionalDependencies))}Mo(t,r,u)}return t},"parseBunLockFile"),Xf=ve(e=>{if(e.endsWith("pnpm-lock.yaml"))return"pnpm";if(e.endsWith("package-lock.json"))return"npm";if(e.endsWith("yarn.lock"))return"yarn";if(e.endsWith("bun.lock"))return"bun"},"inferLockFileType"),Zf=ve((e,t)=>{switch(t){case"bun":return Rv(e);case"npm":return Sv(e);case"pnpm":return jv(e);case"yarn":return Av(e);default:return[]}},"parseLockFileContent"),Qf=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock"];ve(async e=>{const t=await ft(Qf,{type:"file",...e&&{cwd:e}});if(!t)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lock)");const r=Xf(t);if(!r)throw new Error(`Unsupported lock file: ${t}`);const n=await dv(t,"utf8");return{entries:Zf(n,r),path:t,type:r}},"parseLockFile");ve(e=>{const t=dt(Qf,{type:"file",...e&&{cwd:e}});if(!t)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lock)");const r=Xf(t);if(!r)throw new Error(`Unsupported lock file: ${t}`);return{entries:Zf(fv(t,"utf8"),r),path:t,type:r}},"parseLockFileSync");var Cv=Object.defineProperty,ed=(e,t)=>Cv(e,"name",{value:t,configurable:!0});const Tv=Me(import.meta.url),jr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Nv=ed(e=>{if(typeof jr<"u"&&jr.versions&&jr.versions.node){const[t,r]=jr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return jr.getBuiltinModule(e)}return Tv(e)},"__cjs_getBuiltinModule"),{existsSync:Zn,readFileSync:td}=Nv("node:fs");var Pv=Object.defineProperty,rd=ed((e,t)=>Pv(e,"name",{value:t,configurable:!0}),"i");rd(async e=>{const t=await ft(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(t?.endsWith("lerna.json")){const n=await fo(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const o=n;if(o.useWorkspaces||o.packages)return{path:Z(t),strategy:"lerna"}}}const r=t?.endsWith("turbo.json");try{const{packageManager:n,path:o}=await iv(e);if(["npm","yarn"].includes(n)){const s=G(o,"package.json");if(Zn(s)&&td(G(o,"package.json"),"utf8").includes("workspaces"))return{path:o,strategy:r?"turbo":n}}else if(n==="pnpm"){const s=G(o,"pnpm-workspace.yaml");if(Zn(s))return{path:o,strategy:r?"turbo":"pnpm"}}}catch(n){if(!(n instanceof Mt))throw n}throw new Error(`No monorepo root could be found upwards from the directory ${e} using lerna, yarn, pnpm, or npm as indicators.`)},"findMonorepoRoot");rd(e=>{const t=dt(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(t?.endsWith("lerna.json")){const n=Hi(t);if(n.useWorkspaces||n.packages)return{path:Z(t),strategy:"lerna"}}const r=t?.endsWith("turbo.json");try{const{packageManager:n,path:o}=zf(e);if(["npm","yarn"].includes(n)){const s=G(o,"package.json");if(Zn(s)&&td(G(o,"package.json"),"utf8").includes("workspaces"))return{path:o,strategy:r?"turbo":n}}else if(n==="pnpm"){const s=G(o,"pnpm-workspace.yaml");if(Zn(s))return{path:o,strategy:r?"turbo":"pnpm"}}}catch(n){if(!(n instanceof Mt))throw n}throw new Error(`No monorepo root could be found upwards from the directory ${e} using lerna, yarn, pnpm, or npm as indicators.`)},"findMonorepoRootSync");var _v=Object.defineProperty,nd=(e,t)=>_v(e,"name",{value:t,configurable:!0});const Mv=Me(import.meta.url),Ar=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Iv=nd(e=>{if(typeof Ar<"u"&&Ar.versions&&Ar.versions.node){const[t,r]=Ar.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Ar.getBuiltinModule(e)}return Mv(e)},"__cjs_getBuiltinModule"),{existsSync:Wv}=Iv("node:fs");var Bv=Object.defineProperty,wa=nd((e,t)=>Bv(e,"name",{value:t,configurable:!0}),"r");const od=wa(e=>{if(Wv(G(e,"package.json"))){const t=Hi(G(e,"package.json"));if(t.name&&t.private!==!0)return"package.json"}},"packageJsonMatcher");wa(async e=>{try{const n=await ov(e);return Z(n)}catch{}const t=await ft(".git/config",{...e&&{cwd:e},type:"file"});if(t)return Z(Z(t));const r=await ft(od,{...e&&{cwd:e},type:"file"});if(r)return Z(r);throw new Error("Could not find root directory")},"findPackageRoot");wa(e=>{try{const n=sv(e);return Z(n)}catch{}const t=dt(".git/config",{...e&&{cwd:e},type:"file"});if(t)return Z(Z(t));const r=dt(od,{...e&&{cwd:e},type:"file"});if(r)return Z(r);throw new Error("Could not find root directory")},"findPackageRootSync");const Qn=async(e,t)=>{try{return t(await e())}catch{return}},eo=e=>{if(typeof e=="function")return e},sd="Rolldown is not installed. Please install '@rolldown/node' or 'rolldown' to use bundler: 'rolldown'.",va=async()=>{const e=await Qn(()=>import("@rolldown/node"),r=>eo(r.rolldown));if(e)return e;const t=await Qn(()=>import("rolldown"),r=>eo(r.rolldown));if(t)return t;throw new Error(sd)},Jl=async()=>{const e=await Qn(()=>import("@rolldown/node"),r=>eo(r.watch));if(e)return e;const t=await Qn(()=>import("rolldown"),r=>eo(r.watch));if(t)return t;throw new Error(sd)};var Dv=Object.defineProperty,Lv=(e,t)=>Dv(e,"name",{value:t,configurable:!0}),Fv=Object.defineProperty,Bt=Lv((e,t)=>Fv(e,"name",{value:t,configurable:!0}),"u");const id="__packem_cache_wrapped",Ni="__packem_watch_files",lt=Bt(e=>typeof e=="function"?e:e.handler,"getHandler"),cs=Bt(e=>{if(e&&typeof e=="object"&&"filter"in e)return e.filter},"getHookFilter"),zl=new Map,Hv=Bt(e=>{const t=JSON.stringify(e);let r=zl.get(t);return r===void 0&&(r=Ve(t),zl.set(t,r)),r},"hashResolveOptions"),qv=Bt(e=>e!==null&&typeof e=="object"&&e[id]===!0,"isWrappedCacheValue"),Jv=Bt(e=>e!==null&&typeof e=="object"&&Array.isArray(e[Ni]),"isWatchFilesCacheValue"),bn=Bt(e=>qv(e)?e.data:e,"unwrapCachedValue"),de=Bt((e,t,r="")=>{if(!t.isEnabled)return e;const n=G(r,e.name),o={...e,async buildEnd(l){e.buildEnd&&await lt(e.buildEnd).call(this,l)},async buildStart(l){e.buildStart&&await lt(e.buildStart).call(this,l)},async load(l){if(!e.load)return;const u=l.includes("?")?l.split("?")[0]:l;let c="";try{if(u&&Wm(u)){const h=Qu(u);c=Ve(h)}}catch{}const p=G("load",Ve(l),c),f=await t.get(p,n);if(f!==void 0)return bn(f);const d=await lt(e.load).call(this,l);if(d==null)return d;const m=typeof d=="object"&&"code"in d?d:{data:d,[id]:!0};return t.set(p,m,n),d},name:`cached(${e.name})`,async resolveId(l,u,c){if(!e.resolveId)return;const p=G("resolveId",Ve(l),u?Ve(u):"",Hv(c)),f=await t.get(p,n);if(f!==void 0)return bn(f);const d=await lt(e.resolveId).call(this,l,u,c);return d==null||t.set(p,d,n),d},async transform(l,u){if(!e.transform)return;const c=G("transform",Ve(u),Ve(l)),p=await t.get(c,n);if(p!==void 0){const h=bn(p);if(Jv(h)){for(const $ of h[Ni])this.addWatchFile($);return bn(h.result)}return h}const f=[],d=Object.create(this);d.addWatchFile=h=>{f.push(h),this.addWatchFile(h)};const m=await lt(e.transform).call(d,l,u);return f.length>0?t.set(c,{[Ni]:f,result:m},n):m!=null&&t.set(c,m,n),m}},s=cs(e.load),i=cs(e.resolveId),a=cs(e.transform);return s&&o.load&&(o.load={filter:s,handler:lt(o.load)}),i&&o.resolveId&&(o.resolveId={filter:i,handler:lt(o.resolveId)}),a&&o.transform&&(o.transform={filter:a,handler:lt(o.transform)}),o},"cachePlugin");var zv=Object.defineProperty,Uv=(e,t)=>zv(e,"name",{value:t,configurable:!0}),Gv=Object.defineProperty,Vv=Uv((e,t)=>Gv(e,"name",{value:t,configurable:!0}),"c");const Kv=Vv(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,r){if(r.format==="es"||r.format==="cjs"){const n=new Se(e),o=r.format==="es"?"mjs":"cjs",s=/(import\(.*?)(?<!\.d)(\.ts)(?=['"`]\))/g;let i=!1,a;for(;(a=s.exec(e))!==null;){const[,l,u]=a;if(l&&u){const c=a.index+l.length,p=c+u.length;n.overwrite(c,p,`.${o}`),i=!0}}if(i)return{code:n.toString(),map:r.sourcemap?n.generateMap({hires:!0}):void 0}}}}),"fixDynamicImportExtension");var Yv=Object.defineProperty,Xv=(e,t)=>Yv(e,"name",{value:t,configurable:!0}),Zv=Object.defineProperty,Qv=Xv((e,t)=>Zv(e,"name",{value:t,configurable:!0}),"i");const ex=Qv(()=>({generateBundle(e,t){const r=[];for(const o of this.getModuleIds()){const s=this.getModuleInfo(o);if(s!==null&&!s.isExternal)for(const i of s.importedIds)r.push({source:o,target:i})}if(r.length===0)return;const n=Object.keys(t);this.emitFile({fileName:`metafile-${n[0].replace(nh,"")}-${e.format??"unknown"}.json`,source:JSON.stringify(r,void 0,2),type:"asset"})},name:"packem:metafile"}),"metafilePlugin");var tx=Object.defineProperty,rx=(e,t)=>tx(e,"name",{value:t,configurable:!0}),nx=Object.defineProperty,ox=rx((e,t)=>nx(e,"name",{value:t,configurable:!0}),"r");const sx=/^file:\/\//,xa=ox(()=>({name:"packem:resolve-file-url",resolveId:{filter:{id:sx},handler(e){if(e.startsWith("file://"))return ip(e)}}}),"resolveFileUrl");var ix=Object.defineProperty,ax=(e,t)=>ix(e,"name",{value:t,configurable:!0}),lx=Object.defineProperty,cx=ax((e,t)=>lx(e,"name",{value:t,configurable:!0}),"s");const ux=/^(\w+)-runtime$/,px=cx(e=>{const t=Fe(e).split(".");if(t.length>=2){const[r,n]=t.slice(-2),o=t[0]??"",s=ux.exec(r)?.[1];if(ho.includes(n)&&s&&s.length>0)return`${o}-${s}`}},"getCustomModuleLayer");var fx=Object.defineProperty,dx=(e,t)=>fx(e,"name",{value:t,configurable:!0}),mx=Object.defineProperty,hx=dx((e,t)=>mx(e,"name",{value:t,configurable:!0}),"t");const gx=/^use /,Lr=hx(e=>(e.preserveDirectives??{directives:[]}).directives.map(t=>t.replace(gx,"")).find(t=>t!=="strict"),"getModuleLayer");var yx=Object.defineProperty,$x=(e,t)=>yx(e,"name",{value:t,configurable:!0}),bx=Object.defineProperty,to=$x((e,t)=>bx(e,"name",{value:t,configurable:!0}),"p");const wx=/[\\/]node_modules[\\/]@swc[\\/]helper/,us=ch(e=>{let t=0;for(let r=0;r<e.length;r+=1)t=(t<<5)-t+e.codePointAt(r);return(t>>>0).toString(36).slice(0,3)}),ad=to((e,t,r,n=new Set)=>{if(r.has(e))return r.get(e);if(n.has(e))return;n.add(e);const o=t(e);if(!o){r.set(e,void 0);return}const s=Lr(o.meta);if(s)return r.set(e,s),s;let i;for(const a of o.importers){const l=ad(a,t,r,n);if(l){i=l;break}}return r.set(e,i),i},"getEffectiveModuleLayer"),vx=to((e,t,r)=>{const n=t(e);if(!n)return new Set;const o=new Set;for(const s of n.importers){const i=t(s);if(!i)continue;const a=Lr(i.meta);if(a)o.add(a);else{const l=ad(s,t,r,new Set([e]));l&&o.add(l)}}return o},"getImporterLayers"),xx=to((e,t,r=!0)=>{const n=new Map,o=new Map;return to(function(s,i){if(wx.test(s))return"cc";const a=i.getModuleInfo(s);if(!a)return;const{isEntry:l}=a,u=a.meta;let c=Lr(u);if(c&&(c=us(c)),!l){const p=n.get(s);if(p)return p;const f=px(s);if(f)return n.set(s,f),f}if(l&&c){const p=typeof i.getModuleIds=="function"?i.getModuleIds():(()=>{const f=new Set,d=[s];for(;d.length>0;){const m=d.pop();if(f.has(m))continue;f.add(m);const h=i.getModuleInfo(m);if(h)for(const $ of h.importedIds)f.has($)||d.push($)}return f})();for(const f of p){const d=i.getModuleInfo(f);d&&Lr(d.meta)===c&&(e.has(f)||e.set(f,new Set),e.get(f).add([s,c]))}}if(r&&!c&&!l){const p=vx(s,i.getModuleInfo,o);if(p.size>1){if(n.has(s))return n.get(s);const f=Fe(s,tr(s)),d=[...p].toSorted((h,$)=>h.localeCompare($)).join("-"),m=`${f}-${us(d)}`;return n.set(s,m),m}}if(c&&!l&&e.has(s)){const p=[...e.get(s)];if(p.some(([h])=>{if(t.some($=>$.path===h)){const $=i.getModuleInfo(h);return Lr($?$.meta:{})===c}return!1}))return;if(p.every(([,h])=>h===c))return n.has(s)?n.get(s):void 0;const f=Fe(s,tr(s)),d=us(c),m=`${f}-${d}`;return n.set(s,m),m}},"splitChunks")},"createSplitChunks");var Ex=Object.defineProperty,Sx=(e,t)=>Ex(e,"name",{value:t,configurable:!0}),kx=Object.defineProperty,jx=Sx((e,t)=>kx(e,"name",{value:t,configurable:!0}),"i");const sn=jx((e,t)=>{let r={};return e.name&&(r[e.name]=t.rootDir),r={...r,...t.alias},t.rollup.alias&&t.rollup.alias.entries&&(Array.isArray(t.rollup.alias.entries)?Object.assign(r,Object.fromEntries(t.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(r,t.rollup.alias.entries)),r},"resolveAliases");var Ax=Object.defineProperty,Ox=(e,t)=>Ax(e,"name",{value:t,configurable:!0}),Rx=Object.defineProperty,Be=Ox((e,t)=>Rx(e,"name",{value:t,configurable:!0}),"c");const Mr=/[.*+?^${}()|[\]\\]/g,Cx=/.*/,Tx=/^(?:\0|\.{1,2}\/)/,Nx=/^node:/,Px=/^@visulima\/css-style-inject(?:\/.+)?$/,Ul=Be((e,t,r)=>e.reduce((n,o,s)=>(o instanceof RegExp?n.push(o):typeof o=="string"&&o.length>0?n.push(new RegExp(`^${o.replaceAll(Mr,String.raw`\$&`)}$`)):r.warn(`Ignoring wrong entry type #${String(s)} in '${t}' option: ${JSON.stringify(o)}`),n),[]),"getRegExps"),Pi=new Map,_x=Be((e,t)=>{Pi.has(e)||t.info({message:`Inlined implicit external "${ne(e)}". If this is incorrect, add it to the "externals" option.`,prefix:"plugin:packem:externals"}),Pi.set(e,!0)},"logExternalMessage"),Gl=new Set(["node:sqlite","node:test"]),Mx=/[\\:]/,Ix=Be(e=>e.length>0&&!Mx.test(e),"isValidPackageName"),Ea="@types/",Vl=Be(e=>{if(e.startsWith("@")){const[t,r]=e.split("/");return`${t??""}/types/${r??""}`}return`${Ea}${e}`},"getAtTypesPackageName"),Wx=Be(e=>{if(e.startsWith("@")){const t=e.split("/");if(t[1]==="types")return`${t[0]??""}/${t.slice(2).join("/")}`}return e.replace(Ea,"")},"getOriginalPackageName"),Bx=["peerDependencies","dependencies","optionalDependencies"],Sa=Be((e,t)=>{const r=bh.realpathSync.native(process.cwd()),{pkg:n}=e,o=new Set;for(const x of Bx){const E=n[x];if(E)for(const j of Object.keys(E))j.startsWith(Ea)?o.add(Wx(j)):o.add(j)}const s=new Set(Object.keys(n.devDependencies??{})),i=new Set([...Object.keys(n.dependencies??{}),...Object.keys(n.devDependencies??{}),...Object.keys(n.peerDependencies??{}),...Object.keys(n.optionalDependencies??{})]),a=e.options.rollup.resolveExternals??{},l=new Set(Ul([...e.options.externals??[]],"include",e.logger)),u=new Set(Ul([...a.exclude??[]],"exclude",e.logger));if(t?.dtsResolve)if(t.dtsResolve===!0)u.add(Cx);else for(const x of t.dtsResolve)typeof x=="string"?u.add(new RegExp(`^${x.replaceAll(Mr,String.raw`\$&`)}(?:/.+)?$`)):u.add(x);const c=Be(x=>{const{dtsResolve:E}=t??{};return E?typeof E=="boolean"?E:E.some(j=>typeof j=="string"?x===j:j.test(x)):!1},"shouldResolveForDts"),p={...a.deps?n.dependencies??{}:void 0,...a.devDeps?n.devDependencies??{}:void 0,...a.peerDeps?n.peerDependencies??{}:void 0,...a.optDeps?n.optionalDependencies??{}:void 0},f=Object.keys(p);if(f.length>0){const x=f.map(E=>E.replaceAll(Mr,String.raw`\$&`));l.add(new RegExp(`^(?:${x.join("|")})(?:/.+)?$`))}if(l.add(Px),n.peerDependenciesMeta)for(const[x,E]of Object.entries(n.peerDependenciesMeta))E&&typeof E=="object"&&"optional"in E&&l.add(new RegExp(`^${x.replaceAll(Mr,String.raw`\$&`)}(?:/.+)?$`));const d=[...l],m=[...u],h=Be(x=>d.some(E=>E.test(x)),"isIncluded"),$=Be(x=>m.some(E=>E.test(x)),"isExcluded");let y=[];e.tsconfig&&(y=Object.entries(e.tsconfig.config.compilerOptions?.paths??{}).map(([x])=>x.endsWith("*")?new RegExp(`^${x.replace("*","(.*)")}$`):new RegExp(`^${x}$`)));const g=sn(n,e.options),w=e.options.sourceDir?new RegExp(String.raw`(?:^|/)${e.options.sourceDir.replaceAll(Mr,String.raw`\$&`)}/`):void 0,b=new Set,v=new Set,S=new Map;return{buildStart(){Pi.clear()},name:"packem:externals",options:Be(x=>{x.external=(E,j)=>{const k=`${E}::${j??""}`;if(S.has(k))return S.get(k);const R=Fr(E),P=j?Fr(j):void 0;let z;if(Object.keys(g).length>0){const O=_m(R,g);O!==R&&(z=O)}let U="";z&&Tr(z)&&(U=al(z).name??""),!U&&Tr(R)&&(U=al(R).name??ph(R));const J=U&&Tr(U)&&Ix(U)?U:"";if(J&&!mn(J)){e.usedDependencies.add(J);const O=!P||!Vo(P,e.options.rootDir),F=i.has(J);O&&!F&&e.options.validation&&e.options.validation.dependencies&&e.options.validation.dependencies.hoisted!==!1&&!e.options.validation.dependencies.hoisted?.exclude.includes(J)&&e.hoistedDependencies.add(J)}const N=z?[R,z]:[R];for(const O of N){const F=n.name?O===n.name||O.startsWith(`${n.name}/`):!1;if(Tx.test(O)||Tt(O)||(w?.test(O)??!1)||F)return S.set(k,!1),!1;if(mn(O)||Gl.has(O)){let I=a.builtins;return I===void 0&&P&&(I=h(P)&&!$(P)),S.set(k,I),I}if(O[0]==="#"&&!O.startsWith("#/"))return S.set(k,!1),!1;if(h(O)&&!$(O))return S.set(k,!0),!0;if(y.some(I=>I.test(O))||J&&c(J))return S.set(k,!1),!1}return e.implicitDependencies.add(R),_x(R,e.logger),S.set(k,!1),!1}},"options"),resolveId:{filter:{id:Be(x=>!x.startsWith("\0"),"id")},async handler(x,E,j){if(j.isEntry)return;if(x[0]==="#"&&!x.startsWith("#/")&&n.imports)return E&&!Vo(E,e.options.rootDir)?{external:!0,id:x}:void 0;if(Gl.has(x))return{external:!0,id:x,moduleSideEffects:!1};if(mn(x)){const R=x.replace(Nx,"");let P=R;return(a.builtinsPrefix==="add"||!mn(R))&&(P=`node:${R}`),{external:(a.builtins??h(x))&&!$(x),id:a.builtinsPrefix==="ignore"?x:P,moduleSideEffects:!1}}if(!Tr(x)||x.includes("?")||x.includes(" "))return;const[k]=$i(x);if(s.has(k)&&!o.has(k)){if(h(x)&&!$(x))return;if(t?.forTypes)return t.dtsResolve&&c(k)?void 0:{external:!0,id:x,moduleSideEffects:!1};const R=await this.resolve(x,E,{skipSelf:!0,...j});if(!R)throw new Error(`Could not resolve "${x}" even though it's declared in package.json. Try re-installing node_modules.`);if(t?.forTypes){const P=Vl(k);o.has(P)&&!b.has(P)&&(b.add(P),e.logger.warn(`Recommendation: "${P}" is externalized but "${k}" is bundled (devDependencies). This may cause type mismatches for consumers. Consider moving "${k}" to dependencies or "${P}" to devDependencies.`))}return R}if(o.has(k)){if(t?.forTypes){const R=Vl(k);s.has(R)&&!b.has(R)&&(b.add(R),e.logger.warn(`Recommendation: "${R}" is bundled (devDependencies) but "${k}" is externalized. Place "${R}" in dependencies/peerDependencies as well so users don't have missing types.`))}return}if(!s.has(k)&&E&&!Vo(E,r)&&!t?.skipUnlistedWarnings&&!v.has(k)&&(v.add(k),e.logger.warn(`"${k}" imported by "${E}" but not declared in package.json. Will be bundled to prevent failure at runtime.`)),t?.forTypes&&E&&uh(E,r))return{external:!0,id:x,moduleSideEffects:!1}},order:"pre"}}},"externalsPlugin");var Dx=Object.defineProperty,ld=(e,t)=>Dx(e,"name",{value:t,configurable:!0}),Lx=Object.defineProperty,ht=ld((e,t)=>Lx(e,"name",{value:t,configurable:!0}),"h");const Fx=/^export\s+default\s+(\w+);/m,Hx=/export\s*\{([^}]*)\}/,qx=/\s*as\s+default\s*/,Jx=/\s+\}$/,wn=/;$/,zx=/(?:\r?\n\s*){2,}/g,ps=/^type\s+/,Kl=/\bas\s+default\b/,Ux=ht((e,t,r)=>{const n=xh(e).find(l=>l.names?.includes("default")),o=Fx.exec(e);if(o?.[1])return{defaultAlias:o[1],defaultExport:{code:o[0],end:o.index+o[0].length,names:["default"],specifier:void 0,start:o.index,type:"default"},exports:[]};if(!n)return;const s=Hx.exec(n.code);if(!s?.length){r.warn?.(`A default export was indicated in ${t.fileName}, but its structure could not be parsed.`);return}let i;const a=[];for(const l of s[1].split(",").map(u=>u.trim())){if(l==="default"){i=l;continue}const u=qx.exec(l);u?i=l.replace(u[0],""):a.push(l)}if(!i){r.warn?.(`A default export was indicated in ${t.fileName}, but its alias could not be determined from the export statement.`);return}return{defaultAlias:i,defaultExport:n,exports:a}},"extractExports"),Gx=ht((e,t,r)=>{if("declarations"in t&&t.declarations.length>0){const n=t.declarations[0];if(n?.id.type==="Identifier"){e.set(n.id.name,{declare:t.declare===!0,end:t.end,isVariable:!0,start:t.start});return}}if("id"in t&&t.id?.type==="Identifier"){const{name:n}=t.id;e.set(n,{declare:t.declare===!0,end:t.end,isClass:t.type==="ClassDeclaration",start:t.start});return}e.set(r(),{declare:t.declare===!0,end:t.end,start:t.start})},"prepareDeclaration"),Ur=ht((e,t,r,n)=>{const o=yo(r.fileName,e,{astType:"ts",lang:"ts",sourceType:"module"});let s,i=0;const a=ht(()=>(i+=1,`__unnamed_${String(i)}$$`),"generateUnnamed"),l=new Map,u=new Map,{program:c}=o;for(const m of c.body)if(m.type==="ExportNamedDeclaration")for(const h of m.specifiers)h.exported.type==="Identifier"&&(h.exported.name==="default"?h.local.type==="Identifier"&&(s={end:h.end,local:h.local.name,start:h.start}):u.set(h.exported.name,{type:h.exportKind==="type"}));else{if(m.type==="ImportDeclaration")continue;switch(m.type){case"ClassDeclaration":case"FunctionDeclaration":case"TSDeclareFunction":case"TSEnumDeclaration":case"TSInterfaceDeclaration":case"TSTypeAliasDeclaration":case"VariableDeclaration":{Gx(l,m,a);break}case"TSImportEqualsDeclaration":case"TSModuleDeclaration":{l.set(a(),{declare:!1,end:m.end,start:m.start});break}}}const p=[];if(s)for(const[m,h]of u.entries())m!==s.local&&h.type&&p.push(m);if(!s){const m=[...u.values()].every(h=>h.type);return t.startsWith("export type")&&u.size>0&&m||n.warn?.(`Cannot infer default export from the file: ${r.fileName}`),t}if(!l.get(s.local))return n.warn?.(`Cannot infer default export from the file: ${r.fileName}. Declaration for '${s.local}' not found.`),t;const f=t,d=new Se(`${f}
|
|
63
|
+
declare namespace ${s.local} {
|
|
64
|
+
`);for(const[m,h]of l.entries()){if(p.includes(m)&&m!==s.local)continue;const $=e.slice(h.start,h.end).replace(Jx," }");d.append(" "),h.declare?d.append($.replace("declare","export").replaceAll(" "," ")):d.append(`export ${$}`.replaceAll(" "," ")),d.append(`
|
|
65
|
+
`)}return d.append(` import _default = ${s.local};
|
|
66
|
+
export { _default as default };
|
|
67
|
+
`),d.append(`}
|
|
68
|
+
export = ${s.local};
|
|
69
|
+
`),d.toString()},"createCjsNamespace"),fs=ht((e,t,r)=>{const{defaultExport:n,exports:o}=t;if(r){const p=o.length===0?`export = ${r.defaultImport??""};`:`// @ts-ignore
|
|
70
|
+
export = ${r.defaultImport??""};
|
|
71
|
+
export { ${o.join(", ")} } from '${n.specifier??""}'`,f=e.replace(n.code.replace(wn,""),p.replace(wn,""));return f.endsWith(";")?f:`${f};`}const s=`import _default from '${n.specifier??""}';`,i=new Se(e),a=go(e),l=a.length>0?a.at(-1):void 0;l?.end!==void 0&&l.end>0?i.appendRight(l.end,`
|
|
72
|
+
${s}
|
|
73
|
+
`):i.prepend(`${s}
|
|
74
|
+
`);let u=i.toString();u=u.replaceAll(zx,`
|
|
75
|
+
`);let c;if(o.length===0)c=u.replace(n.code.replace(wn,""),"export = _default");else{const p=`// @ts-ignore
|
|
76
|
+
export = _default;
|
|
77
|
+
export { ${o.join(", ")} } from '${n.specifier??""}';`;c=u.replace(n.code.replace(wn,""),p)}return c.replaceAll(";;",";")},"handleDefaultCJSExportAsDefault"),Vx=ht((e,t,r,n,o,s)=>{const{defaultAlias:i,defaultExport:a,exports:l}=r;if(s){if(s.namedImports?.[i]===i){if(l.length===0)return e.replace(a.code,`export = ${i}`);const d=`export { ${l.join(", ")} } from '${a.specifier??""}'`,m=new Se(e).replace(a.code,d).toString();return Ur(e,m,t,o)}o.warn?.(`Cannot parse "${i}" named export from ${s.specifier} import at ${t.fileName}!.`);return}const u=`import { ${i} } from '${a.specifier??""}';
|
|
78
|
+
`;let c=e;const p=n.length>0?n.at(-1)?.end??0:0,f=new Se(c);if(p>0?f.appendRight(p,`
|
|
79
|
+
${u}`):f.prepend(u),c=f.toString(),l.length>0){const d=`export { ${l.join(", ")} } from '${a.specifier??""}'`,m=new Se(c).replace(a.code,d).toString();return Ur(e,m,t,o)}return new Se(c).replace(a.code,`export = ${i}`).toString()},"handleDefaultNamedCJSExport"),Yl=ht((e,t,{defaultAlias:r,defaultExport:n,exports:o},s)=>{const i=o.filter(l=>ps.test(l)),a=o.filter(l=>!ps.test(l));if(i.length>0){let l="";return r&&(l+=`// @ts-ignore
|
|
80
|
+
${r};
|
|
81
|
+
`),l+=`export type { ${i.map(u=>u.replace(ps,"").trim()).join(", ")} };
|
|
82
|
+
`,a.length>0&&(l+=`export { ${a.join(", ")} };
|
|
83
|
+
`),Ur(e,l.trim(),t,s)}if(r&&a.length>0&&i.length===0){let l=`// @ts-ignore
|
|
84
|
+
${r};
|
|
85
|
+
`;return l+=`export { ${a.join(", ")} };
|
|
86
|
+
`,Ur(e,l.trim(),t,s)}if(r&&a.length===0&&i.length===0){const l=new RegExp(String.raw`^export\\s+default\\s+${r};`,"m").exec(e);return l?`${e.slice(0,Math.max(0,l.index))}export = ${r};`:e.replace(n.code,`export = ${r};`).replace(";;",";")}},"handleNoSpecifierDefaultCJSExport"),Kx=/^export\s+default\s+from\s+['"]([^'"]+)['"];?$/m,Yx=ht((e,t,r)=>{const n=Kx.exec(e);if(n)return{code:`import _default from '${n[1]??""}';
|
|
87
|
+
export = _default;`,map:void 0};const o=Ux(e,t,r);if(o){let l;if(o.defaultExport.specifier){const{specifier:u}=o.defaultExport,c=go(e),p=c.filter(y=>y.imports).map(y=>vh(y)),f=p.find(y=>y.specifier===u),{defaultAlias:d,defaultExport:m,exports:h}=o,$=m.exports;if(d==="default"&&m.specifier&&h.length>0)l=fs(e,o,f);else if(d==="default"&&m.specifier&&h.length===0&&$&&Kl.test($))p.find(y=>y.specifier===m.specifier)?.defaultImport?l=fs(e,o,f):(r.warn?.(`Cannot parse default export name from ${m.specifier} import at ${t.fileName}!. The module might not have a default export, or it's aliased as 'default'.`),l=void 0);else if(d==="default"&&m.specifier&&h.length===0)l=fs(e,o,f);else if(m.specifier&&d!=="default"){l=Vx(e,t,o,c,r,f);const y=f&&o.defaultExport.specifier&&d!=="default"&&f.namedImports?.[d]!==d;if(!(l===void 0&&y)&&l===void 0&&!(d==="default"&&h.length===0&&$&&Kl.test($))){const g=Yl(e,t,o,r);g&&(l=g)}}}else l=Yl(e,t,o,r);return l?{code:l,map:void 0}:void 0}const s=yo(t.fileName,e,{astType:"ts",lang:"ts",sourceType:"module"});let i=[],a=!1;if(s.program.body.length>0){const l=s.program.body.at(-1);l?.type==="ExportNamedDeclaration"&&!l.declaration&&l.specifiers.length>0&&l.specifiers.every(u=>u.exportKind==="type")&&(a=!0,i=l.specifiers.map(u=>u.local.type==="Identifier"?u.local.name:"").filter(Boolean))}if(a&&i.length>0){const l=`export type { ${i.join(", ")} };`,u=Ur(e,l,t,r);return u?{code:u,map:void 0}:void 0}},"fixDtsDefaultCJSExports");var Xx=Object.defineProperty,Xl=ld((e,t)=>Xx(e,"name",{value:t,configurable:!0}),"s");const Zx=/\.d\.c?ts$/,cd=Xl((e={})=>{const{matcher:t=Xl(r=>r.exports.length>0&&Zx.test(r.fileName)&&r.isEntry,"matcher")}=e;return{name:"packem:fix-dts-default-cjs-exports-plugin",renderChunk(r,n){return t(n)?Yx(r,{fileName:n.fileName,imports:n.imports},{warn:this.warn}):void 0}}},"fixDtsDefaultCjsExportsPlugin");var Qx=Object.defineProperty,ud=(e,t)=>Qx(e,"name",{value:t,configurable:!0}),e2=Object.defineProperty,or=ud((e,t)=>e2(e,"name",{value:t,configurable:!0}),"a");const t2=or(e=>{const t=[],r=[];e.forEach(o=>{o.startsWith("(")?t.push(o):r.push(o)});const n=or((o,s)=>o.localeCompare(s),"byLocale");return[...r.toSorted(n),...t.toSorted(n)]},"sortLicenses"),r2=or((e,t,r)=>{const n=new Set;for(const o of[e,...t,...r]){const s=typeof o=="string"?o:o?.name;s&&n.add(s)}return[...n]},"collectAuthorNames");function ka(e){return e?`> ${e}`:">"}ud(ka,"P");or(ka,"prefixQuoteMarker");const n2=or((e,t,r)=>e.trim().replaceAll(/\r\n|\r/g,`
|
|
88
|
+
`).replaceAll(`<!-- ${t} -->`,"").replaceAll(r?`<!-- ${r} -->`:"","").replaceAll(`<!-- /${t} -->`,"").replaceAll(r?`<!-- /${r} -->`:"","").trim().split(`
|
|
89
|
+
`).map(n=>ka(n)).join(`
|
|
90
|
+
`),"formatLicenseBody"),ja=or(({dtsMarker:e,licenseFilePath:t,licenseTemplate:r,logger:n,marker:o,mode:s,packageName:i})=>jh({thirdParty(a){const l=new Set,u=a.toSorted(({name:p},{name:f})=>{const d=p??"",m=f??"";return d.localeCompare(m)}).map(({author:p,contributors:f,license:d,licenseText:m,maintainers:h,name:$,repository:y})=>{let g=`## ${$??""}
|
|
91
|
+
`;d&&(g+=`License: ${d}
|
|
92
|
+
`);const w=r2(p,h,f);return w.length>0&&(g+=`By: ${w.join(", ")}
|
|
93
|
+
`),y&&(g+=`Repository: ${typeof y=="string"?y:y.url}
|
|
94
|
+
`),m&&(g+=`
|
|
95
|
+
${n2(m,o,e)}
|
|
96
|
+
`),d&&l.add(d),g}).join(`
|
|
97
|
+
---------------------------------------
|
|
98
|
+
|
|
99
|
+
`);if(u===""){n.info({message:"No dependencies license information found.",prefix:`plugin:license:${s}`});return}const c=r(t2(l),u,i);try{const p=Qu(t),f=fh(p,o,c);if(!f){n.error({message:`Could not find the license marker: <!-- ${o} --><!-- /${o} --> in ${t}`,prefix:`plugin:license:${s}`});return}p!==f&&(Bm(t,f),n.info({message:`${t} updated.`,prefix:`plugin:license:${s}`}))}catch(p){n.error(p)}}}),"licensePlugin");var o2=Object.defineProperty,s2=(e,t)=>o2(e,"name",{value:t,configurable:!0}),i2=Object.defineProperty,ro=s2((e,t)=>i2(e,"name",{value:t,configurable:!0}),"l");const Zl=/\bfrom\s+['"`]([^'"`]+)['"`]/g,a2=/[/\\]node_modules[/\\]/,l2=/^\0/,c2=ro(async e=>{try{const n=await Qr(e);if(n.isFile())return e;if(n.isDirectory()){const o=G(e,"index.js");if(await Xt(o))return o;const s=G(e,"index.json");if(await Xt(s))return s}}catch{}const t=`${e}.js`;if(await Xt(t))return t;const r=`${e}.json`;if(await Xt(r))return r},"tryResolveImplicit"),u2=ro(async(e,t)=>{let r=e;const n=X("/");for(;r!==n&&r!==Z(r);){const o=G(r,"node_modules",t,"package.json");if(await Xt(o))return o;r=Z(r)}},"findPackageJson"),Aa=ro(e=>{const t=new Map,r=new Map,n=new Set;e.pkg.dependencies&&Object.keys(e.pkg.dependencies).forEach(s=>n.add(s)),e.pkg.peerDependencies&&Object.keys(e.pkg.peerDependencies).forEach(s=>n.add(s)),e.pkg.optionalDependencies&&Object.keys(e.pkg.optionalDependencies).forEach(s=>n.add(s));const o=ro(s=>n.has(s),"isExternalPackage");return{name:"packem:resolve-implicit-externals",transform:{filter:{id:{exclude:[l2,a2]}},async handler(s,i){if(i.includes("/node_modules/")||i.startsWith("\0"))return;const a=[];let l;for(Zl.lastIndex=0;(l=Zl.exec(s))!==null;){const f=l[1];if(!f||!Tr(f))continue;const[d,m]=$i(f);if(m&&d&&o(d)){const h=l.index+l[0].indexOf(f);a.push({importId:f,quoteEnd:h+f.length,quoteStart:h})}}if(a.length===0)return;const u=Z(i),c=(await Promise.all(a.map(async f=>{const[d,m]=$i(f.importId);if(!m)return;const h=`${d}:${m}:${u}`,$=r.get(h);if($!==void 0)return $?{...f,resolvedId:$}:void 0;const y=await u2(u,d);if(!y){r.set(h,void 0);return}let g=t.get(y);if(g===void 0)try{g=Dm(y,{resolveCatalogs:!0}),t.set(y,g)}catch{t.set(y,void 0),r.set(h,void 0);return}if(g.exports){r.set(h,void 0);return}const w=Z(y),b=G(w,m),v=await c2(b);if(!v){r.set(h,void 0);return}const S=ke(w,v),x=`${d}/${S}`;return r.set(h,x),{...f,resolvedId:x}}))).filter(f=>f!==void 0);if(c.length===0)return;const p=new Se(s);for(const{quoteEnd:f,quoteStart:d,resolvedId:m}of c)p.overwrite(d,f,m),this.debug(`[resolve-implicit-externals] Rewriting ${s.slice(d,f)} -> ${m} in ${i}`);return{code:p.toString(),map:p.generateMap({hires:!0})}}}}},"resolveImplicitExternalsPlugin");var p2=Object.defineProperty,f2=(e,t)=>p2(e,"name",{value:t,configurable:!0}),d2=Object.defineProperty,Io=f2((e,t)=>d2(e,"name",{value:t,configurable:!0}),"o");const no=/^#![^\n]*/,_i=Io(async e=>{await cp(e,493).catch(()=>{})},"makeExecutable"),m2=Io((e,t)=>({name:"packem:shebang",renderChunk:{handler(r,n,o){if(!n.isEntry||!n.facadeModuleId)return;const s=r.startsWith("#")&&r[1]==="!";if(s&&t.replace)return{code:r.replace(no,`${t.shebang}
|
|
100
|
+
`),map:void 0};if(!s&&e.includes(n.name)){const i=new Se(r);return i.prepend(`${t.shebang}
|
|
101
|
+
`),{code:i.toString(),map:o.sourcemap?i.generateMap({hires:!0}):void 0}}},order:"post"},async writeBundle(r,n){for(const[o,s]of Object.entries(n))if(s.type==="chunk"&&no.test(s.code)&&r.dir){const i=X(r.dir,o);await _i(i)}}}),"shebangPlugin"),pd=Io(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(no,"")}}),"removeShebangPlugin"),h2=Io((e,t=`
|
|
102
|
+
`)=>{const r=no.exec(e);return r?`${r[0]}${t}`:""},"getShebang");var g2=Object.defineProperty,Wo=(e,t)=>g2(e,"name",{value:t,configurable:!0}),y2=Object.defineProperty,bt=Wo((e,t)=>y2(e,"name",{value:t,configurable:!0}),"l");const $2=/\s/,b2=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,w2=/MIT License|MIT license|BSD license/,v2=/\n{2,}/g,x2=/\b(\w+)\$\d+\b/g,E2=/[-/\\^$*+?.()|[\]{}]/g,S2=bt(e=>e.replaceAll(E2,String.raw`\$&`),"escapeRegex"),k2=bt(e=>[...new Set(e)],"unique"),j2=/\.[^/.]+$/;function Oa(e){return w2.test(e)?"":e}Wo(Oa,"k");bt(Oa,"stripLicenseComment");const A2=bt(e=>e.replaceAll(b2,Oa).replaceAll(v2,`
|
|
103
|
+
|
|
104
|
+
`),"cleanUnnecessaryComments"),Mi=new Map;function Ra(e,t,{identifierReplacements:r},n){const o=go(e);let s=e;for(const a of Object.keys(r??{})){const l=o.find(c=>c.specifier===a&&c.imports.includes("{"));if(!l)throw new Error(`${t.fileName} does not import "${a}" for replacement`);const u=r?.[a]??{};for(const c of Object.keys(u)){if(!l.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${a}" for replacement`);const p=u[c],f=S2(c);p.includes(".")&&(s=s.replace(new RegExp(String.raw`\b\w+\b as ${f},?\s?`),"")),s=s.replaceAll(new RegExp(String.raw`\b${f}\b`,"g"),p)}}const i=k2(Array.from(s.matchAll(x2),a=>a[0]));if(i.length>0){const a=i.map(u=>`
|
|
105
|
+
- ${u}`).join(""),l=t.fileName.replace(j2,"");Mi.has(l)||n.warn({message:`${t.fileName} contains confusing identifier names${a}
|
|
106
|
+
|
|
107
|
+
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Mi.set(l,!0)}return s}Wo(Ra,"O");bt(Ra,"replaceConfusingTypeNames");function Ca(e,t){if(!e.includes("@internal"))return e;const r=new Se(e),n=yo(t.fileName,e,{lang:"dts",sourceType:"module"}),o=bt(a=>{let l=a,u=!0;for(;u;){for(u=!1;l<e.length&&$2.test(e[l]);)l+=1;for(const c of n.comments)if(c.start===l){l=c.end,u=!0;break}}return l},"skipPastCommentsAndWhitespace"),s=[];for(const a of n.comments)a.type!=="Block"||!a.value.includes("@internal")||s.push({commentStart:a.start,nextStart:o(a.end)});s.length>0&&Ch(n.program,{enter(a){if(a.type==="Program")return;const{end:l,start:u}=a;if(typeof u!="number"||typeof l!="number")return;const c=s.findIndex(d=>d.nextStart===u);if(c===-1)return;const[{commentStart:p}]=s.splice(c,1),f=e[l]===","?l+1:l;r.remove(p,f),this.skip()}});const i=r.toString();if(i.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`);return i}Wo(Ca,"v");bt(Ca,"stripInternalTypes");const fd=bt((e,t)=>({buildStart(){Mi.clear()},name:"packem:patch-types",renderChunk(r,n){return r=Ra.call(this,r,n,e,t),r=Ca.call(this,r,n),r=A2(r),r}}),"patchTypescriptTypes");var O2=Object.defineProperty,R2=(e,t)=>O2(e,"name",{value:t,configurable:!0}),C2=Object.defineProperty,Qe=R2((e,t)=>C2(e,"name",{value:t,configurable:!0}),"o");const T2=/^\./,N2=/\0/,P2=42,_2=Qe(e=>{let t=!1;for(let r=0;r<e.length;r++)if(e.codePointAt(r)===P2){if(t)return!1;t=!0}return!0},"hasZeroOrOneAsteriskCharacter"),M2=Qe(e=>{const t=e.indexOf("*");return t===-1?void 0:{prefix:e.slice(0,t),suffix:e.slice(t+1)}},"tryParsePattern"),I2=Qe(({prefix:e,suffix:t},r)=>r.length>=e.length+t.length&&r.startsWith(e)&&r.endsWith(t),"isPatternMatch"),W2=Qe((e,t,r)=>{let n,o=-1;for(const s of e){const i=t(s);I2(i,r)&&i.prefix.length>o&&(o=i.prefix.length,n=s)}return n},"findBestPatternMatch"),B2=Qe(e=>{const t=[],r=new Set;for(const n of e){if(!_2(n))continue;const o=M2(n);o?t.push(o):r.add(n)}return{exact:r,patterns:t}},"parsePathPatterns"),D2=Qe((e,t)=>e.exact.has(t)?t:W2(e.patterns,r=>r,t),"matchPatternOrExact"),L2=Qe((e,t)=>t.substring(e.prefix.length,t.length-e.suffix.length),"matchedText"),F2=Qe(({prefix:e,suffix:t})=>`${e}*${t}`,"patternText"),H2=Qe((e,t,r)=>{let n=Z(t.path);t.config.compilerOptions?.baseUrl&&(n=X(e,t.config.compilerOptions.baseUrl)),r?.debug({message:`Resolved baseUrl to ${n}`,prefix:"plugin:resolve-tsconfig-paths"});const o=t.config.compilerOptions?.paths??{};return Object.keys(o).length===0&&r?.debug({message:"No paths found in tsconfig.json",prefix:"plugin:resolve-tsconfig-paths"}),{paths:o,resolvedBaseUrl:n}},"getTsconfigPaths"),Ta=Qe((e,t,r,n)=>{const{paths:o,resolvedBaseUrl:s}=H2(e,t,r),i=Object.keys(o),a=B2(i);return{name:"plugin:resolve-tsconfig-paths",resolveId:{filter:{id:{exclude:[T2,N2]}},async handler(l,u,c){if(i.length===0)return;if(l.includes("\0")){r.debug({message:`Skipping resolution of ${l} as it is a virtual module`,prefix:"plugin:resolve-tsconfig-paths"});return}if(l.includes("node_modules")){r.debug({message:`Skipping request as it is inside node_modules ${l}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(!n.resolveAbsolutePath&&Tt(l)){r.debug({message:`Skipping request as it is an absolute path ${l}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(Vu(l)){r.debug({message:`Skipping request as it is a relative path ${l}`,prefix:"plugin:resolve-tsconfig-paths"});return}const p=D2(a,l);if(!p){r.debug({message:`moduleName did not match any paths pattern ${l}`,prefix:"plugin:resolve-tsconfig-paths"});return}const f=typeof p=="string"?void 0:L2(p,l),d=typeof p=="string"?p:F2(p);for(const m of o[d]){const h=f?m.replace("*",f):m;if(h.endsWith(".d.ts")||h.endsWith(".d.cts")||h.endsWith(".d.mts"))continue;const $=G(s,h);try{const y=await this.resolve($,u,{skipSelf:!0,...c});if(y)return y}catch(y){r.debug({context:[y],message:`Failed to resolve ${$} from ${l}`,prefix:"plugin:resolve-tsconfig-paths"})}}}}}},"resolveTsconfigPathsPlugin");var q2=Object.defineProperty,J2=(e,t)=>q2(e,"name",{value:t,configurable:!0}),z2=Object.defineProperty,dd=J2((e,t)=>z2(e,"name",{value:t,configurable:!0}),"d");const U2=/^\./,G2=/^\.{1,2}\/?$/,V2=dd((e,t)=>{if(!t)return;const{config:r,path:n}=t;if(!r.compilerOptions)return;const{rootDirs:o}=r.compilerOptions;if(!o)return;const s=Z(n),i=Tt(s)?s:X(e,s),a=[];for(const l of o){if(G2.test(l))throw new Error(`Invalid rootDir value '${l}' in ${n}. Expected a directory path such as "./lib" or "src".`);a.push(Tt(l)?l:X(i,l))}return a},"getRootDirectories"),Na=dd((e,t,r)=>{const n=V2(e,r);return{name:"packem:resolve-tsconfig-root-dirs",resolveId:{filter:{id:U2},async handler(o,s,i){if(!(n===void 0||n.length===0)&&o.startsWith("."))for(const a of n){const l=G(a,o),u=await this.resolve(l,s,{skipSelf:!0,...i});if(u)return t.debug({message:`Resolved ${o} to ${u.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),u.id}}}}},"resolveTsconfigRootDirectories");var K2=Object.defineProperty,Y2=(e,t)=>K2(e,"name",{value:t,configurable:!0}),X2=Object.defineProperty,Pa=Y2((e,t)=>X2(e,"name",{value:t,configurable:!0}),"l");const Z2={".cjs":[".cts"],".js":[".ts",".tsx"],".jsx":[".tsx",".ts"],".mjs":[".mts"]},Ql=/\.(?:[mc]?js|jsx)$/,Q2=Pa(e=>{const t=e[0];return!(t==="."||t==="/"||t==="#"||Th(e))},"isBareSpecifier"),ec=Pa(async(e,t,r,n,o,s)=>{for(const i of t)try{const a=await e.resolve(r+i,n,o);if(a)return a}catch(a){if(!s)throw a}},"tryRewrites"),_a=Pa(()=>({name:"packem:resolve-typescript-mjs-cjs",resolveId:{filter:{id:Ql},async handler(e,t,r){if(!t)return;const n=Ql.exec(e);if(!n)return;const o=n[0],s=Z2[o];if(!s)return;const i=e.slice(0,-o.length),a={...r,skipSelf:!0};return!Q2(e)&&!t.includes("/node_modules/")&&!e.includes("/node_modules/")?ec(this,s,i,t,a,!1):await this.resolve(e,t,a)||ec(this,s,i,t,a,!0)}}}),"resolveTypescriptMjsCts");var eE=Object.defineProperty,tE=(e,t)=>eE(e,"name",{value:t,configurable:!0}),rE=Object.defineProperty,Ma=tE((e,t)=>rE(e,"name",{value:t,configurable:!0}),"o");const nE=/\.tsx?$/,oE=/['"]use memo['"]/,tc="babel-options",sE="__packem_babel_missing_options__",iE=Ma(e=>e.find(t=>t==="babel-plugin-react-compiler"||Array.isArray(t)&&t[0]==="babel-plugin-react-compiler"),"getReactCompilerPlugin"),aE=Ma((e,t)=>{if(e.length===0)return;const r=iE(e);if(!(!r||!Array.isArray(r))&&r[1]?.compilationMode==="annotation"&&!oE.test(t)){const n=e.indexOf(r);n!==-1&&e.splice(n,1)}},"filterReactCompilerByAnnotation"),lE=Ma(async(e,t,{filename:r,generatorOpts:n,sourceFileName:o,...s})=>{let i=[];s.plugins&&Array.isArray(s.plugins)&&(i=[...s.plugins]),i.length>0&&aE(i,e);const a=[];(t.endsWith(".jsx")||t.endsWith(".tsx"))&&a.push("jsx"),nE.test(t)&&a.push("typescript");const l=s.parserOpts?.plugins;l&&Array.isArray(l)&&a.unshift(...l);const u=[...new Set(a)],c=await Ih(e,{...s,filename:t,generatorOpts:{...n,decoratorsBeforeExport:!0,importAttributesKeyword:"with"},parserOpts:{...s.parserOpts,allowAwaitOutsideFunction:!0,plugins:u.length>0?u:[],sourceType:"module"},plugins:i.length>0?i:[],sourceFileName:t});if(c?.code)return{code:c.code,map:c.map??void 0}},"transformCode");var cE=Object.defineProperty,uE=(e,t)=>cE(e,"name",{value:t,configurable:!0}),pE=Object.defineProperty,Gr=uE((e,t)=>pE(e,"name",{value:t,configurable:!0}),"s");const fE=20,dE=4,mE=dp("babel-runtime","plugins","babel","worker.js"),hE=Gr(e=>{const t=Gr(r=>{if(r===null)return!0;if(Array.isArray(r))return r.every(n=>t(n));switch(typeof r){case"boolean":case"number":case"string":case"undefined":return!0;case"object":return Object.values(r).every(n=>t(n));default:return!1}},"isSerializable");for(const r of Object.keys(e))if(!t(e[r]))return r},"findNonSerializableOption"),gE=Gr(()=>{let e;try{e=wi(ip(import.meta.url))}catch{return}for(let t=0;t<6;t+=1){const r=dp(e,mE);if(Xi(r))return r;const n=wi(e);if(n===e)break;e=n}},"resolveWorkerScript"),yE=Gr(({exclude:e,generatorOpts:t,include:r,logger:n,parallel:o=!0,parallelThreshold:s=fE,...i})=>{const a=Ze(r,e??kt),l={...i,generatorOpts:t};let u=0,c,p=o===!1||typeof o=="number"&&o<=0;const f=Gr(()=>{if(p)return;if(c)return c;if(u<s)return;const d=hE(l);if(d!==void 0){p=!0,n?.warn(`[packem:babel] Parallel transforms disabled: the Babel option "${d}" is not serializable across a worker thread (e.g. a function plugin/preset or a function-form babel config). Falling back to in-process transforms.`);return}const m=gE();if(!m){p=!0,n?.debug("[packem:babel] Parallel transforms disabled: the worker script was not found on disk (running from source, or the build did not copy it into dist/babel-runtime/). Falling back to in-process transforms.");return}const h=typeof o=="number"?Math.max(1,o):Math.max(1,Math.min(Ph().length,dE));return c=Mh.pool(m,{maxWorkers:h,workerType:"thread"}),c},"ensurePool");return{async closeBundle(){this.meta.watchMode||(await c?.terminate(),c=void 0)},async closeWatcher(){await c?.terminate(),c=void 0},name:"packem:babel",async transform(d,m){if(!a(m))return;u+=1;const h=f();if(h)try{return await h.exec("transform",[d,m,tc])}catch(y){if(y instanceof Error&&y.message.includes(sE))return await h.exec("transform",[d,m,tc,l]);throw y}const $=await lE(d,m,l);if($)return{code:$.code,map:$.map??void 0}}}},"babelTransformPlugin");var $E=Object.defineProperty,bE=(e,t)=>$E(e,"name",{value:t,configurable:!0}),wE=Object.defineProperty,vE=bE((e,t)=>wE(e,"name",{value:t,configurable:!0}),"f");const xE=vE((e,t)=>{const r=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:o}=n;return Array.isArray(o)?o=o.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof o=="string"&&(o=[{src:o}]),{async buildStart(){const s=await Promise.all(o.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):[i]).map(async i=>await Lm(bi(i.src),{ignore:bi(i.exclude).filter(Boolean)}).then(a=>({dest:i.dest??"",parent:Fm(i.src),src:a}))));for(const i of s)for(const a of i.src){let l;r.has(a)?l=r.get(a):(l={copied:[],dest:[],timestamp:0},r.set(a,l));const u=n.flatten?Ku(i.dest):G(i.dest,ke(i.parent,Z(a)));l.dest.includes(u)||l.dest.push(u),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all(Array.from(r,async([i,a])=>{let l;try{const u=await Qr(i);if(!u.isFile())return;const c=u.mtime.getTime();c>a.timestamp&&(a.timestamp=c,a.copied=[]),l=await Nt(i,{buffer:!0})}catch(u){t.error({context:[u],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const u of a.dest){if(n.copyOnce&&a.copied.includes(u))continue;const c=Fe(i),p=G(u,c);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${i} → ${p}`,prefix:"plugin:copy"}),a.copied.push(u)}catch(f){t.error({context:[f],message:`error copying file ${i} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var EE=Object.defineProperty,SE=(e,t)=>EE(e,"name",{value:t,configurable:!0}),kE=Object.defineProperty,jE=SE((e,t)=>kE(e,"name",{value:t,configurable:!0}),"l");const AE=/\?data-uri/,OE=jE((e={})=>{const t=Ze(e.include??[AE],e.exclude);return{async load(r){if(!t(r)||!r.includes("?data-uri"))return;const n=new URL(r,"file://"),o=n.pathname,s=n.searchParams.get("encoding")??"tiny",i=n.searchParams.has("srcset")||e.srcset;this.addWatchFile(o);const a=hp.getType(o)??"application/octet-stream";if(a==="image/svg+xml"){const p=await Nt(o,{buffer:!1}),f=s==="css"?oh(p):sh(p),d=i?f.replaceAll(" ","%20"):f;return`export default ${JSON.stringify(d)}`}const l=await Nt(o,{buffer:!0}),u=Buffer.from(l).toString("base64"),c=`${a.startsWith("text/")?`data:${a};charset=utf-8;base64,`:`data:${a};base64,`}${u}`;return`export default ${JSON.stringify(c)}`},name:"packem:data-uri"}},"dataUriPlugin");var RE=Object.defineProperty,CE=(e,t)=>RE(e,"name",{value:t,configurable:!0}),TE=Object.defineProperty,$e=CE((e,t)=>TE(e,"name",{value:t,configurable:!0}),"u");const NE=/\.[mc]?tsx?(?:\?.*)?$/,PE=/(?:\.[tj]sx?|\/index\.[tj]sx?)(?:\?.*)?$/,_E=/^\s*export/,ME=/^(?:import|export)\s+([\w$]+)/,IE=/([\w$]+)\s*,\s*\{|\}\s*,\s*([\w$]+)/,ds=/[{,]\s*(type\s+)?([\w$]+)(?:\s+as\s+([\w$]+))?/gi,WE=/default\s+([a-zA-Z_$][\w$]*)(?:[;\n]|$)/,BE=/([\w$]+)\s*as\s*$/,DE=/^export\s+\*(?!\s+as)/,LE=/\bas\b/,FE={exports:[],facade:!1,imports:[]},md=$e(e=>NE.test(e),"isSourceFile"),hd=$e(e=>e.includes("/build/cache/vite/")||e.includes("/node_modules/"),"isIgnoredModule"),HE=$e((e,t)=>hd(e)?!1:PE.test(e)?!0:t.possibleBarrelFiles?t.possibleBarrelFiles.some(r=>typeof r=="string"?e.includes(r):r.test(e)):!1,"isPossibleBarrelSpecifier"),gd=$e(e=>_E.test(e)?"export":"import","getDeclarationKind"),{parseAsync:qE}=Wh,yd=$e(async(e,t,r)=>{try{const{output:n}=await qE({input:[{code:t,filename:e}]});return n[0]}catch(n){return r.debug({message:`Failed to parse ${e}:
|
|
108
|
+
${n instanceof Error?n.message:String(n)}`,prefix:"plugin:debarrel"}),FE}},"safeParse"),JE=$e(async(e,t,r,n)=>{const o=e.parseCache.get(t);if(o!==void 0)return o;const s=await yd(t,r,n);return e.parseCache.set(t,s),s},"parsePotentialBarrelFile"),$d=$e((e,t)=>{const r=e.fileCache.get(t);if(r!==void 0)return r;const n=lp.readFile(t,"utf8");return e.fileCache.set(t,n),n},"readFileCached"),bd=$e(e=>{ds.lastIndex=0;const t=[];if(e.includes("*"))return t;if(!e.includes("{")){const o=ME.exec(e);return o&&t.push({imported:"default",local:o[1]}),t}const r=IE.exec(e);r&&t.push({imported:"default",local:r[1]??r[2]});let n=ds.exec(e);for(;n!==null;)!n[1]&&n[2]&&t.push({imported:n[2],local:n[3]}),n=ds.exec(e);return t},"getImportNames"),zE=$e((e,t,r)=>{let n=e.ln,o=t.find(s=>s.ss<e.s&&s.se>e.e&&s.d===-1);if(!o?.n){const s=n??WE.exec(r.slice(e.s))?.[1];s&&(o=t.find(i=>{const a=bd(r.slice(i.ss,i.s)).find(l=>l.local===s);return a&&(n=a.imported),a}))}if(o&&!n){const s=r.slice(o.ss,e.s);if(!s.includes("*")){const i=BE.exec(s)?.[1];i&&(n=i)}}return{imp:o,localExportName:n}},"findMatchingImport"),rc=new Map,UE=$e((e,t)=>{if(gd(e)!=="import"||!LE.test(e))return;let r=rc.get(t);return r||(r=new RegExp(String.raw`(\w+)\s+as\s+${t}(?!\w)`),rc.set(t,r)),r.exec(e)?.[0]},"findAliasedImportName");let Vr;const GE=$e(async(e,t,r,n,o,s,i,a)=>{const{resolve:l}=e,u=zE(n,o,r),{imp:c,localExportName:p}=u;if(!c?.n)return{exportName:s,id:t,resolved:!0};if(c.d>-1)return{exportName:s,id:t,resolved:!0};const f=r.slice(c.ss,n.s),d=UE(f,s),m=(await l(c.n,t))?.id;return m?HE(m,i)?Vr(e,m,p??n.n,i,a):{aliasedImportName:d,exportName:p??s,id:m,resolved:!1}:{aliasedImportName:d,exportName:p,id:t,resolved:!1}},"resolveExportThroughBarrel"),VE=$e(async(e,t,r,n,o,s,i)=>{const a=n.filter(l=>DE.test(r.slice(l.ss,l.s)));if(a.length===1){const l=a[0]?.n,u=(l?await e.resolve(l,t):void 0)?.id;if(!u)return;const c=await Vr(e,u,o,s,i);if(c.resolved)return c}else if(a.length>1){const l=(await Promise.all(a.map(async u=>{const c=u.n;if(!c)return;const p=(await e.resolve(c,t))?.id;if(p)return Vr(e,p,o,s,i)}))).find(u=>u?.resolved);if(l)return l}},"resolveWildcardReExports");Vr=$e(async(e,t,r,n,o)=>{const s=await $d(e,t),{exports:i,imports:a}=await JE(e,t,s,o);for(const l of i)if(l.n===r)return await GE(e,t,s,l,a,r,n,o);return await VE(e,t,s,a,r,n,o)||{exportName:r,id:t,resolved:!1}},"resolveThroughBarrel");const KE=$e((e,t,r)=>{const{aliasedImportName:n,exportName:o}=e,s=t.local??t.imported;if(n)return`{${n}}`;if(o==="default"&&r!=="export")return s;const i=o??s;return`{${i!==s?`${i} as ${s}`:i}}`},"getDeclarationClause"),YE=$e(async(e,t,r,n,o)=>{const s=[],i=await $d(e,t),{imports:a}=await yd(t,i,o);return await Promise.all(a.map(async l=>{if(!l.n||l.d!==-1)return;const u=i.slice(l.ss,l.s),c=bd(u);if(c.length===0)return;const p=(await e.resolve(l.n,t))?.id;if(!p||!md(p)||hd(p))return;const f=gd(u);try{const d=await Promise.all(c.map(async m=>{const h=await Vr(e,p,m.imported,n,o),$=KE(h,m,f),y=JSON.stringify(h.id);return`${f} ${$} from ${y}`}));s.push([l.ss,l.se,d.join(";")])}catch(d){o.warn({context:{error:d},message:String(d),prefix:"plugin:debarrel"})}})),s},"getDebarrelModifications"),XE=$e((e,t,r,n)=>{if(r.length===0)return;const o=new Se(t,{filename:e});for(const[s,i,a]of r)o.update(s,i,a);return{code:o.toString(),map:n?o.generateMap({file:e}):void 0}},"applyModifications"),ZE=$e((e,t)=>{const r=new Map,n=new Map,o=$e(()=>{r.clear(),n.clear()},"purgeCaches"),s=e.include?Ze(e.include,[]):void 0;let i=!0;return{buildEnd:o,buildStart:o,async load(a){const l=r.get(a);if(l)return await l},name:"packem:debarrel",options(a){const{output:l}=a;let u;Array.isArray(l)?u=l[0]?.sourcemap:l&&(u=l.sourcemap),u===!1&&(i=!1)},async transform(a,l){if(l.includes("\0")||l.includes("?")||!md(l)||s&&!s(l))return;const u={fileCache:r,parseCache:n,resolve:this.resolve.bind(this)},c=await YE(u,l,a,e,t);return XE(l,a,c,i)},watchChange(a){r.delete(a),n.delete(a)}}},"debarrelPlugin");var ms,nc;function QE(){if(nc)return ms;nc=1;const e=Oe();return ms=(r,n,o,s,i)=>{typeof o=="string"&&(i=s,s=o,o=void 0);try{return new e(r instanceof e?r.version:r,o).inc(n,s,i).version}catch{return null}},ms}var hs,oc;function eS(){if(oc)return hs;oc=1;const e=Xr();return hs=(r,n)=>{const o=e(r,null,!0),s=e(n,null,!0),i=o.compare(s);if(i===0)return null;const a=i>0,l=a?o:s,u=a?s:o,c=!!l.prerelease.length;if(u.prerelease.length&&!c){if(!u.patch&&!u.minor)return"major";if(u.compareMain(l)===0)return u.minor&&!u.patch?"minor":"patch"}const p=c?"pre":"";return o.major!==s.major?p+"major":o.minor!==s.minor?p+"minor":o.patch!==s.patch?p+"patch":"prerelease"},hs}var gs,sc;function tS(){if(sc)return gs;sc=1;const e=Oe();return gs=(r,n)=>new e(r,n).major,gs}var ys,ic;function rS(){if(ic)return ys;ic=1;const e=Oe();return ys=(r,n)=>new e(r,n).minor,ys}var $s,ac;function nS(){if(ac)return $s;ac=1;const e=Oe();return $s=(r,n)=>new e(r,n).patch,$s}var bs,lc;function oS(){if(lc)return bs;lc=1;const e=Xr();return bs=(r,n)=>{const o=e(r,n);return o&&o.prerelease.length?o.prerelease:null},bs}var ws,cc;function qe(){if(cc)return ws;cc=1;const e=Oe();return ws=(r,n,o)=>new e(r,o).compare(new e(n,o)),ws}var vs,uc;function sS(){if(uc)return vs;uc=1;const e=qe();return vs=(r,n,o)=>e(n,r,o),vs}var xs,pc;function iS(){if(pc)return xs;pc=1;const e=qe();return xs=(r,n)=>e(r,n,!0),xs}var Es,fc;function Ia(){if(fc)return Es;fc=1;const e=Oe();return Es=(r,n,o)=>{const s=new e(r,o),i=new e(n,o);return s.compare(i)||s.compareBuild(i)},Es}var Ss,dc;function aS(){if(dc)return Ss;dc=1;const e=Ia();return Ss=(r,n)=>r.sort((o,s)=>e(o,s,n)),Ss}var ks,mc;function lS(){if(mc)return ks;mc=1;const e=Ia();return ks=(r,n)=>r.sort((o,s)=>e(s,o,n)),ks}var js,hc;function Bo(){if(hc)return js;hc=1;const e=qe();return js=(r,n,o)=>e(r,n,o)>0,js}var As,gc;function Wa(){if(gc)return As;gc=1;const e=qe();return As=(r,n,o)=>e(r,n,o)<0,As}var Os,yc;function wd(){if(yc)return Os;yc=1;const e=qe();return Os=(r,n,o)=>e(r,n,o)===0,Os}var Rs,$c;function vd(){if($c)return Rs;$c=1;const e=qe();return Rs=(r,n,o)=>e(r,n,o)!==0,Rs}var Cs,bc;function Ba(){if(bc)return Cs;bc=1;const e=qe();return Cs=(r,n,o)=>e(r,n,o)>=0,Cs}var Ts,wc;function Da(){if(wc)return Ts;wc=1;const e=qe();return Ts=(r,n,o)=>e(r,n,o)<=0,Ts}var Ns,vc;function xd(){if(vc)return Ns;vc=1;const e=wd(),t=vd(),r=Bo(),n=Ba(),o=Wa(),s=Da();return Ns=(a,l,u,c)=>{switch(l){case"===":return typeof a=="object"&&(a=a.version),typeof u=="object"&&(u=u.version),a===u;case"!==":return typeof a=="object"&&(a=a.version),typeof u=="object"&&(u=u.version),a!==u;case"":case"=":case"==":return e(a,u,c);case"!=":return t(a,u,c);case">":return r(a,u,c);case">=":return n(a,u,c);case"<":return o(a,u,c);case"<=":return s(a,u,c);default:throw new TypeError(`Invalid operator: ${l}`)}},Ns}var Ps,xc;function cS(){if(xc)return Ps;xc=1;const e=Oe(),t=Xr(),{safeRe:r,t:n}=mo();return Ps=(s,i)=>{if(s instanceof e)return s;if(typeof s=="number"&&(s=String(s)),typeof s!="string")return null;i=i||{};let a=null;if(!i.rtl)a=s.match(i.includePrerelease?r[n.COERCEFULL]:r[n.COERCE]);else{const d=i.includePrerelease?r[n.COERCERTLFULL]:r[n.COERCERTL];let m;for(;(m=d.exec(s))&&(!a||a.index+a[0].length!==s.length);)(!a||m.index+m[0].length!==a.index+a[0].length)&&(a=m),d.lastIndex=m.index+m[1].length+m[2].length;d.lastIndex=-1}if(a===null)return null;const l=a[2],u=a[3]||"0",c=a[4]||"0",p=i.includePrerelease&&a[5]?`-${a[5]}`:"",f=i.includePrerelease&&a[6]?`+${a[6]}`:"";return t(`${l}.${u}.${c}${p}${f}`,i)},Ps}var _s,Ec;function uS(){if(Ec)return _s;Ec=1;const e=Xr(),t=Ji(),r=Oe(),n=(a,l,u)=>{if(!t.RELEASE_TYPES.includes(l))return null;const c=o(a,u);return c&&s(c,l)},o=(a,l)=>{const u=a instanceof r?a.version:a;return e(u,l)},s=(a,l)=>{if(i(l))return a.version;switch(a.prerelease=[],l){case"major":a.minor=0,a.patch=0;break;case"minor":a.patch=0;break}return a.format()},i=a=>a.startsWith("pre");return _s=n,_s}var Ms,Sc;function pS(){if(Sc)return Ms;Sc=1;class e{constructor(){this.max=1e3,this.map=new Map}get(r){const n=this.map.get(r);if(n!==void 0)return this.map.delete(r),this.map.set(r,n),n}delete(r){return this.map.delete(r)}set(r,n){if(!this.delete(r)&&n!==void 0){if(this.map.size>=this.max){const o=this.map.keys().next().value;this.delete(o)}this.map.set(r,n)}return this}}return Ms=e,Ms}var Is,kc;function Je(){if(kc)return Is;kc=1;const e=/\s+/g;class t{constructor(O,F){if(F=o(F),O instanceof t)return O.loose===!!F.loose&&O.includePrerelease===!!F.includePrerelease?O:new t(O.raw,F);if(O instanceof s)return this.raw=O.value,this.set=[[O]],this.formatted=void 0,this;if(this.options=F,this.loose=!!F.loose,this.includePrerelease=!!F.includePrerelease,this.raw=O.trim().replace(e," "),this.set=this.raw.split("||").map(I=>this.parseRange(I.trim())).filter(I=>I.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const I=this.set[0];if(this.set=this.set.filter(_=>!y(_[0])),this.set.length===0)this.set=[I];else if(this.set.length>1){for(const _ of this.set)if(_.length===1&&g(_[0])){this.set=[_];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let O=0;O<this.set.length;O++){O>0&&(this.formatted+="||");const F=this.set[O];for(let I=0;I<F.length;I++)I>0&&(this.formatted+=" "),this.formatted+=F[I].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(O){O=O.replace($,"");const F=((this.options.includePrerelease&&m)|(this.options.loose&&h))+":"+O,I=n.get(F);if(I)return I;const _=this.options.loose,M=_?l[c.HYPHENRANGELOOSE]:l[c.HYPHENRANGE];O=O.replace(M,U(this.options.includePrerelease)),i("hyphen replace",O),O=O.replace(l[c.COMPARATORTRIM],p),i("comparator trim",O),O=O.replace(l[c.TILDETRIM],f),i("tilde trim",O),O=O.replace(l[c.CARETTRIM],d),i("caret trim",O);let H=O.split(" ").map(K=>b(K,this.options)).join(" ").split(/\s+/).map(K=>z(K,this.options));_&&(H=H.filter(K=>(i("loose invalid filter",K,this.options),!!K.match(l[c.COMPARATORLOOSE])))),i("range list",H);const V=new Map,B=H.map(K=>new s(K,this.options));for(const K of B){if(y(K))return[K];V.set(K.value,K)}V.size>1&&V.has("")&&V.delete("");const D=[...V.values()];return n.set(F,D),D}intersects(O,F){if(!(O instanceof t))throw new TypeError("a Range is required");return this.set.some(I=>w(I,F)&&O.set.some(_=>w(_,F)&&I.every(M=>_.every(H=>M.intersects(H,F)))))}test(O){if(!O)return!1;if(typeof O=="string")try{O=new a(O,this.options)}catch{return!1}for(let F=0;F<this.set.length;F++)if(J(this.set[F],O,this.options))return!0;return!1}}Is=t;const r=pS(),n=new r,o=ep(),s=Do(),i=tp(),a=Oe(),{safeRe:l,src:u,t:c,comparatorTrimReplace:p,tildeTrimReplace:f,caretTrimReplace:d}=mo(),{FLAG_INCLUDE_PRERELEASE:m,FLAG_LOOSE:h}=Ji(),$=new RegExp(u[c.BUILD],"g"),y=N=>N.value==="<0.0.0-0",g=N=>N.value==="",w=(N,O)=>{let F=!0;const I=N.slice();let _=I.pop();for(;F&&I.length;)F=I.every(M=>_.intersects(M,O)),_=I.pop();return F},b=(N,O)=>(N=N.replace(l[c.BUILD],""),i("comp",N,O),N=E(N,O),i("caret",N),N=S(N,O),i("tildes",N),N=k(N,O),i("xrange",N),N=P(N,O),i("stars",N),N),v=N=>!N||N.toLowerCase()==="x"||N==="*",S=(N,O)=>N.trim().split(/\s+/).map(F=>x(F,O)).join(" "),x=(N,O)=>{const F=O.loose?l[c.TILDELOOSE]:l[c.TILDE];return N.replace(F,(I,_,M,H,V)=>{i("tilde",N,I,_,M,H,V);let B;return v(_)?B="":v(M)?B=`>=${_}.0.0 <${+_+1}.0.0-0`:v(H)?B=`>=${_}.${M}.0 <${_}.${+M+1}.0-0`:V?(i("replaceTilde pr",V),B=`>=${_}.${M}.${H}-${V} <${_}.${+M+1}.0-0`):B=`>=${_}.${M}.${H} <${_}.${+M+1}.0-0`,i("tilde return",B),B})},E=(N,O)=>N.trim().split(/\s+/).map(F=>j(F,O)).join(" "),j=(N,O)=>{i("caret",N,O);const F=O.loose?l[c.CARETLOOSE]:l[c.CARET],I=O.includePrerelease?"-0":"";return N.replace(F,(_,M,H,V,B)=>{i("caret",N,_,M,H,V,B);let D;return v(M)?D="":v(H)?D=`>=${M}.0.0${I} <${+M+1}.0.0-0`:v(V)?M==="0"?D=`>=${M}.${H}.0${I} <${M}.${+H+1}.0-0`:D=`>=${M}.${H}.0${I} <${+M+1}.0.0-0`:B?(i("replaceCaret pr",B),M==="0"?H==="0"?D=`>=${M}.${H}.${V}-${B} <${M}.${H}.${+V+1}-0`:D=`>=${M}.${H}.${V}-${B} <${M}.${+H+1}.0-0`:D=`>=${M}.${H}.${V}-${B} <${+M+1}.0.0-0`):(i("no pr"),M==="0"?H==="0"?D=`>=${M}.${H}.${V}${I} <${M}.${H}.${+V+1}-0`:D=`>=${M}.${H}.${V}${I} <${M}.${+H+1}.0-0`:D=`>=${M}.${H}.${V} <${+M+1}.0.0-0`),i("caret return",D),D})},k=(N,O)=>(i("replaceXRanges",N,O),N.split(/\s+/).map(F=>R(F,O)).join(" ")),R=(N,O)=>{N=N.trim();const F=O.loose?l[c.XRANGELOOSE]:l[c.XRANGE];return N.replace(F,(I,_,M,H,V,B)=>{i("xRange",N,I,_,M,H,V,B);const D=v(M),K=D||v(H),q=K||v(V),A=q;return _==="="&&A&&(_=""),B=O.includePrerelease?"-0":"",D?_===">"||_==="<"?I="<0.0.0-0":I="*":_&&A?(K&&(H=0),V=0,_===">"?(_=">=",K?(M=+M+1,H=0,V=0):(H=+H+1,V=0)):_==="<="&&(_="<",K?M=+M+1:H=+H+1),_==="<"&&(B="-0"),I=`${_+M}.${H}.${V}${B}`):K?I=`>=${M}.0.0${B} <${+M+1}.0.0-0`:q&&(I=`>=${M}.${H}.0${B} <${M}.${+H+1}.0-0`),i("xRange return",I),I})},P=(N,O)=>(i("replaceStars",N,O),N.trim().replace(l[c.STAR],"")),z=(N,O)=>(i("replaceGTE0",N,O),N.trim().replace(l[O.includePrerelease?c.GTE0PRE:c.GTE0],"")),U=N=>(O,F,I,_,M,H,V,B,D,K,q,A)=>(v(I)?F="":v(_)?F=`>=${I}.0.0${N?"-0":""}`:v(M)?F=`>=${I}.${_}.0${N?"-0":""}`:H?F=`>=${F}`:F=`>=${F}${N?"-0":""}`,v(D)?B="":v(K)?B=`<${+D+1}.0.0-0`:v(q)?B=`<${D}.${+K+1}.0-0`:A?B=`<=${D}.${K}.${q}-${A}`:N?B=`<${D}.${K}.${+q+1}-0`:B=`<=${B}`,`${F} ${B}`.trim()),J=(N,O,F)=>{for(let I=0;I<N.length;I++)if(!N[I].test(O))return!1;if(O.prerelease.length&&!F.includePrerelease){for(let I=0;I<N.length;I++)if(i(N[I].semver),N[I].semver!==s.ANY&&N[I].semver.prerelease.length>0){const _=N[I].semver;if(_.major===O.major&&_.minor===O.minor&&_.patch===O.patch)return!0}return!1}return!0};return Is}var Ws,jc;function Do(){if(jc)return Ws;jc=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(c,p){if(p=r(p),c instanceof t){if(c.loose===!!p.loose)return c;c=c.value}c=c.trim().split(/\s+/).join(" "),i("comparator",c,p),this.options=p,this.loose=!!p.loose,this.parse(c),this.semver===e?this.value="":this.value=this.operator+this.semver.version,i("comp",this)}parse(c){const p=this.options.loose?n[o.COMPARATORLOOSE]:n[o.COMPARATOR],f=c.match(p);if(!f)throw new TypeError(`Invalid comparator: ${c}`);this.operator=f[1]!==void 0?f[1]:"",this.operator==="="&&(this.operator=""),f[2]?this.semver=new a(f[2],this.options.loose):this.semver=e}toString(){return this.value}test(c){if(i("Comparator.test",c,this.options.loose),this.semver===e||c===e)return!0;if(typeof c=="string")try{c=new a(c,this.options)}catch{return!1}return s(c,this.operator,this.semver,this.options)}intersects(c,p){if(!(c instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new l(c.value,p).test(this.value):c.operator===""?c.value===""?!0:new l(this.value,p).test(c.semver):(p=r(p),p.includePrerelease&&(this.value==="<0.0.0-0"||c.value==="<0.0.0-0")||!p.includePrerelease&&(this.value.startsWith("<0.0.0")||c.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&c.operator.startsWith(">")||this.operator.startsWith("<")&&c.operator.startsWith("<")||this.semver.version===c.semver.version&&this.operator.includes("=")&&c.operator.includes("=")||s(this.semver,"<",c.semver,p)&&this.operator.startsWith(">")&&c.operator.startsWith("<")||s(this.semver,">",c.semver,p)&&this.operator.startsWith("<")&&c.operator.startsWith(">")))}}Ws=t;const r=ep(),{safeRe:n,t:o}=mo(),s=xd(),i=tp(),a=Oe(),l=Je();return Ws}var Bs,Ac;function an(){if(Ac)return Bs;Ac=1;const e=Je();return Bs=(r,n,o)=>{try{n=new e(n,o)}catch{return!1}return n.test(r)},Bs}var Ds,Oc;function fS(){if(Oc)return Ds;Oc=1;const e=Je();return Ds=(r,n)=>new e(r,n).set.map(o=>o.map(s=>s.value).join(" ").trim().split(" ")),Ds}var Ls,Rc;function dS(){if(Rc)return Ls;Rc=1;const e=Oe(),t=Je();return Ls=(n,o,s)=>{let i=null,a=null,l=null;try{l=new t(o,s)}catch{return null}return n.forEach(u=>{l.test(u)&&(!i||a.compare(u)===-1)&&(i=u,a=new e(i,s))}),i},Ls}var Fs,Cc;function mS(){if(Cc)return Fs;Cc=1;const e=Oe(),t=Je();return Fs=(n,o,s)=>{let i=null,a=null,l=null;try{l=new t(o,s)}catch{return null}return n.forEach(u=>{l.test(u)&&(!i||a.compare(u)===1)&&(i=u,a=new e(i,s))}),i},Fs}var Hs,Tc;function hS(){if(Tc)return Hs;Tc=1;const e=Oe(),t=Je(),r=Bo();return Hs=(o,s)=>{o=new t(o,s);let i=new e("0.0.0");if(o.test(i)||(i=new e("0.0.0-0"),o.test(i)))return i;i=null;for(let a=0;a<o.set.length;++a){const l=o.set[a];let u=null;l.forEach(c=>{const p=new e(c.semver.version);switch(c.operator){case">":p.prerelease.length===0?p.patch++:p.prerelease.push(0),p.raw=p.format();case"":case">=":(!u||r(p,u))&&(u=p);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${c.operator}`)}}),u&&(!i||r(i,u))&&(i=u)}return i&&o.test(i)?i:null},Hs}var qs,Nc;function gS(){if(Nc)return qs;Nc=1;const e=Je();return qs=(r,n)=>{try{return new e(r,n).range||"*"}catch{return null}},qs}var Js,Pc;function La(){if(Pc)return Js;Pc=1;const e=Oe(),t=Do(),{ANY:r}=t,n=Je(),o=an(),s=Bo(),i=Wa(),a=Da(),l=Ba();return Js=(c,p,f,d)=>{c=new e(c,d),p=new n(p,d);let m,h,$,y,g;switch(f){case">":m=s,h=a,$=i,y=">",g=">=";break;case"<":m=i,h=l,$=s,y="<",g="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(o(c,p,d))return!1;for(let w=0;w<p.set.length;++w){const b=p.set[w];let v=null,S=null;if(b.forEach(x=>{x.semver===r&&(x=new t(">=0.0.0")),v=v||x,S=S||x,m(x.semver,v.semver,d)?v=x:$(x.semver,S.semver,d)&&(S=x)}),v.operator===y||v.operator===g||(!S.operator||S.operator===y)&&h(c,S.semver)||S.operator===g&&$(c,S.semver))return!1}return!0},Js}var zs,_c;function yS(){if(_c)return zs;_c=1;const e=La();return zs=(r,n,o)=>e(r,n,">",o),zs}var Us,Mc;function $S(){if(Mc)return Us;Mc=1;const e=La();return Us=(r,n,o)=>e(r,n,"<",o),Us}var Gs,Ic;function bS(){if(Ic)return Gs;Ic=1;const e=Je();return Gs=(r,n,o)=>(r=new e(r,o),n=new e(n,o),r.intersects(n,o)),Gs}var Vs,Wc;function wS(){if(Wc)return Vs;Wc=1;const e=an(),t=qe();return Vs=(r,n,o)=>{const s=[];let i=null,a=null;const l=r.sort((f,d)=>t(f,d,o));for(const f of l)e(f,n,o)?(a=f,i||(i=f)):(a&&s.push([i,a]),a=null,i=null);i&&s.push([i,null]);const u=[];for(const[f,d]of s)f===d?u.push(f):!d&&f===l[0]?u.push("*"):d?f===l[0]?u.push(`<=${d}`):u.push(`${f} - ${d}`):u.push(`>=${f}`);const c=u.join(" || "),p=typeof n.raw=="string"?n.raw:String(n);return c.length<p.length?c:n},Vs}var Ks,Bc;function vS(){if(Bc)return Ks;Bc=1;const e=Je(),t=Do(),{ANY:r}=t,n=an(),o=qe(),s=(p,f,d={})=>{if(p===f)return!0;p=new e(p,d),f=new e(f,d);let m=!1;e:for(const h of p.set){for(const $ of f.set){const y=l(h,$,d);if(m=m||y!==null,y)continue e}if(m)return!1}return!0},i=[new t(">=0.0.0-0")],a=[new t(">=0.0.0")],l=(p,f,d)=>{if(p===f)return!0;if(p.length===1&&p[0].semver===r){if(f.length===1&&f[0].semver===r)return!0;d.includePrerelease?p=i:p=a}if(f.length===1&&f[0].semver===r){if(d.includePrerelease)return!0;f=a}const m=new Set;let h,$;for(const E of p)E.operator===">"||E.operator===">="?h=u(h,E,d):E.operator==="<"||E.operator==="<="?$=c($,E,d):m.add(E.semver);if(m.size>1)return null;let y;if(h&&$&&(y=o(h.semver,$.semver,d),y>0||y===0&&(h.operator!==">="||$.operator!=="<=")))return null;for(const E of m){if(h&&!n(E,String(h),d)||$&&!n(E,String($),d))return null;for(const j of f)if(!n(E,String(j),d))return!1;return!0}let g,w,b,v,S=$&&!d.includePrerelease&&$.semver.prerelease.length?$.semver:!1,x=h&&!d.includePrerelease&&h.semver.prerelease.length?h.semver:!1;S&&S.prerelease.length===1&&$.operator==="<"&&S.prerelease[0]===0&&(S=!1);for(const E of f){if(v=v||E.operator===">"||E.operator===">=",b=b||E.operator==="<"||E.operator==="<=",h){if(x&&E.semver.prerelease&&E.semver.prerelease.length&&E.semver.major===x.major&&E.semver.minor===x.minor&&E.semver.patch===x.patch&&(x=!1),E.operator===">"||E.operator===">="){if(g=u(h,E,d),g===E&&g!==h)return!1}else if(h.operator===">="&&!E.test(h.semver))return!1}if($){if(S&&E.semver.prerelease&&E.semver.prerelease.length&&E.semver.major===S.major&&E.semver.minor===S.minor&&E.semver.patch===S.patch&&(S=!1),E.operator==="<"||E.operator==="<="){if(w=c($,E,d),w===E&&w!==$)return!1}else if($.operator==="<="&&!E.test($.semver))return!1}if(!E.operator&&($||h)&&y!==0)return!1}return!(h&&b&&!$&&y!==0||$&&v&&!h&&y!==0||x||S)},u=(p,f,d)=>{if(!p)return f;const m=o(p.semver,f.semver,d);return m>0?p:m<0||f.operator===">"&&p.operator===">="?f:p},c=(p,f,d)=>{if(!p)return f;const m=o(p.semver,f.semver,d);return m<0?p:m>0||f.operator==="<"&&p.operator==="<="?f:p};return Ks=s,Ks}var Ys,Dc;function xS(){if(Dc)return Ys;Dc=1;const e=mo(),t=Ji(),r=Oe(),n=Hm(),o=Xr(),s=rp(),i=qm(),a=QE(),l=eS(),u=tS(),c=rS(),p=nS(),f=oS(),d=qe(),m=sS(),h=iS(),$=Ia(),y=aS(),g=lS(),w=Bo(),b=Wa(),v=wd(),S=vd(),x=Ba(),E=Da(),j=xd(),k=cS(),R=uS(),P=Do(),z=Je(),U=an(),J=fS(),N=dS(),O=mS(),F=hS(),I=gS(),_=La(),M=yS(),H=$S(),V=bS(),B=wS(),D=vS();return Ys={parse:o,valid:s,clean:i,inc:a,diff:l,major:u,minor:c,patch:p,prerelease:f,compare:d,rcompare:m,compareLoose:h,compareBuild:$,sort:y,rsort:g,gt:w,lt:b,eq:v,neq:S,gte:x,lte:E,cmp:j,coerce:k,truncate:R,Comparator:P,Range:z,satisfies:U,toComparators:J,maxSatisfying:N,minSatisfying:O,minVersion:F,validRange:I,outside:_,gtr:M,ltr:H,intersects:V,simplifyRange:B,subset:D,SemVer:r,re:e.re,src:e.src,tokens:e.t,SEMVER_SPEC_VERSION:t.SEMVER_SPEC_VERSION,RELEASE_TYPES:t.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers},Ys}var Le=xS(),ES=Object.defineProperty,Ed=(e,t)=>ES(e,"name",{value:t,configurable:!0}),SS=Object.defineProperty,Sd=Ed((e,t)=>SS(e,"name",{value:t,configurable:!0}),"r");const oo=/.*\/node_modules\/(?:@[^/]+\/)?[^/]+/,Ii=Vi(async e=>{const t=G(e,"package.json");try{const r=await Jm(t);return{directory:Z(t),name:r.name,version:r.version}}catch{return}})(),kd=Sd(async e=>{const t=Hr(e),r=oo.exec(t);if(!r)return;const n=await Ii(r[0]);if(n)return n;const o=t.lastIndexOf("node_modules");if(o<=0)return;const s=oo.exec(t.slice(0,o-1));if(s)return Ii(s[0])},"getPackageInfo"),kS=Sd(()=>{Ii.destroy()},"destroyPackageInfoCache");var jS=Object.defineProperty,gt=Ed((e,t)=>jS(e,"name",{value:t,configurable:!0}),"d");const Lc=Vi(async(e,t)=>{const r=Hr(e);if(oo.test(r)){const n=await kd(r);if(n)return`${n.name}@${n.version}`}return r.replace(`${Hr(t)}/`,"")})(),AS=gt(e=>new Set([...e].toSorted((t,r)=>t.localeCompare(r))),"sortImporters"),OS=gt(e=>new Map([...e.entries()].toSorted((t,r)=>t[0].localeCompare(r[0])).map(([t,r])=>[t,AS(r)])),"sortDirectoryMap"),RS=gt(e=>new Map([...e.entries()].toSorted((t,r)=>Le.compare(t[0],r[0])).map(([t,r])=>[t,OS(r)])),"sortVersionMap"),CS=gt(e=>new Map([...e.entries()].toSorted((t,r)=>t[0].localeCompare(r[0])).map(([t,r])=>[t,RS(r)])),"sortPackagesInfo"),TS=gt((e,t,r,n,o)=>{let s=e.get(t);s||(s=new Map,e.set(t,s));let i=s.get(r);i||(i=new Map,s.set(r,i));let a=i.get(n);a||(a=new Set,i.set(n,a)),a.add(o)},"addImporter"),NS=gt((e,t,r,n)=>{const o=Math.max(0,...t.map(a=>a.length)),s=gt((a,l)=>a.filter(u=>u!==`${e}@${l}`).map(u=>qi(u)).join(", "),"colorizeImporters"),i=[`
|
|
109
|
+
${Tn(e)}:`];for(const a of t){const l=r.get(e)?.get(a);if(!l)continue;const u=Ae(Yt(a.padEnd(o," ")));if(l.size===1){const[c]=[...l.values()],p=c?[...c]:[];i.push(` - ${u} imported by ${s(p,a)}`);continue}i.push(` - ${u}`);for(const[c,p]of l){const f=Ae(ne(c.replace(Hr(n),".")));i.push(` - ${f} imported by ${s([...p],a)}`)}}return i},"formatDuplicatedPackage"),PS=gt((e,t,{customErrorMessage:r,deep:n=!0,ignore:o={},throwErrorWhenDuplicated:s=!1}={})=>({async buildEnd(){const i=new Map;await Promise.all([...this.getModuleIds()].map(async f=>{const d=this.getModuleInfo(f);if(d===null||d.isExternal||d.isIncluded===!1)return;const m=await kd(f);if(!m)return;const{directory:h,name:$,version:y}=m;for(const g of[...d.importers,...d.dynamicImporters]){const w=Hr(g);!n&&oo.test(w)||TS(i,$,y,h,await Lc(w,t))}})),kS(),Lc.destroy();const a=CS(i),l={},u=new Map;for(const[f,d]of a.entries()){const m=[...d.values()];if(m.length>1||m.length===1&&(m[0]?.size??0)>1){l[f]=[...d.keys()];for(const h of d.keys()){const $=o[f];if(!($!==void 0&&($.includes("*")||$.includes(h)))){const y=u.get(f)??[];y.push(h),u.set(f,y)}}}}if(u.size===0)return;const c=[`packages ${[...u.keys()].map(f=>Tn(f)).join(", ")} is bundled multiple times!`];for(const[f,d]of u)c.push(...NS(f,d,a,t));const p=r?r(a):c.join(`
|
|
110
|
+
`);s&&(e.error(p),e.info(`Fix this error by eliminating the duplicated dependencies or adjusting the ${Tn("ignore")} option.`),e.info(`You can copy the following duplicated dependencies as the value of the ${Tn("ignore")} option:`),e.info(`
|
|
111
|
+
${JSON.stringify(l,void 0,4)}
|
|
112
|
+
`),this.error("Duplicated dependencies detected.")),e.warn(p)},name:"packem:detect-duplicated"}),"detectDuplicatedPlugin");var _S=Object.defineProperty,MS=(e,t)=>_S(e,"name",{value:t,configurable:!0}),IS=Object.defineProperty,Lo=MS((e,t)=>IS(e,"name",{value:t,configurable:!0}),"t");const WS=/(?:^|[^.\w'"`])require(\.resolve)?\(\s*([\w'"`])/,BS=Lo((e,t)=>{if(Nm.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return;let r=!1,n=!1,o=!1;if(e.includes("__filename")&&(r=!0),e.includes("__dirname")&&(n=!0),WS.test(e)&&(o=!0),!r&&!n&&!o)return;const s=go(e).pop(),i=s?s.end:0,a=new Se(e);return a.appendRight(i,t(r,n,o)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),DS=Lo((e,t,r)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
|
|
113
|
+
`),t&&(n+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
|
|
114
|
+
`),r&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
115
|
+
`),(e||t)&&(n+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
116
|
+
`),t&&(n+=`const __dirname = __cjs_path__.dirname(__filename);
|
|
117
|
+
`),r&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
|
|
118
|
+
`),n},"generateCJSShim"),LS=Lo((e,t,r)=>{let n="";return r&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
119
|
+
`),e&&(n+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
|
|
120
|
+
`),t&&(n+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
|
|
121
|
+
`),r&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
|
|
122
|
+
`),n},"generateCJSShimNode20_11"),FS=Lo((e,t)=>{const r=Ze(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,o,s){if(s.format==="es"&&r(o.fileName)){let i=DS;if(e.engines?.node){const a=Le.minVersion(e.engines.node);a&&(a.major>20||a.major===20&&a.minor>=11)&&(i=LS)}return BS(n,i)}}}},"esmShimCjsSyntaxPlugin");var HS=Object.defineProperty,qS=(e,t)=>HS(e,"name",{value:t,configurable:!0}),JS=Object.defineProperty,Fc=qS((e,t)=>JS(e,"name",{value:t,configurable:!0}),"p");const Xs="\0packem-import-attribute/",zS=/(import[\w$*{},\s]*?from\s*["'])([^"']+)(["'])\s*with\s*\{\s*type\s*:\s*["'](text|bytes)["']\s*\}/g,US=/(\bimport\s*\(\s*["'])([^"']+)["']\s*,\s*\{\s*with\s*:\s*\{\s*type\s*:\s*["'](text|bytes)["']\s*\}\s*\}\s*\)/g,GS=/\.[mc]?[jt]sx?$/,VS=Fc(()=>{const e=new Map;let t=0;const r=Fc(n=>{const o=`${Xs}${String(t)}`;return t+=1,e.set(o,n),o},"allocateId");return{buildStart(){e.clear(),t=0},async load(n){const o=e.get(n);if(!o)return null;const{importer:s,source:i,type:a}=o;if(!i.startsWith("./")&&!i.startsWith("../")&&!i.startsWith("/"))return null;const l=i.startsWith("/")?i:Nh(wi(s),i);if(this.addWatchFile(l),a==="text"){const u=await Jn(l,"utf8");return`export default ${JSON.stringify(u)}`}return`export default new Uint8Array([${(await Jn(l)).join(",")}])`},name:"packem:import-attributes",resolveId(n,o){return n.startsWith(Xs)&&e.has(n)?n:null},transform(n,o){const s=o.split("?")[0]??o;if(s.startsWith(Xs)||!GS.test(s)||!n.includes("with")||!n.includes("type")||!n.includes("text")&&!n.includes("bytes"))return null;const i=n.replaceAll(zS,(a,l,u,c,p)=>{const f=r({importer:o,source:u,type:p});return`${l}${f}${c}`}).replaceAll(US,(a,l,u,c)=>{const p=r({importer:o,source:u,type:c});return`${l}${p}")`});return i===n?null:{code:i,map:null}}}},"importAttributesPlugin");var KS=Object.defineProperty,ln=(e,t)=>KS(e,"name",{value:t,configurable:!0});let Dt;const Gt={getHeadTemplatePart(e){const t=e.getFullText(Dt),r=t.indexOf("`")+1,n=it.isTemplateHead(e)?-2:-1;return{end:e.end+n,start:e.pos+r,text:t.slice(r,t.length+n)}},getMiddleTailTemplatePart(e){const t=e.getText(Dt),r=it.isTemplateMiddle(e)?2:1;return{end:e.end-r,start:e.getStart(Dt)+1,text:t.slice(1,t.length-r)}},getRootNode(e,t=""){return it.createSourceFile(t,e,it.ScriptTarget.ESNext)},getTaggedTemplateTemplate(e){return e.template},getTagText(e){return e.tag.getText(Dt)},getTemplateParts(e){return it.isNoSubstitutionTemplateLiteral(e)?[Gt.getHeadTemplatePart(e)]:[Gt.getHeadTemplatePart(e.head),...e.templateSpans.map(t=>Gt.getMiddleTailTemplatePart(t.literal))]},isTaggedTemplate:it.isTaggedTemplateExpression,isTemplate:it.isTemplateLiteral,walkChildNodes(e,t){t(e),it.forEachChild(e,r=>{Gt.walkChildNodes(r,t)})},walkNodes(e,t){Dt=e,Gt.walkChildNodes(e,t),Dt=void 0}};var YS=Object.defineProperty,XS=ln((e,t)=>YS(e,"name",{value:t,configurable:!0}),"i");const ZS=XS((e,t={})=>{const r={...Gt,...t.strategy},n=[],o=[];return r.walkNodes(r.getRootNode(e,t.fileName),s=>{if(r.isTaggedTemplate(s)){const i=r.getTaggedTemplateTemplate(s);o.push(i),n.push({parts:r.getTemplateParts(i),tag:r.getTagText(s)})}else r.isTemplate(s)&&!o.includes(s)&&n.push({parts:r.getTemplateParts(s)})}),n},"parseLiterals");var QS=Object.defineProperty,Fa=ln((e,t)=>QS(e,"name",{value:t,configurable:!0}),"c");const Qt={One:"1",Two:"2",Zero:"0"},ek=Fa(e=>{const t={[Qt.One]:{tidySelectors:!1,transform:void 0},[Qt.Two]:{tidySelectors:!1,transform:void 0},[Qt.Zero]:{}};if(e===void 0)return t;if(typeof e=="number"){const r=e.toString();return{...t,[r]:{...t[r]}}}return e},"optimizationLevelFrom"),tk=/(:[^()\s]+\(([^()]*)\))\s*\{/g,rk=/\s/g,nk=/\s/,Hc=Fa((e,t)=>{let r=t;const n=[...e.matchAll(tk)];for(const o of n){const s=o[1],i=o[2];if(!s||!i||!nk.test(i))continue;const a=i.replaceAll(rk,""),l=s.replace(i,a),u=r.indexOf(l);if(u===-1)continue;const c=u+l.length;r=r.slice(0,Math.max(0,u))+s+r.slice(Math.max(0,c))}return r},"fixCleanCssTidySelectors"),ok={},sk={caseSensitive:!0,collapseWhitespace:!0,decodeEntities:!0,minifyCSS:ok,minifyJS:!0,removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,useShortDoctype:!0},qc=Fa((e={})=>{const t=ek(e.level),r=typeof e.level=="object"&&typeof e.level[1]?.transform=="function"?e.level[1].transform:!1;return t[Qt.One].transform=(n,o)=>o.startsWith("@TEMPLATE_EXPRESSION")&&!o.endsWith(";")?`${o};`:r?r(n,o):o,{...e,level:t}},"adjustMinifyCSSOptions"),ik={combineHTMLStrings(e,t){return e.map(r=>r.text).join(t)},getPlaceholder(e){let t="@TEMPLATE_EXPRESSION";for(;e.some(r=>r.text.includes(t+"();"));)t+="_";return t+"();"},minifyCSS(e,t={}){const r=qc(t),n=new Bh(r).minify(e);if(n.errors.length>0)throw new Error(n.errors.join(`
|
|
123
|
+
|
|
124
|
+
`));return r.level?.[Qt.One]?.tidySelectors&&(n.styles=Hc(e,n.styles)),n.styles},async minifyHTML(e,t={}){let r;t.minifyCSS?r=t.minifyCSS!==!0&&typeof t.minifyCSS!="function"?{...t.minifyCSS}:{}:r=!1;let n=!1;r&&(n=qc(r));let o=await Dh(e,{...t,minifyCSS:n});if(t.collapseWhitespace){const s=[...o.matchAll(/<svg/g)].toReversed();for(const i of s){const a=i.index,l=o.indexOf("</svg",a);if(l===-1)continue;const u=o.slice(0,Math.max(0,a));let c=o.slice(a,l);const p=o.slice(Math.max(0,l));c=c.replaceAll(/\r?\n/g,""),o=u+c+p}}return(n?n.level:void 0)?.[Qt.One]?.tidySelectors&&(o=Hc(e,o)),o},splitHTMLByPlaceholder(e,t){const r=e.split(t);if(t.endsWith(";")){const n=t.slice(0,Math.max(0,t.length-1));for(let o=r.length-1;o>=0;o-=1){const s=r[o];s!==void 0&&r.splice(o,1,...s.split(n))}}return r}};var ak=Object.defineProperty,Fo=ln((e,t)=>ak(e,"name",{value:t,configurable:!0}),"f");const lk=Fo((e,t)=>e.generateMap({file:`${t}.map`,hires:!0,source:t}),"defaultGenerateSourceMap"),ck=Fo(e=>{const t=e.tag?.toLowerCase();return!!t&&(t.includes("html")||t.includes("svg"))},"defaultShouldMinify"),uk=Fo(e=>!!e.tag&&e.tag.toLowerCase().includes("css"),"defaultShouldMinifyCSS"),pk={ensureHTMLPartsValid(e,t){if(e.length!==t.length)throw new Error("splitHTMLByPlaceholder() must return same number of strings as template parts")},ensurePlaceholderValid(e){if(typeof e!="string"||e.length===0)throw new Error("getPlaceholder() must return a non-empty string")}};async function Ha(e,t={}){t.minifyOptions={...sk,...t.minifyOptions},t.MagicString??=Se,t.parseLiterals??=ZS,t.shouldMinify??=ck,t.shouldMinifyCSS??=uk,t.parseLiteralsOptions={fileName:t.fileName,...t.parseLiteralsOptions};const r=t.parseLiterals(e,t.parseLiteralsOptions),n=t.strategy??ik,{shouldMinify:o,shouldMinifyCSS:s}=t;let i;t.validate!==!1&&(i=t.validate??pk);const a=new t.MagicString(e);for(const c of r){const p=o(c),f=!!n.minifyCSS&&s(c);if(p||f){const d=n.getPlaceholder(c.parts);i&&i.ensurePlaceholderValid(d);const m=n.combineHTMLStrings(c.parts,d);let h;if(f){const y=t.minifyOptions?.minifyCSS;if(typeof y=="function"){const g=y(m);h=typeof g=="string"?g:await g}else if(y===!1)h=m;else{const g=typeof y=="object"&&y!==null?y:void 0,w=n.minifyCSS;if(!w)throw new Error("Strategy does not implement minifyCSS but minifyCSS was requested");const b=w(m,g);h=typeof b=="string"?b:await b}}else{const y=n.minifyHTML(m,t.minifyOptions);h=typeof y=="string"?y:await y}const $=n.splitHTMLByPlaceholder(h,d);i&&i.ensureHTMLPartsValid(c.parts,$),c.parts.forEach((y,g)=>{y.start<y.end&&$[g]!==void 0&&a.overwrite(y.start,y.end,$[g])})}}const l=a.toString();if(e===l)return;let u;return t.generateSourceMap!==!1&&(u=(t.generateSourceMap??lk)(a,t.fileName??"")),{code:l,map:u}}ln(Ha,"minifyHTMLLiterals");Fo(Ha,"minifyHTMLLiterals");var fk=Object.defineProperty,dk=ln((e,t)=>fk(e,"name",{value:t,configurable:!0}),"o");const mk=dk(({exclude:e,failOnError:t=!1,include:r,logger:n,minifyHTMLLiterals:o,options:s})=>{o??=Ha;const i=Ze(r,e),a=s??{};return{name:"packem:minify-html-literals",async transform(l,u){if(!(!l.includes("html`")&&!l.includes("css`"))&&i(u))try{return await o(l,{...a,fileName:u})}catch(c){const p=c instanceof Error?c.message:c;t?this.error(p):n.warn({message:p,prefix:"plugin:minify-html-literals"})}}}},"minifyHTMLLiteralsPlugin");var hk=Object.defineProperty,gk=(e,t)=>hk(e,"name",{value:t,configurable:!0}),yk=Object.defineProperty,Jc=gk((e,t)=>yk(e,"name",{value:t,configurable:!0}),"f");const $k=/\.node$/,Zs="\0packem-natives/",bk=Jc((e={})=>{const{nativesDirectory:t="natives"}=e,r=new Map;let n=0;return{buildStart(){r.clear(),n=0},generateBundle:Jc(async o=>{if(r.size===0)return;let s;if(o.dir?s=o.dir:o.file&&(s=Z(o.file)),!s)throw new Error("Output directory not detected. Please ensure Rollup output options are configured.");const i=G(s,t);await yi(i);const a=new Set,l=[];for(const{outputName:u,sourcePath:c}of r.values())a.has(c)||(a.add(c),l.push(Ah(c,G(i,u))));await Promise.all(l)},"generateBundle"),load(o){const s=r.get(o);if(!s)return;const{outputName:i}=s;return`export default require("${`./${t}/${i}`.replaceAll("\\","/")}");`},name:"native-modules",resolveId:{filter:{id:$k},async handler(o,s){if(o.startsWith(Zs))return;if(s?.startsWith(Zs))return{external:!0,id:o};const i=s?X(Z(s),o):X(o);if(!await Xt(i)){this.warn(`Native module not found: ${i}`);return}for(const[f,d]of r)if(d.sourcePath===i)return f;const a=Fe(i);let l=a,u=1;const c=new Set(Array.from(r.values(),f=>f.outputName));for(;c.has(l);){const f=tr(a);l=`${Fe(a,f)}_${String(u)}${f}`,u+=1}const p=`${Zs}${String(n)}`;return n+=1,r.set(p,{outputName:l,sourcePath:i}),p}}}},"nativeModulesPlugin");var wk=Object.defineProperty,vk=(e,t)=>wk(e,"name",{value:t,configurable:!0}),xk=Object.defineProperty,Ek=vk((e,t)=>xk(e,"name",{value:t,configurable:!0}),"a");const Sk=Ek(e=>{const t=Ze(e.include,e.exclude);return{async load(r){if(r.includes("?raw")){const n=r.split("?")[0];try{const o=await Nt(n);return process.platform==="win32"?o.replaceAll(`\r
|
|
125
|
+
`,`
|
|
126
|
+
`):o}catch(o){this.error(`Failed to read file: ${n}: ${o instanceof Error?o.message:String(o)}`)}}return null},name:"packem:raw",transform(r,n){const o=n.includes("?raw"),s=o?n.split("?")[0]:n;if(t(s)||o){const i=process.platform==="win32"?r.replaceAll(`\r
|
|
127
|
+
`,`
|
|
128
|
+
`):r;return{code:`const data = ${JSON.stringify(i)};
|
|
129
|
+
export default data;`,map:null}}return null}}},"rawPlugin");var kk=Object.defineProperty,jd=(e,t)=>kk(e,"name",{value:t,configurable:!0}),jk=Object.defineProperty,Ad=jd((e,t)=>jk(e,"name",{value:t,configurable:!0}),"a");let zc=!1;const Od=new Map,Ak=Ad(()=>{Od.clear()},"clearPureCjsCache"),Ok=Ad(async(e,t,r)=>{if(zc||(await gp(),zc=!0),e.startsWith("node:"))return!1;if(e.endsWith(".cjs"))return!0;if(e.endsWith(".js")||!e.includes("/")&&!e.startsWith(".")){let n;if(r)try{n=(await r(e,t))?.id}catch{}if(!n&&t&&!t.includes("!~{"))try{n=Me(t).resolve(e)}catch{}if(n){try{const{packageJson:o}=await zm(n,{cache:Od});if(o.type==="module")return!1;if(o.type==="commonjs")return!0}catch{}try{const o=await Nt(n,{encoding:"utf8"});try{return Lh(o,n),!0}catch{}}catch{}}}return!1},"isPureCJS");var Rk=Object.defineProperty,dr=jd((e,t)=>Rk(e,"name",{value:t,configurable:!0}),"d");const qa="__cjs_require",Ck='import { createRequire as __cjs_createRequire } from "node:module";',Tk=`const ${qa} = __cjs_createRequire(import.meta.url);`,Nk='const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;',Pk=`const __cjs_getBuiltinModule = (module) => {
|
|
130
|
+
// Check if we're in Node.js and version supports getBuiltinModule
|
|
131
|
+
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
132
|
+
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
133
|
+
// Node.js 20.16.0+ and 22.3.0+
|
|
134
|
+
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
135
|
+
return __cjs_getProcess.getBuiltinModule(module);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Fallback to createRequire
|
|
139
|
+
return ${qa}(module);
|
|
140
|
+
};`,vn={builtin:/const\s+__cjs_getBuiltinModule\s*=\s*\(\w*\)\s*=>\s*\{[\s\S]*?\};\s*/g,import:/import\s*\{\s*createRequire(?:\s+as\s+__cjs_createRequire)?\s*\}\s*from\s*["']node:module["'];?\s*/g,process:/const\s+__cjs_getProcess\s*=\s*typeof\s+globalThis[^;]*;\s*/g,require:/const\s+__cjs_require\s*=\s*(?:__cjs_)?createRequire(?:\$\w+)?\s*\([^)]*\);\s*/g},_k=[/node_modules/,/\.d\.[cm]?ts$/],Mk=[/\.[cm]?[jt]sx?$/];let Uc=!1;const Ik=dr((e,t)=>t&&(Em.includes(e)||e.startsWith("node:")),"isBuiltinModule"),Wk=dr(async(e,t,r,n,o)=>t?!0:await r?.(e,n,o)??await Ok(e,n,o),"shouldTransformImport"),Bk=dr((e,t)=>t?e==="process"||e==="node:process"?{code:"__cjs_getProcess",needsBuiltin:!1,needsProcess:!0,needsRequire:!0}:{code:`__cjs_getBuiltinModule(${JSON.stringify(e)})`,needsBuiltin:!0,needsProcess:!0,needsRequire:!0}:{code:`${qa}(${JSON.stringify(e)})`,needsBuiltin:!1,needsProcess:!1,needsRequire:!0},"generateRequireCode"),Dk=dr(e=>{const t=new Se(e),r={builtin:[...e.matchAll(vn.builtin)],import:[...e.matchAll(vn.import)],process:[...e.matchAll(vn.process)],require:[...e.matchAll(vn.require)]};return Object.values(r).forEach(n=>{if(n.length>1)for(let o=n.length-1;o>0;o-=1){const s=n[o];s&&t.remove(s.index,s.index+s[0].length)}}),t.toString()},"removeDuplicates"),Lk=dr(e=>{if(Array.isArray(e.shouldTransform)){const{shouldTransform:t}=e;e.shouldTransform=r=>t.includes(r)}return{builtinNodeModules:!!e.builtinNodeModules,cwd:e.cwd??ut.cwd(),exclude:e.exclude??_k,include:e.include??Mk,order:"order"in e?e.order:"pre",shouldTransform:e.shouldTransform}},"resolveOptions"),Fk=dr((e,t)=>{if(ut.env.INTERNAL_PACKEM_BUILD)return{name:"require-cjs-transformer"};const{builtinNodeModules:r,cwd:n,exclude:o,include:s,order:i,shouldTransform:a}=Lk(e),l=Ze(s,o);return{async buildStart(){Ak(),Uc||(await gp(),Uc=!0)},name:"packem:plugin-require-cjs",renderChunk:{async handler(u,c,p){if(p.format!=="es"||!l(c.fileName))return;const f=yo(c.fileName,u,{astType:"js",lang:"js",sourceType:"module"}),d=new Se(u);let m=!1,h=!1,$=!1;for(const g of f.program.body){if(g.type!=="ImportDeclaration"||g.importKind==="type")continue;const w=g.source.value,b=Ik(w,r),v=this.resolve;if(!await Wk(w,b,a,n,v))continue;const{code:S,needsBuiltin:x,needsProcess:E,needsRequire:j}=Bk(w,b);if(m||=j,h||=E,$||=x,g.specifiers.length===0){b?d.remove(g.start,g.end):d.overwrite(g.start,g.end,`${S};`);continue}const k=[];let R,P;for(const U of g.specifiers)if(U.type==="ImportNamespaceSpecifier")R=U.local.name;else if(U.type==="ImportSpecifier"&&U.importKind!=="type"){const J=u.slice(U.imported.start,U.imported.end);k.push([J,U.local.name])}else U.type==="ImportDefaultSpecifier"&&(P=U.local.name);const z=[];if(R&&(P??=`_cjs_${R}_default`),P&&z.push(`const ${P} = ${S};`),R&&z.push(`const ${R} = { ...${P??""}, default: ${P??""} };`),k.length>0){const U=`const {
|
|
141
|
+
${k.map(([J,N])=>` ${J===N?N:`${J}: ${N}`}`).join(`,
|
|
142
|
+
`)}
|
|
143
|
+
} = ${P??S};`;z.push(U)}d.overwrite(g.start,g.end,z.join(`
|
|
144
|
+
`))}if(m||h||$){const g=[];m&&g.push(Ck,Tk),h&&g.push(Nk),$&&g.push(Pk);const w=`${g.join(`
|
|
145
|
+
|
|
146
|
+
`)}
|
|
147
|
+
|
|
148
|
+
`,b=d.toString();if(b[0]==="#"){const v=b.indexOf(`
|
|
149
|
+
`)+1;d.appendLeft(v,w)}else d.prepend(w)}const y=new Se(Dk(d.toString()));return{code:y.toString(),map:y.generateMap()}},order:i}}},"requireCJSTransformerPlugin");var Hk=44,Gc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qk=new Uint8Array(64),Rd=new Uint8Array(128);for(let e=0;e<Gc.length;e++){const t=Gc.charCodeAt(e);qk[e]=t,Rd[t]=e}function Or(e,t){let r=0,n=0,o=0;do{const i=e.next();o=Rd[i],r|=(o&31)<<n,n+=5}while(o&32);const s=r&1;return r>>>=1,s&&(r=-2147483648|-r),t+r}function Vc(e,t){return e.pos>=t?!1:e.peek()!==Hk}typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u";var Jk=class{constructor(e){this.pos=0,this.buffer=e}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(e){const{buffer:t,pos:r}=this,n=t.indexOf(e,r);return n===-1?t.length:n}};function zk(e){const{length:t}=e,r=new Jk(e),n=[];let o=0,s=0,i=0,a=0,l=0;do{const u=r.indexOf(";"),c=[];let p=!0,f=0;for(o=0;r.pos<u;){let d;o=Or(r,o),o<f&&(p=!1),f=o,Vc(r,u)?(s=Or(r,s),i=Or(r,i),a=Or(r,a),Vc(r,u)?(l=Or(r,l),d=[o,s,i,a,l]):d=[o,s,i,a]):d=[o],c.push(d),r.pos++}p||Uk(c),n.push(c),r.pos=u+1}while(r.pos<=t);return n}function Uk(e){e.sort(Gk)}function Gk(e,t){return e[0]-t[0]}var Bn={exports:{}},Vk=Bn.exports,Kc;function Kk(){return Kc||(Kc=1,(function(e,t){(function(r,n){e.exports=n()})(Vk,(function(){const r=/^[\w+.-]+:\/\//,n=/^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,o=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function s(g){return r.test(g)}function i(g){return g.startsWith("//")}function a(g){return g.startsWith("/")}function l(g){return g.startsWith("file:")}function u(g){return/^[.?#]/.test(g)}function c(g){const w=n.exec(g);return f(w[1],w[2]||"",w[3],w[4]||"",w[5]||"/",w[6]||"",w[7]||"")}function p(g){const w=o.exec(g),b=w[2];return f("file:","",w[1]||"","",a(b)?b:"/"+b,w[3]||"",w[4]||"")}function f(g,w,b,v,S,x,E){return{scheme:g,user:w,host:b,port:v,path:S,query:x,hash:E,type:7}}function d(g){if(i(g)){const b=c("http:"+g);return b.scheme="",b.type=6,b}if(a(g)){const b=c("http://foo.com"+g);return b.scheme="",b.host="",b.type=5,b}if(l(g))return p(g);if(s(g))return c(g);const w=c("http://foo.com/"+g);return w.scheme="",w.host="",w.type=g?g.startsWith("?")?3:g.startsWith("#")?2:4:1,w}function m(g){if(g.endsWith("/.."))return g;const w=g.lastIndexOf("/");return g.slice(0,w+1)}function h(g,w){$(w,w.type),g.path==="/"?g.path=w.path:g.path=m(w.path)+g.path}function $(g,w){const b=w<=4,v=g.path.split("/");let S=1,x=0,E=!1;for(let k=1;k<v.length;k++){const R=v[k];if(!R){E=!0;continue}if(E=!1,R!=="."){if(R===".."){x?(E=!0,x--,S--):b&&(v[S++]=R);continue}v[S++]=R,x++}}let j="";for(let k=1;k<S;k++)j+="/"+v[k];(!j||E&&!j.endsWith("/.."))&&(j+="/"),g.path=j}function y(g,w){if(!g&&!w)return"";const b=d(g);let v=b.type;if(w&&v!==7){const x=d(w),E=x.type;switch(v){case 1:b.hash=x.hash;case 2:b.query=x.query;case 3:case 4:h(b,x);case 5:b.user=x.user,b.host=x.host,b.port=x.port;case 6:b.scheme=x.scheme}E>v&&(v=E)}$(b,v);const S=b.query+b.hash;switch(v){case 2:case 3:return S;case 4:{const x=b.path.slice(1);return x?u(w||g)&&!u(x)?"./"+x+S:x+S:S||"."}case 5:return b.path+S;default:return b.scheme+"//"+b.user+b.host+b.port+b.path+S}}return y}))})(Bn)),Bn.exports}var Yk=Kk();const Xk=Zr(Yk);function Zk(e){if(!e)return"";const t=e.lastIndexOf("/");return e.slice(0,t+1)}function Qk(e,t){const r=Zk(e),n=t?t+"/":"";return o=>Xk(n+(o||""),r)}var Kr=0,ej=1,tj=2,rj=3,nj=4;function oj(e,t){const r=Yc(e,0);if(r===e.length)return e;t||(e=e.slice());for(let n=r;n<e.length;n=Yc(e,n+1))e[n]=ij(e[n],t);return e}function Yc(e,t){for(let r=t;r<e.length;r++)if(!sj(e[r]))return r;return e.length}function sj(e){for(let t=1;t<e.length;t++)if(e[t][Kr]<e[t-1][Kr])return!1;return!0}function ij(e,t){return t||(e=e.slice()),e.sort(aj)}function aj(e,t){return e[Kr]-t[Kr]}function lj(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}function Ja(e){return typeof e=="string"?JSON.parse(e):e}var cj=function(e,t){const r=Ja(e);if(!("sections"in r))return new za(r,t);const n=[],o=[],s=[],i=[],a=[];Cd(r,t,n,o,s,i,a,0,0,1/0,1/0);const l={version:3,file:r.file,names:i,sources:o,sourcesContent:s,mappings:n,ignoreList:a};return dj(l)};function Cd(e,t,r,n,o,s,i,a,l,u,c){const{sections:p}=e;for(let f=0;f<p.length;f++){const{map:d,offset:m}=p[f];let h=u,$=c;if(f+1<p.length){const y=p[f+1].offset;h=Math.min(u,a+y.line),h===u?$=Math.min(c,l+y.column):h<u&&($=l+y.column)}uj(d,t,r,n,o,s,i,a+m.line,l+m.column,h,$)}}function uj(e,t,r,n,o,s,i,a,l,u,c){const p=Ja(e);if("sections"in p)return Cd(...arguments);const f=new za(p,t),d=n.length,m=s.length,h=fj(f),{resolvedSources:$,sourcesContent:y,ignoreList:g}=f;if(Qs(n,$),Qs(s,f.names),y)Qs(o,y);else for(let w=0;w<$.length;w++)o.push(null);if(g)for(let w=0;w<g.length;w++)i.push(g[w]+d);for(let w=0;w<h.length;w++){const b=a+w;if(b>u)return;const v=pj(r,b),S=w===0?l:0,x=h[w];for(let E=0;E<x.length;E++){const j=x[E],k=S+j[Kr];if(b===u&&k>=c)return;if(j.length===1){v.push([k]);continue}const R=d+j[ej],P=j[tj],z=j[rj];v.push(j.length===4?[k,R,P,z]:[k,R,P,z,m+j[nj]])}}}function Qs(e,t){for(let r=0;r<t.length;r++)e.push(t[r])}function pj(e,t){for(let r=e.length;r<=t;r++)e[r]=[];return e[t]}var za=class{constructor(t,r){const n=typeof t=="string";if(!n&&t._decodedMemo)return t;const o=Ja(t),{version:s,file:i,names:a,sourceRoot:l,sources:u,sourcesContent:c}=o;this.version=s,this.file=i,this.names=a||[],this.sourceRoot=l,this.sources=u,this.sourcesContent=c,this.ignoreList=o.ignoreList||o.x_google_ignoreList||void 0;const p=Qk(r,l);this.resolvedSources=u.map(p);const{mappings:f}=o;if(typeof f=="string")this._encoded=f,this._decoded=void 0;else if(Array.isArray(f))this._encoded=void 0,this._decoded=oj(f,n);else throw o.sections?new Error("TraceMap passed sectioned source map, please use FlattenMap export instead"):new Error(`invalid source map: ${JSON.stringify(o)}`);this._decodedMemo=lj(),this._bySources=void 0,this._bySourceMemos=void 0}};function fj(e){var t;return(t=e)._decoded||(t._decoded=zk(e._encoded))}function dj(e,t){const r=new za(mj(e,[]),t);return r._decoded=e.mappings,r}function mj(e,t){return{version:e.version,file:e.file,names:e.names,sourceRoot:e.sourceRoot,sources:e.sources,sourcesContent:e.sourcesContent,mappings:t,ignoreList:e.ignoreList||e.x_google_ignoreList}}var hj=Object.defineProperty,Td=(e,t)=>hj(e,"name",{value:t,configurable:!0});const gj=Me(import.meta.url),Rr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Nd=Td(e=>{if(typeof Rr<"u"&&Rr.versions&&Rr.versions.node){const[t,r]=Rr.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Rr.getBuiltinModule(e)}return gj(e)},"__cjs_getBuiltinModule"),{readFileSync:Xc}=Nd("node:fs"),{resolve:yj,toNamespacedPath:ei,dirname:$j}=Nd("node:path");var bj=Object.defineProperty,cn=Td((e,t)=>bj(e,"name",{value:t,configurable:!0}),"s");const wj=/^data:application\/json[^,]+base64,/,vj=/\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+)[ \t]*$|\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*\*\/[ \t]*$/,xj=/\r?\n/,Pd=cn(e=>wj.test(e),"isInlineMap"),ti=cn((e,t)=>{const r=e instanceof Error?e.message:String(e),n=`${t}:
|
|
150
|
+
${r}`;throw new Error(n)},"enhanceError"),Ej=cn((e,t)=>{const r=e.split(xj);let n;for(let s=r.length-1;s>=0&&!n;s--)n=vj.exec(r[s])??void 0;if(!n)return;const o=n[1]??n[2];if(o)return Pd(o)?o:yj(t,o)},"resolveSourceMapUrl"),Sj=cn(e=>{const t=e.slice(e.indexOf(",")+1);return Buffer.from(t,"base64").toString()},"decodeInlineMap"),kj=cn(e=>{let t;try{t=Xc(e,{encoding:"utf8"})}catch(o){ti(o,`Error reading sourcemap for file "${ei(e)}"`)}const r=Ej(t,$j(e));if(!r)return;let n;if(Pd(r))n=Sj(r);else try{n=Xc(r,{encoding:"utf8"})}catch(o){ti(o,`Error reading sourcemap for file "${ei(e)}"`)}try{return new cj(n,r)}catch(o){ti(o,`Error parsing sourcemap for file "${ei(e)}"`)}},"loadSourceMap");var jj=Object.defineProperty,Aj=(e,t)=>jj(e,"name",{value:t,configurable:!0}),Oj=Object.defineProperty,Rj=Aj((e,t)=>Oj(e,"name",{value:t,configurable:!0}),"s");const Cj=/\?[^?]*$/,Tj=Rj(({exclude:e,include:t}={})=>{const r=Ze(t,e);return{async load(n){if(!r(n))return;let o;try{o=await Nt(n,{buffer:!1}),this.addWatchFile(n)}catch(i){try{const a=n.replace(Cj,"");o=await Nt(a,{buffer:!1}),this.addWatchFile(a)}catch{this.warn(`Failed reading file "${n}": ${i instanceof Error?i.message:String(i)}`);return}}if(!o.includes("sourceMappingURL"))return o;let s;try{const i=kj(n);if(i===void 0)return o;s=i}catch(i){return this.warn(`Failed resolving source map for "${n}": ${i instanceof Error?i.message:String(i)}`),{code:o}}return{code:o,map:s}},name:"packem:sourcemaps"}},"sourcemapsPlugin");var Nj=Object.defineProperty,Pj=(e,t)=>Nj(e,"name",{value:t,configurable:!0}),_j=Object.defineProperty,_d=Pj((e,t)=>_j(e,"name",{value:t,configurable:!0}),"g");const Mj=_d(async(e,t)=>{await new Promise((r,n)=>{const o=Zi(e);o.on("error",n);const s=wh(t);s.on("error",n),s.on("finish",()=>{r(void 0)}),o.pipe(s)})},"copy"),Ij=_d(({destDir:e,emitFiles:t,exclude:r,fileName:n,include:o,limit:s,publicPath:i,sourceDir:a})=>{const l=Ze(o,r),u={};return{async generateBundle(c){if(!t)return;const p=e??c.dir??Z(c.file??"");await yi(p),await Promise.all(Object.keys(u).map(async f=>{const d=u[f],m=G(p,Z(d));await yi(m),await Mj(f,G(p,d))}))},async load(c){if(!l(c))return;this.addWatchFile(c);const[p,f]=await Promise.all([Qr(c),Jn(c)]);let d;if(s&&p.size>s||s===0){const m=Fh.createHash("sha1").update(f).digest("hex").slice(0,16),h=tr(c),$=Fe(c,h),y=a?ke(a,Z(c)):Fe(Z(c)),g=n.replaceAll("[hash]",m).replaceAll("[extname]",h).replaceAll("[dirname]",y===""?"":`${y}/`).replaceAll("[name]",$);d=G(i??"",g),u[c]=g}else{const m=hp.getType(c);if(m===null)throw new Error(`Could not determine mimetype for ${c}`);d=m==="image/svg+xml"?dh(f):f.toString("base64"),d=`data:${m};base64,${d}`}return`export default ${JSON.stringify(d)}`},name:"packem:url"}},"urlPlugin"),un=(e,t={},r={})=>({...t,...e,values:e.values?{...e.values}:{...r}}),Yr=e=>!!e?.endsWith(".d"),so=(e,t)=>{if(e!==void 0)return typeof e=="string"||typeof e=="function"?t==="js"?e:void 0:e[t]},te=e=>e.logger,Wj=/Circular dependency:[\s\S]*node_modules/,Bj=/\.mts$/,Dj=/\.(?:m|c)?(?:j|t)sx?$/,Lj=/^['|"](use (\w+))['|"]$/,Md=/\.(?:[cm]?jsx?|[cm]?tsx?|json)$/,Fj=e=>e instanceof RegExp?e.source:e,Id=e=>{if(typeof e=="boolean")return String(e);const t=[];for(const r of e)t.push(Fj(r));return t.toSorted((r,n)=>r.localeCompare(n)).join(",")},Zc=(e,t)=>t?r=>{if(!Yr(r.name))return`${r.name}.${e()}`}:r=>{if(!Yr(r.name))return Br(r,e())},Qc=(e,t)=>t?r=>{const{name:n}=r;if(!Yr(n))return`${n??"[name]"}.${e(r)}`}:r=>{const{name:n}=r;if(!Yr(n))return mh(r,e(r))},Wd=e=>{const t=`node${Fn.node.split(".")[0]}`;if(!e.pkg.engines?.node)return t;const r=Le.minVersion(e.pkg.engines.node);return r?`node${String(r.major)}`:t},Bd=(e,t,r)=>{const n=e.options.browserTargets&&e.options.browserTargets.length>0?e.options.browserTargets:e.options.resolvedBrowserTargets??e.options.browserTargets??[];if(t){const o=ih(t);return e.options.runtime==="node"?[...new Set([r,...o])]:e.options.runtime==="browser"?[...new Set([...ol(n),...o])]:o}return e.options.runtime==="node"?[r]:ol(n)},Hj=(e,t)=>{if(!e.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");const r=e.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3";r&&te(e).warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" "));const n=r?"es5":Bd(e,e.options.rollup.esbuild.target,t);let o=e.options.rollup.esbuild.keepNames;return e.options.minify||(o=!1,te(e).debug("Disabling keepNames because minify is disabled")),(r||e.tsconfig?.config.compilerOptions?.target==="es5")&&(o=!1,te(e).debug("Disabling keepNames because target is set to es5")),{logger:te(e),minify:e.options.minify,minifyWhitespace:e.options.minify,sourceMap:e.options.sourcemap,...e.options.rollup.esbuild,keepNames:o,target:n}},qj=e=>{if(!e.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:e.options.minify,...e.options.rollup.swc,jsc:{minify:{compress:{directives:!1,passes:2},format:{comments:"some"},mangle:{topLevel:!0},sourceMap:e.options.sourcemap,toplevel:e.options.emitCJS??e.options.emitESM},...e.options.rollup.swc.jsc},sourceMaps:e.options.sourcemap}},Dd=(e,t)=>{if(!e.options.rollup.oxc)throw new Error("No oxc options found in your configuration.");const{jsx:r}=e.options.rollup.oxc;let n;return typeof r=="string"?n=r:r?n={...r,refresh:!1}:n=void 0,e.options.rollup.oxc={...e.options.rollup.oxc,cwd:e.options.rootDir,jsx:n,sourcemap:e.options.sourcemap,typescript:e.tsconfig?.config?{allowDeclareFields:!0,allowNamespaces:!0,declaration:void 0,jsxPragma:e.tsconfig.config.compilerOptions?.jsxFactory,jsxPragmaFrag:e.tsconfig.config.compilerOptions?.jsxFragmentFactory,onlyRemoveTypeImports:!0,rewriteImportExtensions:!1}:void 0},e.options.rollup.oxc.target=Bd(e,e.options.rollup.oxc.target,t),e.options.rollup.oxc},Jj=(e,t,r)=>{if(r)return"js";if(t.facadeModuleId?.endsWith(".mts")){const n=t.facadeModuleId.replace(Bj,".cts");if(Xi(n))return"mjs"}return!e.options.emitCJS&&e.options.emitESM&&e.pkg.main?.endsWith(".cjs")?"mjs":Pe(e,"esm")},zj=(e,t)=>{const r=Wd(t);if(e==="esbuild")return Hj(t,r);if(e==="swc")return qj(t);if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return t.options.rollup.sucrase}if(e==="oxc")return Dd(t,r);throw new Error("A Unknown transformer was provided")},Uj=e=>{const{browser:t,exportConditions:r}=e,n={...e};delete n.allowExportsFolderMapping,delete n.browser,delete n.exportConditions,delete n.preferBuiltins,delete n.unresolvedImportBehavior;const o=new Set(Array.isArray(n.conditionNames)?n.conditionNames:[]);return Array.isArray(r)&&(n.conditionNames=[...new Set([...r,...o])]),t&&(n.conditionNames=[...new Set(["browser",...n.conditionNames??[]])],n.aliasFields=[["browser"],...n.aliasFields??[]]),n},Ua=e=>{const{resolve:t}=e.options.rollup;if(t)return Um(Uj(t),e.options.rootDir,te(e),e.tsconfig?.path)},Ga=(e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&Wj.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT"){const{resolve:r}=t.options.rollup;if(r&&r.unresolvedImportBehavior==="warn")return!1;const n=new Error(`Failed to resolve the module "${e.exporter??""}" imported by "${ne(ke(X(),e.id??""))}"
|
|
151
|
+
Is the module installed? Note:
|
|
152
|
+
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
153
|
+
↳ to depend on a module via import/require, install it to "dependencies".`);throw n.id=e.id,n}return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&(t.options.cjsInterop??!1)},Ld=e=>{const t={};for(const r of e.options.entries){if(r.name===void 0)continue;const{name:n}=r,o=X(e.options.rootDir,r.input);if(t[n]!==void 0&&t[n]!==o)throw new Error(`Duplicate rollup input name "${n}" — one maps to "${t[n]}", another to "${o}". Each entry must have a unique name.`);t[n]=o}return t},Gj=e=>e.stack?`${e.message}
|
|
154
|
+
${e.stack}`:e.message,Vj=(e,t,r,n)=>{if(t==="dts"&&n.code==="EMPTY_BUNDLE")return;const o=Gj(n),s=t+(n.plugin?`:plugin:${n.plugin}`:"");switch(r){case"info":{te(e).info({message:o,prefix:s});return}case"warn":{te(e).warn({message:o,prefix:s});return}case"debug":te(e).debug({message:o,prefix:s})}},Fd=(e,t)=>({input:Ld(e),logLevel:e.options.debug?"debug":"info",onLog:(r,n)=>{Vj(e,t,r,n)},onwarn(r,n){Ga(r,e)||r.code||n(r)},preserveEntrySignatures:"strict",treeshake:{moduleSideEffects:!0,preset:"smallest"},watch:e.mode==="watch"?e.options.rollup.watch:!1}),Kj=(e,t,r,n)=>{const o={...e.options.rollup.alias,entries:t};return!r&&n&&(o.customResolver=n),Gi(o)},Yj=e=>{if(!e.options.rollup.pure)return{pureNewExpressionPluginInstance:void 0,purePluginInstance:void 0,rolldownPurePluginInstance:void 0};const t=e.options.rollup.pure.functions??[],r=["Object.defineProperty","Object.assign","Object.create","Object.freeze","Object.seal","Object.setPrototypeOf","Object.getOwnPropertyDescriptor","Object.getOwnPropertyDescriptors","Object.getPrototypeOf","Object.hasOwnProperty","Object.isExtensible","Object.isFrozen","Object.isSealed","Symbol","Symbol.for","Symbol.keyFor","Symbol.iterator","Symbol.asyncIterator","Symbol.hasInstance","Symbol.isConcatSpreadable","Symbol.species","Symbol.toPrimitive","Symbol.toStringTag","Proxy","Reflect.apply","Reflect.construct","Reflect.defineProperty","Reflect.deleteProperty","Reflect.get","Reflect.getOwnPropertyDescriptor","Reflect.getPrototypeOf","Reflect.has","Reflect.isExtensible","Reflect.ownKeys","Reflect.preventExtensions","Reflect.set","Reflect.setPrototypeOf","WeakMap","WeakSet","WeakRef","Array.from","Array.of","Array.isArray","Number.isFinite","Number.isInteger","Number.isNaN","Number.isSafeInteger","Number.parseFloat","Number.parseInt","String.fromCharCode","String.fromCodePoint","String.raw","Date.now","Date.parse","Date.UTC","Math.abs","Math.acos","Math.acosh","Math.asin","Math.asinh","Math.atan","Math.atan2","Math.atanh","Math.cbrt","Math.ceil","Math.clz32","Math.cos","Math.cosh","Math.exp","Math.expm1","Math.floor","Math.fround","Math.hypot","Math.imul","Math.log","Math.log10","Math.log1p","Math.log2","Math.max","Math.min","Math.pow","Math.random","Math.round","Math.sign","Math.sin","Math.sinh","Math.sqrt","Math.tan","Math.tanh","Math.trunc","JSON.parse","JSON.stringify","require.resolve","Buffer.from","Buffer.alloc","Buffer.allocUnsafe","Buffer.isBuffer",...t],n=["Proxy","WeakMap","WeakSet","WeakRef",...t.filter(a=>typeof a=="string"&&!a.includes("."))],o=Gm({...e.options.rollup.pure,functions:r,sourcemap:e.options.sourcemap});o.transform.order="pre";const s=nl({constructors:n,sourcemap:e.options.sourcemap}),i=nl({constructors:n,functions:r,mode:"renderChunk",sourcemap:e.options.sourcemap});return{pureNewExpressionPluginInstance:s,purePluginInstance:o,rolldownPurePluginInstance:i}},Xj=(e,t,r)=>{if(e.pkg.peerDependenciesMeta)for(const[n,o]of Object.entries(e.pkg.peerDependenciesMeta))o&&typeof o=="object"&&"optional"in o&&o.optional&&n in t&&r.push(n)},Zj=(e,t,r)=>{if(!e.options.rollup.resolveExternals?.devDeps)for(const n of Object.keys(e.pkg.devDependencies??{}))e.usedDependencies.has(n)&&!(n in t)&&r.push(n)},Qj=e=>{const t=new Set,r=[];for(const n of e)typeof n=="string"?t.has(n)||(t.add(n),r.push(n)):r.push(n);return r},Hd=e=>{const t=e.options.rollup.dts?.resolve;if(t===!1)return!1;if(t===!0)return!0;const r=Object.keys(e.pkg.optionalDependencies??{}),n=e.pkg.peerDependencies??{};return Xj(e,n,r),Zj(e,n,r),r.length===0&&!t?!1:Qj([...r,...t??[]])},e9=async(e,t)=>{const{dts:r}=await import("@visulima/rollup-plugin-dts"),n=e.options.rollup.dts??{},o=so(e.options.banner,"dts"),s=so(e.options.footer,"dts");return r({banner:o,footer:s,...n,compilerOptions:{...n.compilerOptions,incremental:void 0,inlineSources:void 0,lib:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},emitDtsOnly:!0,resolve:t,tsconfig:e.tsconfig?.path})},qd=Vi(e9),Jd=async(e,t)=>{const r=sn(e.pkg,e.options),n=Hd(e),o=Ua(e),s=Id(n),i=e.options.entries.map(p=>p.name??"").filter(p=>p!=="").toSorted((p,f)=>p.localeCompare(f)).join(","),a=`dts-plugin:${String(process.pid)}${e.tsconfig?.path??""}:${s}:${i}`,[l,u,c]=Yi(e.options.rollup.plugins,"dts");return{...Fd(e,"dts"),onwarn(p,f){Ga(p,e)||p.code!=="EMPTY_BUNDLE"&&p.code!=="CIRCULAR_DEPENDENCY"&&f(p)},output:[e.options.emitCJS&&{chunkFileNames:p=>Br(p,Ke(e,"cjs")),compact:e.options.minify,dir:X(e.options.rootDir,e.options.outDir),entryFileNames:`[name].${Ke(e,"cjs")}`,format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:p=>Br(p,Ke(e,"esm")),compact:e.options.minify,dir:X(e.options.rootDir,e.options.outDir),entryFileNames:`[name].${Ke(e,"esm")}`,format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:p=>Br(p,"d.mjs"),compact:e.options.minify,dir:X(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[zi(),de(xa(),t),de(_a(),t),Sa(e,{dtsResolve:n,forTypes:!0,skipUnlistedWarnings:!0}),{load(p){if(!Md.test(p))return""},name:"packem:ignore-files"},e.tsconfig&&de(Na(e.options.rootDir,te(e),e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&de(Ta(e.options.rootDir,e.tsconfig,te(e),e.options.rollup.tsconfigPaths),t),Aa(e),e.options.rollup.replace&&Ui(un(e.options.rollup.replace,{sourcemap:e.options.sourcemap})),e.options.rollup.alias&&Gi({customResolver:o,...e.options.rollup.alias,entries:r}),...l,o,...u,...await qd(a)(e,n),e.options.emitCJS&&cd(),e.options.cjsInterop&&e.options.emitCJS&&Qi({...e.options.rollup.cjsInterop,logger:te(e)}),e.options.rollup.patchTypes&&de(fd(e.options.rollup.patchTypes,te(e)),t),pd(),...c,e.options.rollup.license!==!1&&e.options.rollup.license?.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&ja({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:te(e),marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},zd=async(e,t,r)=>{const n=sn(e.pkg,e.options),o=r==="rolldown",s=o?void 0:Ua(e),i=e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0?await import("@visulima/rollup-plugin-css"):void 0,a=!!(e.options.unbundle||e.options.rollup.output?.preserveModules),l=a?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output?.preserveModulesRoot??e.options.sourceDir}:{manualChunks:xx(e.dependencyGraphMap,e.buildEntries,!o&&!!e.options.rollup.preserveDirectives),preserveModules:!1},[u,c,p]=Yi(e.options.rollup.plugins,"build"),f=e.tsconfig?.config.compilerOptions?.esModuleInterop,{pureNewExpressionPluginInstance:d,purePluginInstance:m,rolldownPurePluginInstance:h}=Yj(e),$=so(e.options.banner,"js"),y=so(e.options.footer,"js");return{...Fd(e,"build"),output:[e.options.emitCJS&&{assetFileNames:"[name]-[hash][extname]",banner:$,chunkFileNames:Zc(()=>Pe(e,"cjs"),a),compact:e.options.minify,dir:X(e.options.rootDir,e.options.outDir),entryFileNames:Qc(g=>Pe(e,"cjs"),a),esModule:f??"if-default-prop",exports:"auto",extend:!0,externalLiveBindings:!1,footer:y,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...l},e.options.emitESM&&{assetFileNames:"[name]-[hash][extname]",banner:$,chunkFileNames:Zc(()=>Pe(e,"esm"),a),compact:e.options.minify,dir:X(e.options.rootDir,e.options.outDir),entryFileNames:Qc(g=>Jj(e,g,a),a),esModule:f??"if-default-prop",exports:"auto",extend:!0,externalLiveBindings:!1,footer:y,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...l}].filter(Boolean),plugins:[!o&&zi(),VS(),de(xa(),t),Sa(e),_a(),e.tsconfig&&de(Na(e.options.rootDir,te(e),e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&de(Ta(e.options.rootDir,e.tsconfig,te(e),e.options.rollup.tsconfigPaths),t),Aa(e),e.options.rollup.replace&&Ui(un(e.options.rollup.replace,{sourcemap:e.options.sourcemap})),e.options.rollup.alias&&Kj(e,n,o,s),...u,s,e.options.rollup.nativeModules&&bk(e.options.rollup.nativeModules),e.options.rollup.dataUri&&OE({...e.options.rollup.dataUri}),e.options.rollup.polyfillNode&&Vm({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),!o&&e.options.rollup.json&&Jh({...e.options.rollup.json}),e.options.rollup.debarrel&&ZE(e.options.rollup.debarrel,te(e)),Km(),e.options.rollup.wasm&&Ym(e.options.rollup.wasm),e.options.rollup.url&&Ij(e.options.rollup.url),i&&de(i.rollupCssPlugin({dts:!!e.options.declaration,sourceMap:e.options.sourcemap,...e.options.rollup.css},e.options.runtime==="browser"&&(!e.options.browserTargets||e.options.browserTargets.length===0)?e.options.resolvedBrowserTargets??[]:e.options.browserTargets??[],e.options.rootDir,e.options.sourceDir,e.environment,e.options.sourcemap,e.options.debug,e.options.minify??!1,n),t),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&(e.options.declaration||e.options.rollup.css.dts)&&i?.cssModulesTypesPlugin(e.options.rollup.css,e.options.rootDir),e.options.rollup.raw&&de(Sk(e.options.rollup.raw),t),e.options.sourcemap&&Tj(e.options.rollup.sourcemap),...c,e.options.rollup.minifyHTMLLiterals&&e.options.minify&&mk({...e.options.rollup.minifyHTMLLiterals,logger:te(e)}),e.options.rollup.requireCJS&&e.options.emitESM&&de(Fk({...e.options.rollup.requireCJS,cwd:e.options.rootDir},te(e)),t),e.options.rollup.babel&&de(yE({include:e.options.rollup.babel.include??Dj,...e.options.rollup.babel,root:e.options.rootDir,sourceMaps:e.options.rollup.babel.sourceMaps??e.options.sourcemap}),t),!o&&d,!o&&m,o&&h,e.options.rollup.detectDuplicated!==!1&&PS(te(e),e.options.rootDir,e.options.rollup.detectDuplicated),!o&&e.options.transformer&&de(e.options.transformer(zj(e.options.transformerName,e)),t),e.options.rollup.preserveDirectives&&Xm({directiveRegex:Lj,...e.options.rollup.preserveDirectives,logger:te(e)}),e.options.rollup.shebang&&m2(e.options.entries.filter(g=>g.executable).map(g=>g.name).filter(Boolean),e.options.rollup.shebang),!o&&e.options.cjsInterop&&e.options.emitCJS&&Qi({...e.options.rollup.cjsInterop,logger:te(e)}),e.options.rollup.dynamicVars&&Kv(),!o&&e.options.rollup.dynamicVars&&Zm(e.options.rollup.dynamicVars),!o&&e.options.rollup.commonjs&&de(Qm({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&FS(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&(()=>{const g=eh({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:te(e),...o?{mode:"renderChunk"}:{}});return o?g:de(g,t)})(),...p,e.options.rollup.metafile&&ex(),e.options.rollup.copy&&xE(e.options.rollup.copy,te(e)),e.options.rollup.license!==!1&&e.options.rollup.license?.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&ja({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:te(e),marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.analyze&&e.options.rollup.visualizer!==!1&&th({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),preserveEntrySignatures:"strict"}},Ud=(e,t)=>zd(e,t,"rollup"),ri=/^\s*\/\/#(?:end)?region\b/,t9=/^\s+/,r9=/\.[cm]js$/,n9={".css":"js",".less":"js",".pcss":"js",".sass":"js",".scss":"js",".styl":"js",".stylus":"js"},o9=e=>{if(!e.options.rollup.oxc)return{};const t=Dd(e,Wd(e));return{jsx:t.jsx,target:t.target,typescript:t.typescript}},Gd=async(e,t)=>{const r=await zd(e,t,"rolldown");return r.transform=o9(e),r.moduleTypes={...n9,...r.moduleTypes},e.options.minify&&Array.isArray(r.output)&&(r.output=r.output.map(n=>({...n,minify:!0}))),r},s9=()=>({name:"packem:strip-rolldown-region-comments",renderChunk(e){const t=e.split(`
|
|
155
|
+
`),r=[];for(let o=0;o<t.length;o+=1){const s=t[o];if(!ri.test(s)){if(s.trim()===""){const i=o>0&&ri.test(t[o-1]),a=o<t.length-1&&ri.test(t[o+1]);if(i||a)continue}r.push(s)}}let n=r.join(`
|
|
156
|
+
`);if(n=n.replace(t9,""),n=`${n.trimEnd()}
|
|
157
|
+
`,n!==e)return{code:n,map:void 0}}}),Vd=async(e,t)=>{const r=sn(e.pkg,e.options),n=Hd(e),o=Ua(e),s=Id(n),i=e.options.entries.map(f=>f.name??"").filter(f=>f!=="").toSorted((f,d)=>f.localeCompare(d)).join(","),a=`dts-plugin:rolldown:${String(process.pid)}${e.tsconfig?.path??""}:${s}:${i}`,[l,u,c]=Yi(e.options.rollup.plugins,"dts"),p={input:Ld(e),logLevel:e.options.debug?"debug":"info",onLog:(f,d)=>{if(d.code==="EMPTY_BUNDLE")return;const m=d.stack?`${d.message}
|
|
158
|
+
${d.stack}`:d.message,h=`dts${d.plugin?`:plugin:${d.plugin}`:""}`,$=te(e);f==="info"?$.info({message:m,prefix:h}):f==="warn"?$.warn({message:m,prefix:h}):$.debug({message:m,prefix:h})},onwarn(f,d){Ga(f,e)||f.code!=="EMPTY_BUNDLE"&&f.code!=="CIRCULAR_DEPENDENCY"&&d(f)},plugins:[zi(),de(xa(),t),de(_a(),t),Sa(e,{dtsResolve:n,forTypes:!0,skipUnlistedWarnings:!0}),{load(f){if(!Md.test(f))return""},name:"packem:ignore-files"},e.tsconfig&&de(Na(e.options.rootDir,te(e),e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&de(Ta(e.options.rootDir,e.tsconfig,te(e),e.options.rollup.tsconfigPaths),t),Aa(e),e.options.rollup.replace&&Ui(un(e.options.rollup.replace,{sourcemap:e.options.sourcemap})),e.options.rollup.alias&&Gi({customResolver:o,...e.options.rollup.alias,entries:r}),...l,o,...u,...await qd(a)(e,n),e.options.emitCJS&&cd(),e.options.cjsInterop&&e.options.emitCJS&&Qi({...e.options.rollup.cjsInterop,logger:te(e)}),e.options.rollup.patchTypes&&de(fd(e.options.rollup.patchTypes,te(e)),t),pd(),...c,e.options.rollup.license!==!1&&e.options.rollup.license?.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&ja({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:te(e),marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name}),{name:"packem:rolldown-cjs-mjs-dts-compat",transform(f,d){if(r9.test(d))return{code:""}}},s9()].filter(Boolean),preserveEntrySignatures:"strict",treeshake:{moduleSideEffects:!0}};return p.moduleTypes={".cts":"ts",".mts":"ts"},p},Kd=(e,t,r)=>{const n=e.filter(s=>s.type==="chunk"&&s.isEntry),o=new Set(n.map(s=>s.fileName));for(const s of n)t.buildEntries.push({chunks:(s.imports??[]).filter(i=>o.has(i)),dynamicImports:s.dynamicImports??[],exports:s.exports??[],modules:Object.entries(s.modules??{}).map(([i,a])=>({bytes:a.renderedLength,id:i})),path:s.fileName,size:{bytes:Buffer.byteLength(s.code??"","utf8")},type:"entry"});for(const s of e.filter(i=>i.type==="asset")){if(r.has(s.fileName))continue;const i=s.source??"",a=typeof i=="string"?Buffer.byteLength(i,"utf8"):i.byteLength;r.set(s.fileName,{path:s.fileName,size:{bytes:a},type:"asset"})}},Yd=async(e,t)=>{try{return t(await e())}catch{return}},Xd="Rollup is not installed. Please install 'rollup' to use bundler: 'rollup' or DTS generation with the rollup driver.",Va=async()=>{const e=await Yd(()=>import("rollup"),t=>t.rollup);if(!e)throw new Error(Xd);return e},eu=async()=>{const e=await Yd(()=>import("rollup"),t=>t.watch);if(!e)throw new Error(Xd);return e},tu="rollup-build.json",Ho="dependencies-cache.json",Zd=e=>e??"rollup",io=e=>!!(e.options.validation&&e.options.validation.dependencies!==!1),Qd=(e,t,r)=>{const n=t.get(Ho,r);n&&(n.used?.forEach(o=>e.usedDependencies.add(o)),n.hoisted?.forEach(o=>e.hoistedDependencies.add(o)))},em=(e,t,r)=>{io(e)&&t.set(Ho,{hoisted:[...e.hoistedDependencies],used:[...e.usedDependencies]},r)},i9=async(e,t,r,n)=>{const o=io(e)&&!!t.get(Ho,r),s=!io(e)||o;let i=n;s&&(i={...n,cache:t.get(tu,r)},o&&Qd(e,t,r));const a=await(await Va())(i);try{s&&t.set(tu,a.cache,r),em(e,t,r),await e.hooks.callHook("rollup:build",e,a);const l=new Map;for(const u of n.output){const{output:c}=await a.write(u);Kd(c,e,l)}e.buildEntries.push(...l.values())}finally{await a.close()}},a9=async(e,t,r,n)=>{io(e)&&t.get(Ho,r)&&Qd(e,t,r);const o=await(await va())(n);try{em(e,t,r),await e.hooks.callHook("rollup:build",e,o);const s=new Map;for(const i of n.output){const{output:a}=await o.write(i);Kd(a,e,s)}e.buildEntries.push(...s.values())}finally{await o.close?.()}},l9=async(e,t,r,n)=>{const o=n==="rolldown",s=o?await Gd(e,t):await Ud(e,t);await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input??{}).length!==0&&(await(o?a9(e,t,r,s):i9(e,t,r,s)),await t.flush())},ru=async e=>{try{return await(e==="rolldown"?va():Va()),!0}catch{return!1}},nu=(e,t)=>{const r=[G(t,"noop.js"),import.meta.url];for(const n of r)try{return Me(n).resolve(e),!0}catch{}return!1},tm=async(e,t,r,n,o)=>{if(!(process.stdout.isTTY&&!process.env.CI)){const a=await Rl(e,r);throw new Error(`${e} is required but is not installed. Run: ${a}`)}const s=await zh({initialValue:!0,message:t});if(Uh(s)||!s){const a=await Rl(e,r);throw new Error(`Cannot continue without ${e}. Run: ${a}`)}const i=Gh();i.start(`Installing ${e}`);try{await Yu([e],{cwd:r,dev:!0,silent:!0}),i.stop(`Installed ${e}`)}catch(a){throw i.stop(`Failed to install ${e}`),a}if(!await o())throw n.error(`Installed ${e} but it still cannot be loaded. Try restarting packem.`),new Error(`${e} was installed but is not loadable in the current process. Re-run packem to pick it up.`)},c9=async(e,t,r)=>{await ru(e)||await tm(e,`${e} is required as the bundler but is not installed. Install it now?`,t,r,()=>ru(e))},u9=async(e,t,r)=>{const n=$1[e];nu(n,t)||await tm(n,`${n} is required for transformer: "${e}" but is not installed. Install it now?`,t,r,()=>Promise.resolve(nu(n,t)))},qo=e=>{const t=G(e,"package.json");if(!rt(t))throw new Error(`package.json not found at ${t}`);const r=ga(t,{resolveCatalogs:!0});return r.publishConfig&&Object.assign(r,r.publishConfig),{packageJson:r,packageJsonPath:t}},p9=async(e,t,r,n)=>{let o;if(n){const s=G(e,n);if(!await Ct(s))throw new Error(`tsconfig.json not found at ${s}`);o={config:Vh(s),path:s},r.info("Using tsconfig settings at",s)}else if(Of(t,["typescript"]))try{o=await Kh(e),r.debug("Using tsconfig settings found at",o.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}return o},f9=/[.*+?^${}()|[\]\\]/g,rm=e=>e.replaceAll(f9,String.raw`\$&`),d9=/^\.\.?\//,m9=(e,t)=>{if(e.executable&&(e.cjs===void 0||e.esm===void 0)){t.pkg.type==="commonjs"&&e.cjs===void 0&&t.options.emitCJS!==void 0?(e.cjs=t.options.emitCJS,e.esm=!1):t.pkg.type==="module"&&e.esm===void 0&&t.options.emitESM!==void 0&&(e.esm=t.options.emitESM,e.cjs=!1);return}e.cjs!==void 0||e.esm!==void 0||e.declaration||(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM))},ou=(e,t)=>{if(typeof e.name!="string"){let r=Tt(e.input)?ke(t.options.rootDir,e.input):Ku(e.input);r.startsWith("./")&&(r=r.slice(2)),e.name=r.replace(new RegExp(`^${rm(t.options.sourceDir)}/`),"").replace(Ki,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Vu(e.input)&&(e.input=X(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),m9(e,t),e.outDir=X(t.options.rootDir,e.outDir??t.options.outDir)},h9=e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:gi(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:gi(t.input)})},g9=e=>{const t=["**/.git/**","**/node_modules/**","**/test-results/**"],{watch:r}=e.options.rollup;if(r){if(typeof r.exclude=="string")t.push(r.exclude);else if(Array.isArray(r.exclude))for(const n of r.exclude)typeof n=="string"&&t.push(n)}return t},y9=e=>{for(const t of e.options.entries.filter(r=>r.isGlob)){const r={...t};delete r.isGlob;const n=Uu([r.input],{cwd:e.options.rootDir,dot:!1,ignore:g9(e),onlyFiles:!0});if(n.length===0)throw new Mt(`No files found in the glob pattern: ${ne(G(e.options.rootDir,r.input))}`);for(const o of n)e.options.entries.push({...r,input:X(e.options.rootDir,o)});e.options.entries.splice(e.options.entries.indexOf(t),1)}},$9=e=>{for(const t of e)if(t==="node"||t==="workerd"||t.includes("node")||t.includes("workerd"))return!0;return!1},b9=e=>e.includes(".server")||e.includes(".node")||e.includes(".workerd"),w9=e=>{const t=e.exportKey&&[...e.exportKey].some(n=>n.includes("browser")||n==="browser"),r=e.fileAlias?.includes(".browser")??!1;if(t||r)return"browser";if(e.exportKey&&$9(e.exportKey)||e.fileAlias&&b9(e.fileAlias))return"node"},v9=e=>{for(const t of e.options.entries){if(t.runtime)continue;const r=w9(t);r&&(t.runtime=r)}},x9=e=>{for(const t of e.options.entries)if(t.fileAlias){let r=t.fileAlias;for(;r.startsWith("./")||r.startsWith("../");)r=r.replace(d9,"");t.name=r}},nm=e=>{h9(e),y9(e),v9(e),x9(e);for(const t of e.options.entries.filter(r=>!r.fileAlias))ou(t,e);for(const t of e.options.entries.filter(r=>r.fileAlias))ou(t,e),t.fileAlias=void 0},E9=/^[_$a-z\u00A0-\uFFFF][\w$\u00A0-\uFFFF]*$/iu,S9=(e,t)=>{const r=e.options.jiti.transformOptions?.babel?.plugins;return JSON.stringify({...e.options.jiti,alias:{...sn(e.pkg,e.options),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},void 0,2).replace('"__$BABEL_PLUGINS"',Array.isArray(r)?`[${r.map((n,o)=>{if(Array.isArray(n)){const[s,...i]=n;return t.push(s),`[${[`plugin${String(o)}`,...i.map(a=>JSON.stringify(a))].join(", ")}]`}return t.push(n),`plugin${String(o)}`}).join(",")}]`:"[]")},k9=e=>e.filter(t=>t!=="default").map((t,r)=>{if(E9.test(t))return`export const ${t} = _module.${t};`;const n=`__packem_export_${String(r)}`,o=t.startsWith("'")&&t.endsWith("'")?`_module[${t}]`:`_module[${JSON.stringify(t)}]`;return`const ${n} = ${o};
|
|
159
|
+
export { ${n} as ${JSON.stringify(t)} };`}),om=(e,t,r)=>{po(e,`export * from "${t}";
|
|
160
|
+
${r?`export { default } from "${t}";`:""}`)},j9=async(e,t,r,n,o,s,i,a,l,u)=>{const c=t(Z(r),await ap("jiti",{conditions:["node","import"],url:import.meta.url})),p=Ke(e,"esm"),f=`${o}.${p}`;po(`${r}.${Pe(e,"esm")}`,s+[`import { createJiti } from "${c}";`,...a.map((d,m)=>`import plugin${String(m)} from "${d}";`),"",`const jiti = createJiti(import.meta.url, ${i});`,"",`/** @type {import("${f}")} */`,`const _module = await jiti.import("${n}");`,...u?["export default _module?.default ?? _module;"]:[],...k9(l)].join(`
|
|
161
|
+
`)),e.options.declaration&&om(`${r}.${p}`,f,u)},A9=async(e,t,r,n,o,s,i,a,l)=>{const u=t(Z(r),await ap("jiti",{conditions:["node","require"],url:import.meta.url})),c=Ke(e,"cjs"),p=`${o}.${c}`;po(`${r}.${Pe(e,"cjs")}`,s+[`const { createJiti } = require("${u}");`,...a.map((f,d)=>`const plugin${String(d)} = require(${JSON.stringify(f)})`),"",`const jiti = createJiti(__filename, ${i});`,"",`/** @type {import("${p}")} */`,`module.exports = jiti("${n}")`].join(`
|
|
162
|
+
`)),e.options.declaration&&om(`${r}.${c}`,p,l)},O9=async e=>{const t=[],r=S9(e,t);for(const n of e.options.entries){const o=X(e.options.rootDir,e.options.outDir,n.name),s=Eh(e.jiti.esmResolve(n.input,{try:!0})??n.input),i=s.replace(Ki,""),a=Fi(s),l=h2(a);let u;try{u=await Sh(s,{extensions:ho})}catch(f){Y(e,`Cannot analyze ${s} for exports: ${String(f)}`);return}const c=u.includes("default")||u.length===0,p=e.options.jiti.absoluteJitiPath?(...f)=>kh(X(...f)):ke;e.options.emitESM&&await j9(e,p,o,s,i,l,r,t,u,c),e.options.emitCJS&&await A9(e,p,o,s,i,l,r,t,c),l&&(await _i(`${o}.${Pe(e,"cjs")}`),await _i(`${o}.${Pe(e,"esm")}`))}await e.hooks.callHook("rollup:done",e)},Ka=e=>e.logger,ao="rollup-watch.json",su=({context:e,doOnSuccessCleanup:t,fileCache:r,mode:n,runBuilder:o,runOnsuccess:s,useCache:i,watcher:a})=>{const l=`watcher:${n}`,u=Ka(e);a.on("change",async(c,{event:p})=>{try{await t?.()}catch(f){u.error({context:[f],message:`onSuccess cleanup failed: ${f.message}`,prefix:l})}u.info({message:`${ne(ke(".",c))} was ${p}d`,prefix:l})}),a.on("restart",()=>{u.info({message:"Rebuilding ...",prefix:l})}),a.on("event",async c=>{try{switch(c.code){case"BUNDLE_END":{await c.result.close(),i&&r.set(n==="bundle"?ao:`dts-${ao}`,c.result.cache),u.raw(`
|
|
163
|
+
⚡️ Build run in ${String(c.duration)}ms
|
|
164
|
+
|
|
165
|
+
`),await o?.(!0);break}case"BUNDLE_START":{u.info({message:ne("build started..."),prefix:l});break}case"END":{u.success({message:"Rebuild finished",prefix:l}),await s?.();break}case"ERROR":{np(c.error),u.error({context:[c.error],message:`Rebuild failed: ${c.error.message}`,prefix:l});break}}}catch(p){u.error({context:[p],message:`Watch handler failed: ${p.message}`,prefix:l})}})},R9=(e,t)=>{const r=[];Array.isArray(t.input)?r.push(...t.input):typeof t.input=="string"?r.push(t.input):r.push(...Object.keys(t.input??{}));let n="Starting watcher for entries:";for(const o of r)n+=De(`
|
|
166
|
+
└─ ${ke(process.cwd(),o)}`);Ka(e).info(n)},C9=(e,t,r)=>{const n=[G(e.options.sourceDir,"**","*"),"package.json","packem.config.*","tsconfig.json","tsconfig.*.json"],{include:o}=r;Array.isArray(o)?n.push(...o):o!==void 0&&n.push(o);const s=t.chokidar??{},i=["**/.git/**","**/node_modules/**","**/test-results/**",...s.ignored??[]];return{...t,...r,chokidar:{cwd:e.options.rootDir,...s,ignored:i},include:n}},T9=(e,t)=>{const r=e.options.rollup.watch;return!r||typeof t!="object"||t.include!==void 0?t:C9(e,t,r)},iu=e=>{const t=["**/.git/**","**/node_modules/**","**/test-results/**"],r=e.options.rollup.watch,n={exclude:t};return r&&typeof r=="object"&&(r.include!==void 0&&(n.include=r.include),r.exclude!==void 0&&t.push(...Array.isArray(r.exclude)?r.exclude:[r.exclude])),n},N9=async(e,t,r,n,o)=>{let s=[];const i=e.options.bundler==="rolldown",a=async()=>{await Promise.all(s.map(m=>m.close())),s=[]},l=async()=>{let m,h,$;if(i){const y=await Jl(),g=await Gd(e,t);if(await e.hooks.callHook("rollup:options",e,g),Object.keys(g.input??{}).length===0)return;g.watch=iu(e),m=y(g),h=g,$=!1}else{const y=await eu(),g=await Ud(e,t);if(await e.hooks.callHook("rollup:options",e,g),Object.keys(g.input??{}).length===0)return;g.cache=t.get(ao),g.watch=T9(e,g.watch),m=y(g),h=g,$=!0}if(await e.hooks.callHook("rollup:watch",e,m),R9(e,h),su({context:e,doOnSuccessCleanup:o,fileCache:t,mode:"bundle",runBuilder:r,runOnsuccess:n,useCache:$,watcher:m}),s.push(m),e.options.declaration){let y,g;if(i){const w=await Jl(),b=await Vd(e,t);await e.hooks.callHook("rollup:dts:options",e,b),b.watch=iu(e),y=w(b),g=!1}else{const w=await eu(),b=await Jd(e,t);b.cache=t.get(`dts-${ao}`),await e.hooks.callHook("rollup:dts:options",e,b),y=w(b),g=!0}await e.hooks.callHook("rollup:watch",e,y),su({context:e,fileCache:t,mode:"types",useCache:g,watcher:y}),s.push(y)}};await l();const u=G(e.options.rootDir,"package.json"),c=Kn.map(m=>G(e.options.rootDir,m));let p;const f=async(m,h)=>{const $=Ka(e);if(h){$.info({message:`${ke(".",m)} changed. Restart packem to apply configuration changes (the watcher cannot reload packem.config.* in place).`,prefix:"watcher"});return}$.info(`${ke(".",m)} changed, restarting watchers...`);try{await a();const{packageJson:y}=qo(e.options.rootDir);e.pkg=y,e.options.entries.length=0,e.buildEntries.length=0,await e.hooks.callHook("build:prepare",e),nm(e),await l()}catch(y){$.error({message:`Failed to restart watchers: ${y.message}`,prefix:"watcher"})}},d=(m,h)=>{clearTimeout(p),p=setTimeout(()=>{f(m,h).catch(()=>{})},100)};il(u,()=>{d(u,!1)});for(const m of c)if(rt(m)){il(m,()=>{d(m,!0)});break}},P9=async e=>{if(e.options.clean){const t=e.logger,r=[];for(const n of new Set(e.options.entries.map(o=>o.outDir).filter(Boolean).toSorted((o,s)=>o.localeCompare(s))))n===e.options.rootDir||n===e.options.sourceDir||e.options.rootDir.startsWith(n.endsWith("/")?n:`${n}/`)||r.some(o=>n.startsWith(o))||(r.push(n),t.info(`Cleaning dist directory: \`./${ke(e.options.rootDir,n)}\``),await Am(n))}},_9=()=>Yh((e,t,r)=>{if(t==="hooks"&&typeof r=="object"&&r!==null&&!Array.isArray(r)){const n=typeof e[t]=="object"&&e[t]!==null&&!Array.isArray(e[t])?e[t]:{};return e[t]={...n,...r},!0}return!1}),M9=Ze,I9=(e,t)=>{const{sideEffects:r}=t;let n;if(typeof r=="boolean")n=()=>r;else if(Array.isArray(r))if(r.length<=0)n=()=>!1;else{const o=r.map(s=>s.includes("/")?s:`**/${s}`);n=M9(o,void 0,{resolve:e})}else n=()=>{};return n};var ni,au;function W9(){if(au)return ni;au=1;var e=Xh,t=e.spawn,r=e.exec;ni=function(i,a,l){if(typeof a=="function"&&l===void 0&&(l=a,a=void 0),i=parseInt(i),Number.isNaN(i)){if(l)return l(new Error("pid must be a number"));throw new Error("pid must be a number")}var u={},c={};switch(u[i]=[],c[i]=1,process.platform){case"win32":r("taskkill /pid "+i+" /T /F",l);break;case"darwin":s(i,u,c,function(p){return t("pgrep",["-P",p])},function(){n(u,a,l)});break;default:s(i,u,c,function(p){return t("ps",["-o","pid","--no-headers","--ppid",p])},function(){n(u,a,l)});break}};function n(i,a,l){var u={};try{Object.keys(i).forEach(function(c){i[c].forEach(function(p){u[p]||(o(p,a),u[p]=1)}),u[c]||(o(c,a),u[c]=1)})}catch(c){if(l)return l(c);throw c}if(l)return l()}function o(i,a){try{process.kill(parseInt(i,10),a)}catch(l){if(l.code!=="ESRCH")throw l}}function s(i,a,l,u,c){var p=u(i),f="";p.stdout.on("data",function(h){var h=h.toString("ascii");f+=h});var d=function(m){if(delete l[i],m!=0){Object.keys(l).length==0&&c();return}f.match(/\d+/g).forEach(function(h){h=parseInt(h,10),a[i].push(h),a[h]=[],l[h]=1,s(h,a,l,u,c)})};p.on("close",d)}return ni}var B9=W9();const D9=Zr(B9),L9=e=>process.platform==="win32"&&"cmd"in e&&"code"in e&&typeof e.cmd=="string"&&e.cmd.startsWith("taskkill")&&e.code===128,F9=async({pid:e,signal:t})=>{await new Promise((r,n)=>{if(!Number.isInteger(e)||e<=0){n(new Error("Invalid process ID"));return}D9(e,t,o=>{if(o&&!L9(o)){n(o);return}r()})})},lu=(e,t)=>{if(e.warnings.size>0){const r=e.logger;if(t&&r.raw(`
|
|
167
|
+
`),r.warn(`Build is done with some warnings:
|
|
168
|
+
|
|
169
|
+
${Array.from(e.warnings,n=>`- ${n}`).join(`
|
|
170
|
+
`)}`),e.options.failOnWarn)throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")}},H9=async(e,t,r,n)=>{try{await $o(G(e,t),{force:!0,recursive:!0})}catch(o){return r.error({message:`Failed to remove cache directory ${t}: ${o instanceof Error?o.message:String(o)}`,prefix:"file-cache"}),n}return n&&r.raw(`
|
|
171
|
+
`),r.info({message:`Removing ${t} file cache, the cache key is not used anymore.`,prefix:"file-cache"}),!1},q9=async(e,t,r)=>{if(!e)return;const n=G(e,"keystore.json");if(!await Ct(n))return;const o=await fo(n),s=(await Oh(e,{withFileTypes:!0})).filter(a=>a.isDirectory());let i=r;for(const a of s)o[a.name]||(i=await H9(e,a.name,t,i))},cu=(e,t)=>{for(const r of bi(e??[]))if(typeof r=="string"&&r.startsWith("node")){const n=Le.coerce(r.slice(4));n&&t.push(n.version)}},J9=e=>{if(e.options.runtime!=="node"||!e.options.emitCJS)return;const t=[],r=e.pkg.engines?.node,n=r?Le.minVersion(r):void 0;n&&t.push(n.version);const o=e.options.rollup;if(cu(o.esbuild?.target,t),cu(o.oxc?.target,t),t.length===0){const s=Le.coerce(Fn.node);s&&t.push(s.version)}t.some(s=>Le.satisfies(s,">=23.0.0 || >=22.12.0"))&&e.logger.warn(["We recommend using the ESM format instead of CommonJS.","The ESM format is compatible with modern platforms and runtimes, and most new libraries are now distributed only in ESM format.","Learn more at https://nodejs.org/en/learn/modules/publishing-a-package#how-did-we-get-here"].join(`
|
|
172
|
+
`))},z9=Me(import.meta.url),Vt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:pt,Ya=e=>{if(typeof Vt<"u"&&Vt.versions&&Vt.versions.node){const[t,r]=Vt.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Vt.getBuiltinModule(e)}return z9(e)},pt=Vt,{execFileSync:U9}=Ya("node:child_process"),Ir=Ya("node:fs"),G9=Ya("node:tty"),Xa=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Za=[12288,12288,65281,65376,65504,65510],Qa=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],el=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Jo=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],pn=(e,t)=>{let r=0,n=Math.floor(e.length/2)-1;for(;r<=n;){const o=Math.floor((r+n)/2),s=o*2;if(t<e[s])n=o-1;else if(t>e[s+1])r=o+1;else return!0}return!1},V9=Xa[0],K9=Xa.at(-1),Y9=Za[0],X9=Za.at(-1),Z9=Qa[0],Q9=Qa.at(-1),e8=el[0],t8=el.at(-1),r8=Jo[0],n8=Jo.at(-1),uu=19968,[o8,s8]=i8(Jo);function i8(e){let t=e[0],r=e[1];for(let n=0;n<e.length;n+=2){const o=e[n],s=e[n+1];if(uu>=o&&uu<=s)return[o,s];s-o>r-t&&(t=o,r=s)}return[t,r]}const a8=e=>e<V9||e>K9?!1:pn(Xa,e),l8=e=>e<Y9||e>X9?!1:pn(Za,e),c8=e=>e<Z9||e>Q9?!1:pn(Qa,e),u8=e=>e<e8||e>t8?!1:pn(el,e),p8=e=>e>=o8&&e<=s8?!0:e<r8||e>n8?!1:pn(Jo,e);function f8(e){return a8(e)?"ambiguous":l8(e)?"fullwidth":c8(e)?"halfwidth":u8(e)?"narrow":p8(e)?"wide":"neutral"}function d8(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function sm(e){return d8(e),f8(e)}const im=String.raw,pu=im`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,m8=()=>new RegExp(im`\p{RI}{2}|(?)${pu}(?:\u200D${pu})*`,"gu"),mr=new Set(["\x1B",""]),zo="\x07",am="[",tl="m",lo="]8;;",h8=39,g8=/[\u200B\uFEFF\u2060-\u2064]/g,y8=new RegExp(`(?:\\${am}(?<code>\\d+)m|\\${lo}(?<uri>.*)${zo})`),$8=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),St=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,fu=/\u001B\[(\d+(?:;\d+)*)?m[^\u001B]*(?:\u001B\[(?:\d+(?:;\d+)*)?m|$)/g,du=/\u001B\]8;[^\u0007\u001B]*(?:\u0007|\u001B\\)(.*?)\u001B\]8;;(?:\u0007|\u001B\\)/g,xn=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,oi=m8(),mu=new Map,En=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Dn=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",b8=(e,t)=>{const r=Math.floor(e/65536),n=e%65536;let o=mu.get(r);if(o||(o=new Map,mu.set(r,o)),o.has(n))return o.get(n);let s;if(Dn(e)==="latin")s=t.width.regular;else if(Dn(e)==="control")s=t.width.control;else if(Dn(e)==="wide")s=t.width.wide;else switch(sm(e)){case"ambiguous":{s=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{s=t.width.fullWidth;break}case"wide":{s=t.width.wide;break}default:s=t.width.regular}return o.set(n,s),s},w8=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,sr=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?sr(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},n=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:o}=e,s=o>1e4;let i=0,a=0,l=o,u=!1;const c=e.includes("\x1B")||e.includes("");for(;i<o;){if(c&&(e[i]==="\x1B"||e[i]==="")){if(e.startsWith("\x1B]8;;",i)){const $="\x1B]8;;\x07",y=$.length,g=e.indexOf("\x07",i+5);if(g!==-1){const w=e.indexOf($,g+1);if(w!==-1){const b=w+y,v=e.slice(g+1,w).replace(St,""),S=sr(v,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,n-a),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),x=S.width;if(S.truncated)u=!0,l=Math.min(l,i);else if(a+x>n&&(l=Math.min(l,i),u=!0,a+x>r.truncation.limit))break;if(a+=x,i=b,u&&a>=r.truncation.limit)break;continue}}}if(St.lastIndex=i,St.test(e)){const $=St.lastIndex-i,y=r.truncation.countAnsiEscapeCodes?$:r.width.ansi;if(a+y>n&&(l=Math.min(l,i),a+y>r.truncation.limit)){u=!0;break}a+=y,i=St.lastIndex;continue}}const d=e.codePointAt(i);if(d===8203||d===65279||d>=8288&&d<=8292){i+=1;continue}if(d===9){if(a+r.width.tab>n&&(l=Math.min(l,i),a+r.width.tab>r.truncation.limit)){u=!0;break}a+=r.width.tab,i+=1;continue}if(En.lastIndex=i,En.test(e)){const $=(En.lastIndex-i)*r.width.regular;if(a+$>n){const y=Math.floor((n-a)/r.width.regular);if(l=Math.min(l,i+y),a+$>r.truncation.limit){u=!0;break}}a+=$,i=En.lastIndex;continue}if((d<=31||d>=127&&d<=159)&&(xn.lastIndex=i,xn.test(e))){const $=(xn.lastIndex-i)*r.width.control;if(a+$>n&&(l=Math.min(l,i+Math.floor((n-a)/r.width.control)),a+$>r.truncation.limit)){u=!0;break}a+=$,i=xn.lastIndex;continue}if(oi.lastIndex=i,oi.test(e)){if(a+r.width.emoji>n&&(l=Math.min(l,i),a+r.width.emoji>r.truncation.limit)){u=!0;break}a+=r.width.emoji,i=oi.lastIndex;continue}const m=e.codePointAt(i)??0;if(w8(m)){i+=m>65535?2:1;continue}let h;if(s)h=b8(m,r);else switch(Dn(m)){case"control":{h=r.width.control;break}case"latin":{h=r.width.regular;break}case"wide":{h=r.width.wide;break}case"zero":{h=0;break}default:switch(sm(m)){case"ambiguous":{h=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{h=r.width.fullWidth;break}case"wide":{h=r.width.wide;break}default:h=r.width.regular}}if(a+h>n&&(l=Math.min(l,i),a+h>r.truncation.limit)){u=!0;break}a+=h,i+=m>65535?2:1}let p=a,f=!1;return u&&r.truncation.limit>=r.truncation.ellipsisWidth&&(p=r.truncation.limit,f=!0),{ellipsed:f,index:u?l:o,truncated:u,width:p}},fe=(e,t={})=>sr(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width;let v8=class{capacity;cache;keyOrder;constructor(t){this.capacity=t,this.cache=new Map,this.keyOrder=[]}get(t){if(this.cache.has(t))return this.keyOrder=this.keyOrder.filter(r=>r!==t),this.keyOrder.push(t),this.cache.get(t)}has(t){return this.cache.has(t)}set(t,r){if(this.cache.has(t))this.keyOrder=this.keyOrder.filter(n=>n!==t);else if(this.cache.size>=this.capacity){const n=this.keyOrder.shift();n!==void 0&&this.cache.delete(n)}this.cache.set(t,r),this.keyOrder.push(t)}delete(t){this.cache.delete(t),this.keyOrder=this.keyOrder.filter(r=>r!==t)}clear(){this.cache.clear(),this.keyOrder=[]}size(){return this.cache.size}};const hu=new v8(100),x8=new Intl.Segmenter("en",{granularity:"grapheme"}),E8=/^[\u0000-\u007F]*$/,S8=new Set(["0","22","23","24","27","28","29","39","49"]),k8=new Set(["1","3","4","7","8","9"]),gu=new Map([["22","1"],["23","3"],["24","4"],["27","7"],["28","8"],["29","9"]]),Sn=e=>e>="30"&&e<="37"||e>="90"&&e<="97"||e.startsWith("38;"),kn=e=>e>="40"&&e<="47"||e>="100"&&e<="107"||e.startsWith("48;"),j8=[{close:"\x1B[22m",open:"\x1B[1m"},{close:"\x1B[23m",open:"\x1B[3m"},{close:"\x1B[24m",open:"\x1B[4m"},{close:"\x1B[27m",open:"\x1B[7m"},{close:"\x1B[28m",open:"\x1B[8m"},{close:"\x1B[29m",open:"\x1B[9m"}],yu=(e,t)=>{let r=-1;for(const n of t){const o=e.indexOf(n);o!==-1&&(r===-1||o<r)&&(r=o)}return r},A8=(e,t)=>{if(!e.includes("\x1B"))return[{after:"",before:"",content:e,visibleLength:fe(e,t.width)}];const r=hu.get(e);if(r)return r;const n=[],o=[];let s=0,i;for(St.lastIndex=0;(i=St.exec(e))!==null;){const c=i[0];n.push(e.slice(s,i.index)),o.push(c),s=i.index+c.length}s<e.length&&n.push(e.slice(s));const a=[];for(const c of o){if(c==="\x1B[0m"||c==="\x1B]8;;\x07"){a.push(c);continue}if(c.startsWith("\x1B[")&&c.endsWith("m")){const p=c.slice(2,-1);if(S8.has(p)){a.push(c);continue}}}const l=new Set,u=[];for(const[c,p]of n.entries()){if(c>0&&o[c-1]){const m=o[c-1];if(m==="\x1B[0m")l.clear();else if(m==="\x1B]8;;\x07"){for(const h of l)if(h.startsWith("\x1B]8;;")&&!h.endsWith("\x1B]8;;\x07")){l.delete(h);break}}else if(m.startsWith("\x1B[")&&m.endsWith("m")){const h=m.slice(2,-1);if(h==="39"){for(const $ of l)if($.startsWith("\x1B[")&&$.endsWith("m")){const y=$.slice(2,-1);if(Sn(y)){l.delete($);break}}}else if(h==="49"){for(const $ of l)if($.startsWith("\x1B[")&&$.endsWith("m")){const y=$.slice(2,-1);if(kn(y)){l.delete($);break}}}else if(gu.has(h)){const $=gu.get(h);for(const y of l)if(y===`\x1B[${$}m`){l.delete(y);break}}else{if(Sn(h)){for(const $ of l)if($.startsWith("\x1B[")&&$.endsWith("m")){const y=$.slice(2,-1);if(Sn(y)){l.delete($);break}}}else if(kn(h)){for(const $ of l)if($.startsWith("\x1B[")&&$.endsWith("m")){const y=$.slice(2,-1);if(kn(y)){l.delete($);break}}}else if(k8.has(h)){const $=`\x1B[${h}m`;l.has($)&&l.delete($)}l.add(m)}}else if(m.startsWith("\x1B]8;;")&&!m.endsWith("\x1B]8;;\x07")){for(const h of l)if(h.startsWith("\x1B]8;;")&&!h.endsWith("\x1B]8;;\x07")){l.delete(h);break}l.add(m)}}if(p==="")continue;let f="";if(l.size>0)if(a.includes("\x1B[0m"))f="\x1B[0m";else{const m=[];let h=!1;for(const w of l)if(w.startsWith("\x1B]8;;")&&!w.endsWith("\x1B]8;;\x07")){h=!0;break}h&&a.includes("\x1B]8;;\x07")&&m.push("\x1B]8;;\x07");let $=!1,y=!1;for(const w of l)if(w.startsWith("\x1B[")&&w.endsWith("m")){const b=w.slice(2,-1);Sn(b)?$=!0:kn(b)&&(y=!0)}if($&&y){const w=yu(e,["\x1B[3","\x1B[9","\x1B[38;"]),b=yu(e,["\x1B[4","\x1B[10","\x1B[48;"]);w>=0&&b>=0?w>b?m.push("\x1B[39m","\x1B[49m"):m.push("\x1B[49m","\x1B[39m"):m.push("\x1B[39m","\x1B[49m")}else $&&m.push("\x1B[39m"),y&&m.push("\x1B[49m");$&&y&&e.includes("\x1B[39m")&&e.includes("\x1B[49m")&&(e.indexOf("\x1B[39m")<e.indexOf("\x1B[49m")?(m.length-=2,m.push("\x1B[39m","\x1B[49m")):e.indexOf("\x1B[49m")<e.indexOf("\x1B[39m")&&(m.length-=2,m.push("\x1B[49m","\x1B[39m")));const g=j8.filter(w=>l.has(w.open)).map(w=>({position:e.indexOf(w.open),style:w})).filter(w=>w.position>=0).toSorted((w,b)=>b.position-w.position);for(const w of g){const b=w;a.includes(b.style.close)&&m.push(b.style.close)}f=m.join("")}const d=[...l].join("");u.push({after:f,before:d,content:p,visibleLength:fe(p,{fullWidth:1,wideWidth:1})})}return hu.set(e,u),u},O8=(e,t,r,n)=>{const o=[...n.segmenter.segment(e)],s=[];let i=0,a=!1;for(const l of o){const u=fe(l.segment,n.width),c=i,p=i+u;if(!a)if(c<t){i=p;continue}else a=!0;if(c>=r||p>r)break;s.push(l.segment),i=p}return s.join("")},ct=(e,t=0,r=Number.MAX_SAFE_INTEGER,n={})=>{const o={segmenter:x8,...n};if(t>=r||e==="")return"";const s=fe(e,o.width);if(t===0&&r>=s)return e;if(t<0||r<0)throw new RangeError("Negative indices aren't supported");if(!e.includes("\x1B"))return E8.test(e)?e.slice(t,r):O8(e,t,r,o);if(fu.lastIndex=0,du.lastIndex=0,!fu.test(e)&&!du.test(e))return e;const i=A8(e,o);if(i.length===0)return"";let a=0;const l=[];for(const[p,f]of i.entries()){const d=a,m=a+f.visibleLength;if(m>t&&d<r){const h=Math.max(0,t-d),$=Math.min(f.visibleLength,r-d);l.push({end:$,index:p,segment:f,start:h})}a=m}if(l.length===0)return"";const u=[],c=l[0].segment;u.push(c.before);for(let p=0;p<l.length;p++){const{end:f,segment:d,start:m}=l[p];if(m===0&&f===d.visibleLength)u.push(d.content);else{const h=[...o.segmenter.segment(d.content)];u.push(h.slice(m,f).map($=>$.segment).join(""))}if(p<l.length-1){const h=l[p+1].segment,$=d.after,y=h.before;$!==y&&($||y)&&u.push($,y)}}return u.push(l.at(-1).segment.after),u.join("")},$u="…",R8=3,jn=(e,t,r=!1)=>{if(e.charAt(t)===" ")return t;const n=r?1:-1,o=Math.min(R8,r?e.length-t:t);for(let s=1;s<=o;s++){const i=t+s*n;if(e.charAt(i)===" ")return i}return t},An=(e,t,r)=>sr(e,{...r,ellipsis:"",ellipsisWidth:0,limit:t}).index,On=(e,t,r)=>fe(e.slice(0,t),r),bu=(e,t,r={})=>{if(typeof e!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof e}`);if(typeof t!="number")throw new TypeError(`Expected \`limit\` to be a number, got ${typeof t}`);if(e===""||t<=0)return"";const n=e.normalize("NFC"),{ellipsis:o=$u,position:s="end",preferTruncationOnSpace:i=!1}=r;let a=r.ellipsisWidth??o===$u?1:void 0;a??=sr(o,{...r.width,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width;const{width:l}=sr(n,{...r.width,ellipsis:o,ellipsisWidth:a});if(l<=t)return n;switch(s){case"end":{if(i){const u=t-a,c=An(n,u,r.width),p=jn(n,c),f=On(n,p,r.width);return ct(n,0,f,{width:r.width})+o}return ct(n,0,t-a,{width:r.width})+o}case"middle":{const u=Math.floor(t/2),c=Math.max(0,t-a),p=Math.min(u,c),f=Math.max(0,c-p);if(i){const d=An(n,p,r.width),m=jn(n,d),h=On(n,m,r.width),$=l-f,y=An(n,$,r.width),g=jn(n,y,!0),w=On(n,g,r.width);return ct(n,0,h,{width:r.width})+o+ct(n,w,l,{width:r.width}).trim()}return ct(n,0,p,{width:r.width})+o+ct(n,l-f,l,{width:r.width})}case"start":{if(i){const u=l-t+a,c=An(n,u,r.width),p=jn(n,c,!0),f=On(n,p,r.width);return o+ct(n,f,l,{width:r.width}).trim()}return o+ct(n,l-t+a,l,{width:r.width})}default:throw new Error(`Invalid position: expected 'start', 'middle' or 'end', got '${s}'`)}},C8=/\x1B\[(\d+)m/;class lm{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const r=C8.exec(t);if(!r)return;const n=Number.parseInt(r[1],10);switch(n){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(n>=30&&n<=37||n>=90&&n<=97)this.activeForeground=t;else if(n>=40&&n<=47||n>=100&&n<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(n))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(n)){const o={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[n];o&&(this.activeFormatting=this.activeFormatting.filter(s=>!s.includes(o)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const r={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(n=>{const o=r[n];o&&t.push(o)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}}const cm=(e,t)=>{if(!mr.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const r=!0,n=e.slice(t+1,t+1+lo.length).join("")===lo;return{isInsideEscape:r,isInsideLinkEscape:n}},T8=(e,t={})=>{const r=new lm;let n="",o=!1,s="",i="",a=!1;const l=[...e];for(let u=0;u<l.length;u++){const c=l[u];if(c&&mr.has(c)){if(n){const h=t.getWidth?.(n)??0,$={isEscapeSequence:!1,isGrapheme:!0,text:n,width:h};if(a&&($.isHyperlink=!0,$.hyperlinkUrl=i),t.onSegment?.($,r)===!1)return;n=""}o=!0,s=c;const d=cm(l,u),{isInsideLinkEscape:m}=d;if(m){let h=u+1;for(i="";h<l.length;){const y=l[h];if(y===zo)break;i+=y,h+=1}i=i.slice(4);const $={hyperlinkUrl:i,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.($,r)===!1)return;u=h,a=!0,o=!1,s="";continue}if(u+1<l.length&&l[u+1]==="\\"&&a){const h={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(h,r)===!1)return;a=!1,i="",u+=1,o=!1,s="";continue}}if(o){if(s!==c&&(s+=c),c===tl){o=!1,r.processEscape(s);const d={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};if(t.onSegment?.(d,r)===!1)return;s=""}continue}n+=c;const p=t.getWidth?.(n)??0,f={isEscapeSequence:!1,isGrapheme:!0,text:n,width:p};if(a&&(f.isHyperlink=!0,f.hyperlinkUrl=i),t.onSegment?.(f,r)===!1)return;n=""}if(n){const u=t.getWidth?.(n)??0,c={isEscapeSequence:!1,isGrapheme:!0,text:n,width:u};a&&(c.isHyperlink=!0,c.hyperlinkUrl=i),t.onSegment?.(c,r)}if(s){const u={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};t.onSegment?.(u,r)}},wu=e=>`${mr.values().next().value}${am}${String(e)}${tl}`,vu=e=>`${mr.values().next().value}${lo}${e}${zo}`,N8=e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",r,n;const o=e.join(`
|
|
173
|
+
`),s=[...o];let i=0;for(const[a,l]of s.entries()){if(t+=l,mr.has(l)){const c=y8.exec(o.slice(i))?.groups??{};if(c.code!==void 0){const p=Number.parseFloat(c.code);r=p===h8?void 0:p}else c.uri!==void 0&&(n=c.uri.length===0?void 0:c.uri)}const u=$8.get(Number(r));s[a+1]===`
|
|
174
|
+
`?(n&&(t+=vu("")),r&&u&&(t+=wu(u))):l===`
|
|
175
|
+
`&&(r&&u&&(t+=wu(r)),n&&(t+=vu(n))),i+=l.length}return t},um=/(?=\s)|(?<=\s)/,pm=/^\s+$/,si=e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},Rt=e=>{const t=e.split(" ");let r=t.length;for(;r>0&&fe(t[r-1])===0;)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},fm=(e,t,r)=>{if(e.length===0)return[""];if(t<=0)return[e];const n=[],o=new lm;let s="",i=0,a=!1,l=!1,u="",c=0;for(;c<e.length;){const p=e[c];if(mr.has(p)){a=!0,u=p,s+=p,l=cm([...e],c).isInsideLinkEscape,c+=1;continue}if(a){u+=p,s+=p,l?p===zo&&(a=l=!1):p===tl&&(a=!1,o.processEscape(u)),c+=1;continue}const f=fe(p),d=p===" ";if(f===0){s+=p,c+=1;continue}if(i+f>t&&(s&&n.push(s+o.getEndEscapesForAllActiveAttributes()),s=o.getStartEscapesForAllActiveAttributes(),i=fe(s),d&&r)){for(;c<e.length&&e[c]===" ";)c+=1;continue}if(s+=p,i+=f,i===t&&c<e.length-1&&(n.push(s+o.getEndEscapesForAllActiveAttributes()),s=o.getStartEscapesForAllActiveAttributes(),i=fe(s),c+1<e.length&&e[c+1]===" "&&r)){for(c+=1;c<e.length&&e[c]===" ";)c+=1;continue}c+=1}return s&&n.push(s+o.getEndEscapesForAllActiveAttributes()),r?n.map(p=>Rt(p)):n},P8=(e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=[];let s="",i=0;return T8(n,{getWidth:fe,onSegment:(a,l)=>{const u=a.text??"";if(a.isEscapeSequence)s+=u;else{const c=u===" ";if(a.width===0)return s+=u,!0;if(i+a.width>t&&(s&&o.push(s),s=l.getStartEscapesForAllActiveAttributes(),i=0,c))return r||o.push(l.getStartEscapesForAllActiveAttributes()+u),!0;s+=u,i+=a.width}return!0}}),s&&o.push(s),r?o.map(a=>Rt(a)):o},_8=(e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=n.split(um),s=[];let i="",a=0,l=0;for(;l<o.length;){const u=o[l],c=pm.test(u),p=fe(u);if(u.length===0){l+=1;continue}if(r&&c&&a===0){l+=1;continue}if(a+p>t&&a>0){r?s.push(Rt(i)):s.push(i),i="",a=0;continue}i+=u,a+=p,l+=1}return i&&(r?s.push(Rt(i)):s.push(i)),s},M8=(e,t,r)=>{if(e.length===0)return[];const n=r?e.trim():e;if(n.length===0)return[];const o=n.split(um),s=[];let i="",a=0,l=0;for(;l<o.length;){const u=o[l],c=pm.test(u),p=fe(u);if(u.length===0){l+=1;continue}if(r&&c&&a===0){l+=1;continue}if(p>t){i&&s.push(si(r?Rt(i):i));const f=fm(u,t,r);if(f.length>0){for(let d=0;d<f.length-1;d+=1)s.push(f[d]);i=f.at(-1),a=fe(i)}else i="",a=0;l+=1;continue}if(a+p>t&&a>0&&(s.push(si(r?Rt(i):i)),i="",a=0,r&&c)){l+=1;continue}i+=u,a+=p,l+=1}return i&&s.push(si(r?Rt(i):i)),s},Rn={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},I8=(e,t={})=>{const{removeZeroWidthCharacters:r=!0,trim:n=!0,width:o=80,wrapMode:s=Rn.PRESERVE_WORDS}=t;if(n&&e.trim()==="")return"";let i=e.normalize("NFC").replaceAll(`\r
|
|
176
|
+
`,`
|
|
177
|
+
`);return r&&(i=i.replaceAll(g8,"")),i.split(`
|
|
178
|
+
`).map(a=>{if(n&&a.trim()==="")return"";let l;switch(s){case Rn.BREAK_AT_CHARACTERS:{l=P8(a,o,n);break}case Rn.BREAK_WORDS:{l=M8(a,o,n);break}case Rn.STRICT_WIDTH:{l=fm(a,o,n);break}default:l=_8(a,o,n)}return N8(l)}).join(`
|
|
179
|
+
`)},dm=80,mm=24,Wi=(e,t,{shell:r,env:n}={})=>U9(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:r,env:n}).trim(),Ln=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),hm=(e,t)=>{const{columns:r,rows:n}=Ln(e,t);if(!(Number.isNaN(r)||Number.isNaN(n))&&!(r===dm&&n===mm))return{columns:r,rows:n}},W8=()=>{if(pt.platform!=="linux")return!0;try{const e=Ir.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const r=e.slice(t+2).trim().split(/\s+/),n=Number.parseInt(r[2],10),o=Number.parseInt(r[5],10);return Number.isNaN(n)||Number.isNaN(o)||o<=0?!1:n===o}catch{return!1}};function B8(){const{env:e,stdout:t,stderr:r}=pt;if(t?.columns&&t?.rows)return Ln(t.columns,t.rows);if(r?.columns&&r?.rows)return Ln(r.columns,r.rows);if(e.COLUMNS&&e.LINES)return Ln(e.COLUMNS,e.LINES);const n={columns:dm,rows:mm};return pt.platform==="win32"?ii()??n:pt.platform==="darwin"?xu()??ii()??n:xu()??ii()??D8()??n}const xu=()=>{try{const e=pt.platform==="darwin"?Ir.constants.O_EVTONLY|Ir.constants.O_NONBLOCK:Ir.constants.O_NONBLOCK,{columns:t,rows:r}=G9.WriteStream(Ir.openSync("/dev/tty",e));return{columns:t,rows:r}}catch{}},ii=()=>{try{const e=Wi("tput",["cols"],{env:{TERM:"dumb",...pt.env}}),t=Wi("tput",["lines"],{env:{TERM:"dumb",...pt.env}});if(e&&t)return hm(e,t)}catch{}},D8=()=>{try{if(!W8())return;const e=Wi("resize",["-u"]).match(/\d+/g);if(e.length===2)return hm(e[0],e[1])}catch{}},Lt=(e,t)=>{switch(t){case"bottom":return{body:e.bottomBody,join:e.bottomJoin,left:e.bottomLeft,right:e.bottomRight};case"middle":return{body:e.joinBody,join:e.joinJoin,left:e.joinLeft,right:e.joinRight};case"top":return{body:e.topBody,join:e.topJoin,left:e.topLeft,right:e.topRight};default:throw new Error(`Invalid borderType: ${String(t)}`)}},L8=e=>({join:e.bodyJoin,left:e.bodyLeft,right:e.bodyRight}),co=(e,t,r)=>{let n=0;for(let o=0;o<r;o+=1)n+=e[t+o]??0;return r>1&&(n+=r-1),n},Bi=(e,t,r,n)=>{let o=t;for(;o>0&&e[o-1]?.[r]===n;)o-=1;let s=t;for(;s<e.length-1&&e[s+1]?.[r]===n;)s+=1;let i;const a=s-o+1;if(a===1)i=!0;else switch(n.vAlign){case"bottom":{i=t===s;break}case"middle":{const l=o+Math.floor(a/2);i=t===l;break}case"top":{i=t===o;break}default:i=t===o}return{firstRow:o,lastRow:s,showContent:i}},F8=(e,t,r,n,o)=>{if(e.length===0)return[];let s=e.length-1;for(let l=0;l<e.length;l+=1){const u=e[l];if(u){for(const[c,p]of u.entries())if(p&&o(e,l,c,p)===l){const f=Bi(e,l,c,p);s=Math.max(s,f.lastRow)}}}const i=Array.from({length:s+1}).fill(1);for(let l=0;l<e.length;l+=1){const u=e[l];if(u)for(let c=0;c<r.columns;c+=1){const p=u[c];if(p&&o(e,l,c,p)===l&&(p.rowSpan??1)===1){const f=p.colSpan??1,d=co(t,c,f),m=n(p,d).length;i[l]=Math.max(i[l]??1,m)}}}const a=Array.from({length:i.length}).fill(!1);if(r.fixedRowHeights)for(let l=0;l<i.length;l+=1){let u;r.fixedRowHeights[l]!==void 0?u=r.fixedRowHeights[l]:r.fixedRowHeights.length===1&&r.fixedRowHeights[0]!==void 0&&(u=r.fixedRowHeights[0]),u!==void 0&&(i[l]=Math.max(1,u),a[l]=!0)}for(let l=0;l<e.length;l+=1){const u=e[l];if(u)for(let c=0;c<r.columns;c+=1){const p=u[c];if(p&&o(e,l,c,p)===l&&(p.rowSpan??1)>1){const f=p.colSpan??1,d=co(t,c,f),m=n(p,d).length-1,h=Bi(e,l,c,p),{firstRow:$,lastRow:y}=h;let g=0,w=0;for(let v=$;v<=y&&v<i.length;v+=1)g+=i[v]??1,a[v]||(w+=1);const b=m-g;if(b>0)if(w>0){const v=Math.ceil(b/w);let S=0;for(let x=$;x<=y&&x<i.length;x+=1)if(!a[x]){const E=Math.min(v,b-S);if(i[x]=(i[x]??1)+E,S+=E,S>=b)break}}else console.warn(`[calculateRowHeights] Content of spanning cell exceeds fixed height allocated. Cell: ${JSON.stringify(p.content)}, Required: ${String(m)}, Allocated: ${String(g)} (fixed).`)}}}return i},Ft=(e,t,r,n)=>{let o=t;for(;o>0&&e[o-1]?.[r]===n;)o-=1;return o},Di="__EMPTY__",Eu=e=>{if(typeof e=="string")return{content:e};if(typeof e=="number"||typeof e=="bigint"||typeof e=="boolean")return{content:String(e)};if(e==null)return{content:Di};if(typeof e=="object"&&"content"in e){let{content:t}=e;if(typeof t=="number"||typeof t=="bigint"||typeof t=="boolean")t=String(t);else if(t==null)t=Di;else if(typeof t!="string")throw new TypeError(`Invalid item type in grid cell: expected string, number, null, undefined, or GridItem object, but received ${JSON.stringify(e)} (type: ${typeof e})`);return{...e,content:t}}throw new TypeError(`Invalid item type in grid cell: expected string, number, null, undefined, or GridItem object, but received ${JSON.stringify(e)} (type: ${typeof e})`)},H8=(e,t,r,n,o)=>{const s=fe(e),i=" ".repeat(Math.max(0,n)),a=" ".repeat(Math.max(0,o));if(s===0)return i+" ".repeat(Math.max(0,t))+a;const l=Math.max(0,t-s);switch(r){case"center":{const u=Math.floor(l/2),c=l-u;return i+" ".repeat(u)+e+" ".repeat(c)+a}case"right":return i+" ".repeat(l)+e+a;default:return i+e+" ".repeat(l)+a}},Cr=/\r?\n/,Su=/\s+/,re=(e,t)=>!e||!t?e:typeof t=="function"?t(e):t.open+e+t.close;class rl{#e;#o=[];#t;#s=new WeakMap;#r=new WeakMap;static createGridLayout(){return[]}constructor(t){const r={autoColumns:1,autoFlow:"row",autoRows:1,balancedWidths:!1,gap:0,paddingLeft:1,paddingRight:1,rows:0,showBorders:t.border!==void 0,truncate:!1,truncateOverflow:!0,wordWrap:!1};let n;Array.isArray(t.fixedRowHeights)?n=t.fixedRowHeights:typeof t.fixedRowHeights=="number"&&(n=[t.fixedRowHeights]),this.#e={...r,...t,columns:t.columns,fixedRowHeights:n,showBorders:t.border!==void 0||(t.showBorders??!1)};let{terminalWidth:o}=this.#e;if(o===void 0){const{columns:s}=B8();o=s}this.#t=o,this.#e.maxWidth&&(this.#e.maxWidth=Math.min(this.#e.maxWidth,this.#t))}addItem(t){return this.#o.push(Eu(t)),this}addItems(t){return this.#o.push(...t.map(r=>Eu(r))),this}setColumns(t){return this.#e.columns=t,this}setRows(t){return this.#e.rows=t,this}setBorder(t){return this.#e.border=t,this}setShowBorders(t){return this.#e.showBorders=t,this}setMaxWidth(t){return this.#e.maxWidth=t,this}toString(){const t=rl.createGridLayout();if(this.placeItems(t),t.length===0||t[0]?.length===0)return"";let r=this.calculateColumnWidths(t);const n=this.calculateTotalGridWidth(r),o=typeof this.#e.maxWidth=="number"&&this.#e.maxWidth>0?Math.min(this.#e.maxWidth,this.#t):this.#t;return n>o&&(r=this.adjustColumnWidthsForTerminal(r,n)),this.renderGrid(t,r)}placeItems(t){let r=0,n=0;const o=this.#e.rows>0?this.#e.rows:Number.POSITIVE_INFINITY;for(let s=0;s<this.#o.length;s+=1){const i=this.#o[s];if(i.content===Di&&!(i.rowSpan&&i.rowSpan>1)&&!(i.colSpan&&i.colSpan>1)){if(this.#e.autoFlow==="row")n+=1,n>=this.#e.columns&&(n=0,r+=1);else{r+=1;const m=t.length>0?t.length:o;r>=m&&m!==Number.POSITIVE_INFINITY?(r=0,n+=1):t.length===0&&m===Number.POSITIVE_INFINITY&&(n+=1)}continue}const a=i.colSpan??1,l=i.rowSpan??1;let u=!1,c=r,p=n,f=0;const d=(t.length+l+5)*this.#e.columns;for(;!u&&c<o&&f<d;){for(f+=1;c+l>t.length;)t.push(Array.from({length:this.#e.columns}).fill(void 0));if(this.canPlaceItem(t,c,p,a,l))if(this.placeItem(t,c,p,i),u=!0,this.#e.autoFlow==="row")n=p+a,r=c,n>=this.#e.columns&&(n=0,r+=1);else{r=c+l,n=p;const m=t.length>0?t.length:o;r>=m&&(r=0,n+=1)}else if(this.#e.autoFlow==="row")p+=1,p>=this.#e.columns&&(p=0,c+=1);else{for(c+=1;c+l>t.length;)t.push(Array.from({length:this.#e.columns}).fill(void 0));const m=t.length>0?t.length:o;if(c>=m&&(c=0,p+=1,p>=this.#e.columns))break}}if(!u)if(console.warn(`@visulima/tabular: Could not find position for item: ${JSON.stringify(i)} after ${String(f)} attempts. Grid might be too small or layout impossible.`),this.#e.autoFlow==="row")n+=1,n>=this.#e.columns&&(n=0,r+=1);else{r+=1;const m=t.length>0?t.length:o;r>=m&&(r=0,n+=1)}if(f>=d)break}if(this.#e.rows===0)for(;t.length>0&&t.at(-1)?.every(s=>s===void 0);)t.pop()}canPlaceItem(t,r,n,o,s,i=!1){if(n+o>this.#e.columns)return!1;for(let a=r;a<r+s;a+=1)if(a<t.length){if(!t[a])return console.warn(`Grid layout unexpectedly missing row ${String(a)} during canPlaceItem check.`),!1;for(let l=n;l<n+o;l+=1)if(t[a]?.[l]!==void 0)return!1}else if(!i)return!1;return!0}computeWrappedContentWidth(t,r,n,o){let s=t;if(o){if(s>20){let i=0;for(const a of r){const l=a.split(Su);for(const u of l)i=Math.max(i,Math.min(fe(u),n))}s=Math.min(s,Math.max(i+4,12))}}else{let i=0;for(const a of r){const l=a.split(Su);for(const u of l)i=Math.max(i,Math.min(fe(u),n))}s=Math.min(s,Math.max(i+12,20))}return s}placeItem(t,r,n,o){const s=o.rowSpan??1,i=o.colSpan??1;for(let a=r;a<r+s;a+=1){for(;a>=t.length;)t.push(Array.from({length:this.#e.columns}).fill(void 0));for(let l=n;l<n+i;l+=1)l<this.#e.columns&&(t[a]||(console.error(`Logic error: Row ${String(a)} not found in placeItem despite check.`),t[a]=Array.from({length:this.#e.columns}).fill(void 0)),t[a][l]=o)}}calculateTotalGridWidth(t){let r=0;const n=this.#e.showBorders?this.#e.border:void 0;n&&(r+=n.bodyLeft.width,r+=n.bodyRight.width);const o=t.length,s=this.#e.showBorders?n?.bodyJoin.width??0:0,i=this.#e.gap;for(let a=0;a<o;a+=1)r+=t[a]??0,a<o-1&&(r+=i,r+=s);return r}adjustColumnWidthsForTerminal(t,r){const n=typeof this.#e.maxWidth=="number"&&this.#e.maxWidth>0?Math.min(this.#e.maxWidth??0,this.#t):this.#t;if(r<=n)return t;let o=0;const s=t.length,i=this.#e.showBorders?this.#e.border:void 0;if(i&&(o+=i.bodyLeft.width,o+=i.bodyRight.width),s>1){o+=(s-1)*this.#e.gap;const p=i?.bodyJoin.width??0;o+=(s-1)*p}if(o>=n)return Array.from({length:s}).fill(1);const a=n-o,l=t.reduce((p,f)=>p+f,0);if(l===0){const p=Math.floor(a/s);return Array.from({length:s}).fill(p)}const u=t.map(p=>{const f=p/l;return Math.max(1,Math.floor(a*f))});let c=a-u.reduce((p,f)=>p+f,0);if(c>0){const p=u.map((f,d)=>{const m=l>0?(t[d]??0)/l:1/s;return{index:d,remainder:a*m%1}}).toSorted((f,d)=>d.remainder-f.remainder);for(const f of p){if(c<=0)break;const{index:d}=f;u[d]!==void 0&&(u[d]+=1,c-=1)}}return u}calculateBalancedColumnWidths(t){const r=this.calculateMinimumColumnWidthsWithGrowableInfo(t),n=r.widths,{growableColumns:o}=r,s=typeof this.#e.maxWidth=="number"&&this.#e.maxWidth>0?Math.min(this.#e.maxWidth,this.#t):this.#t,i=this.#e.showBorders?this.#e.border:void 0;let a=0;if(i&&(a+=i.bodyLeft.width,a+=i.bodyRight.width),this.#e.columns>1){a+=(this.#e.columns-1)*this.#e.gap;const c=i?.bodyJoin.width??0;a+=(this.#e.columns-1)*c}const l=Math.max(0,s-a);if(n.reduce((c,p)=>c+p,0)>0){const c=Math.floor(l/this.#e.columns),p=Array.from({length:this.#e.columns}).fill(c),f=c*this.#e.columns;let d=l-f;for(let y=0;y<p.length&&d>0;y+=1)p[y]=(p[y]??0)+1,d-=1;const m=[];let h=0;for(let y=0;y<this.#e.columns;y+=1){const g=p[y]??0,w=n[y]??0,b=Math.max(g,w);m.push(b),h+=b}if(h>l){const y=l/h,g=m.map(v=>Math.max(3,Math.floor(v*y))),w=g.reduce((v,S)=>v+S,0);let b=l-w;for(let v=0;v<g.length&&b>0;v+=1)g[v]=(g[v]??0)+1,b-=1;return g}let $=l-h;if($>0){const y=o.length>0?o:m.map((g,w)=>w);for(;$>0&&y.length>0;)for(const g of y){if($<=0)break;m[g]=(m[g]??0)+1,$-=1}}return m}const u=Math.floor(l/this.#e.columns);return Array.from({length:this.#e.columns}).fill(u)}calculateMinimumColumnWidthsWithGrowableInfo(t){const r=Array.from({length:this.#e.columns}).fill(0),n=[],o=this.#e.paddingLeft+this.#e.paddingRight,s=this.#e.gap+(this.#e.showBorders?this.#e.border?.bodyJoin.width??0:0);for(let i=0;i<this.#e.columns;i+=1)for(let a=0;a<t.length;a+=1){const l=t[a]?.[i];if(!l||Ft(t,a,i,l)!==a||i>0&&t[a]?.[i-1]===l)continue;const u=l.colSpan??1,c=l.maxWidth??Number.POSITIVE_INFINITY,p=String(l.content??"").split(Cr),f=this.#e.wordWrap&&l.wordWrap!==!1;let d=0;for(const m of p)d=Math.max(d,Math.min(fe(m),c));d=this.computeWrappedContentWidth(d,p,c,f),u===1&&(r[i]=Math.max(r[i]??0,d+o),f&&!n.includes(i)&&n.push(i))}for(let i=0;i<t.length;i+=1)for(let a=0;a<this.#e.columns;a+=1){const l=t[i]?.[a];if(!l||Ft(t,i,a,l)!==i||a>0&&t[i]?.[a-1]===l)continue;const u=l.colSpan??1;if(u>1){const c=l.maxWidth??Number.POSITIVE_INFINITY,p=String(l.content??"").split(Cr),f=this.#e.wordWrap&&l.wordWrap!==!1;let d=0;for(const y of p)d=Math.max(d,Math.min(fe(y),c));d=this.computeWrappedContentWidth(d,p,c,f);const m=(u-1)*s,h=d+o+m;let $=0;for(let y=a;y<a+u;y+=1)$+=r[y]??0;if(h>$){const y=h-$,g=Math.ceil(y/u);for(let w=0;w<u&&a+w<this.#e.columns;w+=1)r[a+w]=Math.max(r[a+w]??0,g)}}}return{growableColumns:n,widths:r}}calculateColumnWidths(t){if(this.#e.fixedColumnWidths&&this.#e.fixedColumnWidths.length===this.#e.columns){const s=this.#e.fixedColumnWidths;if(!s.some(i=>i===void 0||!Number.isFinite(i)))return[...s];if(this.#e.balancedWidths){const i=Array.from({length:s.length}).fill(0),a=typeof this.#e.maxWidth=="number"&&this.#e.maxWidth>0?Math.min(this.#e.maxWidth,this.#t):this.#t,l=this.calculateTotalGridWidth(Array.from({length:i.length}).fill(0)),u=Math.max(0,a-l);let c=0;const p=[];for(const[m,h]of s.entries())typeof h=="number"&&Number.isFinite(h)?(i[m]=h,c+=h):p.push(m);let f=Math.max(0,u-c);const d=p.length>0?Math.floor(f/p.length):0;for(const m of p)i[m]=d;f-=d*p.length;for(const m of p){if(f<=0)break;i[m]+=1,f-=1}return i}}if(this.#e.balancedWidths)return this.calculateBalancedColumnWidths(t);const r=Array.from({length:this.#e.columns}).fill(0),n=this.#e.paddingLeft+this.#e.paddingRight,o=this.#e.gap+(this.#e.showBorders?this.#e.border?.bodyJoin.width??0:0);for(let s=0;s<this.#e.columns;s+=1)for(let i=0;i<t.length;i+=1){const a=t[i]?.[s];if(!a||Ft(t,i,s,a)!==i||s>0&&t[i]?.[s-1]===a)continue;const l=a.colSpan??1,u=a.maxWidth??Number.POSITIVE_INFINITY,c=String(a.content??"").split(Cr);let p=0;for(const f of c)p=Math.max(p,Math.min(fe(f),u));l===1&&(r[s]=Math.max(r[s]??0,p+n))}for(let s=0;s<t.length;s+=1)for(let i=0;i<this.#e.columns;i+=1){const a=t[s]?.[i];if(!a||Ft(t,s,i,a)!==s||i>0&&t[s]?.[i-1]===a)continue;const l=a.colSpan??1;if(l>1){const u=a.maxWidth??Number.POSITIVE_INFINITY,c=String(a.content??"").split(Cr),p=this.#e.wordWrap&&a.wordWrap!==!1;let f=0;for(const y of c)f=Math.max(f,Math.min(fe(y),u));f=this.computeWrappedContentWidth(f,c,u,p);let d=0;for(let y=i;y<i+l;y+=1)d+=r[y]??0;const m=l>1?(l-1)*o:0,h=f+n+m,$=d+m;if(h>$){const y=h-$,g=Math.floor(y/l);let w=0;for(let b=0;b<l&&i+b<this.#e.columns;b+=1){const v=Math.min(g,y-w);if(r[i+b]=(r[i+b]??0)+v,w+=v,w>=y)break}}}}if(this.#e.maxWidth){const s=this.calculateTotalGridWidth(r);if(s>this.#e.maxWidth)return this.adjustColumnWidthsForTerminal(r,s)}return r}renderVisualRowContent(t,r,n,o,s){const i=t[r];if(!i)return"";const a=this.#e.borderColor??this.#e.foregroundColor??void 0,l=[],u=this.#e.showBorders&&this.#e.border?L8(this.#e.border):void 0,c=u&&u.left.width>0?u.left.char:"",p=u&&u.right.width>0?u.right.char:"",f=u&&u.join.width>0?u.join.char:"",d=" ".repeat(this.#e.gap);c&&l.push(re(re(c,a),this.#e.backgroundColor));let m=0;for(;m<this.#e.columns;){const h=i[m]??void 0;let $=1,y;if(h){const g=h.colSpan??1;$=g;const w=Ft(t,r,m,h),b=co(o,m,g),v=this.alignCellContent(h,b),S=v.length,x=this.getCachedCellVerticalPosition(t,r,m,h);x.firstRow!==w&&console.warn(`Mismatch between findFirstOccurrenceRow (${String(w)}) and determineCellVerticalPosition (${String(x.firstRow)})`);const E=s.slice(w,x.lastRow+1).reduce((J,N)=>J+N,0),j=x.lastRow-x.firstRow+1;let k=n,R=0;for(let J=w;J<r;J+=1)J<s.length&&(k+=s[J]??1),J<x.lastRow&&(R+=1);k+=R;const P=h.vAlign??"top";let z;switch(P){case"bottom":{let J=n;for(let O=w;O<r;O+=1)J+=s[O]??1;const N=E-S;z=J>=N?J-N:-1;break}case"middle":{const J=Math.round((E-S)/2);let N=n;for(let O=w;O<r;O+=1)N+=s[O]??1;z=N>=J&&N<J+S?N-J:-1;break}case"top":{z=k;break}default:z=k}const U=z>=0&&z<S;if(y=" ".repeat(Math.max(0,b)),U){let J=!1;P==="middle"&&j%2===0&&z===0&&(J=!0),J||(y=v[z]??y)}h.colSpan&&h.colSpan>1&&(y+=d.repeat(h.colSpan)),h.foregroundColor?y=re(y,h.foregroundColor):this.#e.foregroundColor&&(y=re(y,this.#e.foregroundColor)),h.backgroundColor?y=re(y,h.backgroundColor):this.#e.backgroundColor&&(y=re(y,this.#e.backgroundColor))}else{const g=this.#e.paddingLeft+this.#e.paddingRight,w=Math.max(0,(o[m]??0)-g),b=" ".repeat(this.#e.paddingLeft+w+this.#e.paddingRight);y=re(re(n===0?b:" ".repeat(b.length),this.#e.foregroundColor),this.#e.backgroundColor)}l.push(y),m+$<this.#e.columns&&(l.push(d),this.#e.showBorders&&f&&l.push(re(re(f,a),this.#e.backgroundColor)),this.#e.gap>0&&l.push(d)),m+=$}return p&&l.push(re(re(p,a),this.#e.backgroundColor)),l.join("")}alignCellContent(t,r){const n=this.#s.get(t);if(n?.has(r))return n.get(r);const{paddingLeft:o,paddingRight:s}=this.#e,i=o+s,a=r-i;if(a<=0){const p=[" ".repeat(i+this.#e.gap)];return n?n.set(r,p):this.#s.set(t,new Map([[r,p]])),p}let l;const u=String(t.content??"");if(l=u.includes(`
|
|
180
|
+
`)||u.includes("\r")?u.split(Cr):[u],this.#e.wordWrap&&t.wordWrap!==!1){const p=typeof this.#e.wordWrap=="object"?this.#e.wordWrap:{},f=typeof t.wordWrap=="object"?t.wordWrap:p;l=I8(u,{...f,width:a}).split(`
|
|
181
|
+
`)}if(this.#e.truncate&&t.truncate!==!1){const p=typeof this.#e.truncate=="object"?this.#e.truncate:{},f=typeof t.truncate=="object"?t.truncate:p;l=l.map(d=>bu(d,a,f))}else this.#e.truncateOverflow&&(l=l.map(p=>fe(p)>a?bu(p,a,{}):p));const c=l.map(p=>H8(p,a,t.hAlign??"left",o,s));return n?n.set(r,c):this.#s.set(t,new Map([[r,c]])),c}renderHorizontalBorder(t,r,n,o,s,i=-1){if(!this.#e.showBorders||!this.#e.border)return"";const a=this.#e.border,l=Lt(a,s),u=l.body.char,c=l.body.width,p=a.bodyJoin.char;if(s!=="middle"&&c===0)return"";let f=l.left.char,d=l.right.char;if(s==="middle"&&i!==-1){const y=t[n]?.[0]??void 0,g=t[i]?.[0]??void 0;y&&g&&y===g&&(f=p);const w=this.#e.columns-1,b=t[n]?.[w]??void 0,v=t[i]?.[w]??void 0;b&&v&&b===v&&(d=p)}const m=[],h=" ".repeat(this.#e.gap);f&&m.push(re(re(f,this.#e.borderColor),this.#e.backgroundColor));let $;for(let y=0;y<this.#e.columns;y+=1){const g=t[n]?.[y]??void 0,w=s==="middle"&&i!==-1?t[i]?.[y]??void 0:void 0;let b,v=!1;if(g&&(y===0||t[n]?.[y-1]!==g)&&(b=g,v=!0),g&&!v)continue;if(!g){const E=o[y]??0;if($=c>0?u.repeat(E):" ".repeat(E),m.push(re(re($,this.#e.borderColor),this.#e.backgroundColor)),y<this.#e.columns-1){const j=this.determineJoinChar(s,t,n,i,y,y+1);m.push(h),j.width>0&&m.push(re(re(j.char,this.#e.borderColor),this.#e.backgroundColor))}continue}const S=b?.colSpan??1;if(s==="middle"&&s==="middle"&&w&&g===w&&b){const E=b.vAlign==="middle",{firstRow:j,lastRow:k}=this.getCachedCellVerticalPosition(t,n,y,b),R=k-j+1,P=R%2===0,z=j+Math.ceil(R/2)-1,U=co(o,y,S),J=this.alignCellContent(b,U),N=J.length;if(E&&P&&n===z)$=re(J[0]??"",this.#e.borderColor);else{let O=0;for(let I=j;I<=n;I+=1)O+=r[I]??1,I<n&&(O+=1);const F=O;if(F>=0&&F<N)$=re(J[F]??"",this.#e.foregroundColor);else{const I=o.slice(y,y+S).reduce((_,M)=>_+M,0)+(S-1)*(this.#e.gap+this.#e.border.bodyJoin.width);$=re(" ".repeat(I),this.#e.borderColor)}}m.push(re($,this.#e.backgroundColor))}else{const E=[];for(let j=y;j<y+S;j+=1){const k=o[j]??0,R=c>0?u:" ";if(E.push(R.repeat(k+this.#e.gap)),j<y+S-1){const P=this.determineJoinChar(s,t,n,i,j,j+1);P.width>0&&E.push(P.char)}}$=E.join(""),m.push(re(re($,this.#e.borderColor),this.#e.backgroundColor))}const x=y+S-1;if(x<this.#e.columns-1){const E=this.determineJoinChar(s,t,n,i,x,x+1);E.width>0&&m.push(re(re(E.char,this.#e.borderColor),this.#e.backgroundColor))}y+=S-1}return d&&m.push(re(re(d,this.#e.borderColor),this.#e.backgroundColor)),m.join("")}determineJoinChar(t,r,n,o,s,i=-1){if(!this.#e.showBorders||!this.#e.border)return{char:" ",width:this.#e.gap};const a=this.#e.border;if(t!=="middle"){const v=Lt(a,t),S=r[n]?.[s]??void 0,x=i===-1?s+1:i,E=r[n]?.[x]??void 0,j=S!==void 0&&E!==void 0&&S===E?v.body:v.join,{char:k,width:R}=j;return{char:k,width:R>0?R:this.#e.gap}}if(o===-1||i===-1)return{char:" ",width:this.#e.gap};const l=a.bodyJoin,u=r[n]?.[s]??void 0,c=r[o]?.[s]??void 0,p=r[n]?.[i]??void 0,f=r[o]?.[i]??void 0,d=u!==void 0&&c!==void 0&&u===c,m=p!==void 0&&f!==void 0&&p===f,h=u!==void 0&&p!==void 0&&u===p,$=c!==void 0&&f!==void 0&&c===f;let y;const g=Lt(a,"middle");d&&m?y=h?{char:" ",width:l.width}:l:d?y=a.joinLeft:m?y=a.joinRight:h&&$?y=g.body:h?y=a.topJoin:$?y=a.bottomJoin:y=a.joinJoin;const{char:w,width:b}=y;return{char:w,width:b>0?b:this.#e.gap}}renderGrid(t,r){if(t.length===0)return"";const n=[],o=F8(t,r,this.#e,this.alignCellContent.bind(this),Ft),s=this.#e.showBorders&&this.#e.border?Lt(this.#e.border,"top"):void 0;s&&s.body.width>0&&n.push(this.renderHorizontalBorder(t,o,0,r,"top"));for(let a=0;a<t.length;a+=1){const l=o[a]??1;for(let c=0;c<l;c+=1)n.push(this.renderVisualRowContent(t,a,c,r,o));const u=this.#e.showBorders&&this.#e.border?Lt(this.#e.border,"middle"):void 0;if(a<t.length-1&&u&&u.body.width>0){const c=t[a],p=t[a+1];let f=!1;if(c&&p)for(let d=0;d<this.#e.columns;d+=1){const m=c[d],h=p[d];if(m!==h){f=!0;break}}f&&n.push(this.renderHorizontalBorder(t,o,a,r,"middle",a+1))}}const i=this.#e.showBorders&&this.#e.border?Lt(this.#e.border,"bottom"):void 0;return i&&i.body.width>0&&n.push(this.renderHorizontalBorder(t,o,t.length-1,r,"bottom")),n.join(`
|
|
182
|
+
`)}getCachedCellVerticalPosition(t,r,n,o){const s=this.#r.get(o);if(s)return s;const i=Bi(t,r,n,o);return this.#r.set(o,i),i}}const q8={bodyJoin:{char:"│",width:1},bodyLeft:{char:"│",width:1},bodyRight:{char:"│",width:1},bottomBody:{char:"─",width:1},bottomJoin:{char:"┴",width:1},bottomLeft:{char:"└",width:1},bottomRight:{char:"┘",width:1},joinBody:{char:"─",width:1},joinJoin:{char:"┼",width:1},joinLeft:{char:"├",width:1},joinRight:{char:"┤",width:1},topBody:{char:"─",width:1},topJoin:{char:"┬",width:1},topLeft:{char:"┌",width:1},topRight:{char:"┐",width:1}},J8={bodyJoin:{char:"│",width:1},bodyLeft:{char:"│",width:1},bodyRight:{char:"│",width:1},bottomBody:{char:"─",width:1},bottomJoin:{char:"┴",width:1},bottomLeft:{char:"╰",width:1},bottomRight:{char:"╯",width:1},joinBody:{char:"─",width:1},joinJoin:{char:"┼",width:1},joinLeft:{char:"├",width:1},joinRight:{char:"┤",width:1},topBody:{char:"─",width:1},topJoin:{char:"┬",width:1},topLeft:{char:"╭",width:1},topRight:{char:"╮",width:1}},z8=e=>e.reduce((t,r)=>r===null?t+1:typeof r=="object"&&!Array.isArray(r)?(r.colSpan??=1,r.colSpan<=0?t+1:t+r.colSpan):t+1,0);let U8=class{#e;#o=[];#t=[];#s=[];#r=!0;#n=void 0;constructor(t={}){this.#e={...t,showFooter:t.showFooter??!0,showHeader:t.showHeader??!0,style:{border:q8,paddingLeft:1,paddingRight:1,...t.style}}}setHeaders(t){return t.length>0&&!Array.isArray(t[0])?this.#t=[t]:this.#t=t.map(r=>Array.isArray(r)?r:[r]),this.#r=!0,this.#n=void 0,this}setFooter(t){return t.length>0&&!Array.isArray(t[0])?this.#s=[t]:this.#s=t.map(r=>Array.isArray(r)?r:[r]),this.#r=!0,this.#n=void 0,this}addRow(t){if(!Array.isArray(t))throw new TypeError("Row must be an array");return this.#o.push(t),this.#r=!0,this.#n=void 0,this}addRows(...t){for(const r of t)this.addRow(r);return this.#r=!0,this.#n=void 0,this}toString(){if(!this.#r&&this.#n!==void 0)return this.#n;const t=this.#e.showHeader?this.#t:[],r=this.#e.showFooter?this.#s:[],n=[...t,...this.#o,...r];if(n.length===0)return this.#n="",this.#r=!1,"";let o=0;for(const p of n){const f=p;Array.isArray(f)?o=Math.max(o,z8(f)):console.error("Unexpected non-array element found while calculating columns:",f)}if(o===0)return this.#n="",this.#r=!1,"";let s;Array.isArray(this.#e.columnWidths)?s=this.#e.columnWidths.length>=o?this.#e.columnWidths.slice(0,o):[...this.#e.columnWidths,...Array.from({length:o-this.#e.columnWidths.length}).fill(void 0)]:typeof this.#e.columnWidths=="number"&&(s=Array.from({length:o}).fill(this.#e.columnWidths));let i;const a=n.length;if(Array.isArray(this.#e.rowHeights)?i=this.#e.rowHeights:typeof this.#e.rowHeights=="number"&&(i=Array.from({length:a}).fill(this.#e.rowHeights)),s&&Array.isArray(s)){const p=[...s];for(const f of n){const d=f;for(const[m,h]of d.entries()){let $={};if(typeof h=="object"&&h!==null&&!Array.isArray(h)){const{content:y,href:g,...w}=h;$=w}$.width!==void 0?p[m]=$.width:$.maxWidth!==void 0&&p[m]!==void 0&&(p[m]=Math.min(p[m],$.maxWidth))}}s=p}const l={autoFlow:"row",backgroundColor:this.#e.style?.backgroundColor,balancedWidths:this.#e.balancedWidths??!1,border:this.#e.style?.border,borderColor:this.#e.style?.borderColor,columns:o,fixedColumnWidths:s,fixedRowHeights:i,foregroundColor:this.#e.style?.foregroundColor,gap:this.#e.gap??0,maxWidth:this.#e.maxWidth,paddingLeft:this.#e.style?.paddingLeft,paddingRight:this.#e.style?.paddingRight,terminalWidth:this.#e.terminalWidth,truncate:this.#e.truncate??(s?.every(p=>typeof p=="number")||this.#e.maxWidth!==void 0&&!this.#e.balancedWidths),truncateOverflow:this.#e.truncateOverflow??!0,wordWrap:this.#e.wordWrap??!1},u=new rl(l),c=[];for(const[p,f]of n.entries()){const d=f;if(!Array.isArray(d)){console.error("Skipping non-array row while creating GridItems:",d);continue}const m=this.#e.showHeader?this.#t.length:0,h=this.#o.length,$=this.#e.showHeader&&p<m,y=this.#e.showFooter&&p>=m+h,g=$&&d.length===1&&o>1,w=y&&d.length===1&&o>1;for(const b of d){let v=b,S={};if(typeof v=="object"&&v!==null&&!Array.isArray(v)){const{content:k,href:R,...P}=v;v=R?`\x1B]8;;${R}\x1B\\${String(k)}\x1B]8;;\x1B\\`:k,S=P}g&&(S.colSpan=o),w&&(S.colSpan=o);const x=this.#e.transformTabToSpace&&typeof v=="string"?v.replaceAll(" "," ".repeat(this.#e.transformTabToSpace)):v,{maxWidth:E,width:j}=S;c.push({backgroundColor:S.backgroundColor,colSpan:S.colSpan,content:x,foregroundColor:S.foregroundColor,hAlign:S.hAlign,maxWidth:E,rowSpan:S.rowSpan,truncate:S.truncate??(E===void 0?void 0:!0),vAlign:S.vAlign,width:j,wordWrap:S.wordWrap})}}return u.addItems(c),this.#n=u.toString(),this.#r=!1,this.#n}};const G8=e=>new U8(e),V8=e=>e.logger,K8=/\{\s*"name"/,Y8=Qh(Zh.exec);let gm=class extends Error{};function X8(e){const t=new Map;return(...r)=>{const n=r.toString();if(t.has(n))return t.get(n);const o=e(...r);return t.set(n,o),o}}const Z8={bundler:"bundler",node10:"node10","node16-cjs":"node16 (from CJS)","node16-esm":"node16 (from ESM)"},Q8={"":"",1:"(CJS)",99:"(ESM)"},ku={CJSOnlyExportsDefault:Nn,CJSResolvesToESM:Yt,FallbackCondition:Yt,FalseCJS:qt,FalseESM:qt,FalseExportDefault:Nn,InternalResolutionError:qt,MissingExportEquals:Nn,NamedExports:Yt,NoResolution:qt,UnexpectedModuleSyntax:qt,UntypedResolution:Yt},eA={esmOnly:["node10","node16-cjs"],node16:["node10"],strict:[]},tA=e=>{if(e.startsWith("{"))return e;const t=K8.exec(e)?.index;if(t!==void 0)return e.slice(t);const r=e.indexOf("{");return r!==-1?e.slice(r):e},rA=e=>{const t=e.split(`
|
|
183
|
+
`);let r="[";for(const n of t)n&&(r+=`${n},`);return r.at(-1)===","&&(r=r.slice(0,-1)),r+="]",r},nA=async(e,t)=>{switch(e){case"auto":{const{detect:r}=await import("package-manager-detector/detect"),n=await r({cwd:t});if(!n)return;if(n.name==="bun")throw new Error("Bun does not support --json on the pack command");return n.name}case"bun":throw new Error("Bun does not support --json on the pack command");case"pnpm":return"pnpm";case"yarn":return"yarn";default:return"npm"}},oA=(e,t,r)=>{const{allResolutionKinds:n,filterProblems:o,getResolutionOption:s,groupProblemsByKind:i,problemAffectsEntrypoint:a,problemAffectsResolutionKind:l,problemKindInfo:u}=r,c=n.filter(b=>!t.includes(b)),p=n.filter(b=>t.includes(b)),f=[...c,...p],d=Object.keys(e.entrypoints),m=d.map(b=>`"${b==="."?e.packageName:`${e.packageName}/${b.slice(2)}`}"`),h=d.map((b,v)=>{const S=e.problems.some(x=>a(x,b,e))?"redBright":"greenBright";return Ae[S](m[v])}),$=X8((b,v)=>{const S=t.includes(v)?"(ignored) ":"",x=i(o(e.problems,e,{entrypoint:b,resolutionKind:v})),E=e.entrypoints[b].resolutions[v],{resolution:j}=E,k=Object.keys(x);if(k.length>0)return k.map(U=>S+ku[U](u[U].shortDescription)).join(`
|
|
184
|
+
`);const R="OK (JSON)",P=e.programInfo[s(v)].moduleKinds?.[j?.fileName??""]?.detectedKind??"",z=E.isWildcard?"(wildcard)":`OK ${Q8[P]}`;return S+(j?.isJson?R:z)}),y=G8({style:{border:J8}});y.setHeaders(["",...f.map(b=>Z8[b])]),h.forEach((b,v)=>{const[S,x,E,j]=f.map(k=>d.map(R=>$(R,k)));y.addRow([b,S[v]??null,x[v]??null,E[v]??null,j[v]??null])});const g=i(e.problems),w=Object.entries(g).map(([b,v])=>{const S=u[b],x=v.some(j=>c.some(k=>l(j,k,e))),E=`${`${S.description}${S.details?` Use \`-f json\` to see ${S.details}.`:""}`} ${S.docsUrl}`;return`${x?"":"(ignored per resolution) "}${ku[b](E)}`});return`Are the types wrong problems found:
|
|
185
|
+
|
|
186
|
+
${y.toString()}
|
|
187
|
+
|
|
188
|
+
${w.join(`
|
|
189
|
+
|
|
190
|
+
`)}`},sA=e=>{const t=JSON.parse(e),r=Array.isArray(t)?t[0]:t;if(!r?.filename)throw new Error(`Invalid npm pack output format: ${e}`);return r.filename},iA=async(e,t,r)=>{let n=`--pack-destination "${t}"`;e==="yarn"?n=`--out "${G(t,"package.tgz")}"`:e==="bun"&&(n=` --destination "${t}"`);let o=" --ignore-scripts";e==="yarn"?o="":e==="pnpm"&&(o=" --config.ignore-scripts=true");let s=(await Y8(`${e} pack --json ${n}${o}`,{cwd:r,encoding:"utf8"})).stdout.trim();e==="pnpm"?s=tA(s):e==="yarn"&&(s=rA(s));const i=sA(s);return Tt(i)?i:G(t,Fe(i))},aA=(e,t,r,n,o,s)=>{if(t.types!==!1&&t.problems.length>0){const i=oA(t,r,s);if(n==="error")throw e.error({message:i,prefix:"attw"}),new gm("attw reported types problems; see the log above.");e.warn({message:i,prefix:"attw"});return}e.success({message:qi(`No Are the types wrong problems found ${Gu`(${Math.round(performance.now()-o).toString()}ms)`}`),prefix:"attw"})},lA=async(e,t)=>{if(!e.options?.validation)return;const{validation:r}=e.options;if(!r.attw)return;const n=V8(e),{packageJson:o}=qo(e.options.rootDir);e.pkg=o,t&&n.raw(`
|
|
191
|
+
`),await g1(e.pkg,["@arethetypeswrong/core","package-manager-detector"],"devDependencies",{logger:{warn:v=>{n.warn({message:v,prefix:"attw"})}}});let{level:s="warn",pm:i="auto",profile:a="strict",...l}=r.attw===!0?{}:r.attw;const u=performance.now();n.debug({message:"Running attw check",prefix:"attw"});const c=await up(G(mp(),"packem-attw-")),p=async()=>{await $o(c,{force:!0,recursive:!0}).catch(()=>{})};let f;try{f=await import("@arethetypeswrong/core")}catch{n.error({message:`ATTW check requires ${Nn`@arethetypeswrong/core`} to be installed.`,prefix:"attw"}),await p();return}let d;try{d=await nA(i,e.options.rootDir)}catch(v){throw await p(),v}if(d===void 0)throw await p(),new Error("Could not detect a package manager to run the attw check.");const{allResolutionKinds:m,getResolutionOption:h,groupProblemsByKind:$}=await import("@arethetypeswrong/core/utils"),{filterProblems:y,problemAffectsEntrypoint:g,problemAffectsResolutionKind:w,problemKindInfo:b}=await import("@arethetypeswrong/core/problems");try{const v=await iA(d,c,e.options.rootDir),S=await Jn(v),x=f.createPackageFromTarballData(new Uint8Array(S)),E=await f.checkPackage(x,l),j=eA[a];aA(n,E,j,s,u,{allResolutionKinds:m,filterProblems:y,getResolutionOption:h,groupProblemsByKind:$,problemAffectsEntrypoint:g,problemAffectsResolutionKind:w,problemKindInfo:b})}catch(v){throw v instanceof gm||n.error({message:`ATTW check failed: ${v instanceof Error?v.message:String(v)}`,prefix:"attw"}),v}finally{await p()}},ju=e=>Array.from(e,t=>Yt(t)).join(", "),cA=e=>{if(e.hoistedDependencies.size>0){const s=`These dependencies are shamefully hoisted: ${ju(e.hoistedDependencies)}`;Y(e,s)}let t=Object.keys(e.pkg.dependencies??{}).filter(s=>!e.usedDependencies.has(s));const{validation:r}=e.options,n=r===!1||r===void 0?!1:r.dependencies,o=n===!1?!1:n.unused;if(o!==!1&&(t=t.filter(s=>!o.exclude.includes(s))),t.length>0){const s=`These dependencies are listed in package.json but not used: ${ju(t)}`;Y(e,s)}},Au=">=18.0.0",uA=e=>{const t=e.options.validation,{pkg:r}=e;if(t.packageJson?.engines===!1)return;const n=process.version,o=r.engines?.node;if(!o){Y(e,`The 'engines.node' field is missing in your package.json. Consider adding "engines": { "node": "${Au}" } to specify Node.js version requirements.`);return}if(!Le.validRange(o)){Y(e,`Invalid Node.js version range "${o}" in engines.node field. Please use a valid semver range like "${Au}".`);return}if(!Le.satisfies(n,o))throw new Error(`Node.js version mismatch: Current version ${n} does not satisfy the required range "${o}" specified in package.json engines.node field.`)},pA=(e,t)=>tg(e,t)<=e.length/3||t.includes(e),fA=(e,t)=>{const r=e.toLowerCase();return t.filter(n=>pA(n.toLowerCase(),r))},dA=/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,mA=(e,t)=>{const{options:r}=e;return ya(e.pkg.exports,t,r.declaration,[],r.ignoreExportKeys??[]).filter(n=>!n.ignored).map(n=>r.dtsOnly?n.subKey==="types"?n.file:void 0:n.file)},hA=(e,t)=>e.options.dtsOnly||!t?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:typeof e.pkg.bin=="object"?Object.values(e.pkg.bin):[],gA=(e,t)=>{let r="Potential missing or wrong package.json files:";for(const n of e){const o=fA(n,t);r+=`
|
|
192
|
+
- ${ne(n)}${o.length>0?Om` (did you mean ${o.map(s=>`"${s}"`).join(", ")}?)`:""}`}return r},yA=e=>{const{options:t}=e,r=t.validation,{packageJson:n}=r;if(!n?.exports)return;const o=hA(e,!!n.bin),s=e.pkg.type==="module"?"esm":"cjs",i=new Set([t.declaration&&n.types?e.pkg.types:"",t.declaration&&n.types?e.pkg.typings:"",...o,t.dtsOnly&&!n.main?"":e.pkg.main,t.dtsOnly&&!n.module?"":e.pkg.module,...mA(e,s)].filter(Boolean).map(c=>c&&X(t.rootDir,c.replace(dA,"")))),a=[];for(const c of i)c&&!c.includes("*")&&!Xi(c)&&a.push(c.replace(`${t.rootDir}/`,""));const l=c=>ke(t.rootDir,X(t.outDir,c)),u=e.buildEntries.filter(c=>!c.chunk).map(c=>l(c.path));if(a.length>0){const c=gA(a,u);Y(e,c)}},$A=(e,t)=>{const r=e.options.validation;if(r.packageJson?.exports===!1)return;const n=new Set(["default","import","module-sync","node","node-addons","require"]),o=new Set(["browser","bun","deno","development","edge-light","electron","production","react-native","react-server","types","workerd"]),s=r.packageJson?.extraConditions??[],i=new Set(s),a=new Set([...o,...i,...n]),l=(f,d)=>{if(f!==null){if(typeof f=="string"){if(!f.startsWith("./")){Y(e,`Invalid exports path "${f}" at ${d}. Export paths must start with "./"`);return}if(f.includes("../")){Y(e,`Invalid exports path "${f}" at ${d}. Export paths should not contain "../" for security reasons`);return}const m=r.packageJson?.allowedExportExtensions??[],h=[...lh,...m];if(gi(f)){try{const $=f.startsWith("./")?X(e.options.rootDir,f.slice(2)):X(e.options.rootDir,f),y=Uu([$],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**","**/.git/**","**/dist/**"]});if(y.length===0)return;const g=y.filter(w=>!h.some(b=>w.endsWith(b)));g.length>0&&Y(e,`Export path "${f}" at ${d} matches files with invalid extensions: ${g.join(", ")}. Valid extensions are: ${h.join(", ")}`)}catch($){Y(e,`Could not validate glob pattern "${f}" at ${d}: ${$ instanceof Error?$.message:"Unknown error"}`)}return}h.some($=>f.endsWith($))||Y(e,`Export path "${f}" at ${d} should have a valid file extension (${h.join(", ")})`);return}if(Array.isArray(f)){if(f.length===0){Y(e,`Empty fallback array at ${d}. Fallback arrays should contain at least one entry`);return}f.forEach((m,h)=>{l(m,`${d}[${String(h)}]`)});return}if(typeof f=="object"){const m=Object.keys(f);if(m.length===0){Y(e,`Empty conditions object at ${d}. Conditional exports should define at least one condition`);return}const h=m.filter(y=>!a.has(y));if(h.length>0){const y=s.length>0,g=[...n].join(", ");y?Y(e,`Unknown export conditions [${h.join(", ")}] at ${d}. Consider using standard conditions (${g}) or add custom conditions to 'validation.packageJson.extraConditions' in your packem config.`):Y(e,`Unknown export conditions [${h.join(", ")}] at ${d}. Consider using standard conditions (${g}) or add custom conditions using the 'extraConditions' option in your validation config.`)}const $=m.filter(y=>n.has(y));if($.length>1){const y=["node-addons","node","import","require","module-sync","default"],g=$,w=y.filter(b=>g.includes(b));JSON.stringify(g)!==JSON.stringify(w)&&Y(e,`Incorrect condition order at ${d}. Standard conditions should be ordered: ${w.join(" > ")}`)}m.forEach(y=>{l(f[y],`${d}.${y}`)});return}Y(e,`Invalid exports value type at ${d}. Expected string, array, object, or null`)}},u=(f,d)=>{f.startsWith(".")&&!f.startsWith("./")&&f!=="."&&Y(e,`Invalid subpath "${f}". Subpaths should start with "./" or be exactly "."`),f.includes("*")&&(f.match(/\*/g)??[]).length>1&&Y(e,`Invalid subpath pattern "${f}". Only one "*" wildcard is allowed per subpath`),l(d[f],`exports["${f}"]`)},c=(f,d,m)=>{const h=f.filter(y=>y!=="."),$=e.pkg.bin!==void 0&&h.length<=1&&h.every(y=>y==="./package.json");!d.includes(".")&&!$&&Y(e,'Missing main export ".". Subpaths exports should include a main export entry');for(const y of d)u(y,m)},p=f=>{const d=Object.keys(f);if(d.length===0){Y(e,"Empty exports object. Define at least one export entry");return}const m=d.filter($=>$.startsWith(".")),h=d.filter($=>!$.startsWith("."));if(m.length>0&&h.length>0){Y(e,'Mixed subpaths and conditions in exports object. Use either subpaths (keys starting with ".") or conditions, not both');return}m.length>0?c(m,d,f):l(f,"exports")};(f=>{if(typeof f=="string"){l(f,"exports");return}if(Array.isArray(f)){f.forEach((d,m)=>{l(d,`exports[${String(m)}]`)});return}if(typeof f=="object"&&f!==null){p(f);return}Y(e,"Invalid exports field type. Expected string, array, or object")})(t)},bA=({context:e,pkg:t,validation:r})=>{t.name===void 0&&r.packageJson?.name!==!1&&Y(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),r.packageJson?.files!==!1&&Array.isArray(t.files)&&!t.files.includes("*")&&(t.files.length===0?Y(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):t.files.some(n=>n.includes(e.options.outDir))||Y(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`))},wA=({cjsJSExtension:e,context:t,esmJSExtension:r,pkg:n,validation:o})=>{o.packageJson?.main!==!1&&(n.main===void 0&&Y(t,"The 'main' field is missing in your package.json. This field should point to your main entry file."),n.main?.endsWith(`.${r}`)&&Y(t,`The 'main' field in your package.json should not use a '.${r}' extension for CommonJS modules.`)),o.packageJson?.module!==!1&&(n.module===void 0&&t.options.emitESM&&Y(t,"The 'module' field is missing in your package.json, but you are emitting ES modules."),n.module&&n.main&&n.module===n.main&&Y(t,`Conflict detected: The 'module' and 'main' fields both point to '${n.module}'. Please ensure they refer to different module types.`),t.options.emitESM&&n.module?.endsWith(`.${e}`)&&Y(t,`The 'module' field in your package.json should not use a '.${e}' extension for ES modules.`))},vA=({cjsJSExtension:e,context:t,pkg:r,validation:n})=>{n.packageJson?.main!==!1&&r.main===void 0&&Y(t,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),n.packageJson?.module!==!1&&(r.module===void 0&&Y(t,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),r.module?.endsWith(`.${e}`)&&Y(t,`The 'module' field should not use a '.${e}' extension for ES modules.`),r.module&&r.main&&r.module===r.main&&Y(t,`Conflict detected: The 'module' and 'main' fields both point to '${r.module}'. Please ensure they refer to different module types.`)),n.packageJson?.exports!==!1&&r.exports===void 0&&Y(t,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports.")},xA=e=>{const{context:t,pkg:r,validation:n}=e;r.exports===void 0&&!t.options.emitCJS?n.packageJson?.exports!==!1&&Y(t,"The 'exports' field is missing in your package.json. Define module exports explicitly."):t.options.emitCJS&&vA(e)},EA=({cjsJSExtension:e,context:t,esmJSExtension:r,pkg:n,validation:o},s)=>{if(o.packageJson?.bin===!1)return;const i=s?r:e;if(e===r)return;const a=s?"CommonJS":"ES modules";if(typeof n.bin=="string"&&n.bin.endsWith(`.${i}`))Y(t,`The 'bin' field in your package.json should not use a .${i} extension for ${a} binaries.`);else if(typeof n.bin=="object")for(const[l,u]of Object.entries(n.bin))u?.endsWith(`.${i}`)&&Y(t,`The 'bin.${l}' field in your package.json should not use a .${i} extension for ${a} binaries.`)},SA=({cjsJSExtension:e,context:t,pkg:r,validation:n})=>{if(!t.options.declaration)return;let o=!0;r.type==="module"&&(o=!!r.main?.endsWith(`.${e}`));const s=r.types!==void 0||r.typings!==void 0;!s&&o&&n.packageJson?.types!==!1&&Y(t,"The 'types' field is missing in your package.json. This field should point to your type definitions file.");const i=r.type==="module"&&r.main!==void 0&&s;(t.options.declaration===!0||t.options.declaration==="compatible")&&o&&!i&&n.packageJson?.typesVersions!==!1&&(()=>{const a=r.typesVersions;return a===void 0||Object.keys(a).length===0})()&&Y(t,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'.")},kA=e=>{const t=e.options.validation,{pkg:r}=e,n=Pe(e,"cjs"),o=Pe(e,"esm"),s={cjsJSExtension:n,context:e,esmJSExtension:o,pkg:r,validation:t};bA(s);const i=r.type==="commonjs"||r.type===void 0,a=r.type==="module";i?wA(s):a&&xA(s),r.exports!==void 0&&$A(e,r.exports),EA(s,i),SA(s),t.packageJson?.sideEffects!==!1&&r.sideEffects===void 0&&Y(e,"The 'sideEffects' field is missing in your package.json. Consider adding this field to your package.json.")},jA=e=>{const{packageJson:t}=qo(e.options.rootDir);e.pkg=t,cA(e),uA(e),kA(e),yA(e)},AA=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,OA=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","undefined","var","void","volatile","while","with","yield"]),RA=(e,t)=>{if(e.trim()==="")throw new Error(`Alias name "${e}" is invalid. Alias names should be non-empty strings.`);if(AA.test(e))throw new Error(`Alias name "${e}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(OA.has(e))throw new Error(`Alias name "${e}" is a reserved keyword and cannot be used.`);const r=X(t);if(!rt(r))throw new Error(`Target path "${r}" for alias "${e}" does not exist.`)},Ou=e=>{if(Array.isArray(e))return;const t=e;for(const[r,n]of Object.entries(t))RA(r,n)};var ai={},li,Ru;function Uo(){if(Ru)return li;Ru=1;const e="[^\\\\/]",t="(?=.)",r="[^/]",n="(?:\\/|$)",o="(?:^|\\/)",s=`\\.{1,2}${n}`,i="(?!\\.)",a=`(?!${o}${s})`,l=`(?!\\.{0,1}${n})`,u=`(?!${s})`,c="[^.\\/]",p=`${r}*?`,f="/",d={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:t,QMARK:r,END_ANCHOR:n,DOTS_SLASH:s,NO_DOT:i,NO_DOTS:a,NO_DOT_SLASH:l,NO_DOTS_SLASH:u,QMARK_NO_DOT:c,STAR:p,START_ANCHOR:o,SEP:f},m={...d,SLASH_LITERAL:"[\\\\/]",QMARK:e,STAR:`${e}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},h={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};return li={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:h,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars($){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${$.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars($){return $===!0?m:d}},li}var Cu;function Go(){return Cu||(Cu=1,(function(e){const{REGEX_BACKSLASH:t,REGEX_REMOVE_BACKSLASH:r,REGEX_SPECIAL_CHARS:n,REGEX_SPECIAL_CHARS_GLOBAL:o}=Uo();e.isObject=s=>s!==null&&typeof s=="object"&&!Array.isArray(s),e.hasRegexChars=s=>n.test(s),e.isRegexChar=s=>s.length===1&&e.hasRegexChars(s),e.escapeRegex=s=>s.replace(o,"\\$1"),e.toPosixSlashes=s=>s.replace(t,"/"),e.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){const s=navigator.platform.toLowerCase();return s==="win32"||s==="windows"}return process.platform?process.platform==="win32":!1},e.removeBackslashes=s=>s.replace(r,i=>i==="\\"?"":i),e.escapeLast=(s,i,a)=>{const l=s.lastIndexOf(i,a);return l===-1?s:s[l-1]==="\\"?e.escapeLast(s,i,l-1):`${s.slice(0,l)}\\${s.slice(l)}`},e.removePrefix=(s,i={})=>{let a=s;return a.startsWith("./")&&(a=a.slice(2),i.prefix="./"),a},e.wrapOutput=(s,i={},a={})=>{const l=a.contains?"":"^",u=a.contains?"":"$";let c=`${l}(?:${s})${u}`;return i.negated===!0&&(c=`(?:^(?!${c}).*$)`),c},e.basename=(s,{windows:i}={})=>{const a=s.split(i?/[\\/]/:"/"),l=a[a.length-1];return l===""?a[a.length-2]:l}})(ai)),ai}var ci,Tu;function CA(){if(Tu)return ci;Tu=1;const e=Go(),{CHAR_ASTERISK:t,CHAR_AT:r,CHAR_BACKWARD_SLASH:n,CHAR_COMMA:o,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:i,CHAR_FORWARD_SLASH:a,CHAR_LEFT_CURLY_BRACE:l,CHAR_LEFT_PARENTHESES:u,CHAR_LEFT_SQUARE_BRACKET:c,CHAR_PLUS:p,CHAR_QUESTION_MARK:f,CHAR_RIGHT_CURLY_BRACE:d,CHAR_RIGHT_PARENTHESES:m,CHAR_RIGHT_SQUARE_BRACKET:h}=Uo(),$=w=>w===a||w===n,y=w=>{w.isPrefix!==!0&&(w.depth=w.isGlobstar?1/0:1)};return ci=(w,b)=>{const v=b||{},S=w.length-1,x=v.parts===!0||v.scanToEnd===!0,E=[],j=[],k=[];let R=w,P=-1,z=0,U=0,J=!1,N=!1,O=!1,F=!1,I=!1,_=!1,M=!1,H=!1,V=!1,B=!1,D=0,K,q,A={value:"",depth:0,isGlob:!1};const le=()=>P>=S,ze=()=>R.charCodeAt(P+1),xe=()=>(K=q,R.charCodeAt(++P));for(;P<S;){q=xe();let me;if(q===n){M=A.backslashes=!0,q=xe(),q===l&&(_=!0);continue}if(_===!0||q===l){for(D++;le()!==!0&&(q=xe());){if(q===n){M=A.backslashes=!0,xe();continue}if(q===l){D++;continue}if(_!==!0&&q===s&&(q=xe())===s){if(J=A.isBrace=!0,O=A.isGlob=!0,B=!0,x===!0)continue;break}if(_!==!0&&q===o){if(J=A.isBrace=!0,O=A.isGlob=!0,B=!0,x===!0)continue;break}if(q===d&&(D--,D===0)){_=!1,J=A.isBrace=!0,B=!0;break}}if(x===!0)continue;break}if(q===a){if(E.push(P),j.push(A),A={value:"",depth:0,isGlob:!1},B===!0)continue;if(K===s&&P===z+1){z+=2;continue}U=P+1;continue}if(v.noext!==!0&&(q===p||q===r||q===t||q===f||q===i)&&ze()===u){if(O=A.isGlob=!0,F=A.isExtglob=!0,B=!0,q===i&&P===z&&(V=!0),x===!0){for(;le()!==!0&&(q=xe());){if(q===n){M=A.backslashes=!0,q=xe();continue}if(q===m){O=A.isGlob=!0,B=!0;break}}continue}break}if(q===t){if(K===t&&(I=A.isGlobstar=!0),O=A.isGlob=!0,B=!0,x===!0)continue;break}if(q===f){if(O=A.isGlob=!0,B=!0,x===!0)continue;break}if(q===c){for(;le()!==!0&&(me=xe());){if(me===n){M=A.backslashes=!0,xe();continue}if(me===h){N=A.isBracket=!0,O=A.isGlob=!0,B=!0;break}}if(x===!0)continue;break}if(v.nonegate!==!0&&q===i&&P===z){H=A.negated=!0,z++;continue}if(v.noparen!==!0&&q===u){if(O=A.isGlob=!0,x===!0){for(;le()!==!0&&(q=xe());){if(q===u){M=A.backslashes=!0,q=xe();continue}if(q===m){B=!0;break}}continue}break}if(O===!0){if(B=!0,x===!0)continue;break}}v.noext===!0&&(F=!1,O=!1);let C=R,T="",Ie="";z>0&&(T=R.slice(0,z),R=R.slice(z),U-=z),C&&O===!0&&U>0?(C=R.slice(0,U),Ie=R.slice(U)):O===!0?(C="",Ie=R):C=R,C&&C!==""&&C!=="/"&&C!==R&&$(C.charCodeAt(C.length-1))&&(C=C.slice(0,-1)),v.unescape===!0&&(Ie&&(Ie=e.removeBackslashes(Ie)),C&&M===!0&&(C=e.removeBackslashes(C)));const ie={prefix:T,input:w,start:z,base:C,glob:Ie,isBrace:J,isBracket:N,isGlob:O,isExtglob:F,isGlobstar:I,negated:H,negatedExtglob:V};if(v.tokens===!0&&(ie.maxDepth=0,$(q)||j.push(A),ie.tokens=j),v.parts===!0||v.tokens===!0){let me;for(let pe=0;pe<E.length;pe++){const We=me?me+1:z,wt=E[pe],hr=w.slice(We,wt);v.tokens&&(pe===0&&z!==0?(j[pe].isPrefix=!0,j[pe].value=T):j[pe].value=hr,y(j[pe]),ie.maxDepth+=j[pe].depth),(pe!==0||hr!=="")&&k.push(hr),me=wt}if(me&&me+1<w.length){const pe=w.slice(me+1);k.push(pe),v.tokens&&(j[j.length-1].value=pe,y(j[j.length-1]),ie.maxDepth+=j[j.length-1].depth)}ie.slashes=E,ie.parts=k}return ie},ci}var ui,Nu;function TA(){if(Nu)return ui;Nu=1;const e=Uo(),t=Go(),{MAX_LENGTH:r,POSIX_REGEX_SOURCE:n,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:i}=e,a=(g,w)=>typeof w.expandRange=="function"?w.expandRange(...g,w):(g.sort(),`[${g.join("-")}]`),l=(g,w)=>`Missing ${g}: "${w}" - use "\\\\${w}" to match literal characters`,u=g=>{const w=[];let b=0,v=0,S=0,x="",E=!1;for(const j of g){if(E===!0){x+=j,E=!1;continue}if(j==="\\"){x+=j,E=!0;continue}if(j==='"'){S=S===1?0:1,x+=j;continue}if(S===0){if(j==="[")b++;else if(j==="]"&&b>0)b--;else if(b===0){if(j==="(")v++;else if(j===")"&&v>0)v--;else if(j==="|"&&v===0){w.push(x),x="";continue}}}x+=j}return w.push(x),w},c=g=>{let w=!1;for(const b of g){if(w===!0){w=!1;continue}if(b==="\\"){w=!0;continue}if(/[?*+@!()[\]{}]/.test(b))return!1}return!0},p=g=>{let w=g.trim(),b=!0;for(;b===!0;)b=!1,/^@\([^\\()[\]{}|]+\)$/.test(w)&&(w=w.slice(2,-1),b=!0);if(c(w))return w.replace(/\\(.)/g,"$1")},f=g=>{const w=g.map(p).filter(Boolean);for(let b=0;b<w.length;b++)for(let v=b+1;v<w.length;v++){const S=w[b],x=w[v],E=S[0];if(!(!E||S!==E.repeat(S.length)||x!==E.repeat(x.length))&&(S===x||S.startsWith(x)||x.startsWith(S)))return!0}return!1},d=(g,w=!0)=>{if(g[0]!=="+"&&g[0]!=="*"||g[1]!=="(")return;let b=0,v=0,S=0,x=!1;for(let E=1;E<g.length;E++){const j=g[E];if(x===!0){x=!1;continue}if(j==="\\"){x=!0;continue}if(j==='"'){S=S===1?0:1;continue}if(S!==1){if(j==="["){b++;continue}if(j==="]"&&b>0){b--;continue}if(!(b>0)){if(j==="("){v++;continue}if(j===")"&&(v--,v===0))return w===!0&&E!==g.length-1?void 0:{type:g[0],body:g.slice(2,E),end:E}}}}},m=g=>{let w=0;const b=[];for(;w<g.length;){const v=d(g.slice(w),!1);if(!v||v.type!=="*")return;const S=u(v.body).map(E=>E.trim());if(S.length!==1)return;const x=p(S[0]);if(!x||x.length!==1)return;b.push(x),w+=v.end+1}return b.length<1?void 0:`${b.length===1?t.escapeRegex(b[0]):`[${b.map(v=>t.escapeRegex(v)).join("")}]`}*`},h=g=>{let w=0,b=g.trim(),v=d(b);for(;v;)w++,b=v.body.trim(),v=d(b);return w},$=(g,w)=>{if(w.maxExtglobRecursion===!1)return{risky:!1};const b=typeof w.maxExtglobRecursion=="number"?w.maxExtglobRecursion:e.DEFAULT_MAX_EXTGLOB_RECURSION,v=u(g).map(S=>S.trim());if(v.length>1&&(v.some(S=>S==="")||v.some(S=>/^[*?]+$/.test(S))||f(v)))return{risky:!0};for(const S of v){const x=m(S);if(x)return{risky:!0,safeOutput:x};if(h(S)>b)return{risky:!0}}return{risky:!1}},y=(g,w)=>{if(typeof g!="string")throw new TypeError("Expected a string");g=i[g]||g;const b={...w},v=typeof b.maxLength=="number"?Math.min(r,b.maxLength):r;let S=g.length;if(S>v)throw new SyntaxError(`Input length: ${S}, exceeds maximum allowed length: ${v}`);const x={type:"bos",value:"",output:b.prepend||""},E=[x],j=b.capture?"":"?:",k=e.globChars(b.windows),R=e.extglobChars(k),{DOT_LITERAL:P,PLUS_LITERAL:z,SLASH_LITERAL:U,ONE_CHAR:J,DOTS_SLASH:N,NO_DOT:O,NO_DOT_SLASH:F,NO_DOTS_SLASH:I,QMARK:_,QMARK_NO_DOT:M,STAR:H,START_ANCHOR:V}=k,B=L=>`(${j}(?:(?!${V}${L.dot?N:P}).)*?)`,D=b.dot?"":O,K=b.dot?_:M;let q=b.bash===!0?B(b):H;b.capture&&(q=`(${q})`),typeof b.noext=="boolean"&&(b.noextglob=b.noext);const A={input:g,index:-1,start:0,dot:b.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:E};g=t.removePrefix(g,A),S=g.length;const le=[],ze=[],xe=[];let C=x,T;const Ie=()=>A.index===S-1,ie=A.peek=(L=1)=>g[A.index+L],me=A.advance=()=>g[++A.index]||"",pe=()=>g.slice(A.index+1),We=(L="",ce=0)=>{A.consumed+=L,A.index+=ce},wt=L=>{A.output+=L.output!=null?L.output:L.value,We(L.value)},hr=()=>{let L=1;for(;ie()==="!"&&(ie(2)!=="("||ie(3)==="?");)me(),A.start++,L++;return L%2===0?!1:(A.negated=!0,A.start++,!0)},fn=L=>{A[L]++,xe.push(L)},st=L=>{A[L]--,xe.pop()},Q=L=>{if(C.type==="globstar"){const ce=A.braces>0&&(L.type==="comma"||L.type==="brace"),W=L.extglob===!0||le.length&&(L.type==="pipe"||L.type==="paren");L.type!=="slash"&&L.type!=="paren"&&!ce&&!W&&(A.output=A.output.slice(0,-C.output.length),C.type="star",C.value="*",C.output=q,A.output+=C.output)}if(le.length&&L.type!=="paren"&&(le[le.length-1].inner+=L.value),(L.value||L.output)&&wt(L),C&&C.type==="text"&&L.type==="text"){C.output=(C.output||C.value)+L.value,C.value+=L.value;return}L.prev=C,E.push(L),C=L},dn=(L,ce)=>{const W={...R[ce],conditions:1,inner:""};W.prev=C,W.parens=A.parens,W.output=A.output,W.startIndex=A.index,W.tokensIndex=E.length;const ee=(b.capture?"(":"")+W.open;fn("parens"),Q({type:L,value:ce,output:A.output?"":J}),Q({type:"paren",extglob:!0,value:me(),output:ee}),le.push(W)},xm=L=>{const ce=g.slice(L.startIndex,A.index+1),W=g.slice(L.startIndex+2,A.index),ee=$(W,b);if((L.type==="plus"||L.type==="star")&&ee.risky){const se=ee.safeOutput?(L.output?"":J)+(b.capture?`(${ee.safeOutput})`:ee.safeOutput):void 0,Ue=E[L.tokensIndex];Ue.type="text",Ue.value=ce,Ue.output=se||t.escapeRegex(ce);for(let Ge=L.tokensIndex+1;Ge<E.length;Ge++)E[Ge].value="",E[Ge].output="",delete E[Ge].suffix;A.output=L.output+Ue.output,A.backtrack=!0,Q({type:"paren",extglob:!0,value:T,output:""}),st("parens");return}let ue=L.close+(b.capture?")":""),he;if(L.type==="negate"){let se=q;if(L.inner&&L.inner.length>1&&L.inner.includes("/")&&(se=B(b)),(se!==q||Ie()||/^\)+$/.test(pe()))&&(ue=L.close=`)$))${se}`),L.inner.includes("*")&&(he=pe())&&/^\.[^\\/.]+$/.test(he)){const Ue=y(he,{...w,fastpaths:!1}).output;ue=L.close=`)${Ue})${se})`}L.prev.type==="bos"&&(A.negatedExtglob=!0)}Q({type:"paren",extglob:!0,value:T,output:ue}),st("parens")};if(b.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(g)){let L=!1,ce=g.replace(s,(W,ee,ue,he,se,Ue)=>he==="\\"?(L=!0,W):he==="?"?ee?ee+he+(se?_.repeat(se.length):""):Ue===0?K+(se?_.repeat(se.length):""):_.repeat(ue.length):he==="."?P.repeat(ue.length):he==="*"?ee?ee+he+(se?q:""):q:ee?W:`\\${W}`);return L===!0&&(b.unescape===!0?ce=ce.replace(/\\/g,""):ce=ce.replace(/\\+/g,W=>W.length%2===0?"\\\\":W?"\\":"")),ce===g&&b.contains===!0?(A.output=g,A):(A.output=t.wrapOutput(ce,A,w),A)}for(;!Ie();){if(T=me(),T==="\0")continue;if(T==="\\"){const W=ie();if(W==="/"&&b.bash!==!0||W==="."||W===";")continue;if(!W){T+="\\",Q({type:"text",value:T});continue}const ee=/^\\+/.exec(pe());let ue=0;if(ee&&ee[0].length>2&&(ue=ee[0].length,A.index+=ue,ue%2!==0&&(T+="\\")),b.unescape===!0?T=me():T+=me(),A.brackets===0){Q({type:"text",value:T});continue}}if(A.brackets>0&&(T!=="]"||C.value==="["||C.value==="[^")){if(b.posix!==!1&&T===":"){const W=C.value.slice(1);if(W.includes("[")&&(C.posix=!0,W.includes(":"))){const ee=C.value.lastIndexOf("["),ue=C.value.slice(0,ee),he=C.value.slice(ee+2),se=n[he];if(se){C.value=ue+se,A.backtrack=!0,me(),!x.output&&E.indexOf(C)===1&&(x.output=J);continue}}}(T==="["&&ie()!==":"||T==="-"&&ie()==="]")&&(T=`\\${T}`),T==="]"&&(C.value==="["||C.value==="[^")&&(T=`\\${T}`),b.posix===!0&&T==="!"&&C.value==="["&&(T="^"),C.value+=T,wt({value:T});continue}if(A.quotes===1&&T!=='"'){T=t.escapeRegex(T),C.value+=T,wt({value:T});continue}if(T==='"'){A.quotes=A.quotes===1?0:1,b.keepQuotes===!0&&Q({type:"text",value:T});continue}if(T==="("){fn("parens"),Q({type:"paren",value:T});continue}if(T===")"){if(A.parens===0&&b.strictBrackets===!0)throw new SyntaxError(l("opening","("));const W=le[le.length-1];if(W&&A.parens===W.parens+1){xm(le.pop());continue}Q({type:"paren",value:T,output:A.parens?")":"\\)"}),st("parens");continue}if(T==="["){if(b.nobracket===!0||!pe().includes("]")){if(b.nobracket!==!0&&b.strictBrackets===!0)throw new SyntaxError(l("closing","]"));T=`\\${T}`}else fn("brackets");Q({type:"bracket",value:T});continue}if(T==="]"){if(b.nobracket===!0||C&&C.type==="bracket"&&C.value.length===1){Q({type:"text",value:T,output:`\\${T}`});continue}if(A.brackets===0){if(b.strictBrackets===!0)throw new SyntaxError(l("opening","["));Q({type:"text",value:T,output:`\\${T}`});continue}st("brackets");const W=C.value.slice(1);if(C.posix!==!0&&W[0]==="^"&&!W.includes("/")&&(T=`/${T}`),C.value+=T,wt({value:T}),b.literalBrackets===!1||t.hasRegexChars(W))continue;const ee=t.escapeRegex(C.value);if(A.output=A.output.slice(0,-C.value.length),b.literalBrackets===!0){A.output+=ee,C.value=ee;continue}C.value=`(${j}${ee}|${C.value})`,A.output+=C.value;continue}if(T==="{"&&b.nobrace!==!0){fn("braces");const W={type:"brace",value:T,output:"(",outputIndex:A.output.length,tokensIndex:A.tokens.length};ze.push(W),Q(W);continue}if(T==="}"){const W=ze[ze.length-1];if(b.nobrace===!0||!W){Q({type:"text",value:T,output:T});continue}let ee=")";if(W.dots===!0){const ue=E.slice(),he=[];for(let se=ue.length-1;se>=0&&(E.pop(),ue[se].type!=="brace");se--)ue[se].type!=="dots"&&he.unshift(ue[se].value);ee=a(he,b),A.backtrack=!0}if(W.comma!==!0&&W.dots!==!0){const ue=A.output.slice(0,W.outputIndex),he=A.tokens.slice(W.tokensIndex);W.value=W.output="\\{",T=ee="\\}",A.output=ue;for(const se of he)A.output+=se.output||se.value}Q({type:"brace",value:T,output:ee}),st("braces"),ze.pop();continue}if(T==="|"){le.length>0&&le[le.length-1].conditions++,Q({type:"text",value:T});continue}if(T===","){let W=T;const ee=ze[ze.length-1];ee&&xe[xe.length-1]==="braces"&&(ee.comma=!0,W="|"),Q({type:"comma",value:T,output:W});continue}if(T==="/"){if(C.type==="dot"&&A.index===A.start+1){A.start=A.index+1,A.consumed="",A.output="",E.pop(),C=x;continue}Q({type:"slash",value:T,output:U});continue}if(T==="."){if(A.braces>0&&C.type==="dot"){C.value==="."&&(C.output=P);const W=ze[ze.length-1];C.type="dots",C.output+=T,C.value+=T,W.dots=!0;continue}if(A.braces+A.parens===0&&C.type!=="bos"&&C.type!=="slash"){Q({type:"text",value:T,output:P});continue}Q({type:"dot",value:T,output:P});continue}if(T==="?"){if(!(C&&C.value==="(")&&b.noextglob!==!0&&ie()==="("&&ie(2)!=="?"){dn("qmark",T);continue}if(C&&C.type==="paren"){const W=ie();let ee=T;(C.value==="("&&!/[!=<:]/.test(W)||W==="<"&&!/<([!=]|\w+>)/.test(pe()))&&(ee=`\\${T}`),Q({type:"text",value:T,output:ee});continue}if(b.dot!==!0&&(C.type==="slash"||C.type==="bos")){Q({type:"qmark",value:T,output:M});continue}Q({type:"qmark",value:T,output:_});continue}if(T==="!"){if(b.noextglob!==!0&&ie()==="("&&(ie(2)!=="?"||!/[!=<:]/.test(ie(3)))){dn("negate",T);continue}if(b.nonegate!==!0&&A.index===0){hr();continue}}if(T==="+"){if(b.noextglob!==!0&&ie()==="("&&ie(2)!=="?"){dn("plus",T);continue}if(C&&C.value==="("||b.regex===!1){Q({type:"plus",value:T,output:z});continue}if(C&&(C.type==="bracket"||C.type==="paren"||C.type==="brace")||A.parens>0){Q({type:"plus",value:T});continue}Q({type:"plus",value:z});continue}if(T==="@"){if(b.noextglob!==!0&&ie()==="("&&ie(2)!=="?"){Q({type:"at",extglob:!0,value:T,output:""});continue}Q({type:"text",value:T});continue}if(T!=="*"){(T==="$"||T==="^")&&(T=`\\${T}`);const W=o.exec(pe());W&&(T+=W[0],A.index+=W[0].length),Q({type:"text",value:T});continue}if(C&&(C.type==="globstar"||C.star===!0)){C.type="star",C.star=!0,C.value+=T,C.output=q,A.backtrack=!0,A.globstar=!0,We(T);continue}let L=pe();if(b.noextglob!==!0&&/^\([^?]/.test(L)){dn("star",T);continue}if(C.type==="star"){if(b.noglobstar===!0){We(T);continue}const W=C.prev,ee=W.prev,ue=W.type==="slash"||W.type==="bos",he=ee&&(ee.type==="star"||ee.type==="globstar");if(b.bash===!0&&(!ue||L[0]&&L[0]!=="/")){Q({type:"star",value:T,output:""});continue}const se=A.braces>0&&(W.type==="comma"||W.type==="brace"),Ue=le.length&&(W.type==="pipe"||W.type==="paren");if(!ue&&W.type!=="paren"&&!se&&!Ue){Q({type:"star",value:T,output:""});continue}for(;L.slice(0,3)==="/**";){const Ge=g[A.index+4];if(Ge&&Ge!=="/")break;L=L.slice(3),We("/**",3)}if(W.type==="bos"&&Ie()){C.type="globstar",C.value+=T,C.output=B(b),A.output=C.output,A.globstar=!0,We(T);continue}if(W.type==="slash"&&W.prev.type!=="bos"&&!he&&Ie()){A.output=A.output.slice(0,-(W.output+C.output).length),W.output=`(?:${W.output}`,C.type="globstar",C.output=B(b)+(b.strictSlashes?")":"|$)"),C.value+=T,A.globstar=!0,A.output+=W.output+C.output,We(T);continue}if(W.type==="slash"&&W.prev.type!=="bos"&&L[0]==="/"){const Ge=L[1]!==void 0?"|$":"";A.output=A.output.slice(0,-(W.output+C.output).length),W.output=`(?:${W.output}`,C.type="globstar",C.output=`${B(b)}${U}|${U}${Ge})`,C.value+=T,A.output+=W.output+C.output,A.globstar=!0,We(T+me()),Q({type:"slash",value:"/",output:""});continue}if(W.type==="bos"&&L[0]==="/"){C.type="globstar",C.value+=T,C.output=`(?:^|${U}|${B(b)}${U})`,A.output=C.output,A.globstar=!0,We(T+me()),Q({type:"slash",value:"/",output:""});continue}A.output=A.output.slice(0,-C.output.length),C.type="globstar",C.output=B(b),C.value+=T,A.output+=C.output,A.globstar=!0,We(T);continue}const ce={type:"star",value:T,output:q};if(b.bash===!0){ce.output=".*?",(C.type==="bos"||C.type==="slash")&&(ce.output=D+ce.output),Q(ce);continue}if(C&&(C.type==="bracket"||C.type==="paren")&&b.regex===!0){ce.output=T,Q(ce);continue}(A.index===A.start||C.type==="slash"||C.type==="dot")&&(C.type==="dot"?(A.output+=F,C.output+=F):b.dot===!0?(A.output+=I,C.output+=I):(A.output+=D,C.output+=D),ie()!=="*"&&(A.output+=J,C.output+=J)),Q(ce)}for(;A.brackets>0;){if(b.strictBrackets===!0)throw new SyntaxError(l("closing","]"));A.output=t.escapeLast(A.output,"["),st("brackets")}for(;A.parens>0;){if(b.strictBrackets===!0)throw new SyntaxError(l("closing",")"));A.output=t.escapeLast(A.output,"("),st("parens")}for(;A.braces>0;){if(b.strictBrackets===!0)throw new SyntaxError(l("closing","}"));A.output=t.escapeLast(A.output,"{"),st("braces")}if(b.strictSlashes!==!0&&(C.type==="star"||C.type==="bracket")&&Q({type:"maybe_slash",value:"",output:`${U}?`}),A.backtrack===!0){A.output="";for(const L of A.tokens)A.output+=L.output!=null?L.output:L.value,L.suffix&&(A.output+=L.suffix)}return A};return y.fastpaths=(g,w)=>{const b={...w},v=typeof b.maxLength=="number"?Math.min(r,b.maxLength):r,S=g.length;if(S>v)throw new SyntaxError(`Input length: ${S}, exceeds maximum allowed length: ${v}`);g=i[g]||g;const{DOT_LITERAL:x,SLASH_LITERAL:E,ONE_CHAR:j,DOTS_SLASH:k,NO_DOT:R,NO_DOTS:P,NO_DOTS_SLASH:z,STAR:U,START_ANCHOR:J}=e.globChars(b.windows),N=b.dot?P:R,O=b.dot?z:R,F=b.capture?"":"?:",I={negated:!1,prefix:""};let _=b.bash===!0?".*?":U;b.capture&&(_=`(${_})`);const M=D=>D.noglobstar===!0?_:`(${F}(?:(?!${J}${D.dot?k:x}).)*?)`,H=D=>{switch(D){case"*":return`${N}${j}${_}`;case".*":return`${x}${j}${_}`;case"*.*":return`${N}${_}${x}${j}${_}`;case"*/*":return`${N}${_}${E}${j}${O}${_}`;case"**":return N+M(b);case"**/*":return`(?:${N}${M(b)}${E})?${O}${j}${_}`;case"**/*.*":return`(?:${N}${M(b)}${E})?${O}${_}${x}${j}${_}`;case"**/.*":return`(?:${N}${M(b)}${E})?${x}${j}${_}`;default:{const K=/^(.*?)\.(\w+)$/.exec(D);if(!K)return;const q=H(K[1]);return q?q+x+K[2]:void 0}}},V=t.removePrefix(g,I);let B=H(V);return B&&b.strictSlashes!==!0&&(B+=`${E}?`),B},ui=y,ui}var pi,Pu;function NA(){if(Pu)return pi;Pu=1;const e=CA(),t=TA(),r=Go(),n=Uo(),o=i=>i&&typeof i=="object"&&!Array.isArray(i),s=(i,a,l=!1)=>{if(Array.isArray(i)){const $=i.map(y=>s(y,a,l));return y=>{for(const g of $){const w=g(y);if(w)return w}return!1}}const u=o(i)&&i.tokens&&i.input;if(i===""||typeof i!="string"&&!u)throw new TypeError("Expected pattern to be a non-empty string");const c=a||{},p=c.windows,f=u?s.compileRe(i,a):s.makeRe(i,a,!1,!0),d=f.state;delete f.state;let m=()=>!1;if(c.ignore){const $={...a,ignore:null,onMatch:null,onResult:null};m=s(c.ignore,$,l)}const h=($,y=!1)=>{const{isMatch:g,match:w,output:b}=s.test($,f,a,{glob:i,posix:p}),v={glob:i,state:d,regex:f,posix:p,input:$,output:b,match:w,isMatch:g};return typeof c.onResult=="function"&&c.onResult(v),g===!1?(v.isMatch=!1,y?v:!1):m($)?(typeof c.onIgnore=="function"&&c.onIgnore(v),v.isMatch=!1,y?v:!1):(typeof c.onMatch=="function"&&c.onMatch(v),y?v:!0)};return l&&(h.state=d),h};return s.test=(i,a,l,{glob:u,posix:c}={})=>{if(typeof i!="string")throw new TypeError("Expected input to be a string");if(i==="")return{isMatch:!1,output:""};const p=l||{},f=p.format||(c?r.toPosixSlashes:null);let d=i===u,m=d&&f?f(i):i;return d===!1&&(m=f?f(i):i,d=m===u),(d===!1||p.capture===!0)&&(p.matchBase===!0||p.basename===!0?d=s.matchBase(i,a,l,c):d=a.exec(m)),{isMatch:!!d,match:d,output:m}},s.matchBase=(i,a,l)=>(a instanceof RegExp?a:s.makeRe(a,l)).test(r.basename(i)),s.isMatch=(i,a,l)=>s(a,l)(i),s.parse=(i,a)=>Array.isArray(i)?i.map(l=>s.parse(l,a)):t(i,{...a,fastpaths:!1}),s.scan=(i,a)=>e(i,a),s.compileRe=(i,a,l=!1,u=!1)=>{if(l===!0)return i.output;const c=a||{},p=c.contains?"":"^",f=c.contains?"":"$";let d=`${p}(?:${i.output})${f}`;i&&i.negated===!0&&(d=`^(?!${d}).*$`);const m=s.toRegex(d,a);return u===!0&&(m.state=i),m},s.makeRe=(i,a={},l=!1,u=!1)=>{if(!i||typeof i!="string")throw new TypeError("Expected a non-empty string");let c={negated:!1,fastpaths:!0};return a.fastpaths!==!1&&(i[0]==="."||i[0]==="*")&&(c.output=t.fastpaths(i,a)),c.output||(c=t(i,a)),s.compileRe(c,a,l,u)},s.toRegex=(i,a)=>{try{const l=a||{};return new RegExp(i,l.flags||(l.nocase?"i":""))}catch(l){if(a&&a.debug===!0)throw l;return/$^/}},s.constants=n,pi=s,pi}var fi,_u;function PA(){if(_u)return fi;_u=1;const e=NA(),t=Go();function r(n,o,s=!1){return o&&(o.windows===null||o.windows===void 0)&&(o={...o,windows:t.isWindows()}),e(n,o,s)}return Object.assign(r,e),fi=r,fi}var _A=PA();const MA=Zr(_A),IA=e=>e.logger,Li="Validation: File Size",ym=e=>typeof e=="string"?Uw(e):e,$m=(e,t,r,n,o)=>{if(r){o&&e.raw(`
|
|
193
|
+
`),e.warn({message:t,prefix:"validation:file-size"});return}Y(n,t)},WA=(e,t,r,n,o)=>{for(const[s,i]of Object.entries(r)){const a=ym(i);if(!Number.isFinite(a)||a<=0){t.debug({message:`Invalid limit for ${s}: ${String(i)}`,prefix:Li});continue}const l=e.buildEntries.find(u=>{const c=s.replace(new RegExp(`^.?/?${rm(e.options.outDir)}/?`),"");return u.path.endsWith(c)||MA(s)(u.path)});if(!l?.size?.bytes){t.debug({message:l?`Entry file has no size information: ${s}.`:`Entry file not found: ${s}, please check your configuration.`,prefix:Li});continue}if(l.size.bytes>a){const u=`File size exceeds the limit: ${G(e.options.outDir,l.path)} (${je(l.size.bytes)} / ${je(a,{decimals:2})})`;$m(t,u,n,e,o)}}},BA=(e,t,r,n,o)=>{const s=e.buildEntries.reduce((a,l)=>{const u=l.size?.bytes;return a+(typeof u=="number"?u:0)},0),i=ym(r);if(!Number.isFinite(i)||i<=0){t.debug({message:`Invalid total limit: ${String(r)}`,prefix:Li});return}if(s>i){const a=`Total file size exceeds the limit: ${je(s)} / ${je(i,{decimals:2})}`;$m(t,a,n,e,o)}},DA=(e,t)=>{const r=e.options.validation,{allowFail:n=!1,limit:o,limits:s={}}=r.bundleLimit??{},i=IA(e);WA(e,i,s,n,t),o&&BA(e,i,o,n,t&&Object.keys(s).length===0)},Mu="rollup-dts.json",LA=e=>{const t=new Set,r=[];for(const[n,o]of Object.entries(e))o.type==="chunk"&&o.isEntry&&(t.add(n),r.push(n));if(r.length!==0){for(;r.length>0;){const n=r.pop(),o=e[n];if(o.type==="chunk")for(const s of[...o.imports,...o.dynamicImports])Object.hasOwn(e,s)&&e[s].type==="chunk"&&!t.has(s)&&(t.add(s),r.push(s))}return t}},FA=e=>{const t=LA(e);if(t)for(const[r,n]of Object.entries(e))n.type==="chunk"&&!n.isEntry&&!t.has(r)&&delete e[r]},HA=e=>e.logger,Iu="__packem_skip__/",Wu=(e,t)=>{const r=new Set;if(t.options.emitCJS&&r.add(Ke(t,"cjs")),t.options.emitESM&&r.add(Ke(t,"esm")),(t.options.declaration===!0||t.options.declaration==="compatible")&&r.add("d.ts"),e.declarationExtensions)for(const n of e.declarationExtensions)r.add(n);return r},qA=async(e,t,r)=>{const n=e.options.bundler==="rolldown",o=n?await Vd(e,t):await Jd(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input??{}).length===0)return;let s,i;n?s=await(await va())(o):(i=`${r}/${Ve(e.options.entries.map(a=>a.name??"").filter(Boolean).toSorted((a,l)=>a.localeCompare(l)).join(","))}`,o.cache=t.get(Mu,i),s=await(await Va())(o));try{!n&&i!==void 0&&t.set(Mu,s.cache,i),await e.hooks.callHook("rollup:dts:build",e,s),HA(e).info({message:"Building declaration files...",prefix:"dts"});const a=new Map;for(const p of e.options.entries)p.name&&a.set(p.name,p);const l=new Set;for(const p of e.options.entries)for(const f of Wu(p,e))l.add(f);const u=X(e.options.rootDir,e.options.outDir),c={generateBundle(p,f){for(const d of Object.keys(f))d.startsWith(Iu)&&delete f[d];FA(f)},name:"packem:filter-skip-chunks"};for(const p of l)await s.write({chunkFileNames:f=>Br(f,p),dir:u,entryFileNames:f=>{const d=f.name.endsWith(".d")?f.name.slice(0,-2):f.name,m=d?a.get(d):void 0;return m&&!Wu(m,e).has(p)?`${Iu}[name].${p}`:`[name].${p}`},plugins:[c]});await e.hooks.callHook("rollup:dts:done",e)}finally{await s.close(),await t.flush()}};var JA=an();const bm=Zr(JA),zA=eg("packem:exe"),UA=/(?:^|,)packem:exe(?:,|$)/,GA=()=>{const e=process.env.NODE_DEBUG;return e?UA.test(e):!1},wm=()=>{const e=((t,...r)=>{zA(t,...r)});return Object.defineProperty(e,"enabled",{get:GA}),e},VA=()=>{const e=_h();if(er==="darwin")return G(e,"Library/Caches/packem");if(er==="win32"){const r=process.env.LOCALAPPDATA;return r?G(r,"packem/Caches"):G(e,"AppData/Local/packem/Caches")}const t=process.env.XDG_CACHE_HOME;return t?G(t,"packem"):G(e,".cache/packem")},KA=e=>{const t=VA(),r=e.platform==="win"?"node.exe":"node";return G(t,"node",`v${e.nodeVersion}`,`${e.platform}-${e.arch}`,r)};var YA=rp();const XA=Zr(YA),vm=e=>e==="win"?"zip":e==="linux"?"tar.xz":"tar.gz",ZA=e=>{const{arch:t,nodeVersion:r,platform:n}=e,o=vm(n);return`https://nodejs.org/dist/v${r}/node-v${r}-${n}-${t}.${o}`},QA=e=>{const{arch:t,nodeVersion:r,platform:n}=e,o=`node-v${r}-${n}-${t}`;return n==="win"?`${o}/node.exe`:`${o}/bin/node`},Bu="https://nodejs.org/dist/index.json",e3=/^v/,t3=async e=>{let t=e;if(t==="latest"||t==="latest-lts"){const n=await fetch(Bu);if(!n.ok)throw new Error(`Failed to fetch Node.js releases: HTTP ${String(n.status)} from ${Bu}`);const o=await n.json(),s=t==="latest";let i="";for(const a of o)if(s||a.lts!==!1){i=a.version;break}if(i==="")throw new Error(`No matching Node.js release found for "${t}".`);t=i.replace(e3,"")}const r=XA(t);if(!r)throw new Error(`Invalid Node.js version: ${t}. Please provide a valid version string (e.g., "25.7.0").`);if(!bm(r,">=25.7.0"))throw new Error(`Node.js ${r} does not support SEA (Single Executable Applications). Required minimum version is 25.7.0. Please update the nodeVersion in your target configuration.`);return r},r3=e=>`-${e.platform}-${e.arch}`,tt=wm(),n3=/\s+/,o3=async(e,t)=>{const r=`https://nodejs.org/dist/v${e}/SHASUMS256.txt`;tt("Fetching checksums from: %s",r);const n=await fetch(r);if(!n.ok)throw new Error(`Failed to download Node.js checksums: HTTP ${String(n.status)} from ${r}`);const o=await n.text();for(const s of o.split(`
|
|
194
|
+
`)){const[i,a]=s.trim().split(n3);if(a===t&&i)return i.toLowerCase()}throw new Error(`No checksum entry for "${t}" found in ${r}.`)},s3=async(e,t,r)=>{const n=QA(r),o=Z(t);if(tt("Extracting %s from archive to %s",n,o),r.platform==="win")await qn("tar",["-xf",e,"-C",o,"--strip-components=1",n],{nodeOptions:{stdio:"inherit"},throwOnError:!0});else{const a=e.endsWith(".tar.xz")?"J":"z";await qn("tar",[`-x${a}f`,e,"-C",o,"--strip-components=2",n],{nodeOptions:{stdio:"inherit"},throwOnError:!0})}const s=r.platform==="win"?"node.exe":"node",i=G(o,s);i!==t&&await Rh(i,t)},i3=async(e,t)=>{tt("Resolving Node.js binary for target: %O",e);const r={...e,nodeVersion:await t3(e.nodeVersion)},n=KA(r);if(tt("Cache path: %s",n),await Ct(n))return tt("Cache hit: %s",n),t.info(`Using cached Node.js ${r.nodeVersion} for ${r.platform}-${r.arch}`),n;const o=ZA(r);tt("Cache miss, downloading from: %s",o),t.info(`Downloading Node.js ${r.nodeVersion} for ${r.platform}-${r.arch}...`),t.info(` ${o}`),await pp(Z(n),{recursive:!0});const s=await fetch(o);if(!s.ok)throw new Error(`Failed to download Node.js binary: HTTP ${String(s.status)} from ${o}`);const i=vm(r.platform),a=sg.from(await s.arrayBuffer()),l=Fe(o),u=await o3(r.nodeVersion,l),c=Hh("sha256").update(a).digest("hex");if(c!==u)throw new Error(`Checksum mismatch for ${l}: expected ${u}, got ${c}. The download may be corrupted or tampered with.`);tt("Checksum verified for %s",l);const p=`${n}.download.${qh()}.${i}`;tt("Downloaded %d bytes, writing to: %s",a.length,p),await fp(p,a);try{await s3(p,n,r),r.platform!=="win"&&await cp(n,493),tt("Binary cached at: %s",n),t.info(`Cached Node.js binary at: ${n}`)}finally{await $o(p,{force:!0})}return n},Kt=wm(),a3=/\.d\.[mc]?ts$/,l3=e=>({buildEntries:e.buildEntries,logger:e.logger,options:e.options,packageType:e.pkg.type}),c3=e=>{const{logger:t,options:r}=e;if(Fn.bun||Fn.deno)throw new Error("The `exe` option is not supported in Bun and Deno environments.");if(!bm(process.version,">=25.7.0"))throw new Error(`Node.js ${process.version} does not support \`exe\` option. Please upgrade to Node.js 25.7.0 or later.`);if(r.entries.length>1){const n=r.entries.map(o=>`- ${o.input}`).join(`
|
|
195
|
+
`);throw new Error(`The \`exe\` feature only supports a single entry point. Found ${String(r.entries.length)} entries:
|
|
196
|
+
${n}`)}r.declaration&&t.warn("Generating .d.ts files with the `exe` option is not recommended since they won't be included in the executable. Consider separating your library and executable targets if you need type declarations."),t.info("`exe` option is experimental and may change in future releases.")},u3=(e,t)=>e.endsWith(".cjs")?"commonjs":e.endsWith(".mjs")||t==="module"?"module":"commonjs",Du=er==="win32"?"win":er,Lu=(e,t,r,n,o)=>{let s;return e.fileName?s=typeof e.fileName=="function"?e.fileName(t):e.fileName:s=Fe(r,tr(r)),o&&(s+=o),n==="win"&&(s+=".exe"),s},Fu=async(e,t,r,n,o,s,i)=>{const{logger:a,options:l,packageType:u}=e,c=X(l.rootDir,t.outDir??"build");await pp(c,{recursive:!0});const p=G(c,o);Kt("Building SEA executable: %s -> %s",n,p);const f=performance.now(),d=await up(G(mp(),"packem-sea-"));try{const h={disableExperimentalSEAWarning:!0,...t.seaConfig,main:n,mainFormat:u3(r.path,u),output:p};i&&(h.executable=i);const $=G(d,"sea-config.json");await fp($,JSON.stringify(h)),Kt("Wrote sea-config.json: %O -> %s",h,$),Kt("Running: %s --build-sea %s",process.execPath,$),await qn(process.execPath,["--build-sea",$],{nodeOptions:{stdio:["ignore","ignore","inherit"]},throwOnError:!0})}finally{Kt.enabled?Kt("Preserving temp directory for debugging: %s",d):await $o(d,{force:!0,recursive:!0})}if(s==="darwin")try{await qn("codesign",["--sign","-",p],{nodeOptions:{stdio:"inherit"},throwOnError:!0})}catch{const h=er==="darwin"?`You can sign it manually using:
|
|
197
|
+
codesign --sign - "${p}"`:`Automatic code signing is not supported on ${er}.`;a.warn(`Failed to code-sign the executable. ${h}`)}if(await Ct(p)){const h=await Qr(p),$=je(h.size,{decimals:2});a.info(`${Ae(ke(l.rootDir,p))} ${Gu($)}`)}const m=Math.round(performance.now()-f);a.success(`Built executable: ${qt(ke(l.rootDir,p))} ${De(`(${String(m)}ms)`)}`)},p3=async e=>{const t=l3(e),{buildEntries:r,logger:n,options:o}=t,s=o.exe;if(!s)return;const i=typeof s=="object"?s:{};c3(t);const a=r.filter(p=>p.type==="entry"&&!a3.test(p.path));if(a.length===0)throw new Error("The `exe` feature requires a built entry, but no entry chunks were found.");if(a.length>1){const p=a.map(f=>`- ${f.path}`).join(`
|
|
198
|
+
`);throw new Error(`The \`exe\` feature only supports single-chunk outputs. Found ${String(a.length)} chunks:
|
|
199
|
+
${p}`)}const l=a[0],u=G(o.rootDir,o.outDir,l.path);Kt("Building executable with SEA for chunk: %s",l.path);const{targets:c}=i;if(c!==void 0&&c.length>0){i.seaConfig?.executable&&n.warn("`seaConfig.executable` is ignored when `targets` is specified.");for(const p of c){const f=await i3(p,n),d=r3(p),m=Lu(i,l,u,p.platform,d);await Fu(t,i,l,u,m,p.platform,f)}}else{const p=Lu(i,l,u,Du);await Fu(t,i,l,u,p,Du)}},f3=async(e,t)=>{if(e.length===0)return[];const r=t<=0||!Number.isFinite(t)?1/0:t,n=Array.from({length:e.length});let o=0;const s=async()=>{for(;o<e.length;){const a=o;o+=1;const l=e[a];l&&(n[a]=await l())}},i=Array.from({length:Math.min(r,e.length)},()=>s());return await Promise.all(i),n},d3=async e=>await new Promise((t,r)=>{let n=0;const o=Zi(e).pipe(rg({params:{[ng.BROTLI_PARAM_QUALITY]:4}}));o.on("error",r),o.on("data",s=>{n+=s.length}),o.on("end",()=>{t(n)})}),di=e=>e==null?"undefined":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"||typeof e=="symbol"?e.toString():JSON.stringify(e),mi=(e,t,r)=>{let n=e.get(t);return n===void 0&&(n=r(),e.set(t,n)),n},m3=(e,t,r,n)=>{{const o=new Map;for(const i of e){const a=mi(o,di(i[t]),()=>new Map),l=mi(a,di(i[r]),()=>new Map);mi(l,di(i[n]),()=>[]).push(i)}const s={};for(const[i,a]of o){const l={};for(const[u,c]of a)l[u]=Object.fromEntries(c);s[i]=l}return s}},h3=async e=>await new Promise((t,r)=>{let n=0;const o=Zi(e).pipe(og({level:9}));o.on("error",r),o.on("data",s=>{n+=s.length}),o.on("end",()=>{t(n)})}),g3=2,y3=/\.js$/,$3=/\.d\.[m|c]ts$/,b3=(e,t,r)=>[`total size: ${ne(je(t,{decimals:2}))}`,e.size?.brotli&&`brotli size: ${ne(je(e.size.brotli,{decimals:2}))}`,e.size?.gzip&&`gzip size: ${ne(je(e.size.gzip,{decimals:2}))}`,r!==0&&`chunk size: ${ne(je(r,{decimals:2}))}`].filter(Boolean).join(", "),w3=(e,t,r,n)=>{const o=Pe(t,"cjs"),s=Pe(t,"esm"),i=Ke(t,"cjs"),a=Ke(t,"esm");let l=e.path.replace(y3,".d.ts"),u="commonjs";e.path.endsWith(`.${o}`)?l=e.path.replace(new RegExp(String.raw`\.${o}$`),`.${i}`):e.path.endsWith(`.${s}`)&&(u="module",l=e.path.replace(new RegExp(String.raw`\.${s}$`),`.${a}`));const c=t.buildEntries.find(f=>f.path.endsWith(l));if(!c)return"";n.push(c.path);let p;return!l.includes(".d.ts")&&(l=l.replace($3,".d.ts"),p=t.buildEntries.find(f=>f.path.endsWith(l)),!p)?"":(p&&n.push(p.path),u==="commonjs"&&p?`
|
|
200
|
+
types:
|
|
201
|
+
${[c,p].map(f=>`${De(" └─ ")+Ae(r(f.path))} (total size: ${ne(je(f.size?.bytes??0,{decimals:2}))})`).join(`
|
|
202
|
+
`)}`:`
|
|
203
|
+
types: ${Ae(r(c.path))} (total size: ${ne(je(c.size?.bytes??0,{decimals:2}))})`)},v3=(e,t,r,n)=>{let o=e.size?.bytes??0,s=0;for(const a of e.chunks??[]){const l=t.buildEntries.find(u=>u.path.endsWith(a))?.size?.bytes??0;o+=l,s+=l}let i=` ${Ae(r(e.path))} (${b3(e,o,s)})`;if(i+=e.exports?.length?`
|
|
204
|
+
exports: ${De(e.exports.join(", "))}`:"",e.chunks?.length&&(i+=`
|
|
205
|
+
${e.chunks.map(a=>{const l=t.buildEntries.find(u=>u.path===a)?.bytes;return De(` └─ ${r(a)}${Ae(l?` (${je(l,{decimals:2})})`:"")}`)}).join(`
|
|
206
|
+
`)}`),e.dynamicImports&&e.dynamicImports.length>0&&(i+=`
|
|
207
|
+
dynamic imports:`,i+=`
|
|
208
|
+
${e.dynamicImports.map(a=>De(` └─ ${r(a)}`)).join(`
|
|
209
|
+
`)}`),e.modules&&e.modules.length>0){const a=e.modules.filter(l=>l.id.includes("node_modules")).toSorted((l,u)=>(u.bytes||0)-(l.bytes||0)).map(l=>De(` 📦 ${r(l.id)}${Ae(l.bytes?` (${je(l.bytes,{decimals:2})})`:"")}`)).join(`
|
|
210
|
+
`);i+=a.length>0?`
|
|
211
|
+
inlined modules:
|
|
212
|
+
${a}`:""}return t.options.declaration&&(i+=w3(e,t,r,n)),i+=`
|
|
213
|
+
|
|
214
|
+
`,e.chunk?De(i):i},x3=(e,t)=>{const r=i=>ke(t.options.rootDir,X(t.options.outDir,i));let n=!1;const o=[],s=t.buildEntries.filter(i=>i.type==="entry");if(s.length>0){e.raw(`Entries:
|
|
215
|
+
`);for(const i of s){const a=v3(i,t,r,o);n=!0,e.raw(a)}}if(t.buildEntries.filter(i=>i.type==="asset").length>0){let i="Assets:";for(const a of t.buildEntries.filter(l=>l.type==="asset"&&!o.includes(l.path)))i+=`${De(`
|
|
216
|
+
└─ `)+Ae(r(a.path))} (total size: ${ne(je(a.size?.bytes??0,{decimals:2}))})`;i+=`
|
|
217
|
+
|
|
218
|
+
`,e.raw(i)}return n&&e.raw("Σ Total dist size (byte size):",ne(je(t.buildEntries.reduce((i,a)=>i+(a.size?.bytes??0),0),{decimals:2})),`
|
|
219
|
+
`),n},E3=/\.d\.[mc]?ts$/,hi=e=>e.filter(t=>!E3.test(t.input)),S3=(e,t)=>{const r=[];return e!=="undefined"&&r.push(`${ne(e)} environment`),t!=="undefined"&&r.push(`${ne(t)} runtime`),r.length>0?`Preparing build for ${r.join(" with ")}`:""},k3=(e,t)=>{const r={};return e!=="undefined"&&(r[["process","env","NODE_ENV"].join(".")]=JSON.stringify(e)),r[["process","env","EdgeRuntime"].join(".")]=JSON.stringify(t==="edge-light"),Object.freeze(r)},j3=(e,t)=>{const r=[];return e!=="undefined"&&r.push(e),t!=="undefined"&&r.push(t),r.length>0?`${r.join("/")}/`:""},Cn=(e,t,r,n,o,s)=>({...e,options:{...e.options,emitCJS:t,emitESM:r,entries:n,minify:o,rollup:{...e.options.rollup,replace:e.options.rollup.replace?un(e.options.rollup.replace,{},s):!1}}}),A3=async(e,t)=>{const r=e.logger,n=l=>{const u=l.name??l.fileAlias;if(!u)return"default";const c=[".browser",".server",".development",".node",".workerd"];for(const p of c)if(u.includes(p))return p.slice(1);return"default"},o=e.options.entries.map(l=>({...l,environment:l.environment??"undefined",runtime:l.runtime??"undefined",type:n(l)})),s=m3(o,"environment","runtime","type"),i=new Set,a=new Set;for(const[l,u]of Object.entries(s))for(const[c,p]of Object.entries(u))for(const[,f]of Object.entries(p)){const d={...e,environment:l==="undefined"?void 0:l,options:{...e.options,rollup:{...e.options.rollup,replace:e.options.rollup.replace?{...e.options.rollup.replace,values:{}}:e.options.rollup.replace}}};if(!e.options.dtsOnly&&(l!=="undefined"||c!=="undefined")){const k=S3(l,c);k&&r.info(k)}const m=c==="undefined"?void 0:c;d.options.runtime=m;try{await e.hooks.callHook("rollup:options",d,{})}catch(k){throw r.error(`Error calling rollup:options hook: ${String(k)}`),k}const h=d.options.rollup.replace,$=e.options.rollup.replace,y=h?k3(l,c):{};if(h){h.values??={};const k=$?un($).values:{};Object.assign(h.values,y,k)}else r.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");const g=h?h.values??y:y,w=j3(l,c);let b=d.options.minify??!1;l==="development"?b=!1:l==="production"&&(b=!0);const v=f.map(k=>{const{environment:R,runtime:P,...z}=k;return{...z,environment:R==="undefined"?void 0:R,runtime:P==="undefined"?void 0:P}}),S=[],x=[],E=[],j=[];for(const k of v){if(Yr(k.name)){k.declaration&&j.push(k);continue}k.cjs&&k.esm?S.push(k):k.cjs?E.push(k):k.esm?x.push(k):k.declaration&&j.push(k)}if(S.length>0){const k=Cn(d,!0,!0,hi(S),b,g);if(e.options.dtsOnly||i.add({context:k,fileCache:t,subDirectory:w}),e.options.declaration){const R=S.filter(P=>P.declaration);R.length>0&&a.add({context:{...k,options:{...k.options,entries:R}},fileCache:t,subDirectory:w})}}if(x.length>0){const k=Cn(d,!1,!0,hi(x),b,g);if(e.options.dtsOnly||i.add({context:k,fileCache:t,subDirectory:w}),e.options.declaration){const R=x.filter(P=>P.declaration);R.length>0&&a.add({context:{...k,options:{...k.options,entries:R}},fileCache:t,subDirectory:w})}}if(E.length>0){const k=Cn(d,!0,!1,hi(E),b,g);if(e.options.dtsOnly||i.add({context:k,fileCache:t,subDirectory:w}),e.options.declaration){const R=E.filter(P=>P.declaration);R.length>0&&a.add({context:{...k,options:{...k.options,entries:R}},fileCache:t,subDirectory:w})}}if(d.options.declaration&&j.length>0){const k=j.some(U=>U.declarationCjs),R=j.some(U=>U.declarationEsm),P=j.some(U=>U.declaration&&!U.declarationCjs&&!U.declarationEsm),z=Cn(d,k||P,R,j,b,g);a.add({context:z,fileCache:t,subDirectory:w})}}return{builders:i,typeBuilders:a}},O3=async(e,t)=>{const r=e.logger;await e.hooks.callHook("build:before",e);const{builders:n,typeBuilders:o}=await A3(e,t);if(n.size>0&&await Promise.all(Array.from(n,async({context:l,fileCache:u,subDirectory:c})=>l9(l,u,c,Zd(l.options.bundler)))),o.size>0){const l=e.options.dtsConcurrency??g3;await f3(Array.from(o,({context:u,fileCache:c,subDirectory:p})=>()=>qA(u,c,p)),l)}r.success(qi(e.options.name?`Build succeeded for ${e.options.name}`:"Build succeeded"));const s=new Set;e.buildEntries=e.buildEntries.filter(l=>s.has(l.path)?!1:(s.add(l.path),!0));const i=G(e.options.rootDir,e.options.outDir),a=[];for await(const l of Rm(i,{includeDirs:!1,includeFiles:!0})){let u=e.buildEntries.find(f=>G(i,f.path)===l.path);u||(u={chunk:!0,path:l.path},e.buildEntries.push(u)),u.size??={};const c=X(i,l.path),p=u.size;a.push((async()=>{if(!p.bytes){const m=await Qr(c);p.bytes=m.size}const[f,d]=await Promise.all([p.brotli??d3(c),p.gzip??h3(c)]);p.brotli=f,p.gzip=d})())}return await Promise.all(a),e.options.exe&&await p3(e),await e.hooks.callHook("build:done",e),x3(r,e)},R3=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>{if(!r)return[t,{}];const n=Object.fromEntries(Object.entries(r).map(([o,s])=>Array.isArray(s)?[o,[...new Set(s)]]:[o,[]]));return[t,n]})),C3=async(e,t,r,n,o,s)=>{const i=e;if(s!=="*"&&Le.valid(Le.coerce(s))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");i.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:packem:node10-compatibility"});const a={};for(const c of t){if(c.exportKey===void 0||c.name===void 0)continue;const{name:p}=c;for(const f of c.exportKey)a[f]=f.includes("/*")?[`./${G(r,Z(p),"*.d.ts")}`]:[...a[f]??[],`./${G(r,`${p}.d.ts`)}`]}const l=G(n,"package.json"),u=await fo(l);o==="file"&&Object.keys(a).length>0?(await Ju(l,{...u,typesVersions:R3({...u.typesVersions,[s]:a})},{detectIndent:!0}),i.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:packem:node10-compatibility"})):Object.keys(a).length>0&&i.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
|
|
220
|
+
|
|
221
|
+
${JSON.stringify({typesVersions:{"*":a}},void 0,4)}
|
|
222
|
+
`,prefix:"plugin:packem:node10-compatibility"})},Ht=e=>e??{},T3=/\.(md|txt|htm|html|data)$/,N3=/^@swc\/helpers(?:\/.*)?$/,P3=e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},_3=(e,t,r,n,o,s,i,a)=>{const l=P3(i?.config.compilerOptions?.jsx),u=a.split("."),c=_9()(q1,o,{alias:{},browserTargets:hh(),cjsInterop:!1,clean:!0,debug:n,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:n,interopDefault:!0},minify:r===Wr,name:(s.name??"").split("/").pop()??"default",outDir:i?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!0},css:{autoModules:!0,extensions:[".css",".pcss",".postcss",".sss"],namedExports:!0},dataUri:{srcset:!0},debarrel:{},detectDuplicated:{},dts:{compilerOptions:{baseUrl:i?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99}},dynamicVars:{errorWhenNoFilesFound:!0,exclude:kt,include:Et},esbuild:{charset:"utf8",jsx:l,jsxDev:i?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:i?.config.compilerOptions?.jsxFactory,jsxFragment:Ht(i?.config.compilerOptions).jsxFragmentFactory,jsxImportSource:Ht(i?.config.compilerOptions).jsxImportSource,jsxSideEffects:!0,keepNames:!1,sourcesContent:!1,supported:{"import-attributes":!0},target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!1},license:{dependenciesTemplate:(d,m,h)=>`
|
|
223
|
+
# Licenses of bundled dependencies
|
|
224
|
+
The published ${h} artifact additionally contains code with the following licenses:
|
|
225
|
+
${d.length>0?`${d.join(", ")}
|
|
226
|
+
|
|
227
|
+
`:`
|
|
228
|
+
`}# Bundled dependencies:
|
|
229
|
+
${m}`,dtsTemplate:(d,m,h)=>`
|
|
230
|
+
# Licenses of bundled types
|
|
231
|
+
The published ${h} artifact additionally contains code with the following licenses:
|
|
232
|
+
${d.length>0?`${d.join(", ")}
|
|
233
|
+
|
|
234
|
+
`:`
|
|
235
|
+
`}# Bundled types:
|
|
236
|
+
${m}`},nativeModules:{},node10Compatibility:!1,output:{importAttributesKey:Number(u[0])>=22?"with":"assert"},oxc:{jsx:l==="preserve"?"preserve":{development:r!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:Ht(i?.config.compilerOptions).jsxFragmentFactory,pure:!0,runtime:l==="transform"||l==="automatic"?"automatic":"classic",useBuiltIns:!0,useSpread:!0}},patchTypes:{},polyfillNode:{},preserveDirectives:{include:Et},preserveDynamicImports:!0,pure:{},raw:{exclude:kt,include:[T3]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{aliasFields:[],builtinModules:!1,conditionNames:[r??"production","module-sync","import","require","default"],extensions:ho,mainFields:["module","main"]},resolveExternals:{builtins:!0,builtinsPrefix:"add",deps:!0,devDeps:!1,exclude:[],optDeps:!0,peerDeps:!0},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:kt,include:Et},sourcemap:{},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:!i?.config.compilerOptions?.esModuleInterop,include:Et,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:r===Wr,...i?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(i.config.compilerOptions.jsx)?{jsxFragmentPragma:Ht(i.config.compilerOptions).jsxFragmentFactory,jsxImportSource:Ht(i.config.compilerOptions).jsxImportSource,jsxPragma:i.config.compilerOptions.jsxFactory,jsxRuntime:l,transforms:["typescript","jsx"]}:{transforms:["typescript"]}},swc:{include:Et,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!0,keepClassNames:!0,loose:!0,parser:{decorators:i?.config.compilerOptions?.experimentalDecorators,syntax:i?"typescript":"ecmascript",[i?"tsx":"jsx"]:!0},target:i?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:i?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:i?.config.compilerOptions?.experimentalDecorators,react:{development:r!==Wr,pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:Ht(i?.config.compilerOptions).jsxFragmentFactory,runtime:l,throwIfNamespace:!0},treatConstEnumAsEnum:i?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:i?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:I9(t,s),preset:"recommended",propertyReadSideEffects:!0},tsconfigPaths:{resolveAbsolutePath:!1},url:{emitFiles:!0,fileName:"[hash][extname]",include:["**/*.svg","**/*.png","**/*.jp(e)?g","**/*.gif","**/*.webp"],limit:14*1024},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:kt}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,format:"inline",githubPages:!1,groupOrder:["Classes","Constructors","Accessors","Methods","Functions","Namespaces","Variables","Enumerations","Interfaces","Type Aliases","*"],kindSortOrder:["Project","Module","Class","Interface","Function","Namespace","Variable","Enum","EnumMember","TypeAlias","Reference","Constructor","Property","Accessor","Method","Parameter","TypeParameter","TypeLiteral","CallSignature","ConstructorSignature","IndexSignature","GetSignature","SetSignature"],marker:"TYPEDOC",name:s.name??"unknown",pretty:!0,readme:"none",showConfig:n,tsconfig:i?.path},validation:{dependencies:{hoisted:{exclude:[]},unused:{exclude:[]}},packageJson:{bin:!0,dependencies:!0,exports:!0,files:!0,main:!0,module:!0,name:!0,types:!0,typesVersions:!0}}});c.runtime===void 0&&(e.warn(`No runtime specified, defaulting to 'node'. Add 'runtime: "node"' (or 'runtime: "browser"') to your packem config or pass --runtime to silence this warning.`),c.runtime="node");const p=new Map([...Object.entries(s.dependencies??{}),...Object.entries(s.devDependencies??{})]),f=c.bundler==="rolldown";if(f&&o.transformer!==void 0)throw new Error('The `transformer` option is not supported when `bundler: "rolldown"`. Rolldown uses its own oxc-based transform — remove `transformer` from your packem config.');if(!f){if(c.transformer?.NAME===void 0)throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");c.transformerName=c.transformer.NAME,c.transformerName==="swc"&&(c.externals=[...c.externals,N3])}if(e.info({message:`Using ${ne("node ")}${a}`,prefix:"system"}),e.info({message:f?`Using ${ne("rolldown")} with ${ne(c.runtime)} build runtime`:`Using ${ne("rollup")} with ${ne(c.runtime)} build runtime`,prefix:"bundler"}),!f&&c.transformerName){let d=c.transformerName;c.transformerName==="oxc"?d="oxc-transform":c.transformerName==="swc"&&(d="@swc/core");const m=p.get(d)??"0.0.0";e.info({message:`Using ${ne(c.transformerName)} ${m}`,prefix:"transformer"})}if(c.rollup.resolve&&(c.rollup.resolve.preferBuiltins=c.runtime==="node",c.rollup.resolve.preferBuiltins&&(c.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true"))),c.resolvedBrowserTargets??=c.browserTargets??[],c.runtime==="node"&&(c.browserTargets=[]),c.runtime==="browser"&&(c.rollup.resolve&&c.rollup.resolve.browser===void 0&&(c.rollup.resolve.browser=!0),c.browserTargets&&c.browserTargets.length>0&&e.debug(`Using browser targets: ${c.browserTargets.join(", ")}`)),Ou(c.alias),c.rollup.alias!==!1&&c.rollup.alias?.entries&&Ou(c.rollup.alias.entries),c.outputExtensionMap){let d;for(const[m,h]of Object.entries(c.outputExtensionMap)){if(!["cjs","esm"].includes(m))throw new Error(`Invalid output extension map: ${m} must be "cjs" or "esm"`);if(typeof h!="string")throw new TypeError(`Invalid output extension map: ${m} must be a string`);if(h.startsWith("."))throw new Error(`Invalid output extension map: ${m} must not start with a dot. Example: "cjs": "c.js", "esm": "m.js"`);if(d===void 0)d=h;else if(d===h)throw new Error(`Invalid output extension map: ${m} must be different from the other key`)}}return i?.config.compilerOptions?.declarationMap&&(c.sourcemap=!0,e.info("Enabling sourcemap because declarationMap is enabled in tsconfig.json")),c},M3=async(e,t,r,n,o,s,i,a,l)=>{const u=s.hooks,c=_3(e,t,n,o,s,i,a,l);Tm(G(c.rootDir,c.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,environment:n,hoistedDependencies:new Set,hooks:gh(),implicitDependencies:new Set,jiti:yh(c.rootDir,c.jiti),logger:e,mode:r,options:c,pkg:i,tsconfig:a,usedDependencies:new Set,warnings:new Set};u&&p.hooks.addHooks(u),await p.hooks.callHook("build:prepare",p),p.options.emitESM===void 0&&e.info("Emitting of ESM bundles is disabled."),p.options.emitCJS===void 0&&e.info("Emitting of CJS bundles is disabled."),p.options.minify&&e.info("Minification is enabled, the output will be minified"),J9(p);const f=Of(i,["typescript"]);if(p.options.declaration&&p.tsconfig===void 0&&f)throw new Error("Cannot build declaration files without a tsconfig.json");return f?p.options.declaration===!1&&e.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(p.options.declaration=!1,e.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),p.options.declaration&&e.info(`Using typescript version: ${ne(i.devDependencies?.typescript??i.dependencies?.typescript??"unknown")}`),p.options.declaration&&(i.dependencies?.typescript||i.devDependencies?.typescript)&&!p.tsconfig?.config.compilerOptions?.isolatedModules&&e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
237
|
+
Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
|
|
238
|
+
To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),nm(p),p},I3=e=>{switch(e){case"build":return"Building";case"jit":return"Stubbing";case"watch":return"Watching";default:throw new Error(`Unknown mode: ${String(e)}`)}},YO=async(e,t,r,n,o,s,i)=>{const a=ut.version.slice(1);n.wrapAll(),e=X(ut.cwd(),e),n.debug("Root directory:",e);const{packageJson:l,packageJsonPath:u}=qo(e);n.debug("Using package.json found at",u);const c=await p9(e,l,n,i),p=_w("@visulima/packem",{cwd:e});let f=!1,d,m,h;const $=Ve(JSON.stringify({packemVersion:of,version:l.version,...l.dependencies,...l.devDependencies,...l.peerDependencies,...l.peerDependenciesMeta,browser:l.browser,eNode:l.engines?.node,exports:l.exports,main:l.main,module:l.module,nodeVersion:a,type:l.type,types:l.types}))+Ve(JSON.stringify(s));p&&Cm($,p,n);const y=new ah(e,p,$,n);try{const g=await M3(n,e,t,r,o,s,l,c,a);y.isEnabled=g.options.fileCache??!0;const w=Zd(g.options.bundler);await c9(w,e,n),g.options.transformerName&&await u9(g.options.transformerName,e,n),n.info(ne(`${I3(t)} ${g.options.name}`)),n.debug({context:g.options.entries,message:`${Ae("Root dir:")} ${g.options.rootDir}
|
|
239
|
+
${Ae("Entries:")}`});const b=async j=>{for(const[k,R]of Object.entries(g.options.builder??{})){n.raw(`
|
|
240
|
+
`),await g.hooks.callHook("builder:before",k,g);const P=Date.now(),z=()=>Hl(Math.floor(Date.now()-P));await R(g,p,y,f),await g.hooks.callHook("builder:done",k,g),n.raw(`
|
|
241
|
+
⚡️ ${k} run in ${z()}`),j&&n.raw(`
|
|
242
|
+
|
|
243
|
+
`)}},v=async()=>{if(d?.pid!==void 0)await F9({pid:d.pid,signal:s.killSignal??"SIGTERM"});else if(m!==void 0)try{typeof m=="function"&&await m()}catch(j){throw new Error(`onSuccess function cleanup failed: ${j instanceof Error?j.message:String(j)}`,{cause:j})}d=void 0,m=void 0},S=async()=>{if(typeof g.options.onSuccess=="function")try{m=await g.options.onSuccess()}catch(j){throw new Error(`onSuccess function failed: ${j instanceof Error?j.message:String(j)}`,{cause:j})}else if(typeof g.options.onSuccess=="string"){const j=g.options.onSuccessTimeout??3e4,k=d=$h(g.options.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit",timeout:j}});await k;const{exitCode:R}=k;if(typeof R=="number"&&R!==0)throw new Error(`onSuccess script failed with exit code ${String(R)}. Check the output above for details.`)}},x=Date.now(),E=()=>Hl(Math.floor(Date.now()-x));if(t==="watch"){if(g.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem config.");await N9(g,y,b,S,v),lu(g,!1);return}if(await P9(g),t==="jit")await O9(g),await g.hooks.callHook("build:done",g);else{if(f=await O3(g,y),g.options.emitCJS&&g.options.declaration==="compatible"){f&&n.raw(`
|
|
244
|
+
`);let j="console",k="*";g.options.node10Compatibility&&(j=g.options.node10Compatibility.writeToPackageJson?"file":"console",k=g.options.node10Compatibility.typeScriptVersion??"*"),await C3(n,g.options.entries,g.options.outDir,g.options.rootDir,j,k)}await g.hooks.callHook("validate:before",g),typeof g.options.validation=="object"&&(g.options.validation.packageJson&&jA(g),g.options.validation.attw&&await lA(g,f),g.options.validation.bundleLimit&&DA(g,f)),await g.hooks.callHook("validate:done",g),lu(g,f)}n.raw(`
|
|
245
|
+
⚡️ Build run in ${E()}
|
|
246
|
+
`),h=()=>{v().catch(j=>{n.raw(`
|
|
247
|
+
onSuccess cleanup failed: ${j instanceof Error?j.message:String(j)}
|
|
248
|
+
`)})},ut.once("SIGINT",h),ut.once("SIGTERM",h),await b(),await S()}catch(g){throw n.raw(`
|
|
249
|
+
`),rh(g),np(g),g}finally{h&&(ut.off("SIGINT",h),ut.off("SIGTERM",h)),n.restoreAll(),await q9(p,n,f)}};export{Ne as A,q1 as B,fg as J,ub as K,ua as M,LO as S,YO as T,db as X,OO as Y,hg as Z,X0 as a,Pr as b,Ko as c,CO as d,FO as e,Rl as f,$1 as g,gl as h,_9 as i,PO as j,z0 as k,NO as l,HO as m,pg as n,sb as q,of as v,_y as y};
|