@visulima/packem
Version:
A fast and modern bundler for Node.js and TypeScript.
61 lines (58 loc) • 141 kB
JavaScript
"use strict";var ri=Object.defineProperty;var v=(e,t)=>ri(e,"name",{value:t,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const li=require("@visulima/pail"),pi=require("@visulima/pail/reporter"),We=require("node:process"),E=require("@visulima/colorize"),ci=require("@visulima/find-cache-dir"),P=require("@visulima/fs"),M=require("@visulima/humanizer"),xt=require("@visulima/package"),m=require("@visulima/path"),di=require("browserslist"),ui=require("defu"),mi=require("hookable"),fi=require("jiti"),ce=require("rollup"),gi=require("tinyexec"),yt=require("@visulima/package/package-json"),Ke=require("@visulima/tsconfig"),vi=require("@visulima/fs/error"),Oe=require("@visulima/path/utils"),ye=require("tinyglobby"),D=require("./packem_shared/constants-CR0qfKZx.cjs"),te=require("mlly"),Y=require("node:fs/promises"),hi=require("magic-string"),z=require("./packem_shared/Mime-DDqfACcK.cjs"),xi=require("@rollup/plugin-alias"),yi=require("@rollup/plugin-commonjs"),bi=require("@rollup/plugin-dynamic-import-vars"),bt=require("@rollup/plugin-node-resolve"),wi=require("@rollup/plugin-replace"),ki=require("@rollup/plugin-wasm"),ji=require("rollup-plugin-polyfill-node"),$i=require("rollup-plugin-visualizer"),we=require("semver"),Ei=require("node:assert/strict"),L=require("@rollup/pluginutils"),Si=require("glob-parent"),wt=require("./packem_shared/index-C5qgsR90.cjs"),Oi=require("source-map-js"),Ie=require("./packem_shared/sourcemap-BtmVnsYw.cjs"),Ce=require("./packem_shared/ensure-auto-modules-Cs9762qZ.cjs"),Pi=require("oxc-parser"),Di=require("@rollup/plugin-json"),Ni=require("rollup-plugin-license"),kt=require("./packem_shared/create-or-update-key-storage-mzqiq3Nk.cjs"),_i=require("oxc-resolver"),oe=require("node:fs"),be=require("node:module"),Ci=require("node:url"),Fi=require("@visulima/source-map"),zi=require("@babel/parser"),Mi=require("node:crypto"),Ai=require("child_process"),Ii=require("fastest-levenshtein"),Ti=require("picomatch"),Te=require("node:zlib");var ee=typeof document<"u"?document.currentScript:null;const T=v(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),fe=T(We),Ri=T(di),G=T(hi),jt=T(xi),qi=T(yi),Ji=T(bi),$t=T(wi),Bi=T(ji),ke=T(Ei),Wi=T(Si),Li=T(Di),Ui=T(Ni),Ge=T(be),Vi=T(Mi),Hi=T(Ai),Ki=T(Ti);var Gi=Object.defineProperty,Yi=v((e,t)=>Gi(e,"name",{value:t,configurable:!0}),"e$8");const Et=Yi(e=>{const t=m.join(e,"package.json");if(!P.isAccessibleSync(t))throw new Error("package.json not found at "+t);return{packageJson:yt.parsePackageJson(t),packageJsonPath:t}},"loadPackageJson");var Qi=Object.defineProperty,Zi=v((e,t)=>Qi(e,"name",{value:t,configurable:!0}),"a$p");const Xi=Zi(async(e,t,i,o)=>{let n;if(o){const s=m.join(e,o);if(!await P.isAccessible(s))throw new Error("tsconfig.json not found at "+s);n={config:Ke.readTsConfig(s),path:s},i.info("Using tsconfig settings at",s)}else if(xt.hasPackageJsonAnyDependency(t,["typescript"]))try{n=await Ke.findTsConfig(e),i.debug("Using tsconfig settings found at",n.path)}catch{i.info("No tsconfig.json or jsconfig.json found.")}return n},"loadTsconfig");var eo=Object.defineProperty,St=v((e,t)=>eo(e,"name",{value:t,configurable:!0}),"r$e");const Ye=St(async(e,t)=>{if(typeof e.name!="string"){let i=m.isAbsolute(e.input)?m.relative(t.options.rootDir,e.input):m.normalize(e.input);i.startsWith("./")&&(i=i.slice(2)),e.name=i.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(D.E,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Oe.isRelative(e.input)&&(e.input=m.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=m.resolve(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),to=St(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:ye.isDynamicPattern(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:ye.isDynamicPattern(t.input)});for(const t of e.options.entries.filter(i=>i.isGlob)){const{isGlob:i,...o}=t,n=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")n.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const a of e.options.rollup.watch.exclude)typeof a=="string"&&n.push(a)}const s=ye.globSync([o.input],{cwd:e.options.rootDir,dot:!1,ignore:n,onlyFiles:!0});if(s.length===0)throw new vi.NotFoundError("No files found in the glob pattern: "+E.cyan(m.join(e.options.rootDir,o.input)));for(const a of s)e.options.entries.push({...o,input:m.resolve(e.options.rootDir,a)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for(const t of e.options.entries.filter(i=>i.fileAlias===void 0))await Ye(t,e);for(const t of e.options.entries.filter(i=>i.fileAlias!==void 0))t.name=t.fileAlias,t.fileAlias=void 0,await Ye(t,e)},"prepareEntries");var io=Object.defineProperty,Pe=v((e,t)=>io(e,"name",{value:t,configurable:!0}),"i$e");const je=/^#![^\n]*/,Re=Pe(async e=>{await Y.chmod(e,493).catch(()=>{})},"makeExecutable"),oo=Pe((e,t)=>({name:"packem:shebang",renderChunk:{handler(i,o,n){if(!o.isEntry||!o.facadeModuleId)return null;const s=i.startsWith("#")&&i[1]==="!";if(s&&t.replace)return i.replace(je,t.shebang+`
`);if(s)return null;if(e.includes(o.name)){const a=new G(i);return a.prepend(t.shebang+`
`),{code:a.toString(),map:n.sourcemap?a.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(i,o){for(const[n,s]of Object.entries(o))if(s.type==="chunk"&&je.test(s.code)&&i.dir){const a=m.resolve(i.dir,n);await Re(a)}}}),"shebangPlugin"),no=Pe(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(je,"")}}),"removeShebangPlugin"),ao=Pe((e,t=`
`)=>{const i=je.exec(e);return i?i+t:""},"getShebang");var so=Object.defineProperty,ro=v((e,t)=>so(e,"name",{value:t,configurable:!0}),"i$d");const De=ro((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(o=>[o.find,o.replacement]))):Object.assign(i,t.rollup.alias.entries??t.rollup.alias)),i},"resolveAliases");var lo=Object.defineProperty,po=v((e,t)=>lo(e,"name",{value:t,configurable:!0}),"r$d");const C=po((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var co=Object.defineProperty,uo=v((e,t)=>co(e,"name",{value:t,configurable:!0}),"j$4");const mo=uo(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,i=[],o=JSON.stringify({...e.options.jiti,alias:{...De(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((n,s)=>{if(Array.isArray(n)){const[a,...r]=n;return i.push(a),"["+["plugin"+s,...r.map(c=>JSON.stringify(c))].join(", ")+"]"}return i.push(n),"plugin"+s}).join(",")+"]":"[]");for(const n of e.options.entries){const s=m.resolve(e.options.rootDir,e.options.outDir,n.name),a=te.fileURLToPath(e.jiti.esmResolve(n.input,{try:!0})??n.input),r=a.replace(D.E,""),c=P.readFileSync(a),l=ao(c);let p=[];try{p=await te.resolveModuleExportNames(a,{extensions:D.D})}catch(d){C(e,`Cannot analyze ${a} for exports: ${d.toString()}`);return}const f=p.includes("default")||p.length===0;if(e.options.emitESM){const d=m.relative(m.dirname(s),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("index.cjs",document.baseURI).href})),u=r+".d.mts";P.writeFileSync(`${s}.mjs`,l+['import { createJiti } from "'+d+'";',...i.map((h,x)=>"import plugin"+x+' from "'+h+'";'),"","const jiti = createJiti(import.meta.url, "+o+");","",'/** @type {import("'+u+'")} */','const _module = await jiti.import("'+a+'");',f?`
export default _module?.default ?? _module;`:"",...p.filter(h=>h!=="default").map(h=>`export const ${h} = _module.${h};`)].join(`
`)),e.options.declaration&&P.writeFileSync(`${s}.d.mts`,'export * from "'+u+`";
`+(f?'export { default } from "'+u+'";':""))}if(e.options.emitCJS){const d=m.relative(m.dirname(s),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("index.cjs",document.baseURI).href})),u=r+".d.cts";P.writeFileSync(`${s}.cjs`,l+['const { createJiti } = require("'+d+'");',...i.map((h,x)=>"const plugin"+x+" = require("+JSON.stringify(h)+")"),"","const jiti = createJiti(__filename, "+o+");","",'/** @type {import("'+u+'")} */','module.exports = jiti("'+a+'")'].join(`
`)),e.options.declaration&&P.writeFileSync(s+".d.cts",'export * from "'+u+`";
`+(f?'export { default } from "'+u+'";':""))}l&&(await Re(`${s}.cjs`),await Re(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var fo=Object.defineProperty,Le=v((e,t)=>fo(e,"name",{value:t,configurable:!0}),"i$b");const go=Le(e=>{const{message:t,name:i="Error",stack:o}=e;if(!o)return;const n=`${i}: ${t}
`;return o.startsWith(n)?o.slice(n.length):o},"extractStack"),vo=Le(e=>`
${e.replaceAll(/^\n|\n$/g,"")}
`,"normalizeCodeFrame"),Ot=Le(e=>{const t=go(e);let i=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(i+=`
file: ${E.cyan(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(i+=`
`+E.yellow(vo(e.frame))),e.message=i,t!==void 0&&(e.stack=`${e.message}
${t}`)},"enhanceRollupError");var ho=Object.defineProperty,xo=v((e,t)=>ho(e,"name",{value:t,configurable:!0}),"a$n");const $e=xo(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var yo=Object.defineProperty,Pt=v((e,t)=>yo(e,"name",{value:t,configurable:!0}),"s$e");const bo=Pt((e,t,i)=>{const o=i??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),a=o.get(s);if(a!==void 0)return a;const r=e(...n);return o.set(s,r),r}},"memoize"),wo=Pt(e=>{const t=new Map;return i=>bo(e,i,t)},"memoizeByKey");var ko=Object.defineProperty,de=v((e,t)=>ko(e,"name",{value:t,configurable:!0}),"r$c");const jo=de(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;ke(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 L.extractAssignedNames(t.id))yield i;break}}},"exportName"),$o=de(function*(e){if(e.declaration)for(const t of jo(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"),Eo=de(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),So=de(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),Oo=de(function*(e,t){ke(t.code!=null,`Module ${t.id} doesn't have associated code`);const i=e.parse(t.code);for(const o of i.body)switch(o.type){case"ExportAllDeclaration":{yield*Eo(o);break}case"ExportDefaultDeclaration":{yield*So();break}case"ExportNamedDeclaration":{yield*$o(o);break}}},"parseExports");var Po=Object.defineProperty,ue=v((e,t)=>Po(e,"name",{value:t,configurable:!0}),"n$9");const Dt=ue(async function(e,t,i){const o=await e.resolve(t,i.id);if(ke(o,`Rollup can't resolve ${t} from ${i.id}`),o.external)return null;const n=await e.load(o);return ke(n,`Rollup doesn't have a module for id ${o.id}`),n},"getImportedModule"),Do=ue(async function*(e,t,i){const o=await Dt(e,t.source,i);o&&(yield*Ue(e,o))},"gatherBarrelReExports"),No=ue(async function*(e,t,i){const o=await Dt(e,t.source,i);if(!o)return;const n=new Map(t.bindings.map(s=>[s.importedName,s]));for await(const s of Ue(e,o)){const a=n.get(s.exportedName);a&&(yield{...s,exportedName:a.exportedName})}},"gatherNamedReExports"),_o=ue(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),Ue=ue(async function*(e,t){for(const i of Oo(e,t))i.from==="self"?yield*_o(t,i):i.type==="barrel"?yield*Do(e,i,t):yield*No(e,i,t)},"gatherExports");var Co=Object.defineProperty,Fo=v((e,t)=>Co(e,"name",{value:t,configurable:!0}),"r$b");const zo=Fo(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of Ue(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 Mo=Object.defineProperty,Ao=v((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"r$a");const Io=Ao((e,t)=>{const i=e,o=[];let n;for(;(n=i.exec(t))!==null;)n.index===i.lastIndex&&i.lastIndex++,n.forEach(s=>{o.push(s)});return o.filter(Boolean)},"getRegexMatches");var To=Object.defineProperty,Ro=v((e,t)=>To(e,"name",{value:t,configurable:!0}),"a$m");const Nt=Ro(e=>{const t=Io(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const i=t.at(-1).split(", ");let o="";for(const n of i)if(!n.includes("type")&&(n.includes("default ")&&(o=n.split("default ")[1]),n.includes("as"))){const[s,a]=n.split(" as ");a==="default"&&(o=s)}if(o!==""){const n=new G(e);return n.replace(new RegExp(`(,s)?${o} as default(,)?`),""),n.replace(new RegExp(`export default ${o};
?`),""),n.append(`
export = `+o+";"),{code:n.toString().replace(/export\s\{\s\s\};/,""),map:n.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var qo=Object.defineProperty,Qe=v((e,t)=>qo(e,"name",{value:t,configurable:!0}),"i$9");const _t=Qe(({addDefaultProperty:e=!1,logger:t,type:i})=>({name:"packem:cjs-interop",renderChunk:Qe(async(o,n,s)=>{if(n.type!=="chunk"||!n.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const a=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(o);if(a===null||a.length<3)return null;const r=new G(o);r.replace("",""),r.replaceAll(/exports\.(.*) = (.*);/g,"module.module.exports.$1 = $2;"),e&&r.append(`
module.module.exports = `+a[2]+";");let c=r.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:r.generateMap({hires:!0})}}return s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)?i!=="commonjs"&&n.fileName.endsWith(".d.mts")?null:Nt(o):null},"renderChunk")}),"cjsInteropPlugin");var Jo=Object.defineProperty,Bo=v((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"f$d");const Wo=Bo((e,t)=>{const i=new Map,o={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=o;return Array.isArray(n)?n=n.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const s=await Promise.all(n.flatMap(a=>Array.isArray(a.src)?a.src.map(r=>({...a,src:r})):a).map(async a=>await ye.glob($e(a.src),{ignore:$e(a.exclude).filter(Boolean)}).then(r=>({dest:a.dest??"",parent:Wi(a.src),src:r}))));for(const a of s)for(const r of a.src){let c;i.has(r)?c=i.get(r):(c={copied:[],dest:[],timestamp:0},i.set(r,c));const l=o.flatten?m.normalize(a.dest):m.join(a.dest,m.relative(a.parent,m.dirname(r)));c.dest.includes(l)||c.dest.push(l),this.addWatchFile(r)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...i].map(async([a,r])=>{let c;try{const l=await Y.stat(a);if(!l.isFile())return;const p=l.mtime.getTime();p>r.timestamp&&(r.timestamp=p,r.copied=[]),c=await P.readFile(a,{buffer:!0})}catch(l){t.error({context:[l],message:`error reading file ${a}`,prefix:"plugin:copy"});return}for(const l of r.dest){if(o.copyOnce&&r.copied.includes(l))continue;const p=m.basename(a),f=m.join(l,p);try{this.emitFile({[o.exactFileNames?"fileName":"name"]:f,source:c,type:"asset"}),t.debug({message:`copied ${a} → ${f}`,prefix:"plugin:copy"}),r.copied.push(l)}catch(d){t.error({context:[d],message:`error copying file ${a} → ${f}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Lo=Object.defineProperty,Uo=v((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"r$9");const Ze=Uo((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 Vo=Object.defineProperty,Ho=v((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"a$l");const Ko=4,Go=process.env.UV_THREADPOOL_SIZE?Number.parseInt(process.env.UV_THREADPOOL_SIZE,10):Ko;let Yo=class{static{v(this,"f")}static{Ho(this,"LoaderManager")}test;loaders=new Map;options;workQueue;logger;constructor({extensions:t,loaders:i,logger:o,options:n}){this.test=s=>t.some(a=>s.toLowerCase().endsWith(a)),i.length>0&&this.add(...i),this.options=n,this.logger=o}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(Ze(t,i.test))return!0;return!1}async process(t,i){this.workQueue||(this.workQueue=new wt.d({concurrency:Go-1}));for await(const[o,n]of this.loaders){const s={...i,options:this.options[o]??{}};if(n.alwaysProcess||Ze(s.id,n.test)){this.logger.debug(`Processing ${o} loader for ${s.id}`);const a=await this.workQueue.add(n.process.bind(s,t));a&&(t=a)}}return t}};var Qo=Object.defineProperty,Zo=v((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"u$a");const Xo=Zo(async e=>{const t=new Oi.SourceMapGenerator({file:""}),i=[];let o=0;for await(const{css:n,map:s}of e){i.push(n);const a=Ie.m(s),r=a.toObject();if(!r)continue;const c=a.toConsumer();if(c){if(c.eachMapping(l=>{t.addMapping({generated:{column:l.generatedColumn,line:o+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,c.sourceContentFor(l,!0));o+=n.split(`
`).length}}return{css:i.join(`
`),map:t}},"concat");var en=Object.defineProperty,se=v((e,t)=>en(e,"name",{value:t,configurable:!0}),"b$3");const tn=se(async(e,t)=>e.sort((i,o)=>t.indexOf(i.name)-t.indexOf(o.name)),"sortByNameOrder"),on=se(async(e,t,i,o,n,s,a,r,c,l)=>{const p={...l,...e.alias},f=L.createFilter(e.include,e.exclude),d=z.i(e.sourceMap),u={...z.a(e.mode),autoModules:e.autoModules??!1,dts:e.dts,extensions:e.extensions,namedExports:e.namedExports};typeof u.inject=="object"&&u.inject.treeshakeable&&(u.namedExports=!1,t.info({message:"Disabling named exports due to `inject.treeshakeable` option",prefix:"css"}));let h=!1;if(e.loaders)for(const y of e.loaders)y.name==="postcss"&&(h=!0);else e.loaders=[];h&&(u.postcss={...e.postcss,config:z.c(e.postcss?.config,{}),import:z.b(e.postcss?.import,p),modules:z.c(e.postcss?.modules,void 0),to:e.postcss?.to,url:z.b(e.postcss?.url,p)},e.postcss?.parser&&(u.postcss.parser=await z.e(e.postcss.parser,"parser",o)),e.postcss?.syntax&&(u.postcss.syntax=await z.e(e.postcss.syntax,"syntax",o)),e.postcss?.stringifier&&(u.postcss.stringifier=await z.e(e.postcss.stringifier,"stringifier",o)),e.postcss?.plugins&&(u.postcss.plugins=await z.d(e.postcss.plugins,o)));const x=new Yo({extensions:u.extensions,loaders:await tn(e.loaders,["sourcemap","stylus","less","sass","postcss"]),logger:t,options:{...e,...u,alias:p}});let j=[];const g=se((y,k)=>{const b=[];for(const w of Object.keys(y)){const $=new Set;let S=[w];do{const _=[];for(const F of S){if($.has(F))continue;if(x.isSupported(F)){f(F)&&_.push(F);continue}$.add(F);const U=k(F);U&&_.push(...U.importedIds)}S=_}while(S.some(_=>!x.isSupported(_)));b.push(...S)}return b},"traverseImportedModules");return{augmentChunkHash(y){if(j.length===0)return null;const k=g(y.modules,this.getModuleInfo),b=j.filter(w=>k.includes(w.id)).sort((w,$)=>k.lastIndexOf(w.id)-k.lastIndexOf($.id)).map(w=>`${m.basename(w.id)}:${w.css}`);return b.length===0?null:b.join(":")},async generateBundle(y,k){if(j.length===0||!(y.dir||y.file))return;const b=Object.values(k),w=y.dir??m.dirname(y.file),$=b.filter(N=>N.type==="chunk"),S=$.filter(N=>!N.facadeModuleId),_=y.preserveModules?$:$.filter(N=>N.isEntry||N.isDynamicEntry),F=[],U=se(async(N,A)=>{const O=typeof u.extract=="string"?m.normalize(u.extract).replace(/^\.[/\\]/,""):m.normalize(`${N}.css`);m.isAbsolute(O)&&this.error(["Extraction path must be relative to the output directory,",`which is ${m.relative(o,w)}`].join(`
`)),Oe.isRelative(O)&&this.error(["Extraction path must be nested inside output directory,",`which is ${m.relative(o,w)}`].join(`
`));const B=j.filter(W=>A.includes(W.id)).sort((W,X)=>A.lastIndexOf(W.id)-A.lastIndexOf(X.id)),me=await Xo(B);return{css:me.css,map:Ie.m(me.map.toString()).relative(m.dirname(m.resolve(w,O))).toString(),name:O}},"getExtractedData"),V=se(N=>{if(y.file)return m.parse(y.file).name;if(y.preserveModules){const{dir:A,name:O}=m.parse(N.fileName);return A?m.join(A,O):O}return N.name},"getName"),Z=[];if(typeof u.extract=="string"){t.debug({message:`Extracting to ${u.extract}`,prefix:"css"});const N=[];for(const O of S){const B=g(O.modules,this.getModuleInfo);Z.push(...B),N.push(...B)}for(const O of _)N.push(...g(O.modules,this.getModuleInfo).filter(B=>!Z.includes(B)));const A=V($[0]);F.push([A,N])}else{t.debug({message:"Extracting to individual files",prefix:"css"});for(const N of S){const A=g(N.modules,this.getModuleInfo);if(A.length===0)continue;Z.push(...A);const O=V(N);F.push([O,A])}for(const N of _){const A=g(N.modules,this.getModuleInfo).filter(B=>!Z.includes(B));if(A.length===0)continue;const O=V(N);F.push([O,A])}}for await(const[N,A]of F){const O=await U(N,A);if(typeof e.onExtract=="function"&&!e.onExtract(O))continue;if(c&&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"},me=this.emitFile(B);if(O.map&&d){const W=this.getFileName(me),X=typeof y.assetFileNames=="string"?m.normalize(m.dirname(y.assetFileNames)):typeof y.assetFileNames=="function"?m.normalize(m.dirname(y.assetFileNames(B))):"assets",ne=Ie.m(O.map).modify(I=>(I.file=m.basename(W),I)).modifySources(I=>{if(I==="<no source>"||X.length<=1)return I;I=`../${I}`;for(const _e of X)_e==="/"&&(I=`../${I}`);return I});if(d.inline)ne.modify(I=>d.transform?.(I,m.normalize(m.join(w,W)))),k[W].source+=ne.toCommentData();else{const I=`${W}.map`;ne.modify(si=>d.transform?.(si,m.normalize(m.join(w,I)))),this.emitFile({fileName:I,source:ne.toString(),type:"asset"});const{base:_e}=m.parse(I);k[W].source+=ne.toCommentFile(_e)}}}},name:"packem:css",async transform(y,k){if(!f(k)||!x.isSupported(k)||y.replaceAll(/\s/g,"")==="")return null;typeof e.onImport=="function"&&e.onImport(y,k);const b={alias:p,assets:new Map,autoModules:u.autoModules,browserTargets:i,cwd:o,debug:r,deps:new Set,dts:u.dts,emit:u.emit,environment:s,extensions:u.extensions,extract:u.extract,id:k,inject:u.inject,logger:t,namedExports:u.namedExports,options:{},plugin:this,sourceDir:n,sourceMap:d,useSourcemap:a,warn:this.warn.bind(this)},w=await x.process({code:y},b);for(const $ of b.deps)this.addWatchFile($);for(const[$,S]of b.assets)this.emitFile({fileName:$,source:S,type:"asset"});if(w.extracted){const{id:$}=w.extracted;j=j.filter(S=>S.id!==$),j.push(w.extracted)}return{code:w.code,map:d&&w.map?w.map:{mappings:""},meta:{styles:w.meta},moduleSideEffects:w.extracted?!0:null}}}},"default");var nn=Object.defineProperty,an=v((e,t)=>nn(e,"name",{value:t,configurable:!0}),"u$9");const sn=`
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
/**
* Generated by packem
* @see https://npmjs.com/@visulima/packem
*/
`.trim(),rn=an((e,t,i)=>{let o;return e.postcss&&typeof e.postcss.modules=="boolean"?o=e.postcss.modules:e.lightningcss&&typeof e.lightningcss.modules=="boolean"&&(o=e.lightningcss.modules),{async transform(n,s){let a=o;if(e.postcss&&typeof e.postcss.modules=="object"?a=Ce.n(e.postcss.modules.include,s):e.lightningcss&&typeof e.lightningcss.modules=="object"&&(a=Ce.n(e.lightningcss.modules.include,s)),e.autoModules&&a===void 0&&(a=Ce.n(e.autoModules,s)),!a)return null;const{types:r}=this.getModuleInfo(s)?.meta.styles??{};return r===void 0||await P.isAccessible(s)&&(await P.writeFile(s+".d.ts",`${sn}
${r}`),i.info({message:`Generated types for ${m.normalize(s).replace(t+"/","")}`,prefix:"dts:css-modules"}),this.addWatchFile(s+".d.ts")),null}}},"cssModulesTypes");var ln=Object.defineProperty,pn=v((e,t)=>ln(e,"name",{value:t,configurable:!0}),"r$8");const cn=new Set(["es","chrome","edge","firefox","ios","node","safari","opera","ie"]),dn=["android 4"],un={android:"chrome",ios_saf:"ios"},mn=" ",ge=pn(e=>{let t=e.filter(i=>!dn.some(o=>i.startsWith(o))).map(i=>i.split(mn)).map(([i,o])=>[un[i]||i,o]).map(([i,o])=>[i,o.includes("-")?o.slice(0,o.indexOf("-")):o]).map(([i,o])=>[i,o.endsWith(".0")?o.slice(0,-2):o]).filter(([,i])=>/^\d+(\.\d+)*$/.test(i)).filter(([i])=>cn.has(i));return t=Object.entries(Object.fromEntries(t)),t.map(([i,o])=>`${i}${o}`)},"browserslistToEsbuild");var fn=Object.defineProperty,Ne=v((e,t)=>fn(e,"name",{value:t,configurable:!0}),"t$7");const gn=/(?:^|[^.\w'"`])require(\.resolve)?\(\s*([\w'"`])/,vn=Ne((e,t)=>{if(We.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,o=!1,n=!1;if(e.includes("__filename")&&(i=!0),e.includes("__dirname")&&(o=!0),gn.test(e)&&(n=!0),!i&&!o&&!n)return null;const s=te.findStaticImports(e).pop(),a=s?s.end:0,r=new G(e);return r.appendRight(a,t(i,o,n)),{code:r.toString(),map:r.generateMap()}},"CJSToESM"),hn=Ne((e,t,i)=>{let o="";return(e||t)&&(o+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
`),t&&(o+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
`),i&&(o+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
`),(e||t)&&(o+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
`),t&&(o+=`const __dirname = __cjs_path__.dirname(__filename);
`),i&&(o+=`const require = __cjs_mod__.createRequire(import.meta.url);
`),o},"generateCJSShim"),xn=Ne((e,t,i)=>{let o="";return i&&(o+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
`),e&&(o+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
`),t&&(o+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
`),i&&(o+=`const require = __cjs_mod__.createRequire(import.meta.url);
`),o},"generateCJSShimNode20_11"),yn=Ne((e,t)=>{const i=L.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(o,n,s){if(s.format==="es"&&i(n.fileName)){let a=hn;if(e.engines?.node){const r=we.minVersion(e.engines.node);r&&r.major>=20&&r.minor>=11&&(a=xn)}return vn(o,a)}return null}}},"esmShimCjsSyntaxPlugin");var bn=Object.defineProperty,wn=v((e,t)=>bn(e,"name",{value:t,configurable:!0}),"m$a");const kn=wn(()=>({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 jn=Object.defineProperty,$n=v((e,t)=>jn(e,"name",{value:t,configurable:!0}),"e$6");const Xe=/^([\w-]+):/,et=$n(e=>{if(!e||typeof e!="string")throw new Error("Invalid key: Key must be a non-empty string.");const t=[],i=Xe.exec(e);i&&(t.push(i[1]),e=e.replace(Xe,""));const o=e.split("/");for(const n of o)(n.includes("*")||n)&&t.push(n);return t},"splitTsconfigPathKey");var En=Object.defineProperty,Sn=v((e,t)=>En(e,"name",{value:t,configurable:!0}),"h$2");const On=Sn((e,t)=>{const i=e.replace(/^\.\//,""),o=t.replace(/^\.\//,"");if(o.startsWith(i))return e+o.slice(i.length);if(e.endsWith(t))return e;const n=et(e),s=et(t);let a=n.length-1,r=s.length-1;for(;a>=0&&r>=0&&n[a]===s[r];)a--,r--;let c=n.slice(0,a).join("/");const l=s.slice(r).join("/");return(!c.startsWith(".")||c==="")&&(c="./"+c),c+(l?"/"+l:"")},"extendString");var Pn=Object.defineProperty,Dn=v((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"s$b");const Nn=Dn((...e)=>{if(e.length===0)return"";if(e.length===1)return m.dirname(e[0]);e=e.map(n=>m.toNamespacedPath(n).split(m.sep).join("/"));const[t,...i]=e;let o=t.split("/");for(const n of i){const s=n.split("/",o.length);let a=0;for(const r of s)if(r===o[a])a+=1;else{o=o.slice(0,a);break}o=o.slice(0,a)}return(o.length<=1&&o[0]===""?`/${o[0]}`:o.join("/")).split("/").join(m.sep)},"lowestCommonAncestor");var _n=Object.defineProperty,pe=v((e,t)=>_n(e,"name",{value:t,configurable:!0}),"d$9");const tt=pe((e,t)=>`${e}
//# sourceMappingURL=${m.basename(t)}.map
`,"appendMapUrl"),it=pe((e,t,i)=>JSON.stringify({file:m.basename(i),mappings:e,names:[],sourceRoot:"",sources:[m.relative(m.dirname(i),t)],version:3}),"generateDtsMap"),Cn=pe((e,t,i,o,n,s,a,r)=>{const c=L.createFilter(s.include,s.exclude);let l=Object.create(null);const p=pe((u,h)=>{l[u.replace(D.E,"")]={...h,ext:m.extname(u)}},"addOutput");let f=[];r?.config.compilerOptions&&(f=Object.entries(r.config.compilerOptions.paths??{}).map(([u])=>u.endsWith("*")?new RegExp(`^${u.replace("*","(.*)")}$`):new RegExp(`^${u}$`)));async function d(u,h){if(!c(h))return;let x;try{x=(await Pi.parseAsync(h,u)).program}catch(b){n.debug({message:b.message,prefix:"packem:isolated-declarations"})}if(x){const b=x.body.filter(w=>(w.type==="ImportDeclaration"||w.type==="ExportAllDeclaration"||w.type==="ExportNamedDeclaration")&&!!w.source);for await(const w of b){if(m.basename(w.source.value).includes("."))continue;const $=await this.resolve(w.source.value,h);if(!(!$||$.external)&&($.id.endsWith(".ts")||$.id.endsWith(".cts")||$.id.endsWith(".mts")||$.id.endsWith(".tsx")||$.id.endsWith(".ctsx")||$.id.endsWith(".mtsx"))){const S=$.id.replace(e+"/","");let _=w.source.value;f.some(F=>F.test(w.source.value))&&!w.source.value.startsWith(".")&&(_="./"+w.source.value),u=u.replaceAll('from "'+w.source.value+'"','from "'+On(_,S)+'"')}}}const{errors:j,map:g,sourceText:y}=await t(h,u,a,r?.config?.compilerOptions);if(j.length>0){if(s.ignoreErrors){this.warn(j[0]);return}return this.error(j[0])}if(p(h,{map:g,source:y}),!x)return;const k=x.body.filter(b=>b.type==="ImportDeclaration"?b.importKind==="type"?!0:b.specifiers?.every(w=>w.type==="ImportSpecifier"&&w.importKind==="type"):b.type==="ExportNamedDeclaration"||b.type==="ExportAllDeclaration"?b.exportKind==="type"?!0:b.type==="ExportNamedDeclaration"&&b.specifiers?.every(w=>w.type==="ExportSpecifier"&&w.exportKind==="type"):!1);for await(const b of k){if(!b.source)continue;const w=await this.resolve(b.source.value,h);if(!w)return;const $=w.id;if(c($)&&!l[$.replace(D.E,"")])try{const S=await P.readFile($);await d.call(this,S,$)}catch{}}}return v(d,"F"),pe(d,"transform"),{buildStart(){l=Object.create(null)},name:"packem:isolated-declarations",async renderStart(u,{input:h}){const x=Nn(...Array.isArray(h)?h:Object.values(h));n.debug({message:"Input base:"+x,prefix:"packem:isolated-declarations"}),typeof u.entryFileNames=="function"&&(u.entryFileNames=u.entryFileNames({name:u.name}));const j=u.entryFileNames.replace(/\.(.)?[jt]sx?$/,(g,y)=>`.d.${y||""}ts`);for await(let[g,{ext:y,map:k,source:b}]of Object.entries(l)){if(o&&u.format==="cjs"){const _=Nt(b);_!==null&&(b=_.code)}const w=b.includes("from '")?"'":'"',$=g+y;if((i===!0||i==="compatible")&&u.format==="cjs"){n.debug({message:"Emit compatible dts file: "+g,prefix:"packem:isolated-declarations"});const _=j.replace("[name]",m.toNamespacedPath(g).replace(e+"/","")).replace(".cts",".ts");let F=b;a&&k&&(F=tt(F.trim(),_),this.emitFile({fileName:`${_}.map`,originalFileName:$,source:it(k,$,m.join(u.dir,_)),type:"asset"})),this.emitFile({fileName:_,originalFileName:$,source:F.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(U,V,Z,N)=>V+w+(N||Z)+".d.ts"+w+";"),type:"asset"})}n.debug({message:"Emit dts file: "+g,prefix:"packem:isolated-declarations"});const S=j.replace("[name]",m.toNamespacedPath(g).replace(e+"/",""));a&&k&&(b=tt(b.trim(),S),this.emitFile({fileName:`${S}.map`,originalFileName:$,source:it(k,$,m.join(u.dir,S)),type:"asset"})),this.emitFile({fileName:S,originalFileName:$,source:b.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(_,F,U,V)=>F+w+(V||U)+(u.format==="cjs"?".d.cts":".d.mts")+w+";"),type:"asset"})}},transform:d}},"isolatedDeclarationsPlugin");var Fn=Object.defineProperty,zn=v((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"n$6");const ot="export default ",Ct=zn(e=>{const t=Li(e);return{...t,name:"packem:json",transform(i,o){const n=t.transform?.call(this,i,o);return n&&typeof n!="string"&&"code"in n&&n.code?.startsWith(ot)&&(n.code=n.code.replace(ot,"module.exports = ")),n}}},"JSONPlugin");var Mn=Object.defineProperty,ve=v((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"i$6");class Ft{static{v(this,"WalkerBase")}static{ve(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:ve(()=>this.should_skip=!0,"skip"),remove:ve(()=>this.should_remove=!0,"remove"),replace:ve(t=>this.replacement=t,"replace")}}replace(t,i,o,n){t&&i&&(o!=null?t[i][o]=n:t[i]=n)}remove(t,i,o){t&&i&&(o!=null?t[i].splice(o,1):delete t[i])}}var An=Object.defineProperty,re=v((e,t)=>An(e,"name",{value:t,configurable:!0}),"c$e");class In extends Ft{static{v(this,"SyncWalker")}static{re(this,"SyncWalker")}constructor(t,i){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:re(()=>this.should_skip=!0,"skip"),remove:re(()=>this.should_remove=!0,"remove"),replace:re(o=>this.replacement=o,"replace")},this.enter=t,this.leave=i}visit(t,i,o,n){if(t){if(this.enter){const a=this.should_skip,r=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,i,o,n),this.replacement&&(t=this.replacement,this.replace(i,o,n,t)),this.should_remove&&this.remove(i,o,n);const l=this.should_skip,p=this.should_remove;if(this.should_skip=a,this.should_remove=r,this.replacement=c,l)return t;if(p)return null}let s;for(s in t){const a=t[s];if(a&&typeof a=="object")if(Array.isArray(a)){const r=a;for(let c=0;c<r.length;c+=1){const l=r[c];qe(l)&&(this.visit(l,t,s,c)||c--)}}else qe(a)&&this.visit(a,t,s,null)}if(this.leave){const a=this.replacement,r=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,i,o,n),this.replacement&&(t=this.replacement,this.replace(i,o,n,t)),this.should_remove&&this.remove(i,o,n);const c=this.should_remove;if(this.replacement=a,this.should_remove=r,c)return null}}return t}}function qe(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}v(qe,"n$5");re(qe,"isNode");var Tn=Object.defineProperty,le=v((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"c$d");class Rn extends Ft{static{v(this,"AsyncWalker")}static{le(this,"AsyncWalker")}constructor(t,i){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:le(()=>this.should_skip=!0,"skip"),remove:le(()=>this.should_remove=!0,"remove"),replace:le(o=>this.replacement=o,"replace")},this.enter=t,this.leave=i}async visit(t,i,o,n){if(t){if(this.enter){const a=this.should_skip,r=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,await this.enter.call(this.context,t,i,o,n),this.replacement&&(t=this.replacement,this.replace(i,o,n,t)),this.should_remove&&this.remove(i,o,n);const l=this.should_skip,p=this.should_remove;if(this.should_skip=a,this.should_remove=r,this.replacement=c,l)return t;if(p)return null}let s;for(s in t){const a=t[s];if(a&&typeof a=="object")if(Array.isArray(a)){const r=a;for(let c=0;c<r.length;c+=1){const l=r[c];Je(l)&&(await this.visit(l,t,s,c)||c--)}}else Je(a)&&await this.visit(a,t,s,null)}if(this.leave){const a=this.replacement,r=this.should_remove;this.replacement=null,this.should_remove=!1,await this.leave.call(this.context,t,i,o,n),this.replacement&&(t=this.replacement,this.replace(i,o,n,t)),this.should_remove&&this.remove(i,o,n);const c=this.should_remove;if(this.replacement=a,this.should_remove=r,c)return null}}return t}}function Je(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}v(Je,"a$h");le(Je,"isNode");var qn=Object.defineProperty,zt=v((e,t)=>qn(e,"name",{value:t,configurable:!0}),"a$g");function Ve(e,{enter:t,leave:i}){return new In(t,i).visit(e,null)}v(Ve,"walk");zt(Ve,"walk");async function Jn(e,{enter:t,leave:i}){return await new Rn(t,i).visit(e,null)}v(Jn,"asyncWalk");zt(Jn,"asyncWalk");var Bn=Object.defineProperty,Wn=v((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"u$7");const Ln=Wn(({attributes:e,logger:t})=>{const i=L.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(o,n){if(!i(n))return null;let s=null;try{s=this.parse(o,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(c),null}let a=!1;const r=new G(o);return Ve(s,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const l=c.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of l)for(const f of p.properties)f.type==="Property"&&f.key.type==="Literal"&&f.value.type==="Literal"&&e.includes(f.key.value)&&(r.overwrite(f.start-2,f.end,""),a=!0)}}}),a?{code:r.toString(),map:r.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Un=Object.defineProperty,Mt=v((e,t)=>Un(e,"name",{value:t,configurable:!0}),"d$8");const Vn=Mt(e=>{const t=[],i=[];return e.forEach(o=>{o.startsWith("(")?t.push(o):i.push(o)}),[...i.sort(),...t.sort()]},"sortLicenses"),At=Mt(({dtsMarker:e,licenseFilePath:t,licenseTemplate:i,logger:o,marker:n,mode:s,packageName:a})=>Ui({thirdParty(r){const c=new Set,l=r.sort(({name:f},{name:d})=>(f||0)>(d||0)?1:(d||0)>(f||0)?-1:0).map(({author:f,contributors:d,license:u,licenseText:h,maintainers:x,name:j,repository:g})=>{let y="## "+j+`
`;u&&(y+=`License: ${u}
`);const k=new Set;for(const b of[f,...x,...d]){const w=typeof b=="string"?b:b?.name;w&&k.add(w)}return k.size>0&&(y+=`By: ${[...k].join(", ")}
`),g&&(y+=`Repository: ${typeof g=="string"?g:g.url}
`),h&&(y+=`
`+h.trim().replaceAll(/\r\n|\r/g,`
`).replaceAll(`<!-- ${n} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").replaceAll(`<!-- /${n} -->`,"").replaceAll(e?`<!-- /${e} -->`:"","").trim().split(`
`).map(b=>b?`> ${b}`:">").join(`
`)+`
`),u&&c.add(u),y}).join(`
---------------------------------------
`);if(l===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+s});return}const p=i(Vn(c),l,a);try{const f=P.readFileSync(t),d=kt.g(f,n,p);if(!d){o.error({message:`Could not find the license marker: <!-- ${n} --><!-- /${n} --> in ${t}`,prefix:"plugin:license:"+s});return}f!==d&&(P.writeFileSync(t,d),o.info({message:`${t} updated.`,prefix:"plugin:license:"+s}))}catch(f){o.error(f)}}}),"license");var Hn=Object.defineProperty,Kn=v((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"u$6");const Gn=Kn(()=>({async generateBundle(e,t){const i=[];for(const n of this.getModuleIds()){const s=this.getModuleInfo(n);if(s!=null&&!s.isExternal)for(const a of s.importedIds)i.push({source:n,target:a})}if(Array.isArray(i)&&i.length===0)return;const o=Object.keys(t);this.emitFile({fileName:`metafile-${o[0].replace(D.E,"")}-${e.format}.json`,source:JSON.stringify(i,null,2),type:"asset"})},name:"packem:metafile"}),"metafilePlugin");var Yn=Object.defineProperty,Fe=v((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"i$5");let nt;const Qn=new Map,It=Fe((e,t,i,o)=>{const{ignoreSideEffectsForRoot:n,...s}=e;let a=nt;return a||(a=nt=new _i.ResolverFactory({...s,roots:[...s.roots??[],t],tsconfig:o?{configFile:o,references:"auto"}:void 0})),{name:"oxc-resolve",resolveId:{async handler(r,c,{isEntry:l}){const p=l||!c?m.dirname(r):m.dirname(c),{error:f,path:d}=await a.async(p,r);if(f)return i.debug(f,{context:[{basedir:t,extensions:s.extensions,id:d}]}),null;let u=Fe(x=>!1,"hasModuleSideEffects");try{const{packageJson:x,path:j}=await yt.findPackageJson(m.dirname(d),{cache:Qn}),g=m.dirname(j);if(!n||t!==g){const y=x.sideEffects;if(typeof y=="boolean")u=Fe(()=>y,"hasModuleSideEffects");else if(Array.isArray(y)){const k=y.map(b=>b.includes("/")?b:`**/${b}`);u=L.createFilter(k,null,{resolve:g})}}}catch(x){console.debug(x.message,{context:[{basedir:p,caller:"Resolver",error:x,extensions:s.extensions,id:d}]})}const h=await this.resolve(d,c,{skipSelf:!0});return h?h.external?!1:h.id!==d?h:{id:d,meta:h.meta,moduleSideEffects:u(d)}:null},order:"post"}}},"oxcResolvePlugin");var Zn=Object.defineProperty,Tt=v((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"d$7");const ae=Tt(e=>e.handler||e,"getHandler"),q=Tt((e,t,i="")=>({...e,async buildEnd(o){e.buildEnd&&await ae(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await ae(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=m.join(i,e.name),s=m.join("load",z.f(o));if(t.has(s,n))return await t.get(s,n);const a=await ae(e.load).call(this,o);return t.set(s,a,n),a},name:`cached(${e.name})`,async resolveId(o,n,s){if(!e.resolveId)return null;const a=m.join(i,e.name),r=m.join("resolveId",z.f(o),n?z.f(n):"",z.f(JSON.stringify(s)));if(t.has(r,a))return await t.get(r,a);const c=await ae(e.resolveId).call(this,o,n,s);return t.set(r,c,a),c},async transform(o,n){if(!e.transform)return null;const s=m.join(i,e.name),a=m.join("transform",z.f(n),z.f(o));if(t.has(a,s))return await t.get(a,s);const r=await ae(e.transform).call(this,o,n);return t.set(a,r,s),r}}),"cachingPlugin");var Xn=Object.defineProperty,ea=v((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"c$b");const ta=ea(({directiveRegex:e,exclude:t=[],include:i=[],logger:o})=>{const n={},s={},a=L.createFilter(i,t);return{name:"packem:preserve-directives",onLog(r,c){return c.code==="MODULE_LEVEL_DIRECTIVE"&&r==="warn"?!1:null},renderChunk:{handler(r,c,{sourcemap:l}){const p=c.moduleIds.map(u=>n[u]?n[u]:null).reduce((u,h)=>(h&&h.forEach(x=>{u.add(x)}),u),new Set),f=new G(r);p.size>0&&(o.debug({message:`directives for chunk "${c.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),f.prepend(`${[...p].map(u=>`'${u}';`).join(`
`)}
`));let d;return c.facadeModuleId&&typeof s[c.facadeModuleId]=="string"&&(d=s[c.facadeModuleId]),d&&(o.debug({message:`shebang for chunk "${c.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),f.prepend(`${d}
`)),p.size===0&&d===void 0?null:{code:f.toString(),map:l?f.generateMap({hires:!0}):null}},order:"post"},transform(r,c){if(!a(c))return null;let l=!1;const p=new G(r);if(r.startsWith("#")&&r[1]==="!"){let d=0;for(let u=2,h=r.length;u<h;u++){const x=r.codePointAt(u);if(x===10||x===13||x===8232||x===8233){d=u;break}}d&&(s[c]=r.slice(0,d),p.remove(0,d+1),l=!0,o.debug({message:`shebang for module "${c}" is preserved.`,prefix:"plugin:preserve-directives"}))}let f=null;try{f=this.parse(p.toString(),{allowReturnOutsideFunction:!0})}catch(d){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${c}" and extract the directives.`}),o.warn(d),null}if(f.type!=="Program")return null;for(const d of f.body.filter(Boolean)){if(d.type!=="ExpressionStatement")break;let u=null;"directive"in d?u=d.directive:d.expression.type==="Literal"&&typeof d.expression.value=="string"&&e.test(d.expression.value)&&(u=d.expression.value),u!=="use strict"&&u&&(n[c]||=new Set,n[c].add(u),"start"in d&&typeof d.start=="number"&&"end"in d&&typeof d.end=="number"&&(p.remove(d.start,d.end),l=!0),o.debug({message:`directive "${u}" for module "${c}" is preserved.`,prefix:"plugin:preserve-directives"}))}return l?{code:p.toString(),map:p.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...n[c]??[]],shebang:s[c]??null}}}:null}}},"preserveDirectives");var ia=Object.defineProperty,oa=v((e,t)=>ia(e,"name",{value:t,configurable:!0}),"n$4");const na=oa(e=>{const t=L.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,o){return!t(o)&&!o.includes("?raw")?null:(o.includes("?raw")||(i=`export default ${JSON.stringify(i)}`),{code:i,map:{mappings:""}})}}},"rawPlugin");var aa=Object.defineProperty,ie=v((e,t)=>aa(e,"name",{value:t,configurable:!0}),"p$5");const at=ie((e,t,i)=>e.reduce((o,n,s)=>(n instanceof RegExp?o.push(n):typeof n=="string"&&n.length>0?o.push(new RegExp("^"+n.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&")+"$")):i.warn(`Ignoring wrong entry type #${s} in '${t}' option: ${JSON.stringify(n)}`),o),[]),"getRegExps"),st=new Map,sa=ie((e,t)=>{st.has(e)||t.info({message:'Inlined implicit external "'+E.cyan(e)+'". If this is incorrect, add it to the "externals" option.',prefix:"plugin:packem:resolve-externals"}),st.set(e,!0)},"logExternalMessage"),rt=new Set(["node:test","node:sqlite"]),Rt=ie((e,t,i,o,n)=>{const s=new Map,a=new Map,r=new Set(at([...i.externals],"include",o)),c=new Set(at([...n.exclude??[]],"exclude",o)),l={};Object.assign(l,n.deps?e.dependencies:void 0,n.devDeps?e.devDependencies:void 0,n.peerDeps?e.peerDependencies:void 0,n.optDeps?e.optionalDependencies:void 0);const p=Object.keys(l);if(p.length>0&&r.add(new RegExp("^(?:"+p.join("|")+")(?:/.+)?$")),e.peerDependenciesMeta)for(const[x,j]of Object.entries(e.peerDependenciesMeta))j?.optional&&r.add(new RegExp(`^${x}(?:/.+)?$`));const f=ie(x=>[...r].some(j=>j.test(x)),"isIncluded"),d=ie(x=>[...c].some(j=>j.test(x)),"isExcluded");let u=[];t&&(u=Object.entries(t.config.compilerOptions?.paths??{}).map(([x])=>x.endsWith("*")?new RegExp(`^${x.replace("*","(.*)")}$`):new RegExp(`^${x}$`)));const h=De(e,i);return{name:"packem:resolve-externals",options:ie(x=>{x.external=(j,g)=>{if(a.has(j))return a.get(j);let y;Object.keys(h).length>0&&(y=Oe.resolveAlias(j,h),y===j&&(y=void 0));for(const k of[j,y].filter(Boolean)){if(/^(?:\0|\.{1,2}\/)/.test(k)||m.isAbsolute(k)||new RegExp(`${i.sourceDir}[/.*|\\.*]`).test(k)||e.name&&k.startsWith(e.name))return a.set(k,!1),!1;if(be.isBuiltin(k)||rt.has(k)){let b=n.builtins;return b===void 0&&g&&(b=f(g)&&!d(g)),a.set(k,b),b}if(k[0]==="#"&&e.imports)for(const[b,w]of Object.entries(e.imports)){if(b[0]!=="#"){o.debug({message:'Ignoring package.json import "'+E.cyan(b)+'" because it does not start with "#".',prefix:"plugin:packem:resolve-externals"});continue}if(b===k)return a.set(k,!1),!1;if(b.includes("*")){let $;s.has(b)?$=s.get(b):($=oe.readdirSync(m.join(i.rootDir,w.replace("/*","")),{withFileTypes:!0}).filter(S=>S.isFile()).map(S=>S.name),s.set(b,$));for(const S of $)if(S.replace(D.E,"")===k.replace(D.E,"").replace("#",""))return a.set(k,!1),!1}}if(u.length>0){for(const b of u)if(b.test(k))return a.set(k,!1),!1}if(f(k)&&!d(k))return a.set(k,!0),!0}return sa(j,o),!1}},"options"),resolveId:{async handler(x,j,{isEntry:g}){if(g)return null;if(rt.has(x))return{external:!0,id:x,moduleSideEffects:!1};if(be.isBuiltin(x)){const y=x.replace(/^node:/,"");return{external:(n.builtins||f(x))&&!d(x),id:n.builtinsPrefix==="ignore"?x:n.builtinsPrefix==="add"||!be.isBuiltin(y)?"node:"+y:y,moduleSideEffects:!1}}return null},order:"pre"}}},"resolveExternalsPlugin");var ra=Object.defineProperty,la=v((e,t)=>ra(e,"name",{value:t,configurable:!0}),"r$6");const qt=la(()=>({name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return Ci.fileURLToPath(e)}}),"resolveFileUrl");var pa=Object.defineProperty,ca=v((e,t)=>pa(e,"name",{value:t,configurable:!0}),"l$8");const da=ca(({exclude:e,include:t}={})=>{const i=L.createFilter(t,e);return{async load(o){if(!i(o))return null;let n;try{n=await P.readFile(o,{buffer:!1}),this.addWatchFile(o)}catch{try{const a=o.replace(/\?.*$/,"");n=await P.readFile(a,{buffer:!1}),this.addWatchFile(a)}catch{return this.warn("Failed reading file"),null}}let s;try{const a=Fi.loadSourceMap(o);if(a===void 0)return n;s=a}catch{return this.warn("Failed resolving source map"),{code:n}}return{code:n,map:s}},name:"packem:sourcemaps"}},"sourcemapsPlugin");var ua=Object.defineProperty,Q=v((e,t)=>ua(e,"name",{value:t,configurable:!0}),"r$5");const ma=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,fa=/MIT License|MIT license|BSD license/,ga=/\n{2,}/g,va=/\b(\w+)\$\d+\b/g,ha=/[-/\\^$*+?.()|[\]{}]/g,xa=Q(e=>e.replaceAll(ha,"\\$&"),"escapeRegex"),ya=Q(e=>[...new Set(e)],"unique"),ba=Q(e=>e.replaceAll(ma,t=>fa.test(t)?"":t).replaceAll(ga,`
`),"cleanUnnecessaryComments"),lt=new Map;function Jt(e,t,{identifierReplacements:i},o){const n=te.findStaticImports(e);for(const a in i){const r=n.find(l=>l.specifier===a&&l.imports.includes("{"));if(!r){this.warn(`${t.fileName} does not import "${a}" for replacement`),process.exitCode=1;continue}const c=i[a];for(const l in c){if(!r.imports.includes(l))throw new Error(`${t.fileName} does not import "${l}" from "${a}" for replacement`);const p=c[l],f=xa(l);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${f},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${f}\\b`,"g"),p)}}const s=ya(Array.from(e.matchAll(va),a=>a[0]));if(s.length>0){const a=s.map(c=>