"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault(_promises);var _path = require('path'); var _path2 = _interopRequireDefault(_path);var _autoprefixer = require('autoprefixer'); var _autoprefixer2 = _interopRequireDefault(_autoprefixer);var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);var _postcssmodules = require('postcss-modules'); var _postcssmodules2 = _interopRequireDefault(_postcssmodules);var _tailwindcss = require('tailwindcss'); var _tailwindcss2 = _interopRequireDefault(_tailwindcss);var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);var f=t=>_crypto2.default.createHash("sha256").update(t).digest("hex");var P=({configPath:t,postcssPlugins:m,cssModulesEnabled:h,cssModulesFilter:O,cssModulesExcludePaths:w})=>async i=>{let n=new Map,e="tailwind-css-module",y=async s=>{let L=_path2.default.basename(s.path),a=h&&O.test(L),r=[],l=[];for(let o of m)if(typeof o=="object"&&o.plugin){let p=o;p.prepend?r.push(p.plugin):l.push(p.plugin)}else l.push(o);let c=[...r,_tailwindcss2.default.call(void 0, t),_autoprefixer2.default,...l];a&&c.push(_postcssmodules2.default.call(void 0, {globalModulePaths:w,getJSON:(o,d)=>n.set(s.path,d)}));let M=await _promises2.default.readFile(s.path,"utf8"),{css:u}=await _postcss2.default.call(void 0, c).process(M,{from:s.path});if(!a)return{contents:u,loader:"css"};let x=f(s.path),g=`${e}://${x}`,C=JSON.stringify(n.get(s.path)),T=`import "${g}"; export default ${C};`;return n.set(g,u),{contents:T,loader:"js"}},R=s=>({contents:_optionalChain([n, 'access', _ => _.get, 'call', _2 => _2(s.path), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]),loader:"css"}),S=s=>({path:s.path,namespace:e});i.onLoad({filter:/\.css$/},y),i.onLoad({filter:/.*/,namespace:e},R),i.onResolve({filter:new RegExp(`^${e}://`)},S)};var N={configPath:void 0,postcssPlugins:[],cssModulesEnabled:!1,cssModulesExcludePaths:[],cssModulesFilter:/\.module\.css$/i},B= exports.tailwindPlugin =(t={})=>({name:"tailwindcss",setup:P({...N,...t})});var U=B;exports.default = U; exports.tailwindPlugin = B;