import { type WebComponentInterface } from './WebComponentInterface'; import WebComponentType from './WebComponentType'; /** * Create a constructor body that clones the component template into shadow DOM * and wires the declared element map. * * @param component Component constructor and static metadata. * @param styles CSS text injected into the component shadow root. * @returns Constructor body used by concrete Web Component classes. */ const constructorFactory = >(component: WebComponentType, styles: string): ((this: T) => void) => { return function (this: T): void { /* Find template in main DOM. */ const template = document.getElementById(`${component.tagName}-template`) as HTMLTemplateElement; if (template) { /* Clone the template content. */ const clone = template.content.cloneNode(true) as DocumentFragment; /* Create a