@wow-two-beta/fe 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/chunks/{AppSwitcherMenu.vue_vue_type_script_setup_true_lang-DVqdOOst.js → AccountMenu.vue_vue_type_script_setup_true_lang-CWsiHHiy.js} +700 -283
  2. package/dist/chunks/AccountMenu.vue_vue_type_script_setup_true_lang-CWsiHHiy.js.map +1 -0
  3. package/dist/chunks/Avatar.vue_vue_type_script_setup_true_lang-BIoaOjCh.js +267 -0
  4. package/dist/chunks/Avatar.vue_vue_type_script_setup_true_lang-BIoaOjCh.js.map +1 -0
  5. package/dist/chunks/{BackToTopButton.vue_vue_type_script_setup_true_lang-CNMcUYtR.js → BackToTopButton.vue_vue_type_script_setup_true_lang-6tfkqsrZ.js} +2 -2
  6. package/dist/chunks/{BackToTopButton.vue_vue_type_script_setup_true_lang-CNMcUYtR.js.map → BackToTopButton.vue_vue_type_script_setup_true_lang-6tfkqsrZ.js.map} +1 -1
  7. package/dist/chunks/{Button.vue_vue_type_script_setup_true_lang-BrgCAsgC.js → Button.vue_vue_type_script_setup_true_lang-Cw0QS_Mm.js} +2 -3
  8. package/dist/chunks/{Button.vue_vue_type_script_setup_true_lang-BrgCAsgC.js.map → Button.vue_vue_type_script_setup_true_lang-Cw0QS_Mm.js.map} +1 -1
  9. package/dist/chunks/{DrawerContent.vue_vue_type_script_setup_true_lang-CZQnfNGk.js → DrawerContent.vue_vue_type_script_setup_true_lang-BA-au7LC.js} +2 -2
  10. package/dist/chunks/{DrawerContent.vue_vue_type_script_setup_true_lang-CZQnfNGk.js.map → DrawerContent.vue_vue_type_script_setup_true_lang-BA-au7LC.js.map} +1 -1
  11. package/dist/chunks/{ErrorBoundary.vue_vue_type_script_setup_true_lang-LRQbVAiW.js → ErrorBoundary.vue_vue_type_script_setup_true_lang-DzqE0ZF8.js} +4 -4
  12. package/dist/chunks/{ErrorBoundary.vue_vue_type_script_setup_true_lang-LRQbVAiW.js.map → ErrorBoundary.vue_vue_type_script_setup_true_lang-DzqE0ZF8.js.map} +1 -1
  13. package/dist/chunks/{FieldHelperText.vue_vue_type_script_setup_true_lang-eqG5AyoV.js → FieldHelperText.vue_vue_type_script_setup_true_lang-DuMcXUch.js} +2 -2
  14. package/dist/chunks/{FieldHelperText.vue_vue_type_script_setup_true_lang-eqG5AyoV.js.map → FieldHelperText.vue_vue_type_script_setup_true_lang-DuMcXUch.js.map} +1 -1
  15. package/dist/chunks/{KanbanCard.vue_vue_type_script_setup_true_lang-BCnquIre.js → KanbanCard.vue_vue_type_script_setup_true_lang-CyXb4ZZw.js} +169 -427
  16. package/dist/chunks/KanbanCard.vue_vue_type_script_setup_true_lang-CyXb4ZZw.js.map +1 -0
  17. package/dist/chunks/{LightboxModal.vue_vue_type_script_setup_true_lang-Dm79L1eK.js → LightboxModal.vue_vue_type_script_setup_true_lang-BxdSYLYf.js} +6 -6
  18. package/dist/chunks/{LightboxModal.vue_vue_type_script_setup_true_lang-Dm79L1eK.js.map → LightboxModal.vue_vue_type_script_setup_true_lang-BxdSYLYf.js.map} +1 -1
  19. package/dist/chunks/{MasonryLayout.vue_vue_type_script_setup_true_lang-2CWeHWdV.js → MasonryLayout.vue_vue_type_script_setup_true_lang-DD_jRzkM.js} +4 -4
  20. package/dist/chunks/{MasonryLayout.vue_vue_type_script_setup_true_lang-2CWeHWdV.js.map → MasonryLayout.vue_vue_type_script_setup_true_lang-DD_jRzkM.js.map} +1 -1
  21. package/dist/chunks/{MentionInput.vue_vue_type_script_setup_true_lang-DdT24dkW.js → MentionInput.vue_vue_type_script_setup_true_lang-hYD3uP3P.js} +6 -6
  22. package/dist/chunks/{MentionInput.vue_vue_type_script_setup_true_lang-DdT24dkW.js.map → MentionInput.vue_vue_type_script_setup_true_lang-hYD3uP3P.js.map} +1 -1
  23. package/dist/chunks/{OverlayCloseButton.vue_vue_type_script_setup_true_lang-D01KYAAn.js → OverlayCloseButton.vue_vue_type_script_setup_true_lang-Df9raD_m.js} +2 -2
  24. package/dist/chunks/{OverlayCloseButton.vue_vue_type_script_setup_true_lang-D01KYAAn.js.map → OverlayCloseButton.vue_vue_type_script_setup_true_lang-Df9raD_m.js.map} +1 -1
  25. package/dist/chunks/{PopoverContent.vue_vue_type_script_setup_true_lang-BIHYpwzT.js → PopoverContent.vue_vue_type_script_setup_true_lang-C6YKEo3H.js} +2 -2
  26. package/dist/chunks/{PopoverContent.vue_vue_type_script_setup_true_lang-BIHYpwzT.js.map → PopoverContent.vue_vue_type_script_setup_true_lang-C6YKEo3H.js.map} +1 -1
  27. package/dist/chunks/{ReportAction.vue_vue_type_script_setup_true_lang-l4DjtcpM.js → ReportAction.vue_vue_type_script_setup_true_lang-DCnPCczd.js} +2 -2
  28. package/dist/chunks/{ReportAction.vue_vue_type_script_setup_true_lang-l4DjtcpM.js.map → ReportAction.vue_vue_type_script_setup_true_lang-DCnPCczd.js.map} +1 -1
  29. package/dist/chunks/{SurfaceStyles-B8KNkFsm.js → SurfaceStyles-BYvRlsWe.js} +2 -2
  30. package/dist/chunks/{SurfaceStyles-B8KNkFsm.js.map → SurfaceStyles-BYvRlsWe.js.map} +1 -1
  31. package/dist/chunks/{ToastHost.vue_vue_type_script_setup_true_lang-p0bfXJ9l.js → ToastHost.vue_vue_type_script_setup_true_lang-J1ZPZXn3.js} +3 -3
  32. package/dist/chunks/{ToastHost.vue_vue_type_script_setup_true_lang-p0bfXJ9l.js.map → ToastHost.vue_vue_type_script_setup_true_lang-J1ZPZXn3.js.map} +1 -1
  33. package/dist/chunks/{Tones-CQu-OvAk.js → Tones-Bcz8dIo3.js} +159 -1
  34. package/dist/chunks/Tones-Bcz8dIo3.js.map +1 -0
  35. package/dist/chunks/{index-C-r59Hob.js → index-CGIXFfl9.js} +3 -4
  36. package/dist/chunks/{index-C-r59Hob.js.map → index-CGIXFfl9.js.map} +1 -1
  37. package/dist/foundation/config/ConfigSource.d.ts +12 -5
  38. package/dist/foundation/config/DefineConfig.d.ts +9 -4
  39. package/dist/foundation/config/index.d.ts +1 -1
  40. package/dist/foundation/config/index.js +12 -9
  41. package/dist/foundation/config/index.js.map +1 -1
  42. package/dist/foundation/styles/index.js +9 -10
  43. package/dist/foundation/styles/index.js.map +1 -1
  44. package/dist/index.js +465 -463
  45. package/dist/index.js.map +1 -1
  46. package/dist/presentation/actions/index.js +2 -2
  47. package/dist/presentation/display/index.js +178 -177
  48. package/dist/presentation/display/index.js.map +1 -1
  49. package/dist/presentation/feedback/index.js +3 -3
  50. package/dist/presentation/feedback/toastHost/index.js +1 -1
  51. package/dist/presentation/forms/index.js +2 -2
  52. package/dist/presentation/layout/index.js +1 -1
  53. package/dist/presentation/nav/accountMenu/AccountMenu.vue.d.ts +131 -0
  54. package/dist/presentation/nav/accountMenu/index.d.ts +1 -0
  55. package/dist/presentation/nav/index.d.ts +1 -0
  56. package/dist/presentation/nav/index.js +72 -71
  57. package/dist/presentation/overlays/index.js +4 -4
  58. package/package.json +1 -1
  59. package/dist/chunks/AppSwitcherMenu.vue_vue_type_script_setup_true_lang-DVqdOOst.js.map +0 -1
  60. package/dist/chunks/CssExtensions-ctGVlfYU.js +0 -161
  61. package/dist/chunks/CssExtensions-ctGVlfYU.js.map +0 -1
  62. package/dist/chunks/KanbanCard.vue_vue_type_script_setup_true_lang-BCnquIre.js.map +0 -1
  63. package/dist/chunks/Tones-CQu-OvAk.js.map +0 -1
