@visulima/packem
Version:
A fast and modern bundler for Node.js and TypeScript.
20 lines (19 loc) • 24.7 kB
JavaScript
;var $e=Object.defineProperty;var d=(e,t)=>$e(e,"name",{value:t,configurable:!0});const be=require("node:url"),we=require("@csstools/postcss-slow-plugins"),H=require("@rollup/pluginutils"),h=require("@visulima/path"),je=require("postcss"),D=require("../../../../../packem_shared/resolve-DSG4Zlek.cjs"),P=require("../../../../../packem_shared/Mime-DTB1xJuS.cjs"),S=require("../../../../../packem_shared/sourcemap-BtmVnsYw.cjs"),Z=require("../../../../../packem_shared/ensure-auto-modules-Cs9762qZ.cjs"),F=require("icss-utils"),V=require("@visulima/fs"),Se=require("@visulima/path/utils"),v=require("@csstools/css-parser-algorithms"),x=require("@csstools/css-tokenizer"),K=require("@visulima/package"),Oe=require("postcss-load-config"),xe=require("postcss-modules-extract-imports"),Pe=require("postcss-modules-local-by-default"),ke=require("postcss-modules-scope"),Ne=require("postcss-modules-values"),Re=require("postcss-value-parser");var W=typeof document<"u"?document.currentScript:null;const k=d(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),Ie=k(we),Ce=k(je),Ue=k(Oe),_e=k(xe),Ee=k(Pe),Le=k(ke),De=k(Ne),z=k(Re);var Te=Object.defineProperty,qe=d((e,t)=>Te(e,"name",{value:t,configurable:!0}),"e$3");const Fe=qe((e,...t)=>{const s=P.f([e,"0iOXBLSx",...t].join(":")).slice(0,8);return H.makeLegalIdentifier(`${e}_${s}`)},"default");var We=Object.defineProperty,Me=d((e,t)=>We(e,"name",{value:t,configurable:!0}),"i$4");const Ae=Me(async(e,t,s,o,n)=>{const r=D.r([e,`./${e}`],{baseDirs:[h.dirname(t)],caller:"ICSS loader",extensions:s}),i=await V.readFile(r),{messages:u}=await o.process(i,{...n,from:r}),l={};for(const c of u)c.type==="icss"&&Object.assign(l,c.export);return l},"load");var Be=Object.defineProperty,ze=d((e,t)=>Be(e,"name",{value:t,configurable:!0}),"t$3");const Je=ze(async(e,t,s,o,n,r)=>{const i={};for await(const[u,l]of Object.entries(e)){const c=await t(u,s,o,n,r);for(const[a,f]of Object.entries(l))i[a]=c[f]}return i},"resolve");var Ge=Object.defineProperty,Xe=d((e,t)=>Ge(e,"name",{value:t,configurable:!0}),"c$4");const M="styles-icss",He=[".css",".pcss",".postcss",".sss"],re=Xe(e=>{const t=e?.load??Ae,s=e?.extensions??He;return{async OnceExit(o,{result:n}){if(!o.source?.input.file)return;const r={...n.opts,map:void 0},{icssExports:i,icssImports:u}=F.extractICSS(o),l=await Je(u,t,o.source.input.file,s,n.processor,r);F.replaceSymbols(o,l);for(const[c,a]of Object.entries(i))n.messages.push({export:{[c]:F.replaceValueSymbols(a,l)},plugin:M,type:"icss"});for(const c of Object.keys(u))n.messages.push({import:c,plugin:M,type:"icss-dependency"})},postcssPlugin:M}},"plugin");re.postcss=!0;var Ve=Object.defineProperty,Qe=d((e,t)=>Ve(e,"name",{value:t,configurable:!0}),"t$2");const J=Qe((e,t,s,o)=>{const n=[];if(e!==void 0){let r="layer";e&&(r=`layer(${e})`),n.push(r)}return s!==void 0&&n.push(`supports(${s})`),o!==void 0&&n.push(`scope(${o})`),t!==void 0&&n.push(t),n.join(" ")},"formatImportPrelude");var Ye=Object.defineProperty,Ze=d((e,t)=>Ye(e,"name",{value:t,configurable:!0}),"p$4");const Ke=Ze((e,t)=>{t.reverse();const s=t.pop();if(!s)return e;let o=`${e} ${J(s.layer,s.media,s.supports,s.scope)}`;for(const n of t)o=`'data:text/css;base64,${Buffer.from(`@import ${o}`).toString("base64")}' ${J(n.layer,n.media,n.supports,n.scope)}`;return o},"base64EncodedConditionalImport");var et=Object.defineProperty,T=d((e,t)=>et(e,"name",{value:t,configurable:!0}),"e$2");const tt=T(e=>e.type==="warning","isWarning"),G=T(e=>e.type==="nodes","isNodesStatement"),L=T(e=>e.type==="import","isImportStatement"),st=T(e=>e.type==="pre-import","isPreImportStatement");var rt=Object.defineProperty,nt=d((e,t)=>rt(e,"name",{value:t,configurable:!0}),"u$1");const ot=nt((e,t)=>{e.statements.forEach((s,o)=>{if(tt(s)||st(s)||s.conditions.length===0)return;if(L(s)){s.node.params=Ke(s.fullUri,s.conditions);return}const{nodes:n}=s;if(n.length===0)return;const{parent:r}=n[0];if(!r)return;const i=[];for(const c of s.conditions){if(c.media!==void 0){const a=t({name:"media",params:c.media,source:s.importingNode?.source??r.source});i.push(a)}if(c.scope!==void 0){const a=t({name:"scope",params:c.scope,source:s.importingNode?.source??r.source});i.push(a)}if(c.supports!==void 0){const a=t({name:"supports",params:`(${c.supports})`,source:s.importingNode?.source??r.source});i.push(a)}if(c.layer!==void 0){const a=t({name:"layer",params:c.layer,source:s.importingNode?.source??r.source});i.push(a)}}const u=i[0];if(!u)return;for(let c=0;c<i.length-1;c++)i[c].append(i[c+1]);const l=i.at(-1);r.insertBefore(n[0],u),n.forEach(c=>{c.parent=void 0}),l.append(n),e.statements[o]={conditions:s.conditions,from:s.from,importingNode:s.importingNode,nodes:[u],type:"nodes"}})},"applyConditions");var it=Object.defineProperty,at=d((e,t)=>it(e,"name",{value:t,configurable:!0}),"r$4");const ct=at(e=>{e.statements.forEach((t,s)=>{if(s!==0)if(t.parent!==void 0){const{before:o}=t.parent.node.raws;G(t)?t.nodes[0].raws.before=o:t.node.raws.before=o}else G(t)&&(t.nodes[0].raws.before=t.nodes[0].raws.before??`
`)})},"applyRaws");var ut=Object.defineProperty,lt=d((e,t)=>ut(e,"name",{value:t,configurable:!0}),"t$1");const pt=lt((e,t)=>{t.nodes=[],e.charset&&(e.charset.parent=void 0,t.append(e.charset)),e.statements.forEach(s=>{L(s)?(s.node.parent=void 0,t.append(s.node)):G(s)&&s.nodes.forEach(o=>{o.parent=void 0,t.append(o)})})},"applyStyles");var ft=Object.defineProperty,dt=d((e,t)=>ft(e,"name",{value:t,configurable:!0}),"o$3");const mt=dt((e,t,s)=>{const o={baseDirs:[t],caller:"@import resolver",extensions:s},n=new URL(e,"file://").pathname,r=[n];return(Se.isRelative(n)||n.startsWith("/"))&&r.push(`.${n}`),n.startsWith("/")&&r.push(n.slice(1)),D.r(r,o)},"importResolve");var ht=Object.defineProperty,ne=d((e,t)=>ht(e,"name",{value:t,configurable:!0}),"e$1");const gt=/^data:text\/css(?:;(?:base64|plain))?,/i,yt=/^data:text\/css;base64,/i,vt=/^data:text\/css;plain,/i,X=ne(e=>e!==void 0&>.test(e),"isValidDataURL"),$t=ne(e=>yt.test(e)?Buffer.from(e.slice(21),"base64").toString():vt.test(e)?decodeURIComponent(e.slice(20)):decodeURIComponent(e.slice(14)),"dataURLContents");var bt=Object.defineProperty,wt=d((e,t)=>bt(e,"name",{value:t,configurable:!0}),"o$1");const jt="css-noop",Q=wt(()=>({postcssPlugin:jt}),"noopPlugin");Q.postcss=!0;var St=Object.defineProperty,oe=d((e,t)=>St(e,"name",{value:t,configurable:!0}),"a$3");const ie=oe(async(e,t,s,o,n,r)=>(r===void 0&&(r=0),o.length===0&&o.push(Q()),await e(o).process(t,{from:s,parser:n[r]}).catch(async i=>{if(r++,r===n.length)throw i;return await ie(e,t,s,o,n,r)})),"runPostcss"),Ot=oe(async(e,t,s,o,n)=>{const{plugins:r}=o,i=[];return e.opts.syntax?.parse&&i.push(e.opts.syntax.parse),e.opts.parser&&i.push(e.opts.parser),i.push(void 0),await ie(n,t,s,r,i)},"processContent"),xt=/^charset$/i,ae=/^import$/i,Pt=/^url$/i,E=/^layer$/i,kt=/^supports$/i,Nt=/^scope$/i;var Rt=Object.defineProperty,Y=d((e,t)=>Rt(e,"name",{value:t,configurable:!0}),"a$2");const It=Y(e=>{for(let t=0;t<e.length;t++){const s=e[t];if(!v.isWhiteSpaceOrCommentNode(s)&&v.isSimpleBlockNode(s)&&x.isTokenOpenParen(s.startToken))return e}return[new v.SimpleBlockNode([x.TokenType.OpenParen,"(",-1,-1,void 0],[x.TokenType.CloseParen,")",-1,-1,void 0],e)]},"wrapInParenthesisIfNeeded"),ee=Y(e=>{if(e.startsWith("#"))return"";if(!e.includes("#"))return e;try{const t=new URL(e,"http://example.com");return t.hash?e.slice(0,e.length-t.hash.length):e}catch{return e}},"stripHash"),Ct=Y(e=>{const t=x.tokenize({css:e});if(t.length===2&&(x.isTokenString(t[0])||x.isTokenURL(t[0]))){let c=t[0][4].value;return c=ee(c),c?{fullUri:t[0][1],uri:c}:!1}const s=v.parseListOfComponentValues(t);let o="",n="",r,i,u,l;for(let c=0;c<s.length;c++){const a=s[c];if(!v.isWhiteSpaceOrCommentNode(a)){if(v.isTokenNode(a)&&(x.isTokenString(a.value)||x.isTokenURL(a.value))){if(o)return!1;o=a.value[4].value,n=a.value[1];continue}if(v.isFunctionNode(a)&&Pt.test(a.getName())){if(o)return!1;for(let f=0;f<a.value.length;f++){const p=a.value[f];if(!v.isWhiteSpaceOrCommentNode(p)){if(!o&&v.isTokenNode(p)&&x.isTokenString(p.value)){o=p.value[4].value,n=v.stringify([[a]]);continue}return!1}}continue}if(!o)return!1;if(v.isTokenNode(a)&&x.isTokenIdent(a.value)&&E.test(a.value[4].value)){if(r!==void 0||u!==void 0)return!1;r="";continue}if(v.isFunctionNode(a)&&E.test(a.getName())){if(r!==void 0||u!==void 0)return!1;r=v.stringify([a.value]);continue}if(v.isFunctionNode(a)&&kt.test(a.getName())){if(u!==void 0)return!1;u=v.stringify([a.value]);continue}if(v.isFunctionNode(a)&&Nt.test(a.getName())){if(l!==void 0)return!1;l=v.stringify([It(a.value)]);continue}i=v.stringify([s.slice(c)]);break}}return o=ee(o),o?{fullUri:n,layer:r,media:i,scope:l,supports:u,uri:o}:!1},"parseAtImport");var Ut=Object.defineProperty,C=d((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"l");const ce=C((e,t,s,o)=>{const n=[];let r=t;const i=e.length;for(r;r<i;r++){const u=e[r];if(n.push(u),e[r+1]?.type!=="comment")break}return[r,{conditions:[],from:o,importingNode:s,nodes:n,type:"nodes"}]},"consumeComments"),_t=C((e,t,s,o,n)=>{const r=Ct(t.params);if(!r)return e.warn(`Invalid @import statement in '${t.toString()}'`,{node:t});const i={conditions:[...o],from:n,fullUri:r.fullUri,importingNode:s,node:t,type:"import",uri:r.uri};return(r.layer!==void 0||r.media!==void 0||r.supports!==void 0||r.scope!==void 0)&&i.conditions.push({layer:r.layer,media:r.media,scope:r.scope,supports:r.supports}),i},"parseImport"),Et=C((e,t,s,o,n,r)=>{const i=[];let u=o;const l=t.length;for(u;u<l;u++){const c=t[u];if(c.type==="comment"){const[a,f]=ce(t,u,n,r);i.push(f),u=a;continue}if(c.type==="atrule"&&ae.test(c.name)){i.push(_t(e,c,n,s,r));continue}break}return[u-1,i]},"consumeImports"),Lt=C((e,t,s,o,n)=>{const r=[];let i=s;const u=e.length;for(i;i<u;i++){const l=e[i];r.push(l);const c=e[i+1];if(!(c&&c.type==="atrule"&&E.test(c.name)&&!c.nodes))break}return[i,{conditions:[...t],from:n,importingNode:o,nodes:r,type:"nodes"}]},"consumeLayers"),Dt=C((e,t,s,o,n)=>{const r=[];let i=s;const u=e.length;for(i;i<u;i++){const l=e[i];if(l.type==="comment"){const[c,a]=ce(e,i,o,n);r.push(a),i=c;continue}if(l.type==="atrule"&&E.test(l.name)&&!l.nodes)if(t.length>0){r.push({conditions:[...t],from:n,importingNode:o,node:l,type:"pre-import"});continue}else{const[c,a]=Lt(e,t,i,o,n);r.push(a),i=c;continue}break}return[i-1,r]},"consumeBeforeImports"),ue=C((e,t,s,o,n)=>{const r={statements:[]};if(t.type==="document")return t.each(f=>{const p=ue(e,f,s,o,n);if(r.charset&&p.charset&&r.charset.params.toLowerCase()!==p.charset.params.toLowerCase())throw p.charset.error(`Incompatible @charset statements:
${p.charset.params} specified in ${p.charset.source?.input.file}
${r.charset.params} specified in ${r.charset.source?.input.file}`);!r.charset&&p.charset&&(r.charset=p.charset),r.statements.push(...p.statements)}),r;let i,u=[],l=[],c;for(let f=0;f<t.nodes.length;f++){const p=t.nodes[f];if(f===0&&p.type==="atrule"&&xt.test(p.name)){i=p;continue}if(l.length===0&&(p.type==="comment"||p.type==="atrule"&&E.test(p.name)&&!p.nodes)){[f,u]=Dt(t.nodes,o,f,s,n);continue}if(l.length===0&&p.type==="atrule"&&ae.test(p.name)){[f,l]=Et(e,t.nodes,o,f,s,n);continue}c={conditions:[...o],from:n,importingNode:s,nodes:t.nodes.slice(f),type:"nodes"};break}const a=[];return u.length>0&&a.push(...u),l.length>0&&a.push(...l),c&&a.push(c),{charset:i,statements:a}},"parseStylesheet");var Tt=Object.defineProperty,q=d((e,t)=>Tt(e,"name",{value:t,configurable:!0}),"h");const qt=/^(?:[a-z]+:)?\/\//i,Ft=q(e=>{if(qt.test(e))return!1;try{if(new URL(e,"https://example.com").search)return!1}catch{}return!0},"isProcessableURL"),te=q(async(e,t,s,o,n,r)=>{const{conditions:i,from:u,node:l}=t,c=i.map(g=>J(g.layer,g.media,g.supports,g.scope)).join(":");if(o.skipDuplicates){if(n.importedFiles[s]?.[c])return{statements:[]};n.importedFiles[s]||(n.importedFiles[s]={}),n.importedFiles[s][c]=!0}if(u.includes(s))return{statements:[]};const a=await o.load(s,o);if(a.trim()===""&&o.warnOnEmpty)return e.warn(`${s} is empty`,{node:l}),{statements:[]};if(o.skipDuplicates&&n.hashFiles[a]?.[c])return{statements:[]};const f=await Ot(e,a,s,o,r),p=f.root;return o.debug&&p.append({text:s}),e.messages=[...e.messages,...f.messages],o.skipDuplicates&&(p.some(g=>g.type==="atrule"&&g.name==="import")||(n.hashFiles[a]||(n.hashFiles[a]={}),n.hashFiles[a][c]=!0)),await le(o,e,p,n,l,i,[...u,s],r)},"loadImportContent"),Wt=q(async(e,t,s,o,n)=>{if(X(s.uri)){s.stylesheet=await te(t,s,s.uri,e,o,n);return}if(X(s.from.at(-1))){s.stylesheet={statements:[]},t.warn(`Unable to import '${s.uri}' from a stylesheet that is embedded in a data url`,{node:s.node});return}const r=s.node;let i;r.source?.input.file&&(i=r.source.input.file);const u=i?h.dirname(i):e.root;for(const[c,a]of Object.entries(e.alias))s.uri!==c&&!s.uri.startsWith(`${c}/`)||(s.uri=h.normalize(a)+s.uri.slice(c.length));let l;try{l=await e.resolve(s.uri,u,e.extensions,r)}catch{s.node.warn(t,`Unable to resolve "${s.uri}" from "${u}"`);return}t.messages.push({file:l,parent:i,plugin:"packem-postcss-import",type:"dependency"}),s.stylesheet=await te(t,s,l,e,o,n)},"resolveImportId"),le=q(async(e,t,s,o,n,r,i,u)=>{let{charset:l,statements:c}=ue(t,s,n,r,i);{const a=[];for await(const f of c)!L(f)||!Ft(f.uri)||e.filter&&!e.filter(f.uri)||a.push(Wt(e,t,f,o,u));a.length>0&&await Promise.all(a)}for(let a=0;a<c.length;a++){const f=c[a];if(L(f)&&f.stylesheet){if(l&&f.stylesheet.charset&&l.params.toLowerCase()!==f.stylesheet.charset.params.toLowerCase())throw f.stylesheet.charset.error(`Incompatible @charset statements:
${f.stylesheet.charset.params} specified in ${f.stylesheet.charset.source?.input.file}
${l.params} specified in ${l.source?.input.file}`);!l&&f.stylesheet.charset&&(l=f.stylesheet.charset),c.splice(a,1,...f.stylesheet.statements),a--}}return{charset:l,statements:c}},"parseStyles");var Mt=Object.defineProperty,At=d((e,t)=>Mt(e,"name",{value:t,configurable:!0}),"r$2");const Bt=At(e=>X(e)?$t(e):V.readFileSync(e),"loadContent");var zt=Object.defineProperty,Jt=d((e,t)=>zt(e,"name",{value:t,configurable:!0}),"i");const Gt="css-import",Xt=[".css",".pcss",".postcss",".sss"],pe=Jt(e=>{const t={alias:e?.alias??{},extensions:e?.extensions??Xt,load:Bt,plugins:[],resolve:e?.resolve??mt,skipDuplicates:!1,...e};return{async Once(s,{atRule:o,postcss:n,result:r}){const i={hashFiles:{},importedFiles:{}};if(s.source?.input.file&&(i.importedFiles[s.source.input.file]={}),!Array.isArray(t.plugins))throw new TypeError("plugins option must be an array");const u=await le(t,r,s,i,void 0,[],[],n);ct(u),ot(u,o),pt(u,s)},postcssPlugin:Gt}},"plugin");pe.postcss=!0;var Ht=Object.defineProperty,Vt=d((e,t)=>Ht(e,"name",{value:t,configurable:!0}),"p$1");let A;const Qt=Vt(async(e,t,s,o)=>{if(!o)return{file:"",options:{},plugins:[]};const{dir:n}=h.parse(e),r=o.path?h.resolve(o.path):n;let i;try{i=(await K.findMonorepoRoot(t)).path}catch{try{i=await K.findPackageRoot(t)}catch{}}try{let u;A?u=A:(u=await Ue({cwd:t,env:s,...o.ctx},r,{stopDir:i}),A=u);const l={file:u.file,options:u.options,plugins:await P.d(u.plugins,t)};return l.options.parser&&(l.options.parser=await P.e(l.options.parser,"parser",t)),l.options.syntax&&(l.options.syntax=await P.e(l.options.syntax,"syntax",t)),l.options.stringifier&&(l.options.stringifier=await P.e(l.options.stringifier,"stringifier",t)),l}catch(u){if(u.message.includes("No PostCSS Config found in"))return{file:"",options:{},plugins:[]};throw u}},"loadConfig");var Yt=Object.defineProperty,Zt=d((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"n$2");const Kt=Zt((e="[name]_[local]_[hash:8]")=>(t,s,o)=>{const{base:n,dir:r,name:i}=h.parse(s),u=P.f(`${n}:${o}`),l=S.H.exec(e),c=l&&Number.parseInt(l[1],10);return H.makeLegalIdentifier(e.replace("[dir]",h.basename(r)).replace("[name]",i.replace(/\.module$/,"")).replace("[local]",t).replace(S.H,c?u.slice(0,c):u))},"generate");var es=Object.defineProperty,ts=d((e,t)=>es(e,"name",{value:t,configurable:!0}),"r$1");const ss=ts(e=>{const t={mode:"local",...e,generateScopedName:typeof e.generateScopedName=="function"?e.generateScopedName:Kt(e.generateScopedName)};return[De(),Ee({mode:t.mode}),_e({failOnWrongOrder:t.failOnWrongOrder}),Le({exportGlobals:t.exportGlobals,generateScopedName:t.generateScopedName})]},"default");var rs=Object.defineProperty,ns=d((e,t)=>rs(e,"name",{value:t,configurable:!0}),"c$2");const os=ns((e,t,s)=>{const{base:o,dir:n,ext:r,name:i}=h.parse(t),u=P.f(`${o}:${Buffer.from(s).toString()}`),l=S.H.exec(e),c=l&&Number.parseInt(l[1],10);return e.replace("[dir]",h.basename(n)).replace("[name]",i).replace("[extname]",r).replace(".[ext]",r).replace("[ext]",r.slice(1)).replace(S.H,c?u.slice(0,c):u.slice(0,8))},"default"),is=new P.p(P.g)._freeze();var as=Object.defineProperty,cs=d((e,t)=>as(e,"name",{value:t,configurable:!0}),"r");const us=cs((e,t)=>{const s=is.getType(e)??"application/octet-stream",o=Buffer.from(t).toString("base64");return`data:${s};base64,${o}`},"default");var ls=Object.defineProperty,ps=d((e,t)=>ls(e,"name",{value:t,configurable:!0}),"a");const fs=ps(async(e,t)=>{const s=new URL(e,"file://"),o=s.hash?s.hash.slice(1):"",n=e.split("?")[0]??"",r=[n];n.startsWith("/")&&r.push(`.${n}`),!n.startsWith("/")&&!n.startsWith(".")&&r.push(`./${n}`);const i=D.r(r,{baseDirs:t,caller:"URL resolver"}),u=new URLSearchParams(s.search).toString();return{from:i,source:V.readFileSync(i,{buffer:!0}),urlQuery:(u?`?${u}`:"")+(o?`#${o}`:"")}},"urlResolve");var ds=Object.defineProperty,fe=d((e,t)=>ds(e,"name",{value:t,configurable:!0}),"n");const se=/^url$/i,ms=/^(?:-webkit-)?image-set$/i,hs=fe(e=>/(?:url|(?:-webkit-)?image-set)\(/i.test(e.value),"isDeclWithUrl"),gs=fe((e,t)=>{e.walk(s=>{if(s.type==="function"){if(se.test(s.value)){const{nodes:o}=s,[n]=o,r=n?.type==="string"?n.value:z.stringify(o);t(r.replaceAll(/^\s+|\s+$/g,""),n);return}if(ms.test(s.value))for(const o of s.nodes){if(o.type==="string"){t(o.value.replaceAll(/^\s+|\s+$/g,""),o);continue}if(o.type==="function"&&se.test(o.value)){const{nodes:n}=o,[r]=n,i=r?.type==="string"?r.value:z.stringify(n);t(i.replaceAll(/^\s+|\s+$/g,""),r)}}}})},"walkUrls");var ys=Object.defineProperty,vs=d((e,t)=>ys(e,"name",{value:t,configurable:!0}),"$");const B="packem-css-url",$s="assets/[name]-[hash][extname]",bs="assets/[name][extname]",ws="./assets/",js=".",de=vs(e=>{const t={alias:{},assetDir:js,inline:!1,resolve:fs,...e},s=t.hash??!0?typeof t.hash=="string"?t.hash:$s:bs;return{async Once(o,{result:n}){if(!o.source?.input.file)return;const{file:r}=o.source.input,i=S.m(o.source.input.map?.text??void 0).resolve(h.dirname(r)).toConsumer(),u=[],l=new Set(n.messages.filter(a=>a.type==="dependency").map(a=>a.file));o.walkDecls(a=>{if(!hs(a))return;const f=z(a.value);gs(f,(p,g)=>{for(const[b,$]of Object.entries(t.alias))p!==b&&!p.startsWith(`${b}/`)||(p=h.normalize($)+p.slice(b.length));if(!g||p.length===0){a.warn(n,`Empty URL in \`${a.toString()}\``);return}if(S.D.test(p))return;if(!h.isAbsolute(p))try{new URL(p);return}catch{}const j=new Set;if(a.source?.input.file&&l.has(a.source.input.file)&&j.add(h.dirname(a.source.input.file)),a.source?.start){const b=a.source.start,$=i?.originalPositionFor(b),O=$?.source&&h.dirname($.source);O&&j.add(h.normalize(O))}j.add(h.dirname(r)),u.push({baseDirs:j,decl:a,node:g,parsed:f,url:p})})});const c=new Map;for await(const{baseDirs:a,decl:f,node:p,parsed:g,url:j}of u){let b;try{b||(b=await t.resolve(j,[...a]))}catch{}if(!b){f.warn(n,`Unresolved URL \`${j}\` in \`${f.toString()}\``);continue}const{from:$,source:O,urlQuery:m}=b;if(!(O instanceof Uint8Array)||typeof $!="string"){f.warn(n,`Incorrectly resolved URL \`${j}\` in \`${f.toString()}\``);continue}if(n.messages.push({file:$,plugin:B,type:"dependency"}),t.inline)p.type="string",p.value=us($,O);else{const w=h.normalize(os(s,$,O));let y=w;const N=S.F.test(w);for(let R=1;c.has(y)&&c.get(y)!==$;R++)y=N?w.replace(S.F,`${String(R)}$1`):`${w}${String(R)}`;c.set(y,$);const U=typeof t.publicPath=="string"?t.publicPath+(/[/\\]$/.test(t.publicPath)?"":"/")+h.basename(y):`${ws}${h.basename(y)}`;p.type="string",p.value=typeof t.publicPath=="function"?t.publicPath(p.value,U,r):U,m&&(p.value+=m),typeof t.assetDir=="string"?y=h.join(t.assetDir,y):typeof t.assetDir=="function"&&(y=t.assetDir($,y,r)),n.messages.push({plugin:B,source:O,to:y,type:"asset"})}f.value=g.toString()}},postcssPlugin:B}},"plugin");de.postcss=!0;var Ss=Object.defineProperty,me=d((e,t)=>Ss(e,"name",{value:t,configurable:!0}),"j");const Os=h.dirname(be.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("rollup/plugins/css/loaders/postcss/index.cjs",document.baseURI).href));let _;const I="css",xs=new Set([I]),Ps=me(e=>{const t=H.makeLegalIdentifier(e);return xs.has(t)?`_${t}`:t},"getClassNameDefault"),ks={alwaysProcess:!0,name:"postcss",async process({code:e,extracted:t,map:s}){const o=await Qt(this.id,this.cwd,this.environment,this.options.config),n=[];let r=!1;typeof this.options.modules=="boolean"?r=this.options.modules:typeof this.options.modules=="object"&&(r=Z.n(this.options.modules.include,this.id)),this.autoModules&&this.options.modules===void 0&&(r=Z.n(this.autoModules,this.id));const i={},u=[],l={...o.options,...this.options,from:this.id,map:{annotation:!1,inline:!1,prev:S.m(s).relative(h.dirname(this.id)).toObject(),sourcesContent:this.sourceMap?this.sourceMap.content:!0},plugins:[],to:this.options.to??this.id};if(this.options.import&&n.push(pe({debug:this.debug,extensions:this.extensions,plugins:[],root:this.cwd,warnOnEmpty:!0,...this.options.import})),this.options.url&&n.push(de({inline:!!this.inject,...this.options.url})),this.options.plugins&&n.push(...this.options.plugins),n.push(...o.plugins),r){const m=typeof this.options.modules=="object"?this.options.modules:{};n.push(...ss({failOnWrongOrder:!0,...m}),re({extensions:this.extensions}))}n.length===0&&n.push(Q),this.debug&&n.push(Ie({ignore:["css-noop"]}));const c=await Ce(n).process(e,l);for(const m of c.messages)switch(m.type){case"asset":{this.assets.set(m.to,m.source);break}case"dependency":{this.deps.add(h.normalize(m.file));break}case"icss":{Object.assign(i,m.export);break}case"icss-dependency":{u.push(m.import);break}case"warning":{this.warn({message:m.text,plugin:m.plugin});break}}if(s=S.m(c.map.toJSON()).resolve(h.dirname(l.to)).toString(),!this.extract&&this.sourceMap){const m=S.m(s).modify(w=>{w.file=void 0}).relative();this.sourceMap.transform&&m.modify(this.sourceMap.transform),s=m.toString(),c.css+=m.toCommentData()}const a=me(m=>Fe(m,h.basename(this.id)),"saferId"),f=a("modules"),p=[`var ${I} = ${JSON.stringify(c.css)};`],g=[],j=[I];if(this.namedExports){this.dts&&g.push(`declare const ${I}: string;`);const m=typeof this.namedExports=="function"?this.namedExports:Ps;for(const w in i){const y=m(w);w!==y&&this.warn(`Exported \`${w}\` as \`${y}\` in ${h.relative(this.cwd,this.id)}`);const N=JSON.stringify(i[w]);p.push(`var ${y} = ${N};`),this.dts&&g.push(`declare const ${y}: ${N};`),j.push(y)}}if(this.extract&&(t={css:c.css,id:this.id,map:s}),this.inject)if(typeof this.inject=="function")p.push(this.inject(I,this.id,p),`var ${f} = ${JSON.stringify(i)};`);else{const{treeshakeable:m,...w}=typeof this.inject=="object"?this.inject:{},y=a("injector"),N=`${y}(${I},${JSON.stringify(w)});`;if(_||(_=D.r(["./runtime/inject-css"],{baseDirs:[h.join(Os,"..","..")]}),_=`"${h.normalize(_)}"`),p.unshift(`import ${y} from ${_};`),m||p.push(`var ${f} = ${JSON.stringify(i)};`,N),m){p.push("var injected = false;");const U=`if (!injected) { injected = true; ${N} }`;if(i.inject)throw new Error("`inject` keyword is reserved when using `inject.treeshakeable` option");let R="";for(const[he,ge]of Object.entries(i)){const ye=JSON.stringify(he),ve=JSON.stringify(ge);R+=`get ${ye}() { ${U} return ${ve}; },
`}R+=`inject: function inject() { ${U} },`,p.push(`var ${f} = {${R}};`)}}!this.inject&&Object.keys(i).length>0&&p.push(`var ${f} = ${JSON.stringify(i)};`);const b=`
export default ${r?f:I};
`;if(p.push(b),this.dts&&(r&&g.push(`
interface ModulesExports {
${Object.keys(i).map(m=>` '${m}': string;`).join(`
`)}
}
`,typeof this.inject=="object"&&this.inject.treeshakeable?"interface ModulesExports {inject:()=>void}":"",`declare const ${f}: ModulesExports;`),g.push(b)),this.namedExports){const m=`export {
${j.filter(Boolean).join(`,
`)}
};`;p.push(m),this.dts&&g.push(m)}const $=p.filter(Boolean).join(`
`),O=g.length>0?g.filter(Boolean).join(`
`):void 0;return this.emit?{code:c.css,map:s,meta:{icssDependencies:u,moduleContents:$,types:O}}:{code:$,extracted:t,map:s,meta:{types:O},moduleSideEffects:r||typeof this.inject=="object"&&this.inject.treeshakeable?!1:"no-treeshake"}}};module.exports=ks;