{"version":3,"file":"_component-class.cjs","names":[],"sources":["../src/_component-class.ts"],"sourcesContent":["import { BaseElement } from './base-element';\nimport type { ComponentDefinition } from './component-types';\nimport { ORE_ERRORS, OreApiError } from './errors';\nimport { normalizePropDefinition, type PropInputDefs, type PropsDef, validatePropDefs } from './props';\nimport { toKebab } from './utils/dom';\n\n/**\n * Builds the element class without touching the browser registry. Keeping\n * declaration work separate from registration makes the latter the only\n * irreversible global side effect in the component-definition path.\n *\n * @internal\n */\nexport function createComponentClass<Props extends Record<string, unknown>>(\n  tag: string,\n  definition: ComponentDefinition<Props>,\n): CustomElementConstructor {\n  const { props: propDefs } = definition;\n\n  const normalizedPropDefs: PropsDef<Props> | undefined = (() => {\n    if (!propDefs) return undefined;\n\n    const errors = validatePropDefs(propDefs as Record<string, unknown>);\n\n    if (errors.length > 0) throw new OreApiError(ORE_ERRORS.validationFailed(tag, errors));\n\n    const normalized: PropInputDefs = {};\n\n    for (const [key, def] of Object.entries(propDefs)) {\n      normalized[key] = normalizePropDefinition(def, key);\n    }\n\n    return normalized as PropsDef<Props>;\n  })();\n\n  const observedAttrs = normalizedPropDefs ? Object.keys(normalizedPropDefs).map(toKebab) : [];\n\n  const ComponentClass = class extends BaseElement {\n    static override _definition = definition as unknown as ComponentDefinition;\n    static override _normalizedPropDefs = normalizedPropDefs as PropsDef<Record<never, never>> | undefined;\n    static override formAssociated = definition.formAssociated ?? false;\n    static override observedAttributes = observedAttrs;\n  };\n\n  return ComponentClass;\n}\n"],"mappings":"sHAaA,SAAgB,EACd,EACA,EAC0B,CAC1B,GAAM,CAAE,MAAO,GAAa,EAEtB,OAAyD,CAC7D,GAAI,CAAC,EAAU,OAEf,IAAM,EAAS,EAAA,iBAAiB,CAAmC,EAEnE,GAAI,EAAO,OAAS,EAAG,MAAM,IAAI,EAAA,YAAY,EAAA,WAAW,iBAAiB,EAAK,CAAM,CAAC,EAErF,IAAM,EAA4B,CAAC,EAEnC,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAQ,EAC9C,EAAW,GAAO,EAAA,wBAAwB,EAAK,CAAG,EAGpD,OAAO,CACT,EAAA,CAAG,EAEG,EAAgB,EAAqB,OAAO,KAAK,CAAkB,CAAC,CAAC,IAAI,EAAA,OAAO,EAAI,CAAC,EAS3F,OAAO,cAP8B,EAAA,WAAY,CAC/C,OAAgB,YAAc,EAC9B,OAAgB,oBAAsB,EACtC,OAAgB,eAAiB,EAAW,gBAAkB,GAC9D,OAAgB,mBAAqB,CACvC,CAGF"}