var t=globalThis.H5P=globalThis.H5P||{};t.externalDispatcher=new t.EventDispatcher,t.EventDispatcher.prototype.triggerXAPI=function(t,e){this.trigger(this.createXAPIEventTemplate(t,e))},t.EventDispatcher.prototype.createXAPIEventTemplate=function(e,i){var n=new t.XAPIEvent;if(n.setActor(),n.setVerb(e),void 0!==i)for(var r in i)n.data.statement[r]=i[r];return"object"in n.data.statement||n.setObject(this),"context"in n.data.statement||n.setContext(this),n},t.EventDispatcher.prototype.triggerXAPICompleted=function(t,e,i){this.triggerXAPIScored(t,e,"completed",!0,i)},t.EventDispatcher.prototype.triggerXAPIScored=function(t,e,i,n,r){var o=this.createXAPIEventTemplate(i);o.setScoredResult(t,e,this,n,r),this.trigger(o)},t.EventDispatcher.prototype.setActivityStarted=function(){void 0===this.activityStartTime&&(void 0!==this.contentId&&void 0!==H5PIntegration.contents&&void 0!==H5PIntegration.contents["cid-"+this.contentId]&&this.triggerXAPI("attempted"),this.activityStartTime=Date.now())},t.xAPICompletedListener=function(e){if(("completed"===e.getVerb()||"answered"===e.getVerb())&&!e.getVerifiedStatementValue(["context","contextActivities","parent"])){var i=e.getScore(),n=e.getMaxScore(),r=e.getVerifiedStatementValue(["object","definition","extensions","http://h5p.org/x-api/h5p-local-content-id"]);t.setFinished(r,i,n)}};