"use strict";var n=Object.defineProperty;var r=(i,t,e)=>t in i?n(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>(r(i,typeof t!="symbol"?t+"":t,e),e);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("../blots/embed.js"),s=require("./emitter.js");class a{constructor(t,e){o(this,"isComposing",!1);this.scroll=t,this.emitter=e,this.setupListeners()}setupListeners(){this.scroll.domNode.addEventListener("compositionstart",t=>{this.isComposing||this.handleCompositionStart(t)}),this.scroll.domNode.addEventListener("compositionend",t=>{this.isComposing&&queueMicrotask(()=>{this.handleCompositionEnd(t)})})}handleCompositionStart(t){const e=t.target instanceof Node?this.scroll.find(t.target,!0):null;e&&!(e instanceof l.default)&&(this.emitter.emit(s.default.events.COMPOSITION_BEFORE_START,t),this.scroll.batchStart(),this.emitter.emit(s.default.events.COMPOSITION_START,t),this.isComposing=!0)}handleCompositionEnd(t){this.emitter.emit(s.default.events.COMPOSITION_BEFORE_END,t),this.scroll.batchEnd(),this.emitter.emit(s.default.events.COMPOSITION_END,t),this.isComposing=!1}}exports.default=a;
