import { DEFAULT_FONT_FAMILY, defaultFontFamilyFor, SYSTEM_FONT_FAMILY, } from "./appearance-defaults"; import type { BillingAddressRequirement, CreditCardAdditionalFields, } from "./payment-method-form"; import type { Appearance, AppearanceLabels, AppearanceRuleDeclarations, AppearanceRuleSelector, ThemeVariable, } from "./types"; const STYLE_ID = "amos-js-form-skeleton-styles"; let skeletonSeq = 0; const SKELETON_THEME_DEFAULTS: Record = { "--accent": "oklch(0.97 0 0)", "--radius": "0.625rem", "--input-height": "2.25rem", "--floating-input-height": "3.25rem", "--field-gap": "1rem", "--control-gap": "0.5rem", "--label-font-size": "0.875rem", // Overridden in applyTheme so `fonts: []` uses the system stack. "--font-family": DEFAULT_FONT_FAMILY, }; const PROPERTY_TO_KEBAB: Record = { fontFamily: "font-family", fontSize: "font-size", fontWeight: "font-weight", fontStyle: "font-style", lineHeight: "line-height", letterSpacing: "letter-spacing", textTransform: "text-transform", color: "color", backgroundColor: "background-color", border: "border", borderColor: "border-color", borderWidth: "border-width", borderStyle: "border-style", borderRadius: "border-radius", boxShadow: "box-shadow", outline: "outline", padding: "padding", margin: "margin", opacity: "opacity", }; const MAX_RULE_VALUE_LENGTH = 256; const ALLOWED_SKELETON_VAR_NAMES = new Set([ "--background", "--foreground", "--primary", "--primary-foreground", "--secondary", "--secondary-foreground", "--muted", "--muted-foreground", "--accent", "--accent-foreground", "--destructive", "--destructive-foreground", "--border", "--popover", "--popover-foreground", "--input", "--input-background", "--input-height", "--input-font-size", "--input-font-weight", "--input-padding", "--input-border-width", "--input-shadow", "--floating-input-height", "--floating-label-font-size", "--floating-label-empty-font-size", "--floating-label-font-weight", "--floating-label-color", "--floating-label-floated-color", "--floating-label-offset", "--floating-value-padding-top", "--floating-value-padding-bottom", "--label-font-size", "--label-font-weight", "--field-gap", "--control-gap", "--error-font-size", "--radio-size", "--ring", "--ring-width", "--radius", "--font-family", ]); /** * Resting rules that change skeleton box size. Hover / invalid / * placeholder / dropdown / radio have no host-page equivalent. */ const SKELETON_RULE_CLASSES: Partial> = { ".Input": "amos-js-form-skeleton-input", ".Label": "amos-js-form-skeleton-label", }; function isSafeSkeletonCssValue(raw: string): boolean { if (raw.length > MAX_RULE_VALUE_LENGTH) { return false; } // `<` / `>` close a