import { customElement } from 'solid-element';
import { ChatConfig } from '../primitives/chat-config';
import { ELEMENT_CSS } from './css';
import { createSignal, onCleanup, Show, type JSX } from 'solid-js';
/**
* Shared constructable stylesheet, built once and adopted by every element's
* shadow root. This avoids duplicating the full compiled kit CSS (~77 KB) as an
* inline `
{/* display:contents — no layout box; carries the .dark token scope and
re-roots the inherited `color` to the active mode's foreground, so text
without an explicit color class (e.g. attachment filename labels) follows
light/dark instead of inheriting the host page's color. */}
{Facade(props as unknown as P, { element, dispatch, flag, expose })}
>
);
});
// Shadow any reflected native IDL accessor this element re-uses as a prop (see
// NON_REFLECTING) with a plain, non-reflecting store on the element prototype.
// This must live on the prototype (not the instance) so it is already in place
// when the value is set before connectedCallback, the window in which the native
// setter would otherwise reflect it to a host attribute. component-register reads
// the property back during initializeProps to seed the styling prop, and later
// shadows this with its own (also non-reflecting) per-instance accessor.
const proto = (Ctor as unknown as { prototype?: object } | undefined)?.prototype;
if (proto) {
for (const key of NON_REFLECTING) {
if (!(key in defaults)) continue;
const store = Symbol(`kai-prop:${key}`);
Object.defineProperty(proto, key, {
get(this: Record) {
return this[store];
},
set(this: Record, value: unknown) {
this[store] = value;
},
enumerable: true,
configurable: true,
});
}
}
}