scorm-again
Version:
A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004
19 lines • 128 kB
JavaScript
!function(){var n={"./node_modules/lodash.debounce/index.js":
/*!***********************************************!*\
!*** ./node_modules/lodash.debounce/index.js ***!
\***********************************************/function(e,s,t){function n(e){return(n="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 r=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt,t="object"==(void 0===t.g?"undefined":n(t.g))&&t.g&&t.g.Object===Object&&t.g,h="object"==("undefined"==typeof self?"undefined":n(self))&&self&&self.Object===Object&&self,f=t||h||Function("return this")(),d=Object.prototype.toString,w=Math.max,M=Math.min;function _(e){var t=n(e);return e&&("object"==t||"function"==t)}function m(e){return"symbol"==n(e)||!!(t=e)&&"object"==n(t)&&d.call(e)==i;var t}function b(e){if("number"==typeof e)return e;if(m(e))return r;if("string"!=typeof(e=_(e)?_(t="function"==typeof e.valueOf?e.valueOf():e)?t+"":t:e))return 0===e?e:+e;e=e.replace(o,"");var t=c.test(e);return t||l.test(e)?u(e.slice(2),t?2:8):a.test(e)?r:+e}e.exports=function(h,n,e){var r,i,o,a,s,c,l=0,f=!1,u=!1,t=!0;if("function"!=typeof h)throw new TypeError("Expected a function");function d(e){var t=r,n=i;return r=i=void 0,l=e,a=h.apply(n,t)}function m(e){var t=e-c;return void 0===c||n<=t||t<0||u&&o<=e-l}function p(){var e,t=v();if(m(t))return y(t);s=setTimeout(p,(e=n-((t=t)-c),u?M(e,o-(t-l)):e))}function y(e){return s=void 0,t&&r?d(e):(r=i=void 0,a)}function g(){var e=v(),t=m(e);if(r=arguments,i=this,c=e,t){if(void 0===s)return l=e=c,s=setTimeout(p,n),f?d(e):a;if(u)return s=setTimeout(p,n),d(c)}return void 0===s&&(s=setTimeout(p,n)),a}return n=b(n)||0,_(e)&&(f=!!e.leading,u="maxWait"in e,o=u?w(b(e.maxWait)||0,n):o,t="trailing"in e?!!e.trailing:t),g.cancel=function(){void 0!==s&&clearTimeout(s),r=c=i=s=void(l=0)},g.flush=function(){return void 0===s?a:y(v())},g}},"./src/AICC.js":
/*!*********************!*\
!*** ./src/AICC.js ***!
\*********************/function(r,e,t){"use strict";t.r(e),t.d(e,{default:function(){return d}});var e=t(/*! ./Scorm12API */"./src/Scorm12API.js"),o=t(/*! ./cmi/aicc_cmi */"./src/cmi/aicc_cmi.js"),h=t(/*! ./cmi/scorm12_cmi */"./src/cmi/scorm12_cmi.js");function i(e){return(i="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 n(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function a(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(Object(i),!0).forEach(function(e){var t,n;t=r,n=i[e=e],e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(){return(c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r)return r=Object.getOwnPropertyDescriptor(r,t),r.get?r.get.call(arguments.length<3?e:n):r.value}).apply(this,arguments)}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function f(n){var r=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=u(n),t=(e=r?(e=u(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments),this);if(e&&("object"===i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var d=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&&l(t,e);var n,r=f(i);function i(e){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");var e=a(a({},{mastery_override:!1}),e);return(e=r.call(this,e)).cmi=new o.CMI,e.nav=new h.NAV,e}return t=i,(e=[{key:"getChildElement",value:function(e,t,n){t=c(u(i.prototype),"getChildElement",this).call(this,e,t,n);return t||(this.stringMatches(e,"cmi\\.evaluation\\.comments\\.\\d+")?t=new o.CMIEvaluationCommentsObject:this.stringMatches(e,"cmi\\.student_data\\.tries\\.\\d+")?t=new o.CMITriesObject:this.stringMatches(e,"cmi\\.student_data\\.attempt_records\\.\\d+")&&(t=new o.CMIAttemptRecordsObject)),t}},{key:"replaceWithAnotherScormAPI",value:function(e){this.cmi=e.cmi,this.nav=e.nav}}])&&s(t.prototype,e),n&&s(t,n),Object.defineProperty(t,"prototype",{writable:!1}),i}(e.default)},"./src/BaseAPI.js":
/*!************************!*\
!*** ./src/BaseAPI.js ***!
\************************/function(n,e,t){"use strict";t.r(e),t.d(e,{default:function(){return k}});var p=t(/*! ./cmi/common */"./src/cmi/common.js"),c=t(/*! ./exceptions */"./src/exceptions.js"),e=t(/*! ./constants/error_codes */"./src/constants/error_codes.js"),l=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"),y=t.n(h);function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return v(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?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 n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _(e){return(_="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 n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function w(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?b(Object(n),!0).forEach(function(e){O(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function M(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function S(e,t,n){return t&&E(e.prototype,t),n&&E(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t,n){var r=e;if(t.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,n)}function f(e,t){t=I(e,t,"get");return t.get?t.get.call(e):t.value}function o(e,t,n){var t=I(e,t,"set"),r=n;if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}return n}function I(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var d=l.default.global,C=e.default.scorm12,a=new WeakMap,m=new WeakMap,r=new WeakMap,k=function(){function n(e,t){if(M(this,n),i(this,a,{writable:!0,value:void 0}),i(this,m,{writable:!0,value:void 0}),i(this,r,{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 n?this.constructor:void 0)===n)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(n,[{key:"initialize",value:function(e,t,n){var r=d.SCORM_FALSE;return this.isInitialized()?this.throwSCORMError(f(this,m).INITIALIZED,t):this.isTerminated()?this.throwSCORMError(f(this,m).TERMINATED,n):(this.selfReportSessionTime&&this.cmi.setStartTime(),this.currentState=d.STATE_INITIALIZED,this.lastErrorCode=0,r=d.SCORM_TRUE,this.processListeners(e)),this.apiLog(e,null,"returned: "+r,d.LOG_LEVEL_INFO),this.clearSCORMError(r),r}},{key:"error_codes",get:function(){return f(this,m)}},{key:"settings",get:function(){return f(this,r)},set:function(e){o(this,r,w(w({},f(this,r)),e))}},{key:"terminate",value:function(e,t){var n,r=d.SCORM_FALSE;return this.checkState(t,f(this,m).TERMINATION_BEFORE_INIT,f(this,m).MULTIPLE_TERMINATION)&&(this.currentState=d.STATE_TERMINATED,n=this.storeData(!0),!this.settings.sendBeaconCommit&&!this.settings.asyncCommit&&void 0!==n.errorCode&&0<n.errorCode&&this.throwSCORMError(n.errorCode),r=void 0!==n&&n.result?n.result:d.SCORM_FALSE,t&&(this.lastErrorCode=0),r=d.SCORM_TRUE,this.processListeners(e)),this.apiLog(e,null,"returned: "+r,d.LOG_LEVEL_INFO),this.clearSCORMError(r),r}},{key:"getValue",value:function(e,t,n){var r;if(this.checkState(t,f(this,m).RETRIEVE_BEFORE_INIT,f(this,m).RETRIEVE_AFTER_TERM)){t&&(this.lastErrorCode=0);try{r=this.getCMIValue(n)}catch(e){e instanceof c.ValidationError?(this.lastErrorCode=e.errorCode,r=d.SCORM_FALSE):(e.message?console.error(e.message):console.error(e),this.throwSCORMError(f(this,m).GENERAL))}this.processListeners(e,n)}return this.apiLog(e,n,": returned: "+r,d.LOG_LEVEL_INFO),this.clearSCORMError(r),r}},{key:"setValue",value:function(e,t,n,r,i){void 0!==i&&(i=String(i));var o=d.SCORM_FALSE;if(this.checkState(n,f(this,m).STORE_BEFORE_INIT,f(this,m).STORE_AFTER_TERM)){n&&(this.lastErrorCode=0);try{o=this.setCMIValue(r,i)}catch(e){e instanceof c.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,r,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,r,": "+i+": result: "+o,d.LOG_LEVEL_INFO),this.clearSCORMError(o),o}},{key:"commit",value:function(e,t){this.clearScheduledCommit();var n,r=d.SCORM_FALSE;return this.checkState(t,f(this,m).COMMIT_BEFORE_INIT,f(this,m).COMMIT_AFTER_TERM)&&(n=this.storeData(!1),!this.settings.sendBeaconCommit&&!this.settings.asyncCommit&&n.errorCode&&0<n.errorCode&&this.throwSCORMError(n.errorCode),r=void 0!==n&&n.result?n.result:d.SCORM_FALSE,this.apiLog(e,"HttpRequest"," Result: "+r,d.LOG_LEVEL_DEBUG),t&&(this.lastErrorCode=0),this.processListeners(e)),this.apiLog(e,null,"returned: "+r,d.LOG_LEVEL_INFO),this.clearSCORMError(r),r}},{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 n="";return null!==t&&""!==t&&(n=this.getLmsErrorMessageDetails(t),this.processListeners(e)),this.apiLog(e,null,"returned: "+n,d.LOG_LEVEL_INFO),n}},{key:"getDiagnostic",value:function(e,t){var n="";return null!==t&&""!==t&&(n=this.getLmsErrorMessageDetails(t,!0),this.processListeners(e)),this.apiLog(e,null,"returned: "+n,d.LOG_LEVEL_INFO),n}},{key:"checkState",value:function(e,t,n){return this.isNotInitialized()?(this.throwSCORMError(t),!1):!e||!this.isTerminated()||(this.throwSCORMError(n),!1)}},{key:"apiLog",value:function(e,t,n,r){n=this.formatMessage(e,t,n),r>=this.apiLogLevel&&this.settings.onLogMessage(r,n)}},{key:"formatMessage",value:function(e,t,n){for(var r="",i=20-(r+=e).length,o=0;o<i;o++)r+=" ";if(r+=": ",t)for(var i=70-(r+=t).length,a=0;a<i;a++)r+=" ";return n&&(r+=n),r}},{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,n){if(!t||""===t)return d.SCORM_FALSE;for(var r=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,c=0;c<r.length;c++){var l=r[c];if(c===r.length-1)e&&"{target="===l.substr(0,8)&&"function"==typeof i._isTargetValid?this.throwSCORMError(f(this,m).READ_ONLY_ELEMENT):this._checkObjectHasProperty(i,l)?(this.isInitialized()&&this.stringMatches(t,"\\.correct_responses\\.\\d+")&&this.validateCorrectResponse(t,n),e&&0!==this.lastErrorCode||(i[l]=n,o=d.SCORM_TRUE)):this.throwSCORMError(h,s);else{if(!(i=i[l])){this.throwSCORMError(h,s);break}i instanceof p.CMIArray&&(l=parseInt(r[c+1],10),isNaN(l)||((l=i.childArray[l])?(i=l,a=!0):(l=this.getChildElement(t,n,a),a=!0,l?(i.initialized&&l.initialize(),i.childArray.push(l),i=l):this.throwSCORMError(h,s)),c++))}}return o===d.SCORM_FALSE&&this.apiLog(u,null,"There was an error setting the value for: ".concat(t,", value of: ").concat(n),d.LOG_LEVEL_WARNING),o}},{key:"validateCorrectResponse",value:function(e,t){}},{key:"getChildElement",value:function(e,t,n){throw new Error("The getChildElement method has not been implemented")}},{key:"_commonGetCMIValue",value:function(e,t,n){if(!n||""===n)return"";for(var r=n.split("."),i=this,o=null,u="The data model element passed to ".concat(e," (").concat(n,") has not been initialized."),a="The data model element passed to ".concat(e," (").concat(n,") is not a valid SCORM data model element."),s=t?f(this,m).UNDEFINED_DATA_MODEL:f(this,m).GENERAL,c=0;c<r.length;c++){if(o=r[c],t){if("{target="===String(o).substr(0,8)&&"function"==typeof i._isTargetValid)return l=String(o).substr(8,String(o).length-9),i._isTargetValid(l);if(!this._checkObjectHasProperty(i,o))return void this.throwSCORMError(s,a)}else if(c===r.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 l=parseInt(r[c+1],10);if(!isNaN(l)){var h=i.childArray[l];if(!h){this.throwSCORMError(f(this,m).VALUE_NOT_INITIALIZED,u);break}i=h,c++}}}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 n=e.split(" "),r=0;r<n.length;r++){var i=n[r].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(r,i){var o=this;if(i)for(var a=r.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],n=null,e=(1<e.length&&(n=r.replace(t+".","")),o.listenerArray.findIndex(function(e){return e.functionName===t&&e.CMIElement===n&&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"===_(t))return t.v}}},{key:"clear",value:function(r){for(var i=this,o=r.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],n=null;1<e.length&&(n=r.replace(t+".","")),i.listenerArray=i.listenerArray.filter(function(e){return e.functionName!==t&&e.CMIElement!==n})}(e);if("object"===_(t))return t.v}}},{key:"processListeners",value:function(e,t,n){this.apiLog(e,t,n);for(var r=0;r<this.listenerArray.length;r++){var i=this.listenerArray[r],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,n)}}},{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,n){var r,i,e,o,a=this;function s(e,t,n){var r,e=e.match(n);return null!==e&&null!==(r=t.match(n))?(t=Number(e[2]))===(n=Number(r[2]))?"id"!==e[3]&&("type"!==e[3]||"id"===r[3])?1:-1:t-n:null}this.isNotInitialized()?(r=/^(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=g(e,2),n=e[0],e=(e[1],g(t,2)),t=e[0];e[1];return null!==(e=s(n,t,r))||null!==(e=s(n,t,i))?e:n<t?-1:t<n?1:0}),e.forEach(function(e){(o={})[e[0]]=e[1],a.loadFromJSON((0,u.unflatten)(o),n)})):console.error("loadFromFlattenedJSON can only be called before the call to lmsInitialize.")}},{key:"loadFromJSON",value:function(e,t){if(this.isNotInitialized()){for(var n in t=void 0!==t?t:"cmi",this.startingData=e)if({}.hasOwnProperty.call(e,n)&&e[n]){var r=(t?t+".":"")+n,i=e[n];if(i.childArray)for(var o=0;o<i.childArray.length;o++)this.loadFromJSON(i.childArray[o],r+"."+o);else i.constructor===Object?this.loadFromJSON(i,r):this.setCMIValue(r,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 n(e,t,n,r){if(r={result:d.SCORM_FALSE,errorCode:r.GENERAL},n.sendBeaconCommit)try{var i={type:n.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),c.processListeners("CommitError"),r}else{var s=new XMLHttpRequest;s.open("POST",e,n.asyncCommit),Object.keys(n.xhrHeaders).length&&Object.keys(n.xhrHeaders).forEach(function(e){s.setRequestHeader(e,n.xhrHeaders[e])}),s.withCredentials=n.xhrWithCredentials,n.asyncCommit&&(s.onload=function(e){a="function"==typeof n.responseHandler?n.responseHandler(s):JSON.parse(s.responseText)});try{if((t=n.requestHandler(t))instanceof Array?(s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(t.join("&"))):(s.setRequestHeader("Content-Type",n.commitRequestDataType),s.send(JSON.stringify(t))),n.asyncCommit)return(a={}).result=d.SCORM_TRUE,a.errorCode=0,c.processListeners("CommitSuccess"),a;a="function"==typeof n.responseHandler?n.responseHandler(s):JSON.parse(s.responseText)}catch(e){return console.error(e),c.processListeners("CommitError"),r}}return void 0===a?(c.processListeners("CommitError"),r):(!0===a.result||a.result===d.SCORM_TRUE?c.processListeners("CommitSuccess"):c.processListeners("CommitError"),a)}var r,i=2<arguments.length&&void 0!==arguments[2]&&arguments[2],c=this;return void 0!==y()?((r=y()(n,500))(e,t,this.settings,this.error_codes),i&&r.flush(),{result:d.SCORM_TRUE,errorCode:0}):n(e,t,this.settings,this.error_codes)}},{key:"scheduleCommit",value:function(e,t){o(this,a,new L(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))}}]),n}(),T=new WeakMap,j=new WeakMap,s=new WeakMap,R=new WeakMap,L=function(){function r(e,t,n){M(this,r),i(this,T,{writable:!0,value:void 0}),i(this,j,{writable:!0,value:!1}),i(this,s,{writable:!0,value:void 0}),i(this,R,{writable:!0,value:void 0}),o(this,T,e),o(this,s,setTimeout(this.wrapper.bind(this),t)),o(this,R,n)}return S(r,[{key:"cancel",value:function(){o(this,j,!0),f(this,s)&&clearTimeout(f(this,s))}},{key:"wrapper",value:function(){f(this,j)||f(this,T).commit(f(this,R))}}]),r}()},"./src/Scorm12API.js":
/*!***************************!*\
!*** ./src/Scorm12API.js ***!
\***************************/function(r,e,t){"use strict";t.r(e),t.d(e,{default:function(){return y}});var e=t(/*! ./BaseAPI */"./src/BaseAPI.js"),o=t(/*! ./cmi/scorm12_cmi */"./src/cmi/scorm12_cmi.js"),a=t(/*! ./utilities */"./src/utilities.js"),n=t(/*! ./constants/api_constants */"./src/constants/api_constants.js"),t=t(/*! ./constants/error_codes */"./src/constants/error_codes.js");function i(e){return(i="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 s(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function h(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?s(Object(i),!0).forEach(function(e){var t,n;t=r,n=i[e=e],e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function d(e,t){return(d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function m(n){var r=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(n),t=(e=r?(e=c(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments),this);if(e&&("object"===i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=n.default.scorm12,u=n.default.global,p=t.default.scorm12,y=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&&d(t,e);var n,r=m(i);function i(e){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");var e=h(h({},{mastery_override:!1}),e);return(e=r.call(this,p,e)).cmi=new o.CMI,e.nav=new o.NAV,e.LMSInitialize=e.lmsInitialize,e.LMSFinish=e.lmsFinish,e.LMSGetValue=e.lmsGetValue,e.LMSSetValue=e.lmsSetValue,e.LMSCommit=e.lmsCommit,e.LMSGetLastError=e.lmsGetLastError,e.LMSGetErrorString=e.lmsGetErrorString,e.LMSGetDiagnostic=e.lmsGetDiagnostic,e}return t=i,(e=[{key:"lmsInitialize",value:function(){return this.cmi.initialize(),this.initialize("LMSInitialize","LMS was already initialized!","LMS is already finished!")}},{key:"lmsFinish",value:function(){var e=this.terminate("LMSFinish",!0);return e===u.SCORM_TRUE&&(""!==this.nav.event?"continue"===this.nav.event?this.processListeners("SequenceNext"):this.processListeners("SequencePrevious"):this.settings.autoProgress&&this.processListeners("SequenceNext")),e}},{key:"lmsGetValue",value:function(e){return this.getValue("LMSGetValue",!1,e)}},{key:"lmsSetValue",value:function(e,t){return this.setValue("LMSSetValue","LMSCommit",!1,e,t)}},{key:"lmsCommit",value:function(){return this.commit("LMSCommit",!1)}},{key:"lmsGetLastError",value:function(){return this.getLastError("LMSGetLastError")}},{key:"lmsGetErrorString",value:function(e){return this.getErrorString("LMSGetErrorString",e)}},{key:"lmsGetDiagnostic",value:function(e){return this.getDiagnostic("LMSGetDiagnostic",e)}},{key:"setCMIValue",value:function(e,t){return this._commonSetCMIValue("LMSSetValue",!1,e,t)}},{key:"getCMIValue",value:function(e){return this._commonGetCMIValue("getCMIValue",!1,e)}},{key:"getChildElement",value:function(e,t,n){var r;return this.stringMatches(e,"cmi\\.objectives\\.\\d+")?r=new o.CMIObjectivesObject:n&&this.stringMatches(e,"cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+")?r=new o.CMIInteractionsCorrectResponsesObject:n&&this.stringMatches(e,"cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")?r=new o.CMIInteractionsObjectivesObject:!n&&this.stringMatches(e,"cmi\\.interactions\\.\\d+")&&(r=new o.CMIInteractionsObject),r}},{key:"validateCorrectResponse",value:function(e,t){return!0}},{key:"getLmsErrorMessageDetails",value:function(e,t){var n="No Error",r="No Error";return e=String(e),l.error_descriptions[e]&&(n=l.error_descriptions[e].basicMessage,r=l.error_descriptions[e].detailMessage),t?r:n}},{key:"replaceWithAnotherScormAPI",value:function(e){this.cmi=e.cmi}},{key:"renderCommitCMI",value:function(e){var t=this.renderCMIToJSONObject(),n=(e&&(t.cmi.core.total_time=this.cmi.getCurrentTotalTime()),[]),r=a.flatten(t);switch(this.settings.dataCommitFormat){case"flattened":return a.flatten(t);case"params":for(var i in r)!{}.hasOwnProperty.call(r,i)||n.push("".concat(i,"=").concat(r[i]));return n;default:return t}}},{key:"storeData",value:function(e){e&&("not attempted"===(t=this.cmi.core.lesson_status)&&(this.cmi.core.lesson_status="completed"),"normal"===this.cmi.core.lesson_mode?"credit"===this.cmi.core.credit&&this.settings.mastery_override&&""!==this.cmi.student_data.mastery_score&&""!==this.cmi.core.score.raw&&(parseFloat(this.cmi.core.score.raw)>=parseFloat(this.cmi.student_data.mastery_score)?this.cmi.core.lesson_status="passed":this.cmi.core.lesson_status="failed"):"browse"===this.cmi.core.lesson_mode&&""===((null===(i=this.startingData)||void 0===i||null===(n=i.cmi)||void 0===n||null===(r=n.core)||void 0===r?void 0:r.lesson_status)||"")&&"not attempted"===t&&(this.cmi.core.lesson_status="browsed"));var t,n,r,i=this.renderCommitCMI(e||this.settings.alwaysSendTotalTime);return this.apiLogLevel===u.LOG_LEVEL_DEBUG&&(console.debug("Commit (terminated: "+(e?"yes":"no")+"): "),console.debug(i)),this.settings.lmsCommitUrl?this.processHttpRequest(this.settings.lmsCommitUrl,i,e):u.SCORM_TRUE}}])&&f(t.prototype,e),n&&f(t,n),Object.defineProperty(t,"prototype",{writable:!1}),i}(e.default)},"./src/Scorm2004API.js":
/*!*****************************!*\
!*** ./src/Scorm2004API.js ***!
\*****************************/function(n,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"),r=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 y(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function g(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?y(Object(n),!0).forEach(function(e){w(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _(e,t){return(_=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function b(n){var r=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(n),t=(e=r?(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 w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e,t,n){var r=e;if(t.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,n)}function E(e,t){t=function(e,t,n){if(t.has(e))return t.get(e);throw new TypeError("attempted to "+n+" private field on non-instance")}(e,t,"get");return t.get?t.get.call(e):t.value}var c=r.default.scorm2004,l=r.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&&_(t,e);var n,r=b(i);function i(e){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");var e=g(g({},{mastery_override:!1}),e);return M(s(e=r.call(this,u,e)),O,{writable:!0,value:void 0}),w(s(e),"checkDuplicatedPattern",function(e,t,n){for(var r=!1,i=e._count,o=0;o<i&&!r;o++)o!==t&&e.childArray[o]===n&&(r=!0);return r}),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 E(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===l.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,n){var r,i,o;return this.stringMatches(e,"cmi\\.objectives\\.\\d+")?r=new a.CMIObjectivesObject:n&&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&&(r=new a.CMIInteractionsCorrectResponsesObject)):n&&this.stringMatches(e,"cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")?r=new a.CMIInteractionsObjectivesObject:!n&&this.stringMatches(e,"cmi\\.interactions\\.\\d+")?r=new a.CMIInteractionsObject:this.stringMatches(e,"cmi\\.comments_from_learner\\.\\d+")?r=new a.CMICommentsObject:this.stringMatches(e,"cmi\\.comments_from_lms\\.\\d+")&&(r=new a.CMICommentsObject(!0)),r}},{key:"checkValidResponseType",value:function(e,t,n){var r=[];null!=e&&e.delimiter?r=String(t).split(e.delimiter):r[0]=t,0<r.length&&r.length<=e.max?this.checkCorrectResponseValue(n,r,t):r.length>e.max&&this.throwSCORMError(u.GENERAL_SET_FAILURE,"Data Model Element Pattern Too Long")}},{key:"checkDuplicateChoiceResponse",value:function(e,t){var n=e.correct_responses._count;if("choice"===e.type)for(var r=0;r<n&&0===this.lastErrorCode;r++)e.correct_responses.childArray[r].pattern===t&&this.throwSCORMError(u.GENERAL_SET_FAILURE)}},{key:"validateCorrectResponse",value:function(e,t){var e=e.split("."),n=Number(e[2]),e=Number(e[4]),n=this.cmi.interactions.childArray[n],r=n.correct_responses._count,i=(this.checkDuplicateChoiceResponse(n,t),h[n.type]);void 0===i.limit||r<=i.limit?(this.checkValidResponseType(i,t,n.type),0===this.lastErrorCode&&(!i.duplicate||!this.checkDuplicatedPattern(n.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 n="",r="";return e=String(e),c.error_descriptions[e]&&(n=c.error_descriptions[e].basicMessage,r=c.error_descriptions[e].detailMessage),t?r:n}},{key:"checkCorrectResponseValue",value:function(e,t,n){for(var r=h[e],i=new RegExp(r.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!=r&&r.delimiter2){var a=t[o].split(r.delimiter2);2===a.length&&a[0].match(i)&&a[1].match(new RegExp(r.format2))||this.throwSCORMError(u.TYPE_MISMATCH)}else{a=t[o].match(i);if(!a&&""!==n||!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]&&r.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,n=!1,r=!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||n||r||"true"!==a[3]&&"false"!==a[3]&&this.throwSCORMError(u.TYPE_MISMATCH),r=!0;break;case"order_matters":r||i||n||"true"!==a[3]&&"false"!==a[3]&&this.throwSCORMError(u.TYPE_MISMATCH),n=!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(),n=(e&&(t.cmi.total_time=this.cmi.getCurrentTotalTime()),[]),r=o.flatten(t);switch(this.settings.dataCommitFormat){case"flattened":return o.flatten(t);case"params":for(var i in r)!{}.hasOwnProperty.call(r,i)||n.push("".concat(i,"=").concat(r[i]));return n;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,n,r=!1,i=(this.adl.nav.request!==(null===(i=this.startingData)||void 0===i||null===(n=i.adl)||void 0===n||null===(t=n.nav)||void 0===t?void 0:t.request)&&"_none_"!==this.adl.nav.request&&(this.adl.nav.request=encodeURIComponent(this.adl.nav.request),r=!0),this.renderCommitCMI(e||this.settings.alwaysSendTotalTime));return this.apiLogLevel===l.LOG_LEVEL_DEBUG&&(console.debug("Commit (terminated: "+(e?"yes":"no")+"): "),console.debug(i)),this.settings.lmsCommitUrl?(n=this.processHttpRequest(this.settings.lmsCommitUrl,i,e),r&&void 0!==n.navRequest&&""!==n.navRequest&&Function('"use strict";(() => { '.concat(n.navRequest," })()"))(),n):l.SCORM_TRUE}}])&&v(t.prototype,e),n&&v(t,n),Object.defineProperty(t,"prototype",{writable:!1}),i}(e.default)},"./src/cmi/aicc_cmi.js":
/*!*****************************!*\
!*** ./src/cmi/aicc_cmi.js ***!
\*****************************/function(t,n,f){"use strict";f.r(n),f.d(n,{CMI:function(){return C},CMIAttemptRecords:function(){return he},CMIAttemptRecordsObject:function(){return de},CMIEvaluationCommentsObject:function(){return ge},CMIPaths:function(){return Q},CMIPathsObject:function(){return ae},CMIStudentDemographics:function(){return K},CMITries:function(){return se},CMITriesObject:function(){return ue}});var d=f(/*! ./scorm12_cmi */"./src/cmi/scorm12_cmi.js"),r=f(/*! ./common */"./src/cmi/common.js"),n=f(/*! ../constants/api_constants */"./src/constants/api_constants.js"),m=f(/*! ../constants/regex */"./src/constants/regex.js"),p=f(/*! ../constants/error_codes */"./src/constants/error_codes.js"),y=f(/*! ../exceptions */"./src/exceptions.js");function g(e){return(g="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 i(e,t,n){var r=e;if(t.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,n)}function o(e,t,n){var t=v(e,t,"set"),r=n;if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}return n}function e(e,t){t=v(e,t,"get");return t.get?t.get.call(e):t.value}function v(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&_(e.prototype,t),n&&_(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(){return(b="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=S(e)););return e}(e,t);if(r)return r=Object.getOwnPropertyDescriptor(r,t),r.get?r.get.call(arguments.length<3?e:n):r.value}).apply(this,arguments)}function w(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&&M(e,t)}function M(e,t){return(M=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function E(n){var r=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=S(n),t=(e=r?(e=S(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments),this);if(e&&("object"===g(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var O=n.default.aicc,l=m.default.aicc,I=p.default.scorm12;function u(){throw new y.AICCValidationError(I.READ_ONLY_ELEMENT)}function h(e,t,n){return(0,r.checkValidFormat)(e,t,I.TYPE_MISMATCH,y.AICCValidationError,n)}var C=function(){w(r,d.CMI);var n=E(r);function r(e){var t;return a(this,r),t=n.call(this,O.cmi_children),e&&t.initialize(),t.student_preference=new P,t.student_data=new z,t.student_demographics=new K,t.evaluation=new k,t.paths=new Q,t}return s(r,[{key:"initialize",value:function(){var e;b(S(r.prototype),"initialize",this).call(this),null!==(e=this.student_preference)&&void 0!==e&&e.initialize(),null!==(e=this.student_data)&&void 0!==e&&e.initialize(),null!==(e=this.student_demographics)&&void 0!==e&&e.initialize(),null!==(e=this.evaluation)&&void 0!==e&&e.initialize(),null!==(e=this.paths)&&void 0!==e&&e.initialize()}},{key:"toJSON",value:function(){this.jsonString=!0;var e={suspend_data:this.suspend_data,launch_data:this.launch_data,comments:this.comments,comments_from_lms:this.comments_from_lms,core:this.core,objectives:this.objectives,student_data:this.student_data,student_preference:this.student_preference,student_demographics:this.student_demographics,interactions:this.interactions,evaluation:this.evaluation,paths:this.paths};return delete this.jsonString,e}}]),r}(),k=function(){w(n,r.BaseCMI);var t=E(n);function n(){var e;return a(this,n),(e=t.call(this)).comments=new T,e}return s(n,[{key:"initialize",value:function(){var e;b(S(n.prototype),"initialize",this).call(this),null!==(e=this.comments)&&void 0!==e&&e.initialize()}},{key:"toJSON",value:function(){this.jsonString=!0;var e={comments:this.comments};return delete this.jsonString,e}}]),n}(),T=function(){w(t,r.CMIArray);var e=E(t);function t(){return a(this,t),e.call(this,{children:O.comments_children,errorCode:I.INVALID_SET_VALUE,errorClass:y.AICCValidationError})}return s(t)}(),j=new WeakMap,R=new WeakMap,L=new WeakMap,A=new WeakMap,N=new WeakMap,P=function(){w(n,d.CMIStudentPreference);var t=E(n);function n(){var e;return a(this,n),i(c(e=t.call(this,O.student_preference_children)),j,{writable:!0,value:""}),i(c(e),R,{writable:!0,value:""}),i(c(e),L,{writable:!0,value:""}),i(c(e),A,{writable:!0,value:""}),i(c(e),N,{writable:!0,value:""}),e.windows=new r.CMIArray({errorCode:I.INVALID_SET_VALUE,errorClass:y.AICCValidationError,children:""}),e}return s(n,[{key:"initialize",value:function(){var e;b(S(n.prototype),"initialize",this).call(this),null!==(e=this.windows)&&void 0!==e&&e.initialize()}},{key:"lesson_type",get:function(){return e(this,j)},set:function(e){h(e,l.CMIString256)&&o(this,j,e)}},{key:"text_color",get:function(){return e(this,R)},set:function(e){h(e,l.CMIString256)&&o(this,R,e)}},{key:"text_location",get:function(){return e(this,L)},set:function(e){h(e,l.CMIString256)&&o(this,L,e)}},{key:"text_size",get:function(){return e(this,A)},set:function(e){h(e,l.CMIString256)&&o(this,A,e)}},{key:"video",get:function(){return e(this,N)},set:function(e){h(e,l.CMIString256)&&o(this,N,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={audio:this.audio,language:this.language,lesson_type:this.lesson_type,speed:this.speed,text:this.text,text_color:this.text_color,text_location:this.text_location,text_size:this.text_size,video:this.video,windows:this.windows};return delete this.jsonString,e}}]),n}(),D=new WeakMap,z=function(){w(n,d.CMIStudentData);var t=E(n);function n(){var e;return a(this,n),i(c(e=t.call(this,O.student_data_children)),D,{writable:!0,value:""}),e.tries=new se,e}return s(n,[{key:"initialize",value:function(){var e;b(S(n.prototype),"initialize",this).call(this),null!==(e=this.tries)&&void 0!==e&&e.initialize()}},{key:"tries_during_lesson",get:function(){return e(this,D)},set:function(e){this.initialized?u():o(this,D,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={mastery_score:this.mastery_score,max_time_allowed:this.max_time_allowed,time_limit_action:this.time_limit_action,tries:this.tries};return delete this.jsonString,e}}]),n}(),V=new WeakMap,x=new WeakMap,W=new WeakMap,F=new WeakMap,G=new WeakMap,U=new WeakMap,B=new WeakMap,q=new WeakMap,$=new WeakMap,H=new WeakMap,J=new WeakMap,Y=new WeakMap,Z=new WeakMap,X=new WeakMap,K=function(){w(n,r.BaseCMI);var t=E(n);function n(){var e;return a(this,n),i(c(e=t.call(this)),V,{writable:!0,value:O.student_demographics_children}),i(c(e),x,{writable:!0,value:""}),i(c(e),W,{writable:!0,value:""}),i(c(e),F,{writable:!0,value:""}),i(c(e),G,{writable:!0,value:""}),i(c(e),U,{writable:!0,value:""}),i(c(e),B,{writable:!0,value:""}),i(c(e),q,{writable:!0,value:""}),i(c(e),$,{writable:!0,value:""}),i(c(e),H,{writable:!0,value:""}),i(c(e),J,{writable:!0,value:""}),i(c(e),Y,{writable:!0,value:""}),i(c(e),Z,{writable:!0,value:""}),i(c(e),X,{writable:!0,value:""}),e}return s(n,[{key:"_children",get:function(){return e(this,V)}},{key:"city",get:function(){return e(this,x)},set:function(e){this.initialized?u():o(this,x,e)}},{key:"class",get:function(){return e(this,W)},set:function(e){this.initialized?u():o(this,W,e)}},{key:"company",get:function(){return e(this,F)},set:function(e){this.initialized?u():o(this,F,e)}},{key:"country",get:function(){return e(this,G)},set:function(e){this.initialized?u():o(this,G,e)}},{key:"experience",get:function(){return e(this,U)},set:function(e){this.initialized?u():o(this,U,e)}},{key:"familiar_name",g