export class CompositionController {
    dom;
    composing = false;
    data = '';
    constructor(dom) {
        this.dom = dom;
    }
    /** -------------------------------------------------- {@link UiLifeCycles} */
    start() {
        const onStart = (event) => {
            this.composing = true;
            this.data = event.data;
        };
        const onUpdate = (event) => {
            this.composing = true;
            this.data = event.data;
        };
        const onEnd = (event) => {
            this.composing = false;
            this.data = '';
            const text = event.data;
            if (text)
                this.dom.et.insert(text);
        };
        const el = this.dom.el;
        el.addEventListener('compositionstart', onStart);
        el.addEventListener('compositionupdate', onUpdate);
        el.addEventListener('compositionend', onEnd);
        return () => {
            el.removeEventListener('compositionstart', onStart);
            el.removeEventListener('compositionupdate', onUpdate);
            el.removeEventListener('compositionend', onEnd);
        };
    }
    /** ----------------------------------------------------- {@link Printable} */
    toString(tab) {
        return `composition { composing: ${this.composing}, data: ${JSON.stringify(this.data)} }`;
    }
}
//# sourceMappingURL=CompositionController.js.map