"use strict";var r=Object.defineProperty;var u=(i,t,o)=>t in i?r(i,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[t]=o;var e=(i,t,o)=>u(i,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-BQRd8ZzE.cjs");class c{constructor(t,o={}){e(this,"quill");e(this,"options");e(this,"toolbarEl");e(this,"ownerDocument");e(this,"controller");e(this,"button",null);e(this,"buttonIcon",null);e(this,"unsubscribeController",null);e(this,"buttonClickHandler",t=>this.controller.toggleFullscreen(t));if(this.quill=t,this.options=o,this.ownerDocument=t.root instanceof HTMLElement?t.root.ownerDocument:document,this.controller=s.getOrCreateQuillFullscreenController(t),this.options.type==="Raw"){this.toolbarEl=null;return}const n=t.getModule("toolbar"),l=(n==null?void 0:n.container)??null;this.toolbarEl=l,this.createButton()}destroy(){var t,o;(t=this.unsubscribeController)==null||t.call(this),this.unsubscribeController=null,this.button&&(this.button.removeEventListener("click",this.buttonClickHandler),this.button.remove(),this.button=null),(o=this.toolbarEl)==null||o.classList.remove("ql-toolbar-has-right-action"),s.destroyQuillFullscreenController(this.quill)}createButton(){if(!this.options.maximize||!this.options.minimize)return;const t=this.ownerDocument.createElement("button"),o=this.ownerDocument.createElement("span");t.type="button",t.classList.add("ql-fullscreen"),o.classList.add("ql-fullscreen-icon"),t.append(o),t.addEventListener("click",this.buttonClickHandler),this.button=t,this.buttonIcon=o,this.unsubscribeController=this.controller.subscribe(n=>this.syncButtonState(n)),this.toolbarEl&&(t.classList.add("ql-right-action"),this.toolbarEl.classList.add("ql-toolbar-has-right-action"),this.toolbarEl.append(t))}syncButtonState(t){if(!this.button||!this.buttonIcon)return;this.button.classList.toggle("ql-active",t);const o=t?this.options.minimize??"":this.options.maximize??"",n=t?this.options.minimizeLabel??"":this.options.maximizeLabel??"";this.buttonIcon.innerHTML!==o&&(this.buttonIcon.innerHTML=o),this.button.title!==n&&(this.button.title=n),this.button.getAttribute("aria-label")!==n&&this.button.setAttribute("aria-label",n)}}exports.default=c;
