"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=new WeakMap,a="rte-fullscreen-active",t=e=>(o.has(e)||o.set(e,{isFullscreen:!1,fullscreenButton:null}),o.get(e)),f=(e,s)=>{if(e.classList.add(a),e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.right="0",e.style.bottom="0",e.style.width="100%",e.style.height="100%",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.borderRadius="0",e.style.zIndex="9999",e.style.margin="0",e.style.padding="0",e.style.boxShadow="none",e.style.display="flex",e.style.flexDirection="column",e.style.background="white",document.body.style.overflow="hidden",document.body.classList.add("fullscreen-active"),s.fullscreenButton){s.fullscreenButton.setAttribute("data-active","true"),s.fullscreenButton.style.backgroundColor="var(--rte-color-primary, #007bff)",s.fullscreenButton.style.color="white";const l=s.fullscreenButton.querySelector("svg");l&&(l.style.fill="white",l.style.stroke="white")}},c=(e,s)=>{if(e.classList.remove(a),e.style.position="",e.style.top="",e.style.left="",e.style.right="",e.style.bottom="",e.style.width="",e.style.height="",e.style.maxWidth="",e.style.maxHeight="",e.style.borderRadius="",e.style.zIndex="",e.style.margin="",e.style.padding="",e.style.boxShadow="",e.style.display="",e.style.flexDirection="",e.style.background="",document.body.style.overflow="",document.body.classList.remove("fullscreen-active"),s.fullscreenButton){s.fullscreenButton.setAttribute("data-active","false"),s.fullscreenButton.style.backgroundColor="",s.fullscreenButton.style.color="";const l=s.fullscreenButton.querySelector("svg");l&&(l.style.fill="",l.style.stroke="")}},y=e=>{try{if(!e){const l=document.activeElement;l&&l.closest("[data-editora-editor]")&&(e=l.closest("[data-editora-editor]"))}if(e||(e=document.querySelector("[data-editora-editor]")),!e)return console.warn("Editor element not found"),!1;const s=t(e);return s.fullscreenButton||(s.fullscreenButton=e.querySelector('[data-command="toggleFullscreen"]')),s.isFullscreen=!s.isFullscreen,s.isFullscreen?f(e,s):c(e,s),!0}catch(s){return console.error("Fullscreen toggle failed:",s),!1}},i=e=>{if(!e){document.querySelectorAll("[data-editora-editor]").forEach(l=>{const u=l,n=t(u);n.isFullscreen&&(n.isFullscreen=!1,c(u,n))});return}const s=t(e);s.isFullscreen&&(s.isFullscreen=!1,c(e,s))},d=e=>t(e).isFullscreen,r=()=>{const e=s=>{s.key==="Escape"&&i()};return typeof window<"u"&&window.addEventListener("keydown",e),()=>{typeof window<"u"&&window.removeEventListener("keydown",e)}};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r):r());const g=()=>({name:"fullscreen",toolbar:[{label:"Fullscreen",command:"toggleFullscreen",type:"button",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"></path></svg>'}],commands:{toggleFullscreen:y},keymap:{Escape:()=>{const e=document.querySelectorAll("[data-editora-editor]");for(const s of e)if(d(s))return i(s),!0;return!1}}});exports.FullscreenPlugin=g;
