@dreamy-ui/panda-preset
Version:
A panda preset for Dreamy UI React component library
1 lines • 191 kB
Source Map (JSON)
{"version":3,"sources":["../src/index.ts","../src/plugin/index.ts","../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js","../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js","../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js","../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js","../src/plugin/factory.ts","../src/plugin/remove-jsx-elements.ts","../src/plugin/system.ts","../src/plugin/update-style-context.ts","../src/recipes/color-scheme.ts","../src/recipes/jsx.ts","../src/theme/preset.ts","../src/theme/resolve-button-colors.ts","../src/theme/semantic-tokens/colors.ts","../src/theme/colors.ts","../src/theme/semantic-tokens/radii.ts","../src/theme/semantic-tokens/index.ts","../src/theme/semantic-tokens/font-sizes.ts","../src/theme/semantic-tokens/shadows.ts","../src/theme/tokens/assets.ts","../src/theme/tokens/colors.ts","../src/theme/tokens/typography/fonts.ts","../src/theme/tokens/index.ts","../src/theme/keyframes.ts","../src/theme/tokens/aspect-ratios.ts","../src/theme/tokens/blurs.ts","../src/theme/tokens/borders.ts","../src/theme/tokens/durations.ts","../src/theme/tokens/easings.ts","../src/theme/tokens/radii.ts","../src/theme/tokens/spacing.ts","../src/theme/tokens/sizes.ts","../src/theme/tokens/typography/font-sizes.ts","../src/theme/tokens/typography/font-weights.ts","../src/theme/tokens/typography/letter-spacings.ts","../src/theme/tokens/typography/line-heights.ts","../src/theme/tokens/z-index.ts","../src/theme/breakpoints.ts","../src/theme/conditions.ts","../src/theme/containerSizes.ts","../src/theme/global-css.ts","../src/theme/staticCss.ts","../src/theme/text-styles.ts","../src/theme/utils/common.ts","../src/theme/utils/container.ts","../src/theme/utils/flexbox.ts","../src/theme/utils/typography.ts","../src/theme/utils/index.ts","../src/types.ts"],"sourcesContent":["export * from \"./plugin\";\nexport * from \"./recipes\";\nexport {\n\tdefault,\n\tdefaultPresetOptions,\n\ttype PresetOptions\n} from \"./theme/preset\";\nexport * from \"./types\";\n","import { definePlugin } from \"@pandacss/dev\";\nimport chalk from \"chalk\";\nimport { updateFactory } from \"./factory\";\nimport { removeJsxElements } from \"./remove-jsx-elements\";\nimport { ensureJsxFolderExists, ensureStyledSystemExists, ensureTypesFolderExists } from \"./system\";\nimport { removeFactoryFromStyleContext, updateStyleContextTypes } from \"./update-style-context\";\n\nexport interface DreamyPluginOptions {\n /**\n * Whether to remove the jsx generated files from the `jsx` directory in the `styled-system` folder.\n * @default true\n */\n removeJsxElements?: boolean;\n /**\n * Whether to remove the \"dreamy\" factory from the style context.\n * @default true\n */\n removeFactoryFromStyleContext?: boolean;\n /**\n * Whether to update the factory and types files to match dreamy ui needs.\n * @default true\n */\n updateFactory?: boolean;\n /**\n * The current working directory.\n * @default process.cwd()\n */\n cwd?: string;\n}\n\n/**\n * This plugin is used to modify the `styled-system` folder to remove default\n * JSX generated components from patterns, since Dreamy UI has its own components.\n *\n * It also updates the `styled` factory and types files to match Dreamy UI needs.\n *\n * `jsxFactory: \"dreamy\"` is required in `panda.config.ts` to make Dreamy UI work.\n */\nexport function dreamyPlugin(options?: DreamyPluginOptions) {\n const {\n removeJsxElements: removeJsxElementsOption = true,\n updateFactory: updateFactoryOption = true,\n removeFactoryFromStyleContext: removeFactoryFromStyleContextOption = true,\n cwd = process.cwd()\n } = options ?? {};\n\n return definePlugin({\n name: \"dreamy-plugin\",\n hooks: {\n \"codegen:done\": async () => {\n const isSilent = process.argv.includes(\"--silent\");\n\n const start = performance.now();\n\n const styledFolder = await ensureStyledSystemExists(cwd);\n const [jsxFolder, typesFolder] = await Promise.all([\n ensureJsxFolderExists(styledFolder),\n updateFactoryOption ? ensureTypesFolderExists(styledFolder) : null\n ]);\n\n await Promise.all([\n removeJsxElementsOption && removeJsxElements(jsxFolder),\n updateFactoryOption && updateFactory(jsxFolder, typesFolder!),\n removeFactoryFromStyleContextOption &&\n (async () => {\n await removeFactoryFromStyleContext(jsxFolder);\n await updateStyleContextTypes(jsxFolder);\n })()\n ]);\n\n const end = performance.now();\n\n if (!isSilent) {\n console.log(\n chalk.ansi256(140)(\"✔️ Dreamy UI\"),\n chalk.reset(\"has successfully modified\"),\n chalk.cyan(\"`styled-system/jsx`\"),\n chalk.reset(\"and\"),\n chalk.cyan(\"`styled-system/types`\"),\n chalk.gray(` (${(end - start).toFixed(0)}ms)`)\n );\n }\n }\n }\n });\n}\n","const ANSI_BACKGROUND_OFFSET = 10;\n\nconst wrapAnsi16 = (offset = 0) => code => `\\u001B[${code + offset}m`;\n\nconst wrapAnsi256 = (offset = 0) => code => `\\u001B[${38 + offset};5;${code}m`;\n\nconst wrapAnsi16m = (offset = 0) => (red, green, blue) => `\\u001B[${38 + offset};2;${red};${green};${blue}m`;\n\nconst styles = {\n\tmodifier: {\n\t\treset: [0, 0],\n\t\t// 21 isn't widely supported and 22 does the same thing\n\t\tbold: [1, 22],\n\t\tdim: [2, 22],\n\t\titalic: [3, 23],\n\t\tunderline: [4, 24],\n\t\toverline: [53, 55],\n\t\tinverse: [7, 27],\n\t\thidden: [8, 28],\n\t\tstrikethrough: [9, 29],\n\t},\n\tcolor: {\n\t\tblack: [30, 39],\n\t\tred: [31, 39],\n\t\tgreen: [32, 39],\n\t\tyellow: [33, 39],\n\t\tblue: [34, 39],\n\t\tmagenta: [35, 39],\n\t\tcyan: [36, 39],\n\t\twhite: [37, 39],\n\n\t\t// Bright color\n\t\tblackBright: [90, 39],\n\t\tgray: [90, 39], // Alias of `blackBright`\n\t\tgrey: [90, 39], // Alias of `blackBright`\n\t\tredBright: [91, 39],\n\t\tgreenBright: [92, 39],\n\t\tyellowBright: [93, 39],\n\t\tblueBright: [94, 39],\n\t\tmagentaBright: [95, 39],\n\t\tcyanBright: [96, 39],\n\t\twhiteBright: [97, 39],\n\t},\n\tbgColor: {\n\t\tbgBlack: [40, 49],\n\t\tbgRed: [41, 49],\n\t\tbgGreen: [42, 49],\n\t\tbgYellow: [43, 49],\n\t\tbgBlue: [44, 49],\n\t\tbgMagenta: [45, 49],\n\t\tbgCyan: [46, 49],\n\t\tbgWhite: [47, 49],\n\n\t\t// Bright color\n\t\tbgBlackBright: [100, 49],\n\t\tbgGray: [100, 49], // Alias of `bgBlackBright`\n\t\tbgGrey: [100, 49], // Alias of `bgBlackBright`\n\t\tbgRedBright: [101, 49],\n\t\tbgGreenBright: [102, 49],\n\t\tbgYellowBright: [103, 49],\n\t\tbgBlueBright: [104, 49],\n\t\tbgMagentaBright: [105, 49],\n\t\tbgCyanBright: [106, 49],\n\t\tbgWhiteBright: [107, 49],\n\t},\n};\n\nexport const modifierNames = Object.keys(styles.modifier);\nexport const foregroundColorNames = Object.keys(styles.color);\nexport const backgroundColorNames = Object.keys(styles.bgColor);\nexport const colorNames = [...foregroundColorNames, ...backgroundColorNames];\n\nfunction assembleStyles() {\n\tconst codes = new Map();\n\n\tfor (const [groupName, group] of Object.entries(styles)) {\n\t\tfor (const [styleName, style] of Object.entries(group)) {\n\t\t\tstyles[styleName] = {\n\t\t\t\topen: `\\u001B[${style[0]}m`,\n\t\t\t\tclose: `\\u001B[${style[1]}m`,\n\t\t\t};\n\n\t\t\tgroup[styleName] = styles[styleName];\n\n\t\t\tcodes.set(style[0], style[1]);\n\t\t}\n\n\t\tObject.defineProperty(styles, groupName, {\n\t\t\tvalue: group,\n\t\t\tenumerable: false,\n\t\t});\n\t}\n\n\tObject.defineProperty(styles, 'codes', {\n\t\tvalue: codes,\n\t\tenumerable: false,\n\t});\n\n\tstyles.color.close = '\\u001B[39m';\n\tstyles.bgColor.close = '\\u001B[49m';\n\n\tstyles.color.ansi = wrapAnsi16();\n\tstyles.color.ansi256 = wrapAnsi256();\n\tstyles.color.ansi16m = wrapAnsi16m();\n\tstyles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);\n\tstyles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);\n\tstyles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);\n\n\t// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js\n\tObject.defineProperties(styles, {\n\t\trgbToAnsi256: {\n\t\t\tvalue(red, green, blue) {\n\t\t\t\t// We use the extended greyscale palette here, with the exception of\n\t\t\t\t// black and white. normal palette only has 4 greyscale shades.\n\t\t\t\tif (red === green && green === blue) {\n\t\t\t\t\tif (red < 8) {\n\t\t\t\t\t\treturn 16;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (red > 248) {\n\t\t\t\t\t\treturn 231;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Math.round(((red - 8) / 247) * 24) + 232;\n\t\t\t\t}\n\n\t\t\t\treturn 16\n\t\t\t\t\t+ (36 * Math.round(red / 255 * 5))\n\t\t\t\t\t+ (6 * Math.round(green / 255 * 5))\n\t\t\t\t\t+ Math.round(blue / 255 * 5);\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToRgb: {\n\t\t\tvalue(hex) {\n\t\t\t\tconst matches = /[a-f\\d]{6}|[a-f\\d]{3}/i.exec(hex.toString(16));\n\t\t\t\tif (!matches) {\n\t\t\t\t\treturn [0, 0, 0];\n\t\t\t\t}\n\n\t\t\t\tlet [colorString] = matches;\n\n\t\t\t\tif (colorString.length === 3) {\n\t\t\t\t\tcolorString = [...colorString].map(character => character + character).join('');\n\t\t\t\t}\n\n\t\t\t\tconst integer = Number.parseInt(colorString, 16);\n\n\t\t\t\treturn [\n\t\t\t\t\t/* eslint-disable no-bitwise */\n\t\t\t\t\t(integer >> 16) & 0xFF,\n\t\t\t\t\t(integer >> 8) & 0xFF,\n\t\t\t\t\tinteger & 0xFF,\n\t\t\t\t\t/* eslint-enable no-bitwise */\n\t\t\t\t];\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToAnsi256: {\n\t\t\tvalue: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),\n\t\t\tenumerable: false,\n\t\t},\n\t\tansi256ToAnsi: {\n\t\t\tvalue(code) {\n\t\t\t\tif (code < 8) {\n\t\t\t\t\treturn 30 + code;\n\t\t\t\t}\n\n\t\t\t\tif (code < 16) {\n\t\t\t\t\treturn 90 + (code - 8);\n\t\t\t\t}\n\n\t\t\t\tlet red;\n\t\t\t\tlet green;\n\t\t\t\tlet blue;\n\n\t\t\t\tif (code >= 232) {\n\t\t\t\t\tred = (((code - 232) * 10) + 8) / 255;\n\t\t\t\t\tgreen = red;\n\t\t\t\t\tblue = red;\n\t\t\t\t} else {\n\t\t\t\t\tcode -= 16;\n\n\t\t\t\t\tconst remainder = code % 36;\n\n\t\t\t\t\tred = Math.floor(code / 36) / 5;\n\t\t\t\t\tgreen = Math.floor(remainder / 6) / 5;\n\t\t\t\t\tblue = (remainder % 6) / 5;\n\t\t\t\t}\n\n\t\t\t\tconst value = Math.max(red, green, blue) * 2;\n\n\t\t\t\tif (value === 0) {\n\t\t\t\t\treturn 30;\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tlet result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));\n\n\t\t\t\tif (value === 2) {\n\t\t\t\t\tresult += 60;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\trgbToAnsi: {\n\t\t\tvalue: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToAnsi: {\n\t\t\tvalue: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),\n\t\t\tenumerable: false,\n\t\t},\n\t});\n\n\treturn styles;\n}\n\nconst ansiStyles = assembleStyles();\n\nexport default ansiStyles;\n","import process from 'node:process';\nimport os from 'node:os';\nimport tty from 'node:tty';\n\n// From: https://github.com/sindresorhus/has-flag/blob/main/index.js\n/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {\nfunction hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {\n\tconst prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');\n\tconst position = argv.indexOf(prefix + flag);\n\tconst terminatorPosition = argv.indexOf('--');\n\treturn position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n}\n\nconst {env} = process;\n\nlet flagForceColor;\nif (\n\thasFlag('no-color')\n\t|| hasFlag('no-colors')\n\t|| hasFlag('color=false')\n\t|| hasFlag('color=never')\n) {\n\tflagForceColor = 0;\n} else if (\n\thasFlag('color')\n\t|| hasFlag('colors')\n\t|| hasFlag('color=true')\n\t|| hasFlag('color=always')\n) {\n\tflagForceColor = 1;\n}\n\nfunction envForceColor() {\n\tif ('FORCE_COLOR' in env) {\n\t\tif (env.FORCE_COLOR === 'true') {\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (env.FORCE_COLOR === 'false') {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);\n\t}\n}\n\nfunction translateLevel(level) {\n\tif (level === 0) {\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tlevel,\n\t\thasBasic: true,\n\t\thas256: level >= 2,\n\t\thas16m: level >= 3,\n\t};\n}\n\nfunction _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {\n\tconst noFlagForceColor = envForceColor();\n\tif (noFlagForceColor !== undefined) {\n\t\tflagForceColor = noFlagForceColor;\n\t}\n\n\tconst forceColor = sniffFlags ? flagForceColor : noFlagForceColor;\n\n\tif (forceColor === 0) {\n\t\treturn 0;\n\t}\n\n\tif (sniffFlags) {\n\t\tif (hasFlag('color=16m')\n\t\t\t|| hasFlag('color=full')\n\t\t\t|| hasFlag('color=truecolor')) {\n\t\t\treturn 3;\n\t\t}\n\n\t\tif (hasFlag('color=256')) {\n\t\t\treturn 2;\n\t\t}\n\t}\n\n\t// Check for Azure DevOps pipelines.\n\t// Has to be above the `!streamIsTTY` check.\n\tif ('TF_BUILD' in env && 'AGENT_NAME' in env) {\n\t\treturn 1;\n\t}\n\n\tif (haveStream && !streamIsTTY && forceColor === undefined) {\n\t\treturn 0;\n\t}\n\n\tconst min = forceColor || 0;\n\n\tif (env.TERM === 'dumb') {\n\t\treturn min;\n\t}\n\n\tif (process.platform === 'win32') {\n\t\t// Windows 10 build 10586 is the first Windows release that supports 256 colors.\n\t\t// Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n\t\tconst osRelease = os.release().split('.');\n\t\tif (\n\t\t\tNumber(osRelease[0]) >= 10\n\t\t\t&& Number(osRelease[2]) >= 10_586\n\t\t) {\n\t\t\treturn Number(osRelease[2]) >= 14_931 ? 3 : 2;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif ('CI' in env) {\n\t\tif (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {\n\t\t\treturn 3;\n\t\t}\n\n\t\tif (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn min;\n\t}\n\n\tif ('TEAMCITY_VERSION' in env) {\n\t\treturn /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;\n\t}\n\n\tif (env.COLORTERM === 'truecolor') {\n\t\treturn 3;\n\t}\n\n\tif (env.TERM === 'xterm-kitty') {\n\t\treturn 3;\n\t}\n\n\tif (env.TERM === 'xterm-ghostty') {\n\t\treturn 3;\n\t}\n\n\tif (env.TERM === 'wezterm') {\n\t\treturn 3;\n\t}\n\n\tif ('TERM_PROGRAM' in env) {\n\t\tconst version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);\n\n\t\tswitch (env.TERM_PROGRAM) {\n\t\t\tcase 'iTerm.app': {\n\t\t\t\treturn version >= 3 ? 3 : 2;\n\t\t\t}\n\n\t\t\tcase 'Apple_Terminal': {\n\t\t\t\treturn 2;\n\t\t\t}\n\t\t\t// No default\n\t\t}\n\t}\n\n\tif (/-256(color)?$/i.test(env.TERM)) {\n\t\treturn 2;\n\t}\n\n\tif (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {\n\t\treturn 1;\n\t}\n\n\tif ('COLORTERM' in env) {\n\t\treturn 1;\n\t}\n\n\treturn min;\n}\n\nexport function createSupportsColor(stream, options = {}) {\n\tconst level = _supportsColor(stream, {\n\t\tstreamIsTTY: stream && stream.isTTY,\n\t\t...options,\n\t});\n\n\treturn translateLevel(level);\n}\n\nconst supportsColor = {\n\tstdout: createSupportsColor({isTTY: tty.isatty(1)}),\n\tstderr: createSupportsColor({isTTY: tty.isatty(2)}),\n};\n\nexport default supportsColor;\n","// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.\nexport function stringReplaceAll(string, substring, replacer) {\n\tlet index = string.indexOf(substring);\n\tif (index === -1) {\n\t\treturn string;\n\t}\n\n\tconst substringLength = substring.length;\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\treturnValue += string.slice(endIndex, index) + substring + replacer;\n\t\tendIndex = index + substringLength;\n\t\tindex = string.indexOf(substring, endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.slice(endIndex);\n\treturn returnValue;\n}\n\nexport function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\tconst gotCR = string[index - 1] === '\\r';\n\t\treturnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\\r\\n' : '\\n') + postfix;\n\t\tendIndex = index + 1;\n\t\tindex = string.indexOf('\\n', endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.slice(endIndex);\n\treturn returnValue;\n}\n","import ansiStyles from '#ansi-styles';\nimport supportsColor from '#supports-color';\nimport { // eslint-disable-line import/order\n\tstringReplaceAll,\n\tstringEncaseCRLFWithFirstIndex,\n} from './utilities.js';\n\nconst {stdout: stdoutColor, stderr: stderrColor} = supportsColor;\n\nconst GENERATOR = Symbol('GENERATOR');\nconst STYLER = Symbol('STYLER');\nconst IS_EMPTY = Symbol('IS_EMPTY');\n\n// `supportsColor.level` → `ansiStyles.color[name]` mapping\nconst levelMapping = [\n\t'ansi',\n\t'ansi',\n\t'ansi256',\n\t'ansi16m',\n];\n\nconst styles = Object.create(null);\n\nconst applyOptions = (object, options = {}) => {\n\tif (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {\n\t\tthrow new Error('The `level` option should be an integer from 0 to 3');\n\t}\n\n\t// Detect level if not set manually\n\tconst colorLevel = stdoutColor ? stdoutColor.level : 0;\n\tobject.level = options.level === undefined ? colorLevel : options.level;\n};\n\nexport class Chalk {\n\tconstructor(options) {\n\t\t// eslint-disable-next-line no-constructor-return\n\t\treturn chalkFactory(options);\n\t}\n}\n\nconst chalkFactory = options => {\n\tconst chalk = (...strings) => strings.join(' ');\n\tapplyOptions(chalk, options);\n\n\tObject.setPrototypeOf(chalk, createChalk.prototype);\n\n\treturn chalk;\n};\n\nfunction createChalk(options) {\n\treturn chalkFactory(options);\n}\n\nObject.setPrototypeOf(createChalk.prototype, Function.prototype);\n\nfor (const [styleName, style] of Object.entries(ansiStyles)) {\n\tstyles[styleName] = {\n\t\tget() {\n\t\t\tconst builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);\n\t\t\tObject.defineProperty(this, styleName, {value: builder});\n\t\t\treturn builder;\n\t\t},\n\t};\n}\n\nstyles.visible = {\n\tget() {\n\t\tconst builder = createBuilder(this, this[STYLER], true);\n\t\tObject.defineProperty(this, 'visible', {value: builder});\n\t\treturn builder;\n\t},\n};\n\nconst getModelAnsi = (model, level, type, ...arguments_) => {\n\tif (model === 'rgb') {\n\t\tif (level === 'ansi16m') {\n\t\t\treturn ansiStyles[type].ansi16m(...arguments_);\n\t\t}\n\n\t\tif (level === 'ansi256') {\n\t\t\treturn ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));\n\t\t}\n\n\t\treturn ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));\n\t}\n\n\tif (model === 'hex') {\n\t\treturn getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));\n\t}\n\n\treturn ansiStyles[type][model](...arguments_);\n};\n\nconst usedModels = ['rgb', 'hex', 'ansi256'];\n\nfor (const model of usedModels) {\n\tstyles[model] = {\n\t\tget() {\n\t\t\tconst {level} = this;\n\t\t\treturn function (...arguments_) {\n\t\t\t\tconst styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);\n\t\t\t\treturn createBuilder(this, styler, this[IS_EMPTY]);\n\t\t\t};\n\t\t},\n\t};\n\n\tconst bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);\n\tstyles[bgModel] = {\n\t\tget() {\n\t\t\tconst {level} = this;\n\t\t\treturn function (...arguments_) {\n\t\t\t\tconst styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);\n\t\t\t\treturn createBuilder(this, styler, this[IS_EMPTY]);\n\t\t\t};\n\t\t},\n\t};\n}\n\nconst proto = Object.defineProperties(() => {}, {\n\t...styles,\n\tlevel: {\n\t\tenumerable: true,\n\t\tget() {\n\t\t\treturn this[GENERATOR].level;\n\t\t},\n\t\tset(level) {\n\t\t\tthis[GENERATOR].level = level;\n\t\t},\n\t},\n});\n\nconst createStyler = (open, close, parent) => {\n\tlet openAll;\n\tlet closeAll;\n\tif (parent === undefined) {\n\t\topenAll = open;\n\t\tcloseAll = close;\n\t} else {\n\t\topenAll = parent.openAll + open;\n\t\tcloseAll = close + parent.closeAll;\n\t}\n\n\treturn {\n\t\topen,\n\t\tclose,\n\t\topenAll,\n\t\tcloseAll,\n\t\tparent,\n\t};\n};\n\nconst createBuilder = (self, _styler, _isEmpty) => {\n\t// Single argument is hot path, implicit coercion is faster than anything\n\t// eslint-disable-next-line no-implicit-coercion\n\tconst builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));\n\n\t// We alter the prototype because we must return a function, but there is\n\t// no way to create a function with a different prototype\n\tObject.setPrototypeOf(builder, proto);\n\n\tbuilder[GENERATOR] = self;\n\tbuilder[STYLER] = _styler;\n\tbuilder[IS_EMPTY] = _isEmpty;\n\n\treturn builder;\n};\n\nconst applyStyle = (self, string) => {\n\tif (self.level <= 0 || !string) {\n\t\treturn self[IS_EMPTY] ? '' : string;\n\t}\n\n\tlet styler = self[STYLER];\n\n\tif (styler === undefined) {\n\t\treturn string;\n\t}\n\n\tconst {openAll, closeAll} = styler;\n\tif (string.includes('\\u001B')) {\n\t\twhile (styler !== undefined) {\n\t\t\t// Replace any instances already present with a re-opening code\n\t\t\t// otherwise only the part of the string until said closing code\n\t\t\t// will be colored, and the rest will simply be 'plain'.\n\t\t\tstring = stringReplaceAll(string, styler.close, styler.open);\n\n\t\t\tstyler = styler.parent;\n\t\t}\n\t}\n\n\t// We can move both next actions out of loop, because remaining actions in loop won't have\n\t// any/visible effect on parts we add here. Close the styling before a linebreak and reopen\n\t// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92\n\tconst lfIndex = string.indexOf('\\n');\n\tif (lfIndex !== -1) {\n\t\tstring = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);\n\t}\n\n\treturn openAll + string + closeAll;\n};\n\nObject.defineProperties(createChalk.prototype, styles);\n\nconst chalk = createChalk();\nexport const chalkStderr = createChalk({level: stderrColor ? stderrColor.level : 0});\n\nexport {\n\tmodifierNames,\n\tforegroundColorNames,\n\tbackgroundColorNames,\n\tcolorNames,\n\n\t// TODO: Remove these aliases in the next major version\n\tmodifierNames as modifiers,\n\tforegroundColorNames as foregroundColors,\n\tbackgroundColorNames as backgroundColors,\n\tcolorNames as colors,\n} from './vendor/ansi-styles/index.js';\n\nexport {\n\tstdoutColor as supportsColor,\n\tstderrColor as supportsColorStderr,\n};\n\nexport default chalk;\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport async function updateFactory(jsxFolder: string, typesFolder: string) {\n await Promise.all([updateFactoryFile(jsxFolder), updateFactoryTypes(typesFolder)]);\n}\n\nasync function updateFactoryFile(jsxFolder: string) {\n const factoryFile = path.join(jsxFolder, \"factory.js\");\n await fs.writeFile(factoryFile, factoryFileNewContent);\n}\n\nasync function updateFactoryTypes(typesFolder: string) {\n const factoryFile = path.join(typesFolder, \"jsx.d.ts\");\n let factoryFileContent = await fs.readFile(factoryFile, \"utf8\");\n\n factoryFileContent = factoryFileContent.replace(\n `import type { ElementType, JSX, ComponentPropsWithRef, ComponentType, Component } from 'react'`,\n `import type { ElementType, ReactNode, JSX, ComponentPropsWithRef, ComponentType, Component } from 'react'`\n );\n\n factoryFileContent = factoryFileContent.replace(\n `export interface AsProps {\n /**\n * The element to render as\n */\n as?: ElementType | undefined\n}`,\n `export interface AsProps {\n /**\n * The element to render as\n */\n as?: ElementType | ReactNode | undefined\n /**\n * If \\`true\\`, the component will render the child as a component.\n * @default false\n */\n asChild?: boolean;\n}`\n );\n\n await fs.writeFile(factoryFile, factoryFileContent);\n}\n\nconst factoryFileNewContent = `import { Children, cloneElement, createElement, forwardRef, isValidElement, useMemo } from \"react\";\nimport { css, cva, cx } from \"../css/index.js\";\nimport { normalizeHTMLProps, splitProps } from \"../helpers.js\";\nimport {\n composeCvaFn,\n composeShouldForwardProps,\n defaultShouldForwardProp,\n getDisplayName\n} from \"./factory-helper.js\";\nimport { isCssProperty } from \"./is-valid-prop.js\";\n\nfunction setRef(ref, value) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null && ref !== undefined) {\n ref.current = value;\n }\n}\n\nfunction composeRefs(...refs) {\n return (node) => {\n for (const ref of refs) setRef(ref, node);\n };\n}\n\nfunction styledFn(Dynamic, configOrCva = {}, options = {}) {\n const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva);\n\n const forwardFn = options.shouldForwardProp || defaultShouldForwardProp;\n const shouldForwardProp = (prop) => {\n if (options.forwardProps?.includes(prop)) return true;\n return forwardFn(prop, cvaFn.variantKeys);\n };\n\n const defaultProps = Object.assign(\n options.dataAttr && configOrCva.__name__ ? { \"data-recipe\": configOrCva.__name__ } : {},\n options.defaultProps\n );\n\n const __cvaFn__ = composeCvaFn(Dynamic?.__cva__, cvaFn);\n const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp);\n const __base__ = Dynamic?.__base__ || Dynamic;\n\n const DreamyComponent = /* @__PURE__ */ forwardRef(function DreamyComponent(props, ref) {\n const { as: Element = __base__, unstyled, children, asChild, ...restProps } = props;\n\n const combinedProps = useMemo(\n () => Object.assign({}, defaultProps, restProps),\n [restProps]\n );\n\n const [htmlProps, forwardedProps, variantProps, styleProps, elementProps] = useMemo(() => {\n return splitProps(\n combinedProps,\n normalizeHTMLProps.keys,\n __shouldForwardProps__,\n __cvaFn__.variantKeys,\n isCssProperty\n );\n }, [combinedProps]);\n\n function recipeClass() {\n const { css: cssStyles, ...propStyles } = styleProps;\n const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);\n return cx(\n __cvaFn__(variantProps, false),\n css(compoundVariantStyles, propStyles, cssStyles),\n combinedProps.className\n );\n }\n\n function cvaClass() {\n const { css: cssStyles, ...propStyles } = styleProps;\n const cvaStyles = __cvaFn__.raw(variantProps);\n return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.className);\n }\n\n function classes() {\n if (unstyled) {\n const { css: cssStyles, ...propStyles } = styleProps;\n return cx(css(propStyles, cssStyles), combinedProps.className);\n }\n return configOrCva.__recipe__ ? recipeClass() : cvaClass();\n }\n\n if (asChild) {\n const onlyChild = Children.only(children);\n\n if (!isValidElement(onlyChild)) {\n return null;\n }\n\n return cloneElement(onlyChild, {\n ref: onlyChild?.ref ? composeRefs(ref, onlyChild?.ref) : ref,\n ...forwardedProps,\n ...elementProps,\n ...normalizeHTMLProps(htmlProps),\n ...(onlyChild?.props || {}),\n className: classes()\n });\n }\n\n if (typeof Element === \"object\" && !(\"render\" in Element) && Element !== null) {\n return createElement(\n Element?.type || __base__,\n {\n ref: Element?.ref ? composeRefs(ref, Element?.ref) : ref,\n ...forwardedProps,\n ...elementProps,\n ...normalizeHTMLProps(htmlProps),\n ...(Element?.props || {}),\n className: classes()\n },\n children ?? combinedProps.children\n );\n }\n\n return createElement(\n Element,\n {\n ref,\n ...forwardedProps,\n ...elementProps,\n ...normalizeHTMLProps(htmlProps),\n className: classes()\n },\n children ?? combinedProps.children\n );\n });\n\n const name = getDisplayName(__base__);\n\n DreamyComponent.displayName = \\`dreamy.\\${name}\\`;\n DreamyComponent.__cva__ = __cvaFn__;\n DreamyComponent.__base__ = __base__;\n DreamyComponent.__shouldForwardProps__ = shouldForwardProp;\n\n return DreamyComponent;\n}\n\nfunction createJsxFactory() {\n const cache = new Map();\n\n return new Proxy(styledFn, {\n apply(_, __, args) {\n return styledFn(...args);\n },\n get(_, el) {\n if (!cache.has(el)) {\n cache.set(el, styledFn(el));\n }\n return cache.get(el);\n }\n });\n}\n\nexport const dreamy = /* @__PURE__ */ createJsxFactory();\n`;\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport async function removeJsxElements(jsxFolder: string) {\n\tconst files = await fs.readdir(jsxFolder);\n\tfor (const file of files) {\n\t\tif (\n\t\t\t![\"index\", \"factory\", \"is-valid-prop\", \"create-style-context\"].some((prefix) =>\n\t\t\t\tfile.startsWith(prefix)\n\t\t\t)\n\t\t) {\n\t\t\tawait fs.unlink(path.join(jsxFolder, file));\n\t\t}\n\t}\n\n\tlet js: \"mjs\" | \"js\" | \"both\" = \"js\";\n\n\t// read the index.js and index.mjs files\n\tconst indexJs = await fs.readFile(path.join(jsxFolder, \"index.js\"), \"utf-8\").catch(() => null);\n\tconst indexMjs = await fs\n\t\t.readFile(path.join(jsxFolder, \"index.mjs\"), \"utf-8\")\n\t\t.catch(() => null);\n\n\tif (indexJs && indexMjs) {\n\t\tjs = \"both\";\n\t} else if (indexJs) {\n\t\tjs = \"js\";\n\t} else if (indexMjs) {\n\t\tjs = \"mjs\";\n\t}\n\n\tconst indexContent = `export * from './factory.js';\nexport * from './is-valid-prop.js';\nexport * from './create-style-context.js';\n`;\n\n\t// write the index files\n\tawait Promise.all([\n\t\t(js === \"js\" || js === \"both\") &&\n\t\t\tfs.writeFile(path.join(jsxFolder, \"index.js\"), indexContent),\n\t\t(js === \"mjs\" || js === \"both\") &&\n\t\t\tfs.writeFile(path.join(jsxFolder, \"index.mjs\"), indexContent),\n\t\tfs.writeFile(\n\t\t\tpath.join(jsxFolder, \"index.d.ts\"),\n\t\t\t`export * from './factory';\nexport * from './is-valid-prop';\nexport * from './create-style-context';\nexport type { HTMLDreamyProps, DreamyComponent } from '../types/jsx';`\n\t\t)\n\t]);\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport chalk from \"chalk\";\n\nexport async function ensureStyledSystemExists(cwd: string) {\n const styledSystemFolder = path.join(cwd, \"styled-system\");\n if (!(await fs.stat(styledSystemFolder)).isDirectory()) {\n console.error(chalk.blue(`❌ ${chalk.red(\"styled-system\")} folder does not exist.`));\n throw new Error(\"styled-system folder does not exist\");\n }\n\n return styledSystemFolder;\n}\n\nexport async function ensureTypesFolderExists(styledFolder: string) {\n const typesFolder = path.join(styledFolder, \"types\");\n if (!(await fs.stat(typesFolder)).isDirectory()) {\n console.error(chalk.blue(`❌ ${chalk.red(\"types\")} folder does not exist in ${chalk.green(styledFolder)}.`));\n throw new Error(\"types folder does not exist\");\n }\n\n return typesFolder;\n}\n\nexport async function ensureJsxFolderExists(styledFolder: string) {\n const jsxFolder = path.join(styledFolder, \"jsx\");\n if (!(await fs.stat(jsxFolder)).isDirectory()) {\n console.error(\n chalk.blue(\n `❌ ${chalk.red(\n \"jsx\"\n )} folder does not exist in styled-system. Did you forget to add ${chalk.green(\n \"jsxFramework: 'react'\"\n )} to the ${chalk.green(\"panda.config.ts\")}?`\n )\n );\n throw new Error(\"jsx folder does not exist\");\n }\n\n return jsxFolder;\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport async function removeFactoryFromStyleContext(jsxFolder: string) {\n const files = await fs\n .readdir(jsxFolder)\n .then((files) => files.filter((file) => !file.endsWith(\"d.ts\")));\n const styleContextFile = files.find((file) => file.startsWith(\"create-style-context\"));\n console.log(\"styleContextFile\", styleContextFile);\n\n if (!styleContextFile) {\n throw new Error(`create-style-context.js file not found in ${jsxFolder}`);\n }\n\n const newContent = `\"use client\";\n\nimport { createContext, createElement, forwardRef, useContext } from \"react\";\nimport { cx, sva } from \"../css/index.js\";\nimport { getDisplayName } from \"./factory-helper.js\";\n\nfunction createSafeContext(contextName) {\n const Context = createContext(undefined);\n const useStyleContext = (componentName, slot) => {\n const context = useContext(Context);\n if (context === undefined) {\n const componentInfo = componentName ? \\`Component \"\\${componentName}\"\\` : \"A component\";\n const slotInfo = slot ? \\` (slot: \"\\${slot}\")\\` : \"\";\n\n throw new Error(\n \\`\\${componentInfo}\\${slotInfo} cannot access \\${contextName} because it's missing its Provider.\\`\n );\n }\n return context;\n };\n return [Context, useStyleContext];\n}\n\nexport function createStyleContext(recipe, styleContextOptions = {}) {\n const isConfigRecipe = \"__recipe__\" in recipe;\n const recipeName = isConfigRecipe && recipe.__name__ ? recipe.__name__ : undefined;\n const contextName = recipeName ? \\`createStyleContext(\"\\${recipeName}\")\\` : \"createStyleContext\";\n const forwardVariants = styleContextOptions.forwardVariants ?? [];\n\n const [StyleContext, useStyleContext] = createSafeContext(contextName);\n const svaFn = isConfigRecipe ? recipe : sva(recipe.config);\n\n function getForwardedVariantProps(variantProps) {\n if (!forwardVariants.length) {\n return {};\n }\n\n return forwardVariants.reduce((accumulator, variantKey) => {\n if (variantProps[variantKey] !== undefined) {\n accumulator[variantKey] = variantProps[variantKey];\n }\n return accumulator;\n }, {});\n }\n\n const getResolvedProps = (props, slotStyles) => {\n const { unstyled, ...restProps } = props;\n if (unstyled) return restProps;\n if (isConfigRecipe) {\n return { ...restProps, className: cx(slotStyles, restProps.className) };\n }\n return { ...slotStyles, ...restProps };\n };\n\n const withRootProvider = (Component, options) => {\n const WithRootProvider = (props) => {\n const [variantProps, otherProps] = svaFn.splitVariantProps(props);\n const forwardedVariantProps = getForwardedVariantProps(variantProps);\n\n const slotStyles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps);\n slotStyles._classNameMap = svaFn.classNameMap;\n\n const mergedProps = options?.defaultProps\n ? { ...options.defaultProps, ...otherProps }\n : otherProps;\n\n return createElement(StyleContext.Provider, {\n value: slotStyles,\n children: createElement(Component, { ...mergedProps, ...forwardedVariantProps })\n });\n };\n\n const componentName = getDisplayName(Component);\n WithRootProvider.displayName = \\`withRootProvider(\\${componentName})\\`;\n\n return WithRootProvider;\n };\n\n const withProvider = (Component, slot, options) => {\n const WithProvider = forwardRef((props, ref) => {\n const [variantProps, restProps] = svaFn.splitVariantProps(props);\n const forwardedVariantProps = getForwardedVariantProps(variantProps);\n\n const slotStyles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps);\n slotStyles._classNameMap = svaFn.classNameMap;\n\n const propsWithClass = {\n ...restProps,\n ...options?.defaultProps,\n ...forwardedVariantProps,\n className: restProps.className ?? options?.defaultProps?.className\n };\n const resolvedProps = getResolvedProps(propsWithClass, slotStyles[slot]);\n return createElement(StyleContext.Provider, {\n value: slotStyles,\n children: createElement(Component, {\n ...resolvedProps,\n className: cx(resolvedProps.className, slotStyles._classNameMap[slot]),\n ref\n })\n });\n });\n\n const componentName = getDisplayName(Component);\n WithProvider.displayName = \\`withProvider(\\${componentName})\\`;\n\n return WithProvider;\n };\n\n const withContext = (Component, slot, options) => {\n const componentName = getDisplayName(Component);\n\n const WithContext = forwardRef((props, ref) => {\n const slotStyles = useStyleContext(componentName, slot);\n\n const propsWithClass = {\n ...props,\n ...options?.defaultProps,\n className: props.className ?? options?.defaultProps?.className\n };\n const resolvedProps = getResolvedProps(propsWithClass, slotStyles[slot]);\n return createElement(Component, {\n ...resolvedProps,\n className: cx(resolvedProps.className, slotStyles._classNameMap[slot]),\n ref\n });\n });\n\n WithContext.displayName = \\`withContext(\\${componentName})\\`;\n\n return WithContext;\n };\n\n return {\n withRootProvider,\n withProvider,\n withContext\n };\n}\n`;\n\n await fs.writeFile(path.join(jsxFolder, styleContextFile), newContent);\n}\n\nexport async function updateStyleContextTypes(jsxFolder: string) {\n const dtsPath = path.join(jsxFolder, \"create-style-context.d.ts\");\n try {\n const content = await fs.readFile(dtsPath, \"utf-8\");\n const withoutJsxStyleProps = content.replace(/, JsxStyleProps/g, \"\");\n\n const styleContextOptionsInterface = `interface StyleContextOptions {\n forwardVariants?: string[] | undefined\n}\n\n`;\n const withStyleContextOptionsInterface = withoutJsxStyleProps.includes(\n \"interface StyleContextOptions {\"\n )\n ? withoutJsxStyleProps\n : withoutJsxStyleProps.replace(\n \"type StyleContextConsumer<T extends ElementType> = ComponentType<\\n JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps>\\n>\\n\\n\",\n \"type StyleContextConsumer<T extends ElementType> = ComponentType<\\n JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps>\\n>\\n\\n\" +\n styleContextOptionsInterface\n );\n\n const newContent = withStyleContextOptionsInterface.replace(\n /export declare function createStyleContext<R extends SlotRecipe>\\(recipe: R\\): StyleContext<R>/,\n \"export declare function createStyleContext<R extends SlotRecipe>(recipe: R, options?: StyleContextOptions | undefined): StyleContext<R>\"\n );\n await fs.writeFile(dtsPath, newContent);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n // create-style-context.d.ts not generated yet (e.g. first run), skip\n }\n}\n","import type { SystemStyleObject } from \"@pandacss/dev\";\n\nconst schemeNames = [\n \"primary\",\n \"secondary\",\n \"success\",\n \"warning\",\n \"error\",\n \"info\",\n \"none\"\n] as const;\n\ntype SchemeName = (typeof schemeNames)[number];\ntype ColorSchemes = Record<SchemeName, string>;\n\nconst schemes: ColorSchemes = {\n primary: \"{colors.primary}\",\n secondary: \"{colors.secondary}\",\n success: \"{colors.success}\",\n warning: \"{colors.warning}\",\n error: \"{colors.error}\",\n info: \"{colors.info}\",\n none: \"{colors.fg.max}\"\n};\n\nexport function getColorSchemes<T extends string>(\n cssVar: string,\n schemeProps?: (scheme: SchemeName) => Record<any, SystemStyleObject>,\n /**\n * if it is a slot recipe, select a main slot to apply the color scheme\n */\n slot?: T,\n generateFg = false\n): Record<\n SchemeName,\n T extends string ? Record<T, Record<any, SystemStyleObject>> : Record<any, SystemStyleObject>\n> {\n const entries = Object.fromEntries(\n schemeNames.map((scheme) => {\n const val = slot\n ? {\n [slot]: {\n [cssVar]: schemes[scheme] as any,\n ...schemeProps?.(scheme),\n ...(generateFg ? { [cssVar + \"-fg\"]: addFgToTheScheme(scheme) } : {})\n }\n }\n : {\n [cssVar]: schemes[scheme] as any,\n ...schemeProps?.(scheme)\n };\n\n return [scheme, val as Record<any, SystemStyleObject>];\n })\n );\n\n return Object.assign({}, entries) as any;\n}\n\nfunction addFgToTheScheme(scheme: SchemeName) {\n const s = schemes[scheme];\n\n if (scheme !== \"none\") {\n return s.replace(\"}\", \".fg}\");\n }\n\n return \"{colors.bg}\";\n}\n","export function mapJsx(root: string, jsx: string[]) {\n return jsx.map((item) => `${root}.${item}`);\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { resolveButtonColors } from \"@/theme/resolve-button-colors\";\nimport { createSemanticTokens } from \"@/theme/semantic-tokens\";\nimport { createTokens } from \"@/theme/tokens\";\nimport type { BorderRadius, DeepPartial } from \"@/types\";\nimport { type Preset, definePreset } from \"@pandacss/dev\";\nimport deepmerge from \"deepmerge\";\nimport { breakpoints } from \"./breakpoints\";\nimport { conditions } from \"./conditions\";\nimport { containerSizes } from \"./containerSizes\";\nimport { globalCss } from \"./global-css\";\nimport { keyframes } from \"./keyframes\";\nimport { staticCss } from \"./staticCss\";\nimport { textStyles } from \"./text-styles\";\nimport { utilities } from \"./utils/index\";\n\ninterface LightDarkColor {\n light: string;\n dark: string;\n}\n\nexport interface LightDarkNumber {\n light: number;\n dark: number;\n}\n\n/** Per-token lightness offset for foreground tokens (OKLCH 0–1 scale). */\nexport interface FgLightnessOffset {\n /** `fg.max` token — the most prominent text (e.g. headings). */\n max?: number | LightDarkNumber;\n /** `fg` / `fg.normal` token — default body text. */\n normal?: number | LightDarkNumber;\n /** `fg.medium` token — secondary / muted text. */\n medium?: number | LightDarkNumber;\n /** `fg.disabled` token — disabled state text. */\n disabled?: number | LightDarkNumber;\n}\n\n/** Per-token lightness offset for border tokens (OKLCH 0–1 scale). */\nexport interface BorderLightnessOffset {\n /**\n * `border` / `border.default` token.\n * @default fgLightnessOffset.normal when `borderLightnessOffset` is not set\n */\n default?: number | LightDarkNumber;\n /**\n * `border.muted` token.\n * @default fgLightnessOffset.disabled when `borderLightnessOffset` is not set\n */\n muted?: number | LightDarkNumber;\n /**\n * `border.hover` token.\n * @default fgLightnessOffset.normal when `borderLightnessOffset` is not set\n */\n hover?: number | LightDarkNumber;\n}\n\ninterface ColorTuning {\n /**\n * Multiplier applied to the computed foreground token chroma (color tint intensity).\n * Values above `1` increase the color tint of text tokens; values below `1` make them\n * more neutral/grayscale. The result is still clamped to safe bounds.\n * Provide a `{ light, dark }` object to tune each color mode independently.\n * @default 1\n */\n fgChromaScale?: number | LightDarkNumber;\n /**\n * Multiplier applied to the computed border token chroma (color tint intensity).\n * Values above `1` increase the color tint of border tokens; values below `1` make them\n * more neutral/grayscale. The result is still clamped to safe bounds.\n * Provide a `{ light, dark }` object to tune each color mode independently.\n * @default fgChromaScale (falls back to 1 if that is also not set)\n */\n borderChromaScale?: number | LightDarkNumber;\n /**\n * Per-token lightness offset for foreground tokens (OKLCH 0–1 scale).\n * Positive values brighten a token; negative values darken it.\n * Omitted tokens are left at their default lightness.\n */\n fgLightnessOffset?: FgLightnessOffset;\n /**\n * Per-token lightness offset for border tokens (OKLCH 0–1 scale).\n * When this entire option is omitted, border tokens fall back to corresponding\n * fg offsets: `default` ← `fg.normal`, `muted` ← `fg.disabled`, `hover` ← `fg.normal`.\n */\n borderLightnessOffset?: BorderLightnessOffset;\n}\n\nexport interface PresetOptions {\n backgrounds: {\n light: string;\n dark: string;\n };\n fonts: {\n body: string;\n heading: string;\n mono: string;\n };\n primaryColor: string | LightDarkColor;\n secondaryColor: string | LightDarkColor;\n rounded: BorderRadius;\n /**\n * Color for the primary button. It depends on the `primaryColor` option.\n * @default Dreamy UI will automatically resolve contrast to match the `primaryColor` option.\n */\n buttonPrimaryTextColor: string | LightDarkColor;\n /**\n * Color for the secondary button. It depends on the `secondaryColor` option.\n * @default Dreamy UI will automatically resolve contrast to match the `secondaryColor` option.\n */\n buttonSecondaryTextColor: string | LightDarkColor;\n /**\n * Fine-tune the chroma (color tint intensity) of auto-generated foreground and border tokens.\n * Useful when the default generation feels too colorful or too neutral for a given background.\n */\n colorTuning?: ColorTuning;\n}\n\nexport const defaultPresetOptions = {\n backgrounds: {\n light: \"#fff\",\n dark: \"#0D0D0E\"\n },\n fonts: {\n body: \"sans-serif\",\n heading: \"sans-serif\",\n mono: \"monospace\"\n },\n primaryColor: {\n light: \"#000000\",\n dark: \"#ffffff\"\n },\n secondaryColor: {\n light: \"#000000\",\n dark: \"#ffffff\"\n },\n // buttonPrimaryTextColor: \"{colors.bg}\",\n // buttonSecondaryTextColor: \"{colors.bg}\",\n rounded: \"md\"\n} satisfies Omit<PresetOptions, \"buttonPrimaryTextColor\" | \"buttonSecondaryTextColor\">;\n\nconst presetStorage = new AsyncLocalStorage<PresetOptions>();\n\nexport function getPresetOptions() {\n const options = presetStorage.getStore();\n if (!options) {\n throw new Error(\n \"Preset options not found in async local storage. Make sure to call setPresetOptions() first.\"\n );\n }\n return options;\n}\n\nexport function setPresetOptions(options: PresetOptions) {\n void presetStorage.enterWith(options);\n}\n\nexport default function createDreamyPreset(\n optionsArg: DeepPartial<PresetOptions> = defaultPresetOptions\n): Preset {\n if (!optionsArg.fonts?.heading && optionsArg.fonts?.body) {\n optionsArg.fonts.heading = optionsArg.fonts.body;\n }\n const options = deepmerge(defaultPresetOptions, optionsArg) as PresetOptions;\n\n // Set options in async local storage for other functions to access\n return presetStorage.run(options, () => {\n resolveButtonColors();\n\n const semanticTokens = createSemanticTokens();\n const tokens = createTokens();\n\n const preset = definePreset({\n name: \"@dreamy-ui/panda-preset\",\n conditions,\n theme: {\n extend: {\n colorPalette: {\n enabled: false\n },\n textStyles,\n tokens,\n semanticTokens,\n keyframes,\n breakpoints,\n containerSizes\n }\n },\n globalCss,\n utilities,\n staticCss\n