const SlotsForNoShadowDOMMixin = (superClass)=>{
    class SlotsForNoShadowDOMClass extends superClass {
        createRenderRoot() {
            return this;
        }
        willUpdate(changedProperties) {
            super.willUpdate?.(changedProperties);
            if (!this.hasUpdated) this.adoptChildren();
        }
        updated(changedProperties) {
            super.updated?.(changedProperties);
            for (const { placeholder, nodes } of this.slotPlaceholders)placeholder.replaceWith(...nodes);
            this.slotPlaceholders = [];
        }
        adoptChildren() {
            const children = Array.from(this.childNodes);
            for (const child of children){
                const slotName = child instanceof Element ? child.getAttribute('slot') || '' : '';
                if (!this.slotContent[slotName]) this.slotContent[slotName] = [];
                this.slotContent[slotName].push(child);
                child.remove();
            }
        }
        isTextNodeEmpty(node) {
            return !node.textContent || !node.textContent.trim();
        }
        isSlotEmpty(slot) {
            const content = this.slotContent[slot];
            return !content || content.every((child)=>child instanceof Comment || child instanceof Text && this.isTextNodeEmpty(child));
        }
        renderDefaultSlotContent(defaultContent) {
            if (!this.isSlotEmpty('')) return this.createSlotPlaceholder(this.slotContent['']);
            return defaultContent ? [
                defaultContent
            ] : [];
        }
        createSlotPlaceholder(nodes) {
            const placeholder = document.createComment('slot');
            this.slotPlaceholders.push({
                placeholder,
                nodes
            });
            return [
                placeholder
            ];
        }
        constructor(...args){
            super(...args), this.slotContent = {}, this.slotPlaceholders = [];
        }
    }
    return SlotsForNoShadowDOMClass;
};
export { SlotsForNoShadowDOMMixin };
