"use strict";var q=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var Q=(t,e)=>{for(var n in e)q(t,n,{get:e[n],enumerable:!0})},J=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of N(e))!$.call(t,i)&&i!==n&&q(t,i,{get:()=>e[i],enumerable:!(s=W(e,i))||s.enumerable});return t};var X=t=>J(q({},"__esModule",{value:!0}),t);var te={};Q(te,{Appearance:()=>I,Direction:()=>D,EventManager:()=>C,EventPath:()=>E,EventPathList:()=>A,EventPosition:()=>L,ExtendedMouseEvent:()=>g,ExtendedTouchEvent:()=>T,ExtendedUIEvent:()=>b,Orientation:()=>S,Size:()=>j});module.exports=X(te);var l=(()=>{if(typeof window<"u")return window;if(typeof global<"u")return global;if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self})(),H=class t{static{this.vendors=["","webkit","moz","ms","MS","o","O"]}static{this.polyfillEventTypeMap={wheel:["wheel","mousewheel","DOMMouseScroll"],pointerlockchange:t.withVendor("pointer","lock","change"),pointerlockerror:t.withVendor("pointer","lock","error"),pointercancel:t.withVendor("pointer","cancel"),pointerdown:t.withVendor("pointer","down"),pointerhover:t.withVendor("pointer","hover"),pointermove:t.withVendor("pointer","move"),pointerout:t.withVendor("pointer","out"),pointerover:t.withVendor("pointer","over"),pointerup:t.withVendor("pointer","up"),lostpointercapture:t.withVendor("lost","pointer","capture"),gotpointercapture:t.withVendor("got","pointer","capture"),fullscreenchange:t.withVendor("fullscreen","change"),fullscreenerror:t.withVendor("fullscreen","error"),transitionstart:t.withVendor("transition","start"),transitionrun:t.withVendor("transition","run"),transitionend:t.withVendor("transition","end"),transitioncancel:t.withVendor("transition","cancel"),animationstart:t.withVendor("animation","start"),animationiteration:t.withVendor("animation","iteration"),animationend:t.withVendor("animation","end"),animationcancel:t.withVendor("animation","cancel")}}static withVendor(...e){return t.vendors.flatMap(n=>[n+e.join(""),n+e.map(s=>t.capitalize(s)).join("")])}static capitalize(e){return e.replace(/\b[a-z]/,n=>n.toUpperCase())}static get(e,n){let s=t.polyfillEventTypeMap[n];if(s){for(let i of s)if("on"+i in e)return i}else if("on"+n in e)return n}},G=class{constructor(e){this.lastExecutionTime=0;this.scheduledTask=null;this.rafId=null;this.delayThreshold=e;let n=Date.now||function(){return new Date().getTime()},s=n();this.now=()=>l.performance&&l.performance.now?l.performance.now():n()-s;let i=0;this.requestAnimationFrame=l.requestAnimationFrame||l.webkitRequestAnimationFrame||l.mozRequestAnimationFrame||l.oRequestAnimationFrame||l.msRequestAnimationFrame||(o=>{let r=this.now(),a=Math.max(0,16-(r-i)),h=window.setTimeout(function(){o(r+a)},a);return i=r+a,h}),this.cancelAnimationFrame=l.cancelAnimationFrame||l.webkitCancelAnimationFrame||l.webkitCancelRequestAnimationFrame||l.mozCancelAnimationFrame||l.mozCancelRequestAnimationFrame||l.oCancelAnimationFrame||l.oCancelRequestAnimationFrame||l.msCancelAnimationFrame||l.msCancelRequestAnimationFrame||(o=>{clearTimeout(o)})}scheduleTask(e){this.now()-this.lastExecutionTime>=this.delayThreshold?(this.rafId!==null&&(this.cancelAnimationFrame(this.rafId),this.rafId=null),this.executeTask(e)):(this.scheduledTask=e,this.rafId===null&&(this.rafId=this.requestAnimationFrame(()=>this.runScheduledTask())))}executeTask(e){this.lastExecutionTime=this.now(),e()}runScheduledTask(){this.scheduledTask&&(this.executeTask(this.scheduledTask),this.scheduledTask=null,this.rafId=null)}},O=class t{constructor(e){this.addEventListener=(e,n,s)=>{if("addEventListener"in this.target){this.target.addEventListener(e,n,s);return}if("attachEvent"in this.target){this.target.attachEvent("on"+e,n);return}if("addListener"in this.target){this.target.addListener(n);return}};this.removeEventListener=(e,n,s)=>{if("removeEventListener"in this.target){this.target.removeEventListener(e,n,s);return}if("detachEvent"in this.target){this.target.detachEvent("on"+e,n);return}if("removeListener"in this.target){this.target.removeListener(n);return}return()=>{}};this.dispatchEvent=e=>{if("dispatchEvent"in this.target){this.target.dispatchEvent(e);return}if("fireEvent"in this.target){this.target.fireEvent("on"+e.type);return}};this.target=e,this.checkSupportedOptions(e)}static{this.passiveSupported=new Map}static{this.onceSupported=new Map}checkSupportedOptions(e){if(t.onceSupported.get(e.constructor)===void 0||t.passiveSupported.get(e.constructor)===void 0){t.passiveSupported.set(e.constructor,!1),t.onceSupported.set(e.constructor,!1);try{let n=()=>{},s=Object.create({},{passive:{get(){t.passiveSupported.set(e.constructor,!0)}},once:{get(){t.onceSupported.set(e.constructor,!0)}}});this.addEventListener("test",n,s),this.removeEventListener("test",n,s)}catch{}}}},P=class t{static{this.meta=new WeakMap}static{this.isActivePreventDefaultPinchGesture=!1}static{this.isActivePreventDefaultPanGesture=!1}static{this.isActivePreventDefaultSelectGesture=!1}static{this.preventDefault=e=>{(!("cancelable"in e)||e.cancelable)&&e.preventDefault()}}static{this.emptyPromise=new Promise(()=>{})}static{this.documentEventRegister=new O(document)}static activePreventDefaultPinchGesture(){return t.isActivePreventDefaultPinchGesture?t.emptyPromise:(t.isActivePreventDefaultPinchGesture=!0,t.documentEventRegister.addEventListener("touchmove",t.preventDefault,{passive:!1}),t.documentEventRegister.addEventListener("touchstart",t.preventDefault,{passive:!1}),new Promise(async e=>{let n=document.querySelectorAll('meta[name="viewport"]');if(n.length===0){let s=document.createElement("meta");s.setAttribute("name","viewport"),s.setAttribute("content","user-scalable=no"),document.head.append(s),t.meta.set(s,{})}n.forEach(s=>{let i=s.getAttribute("content");if(i){let o=t.splitViewportContent(i);t.meta.set(s,o),o["user-scalable"]="no",s.setAttribute("content",t.joinViewportContent(o))}}),setTimeout(e)}))}static inactivePreventDefaultPinchGesture(){t.isActivePreventDefaultPinchGesture&&(t.isActivePreventDefaultPinchGesture=!1,t.documentEventRegister.removeEventListener("touchmove",t.preventDefault),t.documentEventRegister.removeEventListener("touchstart",t.preventDefault),document.querySelectorAll('meta[name="viewport"]').forEach(e=>{if(t.meta.has(e)){let n=t.meta.get(e);Object.keys(n).length===0?e.remove():e.setAttribute("content",t.joinViewportContent(n))}}))}static activePreventDefaultPanGesture(){return t.isActivePreventDefaultPanGesture?t.emptyPromise:(t.isActivePreventDefaultPanGesture=!0,new Promise(e=>{t.documentEventRegister.addEventListener("touchstart",t.preventDefault,{passive:!1}),setTimeout(e)}))}static inactivePreventDefaultPanGesture(){t.isActivePreventDefaultPanGesture&&(t.isActivePreventDefaultPanGesture=!1,t.documentEventRegister.removeEventListener("touchstart",t.preventDefault))}static activePreventDefaultSelectGesture(){return t.isActivePreventDefaultSelectGesture?t.emptyPromise:(t.isActivePreventDefaultSelectGesture=!0,t.documentEventRegister.addEventListener("touchstart",t.preventDefault,{passive:!1}),new Promise(e=>{t.getStyleSheet().insertRule("html{-webkit-touch-callout: none;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);outline-style: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;-o-user-select: none;user-select: none;-webkit-user-drag: none;-khtml-user-drag: none;-moz-user-drag: none;-ms-user-drag: none;-o-user-drag: none;user-drag: none;-webkit-app-region: none;-khtml-app-region: none;-moz-app-region: none;-ms-app-region: none;-o-app-region: none;app-region: none;}"),setTimeout(e)}))}static inactivePreventDefaultSelectGesture(){if(t.isActivePreventDefaultSelectGesture){t.isActivePreventDefaultSelectGesture=!1,t.documentEventRegister.removeEventListener("touchstart",t.preventDefault);try{t.getStyleSheet().deleteRule(0)}catch{}}}static getStyleSheet(){if(!t.styleSheet){let e=document.createElement("style");document.head.append(e),t.styleSheet=e.sheet}return t.styleSheet}static splitViewportContent(e){return e.split(",").map(n=>{let s=n.trim().split("=");return{[s[0]]:s[1]}}).reduce((n,s)=>Object.assign(n,s),{})}static joinViewportContent(e){return Object.keys(e).map(n=>n+"="+e[n]).join(", ")}},V=class{constructor(){this.map=new Map}get(e,n){let s=this.parseOptions(n),i=this.map.get(e);return s.capture?i?.capture:i?.release}set(e,n,s,i){let o=this.parseCallback(s),r=this.parseOptions(i),a=O.passiveSupported.get(e.constructor),h=O.onceSupported.get(e.constructor),u=function(v){!a&&r.passive&&(v.preventDefault=function(){}),o(v),!h&&r.once&&e.removeEventListener(v.type,u)};return a&&h&&(u=o),r.capture?this.map.set(s,{capture:u,release:this.map.get(s)?.release}):this.map.set(s,{capture:this.map.get(s)?.capture,release:u}),o}delete(e,n){let s=this.parseOptions(n),i=this.map.get(e);s.capture?delete i?.capture:delete i?.release,i&&(Object.keys(i).length===0?this.map.delete(e):this.map.set(e,i))}keys(){return this.map.keys()}size(){return this.map.size}parseCallback(e){return typeof e=="function"?e:e.handleEvent}parseOptions(e){return e===void 0?{}:typeof e=="boolean"?{capture:e}:e}};var oe=(()=>{if(typeof l.TouchEvent>"u"){class t extends UIEvent{constructor(n,s){super(n,s)}}l.TouchEvent=t}if(!l.WeakMap){let t=Object.prototype.hasOwnProperty,e=(()=>{try{return Object.defineProperty({},"x",{value:1}).x===1}catch{return!1}})(),n=(i,o,r)=>{e?Object.defineProperty(i,o,{configurable:!0,writable:!0,value:r}):i[o]=r};l.WeakMap=function(){class i{constructor(){if(this===void 0)throw new TypeError("Constructor WeakMap requires 'new'");if(this._id=r("_WeakMap"),arguments.length>0)throw new TypeError("WeakMap iterable is not supported")}delete(u){if(o(this,"delete"),!s(u))return!1;let v=u[this._id];return v&&v[0]===u?(delete u[this._id],!0):!1}get(u){if(o(this,"get"),!s(u))return;let v=u[this._id];if(v&&v[0]===u)return v[1]}has(u){if(o(this,"has"),!s(u))return!1;let v=u[this._id];return!!(v&&v[0]===u)}set(u,v){if(o(this,"set"),!s(u))throw new TypeError("Invalid value used as weak map key");let p=u[this._id];return p&&p[0]===u?(p[1]=v,this):(n(u,this._id,[u,v]),this)}}function o(h,u){if(!s(h)||!t.call(h,"_id"))throw new TypeError(`${u} method called on incompatible receiver ${typeof h}`)}function r(h){return`${h}_${a()}.${a()}`}function a(){return Math.random().toString().substring(2)}return n(i,"_polyfill",!0),i}();let s=i=>Object(i)===i}l.matchMedia||(l.matchMedia=function(t){let e=l.styleMedia||l.media;if(!e){let n=document.createElement("style"),s=null;n.type="text/css",n.setAttribute("data-match-media-query","true"),document.head.appendChild(n),s="getComputedStyle"in window&&window.getComputedStyle(n)||n.currentStyle,e={matchMedium:function(i){let o="@media "+i+"{ [data-match-media-query] { width: 1px; } }";return n.styleSheet?n.styleSheet.cssText=o:n.textContent=o,document.head.removeChild(n),s.width==="1px"}}}return{matches:e.matchMedium(t),media:t}})})();var F={name:"eventlistener-manager",version:"1.0.45",description:"The EventManager is capable of handling both native and custom events seamlessly, providing a robust solution for event management in complex applications.",scripts:{test:'echo "Error: no test specified" && exit 1',build:"node build.js"},author:"",license:"MIT",type:"module",main:"dist/index.cjs",require:"dist/index.cjs",module:"dist/index.mjs",umd:"dist/index.umd.js",types:"dist/src/index.d.ts",exports:{".":{import:"./dist/index.mjs",require:"./dist/index.cjs",umd:"./dist/index.umd.js",types:"./dist/src/index.d.ts"}},repository:{type:"git",url:"https://github.com/pjy0509/eventlistener-manager"},homepage:"https://pjy0509.github.io/example/eventlistener-manager/",keywords:["event","eventlistener","listener","gesture","longpress","pan","pinch","javascript","typescript"],devDependencies:{esbuild:"^0.21.4",glob:"^10.4.1","html-webpack-plugin":"^5.6.0","ts-loader":"^9.5.1",typescript:"^5.4.5"}};var Z={mouselongpressstart:"mouselongpress",mouselongpressmove:"mouselongpress",mouselongpressend:"mouselongpress",mouselongpressleave:"mouselongpress",mousepanstart:"mousepan",mousepanmove:"mousepan",mousepanleft:"mousepan",mousepanright:"mousepan",mousepanup:"mousepan",mousepandown:"mousepan",mousepanend:"mousepan",mousepanleave:"mousepan"},_={touchlongpressstart:"touchlongpress",touchlongpressmove:"touchlongpress",touchlongpressend:"touchlongpress",touchlongpresscancel:"touchlongpress",touchpanstart:"touchpan",touchpanmove:"touchpan",touchpanleft:"touchpan",touchpanright:"touchpan",touchpanup:"touchpan",touchpandown:"touchpan",touchpanend:"touchpan",touchpancancel:"touchpan",touchpinchstart:"touchpinch",touchpinchmove:"touchpinch",touchpinchend:"touchpinch",touchpinchcancel:"touchpinch"},ee={appearancechange:"appearancechange",orientationchange:"orientationchange",resize:"resize",intersectionchange:"intersection"},B={...Z,..._,...ee};var D=class t{static{this.U=0}static{this.UR=1}static{this.R=2}static{this.DR=3}static{this.D=4}static{this.DL=5}static{this.L=6}static{this.UL=7}static{this.Unknown=-1}static get4Direction(e){return e>=0&&e<=45?t.R:e>45&&e<=135?t.D:e>135&&e<=180||e>=-180&&e<=-135?t.L:e>-135&&e<=-45?t.U:e>-45&&e<=-0?t.R:t.Unknown}static get8Direction(e){return e>=0&&e<=22.5?t.R:e>22.5&&e<=67.5?t.DR:e>67.5&&e<=112.5?t.D:e>112.5&&e<=157.5?t.DL:e>157.5&&e<=180||e>=-180&&e<=-157.5?t.L:e>-157.5&&e<=-112.5?t.UL:e>-112.5&&e<=-67.5?t.U:e>-67.5&&e<=-22.5?t.UR:e>-22.5&&e<=-0?t.R:t.Unknown}},L=class t{constructor(...e){this.t=new Date().getTime();let n=e[0],s=e[1];n instanceof MouseEvent?(this.x=n.clientX,this.y=n.clientY):n instanceof TouchEvent&&typeof s=="number"&&n.touches.length>s?(this.x=n.touches[s].clientX,this.y=n.touches[s].clientY):typeof n=="number"&&typeof s=="number"?(this.x=n,this.y=s):(this.x=NaN,this.y=NaN)}static fromMouseEvent(e){return new t(e)}static fromTouchEvent(e,n=0){return new t(e,n)}static fromCoordinate(e,n){return new t(e,n)}static center(e,n){return new t((e.x+n.x)/2,(e.y+n.y)/2)}distance(e){let n=this.x-e.x,s=this.y-e.y;return Math.sqrt(n*n+s*s)}timeDiff(e){return Math.abs(this.t-e.t)}},E=class{constructor(e,n){this.start=e,this.end=n,this.center=L.center(e,n),this.dx=n.x-e.x,this.dy=n.y-e.y,this.distance=n.distance(e),this.time=n.t-e.t,this.speed=this.distance/this.time,this.radian=Math.atan2(this.dy,this.dx),this.degree=this.radian*(180/Math.PI),this.direction=D.get8Direction(this.degree)}equals(e){return this.start.x===e.start.x&&this.end.x===e.end.x&&this.start.y===e.start.y&&this.end.y===e.end.y}},A=class extends Array{constructor(e){super(),e.length>0&&(this.push(...e),this.first=e[0],this.last=e[this.length-1])}item(e){if(this.length>e)return this[e]}dPath(e,n){if(e<1)return;let s=this.item(e),i=this.item(e-1);if(s&&i){let o=s[n],r=i[n];if(o instanceof L&&r instanceof L)return new E(o,r)}}dNumber(e,n){if(e<1)return;let s=this.item(e),i=this.item(e-1);if(s&&i){let o=s[n],r=i[n];if(typeof o=="number"&&typeof r=="number")return r-o}}dStart(e){return this.dPath(e,"start")}dEnd(e){return this.dPath(e,"end")}dCenter(e){return this.dPath(e,"center")}dDistance(e){return this.dNumber(e,"distance")}dRadian(e){return this.dNumber(e,"radian")}dDegree(e){return this.dNumber(e,"degree")}},I=class{static{this.Dark=0}static{this.Light=1}},S=class{static{this.Portrait=0}static{this.Landscape=1}},j=class{constructor(e){this.width=e.outerWidth||e.offsetWidth||e.width||NaN,this.height=e.outerHeight||e.offsetHeight||e.height||NaN}};var U=class{static clone(e){return Object.assign({},e)}},g=class extends MouseEvent{constructor(e,n,s=[]){super(e,U.clone(n)),this.paths=new A(s)}},T=class extends TouchEvent{constructor(e,n,s=[]){super(e,U.clone(n)),this.paths=new A(s)}},b=class extends UIEvent{constructor(e,n,s){super(e,U.clone(n)),this.property=s}};var R=new G(5),C=class t{static{this.instance={generalEventInstance:new WeakMap,extendedEventInstance:new WeakMap}}static{this.options={strict:!0,mouseLongpressTimeRequired:750,mouseLongpressBelowDistance:15,touchLongpressTimeRequired:750,touchLongpressBelowDistance:30,callWhenAddedUIEvent:!0}}static{this.resizeObserver=void 0}static{this.intersectionObserver=void 0}static{this.version=F.version}static on(e,n,s,i){for(let o of t.toArray(n))if(t.extendedEventKey(o))t.addExtendedEventListener(e,n,s,i);else{if(!H.get(e,o))continue;t.addEventListener(e,o,s,i)}}static addEventListener(e,n,s,i){new O(e).addEventListener(n,t.storeEventListener(e,n,s,i),i)}static removeEventListener(e,n,s,i){t.off(e,n,s,i)}static dispatchEvent(e,n){new O(e).dispatchEvent(n)}static extendedEventKey(e){return B[e]}static addExtendedEventListener(e,n,s,i){for(let o of t.toArray(n))switch(t.addEventListener(e,o,s,i),t.extendedEventKey(o)){case"mouselongpress":t.addMouseLongpressEvent(e);break;case"mousepan":t.addMousePanEvent(e);break;case"touchlongpress":t.addTouchLongpressEvent(e);break;case"touchpan":t.addTouchPanEvent(e);break;case"touchpinch":t.addTouchPinchEvent(e);break;case"appearancechange":t.addAppearanceChange(e);break;case"orientationchange":t.addOrientationChange(e);break;case"resize":t.addResize(e);break;case"intersection":t.addIntersection(e);break}}static off(e,n,s,i){let o=t.instance.generalEventInstance.get(e);if(o)if(n)t.removeEventListenerFromType(e,n,s,i);else{let r=o.keys(),a=r.next();for(;!a.done;){let h=a.value;t.removeEventListenerFromType(e,h,s,i),a=r.next()}}}static removeEventListenerFromType(e,n,s,i){let o=t.instance.generalEventInstance.get(e);if(o)for(let r of t.toArray(n)){let a=[],h=o.get(r);if(h){let v=h.keys(),p=v.next();for(;!p.done;){let m=h.get(p.value,i);if(m){let x=t.matchAndRemoveListener(e,r,m,s,i);x&&a.push(x)}p=v.next()}for(let m of a)h.delete(m,i);h.size()===0&&o.delete(n)}o.size===0&&t.instance.generalEventInstance.delete(e);let u=t.extendedEventKey(r);if(u){let v=o.keys(),p=v.next(),m=!0;e:for(;!p.done;){let x=p.value;for(let d of t.toArray(x))if(u===t.extendedEventKey(d)){m=!1;break e}p=v.next()}m&&t.removeExtendedEvent(e,u,i)}}}static matchAndRemoveListener(e,n,s,i,o){if(!i||i===s)return t.removeEventListenerOne(e,n,s,o)}static removeEventListenerOne(e,n,s,i){let o=t.instance.generalEventInstance.get(e)?.get(n)?.get(s,i);return o&&(new O(e).removeEventListener(n,o,i),t.instance.generalEventInstance.get(e)?.get(n)?.delete(s,i)),s}static storeEventListener(e,n,s,i){let o=t.getOrCreateListenerMap(e,n),r=o.set(e,n,s,i);return t.getOrCreateEventListenerEventMap(e).set(n,o),r}static getOrCreateListenerMap(e,n){let s=t.getOrCreateEventListenerEventMap(e),i=s.get(n);if(i)return i;{let o=new V;return s.set(n,o),o}}static getOrCreateEventListenerEventMap(e){let n=t.instance.generalEventInstance.get(e);if(n)return n;{let s=new Map;return t.instance.generalEventInstance.set(e,s),s}}static getExtendedEvent(e){return t.instance.extendedEventInstance.get(e)}static addExtendedEvent(e,n,s){let i=t.getExtendedEvent(e)||{};t.instance.extendedEventInstance.set(e,{...i,[n]:s})}static hasExtendedEventImplementation(e,n){return!!t.getExtendedEvent(e)?.[n]}static removeExtendedEvent(e,n,s){let i=t.getExtendedEvent(e);if(i){let o=i[n];if(o)for(let r in o){let a=o[r];if(a instanceof Array)for(let h of a)t.removeEventListener(e,r,h,s);else typeof a=="function"&&a()}delete i[n],Object.keys(i).length===0&&t.instance.extendedEventInstance.delete(e)}}static addMouseLongpressEvent(e){if(!t.hasExtendedEventImplementation(e,"mouselongpress")){let n,s,i=!1,o=()=>{t.removeEventListener(e,"mousemove",v),t.removeEventListener(e,"mouseup",a),t.removeEventListener(e,"mouseleave",h),s&&clearTimeout(s)},r=p=>{i=!0,n=L.fromMouseEvent(p),o(),t.addEventListener(e,"mousemove",v,{passive:!1}),s=setTimeout(()=>{t.dispatchEvent(e,new g("mouselongpressstart",p)),t.removeEventListener(e,"mouseup",o),t.removeEventListener(e,"mouseleave",o),t.addEventListener(e,"mouseup",a,{passive:!1}),t.addEventListener(e,"mouseleave",h,{passive:!1})},t.options.mouseLongpressTimeRequired)},a=p=>{n&&t.dispatchEvent(e,new g("mouselongpressend",p,[new E(n,L.fromMouseEvent(p))])),o()},h=p=>{n&&t.dispatchEvent(e,new g("mouselongpressleave",p,[new E(n,L.fromMouseEvent(p))])),o()},u=()=>{i=!1},v=p=>{if(!i){o();return}if(n){let m=L.fromMouseEvent(p);n.timeDiff(m)t.options.mouseLongpressBelowDistance?o():n.timeDiff(m)>=t.options.mouseLongpressTimeRequired&&(t.options.strict?t.dispatchEvent(e,new g("mouselongpressmove",p,[new E(n,m)])):R.scheduleTask(()=>{i&&t.dispatchEvent(e,new g("mouselongpressmove",p,[new E(n,m)]))}))}};t.addEventListener(e,"mousedown",r,{passive:!1}),t.addEventListener(e,"mouseup",o,{passive:!1}),t.addEventListener(e,"mouseleave",o,{passive:!1}),t.addEventListener(e,"mouseup",u,{passive:!1}),t.addEventListener(e,"mouseleave",u,{passive:!1}),t.addExtendedEvent(e,"mouselongpress",{mousedown:[r],mouseup:[a,u,o],mouseleave:[a,u,o],mousemove:[v]})}}static addMousePanEvent(e){if(!t.hasExtendedEventImplementation(e,"mousepan")){let n,s,i=[],o=!1,r=!1,a=()=>{i=[],o=!1,t.removeEventListener(e,"mousemove",x),t.removeEventListener(e,"mouseup",u),t.removeEventListener(e,"mouseleave",v)},h=d=>{r=!0,n=L.fromMouseEvent(d),s=n,a(),t.addEventListener(e,"mousemove",x,{passive:!1}),t.addEventListener(e,"mouseup",u,{passive:!1}),t.addEventListener(e,"mouseleave",v,{passive:!1})},u=d=>{o&&n&&(m(d),t.dispatchEvent(e,new g("mousepanend",d,[new E(n,L.fromMouseEvent(d))]))),a()},v=d=>{o&&n&&(m(d),t.dispatchEvent(e,new g("mousepanleave",d,[new E(n,L.fromMouseEvent(d))]))),a()},p=()=>{r=!1},m=d=>{if(n){let c=[],y;for(let w of i){y||(y=w.start);let M=new E(y,w.end);M.distance>=25&&(c.push(M),y=null)}let f=new Set(c.map(w=>D.get4Direction(w.degree)));if(f.size===1){let w;f.has(0)?w="mousepanup":f.has(2)?w="mousepanright":f.has(4)?w="mousepandown":f.has(6)&&(w="mousepanleft"),w&&t.dispatchEvent(e,new g(w,d,c))}}},x=d=>{if(s&&n){let c=L.fromMouseEvent(d),y=new E(s,c),f=i.length;s=c,f===0&&y.distance>0&&t.dispatchEvent(e,new g("mousepanstart",d,i)),y.distance>0&&(o=!0,i.push(y),t.options.strict?t.dispatchEvent(e,new g("mousepanmove",d,i)):R.scheduleTask(()=>{r&&t.dispatchEvent(e,new g("mousepanmove",d,i))}))}};t.addEventListener(e,"mousedown",h,{passive:!1}),t.addEventListener(e,"mouseup",p,{passive:!1}),t.addEventListener(e,"mouseleave",p,{passive:!1}),t.addExtendedEvent(e,"mousepan",{mousedown:[h],mouseup:[u,p],mouseleave:[v,p],mousemove:[x]})}}static addTouchLongpressEvent(e){if(!t.hasExtendedEventImplementation(e,"touchlongpress")){let n,s,i,o=!1,r=!1,a=()=>{o=!1,t.removeEventListener(e,"touchmove",m),t.removeEventListener(e,"touchend",u),t.removeEventListener(e,"touchcancel",v),i&&clearTimeout(i)},h=d=>{d instanceof TouchEvent&&d.touches.length===1?P.activePreventDefaultSelectGesture().then(()=>{r=!0,n=L.fromTouchEvent(d,0),s=n,a(),t.addEventListener(e,"touchmove",m,{passive:!1}),i=setTimeout(()=>{r&&(o=!0,t.dispatchEvent(e,new T("touchlongpressstart",d)),t.removeEventListener(e,"touchend",a),t.removeEventListener(e,"touchcancel",a),t.addEventListener(e,"touchend",u,{passive:!1}),t.addEventListener(e,"touchcancel",v,{passive:!1}))},t.options.touchLongpressTimeRequired)}):o?v(d):a()},u=d=>{n&&s&&t.dispatchEvent(e,new T("touchlongpressend",d,[new E(n,s)])),a()},v=d=>{n&&s&&t.dispatchEvent(e,new T("touchlongpresscancel",d,[new E(n,s)])),a()},p=()=>{r=!1,P.inactivePreventDefaultSelectGesture()},m=d=>{if(d instanceof TouchEvent&&d.touches.length===1){if(!r){a();return}if(n){let c=L.fromTouchEvent(d,0);if(n.timeDiff(c)t.options.touchLongpressBelowDistance)a();else if(n.timeDiff(c)>=t.options.touchLongpressTimeRequired&&s){let y=L.fromTouchEvent(d,0);new E(s,y).distance>0&&(t.options.strict?t.dispatchEvent(e,new T("touchlongpressmove",d,[new E(n,y)])):R.scheduleTask(()=>{r&&t.dispatchEvent(e,new T("touchlongpressmove",d,[new E(n,y)]))}))}s=c}}},x=d=>{(!("cancelable"in d)||d.cancelable)&&d.preventDefault()};t.addEventListener(e,"contextmenu",x,{passive:!1}),t.addEventListener(e,"touchstart",h,{passive:!1}),t.addEventListener(e,"touchend",a,{passive:!1}),t.addEventListener(e,"touchcancel",a,{passive:!1}),t.addEventListener(e,"touchend",p,{passive:!1}),t.addEventListener(e,"touchcancel",p,{passive:!1}),t.addExtendedEvent(e,"touchlongpress",{contextmenu:[x],touchstart:[h],touchend:[u,p,a],touchcancel:[v,p,a],touchmove:[m]})}}static addTouchPanEvent(e){if(!t.hasExtendedEventImplementation(e,"touchpan")){let n,s,i=[],o=!1,r=!1,a=()=>{i=[],o=!1,t.removeEventListener(e,"touchmove",x),t.removeEventListener(e,"touchend",u),t.removeEventListener(e,"touchcancel",v)},h=c=>{c instanceof TouchEvent&&c.touches.length===1?(P.activePreventDefaultPanGesture().then(),r=!0,n=L.fromTouchEvent(c,0),s=n,a(),t.addEventListener(e,"touchmove",x,{passive:!1}),t.addEventListener(e,"touchend",u,{passive:!1}),t.addEventListener(e,"touchcancel",v,{passive:!1})):o&&v(c)},u=c=>{o&&n&&s&&(m(c),t.dispatchEvent(e,new T("touchpanend",c,[new E(n,s)]))),a()},v=c=>{o&&n&&s&&t.dispatchEvent(e,new T("touchpancancel",c,[new E(n,s)])),a()},p=()=>{r=!1,P.inactivePreventDefaultPanGesture()},m=c=>{if(n){let y=[],f;for(let M of i){f||(f=M.start);let k=new E(f,M.end);k.distance>=25&&(y.push(k),f=null)}let w=new Set(y.map(M=>D.get4Direction(M.degree)));if(w.size===1){let M;w.has(0)?M="touchpanup":w.has(2)?M="touchpanright":w.has(4)?M="touchpandown":w.has(6)&&(M="touchpanleft"),M&&t.dispatchEvent(e,new g(M,c,y))}}},x=c=>{if(c instanceof TouchEvent&&c.touches.length===1&&s&&n){let y=L.fromTouchEvent(c,0),f=new E(s,y),w=i.length;s=y,w===0&&f.distance>0&&t.dispatchEvent(e,new T("touchpanstart",c,i)),f.distance>0&&(o=!0,i.push(f),t.options.strict?t.dispatchEvent(e,new T("touchpanmove",c,i)):R.scheduleTask(()=>{r&&t.dispatchEvent(e,new T("touchpanmove",c,i))}))}},d=c=>{(!("cancelable"in c)||c.cancelable)&&c.preventDefault()};t.addEventListener(e,"contextmenu",d,{passive:!1}),t.addEventListener(e,"touchstart",h,{passive:!1}),t.addEventListener(e,"touchend",p,{passive:!1}),t.addEventListener(e,"touchcancel",p,{passive:!1}),t.addExtendedEvent(e,"touchpan",{contextmenu:[d],touchstart:[h],touchend:[u,p],touchcancel:[v,p],touchmove:[x]})}}static addTouchPinchEvent(e){if(!t.hasExtendedEventImplementation(e,"touchpinch")){let n=[],s,i=[],o=[],r=!1,a=!1,h=()=>{n=[],i=[],o=[],r=!1,t.removeEventListener(e,"touchmove",x),t.removeEventListener(e,"touchend",v),t.removeEventListener(e,"touchcancel",p),P.inactivePreventDefaultPinchGesture()},u=c=>{if(c instanceof TouchEvent&&c.touches.length>1){P.activePreventDefaultPinchGesture().then();let y=c.touches.length;a=!0,h();for(let f=0;f{r&&n&&i&&t.dispatchEvent(e,new T("touchpinchend",c,[new E(L.center(n[0],n[1]),L.center(i[0],i[1]))])),h()},p=c=>{r&&n&&i&&t.dispatchEvent(e,new T("touchpinchcancel",c,[new E(L.center(n[0],n[1]),L.center(i[0],i[1]))])),h()},m=()=>{a=!1,P.inactivePreventDefaultPinchGesture()},x=c=>{if(i.length>1&&n.length>1&&s&&c instanceof TouchEvent&&c.touches.length>1){let y=c.touches.length,f=[],w=[],M=o.length;for(let z=0;z0&&o[M-1].equals(k))&&(r=!0,o.push(k),t.options.strict?t.dispatchEvent(e,new T("touchpinchmove",c,o)):R.scheduleTask(()=>{a&&t.dispatchEvent(e,new T("touchpinchmove",c,o))}))}},d=c=>{(!("cancelable"in c)||c.cancelable)&&c.preventDefault()};t.addEventListener(e,"contextmenu",d,{passive:!1}),t.addEventListener(e,"touchstart",u,{passive:!1}),t.addEventListener(e,"touchend",m,{passive:!1}),t.addEventListener(e,"touchcancel",m,{passive:!1}),t.addExtendedEvent(e,"touchpinch",{contextmenu:[d],touchstart:[u],touchend:[v,m],touchcancel:[p,m],touchmove:[x]})}}static addAppearanceChange(e){let n=matchMedia("(prefers-color-scheme: dark)"),s=o=>o.matches?I.Dark:I.Light,i=o=>{t.dispatchEvent(e,new b("appearancechange",o,{appearance:s(o)}))};n.addEventListener("change",i,{passive:!1}),t.options.callWhenAddedUIEvent&&t.dispatchEvent(e,new b("appearancechange",new MediaQueryListEvent("change"),{appearance:s(n)})),t.addExtendedEvent(n,"appearancechange",{change:[i]})}static addOrientationChange(e){let n=matchMedia("(orientation: portrait)"),s=o=>o.matches?S.Portrait:S.Landscape,i=o=>{t.dispatchEvent(e,new b("orientationchange",o,{orientation:s(o)}))};n.addEventListener("change",i,{passive:!1}),t.options.callWhenAddedUIEvent&&t.dispatchEvent(e,new b("appearancechange",new MediaQueryListEvent("change"),{appearance:s(n)})),t.addExtendedEvent(n,"orientationchange",{change:[i]})}static addResize(e){if(e===window||!("ResizeObserver"in window))return;let n=e,s=r=>{let a=()=>t.dispatchEvent(e,new b("resize",new Event("resize"),{size:new j(r)}));t.options.strict?a():R.scheduleTask(a)},i=!1,o;t.resizeObserver?o=t.resizeObserver:(o=new ResizeObserver(()=>{(i||t.options.callWhenAddedUIEvent)&&s(n),i=!0}),t.resizeObserver=o),o.observe(n),t.addExtendedEvent(e,"resize",{callback:()=>o.unobserve(n)})}static addIntersection(e){if(e===window||!("IntersectionObserver"in window))return;let n=e,s=r=>{let a=()=>t.dispatchEvent(e,new b("intersectionchange",new Event("intersectionchange"),{size:new j(r.intersectionRect),ration:r.intersectionRatio}));t.options.strict?a():R.scheduleTask(a)},i=!1,o;t.intersectionObserver?o=t.intersectionObserver:(o=new IntersectionObserver(r=>{if((i||t.options.callWhenAddedUIEvent)&&r.length>0){let a=r[0];s(a)}i=!0},{threshold:Array.from({length:1001},(r,a)=>a/1e3)}),t.intersectionObserver=o),o.observe(n),t.addExtendedEvent(e,"intersection",{callback:()=>{o.unobserve(n)}})}static toArray(e){return Array.isArray(e)?e:[e]}};l.ExtendedMouseEvent=g,l.ExtendedTouchEvent=T,l.ExtendedUIEvent=b,l.EventManager=C,l.EventPath=E,l.EventPathList=A,l.EventPosition=L,l.Direction=D,l.Appearance=I,l.Orientation=S,l.Size=j,EventTarget.prototype.on=function(t,e,n){C.on(this,t,e,n)},EventTarget.prototype.off=function(t,e,n){C.off(this,t,e,n)}; //# sourceMappingURL=index.cjs.map