scorm-again
Version:
A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004
16 lines • 87.4 kB
JavaScript
!function(){var r={"./node_modules/lodash.debounce/index.js":
/*!***********************************************!*\
!*** ./node_modules/lodash.debounce/index.js ***!
\***********************************************/function(e,s,t){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(){return f.Date.now()}var n=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt,t="object"==(void 0===t.g?"undefined":r(t.g))&&t.g&&t.g.Object===Object&&t.g,h="object"==("undefined"==typeof self?"undefined":r(self))&&self&&self.Object===Object&&self,f=t||h||Function("return this")(),d=Object.prototype.toString,_=Math.max,M=Math.min;function E(e){var t=r(e);return e&&("object"==t||"function"==t)}function m(e){return"symbol"==r(e)||!!(t=e)&&"object"==r(t)&&d.call(e)==i;var t}function b(e){if("number"==typeof e)return e;if(m(e))return n;if("string"!=typeof(e=E(e)?E(t="function"==typeof e.valueOf?e.valueOf():e)?t+"":t:e))return 0===e?e:+e;e=e.replace(o,"");var t=l.test(e);return t||c.test(e)?u(e.slice(2),t?2:8):a.test(e)?n:+e}e.exports=function(h,r,e){var n,i,o,a,s,l,c=0,f=!1,u=!1,t=!0;if("function"!=typeof h)throw new TypeError("Expected a function");function d(e){var t=n,r=i;return n=i=void 0,c=e,a=h.apply(r,t)}function m(e){var t=e-l;return void 0===l||r<=t||t<0||u&&o<=e-c}function p(){var e,t=v();if(m(t))return g(t);s=setTimeout(p,(e=r-((t=t)-l),u?M(e,o-(t-c)):e))}function g(e){return s=void 0,t&&n?d(e):(n=i=void 0,a)}function y(){var e=v(),t=m(e);if(n=arguments,i=this,l=e,t){if(void 0===s)return c=e=l,s=setTimeout(p,r),f?d(e):a;if(u)return s=setTimeout(p,r),d(l)}return void 0===s&&(s=setTimeout(p,r)),a}return r=b(r)||0,E(e)&&(f=!!e.leading,u="maxWait"in e,o=u?_(b(e.maxWait)||0,r):o,t="trailing"in e?!!e.trailing:t),y.cancel=function(){void 0!==s&&clearTimeout(s),n=l=i=s=void(c=0)},y.flush=function(){return void 0===s?a:g(v())},y}},"./src/BaseAPI.js":
/*!************************!*\
!*** ./src/BaseAPI.js ***!
\************************/function(r,e,t){"use strict";t.r(e),t.d(e,{default:function(){return T}});var p=t(/*! ./cmi/common */"./src/cmi/common.js"),l=t(/*! ./exceptions */"./src/exceptions.js"),e=t(/*! ./constants/error_codes */"./src/constants/error_codes.js"),c=t(/*! ./constants/api_constants */"./src/constants/api_constants.js"),u=t(/*! ./utilities */"./src/utilities.js"),h=t(/*! lodash.debounce */"./node_modules/lodash.debounce/index.js"),g=t.n(h);function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return v(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function b(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function _(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?b(Object(r),!0).forEach(function(e){O(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function M(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function S(e,t,r){return t&&w(e.prototype,t),r&&w(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function O(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t,r){var n=e;if(t.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}function f(e,t){t=I(e,t,"get");return t.get?t.get.call(e):t.value}function o(e,t,r){var t=I(e,t,"set"),n=r;if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}return r}function I(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}var d=c.default.global,C=e.default.scorm12,a=new WeakMap,m=new WeakMap,n=new WeakMap,T=function(){function r(e,t){if(M(this,r),i(this,a,{writable:!0,value:void 0}),i(this,m,{writable:!0,value:void 0}),i(this,n,{writable:!0,value:{autocommit:!1,autocommitSeconds:10,asyncCommit:!1,sendBeaconCommit:!1,lmsCommitUrl:!1,dataCommitFormat:"json",commitRequestDataType:"application/json;charset=UTF-8",autoProgress:!1,logLevel:d.LOG_LEVEL_ERROR,selfReportSessionTime:!1,alwaysSendTotalTime:!1,strict_errors:!0,xhrHeaders:{},xhrWithCredentials:!1,responseHandler:function(e){var t;return void 0!==e&&(null!==(t=JSON.parse(e.responseText))&&{}.hasOwnProperty.call(t,"result")||(t={},200===e.status?(t.result=d.SCORM_TRUE,t.errorCode=0):(t.result=d.SCORM_FALSE,t.errorCode=101))),t},requestHandler:function(e){return e},onLogMessage:function(e,t){switch(e){case d.LOG_LEVEL_ERROR:console.error(t);break;case d.LOG_LEVEL_WARNING:console.warn(t);break;case d.LOG_LEVEL_INFO:console.info(t);break;case d.LOG_LEVEL_DEBUG:console.debug?console.debug(t):console.log(t)}}}}),O(this,"cmi",void 0),O(this,"startingData",void 0),(this instanceof r?this.constructor:void 0)===r)throw new TypeError("Cannot construct BaseAPI instances directly");this.currentState=d.STATE_NOT_INITIALIZED,this.lastErrorCode=0,this.listenerArray=[],o(this,a,null),o(this,m,e),this.settings=t,this.apiLogLevel=this.settings.logLevel,this.selfReportSessionTime=this.settings.selfReportSessionTime}return S(r,[{key:"initialize",value:function(e,t,r){var n=d.SCORM_FALSE;return this.isInitialized()?this.throwSCORMError(f(this,m).INITIALIZED,t):this.isTerminated()?this.throwSCORMError(f(this,m).TERMINATED,r):(this.selfReportSessionTime&&this.cmi.setStartTime(),this.currentState=d.STATE_INITIALIZED,this.lastErrorCode=0,n=d.SCORM_TRUE,this.processListeners(e)),this.apiLog(e,null,"returned: "+n,d.LOG_LEVEL_INFO),this.clearSCORMError(n),n}},{key:"error_codes",get:function(){return f(this,m)}},{key:"settings",get:function(){return f(this,n)},set:function(e){o(this,n,_(_({},f(this,n)),e))}},{key:"terminate",value:function(e,t){var r,n=d.SCORM_FALSE;return this.checkState(t,f(this,m).TERMINATION_BEFORE_INIT,f(this,m).MULTIPLE_TERMINATION)&&(this.currentState=d.STATE_TERMINATED,r=this.storeData(!0),!this.settings.sendBeaconCommit&&!this.settings.asyncCommit&&void 0!==r.errorCode&&0<r.errorCode&&this.throwSCORMError(r.errorCode),n=void 0!==r&&r.result?r.result:d.SCORM_FALSE,t&&(this.lastErrorCode=0),n=d.SCORM_TRUE,this.processListeners(e)),this.apiLog(e,null,"returned: "+n,d.LOG_LEVEL_INFO),this.clearSCORMError(n),n}},{key:"getValue",value:function(e,t,r){var n;if(this.checkState(t,f(this,m).RETRIEVE_BEFORE_INIT,f(this,m).RETRIEVE_AFTER_TERM)){t&&(this.lastErrorCode=0);try{n=this.getCMIValue(r)}catch(e){e instanceof l.ValidationError?(this.lastErrorCode=e.errorCode,n=d.SCORM_FALSE):(e.message?console.error(e.message):console.error(e),this.throwSCORMError(f(this,m).GENERAL))}this.processListeners(e,r)}return this.apiLog(e,r,": returned: "+n,d.LOG_LEVEL_INFO),this.clearSCORMError(n),n}},{key:"setValue",value:function(e,t,r,n,i){void 0!==i&&(i=String(i));var o=d.SCORM_FALSE;if(this.checkState(r,f(this,m).STORE_BEFORE_INIT,f(this,m).STORE_AFTER_TERM)){r&&(this.lastErrorCode=0);try{o=this.setCMIValue(n,i)}catch(e){e instanceof l.ValidationError?(this.lastErrorCode=e.errorCode,o=d.SCORM_FALSE):(e.message?console.error(e.message):console.error(e),this.throwSCORMError(f(this,m).GENERAL))}this.processListeners(e,n,i)}return void 0===o&&(o=d.SCORM_FALSE),"0"===String(this.lastErrorCode)&&this.settings.autocommit&&!f(this,a)&&this.scheduleCommit(1e3*this.settings.autocommitSeconds,t),this.apiLog(e,n,": "+i+": result: "+o,d.LOG_LEVEL_INFO),this.clearSCORMError(o),o}},{key:"commit",value:function(e,t){this.clearScheduledCommit();var r,n=d.SCORM_FALSE;return this.checkState(t,f(this,m).COMMIT_BEFORE_INIT,f(this,m).COMMIT_AFTER_TERM)&&(r=this.storeData(!1),!this.settings.sendBeaconCommit&&!this.settings.asyncCommit&&r.errorCode&&0<r.errorCode&&this.throwSCORMError(r.errorCode),n=void 0!==r&&r.result?r.result:d.SCORM_FALSE,this.apiLog(e,"HttpRequest"," Result: "+n,d.LOG_LEVEL_DEBUG),t&&(this.lastErrorCode=0),this.processListeners(e)),this.apiLog(e,null,"returned: "+n,d.LOG_LEVEL_INFO),this.clearSCORMError(n),n}},{key:"getLastError",value:function(e){var t=String(this.lastErrorCode);return this.processListeners(e),this.apiLog(e,null,"returned: "+t,d.LOG_LEVEL_INFO),t}},{key:"getErrorString",value:function(e,t){var r="";return null!==t&&""!==t&&(r=this.getLmsErrorMessageDetails(t),this.processListeners(e)),this.apiLog(e,null,"returned: "+r,d.LOG_LEVEL_INFO),r}},{key:"getDiagnostic",value:function(e,t){var r="";return null!==t&&""!==t&&(r=this.getLmsErrorMessageDetails(t,!0),this.processListeners(e)),this.apiLog(e,null,"returned: "+r,d.LOG_LEVEL_INFO),r}},{key:"checkState",value:function(e,t,r){return this.isNotInitialized()?(this.throwSCORMError(t),!1):!e||!this.isTerminated()||(this.throwSCORMError(r),!1)}},{key:"apiLog",value:function(e,t,r,n){r=this.formatMessage(e,t,r),n>=this.apiLogLevel&&this.settings.onLogMessage(n,r)}},{key:"formatMessage",value:function(e,t,r){for(var n="",i=20-(n+=e).length,o=0;o<i;o++)n+=" ";if(n+=": ",t)for(var i=70-(n+=t).length,a=0;a<i;a++)n+=" ";return r&&(n+=r),n}},{key:"stringMatches",value:function(e,t){return e&&t&&e.match(t)}},{key:"_checkObjectHasProperty",value:function(e,t){return Object.hasOwnProperty.call(e,t)||Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t)||t in e}},{key:"getLmsErrorMessageDetails",value:function(e,t){throw new Error("The getLmsErrorMessageDetails method has not been implemented")}},{key:"getCMIValue",value:function(e){throw new Error("The getCMIValue method has not been implemented")}},{key:"setCMIValue",value:function(e,t){throw new Error("The setCMIValue method has not been implemented")}},{key:"_commonSetCMIValue",value:function(u,e,t,r){if(!t||""===t)return d.SCORM_FALSE;for(var n=t.split("."),i=this,o=d.SCORM_FALSE,a=!1,s="The data model element passed to ".concat(u," (").concat(t,") is not a valid SCORM data model element."),h=e?f(this,m).UNDEFINED_DATA_MODEL:f(this,m).GENERAL,l=0;l<n.length;l++){var c=n[l];if(l===n.length-1)e&&"{target="===c.substr(0,8)&&"function"==typeof i._isTargetValid?this.throwSCORMError(f(this,m).READ_ONLY_ELEMENT):this._checkObjectHasProperty(i,c)?(this.isInitialized()&&this.stringMatches(t,"\\.correct_responses\\.\\d+")&&this.validateCorrectResponse(t,r),e&&0!==this.lastErrorCode||(i[c]=r,o=d.SCORM_TRUE)):this.throwSCORMError(h,s);else{if(!(i=i[c])){this.throwSCORMError(h,s);break}i instanceof p.CMIArray&&(c=parseInt(n[l+1],10),isNaN(c)||((c=i.childArray[c])?(i=c,a=!0):(c=this.getChildElement(t,r,a),a=!0,c?(i.initialized&&c.initialize(),i.childArray.push(c),i=c):this.throwSCORMError(h,s)),l++))}}return o===d.SCORM_FALSE&&this.apiLog(u,null,"There was an error setting the value for: ".concat(t,", value of: ").concat(r),d.LOG_LEVEL_WARNING),o}},{key:"validateCorrectResponse",value:function(e,t){}},{key:"getChildElement",value:function(e,t,r){throw new Error("The getChildElement method has not been implemented")}},{key:"_commonGetCMIValue",value:function(e,t,r){if(!r||""===r)return"";for(var n=r.split("."),i=this,o=null,u="The data model element passed to ".concat(e," (").concat(r,") has not been initialized."),a="The data model element passed to ".concat(e," (").concat(r,") is not a valid SCORM data model element."),s=t?f(this,m).UNDEFINED_DATA_MODEL:f(this,m).GENERAL,l=0;l<n.length;l++){if(o=n[l],t){if("{target="===String(o).substr(0,8)&&"function"==typeof i._isTargetValid)return c=String(o).substr(8,String(o).length-9),i._isTargetValid(c);if(!this._checkObjectHasProperty(i,o))return void this.throwSCORMError(s,a)}else if(l===n.length-1&&!this._checkObjectHasProperty(i,o))return void this.throwSCORMError(s,a);if(void 0===(i=i[o])){this.throwSCORMError(s,a);break}if(i instanceof p.CMIArray){var c=parseInt(n[l+1],10);if(!isNaN(c)){var h=i.childArray[c];if(!h){this.throwSCORMError(f(this,m).VALUE_NOT_INITIALIZED,u);break}i=h,l++}}}if(null!=i)return i;t||("_children"===o?this.throwSCORMError(C.CHILDREN_ERROR):"_count"===o&&this.throwSCORMError(C.COUNT_ERROR))}},{key:"isInitialized",value:function(){return this.currentState===d.STATE_INITIALIZED}},{key:"isNotInitialized",value:function(){return this.currentState===d.STATE_NOT_INITIALIZED}},{key:"isTerminated",value:function(){return this.currentState===d.STATE_TERMINATED}},{key:"on",value:function(e,t){if(t)for(var r=e.split(" "),n=0;n<r.length;n++){var i=r[n].split(".");if(0===i.length)return;var o=i[0],a=null;1<i.length&&(a=e.replace(o+".","")),this.listenerArray.push({functionName:o,CMIElement:a,callback:t}),this.apiLog("on",o,"Added event listener: ".concat(this.listenerArray.length),d.LOG_LEVEL_INFO)}}},{key:"off",value:function(n,i){var o=this;if(i)for(var a=n.split(" "),e=0;e<a.length;e++){var t=function(e){e=a[e].split(".");if(0===e.length)return{v:void 0};var t=e[0],r=null,e=(1<e.length&&(r=n.replace(t+".","")),o.listenerArray.findIndex(function(e){return e.functionName===t&&e.CMIElement===r&&e.callback===i}));-1!==e&&(o.listenerArray.splice(e,1),o.apiLog("off",t,"Removed event listener: ".concat(o.listenerArray.length),d.LOG_LEVEL_INFO))}(e);if("object"===E(t))return t.v}}},{key:"clear",value:function(n){for(var i=this,o=n.split(" "),e=0;e<o.length;e++){var t=function(e){e=o[e].split(".");if(0===e.length)return{v:void 0};var t=e[0],r=null;1<e.length&&(r=n.replace(t+".","")),i.listenerArray=i.listenerArray.filter(function(e){return e.functionName!==t&&e.CMIElement!==r})}(e);if("object"===E(t))return t.v}}},{key:"processListeners",value:function(e,t,r){this.apiLog(e,t,r);for(var n=0;n<this.listenerArray.length;n++){var i=this.listenerArray[n],o=i.functionName===e,a=!!i.CMIElement,s=!1,s=t&&i.CMIElement&&"*"===i.CMIElement.substring(i.CMIElement.length-1)?0===t.indexOf(i.CMIElement.substring(0,i.CMIElement.length-1)):i.CMIElement===t;!o||a&&!s||i.callback(t,r)}}},{key:"throwSCORMError",value:function(e,t){t=t||this.getLmsErrorMessageDetails(e),this.apiLog("throwSCORMError",null,e+": "+t,d.LOG_LEVEL_ERROR),this.lastErrorCode=String(e)}},{key:"clearSCORMError",value:function(e){void 0!==e&&e!==d.SCORM_FALSE&&(this.lastErrorCode=0)}},{key:"storeData",value:function(e){throw new Error("The storeData method has not been implemented")}},{key:"loadFromFlattenedJSON",value:function(t,r){var n,i,e,o,a=this;function s(e,t,r){var n,e=e.match(r);return null!==e&&null!==(n=t.match(r))?(t=Number(e[2]))===(r=Number(n[2]))?"id"!==e[3]&&("type"!==e[3]||"id"===n[3])?1:-1:t-r:null}this.isNotInitialized()?(n=/^(cmi\.interactions\.)(\d+)\.(.*)$/,i=/^(cmi\.objectives\.)(\d+)\.(.*)$/,(e=Object.keys(t).map(function(e){return[String(e),t[e]]})).sort(function(e,t){var e=y(e,2),r=e[0],e=(e[1],y(t,2)),t=e[0];e[1];return null!==(e=s(r,t,n))||null!==(e=s(r,t,i))?e:r<t?-1:t<r?1:0}),e.forEach(function(e){(o={})[e[0]]=e[1],a.loadFromJSON((0,u.unflatten)(o),r)})):console.error("loadFromFlattenedJSON can only be called before the call to lmsInitialize.")}},{key:"loadFromJSON",value:function(e,t){if(this.isNotInitialized()){for(var r in t=void 0!==t?t:"cmi",this.startingData=e)if({}.hasOwnProperty.call(e,r)&&e[r]){var n=(t?t+".":"")+r,i=e[r];if(i.childArray)for(var o=0;o<i.childArray.length;o++)this.loadFromJSON(i.childArray[o],n+"."+o);else i.constructor===Object?this.loadFromJSON(i,n):this.setCMIValue(n,i)}}else console.error("loadFromJSON can only be called before the call to lmsInitialize.")}},{key:"renderCMIToJSONString",value:function(){var e=this.cmi;return JSON.stringify({cmi:e})}},{key:"renderCMIToJSONObject",value:function(){return JSON.parse(this.renderCMIToJSONString())}},{key:"renderCommitCMI",value:function(e){throw new Error("The storeData method has not been implemented")}},{key:"processHttpRequest",value:function(e,t){function r(e,t,r,n){if(n={result:d.SCORM_FALSE,errorCode:n.GENERAL},r.sendBeaconCommit)try{var i={type:r.commitRequestDataType},o=t instanceof Array?new Blob([t.join("&")],i):new Blob([JSON.stringify(t)],i),a={};navigator.sendBeacon(e,o)?(a.result=d.SCORM_TRUE,a.errorCode=0):(a.result=d.SCORM_FALSE,a.errorCode=101)}catch(e){return console.error(e),l.processListeners("CommitError"),n}else{var s=new XMLHttpRequest;s.open("POST",e,r.asyncCommit),Object.keys(r.xhrHeaders).length&&Object.keys(r.xhrHeaders).forEach(function(e){s.setRequestHeader(e,r.xhrHeaders[e])}),s.withCredentials=r.xhrWithCredentials,r.asyncCommit&&(s.onload=function(e){a="function"==typeof r.responseHandler?r.responseHandler(s):JSON.parse(s.responseText)});try{if((t=r.requestHandler(t))instanceof Array?(s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(t.join("&"))):(s.setRequestHeader("Content-Type",r.commitRequestDataType),s.send(JSON.stringify(t))),r.asyncCommit)return(a={}).result=d.SCORM_TRUE,a.errorCode=0,l.processListeners("CommitSuccess"),a;a="function"==typeof r.responseHandler?r.responseHandler(s):JSON.parse(s.responseText)}catch(e){return console.error(e),l.processListeners("CommitError"),n}}return void 0===a?(l.processListeners("CommitError"),n):(!0===a.result||a.result===d.SCORM_TRUE?l.processListeners("CommitSuccess"):l.processListeners("CommitError"),a)}var n,i=2<arguments.length&&void 0!==arguments[2]&&arguments[2],l=this;return void 0!==g()?((n=g()(r,500))(e,t,this.settings,this.error_codes),i&&n.flush(),{result:d.SCORM_TRUE,errorCode:0}):r(e,t,this.settings,this.error_codes)}},{key:"scheduleCommit",value:function(e,t){o(this,a,new j(this,e,t)),this.apiLog("scheduleCommit","","scheduled",d.LOG_LEVEL_DEBUG)}},{key:"clearScheduledCommit",value:function(){f(this,a)&&(f(this,a).cancel(),o(this,a,null),this.apiLog("clearScheduledCommit","","cleared",d.LOG_LEVEL_DEBUG))}}]),r}(),k=new WeakMap,R=new WeakMap,s=new WeakMap,L=new WeakMap,j=function(){function n(e,t,r){M(this,n),i(this,k,{writable:!0,value:void 0}),i(this,R,{writable:!0,value:!1}),i(this,s,{writable:!0,value:void 0}),i(this,L,{writable:!0,value:void 0}),o(this,k,e),o(this,s,setTimeout(this.wrapper.bind(this),t)),o(this,L,r)}return S(n,[{key:"cancel",value:function(){o(this,R,!0),f(this,s)&&clearTimeout(f(this,s))}},{key:"wrapper",value:function(){f(this,R)||f(this,k).commit(f(this,L))}}]),n}()},"./src/Scorm2004API.js":
/*!*****************************!*\
!*** ./src/Scorm2004API.js ***!
\*****************************/function(r,e,t){"use strict";t.r(e),t.d(e,{default:function(){return I}});var e=t(/*! ./BaseAPI */"./src/BaseAPI.js"),a=t(/*! ./cmi/scorm2004_cmi */"./src/cmi/scorm2004_cmi.js"),o=t(/*! ./utilities */"./src/utilities.js"),n=t(/*! ./constants/api_constants */"./src/constants/api_constants.js"),f=t(/*! ./constants/error_codes */"./src/constants/error_codes.js"),d=t(/*! ./constants/response_constants */"./src/constants/response_constants.js"),m=t(/*! ./constants/language_constants */"./src/constants/language_constants.js"),t=t(/*! ./constants/regex */"./src/constants/regex.js");function p(e){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function g(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function y(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?g(Object(r),!0).forEach(function(e){_(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function E(e,t){return(E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function b(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t=i(r),t=(e=n?(e=i(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments),this);if(e&&("object"===p(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function M(e,t,r){var n=e;if(t.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}function w(e,t){t=function(e,t,r){if(t.has(e))return t.get(e);throw new TypeError("attempted to "+r+" private field on non-instance")}(e,t,"get");return t.get?t.get.call(e):t.value}var l=n.default.scorm2004,c=n.default.global,u=f.default.scorm2004,h=d.default.correct,S=t.default.scorm2004,O=new WeakMap,I=function(e){var t=i;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&E(t,e);var r,n=b(i);function i(e){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");var e=y(y({},{mastery_override:!1}),e);return M(s(e=n.call(this,u,e)),O,{writable:!0,value:void 0}),_(s(e),"checkDuplicatedPattern",function(e,t,r){for(var n=!1,i=e._count,o=0;o<i&&!n;o++)o!==t&&e.childArray[o]===r&&(n=!0);return n}),e.cmi=new a.CMI,e.adl=new a.ADL,e.Initialize=e.lmsInitialize,e.Terminate=e.lmsTerminate,e.GetValue=e.lmsGetValue,e.SetValue=e.lmsSetValue,e.Commit=e.lmsCommit,e.GetLastError=e.lmsGetLastError,e.GetErrorString=e.lmsGetErrorString,e.GetDiagnostic=e.lmsGetDiagnostic,e}return t=i,(e=[{key:"version",get:function(){return w(this,O)}},{key:"lmsInitialize",value:function(){return this.cmi.initialize(),this.initialize("Initialize")}},{key:"lmsTerminate",value:function(){var e=this.terminate("Terminate",!0);if(e===c.SCORM_TRUE)if("_none_"!==this.adl.nav.request)switch(this.adl.nav.request){case"continue":this.processListeners("SequenceNext");break;case"previous":this.processListeners("SequencePrevious");break;case"choice":this.processListeners("SequenceChoice");break;case"exit":this.processListeners("SequenceExit");break;case"exitAll":this.processListeners("SequenceExitAll");break;case"abandon":this.processListeners("SequenceAbandon");break;case"abandonAll":this.processListeners("SequenceAbandonAll")}else this.settings.autoProgress&&this.processListeners("SequenceNext");return e}},{key:"lmsGetValue",value:function(e){return this.getValue("GetValue",!0,e)}},{key:"lmsSetValue",value:function(e,t){return this.setValue("SetValue","Commit",!0,e,t)}},{key:"lmsCommit",value:function(){return this.commit("Commit")}},{key:"lmsGetLastError",value:function(){return this.getLastError("GetLastError")}},{key:"lmsGetErrorString",value:function(e){return this.getErrorString("GetErrorString",e)}},{key:"lmsGetDiagnostic",value:function(e){return this.getDiagnostic("GetDiagnostic",e)}},{key:"setCMIValue",value:function(e,t){return this._commonSetCMIValue("SetValue",!0,e,t)}},{key:"getChildElement",value:function(e,t,r){var n,i,o;return this.stringMatches(e,"cmi\\.objectives\\.\\d+")?n=new a.CMIObjectivesObject:r&&this.stringMatches(e,"cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+")?(i=e.split("."),i=Number(i[2]),i=this.cmi.interactions.childArray[i],this.isInitialized()&&(i.type?(this.checkDuplicateChoiceResponse(i,t),(o=h[i.type])?this.checkValidResponseType(o,t,i.type):this.throwSCORMError(u.GENERAL_SET_FAILURE,"Incorrect Response Type: "+i.type)):this.throwSCORMError(u.DEPENDENCY_NOT_ESTABLISHED)),0===this.lastErrorCode&&(n=new a.CMIInteractionsCorrectResponsesObject)):r&&this.stringMatches(e,"cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")?n=new a.CMIInteractionsObjectivesObject:!r&&this.stringMatches(e,"cmi\\.interactions\\.\\d+")?n=new a.CMIInteractionsObject:this.stringMatches(e,"cmi\\.comments_from_learner\\.\\d+")?n=new a.CMICommentsObject:this.stringMatches(e,"cmi\\.comments_from_lms\\.\\d+")&&(n=new a.CMICommentsObject(!0)),n}},{key:"checkValidResponseType",value:function(e,t,r){var n=[];null!=e&&e.delimiter?n=String(t).split(e.delimiter):n[0]=t,0<n.length&&n.length<=e.max?this.checkCorrectResponseValue(r,n,t):n.length>e.max&&this.throwSCORMError(u.GENERAL_SET_FAILURE,"Data Model Element Pattern Too Long")}},{key:"checkDuplicateChoiceResponse",value:function(e,t){var r=e.correct_responses._count;if("choice"===e.type)for(var n=0;n<r&&0===this.lastErrorCode;n++)e.correct_responses.childArray[n].pattern===t&&this.throwSCORMError(u.GENERAL_SET_FAILURE)}},{key:"validateCorrectResponse",value:function(e,t){var e=e.split("."),r=Number(e[2]),e=Number(e[4]),r=this.cmi.interactions.childArray[r],n=r.correct_responses._count,i=(this.checkDuplicateChoiceResponse(r,t),h[r.type]);void 0===i.limit||n<=i.limit?(this.checkValidResponseType(i,t,r.type),0===this.lastErrorCode&&(!i.duplicate||!this.checkDuplicatedPattern(r.correct_responses,e,t))||0===this.lastErrorCode&&""===t||0===this.lastErrorCode&&this.throwSCORMError(u.GENERAL_SET_FAILURE,"Data Model Element Pattern Already Exists")):this.throwSCORMError(u.GENERAL_SET_FAILURE,"Data Model Element Collection Limit Reached")}},{key:"getCMIValue",value:function(e){return this._commonGetCMIValue("GetValue",!0,e)}},{key:"getLmsErrorMessageDetails",value:function(e,t){var r="",n="";return e=String(e),l.error_descriptions[e]&&(r=l.error_descriptions[e].basicMessage,n=l.error_descriptions[e].detailMessage),t?n:r}},{key:"checkCorrectResponseValue",value:function(e,t,r){for(var n=h[e],i=new RegExp(n.format),o=0;o<t.length&&0===this.lastErrorCode;o++)if(e.match("^(fill-in|long-fill-in|matching|performance|sequencing)$")&&(t[o]=this.removeCorrectResponsePrefixes(t[o])),null!=n&&n.delimiter2){var a=t[o].split(n.delimiter2);2===a.length&&a[0].match(i)&&a[1].match(new RegExp(n.format2))||this.throwSCORMError(u.TYPE_MISMATCH)}else{a=t[o].match(i);if(!a&&""!==r||!a&&"true-false"===e)this.throwSCORMError(u.TYPE_MISMATCH);else if("numeric"===e&&1<t.length)Number(t[0])>Number(t[1])&&this.throwSCORMError(u.TYPE_MISMATCH);else if(""!==t[o]&&n.unique)for(var s=0;s<o&&0===this.lastErrorCode;s++)t[o]===t[s]&&this.throwSCORMError(u.TYPE_MISMATCH)}}},{key:"removeCorrectResponsePrefixes",value:function(e){for(var t,r=!1,n=!1,i=!1,o=new RegExp("^({(lang|case_matters|order_matters)=([^}]+)})"),a=e.match(o);a;){switch(a[2]){case"lang":!(t=e.match(S.CMILangcr))||void 0!==(t=t[3])&&0<t.length&&void 0===m.default[t.toLowerCase()]&&this.throwSCORMError(u.TYPE_MISMATCH),i=!0;break;case"case_matters":i||r||n||"true"!==a[3]&&"false"!==a[3]&&this.throwSCORMError(u.TYPE_MISMATCH),n=!0;break;case"order_matters":n||i||r||"true"!==a[3]&&"false"!==a[3]&&this.throwSCORMError(u.TYPE_MISMATCH),r=!0}a=(e=e.substr(a[1].length)).match(o)}return e}},{key:"replaceWithAnotherScormAPI",value:function(e){this.cmi=e.cmi,this.adl=e.adl}},{key:"renderCommitCMI",value:function(e){var t=this.renderCMIToJSONObject(),r=(e&&(t.cmi.total_time=this.cmi.getCurrentTotalTime()),[]),n=o.flatten(t);switch(this.settings.dataCommitFormat){case"flattened":return o.flatten(t);case"params":for(var i in n)!{}.hasOwnProperty.call(n,i)||r.push("".concat(i,"=").concat(n[i]));return r;default:return t}}},{key:"storeData",value:function(e){e&&"normal"===this.cmi.mode&&"credit"===this.cmi.credit&&(this.cmi.completion_threshold&&this.cmi.progress_measure&&(this.cmi.progress_measure>=this.cmi.completion_threshold?(console.debug("Setting Completion Status: Completed"),this.cmi.completion_status="completed"):(console.debug("Setting Completion Status: Incomplete"),this.cmi.completion_status="incomplete")),this.cmi.scaled_passing_score&&this.cmi.score.scaled&&(this.cmi.score.scaled>=this.cmi.scaled_passing_score?(console.debug("Setting Success Status: Passed"),this.cmi.success_status="passed"):(console.debug("Setting Success Status: Failed"),this.cmi.success_status="failed")));var t,r,n=!1,i=(this.adl.nav.request!==(null===(i=this.startingData)||void 0===i||null===(r=i.adl)||void 0===r||null===(t=r.nav)||void 0===t?void 0:t.request)&&"_none_"!==this.adl.nav.request&&(this.adl.nav.request=encodeURIComponent(this.adl.nav.request),n=!0),this.renderCommitCMI(e||this.settings.alwaysSendTotalTime));return this.apiLogLevel===c.LOG_LEVEL_DEBUG&&(console.debug("Commit (terminated: "+(e?"yes":"no")+"): "),console.debug(i)),this.settings.lmsCommitUrl?(r=this.processHttpRequest(this.settings.lmsCommitUrl,i,e),n&&void 0!==r.navRequest&&""!==r.navRequest&&Function('"use strict";(() => { '.concat(r.navRequest," })()"))(),r):c.SCORM_TRUE}}])&&v(t.prototype,e),r&&v(t,r),Object.defineProperty(t,"prototype",{writable:!1}),i}(e.default)},"./src/cmi/common.js":
/*!***************************!*\
!*** ./src/cmi/common.js ***!
\***************************/function(r,n,e){"use strict";e.r(n),e.d(n,{BaseCMI:function(){return k},CMIArray:function(){return z},CMIScore:function(){return D},checkValidFormat:function(){return O},checkValidRange:function(){return I}});var n=e(/*! ../constants/api_constants */"./src/constants/api_constants.js"),i=e(/*! ../constants/error_codes */"./src/constants/error_codes.js"),e=e(/*! ../constants/regex */"./src/constants/regex.js");function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function l(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t=c(r),t=(e=n?(e=c(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments),this);if(e&&("object"===o(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function b(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(e,t,r){var n=e;if(t.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}function d(e,t,r){var t=_(e,t,"set"),n=r;if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}return r}function t(e,t){t=_(e,t,"get");return t.get?t.get.call(e):t.value}function _(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}var M=n.default.scorm12,w=e.default.scorm12,S=i.default.scorm12;function O(e,t,r,n,i){t=new RegExp(t),t=e.match(t);if(i&&""===e)return!0;if(void 0===e||!t||""===t[0])throw new n.prototype.constructor(r);return!0}function I(e,t,r,n){t=t.split("#");if((e=+e)>=t[0]){if("*"===t[1]||e<=t[1])return!0;throw new n.prototype.constructor(r)}throw new n.prototype.constructor(r)}var C=new WeakMap,T=new WeakMap,k=function(){function n(){var e,t,r;if(E(this,n),r=!(t="jsonString"),t in(e=this)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,f(this,C,{writable:!0,value:!1}),f(this,T,{writable:!0,value:void 0}),(this instanceof n?this.constructor:void 0)===n)throw new TypeError("Cannot construct BaseCMI instances directly")}return b(n,[{key:"initialized",get:function(){return t(this,C)}},{key:"start_time",get:function(){return t(this,T)}},{key:"initialize",value:function(){d(this,C,!0)}},{key:"setStartTime",value:function(){d(this,T,(new Date).getTime())}}]),n}(),R=new WeakMap,m=new WeakMap,L=new WeakMap,p=new WeakMap,g=new WeakMap,y=new WeakMap,v=new WeakMap,j=new WeakMap,A=new WeakMap,N=new WeakMap,D=function(){a(u,k);var c=l(u);function u(e){var t,r=e.score_children,n=e.score_range,i=e.max,o=e.invalidErrorCode,a=e.invalidTypeCode,s=e.invalidRangeCode,l=e.decimalRegex,e=e.errorClass;return E(this,u),f(h(t=c.call(this)),R,{writable:!0,value:void 0}),f(h(t),m,{writable:!0,value:void 0}),f(h(t),L,{writable:!0,value:void 0}),f(h(t),p,{writable:!0,value:void 0}),f(h(t),g,{writable:!0,value:void 0}),f(h(t),y,{writable:!0,value:void 0}),f(h(t),v,{writable:!0,value:void 0}),f(h(t),j,{writable:!0,value:""}),f(h(t),A,{writable:!0,value:""}),f(h(t),N,{writable:!0,value:void 0}),d(h(t),R,r||M.score_children),d(h(t),m,!!n&&w.score_range),d(h(t),N,i||""===i?i:"100"),d(h(t),L,o||S.INVALID_SET_VALUE),d(h(t),p,a||S.TYPE_MISMATCH),d(h(t),g,s||S.VALUE_OUT_OF_RANGE),d(h(t),y,l||w.CMIDecimal),d(h(t),v,e),t}return b(u,[{key:"_children",get:function(){return t(this,R)},set:function(e){throw new(t(this,v).prototype.constructor)(t(this,L))}},{key:"raw",get:function(){return t(this,j)},set:function(e){!O(e,t(this,y),t(this,p),t(this,v))||t(this,m)&&!I(e,t(this,m),t(this,g),t(this,v))||d(this,j,e)}},{key:"min",get:function(){return t(this,A)},set:function(e){!O(e,t(this,y),t(this,p),t(this,v))||t(this,m)&&!I(e,t(this,m),t(this,g),t(this,v))||d(this,A,e)}},{key:"max",get:function(){return t(this,N)},set:function(e){!O(e,t(this,y),t(this,p),t(this,v))||t(this,m)&&!I(e,t(this,m),t(this,g),t(this,v))||d(this,N,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={raw:this.raw,min:this.min,max:this.max};return delete this.jsonString,e}}]),u}(),P=new WeakMap,x=new WeakMap,V=new WeakMap,z=function(){a(o,k);var i=l(o);function o(e){var t,r=e.children,n=e.errorCode,e=e.errorClass;return E(this,o),f(h(t=i.call(this)),P,{writable:!0,value:void 0}),f(h(t),x,{writable:!0,value:void 0}),f(h(t),V,{writable:!0,value:void 0}),d(h(t),V,r),d(h(t),P,n),d(h(t),x,e),t.childArray=[],t}return b(o,[{key:"_children",get:function(){return t(this,V)},set:function(e){throw new(t(this,x).prototype.constructor)(t(this,P))}},{key:"_count",get:function(){return this.childArray.length},set:function(e){throw new(t(this,x).prototype.constructor)(t(this,P))}},{key:"toJSON",value:function(){this.jsonString=!0;for(var e={},t=0;t<this.childArray.length;t++)e[t+""]=this.childArray[t];return delete this.jsonString,e}}]),o}()},"./src/cmi/scorm2004_cmi.js":
/*!**********************************!*\
!*** ./src/cmi/scorm2004_cmi.js ***!
\**********************************/function(e,t,r){"use strict";r.r(t),r.d(t,{ADL:function(){return xe},CMI:function(){return ee},CMICommentsObject:function(){return je},CMIInteractionsCorrectResponsesObject:function(){return Pe},CMIInteractionsObject:function(){return Ee},CMIInteractionsObjectivesObject:function(){return Ne},CMIObjectivesObject:function(){return Oe}});var i=r(/*! ./common */"./src/cmi/common.js"),t=r(/*! ../constants/api_constants */"./src/constants/api_constants.js"),n=r(/*! ../constants/regex */"./src/constants/regex.js"),m=r(/*! ../constants/error_codes */"./src/constants/error_codes.js"),p=r(/*! ../constants/response_constants */"./src/constants/response_constants.js"),g=r(/*! ../exceptions */"./src/exceptions.js"),y=r(/*! ../utilities */"./src/utilities.js");function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function E(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t&&b(e.prototype,t),r&&b(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _(){return(_="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=O(e)););return e}(e,t);if(n)return n=Object.getOwnPropertyDescriptor(n,t),n.get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function M(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&w(e,t)}function w(e,t){return(w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function S(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t=O(r),t=(e=n?(e=O(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments),this);if(e&&("object"===v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t,r){var n=e;if(t.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}function c(e,t,r){var t=I(e,t,"set"),n=r;if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}return r}function u(e,t){t=I(e,t,"get");return t.get?t.get.call(e):t.value}function I(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}var C=t.default.scorm2004,T=m.default.scorm2004,k=p.default.learner,h=n.default.scorm2004;function f(){throw new g.Scorm2004ValidationError(T.READ_ONLY_ELEMENT)}function R(){throw new g.Scorm2004ValidationError(T.WRITE_ONLY_ELEMENT)}function L(){throw new g.Scorm2004ValidationError(T.TYPE_MISMATCH)}function j(){throw new g.Scorm2004ValidationError(T.DEPENDENCY_NOT_ESTABLISHED)}function d(e,t,r){return(0,i.checkValidFormat)(e,t,T.TYPE_MISMATCH,g.Scorm2004ValidationError,r)}function A(e,t){return(0,i.checkValidRange)(e,t,T.VALUE_OUT_OF_RANGE,g.Scorm2004ValidationError)}var N=new WeakMap,D=new WeakMap,P=new WeakMap,x=new WeakMap,V=new WeakMap,z=new WeakMap,F=new WeakMap,G=new WeakMap,W=new WeakMap,U=new WeakMap,q=new WeakMap,$=new WeakMap,B=new WeakMap,H=new WeakMap,Y=new WeakMap,J=new WeakMap,Z=new WeakMap,X=new WeakMap,K=new WeakMap,Q=new WeakMap,ee=function(){M(n,i.BaseCMI);var r=S(n);function n(e){var t;return o(this,n),l(s(t=r.call(this)),N,{writable:!0,value:"1.0"}),l(s(t),D,{writable:!0,value:C.cmi_children}),l(s(t),P,{writable:!0,value:"unknown"}),l(s(t),x,{writable:!0,value:""}),l(s(t),V,{writable:!0,value:"credit"}),l(s(t),z,{writable:!0,value:""}),l(s(t),F,{writable:!0,value:""}),l(s(t),G,{writable:!0,value:""}),l(s(t),W,{writable:!0,value:""}),l(s(t),U,{writable:!0,value:""}),l(s(t),q,{writable:!0,value:""}),l(s(t),$,{writable:!0,value:""}),l(s(t),B,{writable:!0,value:"normal"}),l(s(t),H,{writable:!0,value:""}),l(s(t),Y,{writable:!0,value:""}),l(s(t),J,{writable:!0,value:"PT0H0M0S"}),l(s(t),Z,{writable:!0,value:"unknown"}),l(s(t),X,{writable:!0,value:""}),l(s(t),K,{writable:!0,value:"continue,no message"}),l(s(t),Q,{writable:!0,value:""}),t.learner_preference=new ae,t.score=new Ce,t.comments_from_learner=new ue,t.comments_from_lms=new ce,t.interactions=new se,t.objectives=new le,e&&t.initialize(),t}return a(n,[{key:"initialize",value:function(){var e;_(O(n.prototype),"initialize",this).call(this),null!==(e=this.learner_preference)&&void 0!==e&&e.initialize(),null!==(e=this.score)&&void 0!==e&&e.initialize(),null!==(e=this.comments_from_learner)&&void 0!==e&&e.initialize(),null!==(e=this.comments_from_lms)&&void 0!==e&&e.initialize(),null!==(e=this.interactions)&&void 0!==e&&e.initialize(),null!==(e=this.objectives)&&void 0!==e&&e.initialize()}},{key:"_version",get:function(){return u(this,N)},set:function(e){f()}},{key:"_children",get:function(){return u(this,D)},set:function(e){f()}},{key:"completion_status",get:function(){return u(this,P)},set:function(e){d(e,h.CMICStatus)&&c(this,P,e)}},{key:"completion_threshold",get:function(){return u(this,x)},set:function(e){this.initialized?f():c(this,x,e)}},{key:"credit",get:function(){return u(this,V)},set:function(e){this.initialized?f():c(this,V,e)}},{key:"entry",get:function(){return u(this,z)},set:function(e){this.initialized?f():c(this,z,e)}},{key:"exit",get:function(){return this.jsonString?u(this,F):R()},set:function(e){d(e,h.CMIExit,!0)&&c(this,F,e)}},{key:"launch_data",get:function(){return u(this,G)},set:function(e){this.initialized?f():c(this,G,e)}},{key:"learner_id",get:function(){return u(this,W)},set:function(e){this.initialized?f():c(this,W,e)}},{key:"learner_name",get:function(){return u(this,U)},set:function(e){this.initialized?f():c(this,U,e)}},{key:"location",get:function(){return u(this,q)},set:function(e){d(e,h.CMIString1000)&&c(this,q,e)}},{key:"max_time_allowed",get:function(){return u(this,$)},set:function(e){this.initialized?f():c(this,$,e)}},{key:"mode",get:function(){return u(this,B)},set:function(e){this.initialized?f():c(this,B,e)}},{key:"progress_measure",get:function(){return u(this,H)},set:function(e){d(e,h.CMIDecimal)&&A(e,h.progress_range)&&c(this,H,e)}},{key:"scaled_passing_score",get:function(){return u(this,Y)},set:function(e){this.initialized?f():c(this,Y,e)}},{key:"session_time",get:function(){return this.jsonString?u(this,J):R()},set:function(e){d(e,h.CMITimespan)&&c(this,J,e)}},{key:"success_status",get:function(){return u(this,Z)},set:function(e){d(e,h.CMISStatus)&&c(this,Z,e)}},{key:"suspend_data",get:function(){return u(this,X)},set:function(e){d(e,h.CMIString64000,!0)&&c(this,X,e)}},{key:"time_limit_action",get:function(){return u(this,K)},set:function(e){this.initialized?f():c(this,K,e)}},{key:"total_time",get:function(){return u(this,Q)},set:function(e){this.initialized?f():c(this,Q,e)}},{key:"getCurrentTotalTime",value:function(){var e=u(this,J),t=this.start_time;return null!=t&&(t=(new Date).getTime()-t,e=y.getSecondsAsISODuration(t/1e3)),y.addTwoDurations(u(this,Q),e,h.CMITimespan)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={comments_from_learner:this.comments_from_learner,comments_from_lms:this.comments_from_lms,completion_status:this.completion_status,completion_threshold:this.completion_threshold,credit:this.credit,entry:this.entry,exit:this.exit,interactions:this.interactions,launch_data:this.launch_data,learner_id:this.learner_id,learner_name:this.learner_name,learner_preference:this.learner_preference,location:this.location,max_time_allowed:this.max_time_allowed,mode:this.mode,objectives:this.objectives,progress_measure:this.progress_measure,scaled_passing_score:this.scaled_passing_score,score:this.score,session_time:this.session_time,success_status:this.success_status,suspend_data:this.suspend_data,time_limit_action:this.time_limit_action};return delete this.jsonString,e}}]),n}(),te=new WeakMap,re=new WeakMap,ne=new WeakMap,ie=new WeakMap,oe=new WeakMap,ae=function(){M(r,i.BaseCMI);var t=S(r);function r(){var e;return o(this,r),l(s(e=t.call(this)),te,{writable:!0,value:C.student_preference_children}),l(s(e),re,{writable:!0,value:"1"}),l(s(e),ne,{writable:!0,value:""}),l(s(e),ie,{writable:!0,value:"1"}),l(s(e),oe,{writable:!0,value:"0"}),e}return a(r,[{key:"_children",get:function(){return u(this,te)},set:function(e){f()}},{key:"audio_level",get:function(){return u(this,re)},set:function(e){d(e,h.CMIDecimal)&&A(e,h.audio_range)&&c(this,re,e)}},{key:"language",get:function(){return u(this,ne)},set:function(e){d(e,h.CMILang)&&c(this,ne,e)}},{key:"delivery_speed",get:function(){return u(this,ie)},set:function(e){d(e,h.CMIDecimal)&&A(e,h.speed_range)&&c(this,ie,e)}},{key:"audio_captioning",get:function(){return u(this,oe)},set:function(e){d(e,h.CMISInteger)&&A(e,h.text_range)&&c(this,oe,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={audio_level:this.audio_level,language:this.language,delivery_speed:this.delivery_speed,audio_captioning:this.audio_captioning};return delete this.jsonString,e}}]),r}(),se=function(){M(t,i.CMIArray);var e=S(t);function t(){return o(this,t),e.call(this,{children:C.interactions_children,errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError})}return a(t)}(),le=function(){M(t,i.CMIArray);var e=S(t);function t(){return o(this,t),e.call(this,{children:C.objectives_children,errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError})}return a(t)}(),ce=function(){M(t,i.CMIArray);var e=S(t);function t(){return o(this,t),e.call(this,{children:C.comments_children,errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError})}return a(t)}(),ue=function(){M(t,i.CMIArray);var e=S(t);function t(){return o(this,t),e.call(this,{children:C.comments_children,errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError})}return a(t)}(),he=new WeakMap,fe=new WeakMap,de=new WeakMap,me=new WeakMap,pe=new WeakMap,ge=new WeakMap,ye=new WeakMap,ve=new WeakMap,Ee=function(){M(r,i.BaseCMI);var t=S(r);function r(){var e;return o(this,r),l(s(e=t.call(this)),he,{writable:!0,value:""}),l(s(e),fe,{writable:!0,value:""}),l(s(e),de,{writable:!0,value:""}),l(s(e),me,{writable:!0,value:""}),l(s(e),pe,{writable:!0,value:""}),l(s(e),ge,{writable:!0,value:""}),l(s(e),ye,{writable:!0,value:""}),l(s(e),ve,{writable:!0,value:""}),e.objectives=new i.CMIArray({errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError,children:C.objectives_children}),e.correct_responses=new i.CMIArray({errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError,children:C.correct_responses_children}),e}return a(r,[{key:"initialize",value:function(){var e;_(O(r.prototype),"initialize",this).call(this),null!==(e=this.objectives)&&void 0!==e&&e.initialize(),null!==(e=this.correct_responses)&&void 0!==e&&e.initialize()}},{key:"id",get:function(){return u(this,he)},set:function(e){d(e,h.CMILongIdentifier)&&c(this,he,e)}},{key:"type",get:function(){return u(this,fe)},set:function(e){this.initialized&&""===u(this,he)?j():d(e,h.CMIType)&&c(this,fe,e)}},{key:"timestamp",get:function(){return u(this,de)},set:function(e){this.initialized&&""===u(this,he)?j():d(e,h.CMITime)&&c(this,de,e)}},{key:"weighting",get:function(){return u(this,me)},set:function(e){this.initialized&&""===u(this,he)?j():d(e,h.CMIDecimal)&&c(this,me,e)}},{key:"learner_response",get:function(){return u(this,pe)},set:function(e){if(!this.initialized||""!==u(this,fe)&&""!==u(this,he)){var t=[],r=k[this.type];if(r){if(null!=r&&r.delimiter?t=e.split(r.delimiter):t[0]=e,!(0<t.length&&t.length<=r.max))throw new g.Scorm2004ValidationError(T.GENERAL_SET_FAILURE);for(var n=new RegExp(r.format),i=0;i<t.length;i++)if(null!=r&&r.delimiter2){var o=t[i].split(r.delimiter2);2===o.length&&o[0].match(n)&&o[1].match(new RegExp(r.format2))||L()}else if