'use strict'; const fs = require('node:fs'); const merge = require('merge'); const defu = require('defu'); const path = require('node:path'); const hash = require('object-hash'); function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } const fs__default = /*#__PURE__*/_interopDefaultCompat(fs); const merge__default = /*#__PURE__*/_interopDefaultCompat(merge); const defu__default = /*#__PURE__*/_interopDefaultCompat(defu); const path__default = /*#__PURE__*/_interopDefaultCompat(path); const hash__default = /*#__PURE__*/_interopDefaultCompat(hash); const defuOverrideArray = defu.createDefu((obj, key, value) => { if (Array.isArray(obj[key]) && Array.isArray(value)) { obj[key] = value; return true; } }); const defuOptions = defu.createDefu((obj, key, value) => { if (Array.isArray(obj[key]) && Array.isArray(value)) { obj[key] = [...obj[key], ...value]; return true; } }); const defuArrayRight = defu.createDefu((obj, key, value) => { if (Array.isArray(obj[key]) && Array.isArray(value)) { obj[key] = [...obj[key], ...value]; return true; } }); function expandTypes(types, fn) { return types.reduce((acc, cur) => { const { key, value } = fn(cur); acc[key] = value; return acc; }, {}); } function getSelector(type, prefix = "-") { return type === "" ? type : `${prefix}${type}`; } function mergeR(...items) { return merge__default.recursive(...items); } function mergeRClone(...items) { return merge__default.recursive(true, ...items); } function groupBy(arr, cb) { if (!Array.isArray(arr)) { throw new TypeError("expected an array for first argument"); } if (typeof cb !== "function") { throw new TypeError("expected a function for second argument"); } const result = {}; for (const item of arr) { const bucketCategory = cb(item); const bucket = result[bucketCategory]; if (Array.isArray(bucket)) { result[bucketCategory].push(item); } else { result[bucketCategory] = [item]; } } return result; } function JSONStringify(value) { return JSON.stringify(value, null, 2); } function arrMatch(matchArr, str) { if (!Array.isArray(matchArr)) return; if (typeof str !== "string") return; return matchArr.some((regex) => { if (typeof regex === "string") { return str.includes(regex); } return str.match(regex); }); } function isModeMergeValue(input) { return typeof input === "object" && (Reflect.has(input, "base") || Reflect.has(input, "styled") || Reflect.has(input, "utils")); } function makeArray(value) { if (value) { return Array.isArray(value) ? value : [value]; } return []; } const css = String.raw; function touch(filename) { const time = /* @__PURE__ */ new Date(); try { fs__default.utimesSync(filename, time, time); } catch { fs__default.closeSync(fs__default.openSync(filename, "w")); } } const jsExtensions = /* @__PURE__ */ new Set([".js", ".cjs", ".mjs"]); const jsResolutionOrder = ["", ".js", ".cjs", ".mjs", ".ts", ".cts", ".mts", ".jsx", ".tsx"]; const tsResolutionOrder = ["", ".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"]; function resolveWithExtension(file, extensions) { for (const ext of extensions) { const full = `${file}${ext}`; if (fs__default.existsSync(full) && fs__default.statSync(full).isFile()) { return full; } } for (const ext of extensions) { const full = `${file}/index${ext}`; if (fs__default.existsSync(full)) { return full; } } return null; } function* _getModuleDependencies(filename, base, seen, ext = path__default.extname(filename)) { const absoluteFile = resolveWithExtension(path__default.resolve(base, filename), jsExtensions.has(ext) ? jsResolutionOrder : tsResolutionOrder); if (absoluteFile === null) return; if (seen.has(absoluteFile)) return; seen.add(absoluteFile); yield absoluteFile; base = path__default.dirname(absoluteFile); ext = path__default.extname(absoluteFile); const contents = fs__default.readFileSync(absoluteFile, "utf8"); for (const match of [ ...contents.matchAll(/import[\S\s]*?["'](.{3,}?)["']/gi), ...contents.matchAll(/import[\S\s]*from[\S\s]*?["'](.{3,}?)["']/gi), ...contents.matchAll(/require\(["'`](.+)["'`]\)/gi) ]) { if (!match[1].startsWith(".")) continue; yield* _getModuleDependencies(match[1], base, seen, ext); } } function getModuleDependencies(absoluteFilePath) { if (absoluteFilePath === null) return /* @__PURE__ */ new Set(); return new Set(_getModuleDependencies(absoluteFilePath, path__default.dirname(absoluteFilePath), /* @__PURE__ */ new Set())); } function objHash(object) { return hash__default(object, { ignoreUnknown: true }); } exports.defu = defu__default; exports.JSONStringify = JSONStringify; exports.arrMatch = arrMatch; exports.css = css; exports.defuArrayRight = defuArrayRight; exports.defuOptions = defuOptions; exports.defuOverrideArray = defuOverrideArray; exports.expandTypes = expandTypes; exports.getModuleDependencies = getModuleDependencies; exports.getSelector = getSelector; exports.groupBy = groupBy; exports.isModeMergeValue = isModeMergeValue; exports.makeArray = makeArray; exports.mergeR = mergeR; exports.mergeRClone = mergeRClone; exports.objHash = objHash; exports.touch = touch;