const o=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],t=(()=>{if(typeof document>"u")return!1;const e=o[0],r={};for(const n of o)if((n==null?void 0:n[1])in document){for(const[s,u]of n.entries())r[e[s]]=u;return r}return!1})(),i={change:t.fullscreenchange,error:t.fullscreenerror};let l={request(e=document.documentElement,r){return new Promise((n,c)=>{const s=()=>{l.off("change",s),n()};l.on("change",s);const u=e[t.requestFullscreen](r);u instanceof Promise&&u.then(s).catch(c)})},exit(){return new Promise((e,r)=>{if(!l.isFullscreen){e();return}const n=()=>{l.off("change",n),e()};l.on("change",n);const c=document[t.exitFullscreen]();c instanceof Promise&&c.then(n).catch(r)})},toggle(e,r){return l.isFullscreen?l.exit():l.request(e,r)},onchange(e){l.on("change",e)},onerror(e){l.on("error",e)},on(e,r){const n=i[e];n&&document.addEventListener(n,r,!1)},off(e,r){const n=i[e];n&&document.removeEventListener(n,r,!1)},raw:t};Object.defineProperties(l,{isFullscreen:{get:()=>!!document[t.fullscreenElement]},element:{enumerable:!0,get:()=>document[t.fullscreenElement]??void 0},isEnabled:{enumerable:!0,get:()=>!!document[t.fullscreenEnabled]}});t||(l={isEnabled:!1});const f=l;export{f as s};
