import{aD as t,aF as e,aK as s,a$ as i,aH as n,aR as o,aJ as a,bK as r,b9 as c,aO as v}from"./p-BTBbFFOR.js";var f=function(t,e,s,i){var n,o=arguments.length,a=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var r=t.length-1;r>=0;r--)(n=t[r])&&(a=(o<3?n(a):o>3?n(e,s,a):n(e,s))||a);return o>3&&a&&Object.defineProperty(e,s,a),a};class h extends e{constructor(){super(),this.canHandle=({namespace:t})=>"vega"===t||!this.nativeEvent||"function"!=typeof this.nativeEvent.emit,this.handle=t=>this.vegaEvent.emit(t)}}f([t()],h.prototype,"vegaEvent",void 0),f([t()],h.prototype,"nativeEvent",void 0);class l extends e{constructor(){super(),this.canHandle=({namespace:t})=>"native"===t,this.handle=(t,e)=>(e&&e.stopPropagation(),this.nativeEvent.emit(t))}}!function(t,e,s,i){var n,o=arguments.length,a=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var r=t.length-1;r>=0;r--)(n=t[r])&&(a=(o<3?n(a):o>3?n(e,s,a):n(e,s))||a);o>3&&a&&Object.defineProperty(e,s,a)}([t()],l.prototype,"nativeEvent",void 0);class u extends e{constructor(){super(),this.canHandle=({namespace:t,jqueryDelegatedEvent:e})=>"native"===t&&!!e&&s.isSupportDelegated(this.host,this.eventID),this.handle=(t,e)=>{const i=s.getStrategy(this.host,this.eventID);if(i)return e&&e.stopPropagation(),i.handle(this.host,t)}}setEventID(t){this.eventID=t}}!function(t,e,s,i){var n,o=arguments.length,a=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var r=t.length-1;r>=0;r--)(n=t[r])&&(a=(o<3?n(a):o>3?n(e,s,a):n(e,s))||a);o>3&&a&&Object.defineProperty(e,s,a)}([t()],u.prototype,"host",void 0);var p=function(t,e,s,i){var n,o=arguments.length,a=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var r=t.length-1;r>=0;r--)(n=t[r])&&(a=(o<3?n(a):o>3?n(e,s,a):n(e,s))||a);return o>3&&a&&Object.defineProperty(e,s,a),a};class m extends e{constructor({eventID:t}){super(),this.vegaEventEmitHandler=new h,this.nativeEventEmitHandler=new l,this.jqueryDelegatedEventEmitHandler=new u,this.emit=(t,e)=>{let s=!1;n.notify(o.getSubject(this.host,this.eventID),{host:this.host,detail:t,eventName:this.eventName,preventDefault:()=>{s=!0}});const i=a.getSemantics(this.host);let r;for(const s of this.eventHandlers)if(s.canHandle(i)){r=s.handle(t,e);break}return r&&s&&r.preventDefault(),r},this.removeObserverFromHost=()=>{Promise.resolve(!0).then((()=>{this.isNodeRemovedFromDocument(this.host)&&r.removeUniqueObserverFromNode(this.host,this.eventID)}))},this.eventID=t,this.eventName=t.getVegaName(),this.initialEventHandlers()}isNodeRemovedFromDocument(t){var e;return!(!t||(null===(e=c())||void 0===e?void 0:e.body.contains(t))||t.parentNode)}initialEventHandlers(){this.jqueryDelegatedEventEmitHandler.setEventID(this.eventID),this.eventHandlers=[this.vegaEventEmitHandler,this.jqueryDelegatedEventEmitHandler,this.nativeEventEmitHandler]}}function d(t,e,s){const i=e.getVegaName(),n=s||e.getNativeName();return v(t,m,[{mapFrom:"host",mapTo:"host"},{mapFrom:i,mapTo:"vegaEvent"},{mapFrom:n,mapTo:"nativeEvent",isOptional:!0}],[{mapFrom:"disconnectedCallback",mapTo:"removeObserverFromHost"}],[{eventID:e}])}p([i()],m.prototype,"vegaEventEmitHandler",void 0),p([i()],m.prototype,"nativeEventEmitHandler",void 0),p([i()],m.prototype,"jqueryDelegatedEventEmitHandler",void 0);export{d as c}