@@ -108,13 +108,16 @@ function list(options) {
108
108
  );
109
109
  }
110
110
  const DefaultRuntimeConfigKey = "__APP_CONFIG__";
111
- function importMetaEnvSource() {
112
- try {
113
- const meta = import.meta;
114
- return meta.env ?? {};
115
- } catch {
116
- return {};
111
+ function importMetaEnvSource(env) {
112
+ const values = /* @__PURE__ */ Object.create(null);
113
+ if (env === null || typeof env !== "object") return Object.freeze(values);
114
+ for (const key of Object.keys(env)) {
115
+ const value = env[key];
116
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
117
+ values[key] = String(value);
118
+ }
117
119
  }
120
+ return Object.freeze(values);
118
121
  }
119
122
  function windowConfigSource(globalKey = DefaultRuntimeConfigKey) {
120
123
  if (typeof window === "undefined") return {};
@@ -125,8 +128,8 @@ function windowConfigSource(globalKey = DefaultRuntimeConfigKey) {
125
128
  function staticSource(values) {
126
129
  return values;
127
130
  }
128
- function defaultSources() {
129
- return [windowConfigSource(), importMetaEnvSource()];
131
+ function defaultSources(env) {
132
+ return env === void 0 ? [windowConfigSource()] : [windowConfigSource(), importMetaEnvSource(env)];
130
133
  }
131
134
  function resolveRaw(sources, key) {
132
135
  for (const source of sources) {
@@ -152,7 +155,7 @@ ${lines}`);
152
155
  }
153
156
  }
154
157
  function defineConfig(schema, options) {
155
- const sources = options?.sources ?? defaultSources();
158
+ const sources = options?.sources ?? defaultSources(options?.env);
156
159
  const prefix = options?.prefix ?? "";
157
160
  const resolved = /* @__PURE__ */ Object.create(null);
158
161
  const issues = [];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/foundation/config/ConfigField.ts","../../../src/foundation/config/ConfigSource.ts","../../../src/foundation/config/DefineConfig.ts"],"sourcesContent":["import { LosslessJson } from '../json';\nimport { ResultExtensions, type Result } from '../results';\n\n// Typed-env field specs. A `ConfigField<T>` describes how one configuration key is parsed from its raw\n// string form, whether it is required, and its fallback — the atoms `defineConfig` reads a source through.\n// Each builder (`str`, `num`, `bool`, `oneOf`, `url`, `port`, `json`, `list`) returns a field whose `parse`\n// handles only a *present* raw string and throws a human-readable message on an invalid value; the engine\n// owns the missing / default / required decision centrally, so a field never re-implements that policy.\n\n/** Tunes one field's presence policy and fallback. A `default` (or `required: false`) makes the field optional. */\nexport interface ConfigFieldOptions<T> {\n /** Marks the field required. Defaults to `true` unless a `default` is supplied. */\n readonly required?: boolean;\n\n /** The value used when the key is absent or empty. Supplying it makes the field optional. */\n readonly default?: T;\n\n /** Creates an independent fallback for each resolution; use for mutable values. */\n readonly defaultFactory?: () => T;\n\n /** Redacts the raw value from `ConfigError` messages — set for tokens, keys, and passwords. */\n readonly secret?: boolean;\n}\n\n/**\n * Describes a single configuration key: its scalar type, presence policy, and how to parse a present raw\n * string into `T`. `Optional` is a phantom flag the schema inference reads to widen the output to `T | undefined`\n * for a field that is `required: false` with no `default`.\n */\nexport interface ConfigField<T, Optional extends boolean = false> {\n /** The human-facing type name used in error messages (`string`, `number`, `one of [...]`, …). */\n readonly typeName: string;\n\n /** Whether a missing key is an error. `false` when a `default` is present or `required: false`. */\n readonly required: boolean;\n\n /** Whether an explicit `default` was supplied. */\n readonly hasDefault: boolean;\n\n /** The configured fallback, meaningful only when `hasDefault` is `true`. */\n readonly defaultValue?: T;\n\n /** Builds an independent fallback when configured. */\n readonly createDefault?: () => T;\n\n /** Whether the raw value is redacted from error output. */\n readonly secret: boolean;\n\n /** Phantom marker: `true` widens the inferred output type to `T | undefined`. Never read at runtime. */\n readonly __optional?: Optional;\n\n /** Parses a present, non-empty raw string into `T`; throws a `string` message describing the failure. */\n parse(raw: string): T;\n}\n\n/** Computes a field's phantom optionality from its options — optional iff no `default` and `required: false`. */\ntype Optionality<O> = O extends { default: unknown } | { defaultFactory: unknown }\n ? false\n : O extends { required: false }\n ? true\n : false;\n\n/** The upper bound for a field of unknown scalar type — every concrete `ConfigField<T, …>` is assignable to it. */\nexport type AnyConfigField = ConfigField<unknown, boolean>;\n\n/** Shared field constructor — folds the options into the runtime presence policy around a scalar `parse`. */\nfunction createField<T>(\n typeName: string,\n parse: (raw: string) => T,\n options: ConfigFieldOptions<T> | undefined,\n): ConfigField<T, boolean> {\n const hasValue = options !== undefined && Object.hasOwn(options, 'default');\n const hasFactory = options !== undefined && Object.hasOwn(options, 'defaultFactory');\n if (hasValue && hasFactory) throw new TypeError('Choose default or defaultFactory, not both.');\n if (\n hasValue &&\n (options.default === undefined ||\n (typeof options.default === 'object' && options.default !== null) ||\n typeof options.default === 'function')\n ) {\n throw new TypeError('Use defaultFactory for mutable config defaults; undefined is not a default.');\n }\n if (hasFactory && typeof options.defaultFactory !== 'function')\n throw new TypeError('defaultFactory must be a function.');\n const hasDefault = hasValue || hasFactory;\n return Object.freeze({\n typeName,\n parse,\n hasDefault,\n defaultValue: hasValue ? options.default : undefined,\n createDefault: hasFactory ? options.defaultFactory : undefined,\n // A field is required unless it carries a default or is explicitly opted out.\n required: hasDefault ? false : (options?.required ?? true),\n secret: options?.secret ?? false,\n });\n}\n\n/** A string field — preserves the raw value; empty strings are handled as missing by resolution. */\nexport function str<const O extends ConfigFieldOptions<string> = ConfigFieldOptions<string>>(\n options?: O,\n): ConfigField<string, Optionality<O>> {\n return createField('string', (raw) => raw, options) as ConfigField<string, Optionality<O>>;\n}\n\n/** A finite-number field — rejects any raw string that does not parse to a finite JS number. */\nexport function num<const O extends ConfigFieldOptions<number> = ConfigFieldOptions<number>>(\n options?: O,\n): ConfigField<number, Optionality<O>> {\n return createField(\n 'number',\n (raw) => {\n const value = Number(raw);\n if (!Number.isFinite(value)) throw `expected a number, got \"${raw}\"`;\n return value;\n },\n options,\n ) as ConfigField<number, Optionality<O>>;\n}\n\n/** The raw spellings each boolean side accepts, case-insensitively. */\nconst TrueTokens = new Set(['true', '1', 'yes', 'on']);\nconst FalseTokens = new Set(['false', '0', 'no', 'off']);\n\n/** A boolean field — accepts `true/1/yes/on` and `false/0/no/off` (case-insensitive); rejects anything else. */\nexport function bool<const O extends ConfigFieldOptions<boolean> = ConfigFieldOptions<boolean>>(\n options?: O,\n): ConfigField<boolean, Optionality<O>> {\n return createField(\n 'boolean',\n (raw) => {\n const token = raw.trim().toLowerCase();\n if (TrueTokens.has(token)) return true;\n if (FalseTokens.has(token)) return false;\n throw `expected a boolean (true/false/1/0/yes/no/on/off), got \"${raw}\"`;\n },\n options,\n ) as ConfigField<boolean, Optionality<O>>;\n}\n\n/** An enum field — the value must be one of `values`; the output type narrows to that literal union. */\nexport function oneOf<\n const V extends readonly string[],\n const O extends ConfigFieldOptions<V[number]> = ConfigFieldOptions<V[number]>,\n>(values: V, options?: O): ConfigField<V[number], Optionality<O>> {\n return createField(\n `one of [${values.join(', ')}]`,\n (raw) => {\n if ((values as readonly string[]).includes(raw)) return raw as V[number];\n throw `expected one of [${values.join(', ')}], got \"${raw}\"`;\n },\n options,\n ) as ConfigField<V[number], Optionality<O>>;\n}\n\n/** A URL field — validated with the `URL` constructor; the parsed string is returned unchanged. */\nexport function url<const O extends ConfigFieldOptions<string> = ConfigFieldOptions<string>>(\n options?: O,\n): ConfigField<string, Optionality<O>> {\n return createField(\n 'url',\n (raw) => {\n try {\n // Construct-and-discard: `URL` throws on a malformed value; we keep the caller's original string.\n void new URL(raw);\n return raw;\n } catch {\n throw `expected a valid URL, got \"${raw}\"`;\n }\n },\n options,\n ) as ConfigField<string, Optionality<O>>;\n}\n\n/** A TCP-port field — a finite integer in `1..65535`. */\nexport function port<const O extends ConfigFieldOptions<number> = ConfigFieldOptions<number>>(\n options?: O,\n): ConfigField<number, Optionality<O>> {\n return createField(\n 'port',\n (raw) => {\n const value = Number(raw);\n if (!Number.isInteger(value) || value < 1 || value > 65535) throw `expected a port in 1..65535, got \"${raw}\"`;\n return value;\n },\n options,\n ) as ConfigField<number, Optionality<O>>;\n}\n\n/** Validates a parsed JSON value; expected failures carry the decoder's own failure data. */\nexport type ConfigJsonDecoder<T> = (value: unknown) => Result<T, unknown>;\n\n/** Reads JSON without claiming a decoded application shape. Numeric tokens remain ExactNumber values. */\nexport function json<const O extends ConfigFieldOptions<unknown> = ConfigFieldOptions<unknown>>(\n options?: O,\n): ConfigField<unknown, Optionality<O>>;\n/** Decodes a lossless JSON value into a validated application shape; decoder failures reject the field. */\nexport function json<T, const O extends ConfigFieldOptions<T> = ConfigFieldOptions<T>>(\n decode: ConfigJsonDecoder<T>,\n options?: O,\n): ConfigField<T, Optionality<O>>;\nexport function json(\n decodeOrOptions?: ConfigJsonDecoder<unknown> | ConfigFieldOptions<unknown>,\n options?: ConfigFieldOptions<unknown>,\n): ConfigField<unknown, boolean> {\n const decode =\n typeof decodeOrOptions === 'function' ? decodeOrOptions : (value: unknown) => ResultExtensions.ok(value);\n return createField(\n 'json',\n (raw) => {\n const parsed = LosslessJson.parse(raw);\n if (!parsed.ok) throw 'expected valid JSON';\n const decoded = decode(parsed.value);\n if (!decoded.ok) throw 'JSON value failed its decoder';\n return decoded.value;\n },\n typeof decodeOrOptions === 'function' ? options : decodeOrOptions,\n );\n}\n\n/** Tunes how a `list` field splits its raw value. */\nexport interface ListFieldOptions extends ConfigFieldOptions<readonly string[]> {\n /** The item separator. Defaults to a comma. */\n readonly separator?: string;\n}\n\n/** A string-list field — splits on `separator` (default `,`), trims each item, and drops empty items. */\nexport function list<const O extends ListFieldOptions = ListFieldOptions>(\n options?: O,\n): ConfigField<ReadonlyArray<string>, Optionality<O>> {\n const separator = options?.separator ?? ',';\n return createField<readonly string[]>(\n 'list',\n (raw) =>\n raw\n .split(separator)\n .map((item) => item.trim())\n .filter((item) => item.length > 0),\n options,\n ) as ConfigField<readonly string[], Optionality<O>>;\n}\n","// Configuration sources — the raw key/value stores `defineConfig` reads through. Two ship by default: the\n// build-time `import.meta.env` (Vite inlines it at build) and the runtime `window.__APP_CONFIG__` global an ops\n// team can inject per-environment without a rebuild (12-factor runtime config). A source is a flat record of\n// string values; `defineConfig` merges an ordered list where the *earlier* source wins, so runtime config is\n// layered ahead of build-time env by default. Reading a source never throws — an unavailable one yields `{}`.\n\n/** A flat, read-only key/value store of raw configuration strings. */\nexport type ConfigSource = Readonly<Record<string, string | undefined>>;\n\n/** The default runtime-config global — `window.__APP_CONFIG__`, injected per-environment ahead of build-time env. */\nexport const DefaultRuntimeConfigKey = '__APP_CONFIG__';\n\n/**\n * The build-time source — Vite's `import.meta.env`, inlined at build. Returns `{}` outside a bundler context\n * (e.g. a plain Node test) where `import.meta.env` is absent, so it is always safe to include.\n */\nexport function importMetaEnvSource(): ConfigSource {\n try {\n const meta = import.meta as unknown as { env?: Record<string, string | undefined> };\n return meta.env ?? {};\n } catch {\n return {};\n }\n}\n\n/**\n * The runtime source — a global object (default `window.__APP_CONFIG__`) a deployment injects before the app\n * boots. Returns `{}` when there is no `window` (SSR / Node) or the global is absent or not an object.\n */\nexport function windowConfigSource(globalKey: string = DefaultRuntimeConfigKey): ConfigSource {\n if (typeof window === 'undefined') return {};\n if (!Object.hasOwn(window, globalKey)) return {};\n const raw = (window as unknown as Record<string, unknown>)[globalKey];\n return raw !== null && typeof raw === 'object' && !Array.isArray(raw) ? (raw as ConfigSource) : {};\n}\n\n/** An explicit source over a plain record — the injection seam for tests and for values resolved elsewhere. */\nexport function staticSource(values: Record<string, string | undefined>): ConfigSource {\n return values;\n}\n\n/** The default source order: runtime `window.__APP_CONFIG__` layered ahead of build-time `import.meta.env`. */\nexport function defaultSources(): ReadonlyArray<ConfigSource> {\n return [windowConfigSource(), importMetaEnvSource()];\n}\n\n/**\n * Resolves `key` across an ordered source list, first non-empty match wins (earlier source = higher priority).\n * A non-string hit (e.g. `import.meta.env.DEV` is a boolean) is coerced to its string form; an empty string is\n * treated as absent so an unset-but-declared env var falls through to the next source or the field default.\n */\nexport function resolveRaw(sources: ReadonlyArray<ConfigSource>, key: string): string | undefined {\n for (const source of sources) {\n if (!Object.hasOwn(source, key)) continue;\n const hit = (source as Record<string, unknown>)[key];\n if (hit === undefined || hit === null) continue;\n const asString = typeof hit === 'string' ? hit : String(hit);\n if (asString.length === 0) continue;\n return asString;\n }\n return undefined;\n}\n","// The typed-env engine. `defineConfig(schema, options)` reads each declared key from an ordered source list,\n// parses it through its `ConfigField`, applies defaults, and returns a frozen, fully-typed config object. Unlike\n// storage (which degrades silently), config fails LOUD: every missing-required and invalid-value problem is\n// collected across the whole schema and thrown together as one `ConfigError` at startup — so a misconfigured\n// deploy surfaces all its problems at once, not one boot-crash at a time.\n\nimport type { AnyConfigField, ConfigField } from './ConfigField';\nimport { defaultSources, resolveRaw, type ConfigSource } from './ConfigSource';\n\n/** A schema: a map from output key to its field spec. */\nexport type ConfigSchema = Readonly<Record<string, AnyConfigField>>;\n\n/** Widens an optional field's output to include `undefined`; a required / defaulted field stays `T`. */\ntype InferField<F> =\n F extends ConfigField<infer T, infer Optional> ? (Optional extends true ? T | undefined : T) : never;\n\n/** The resolved, typed config object inferred from a schema. */\nexport type InferConfig<S extends ConfigSchema> = { readonly [K in keyof S]: InferField<S[K]> };\n\n/** Tunes where `defineConfig` reads from and how keys are namespaced. */\nexport interface DefineConfigOptions {\n /** The ordered source list; earlier wins. Defaults to `[window.__APP_CONFIG__, import.meta.env]`. */\n readonly sources?: ReadonlyArray<ConfigSource>;\n\n /** A prefix prepended to every schema key on lookup (e.g. `'VITE_'` → key `API_URL` reads `VITE_API_URL`). */\n readonly prefix?: string;\n}\n\n/** One resolution failure — a missing required key or a value that failed its field's `parse`. */\nexport interface ConfigIssue {\n /** The schema key (output name, without the lookup prefix). */\n readonly key: string;\n\n /** The full source key looked up (with prefix). */\n readonly lookupKey: string;\n\n /** Why it failed. */\n readonly reason: 'missing' | 'invalid';\n\n /** A human-readable description; a `secret` field's raw value is never included. */\n readonly message: string;\n}\n\n/** Thrown by `defineConfig` when one or more keys are missing or invalid — aggregates every issue found. */\nexport class ConfigError extends Error {\n /** Every resolution failure across the schema. */\n readonly issues: ReadonlyArray<ConfigIssue>;\n\n constructor(issues: ReadonlyArray<ConfigIssue>) {\n const lines = issues.map((issue) => ` - ${issue.lookupKey}: ${issue.message}`).join('\\n');\n super(`Invalid configuration (${issues.length} ${issues.length === 1 ? 'issue' : 'issues'}):\\n${lines}`);\n this.name = 'ConfigError';\n this.issues = Object.freeze(issues.map((issue) => Object.freeze({ ...issue })));\n // Restore the prototype chain across the ES5 `Error` transpilation target so `instanceof` holds.\n Object.setPrototypeOf(this, ConfigError.prototype);\n }\n}\n\n/**\n * Resolves a typed configuration object from `schema`. Each key is looked up across the source list (prefix\n * applied), parsed through its field, and defaulted when absent. Empty strings count as absent. All missing /\n * invalid problems are aggregated and thrown together as a single {@link ConfigError}; on success the returned\n * object is frozen. Pass an explicit `sources` (e.g. `[staticSource({...})]`) to make resolution deterministic\n * in tests.\n */\nexport function defineConfig<const S extends ConfigSchema>(schema: S, options?: DefineConfigOptions): InferConfig<S> {\n const sources = options?.sources ?? defaultSources();\n const prefix = options?.prefix ?? '';\n\n const resolved: Record<string, unknown> = Object.create(null);\n const issues: ConfigIssue[] = [];\n\n for (const [key, field] of Object.entries(schema) as [string, AnyConfigField][]) {\n const lookupKey = `${prefix}${key}`;\n const raw = resolveRaw(sources, lookupKey);\n\n if (raw === undefined) {\n if (field.hasDefault) {\n try {\n const value = field.createDefault ? field.createDefault() : field.defaultValue;\n if (value === undefined) throw new TypeError('Config defaults cannot be undefined.');\n resolved[key] = value;\n } catch {\n issues.push({ key, lookupKey, reason: 'invalid', message: `invalid ${field.typeName} default` });\n }\n } else if (!field.required) {\n resolved[key] = undefined;\n } else {\n issues.push({ key, lookupKey, reason: 'missing', message: `missing required ${field.typeName}` });\n }\n continue;\n }\n\n try {\n resolved[key] = field.parse(raw);\n } catch (error) {\n // A field's `parse` throws a `string` describing the failure; anything else is coerced defensively.\n const detail = typeof error === 'string' ? error : `invalid ${field.typeName}`;\n // Never leak a secret's raw value — the field's own message may quote it, so replace it wholesale.\n const message = field.secret ? `invalid ${field.typeName} (value redacted)` : detail;\n issues.push({ key, lookupKey, reason: 'invalid', message });\n }\n }\n\n if (issues.length > 0) throw new ConfigError(issues);\n\n return Object.freeze(resolved) as InferConfig<S>;\n}\n"],"names":[],"mappings":";;;AAkEA,SAAS,YACP,UACA,OACA,SACyB;AACzB,QAAM,WAAW,YAAY,UAAa,OAAO,OAAO,SAAS,SAAS;AAC1E,QAAM,aAAa,YAAY,UAAa,OAAO,OAAO,SAAS,gBAAgB;AACnF,MAAI,YAAY,WAAY,OAAM,IAAI,UAAU,6CAA6C;AAC7F,MACE,aACC,QAAQ,YAAY,UAClB,OAAO,QAAQ,YAAY,YAAY,QAAQ,YAAY,QAC5D,OAAO,QAAQ,YAAY,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config/ConfigSource.ts","../../../src/foundation/config/DefineConfig.ts"],"sourcesContent":["import { LosslessJson } from '../json';\nimport { ResultExtensions, type Result } from '../results';\n\n// Typed-env field specs. A `ConfigField<T>` describes how one configuration key is parsed from its raw\n// string form, whether it is required, and its fallback — the atoms `defineConfig` reads a source through.\n// Each builder (`str`, `num`, `bool`, `oneOf`, `url`, `port`, `json`, `list`) returns a field whose `parse`\n// handles only a *present* raw string and throws a human-readable message on an invalid value; the engine\n// owns the missing / default / required decision centrally, so a field never re-implements that policy.\n\n/** Tunes one field's presence policy and fallback. A `default` (or `required: false`) makes the field optional. */\nexport interface ConfigFieldOptions<T> {\n /** Marks the field required. Defaults to `true` unless a `default` is supplied. */\n readonly required?: boolean;\n\n /** The value used when the key is absent or empty. Supplying it makes the field optional. */\n readonly default?: T;\n\n /** Creates an independent fallback for each resolution; use for mutable values. */\n readonly defaultFactory?: () => T;\n\n /** Redacts the raw value from `ConfigError` messages — set for tokens, keys, and passwords. */\n readonly secret?: boolean;\n}\n\n/**\n * Describes a single configuration key: its scalar type, presence policy, and how to parse a present raw\n * string into `T`. `Optional` is a phantom flag the schema inference reads to widen the output to `T | undefined`\n * for a field that is `required: false` with no `default`.\n */\nexport interface ConfigField<T, Optional extends boolean = false> {\n /** The human-facing type name used in error messages (`string`, `number`, `one of [...]`, …). */\n readonly typeName: string;\n\n /** Whether a missing key is an error. `false` when a `default` is present or `required: false`. */\n readonly required: boolean;\n\n /** Whether an explicit `default` was supplied. */\n readonly hasDefault: boolean;\n\n /** The configured fallback, meaningful only when `hasDefault` is `true`. */\n readonly defaultValue?: T;\n\n /** Builds an independent fallback when configured. */\n readonly createDefault?: () => T;\n\n /** Whether the raw value is redacted from error output. */\n readonly secret: boolean;\n\n /** Phantom marker: `true` widens the inferred output type to `T | undefined`. Never read at runtime. */\n readonly __optional?: Optional;\n\n /** Parses a present, non-empty raw string into `T`; throws a `string` message describing the failure. */\n parse(raw: string): T;\n}\n\n/** Computes a field's phantom optionality from its options — optional iff no `default` and `required: false`. */\ntype Optionality<O> = O extends { default: unknown } | { defaultFactory: unknown }\n ? false\n : O extends { required: false }\n ? true\n : false;\n\n/** The upper bound for a field of unknown scalar type — every concrete `ConfigField<T, …>` is assignable to it. */\nexport type AnyConfigField = ConfigField<unknown, boolean>;\n\n/** Shared field constructor — folds the options into the runtime presence policy around a scalar `parse`. */\nfunction createField<T>(\n typeName: string,\n parse: (raw: string) => T,\n options: ConfigFieldOptions<T> | undefined,\n): ConfigField<T, boolean> {\n const hasValue = options !== undefined && Object.hasOwn(options, 'default');\n const hasFactory = options !== undefined && Object.hasOwn(options, 'defaultFactory');\n if (hasValue && hasFactory) throw new TypeError('Choose default or defaultFactory, not both.');\n if (\n hasValue &&\n (options.default === undefined ||\n (typeof options.default === 'object' && options.default !== null) ||\n typeof options.default === 'function')\n ) {\n throw new TypeError('Use defaultFactory for mutable config defaults; undefined is not a default.');\n }\n if (hasFactory && typeof options.defaultFactory !== 'function')\n throw new TypeError('defaultFactory must be a function.');\n const hasDefault = hasValue || hasFactory;\n return Object.freeze({\n typeName,\n parse,\n hasDefault,\n defaultValue: hasValue ? options.default : undefined,\n createDefault: hasFactory ? options.defaultFactory : undefined,\n // A field is required unless it carries a default or is explicitly opted out.\n required: hasDefault ? false : (options?.required ?? true),\n secret: options?.secret ?? false,\n });\n}\n\n/** A string field — preserves the raw value; empty strings are handled as missing by resolution. */\nexport function str<const O extends ConfigFieldOptions<string> = ConfigFieldOptions<string>>(\n options?: O,\n): ConfigField<string, Optionality<O>> {\n return createField('string', (raw) => raw, options) as ConfigField<string, Optionality<O>>;\n}\n\n/** A finite-number field — rejects any raw string that does not parse to a finite JS number. */\nexport function num<const O extends ConfigFieldOptions<number> = ConfigFieldOptions<number>>(\n options?: O,\n): ConfigField<number, Optionality<O>> {\n return createField(\n 'number',\n (raw) => {\n const value = Number(raw);\n if (!Number.isFinite(value)) throw `expected a number, got \"${raw}\"`;\n return value;\n },\n options,\n ) as ConfigField<number, Optionality<O>>;\n}\n\n/** The raw spellings each boolean side accepts, case-insensitively. */\nconst TrueTokens = new Set(['true', '1', 'yes', 'on']);\nconst FalseTokens = new Set(['false', '0', 'no', 'off']);\n\n/** A boolean field — accepts `true/1/yes/on` and `false/0/no/off` (case-insensitive); rejects anything else. */\nexport function bool<const O extends ConfigFieldOptions<boolean> = ConfigFieldOptions<boolean>>(\n options?: O,\n): ConfigField<boolean, Optionality<O>> {\n return createField(\n 'boolean',\n (raw) => {\n const token = raw.trim().toLowerCase();\n if (TrueTokens.has(token)) return true;\n if (FalseTokens.has(token)) return false;\n throw `expected a boolean (true/false/1/0/yes/no/on/off), got \"${raw}\"`;\n },\n options,\n ) as ConfigField<boolean, Optionality<O>>;\n}\n\n/** An enum field — the value must be one of `values`; the output type narrows to that literal union. */\nexport function oneOf<\n const V extends readonly string[],\n const O extends ConfigFieldOptions<V[number]> = ConfigFieldOptions<V[number]>,\n>(values: V, options?: O): ConfigField<V[number], Optionality<O>> {\n return createField(\n `one of [${values.join(', ')}]`,\n (raw) => {\n if ((values as readonly string[]).includes(raw)) return raw as V[number];\n throw `expected one of [${values.join(', ')}], got \"${raw}\"`;\n },\n options,\n ) as ConfigField<V[number], Optionality<O>>;\n}\n\n/** A URL field — validated with the `URL` constructor; the parsed string is returned unchanged. */\nexport function url<const O extends ConfigFieldOptions<string> = ConfigFieldOptions<string>>(\n options?: O,\n): ConfigField<string, Optionality<O>> {\n return createField(\n 'url',\n (raw) => {\n try {\n // Construct-and-discard: `URL` throws on a malformed value; we keep the caller's original string.\n void new URL(raw);\n return raw;\n } catch {\n throw `expected a valid URL, got \"${raw}\"`;\n }\n },\n options,\n ) as ConfigField<string, Optionality<O>>;\n}\n\n/** A TCP-port field — a finite integer in `1..65535`. */\nexport function port<const O extends ConfigFieldOptions<number> = ConfigFieldOptions<number>>(\n options?: O,\n): ConfigField<number, Optionality<O>> {\n return createField(\n 'port',\n (raw) => {\n const value = Number(raw);\n if (!Number.isInteger(value) || value < 1 || value > 65535) throw `expected a port in 1..65535, got \"${raw}\"`;\n return value;\n },\n options,\n ) as ConfigField<number, Optionality<O>>;\n}\n\n/** Validates a parsed JSON value; expected failures carry the decoder's own failure data. */\nexport type ConfigJsonDecoder<T> = (value: unknown) => Result<T, unknown>;\n\n/** Reads JSON without claiming a decoded application shape. Numeric tokens remain ExactNumber values. */\nexport function json<const O extends ConfigFieldOptions<unknown> = ConfigFieldOptions<unknown>>(\n options?: O,\n): ConfigField<unknown, Optionality<O>>;\n/** Decodes a lossless JSON value into a validated application shape; decoder failures reject the field. */\nexport function json<T, const O extends ConfigFieldOptions<T> = ConfigFieldOptions<T>>(\n decode: ConfigJsonDecoder<T>,\n options?: O,\n): ConfigField<T, Optionality<O>>;\nexport function json(\n decodeOrOptions?: ConfigJsonDecoder<unknown> | ConfigFieldOptions<unknown>,\n options?: ConfigFieldOptions<unknown>,\n): ConfigField<unknown, boolean> {\n const decode =\n typeof decodeOrOptions === 'function' ? decodeOrOptions : (value: unknown) => ResultExtensions.ok(value);\n return createField(\n 'json',\n (raw) => {\n const parsed = LosslessJson.parse(raw);\n if (!parsed.ok) throw 'expected valid JSON';\n const decoded = decode(parsed.value);\n if (!decoded.ok) throw 'JSON value failed its decoder';\n return decoded.value;\n },\n typeof decodeOrOptions === 'function' ? options : decodeOrOptions,\n );\n}\n\n/** Tunes how a `list` field splits its raw value. */\nexport interface ListFieldOptions extends ConfigFieldOptions<readonly string[]> {\n /** The item separator. Defaults to a comma. */\n readonly separator?: string;\n}\n\n/** A string-list field — splits on `separator` (default `,`), trims each item, and drops empty items. */\nexport function list<const O extends ListFieldOptions = ListFieldOptions>(\n options?: O,\n): ConfigField<ReadonlyArray<string>, Optionality<O>> {\n const separator = options?.separator ?? ',';\n return createField<readonly string[]>(\n 'list',\n (raw) =>\n raw\n .split(separator)\n .map((item) => item.trim())\n .filter((item) => item.length > 0),\n options,\n ) as ConfigField<readonly string[], Optionality<O>>;\n}\n","// Configuration sources — the raw key/value stores `defineConfig` reads through. Two ship by default: the\n// runtime `window.__APP_CONFIG__` global an ops team can inject per-environment without a rebuild (12-factor\n// runtime config), and the app's build-time `import.meta.env`, which the app passes in from its own module. A\n// source is a flat record of string values; `defineConfig` merges an ordered list where the *earlier* source\n// wins, so runtime config is layered ahead of build-time env. Reading a source never throws — an unavailable\n// one yields `{}`.\n//\n// The package cannot read the app's env itself: a bundler replaces `import.meta.env` only in the app's own\n// modules, never inside this prebuilt package, so the app hands over its `import.meta.env` object.\n\n/** A flat, read-only key/value store of raw configuration strings. */\nexport type ConfigSource = Readonly<Record<string, string | undefined>>;\n\n/** The default runtime-config global — `window.__APP_CONFIG__`, injected per-environment ahead of build-time env. */\nexport const DefaultRuntimeConfigKey = '__APP_CONFIG__';\n\n/** A build-time env record as a bundler exposes it — Vite's `import.meta.env`, with string and boolean values. */\nexport type ConfigEnv = Readonly<Record<string, unknown>>;\n\n/**\n * The build-time source over the app's own env — call it as `importMetaEnvSource(import.meta.env)` from an app\n * module, where the bundler inlines `import.meta.env`. Copies every string, number, boolean and bigint value as a\n * string (`DEV: true` → `'true'`) into a frozen snapshot and drops anything else. A missing or non-object `env`\n * yields `{}`.\n */\nexport function importMetaEnvSource(env: ConfigEnv | undefined): ConfigSource {\n const values: Record<string, string> = Object.create(null);\n if (env === null || typeof env !== 'object') return Object.freeze(values);\n for (const key of Object.keys(env)) {\n const value = env[key];\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n typeof value === 'bigint'\n ) {\n values[key] = String(value);\n }\n }\n return Object.freeze(values);\n}\n\n/**\n * The runtime source — a global object (default `window.__APP_CONFIG__`) a deployment injects before the app\n * boots. Returns `{}` when there is no `window` (SSR / Node) or the global is absent or not an object.\n */\nexport function windowConfigSource(globalKey: string = DefaultRuntimeConfigKey): ConfigSource {\n if (typeof window === 'undefined') return {};\n if (!Object.hasOwn(window, globalKey)) return {};\n const raw = (window as unknown as Record<string, unknown>)[globalKey];\n return raw !== null && typeof raw === 'object' && !Array.isArray(raw) ? (raw as ConfigSource) : {};\n}\n\n/** An explicit source over a plain record — the injection seam for tests and for values resolved elsewhere. */\nexport function staticSource(values: Record<string, string | undefined>): ConfigSource {\n return values;\n}\n\n/**\n * The default source order: runtime `window.__APP_CONFIG__` layered ahead of the app's build-time env. Pass the\n * app's `import.meta.env` as `env`; without it only the runtime source is read.\n */\nexport function defaultSources(env?: ConfigEnv): ReadonlyArray<ConfigSource> {\n return env === undefined ? [windowConfigSource()] : [windowConfigSource(), importMetaEnvSource(env)];\n}\n\n/**\n * Resolves `key` across an ordered source list, first non-empty match wins (earlier source = higher priority).\n * A non-string hit (e.g. `import.meta.env.DEV` is a boolean) is coerced to its string form; an empty string is\n * treated as absent so an unset-but-declared env var falls through to the next source or the field default.\n */\nexport function resolveRaw(sources: ReadonlyArray<ConfigSource>, key: string): string | undefined {\n for (const source of sources) {\n if (!Object.hasOwn(source, key)) continue;\n const hit = (source as Record<string, unknown>)[key];\n if (hit === undefined || hit === null) continue;\n const asString = typeof hit === 'string' ? hit : String(hit);\n if (asString.length === 0) continue;\n return asString;\n }\n return undefined;\n}\n","// The typed-env engine. `defineConfig(schema, options)` reads each declared key from an ordered source list,\n// parses it through its `ConfigField`, applies defaults, and returns a frozen, fully-typed config object. Unlike\n// storage (which degrades silently), config fails LOUD: every missing-required and invalid-value problem is\n// collected across the whole schema and thrown together as one `ConfigError` at startup — so a misconfigured\n// deploy surfaces all its problems at once, not one boot-crash at a time.\n\nimport type { AnyConfigField, ConfigField } from './ConfigField';\nimport { defaultSources, resolveRaw, type ConfigEnv, type ConfigSource } from './ConfigSource';\n\n/** A schema: a map from output key to its field spec. */\nexport type ConfigSchema = Readonly<Record<string, AnyConfigField>>;\n\n/** Widens an optional field's output to include `undefined`; a required / defaulted field stays `T`. */\ntype InferField<F> =\n F extends ConfigField<infer T, infer Optional> ? (Optional extends true ? T | undefined : T) : never;\n\n/** The resolved, typed config object inferred from a schema. */\nexport type InferConfig<S extends ConfigSchema> = { readonly [K in keyof S]: InferField<S[K]> };\n\n/** Tunes where `defineConfig` reads from and how keys are namespaced. */\nexport interface DefineConfigOptions {\n /** The ordered source list; earlier wins. Defaults to `defaultSources(env)`. */\n readonly sources?: ReadonlyArray<ConfigSource>;\n\n /**\n * The app's build-time env — pass `import.meta.env` from the app's own module. Read after the runtime\n * `window.__APP_CONFIG__` when `sources` is omitted; ignored when `sources` is given.\n */\n readonly env?: ConfigEnv;\n\n /** A prefix prepended to every schema key on lookup (e.g. `'VITE_'` → key `API_URL` reads `VITE_API_URL`). */\n readonly prefix?: string;\n}\n\n/** One resolution failure — a missing required key or a value that failed its field's `parse`. */\nexport interface ConfigIssue {\n /** The schema key (output name, without the lookup prefix). */\n readonly key: string;\n\n /** The full source key looked up (with prefix). */\n readonly lookupKey: string;\n\n /** Why it failed. */\n readonly reason: 'missing' | 'invalid';\n\n /** A human-readable description; a `secret` field's raw value is never included. */\n readonly message: string;\n}\n\n/** Thrown by `defineConfig` when one or more keys are missing or invalid — aggregates every issue found. */\nexport class ConfigError extends Error {\n /** Every resolution failure across the schema. */\n readonly issues: ReadonlyArray<ConfigIssue>;\n\n constructor(issues: ReadonlyArray<ConfigIssue>) {\n const lines = issues.map((issue) => ` - ${issue.lookupKey}: ${issue.message}`).join('\\n');\n super(`Invalid configuration (${issues.length} ${issues.length === 1 ? 'issue' : 'issues'}):\\n${lines}`);\n this.name = 'ConfigError';\n this.issues = Object.freeze(issues.map((issue) => Object.freeze({ ...issue })));\n // Restore the prototype chain across the ES5 `Error` transpilation target so `instanceof` holds.\n Object.setPrototypeOf(this, ConfigError.prototype);\n }\n}\n\n/**\n * Resolves a typed configuration object from `schema`. Each key is looked up across the source list (prefix\n * applied), parsed through its field, and defaulted when absent. Empty strings count as absent. All missing /\n * invalid problems are aggregated and thrown together as a single {@link ConfigError}; on success the returned\n * object is frozen. Pass the app's `env: import.meta.env`, or an explicit `sources` (e.g.\n * `[staticSource({...})]`) to make resolution deterministic in tests.\n */\nexport function defineConfig<const S extends ConfigSchema>(schema: S, options?: DefineConfigOptions): InferConfig<S> {\n const sources = options?.sources ?? defaultSources(options?.env);\n const prefix = options?.prefix ?? '';\n\n const resolved: Record<string, unknown> = Object.create(null);\n const issues: ConfigIssue[] = [];\n\n for (const [key, field] of Object.entries(schema) as [string, AnyConfigField][]) {\n const lookupKey = `${prefix}${key}`;\n const raw = resolveRaw(sources, lookupKey);\n\n if (raw === undefined) {\n if (field.hasDefault) {\n try {\n const value = field.createDefault ? field.createDefault() : field.defaultValue;\n if (value === undefined) throw new TypeError('Config defaults cannot be undefined.');\n resolved[key] = value;\n } catch {\n issues.push({ key, lookupKey, reason: 'invalid', message: `invalid ${field.typeName} default` });\n }\n } else if (!field.required) {\n resolved[key] = undefined;\n } else {\n issues.push({ key, lookupKey, reason: 'missing', message: `missing required ${field.typeName}` });\n }\n continue;\n }\n\n try {\n resolved[key] = field.parse(raw);\n } catch (error) {\n // A field's `parse` throws a `string` describing the failure; anything else is coerced defensively.\n const detail = typeof error === 'string' ? error : `invalid ${field.typeName}`;\n // Never leak a secret's raw value — the field's own message may quote it, so replace it wholesale.\n const message = field.secret ? `invalid ${field.typeName} (value redacted)` : detail;\n issues.push({ key, lookupKey, reason: 'invalid', message });\n }\n }\n\n if (issues.length > 0) throw new ConfigError(issues);\n\n return Object.freeze(resolved) as InferConfig<S>;\n}\n"],"names":[],"mappings":";;;AAkEA,SAAS,YACP,UACA,OACA,SACyB;AACzB,QAAM,WAAW,YAAY,UAAa,OAAO,OAAO,SAAS,SAAS;AAC1E,QAAM,aAAa,YAAY,UAAa,OAAO,OAAO,SAAS,gBAAgB;AACnF,MAAI,YAAY,WAAY,OAAM,IAAI,UAAU,6CAA6C;AAC7F,MACE,aACC,QAAQ,YAAY,UAClB,OAAO,QAAQ,YAAY,YAAY,QAAQ,YAAY,QAC5D,OAAO,QAAQ,YAAY,aAC7B;AACA,UAAM,IAAI,UAAU,6EAA6E;AAAA,EACnG;AACA,MAAI,cAAc,OAAO,QAAQ,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AAQ,sBAAsB;AAC9E,aAAO,KAAK,EAAE,KAAK,WAAW,QAAQ,WAAW,SAAS;AAAA,IAC5D;AAAA,EACF;AAEA,MAAI,OAAO,SAAS,EAAG,OAAM,IAAI,YAAY,MAAM;AAEnD,SAAO,OAAO,OAAO,QAAQ;AAC/B;"}
@@ -1,10 +1,9 @@
1
1
  import { c } from "../../chunks/Cn-C7De6POU.js";
2
- import { A, C, R, S } from "../../chunks/CssExtensions-ctGVlfYU.js";
3
- import { C as C2, a } from "../../chunks/ColorExtensions-DiCSaVbJ.js";
4
- import { S as S2, s } from "../../chunks/SurfaceStyles-B8KNkFsm.js";
5
- import { D, L, l } from "../../chunks/index-C-r59Hob.js";
6
- import { P, R as R2, S as S3, T } from "../../chunks/StyleTokens-Bkz7Dm5L.js";
7
- import { a as a2, T as T2 } from "../../chunks/Tones-CQu-OvAk.js";
2
+ import { A, C, R, S, a, T } from "../../chunks/Tones-Bcz8dIo3.js";
3
+ import { C as C2, a as a2 } from "../../chunks/ColorExtensions-DiCSaVbJ.js";
4
+ import { S as S2, s } from "../../chunks/SurfaceStyles-BYvRlsWe.js";
5
+ import { D, L, l } from "../../chunks/index-CGIXFfl9.js";
6
+ import { P, R as R2, S as S3, T as T2 } from "../../chunks/StyleTokens-Bkz7Dm5L.js";
8
7
  import { S as S4 } from "../../chunks/Severity-D0C5oAt-.js";
9
8
  import { O } from "../../chunks/Orientation-u-sYunuG.js";
10
9
  import { A as A2 } from "../../chunks/Align-DqFtCY3a.js";
@@ -18,7 +17,7 @@ export {
18
17
  A as AbsolutePositionPreset,
19
18
  A2 as Align,
20
19
  C2 as ColorExtensions,
21
- a as ColorTone,
20
+ a2 as ColorTone,
22
21
  C3 as CornerPosition,
23
22
  C as CssExtensions,
24
23
  D as Density,
@@ -35,9 +34,9 @@ export {
35
34
  S as SizePreset,
36
35
  S6 as StatusTone,
37
36
  S2 as SurfaceVariant,
38
- T as Tone,
39
- a2 as ToneFamily,
40
- T2 as Tones,
37
+ T2 as Tone,
38
+ a as ToneFamily,
39
+ T as Tones,
41
40
  c as cn,
42
41
  l as layerStyle,
43
42
  s as surfaceVariants,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}