"use strict";var ii=Object.defineProperty;var g=(e,t)=>ii(e,"name",{value:t,configurable:!0});const Be=require("node:process"),j=require("@visulima/colorize"),ni=require("@visulima/find-cache-dir"),S=require("@visulima/fs"),L=require("@visulima/humanizer"),f=require("@visulima/path"),He=require("@visulima/tsconfig"),oi=require("browserslist"),ai=require("defu"),si=require("hookable"),ht=require("jiti"),pe=require("rollup"),ri=require("tinyexec"),Y=require("node:fs/promises"),li=require("@rollup/plugin-alias"),pi=require("@rollup/plugin-commonjs"),ci=require("@rollup/plugin-dynamic-import-vars"),yt=require("@rollup/plugin-node-resolve"),di=require("@rollup/plugin-replace"),ui=require("@rollup/plugin-wasm"),mi=require("rollup-plugin-polyfill-node"),fi=require("rollup-plugin-visualizer"),xe=require("semver"),gi=require("node:assert/strict"),U=require("@rollup/pluginutils"),vi=require("magic-string"),hi=require("glob-parent"),he=require("tinyglobby"),Se=require("@visulima/path/utils"),xt=require("./packem_shared/index-B4tUSomc.cjs"),yi=require("source-map-js"),Te=require("./packem_shared/sourcemap-CXAd1Jcz.cjs"),_=require("./packem_shared/Mime-BsyBfmma.cjs"),Ce=require("./packem_shared/ensure-auto-modules-DBW-5Idh.cjs"),te=require("mlly"),xi=require("oxc-parser"),E=require("./packem_shared/constants-C98jAkyM.cjs"),bi=require("@rollup/plugin-json"),wi=require("rollup-plugin-license"),bt=require("./packem_shared/create-or-update-key-storage-DOolYH4A.cjs"),be=require("node:fs"),ye=require("node:module"),ki=require("node:url"),ji=require("@visulima/source-map"),$i=require("@babel/parser"),Ei=require("node:crypto"),Si=require("child_process"),Oi=require("@visulima/package/package-json"),Pi=require("@visulima/fs/error"),Di=require("fastest-levenshtein");var ee=typeof document<"u"?document.currentScript:null;const T=g(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),Me=T(Be),Ni=T(oi),wt=T(li),_i=T(pi),Ci=T(ci),kt=T(di),Mi=T(mi),we=T(gi),G=T(vi),Ai=T(hi),Fi=T(bi),Ii=T(wi),Ge=T(ye),Ti=T(Ei),zi=T(Si);var Ri=Object.defineProperty,qi=g((e,t)=>Ri(e,"name",{value:t,configurable:!0}),"a$n");const le=qi(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var Ji=Object.defineProperty,jt=g((e,t)=>Ji(e,"name",{value:t,configurable:!0}),"s$g");const Bi=jt((e,t,i)=>{const n=i??new Map;return(...o)=>{const a=t?typeof t=="function"?t(...o):t:JSON.stringify({args:o}),s=n.get(a);if(s!==void 0)return s;const r=e(...o);return n.set(a,r),r}},"memoize"),Wi=jt(e=>{const t=new Map;return i=>Bi(e,i,t)},"memoizeByKey");var Li=Object.defineProperty,ce=g((e,t)=>Li(e,"name",{value:t,configurable:!0}),"r$e");const Ui=ce(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;we(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const i of U.extractAssignedNames(t.id))yield i;break}}},"exportName"),Ki=ce(function*(e){if(e.declaration)for(const t of Ui(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),Vi=ce(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),Hi=ce(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),Gi=ce(function*(e,t){we(t.code!=null,`Module ${t.id} doesn't have associated code`);const i=e.parse(t.code);for(const n of i.body)switch(n.type){case"ExportAllDeclaration":{yield*Vi(n);break}case"ExportDefaultDeclaration":{yield*Hi();break}case"ExportNamedDeclaration":{yield*Ki(n);break}}},"parseExports");var Yi=Object.defineProperty,de=g((e,t)=>Yi(e,"name",{value:t,configurable:!0}),"n$b");const $t=de(async function(e,t,i){const n=await e.resolve(t,i.id);if(we(n,`Rollup can't resolve ${t} from ${i.id}`),n.external)return null;const o=await e.load(n);return we(o,`Rollup doesn't have a module for id ${n.id}`),o},"getImportedModule"),Qi=de(async function*(e,t,i){const n=await $t(e,t.source,i);n&&(yield*We(e,n))},"gatherBarrelReExports"),Zi=de(async function*(e,t,i){const n=await $t(e,t.source,i);if(!n)return;const o=new Map(t.bindings.map(a=>[a.importedName,a]));for await(const a of We(e,n)){const s=o.get(a.exportedName);s&&(yield{...a,exportedName:s.exportedName})}},"gatherNamedReExports"),Xi=de(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),We=de(async function*(e,t){for(const i of Gi(e,t))i.from==="self"?yield*Xi(t,i):i.type==="barrel"?yield*Qi(e,i,t):yield*Zi(e,i,t)},"gatherExports");var en=Object.defineProperty,tn=g((e,t)=>en(e,"name",{value:t,configurable:!0}),"r$d");const nn=tn(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of We(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var on=Object.defineProperty,an=g((e,t)=>on(e,"name",{value:t,configurable:!0}),"r$c");const sn=an((e,t)=>{const i=e,n=[];let o;for(;(o=i.exec(t))!==null;)o.index===i.lastIndex&&i.lastIndex++,o.forEach(a=>{n.push(a)});return n.filter(Boolean)},"getRegexMatches");var rn=Object.defineProperty,ln=g((e,t)=>rn(e,"name",{value:t,configurable:!0}),"a$m");const Et=ln(e=>{const t=sn(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const i=t.at(-1).split(", ");let n="";for(const o of i)if(!o.includes("type")&&(o.includes("default ")&&(n=o.split("default ")[1]),o.includes("as"))){const[a,s]=o.split(" as ");s==="default"&&(n=a)}if(n!==""){const o=new G(e);return o.replace(new RegExp(`(,s)?${n} as default(,)?`),""),o.replace(new RegExp(`export default ${n}; ?`),""),o.append(` export = `+n+";"),{code:o.toString().replace(/export\s\{\s\s\};/,""),map:o.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var pn=Object.defineProperty,Ye=g((e,t)=>pn(e,"name",{value:t,configurable:!0}),"i$b");const St=Ye(({addDefaultProperty:e=!1,logger:t,type:i})=>({name:"packem:cjs-interop",renderChunk:Ye(async(n,o,a)=>{if(o.type!=="chunk"||!o.isEntry)return null;if(a.format==="cjs"&&a.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(s===null||s.length<3)return null;const r=new G(n);r.replace("",""),r.replaceAll(/exports\.(.*) = (.*);/g,"module.module.exports.$1 = $2;"),e&&r.append(` module.module.exports = `+s[2]+";");let p=r.toString();return p=p.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"plugin:cjs-interop"}),{code:p,map:r.generateMap({hires:!0})}}return a.format==="es"&&/\.d\.(?:ts|cts)$/.test(o.fileName)?i!=="commonjs"&&o.fileName.endsWith(".d.mts")?null:Et(n):null},"renderChunk")}),"cjsInteropPlugin");var cn=Object.defineProperty,dn=g((e,t)=>cn(e,"name",{value:t,configurable:!0}),"f$f");const un=dn((e,t)=>{const i=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:o}=n;return Array.isArray(o)?o=o.map(a=>{if(typeof a=="string")return{src:a};if(typeof a=="object"&&"src"in a)return a}).filter(Boolean):typeof o=="string"&&(o=[{src:o}]),{async buildStart(){const a=await Promise.all(o.flatMap(s=>Array.isArray(s.src)?s.src.map(r=>({...s,src:r})):s).map(async s=>await he.glob(le(s.src),{ignore:le(s.exclude).filter(Boolean)}).then(r=>({dest:s.dest??"",parent:Ai(s.src),src:r}))));for(const s of a)for(const r of s.src){let p;i.has(r)?p=i.get(r):(p={copied:[],dest:[],timestamp:0},i.set(r,p));const l=n.flatten?f.normalize(s.dest):f.join(s.dest,f.relative(s.parent,f.dirname(r)));p.dest.includes(l)||p.dest.push(l),this.addWatchFile(r)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...i].map(async([s,r])=>{let p;try{const l=await Y.stat(s);if(!l.isFile())return;const c=l.mtime.getTime();c>r.timestamp&&(r.timestamp=c,r.copied=[]),p=await S.readFile(s,{buffer:!0})}catch(l){t.error({context:[l],message:`error reading file ${s}`,prefix:"plugin:copy"});return}for(const l of r.dest){if(n.copyOnce&&r.copied.includes(l))continue;const c=f.basename(s),u=f.join(l,c);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:u,source:p,type:"asset"}),t.debug({message:`copied ${s} → ${u}`,prefix:"plugin:copy"}),r.copied.push(l)}catch(d){t.error({context:[d],message:`error copying file ${s} → ${u}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var mn=Object.defineProperty,fn=g((e,t)=>mn(e,"name",{value:t,configurable:!0}),"r$b");const Qe=fn((e,t)=>{if(!t)return!1;if(typeof t=="function")return t(e);if(typeof t.test=="function")return t.test(e);throw new Error("Invalid condition type")},"matchFile");var gn=Object.defineProperty,vn=g((e,t)=>gn(e,"name",{value:t,configurable:!0}),"a$l");const hn=4,yn=process.env.UV_THREADPOOL_SIZE?Number.parseInt(process.env.UV_THREADPOOL_SIZE,10):hn;let xn=class{static{g(this,"f")}static{vn(this,"LoaderManager")}test;loaders=new Map;options;workQueue;logger;constructor({extensions:t,loaders:i,logger:n,options:o}){this.test=a=>t.some(s=>a.toLowerCase().endsWith(s)),i.length>0&&this.add(...i),this.options=o,this.logger=n}add(...t){for(const i of t)this.loaders.has(i.name)||this.loaders.set(i.name,i)}isSupported(t){if(this.test(t))return!0;for(const[,i]of this.loaders)if(Qe(t,i.test))return!0;return!1}async process(t,i){this.workQueue||(this.workQueue=new xt.d({concurrency:yn-1}));for await(const[n,o]of this.loaders){const a={...i,options:this.options[n]??{}};if(o.alwaysProcess||Qe(a.id,o.test)){this.logger.debug(`Processing ${n} loader for ${a.id}`);const s=await this.workQueue.add(o.process.bind(a,t));s&&(t=s)}}return t}};var bn=Object.defineProperty,wn=g((e,t)=>bn(e,"name",{value:t,configurable:!0}),"u$c");const kn=wn(async e=>{const t=new yi.SourceMapGenerator({file:""}),i=[];let n=0;for await(const{css:o,map:a}of e){i.push(o);const s=Te.m(a),r=s.toObject();if(!r)continue;const p=s.toConsumer();if(p){if(p.eachMapping(l=>{t.addMapping({generated:{column:l.generatedColumn,line:n+l.generatedLine},name:l.name,original:{column:l.originalColumn,line:l.originalLine},source:l.source})}),r.sourcesContent)for(const l of r.sources)t.setSourceContent(l,p.sourceContentFor(l,!0));n+=o.split(` `).length}}return{css:i.join(` `),map:t}},"concat");var jn=Object.defineProperty,oe=g((e,t)=>jn(e,"name",{value:t,configurable:!0}),"b$3");const $n=oe(async(e,t)=>e.sort((i,n)=>t.indexOf(i.name)-t.indexOf(n.name)),"sortByNameOrder"),En=oe(async(e,t,i,n,o,a,s,r,p,l)=>{const c={...l,...e.alias},u=U.createFilter(e.include,e.exclude),d=_.i(e.sourceMap),m={..._.a(e.mode),autoModules:e.autoModules??!1,dts:e.dts,extensions:e.extensions,namedExports:e.namedExports};typeof m.inject=="object"&&m.inject.treeshakeable&&(m.namedExports=!1,t.info({message:"Disabling named exports due to `inject.treeshakeable` option",prefix:"css"}));let w=!1;if(e.loaders)for(const v of e.loaders)v.name==="postcss"&&(w=!0);else e.loaders=[];w&&(m.postcss={...e.postcss,config:_.b(e.postcss?.config,{}),import:_.c(e.postcss?.import,c),modules:_.b(e.postcss?.modules,void 0),to:e.postcss?.to,url:_.c(e.postcss?.url,c)},e.postcss?.parser&&(m.postcss.parser=await _.e(e.postcss.parser,"parser",n)),e.postcss?.syntax&&(m.postcss.syntax=await _.e(e.postcss.syntax,"syntax",n)),e.postcss?.stringifier&&(m.postcss.stringifier=await _.e(e.postcss.stringifier,"stringifier",n)),e.postcss?.plugins&&(m.postcss.plugins=await _.d(e.postcss.plugins,n)));const b=new xn({extensions:m.extensions,loaders:await $n(e.loaders,["sourcemap","stylus","less","sass","postcss"]),logger:t,options:{...e,...m,alias:c}});let y=[];const h=oe((v,k)=>{const $=[];for(const x of Object.keys(v)){const N=new Set;let A=[x];do{const J=[];for(const z of A){if(N.has(z))continue;if(b.isSupported(z)){u(z)&&J.push(z);continue}N.add(z);const Z=k(z);Z&&J.push(...Z.importedIds)}A=J}while(A.some(J=>!b.isSupported(J)));$.push(...A)}return $},"traverseImportedModules");return{augmentChunkHash(v){if(y.length===0)return null;const k=h(v.modules,this.getModuleInfo),$=y.filter(x=>k.includes(x.id)).sort((x,N)=>k.lastIndexOf(x.id)-k.lastIndexOf(N.id)).map(x=>`${f.basename(x.id)}:${x.css}`);return $.length===0?null:$.join(":")},async generateBundle(v,k){if(y.length===0||!(v.dir||v.file))return;const $=Object.values(k),x=v.dir??f.dirname(v.file),N=$.filter(P=>P.type==="chunk"),A=N.filter(P=>!P.facadeModuleId),J=v.preserveModules?N:N.filter(P=>P.isEntry||P.isDynamicEntry),z=[],Z=oe(async(P,C)=>{const O=typeof m.extract=="string"?f.normalize(m.extract).replace(/^\.[/\\]/,""):f.normalize(`${P}.css`);f.isAbsolute(O)&&this.error(["Extraction path must be relative to the output directory,",`which is ${f.relative(n,x)}`].join(` `)),Se.isRelative(O)&&this.error(["Extraction path must be nested inside output directory,",`which is ${f.relative(n,x)}`].join(` `));const B=y.filter(W=>C.includes(W.id)).sort((W,X)=>C.lastIndexOf(W.id)-C.lastIndexOf(X.id)),ue=await kn(B);return{css:ue.css,map:Te.m(ue.map.toString()).relative(f.dirname(f.resolve(x,O))).toString(),name:O}},"getExtractedData"),R=oe(P=>{if(v.file)return f.parse(v.file).name;if(v.preserveModules){const{dir:C,name:O}=f.parse(P.fileName);return C?f.join(C,O):O}return P.name},"getName"),V=[];if(typeof m.extract=="string"){t.debug({message:`Extracting to ${m.extract}`,prefix:"css"});const P=[];for(const O of A){const B=h(O.modules,this.getModuleInfo);V.push(...B),P.push(...B)}for(const O of J)P.push(...h(O.modules,this.getModuleInfo).filter(B=>!V.includes(B)));const C=R(N[0]);z.push([C,P])}else{t.debug({message:"Extracting to individual files",prefix:"css"});for(const P of A){const C=h(P.modules,this.getModuleInfo);if(C.length===0)continue;V.push(...C);const O=R(P);z.push([O,C])}for(const P of J){const C=h(P.modules,this.getModuleInfo).filter(B=>!V.includes(B));if(C.length===0)continue;const O=R(P);z.push([O,C])}}for await(const[P,C]of z){const O=await Z(P,C);if(typeof e.onExtract=="function"&&!e.onExtract(O))continue;if(p&&e.minifier){t.info({message:`Minifying ${O.name} with ${e.minifier.name}`,prefix:"css"});const{css:W,map:X}=await e.minifier.handler.bind({browserTargets:i,warn:this.warn.bind(this)})(O,d,e[e.minifier.name]??{});O.css=W,O.map=X}const B={fileName:O.name,name:O.name,names:[O.name],originalFileName:O.name,originalFileNames:[O.name],source:O.css,type:"asset"},ue=this.emitFile(B);if(O.map&&d){const W=this.getFileName(ue),X=typeof v.assetFileNames=="string"?f.normalize(f.dirname(v.assetFileNames)):typeof v.assetFileNames=="function"?f.normalize(f.dirname(v.assetFileNames(B))):"assets",ie=Te.m(O.map).modify(M=>(M.file=f.basename(W),M)).modifySources(M=>{if(M===""||X.length<=1)return M;M=`../${M}`;for(const _e of X)_e==="/"&&(M=`../${M}`);return M});if(d.inline)ie.modify(M=>d.transform?.(M,f.normalize(f.join(x,W)))),k[W].source+=ie.toCommentData();else{const M=`${W}.map`;ie.modify(ti=>d.transform?.(ti,f.normalize(f.join(x,M)))),this.emitFile({fileName:M,source:ie.toString(),type:"asset"});const{base:_e}=f.parse(M);k[W].source+=ie.toCommentFile(_e)}}}},name:"packem:css",async transform(v,k){if(!u(k)||!b.isSupported(k)||v.replaceAll(/\s/g,"")==="")return null;try{return this.parse(v,{}),this.warn(`Skipping processed file ${f.relative(n,k)}`),null}catch{}typeof e.onImport=="function"&&e.onImport(v,k);const $={alias:c,assets:new Map,autoModules:m.autoModules,browserTargets:i,cwd:n,debug:r,deps:new Set,dts:m.dts,emit:m.emit,environment:a,extensions:m.extensions,extract:m.extract,id:k,inject:m.inject,logger:t,namedExports:m.namedExports,options:{},plugin:this,sourceDir:o,sourceMap:d,useSourcemap:s,warn:this.warn.bind(this)},x=await b.process({code:v},$);for(const N of $.deps)this.addWatchFile(N);for(const[N,A]of $.assets)this.emitFile({fileName:N,source:A,type:"asset"});if(x.extracted){const{id:N}=x.extracted;y=y.filter(A=>A.id!==N),y.push(x.extracted)}return{code:x.code,map:d&&x.map?x.map:{mappings:""},meta:{styles:x.meta},moduleSideEffects:x.extracted?!0:null}}}},"default");var Sn=Object.defineProperty,On=g((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"u$b");const Pn=` /* eslint-disable */ /* prettier-ignore */ // @ts-nocheck /** * Generated by packem * @see https://npmjs.com/@visulima/packem */ `.trim(),Dn=On((e,t,i)=>{let n;return e.postcss&&typeof e.postcss.modules=="boolean"?n=e.postcss.modules:e.lightningcss&&typeof e.lightningcss.modules=="boolean"&&(n=e.lightningcss.modules),{async transform(o,a){let s=n;if(e.postcss&&typeof e.postcss.modules=="object"?s=Ce.n(e.postcss.modules.include,a):e.lightningcss&&typeof e.lightningcss.modules=="object"&&(s=Ce.n(e.lightningcss.modules.include,a)),e.autoModules&&s===void 0&&(s=Ce.n(e.autoModules,a)),!s)return null;const{types:r}=this.getModuleInfo(a)?.meta.styles??{};return r===void 0||await S.isAccessible(a)&&(await S.writeFile(a+".d.ts",`${Pn} ${r}`),i.info({message:`Generated types for ${f.normalize(a).replace(t+"/","")}`,prefix:"dts:css-modules"}),this.addWatchFile(a+".d.ts")),null}}},"cssModulesTypes");var Nn=Object.defineProperty,Oe=g((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"t$a");const _n=/\Wrequire(?:\.resolve)?\(/,Cn=Oe((e,t)=>{if(Be.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let i=!1,n=!1,o=!1;if(e.includes("__filename")&&(i=!0),e.includes("__dirname")&&(n=!0),_n.test(e)&&(o=!0),!i&&!n&&!o)return null;const a=te.findStaticImports(e).pop(),s=a?a.end:0,r=new G(e);return r.appendRight(s,t(i,n,o)),{code:r.toString(),map:r.generateMap()}},"CJSToESM"),Mn=Oe((e,t,i)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim -- `),t&&(n+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim -- `),i&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim -- `),(e||t)&&(n+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url); `),t&&(n+=`const __dirname = __cjs_path__.dirname(__filename); `),i&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url); `),n},"generateCJSShim"),An=Oe((e,t,i)=>{let n="";return i&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim -- `),e&&(n+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim -- `),t&&(n+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim -- `),i&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url); `),n},"generateCJSShimNode20_11"),Fn=Oe((e,t)=>{const i=U.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,o,a){if(a.format==="es"&&i(o.fileName)){let s=Mn;if(e.engines?.node){const r=xe.minVersion(e.engines.node);r&&r.major>=20&&r.minor>=11&&(s=An)}return Cn(n,s)}return null}}},"esmShimCjsSyntaxPlugin");var In=Object.defineProperty,Tn=g((e,t)=>In(e,"name",{value:t,configurable:!0}),"m$9");const zn=Tn(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,i){return i.format==="es"||i.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(i.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Rn=Object.defineProperty,qn=g((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"e$7");const Ze=/^([\w-]+):/,Xe=qn(e=>{if(!e||typeof e!="string")throw new Error("Invalid key: Key must be a non-empty string.");const t=[],i=Ze.exec(e);i&&(t.push(i[1]),e=e.replace(Ze,""));const n=e.split("/");for(const o of n)(o.includes("*")||o)&&t.push(o);return t},"splitTsconfigPathKey");var Jn=Object.defineProperty,Bn=g((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"h$2");const Wn=Bn((e,t)=>{const i=e.replace(/^\.\//,""),n=t.replace(/^\.\//,"");if(n.startsWith(i))return e+n.slice(i.length);if(e.endsWith(t))return e;const o=Xe(e),a=Xe(t);let s=o.length-1,r=a.length-1;for(;s>=0&&r>=0&&o[s]===a[r];)s--,r--;let p=o.slice(0,s).join("/");const l=a.slice(r).join("/");return(!p.startsWith(".")||p==="")&&(p="./"+p),p+(l?"/"+l:"")},"extendString");var Ln=Object.defineProperty,Un=g((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"s$d");const Kn=Un((...e)=>{if(e.length===0)return"";if(e.length===1)return f.dirname(e[0]);e=e.map(o=>f.toNamespacedPath(o));const[t,...i]=e;let n=t.split("/");for(const o of i){const a=o.split("/",n.length);let s=0;for(const r of a)if(r===n[s])s+=1;else{n=n.slice(0,s);break}n=n.slice(0,s)}return n.length<=1&&n[0]===""?`/${n[0]}`:n.join("/")},"lowestCommonAncestor");var Vn=Object.defineProperty,Ae=g((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"m$7");const Hn=Ae((e,t,i,n,o,a)=>{const s=U.createFilter(o.include,o.exclude),r={},p=Ae((u,d)=>{r[u.replace(E.E,"")]=d},"addOutput");let l=[];a?.config.compilerOptions&&(l=Object.entries(a.config.compilerOptions.paths??{}).map(([u])=>u.endsWith("*")?new RegExp(`^${u.replace("*","(.*)")}$`):new RegExp(`^${u}$`)));async function c(u,d){if(!s(d))return;let m;try{m=(await xi.parseAsync(u,{sourceFilename:d})).program}catch{}if(m){const h=m.body.filter(v=>v.type==="ImportDeclaration"||v.type==="ExportAllDeclaration"||v.type==="ExportNamedDeclaration");for await(const v of h){if(!v.source||f.basename(v.source.value).includes("."))continue;const k=await this.resolve(v.source.value,d);if(!(!k||k.external)&&(k.id.endsWith(".ts")||k.id.endsWith(".cts")||k.id.endsWith(".mts")||k.id.endsWith(".tsx")||k.id.endsWith(".ctsx")||k.id.endsWith(".mtsx"))){const $=k.id.replace(e+"/","");let x=v.source.value;l.some(N=>N.test(v.source.value))&&!v.source.value.startsWith(".")&&(x="./"+v.source.value),u=u.replaceAll('from "'+v.source.value+'"','from "'+Wn(x,$)+'"')}}}const{errors:w,sourceText:b}=await t(d,u);if(w.length>0){if(o.ignoreErrors){this.warn(w[0]);return}return this.error(w[0])}if(p(d,b),!m)return;const y=m.body.filter(h=>h.type==="ImportDeclaration"?h.importKind==="type"?!0:h.specifiers?.every(v=>v.type==="ImportSpecifier"&&v.importKind==="type"):h.type==="ExportNamedDeclaration"||h.type==="ExportAllDeclaration"?h.exportKind==="type"?!0:h.type==="ExportNamedDeclaration"&&h.specifiers?.every(v=>v.type==="ExportSpecifier"&&v.exportKind==="type"):!1);for await(const h of y){if(!h.source)continue;const v=await this.resolve(h.source.value,d);if(!v)return;const k=v.id;if(s(k)&&!r[k.replace(E.E,"")])try{const $=await S.readFile(k);await c.call(this,$,k)}catch{}}}return g(c,"N"),Ae(c,"transform"),{name:"packem:isolated-declarations",async renderStart(u,{input:d}){const m=Kn(...Array.isArray(d)?d:Object.values(d));typeof u.entryFileNames=="function"&&(u.entryFileNames=u.entryFileNames({name:u.name}));const w=u.entryFileNames.replace(/\.(.)?[jt]sx?$/,(b,y)=>`.d.${y||""}ts`);for await(let[b,y]of Object.entries(r)){if(n&&u.format==="cjs"){const v=Et(y);v!==null&&(y=v.code)}const h=y.includes("from '")?"'":'"';(i===!0||i==="compatible")&&u.format==="cjs"&&this.emitFile({fileName:w.replace("[name]",f.relative(m,b)).replace(".cts",".ts"),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(v,k,$,x)=>k+h+(x||$)+".d.ts"+h+";"),type:"asset"}),this.emitFile({fileName:w.replace("[name]",f.relative(m,b)),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(v,k,$,x)=>k+h+(x||$)+(u.format==="cjs"?".d.cts":".d.mts")+h+";"),type:"asset"})}},transform:c}},"isolatedDeclarationsPlugin");var Gn=Object.defineProperty,Yn=g((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"n$9");const et="export default ",Ot=Yn(e=>{const t=Fi(e);return{...t,name:"packem:json",transform(i,n){const o=t.transform?.call(this,i,n);return o&&typeof o!="string"&&"code"in o&&o.code?.startsWith(et)&&(o.code=o.code.replace(et,"module.exports = ")),o}}},"JSONPlugin");var Qn=Object.defineProperty,me=g((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"i$8");class Pt{static{g(this,"WalkerBase")}static{me(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:me(()=>this.should_skip=!0,"skip"),remove:me(()=>this.should_remove=!0,"remove"),replace:me(t=>this.replacement=t,"replace")}}replace(t,i,n,o){t&&i&&(n!=null?t[i][n]=o:t[i]=o)}remove(t,i,n){t&&i&&(n!=null?t[i].splice(n,1):delete t[i])}}var Zn=Object.defineProperty,ae=g((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"c$g");class Xn extends Pt{static{g(this,"SyncWalker")}static{ae(this,"SyncWalker")}constructor(t,i){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:ae(()=>this.should_skip=!0,"skip"),remove:ae(()=>this.should_remove=!0,"remove"),replace:ae(n=>this.replacement=n,"replace")},this.enter=t,this.leave=i}visit(t,i,n,o){if(t){if(this.enter){const s=this.should_skip,r=this.should_remove,p=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,i,n,o),this.replacement&&(t=this.replacement,this.replace(i,n,o,t)),this.should_remove&&this.remove(i,n,o);const l=this.should_skip,c=this.should_remove;if(this.should_skip=s,this.should_remove=r,this.replacement=p,l)return t;if(c)return null}let a;for(a in t){const s=t[a];if(s&&typeof s=="object")if(Array.isArray(s)){const r=s;for(let p=0;peo(e,"name",{value:t,configurable:!0}),"c$f");class to extends Pt{static{g(this,"AsyncWalker")}static{se(this,"AsyncWalker")}constructor(t,i){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:se(()=>this.should_skip=!0,"skip"),remove:se(()=>this.should_remove=!0,"remove"),replace:se(n=>this.replacement=n,"replace")},this.enter=t,this.leave=i}async visit(t,i,n,o){if(t){if(this.enter){const s=this.should_skip,r=this.should_remove,p=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,await this.enter.call(this.context,t,i,n,o),this.replacement&&(t=this.replacement,this.replace(i,n,o,t)),this.should_remove&&this.remove(i,n,o);const l=this.should_skip,c=this.should_remove;if(this.should_skip=s,this.should_remove=r,this.replacement=p,l)return t;if(c)return null}let a;for(a in t){const s=t[a];if(s&&typeof s=="object")if(Array.isArray(s)){const r=s;for(let p=0;pio(e,"name",{value:t,configurable:!0}),"a$h");function Le(e,{enter:t,leave:i}){return new Xn(t,i).visit(e,null)}g(Le,"walk");Dt(Le,"walk");async function no(e,{enter:t,leave:i}){return await new to(t,i).visit(e,null)}g(no,"asyncWalk");Dt(no,"asyncWalk");var oo=Object.defineProperty,ao=g((e,t)=>oo(e,"name",{value:t,configurable:!0}),"u$9");const so=ao(({attributes:e,logger:t})=>{const i=U.createFilter([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,o){if(!i(o))return null;let a=null;try{a=this.parse(n,{allowReturnOutsideFunction:!0})}catch(p){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${o}" and remove the jsx attribute.`}),t.warn(p),null}let s=!1;const r=new G(n);return Le(a,{enter(p){if(p.type==="CallExpression"&&p.callee.type==="Identifier"&&p.callee.name==="jsx"){const l=p.arguments.filter(c=>c.type==="ObjectExpression"&&Array.isArray(c.properties));for(const c of l)for(const u of c.properties)u.type==="Property"&&u.key.type==="Literal"&&u.value.type==="Literal"&&e.includes(u.key.value)&&(r.overwrite(u.start-2,u.end,""),s=!0)}}}),s?{code:r.toString(),map:r.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var ro=Object.defineProperty,Nt=g((e,t)=>ro(e,"name",{value:t,configurable:!0}),"d$a");const lo=Nt(e=>{const t=[],i=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):i.push(n)}),[...i.sort(),...t.sort()]},"sortLicenses"),_t=Nt(({dtsMarker:e,licenseFilePath:t,licenseTemplate:i,logger:n,marker:o,mode:a,packageName:s})=>Ii({thirdParty(r){const p=new Set,l=r.sort(({name:u},{name:d})=>(u||0)>(d||0)?1:(d||0)>(u||0)?-1:0).map(({author:u,contributors:d,license:m,licenseText:w,maintainers:b,name:y,repository:h})=>{let v="## "+y+` `;m&&(v+=`License: ${m} `);const k=new Set;for(const $ of[u,...b,...d]){const x=typeof $=="string"?$:$?.name;x&&k.add(x)}return k.size>0&&(v+=`By: ${[...k].join(", ")} `),h&&(v+=`Repository: ${typeof h=="string"?h:h.url} `),w&&(v+=` `+w.trim().replaceAll(/\r\n|\r/g,` `).replaceAll(``,"").replaceAll(e?``:"","").replaceAll(``,"").replaceAll(e?``:"","").trim().split(` `).map($=>$?`> ${$}`:">").join(` `)+` `),m&&p.add(m),v}).join(` --------------------------------------- `);if(l===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+a});return}const c=i(lo(p),l,s);try{const u=S.readFileSync(t),d=bt.g(u,o,c);if(!d){n.error({message:`Could not find the license marker: in ${t}`,prefix:"plugin:license:"+a});return}u!==d&&(S.writeFileSync(t,d),n.info({message:`${t} updated.`,prefix:"plugin:license:"+a}))}catch(u){n.error(u)}}}),"license");var po=Object.defineProperty,co=g((e,t)=>po(e,"name",{value:t,configurable:!0}),"u$8");const uo=co(()=>({async generateBundle(e,t){const i=[];for(const o of this.getModuleIds()){const a=this.getModuleInfo(o);if(a!=null&&!a.isExternal)for(const s of a.importedIds)i.push({source:o,target:s})}if(Array.isArray(i)&&i.length===0)return;const n=Object.keys(t);this.emitFile({fileName:`metafile-${n[0].replace(E.E,"")}-${e.format}.json`,source:JSON.stringify(i,null,2),type:"asset"})},name:"packem:metafile"}),"metafilePlugin");var mo=Object.defineProperty,fo=g((e,t)=>mo(e,"name",{value:t,configurable:!0}),"g$7");let tt=!1;const go=fo((e,t,i,n,o,a)=>{if(a!=="*"&&xe.valid(xe.coerce(a))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");return{name:"packem:node10-compatibility",writeBundle(){tt||(e.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:node10-compatibility"}),tt=!0);const s={};for(const l of t)for(const c of l.exportKey)c.includes("/*")?s[c]=["./"+f.join(i,f.dirname(l.name),"*.d.ts")]:s[c]=[...s[c]??[],"./"+f.join(i,l.name+".d.ts")];const r=f.join(n,"package.json"),p=S.readJsonSync(r);o==="file"&&Object.keys(s).length>0?(S.writeJsonSync(r,{...p,typesVersions:{...p.typesVersions,[a]:s}},{detectIndent:!0}),e.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:node10-compatibility"})):Object.keys(s).length>0&&e.info({message:`Please add the following field into your package.json to enable node 10 compatibility: ${JSON.stringify({typesVersions:{"*":s}},null,4)} `,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var vo=Object.defineProperty,Ct=g((e,t)=>vo(e,"name",{value:t,configurable:!0}),"d$9");const ne=Ct(e=>e.handler||e,"getHandler"),F=Ct((e,t,i="")=>({...e,async buildEnd(n){e.buildEnd&&await ne(e.buildEnd).call(this,n)},async buildStart(n){e.buildStart&&await ne(e.buildStart).call(this,n)},async load(n){if(!e.load)return null;const o=f.join(i,e.name),a=f.join("load",_.f(n));if(t.has(a,o))return await t.get(a,o);const s=await ne(e.load).call(this,n);return t.set(a,s,o),s},name:`cached(${e.name})`,async resolveId(n,o,a){if(!e.resolveId)return null;const s=f.join(i,e.name),r=f.join("resolveId",_.f(n),o?_.f(o):"",_.f(JSON.stringify(a)));if(t.has(r,s))return await t.get(r,s);const p=await ne(e.resolveId).call(this,n,o,a);return t.set(r,p,s),p},async transform(n,o){if(!e.transform)return null;const a=f.join(i,e.name),s=f.join("transform",_.f(o),_.f(n));if(t.has(s,a))return await t.get(s,a);const r=await ne(e.transform).call(this,n,o);return t.set(s,r,a),r}}),"cachingPlugin");var ho=Object.defineProperty,yo=g((e,t)=>ho(e,"name",{value:t,configurable:!0}),"n$7");const xo=yo(()=>({name:"packem:prepend-directive",transform:{handler(e,t){const i=this.getModuleInfo(t);if(i?.meta.preserveDirectives){const n=i.meta.preserveDirectives.directives[0];if(n)return`'${n.value}'; `+e}return null},order:"post"}}),"prependDirectivePlugin");var bo=Object.defineProperty,wo=g((e,t)=>bo(e,"name",{value:t,configurable:!0}),"c$b");const ko=wo(({directiveRegex:e,exclude:t=[],include:i=[],logger:n})=>{const o={},a={},s=U.createFilter(i,t);return{name:"packem:preserve-directives",onLog(r,p){return p.code==="MODULE_LEVEL_DIRECTIVE"&&r==="warn"?!1:null},renderChunk:{handler(r,p,{sourcemap:l}){const c=p.moduleIds.map(m=>o[m]?o[m]:null).reduce((m,w)=>(w&&w.forEach(b=>{m.add(b)}),m),new Set),u=new G(r);c.size>0&&(n.debug({message:`directives for chunk "${p.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),u.prepend(`${[...c].map(m=>`'${m}';`).join(` `)} `));let d;return p.facadeModuleId&&typeof a[p.facadeModuleId]=="string"&&(d=a[p.facadeModuleId]),d&&(n.debug({message:`shebang for chunk "${p.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),u.prepend(`${d} `)),c.size===0&&d===void 0?null:{code:u.toString(),map:l?u.generateMap({hires:!0}):null}},order:"post"},transform(r,p){if(!s(p))return null;let l=!1;const c=new G(r);if(r.startsWith("#")&&r[1]==="!"){let d=0;for(let m=2,w=r.length;mjo(e,"name",{value:t,configurable:!0}),"n$6");const Eo=$o(e=>{const t=U.createFilter(e.include,e.exclude);return{async load(i){return i.includes("?raw")?await this.load({id:i.replace(/\?raw$/,"")}):null},name:"packem:raw",transform(i,n){return!t(n)&&!n.includes("?raw")?null:(n.includes("?raw")||(i=`export default ${JSON.stringify(i)}`),{code:i,map:{mappings:""}})}}},"rawPlugin");var So=Object.defineProperty,Oo=g((e,t)=>So(e,"name",{value:t,configurable:!0}),"i$7");const Pe=Oo((e,t)=>{let i={};return e.name&&(i[e.name]=t.rootDir),i={...i,...t.alias},t.rollup.alias&&(Array.isArray(t.rollup.alias.entries)?Object.assign(i,Object.fromEntries(t.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(i,t.rollup.alias.entries??t.rollup.alias)),i},"resolveAliases");var Po=Object.defineProperty,re=g((e,t)=>Po(e,"name",{value:t,configurable:!0}),"a$f");const it=re((e,t,i)=>e.reduce((n,o,a)=>(o instanceof RegExp?n.push(o):typeof o=="string"&&o.length>0?n.push(new RegExp("^"+o.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&")+"$")):i.warn(`Ignoring wrong entry type #${a} in '${t}' option: ${JSON.stringify(o)}`),n),[]),"getRegExps"),nt=new Map,Mt=re((e,t,i,n,o)=>{const a=new Map,s=new Map,r=new Set(it([...i.externals],"include",n)),p=new Set(it([...o.exclude??[]],"exclude",n)),l={};Object.assign(l,o.deps?e.dependencies:void 0,o.devDeps?e.devDependencies:void 0,o.peerDeps?e.peerDependencies:void 0,o.optDeps?e.optionalDependencies:void 0);const c=Object.keys(l);if(c.length>0&&r.add(new RegExp("^(?:"+c.join("|")+")(?:/.+)?$")),e.peerDependenciesMeta)for(const[b,y]of Object.entries(e.peerDependenciesMeta))y?.optional&&r.add(new RegExp(`^${b}(?:/.+)?$`));const u=re(b=>[...r].some(y=>y.test(b)),"isIncluded"),d=re(b=>[...p].some(y=>y.test(b)),"isExcluded");let m=[];t&&(m=Object.entries(t.config.compilerOptions?.paths??{}).map(([b])=>b.endsWith("*")?new RegExp(`^${b.replace("*","(.*)")}$`):new RegExp(`^${b}$`)));const w=Pe(e,i);return{name:"packem:resolve-externals",options:re(b=>{b.external=(y,h)=>{if(s.has(y))return s.get(y);if(Object.keys(w).length>0&&(y=Se.resolveAlias(y,w)),/^(?:\0|\.{1,2}\/)/.test(y)||f.isAbsolute(y)||e.name&&y.startsWith(e.name))return s.set(y,!1),!1;if(ye.isBuiltin(y)){let v=o.builtins;return v===void 0&&h&&(v=u(h)&&!d(h)),s.set(y,v),v}if(u(y)&&!d(y))return s.set(y,!0),!0;if(e.imports)for(const[v,k]of Object.entries(e.imports)){if(v===y)return s.set(y,!1),!1;if(v.includes("*")){let $;a.has(v)?$=a.get(v):($=be.readdirSync(f.join(i.rootDir,k.replace("/*","")),{withFileTypes:!0}).filter(x=>x.isFile()).map(x=>x.name),a.set(v,$));for(const x of $)if(x.replace(E.E,"")===y.replace(E.E,"").replace("#",""))return s.set(y,!1),!1}}if(m.length>0){for(const v of m)if(v.test(y))return s.set(y,!1),!1}return nt.has(y)||n.info({message:'Inlined implicit external "'+j.cyan(y)+'". If this is incorrect, add it to the "externals" option.',prefix:"plugin:packem:resolve-externals"}),nt.set(y,!0),!1}},"options"),resolveId:{async handler(b,y,{isEntry:h}){if(h)return null;if(ye.isBuiltin(b)){const v=b.replace(/^node:/,"");return{external:(o.builtins||u(b))&&!d(b),id:o.builtinsPrefix==="ignore"?b:o.builtinsPrefix==="add"||!ye.isBuiltin(v)?"node:"+v:v,moduleSideEffects:!1}}return null},order:"pre"}}},"resolveExternalsPlugin");var Do=Object.defineProperty,No=g((e,t)=>Do(e,"name",{value:t,configurable:!0}),"r$9");const At=No(()=>({name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return ki.fileURLToPath(e)}}),"resolveFileUrl");var _o=Object.defineProperty,De=g((e,t)=>_o(e,"name",{value:t,configurable:!0}),"i$5");const ke=/^#![^\n]*/,qe=De(async e=>{await Y.chmod(e,493).catch(()=>{})},"makeExecutable"),Co=De((e,t)=>({name:"packem:shebang",renderChunk:{handler(i,n,o){if(!n.isEntry||!n.facadeModuleId)return null;const a=i.startsWith("#")&&i[1]==="!";if(a&&t.replace)return i.replace(ke,t.shebang+` `);if(a)return null;if(e.includes(n.name)){const s=new G(i);return s.prepend(t.shebang+` `),{code:s.toString(),map:o.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(i,n){for(const[o,a]of Object.entries(n))if(a.type==="chunk"&&ke.test(a.code)&&i.dir){const s=f.resolve(i.dir,o);await qe(s)}}}),"shebangPlugin"),Mo=De(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ke,"")}}),"removeShebangPlugin"),Ao=De((e,t=` `)=>{const i=ke.exec(e);return i?i+t:""},"getShebang");var Fo=Object.defineProperty,Io=g((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"l$6");const To=Io(({exclude:e,include:t}={})=>{const i=U.createFilter(t,e);return{async load(n){if(!i(n))return null;let o;try{o=await S.readFile(n,{buffer:!1}),this.addWatchFile(n)}catch{try{const s=n.replace(/\?.*$/,"");o=await S.readFile(s,{buffer:!1}),this.addWatchFile(s)}catch{return this.warn("Failed reading file"),null}}let a;try{const s=ji.loadSourceMap(n);if(s===void 0)return o;a=s}catch{return this.warn("Failed resolving source map"),{code:o}}return{code:o,map:a}},name:"packem:sourcemaps"}},"sourcemapsPlugin");var zo=Object.defineProperty,Q=g((e,t)=>zo(e,"name",{value:t,configurable:!0}),"r$8");const Ro=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,qo=/MIT License|MIT license|BSD license/,Jo=/\n{2,}/g,Bo=/\b(\w+)\$\d+\b/g,Wo=/[-/\\^$*+?.()|[\]{}]/g,Lo=Q(e=>e.replaceAll(Wo,"\\$&"),"escapeRegex"),Uo=Q(e=>[...new Set(e)],"unique"),Ko=Q(e=>e.replaceAll(Ro,t=>qo.test(t)?"":t).replaceAll(Jo,` `),"cleanUnnecessaryComments"),ot=new Map;function Ft(e,t,{identifierReplacements:i},n){const o=te.findStaticImports(e);for(const s in i){const r=o.find(l=>l.specifier===s&&l.imports.includes("{"));if(!r){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const p=i[s];for(const l in p){if(!r.imports.includes(l))throw new Error(`${t.fileName} does not import "${l}" from "${s}" for replacement`);const c=p[l],u=Lo(l);c.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${u},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${u}\\b`,"g"),c)}}const a=Uo(Array.from(e.matchAll(Bo),s=>s[0]));if(a.length>0){const s=a.map(p=>` - ${p}`).join(""),r=t.fileName.replace(/\.[^/.]+$/,"");ot.has(r)||n.warn({message:`${t.fileName} contains confusing identifier names${s} To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),ot.set(r,!0)}return e}g(Ft,"I$1");Q(Ft,"replaceConfusingTypeNames");const Vo=Q((e,t)=>{if(t.leadingComments?.some(i=>i.type==="CommentBlock"&&i.value.includes("@internal"))){const i=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,i),!0}return!1},"removeInternal");function It(e,t){if(e.includes("@internal")){const i=new G(e),n=$i.parse(e,{plugins:["typescript"],sourceType:"module"});if(Le(n,{enter(o){Vo(i,o)&&this.skip()}}),e=i.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}g(It,"S$3");Q(It,"stripInternalTypes");const Ho=Q((e,t)=>({name:"packem:patch-types",renderChunk(i,n){return i=Ft.call(this,i,n,e,t),i=It.call(this,i,n),i=Ko(i),i},resolveId(i){return i.startsWith("types/")?{external:!0,id:"../../"+(i.endsWith(".js")?i:i+".js")}:null}}),"patchTypescriptTypes");var Go=Object.defineProperty,K=g((e,t)=>Go(e,"name",{value:t,configurable:!0}),"a$e");const Yo=42,Qo=K(e=>{let t=!1;for(let i=0;i{const t=e.indexOf("*");return t===-1?void 0:{prefix:e.slice(0,t),suffix:e.slice(t+1)}},"tryParsePattern"),Xo=K(({prefix:e,suffix:t},i)=>i.length>=e.length+t.length&&i.startsWith(e)&&i.endsWith(t),"isPatternMatch"),ea=K((e,t,i)=>{let n,o=-1;for(const a of e){const s=t(a);Xo(s,i)&&s.prefix.length>o&&(o=s.prefix.length,n=a)}return n},"findBestPatternMatch"),ta=K((e,t)=>{const i=[];for(const n of e){if(!Qo(n))continue;const o=Zo(n);if(o)i.push(o);else if(n===t)return n}return ea(i,n=>n,t)},"matchPatternOrExact"),ia=K((e,t)=>t.substring(e.prefix.length,t.length-e.suffix.length),"matchedText"),na=K(({prefix:e,suffix:t})=>`${e}*${t}`,"patternText"),oa=K((e,t,i)=>{let n=f.dirname(t.path);t.config.compilerOptions?.baseUrl&&(n=f.resolve(e,t.config.compilerOptions.baseUrl)),i?.debug({message:`Resolved baseUrl to ${n}`,prefix:"plugin:packem:resolve-tsconfig-paths"});const o=t.config.compilerOptions?.paths??{};return Object.keys(o).length===0&&i?.debug({message:"No paths found in tsconfig.json",prefix:"plugin:packem:resolve-tsconfig-paths"}),{paths:o,resolvedBaseUrl:n}},"getTsconfigPaths"),Tt=K((e,t,i,n)=>{const{paths:o,resolvedBaseUrl:a}=oa(e,t,i),s=Object.keys(o);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,p,l){if(s.length===0)return null;if(r.includes("\0"))return i.debug({message:`Skipping resolution of ${r} as it is a virtual module`,prefix:"plugin:packem:resolve-tsconfig-paths"}),null;if(r.includes("node_modules"))return i.debug({message:`Skipping request as it is inside node_modules ${r}`,prefix:"plugin:packem:resolve-tsconfig-paths"}),null;if(!n.resolveAbsolutePath&&f.isAbsolute(r))return i.debug({message:`Skipping request as it is an absolute path ${r}`,prefix:"plugin:packem:resolve-tsconfig-paths"}),null;if(Se.isRelative(r))return i.debug({message:`Skipping request as it is a relative path ${r}`,prefix:"plugin:packem:resolve-tsconfig-paths"}),null;const c=ta(s,r);if(!c)return i.debug({message:`moduleName did not match any paths pattern ${r}`,prefix:"plugin:packem:resolve-tsconfig-paths"}),null;const u=typeof c=="string"?void 0:ia(c,r),d=typeof c=="string"?c:na(c);for await(const m of o[d]){const w=u?m.replace("*",u):m;if(w.endsWith(".d.ts")||w.endsWith(".d.cts")||w.endsWith(".d.mts"))continue;const b=f.join(a,w);try{const y=await this.resolve(b,p,{skipSelf:!0,...l});if(y)return y}catch(y){i.debug({context:y,message:`Failed to resolve ${b} from ${r}`,prefix:"plugin:packem:resolve-tsconfig-paths"})}}return null}}},"resolveTsconfigPathsPlugin");var aa=Object.defineProperty,zt=g((e,t)=>aa(e,"name",{value:t,configurable:!0}),"u$6");const sa=zt((e,t)=>{if(!t)return null;const{config:i,path:n}=t;if(!i.compilerOptions)return null;const{rootDirs:o}=i.compilerOptions;if(!o)return null;const a=[];for(const s of o){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);a.push(f.resolve(e,s))}return a},"getRootDirectories"),Rt=zt((e,t,i)=>{const n=sa(e,i);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(o,a,s){if(n===null||n.length===0)return null;if(o.startsWith("."))for(const r of n){const p=f.join(r,o),l=await this.resolve(p,a,{skipSelf:!0,...s});if(l)return t.debug({message:`Resolved ${o} to ${l.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),l.id}return null}}},"resolveTsconfigRootDirectories");var ra=Object.defineProperty,la=g((e,t)=>ra(e,"name",{value:t,configurable:!0}),"r$7");const qt=la(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,i,n){return e.test(t)&&i?await this.resolve(t.replace(/js(x?)$/,"ts$1"),i,n):null}}},"resolveTypescriptMjsCts"),Jt={"application/prs.cww":["cww"],"application/prs.xsf+xml":["xsf"],"application/vnd.1000minds.decision-model+xml":["1km"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["*xfdf"],"application/vnd.age":["age"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.keynote":["key"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.numbers":["numbers"],"application/vnd.apple.pages":["pages"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.balsamiq.bmml+xml":["bmml"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.citationstyles.style+xml":["csl"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dbf":["dbf"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["*fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mapbox-vector-tile":["mvt"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["*mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.pwg-xhtml-print+xml":["xhtm"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.rar":["rar"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml","uo"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-iwork-keynote-sffkey":["*key"],"application/x-iwork-numbers-sffnumbers":["*numbers"],"application/x-iwork-pages-sffpages":["*pages"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["*prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["*rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["*sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["*aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif","btf"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.pco.b16":["b16"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.cld":["cld"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.pytha.pyox":["pyo","pyox"],"model/vnd.sap.vds":["vds"],"model/vnd.usda":["usda"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.familysearch.gedcom":["ged"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]};Object.freeze(Jt);const pa=new _.p(_.g,Jt)._freeze();var ca=Object.defineProperty,Ue=g((e,t)=>ca(e,"name",{value:t,configurable:!0}),"u$5");const da=Ue(async(e,t)=>{await new Promise((i,n)=>{const o=be.createReadStream(e);o.on("error",n);const a=be.createWriteStream(t);a.on("error",n),a.on("finish",i),o.pipe(a)})},"copy"),ua=Ue(e=>{let t=e.toString("utf8").replaceAll(/[\n\r]/g,"").replaceAll(" "," "),i;do i=t,t=t.replaceAll(/))-->/g,"");while(t!==i);return encodeURIComponent(t.replaceAll("'","\\i")).replaceAll("(","%28").replaceAll(")","%29")},"encodeSVG"),ma=Ue(({destDir:e,emitFiles:t,exclude:i,fileName:n,include:o,limit:a,publicPath:s,sourceDir:r})=>{const p=U.createFilter(o,i),l={};return{async generateBundle(c){if(!t)return;const u=e??c.dir??f.dirname(c.file??"");await S.ensureDir(u),await Promise.all(Object.keys(l).map(async d=>{const m=l[d],w=f.join(u,f.dirname(m));await S.ensureDir(w),await da(d,f.join(u,m))}))},async load(c){if(!p(c))return null;this.addWatchFile(c);const[u,d]=await Promise.all([Y.stat(c),Y.readFile(c)]);let m;if(a&&u.size>a||a===0){const w=Ti.createHash("sha1").update(d).digest("hex").slice(0,16),b=f.extname(c),y=f.basename(c,b),h=r?f.relative(r,f.dirname(c)):f.basename(f.dirname(c)),v=n.replaceAll("[hash]",w).replaceAll("[extname]",b).replaceAll("[dirname]",h===""?"":`${h}/`).replaceAll("[name]",y);m=f.join(s??"",v),l[c]=v}else{const w=pa.getType(c);if(w===null)throw new Error(`Could not determine mimetype for ${c}`);const b=w==="image/svg+xml";m=b?ua(d):d.toString("base64"),m=`data:${w}${b?"":";base64"},${m}`}return`export default "${m}"`},name:"packem:url"}},"urlPlugin");var fa=Object.defineProperty,ga=g((e,t)=>fa(e,"name",{value:t,configurable:!0}),"s$8");const va=ga(e=>{const t=f.basename(e).split(".");if(t.length>=2){const[i,n]=t.slice(-2),o=t[0],a=/^(\w+)-runtime$/.exec(i)?.[1];if(E.D.includes(n)&&a&&a.length>0)return o+"-"+a}},"getCustomModuleLayer");var ha=Object.defineProperty,ya=g((e,t)=>ha(e,"name",{value:t,configurable:!0}),"i$4");const Fe=ya(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var xa=Object.defineProperty,at=g((e,t)=>xa(e,"name",{value:t,configurable:!0}),"d$8");const ba=at((e,t)=>{const i=new Map;return at(function(n,o){const a=o.getModuleInfo(n);if(!a)return;const{isEntry:s}=a,r=a.meta,p=Fe(r);if(!s){const l=i.get(n);if(l)return l;const c=va(n);if(c)return i.set(n,c),c}if(s){const l=o.getModuleIds();for(const c of l)o.getModuleInfo(c)&&Fe(r)===p&&(e.has(c)||e.set(c,new Set),e.get(c).add([n,p]))}if(p&&!s&&e.has(n)){const l=[...e.get(n)];if(l.some(([u])=>{if(t.some(d=>d.path===u)){const d=o.getModuleInfo(u);return Fe(d?d.meta:{})===p}return!1}))return;if(l.every(([,u])=>u===p))return i.has(n)?i.get(n):void 0;const c=f.basename(n,f.extname(n))+"-"+p;return i.set(n,c),c}},"splitChunks")},"createSplitChunks");var wa=Object.defineProperty,ka=g((e,t)=>wa(e,"name",{value:t,configurable:!0}),"n$4");const H=ka((e,t)=>e.isDynamicEntry?`${E.C}/[name].${t}`:`${E.S}/${e.name}-[hash].${t}`,"getChunkFilename");var ja=Object.defineProperty,$a=g((e,t)=>ja(e,"name",{value:t,configurable:!0}),"o$4");const Ea=process.platform==="win32",st=$a((e,t)=>{const i=Ea?"\\":"/";for(let n of Array.isArray(e.names)?e.names:[]){if(n.includes("node_modules"+i+".pnpm"))return n=n.replace("node_modules"+i+".pnpm","external")+"."+t,n.replace("node_modules"+i,"");if(n.includes("node_modules"))return n.replace("node_modules","external")+"."+t}return"[name]."+t},"getEntryFileNames");var Sa=Object.defineProperty,I=g((e,t)=>Sa(e,"name",{value:t,configurable:!0}),"e$5");const Bt=I((e,t)=>{const i=[],n=[],o=[];return e&&e.filter(Boolean).filter(a=>a.type===t?!0:t==="build"&&a.type===void 0).forEach(a=>{a.enforce==="pre"?i.push(a.plugin):a.enforce==="post"?n.push(a.plugin):o.push(a.plugin)}),[i,o,n]},"sortUserPlugins"),Oa=I((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.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(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let i="node"+Be.versions.node.split(".")[0];if(t.pkg.engines?.node){const n=xe.minVersion(t.pkg.engines.node);n&&(i="node"+n.major)}if(t.options.rollup.esbuild.target){const n=le(t.options.rollup.esbuild.target);n.some(o=>o.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...le(i),...n])])}else t.options.rollup.esbuild.target=le(i);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{topLevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return t.options.rollup.sucrase}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),Wt=I((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${j.cyan(f.relative(f.resolve(),e.id))}" Is the module installed? Note: ↳ to inline a module into your bundle, install it to "devDependencies". ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Lt=I((e,t)=>({input:Object.fromEntries(e.options.entries.map(i=>[i.name,f.resolve(e.options.rootDir,i.input)])),logLevel:e.options.debug?"debug":"info",onLog:I((i,n)=>{let o=n.message;switch(n.stack&&(o=`${o} ${n.stack}`),i){case"info":{e.logger.info({message:o,prefix:t+(n.plugin?":plugin:"+n.plugin:"")});return}case"warn":{e.logger.warn({message:o,prefix:t+(n.plugin?":plugin:"+n.plugin:"")});return}case"debug":e.logger.debug({message:o,prefix:t+(n.plugin?":plugin:"+n.plugin:"")})}},"onLog"),onwarn(i,n){Wt(i,e)||i.code||n(i)},treeshake:{moduleSideEffects:!0,preset:"smallest"},watch:e.mode==="watch"?e.options.rollup.watch:!1}),"baseRollupOptions"),Ut=I(async(e,t)=>{const i=Pe(e.pkg,e.options);let n;e.options.rollup.resolve&&(n=yt.nodeResolve({...e.options.rollup.resolve}));const o=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:ba(e.dependencyGraphMap,e.buildEntries),preserveModules:!1},[a,s,r]=Bt(e.options.rollup.plugins,"build");return{...Lt(e,"build"),output:[e.options.emitCJS&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:I(p=>H(p,"cjs"),"chunkFileNames"),compact:e.options.minify,dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:I(p=>st(p,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,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,...o},e.options.emitESM&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:I(p=>H(p,"mjs"),"chunkFileNames"),compact:e.options.minify,dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:I(p=>st(p,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,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,...o}].filter(Boolean),plugins:[F(At(),t),F(qt(),t),e.tsconfig&&F(Rt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&F(Tt(e.options.rootDir,e.tsconfig,e.logger,e.options.rollup.tsconfigPaths),t),F(Mt(e.pkg,e.tsconfig,e.options,e.logger,e.options.rollup.resolveExternals??{}),t),e.options.rollup.replace&&kt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&wt({customResolver:n,...e.options.rollup.alias,entries:i}),...a,n,e.options.rollup.polyfillNode&&Mi({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Ot({...e.options.rollup.json}),nn(),e.options.rollup.wasm&&ui.wasm(e.options.rollup.wasm),e.options.rollup.url&&ma(e.options.rollup.url),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&await En({dts:!!e.options.declaration||e.options.isolatedDeclarationTransformer!==void 0,sourceMap:e.options.sourcemap,...e.options.rollup.css},e.logger,e.options.browserTargets,e.options.rootDir,e.options.sourceDir,e.environment,e.options.sourcemap,e.options.debug,e.options.minify??!1,i),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&e.options.declaration&&Dn(e.options.rollup.css,e.options.rootDir,e.logger),e.options.rollup.raw&&F(Eo(e.options.rollup.raw),t),e.options.sourcemap&&To(e.options.rollup.sourcemap),...s,e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Hn(f.join(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations,e.tsconfig),e.options.transformer(Oa(e.options.transformerName,e)),F(ko({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&Co(e.options.entries.filter(p=>p.executable).map(p=>p.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&St({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&zn(),e.options.rollup.dynamicVars&&Ci(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&F(_i({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&&Fn(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&F(so({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),...r,e.options.rollup.metafile&&uo(),e.options.rollup.copy&&un(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&_t({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),xo(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&go(e.logger,e.options.entries,e.options.outDir,e.options.rootDir,e.options.rollup.node10Compatibility.writeToPackageJson?"file":"console",e.options.rollup.node10Compatibility.typeScriptVersion??"*"),e.options.analyze&&e.options.rollup.visualizer!==!1&&fi.visualizer({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)}},"getRollupOptions"),Pa=I(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Da=Wi(Pa),Kt=I(async(e,t)=>{const i=Pe(e.pkg,e.options),n=e.tsconfig?.config.compilerOptions;delete n?.lib;let o;e.options.rollup.resolve&&(o=yt.nodeResolve({...e.options.rollup.resolve}));const a="dts-plugin:"+process.pid+e.tsconfig.path,[s,r,p]=Bt(e.options.rollup.plugins,"dts");return{...Lt(e,"dts"),onwarn(l,c){Wt(l,e)||l.code!=="EMPTY_BUNDLE"&&c(l)},output:[e.options.emitCJS&&{chunkFileNames:I(l=>H(l,"d.cts"),"chunkFileNames"),compact:e.options.minify,dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:I(l=>H(l,"d.mts"),"chunkFileNames"),compact:e.options.minify,dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:I(l=>H(l,"d.ts"),"chunkFileNames"),compact:e.options.minify,dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[F(At(),t),F(qt(),t),e.options.rollup.json&&Ot({...e.options.rollup.json}),{load(l){return/\.(?:js|cjs|mjs|jsx|ts|tsx|ctsx|mtsx|mts|json)$/.test(l)?null:""},name:"packem:ignore-files"},e.tsconfig&&F(Rt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&F(Tt(e.options.rootDir,e.tsconfig,e.logger,e.options.rollup.tsconfigPaths),t),F(Mt(e.pkg,e.tsconfig,e.options,e.logger,e.options.rollup.resolveExternals??{}),t),e.options.rollup.replace&&kt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&wt({customResolver:o,...e.options.rollup.alias,entries:i}),...s,o,...r,await Da(a)(e),e.options.cjsInterop&&e.options.emitCJS&&St({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&F(Ho(e.options.rollup.patchTypes,e.logger),t),Mo(),...p,e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&_t({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Na=Object.defineProperty,_a=g((e,t)=>Na(e,"name",{value:t,configurable:!0}),"m$5");const rt="rollup-build.json",Ca=_a(async(e,t,i)=>{const n=await Ut(e,t);if(await e.hooks.callHook("rollup:options",e,n),Object.keys(n.input).length===0)return;let o=!0;(e.options.rollup.isolatedDeclarations||e.options.isolatedDeclarationTransformer||e.options.rollup.css)&&(o=!1),o&&(n.cache=t.get(rt,i));const a=await pe.rollup(n);o&&t.set(rt,a.cache,i),await e.hooks.callHook("rollup:build",e,a);const s=new Map;for(const r of n.output){const{output:p}=await a.write(r),l=new Set,c=p.filter(d=>d.type==="chunk");for(const d of c){l.add(d.fileName);for(const m of d.imports)e.usedImports.add(m);d.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(d.code,"utf8"),chunks:d.imports.filter(m=>c.find(w=>w.fileName===m)),exports:d.exports,modules:Object.entries(d.modules).map(([m,w])=>({bytes:w.renderedLength,id:m})),path:d.fileName,type:"entry"})}const u=p.filter(d=>d.type==="asset");for(const d of u)s.has(d.fileName)||s.set(d.fileName,{bytes:Buffer.byteLength(d.source,"utf8"),path:d.fileName,type:"asset"});for(const d of l)e.usedImports.delete(d)}e.buildEntries.push(...s.values())},"build");var Ma=Object.defineProperty,fe=g((e,t)=>Ma(e,"name",{value:t,configurable:!0}),"a$9");const lt="rollup-dts.json",Aa=fe(async(e,t,i)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});return}const n=await Kt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,n),Object.keys(n.input).length===0)return;n.cache=t.get(lt,i);const o=await pe.rollup(n);t.set(lt,o.cache,i),await e.hooks.callHook("rollup:dts:build",e,o),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await o.write({chunkFileNames:fe(a=>H(a,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await o.write({chunkFileNames:fe(a=>H(a,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await o.write({chunkFileNames:fe(a=>H(a,"d.cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Fa=Object.defineProperty,Ia=g((e,t)=>Fa(e,"name",{value:t,configurable:!0}),"y$4");const Ta=Ia((e,t,i)=>e.reduce((n,o)=>{const a=o[t],s=o[i];return n[a]||(n[a]={}),n[a][s]||(n[a][s]=[]),n[a][s].push(o),n},{}),"groupByKeys");var za=Object.defineProperty,je=g((e,t)=>za(e,"name",{value:t,configurable:!0}),"j$1");const Ra=je((e,t)=>{const i=je(s=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,s)),"rPath");let n=!1;const o=[],a=t.buildEntries.filter(s=>s.type==="entry");if(a.length>0){e.raw(`Entries: `);for(const s of a){let r=s.bytes??0;for(const l of s.chunks??[])r+=t.buildEntries.find(c=>c.path===l)?.bytes??0;let p=` ${j.bold(i(s.path))} (${["total size: "+j.cyan(L.formatBytes(r)),s.bytes&&"chunk size: "+j.cyan(L.formatBytes(s.bytes))].filter(Boolean).join(", ")})`;if(p+=s.exports?.length?` exports: `+j.gray(s.exports.join(", ")):"",s.chunks?.length&&(p+=` ${s.chunks.map(l=>{const c=t.buildEntries.find(u=>u.path===l)??{};return j.gray(" └─ "+i(l)+j.bold(c.bytes?" ("+L.formatBytes(c?.bytes)+")":""))}).join(` `)}`),s.modules&&s.modules.length>0){const l=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,u)=>(u.bytes||0)-(c.bytes||0)).map(c=>j.gray(" 📦 "+i(c.id)+j.bold(c.bytes?" ("+L.formatBytes(c.bytes)+")":""))).join(` `);p+=l.length>0?` inlined modules: `+l:""}if(t.options.declaration){let l=s.path.replace(/\.js$/,".d.ts"),c="commonjs";s.path.endsWith(".cjs")?l=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(c="module",l=s.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(d=>d.path.endsWith(l));if(u){o.push(u.path);let d;l.includes(".d.ts")||(l=l.replace(".d.c",".d."),d=t.buildEntries.find(m=>m.path.endsWith(l))),d&&(o.push(d.path),p+=c==="commonjs"?` types: `+[u,d].map(m=>j.gray(" └─ ")+j.bold(i(m.path))+" (total size: "+j.cyan(L.formatBytes(m.bytes??0))+")").join(` `):` types: `+j.bold(i(u.path))+" (total size: "+j.cyan(L.formatBytes(u.bytes??0))+")")}}n=!0,p+=` `,e.raw(s.chunk?j.gray(p):p)}}if(t.buildEntries.filter(s=>s.type==="asset").length>0){let s="Assets:";for(const r of t.buildEntries.filter(p=>p.type==="asset"))o.includes(r.path)||(s+=j.gray(` └─ `)+j.bold(i(r.path))+" (total size: "+j.cyan(L.formatBytes(r.bytes??0))+")");s+=` `,e.raw(s)}return n&&e.raw("Σ Total dist size (byte size):",j.cyan(L.formatBytes(t.buildEntries.reduce((s,r)=>s+(r.bytes??0),0),{decimals:2})),` `),n},"showSizeInformation"),qa=je((e,t)=>{const i=Ta(e.options.entries,"environment","runtime"),n=new Set,o=new Set;for(const[a,s]of Object.entries(i))for(const[r,p]of Object.entries(s)){const l={...e};!e.options.dtsOnly&&(a!=="undefined"||r!=="undefined")&&e.logger.info("Preparing build for "+(a==="undefined"?"":j.cyan(a)+" environment"+(r==="undefined"?"":" with "))+(r==="undefined"?"":j.cyan(r)+" runtime"));const c={};l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),a!=="undefined"&&(c[["process","env","NODE_ENV"].join(".")]=JSON.stringify(a)),c[["process","env","EdgeRuntime"].join(".")]=JSON.stringify(r==="edge-light"),Object.freeze(c)):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let u="";a!=="undefined"&&(u+=a+"/"),r!=="undefined"&&(u+=r+"/");let d=!1;l.options.minify!==void 0&&(d=l.options.minify),a==="development"?d=!1:a==="production"&&(d=!0);const m=[],w=[],b=[],y=[];for(const h of p)h.cjs&&h.esm?m.push(h):h.cjs?b.push(h):h.esm?w.push(h):h.declaration&&y.push(h);if(m.length>0){const h={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:m,minify:d,rollup:{...l.options.rollup,replace:l.options.rollup.replace?{...l.options.rollup.replace,values:{...l.options.rollup.replace.values,...c}}:!1}}};if(e.options.dtsOnly||n.add({context:h,fileCache:t,subDirectory:u}),e.options.declaration){const v=h.options.entries.filter(k=>k.declaration);v.length>0&&o.add({context:{...h,options:{...h.options,entries:v}},fileCache:t,subDirectory:u})}}if(w.length>0){const h={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:w,minify:d,rollup:{...l.options.rollup,replace:l.options.rollup.replace?{...l.options.rollup.replace,values:{...l.options.rollup.replace.values,...c}}:!1}}};if(e.options.dtsOnly||n.add({context:h,fileCache:t,subDirectory:u}),e.options.declaration){const v=h.options.entries.filter(k=>k.declaration);v.length>0&&o.add({context:{...h,options:{...h.options,entries:v}},fileCache:t,subDirectory:u})}}if(b.length>0){const h={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:b,minify:d,rollup:{...l.options.rollup,replace:l.options.rollup.replace?{...l.options.rollup.replace,values:{...l.options.rollup.replace.values,...c}}:!1}}};if(e.options.dtsOnly||n.add({context:h,fileCache:t,subDirectory:u}),e.options.declaration){const v=h.options.entries.filter(k=>k.declaration);v.length>0&&o.add({context:{...h,options:{...h.options,entries:v}},fileCache:t,subDirectory:u})}}l.options.declaration&&y.length>0&&o.add({context:{...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:y,minify:d,rollup:{...l.options.rollup,replace:l.options.rollup.replace?{...l.options.rollup.replace,values:{...l.options.rollup.replace.values,...c}}:!1}}},fileCache:t,subDirectory:u})}return{builders:n,typeBuilders:o}},"prepareRollupConfig"),Ja=je(async(e,t)=>{await e.hooks.callHook("build:before",e);const{builders:i,typeBuilders:n}=qa(e,t);await Promise.all([...i].map(async({context:o,fileCache:a,subDirectory:s})=>await Ca(o,a,s))),await Promise.all([...n].map(async({context:o,fileCache:a,subDirectory:s})=>await Aa(o,a,s))),e.logger.success(j.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of S.walk(f.join(e.options.rootDir,e.options.outDir))){let a=e.buildEntries.find(s=>f.join(e.options.rootDir,e.options.outDir,s.path)===o.path);if(a||(a={chunk:!0,path:o.path},e.buildEntries.push(a)),!a.bytes){const s=await Y.stat(f.resolve(e.options.rootDir,e.options.outDir,o.path));a.bytes=s.size}}return await e.hooks.callHook("build:done",e),Ra(e.logger,e)},"build");var Ba=Object.defineProperty,Wa=g((e,t)=>Ba(e,"name",{value:t,configurable:!0}),"r$5");const D=Wa((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var La=Object.defineProperty,Vt=g((e,t)=>La(e,"name",{value:t,configurable:!0}),"t$4");const $e=Vt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Je=Vt((e,t,i,n)=>{if(e==="module-sync")return"esm";if(n){const s=$e(n);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return i;const[o,...a]=t;return Je(o,a,i,n)},"inferExportType");var Ua=Object.defineProperty,Ka=g((e,t)=>Ua(e,"name",{value:t,configurable:!0}),"y$3");const Va=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...E.R,...E.a]),Ke=Ka((e,t,i,n=[])=>{if(!e)return[];if(typeof e=="string"){const o=$e(e);if(o&&o!==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:o??t}]}if(typeof e=="object"){const o=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let a=[];for(const[s,r]of o)if(typeof r=="string"){let p={};Number.isInteger(+s)?p={exportKey:"*"}:s.startsWith("./")?p={exportKey:s.replace("./","")}:p={exportKey:s==="."?".":"*",subKey:s},a.push({...p,file:r,key:"exports",type:Je(s,n,t,r)})}else if(typeof r=="object"&&r!==null)for(const[p,l]of Object.entries(r)){if(i===!1&&p==="types")continue;const c=Number.isInteger(+s)?p:s;typeof l=="string"?a.push({exportKey:c.replace("./",""),file:l,key:"exports",...Va.has(p)?{subKey:p}:{},type:Je(p,n,t,l)}):a=[...a,...Ke({[c]:l},t,i,[...n,p])]}return a}return[]},"extractExportFilenames");var Ha=Object.defineProperty,Ne=g((e,t)=>Ha(e,"name",{value:t,configurable:!0}),"y$2");const Ga=Ne((e,t)=>e.key==="exports"&&e.subKey===E.P?E.P:e.key==="exports"&&e.subKey===E.b?E.b:t,"getEnvironment"),ge=Ne((e,t,i,n,o,a,s)=>{const r=Ga(o,a.environment);let p="node";for(const u of E.R)if(o.file.includes("."+u+".")||o.subKey===u){p=u;break}let l=e.find(u=>u.input===t&&u.environment===r&&u.runtime===p);l===void 0?l=e[e.push({environment:r,exportKey:new Set([o.exportKey].filter(Boolean)),input:t,runtime:p})-1]:l.exportKey&&o.exportKey&&l.exportKey.add(o.exportKey),s&&(l.isGlob=!0),i&&(l.outDir=n),o.isExecutable?(l.executable=!0,l.declaration=!1,o.type==="cjs"?l.cjs=!0:o.type==="esm"&&(l.esm=!0)):(/\.d\.[mc]?ts$/.test(o.file)&&a.options.declaration!==!1&&(l.declaration=a.options.declaration),o.type==="cjs"?l.cjs=!0:o.type==="esm"&&(l.esm=!0));const c=o.file.replace(f.extname(o.file),"").replace(new RegExp(`^./${a.options.outDir.replace(/^\.\//,"")}/`),"");E.a.has(o.subKey)&&!t.includes(c)&&(l.fileAlias=c)},"createOrUpdateEntry");let pt=!1;const ct=Ne(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.")},"validateIfTypescriptIsInstalled"),Ya=Ne((e,t,i)=>{const n=[];t.sort((r,p)=>r.split("/").length-p.split("/").length);const o=e.type==="module"?"esm":"cjs";o==="esm"&&(i.options.emitESM=!0),o==="cjs"&&(i.options.emitCJS=!0);const a=Ke(e.exports,o,i.options.declaration);if(e.bin){const r=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const p of r){const l=$e(p);if(l&&l!==o)throw new Error(`Exported file "${p}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);a.push({file:p,isExecutable:!0,key:"bin",type:l??o})}}e.main&&a.push({file:e.main,key:"main",type:$e(e.main)??o}),e.module&&a.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(ct(i),i.options.declaration===void 0&&(i.options.declaration="compatible"),a.push({file:e.types??e.typings,key:"types"}));const s=[];for(const r of a){const p=f.extname(r.file);if(p!==""&&!E.D.includes(p))continue;i.options.declaration===void 0&&(r.key==="types"||r.subKey==="types")&&(i.options.declaration=r.file.includes(".d.ts")?"compatible":!0),i.options.emitCJS===void 0&&r.type==="cjs"&&(i.options.emitCJS=!0),i.options.emitESM===void 0&&r.type==="esm"&&(i.options.emitESM=!0);const l=r.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const u=l.replace(new RegExp("(./)?"+i.options.outDir),i.options.sourceDir).replace("./",""),d="(?<=/|$)",m=c?"":"(\\.[cm]?[tj]sx?)$";if(r.file.includes("/*")&&r.key==="exports"){pt||(i.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),pt=!0);const h=[],v=new RegExp(d+u.replace("*","(.*)")+m),k=new RegExp(d+u.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+m);for(const $ of t)(v.test($)||E.a.has(r.subKey)&&k.test($))&&h.push($);if(h.length===0){n.push(`Could not find entrypoint for \`${r.file}\``);continue}for(const $ of h)ge(s,$,c,l,r,i,!0);continue}const w=new RegExp(d+u+m);let b=t.find(h=>w.test(h));if(E.a.has(r.subKey)&&b===void 0){const h=new RegExp(d+u.replace(/(.*)\.[^.]*$/,"$1")+m);b=t.find(v=>h.test(v))}if(b===void 0){S.isAccessibleSync(f.resolve(i.options.rootDir,r.file))||n.push(`Could not find entrypoint for \`${r.file}\``);continue}(b.endsWith(".ts")||b.endsWith(".cts")||b.endsWith(".mts"))&&S.isAccessibleSync(b)&&ct(i);const y=f.toNamespacedPath(b.replace(E.E,""));S.isAccessibleSync(y+".cts")&&S.isAccessibleSync(y+".mts")?(ge(s,y+".cts",c,l,{...r,type:"cjs"},i,!1),ge(s,y+".mts",c,l,{...r,type:"esm"},i,!1)):ge(s,b,c,l,r,i,!1)}return{entries:s,warnings:n}},"inferEntries");var Qa=Object.defineProperty,Za=g((e,t)=>Qa(e,"name",{value:t,configurable:!0}),"o$3");const Xa=Za((e,t)=>{const{publishConfig:i}=e;return i&&(i.bin&&(typeof i.bin=="object"||typeof i.bin=="string")&&(e.bin=i.bin),i.type&&typeof i.type=="string"&&i.type!==""&&(e.type=i.type),i.main&&typeof i.main=="string"&&i.main!==""&&(e.main=i.main),i.module&&typeof i.module=="string"&&i.module!==""&&(e.module=i.module),t===void 0&&i.types&&typeof i.types=="string"&&i.types!==""?e.types=i.types:t===void 0&&i.typings&&typeof i.typings=="string"&&i.typings!==""&&(e.typings=i.typings),i.exports&&typeof i.exports=="object"&&(e.exports=i.exports)),e},"overwriteWithPublishConfig");var es=Object.defineProperty,ts=g((e,t)=>es(e,"name",{value:t,configurable:!0}),"t$3");const is={hooks:{"build:prepare":ts(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,e.options.sourceDir);if(!S.isAccessibleSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const i=S.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(i.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(n.publishConfig),n=Xa(n,e.options.declaration));const o=Ya(n,i,e);for(const a of o.warnings)D(e,a);if(e.options.entries.push(...o.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",j.cyan(e.options.entries.map(a=>a.fileAlias?j.bold(a.fileAlias)+" => "+j.bold(a.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):j.bold(a.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),j.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(a=>`[${a}]`).join(" ")))},"build:prepare")}};var ns=Object.defineProperty,os=g((e,t)=>ns(e,"name",{value:t,configurable:!0}),"t$2");const as=os(async(e,t)=>{if(e==="auto")e=is;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var ss=Object.defineProperty,rs=g((e,t)=>ss(e,"name",{value:t,configurable:!0}),"j");const ls=rs(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,i=[],n=JSON.stringify({...e.options.jiti,alias:{...Pe(e.pkg,e.options),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((o,a)=>{if(Array.isArray(o)){const[s,...r]=o;return i.push(s),"["+["plugin"+a,...r.map(p=>JSON.stringify(p))].join(", ")+"]"}return i.push(o),"plugin"+a}).join(",")+"]":"[]");for(const o of e.options.entries){const a=f.resolve(e.options.rootDir,e.options.outDir,o.name),s=te.fileURLToPath(e.jiti.esmResolve(o.input,{try:!0})??o.input),r=s.replace(E.E,""),p=S.readFileSync(s),l=Ao(p);let c=[];try{c=await te.resolveModuleExportNames(s,{extensions:E.D})}catch(d){D(e,`Cannot analyze ${s} for exports: ${d.toString()}`);return}const u=c.includes("default")||c.length===0;if(e.options.emitESM){const d=f.relative(f.dirname(a),await te.resolvePath("jiti",{conditions:["node","import"],url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ee&&ee.tagName.toUpperCase()==="SCRIPT"&&ee.src||new URL("packem.cjs",document.baseURI).href})),m=r+".d.mts";S.writeFileSync(`${a}.mjs`,l+['import { createJiti } from "'+d+'";',...i.map((w,b)=>"import plugin"+b+' from "'+w+'";'),"","const jiti = createJiti(import.meta.url, "+n+");","",'/** @type {import("'+m+'")} */','const _module = await jiti.import("'+s+'");',u?` export default _module;`:"",...c.filter(w=>w!=="default").map(w=>`export const ${w} = _module.${w};`)].join(` `)),e.options.declaration&&S.writeFileSync(`${a}.d.mts`,'export * from "'+m+`"; `+(u?'export { default } from "'+m+'";':""))}if(e.options.emitCJS){const d=f.relative(f.dirname(a),await te.resolvePath("jiti",{conditions:["node","require"],url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ee&&ee.tagName.toUpperCase()==="SCRIPT"&&ee.src||new URL("packem.cjs",document.baseURI).href})),m=r+".d.cts";S.writeFileSync(`${a}.cjs`,l+['const { createJiti } = require("'+d+'");',...i.map((w,b)=>"const plugin"+b+" = require("+JSON.stringify(w)+")"),"","const jiti = createJiti(__filename, "+n+");","",'/** @type {import("'+m+'")} */','module.exports = jiti("'+s+'")'].join(` `)),e.options.declaration&&S.writeFileSync(a+".d.cts",'export * from "'+m+`"; `+(u?'export { default } from "'+m+'";':""))}l&&(await qe(`${a}.cjs`),await qe(`${a}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var ps=Object.defineProperty,Ve=g((e,t)=>ps(e,"name",{value:t,configurable:!0}),"i$2");const cs=Ve(e=>{const{message:t,name:i="Error",stack:n}=e;if(!n)return n;const o=`${i}: ${t} `;return n.startsWith(o)?n.slice(o.length):n},"extractStack"),ds=Ve(e=>` ${e.replaceAll(/^\n|\n$/g,"")} `,"normalizeCodeFrame"),Ht=Ve(e=>{const t=cs(e);let i=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(i+=` file: ${j.cyan(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(i+=` `+j.yellow(ds(e.frame))),e.message=i,t!==void 0&&(e.stack=`${e.message} ${t}`)},"enhanceRollupError");var us=Object.defineProperty,Gt=g((e,t)=>us(e,"name",{value:t,configurable:!0}),"d$3");const Ee="rollup-watch.json",dt=Gt(({context:e,doOnSuccessCleanup:t,fileCache:i,mode:n,runBuilder:o,runOnsuccess:a,useCache:s,watcher:r})=>{const p="watcher:"+n;r.on("change",async(l,{event:c})=>{await t?.(),e.logger.info({message:`${j.cyan(f.relative(".",l))} was ${c}d`,prefix:p})}),r.on("restart",()=>{e.logger.info({message:"Rebuilding ...",prefix:p})}),r.on("event",async l=>{switch(l.code){case"END":{e.logger.success({message:"Rebuild finished",prefix:p}),await a?.();break}case"BUNDLE_START":{e.logger.info({message:j.cyan("build started..."),prefix:p});break}case"BUNDLE_END":{await l.result.close(),s&&i.set(n==="bundle"?Ee:"dts-"+Ee,l.result.cache),e.logger.raw(` ⚡️ Build run in `+l.duration+`ms `),await o?.(!0);break}case"ERROR":{Ht(l.error),e.logger.error({context:[l.error],message:"Rebuild failed: "+l.error.message,prefix:p});break}}})},"watchHandler"),ms=Gt(async(e,t,i,n,o)=>{const a=await Ut(e,t);if(await e.hooks.callHook("rollup:options",e,a),Object.keys(a.input).length===0)return;let s=!0;(e.options.rollup.isolatedDeclarations||e.options.isolatedDeclarationTransformer||e.options.rollup.css)&&(s=!1),s&&(a.cache=t.get(Ee)),e.options.rollup.watch&&typeof a.watch=="object"&&a.watch.include===void 0&&(a.watch={...a.watch,...e.options.rollup.watch},a.watch.include=[f.join(e.options.sourceDir,"**","*"),"package.json","packem.config.*","tsconfig.json","tsconfig.*.json"],Array.isArray(e.options.rollup.watch.include)?a.watch.include=[...a.watch.include,...e.options.rollup.watch.include]:e.options.rollup.watch.include&&a.watch.include.push(e.options.rollup.watch.include),a.watch.chokidar={cwd:e.options.rootDir,...a.watch.chokidar,ignored:["**/.git/**","**/node_modules/**","**/test-results/**",...a.watch.chokidar?.ignored??[]]});const r=pe.watch(a);await e.hooks.callHook("rollup:watch",e,r);const p=[...Array.isArray(a.input)?a.input:typeof a.input=="string"?[a.input]:Object.keys(a.input??{})];let l="Starting watcher for entries:";for(const c of p)l+=j.gray(` └─ ${f.relative(process.cwd(),c)}`);if(e.logger.info(l),dt({context:e,doOnSuccessCleanup:o,fileCache:t,mode:"bundle",runBuilder:i,runOnsuccess:n,useCache:s,watcher:r}),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer)e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});else if(e.options.declaration){const c=await Kt(e,t);s&&(c.cache=t.get("dts-"+Ee)),await e.hooks.callHook("rollup:dts:options",e,c);const u=pe.watch(c);await e.hooks.callHook("rollup:watch",e,u),dt({context:e,fileCache:t,mode:"types",useCache:s,watcher:u})}},"watch");var fs=Object.defineProperty,gs=g((e,t)=>fs(e,"name",{value:t,configurable:!0}),"s$5");const vs=gs(async e=>{const t=[];if(e.options.clean)for(const i of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))i===e.options.rootDir||i===e.options.sourceDir||e.options.rootDir.startsWith(i.endsWith("/")?i:`${i}/`)||t.some(n=>i.startsWith(n))||(t.push(i),e.logger.info(`Cleaning dist directory: \`./${f.relative(e.options.rootDir,i)}\``),await S.emptyDir(i))},"cleanDistributionDirectories");var hs=Object.defineProperty,Yt=g((e,t)=>hs(e,"name",{value:t,configurable:!0}),"s$4");const ys=Yt(e=>{try{JSON.parse(e)}catch{return!1}return!0},"isJson");let xs=class{static{g(this,"g")}static{Yt(this,"FileCache")}#n;#e;#o;#t=!0;#i=new Map;constructor(t,i,n,o){this.#n=t,this.#o=n,i===void 0?o.debug({message:"Could not create cache directory.",prefix:"file-cache"}):(this.#e=i,o.debug({message:"Cache path is: "+this.#e,prefix:"file-cache"}))}set isEnabled(t){this.#t=t}has(t,i){return!this.#t||this.#e===void 0?!1:S.isAccessibleSync(this.getFilePath(t,i))}get(t,i){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,i);if(this.#i.has(n))return this.#i.get(n);if(!S.isAccessibleSync(n))return;const o=S.readFileSync(n);if(ys(o)){const a=JSON.parse(o);return this.#i.set(n,a),a}return this.#i.set(n,o),o}set(t,i,n){if(!this.#t||this.#e===void 0||i===void 0)return;const o=this.getFilePath(t,n);(typeof i=="object"||typeof i=="number"||typeof i=="boolean")&&(i=JSON.stringify(i)),S.writeFileSync(o,i,{overwrite:!0})}getFilePath(t,i){let n=t.replaceAll(f.toNamespacedPath(this.#n),"");return n=n.replaceAll(":","-"),f.join(this.#e,this.#o,i?.replaceAll(":","-")??"",f.toNamespacedPath(n))}};var bs=Object.defineProperty,ws=g((e,t)=>bs(e,"name",{value:t,configurable:!0}),"t$1");const ks=ws(async(e,t="")=>{let i=t;if(!i){const n=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const o of n)if(await S.isAccessible(f.join(e,o))){i="./"+o;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(i))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return i},"findPackemFile");var js=Object.defineProperty,ve=g((e,t)=>js(e,"name",{value:t,configurable:!0}),"l$4");const $s=U.createFilter,Es=ve((e,t)=>{const{sideEffects:i}=t;let n;if(typeof i=="boolean")n=ve(()=>i,"hasSideEffects");else if(Array.isArray(i))if(i.length<=0)n=ve(()=>!1,"hasSideEffects");else{const o=i.map(a=>a.includes("/")?a:`**/${a}`);n=$s(o,null,{resolve:e})}else n=ve(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var Ie,ut;function Ss(){if(ut)return Ie;ut=1;var e=Object.defineProperty,t=g((p,l)=>e(p,"name",{value:l,configurable:!0}),"s"),i=zi,n=i.spawn,o=i.exec;Ie=g(function(p,l,c){if(typeof l=="function"&&c===void 0&&(c=l,l=void 0),p=parseInt(p),Number.isNaN(p)){if(c)return c(new Error("pid must be a number"));throw new Error("pid must be a number")}var u={},d={};switch(u[p]=[],d[p]=1,process.platform){case"win32":o("taskkill /pid "+p+" /T /F",c);break;case"darwin":r(p,u,d,function(m){return n("pgrep",["-P",m])},function(){a(u,l,c)});break;default:r(p,u,d,function(m){return n("ps",["-o","pid","--no-headers","--ppid",m])},function(){a(u,l,c)});break}},"treeKill");function a(p,l,c){var u={};try{Object.keys(p).forEach(function(d){p[d].forEach(function(m){u[m]||(s(m,l),u[m]=1)}),u[d]||(s(d,l),u[d]=1)})}catch(d){if(c)return c(d);throw d}if(c)return c()}g(a,"killAll"),t(a,"killAll");function s(p,l){try{process.kill(parseInt(p,10),l)}catch(c){if(c.code!=="ESRCH")throw c}}g(s,"killPid"),t(s,"killPid");function r(p,l,c,u,d){var m=u(p),w="";m.stdout.on("data",function(h){var h=h.toString("ascii");w+=h});var b=t(function(y){if(delete c[p],y!=0){Object.keys(c).length==0&&d();return}w.match(/\d+/g).forEach(function(h){h=parseInt(h,10),l[p].push(h),l[h]=[],c[h]=1,r(h,l,c,u,d)})},"onClose");m.on("close",b)}return g(r,"buildProcessTree"),t(r,"buildProcessTree"),Ie}g(Ss,"requireTreeKill");var Os=Ss();const Ps=xt.g(Os);var Ds=Object.defineProperty,Qt=g((e,t)=>Ds(e,"name",{value:t,configurable:!0}),"l$3");const Ns=Qt(e=>process.platform==="win32"&&"cmd"in e&&"code"in e&&typeof e.cmd=="string"&&e.cmd.startsWith("taskkill")&&e.code===128,"isTaskKillCmdProcessNotFoundError"),_s=Qt(async({pid:e,signal:t})=>await new Promise((i,n)=>{if(!Number.isInteger(e)||e<=0){n(new Error("Invalid process ID"));return}Ps(e,t,o=>{if(o&&!Ns(o)){n(o);return}i()})}),"killProcess");var Cs=Object.defineProperty,Ms=g((e,t)=>Cs(e,"name",{value:t,configurable:!0}),"n$1");const Zt=Ms(e=>{const t=f.join(e,"package.json");if(!S.isAccessibleSync(t))throw new Error("package.json not found at "+t);return{packageJson:Oi.parsePackageJson(t),packageJsonPath:t}},"loadPackageJson");var As=Object.defineProperty,Fs=g((e,t)=>As(e,"name",{value:t,configurable:!0}),"r$3");const mt=Fs((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(` `),e.logger.warn(`Build is done with some warnings: ${[...e.warnings].map(i=>`- ${i}`).join(` `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var Is=Object.defineProperty,Xt=g((e,t)=>Is(e,"name",{value:t,configurable:!0}),"r$2");const ft=Xt(async(e,t)=>{if(typeof e.name!="string"){let i=f.isAbsolute(e.input)?f.relative(t.options.rootDir,e.input):f.normalize(e.input);i.startsWith("./")&&(i=i.slice(2)),e.name=i.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(E.E,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Se.isRelative(e.input)&&(e.input=f.resolve(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),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):e.cjs===void 0&&e.esm===void 0&&(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM)),e.outDir=f.resolve(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),Ts=Xt(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:he.isDynamicPattern(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:he.isDynamicPattern(t.input)});for(const t of e.options.entries.filter(i=>i.isGlob)){const{isGlob:i,...n}=t,o=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")o.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const s of e.options.rollup.watch.exclude)typeof s=="string"&&o.push(s)}const a=he.globSync([n.input],{cwd:e.options.rootDir,dot:!1,ignore:o,onlyFiles:!0});if(a.length===0)throw new Pi.NotFoundError("No files found in the glob pattern: "+j.cyan(f.join(e.options.rootDir,n.input)));for(const s of a)e.options.entries.push({...n,input:f.resolve(e.options.rootDir,s)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for(const t of e.options.entries.filter(i=>i.fileAlias===void 0))await ft(t,e);for(const t of e.options.entries.filter(i=>i.fileAlias!==void 0))t.name=t.fileAlias,t.fileAlias=void 0,await ft(t,e)},"prepareEntries");var zs=Object.defineProperty,Rs=g((e,t)=>zs(e,"name",{value:t,configurable:!0}),"a$4");const qs=Rs(async(e,t,i)=>{if(e&&await S.isAccessible(f.join(e,"keystore.json"))){const n=await S.readJson(f.join(e,"keystore.json"));let o=await Y.readdir(e,{withFileTypes:!0});o=o.filter(s=>s.isDirectory());let a=i;for(const s of o)if(!n[s.name]){try{await Y.rm(f.join(e,s.name),{force:!0,recursive:!0})}catch(r){t.error({message:`Failed to remove cache directory ${s.name}: ${r instanceof Error?r.message:String(r)}`,prefix:"file-cache"});continue}a&&t.raw(` `),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),a=!1}}},"removeOldCacheFolders");var Js=Object.defineProperty,Bs=g((e,t)=>Js(e,"name",{value:t,configurable:!0}),"a$3");const Ws=Bs((e,t)=>e.some(i=>i instanceof RegExp?i.test(t):i===t),"arrayIncludes");var Ls=Object.defineProperty,Us=g((e,t)=>Ls(e,"name",{value:t,configurable:!0}),"a$2");const Ks=Us((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var Vs=Object.defineProperty,Hs=g((e,t)=>Vs(e,"name",{value:t,configurable:!0}),"o");const Gs=Hs(e=>{if(e.options.validation?.packageJson?.dependencies===!1)return;const t=new Set,i=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const o of e.usedImports)i.delete(o),t.add(o);if(e.pkg?.dependencies)for(const o of Object.keys(e.pkg?.dependencies))i.delete(o);for(const o of t){const a=Ks(o);!Ws(e.options.externals,o)&&!o.startsWith("chunks/")&&![...Ge.builtinModules,...Ge.builtinModules.map(s=>`node:${s}`)].includes(a)&&e.pkg?.dependencies?.[a]===void 0&&e.pkg?.peerDependencies?.[a]===void 0&&e.pkg.peerDependenciesMeta?.[a]?.optional!==!0&&n.add(o)}i.size>0&&D(e,`Potential unused dependencies found: ${[...i].map(o=>j.cyan(o)).join(", ")}`),n.size>0&&D(e,`Potential implicit dependencies found: ${[...n].map(o=>j.cyan(o)).join(", ")}`)},"validateDependencies");var Ys=Object.defineProperty,ei=g((e,t)=>Ys(e,"name",{value:t,configurable:!0}),"i$1");const Qs=ei((e,t)=>Di.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),Zs=ei((e,t)=>{const i=e.toLowerCase();return t.filter(n=>Qs(n.toLowerCase(),i))},"findAlternatives");var Xs=Object.defineProperty,gt=g((e,t)=>Xs(e,"name",{value:t,configurable:!0}),"r");const er=gt(e=>{const{options:t}=e;if(t.validation?.packageJson?.exports===!1)return;const i=t.validation?.packageJson,n=new Set([t.declaration&&i?.types?e.pkg.types:"",t.declaration&&i?.types?e.pkg.typings:"",...t.dtsOnly||i?.bin===!1?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:Object.values(e.pkg.bin??{}),t.dtsOnly&&i?.main===!1?"":e.pkg.main,t.dtsOnly&&i?.module===!1?"":e.pkg.module,...i?.exports===!1?[]:Ke(e.pkg.exports,e.pkg.type==="module"?"esm":"cjs",t.declaration).map(r=>t.dtsOnly?r.subKey==="types"?r.file:void 0:r.file)].filter(Boolean).map(r=>r&&f.resolve(t.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),o=[];for(const r of n)r&&!r.includes("*")&&!be.existsSync(r)&&o.push(r.replace(`${t.rootDir}/`,""));const a=gt(r=>f.relative(t.rootDir,f.resolve(t.outDir,r)),"rPath"),s=e.buildEntries.filter(r=>!r.chunk).map(r=>a(r.path));if(o.length>0){let r="Potential missing or wrong package.json files:";for(const p of o){const l=Zs(p,s);r+=` - `+j.cyan(p)+(l.length>0?j.grey` (did you mean ${l.map(c=>`"${c}"`).join(", ")}?)`:"")}D(e,r)}},"validatePackageEntries");var tr=Object.defineProperty,ir=g((e,t)=>tr(e,"name",{value:t,configurable:!0}),"l$1");const nr=ir(e=>{const{options:{validation:t},pkg:i}=e;i.name===void 0&&t?.packageJson?.name!==!1&&D(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t?.packageJson?.files!==!1&&(i.files===void 0?D(e,"The 'files' field is missing in your package.json. Add the files to be included in the package."):i.files.length===0?D(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):i.files.some(a=>a.includes(e.options.outDir))||D(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const n=i.type==="commonjs"||i.type===void 0,o=i.type==="module";if(n?(t?.packageJson?.main!==!1&&(i.main===void 0&&D(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),i.main?.includes(".mjs")&&D(e,"The 'main' field in your package.json should not use a '.mjs' extension for CommonJS modules.")),t?.packageJson?.module!==!1&&(i.module===void 0&&e.options.emitESM&&D(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),i.module&&i.main&&i.module===i.main&&D(e,`Conflict detected: The 'module' and 'main' fields both point to '${i.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&i.module?.includes(".cjs")&&D(e,"The 'module' field in your package.json should not use a '.cjs' extension for ES modules."))):o&&(i.exports===void 0&&!e.options.emitCJS?t?.packageJson?.exports!==!1&&D(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t?.packageJson?.main!==!1&&i.main===void 0&&D(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t?.packageJson?.module!==!1&&(i.module===void 0&&D(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),i.module?.includes(".cjs")&&D(e,"The 'module' field should not use a '.cjs' extension for ES modules."),i.module&&i.main&&i.module===i.main&&D(e,`Conflict detected: The 'module' and 'main' fields both point to '${i.module}'. Please ensure they refer to different module types.`)),t?.packageJson?.exports!==!1&&i.exports===void 0&&D(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),t?.packageJson?.bin!==!1){if(typeof i.bin=="string"&&i.bin.includes(n?".mjs":".cjs"))D(e,`The 'bin' field in your package.json should not use a ${n?".mjs":".cjs"} extension for ${n?"CommonJS":"ES modules"} binaries.`);else if(typeof i.bin=="object")for(const[a,s]of Object.entries(i.bin))s&&s.includes(n?".mjs":".cjs")&&D(e,`The 'bin.${a}' field in your package.json should not use a ${n?".mjs":".cjs"} extension for ${n?"CommonJS":"ES modules"} binaries.`)}if(e.options.declaration){let a=!0;i.type==="module"&&(a=!!i.main?.endsWith(".cjs")),i.types===void 0&&i.typings===void 0&&a&&t?.packageJson?.types!==!1&&D(e,"The 'types' field is missing in your package.json. This field should point to your type definitions file."),(e.options.declaration===!0||e.options.declaration==="compatible")&&a&&t?.packageJson?.typesVersions!==!1&&(i.typesVersions===void 0||Object.keys(i.typesVersions).length===0)&&D(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'.")}},"validatePackageFields");var or=Object.defineProperty,ar=g((e,t)=>or(e,"name",{value:t,configurable:!0}),"i");const sr=ar(e=>{const{packageJson:t}=Zt(e.options.rootDir);e.pkg=t,Gs(e),nr(e),er(e)},"validator");var rr=Object.defineProperty,lr=g((e,t)=>rr(e,"name",{value:t,configurable:!0}),"a");const pr=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,cr=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","var","void","volatile","while","with","yield"]),vt=lr(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,i]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(pr.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(cr.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=f.resolve(i);if(!S.isAccessibleSync(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var dr=Object.defineProperty,q=g((e,t)=>dr(e,"name",{value:t,configurable:!0}),"c");const ur=q(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),mr=q((e,t,i,n,o,a,s,r,p)=>{const l=ur(p?.config.compilerOptions?.jsx),c=ai.defu(a,o,s,{alias:{},browserTargets:Ni(),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:i===E.P,name:(r.name??"").split("/").pop()??"default",outDir:p?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},css:{autoModules:!0,extensions:[".css",".pcss",".postcss",".sss"],namedExports:!0},dts:{compilerOptions:{baseUrl:p?.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},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,exclude:E.c,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",jsx:l,jsxDev:p?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:p?.config.compilerOptions?.jsxFactory,jsxFragment:p?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:p?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:p?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:p?.config},isolatedDeclarations:{exclude:E.c,ignoreErrors:!1,include:E.A},json:{preferConst:!0},license:{dependenciesTemplate:q((u,d,m)=>` # Licenses of bundled dependencies The published ${m} artifact additionally contains code with the following licenses: `+(u.length>0?`${u.join(", ")} `:` `)+`# Bundled dependencies: `+d,"dependenciesTemplate"),dtsTemplate:q((u,d,m)=>` # Licenses of bundled types The published ${m} artifact additionally contains code with the following licenses: `+(u.length>0?`${u.join(", ")} `:` `)+`# Bundled types: `+d,"dtsTemplate")},node10Compatibility:{},patchTypes:{},polyfillNode:{},preserveDirectives:{include:E.A},preserveDynamicImports:!0,raw:{exclude:E.c,include:[/\.(md|txt|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:["module-sync"],extensions:E.D,preferBuiltins:!1},resolveExternals:{builtins:!0,builtinsPrefix:"add",deps:!0,devDeps:!1,exclude:[],optDeps:!0,peerDeps:!0},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:E.c,include:E.A},sourcemap:{},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:p?.config.compilerOptions?.esModuleInterop===!1,include:E.A,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:i===E.P,...p?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(p.config.compilerOptions.jsx)?{jsxFragmentPragma:p.config.compilerOptions.jsxFragmentFactory,jsxImportSource:p.config.compilerOptions.jsxImportSource,jsxPragma:p.config.compilerOptions.jsxFactory,jsxRuntime:l,transforms:["typescript","jsx",...p.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...p?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:E.A,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:p?.config.compilerOptions?.experimentalDecorators,syntax:p?"typescript":"ecmascript",[p?"tsx":"jsx"]:!0},target:p?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:p?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:p?.config.compilerOptions?.experimentalDecorators,react:{development:i!==E.P,pragma:p?.config.compilerOptions?.jsxFactory,pragmaFrag:p?.config.compilerOptions?.jsxFragmentFactory,runtime:l,throwIfNamespace:!0},treatConstEnumAsEnum:p?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:p?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Es(t,r),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:E.c}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,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:r.name??"unknown",pretty:!0,readme:"none",showConfig:n,tsconfig:p?.path}});if(!c.transformerName){const u=new Map([...Object.entries(r.dependencies??{}),...Object.entries(r.devDependencies??{})]);let d="0.0.0";if(u.has("esbuild"))c.transformerName="esbuild",d=u.get("esbuild");else if(u.has("@swc/core"))c.transformerName="swc",d=u.get("@swc/core");else if(u.has("sucrase"))c.transformerName="sucrase",d=u.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+j.cyan("rollup ")+pe.VERSION),e.info({message:"Using "+j.cyan(c.transformerName)+" "+d,prefix:"transformer"})}return c.rollup.resolve&&c.rollup.resolve.preferBuiltins===!0&&(c.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),c.browserTargets&&c.browserTargets.length>0&&e.debug("Using browser targets: "+c.browserTargets.join(", ")),vt(c.alias),c.rollup.alias&&c.rollup.alias.entries&&vt(c.rollup.alias.entries),c},"generateOptions"),fr=q(async(e,t,i,n,o,a,s,r,p,l)=>{const c=await as(s.preset??a.preset??"auto",l),u=mr(e,t,n,o,a,s,c,r,p);S.ensureDirSync(f.join(u.rootDir,u.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:si.createHooks(),jiti:ht.createJiti(u.rootDir,u.jiti),logger:e,mode:i,options:u,pkg:r,tsconfig:p,usedImports:new Set,warnings:new Set};c.hooks&&d.hooks.addHooks(c.hooks),a.hooks&&d.hooks.addHooks(a.hooks),s.hooks&&d.hooks.addHooks(s.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d.options.minify&&d.logger.info("Minification is enabled, the output will be minified");const m=r.dependencies?.typescript!==void 0||r.devDependencies?.typescript!==void 0;if(d.options.declaration&&d.tsconfig===void 0&&m)throw new Error("Cannot build declaration files without a tsconfig.json");return m?d.options.declaration===!1&&d.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(d.options.declaration=!1,d.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),d.options.declaration&&d.logger.info("Using typescript version: "+j.cyan(r.devDependencies?.typescript??r.dependencies?.typescript??"unknown")),d.options.declaration&&(r.dependencies?.typescript||r.devDependencies?.typescript)&&!d.tsconfig?.config.compilerOptions?.isolatedModules&&d.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig. 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. 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.`),await Ts(d),d},"createContext"),gr=q(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),vr=q(async(e,t,i,n,o={})=>{const{configPath:a,debug:s,tsconfigPath:r,...p}=o;n.wrapAll(),e=f.resolve(Me.cwd(),e),n.debug("Root directory:",e);const{packageJson:l,packageJsonPath:c}=Zt(e);n.debug("Using package.json found at",c);let u;if(r){const y=f.join(e,r);if(!await S.isAccessible(y))throw new Error("tsconfig.json not found at "+y);u={config:He.readTsConfig(y),path:y},n.info("Using tsconfig settings at",y)}else if(l.dependencies?.typescript||l.devDependencies?.typescript)try{u=await He.findTsConfig(e),n.debug("Using tsconfig settings found at",u.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}const d=ni.findCacheDirSync("@visulima/packem",{cwd:e});let m=!1,w,b;try{const y=await ks(e,a??""),h=ht.createJiti(e,{debug:s});let v=await h.import(y,{default:!0,try:!0})||{};typeof v=="function"&&(v=await v(i,t)),n.debug("Using packem config found at",f.join(e,y));const k=_.f(JSON.stringify({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,type:l.type,types:l.types}))+_.f(JSON.stringify(v));d&&bt.d(k,d,n);const $=new xs(e,d,k,n),x=await fr(n,e,t,i,s??!1,p,v,l,u,h);$.isEnabled=x.options.fileCache,x.logger.info(j.cyan(gr(t)+" "+x.options.name)),x.logger.debug({context:x.options.entries,message:`${j.bold("Root dir:")} ${x.options.rootDir} ${j.bold("Entries:")}`}),await vs(x);const N=q(async R=>{for await(const[V,P]of Object.entries(x.options.builder??{})){x.logger.raw(` `),await x.hooks.callHook("builder:before",V,x);const C=Date.now(),O=q(()=>L.duration(Math.floor(Date.now()-C)),"getBuilderDuration");await P(x,d,$,m),await x.hooks.callHook("builder:done",V,x),x.logger.raw(` ⚡️ `+V+" run in "+O()),R&&x.logger.raw(` `)}},"runBuilder"),A=q(async()=>{if(w!==void 0)await _s({pid:w.pid,signal:p.killSignal??v.killSignal??"SIGTERM"});else if(b!==void 0)try{await b()}catch(R){throw new Error("onSuccess function cleanup failed: "+R.message,{cause:R})}w=void 0,b=void 0},"doOnSuccessCleanup"),J=q(async()=>{if(typeof x.options.onSuccess=="function")try{b=await x.options.onSuccess()}catch(R){throw new Error("onSuccess function failed: "+R.message,{cause:R})}else if(typeof x.options.onSuccess=="string"){const R=x.options.onSuccessTimeout??3e4;if(w=ri.exec(x.options.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit",timeout:R}}),await w,w.exitCode&&w.exitCode!==0)throw new Error("onSuccess script failed with exit code "+w.exitCode+". Check the output above for details.")}},"runOnsuccess"),z=Date.now(),Z=q(()=>L.duration(Math.floor(Date.now()-z)),"getDuration");if(t==="watch"){if(x.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await ms(x,$,N,J,A),mt(x,!1);return}t==="jit"?(await ls(x),await x.hooks.callHook("build:done",x)):(m=await Ja(x,$),await x.hooks.callHook("validate:before",x),sr(x),await x.hooks.callHook("validate:done",x),mt(x,m)),x.logger.raw(` ⚡️ Build run in `+Z()),await N(),await J(),Me.on("SIGINT",async()=>{await A()}),Me.on("SIGTERM",async()=>{await A()})}catch(y){throw n.raw(` `),Ht(y),y}finally{n.restoreAll(),await qs(d,n,m)}},"packem");module.exports=vr;