var t=globalThis.H5P=globalThis.H5P||{};t.Event=function(t,e,i){this.type=t,this.data=e;var n=!1,r=!1,o=!1;void 0===i&&(i={}),!0===i.bubbles&&(n=!0),!0===i.external&&(r=!0),this.preventBubbling=function(){n=!1},this.getBubbles=function(){return n},this.scheduleForExternal=function(){return!(!r||o)&&(o=!0,!0)}},t.EventDispatcher=function EventDispatcher(){var e=this,i={};this.on=function(t,n,r){if("function"!=typeof n)throw TypeError("listener must be a function");e.trigger("newListener",{type:t,listener:n});var o={listener:n,thisArg:r};i[t]?i[t].push(o):i[t]=[o]},this.once=function(t,i,n){if(!(i instanceof Function))throw TypeError("listener must be a function");var once=function(t){e.off(t.type,once),i.call(this,t)};e.on(t,once,n)},this.off=function(t,n){if(void 0!==n&&!(n instanceof Function))throw TypeError("listener must be a function");if(void 0!==i[t]){if(void 0===n)return delete i[t],void e.trigger("removeListener",t);for(var r=0;r<i[t].length;r++)if(i[t][r].listener===n){i[t].splice(r,1),e.trigger("removeListener",t,{listener:n});break}i[t].length||delete i[t]}};var call=function(t,e){if(void 0!==i[t])for(var n=i[t].slice(),r=0;r<n.length;r++){var o=n[r],s=o.thisArg?o.thisArg:this;o.listener.call(s,e)}};this.trigger=function(i,n,r){if(void 0!==i){i instanceof String||"string"==typeof i?i=new t.Event(i,n,r):void 0!==n&&(i.data=n);var o=i.scheduleForExternal();call.call(this,i.type,i),call.call(this,"*",i),i.getBubbles()&&e.parent instanceof t.EventDispatcher&&(e.parent.trigger instanceof Function||"function"==typeof e.parent.trigger)&&e.parent.trigger(i),o&&t.externalDispatcher.trigger.call(this,i)}}};