scorm-again 3.0.5 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +77 -1
  2. package/dist/cross-frame-api.js +579 -320
  3. package/dist/cross-frame-api.js.map +1 -1
  4. package/dist/cross-frame-api.min.js +1 -1
  5. package/dist/cross-frame-api.min.js.map +1 -1
  6. package/dist/cross-frame-lms.js +226 -163
  7. package/dist/cross-frame-lms.js.map +1 -1
  8. package/dist/cross-frame-lms.min.js +1 -1
  9. package/dist/cross-frame-lms.min.js.map +1 -1
  10. package/dist/esm/cross-frame-api.js.map +1 -1
  11. package/dist/esm/scorm-again.js +391 -86
  12. package/dist/esm/scorm-again.js.map +1 -1
  13. package/dist/esm/scorm-again.min.js +1 -1
  14. package/dist/esm/scorm-again.min.js.map +1 -1
  15. package/dist/esm/scorm12.js +323 -76
  16. package/dist/esm/scorm12.js.map +1 -1
  17. package/dist/esm/scorm12.min.js +1 -1
  18. package/dist/esm/scorm12.min.js.map +1 -1
  19. package/dist/esm/scorm2004.js +373 -72
  20. package/dist/esm/scorm2004.js.map +1 -1
  21. package/dist/esm/scorm2004.min.js +1 -1
  22. package/dist/esm/scorm2004.min.js.map +1 -1
  23. package/dist/scorm-again.js +32522 -19996
  24. package/dist/scorm-again.js.map +1 -1
  25. package/dist/scorm-again.min.js +1 -1
  26. package/dist/scorm-again.min.js.map +1 -1
  27. package/dist/scorm12.js +9130 -5031
  28. package/dist/scorm12.js.map +1 -1
  29. package/dist/scorm12.min.js +1 -1
  30. package/dist/scorm12.min.js.map +1 -1
  31. package/dist/scorm2004.js +30040 -18419
  32. package/dist/scorm2004.js.map +1 -1
  33. package/dist/scorm2004.min.js +1 -1
  34. package/dist/scorm2004.min.js.map +1 -1
  35. package/dist/types/BaseAPI.d.ts +15 -5
  36. package/dist/types/Scorm12API.d.ts +2 -2
  37. package/dist/types/Scorm2004API.d.ts +3 -2
  38. package/dist/types/cmi/common/score.d.ts +2 -0
  39. package/dist/types/interfaces/services.d.ts +8 -4
  40. package/dist/types/services/AsynchronousHttpService.d.ts +3 -2
  41. package/dist/types/services/EventService.d.ts +2 -2
  42. package/dist/types/services/OfflineStorageService.d.ts +6 -1
  43. package/dist/types/services/SynchronousHttpService.d.ts +2 -2
  44. package/dist/types/services/ValidationService.d.ts +1 -1
  45. package/dist/types/types/api_types.d.ts +22 -2
  46. package/dist/types/utilities/index.d.ts +1 -0
  47. package/dist/types/utilities/url.d.ts +2 -0
  48. package/package.json +27 -27
@@ -1,2 +1,2 @@
1
- !function(){"use strict";const e={D:86400,H:3600,M:60,S:1},t=e=>{if(!e||0>=e)return"00:00:00";const t=Math.floor(e/3600),i=new Date(1e3*e),s=i.getUTCMinutes(),r=i.getSeconds(),n=e%1;let o="";return a(n)>0&&(o=a(n)>2?n.toFixed(2):n+"",o="."+o.split(".")[1]),(t+":"+s+":"+r).replace(/\b\d\b/g,"0$&")+o},i=t=>{if(!t||0>=t)return"PT0S";let i="P",s=t;return Object.entries(e).forEach(e=>{let[t,r]=e,n=Math.floor(s/r);s%=r,a(s)>2&&(s=+(+s).toFixed(2)),"S"===t&&s>0&&(n+=s),n&&((i.indexOf("D")>0||["H","M","S"].includes(t))&&-1===i.indexOf("T")&&(i+="T"),i+=`${n}${t}`)}),i},s=l((e,t)=>{if("number"!=typeof e&&"boolean"!=typeof e||(e+=""),"string"==typeof t&&(t=RegExp(t)),!e)return 0;if(!e.match(t))return/^\d+(?:\.\d+)?$/.test(e)?+e:0;const i=e.split(":");return 3600*+i[0]+60*+i[1]+ +i[2]},(e,t)=>`${"string"==typeof e?e:(e??"")+""}:${"string"==typeof t?t:t?.toString()??""}`),r=l((e,t)=>{if("string"==typeof t&&(t=RegExp(t)),!e||!e?.match?.(t))return 0;const[,i,s,r,n,o,a,c]=RegExp(t).exec?.(e)??[];let result=0;return result+=+c||0,result+=60*+a||0,result+=3600*+o||0,result+=86400*+n||0,result+=604800*+r||0,result+=2592e3*+s||0,result+=31536e3*+i||0,result},(e,t)=>`${e??""}:${"string"==typeof t?t:t?.toString()??""}`),n=l((e,t)=>("string"==typeof t&&(t=RegExp(t)),!(!e||!e?.match?.(t))));function o(e){const result={};return function e(t,i){if(Object(t)!==t)result[i]=t;else if(Array.isArray(t))t.forEach((t,s)=>{e(t,`${i}[${s}]`)}),0===t.length&&(result[i]=[]);else{const s=Object.keys(t).filter(e=>({}.hasOwnProperty.call(t,e))),r=0===s.length;s.forEach(s=>{e(t[s],i?`${i}.${s}`:s)}),r&&i&&(result[i]={})}}(e,""),result}function a(e){if(Math.floor(e)===e||0>(e+"")?.indexOf?.("."))return 0;const t=(""+e).split(".")?.[1];return t?.length??0}function c(e,t){return"string"==typeof e&&RegExp(t).test(e)}function l(e,t){const i=new Map;return function(){for(var s=arguments.length,r=Array(s),n=0;s>n;n++)r[n]=arguments[n];const o=t?t(...r):JSON.stringify(r);return i.has(o)?i.get(o):(()=>{const result=e(...r);return i.set(o,result),result})()}}var u=Object.defineProperty,h=(e,t,i)=>((e,t,i)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class d{constructor(e){h(this,"jsonString",!1),h(this,"_cmi_element"),h(this,"_initialized",!1),this._cmi_element=e}get initialized(){return this._initialized}initialize(){this._initialized=!0}}class m extends d{constructor(){super(...arguments),h(this,"_start_time")}get start_time(){return this._start_time}setStartTime(){if(void 0!==this._start_time)throw Error("Start time has already been set.");this._start_time=(new Date).getTime()}}var p=Object.defineProperty,_=(e,t,i)=>((e,t,i)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class v extends Error{constructor(e,t){super(`${e} : ${""+t}`),_(this,"_errorCode"),this._errorCode=t,Object.setPrototypeOf(this,v.prototype)}get errorCode(){return this._errorCode}}class g extends v{constructor(e,t,i,s){super(e,t),_(this,"_errorMessage"),_(this,"_detailedMessage",""),this.message=`${e} : ${i}`,this._errorMessage=i,s&&(this._detailedMessage=s),Object.setPrototypeOf(this,g.prototype)}get errorMessage(){return this._errorMessage}get detailedMessage(){return this._detailedMessage}}const f="true",S="false",b="raw,min,max",y="id,score,status",C={0:{basicMessage:"No Error",detailMessage:"No error occurred, the previous API call was successful."},101:{basicMessage:"General Exception",detailMessage:"No specific error code exists to describe the error."},201:{basicMessage:"Invalid argument error",detailMessage:"Indicates that an argument represents an invalid data model element or is otherwise incorrect."},202:{basicMessage:"Element cannot have children",detailMessage:'Indicates that LMSGetValue was called with a data model element name that ends in "_children" for a data model element that does not support the "_children" suffix.'},203:{basicMessage:"Element not an array - cannot have count",detailMessage:'Indicates that LMSGetValue was called with a data model element name that ends in "_count" for a data model element that does not support the "_count" suffix.'},301:{basicMessage:"Not initialized",detailMessage:"Indicates that an API call was made before the call to lmsInitialize."},401:{basicMessage:"Not implemented error",detailMessage:"The data model element indicated in a call to LMSGetValue or LMSSetValue is valid, but was not implemented by this LMS. SCORM 1.2 defines a set of data model elements as being optional for an LMS to implement."},402:{basicMessage:"Invalid set value, element is a keyword",detailMessage:'Indicates that LMSSetValue was called on a data model element that represents a keyword (elements that end in "_children" and "_count").'},403:{basicMessage:"Element is read only",detailMessage:"LMSSetValue was called with a data model element that can only be read."},404:{basicMessage:"Element is write only",detailMessage:"LMSGetValue was called on a data model element that can only be written to."},405:{basicMessage:"Incorrect Data Type",detailMessage:"LMSSetValue was called with a value that is not consistent with the data format of the supplied data model element."},407:{basicMessage:"Element Value Out Of Range",detailMessage:"The numeric value supplied to a LMSSetValue call is outside of the numeric range allowed for the supplied data model element."},408:{basicMessage:"Data Model Dependency Not Established",detailMessage:"Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element."}},A={cmi_children:"_version,comments_from_learner,comments_from_lms,completion_status,completion_threshold,credit,entry,exit,interactions,launch_data,learner_id,learner_name,learner_preference,location,max_time_allowed,mode,objectives,progress_measure,scaled_passing_score,score,session_time,success_status,suspend_data,time_limit_action,total_time",comments_children:"comment,timestamp,location",score_children:"max,raw,scaled,min",objectives_children:"progress_measure,completion_status,success_status,description,score,id",correct_responses_children:"pattern",student_preference_children:"audio_level,audio_captioning,delivery_speed,language",interactions_children:"id,type,objectives,timestamp,correct_responses,weighting,learner_response,result,latency,description",adl_data_children:"id,store",error_descriptions:{0:{basicMessage:"No Error",detailMessage:"No error occurred, the previous API call was successful."},101:{basicMessage:"General Exception",detailMessage:"No specific error code exists to describe the error."},102:{basicMessage:"General Initialization Failure",detailMessage:"Call to Initialize failed for an unknown reason."},103:{basicMessage:"Already Initialized",detailMessage:"Call to Initialize failed because Initialize was already called."},104:{basicMessage:"Content Instance Terminated",detailMessage:"Call to Initialize failed because Terminate was already called."},111:{basicMessage:"General Termination Failure",detailMessage:"Call to Terminate failed for an unknown reason."},112:{basicMessage:"Termination Before Initialization",detailMessage:"Call to Terminate failed because it was made before the call to Initialize."},113:{basicMessage:"Termination After Termination",detailMessage:"Call to Terminate failed because Terminate was already called."},122:{basicMessage:"Retrieve Data Before Initialization",detailMessage:"Call to GetValue failed because it was made before the call to Initialize."},123:{basicMessage:"Retrieve Data After Termination",detailMessage:"Call to GetValue failed because it was made after the call to Terminate."},132:{basicMessage:"Store Data Before Initialization",detailMessage:"Call to SetValue failed because it was made before the call to Initialize."},133:{basicMessage:"Store Data After Termination",detailMessage:"Call to SetValue failed because it was made after the call to Terminate."},142:{basicMessage:"Commit Before Initialization",detailMessage:"Call to Commit failed because it was made before the call to Initialize."},143:{basicMessage:"Commit After Termination",detailMessage:"Call to Commit failed because it was made after the call to Terminate."},201:{basicMessage:"General Argument Error",detailMessage:"An invalid argument was passed to an API method (usually indicates that Initialize, Commit or Terminate did not receive the expected empty string argument."},301:{basicMessage:"General Get Failure",detailMessage:"Indicates a failed GetValue call where no other specific error code is applicable. Use GetDiagnostic for more information."},351:{basicMessage:"General Set Failure",detailMessage:"Indicates a failed SetValue call where no other specific error code is applicable. Use GetDiagnostic for more information."},391:{basicMessage:"General Commit Failure",detailMessage:"Indicates a failed Commit call where no other specific error code is applicable. Use GetDiagnostic for more information."},401:{basicMessage:"Undefined Data Model Element",detailMessage:"The data model element name passed to GetValue or SetValue is not a valid SCORM data model element."},402:{basicMessage:"Unimplemented Data Model Element",detailMessage:"The data model element indicated in a call to GetValue or SetValue is valid, but was not implemented by this LMS. In SCORM 2004, this error would indicate an LMS that is not fully SCORM conformant."},403:{basicMessage:"Data Model Element Value Not Initialized",detailMessage:"Attempt to read a data model element that has not been initialized by the LMS or through a SetValue call. This error condition is often reached during normal execution of a SCO."},404:{basicMessage:"Data Model Element Is Read Only",detailMessage:"SetValue was called with a data model element that can only be read."},405:{basicMessage:"Data Model Element Is Write Only",detailMessage:"GetValue was called on a data model element that can only be written to."},406:{basicMessage:"Data Model Element Type Mismatch",detailMessage:"SetValue was called with a value that is not consistent with the data format of the supplied data model element."},407:{basicMessage:"Data Model Element Value Out Of Range",detailMessage:"The numeric value supplied to a SetValue call is outside of the numeric range allowed for the supplied data model element."},408:{basicMessage:"Data Model Dependency Not Established",detailMessage:"Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element."}}},E=C;class w extends g{constructor(e,t){!{}.hasOwnProperty.call(E,t+"")?super(e,101,E[101]?.basicMessage,E[101]?.detailMessage):super(e,t,E[t+""]?.basicMessage||"Unknown error",E[t+""]?.detailMessage),Object.setPrototypeOf(this,w.prototype)}}const M=A.error_descriptions;class O extends g{constructor(e,t){!{}.hasOwnProperty.call(M,t+"")?super(e,101,M[101]?.basicMessage,M[101]?.detailMessage):super(e,t,M[t+""]?.basicMessage||"Unknown error",M[t+""]?.detailMessage),Object.setPrototypeOf(this,O.prototype)}}const R={GENERAL:101,INITIALIZATION_FAILED:101,INITIALIZED:101,TERMINATED:101,TERMINATION_FAILURE:101,TERMINATION_BEFORE_INIT:101,MULTIPLE_TERMINATION:101,RETRIEVE_BEFORE_INIT:101,RETRIEVE_AFTER_TERM:101,STORE_BEFORE_INIT:101,STORE_AFTER_TERM:101,COMMIT_BEFORE_INIT:101,COMMIT_AFTER_TERM:101,ARGUMENT_ERROR:101,CHILDREN_ERROR:101,COUNT_ERROR:101,GENERAL_GET_FAILURE:101,GENERAL_SET_FAILURE:101,GENERAL_COMMIT_FAILURE:101,UNDEFINED_DATA_MODEL:101,UNIMPLEMENTED_ELEMENT:101,VALUE_NOT_INITIALIZED:101,INVALID_SET_VALUE:101,READ_ONLY_ELEMENT:101,WRITE_ONLY_ELEMENT:101,TYPE_MISMATCH:101,VALUE_OUT_OF_RANGE:101,DEPENDENCY_NOT_ESTABLISHED:101},T={...R,RETRIEVE_BEFORE_INIT:301,STORE_BEFORE_INIT:301,COMMIT_BEFORE_INIT:301,ARGUMENT_ERROR:201,CHILDREN_ERROR:202,COUNT_ERROR:203,UNDEFINED_DATA_MODEL:401,UNIMPLEMENTED_ELEMENT:401,VALUE_NOT_INITIALIZED:301,INVALID_SET_VALUE:402,READ_ONLY_ELEMENT:403,WRITE_ONLY_ELEMENT:404,TYPE_MISMATCH:405,VALUE_OUT_OF_RANGE:407,DEPENDENCY_NOT_ESTABLISHED:408},j={...R,INITIALIZATION_FAILED:102,INITIALIZED:103,TERMINATED:104,TERMINATION_FAILURE:111,TERMINATION_BEFORE_INIT:112,MULTIPLE_TERMINATION:113,MULTIPLE_TERMINATIONS:113,RETRIEVE_BEFORE_INIT:122,RETRIEVE_AFTER_TERM:123,STORE_BEFORE_INIT:132,STORE_AFTER_TERM:133,COMMIT_BEFORE_INIT:142,COMMIT_AFTER_TERM:143,ARGUMENT_ERROR:201,GENERAL_GET_FAILURE:301,GENERAL_SET_FAILURE:351,GENERAL_COMMIT_FAILURE:391,UNDEFINED_DATA_MODEL:401,UNIMPLEMENTED_ELEMENT:402,VALUE_NOT_INITIALIZED:403,READ_ONLY_ELEMENT:404,WRITE_ONLY_ELEMENT:405,TYPE_MISMATCH:406,VALUE_OUT_OF_RANGE:407,DEPENDENCY_NOT_ESTABLISHED:408};var I=Object.defineProperty,N=(e,t,i)=>((e,t,i)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class x extends d{constructor(e){super(e.CMIElement),N(this,"_errorCode"),N(this,"_errorClass"),N(this,"__children"),N(this,"childArray"),this.__children=e.children,this._errorCode=e.errorCode??T.GENERAL,this._errorClass=e.errorClass||v,this.childArray=[]}reset(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this._initialized=!1,e)this.childArray=[];else for(let e=0;this.childArray.length>e;e++)this.childArray[e]?.reset()}get _children(){return this.__children}set _children(_children){throw new this._errorClass(this._cmi_element+"._children",this._errorCode)}get _count(){return this.childArray.length}set _count(_count){throw new this._errorClass(this._cmi_element+"._count",this._errorCode)}toJSON(){this.jsonString=!0;const result={};for(let e=0;this.childArray.length>e;e++)result[e+""]=this.childArray[e];return this.jsonString=!1,result}}const q="unknown",D="true",L="false",P="passed",z="failed",F="unknown",k="completed",V="incomplete",H="unknown",B={_:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},U={autocommit:!1,autocommitSeconds:10,throttleCommits:!1,useAsynchronousCommits:!1,sendFullCommit:!0,lmsCommitUrl:!1,dataCommitFormat:"json",commitRequestDataType:"application/json;charset=UTF-8",autoProgress:!1,logLevel:B.ERROR,selfReportSessionTime:!1,alwaysSendTotalTime:!1,renderCommonCommitFields:!1,autoCompleteLessonStatus:!1,strict_errors:!0,xhrHeaders:{},xhrWithCredentials:!1,fetchMode:"cors",asyncModeBeaconBehavior:"never",responseHandler:async function(e){if(void 0!==e){let t=null;try{if("function"==typeof e.json)t=await e.json();else if("function"==typeof e.text){const i=await e.text();i&&(t=JSON.parse(i))}}catch(e){}return null!==t&&{}.hasOwnProperty.call(t,"result")?{result:t.result,errorCode:"number"==typeof t.errorCode?t.errorCode:!0===t.result||t.result===f?0:101}:200===e.status?{result:f,errorCode:0}:{result:S,errorCode:101}}return{result:S,errorCode:101}},xhrResponseHandler:function(e){if(void 0!==e){let t=null;if(200>e.status||e.status>299)return{result:S,errorCode:101};try{t=JSON.parse(e.responseText)}catch(e){}return null!==t&&{}.hasOwnProperty.call(t,"result")?{result:t.result,errorCode:"number"==typeof t.errorCode?t.errorCode:!0===t.result||t.result===f?0:101}:{result:f,errorCode:0}}return{result:S,errorCode:101}},requestHandler:function(e){return e},onLogMessage:$,mastery_override:!1,score_overrides_status:!1,completion_status_on_failed:"completed",scoItemIds:[],scoItemIdValidator:!1,globalObjectiveIds:[],enableOfflineSupport:!1,courseId:"",syncOnInitialize:!0,syncOnTerminate:!0,maxSyncAttempts:5,scoId:"",autoPopulateCommitMetadata:!1,httpService:null,globalStudentPreferences:!1};function $(e,t){switch(e){case"4":case 4:case"ERROR":case B.ERROR:console.error(t);break;case"3":case 3:case"WARN":case B.WARN:console.warn(t);break;case"2":case 2:case"INFO":case B.INFO:console.info(t);break;case"1":case 1:case"DEBUG":case B.DEBUG:console.debug?console.debug(t):console.log(t)}}const G="^[\\s\\S]{0,255}$",Y="^([0-9]+):([0-9]{2}):([0-9]{2})(\\.\\d{1,2})?$",W="^-?([0-9]+)$",J="^-?([0-9]{0,10})(\\.[0-9]*)?$",K="^[\\u0021-\\u007E\\s]{0,255}$",X="^.*$",Q="^(passed|completed|failed|incomplete|browsed|not attempted)$",Z="0#100",ee="^[\\u0000-\\uFFFF]{0,4000}$",te="^[\\u0000-\\uFFFF]{0,64000}$",ie="^({lang=([a-zA-Z]{1,8}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,250}$)?$",se="^({lang=([a-zA-Z]{1,8}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,4000}$)?$",re="^(19[7-9][0-9]|[2-9][0-9]{3})((-(0[1-9]|1[0-2]))((-(0[1-9]|[1-2][0-9]|3[0-1]))(T([0-1][0-9]|2[0-3])((:[0-5][0-9])((:[0-5][0-9])((\\.[0-9]{1,6})((Z|([+|-]([0-1][0-9]|2[0-3])))(:[0-5][0-9])?)?)?)?)?)?)?)?$",ne="^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:(\\d+(?:\\.\\d{1,2})?)S)?)?$",oe="^-?([0-9]{1,10})(\\.[0-9]{1,18})?$",ae="^(?=.*\\w)[\\w\\-\\(\\)\\+\\.\\:\\=\\@\\;\\$\\_\\!\\*\\'\\%\\/\\#]{1,250}$",ce="^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$",le="^(completed|incomplete|not attempted|unknown)$",ue="^(passed|failed|unknown)$",he="^(_?(start|resumeAll|previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|retry|retryAll)|_none_|(\\{target=(?<choice_target>\\S{0,}[a-zA-Z0-9-_]+)})?choice|(\\{target=(?<jump_target>\\S{0,}[a-zA-Z0-9-_]+)})?jump)$",de="^(unknown|true|false)$",me="^{target=\\S{0,}[a-zA-Z0-9-_]+}$",pe="^$|"+ae,_e="(?![\\s\\S]*(?:\\[,\\]|\\[\\.\\]|\\[:\\]))[\\s\\S]{1,250}",ve={"true-false":{format:"^true$|^false$",max:1,delimiter:"",unique:!1},choice:{format:ce,max:36,delimiter:"[,]",unique:!0},"fill-in":{format:ie,max:10,delimiter:"[,]",unique:!1},"long-fill-in":{format:se,max:1,delimiter:"",unique:!1},matching:{format:ae,format2:ae,max:36,delimiter:"[,]",delimiter2:"[.]",unique:!1},performance:{format:pe,format2:"^(?:|"+_e+")$",max:250,delimiter:"[,]",delimiter2:"[.]",unique:!1},sequencing:{format:ae,max:36,delimiter:"[,]",unique:!1},likert:{format:ae,max:1,delimiter:"",unique:!1},numeric:{format:oe,max:1,delimiter:"",unique:!1},other:{format:ee,max:1,delimiter:"",unique:!1}},ge={"true-false":{max:1,delimiter:"",unique:!1,duplicate:!1,format:"^true$|^false$",limit:1},choice:{max:36,delimiter:"[,]",unique:!0,duplicate:!1,format:ce},"fill-in":{max:10,delimiter:"[,]",unique:!1,duplicate:!1,format:"^(({lang=([a-zA-Z]{1,8}|i|x)?(-[a-zA-Z0-9-]{2,8})?})?(.{0,250})?)?$"},"long-fill-in":{max:1,delimiter:"",unique:!1,duplicate:!0,format:se},matching:{max:36,delimiter:"[,]",delimiter2:"[.]",unique:!1,duplicate:!1,format:ae,format2:ae},performance:{max:250,delimiter:"[,]",delimiter2:"[.]",unique:!1,duplicate:!1,format:pe,format2:"^(?:|(?:-?\\d+(?:\\.\\d+)?)?\\[:\\](?:-?\\d+(?:\\.\\d+)?)?|"+_e+")$"},sequencing:{max:36,delimiter:"[,]",unique:!1,duplicate:!1,format:ae},likert:{max:1,delimiter:"",unique:!1,duplicate:!1,format:ae,limit:1},numeric:{max:2,delimiter:"[:]",unique:!1,duplicate:!1,format:oe,limit:1},other:{max:1,delimiter:"",unique:!1,duplicate:!1,format:ee,limit:1}},fe=["aa","ab","ae","af","ak","am","an","ar","as","av","ay","az","ba","be","bg","bh","bi","bm","bn","bo","br","bs","ca","ce","ch","co","cr","cs","cu","cv","cy","da","de","dv","dz","ee","el","en","eo","es","et","eu","fa","ff","fi","fj","fo","fr","fy","ga","gd","gl","gn","gu","gv","ha","he","hi","ho","hr","ht","hu","hy","hz","ia","id","ie","ig","ii","ik","io","is","it","iu","ja","jv","ka","kg","ki","kj","kk","kl","km","kn","ko","kr","ks","ku","kv","kw","ky","la","lb","lg","li","ln","lo","lt","lu","lv","mg","mh","mi","mk","ml","mn","mo","mr","ms","mt","my","na","nb","nd","ne","ng","nl","nn","no","nr","nv","ny","oc","oj","om","or","os","pa","pi","pl","ps","pt","qu","rm","rn","ro","ru","rw","sa","sc","sd","se","sg","sh","si","sk","sl","sm","sn","so","sq","sr","ss","st","su","sv","sw","ta","te","tg","th","ti","tk","tl","tn","to","tr","ts","tt","tw","ty","ug","uk","ur","uz","ve","vi","vo","wa","wo","xh","yi","yo","za","zh","zu","aar","abk","ave","afr","aka","amh","arg","ara","asm","ava","aym","aze","bak","bel","bul","bih","bis","bam","ben","tib","bod","bre","bos","cat","che","cha","cos","cre","cze","ces","chu","chv","wel","cym","dan","ger","deu","div","dzo","ewe","gre","ell","eng","epo","spa","est","baq","eus","per","fas","ful","fin","fij","fao","fre","fra","fry","gle","gla","glg","grn","guj","glv","hau","heb","hin","hmo","hrv","hat","hun","arm","hye","her","ina","ind","ile","ibo","iii","ipk","ido","ice","isl","ita","iku","jpn","jav","geo","kat","kon","kik","kua","kaz","kal","khm","kan","kor","kau","kas","kur","kom","cor","kir","lat","ltz","lug","lim","lin","lao","lit","lub","lav","mlg","mah","mao","mri","mac","mkd","mal","mon","mol","mar","may","msa","mlt","bur","mya","nau","nob","nde","nep","ndo","dut","nld","nno","nor","nbl","nav","nya","oci","oji","orm","ori","oss","pan","pli","pol","pus","por","que","roh","run","rum","ron","rus","kin","san","srd","snd","sme","sag","slo","sin","slk","slv","smo","sna","som","alb","sqi","srp","ssw","sot","sun","swe","swa","tam","tel","tgk","tha","tir","tuk","tgl","tsn","ton","tur","tso","tat","twi","tah","uig","ukr","urd","uzb","ven","vie","vol","wln","wol","xho","yid","yor","zha","chi","zho","zul"];var Se=Object.defineProperty,be=(e,t,i)=>((e,t,i)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ye{constructor(e,t,i){be(this,"_API"),be(this,"_cancelled",!1),be(this,"_timeout"),be(this,"_callback"),this._API=e,this._timeout=setTimeout(this.wrapper.bind(this),t),this._callback=i}cancel(){this._cancelled=!0,this._timeout&&clearTimeout(this._timeout)}wrapper(){this._cancelled||this._API.isInitialized()&&(async()=>{await this._API.commit(this._callback)})()}}const Ce=["continue","previous","exit","exitAll","abandon","abandonAll","suspendAll"];var Ae=Object.defineProperty,Ee=(e,t,i)=>((e,t,i)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),we=(e=>(e.NOT="not",e.AND="and",e.OR="or",e))(we||{}),Me=(e=>(e.SKIP="skip",e.DISABLED="disabled",e.HIDE_FROM_CHOICE="hiddenFromChoice",e.STOP_FORWARD_TRAVERSAL="stopForwardTraversal",e.EXIT_PARENT="exitParent",e.EXIT_ALL="exitAll",e.RETRY="retry",e.RETRY_ALL="retryAll",e.CONTINUE="continue",e.PREVIOUS="previous",e.EXIT="exit",e))(Me||{});const Oe=class e extends d{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"always",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map;super("ruleCondition"),Ee(this,"_condition","always"),Ee(this,"_operator",null),Ee(this,"_parameters",new Map),Ee(this,"_referencedObjective",null),this._condition=e,this._operator=t,this._parameters=i}static setNowProvider(t){"function"==typeof t&&(e._now=t)}static setElapsedSecondsHook(t){e._getElapsedSecondsHook=t}reset(){this._initialized=!1,this._condition="always",this._operator=null,this._parameters=new Map}get condition(){return this._condition}set condition(e){this._condition=e}get operator(){return this._operator}set operator(e){this._operator=e}get parameters(){return this._parameters}set parameters(e){this._parameters=e}get referencedObjective(){return this._referencedObjective}set referencedObjective(e){this._referencedObjective=e}resolveReferencedObjective(e){return this._referencedObjective?e.primaryObjective?.id===this._referencedObjective?e.primaryObjective:(e.objectives||[]).find(e=>e.id===this._referencedObjective)||null:null}evaluate(e){let result;const t=this.resolveReferencedObjective(e);switch(this._condition){case"satisfied":case"objectiveSatisfied":result=t?!0===t.satisfiedStatus:e.successStatus===P||!0===e.objectiveSatisfiedStatus;break;case"objectiveStatusKnown":case"objectiveMeasureKnown":result=t?!!t.measureStatus:!!e.objectiveMeasureStatus;break;case"objectiveMeasureGreaterThan":{const i=this._parameters.get("threshold")||0;result=!!(t?t.measureStatus:e.objectiveMeasureStatus)&&(t?t.normalizedMeasure:e.objectiveNormalizedMeasure)>i;break}case"objectiveMeasureLessThan":{const i=this._parameters.get("threshold")||0;result=!!(t?t.measureStatus:e.objectiveMeasureStatus)&&i>(t?t.normalizedMeasure:e.objectiveNormalizedMeasure);break}case"completed":case"activityCompleted":result=t?t.completionStatus===k:e.isCompleted;break;case"progressKnown":case"activityProgressKnown":result=t?t.completionStatus!==H:"unknown"!==e.completionStatus;break;case"attempted":result=e.attemptCount>0;break;case"attemptLimitExceeded":result=e.hasAttemptLimitExceeded();break;case"timeLimitExceeded":result=this.evaluateTimeLimitExceeded(e);break;case"outsideAvailableTimeRange":result=this.evaluateOutsideAvailableTimeRange(e);break;case"always":result=!0;break;default:result=!1}return"not"===this._operator&&(result=!result),result}evaluateTimeLimitExceeded(t){let i=t.timeLimitDuration;if(!i&&t.attemptAbsoluteDurationLimit&&(i=t.attemptAbsoluteDurationLimit),!i)return!1;const s=r(i,ne);if(0>=s)return!1;let n=0;if(e._getElapsedSecondsHook)try{const i=e._getElapsedSecondsHook(t);"number"!=typeof i||Number.isNaN(i)||0>i||(n=i)}catch{n=0}if(0===n&&t.attemptExperiencedDuration){const e=r(t.attemptExperiencedDuration,ne);e>0&&(n=e)}if(0===n&&t.attemptAbsoluteStartTime)try{const i=new Date(t.attemptAbsoluteStartTime).getTime(),s=e._now().getTime();Number.isNaN(i)||Number.isNaN(s)||i>s||(n=(s-i)/1e3)}catch{n=0}return n>s}evaluateOutsideAvailableTimeRange(t){const i=t.beginTimeLimit,s=t.endTimeLimit;if(!i&&!s)return!1;const r=e._now();return!(!i||r>=new Date(i))||!(!s||new Date(s)>=r)}parseISO8601Duration(e){return 1e3*r(e,ne)}toJSON(){this.jsonString=!0;const result={condition:this._condition,operator:this._operator,parameters:Object.fromEntries(this._parameters)};return this.jsonString=!1,result}};Ee(Oe,"_now",()=>new Date),Ee(Oe,"_getElapsedSecondsHook");let Re=Oe;class Te extends d{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"skip",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"and";super("sequencingRule"),Ee(this,"_conditions",[]),Ee(this,"_action","skip"),Ee(this,"_conditionCombination","and"),this._action=e,this._conditionCombination=t}reset(){this._initialized=!1,this._conditions=[],this._action="skip",this._conditionCombination="and"}get conditions(){return this._conditions}addCondition(e){if(!(e instanceof Re))throw new O(this._cmi_element+".conditions",j.TYPE_MISMATCH);this._conditions.includes(e)||this._conditions.push(e)}removeCondition(e){if(!(e instanceof Re))throw new O(this._cmi_element+".conditions",j.TYPE_MISMATCH);const t=this._conditions.indexOf(e);return-1!==t&&(this._conditions.splice(t,1),!0)}get action(){return this._action}set action(e){this._action=e}get conditionCombination(){return this._conditionCombination}set conditionCombination(e){this._conditionCombination=e}evaluate(e){return 0===this._conditions.length||("all"===this._conditionCombination||"and"===this._conditionCombination?this._conditions.every(t=>t.evaluate(e)):("any"===this._conditionCombination||"or"===this._conditionCombination)&&this._conditions.some(t=>t.evaluate(e)))}toJSON(){this.jsonString=!0;const result={conditions:this._conditions,action:this._action,conditionCombination:this._conditionCombination};return this.jsonString=!1,result}}class je extends d{constructor(){super("sequencingRules"),Ee(this,"_preConditionRules",[]),Ee(this,"_exitConditionRules",[]),Ee(this,"_postConditionRules",[])}reset(){this._initialized=!1,this._preConditionRules=[],this._exitConditionRules=[],this._postConditionRules=[]}get preConditionRules(){return this._preConditionRules}addPreConditionRule(e){if(!(e instanceof Te))throw new O(this._cmi_element+".preConditionRules",j.TYPE_MISMATCH);this._preConditionRules.push(e)}get exitConditionRules(){return this._exitConditionRules}addExitConditionRule(e){if(!(e instanceof Te))throw new O(this._cmi_element+".exitConditionRules",j.TYPE_MISMATCH);this._exitConditionRules.push(e)}get postConditionRules(){return this._postConditionRules}addPostConditionRule(e){if(!(e instanceof Te))throw new O(this._cmi_element+".postConditionRules",j.TYPE_MISMATCH);this._postConditionRules.push(e)}evaluatePreConditionRules(e){for(const t of this._preConditionRules)if(t.evaluate(e))return t.action;return null}evaluateExitConditionRules(e){for(const t of this._exitConditionRules)if(t.evaluate(e))return t.action;return null}evaluatePostConditionRules(e){for(const t of this._postConditionRules)if(t.evaluate(e))return t.action;return null}toJSON(){this.jsonString=!0;const result={preConditionRules:this._preConditionRules,exitConditionRules:this._exitConditionRules,postConditionRules:this._postConditionRules};return this.jsonString=!1,result}}var Ie=Object.defineProperty;class Ne{constructor(e){((e,t,i)=>{t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(this,"activityTree"+"",e)}isInTree(e){return this.activityTree.getAllActivities().includes(e)}isAncestorOf(e,t){let i=t;for(;i;){if(i===e)return!0;i=i.parent}return!1}findCommonAncestor(e,t){if(!e||!t)return null;const i=[];let s=e;for(;s;)i.push(s),s=s.parent;for(s=t;s;){if(i.includes(s))return s;s=s.parent}return null}findChildInPath(e,t){let i=t;for(;i&&i.parent;){if(i.parent===e)return i;i=i.parent}return null}isLastInTree(e){if(e.children.length>0)return!1;let t=e;for(;t;){if(this.activityTree.getNextSibling(t))return!1;t=t.parent}return!0}getCurrentInParent(e){if(e.children)for(const t of e.children)if(t.isActive)return t;return null}isMandatory(e){if(e.sequencingRules&&e.sequencingRules.preConditionRules)for(const t of e.sequencingRules.preConditionRules)if("skip"===t.action&&t.conditions&&0===t.conditions.length)return!1;return!0===e.mandatory}isCompleted(e){return"completed"===e.completionStatus||"passed"===e.completionStatus||"passed"===e.successStatus}isAvailableForChoice(e){return e.isVisible&&!e.isHiddenFromChoice&&e.isAvailable&&(!e.sequencingControls||e.sequencingControls.choice)}getAncestors(e){const t=[];let i=e.parent;for(;i;)t.push(i),i=i.parent;return t}getPathToRoot(e){const t=[e];let i=e.parent;for(;i;)t.push(i),i=i.parent;return t}isLeaf(e){return 0===e.children.length}isCluster(e){return e.children.length>0}getDepth(e){let t=0,i=e.parent;for(;i;)t++,i=i.parent;return t}}var xe=Object.defineProperty,qe=(e,t,i)=>((e,t,i)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class De{constructor(e,t){qe(this,"activityTree",e),qe(this,"treeQueries",t)}validateChoice(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this.treeQueries.isInTree(t))return{valid:!1,exception:"SB.2.9-2"};if(t===this.activityTree.root)return{valid:!1,exception:"SB.2.9-3"};const s=this.validatePathToRoot(t);if(!s.valid)return s;if(i.checkAvailability&&!t.isAvailable)return{valid:!1,exception:"SB.2.9-7"};if(!e)return{valid:!0,exception:null};const r=this.validateChoiceExit(e,t);if(!r.valid)return r;const n=this.validateAncestorConstraints(e,t);return n.valid?{valid:!0,exception:null}:n}validatePathToRoot(e){let t=e;for(;t;){if(t.isHiddenFromChoice)return{valid:!1,exception:"SB.2.9-4"};if(t.parent&&!t.parent.sequencingControls.choice)return{valid:!1,exception:"SB.2.9-5"};if(t.parent&&t.parent.sequencingControls.preventActivation&&0===e.attemptCount&&!e.isActive)return{valid:!1,exception:"SB.2.9-6"};t=t.parent}return{valid:!0,exception:null}}validateChoiceExit(e,t){let i=e.parent;for(;i;){if(i.isActive&&!i.sequencingControls.choiceExit){if(!this.treeQueries.isAncestorOf(i,t))return{valid:!1,exception:"SB.2.9-8"};break}i=i.parent}return{valid:!0,exception:null}}validateAncestorConstraints(e,t){let i=t.parent;for(;i;){const s=this.validateConstraintsAtLevel(i,e,t);if(!s.valid)return s;i=i.parent}return{valid:!0,exception:null}}validateConstraintsAtLevel(e,t,i){const s=this.treeQueries.findChildInPath(e,i),r=this.treeQueries.findChildInPath(e,t);if(!s||!r)return{valid:!0,exception:null};const n=e.children,o=n.indexOf(s),a=n.indexOf(r);if(-1===o||-1===a)return{valid:!0,exception:null};if(e.sequencingControls.forwardOnly&&a>o)return{valid:!1,exception:"SB.2.9-5"};if(o>a)for(let e=a+1;o>e;e++){const t=n[e];if(t&&this.treeQueries.isMandatory(t)&&!this.treeQueries.isCompleted(t))return{valid:!1,exception:"SB.2.9-6"}}if(e.sequencingControls.constrainChoice){if(o>a+1)return{valid:!1,exception:"SB.2.9-7"};if(a>o&&"completed"!==i.completionStatus&&"passed"!==i.completionStatus)return{valid:!1,exception:"SB.2.9-7"}}return e.sequencingControls.preventActivation&&0===i.attemptCount&&!i.isActive?{valid:!1,exception:"SB.2.9-6"}:{valid:!0,exception:null}}checkForwardOnlyViolation(e){let t=e.parent;for(;t;){if(t.sequencingControls.forwardOnly)return{valid:!1,exception:"SB.2.9-5"};t=t.parent}return{valid:!0,exception:null}}isAvailableForChoice(e){return this.treeQueries.isAvailableForChoice(e)}validateFlowConstraints(e,t){const i=[];for(const s of t)this.meetsFlowConstraints(s,e)&&i.push(s);return{valid:i.length>0,validChildren:i}}meetsFlowConstraints(e,t){return!(!e.isAvailable||e.isHiddenFromChoice)&&(!t.sequencingControls.constrainChoice||this.validateConstrainChoiceForFlow(e,t))}validateConstrainChoiceForFlow(e,t){if(!t.sequencingControls||!t.sequencingControls.constrainChoice)return!0;const i=t.children;if(!i||0===i.length)return!0;const s=i.indexOf(e);if(-1===s)return!1;const r=this.treeQueries.getCurrentInParent(t);if(!r)return this.isAvailableForChoice(e);const n=i.indexOf(r);return-1===n||(t.sequencingControls.flow?t.sequencingControls.forwardOnly&&n>s?"completed"===e.completionStatus||"passed"===e.completionStatus:n>s?n>s&&("completed"===e.completionStatus||"passed"===e.completionStatus)&&this.isAvailableForChoice(e):(s===n||s===n+1)&&this.isAvailableForChoice(e):this.isAvailableForChoice(e)&&("completed"===e.completionStatus||"unknown"===e.completionStatus||"incomplete"===e.completionStatus))}validateTraversalConstraints(e){let t=!0,i=!0;return e.parent?.sequencingControls.constrainChoice&&(t=this.evaluateConstrainChoiceForTraversal(e)),e.sequencingControls&&e.sequencingControls.stopForwardTraversal&&(i=!1),e.parent?.sequencingControls.forwardOnly&&(i=this.evaluateForwardOnlyForChoice(e)),{canTraverse:t,canTraverseInto:i}}evaluateConstrainChoiceForTraversal(e){if(!e.parent)return!0;let t=e.parent;for(;t;){if(t.sequencingControls&&t.sequencingControls.constrainChoice){const i=t.children,s=this.treeQueries.findChildInPath(t,e);if(s){const r=i.indexOf(s),n=this.treeQueries.getCurrentInParent(t);if(n){const s=i.indexOf(n);if(-1!==s&&-1!==r){if(r>s)for(let e=s+1;r>e;e++){const t=i[e];if(t&&this.treeQueries.isMandatory(t)&&!this.treeQueries.isCompleted(t))return!1}if(t.sequencingControls.forwardOnly&&s>r&&!this.treeQueries.isCompleted(e))return!1}}}}t=t.parent}return this.isAvailableForChoice(e)}evaluateForwardOnlyForChoice(e){if(!e.parent)return!0;const t=e.parent;if(!t.sequencingControls||!t.sequencingControls.forwardOnly)return!0;const i=t.children;if(!i||0===i.length)return!0;const s=i.indexOf(e);if(-1===s)return!1;const r=this.treeQueries.getCurrentInParent(t);if(!r)return this.isAvailableForChoice(e);const n=i.indexOf(r);return-1===n||(n>s?!("completed"!==e.completionStatus&&"passed"!==e.completionStatus||!e.sequencingControls||!e.sequencingControls.choice):this.isAvailableForChoice(e))}hasTimeBoundaryViolation(e,t){if(e.beginTimeLimit)try{if(new Date(e.beginTimeLimit)>t)return!0}catch{}if(e.endTimeLimit)try{if(t>new Date(e.endTimeLimit))return!0}catch{}return!1}hasAttemptLimitViolation(e){return!(!e.attemptLimit||e.attemptLimit>e.attemptCount)}}var Le=Object.defineProperty,Pe=(e,t,i)=>((e,t,i)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),ze=(e=>(e.START="start",e.RESUME_ALL="resumeAll",e.CONTINUE="continue",e.PREVIOUS="previous",e.CHOICE="choice",e.JUMP="jump",e.EXIT="exit",e.EXIT_PARENT="exitParent",e.EXIT_ALL="exitAll",e.ABANDON="abandon",e.ABANDON_ALL="abandonAll",e.SUSPEND_ALL="suspendAll",e.RETRY="retry",e.RETRY_ALL="retryAll",e))(ze||{}),Fe=(e=>(e.DELIVER="deliver",e.DO_NOT_DELIVER="doNotDeliver",e))(Fe||{});class ke{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"doNotDeliver",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Pe(this,"deliveryRequest"),Pe(this,"targetActivity"),Pe(this,"exception"),Pe(this,"endSequencingSession"),this.deliveryRequest=e,this.targetActivity=t,this.exception=i,this.endSequencingSession=s}}class Ve{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Pe(this,"identifiedActivity"),Pe(this,"deliverable"),Pe(this,"exception"),Pe(this,"endSequencingSession"),this.identifiedActivity=e,this.deliverable=t,this.exception=i,this.endSequencingSession=s}}class He{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;Pe(this,"activity"),Pe(this,"exception"),this.activity=e,this.exception=t}}var Be=(e=>(e.FORWARD="forward",e.BACKWARD="backward",e))(Be||{}),Ue=Object.defineProperty,$e=(e,t,i)=>((e,t,i)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ge{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};$e(this,"now"),$e(this,"getAttemptElapsedSecondsHook"),this.now=e.now||(()=>new Date),this.getAttemptElapsedSecondsHook=e.getAttemptElapsedSecondsHook||null}checkSequencingRules(e,t){for(const i of t)if(this.checkRuleSubprocess(e,i))return i.action;return null}checkRuleSubprocess(e,t){if(0===t.conditions.length)return!0;const i=t.conditionCombination;return"all"===i||i===we.AND?t.conditions.every(t=>t.evaluate(e)):("any"===i||i===we.OR)&&t.conditions.some(t=>t.evaluate(e))}evaluateExitRules(e){const t=this.checkSequencingRules(e,e.sequencingRules.exitConditionRules);return t===Me.EXIT||t===Me.EXIT_PARENT||t===Me.EXIT_ALL?t:null}evaluatePostConditionAction(e){const t=this.checkSequencingRules(e,e.sequencingRules.postConditionRules);return t&&[Me.EXIT_PARENT,Me.EXIT_ALL,Me.RETRY,Me.RETRY_ALL,Me.CONTINUE,Me.PREVIOUS,Me.STOP_FORWARD_TRAVERSAL].includes(t)?t:null}evaluatePostConditions(e){const t=this.evaluatePostConditionAction(e);if(!t)return{sequencingRequest:null,terminationRequest:null};switch(t){case Me.EXIT_PARENT:return{sequencingRequest:null,terminationRequest:ze.EXIT_PARENT};case Me.EXIT_ALL:return{sequencingRequest:null,terminationRequest:ze.EXIT_ALL};case Me.RETRY:return{sequencingRequest:ze.RETRY,terminationRequest:null};case Me.RETRY_ALL:return{sequencingRequest:ze.RETRY,terminationRequest:ze.EXIT_ALL};case Me.CONTINUE:return{sequencingRequest:ze.CONTINUE,terminationRequest:null};case Me.PREVIOUS:return{sequencingRequest:ze.PREVIOUS,terminationRequest:null};case Me.STOP_FORWARD_TRAVERSAL:return e.sequencingControls.stopForwardTraversal=!0,{sequencingRequest:null,terminationRequest:null};default:return{sequencingRequest:null,terminationRequest:null}}}checkLimitConditions(e){if(null!==e.attemptLimit&&e.attemptCount>=e.attemptLimit)return!0;if(null!==e.attemptAbsoluteDurationLimit){const t=this.parseDuration(e.attemptAbsoluteDurationLimit);if(t>0&&this.parseDuration(e.attemptExperiencedDuration)>=t)return!0}if(null!==e.activityAbsoluteDurationLimit){const t=this.parseDuration(e.activityAbsoluteDurationLimit);if(t>0&&this.parseDuration(e.activityExperiencedDuration)>=t)return!0}return!1}parseDuration(e){if(!e||"string"!=typeof e)return 0;const t=e.match(/^P(?:(\d+(?:\.\d+)?)Y)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)W)?(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/);if(!t||"P"===e||e.endsWith("T"))return 0;let i=0;return i+=315576e5*parseFloat(t[1]||"0"),i+=30.44*24*parseFloat(t[2]||"0")*36e5,i+=6048e5*parseFloat(t[3]||"0"),i+=864e5*parseFloat(t[4]||"0"),i+=36e5*parseFloat(t[5]||"0"),i+=6e4*parseFloat(t[6]||"0"),i+=1e3*parseFloat(t[7]||"0"),i}getElapsedSeconds(e){if(this.getAttemptElapsedSecondsHook)try{return this.getAttemptElapsedSecondsHook(e)||0}catch{return 0}if(e.attemptAbsoluteStartTime){const t=new Date(e.attemptAbsoluteStartTime).getTime(),i=this.now().getTime();if(!Number.isNaN(t)&&i>t)return Math.max(0,(i-t)/1e3)}return 0}isTimeLimitExceeded(e){let t=e.timeLimitDuration;if(!t&&e.attemptAbsoluteDurationLimit&&(t=e.attemptAbsoluteDurationLimit),!t)return!1;const i=r(t,ne);return i>0&&this.getElapsedSeconds(e)>i}isOutsideAvailableTimeRange(e){const t=this.now();if(e.beginTimeLimit)try{const i=new Date(e.beginTimeLimit);if(!Number.isNaN(i.getTime())&&i>t)return!0}catch{}if(e.endTimeLimit)try{const i=new Date(e.endTimeLimit);if(!Number.isNaN(i.getTime())&&t>i)return!0}catch{}return!1}canDeliverActivity(e){if(this.checkLimitConditions(e))return{canDeliver:!1,wasSkipped:!1};const t=this.checkSequencingRules(e,e.sequencingRules.preConditionRules);return{canDeliver:t!==Me.SKIP&&t!==Me.DISABLED,wasSkipped:t===Me.SKIP}}}var Ye=Object.defineProperty,We=(e,t,i)=>((e,t,i)=>t in e?Ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),Je=(e=>(e.NEVER="never",e.ONCE="once",e.ON_EACH_NEW_ATTEMPT="onEachNewAttempt",e))(Je||{}),Ke=(e=>(e.NEVER="never",e.ONCE="once",e.ON_EACH_NEW_ATTEMPT="onEachNewAttempt",e))(Ke||{});class Xe extends d{constructor(){super("sequencingControls"),We(this,"_enabled",!0),We(this,"_choice",!0),We(this,"_choiceExit",!0),We(this,"_flow",!0),We(this,"_forwardOnly",!1),We(this,"_useCurrentAttemptObjectiveInfo",!0),We(this,"_useCurrentAttemptProgressInfo",!0),We(this,"_preventActivation",!1),We(this,"_constrainChoice",!1),We(this,"_stopForwardTraversal",!1),We(this,"_rollupObjectiveSatisfied",!0),We(this,"_rollupProgressCompletion",!0),We(this,"_objectiveMeasureWeight",1),We(this,"_selectionTiming","never"),We(this,"_selectCount",null),We(this,"_selectionCountStatus",!1),We(this,"_randomizeChildren",!1),We(this,"_randomizationTiming","never"),We(this,"_reorderChildren",!1),We(this,"_completionSetByContent",!1),We(this,"_objectiveSetByContent",!1),We(this,"_tracked",!0)}reset(){this._initialized=!1,this._enabled=!0,this._choice=!0,this._choiceExit=!0,this._flow=!0,this._forwardOnly=!1,this._useCurrentAttemptObjectiveInfo=!0,this._useCurrentAttemptProgressInfo=!0,this._preventActivation=!1,this._constrainChoice=!1,this._stopForwardTraversal=!1,this._rollupObjectiveSatisfied=!0,this._rollupProgressCompletion=!0,this._objectiveMeasureWeight=1,this._selectionTiming="never",this._selectCount=null,this._selectionCountStatus=!1,this._randomizeChildren=!1,this._randomizationTiming="never",this._reorderChildren=!1,this._completionSetByContent=!1,this._objectiveSetByContent=!1,this._tracked=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e}get choice(){return this._choice}set choice(e){this._choice=e}get choiceExit(){return this._choiceExit}set choiceExit(e){this._choiceExit=e}get flow(){return this._flow}set flow(e){this._flow=e}get forwardOnly(){return this._forwardOnly}set forwardOnly(e){this._forwardOnly=e}get useCurrentAttemptObjectiveInfo(){return this._useCurrentAttemptObjectiveInfo}set useCurrentAttemptObjectiveInfo(e){this._useCurrentAttemptObjectiveInfo=e}get useCurrentAttemptProgressInfo(){return this._useCurrentAttemptProgressInfo}set useCurrentAttemptProgressInfo(e){this._useCurrentAttemptProgressInfo=e}get preventActivation(){return this._preventActivation}set preventActivation(e){this._preventActivation=e}get constrainChoice(){return this._constrainChoice}set constrainChoice(e){this._constrainChoice=e}get stopForwardTraversal(){return this._stopForwardTraversal}set stopForwardTraversal(e){this._stopForwardTraversal=e}get rollupObjectiveSatisfied(){return this._rollupObjectiveSatisfied}set rollupObjectiveSatisfied(e){this._rollupObjectiveSatisfied=e}get rollupProgressCompletion(){return this._rollupProgressCompletion}set rollupProgressCompletion(e){this._rollupProgressCompletion=e}get objectiveMeasureWeight(){return this._objectiveMeasureWeight}set objectiveMeasureWeight(e){0>e||(this._objectiveMeasureWeight=e)}isChoiceNavigationAllowed(){return this._enabled&&!this._constrainChoice}isFlowNavigationAllowed(){return this._enabled&&this._flow}isForwardNavigationAllowed(){return this._enabled&&this._flow}isBackwardNavigationAllowed(){return this._enabled&&this._flow&&!this._forwardOnly}get selectionTiming(){return this._selectionTiming}set selectionTiming(e){this._selectionTiming=e}get selectCount(){return this._selectCount}set selectCount(e){(null===e||e>0)&&(this._selectCount=e)}get selectionCountStatus(){return this._selectionCountStatus}set selectionCountStatus(e){this._selectionCountStatus=e}get randomizeChildren(){return this._randomizeChildren}set randomizeChildren(e){this._randomizeChildren=e}get randomizationTiming(){return this._randomizationTiming}set randomizationTiming(e){this._randomizationTiming=e}get reorderChildren(){return this._reorderChildren}set reorderChildren(e){this._reorderChildren=e}get completionSetByContent(){return this._completionSetByContent}set completionSetByContent(e){this._completionSetByContent=e}get objectiveSetByContent(){return this._objectiveSetByContent}set objectiveSetByContent(e){this._objectiveSetByContent=e}get tracked(){return this._tracked}set tracked(e){this._tracked=e}toJSON(){this.jsonString=!0;const result={enabled:this._enabled,choice:this._choice,choiceExit:this._choiceExit,flow:this._flow,forwardOnly:this._forwardOnly,useCurrentAttemptObjectiveInfo:this._useCurrentAttemptObjectiveInfo,useCurrentAttemptProgressInfo:this._useCurrentAttemptProgressInfo,preventActivation:this._preventActivation,constrainChoice:this._constrainChoice,stopForwardTraversal:this._stopForwardTraversal,rollupObjectiveSatisfied:this._rollupObjectiveSatisfied,rollupProgressCompletion:this._rollupProgressCompletion,objectiveMeasureWeight:this._objectiveMeasureWeight,selectionTiming:this._selectionTiming,selectCount:this._selectCount,selectionCountStatus:this._selectionCountStatus,randomizeChildren:this._randomizeChildren,randomizationTiming:this._randomizationTiming,reorderChildren:this._reorderChildren,completionSetByContent:this._completionSetByContent,objectiveSetByContent:this._objectiveSetByContent,tracked:this._tracked};return this.jsonString=!1,result}}class Qe{static selectChildrenProcess(e){const t=e.sequencingControls,i=[...e.children];if(t.selectionTiming===Je.NEVER)return i;if(t.selectionTiming===Je.ONCE&&t.selectionCountStatus)return i;if(t.selectionTiming!==Je.ONCE&&!t.selectionCountStatus)return i;const s=t.selectCount;if(null===s||s>=i.length)return t.selectionTiming===Je.ONCE&&(t.selectionCountStatus=!0),i;const r=[],n=i.map((e,t)=>t);for(let e=0;s>e&&0!==n.length;e++){const e=Math.floor(Math.random()*n.length),t=n[e];void 0!==t&&i[t]&&r.push(i[t]),n.splice(e,1)}t.selectionTiming===Je.ONCE&&(t.selectionCountStatus=!0);for(const e of i)r.includes(e)||(e.isHiddenFromChoice=!0,e.isAvailable=!1);return r}static randomizeChildrenProcess(e){const t=e.sequencingControls,i=[...e.children];if(t.randomizationTiming===Ke.NEVER)return i;if(t.randomizationTiming===Ke.ONCE&&t.reorderChildren)return i;if(!t.randomizeChildren)return i;const s=[...i];for(let e=s.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),i=s[e],r=s[t];i&&r&&(s[e]=r,s[t]=i)}return t.randomizationTiming===Ke.ONCE&&(t.reorderChildren=!0),e.children.length=0,e.children.push(...s),s}static applySelectionAndRandomization(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=e.sequencingControls;if(!t&&(e.isActive||e.isSuspended))return e.children;let s=!1,r=!1;i.selectionTiming===Je.ON_EACH_NEW_ATTEMPT?(s=t,t&&(i.selectionCountStatus=!0)):i.selectionTiming===Je.ONCE&&(s=!i.selectionCountStatus),i.randomizationTiming===Ke.ON_EACH_NEW_ATTEMPT?(r=t,t&&(i.reorderChildren=!1)):i.randomizationTiming===Ke.ONCE&&(r=!i.reorderChildren),s&&this.selectChildrenProcess(e),r&&this.randomizeChildrenProcess(e);const n=e.children.filter(e=>e.isAvailable);return e.setProcessedChildren(n),n}static isSelectionNeeded(e){const t=e.sequencingControls;return t.selectionTiming!==Je.NEVER&&(t.selectionTiming!==Je.ONCE||!t.selectionCountStatus)&&null!==t.selectCount&&e.children.length>t.selectCount}static isRandomizationNeeded(e){const t=e.sequencingControls;return t.randomizationTiming!==Ke.NEVER&&(t.randomizationTiming!==Ke.ONCE||!t.reorderChildren)&&t.randomizeChildren}}var Ze=Object.defineProperty,et=(e,t,i)=>((e,t,i)=>t in e?Ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class tt{constructor(e,t){et(this,"activityTree",e),et(this,"ruleEngine",t)}flowSubprocess(e,t){let i=e,s=!0,r=!1;for(;i;){const e=this.flowTreeTraversalSubprocess(i,t,s);if(!e.activity){let s=null;return e.exception?s=e.exception:t===Be.BACKWARD?s="SB.2.1-3":r&&(s="SB.2.1-2"),new Ve(i,!1,s,e.endSequencingSession)}r=e.activity.children.length>0&&0===e.activity.getAvailableChildren().length;const n=this.flowActivityTraversalSubprocess(e.activity,t===Be.FORWARD,!0,t);if(n)return new Ve(n,!0,null,!1);i=e.activity,s=!1}return new Ve(null,!1,null,!1)}flowTreeTraversalSubprocess(e,t){return t===Be.FORWARD?this.traverseForward(e,arguments.length>2&&void 0!==arguments[2]&&arguments[2]):this.traverseBackward(e)}traverseForward(e,t){if(t&&this.isActivityLastOverall(e))return this.activityTree.root&&this.terminateDescendentAttempts(this.activityTree.root),{activity:null,endSequencingSession:!0};if(!t){this.ensureSelectionAndRandomization(e);const t=e.getAvailableChildren();if(t.length>0)return{activity:t[0]||null,endSequencingSession:!1}}let i=e;for(;i;){const e=this.activityTree.getNextSibling(i);if(e)return{activity:e,endSequencingSession:!1};i=i.parent}return this.activityTree.root&&this.terminateDescendentAttempts(this.activityTree.root),{activity:null,endSequencingSession:!0}}traverseBackward(e){if(e.parent&&e.parent.sequencingControls.forwardOnly)return{activity:null,endSequencingSession:!1,exception:"SB.2.1-4"};const t=this.activityTree.getPreviousSibling(e);if(t)return{activity:this.getLastDescendant(t),endSequencingSession:!1};let i=e,s=0;for(;i&&i.parent;){if(++s>1e4)throw Error("Infinite loop detected in backward traversal");const e=this.activityTree.getPreviousSibling(i.parent);if(e)return{activity:this.getLastDescendant(e),endSequencingSession:!1};i=i.parent}return{activity:null,endSequencingSession:!1}}getLastDescendant(e){let t=e,i=0;for(;;){if(++i>1e4)throw Error("Infinite loop detected while getting last descendant");this.ensureSelectionAndRandomization(t);const e=t.getAvailableChildren();if(0===e.length)break;const s=e[e.length-1];if(!s)break;t=s}return t}flowActivityTraversalSubprocess(e,t,i,mode){const s=e.parent;if(s&&!s.sequencingControls.flow)return null;if(!e.isAvailable)return null;if(mode===Be.FORWARD&&e.sequencingControls.stopForwardTraversal)return null;if(i){this.ensureSelectionAndRandomization(e);const t=e.getAvailableChildren();for(const e of t){const t=this.flowActivityTraversalSubprocess(e,mode===Be.FORWARD,!0,mode);if(t)return t}}return 0===e.children.length&&this.checkActivityProcess(e)?e:null}checkActivityProcess(e){if(!e.isAvailable)return!1;if(0===e.children.length&&!e.isVisible)return!1;if(this.ruleEngine.checkLimitConditions(e))return!1;const t=this.ruleEngine.canDeliverActivity(e);return e.wasSkipped=t.wasSkipped,t.canDeliver}ensureSelectionAndRandomization(e){e.getAvailableChildren()===e.children&&(Qe.isSelectionNeeded(e)||Qe.isRandomizationNeeded(e))&&Qe.applySelectionAndRandomization(e,e.isNewAttempt)}isActivityLastOverall(e){if(e.children.length>0)return!1;let t=e;for(;t;){if(this.activityTree.getNextSibling(t))return!1;t=t.parent}return!0}terminateDescendentAttempts(e){e.isActive=!1;for(const t of e.children)this.terminateDescendentAttempts(t)}findFirstDeliverableActivity(e){if(0===e.children.length)return this.checkActivityProcess(e)?e:null;this.ensureSelectionAndRandomization(e);const t=e.getAvailableChildren();for(const e of t){const t=this.flowActivityTraversalSubprocess(e,!0,!0,Be.FORWARD);if(t)return t}return null}canDeliver(e){return this.checkActivityProcess(e)}}var it=Object.defineProperty,st=(e,t,i)=>((e,t,i)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class rt{constructor(e,t){st(this,"activityTree",e),st(this,"traversalService",t)}handleStart(){const result=new ke;if(!this.activityTree.root)return result.exception="SB.2.5-1",result;if(this.activityTree.currentActivity)return result.exception="SB.2.5-2",result;const e=this.traversalService.findFirstDeliverableActivity(this.activityTree.root);return e?(result.deliveryRequest=Fe.DELIVER,result.targetActivity=e,result):(result.exception="SB.2.5-3",result)}handleResumeAll(){const result=new ke;return this.activityTree.suspendedActivity?this.activityTree.currentActivity?(result.exception="SB.2.6-2",result):(result.deliveryRequest=Fe.DELIVER,result.targetActivity=this.activityTree.suspendedActivity,result):(result.exception="SB.2.6-1",result)}handleContinue(e){const result=new ke;if(e.isActive)return result.exception="SB.2.7-1",result;if(e.parent&&!e.parent.sequencingControls.flow)return result.exception="SB.2.7-2",result;const t=this.traversalService.flowSubprocess(e,Be.FORWARD);return result.endSequencingSession=t.endSequencingSession,t.deliverable&&t.identifiedActivity?(result.deliveryRequest=Fe.DELIVER,result.targetActivity=t.identifiedActivity,result):(result.exception=t.exception||"SB.2.7-2",result)}handlePrevious(e){const result=new ke;if(e.isActive)return result.exception="SB.2.8-1",result;if(e.parent&&!e.parent.sequencingControls.flow)return result.exception="SB.2.8-2",result;const t=this.checkForwardOnlyViolation(e);if(t)return result.exception=t,result;const i=this.traversalService.flowSubprocess(e,Be.BACKWARD);return i.deliverable&&i.identifiedActivity?(result.deliveryRequest=Fe.DELIVER,result.targetActivity=i.identifiedActivity,result):(result.exception=i.exception||"SB.2.8-3",result)}checkForwardOnlyViolation(e){let t=e.parent;for(;t;){if(t.sequencingControls.forwardOnly)return"SB.2.9-5";t=t.parent}return null}}var nt=Object.defineProperty,ot=(e,t,i)=>((e,t,i)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class at{constructor(e,t,i,s){ot(this,"activityTree",e),ot(this,"constraintValidator",t),ot(this,"traversalService",i),ot(this,"treeQueries",s)}handleChoice(e,t){const result=new ke,i=this.activityTree.getActivity(e);if(!i)return result.exception="SB.2.9-1",result;if(t&&t.isActive)return result.exception="SB.2.9-6",result;const s=this.constraintValidator.validateChoice(t,i,{checkAvailability:!0});if(!s.valid)return result.exception=s.exception,result;const r=this.treeQueries.findCommonAncestor(t,i);t&&this.terminateDescendentAttemptsProcess(r||this.activityTree.root);const n=this.buildActivityPath(i,r);for(const e of n)if(!this.traversalService.checkActivityProcess(e))return result;let o=i;if(i.children.length>0){const e=this.choiceFlowSubprocess(i);if(!e)return result.exception="SB.2.9-7",result;o=e}return result.deliveryRequest=Fe.DELIVER,result.targetActivity=o,result}handleJump(e){const result=new ke,t=this.activityTree.getActivity(e);return t?this.treeQueries.isInTree(t)?t.isAvailable?(result.deliveryRequest=Fe.DELIVER,result.targetActivity=t,result):(result.exception="SB.2.13-3",result):(result.exception="SB.2.13-2",result):(result.exception="SB.2.13-1",result)}getAvailableChoices(){const e=this.activityTree.getAllActivities(),t=this.activityTree.currentActivity,i=[];for(const s of e)s!==this.activityTree.root&&!s.isHiddenFromChoice&&s.isAvailable&&s.isVisible&&(s.parent&&!s.parent.sequencingControls.choice||this.constraintValidator.validateChoice(t,s).valid&&i.push(s));return i}buildActivityPath(e,t){const i=[];let s=e;for(;s&&s!==t;)i.unshift(s),s=s.parent;return i}choiceFlowSubprocess(e){return 0===e.children.length?e:this.choiceFlowTreeTraversal(e)}choiceFlowTreeTraversal(e){this.traversalService.ensureSelectionAndRandomization(e);const t=e.getAvailableChildren(),i=this.constraintValidator.validateFlowConstraints(e,t);if(!i.valid)return null;for(const e of i.validChildren){const t=this.enhancedChoiceTraversal(e);if(t.activity)return t.activity}return null}enhancedChoiceTraversal(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&e===this.activityTree.root)return new He(null,"SB.2.4-3");if(!e.isAvailable)return new He(null,null);if(e.isHiddenFromChoice)return new He(null,null);if(e.sequencingControls&&e.sequencingControls.stopForwardTraversal)return new He(null,"SB.2.4-1");const t=this.constraintValidator.validateTraversalConstraints(e);if(!t.canTraverse)return new He(null,null);if(0===e.children.length)return this.traversalService.checkActivityProcess(e)?new He(e,null):new He(null,null);if(e.parent?.sequencingControls.constrainChoice&&!t.canTraverseInto)return new He(null,"SB.2.4-2");if(t.canTraverseInto){const t=this.choiceFlowTreeTraversal(e);return new He(t,null)}return new He(null,null)}terminateDescendentAttemptsProcess(e){e.isActive=!1;for(const t of e.children)this.terminateDescendentAttemptsProcess(t)}}var ct=Object.defineProperty,lt=(e,t,i)=>((e,t,i)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ut{constructor(e,t){lt(this,"activityTree",e),lt(this,"ruleEngine",t)}handleExit(e){const result=new ke;return e.parent?e.parent.sequencingControls.choiceExit?(this.terminateDescendentAttempts(e),result):(result.exception="SB.2.11-2",result):(result.exception="SB.2.11-1",result)}handleExitAll(){const result=new ke;return this.activityTree.root&&this.terminateDescendentAttempts(this.activityTree.root),result}handleAbandon(e){const result=new ke;return e.isActive=!1,this.activityTree.currentActivity=e.parent,result}handleAbandonAll(){const result=new ke;return this.activityTree.currentActivity=null,result}handleSuspendAll(e){const result=new ke;return e===this.activityTree.root?(result.exception="SB.2.15-1",result):(e.isSuspended=!0,this.activityTree.suspendedActivity=e,this.activityTree.currentActivity=null,result)}terminateDescendentAttempts(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=null;t||(i=this.ruleEngine.evaluateExitRules(e)),e.isActive=!1;for(const i of e.children)this.terminateDescendentAttempts(i,t);i&&!t&&this.processDeferredExitAction(i,e)}processDeferredExitAction(e,t){switch(e){case Me.EXIT:break;case Me.EXIT_PARENT:t.parent&&t.parent.isActive&&this.terminateDescendentAttempts(t.parent,!0);break;case Me.EXIT_ALL:this.activityTree.root&&this.activityTree.root!==t&&this.activityTree.getAllActivities().some(e=>e.isActive)&&this.terminateDescendentAttempts(this.activityTree.root,!0)}}}var ht=Object.defineProperty,dt=(e,t,i)=>((e,t,i)=>t in e?ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class mt{constructor(e,t){dt(this,"activityTree",e),dt(this,"traversalService",t)}handleRetry(e){const result=new ke;if(e.isActive||e.isSuspended)return result.exception="SB.2.10-2",result;if(e.children.length>0){this.traversalService.ensureSelectionAndRandomization(e);const t=e.getAvailableChildren();let i=null;for(const e of t)if(i=this.traversalService.flowActivityTraversalSubprocess(e,!0,!0,Be.FORWARD),i)break;return i?(result.deliveryRequest=Fe.DELIVER,result.targetActivity=i,result):(result.exception="SB.2.10-3",result)}return this.terminateDescendentAttempts(e),result.deliveryRequest=Fe.DELIVER,result.targetActivity=e,result}handleRetryAll(){if(this.activityTree.currentActivity=null,!this.activityTree.root){const e=new ke;return e.exception="SB.2.10-1",e}const e=this.traversalService.findFirstDeliverableActivity(this.activityTree.root),result=new ke;return e?(result.deliveryRequest=Fe.DELIVER,result.targetActivity=e,result):(result.exception="SB.2.10-3",result)}terminateDescendentAttempts(e){e.isActive=!1;for(const t of e.children)this.terminateDescendentAttempts(t)}}var pt=Object.defineProperty,_t=(e,t,i)=>((e,t,i)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class vt{constructor(e,t,i){let s=arguments.length>4?arguments[4]:void 0;_t(this,"activityTree"),_t(this,"treeQueries"),_t(this,"constraintValidator"),_t(this,"ruleEngine"),_t(this,"traversalService"),_t(this,"flowHandler"),_t(this,"choiceHandler"),_t(this,"exitHandler"),_t(this,"retryHandler"),_t(this,"_now"),_t(this,"_getAttemptElapsedSecondsHook"),this.activityTree=e,this._now=s?.now||(()=>new Date),this._getAttemptElapsedSecondsHook=s?.getAttemptElapsedSeconds,this.treeQueries=new Ne(e),this.ruleEngine=new Ge({now:this._now,getAttemptElapsedSecondsHook:this._getAttemptElapsedSecondsHook}),this.constraintValidator=new De(e,this.treeQueries),this.traversalService=new tt(e,this.ruleEngine),this.flowHandler=new rt(e,this.traversalService),this.choiceHandler=new at(e,this.constraintValidator,this.traversalService,this.treeQueries),this.exitHandler=new ut(e,this.ruleEngine),this.retryHandler=new mt(e,this.traversalService)}get now(){return this._now}set now(e){this._now=e,Re.setNowProvider(e),this.ruleEngine=new Ge({now:e,getAttemptElapsedSecondsHook:this._getAttemptElapsedSecondsHook}),this.traversalService=new tt(this.activityTree,this.ruleEngine),this.flowHandler=new rt(this.activityTree,this.traversalService),this.choiceHandler=new at(this.activityTree,this.constraintValidator,this.traversalService,this.treeQueries),this.retryHandler=new mt(this.activityTree,this.traversalService)}get getAttemptElapsedSecondsHook(){return this._getAttemptElapsedSecondsHook}set getAttemptElapsedSecondsHook(e){this._getAttemptElapsedSecondsHook=e,Re.setElapsedSecondsHook(e),this.ruleEngine=new Ge({now:this._now,getAttemptElapsedSecondsHook:e}),this.traversalService=new tt(this.activityTree,this.ruleEngine),this.flowHandler=new rt(this.activityTree,this.traversalService),this.choiceHandler=new at(this.activityTree,this.constraintValidator,this.traversalService,this.treeQueries),this.retryHandler=new mt(this.activityTree,this.traversalService)}sequencingRequestProcess(request){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const t=this.activityTree.currentActivity;switch(request){case ze.START:return this.flowHandler.handleStart();case ze.RESUME_ALL:return this.flowHandler.handleResumeAll();case ze.CONTINUE:return t?this.flowHandler.handleContinue(t):new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-1");case ze.PREVIOUS:return t?this.flowHandler.handlePrevious(t):new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-1");case ze.CHOICE:return e?this.choiceHandler.handleChoice(e,t):new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-5");case ze.JUMP:return e?this.choiceHandler.handleJump(e):new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-5");case ze.EXIT:return t?this.exitHandler.handleExit(t):new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-1");case ze.EXIT_ALL:return t?this.exitHandler.handleExitAll():new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-1");case ze.ABANDON:return t?this.exitHandler.handleAbandon(t):new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-1");case ze.ABANDON_ALL:return t?this.exitHandler.handleAbandonAll():new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-1");case ze.SUSPEND_ALL:return t?this.exitHandler.handleSuspendAll(t):new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-1");case ze.RETRY:return t?this.retryHandler.handleRetry(t):new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-1");case ze.RETRY_ALL:return this.retryHandler.handleRetryAll();default:return new ke(Fe.DO_NOT_DELIVER,null,"SB.2.12-6")}}evaluatePostConditionRules(e){return this.ruleEngine.evaluatePostConditions(e)}canActivityBeDelivered(e){return this.traversalService.canDeliver(e)}validateNavigationRequest(request){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!Object.values(ze).includes(request))return{valid:!1,exception:"SB.2.12-6"};switch(request){case ze.CONTINUE:case ze.PREVIOUS:if(!t)return{valid:!1,exception:"SB.2.12-1"};if(t.isActive)return{valid:!1,exception:request===ze.CONTINUE?"SB.2.7-1":"SB.2.8-1"};if(t.parent&&!t.parent.sequencingControls.flow)return{valid:!1,exception:request===ze.CONTINUE?"SB.2.7-2":"SB.2.8-2"};if(request===ze.PREVIOUS){const e=this.constraintValidator.checkForwardOnlyViolation(t);if(!e.valid)return e}break;case ze.CHOICE:{if(!e)return{valid:!1,exception:"SB.2.12-5"};const i=this.activityTree.getActivity(e);if(!i)return{valid:!1,exception:"SB.2.9-1"};const s=this.constraintValidator.validateChoice(t,i,{checkAvailability:!0});if(!s.valid)return s;if(!this.traversalService.canDeliver(i))return{valid:!1,exception:"SB.2.9-6"};if(this.ruleEngine.checkSequencingRules(i,i.sequencingRules.preConditionRules)===Me.HIDE_FROM_CHOICE)return{valid:!1,exception:"SB.2.9-4"};break}case ze.JUMP:if(!e)return{valid:!1,exception:"SB.2.12-5"};if(!this.activityTree.getActivity(e))return{valid:!1,exception:"SB.2.13-1"}}return{valid:!0,exception:null}}getAvailableChoices(){return this.choiceHandler.getAvailableChoices()}getTreeQueries(){return this.treeQueries}getConstraintValidator(){return this.constraintValidator}getRuleEngine(){return this.ruleEngine}getTraversalService(){return this.traversalService}}var gt=Object.defineProperty,ft=(e,t,i)=>((e,t,i)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class St{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};ft(this,"eventService"),ft(this,"loggingService"),ft(this,"callbacks"),ft(this,"currentDeliveredActivity",null),ft(this,"pendingDelivery",null),this.eventService=e,this.loggingService=t,this.callbacks=i}processSequencingResult(result){if(result.exception)return this.loggingService.error("Sequencing error: "+result.exception),void this.callbacks.onSequencingError?.(result.exception);result.deliveryRequest===Fe.DELIVER&&result.targetActivity?this.deliverActivity(result.targetActivity):this.loggingService.info("Sequencing completed with no delivery request"),this.callbacks.onSequencingComplete?.(result)}deliverActivity(e){this.currentDeliveredActivity!==e?(this.currentDeliveredActivity&&this.unloadActivity(this.currentDeliveredActivity),this.pendingDelivery=e,this.loggingService.info(`Delivering activity: ${e.id} - ${e.title}`),this.eventService.processListeners("ActivityDelivery",e.id,e),this.callbacks.onDeliverActivity?.(e),this.currentDeliveredActivity=e,this.pendingDelivery=null,e.isActive=!0):this.loggingService.info("Skipping delivery - activity already delivered: "+e.id)}unloadActivity(e){this.loggingService.info(`Unloading activity: ${e.id} - ${e.title}`),this.eventService.processListeners("ActivityUnload",e.id,e),this.callbacks.onUnloadActivity?.(e),e.isActive=!1}getCurrentDeliveredActivity(){return this.currentDeliveredActivity}getPendingDelivery(){return this.pendingDelivery}updateCallbacks(e){this.callbacks={...this.callbacks,...e}}reset(){this.currentDeliveredActivity&&this.unloadActivity(this.currentDeliveredActivity),this.currentDeliveredActivity=null,this.pendingDelivery=null}}var bt=Object.defineProperty,yt=(e,t,i)=>((e,t,i)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ct{constructor(e,t){yt(this,"settings"),yt(this,"error_codes"),this.settings=e,this.error_codes=t}processHttpRequest(e,t){return this._performAsyncRequest(e,t,arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3?arguments[3]:void 0,arguments.length>4?arguments[4]:void 0),{result:f,errorCode:0}}async _performAsyncRequest(e,t,i,s,r){try{const s=this.settings.requestHandler(t);let n;n=i&&"never"!==this.settings.asyncModeBeaconBehavior?await this.performBeacon(e,s):await this.performFetch(e,s);const result=await this.transformResponse(n,r);this._isSuccessResponse(n,result)?r("CommitSuccess"):r("CommitError",void 0,result.errorCode)}catch(e){s("processHttpRequest","Async request failed: "+(e instanceof Error?e.message:e+""),B.ERROR),r("CommitError")}}_prepareRequestBody(e){return{body:e instanceof Array?e.join("&"):JSON.stringify(e),contentType:e instanceof Array?"application/x-www-form-urlencoded":this.settings.commitRequestDataType}}async performFetch(e,t){if("always"===this.settings.asyncModeBeaconBehavior)return this.performBeacon(e,t);const{body:i,contentType:s}=this._prepareRequestBody(t),r={method:"POST",mode:this.settings.fetchMode,body:i,headers:{...this.settings.xhrHeaders,"Content-Type":s},keepalive:!0};return this.settings.xhrWithCredentials&&(r.credentials="include"),fetch(e,r)}async performBeacon(e,t){const{body:i,contentType:s}=this._prepareRequestBody(t),r=navigator.sendBeacon(e,new Blob([i],{type:s}));return Promise.resolve({status:r?200:0,ok:r,json:async()=>({result:r?"true":"false",errorCode:r?0:this.error_codes.GENERAL_COMMIT_FAILURE||391}),text:async()=>JSON.stringify({result:r?"true":"false",errorCode:r?0:this.error_codes.GENERAL_COMMIT_FAILURE||391})})}async transformResponse(e,t){let result;try{result="function"==typeof this.settings.responseHandler?await this.settings.responseHandler(e):await e.json()}catch(t){const i=await e.text().catch(()=>"Unable to read response text");return{result:S,errorCode:this.error_codes.GENERAL_COMMIT_FAILURE||391,errorMessage:"Failed to parse LMS response: "+(t instanceof Error?t.message:t+""),errorDetails:JSON.stringify({status:e.status,statusText:e.statusText,url:e.url,responseText:i.substring(0,500),parseError:t instanceof Error?t.message:t+""})}}return Object.hasOwnProperty.call(result,"errorCode")||(result.errorCode=this._isSuccessResponse(e,result)?0:this.error_codes.GENERAL_COMMIT_FAILURE||391),this._isSuccessResponse(e,result)||(result.errorDetails={status:e.status,statusText:e.statusText,url:e.url,...result.errorDetails}),result}_isSuccessResponse(e,result){const t=result.result;return!(200>e.status||e.status>299||!0!==t&&"true"!==t&&t!==f)}updateSettings(e){this.settings=e}}var At=Object.defineProperty;const Et="{target=";function wt(e,t){const i=e[t];return void 0===i?(void 0!==console&&console.warn&&console.warn("CMIValueAccessService: Unknown error code key: "+t),e.GENERAL??0):i}class Mt{constructor(e){var t;((e,t,i)=>{t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(this,"context"+"",t),this.context=e}getUndefinedDataModelErrorCode(e){return wt(this.context.errorCodes,e?"UNDEFINED_DATA_MODEL":"GENERAL")}setCMIValue(e,t,i,s){if(!i||""===i)return t&&this.context.throwSCORMError(i,wt(this.context.errorCodes,"GENERAL_SET_FAILURE"),"The data model element was not specified"),S;this.context.setLastErrorCode("0");const r=i.split(".");let n=this.context.getDataModel(),o=S,a=!1;const c=`The data model element passed to ${e} (${i}) is not a valid SCORM data model element.`,l=this.getUndefinedDataModelErrorCode(t);for(let e=0;r.length>e;e++){if(e===r.length-1){o=this.setFinalAttribute(n,r[e],s,i,t,l,c);break}{const o=this.traverseToNextLevel(n,r,e,s,i,t,a,l,c);if(o.error)break;n=o.refObject,e=o.idx,a=o.foundFirstIndex}}return o===S&&this.context.apiLog(e,`There was an error setting the value for: ${i}, value of: ${s}`,B.WARN),o}getCMIValue(e,t,i){if(!i||""===i)return t&&this.context.throwSCORMError(i,wt(this.context.errorCodes,"GENERAL_GET_FAILURE"),"The data model element was not specified"),"";if(t&&i.endsWith("._version")&&"cmi._version"!==i)return this.context.throwSCORMError(i,wt(this.context.errorCodes,"GENERAL_GET_FAILURE"),"The _version keyword was used incorrectly"),"";const s=i.split(".");let r=this.context.getDataModel(),n=null;const o=`The data model element passed to ${e} (${i}) has not been initialized.`,a=`The data model element passed to ${e} (${i}) is not a valid SCORM data model element.`,c=this.getUndefinedDataModelErrorCode(t);for(let e=0;s.length>e;e++){n=s[e];const l=this.validateGetAttribute(r,n,i,t,c,a,e===s.length-1);if(void 0!==l.returnValue)return l.returnValue;if(l.error)return"";if(null==n){this.context.throwSCORMError(i,c,a);break}if(r=r[n],void 0===r){this.context.throwSCORMError(i,c,a);break}if(r instanceof x){const t=this.handleGetArrayAccess(r,s,e,i,o);if(t.error)return"";r=t.refObject,e=t.idx}}return null==r?(t||("_children"===n?this.context.throwSCORMError(i,wt(this.context.errorCodes,"CHILDREN_ERROR"),void 0):"_count"===n&&this.context.throwSCORMError(i,wt(this.context.errorCodes,"COUNT_ERROR"),void 0)),""):r}setFinalAttribute(e,t,i,s,r,n,o){return r&&t?.startsWith(Et)?this.context.isInitialized()?(this.context.throwSCORMError(s,wt(this.context.errorCodes,"READ_ONLY_ELEMENT")),S):f:void 0!==t&&this.context.checkObjectHasProperty(e,t)?c(s,"\\.correct_responses\\.\\d+$")&&this.context.isInitialized()&&"pattern"!==t&&(this.context.validateCorrectResponse(s,i),"0"!==this.context.getLastErrorCode())?(this.context.throwSCORMError(s,wt(this.context.errorCodes,"TYPE_MISMATCH")),S):r&&"0"!==this.context.getLastErrorCode()?S:void 0===t||"__proto__"===t||"constructor"===t?(this.context.throwSCORMError(s,n,o),S):r&&"id"===t&&this.context.isInitialized()&&this.context.checkForDuplicateId(s,i)?(this.context.throwSCORMError(s,wt(this.context.errorCodes,"GENERAL_SET_FAILURE")),S):(e[t]=i,f):(this.context.throwSCORMError(s,n,o),S)}traverseToNextLevel(e,t,i,s,r,n,o,a,c){const l=t[i];if(void 0===l||!this.context.checkObjectHasProperty(e,l))return this.context.throwSCORMError(r,a,c),{refObject:e,idx:i,foundFirstIndex:o,error:!0};if(!(e=e[l]))return this.context.throwSCORMError(r,a,c),{refObject:e,idx:i,foundFirstIndex:o,error:!0};if(e instanceof x){const l=this.handleSetArrayAccess(e,t,i,s,r,n,o,a,c);return l.error?{refObject:e,idx:i,foundFirstIndex:o,error:!0}:l}return{refObject:e,idx:i,foundFirstIndex:o,error:!1}}handleSetArrayAccess(e,t,i,s,r,n,o,a,c){const l=parseInt(t[i+1]||"0",10);if(!isNaN(l)){const t=e.childArray[l];if(t)return{refObject:t,idx:i+1,foundFirstIndex:!0,error:!1};{if(l>e.childArray.length){const t=n?wt(this.context.errorCodes,"GENERAL_SET_FAILURE"):wt(this.context.errorCodes,"INVALID_SET_VALUE")||wt(this.context.errorCodes,"GENERAL_SET_FAILURE");return this.context.throwSCORMError(r,t,`Cannot set array element at index ${l}. Array indices must be sequential. Current array length is ${e.childArray.length}, expected index ${e.childArray.length}.`),{refObject:e,idx:i,foundFirstIndex:o,error:!0}}const t=this.context.getChildElement(r,s,o);return t?(e.initialized&&t.initialize(),e.childArray[l]=t,{refObject:t,idx:i+1,foundFirstIndex:!0,error:!1}):("0"===this.context.getLastErrorCode()&&this.context.throwSCORMError(r,a,c),{refObject:e,idx:i,foundFirstIndex:o,error:!0})}}return{refObject:e,idx:i,foundFirstIndex:o,error:!1}}validateGetAttribute(e,t,i,s,r,n,o){if(s){const s=t+"";if(s.startsWith(Et)&&"function"==typeof e._isTargetValid){const t=s.substring(8,s.length-1);return{error:!1,returnValue:e._isTargetValid(t)}}if(void 0===t||!this.context.checkObjectHasProperty(e,t))return"_children"===t?(this.context.throwSCORMError(i,wt(this.context.errorCodes,"GENERAL_GET_FAILURE"),"The data model element does not have children"),{error:!0}):"_count"===t?(this.context.throwSCORMError(i,wt(this.context.errorCodes,"GENERAL_GET_FAILURE"),"The data model element is not a collection and therefore does not have a count"),{error:!0}):(this.context.throwSCORMError(i,r,n),{error:!0})}else if(o&&(void 0===t||!this.context.checkObjectHasProperty(e,t)))return"_children"===t?this.context.throwSCORMError(i,wt(this.context.errorCodes,"CHILDREN_ERROR")):"_count"===t?this.context.throwSCORMError(i,wt(this.context.errorCodes,"COUNT_ERROR")):this.context.throwSCORMError(i,r,n),{error:!0};return{error:!1}}handleGetArrayAccess(e,t,i,s,r){const n=parseInt(t[i+1]||"",10);if(!isNaN(n)){const t=e.childArray[n];return t?{refObject:t,idx:i+1,error:!1}:(this.context.throwSCORMError(s,wt(this.context.errorCodes,"VALUE_NOT_INITIALIZED"),r),{refObject:e,idx:i,error:!0})}return{refObject:e,idx:i,error:!1}}}var Ot=Object.defineProperty,Rt=(e,t,i)=>((e,t,i)=>t in e?Ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);const Tt=class e{constructor(){Rt(this,"_logLevel",B.ERROR),Rt(this,"_logHandler"),this._logHandler=$}static getInstance(){return e._instance||(e._instance=new e),e._instance}setLogLevel(e){this._logLevel=e}getLogLevel(){return this._logLevel}setLogHandler(e){this._logHandler=e}log(e,t){this.shouldLog(e)&&this._logHandler(e,t)}error(e){this.log(B.ERROR,e)}warn(e){this.log(B.WARN,e)}info(e){this.log(B.INFO,e)}debug(e){this.log(B.DEBUG,e)}shouldLog(e){return this.getNumericLevel(e)>=this.getNumericLevel(this._logLevel)}getNumericLevel(e){if(void 0===e)return B.NONE;if("number"==typeof e)return e;switch("string"==typeof e?e.toUpperCase():e){case"1":case"DEBUG":return B.DEBUG;case"2":case"INFO":return B.INFO;case"3":case"WARN":return B.WARN;case"4":case"ERROR":default:return B.ERROR;case"5":case"NONE":return B.NONE}}};Rt(Tt,"_instance");let jt=Tt;function It(){return jt.getInstance()}var Nt=Object.defineProperty,xt=(e,t,i)=>((e,t,i)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class qt{constructor(e,t,i,s){xt(this,"_lastErrorCode","0"),xt(this,"_lastDiagnostic",""),xt(this,"_errorCodes"),xt(this,"_apiLog"),xt(this,"_getLmsErrorMessageDetails"),xt(this,"_loggingService"),this._errorCodes=e,this._apiLog=t,this._getLmsErrorMessageDetails=i,this._loggingService=s||It()}get lastErrorCode(){return this._lastErrorCode}set lastErrorCode(e){this._lastErrorCode=e}get lastDiagnostic(){return this._lastDiagnostic}throwSCORMError(e,t,i){this._lastDiagnostic=i||"",i||(i=this._getLmsErrorMessageDetails(t,!0));const s=`SCORM Error ${t}: ${i}${e?` [Element: ${e}]`:""}`;this._apiLog("throwSCORMError",t+": "+i,B.ERROR,e),this._loggingService.error(s),this._lastErrorCode=t+""}clearSCORMError(e){void 0!==e&&e!==S&&(this._lastErrorCode="0")}handleValueAccessException(e,t,i){if(t instanceof g){const s=t;this._lastErrorCode=s.errorCode+"",this._lastDiagnostic="",this._loggingService.warn(`Validation Error ${s.errorCode}: ${s.message} [Element: ${e}]`),i=S}else if(t instanceof Error){const s=t.constructor.name;this._loggingService.error(`${s}: ${t.message} [Element: ${e}]\n${t.stack||""}`),this.throwSCORMError(e,this._errorCodes.GENERAL,`${s}: ${t.message}`),i=S}else{this._loggingService.error(`Unknown error occurred while accessing [Element: ${e}]`);try{const e=JSON.stringify(t);this._loggingService.error("Error details: "+e)}catch(e){this._loggingService.error("Could not stringify error object for details")}this.throwSCORMError(e,this._errorCodes.GENERAL,"Unknown error"),i=S}return i}get errorCodes(){return this._errorCodes}}var Dt=Object.defineProperty,Lt=(e,t,i)=>((e,t,i)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Pt{constructor(e){Lt(this,"listenerMap",new Map),Lt(this,"listenerCount",0),Lt(this,"apiLog"),this.apiLog=e}parseListenerName(e){if(!e)return null;const t=e.split("."),i=t[0];let s=null;return t.length>1&&(s=e.replace(i+".","")),{functionName:i??e,CMIElement:s}}on(e,t){if(!t)return;const i=e.split(" ");for(const e of i){const i=this.parseListenerName(e);if(!i)continue;const{functionName:s,CMIElement:r}=i,n=this.listenerMap.get(s)??[];n.push({functionName:s,CMIElement:r,callback:t}),this.listenerMap.set(s,n),this.listenerCount++,this.apiLog("on","Added event listener: "+this.listenerCount,B.INFO,s)}}off(e,t){if(!t)return;const i=e.split(" ");for(const e of i){const i=this.parseListenerName(e);if(!i)continue;const{functionName:s,CMIElement:r}=i,n=this.listenerMap.get(s);if(!n)continue;const o=n.findIndex(e=>e.CMIElement===r&&e.callback===t);-1!==o&&(n.splice(o,1),this.listenerCount--,0===n.length&&this.listenerMap.delete(s),this.apiLog("off","Removed event listener: "+this.listenerCount,B.INFO,s))}}clear(e){const t=e.split(" ");for(const e of t){const t=this.parseListenerName(e);if(!t)continue;const{functionName:i,CMIElement:s}=t;if(this.listenerMap.has(i)){const e=this.listenerMap.get(i),t=null===s?[]:e.filter(e=>e.CMIElement!==s);this.listenerCount-=e.length-t.length,0===t.length?this.listenerMap.delete(i):this.listenerMap.set(i,t)}}}processListeners(e,t,i){this.apiLog(e,i,B.INFO,t);const s=this.listenerMap.get(e);if(s)for(const r of s){const s=!!r.CMIElement;let n=!1;if(t&&r.CMIElement)if(r.CMIElement.endsWith("*")){const e=r.CMIElement.slice(0,-1);n=t.startsWith(e)}else n=r.CMIElement===t;s&&!n||(this.apiLog("processListeners","Processing listener: "+r.functionName,B.DEBUG,t),e.startsWith("Sequence")||"CommitError"===e?r.callback(i):"CommitSuccess"===e?r.callback():r.callback(t,i))}}reset(){this.listenerMap.clear(),this.listenerCount=0}}var zt=Object.defineProperty,Ft=(e,t,i)=>((e,t,i)=>t in e?zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class kt{constructor(e,t,i){Ft(this,"apiLog",i),Ft(this,"settings"),Ft(this,"error_codes"),Ft(this,"storeName","scorm_again_offline_data"),Ft(this,"syncQueue","scorm_again_sync_queue"),Ft(this,"isOnline",navigator.onLine),Ft(this,"syncInProgress",!1),Ft(this,"boundOnlineStatusChangeHandler"),Ft(this,"boundCustomNetworkStatusHandler"),this.settings=e,this.error_codes=t,this.boundOnlineStatusChangeHandler=this.handleOnlineStatusChange.bind(this),this.boundCustomNetworkStatusHandler=this.handleCustomNetworkStatus.bind(this),window.addEventListener("online",this.boundOnlineStatusChangeHandler),window.addEventListener("offline",this.boundOnlineStatusChangeHandler),window.addEventListener("scorm-again:network-status",this.boundCustomNetworkStatusHandler)}handleOnlineStatusChange(){const e=this.isOnline;this.isOnline=navigator.onLine,!e&&this.isOnline?(this.apiLog("OfflineStorageService","Device is back online, attempting to sync...",B.INFO),this.syncOfflineData().then(e=>{e?this.apiLog("OfflineStorageService","Sync completed successfully",B.INFO):this.apiLog("OfflineStorageService","Sync failed",B.ERROR)},e=>{this.apiLog("OfflineStorageService","Error during sync: "+e,B.ERROR)})):e&&!this.isOnline&&this.apiLog("OfflineStorageService","Device is offline, data will be stored locally",B.INFO)}handleCustomNetworkStatus(e){if(!(e instanceof CustomEvent))return void this.apiLog("OfflineStorageService","Invalid network status event received",B.WARN);const{online:t}=e.detail;if("boolean"!=typeof t)return void this.apiLog("OfflineStorageService","Invalid online status value in custom event",B.WARN);const i=this.isOnline;this.isOnline=t,this.apiLog("OfflineStorageService","Network status updated via custom event: "+(t?"online":"offline"),B.INFO),!i&&this.isOnline?(this.apiLog("OfflineStorageService","Device is back online, attempting to sync...",B.INFO),this.syncOfflineData().then(e=>{e?this.apiLog("OfflineStorageService","Sync completed successfully",B.INFO):this.apiLog("OfflineStorageService","Sync failed",B.ERROR)},e=>{this.apiLog("OfflineStorageService","Error during sync: "+e,B.ERROR)})):i&&!this.isOnline&&this.apiLog("OfflineStorageService","Device is offline, data will be stored locally",B.INFO)}storeOffline(e,t){try{const i={id:`${e}_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,courseId:e,timestamp:Date.now(),data:t,syncAttempts:0},s=this.getFromStorage(this.syncQueue)||[];return s.push(i),this.saveToStorage(this.syncQueue,s),this.saveToStorage(`${this.storeName}_${e}`,t),this.apiLog("OfflineStorageService","Stored data offline for course "+e,B.INFO),{result:f,errorCode:0}}catch(t){const i=(t instanceof Error?t.message:t+"").includes("storage quota");return this.apiLog("OfflineStorageService",i?"storage quota exceeded - cannot store offline data for course "+e:"Error storing offline data: "+t,B.ERROR),{result:S,errorCode:this.error_codes.GENERAL??0}}}async getOfflineData(e){try{return this.getFromStorage(`${this.storeName}_${e}`)||null}catch(e){return this.apiLog("OfflineStorageService","Error retrieving offline data: "+e,B.ERROR),null}}async syncOfflineData(){if(this.syncInProgress||!this.isOnline)return!1;this.syncInProgress=!0;try{const e=this.getFromStorage(this.syncQueue)||[];if(0===e.length)return this.syncInProgress=!1,!0;this.apiLog("OfflineStorageService",`Found ${e.length} items to sync`,B.INFO);const t=[];for(const i of e){const e=this.settings.maxSyncAttempts??5;if(e>i.syncAttempts)try{const e=await this.sendDataToLMS(i.data);!0===e.result||e.result===f?this.apiLog("OfflineStorageService","Successfully synced item "+i.id,B.INFO):(i.syncAttempts++,t.push(i),this.apiLog("OfflineStorageService",`Failed to sync item ${i.id}, attempt #${i.syncAttempts}`,B.WARN))}catch(e){i.syncAttempts++,t.push(i),this.apiLog("OfflineStorageService",`Error syncing item ${i.id}: ${e}`,B.ERROR)}else this.apiLog("OfflineStorageService",`Removing abandoned item ${i.id} after ${e} failed sync attempts`,B.WARN)}return this.saveToStorage(this.syncQueue,t),this.apiLog("OfflineStorageService",`Sync completed. ${e.length-t.length} items synced, ${t.length} items remaining`,B.INFO),this.syncInProgress=!1,!0}catch(e){return this.apiLog("OfflineStorageService","Error during sync process: "+e,B.ERROR),this.syncInProgress=!1,!1}}async sendDataToLMS(e){if(!this.settings.lmsCommitUrl)return{result:S,errorCode:this.error_codes.GENERAL||101};try{const t=this.settings.requestHandler(e),i={method:"POST",mode:this.settings.fetchMode,body:JSON.stringify(t),headers:{...this.settings.xhrHeaders,"Content-Type":this.settings.commitRequestDataType}};this.settings.xhrWithCredentials&&(i.credentials="include");const s=await fetch(this.settings.lmsCommitUrl,i),result="function"==typeof this.settings.responseHandler?await this.settings.responseHandler(s):await s.json();return 200>s.status||s.status>299||!0!==result.result&&result.result!==f?(Object.hasOwnProperty.call(result,"errorCode")||(result.errorCode=this.error_codes.GENERAL),result):(Object.hasOwnProperty.call(result,"errorCode")||(result.errorCode=0),result)}catch(e){return this.apiLog("OfflineStorageService","Error sending data to LMS: "+e,B.ERROR),{result:S,errorCode:this.error_codes.GENERAL||101}}}isDeviceOnline(){return this.isOnline}getFromStorage(e){const t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(e){return null}return null}saveToStorage(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){if(e instanceof DOMException&&"QuotaExceededError"===e.name)throw Error("storage quota exceeded - localStorage is full",{cause:e});throw e}}async hasPendingOfflineData(e){return(this.getFromStorage(this.syncQueue)||[]).some(t=>t.courseId===e)}updateSettings(e){this.settings=e}destroy(){window.removeEventListener("online",this.boundOnlineStatusChangeHandler),window.removeEventListener("offline",this.boundOnlineStatusChangeHandler),window.removeEventListener("scorm-again:network-status",this.boundCustomNetworkStatusHandler)}}const Vt=l((e,t,i,s,r,n)=>{if("string"!=typeof t)return!1;const o=RegExp(i),a=t.match(o);if(n&&""===t)return!0;if(!a||""===a[0])throw new r(e,s);return!0},(e,t,i,s,r,n)=>`${e}:${"string"==typeof t?t:`[${typeof t}]`}:${i}:${s}:${n||!1}`),Ht=l((e,t,i,s,r)=>{const n=i.split("#");if(isNaN(t=+t))throw new r(e,s);const o=n[0],a=n[1],c=void 0!==a&&""!==a&&"*"!==a;if(void 0!==o&&""!==o&&+o>t)throw new r(e,s);if(c&&t>+a)throw new r(e,s);return!0},(e,t,i,s,r)=>`${e}:${t}:${i}:${s}`);function Bt(e,t,i,s){return Vt(e,t,i,j.TYPE_MISMATCH,O,s)}function Ut(e,t,i){return Ht(e,t,i,j.VALUE_OUT_OF_RANGE,O)}var $t=Object.defineProperty,Gt=(e,t,i)=>((e,t,i)=>t in e?$t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),Yt=(e=>(e.SATISFIED="satisfied",e.NOT_SATISFIED="notSatisfied",e.COMPLETED="completed",e.INCOMPLETE="incomplete",e))(Yt||{}),Wt=(e=>(e.ALL="all",e.ANY="any",e.NONE="none",e.AT_LEAST_COUNT="atLeastCount",e.AT_LEAST_PERCENT="atLeastPercent",e))(Wt||{});class Jt extends d{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"always",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Map;super("rollupCondition"),Gt(this,"_condition","always"),Gt(this,"_parameters",new Map),this._condition=e,this._parameters=t}reset(){this._initialized=!1}get condition(){return this._condition}set condition(e){this._condition=e}get parameters(){return this._parameters}set parameters(e){this._parameters=e}evaluate(e){switch(this._condition){case"satisfied":return!0===e.objectiveSatisfiedStatus||e.successStatus===P;case"objectiveStatusKnown":return e.objectiveSatisfiedStatusKnown;case"objectiveMeasureKnown":return e.objectiveMeasureStatus;case"objectiveMeasureGreaterThan":{const t=this._parameters.get("threshold")||0;return e.objectiveMeasureStatus&&e.objectiveNormalizedMeasure>t}case"objectiveMeasureLessThan":{const t=this._parameters.get("threshold")||0;return e.objectiveMeasureStatus&&t>e.objectiveNormalizedMeasure}case"completed":return e.isCompleted;case"progressKnown":return e.completionStatus!==H;case"attempted":return e.attemptCount>0;case"notAttempted":return 0===e.attemptCount;case"always":return!0;default:return!1}}toJSON(){this.jsonString=!0;const result={condition:this._condition,parameters:Object.fromEntries(this._parameters)};return this.jsonString=!1,result}}class Kt extends d{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"satisfied",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;super("rollupRule"),Gt(this,"_conditions",[]),Gt(this,"_action","satisfied"),Gt(this,"_consideration","all"),Gt(this,"_minimumCount",0),Gt(this,"_minimumPercent",0),this._action=e,this._consideration=t,this._minimumCount=i,this._minimumPercent=s}reset(){this._initialized=!1,this._conditions=[]}get conditions(){return this._conditions}addCondition(e){if(!(e instanceof Jt))throw new O(this._cmi_element+".conditions",j.TYPE_MISMATCH);this._conditions.push(e)}removeCondition(e){const t=this._conditions.indexOf(e);return-1!==t&&(this._conditions.splice(t,1),!0)}get action(){return this._action}set action(e){this._action=e}get consideration(){return this._consideration}set consideration(e){this._consideration=e}get minimumCount(){return this._minimumCount}set minimumCount(e){0>e||(this._minimumCount=e)}get minimumPercent(){return this._minimumPercent}set minimumPercent(e){0>e||e>100||(this._minimumPercent=e)}evaluate(e){if(0===e.length)return!1;const t=e.filter(e=>this._conditions.every(t=>t.evaluate(e)));switch(this._consideration){case"all":return t.length===e.length;case"any":return t.length>0;case"none":return 0===t.length;case"atLeastCount":return t.length>=this._minimumCount;case"atLeastPercent":return t.length/e.length*100>=this._minimumPercent;default:return!1}}toJSON(){this.jsonString=!0;const result={conditions:this._conditions,action:this._action,consideration:this._consideration,minimumCount:this._minimumCount,minimumPercent:this._minimumPercent};return this.jsonString=!1,result}}class Xt extends d{constructor(){super("rollupRules"),Gt(this,"_rules",[])}reset(){this._initialized=!1,this._rules=[]}get rules(){return this._rules}addRule(e){if(!(e instanceof Kt))throw new O(this._cmi_element+".rules",j.TYPE_MISMATCH);this._rules.push(e)}removeRule(e){const t=this._rules.indexOf(e);return-1!==t&&(this._rules.splice(t,1),!0)}processRollup(e){if(!e||0===e.children.length)return;const t=e.getAvailableChildren();let i=!1,s=!1;if(e.sequencingControls.rollupObjectiveSatisfied&&null!==this._objectiveRollupUsingMeasure(e,t)&&(s=!0),!s)for(const r of this._rules)if(r.evaluate(t))switch(r.action){case"satisfied":e.successStatus=P,s=!0;break;case"notSatisfied":e.successStatus=z,s=!0;break;case"completed":e.completionStatus=k,e.isCompleted=!0,i=!0;break;case"incomplete":e.completionStatus=V,e.isCompleted=!1,i=!0}i||this._defaultCompletionRollup(e,t),s||this._defaultSuccessRollup(e,t)}_defaultCompletionRollup(e,t){t.every(e=>e.isCompleted)?(e.completionStatus=k,e.isCompleted=!0):t.some(e=>e.completionStatus===V)&&(e.completionStatus=V,e.isCompleted=!1)}_objectiveRollupUsingMeasure(e,t){if(0>=e.sequencingControls.objectiveMeasureWeight)return null;let i=0,s=0,r=!1;for(const e of t)if(e.sequencingControls.rollupObjectiveSatisfied&&e.objectiveMeasureStatus&&!0===e.objectiveMeasureStatus){const t=e.sequencingControls.objectiveMeasureWeight;t>0&&(s+=e.objectiveNormalizedMeasure*t,i+=t,r=!0)}if(!r||0===i)return null;const n=s/i;return e.objectiveNormalizedMeasure=n,e.objectiveMeasureStatus=!0,e.scaledPassingScore>n?(e.successStatus=z,e.objectiveSatisfiedStatus=!1,!1):(e.successStatus=P,e.objectiveSatisfiedStatus=!0,!0)}_defaultSuccessRollup(e,t){t.every(e=>e.successStatus===P)?e.successStatus=P:t.some(e=>e.successStatus===z)&&(e.successStatus=z)}toJSON(){this.jsonString=!0;const result={rules:this._rules};return this.jsonString=!1,result}}var Qt=Object.defineProperty,Zt=(e,t,i)=>((e,t,i)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ei{constructor(id){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Zt(this,"_id"),Zt(this,"_description"),Zt(this,"_satisfiedByMeasure"),Zt(this,"_minNormalizedMeasure"),Zt(this,"_mapInfo"),Zt(this,"_isPrimary"),Zt(this,"_satisfiedStatus",!1),Zt(this,"_satisfiedStatusKnown",!1),Zt(this,"_measureStatus",!1),Zt(this,"_normalizedMeasure",0),Zt(this,"_progressMeasure",0),Zt(this,"_progressMeasureStatus",!1),Zt(this,"_completionStatus",H),Zt(this,"_progressStatus",!1),Zt(this,"_satisfiedStatusDirty",!1),Zt(this,"_normalizedMeasureDirty",!1),Zt(this,"_completionStatusDirty",!1),Zt(this,"_progressMeasureDirty",!1),this._id=id,this._description=e.description??null,this._satisfiedByMeasure=e.satisfiedByMeasure??!1,this._minNormalizedMeasure=e.minNormalizedMeasure??null,this._mapInfo=e.mapInfo?[...e.mapInfo]:[],this._isPrimary=e.isPrimary??!1}get id(){return this._id}get description(){return this._description}get satisfiedByMeasure(){return this._satisfiedByMeasure}set satisfiedByMeasure(e){this._satisfiedByMeasure=e}get minNormalizedMeasure(){return this._minNormalizedMeasure}set minNormalizedMeasure(e){this._minNormalizedMeasure=e}get mapInfo(){return this._mapInfo}set mapInfo(e){this._mapInfo=[...e]}get isPrimary(){return this._isPrimary}set isPrimary(e){this._isPrimary=e}get satisfiedStatus(){return this._satisfiedStatus}set satisfiedStatus(e){this._satisfiedStatus!==e&&(this._satisfiedStatus=e,this._satisfiedStatusDirty=!0)}get satisfiedStatusKnown(){return this._satisfiedStatusKnown}set satisfiedStatusKnown(e){this._satisfiedStatusKnown=e}get measureStatus(){return this._measureStatus}set measureStatus(e){this._measureStatus=e}get normalizedMeasure(){return this._normalizedMeasure}set normalizedMeasure(e){this._normalizedMeasure!==e&&(this._normalizedMeasure=e,this._normalizedMeasureDirty=!0)}get progressMeasure(){return this._progressMeasure}set progressMeasure(e){this._progressMeasure!==e&&(this._progressMeasure=e,this._progressMeasureDirty=!0)}get progressMeasureStatus(){return this._progressMeasureStatus}set progressMeasureStatus(e){this._progressMeasureStatus=e}get completionStatus(){return this._completionStatus}set completionStatus(e){this._completionStatus!==e&&(this._completionStatus=e,this._completionStatusDirty=!0)}get progressStatus(){return this._progressStatus}set progressStatus(e){this._progressStatus=e}isDirty(e){switch(e){case"satisfiedStatus":return this._satisfiedStatusDirty;case"normalizedMeasure":return this._normalizedMeasureDirty;case"completionStatus":return this._completionStatusDirty;case"progressMeasure":return this._progressMeasureDirty}}clearDirty(e){switch(e){case"satisfiedStatus":this._satisfiedStatusDirty=!1;break;case"normalizedMeasure":this._normalizedMeasureDirty=!1;break;case"completionStatus":this._completionStatusDirty=!1;break;case"progressMeasure":this._progressMeasureDirty=!1}}clearAllDirty(){this._satisfiedStatusDirty=!1,this._normalizedMeasureDirty=!1,this._completionStatusDirty=!1,this._progressMeasureDirty=!1}initializeFromCMI(e,t,i){this._satisfiedStatus=e,this._satisfiedStatusDirty=!0,this._normalizedMeasure=t,this._normalizedMeasureDirty=!0,this._measureStatus=i}resetState(){this._satisfiedStatus=!1,this._satisfiedStatusKnown=!1,this._measureStatus=!1,this._normalizedMeasure=0,this._progressMeasure=0,this._progressMeasureStatus=!1,this._completionStatus=H,this._progressStatus=!1,this.clearAllDirty()}updateFromActivity(e){this._satisfiedStatus!==e.objectiveSatisfiedStatus&&(this._satisfiedStatus=e.objectiveSatisfiedStatus,this._satisfiedStatusDirty=!0),this._satisfiedStatusKnown=e.objectiveSatisfiedStatusKnown,this._measureStatus=e.objectiveMeasureStatus,this._normalizedMeasure!==e.objectiveNormalizedMeasure&&(this._normalizedMeasure=e.objectiveNormalizedMeasure,this._normalizedMeasureDirty=!0),this._progressMeasure!==e.progressMeasure&&(this._progressMeasure=e.progressMeasure,this._progressMeasureDirty=!0),this._progressMeasureStatus=e.progressMeasureStatus,this._completionStatus!==e.completionStatus&&(this._completionStatus=e.completionStatus,this._completionStatusDirty=!0)}applyToActivity(e){this._isPrimary&&e.setPrimaryObjectiveState(this._satisfiedStatus,this._measureStatus,this._normalizedMeasure,this._progressMeasure,this._progressMeasureStatus,this._completionStatus)}}class ti extends d{constructor(){let id=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";super("activity"),Zt(this,"_id",""),Zt(this,"_title",""),Zt(this,"_children",[]),Zt(this,"_parent",null),Zt(this,"_isVisible",!0),Zt(this,"_isActive",!1),Zt(this,"_isSuspended",!1),Zt(this,"_isCompleted",!1),Zt(this,"_completionStatus",H),Zt(this,"_successStatus",F),Zt(this,"_attemptCount",0),Zt(this,"_attemptCompletionAmount",0),Zt(this,"_attemptAbsoluteDuration","PT0H0M0S"),Zt(this,"_attemptExperiencedDuration","PT0H0M0S"),Zt(this,"_activityAbsoluteDuration","PT0H0M0S"),Zt(this,"_activityExperiencedDuration","PT0H0M0S"),Zt(this,"_attemptAbsoluteDurationValue","PT0H0M0S"),Zt(this,"_attemptExperiencedDurationValue","PT0H0M0S"),Zt(this,"_activityAbsoluteDurationValue","PT0H0M0S"),Zt(this,"_activityExperiencedDurationValue","PT0H0M0S"),Zt(this,"_activityStartTimestampUtc",null),Zt(this,"_attemptStartTimestampUtc",null),Zt(this,"_activityEndedDate",null),Zt(this,"_objectiveSatisfiedStatus",!1),Zt(this,"_objectiveSatisfiedStatusKnown",!1),Zt(this,"_objectiveMeasureStatus",!1),Zt(this,"_objectiveNormalizedMeasure",0),Zt(this,"_scaledPassingScore",.7),Zt(this,"_objectiveSatisfiedStatusDirty",!1),Zt(this,"_objectiveNormalizedMeasureDirty",!1),Zt(this,"_objectiveMeasureStatusDirty",!1),Zt(this,"_progressMeasure",0),Zt(this,"_progressMeasureStatus",!1),Zt(this,"_location",""),Zt(this,"_attemptAbsoluteStartTime",""),Zt(this,"_learnerPrefs",null),Zt(this,"_activityAttemptActive",!1),Zt(this,"_isHiddenFromChoice",!1),Zt(this,"_isAvailable",!0),Zt(this,"_hideLmsUi",[]),Zt(this,"_auxiliaryResources",[]),Zt(this,"_attemptLimit",null),Zt(this,"_attemptAbsoluteDurationLimit",null),Zt(this,"_activityAbsoluteDurationLimit",null),Zt(this,"_timeLimitAction",null),Zt(this,"_timeLimitDuration",null),Zt(this,"_beginTimeLimit",null),Zt(this,"_endTimeLimit",null),Zt(this,"_launchData",""),Zt(this,"_credit","credit"),Zt(this,"_maxTimeAllowed",""),Zt(this,"_completionThreshold",""),Zt(this,"_sequencingControls"),Zt(this,"_sequencingRules"),Zt(this,"_rollupRules"),Zt(this,"_processedChildren",null),Zt(this,"_isNewAttempt",!1),Zt(this,"_primaryObjective",null),Zt(this,"_objectives",[]),Zt(this,"_rollupConsiderations",{requiredForSatisfied:"always",requiredForNotSatisfied:"always",requiredForCompleted:"always",requiredForIncomplete:"always",measureSatisfactionIfActive:!0}),Zt(this,"_requiredForSatisfied","always"),Zt(this,"_requiredForNotSatisfied","always"),Zt(this,"_requiredForCompleted","always"),Zt(this,"_requiredForIncomplete","always"),Zt(this,"_wasSkipped",!1),Zt(this,"_attemptProgressStatus",!1),Zt(this,"_wasAutoCompleted",!1),Zt(this,"_wasAutoSatisfied",!1),Zt(this,"_completedByMeasure",!1),Zt(this,"_minProgressMeasure",1),Zt(this,"_progressWeight",1),Zt(this,"_attemptCompletionAmountStatus",!1),this._id=id,this._title=e,this._sequencingControls=new Xe,this._sequencingRules=new je,this._rollupRules=new Xt,this._primaryObjective=null,this._objectives=[]}initialize(){super.initialize();for(const e of this._children)e.initialize()}reset(){this._initialized=!1,this._isActive=!1,this._isSuspended=!1,this._isCompleted=!1,this._completionStatus=H,this._successStatus=F,this._attemptCount=0,this._attemptCompletionAmount=0,this._attemptAbsoluteDuration="PT0H0M0S",this._attemptExperiencedDuration="PT0H0M0S",this._activityAbsoluteDuration="PT0H0M0S",this._activityExperiencedDuration="PT0H0M0S",this._attemptAbsoluteDurationValue="PT0H0M0S",this._attemptExperiencedDurationValue="PT0H0M0S",this._activityAbsoluteDurationValue="PT0H0M0S",this._activityExperiencedDurationValue="PT0H0M0S",this._activityStartTimestampUtc=null,this._attemptStartTimestampUtc=null,this._activityEndedDate=null,this._objectiveSatisfiedStatus=!1,this._objectiveSatisfiedStatusKnown=!1,this._objectiveMeasureStatus=!1,this._objectiveNormalizedMeasure=0,this._progressMeasure=0,this._progressMeasureStatus=!1,this._location="",this._attemptAbsoluteStartTime="",this._learnerPrefs=null,this._activityAttemptActive=!1,this._primaryObjective&&(this._primaryObjective.resetState(),this._primaryObjective.updateFromActivity(this));for(const e of this._objectives)e.resetState();for(const e of this._children)e.reset();this._wasSkipped=!1,this._attemptProgressStatus=!1,this._wasAutoCompleted=!1,this._wasAutoSatisfied=!1,this._completedByMeasure=!1,this._minProgressMeasure=1,this._progressWeight=1,this._attemptCompletionAmountStatus=!1,this.clearAllObjectiveDirty()}get id(){return this._id}set id(id){Bt(this._cmi_element+".id",id,ce)&&(this._id=id)}get title(){return this._title}set title(e){Bt(this._cmi_element+".title",e,ie)&&(this._title=e)}get children(){return this._children}addChild(e){if(!(e instanceof ti))throw new O(this._cmi_element+".children",j.TYPE_MISMATCH);e._parent=this,this._children.push(e)}setChildOrder(e){if(0===e.length)return;const t=new Map(this._children.map(e=>[e.id,e])),i=[];for(const id of e){const e=t.get(id);e&&(i.push(e),t.delete(id))}if(t.size>0)for(const e of this._children)t.has(e.id)&&(i.push(e),t.delete(e.id));i.length===this._children.length&&this._children.splice(0,this._children.length,...i)}removeChild(e){const t=this._children.indexOf(e);return-1!==t&&(this._children.splice(t,1),e._parent=null,!0)}get parent(){return this._parent}get isVisible(){return this._isVisible}set isVisible(e){this._isVisible=e}get isActive(){return this._isActive}set isActive(e){this._isActive=e}get isSuspended(){return this._isSuspended}set isSuspended(e){this._isSuspended=e}get isCompleted(){return this._isCompleted}set isCompleted(e){this._isCompleted=e,this._completionStatus=e?k:V}get completionStatus(){return this._completionStatus}set completionStatus(e){this._completionStatus=e,this._isCompleted=e===k,this.updatePrimaryObjectiveFromActivity()}get successStatus(){return this._successStatus}set successStatus(e){this._successStatus=e}get attemptCount(){return this._attemptCount}set attemptCount(e){this._attemptCount=e}get attemptCompletionAmount(){return this._attemptCompletionAmount}set attemptCompletionAmount(e){this._attemptCompletionAmount=e}incrementAttemptCount(){this._attemptCount++,this._isNewAttempt=!0;const e=this._sequencingControls;"onEachNewAttempt"!==e.selectionTiming&&"onEachNewAttempt"!==e.randomizationTiming||(this._processedChildren=null)}get objectiveSatisfiedStatus(){return this._objectiveSatisfiedStatus}set objectiveSatisfiedStatus(e){this._objectiveSatisfiedStatus!==e&&(this._objectiveSatisfiedStatus=e,this._objectiveSatisfiedStatusDirty=!0),this._objectiveSatisfiedStatusKnown=!0,this._successStatus=e?P:z,this.updatePrimaryObjectiveFromActivity()}get objectiveSatisfiedStatusKnown(){return this._objectiveSatisfiedStatusKnown}set objectiveSatisfiedStatusKnown(e){this._objectiveSatisfiedStatusKnown=e}get objectiveMeasureStatus(){return this._objectiveMeasureStatus}set objectiveMeasureStatus(e){this._objectiveMeasureStatus!==e&&(this._objectiveMeasureStatus=e,this._objectiveMeasureStatusDirty=!0),this.updatePrimaryObjectiveFromActivity()}get objectiveNormalizedMeasure(){return this._objectiveNormalizedMeasure}set objectiveNormalizedMeasure(e){this._objectiveNormalizedMeasure!==e&&(this._objectiveNormalizedMeasure=e,this._objectiveNormalizedMeasureDirty=!0),this.updatePrimaryObjectiveFromActivity()}get scaledPassingScore(){return this._scaledPassingScore}set scaledPassingScore(e){-1>e||e>1||(this._scaledPassingScore=e)}get progressMeasure(){return this._progressMeasure}set progressMeasure(e){this._progressMeasure=e,this.updatePrimaryObjectiveFromActivity()}get progressMeasureStatus(){return this._progressMeasureStatus}set progressMeasureStatus(e){this._progressMeasureStatus=e,this.updatePrimaryObjectiveFromActivity()}get location(){return this._location}set location(location){this._location=location}get attemptAbsoluteStartTime(){return this._attemptAbsoluteStartTime}set attemptAbsoluteStartTime(e){this._attemptAbsoluteStartTime=e}get learnerPrefs(){return this._learnerPrefs}set learnerPrefs(e){this._learnerPrefs=e}get activityAttemptActive(){return this._activityAttemptActive}set activityAttemptActive(e){this._activityAttemptActive=e}get isHiddenFromChoice(){return this._isHiddenFromChoice}set isHiddenFromChoice(e){this._isHiddenFromChoice=e}get isAvailable(){return this._isAvailable}set isAvailable(e){this._isAvailable=e}get attemptLimit(){return this._attemptLimit}set attemptLimit(e){this._attemptLimit=e}hasAttemptLimitExceeded(){return null!==this._attemptLimit&&this._attemptCount>=this._attemptLimit}get timeLimitDuration(){return this._timeLimitDuration}set timeLimitDuration(e){this._timeLimitDuration=e}get timeLimitAction(){return this._timeLimitAction}set timeLimitAction(e){this._timeLimitAction=e}get beginTimeLimit(){return this._beginTimeLimit}set beginTimeLimit(e){this._beginTimeLimit=e}get endTimeLimit(){return this._endTimeLimit}set endTimeLimit(e){this._endTimeLimit=e}get attemptAbsoluteDurationLimit(){return this._attemptAbsoluteDurationLimit}set attemptAbsoluteDurationLimit(e){if(null!==e&&!n(e,ne))throw new O(this._cmi_element+".attemptAbsoluteDurationLimit",j.TYPE_MISMATCH);this._attemptAbsoluteDurationLimit=e}get attemptExperiencedDuration(){return this._attemptExperiencedDuration}set attemptExperiencedDuration(e){if(!n(e,ne))throw new O(this._cmi_element+".attemptExperiencedDuration",j.TYPE_MISMATCH);this._attemptExperiencedDuration=e}get activityAbsoluteDurationLimit(){return this._activityAbsoluteDurationLimit}set activityAbsoluteDurationLimit(e){if(null!==e&&!n(e,ne))throw new O(this._cmi_element+".activityAbsoluteDurationLimit",j.TYPE_MISMATCH);this._activityAbsoluteDurationLimit=e}get activityExperiencedDuration(){return this._activityExperiencedDuration}set activityExperiencedDuration(e){if(!n(e,ne))throw new O(this._cmi_element+".activityExperiencedDuration",j.TYPE_MISMATCH);this._activityExperiencedDuration=e}get attemptAbsoluteDuration(){return this._attemptAbsoluteDurationLimit||"PT0H0M0S"}set attemptAbsoluteDuration(e){this._attemptAbsoluteDurationLimit=e}get activityAbsoluteDuration(){return this._activityAbsoluteDurationLimit||"PT0H0M0S"}set activityAbsoluteDuration(e){this._activityAbsoluteDurationLimit=e}get attemptAbsoluteDurationValue(){return this._attemptAbsoluteDurationValue}set attemptAbsoluteDurationValue(e){if(!n(e,ne))throw new O(this._cmi_element+".attemptAbsoluteDurationValue",j.TYPE_MISMATCH);this._attemptAbsoluteDurationValue=e}get attemptExperiencedDurationValue(){return this._attemptExperiencedDurationValue}set attemptExperiencedDurationValue(e){if(!n(e,ne))throw new O(this._cmi_element+".attemptExperiencedDurationValue",j.TYPE_MISMATCH);this._attemptExperiencedDurationValue=e}get activityAbsoluteDurationValue(){return this._activityAbsoluteDurationValue}set activityAbsoluteDurationValue(e){if(!n(e,ne))throw new O(this._cmi_element+".activityAbsoluteDurationValue",j.TYPE_MISMATCH);this._activityAbsoluteDurationValue=e}get activityExperiencedDurationValue(){return this._activityExperiencedDurationValue}set activityExperiencedDurationValue(e){if(!n(e,ne))throw new O(this._cmi_element+".activityExperiencedDurationValue",j.TYPE_MISMATCH);this._activityExperiencedDurationValue=e}get activityStartTimestampUtc(){return this._activityStartTimestampUtc}set activityStartTimestampUtc(timestamp){this._activityStartTimestampUtc=timestamp}get attemptStartTimestampUtc(){return this._attemptStartTimestampUtc}set attemptStartTimestampUtc(timestamp){this._attemptStartTimestampUtc=timestamp}get activityEndedDate(){return this._activityEndedDate}set activityEndedDate(e){this._activityEndedDate=e}get sequencingControls(){return this._sequencingControls}set sequencingControls(e){this._sequencingControls=e}get sequencingRules(){return this._sequencingRules}set sequencingRules(e){this._sequencingRules=e}get rollupRules(){return this._rollupRules}set rollupRules(e){this._rollupRules=e}get rollupConsiderations(){return{...this._rollupConsiderations}}set rollupConsiderations(e){this._rollupConsiderations={...e}}applyRollupConsiderations(e){this._rollupConsiderations={...this._rollupConsiderations,...e}}get requiredForSatisfied(){return this._requiredForSatisfied}set requiredForSatisfied(e){this._requiredForSatisfied=e}get requiredForNotSatisfied(){return this._requiredForNotSatisfied}set requiredForNotSatisfied(e){this._requiredForNotSatisfied=e}get requiredForCompleted(){return this._requiredForCompleted}set requiredForCompleted(e){this._requiredForCompleted=e}get requiredForIncomplete(){return this._requiredForIncomplete}set requiredForIncomplete(e){this._requiredForIncomplete=e}get wasSkipped(){return this._wasSkipped}set wasSkipped(e){this._wasSkipped=e}get attemptProgressStatus(){return this._attemptProgressStatus}set attemptProgressStatus(e){this._attemptProgressStatus=e}get wasAutoCompleted(){return this._wasAutoCompleted}set wasAutoCompleted(e){this._wasAutoCompleted=e}get wasAutoSatisfied(){return this._wasAutoSatisfied}set wasAutoSatisfied(e){this._wasAutoSatisfied=e}get completedByMeasure(){return this._completedByMeasure}set completedByMeasure(e){this._completedByMeasure=e}get minProgressMeasure(){return this._minProgressMeasure}set minProgressMeasure(e){if(0>e||e>1)throw new O(this._cmi_element+".minProgressMeasure",j.TYPE_MISMATCH);this._minProgressMeasure=e}get progressWeight(){return this._progressWeight}set progressWeight(e){if(0>e)throw new O(this._cmi_element+".progressWeight",j.TYPE_MISMATCH);this._progressWeight=e}get attemptCompletionAmountStatus(){return this._attemptCompletionAmountStatus}set attemptCompletionAmountStatus(e){this._attemptCompletionAmountStatus=e}get primaryObjective(){return this._primaryObjective}set primaryObjective(e){this._primaryObjective=e,this._primaryObjective&&(this._primaryObjective.isPrimary=!0,null!==this._primaryObjective.minNormalizedMeasure&&(this._scaledPassingScore=this._primaryObjective.minNormalizedMeasure??this._scaledPassingScore),this._primaryObjective.updateFromActivity(this)),this.syncPrimaryObjectiveCollection()}get objectives(){return this._objectives.filter(e=>e.id!==this._primaryObjective?.id)}set objectives(objectives){this._objectives=[...objectives],this.syncPrimaryObjectiveCollection()}addObjective(e){this._objectives.find(t=>t.id===e.id)||this._objectives.push(e)}syncPrimaryObjectiveCollection(){if(!this._primaryObjective)return void(this._objectives=this._objectives.filter(e=>!e.isPrimary));const e=this._objectives.findIndex(e=>e.id===this._primaryObjective?.id);0>e?this._objectives=[this._primaryObjective,...this._objectives]:this._objectives[e]=this._primaryObjective}getObjectiveById(e){if(this._primaryObjective?.id===e)return{objective:this._primaryObjective,isPrimary:!0};const t=this._objectives.find(t=>t.id===e);return t?{objective:t,isPrimary:!1}:null}getAllObjectives(){const objectives=[];this._primaryObjective&&objectives.push(this._primaryObjective);const e=this._objectives.filter(e=>e!==this._primaryObjective&&e.id!==this._primaryObjective?.id);return objectives.concat(e)}updatePrimaryObjectiveFromActivity(){this._primaryObjective&&this._primaryObjective.updateFromActivity(this)}isObjectiveDirty(e){switch(e){case"satisfiedStatus":return this._objectiveSatisfiedStatusDirty;case"normalizedMeasure":return this._objectiveNormalizedMeasureDirty;case"measureStatus":return this._objectiveMeasureStatusDirty}}clearObjectiveDirty(e){switch(e){case"satisfiedStatus":this._objectiveSatisfiedStatusDirty=!1;break;case"normalizedMeasure":this._objectiveNormalizedMeasureDirty=!1;break;case"measureStatus":this._objectiveMeasureStatusDirty=!1}}clearAllObjectiveDirty(){this._objectiveSatisfiedStatusDirty=!1,this._objectiveNormalizedMeasureDirty=!1,this._objectiveMeasureStatusDirty=!1}setPrimaryObjectiveState(e,t,i,s,r,n){this._objectiveSatisfiedStatus!==e&&(this._objectiveSatisfiedStatus=e,this._objectiveSatisfiedStatusDirty=!0),this._objectiveSatisfiedStatusKnown=!0,this._objectiveMeasureStatus!==t&&(this._objectiveMeasureStatus=t,this._objectiveMeasureStatusDirty=!0),this._objectiveNormalizedMeasure!==i&&(this._objectiveNormalizedMeasure=i,this._objectiveNormalizedMeasureDirty=!0),this._progressMeasure=s,this._progressMeasureStatus=r,this._completionStatus=n,this._primaryObjective&&(this._primaryObjective.satisfiedStatus=e,this._primaryObjective.measureStatus=t,this._primaryObjective.normalizedMeasure=i,this._primaryObjective.progressMeasure=s,this._primaryObjective.progressMeasureStatus=r,this._primaryObjective.completionStatus=n)}getObjectiveStateSnapshot(){return{primary:this._primaryObjective?{id:this._primaryObjective.id,satisfiedStatus:this.objectiveSatisfiedStatus,measureStatus:this.objectiveMeasureStatus,normalizedMeasure:this.objectiveNormalizedMeasure,progressMeasure:this.progressMeasure??0,progressMeasureStatus:this.progressMeasureStatus,progressStatus:this._primaryObjective.progressStatus,completionStatus:this.completionStatus,satisfiedByMeasure:this._primaryObjective.satisfiedByMeasure,minNormalizedMeasure:this._primaryObjective.minNormalizedMeasure}:null,objectives:this._objectives.map(e=>({id:e.id,satisfiedStatus:e.satisfiedStatus,measureStatus:e.measureStatus,normalizedMeasure:e.normalizedMeasure,progressMeasure:e.progressMeasure,progressMeasureStatus:e.progressMeasureStatus,progressStatus:e.progressStatus,completionStatus:e.completionStatus,satisfiedByMeasure:e.satisfiedByMeasure,minNormalizedMeasure:e.minNormalizedMeasure}))}}applyObjectiveStateSnapshot(e){if(e.primary){const t=this.getObjectiveById(e.primary.id);if(t&&t.isPrimary){const i=e.primary;t.objective.satisfiedByMeasure=i.satisfiedByMeasure??t.objective.satisfiedByMeasure,t.objective.minNormalizedMeasure=void 0!==i.minNormalizedMeasure?i.minNormalizedMeasure:t.objective.minNormalizedMeasure,this.setPrimaryObjectiveState(i.satisfiedStatus,i.measureStatus,i.normalizedMeasure,i.progressMeasure,i.progressMeasureStatus,i.completionStatus)}}for(const t of e.objectives){const e=this.getObjectiveById(t.id);if(e&&!e.isPrimary){const i=e.objective;i.satisfiedStatus=t.satisfiedStatus,i.measureStatus=t.measureStatus,i.normalizedMeasure=t.normalizedMeasure,i.progressMeasure=t.progressMeasure,i.progressMeasureStatus=t.progressMeasureStatus,i.completionStatus=t.completionStatus,i.satisfiedByMeasure=t.satisfiedByMeasure??i.satisfiedByMeasure,i.minNormalizedMeasure=void 0!==t.minNormalizedMeasure?t.minNormalizedMeasure:i.minNormalizedMeasure}}}getAvailableChildren(){return 0===this._children.length?[]:null!==this._processedChildren?this._processedChildren:this._children}setProcessedChildren(e){this._processedChildren=e}resetProcessedChildren(){this._processedChildren=null}get isNewAttempt(){return this._isNewAttempt}set isNewAttempt(e){this._isNewAttempt=e}get launchData(){return this._launchData}set launchData(e){this._launchData=e}get credit(){return this._credit}set credit(credit){this._credit=credit}get maxTimeAllowed(){return this._maxTimeAllowed}set maxTimeAllowed(e){this._maxTimeAllowed=e}get completionThreshold(){return this._completionThreshold}set completionThreshold(e){this._completionThreshold=e}getSuspensionState(){return{id:this._id,title:this._title,isVisible:this._isVisible,isActive:this._isActive,isSuspended:this._isSuspended,isCompleted:this._isCompleted,completionStatus:this._completionStatus,successStatus:this._successStatus,attemptCount:this._attemptCount,attemptCompletionAmount:this._attemptCompletionAmount,attemptAbsoluteDuration:this._attemptAbsoluteDuration,attemptExperiencedDuration:this._attemptExperiencedDuration,activityAbsoluteDuration:this._activityAbsoluteDuration,activityExperiencedDuration:this._activityExperiencedDuration,attemptAbsoluteDurationValue:this._attemptAbsoluteDurationValue,attemptExperiencedDurationValue:this._attemptExperiencedDurationValue,activityAbsoluteDurationValue:this._activityAbsoluteDurationValue,activityExperiencedDurationValue:this._activityExperiencedDurationValue,activityStartTimestampUtc:this._activityStartTimestampUtc,attemptStartTimestampUtc:this._attemptStartTimestampUtc,objectiveSatisfiedStatus:this._objectiveSatisfiedStatus,objectiveSatisfiedStatusKnown:this._objectiveSatisfiedStatusKnown,objectiveMeasureStatus:this._objectiveMeasureStatus,objectiveNormalizedMeasure:this._objectiveNormalizedMeasure,scaledPassingScore:this._scaledPassingScore,progressMeasure:this._progressMeasure,progressMeasureStatus:this._progressMeasureStatus,location:this._location,attemptAbsoluteStartTime:this._attemptAbsoluteStartTime,activityAttemptActive:this._activityAttemptActive,isHiddenFromChoice:this._isHiddenFromChoice,isAvailable:this._isAvailable,rollupConsiderations:{...this._rollupConsiderations},wasSkipped:this._wasSkipped,attemptProgressStatus:this._attemptProgressStatus,wasAutoCompleted:this._wasAutoCompleted,wasAutoSatisfied:this._wasAutoSatisfied,completedByMeasure:this._completedByMeasure,minProgressMeasure:this._minProgressMeasure,progressWeight:this._progressWeight,attemptCompletionAmountStatus:this._attemptCompletionAmountStatus,processedChildren:this._processedChildren?this._processedChildren.map(e=>e.id):null,isNewAttempt:this._isNewAttempt,selectionCountStatus:this._sequencingControls.selectionCountStatus,reorderChildren:this._sequencingControls.reorderChildren,primaryObjective:this._primaryObjective?{id:this._primaryObjective.id,satisfiedStatus:this._primaryObjective.satisfiedStatus,measureStatus:this._primaryObjective.measureStatus,normalizedMeasure:this._primaryObjective.normalizedMeasure,progressMeasure:this._primaryObjective.progressMeasure,progressMeasureStatus:this._primaryObjective.progressMeasureStatus,completionStatus:this._primaryObjective.completionStatus,satisfiedByMeasure:this._primaryObjective.satisfiedByMeasure,minNormalizedMeasure:this._primaryObjective.minNormalizedMeasure,progressStatus:this._primaryObjective.progressStatus,mapInfo:this._primaryObjective.mapInfo}:null,objectives:this._objectives.map(e=>({id:e.id,satisfiedStatus:e.satisfiedStatus,measureStatus:e.measureStatus,normalizedMeasure:e.normalizedMeasure,progressMeasure:e.progressMeasure,progressMeasureStatus:e.progressMeasureStatus,completionStatus:e.completionStatus,satisfiedByMeasure:e.satisfiedByMeasure,minNormalizedMeasure:e.minNormalizedMeasure,progressStatus:e.progressStatus,mapInfo:e.mapInfo})),children:this._children.map(e=>e.getSuspensionState())}}restoreSuspensionState(e){if(e){if(this._isVisible=e.isVisible??this._isVisible,this._isActive=e.isActive??this._isActive,this._isSuspended=e.isSuspended??this._isSuspended,this._isCompleted=e.isCompleted??this._isCompleted,this._completionStatus=e.completionStatus??this._completionStatus,this._successStatus=e.successStatus??this._successStatus,this._attemptCount=e.attemptCount??this._attemptCount,this._attemptCompletionAmount=e.attemptCompletionAmount??this._attemptCompletionAmount,this._attemptAbsoluteDuration=e.attemptAbsoluteDuration??this._attemptAbsoluteDuration,this._attemptExperiencedDuration=e.attemptExperiencedDuration??this._attemptExperiencedDuration,this._activityAbsoluteDuration=e.activityAbsoluteDuration??this._activityAbsoluteDuration,this._activityExperiencedDuration=e.activityExperiencedDuration??this._activityExperiencedDuration,this._attemptAbsoluteDurationValue=e.attemptAbsoluteDurationValue??this._attemptAbsoluteDurationValue,this._attemptExperiencedDurationValue=e.attemptExperiencedDurationValue??this._attemptExperiencedDurationValue,this._activityAbsoluteDurationValue=e.activityAbsoluteDurationValue??this._activityAbsoluteDurationValue,this._activityExperiencedDurationValue=e.activityExperiencedDurationValue??this._activityExperiencedDurationValue,this._activityStartTimestampUtc=e.activityStartTimestampUtc??this._activityStartTimestampUtc,this._attemptStartTimestampUtc=e.attemptStartTimestampUtc??this._attemptStartTimestampUtc,this._objectiveSatisfiedStatus=e.objectiveSatisfiedStatus??this._objectiveSatisfiedStatus,this._objectiveSatisfiedStatusKnown=e.objectiveSatisfiedStatusKnown??this._objectiveSatisfiedStatusKnown,this._objectiveMeasureStatus=e.objectiveMeasureStatus??this._objectiveMeasureStatus,this._objectiveNormalizedMeasure=e.objectiveNormalizedMeasure??this._objectiveNormalizedMeasure,this._scaledPassingScore=e.scaledPassingScore??this._scaledPassingScore,this._progressMeasure=e.progressMeasure??this._progressMeasure,this._progressMeasureStatus=e.progressMeasureStatus??this._progressMeasureStatus,this._location=e.location??this._location,this._attemptAbsoluteStartTime=e.attemptAbsoluteStartTime??this._attemptAbsoluteStartTime,this._activityAttemptActive=e.activityAttemptActive??this._activityAttemptActive,this._isHiddenFromChoice=e.isHiddenFromChoice??this._isHiddenFromChoice,this._isAvailable=e.isAvailable??this._isAvailable,e.rollupConsiderations&&(this._rollupConsiderations={...e.rollupConsiderations}),this._wasSkipped=e.wasSkipped??this._wasSkipped,this._attemptProgressStatus=e.attemptProgressStatus??this._attemptProgressStatus,this._wasAutoCompleted=e.wasAutoCompleted??this._wasAutoCompleted,this._wasAutoSatisfied=e.wasAutoSatisfied??this._wasAutoSatisfied,this._completedByMeasure=e.completedByMeasure??this._completedByMeasure,this._minProgressMeasure=e.minProgressMeasure??this._minProgressMeasure,this._progressWeight=e.progressWeight??this._progressWeight,this._attemptCompletionAmountStatus=e.attemptCompletionAmountStatus??this._attemptCompletionAmountStatus,this._isNewAttempt=e.isNewAttempt??this._isNewAttempt,void 0!==e.selectionCountStatus&&(this._sequencingControls.selectionCountStatus=e.selectionCountStatus),void 0!==e.reorderChildren&&(this._sequencingControls.reorderChildren=e.reorderChildren),e.processedChildren){const t=new Map(this._children.map(e=>[e.id,e]));this._processedChildren=e.processedChildren.map(id=>t.get(id)).filter(e=>void 0!==e)}else this._processedChildren=null;if(e.primaryObjective&&this._primaryObjective&&(this._primaryObjective.satisfiedStatus=e.primaryObjective.satisfiedStatus??this._primaryObjective.satisfiedStatus,this._primaryObjective.measureStatus=e.primaryObjective.measureStatus??this._primaryObjective.measureStatus,this._primaryObjective.normalizedMeasure=e.primaryObjective.normalizedMeasure??this._primaryObjective.normalizedMeasure,this._primaryObjective.progressMeasure=e.primaryObjective.progressMeasure??this._primaryObjective.progressMeasure,this._primaryObjective.progressMeasureStatus=e.primaryObjective.progressMeasureStatus??this._primaryObjective.progressMeasureStatus,this._primaryObjective.completionStatus=e.primaryObjective.completionStatus??this._primaryObjective.completionStatus,this._primaryObjective.progressStatus=e.primaryObjective.progressStatus??this._primaryObjective.progressStatus),e.objectives)for(const t of e.objectives){const e=this._objectives.find(e=>e.id===t.id);e&&(e.satisfiedStatus=t.satisfiedStatus??e.satisfiedStatus,e.measureStatus=t.measureStatus??e.measureStatus,e.normalizedMeasure=t.normalizedMeasure??e.normalizedMeasure,e.progressMeasure=t.progressMeasure??e.progressMeasure,e.progressMeasureStatus=t.progressMeasureStatus??e.progressMeasureStatus,e.completionStatus=t.completionStatus??e.completionStatus,e.progressStatus=t.progressStatus??e.progressStatus)}if(e.children&&Array.isArray(e.children))for(let t=0;e.children.length>t&&this._children.length>t;t++){const i=e.children[t],s=this._children.find(e=>e.id===i.id);s&&s.restoreSuspensionState(i)}}}toJSON(){this.jsonString=!0;const result={id:this._id,title:this._title,isVisible:this._isVisible,isActive:this._isActive,isSuspended:this._isSuspended,isCompleted:this._isCompleted,completionStatus:this._completionStatus,successStatus:this._successStatus,attemptCount:this._attemptCount,attemptCompletionAmount:this._attemptCompletionAmount,attemptAbsoluteDuration:this._attemptAbsoluteDuration,attemptExperiencedDuration:this._attemptExperiencedDuration,activityAbsoluteDuration:this._activityAbsoluteDuration,activityExperiencedDuration:this._activityExperiencedDuration,objectiveSatisfiedStatus:this._objectiveSatisfiedStatus,objectiveSatisfiedStatusKnown:this._objectiveSatisfiedStatusKnown,objectiveMeasureStatus:this._objectiveMeasureStatus,objectiveNormalizedMeasure:this._objectiveNormalizedMeasure,rollupConsiderations:{...this._rollupConsiderations},wasSkipped:this._wasSkipped,completedByMeasure:this._completedByMeasure,minProgressMeasure:this._minProgressMeasure,progressWeight:this._progressWeight,attemptCompletionAmountStatus:this._attemptCompletionAmountStatus,hideLmsUi:[...this._hideLmsUi],auxiliaryResources:this._auxiliaryResources.map(e=>({...e})),children:this._children.map(e=>e.toJSON())};return this.jsonString=!1,result}get auxiliaryResources(){return this._auxiliaryResources.map(e=>({...e}))}set auxiliaryResources(e){const t=[],i=new Set;for(const s of e||[]){if(!s)continue;const e="string"==typeof s.resourceId?s.resourceId.trim():"",r="string"==typeof s.purpose?s.purpose.trim():"";e&&!i.has(e)&&(i.add(e),t.push({resourceId:e,purpose:r}))}this._auxiliaryResources=t}addAuxiliaryResource(e){this.auxiliaryResources=[...this._auxiliaryResources,e]}captureRollupStatus(){return{measureStatus:this._objectiveMeasureStatus,normalizedMeasure:this._objectiveNormalizedMeasure,objectiveProgressStatus:null!=this._objectiveSatisfiedStatus,objectiveSatisfiedStatus:this._objectiveSatisfiedStatus,attemptProgressStatus:this._completionStatus!==H,attemptCompletionStatus:this._completionStatus===k}}static compareRollupStatus(e,t){return e.measureStatus===t.measureStatus&&1e-4>Math.abs(e.normalizedMeasure-t.normalizedMeasure)&&e.objectiveProgressStatus===t.objectiveProgressStatus&&e.objectiveSatisfiedStatus===t.objectiveSatisfiedStatus&&e.attemptProgressStatus===t.attemptProgressStatus&&e.attemptCompletionStatus===t.attemptCompletionStatus}get hideLmsUi(){return[...this._hideLmsUi]}set hideLmsUi(e){const t=new Set(Ce),i=new Set,s=[];for(const r of e)t.has(r)&&!i.has(r)&&(i.add(r),s.push(r));this._hideLmsUi=s}}class ii{checkChildForRollupSubprocess(e,t,i){if(!1===e.sequencingControls.tracked)return!1;let s=!1;if("measure"===t||"objective"===t){if(!e.sequencingControls.rollupObjectiveSatisfied)return!1;s=!0;const t=e.requiredForSatisfied,r=e.requiredForNotSatisfied;"satisfied"===i&&"ifNotSuspended"===t||"notSatisfied"===i&&"ifNotSuspended"===r?(!e.attemptProgressStatus||e.attemptCount>0&&e.isSuspended)&&(s=!1):"satisfied"===i&&"ifAttempted"===t||"notSatisfied"===i&&"ifAttempted"===r?e.attemptProgressStatus&&0!==e.attemptCount||(s=!1):("satisfied"===i&&"ifNotSkipped"===t||"notSatisfied"===i&&"ifNotSkipped"===r)&&e.wasSkipped&&(s=!1)}if("progress"===t){if(!e.sequencingControls.rollupProgressCompletion)return!1;s=!0;const t=e.requiredForCompleted,r=e.requiredForIncomplete;"completed"===i&&"ifNotSuspended"===t||"incomplete"===i&&"ifNotSuspended"===r?(!e.attemptProgressStatus||e.attemptCount>0&&e.isSuspended)&&(s=!1):"completed"===i&&"ifAttempted"===t||"incomplete"===i&&"ifAttempted"===r?e.attemptProgressStatus&&0!==e.attemptCount||(s=!1):("completed"===i&&"ifNotSkipped"===t||"incomplete"===i&&"ifNotSkipped"===r)&&e.wasSkipped&&(s=!1)}return!(s&&!e.isAvailable)&&s}filterChildrenForRequirement(e,t,mode,i){return e.filter(e=>this.shouldIncludeChildForRollup(e,t,mode,i))}shouldIncludeChildForRollup(e,t,mode,i){return!(!this.checkChildForRollupSubprocess(e,t,mode)||"objective"===t&&!i.measureSatisfactionIfActive&&(e.activityAttemptActive||e.isActive))}isChildSatisfiedForRollup(e){return!0===e.objectiveSatisfiedStatus||!1!==e.objectiveSatisfiedStatus&&e.successStatus===P}isChildCompletedForRollup(e){return!("completed"!==e.completionStatus&&!e.isCompleted)}getTrackableChildren(e){return e.children.filter(e=>!1!==e.sequencingControls.tracked)}}var si=Object.defineProperty;class ri{constructor(e){var t;((e,t,i)=>{t in e?si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(this,"childFilter"+"",t),this.childFilter=e}evaluateRollupRule(e,t){const i=e.getAvailableChildren();let s=0,r=0;for(const e of i){let i=!1;switch(t.action){case Yt.SATISFIED:i=this.childFilter.checkChildForRollupSubprocess(e,"objective","satisfied");break;case Yt.NOT_SATISFIED:i=this.childFilter.checkChildForRollupSubprocess(e,"objective","notSatisfied");break;case Yt.COMPLETED:i=this.childFilter.checkChildForRollupSubprocess(e,"progress","completed");break;case Yt.INCOMPLETE:i=this.childFilter.checkChildForRollupSubprocess(e,"progress","incomplete")}i&&(s++,this.evaluateRollupConditionsSubprocess(e,t)&&r++)}return t.consideration===Wt.ALL?s>0&&r===s:null!==t.minimumCount?r>=t.minimumCount:null!==t.minimumPercent?(s>0?r/s:0)>=t.minimumPercent:s>0&&r===s}evaluateRollupConditionsSubprocess(e,t){if(0===t.conditions.length)return!0;switch(t.consideration){case Wt.ALL:return t.conditions.every(t=>t.evaluate(e));case Wt.ANY:return t.conditions.some(t=>t.evaluate(e));case Wt.NONE:return!t.conditions.some(t=>t.evaluate(e));case Wt.AT_LEAST_COUNT:case Wt.AT_LEAST_PERCENT:return t.conditions.every(t=>t.evaluate(e));default:return!1}}evaluateRulesForAction(e,t,i){const s=t.filter(e=>e.action===i);if(0===s.length)return null;for(const t of s)if(this.evaluateRollupRule(e,t))return!0;return!1}}var ni=Object.defineProperty,oi=(e,t,i)=>((e,t,i)=>t in e?ni(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ai{constructor(e,t){oi(this,"childFilter"),oi(this,"eventCallback"),this.childFilter=e,this.eventCallback=t||null}measureRollupProcess(e){if(!e.sequencingControls.rollupObjectiveSatisfied)return[];const t=e.getAvailableChildren();if(0===t.length)return[];const i=e.rollupConsiderations,s=t.filter(e=>!(!this.childFilter.checkChildForRollupSubprocess(e,"measure")||!e.objectiveMeasureStatus||null===e.objectiveNormalizedMeasure||!i.measureSatisfactionIfActive&&(e.activityAttemptActive||e.isActive)));if(0===s.length)return e.objectiveMeasureStatus=!1,[];const r=this.calculateComplexWeightedMeasure(e,s,{enableThresholdBias:!1});return e.objectiveNormalizedMeasure=r,e.objectiveMeasureStatus=!0,this.identifyActivityClusters(s)}completionMeasureRollupProcess(e){const t=e.getAvailableChildren();if(0===t.length)return;const i=t.filter(e=>e.attemptCompletionAmountStatus);if(0===i.length)return void(e.attemptCompletionAmountStatus=!1);let s=0,r=0;for(const e of i)s+=e.attemptCompletionAmount*e.progressWeight,r+=e.progressWeight;r>0&&(e.attemptCompletionAmount=s/r,e.attemptCompletionAmountStatus=!0)}calculateComplexWeightedMeasure(e,t,i){let s=0,r=0;const n=[],o=i?.enableThresholdBias??!0;for(const e of t)if(this.childFilter.checkChildForRollupSubprocess(e,"measure")&&e.objectiveMeasureStatus&&null!==e.objectiveNormalizedMeasure){const t=this.calculateAdjustedWeight(e,e.sequencingControls.objectiveMeasureWeight,o);s+=e.objectiveNormalizedMeasure*t,r+=t,n.push({childId:e.id,measure:e.objectiveNormalizedMeasure,weight:t})}return this.eventCallback?.("complex_weighting_calculated",{activityId:e.id,weightingDetails:n,totalWeight:r,totalWeightedMeasure:s,result:r>0?s/r:0}),r>0?s/r:0}calculateAdjustedWeight(e,t){let i=2>=arguments.length||void 0===arguments[2]||arguments[2],s=t;return"completed"!==e.completionStatus&&(s*=.8),e.attemptCount>1&&(s*=Math.max(.5,1-.1*(e.attemptCount-1))),e.hasAttemptLimitExceeded()&&(s*=.6),i&&e.objectiveMeasureStatus&&(s*=(e.scaledPassingScore??.7)>e.objectiveNormalizedMeasure?.95:1.05),Math.max(0,s)}identifyActivityClusters(e){const t=[];for(const i of e)i.children.length>0&&i.sequencingControls.flow&&t.push(i);return t}}var ci=Object.defineProperty,li=(e,t,i)=>((e,t,i)=>t in e?ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ui{constructor(e,t,i){li(this,"childFilter"),li(this,"ruleEvaluator"),li(this,"eventCallback"),this.childFilter=e,this.ruleEvaluator=t,this.eventCallback=i||null}objectiveRollupProcess(e){const t=this.objectiveRollupUsingRules(e,e.rollupRules.rules);if(null!==t)return e.objectiveSatisfiedStatus=t,void this.syncPrimaryObjectiveFromActivity(e);const i=this.objectiveRollupUsingMeasure(e);if(null!==i)return e.objectiveSatisfiedStatus=i,void this.syncPrimaryObjectiveFromActivity(e);e.objectiveSatisfiedStatus=this.objectiveRollupUsingDefault(e),this.syncPrimaryObjectiveFromActivity(e)}objectiveRollupUsingRules(e,t){const i=t.filter(e=>e.action===Yt.SATISFIED),s=t.filter(e=>e.action===Yt.NOT_SATISFIED);for(const t of i)if(this.ruleEvaluator.evaluateRollupRule(e,t))return!0;for(const t of s)if(this.ruleEvaluator.evaluateRollupRule(e,t))return!1;return null}objectiveRollupUsingMeasure(e){return e.objectiveMeasureStatus&&null!==e.scaledPassingScore?e.objectiveNormalizedMeasure>=e.scaledPassingScore:null}objectiveRollupUsingDefault(e){const t=e.getAvailableChildren();if(0===t.length)return!1;const i=e.rollupConsiderations,s=t.filter(e=>!(!this.childFilter.checkChildForRollupSubprocess(e,"objective","satisfied")||!this.childFilter.checkChildForRollupSubprocess(e,"objective","notSatisfied")||!i.measureSatisfactionIfActive&&(e.activityAttemptActive||e.isActive)));return 0!==s.length&&!s.some(e=>!this.childFilter.isChildSatisfiedForRollup(e))&&s.every(e=>this.childFilter.isChildSatisfiedForRollup(e))}syncPrimaryObjectiveFromActivity(e){e.primaryObjective&&(e.primaryObjective.satisfiedStatus=e.objectiveSatisfiedStatus,e.primaryObjective.satisfiedStatusKnown=e.objectiveSatisfiedStatusKnown,e.primaryObjective.measureStatus=e.objectiveMeasureStatus,e.primaryObjective.normalizedMeasure=e.objectiveNormalizedMeasure,e.primaryObjective.progressMeasure=e.progressMeasure,e.primaryObjective.progressMeasureStatus=e.progressMeasureStatus,e.primaryObjective.completionStatus=e.completionStatus)}}var hi=Object.defineProperty,di=(e,t,i)=>((e,t,i)=>t in e?hi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class mi{constructor(e,t,i,s){di(this,"childFilter"),di(this,"ruleEvaluator"),di(this,"objectiveProcessor"),di(this,"eventCallback"),this.childFilter=e,this.ruleEvaluator=t,this.objectiveProcessor=i,this.eventCallback=s||null}activityProgressRollupProcess(e){if(this.activityProgressRollupUsingMeasure(e))return;const t=e.rollupRules,i=t.rules.filter(e=>e.action===Yt.COMPLETED),s=t.rules.filter(e=>e.action===Yt.INCOMPLETE);for(const t of i)if(this.ruleEvaluator.evaluateRollupRule(e,t))return e.completionStatus=k,void this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e);for(const t of s)if(this.ruleEvaluator.evaluateRollupRule(e,t))return e.completionStatus=V,void this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e);const r=e.getAvailableChildren().filter(e=>this.childFilter.checkChildForRollupSubprocess(e,"progress","completed")&&this.childFilter.checkChildForRollupSubprocess(e,"progress","incomplete"));return 0===r.length||r.some(e=>!this.childFilter.isChildCompletedForRollup(e))?(e.completionStatus=V,void this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e)):(e.completionStatus=k,void this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e))}activityProgressRollupUsingMeasure(e){return!!e.completedByMeasure&&(e.attemptCompletionAmountStatus?(e.completionStatus=e.minProgressMeasure>e.attemptCompletionAmount?V:k,this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e),!0):(e.completionStatus=H,this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e),!0))}}var pi=Object.defineProperty;class _i{constructor(e){var t;((e,t,i)=>{t in e?pi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(this,"eventCallback"+"",t),this.eventCallback=e||null}durationRollupProcess(e){if(0===e.children.length)return;const t=e.getAvailableChildren();if(0===t.length)return;let s=null,n=null,o=null,a=null,c=0,l=0;for(const i of t){i.activityStartTimestampUtc&&(s&&i.activityStartTimestampUtc>=s||(s=i.activityStartTimestampUtc)),i.activityEndedDate&&(o&&o>=i.activityEndedDate||(o=i.activityEndedDate));const t="PT0H0M0S"!==i.activityExperiencedDurationValue?i.activityExperiencedDurationValue:i.activityExperiencedDuration;if(t&&"PT0H0M0S"!==t&&(c+=r(t,ne)),!e.attemptStartTimestampUtc||i.attemptStartTimestampUtc&&i.attemptStartTimestampUtc>=e.attemptStartTimestampUtc){i.attemptStartTimestampUtc&&(n&&i.attemptStartTimestampUtc>=n||(n=i.attemptStartTimestampUtc)),i.activityEndedDate&&(a&&a>=i.activityEndedDate||(a=i.activityEndedDate));const e="PT0H0M0S"!==i.attemptExperiencedDurationValue?i.attemptExperiencedDurationValue:i.attemptExperiencedDuration;e&&"PT0H0M0S"!==e&&(l+=r(e,ne))}}if(null!==s){if(e.activityStartTimestampUtc=s,!e.attemptStartTimestampUtc&&n&&(e.attemptStartTimestampUtc=n),e.activityEndedDate=o,o&&e.activityStartTimestampUtc){const t=new Date(e.activityStartTimestampUtc),s=o.getTime()-t.getTime();e.activityAbsoluteDurationValue=i(Math.max(0,s/1e3))}if(a&&e.attemptStartTimestampUtc){const t=new Date(e.attemptStartTimestampUtc),s=a.getTime()-t.getTime();e.attemptAbsoluteDurationValue=i(Math.max(0,s/1e3))}e.activityExperiencedDurationValue=i(c),e.attemptExperiencedDurationValue=i(l),this.eventCallback?.("duration_rollup_completed",{activityId:e.id,activityAbsoluteDuration:e.activityAbsoluteDurationValue,attemptAbsoluteDuration:e.attemptAbsoluteDurationValue,activityExperiencedDuration:e.activityExperiencedDurationValue,attemptExperiencedDuration:e.attemptExperiencedDurationValue,childCount:t.length})}}}var vi=Object.defineProperty,gi=(e,t,i)=>((e,t,i)=>t in e?vi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class fi{constructor(e,t,i,s){gi(this,"measureProcessor"),gi(this,"objectiveProcessor"),gi(this,"progressProcessor"),gi(this,"eventCallback"),gi(this,"processingClusters",new Set),this.measureProcessor=e,this.objectiveProcessor=t,this.progressProcessor=i,this.eventCallback=s||null}processCrossClusterDependencies(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(10>i)if(this.processingClusters.has(e.id))this.eventCallback?.("cross_cluster_skip_reentrant",{activityId:e.id});else try{this.processingClusters.add(e.id),this.eventCallback?.("cross_cluster_processing_started",{activityId:e.id,clusterCount:t.length,depth:i});const s=new Map;for(const e of t)this.analyzeCrossClusterDependencies(e,s);const r=this.resolveDependencyOrder(s);for(const e of r){const s=t.find(t=>t.id===e);s&&this.processClusterRollup(s,i)}this.eventCallback?.("cross_cluster_processing_completed",{activityId:e.id,processedClusters:r.length,dependencyMap:Array.from(s.entries())})}catch(t){this.eventCallback?.("cross_cluster_processing_error",{activityId:e.id,error:t instanceof Error?t.message:t+""})}finally{this.processingClusters.delete(e.id)}else this.eventCallback?.("cross_cluster_max_depth_reached",{activityId:e.id,depth:i,maxDepth:10})}identifyActivityClusters(e){const t=[];for(const i of e)i.children.length>0&&i.sequencingControls.flow&&t.push(i);return t}analyzeCrossClusterDependencies(e,t){t.set(e.id,[])}resolveDependencyOrder(e){const t=[],i=new Set,s=id=>{if(t.includes(id))return;if(i.has(id))return void this.eventCallback?.("circular_dependency_detected",{activityId:id});i.add(id);const r=e.get(id)||[];for(const e of r)s(e);i.delete(id),t.push(id)};for(const id of Array.from(e.keys()))s(id);return t}processClusterRollup(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const i=this.measureProcessor.measureRollupProcess(e);e.sequencingControls.rollupObjectiveSatisfied&&this.objectiveProcessor.objectiveRollupProcess(e),e.sequencingControls.rollupProgressCompletion&&this.progressProcessor.activityProgressRollupProcess(e),i.length>1&&this.processCrossClusterDependencies(e,i,t+1)}}var Si=Object.defineProperty;class bi{constructor(e){var t;((e,t,i)=>{t in e?Si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(this,"eventCallback"+"",t),this.eventCallback=e||null}processGlobalObjectiveMapping(e,t){try{this.eventCallback?.("global_objective_processing_started",{activityId:e.id,globalObjectiveCount:t.size});const i=[];this.collectActivitiesRecursive(e,i);for(const e of i)this.syncGlobalObjectivesWritePhase(e,t);for(const e of i)this.syncGlobalObjectivesReadPhase(e,t);this.eventCallback?.("global_objective_processing_completed",{activityId:e.id,processedObjectives:t.size})}catch(t){this.eventCallback?.("global_objective_processing_error",{activityId:e.id,error:t instanceof Error?t.message:t+""})}}collectActivitiesRecursive(e,result){result.push(e);for(const t of e.children)this.collectActivitiesRecursive(t,result)}syncGlobalObjectivesWritePhase(e,t){const objectives=e.getAllObjectives();for(const i of objectives){const s=i.mapInfo.length>0?i.mapInfo:[this.createDefaultMapInfo(i)];for(const r of s){const s=this.ensureGlobalObjectiveEntry(t,r.targetObjectiveID||i.id,i);r.writeSatisfiedStatus&&i.measureStatus&&i.isDirty("satisfiedStatus")&&(s.satisfiedStatus=i.satisfiedStatus,s.satisfiedStatusKnown=!0,i.clearDirty("satisfiedStatus")),r.writeNormalizedMeasure&&i.measureStatus&&i.isDirty("normalizedMeasure")&&(s.normalizedMeasure=i.normalizedMeasure,s.normalizedMeasureKnown=!0,i.clearDirty("normalizedMeasure"),s.satisfiedByMeasure||i.satisfiedByMeasure)&&(s.satisfiedStatus=i.normalizedMeasure>=(i.minNormalizedMeasure??e.scaledPassingScore??.7),s.satisfiedStatusKnown=!0,i.clearDirty("satisfiedStatus")),r.writeCompletionStatus&&i.completionStatus!==H&&i.isDirty("completionStatus")&&(s.completionStatus=i.completionStatus,s.completionStatusKnown=!0,i.clearDirty("completionStatus")),r.writeProgressMeasure&&i.progressMeasureStatus&&i.isDirty("progressMeasure")&&(s.progressMeasure=i.progressMeasure,s.progressMeasureKnown=!0,i.clearDirty("progressMeasure")),r.updateAttemptData&&this.updateActivityAttemptData(e,s,i)}}}syncGlobalObjectivesReadPhase(e,t){const objectives=e.getAllObjectives();for(const i of objectives){const s=i.mapInfo.length>0?i.mapInfo:[this.createDefaultMapInfo(i)];for(const r of s){const s=t.get(r.targetObjectiveID||i.id);if(!s)continue;const n=i.isPrimary;r.readSatisfiedStatus&&s.satisfiedStatusKnown&&(i.satisfiedStatus=s.satisfiedStatus,i.measureStatus=!0),r.readNormalizedMeasure&&s.normalizedMeasureKnown&&(i.normalizedMeasure=s.normalizedMeasure,i.measureStatus=!0,s.satisfiedByMeasure||i.satisfiedByMeasure)&&(i.satisfiedStatus=s.normalizedMeasure>=(i.minNormalizedMeasure??e.scaledPassingScore??.7)),r.readProgressMeasure&&s.progressMeasureKnown&&(i.progressMeasure=s.progressMeasure,i.progressMeasureStatus=!0),r.readCompletionStatus&&s.completionStatusKnown&&(i.completionStatus=s.completionStatus),n&&i.applyToActivity(e),this.eventCallback?.("objective_synchronized",{activityId:e.id,objectiveId:i.id,globalState:s,synchronizationTime:(new Date).toISOString()})}}}synchronizeGlobalObjectives(e,t){const objectives=e.getAllObjectives();for(const i of objectives){const s=i.mapInfo.length>0?i.mapInfo:[this.createDefaultMapInfo(i)];for(const r of s){const s=this.ensureGlobalObjectiveEntry(t,r.targetObjectiveID||i.id,i);this.syncObjectiveState(e,i,r,s)}}}syncObjectiveState(e,t,i,s){try{const r=this.getLocalObjectiveState(e,t,t.isPrimary);i.readSatisfiedStatus&&s.satisfiedStatusKnown&&(t.satisfiedStatus=s.satisfiedStatus,t.measureStatus=!0),i.readNormalizedMeasure&&s.normalizedMeasureKnown&&(t.normalizedMeasure=s.normalizedMeasure,t.measureStatus=!0,s.satisfiedByMeasure||t.satisfiedByMeasure)&&(t.satisfiedStatus=s.normalizedMeasure>=(t.minNormalizedMeasure??e.scaledPassingScore??.7)),i.readProgressMeasure&&s.progressMeasureKnown&&(t.progressMeasure=s.progressMeasure,t.progressMeasureStatus=!0),i.readCompletionStatus&&s.completionStatusKnown&&(t.completionStatus=s.completionStatus),t.isPrimary&&t.applyToActivity(e),i.writeSatisfiedStatus&&t.measureStatus&&(s.satisfiedStatus=t.satisfiedStatus,s.satisfiedStatusKnown=!0),i.writeNormalizedMeasure&&t.measureStatus&&(s.normalizedMeasure=t.normalizedMeasure,s.normalizedMeasureKnown=!0,s.satisfiedByMeasure||t.satisfiedByMeasure)&&(s.satisfiedStatus=t.normalizedMeasure>=(t.minNormalizedMeasure??e.scaledPassingScore??.7),s.satisfiedStatusKnown=!0),i.writeCompletionStatus&&t.completionStatus!==H&&(s.completionStatus=t.completionStatus,s.completionStatusKnown=!0),i.writeProgressMeasure&&t.progressMeasureStatus&&(s.progressMeasure=t.progressMeasure,s.progressMeasureKnown=!0),i.updateAttemptData&&this.updateActivityAttemptData(e,s,t),this.eventCallback?.("objective_synchronized",{activityId:e.id,objectiveId:t.id,localState:r,globalState:s,synchronizationTime:(new Date).toISOString()})}catch(i){this.eventCallback?.("objective_sync_error",{activityId:e.id,objectiveId:t.id,error:i instanceof Error?i.message:i+"",timestamp:(new Date).toISOString()})}}ensureGlobalObjectiveEntry(e,t,i){return e.has(t)||e.set(t,{id:t,satisfiedStatus:i.satisfiedStatus,satisfiedStatusKnown:i.satisfiedStatusKnown,normalizedMeasure:i.normalizedMeasure,normalizedMeasureKnown:i.measureStatus,progressMeasure:i.progressMeasure,progressMeasureKnown:i.progressMeasureStatus,completionStatus:i.completionStatus,completionStatusKnown:i.completionStatus!==H,satisfiedByMeasure:i.satisfiedByMeasure,minNormalizedMeasure:i.minNormalizedMeasure}),e.get(t)}createDefaultMapInfo(e){return{targetObjectiveID:e.id,readSatisfiedStatus:!1,writeSatisfiedStatus:!0,readNormalizedMeasure:!1,writeNormalizedMeasure:!0,readCompletionStatus:!1,writeCompletionStatus:!0,readProgressMeasure:!1,writeProgressMeasure:!0,updateAttemptData:e.isPrimary}}getLocalObjectiveState(e,t,i){return i?{id:t.id,satisfiedStatus:e.objectiveSatisfiedStatus,measureStatus:e.objectiveMeasureStatus,normalizedMeasure:e.objectiveNormalizedMeasure,progressMeasure:e.progressMeasure,progressMeasureStatus:e.progressMeasureStatus,completionStatus:e.completionStatus,scaledPassingScore:e.scaledPassingScore}:{id:t.id,satisfiedStatus:t.satisfiedStatus,measureStatus:t.measureStatus,normalizedMeasure:t.normalizedMeasure,progressMeasure:t.progressMeasure,progressMeasureStatus:t.progressMeasureStatus,completionStatus:t.completionStatus,scaledPassingScore:t.minNormalizedMeasure}}updateActivityAttemptData(e,t,i){try{if(!i.isPrimary&&!t.updateAttemptData)return;const s=e.rollupRules.rules.some(e=>"completed"===e.action||"incomplete"===e.action);t.satisfiedStatusKnown&&t.satisfiedStatus&&(s||e.completionStatus!==H&&e.completionStatus!==V||(e.completionStatus=k),"unknown"===e.successStatus&&(e.successStatus="passed")),t.attemptCount&&t.attemptCount>e.attemptCount&&(e.attemptCount=t.attemptCount),t.progressMeasureKnown&&void 0!==t.progressMeasure&&(e.attemptCompletionAmount=t.progressMeasure),t.attemptAbsoluteDuration&&(e.attemptAbsoluteDuration=t.attemptAbsoluteDuration),t.attemptExperiencedDuration&&(e.attemptExperiencedDuration=t.attemptExperiencedDuration),t.activityAbsoluteDuration&&(e.activityAbsoluteDuration=t.activityAbsoluteDuration),t.activityExperiencedDuration&&(e.activityExperiencedDuration=t.activityExperiencedDuration),void 0!==t.location&&(e.location=t.location),void 0!==t.suspendData&&(e.isSuspended=t.suspendData.length>0)}catch(t){this.eventCallback?.("attempt_data_update_error",{activityId:e.id,error:t instanceof Error?t.message:t+"",timestamp:(new Date).toISOString()})}}}var yi=Object.defineProperty,Ci=(e,t,i)=>((e,t,i)=>t in e?yi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ai{constructor(e,t){Ci(this,"rollupStateLog",[]),Ci(this,"childFilter"),Ci(this,"eventCallback"),this.childFilter=e,this.eventCallback=t||null}validateRollupStateConsistency(e){try{this.eventCallback?.("rollup_validation_started",{activityId:e.id,timestamp:(new Date).toISOString()});const t=[];return this.validateActivityRollupState(e,t),t.length>0?(this.eventCallback?.("rollup_state_inconsistencies",{activityId:e.id,inconsistencies:t,count:t.length}),!1):(this.eventCallback?.("rollup_validation_completed",{activityId:e.id,result:"consistent"}),!0)}catch(t){return this.eventCallback?.("rollup_validation_error",{activityId:e.id,error:t instanceof Error?t.message:t+""}),!1}}validateActivityRollupState(e,t){const i=e.id;e.objectiveMeasureStatus&&null===e.objectiveNormalizedMeasure&&t.push(`Activity ${i}: measure status true but normalized measure is null`),e.objectiveMeasureStatus&&null!==e.scaledPassingScore&&"unknown"!==e.successStatus&&e.objectiveSatisfiedStatus!==e.objectiveNormalizedMeasure>=e.scaledPassingScore&&t.push(`Activity ${i}: satisfaction status inconsistent with measure`);const s=e.sequencingControls,r=e.getAvailableChildren();if(r.length>0&&s.rollupObjectiveSatisfied){const s=r.filter(e=>this.childFilter.checkChildForRollupSubprocess(e,"objective","satisfied")&&this.childFilter.isChildSatisfiedForRollup(e)),n=r.filter(e=>this.childFilter.checkChildForRollupSubprocess(e,"objective","notSatisfied")&&!this.childFilter.isChildSatisfiedForRollup(e));s.length>0&&0===n.length&&!1===e.objectiveSatisfiedStatus&&0===e.rollupRules.rules.length&&t.push(`Activity ${i}: all children satisfied but parent is not satisfied (no rollup rules to override)`)}if(r.length>0&&s.rollupProgressCompletion){const s=r.filter(e=>this.childFilter.checkChildForRollupSubprocess(e,"progress","completed")&&this.childFilter.isChildCompletedForRollup(e)),n=r.filter(e=>this.childFilter.checkChildForRollupSubprocess(e,"progress","incomplete")&&!this.childFilter.isChildCompletedForRollup(e));s.length>0&&0===n.length&&"completed"!==e.completionStatus&&0===e.rollupRules.rules.length&&t.push(`Activity ${i}: all children completed but parent is incomplete (no rollup rules to override)`)}for(const e of r)this.validateActivityRollupState(e,t);this.rollupStateLog.push({activity:i,timestamp:(new Date).toISOString(),state:{measureStatus:e.objectiveMeasureStatus,measure:e.objectiveNormalizedMeasure,satisfiedStatus:e.objectiveSatisfiedStatus,completionStatus:e.completionStatus}})}getRollupStateLog(){return[...this.rollupStateLog]}clearRollupStateLog(){this.rollupStateLog=[]}}var Ei=Object.defineProperty,wi=(e,t,i)=>((e,t,i)=>t in e?Ei(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Mi{constructor(e){wi(this,"childFilter"),wi(this,"ruleEvaluator"),wi(this,"measureProcessor"),wi(this,"objectiveProcessor"),wi(this,"progressProcessor"),wi(this,"durationProcessor"),wi(this,"globalObjectiveSynchronizer"),wi(this,"stateValidator"),wi(this,"crossClusterProcessor"),wi(this,"eventCallback"),this.eventCallback=e||null,this.childFilter=new ii,this.ruleEvaluator=new ri(this.childFilter),this.measureProcessor=new ai(this.childFilter,e),this.objectiveProcessor=new ui(this.childFilter,this.ruleEvaluator,e),this.progressProcessor=new mi(this.childFilter,this.ruleEvaluator,this.objectiveProcessor,e),this.durationProcessor=new _i(e),this.globalObjectiveSynchronizer=new bi(e),this.stateValidator=new Ai(this.childFilter,e),this.crossClusterProcessor=new fi(this.measureProcessor,this.objectiveProcessor,this.progressProcessor,e)}overallRollupProcess(e){const t=[];let i=e.parent,s=!1,r=!0;for(;i;){if(i.children.length>0&&this.durationProcessor.durationRollupProcess(i),!s){const e=i.captureRollupStatus();if(i.sequencingControls.rollupObjectiveSatisfied||i.sequencingControls.rollupProgressCompletion){if(i.children.length>0){const e=this.measureProcessor.measureRollupProcess(i);this.measureProcessor.completionMeasureRollupProcess(i),e.length>1&&this.crossClusterProcessor.processCrossClusterDependencies(i,e)}i.sequencingControls.rollupObjectiveSatisfied&&this.objectiveProcessor.objectiveRollupProcess(i),i.sequencingControls.rollupProgressCompletion&&this.progressProcessor.activityProgressRollupProcess(i)}const n=i.captureRollupStatus();r||!ti.compareRollupStatus(e,n)||(this.eventCallback?.("rollup_optimization_activated",{activityId:i.id,depth:t.length}),s=!0),!r&&ti.compareRollupStatus(e,n)||t.push(i)}i=i.parent,r=!1}return t}validateRollupStateConsistency(e){return this.stateValidator.validateRollupStateConsistency(e)}processGlobalObjectiveMapping(e,t){this.globalObjectiveSynchronizer.processGlobalObjectiveMapping(e,t)}calculateComplexWeightedMeasure(e,t,i){return this.measureProcessor.calculateComplexWeightedMeasure(e,t,i)}processCrossClusterDependencies(e,t){this.crossClusterProcessor.processCrossClusterDependencies(e,t)}getChildFilter(){return this.childFilter}getRuleEvaluator(){return this.ruleEvaluator}getMeasureProcessor(){return this.measureProcessor}getObjectiveProcessor(){return this.objectiveProcessor}getProgressProcessor(){return this.progressProcessor}getDurationProcessor(){return this.durationProcessor}getGlobalObjectiveSynchronizer(){return this.globalObjectiveSynchronizer}getStateValidator(){return this.stateValidator}getCrossClusterProcessor(){return this.crossClusterProcessor}}var Oi=Object.defineProperty;const Ri=[k,V,H],Ti=[P,z,F];function ji(e){return e&&Ri.includes(e)?e:null}function Ii(e){return e&&Ti.includes(e)?e:null}class Ni{constructor(e){var t;((e,t,i)=>{t in e?Oi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(this,"context"+"",t),this.context=e}transferRteData(e){if(!this.context.getCMIData)return;const t=this.context.getCMIData();t&&(this.transferPrimaryObjective(e,t),this.transferNonPrimaryObjectives(e,t),this.context.fireEvent("onRteDataTransfer",{activityId:e.id,timestamp:(new Date).toISOString()}))}transferPrimaryObjective(e,t){const i=ji(t.completion_status);i&&i!==H&&(e.completionStatus=i,e.attemptProgressStatus=!0);let s=!1,r=!1,n=!1,o=0;const a=Ii(t.success_status);if(a&&a!==F&&(r=a===P,s=!0,e.objectiveSatisfiedStatus=r,e.objectiveSatisfiedStatusKnown=!0,e.successStatus=a,e.objectiveMeasureStatus=!0),t.score){const i=this.normalizeScore(t.score);null!==i&&(o=i,n=!0,e.objectiveNormalizedMeasure=o,e.objectiveMeasureStatus=!0)}if(e.primaryObjective&&(s||n)&&(e.primaryObjective.initializeFromCMI(s?r:e.primaryObjective.satisfiedStatus,n?o:e.primaryObjective.normalizedMeasure,s||n),s&&(e.primaryObjective.satisfiedStatusKnown=!0,e.primaryObjective.progressStatus=!0)),t.progress_measure&&""!==t.progress_measure){const i=parseFloat(t.progress_measure);isNaN(i)||(e.progressMeasure=i,e.progressMeasureStatus=!0,e.primaryObjective&&(e.primaryObjective.progressMeasure=i,e.primaryObjective.progressMeasureStatus=!0))}}transferNonPrimaryObjectives(e,t){if(t.objectives&&0!==t.objectives.length)for(const i of t.objectives){if(!i.id)continue;const t=e.getObjectiveById(i.id);if(!t||t.isPrimary)continue;const s=t.objective;let r=!1,n=!1,o=!1,a=0;const c=Ii(i.success_status);c&&c!==F&&(n=c===P,r=!0,s.progressStatus=!0);const l=ji(i.completion_status);if(l&&l!==H&&(s.completionStatus=l),i.score){const e=this.normalizeScore(i.score);null!==e&&(a=e,o=!0)}if((r||o)&&s.initializeFromCMI(r?n:s.satisfiedStatus,o?a:s.normalizedMeasure,o),i.progress_measure&&""!==i.progress_measure){const e=parseFloat(i.progress_measure);isNaN(e)||(s.progressMeasure=e,s.progressMeasureStatus=!0)}}}normalizeScore(score){if(score.scaled&&""!==score.scaled){const e=parseFloat(score.scaled);if(!isNaN(e))return e}if(score.raw&&""!==score.raw&&score.min&&""!==score.min&&score.max&&""!==score.max){const e=parseFloat(score.raw),t=parseFloat(score.min),i=parseFloat(score.max);if(!isNaN(e)&&!isNaN(t)&&!isNaN(i)&&i>t)return Math.max(-1,Math.min(1,(e-t)/(i-t)))}return null}}var xi=Object.defineProperty,qi=(e,t,i)=>((e,t,i)=>t in e?xi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Di{constructor(e,t,i,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n=arguments.length>5?arguments[5]:void 0;qi(this,"activityTree"),qi(this,"sequencingProcess"),qi(this,"rollupProcess"),qi(this,"globalObjectiveMap"),qi(this,"eventCallback"),qi(this,"getCMIData"),qi(this,"is4thEdition"),qi(this,"invalidateCacheCallback",null),qi(this,"_rteDataTransferService"),this.activityTree=e,this.sequencingProcess=t,this.rollupProcess=i,this.globalObjectiveMap=s,this.eventCallback=r,this.getCMIData=n?.getCMIData||null,this.is4thEdition=n?.is4thEdition||!1,this._rteDataTransferService=new Ni({getCMIData:this.getCMIData,fireEvent:(e,t)=>this.fireEvent(e,t)})}setInvalidateCacheCallback(e){this.invalidateCacheCallback=e}processTerminationRequest(request){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=arguments.length>2?arguments[2]:void 0;const i=this.activityTree.currentActivity;if(!i)return{terminationRequest:request,sequencingRequest:null,exception:"TB.2.3-1",valid:!1};if((request===ze.EXIT||request===ze.ABANDON)&&!i.isActive)return{terminationRequest:request,sequencingRequest:null,exception:"TB.2.3-2",valid:!1};if(this.fireEvent("onTerminationRequestProcessing",{request:request,hasSequencingRequest:e,currentActivity:i.id,exitType:t}),"logout"===t)return this.fireEvent("onSequencingDebug",{message:"cmi.exit='logout' detected, treating as EXIT_ALL",activityId:i.id}),this.handleExitAll(i);switch(request){case ze.EXIT:return this.handleExit(i,e);case ze.EXIT_ALL:return this.handleExitAll(i);case ze.ABANDON:return this.handleAbandon(i,e);case ze.ABANDON_ALL:return this.handleAbandonAll(i);case ze.SUSPEND_ALL:return this.handleSuspendAll(i);default:return{terminationRequest:request,sequencingRequest:null,exception:"TB.2.3-7",valid:!1}}}handleExitTermination(e,t){return this.handleExit(e,t)}handleExit(e,t){e.children.length>0&&this.terminateDescendants(e),this.endAttempt(e);const i=this.evaluateExitRules(e);if("EXIT_ALL"===i.action)return this.handleExitAll(e);let s,r;"EXIT_PARENT"===i.action&&e.parent&&(this.activityTree.currentActivity=e.parent,this.endAttempt(this.activityTree.currentActivity));do{if(s=!1,r=this.evaluatePostConditions(this.activityTree.currentActivity||e),r.terminationRequest===ze.EXIT_ALL)return this.fireEvent("onPostConditionExitAll",{activity:(this.activityTree.currentActivity||e).id}),this.handleExitAll(this.activityTree.root);if(r.terminationRequest===ze.EXIT_PARENT){const t=this.activityTree.currentActivity||e;if(!t.parent)return{terminationRequest:ze.EXIT_PARENT,sequencingRequest:null,exception:"TB.2.3-4",valid:!1};this.activityTree.currentActivity=t.parent,this.endAttempt(this.activityTree.currentActivity),s=!0,this.fireEvent("onPostConditionExitParent",{fromActivity:t.id,toActivity:this.activityTree.currentActivity.id})}if(!s&&(this.activityTree.currentActivity||e)===this.activityTree.root&&r.sequencingRequest!==ze.RETRY)return{terminationRequest:ze.EXIT,sequencingRequest:ze.EXIT,exception:null,valid:!0}}while(s);if(!t&&!r.sequencingRequest){const t=this.activityTree.currentActivity||e;t.parent&&this.activityTree.setCurrentActivityWithoutActivation(t.parent)}return{terminationRequest:ze.EXIT,sequencingRequest:r.sequencingRequest,exception:null,valid:!0}}handleExitAll(e){return this.activityTree.root&&this.handleMultiLevelExit(this.activityTree.root),this.activityTree.root&&this.endAttempt(this.activityTree.root),this.activityTree.currentActivity=null,this.cleanupSuspendedActivity(),{terminationRequest:ze.EXIT_ALL,sequencingRequest:ze.EXIT,exception:null,valid:!0}}handleAbandon(e,t){return e.isActive=!1,t||(this.activityTree.currentActivity=e.parent),{terminationRequest:ze.ABANDON,sequencingRequest:null,exception:null,valid:!0}}handleAbandonAll(e){const t=[];let i=e;for(;null!==i;)t.push(i),i=i.parent;if(0===t.length)return{terminationRequest:ze.ABANDON_ALL,sequencingRequest:null,exception:"TB.2.3-6",valid:!1};for(const e of t)e.isActive=!1;return this.activityTree.currentActivity=null,this.cleanupSuspendedActivity(),{terminationRequest:ze.ABANDON_ALL,sequencingRequest:null,exception:null,valid:!0}}handleSuspendAll(e){const t=this.processSuspendAllRequest(e);return t.valid?{terminationRequest:ze.SUSPEND_ALL,sequencingRequest:ze.EXIT,exception:null,valid:!0}:t}processSuspendAllRequest(e){const t=this.activityTree.root;if(!e||!t)return this.fireEvent("onSuspendError",{exception:"TB.2.3-1",message:"No current activity to suspend",activity:e?.id}),{terminationRequest:ze.SUSPEND_ALL,sequencingRequest:null,exception:"TB.2.3-1",valid:!1};if(e===t&&!e.isActive&&!e.isSuspended)return this.fireEvent("onSuspendError",{exception:"TB.2.3-3",message:"Nothing to suspend (root activity)",activity:e.id}),{terminationRequest:ze.SUSPEND_ALL,sequencingRequest:null,exception:"TB.2.3-3",valid:!1};this.activityTree.suspendedActivity=e;const i=e,s=[];let r=i;for(;null!==r;)s.push(r),r=r.parent;if(0===s.length)return this.fireEvent("onSuspendError",{exception:"TB.2.3-5",message:"Activity path is empty",activity:i?.id}),{terminationRequest:ze.SUSPEND_ALL,sequencingRequest:null,exception:"TB.2.3-5",valid:!1};for(const e of s)e.isActive=!1,e.isSuspended=!0;return this.activityTree.currentActivity=t,t.isActive=!1,this.fireEvent("onActivitySuspended",{activity:i?.id,suspendedPath:s.map(e=>e.id),pathLength:s.length,timestamp:(new Date).toISOString()}),{terminationRequest:ze.SUSPEND_ALL,sequencingRequest:null,exception:null,valid:!0}}evaluateExitRules(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t++;const i=e.sequencingRules.exitConditionRules;for(const s of i){let i;if(i="all"===s.conditionCombination?s.conditions.every(t=>t.evaluate(e)):s.conditions.some(t=>t.evaluate(e)),i){if(s.action===Me.EXIT_PARENT)return{action:"EXIT_PARENT",recursionDepth:t};if(s.action===Me.EXIT_ALL)return{action:"EXIT_ALL",recursionDepth:t}}}return{action:null,recursionDepth:t}}evaluatePostConditions(e){const t=this.sequencingProcess.evaluatePostConditionRules(e);return(t.sequencingRequest||t.terminationRequest)&&this.fireEvent("onPostConditionEvaluated",{activity:e.id,sequencingRequest:t.sequencingRequest,terminationRequest:t.terminationRequest,timestamp:(new Date).toISOString()}),t}handleMultiLevelExit(e){this.processExitAtLevel(e,0),this.terminateAll(e)}processExitAtLevel(e,t){const i=this.evaluateExitRules(e,0);i.action&&this.fireEvent("onMultiLevelExitAction",{activity:e.id,level:t,action:i.action});for(const i of e.children)this.processExitAtLevel(i,t+1)}cleanupSuspendedActivity(){const e=this.activityTree.suspendedActivity;if(e){let t=e;const i=[];for(;t;)t.isSuspended&&(t.isSuspended=!1,i.push(t.id)),t=t.parent;this.activityTree.suspendedActivity=null,this.fireEvent("onSuspendedActivityCleanup",{cleanedActivities:i,originalSuspendedActivity:e.id})}}terminateAll(e){for(const t of e.children)this.terminateAll(t);e.isActive&&this.endAttempt(e)}terminateDescendants(e){for(const t of e.children){t.children.length>0&&this.terminateDescendants(t);const e=this.exitActionRulesSubprocess(t);t.isActive&&("EXIT_ALL"===e&&this.terminateDescendants(t),this.endAttempt(t))}}exitActionRulesSubprocess(e){const t=e.sequencingRules.exitConditionRules;for(const i of t){let t;if(t="all"===i.conditionCombination?i.conditions.every(t=>t.evaluate(e)):i.conditions.some(t=>t.evaluate(e)),t){if(i.action===Me.EXIT_PARENT)return"EXIT_PARENT";if(i.action===Me.EXIT_ALL)return"EXIT_ALL"}}return null}clearSuspendedActivity(){if(this.activityTree.suspendedActivity){let e=this.activityTree.suspendedActivity;for(;e;)e.isSuspended=!1,e=e.parent;this.activityTree.suspendedActivity=null}}endAttempt(e){if(e.isActive){if(this._rteDataTransferService.transferRteData(e),e.isActive=!1,e.activityAttemptActive=!1,0===e.children.length){if(!e.isSuspended&&(e.sequencingControls.completionSetByContent||e.attemptProgressStatus||(e.attemptProgressStatus=!0,e.completionStatus="completed",e.wasAutoCompleted=!0,this.fireEvent("onAutoCompletion",{activityId:e.id,timestamp:(new Date).toISOString()})),!e.sequencingControls.objectiveSetByContent)){const t=e.primaryObjective;t&&(t.progressStatus||(t.progressStatus=!0,t.satisfiedStatus=!0,e.objectiveSatisfiedStatus=!0,e.successStatus="passed",e.wasAutoSatisfied=!0,this.fireEvent("onAutoSatisfaction",{activityId:e.id,timestamp:(new Date).toISOString()})))}}else{const t=e.children.some(e=>e.isSuspended);e.isSuspended=t}"unknown"===e.completionStatus&&(e.completionStatus="incomplete"),"unknown"===e.successStatus&&e.objectiveSatisfiedStatus&&(e.successStatus=e.objectiveSatisfiedStatus?"passed":"failed"),this.rollupProcess.processGlobalObjectiveMapping(this.activityTree.root||e,this.globalObjectiveMap),this.rollupProcess.overallRollupProcess(e),this.invalidateCacheCallback&&this.invalidateCacheCallback(),this.activityTree.root&&this.rollupProcess.validateRollupStateConsistency(this.activityTree.root),Qe.applySelectionAndRandomization(e,!1)}}fireEvent(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn(`Failed to fire sequencing event ${e}: ${t}`)}}}var Li=Object.defineProperty,Pi=(e,t,i)=>((e,t,i)=>t in e?Li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class zi{constructor(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;Pi(this,"valid"),Pi(this,"targetActivity"),Pi(this,"exception"),this.valid=e,this.targetActivity=t,this.exception=i}}const Fi=class e{constructor(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n=arguments.length>5?arguments[5]:void 0;Pi(this,"activityTree"),Pi(this,"rollupProcess"),Pi(this,"globalObjectiveMap"),Pi(this,"adlNav"),Pi(this,"eventCallback"),Pi(this,"now"),Pi(this,"defaultHideLmsUi"),Pi(this,"defaultAuxiliaryResources"),Pi(this,"_deliveryInProgress",!1),Pi(this,"contentDelivered",!1),Pi(this,"checkActivityCallback",null),Pi(this,"invalidateCacheCallback",null),Pi(this,"updateNavigationValidityCallback",null),Pi(this,"clearSuspendedActivityCallback",null),this.activityTree=e,this.rollupProcess=t,this.globalObjectiveMap=i,this.adlNav=s,this.eventCallback=r,this.now=n?.now||(()=>new Date),this.defaultHideLmsUi=n?.defaultHideLmsUi?[...n.defaultHideLmsUi]:[],this.defaultAuxiliaryResources=n?.defaultAuxiliaryResources?n.defaultAuxiliaryResources.map(e=>({...e})):[]}setCheckActivityCallback(e){this.checkActivityCallback=e}setInvalidateCacheCallback(e){this.invalidateCacheCallback=e}setUpdateNavigationValidityCallback(e){this.updateNavigationValidityCallback=e}setClearSuspendedActivityCallback(e){this.clearSuspendedActivityCallback=e}isDeliveryInProgress(){return this._deliveryInProgress}hasContentBeenDelivered(){return this.contentDelivered}resetContentDelivered(){this.contentDelivered=!1}setContentDelivered(e){this.contentDelivered=e}processDeliveryRequest(e){if(this.fireEvent("onDeliveryRequestProcessing",{activity:e.id,timestamp:(new Date).toISOString()}),e.children.length>0)return new zi(!1,null,"DB.1.1-1");const t=this.getActivityPath(e,!0);if(0===t.length)return new zi(!1,null,"DB.1.1-2");for(const e of t)if(this.checkActivityCallback&&!this.checkActivityCallback(e))return new zi(!1,null,"DB.1.1-3");return new zi(!0,e)}contentDeliveryEnvironmentProcess(e){this._deliveryInProgress=!0;try{const t=e.isSuspended;this.activityTree.suspendedActivity&&this.clearSuspendedActivityCallback&&this.clearSuspendedActivityCallback();const i=this.getActivityPath(e,!0);for(const e of i)e.isActive||(t||e.isSuspended?e.isSuspended=!1:e.incrementAttemptCount(),e.isActive=!0,Qe.applySelectionAndRandomization(e,1>=e.attemptCount));this.activityTree.currentActivity=e,this.initializeForDelivery(e),this.setupAttemptTracking(e),this.contentDelivered=!0,this.adlNav&&this.updateNavigationValidityCallback&&this.updateNavigationValidityCallback(),this.fireDeliveryEvent(e)}finally{this._deliveryInProgress=!1}}initializeForDelivery(e){"unknown"===e.completionStatus&&0===e.children.length&&(e.completionStatus="not attempted"),null===e.objectiveSatisfiedStatus&&(e.objectiveSatisfiedStatus=!1),null===e.progressMeasure&&(e.progressMeasure=0,e.progressMeasureStatus=!1),null===e.objectiveNormalizedMeasure&&(e.objectiveNormalizedMeasure=0,e.objectiveMeasureStatus=!1),e.attemptAbsoluteDuration="PT0H0M0S",e.attemptExperiencedDuration="PT0H0M0S",e.isAvailable=!0}setupAttemptTracking(e){e.wasSkipped=!1,e.attemptAbsoluteStartTime=this.now().toISOString(),e.location||(e.location=""),e.activityAttemptActive=!0,e.learnerPrefs||(e.learnerPrefs={audioCaptioning:"0",audioLevel:"1",deliverySpeed:"1",language:""})}fireDeliveryEvent(e){try{this.eventCallback&&this.eventCallback("onActivityDelivery",e),console.debug(`Activity delivered: ${e.id} - ${e.title}`)}catch(e){console.warn("Failed to fire activity delivery event: "+e)}}getEffectiveHideLmsUi(t){const i=new Set;for(const e of this.defaultHideLmsUi)i.add(e);let s=t;for(;s;){for(const e of s.hideLmsUi)i.add(e);s=s.parent}return e.HIDE_LMS_UI_ORDER.filter(e=>i.has(e))}getEffectiveAuxiliaryResources(e){const t=new Map;for(const e of this.defaultAuxiliaryResources)e.resourceId&&t.set(e.resourceId,{...e});const i=[];let s=e;for(;s;)i.push(s),s=s.parent;for(const e of i.reverse())for(const i of e.auxiliaryResources)i.resourceId&&t.set(i.resourceId,{...i});return Array.from(t.values())}getContentActivityData(e){return{hideLmsUi:this.getEffectiveHideLmsUi(e),auxiliaryResources:this.getEffectiveAuxiliaryResources(e),location:e.location||"",credit:e.credit||"credit",launchData:e.launchData||"",maxTimeAllowed:e.attemptAbsoluteDurationLimit||"",completionThreshold:e.completionThreshold?.toString()||"",timeLimitAction:e.timeLimitAction||"continue,no message"}}getActivityPath(e){let t=1>=arguments.length||void 0===arguments[1]||arguments[1];const i=[];let s=e;for(;null!==s;)i.unshift(s),s=s.parent;return!t&&i.length>0&&i.pop(),i}fireEvent(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn(`Failed to fire sequencing event ${e}: ${t}`)}}};Pi(Fi,"HIDE_LMS_UI_ORDER",[...Ce]);let ki=Fi;var Vi=Object.defineProperty,Hi=(e,t,i)=>((e,t,i)=>t in e?Vi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Bi{constructor(e,t){Hi(this,"activityTree"),Hi(this,"sequencingProcess"),Hi(this,"cache",null),Hi(this,"isDirty",!0),this.activityTree=e,this.sequencingProcess=t}predictContinueEnabled(){return this.ensureCacheValid(),this.cache?.continueEnabled??!1}predictPreviousEnabled(){return this.ensureCacheValid(),this.cache?.previousEnabled??!1}predictChoiceEnabled(e){return this.ensureCacheValid(),this.cache?.choiceEnabledMap.get(e)??!1}getAvailableChoices(){return this.ensureCacheValid(),Array.from(this.cache?.availableChoices??[])}getAllPredictions(){return this.ensureCacheValid(),{continueEnabled:this.cache?.continueEnabled??!1,previousEnabled:this.cache?.previousEnabled??!1,availableChoices:Array.from(this.cache?.availableChoices??[])}}invalidateCache(){this.isDirty=!0}updateCache(){this.isDirty=!0,this.ensureCacheValid()}ensureCacheValid(){const e=this.calculateTreeStateHash();!this.isDirty&&this.cache&&this.cache.treeStateHash===e||(this.recalculateCache(e),this.isDirty=!1)}recalculateCache(e){const t=this.activityTree.currentActivity;this.cache={continueEnabled:!1,previousEnabled:!1,availableChoices:new Set,choiceEnabledMap:new Map,treeStateHash:e},t?(this.cache.continueEnabled=this.predictContinueInternal(t),this.cache.previousEnabled=this.predictPreviousInternal(t),this.calculateAvailableChoices()):this.calculateAvailableChoicesFromRoot()}predictContinueInternal(e){return!!e.parent&&!!e.parent.sequencingControls.flow&&this.hasAvailableNextActivity(e)}hasAvailableNextActivity(e){const t=e.parent;if(!t)return!1;const i=t.children,s=i.indexOf(e);if(-1===s)return!1;if(i.length-1>s)for(let e=s+1;i.length>e;e++){const t=i[e];if(t&&this.isActivityPotentiallyDeliverableForward(t))return!0}return!(!t.parent||!t.sequencingControls.flow)&&this.hasAvailableNextActivity(t)}predictPreviousInternal(e){return!!e.parent&&!!e.parent.sequencingControls.flow&&!e.parent.sequencingControls.forwardOnly&&this.hasAvailablePreviousActivity(e)}hasAvailablePreviousActivity(e){const t=e.parent;if(!t)return!1;const i=t.children,s=i.indexOf(e);if(-1===s)return!1;if(s>0)for(let e=s-1;e>=0;e--){const t=i[e];if(t&&this.isActivityPotentiallyDeliverableBackward(t))return!0}return!(!t.parent||!t.sequencingControls.flow||t.sequencingControls.forwardOnly)&&this.hasAvailablePreviousActivity(t)}calculateAvailableChoicesFromRoot(){}calculateAvailableChoices(){this.cache&&this.activityTree.root&&this.recursivelyCheckChoiceAvailability(this.activityTree.root)}recursivelyCheckChoiceAvailability(e){if(!this.cache)return;const t=this.sequencingProcess.validateNavigationRequest(ze.CHOICE,e.id,this.activityTree.currentActivity).valid;if(this.cache.choiceEnabledMap.set(e.id,t),t&&this.cache.availableChoices.add(e.id),e.children)for(const t of e.children)this.recursivelyCheckChoiceAvailability(t)}isActivityPotentiallyDeliverableForward(e){if(e.isHiddenFromChoice||!e.isAvailable)return!1;if(0===e.children.length)return!!e.isVisible&&this.sequencingProcess.canActivityBeDelivered(e);for(const t of e.children)if(this.isActivityPotentiallyDeliverableForward(t))return!0;return!1}isActivityPotentiallyDeliverableBackward(e){if(e.isHiddenFromChoice||!e.isAvailable)return!1;if(0===e.children.length)return e.isVisible;for(const t of e.children)if(this.isActivityPotentiallyDeliverableBackward(t))return!0;return!1}calculateTreeStateHash(){const e=this.activityTree.currentActivity,t=this.activityTree.suspendedActivity;return[e?.id??"none",t?.id??"none",this.getActivityTreeStateSignature()].join("|")}getActivityTreeStateSignature(){if(!this.activityTree.root)return"empty";const e=[];return this.collectActivitySignatures(this.activityTree.root,e),e.join(":")}collectActivitySignatures(e,t){if(t.push(e.id+(e.isActive?"A":"-")+(e.isSuspended?"S":"-")+e.completionStatus+e.successStatus+e.attemptCount),e.children)for(const i of e.children)this.collectActivitySignatures(i,t)}}var Ui=Object.defineProperty,$i=(e,t,i)=>((e,t,i)=>t in e?Ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),Gi=(e=>(e.START="start",e.RESUME_ALL="resumeAll",e.CONTINUE="continue",e.PREVIOUS="previous",e.CHOICE="choice",e.JUMP="jump",e.EXIT="exit",e.EXIT_ALL="exitAll",e.ABANDON="abandon",e.ABANDON_ALL="abandonAll",e.SUSPEND_ALL="suspendAll",e.NOT_VALID="_none_",e))(Gi||{});class Yi{constructor(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;$i(this,"valid"),$i(this,"terminationRequest"),$i(this,"sequencingRequest"),$i(this,"targetActivityId"),$i(this,"exception"),this.valid=e,this.terminationRequest=t,this.sequencingRequest=i,this.targetActivityId=s,this.exception=r}}class Wi{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;$i(this,"activityTree"),$i(this,"sequencingProcess"),$i(this,"adlNav"),$i(this,"eventCallback"),$i(this,"navigationLookAhead"),$i(this,"getEffectiveHideLmsUiCallback",null),this.activityTree=e,this.sequencingProcess=t,this.adlNav=i,this.eventCallback=s,this.navigationLookAhead=new Bi(e,t)}setGetEffectiveHideLmsUiCallback(e){this.getEffectiveHideLmsUiCallback=e}getNavigationLookAhead(){return this.navigationLookAhead}validateRequest(request){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.fireEvent("onNavigationRequestProcessing",{request:request,targetActivityId:e});const t=this.activityTree.currentActivity;switch(request){case"start":return this.validateStartRequest(t);case"resumeAll":return this.validateResumeRequest(t);case"continue":return this.validateContinueRequest(t);case"previous":return this.validatePreviousRequest(t);case"choice":return this.validateChoiceRequest(t,e);case"jump":return this.validateJumpRequest(e);case"exit":return this.validateExitRequest(t);case"exitAll":return this.validateExitAllRequest(t);case"abandon":return this.validateAbandonRequest(t);case"abandonAll":return this.validateAbandonAllRequest(t);case"suspendAll":return this.validateSuspendAllRequest(t);default:return new Yi(!1,null,null,null,"NB.2.1-18")}}validateStartRequest(e){return null!==e?new Yi(!1,null,null,null,"NB.2.1-1"):new Yi(!0,null,ze.START,null)}validateResumeRequest(e){return null!==e?new Yi(!1,null,null,null,"NB.2.1-2"):null===this.activityTree.suspendedActivity?new Yi(!1,null,null,null,"NB.2.1-3"):new Yi(!0,null,ze.RESUME_ALL,null)}validateContinueRequest(e){return e?e.parent&&e.parent.sequencingControls.flow?new Yi(!0,e.isActive?ze.EXIT:null,ze.CONTINUE,null):new Yi(!1,null,null,null,"NB.2.1-5"):new Yi(!1,null,null,null,"NB.2.1-4")}validatePreviousRequest(e){if(!e)return new Yi(!1,null,null,null,"NB.2.1-6");if(!e.parent||!e.parent.sequencingControls.flow)return new Yi(!1,null,null,null,"NB.2.1-7");const t=this.validateForwardOnlyConstraints(e);return t.valid?new Yi(!0,e.isActive?ze.EXIT:null,ze.PREVIOUS,null):new Yi(!1,null,null,null,t.exception)}validateChoiceRequest(e,t){if(!t)return new Yi(!1,null,null,null,"NB.2.1-9");const i=this.activityTree.getActivity(t);if(!i)return new Yi(!1,null,null,null,"NB.2.1-10");const s=this.validateChoicePath(e,i);return s.valid?new Yi(!0,e?.isActive?ze.EXIT:null,ze.CHOICE,t):new Yi(!1,null,null,null,s.exception)}validateJumpRequest(e){return e?new Yi(!0,null,ze.JUMP,e):new Yi(!1,null,null,null,"NB.2.1-12")}validateExitRequest(e){return e?new Yi(!0,e===this.activityTree.root?ze.EXIT_ALL:ze.EXIT,null,null):new Yi(!1,null,null,null,"NB.2.1-13")}validateExitAllRequest(e){return e?new Yi(!0,ze.EXIT_ALL,null,null):new Yi(!1,null,null,null,"NB.2.1-14")}validateAbandonRequest(e){return e?new Yi(!0,ze.ABANDON,null,null):new Yi(!1,null,null,null,"NB.2.1-15")}validateAbandonAllRequest(e){return e?new Yi(!0,ze.ABANDON_ALL,null,null):new Yi(!1,null,null,null,"NB.2.1-16")}validateSuspendAllRequest(e){return e?new Yi(!0,ze.SUSPEND_ALL,null,null):new Yi(!1,null,null,null,"NB.2.1-17")}validateChoicePath(e,t){if(t.isHiddenFromChoice)return{valid:!1,exception:"NB.2.1-11"};if(!t.isAvailable)return{valid:!1,exception:"NB.2.1-11"};if(this.isActivityDisabled(t))return{valid:!1,exception:"NB.2.1-11"};if(e){const i=this.findCommonAncestor(e,t);if(!i)return{valid:!1,exception:"NB.2.1-11"};let s=e;for(;s&&s!==i;){if(!0===s.isActive&&s.sequencingControls&&!1===s.sequencingControls.choiceExit&&t!==s&&!this.activityContains(s,t))return{valid:!1,exception:"NB.2.1-11"};s=s.parent}const r=this.validateConstrainChoice(e,t,i);if(!r.valid)return r;const n=this.validateChoiceSet(e,t,i);if(!n.valid)return n}let i=t;for(;i;){if(i.parent&&!i.parent.sequencingControls.choice)return{valid:!1,exception:"NB.2.1-11"};i=i.parent}return{valid:!0,exception:null}}validateForwardOnlyConstraints(e){if(e.parent?.sequencingControls.forwardOnly)return{valid:!1,exception:"NB.2.1-8"};let t=e.parent?.parent;for(;t;){if(t.sequencingControls.forwardOnly)return{valid:!1,exception:"NB.2.1-8"};t=t.parent}return{valid:!0,exception:null}}validateConstrainChoice(e,t,i){let s=i;for(;s;){if(s.sequencingControls?.constrainChoice||s.sequencingControls?.preventActivation){const i=this.findChildContaining(s,e);if(!i)return{valid:!1,exception:"NB.2.1-11"};if(t===s)return{valid:!1,exception:"NB.2.1-11"};const r=this.findChildContaining(s,t);if(!r)return{valid:!1,exception:"NB.2.1-11"};if(s.sequencingControls?.constrainChoice&&r!==i)return{valid:!1,exception:"NB.2.1-11"};if(s.sequencingControls?.preventActivation&&r!==i&&this.requiresNewActivation(r,t))return{valid:!1,exception:"NB.2.1-11"}}s=s.parent}return this.validateAncestors(i,e,t)}validateChoiceSet(e,t,i){if(!this.activityContains(i,t)&&t!==i)return{valid:!1,exception:"NB.2.1-11"};let s=t;for(;s&&s!==i;){if(!s.isAvailable||s.isHiddenFromChoice||this.isActivityDisabled(s))return{valid:!1,exception:"NB.2.1-11"};s=s.parent}return{valid:!0,exception:null}}isActivityDisabled(e){if(!e.isAvailable)return!0;if(e.isHiddenFromChoice)return!0;const t=this.evaluatePreConditionRulesForChoice(e);return!!t&&(t===Me.DISABLED||t===Me.HIDE_FROM_CHOICE||t===Me.STOP_FORWARD_TRAVERSAL)}findChildContaining(e,t){for(const i of e.children){if(i===t)return i;if(this.activityContains(i,t))return i}return null}activityContains(e,t){let i=t;for(;i;){if(i===e)return!0;i=i.parent}return!1}findCommonAncestor(e,t){const i=[];let s=e;for(;s;)i.push(s),s=s.parent;for(s=t;s;){if(i.includes(s))return s;s=s.parent}return null}validateAncestors(e,t,i){const s=e.children;if(!s||0===s.length)return{valid:!0,exception:null};const r=this.findChildContaining(e,t),n=this.findChildContaining(e,i);if(!r||!n)return{valid:!1,exception:"NB.2.1-11"};const o=s.indexOf(r),a=s.indexOf(n);if(e.sequencingControls.forwardOnly&&o>a)return{valid:!1,exception:"NB.2.1-8"};const c=s.findIndex(e=>e?.sequencingControls.stopForwardTraversal);if(r.sequencingControls.stopForwardTraversal&&a>o)return{valid:!1,exception:"NB.2.1-11"};if(-1!==c&&a>c)return{valid:!1,exception:"NB.2.1-11"};if(a>o&&e.sequencingControls.forwardOnly)for(let e=o+1;a>e;e++){const t=s[e];if(t){if(t.sequencingControls.stopForwardTraversal)return{valid:!1,exception:"NB.2.1-11"};if(this.isActivityMandatory(t)&&!this.isActivityCompleted(t))return{valid:!1,exception:"NB.2.1-11"}}}return{valid:!0,exception:null}}requiresNewActivation(e,t){return!this.branchHasActiveAttempt(e)&&!t.activityAttemptActive&&!t.isActive}branchHasActiveAttempt(e){if(e.activityAttemptActive||e.isActive)return!0;for(const t of e.children)if(this.branchHasActiveAttempt(t))return!0;return!1}isActivityMandatory(e){if(!e.isAvailable||e.isHiddenFromChoice)return!1;const t=this.evaluatePreConditionRulesForChoice(e);return t!==Me.SKIP&&t!==Me.DISABLED&&t!==Me.HIDE_FROM_CHOICE&&t!==Me.STOP_FORWARD_TRAVERSAL&&!this.isActivityDisabled(e)&&!1!==e.mandatory}isActivityCompleted(e){if(!e.isAvailable||e.isHiddenFromChoice)return!0;const t=this.evaluatePreConditionRulesForChoice(e);return t===Me.SKIP||t===Me.DISABLED||t===Me.HIDE_FROM_CHOICE||t===Me.STOP_FORWARD_TRAVERSAL||!!this.isActivityDisabled(e)||"completed"===e.completionStatus||"passed"===e.successStatus||"passed"===e.successStatus}evaluatePreConditionRulesForChoice(e){if(!e.sequencingRules)return null;return e.sequencingRules.evaluatePreConditionRules(e)||null}updateNavigationValidity(){if(!this.adlNav||!this.activityTree.currentActivity)return;this.navigationLookAhead.invalidateCache();const e=this.navigationLookAhead.predictContinueEnabled();try{this.adlNav.request_valid.continue=e?"true":"false"}catch(e){}const t=this.navigationLookAhead.predictPreviousEnabled();try{this.adlNav.request_valid.previous=t?"true":"false"}catch(e){}const i=this.activityTree.getAllActivities(),s={},r={};for(const e of i){const t=this.validateRequest("choice",e.id);s[e.id]=t.valid?"true":"false";const i=this.validateRequest("jump",e.id);r[e.id]=i.valid?"true":"false"}try{this.adlNav.request_valid.choice=s}catch(e){}try{this.adlNav.request_valid.jump=r}catch(e){}const n=this.getEffectiveHideLmsUiCallback?this.getEffectiveHideLmsUiCallback(this.activityTree.currentActivity):[];this.fireEvent("onNavigationValidityUpdate",{continue:e,previous:t,choice:s,jump:r,hideLmsUi:n})}getAllPredictions(){return this.navigationLookAhead.getAllPredictions()}predictContinueEnabled(){return this.navigationLookAhead.predictContinueEnabled()}predictPreviousEnabled(){return this.navigationLookAhead.predictPreviousEnabled()}predictChoiceEnabled(e){return this.navigationLookAhead.predictChoiceEnabled(e)}getAvailableChoices(){return this.navigationLookAhead.getAvailableChoices()}invalidateCache(){this.navigationLookAhead.invalidateCache()}fireEvent(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn(`Failed to fire sequencing event ${e}: ${t}`)}}}var Ji=Object.defineProperty,Ki=(e,t,i)=>((e,t,i)=>t in e?Ji(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Xi{constructor(e){Ki(this,"globalObjectiveMap",new Map),Ki(this,"eventCallback",null),this.eventCallback=e||null}initialize(e){try{this.globalObjectiveMap.clear(),e&&this.collectObjectives(e),this.fireEvent("onGlobalObjectiveMapInitialized",{objectiveCount:this.globalObjectiveMap.size,timestamp:(new Date).toISOString()})}catch(e){this.fireEvent("onGlobalObjectiveMapError",{error:e instanceof Error?e.message:e+"",timestamp:(new Date).toISOString()})}}collectObjectives(e){const objectives=e.getAllObjectives();if(0===objectives.length){const t=e.id+"_default_objective";this.globalObjectiveMap.has(t)||this.globalObjectiveMap.set(t,{id:t,satisfiedStatus:e.objectiveSatisfiedStatus,satisfiedStatusKnown:e.objectiveMeasureStatus,normalizedMeasure:e.objectiveNormalizedMeasure,normalizedMeasureKnown:e.objectiveMeasureStatus,progressMeasure:e.progressMeasure,progressMeasureKnown:e.progressMeasureStatus,completionStatus:e.completionStatus,completionStatusKnown:e.completionStatus!==H,readSatisfiedStatus:!0,writeSatisfiedStatus:!0,readNormalizedMeasure:!0,writeNormalizedMeasure:!0,readCompletionStatus:!0,writeCompletionStatus:!0,readProgressMeasure:!0,writeProgressMeasure:!0,satisfiedByMeasure:null!==e.scaledPassingScore,minNormalizedMeasure:e.scaledPassingScore,updateAttemptData:!0})}for(const e of objectives){const t=e.mapInfo.length>0?e.mapInfo:[{targetObjectiveID:e.id,readSatisfiedStatus:!0,writeSatisfiedStatus:!0,readNormalizedMeasure:!0,writeNormalizedMeasure:!0,readProgressMeasure:!0,writeProgressMeasure:!0,readCompletionStatus:!0,writeCompletionStatus:!0,updateAttemptData:e.isPrimary}];for(const i of t){const t=i.targetObjectiveID||e.id;this.globalObjectiveMap.has(t)||this.globalObjectiveMap.set(t,{id:t,satisfiedStatus:e.satisfiedStatus,satisfiedStatusKnown:e.measureStatus,normalizedMeasure:e.normalizedMeasure,normalizedMeasureKnown:e.measureStatus,progressMeasure:e.progressMeasure,progressMeasureKnown:e.progressMeasureStatus,completionStatus:e.completionStatus,completionStatusKnown:e.completionStatus!==H,readSatisfiedStatus:i.readSatisfiedStatus??!1,writeSatisfiedStatus:i.writeSatisfiedStatus??!1,readNormalizedMeasure:i.readNormalizedMeasure??!1,writeNormalizedMeasure:i.writeNormalizedMeasure??!1,readProgressMeasure:i.readProgressMeasure??!1,writeProgressMeasure:i.writeProgressMeasure??!1,readCompletionStatus:i.readCompletionStatus??!1,writeCompletionStatus:i.writeCompletionStatus??!1,readRawScore:i.readRawScore??!1,writeRawScore:i.writeRawScore??!1,readMinScore:i.readMinScore??!1,writeMinScore:i.writeMinScore??!1,readMaxScore:i.readMaxScore??!1,writeMaxScore:i.writeMaxScore??!1,satisfiedByMeasure:e.satisfiedByMeasure,minNormalizedMeasure:e.minNormalizedMeasure,updateAttemptData:i.updateAttemptData??e.isPrimary})}}for(const t of e.children)this.collectObjectives(t)}getMap(){return this.globalObjectiveMap}getSnapshot(){return this.serialize()}restoreSnapshot(e){this.restore(e)}updateObjective(e,t){try{this.globalObjectiveMap.set(e,{...this.globalObjectiveMap.get(e),...t,lastUpdated:(new Date).toISOString()}),this.fireEvent("onGlobalObjectiveUpdated",{objectiveId:e,data:t,timestamp:(new Date).toISOString()})}catch(t){this.fireEvent("onGlobalObjectiveUpdateError",{objectiveId:e,error:t instanceof Error?t.message:t+"",timestamp:(new Date).toISOString()})}}synchronize(e,t){e&&t.processGlobalObjectiveMapping(e,this.globalObjectiveMap)}getObjective(e){return this.globalObjectiveMap.get(e)}hasObjective(e){return this.globalObjectiveMap.has(e)}getObjectiveIds(){return Array.from(this.globalObjectiveMap.keys())}getObjectiveCount(){return this.globalObjectiveMap.size}clear(){this.globalObjectiveMap.clear(),this.fireEvent("onGlobalObjectiveMapCleared",{timestamp:(new Date).toISOString()})}serialize(){const e={};return this.globalObjectiveMap.forEach((t,id)=>{e[id]={...t}}),e}restore(e){if(this.globalObjectiveMap.clear(),e){for(const[id,t]of Object.entries(e))this.globalObjectiveMap.set(id,{...t});this.fireEvent("onGlobalObjectiveMapRestored",{objectiveCount:this.globalObjectiveMap.size,timestamp:(new Date).toISOString()})}}fireEvent(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn(`Failed to fire global objective event ${e}: ${t}`)}}}var Qi=Object.defineProperty,Zi=(e,t,i)=>((e,t,i)=>t in e?Qi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class es{constructor(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;Zi(this,"activityTree"),Zi(this,"globalObjectiveService"),Zi(this,"rollupProcess"),Zi(this,"adlNav"),Zi(this,"eventCallback"),Zi(this,"getEffectiveHideLmsUiCallback",null),Zi(this,"getEffectiveAuxiliaryResourcesCallback",null),Zi(this,"contentDeliveredGetter",null),Zi(this,"contentDeliveredSetter",null),this.activityTree=e,this.globalObjectiveService=t,this.rollupProcess=i,this.adlNav=s,this.eventCallback=r}setGetEffectiveHideLmsUiCallback(e){this.getEffectiveHideLmsUiCallback=e}setGetEffectiveAuxiliaryResourcesCallback(e){this.getEffectiveAuxiliaryResourcesCallback=e}setContentDeliveredAccessors(e,t){this.contentDeliveredGetter=e,this.contentDeliveredSetter=t}getState(){return{version:"1.0",timestamp:(new Date).toISOString(),contentDelivered:!!this.contentDeliveredGetter&&this.contentDeliveredGetter(),currentActivity:this.activityTree.currentActivity?.id||null,suspendedActivity:this.activityTree.suspendedActivity?.id||null,activityStates:this.serializeActivities(),navigationState:this.getNavigationState(),globalObjectiveMap:this.globalObjectiveService.getSnapshot()}}restoreState(e){try{if(!e||"1.0"!==e.version)return console.warn("Incompatible sequencing state version"),!1;if(this.contentDeliveredSetter&&this.contentDeliveredSetter(e.contentDelivered||!1),e.globalObjectiveMap&&this.globalObjectiveService.restoreSnapshot(e.globalObjectiveMap),e.activityStates&&this.deserializeActivities(e.activityStates),e.currentActivity){const t=this.activityTree.getActivity(e.currentActivity);t&&(this.activityTree.currentActivity=t,t.isActive=!0)}if(e.suspendedActivity){const t=this.activityTree.getActivity(e.suspendedActivity);t&&(this.activityTree.suspendedActivity=t,t.isSuspended=!0)}return e.navigationState&&this.restoreNavigationState(e.navigationState),this.activityTree.root&&this.globalObjectiveService.synchronize(this.activityTree.root,this.rollupProcess),console.debug("Sequencing state restored successfully"),!0}catch(e){return console.error("Failed to restore sequencing state: "+e),!1}}serializeActivities(){const e={},t=i=>{e[i.id]={id:i.id,title:i.title,isActive:i.isActive,isSuspended:i.isSuspended,isCompleted:i.isCompleted,completionStatus:i.completionStatus,successStatus:i.successStatus,attemptCount:i.attemptCount,attemptCompletionAmount:i.attemptCompletionAmount,attemptAbsoluteDuration:i.attemptAbsoluteDuration,attemptExperiencedDuration:i.attemptExperiencedDuration,activityAbsoluteDuration:i.activityAbsoluteDuration,activityExperiencedDuration:i.activityExperiencedDuration,objectiveSatisfiedStatus:i.objectiveSatisfiedStatus,objectiveMeasureStatus:i.objectiveMeasureStatus,objectiveNormalizedMeasure:i.objectiveNormalizedMeasure,progressMeasure:i.progressMeasure,progressMeasureStatus:i.progressMeasureStatus,isAvailable:i.isAvailable,isHiddenFromChoice:i.isHiddenFromChoice,location:i.location,attemptAbsoluteStartTime:i.attemptAbsoluteStartTime,objectives:i.getObjectiveStateSnapshot(),auxiliaryResources:i.auxiliaryResources,selectionRandomizationState:{selectionCountStatus:i.sequencingControls.selectionCountStatus,reorderChildren:i.sequencingControls.reorderChildren,childOrder:i.children.map(e=>e.id),selectedChildIds:i.children.filter(e=>e.isAvailable).map(e=>e.id),hiddenFromChoiceChildIds:i.children.filter(e=>e.isHiddenFromChoice).map(e=>e.id)}};for(const e of i.children)t(e)};return this.activityTree.root&&t(this.activityTree.root),e}deserializeActivities(e){const t=i=>{const s=e[i.id];s&&(i.isActive=s.isActive||!1,i.isSuspended=s.isSuspended||!1,i.isCompleted=s.isCompleted||!1,i.completionStatus=s.completionStatus||"unknown",i.successStatus=s.successStatus||"unknown",i.attemptCount=s.attemptCount||0,i.attemptCompletionAmount=s.attemptCompletionAmount||0,i.attemptAbsoluteDuration=s.attemptAbsoluteDuration||"PT0H0M0S",i.attemptExperiencedDuration=s.attemptExperiencedDuration||"PT0H0M0S",i.activityAbsoluteDuration=s.activityAbsoluteDuration||"PT0H0M0S",i.activityExperiencedDuration=s.activityExperiencedDuration||"PT0H0M0S",i.objectiveSatisfiedStatus=s.objectiveSatisfiedStatus||!1,i.objectiveMeasureStatus=s.objectiveMeasureStatus||!1,i.objectiveNormalizedMeasure=s.objectiveNormalizedMeasure||0,i.progressMeasure=s.progressMeasure??0,i.progressMeasureStatus=s.progressMeasureStatus||!1,i.isAvailable=!1!==s.isAvailable,i.isHiddenFromChoice=!0===s.isHiddenFromChoice,i.location=s.location||"",i.attemptAbsoluteStartTime=s.attemptAbsoluteStartTime||"",Array.isArray(s.auxiliaryResources)&&(i.auxiliaryResources=s.auxiliaryResources),s.objectives&&i.applyObjectiveStateSnapshot(s.objectives));for(const e of i.children)t(e);if(s?.selectionRandomizationState){const e=s.selectionRandomizationState,t=i.sequencingControls;void 0!==e.selectionCountStatus&&(t.selectionCountStatus=e.selectionCountStatus),void 0!==e.reorderChildren&&(t.reorderChildren=e.reorderChildren),e.childOrder&&e.childOrder.length>0&&i.setChildOrder(e.childOrder);const r=Array.isArray(e.selectedChildIds)?new Set(e.selectedChildIds):null,n=Array.isArray(e.hiddenFromChoiceChildIds)?new Set(e.hiddenFromChoiceChildIds):null;if(r||n)for(const e of i.children){if(r){const t=r.has(e.id);e.isAvailable=t,n||(e.isHiddenFromChoice=!t)}n&&(e.isHiddenFromChoice=n.has(e.id))}i.setProcessedChildren(i.children.filter(e=>e.isAvailable))}else i.resetProcessedChildren()};this.activityTree.root&&t(this.activityTree.root)}getNavigationState(){if(!this.adlNav)return null;const e=this.getEffectiveHideLmsUiCallback?this.getEffectiveHideLmsUiCallback(this.activityTree.currentActivity):[],t=this.getEffectiveAuxiliaryResourcesCallback?this.getEffectiveAuxiliaryResourcesCallback(this.activityTree.currentActivity):[];return{request:this.adlNav.request||"_none_",requestValid:{continue:this.adlNav.request_valid?.continue||"false",previous:this.adlNav.request_valid?.previous||"false",choice:"unknown",jump:"unknown",exit:this.adlNav.request_valid?.exit||"false",exitAll:this.adlNav.request_valid?.exitAll||"false",abandon:this.adlNav.request_valid?.abandon||"false",abandonAll:this.adlNav.request_valid?.abandonAll||"false",suspendAll:this.adlNav.request_valid?.suspendAll||"false"},hideLmsUi:e,auxiliaryResources:t}}restoreNavigationState(e){if(this.adlNav&&e)try{if(e.requestValid){const t=e.requestValid;this.adlNav.request_valid.continue=t.continue||"false",this.adlNav.request_valid.previous=t.previous||"false",this.adlNav.request_valid.exit=t.exit||"false",this.adlNav.request_valid.exitAll=t.exitAll||"false",this.adlNav.request_valid.abandon=t.abandon||"false",this.adlNav.request_valid.abandonAll=t.abandonAll||"false",this.adlNav.request_valid.suspendAll=t.suspendAll||"false"}}catch(e){console.warn("Could not fully restore navigation state: "+e)}}getSuspensionState(){const e={activityTree:this.activityTree.root?this.activityTree.root.getSuspensionState():null,currentActivityId:this.activityTree.currentActivity?.id||null,suspendedActivityId:this.activityTree.suspendedActivity?.id||null,globalObjectives:this.globalObjectiveService.getSnapshot(),timestamp:(new Date).toISOString()};return this.fireEvent("onSuspensionStateCaptured",{hasActivityTree:!!e.activityTree,currentActivityId:e.currentActivityId,suspendedActivityId:e.suspendedActivityId,globalObjectiveCount:Object.keys(e.globalObjectives).length,timestamp:e.timestamp}),e}restoreSuspensionState(e){if(e)try{if(e.globalObjectives&&this.globalObjectiveService.restoreSnapshot(e.globalObjectives),e.activityTree&&this.activityTree.root&&this.activityTree.root.restoreSuspensionState(e.activityTree),e.currentActivityId){const t=this.activityTree.getActivity(e.currentActivityId);t&&(this.activityTree.currentActivity=t)}if(e.suspendedActivityId){const t=this.activityTree.getActivity(e.suspendedActivityId);t&&(this.activityTree.suspendedActivity=t)}this.fireEvent("onSuspensionStateRestored",{currentActivityId:e.currentActivityId,suspendedActivityId:e.suspendedActivityId,globalObjectiveCount:e.globalObjectives?Object.keys(e.globalObjectives).length:0,originalTimestamp:e.timestamp,restoreTimestamp:(new Date).toISOString()})}catch(e){throw this.fireEvent("onSuspensionStateRestoreError",{error:e instanceof Error?e.message:e+"",timestamp:(new Date).toISOString()}),e}else this.fireEvent("onSuspensionStateRestoreError",{error:"No suspension state provided",timestamp:(new Date).toISOString()})}fireEvent(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn(`Failed to fire state manager event ${e}: ${t}`)}}}var ts=Object.defineProperty,is=(e,t,i)=>((e,t,i)=>t in e?ts(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ss{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2?arguments[2]:void 0;is(this,"activityTree"),is(this,"eventCallback"),is(this,"now"),is(this,"contentDeliveredGetter",null),this.activityTree=e,this.eventCallback=t,this.now=i?.now||(()=>new Date)}setContentDeliveredGetter(e){this.contentDeliveredGetter=e}validateTreeConsistency(e){if(!this.activityTree.root)return{consistent:!1,exception:"DB.1.1-4"};if(!this.isActivityPartOfTree(e,this.activityTree.root))return{consistent:!1,exception:"DB.1.1-5"};const t=this.getActiveActivities();if(t.length>1)return this.fireEvent("onStateInconsistency",{activeActivities:t.map(e=>e.id),targetActivity:e.id}),{consistent:!1,exception:"DB.1.1-6"};let i=e;for(;i?.parent;){if(!i.parent.children.includes(i))return{consistent:!1,exception:"DB.1.1-7"};i=i.parent}return{consistent:!0,exception:null}}validateResources(e){const t=this.getRequiredResources(e);for(const e of t)if(!this.isResourceAvailable(e))return{available:!1,exception:"DB.1.1-8"};return this.checkSystemLimits().adequate?{available:!0,exception:null}:{available:!1,exception:"DB.1.1-9"}}validateConcurrentDelivery(e){return this.contentDeliveredGetter&&this.contentDeliveredGetter()&&this.activityTree.currentActivity&&this.activityTree.currentActivity!==e?{allowed:!1,exception:"DB.1.1-10"}:this.hasPendingDeliveryRequests()?{allowed:!1,exception:"DB.1.1-11"}:this.isDeliveryLocked()?{allowed:!1,exception:"DB.1.1-12"}:{allowed:!0,exception:null}}validateDependencies(e){const t=this.getPrerequisites(e);for(const i of t)if(!this.isPrerequisiteSatisfied(i,e))return{satisfied:!1,exception:"DB.1.1-13"};const i=this.getObjectiveDependencies(e);for(const e of i)if(!this.isObjectiveDependencySatisfied(e))return{satisfied:!1,exception:"DB.1.1-14"};return this.getSequencingRuleDependencies(e).satisfied?{satisfied:!0,exception:null}:{satisfied:!1,exception:"DB.1.1-15"}}checkActivity(e){return!!e.isAvailable&&!!this.checkLimitConditions(e)}checkLimitConditions(e){let result=!0,t="";if(null!==e.attemptLimit&&e.attemptLimit>0&&(e.attemptLimit>e.attemptCount||(result=!1,t="Attempt limit exceeded")),result&&e.attemptAbsoluteDurationLimit){const i=r(e.attemptAbsoluteDurationLimit,ne);i>0&&(i>r(e.attemptAbsoluteDuration||"PT0H0M0S",ne)||(result=!1,t="Attempt duration limit exceeded"))}if(result&&e.activityAbsoluteDurationLimit){const i=r(e.activityAbsoluteDurationLimit,ne);i>0&&(i>r(e.activityAbsoluteDuration||"PT0H0M0S",ne)||(result=!1,t="Activity duration limit exceeded"))}if(result&&e.beginTimeLimit){const i=this.now();new Date(e.beginTimeLimit)>i&&(result=!1,t="Not yet time to begin")}return result&&e.endTimeLimit&&this.now()>new Date(e.endTimeLimit)&&(result=!1,t="Time limit expired"),this.fireEvent("onLimitConditionCheck",{activity:e,result:result,failureReason:t,checks:{attemptLimit:e.attemptLimit,attemptCount:e.attemptCount,attemptDurationLimit:e.attemptAbsoluteDurationLimit,activityDurationLimit:e.activityAbsoluteDurationLimit,beginTimeLimit:e.beginTimeLimit,endTimeLimit:e.endTimeLimit}}),result}isActivityPartOfTree(e,t){if(e===t)return!0;for(const i of t.children)if(this.isActivityPartOfTree(e,i))return!0;return!1}getActiveActivities(){const e=[];return this.activityTree.root&&this.collectActiveActivities(this.activityTree.root,e),e}collectActiveActivities(e,t){e.isActive&&t.push(e);for(const i of e.children)this.collectActiveActivities(i,t)}getRequiredResources(e){const t=[],i=(e.title+" "+e.location).toLowerCase();return(i.includes("video")||i.includes("multimedia"))&&t.push("video-codec"),(i.includes("audio")||i.includes("sound"))&&t.push("audio-codec"),(i.includes("flash")||i.includes(".swf"))&&t.push("flash-plugin"),(i.includes("java")||i.includes("applet"))&&t.push("java-runtime"),e.children&&e.children.length>0&&t.push("high-bandwidth"),e.attemptAbsoluteDurationLimit&&this.parseDurationToMinutes(e.attemptAbsoluteDurationLimit)>60&&t.push("extended-storage"),e.attemptLimit&&e.attemptLimit>1&&t.push("persistent-storage"),t}isResourceAvailable(e){try{switch(e){case"video-codec":return!!document.createElement("video").canPlayType;case"audio-codec":return!!document.createElement("audio").canPlayType;case"flash-plugin":return navigator.plugins&&Array.from(navigator.plugins).some(e=>"Shockwave Flash"===e.name);case"java-runtime":return navigator.plugins&&Array.from(navigator.plugins).some(e=>"Java"===e.name);case"high-bandwidth":if("connection"in navigator){const e=navigator.connection;return"4g"===e.effectiveType||e.downlink>5}return!0;case"extended-storage":default:return!0;case"persistent-storage":return"localStorage"in window&&"sessionStorage"in window}}catch(e){return!1}}checkSystemLimits(){try{let e=!0;if("memory"in performance){const t=performance.memory;t.usedJSHeapSize/t.jsHeapSizeLimit>.8&&(e=!1)}if("deviceMemory"in navigator&&2>navigator.deviceMemory&&(e=!1),"hardwareConcurrency"in navigator&&2>navigator.hardwareConcurrency&&(e=!1),"connection"in navigator){const t=navigator.connection;(t.saveData||"slow-2g"===t.effectiveType)&&(e=!1)}return{adequate:e}}catch(e){return{adequate:!0}}}hasPendingDeliveryRequests(){return this.activityTree&&this.activityTree.pendingRequests?this.activityTree.pendingRequests.length>0:!("undefined"==typeof window||!window.pendingScormRequests)&&window.pendingScormRequests>0}isDeliveryLocked(){return!(!this.activityTree||!this.activityTree.navigationLocked)||(!(!this.activityTree||!this.activityTree.terminationInProgress)||(!this.checkSystemLimits().adequate||!("undefined"==typeof window||!window.scormMaintenanceMode)))}getPrerequisites(e){const t=[];if(e.sequencingRules&&e.sequencingRules.preConditionRules)for(const i of e.sequencingRules.preConditionRules)if(i.conditions&&i.conditions.length>0)for(const s of i.conditions)s.referencedObjectiveID&&s.referencedObjectiveID!==e.id&&t.push(s.referencedObjectiveID);if(e.parent&&e.sequencingControls&&!e.sequencingControls.choiceExit){const i=e.parent.children;if(i){const s=i.indexOf(e);for(let e=0;s>e;e++){const s=i[e];s&&t.push(s.id)}}}return e.prerequisiteActivities&&t.push(...e.prerequisiteActivities),Array.from(new Set(t))}isPrerequisiteSatisfied(e,t){const i=this.activityTree.getActivity(e);return!!i&&"completed"===i.completionStatus}getObjectiveDependencies(e){const t=[],objectives=e.objectives;if(objectives&&objectives.length>0)for(const e of objectives)e.globalObjectiveID&&t.push(e.globalObjectiveID),!e.satisfiedByMeasure&&e.readNormalizedMeasure&&t.push(e.id+"_measure");if(e.sequencingRules){const i=[...e.sequencingRules.preConditionRules||[],...e.sequencingRules.exitConditionRules||[],...e.sequencingRules.postConditionRules||[]];for(const s of i)if(s.conditions&&s.conditions.length>0)for(const i of s.conditions)i.objectiveReference&&i.objectiveReference!==e.id&&t.push(i.objectiveReference)}return Array.from(new Set(t))}isObjectiveDependencySatisfied(e){if(this.activityTree&&this.activityTree.globalObjectives){const t=this.activityTree.globalObjectives[e];if(t)return!0===t.satisfied&&!0===t.statusKnown}if(e.endsWith("_measure")){const t=e.replace("_measure","");if(this.activityTree&&this.activityTree.globalObjectives){const e=this.activityTree.globalObjectives[t];if(e)return!0===e.measureKnown&&e.normalizedMeasure>=0}}const t=this.activityTree.getActivity(e);return!!t&&t.objectiveSatisfiedStatus&&t.objectiveMeasureStatus}getSequencingRuleDependencies(e){let t=!0;try{if(e.sequencingRules&&e.sequencingRules.preConditionRules)for(const i of e.sequencingRules.preConditionRules)if(i.conditions&&i.conditions.length>0)for(const s of i.conditions)switch(s.conditionType||s.condition){case"activityProgressKnown":e.progressMeasureStatus||(t=!1);break;case"objectiveStatusKnown":case"objectiveSatisfied":this.isObjectiveDependencySatisfied(s.referencedObjectiveID||e.id)||(t=!1);break;case"attemptLimitExceeded":null===e.attemptLimit&&(t=!1);break;case"timeLimitExceeded":e.attemptAbsoluteDurationLimit||e.activityAbsoluteDurationLimit||(t=!1);break;case"always":case"never":break;default:t=!1}if(e.sequencingRules&&e.sequencingRules.exitConditionRules)for(const i of e.sequencingRules.exitConditionRules)if(i.conditions&&i.conditions.length>0)for(const s of i.conditions)["objectiveStatusKnown","objectiveSatisfied"].includes(s.conditionType||s.condition)&&(this.isObjectiveDependencySatisfied(s.referencedObjectiveID||e.id)||(t=!1));if(e.rollupRules&&e.rollupRules.rules)for(const i of e.rollupRules.rules)if(i.conditions&&i.conditions.length>0&&e.children&&e.children.length>0)for(const i of e.children)if(!i.isCompleted){t=!1;break}}catch(e){t=!1}return{satisfied:t}}parseDurationToMinutes(e){return r(e,ne)/60}fireEvent(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn(`Failed to fire delivery validator event ${e}: ${t}`)}}}var rs=Object.defineProperty,ns=(e,t,i)=>((e,t,i)=>t in e?rs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class os{constructor(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n=arguments.length>5?arguments[5]:void 0;ns(this,"activityTree"),ns(this,"sequencingProcess"),ns(this,"rollupProcess"),ns(this,"adlNav"),ns(this,"eventCallback",null),ns(this,"terminationHandler"),ns(this,"deliveryHandler"),ns(this,"navigationValidityService"),ns(this,"globalObjectiveService"),ns(this,"stateManager"),ns(this,"deliveryValidator"),ns(this,"navigationLookAhead"),ns(this,"enhancedDeliveryValidation"),ns(this,"is4thEdition"),this.activityTree=e,this.sequencingProcess=t,this.rollupProcess=i,this.adlNav=s,this.eventCallback=r,this.enhancedDeliveryValidation=!0===n?.enhancedDeliveryValidation,this.is4thEdition=n?.is4thEdition||!1,this.globalObjectiveService=new Xi(r||void 0),this.globalObjectiveService.initialize(e.root);const o={};n?.now&&(o.now=n.now),this.deliveryValidator=new ss(e,r,o);const a={};n?.getCMIData&&(a.getCMIData=n.getCMIData),void 0!==n?.is4thEdition&&(a.is4thEdition=n.is4thEdition),this.terminationHandler=new Di(e,t,i,this.globalObjectiveService.getMap(),r,a);const c={};n?.now&&(c.now=n.now),n?.defaultHideLmsUi&&(c.defaultHideLmsUi=n.defaultHideLmsUi),n?.defaultAuxiliaryResources&&(c.defaultAuxiliaryResources=n.defaultAuxiliaryResources),this.deliveryHandler=new ki(e,i,this.globalObjectiveService.getMap(),s,r,c),this.navigationValidityService=new Wi(e,t,s,r),this.stateManager=new es(e,this.globalObjectiveService,i,s,r),this.navigationLookAhead=this.navigationValidityService.getNavigationLookAhead(),this.setupCallbacks()}setupCallbacks(){this.terminationHandler.setInvalidateCacheCallback(()=>{this.navigationLookAhead.invalidateCache()}),this.deliveryHandler.setCheckActivityCallback(e=>this.deliveryValidator.checkActivity(e)),this.deliveryHandler.setInvalidateCacheCallback(()=>{this.navigationLookAhead.invalidateCache()}),this.deliveryHandler.setUpdateNavigationValidityCallback(()=>{this.navigationValidityService.updateNavigationValidity()}),this.deliveryHandler.setClearSuspendedActivityCallback(()=>{this.terminationHandler.clearSuspendedActivity()}),this.deliveryValidator.setContentDeliveredGetter(()=>this.deliveryHandler.hasContentBeenDelivered()),this.navigationValidityService.setGetEffectiveHideLmsUiCallback(e=>this.deliveryHandler.getEffectiveHideLmsUi(e)),this.stateManager.setGetEffectiveHideLmsUiCallback(e=>this.deliveryHandler.getEffectiveHideLmsUi(e)),this.stateManager.setGetEffectiveAuxiliaryResourcesCallback(e=>this.deliveryHandler.getEffectiveAuxiliaryResources(e)),this.stateManager.setContentDeliveredAccessors(()=>this.deliveryHandler.hasContentBeenDelivered(),e=>this.deliveryHandler.setContentDelivered(e))}processNavigationRequest(e){let t=arguments.length>2?arguments[2]:void 0;const i=this.navigationValidityService.validateRequest(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null);if(!i.valid)return new zi(!1,null,i.exception);if(i.terminationRequest){const s=!!i.sequencingRequest,r=this.terminationHandler.processTerminationRequest(i.terminationRequest,s,t);if(!r.valid)return new zi(!1,null,r.exception||"TB.2.3-1");if(null!==r.sequencingRequest&&(s||r.sequencingRequest!==ze.EXIT)&&(i.sequencingRequest=r.sequencingRequest),!i.sequencingRequest)return i.terminationRequest!==ze.EXIT_ALL&&i.terminationRequest!==ze.ABANDON_ALL||this.fireEvent("onSequencingSessionEnd",{reason:i.terminationRequest===ze.EXIT_ALL?"exit_all":"abandon_all",navigationRequest:e}),new zi(!0,null)}if(i.sequencingRequest){const t=this.sequencingProcess.sequencingRequestProcess(i.sequencingRequest,i.targetActivityId);if(t.endSequencingSession)return this.fireEvent("onSequencingSessionEnd",{reason:"end_of_content",exception:t.exception,navigationRequest:e}),new zi(!1,null,t.exception||"SESSION_ENDED");if(t.exception)return new zi(!1,null,t.exception);if(t.deliveryRequest===Fe.DELIVER&&t.targetActivity)return this.activityTree.root&&(this.rollupProcess.validateRollupStateConsistency(this.activityTree.root)||this.fireEvent("onSequencingDebug",{message:"Rollup state inconsistency detected before delivery",activityId:this.activityTree.root.id})),this.rollupProcess.processGlobalObjectiveMapping(t.targetActivity,this.globalObjectiveService.getMap()),this.processDelivery(t.targetActivity)}return new zi(!1,null,"OP.1-1")}processDelivery(e){if(this.enhancedDeliveryValidation){const t=this.deliveryValidator.validateTreeConsistency(e);if(!t.consistent)return new zi(!1,null,t.exception);const i=this.deliveryValidator.validateResources(e);if(!i.available)return new zi(!1,null,i.exception);const s=this.deliveryValidator.validateConcurrentDelivery(e);if(!s.allowed)return new zi(!1,null,s.exception);const r=this.deliveryValidator.validateDependencies(e);if(!r.satisfied)return new zi(!1,null,r.exception)}const t=this.deliveryHandler.processDeliveryRequest(e);return t.valid&&(this.deliveryHandler.contentDeliveryEnvironmentProcess(t.targetActivity),this.navigationLookAhead.invalidateCache(),this.activityTree.root&&this.rollupProcess.validateRollupStateConsistency(this.activityTree.root)),t}hasContentBeenDelivered(){return this.deliveryHandler.hasContentBeenDelivered()}isDeliveryInProgress(){return this.deliveryHandler.isDeliveryInProgress()}resetContentDelivered(){this.deliveryHandler.resetContentDelivered()}setContentDelivered(e){this.deliveryHandler.setContentDelivered(e)}updateNavigationValidity(){this.navigationValidityService.updateNavigationValidity()}synchronizeGlobalObjectives(){this.globalObjectiveService.synchronize(this.activityTree.root,this.rollupProcess)}getGlobalObjectiveMap(){return this.globalObjectiveService.getMap()}getGlobalObjectiveMapSnapshot(){return this.globalObjectiveService.getSnapshot()}restoreGlobalObjectiveMapSnapshot(e){this.globalObjectiveService.restoreSnapshot(e)}updateGlobalObjective(e,t){this.globalObjectiveService.updateObjective(e,t)}getSequencingState(){return this.stateManager.getState()}restoreSequencingState(e){return this.stateManager.restoreState(e)}getSuspensionState(){return this.stateManager.getSuspensionState()}restoreSuspensionState(e){this.stateManager.restoreSuspensionState(e)}getNavigationLookAhead(){return this.navigationValidityService.getAllPredictions()}predictContinueEnabled(){return this.navigationValidityService.predictContinueEnabled()}predictPreviousEnabled(){return this.navigationValidityService.predictPreviousEnabled()}predictChoiceEnabled(e){return this.navigationValidityService.predictChoiceEnabled(e)}getAvailableChoices(){return this.navigationValidityService.getAvailableChoices()}invalidateNavigationCache(){this.navigationValidityService.invalidateCache()}applyDeliveryControls(e){e.sequencingControls.completionSetByContent||e.completionStatus===H&&(e.completionStatus=k,e.wasAutoCompleted=!0),e.sequencingControls.objectiveSetByContent||e.successStatus===F&&(e.successStatus=P,e.wasAutoSatisfied=!0)}getEffectiveHideLmsUi(e){return this.deliveryHandler.getEffectiveHideLmsUi(e)}getEffectiveAuxiliaryResources(e){return this.deliveryHandler.getEffectiveAuxiliaryResources(e)}getContentActivityData(e){return this.deliveryHandler.getContentActivityData(e)}terminationRequestProcess(request,e,t){return this.terminationHandler.processTerminationRequest(request,e,t)}contentDeliveryEnvironmentProcess(e){this.deliveryHandler.contentDeliveryEnvironmentProcess(e)}endAttemptProcess(e){this.terminationHandler.endAttempt(e)}handleExitTermination(e,t){return this.terminationHandler.handleExitTermination(e,t)}fireEvent(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn(`Failed to fire sequencing event ${e}: ${t}`)}}}var as=Object.defineProperty,cs=(e,t,i)=>((e,t,i)=>t in e?as(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ls{constructor(e,cmi,adl,t,i){let s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};cs(this,"sequencing"),cs(this,"cmi"),cs(this,"adl"),cs(this,"eventService"),cs(this,"loggingService"),cs(this,"activityDeliveryService"),cs(this,"rollupProcess"),cs(this,"overallSequencingProcess",null),cs(this,"sequencingProcess",null),cs(this,"eventListeners",{}),cs(this,"configuration"),cs(this,"isInitialized",!1),cs(this,"isSequencingActive",!1),cs(this,"lastCMIValues",new Map),cs(this,"lastSequencingResult",null),this.sequencing=e,this.cmi=cmi,this.adl=adl,this.eventService=t,this.loggingService=i,this.configuration={autoRollupOnCMIChange:!0,autoProgressOnCompletion:!1,validateNavigationRequests:!0,enableEventSystem:!0,logLevel:"info",now:()=>new Date,...s},this.activityDeliveryService=new St(t,i,{onDeliverActivity:e=>this.handleActivityDelivery(e),onUnloadActivity:e=>this.handleActivityUnload(e),onSequencingComplete:result=>this.handleSequencingComplete(result),onSequencingError:e=>this.handleSequencingError(e)}),this.rollupProcess=new Mi,this.configuration.now&&Re.setNowProvider(this.configuration.now),this.setupCMIChangeWatchers(),this.createSequencingProcesses()}createSequencingProcesses(){try{if(this.sequencing.initialized||this.sequencing.initialize(),this.sequencing.adlNav=this.adl.nav,this.sequencing.activityTree.root){const e={};this.configuration.now&&(e.now=this.configuration.now),this.configuration.getAttemptElapsedSeconds&&(e.getAttemptElapsedSeconds=this.configuration.getAttemptElapsedSeconds),this.configuration.getActivityElapsedSeconds&&(e.getActivityElapsedSeconds=this.configuration.getActivityElapsedSeconds),this.sequencingProcess=new vt(this.sequencing.activityTree,this.sequencing.sequencingRules,this.sequencing.sequencingControls,this.adl.nav,e);const t={};this.configuration.now&&(t.now=this.configuration.now),t.defaultHideLmsUi=[...this.sequencing.hideLmsUi],this.sequencing.auxiliaryResources.length>0&&(t.defaultAuxiliaryResources=this.sequencing.auxiliaryResources.map(e=>({resourceId:e.resourceId,purpose:e.purpose}))),t.getCMIData=()=>this.getCMIDataForTransfer(),this.overallSequencingProcess=new os(this.sequencing.activityTree,this.sequencingProcess,this.rollupProcess,this.adl.nav,(e,t)=>this.handleSequencingProcessEvent(e,t),t),this.sequencing.overallSequencingProcess=this.overallSequencingProcess,this.isInitialized=!0,this.log("info","Sequencing processes created and ready for navigation")}}catch(e){this.log("error","Failed to create sequencing processes: "+e)}}initialize(){try{return this.log("info","Initializing sequencing service for SCO session"),this.isInitialized||this.createSequencingProcesses(),this.shouldAutoStartSequencing()&&!this.isSequencingActive&&this.startSequencing(),this.initializeCMITracking(),this.fireEvent("onSequencingStart",this.sequencing.getCurrentActivity()),this.log("info","Sequencing service initialized successfully"),f}catch(e){const t="Failed to initialize sequencing service: "+e;return this.log("error",t),this.fireEvent("onSequencingError",t,"initialization"),S}}terminate(){try{return this.log("info","Terminating sequencing service"),this.triggerFinalRollup(),this.endSequencing(),this.isInitialized=!1,this.fireEvent("onSequencingEnd"),this.log("info","Sequencing service terminated successfully"),f}catch(e){const t="Failed to terminate sequencing service: "+e;return this.log("error",t),this.fireEvent("onSequencingError",t,"termination"),S}}processNavigationRequest(request,e,t){if(!this.isInitialized||!this.overallSequencingProcess)return this.log("warn",`Navigation request '${request}' ignored - sequencing not initialized`),!1;try{this.log("info",`Processing navigation request: ${request}${e?` (target: ${e})`:""}${t?` (exit: ${t})`:""}`),this.fireEvent("onNavigationRequest",request,e);const i=this.parseNavigationRequest(request);if(null===i)return this.log("warn","Invalid navigation request: "+request),!1;const s=this.overallSequencingProcess.processNavigationRequest(i,e||null,t),r={deliveryRequest:s.valid?Fe.DELIVER:Fe.DO_NOT_DELIVER,targetActivity:s.targetActivity,exception:s.exception||null,endSequencingSession:!1};return this.lastSequencingResult=r,s.valid&&s.targetActivity?(this.activityDeliveryService.processSequencingResult(r),this.overallSequencingProcess.updateNavigationValidity(),this.log("info",`Navigation request '${request}' resulted in activity delivery: ${s.targetActivity.id}`),!0):(s.exception?(this.log("warn",`Navigation request '${request}' failed: ${s.exception}`),this.fireEvent("onSequencingError",s.exception,"navigation")):this.log("info",`Navigation request '${request}' completed with no activity delivery`),s.valid)}catch(e){const t=`Error processing navigation request '${request}': ${e}`;return this.log("error",t),this.fireEvent("onSequencingError",t,"navigation"),!1}}triggerRollupOnCMIChange(e,t,i){if(this.configuration.autoRollupOnCMIChange&&this.isInitialized&&["cmi.completion_status","cmi.success_status","cmi.score.scaled","cmi.score.raw","cmi.score.min","cmi.score.max","cmi.progress_measure","cmi.objectives.n.success_status","cmi.objectives.n.completion_status","cmi.objectives.n.score.scaled"].some(t=>e.startsWith(t)))try{this.log("debug",`Triggering rollup due to CMI change: ${e} = ${i} (was ${t})`);const s=this.sequencing.getCurrentActivity();if(!s)return void this.log("debug","No current activity for rollup");this.updateActivityFromCMI(s),this.rollupProcess.overallRollupProcess(s),this.overallSequencingProcess&&this.overallSequencingProcess.synchronizeGlobalObjectives(),this.overallSequencingProcess&&this.overallSequencingProcess.updateNavigationValidity(),this.fireEvent("onRollupComplete",s),this.log("debug","Rollup completed for activity: "+s.id)}catch(e){const t="Error during rollup on CMI change: "+e;this.log("error",t),this.fireEvent("onSequencingError",t,"rollup")}}setEventListeners(e){this.eventListeners={...this.eventListeners,...e},this.log("debug","Sequencing event listeners updated")}updateConfiguration(e){this.configuration={...this.configuration,...e},this.log("debug","Sequencing configuration updated")}getSequencingState(){return{isInitialized:this.isInitialized,isActive:this.isSequencingActive,currentActivity:this.sequencing.getCurrentActivity(),rootActivity:this.sequencing.getRootActivity(),lastSequencingResult:this.lastSequencingResult}}getOverallSequencingProcess(){return this.overallSequencingProcess}isDeliveryInProgress(){return this.overallSequencingProcess?.isDeliveryInProgress()??!1}setupCMIChangeWatchers(){}initializeCMITracking(){this.lastCMIValues.set("cmi.completion_status",this.cmi.completion_status),this.lastCMIValues.set("cmi.success_status",this.cmi.success_status),this.lastCMIValues.set("cmi.progress_measure",this.cmi.progress_measure),this.cmi.score&&(this.lastCMIValues.set("cmi.score.scaled",this.cmi.score.scaled),this.lastCMIValues.set("cmi.score.raw",this.cmi.score.raw))}shouldAutoStartSequencing(){return!(!this.sequencing.activityTree.root||this.sequencing.getCurrentActivity())}startSequencing(){if(this.overallSequencingProcess)try{this.processNavigationRequest("start")&&(this.isSequencingActive=!0,this.log("info","Automatic sequencing started"))}catch(e){this.log("error","Failed to start automatic sequencing: "+e)}}endSequencing(){this.isSequencingActive=!1,this.activityDeliveryService.reset()}triggerFinalRollup(){try{const e=this.sequencing.getCurrentActivity();e&&(this.updateActivityFromCMI(e),this.rollupProcess.overallRollupProcess(e),this.overallSequencingProcess&&this.overallSequencingProcess.synchronizeGlobalObjectives(),this.log("info","Final rollup completed"))}catch(e){this.log("error","Error during final rollup: "+e)}}updateActivityFromCMI(e){if("unknown"!==this.cmi.completion_status&&(e.completionStatus=this.cmi.completion_status,e.attemptProgressStatus=!0),"unknown"!==this.cmi.success_status&&(e.successStatus=this.cmi.success_status,e.objectiveSatisfiedStatus="passed"===this.cmi.success_status,e.objectiveMeasureStatus=!0,e.primaryObjective&&(e.primaryObjective.progressStatus=!0)),""!==this.cmi.progress_measure){const t=parseFloat(this.cmi.progress_measure);isNaN(t)||(e.progressMeasure=t,e.progressMeasureStatus=!0)}if(this.cmi.score&&""!==this.cmi.score.scaled){const t=parseFloat(this.cmi.score.scaled);isNaN(t)||(e.objectiveNormalizedMeasure=t,e.objectiveMeasureStatus=!0,e.primaryObjective&&(e.primaryObjective.progressStatus=!0))}e.primaryObjective&&e.primaryObjective.updateFromActivity(e)}getCMIDataForTransfer(){const e={completion_status:this.cmi.completion_status,success_status:this.cmi.success_status,progress_measure:this.cmi.progress_measure,score:{scaled:this.cmi.score?.scaled||"",raw:this.cmi.score?.raw||"",min:this.cmi.score?.min||"",max:this.cmi.score?.max||""},objectives:[]};if(this.cmi.objectives&&this.cmi.objectives.childArray)for(const t of this.cmi.objectives.childArray){const i=t;i.id&&e.objectives.push({id:i.id,success_status:i.success_status,completion_status:i.completion_status,progress_measure:i.progress_measure,score:{scaled:i.score?.scaled||"",raw:i.score?.raw||"",min:i.score?.min||"",max:i.score?.max||""}})}return e}parseNavigationRequest(request){let e=request;if(e.startsWith("_")&&"_none_"!==e&&(e=e.substring(1)),request.includes("choice"))return Gi.CHOICE;if(request.includes("jump"))return Gi.JUMP;switch(e){case"start":return Gi.START;case"resumeAll":return Gi.RESUME_ALL;case"continue":return Gi.CONTINUE;case"previous":return Gi.PREVIOUS;case"exit":return Gi.EXIT;case"exitAll":return Gi.EXIT_ALL;case"abandon":return Gi.ABANDON;case"abandonAll":return Gi.ABANDON_ALL;case"suspendAll":return Gi.SUSPEND_ALL;case"_none_":return Gi.NOT_VALID;default:return null}}handleActivityDelivery(e){this.log("info",`Activity delivered: ${e.id} - ${e.title}`),this.fireEvent("onActivityDelivery",e)}handleActivityUnload(e){this.log("info",`Activity unloaded: ${e.id} - ${e.title}`),this.fireEvent("onActivityUnload",e)}handleSequencingComplete(result){this.log("debug","Sequencing completed",result)}handleSequencingError(e){this.log("error","Sequencing error: "+e),this.fireEvent("onSequencingError",e,"sequencing")}fireEvent(e){if(this.configuration.enableEventSystem){for(var t=arguments.length,i=Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];"onSequencingDebug"!==e&&this.fireDebugEvent(e+" fired",{eventType:e,argsLength:i.length});try{const t=this.eventListeners[e];if(t&&"function"==typeof t)try{t(...i),this.log("debug",`Internal listener for ${e} executed successfully`)}catch(t){this.log("error",`Internal listener for ${e} failed: ${t}`)}try{this.eventService.processListeners("Sequencing."+e,i[0],...i.slice(1)),this.log("debug",`Event service listeners for ${e} processed`)}catch(t){this.log("warn",`Event service failed for ${e}: ${t}`)}try{if("undefined"!=typeof window&&window.scormSequencingEvents){const t=window.scormSequencingEvents;t[e]&&"function"==typeof t[e]&&(t[e](...i),this.log("debug",`Global listener for ${e} executed`))}}catch(t){this.log("warn",`Global listener for ${e} failed: ${t}`)}}catch(t){this.log("error",`Critical error firing event ${e}: ${t}`)}}}fireDebugEvent(e,t){try{const i=this.eventListeners.onSequencingDebug;i&&"function"==typeof i&&i(e,{timestamp:(new Date).toISOString(),...t});try{this.eventService.processListeners("Sequencing.onSequencingDebug",e,{timestamp:(new Date).toISOString(),...t})}catch(e){}}catch(e){console.debug("Debug event failed: "+e)}}fireActivityAttemptStart(e){this.fireEvent("onActivityAttemptStart",e),this.fireDebugEvent("Activity attempt started",{activityId:e.id,title:e.title,attemptCount:e.attemptCount})}fireActivityAttemptEnd(e){this.fireEvent("onActivityAttemptEnd",e),this.fireDebugEvent("Activity attempt ended",{activityId:e.id,title:e.title,completionStatus:e.completionStatus,successStatus:e.successStatus})}fireLimitConditionCheck(e,result){this.fireEvent("onLimitConditionCheck",e,result),this.fireDebugEvent("Limit condition check",{activityId:e.id,result:result,attemptCount:e.attemptCount,attemptLimit:e.attemptLimit})}fireNavigationValidityUpdate(e){this.fireEvent("onNavigationValidityUpdate",e),this.fireDebugEvent("Navigation validity updated",{validity:e})}fireSequencingStateChange(e){this.fireEvent("onSequencingStateChange",e),this.fireDebugEvent("Sequencing state changed",{stateKeys:Object.keys(e)})}handleSequencingProcessEvent(e,t){try{switch(e){case"onActivityDelivery":this.fireEvent("onActivityDelivery",t);break;case"onLimitConditionCheck":this.fireLimitConditionCheck(t.activity,t.result);break;case"onActivityAttemptStart":this.fireActivityAttemptStart(t);break;case"onActivityAttemptEnd":this.fireActivityAttemptEnd(t);break;case"onNavigationValidityUpdate":this.fireNavigationValidityUpdate(t);break;case"onSequencingSessionEnd":this.fireEvent("onSequencingSessionEnd",t);break;default:this.fireDebugEvent("Sequencing process event: "+e,t)}}catch(t){this.log("error",`Error handling sequencing process event ${e}: ${t}`)}}log(e,t,i){const s=["debug","info","warn","error"],r=this.configuration.logLevel||"info";if(s.indexOf(e)>=s.indexOf(r))switch(e){case"debug":this.loggingService.debug(`[Sequencing] ${t}${i?" - "+JSON.stringify(i):""}`);break;case"info":this.loggingService.info(`[Sequencing] ${t}${i?" - "+JSON.stringify(i):""}`);break;case"warn":this.loggingService.warn(`[Sequencing] ${t}${i?" - "+JSON.stringify(i):""}`);break;case"error":this.loggingService.error(`[Sequencing] ${t}${i?" - "+JSON.stringify(i):""}`)}}}class us{loadFromFlattenedJSON(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;if(!s())return void console.error("loadFromFlattenedJSON can only be called before the call to lmsInitialize.");const n=/^(cmi\.interactions\.)(\d+)\.(.*)$/,o=/^(cmi\.objectives\.)(\d+)\.(.*)$/,interactions=[],objectives=[],a=[];for(const t in e)if({}.hasOwnProperty.call(e,t)){const i=t.match(n);if(i){interactions.push({key:t,value:e[t],index:+i[2],field:i[3]||""});continue}const s=t.match(o);if(s){objectives.push({key:t,value:e[t],index:+s[2],field:s[3]||""});continue}a.push({key:t,value:e[t]})}interactions.sort((e,t)=>e.index!==t.index?e.index-t.index:"id"===e.field?-1:"id"===t.field?1:"type"===e.field?-1:"type"===t.field?1:e.field.localeCompare(t.field)),objectives.sort((e,t)=>e.index!==t.index?e.index-t.index:"id"===e.field?-1:"id"===t.field?1:e.field.localeCompare(t.field)),a.sort((e,t)=>e.key.localeCompare(t.key));const c=e=>{e.forEach(e=>{const n={};n[e.key]=e.value,this.loadFromJSON(function(e){if(Object(e)!==e||Array.isArray(e))return e;const result={},pattern=/\.?([^.[\]]+)|\[(\d+)]/g;return Object.keys(e).filter(t=>({}.hasOwnProperty.call(e,t))).forEach(t=>{let i=result,s="";const r=RegExp(pattern);Array.from({length:t.match(RegExp(pattern,"g"))?.length??0},()=>r.exec(t)).forEach(e=>{e&&(i=i[s]??(i[s]=e[2]?[]:{}),s=e[2]||e[1]||"")}),i[s]=e[t]}),result[""]??result}(n),t,i,s,r)})};c(interactions),c(objectives),c(a)}loadFromJSON(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;if(s()){t=void 0!==t?t:"cmi",r(e);for(const n in e)if({}.hasOwnProperty.call(e,n)&&e[n]){const o=(t?t+".":"")+n,a=e[n];if(a.constructor===Array){for(let e=0;a.length>e;e++)if(a[e]){const t=a[e],n=`${o}.${e}`;t.constructor===Object?this.loadFromJSON(t,n,i,s,r):i(n,t)}}else a.constructor===Object?this.loadFromJSON(a,o,i,s,r):i(o,a)}}else console.error("loadFromJSON can only be called before the call to lmsInitialize.")}renderCMIToJSONString(cmi,e){return e?JSON.stringify({cmi:cmi}):JSON.stringify({cmi:cmi},(e,t)=>void 0===t?null:t,2)}renderCMIToJSONObject(cmi,e){return JSON.parse(this.renderCMIToJSONString(cmi,e))}getCommitObject(e,t,i,s,r,n){const o=t||e,a=i?s(e,o):r(e,o);return[B.DEBUG,"1",1,"DEBUG"].includes(n)&&(console.debug("Commit (terminated: "+(e?"yes":"no")+"): "),console.debug(a)),a}}var hs=Object.defineProperty,ds=(e,t,i)=>((e,t,i)=>t in e?hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ms{constructor(e,t){ds(this,"settings"),ds(this,"error_codes"),this.settings=e,this.error_codes=t}processHttpRequest(e,t){return arguments.length>2&&void 0!==arguments[2]&&arguments[2]?this._handleImmediateRequest(e,t):this._performSyncXHR(e,t)}_handleImmediateRequest(e,t){const i=this.settings.requestHandler(t)??t,{body:s}=this._prepareRequestBody(i),r=navigator.sendBeacon(e,new Blob([s],{type:"text/plain;charset=UTF-8"}));return{result:r?"true":"false",errorCode:r?0:this.error_codes.GENERAL_COMMIT_FAILURE||391}}_performSyncXHR(e,t){const i=this.settings.requestHandler(t)??t,{body:s,contentType:r}=this._prepareRequestBody(i),n=new XMLHttpRequest;n.open("POST",e,!1),n.setRequestHeader("Content-Type",r),Object.entries(this.settings.xhrHeaders).forEach(e=>{let[t,i]=e;n.setRequestHeader(t,i+"")}),this.settings.xhrWithCredentials&&(n.withCredentials=!0);try{return n.send(s),this.settings.xhrResponseHandler(n)}catch(e){return{result:S,errorCode:this.error_codes.GENERAL_COMMIT_FAILURE||391,errorMessage:e instanceof Error?e.message:e+""}}}_prepareRequestBody(e){return{body:e instanceof Array?e.join("&"):JSON.stringify(e),contentType:e instanceof Array?"application/x-www-form-urlencoded":this.settings.commitRequestDataType}}updateSettings(e){this.settings=e}}function ps(e,t,i,s){return Vt(e,t,i,T.TYPE_MISMATCH,w,s)}function _s(e,t,i,s){if(""===t)throw new w(e,T.VALUE_OUT_OF_RANGE);return Ht(e,t,i,T.VALUE_OUT_OF_RANGE,w)}const vs=new class{validateScore(e,t,i,s,r,n,o){return Vt(e,t,i,r,o)&&(!s||Ht(e,t,s,n,o))}validateScorm12Audio(e,t){return ps(e,t,W)&&_s(e,t,"-1#100")}validateScorm12Language(e,t){return ps(e,t,G)}validateScorm12Speed(e,t){return ps(e,t,W)&&_s(e,t,"-100#100")}validateScorm12Text(e,t){return ps(e,t,W)&&_s(e,t,"-1#1")}validateReadOnly(e,t){if(t)throw new w(e,T.READ_ONLY_ELEMENT)}};var gs=Object.defineProperty,fs=(e,t,i)=>((e,t,i)=>t in e?gs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ss{constructor(e,t,i,s,r,n,o,a,c){if(fs(this,"_timeout"),fs(this,"_error_codes"),fs(this,"_settings",U),fs(this,"_httpService"),fs(this,"_eventService"),fs(this,"_serializationService"),fs(this,"_errorHandlingService"),fs(this,"_loggingService"),fs(this,"_offlineStorageService"),fs(this,"_cmiValueAccessService"),fs(this,"_courseId",""),fs(this,"startingData"),fs(this,"currentState"),new.target===Ss)throw new TypeError("Cannot construct BaseAPI instances directly");this.currentState=0,this._error_codes=e,t&&(this.settings={...U,...t}),void 0!==t?.asyncCommit&&void 0===t.useAsynchronousCommits&&void 0===t.throttleCommits&&(console.warn("DEPRECATED: 'asyncCommit' setting is deprecated and will be removed in a future version. Use 'useAsynchronousCommits: true' and 'throttleCommits: true' instead."),t.asyncCommit&&(this.settings.useAsynchronousCommits=!0,this.settings.throttleCommits=!0)),!this.settings.useAsynchronousCommits&&this.settings.throttleCommits&&(console.warn("throttleCommits cannot be used with synchronous commits. Setting throttleCommits to false."),this.settings.throttleCommits=!1),this._loggingService=a||It(),this._loggingService.setLogLevel(this.settings.logLevel),this._loggingService.setLogHandler(this.settings.onLogMessage?this.settings.onLogMessage:$),i?this._httpService=i:this.settings.httpService?this._httpService=this.settings.httpService:this.settings.useAsynchronousCommits?(console.warn("WARNING: useAsynchronousCommits=true is not SCORM compliant. Commit failures will not be reported to the SCO, which may cause data loss. This setting should only be used for specific legacy compatibility cases."),this._httpService=new Ct(this.settings,this._error_codes)):this._httpService=new ms(this.settings,this._error_codes),this._eventService=s||new Pt((e,t,i,s)=>this.apiLog(e,t,i,s)),this._serializationService=r||new us,this._errorHandlingService=o||new qt(this._error_codes,(e,t,i,s)=>this.apiLog(e,t,i||B.ERROR,s),(e,t)=>this.getLmsErrorMessageDetails(e,t),void 0),this.settings.enableOfflineSupport&&(this._offlineStorageService=c||new kt(this.settings,this._error_codes,(e,t,i,s)=>this.apiLog(e,t,i,s)),this.settings.courseId&&(this._courseId=this.settings.courseId),this.settings.syncOnTerminate&&this._eventService.on("BeforeTerminate",()=>{this._offlineStorageService?.isDeviceOnline()&&this._courseId&&this._offlineStorageService.hasPendingOfflineData(this._courseId).then(e=>{if(e)return this.apiLog("BeforeTerminate","Syncing pending offline data before termination",B.INFO),this._offlineStorageService?.syncOfflineData()}).then(e=>{e?this.processListeners("OfflineDataSynced"):!1===e&&this.processListeners("OfflineDataSyncFailed")}).catch(e=>{this.apiLog("BeforeTerminate","Error syncing offline data: "+e,B.ERROR),this.processListeners("OfflineDataSyncFailed")})}),this._offlineStorageService&&this._courseId&&this._offlineStorageService.getOfflineData(this._courseId).then(e=>{e&&(this.apiLog("constructor","Found offline data to restore",B.INFO),this.loadFromJSON(e.runtimeData))}).catch(e=>{this.apiLog("constructor","Error retrieving offline data: "+e,B.ERROR)})),this._cmiValueAccessService=new Mt({errorCodes:this._error_codes,getLastErrorCode:()=>this.lastErrorCode,setLastErrorCode:e=>{this.lastErrorCode=e},throwSCORMError:(e,t,i)=>this.throwSCORMError(e,t,i),isInitialized:()=>this.isInitialized(),validateCorrectResponse:(e,t)=>this.validateCorrectResponse(e,t),checkForDuplicateId:(e,t)=>this._checkForDuplicateId(e,t),getChildElement:(e,t,i)=>this.getChildElement(e,t,i),apiLog:(e,t,i)=>this.apiLog(e,t,i),checkObjectHasProperty:(e,t)=>this._checkObjectHasProperty(e,t),getDataModel:()=>this})}get lastErrorCode(){return this._errorHandlingService?.lastErrorCode??"0"}set lastErrorCode(e){this._errorHandlingService&&(this._errorHandlingService.lastErrorCode=e)}get eventService(){return this._eventService}get loggingService(){return this._loggingService}commonReset(e){this.apiLog("reset","Called",B.INFO),this.settings={...this.settings,...e},this.clearScheduledCommit(),this.currentState=0,this.lastErrorCode="0",this._eventService.reset(),this.startingData={},this._offlineStorageService&&(this._offlineStorageService.updateSettings(this.settings),e?.courseId&&(this._courseId=e.courseId))}initialize(e,t,i){let s=S;return this.isInitialized()?this.throwSCORMError("api",this._error_codes.INITIALIZED,t):this.isTerminated()?this.throwSCORMError("api",this._error_codes.TERMINATED,i):(this.settings.selfReportSessionTime&&this.cmi.setStartTime(),this.currentState=1,this.lastErrorCode="0",s=f,this.processListeners(e),this.settings.enableOfflineSupport&&this._offlineStorageService&&this._courseId&&this.settings.syncOnInitialize&&this._offlineStorageService.isDeviceOnline()&&this._offlineStorageService.hasPendingOfflineData(this._courseId).then(t=>{t&&(this.apiLog(e,"Syncing pending offline data on initialization",B.INFO),this._offlineStorageService?.syncOfflineData().then(t=>{t&&(this.apiLog(e,"Successfully synced offline data",B.INFO),this.processListeners("OfflineDataSynced"))}))})),this.apiLog(e,"returned: "+s,B.INFO),this.clearSCORMError(s),s}apiLog(e,t,i,s){t=function(e,t,i){let s=e?(e+"").padEnd(20)+": ":"";return i&&(s+=i,s=s.padEnd(70)),s+=t??"",s}(e,t,s),this._loggingService.log(i,t)}get settings(){return this._settings}set settings(e){const t=this._settings;this._settings={...this._settings,...e},this._httpService?.updateSettings(this._settings),void 0!==e.logLevel&&e.logLevel!==t.logLevel&&this._loggingService?.setLogLevel(e.logLevel),void 0!==e.onLogMessage&&e.onLogMessage!==t.onLogMessage&&this._loggingService?.setLogHandler(e.onLogMessage)}terminate(e,t){let i=f,s=!1;if(this.isNotInitialized()){const e=this._error_codes.TERMINATION_BEFORE_INIT??0;this.throwSCORMError("api",e),112===e&&(i=S)}else if(t&&this.isTerminated()){const e=this._error_codes.MULTIPLE_TERMINATION??0;this.throwSCORMError("api",e),113===e&&(i=S)}else{s=!0,this.processListeners("BeforeTerminate");const result=this.storeData(!0);if((result.errorCode??0)>0)result.errorMessage&&this.apiLog("terminate","Terminate failed with error: "+result.errorMessage,B.ERROR),result.errorDetails&&this.apiLog("terminate","Error details: "+JSON.stringify(result.errorDetails),B.DEBUG),this.throwSCORMError("api",result.errorCode??0),i=S;else{this.currentState=2,t&&(this.lastErrorCode="0");const e=result?.result??f;i="boolean"==typeof e?e+"":e}this.processListeners(e)}return this.apiLog(e,"returned: "+i,B.INFO),s&&this.clearSCORMError(i),i}getValue(e,t,i){let s="";if(this.checkState(t,this._error_codes.RETRIEVE_BEFORE_INIT??0,this._error_codes.RETRIEVE_AFTER_TERM??0)){try{s=this.getCMIValue(i)}catch(e){s=this.handleValueAccessException(i,e,s)}this.processListeners(e,i)}return this.apiLog(e,": returned: "+s,B.INFO,i),void 0===s?"":("0"===this.lastErrorCode&&this.clearSCORMError(s),s)}setValue(e,t,i,s,r){void 0!==r&&(r+="");let n=S;if(this.checkState(i,this._error_codes.STORE_BEFORE_INIT??0,this._error_codes.STORE_AFTER_TERM??0)){try{n=this.setCMIValue(s,r)}catch(e){n=this.handleValueAccessException(s,e,n)}this.processListeners(e,s,r)}return void 0===n&&(n=S),this.lastErrorCode+""=="0"&&this.settings.autocommit&&this.scheduleCommit(1e3*this.settings.autocommitSeconds,t),this.apiLog(e,": "+r+": result: "+n,B.INFO,s),"0"===this.lastErrorCode&&this.clearSCORMError(n),n}commit(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.clearScheduledCommit();let i=f;if(this.isNotInitialized()){const e=this._error_codes.COMMIT_BEFORE_INIT??0;this.throwSCORMError("api",e),142===e&&(i=S)}else if(t&&this.isTerminated()){const e=this._error_codes.COMMIT_AFTER_TERM??0;this.throwSCORMError("api",e),143===e&&(i=S)}else{const result=this.storeData(!1),s=result.errorCode??0;s>0&&(result.errorMessage&&this.apiLog("commit","Commit failed with error: "+result.errorMessage,B.ERROR),result.errorDetails&&this.apiLog("commit","Error details: "+JSON.stringify(result.errorDetails),B.DEBUG),this.throwSCORMError("api",s));const r=result?.result??S;i="boolean"==typeof r?r+"":r,this.apiLog(e," Result: "+i,B.DEBUG,"HttpRequest"),t&&0===s&&(this.lastErrorCode="0"),this.processListeners(e),this.settings.enableOfflineSupport&&this._offlineStorageService&&this._offlineStorageService.isDeviceOnline()&&this._courseId&&this._offlineStorageService.hasPendingOfflineData(this._courseId).then(t=>{t&&(this.apiLog(e,"Syncing pending offline data",B.INFO),this._offlineStorageService?.syncOfflineData().then(t=>{t?(this.apiLog(e,"Successfully synced offline data",B.INFO),this.processListeners("OfflineDataSynced")):this.apiLog(e,"Failed to sync some offline data",B.WARN)}))})}return this.apiLog(e,"returned: "+i,B.INFO),this.isNotInitialized()||t&&this.isTerminated()||this.clearSCORMError(i),i}getLastError(e){const t=this.lastErrorCode+"";return this.processListeners(e),this.apiLog(e,"returned: "+t,B.INFO),t}getErrorString(e,t){let i="";return null!==t&&""!==t&&(i=this.getLmsErrorMessageDetails(t),this.processListeners(e)),i.length>255&&(i=i.substring(0,255)),this.apiLog(e,"returned: "+i,B.INFO),i}getDiagnostic(e,t){let i="";const s=""===t?this.lastErrorCode+"":t;if(null!==s&&""!==s){const t=this._errorHandlingService.lastDiagnostic;i=t&&s+""==this.lastErrorCode+""?t:this.getLmsErrorMessageDetails(s,!0),this.processListeners(e)}return i.length>255&&(i=i.substring(0,255)),this.apiLog(e,"returned: "+i,B.INFO),i}checkState(e,t,i){return this.isNotInitialized()?(this.throwSCORMError("api",t),!1):!e||!this.isTerminated()||(this.throwSCORMError("api",i),!1)}_checkForDuplicateId(e,t){const i=(e,t)=>{if(e&&"object"==typeof e&&t in e){const i=e[t];return i instanceof x?i:void 0}},s=(e,t,i)=>{for(let s=0;e.childArray.length>s;s++)if(s!==t){const t=e.childArray[s];if(t&&"object"==typeof t&&"id"in t&&t.id===i)return!0}return!1},r=e.match(/^cmi\.objectives\.(\d+)\.id$/);if(r&&r[1]){const e=parseInt(r[1],10),objectives=i(this.cmi,"objectives");return!!objectives&&s(objectives,e,t)}const n=e.match(/^cmi\.interactions\.(\d+)\.id$/);if(n&&n[1]){const e=parseInt(n[1],10),interactions=i(this.cmi,"interactions");return!!interactions&&s(interactions,e,t)}const o=e.match(/^cmi\.interactions\.(\d+)\.objectives\.(\d+)\.id$/);if(o&&o[1]&&o[2]){const e=parseInt(o[1],10),r=parseInt(o[2],10),interactions=i(this.cmi,"interactions");if(interactions){const n=interactions.childArray[e];if(n){const objectives=i(n,"objectives");if(objectives)return s(objectives,r,t)}}return!1}return!1}getLmsErrorMessageDetails(e){throw Error("The getLmsErrorMessageDetails method has not been implemented")}getCMIValue(e){throw Error("The getCMIValue method has not been implemented")}setCMIValue(e,t){throw Error("The setCMIValue method has not been implemented")}_commonSetCMIValue(e,t,i,s){return this._cmiValueAccessService.setCMIValue(e,t,i,s)}_commonGetCMIValue(e,t,i){return this._cmiValueAccessService.getCMIValue(e,t,i)}isInitialized(){return 1===this.currentState}isNotInitialized(){return 0===this.currentState}isTerminated(){return 2===this.currentState}on(e,t){this._eventService.on(e,t)}off(e,t){this._eventService.off(e,t)}clear(e){this._eventService.clear(e)}processListeners(e,t,i){this._eventService.processListeners(e,t,i)}throwSCORMError(e,t,i){this._errorHandlingService.throwSCORMError(e,t??0,i)}clearSCORMError(e){this._errorHandlingService.clearSCORMError(e)}loadFromFlattenedJSON(e,t){t||(t=""),this._serializationService.loadFromFlattenedJSON(e,t,(e,t)=>this.setCMIValue(e,t),()=>this.isNotInitialized(),e=>{this.startingData=e})}getFlattenedCMI(){return o(this.renderCMIToJSONObject())}loadFromJSON(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";t&&""!==t||Object.hasOwnProperty.call(e,"cmi")||Object.hasOwnProperty.call(e,"adl")||(t="cmi"),this._serializationService.loadFromJSON(e,t,(e,t)=>this.setCMIValue(e,t),()=>this.isNotInitialized(),e=>{this.startingData=e})}renderCMIToJSONString(){return this._serializationService.renderCMIToJSONString(this.cmi,this.settings.sendFullCommit)}renderCMIToJSONObject(){return this._serializationService.renderCMIToJSONObject(this.cmi,this.settings.sendFullCommit)}processHttpRequest(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.settings.enableOfflineSupport&&this._offlineStorageService&&!this._offlineStorageService.isDeviceOnline()&&this._courseId?(this.apiLog("processHttpRequest","Device is offline, storing data locally",B.INFO),t&&"object"==typeof t&&"cmi"in t?this._offlineStorageService.storeOffline(this._courseId,t):(this.apiLog("processHttpRequest","Invalid commit data format for offline storage",B.ERROR),{result:S,errorCode:this._error_codes.GENERAL??101})):this._httpService.processHttpRequest(e,t,i,(e,t,i,s)=>this.apiLog(e,t,i,s),(e,t,i)=>this.processListeners(e,t,i))}scheduleCommit(e,t){this._timeout||(this._timeout=new ye(this,e,t),this.apiLog("scheduleCommit","scheduled",B.DEBUG,""))}clearScheduledCommit(){this._timeout&&(this._timeout.cancel(),this._timeout=void 0,this.apiLog("clearScheduledCommit","cleared",B.DEBUG,""))}_checkObjectHasProperty(e,t){return null!=e&&"object"==typeof e&&(Object.hasOwnProperty.call(e,t)||null!=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t)||t in e)}handleValueAccessException(e,t,i){return t instanceof g?(this.lastErrorCode=t.errorCode+"",""!==i&&(i=S),this.throwSCORMError(e,t.errorCode,t.errorMessage)):this.throwSCORMError(e,this._error_codes.GENERAL,t instanceof Error&&t.message?t.message:"Unknown error"),i}getCommitObject(e){return this._serializationService.getCommitObject(e,this.settings.alwaysSendTotalTime,this.settings.renderCommonCommitFields,(e,t)=>this.renderCommitObject(e,t),(e,t)=>this.renderCommitCMI(e,t),this.settings.logLevel)}}var bs=Object.defineProperty,ys=(e,t,i)=>((e,t,i)=>t in e?bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Cs extends d{constructor(e){super(e.CMIElement),ys(this,"__children"),ys(this,"__score_range"),ys(this,"__invalid_error_code"),ys(this,"__invalid_type_code"),ys(this,"__invalid_range_code"),ys(this,"__decimal_regex"),ys(this,"__error_class"),ys(this,"_raw",""),ys(this,"_min",""),ys(this,"_max"),this.__children=e.score_children||b,this.__score_range=!!e.score_range&&Z,this._max=e.max||""===e.max?e.max:"100",this.__invalid_error_code=e.invalidErrorCode||T.INVALID_SET_VALUE,this.__invalid_type_code=e.invalidTypeCode||T.TYPE_MISMATCH,this.__invalid_range_code=e.invalidRangeCode||T.VALUE_OUT_OF_RANGE,this.__decimal_regex=e.decimalRegex||J,this.__error_class=e.errorClass}reset(){this._initialized=!1,this._raw="",this._min=""}get _children(){return this.__children}set _children(_children){throw new this.__error_class(this._cmi_element+"._children",this.__invalid_error_code)}get raw(){return this._raw}set raw(e){vs.validateScore(this._cmi_element+".raw",e,this.__decimal_regex,this.__score_range,this.__invalid_type_code,this.__invalid_range_code,this.__error_class)&&(this._raw=e)}get min(){return this._min}set min(e){vs.validateScore(this._cmi_element+".min",e,this.__decimal_regex,this.__score_range,this.__invalid_type_code,this.__invalid_range_code,this.__error_class)&&(this._min=e)}get max(){return this._max}set max(e){vs.validateScore(this._cmi_element+".max",e,this.__decimal_regex,this.__score_range,this.__invalid_type_code,this.__invalid_range_code,this.__error_class)&&(this._max=e)}getScoreObject(){const e={};return Number.isNaN(Number.parseFloat(this.raw))||(e.raw=Number.parseFloat(this.raw)),Number.isNaN(Number.parseFloat(this.min))||(e.min=Number.parseFloat(this.min)),Number.isNaN(Number.parseFloat(this.max))||(e.max=Number.parseFloat(this.max)),e}toJSON(){this.jsonString=!0;const result={raw:this.raw,min:this.min,max:this.max};return this.jsonString=!1,result}}var As=Object.defineProperty,Es=(e,t,i)=>((e,t,i)=>t in e?As(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ws extends d{constructor(){super("cmi.core"),Es(this,"score"),Es(this,"__children","student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,lesson_mode,exit,session_time"),Es(this,"_student_id",""),Es(this,"_student_name",""),Es(this,"_lesson_location",""),Es(this,"_credit",""),Es(this,"_lesson_status","not attempted"),Es(this,"_entry",""),Es(this,"_total_time",""),Es(this,"_lesson_mode","normal"),Es(this,"_exit",""),Es(this,"_session_time","00:00:00"),Es(this,"_suspend_data",""),this.score=new Cs({CMIElement:"cmi.core.score",score_children:b,score_range:Z,invalidErrorCode:T.INVALID_SET_VALUE,invalidTypeCode:T.TYPE_MISMATCH,invalidRangeCode:T.VALUE_OUT_OF_RANGE,errorClass:w})}initialize(){super.initialize(),this.score?.initialize()}reset(){this._initialized=!1,this._exit="",this._entry="",this._session_time="00:00:00",this.score?.reset()}get _children(){return this.__children}set _children(_children){throw new w(this._cmi_element+"._children",T.INVALID_SET_VALUE)}get student_id(){return this._student_id}set student_id(student_id){if(this.initialized)throw new w(this._cmi_element+".student_id",T.READ_ONLY_ELEMENT);this._student_id=student_id}get student_name(){return this._student_name}set student_name(student_name){if(this.initialized)throw new w(this._cmi_element+".student_name",T.READ_ONLY_ELEMENT);this._student_name=student_name}get lesson_location(){return this._lesson_location}set lesson_location(lesson_location){ps(this._cmi_element+".lesson_location",lesson_location,G,!0)&&(this._lesson_location=lesson_location)}get credit(){return this._credit}set credit(credit){if(this.initialized)throw new w(this._cmi_element+".credit",T.READ_ONLY_ELEMENT);ps(this._cmi_element+".credit",credit,"^(credit|no-credit)$",!0)&&(this._credit=credit)}get lesson_status(){return this._lesson_status}set lesson_status(lesson_status){this.initialized?ps(this._cmi_element+".lesson_status",lesson_status,"^(passed|completed|failed|incomplete|browsed)$")&&(this._lesson_status=lesson_status):ps(this._cmi_element+".lesson_status",lesson_status,Q)&&(this._lesson_status=lesson_status)}get entry(){return this._entry}set entry(entry){if(this.initialized)throw new w(this._cmi_element+".entry",T.READ_ONLY_ELEMENT);ps(this._cmi_element+".entry",entry,"^(ab-initio|resume|)$",!0)&&(this._entry=entry)}get total_time(){return this._total_time}set total_time(total_time){if(this.initialized)throw new w(this._cmi_element+".total_time",T.READ_ONLY_ELEMENT);if(ps(this._cmi_element+".total_time",total_time,Y,!0))if(total_time){const e=s(total_time,Y);this._total_time=t(e)}else this._total_time=total_time}get lesson_mode(){return this._lesson_mode}set lesson_mode(lesson_mode){if(this.initialized)throw new w(this._cmi_element+".lesson_mode",T.READ_ONLY_ELEMENT);ps(this._cmi_element+".lesson_mode",lesson_mode,"^(normal|browse|review)$")&&(this._lesson_mode=lesson_mode)}get exit(){if(!this.jsonString)throw new w(this._cmi_element+".exit",T.WRITE_ONLY_ELEMENT);return this._exit}set exit(exit){"normal"===exit&&(console.warn("SCORM 1.2: Received non-standard value 'normal' for cmi.core.exit; normalizing to empty string."),exit=""),ps(this._cmi_element+".exit",exit,"^(time-out|suspend|logout|)$",!0)&&(this._exit=exit)}get session_time(){if(!this.jsonString)throw new w(this._cmi_element+".session_time",T.WRITE_ONLY_ELEMENT);return this._session_time}set session_time(session_time){if(ps(this._cmi_element+".session_time",session_time,Y)){const e=s(session_time,Y);this._session_time=t(e)}}get suspend_data(){return this._suspend_data}set suspend_data(suspend_data){ps(this._cmi_element+".suspend_data",suspend_data,"^[\\s\\S]{0,64000}$",!0)&&(this._suspend_data=suspend_data)}getCurrentTotalTime(e){let i=this._session_time;if(void 0!==e){const s=(new Date).getTime()-e;i=t(s/1e3)}return r=this._total_time,n=i,"string"==typeof(o=RegExp(Y))&&(o=RegExp(o)),t(s(r,o)+s(n,o));var r,n,o}toJSON(){this.jsonString=!0;const result={student_id:this.student_id,student_name:this.student_name,lesson_location:this.lesson_location,credit:this.credit,lesson_status:this.lesson_status,entry:this.entry,lesson_mode:this.lesson_mode,exit:this.exit,session_time:this.session_time,score:this.score};return this.jsonString=!1,result}}var Ms=Object.defineProperty,Os=(e,t,i)=>((e,t,i)=>t in e?Ms(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);let Rs=class extends x{constructor(){super({CMIElement:"cmi.objectives",children:y,errorCode:T.INVALID_SET_VALUE,errorClass:w})}},Ts=class extends d{constructor(){super("cmi.objectives.n"),Os(this,"score"),Os(this,"_id",""),Os(this,"_status",""),this.score=new Cs({CMIElement:"cmi.objectives.n.score",score_children:b,score_range:Z,invalidErrorCode:T.INVALID_SET_VALUE,invalidTypeCode:T.TYPE_MISMATCH,invalidRangeCode:T.VALUE_OUT_OF_RANGE,errorClass:w})}reset(){this._initialized=!1,this._id="",this._status="",this.score?.reset()}get id(){return this._id}set id(id){ps(this._cmi_element+".id",id,K)&&(this._id=id)}get status(){return this._status}set status(status){ps(this._cmi_element+".status",status,Q)&&(this._status=status)}toJSON(){this.jsonString=!0;const result={id:this.id,status:this.status,score:this.score};return this.jsonString=!1,result}};var js=Object.defineProperty,Is=(e,t,i)=>((e,t,i)=>t in e?js(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ns extends d{constructor(e){super("cmi.student_data"),Is(this,"__children"),Is(this,"_mastery_score",""),Is(this,"_max_time_allowed",""),Is(this,"_time_limit_action",""),this.__children=e||"mastery_score,max_time_allowed,time_limit_action"}reset(){this._initialized=!1}get _children(){return this.__children}set _children(_children){throw new w(this._cmi_element+"._children",T.INVALID_SET_VALUE)}get mastery_score(){return this._mastery_score}set mastery_score(mastery_score){if(vs.validateReadOnly(this._cmi_element+".mastery_score",this.initialized),null==mastery_score)return;let e=mastery_score;"string"!=typeof e&&(e+=""),""!==e?ps(this._cmi_element+".mastery_score",e,J)&&_s(this._cmi_element+".mastery_score",e,Z)&&(this._mastery_score=e):this._mastery_score=mastery_score}get max_time_allowed(){return this._max_time_allowed}set max_time_allowed(max_time_allowed){if(vs.validateReadOnly(this._cmi_element+".max_time_allowed",this.initialized),null==max_time_allowed)return;const e="string"==typeof max_time_allowed?max_time_allowed:max_time_allowed+"";this._max_time_allowed=""!==e?function(e,i){try{ps(i,e,Y,!0);const r=s(e,Y);return t(r)}catch(e){}try{ps(i,e,ne,!0);const s=r(e,ne);return t(s)}catch(e){}throw new w(i,T.TYPE_MISMATCH)}(e,this._cmi_element+".max_time_allowed"):""}get time_limit_action(){return this._time_limit_action}set time_limit_action(time_limit_action){if(vs.validateReadOnly(this._cmi_element+".time_limit_action",this.initialized),null==time_limit_action)return;const e="string"==typeof time_limit_action?time_limit_action:time_limit_action+"";ps(this._cmi_element+".time_limit_action",e,"^(exit,message|exit,no message|continue,message|continue,no message)$",!0)&&(this._time_limit_action=e)}toJSON(){this.jsonString=!0;const result={mastery_score:this.mastery_score,max_time_allowed:this.max_time_allowed,time_limit_action:this.time_limit_action};return this.jsonString=!1,result}}var xs=Object.defineProperty,qs=(e,t,i)=>((e,t,i)=>t in e?xs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ds extends d{constructor(e){super("cmi.student_preference"),qs(this,"__children"),qs(this,"_audio",""),qs(this,"_language",""),qs(this,"_speed",""),qs(this,"_text",""),this.__children=e||"audio,language,speed,text"}reset(){this._initialized=!1}get _children(){return this.__children}set _children(_children){throw new w(this._cmi_element+"._children",T.INVALID_SET_VALUE)}get audio(){return this._audio}set audio(audio){vs.validateScorm12Audio(this._cmi_element+".audio",audio)&&(this._audio=audio)}get language(){return this._language}set language(language){vs.validateScorm12Language(this._cmi_element+".language",language)&&(this._language=language)}get speed(){return this._speed}set speed(speed){vs.validateScorm12Speed(this._cmi_element+".speed",speed)&&(this._speed=speed)}get text(){return this._text}set text(text){vs.validateScorm12Text(this._cmi_element+".text",text)&&(this._text=text)}toJSON(){this.jsonString=!0;const result={audio:this.audio,language:this.language,speed:this.speed,text:this.text};return this.jsonString=!1,result}}var Ls=Object.defineProperty,Ps=(e,t,i)=>((e,t,i)=>t in e?Ls(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);let zs=class extends x{constructor(){super({CMIElement:"cmi.interactions",children:"id,objectives,time,type,correct_responses,weighting,student_response,result,latency",errorCode:T.INVALID_SET_VALUE,errorClass:w})}},Fs=class extends d{constructor(){super("cmi.interactions.n"),Ps(this,"objectives"),Ps(this,"correct_responses"),Ps(this,"_id",""),Ps(this,"_time",""),Ps(this,"_type",""),Ps(this,"_weighting",""),Ps(this,"_student_response",""),Ps(this,"_result",""),Ps(this,"_latency",""),this.objectives=new x({CMIElement:"cmi.interactions.n.objectives",errorCode:T.INVALID_SET_VALUE,errorClass:w,children:y}),this.correct_responses=new x({CMIElement:"cmi.interactions.correct_responses",errorCode:T.INVALID_SET_VALUE,errorClass:w,children:"pattern"})}initialize(){super.initialize(),this.objectives?.initialize(),this.correct_responses?.initialize()}reset(){this._initialized=!1,this._id="",this._time="",this._type="",this._weighting="",this._student_response="",this._result="",this._latency="",this.objectives?.reset(),this.correct_responses?.reset()}get id(){if(!this.jsonString)throw new w(this._cmi_element+".id",T.WRITE_ONLY_ELEMENT);return this._id}set id(id){ps(this._cmi_element+".id",id,K)&&(this._id=id)}get time(){if(!this.jsonString)throw new w(this._cmi_element+".time",T.WRITE_ONLY_ELEMENT);return this._time}set time(time){ps(this._cmi_element+".time",time,"^(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)(\\.\\d{1,2})?$")&&(this._time=time)}get type(){if(!this.jsonString)throw new w(this._cmi_element+".type",T.WRITE_ONLY_ELEMENT);return this._type}set type(type){ps(this._cmi_element+".type",type,"^(true-false|choice|fill-in|matching|performance|sequencing|likert|numeric)$")&&(this._type=type)}get weighting(){if(!this.jsonString)throw new w(this._cmi_element+".weighting",T.WRITE_ONLY_ELEMENT);return this._weighting}set weighting(weighting){ps(this._cmi_element+".weighting",weighting,J)&&_s(this._cmi_element+".weighting",weighting,"-100#100")&&(this._weighting=weighting)}get student_response(){if(!this.jsonString)throw new w(this._cmi_element+".student_response",T.WRITE_ONLY_ELEMENT);return this._student_response}set student_response(student_response){ps(this._cmi_element+".student_response",student_response,X,!0)&&(this._student_response=student_response)}get result(){if(!this.jsonString)throw new w(this._cmi_element+".result",T.WRITE_ONLY_ELEMENT);return this._result}set result(result){let e=result;"incorrect"===result&&(e="wrong",console.warn("SCORM 1.2: Received non-standard value 'incorrect' for cmi.interactions.n.result; normalizing to 'wrong'.")),ps(this._cmi_element+".result",e,"^(correct|wrong|unanticipated|neutral|([0-9]{0,3})?(\\.[0-9]*)?)$")&&(this._result=e)}get latency(){if(!this.jsonString)throw new w(this._cmi_element+".latency",T.WRITE_ONLY_ELEMENT);return this._latency}set latency(latency){if(ps(this._cmi_element+".latency",latency,Y)){const e=s(latency,Y);this._latency=t(e)}}toJSON(){this.jsonString=!0;const result={id:this.id,time:this.time,type:this.type,weighting:this.weighting,student_response:this.student_response,result:this.result,latency:this.latency,objectives:this.objectives,correct_responses:this.correct_responses};return this.jsonString=!1,result}},ks=class extends d{constructor(){super("cmi.interactions.n.objectives.n"),Ps(this,"_id","")}reset(){this._initialized=!1,this._id=""}get id(){if(!this.jsonString)throw new w(this._cmi_element+".id",T.WRITE_ONLY_ELEMENT);return this._id}set id(id){ps(this._cmi_element+".id",id,K)&&(this._id=id)}toJSON(){this.jsonString=!0;const result={id:this.id};return this.jsonString=!1,result}},Vs=class extends d{constructor(){super("cmi.interactions.correct_responses.n"),Ps(this,"_pattern","")}reset(){this._initialized=!1,this._pattern=""}get pattern(){if(!this.jsonString)throw new w(this._cmi_element+".pattern",T.WRITE_ONLY_ELEMENT);return this._pattern}set pattern(pattern){ps(this._cmi_element+".pattern",pattern,X,!0)&&(this._pattern=pattern)}toJSON(){this.jsonString=!0;const result={pattern:this._pattern};return this.jsonString=!1,result}};var Hs=Object.defineProperty,Bs=(e,t,i)=>((e,t,i)=>t in e?Hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);let Us=class extends m{constructor(e,student_data,t){super("cmi"),Bs(this,"__children",""),Bs(this,"__version","3.4"),Bs(this,"_launch_data",""),Bs(this,"_comments",""),Bs(this,"_comments_from_lms",""),Bs(this,"core"),Bs(this,"objectives"),Bs(this,"student_data"),Bs(this,"student_preference"),Bs(this,"interactions"),t&&this.initialize(),this.__children=e||"core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions",this.core=new ws,this.objectives=new Rs,this.student_data=student_data||new Ns,this.student_preference=new Ds,this.interactions=new zs}reset(){this._initialized=!1,this._launch_data="",this._comments="",this.core?.reset(),this.objectives?.reset(!0),this.interactions?.reset(!0),this.student_data?.reset(),this.student_preference?.reset()}initialize(){super.initialize(),this.core?.initialize(),this.objectives?.initialize(),this.student_data?.initialize(),this.student_preference?.initialize(),this.interactions?.initialize()}toJSON(){this.jsonString=!0;const result={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,interactions:this.interactions};return this.jsonString=!1,result}get _version(){return this.__version}set _version(_version){throw new w(this._cmi_element+"._version",T.INVALID_SET_VALUE)}get _children(){return this.__children}set _children(_children){throw new w(this._cmi_element+"._children",T.INVALID_SET_VALUE)}get suspend_data(){return this.core?.suspend_data}set suspend_data(suspend_data){this.core&&(this.core.suspend_data=suspend_data)}get launch_data(){return this._launch_data}set launch_data(launch_data){if(this.initialized)throw new w(this._cmi_element+".launch_data",T.READ_ONLY_ELEMENT);this._launch_data=launch_data}get comments(){return this._comments}set comments(comments){ps(this._cmi_element+".comments",comments,"^[\\s\\S]{0,4096}$",!0)&&(this._comments=comments)}get comments_from_lms(){return this._comments_from_lms}set comments_from_lms(comments_from_lms){if(this.initialized)throw new w(this._cmi_element+".comments_from_lms",T.READ_ONLY_ELEMENT);this._comments_from_lms=comments_from_lms}getCurrentTotalTime(){return this.core.getCurrentTotalTime(this.start_time)}};var $s=Object.defineProperty;class Gs extends d{constructor(){super("cmi.nav"),((e,t,i)=>{t in e?$s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(this,"_event"+"","")}reset(){this._event="",this._initialized=!1}get event(){return this._event}set event(e){(""===e||ps(this._cmi_element+".event",e,"^(_?(previous|continue|start|resumeAll|exit|exitAll|abandon|abandonAll|suspendAll|retry|retryAll)|choice|jump|_none_)$"))&&(this._event=e)}toJSON(){this.jsonString=!0;const result={event:this.event};return this.jsonString=!1,result}}var Ys=Object.defineProperty,Ws=(e,t,i)=>((e,t,i)=>t in e?Ys(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);const Js=class e extends Ss{constructor(t,i){const s=t?{...t}:void 0;s&&void 0===s.mastery_override&&(s.mastery_override=!0),super(T,s,i),Ws(this,"statusSetByModule",!1),Ws(this,"cmi"),Ws(this,"nav"),Ws(this,"LMSInitialize"),Ws(this,"LMSFinish"),Ws(this,"LMSGetValue"),Ws(this,"LMSSetValue"),Ws(this,"LMSCommit"),Ws(this,"LMSGetLastError"),Ws(this,"LMSGetErrorString"),Ws(this,"LMSGetDiagnostic"),this.cmi=new Us,this.nav=new Gs,this.settings.globalStudentPreferences&&e._globalLearnerPrefs&&(""!==e._globalLearnerPrefs.audio&&(this.cmi.student_preference.audio=e._globalLearnerPrefs.audio),""!==e._globalLearnerPrefs.language&&(this.cmi.student_preference.language=e._globalLearnerPrefs.language),""!==e._globalLearnerPrefs.speed&&(this.cmi.student_preference.speed=e._globalLearnerPrefs.speed),""!==e._globalLearnerPrefs.text&&(this.cmi.student_preference.text=e._globalLearnerPrefs.text)),this.LMSInitialize=this.lmsInitialize,this.LMSFinish=this.lmsFinish,this.LMSGetValue=this.lmsGetValue,this.LMSSetValue=this.lmsSetValue,this.LMSCommit=this.lmsCommit,this.LMSGetLastError=this.lmsGetLastError,this.LMSGetErrorString=this.lmsGetErrorString,this.LMSGetDiagnostic=this.lmsGetDiagnostic}static clearGlobalPreferences(){e._globalLearnerPrefs=null}reset(e){this.commonReset(e),this.cmi?.reset(),this.nav?.reset(),this.statusSetByModule=!1}lmsInitialize(){return""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")?(this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),S):(this.cmi.initialize(),this.cmi.core.lesson_status?this.statusSetByModule=!0:this.cmi.core.lesson_status="not attempted",this.initialize("LMSInitialize","LMS was already initialized!","LMS is already finished!"))}lmsFinish(){if(""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:""))return this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),S;const result=this.terminate("LMSFinish",!0);return result===f&&(""!==this.nav.event?this.processListeners("continue"===this.nav.event?"SequenceNext":"SequencePrevious"):this.settings.autoProgress&&this.processListeners("SequenceNext")),result}lmsGetValue(e){return this.getValue("LMSGetValue",!1,e)}lmsSetValue(e,t){return"cmi.core.lesson_status"===e&&(this.statusSetByModule=!0),this.setValue("LMSSetValue","LMSCommit",!1,e,t)}lmsCommit(){return""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")?(this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),S):this.settings.throttleCommits?(this.scheduleCommit(500,"LMSCommit"),f):this.commit("LMSCommit",!1)}lmsGetLastError(){return this.getLastError("LMSGetLastError")}lmsGetErrorString(e){return this.getErrorString("LMSGetErrorString",e)}lmsGetDiagnostic(e){return this.getDiagnostic("LMSGetDiagnostic",e)}setCMIValue(e,t){const result=this._commonSetCMIValue("LMSSetValue",!1,e,t);return result===f&&this.settings.globalStudentPreferences&&("cmi.student_preference.audio"===e?this._updateGlobalPreference("audio",t):"cmi.student_preference.language"===e?this._updateGlobalPreference("language",t):"cmi.student_preference.speed"===e?this._updateGlobalPreference("speed",t):"cmi.student_preference.text"===e&&this._updateGlobalPreference("text",t)),result}_updateGlobalPreference(t,i){e._globalLearnerPrefs||(e._globalLearnerPrefs={audio:"",language:"",speed:"",text:""}),e._globalLearnerPrefs[t]=i}getCMIValue(e){return this._commonGetCMIValue("getCMIValue",!1,e)}getChildElement(e,t,i){return c(e,"cmi\\.objectives\\.\\d+")?new Ts:i&&c(e,"cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+")?new Vs:i&&c(e,"cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")?new ks:!i&&c(e,"cmi\\.interactions\\.\\d+")?new Fs:null}validateCorrectResponse(e,t){}getLmsErrorMessageDetails(e,t){let i="No Error",s="No Error";return C[e+=""]&&(i=C[e]?.basicMessage||i,s=C[e]?.detailMessage||s),t?s:i}replaceWithAnotherScormAPI(e){this.cmi=e.cmi}renderCommitCMI(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.renderCMIToJSONObject();(e||t)&&(i.cmi.core.total_time=this.cmi.getCurrentTotalTime());const result=[],s=o(i);switch(this.settings.dataCommitFormat){case"flattened":return s;case"params":for(const e in s)({}).hasOwnProperty.call(s,e)&&result.push(`${e}=${s[e]}`);return result;default:return i}}renderCommitObject(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.renderCommitCMI(e,t),r=e||t?this.cmi.getCurrentTotalTime():"",n=s(r,Y),o=this.cmi.core.lesson_status;let a=H,c=F;o&&(a="completed"===o||"passed"===o?k:V,"passed"===o?c=P:"failed"===o&&(c=z));const l=this.cmi?.core?.score?.getScoreObject()||{},u={successStatus:c,completionStatus:a,runtimeData:i,totalTimeSeconds:n};return l&&(u.score=l),this.settings.autoPopulateCommitMetadata&&(this.settings.courseId&&(u.courseId=this.settings.courseId),this.settings.scoId&&(u.scoId=this.settings.scoId),this.cmi.core.student_id&&(u.learnerId=this.cmi.core.student_id),this.cmi.core.student_name&&(u.learnerName=this.cmi.core.student_name)),u}storeData(e){if(e){const t=this.cmi.core.lesson_status;if("browse"===this.cmi.core.lesson_mode&&""===(this.startingData?.cmi?.core?.lesson_status||"")&&"not attempted"===t)return this.cmi.core.lesson_status="browsed",this.processCommitData(e);if(this.cmi.core.lesson_status&&(this.statusSetByModule||"not attempted"!==this.cmi.core.lesson_status)||(this.cmi.core.lesson_status=this.settings.autoCompleteLessonStatus?"completed":"incomplete"),"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){const e=parseFloat(this.cmi.core.score.raw),t=parseFloat(this.cmi.student_data.mastery_score);isNaN(e)||isNaN(t)||(this.cmi.core.lesson_status=t>e?"failed":"passed")}if(this.settings.score_overrides_status&&this.statusSetByModule&&"normal"===this.cmi.core.lesson_mode&&"credit"===this.cmi.core.credit&&""!==this.cmi.student_data.mastery_score&&""!==this.cmi.core.score.raw){const e=parseFloat(this.cmi.core.score.raw),t=parseFloat(this.cmi.student_data.mastery_score);isNaN(e)||isNaN(t)||(this.cmi.core.lesson_status=t>e?"failed":"passed")}}return this.processCommitData(e)}processCommitData(e){const t=this.getCommitObject(e);return"string"==typeof this.settings.lmsCommitUrl?this.processHttpRequest(this.settings.lmsCommitUrl,t,e):{result:f,errorCode:0}}};Ws(Js,"_globalLearnerPrefs",null);let Scorm12API=Js;var Ks=Object.defineProperty,Xs=(e,t,i)=>((e,t,i)=>t in e?Ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Qs extends d{constructor(){super("cmi.learner_preference"),Xs(this,"__children",A.student_preference_children),Xs(this,"_audio_level","1"),Xs(this,"_language",""),Xs(this,"_delivery_speed","1"),Xs(this,"_audio_captioning","0")}reset(){this._initialized=!1}get _children(){return this.__children}set _children(_children){throw new O(this._cmi_element+"._children",j.READ_ONLY_ELEMENT)}get audio_level(){return this._audio_level}set audio_level(audio_level){Bt(this._cmi_element+".audio_level",audio_level,oe)&&Ut(this._cmi_element+".audio_level",audio_level,"0#999.9999999")&&(this._audio_level=audio_level)}get language(){return this._language}set language(language){Bt(this._cmi_element+".language",language,"^([a-zA-Z]{1,8}|i|x)(-[a-zA-Z0-9-]{2,8})?$|^$")&&(this._language=language)}get delivery_speed(){return this._delivery_speed}set delivery_speed(delivery_speed){if(Bt(this._cmi_element+".delivery_speed",delivery_speed,oe)&&Ut(this._cmi_element+".delivery_speed",delivery_speed,"0#999.9999999")){if(0===parseFloat(delivery_speed))throw new O(this._cmi_element+".delivery_speed",j.VALUE_OUT_OF_RANGE);this._delivery_speed=delivery_speed}}get audio_captioning(){return this._audio_captioning}set audio_captioning(audio_captioning){Bt(this._cmi_element+".audio_captioning",audio_captioning,"^-?([0-9]+)$")&&Ut(this._cmi_element+".audio_captioning",audio_captioning,"-1#1")&&(this._audio_captioning=audio_captioning)}toJSON(){this.jsonString=!0;const result={audio_level:this.audio_level,language:this.language,delivery_speed:this.delivery_speed,audio_captioning:this.audio_captioning};return this.jsonString=!1,result}}function Zs(e){return e.replace(/[[\]]/g,"")}function er(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tr(e,t){if(!t)return[e];if(e.includes(t))return e.split(t);const i=Zs(t);if(!i)return[e];const s=RegExp("(?<!\\\\)"+er(i),"g"),r=RegExp("\\\\"+er(i),"g");return e.split(s).map(e=>e.replace(r,i))}function ir(e,t){if(!t)return[e];if(e.includes(t)){const i=e.indexOf(t);return[e.slice(0,i),e.slice(i+t.length)]}const i=Zs(t);if(!i)return[e];const s=RegExp("(?<!\\\\)"+er(i)),r=RegExp("\\\\"+er(i),"g"),n=e.split(s),o=(n[0]??"").replace(r,i);return 1===n.length?[o]:[o,n.slice(1).join(i).replace(r,i)]}var sr=Object.defineProperty,rr=(e,t,i)=>((e,t,i)=>t in e?sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class nr extends x{constructor(){super({CMIElement:"cmi.interactions",children:A.interactions_children,errorCode:j.READ_ONLY_ELEMENT,errorClass:O})}}class or extends d{constructor(){super("cmi.interactions.n"),rr(this,"_id",""),rr(this,"_idIsSet",!1),rr(this,"_type",""),rr(this,"_timestamp",""),rr(this,"_weighting",""),rr(this,"_learner_response",""),rr(this,"_result",""),rr(this,"_latency",""),rr(this,"_description",""),rr(this,"objectives"),rr(this,"correct_responses"),this.objectives=new x({CMIElement:"cmi.interactions.n.objectives",errorCode:j.READ_ONLY_ELEMENT,errorClass:O,children:A.objectives_children}),this.correct_responses=new x({CMIElement:"cmi.interactions.n.correct_responses",errorCode:j.READ_ONLY_ELEMENT,errorClass:O,children:A.correct_responses_children})}initialize(){super.initialize(),this.objectives?.initialize(),this.correct_responses?.initialize()}reset(){this._initialized=!1,this._id="",this._idIsSet=!1,this._type="",this._timestamp="",this._weighting="",this._learner_response="",this._result="",this._latency="",this._description="",this.objectives=new x({CMIElement:"cmi.interactions.n.objectives",errorCode:j.READ_ONLY_ELEMENT,errorClass:O,children:A.objectives_children}),this.correct_responses=new x({CMIElement:"cmi.interactions.n.correct_responses",errorCode:j.READ_ONLY_ELEMENT,errorClass:O,children:A.correct_responses_children})}get id(){return this._id}set id(id){if(""===id||""===id.trim())throw new O(this._cmi_element+".id",j.TYPE_MISMATCH);if(this._idIsSet&&this._id!==id)throw new O(this._cmi_element+".id",j.GENERAL_SET_FAILURE);Bt(this._cmi_element+".id",id,ce)&&(this._id=id,this._idIsSet=!0)}get type(){return this._type}set type(type){if(this.initialized&&""===this._id)throw new O(this._cmi_element+".type",j.DEPENDENCY_NOT_ESTABLISHED);Bt(this._cmi_element+".type",type,"^(true-false|choice|fill-in|long-fill-in|matching|performance|sequencing|likert|numeric|other)$")&&(this._type=type)}get timestamp(){return this._timestamp}set timestamp(timestamp){if(this.initialized&&""===this._id)throw new O(this._cmi_element+".timestamp",j.DEPENDENCY_NOT_ESTABLISHED);Bt(this._cmi_element+".timestamp",timestamp,re)&&(this._timestamp=timestamp)}get weighting(){return this._weighting}set weighting(weighting){if(this.initialized&&""===this._id)throw new O(this._cmi_element+".weighting",j.DEPENDENCY_NOT_ESTABLISHED);Bt(this._cmi_element+".weighting",weighting,oe)&&(this._weighting=weighting)}get learner_response(){return this._learner_response}set learner_response(learner_response){if(this.initialized&&(""===this._type||""===this._id))throw new O(this._cmi_element+".learner_response",j.DEPENDENCY_NOT_ESTABLISHED);{let e=[];const t=ve[this.type];if(!t)throw new O(this._cmi_element+".learner_response",j.TYPE_MISMATCH);if(t?.delimiter?e=tr(learner_response,t.delimiter):e[0]=learner_response,0>=e.length||e.length>t.max)throw new O(this._cmi_element+".learner_response",j.GENERAL_SET_FAILURE);{const i=RegExp(t.format);for(let s=0;e.length>s;s++)if(t?.delimiter2){const r=e[s]??"",n="performance"===this.type?ir(r,t.delimiter2):tr(r,t.delimiter2);if(2!==n?.length)throw new O(this._cmi_element+".learner_response",j.TYPE_MISMATCH);if("performance"===this.type&&""===n[0]&&""===n[1])throw new O(this._cmi_element+".learner_response",j.TYPE_MISMATCH);if(!n[0]?.match(i))throw new O(this._cmi_element+".learner_response",j.TYPE_MISMATCH);if(!t.format2||!n[1]?.match(RegExp(t.format2)))throw new O(this._cmi_element+".learner_response",j.TYPE_MISMATCH)}else{if(!e[s]?.match(i))throw new O(this._cmi_element+".learner_response",j.TYPE_MISMATCH);if(""!==e[s]&&t.unique)for(let t=0;s>t;t++)if(e[s]===e[t])throw new O(this._cmi_element+".learner_response",j.TYPE_MISMATCH)}}this._learner_response=learner_response}}get result(){return this._result}set result(result){Bt(this._cmi_element+".result",result,"^(correct|incorrect|unanticipated|neutral|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$")&&(this._result=result)}get latency(){return this._latency}set latency(latency){if(this.initialized&&""===this._id)throw new O(this._cmi_element+".latency",j.DEPENDENCY_NOT_ESTABLISHED);Bt(this._cmi_element+".latency",latency,ne)&&(this._latency=latency)}get description(){return this._description}set description(description){if(this.initialized&&""===this._id)throw new O(this._cmi_element+".description",j.DEPENDENCY_NOT_ESTABLISHED);Bt(this._cmi_element+".description",description,ie,!0)&&(this._description=description)}toJSON(){this.jsonString=!0;const result={id:this.id,type:this.type,objectives:this.objectives,timestamp:this.timestamp,weighting:this.weighting,learner_response:this.learner_response,result:this.result,latency:this.latency,description:this.description,correct_responses:this.correct_responses};return this.jsonString=!1,result}}class ar extends d{constructor(){super("cmi.interactions.n.objectives.n"),rr(this,"_id","")}reset(){this._initialized=!1,this._id=""}get id(){return this._id}set id(id){if(""===id||""===id.trim())throw new O(this._cmi_element+".id",j.TYPE_MISMATCH);Bt(this._cmi_element+".id",id,ce)&&(this._id=id)}toJSON(){this.jsonString=!0;const result={id:this.id};return this.jsonString=!1,result}}const cr=/^\{(?:lang|case_matters|order_matters)=[^}]+\}/;function lr(e){let result=e;for(;cr.test(result);)result=result.replace(cr,"");return result}class ur extends d{constructor(e){super("cmi.interactions.n.correct_responses.n"),rr(this,"_pattern",""),rr(this,"_interactionType"),this._interactionType=e}reset(){this._initialized=!1,this._pattern=""}get pattern(){return this._pattern}set pattern(pattern){if("fill-in"!==this._interactionType||""!==pattern){if(Bt(this._cmi_element+".pattern",pattern,"^.*$")){if(this._interactionType){const e=ge[this._interactionType];e&&("matching"===this._interactionType&&/\\[.,]/.test(pattern)||function(type,pattern,e){if(pattern.trim()!==pattern)throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);const t=e.delimiter?tr(pattern,e.delimiter):[pattern];for(const e of t)if(e.trim()!==e)throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);if("fill-in"===type&&""===pattern)return;const i=e.delimiter?tr(pattern,e.delimiter):[pattern];if(!e.delimiter&&pattern.includes(","))throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);if("numeric"!==type&&(e.unique||!1===e.duplicate)&&new Set(i).size!==i.length)throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);if(0===i.length||i.length>e.max)throw new O("cmi.interactions.n.correct_responses.n.pattern",j.GENERAL_SET_FAILURE);const s=RegExp(e.format),r=e.format2?RegExp(e.format2):null,n=e=>{if(!s.test(e))throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH)},o=(e,t)=>{if(!t)throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);const i=tr(e,t);if(2!==i.length||""===i[0]||""===i[1])throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);if(void 0!==i[0]&&!s.test(i[0])||r&&void 0!==i[1]&&!r.test(i[1]))throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH)};for(const t of i)switch(type){case"numeric":if(""===t){if(2>i.length||!e.delimiter||!pattern.includes(e.delimiter))throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);break}n(t);break;case"performance":{const i=e.delimiter2;if(!i)throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);const n=ir(lr(t),i);if(2!==n.length)throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);const[o,a]=n;if(""===o&&""===a)throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);if(void 0===o||!s.test(o))throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);if(r&&void 0!==a&&!r.test(a))throw new O("cmi.interactions.n.correct_responses.n.pattern",j.TYPE_MISMATCH);break}default:e.delimiter2?o(t,e.delimiter2):n(t)}}(this._interactionType,pattern,e))}this._pattern=pattern}}else this._pattern=""}toJSON(){this.jsonString=!0;const result={pattern:this.pattern};return this.jsonString=!1,result}}var hr=Object.defineProperty;class dr extends Cs{constructor(){super({CMIElement:"cmi.score",score_children:A.score_children,max:"",invalidErrorCode:j.READ_ONLY_ELEMENT,invalidTypeCode:j.TYPE_MISMATCH,invalidRangeCode:j.VALUE_OUT_OF_RANGE,decimalRegex:oe,errorClass:O}),((e,t,i)=>{t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(this,"_scaled"+"","")}reset(){this._initialized=!1,this._scaled="",this._raw="",this._min="",this._max=""}get scaled(){return this._scaled}set scaled(e){Bt(this._cmi_element+".scaled",e,oe)&&Ut(this._cmi_element+".scaled",e,"-1#1")&&(this._scaled=e)}getScoreObject(){const e=super.getScoreObject();return Number.isNaN(Number.parseFloat(this.scaled))||(e.scaled=Number.parseFloat(this.scaled)),e}toJSON(){this.jsonString=!0;const result={scaled:this.scaled,raw:this.raw,min:this.min,max:this.max};return this.jsonString=!1,result}}var mr=Object.defineProperty,pr=(e,t,i)=>((e,t,i)=>t in e?mr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class _r extends x{constructor(){super({CMIElement:"cmi.comments_from_lms",children:A.comments_children,errorCode:j.READ_ONLY_ELEMENT,errorClass:O})}}class vr extends x{constructor(){super({CMIElement:"cmi.comments_from_learner",children:A.comments_children,errorCode:j.READ_ONLY_ELEMENT,errorClass:O})}}class gr extends d{constructor(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];super("cmi.comments_from_learner.n"),pr(this,"_comment",""),pr(this,"_location",""),pr(this,"_timestamp",""),pr(this,"_readOnlyAfterInit"),this._comment="",this._location="",this._timestamp="",this._readOnlyAfterInit=e}reset(){this._initialized=!1}get comment(){return this._comment}set comment(comment){if(this.initialized&&this._readOnlyAfterInit)throw new O(this._cmi_element+".comment",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".comment",comment,se,!0)&&(this._comment=comment)}get location(){return this._location}set location(location){if(this.initialized&&this._readOnlyAfterInit)throw new O(this._cmi_element+".location",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".location",location,"^[\\u0000-\\uFFFF]{0,250}$")&&(this._location=location)}get timestamp(){return this._timestamp}set timestamp(timestamp){if(this.initialized&&this._readOnlyAfterInit)throw new O(this._cmi_element+".timestamp",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".timestamp",timestamp,re)&&(this._timestamp=timestamp)}toJSON(){this.jsonString=!0;const result={comment:this.comment,location:this.location,timestamp:this.timestamp};return this.jsonString=!1,result}}var fr=Object.defineProperty,Sr=(e,t,i)=>((e,t,i)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class br extends x{constructor(){super({CMIElement:"cmi.objectives",children:A.objectives_children,errorCode:j.READ_ONLY_ELEMENT,errorClass:O})}findObjectiveById(id){return this.childArray.find(e=>e.id===id)}findObjectiveByIndex(e){return this.childArray[e]}setObjectiveByIndex(e,t){this.childArray[e]=t}}class yr extends d{constructor(){super("cmi.objectives.n"),Sr(this,"_id",""),Sr(this,"_idIsSet",!1),Sr(this,"_success_status","unknown"),Sr(this,"_completion_status","unknown"),Sr(this,"_progress_measure",""),Sr(this,"_description",""),Sr(this,"score"),this.score=new dr}reset(){this._initialized=!1,this._id="",this._idIsSet=!1,this._success_status="unknown",this._completion_status="unknown",this._progress_measure="",this._description="",this.score?.reset()}initialize(){super.initialize(),this.score?.initialize()}get id(){return this._id}set id(id){if(""===id||""===id.trim())throw new O(this._cmi_element+".id",j.TYPE_MISMATCH);if(this._idIsSet&&this._id!==id)throw new O(this._cmi_element+".id",j.GENERAL_SET_FAILURE);Bt(this._cmi_element+".id",id,ce)&&(this._id=id,this._idIsSet=!0)}get success_status(){return this._success_status}set success_status(success_status){if(this.initialized&&""===this._id)throw new O(this._cmi_element+".success_status",j.DEPENDENCY_NOT_ESTABLISHED);Bt(this._cmi_element+".success_status",success_status,ue)&&(this._success_status=success_status)}get completion_status(){return this._completion_status}set completion_status(completion_status){if(this.initialized&&""===this._id)throw new O(this._cmi_element+".completion_status",j.DEPENDENCY_NOT_ESTABLISHED);Bt(this._cmi_element+".completion_status",completion_status,le)&&(this._completion_status=completion_status)}get progress_measure(){return this._progress_measure}set progress_measure(progress_measure){if(this.initialized&&""===this._id)throw new O(this._cmi_element+".progress_measure",j.DEPENDENCY_NOT_ESTABLISHED);Bt(this._cmi_element+".progress_measure",progress_measure,oe)&&Ut(this._cmi_element+".progress_measure",progress_measure,"0#1")&&(this._progress_measure=progress_measure)}get description(){return this._description}set description(description){if(this.initialized&&""===this._id)throw new O(this._cmi_element+".description",j.DEPENDENCY_NOT_ESTABLISHED);Bt(this._cmi_element+".description",description,ie,!0)&&(this._description=description)}toJSON(){this.jsonString=!0;const result={id:this.id,success_status:this.success_status,completion_status:this.completion_status,progress_measure:this.progress_measure,description:this.description,score:this.score};return this.jsonString=!1,result}fromJSON(e){e&&"object"==typeof e&&("string"==typeof e.id&&(this.id=e.id),"string"==typeof e.success_status&&(this.success_status=e.success_status),"string"==typeof e.completion_status&&(this.completion_status=e.completion_status),void 0!==e.progress_measure&&(this.progress_measure=e.progress_measure+""),"string"==typeof e.description&&(this.description=e.description),e.score&&"object"==typeof e.score&&(void 0!==e.score.scaled&&(this.score.scaled=e.score.scaled+""),void 0!==e.score.raw&&(this.score.raw=e.score.raw+""),void 0!==e.score.min&&(this.score.min=e.score.min+""),void 0!==e.score.max&&(this.score.max=e.score.max+"")))}}var Cr=Object.defineProperty,Ar=(e,t,i)=>((e,t,i)=>t in e?Cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Er extends d{constructor(){super("cmi"),Ar(this,"__version","1.0"),Ar(this,"__children",A.cmi_children)}get _version(){return this.__version}set _version(_version){throw new O(this._cmi_element+"._version",j.READ_ONLY_ELEMENT)}get _children(){return this.__children}set _children(_children){throw new O(this._cmi_element+"._children",j.READ_ONLY_ELEMENT)}reset(){this._initialized=!1}}var wr=Object.defineProperty,Mr=(e,t,i)=>((e,t,i)=>t in e?wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Or extends d{constructor(){super("cmi"),Mr(this,"_learner_id",""),Mr(this,"_learner_name","")}get learner_id(){return this._learner_id}set learner_id(learner_id){if(this.initialized)throw new O(this._cmi_element+".learner_id",j.READ_ONLY_ELEMENT);this._learner_id=learner_id}get learner_name(){return this._learner_name}set learner_name(learner_name){if(this.initialized)throw new O(this._cmi_element+".learner_name",j.READ_ONLY_ELEMENT);this._learner_name=learner_name}reset(){this._initialized=!1}}var Rr=Object.defineProperty,Tr=(e,t,i)=>((e,t,i)=>t in e?Rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class jr extends d{constructor(){super("cmi"),Tr(this,"_completion_status","unknown"),Tr(this,"_success_status","unknown"),Tr(this,"_progress_measure","")}get completion_status(){return this._completion_status}set completion_status(completion_status){Bt(this._cmi_element+".completion_status",completion_status,le)&&(this._completion_status=completion_status)}get success_status(){return this._success_status}set success_status(success_status){Bt(this._cmi_element+".success_status",success_status,ue)&&(this._success_status=success_status)}get progress_measure(){return this._progress_measure}set progress_measure(progress_measure){Bt(this._cmi_element+".progress_measure",progress_measure,oe)&&Ut(this._cmi_element+".progress_measure",progress_measure,"0#1")&&(this._progress_measure=progress_measure)}reset(){this._initialized=!1,this._completion_status="unknown",this._success_status="unknown",this._progress_measure=""}}var Ir=Object.defineProperty,Nr=(e,t,i)=>((e,t,i)=>t in e?Ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class xr extends d{constructor(){super("cmi"),Nr(this,"_entry",""),Nr(this,"_exit",""),Nr(this,"_session_time","PT0H0M0S"),Nr(this,"_total_time","PT0S")}get entry(){return this._entry}set entry(entry){if(this.initialized)throw new O(this._cmi_element+".entry",j.READ_ONLY_ELEMENT);this._entry=entry}get exit(){if(!this.jsonString)throw new O(this._cmi_element+".exit",j.WRITE_ONLY_ELEMENT);return this._exit}getExitValueInternal(){return this._exit}set exit(exit){"logout"===exit&&console.warn('SCORM 2004: cmi.exit value "logout" is deprecated per 4th Edition. Consider using "normal" or "suspend" instead.'),Bt(this._cmi_element+".exit",exit,"^(time-out|suspend|logout|normal)$",!0)&&(this._exit=exit)}get session_time(){if(!this.jsonString)throw new O(this._cmi_element+".session_time",j.WRITE_ONLY_ELEMENT);return this._session_time}set session_time(session_time){Bt(this._cmi_element+".session_time",session_time,ne)&&(this._session_time=session_time)}get total_time(){return this._total_time}set total_time(total_time){if(this.initialized)throw new O(this._cmi_element+".total_time",j.READ_ONLY_ELEMENT);this._total_time=total_time}getCurrentTotalTime(e){let t=this._session_time;if(void 0!==e){const s=(new Date).getTime()-e;t=i(s/1e3)}return function(e,t,s){const n=RegExp(s);return i(r(e,n)+r(t,n))}(this._total_time,t,ne)}reset(){this._initialized=!1,this._entry="ab-initio",this._exit="",this._session_time="PT0H0M0S"}}var qr=Object.defineProperty,Dr=(e,t,i)=>((e,t,i)=>t in e?qr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Lr extends d{constructor(){super("cmi"),Dr(this,"_location",""),Dr(this,"_launch_data",""),Dr(this,"_suspend_data","")}get location(){return this._location}set location(location){Bt(this._cmi_element+".location",location,"^[\\u0000-\\uFFFF]{0,1000}$")&&(this._location=location)}get launch_data(){return this._launch_data}set launch_data(launch_data){if(this.initialized)throw new O(this._cmi_element+".launch_data",j.READ_ONLY_ELEMENT);this._launch_data=launch_data}get suspend_data(){return this._suspend_data}set suspend_data(suspend_data){Bt(this._cmi_element+".suspend_data",suspend_data,te,!0)&&(this._suspend_data=suspend_data)}reset(){this._initialized=!1,this._location="",this._suspend_data=""}}var Pr=Object.defineProperty,zr=(e,t,i)=>((e,t,i)=>t in e?Pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Fr extends d{constructor(){super("cmi"),zr(this,"_credit","credit"),zr(this,"_mode","normal"),zr(this,"_time_limit_action","continue,no message"),zr(this,"_max_time_allowed","")}get credit(){return this._credit}set credit(credit){if(this.initialized)throw new O(this._cmi_element+".credit",j.READ_ONLY_ELEMENT);if(!/^(credit|no-credit)$/.test(credit))throw new O(this._cmi_element+".credit",j.TYPE_MISMATCH);this._credit=credit}get mode(){return this._mode}set mode(mode){if(this.initialized)throw new O(this._cmi_element+".mode",j.READ_ONLY_ELEMENT);if(!/^(browse|normal|review)$/.test(mode))throw new O(this._cmi_element+".mode",j.TYPE_MISMATCH);this._mode=mode}get time_limit_action(){return this._time_limit_action}set time_limit_action(time_limit_action){if(this.initialized)throw new O(this._cmi_element+".time_limit_action",j.READ_ONLY_ELEMENT);if(!/^(exit,message|exit,no message|continue,message|continue,no message)$/.test(time_limit_action))throw new O(this._cmi_element+".time_limit_action",j.TYPE_MISMATCH);this._time_limit_action=time_limit_action}get max_time_allowed(){return this._max_time_allowed}set max_time_allowed(max_time_allowed){if(this.initialized)throw new O(this._cmi_element+".max_time_allowed",j.READ_ONLY_ELEMENT);if(""!==max_time_allowed){if(!RegExp(ne).test(max_time_allowed))throw new O(this._cmi_element+".max_time_allowed",j.TYPE_MISMATCH);this._max_time_allowed=max_time_allowed}else this._max_time_allowed=max_time_allowed}reset(){this._initialized=!1}}var kr=Object.defineProperty,Vr=(e,t,i)=>((e,t,i)=>t in e?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Hr extends d{constructor(){super("cmi"),Vr(this,"_scaled_passing_score",""),Vr(this,"_completion_threshold","")}get scaled_passing_score(){return this._scaled_passing_score}set scaled_passing_score(scaled_passing_score){if(this.initialized)throw new O(this._cmi_element+".scaled_passing_score",j.READ_ONLY_ELEMENT??404);if(""===scaled_passing_score)return void(this._scaled_passing_score=scaled_passing_score);if(!RegExp(oe).test(scaled_passing_score))throw new O(this._cmi_element+".scaled_passing_score",j.TYPE_MISMATCH??406);const e=parseFloat(scaled_passing_score);if(-1>e||e>1)throw new O(this._cmi_element+".scaled_passing_score",j.VALUE_OUT_OF_RANGE??407);this._scaled_passing_score=scaled_passing_score}get completion_threshold(){return this._completion_threshold}set completion_threshold(e){if(this.initialized)throw new O(this._cmi_element+".completion_threshold",j.READ_ONLY_ELEMENT??404);if(""===e)return void(this._completion_threshold=e);if(!RegExp(oe).test(e))throw new O(this._cmi_element+".completion_threshold",j.TYPE_MISMATCH??406);const t=parseFloat(e);if(0>t||t>1)throw new O(this._cmi_element+".completion_threshold",j.VALUE_OUT_OF_RANGE??407);this._completion_threshold=e}reset(){this._initialized=!1}}var Br=Object.defineProperty,Ur=(e,t,i)=>((e,t,i)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class $r extends m{constructor(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];super("cmi"),Ur(this,"metadata"),Ur(this,"learner"),Ur(this,"status"),Ur(this,"session"),Ur(this,"content"),Ur(this,"settings"),Ur(this,"thresholds"),Ur(this,"learner_preference"),Ur(this,"score"),Ur(this,"comments_from_learner"),Ur(this,"comments_from_lms"),Ur(this,"interactions"),Ur(this,"objectives"),this.metadata=new Er,this.learner=new Or,this.status=new jr,this.session=new xr,this.content=new Lr,this.settings=new Fr,this.thresholds=new Hr,this.learner_preference=new Qs,this.score=new dr,this.comments_from_learner=new vr,this.comments_from_lms=new _r,this.interactions=new nr,this.objectives=new br,e&&this.initialize()}initialize(){super.initialize(),this.metadata?.initialize(),this.learner?.initialize(),this.status?.initialize(),this.session?.initialize(),this.content?.initialize(),this.settings?.initialize(),this.thresholds?.initialize(),this.learner_preference?.initialize(),this.score?.initialize(),this.comments_from_learner?.initialize(),this.comments_from_lms?.initialize(),this.interactions?.initialize(),this.objectives?.initialize()}reset(){this._initialized=!1,this.metadata?.reset(),this.learner?.reset(),this.status?.reset(),this.session?.reset(),this.content?.reset(),this.settings?.reset(),this.thresholds?.reset(),this.objectives?.reset(!0),this.interactions?.reset(!0),this.score?.reset(),this.comments_from_learner?.reset(),this.comments_from_lms?.reset(),this.learner_preference?.reset()}get _version(){return this.metadata._version}set _version(_version){this.metadata._version=_version}get _children(){return this.metadata._children}set _children(_children){this.metadata._children=_children}get completion_status(){return this.status.completion_status}set completion_status(completion_status){this.status.completion_status=completion_status}get completion_threshold(){return this.thresholds.completion_threshold}set completion_threshold(e){this.thresholds.completion_threshold=e}get credit(){return this.settings.credit}set credit(credit){this.settings.credit=credit}get entry(){return this.session.entry}set entry(entry){this.session.entry=entry}get exit(){return this.session.jsonString=this.jsonString,this.session.exit}set exit(exit){this.session.exit=exit}getExitValueInternal(){return this.session.getExitValueInternal()}get launch_data(){return this.content.launch_data}set launch_data(launch_data){this.content.launch_data=launch_data}get learner_id(){return this.learner.learner_id}set learner_id(learner_id){this.learner.learner_id=learner_id}get learner_name(){return this.learner.learner_name}set learner_name(learner_name){this.learner.learner_name=learner_name}get location(){return this.content.location}set location(location){this.content.location=location}get max_time_allowed(){return this.settings.max_time_allowed}set max_time_allowed(max_time_allowed){this.settings.max_time_allowed=max_time_allowed}get mode(){return this.settings.mode}set mode(mode){this.settings.mode=mode}get progress_measure(){return this.status.progress_measure}set progress_measure(progress_measure){this.status.progress_measure=progress_measure}get scaled_passing_score(){return this.thresholds.scaled_passing_score}set scaled_passing_score(scaled_passing_score){this.thresholds.scaled_passing_score=scaled_passing_score}get session_time(){return this.session.jsonString=this.jsonString,this.session.session_time}set session_time(session_time){this.session.session_time=session_time}get success_status(){return this.status.success_status}set success_status(success_status){this.status.success_status=success_status}get suspend_data(){return this.content.suspend_data}set suspend_data(suspend_data){this.content.suspend_data=suspend_data}get time_limit_action(){return this.settings.time_limit_action}set time_limit_action(time_limit_action){this.settings.time_limit_action=time_limit_action}get total_time(){return this.session.total_time}set total_time(total_time){this.session.total_time=total_time}getCurrentTotalTime(){return this.session.getCurrentTotalTime(this.start_time)}toJSON(){this.jsonString=!0,this.session.jsonString=!0;const result={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,total_time:this.total_time};return this.jsonString=!1,this.session.jsonString=!1,result}}var Gr=Object.defineProperty,Yr=(e,t,i)=>((e,t,i)=>t in e?Gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Wr extends d{constructor(){super("adl"),Yr(this,"nav"),Yr(this,"data",new Kr),Yr(this,"_sequencing",null),this.nav=new Jr,this.data=new Kr}initialize(){super.initialize(),this.nav?.initialize()}reset(){this._initialized=!1,this.nav?.reset()}get sequencing(){return this._sequencing}set sequencing(e){this._sequencing=e,e&&(e.adlNav=this.nav,this.nav.sequencing=e)}toJSON(){this.jsonString=!0;const result={nav:this.nav,data:this.data};return this.jsonString=!1,result}}class Jr extends d{constructor(){super("adl.nav"),Yr(this,"_request","_none_"),Yr(this,"_sequencing",null),Yr(this,"request_valid"),this.request_valid=new en,this.request_valid.setParentNav(this)}get sequencing(){return this._sequencing}set sequencing(e){this._sequencing=e}initialize(){super.initialize(),this.request_valid?.initialize()}reset(){this._initialized=!1,this._request="_none_",this._sequencing&&(this._sequencing.adlNav=null),this._sequencing=null,this.request_valid?.reset()}get request(){return this._request}set request(request){Bt(this._cmi_element+".request",request,he)&&(this._request=request)}toJSON(){this.jsonString=!0;const result={request:this.request};return this.jsonString=!1,result}}class Kr extends x{constructor(){super({CMIElement:"adl.data",children:A.adl_data_children,errorCode:j.READ_ONLY_ELEMENT,errorClass:O})}}class Xr extends d{constructor(){super("adl.data.n"),Yr(this,"_id",""),Yr(this,"_store",""),Yr(this,"_idIsSet",!1),Yr(this,"_storeIsSet",!1)}reset(){this._initialized=!1,this._idIsSet=!1,this._storeIsSet=!1}get id(){return this._id}set id(id){if(this.initialized)throw new O(this._cmi_element+".id",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".id",id,ce)&&(this._id=id,this._idIsSet=!0)}get store(){if(this.initialized&&!this._storeIsSet)throw new O(this._cmi_element+".store",j.VALUE_NOT_INITIALIZED);return this._store}set store(e){if(this.initialized&&!this._idIsSet)throw new O(this._cmi_element+".store",j.DEPENDENCY_NOT_ESTABLISHED);Bt(this._cmi_element+".store",e,te)&&(this._store=e,this._storeIsSet=!0)}toJSON(){this.jsonString=!0;const result={id:this._id,store:this._store};return this.jsonString=!1,result}}class Qr{constructor(){Yr(this,"_parentNav",null),Yr(this,"_staticValues",{})}setParentNav(nav){this._parentNav=nav}_isTargetValid(e){if(this._parentNav?.sequencing?.overallSequencingProcess){const t=this._parentNav.sequencing.overallSequencingProcess;if(t.predictChoiceEnabled)return t.predictChoiceEnabled(e)?"true":"false"}const t=this._staticValues[e];return t===D?"true":t===L?"false":"unknown"}getAll(){return{...this._staticValues}}setAll(e){this._staticValues={...e}}}class Zr{constructor(){Yr(this,"_parentNav",null),Yr(this,"_staticValues",{})}setParentNav(nav){this._parentNav=nav}_isTargetValid(e){if(this._parentNav?.sequencing?.activityTree)return this._parentNav.sequencing.activityTree.getActivity(e)?"true":"false";const t=this._staticValues[e];return t===D?"true":t===L?"false":"unknown"}getAll(){return{...this._staticValues}}setAll(e){this._staticValues={...e}}}class en extends d{constructor(){super("adl.nav.request_valid"),Yr(this,"_continue","unknown"),Yr(this,"_previous","unknown"),Yr(this,"_choice"),Yr(this,"_jump"),Yr(this,"_exit","unknown"),Yr(this,"_exitAll","unknown"),Yr(this,"_abandon","unknown"),Yr(this,"_abandonAll","unknown"),Yr(this,"_suspendAll","unknown"),Yr(this,"_parentNav",null),this._choice=new Qr,this._jump=new Zr}setParentNav(nav){this._parentNav=nav,this._choice.setParentNav(nav),this._jump.setParentNav(nav)}reset(){this._initialized=!1,this._continue="unknown",this._previous="unknown",this._choice.setAll({}),this._jump.setAll({}),this._exit="unknown",this._exitAll="unknown",this._abandon="unknown",this._abandonAll="unknown",this._suspendAll="unknown"}get continue(){if(this._parentNav?.sequencing?.overallSequencingProcess){const e=this._parentNav.sequencing.overallSequencingProcess;if(e.predictContinueEnabled)return e.predictContinueEnabled()?"true":"false"}return this._continue}set continue(e){if(this.initialized)throw new O(this._cmi_element+".continue",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".continue",e,de)&&(this._continue=e)}get previous(){if(this._parentNav?.sequencing?.overallSequencingProcess){const e=this._parentNav.sequencing.overallSequencingProcess;if(e.predictPreviousEnabled)return e.predictPreviousEnabled()?"true":"false"}return this._previous}set previous(e){if(this.initialized)throw new O(this._cmi_element+".previous",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".previous",e,de)&&(this._previous=e)}get choice(){return this._choice}set choice(e){if(this.initialized)throw new O(this._cmi_element+".choice",j.READ_ONLY_ELEMENT);if("object"!=typeof e)throw new O(this._cmi_element+".choice",j.TYPE_MISMATCH);const t={};for(const i in e)if({}.hasOwnProperty.call(e,i)&&Bt(this._cmi_element+".choice."+i,e[i]||"",de)&&Bt(this._cmi_element+".choice."+i,i,me)){const s=e[i];"true"===s?t[i]=D:"false"===s?t[i]=L:"unknown"===s&&(t[i]=q)}this._choice.setAll(t)}get jump(){return this._jump}set jump(e){if(this.initialized)throw new O(this._cmi_element+".jump",j.READ_ONLY_ELEMENT);if("object"!=typeof e)throw new O(this._cmi_element+".jump",j.TYPE_MISMATCH);const t={};for(const i in e)if({}.hasOwnProperty.call(e,i)&&Bt(this._cmi_element+".jump."+i,e[i]||"",de)&&Bt(this._cmi_element+".jump."+i,i,me)){const s=e[i];"true"===s?t[i]=D:"false"===s?t[i]=L:"unknown"===s&&(t[i]=q)}this._jump.setAll(t)}get exit(){return this._exit}set exit(e){if(this.initialized)throw new O(this._cmi_element+".exit",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".exit",e,de)&&(this._exit=e)}get exitAll(){return this._exitAll}set exitAll(e){if(this.initialized)throw new O(this._cmi_element+".exitAll",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".exitAll",e,de)&&(this._exitAll=e)}get abandon(){return this._abandon}set abandon(e){if(this.initialized)throw new O(this._cmi_element+".abandon",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".abandon",e,de)&&(this._abandon=e)}get abandonAll(){return this._abandonAll}set abandonAll(e){if(this.initialized)throw new O(this._cmi_element+".abandonAll",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".abandonAll",e,de)&&(this._abandonAll=e)}get suspendAll(){return this._suspendAll}set suspendAll(e){if(this.initialized)throw new O(this._cmi_element+".suspendAll",j.READ_ONLY_ELEMENT);Bt(this._cmi_element+".suspendAll",e,de)&&(this._suspendAll=e)}toJSON(){this.jsonString=!0;const result={previous:this.previous,continue:this.continue,choice:this._choice.getAll(),jump:this._jump.getAll(),exit:this.exit,exitAll:this.exitAll,abandon:this.abandon,abandonAll:this.abandonAll,suspendAll:this.suspendAll};return this.jsonString=!1,result}}var tn=Object.defineProperty,sn=(e,t,i)=>((e,t,i)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class rn extends d{constructor(e){super("activityTree"),sn(this,"_root",null),sn(this,"_currentActivity",null),sn(this,"_suspendedActivity",null),sn(this,"_activities",new Map),e&&(this.root=e)}initialize(){super.initialize(),this._root&&this._root.initialize()}reset(){this._initialized=!1,this._currentActivity=null,this._suspendedActivity=null,this._activities.clear(),this._root&&(this._root.reset(),this._activities.set(this._root.id,this._root),this._addActivitiesToMap(this._root))}get root(){return this._root}set root(e){if(null!==e&&!(e instanceof ti))throw new O(this._cmi_element+".root",j.TYPE_MISMATCH);this._activities.clear(),this._root=e,e&&(this._activities.set(e.id,e),this._addActivitiesToMap(e))}_addActivitiesToMap(e){for(const t of e.children)this._activities.set(t.id,t),this._addActivitiesToMap(t)}get currentActivity(){return this._currentActivity}set currentActivity(e){if(null!==e&&!(e instanceof ti))throw new O(this._cmi_element+".currentActivity",j.TYPE_MISMATCH);if(this._currentActivity){this._currentActivity.isActive=!1;let e=this._currentActivity.parent;for(;e;)e.isActive=!1,e=e.parent}if(this._currentActivity=e,e){e.isActive=!0;let t=e.parent;for(;t;)t.isActive=!0,t=t.parent}}setCurrentActivityWithoutActivation(e){if(null!==e&&!(e instanceof ti))throw new O(this._cmi_element+".currentActivity",j.TYPE_MISMATCH);if(this._currentActivity){const t=new Set;if(e){t.add(e);let i=e.parent;for(;i;)t.add(i),i=i.parent}this._currentActivity.isActive=!1;let i=this._currentActivity.parent;for(;i;)t.has(i)||(i.isActive=!1),i=i.parent}this._currentActivity=e}get suspendedActivity(){return this._suspendedActivity}set suspendedActivity(e){if(null!==e&&!(e instanceof ti))throw new O(this._cmi_element+".suspendedActivity",j.TYPE_MISMATCH);if(this._suspendedActivity){this._suspendedActivity.isSuspended=!1;let e=this._suspendedActivity.parent;for(;e;)e.isSuspended=!1,e=e.parent}if(this._suspendedActivity=e,e){e.isSuspended=!0;let t=e.parent;for(;t;)t.isSuspended=!0,t=t.parent}}getActivity(id){return this._activities.get(id)||null}getAllActivities(){return Array.from(this._activities.values())}getParent(e){return e.parent}getChildren(e){return 1>=arguments.length||void 0===arguments[1]||arguments[1]?e.getAvailableChildren():e.children}getSiblings(e){return e.parent?e.parent.children.filter(t=>t!==e):[]}getNextSibling(e){let t=1>=arguments.length||void 0===arguments[1]||arguments[1];if(!e.parent)return null;let i=t?e.parent.getAvailableChildren():e.parent.children,s=i.indexOf(e);return-1===s&&t&&(i=e.parent.children,s=i.indexOf(e)),-1===s||s===i.length-1?null:i[s+1]??null}getPreviousSibling(e){let t=1>=arguments.length||void 0===arguments[1]||arguments[1];if(!e.parent)return null;let i=t?e.parent.getAvailableChildren():e.parent.children,s=i.indexOf(e);return-1===s&&t&&(i=e.parent.children,s=i.indexOf(e)),s>0?i[s-1]??null:null}getFirstChild(e){const t=1>=arguments.length||void 0===arguments[1]||arguments[1]?e.getAvailableChildren():e.children;return 0===t.length?null:t[0]??null}getLastChild(e){const t=1>=arguments.length||void 0===arguments[1]||arguments[1]?e.getAvailableChildren():e.children;return 0===t.length?null:t[t.length-1]??null}getCommonAncestor(e,t){const i=[];let s=e;for(;s;)i.unshift(s),s=s.parent;for(s=t;s;){if(i.includes(s))return s;s=s.parent}return null}toJSON(){this.jsonString=!0;const result={root:this._root,currentActivity:this._currentActivity?this._currentActivity.id:null,suspendedActivity:this._suspendedActivity?this._suspendedActivity.id:null};return this.jsonString=!1,result}}var nn=Object.defineProperty,an=(e,t,i)=>((e,t,i)=>t in e?nn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class cn extends d{constructor(){super("sequencing"),an(this,"_activityTree"),an(this,"_sequencingRules"),an(this,"_sequencingControls"),an(this,"_rollupRules"),an(this,"_adlNav",null),an(this,"_hideLmsUi",[]),an(this,"_auxiliaryResources",[]),an(this,"_overallSequencingProcess",null),this._activityTree=new rn,this._sequencingRules=new je,this._sequencingControls=new Xe,this._rollupRules=new Xt}initialize(){super.initialize(),this._activityTree.initialize(),this._sequencingRules.initialize(),this._sequencingControls.initialize(),this._rollupRules.initialize()}reset(){this._initialized=!1,this._activityTree.reset(),this._sequencingRules.reset(),this._sequencingControls.reset(),this._rollupRules.reset(),this._hideLmsUi=[],this._auxiliaryResources=[]}get activityTree(){return this._activityTree}set activityTree(e){if(!(e instanceof rn))throw new O(this._cmi_element+".activityTree",j.TYPE_MISMATCH);this._activityTree=e}get sequencingRules(){return this._sequencingRules}set sequencingRules(e){if(!(e instanceof je))throw new O(this._cmi_element+".sequencingRules",j.TYPE_MISMATCH);this._sequencingRules=e}get sequencingControls(){return this._sequencingControls}set sequencingControls(e){if(!(e instanceof Xe))throw new O(this._cmi_element+".sequencingControls",j.TYPE_MISMATCH);this._sequencingControls=e}get hideLmsUi(){return[...this._hideLmsUi]}set hideLmsUi(e){this._hideLmsUi=[...e]}get auxiliaryResources(){return this._auxiliaryResources.map(e=>({...e}))}set auxiliaryResources(e){this._auxiliaryResources=e.map(e=>({...e}))}get rollupRules(){return this._rollupRules}set rollupRules(e){if(!(e instanceof Xt))throw new O(this._cmi_element+".rollupRules",j.TYPE_MISMATCH);this._rollupRules=e}get adlNav(){return this._adlNav}set adlNav(e){this._adlNav=e}get overallSequencingProcess(){return this._overallSequencingProcess}set overallSequencingProcess(e){this._overallSequencingProcess=e}processRollup(){const e=this._activityTree.root;e&&this._processRollupRecursive(e)}_processRollupRecursive(e){for(const t of e.children)this._processRollupRecursive(t);this._rollupRules.processRollup(e)}getCurrentActivity(){return this._activityTree.currentActivity}getRootActivity(){return this._activityTree.root}toJSON(){this.jsonString=!0;const result={activityTree:this._activityTree,sequencingRules:this._sequencingRules,sequencingControls:this._sequencingControls,rollupRules:this._rollupRules,adlNav:this._adlNav};return this.jsonString=!1,result}}var ln=Object.defineProperty;class un{constructor(e){var t;((e,t,i)=>{t in e?ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(this,"context"+"",t),this.context=e}checkValidResponseType(e,t,i,s){let r=[];t?.delimiter?r=tr(i+"",t.delimiter):r[0]=i,r.length>0&&t.max>=r.length?this.context.checkCorrectResponseValue?this.context.checkCorrectResponseValue(e,s,r,i):this.checkCorrectResponseValue(e,s,r,i):r.length>t.max&&this.context.throwSCORMError(e,j.GENERAL_SET_FAILURE,"Data Model Element Pattern Too Long: "+i)}checkDuplicateChoiceResponse(e,t,i){const s=t.correct_responses._count;if("choice"===t.type)for(let r=0;s>r&&"0"===this.context.getLastErrorCode();r++){const s=t.correct_responses.childArray[r];s?.pattern===i&&this.context.throwSCORMError(e,j.GENERAL_SET_FAILURE,""+i)}}validateCorrectResponse(e,t,i){const s=+e.split(".")[4];if(!t)return void this.context.throwSCORMError(e,j.DEPENDENCY_NOT_ESTABLISHED,e);const r=t.correct_responses._count;this.checkDuplicateChoiceResponse(e,t,i);const n=ge[t.type];n&&(void 0===n.limit||n.limit>r)?(this.checkValidResponseType(e,n,i,t.type),"0"===this.context.getLastErrorCode()&&(!n.duplicate||!this.checkDuplicatedPattern(t.correct_responses,s,i))||"0"===this.context.getLastErrorCode()&&""===i||"0"===this.context.getLastErrorCode()&&this.context.throwSCORMError(e,j.GENERAL_SET_FAILURE,`Data Model Element Pattern Already Exists: ${e} - ${i}`)):this.context.throwSCORMError(e,j.GENERAL_SET_FAILURE,`Data Model Element Collection Limit Reached: ${e} - ${i}`)}checkDuplicatedPattern(e,t,i){let s=!1;const r=e._count;for(let n=0;r>n&&!s;n++)if(n!==t){const t=e.childArray[n],r=t?.pattern;r===i&&(s=!0)}return s}checkCorrectResponseValue(e,t,i,s){const r=ge[t];if(!r)return void this.context.throwSCORMError(e,j.TYPE_MISMATCH,"Incorrect Response Type: "+t);const n=RegExp(r.format);for(let o=0;i.length>o&&"0"===this.context.getLastErrorCode();o++)if(t.match("^(fill-in|long-fill-in|matching|performance|sequencing)$")&&(i[o]=this.removeCorrectResponsePrefixes(e,i[o])),r?.delimiter2){const a="performance"===t?ir(i[o],r.delimiter2):tr(i[o],r.delimiter2);if(2===a.length)if("performance"===t&&""===a[0]&&""===a[1])this.context.throwSCORMError(e,j.TYPE_MISMATCH,`${t}: ${s}`);else{const i=a[0]?.match(n);i&&r.format2&&a[1]?.match(RegExp(r.format2))||this.context.throwSCORMError(e,j.TYPE_MISMATCH,`${t}: ${s}`)}else this.context.throwSCORMError(e,j.TYPE_MISMATCH,`${t}: ${s}`)}else{if("numeric"===t&&i.length>1&&""===i[o]&&r.delimiter&&(s+"").includes(r.delimiter))continue;const a=i[o].match(n);if(!a&&""!==s||!a&&"true-false"===t)this.context.throwSCORMError(e,j.TYPE_MISMATCH,`${t}: ${s}`);else if("numeric"===t&&i.length>1)""!==i[0]&&""!==i[1]&&+i[0]>+i[1]&&this.context.throwSCORMError(e,j.TYPE_MISMATCH,`${t}: ${s}`);else if(""!==i[o]&&r.unique)for(let r=0;o>r&&"0"===this.context.getLastErrorCode();r++)i[o]===i[r]&&this.context.throwSCORMError(e,j.TYPE_MISMATCH,`${t}: ${s}`)}}removeCorrectResponsePrefixes(e,t){let i=!1,s=!1,r=!1;const n=RegExp("^({(lang|case_matters|order_matters)=([^}]+)})");let o,a=t.match(n);for(;a;){switch(a[2]){case"lang":if(o=t.match("^(({lang=([a-zA-Z]{1,8}|i|x)?(-[a-zA-Z0-9-]{2,8})?}))(.*?)$"),o){const i=o[3];void 0!==i&&i.length>0&&(fe.includes(i.toLowerCase())||this.context.throwSCORMError(e,j.TYPE_MISMATCH,""+t))}r=!0;break;case"case_matters":r||i||s||"true"!==a[3]&&"false"!==a[3]&&this.context.throwSCORMError(e,j.TYPE_MISMATCH,""+t),s=!0;break;case"order_matters":s||r||i||"true"!==a[3]&&"false"!==a[3]&&this.context.throwSCORMError(e,j.TYPE_MISMATCH,""+t),i=!0}a=(t=t.substring(a[1]?.length||0)).match(n)}return t}}var hn=Object.defineProperty,dn=(e,t,i)=>((e,t,i)=>t in e?hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class mn{constructor(e,t){dn(this,"context"),dn(this,"responseValidator"),this.context=e,this.responseValidator=t}getChildElement(e,t,i){if(c(e,"cmi\\.objectives\\.\\d+"))return new yr;if(i){if(c(e,"cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+"))return this.createCorrectResponsesObject(e,t);if(c(e,"cmi\\.interactions\\.\\d+\\.objectives\\.\\d+"))return new ar}else if(c(e,"cmi\\.interactions\\.\\d+"))return new or;return c(e,"cmi\\.comments_from_learner\\.\\d+")?new gr:c(e,"cmi\\.comments_from_lms\\.\\d+")?new gr(!0):c(e,"adl\\.data\\.\\d+")?new Xr:null}createCorrectResponsesObject(e,t){const i=e.split("."),s=this.context.cmi.interactions.childArray[+i[2]];if(this.context.isInitialized()){if(void 0===s||!s.type)return this.context.throwSCORMError(e,j.DEPENDENCY_NOT_ESTABLISHED,e),null;{const i=ge[s.type];if(i&&void 0!==i.limit&&s.correct_responses._count>=i.limit)return this.context.throwSCORMError(e,j.GENERAL_SET_FAILURE,"Data Model Element Collection Limit Reached: "+e),null;if(this.responseValidator.checkDuplicateChoiceResponse(e,s,t),!i)return this.context.throwSCORMError(e,j.GENERAL_SET_FAILURE,"Incorrect Response Type: "+s.type),null;this.responseValidator.checkValidResponseType(e,i,t,s.type)}}return"0"===this.context.getLastErrorCode()?new ur(s?.type):null}evaluateCompletionStatus(){const e=this.context.cmi.completion_threshold,t=this.context.cmi.progress_measure,i=this.context.cmi.completion_status;if(""!==e&&null!=e){const i=parseFloat(e+"");if(!isNaN(i)){if(""!==t&&null!=t){const e=parseFloat(t+"");if(!isNaN(e))return i>e?V:k}return H}}return i||H}evaluateSuccessStatus(){const e=this.context.cmi.scaled_passing_score,t=this.context.cmi.score.scaled,i=this.context.cmi.success_status;if(""!==e&&null!=e){const i=parseFloat(e+"");if(!isNaN(i)){if(""!==t&&null!=t){const e=parseFloat(t+"");if(!isNaN(e))return i>e?z:P}return F}}return i||F}}class pn{applySequencingControlsSettings(e,t){void 0!==t.enabled&&(e.enabled=t.enabled),void 0!==t.choice&&(e.choice=t.choice),void 0!==t.choiceExit&&(e.choiceExit=t.choiceExit),void 0!==t.flow&&(e.flow=t.flow),void 0!==t.forwardOnly&&(e.forwardOnly=t.forwardOnly),void 0!==t.useCurrentAttemptObjectiveInfo&&(e.useCurrentAttemptObjectiveInfo=t.useCurrentAttemptObjectiveInfo),void 0!==t.useCurrentAttemptProgressInfo&&(e.useCurrentAttemptProgressInfo=t.useCurrentAttemptProgressInfo),void 0!==t.preventActivation&&(e.preventActivation=t.preventActivation),void 0!==t.constrainChoice&&(e.constrainChoice=t.constrainChoice),void 0!==t.stopForwardTraversal&&(e.stopForwardTraversal=t.stopForwardTraversal),void 0!==t.rollupObjectiveSatisfied&&(e.rollupObjectiveSatisfied=t.rollupObjectiveSatisfied),void 0!==t.rollupProgressCompletion&&(e.rollupProgressCompletion=t.rollupProgressCompletion),void 0!==t.objectiveMeasureWeight&&(e.objectiveMeasureWeight=t.objectiveMeasureWeight),void 0!==t.selectionTiming&&(e.selectionTiming=t.selectionTiming),void 0!==t.selectCount&&(e.selectCount=t.selectCount),void 0!==t.randomizeChildren&&(e.randomizeChildren=t.randomizeChildren),void 0!==t.randomizationTiming&&(e.randomizationTiming=t.randomizationTiming),void 0!==t.selectionCountStatus&&(e.selectionCountStatus=t.selectionCountStatus),void 0!==t.reorderChildren&&(e.reorderChildren=t.reorderChildren),void 0!==t.completionSetByContent&&(e.completionSetByContent=t.completionSetByContent),void 0!==t.objectiveSetByContent&&(e.objectiveSetByContent=t.objectiveSetByContent)}applySequencingRulesSettings(e,t){if(t){if(t.preConditionRules)for(const i of t.preConditionRules){const t=this.createSequencingRule(i);e.addPreConditionRule(t)}if(t.exitConditionRules)for(const i of t.exitConditionRules){const t=this.createSequencingRule(i);e.addExitConditionRule(t)}if(t.postConditionRules)for(const i of t.postConditionRules){const t=this.createSequencingRule(i);e.addPostConditionRule(t)}}}createSequencingRule(e){const t=new Te(e.action,e.conditionCombination);for(const i of e.conditions){const e=new Re(i.condition,i.operator,new Map(Object.entries(i.parameters||{})));i.referencedObjective&&(e.referencedObjective=i.referencedObjective),t.addCondition(e)}return t}applyRollupRulesSettings(e,t){if(t?.rules)for(const i of t.rules){const t=this.createRollupRule(i);e.addRule(t)}}createRollupRule(e){const t=new Kt(e.action,e.consideration,e.minimumCount,e.minimumPercent);for(const i of e.conditions){const e=new Jt(i.condition,new Map(Object.entries(i.parameters||{})));t.addCondition(e)}return t}sanitizeSequencingCollections(e){if(!e)return{};const t={};for(const[id,i]of Object.entries(e)){const e=id.trim();if(!e)continue;const s={};if(i.sequencingControls&&(s.sequencingControls={...i.sequencingControls}),i.sequencingRules){const e=e=>{const t={action:e.action,conditions:e.conditions.map(e=>{const t={condition:e.condition};return void 0!==e.operator&&(t.operator=e.operator),e.parameters&&(t.parameters={...e.parameters}),void 0!==e.referencedObjective&&(t.referencedObjective=e.referencedObjective),t})};return void 0!==e.conditionCombination&&(t.conditionCombination=e.conditionCombination),t};s.sequencingRules={},i.sequencingRules.preConditionRules&&(s.sequencingRules.preConditionRules=i.sequencingRules.preConditionRules.map(e)),i.sequencingRules.exitConditionRules&&(s.sequencingRules.exitConditionRules=i.sequencingRules.exitConditionRules.map(e)),i.sequencingRules.postConditionRules&&(s.sequencingRules.postConditionRules=i.sequencingRules.postConditionRules.map(e))}i.rollupRules&&(s.rollupRules={rules:i.rollupRules.rules?.map(e=>{const t={action:e.action,conditions:e.conditions.map(e=>{const t={condition:e.condition};return e.parameters&&(t.parameters={...e.parameters}),t})};return void 0!==e.consideration&&(t.consideration=e.consideration),void 0!==e.minimumCount&&(t.minimumCount=e.minimumCount),void 0!==e.minimumPercent&&(t.minimumPercent=e.minimumPercent),t})}),i.rollupConsiderations&&(s.rollupConsiderations={...i.rollupConsiderations}),i.selectionRandomizationState&&(s.selectionRandomizationState=this.cloneSelectionRandomizationState(i.selectionRandomizationState)),i.hideLmsUi&&(s.hideLmsUi=this.sanitizeHideLmsUi(i.hideLmsUi)),i.auxiliaryResources&&(s.auxiliaryResources=this.sanitizeAuxiliaryResources(i.auxiliaryResources)),t[e]=s}return t}normalizeCollectionRefs(e){if(!e)return[];const t=Array.isArray(e)?e:[e],i=new Set,result=[];for(const e of t){const t=e.trim();t&&!i.has(t)&&(i.add(t),result.push(t))}return result}applySequencingCollection(e,t,i){if(t){if(t.sequencingControls&&this.applySequencingControlsSettings(e.sequencingControls,t.sequencingControls),t.sequencingRules&&this.applySequencingRulesSettings(e.sequencingRules,t.sequencingRules),t.rollupRules&&this.applyRollupRulesSettings(e.rollupRules,t.rollupRules),t.rollupConsiderations&&e.applyRollupConsiderations(t.rollupConsiderations),t.hideLmsUi){const i=this.mergeHideLmsUi(e.hideLmsUi,t.hideLmsUi);i.length>0&&(e.hideLmsUi=i)}if(t.auxiliaryResources){const i=this.sanitizeAuxiliaryResources(t.auxiliaryResources);i.length>0&&(e.auxiliaryResources=this.mergeAuxiliaryResources(e.auxiliaryResources,i))}t.selectionRandomizationState&&i.push(this.cloneSelectionRandomizationState(t.selectionRandomizationState))}}sanitizeHideLmsUi(e){if(!e)return[];const t=new Set(Ce),i=new Set,s=[];for(const r of e)t.has(r)&&!i.has(r)&&(i.add(r),s.push(r));return s}mergeHideLmsUi(e,t){return t&&0!==t.length?this.sanitizeHideLmsUi([...e,...t]):e}sanitizeAuxiliaryResources(e){if(!e)return[];const t=new Set,i=[];for(const s of e){if(!s)continue;if(!s.resourceId||"string"!=typeof s.resourceId)continue;if(!s.purpose||"string"!=typeof s.purpose)continue;const e=s.resourceId.trim(),r=s.purpose.trim();if(!e||!r)continue;const n=`${e}::${r}`;t.has(n)||(t.add(n),i.push({resourceId:e,purpose:r}))}return i}mergeAuxiliaryResources(e,t){const i=[],s=new Set;for(const r of[...e??[],...t??[]]){if(!r)continue;const e=r.resourceId;e&&!s.has(e)&&(s.add(e),i.push({resourceId:e,purpose:r.purpose}))}return i}cloneSelectionRandomizationState(e){const t={};return e.childOrder&&(t.childOrder=[...e.childOrder]),e.selectedChildIds&&(t.selectedChildIds=[...e.selectedChildIds]),e.hiddenFromChoiceChildIds&&(t.hiddenFromChoiceChildIds=[...e.hiddenFromChoiceChildIds]),void 0!==e.selectionCountStatus&&(t.selectionCountStatus=e.selectionCountStatus),void 0!==e.reorderChildren&&(t.reorderChildren=e.reorderChildren),t}applySelectionRandomizationState(e,t){const i=e.sequencingControls;void 0!==t.selectionCountStatus&&(i.selectionCountStatus=t.selectionCountStatus),void 0!==t.reorderChildren&&(i.reorderChildren=t.reorderChildren);const s=t.selectedChildIds?new Set(t.selectedChildIds):null,r=t.hiddenFromChoiceChildIds?new Set(t.hiddenFromChoiceChildIds):null;t.childOrder&&t.childOrder.length>0&&e.setChildOrder(t.childOrder);let n=!1;if(s||r)for(const t of e.children){if(s){const e=s.has(t.id);t.isAvailable=e,r||(t.isHiddenFromChoice=!e),n=!0}r&&(t.isHiddenFromChoice=r.has(t.id),n=!0)}(n||s||void 0!==t.selectionCountStatus||void 0!==t.reorderChildren||t.childOrder&&t.childOrder.length>0)&&e.setProcessedChildren(e.children.filter(e=>e.isAvailable))}}var _n=Object.defineProperty,vn=(e,t,i)=>((e,t,i)=>t in e?_n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class gn{constructor(e,t){vn(this,"sequencingCollections"),vn(this,"sequencingConfigBuilder"),this.sequencingCollections=e||{},this.sequencingConfigBuilder=t||new pn}setSequencingCollections(e){this.sequencingCollections=e}createActivity(e){const t=new ti(e.id,e.title),i=[],s=this.sequencingConfigBuilder.normalizeCollectionRefs(e.sequencingCollectionRefs);for(const e of s){const s=this.sequencingCollections[e];s&&this.sequencingConfigBuilder.applySequencingCollection(t,s,i)}if(void 0!==e.isVisible&&(t.isVisible=e.isVisible),void 0!==e.isActive&&(t.isActive=e.isActive),void 0!==e.isSuspended&&(t.isSuspended=e.isSuspended),void 0!==e.isCompleted&&(t.isCompleted=e.isCompleted),void 0!==e.isHiddenFromChoice&&(t.isHiddenFromChoice=e.isHiddenFromChoice),void 0!==e.isAvailable&&(t.isAvailable=e.isAvailable),void 0!==e.attemptLimit&&(t.attemptLimit=e.attemptLimit),void 0!==e.attemptAbsoluteDurationLimit&&(t.attemptAbsoluteDurationLimit=e.attemptAbsoluteDurationLimit),void 0!==e.activityAbsoluteDurationLimit&&(t.activityAbsoluteDurationLimit=e.activityAbsoluteDurationLimit),void 0!==e.timeLimitAction&&(t.timeLimitAction=e.timeLimitAction),void 0!==e.timeLimitDuration&&(t.timeLimitDuration=e.timeLimitDuration),void 0!==e.beginTimeLimit&&(t.beginTimeLimit=e.beginTimeLimit),void 0!==e.endTimeLimit&&(t.endTimeLimit=e.endTimeLimit),e.primaryObjective){const i=this.createActivityObjectiveFromSettings(e.primaryObjective,!0);t.primaryObjective=i,null!==i.minNormalizedMeasure&&(t.scaledPassingScore=i.minNormalizedMeasure)}if(e.objectives)for(const i of e.objectives){const e=!0===i.isPrimary,s=this.createActivityObjectiveFromSettings(i,e);e?t.primaryObjective=s:t.addObjective(s)}if(e.sequencingControls&&this.sequencingConfigBuilder.applySequencingControlsSettings(t.sequencingControls,e.sequencingControls),e.sequencingRules&&this.sequencingConfigBuilder.applySequencingRulesSettings(t.sequencingRules,e.sequencingRules),e.rollupRules&&this.sequencingConfigBuilder.applyRollupRulesSettings(t.rollupRules,e.rollupRules),e.rollupConsiderations&&t.applyRollupConsiderations(e.rollupConsiderations),e.hideLmsUi){const i=this.sequencingConfigBuilder.mergeHideLmsUi(t.hideLmsUi,e.hideLmsUi);i.length>0&&(t.hideLmsUi=i)}if(e.auxiliaryResources){const i=this.sequencingConfigBuilder.sanitizeAuxiliaryResources(e.auxiliaryResources);i.length>0&&(t.auxiliaryResources=this.sequencingConfigBuilder.mergeAuxiliaryResources(t.auxiliaryResources,i))}if(e.children)for(const i of e.children){const e=this.createActivity(i);t.addChild(e)}e.selectionRandomizationState&&i.push(this.sequencingConfigBuilder.cloneSelectionRandomizationState(e.selectionRandomizationState));for(const e of i)this.sequencingConfigBuilder.applySelectionRandomizationState(t,e);return t}extractActivityIds(e){const t=[e.id];for(const i of e.children)t.push(...this.extractActivityIds(i));return t}createActivityObjectiveFromSettings(e,t){const i=(e.mapInfo||[]).map(e=>({targetObjectiveID:e.targetObjectiveID,readSatisfiedStatus:e.readSatisfiedStatus??!1,readNormalizedMeasure:e.readNormalizedMeasure??!1,writeSatisfiedStatus:e.writeSatisfiedStatus??!1,writeNormalizedMeasure:e.writeNormalizedMeasure??!1,readCompletionStatus:e.readCompletionStatus??!1,writeCompletionStatus:e.writeCompletionStatus??!1,readProgressMeasure:e.readProgressMeasure??!1,writeProgressMeasure:e.writeProgressMeasure??!1,readRawScore:e.readRawScore??!1,writeRawScore:e.writeRawScore??!1,readMinScore:e.readMinScore??!1,writeMinScore:e.writeMinScore??!1,readMaxScore:e.readMaxScore??!1,writeMaxScore:e.writeMaxScore??!1,updateAttemptData:e.updateAttemptData??!1}));return new ei(e.objectiveID,{description:e.description??null,satisfiedByMeasure:e.satisfiedByMeasure??!1,minNormalizedMeasure:e.minNormalizedMeasure??null,mapInfo:i,isPrimary:t})}}var fn=Object.defineProperty,Sn=(e,t,i)=>((e,t,i)=>t in e?fn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class bn{constructor(e){Sn(this,"_globalObjectives",[]),Sn(this,"context"),this.context=e}get globalObjectives(){return this._globalObjectives}set globalObjectives(objectives){this._globalObjectives=objectives}updateSequencingService(e){this.context.sequencingService=e}syncGlobalObjectiveIdsFromSequencing(){if(!this.context.sequencingService)return;const e=this.context.sequencingService.getOverallSequencingProcess();if(!e)return;const t=e.getGlobalObjectiveMap();if(!t||0===t.size)return;const i=Array.from(t.keys()),s=this.context.getSettings(),r=Array.from(new Set((s.globalObjectiveIds||[]).concat(i)));s.globalObjectiveIds=r}restoreGlobalObjectivesToCMI(){if(0!==this._globalObjectives.length)for(let e=0;this._globalObjectives.length>e;e++){const t=this._globalObjectives[e];if(!t||!t.id)continue;if(this.context.cmi.objectives.findObjectiveById(t.id))continue;const i=this.context.cmi.objectives.childArray.length;this.context.commonSetCMIValue("RestoreGlobalObjective",!0,`cmi.objectives.${i}.id`,t.id),t.success_status&&"unknown"!==t.success_status&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,`cmi.objectives.${i}.success_status`,t.success_status),t.completion_status&&"unknown"!==t.completion_status&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,`cmi.objectives.${i}.completion_status`,t.completion_status),""!==t.score.scaled&&null!==t.score.scaled&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,`cmi.objectives.${i}.score.scaled`,t.score.scaled),""!==t.score.raw&&null!==t.score.raw&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,`cmi.objectives.${i}.score.raw`,t.score.raw),""!==t.score.min&&null!==t.score.min&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,`cmi.objectives.${i}.score.min`,t.score.min),""!==t.score.max&&null!==t.score.max&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,`cmi.objectives.${i}.score.max`,t.score.max),""!==t.progress_measure&&null!==t.progress_measure&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,`cmi.objectives.${i}.progress_measure`,t.progress_measure),""!==t.description&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,`cmi.objectives.${i}.description`,t.description)}}updateGlobalObjectiveFromCMI(e,t){if(!e||!this.context.sequencingService)return;const i=this.context.sequencingService.getOverallSequencingProcess();if(!i)return;if(!i.getGlobalObjectiveMap().has(e)){const s=this.buildObjectiveMapEntryFromCMI(t);return void i.updateGlobalObjective(e,s)}const s={};t.success_status&&t.success_status!==F&&(s.satisfiedStatus=t.success_status===P,s.satisfiedStatusKnown=!0);const r=this.parseObjectiveNumber(t.score?.scaled);null!==r&&(s.normalizedMeasure=r,s.normalizedMeasureKnown=!0);const n=this.parseObjectiveNumber(t.progress_measure);null!==n&&(s.progressMeasure=n,s.progressMeasureKnown=!0),t.completion_status&&t.completion_status!==H&&(s.completionStatus=t.completion_status,s.completionStatusKnown=!0),0!==Object.keys(s).length&&i.updateGlobalObjective(e,s)}buildObjectiveMapEntryFromCMI(e){const entry={id:e.id,satisfiedStatusKnown:!1,normalizedMeasureKnown:!1,progressMeasureKnown:!1,completionStatusKnown:!1,readSatisfiedStatus:!0,writeSatisfiedStatus:!0,readNormalizedMeasure:!0,writeNormalizedMeasure:!0,readCompletionStatus:!0,writeCompletionStatus:!0,readProgressMeasure:!0,writeProgressMeasure:!0};e.success_status&&e.success_status!==F&&(entry.satisfiedStatus=e.success_status===P,entry.satisfiedStatusKnown=!0);const t=this.parseObjectiveNumber(e.score?.scaled);null!==t&&(entry.normalizedMeasure=t,entry.normalizedMeasureKnown=!0);const i=this.parseObjectiveNumber(e.progress_measure);return null!==i&&(entry.progressMeasure=i,entry.progressMeasureKnown=!0),e.completion_status&&e.completion_status!==H&&(entry.completionStatus=e.completion_status,entry.completionStatusKnown=!0),entry}buildCMIObjectivesFromMap(e){const objectives=[];if(!e||"object"!=typeof e)return objectives;for(const[t,entry]of Object.entries(e)){if(!entry||"object"!=typeof entry)continue;const e=new yr;e.id=entry.id??t,!0===entry.satisfiedStatusKnown&&(e.success_status=entry.satisfiedStatus?P:z);const i=this.parseObjectiveNumber(entry.normalizedMeasure);!0===entry.normalizedMeasureKnown&&null!==i&&(e.score.scaled=i+"");const s=this.parseObjectiveNumber(entry.progressMeasure);!0===entry.progressMeasureKnown&&null!==s&&(e.progress_measure=s+""),!0===entry.completionStatusKnown&&"string"==typeof entry.completionStatus&&(e.completion_status=entry.completionStatus),objectives.push(e)}return objectives}buildCMIObjectiveFromJSON(e){const t=new yr;if(!e||"object"!=typeof e)return t;"string"==typeof e.id&&(t.id=e.id),"string"==typeof e.success_status&&(t.success_status=e.success_status),"string"==typeof e.completion_status&&(t.completion_status=e.completion_status),"string"==typeof e.progress_measure&&""!==e.progress_measure&&(t.progress_measure=e.progress_measure),"string"==typeof e.description&&(t.description=e.description);const score=e.score;return score&&"object"==typeof score&&("string"==typeof score.scaled&&""!==score.scaled?t.score.scaled=score.scaled:"number"==typeof score.scaled&&Number.isFinite(score.scaled)&&(t.score.scaled=score.scaled+""),"string"==typeof score.raw&&""!==score.raw?t.score.raw=score.raw:"number"==typeof score.raw&&Number.isFinite(score.raw)&&(t.score.raw=score.raw+""),"string"==typeof score.min&&""!==score.min?t.score.min=score.min:"number"==typeof score.min&&Number.isFinite(score.min)&&(t.score.min=score.min+""),"string"==typeof score.max&&""!==score.max?t.score.max=score.max:"number"==typeof score.max&&Number.isFinite(score.max)&&(t.score.max=score.max+"")),t}captureGlobalObjectiveSnapshot(e){const t={},i=e??this.context.sequencingService?.getOverallSequencingProcess()??null;if(i){const e=i.getGlobalObjectiveMapSnapshot();for(const[id,i]of Object.entries(e))t[id]={...i}}for(const e of this._globalObjectives)e.id&&!t[e.id]&&(t[e.id]=this.buildObjectiveMapEntryFromCMI(e));return t}parseObjectiveNumber(e){if(null==e)return null;if("number"==typeof e&&Number.isFinite(e))return e;const t=parseFloat(e+"");return Number.isFinite(t)?t:null}syncCmiToSequencingActivity(e,t,i){if(!this.context.sequencing)return;const s=this.context.sequencing.getCurrentActivity();if(!s||!s.primaryObjective)return;const r=s.primaryObjective;t!==F&&(r.satisfiedStatus=t===P,r.satisfiedStatusKnown=!0,r.measureStatus=!0,s.objectiveMeasureStatus=!0,s.objectiveSatisfiedStatus=t===P,s.objectiveSatisfiedStatusKnown=!0),e!==H&&(r.completionStatus=e),void 0!==i?.scaled&&null!==i.scaled&&(r.normalizedMeasure=i.scaled,r.measureStatus=!0)}findOrCreateGlobalObjective(e){let t=this._globalObjectives.findIndex(t=>t.id===e);if(-1===t){t=this._globalObjectives.length;const i=new yr;i.id=e,this._globalObjectives.push(i)}return{index:t,objective:this._globalObjectives[t]}}}var yn=Object.defineProperty,Cn=(e,t,i)=>((e,t,i)=>t in e?yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class An{constructor(e,t){Cn(this,"context"),Cn(this,"globalObjectiveManager"),this.context=e,this.globalObjectiveManager=t}async saveSequencingState(e){const t=this.context.getSettings();if(!t.sequencingStatePersistence)return this.context.apiLog("saveSequencingState","No persistence configuration provided",B.WARN),!1;try{const i=this.serializeSequencingState(),s={learnerId:this.context.learnerId||"unknown",courseId:t.courseId||"unknown",attemptNumber:1,lastUpdated:(new Date).toISOString(),version:t.sequencingStatePersistence.stateVersion||"1.0",...e},r=t.sequencingStatePersistence;let n=i;if(!1!==r.compress&&(n=this.compressStateData(i)),r.maxStateSize&&n.length>r.maxStateSize)throw Error(`State size ${n.length} exceeds limit ${r.maxStateSize}`);const o=await r.persistence.saveState(n,s);return r.debugPersistence&&this.context.apiLog("saveSequencingState",`State save ${o?"succeeded":"failed"}: size=${n.length}`,o?B.INFO:B.WARN),o}catch(e){return this.context.apiLog("saveSequencingState","Error saving sequencing state: "+(e instanceof Error?e.message:e+""),B.ERROR),!1}}async loadSequencingState(e){const t=this.context.getSettings();if(!t.sequencingStatePersistence)return this.context.apiLog("loadSequencingState","No persistence configuration provided",B.WARN),!1;try{const i={learnerId:this.context.learnerId||"unknown",courseId:t.courseId||"unknown",attemptNumber:1,version:t.sequencingStatePersistence.stateVersion||"1.0",...e},s=t.sequencingStatePersistence,r=await s.persistence.loadState(i);if(!r)return s.debugPersistence&&this.context.apiLog("loadSequencingState","No sequencing state found to load",B.INFO),!1;let n=r;!1!==s.compress&&(n=this.decompressStateData(r));const o=this.deserializeSequencingState(n);return s.debugPersistence&&this.context.apiLog("loadSequencingState",`State load ${o?"succeeded":"failed"}: size=${r.length}`,o?B.INFO:B.WARN),o}catch(e){return this.context.apiLog("loadSequencingState","Error loading sequencing state: "+(e instanceof Error?e.message:e+""),B.ERROR),!1}}serializeSequencingState(){const e=this.context.getSettings(),t={version:e.sequencingStatePersistence?.stateVersion||"1.0",timestamp:(new Date).toISOString(),sequencing:null,currentActivityId:null,globalObjectives:this.globalObjectiveManager.globalObjectives.map(e=>e.toJSON()),globalObjectiveMap:{},adlNavState:{request:this.context.adl.nav.request,request_valid:this.context.adl.nav.request_valid},contentDelivered:!1};if(this.context.sequencingService){const e=this.context.sequencingService.getOverallSequencingProcess();if(e){const i=e.getSequencingState();t.sequencing=i,t.contentDelivered=e.hasContentBeenDelivered(),t.globalObjectiveMap=this.globalObjectiveManager.captureGlobalObjectiveSnapshot(e)}const i=this.context.sequencing.getCurrentActivity();i&&(t.currentActivityId=i.id)}return t.globalObjectiveMap&&0!==Object.keys(t.globalObjectiveMap).length||(t.globalObjectiveMap=this.globalObjectiveManager.captureGlobalObjectiveSnapshot()),JSON.stringify(t)}deserializeSequencingState(e){try{const t=JSON.parse(e),i=this.context.getSettings(),s=i.sequencingStatePersistence?.stateVersion||"1.0";if(t.version!==s&&this.context.apiLog("deserializeSequencingState",`State version mismatch: ${t.version} vs expected ${s}`,B.WARN),t.globalObjectiveMap&&t.sequencing&&!t.sequencing.globalObjectiveMap&&(t.sequencing.globalObjectiveMap=t.globalObjectiveMap),t.sequencing&&this.context.sequencingService){const e=this.context.sequencingService.getOverallSequencingProcess();e&&(e.restoreSequencingState(t.sequencing),t.contentDelivered&&e.setContentDelivered(!0))}const r=new Map;if(Array.isArray(t.globalObjectives))for(const e of t.globalObjectives){const t=this.globalObjectiveManager.buildCMIObjectiveFromJSON(e);t.id&&r.set(t.id,t)}if(t.globalObjectiveMap&&"object"==typeof t.globalObjectiveMap){const e=this.globalObjectiveManager.buildCMIObjectivesFromMap(t.globalObjectiveMap);for(const t of e)t.id&&(r.has(t.id)||r.set(t.id,t))}return r.size>0&&(this.globalObjectiveManager.globalObjectives=Array.from(r.values()),this.globalObjectiveManager.globalObjectives.forEach(e=>{e.id&&this.globalObjectiveManager.updateGlobalObjectiveFromCMI(e.id,e)})),t.adlNavState&&(this.context.adl.nav.request=t.adlNavState.request||"_none_",this.context.adl.nav.request_valid=t.adlNavState.request_valid||{}),!0}catch(e){return this.context.apiLog("deserializeSequencingState","Error deserializing sequencing state: "+(e instanceof Error?e.message:e+""),B.ERROR),!1}}compressStateData(e){return"undefined"!=typeof btoa?btoa(encodeURIComponent(e)):e}decompressStateData(e){if("undefined"!=typeof atob)try{return decodeURIComponent(atob(e))}catch{return e}return e}}var En=Object.defineProperty,wn=(e,t,i)=>((e,t,i)=>t in e?En(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Mn{constructor(e,t){wn(this,"context"),wn(this,"globalObjectiveManager"),this.context=e,this.globalObjectiveManager=t||null}setGlobalObjectiveManager(e){this.globalObjectiveManager=e}updateSequencingService(e){this.context.sequencingService=e}renderCommitCMI(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.context.renderCMIToJSONObject();e||t?i.cmi.total_time=this.context.cmi.getCurrentTotalTime():delete i.cmi.total_time;const result=[],s=o(i);switch(this.context.getSettings().dataCommitFormat){case"flattened":return o(i);case"params":for(const e in s)({}).hasOwnProperty.call(s,e)&&result.push(`${e}=${s[e]}`);return result;default:return i}}renderCommitObject(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.renderCommitCMI(e,t),s=e||t?this.context.cmi.getCurrentTotalTime():"",n=r(s,ne);let o=H,a=F;this.context.cmi.completion_status&&("completed"===this.context.cmi.completion_status?o=k:"incomplete"===this.context.cmi.completion_status&&(o=V)),this.context.cmi.success_status&&("passed"===this.context.cmi.success_status?a=P:"failed"===this.context.cmi.success_status&&(a=z));const c=this.context.cmi?.score?.getScoreObject()||{},l={completionStatus:o,successStatus:a,totalTimeSeconds:n,runtimeData:i};c&&(l.score=c);const u=this.context.getSettings();if(u.autoPopulateCommitMetadata){u.courseId&&(l.courseId=u.courseId),u.scoId&&(l.scoId=u.scoId),this.context.cmi.learner_id&&(l.learnerId=this.context.cmi.learner_id),this.context.cmi.learner_name&&(l.learnerName=this.context.cmi.learner_name);const e=this.context.sequencingService?.getSequencingState();e?.currentActivity?.id&&(l.activityId=e.currentActivity.id)}return this.globalObjectiveManager&&this.globalObjectiveManager.syncCmiToSequencingActivity(o,a,c),l}determineEntryValue(e,t){const i=e?.trim();return""===e||null==e||""===i?"ab-initio":"suspend"===e?"resume":"logout"===e||"normal"===e?"":"time-out"===e&&t?"resume":""}}var On=Object.defineProperty,Rn=(e,t,i)=>((e,t,i)=>t in e?On(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);"undefined"!=typeof window&&(window.Scorm12API=Scorm12API,window.Scorm2004API=class extends Ss{constructor(e,t){const i=e?{...e}:void 0;i&&void 0===i.mastery_override&&(i.mastery_override=!1),super(j,i,t),Rn(this,"_version","1.0"),Rn(this,"_sequencing"),Rn(this,"_sequencingService",null),Rn(this,"_extractedScoItemIds",[]),Rn(this,"_sequencingCollections",{}),Rn(this,"_responseValidator"),Rn(this,"_cmiHandler"),Rn(this,"_activityTreeBuilder"),Rn(this,"_sequencingConfigBuilder"),Rn(this,"_globalObjectiveManager"),Rn(this,"_statePersistence",null),Rn(this,"_dataSerializer"),Rn(this,"cmi"),Rn(this,"adl"),Rn(this,"Initialize"),Rn(this,"Terminate"),Rn(this,"GetValue"),Rn(this,"SetValue"),Rn(this,"Commit"),Rn(this,"GetLastError"),Rn(this,"GetErrorString"),Rn(this,"GetDiagnostic"),this.cmi=new $r,this.adl=new Wr,this._sequencing=new cn,this.adl.sequencing=this._sequencing,this._sequencingConfigBuilder=new pn,this._activityTreeBuilder=new gn({},this._sequencingConfigBuilder),this._responseValidator=new un({throwSCORMError:(e,t,i)=>this.throwSCORMError(e,t,i),getLastErrorCode:()=>this.lastErrorCode,checkCorrectResponseValue:(e,t,i,s)=>this._responseValidator.checkCorrectResponseValue(e,t,i,s)}),this._cmiHandler=new mn({cmi:this.cmi,isInitialized:()=>this.isInitialized(),throwSCORMError:(e,t,i)=>this.throwSCORMError(e,t,i),getLastErrorCode:()=>this.lastErrorCode},this._responseValidator);const s={getSettings:()=>this.settings,cmi:this.cmi,sequencing:this._sequencing,sequencingService:this._sequencingService,commonSetCMIValue:this._commonSetCMIValue.bind(this)};this._globalObjectiveManager=new bn(s);const r={getSettings:()=>this.settings,cmi:this.cmi,sequencingService:this._sequencingService,renderCMIToJSONObject:this.renderCMIToJSONObject.bind(this)};this._dataSerializer=new Mn(r,this._globalObjectiveManager),i?.sequencing&&this.configureSequencing(i.sequencing),this.initializeSequencingService(i),this.Initialize=this.lmsInitialize,this.Terminate=this.lmsFinish,this.GetValue=this.lmsGetValue,this.SetValue=this.lmsSetValue,this.Commit=this.lmsCommit,this.GetLastError=this.lmsGetLastError,this.GetErrorString=this.lmsGetErrorString,this.GetDiagnostic=this.lmsGetDiagnostic}reset(e){this.commonReset(e),this.cmi?.reset(),this.adl?.reset()}get version(){return this._version}get globalObjectives(){return this._globalObjectiveManager.globalObjectives}set _globalObjectives(objectives){this._globalObjectiveManager.globalObjectives=objectives}get _globalObjectives(){return this._globalObjectiveManager.globalObjectives}compressStateData(e){return this._statePersistence?this._statePersistence.compressStateData(e):"undefined"!=typeof btoa?btoa(encodeURIComponent(e)):e}decompressStateData(e){if(this._statePersistence)return this._statePersistence.decompressStateData(e);if("undefined"!=typeof atob)try{return decodeURIComponent(atob(e))}catch{return e}return e}lmsInitialize(){if(""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:""))return this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),S;this.cmi.initialize();const result=this.initialize("Initialize","LMS was already initialized!","LMS is already finished!");return result===f&&this._sequencingService&&this._sequencingService.initialize(),result===f&&this._globalObjectiveManager.restoreGlobalObjectivesToCMI(),result===f&&this.settings.sequencingStatePersistence&&this.loadSequencingState().catch(()=>{this.apiLog("lmsInitialize","Failed to auto-load sequencing state",B.WARN)}),result}lmsFinish(){if(""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:""))return this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),S;const e=this.adl?.nav?.request||"_none_",t=this.cmi?.getExitValueInternal()||"",i=this.isTerminated(),s=this._sequencingService?.isDeliveryInProgress()??!1,result=this.terminate("Terminate",!0);if(result===f&&!i&&!s){let i=!1,s=null,r=e,n="";const o=RegExp(he);if("_none_"!==e){const t=e.match(o);t&&(t.groups?.choice_target?(n=t.groups?.choice_target,r="choice"):t.groups?.jump_target&&(n=t.groups?.jump_target,r="jump"))}if(this._sequencingService)try{let e,o=null;"_none_"!==r?(o=r,e=n||void 0):this._sequencing.getCurrentActivity()&&(o="exit"),o&&(i=this._sequencingService.processNavigationRequest(o,e,t),s=o)}catch(e){this.apiLog("lmsFinish","Sequencing navigation failed, falling back to event-based navigation: "+e,B.WARN),i=!1}if(!i)if("_none_"!==e){const e={continue:"SequenceNext",previous:"SequencePrevious",choice:"SequenceChoice",jump:"SequenceJump",exit:"SequenceExit",exitAll:"SequenceExitAll",abandon:"SequenceAbandon",abandonAll:"SequenceAbandonAll"}[r];e&&this.processListeners(e,"adl.nav.request",n)}else this.settings.autoProgress&&this.processListeners("SequenceNext",void 0,"next");this._sequencingService&&s&&["exitAll","abandonAll","suspendAll"].includes(s)&&this._sequencingService.terminate(),this.adl.nav.request="_none_"}return result}lmsGetValue(e){if(this.isTerminated())return this.lastErrorCode=j.RETRIEVE_AFTER_TERM+"","";if(!this.isInitialized())return this.lastErrorCode=j.RETRIEVE_BEFORE_INIT+"","";if("adl.nav.request"===e)return this.throwSCORMError(e,j.WRITE_ONLY_ELEMENT,"adl.nav.request is write-only"),"";const t="^adl\\.nav\\.request_valid\\.(choice|jump)\\.{target=([a-zA-Z0-9-_]+)}$";if(c(e,t)){const i=e.match(t);if(i){const request=i[1],e=i[2]?.replace(/{target=/g,"").replace(/}/g,"")||"";if("choice"===request||"jump"===request){const t=this._sequencing?.overallSequencingProcess;return this.settings.scoItemIdValidator?this.settings.scoItemIdValidator(e)+"":t?.predictChoiceEnabled&&"choice"===request?t.predictChoiceEnabled(e)?"true":"false":t?.predictJumpEnabled&&"jump"===request?t.predictJumpEnabled(e)?"true":"false":this._extractedScoItemIds.length>0?this._extractedScoItemIds.includes(e)+"":this.settings?.scoItemIds?.includes(e)+""}}}return"cmi.completion_status"===e?this._cmiHandler.evaluateCompletionStatus():"cmi.success_status"===e?this._cmiHandler.evaluateSuccessStatus():this.getValue("GetValue",!0,e)}lmsSetValue(e,t){const i=this._peekCMIValue(e),result=this.setValue("SetValue","Commit",!0,e,t);if(result===f&&this._sequencingService)try{this._sequencingService.triggerRollupOnCMIChange(e,i,t)}catch(t){console.warn(`Sequencing rollup failed for ${e}: ${t}`)}return result===f&&"setValue"===this.settings.sequencingStatePersistence?.autoSaveOn&&["cmi.completion_status","cmi.success_status","cmi.score.scaled","cmi.objectives","adl.nav.request"].some(t=>e.startsWith(t))&&this.saveSequencingState().catch(()=>{this.apiLog("lmsSetValue","Failed to auto-save sequencing state",B.WARN)}),result}lmsCommit(){if(""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:""))return this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),S;if(this.settings.throttleCommits)return this.scheduleCommit(500,"Commit"),f;{const result=this.commit("Commit",!0);return result===f&&"commit"===this.settings.sequencingStatePersistence?.autoSaveOn&&this.saveSequencingState().catch(()=>{this.apiLog("lmsCommit","Failed to auto-save sequencing state",B.WARN)}),result}}lmsGetLastError(){return this.getLastError("GetLastError")}lmsGetErrorString(e){return this.getErrorString("GetErrorString",e)}lmsGetDiagnostic(e){return this.getDiagnostic("GetDiagnostic",e)}setCMIValue(e,t){if(c(e,"cmi\\.objectives\\.\\d+")){const i=+e.split(".")[2],s="cmi.objectives."+i;let r;if(c(e,"cmi\\.objectives\\.\\d+\\.id"))r=t;else{const e=this.cmi.objectives.findObjectiveByIndex(i);r=e?e.id:void 0}if(r&&this.settings.globalObjectiveIds?.includes(r)){const{index:i}=this._globalObjectiveManager.findOrCreateGlobalObjective(r),n=e.replace(s,"_globalObjectives."+i);this._commonSetCMIValue("SetGlobalObjectiveValue",!0,n,t);const o=this._globalObjectiveManager.globalObjectives[i];r&&o&&this._globalObjectiveManager.updateGlobalObjectiveFromCMI(r,o)}}return this._commonSetCMIValue("SetValue",!0,e,t)}getChildElement(e,t,i){return this._cmiHandler.getChildElement(e,t,i)}validateCorrectResponse(e,t){const i=e.split("."),s=this.cmi.interactions.childArray[+i[2]];s?this._responseValidator.validateCorrectResponse(e,s,t):this.throwSCORMError(e,j.DEPENDENCY_NOT_ESTABLISHED,e)}_peekCMIValue(e){if(!e||"string"!=typeof e)return null;const t=e.split(".");let i=this;for(let e=0;t.length>e;e++){const s=t[e];if(null==i)return null;try{i=i[s]}catch{return null}if(i instanceof x){const s=e+1;if(s>=t.length)return i;const r=+t[s];if(!Number.isNaN(r)&&Number.isInteger(r)&&r>=0){if(r>=i.childArray.length)return null;i=i.childArray[r],e++}}}return i??null}getCMIValue(e){return this._commonGetCMIValue("GetValue",!0,e)}getLmsErrorMessageDetails(e,t){let i="",s="";const r=A.error_descriptions[e+=""];return r&&(i=r.basicMessage,s=r.detailMessage),t?s:i}replaceWithAnotherScormAPI(e){this.cmi=e.cmi,this.adl=e.adl}renderCommitCMI(e){return this._dataSerializer.renderCommitCMI(e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}renderCommitObject(e){return this._dataSerializer.renderCommitObject(e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}storeData(e){e&&"normal"===this.cmi.mode&&"credit"===this.cmi.credit&&(this.cmi.completion_threshold&&this.cmi.progress_measure&&(this.cmi.completion_status=this.cmi.completion_threshold>this.cmi.progress_measure?"incomplete":"completed"),this.cmi.scaled_passing_score&&this.cmi.score.scaled&&(this.cmi.success_status=this.cmi.scaled_passing_score>this.cmi.score.scaled?"failed":"passed"));let t=!1;this.adl.nav.request!==this.startingData?.adl?.nav?.request&&"_none_"!==this.adl.nav.request&&(t=!0);const i=this.getCommitObject(e),s=this.cmi?.score?.getScoreObject()||{};let r=H;"completed"===this.cmi.completion_status?r=k:"incomplete"===this.cmi.completion_status&&(r=V);let n=F;if("passed"===this.cmi.success_status?n=P:"failed"===this.cmi.success_status&&(n=z),this._globalObjectiveManager.syncCmiToSequencingActivity(r,n,s),"string"==typeof this.settings.lmsCommitUrl){const result=this.processHttpRequest(this.settings.lmsCommitUrl,i,e);if(t&&void 0!==result.navRequest&&""!==result.navRequest&&"string"==typeof result.navRequest){const e=function(e){const t=new Set(["start","resumeAll","continue","previous","choice","jump","exit","exitAll","abandon","abandonAll","suspendAll","_none_"]),i=e.trim();if(!i)return{command:"_none_",targetActivityId:null,valid:!1,error:"Empty navigation request"};if(t.has(i))return{command:i,targetActivityId:null,valid:!0};const s=i.indexOf(".");if(s>0){const e=i.substring(0,s),t=i.substring(s+1);if(("choice"===e||"jump"===e)&&t)return/^[a-zA-Z0-9._-]+$/.test(t)?{command:e,targetActivityId:t,valid:!0}:{command:"_none_",targetActivityId:null,valid:!1,error:"Invalid target activity ID: contains disallowed characters"}}return{command:"_none_",targetActivityId:null,valid:!1,error:`Unrecognized navigation command: "${i}"`}}(result.navRequest);if(e.valid){const t={start:"SequenceStart",resumeAll:"SequenceResumeAll",continue:"SequenceNext",previous:"SequencePrevious",choice:"SequenceChoice",jump:"SequenceJump",exit:"SequenceExit",exitAll:"SequenceExitAll",abandon:"SequenceAbandon",abandonAll:"SequenceAbandonAll",suspendAll:"SequenceSuspendAll"}[e.command];t&&this.processListeners(t,"adl.nav.request",e.targetActivityId)}else this.apiLog("storeData","Invalid navigation request from LMS: "+e.error,B.WARN)}else result?.navRequest&&!t&&"object"==typeof result.navRequest&&Object.hasOwnProperty.call(result.navRequest,"name")&&result.navRequest.name&&this.processListeners(result.navRequest.name,result.navRequest.data);return result}return{result:f,errorCode:0}}configureSequencing(e){this._sequencingCollections=this._sequencingConfigBuilder.sanitizeSequencingCollections(e.collections),this._activityTreeBuilder.setSequencingCollections(this._sequencingCollections),e.activityTree&&this.configureActivityTree(e.activityTree),e.sequencingRules&&this.configureSequencingRules(e.sequencingRules),e.sequencingControls&&this.configureSequencingControls(e.sequencingControls),e.rollupRules&&this.configureRollupRules(e.rollupRules),this._sequencing.hideLmsUi=e.hideLmsUi?this._sequencingConfigBuilder.sanitizeHideLmsUi(e.hideLmsUi):[],this._sequencing.auxiliaryResources=e.auxiliaryResources?this._sequencingConfigBuilder.sanitizeAuxiliaryResources(e.auxiliaryResources):[]}configureActivityTree(e){const t=this._activityTreeBuilder.createActivity(e);this._sequencing.activityTree.root=t,this._extractedScoItemIds=this._activityTreeBuilder.extractActivityIds(t)}configureSequencingRules(e){this._sequencingConfigBuilder.applySequencingRulesSettings(this._sequencing.sequencingRules,e)}configureSequencingControls(e){this._sequencingConfigBuilder.applySequencingControlsSettings(this._sequencing.sequencingControls,e)}configureRollupRules(e){this._sequencingConfigBuilder.applyRollupRulesSettings(this._sequencing.rollupRules,e)}initializeSequencingService(e){try{if(this._sequencingService=new ls(this._sequencing,this.cmi,this.adl,this.eventService||this,this.loggingService,{autoRollupOnCMIChange:e?.sequencing?.autoRollupOnCMIChange??!0,autoProgressOnCompletion:e?.sequencing?.autoProgressOnCompletion??!1,validateNavigationRequests:e?.sequencing?.validateNavigationRequests??!0,enableEventSystem:e?.sequencing?.enableEventSystem??!0,logLevel:e?.sequencing?.logLevel??"info"}),e?.sequencing?.eventListeners&&this._sequencingService.setEventListeners(e.sequencing.eventListeners),this._globalObjectiveManager.updateSequencingService(this._sequencingService),this._dataSerializer.updateSequencingService(this._sequencingService),e?.sequencingStatePersistence){const e={getSettings:()=>this.settings,apiLog:this.apiLog.bind(this),adl:this.adl,sequencing:this._sequencing,sequencingService:this._sequencingService,learnerId:this.cmi.learner_id};this._statePersistence=new An(e,this._globalObjectiveManager)}this._globalObjectiveManager.syncGlobalObjectiveIdsFromSequencing()}catch(e){console.warn("Failed to initialize sequencing service:",e),this._sequencingService=null}}getSequencingService(){return this._sequencingService}setSequencingEventListeners(e){this._sequencingService&&this._sequencingService.setEventListeners(e)}updateSequencingConfiguration(e){this._sequencingService&&this._sequencingService.updateConfiguration(e)}getSequencingState(){return this._sequencingService?this._sequencingService.getSequencingState():{isInitialized:!1,isActive:!1,currentActivity:null,rootActivity:this._sequencing.getRootActivity(),lastSequencingResult:null}}processNavigationRequest(request,e){return!!this._sequencingService&&this._sequencingService.processNavigationRequest(request,e)}resetSequencingState(){this._sequencing?.reset(),this._sequencingService?.setEventListeners({})}getActivityTrackingData(e){if(!this._sequencing?.activityTree)return null;const t=this._sequencing.activityTree.getActivity(e);return t?{completionStatus:t.completionStatus||"unknown",successStatus:t.successStatus||"unknown",progressMeasure:t.progressMeasure??null,score:t.objectiveMeasureStatus?t.objectiveNormalizedMeasure:null}:null}async saveSequencingState(e){if(this._statePersistence)return this._statePersistence.saveSequencingState(e);if(!this.settings.sequencingStatePersistence)return this.apiLog("saveSequencingState","No persistence configuration provided",B.WARN),!1;const t={getSettings:()=>this.settings,apiLog:this.apiLog.bind(this),adl:this.adl,sequencing:this._sequencing,sequencingService:this._sequencingService,learnerId:this.cmi.learner_id};return new An(t,this._globalObjectiveManager).saveSequencingState(e)}async loadSequencingState(e){if(this._statePersistence)return this._statePersistence.loadSequencingState(e);if(!this.settings.sequencingStatePersistence)return this.apiLog("loadSequencingState","No persistence configuration provided",B.WARN),!1;const t={getSettings:()=>this.settings,apiLog:this.apiLog.bind(this),adl:this.adl,sequencing:this._sequencing,sequencingService:this._sequencingService,learnerId:this.cmi.learner_id};return new An(t,this._globalObjectiveManager).loadSequencingState(e)}serializeSequencingState(){if(this._statePersistence)return this._statePersistence.serializeSequencingState();const e={getSettings:()=>this.settings,apiLog:this.apiLog.bind(this),adl:this.adl,sequencing:this._sequencing,sequencingService:this._sequencingService,learnerId:this.cmi.learner_id};return new An(e,this._globalObjectiveManager).serializeSequencingState()}deserializeSequencingState(e){if(this._statePersistence)return this._statePersistence.deserializeSequencingState(e);const t={getSettings:()=>this.settings,apiLog:this.apiLog.bind(this),adl:this.adl,sequencing:this._sequencing,sequencingService:this._sequencingService,learnerId:this.cmi.learner_id};return new An(t,this._globalObjectiveManager).deserializeSequencingState(e)}determineEntryValue(e,t){return this._dataSerializer.determineEntryValue(e,t)}})}();
1
+ !function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,o=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}}(e,t)||n(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 i(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||n(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,i){if(t){if("string"==typeof t)return e(t,i);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,i):void 0}}var r={D:86400,H:3600,M:60,S:1},o=function(e){if(!e||0>=e)return"00:00:00";var t=Math.floor(e/3600),i=new Date(1e3*e),n=i.getUTCMinutes(),r=i.getSeconds(),o=e%1,s="";return d(o)>0&&(s="."+(s=d(o)>2?o.toFixed(2):o+"").split(".")[1]),(t+":"+n+":"+r).replace(/\b\d\b/g,"0$&")+s},s=function(e){if(!e||0>=e)return"PT0S";var i="P",n=e;return Object.entries(r).forEach(function(e){var r=t(e,2),o=r[0],s=r[1],a=Math.floor(n/s);d(n%=s)>2&&(n=+(+n).toFixed(2)),"S"===o&&n>0&&(a+=n),a&&((i.indexOf("D")>0||["H","M","S"].includes(o))&&-1===i.indexOf("T")&&(i+="T"),i+="".concat(a).concat(o))}),i},a=v(function(e,t){if("number"!=typeof e&&"boolean"!=typeof e||(e+=""),"string"==typeof t&&(t=RegExp(t)),!e)return 0;if(!e.match(t))return/^\d+(?:\.\d+)?$/.test(e)?+e:0;var i=e.split(":");return 3600*+i[0]+60*+i[1]+ +i[2]},function(e,t){var i,n="string"==typeof t?t:null!==(i=null==t?void 0:""+t)&&void 0!==i?i:"";return"".concat("string"==typeof e?e:(null!=e?e:"")+"",":").concat(n)}),u=v(function(e,i){var n,r,o,s;if("string"==typeof i&&(i=RegExp(i)),!e||!(null==e||null===(r=e.match)||void 0===r?void 0:r.call(e,i)))return 0;var a=t(null!==(n=null===(o=(s=RegExp(i)).exec)||void 0===o?void 0:o.call(s,e))&&void 0!==n?n:[],8),result=0;return result+=+a[7]||0,result+=60*+a[6]||0,result+=3600*+a[5]||0,result+=86400*+a[4]||0,result+=604800*+a[3]||0,(result+=2592e3*+a[2]||0)+(31536e3*+a[1]||0)},function(e,t){var i,n="string"==typeof t?t:null!==(i=null==t?void 0:""+t)&&void 0!==i?i:"";return"".concat(null!=e?e:"",":").concat(n)}),l=v(function(e,t){var i;return"string"==typeof t&&(t=RegExp(t)),!(!e||!(null==e||null===(i=e.match)||void 0===i?void 0:i.call(e,t)))});function c(e){var result={};return function e(t,i){if(Object(t)!==t)result[i]=t;else if(Array.isArray(t))t.forEach(function(t,n){e(t,"".concat(i,"[").concat(n,"]"))}),0===t.length&&(result[i]=[]);else{var n=Object.keys(t).filter(function(e){return{}.hasOwnProperty.call(t,e)}),r=0===n.length;n.forEach(function(n){e(t[n],i?"".concat(i,".").concat(n):n)}),r&&i&&(result[i]={})}}(e,""),result}function d(e){var t,i,n,r;if(Math.floor(e)===e||0>(null===(n=e+"")||void 0===n||null===(i=n.indexOf)||void 0===i?void 0:i.call(n,".")))return 0;var o=null===(r=(""+e).split("."))||void 0===r?void 0:r[1];return null!==(t=null==o?void 0:o.length)&&void 0!==t?t:0}function f(e,t){return"string"==typeof e&&RegExp(t).test(e)}function v(e,t){var n=new Map;return function(){for(var r=arguments.length,o=Array(r),s=0;r>s;s++)o[s]=arguments[s];var result,a=t?t.apply(void 0,i(o)):JSON.stringify(o);return n.has(a)?n.get(a):(result=e.apply(void 0,i(o)),n.set(a,result),result)}}var h=function(e,t,i){var n=e.indexOf("#"),r=-1===n?e:e.slice(0,n),o=-1===n?"":e.slice(n),s=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?",a="".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(i+""));return"".concat(r).concat(s).concat(a).concat(o)};function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t,i){return t&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}function g(e,t){return g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},g(e,t)}function _(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function b(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(b=function(){return!!result})()}var S=Object.defineProperty,w=function(e,t,i){return function(e,t,i){return t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":_(t))?t+"":t,i)},C=function(){function e(t){m(this,e),w(this,"jsonString",!1),w(this,"_cmi_element"),w(this,"_initialized",!1),this._cmi_element=t}return p(e,[{key:"initialized",get:function(){return this._initialized}},{key:"initialize",value:function(){this._initialized=!0}}]),e}(),O=function(e){function t(){var e;return m(this,t),e=function(e,t,i){return t=y(t),n=e,!(r=b()?Reflect.construct(t,i||[],y(e).constructor):t.apply(e,i))||"object"!==_(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,arguments),w(e,"_start_time"),e}return function(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}}),t&&g(e,t)}(t,e),p(t,[{key:"start_time",get:function(){return this._start_time}},{key:"setStartTime",value:function(){if(void 0!==this._start_time)throw Error("Start time has already been set.");this._start_time=(new Date).getTime()}}]),t}(C);function E(e,t,i){return t=R(t),n=e,!(r=x()?Reflect.construct(t,i||[],R(e).constructor):t.apply(e,i))||"object"!==P(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}function A(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t,i){return k=x()?Reflect.construct:function(e,t,i){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(e,n));return i&&T(r,i.prototype),r},k.apply(null,arguments)}function j(e,t,i){return t&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}function R(e){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},R(e)}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}}),t&&T(e,t)}function T(e,t){return T=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},T(e,t)}function P(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function I(e){var t="function"==typeof Map?new Map:void 0;return I=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return k(e,arguments,R(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),T(i,e)},I(e)}function x(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(x=function(){return!!result})()}var N=Object.defineProperty,D=function(e,t,i){return function(e,t,i){return t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":P(t))?t+"":t,i)},q=function(e){function t(e,i){var n;return A(this,t),n=E(this,t,["".concat(e," : ").concat(""+i)]),D(n,"_errorCode"),n._errorCode=i,Object.setPrototypeOf(n,t.prototype),n}return M(t,e),j(t,[{key:"errorCode",get:function(){return this._errorCode}}]),t}(I(Error)),L=function(e){function t(e,i,n,r){var o;return A(this,t),o=E(this,t,[e,i]),D(o,"_errorMessage"),D(o,"_detailedMessage",""),o.message="".concat(e," : ").concat(n),o._errorMessage=n,r&&(o._detailedMessage=r),Object.setPrototypeOf(o,t.prototype),o}return M(t,e),j(t,[{key:"errorMessage",get:function(){return this._errorMessage}},{key:"detailedMessage",get:function(){return this._detailedMessage}}]),t}(q),z="true",F="false",B={cmi_children:"core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions",core_children:"student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,lesson_mode,exit,session_time",score_children:"raw,min,max",objectives_children:"id,score,status",correct_responses_children:"pattern",student_data_children:"mastery_score,max_time_allowed,time_limit_action",student_preference_children:"audio,language,speed,text",interactions_children:"id,objectives,time,type,correct_responses,weighting,student_response,result,latency",error_descriptions:{0:{basicMessage:"No Error",detailMessage:"No error occurred, the previous API call was successful."},101:{basicMessage:"General Exception",detailMessage:"No specific error code exists to describe the error."},201:{basicMessage:"Invalid argument error",detailMessage:"Indicates that an argument represents an invalid data model element or is otherwise incorrect."},202:{basicMessage:"Element cannot have children",detailMessage:'Indicates that LMSGetValue was called with a data model element name that ends in "_children" for a data model element that does not support the "_children" suffix.'},203:{basicMessage:"Element not an array - cannot have count",detailMessage:'Indicates that LMSGetValue was called with a data model element name that ends in "_count" for a data model element that does not support the "_count" suffix.'},301:{basicMessage:"Not initialized",detailMessage:"Indicates that an API call was made before the call to lmsInitialize."},401:{basicMessage:"Not implemented error",detailMessage:"The data model element indicated in a call to LMSGetValue or LMSSetValue is valid, but was not implemented by this LMS. SCORM 1.2 defines a set of data model elements as being optional for an LMS to implement."},402:{basicMessage:"Invalid set value, element is a keyword",detailMessage:'Indicates that LMSSetValue was called on a data model element that represents a keyword (elements that end in "_children" and "_count").'},403:{basicMessage:"Element is read only",detailMessage:"LMSSetValue was called with a data model element that can only be read."},404:{basicMessage:"Element is write only",detailMessage:"LMSGetValue was called on a data model element that can only be written to."},405:{basicMessage:"Incorrect Data Type",detailMessage:"LMSSetValue was called with a value that is not consistent with the data format of the supplied data model element."},407:{basicMessage:"Element Value Out Of Range",detailMessage:"The numeric value supplied to a LMSSetValue call is outside of the numeric range allowed for the supplied data model element."},408:{basicMessage:"Data Model Dependency Not Established",detailMessage:"Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element."}}},V={cmi_children:"_version,comments_from_learner,comments_from_lms,completion_status,completion_threshold,credit,entry,exit,interactions,launch_data,learner_id,learner_name,learner_preference,location,max_time_allowed,mode,objectives,progress_measure,scaled_passing_score,score,session_time,success_status,suspend_data,time_limit_action,total_time",comments_children:"comment,timestamp,location",score_children:"max,raw,scaled,min",objectives_children:"progress_measure,completion_status,success_status,description,score,id",correct_responses_children:"pattern",student_preference_children:"audio_level,audio_captioning,delivery_speed,language",interactions_children:"id,type,objectives,timestamp,correct_responses,weighting,learner_response,result,latency,description",adl_data_children:"id,store",error_descriptions:{0:{basicMessage:"No Error",detailMessage:"No error occurred, the previous API call was successful."},101:{basicMessage:"General Exception",detailMessage:"No specific error code exists to describe the error."},102:{basicMessage:"General Initialization Failure",detailMessage:"Call to Initialize failed for an unknown reason."},103:{basicMessage:"Already Initialized",detailMessage:"Call to Initialize failed because Initialize was already called."},104:{basicMessage:"Content Instance Terminated",detailMessage:"Call to Initialize failed because Terminate was already called."},111:{basicMessage:"General Termination Failure",detailMessage:"Call to Terminate failed for an unknown reason."},112:{basicMessage:"Termination Before Initialization",detailMessage:"Call to Terminate failed because it was made before the call to Initialize."},113:{basicMessage:"Termination After Termination",detailMessage:"Call to Terminate failed because Terminate was already called."},122:{basicMessage:"Retrieve Data Before Initialization",detailMessage:"Call to GetValue failed because it was made before the call to Initialize."},123:{basicMessage:"Retrieve Data After Termination",detailMessage:"Call to GetValue failed because it was made after the call to Terminate."},132:{basicMessage:"Store Data Before Initialization",detailMessage:"Call to SetValue failed because it was made before the call to Initialize."},133:{basicMessage:"Store Data After Termination",detailMessage:"Call to SetValue failed because it was made after the call to Terminate."},142:{basicMessage:"Commit Before Initialization",detailMessage:"Call to Commit failed because it was made before the call to Initialize."},143:{basicMessage:"Commit After Termination",detailMessage:"Call to Commit failed because it was made after the call to Terminate."},201:{basicMessage:"General Argument Error",detailMessage:"An invalid argument was passed to an API method (usually indicates that Initialize, Commit or Terminate did not receive the expected empty string argument."},301:{basicMessage:"General Get Failure",detailMessage:"Indicates a failed GetValue call where no other specific error code is applicable. Use GetDiagnostic for more information."},351:{basicMessage:"General Set Failure",detailMessage:"Indicates a failed SetValue call where no other specific error code is applicable. Use GetDiagnostic for more information."},391:{basicMessage:"General Commit Failure",detailMessage:"Indicates a failed Commit call where no other specific error code is applicable. Use GetDiagnostic for more information."},401:{basicMessage:"Undefined Data Model Element",detailMessage:"The data model element name passed to GetValue or SetValue is not a valid SCORM data model element."},402:{basicMessage:"Unimplemented Data Model Element",detailMessage:"The data model element indicated in a call to GetValue or SetValue is valid, but was not implemented by this LMS. In SCORM 2004, this error would indicate an LMS that is not fully SCORM conformant."},403:{basicMessage:"Data Model Element Value Not Initialized",detailMessage:"Attempt to read a data model element that has not been initialized by the LMS or through a SetValue call. This error condition is often reached during normal execution of a SCO."},404:{basicMessage:"Data Model Element Is Read Only",detailMessage:"SetValue was called with a data model element that can only be read."},405:{basicMessage:"Data Model Element Is Write Only",detailMessage:"GetValue was called on a data model element that can only be written to."},406:{basicMessage:"Data Model Element Type Mismatch",detailMessage:"SetValue was called with a value that is not consistent with the data format of the supplied data model element."},407:{basicMessage:"Data Model Element Value Out Of Range",detailMessage:"The numeric value supplied to a SetValue call is outside of the numeric range allowed for the supplied data model element."},408:{basicMessage:"Data Model Dependency Not Established",detailMessage:"Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element."}}};function H(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function U(e,t,i){return t=G(t),n=e,!(r=W()?Reflect.construct(t,i||[],G(e).constructor):t.apply(e,i))||"object"!=((o=r)&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)&&"function"!=typeof r?H(n):r;var n,r,o}function G(e){return G=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},G(e)}function Y(e,t){return Y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Y(e,t)}function W(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(W=function(){return!!result})()}var J=B.error_descriptions,K=function(e){function t(e,i){var n,r,o,s,a,u;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n={}.hasOwnProperty.call(J,i+"")?U(this,t,[e,i,(null===(r=J[i+""])||void 0===r?void 0:r.basicMessage)||"Unknown error",null===(o=J[i+""])||void 0===o?void 0:o.detailMessage]):U(this,t,[e,101,null!==(s=null===(a=J[101])||void 0===a?void 0:a.basicMessage)&&void 0!==s?s:"General error",null===(u=J[101])||void 0===u?void 0:u.detailMessage]),Object.setPrototypeOf(H(n),t.prototype),H(n)}return function(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}}),t&&Y(e,t)}(t,e),t}(L);function $(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function X(e,t,i){return t=Q(t),n=e,!(r=ee()?Reflect.construct(t,i||[],Q(e).constructor):t.apply(e,i))||"object"!=((o=r)&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)&&"function"!=typeof r?$(n):r;var n,r,o}function Q(e){return Q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Q(e)}function Z(e,t){return Z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Z(e,t)}function ee(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ee=function(){return!!result})()}var te=V.error_descriptions,ie=function(e){function t(e,i){var n,r,o,s,a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n={}.hasOwnProperty.call(te,i+"")?X(this,t,[e,i,(null===(r=te[i+""])||void 0===r?void 0:r.basicMessage)||"Unknown error",null===(o=te[i+""])||void 0===o?void 0:o.detailMessage]):X(this,t,[e,101,(null===(s=te[101])||void 0===s?void 0:s.basicMessage)||"General error",null===(a=te[101])||void 0===a?void 0:a.detailMessage]),Object.setPrototypeOf($(n),t.prototype),$(n)}return function(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}}),t&&Z(e,t)}(t,e),t}(L);function ne(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function re(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){ne(e,t,i[t])})}return e}function oe(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t}(Object(t)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}var se={GENERAL:101,INITIALIZATION_FAILED:101,INITIALIZED:101,TERMINATED:101,TERMINATION_FAILURE:101,TERMINATION_BEFORE_INIT:101,MULTIPLE_TERMINATION:101,RETRIEVE_BEFORE_INIT:101,RETRIEVE_AFTER_TERM:101,STORE_BEFORE_INIT:101,STORE_AFTER_TERM:101,COMMIT_BEFORE_INIT:101,COMMIT_AFTER_TERM:101,ARGUMENT_ERROR:101,CHILDREN_ERROR:101,COUNT_ERROR:101,GENERAL_GET_FAILURE:101,GENERAL_SET_FAILURE:101,GENERAL_COMMIT_FAILURE:101,UNDEFINED_DATA_MODEL:101,UNIMPLEMENTED_ELEMENT:101,VALUE_NOT_INITIALIZED:101,INVALID_SET_VALUE:101,READ_ONLY_ELEMENT:101,WRITE_ONLY_ELEMENT:101,TYPE_MISMATCH:101,VALUE_OUT_OF_RANGE:101,DEPENDENCY_NOT_ESTABLISHED:101},ae=oe(re({},se),{RETRIEVE_BEFORE_INIT:301,STORE_BEFORE_INIT:301,COMMIT_BEFORE_INIT:301,ARGUMENT_ERROR:201,CHILDREN_ERROR:202,COUNT_ERROR:203,UNDEFINED_DATA_MODEL:401,UNIMPLEMENTED_ELEMENT:401,VALUE_NOT_INITIALIZED:301,INVALID_SET_VALUE:402,READ_ONLY_ELEMENT:403,WRITE_ONLY_ELEMENT:404,TYPE_MISMATCH:405,VALUE_OUT_OF_RANGE:405,DEPENDENCY_NOT_ESTABLISHED:408}),ue=oe(re({},se),{INITIALIZATION_FAILED:102,INITIALIZED:103,TERMINATED:104,TERMINATION_FAILURE:111,TERMINATION_BEFORE_INIT:112,MULTIPLE_TERMINATION:113,MULTIPLE_TERMINATIONS:113,RETRIEVE_BEFORE_INIT:122,RETRIEVE_AFTER_TERM:123,STORE_BEFORE_INIT:132,STORE_AFTER_TERM:133,COMMIT_BEFORE_INIT:142,COMMIT_AFTER_TERM:143,ARGUMENT_ERROR:201,GENERAL_GET_FAILURE:301,GENERAL_SET_FAILURE:351,GENERAL_COMMIT_FAILURE:391,UNDEFINED_DATA_MODEL:401,UNIMPLEMENTED_ELEMENT:402,VALUE_NOT_INITIALIZED:403,READ_ONLY_ELEMENT:404,WRITE_ONLY_ELEMENT:405,TYPE_MISMATCH:406,VALUE_OUT_OF_RANGE:407,DEPENDENCY_NOT_ESTABLISHED:408});function le(e){return le=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},le(e)}function ce(e,t){return ce=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ce(e,t)}function de(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function fe(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(fe=function(){return!!result})()}var ve=Object.defineProperty,he=function(e,t,i){return function(e,t,i){return t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":de(t))?t+"":t,i)},me=function(e){function t(e){var i,n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=function(e,t,i){return t=le(t),n=e,!(r=fe()?Reflect.construct(t,i||[],le(e).constructor):t.apply(e,i))||"object"!==de(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,[e.CMIElement]),he(i,"_errorCode"),he(i,"_errorClass"),he(i,"__children"),he(i,"childArray"),i.__children=e.children,i._errorCode=null!==(n=e.errorCode)&&void 0!==n?n:ae.GENERAL,i._errorClass=e.errorClass||q,i.childArray=[],i}return function(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}}),t&&ce(e,t)}(t,e),i=t,n=[{key:"reset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this._initialized=!1,e)this.childArray=[];else for(var t=0;this.childArray.length>t;t++){var i;null===(i=this.childArray[t])||void 0===i||i.reset()}}},{key:"_children",get:function(){return this.__children},set:function(_children){throw new this._errorClass(this._cmi_element+"._children",this._errorCode)}},{key:"_count",get:function(){return this.childArray.length},set:function(_count){throw new this._errorClass(this._cmi_element+"._count",this._errorCode)}},{key:"toJSON",value:function(){this.jsonString=!0;for(var result={},e=0;this.childArray.length>e;e++)result[e+""]=this.childArray[e];return this.jsonString=!1,result}}],n&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C),pe="unknown",ye="true",ge="false",_e="passed",be="failed",Se="unknown",we="completed",Ce="incomplete",Oe="unknown",Ee={_:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5};function Ae(e,t,i,n,r,o,s){try{var a=e[o](s),u=a.value}catch(e){return void i(e)}a.done?t(u):Promise.resolve(u).then(n,r)}var ke={autocommit:!1,autocommitSeconds:10,throttleCommits:!1,useAsynchronousCommits:!1,sendFullCommit:!0,lmsCommitUrl:!1,dataCommitFormat:"json",commitRequestDataType:"application/json;charset=UTF-8",autoProgress:!1,logLevel:Ee.ERROR,selfReportSessionTime:!1,alwaysSendTotalTime:!1,renderCommonCommitFields:!1,autoCompleteLessonStatus:!1,strict_errors:!0,xhrHeaders:{},xhrWithCredentials:!1,fetchMode:"cors",asyncModeBeaconBehavior:"never",includeCommitSequence:!1,responseHandler:function(e){return(t=function(){var t,i;return function(e,t){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(s,"next",{value:u(0)}),a(s,"throw",{value:u(1)}),a(s,"return",{value:u(2)}),"function"==typeof Symbol&&a(s,Symbol.iterator,{value:function(){return this}}),s;function u(a){return function(u){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&r[3]>a[1])){o.label=a[1];break}if(6===a[0]&&r[1]>o.label){o.label=r[1],r=a;break}if(r&&r[2]>o.label){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,function(n){switch(n.label){case 0:if(void 0===e)return[3,8];t=null,n.label=1;case 1:return n.trys.push([1,6,,7]),"function"!=typeof e.json?[3,3]:[4,e.json()];case 2:return t=n.sent(),[3,5];case 3:return"function"!=typeof e.text?[3,5]:[4,e.text()];case 4:(i=n.sent())&&(t=JSON.parse(i)),n.label=5;case 5:return[3,7];case 6:return n.sent(),[3,7];case 7:return null!==t&&{}.hasOwnProperty.call(t,"result")?[2,{result:t.result,errorCode:"number"==typeof t.errorCode?t.errorCode:!0===t.result||t.result===z?0:101}]:200===e.status?[2,{result:z,errorCode:0}]:[2,{result:F,errorCode:101}];case 8:return[2,{result:F,errorCode:101}]}})},function(){var e=this,i=arguments;return new Promise(function(n,r){var o=t.apply(e,i);function s(e){Ae(o,n,r,s,a,"next",e)}function a(e){Ae(o,n,r,s,a,"throw",e)}s(void 0)})})();var t},xhrResponseHandler:function(e){if(void 0!==e){var t=null;if(200>e.status||e.status>299)return{result:F,errorCode:101};try{t=JSON.parse(e.responseText)}catch(e){}return null!==t&&{}.hasOwnProperty.call(t,"result")?{result:t.result,errorCode:"number"==typeof t.errorCode?t.errorCode:!0===t.result||t.result===z?0:101}:{result:z,errorCode:0}}return{result:F,errorCode:101}},requestHandler:function(e){return e},onLogMessage:je,mastery_override:!1,score_overrides_status:!1,completion_status_on_failed:"completed",scoItemIds:[],scoItemIdValidator:!1,globalObjectiveIds:[],enableOfflineSupport:!1,courseId:"",syncOnInitialize:!0,syncOnTerminate:!0,maxSyncAttempts:5,scoId:"",autoPopulateCommitMetadata:!1,httpService:null,globalStudentPreferences:!1};function je(e,t){switch(e){case"4":case 4:case"ERROR":case Ee.ERROR:console.error(t);break;case"3":case 3:case"WARN":case Ee.WARN:console.warn(t);break;case"2":case 2:case"INFO":case Ee.INFO:console.info(t);break;case"1":case 1:case"DEBUG":case Ee.DEBUG:console.debug?console.debug(t):console.log(t)}}var Re="^[\\s\\S]{0,255}$",Me="^([0-9]+):([0-9]{2}):([0-9]{2})(\\.\\d{1,2})?$",Te="^-?([0-9]+)$",Pe="^-?([0-9]{0,10})(\\.[0-9]*)?$",Ie="^[\\u0021-\\u007E\\s]{0,255}$",xe="^.*$",Ne="^(passed|completed|failed|incomplete|browsed|not attempted)$",De="0#100",qe="^[\\u0000-\\uFFFF]{0,4000}$",Le="^[\\u0000-\\uFFFF]{0,64000}$",ze="^({lang=([a-zA-Z]{1,8}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,250}$)?$",Fe="^({lang=([a-zA-Z]{1,8}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,4000}$)?$",Be="^(19[7-9][0-9]|[2-9][0-9]{3})((-(0[1-9]|1[0-2]))((-(0[1-9]|[1-2][0-9]|3[0-1]))(T([0-1][0-9]|2[0-3])((:[0-5][0-9])((:[0-5][0-9])((\\.[0-9]{1,6})((Z|([+|-]([0-1][0-9]|2[0-3])))(:[0-5][0-9])?)?)?)?)?)?)?)?$",Ve="^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:(\\d+(?:\\.\\d{1,2})?)S)?)?$",He="^-?([0-9]{1,10})(\\.[0-9]{1,18})?$",Ue="^(?=.*\\w)[\\w\\-\\(\\)\\+\\.\\:\\=\\@\\;\\$\\_\\!\\*\\'\\%\\/\\#]{1,250}$",Ge="^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$",Ye="^(completed|incomplete|not attempted|unknown)$",We="^(passed|failed|unknown)$",Je="^(_?(start|resumeAll|previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|retry|retryAll)|_none_|(\\{target=(?<choice_target>\\S{0,}[a-zA-Z0-9-_]+)})?choice|(\\{target=(?<jump_target>\\S{0,}[a-zA-Z0-9-_]+)})?jump)$",Ke="^(unknown|true|false)$",$e="^{target=\\S{0,}[a-zA-Z0-9-_]+}$",Xe="^$|"+Ue,Qe="(?![\\s\\S]*(?:\\[,\\]|\\[\\.\\]|\\[:\\]))[\\s\\S]{1,250}",Ze={"true-false":{format:"^true$|^false$",max:1,delimiter:"",unique:!1},choice:{format:Ge,max:36,delimiter:"[,]",unique:!0},"fill-in":{format:ze,max:10,delimiter:"[,]",unique:!1},"long-fill-in":{format:Fe,max:1,delimiter:"",unique:!1},matching:{format:Ue,format2:Ue,max:36,delimiter:"[,]",delimiter2:"[.]",unique:!1},performance:{format:Xe,format2:"^(?:|"+Qe+")$",max:250,delimiter:"[,]",delimiter2:"[.]",unique:!1},sequencing:{format:Ue,max:36,delimiter:"[,]",unique:!1},likert:{format:Ue,max:1,delimiter:"",unique:!1},numeric:{format:He,max:1,delimiter:"",unique:!1},other:{format:qe,max:1,delimiter:"",unique:!1}},et={"true-false":{max:1,delimiter:"",unique:!1,duplicate:!1,format:"^true$|^false$",limit:1},choice:{max:36,delimiter:"[,]",unique:!0,duplicate:!1,format:Ge},"fill-in":{max:10,delimiter:"[,]",unique:!1,duplicate:!1,format:"^(({lang=([a-zA-Z]{1,8}|i|x)?(-[a-zA-Z0-9-]{2,8})?})?(.{0,250})?)?$"},"long-fill-in":{max:1,delimiter:"",unique:!1,duplicate:!0,format:Fe},matching:{max:36,delimiter:"[,]",delimiter2:"[.]",unique:!1,duplicate:!1,format:Ue,format2:Ue},performance:{max:250,delimiter:"[,]",delimiter2:"[.]",unique:!1,duplicate:!1,format:Xe,format2:"^(?:|(?:-?\\d+(?:\\.\\d+)?)?\\[:\\](?:-?\\d+(?:\\.\\d+)?)?|"+Qe+")$"},sequencing:{max:36,delimiter:"[,]",unique:!1,duplicate:!1,format:Ue},likert:{max:1,delimiter:"",unique:!1,duplicate:!1,format:Ue,limit:1},numeric:{max:2,delimiter:"[:]",unique:!1,duplicate:!1,format:He,limit:1},other:{max:1,delimiter:"",unique:!1,duplicate:!1,format:qe,limit:1}};function tt(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}!function(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){tt(e,t,i[t])})}}({},{"NB.2.1-1":"Sequencing session already started","NB.2.1-2":"Current activity not defined / sequencing not begun","NB.2.1-3":"No suspended activity to resume","NB.2.1-4":"Flow not enabled / current activity is root","NB.2.1-5":"Violates control mode (forward only or flow disabled)","NB.2.1-6":"Cannot move backward from root","NB.2.1-7":"Forward/Backward navigation not supported","NB.2.1-8":"Forward-only constraint violation","NB.2.1-9":"Activity path empty","NB.2.1-10":"Choice control disabled on parent","NB.2.1-11":"Target activity does not exist","NB.2.1-12":"Activity already terminated","NB.2.1-13":"Undefined navigation request","NB.2.1-14":"No current activity for EXIT_ALL","NB.2.1-15":"No current activity for ABANDON","NB.2.1-16":"No current activity for ABANDON_ALL","NB.2.1-17":"No current activity for SUSPEND_ALL","NB.2.1-18":"Invalid navigation request type"},{"TB.2.3-1":"No current activity to terminate","TB.2.3-2":"Current activity already terminated","TB.2.3-3":"Nothing to suspend (root activity)","TB.2.3-4":"Cannot EXIT_PARENT from root activity","TB.2.3-5":"Activity path is empty during suspend","TB.2.3-6":"Nothing to abandon","TB.2.3-7":"Undefined termination request"},{"SB.2.1-2":"No available children to deliver","SB.2.1-3":"Reached beginning of course","SB.2.1-4":"Forward only violation - cannot traverse backward"},{"SB.2.2-1":"Flow control disabled on parent","SB.2.2-2":"Activity not available"},{"SB.2.7-1":"Sequencing session not begun (current activity not terminated)","SB.2.7-2":"Cannot continue - flow disabled or no activity available"},{"SB.2.8-1":"Current activity not terminated","SB.2.8-2":"Cannot go previous - at beginning or forwardOnly enabled"},{"SB.2.9-1":"Target activity does not exist","SB.2.9-2":"Target activity not in tree","SB.2.9-3":"Cannot choose root activity","SB.2.9-4":"Activity hidden from choice","SB.2.9-5":"Choice control is not allowed","SB.2.9-6":"Current activity not terminated","SB.2.9-7":"No activity available from target","SB.2.9-8":"choiceExit prevents navigation outside ancestor subtree"},{"SB.2.4-1":"Stop forward traversal rule evaluates to true","SB.2.4-2":"Constrained choice requires forward traversal from leaf","SB.2.4-3":"Cannot walk backward from root of activity tree"},{"SB.2.10-1":"Current activity not defined","SB.2.10-2":"Activity is still active or suspended","SB.2.10-3":"Flow subprocess returned false (nothing to deliver)"},{"SB.2.11-1":"Exit not allowed - no parent","SB.2.11-2":"Exit not allowed by sequencing controls"},{"SB.2.12-1":"No current activity","SB.2.12-5":"No target activity specified","SB.2.12-6":"Undefined sequencing request"},{"SB.2.13-1":"Target activity does not exist","SB.2.13-2":"Target activity not in tree","SB.2.13-3":"Target not available"},{"SB.2.5-1":"No activity tree","SB.2.5-2":"Sequencing session already begun","SB.2.5-3":"No activity available"},{"SB.2.6-1":"No suspended activity","SB.2.6-2":"Current activity already defined"},{"SB.2.15-1":"Cannot suspend root"});var it=["aa","ab","ae","af","ak","am","an","ar","as","av","ay","az","ba","be","bg","bh","bi","bm","bn","bo","br","bs","ca","ce","ch","co","cr","cs","cu","cv","cy","da","de","dv","dz","ee","el","en","eo","es","et","eu","fa","ff","fi","fj","fo","fr","fy","ga","gd","gl","gn","gu","gv","ha","he","hi","ho","hr","ht","hu","hy","hz","ia","id","ie","ig","ii","ik","io","is","it","iu","ja","jv","ka","kg","ki","kj","kk","kl","km","kn","ko","kr","ks","ku","kv","kw","ky","la","lb","lg","li","ln","lo","lt","lu","lv","mg","mh","mi","mk","ml","mn","mo","mr","ms","mt","my","na","nb","nd","ne","ng","nl","nn","no","nr","nv","ny","oc","oj","om","or","os","pa","pi","pl","ps","pt","qu","rm","rn","ro","ru","rw","sa","sc","sd","se","sg","sh","si","sk","sl","sm","sn","so","sq","sr","ss","st","su","sv","sw","ta","te","tg","th","ti","tk","tl","tn","to","tr","ts","tt","tw","ty","ug","uk","ur","uz","ve","vi","vo","wa","wo","xh","yi","yo","za","zh","zu","aar","abk","ave","afr","aka","amh","arg","ara","asm","ava","aym","aze","bak","bel","bul","bih","bis","bam","ben","tib","bod","bre","bos","cat","che","cha","cos","cre","cze","ces","chu","chv","wel","cym","dan","ger","deu","div","dzo","ewe","gre","ell","eng","epo","spa","est","baq","eus","per","fas","ful","fin","fij","fao","fre","fra","fry","gle","gla","glg","grn","guj","glv","hau","heb","hin","hmo","hrv","hat","hun","arm","hye","her","ina","ind","ile","ibo","iii","ipk","ido","ice","isl","ita","iku","jpn","jav","geo","kat","kon","kik","kua","kaz","kal","khm","kan","kor","kau","kas","kur","kom","cor","kir","lat","ltz","lug","lim","lin","lao","lit","lub","lav","mlg","mah","mao","mri","mac","mkd","mal","mon","mol","mar","may","msa","mlt","bur","mya","nau","nob","nde","nep","ndo","dut","nld","nno","nor","nbl","nav","nya","oci","oji","orm","ori","oss","pan","pli","pol","pus","por","que","roh","run","rum","ron","rus","kin","san","srd","snd","sme","sag","slo","sin","slk","slv","smo","sna","som","alb","sqi","srp","ssw","sot","sun","swe","swa","tam","tel","tgk","tha","tir","tuk","tgl","tsn","ton","tur","tso","tat","twi","tah","uig","ukr","urd","uzb","ven","vie","vol","wln","wol","xho","yid","yor","zha","chi","zho","zul"];function nt(e,t,i,n,r,o,s){try{var a=e[o](s),u=a.value}catch(e){return void i(e)}a.done?t(u):Promise.resolve(u).then(n,r)}var rt=Object.defineProperty,ot=function(e,t,i){return function(e,t,i){return t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},st=function(){function e(t,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ot(this,"_API"),ot(this,"_cancelled",!1),ot(this,"_timeout"),ot(this,"_callback"),this._API=t,this._timeout=setTimeout(this.wrapper.bind(this),i),this._callback=n}return t=e,i=[{key:"cancel",value:function(){this._cancelled=!0,this._timeout&&clearTimeout(this._timeout)}},{key:"wrapper",value:function(){var e;this._cancelled||this._API.isInitialized()&&(e=function(){return function(e,t){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(s,"next",{value:u(0)}),a(s,"throw",{value:u(1)}),a(s,"return",{value:u(2)}),"function"==typeof Symbol&&a(s,Symbol.iterator,{value:function(){return this}}),s;function u(a){return function(u){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&r[3]>a[1])){o.label=a[1];break}if(6===a[0]&&r[1]>o.label){o.label=r[1],r=a;break}if(r&&r[2]>o.label){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,function(e){switch(e.label){case 0:return[4,this._API.commit(this._callback,!1,"autocommit")];case 1:return[2,e.sent()]}})},function(){var t=this,i=arguments;return new Promise(function(n,r){var o=e.apply(t,i);function s(e){nt(o,n,r,s,a,"next",e)}function a(e){nt(o,n,r,s,a,"throw",e)}s(void 0)})}).call(this)}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}(),at=["continue","previous","exit","exitAll","abandon","abandonAll","suspendAll"];function ut(e,t,i){return t=ft(t),n=e,!(r=yt()?Reflect.construct(t,i||[],ft(e).constructor):t.apply(e,i))||"object"!==pt(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}function lt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ct(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function dt(e,t,i){return t&&ct(e.prototype,t),i&&ct(e,i),e}function ft(e){return ft=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ft(e)}function vt(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}}),t&&mt(e,t)}function ht(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function mt(e,t){return mt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},mt(e,t)}function pt(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function yt(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(yt=function(){return!!result})()}var gt=Object.defineProperty,_t=function(e,t,i){return function(e,t,i){return t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":pt(t))?t+"":t,i)},bt=function(e){return e.NOT="not",e.AND="and",e.OR="or",e}(bt||{}),St=function(e){return e.SKIP="skip",e.DISABLED="disabled",e.HIDE_FROM_CHOICE="hiddenFromChoice",e.STOP_FORWARD_TRAVERSAL="stopForwardTraversal",e.EXIT_PARENT="exitParent",e.EXIT_ALL="exitAll",e.RETRY="retry",e.RETRY_ALL="retryAll",e.CONTINUE="continue",e.PREVIOUS="previous",e.EXIT="exit",e}(St||{}),wt=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"always",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map;return lt(this,t),e=ut(this,t,["ruleCondition"]),_t(e,"_condition","always"),_t(e,"_operator",null),_t(e,"_parameters",new Map),_t(e,"_referencedObjective",null),e._condition=i,e._operator=n,e._parameters=r,e}return vt(t,e),dt(t,[{key:"reset",value:function(){this._initialized=!1,this._condition="always",this._operator=null,this._parameters=new Map}},{key:"condition",get:function(){return this._condition},set:function(e){this._condition=e}},{key:"operator",get:function(){return this._operator},set:function(e){this._operator=e}},{key:"parameters",get:function(){return this._parameters},set:function(e){this._parameters=e}},{key:"referencedObjective",get:function(){return this._referencedObjective},set:function(e){this._referencedObjective=e}},{key:"resolveReferencedObjective",value:function(e){var t,i=this;return this._referencedObjective?(null===(t=e.primaryObjective)||void 0===t?void 0:t.id)===this._referencedObjective?e.primaryObjective:(e.objectives||[]).find(function(e){return e.id===i._referencedObjective})||null:null}},{key:"evaluate",value:function(e){var result,t=this.resolveReferencedObjective(e);switch(this._condition){case"satisfied":case"objectiveSatisfied":result=t?!0===t.satisfiedStatus:e.successStatus===_e||!0===e.objectiveSatisfiedStatus;break;case"objectiveStatusKnown":case"objectiveMeasureKnown":result=t?!!t.measureStatus:!!e.objectiveMeasureStatus;break;case"objectiveMeasureGreaterThan":var i=this._parameters.get("threshold")||0;result=!!(t?t.measureStatus:e.objectiveMeasureStatus)&&(t?t.normalizedMeasure:e.objectiveNormalizedMeasure)>i;break;case"objectiveMeasureLessThan":var n=this._parameters.get("threshold")||0;result=!!(t?t.measureStatus:e.objectiveMeasureStatus)&&n>(t?t.normalizedMeasure:e.objectiveNormalizedMeasure);break;case"completed":case"activityCompleted":result=t?t.completionStatus===we:e.isCompleted;break;case"progressKnown":case"activityProgressKnown":result=t?t.completionStatus!==Oe:"unknown"!==e.completionStatus;break;case"attempted":result=e.attemptCount>0;break;case"attemptLimitExceeded":result=e.hasAttemptLimitExceeded();break;case"timeLimitExceeded":result=this.evaluateTimeLimitExceeded(e);break;case"outsideAvailableTimeRange":result=this.evaluateOutsideAvailableTimeRange(e);break;case"always":result=!0;break;default:result=!1}return"not"===this._operator&&(result=!result),result}},{key:"evaluateTimeLimitExceeded",value:function(e){var i=e.timeLimitDuration;if(!i&&e.attemptAbsoluteDurationLimit&&(i=e.attemptAbsoluteDurationLimit),!i)return!1;var n=u(i,Ve);if(0>=n)return!1;var r=0;if(t._getElapsedSecondsHook)try{var o=t._getElapsedSecondsHook(e);"number"!=typeof o||Number.isNaN(o)||0>o||(r=o)}catch(e){r=0}if(0===r&&e.attemptExperiencedDuration){var s=u(e.attemptExperiencedDuration,Ve);s>0&&(r=s)}if(0===r&&e.attemptAbsoluteStartTime)try{var a=new Date(e.attemptAbsoluteStartTime).getTime(),l=t._now().getTime();Number.isNaN(a)||Number.isNaN(l)||a>l||(r=(l-a)/1e3)}catch(e){r=0}return r>n}},{key:"evaluateOutsideAvailableTimeRange",value:function(e){var i=e.beginTimeLimit,n=e.endTimeLimit;if(!i&&!n)return!1;var r=t._now();return!(!i||r>=new Date(i))||!(!n||new Date(n)>=r)}},{key:"parseISO8601Duration",value:function(e){return 1e3*u(e,Ve)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={condition:this._condition,operator:this._operator,parameters:Object.fromEntries(this._parameters)};return this.jsonString=!1,result}}],[{key:"setNowProvider",value:function(e){"function"==typeof e&&(t._now=e)}},{key:"setElapsedSecondsHook",value:function(e){t._getElapsedSecondsHook=e}}]),t}(C);_t(wt,"_now",function(){return new Date}),_t(wt,"_getElapsedSecondsHook");var Ct=wt,Ot=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"skip",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"and";return lt(this,t),e=ut(this,t,["sequencingRule"]),_t(e,"_conditions",[]),_t(e,"_action","skip"),_t(e,"_conditionCombination","and"),e._action=i,e._conditionCombination=n,e}return vt(t,e),dt(t,[{key:"reset",value:function(){this._initialized=!1,this._conditions=[],this._action="skip",this._conditionCombination="and"}},{key:"conditions",get:function(){return this._conditions}},{key:"addCondition",value:function(e){if(!ht(e,Ct))throw new ie(this._cmi_element+".conditions",ue.TYPE_MISMATCH);this._conditions.includes(e)||this._conditions.push(e)}},{key:"removeCondition",value:function(e){if(!ht(e,Ct))throw new ie(this._cmi_element+".conditions",ue.TYPE_MISMATCH);var t=this._conditions.indexOf(e);return-1!==t&&(this._conditions.splice(t,1),!0)}},{key:"action",get:function(){return this._action},set:function(e){this._action=e}},{key:"conditionCombination",get:function(){return this._conditionCombination},set:function(e){this._conditionCombination=e}},{key:"evaluate",value:function(e){return 0===this._conditions.length||("all"===this._conditionCombination||"and"===this._conditionCombination?this._conditions.every(function(t){return t.evaluate(e)}):("any"===this._conditionCombination||"or"===this._conditionCombination)&&this._conditions.some(function(t){return t.evaluate(e)}))}},{key:"toJSON",value:function(){this.jsonString=!0;var result={conditions:this._conditions,action:this._action,conditionCombination:this._conditionCombination};return this.jsonString=!1,result}}]),t}(C),Et=function(e){function t(){var e;return lt(this,t),e=ut(this,t,["sequencingRules"]),_t(e,"_preConditionRules",[]),_t(e,"_exitConditionRules",[]),_t(e,"_postConditionRules",[]),e}return vt(t,e),dt(t,[{key:"reset",value:function(){this._initialized=!1,this._preConditionRules=[],this._exitConditionRules=[],this._postConditionRules=[]}},{key:"preConditionRules",get:function(){return this._preConditionRules}},{key:"addPreConditionRule",value:function(e){if(!ht(e,Ot))throw new ie(this._cmi_element+".preConditionRules",ue.TYPE_MISMATCH);this._preConditionRules.push(e)}},{key:"exitConditionRules",get:function(){return this._exitConditionRules}},{key:"addExitConditionRule",value:function(e){if(!ht(e,Ot))throw new ie(this._cmi_element+".exitConditionRules",ue.TYPE_MISMATCH);this._exitConditionRules.push(e)}},{key:"postConditionRules",get:function(){return this._postConditionRules}},{key:"addPostConditionRule",value:function(e){if(!ht(e,Ot))throw new ie(this._cmi_element+".postConditionRules",ue.TYPE_MISMATCH);this._postConditionRules.push(e)}},{key:"evaluatePreConditionRules",value:function(e){var t=!0,i=!1,n=void 0;try{for(var r,o=this._preConditionRules[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value;if(s.evaluate(e))return s.action}}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}return null}},{key:"evaluateExitConditionRules",value:function(e){var t=!0,i=!1,n=void 0;try{for(var r,o=this._exitConditionRules[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value;if(s.evaluate(e))return s.action}}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}return null}},{key:"evaluatePostConditionRules",value:function(e){var t=!0,i=!1,n=void 0;try{for(var r,o=this._postConditionRules[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value;if(s.evaluate(e))return s.action}}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}return null}},{key:"toJSON",value:function(){this.jsonString=!0;var result={preConditionRules:this._preConditionRules,exitConditionRules:this._exitConditionRules,postConditionRules:this._postConditionRules};return this.jsonString=!1,result}}]),t}(C);var At=Object.defineProperty,kt=function(){function e(t){var i,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),n=t,function(e,t,i){t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(this,"symbol"!==function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(i="activityTree")?i+"":i,n)}return t=e,(i=[{key:"isInTree",value:function(e){return this.activityTree.getAllActivities().includes(e)}},{key:"isAncestorOf",value:function(e,t){for(var i=t;i;){if(i===e)return!0;i=i.parent}return!1}},{key:"findCommonAncestor",value:function(e,t){if(!e||!t)return null;for(var i=[],n=e;n;)i.push(n),n=n.parent;for(n=t;n;){if(i.includes(n))return n;n=n.parent}return null}},{key:"findChildInPath",value:function(e,t){for(var i=t;i&&i.parent;){if(i.parent===e)return i;i=i.parent}return null}},{key:"isLastInTree",value:function(e){if(e.children.length>0)return!1;for(var t=e;t;){if(this.activityTree.getNextSibling(t))return!1;t=t.parent}return!0}},{key:"getCurrentInParent",value:function(e){if(e.children){var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value;if(s.isActive)return s}}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}}return null}},{key:"isMandatory",value:function(e){if(e.sequencingRules&&e.sequencingRules.preConditionRules){var t=!0,i=!1,n=void 0;try{for(var r,o=e.sequencingRules.preConditionRules[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value;if("skip"===s.action&&s.conditions&&0===s.conditions.length)return!1}}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}}return!0===e.mandatory}},{key:"isCompleted",value:function(e){return"completed"===e.completionStatus||"passed"===e.completionStatus||"passed"===e.successStatus}},{key:"isAvailableForChoice",value:function(e){return e.isVisible&&!e.isHiddenFromChoice&&e.isAvailable&&(!e.sequencingControls||e.sequencingControls.choice)}},{key:"getAncestors",value:function(e){for(var t=[],i=e.parent;i;)t.push(i),i=i.parent;return t}},{key:"getPathToRoot",value:function(e){for(var t=[e],i=e.parent;i;)t.push(i),i=i.parent;return t}},{key:"isLeaf",value:function(e){return 0===e.children.length}},{key:"isCluster",value:function(e){return e.children.length>0}},{key:"getDepth",value:function(e){for(var t=0,i=e.parent;i;)t++,i=i.parent;return t}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var jt=Object.defineProperty,Rt=function(e,t,i){return function(e,t,i){return t in e?jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Mt=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Rt(this,"activityTree",t),Rt(this,"treeQueries",i)}return t=e,i=[{key:"validateChoice",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this.treeQueries.isInTree(t))return{valid:!1,exception:"SB.2.9-2"};if(t===this.activityTree.root)return{valid:!1,exception:"SB.2.9-3"};var n=this.validatePathToRoot(t);if(!n.valid)return n;if(i.checkAvailability&&!t.isAvailable)return{valid:!1,exception:"SB.2.9-7"};if(!e)return{valid:!0,exception:null};var r=this.validateChoiceExit(e,t);if(!r.valid)return r;var o=this.validateAncestorConstraints(e,t);return o.valid?{valid:!0,exception:null}:o}},{key:"validatePathToRoot",value:function(e){for(var t=e;t;){if(t.isHiddenFromChoice)return{valid:!1,exception:"SB.2.9-4"};if(t.parent&&!t.parent.sequencingControls.choice)return{valid:!1,exception:"SB.2.9-5"};if(t.parent&&t.parent.sequencingControls.preventActivation&&0===e.attemptCount&&!e.isActive)return{valid:!1,exception:"SB.2.9-6"};t=t.parent}return{valid:!0,exception:null}}},{key:"validateChoiceExit",value:function(e,t){for(var i=e.parent;i;){if(i.isActive&&!i.sequencingControls.choiceExit){if(!this.treeQueries.isAncestorOf(i,t))return{valid:!1,exception:"SB.2.9-8"};break}i=i.parent}return{valid:!0,exception:null}}},{key:"validateAncestorConstraints",value:function(e,t){for(var i=t.parent;i;){var n=this.validateConstraintsAtLevel(i,e,t);if(!n.valid)return n;i=i.parent}return{valid:!0,exception:null}}},{key:"validateConstraintsAtLevel",value:function(e,t,i){var n=this.treeQueries.findChildInPath(e,i),r=this.treeQueries.findChildInPath(e,t);if(!n||!r)return{valid:!0,exception:null};var o=e.children,s=o.indexOf(n),a=o.indexOf(r);if(-1===s||-1===a)return{valid:!0,exception:null};if(e.sequencingControls.forwardOnly&&a>s)return{valid:!1,exception:"SB.2.9-5"};if(s>a)for(var u=a+1;s>u;u++){var l=o[u];if(l&&this.treeQueries.isMandatory(l)&&!this.treeQueries.isCompleted(l))return{valid:!1,exception:"SB.2.9-6"}}if(e.sequencingControls.constrainChoice){if(s>a+1)return{valid:!1,exception:"SB.2.9-7"};if(a>s&&"completed"!==i.completionStatus&&"passed"!==i.completionStatus)return{valid:!1,exception:"SB.2.9-7"}}return e.sequencingControls.preventActivation&&0===i.attemptCount&&!i.isActive?{valid:!1,exception:"SB.2.9-6"}:{valid:!0,exception:null}}},{key:"checkForwardOnlyViolation",value:function(e){for(var t=e.parent;t;){if(t.sequencingControls.forwardOnly)return{valid:!1,exception:"SB.2.9-5"};t=t.parent}return{valid:!0,exception:null}}},{key:"isAvailableForChoice",value:function(e){return this.treeQueries.isAvailableForChoice(e)}},{key:"validateFlowConstraints",value:function(e,t){var i=[],n=!0,r=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value;this.meetsFlowConstraints(u,e)&&i.push(u)}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return{valid:i.length>0,validChildren:i}}},{key:"meetsFlowConstraints",value:function(e,t){return!(!e.isAvailable||e.isHiddenFromChoice)&&(!t.sequencingControls.constrainChoice||this.validateConstrainChoiceForFlow(e,t))}},{key:"validateConstrainChoiceForFlow",value:function(e,t){if(!t.sequencingControls||!t.sequencingControls.constrainChoice)return!0;var i=t.children;if(!i||0===i.length)return!0;var n=i.indexOf(e);if(-1===n)return!1;var r=this.treeQueries.getCurrentInParent(t);if(!r)return this.isAvailableForChoice(e);var o=i.indexOf(r);return-1===o||(t.sequencingControls.flow?t.sequencingControls.forwardOnly&&o>n?"completed"===e.completionStatus||"passed"===e.completionStatus:o>n?o>n&&("completed"===e.completionStatus||"passed"===e.completionStatus)&&this.isAvailableForChoice(e):(n===o||n===o+1)&&this.isAvailableForChoice(e):this.isAvailableForChoice(e)&&("completed"===e.completionStatus||"unknown"===e.completionStatus||"incomplete"===e.completionStatus))}},{key:"validateTraversalConstraints",value:function(e){var t,i,n=!0,r=!0;return(null===(t=e.parent)||void 0===t?void 0:t.sequencingControls.constrainChoice)&&(n=this.evaluateConstrainChoiceForTraversal(e)),e.sequencingControls&&e.sequencingControls.stopForwardTraversal&&(r=!1),(null===(i=e.parent)||void 0===i?void 0:i.sequencingControls.forwardOnly)&&(r=this.evaluateForwardOnlyForChoice(e)),{canTraverse:n,canTraverseInto:r}}},{key:"evaluateConstrainChoiceForTraversal",value:function(e){if(!e.parent)return!0;for(var t=e.parent;t;){if(t.sequencingControls&&t.sequencingControls.constrainChoice){var i=t.children,n=this.treeQueries.findChildInPath(t,e);if(n){var r=i.indexOf(n),o=this.treeQueries.getCurrentInParent(t);if(o){var s=i.indexOf(o);if(-1!==s&&-1!==r){if(r>s)for(var a=s+1;r>a;a++){var u=i[a];if(u&&this.treeQueries.isMandatory(u)&&!this.treeQueries.isCompleted(u))return!1}if(t.sequencingControls.forwardOnly&&s>r&&!this.treeQueries.isCompleted(e))return!1}}}}t=t.parent}return this.isAvailableForChoice(e)}},{key:"evaluateForwardOnlyForChoice",value:function(e){if(!e.parent)return!0;var t=e.parent;if(!t.sequencingControls||!t.sequencingControls.forwardOnly)return!0;var i=t.children;if(!i||0===i.length)return!0;var n=i.indexOf(e);if(-1===n)return!1;var r=this.treeQueries.getCurrentInParent(t);if(!r)return this.isAvailableForChoice(e);var o=i.indexOf(r);return-1===o||(o>n?!("completed"!==e.completionStatus&&"passed"!==e.completionStatus||!e.sequencingControls||!e.sequencingControls.choice):this.isAvailableForChoice(e))}},{key:"hasTimeBoundaryViolation",value:function(e,t){if(e.beginTimeLimit)try{if(new Date(e.beginTimeLimit)>t)return!0}catch(e){}if(e.endTimeLimit)try{if(t>new Date(e.endTimeLimit))return!0}catch(e){}return!1}},{key:"hasAttemptLimitViolation",value:function(e){return!(!e.attemptLimit||e.attemptLimit>e.attemptCount)}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Tt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Pt=Object.defineProperty,It=function(e,t,i){return function(e,t,i){return t in e?Pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},xt=function(e){return e.START="start",e.RESUME_ALL="resumeAll",e.CONTINUE="continue",e.PREVIOUS="previous",e.CHOICE="choice",e.JUMP="jump",e.EXIT="exit",e.EXIT_PARENT="exitParent",e.EXIT_ALL="exitAll",e.ABANDON="abandon",e.ABANDON_ALL="abandonAll",e.SUSPEND_ALL="suspendAll",e.RETRY="retry",e.RETRY_ALL="retryAll",e}(xt||{}),Nt=function(e){return e.DELIVER="deliver",e.DO_NOT_DELIVER="doNotDeliver",e}(Nt||{}),Dt=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"doNotDeliver",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Tt(this,e),It(this,"deliveryRequest"),It(this,"targetActivity"),It(this,"exception"),It(this,"endSequencingSession"),this.deliveryRequest=t,this.targetActivity=i,this.exception=n,this.endSequencingSession=r},qt=function e(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Tt(this,e),It(this,"identifiedActivity"),It(this,"deliverable"),It(this,"exception"),It(this,"endSequencingSession"),this.identifiedActivity=t,this.deliverable=i,this.exception=n,this.endSequencingSession=r},Lt=function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;Tt(this,e),It(this,"activity"),It(this,"exception"),this.activity=t,this.exception=i},zt=function(e){return e.FORWARD="forward",e.BACKWARD="backward",e}(zt||{});var Ft=Object.defineProperty,Bt=function(e,t,i){return function(e,t,i){return t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Vt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Bt(this,"now"),Bt(this,"getAttemptElapsedSecondsHook"),this.now=t.now||function(){return new Date},this.getAttemptElapsedSecondsHook=t.getAttemptElapsedSecondsHook||null}return t=e,(i=[{key:"checkSequencingRules",value:function(e,t){var i=!0,n=!1,r=void 0;try{for(var o,s=t[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value;if(this.checkRuleSubprocess(e,a))return a.action}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return null}},{key:"checkRuleSubprocess",value:function(e,t){if(0===t.conditions.length)return!0;var i=t.conditionCombination;return"all"===i||i===bt.AND?t.conditions.every(function(t){return t.evaluate(e)}):("any"===i||i===bt.OR)&&t.conditions.some(function(t){return t.evaluate(e)})}},{key:"evaluateExitRules",value:function(e){var t=this.checkSequencingRules(e,e.sequencingRules.exitConditionRules);return t===St.EXIT||t===St.EXIT_PARENT||t===St.EXIT_ALL?t:null}},{key:"evaluatePostConditionAction",value:function(e){var t=this.checkSequencingRules(e,e.sequencingRules.postConditionRules);return t&&[St.EXIT_PARENT,St.EXIT_ALL,St.RETRY,St.RETRY_ALL,St.CONTINUE,St.PREVIOUS,St.STOP_FORWARD_TRAVERSAL].includes(t)?t:null}},{key:"evaluatePostConditions",value:function(e){var t=this.evaluatePostConditionAction(e);if(!t)return{sequencingRequest:null,terminationRequest:null};switch(t){case St.EXIT_PARENT:return{sequencingRequest:null,terminationRequest:xt.EXIT_PARENT};case St.EXIT_ALL:return{sequencingRequest:null,terminationRequest:xt.EXIT_ALL};case St.RETRY:return{sequencingRequest:xt.RETRY,terminationRequest:null};case St.RETRY_ALL:return{sequencingRequest:xt.RETRY,terminationRequest:xt.EXIT_ALL};case St.CONTINUE:return{sequencingRequest:xt.CONTINUE,terminationRequest:null};case St.PREVIOUS:return{sequencingRequest:xt.PREVIOUS,terminationRequest:null};case St.STOP_FORWARD_TRAVERSAL:return e.sequencingControls.stopForwardTraversal=!0,{sequencingRequest:null,terminationRequest:null};default:return{sequencingRequest:null,terminationRequest:null}}}},{key:"checkLimitConditions",value:function(e){if(null!==e.attemptLimit&&e.attemptCount>=e.attemptLimit)return!0;if(null!==e.attemptAbsoluteDurationLimit){var t=this.parseDuration(e.attemptAbsoluteDurationLimit);if(t>0&&this.parseDuration(e.attemptExperiencedDuration)>=t)return!0}if(null!==e.activityAbsoluteDurationLimit){var i=this.parseDuration(e.activityAbsoluteDurationLimit);if(i>0&&this.parseDuration(e.activityExperiencedDuration)>=i)return!0}return!1}},{key:"parseDuration",value:function(e){if(!e||"string"!=typeof e)return 0;var t=e.match(/^P(?:(\d+(?:\.\d+)?)Y)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)W)?(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/);if(!t||"P"===e||e.endsWith("T"))return 0;var i=0;return i+=315576e5*parseFloat(t[1]||"0"),i+=30.44*24*parseFloat(t[2]||"0")*36e5,i+=6048e5*parseFloat(t[3]||"0"),i+=864e5*parseFloat(t[4]||"0"),i+=36e5*parseFloat(t[5]||"0"),(i+=6e4*parseFloat(t[6]||"0"))+1e3*parseFloat(t[7]||"0")}},{key:"getElapsedSeconds",value:function(e){if(this.getAttemptElapsedSecondsHook)try{return this.getAttemptElapsedSecondsHook(e)||0}catch(e){return 0}if(e.attemptAbsoluteStartTime){var t=new Date(e.attemptAbsoluteStartTime).getTime(),i=this.now().getTime();if(!Number.isNaN(t)&&i>t)return Math.max(0,(i-t)/1e3)}return 0}},{key:"isTimeLimitExceeded",value:function(e){var t=e.timeLimitDuration;if(!t&&e.attemptAbsoluteDurationLimit&&(t=e.attemptAbsoluteDurationLimit),!t)return!1;var i=u(t,Ve);return i>0&&this.getElapsedSeconds(e)>i}},{key:"isOutsideAvailableTimeRange",value:function(e){var t=this.now();if(e.beginTimeLimit)try{var i=new Date(e.beginTimeLimit);if(!Number.isNaN(i.getTime())&&i>t)return!0}catch(e){}if(e.endTimeLimit)try{var n=new Date(e.endTimeLimit);if(!Number.isNaN(n.getTime())&&t>n)return!0}catch(e){}return!1}},{key:"canDeliverActivity",value:function(e){if(this.checkLimitConditions(e))return{canDeliver:!1,wasSkipped:!1};var t=this.checkSequencingRules(e,e.sequencingRules.preConditionRules);return{canDeliver:t!==St.SKIP&&t!==St.DISABLED,wasSkipped:t===St.SKIP}}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Ht(e){return Ht=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Ht(e)}function Ut(e,t){return Ut=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ut(e,t)}function Gt(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Yt(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Yt=function(){return!!result})()}var Wt=Object.defineProperty,Jt=function(e,t,i){return function(e,t,i){return t in e?Wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Gt(t))?t+"":t,i)},Kt=function(e){return e.NEVER="never",e.ONCE="once",e.ON_EACH_NEW_ATTEMPT="onEachNewAttempt",e}(Kt||{}),$t=function(e){return e.NEVER="never",e.ONCE="once",e.ON_EACH_NEW_ATTEMPT="onEachNewAttempt",e}($t||{}),Xt=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=Ht(t),n=e,!(r=Yt()?Reflect.construct(t,i||[],Ht(e).constructor):t.apply(e,i))||"object"!==Gt(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["sequencingControls"]),Jt(e,"_enabled",!0),Jt(e,"_choice",!0),Jt(e,"_choiceExit",!0),Jt(e,"_flow",!0),Jt(e,"_forwardOnly",!1),Jt(e,"_useCurrentAttemptObjectiveInfo",!0),Jt(e,"_useCurrentAttemptProgressInfo",!0),Jt(e,"_preventActivation",!1),Jt(e,"_constrainChoice",!1),Jt(e,"_stopForwardTraversal",!1),Jt(e,"_rollupObjectiveSatisfied",!0),Jt(e,"_rollupProgressCompletion",!0),Jt(e,"_objectiveMeasureWeight",1),Jt(e,"_selectionTiming","never"),Jt(e,"_selectCount",null),Jt(e,"_selectionCountStatus",!1),Jt(e,"_randomizeChildren",!1),Jt(e,"_randomizationTiming","never"),Jt(e,"_reorderChildren",!1),Jt(e,"_completionSetByContent",!1),Jt(e,"_objectiveSetByContent",!1),Jt(e,"_tracked",!0),e}return function(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}}),t&&Ut(e,t)}(t,e),i=t,(n=[{key:"reset",value:function(){this._initialized=!1,this._enabled=!0,this._choice=!0,this._choiceExit=!0,this._flow=!0,this._forwardOnly=!1,this._useCurrentAttemptObjectiveInfo=!0,this._useCurrentAttemptProgressInfo=!0,this._preventActivation=!1,this._constrainChoice=!1,this._stopForwardTraversal=!1,this._rollupObjectiveSatisfied=!0,this._rollupProgressCompletion=!0,this._objectiveMeasureWeight=1,this._selectionTiming="never",this._selectCount=null,this._selectionCountStatus=!1,this._randomizeChildren=!1,this._randomizationTiming="never",this._reorderChildren=!1,this._completionSetByContent=!1,this._objectiveSetByContent=!1,this._tracked=!0}},{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}},{key:"choice",get:function(){return this._choice},set:function(e){this._choice=e}},{key:"choiceExit",get:function(){return this._choiceExit},set:function(e){this._choiceExit=e}},{key:"flow",get:function(){return this._flow},set:function(e){this._flow=e}},{key:"forwardOnly",get:function(){return this._forwardOnly},set:function(e){this._forwardOnly=e}},{key:"useCurrentAttemptObjectiveInfo",get:function(){return this._useCurrentAttemptObjectiveInfo},set:function(e){this._useCurrentAttemptObjectiveInfo=e}},{key:"useCurrentAttemptProgressInfo",get:function(){return this._useCurrentAttemptProgressInfo},set:function(e){this._useCurrentAttemptProgressInfo=e}},{key:"preventActivation",get:function(){return this._preventActivation},set:function(e){this._preventActivation=e}},{key:"constrainChoice",get:function(){return this._constrainChoice},set:function(e){this._constrainChoice=e}},{key:"stopForwardTraversal",get:function(){return this._stopForwardTraversal},set:function(e){this._stopForwardTraversal=e}},{key:"rollupObjectiveSatisfied",get:function(){return this._rollupObjectiveSatisfied},set:function(e){this._rollupObjectiveSatisfied=e}},{key:"rollupProgressCompletion",get:function(){return this._rollupProgressCompletion},set:function(e){this._rollupProgressCompletion=e}},{key:"objectiveMeasureWeight",get:function(){return this._objectiveMeasureWeight},set:function(e){0>e||(this._objectiveMeasureWeight=e)}},{key:"isChoiceNavigationAllowed",value:function(){return this._enabled&&!this._constrainChoice}},{key:"isFlowNavigationAllowed",value:function(){return this._enabled&&this._flow}},{key:"isForwardNavigationAllowed",value:function(){return this._enabled&&this._flow}},{key:"isBackwardNavigationAllowed",value:function(){return this._enabled&&this._flow&&!this._forwardOnly}},{key:"selectionTiming",get:function(){return this._selectionTiming},set:function(e){this._selectionTiming=e}},{key:"selectCount",get:function(){return this._selectCount},set:function(e){(null===e||e>0)&&(this._selectCount=e)}},{key:"selectionCountStatus",get:function(){return this._selectionCountStatus},set:function(e){this._selectionCountStatus=e}},{key:"randomizeChildren",get:function(){return this._randomizeChildren},set:function(e){this._randomizeChildren=e}},{key:"randomizationTiming",get:function(){return this._randomizationTiming},set:function(e){this._randomizationTiming=e}},{key:"reorderChildren",get:function(){return this._reorderChildren},set:function(e){this._reorderChildren=e}},{key:"completionSetByContent",get:function(){return this._completionSetByContent},set:function(e){this._completionSetByContent=e}},{key:"objectiveSetByContent",get:function(){return this._objectiveSetByContent},set:function(e){this._objectiveSetByContent=e}},{key:"tracked",get:function(){return this._tracked},set:function(e){this._tracked=e}},{key:"toJSON",value:function(){this.jsonString=!0;var result={enabled:this._enabled,choice:this._choice,choiceExit:this._choiceExit,flow:this._flow,forwardOnly:this._forwardOnly,useCurrentAttemptObjectiveInfo:this._useCurrentAttemptObjectiveInfo,useCurrentAttemptProgressInfo:this._useCurrentAttemptProgressInfo,preventActivation:this._preventActivation,constrainChoice:this._constrainChoice,stopForwardTraversal:this._stopForwardTraversal,rollupObjectiveSatisfied:this._rollupObjectiveSatisfied,rollupProgressCompletion:this._rollupProgressCompletion,objectiveMeasureWeight:this._objectiveMeasureWeight,selectionTiming:this._selectionTiming,selectCount:this._selectCount,selectionCountStatus:this._selectionCountStatus,randomizeChildren:this._randomizeChildren,randomizationTiming:this._randomizationTiming,reorderChildren:this._reorderChildren,completionSetByContent:this._completionSetByContent,objectiveSetByContent:this._objectiveSetByContent,tracked:this._tracked};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function Qt(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function Zt(e){return function(e){if(Array.isArray(e))return Qt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Qt(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Qt(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ei=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return t=e,i=[{key:"selectChildrenProcess",value:function(e){var t=e.sequencingControls,i=Zt(e.children);if(t.selectionTiming===Kt.NEVER)return i;if(t.selectionTiming===Kt.ONCE&&t.selectionCountStatus)return i;if(t.selectionTiming!==Kt.ONCE&&!t.selectionCountStatus)return i;var n=t.selectCount;if(null===n||n>=i.length)return t.selectionTiming===Kt.ONCE&&(t.selectionCountStatus=!0),i;for(var r=[],o=i.map(function(e,t){return t}),s=0;n>s&&0!==o.length;s++){var a=Math.floor(Math.random()*o.length),u=o[a];void 0!==u&&i[u]&&r.push(i[u]),o.splice(a,1)}t.selectionTiming===Kt.ONCE&&(t.selectionCountStatus=!0);var l=!0,c=!1,d=void 0;try{for(var f,v=i[Symbol.iterator]();!(l=(f=v.next()).done);l=!0){var h=f.value;r.includes(h)||(h.isHiddenFromChoice=!0,h.isAvailable=!1)}}catch(e){c=!0,d=e}finally{try{l||null==v.return||v.return()}finally{if(c)throw d}}return r}},{key:"randomizeChildrenProcess",value:function(e){var t,i=e.sequencingControls,n=Zt(e.children);if(i.randomizationTiming===$t.NEVER)return n;if(i.randomizationTiming===$t.ONCE&&i.reorderChildren)return n;if(!i.randomizeChildren)return n;for(var r=Zt(n),o=r.length-1;o>0;o--){var s=Math.floor(Math.random()*(o+1)),a=r[o],u=r[s];a&&u&&(r[o]=u,r[s]=a)}return i.randomizationTiming===$t.ONCE&&(i.reorderChildren=!0),e.children.length=0,(t=e.children).push.apply(t,Zt(r)),r}},{key:"applySelectionAndRandomization",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=e.sequencingControls;if(!t&&(e.isActive||e.isSuspended))return e.children;var n=!1,r=!1;i.selectionTiming===Kt.ON_EACH_NEW_ATTEMPT?(n=t,t&&(i.selectionCountStatus=!0)):i.selectionTiming===Kt.ONCE&&(n=!i.selectionCountStatus),i.randomizationTiming===$t.ON_EACH_NEW_ATTEMPT?(r=t,t&&(i.reorderChildren=!1)):i.randomizationTiming===$t.ONCE&&(r=!i.reorderChildren),n&&this.selectChildrenProcess(e),r&&this.randomizeChildrenProcess(e);var o=e.children.filter(function(e){return e.isAvailable});return e.setProcessedChildren(o),o}},{key:"isSelectionNeeded",value:function(e){var t=e.sequencingControls;return t.selectionTiming!==Kt.NEVER&&(t.selectionTiming!==Kt.ONCE||!t.selectionCountStatus)&&null!==t.selectCount&&e.children.length>t.selectCount}},{key:"isRandomizationNeeded",value:function(e){var t=e.sequencingControls;return t.randomizationTiming!==$t.NEVER&&(t.randomizationTiming!==$t.ONCE||!t.reorderChildren)&&t.randomizeChildren}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t,i),e;var t,i}();var ti=Object.defineProperty,ii=function(e,t,i){return function(e,t,i){return t in e?ti(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},ni=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ii(this,"activityTree",t),ii(this,"ruleEngine",i)}return t=e,i=[{key:"flowSubprocess",value:function(e,t){for(var i=e,n=!0,r=!1;i;){var o=this.flowTreeTraversalSubprocess(i,t,n);if(!o.activity){var s=null;return o.exception?s=o.exception:t===zt.BACKWARD?s="SB.2.1-3":r&&(s="SB.2.1-2"),new qt(i,!1,s,o.endSequencingSession)}r=o.activity.children.length>0&&0===o.activity.getAvailableChildren().length;var a=this.flowActivityTraversalSubprocess(o.activity,t===zt.FORWARD,!0,t);if(a)return new qt(a,!0,null,!1);i=o.activity,n=!1}return new qt(null,!1,null,!1)}},{key:"flowTreeTraversalSubprocess",value:function(e,t){return t===zt.FORWARD?this.traverseForward(e,arguments.length>2&&void 0!==arguments[2]&&arguments[2]):this.traverseBackward(e)}},{key:"traverseForward",value:function(e,t){if(t&&this.isActivityLastOverall(e))return this.activityTree.root&&this.terminateDescendentAttempts(this.activityTree.root),{activity:null,endSequencingSession:!0};if(!t){this.ensureSelectionAndRandomization(e);var i=e.getAvailableChildren();if(i.length>0)return{activity:i[0]||null,endSequencingSession:!1}}for(var n=e;n;){var r=this.activityTree.getNextSibling(n);if(r)return{activity:r,endSequencingSession:!1};n=n.parent}return this.activityTree.root&&this.terminateDescendentAttempts(this.activityTree.root),{activity:null,endSequencingSession:!0}}},{key:"traverseBackward",value:function(e){if(e.parent&&e.parent.sequencingControls.forwardOnly)return{activity:null,endSequencingSession:!1,exception:"SB.2.1-4"};var t=this.activityTree.getPreviousSibling(e);if(t)return{activity:this.getLastDescendant(t),endSequencingSession:!1};for(var i=e,n=0;i&&i.parent;){if(++n>1e4)throw Error("Infinite loop detected in backward traversal");var r=this.activityTree.getPreviousSibling(i.parent);if(r)return{activity:this.getLastDescendant(r),endSequencingSession:!1};i=i.parent}return{activity:null,endSequencingSession:!1}}},{key:"getLastDescendant",value:function(e){for(var t=e,i=0;;){if(++i>1e4)throw Error("Infinite loop detected while getting last descendant");this.ensureSelectionAndRandomization(t);var n=t.getAvailableChildren();if(0===n.length)break;var r=n[n.length-1];if(!r)break;t=r}return t}},{key:"flowActivityTraversalSubprocess",value:function(e,t,i,mode){var n=e.parent;if(n&&!n.sequencingControls.flow)return null;if(!e.isAvailable)return null;if(mode===zt.FORWARD&&e.sequencingControls.stopForwardTraversal)return null;if(i){this.ensureSelectionAndRandomization(e);var r=e.getAvailableChildren(),o=!0,s=!1,a=void 0;try{for(var u,l=r[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c=this.flowActivityTraversalSubprocess(u.value,mode===zt.FORWARD,!0,mode);if(c)return c}}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}}return 0===e.children.length&&this.checkActivityProcess(e)?e:null}},{key:"checkActivityProcess",value:function(e){if(!e.isAvailable)return!1;if(0===e.children.length&&!e.isVisible)return!1;if(this.ruleEngine.checkLimitConditions(e))return!1;var t=this.ruleEngine.canDeliverActivity(e);return e.wasSkipped=t.wasSkipped,t.canDeliver}},{key:"ensureSelectionAndRandomization",value:function(e){e.getAvailableChildren()===e.children&&(ei.isSelectionNeeded(e)||ei.isRandomizationNeeded(e))&&ei.applySelectionAndRandomization(e,e.isNewAttempt)}},{key:"isActivityLastOverall",value:function(e){if(e.children.length>0)return!1;for(var t=e;t;){if(this.activityTree.getNextSibling(t))return!1;t=t.parent}return!0}},{key:"terminateDescendentAttempts",value:function(e){e.isActive=!1;var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)this.terminateDescendentAttempts(r.value)}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}}},{key:"findFirstDeliverableActivity",value:function(e){if(0===e.children.length)return this.checkActivityProcess(e)?e:null;this.ensureSelectionAndRandomization(e);var t=e.getAvailableChildren(),i=!0,n=!1,r=void 0;try{for(var o,s=t[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=this.flowActivityTraversalSubprocess(o.value,!0,!0,zt.FORWARD);if(a)return a}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return null}},{key:"canDeliver",value:function(e){return this.checkActivityProcess(e)}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var ri=Object.defineProperty,oi=function(e,t,i){return function(e,t,i){return t in e?ri(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},si=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),oi(this,"activityTree",t),oi(this,"traversalService",i)}return t=e,(i=[{key:"handleStart",value:function(){var result=new Dt;if(!this.activityTree.root)return result.exception="SB.2.5-1",result;if(this.activityTree.currentActivity)return result.exception="SB.2.5-2",result;var e=this.traversalService.findFirstDeliverableActivity(this.activityTree.root);return e?(result.deliveryRequest=Nt.DELIVER,result.targetActivity=e,result):(result.exception="SB.2.5-3",result)}},{key:"handleResumeAll",value:function(){var result=new Dt;return this.activityTree.suspendedActivity?this.activityTree.currentActivity?(result.exception="SB.2.6-2",result):(result.deliveryRequest=Nt.DELIVER,result.targetActivity=this.activityTree.suspendedActivity,result):(result.exception="SB.2.6-1",result)}},{key:"handleContinue",value:function(e){var result=new Dt;if(e.isActive)return result.exception="SB.2.7-1",result;if(e.parent&&!e.parent.sequencingControls.flow)return result.exception="SB.2.7-2",result;var t=this.traversalService.flowSubprocess(e,zt.FORWARD);return result.endSequencingSession=t.endSequencingSession,t.deliverable&&t.identifiedActivity?(result.deliveryRequest=Nt.DELIVER,result.targetActivity=t.identifiedActivity,result):(result.exception=t.exception||"SB.2.7-2",result)}},{key:"handlePrevious",value:function(e){var result=new Dt;if(e.isActive)return result.exception="SB.2.8-1",result;if(e.parent&&!e.parent.sequencingControls.flow)return result.exception="SB.2.8-2",result;var t=this.checkForwardOnlyViolation(e);if(t)return result.exception=t,result;var i=this.traversalService.flowSubprocess(e,zt.BACKWARD);return i.deliverable&&i.identifiedActivity?(result.deliveryRequest=Nt.DELIVER,result.targetActivity=i.identifiedActivity,result):(result.exception=i.exception||"SB.2.8-3",result)}},{key:"checkForwardOnlyViolation",value:function(e){for(var t=e.parent;t;){if(t.sequencingControls.forwardOnly)return"SB.2.9-5";t=t.parent}return null}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var ai=Object.defineProperty,ui=function(e,t,i){return function(e,t,i){return t in e?ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},li=function(){function e(t,i,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ui(this,"activityTree",t),ui(this,"constraintValidator",i),ui(this,"traversalService",n),ui(this,"treeQueries",r)}return t=e,i=[{key:"handleChoice",value:function(e,t){var result=new Dt,i=this.activityTree.getActivity(e);if(!i)return result.exception="SB.2.9-1",result;if(t&&t.isActive)return result.exception="SB.2.9-6",result;var n=this.constraintValidator.validateChoice(t,i,{checkAvailability:!0});if(!n.valid)return result.exception=n.exception,result;var r=this.treeQueries.findCommonAncestor(t,i);t&&this.terminateDescendentAttemptsProcess(r||this.activityTree.root);var o=this.buildActivityPath(i,r),s=!0,a=!1,u=void 0;try{for(var l,c=o[Symbol.iterator]();!(s=(l=c.next()).done);s=!0)if(!this.traversalService.checkActivityProcess(l.value))return result}catch(e){a=!0,u=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw u}}var d=i;if(i.children.length>0){var f=this.choiceFlowSubprocess(i);if(!f)return result.exception="SB.2.9-7",result;d=f}return result.deliveryRequest=Nt.DELIVER,result.targetActivity=d,result}},{key:"handleJump",value:function(e){var result=new Dt,t=this.activityTree.getActivity(e);return t?this.treeQueries.isInTree(t)?t.isAvailable?(result.deliveryRequest=Nt.DELIVER,result.targetActivity=t,result):(result.exception="SB.2.13-3",result):(result.exception="SB.2.13-2",result):(result.exception="SB.2.13-1",result)}},{key:"getAvailableChoices",value:function(){var e=this.activityTree.getAllActivities(),t=this.activityTree.currentActivity,i=[],n=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value;u!==this.activityTree.root&&!u.isHiddenFromChoice&&u.isAvailable&&u.isVisible&&(u.parent&&!u.parent.sequencingControls.choice||this.constraintValidator.validateChoice(t,u).valid&&i.push(u))}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return i}},{key:"buildActivityPath",value:function(e,t){for(var i=[],n=e;n&&n!==t;)i.unshift(n),n=n.parent;return i}},{key:"choiceFlowSubprocess",value:function(e){return 0===e.children.length?e:this.choiceFlowTreeTraversal(e)}},{key:"choiceFlowTreeTraversal",value:function(e){this.traversalService.ensureSelectionAndRandomization(e);var t=e.getAvailableChildren(),i=this.constraintValidator.validateFlowConstraints(e,t);if(!i.valid)return null;var n=!0,r=!1,o=void 0;try{for(var s,a=i.validChildren[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=this.enhancedChoiceTraversal(s.value);if(u.activity)return u.activity}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return null}},{key:"enhancedChoiceTraversal",value:function(e){var t;if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&e===this.activityTree.root)return new Lt(null,"SB.2.4-3");if(!e.isAvailable)return new Lt(null,null);if(e.isHiddenFromChoice)return new Lt(null,null);if(e.sequencingControls&&e.sequencingControls.stopForwardTraversal)return new Lt(null,"SB.2.4-1");var i=this.constraintValidator.validateTraversalConstraints(e);if(!i.canTraverse)return new Lt(null,null);if(0===e.children.length)return this.traversalService.checkActivityProcess(e)?new Lt(e,null):new Lt(null,null);if((null===(t=e.parent)||void 0===t?void 0:t.sequencingControls.constrainChoice)&&!i.canTraverseInto)return new Lt(null,"SB.2.4-2");if(i.canTraverseInto){var n=this.choiceFlowTreeTraversal(e);return new Lt(n,null)}return new Lt(null,null)}},{key:"terminateDescendentAttemptsProcess",value:function(e){e.isActive=!1;var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)this.terminateDescendentAttemptsProcess(r.value)}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var ci=Object.defineProperty,di=function(e,t,i){return function(e,t,i){return t in e?ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},fi=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),di(this,"activityTree",t),di(this,"ruleEngine",i)}return t=e,i=[{key:"handleExit",value:function(e){var result=new Dt;return e.parent?e.parent.sequencingControls.choiceExit?(this.terminateDescendentAttempts(e),result):(result.exception="SB.2.11-2",result):(result.exception="SB.2.11-1",result)}},{key:"handleExitAll",value:function(){var result=new Dt;return this.activityTree.root&&this.terminateDescendentAttempts(this.activityTree.root),result}},{key:"handleAbandon",value:function(e){var result=new Dt;return e.isActive=!1,this.activityTree.currentActivity=e.parent,result}},{key:"handleAbandonAll",value:function(){var result=new Dt;return this.activityTree.currentActivity=null,result}},{key:"handleSuspendAll",value:function(e){var result=new Dt;return e===this.activityTree.root?(result.exception="SB.2.15-1",result):(e.isSuspended=!0,this.activityTree.suspendedActivity=e,this.activityTree.currentActivity=null,result)}},{key:"terminateDescendentAttempts",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=null;t||(i=this.ruleEngine.evaluateExitRules(e)),e.isActive=!1;var n=!0,r=!1,o=void 0;try{for(var s,a=e.children[Symbol.iterator]();!(n=(s=a.next()).done);n=!0)this.terminateDescendentAttempts(s.value,t)}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}i&&!t&&this.processDeferredExitAction(i,e)}},{key:"processDeferredExitAction",value:function(e,t){switch(e){case St.EXIT:break;case St.EXIT_PARENT:t.parent&&t.parent.isActive&&this.terminateDescendentAttempts(t.parent,!0);break;case St.EXIT_ALL:this.activityTree.root&&this.activityTree.root!==t&&this.activityTree.getAllActivities().some(function(e){return e.isActive})&&this.terminateDescendentAttempts(this.activityTree.root,!0)}}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var vi=Object.defineProperty,hi=function(e,t,i){return function(e,t,i){return t in e?vi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},mi=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),hi(this,"activityTree",t),hi(this,"traversalService",i)}return t=e,(i=[{key:"handleRetry",value:function(e){var result=new Dt;if(e.isActive||e.isSuspended)return result.exception="SB.2.10-2",result;if(e.children.length>0){this.traversalService.ensureSelectionAndRandomization(e);var t=e.getAvailableChildren(),i=null,n=!0,r=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done)&&!(i=this.traversalService.flowActivityTraversalSubprocess(s.value,!0,!0,zt.FORWARD));n=!0);}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return i?(result.deliveryRequest=Nt.DELIVER,result.targetActivity=i,result):(result.exception="SB.2.10-3",result)}return this.terminateDescendentAttempts(e),result.deliveryRequest=Nt.DELIVER,result.targetActivity=e,result}},{key:"handleRetryAll",value:function(){if(this.activityTree.currentActivity=null,!this.activityTree.root){var e=new Dt;return e.exception="SB.2.10-1",e}var t=this.traversalService.findFirstDeliverableActivity(this.activityTree.root),result=new Dt;return t?(result.deliveryRequest=Nt.DELIVER,result.targetActivity=t,result):(result.exception="SB.2.10-3",result)}},{key:"terminateDescendentAttempts",value:function(e){e.isActive=!1;var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)this.terminateDescendentAttempts(r.value)}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var pi=Object.defineProperty,yi=function(e,t,i){return function(e,t,i){return t in e?pi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},gi=function(){function e(t,i,n){var r=arguments.length>4?arguments[4]:void 0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),yi(this,"activityTree"),yi(this,"treeQueries"),yi(this,"constraintValidator"),yi(this,"ruleEngine"),yi(this,"traversalService"),yi(this,"flowHandler"),yi(this,"choiceHandler"),yi(this,"exitHandler"),yi(this,"retryHandler"),yi(this,"_now"),yi(this,"_getAttemptElapsedSecondsHook"),this.activityTree=t,this._now=(null==r?void 0:r.now)||function(){return new Date},this._getAttemptElapsedSecondsHook=null==r?void 0:r.getAttemptElapsedSeconds,this.treeQueries=new kt(t),this.ruleEngine=new Vt({now:this._now,getAttemptElapsedSecondsHook:this._getAttemptElapsedSecondsHook}),this.constraintValidator=new Mt(t,this.treeQueries),this.traversalService=new ni(t,this.ruleEngine),this.flowHandler=new si(t,this.traversalService),this.choiceHandler=new li(t,this.constraintValidator,this.traversalService,this.treeQueries),this.exitHandler=new fi(t,this.ruleEngine),this.retryHandler=new mi(t,this.traversalService)}return t=e,i=[{key:"now",get:function(){return this._now},set:function(e){this._now=e,Ct.setNowProvider(e),this.ruleEngine=new Vt({now:e,getAttemptElapsedSecondsHook:this._getAttemptElapsedSecondsHook}),this.traversalService=new ni(this.activityTree,this.ruleEngine),this.flowHandler=new si(this.activityTree,this.traversalService),this.choiceHandler=new li(this.activityTree,this.constraintValidator,this.traversalService,this.treeQueries),this.retryHandler=new mi(this.activityTree,this.traversalService)}},{key:"getAttemptElapsedSecondsHook",get:function(){return this._getAttemptElapsedSecondsHook},set:function(e){this._getAttemptElapsedSecondsHook=e,Ct.setElapsedSecondsHook(e),this.ruleEngine=new Vt({now:this._now,getAttemptElapsedSecondsHook:e}),this.traversalService=new ni(this.activityTree,this.ruleEngine),this.flowHandler=new si(this.activityTree,this.traversalService),this.choiceHandler=new li(this.activityTree,this.constraintValidator,this.traversalService,this.treeQueries),this.retryHandler=new mi(this.activityTree,this.traversalService)}},{key:"sequencingRequestProcess",value:function(request){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=this.activityTree.currentActivity;switch(request){case xt.START:return this.flowHandler.handleStart();case xt.RESUME_ALL:return this.flowHandler.handleResumeAll();case xt.CONTINUE:return t?this.flowHandler.handleContinue(t):new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-1");case xt.PREVIOUS:return t?this.flowHandler.handlePrevious(t):new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-1");case xt.CHOICE:return e?this.choiceHandler.handleChoice(e,t):new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-5");case xt.JUMP:return e?this.choiceHandler.handleJump(e):new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-5");case xt.EXIT:return t?this.exitHandler.handleExit(t):new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-1");case xt.EXIT_ALL:return t?this.exitHandler.handleExitAll():new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-1");case xt.ABANDON:return t?this.exitHandler.handleAbandon(t):new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-1");case xt.ABANDON_ALL:return t?this.exitHandler.handleAbandonAll():new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-1");case xt.SUSPEND_ALL:return t?this.exitHandler.handleSuspendAll(t):new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-1");case xt.RETRY:return t?this.retryHandler.handleRetry(t):new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-1");case xt.RETRY_ALL:return this.retryHandler.handleRetryAll();default:return new Dt(Nt.DO_NOT_DELIVER,null,"SB.2.12-6")}}},{key:"evaluatePostConditionRules",value:function(e){return this.ruleEngine.evaluatePostConditions(e)}},{key:"canActivityBeDelivered",value:function(e){return this.traversalService.canDeliver(e)}},{key:"validateNavigationRequest",value:function(request){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!Object.values(xt).includes(request))return{valid:!1,exception:"SB.2.12-6"};switch(request){case xt.CONTINUE:case xt.PREVIOUS:if(!t)return{valid:!1,exception:"SB.2.12-1"};if(t.isActive)return{valid:!1,exception:request===xt.CONTINUE?"SB.2.7-1":"SB.2.8-1"};if(t.parent&&!t.parent.sequencingControls.flow)return{valid:!1,exception:request===xt.CONTINUE?"SB.2.7-2":"SB.2.8-2"};if(request===xt.PREVIOUS){var i=this.constraintValidator.checkForwardOnlyViolation(t);if(!i.valid)return i}break;case xt.CHOICE:if(!e)return{valid:!1,exception:"SB.2.12-5"};var n=this.activityTree.getActivity(e);if(!n)return{valid:!1,exception:"SB.2.9-1"};var r=this.constraintValidator.validateChoice(t,n,{checkAvailability:!0});if(!r.valid)return r;if(!this.traversalService.canDeliver(n))return{valid:!1,exception:"SB.2.9-6"};if(this.ruleEngine.checkSequencingRules(n,n.sequencingRules.preConditionRules)===St.HIDE_FROM_CHOICE)return{valid:!1,exception:"SB.2.9-4"};break;case xt.JUMP:if(!e)return{valid:!1,exception:"SB.2.12-5"};if(!this.activityTree.getActivity(e))return{valid:!1,exception:"SB.2.13-1"}}return{valid:!0,exception:null}}},{key:"getAvailableChoices",value:function(){return this.choiceHandler.getAvailableChoices()}},{key:"getTreeQueries",value:function(){return this.treeQueries}},{key:"getConstraintValidator",value:function(){return this.constraintValidator}},{key:"getRuleEngine",value:function(){return this.ruleEngine}},{key:"getTraversalService",value:function(){return this.traversalService}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function _i(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var bi=Object.defineProperty,Si=function(e,t,i){return function(e,t,i){return t in e?bi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},wi=function(){function e(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Si(this,"eventService"),Si(this,"loggingService"),Si(this,"callbacks"),Si(this,"currentDeliveredActivity",null),Si(this,"pendingDelivery",null),this.eventService=t,this.loggingService=i,this.callbacks=n}return t=e,i=[{key:"processSequencingResult",value:function(result){var e,t,i,n;if(result.exception)return this.loggingService.error("Sequencing error: ".concat(result.exception)),void(null===(i=(n=this.callbacks).onSequencingError)||void 0===i||i.call(n,result.exception));result.deliveryRequest===Nt.DELIVER&&result.targetActivity?this.deliverActivity(result.targetActivity):this.loggingService.info("Sequencing completed with no delivery request"),null===(e=(t=this.callbacks).onSequencingComplete)||void 0===e||e.call(t,result)}},{key:"deliverActivity",value:function(e){var t,i;this.currentDeliveredActivity!==e?(this.currentDeliveredActivity&&this.unloadActivity(this.currentDeliveredActivity),this.pendingDelivery=e,this.loggingService.info("Delivering activity: ".concat(e.id," - ").concat(e.title)),this.eventService.processListeners("ActivityDelivery",e.id,e),null===(t=(i=this.callbacks).onDeliverActivity)||void 0===t||t.call(i,e),this.currentDeliveredActivity=e,this.pendingDelivery=null,e.isActive=!0):this.loggingService.info("Skipping delivery - activity already delivered: ".concat(e.id))}},{key:"unloadActivity",value:function(e){var t,i;this.loggingService.info("Unloading activity: ".concat(e.id," - ").concat(e.title)),this.eventService.processListeners("ActivityUnload",e.id,e),null===(t=(i=this.callbacks).onUnloadActivity)||void 0===t||t.call(i,e),e.isActive=!1}},{key:"getCurrentDeliveredActivity",value:function(){return this.currentDeliveredActivity}},{key:"getPendingDelivery",value:function(){return this.pendingDelivery}},{key:"updateCallbacks",value:function(e){this.callbacks=function(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){_i(e,t,i[t])})}return e}({},this.callbacks,e)}},{key:"reset",value:function(){this.currentDeliveredActivity&&this.unloadActivity(this.currentDeliveredActivity),this.currentDeliveredActivity=null,this.pendingDelivery=null}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Ci(e,t,i,n,r,o,s){try{var a=e[o](s),u=a.value}catch(e){return void i(e)}a.done?t(u):Promise.resolve(u).then(n,r)}function Oi(e){return function(){var t=this,i=arguments;return new Promise(function(n,r){var o=e.apply(t,i);function s(e){Ci(o,n,r,s,a,"next",e)}function a(e){Ci(o,n,r,s,a,"throw",e)}s(void 0)})}}function Ei(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Ai(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function ki(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){Ei(e,t,i[t])})}return e}function ji(e,t){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(s,"next",{value:u(0)}),a(s,"throw",{value:u(1)}),a(s,"return",{value:u(2)}),"function"==typeof Symbol&&a(s,Symbol.iterator,{value:function(){return this}}),s;function u(a){return function(u){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&r[3]>a[1])){o.label=a[1];break}if(6===a[0]&&r[1]>o.label){o.label=r[1],r=a;break}if(r&&r[2]>o.label){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}var Ri=Object.defineProperty,Mi=function(e,t,i){return function(e,t,i){return t in e?Ri(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Ti=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Mi(this,"reportsRequestCompletion",!0),Mi(this,"settings"),Mi(this,"error_codes"),this.settings=t,this.error_codes=i}return t=e,i=[{key:"processHttpRequest",value:function(e,t){return this._performAsyncRequest(e,t,arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3?arguments[3]:void 0,arguments.length>4?arguments[4]:void 0,arguments.length>5?arguments[5]:void 0,arguments.length>6?arguments[6]:void 0),{result:z,errorCode:0}}},{key:"_performAsyncRequest",value:function(e,t,i,n,r,o,s){return Oi(function(){var a,u,l,result,c,d;return ji(this,function(f){switch(f.label){case 0:return f.trys.push([0,6,7,8]),a=void 0===o?this.settings.requestHandler(t):this.settings.requestHandler(t,o),u=a,i&&"never"!==this.settings.asyncModeBeaconBehavior?[4,this.performBeacon(e,u)]:[3,2];case 1:return l=f.sent(),[3,4];case 2:return[4,this.performFetch(e,u)];case 3:l=f.sent(),f.label=4;case 4:return[4,this.transformResponse(l,r)];case 5:return result=f.sent(),this._isSuccessResponse(l,result)?r("CommitSuccess"):r("CommitError",void 0,result.errorCode),[3,8];case 6:return c=f.sent(),d=Ai(c,Error)?c.message:c+"",n("processHttpRequest","Async request failed: ".concat(d),Ee.ERROR),r("CommitError",void 0,this.error_codes.GENERAL_COMMIT_FAILURE||391),[3,8];case 7:return null==s||s(),[7];case 8:return[2]}})}).call(this)}},{key:"_prepareRequestBody",value:function(e){return{body:Ai(e,Array)?e.join("&"):JSON.stringify(e),contentType:Ai(e,Array)?"application/x-www-form-urlencoded":this.settings.commitRequestDataType}}},{key:"performFetch",value:function(e,t){return Oi(function(){var i,n,r;return ji(this,function(o){return"always"===this.settings.asyncModeBeaconBehavior?[2,this.performBeacon(e,t)]:(i=this._prepareRequestBody(t),n=i.contentType,r={method:"POST",mode:this.settings.fetchMode,body:i.body,headers:(s=ki({},this.settings.xhrHeaders),a={"Content-Type":n},a=null!=a?a:{},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t}(Object(a)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(a,e))}),s),keepalive:!0},this.settings.xhrWithCredentials&&(r.credentials="include"),[2,fetch(e,r)]);var s,a})}).call(this)}},{key:"performBeacon",value:function(e,t){return Oi(function(){var i,n,r;return ji(this,function(o){return i=this,n=this._prepareRequestBody(t),r=navigator.sendBeacon(e,new Blob([n.body],{type:n.contentType})),[2,Promise.resolve({status:r?200:0,ok:r,json:function(){return Oi(function(){return ji(this,function(e){return[2,{result:r?"true":"false",errorCode:r?0:this.error_codes.GENERAL_COMMIT_FAILURE||391}]})}).call(i)},text:function(){return Oi(function(){return ji(this,function(e){return[2,JSON.stringify({result:r?"true":"false",errorCode:r?0:this.error_codes.GENERAL_COMMIT_FAILURE||391})]})}).call(i)}})]})}).call(this)}},{key:"transformResponse",value:function(e,t){return Oi(function(){var result,t,i,n;return ji(this,function(r){switch(r.label){case 0:return r.trys.push([0,5,,7]),"function"!=typeof this.settings.responseHandler?[3,2]:[4,this.settings.responseHandler(e)];case 1:return t=r.sent(),[3,4];case 2:return[4,e.json()];case 3:t=r.sent(),r.label=4;case 4:return result=t,[3,7];case 5:return i=r.sent(),[4,e.text().catch(function(){return"Unable to read response text"})];case 6:return n=r.sent(),[2,{result:F,errorCode:this.error_codes.GENERAL_COMMIT_FAILURE||391,errorMessage:"Failed to parse LMS response: ".concat(Ai(i,Error)?i.message:i+""),errorDetails:JSON.stringify({status:e.status,statusText:e.statusText,url:e.url,responseText:n.substring(0,500),parseError:Ai(i,Error)?i.message:i+""})}];case 7:return Object.hasOwnProperty.call(result,"errorCode")||(result.errorCode=this._isSuccessResponse(e,result)?0:this.error_codes.GENERAL_COMMIT_FAILURE||391),this._isSuccessResponse(e,result)||(result.errorDetails=ki({status:e.status,statusText:e.statusText,url:e.url},result.errorDetails)),[2,result]}})}).call(this)}},{key:"_isSuccessResponse",value:function(e,result){var t=result.result;return!(200>e.status||e.status>299||!0!==t&&"true"!==t&&t!==z)}},{key:"updateSettings",value:function(e){this.settings=e}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Pi(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}var Ii=Object.defineProperty,xi="{target=";function Ni(e,t){var i,n=e[t];return void 0===n?(void 0!==console&&console.warn&&console.warn("CMIValueAccessService: Unknown error code key: ".concat(t)),null!==(i=e.GENERAL)&&void 0!==i?i:0):n}var Di=function(){function e(t){var i,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),function(e,t,i){t in e?Ii(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(this,"symbol"!==function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(i="context")?i+"":i,n),this.context=t}return t=e,(i=[{key:"getUndefinedDataModelErrorCode",value:function(){return Ni(this.context.errorCodes,"UNDEFINED_DATA_MODEL")}},{key:"setCMIValue",value:function(e,t,i,n){if(!i||""===i)return t&&this.context.throwSCORMError(i,Ni(this.context.errorCodes,"GENERAL_SET_FAILURE"),"The data model element was not specified"),F;this.context.setLastErrorCode("0");for(var r=i.split("."),o=this.context.getDataModel(),s=F,a=!1,u="The data model element passed to ".concat(e," (").concat(i,") is not a valid SCORM data model element."),l=this.getUndefinedDataModelErrorCode(),c=0;r.length>c;c++){if(c===r.length-1){s=this.setFinalAttribute(o,r[c],n,i,t,l,u);break}var d=this.traverseToNextLevel(o,r,c,n,i,t,a,l,u);if(d.error)break;o=d.refObject,c=d.idx,a=d.foundFirstIndex}return s===F&&this.context.apiLog(e,"There was an error setting the value for: ".concat(i,", value of: ").concat(n),Ee.WARN),s}},{key:"getCMIValue",value:function(e,t,i){if(!i||""===i)return t&&this.context.throwSCORMError(i,Ni(this.context.errorCodes,"GENERAL_GET_FAILURE"),"The data model element was not specified"),"";if(t&&i.endsWith("._version")&&"cmi._version"!==i)return this.context.throwSCORMError(i,Ni(this.context.errorCodes,"GENERAL_GET_FAILURE"),"The _version keyword was used incorrectly"),"";this.context.setLastErrorCode("0");for(var n=i.split("."),r=this.context.getDataModel(),o=null,s="The data model element passed to ".concat(e," (").concat(i,") has not been initialized."),a="The data model element passed to ".concat(e," (").concat(i,") is not a valid SCORM data model element."),u=this.getUndefinedDataModelErrorCode(),l=0;n.length>l;l++){var c=this.validateGetAttribute(r,o=n[l],i,t,u,a,l===n.length-1);if(void 0!==c.returnValue)return c.returnValue;if(c.error)return"";if(null==o){this.context.throwSCORMError(i,u,a);break}if(void 0===(r=r[o])){this.context.throwSCORMError(i,u,a);break}if(Pi(r,me)){var d=this.handleGetArrayAccess(r,n,l,i,s);if(d.error)return"";r=d.refObject,l=d.idx}}return null==r?(t||("_children"===o?this.context.throwSCORMError(i,Ni(this.context.errorCodes,"CHILDREN_ERROR"),void 0):"_count"===o&&this.context.throwSCORMError(i,Ni(this.context.errorCodes,"COUNT_ERROR"),void 0)),""):r}},{key:"setFinalAttribute",value:function(e,t,i,n,r,o,s){return r&&(null==t?void 0:t.startsWith(xi))?this.context.isInitialized()?(this.context.throwSCORMError(n,Ni(this.context.errorCodes,"READ_ONLY_ELEMENT")),F):z:void 0!==t&&this.context.checkObjectHasProperty(e,t)?f(n,"\\.correct_responses\\.\\d+$")&&this.context.isInitialized()&&"pattern"!==t&&(this.context.validateCorrectResponse(n,i),"0"!==this.context.getLastErrorCode())?(this.context.throwSCORMError(n,Ni(this.context.errorCodes,"TYPE_MISMATCH")),F):r&&"0"!==this.context.getLastErrorCode()?F:void 0===t||"__proto__"===t||"constructor"===t?(this.context.throwSCORMError(n,o,s),F):r&&"id"===t&&this.context.isInitialized()&&this.context.checkForDuplicateId(n,i)?(this.context.throwSCORMError(n,Ni(this.context.errorCodes,"GENERAL_SET_FAILURE")),F):(e[t]=i,z):(this.context.throwSCORMError(n,o,s),F)}},{key:"traverseToNextLevel",value:function(e,t,i,n,r,o,s,a,u){var l=t[i];if(void 0===l||!this.context.checkObjectHasProperty(e,l))return this.context.throwSCORMError(r,a,u),{refObject:e,idx:i,foundFirstIndex:s,error:!0};if(!(e=e[l]))return this.context.throwSCORMError(r,a,u),{refObject:e,idx:i,foundFirstIndex:s,error:!0};if(Pi(e,me)){var c=this.handleSetArrayAccess(e,t,i,n,r,o,s,a,u);return c.error?{refObject:e,idx:i,foundFirstIndex:s,error:!0}:c}return{refObject:e,idx:i,foundFirstIndex:s,error:!1}}},{key:"handleSetArrayAccess",value:function(e,t,i,n,r,o,s,a,u){var l=parseInt(t[i+1]||"0",10);if(!isNaN(l)){var c=e.childArray[l];if(c)return{refObject:c,idx:i+1,foundFirstIndex:!0,error:!1};if(l>e.childArray.length){var d=o?Ni(this.context.errorCodes,"GENERAL_SET_FAILURE"):Ni(this.context.errorCodes,"INVALID_SET_VALUE")||Ni(this.context.errorCodes,"GENERAL_SET_FAILURE");return this.context.throwSCORMError(r,d,"Cannot set array element at index ".concat(l,". Array indices must be sequential. Current array length is ").concat(e.childArray.length,", expected index ").concat(e.childArray.length,".")),{refObject:e,idx:i,foundFirstIndex:s,error:!0}}var f=this.context.getChildElement(r,n,s);return f?(e.initialized&&f.initialize(),e.childArray[l]=f,{refObject:f,idx:i+1,foundFirstIndex:!0,error:!1}):("0"===this.context.getLastErrorCode()&&this.context.throwSCORMError(r,a,u),{refObject:e,idx:i,foundFirstIndex:s,error:!0})}return{refObject:e,idx:i,foundFirstIndex:s,error:!1}}},{key:"validateGetAttribute",value:function(e,t,i,n,r,o,s){if(n){var a=t+"";if(a.startsWith(xi)&&"function"==typeof e._isTargetValid){var u=a.substring(8,a.length-1);return{error:!1,returnValue:e._isTargetValid(u)}}if(void 0===t||!this.context.checkObjectHasProperty(e,t))return"_children"===t?(this.context.throwSCORMError(i,Ni(this.context.errorCodes,"GENERAL_GET_FAILURE"),"The data model element does not have children"),{error:!0}):"_count"===t?(this.context.throwSCORMError(i,Ni(this.context.errorCodes,"GENERAL_GET_FAILURE"),"The data model element is not a collection and therefore does not have a count"),{error:!0}):(this.context.throwSCORMError(i,r,o),{error:!0})}else if(s&&(void 0===t||!this.context.checkObjectHasProperty(e,t)))return"_children"===t?this.context.throwSCORMError(i,Ni(this.context.errorCodes,"CHILDREN_ERROR")):"_count"===t?this.context.throwSCORMError(i,Ni(this.context.errorCodes,"COUNT_ERROR")):this.context.throwSCORMError(i,r,o),{error:!0};return{error:!1}}},{key:"handleGetArrayAccess",value:function(e,t,i,n,r){var o=parseInt(t[i+1]||"",10);if(!isNaN(o)){var s=e.childArray[o];return s?{refObject:s,idx:i+1,error:!1}:(this.context.throwSCORMError(n,Ni(this.context.errorCodes,"VALUE_NOT_INITIALIZED"),r),{refObject:e,idx:i,error:!0})}return{refObject:e,idx:i,error:!1}}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function qi(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Li=Object.defineProperty,zi=function(e,t,i){return function(e,t,i){return t in e?Li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Fi=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),zi(this,"_logLevel",Ee.ERROR),zi(this,"_logHandler"),this._logHandler=je}var t,i,n;return t=e,n=[{key:"getInstance",value:function(){return e._instance||(e._instance=new e),e._instance}}],(i=[{key:"setLogLevel",value:function(e){this._logLevel=e}},{key:"getLogLevel",value:function(){return this._logLevel}},{key:"setLogHandler",value:function(e){this._logHandler=e}},{key:"log",value:function(e,t){this.shouldLog(e)&&this._logHandler(e,t)}},{key:"error",value:function(e){this.log(Ee.ERROR,e)}},{key:"warn",value:function(e){this.log(Ee.WARN,e)}},{key:"info",value:function(e){this.log(Ee.INFO,e)}},{key:"debug",value:function(e){this.log(Ee.DEBUG,e)}},{key:"shouldLog",value:function(e){return this.getNumericLevel(e)>=this.getNumericLevel(this._logLevel)}},{key:"getNumericLevel",value:function(e){if(void 0===e)return Ee.NONE;if("number"==typeof e)return e;switch("string"==typeof e?e.toUpperCase():e){case"1":case"DEBUG":return Ee.DEBUG;case"2":case"INFO":return Ee.INFO;case"3":case"WARN":return Ee.WARN;case"4":case"ERROR":default:return Ee.ERROR;case"5":case"NONE":return Ee.NONE}}}])&&qi(t.prototype,i),n&&qi(t,n),e}();zi(Fi,"_instance");var Bi=Fi;function Vi(){return Bi.getInstance()}function Hi(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}var Ui=Object.defineProperty,Gi=function(e,t,i){return function(e,t,i){return t in e?Ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Yi=function(){function e(t,i,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Gi(this,"_lastErrorCode","0"),Gi(this,"_lastDiagnostic",""),Gi(this,"_errorCodes"),Gi(this,"_apiLog"),Gi(this,"_getLmsErrorMessageDetails"),Gi(this,"_loggingService"),this._errorCodes=t,this._apiLog=i,this._getLmsErrorMessageDetails=n,this._loggingService=r||Vi()}return t=e,(i=[{key:"lastErrorCode",get:function(){return this._lastErrorCode},set:function(e){this._lastErrorCode=e}},{key:"lastDiagnostic",get:function(){return this._lastDiagnostic}},{key:"throwSCORMError",value:function(e,t,i){this._lastDiagnostic=i||"",i||(i=this._getLmsErrorMessageDetails(t,!0));var n="SCORM Error ".concat(t,": ").concat(i).concat(e?" [Element: ".concat(e,"]"):"");this._apiLog("throwSCORMError",t+": "+i,Ee.ERROR,e),this._loggingService.error(n),this._lastErrorCode=t+""}},{key:"clearSCORMError",value:function(e){void 0!==e&&e!==F&&(this._lastErrorCode="0")}},{key:"handleValueAccessException",value:function(e,t,i){if(Hi(t,L)){var n=t;this._lastErrorCode=n.errorCode+"",this._lastDiagnostic="";var r="Validation Error ".concat(n.errorCode,": ").concat(n.message," [Element: ").concat(e,"]");this._loggingService.warn(r),i=F}else if(Hi(t,Error)){var o=t.constructor.name,s="".concat(o,": ").concat(t.message," [Element: ").concat(e,"]"),a=t.stack||"";this._loggingService.error("".concat(s,"\n").concat(a)),this.throwSCORMError(e,this._errorCodes.GENERAL,"".concat(o,": ").concat(t.message)),i=F}else{this._loggingService.error("Unknown error occurred while accessing [Element: ".concat(e,"]"));try{var u=JSON.stringify(t);this._loggingService.error("Error details: ".concat(u))}catch(e){this._loggingService.error("Could not stringify error object for details")}this.throwSCORMError(e,this._errorCodes.GENERAL,"Unknown error"),i=F}return i}},{key:"errorCodes",get:function(){return this._errorCodes}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var Wi=Object.defineProperty,Ji=function(e,t,i){return function(e,t,i){return t in e?Wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Ki=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Ji(this,"listenerMap",new Map),Ji(this,"listenerCount",0),Ji(this,"apiLog"),this.apiLog=t}return t=e,(i=[{key:"parseListenerName",value:function(e){if(!e)return null;var t=e.split("."),i=t[0],n=null;return t.length>1&&(n=e.replace("".concat(i,"."),"")),{functionName:null!=i?i:e,CMIElement:n}}},{key:"on",value:function(e,t){if(t){var i=e.split(" "),n=!0,r=!1,o=void 0;try{for(var s,a=i[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u,l=this.parseListenerName(s.value);if(l){var c=l.functionName,d=l.CMIElement,f=null!==(u=this.listenerMap.get(c))&&void 0!==u?u:[];f.push({functionName:c,CMIElement:d,callback:t}),this.listenerMap.set(c,f),this.listenerCount++,this.apiLog("on","Added event listener: ".concat(this.listenerCount),Ee.INFO,c)}}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}}}},{key:"off",value:function(e,t){if(t){var i=e.split(" "),n=!0,r=!1,o=void 0;try{for(var s,a,u=function(){var e=s.parseListenerName(a.value);if(!e)return"continue";var i=e.functionName,n=e.CMIElement,r=s.listenerMap.get(i);if(!r)return"continue";var o=r.findIndex(function(e){return e.CMIElement===n&&e.callback===t});-1!==o&&(r.splice(o,1),s.listenerCount--,0===r.length&&s.listenerMap.delete(i),s.apiLog("off","Removed event listener: ".concat(s.listenerCount),Ee.INFO,i))},l=i[Symbol.iterator]();!(n=(a=l.next()).done);n=!0)s=this,u()}catch(e){r=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw o}}}}},{key:"clear",value:function(e){var t=e.split(" "),i=!0,n=!1,r=void 0;try{for(var o,s,a=function(){var e=o.parseListenerName(s.value);if(!e)return"continue";var t=e.functionName,i=e.CMIElement;if(o.listenerMap.has(t)){var n=o.listenerMap.get(t),r=null===i?[]:n.filter(function(e){return e.CMIElement!==i});o.listenerCount-=n.length-r.length,0===r.length?o.listenerMap.delete(t):o.listenerMap.set(t,r)}},u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0)o=this,a()}catch(e){n=!0,r=e}finally{try{i||null==u.return||u.return()}finally{if(n)throw r}}}},{key:"processListeners",value:function(e,t,i,n){this.apiLog(e,i,Ee.INFO,t);var r=this.listenerMap.get(e);if(r){var o=!0,s=!1,a=void 0;try{for(var u,l=r[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c=u.value,d=!!c.CMIElement,f=!1;if(t&&c.CMIElement)if(c.CMIElement.endsWith("*")){var v=c.CMIElement.slice(0,-1);f=t.startsWith(v)}else f=c.CMIElement===t;d&&!f||(this.apiLog("processListeners","Processing listener: ".concat(c.functionName),Ee.DEBUG,t),e.startsWith("Sequence")?c.callback(i):"CommitError"===e?void 0!==n?c.callback(i,n):c.callback(i):"CommitSuccess"===e?void 0!==n?c.callback(n):c.callback():c.callback(t,i))}}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}}}},{key:"reset",value:function(){this.listenerMap.clear(),this.listenerCount=0}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function $i(e,t,i,n,r,o,s){try{var a=e[o](s),u=a.value}catch(e){return void i(e)}a.done?t(u):Promise.resolve(u).then(n,r)}function Xi(e){return function(){var t=this,i=arguments;return new Promise(function(n,r){var o=e.apply(t,i);function s(e){$i(o,n,r,s,a,"next",e)}function a(e){$i(o,n,r,s,a,"throw",e)}s(void 0)})}}function Qi(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Zi(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function en(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){Qi(e,t,i[t])})}return e}function tn(e,t){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(s,"next",{value:u(0)}),a(s,"throw",{value:u(1)}),a(s,"return",{value:u(2)}),"function"==typeof Symbol&&a(s,Symbol.iterator,{value:function(){return this}}),s;function u(a){return function(u){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&r[3]>a[1])){o.label=a[1];break}if(6===a[0]&&r[1]>o.label){o.label=r[1],r=a;break}if(r&&r[2]>o.label){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}var nn=Object.defineProperty,rn=function(e,t,i){return function(e,t,i){return t in e?nn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},sn=function(){function e(t,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),rn(this,"apiLog",n),rn(this,"settings"),rn(this,"error_codes"),rn(this,"storeName","scorm_again_offline_data"),rn(this,"syncQueue","scorm_again_sync_queue"),rn(this,"isOnline",navigator.onLine),rn(this,"syncInProgress",!1),rn(this,"boundOnlineStatusChangeHandler"),rn(this,"boundCustomNetworkStatusHandler"),this.settings=t,this.error_codes=i,this.boundOnlineStatusChangeHandler=this.handleOnlineStatusChange.bind(this),this.boundCustomNetworkStatusHandler=this.handleCustomNetworkStatus.bind(this),window.addEventListener("online",this.boundOnlineStatusChangeHandler),window.addEventListener("offline",this.boundOnlineStatusChangeHandler),window.addEventListener("scorm-again:network-status",this.boundCustomNetworkStatusHandler)}return t=e,(i=[{key:"handleOnlineStatusChange",value:function(){var e=this,t=this.isOnline;this.isOnline=navigator.onLine,!t&&this.isOnline?(this.apiLog("OfflineStorageService","Device is back online, attempting to sync...",Ee.INFO),this.syncOfflineData().then(function(t){t?e.apiLog("OfflineStorageService","Sync completed successfully",Ee.INFO):e.apiLog("OfflineStorageService","Sync failed",Ee.ERROR)},function(t){e.apiLog("OfflineStorageService","Error during sync: ".concat(t),Ee.ERROR)})):t&&!this.isOnline&&this.apiLog("OfflineStorageService","Device is offline, data will be stored locally",Ee.INFO)}},{key:"handleCustomNetworkStatus",value:function(e){var t=this;if(Zi(e,CustomEvent)){var i=e.detail.online;if("boolean"==typeof i){var n=this.isOnline;this.isOnline=i,this.apiLog("OfflineStorageService","Network status updated via custom event: ".concat(i?"online":"offline"),Ee.INFO),!n&&this.isOnline?(this.apiLog("OfflineStorageService","Device is back online, attempting to sync...",Ee.INFO),this.syncOfflineData().then(function(e){e?t.apiLog("OfflineStorageService","Sync completed successfully",Ee.INFO):t.apiLog("OfflineStorageService","Sync failed",Ee.ERROR)},function(e){t.apiLog("OfflineStorageService","Error during sync: ".concat(e),Ee.ERROR)})):n&&!this.isOnline&&this.apiLog("OfflineStorageService","Device is offline, data will be stored locally",Ee.INFO)}else this.apiLog("OfflineStorageService","Invalid online status value in custom event",Ee.WARN)}else this.apiLog("OfflineStorageService","Invalid network status event received",Ee.WARN)}},{key:"storeOffline",value:function(e,t,i){try{var n=en({id:"".concat(e,"_").concat(Date.now(),"_").concat(Math.random().toString(36).substring(2,9)),courseId:e,timestamp:Date.now(),data:t,syncAttempts:0},void 0!==(null==i?void 0:i.isTerminateCommit)?{isTerminateCommit:i.isTerminateCommit}:{},void 0!==(null==i?void 0:i.sequence)?{sequence:i.sequence}:{}),r=this.getFromStorage(this.syncQueue)||[];return r.push(n),this.saveToStorage(this.syncQueue,r),this.saveToStorage("".concat(this.storeName,"_").concat(e),t),this.apiLog("OfflineStorageService","Stored data offline for course ".concat(e),Ee.INFO),{result:z,errorCode:0}}catch(t){var o,s=(Zi(t,Error)?t.message:t+"").includes("storage quota");return this.apiLog("OfflineStorageService",s?"storage quota exceeded - cannot store offline data for course ".concat(e):"Error storing offline data: ".concat(t),Ee.ERROR),{result:F,errorCode:null!==(o=this.error_codes.GENERAL)&&void 0!==o?o:0}}}},{key:"getOfflineData",value:function(e){return Xi(function(){return tn(this,function(t){try{return[2,this.getFromStorage("".concat(this.storeName,"_").concat(e))||null]}catch(e){return this.apiLog("OfflineStorageService","Error retrieving offline data: ".concat(e),Ee.ERROR),[2,null]}return[2]})}).call(this)}},{key:"syncOfflineData",value:function(){return Xi(function(){var e,t,i,n,r,o,s,a,u,l,c,d,f,v;return tn(this,function(h){switch(h.label){case 0:if(this.syncInProgress||!this.isOnline)return[2,!1];this.syncInProgress=!0,h.label=1;case 1:if(h.trys.push([1,12,,13]),0===(e=this.getFromStorage(this.syncQueue)||[]).length)return this.syncInProgress=!1,[2,!0];this.apiLog("OfflineStorageService","Found ".concat(e.length," items to sync"),Ee.INFO),t=[],i=!0,n=!1,r=void 0,h.label=2;case 2:h.trys.push([2,9,10,11]),o=e[Symbol.iterator](),h.label=3;case 3:if(i=(s=o.next()).done)return[3,8];if(l=null!==(u=this.settings.maxSyncAttempts)&&void 0!==u?u:5,(a=s.value).syncAttempts>=l)return this.apiLog("OfflineStorageService","Removing abandoned item ".concat(a.id," after ").concat(l," failed sync attempts"),Ee.WARN),[3,7];h.label=4;case 4:return h.trys.push([4,6,,7]),[4,this.sendDataToLMS(a.data,en({},void 0!==a.isTerminateCommit?{isTerminateCommit:a.isTerminateCommit}:{},void 0!==a.sequence?{sequence:a.sequence}:{}))];case 5:return!0===(c=h.sent()).result||c.result===z?this.apiLog("OfflineStorageService","Successfully synced item ".concat(a.id),Ee.INFO):(a.syncAttempts++,t.push(a),this.apiLog("OfflineStorageService","Failed to sync item ".concat(a.id,", attempt #").concat(a.syncAttempts),Ee.WARN)),[3,7];case 6:return d=h.sent(),a.syncAttempts++,t.push(a),this.apiLog("OfflineStorageService","Error syncing item ".concat(a.id,": ").concat(d),Ee.ERROR),[3,7];case 7:return i=!0,[3,3];case 8:return[3,11];case 9:return f=h.sent(),n=!0,r=f,[3,11];case 10:try{i||null==o.return||o.return()}finally{if(n)throw r}return[7];case 11:return this.saveToStorage(this.syncQueue,t),this.apiLog("OfflineStorageService","Sync completed. ".concat(e.length-t.length," items synced, ").concat(t.length," items remaining"),Ee.INFO),this.syncInProgress=!1,[2,!0];case 12:return v=h.sent(),this.apiLog("OfflineStorageService","Error during sync process: ".concat(v),Ee.ERROR),this.syncInProgress=!1,[2,!1];case 13:return[2]}})}).call(this)}},{key:"sendDataToLMS",value:function(e,t){return Xi(function(){var i,n,r,o,s,a,u,result,l,c;return tn(this,function(d){switch(d.label){case 0:if(!(i=this.settings.lmsCommitUrl))return[2,{result:F,errorCode:this.error_codes.GENERAL||101}];d.label=1;case 1:return d.trys.push([1,7,,8]),r=i+"",o=this.settings.requestHandler(e,en({isTerminateCommit:null!==(n=null==t?void 0:t.isTerminateCommit)&&void 0!==n&&n,trigger:"offline-replay"},void 0!==(null==t?void 0:t.sequence)?{sequence:t.sequence}:{})),s=(null==t?void 0:t.isTerminateCommit)&&this.settings.terminateCommitParam?h(r,this.settings.terminateCommitParam,"true"):r,a={method:"POST",mode:this.settings.fetchMode,body:JSON.stringify(o),headers:(f=en({},this.settings.xhrHeaders),v={"Content-Type":this.settings.commitRequestDataType},v=null!=v?v:{},Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(v)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t}(Object(v)).forEach(function(e){Object.defineProperty(f,e,Object.getOwnPropertyDescriptor(v,e))}),f)},this.settings.xhrWithCredentials&&(a.credentials="include"),[4,fetch(s,a)];case 2:return u=d.sent(),"function"!=typeof this.settings.responseHandler?[3,4]:[4,this.settings.responseHandler(u)];case 3:return l=d.sent(),[3,6];case 4:return[4,u.json()];case 5:l=d.sent(),d.label=6;case 6:return result=l,200>u.status||u.status>299||!0!==result.result&&result.result!==z?(Object.hasOwnProperty.call(result,"errorCode")||(result.errorCode=this.error_codes.GENERAL),[2,result]):(Object.hasOwnProperty.call(result,"errorCode")||(result.errorCode=0),[2,result]);case 7:return c=d.sent(),this.apiLog("OfflineStorageService","Error sending data to LMS: ".concat(c),Ee.ERROR),[2,{result:F,errorCode:this.error_codes.GENERAL||101}];case 8:return[2]}var f,v})}).call(this)}},{key:"isDeviceOnline",value:function(){return this.isOnline}},{key:"getFromStorage",value:function(e){var t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(e){return null}return null}},{key:"saveToStorage",value:function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){if(Zi(e,DOMException)&&"QuotaExceededError"===e.name)throw Error("storage quota exceeded - localStorage is full",{cause:e});throw e}}},{key:"hasPendingOfflineData",value:function(e){return Xi(function(){return tn(this,function(t){return[2,(this.getFromStorage(this.syncQueue)||[]).some(function(t){return t.courseId===e})]})}).call(this)}},{key:"updateSettings",value:function(e){this.settings=e}},{key:"destroy",value:function(){window.removeEventListener("online",this.boundOnlineStatusChangeHandler),window.removeEventListener("offline",this.boundOnlineStatusChangeHandler),window.removeEventListener("scorm-again:network-status",this.boundCustomNetworkStatusHandler)}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}(),an=v(function(e,t,i,n,r,o){if("string"!=typeof t)return!1;var s=RegExp(i),a=t.match(s);if(o&&""===t)return!0;if(!a||""===a[0])throw new r(e,n);return!0},function(e,t,i,n,r,o){var s,a="string"==typeof t?t:"[".concat(void 0===t?"undefined":(s=t)&&"undefined"!=typeof Symbol&&s.constructor===Symbol?"symbol":typeof s,"]");return"".concat(e,":").concat(a,":").concat(i,":").concat(n,":").concat(o||!1)}),un=v(function(e,t,i,n,r){var o=i.split("#");if(isNaN(t=+t))throw new r(e,n);var s=o[0],a=o[1],u=void 0!==a&&""!==a&&"*"!==a;if(void 0!==s&&""!==s&&+s>t)throw new r(e,n);if(u&&t>+a)throw new r(e,n);return!0},function(e,t,i,n,r){return"".concat(e,":").concat(t,":").concat(i,":").concat(n)});function ln(e,t,i,n){return an(e,t,i,ue.TYPE_MISMATCH,ie,n)}function cn(e,t,i){return un(e,t,i,ue.VALUE_OUT_OF_RANGE,ie)}function dn(e,t,i){return t=hn(t),n=e,!(r=_n()?Reflect.construct(t,i||[],hn(e).constructor):t.apply(e,i))||"object"!==gn(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}function fn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function vn(e,t,i){return t&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}function hn(e){return hn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},hn(e)}function mn(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}}),t&&yn(e,t)}function pn(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function yn(e,t){return yn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},yn(e,t)}function gn(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _n(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_n=function(){return!!result})()}var bn=Object.defineProperty,Sn=function(e,t,i){return function(e,t,i){return t in e?bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":gn(t))?t+"":t,i)},wn=function(e){return e.SATISFIED="satisfied",e.NOT_SATISFIED="notSatisfied",e.COMPLETED="completed",e.INCOMPLETE="incomplete",e}(wn||{}),Cn=function(e){return e.ALL="all",e.ANY="any",e.NONE="none",e.AT_LEAST_COUNT="atLeastCount",e.AT_LEAST_PERCENT="atLeastPercent",e}(Cn||{}),On=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"always",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Map;return fn(this,t),e=dn(this,t,["rollupCondition"]),Sn(e,"_condition","always"),Sn(e,"_parameters",new Map),e._condition=i,e._parameters=n,e}return mn(t,e),vn(t,[{key:"reset",value:function(){this._initialized=!1}},{key:"condition",get:function(){return this._condition},set:function(e){this._condition=e}},{key:"parameters",get:function(){return this._parameters},set:function(e){this._parameters=e}},{key:"evaluate",value:function(e){switch(this._condition){case"satisfied":return!0===e.objectiveSatisfiedStatus||e.successStatus===_e;case"objectiveStatusKnown":return e.objectiveSatisfiedStatusKnown;case"objectiveMeasureKnown":return e.objectiveMeasureStatus;case"objectiveMeasureGreaterThan":var t=this._parameters.get("threshold")||0;return e.objectiveMeasureStatus&&e.objectiveNormalizedMeasure>t;case"objectiveMeasureLessThan":var i=this._parameters.get("threshold")||0;return e.objectiveMeasureStatus&&i>e.objectiveNormalizedMeasure;case"completed":return e.isCompleted;case"progressKnown":return e.completionStatus!==Oe;case"attempted":return e.attemptCount>0;case"notAttempted":return 0===e.attemptCount;case"always":return!0;default:return!1}}},{key:"toJSON",value:function(){this.jsonString=!0;var result={condition:this._condition,parameters:Object.fromEntries(this._parameters)};return this.jsonString=!1,result}}]),t}(C),En=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"satisfied",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return fn(this,t),e=dn(this,t,["rollupRule"]),Sn(e,"_conditions",[]),Sn(e,"_action","satisfied"),Sn(e,"_consideration","all"),Sn(e,"_minimumCount",0),Sn(e,"_minimumPercent",0),e._action=i,e._consideration=n,e._minimumCount=r,e._minimumPercent=o,e}return mn(t,e),vn(t,[{key:"reset",value:function(){this._initialized=!1,this._conditions=[]}},{key:"conditions",get:function(){return this._conditions}},{key:"addCondition",value:function(e){if(!pn(e,On))throw new ie(this._cmi_element+".conditions",ue.TYPE_MISMATCH);this._conditions.push(e)}},{key:"removeCondition",value:function(e){var t=this._conditions.indexOf(e);return-1!==t&&(this._conditions.splice(t,1),!0)}},{key:"action",get:function(){return this._action},set:function(e){this._action=e}},{key:"consideration",get:function(){return this._consideration},set:function(e){this._consideration=e}},{key:"minimumCount",get:function(){return this._minimumCount},set:function(e){0>e||(this._minimumCount=e)}},{key:"minimumPercent",get:function(){return this._minimumPercent},set:function(e){0>e||e>100||(this._minimumPercent=e)}},{key:"evaluate",value:function(e){var t=this;if(0===e.length)return!1;var i=e.filter(function(e){return t._conditions.every(function(t){return t.evaluate(e)})});switch(this._consideration){case"all":return i.length===e.length;case"any":return i.length>0;case"none":return 0===i.length;case"atLeastCount":return i.length>=this._minimumCount;case"atLeastPercent":return i.length/e.length*100>=this._minimumPercent;default:return!1}}},{key:"toJSON",value:function(){this.jsonString=!0;var result={conditions:this._conditions,action:this._action,consideration:this._consideration,minimumCount:this._minimumCount,minimumPercent:this._minimumPercent};return this.jsonString=!1,result}}]),t}(C),An=function(e){function t(){var e;return fn(this,t),e=dn(this,t,["rollupRules"]),Sn(e,"_rules",[]),e}return mn(t,e),vn(t,[{key:"reset",value:function(){this._initialized=!1,this._rules=[]}},{key:"rules",get:function(){return this._rules}},{key:"addRule",value:function(e){if(!pn(e,En))throw new ie(this._cmi_element+".rules",ue.TYPE_MISMATCH);this._rules.push(e)}},{key:"removeRule",value:function(e){var t=this._rules.indexOf(e);return-1!==t&&(this._rules.splice(t,1),!0)}},{key:"processRollup",value:function(e){if(e&&0!==e.children.length){var t=e.getAvailableChildren(),i=!1,n=!1;if(e.sequencingControls.rollupObjectiveSatisfied&&null!==this._objectiveRollupUsingMeasure(e,t)&&(n=!0),!n){var r=!0,o=!1,s=void 0;try{for(var a,u=this._rules[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var l=a.value;if(l.evaluate(t))switch(l.action){case"satisfied":e.successStatus=_e,n=!0;break;case"notSatisfied":e.successStatus=be,n=!0;break;case"completed":e.completionStatus=we,e.isCompleted=!0,i=!0;break;case"incomplete":e.completionStatus=Ce,e.isCompleted=!1,i=!0}}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}}i||this._defaultCompletionRollup(e,t),n||this._defaultSuccessRollup(e,t)}}},{key:"_defaultCompletionRollup",value:function(e,t){t.every(function(e){return e.isCompleted})?(e.completionStatus=we,e.isCompleted=!0):t.some(function(e){return e.completionStatus===Ce})&&(e.completionStatus=Ce,e.isCompleted=!1)}},{key:"_objectiveRollupUsingMeasure",value:function(e,t){if(0>=e.sequencingControls.objectiveMeasureWeight)return null;var i=0,n=0,r=!1,o=!0,s=!1,a=void 0;try{for(var u,l=t[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c=u.value;if(c.sequencingControls.rollupObjectiveSatisfied&&c.objectiveMeasureStatus&&!0===c.objectiveMeasureStatus){var d=c.sequencingControls.objectiveMeasureWeight;d>0&&(n+=c.objectiveNormalizedMeasure*d,i+=d,r=!0)}}}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}if(!r||0===i)return null;var f=n/i;return e.objectiveNormalizedMeasure=f,e.objectiveMeasureStatus=!0,e.scaledPassingScore>f?(e.successStatus=be,e.objectiveSatisfiedStatus=!1,!1):(e.successStatus=_e,e.objectiveSatisfiedStatus=!0,!0)}},{key:"_defaultSuccessRollup",value:function(e,t){t.every(function(e){return e.successStatus===_e})?e.successStatus=_e:t.some(function(e){return e.successStatus===be})&&(e.successStatus=be)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={rules:this._rules};return this.jsonString=!1,result}}]),t}(C);function kn(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function jn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Rn(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Mn(e,t,i){return t&&Rn(e.prototype,t),i&&Rn(e,i),e}function Tn(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Pn(e,t,i){return Pn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=In(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},Pn(e,t,i||e)}function In(e){return In=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},In(e)}function xn(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){Tn(e,t,i[t])})}return e}function Nn(e,t){return Nn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Nn(e,t)}function Dn(e){return function(e){if(Array.isArray(e))return kn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return kn(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?kn(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qn(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Ln(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ln=function(){return!!result})()}var zn=Object.defineProperty,Fn=function(e,t,i){return function(e,t,i){return t in e?zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":qn(t))?t+"":t,i)},Bn=function(){function e(id){var t,i,n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};jn(this,e),Fn(this,"_id"),Fn(this,"_description"),Fn(this,"_satisfiedByMeasure"),Fn(this,"_minNormalizedMeasure"),Fn(this,"_mapInfo"),Fn(this,"_isPrimary"),Fn(this,"_satisfiedStatus",!1),Fn(this,"_satisfiedStatusKnown",!1),Fn(this,"_measureStatus",!1),Fn(this,"_normalizedMeasure",0),Fn(this,"_progressMeasure",0),Fn(this,"_progressMeasureStatus",!1),Fn(this,"_completionStatus",Oe),Fn(this,"_progressStatus",!1),Fn(this,"_satisfiedStatusDirty",!1),Fn(this,"_normalizedMeasureDirty",!1),Fn(this,"_completionStatusDirty",!1),Fn(this,"_progressMeasureDirty",!1),this._id=id,this._description=null!==(t=o.description)&&void 0!==t?t:null,this._satisfiedByMeasure=null!==(i=o.satisfiedByMeasure)&&void 0!==i&&i,this._minNormalizedMeasure=null!==(n=o.minNormalizedMeasure)&&void 0!==n?n:null,this._mapInfo=o.mapInfo?Dn(o.mapInfo):[],this._isPrimary=null!==(r=o.isPrimary)&&void 0!==r&&r}return Mn(e,[{key:"id",get:function(){return this._id}},{key:"description",get:function(){return this._description}},{key:"satisfiedByMeasure",get:function(){return this._satisfiedByMeasure},set:function(e){this._satisfiedByMeasure=e}},{key:"minNormalizedMeasure",get:function(){return this._minNormalizedMeasure},set:function(e){this._minNormalizedMeasure=e}},{key:"mapInfo",get:function(){return this._mapInfo},set:function(e){this._mapInfo=Dn(e)}},{key:"isPrimary",get:function(){return this._isPrimary},set:function(e){this._isPrimary=e}},{key:"satisfiedStatus",get:function(){return this._satisfiedStatus},set:function(e){this._satisfiedStatus!==e&&(this._satisfiedStatus=e,this._satisfiedStatusDirty=!0)}},{key:"satisfiedStatusKnown",get:function(){return this._satisfiedStatusKnown},set:function(e){this._satisfiedStatusKnown=e}},{key:"measureStatus",get:function(){return this._measureStatus},set:function(e){this._measureStatus=e}},{key:"normalizedMeasure",get:function(){return this._normalizedMeasure},set:function(e){this._normalizedMeasure!==e&&(this._normalizedMeasure=e,this._normalizedMeasureDirty=!0)}},{key:"progressMeasure",get:function(){return this._progressMeasure},set:function(e){this._progressMeasure!==e&&(this._progressMeasure=e,this._progressMeasureDirty=!0)}},{key:"progressMeasureStatus",get:function(){return this._progressMeasureStatus},set:function(e){this._progressMeasureStatus=e}},{key:"completionStatus",get:function(){return this._completionStatus},set:function(e){this._completionStatus!==e&&(this._completionStatus=e,this._completionStatusDirty=!0)}},{key:"progressStatus",get:function(){return this._progressStatus},set:function(e){this._progressStatus=e}},{key:"isDirty",value:function(e){switch(e){case"satisfiedStatus":return this._satisfiedStatusDirty;case"normalizedMeasure":return this._normalizedMeasureDirty;case"completionStatus":return this._completionStatusDirty;case"progressMeasure":return this._progressMeasureDirty}}},{key:"clearDirty",value:function(e){switch(e){case"satisfiedStatus":this._satisfiedStatusDirty=!1;break;case"normalizedMeasure":this._normalizedMeasureDirty=!1;break;case"completionStatus":this._completionStatusDirty=!1;break;case"progressMeasure":this._progressMeasureDirty=!1}}},{key:"clearAllDirty",value:function(){this._satisfiedStatusDirty=!1,this._normalizedMeasureDirty=!1,this._completionStatusDirty=!1,this._progressMeasureDirty=!1}},{key:"initializeFromCMI",value:function(e,t,i){this._satisfiedStatus=e,this._satisfiedStatusDirty=!0,this._normalizedMeasure=t,this._normalizedMeasureDirty=!0,this._measureStatus=i}},{key:"resetState",value:function(){this._satisfiedStatus=!1,this._satisfiedStatusKnown=!1,this._measureStatus=!1,this._normalizedMeasure=0,this._progressMeasure=0,this._progressMeasureStatus=!1,this._completionStatus=Oe,this._progressStatus=!1,this.clearAllDirty()}},{key:"updateFromActivity",value:function(e){this._satisfiedStatus!==e.objectiveSatisfiedStatus&&(this._satisfiedStatus=e.objectiveSatisfiedStatus,this._satisfiedStatusDirty=!0),this._satisfiedStatusKnown=e.objectiveSatisfiedStatusKnown,this._measureStatus=e.objectiveMeasureStatus,this._normalizedMeasure!==e.objectiveNormalizedMeasure&&(this._normalizedMeasure=e.objectiveNormalizedMeasure,this._normalizedMeasureDirty=!0),this._progressMeasure!==e.progressMeasure&&(this._progressMeasure=e.progressMeasure,this._progressMeasureDirty=!0),this._progressMeasureStatus=e.progressMeasureStatus,this._completionStatus!==e.completionStatus&&(this._completionStatus=e.completionStatus,this._completionStatusDirty=!0)}},{key:"applyToActivity",value:function(e){this._isPrimary&&e.setPrimaryObjectiveState(this._satisfiedStatus,this._measureStatus,this._normalizedMeasure,this._progressMeasure,this._progressMeasureStatus,this._completionStatus)}}]),e}(),Vn=function(e){function t(){var e,id=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return jn(this,t),e=function(e,t,i){return t=In(t),n=e,!(r=Ln()?Reflect.construct(t,i||[],In(e).constructor):t.apply(e,i))||"object"!==qn(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["activity"]),Fn(e,"_id",""),Fn(e,"_title",""),Fn(e,"_children",[]),Fn(e,"_parent",null),Fn(e,"_isVisible",!0),Fn(e,"_isActive",!1),Fn(e,"_isSuspended",!1),Fn(e,"_isCompleted",!1),Fn(e,"_completionStatus",Oe),Fn(e,"_successStatus",Se),Fn(e,"_attemptCount",0),Fn(e,"_attemptCompletionAmount",0),Fn(e,"_attemptAbsoluteDuration","PT0H0M0S"),Fn(e,"_attemptExperiencedDuration","PT0H0M0S"),Fn(e,"_activityAbsoluteDuration","PT0H0M0S"),Fn(e,"_activityExperiencedDuration","PT0H0M0S"),Fn(e,"_attemptAbsoluteDurationValue","PT0H0M0S"),Fn(e,"_attemptExperiencedDurationValue","PT0H0M0S"),Fn(e,"_activityAbsoluteDurationValue","PT0H0M0S"),Fn(e,"_activityExperiencedDurationValue","PT0H0M0S"),Fn(e,"_activityStartTimestampUtc",null),Fn(e,"_attemptStartTimestampUtc",null),Fn(e,"_activityEndedDate",null),Fn(e,"_objectiveSatisfiedStatus",!1),Fn(e,"_objectiveSatisfiedStatusKnown",!1),Fn(e,"_objectiveMeasureStatus",!1),Fn(e,"_objectiveNormalizedMeasure",0),Fn(e,"_scaledPassingScore",.7),Fn(e,"_objectiveSatisfiedStatusDirty",!1),Fn(e,"_objectiveNormalizedMeasureDirty",!1),Fn(e,"_objectiveMeasureStatusDirty",!1),Fn(e,"_progressMeasure",0),Fn(e,"_progressMeasureStatus",!1),Fn(e,"_location",""),Fn(e,"_attemptAbsoluteStartTime",""),Fn(e,"_learnerPrefs",null),Fn(e,"_activityAttemptActive",!1),Fn(e,"_isHiddenFromChoice",!1),Fn(e,"_isAvailable",!0),Fn(e,"_hideLmsUi",[]),Fn(e,"_auxiliaryResources",[]),Fn(e,"_attemptLimit",null),Fn(e,"_attemptAbsoluteDurationLimit",null),Fn(e,"_activityAbsoluteDurationLimit",null),Fn(e,"_timeLimitAction",null),Fn(e,"_timeLimitDuration",null),Fn(e,"_beginTimeLimit",null),Fn(e,"_endTimeLimit",null),Fn(e,"_launchData",""),Fn(e,"_credit","credit"),Fn(e,"_maxTimeAllowed",""),Fn(e,"_completionThreshold",""),Fn(e,"_sequencingControls"),Fn(e,"_sequencingRules"),Fn(e,"_rollupRules"),Fn(e,"_processedChildren",null),Fn(e,"_isNewAttempt",!1),Fn(e,"_primaryObjective",null),Fn(e,"_objectives",[]),Fn(e,"_rollupConsiderations",{requiredForSatisfied:"always",requiredForNotSatisfied:"always",requiredForCompleted:"always",requiredForIncomplete:"always",measureSatisfactionIfActive:!0}),Fn(e,"_requiredForSatisfied","always"),Fn(e,"_requiredForNotSatisfied","always"),Fn(e,"_requiredForCompleted","always"),Fn(e,"_requiredForIncomplete","always"),Fn(e,"_wasSkipped",!1),Fn(e,"_attemptProgressStatus",!1),Fn(e,"_wasAutoCompleted",!1),Fn(e,"_wasAutoSatisfied",!1),Fn(e,"_completedByMeasure",!1),Fn(e,"_minProgressMeasure",1),Fn(e,"_progressWeight",1),Fn(e,"_attemptCompletionAmountStatus",!1),e._id=id,e._title=i,e._sequencingControls=new Xt,e._sequencingRules=new Et,e._rollupRules=new An,e._primaryObjective=null,e._objectives=[],e}return function(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}}),t&&Nn(e,t)}(t,e),Mn(t,[{key:"initialize",value:function(){Pn(In(t.prototype),"initialize",this).call(this);var e=!0,i=!1,n=void 0;try{for(var r,o=this._children[Symbol.iterator]();!(e=(r=o.next()).done);e=!0)r.value.initialize()}catch(e){i=!0,n=e}finally{try{e||null==o.return||o.return()}finally{if(i)throw n}}}},{key:"reset",value:function(){this._initialized=!1,this._isActive=!1,this._isSuspended=!1,this._isCompleted=!1,this._completionStatus=Oe,this._successStatus=Se,this._attemptCount=0,this._attemptCompletionAmount=0,this._attemptAbsoluteDuration="PT0H0M0S",this._attemptExperiencedDuration="PT0H0M0S",this._activityAbsoluteDuration="PT0H0M0S",this._activityExperiencedDuration="PT0H0M0S",this._attemptAbsoluteDurationValue="PT0H0M0S",this._attemptExperiencedDurationValue="PT0H0M0S",this._activityAbsoluteDurationValue="PT0H0M0S",this._activityExperiencedDurationValue="PT0H0M0S",this._activityStartTimestampUtc=null,this._attemptStartTimestampUtc=null,this._activityEndedDate=null,this._objectiveSatisfiedStatus=!1,this._objectiveSatisfiedStatusKnown=!1,this._objectiveMeasureStatus=!1,this._objectiveNormalizedMeasure=0,this._progressMeasure=0,this._progressMeasureStatus=!1,this._location="",this._attemptAbsoluteStartTime="",this._learnerPrefs=null,this._activityAttemptActive=!1,this._primaryObjective&&(this._primaryObjective.resetState(),this._primaryObjective.updateFromActivity(this));var e=!0,t=!1,i=void 0;try{for(var n,r=this._objectives[Symbol.iterator]();!(e=(n=r.next()).done);e=!0)n.value.resetState()}catch(e){t=!0,i=e}finally{try{e||null==r.return||r.return()}finally{if(t)throw i}}var o=!0,s=!1,a=void 0;try{for(var u,l=this._children[Symbol.iterator]();!(o=(u=l.next()).done);o=!0)u.value.reset()}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}this._wasSkipped=!1,this._attemptProgressStatus=!1,this._wasAutoCompleted=!1,this._wasAutoSatisfied=!1,this._completedByMeasure=!1,this._minProgressMeasure=1,this._progressWeight=1,this._attemptCompletionAmountStatus=!1,this.clearAllObjectiveDirty()}},{key:"id",get:function(){return this._id},set:function(id){ln(this._cmi_element+".id",id,Ge)&&(this._id=id)}},{key:"title",get:function(){return this._title},set:function(e){ln(this._cmi_element+".title",e,ze)&&(this._title=e)}},{key:"children",get:function(){return this._children}},{key:"addChild",value:function(e){if(i=e,!(null!=(n=t)&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?n[Symbol.hasInstance](i):i instanceof n))throw new ie(this._cmi_element+".children",ue.TYPE_MISMATCH);var i,n;e._parent=this,this._children.push(e)}},{key:"setChildOrder",value:function(e){if(0!==e.length){var t,i=new Map(this._children.map(function(e){return[e.id,e]})),n=[],r=!0,o=!1,s=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var id=a.value,l=i.get(id);l&&(n.push(l),i.delete(id))}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}if(i.size>0){var c=!0,d=!1,f=void 0;try{for(var v,h=this._children[Symbol.iterator]();!(c=(v=h.next()).done);c=!0){var m=v.value;i.has(m.id)&&(n.push(m),i.delete(m.id))}}catch(e){d=!0,f=e}finally{try{c||null==h.return||h.return()}finally{if(d)throw f}}}n.length===this._children.length&&(t=this._children).splice.apply(t,[0,this._children.length].concat(Dn(n)))}}},{key:"removeChild",value:function(e){var t=this._children.indexOf(e);return-1!==t&&(this._children.splice(t,1),e._parent=null,!0)}},{key:"parent",get:function(){return this._parent}},{key:"isVisible",get:function(){return this._isVisible},set:function(e){this._isVisible=e}},{key:"isActive",get:function(){return this._isActive},set:function(e){this._isActive=e}},{key:"isSuspended",get:function(){return this._isSuspended},set:function(e){this._isSuspended=e}},{key:"isCompleted",get:function(){return this._isCompleted},set:function(e){this._isCompleted=e,this._completionStatus=e?we:Ce}},{key:"completionStatus",get:function(){return this._completionStatus},set:function(e){this._completionStatus=e,this._isCompleted=e===we,this.updatePrimaryObjectiveFromActivity()}},{key:"successStatus",get:function(){return this._successStatus},set:function(e){this._successStatus=e}},{key:"attemptCount",get:function(){return this._attemptCount},set:function(e){this._attemptCount=e}},{key:"attemptCompletionAmount",get:function(){return this._attemptCompletionAmount},set:function(e){this._attemptCompletionAmount=e}},{key:"incrementAttemptCount",value:function(){this._attemptCount++,this._isNewAttempt=!0;var e=this._sequencingControls;"onEachNewAttempt"!==e.selectionTiming&&"onEachNewAttempt"!==e.randomizationTiming||(this._processedChildren=null)}},{key:"objectiveSatisfiedStatus",get:function(){return this._objectiveSatisfiedStatus},set:function(e){this._objectiveSatisfiedStatus!==e&&(this._objectiveSatisfiedStatus=e,this._objectiveSatisfiedStatusDirty=!0),this._objectiveSatisfiedStatusKnown=!0,this._successStatus=e?_e:be,this.updatePrimaryObjectiveFromActivity()}},{key:"objectiveSatisfiedStatusKnown",get:function(){return this._objectiveSatisfiedStatusKnown},set:function(e){this._objectiveSatisfiedStatusKnown=e}},{key:"objectiveMeasureStatus",get:function(){return this._objectiveMeasureStatus},set:function(e){this._objectiveMeasureStatus!==e&&(this._objectiveMeasureStatus=e,this._objectiveMeasureStatusDirty=!0),this.updatePrimaryObjectiveFromActivity()}},{key:"objectiveNormalizedMeasure",get:function(){return this._objectiveNormalizedMeasure},set:function(e){this._objectiveNormalizedMeasure!==e&&(this._objectiveNormalizedMeasure=e,this._objectiveNormalizedMeasureDirty=!0),this.updatePrimaryObjectiveFromActivity()}},{key:"scaledPassingScore",get:function(){return this._scaledPassingScore},set:function(e){-1>e||e>1||(this._scaledPassingScore=e)}},{key:"progressMeasure",get:function(){return this._progressMeasure},set:function(e){this._progressMeasure=e,this.updatePrimaryObjectiveFromActivity()}},{key:"progressMeasureStatus",get:function(){return this._progressMeasureStatus},set:function(e){this._progressMeasureStatus=e,this.updatePrimaryObjectiveFromActivity()}},{key:"location",get:function(){return this._location},set:function(location){this._location=location}},{key:"attemptAbsoluteStartTime",get:function(){return this._attemptAbsoluteStartTime},set:function(e){this._attemptAbsoluteStartTime=e}},{key:"learnerPrefs",get:function(){return this._learnerPrefs},set:function(e){this._learnerPrefs=e}},{key:"activityAttemptActive",get:function(){return this._activityAttemptActive},set:function(e){this._activityAttemptActive=e}},{key:"isHiddenFromChoice",get:function(){return this._isHiddenFromChoice},set:function(e){this._isHiddenFromChoice=e}},{key:"isAvailable",get:function(){return this._isAvailable},set:function(e){this._isAvailable=e}},{key:"attemptLimit",get:function(){return this._attemptLimit},set:function(e){this._attemptLimit=e}},{key:"hasAttemptLimitExceeded",value:function(){return null!==this._attemptLimit&&this._attemptCount>=this._attemptLimit}},{key:"timeLimitDuration",get:function(){return this._timeLimitDuration},set:function(e){this._timeLimitDuration=e}},{key:"timeLimitAction",get:function(){return this._timeLimitAction},set:function(e){this._timeLimitAction=e}},{key:"beginTimeLimit",get:function(){return this._beginTimeLimit},set:function(e){this._beginTimeLimit=e}},{key:"endTimeLimit",get:function(){return this._endTimeLimit},set:function(e){this._endTimeLimit=e}},{key:"attemptAbsoluteDurationLimit",get:function(){return this._attemptAbsoluteDurationLimit},set:function(e){if(null!==e&&!l(e,Ve))throw new ie(this._cmi_element+".attemptAbsoluteDurationLimit",ue.TYPE_MISMATCH);this._attemptAbsoluteDurationLimit=e}},{key:"attemptExperiencedDuration",get:function(){return this._attemptExperiencedDuration},set:function(e){if(!l(e,Ve))throw new ie(this._cmi_element+".attemptExperiencedDuration",ue.TYPE_MISMATCH);this._attemptExperiencedDuration=e}},{key:"activityAbsoluteDurationLimit",get:function(){return this._activityAbsoluteDurationLimit},set:function(e){if(null!==e&&!l(e,Ve))throw new ie(this._cmi_element+".activityAbsoluteDurationLimit",ue.TYPE_MISMATCH);this._activityAbsoluteDurationLimit=e}},{key:"activityExperiencedDuration",get:function(){return this._activityExperiencedDuration},set:function(e){if(!l(e,Ve))throw new ie(this._cmi_element+".activityExperiencedDuration",ue.TYPE_MISMATCH);this._activityExperiencedDuration=e}},{key:"attemptAbsoluteDuration",get:function(){return this._attemptAbsoluteDurationLimit||"PT0H0M0S"},set:function(e){this._attemptAbsoluteDurationLimit=e}},{key:"activityAbsoluteDuration",get:function(){return this._activityAbsoluteDurationLimit||"PT0H0M0S"},set:function(e){this._activityAbsoluteDurationLimit=e}},{key:"attemptAbsoluteDurationValue",get:function(){return this._attemptAbsoluteDurationValue},set:function(e){if(!l(e,Ve))throw new ie(this._cmi_element+".attemptAbsoluteDurationValue",ue.TYPE_MISMATCH);this._attemptAbsoluteDurationValue=e}},{key:"attemptExperiencedDurationValue",get:function(){return this._attemptExperiencedDurationValue},set:function(e){if(!l(e,Ve))throw new ie(this._cmi_element+".attemptExperiencedDurationValue",ue.TYPE_MISMATCH);this._attemptExperiencedDurationValue=e}},{key:"activityAbsoluteDurationValue",get:function(){return this._activityAbsoluteDurationValue},set:function(e){if(!l(e,Ve))throw new ie(this._cmi_element+".activityAbsoluteDurationValue",ue.TYPE_MISMATCH);this._activityAbsoluteDurationValue=e}},{key:"activityExperiencedDurationValue",get:function(){return this._activityExperiencedDurationValue},set:function(e){if(!l(e,Ve))throw new ie(this._cmi_element+".activityExperiencedDurationValue",ue.TYPE_MISMATCH);this._activityExperiencedDurationValue=e}},{key:"activityStartTimestampUtc",get:function(){return this._activityStartTimestampUtc},set:function(timestamp){this._activityStartTimestampUtc=timestamp}},{key:"attemptStartTimestampUtc",get:function(){return this._attemptStartTimestampUtc},set:function(timestamp){this._attemptStartTimestampUtc=timestamp}},{key:"activityEndedDate",get:function(){return this._activityEndedDate},set:function(e){this._activityEndedDate=e}},{key:"sequencingControls",get:function(){return this._sequencingControls},set:function(e){this._sequencingControls=e}},{key:"sequencingRules",get:function(){return this._sequencingRules},set:function(e){this._sequencingRules=e}},{key:"rollupRules",get:function(){return this._rollupRules},set:function(e){this._rollupRules=e}},{key:"rollupConsiderations",get:function(){return xn({},this._rollupConsiderations)},set:function(e){this._rollupConsiderations=xn({},e)}},{key:"applyRollupConsiderations",value:function(e){this._rollupConsiderations=xn({},this._rollupConsiderations,e)}},{key:"requiredForSatisfied",get:function(){return this._requiredForSatisfied},set:function(e){this._requiredForSatisfied=e}},{key:"requiredForNotSatisfied",get:function(){return this._requiredForNotSatisfied},set:function(e){this._requiredForNotSatisfied=e}},{key:"requiredForCompleted",get:function(){return this._requiredForCompleted},set:function(e){this._requiredForCompleted=e}},{key:"requiredForIncomplete",get:function(){return this._requiredForIncomplete},set:function(e){this._requiredForIncomplete=e}},{key:"wasSkipped",get:function(){return this._wasSkipped},set:function(e){this._wasSkipped=e}},{key:"attemptProgressStatus",get:function(){return this._attemptProgressStatus},set:function(e){this._attemptProgressStatus=e}},{key:"wasAutoCompleted",get:function(){return this._wasAutoCompleted},set:function(e){this._wasAutoCompleted=e}},{key:"wasAutoSatisfied",get:function(){return this._wasAutoSatisfied},set:function(e){this._wasAutoSatisfied=e}},{key:"completedByMeasure",get:function(){return this._completedByMeasure},set:function(e){this._completedByMeasure=e}},{key:"minProgressMeasure",get:function(){return this._minProgressMeasure},set:function(e){if(0>e||e>1)throw new ie(this._cmi_element+".minProgressMeasure",ue.TYPE_MISMATCH);this._minProgressMeasure=e}},{key:"progressWeight",get:function(){return this._progressWeight},set:function(e){if(0>e)throw new ie(this._cmi_element+".progressWeight",ue.TYPE_MISMATCH);this._progressWeight=e}},{key:"attemptCompletionAmountStatus",get:function(){return this._attemptCompletionAmountStatus},set:function(e){this._attemptCompletionAmountStatus=e}},{key:"primaryObjective",get:function(){return this._primaryObjective},set:function(e){var t;(this._primaryObjective=e,this._primaryObjective)&&(this._primaryObjective.isPrimary=!0,null!==this._primaryObjective.minNormalizedMeasure&&(this._scaledPassingScore=null!==(t=this._primaryObjective.minNormalizedMeasure)&&void 0!==t?t:this._scaledPassingScore),this._primaryObjective.updateFromActivity(this));this.syncPrimaryObjectiveCollection()}},{key:"objectives",get:function(){var e=this;return this._objectives.filter(function(t){var i;return t.id!==(null===(i=e._primaryObjective)||void 0===i?void 0:i.id)})},set:function(objectives){this._objectives=Dn(objectives),this.syncPrimaryObjectiveCollection()}},{key:"addObjective",value:function(e){this._objectives.find(function(t){return t.id===e.id})||this._objectives.push(e)}},{key:"syncPrimaryObjectiveCollection",value:function(){var e=this;if(this._primaryObjective){var t=this._objectives.findIndex(function(t){var i;return t.id===(null===(i=e._primaryObjective)||void 0===i?void 0:i.id)});0>t?this._objectives=[this._primaryObjective].concat(Dn(this._objectives)):this._objectives[t]=this._primaryObjective}else this._objectives=this._objectives.filter(function(e){return!e.isPrimary})}},{key:"getObjectiveById",value:function(e){var t;if((null===(t=this._primaryObjective)||void 0===t?void 0:t.id)===e)return{objective:this._primaryObjective,isPrimary:!0};var i=this._objectives.find(function(t){return t.id===e});return i?{objective:i,isPrimary:!1}:null}},{key:"getAllObjectives",value:function(){var e=this,objectives=[];this._primaryObjective&&objectives.push(this._primaryObjective);var t=this._objectives.filter(function(t){var i;return t!==e._primaryObjective&&t.id!==(null===(i=e._primaryObjective)||void 0===i?void 0:i.id)});return objectives.concat(t)}},{key:"updatePrimaryObjectiveFromActivity",value:function(){this._primaryObjective&&this._primaryObjective.updateFromActivity(this)}},{key:"isObjectiveDirty",value:function(e){switch(e){case"satisfiedStatus":return this._objectiveSatisfiedStatusDirty;case"normalizedMeasure":return this._objectiveNormalizedMeasureDirty;case"measureStatus":return this._objectiveMeasureStatusDirty}}},{key:"clearObjectiveDirty",value:function(e){switch(e){case"satisfiedStatus":this._objectiveSatisfiedStatusDirty=!1;break;case"normalizedMeasure":this._objectiveNormalizedMeasureDirty=!1;break;case"measureStatus":this._objectiveMeasureStatusDirty=!1}}},{key:"clearAllObjectiveDirty",value:function(){this._objectiveSatisfiedStatusDirty=!1,this._objectiveNormalizedMeasureDirty=!1,this._objectiveMeasureStatusDirty=!1}},{key:"setPrimaryObjectiveState",value:function(e,t,i,n,r,o){this._objectiveSatisfiedStatus!==e&&(this._objectiveSatisfiedStatus=e,this._objectiveSatisfiedStatusDirty=!0),this._objectiveSatisfiedStatusKnown=!0,this._objectiveMeasureStatus!==t&&(this._objectiveMeasureStatus=t,this._objectiveMeasureStatusDirty=!0),this._objectiveNormalizedMeasure!==i&&(this._objectiveNormalizedMeasure=i,this._objectiveNormalizedMeasureDirty=!0),this._progressMeasure=n,this._progressMeasureStatus=r,this._completionStatus=o,this._primaryObjective&&(this._primaryObjective.satisfiedStatus=e,this._primaryObjective.measureStatus=t,this._primaryObjective.normalizedMeasure=i,this._primaryObjective.progressMeasure=n,this._primaryObjective.progressMeasureStatus=r,this._primaryObjective.completionStatus=o)}},{key:"getObjectiveStateSnapshot",value:function(){var e;return{primary:this._primaryObjective?{id:this._primaryObjective.id,satisfiedStatus:this.objectiveSatisfiedStatus,measureStatus:this.objectiveMeasureStatus,normalizedMeasure:this.objectiveNormalizedMeasure,progressMeasure:null!==(e=this.progressMeasure)&&void 0!==e?e:0,progressMeasureStatus:this.progressMeasureStatus,progressStatus:this._primaryObjective.progressStatus,completionStatus:this.completionStatus,satisfiedByMeasure:this._primaryObjective.satisfiedByMeasure,minNormalizedMeasure:this._primaryObjective.minNormalizedMeasure}:null,objectives:this._objectives.map(function(e){return{id:e.id,satisfiedStatus:e.satisfiedStatus,measureStatus:e.measureStatus,normalizedMeasure:e.normalizedMeasure,progressMeasure:e.progressMeasure,progressMeasureStatus:e.progressMeasureStatus,progressStatus:e.progressStatus,completionStatus:e.completionStatus,satisfiedByMeasure:e.satisfiedByMeasure,minNormalizedMeasure:e.minNormalizedMeasure}})}}},{key:"applyObjectiveStateSnapshot",value:function(e){if(e.primary){var t=this.getObjectiveById(e.primary.id);if(t&&t.isPrimary){var i,n=e.primary;t.objective.satisfiedByMeasure=null!==(i=n.satisfiedByMeasure)&&void 0!==i?i:t.objective.satisfiedByMeasure,t.objective.minNormalizedMeasure=void 0!==n.minNormalizedMeasure?n.minNormalizedMeasure:t.objective.minNormalizedMeasure,this.setPrimaryObjectiveState(n.satisfiedStatus,n.measureStatus,n.normalizedMeasure,n.progressMeasure,n.progressMeasureStatus,n.completionStatus)}}var r=!0,o=!1,s=void 0;try{for(var a,u=e.objectives[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var l=a.value,c=this.getObjectiveById(l.id);if(c&&!c.isPrimary){var d,f=c.objective;f.satisfiedStatus=l.satisfiedStatus,f.measureStatus=l.measureStatus,f.normalizedMeasure=l.normalizedMeasure,f.progressMeasure=l.progressMeasure,f.progressMeasureStatus=l.progressMeasureStatus,f.completionStatus=l.completionStatus,f.satisfiedByMeasure=null!==(d=l.satisfiedByMeasure)&&void 0!==d?d:f.satisfiedByMeasure,f.minNormalizedMeasure=void 0!==l.minNormalizedMeasure?l.minNormalizedMeasure:f.minNormalizedMeasure}}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}}},{key:"getAvailableChildren",value:function(){return 0===this._children.length?[]:null!==this._processedChildren?this._processedChildren:this._children}},{key:"setProcessedChildren",value:function(e){this._processedChildren=e}},{key:"resetProcessedChildren",value:function(){this._processedChildren=null}},{key:"isNewAttempt",get:function(){return this._isNewAttempt},set:function(e){this._isNewAttempt=e}},{key:"launchData",get:function(){return this._launchData},set:function(e){this._launchData=e}},{key:"credit",get:function(){return this._credit},set:function(credit){this._credit=credit}},{key:"maxTimeAllowed",get:function(){return this._maxTimeAllowed},set:function(e){this._maxTimeAllowed=e}},{key:"completionThreshold",get:function(){return this._completionThreshold},set:function(e){this._completionThreshold=e}},{key:"getSuspensionState",value:function(){return{id:this._id,title:this._title,isVisible:this._isVisible,isActive:this._isActive,isSuspended:this._isSuspended,isCompleted:this._isCompleted,completionStatus:this._completionStatus,successStatus:this._successStatus,attemptCount:this._attemptCount,attemptCompletionAmount:this._attemptCompletionAmount,attemptAbsoluteDuration:this._attemptAbsoluteDuration,attemptExperiencedDuration:this._attemptExperiencedDuration,activityAbsoluteDuration:this._activityAbsoluteDuration,activityExperiencedDuration:this._activityExperiencedDuration,attemptAbsoluteDurationValue:this._attemptAbsoluteDurationValue,attemptExperiencedDurationValue:this._attemptExperiencedDurationValue,activityAbsoluteDurationValue:this._activityAbsoluteDurationValue,activityExperiencedDurationValue:this._activityExperiencedDurationValue,activityStartTimestampUtc:this._activityStartTimestampUtc,attemptStartTimestampUtc:this._attemptStartTimestampUtc,objectiveSatisfiedStatus:this._objectiveSatisfiedStatus,objectiveSatisfiedStatusKnown:this._objectiveSatisfiedStatusKnown,objectiveMeasureStatus:this._objectiveMeasureStatus,objectiveNormalizedMeasure:this._objectiveNormalizedMeasure,scaledPassingScore:this._scaledPassingScore,progressMeasure:this._progressMeasure,progressMeasureStatus:this._progressMeasureStatus,location:this._location,attemptAbsoluteStartTime:this._attemptAbsoluteStartTime,activityAttemptActive:this._activityAttemptActive,isHiddenFromChoice:this._isHiddenFromChoice,isAvailable:this._isAvailable,rollupConsiderations:xn({},this._rollupConsiderations),wasSkipped:this._wasSkipped,attemptProgressStatus:this._attemptProgressStatus,wasAutoCompleted:this._wasAutoCompleted,wasAutoSatisfied:this._wasAutoSatisfied,completedByMeasure:this._completedByMeasure,minProgressMeasure:this._minProgressMeasure,progressWeight:this._progressWeight,attemptCompletionAmountStatus:this._attemptCompletionAmountStatus,processedChildren:this._processedChildren?this._processedChildren.map(function(e){return e.id}):null,isNewAttempt:this._isNewAttempt,selectionCountStatus:this._sequencingControls.selectionCountStatus,reorderChildren:this._sequencingControls.reorderChildren,primaryObjective:this._primaryObjective?{id:this._primaryObjective.id,satisfiedStatus:this._primaryObjective.satisfiedStatus,measureStatus:this._primaryObjective.measureStatus,normalizedMeasure:this._primaryObjective.normalizedMeasure,progressMeasure:this._primaryObjective.progressMeasure,progressMeasureStatus:this._primaryObjective.progressMeasureStatus,completionStatus:this._primaryObjective.completionStatus,satisfiedByMeasure:this._primaryObjective.satisfiedByMeasure,minNormalizedMeasure:this._primaryObjective.minNormalizedMeasure,progressStatus:this._primaryObjective.progressStatus,mapInfo:this._primaryObjective.mapInfo}:null,objectives:this._objectives.map(function(e){return{id:e.id,satisfiedStatus:e.satisfiedStatus,measureStatus:e.measureStatus,normalizedMeasure:e.normalizedMeasure,progressMeasure:e.progressMeasure,progressMeasureStatus:e.progressMeasureStatus,completionStatus:e.completionStatus,satisfiedByMeasure:e.satisfiedByMeasure,minNormalizedMeasure:e.minNormalizedMeasure,progressStatus:e.progressStatus,mapInfo:e.mapInfo}}),children:this._children.map(function(e){return e.getSuspensionState()})}}},{key:"restoreSuspensionState",value:function(e){var t,i,n,r,o,s,a,u,l,c,d,f,v,h,m,p,y,g,_,b,S,w,C,O,E,A,k,j,R,M,T,P,I,x,N,D,q,L,z;if(e){if(this._isVisible=null!==(t=e.isVisible)&&void 0!==t?t:this._isVisible,this._isActive=null!==(i=e.isActive)&&void 0!==i?i:this._isActive,this._isSuspended=null!==(n=e.isSuspended)&&void 0!==n?n:this._isSuspended,this._isCompleted=null!==(r=e.isCompleted)&&void 0!==r?r:this._isCompleted,this._completionStatus=null!==(o=e.completionStatus)&&void 0!==o?o:this._completionStatus,this._successStatus=null!==(s=e.successStatus)&&void 0!==s?s:this._successStatus,this._attemptCount=null!==(a=e.attemptCount)&&void 0!==a?a:this._attemptCount,this._attemptCompletionAmount=null!==(u=e.attemptCompletionAmount)&&void 0!==u?u:this._attemptCompletionAmount,this._attemptAbsoluteDuration=null!==(l=e.attemptAbsoluteDuration)&&void 0!==l?l:this._attemptAbsoluteDuration,this._attemptExperiencedDuration=null!==(c=e.attemptExperiencedDuration)&&void 0!==c?c:this._attemptExperiencedDuration,this._activityAbsoluteDuration=null!==(d=e.activityAbsoluteDuration)&&void 0!==d?d:this._activityAbsoluteDuration,this._activityExperiencedDuration=null!==(f=e.activityExperiencedDuration)&&void 0!==f?f:this._activityExperiencedDuration,this._attemptAbsoluteDurationValue=null!==(v=e.attemptAbsoluteDurationValue)&&void 0!==v?v:this._attemptAbsoluteDurationValue,this._attemptExperiencedDurationValue=null!==(h=e.attemptExperiencedDurationValue)&&void 0!==h?h:this._attemptExperiencedDurationValue,this._activityAbsoluteDurationValue=null!==(m=e.activityAbsoluteDurationValue)&&void 0!==m?m:this._activityAbsoluteDurationValue,this._activityExperiencedDurationValue=null!==(p=e.activityExperiencedDurationValue)&&void 0!==p?p:this._activityExperiencedDurationValue,this._activityStartTimestampUtc=null!==(y=e.activityStartTimestampUtc)&&void 0!==y?y:this._activityStartTimestampUtc,this._attemptStartTimestampUtc=null!==(g=e.attemptStartTimestampUtc)&&void 0!==g?g:this._attemptStartTimestampUtc,this._objectiveSatisfiedStatus=null!==(_=e.objectiveSatisfiedStatus)&&void 0!==_?_:this._objectiveSatisfiedStatus,this._objectiveSatisfiedStatusKnown=null!==(b=e.objectiveSatisfiedStatusKnown)&&void 0!==b?b:this._objectiveSatisfiedStatusKnown,this._objectiveMeasureStatus=null!==(S=e.objectiveMeasureStatus)&&void 0!==S?S:this._objectiveMeasureStatus,this._objectiveNormalizedMeasure=null!==(w=e.objectiveNormalizedMeasure)&&void 0!==w?w:this._objectiveNormalizedMeasure,this._scaledPassingScore=null!==(C=e.scaledPassingScore)&&void 0!==C?C:this._scaledPassingScore,this._progressMeasure=null!==(O=e.progressMeasure)&&void 0!==O?O:this._progressMeasure,this._progressMeasureStatus=null!==(E=e.progressMeasureStatus)&&void 0!==E?E:this._progressMeasureStatus,this._location=null!==(A=e.location)&&void 0!==A?A:this._location,this._attemptAbsoluteStartTime=null!==(k=e.attemptAbsoluteStartTime)&&void 0!==k?k:this._attemptAbsoluteStartTime,this._activityAttemptActive=null!==(j=e.activityAttemptActive)&&void 0!==j?j:this._activityAttemptActive,this._isHiddenFromChoice=null!==(R=e.isHiddenFromChoice)&&void 0!==R?R:this._isHiddenFromChoice,this._isAvailable=null!==(M=e.isAvailable)&&void 0!==M?M:this._isAvailable,e.rollupConsiderations&&(this._rollupConsiderations=xn({},e.rollupConsiderations)),this._wasSkipped=null!==(T=e.wasSkipped)&&void 0!==T?T:this._wasSkipped,this._attemptProgressStatus=null!==(P=e.attemptProgressStatus)&&void 0!==P?P:this._attemptProgressStatus,this._wasAutoCompleted=null!==(I=e.wasAutoCompleted)&&void 0!==I?I:this._wasAutoCompleted,this._wasAutoSatisfied=null!==(x=e.wasAutoSatisfied)&&void 0!==x?x:this._wasAutoSatisfied,this._completedByMeasure=null!==(N=e.completedByMeasure)&&void 0!==N?N:this._completedByMeasure,this._minProgressMeasure=null!==(D=e.minProgressMeasure)&&void 0!==D?D:this._minProgressMeasure,this._progressWeight=null!==(q=e.progressWeight)&&void 0!==q?q:this._progressWeight,this._attemptCompletionAmountStatus=null!==(L=e.attemptCompletionAmountStatus)&&void 0!==L?L:this._attemptCompletionAmountStatus,this._isNewAttempt=null!==(z=e.isNewAttempt)&&void 0!==z?z:this._isNewAttempt,void 0!==e.selectionCountStatus&&(this._sequencingControls.selectionCountStatus=e.selectionCountStatus),void 0!==e.reorderChildren&&(this._sequencingControls.reorderChildren=e.reorderChildren),e.processedChildren){var F=new Map(this._children.map(function(e){return[e.id,e]}));this._processedChildren=e.processedChildren.map(function(id){return F.get(id)}).filter(function(e){return void 0!==e})}else this._processedChildren=null;var B,V,H,U,G,Y,W;if(e.primaryObjective&&this._primaryObjective&&(this._primaryObjective.satisfiedStatus=null!==(B=e.primaryObjective.satisfiedStatus)&&void 0!==B?B:this._primaryObjective.satisfiedStatus,this._primaryObjective.measureStatus=null!==(V=e.primaryObjective.measureStatus)&&void 0!==V?V:this._primaryObjective.measureStatus,this._primaryObjective.normalizedMeasure=null!==(H=e.primaryObjective.normalizedMeasure)&&void 0!==H?H:this._primaryObjective.normalizedMeasure,this._primaryObjective.progressMeasure=null!==(U=e.primaryObjective.progressMeasure)&&void 0!==U?U:this._primaryObjective.progressMeasure,this._primaryObjective.progressMeasureStatus=null!==(G=e.primaryObjective.progressMeasureStatus)&&void 0!==G?G:this._primaryObjective.progressMeasureStatus,this._primaryObjective.completionStatus=null!==(Y=e.primaryObjective.completionStatus)&&void 0!==Y?Y:this._primaryObjective.completionStatus,this._primaryObjective.progressStatus=null!==(W=e.primaryObjective.progressStatus)&&void 0!==W?W:this._primaryObjective.progressStatus),e.objectives){var J=!0,K=!1,$=void 0;try{for(var X,Q,Z=function(){var e,t,i,n,r,o,s,a=Q.value,u=X._objectives.find(function(e){return e.id===a.id});u&&(u.satisfiedStatus=null!==(e=a.satisfiedStatus)&&void 0!==e?e:u.satisfiedStatus,u.measureStatus=null!==(t=a.measureStatus)&&void 0!==t?t:u.measureStatus,u.normalizedMeasure=null!==(i=a.normalizedMeasure)&&void 0!==i?i:u.normalizedMeasure,u.progressMeasure=null!==(n=a.progressMeasure)&&void 0!==n?n:u.progressMeasure,u.progressMeasureStatus=null!==(r=a.progressMeasureStatus)&&void 0!==r?r:u.progressMeasureStatus,u.completionStatus=null!==(o=a.completionStatus)&&void 0!==o?o:u.completionStatus,u.progressStatus=null!==(s=a.progressStatus)&&void 0!==s?s:u.progressStatus)},ee=e.objectives[Symbol.iterator]();!(J=(Q=ee.next()).done);J=!0)X=this,Z()}catch(e){K=!0,$=e}finally{try{J||null==ee.return||ee.return()}finally{if(K)throw $}}}if(e.children&&Array.isArray(e.children))for(var te,ie=function(t){var i=e.children[t],n=te._children.find(function(e){return e.id===i.id});n&&n.restoreSuspensionState(i)},ne=0;e.children.length>ne&&this._children.length>ne;ne++)te=this,ie(ne)}}},{key:"toJSON",value:function(){this.jsonString=!0;var result={id:this._id,title:this._title,isVisible:this._isVisible,isActive:this._isActive,isSuspended:this._isSuspended,isCompleted:this._isCompleted,completionStatus:this._completionStatus,successStatus:this._successStatus,attemptCount:this._attemptCount,attemptCompletionAmount:this._attemptCompletionAmount,attemptAbsoluteDuration:this._attemptAbsoluteDuration,attemptExperiencedDuration:this._attemptExperiencedDuration,activityAbsoluteDuration:this._activityAbsoluteDuration,activityExperiencedDuration:this._activityExperiencedDuration,objectiveSatisfiedStatus:this._objectiveSatisfiedStatus,objectiveSatisfiedStatusKnown:this._objectiveSatisfiedStatusKnown,objectiveMeasureStatus:this._objectiveMeasureStatus,objectiveNormalizedMeasure:this._objectiveNormalizedMeasure,rollupConsiderations:xn({},this._rollupConsiderations),wasSkipped:this._wasSkipped,completedByMeasure:this._completedByMeasure,minProgressMeasure:this._minProgressMeasure,progressWeight:this._progressWeight,attemptCompletionAmountStatus:this._attemptCompletionAmountStatus,hideLmsUi:Dn(this._hideLmsUi),auxiliaryResources:this._auxiliaryResources.map(function(e){return xn({},e)}),children:this._children.map(function(e){return e.toJSON()})};return this.jsonString=!1,result}},{key:"auxiliaryResources",get:function(){return this._auxiliaryResources.map(function(e){return xn({},e)})},set:function(e){var t=[],i=new Set,n=!0,r=!1,o=void 0;try{for(var s,a=(e||[])[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value;if(u){var l="string"==typeof u.resourceId?u.resourceId.trim():"",c="string"==typeof u.purpose?u.purpose.trim():"";l&&!i.has(l)&&(i.add(l),t.push({resourceId:l,purpose:c}))}}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}this._auxiliaryResources=t}},{key:"addAuxiliaryResource",value:function(e){this.auxiliaryResources=Dn(this._auxiliaryResources).concat([e])}},{key:"captureRollupStatus",value:function(){return{measureStatus:this._objectiveMeasureStatus,normalizedMeasure:this._objectiveNormalizedMeasure,objectiveProgressStatus:null!=this._objectiveSatisfiedStatus,objectiveSatisfiedStatus:this._objectiveSatisfiedStatus,attemptProgressStatus:this._completionStatus!==Oe,attemptCompletionStatus:this._completionStatus===we}}},{key:"hideLmsUi",get:function(){return Dn(this._hideLmsUi)},set:function(e){var t=new Set(at),i=new Set,n=[],r=!0,o=!1,s=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var l=a.value;t.has(l)&&!i.has(l)&&(i.add(l),n.push(l))}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}this._hideLmsUi=n}}],[{key:"compareRollupStatus",value:function(e,t){return e.measureStatus===t.measureStatus&&1e-4>Math.abs(e.normalizedMeasure-t.normalizedMeasure)&&e.objectiveProgressStatus===t.objectiveProgressStatus&&e.objectiveSatisfiedStatus===t.objectiveSatisfiedStatus&&e.attemptProgressStatus===t.attemptProgressStatus&&e.attemptCompletionStatus===t.attemptCompletionStatus}}]),t}(C);var Hn=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return t=e,(i=[{key:"checkChildForRollupSubprocess",value:function(e,t,i){if(!1===e.sequencingControls.tracked)return!1;var n=!1;if("measure"===t||"objective"===t){if(!e.sequencingControls.rollupObjectiveSatisfied)return!1;n=!0;var r=e.requiredForSatisfied,o=e.requiredForNotSatisfied;"satisfied"===i&&"ifNotSuspended"===r||"notSatisfied"===i&&"ifNotSuspended"===o?(!e.attemptProgressStatus||e.attemptCount>0&&e.isSuspended)&&(n=!1):"satisfied"===i&&"ifAttempted"===r||"notSatisfied"===i&&"ifAttempted"===o?e.attemptProgressStatus&&0!==e.attemptCount||(n=!1):("satisfied"===i&&"ifNotSkipped"===r||"notSatisfied"===i&&"ifNotSkipped"===o)&&e.wasSkipped&&(n=!1)}if("progress"===t){if(!e.sequencingControls.rollupProgressCompletion)return!1;n=!0;var s=e.requiredForCompleted,a=e.requiredForIncomplete;"completed"===i&&"ifNotSuspended"===s||"incomplete"===i&&"ifNotSuspended"===a?(!e.attemptProgressStatus||e.attemptCount>0&&e.isSuspended)&&(n=!1):"completed"===i&&"ifAttempted"===s||"incomplete"===i&&"ifAttempted"===a?e.attemptProgressStatus&&0!==e.attemptCount||(n=!1):("completed"===i&&"ifNotSkipped"===s||"incomplete"===i&&"ifNotSkipped"===a)&&e.wasSkipped&&(n=!1)}return!(n&&!e.isAvailable)&&n}},{key:"filterChildrenForRequirement",value:function(e,t,mode,i){var n=this;return e.filter(function(e){return n.shouldIncludeChildForRollup(e,t,mode,i)})}},{key:"shouldIncludeChildForRollup",value:function(e,t,mode,i){return!(!this.checkChildForRollupSubprocess(e,t,mode)||"objective"===t&&!i.measureSatisfactionIfActive&&(e.activityAttemptActive||e.isActive))}},{key:"isChildSatisfiedForRollup",value:function(e){return!0===e.objectiveSatisfiedStatus||!1!==e.objectiveSatisfiedStatus&&e.successStatus===_e}},{key:"isChildCompletedForRollup",value:function(e){return!("completed"!==e.completionStatus&&!e.isCompleted)}},{key:"getTrackableChildren",value:function(e){return e.children.filter(function(e){return!1!==e.sequencingControls.tracked})}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var Un=Object.defineProperty,Gn=function(){function e(t){var i,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),function(e,t,i){t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(this,"symbol"!==function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(i="childFilter")?i+"":i,n),this.childFilter=t}return t=e,(i=[{key:"evaluateRollupRule",value:function(e,t){var i=e.getAvailableChildren(),n=0,r=0,o=!0,s=!1,a=void 0;try{for(var u,l=i[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c=u.value,d=!1;switch(t.action){case wn.SATISFIED:d=this.childFilter.checkChildForRollupSubprocess(c,"objective","satisfied");break;case wn.NOT_SATISFIED:d=this.childFilter.checkChildForRollupSubprocess(c,"objective","notSatisfied");break;case wn.COMPLETED:d=this.childFilter.checkChildForRollupSubprocess(c,"progress","completed");break;case wn.INCOMPLETE:d=this.childFilter.checkChildForRollupSubprocess(c,"progress","incomplete")}d&&(n++,this.evaluateRollupConditionsSubprocess(c,t)&&r++)}}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}return t.consideration===Cn.ALL?n>0&&r===n:null!==t.minimumCount?r>=t.minimumCount:null!==t.minimumPercent?(n>0?r/n:0)>=t.minimumPercent:n>0&&r===n}},{key:"evaluateRollupConditionsSubprocess",value:function(e,t){if(0===t.conditions.length)return!0;switch(t.consideration){case Cn.ALL:return t.conditions.every(function(t){return t.evaluate(e)});case Cn.ANY:return t.conditions.some(function(t){return t.evaluate(e)});case Cn.NONE:return!t.conditions.some(function(t){return t.evaluate(e)});case Cn.AT_LEAST_COUNT:case Cn.AT_LEAST_PERCENT:return t.conditions.every(function(t){return t.evaluate(e)});default:return!1}}},{key:"evaluateRulesForAction",value:function(e,t,i){var n=t.filter(function(e){return e.action===i});if(0===n.length)return null;var r=!0,o=!1,s=void 0;try{for(var a,u=n[Symbol.iterator]();!(r=(a=u.next()).done);r=!0)if(this.evaluateRollupRule(e,a.value))return!0}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}return!1}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var Yn=Object.defineProperty,Wn=function(e,t,i){return function(e,t,i){return t in e?Yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Jn=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Wn(this,"childFilter"),Wn(this,"eventCallback"),this.childFilter=t,this.eventCallback=i||null}return t=e,i=[{key:"measureRollupProcess",value:function(e){var t=this;if(!e.sequencingControls.rollupObjectiveSatisfied)return[];var i=e.getAvailableChildren();if(0===i.length)return[];var n=e.rollupConsiderations,r=i.filter(function(e){return!(!t.childFilter.checkChildForRollupSubprocess(e,"measure")||!e.objectiveMeasureStatus||null===e.objectiveNormalizedMeasure||!n.measureSatisfactionIfActive&&(e.activityAttemptActive||e.isActive))});if(0===r.length)return e.objectiveMeasureStatus=!1,[];var o=this.calculateComplexWeightedMeasure(e,r,{enableThresholdBias:!1});return e.objectiveNormalizedMeasure=o,e.objectiveMeasureStatus=!0,this.identifyActivityClusters(r)}},{key:"completionMeasureRollupProcess",value:function(e){var t=e.getAvailableChildren();if(0!==t.length){var i=t.filter(function(e){return e.attemptCompletionAmountStatus});if(0!==i.length){var n=0,r=0,o=!0,s=!1,a=void 0;try{for(var u,l=i[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c=u.value;n+=c.attemptCompletionAmount*c.progressWeight,r+=c.progressWeight}}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}r>0&&(e.attemptCompletionAmount=n/r,e.attemptCompletionAmountStatus=!0)}else e.attemptCompletionAmountStatus=!1}}},{key:"calculateComplexWeightedMeasure",value:function(e,t,i){var n,r,o=0,s=0,a=[],u=null===(n=null==i?void 0:i.enableThresholdBias)||void 0===n||n,l=!0,c=!1,d=void 0;try{for(var f,v=t[Symbol.iterator]();!(l=(f=v.next()).done);l=!0){var h=f.value;if(this.childFilter.checkChildForRollupSubprocess(h,"measure")&&h.objectiveMeasureStatus&&null!==h.objectiveNormalizedMeasure){var m=this.calculateAdjustedWeight(h,h.sequencingControls.objectiveMeasureWeight,u);o+=h.objectiveNormalizedMeasure*m,s+=m,a.push({childId:h.id,measure:h.objectiveNormalizedMeasure,weight:m})}}}catch(e){c=!0,d=e}finally{try{l||null==v.return||v.return()}finally{if(c)throw d}}return null===(r=this.eventCallback)||void 0===r||r.call(this,"complex_weighting_calculated",{activityId:e.id,weightingDetails:a,totalWeight:s,totalWeightedMeasure:o,result:s>0?o/s:0}),s>0?o/s:0}},{key:"calculateAdjustedWeight",value:function(e,t){var i,n=2>=arguments.length||void 0===arguments[2]||arguments[2],r=t;return"completed"!==e.completionStatus&&(r*=.8),e.attemptCount>1&&(r*=Math.max(.5,1-.1*(e.attemptCount-1))),e.hasAttemptLimitExceeded()&&(r*=.6),n&&e.objectiveMeasureStatus&&(r*=(null!==(i=e.scaledPassingScore)&&void 0!==i?i:.7)>e.objectiveNormalizedMeasure?.95:1.05),Math.max(0,r)}},{key:"identifyActivityClusters",value:function(e){var t=[],i=!0,n=!1,r=void 0;try{for(var o,s=e[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value;a.children.length>0&&a.sequencingControls.flow&&t.push(a)}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return t}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var Kn=Object.defineProperty,$n=function(e,t,i){return function(e,t,i){return t in e?Kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Xn=function(){function e(t,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),$n(this,"childFilter"),$n(this,"ruleEvaluator"),$n(this,"eventCallback"),this.childFilter=t,this.ruleEvaluator=i,this.eventCallback=n||null}return t=e,(i=[{key:"objectiveRollupProcess",value:function(e){var t=this.objectiveRollupUsingRules(e,e.rollupRules.rules);if(null!==t)return e.objectiveSatisfiedStatus=t,void this.syncPrimaryObjectiveFromActivity(e);var i=this.objectiveRollupUsingMeasure(e);if(null!==i)return e.objectiveSatisfiedStatus=i,void this.syncPrimaryObjectiveFromActivity(e);e.objectiveSatisfiedStatus=this.objectiveRollupUsingDefault(e),this.syncPrimaryObjectiveFromActivity(e)}},{key:"objectiveRollupUsingRules",value:function(e,t){var i=t.filter(function(e){return e.action===wn.SATISFIED}),n=t.filter(function(e){return e.action===wn.NOT_SATISFIED}),r=!0,o=!1,s=void 0;try{for(var a,u=i[Symbol.iterator]();!(r=(a=u.next()).done);r=!0)if(this.ruleEvaluator.evaluateRollupRule(e,a.value))return!0}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}var l=!0,c=!1,d=void 0;try{for(var f,v=n[Symbol.iterator]();!(l=(f=v.next()).done);l=!0)if(this.ruleEvaluator.evaluateRollupRule(e,f.value))return!1}catch(e){c=!0,d=e}finally{try{l||null==v.return||v.return()}finally{if(c)throw d}}return null}},{key:"objectiveRollupUsingMeasure",value:function(e){return e.objectiveMeasureStatus&&null!==e.scaledPassingScore?e.objectiveNormalizedMeasure>=e.scaledPassingScore:null}},{key:"objectiveRollupUsingDefault",value:function(e){var t=this,i=e.getAvailableChildren();if(0===i.length)return!1;var n=e.rollupConsiderations,r=i.filter(function(e){return!(!t.childFilter.checkChildForRollupSubprocess(e,"objective","satisfied")||!t.childFilter.checkChildForRollupSubprocess(e,"objective","notSatisfied")||!n.measureSatisfactionIfActive&&(e.activityAttemptActive||e.isActive))});return 0!==r.length&&!r.some(function(e){return!t.childFilter.isChildSatisfiedForRollup(e)})&&r.every(function(e){return t.childFilter.isChildSatisfiedForRollup(e)})}},{key:"syncPrimaryObjectiveFromActivity",value:function(e){e.primaryObjective&&(e.primaryObjective.satisfiedStatus=e.objectiveSatisfiedStatus,e.primaryObjective.satisfiedStatusKnown=e.objectiveSatisfiedStatusKnown,e.primaryObjective.measureStatus=e.objectiveMeasureStatus,e.primaryObjective.normalizedMeasure=e.objectiveNormalizedMeasure,e.primaryObjective.progressMeasure=e.progressMeasure,e.primaryObjective.progressMeasureStatus=e.progressMeasureStatus,e.primaryObjective.completionStatus=e.completionStatus)}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var Qn=Object.defineProperty,Zn=function(e,t,i){return function(e,t,i){return t in e?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},er=function(){function e(t,i,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Zn(this,"childFilter"),Zn(this,"ruleEvaluator"),Zn(this,"objectiveProcessor"),Zn(this,"eventCallback"),this.childFilter=t,this.ruleEvaluator=i,this.objectiveProcessor=n,this.eventCallback=r||null}return t=e,(i=[{key:"activityProgressRollupProcess",value:function(e){var t=this;if(!this.activityProgressRollupUsingMeasure(e)){var i=e.rollupRules,n=i.rules.filter(function(e){return e.action===wn.COMPLETED}),r=i.rules.filter(function(e){return e.action===wn.INCOMPLETE}),o=!0,s=!1,a=void 0;try{for(var u,l=n[Symbol.iterator]();!(o=(u=l.next()).done);o=!0)if(this.ruleEvaluator.evaluateRollupRule(e,u.value))return e.completionStatus=we,void this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e)}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}var c=!0,d=!1,f=void 0;try{for(var v,h=r[Symbol.iterator]();!(c=(v=h.next()).done);c=!0)if(this.ruleEvaluator.evaluateRollupRule(e,v.value))return e.completionStatus=Ce,void this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e)}catch(e){d=!0,f=e}finally{try{c||null==h.return||h.return()}finally{if(d)throw f}}var m=e.getAvailableChildren().filter(function(e){return t.childFilter.checkChildForRollupSubprocess(e,"progress","completed")&&t.childFilter.checkChildForRollupSubprocess(e,"progress","incomplete")});if(0===m.length)return e.completionStatus=Ce,void this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e);if(m.some(function(e){return!t.childFilter.isChildCompletedForRollup(e)}))return e.completionStatus=Ce,void this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e);e.completionStatus=we,this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e)}}},{key:"activityProgressRollupUsingMeasure",value:function(e){return!!e.completedByMeasure&&(e.attemptCompletionAmountStatus?(e.completionStatus=e.minProgressMeasure>e.attemptCompletionAmount?Ce:we,this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e),!0):(e.completionStatus=Oe,this.objectiveProcessor.syncPrimaryObjectiveFromActivity(e),!0))}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var tr=Object.defineProperty,ir=function(){function e(t){var i,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),function(e,t,i){t in e?tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(this,"symbol"!==function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(i="eventCallback")?i+"":i,n),this.eventCallback=t||null}return t=e,(i=[{key:"durationRollupProcess",value:function(e){if(0!==e.children.length){var t=e.getAvailableChildren();if(0!==t.length){var i=null,n=null,r=null,o=null,a=0,l=0,c=!0,d=!1,f=void 0;try{for(var v,h=t[Symbol.iterator]();!(c=(v=h.next()).done);c=!0){var m=v.value;m.activityStartTimestampUtc&&(i&&m.activityStartTimestampUtc>=i||(i=m.activityStartTimestampUtc)),m.activityEndedDate&&(r&&r>=m.activityEndedDate||(r=m.activityEndedDate));var p="PT0H0M0S"!==m.activityExperiencedDurationValue?m.activityExperiencedDurationValue:m.activityExperiencedDuration;if(p&&"PT0H0M0S"!==p&&(a+=u(p,Ve)),!e.attemptStartTimestampUtc||m.attemptStartTimestampUtc&&m.attemptStartTimestampUtc>=e.attemptStartTimestampUtc){m.attemptStartTimestampUtc&&(n&&m.attemptStartTimestampUtc>=n||(n=m.attemptStartTimestampUtc)),m.activityEndedDate&&(o&&o>=m.activityEndedDate||(o=m.activityEndedDate));var y="PT0H0M0S"!==m.attemptExperiencedDurationValue?m.attemptExperiencedDurationValue:m.attemptExperiencedDuration;y&&"PT0H0M0S"!==y&&(l+=u(y,Ve))}}}catch(e){d=!0,f=e}finally{try{c||null==h.return||h.return()}finally{if(d)throw f}}if(null!==i){var g;if(e.activityStartTimestampUtc=i,!e.attemptStartTimestampUtc&&n&&(e.attemptStartTimestampUtc=n),e.activityEndedDate=r,r&&e.activityStartTimestampUtc){var _=new Date(e.activityStartTimestampUtc),b=r.getTime()-_.getTime();e.activityAbsoluteDurationValue=s(Math.max(0,b/1e3))}if(o&&e.attemptStartTimestampUtc){var S=new Date(e.attemptStartTimestampUtc),w=o.getTime()-S.getTime();e.attemptAbsoluteDurationValue=s(Math.max(0,w/1e3))}e.activityExperiencedDurationValue=s(a),e.attemptExperiencedDurationValue=s(l),null===(g=this.eventCallback)||void 0===g||g.call(this,"duration_rollup_completed",{activityId:e.id,activityAbsoluteDuration:e.activityAbsoluteDurationValue,attemptAbsoluteDuration:e.attemptAbsoluteDurationValue,activityExperiencedDuration:e.activityExperiencedDurationValue,attemptExperiencedDuration:e.attemptExperiencedDurationValue,childCount:t.length})}}}}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var nr=Object.defineProperty,rr=function(e,t,i){return function(e,t,i){return t in e?nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},or=function(){function e(t,i,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),rr(this,"measureProcessor"),rr(this,"objectiveProcessor"),rr(this,"progressProcessor"),rr(this,"eventCallback"),rr(this,"processingClusters",new Set),this.measureProcessor=t,this.objectiveProcessor=i,this.progressProcessor=n,this.eventCallback=r||null}return t=e,i=[{key:"processCrossClusterDependencies",value:function(e,t){var i,n,r,o,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(10>s)if(this.processingClusters.has(e.id))null===(i=this.eventCallback)||void 0===i||i.call(this,"cross_cluster_skip_reentrant",{activityId:e.id});else try{var a,u;this.processingClusters.add(e.id),null===(a=this.eventCallback)||void 0===a||a.call(this,"cross_cluster_processing_started",{activityId:e.id,clusterCount:t.length,depth:s});var l=new Map,c=!0,d=!1,f=void 0;try{for(var v,h=t[Symbol.iterator]();!(c=(v=h.next()).done);c=!0)this.analyzeCrossClusterDependencies(v.value,l)}catch(e){d=!0,f=e}finally{try{c||null==h.return||h.return()}finally{if(d)throw f}}var m=this.resolveDependencyOrder(l),p=!0,y=!1,g=void 0;try{for(var _,b,S=function(){var e=b.value,i=t.find(function(t){return t.id===e});i&&_.processClusterRollup(i,s)},w=m[Symbol.iterator]();!(p=(b=w.next()).done);p=!0)_=this,S()}catch(e){y=!0,g=e}finally{try{p||null==w.return||w.return()}finally{if(y)throw g}}null===(u=this.eventCallback)||void 0===u||u.call(this,"cross_cluster_processing_completed",{activityId:e.id,processedClusters:m.length,dependencyMap:Array.from(l.entries())})}catch(t){var C;null===(C=this.eventCallback)||void 0===C||C.call(this,"cross_cluster_processing_error",{activityId:e.id,error:(n=t,r=Error,(null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?r[Symbol.hasInstance](n):n instanceof r)?t.message:t+"")})}finally{this.processingClusters.delete(e.id)}else null===(o=this.eventCallback)||void 0===o||o.call(this,"cross_cluster_max_depth_reached",{activityId:e.id,depth:s,maxDepth:10})}},{key:"identifyActivityClusters",value:function(e){var t=[],i=!0,n=!1,r=void 0;try{for(var o,s=e[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value;a.children.length>0&&a.sequencingControls.flow&&t.push(a)}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return t}},{key:"analyzeCrossClusterDependencies",value:function(e,t){t.set(e.id,[])}},{key:"resolveDependencyOrder",value:function(e){var t=this,i=[],n=new Set,r=function(id){if(!i.includes(id))if(n.has(id)){var o,s;null===(o=(s=t).eventCallback)||void 0===o||o.call(s,"circular_dependency_detected",{activityId:id})}else{n.add(id);var a=e.get(id)||[],u=!0,l=!1,c=void 0;try{for(var d,f=a[Symbol.iterator]();!(u=(d=f.next()).done);u=!0)r(d.value)}catch(e){l=!0,c=e}finally{try{u||null==f.return||f.return()}finally{if(l)throw c}}n.delete(id),i.push(id)}},o=!0,s=!1,a=void 0;try{for(var u,l=Array.from(e.keys())[Symbol.iterator]();!(o=(u=l.next()).done);o=!0)r(u.value)}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}return i}},{key:"processClusterRollup",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=this.measureProcessor.measureRollupProcess(e);e.sequencingControls.rollupObjectiveSatisfied&&this.objectiveProcessor.objectiveRollupProcess(e),e.sequencingControls.rollupProgressCompletion&&this.progressProcessor.activityProgressRollupProcess(e),i.length>1&&this.processCrossClusterDependencies(e,i,t+1)}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function sr(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}var ar=Object.defineProperty,ur=function(){function e(t){var i,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),function(e,t,i){t in e?ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(this,"symbol"!==function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(i="eventCallback")?i+"":i,n),this.eventCallback=t||null}return t=e,(i=[{key:"processGlobalObjectiveMapping",value:function(e,t){try{var i,n;null===(i=this.eventCallback)||void 0===i||i.call(this,"global_objective_processing_started",{activityId:e.id,globalObjectiveCount:t.size});var r=[];this.collectActivitiesRecursive(e,r);var o=!0,s=!1,a=void 0;try{for(var u,l=r[Symbol.iterator]();!(o=(u=l.next()).done);o=!0)this.syncGlobalObjectivesWritePhase(u.value,t)}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}var c=!0,d=!1,f=void 0;try{for(var v,h=r[Symbol.iterator]();!(c=(v=h.next()).done);c=!0)this.syncGlobalObjectivesReadPhase(v.value,t)}catch(e){d=!0,f=e}finally{try{c||null==h.return||h.return()}finally{if(d)throw f}}null===(n=this.eventCallback)||void 0===n||n.call(this,"global_objective_processing_completed",{activityId:e.id,processedObjectives:t.size})}catch(t){var m;null===(m=this.eventCallback)||void 0===m||m.call(this,"global_objective_processing_error",{activityId:e.id,error:sr(t,Error)?t.message:t+""})}}},{key:"collectActivitiesRecursive",value:function(e,result){result.push(e);var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)this.collectActivitiesRecursive(r.value,result)}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}}},{key:"syncGlobalObjectivesWritePhase",value:function(e,t){var objectives=e.getAllObjectives(),i=!0,n=!1,r=void 0;try{for(var o,s=objectives[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value,u=a.mapInfo.length>0?a.mapInfo:[this.createDefaultMapInfo(a)],l=!0,c=!1,d=void 0;try{for(var f,v=u[Symbol.iterator]();!(l=(f=v.next()).done);l=!0){var h=f.value,m=this.ensureGlobalObjectiveEntry(t,h.targetObjectiveID||a.id,a);if(h.writeSatisfiedStatus&&a.measureStatus&&a.isDirty("satisfiedStatus")&&(m.satisfiedStatus=a.satisfiedStatus,m.satisfiedStatusKnown=!0,a.clearDirty("satisfiedStatus")),h.writeNormalizedMeasure&&a.measureStatus&&a.isDirty("normalizedMeasure")&&(m.normalizedMeasure=a.normalizedMeasure,m.normalizedMeasureKnown=!0,a.clearDirty("normalizedMeasure"),m.satisfiedByMeasure||a.satisfiedByMeasure)){var p,y,g=null!==(p=null!==(y=a.minNormalizedMeasure)&&void 0!==y?y:e.scaledPassingScore)&&void 0!==p?p:.7;m.satisfiedStatus=a.normalizedMeasure>=g,m.satisfiedStatusKnown=!0,a.clearDirty("satisfiedStatus")}h.writeCompletionStatus&&a.completionStatus!==Oe&&a.isDirty("completionStatus")&&(m.completionStatus=a.completionStatus,m.completionStatusKnown=!0,a.clearDirty("completionStatus")),h.writeProgressMeasure&&a.progressMeasureStatus&&a.isDirty("progressMeasure")&&(m.progressMeasure=a.progressMeasure,m.progressMeasureKnown=!0,a.clearDirty("progressMeasure")),h.updateAttemptData&&this.updateActivityAttemptData(e,m,a)}}catch(e){c=!0,d=e}finally{try{l||null==v.return||v.return()}finally{if(c)throw d}}}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}},{key:"syncGlobalObjectivesReadPhase",value:function(e,t){var objectives=e.getAllObjectives(),i=!0,n=!1,r=void 0;try{for(var o,s=objectives[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value,u=a.mapInfo.length>0?a.mapInfo:[this.createDefaultMapInfo(a)],l=!0,c=!1,d=void 0;try{for(var f,v=u[Symbol.iterator]();!(l=(f=v.next()).done);l=!0){var h,m=f.value,p=t.get(m.targetObjectiveID||a.id);if(p){var y=a.isPrimary;if(m.readSatisfiedStatus&&p.satisfiedStatusKnown&&(a.satisfiedStatus=p.satisfiedStatus,a.measureStatus=!0),m.readNormalizedMeasure&&p.normalizedMeasureKnown&&(a.normalizedMeasure=p.normalizedMeasure,a.measureStatus=!0,p.satisfiedByMeasure||a.satisfiedByMeasure)){var g,_,b=null!==(g=null!==(_=a.minNormalizedMeasure)&&void 0!==_?_:e.scaledPassingScore)&&void 0!==g?g:.7;a.satisfiedStatus=p.normalizedMeasure>=b}m.readProgressMeasure&&p.progressMeasureKnown&&(a.progressMeasure=p.progressMeasure,a.progressMeasureStatus=!0),m.readCompletionStatus&&p.completionStatusKnown&&(a.completionStatus=p.completionStatus),y&&a.applyToActivity(e),null===(h=this.eventCallback)||void 0===h||h.call(this,"objective_synchronized",{activityId:e.id,objectiveId:a.id,globalState:p,synchronizationTime:(new Date).toISOString()})}}}catch(e){c=!0,d=e}finally{try{l||null==v.return||v.return()}finally{if(c)throw d}}}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}},{key:"synchronizeGlobalObjectives",value:function(e,t){var objectives=e.getAllObjectives(),i=!0,n=!1,r=void 0;try{for(var o,s=objectives[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value,u=a.mapInfo.length>0?a.mapInfo:[this.createDefaultMapInfo(a)],l=!0,c=!1,d=void 0;try{for(var f,v=u[Symbol.iterator]();!(l=(f=v.next()).done);l=!0){var h=f.value,m=this.ensureGlobalObjectiveEntry(t,h.targetObjectiveID||a.id,a);this.syncObjectiveState(e,a,h,m)}}catch(e){c=!0,d=e}finally{try{l||null==v.return||v.return()}finally{if(c)throw d}}}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}},{key:"syncObjectiveState",value:function(e,t,i,n){try{var r,o=this.getLocalObjectiveState(e,t,t.isPrimary);if(i.readSatisfiedStatus&&n.satisfiedStatusKnown&&(t.satisfiedStatus=n.satisfiedStatus,t.measureStatus=!0),i.readNormalizedMeasure&&n.normalizedMeasureKnown&&(t.normalizedMeasure=n.normalizedMeasure,t.measureStatus=!0,n.satisfiedByMeasure||t.satisfiedByMeasure)){var s,a,u=null!==(s=null!==(a=t.minNormalizedMeasure)&&void 0!==a?a:e.scaledPassingScore)&&void 0!==s?s:.7;t.satisfiedStatus=n.normalizedMeasure>=u}if(i.readProgressMeasure&&n.progressMeasureKnown&&(t.progressMeasure=n.progressMeasure,t.progressMeasureStatus=!0),i.readCompletionStatus&&n.completionStatusKnown&&(t.completionStatus=n.completionStatus),t.isPrimary&&t.applyToActivity(e),i.writeSatisfiedStatus&&t.measureStatus&&(n.satisfiedStatus=t.satisfiedStatus,n.satisfiedStatusKnown=!0),i.writeNormalizedMeasure&&t.measureStatus&&(n.normalizedMeasure=t.normalizedMeasure,n.normalizedMeasureKnown=!0,n.satisfiedByMeasure||t.satisfiedByMeasure)){var l,c,d=null!==(l=null!==(c=t.minNormalizedMeasure)&&void 0!==c?c:e.scaledPassingScore)&&void 0!==l?l:.7;n.satisfiedStatus=t.normalizedMeasure>=d,n.satisfiedStatusKnown=!0}i.writeCompletionStatus&&t.completionStatus!==Oe&&(n.completionStatus=t.completionStatus,n.completionStatusKnown=!0),i.writeProgressMeasure&&t.progressMeasureStatus&&(n.progressMeasure=t.progressMeasure,n.progressMeasureKnown=!0),i.updateAttemptData&&this.updateActivityAttemptData(e,n,t),null===(r=this.eventCallback)||void 0===r||r.call(this,"objective_synchronized",{activityId:e.id,objectiveId:t.id,localState:o,globalState:n,synchronizationTime:(new Date).toISOString()})}catch(i){var f;null===(f=this.eventCallback)||void 0===f||f.call(this,"objective_sync_error",{activityId:e.id,objectiveId:t.id,error:sr(i,Error)?i.message:i+"",timestamp:(new Date).toISOString()})}}},{key:"ensureGlobalObjectiveEntry",value:function(e,t,i){return e.has(t)||e.set(t,{id:t,satisfiedStatus:i.satisfiedStatus,satisfiedStatusKnown:i.satisfiedStatusKnown,normalizedMeasure:i.normalizedMeasure,normalizedMeasureKnown:i.measureStatus,progressMeasure:i.progressMeasure,progressMeasureKnown:i.progressMeasureStatus,completionStatus:i.completionStatus,completionStatusKnown:i.completionStatus!==Oe,satisfiedByMeasure:i.satisfiedByMeasure,minNormalizedMeasure:i.minNormalizedMeasure}),e.get(t)}},{key:"createDefaultMapInfo",value:function(e){return{targetObjectiveID:e.id,readSatisfiedStatus:!1,writeSatisfiedStatus:!0,readNormalizedMeasure:!1,writeNormalizedMeasure:!0,readCompletionStatus:!1,writeCompletionStatus:!0,readProgressMeasure:!1,writeProgressMeasure:!0,updateAttemptData:e.isPrimary}}},{key:"getLocalObjectiveState",value:function(e,t,i){return i?{id:t.id,satisfiedStatus:e.objectiveSatisfiedStatus,measureStatus:e.objectiveMeasureStatus,normalizedMeasure:e.objectiveNormalizedMeasure,progressMeasure:e.progressMeasure,progressMeasureStatus:e.progressMeasureStatus,completionStatus:e.completionStatus,scaledPassingScore:e.scaledPassingScore}:{id:t.id,satisfiedStatus:t.satisfiedStatus,measureStatus:t.measureStatus,normalizedMeasure:t.normalizedMeasure,progressMeasure:t.progressMeasure,progressMeasureStatus:t.progressMeasureStatus,completionStatus:t.completionStatus,scaledPassingScore:t.minNormalizedMeasure}}},{key:"updateActivityAttemptData",value:function(e,t,i){try{if(!i.isPrimary&&!t.updateAttemptData)return;var n=e.rollupRules.rules.some(function(e){return"completed"===e.action||"incomplete"===e.action});t.satisfiedStatusKnown&&t.satisfiedStatus&&(n||e.completionStatus!==Oe&&e.completionStatus!==Ce||(e.completionStatus=we),"unknown"===e.successStatus&&(e.successStatus="passed")),t.attemptCount&&t.attemptCount>e.attemptCount&&(e.attemptCount=t.attemptCount),t.progressMeasureKnown&&void 0!==t.progressMeasure&&(e.attemptCompletionAmount=t.progressMeasure),t.attemptAbsoluteDuration&&(e.attemptAbsoluteDuration=t.attemptAbsoluteDuration),t.attemptExperiencedDuration&&(e.attemptExperiencedDuration=t.attemptExperiencedDuration),t.activityAbsoluteDuration&&(e.activityAbsoluteDuration=t.activityAbsoluteDuration),t.activityExperiencedDuration&&(e.activityExperiencedDuration=t.activityExperiencedDuration),void 0!==t.location&&(e.location=t.location),void 0!==t.suspendData&&(e.isSuspended=t.suspendData.length>0)}catch(t){var r;null===(r=this.eventCallback)||void 0===r||r.call(this,"attempt_data_update_error",{activityId:e.id,error:sr(t,Error)?t.message:t+"",timestamp:(new Date).toISOString()})}}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function lr(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}var cr=Object.defineProperty,dr=function(e,t,i){return function(e,t,i){return t in e?cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},fr=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),dr(this,"rollupStateLog",[]),dr(this,"childFilter"),dr(this,"eventCallback"),this.childFilter=t,this.eventCallback=i||null}return t=e,(i=[{key:"validateRollupStateConsistency",value:function(e){try{var t,i;null===(t=this.eventCallback)||void 0===t||t.call(this,"rollup_validation_started",{activityId:e.id,timestamp:(new Date).toISOString()});var n,r=[];return this.validateActivityRollupState(e,r),r.length>0?(null===(n=this.eventCallback)||void 0===n||n.call(this,"rollup_state_inconsistencies",{activityId:e.id,inconsistencies:r,count:r.length}),!1):(null===(i=this.eventCallback)||void 0===i||i.call(this,"rollup_validation_completed",{activityId:e.id,result:"consistent"}),!0)}catch(t){var o;return null===(o=this.eventCallback)||void 0===o||o.call(this,"rollup_validation_error",{activityId:e.id,error:(s=t,a=Error,(null!=a&&"undefined"!=typeof Symbol&&a[Symbol.hasInstance]?a[Symbol.hasInstance](s):s instanceof a)?t.message:t+"")}),!1}var s,a}},{key:"validateActivityRollupState",value:function(e,t){var i=this,n=e.id;e.objectiveMeasureStatus&&null===e.objectiveNormalizedMeasure&&t.push("Activity ".concat(n,": measure status true but normalized measure is null")),e.objectiveMeasureStatus&&null!==e.scaledPassingScore&&"unknown"!==e.successStatus&&e.objectiveSatisfiedStatus!==e.objectiveNormalizedMeasure>=e.scaledPassingScore&&t.push("Activity ".concat(n,": satisfaction status inconsistent with measure"));var r=e.sequencingControls,o=e.getAvailableChildren();if(o.length>0&&r.rollupObjectiveSatisfied){var s=o.filter(function(e){return i.childFilter.checkChildForRollupSubprocess(e,"objective","satisfied")&&i.childFilter.isChildSatisfiedForRollup(e)}),a=o.filter(function(e){return i.childFilter.checkChildForRollupSubprocess(e,"objective","notSatisfied")&&!i.childFilter.isChildSatisfiedForRollup(e)});s.length>0&&0===a.length&&!1===e.objectiveSatisfiedStatus&&0===e.rollupRules.rules.length&&t.push("Activity ".concat(n,": all children satisfied but parent is not satisfied (no rollup rules to override)"))}if(o.length>0&&r.rollupProgressCompletion){var u=o.filter(function(e){return i.childFilter.checkChildForRollupSubprocess(e,"progress","completed")&&i.childFilter.isChildCompletedForRollup(e)}),l=o.filter(function(e){return i.childFilter.checkChildForRollupSubprocess(e,"progress","incomplete")&&!i.childFilter.isChildCompletedForRollup(e)});u.length>0&&0===l.length&&"completed"!==e.completionStatus&&0===e.rollupRules.rules.length&&t.push("Activity ".concat(n,": all children completed but parent is incomplete (no rollup rules to override)"))}var c=!0,d=!1,f=void 0;try{for(var v,h=o[Symbol.iterator]();!(c=(v=h.next()).done);c=!0)this.validateActivityRollupState(v.value,t)}catch(e){d=!0,f=e}finally{try{c||null==h.return||h.return()}finally{if(d)throw f}}this.rollupStateLog.push({activity:n,timestamp:(new Date).toISOString(),state:{measureStatus:e.objectiveMeasureStatus,measure:e.objectiveNormalizedMeasure,satisfiedStatus:e.objectiveSatisfiedStatus,completionStatus:e.completionStatus}})}},{key:"getRollupStateLog",value:function(){return function(e){if(Array.isArray(e))return lr(e)}(e=this.rollupStateLog)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return lr(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?lr(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var e}},{key:"clearRollupStateLog",value:function(){this.rollupStateLog=[]}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var vr=Object.defineProperty,hr=function(e,t,i){return function(e,t,i){return t in e?vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},mr=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),hr(this,"childFilter"),hr(this,"ruleEvaluator"),hr(this,"measureProcessor"),hr(this,"objectiveProcessor"),hr(this,"progressProcessor"),hr(this,"durationProcessor"),hr(this,"globalObjectiveSynchronizer"),hr(this,"stateValidator"),hr(this,"crossClusterProcessor"),hr(this,"eventCallback"),this.eventCallback=t||null,this.childFilter=new Hn,this.ruleEvaluator=new Gn(this.childFilter),this.measureProcessor=new Jn(this.childFilter,t),this.objectiveProcessor=new Xn(this.childFilter,this.ruleEvaluator,t),this.progressProcessor=new er(this.childFilter,this.ruleEvaluator,this.objectiveProcessor,t),this.durationProcessor=new ir(t),this.globalObjectiveSynchronizer=new ur(t),this.stateValidator=new fr(this.childFilter,t),this.crossClusterProcessor=new or(this.measureProcessor,this.objectiveProcessor,this.progressProcessor,t)}return t=e,(i=[{key:"overallRollupProcess",value:function(e){for(var t=[],i=e.parent,n=!1,r=!0;i;){if(i.children.length>0&&this.durationProcessor.durationRollupProcess(i),!n){var o=i.captureRollupStatus();if(i.sequencingControls.rollupObjectiveSatisfied||i.sequencingControls.rollupProgressCompletion){if(i.children.length>0){var s=this.measureProcessor.measureRollupProcess(i);this.measureProcessor.completionMeasureRollupProcess(i),s.length>1&&this.crossClusterProcessor.processCrossClusterDependencies(i,s)}i.sequencingControls.rollupObjectiveSatisfied&&this.objectiveProcessor.objectiveRollupProcess(i),i.sequencingControls.rollupProgressCompletion&&this.progressProcessor.activityProgressRollupProcess(i)}var a,u=i.captureRollupStatus();r||Vn.compareRollupStatus(o,u)&&(null===(a=this.eventCallback)||void 0===a||a.call(this,"rollup_optimization_activated",{activityId:i.id,depth:t.length}),n=!0),!r&&Vn.compareRollupStatus(o,u)||t.push(i)}i=i.parent,r=!1}return t}},{key:"validateRollupStateConsistency",value:function(e){return this.stateValidator.validateRollupStateConsistency(e)}},{key:"processGlobalObjectiveMapping",value:function(e,t){this.globalObjectiveSynchronizer.processGlobalObjectiveMapping(e,t)}},{key:"calculateComplexWeightedMeasure",value:function(e,t,i){return this.measureProcessor.calculateComplexWeightedMeasure(e,t,i)}},{key:"processCrossClusterDependencies",value:function(e,t){this.crossClusterProcessor.processCrossClusterDependencies(e,t)}},{key:"getChildFilter",value:function(){return this.childFilter}},{key:"getRuleEvaluator",value:function(){return this.ruleEvaluator}},{key:"getMeasureProcessor",value:function(){return this.measureProcessor}},{key:"getObjectiveProcessor",value:function(){return this.objectiveProcessor}},{key:"getProgressProcessor",value:function(){return this.progressProcessor}},{key:"getDurationProcessor",value:function(){return this.durationProcessor}},{key:"getGlobalObjectiveSynchronizer",value:function(){return this.globalObjectiveSynchronizer}},{key:"getStateValidator",value:function(){return this.stateValidator}},{key:"getCrossClusterProcessor",value:function(){return this.crossClusterProcessor}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var pr=Object.defineProperty,yr=[we,Ce,Oe],gr=[_e,be,Se];function _r(e){return e&&yr.includes(e)?e:null}function br(e){return e&&gr.includes(e)?e:null}var Sr=function(){function e(t){var i,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),function(e,t,i){t in e?pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(this,"symbol"!==function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(i="context")?i+"":i,n),this.context=t}return t=e,(i=[{key:"transferRteData",value:function(e){if(this.context.getCMIData){var t=this.context.getCMIData();t&&(this.transferPrimaryObjective(e,t),this.transferNonPrimaryObjectives(e,t),this.context.fireEvent("onRteDataTransfer",{activityId:e.id,timestamp:(new Date).toISOString()}))}}},{key:"transferPrimaryObjective",value:function(e,t){var i=_r(t.completion_status);i&&i!==Oe&&(e.completionStatus=i,e.attemptProgressStatus=!0);var n=!1,r=!1,o=!1,s=0,a=br(t.success_status);if(a&&a!==Se&&(n=!0,e.objectiveSatisfiedStatus=r=a===_e,e.objectiveSatisfiedStatusKnown=!0,e.successStatus=a,e.objectiveMeasureStatus=!0),t.score){var u=this.normalizeScore(t.score);null!==u&&(o=!0,e.objectiveNormalizedMeasure=s=u,e.objectiveMeasureStatus=!0)}if(e.primaryObjective&&(n||o)&&(e.primaryObjective.initializeFromCMI(n?r:e.primaryObjective.satisfiedStatus,o?s:e.primaryObjective.normalizedMeasure,n||o),n&&(e.primaryObjective.satisfiedStatusKnown=!0,e.primaryObjective.progressStatus=!0)),t.progress_measure&&""!==t.progress_measure){var l=parseFloat(t.progress_measure);isNaN(l)||(e.progressMeasure=l,e.progressMeasureStatus=!0,e.primaryObjective&&(e.primaryObjective.progressMeasure=l,e.primaryObjective.progressMeasureStatus=!0))}}},{key:"transferNonPrimaryObjectives",value:function(e,t){if(t.objectives&&0!==t.objectives.length){var i=!0,n=!1,r=void 0;try{for(var o,s=t.objectives[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value;if(a.id){var u=e.getObjectiveById(a.id);if(u&&!u.isPrimary){var l=u.objective,c=!1,d=!1,f=!1,v=0,h=br(a.success_status);h&&h!==Se&&(d=h===_e,c=!0,l.progressStatus=!0);var m=_r(a.completion_status);if(m&&m!==Oe&&(l.completionStatus=m),a.score){var p=this.normalizeScore(a.score);null!==p&&(v=p,f=!0)}if((c||f)&&l.initializeFromCMI(c?d:l.satisfiedStatus,f?v:l.normalizedMeasure,f),a.progress_measure&&""!==a.progress_measure){var y=parseFloat(a.progress_measure);isNaN(y)||(l.progressMeasure=y,l.progressMeasureStatus=!0)}}}}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}}},{key:"normalizeScore",value:function(score){if(score.scaled&&""!==score.scaled){var e=parseFloat(score.scaled);if(!isNaN(e))return e}if(score.raw&&""!==score.raw&&score.min&&""!==score.min&&score.max&&""!==score.max){var t=parseFloat(score.raw),i=parseFloat(score.min),n=parseFloat(score.max);if(!isNaN(t)&&!isNaN(i)&&!isNaN(n)&&n>i)return Math.max(-1,Math.min(1,(t-i)/(n-i)))}return null}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var wr=Object.defineProperty,Cr=function(e,t,i){return function(e,t,i){return t in e?wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Or=function(){function e(t,i,n,r){var o=this,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5?arguments[5]:void 0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Cr(this,"activityTree"),Cr(this,"sequencingProcess"),Cr(this,"rollupProcess"),Cr(this,"globalObjectiveMap"),Cr(this,"eventCallback"),Cr(this,"getCMIData"),Cr(this,"is4thEdition"),Cr(this,"invalidateCacheCallback",null),Cr(this,"_rteDataTransferService"),this.activityTree=t,this.sequencingProcess=i,this.rollupProcess=n,this.globalObjectiveMap=r,this.eventCallback=s,this.getCMIData=(null==a?void 0:a.getCMIData)||null,this.is4thEdition=(null==a?void 0:a.is4thEdition)||!1,this._rteDataTransferService=new Sr({getCMIData:this.getCMIData,fireEvent:function(e,t){return o.fireEvent(e,t)}})}return t=e,i=[{key:"setInvalidateCacheCallback",value:function(e){this.invalidateCacheCallback=e}},{key:"processTerminationRequest",value:function(request){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=arguments.length>2?arguments[2]:void 0,i=this.activityTree.currentActivity;if(!i)return{terminationRequest:request,sequencingRequest:null,exception:"TB.2.3-1",valid:!1};if((request===xt.EXIT||request===xt.ABANDON)&&!i.isActive)return{terminationRequest:request,sequencingRequest:null,exception:"TB.2.3-2",valid:!1};if(this.fireEvent("onTerminationRequestProcessing",{request:request,hasSequencingRequest:e,currentActivity:i.id,exitType:t}),"logout"===t)return this.fireEvent("onSequencingDebug",{message:"cmi.exit='logout' detected, treating as EXIT_ALL",activityId:i.id}),this.handleExitAll(i);switch(request){case xt.EXIT:return this.handleExit(i,e);case xt.EXIT_ALL:return this.handleExitAll(i);case xt.ABANDON:return this.handleAbandon(i,e);case xt.ABANDON_ALL:return this.handleAbandonAll(i);case xt.SUSPEND_ALL:return this.handleSuspendAll(i);default:return{terminationRequest:request,sequencingRequest:null,exception:"TB.2.3-7",valid:!1}}}},{key:"handleExitTermination",value:function(e,t){return this.handleExit(e,t)}},{key:"handleExit",value:function(e,t){e.children.length>0&&this.terminateDescendants(e),this.endAttempt(e);var i,n,r=this.evaluateExitRules(e);if("EXIT_ALL"===r.action)return this.handleExitAll(e);"EXIT_PARENT"===r.action&&e.parent&&(this.activityTree.currentActivity=e.parent,this.endAttempt(this.activityTree.currentActivity));do{if(i=!1,(n=this.evaluatePostConditions(this.activityTree.currentActivity||e)).terminationRequest===xt.EXIT_ALL)return this.fireEvent("onPostConditionExitAll",{activity:(this.activityTree.currentActivity||e).id}),this.handleExitAll(this.activityTree.root);if(n.terminationRequest===xt.EXIT_PARENT){var o=this.activityTree.currentActivity||e;if(!o.parent)return{terminationRequest:xt.EXIT_PARENT,sequencingRequest:null,exception:"TB.2.3-4",valid:!1};this.activityTree.currentActivity=o.parent,this.endAttempt(this.activityTree.currentActivity),i=!0,this.fireEvent("onPostConditionExitParent",{fromActivity:o.id,toActivity:this.activityTree.currentActivity.id})}if(!i&&(this.activityTree.currentActivity||e)===this.activityTree.root&&n.sequencingRequest!==xt.RETRY)return{terminationRequest:xt.EXIT,sequencingRequest:xt.EXIT,exception:null,valid:!0}}while(i);if(!t&&!n.sequencingRequest){var s=this.activityTree.currentActivity||e;s.parent&&this.activityTree.setCurrentActivityWithoutActivation(s.parent)}return{terminationRequest:xt.EXIT,sequencingRequest:n.sequencingRequest,exception:null,valid:!0}}},{key:"handleExitAll",value:function(e){return this.activityTree.root&&this.handleMultiLevelExit(this.activityTree.root),this.activityTree.root&&this.endAttempt(this.activityTree.root),this.activityTree.currentActivity=null,this.cleanupSuspendedActivity(),{terminationRequest:xt.EXIT_ALL,sequencingRequest:xt.EXIT,exception:null,valid:!0}}},{key:"handleAbandon",value:function(e,t){return e.isActive=!1,t||(this.activityTree.currentActivity=e.parent),{terminationRequest:xt.ABANDON,sequencingRequest:null,exception:null,valid:!0}}},{key:"handleAbandonAll",value:function(e){for(var t=[],i=e;null!==i;)t.push(i),i=i.parent;if(0===t.length)return{terminationRequest:xt.ABANDON_ALL,sequencingRequest:null,exception:"TB.2.3-6",valid:!1};var n=!0,r=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0)s.value.isActive=!1}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return this.activityTree.currentActivity=null,this.cleanupSuspendedActivity(),{terminationRequest:xt.ABANDON_ALL,sequencingRequest:null,exception:null,valid:!0}}},{key:"handleSuspendAll",value:function(e){var t=this.processSuspendAllRequest(e);return t.valid?{terminationRequest:xt.SUSPEND_ALL,sequencingRequest:xt.EXIT,exception:null,valid:!0}:t}},{key:"processSuspendAllRequest",value:function(e){var t=this.activityTree.root;if(!e||!t)return this.fireEvent("onSuspendError",{exception:"TB.2.3-1",message:"No current activity to suspend",activity:null==e?void 0:e.id}),{terminationRequest:xt.SUSPEND_ALL,sequencingRequest:null,exception:"TB.2.3-1",valid:!1};if(e===t&&!e.isActive&&!e.isSuspended)return this.fireEvent("onSuspendError",{exception:"TB.2.3-3",message:"Nothing to suspend (root activity)",activity:e.id}),{terminationRequest:xt.SUSPEND_ALL,sequencingRequest:null,exception:"TB.2.3-3",valid:!1};this.activityTree.suspendedActivity=e;for(var i=e,n=[],r=i;null!==r;)n.push(r),r=r.parent;if(0===n.length)return this.fireEvent("onSuspendError",{exception:"TB.2.3-5",message:"Activity path is empty",activity:null==i?void 0:i.id}),{terminationRequest:xt.SUSPEND_ALL,sequencingRequest:null,exception:"TB.2.3-5",valid:!1};var o=!0,s=!1,a=void 0;try{for(var u,l=n[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c=u.value;c.isActive=!1,c.isSuspended=!0}}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}return this.activityTree.currentActivity=t,t.isActive=!1,this.fireEvent("onActivitySuspended",{activity:null==i?void 0:i.id,suspendedPath:n.map(function(e){return e.id}),pathLength:n.length,timestamp:(new Date).toISOString()}),{terminationRequest:xt.SUSPEND_ALL,sequencingRequest:null,exception:null,valid:!0}}},{key:"evaluateExitRules",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t++;var i=e.sequencingRules.exitConditionRules,n=!0,r=!1,o=void 0;try{for(var s,a=i[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value;if("all"===u.conditionCombination?u.conditions.every(function(t){return t.evaluate(e)}):u.conditions.some(function(t){return t.evaluate(e)})){if(u.action===St.EXIT_PARENT)return{action:"EXIT_PARENT",recursionDepth:t};if(u.action===St.EXIT_ALL)return{action:"EXIT_ALL",recursionDepth:t}}}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return{action:null,recursionDepth:t}}},{key:"evaluatePostConditions",value:function(e){var t=this.sequencingProcess.evaluatePostConditionRules(e);return(t.sequencingRequest||t.terminationRequest)&&this.fireEvent("onPostConditionEvaluated",{activity:e.id,sequencingRequest:t.sequencingRequest,terminationRequest:t.terminationRequest,timestamp:(new Date).toISOString()}),t}},{key:"handleMultiLevelExit",value:function(e){this.processExitAtLevel(e,0),this.terminateAll(e)}},{key:"processExitAtLevel",value:function(e,t){var i=this.evaluateExitRules(e,0);i.action&&this.fireEvent("onMultiLevelExitAction",{activity:e.id,level:t,action:i.action});var n=!0,r=!1,o=void 0;try{for(var s,a=e.children[Symbol.iterator]();!(n=(s=a.next()).done);n=!0)this.processExitAtLevel(s.value,t+1)}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}}},{key:"cleanupSuspendedActivity",value:function(){var e=this.activityTree.suspendedActivity;if(e){for(var t=e,i=[];t;)t.isSuspended&&(t.isSuspended=!1,i.push(t.id)),t=t.parent;this.activityTree.suspendedActivity=null,this.fireEvent("onSuspendedActivityCleanup",{cleanedActivities:i,originalSuspendedActivity:e.id})}}},{key:"terminateAll",value:function(e){var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)this.terminateAll(r.value)}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}e.isActive&&this.endAttempt(e)}},{key:"terminateDescendants",value:function(e){var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value;s.children.length>0&&this.terminateDescendants(s);var a=this.exitActionRulesSubprocess(s);s.isActive&&("EXIT_ALL"===a&&this.terminateDescendants(s),this.endAttempt(s))}}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}}},{key:"exitActionRulesSubprocess",value:function(e){var t=e.sequencingRules.exitConditionRules,i=!0,n=!1,r=void 0;try{for(var o,s=t[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value;if("all"===a.conditionCombination?a.conditions.every(function(t){return t.evaluate(e)}):a.conditions.some(function(t){return t.evaluate(e)})){if(a.action===St.EXIT_PARENT)return"EXIT_PARENT";if(a.action===St.EXIT_ALL)return"EXIT_ALL"}}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return null}},{key:"clearSuspendedActivity",value:function(){if(this.activityTree.suspendedActivity){for(var e=this.activityTree.suspendedActivity;e;)e.isSuspended=!1,e=e.parent;this.activityTree.suspendedActivity=null}}},{key:"endAttempt",value:function(e){if(e.isActive){if(this._rteDataTransferService.transferRteData(e),e.isActive=!1,e.activityAttemptActive=!1,0===e.children.length){if(!e.isSuspended&&(e.sequencingControls.completionSetByContent||e.attemptProgressStatus||(e.attemptProgressStatus=!0,e.completionStatus="completed",e.wasAutoCompleted=!0,this.fireEvent("onAutoCompletion",{activityId:e.id,timestamp:(new Date).toISOString()})),!e.sequencingControls.objectiveSetByContent)){var t=e.primaryObjective;t&&(t.progressStatus||(t.progressStatus=!0,t.satisfiedStatus=!0,e.objectiveSatisfiedStatus=!0,e.successStatus="passed",e.wasAutoSatisfied=!0,this.fireEvent("onAutoSatisfaction",{activityId:e.id,timestamp:(new Date).toISOString()})))}}else{var i=e.children.some(function(e){return e.isSuspended});e.isSuspended=i}"unknown"===e.completionStatus&&(e.completionStatus="incomplete"),"unknown"===e.successStatus&&e.objectiveSatisfiedStatus&&(e.successStatus=e.objectiveSatisfiedStatus?"passed":"failed"),this.rollupProcess.processGlobalObjectiveMapping(this.activityTree.root||e,this.globalObjectiveMap),this.rollupProcess.overallRollupProcess(e),this.invalidateCacheCallback&&this.invalidateCacheCallback(),this.activityTree.root&&this.rollupProcess.validateRollupStateConsistency(this.activityTree.root),ei.applySelectionAndRandomization(e,!1)}}},{key:"fireEvent",value:function(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn("Failed to fire sequencing event ".concat(e,": ").concat(t))}}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Er(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function Ar(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function kr(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function jr(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){kr(e,t,i[t])})}return e}function Rr(e){return function(e){if(Array.isArray(e))return Er(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Er(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Er(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Mr=Object.defineProperty,Tr=function(e,t,i){return function(e,t,i){return t in e?Mr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Pr=function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;Ar(this,e),Tr(this,"valid"),Tr(this,"targetActivity"),Tr(this,"exception"),this.valid=t,this.targetActivity=i,this.exception=n},Ir=function(){function e(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,s=arguments.length>5?arguments[5]:void 0;Ar(this,e),Tr(this,"activityTree"),Tr(this,"rollupProcess"),Tr(this,"globalObjectiveMap"),Tr(this,"adlNav"),Tr(this,"eventCallback"),Tr(this,"now"),Tr(this,"defaultHideLmsUi"),Tr(this,"defaultAuxiliaryResources"),Tr(this,"_deliveryInProgress",!1),Tr(this,"contentDelivered",!1),Tr(this,"checkActivityCallback",null),Tr(this,"invalidateCacheCallback",null),Tr(this,"updateNavigationValidityCallback",null),Tr(this,"clearSuspendedActivityCallback",null),this.activityTree=t,this.rollupProcess=i,this.globalObjectiveMap=n,this.adlNav=r,this.eventCallback=o,this.now=(null==s?void 0:s.now)||function(){return new Date},this.defaultHideLmsUi=(null==s?void 0:s.defaultHideLmsUi)?Rr(s.defaultHideLmsUi):[],this.defaultAuxiliaryResources=(null==s?void 0:s.defaultAuxiliaryResources)?s.defaultAuxiliaryResources.map(function(e){return jr({},e)}):[]}return t=e,i=[{key:"setCheckActivityCallback",value:function(e){this.checkActivityCallback=e}},{key:"setInvalidateCacheCallback",value:function(e){this.invalidateCacheCallback=e}},{key:"setUpdateNavigationValidityCallback",value:function(e){this.updateNavigationValidityCallback=e}},{key:"setClearSuspendedActivityCallback",value:function(e){this.clearSuspendedActivityCallback=e}},{key:"isDeliveryInProgress",value:function(){return this._deliveryInProgress}},{key:"hasContentBeenDelivered",value:function(){return this.contentDelivered}},{key:"resetContentDelivered",value:function(){this.contentDelivered=!1}},{key:"setContentDelivered",value:function(e){this.contentDelivered=e}},{key:"processDeliveryRequest",value:function(e){if(this.fireEvent("onDeliveryRequestProcessing",{activity:e.id,timestamp:(new Date).toISOString()}),e.children.length>0)return new Pr(!1,null,"DB.1.1-1");var t=this.getActivityPath(e,!0);if(0===t.length)return new Pr(!1,null,"DB.1.1-2");var i=!0,n=!1,r=void 0;try{for(var o,s=t[Symbol.iterator]();!(i=(o=s.next()).done);i=!0)if(this.checkActivityCallback&&!this.checkActivityCallback(o.value))return new Pr(!1,null,"DB.1.1-3")}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return new Pr(!0,e)}},{key:"contentDeliveryEnvironmentProcess",value:function(e){this._deliveryInProgress=!0;try{var t=e.isSuspended;this.activityTree.suspendedActivity&&this.clearSuspendedActivityCallback&&this.clearSuspendedActivityCallback();var i=this.getActivityPath(e,!0),n=!0,r=!1,o=void 0;try{for(var s,a=i[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value;u.isActive||(t||u.isSuspended?u.isSuspended=!1:u.incrementAttemptCount(),u.isActive=!0,ei.applySelectionAndRandomization(u,1>=u.attemptCount))}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}this.activityTree.currentActivity=e,this.initializeForDelivery(e),this.setupAttemptTracking(e),this.contentDelivered=!0,this.adlNav&&this.updateNavigationValidityCallback&&this.updateNavigationValidityCallback(),this.fireDeliveryEvent(e)}finally{this._deliveryInProgress=!1}}},{key:"initializeForDelivery",value:function(e){"unknown"===e.completionStatus&&0===e.children.length&&(e.completionStatus="not attempted"),null===e.objectiveSatisfiedStatus&&(e.objectiveSatisfiedStatus=!1),null===e.progressMeasure&&(e.progressMeasure=0,e.progressMeasureStatus=!1),null===e.objectiveNormalizedMeasure&&(e.objectiveNormalizedMeasure=0,e.objectiveMeasureStatus=!1),e.attemptAbsoluteDuration="PT0H0M0S",e.attemptExperiencedDuration="PT0H0M0S",e.isAvailable=!0}},{key:"setupAttemptTracking",value:function(e){e.wasSkipped=!1,e.attemptAbsoluteStartTime=this.now().toISOString(),e.location||(e.location=""),e.activityAttemptActive=!0,e.learnerPrefs||(e.learnerPrefs={audioCaptioning:"0",audioLevel:"1",deliverySpeed:"1",language:""})}},{key:"fireDeliveryEvent",value:function(e){try{this.eventCallback&&this.eventCallback("onActivityDelivery",e),console.debug("Activity delivered: ".concat(e.id," - ").concat(e.title))}catch(e){console.warn("Failed to fire activity delivery event: ".concat(e))}}},{key:"getEffectiveHideLmsUi",value:function(t){var i=new Set,n=!0,r=!1,o=void 0;try{for(var s,a=this.defaultHideLmsUi[Symbol.iterator]();!(n=(s=a.next()).done);n=!0)i.add(s.value)}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}for(var u=t;u;){var l=!0,c=!1,d=void 0;try{for(var f,v=u.hideLmsUi[Symbol.iterator]();!(l=(f=v.next()).done);l=!0)i.add(f.value)}catch(e){c=!0,d=e}finally{try{l||null==v.return||v.return()}finally{if(c)throw d}}u=u.parent}return e.HIDE_LMS_UI_ORDER.filter(function(e){return i.has(e)})}},{key:"getEffectiveAuxiliaryResources",value:function(e){var t=new Map,i=!0,n=!1,r=void 0;try{for(var o,s=this.defaultAuxiliaryResources[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value;a.resourceId&&t.set(a.resourceId,jr({},a))}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}for(var u=[],l=e;l;)u.push(l),l=l.parent;var c=!0,d=!1,f=void 0;try{for(var v,h=u.reverse()[Symbol.iterator]();!(c=(v=h.next()).done);c=!0){var m=v.value,p=!0,y=!1,g=void 0;try{for(var _,b=m.auxiliaryResources[Symbol.iterator]();!(p=(_=b.next()).done);p=!0){var S=_.value;S.resourceId&&t.set(S.resourceId,jr({},S))}}catch(e){y=!0,g=e}finally{try{p||null==b.return||b.return()}finally{if(y)throw g}}}}catch(e){d=!0,f=e}finally{try{c||null==h.return||h.return()}finally{if(d)throw f}}return Array.from(t.values())}},{key:"getContentActivityData",value:function(e){var t;return{hideLmsUi:this.getEffectiveHideLmsUi(e),auxiliaryResources:this.getEffectiveAuxiliaryResources(e),location:e.location||"",credit:e.credit||"credit",launchData:e.launchData||"",maxTimeAllowed:e.attemptAbsoluteDurationLimit||"",completionThreshold:(null===(t=e.completionThreshold)||void 0===t?void 0:""+t)||"",timeLimitAction:e.timeLimitAction||"continue,no message"}}},{key:"getActivityPath",value:function(e){for(var t=1>=arguments.length||void 0===arguments[1]||arguments[1],i=[],n=e;null!==n;)i.unshift(n),n=n.parent;return!t&&i.length>0&&i.pop(),i}},{key:"fireEvent",value:function(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn("Failed to fire sequencing event ".concat(e,": ").concat(t))}}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();Tr(Ir,"HIDE_LMS_UI_ORDER",Rr(at));var xr=Ir;var Nr=Object.defineProperty,Dr=function(e,t,i){return function(e,t,i){return t in e?Nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},qr=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Dr(this,"activityTree"),Dr(this,"sequencingProcess"),Dr(this,"cache",null),Dr(this,"isDirty",!0),this.activityTree=t,this.sequencingProcess=i}return t=e,(i=[{key:"predictContinueEnabled",value:function(){var e,t;return this.ensureCacheValid(),null!==(e=null===(t=this.cache)||void 0===t?void 0:t.continueEnabled)&&void 0!==e&&e}},{key:"predictPreviousEnabled",value:function(){var e,t;return this.ensureCacheValid(),null!==(e=null===(t=this.cache)||void 0===t?void 0:t.previousEnabled)&&void 0!==e&&e}},{key:"predictChoiceEnabled",value:function(e){var t,i;return this.ensureCacheValid(),null!==(t=null===(i=this.cache)||void 0===i?void 0:i.choiceEnabledMap.get(e))&&void 0!==t&&t}},{key:"getAvailableChoices",value:function(){var e,t;return this.ensureCacheValid(),Array.from(null!==(e=null===(t=this.cache)||void 0===t?void 0:t.availableChoices)&&void 0!==e?e:[])}},{key:"getAllPredictions",value:function(){var e,t,i,n,r,o;return this.ensureCacheValid(),{continueEnabled:null!==(e=null===(n=this.cache)||void 0===n?void 0:n.continueEnabled)&&void 0!==e&&e,previousEnabled:null!==(t=null===(r=this.cache)||void 0===r?void 0:r.previousEnabled)&&void 0!==t&&t,availableChoices:Array.from(null!==(i=null===(o=this.cache)||void 0===o?void 0:o.availableChoices)&&void 0!==i?i:[])}}},{key:"invalidateCache",value:function(){this.isDirty=!0}},{key:"updateCache",value:function(){this.isDirty=!0,this.ensureCacheValid()}},{key:"ensureCacheValid",value:function(){var e=this.calculateTreeStateHash();!this.isDirty&&this.cache&&this.cache.treeStateHash===e||(this.recalculateCache(e),this.isDirty=!1)}},{key:"recalculateCache",value:function(e){var t=this.activityTree.currentActivity;this.cache={continueEnabled:!1,previousEnabled:!1,availableChoices:new Set,choiceEnabledMap:new Map,treeStateHash:e},t?(this.cache.continueEnabled=this.predictContinueInternal(t),this.cache.previousEnabled=this.predictPreviousInternal(t),this.calculateAvailableChoices()):this.calculateAvailableChoicesFromRoot()}},{key:"predictContinueInternal",value:function(e){return!!e.parent&&!!e.parent.sequencingControls.flow&&this.hasAvailableNextActivity(e)}},{key:"hasAvailableNextActivity",value:function(e){var t=e.parent;if(!t)return!1;var i=t.children,n=i.indexOf(e);if(-1===n)return!1;if(i.length-1>n)for(var r=n+1;i.length>r;r++){var o=i[r];if(o&&this.isActivityPotentiallyDeliverableForward(o))return!0}return!(!t.parent||!t.sequencingControls.flow)&&this.hasAvailableNextActivity(t)}},{key:"predictPreviousInternal",value:function(e){return!!e.parent&&!!e.parent.sequencingControls.flow&&!e.parent.sequencingControls.forwardOnly&&this.hasAvailablePreviousActivity(e)}},{key:"hasAvailablePreviousActivity",value:function(e){var t=e.parent;if(!t)return!1;var i=t.children,n=i.indexOf(e);if(-1===n)return!1;if(n>0)for(var r=n-1;r>=0;r--){var o=i[r];if(o&&this.isActivityPotentiallyDeliverableBackward(o))return!0}return!(!t.parent||!t.sequencingControls.flow||t.sequencingControls.forwardOnly)&&this.hasAvailablePreviousActivity(t)}},{key:"calculateAvailableChoicesFromRoot",value:function(){}},{key:"calculateAvailableChoices",value:function(){this.cache&&this.activityTree.root&&this.recursivelyCheckChoiceAvailability(this.activityTree.root)}},{key:"recursivelyCheckChoiceAvailability",value:function(e){if(this.cache){var t=this.sequencingProcess.validateNavigationRequest(xt.CHOICE,e.id,this.activityTree.currentActivity).valid;if(this.cache.choiceEnabledMap.set(e.id,t),t&&this.cache.availableChoices.add(e.id),e.children){var i=!0,n=!1,r=void 0;try{for(var o,s=e.children[Symbol.iterator]();!(i=(o=s.next()).done);i=!0)this.recursivelyCheckChoiceAvailability(o.value)}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}}}},{key:"isActivityPotentiallyDeliverableForward",value:function(e){if(e.isHiddenFromChoice||!e.isAvailable)return!1;if(0===e.children.length)return!!e.isVisible&&this.sequencingProcess.canActivityBeDelivered(e);var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)if(this.isActivityPotentiallyDeliverableForward(r.value))return!0}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}return!1}},{key:"isActivityPotentiallyDeliverableBackward",value:function(e){if(e.isHiddenFromChoice||!e.isAvailable)return!1;if(0===e.children.length)return e.isVisible;var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)if(this.isActivityPotentiallyDeliverableBackward(r.value))return!0}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}return!1}},{key:"calculateTreeStateHash",value:function(){var e,t,i=this.activityTree.currentActivity,n=this.activityTree.suspendedActivity;return[null!==(e=null==i?void 0:i.id)&&void 0!==e?e:"none",null!==(t=null==n?void 0:n.id)&&void 0!==t?t:"none",this.getActivityTreeStateSignature()].join("|")}},{key:"getActivityTreeStateSignature",value:function(){if(!this.activityTree.root)return"empty";var e=[];return this.collectActivitySignatures(this.activityTree.root,e),e.join(":")}},{key:"collectActivitySignatures",value:function(e,t){if(t.push(e.id+(e.isActive?"A":"-")+(e.isSuspended?"S":"-")+e.completionStatus+e.successStatus+e.attemptCount),e.children){var i=!0,n=!1,r=void 0;try{for(var o,s=e.children[Symbol.iterator]();!(i=(o=s.next()).done);i=!0)this.collectActivitySignatures(o.value,t)}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Lr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var zr=Object.defineProperty,Fr=function(e,t,i){return function(e,t,i){return t in e?zr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Br=function(e){return e.START="start",e.RESUME_ALL="resumeAll",e.CONTINUE="continue",e.PREVIOUS="previous",e.CHOICE="choice",e.JUMP="jump",e.EXIT="exit",e.EXIT_ALL="exitAll",e.ABANDON="abandon",e.ABANDON_ALL="abandonAll",e.SUSPEND_ALL="suspendAll",e.NOT_VALID="_none_",e}(Br||{}),Vr=function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;Lr(this,e),Fr(this,"valid"),Fr(this,"terminationRequest"),Fr(this,"sequencingRequest"),Fr(this,"targetActivityId"),Fr(this,"exception"),this.valid=t,this.terminationRequest=i,this.sequencingRequest=n,this.targetActivityId=r,this.exception=o},Hr=function(){function e(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;Lr(this,e),Fr(this,"activityTree"),Fr(this,"sequencingProcess"),Fr(this,"adlNav"),Fr(this,"eventCallback"),Fr(this,"navigationLookAhead"),Fr(this,"getEffectiveHideLmsUiCallback",null),this.activityTree=t,this.sequencingProcess=i,this.adlNav=n,this.eventCallback=r,this.navigationLookAhead=new qr(t,i)}return t=e,i=[{key:"setGetEffectiveHideLmsUiCallback",value:function(e){this.getEffectiveHideLmsUiCallback=e}},{key:"getNavigationLookAhead",value:function(){return this.navigationLookAhead}},{key:"validateRequest",value:function(request){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.fireEvent("onNavigationRequestProcessing",{request:request,targetActivityId:e});var t=this.activityTree.currentActivity;switch(request){case"start":return this.validateStartRequest(t);case"resumeAll":return this.validateResumeRequest(t);case"continue":return this.validateContinueRequest(t);case"previous":return this.validatePreviousRequest(t);case"choice":return this.validateChoiceRequest(t,e);case"jump":return this.validateJumpRequest(e);case"exit":return this.validateExitRequest(t);case"exitAll":return this.validateExitAllRequest(t);case"abandon":return this.validateAbandonRequest(t);case"abandonAll":return this.validateAbandonAllRequest(t);case"suspendAll":return this.validateSuspendAllRequest(t);default:return new Vr(!1,null,null,null,"NB.2.1-18")}}},{key:"validateStartRequest",value:function(e){return null!==e?new Vr(!1,null,null,null,"NB.2.1-1"):new Vr(!0,null,xt.START,null)}},{key:"validateResumeRequest",value:function(e){return null!==e?new Vr(!1,null,null,null,"NB.2.1-2"):null===this.activityTree.suspendedActivity?new Vr(!1,null,null,null,"NB.2.1-3"):new Vr(!0,null,xt.RESUME_ALL,null)}},{key:"validateContinueRequest",value:function(e){return e?e.parent&&e.parent.sequencingControls.flow?new Vr(!0,e.isActive?xt.EXIT:null,xt.CONTINUE,null):new Vr(!1,null,null,null,"NB.2.1-5"):new Vr(!1,null,null,null,"NB.2.1-4")}},{key:"validatePreviousRequest",value:function(e){if(!e)return new Vr(!1,null,null,null,"NB.2.1-6");if(!e.parent||!e.parent.sequencingControls.flow)return new Vr(!1,null,null,null,"NB.2.1-7");var t=this.validateForwardOnlyConstraints(e);return t.valid?new Vr(!0,e.isActive?xt.EXIT:null,xt.PREVIOUS,null):new Vr(!1,null,null,null,t.exception)}},{key:"validateChoiceRequest",value:function(e,t){if(!t)return new Vr(!1,null,null,null,"NB.2.1-9");var i=this.activityTree.getActivity(t);if(!i)return new Vr(!1,null,null,null,"NB.2.1-10");var n=this.validateChoicePath(e,i);return n.valid?new Vr(!0,(null==e?void 0:e.isActive)?xt.EXIT:null,xt.CHOICE,t):new Vr(!1,null,null,null,n.exception)}},{key:"validateJumpRequest",value:function(e){return e?new Vr(!0,null,xt.JUMP,e):new Vr(!1,null,null,null,"NB.2.1-12")}},{key:"validateExitRequest",value:function(e){return e?new Vr(!0,e===this.activityTree.root?xt.EXIT_ALL:xt.EXIT,null,null):new Vr(!1,null,null,null,"NB.2.1-13")}},{key:"validateExitAllRequest",value:function(e){return e?new Vr(!0,xt.EXIT_ALL,null,null):new Vr(!1,null,null,null,"NB.2.1-14")}},{key:"validateAbandonRequest",value:function(e){return e?new Vr(!0,xt.ABANDON,null,null):new Vr(!1,null,null,null,"NB.2.1-15")}},{key:"validateAbandonAllRequest",value:function(e){return e?new Vr(!0,xt.ABANDON_ALL,null,null):new Vr(!1,null,null,null,"NB.2.1-16")}},{key:"validateSuspendAllRequest",value:function(e){return e?new Vr(!0,xt.SUSPEND_ALL,null,null):new Vr(!1,null,null,null,"NB.2.1-17")}},{key:"validateChoicePath",value:function(e,t){if(t.isHiddenFromChoice)return{valid:!1,exception:"NB.2.1-11"};if(!t.isAvailable)return{valid:!1,exception:"NB.2.1-11"};if(this.isActivityDisabled(t))return{valid:!1,exception:"NB.2.1-11"};if(e){var i=this.findCommonAncestor(e,t);if(!i)return{valid:!1,exception:"NB.2.1-11"};for(var n=e;n&&n!==i;){if(!0===n.isActive&&n.sequencingControls&&!1===n.sequencingControls.choiceExit&&t!==n&&!this.activityContains(n,t))return{valid:!1,exception:"NB.2.1-11"};n=n.parent}var r=this.validateConstrainChoice(e,t,i);if(!r.valid)return r;var o=this.validateChoiceSet(e,t,i);if(!o.valid)return o}for(var s=t;s;){if(s.parent&&!s.parent.sequencingControls.choice)return{valid:!1,exception:"NB.2.1-11"};s=s.parent}return{valid:!0,exception:null}}},{key:"validateForwardOnlyConstraints",value:function(e){var t,i;if(null===(t=e.parent)||void 0===t?void 0:t.sequencingControls.forwardOnly)return{valid:!1,exception:"NB.2.1-8"};for(var n=null===(i=e.parent)||void 0===i?void 0:i.parent;n;){if(n.sequencingControls.forwardOnly)return{valid:!1,exception:"NB.2.1-8"};n=n.parent}return{valid:!0,exception:null}}},{key:"validateConstrainChoice",value:function(e,t,i){for(var n=i;n;){var r,o;if((null===(r=n.sequencingControls)||void 0===r?void 0:r.constrainChoice)||(null===(o=n.sequencingControls)||void 0===o?void 0:o.preventActivation)){var s,a,u=this.findChildContaining(n,e);if(!u)return{valid:!1,exception:"NB.2.1-11"};if(t===n)return{valid:!1,exception:"NB.2.1-11"};var l=this.findChildContaining(n,t);if(!l)return{valid:!1,exception:"NB.2.1-11"};if((null===(s=n.sequencingControls)||void 0===s?void 0:s.constrainChoice)&&l!==u)return{valid:!1,exception:"NB.2.1-11"};if((null===(a=n.sequencingControls)||void 0===a?void 0:a.preventActivation)&&l!==u&&this.requiresNewActivation(l,t))return{valid:!1,exception:"NB.2.1-11"}}n=n.parent}return this.validateAncestors(i,e,t)}},{key:"validateChoiceSet",value:function(e,t,i){if(!this.activityContains(i,t)&&t!==i)return{valid:!1,exception:"NB.2.1-11"};for(var n=t;n&&n!==i;){if(!n.isAvailable||n.isHiddenFromChoice||this.isActivityDisabled(n))return{valid:!1,exception:"NB.2.1-11"};n=n.parent}return{valid:!0,exception:null}}},{key:"isActivityDisabled",value:function(e){if(!e.isAvailable)return!0;if(e.isHiddenFromChoice)return!0;var t=this.evaluatePreConditionRulesForChoice(e);return!!t&&(t===St.DISABLED||t===St.HIDE_FROM_CHOICE||t===St.STOP_FORWARD_TRAVERSAL)}},{key:"findChildContaining",value:function(e,t){var i=!0,n=!1,r=void 0;try{for(var o,s=e.children[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value;if(a===t)return a;if(this.activityContains(a,t))return a}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return null}},{key:"activityContains",value:function(e,t){for(var i=t;i;){if(i===e)return!0;i=i.parent}return!1}},{key:"findCommonAncestor",value:function(e,t){for(var i=[],n=e;n;)i.push(n),n=n.parent;for(n=t;n;){if(i.includes(n))return n;n=n.parent}return null}},{key:"validateAncestors",value:function(e,t,i){var n=e.children;if(!n||0===n.length)return{valid:!0,exception:null};var r=this.findChildContaining(e,t),o=this.findChildContaining(e,i);if(!r||!o)return{valid:!1,exception:"NB.2.1-11"};var s=n.indexOf(r),a=n.indexOf(o);if(e.sequencingControls.forwardOnly&&s>a)return{valid:!1,exception:"NB.2.1-8"};var u=n.findIndex(function(e){return null==e?void 0:e.sequencingControls.stopForwardTraversal});if(r.sequencingControls.stopForwardTraversal&&a>s)return{valid:!1,exception:"NB.2.1-11"};if(-1!==u&&a>u)return{valid:!1,exception:"NB.2.1-11"};if(a>s&&e.sequencingControls.forwardOnly)for(var l=s+1;a>l;l++){var c=n[l];if(c){if(c.sequencingControls.stopForwardTraversal)return{valid:!1,exception:"NB.2.1-11"};if(this.isActivityMandatory(c)&&!this.isActivityCompleted(c))return{valid:!1,exception:"NB.2.1-11"}}}return{valid:!0,exception:null}}},{key:"requiresNewActivation",value:function(e,t){return!this.branchHasActiveAttempt(e)&&!t.activityAttemptActive&&!t.isActive}},{key:"branchHasActiveAttempt",value:function(e){if(e.activityAttemptActive||e.isActive)return!0;var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)if(this.branchHasActiveAttempt(r.value))return!0}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}return!1}},{key:"isActivityMandatory",value:function(e){if(!e.isAvailable||e.isHiddenFromChoice)return!1;var t=this.evaluatePreConditionRulesForChoice(e);return t!==St.SKIP&&t!==St.DISABLED&&t!==St.HIDE_FROM_CHOICE&&t!==St.STOP_FORWARD_TRAVERSAL&&!this.isActivityDisabled(e)&&!1!==e.mandatory}},{key:"isActivityCompleted",value:function(e){if(!e.isAvailable||e.isHiddenFromChoice)return!0;var t=this.evaluatePreConditionRulesForChoice(e);return t===St.SKIP||t===St.DISABLED||t===St.HIDE_FROM_CHOICE||t===St.STOP_FORWARD_TRAVERSAL||!!this.isActivityDisabled(e)||"completed"===e.completionStatus||"passed"===e.successStatus||"passed"===e.successStatus}},{key:"evaluatePreConditionRulesForChoice",value:function(e){return e.sequencingRules&&e.sequencingRules.evaluatePreConditionRules(e)||null}},{key:"updateNavigationValidity",value:function(){if(this.adlNav&&this.activityTree.currentActivity){this.navigationLookAhead.invalidateCache();var e=this.navigationLookAhead.predictContinueEnabled();try{this.adlNav.request_valid.continue=e?"true":"false"}catch(e){}var t=this.navigationLookAhead.predictPreviousEnabled();try{this.adlNav.request_valid.previous=t?"true":"false"}catch(e){}var i=this.activityTree.getAllActivities(),n={},r={},o=!0,s=!1,a=void 0;try{for(var u,l=i[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c=u.value,d=this.validateRequest("choice",c.id);n[c.id]=d.valid?"true":"false";var f=this.validateRequest("jump",c.id);r[c.id]=f.valid?"true":"false"}}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}try{this.adlNav.request_valid.choice=n}catch(e){}try{this.adlNav.request_valid.jump=r}catch(e){}var v=this.getEffectiveHideLmsUiCallback?this.getEffectiveHideLmsUiCallback(this.activityTree.currentActivity):[];this.fireEvent("onNavigationValidityUpdate",{continue:e,previous:t,choice:n,jump:r,hideLmsUi:v})}}},{key:"getAllPredictions",value:function(){return this.navigationLookAhead.getAllPredictions()}},{key:"predictContinueEnabled",value:function(){return this.navigationLookAhead.predictContinueEnabled()}},{key:"predictPreviousEnabled",value:function(){return this.navigationLookAhead.predictPreviousEnabled()}},{key:"predictChoiceEnabled",value:function(e){return this.navigationLookAhead.predictChoiceEnabled(e)}},{key:"getAvailableChoices",value:function(){return this.navigationLookAhead.getAvailableChoices()}},{key:"invalidateCache",value:function(){this.navigationLookAhead.invalidateCache()}},{key:"fireEvent",value:function(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn("Failed to fire sequencing event ".concat(e,": ").concat(t))}}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Ur(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function Gr(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Yr(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function Wr(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){Gr(e,t,i[t])})}return e}function Jr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,o=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Ur(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Ur(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.")}()}var Kr=Object.defineProperty,$r=function(e,t,i){return function(e,t,i){return t in e?Kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Xr=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),$r(this,"globalObjectiveMap",new Map),$r(this,"eventCallback",null),this.eventCallback=t||null}return t=e,(i=[{key:"initialize",value:function(e){try{this.globalObjectiveMap.clear(),e&&this.collectObjectives(e),this.fireEvent("onGlobalObjectiveMapInitialized",{objectiveCount:this.globalObjectiveMap.size,timestamp:(new Date).toISOString()})}catch(e){this.fireEvent("onGlobalObjectiveMapError",{error:Yr(e,Error)?e.message:e+"",timestamp:(new Date).toISOString()})}}},{key:"collectObjectives",value:function(e){var objectives=e.getAllObjectives();if(0===objectives.length){var t="".concat(e.id,"_default_objective");this.globalObjectiveMap.has(t)||this.globalObjectiveMap.set(t,{id:t,satisfiedStatus:e.objectiveSatisfiedStatus,satisfiedStatusKnown:e.objectiveMeasureStatus,normalizedMeasure:e.objectiveNormalizedMeasure,normalizedMeasureKnown:e.objectiveMeasureStatus,progressMeasure:e.progressMeasure,progressMeasureKnown:e.progressMeasureStatus,completionStatus:e.completionStatus,completionStatusKnown:e.completionStatus!==Oe,readSatisfiedStatus:!0,writeSatisfiedStatus:!0,readNormalizedMeasure:!0,writeNormalizedMeasure:!0,readCompletionStatus:!0,writeCompletionStatus:!0,readProgressMeasure:!0,writeProgressMeasure:!0,satisfiedByMeasure:null!==e.scaledPassingScore,minNormalizedMeasure:e.scaledPassingScore,updateAttemptData:!0})}var i=!0,n=!1,r=void 0;try{for(var o,s=objectives[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value,u=a.mapInfo.length>0?a.mapInfo:[{targetObjectiveID:a.id,readSatisfiedStatus:!0,writeSatisfiedStatus:!0,readNormalizedMeasure:!0,writeNormalizedMeasure:!0,readProgressMeasure:!0,writeProgressMeasure:!0,readCompletionStatus:!0,writeCompletionStatus:!0,updateAttemptData:a.isPrimary}],l=!0,c=!1,d=void 0;try{for(var f,v=u[Symbol.iterator]();!(l=(f=v.next()).done);l=!0){var h,m,p,y,g,_,b,S,w,C,O,E,A,k,j,R=f.value,M=R.targetObjectiveID||a.id;this.globalObjectiveMap.has(M)||this.globalObjectiveMap.set(M,{id:M,satisfiedStatus:a.satisfiedStatus,satisfiedStatusKnown:a.measureStatus,normalizedMeasure:a.normalizedMeasure,normalizedMeasureKnown:a.measureStatus,progressMeasure:a.progressMeasure,progressMeasureKnown:a.progressMeasureStatus,completionStatus:a.completionStatus,completionStatusKnown:a.completionStatus!==Oe,readSatisfiedStatus:null!==(h=R.readSatisfiedStatus)&&void 0!==h&&h,writeSatisfiedStatus:null!==(m=R.writeSatisfiedStatus)&&void 0!==m&&m,readNormalizedMeasure:null!==(p=R.readNormalizedMeasure)&&void 0!==p&&p,writeNormalizedMeasure:null!==(y=R.writeNormalizedMeasure)&&void 0!==y&&y,readProgressMeasure:null!==(g=R.readProgressMeasure)&&void 0!==g&&g,writeProgressMeasure:null!==(_=R.writeProgressMeasure)&&void 0!==_&&_,readCompletionStatus:null!==(b=R.readCompletionStatus)&&void 0!==b&&b,writeCompletionStatus:null!==(S=R.writeCompletionStatus)&&void 0!==S&&S,readRawScore:null!==(w=R.readRawScore)&&void 0!==w&&w,writeRawScore:null!==(C=R.writeRawScore)&&void 0!==C&&C,readMinScore:null!==(O=R.readMinScore)&&void 0!==O&&O,writeMinScore:null!==(E=R.writeMinScore)&&void 0!==E&&E,readMaxScore:null!==(A=R.readMaxScore)&&void 0!==A&&A,writeMaxScore:null!==(k=R.writeMaxScore)&&void 0!==k&&k,satisfiedByMeasure:a.satisfiedByMeasure,minNormalizedMeasure:a.minNormalizedMeasure,updateAttemptData:null!==(j=R.updateAttemptData)&&void 0!==j?j:a.isPrimary})}}catch(e){c=!0,d=e}finally{try{l||null==v.return||v.return()}finally{if(c)throw d}}}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}var T=!0,P=!1,I=void 0;try{for(var x,N=e.children[Symbol.iterator]();!(T=(x=N.next()).done);T=!0)this.collectObjectives(x.value)}catch(e){P=!0,I=e}finally{try{T||null==N.return||N.return()}finally{if(P)throw I}}}},{key:"getMap",value:function(){return this.globalObjectiveMap}},{key:"getSnapshot",value:function(){return this.serialize()}},{key:"restoreSnapshot",value:function(e){this.restore(e)}},{key:"updateObjective",value:function(e,t){try{this.globalObjectiveMap.set(e,(i=Wr({},this.globalObjectiveMap.get(e),t),n=null!=(n={lastUpdated:(new Date).toISOString()})?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(n)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t}(Object(n)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(n,e))}),i)),this.fireEvent("onGlobalObjectiveUpdated",{objectiveId:e,data:t,timestamp:(new Date).toISOString()})}catch(t){this.fireEvent("onGlobalObjectiveUpdateError",{objectiveId:e,error:Yr(t,Error)?t.message:t+"",timestamp:(new Date).toISOString()})}var i,n}},{key:"synchronize",value:function(e,t){e&&t.processGlobalObjectiveMapping(e,this.globalObjectiveMap)}},{key:"getObjective",value:function(e){return this.globalObjectiveMap.get(e)}},{key:"hasObjective",value:function(e){return this.globalObjectiveMap.has(e)}},{key:"getObjectiveIds",value:function(){return Array.from(this.globalObjectiveMap.keys())}},{key:"getObjectiveCount",value:function(){return this.globalObjectiveMap.size}},{key:"clear",value:function(){this.globalObjectiveMap.clear(),this.fireEvent("onGlobalObjectiveMapCleared",{timestamp:(new Date).toISOString()})}},{key:"serialize",value:function(){var e={};return this.globalObjectiveMap.forEach(function(t,id){e[id]=Wr({},t)}),e}},{key:"restore",value:function(e){if(this.globalObjectiveMap.clear(),e){var t=!0,i=!1,n=void 0;try{for(var r,o=Object.entries(e)[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=Jr(r.value,2);this.globalObjectiveMap.set(s[0],Wr({},s[1]))}}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}this.fireEvent("onGlobalObjectiveMapRestored",{objectiveCount:this.globalObjectiveMap.size,timestamp:(new Date).toISOString()})}}},{key:"fireEvent",value:function(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn("Failed to fire global objective event ".concat(e,": ").concat(t))}}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var Qr=Object.defineProperty,Zr=function(e,t,i){return function(e,t,i){return t in e?Qr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},eo=function(){function e(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Zr(this,"activityTree"),Zr(this,"globalObjectiveService"),Zr(this,"rollupProcess"),Zr(this,"adlNav"),Zr(this,"eventCallback"),Zr(this,"getEffectiveHideLmsUiCallback",null),Zr(this,"getEffectiveAuxiliaryResourcesCallback",null),Zr(this,"contentDeliveredGetter",null),Zr(this,"contentDeliveredSetter",null),this.activityTree=t,this.globalObjectiveService=i,this.rollupProcess=n,this.adlNav=r,this.eventCallback=o}return t=e,(i=[{key:"setGetEffectiveHideLmsUiCallback",value:function(e){this.getEffectiveHideLmsUiCallback=e}},{key:"setGetEffectiveAuxiliaryResourcesCallback",value:function(e){this.getEffectiveAuxiliaryResourcesCallback=e}},{key:"setContentDeliveredAccessors",value:function(e,t){this.contentDeliveredGetter=e,this.contentDeliveredSetter=t}},{key:"getState",value:function(){var e,t;return{version:"1.0",timestamp:(new Date).toISOString(),contentDelivered:!!this.contentDeliveredGetter&&this.contentDeliveredGetter(),currentActivity:(null===(e=this.activityTree.currentActivity)||void 0===e?void 0:e.id)||null,suspendedActivity:(null===(t=this.activityTree.suspendedActivity)||void 0===t?void 0:t.id)||null,activityStates:this.serializeActivities(),navigationState:this.getNavigationState(),globalObjectiveMap:this.globalObjectiveService.getSnapshot()}}},{key:"restoreState",value:function(e){try{if(!e||"1.0"!==e.version)return console.warn("Incompatible sequencing state version"),!1;if(this.contentDeliveredSetter&&this.contentDeliveredSetter(e.contentDelivered||!1),e.globalObjectiveMap&&this.globalObjectiveService.restoreSnapshot(e.globalObjectiveMap),e.activityStates&&this.deserializeActivities(e.activityStates),e.currentActivity){var t=this.activityTree.getActivity(e.currentActivity);t&&(this.activityTree.currentActivity=t,t.isActive=!0)}if(e.suspendedActivity){var i=this.activityTree.getActivity(e.suspendedActivity);i&&(this.activityTree.suspendedActivity=i,i.isSuspended=!0)}return e.navigationState&&this.restoreNavigationState(e.navigationState),this.activityTree.root&&this.globalObjectiveService.synchronize(this.activityTree.root,this.rollupProcess),console.debug("Sequencing state restored successfully"),!0}catch(e){return console.error("Failed to restore sequencing state: ".concat(e)),!1}}},{key:"serializeActivities",value:function(){var e={},t=function(i){e[i.id]={id:i.id,title:i.title,isActive:i.isActive,isSuspended:i.isSuspended,isCompleted:i.isCompleted,completionStatus:i.completionStatus,successStatus:i.successStatus,attemptCount:i.attemptCount,attemptCompletionAmount:i.attemptCompletionAmount,attemptAbsoluteDuration:i.attemptAbsoluteDuration,attemptExperiencedDuration:i.attemptExperiencedDuration,activityAbsoluteDuration:i.activityAbsoluteDuration,activityExperiencedDuration:i.activityExperiencedDuration,objectiveSatisfiedStatus:i.objectiveSatisfiedStatus,objectiveMeasureStatus:i.objectiveMeasureStatus,objectiveNormalizedMeasure:i.objectiveNormalizedMeasure,progressMeasure:i.progressMeasure,progressMeasureStatus:i.progressMeasureStatus,isAvailable:i.isAvailable,isHiddenFromChoice:i.isHiddenFromChoice,location:i.location,attemptAbsoluteStartTime:i.attemptAbsoluteStartTime,objectives:i.getObjectiveStateSnapshot(),auxiliaryResources:i.auxiliaryResources,selectionRandomizationState:{selectionCountStatus:i.sequencingControls.selectionCountStatus,reorderChildren:i.sequencingControls.reorderChildren,childOrder:i.children.map(function(e){return e.id}),selectedChildIds:i.children.filter(function(e){return e.isAvailable}).map(function(e){return e.id}),hiddenFromChoiceChildIds:i.children.filter(function(e){return e.isHiddenFromChoice}).map(function(e){return e.id})}};var n=!0,r=!1,o=void 0;try{for(var s,a=i.children[Symbol.iterator]();!(n=(s=a.next()).done);n=!0)t(s.value)}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}};return this.activityTree.root&&t(this.activityTree.root),e}},{key:"deserializeActivities",value:function(e){var t=function(i){var n,r=e[i.id];r&&(i.isActive=r.isActive||!1,i.isSuspended=r.isSuspended||!1,i.isCompleted=r.isCompleted||!1,i.completionStatus=r.completionStatus||"unknown",i.successStatus=r.successStatus||"unknown",i.attemptCount=r.attemptCount||0,i.attemptCompletionAmount=r.attemptCompletionAmount||0,i.attemptAbsoluteDuration=r.attemptAbsoluteDuration||"PT0H0M0S",i.attemptExperiencedDuration=r.attemptExperiencedDuration||"PT0H0M0S",i.activityAbsoluteDuration=r.activityAbsoluteDuration||"PT0H0M0S",i.activityExperiencedDuration=r.activityExperiencedDuration||"PT0H0M0S",i.objectiveSatisfiedStatus=r.objectiveSatisfiedStatus||!1,i.objectiveMeasureStatus=r.objectiveMeasureStatus||!1,i.objectiveNormalizedMeasure=r.objectiveNormalizedMeasure||0,i.progressMeasure=null!==(n=r.progressMeasure)&&void 0!==n?n:0,i.progressMeasureStatus=r.progressMeasureStatus||!1,i.isAvailable=!1!==r.isAvailable,i.isHiddenFromChoice=!0===r.isHiddenFromChoice,i.location=r.location||"",i.attemptAbsoluteStartTime=r.attemptAbsoluteStartTime||"",Array.isArray(r.auxiliaryResources)&&(i.auxiliaryResources=r.auxiliaryResources),r.objectives&&i.applyObjectiveStateSnapshot(r.objectives));var o=!0,s=!1,a=void 0;try{for(var u,l=i.children[Symbol.iterator]();!(o=(u=l.next()).done);o=!0)t(u.value)}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}if(null==r?void 0:r.selectionRandomizationState){var c=r.selectionRandomizationState,d=i.sequencingControls;void 0!==c.selectionCountStatus&&(d.selectionCountStatus=c.selectionCountStatus),void 0!==c.reorderChildren&&(d.reorderChildren=c.reorderChildren),c.childOrder&&c.childOrder.length>0&&i.setChildOrder(c.childOrder);var f=Array.isArray(c.selectedChildIds)?new Set(c.selectedChildIds):null,v=Array.isArray(c.hiddenFromChoiceChildIds)?new Set(c.hiddenFromChoiceChildIds):null;if(f||v){var h=!0,m=!1,p=void 0;try{for(var y,g=i.children[Symbol.iterator]();!(h=(y=g.next()).done);h=!0){var _=y.value;if(f){var b=f.has(_.id);_.isAvailable=b,v||(_.isHiddenFromChoice=!b)}v&&(_.isHiddenFromChoice=v.has(_.id))}}catch(e){m=!0,p=e}finally{try{h||null==g.return||g.return()}finally{if(m)throw p}}}i.setProcessedChildren(i.children.filter(function(e){return e.isAvailable}))}else i.resetProcessedChildren()};this.activityTree.root&&t(this.activityTree.root)}},{key:"getNavigationState",value:function(){var e,t,i,n,r,o,s;if(!this.adlNav)return null;var a=this.getEffectiveHideLmsUiCallback?this.getEffectiveHideLmsUiCallback(this.activityTree.currentActivity):[],u=this.getEffectiveAuxiliaryResourcesCallback?this.getEffectiveAuxiliaryResourcesCallback(this.activityTree.currentActivity):[];return{request:this.adlNav.request||"_none_",requestValid:{continue:(null===(e=this.adlNav.request_valid)||void 0===e?void 0:e.continue)||"false",previous:(null===(t=this.adlNav.request_valid)||void 0===t?void 0:t.previous)||"false",choice:"unknown",jump:"unknown",exit:(null===(i=this.adlNav.request_valid)||void 0===i?void 0:i.exit)||"false",exitAll:(null===(n=this.adlNav.request_valid)||void 0===n?void 0:n.exitAll)||"false",abandon:(null===(r=this.adlNav.request_valid)||void 0===r?void 0:r.abandon)||"false",abandonAll:(null===(o=this.adlNav.request_valid)||void 0===o?void 0:o.abandonAll)||"false",suspendAll:(null===(s=this.adlNav.request_valid)||void 0===s?void 0:s.suspendAll)||"false"},hideLmsUi:a,auxiliaryResources:u}}},{key:"restoreNavigationState",value:function(e){if(this.adlNav&&e)try{if(e.requestValid){var t=e.requestValid;this.adlNav.request_valid.continue=t.continue||"false",this.adlNav.request_valid.previous=t.previous||"false",this.adlNav.request_valid.exit=t.exit||"false",this.adlNav.request_valid.exitAll=t.exitAll||"false",this.adlNav.request_valid.abandon=t.abandon||"false",this.adlNav.request_valid.abandonAll=t.abandonAll||"false",this.adlNav.request_valid.suspendAll=t.suspendAll||"false"}}catch(e){console.warn("Could not fully restore navigation state: ".concat(e))}}},{key:"getSuspensionState",value:function(){var e,t,i={activityTree:this.activityTree.root?this.activityTree.root.getSuspensionState():null,currentActivityId:(null===(e=this.activityTree.currentActivity)||void 0===e?void 0:e.id)||null,suspendedActivityId:(null===(t=this.activityTree.suspendedActivity)||void 0===t?void 0:t.id)||null,globalObjectives:this.globalObjectiveService.getSnapshot(),timestamp:(new Date).toISOString()};return this.fireEvent("onSuspensionStateCaptured",{hasActivityTree:!!i.activityTree,currentActivityId:i.currentActivityId,suspendedActivityId:i.suspendedActivityId,globalObjectiveCount:Object.keys(i.globalObjectives).length,timestamp:i.timestamp}),i}},{key:"restoreSuspensionState",value:function(e){var t,i;if(e)try{if(e.globalObjectives&&this.globalObjectiveService.restoreSnapshot(e.globalObjectives),e.activityTree&&this.activityTree.root&&this.activityTree.root.restoreSuspensionState(e.activityTree),e.currentActivityId){var n=this.activityTree.getActivity(e.currentActivityId);n&&(this.activityTree.currentActivity=n)}if(e.suspendedActivityId){var r=this.activityTree.getActivity(e.suspendedActivityId);r&&(this.activityTree.suspendedActivity=r)}this.fireEvent("onSuspensionStateRestored",{currentActivityId:e.currentActivityId,suspendedActivityId:e.suspendedActivityId,globalObjectiveCount:e.globalObjectives?Object.keys(e.globalObjectives).length:0,originalTimestamp:e.timestamp,restoreTimestamp:(new Date).toISOString()})}catch(e){throw this.fireEvent("onSuspensionStateRestoreError",{error:(t=e,i=Error,(null!=i&&"undefined"!=typeof Symbol&&i[Symbol.hasInstance]?i[Symbol.hasInstance](t):t instanceof i)?e.message:e+""),timestamp:(new Date).toISOString()}),e}else this.fireEvent("onSuspensionStateRestoreError",{error:"No suspension state provided",timestamp:(new Date).toISOString()})}},{key:"fireEvent",value:function(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn("Failed to fire state manager event ".concat(e,": ").concat(t))}}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function to(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function io(e){return function(e){if(Array.isArray(e))return to(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return to(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?to(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var no=Object.defineProperty,ro=function(e,t,i){return function(e,t,i){return t in e?no(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},oo=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ro(this,"activityTree"),ro(this,"eventCallback"),ro(this,"now"),ro(this,"contentDeliveredGetter",null),this.activityTree=t,this.eventCallback=i,this.now=(null==n?void 0:n.now)||function(){return new Date}}return t=e,(i=[{key:"setContentDeliveredGetter",value:function(e){this.contentDeliveredGetter=e}},{key:"validateTreeConsistency",value:function(e){if(!this.activityTree.root)return{consistent:!1,exception:"DB.1.1-4"};if(!this.isActivityPartOfTree(e,this.activityTree.root))return{consistent:!1,exception:"DB.1.1-5"};var t=this.getActiveActivities();if(t.length>1)return this.fireEvent("onStateInconsistency",{activeActivities:t.map(function(e){return e.id}),targetActivity:e.id}),{consistent:!1,exception:"DB.1.1-6"};for(var i=e;null==i?void 0:i.parent;){if(!i.parent.children.includes(i))return{consistent:!1,exception:"DB.1.1-7"};i=i.parent}return{consistent:!0,exception:null}}},{key:"validateResources",value:function(e){var t=this.getRequiredResources(e),i=!0,n=!1,r=void 0;try{for(var o,s=t[Symbol.iterator]();!(i=(o=s.next()).done);i=!0)if(!this.isResourceAvailable(o.value))return{available:!1,exception:"DB.1.1-8"}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return this.checkSystemLimits().adequate?{available:!0,exception:null}:{available:!1,exception:"DB.1.1-9"}}},{key:"validateConcurrentDelivery",value:function(e){return this.contentDeliveredGetter&&this.contentDeliveredGetter()&&this.activityTree.currentActivity&&this.activityTree.currentActivity!==e?{allowed:!1,exception:"DB.1.1-10"}:this.hasPendingDeliveryRequests()?{allowed:!1,exception:"DB.1.1-11"}:this.isDeliveryLocked()?{allowed:!1,exception:"DB.1.1-12"}:{allowed:!0,exception:null}}},{key:"validateDependencies",value:function(e){var t=this.getPrerequisites(e),i=!0,n=!1,r=void 0;try{for(var o,s=t[Symbol.iterator]();!(i=(o=s.next()).done);i=!0)if(!this.isPrerequisiteSatisfied(o.value,e))return{satisfied:!1,exception:"DB.1.1-13"}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}var a=this.getObjectiveDependencies(e),u=!0,l=!1,c=void 0;try{for(var d,f=a[Symbol.iterator]();!(u=(d=f.next()).done);u=!0)if(!this.isObjectiveDependencySatisfied(d.value))return{satisfied:!1,exception:"DB.1.1-14"}}catch(e){l=!0,c=e}finally{try{u||null==f.return||f.return()}finally{if(l)throw c}}return this.getSequencingRuleDependencies(e).satisfied?{satisfied:!0,exception:null}:{satisfied:!1,exception:"DB.1.1-15"}}},{key:"checkActivity",value:function(e){return!!e.isAvailable&&!!this.checkLimitConditions(e)}},{key:"checkLimitConditions",value:function(e){var result=!0,t="";if(null!==e.attemptLimit&&e.attemptLimit>0&&(e.attemptLimit>e.attemptCount||(result=!1,t="Attempt limit exceeded")),result&&e.attemptAbsoluteDurationLimit){var i=u(e.attemptAbsoluteDurationLimit,Ve);i>0&&(i>u(e.attemptAbsoluteDuration||"PT0H0M0S",Ve)||(result=!1,t="Attempt duration limit exceeded"))}if(result&&e.activityAbsoluteDurationLimit){var n=u(e.activityAbsoluteDurationLimit,Ve);n>0&&(n>u(e.activityAbsoluteDuration||"PT0H0M0S",Ve)||(result=!1,t="Activity duration limit exceeded"))}if(result&&e.beginTimeLimit){var r=this.now();new Date(e.beginTimeLimit)>r&&(result=!1,t="Not yet time to begin")}return result&&e.endTimeLimit&&this.now()>new Date(e.endTimeLimit)&&(result=!1,t="Time limit expired"),this.fireEvent("onLimitConditionCheck",{activity:e,result:result,failureReason:t,checks:{attemptLimit:e.attemptLimit,attemptCount:e.attemptCount,attemptDurationLimit:e.attemptAbsoluteDurationLimit,activityDurationLimit:e.activityAbsoluteDurationLimit,beginTimeLimit:e.beginTimeLimit,endTimeLimit:e.endTimeLimit}}),result}},{key:"isActivityPartOfTree",value:function(e,t){if(e===t)return!0;var i=!0,n=!1,r=void 0;try{for(var o,s=t.children[Symbol.iterator]();!(i=(o=s.next()).done);i=!0)if(this.isActivityPartOfTree(e,o.value))return!0}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return!1}},{key:"getActiveActivities",value:function(){var e=[];return this.activityTree.root&&this.collectActiveActivities(this.activityTree.root,e),e}},{key:"collectActiveActivities",value:function(e,t){e.isActive&&t.push(e);var i=!0,n=!1,r=void 0;try{for(var o,s=e.children[Symbol.iterator]();!(i=(o=s.next()).done);i=!0)this.collectActiveActivities(o.value,t)}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}},{key:"getRequiredResources",value:function(e){var t=[],i=(e.title+" "+e.location).toLowerCase();return(i.includes("video")||i.includes("multimedia"))&&t.push("video-codec"),(i.includes("audio")||i.includes("sound"))&&t.push("audio-codec"),(i.includes("flash")||i.includes(".swf"))&&t.push("flash-plugin"),(i.includes("java")||i.includes("applet"))&&t.push("java-runtime"),e.children&&e.children.length>0&&t.push("high-bandwidth"),e.attemptAbsoluteDurationLimit&&this.parseDurationToMinutes(e.attemptAbsoluteDurationLimit)>60&&t.push("extended-storage"),e.attemptLimit&&e.attemptLimit>1&&t.push("persistent-storage"),t}},{key:"isResourceAvailable",value:function(e){try{switch(e){case"video-codec":return!!document.createElement("video").canPlayType;case"audio-codec":return!!document.createElement("audio").canPlayType;case"flash-plugin":return navigator.plugins&&Array.from(navigator.plugins).some(function(e){return"Shockwave Flash"===e.name});case"java-runtime":return navigator.plugins&&Array.from(navigator.plugins).some(function(e){return"Java"===e.name});case"high-bandwidth":if("connection"in navigator){var t=navigator.connection;return"4g"===t.effectiveType||t.downlink>5}return!0;case"extended-storage":default:return!0;case"persistent-storage":return"localStorage"in window&&"sessionStorage"in window}}catch(e){return!1}}},{key:"checkSystemLimits",value:function(){try{var e=!0;if("memory"in performance){var t=performance.memory;t.usedJSHeapSize/t.jsHeapSizeLimit>.8&&(e=!1)}if("deviceMemory"in navigator&&2>navigator.deviceMemory&&(e=!1),"hardwareConcurrency"in navigator&&2>navigator.hardwareConcurrency&&(e=!1),"connection"in navigator){var i=navigator.connection;(i.saveData||"slow-2g"===i.effectiveType)&&(e=!1)}return{adequate:e}}catch(e){return{adequate:!0}}}},{key:"hasPendingDeliveryRequests",value:function(){return this.activityTree&&this.activityTree.pendingRequests?this.activityTree.pendingRequests.length>0:!("undefined"==typeof window||!window.pendingScormRequests)&&window.pendingScormRequests>0}},{key:"isDeliveryLocked",value:function(){return!((!this.activityTree||!this.activityTree.navigationLocked)&&(!this.activityTree||!this.activityTree.terminationInProgress)&&this.checkSystemLimits().adequate&&("undefined"==typeof window||!window.scormMaintenanceMode))}},{key:"getPrerequisites",value:function(e){var t,i=[];if(e.sequencingRules&&e.sequencingRules.preConditionRules){var n=!0,r=!1,o=void 0;try{for(var s,a=e.sequencingRules.preConditionRules[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value;if(u.conditions&&u.conditions.length>0){var l=!0,c=!1,d=void 0;try{for(var f,v=u.conditions[Symbol.iterator]();!(l=(f=v.next()).done);l=!0){var h=f.value;h.referencedObjectiveID&&h.referencedObjectiveID!==e.id&&i.push(h.referencedObjectiveID)}}catch(e){c=!0,d=e}finally{try{l||null==v.return||v.return()}finally{if(c)throw d}}}}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}}if(e.parent&&e.sequencingControls&&!e.sequencingControls.choiceExit){var m=e.parent.children;if(m)for(var p=m.indexOf(e),y=0;p>y;y++){var g=m[y];g&&i.push(g.id)}}return e.prerequisiteActivities&&(t=i).push.apply(t,io(e.prerequisiteActivities)),Array.from(new Set(i))}},{key:"isPrerequisiteSatisfied",value:function(e,t){var i=this.activityTree.getActivity(e);return!!i&&"completed"===i.completionStatus}},{key:"getObjectiveDependencies",value:function(e){var t=[],objectives=e.objectives;if(objectives&&objectives.length>0){var i=!0,n=!1,r=void 0;try{for(var o,s=objectives[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value;a.globalObjectiveID&&t.push(a.globalObjectiveID),!a.satisfiedByMeasure&&a.readNormalizedMeasure&&t.push(a.id+"_measure")}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}if(e.sequencingRules){var u=io(e.sequencingRules.preConditionRules||[]).concat(io(e.sequencingRules.exitConditionRules||[]),io(e.sequencingRules.postConditionRules||[])),l=!0,c=!1,d=void 0;try{for(var f,v=u[Symbol.iterator]();!(l=(f=v.next()).done);l=!0){var h=f.value;if(h.conditions&&h.conditions.length>0){var m=!0,p=!1,y=void 0;try{for(var g,_=h.conditions[Symbol.iterator]();!(m=(g=_.next()).done);m=!0){var b=g.value;b.objectiveReference&&b.objectiveReference!==e.id&&t.push(b.objectiveReference)}}catch(e){p=!0,y=e}finally{try{m||null==_.return||_.return()}finally{if(p)throw y}}}}}catch(e){c=!0,d=e}finally{try{l||null==v.return||v.return()}finally{if(c)throw d}}}return Array.from(new Set(t))}},{key:"isObjectiveDependencySatisfied",value:function(e){if(this.activityTree&&this.activityTree.globalObjectives){var t=this.activityTree.globalObjectives[e];if(t)return!0===t.satisfied&&!0===t.statusKnown}if(e.endsWith("_measure")){var i=e.replace("_measure","");if(this.activityTree&&this.activityTree.globalObjectives){var n=this.activityTree.globalObjectives[i];if(n)return!0===n.measureKnown&&n.normalizedMeasure>=0}}var r=this.activityTree.getActivity(e);return!!r&&r.objectiveSatisfiedStatus&&r.objectiveMeasureStatus}},{key:"getSequencingRuleDependencies",value:function(e){var t=!0;try{if(e.sequencingRules&&e.sequencingRules.preConditionRules){var i=!0,n=!1,r=void 0;try{for(var o,s=e.sequencingRules.preConditionRules[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value;if(a.conditions&&a.conditions.length>0){var u=!0,l=!1,c=void 0;try{for(var d,f=a.conditions[Symbol.iterator]();!(u=(d=f.next()).done);u=!0){var v=d.value;switch(v.conditionType||v.condition){case"activityProgressKnown":e.progressMeasureStatus||(t=!1);break;case"objectiveStatusKnown":case"objectiveSatisfied":this.isObjectiveDependencySatisfied(v.referencedObjectiveID||e.id)||(t=!1);break;case"attemptLimitExceeded":null===e.attemptLimit&&(t=!1);break;case"timeLimitExceeded":e.attemptAbsoluteDurationLimit||e.activityAbsoluteDurationLimit||(t=!1);break;case"always":case"never":break;default:t=!1}}}catch(e){l=!0,c=e}finally{try{u||null==f.return||f.return()}finally{if(l)throw c}}}}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}if(e.sequencingRules&&e.sequencingRules.exitConditionRules){var h=!0,m=!1,p=void 0;try{for(var y,g=e.sequencingRules.exitConditionRules[Symbol.iterator]();!(h=(y=g.next()).done);h=!0){var _=y.value;if(_.conditions&&_.conditions.length>0){var b=!0,S=!1,w=void 0;try{for(var C,O=_.conditions[Symbol.iterator]();!(b=(C=O.next()).done);b=!0){var E=C.value;["objectiveStatusKnown","objectiveSatisfied"].includes(E.conditionType||E.condition)&&(this.isObjectiveDependencySatisfied(E.referencedObjectiveID||e.id)||(t=!1))}}catch(e){S=!0,w=e}finally{try{b||null==O.return||O.return()}finally{if(S)throw w}}}}}catch(e){m=!0,p=e}finally{try{h||null==g.return||g.return()}finally{if(m)throw p}}}if(e.rollupRules&&e.rollupRules.rules){var A=!0,k=!1,j=void 0;try{for(var R,M=e.rollupRules.rules[Symbol.iterator]();!(A=(R=M.next()).done);A=!0){var T=R.value;if(T.conditions&&T.conditions.length>0&&e.children&&e.children.length>0){var P=!0,I=!1,x=void 0;try{for(var N,D=e.children[Symbol.iterator]();!(P=(N=D.next()).done);P=!0)if(!N.value.isCompleted){t=!1;break}}catch(e){I=!0,x=e}finally{try{P||null==D.return||D.return()}finally{if(I)throw x}}}}}catch(e){k=!0,j=e}finally{try{A||null==M.return||M.return()}finally{if(k)throw j}}}}catch(e){t=!1}return{satisfied:t}}},{key:"parseDurationToMinutes",value:function(e){return u(e,Ve)/60}},{key:"fireEvent",value:function(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn("Failed to fire delivery validator event ".concat(e,": ").concat(t))}}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var so=Object.defineProperty,ao=function(e,t,i){return function(e,t,i){return t in e?so(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},uo=function(){function e(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,s=arguments.length>5?arguments[5]:void 0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ao(this,"activityTree"),ao(this,"sequencingProcess"),ao(this,"rollupProcess"),ao(this,"adlNav"),ao(this,"eventCallback",null),ao(this,"terminationHandler"),ao(this,"deliveryHandler"),ao(this,"navigationValidityService"),ao(this,"globalObjectiveService"),ao(this,"stateManager"),ao(this,"deliveryValidator"),ao(this,"navigationLookAhead"),ao(this,"enhancedDeliveryValidation"),ao(this,"is4thEdition"),this.activityTree=t,this.sequencingProcess=i,this.rollupProcess=n,this.adlNav=r,this.eventCallback=o,this.enhancedDeliveryValidation=!0===(null==s?void 0:s.enhancedDeliveryValidation),this.is4thEdition=(null==s?void 0:s.is4thEdition)||!1,this.globalObjectiveService=new Xr(o||void 0),this.globalObjectiveService.initialize(t.root);var a={};(null==s?void 0:s.now)&&(a.now=s.now),this.deliveryValidator=new oo(t,o,a);var u={};(null==s?void 0:s.getCMIData)&&(u.getCMIData=s.getCMIData),void 0!==(null==s?void 0:s.is4thEdition)&&(u.is4thEdition=s.is4thEdition),this.terminationHandler=new Or(t,i,n,this.globalObjectiveService.getMap(),o,u);var l={};(null==s?void 0:s.now)&&(l.now=s.now),(null==s?void 0:s.defaultHideLmsUi)&&(l.defaultHideLmsUi=s.defaultHideLmsUi),(null==s?void 0:s.defaultAuxiliaryResources)&&(l.defaultAuxiliaryResources=s.defaultAuxiliaryResources),this.deliveryHandler=new xr(t,n,this.globalObjectiveService.getMap(),r,o,l),this.navigationValidityService=new Hr(t,i,r,o),this.stateManager=new eo(t,this.globalObjectiveService,n,r,o),this.navigationLookAhead=this.navigationValidityService.getNavigationLookAhead(),this.setupCallbacks()}return t=e,i=[{key:"setupCallbacks",value:function(){var e=this;this.terminationHandler.setInvalidateCacheCallback(function(){e.navigationLookAhead.invalidateCache()}),this.deliveryHandler.setCheckActivityCallback(function(t){return e.deliveryValidator.checkActivity(t)}),this.deliveryHandler.setInvalidateCacheCallback(function(){e.navigationLookAhead.invalidateCache()}),this.deliveryHandler.setUpdateNavigationValidityCallback(function(){e.navigationValidityService.updateNavigationValidity()}),this.deliveryHandler.setClearSuspendedActivityCallback(function(){e.terminationHandler.clearSuspendedActivity()}),this.deliveryValidator.setContentDeliveredGetter(function(){return e.deliveryHandler.hasContentBeenDelivered()}),this.navigationValidityService.setGetEffectiveHideLmsUiCallback(function(t){return e.deliveryHandler.getEffectiveHideLmsUi(t)}),this.stateManager.setGetEffectiveHideLmsUiCallback(function(t){return e.deliveryHandler.getEffectiveHideLmsUi(t)}),this.stateManager.setGetEffectiveAuxiliaryResourcesCallback(function(t){return e.deliveryHandler.getEffectiveAuxiliaryResources(t)}),this.stateManager.setContentDeliveredAccessors(function(){return e.deliveryHandler.hasContentBeenDelivered()},function(t){return e.deliveryHandler.setContentDelivered(t)})}},{key:"processNavigationRequest",value:function(e){var t=arguments.length>2?arguments[2]:void 0,i=this.navigationValidityService.validateRequest(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null);if(!i.valid)return new Pr(!1,null,i.exception);if(i.terminationRequest){var n=!!i.sequencingRequest,r=this.terminationHandler.processTerminationRequest(i.terminationRequest,n,t);if(!r.valid)return new Pr(!1,null,r.exception||"TB.2.3-1");if(null!==r.sequencingRequest&&(n||r.sequencingRequest!==xt.EXIT)&&(i.sequencingRequest=r.sequencingRequest),!i.sequencingRequest)return i.terminationRequest!==xt.EXIT_ALL&&i.terminationRequest!==xt.ABANDON_ALL||this.fireEvent("onSequencingSessionEnd",{reason:i.terminationRequest===xt.EXIT_ALL?"exit_all":"abandon_all",navigationRequest:e}),new Pr(!0,null)}if(i.sequencingRequest){var o=this.sequencingProcess.sequencingRequestProcess(i.sequencingRequest,i.targetActivityId);if(o.endSequencingSession)return this.fireEvent("onSequencingSessionEnd",{reason:"end_of_content",exception:o.exception,navigationRequest:e}),new Pr(!1,null,o.exception||"SESSION_ENDED");if(o.exception)return new Pr(!1,null,o.exception);if(o.deliveryRequest===Nt.DELIVER&&o.targetActivity)return this.activityTree.root&&(this.rollupProcess.validateRollupStateConsistency(this.activityTree.root)||this.fireEvent("onSequencingDebug",{message:"Rollup state inconsistency detected before delivery",activityId:this.activityTree.root.id})),this.rollupProcess.processGlobalObjectiveMapping(o.targetActivity,this.globalObjectiveService.getMap()),this.processDelivery(o.targetActivity)}return new Pr(!1,null,"OP.1-1")}},{key:"processDelivery",value:function(e){if(this.enhancedDeliveryValidation){var t=this.deliveryValidator.validateTreeConsistency(e);if(!t.consistent)return new Pr(!1,null,t.exception);var i=this.deliveryValidator.validateResources(e);if(!i.available)return new Pr(!1,null,i.exception);var n=this.deliveryValidator.validateConcurrentDelivery(e);if(!n.allowed)return new Pr(!1,null,n.exception);var r=this.deliveryValidator.validateDependencies(e);if(!r.satisfied)return new Pr(!1,null,r.exception)}var o=this.deliveryHandler.processDeliveryRequest(e);return o.valid&&(this.deliveryHandler.contentDeliveryEnvironmentProcess(o.targetActivity),this.navigationLookAhead.invalidateCache(),this.activityTree.root&&this.rollupProcess.validateRollupStateConsistency(this.activityTree.root)),o}},{key:"hasContentBeenDelivered",value:function(){return this.deliveryHandler.hasContentBeenDelivered()}},{key:"isDeliveryInProgress",value:function(){return this.deliveryHandler.isDeliveryInProgress()}},{key:"resetContentDelivered",value:function(){this.deliveryHandler.resetContentDelivered()}},{key:"setContentDelivered",value:function(e){this.deliveryHandler.setContentDelivered(e)}},{key:"updateNavigationValidity",value:function(){this.navigationValidityService.updateNavigationValidity()}},{key:"synchronizeGlobalObjectives",value:function(){this.globalObjectiveService.synchronize(this.activityTree.root,this.rollupProcess)}},{key:"getGlobalObjectiveMap",value:function(){return this.globalObjectiveService.getMap()}},{key:"getGlobalObjectiveMapSnapshot",value:function(){return this.globalObjectiveService.getSnapshot()}},{key:"restoreGlobalObjectiveMapSnapshot",value:function(e){this.globalObjectiveService.restoreSnapshot(e)}},{key:"updateGlobalObjective",value:function(e,t){this.globalObjectiveService.updateObjective(e,t)}},{key:"getSequencingState",value:function(){return this.stateManager.getState()}},{key:"restoreSequencingState",value:function(e){return this.stateManager.restoreState(e)}},{key:"getSuspensionState",value:function(){return this.stateManager.getSuspensionState()}},{key:"restoreSuspensionState",value:function(e){this.stateManager.restoreSuspensionState(e)}},{key:"getNavigationLookAhead",value:function(){return this.navigationValidityService.getAllPredictions()}},{key:"predictContinueEnabled",value:function(){return this.navigationValidityService.predictContinueEnabled()}},{key:"predictPreviousEnabled",value:function(){return this.navigationValidityService.predictPreviousEnabled()}},{key:"predictChoiceEnabled",value:function(e){return this.navigationValidityService.predictChoiceEnabled(e)}},{key:"getAvailableChoices",value:function(){return this.navigationValidityService.getAvailableChoices()}},{key:"invalidateNavigationCache",value:function(){this.navigationValidityService.invalidateCache()}},{key:"applyDeliveryControls",value:function(e){e.sequencingControls.completionSetByContent||e.completionStatus===Oe&&(e.completionStatus=we,e.wasAutoCompleted=!0),e.sequencingControls.objectiveSetByContent||e.successStatus===Se&&(e.successStatus=_e,e.wasAutoSatisfied=!0)}},{key:"getEffectiveHideLmsUi",value:function(e){return this.deliveryHandler.getEffectiveHideLmsUi(e)}},{key:"getEffectiveAuxiliaryResources",value:function(e){return this.deliveryHandler.getEffectiveAuxiliaryResources(e)}},{key:"getContentActivityData",value:function(e){return this.deliveryHandler.getContentActivityData(e)}},{key:"terminationRequestProcess",value:function(request,e,t){return this.terminationHandler.processTerminationRequest(request,e,t)}},{key:"contentDeliveryEnvironmentProcess",value:function(e){this.deliveryHandler.contentDeliveryEnvironmentProcess(e)}},{key:"endAttemptProcess",value:function(e){this.terminationHandler.endAttempt(e)}},{key:"handleExitTermination",value:function(e,t){return this.terminationHandler.handleExitTermination(e,t)}},{key:"fireEvent",value:function(e,t){try{this.eventCallback&&this.eventCallback(e,t)}catch(t){console.warn("Failed to fire sequencing event ".concat(e,": ").concat(t))}}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function lo(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function co(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function fo(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){co(e,t,i[t])})}return e}function vo(e){return function(e){if(Array.isArray(e))return lo(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return lo(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?lo(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ho=Object.defineProperty,mo=function(e,t,i){return function(e,t,i){return t in e?ho(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},po=function(){function e(t,cmi,adl,i,n){var r=this,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),mo(this,"sequencing"),mo(this,"cmi"),mo(this,"adl"),mo(this,"eventService"),mo(this,"loggingService"),mo(this,"activityDeliveryService"),mo(this,"rollupProcess"),mo(this,"overallSequencingProcess",null),mo(this,"sequencingProcess",null),mo(this,"eventListeners",{}),mo(this,"configuration"),mo(this,"isInitialized",!1),mo(this,"isSequencingActive",!1),mo(this,"lastCMIValues",new Map),mo(this,"lastSequencingResult",null),this.sequencing=t,this.cmi=cmi,this.adl=adl,this.eventService=i,this.loggingService=n,this.configuration=fo({autoRollupOnCMIChange:!0,autoProgressOnCompletion:!1,validateNavigationRequests:!0,enableEventSystem:!0,logLevel:"info",now:function(){return new Date}},o),this.activityDeliveryService=new wi(i,n,{onDeliverActivity:function(e){return r.handleActivityDelivery(e)},onUnloadActivity:function(e){return r.handleActivityUnload(e)},onSequencingComplete:function(result){return r.handleSequencingComplete(result)},onSequencingError:function(e){return r.handleSequencingError(e)}}),this.rollupProcess=new mr,this.configuration.now&&Ct.setNowProvider(this.configuration.now),this.setupCMIChangeWatchers(),this.createSequencingProcesses()}return t=e,i=[{key:"createSequencingProcesses",value:function(){var e=this;try{if(this.sequencing.initialized||this.sequencing.initialize(),this.sequencing.adlNav=this.adl.nav,this.sequencing.activityTree.root){var t={};this.configuration.now&&(t.now=this.configuration.now),this.configuration.getAttemptElapsedSeconds&&(t.getAttemptElapsedSeconds=this.configuration.getAttemptElapsedSeconds),this.configuration.getActivityElapsedSeconds&&(t.getActivityElapsedSeconds=this.configuration.getActivityElapsedSeconds),this.sequencingProcess=new gi(this.sequencing.activityTree,this.sequencing.sequencingRules,this.sequencing.sequencingControls,this.adl.nav,t);var i={};this.configuration.now&&(i.now=this.configuration.now),i.defaultHideLmsUi=vo(this.sequencing.hideLmsUi),this.sequencing.auxiliaryResources.length>0&&(i.defaultAuxiliaryResources=this.sequencing.auxiliaryResources.map(function(e){return{resourceId:e.resourceId,purpose:e.purpose}})),i.getCMIData=function(){return e.getCMIDataForTransfer()},this.overallSequencingProcess=new uo(this.sequencing.activityTree,this.sequencingProcess,this.rollupProcess,this.adl.nav,function(t,i){return e.handleSequencingProcessEvent(t,i)},i),this.sequencing.overallSequencingProcess=this.overallSequencingProcess,this.isInitialized=!0,this.log("info","Sequencing processes created and ready for navigation")}}catch(e){this.log("error","Failed to create sequencing processes: ".concat(e))}}},{key:"initialize",value:function(){try{return this.log("info","Initializing sequencing service for SCO session"),this.isInitialized||this.createSequencingProcesses(),this.shouldAutoStartSequencing()&&!this.isSequencingActive&&this.startSequencing(),this.initializeCMITracking(),this.fireEvent("onSequencingStart",this.sequencing.getCurrentActivity()),this.log("info","Sequencing service initialized successfully"),z}catch(t){var e="Failed to initialize sequencing service: ".concat(t);return this.log("error",e),this.fireEvent("onSequencingError",e,"initialization"),F}}},{key:"terminate",value:function(){try{return this.log("info","Terminating sequencing service"),this.triggerFinalRollup(),this.endSequencing(),this.isInitialized=!1,this.fireEvent("onSequencingEnd"),this.log("info","Sequencing service terminated successfully"),z}catch(t){var e="Failed to terminate sequencing service: ".concat(t);return this.log("error",e),this.fireEvent("onSequencingError",e,"termination"),F}}},{key:"processNavigationRequest",value:function(request,e,t){if(!this.isInitialized||!this.overallSequencingProcess)return this.log("warn","Navigation request '".concat(request,"' ignored - sequencing not initialized")),!1;try{this.log("info","Processing navigation request: ".concat(request).concat(e?" (target: ".concat(e,")"):"").concat(t?" (exit: ".concat(t,")"):"")),this.fireEvent("onNavigationRequest",request,e);var i=this.parseNavigationRequest(request);if(null===i)return this.log("warn","Invalid navigation request: ".concat(request)),!1;var n=this.overallSequencingProcess.processNavigationRequest(i,e||null,t),r={deliveryRequest:n.valid?Nt.DELIVER:Nt.DO_NOT_DELIVER,targetActivity:n.targetActivity,exception:n.exception||null,endSequencingSession:!1};return this.lastSequencingResult=r,n.valid&&n.targetActivity?(this.activityDeliveryService.processSequencingResult(r),this.overallSequencingProcess.updateNavigationValidity(),this.log("info","Navigation request '".concat(request,"' resulted in activity delivery: ").concat(n.targetActivity.id)),!0):(n.exception?(this.log("warn","Navigation request '".concat(request,"' failed: ").concat(n.exception)),this.fireEvent("onSequencingError",n.exception,"navigation")):this.log("info","Navigation request '".concat(request,"' completed with no activity delivery")),n.valid)}catch(e){var o="Error processing navigation request '".concat(request,"': ").concat(e);return this.log("error",o),this.fireEvent("onSequencingError",o,"navigation"),!1}}},{key:"triggerRollupOnCMIChange",value:function(e,t,i){if(this.configuration.autoRollupOnCMIChange&&this.isInitialized&&["cmi.completion_status","cmi.success_status","cmi.score.scaled","cmi.score.raw","cmi.score.min","cmi.score.max","cmi.progress_measure","cmi.objectives.n.success_status","cmi.objectives.n.completion_status","cmi.objectives.n.score.scaled"].some(function(t){return e.startsWith(t)}))try{this.log("debug","Triggering rollup due to CMI change: ".concat(e," = ").concat(i," (was ").concat(t,")"));var n=this.sequencing.getCurrentActivity();if(!n)return void this.log("debug","No current activity for rollup");this.updateActivityFromCMI(n),this.rollupProcess.overallRollupProcess(n),this.overallSequencingProcess&&this.overallSequencingProcess.synchronizeGlobalObjectives(),this.overallSequencingProcess&&this.overallSequencingProcess.updateNavigationValidity(),this.fireEvent("onRollupComplete",n),this.log("debug","Rollup completed for activity: ".concat(n.id))}catch(e){var r="Error during rollup on CMI change: ".concat(e);this.log("error",r),this.fireEvent("onSequencingError",r,"rollup")}}},{key:"setEventListeners",value:function(e){this.eventListeners=fo({},this.eventListeners,e),this.log("debug","Sequencing event listeners updated")}},{key:"updateConfiguration",value:function(e){this.configuration=fo({},this.configuration,e),this.log("debug","Sequencing configuration updated")}},{key:"getSequencingState",value:function(){return{isInitialized:this.isInitialized,isActive:this.isSequencingActive,currentActivity:this.sequencing.getCurrentActivity(),rootActivity:this.sequencing.getRootActivity(),lastSequencingResult:this.lastSequencingResult}}},{key:"getOverallSequencingProcess",value:function(){return this.overallSequencingProcess}},{key:"isDeliveryInProgress",value:function(){var e,t;return null!==(e=null===(t=this.overallSequencingProcess)||void 0===t?void 0:t.isDeliveryInProgress())&&void 0!==e&&e}},{key:"setupCMIChangeWatchers",value:function(){}},{key:"initializeCMITracking",value:function(){this.lastCMIValues.set("cmi.completion_status",this.cmi.completion_status),this.lastCMIValues.set("cmi.success_status",this.cmi.success_status),this.lastCMIValues.set("cmi.progress_measure",this.cmi.progress_measure),this.cmi.score&&(this.lastCMIValues.set("cmi.score.scaled",this.cmi.score.scaled),this.lastCMIValues.set("cmi.score.raw",this.cmi.score.raw))}},{key:"shouldAutoStartSequencing",value:function(){return!(!this.sequencing.activityTree.root||this.sequencing.getCurrentActivity())}},{key:"startSequencing",value:function(){if(this.overallSequencingProcess)try{this.processNavigationRequest("start")&&(this.isSequencingActive=!0,this.log("info","Automatic sequencing started"))}catch(e){this.log("error","Failed to start automatic sequencing: ".concat(e))}}},{key:"endSequencing",value:function(){this.isSequencingActive=!1,this.activityDeliveryService.reset()}},{key:"triggerFinalRollup",value:function(){try{var e=this.sequencing.getCurrentActivity();e&&(this.updateActivityFromCMI(e),this.rollupProcess.overallRollupProcess(e),this.overallSequencingProcess&&this.overallSequencingProcess.synchronizeGlobalObjectives(),this.log("info","Final rollup completed"))}catch(e){this.log("error","Error during final rollup: ".concat(e))}}},{key:"updateActivityFromCMI",value:function(e){if("unknown"!==this.cmi.completion_status&&(e.completionStatus=this.cmi.completion_status,e.attemptProgressStatus=!0),"unknown"!==this.cmi.success_status&&(e.successStatus=this.cmi.success_status,e.objectiveSatisfiedStatus="passed"===this.cmi.success_status,e.objectiveMeasureStatus=!0,e.primaryObjective&&(e.primaryObjective.progressStatus=!0)),""!==this.cmi.progress_measure){var t=parseFloat(this.cmi.progress_measure);isNaN(t)||(e.progressMeasure=t,e.progressMeasureStatus=!0)}if(this.cmi.score&&""!==this.cmi.score.scaled){var i=parseFloat(this.cmi.score.scaled);isNaN(i)||(e.objectiveNormalizedMeasure=i,e.objectiveMeasureStatus=!0,e.primaryObjective&&(e.primaryObjective.progressStatus=!0))}e.primaryObjective&&e.primaryObjective.updateFromActivity(e)}},{key:"getCMIDataForTransfer",value:function(){var e,t,i,n,r={completion_status:this.cmi.completion_status,success_status:this.cmi.success_status,progress_measure:this.cmi.progress_measure,score:{scaled:(null===(e=this.cmi.score)||void 0===e?void 0:e.scaled)||"",raw:(null===(t=this.cmi.score)||void 0===t?void 0:t.raw)||"",min:(null===(i=this.cmi.score)||void 0===i?void 0:i.min)||"",max:(null===(n=this.cmi.score)||void 0===n?void 0:n.max)||""},objectives:[]};if(this.cmi.objectives&&this.cmi.objectives.childArray){var o=!0,s=!1,a=void 0;try{for(var u,l=this.cmi.objectives.childArray[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var c,d,f,v,h=u.value;h.id&&r.objectives.push({id:h.id,success_status:h.success_status,completion_status:h.completion_status,progress_measure:h.progress_measure,score:{scaled:(null===(c=h.score)||void 0===c?void 0:c.scaled)||"",raw:(null===(d=h.score)||void 0===d?void 0:d.raw)||"",min:(null===(f=h.score)||void 0===f?void 0:f.min)||"",max:(null===(v=h.score)||void 0===v?void 0:v.max)||""}})}}catch(e){s=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}}return r}},{key:"parseNavigationRequest",value:function(request){var e=request;if(e.startsWith("_")&&"_none_"!==e&&(e=e.substring(1)),request.includes("choice"))return Br.CHOICE;if(request.includes("jump"))return Br.JUMP;switch(e){case"start":return Br.START;case"resumeAll":return Br.RESUME_ALL;case"continue":return Br.CONTINUE;case"previous":return Br.PREVIOUS;case"exit":return Br.EXIT;case"exitAll":return Br.EXIT_ALL;case"abandon":return Br.ABANDON;case"abandonAll":return Br.ABANDON_ALL;case"suspendAll":return Br.SUSPEND_ALL;case"_none_":return Br.NOT_VALID;default:return null}}},{key:"handleActivityDelivery",value:function(e){this.log("info","Activity delivered: ".concat(e.id," - ").concat(e.title)),this.fireEvent("onActivityDelivery",e)}},{key:"handleActivityUnload",value:function(e){this.log("info","Activity unloaded: ".concat(e.id," - ").concat(e.title)),this.fireEvent("onActivityUnload",e)}},{key:"handleSequencingComplete",value:function(result){this.log("debug","Sequencing completed",result)}},{key:"handleSequencingError",value:function(e){this.log("error","Sequencing error: ".concat(e)),this.fireEvent("onSequencingError",e,"sequencing")}},{key:"fireEvent",value:function(e){for(var t=arguments.length,i=Array(t>1?t-1:0),n=1;t>n;n++)i[n-1]=arguments[n];if(this.configuration.enableEventSystem){"onSequencingDebug"!==e&&this.fireDebugEvent("".concat(e," fired"),{eventType:e,argsLength:i.length});try{var r=this.eventListeners[e];if(r&&"function"==typeof r)try{r.apply(void 0,vo(i)),this.log("debug","Internal listener for ".concat(e," executed successfully"))}catch(t){this.log("error","Internal listener for ".concat(e," failed: ").concat(t))}try{var o;(o=this.eventService).processListeners.apply(o,["Sequencing.".concat(e),i[0]].concat(vo(i.slice(1)))),this.log("debug","Event service listeners for ".concat(e," processed"))}catch(t){this.log("warn","Event service failed for ".concat(e,": ").concat(t))}try{if("undefined"!=typeof window&&window.scormSequencingEvents){var s,a=window.scormSequencingEvents;a[e]&&"function"==typeof a[e]&&((s=a)[e].apply(s,vo(i)),this.log("debug","Global listener for ".concat(e," executed")))}}catch(t){this.log("warn","Global listener for ".concat(e," failed: ").concat(t))}}catch(t){this.log("error","Critical error firing event ".concat(e,": ").concat(t))}}}},{key:"fireDebugEvent",value:function(e,t){try{var i=this.eventListeners.onSequencingDebug;i&&"function"==typeof i&&i(e,fo({timestamp:(new Date).toISOString()},t));try{this.eventService.processListeners("Sequencing.onSequencingDebug",e,fo({timestamp:(new Date).toISOString()},t))}catch(e){}}catch(e){console.debug("Debug event failed: ".concat(e))}}},{key:"fireActivityAttemptStart",value:function(e){this.fireEvent("onActivityAttemptStart",e),this.fireDebugEvent("Activity attempt started",{activityId:e.id,title:e.title,attemptCount:e.attemptCount})}},{key:"fireActivityAttemptEnd",value:function(e){this.fireEvent("onActivityAttemptEnd",e),this.fireDebugEvent("Activity attempt ended",{activityId:e.id,title:e.title,completionStatus:e.completionStatus,successStatus:e.successStatus})}},{key:"fireLimitConditionCheck",value:function(e,result){this.fireEvent("onLimitConditionCheck",e,result),this.fireDebugEvent("Limit condition check",{activityId:e.id,result:result,attemptCount:e.attemptCount,attemptLimit:e.attemptLimit})}},{key:"fireNavigationValidityUpdate",value:function(e){this.fireEvent("onNavigationValidityUpdate",e),this.fireDebugEvent("Navigation validity updated",{validity:e})}},{key:"fireSequencingStateChange",value:function(e){this.fireEvent("onSequencingStateChange",e),this.fireDebugEvent("Sequencing state changed",{stateKeys:Object.keys(e)})}},{key:"handleSequencingProcessEvent",value:function(e,t){try{switch(e){case"onActivityDelivery":this.fireEvent("onActivityDelivery",t);break;case"onLimitConditionCheck":this.fireLimitConditionCheck(t.activity,t.result);break;case"onActivityAttemptStart":this.fireActivityAttemptStart(t);break;case"onActivityAttemptEnd":this.fireActivityAttemptEnd(t);break;case"onNavigationValidityUpdate":this.fireNavigationValidityUpdate(t);break;case"onSequencingSessionEnd":this.fireEvent("onSequencingSessionEnd",t);break;default:this.fireDebugEvent("Sequencing process event: ".concat(e),t)}}catch(t){this.log("error","Error handling sequencing process event ".concat(e,": ").concat(t))}}},{key:"log",value:function(e,t,i){var n=["debug","info","warn","error"],r=this.configuration.logLevel||"info";if(n.indexOf(e)>=n.indexOf(r))switch(e){case"debug":this.loggingService.debug("[Sequencing] ".concat(t).concat(i?" - ".concat(JSON.stringify(i)):""));break;case"info":this.loggingService.info("[Sequencing] ".concat(t).concat(i?" - ".concat(JSON.stringify(i)):""));break;case"warn":this.loggingService.warn("[Sequencing] ".concat(t).concat(i?" - ".concat(JSON.stringify(i)):""));break;case"error":this.loggingService.error("[Sequencing] ".concat(t).concat(i?" - ".concat(JSON.stringify(i)):""))}}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var yo=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return t=e,i=[{key:"loadFromFlattenedJSON",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;if(r()){var s=/^(cmi\.interactions\.)(\d+)\.(.*)$/,a=/^(cmi\.objectives\.)(\d+)\.(.*)$/,interactions=[],objectives=[],u=[];for(var l in e)if({}.hasOwnProperty.call(e,l)){var c=l.match(s);if(c){interactions.push({key:l,value:e[l],index:+c[2],field:c[3]||""});continue}var d=l.match(a);if(d){objectives.push({key:l,value:e[l],index:+d[2],field:d[3]||""});continue}u.push({key:l,value:e[l]})}interactions.sort(function(e,t){return e.index!==t.index?e.index-t.index:"id"===e.field?-1:"id"===t.field?1:"type"===e.field?-1:"type"===t.field?1:e.field.localeCompare(t.field)}),objectives.sort(function(e,t){return e.index!==t.index?e.index-t.index:"id"===e.field?-1:"id"===t.field?1:e.field.localeCompare(t.field)}),u.sort(function(e,t){return e.key.localeCompare(t.key)});var f=function(e){e.forEach(function(e){var s={};s[e.key]=e.value,t.loadFromJSON(function(e){var t;if(Object(e)!==e||Array.isArray(e))return e;var result={},pattern=/\.?([^.[\]]+)|\[(\d+)]/g;return Object.keys(e).filter(function(t){return{}.hasOwnProperty.call(e,t)}).forEach(function(t){var i,n,r=result,o="",s=RegExp(pattern);Array.from({length:null!==(i=null===(n=t.match(RegExp(pattern,"g")))||void 0===n?void 0:n.length)&&void 0!==i?i:0},function(){return s.exec(t)}).forEach(function(e){var t;e&&(r=null!==(t=r[o])&&void 0!==t?t:r[o]=e[2]?[]:{},o=e[2]||e[1]||"")}),r[o]=e[t]}),null!==(t=result[""])&&void 0!==t?t:result}(s),i,n,r,o)})};f(interactions),f(objectives),f(u)}else console.error("loadFromFlattenedJSON can only be called before the call to lmsInitialize.")}},{key:"loadFromJSON",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;if(n()){for(var o in t=void 0!==t?t:"cmi",r(e),e)if({}.hasOwnProperty.call(e,o)&&e[o]){var s=(t?t+".":"")+o,a=e[o];if(a.constructor===Array){for(var u=0;a.length>u;u++)if(a[u]){var l=a[u],c="".concat(s,".").concat(u);l.constructor===Object?this.loadFromJSON(l,c,i,n,r):i(c,l)}}else a.constructor===Object?this.loadFromJSON(a,s,i,n,r):i(s,a)}}else console.error("loadFromJSON can only be called before the call to lmsInitialize.")}},{key:"renderCMIToJSONString",value:function(cmi,e){return e?JSON.stringify({cmi:cmi}):JSON.stringify({cmi:cmi},function(e,t){return void 0===t?null:t},2)}},{key:"renderCMIToJSONObject",value:function(cmi,e){return JSON.parse(this.renderCMIToJSONString(cmi,e))}},{key:"getCommitObject",value:function(e,t,i,n,r,o){var s=t||e,a=i?n(e,s):r(e,s);return[Ee.DEBUG,"1",1,"DEBUG"].includes(o)&&(console.debug("Commit (terminated: "+(e?"yes":"no")+"): "),console.debug(a)),a}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function go(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function _o(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}var bo=Object.defineProperty,So=function(e,t,i){return function(e,t,i){return t in e?bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},wo=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),So(this,"settings"),So(this,"error_codes"),this.settings=t,this.error_codes=i}return t=e,i=[{key:"processHttpRequest",value:function(e,t){var i=arguments.length>5?arguments[5]:void 0;return arguments.length>2&&void 0!==arguments[2]&&arguments[2]?this._handleImmediateRequest(e,t,i):this._performSyncXHR(e,t,i)}},{key:"_handleImmediateRequest",value:function(e,t,i){var n=void 0===i?this.settings.requestHandler(t):this.settings.requestHandler(t,i),r=this._prepareRequestBody(null!=n?n:t).body,o=navigator.sendBeacon(e,new Blob([r],{type:"text/plain;charset=UTF-8"}));return{result:o?"true":"false",errorCode:o?0:this.error_codes.GENERAL_COMMIT_FAILURE||391}}},{key:"_performSyncXHR",value:function(e,t,i){var n=void 0===i?this.settings.requestHandler(t):this.settings.requestHandler(t,i),r=this._prepareRequestBody(null!=n?n:t),o=r.body,s=r.contentType,a=new XMLHttpRequest;a.open("POST",e,!1),a.setRequestHeader("Content-Type",s),Object.entries(this.settings.xhrHeaders).forEach(function(e){var t,i,n=(i=2,function(e){if(Array.isArray(e))return e}(t=e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,o=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}}(t,i)||function(e,t){if(e){if("string"==typeof e)return go(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?go(e,t):void 0}}(t,i)||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.")}());a.setRequestHeader(n[0],n[1]+"")}),this.settings.xhrWithCredentials&&(a.withCredentials=!0);try{return a.send(o),this.settings.xhrResponseHandler(a)}catch(e){var u=_o(e,Error)?e.message:e+"";return{result:F,errorCode:this.error_codes.GENERAL_COMMIT_FAILURE||391,errorMessage:u}}}},{key:"_prepareRequestBody",value:function(e){return{body:_o(e,Array)?e.join("&"):JSON.stringify(e),contentType:_o(e,Array)?"application/x-www-form-urlencoded":this.settings.commitRequestDataType}}},{key:"updateSettings",value:function(e){this.settings=e}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Co(e,t,i,n){return an(e,t,i,ae.TYPE_MISMATCH,K,n)}function Oo(e,t,i,n){if(""===t)throw new K(e,ae.VALUE_OUT_OF_RANGE);return un(e,t,i,ae.VALUE_OUT_OF_RANGE,K)}var Eo=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return t=e,i=[{key:"validateScore",value:function(e,t,i,n,r,o,s){return!(7>=arguments.length||void 0===arguments[7]||!arguments[7]||""!==t)||an(e,t,i,r,s)&&(!n||un(e,t,n,o,s))}},{key:"validateScorm12Audio",value:function(e,t){return Co(e,t,Te)&&Oo(e,t,"-1#100")}},{key:"validateScorm12Language",value:function(e,t){return Co(e,t,Re)}},{key:"validateScorm12Speed",value:function(e,t){return Co(e,t,Te)&&Oo(e,t,"-100#100")}},{key:"validateScorm12Text",value:function(e,t){return Co(e,t,Te)&&Oo(e,t,"-1#1")}},{key:"validateReadOnly",value:function(e,t){if(t)throw new K(e,ae.READ_ONLY_ELEMENT)}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}(),Ao=new Eo;function ko(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function jo(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Ro(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function Mo(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){jo(e,t,i[t])})}return e}function To(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t}(Object(t)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}function Po(e){return function(e){if(Array.isArray(e))return ko(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return ko(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?ko(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Io(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var xo=Object.defineProperty,No=function(e,t,i){return function(e,t,i){return t in e?xo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Io(t))?t+"":t,i)},Do=function(){function e(t,i,n,r,o,s,a,u,l){var c=this;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),No(this,"_timeout"),No(this,"_error_codes"),No(this,"_settings",ke),No(this,"_httpService"),No(this,"_eventService"),No(this,"_serializationService"),No(this,"_errorHandlingService"),No(this,"_loggingService"),No(this,"_offlineStorageService"),No(this,"_cmiValueAccessService"),No(this,"_courseId",""),No(this,"_pendingCommitCount",0),No(this,"_commitSequence",0),No(this,"_commitSettleWaiters",[]),No(this,"_setCMIElements",new Set),No(this,"startingData"),No(this,"currentState"),(Ro(this,e)?this.constructor:void 0)===e)throw new TypeError("Cannot construct BaseAPI instances directly");this.currentState=0,this._error_codes=t,i&&(this.settings=Mo({},ke,i)),void 0!==(null==i?void 0:i.asyncCommit)&&void 0===i.useAsynchronousCommits&&void 0===i.throttleCommits&&(console.warn("DEPRECATED: 'asyncCommit' setting is deprecated and will be removed in a future version. Use 'useAsynchronousCommits: true' and 'throttleCommits: true' instead."),i.asyncCommit&&(this.settings.useAsynchronousCommits=!0,this.settings.throttleCommits=!0)),!this.settings.useAsynchronousCommits&&this.settings.throttleCommits&&(console.warn("throttleCommits cannot be used with synchronous commits. Setting throttleCommits to false."),this.settings.throttleCommits=!1),this._loggingService=u||Vi(),this._loggingService.setLogLevel(this.settings.logLevel),this._loggingService.setLogHandler(this.settings.onLogMessage?this.settings.onLogMessage:je),n?this._httpService=n:this.settings.httpService?this._httpService=this.settings.httpService:this.settings.useAsynchronousCommits?(console.warn("WARNING: useAsynchronousCommits=true is not SCORM compliant. Commit failures will not be reported to the SCO, which may cause data loss. This setting should only be used for specific legacy compatibility cases."),this._httpService=new Ti(this.settings,this._error_codes)):this._httpService=new wo(this.settings,this._error_codes),this._eventService=r||new Ki(function(e,t,i,n){return c.apiLog(e,t,i,n)}),this._serializationService=o||new yo,this._errorHandlingService=a||new Yi(this._error_codes,function(e,t,i,n){return c.apiLog(e,t,i||Ee.ERROR,n)},function(e,t){return c.getLmsErrorMessageDetails(e,t)},void 0),this.settings.enableOfflineSupport&&(this._offlineStorageService=l||new sn(this.settings,this._error_codes,function(e,t,i,n){return c.apiLog(e,t,i,n)}),this.settings.courseId&&(this._courseId=this.settings.courseId),this.settings.syncOnTerminate&&this._eventService.on("BeforeTerminate",function(){var e;(null===(e=c._offlineStorageService)||void 0===e?void 0:e.isDeviceOnline())&&c._courseId&&c._offlineStorageService.hasPendingOfflineData(c._courseId).then(function(e){var t;if(e)return c.apiLog("BeforeTerminate","Syncing pending offline data before termination",Ee.INFO),null===(t=c._offlineStorageService)||void 0===t?void 0:t.syncOfflineData()}).then(function(e){e?c.processListeners("OfflineDataSynced"):!1===e&&c.processListeners("OfflineDataSyncFailed")}).catch(function(e){c.apiLog("BeforeTerminate","Error syncing offline data: ".concat(e),Ee.ERROR),c.processListeners("OfflineDataSyncFailed")})}),this._offlineStorageService&&this._courseId&&this._offlineStorageService.getOfflineData(this._courseId).then(function(e){e&&(c.apiLog("constructor","Found offline data to restore",Ee.INFO),c.loadFromJSON(e.runtimeData))}).catch(function(e){c.apiLog("constructor","Error retrieving offline data: ".concat(e),Ee.ERROR)})),this._cmiValueAccessService=new Di({errorCodes:this._error_codes,getLastErrorCode:function(){return c.lastErrorCode},setLastErrorCode:function(e){c.lastErrorCode=e},throwSCORMError:function(e,t,i){return c.throwSCORMError(e,t,i)},isInitialized:function(){return c.isInitialized()},validateCorrectResponse:function(e,t){return c.validateCorrectResponse(e,t)},checkForDuplicateId:function(e,t){return c._checkForDuplicateId(e,t)},getChildElement:function(e,t,i){return c.getChildElement(e,t,i)},apiLog:function(e,t,i){return c.apiLog(e,t,i)},checkObjectHasProperty:function(e,t){return c._checkObjectHasProperty(e,t)},getDataModel:function(){return c}})}return t=e,i=[{key:"lastErrorCode",get:function(){var e,t;return null!==(e=null===(t=this._errorHandlingService)||void 0===t?void 0:t.lastErrorCode)&&void 0!==e?e:"0"},set:function(e){this._errorHandlingService&&(this._errorHandlingService.lastErrorCode=e)}},{key:"eventService",get:function(){return this._eventService}},{key:"loggingService",get:function(){return this._loggingService}},{key:"commonReset",value:function(e){this.apiLog("reset","Called",Ee.INFO),this.settings=Mo({},this.settings,e),this.clearScheduledCommit(),this.currentState=0,this.lastErrorCode="0",this._eventService.reset(),this.startingData={},this._setCMIElements.clear(),this._offlineStorageService&&(this._offlineStorageService.updateSettings(this.settings),(null==e?void 0:e.courseId)&&(this._courseId=e.courseId))}},{key:"initialize",value:function(e,t,i){var n=this,r=F;return this.isInitialized()?this.throwSCORMError("api",this._error_codes.INITIALIZED,t):this.isTerminated()?this.throwSCORMError("api",this._error_codes.TERMINATED,i):(this.settings.selfReportSessionTime&&this.cmi.setStartTime(),this.currentState=1,this.lastErrorCode="0",r=z,this.processListeners(e),this.settings.enableOfflineSupport&&this._offlineStorageService&&this._courseId&&this.settings.syncOnInitialize&&this._offlineStorageService.isDeviceOnline()&&this._offlineStorageService.hasPendingOfflineData(this._courseId).then(function(t){var i;t&&(n.apiLog(e,"Syncing pending offline data on initialization",Ee.INFO),null===(i=n._offlineStorageService)||void 0===i||i.syncOfflineData().then(function(t){t&&(n.apiLog(e,"Successfully synced offline data",Ee.INFO),n.processListeners("OfflineDataSynced"))}))})),this.apiLog(e,"returned: "+r,Ee.INFO),this.clearSCORMError(r),r}},{key:"apiLog",value:function(e,t,i,n){t=function(e,t,i){var n=e?"".concat((e+"").padEnd(20),": "):"";return i&&(n=(n+=i).padEnd(70)),n+(null!=t?t:"")}(e,t,n),this._loggingService.log(i,t)}},{key:"settings",get:function(){return this._settings},set:function(e){var t,i,n,r=this._settings;this._settings=Mo({},this._settings,e),null===(t=this._httpService)||void 0===t||t.updateSettings(this._settings),void 0!==e.logLevel&&e.logLevel!==r.logLevel&&(null===(i=this._loggingService)||void 0===i||i.setLogLevel(e.logLevel)),void 0!==e.onLogMessage&&e.onLogMessage!==r.onLogMessage&&(null===(n=this._loggingService)||void 0===n||n.setLogHandler(e.onLogMessage))}},{key:"pendingCommitCount",get:function(){return this._pendingCommitCount}},{key:"whenCommitsSettled",value:function(e){var t=this;return 0===this._pendingCommitCount?Promise.resolve():new Promise(function(i){var n={resolve:i};void 0!==(null==e?void 0:e.timeoutMs)&&(n.timeoutId=setTimeout(function(){var e=t._commitSettleWaiters.indexOf(n);-1!==e&&(t._commitSettleWaiters.splice(e,1),i())},e.timeoutMs)),t._commitSettleWaiters.push(n)})}},{key:"_flushCommitSettleWaiters",value:function(){var e=this._commitSettleWaiters.splice(0),t=!0,i=!1,n=void 0;try{for(var r,o=e[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value;void 0!==s.timeoutId&&clearTimeout(s.timeoutId),s.resolve()}}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}}},{key:"terminate",value:function(e,t){var i=z,n=!1;if(this.isNotInitialized()){var r,o=null!==(r=this._error_codes.TERMINATION_BEFORE_INIT)&&void 0!==r?r:0;this.throwSCORMError("api",o),112===o&&(i=F)}else if(t&&this.isTerminated()){var s,a=null!==(s=this._error_codes.MULTIPLE_TERMINATION)&&void 0!==s?s:0;this.throwSCORMError("api",a),113===a&&(i=F)}else{var u;n=!0,this.processListeners("BeforeTerminate");var result=this.storeData(!0,"terminate");if((null!==(u=result.errorCode)&&void 0!==u?u:0)>0){var l;result.errorMessage&&this.apiLog("terminate","Terminate failed with error: ".concat(result.errorMessage),Ee.ERROR),result.errorDetails&&this.apiLog("terminate","Error details: ".concat(JSON.stringify(result.errorDetails)),Ee.DEBUG),this.throwSCORMError("api",null!==(l=result.errorCode)&&void 0!==l?l:0),i=F}else{var c;this.currentState=2,t&&(this.lastErrorCode="0");var d=null!==(c=null==result?void 0:result.result)&&void 0!==c?c:z;i="boolean"==typeof d?d+"":d}this.processListeners(e)}return this.apiLog(e,"returned: "+i,Ee.INFO),n&&this.clearSCORMError(i),i}},{key:"getValue",value:function(e,t,i){var n,r,o="";if(this.checkState(t,null!==(n=this._error_codes.RETRIEVE_BEFORE_INIT)&&void 0!==n?n:0,null!==(r=this._error_codes.RETRIEVE_AFTER_TERM)&&void 0!==r?r:0)){try{o=this.getCMIValue(i)}catch(e){o=this.handleValueAccessException(i,e,o)}"0"===this.lastErrorCode&&this.checkUninitializedGet(i,o),this.processListeners(e,i)}return this.apiLog(e,": returned: "+o,Ee.INFO,i),void 0===o?"":("0"===this.lastErrorCode&&this.clearSCORMError(o),"number"==typeof o||"boolean"==typeof o?o+"":o)}},{key:"setValue",value:function(e,t,i,n,r){var o,s;void 0!==r&&(r+="");var a=F;if(this.checkState(i,null!==(o=this._error_codes.STORE_BEFORE_INIT)&&void 0!==o?o:0,null!==(s=this._error_codes.STORE_AFTER_TERM)&&void 0!==s?s:0)){try{a=this.setCMIValue(n,r)}catch(e){a=this.handleValueAccessException(n,e,a)}this.processListeners(e,n,r)}return void 0===a&&(a=F),this.lastErrorCode+""=="0"&&this.settings.autocommit&&this.scheduleCommit(1e3*this.settings.autocommitSeconds,t),this.apiLog(e,": "+r+": result: "+a,Ee.INFO,n),"0"===this.lastErrorCode&&this.clearSCORMError(a),a}},{key:"commit",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"manual";this.clearScheduledCommit();var r=z;if(this.isNotInitialized()){var o,s=null!==(o=this._error_codes.COMMIT_BEFORE_INIT)&&void 0!==o?o:0;this.throwSCORMError("api",s),142===s&&(r=F)}else if(i&&this.isTerminated()){var a,u=null!==(a=this._error_codes.COMMIT_AFTER_TERM)&&void 0!==a?a:0;this.throwSCORMError("api",u),143===u&&(r=F)}else{var l,c,result=this.storeData(!1,n),d=null!==(l=result.errorCode)&&void 0!==l?l:0;d>0&&(result.errorMessage&&this.apiLog("commit","Commit failed with error: ".concat(result.errorMessage),Ee.ERROR),result.errorDetails&&this.apiLog("commit","Error details: ".concat(JSON.stringify(result.errorDetails)),Ee.DEBUG),this.throwSCORMError("api",d));var f=null!==(c=null==result?void 0:result.result)&&void 0!==c?c:F;this.apiLog(e," Result: "+(r="boolean"==typeof f?f+"":f),Ee.DEBUG,"HttpRequest"),i&&0===d&&(this.lastErrorCode="0"),this.processListeners(e),this.settings.enableOfflineSupport&&this._offlineStorageService&&this._offlineStorageService.isDeviceOnline()&&this._courseId&&this._offlineStorageService.hasPendingOfflineData(this._courseId).then(function(i){var n;i&&(t.apiLog(e,"Syncing pending offline data",Ee.INFO),null===(n=t._offlineStorageService)||void 0===n||n.syncOfflineData().then(function(i){i?(t.apiLog(e,"Successfully synced offline data",Ee.INFO),t.processListeners("OfflineDataSynced")):t.apiLog(e,"Failed to sync some offline data",Ee.WARN)}))})}return this.apiLog(e,"returned: "+r,Ee.INFO),this.isNotInitialized()||i&&this.isTerminated()||this.clearSCORMError(r),r}},{key:"getLastError",value:function(e){var t=this.lastErrorCode+"";return this.processListeners(e),this.apiLog(e,"returned: "+t,Ee.INFO),t}},{key:"getErrorString",value:function(e,t){var i="";return null!==t&&""!==t&&(i=this.getLmsErrorMessageDetails(t),this.processListeners(e)),i.length>255&&(i=i.substring(0,255)),this.apiLog(e,"returned: "+i,Ee.INFO),i}},{key:"getDiagnostic",value:function(e,t){var i="",n=""===t?this.lastErrorCode+"":t;if(null!==n&&""!==n){var r=this._errorHandlingService.lastDiagnostic;i=r&&n+""==this.lastErrorCode+""?r:this.getLmsErrorMessageDetails(n,!0),this.processListeners(e)}return i.length>255&&(i=i.substring(0,255)),this.apiLog(e,"returned: "+i,Ee.INFO),i}},{key:"checkState",value:function(e,t,i){return this.isNotInitialized()?(this.throwSCORMError("api",t),!1):!e||!this.isTerminated()||(this.throwSCORMError("api",i),!1)}},{key:"_checkForDuplicateId",value:function(e,t){var i=function(e,t){if(e&&"object"===(void 0===e?"undefined":Io(e))&&t in e){var i=e[t];return Ro(i,me)?i:void 0}},n=function(e,t,i){for(var n=0;e.childArray.length>n;n++)if(n!==t){var r=e.childArray[n];if(r&&"object"===(void 0===r?"undefined":Io(r))&&"id"in r&&r.id===i)return!0}return!1},r=e.match(/^cmi\.objectives\.(\d+)\.id$/);if(r&&r[1]){var o=parseInt(r[1],10),objectives=i(this.cmi,"objectives");return!!objectives&&n(objectives,o,t)}var s=e.match(/^cmi\.interactions\.(\d+)\.id$/);if(s&&s[1]){var a=parseInt(s[1],10),interactions=i(this.cmi,"interactions");return!!interactions&&n(interactions,a,t)}var u=e.match(/^cmi\.interactions\.(\d+)\.objectives\.(\d+)\.id$/);if(u&&u[1]&&u[2]){var l=parseInt(u[1],10),c=parseInt(u[2],10),d=i(this.cmi,"interactions");if(d){var f=d.childArray[l];if(f){var v=i(f,"objectives");if(v)return n(v,c,t)}}return!1}return!1}},{key:"getLmsErrorMessageDetails",value:function(e){throw Error("The getLmsErrorMessageDetails method has not been implemented")}},{key:"getCMIValue",value:function(e){throw Error("The getCMIValue method has not been implemented")}},{key:"setCMIValue",value:function(e,t){throw Error("The setCMIValue method has not been implemented")}},{key:"_commonSetCMIValue",value:function(e,t,i,n){var result=this._cmiValueAccessService.setCMIValue(e,t,i,n);return result===z&&this._setCMIElements.add(i),result}},{key:"_commonGetCMIValue",value:function(e,t,i){return this._cmiValueAccessService.getCMIValue(e,t,i)}},{key:"checkUninitializedGet",value:function(e,t){}},{key:"isInitialized",value:function(){return 1===this.currentState}},{key:"isNotInitialized",value:function(){return 0===this.currentState}},{key:"isTerminated",value:function(){return 2===this.currentState}},{key:"on",value:function(e,t){this._eventService.on(e,t)}},{key:"off",value:function(e,t){this._eventService.off(e,t)}},{key:"clear",value:function(e){this._eventService.clear(e)}},{key:"processListeners",value:function(e,t,i,n){void 0!==n?this._eventService.processListeners(e,t,i,n):this._eventService.processListeners(e,t,i)}},{key:"throwSCORMError",value:function(e,t,i){this._errorHandlingService.throwSCORMError(e,null!=t?t:0,i)}},{key:"clearSCORMError",value:function(e){this._errorHandlingService.clearSCORMError(e)}},{key:"loadFromFlattenedJSON",value:function(e,t){var i=this;t||(t=""),this._serializationService.loadFromFlattenedJSON(e,t,function(e,t){return i.setCMIValue(e,t)},function(){return i.isNotInitialized()},function(e){i.startingData=e})}},{key:"getFlattenedCMI",value:function(){return c(this.renderCMIToJSONObject())}},{key:"loadFromJSON",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";i&&""!==i||Object.hasOwnProperty.call(e,"cmi")||Object.hasOwnProperty.call(e,"adl")||(i="cmi"),this._serializationService.loadFromJSON(e,i,function(e,i){return t.setCMIValue(e,i)},function(){return t.isNotInitialized()},function(e){t.startingData=e})}},{key:"renderCMIToJSONString",value:function(){return this._serializationService.renderCMIToJSONString(this.cmi,this.settings.sendFullCommit)}},{key:"renderCMIToJSONObject",value:function(){return this._serializationService.renderCMIToJSONObject(this.cmi,this.settings.sendFullCommit)}},{key:"processHttpRequest",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3?arguments[3]:void 0,o=++this._commitSequence;this._pendingCommitCount+=1;var s=!1,a=!1,u=function(){s||(s=!0,i._pendingCommitCount-=1,0===i._pendingCommitCount&&i._flushCommitSettleWaiters())};try{var l=null!=r?r:n?"terminate":"manual",c=t;if(n&&this.settings.terminateCommitPayloadField){var d=this.settings.terminateCommitPayloadField;Array.isArray(c)?c=Po(c).concat(["".concat(encodeURIComponent(d),"=true")]):c&&"object"===(void 0===c?"undefined":Io(c))&&(c=To(Mo({},c),jo({},d,!0)))}!0===this.settings.includeCommitSequence&&(Array.isArray(c)?c=Po(c).concat(["commitSequence=".concat(o)]):c&&"object"===(void 0===c?"undefined":Io(c))&&(c=To(Mo({},c),{commitSequence:o})));var f,v=n&&this.settings.terminateCommitParam?h(e,this.settings.terminateCommitParam,"true"):e,m={isTerminateCommit:n,trigger:l,sequence:o},p={url:v,trigger:l,isTerminateCommit:n,sequence:o};if(this.settings.enableOfflineSupport&&this._offlineStorageService&&!this._offlineStorageService.isDeviceOnline()&&this._courseId)return this.apiLog("processHttpRequest","Device is offline, storing data locally",Ee.INFO),c&&"object"===(void 0===c?"undefined":Io(c))&&"cmi"in c?this._offlineStorageService.storeOffline(this._courseId,c,{isTerminateCommit:n,sequence:o}):(this.apiLog("processHttpRequest","Invalid commit data format for offline storage",Ee.ERROR),{result:F,errorCode:null!==(f=this._error_codes.GENERAL)&&void 0!==f?f:101});var result=this._httpService.processHttpRequest(v,c,n,function(e,t,n,r){return i.apiLog(e,t,n,r)},function(e,t,n){"CommitSuccess"===e||"CommitError"===e?("CommitError"===e&&"number"==typeof n&&(p.errorCode=n),u(),i.processListeners(e,t,n,p)):i.processListeners(e,t,n)},m,u);return a=!0===this._httpService.reportsRequestCompletion,result}finally{a||u()}}},{key:"scheduleCommit",value:function(e,t){this._timeout||(this._timeout=new st(this,e,t),this.apiLog("scheduleCommit","scheduled",Ee.DEBUG,""))}},{key:"clearScheduledCommit",value:function(){this._timeout&&(this._timeout.cancel(),this._timeout=void 0,this.apiLog("clearScheduledCommit","cleared",Ee.DEBUG,""))}},{key:"_checkObjectHasProperty",value:function(e,t){return null!=e&&"object"===(void 0===e?"undefined":Io(e))&&(Object.hasOwnProperty.call(e,t)||null!=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t)||t in e)}},{key:"handleValueAccessException",value:function(e,t,i){return Ro(t,L)?(this.lastErrorCode=t.errorCode+"",""!==i&&(i=F),this.throwSCORMError(e,t.errorCode,t.errorMessage)):Ro(t,Error)&&t.message?this.throwSCORMError(e,this._error_codes.GENERAL,t.message):this.throwSCORMError(e,this._error_codes.GENERAL,"Unknown error"),i}},{key:"getCommitObject",value:function(e){var t=this;return this._serializationService.getCommitObject(e,this.settings.alwaysSendTotalTime,this.settings.renderCommonCommitFields,function(e,i){return t.renderCommitObject(e,i)},function(e,i){return t.renderCommitCMI(e,i)},this.settings.logLevel)}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function qo(e){return qo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},qo(e)}function Lo(e,t){return Lo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Lo(e,t)}function zo(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Fo(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Fo=function(){return!!result})()}var Bo=Object.defineProperty,Vo=function(e,t,i){return function(e,t,i){return t in e?Bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":zo(t))?t+"":t,i)},Ho=function(e){function t(e){var i,n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=function(e,t,i){return t=qo(t),n=e,!(r=Fo()?Reflect.construct(t,i||[],qo(e).constructor):t.apply(e,i))||"object"!==zo(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,[e.CMIElement]),Vo(i,"__children"),Vo(i,"__score_range"),Vo(i,"__invalid_error_code"),Vo(i,"__invalid_type_code"),Vo(i,"__invalid_range_code"),Vo(i,"__decimal_regex"),Vo(i,"__error_class"),Vo(i,"__allow_empty_string"),Vo(i,"_raw",""),Vo(i,"_min",""),Vo(i,"_max"),i.__children=e.score_children||B.score_children,i.__score_range=!!e.score_range&&De,i._max=e.max||""===e.max?e.max:"100",i.__invalid_error_code=e.invalidErrorCode||ae.INVALID_SET_VALUE,i.__invalid_type_code=e.invalidTypeCode||ae.TYPE_MISMATCH,i.__invalid_range_code=e.invalidRangeCode||ae.VALUE_OUT_OF_RANGE,i.__decimal_regex=e.decimalRegex||Pe,i.__error_class=e.errorClass,i.__allow_empty_string=null!==(n=e.allowEmptyString)&&void 0!==n&&n,i}return function(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}}),t&&Lo(e,t)}(t,e),i=t,(n=[{key:"reset",value:function(){this._initialized=!1,this._raw="",this._min=""}},{key:"_children",get:function(){return this.__children},set:function(_children){throw new this.__error_class(this._cmi_element+"._children",this.__invalid_error_code)}},{key:"raw",get:function(){return this._raw},set:function(e){Ao.validateScore(this._cmi_element+".raw",e,this.__decimal_regex,this.__score_range,this.__invalid_type_code,this.__invalid_range_code,this.__error_class,this.__allow_empty_string)&&(this._raw=e)}},{key:"min",get:function(){return this._min},set:function(e){Ao.validateScore(this._cmi_element+".min",e,this.__decimal_regex,this.__score_range,this.__invalid_type_code,this.__invalid_range_code,this.__error_class,this.__allow_empty_string)&&(this._min=e)}},{key:"max",get:function(){return this._max},set:function(e){Ao.validateScore(this._cmi_element+".max",e,this.__decimal_regex,this.__score_range,this.__invalid_type_code,this.__invalid_range_code,this.__error_class,this.__allow_empty_string)&&(this._max=e)}},{key:"getScoreObject",value:function(){var e={};return Number.isNaN(Number.parseFloat(this.raw))||(e.raw=Number.parseFloat(this.raw)),Number.isNaN(Number.parseFloat(this.min))||(e.min=Number.parseFloat(this.min)),Number.isNaN(Number.parseFloat(this.max))||(e.max=Number.parseFloat(this.max)),e}},{key:"toJSON",value:function(){this.jsonString=!0;var result={raw:this.raw,min:this.min,max:this.max};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function Uo(e,t,i){return Uo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=Go(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},Uo(e,t,i||e)}function Go(e){return Go=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Go(e)}function Yo(e,t){return Yo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Yo(e,t)}function Wo(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Jo(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Jo=function(){return!!result})()}var Ko=Object.defineProperty,$o=function(e,t,i){return function(e,t,i){return t in e?Ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Wo(t))?t+"":t,i)},Xo=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=Go(t),n=e,!(r=Jo()?Reflect.construct(t,i||[],Go(e).constructor):t.apply(e,i))||"object"!==Wo(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi.core"]),$o(e,"score"),$o(e,"__children",B.core_children),$o(e,"_student_id",""),$o(e,"_student_name",""),$o(e,"_lesson_location",""),$o(e,"_credit",""),$o(e,"_lesson_status","not attempted"),$o(e,"_entry",""),$o(e,"_total_time",""),$o(e,"_lesson_mode","normal"),$o(e,"_exit",""),$o(e,"_session_time","00:00:00"),$o(e,"_suspend_data",""),e.score=new Ho({CMIElement:"cmi.core.score",score_children:B.score_children,score_range:De,invalidErrorCode:ae.INVALID_SET_VALUE,invalidTypeCode:ae.TYPE_MISMATCH,invalidRangeCode:ae.VALUE_OUT_OF_RANGE,errorClass:K,allowEmptyString:!0}),e}return function(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}}),t&&Yo(e,t)}(t,e),i=t,(n=[{key:"initialize",value:function(){var e;Uo(Go(t.prototype),"initialize",this).call(this),null===(e=this.score)||void 0===e||e.initialize()}},{key:"reset",value:function(){var e;this._initialized=!1,this._exit="",this._entry="",this._session_time="00:00:00",null===(e=this.score)||void 0===e||e.reset()}},{key:"_children",get:function(){return this.__children},set:function(_children){throw new K(this._cmi_element+"._children",ae.INVALID_SET_VALUE)}},{key:"student_id",get:function(){return this._student_id},set:function(student_id){if(this.initialized)throw new K(this._cmi_element+".student_id",ae.READ_ONLY_ELEMENT);this._student_id=student_id}},{key:"student_name",get:function(){return this._student_name},set:function(student_name){if(this.initialized)throw new K(this._cmi_element+".student_name",ae.READ_ONLY_ELEMENT);this._student_name=student_name}},{key:"lesson_location",get:function(){return this._lesson_location},set:function(lesson_location){Co(this._cmi_element+".lesson_location",lesson_location,Re,!0)&&(this._lesson_location=lesson_location)}},{key:"credit",get:function(){return this._credit},set:function(credit){if(this.initialized)throw new K(this._cmi_element+".credit",ae.READ_ONLY_ELEMENT);Co(this._cmi_element+".credit",credit,"^(credit|no-credit)$",!0)&&(this._credit=credit)}},{key:"lesson_status",get:function(){return this._lesson_status},set:function(lesson_status){this.initialized?Co(this._cmi_element+".lesson_status",lesson_status,"^(passed|completed|failed|incomplete|browsed)$")&&(this._lesson_status=lesson_status):Co(this._cmi_element+".lesson_status",lesson_status,Ne)&&(this._lesson_status=lesson_status)}},{key:"entry",get:function(){return this._entry},set:function(entry){if(this.initialized)throw new K(this._cmi_element+".entry",ae.READ_ONLY_ELEMENT);Co(this._cmi_element+".entry",entry,"^(ab-initio|resume|)$",!0)&&(this._entry=entry)}},{key:"total_time",get:function(){return this._total_time},set:function(total_time){if(this.initialized)throw new K(this._cmi_element+".total_time",ae.READ_ONLY_ELEMENT);if(Co(this._cmi_element+".total_time",total_time,Me,!0))if(total_time){var e=a(total_time,Me);this._total_time=o(e)}else this._total_time=total_time}},{key:"lesson_mode",get:function(){return this._lesson_mode},set:function(lesson_mode){if(this.initialized)throw new K(this._cmi_element+".lesson_mode",ae.READ_ONLY_ELEMENT);Co(this._cmi_element+".lesson_mode",lesson_mode,"^(normal|browse|review)$")&&(this._lesson_mode=lesson_mode)}},{key:"exit",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".exit",ae.WRITE_ONLY_ELEMENT);return this._exit},set:function(exit){"normal"===exit&&(console.warn("SCORM 1.2: Received non-standard value 'normal' for cmi.core.exit; normalizing to empty string."),exit=""),Co(this._cmi_element+".exit",exit,"^(time-out|suspend|logout|)$",!0)&&(this._exit=exit)}},{key:"session_time",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".session_time",ae.WRITE_ONLY_ELEMENT);return this._session_time},set:function(session_time){if(Co(this._cmi_element+".session_time",session_time,Me)){var e=a(session_time,Me);this._session_time=o(e)}}},{key:"suspend_data",get:function(){return this._suspend_data},set:function(suspend_data){Co(this._cmi_element+".suspend_data",suspend_data,"^[\\s\\S]{0,64000}$",!0)&&(this._suspend_data=suspend_data)}},{key:"getCurrentTotalTime",value:function(e){var t,i,n,r=this._session_time;return void 0!==e&&(r=o(((new Date).getTime()-e)/1e3)),t=this._total_time,i=r,"string"==typeof(n=RegExp(Me))&&(n=RegExp(n)),o(a(t,n)+a(i,n))}},{key:"toJSON",value:function(){this.jsonString=!0;var result={student_id:this.student_id,student_name:this.student_name,lesson_location:this.lesson_location,credit:this.credit,lesson_status:this.lesson_status,entry:this.entry,lesson_mode:this.lesson_mode,exit:this.exit,session_time:this.session_time,score:this.score};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function Qo(e,t,i){return t=es(t),n=e,!(r=rs()?Reflect.construct(t,i||[],es(e).constructor):t.apply(e,i))||"object"!==ns(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}function Zo(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function es(e){return es=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},es(e)}function ts(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}}),t&&is(e,t)}function is(e,t){return is=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},is(e,t)}function ns(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function rs(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(rs=function(){return!!result})()}var os=Object.defineProperty,ss=function(e,t,i){return function(e,t,i){return t in e?os(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":ns(t))?t+"":t,i)},as=function(e){function t(){return Zo(this,t),Qo(this,t,[{CMIElement:"cmi.objectives",children:B.objectives_children,errorCode:ae.INVALID_SET_VALUE,errorClass:K}])}return ts(t,e),t}(me),us=function(e){function t(){var e;return Zo(this,t),e=Qo(this,t,["cmi.objectives.n"]),ss(e,"score"),ss(e,"_id",""),ss(e,"_status",""),e.score=new Ho({CMIElement:"cmi.objectives.n.score",score_children:B.score_children,score_range:De,invalidErrorCode:ae.INVALID_SET_VALUE,invalidTypeCode:ae.TYPE_MISMATCH,invalidRangeCode:ae.VALUE_OUT_OF_RANGE,errorClass:K,allowEmptyString:!0}),e}return ts(t,e),i=t,(n=[{key:"reset",value:function(){var e;this._initialized=!1,this._id="",this._status="",null===(e=this.score)||void 0===e||e.reset()}},{key:"id",get:function(){return this._id},set:function(id){Co(this._cmi_element+".id",id,Ie)&&(this._id=id)}},{key:"status",get:function(){return this._status},set:function(status){Co(this._cmi_element+".status",status,Ne)&&(this._status=status)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={id:this.id,status:this.status,score:this.score};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function ls(e){return ls=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ls(e)}function cs(e,t){return cs=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},cs(e,t)}function ds(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function fs(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(fs=function(){return!!result})()}var vs=Object.defineProperty,hs=function(e,t,i){return function(e,t,i){return t in e?vs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":ds(t))?t+"":t,i)},ms=function(e){function t(e){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=function(e,t,i){return t=ls(t),n=e,!(r=fs()?Reflect.construct(t,i||[],ls(e).constructor):t.apply(e,i))||"object"!==ds(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi.student_data"]),hs(i,"__children"),hs(i,"_mastery_score",""),hs(i,"_max_time_allowed",""),hs(i,"_time_limit_action",""),i.__children=e||B.student_data_children,i}return function(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}}),t&&cs(e,t)}(t,e),i=t,(n=[{key:"reset",value:function(){this._initialized=!1}},{key:"_children",get:function(){return this.__children},set:function(_children){throw new K(this._cmi_element+"._children",ae.INVALID_SET_VALUE)}},{key:"mastery_score",get:function(){return this._mastery_score},set:function(mastery_score){if(Ao.validateReadOnly(this._cmi_element+".mastery_score",this.initialized),null!=mastery_score){var e=mastery_score;"string"!=typeof e&&(e+=""),""!==e?Co(this._cmi_element+".mastery_score",e,Pe)&&Oo(this._cmi_element+".mastery_score",e,De)&&(this._mastery_score=e):this._mastery_score=mastery_score}}},{key:"max_time_allowed",get:function(){return this._max_time_allowed},set:function(max_time_allowed){if(Ao.validateReadOnly(this._cmi_element+".max_time_allowed",this.initialized),null!=max_time_allowed){var e="string"==typeof max_time_allowed?max_time_allowed:max_time_allowed+"";this._max_time_allowed=""!==e?function(e,t){try{Co(t,e,Me,!0);var i=a(e,Me);return o(i)}catch(e){}try{Co(t,e,Ve,!0);var n=u(e,Ve);return o(n)}catch(e){}throw new K(t,ae.TYPE_MISMATCH)}(e,this._cmi_element+".max_time_allowed"):""}}},{key:"time_limit_action",get:function(){return this._time_limit_action},set:function(time_limit_action){if(Ao.validateReadOnly(this._cmi_element+".time_limit_action",this.initialized),null!=time_limit_action){var e="string"==typeof time_limit_action?time_limit_action:time_limit_action+"";Co(this._cmi_element+".time_limit_action",e,"^(exit,message|exit,no message|continue,message|continue,no message)$",!0)&&(this._time_limit_action=e)}}},{key:"toJSON",value:function(){this.jsonString=!0;var result={mastery_score:this.mastery_score,max_time_allowed:this.max_time_allowed,time_limit_action:this.time_limit_action};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function ps(e){return ps=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ps(e)}function ys(e,t){return ys=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ys(e,t)}function gs(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _s(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_s=function(){return!!result})()}var bs=Object.defineProperty,Ss=function(e,t,i){return function(e,t,i){return t in e?bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":gs(t))?t+"":t,i)},ws=function(e){function t(e){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=function(e,t,i){return t=ps(t),n=e,!(r=_s()?Reflect.construct(t,i||[],ps(e).constructor):t.apply(e,i))||"object"!==gs(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi.student_preference"]),Ss(i,"__children"),Ss(i,"_audio",""),Ss(i,"_language",""),Ss(i,"_speed",""),Ss(i,"_text",""),i.__children=e||B.student_preference_children,i}return function(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}}),t&&ys(e,t)}(t,e),i=t,(n=[{key:"reset",value:function(){this._initialized=!1}},{key:"_children",get:function(){return this.__children},set:function(_children){throw new K(this._cmi_element+"._children",ae.INVALID_SET_VALUE)}},{key:"audio",get:function(){return this._audio},set:function(audio){Ao.validateScorm12Audio(this._cmi_element+".audio",audio)&&(this._audio=audio)}},{key:"language",get:function(){return this._language},set:function(language){Ao.validateScorm12Language(this._cmi_element+".language",language)&&(this._language=language)}},{key:"speed",get:function(){return this._speed},set:function(speed){Ao.validateScorm12Speed(this._cmi_element+".speed",speed)&&(this._speed=speed)}},{key:"text",get:function(){return this._text},set:function(text){Ao.validateScorm12Text(this._cmi_element+".text",text)&&(this._text=text)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={audio:this.audio,language:this.language,speed:this.speed,text:this.text};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function Cs(e,t,i){return t=ks(t),n=e,!(r=Ts()?Reflect.construct(t,i||[],ks(e).constructor):t.apply(e,i))||"object"!==Ms(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}function Os(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Es(e,t,i){return t&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}function As(e,t,i){return As="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=ks(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},As(e,t,i||e)}function ks(e){return ks=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ks(e)}function js(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}}),t&&Rs(e,t)}function Rs(e,t){return Rs=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Rs(e,t)}function Ms(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Ts(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ts=function(){return!!result})()}var Ps=Object.defineProperty,Is=function(e,t,i){return function(e,t,i){return t in e?Ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Ms(t))?t+"":t,i)},xs=function(e){function t(){return Os(this,t),Cs(this,t,[{CMIElement:"cmi.interactions",children:B.interactions_children,errorCode:ae.INVALID_SET_VALUE,errorClass:K}])}return js(t,e),t}(me),Ns=function(e){function t(){var e;return Os(this,t),e=Cs(this,t,["cmi.interactions.n"]),Is(e,"objectives"),Is(e,"correct_responses"),Is(e,"_id",""),Is(e,"_time",""),Is(e,"_type",""),Is(e,"_weighting",""),Is(e,"_student_response",""),Is(e,"_result",""),Is(e,"_latency",""),e.objectives=new me({CMIElement:"cmi.interactions.n.objectives",errorCode:ae.INVALID_SET_VALUE,errorClass:K,children:B.objectives_children}),e.correct_responses=new me({CMIElement:"cmi.interactions.correct_responses",errorCode:ae.INVALID_SET_VALUE,errorClass:K,children:B.correct_responses_children}),e}return js(t,e),Es(t,[{key:"initialize",value:function(){var e,i;As(ks(t.prototype),"initialize",this).call(this),null===(e=this.objectives)||void 0===e||e.initialize(),null===(i=this.correct_responses)||void 0===i||i.initialize()}},{key:"reset",value:function(){var e,t;this._initialized=!1,this._id="",this._time="",this._type="",this._weighting="",this._student_response="",this._result="",this._latency="",null===(e=this.objectives)||void 0===e||e.reset(),null===(t=this.correct_responses)||void 0===t||t.reset()}},{key:"id",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".id",ae.WRITE_ONLY_ELEMENT);return this._id},set:function(id){Co(this._cmi_element+".id",id,Ie)&&(this._id=id)}},{key:"time",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".time",ae.WRITE_ONLY_ELEMENT);return this._time},set:function(time){Co(this._cmi_element+".time",time,"^(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)(\\.\\d{1,2})?$")&&(this._time=time)}},{key:"type",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".type",ae.WRITE_ONLY_ELEMENT);return this._type},set:function(type){Co(this._cmi_element+".type",type,"^(true-false|choice|fill-in|matching|performance|sequencing|likert|numeric)$")&&(this._type=type)}},{key:"weighting",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".weighting",ae.WRITE_ONLY_ELEMENT);return this._weighting},set:function(weighting){Co(this._cmi_element+".weighting",weighting,Pe)&&Oo(this._cmi_element+".weighting",weighting,"-100#100")&&(this._weighting=weighting)}},{key:"student_response",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".student_response",ae.WRITE_ONLY_ELEMENT);return this._student_response},set:function(student_response){Co(this._cmi_element+".student_response",student_response,xe,!0)&&(this._student_response=student_response)}},{key:"result",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".result",ae.WRITE_ONLY_ELEMENT);return this._result},set:function(result){var e=result;"incorrect"===result&&(e="wrong",console.warn("SCORM 1.2: Received non-standard value 'incorrect' for cmi.interactions.n.result; normalizing to 'wrong'.")),Co(this._cmi_element+".result",e,"^(correct|wrong|unanticipated|neutral|([0-9]{0,3})?(\\.[0-9]*)?)$")&&(this._result=e)}},{key:"latency",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".latency",ae.WRITE_ONLY_ELEMENT);return this._latency},set:function(latency){if(Co(this._cmi_element+".latency",latency,Me)){var e=a(latency,Me);this._latency=o(e)}}},{key:"toJSON",value:function(){this.jsonString=!0;var result={id:this.id,time:this.time,type:this.type,weighting:this.weighting,student_response:this.student_response,result:this.result,latency:this.latency,objectives:this.objectives,correct_responses:this.correct_responses};return this.jsonString=!1,result}}]),t}(C),Ds=function(e){function t(){var e;return Os(this,t),e=Cs(this,t,["cmi.interactions.n.objectives.n"]),Is(e,"_id",""),e}return js(t,e),Es(t,[{key:"reset",value:function(){this._initialized=!1,this._id=""}},{key:"id",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".id",ae.WRITE_ONLY_ELEMENT);return this._id},set:function(id){Co(this._cmi_element+".id",id,Ie)&&(this._id=id)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={id:this.id};return this.jsonString=!1,result}}]),t}(C),qs=function(e){function t(){var e;return Os(this,t),e=Cs(this,t,["cmi.interactions.correct_responses.n"]),Is(e,"_pattern",""),e}return js(t,e),Es(t,[{key:"reset",value:function(){this._initialized=!1,this._pattern=""}},{key:"pattern",get:function(){if(!this.jsonString)throw new K(this._cmi_element+".pattern",ae.WRITE_ONLY_ELEMENT);return this._pattern},set:function(pattern){Co(this._cmi_element+".pattern",pattern,xe,!0)&&(this._pattern=pattern)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={pattern:this._pattern};return this.jsonString=!1,result}}]),t}(C);function Ls(e,t,i){return Ls="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=zs(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},Ls(e,t,i||e)}function zs(e){return zs=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},zs(e)}function Fs(e,t){return Fs=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Fs(e,t)}function Bs(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Vs(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Vs=function(){return!!result})()}var Hs=Object.defineProperty,Us=function(e,t,i){return function(e,t,i){return t in e?Hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Bs(t))?t+"":t,i)},Gs=function(e){function t(e,student_data,i){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n=function(e,t,i){return t=zs(t),n=e,!(r=Vs()?Reflect.construct(t,i||[],zs(e).constructor):t.apply(e,i))||"object"!==Bs(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi"]),Us(n,"__children",""),Us(n,"__version","3.4"),Us(n,"_launch_data",""),Us(n,"_comments",""),Us(n,"_comments_from_lms",""),Us(n,"core"),Us(n,"objectives"),Us(n,"student_data"),Us(n,"student_preference"),Us(n,"interactions"),i&&n.initialize(),n.__children=e||B.cmi_children,n.core=new Xo,n.objectives=new as,n.student_data=student_data||new ms,n.student_preference=new ws,n.interactions=new xs,n}return function(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}}),t&&Fs(e,t)}(t,e),i=t,(n=[{key:"reset",value:function(){var e,t,i,n,r;this._initialized=!1,this._launch_data="",this._comments="",null===(e=this.core)||void 0===e||e.reset(),null===(t=this.objectives)||void 0===t||t.reset(!0),null===(i=this.interactions)||void 0===i||i.reset(!0),null===(n=this.student_data)||void 0===n||n.reset(),null===(r=this.student_preference)||void 0===r||r.reset()}},{key:"initialize",value:function(){var e,i,n,r,o;Ls(zs(t.prototype),"initialize",this).call(this),null===(e=this.core)||void 0===e||e.initialize(),null===(i=this.objectives)||void 0===i||i.initialize(),null===(n=this.student_data)||void 0===n||n.initialize(),null===(r=this.student_preference)||void 0===r||r.initialize(),null===(o=this.interactions)||void 0===o||o.initialize()}},{key:"toJSON",value:function(){this.jsonString=!0;var result={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,interactions:this.interactions};return this.jsonString=!1,result}},{key:"_version",get:function(){return this.__version},set:function(_version){throw new K(this._cmi_element+"._version",ae.INVALID_SET_VALUE)}},{key:"_children",get:function(){return this.__children},set:function(_children){throw new K(this._cmi_element+"._children",ae.INVALID_SET_VALUE)}},{key:"suspend_data",get:function(){var e;return null===(e=this.core)||void 0===e?void 0:e.suspend_data},set:function(suspend_data){this.core&&(this.core.suspend_data=suspend_data)}},{key:"launch_data",get:function(){return this._launch_data},set:function(launch_data){if(this.initialized)throw new K(this._cmi_element+".launch_data",ae.READ_ONLY_ELEMENT);this._launch_data=launch_data}},{key:"comments",get:function(){return this._comments},set:function(comments){Co(this._cmi_element+".comments",comments,"^[\\s\\S]{0,4096}$",!0)&&(this._comments=comments)}},{key:"comments_from_lms",get:function(){return this._comments_from_lms},set:function(comments_from_lms){if(this.initialized)throw new K(this._cmi_element+".comments_from_lms",ae.READ_ONLY_ELEMENT);this._comments_from_lms=comments_from_lms}},{key:"getCurrentTotalTime",value:function(){return this.core.getCurrentTotalTime(this.start_time)}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(O);function Ys(e){return Ys=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Ys(e)}function Ws(e,t){return Ws=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ws(e,t)}function Js(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Ks(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ks=function(){return!!result})()}var $s=Object.defineProperty,Xs=function(e){function t(){var e,i,n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=Ys(t),n=e,!(r=Ks()?Reflect.construct(t,i||[],Ys(e).constructor):t.apply(e,i))||"object"!==Js(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi.nav"]),n="",function(e,t,i){t in e?$s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==Js(i="_event")?i+"":i,n),e}return function(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}}),t&&Ws(e,t)}(t,e),i=t,(n=[{key:"reset",value:function(){this._event="",this._initialized=!1}},{key:"event",get:function(){return this._event},set:function(e){(""===e||Co(this._cmi_element+".event",e,"^(_?(previous|continue|start|resumeAll|exit|exitAll|abandon|abandonAll|suspendAll|retry|retryAll)|choice|jump|_none_)$"))&&(this._event=e)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={event:this.event};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function Qs(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function Zs(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ea(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function ta(e){return ta=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ta(e)}function ia(e,t){return ia=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ia(e,t)}function na(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function ra(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ra=function(){return!!result})()}var oa=Object.defineProperty,sa=function(e,t,i){return function(e,t,i){return t in e?oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":na(t))?t+"":t,i)},aa=function(e){function t(e,i){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=e?function(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){ea(e,t,i[t])})}return e}({},e):void 0;return r&&void 0===r.mastery_override&&(r.mastery_override=!0),n=function(e,t,i){return t=ta(t),n=e,!(r=ra()?Reflect.construct(t,i||[],ta(e).constructor):t.apply(e,i))||"object"!==na(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,[ae,r,i]),sa(n,"statusSetByModule",!1),sa(n,"cmi"),sa(n,"nav"),sa(n,"LMSInitialize"),sa(n,"LMSFinish"),sa(n,"LMSGetValue"),sa(n,"LMSSetValue"),sa(n,"LMSCommit"),sa(n,"LMSGetLastError"),sa(n,"LMSGetErrorString"),sa(n,"LMSGetDiagnostic"),n.cmi=new Gs,n.nav=new Xs,n.settings.globalStudentPreferences&&t._globalLearnerPrefs&&(""!==t._globalLearnerPrefs.audio&&(n.cmi.student_preference.audio=t._globalLearnerPrefs.audio),""!==t._globalLearnerPrefs.language&&(n.cmi.student_preference.language=t._globalLearnerPrefs.language),""!==t._globalLearnerPrefs.speed&&(n.cmi.student_preference.speed=t._globalLearnerPrefs.speed),""!==t._globalLearnerPrefs.text&&(n.cmi.student_preference.text=t._globalLearnerPrefs.text)),n.LMSInitialize=n.lmsInitialize,n.LMSFinish=n.lmsFinish,n.LMSGetValue=n.lmsGetValue,n.LMSSetValue=n.lmsSetValue,n.LMSCommit=n.lmsCommit,n.LMSGetLastError=n.lmsGetLastError,n.LMSGetErrorString=n.lmsGetErrorString,n.LMSGetDiagnostic=n.lmsGetDiagnostic,n}var i,n,r;return function(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}}),t&&ia(e,t)}(t,e),i=t,n=[{key:"reset",value:function(e){var t,i;this.commonReset(e),null===(t=this.cmi)||void 0===t||t.reset(),null===(i=this.nav)||void 0===i||i.reset(),this.statusSetByModule=!1}},{key:"lmsInitialize",value:function(){return""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")?(this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),F):(this.cmi.initialize(),this.cmi.core.lesson_status?this.statusSetByModule=!0:this.cmi.core.lesson_status="not attempted",this.initialize("LMSInitialize","LMS was already initialized!","LMS is already finished!"))}},{key:"lmsFinish",value:function(){if(""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:""))return this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),F;var result=this.terminate("LMSFinish",!0);return result===z&&(""!==this.nav.event?this.processListeners("continue"===this.nav.event?"SequenceNext":"SequencePrevious"):this.settings.autoProgress&&this.processListeners("SequenceNext")),result}},{key:"lmsGetValue",value:function(e){return this.getValue("LMSGetValue",!1,e)}},{key:"lmsSetValue",value:function(e,t){return"cmi.core.lesson_status"===e&&(this.statusSetByModule=!0),this.setValue("LMSSetValue","LMSCommit",!1,e,t)}},{key:"lmsCommit",value:function(){return""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")?(this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),F):this.settings.throttleCommits?(this.scheduleCommit(500,"LMSCommit"),z):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){var result=this._commonSetCMIValue("LMSSetValue",!1,e,t);return result===z&&this.settings.globalStudentPreferences&&("cmi.student_preference.audio"===e?this._updateGlobalPreference("audio",t):"cmi.student_preference.language"===e?this._updateGlobalPreference("language",t):"cmi.student_preference.speed"===e?this._updateGlobalPreference("speed",t):"cmi.student_preference.text"===e&&this._updateGlobalPreference("text",t)),result}},{key:"_updateGlobalPreference",value:function(e,i){t._globalLearnerPrefs||(t._globalLearnerPrefs={audio:"",language:"",speed:"",text:""}),t._globalLearnerPrefs[e]=i}},{key:"getCMIValue",value:function(e){return this._commonGetCMIValue("getCMIValue",!1,e)}},{key:"getChildElement",value:function(e,t,i){return f(e,"cmi\\.objectives\\.\\d+")?new us:i&&f(e,"cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+")?new qs:i&&f(e,"cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")?new Ds:!i&&f(e,"cmi\\.interactions\\.\\d+")?new Ns:null}},{key:"validateCorrectResponse",value:function(e,t){}},{key:"getLmsErrorMessageDetails",value:function(e,t){var i,n,r="No Error",o="No Error";return B.error_descriptions[e+=""]&&(r=(null===(i=B.error_descriptions[e])||void 0===i?void 0:i.basicMessage)||r,o=(null===(n=B.error_descriptions[e])||void 0===n?void 0:n.detailMessage)||o),t?o:r}},{key:"replaceWithAnotherScormAPI",value:function(e){this.cmi=e.cmi}},{key:"renderCommitCMI",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.renderCMIToJSONObject();(e||t)&&(i.cmi.core.total_time=this.cmi.getCurrentTotalTime());var n=c(i);switch(this.settings.dataCommitFormat){case"flattened":return n;case"params":return Object.entries(n).map(function(e){var t,i,n=(i=2,function(e){if(Array.isArray(e))return e}(t=e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,o=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}}(t,i)||function(e,t){if(e){if("string"==typeof e)return Qs(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Qs(e,t):void 0}}(t,i)||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.")}()),r=n[1];return"".concat(n[0],"=").concat(r)});default:return i}}},{key:"renderCommitObject",value:function(e){var t,i,n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=this.renderCommitCMI(e,r),s=e||r?this.cmi.getCurrentTotalTime():"",u=a(s,Me),l=this.cmi.core.lesson_status,c=Oe,d=Se;l&&(c="completed"===l||"passed"===l?we:Ce,"passed"===l?d=_e:"failed"===l&&(d=be));var f=(null===(n=this.cmi)||void 0===n||null===(i=n.core)||void 0===i||null===(t=i.score)||void 0===t?void 0:t.getScoreObject())||{},v={successStatus:d,completionStatus:c,runtimeData:o,totalTimeSeconds:u};return f&&(v.score=f),this.settings.autoPopulateCommitMetadata&&(this.settings.courseId&&(v.courseId=this.settings.courseId),this.settings.scoId&&(v.scoId=this.settings.scoId),this.cmi.core.student_id&&(v.learnerId=this.cmi.core.student_id),this.cmi.core.student_name&&(v.learnerName=this.cmi.core.student_name)),v}},{key:"storeData",value:function(e,t){if(e){var i,n,r;if("browse"===this.cmi.core.lesson_mode&&""===((null===(r=this.startingData)||void 0===r||null===(n=r.cmi)||void 0===n||null===(i=n.core)||void 0===i?void 0:i.lesson_status)||"")&&"not attempted"===this.cmi.core.lesson_status)return this.cmi.core.lesson_status="browsed",this.processCommitData(e,t);if(this.cmi.core.lesson_status&&(this.statusSetByModule||"not attempted"!==this.cmi.core.lesson_status)||(this.cmi.core.lesson_status=this.settings.autoCompleteLessonStatus?"completed":"incomplete"),"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){var o=parseFloat(this.cmi.core.score.raw),s=parseFloat(this.cmi.student_data.mastery_score);isNaN(o)||isNaN(s)||(this.cmi.core.lesson_status=s>o?"failed":"passed")}if(this.settings.score_overrides_status&&this.statusSetByModule&&"normal"===this.cmi.core.lesson_mode&&"credit"===this.cmi.core.credit&&""!==this.cmi.student_data.mastery_score&&""!==this.cmi.core.score.raw){var a=parseFloat(this.cmi.core.score.raw),u=parseFloat(this.cmi.student_data.mastery_score);isNaN(a)||isNaN(u)||(this.cmi.core.lesson_status=u>a?"failed":"passed")}}return this.processCommitData(e,t)}},{key:"processCommitData",value:function(e,t){var i=this.getCommitObject(e);return"string"==typeof this.settings.lmsCommitUrl?this.processHttpRequest(this.settings.lmsCommitUrl,i,e,t):{result:z,errorCode:0}}}],r=[{key:"clearGlobalPreferences",value:function(){t._globalLearnerPrefs=null}}],n&&Zs(i.prototype,n),r&&Zs(i,r),t}(Do);sa(aa,"_globalLearnerPrefs",null);var Scorm12API=aa;function ua(e){return ua=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ua(e)}function la(e,t){return la=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},la(e,t)}function ca(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function da(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(da=function(){return!!result})()}var fa=Object.defineProperty,va=function(e,t,i){return function(e,t,i){return t in e?fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":ca(t))?t+"":t,i)},ha=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=ua(t),n=e,!(r=da()?Reflect.construct(t,i||[],ua(e).constructor):t.apply(e,i))||"object"!==ca(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi.learner_preference"]),va(e,"__children",V.student_preference_children),va(e,"_audio_level","1"),va(e,"_language",""),va(e,"_delivery_speed","1"),va(e,"_audio_captioning","0"),e}return function(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}}),t&&la(e,t)}(t,e),i=t,(n=[{key:"reset",value:function(){this._initialized=!1}},{key:"_children",get:function(){return this.__children},set:function(_children){throw new ie(this._cmi_element+"._children",ue.READ_ONLY_ELEMENT)}},{key:"audio_level",get:function(){return this._audio_level},set:function(audio_level){ln(this._cmi_element+".audio_level",audio_level,He)&&cn(this._cmi_element+".audio_level",audio_level,"0#999.9999999")&&(this._audio_level=audio_level)}},{key:"language",get:function(){return this._language},set:function(language){ln(this._cmi_element+".language",language,"^([a-zA-Z]{1,8}|i|x)(-[a-zA-Z0-9-]{2,8})?$|^$")&&(this._language=language)}},{key:"delivery_speed",get:function(){return this._delivery_speed},set:function(delivery_speed){if(ln(this._cmi_element+".delivery_speed",delivery_speed,He)&&cn(this._cmi_element+".delivery_speed",delivery_speed,"0#999.9999999")){if(0===parseFloat(delivery_speed))throw new ie(this._cmi_element+".delivery_speed",ue.VALUE_OUT_OF_RANGE);this._delivery_speed=delivery_speed}}},{key:"audio_captioning",get:function(){return this._audio_captioning},set:function(audio_captioning){ln(this._cmi_element+".audio_captioning",audio_captioning,"^-?([0-9]+)$")&&cn(this._cmi_element+".audio_captioning",audio_captioning,"-1#1")&&(this._audio_captioning=audio_captioning)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={audio_level:this.audio_level,language:this.language,delivery_speed:this.delivery_speed,audio_captioning:this.audio_captioning};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function ma(e){return e.replace(/[[\]]/g,"")}function pa(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ya(e,t){if(!t)return[e];if(e.includes(t))return e.split(t);var i=ma(t);if(!i)return[e];var n=RegExp("(?<!\\\\)".concat(pa(i)),"g"),r=RegExp("\\\\".concat(pa(i)),"g");return e.split(n).map(function(e){return e.replace(r,i)})}function ga(e,t){var i;if(!t)return[e];if(e.includes(t)){var n=e.indexOf(t);return[e.slice(0,n),e.slice(n+t.length)]}var r=ma(t);if(!r)return[e];var o=RegExp("(?<!\\\\)".concat(pa(r))),s=RegExp("\\\\".concat(pa(r)),"g"),a=e.split(o),u=(null!==(i=a[0])&&void 0!==i?i:"").replace(s,r);return 1===a.length?[u]:[u,a.slice(1).join(r).replace(s,r)]}function _a(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function ba(e,t,i){return t=Oa(t),n=e,!(r=Ra()?Reflect.construct(t,i||[],Oa(e).constructor):t.apply(e,i))||"object"!==ja(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}function Sa(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wa(e,t,i){return t&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}function Ca(e,t,i){return Ca="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=Oa(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},Ca(e,t,i||e)}function Oa(e){return Oa=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Oa(e)}function Ea(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}}),t&&Aa(e,t)}function Aa(e,t){return Aa=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Aa(e,t)}function ka(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,o=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return _a(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_a(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 ja(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Ra(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ra=function(){return!!result})()}var Ma=Object.defineProperty,Ta=function(e,t,i){return function(e,t,i){return t in e?Ma(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":ja(t))?t+"":t,i)},Pa=function(e){function t(){return Sa(this,t),ba(this,t,[{CMIElement:"cmi.interactions",children:V.interactions_children,errorCode:ue.READ_ONLY_ELEMENT,errorClass:ie}])}return Ea(t,e),t}(me),Ia=function(e){function t(){var e;return Sa(this,t),e=ba(this,t,["cmi.interactions.n"]),Ta(e,"_id",""),Ta(e,"_idIsSet",!1),Ta(e,"_type",""),Ta(e,"_timestamp",""),Ta(e,"_weighting",""),Ta(e,"_learner_response",""),Ta(e,"_result",""),Ta(e,"_latency",""),Ta(e,"_description",""),Ta(e,"objectives"),Ta(e,"correct_responses"),e.objectives=new me({CMIElement:"cmi.interactions.n.objectives",errorCode:ue.READ_ONLY_ELEMENT,errorClass:ie,children:V.objectives_children}),e.correct_responses=new me({CMIElement:"cmi.interactions.n.correct_responses",errorCode:ue.READ_ONLY_ELEMENT,errorClass:ie,children:V.correct_responses_children}),e}return Ea(t,e),wa(t,[{key:"initialize",value:function(){var e,i;Ca(Oa(t.prototype),"initialize",this).call(this),null===(e=this.objectives)||void 0===e||e.initialize(),null===(i=this.correct_responses)||void 0===i||i.initialize()}},{key:"reset",value:function(){this._initialized=!1,this._id="",this._idIsSet=!1,this._type="",this._timestamp="",this._weighting="",this._learner_response="",this._result="",this._latency="",this._description="",this.objectives=new me({CMIElement:"cmi.interactions.n.objectives",errorCode:ue.READ_ONLY_ELEMENT,errorClass:ie,children:V.objectives_children}),this.correct_responses=new me({CMIElement:"cmi.interactions.n.correct_responses",errorCode:ue.READ_ONLY_ELEMENT,errorClass:ie,children:V.correct_responses_children})}},{key:"id",get:function(){return this._id},set:function(id){if(""===id||""===id.trim())throw new ie(this._cmi_element+".id",ue.TYPE_MISMATCH);if(this._idIsSet&&this._id!==id)throw new ie(this._cmi_element+".id",ue.GENERAL_SET_FAILURE);ln(this._cmi_element+".id",id,Ge)&&(this._id=id,this._idIsSet=!0)}},{key:"type",get:function(){return this._type},set:function(type){if(this.initialized&&""===this._id)throw new ie(this._cmi_element+".type",ue.DEPENDENCY_NOT_ESTABLISHED);ln(this._cmi_element+".type",type,"^(true-false|choice|fill-in|long-fill-in|matching|performance|sequencing|likert|numeric|other)$")&&(this._type=type)}},{key:"timestamp",get:function(){return this._timestamp},set:function(timestamp){if(this.initialized&&""===this._id)throw new ie(this._cmi_element+".timestamp",ue.DEPENDENCY_NOT_ESTABLISHED);ln(this._cmi_element+".timestamp",timestamp,Be)&&(this._timestamp=timestamp)}},{key:"weighting",get:function(){return this._weighting},set:function(weighting){if(this.initialized&&""===this._id)throw new ie(this._cmi_element+".weighting",ue.DEPENDENCY_NOT_ESTABLISHED);ln(this._cmi_element+".weighting",weighting,He)&&(this._weighting=weighting)}},{key:"learner_response",get:function(){return this._learner_response},set:function(learner_response){if(this.initialized&&(""===this._type||""===this._id))throw new ie(this._cmi_element+".learner_response",ue.DEPENDENCY_NOT_ESTABLISHED);var e=[],t=Ze[this.type];if(!t)throw new ie(this._cmi_element+".learner_response",ue.TYPE_MISMATCH);if((null==t?void 0:t.delimiter)?e=ya(learner_response,t.delimiter):e[0]=learner_response,0>=e.length||e.length>t.max)throw new ie(this._cmi_element+".learner_response",ue.GENERAL_SET_FAILURE);for(var i=RegExp(t.format),n=0;e.length>n;n++)if(null==t?void 0:t.delimiter2){var r,o,s,a=null!==(r=e[n])&&void 0!==r?r:"",u="performance"===this.type?ga(a,t.delimiter2):ya(a,t.delimiter2);if(2!==(null==u?void 0:u.length))throw new ie(this._cmi_element+".learner_response",ue.TYPE_MISMATCH);if("performance"===this.type&&""===u[0]&&""===u[1])throw new ie(this._cmi_element+".learner_response",ue.TYPE_MISMATCH);if(!(null===(o=u[0])||void 0===o?void 0:o.match(i)))throw new ie(this._cmi_element+".learner_response",ue.TYPE_MISMATCH);if(!t.format2||!(null===(s=u[1])||void 0===s?void 0:s.match(RegExp(t.format2))))throw new ie(this._cmi_element+".learner_response",ue.TYPE_MISMATCH)}else{var l;if(!(null===(l=e[n])||void 0===l?void 0:l.match(i)))throw new ie(this._cmi_element+".learner_response",ue.TYPE_MISMATCH);if(""!==e[n]&&t.unique)for(var c=0;n>c;c++)if(e[n]===e[c])throw new ie(this._cmi_element+".learner_response",ue.TYPE_MISMATCH)}this._learner_response=learner_response}},{key:"result",get:function(){return this._result},set:function(result){ln(this._cmi_element+".result",result,"^(correct|incorrect|unanticipated|neutral|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$")&&(this._result=result)}},{key:"latency",get:function(){return this._latency},set:function(latency){if(this.initialized&&""===this._id)throw new ie(this._cmi_element+".latency",ue.DEPENDENCY_NOT_ESTABLISHED);ln(this._cmi_element+".latency",latency,Ve)&&(this._latency=latency)}},{key:"description",get:function(){return this._description},set:function(description){if(this.initialized&&""===this._id)throw new ie(this._cmi_element+".description",ue.DEPENDENCY_NOT_ESTABLISHED);ln(this._cmi_element+".description",description,ze,!0)&&(this._description=description)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={id:this.id,type:this.type,objectives:this.objectives,timestamp:this.timestamp,weighting:this.weighting,learner_response:this.learner_response,result:this.result,latency:this.latency,description:this.description,correct_responses:this.correct_responses};return this.jsonString=!1,result}}]),t}(C),xa=function(e){function t(){var e;return Sa(this,t),e=ba(this,t,["cmi.interactions.n.objectives.n"]),Ta(e,"_id",""),e}return Ea(t,e),wa(t,[{key:"reset",value:function(){this._initialized=!1,this._id=""}},{key:"id",get:function(){return this._id},set:function(id){if(""===id||""===id.trim())throw new ie(this._cmi_element+".id",ue.TYPE_MISMATCH);ln(this._cmi_element+".id",id,Ge)&&(this._id=id)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={id:this.id};return this.jsonString=!1,result}}]),t}(C),Na=/^\{(?:lang|case_matters|order_matters)=[^}]+\}/;function Da(e){for(var result=e;Na.test(result);)result=result.replace(Na,"");return result}var qa=function(e){function t(e){var i;return Sa(this,t),i=ba(this,t,["cmi.interactions.n.correct_responses.n"]),Ta(i,"_pattern",""),Ta(i,"_interactionType"),i._interactionType=e,i}return Ea(t,e),wa(t,[{key:"reset",value:function(){this._initialized=!1,this._pattern=""}},{key:"pattern",get:function(){return this._pattern},set:function(pattern){if("fill-in"!==this._interactionType||""!==pattern){if(ln(this._cmi_element+".pattern",pattern,"^.*$")){if(this._interactionType){var e=et[this._interactionType];e&&("matching"===this._interactionType&&/\\[.,]/.test(pattern)||function(type,pattern,e){if(pattern.trim()!==pattern)throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);var t=e.delimiter?ya(pattern,e.delimiter):[pattern],i=!0,n=!1,r=void 0;try{for(var o,s=t[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value;if(a.trim()!==a)throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH)}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}if("fill-in"!==type||""!==pattern){var u=e.delimiter?ya(pattern,e.delimiter):[pattern];if(!e.delimiter&&pattern.includes(","))throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);if("numeric"!==type&&(e.unique||!1===e.duplicate)&&new Set(u).size!==u.length)throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);if(0===u.length||u.length>e.max)throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.GENERAL_SET_FAILURE);var l=RegExp(e.format),c=e.format2?RegExp(e.format2):null,d=function(e){if(!l.test(e))throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH)},f=function(e,t){if(!t)throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);var i=ya(e,t);if(2!==i.length||""===i[0]||""===i[1])throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);if(void 0!==i[0]&&!l.test(i[0])||c&&void 0!==i[1]&&!c.test(i[1]))throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH)},v=!0,h=!1,m=void 0;try{for(var p,y=u[Symbol.iterator]();!(v=(p=y.next()).done);v=!0){var g=p.value;switch(type){case"numeric":if(""===g){if(2>u.length||!e.delimiter||!pattern.includes(e.delimiter))throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);break}d(g);break;case"performance":var _=e.delimiter2;if(!_)throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);var b=ga(Da(g),_);if(2!==b.length)throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);var S=ka(b,2),w=S[0],C=S[1];if(""===w&&""===C)throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);if(void 0===w||!l.test(w))throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);if(c&&void 0!==C&&!c.test(C))throw new ie("cmi.interactions.n.correct_responses.n.pattern",ue.TYPE_MISMATCH);break;default:e.delimiter2?f(g,e.delimiter2):d(g)}}}catch(e){h=!0,m=e}finally{try{v||null==y.return||y.return()}finally{if(h)throw m}}}}(this._interactionType,pattern,e))}this._pattern=pattern}}else this._pattern=""}},{key:"toJSON",value:function(){this.jsonString=!0;var result={pattern:this.pattern};return this.jsonString=!1,result}}]),t}(C);function La(e,t,i){return La="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=za(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},La(e,t,i||e)}function za(e){return za=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},za(e)}function Fa(e,t){return Fa=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Fa(e,t)}function Ba(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Va(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Va=function(){return!!result})()}var Ha=Object.defineProperty,Ua=function(e){function t(){var e,i,n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=za(t),n=e,!(r=Va()?Reflect.construct(t,i||[],za(e).constructor):t.apply(e,i))||"object"!==Ba(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,[{CMIElement:"cmi.score",score_children:V.score_children,max:"",invalidErrorCode:ue.READ_ONLY_ELEMENT,invalidTypeCode:ue.TYPE_MISMATCH,invalidRangeCode:ue.VALUE_OUT_OF_RANGE,decimalRegex:He,errorClass:ie}]),n="",function(e,t,i){t in e?Ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==Ba(i="_scaled")?i+"":i,n),e}return function(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}}),t&&Fa(e,t)}(t,e),i=t,(n=[{key:"reset",value:function(){this._initialized=!1,this._scaled="",this._raw="",this._min="",this._max=""}},{key:"scaled",get:function(){return this._scaled},set:function(e){ln(this._cmi_element+".scaled",e,He)&&cn(this._cmi_element+".scaled",e,"-1#1")&&(this._scaled=e)}},{key:"getScoreObject",value:function(){var e=La(za(t.prototype),"getScoreObject",this).call(this);return Number.isNaN(Number.parseFloat(this.scaled))||(e.scaled=Number.parseFloat(this.scaled)),e}},{key:"toJSON",value:function(){this.jsonString=!0;var result={scaled:this.scaled,raw:this.raw,min:this.min,max:this.max};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(Ho);function Ga(e,t,i){return t=Wa(t),n=e,!(r=Xa()?Reflect.construct(t,i||[],Wa(e).constructor):t.apply(e,i))||"object"!==$a(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}function Ya(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Wa(e){return Wa=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Wa(e)}function Ja(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}}),t&&Ka(e,t)}function Ka(e,t){return Ka=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ka(e,t)}function $a(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Xa(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Xa=function(){return!!result})()}var Qa=Object.defineProperty,Za=function(e,t,i){return function(e,t,i){return t in e?Qa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":$a(t))?t+"":t,i)},eu=function(e){function t(){return Ya(this,t),Ga(this,t,[{CMIElement:"cmi.comments_from_lms",children:V.comments_children,errorCode:ue.READ_ONLY_ELEMENT,errorClass:ie}])}return Ja(t,e),t}(me),tu=function(e){function t(){return Ya(this,t),Ga(this,t,[{CMIElement:"cmi.comments_from_learner",children:V.comments_children,errorCode:ue.READ_ONLY_ELEMENT,errorClass:ie}])}return Ja(t,e),t}(me),iu=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Ya(this,t),e=Ga(this,t,["cmi.comments_from_learner.n"]),Za(e,"_comment",""),Za(e,"_location",""),Za(e,"_timestamp",""),Za(e,"_readOnlyAfterInit"),e._comment="",e._location="",e._timestamp="",e._readOnlyAfterInit=i,e}return Ja(t,e),i=t,(n=[{key:"reset",value:function(){this._initialized=!1}},{key:"comment",get:function(){return this._comment},set:function(comment){if(this.initialized&&this._readOnlyAfterInit)throw new ie(this._cmi_element+".comment",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".comment",comment,Fe,!0)&&(this._comment=comment)}},{key:"location",get:function(){return this._location},set:function(location){if(this.initialized&&this._readOnlyAfterInit)throw new ie(this._cmi_element+".location",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".location",location,"^[\\u0000-\\uFFFF]{0,250}$")&&(this._location=location)}},{key:"timestamp",get:function(){return this._timestamp},set:function(timestamp){if(this.initialized&&this._readOnlyAfterInit)throw new ie(this._cmi_element+".timestamp",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".timestamp",timestamp,Be)&&(this._timestamp=timestamp)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={comment:this.comment,location:this.location,timestamp:this.timestamp};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function nu(e,t,i){return t=au(t),n=e,!(r=du()?Reflect.construct(t,i||[],au(e).constructor):t.apply(e,i))||"object"!==cu(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}function ru(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ou(e,t,i){return t&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}function su(e,t,i){return su="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=au(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},su(e,t,i||e)}function au(e){return au=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},au(e)}function uu(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}}),t&&lu(e,t)}function lu(e,t){return lu=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},lu(e,t)}function cu(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function du(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(du=function(){return!!result})()}var fu=Object.defineProperty,vu=function(e,t,i){return function(e,t,i){return t in e?fu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":cu(t))?t+"":t,i)},hu=function(e){function t(){return ru(this,t),nu(this,t,[{CMIElement:"cmi.objectives",children:V.objectives_children,errorCode:ue.READ_ONLY_ELEMENT,errorClass:ie}])}return uu(t,e),ou(t,[{key:"findObjectiveById",value:function(id){return this.childArray.find(function(e){return e.id===id})}},{key:"findObjectiveByIndex",value:function(e){return this.childArray[e]}},{key:"setObjectiveByIndex",value:function(e,t){this.childArray[e]=t}}]),t}(me),mu=function(e){function t(){var e;return ru(this,t),e=nu(this,t,["cmi.objectives.n"]),vu(e,"_id",""),vu(e,"_idIsSet",!1),vu(e,"_success_status","unknown"),vu(e,"_completion_status","unknown"),vu(e,"_progress_measure",""),vu(e,"_description",""),vu(e,"score"),e.score=new Ua,e}return uu(t,e),ou(t,[{key:"reset",value:function(){var e;this._initialized=!1,this._id="",this._idIsSet=!1,this._success_status="unknown",this._completion_status="unknown",this._progress_measure="",this._description="",null===(e=this.score)||void 0===e||e.reset()}},{key:"initialize",value:function(){var e;su(au(t.prototype),"initialize",this).call(this),null===(e=this.score)||void 0===e||e.initialize()}},{key:"id",get:function(){return this._id},set:function(id){if(""===id||""===id.trim())throw new ie(this._cmi_element+".id",ue.TYPE_MISMATCH);if(this._idIsSet&&this._id!==id)throw new ie(this._cmi_element+".id",ue.GENERAL_SET_FAILURE);ln(this._cmi_element+".id",id,Ge)&&(this._id=id,this._idIsSet=!0)}},{key:"success_status",get:function(){return this._success_status},set:function(success_status){if(this.initialized&&""===this._id)throw new ie(this._cmi_element+".success_status",ue.DEPENDENCY_NOT_ESTABLISHED);ln(this._cmi_element+".success_status",success_status,We)&&(this._success_status=success_status)}},{key:"completion_status",get:function(){return this._completion_status},set:function(completion_status){if(this.initialized&&""===this._id)throw new ie(this._cmi_element+".completion_status",ue.DEPENDENCY_NOT_ESTABLISHED);ln(this._cmi_element+".completion_status",completion_status,Ye)&&(this._completion_status=completion_status)}},{key:"progress_measure",get:function(){return this._progress_measure},set:function(progress_measure){if(this.initialized&&""===this._id)throw new ie(this._cmi_element+".progress_measure",ue.DEPENDENCY_NOT_ESTABLISHED);ln(this._cmi_element+".progress_measure",progress_measure,He)&&cn(this._cmi_element+".progress_measure",progress_measure,"0#1")&&(this._progress_measure=progress_measure)}},{key:"description",get:function(){return this._description},set:function(description){if(this.initialized&&""===this._id)throw new ie(this._cmi_element+".description",ue.DEPENDENCY_NOT_ESTABLISHED);ln(this._cmi_element+".description",description,ze,!0)&&(this._description=description)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={id:this.id,success_status:this.success_status,completion_status:this.completion_status,progress_measure:this.progress_measure,description:this.description,score:this.score};return this.jsonString=!1,result}},{key:"fromJSON",value:function(e){e&&"object"===(void 0===e?"undefined":cu(e))&&("string"==typeof e.id&&(this.id=e.id),"string"==typeof e.success_status&&(this.success_status=e.success_status),"string"==typeof e.completion_status&&(this.completion_status=e.completion_status),void 0!==e.progress_measure&&(this.progress_measure=e.progress_measure+""),"string"==typeof e.description&&(this.description=e.description),e.score&&"object"===cu(e.score)&&(void 0!==e.score.scaled&&(this.score.scaled=e.score.scaled+""),void 0!==e.score.raw&&(this.score.raw=e.score.raw+""),void 0!==e.score.min&&(this.score.min=e.score.min+""),void 0!==e.score.max&&(this.score.max=e.score.max+"")))}}]),t}(C);function pu(e){return pu=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},pu(e)}function yu(e,t){return yu=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},yu(e,t)}function gu(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _u(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_u=function(){return!!result})()}var bu=Object.defineProperty,Su=function(e,t,i){return function(e,t,i){return t in e?bu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":gu(t))?t+"":t,i)},wu=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=pu(t),n=e,!(r=_u()?Reflect.construct(t,i||[],pu(e).constructor):t.apply(e,i))||"object"!==gu(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi"]),Su(e,"__version","1.0"),Su(e,"__children",V.cmi_children),e}return function(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}}),t&&yu(e,t)}(t,e),i=t,(n=[{key:"_version",get:function(){return this.__version},set:function(_version){throw new ie(this._cmi_element+"._version",ue.READ_ONLY_ELEMENT)}},{key:"_children",get:function(){return this.__children},set:function(_children){throw new ie(this._cmi_element+"._children",ue.READ_ONLY_ELEMENT)}},{key:"reset",value:function(){this._initialized=!1}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function Cu(e){return Cu=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Cu(e)}function Ou(e,t){return Ou=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ou(e,t)}function Eu(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Au(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Au=function(){return!!result})()}var ku=Object.defineProperty,ju=function(e,t,i){return function(e,t,i){return t in e?ku(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Eu(t))?t+"":t,i)},Ru=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=Cu(t),n=e,!(r=Au()?Reflect.construct(t,i||[],Cu(e).constructor):t.apply(e,i))||"object"!==Eu(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi"]),ju(e,"_learner_id",""),ju(e,"_learner_name",""),e}return function(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}}),t&&Ou(e,t)}(t,e),i=t,(n=[{key:"learner_id",get:function(){return this._learner_id},set:function(learner_id){if(this.initialized)throw new ie(this._cmi_element+".learner_id",ue.READ_ONLY_ELEMENT);this._learner_id=learner_id}},{key:"learner_name",get:function(){return this._learner_name},set:function(learner_name){if(this.initialized)throw new ie(this._cmi_element+".learner_name",ue.READ_ONLY_ELEMENT);this._learner_name=learner_name}},{key:"reset",value:function(){this._initialized=!1}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function Mu(e){return Mu=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Mu(e)}function Tu(e,t){return Tu=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Tu(e,t)}function Pu(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Iu(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Iu=function(){return!!result})()}var xu=Object.defineProperty,Nu=function(e,t,i){return function(e,t,i){return t in e?xu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Pu(t))?t+"":t,i)},Du=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=Mu(t),n=e,!(r=Iu()?Reflect.construct(t,i||[],Mu(e).constructor):t.apply(e,i))||"object"!==Pu(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi"]),Nu(e,"_completion_status","unknown"),Nu(e,"_success_status","unknown"),Nu(e,"_progress_measure",""),e}return function(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}}),t&&Tu(e,t)}(t,e),i=t,(n=[{key:"completion_status",get:function(){return this._completion_status},set:function(completion_status){ln(this._cmi_element+".completion_status",completion_status,Ye)&&(this._completion_status=completion_status)}},{key:"success_status",get:function(){return this._success_status},set:function(success_status){ln(this._cmi_element+".success_status",success_status,We)&&(this._success_status=success_status)}},{key:"progress_measure",get:function(){return this._progress_measure},set:function(progress_measure){ln(this._cmi_element+".progress_measure",progress_measure,He)&&cn(this._cmi_element+".progress_measure",progress_measure,"0#1")&&(this._progress_measure=progress_measure)}},{key:"reset",value:function(){this._initialized=!1,this._completion_status="unknown",this._success_status="unknown",this._progress_measure=""}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function qu(e){return qu=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},qu(e)}function Lu(e,t){return Lu=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Lu(e,t)}function zu(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Fu(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Fu=function(){return!!result})()}var Bu=Object.defineProperty,Vu=function(e,t,i){return function(e,t,i){return t in e?Bu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":zu(t))?t+"":t,i)},Hu=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=qu(t),n=e,!(r=Fu()?Reflect.construct(t,i||[],qu(e).constructor):t.apply(e,i))||"object"!==zu(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi"]),Vu(e,"_entry",""),Vu(e,"_exit",""),Vu(e,"_session_time","PT0H0M0S"),Vu(e,"_total_time","PT0S"),e}return function(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}}),t&&Lu(e,t)}(t,e),i=t,(n=[{key:"entry",get:function(){return this._entry},set:function(entry){if(this.initialized)throw new ie(this._cmi_element+".entry",ue.READ_ONLY_ELEMENT);this._entry=entry}},{key:"exit",get:function(){if(!this.jsonString)throw new ie(this._cmi_element+".exit",ue.WRITE_ONLY_ELEMENT);return this._exit},set:function(exit){"logout"===exit&&console.warn('SCORM 2004: cmi.exit value "logout" is deprecated per 4th Edition. Consider using "normal" or "suspend" instead.'),ln(this._cmi_element+".exit",exit,"^(time-out|suspend|logout|normal)$",!0)&&(this._exit=exit)}},{key:"getExitValueInternal",value:function(){return this._exit}},{key:"session_time",get:function(){if(!this.jsonString)throw new ie(this._cmi_element+".session_time",ue.WRITE_ONLY_ELEMENT);return this._session_time},set:function(session_time){ln(this._cmi_element+".session_time",session_time,Ve)&&(this._session_time=session_time)}},{key:"total_time",get:function(){return this._total_time},set:function(total_time){if(this.initialized)throw new ie(this._cmi_element+".total_time",ue.READ_ONLY_ELEMENT);this._total_time=total_time}},{key:"getCurrentTotalTime",value:function(e){var t,i,n,r=this._session_time;return void 0!==e&&(r=s(((new Date).getTime()-e)/1e3)),t=this._total_time,i=r,n=RegExp(Ve),s(u(t,n)+u(i,n))}},{key:"reset",value:function(){this._initialized=!1,this._entry="ab-initio",this._exit="",this._session_time="PT0H0M0S"}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function Uu(e){return Uu=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Uu(e)}function Gu(e,t){return Gu=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Gu(e,t)}function Yu(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Wu(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Wu=function(){return!!result})()}var Ju=Object.defineProperty,Ku=function(e,t,i){return function(e,t,i){return t in e?Ju(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Yu(t))?t+"":t,i)},$u=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=Uu(t),n=e,!(r=Wu()?Reflect.construct(t,i||[],Uu(e).constructor):t.apply(e,i))||"object"!==Yu(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi"]),Ku(e,"_location",""),Ku(e,"_launch_data",""),Ku(e,"_suspend_data",""),e}return function(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}}),t&&Gu(e,t)}(t,e),i=t,(n=[{key:"location",get:function(){return this._location},set:function(location){ln(this._cmi_element+".location",location,"^[\\u0000-\\uFFFF]{0,1000}$")&&(this._location=location)}},{key:"launch_data",get:function(){return this._launch_data},set:function(launch_data){if(this.initialized)throw new ie(this._cmi_element+".launch_data",ue.READ_ONLY_ELEMENT);this._launch_data=launch_data}},{key:"suspend_data",get:function(){return this._suspend_data},set:function(suspend_data){ln(this._cmi_element+".suspend_data",suspend_data,Le,!0)&&(this._suspend_data=suspend_data)}},{key:"reset",value:function(){this._initialized=!1,this._location="",this._suspend_data=""}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function Xu(e){return Xu=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Xu(e)}function Qu(e,t){return Qu=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Qu(e,t)}function Zu(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function el(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(el=function(){return!!result})()}var tl=Object.defineProperty,il=function(e,t,i){return function(e,t,i){return t in e?tl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Zu(t))?t+"":t,i)},nl=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=Xu(t),n=e,!(r=el()?Reflect.construct(t,i||[],Xu(e).constructor):t.apply(e,i))||"object"!==Zu(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi"]),il(e,"_credit","credit"),il(e,"_mode","normal"),il(e,"_time_limit_action","continue,no message"),il(e,"_max_time_allowed",""),e}return function(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}}),t&&Qu(e,t)}(t,e),i=t,(n=[{key:"credit",get:function(){return this._credit},set:function(credit){if(this.initialized)throw new ie(this._cmi_element+".credit",ue.READ_ONLY_ELEMENT);if(!/^(credit|no-credit)$/.test(credit))throw new ie(this._cmi_element+".credit",ue.TYPE_MISMATCH);this._credit=credit}},{key:"mode",get:function(){return this._mode},set:function(mode){if(this.initialized)throw new ie(this._cmi_element+".mode",ue.READ_ONLY_ELEMENT);if(!/^(browse|normal|review)$/.test(mode))throw new ie(this._cmi_element+".mode",ue.TYPE_MISMATCH);this._mode=mode}},{key:"time_limit_action",get:function(){return this._time_limit_action},set:function(time_limit_action){if(this.initialized)throw new ie(this._cmi_element+".time_limit_action",ue.READ_ONLY_ELEMENT);if(!/^(exit,message|exit,no message|continue,message|continue,no message)$/.test(time_limit_action))throw new ie(this._cmi_element+".time_limit_action",ue.TYPE_MISMATCH);this._time_limit_action=time_limit_action}},{key:"max_time_allowed",get:function(){return this._max_time_allowed},set:function(max_time_allowed){if(this.initialized)throw new ie(this._cmi_element+".max_time_allowed",ue.READ_ONLY_ELEMENT);if(""!==max_time_allowed){if(!RegExp(Ve).test(max_time_allowed))throw new ie(this._cmi_element+".max_time_allowed",ue.TYPE_MISMATCH);this._max_time_allowed=max_time_allowed}else this._max_time_allowed=max_time_allowed}},{key:"reset",value:function(){this._initialized=!1}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function rl(e){return rl=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},rl(e)}function ol(e,t){return ol=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ol(e,t)}function sl(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function al(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(al=function(){return!!result})()}var ul=Object.defineProperty,ll=function(e,t,i){return function(e,t,i){return t in e?ul(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":sl(t))?t+"":t,i)},cl=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=rl(t),n=e,!(r=al()?Reflect.construct(t,i||[],rl(e).constructor):t.apply(e,i))||"object"!==sl(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi"]),ll(e,"_scaled_passing_score",""),ll(e,"_completion_threshold",""),e}return function(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}}),t&&ol(e,t)}(t,e),i=t,(n=[{key:"scaled_passing_score",get:function(){return this._scaled_passing_score},set:function(scaled_passing_score){var e;if(this.initialized)throw new ie(this._cmi_element+".scaled_passing_score",null!==(e=ue.READ_ONLY_ELEMENT)&&void 0!==e?e:404);if(""!==scaled_passing_score){var t;if(!RegExp(He).test(scaled_passing_score))throw new ie(this._cmi_element+".scaled_passing_score",null!==(t=ue.TYPE_MISMATCH)&&void 0!==t?t:406);var i,n=parseFloat(scaled_passing_score);if(-1>n||n>1)throw new ie(this._cmi_element+".scaled_passing_score",null!==(i=ue.VALUE_OUT_OF_RANGE)&&void 0!==i?i:407);this._scaled_passing_score=scaled_passing_score}else this._scaled_passing_score=scaled_passing_score}},{key:"completion_threshold",get:function(){return this._completion_threshold},set:function(e){var t;if(this.initialized)throw new ie(this._cmi_element+".completion_threshold",null!==(t=ue.READ_ONLY_ELEMENT)&&void 0!==t?t:404);if(""!==e){var i;if(!RegExp(He).test(e))throw new ie(this._cmi_element+".completion_threshold",null!==(i=ue.TYPE_MISMATCH)&&void 0!==i?i:406);var n,r=parseFloat(e);if(0>r||r>1)throw new ie(this._cmi_element+".completion_threshold",null!==(n=ue.VALUE_OUT_OF_RANGE)&&void 0!==n?n:407);this._completion_threshold=e}else this._completion_threshold=e}},{key:"reset",value:function(){this._initialized=!1}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function dl(e,t,i){return dl="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=fl(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},dl(e,t,i||e)}function fl(e){return fl=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},fl(e)}function vl(e,t){return vl=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},vl(e,t)}function hl(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function ml(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ml=function(){return!!result})()}var pl=Object.defineProperty,yl=function(e,t,i){return function(e,t,i){return t in e?pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":hl(t))?t+"":t,i)},gl=function(e){function t(){var e,i=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=fl(t),n=e,!(r=ml()?Reflect.construct(t,i||[],fl(e).constructor):t.apply(e,i))||"object"!==hl(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["cmi"]),yl(e,"metadata"),yl(e,"learner"),yl(e,"status"),yl(e,"session"),yl(e,"content"),yl(e,"settings"),yl(e,"thresholds"),yl(e,"learner_preference"),yl(e,"score"),yl(e,"comments_from_learner"),yl(e,"comments_from_lms"),yl(e,"interactions"),yl(e,"objectives"),e.metadata=new wu,e.learner=new Ru,e.status=new Du,e.session=new Hu,e.content=new $u,e.settings=new nl,e.thresholds=new cl,e.learner_preference=new ha,e.score=new Ua,e.comments_from_learner=new tu,e.comments_from_lms=new eu,e.interactions=new Pa,e.objectives=new hu,i&&e.initialize(),e}return function(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}}),t&&vl(e,t)}(t,e),i=t,(n=[{key:"initialize",value:function(){var e,i,n,r,o,s,a,u,l,c,d,f,v;dl(fl(t.prototype),"initialize",this).call(this),null===(e=this.metadata)||void 0===e||e.initialize(),null===(i=this.learner)||void 0===i||i.initialize(),null===(n=this.status)||void 0===n||n.initialize(),null===(r=this.session)||void 0===r||r.initialize(),null===(o=this.content)||void 0===o||o.initialize(),null===(s=this.settings)||void 0===s||s.initialize(),null===(a=this.thresholds)||void 0===a||a.initialize(),null===(u=this.learner_preference)||void 0===u||u.initialize(),null===(l=this.score)||void 0===l||l.initialize(),null===(c=this.comments_from_learner)||void 0===c||c.initialize(),null===(d=this.comments_from_lms)||void 0===d||d.initialize(),null===(f=this.interactions)||void 0===f||f.initialize(),null===(v=this.objectives)||void 0===v||v.initialize()}},{key:"reset",value:function(){var e,t,i,n,r,o,s,a,u,l,c,d,f;this._initialized=!1,null===(e=this.metadata)||void 0===e||e.reset(),null===(t=this.learner)||void 0===t||t.reset(),null===(i=this.status)||void 0===i||i.reset(),null===(n=this.session)||void 0===n||n.reset(),null===(r=this.content)||void 0===r||r.reset(),null===(o=this.settings)||void 0===o||o.reset(),null===(s=this.thresholds)||void 0===s||s.reset(),null===(a=this.objectives)||void 0===a||a.reset(!0),null===(u=this.interactions)||void 0===u||u.reset(!0),null===(l=this.score)||void 0===l||l.reset(),null===(c=this.comments_from_learner)||void 0===c||c.reset(),null===(d=this.comments_from_lms)||void 0===d||d.reset(),null===(f=this.learner_preference)||void 0===f||f.reset()}},{key:"_version",get:function(){return this.metadata._version},set:function(_version){this.metadata._version=_version}},{key:"_children",get:function(){return this.metadata._children},set:function(_children){this.metadata._children=_children}},{key:"completion_status",get:function(){return this.status.completion_status},set:function(completion_status){this.status.completion_status=completion_status}},{key:"completion_threshold",get:function(){return this.thresholds.completion_threshold},set:function(e){this.thresholds.completion_threshold=e}},{key:"credit",get:function(){return this.settings.credit},set:function(credit){this.settings.credit=credit}},{key:"entry",get:function(){return this.session.entry},set:function(entry){this.session.entry=entry}},{key:"exit",get:function(){return this.session.jsonString=this.jsonString,this.session.exit},set:function(exit){this.session.exit=exit}},{key:"getExitValueInternal",value:function(){return this.session.getExitValueInternal()}},{key:"launch_data",get:function(){return this.content.launch_data},set:function(launch_data){this.content.launch_data=launch_data}},{key:"learner_id",get:function(){return this.learner.learner_id},set:function(learner_id){this.learner.learner_id=learner_id}},{key:"learner_name",get:function(){return this.learner.learner_name},set:function(learner_name){this.learner.learner_name=learner_name}},{key:"location",get:function(){return this.content.location},set:function(location){this.content.location=location}},{key:"max_time_allowed",get:function(){return this.settings.max_time_allowed},set:function(max_time_allowed){this.settings.max_time_allowed=max_time_allowed}},{key:"mode",get:function(){return this.settings.mode},set:function(mode){this.settings.mode=mode}},{key:"progress_measure",get:function(){return this.status.progress_measure},set:function(progress_measure){this.status.progress_measure=progress_measure}},{key:"scaled_passing_score",get:function(){return this.thresholds.scaled_passing_score},set:function(scaled_passing_score){this.thresholds.scaled_passing_score=scaled_passing_score}},{key:"session_time",get:function(){return this.session.jsonString=this.jsonString,this.session.session_time},set:function(session_time){this.session.session_time=session_time}},{key:"success_status",get:function(){return this.status.success_status},set:function(success_status){this.status.success_status=success_status}},{key:"suspend_data",get:function(){return this.content.suspend_data},set:function(suspend_data){this.content.suspend_data=suspend_data}},{key:"time_limit_action",get:function(){return this.settings.time_limit_action},set:function(time_limit_action){this.settings.time_limit_action=time_limit_action}},{key:"total_time",get:function(){return this.session.total_time},set:function(total_time){this.session.total_time=total_time}},{key:"getCurrentTotalTime",value:function(){return this.session.getCurrentTotalTime(this.start_time)}},{key:"toJSON",value:function(){this.jsonString=!0,this.session.jsonString=!0;var result={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,total_time:this.total_time};return this.jsonString=!1,this.session.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(O);function _l(e,t,i){return t=Ol(t),n=e,!(r=Rl()?Reflect.construct(t,i||[],Ol(e).constructor):t.apply(e,i))||"object"!==jl(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}function bl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Sl(e,t,i){return t&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}function wl(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Cl(e,t,i){return Cl="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=Ol(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},Cl(e,t,i||e)}function Ol(e){return Ol=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Ol(e)}function El(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}}),t&&kl(e,t)}function Al(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){wl(e,t,i[t])})}return e}function kl(e,t){return kl=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},kl(e,t)}function jl(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Rl(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Rl=function(){return!!result})()}var Ml=Object.defineProperty,Tl=function(e,t,i){return function(e,t,i){return t in e?Ml(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":jl(t))?t+"":t,i)},Pl=function(e){function t(){var e;return bl(this,t),e=_l(this,t,["adl"]),Tl(e,"nav"),Tl(e,"data",new xl),Tl(e,"_sequencing",null),e.nav=new Il,e.data=new xl,e}return El(t,e),Sl(t,[{key:"initialize",value:function(){var e;Cl(Ol(t.prototype),"initialize",this).call(this),null===(e=this.nav)||void 0===e||e.initialize()}},{key:"reset",value:function(){var e;this._initialized=!1,null===(e=this.nav)||void 0===e||e.reset()}},{key:"sequencing",get:function(){return this._sequencing},set:function(e){this._sequencing=e,e&&(e.adlNav=this.nav,this.nav.sequencing=e)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={nav:this.nav,data:this.data};return this.jsonString=!1,result}}]),t}(C),Il=function(e){function t(){var e;return bl(this,t),e=_l(this,t,["adl.nav"]),Tl(e,"_request","_none_"),Tl(e,"_sequencing",null),Tl(e,"request_valid"),e.request_valid=new Ll,e.request_valid.setParentNav(e),e}return El(t,e),Sl(t,[{key:"sequencing",get:function(){return this._sequencing},set:function(e){this._sequencing=e}},{key:"initialize",value:function(){var e;Cl(Ol(t.prototype),"initialize",this).call(this),null===(e=this.request_valid)||void 0===e||e.initialize()}},{key:"reset",value:function(){var e;this._initialized=!1,this._request="_none_",this._sequencing&&(this._sequencing.adlNav=null),this._sequencing=null,null===(e=this.request_valid)||void 0===e||e.reset()}},{key:"request",get:function(){return this._request},set:function(request){ln(this._cmi_element+".request",request,Je)&&(this._request=request)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={request:this.request};return this.jsonString=!1,result}}]),t}(C),xl=function(e){function t(){return bl(this,t),_l(this,t,[{CMIElement:"adl.data",children:V.adl_data_children,errorCode:ue.READ_ONLY_ELEMENT,errorClass:ie}])}return El(t,e),t}(me),Nl=function(e){function t(){var e;return bl(this,t),e=_l(this,t,["adl.data.n"]),Tl(e,"_id",""),Tl(e,"_store",""),Tl(e,"_idIsSet",!1),Tl(e,"_storeIsSet",!1),e}return El(t,e),Sl(t,[{key:"reset",value:function(){this._initialized=!1,this._idIsSet=!1,this._storeIsSet=!1}},{key:"id",get:function(){return this._id},set:function(id){if(this.initialized)throw new ie(this._cmi_element+".id",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".id",id,Ge)&&(this._id=id,this._idIsSet=!0)}},{key:"store",get:function(){if(this.initialized&&!this._storeIsSet)throw new ie(this._cmi_element+".store",ue.VALUE_NOT_INITIALIZED);return this._store},set:function(e){if(this.initialized&&!this._idIsSet)throw new ie(this._cmi_element+".store",ue.DEPENDENCY_NOT_ESTABLISHED);ln(this._cmi_element+".store",e,Le)&&(this._store=e,this._storeIsSet=!0)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={id:this._id,store:this._store};return this.jsonString=!1,result}}]),t}(C),Dl=function(){function e(){bl(this,e),Tl(this,"_parentNav",null),Tl(this,"_staticValues",{})}return Sl(e,[{key:"setParentNav",value:function(nav){this._parentNav=nav}},{key:"_isTargetValid",value:function(e){var t,i;if(null===(i=this._parentNav)||void 0===i||null===(t=i.sequencing)||void 0===t?void 0:t.overallSequencingProcess){var n=this._parentNav.sequencing.overallSequencingProcess;if(n.predictChoiceEnabled)return n.predictChoiceEnabled(e)?"true":"false"}var r=this._staticValues[e];return r===ye?"true":r===ge?"false":"unknown"}},{key:"getAll",value:function(){return Al({},this._staticValues)}},{key:"setAll",value:function(e){this._staticValues=Al({},e)}}]),e}(),ql=function(){function e(){bl(this,e),Tl(this,"_parentNav",null),Tl(this,"_staticValues",{})}return Sl(e,[{key:"setParentNav",value:function(nav){this._parentNav=nav}},{key:"_isTargetValid",value:function(e){var t,i;if(null===(i=this._parentNav)||void 0===i||null===(t=i.sequencing)||void 0===t?void 0:t.activityTree)return this._parentNav.sequencing.activityTree.getActivity(e)?"true":"false";var n=this._staticValues[e];return n===ye?"true":n===ge?"false":"unknown"}},{key:"getAll",value:function(){return Al({},this._staticValues)}},{key:"setAll",value:function(e){this._staticValues=Al({},e)}}]),e}(),Ll=function(e){function t(){var e;return bl(this,t),e=_l(this,t,["adl.nav.request_valid"]),Tl(e,"_continue","unknown"),Tl(e,"_previous","unknown"),Tl(e,"_choice"),Tl(e,"_jump"),Tl(e,"_exit","unknown"),Tl(e,"_exitAll","unknown"),Tl(e,"_abandon","unknown"),Tl(e,"_abandonAll","unknown"),Tl(e,"_suspendAll","unknown"),Tl(e,"_parentNav",null),e._choice=new Dl,e._jump=new ql,e}return El(t,e),Sl(t,[{key:"setParentNav",value:function(nav){this._parentNav=nav,this._choice.setParentNav(nav),this._jump.setParentNav(nav)}},{key:"reset",value:function(){this._initialized=!1,this._continue="unknown",this._previous="unknown",this._choice.setAll({}),this._jump.setAll({}),this._exit="unknown",this._exitAll="unknown",this._abandon="unknown",this._abandonAll="unknown",this._suspendAll="unknown"}},{key:"continue",get:function(){var e,t;if(null===(t=this._parentNav)||void 0===t||null===(e=t.sequencing)||void 0===e?void 0:e.overallSequencingProcess){var i=this._parentNav.sequencing.overallSequencingProcess;if(i.predictContinueEnabled)return i.predictContinueEnabled()?"true":"false"}return this._continue},set:function(e){if(this.initialized)throw new ie(this._cmi_element+".continue",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".continue",e,Ke)&&(this._continue=e)}},{key:"previous",get:function(){var e,t;if(null===(t=this._parentNav)||void 0===t||null===(e=t.sequencing)||void 0===e?void 0:e.overallSequencingProcess){var i=this._parentNav.sequencing.overallSequencingProcess;if(i.predictPreviousEnabled)return i.predictPreviousEnabled()?"true":"false"}return this._previous},set:function(e){if(this.initialized)throw new ie(this._cmi_element+".previous",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".previous",e,Ke)&&(this._previous=e)}},{key:"choice",get:function(){return this._choice},set:function(e){if(this.initialized)throw new ie(this._cmi_element+".choice",ue.READ_ONLY_ELEMENT);if("object"!==(void 0===e?"undefined":jl(e)))throw new ie(this._cmi_element+".choice",ue.TYPE_MISMATCH);var t={};for(var i in e)if({}.hasOwnProperty.call(e,i)&&ln(this._cmi_element+".choice."+i,e[i]||"",Ke)&&ln(this._cmi_element+".choice."+i,i,$e)){var n=e[i];"true"===n?t[i]=ye:"false"===n?t[i]=ge:"unknown"===n&&(t[i]=pe)}this._choice.setAll(t)}},{key:"jump",get:function(){return this._jump},set:function(e){if(this.initialized)throw new ie(this._cmi_element+".jump",ue.READ_ONLY_ELEMENT);if("object"!==(void 0===e?"undefined":jl(e)))throw new ie(this._cmi_element+".jump",ue.TYPE_MISMATCH);var t={};for(var i in e)if({}.hasOwnProperty.call(e,i)&&ln(this._cmi_element+".jump."+i,e[i]||"",Ke)&&ln(this._cmi_element+".jump."+i,i,$e)){var n=e[i];"true"===n?t[i]=ye:"false"===n?t[i]=ge:"unknown"===n&&(t[i]=pe)}this._jump.setAll(t)}},{key:"exit",get:function(){return this._exit},set:function(e){if(this.initialized)throw new ie(this._cmi_element+".exit",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".exit",e,Ke)&&(this._exit=e)}},{key:"exitAll",get:function(){return this._exitAll},set:function(e){if(this.initialized)throw new ie(this._cmi_element+".exitAll",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".exitAll",e,Ke)&&(this._exitAll=e)}},{key:"abandon",get:function(){return this._abandon},set:function(e){if(this.initialized)throw new ie(this._cmi_element+".abandon",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".abandon",e,Ke)&&(this._abandon=e)}},{key:"abandonAll",get:function(){return this._abandonAll},set:function(e){if(this.initialized)throw new ie(this._cmi_element+".abandonAll",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".abandonAll",e,Ke)&&(this._abandonAll=e)}},{key:"suspendAll",get:function(){return this._suspendAll},set:function(e){if(this.initialized)throw new ie(this._cmi_element+".suspendAll",ue.READ_ONLY_ELEMENT);ln(this._cmi_element+".suspendAll",e,Ke)&&(this._suspendAll=e)}},{key:"toJSON",value:function(){this.jsonString=!0;var result={previous:this.previous,continue:this.continue,choice:this._choice.getAll(),jump:this._jump.getAll(),exit:this.exit,exitAll:this.exitAll,abandon:this.abandon,abandonAll:this.abandonAll,suspendAll:this.suspendAll};return this.jsonString=!1,result}}]),t}(C);function zl(e,t,i){return zl="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=Fl(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},zl(e,t,i||e)}function Fl(e){return Fl=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Fl(e)}function Bl(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function Vl(e,t){return Vl=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Vl(e,t)}function Hl(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Ul(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ul=function(){return!!result})()}var Gl=Object.defineProperty,Yl=function(e,t,i){return function(e,t,i){return t in e?Gl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Hl(t))?t+"":t,i)},Wl=function(e){function t(e){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=function(e,t,i){return t=Fl(t),n=e,!(r=Ul()?Reflect.construct(t,i||[],Fl(e).constructor):t.apply(e,i))||"object"!==Hl(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["activityTree"]),Yl(i,"_root",null),Yl(i,"_currentActivity",null),Yl(i,"_suspendedActivity",null),Yl(i,"_activities",new Map),e&&(i.root=e),i}return function(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}}),t&&Vl(e,t)}(t,e),i=t,n=[{key:"initialize",value:function(){zl(Fl(t.prototype),"initialize",this).call(this),this._root&&this._root.initialize()}},{key:"reset",value:function(){this._initialized=!1,this._currentActivity=null,this._suspendedActivity=null,this._activities.clear(),this._root&&(this._root.reset(),this._activities.set(this._root.id,this._root),this._addActivitiesToMap(this._root))}},{key:"root",get:function(){return this._root},set:function(e){if(null!==e&&!Bl(e,Vn))throw new ie(this._cmi_element+".root",ue.TYPE_MISMATCH);this._activities.clear(),this._root=e,e&&(this._activities.set(e.id,e),this._addActivitiesToMap(e))}},{key:"_addActivitiesToMap",value:function(e){var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value;this._activities.set(s.id,s),this._addActivitiesToMap(s)}}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}}},{key:"currentActivity",get:function(){return this._currentActivity},set:function(e){if(null!==e&&!Bl(e,Vn))throw new ie(this._cmi_element+".currentActivity",ue.TYPE_MISMATCH);if(this._currentActivity){this._currentActivity.isActive=!1;for(var t=this._currentActivity.parent;t;)t.isActive=!1,t=t.parent}if(this._currentActivity=e,e){e.isActive=!0;for(var i=e.parent;i;)i.isActive=!0,i=i.parent}}},{key:"setCurrentActivityWithoutActivation",value:function(e){if(null!==e&&!Bl(e,Vn))throw new ie(this._cmi_element+".currentActivity",ue.TYPE_MISMATCH);if(this._currentActivity){var t=new Set;if(e){t.add(e);for(var i=e.parent;i;)t.add(i),i=i.parent}this._currentActivity.isActive=!1;for(var n=this._currentActivity.parent;n;)t.has(n)||(n.isActive=!1),n=n.parent}this._currentActivity=e}},{key:"suspendedActivity",get:function(){return this._suspendedActivity},set:function(e){if(null!==e&&!Bl(e,Vn))throw new ie(this._cmi_element+".suspendedActivity",ue.TYPE_MISMATCH);if(this._suspendedActivity){this._suspendedActivity.isSuspended=!1;for(var t=this._suspendedActivity.parent;t;)t.isSuspended=!1,t=t.parent}if(this._suspendedActivity=e,e){e.isSuspended=!0;for(var i=e.parent;i;)i.isSuspended=!0,i=i.parent}}},{key:"getActivity",value:function(id){return this._activities.get(id)||null}},{key:"getAllActivities",value:function(){return Array.from(this._activities.values())}},{key:"getParent",value:function(e){return e.parent}},{key:"getChildren",value:function(e){return 1>=arguments.length||void 0===arguments[1]||arguments[1]?e.getAvailableChildren():e.children}},{key:"getSiblings",value:function(e){return e.parent?e.parent.children.filter(function(t){return t!==e}):[]}},{key:"getNextSibling",value:function(e){var t,i=1>=arguments.length||void 0===arguments[1]||arguments[1];if(!e.parent)return null;var n=i?e.parent.getAvailableChildren():e.parent.children,r=n.indexOf(e);return-1===r&&i&&(r=(n=e.parent.children).indexOf(e)),-1===r||r===n.length-1?null:null!==(t=n[r+1])&&void 0!==t?t:null}},{key:"getPreviousSibling",value:function(e){var t,i=1>=arguments.length||void 0===arguments[1]||arguments[1];if(!e.parent)return null;var n=i?e.parent.getAvailableChildren():e.parent.children,r=n.indexOf(e);return-1===r&&i&&(r=(n=e.parent.children).indexOf(e)),r>0&&null!==(t=n[r-1])&&void 0!==t?t:null}},{key:"getFirstChild",value:function(e){var t,i=1>=arguments.length||void 0===arguments[1]||arguments[1]?e.getAvailableChildren():e.children;return 0===i.length?null:null!==(t=i[0])&&void 0!==t?t:null}},{key:"getLastChild",value:function(e){var t,i=1>=arguments.length||void 0===arguments[1]||arguments[1]?e.getAvailableChildren():e.children;return 0===i.length?null:null!==(t=i[i.length-1])&&void 0!==t?t:null}},{key:"getCommonAncestor",value:function(e,t){for(var i=[],n=e;n;)i.unshift(n),n=n.parent;for(n=t;n;){if(i.includes(n))return n;n=n.parent}return null}},{key:"toJSON",value:function(){this.jsonString=!0;var result={root:this._root,currentActivity:this._currentActivity?this._currentActivity.id:null,suspendedActivity:this._suspendedActivity?this._suspendedActivity.id:null};return this.jsonString=!1,result}}],n&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);function Jl(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function Kl(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function $l(e,t,i){return $l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=Xl(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i||e):r.value}},$l(e,t,i||e)}function Xl(e){return Xl=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Xl(e)}function Ql(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function Zl(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){Kl(e,t,i[t])})}return e}function ec(e,t){return ec=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ec(e,t)}function tc(e){return function(e){if(Array.isArray(e))return Jl(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Jl(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Jl(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ic(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function nc(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(nc=function(){return!!result})()}var rc=Object.defineProperty,oc=function(e,t,i){return function(e,t,i){return t in e?rc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":ic(t))?t+"":t,i)},sc=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t,i){return t=Xl(t),n=e,!(r=nc()?Reflect.construct(t,i||[],Xl(e).constructor):t.apply(e,i))||"object"!==ic(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,t,["sequencing"]),oc(e,"_activityTree"),oc(e,"_sequencingRules"),oc(e,"_sequencingControls"),oc(e,"_rollupRules"),oc(e,"_adlNav",null),oc(e,"_hideLmsUi",[]),oc(e,"_auxiliaryResources",[]),oc(e,"_overallSequencingProcess",null),e._activityTree=new Wl,e._sequencingRules=new Et,e._sequencingControls=new Xt,e._rollupRules=new An,e}return function(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}}),t&&ec(e,t)}(t,e),i=t,(n=[{key:"initialize",value:function(){$l(Xl(t.prototype),"initialize",this).call(this),this._activityTree.initialize(),this._sequencingRules.initialize(),this._sequencingControls.initialize(),this._rollupRules.initialize()}},{key:"reset",value:function(){this._initialized=!1,this._activityTree.reset(),this._sequencingRules.reset(),this._sequencingControls.reset(),this._rollupRules.reset(),this._hideLmsUi=[],this._auxiliaryResources=[]}},{key:"activityTree",get:function(){return this._activityTree},set:function(e){if(!Ql(e,Wl))throw new ie(this._cmi_element+".activityTree",ue.TYPE_MISMATCH);this._activityTree=e}},{key:"sequencingRules",get:function(){return this._sequencingRules},set:function(e){if(!Ql(e,Et))throw new ie(this._cmi_element+".sequencingRules",ue.TYPE_MISMATCH);this._sequencingRules=e}},{key:"sequencingControls",get:function(){return this._sequencingControls},set:function(e){if(!Ql(e,Xt))throw new ie(this._cmi_element+".sequencingControls",ue.TYPE_MISMATCH);this._sequencingControls=e}},{key:"hideLmsUi",get:function(){return tc(this._hideLmsUi)},set:function(e){this._hideLmsUi=tc(e)}},{key:"auxiliaryResources",get:function(){return this._auxiliaryResources.map(function(e){return Zl({},e)})},set:function(e){this._auxiliaryResources=e.map(function(e){return Zl({},e)})}},{key:"rollupRules",get:function(){return this._rollupRules},set:function(e){if(!Ql(e,An))throw new ie(this._cmi_element+".rollupRules",ue.TYPE_MISMATCH);this._rollupRules=e}},{key:"adlNav",get:function(){return this._adlNav},set:function(e){this._adlNav=e}},{key:"overallSequencingProcess",get:function(){return this._overallSequencingProcess},set:function(e){this._overallSequencingProcess=e}},{key:"processRollup",value:function(){var e=this._activityTree.root;e&&this._processRollupRecursive(e)}},{key:"_processRollupRecursive",value:function(e){var t=!0,i=!1,n=void 0;try{for(var r,o=e.children[Symbol.iterator]();!(t=(r=o.next()).done);t=!0)this._processRollupRecursive(r.value)}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}this._rollupRules.processRollup(e)}},{key:"getCurrentActivity",value:function(){return this._activityTree.currentActivity}},{key:"getRootActivity",value:function(){return this._activityTree.root}},{key:"toJSON",value:function(){this.jsonString=!0;var result={activityTree:this._activityTree,sequencingRules:this._sequencingRules,sequencingControls:this._sequencingControls,rollupRules:this._rollupRules,adlNav:this._adlNav};return this.jsonString=!1,result}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,n),t;var i,n}(C);var ac=Object.defineProperty,uc=function(){function e(t){var i,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),function(e,t,i){t in e?ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(this,"symbol"!==function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(i="context")?i+"":i,n),this.context=t}return t=e,(i=[{key:"checkValidResponseType",value:function(e,t,i,n){var r=[];(null==t?void 0:t.delimiter)?r=ya(i+"",t.delimiter):r[0]=i,r.length>0&&t.max>=r.length?this.context.checkCorrectResponseValue?this.context.checkCorrectResponseValue(e,n,r,i):this.checkCorrectResponseValue(e,n,r,i):r.length>t.max&&this.context.throwSCORMError(e,ue.GENERAL_SET_FAILURE,"Data Model Element Pattern Too Long: ".concat(i))}},{key:"checkDuplicateChoiceResponse",value:function(e,t,i){var n=t.correct_responses._count;if("choice"===t.type)for(var r=0;n>r&&"0"===this.context.getLastErrorCode();r++){var o=t.correct_responses.childArray[r];(null==o?void 0:o.pattern)===i&&this.context.throwSCORMError(e,ue.GENERAL_SET_FAILURE,"".concat(i))}}},{key:"validateCorrectResponse",value:function(e,t,i){var n=+e.split(".")[4];if(t){var r=t.correct_responses._count;this.checkDuplicateChoiceResponse(e,t,i);var o=et[t.type];o&&(void 0===o.limit||o.limit>r)?(this.checkValidResponseType(e,o,i,t.type),"0"===this.context.getLastErrorCode()&&(!o.duplicate||!this.checkDuplicatedPattern(t.correct_responses,n,i))||"0"===this.context.getLastErrorCode()&&""===i||"0"===this.context.getLastErrorCode()&&this.context.throwSCORMError(e,ue.GENERAL_SET_FAILURE,"Data Model Element Pattern Already Exists: ".concat(e," - ").concat(i))):this.context.throwSCORMError(e,ue.GENERAL_SET_FAILURE,"Data Model Element Collection Limit Reached: ".concat(e," - ").concat(i))}else this.context.throwSCORMError(e,ue.DEPENDENCY_NOT_ESTABLISHED,e)}},{key:"checkDuplicatedPattern",value:function(e,t,i){for(var n=!1,r=e._count,o=0;r>o&&!n;o++)if(o!==t){var s=e.childArray[o];(null==s?void 0:s.pattern)===i&&(n=!0)}return n}},{key:"checkCorrectResponseValue",value:function(e,t,i,n){var r=et[t];if(r)for(var o=RegExp(r.format),s=0;i.length>s&&"0"===this.context.getLastErrorCode();s++)if(t.match("^(fill-in|long-fill-in|matching|performance|sequencing)$")&&(i[s]=this.removeCorrectResponsePrefixes(e,i[s])),null==r?void 0:r.delimiter2){var a,u,l="performance"===t?ga(i[s],r.delimiter2):ya(i[s],r.delimiter2);2===l.length?"performance"===t&&""===l[0]&&""===l[1]?this.context.throwSCORMError(e,ue.TYPE_MISMATCH,"".concat(t,": ").concat(n)):(null===(a=l[0])||void 0===a?void 0:a.match(o))&&r.format2&&(null===(u=l[1])||void 0===u?void 0:u.match(RegExp(r.format2)))||this.context.throwSCORMError(e,ue.TYPE_MISMATCH,"".concat(t,": ").concat(n)):this.context.throwSCORMError(e,ue.TYPE_MISMATCH,"".concat(t,": ").concat(n))}else{if("numeric"===t&&i.length>1&&""===i[s]&&r.delimiter&&(n+"").includes(r.delimiter))continue;var c=i[s].match(o);if(!c&&""!==n||!c&&"true-false"===t)this.context.throwSCORMError(e,ue.TYPE_MISMATCH,"".concat(t,": ").concat(n));else if("numeric"===t&&i.length>1)""!==i[0]&&""!==i[1]&&+i[0]>+i[1]&&this.context.throwSCORMError(e,ue.TYPE_MISMATCH,"".concat(t,": ").concat(n));else if(""!==i[s]&&r.unique)for(var d=0;s>d&&"0"===this.context.getLastErrorCode();d++)i[s]===i[d]&&this.context.throwSCORMError(e,ue.TYPE_MISMATCH,"".concat(t,": ").concat(n))}else this.context.throwSCORMError(e,ue.TYPE_MISMATCH,"Incorrect Response Type: ".concat(t))}},{key:"removeCorrectResponsePrefixes",value:function(e,t){for(var i,n=!1,r=!1,o=!1,s=RegExp("^({(lang|case_matters|order_matters)=([^}]+)})"),a=t.match(s);a;){var u;switch(a[2]){case"lang":if(i=t.match("^(({lang=([a-zA-Z]{1,8}|i|x)?(-[a-zA-Z0-9-]{2,8})?}))(.*?)$")){var l=i[3];void 0!==l&&l.length>0&&(it.includes(l.toLowerCase())||this.context.throwSCORMError(e,ue.TYPE_MISMATCH,"".concat(t)))}o=!0;break;case"case_matters":o||n||r||"true"!==a[3]&&"false"!==a[3]&&this.context.throwSCORMError(e,ue.TYPE_MISMATCH,"".concat(t)),r=!0;break;case"order_matters":r||o||n||"true"!==a[3]&&"false"!==a[3]&&this.context.throwSCORMError(e,ue.TYPE_MISMATCH,"".concat(t)),n=!0}a=(t=t.substring((null===(u=a[1])||void 0===u?void 0:u.length)||0)).match(s)}return t}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();var lc=Object.defineProperty,cc=function(e,t,i){return function(e,t,i){return t in e?lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},dc=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),cc(this,"context"),cc(this,"responseValidator"),this.context=t,this.responseValidator=i}return t=e,(i=[{key:"getChildElement",value:function(e,t,i){if(f(e,"cmi\\.objectives\\.\\d+"))return new mu;if(i){if(f(e,"cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+"))return this.createCorrectResponsesObject(e,t);if(f(e,"cmi\\.interactions\\.\\d+\\.objectives\\.\\d+"))return new xa}else if(f(e,"cmi\\.interactions\\.\\d+"))return new Ia;return f(e,"cmi\\.comments_from_learner\\.\\d+")?new iu:f(e,"cmi\\.comments_from_lms\\.\\d+")?new iu(!0):f(e,"adl\\.data\\.\\d+")?new Nl:null}},{key:"createCorrectResponsesObject",value:function(e,t){var i=e.split("."),n=this.context.cmi.interactions.childArray[+i[2]];if(this.context.isInitialized()){if(void 0===n||!n.type)return this.context.throwSCORMError(e,ue.DEPENDENCY_NOT_ESTABLISHED,e),null;var r=et[n.type];if(r&&void 0!==r.limit&&n.correct_responses._count>=r.limit)return this.context.throwSCORMError(e,ue.GENERAL_SET_FAILURE,"Data Model Element Collection Limit Reached: ".concat(e)),null;if(this.responseValidator.checkDuplicateChoiceResponse(e,n,t),!r)return this.context.throwSCORMError(e,ue.GENERAL_SET_FAILURE,"Incorrect Response Type: ".concat(n.type)),null;this.responseValidator.checkValidResponseType(e,r,t,n.type)}return"0"===this.context.getLastErrorCode()?new qa(null==n?void 0:n.type):null}},{key:"evaluateCompletionStatus",value:function(){var e=this.context.cmi.completion_threshold,t=this.context.cmi.progress_measure,i=this.context.cmi.completion_status;if(""!==e&&null!=e){var n=parseFloat(e+"");if(!isNaN(n)){if(""!==t&&null!=t){var r=parseFloat(t+"");if(!isNaN(r))return n>r?Ce:we}return Oe}}return i||Oe}},{key:"evaluateSuccessStatus",value:function(){var e=this.context.cmi.scaled_passing_score,t=this.context.cmi.score.scaled,i=this.context.cmi.success_status;if(""!==e&&null!=e){var n=parseFloat(e+"");if(!isNaN(n)){if(""!==t&&null!=t){var r=parseFloat(t+"");if(!isNaN(r))return n>r?be:_e}return Se}}return i||Se}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function fc(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function vc(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function hc(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){vc(e,t,i[t])})}return e}function mc(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,o=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}}(e,t)||yc(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 pc(e){return function(e){if(Array.isArray(e))return fc(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||yc(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function yc(e,t){if(e){if("string"==typeof e)return fc(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?fc(e,t):void 0}}var gc=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return t=e,(i=[{key:"applySequencingControlsSettings",value:function(e,t){void 0!==t.enabled&&(e.enabled=t.enabled),void 0!==t.choice&&(e.choice=t.choice),void 0!==t.choiceExit&&(e.choiceExit=t.choiceExit),void 0!==t.flow&&(e.flow=t.flow),void 0!==t.forwardOnly&&(e.forwardOnly=t.forwardOnly),void 0!==t.useCurrentAttemptObjectiveInfo&&(e.useCurrentAttemptObjectiveInfo=t.useCurrentAttemptObjectiveInfo),void 0!==t.useCurrentAttemptProgressInfo&&(e.useCurrentAttemptProgressInfo=t.useCurrentAttemptProgressInfo),void 0!==t.preventActivation&&(e.preventActivation=t.preventActivation),void 0!==t.constrainChoice&&(e.constrainChoice=t.constrainChoice),void 0!==t.stopForwardTraversal&&(e.stopForwardTraversal=t.stopForwardTraversal),void 0!==t.rollupObjectiveSatisfied&&(e.rollupObjectiveSatisfied=t.rollupObjectiveSatisfied),void 0!==t.rollupProgressCompletion&&(e.rollupProgressCompletion=t.rollupProgressCompletion),void 0!==t.objectiveMeasureWeight&&(e.objectiveMeasureWeight=t.objectiveMeasureWeight),void 0!==t.selectionTiming&&(e.selectionTiming=t.selectionTiming),void 0!==t.selectCount&&(e.selectCount=t.selectCount),void 0!==t.randomizeChildren&&(e.randomizeChildren=t.randomizeChildren),void 0!==t.randomizationTiming&&(e.randomizationTiming=t.randomizationTiming),void 0!==t.selectionCountStatus&&(e.selectionCountStatus=t.selectionCountStatus),void 0!==t.reorderChildren&&(e.reorderChildren=t.reorderChildren),void 0!==t.completionSetByContent&&(e.completionSetByContent=t.completionSetByContent),void 0!==t.objectiveSetByContent&&(e.objectiveSetByContent=t.objectiveSetByContent)}},{key:"applySequencingRulesSettings",value:function(e,t){if(t){if(t.preConditionRules){var i=!0,n=!1,r=void 0;try{for(var o,s=t.preConditionRules[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=this.createSequencingRule(o.value);e.addPreConditionRule(a)}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}if(t.exitConditionRules){var u=!0,l=!1,c=void 0;try{for(var d,f=t.exitConditionRules[Symbol.iterator]();!(u=(d=f.next()).done);u=!0){var v=this.createSequencingRule(d.value);e.addExitConditionRule(v)}}catch(e){l=!0,c=e}finally{try{u||null==f.return||f.return()}finally{if(l)throw c}}}if(t.postConditionRules){var h=!0,m=!1,p=void 0;try{for(var y,g=t.postConditionRules[Symbol.iterator]();!(h=(y=g.next()).done);h=!0){var _=this.createSequencingRule(y.value);e.addPostConditionRule(_)}}catch(e){m=!0,p=e}finally{try{h||null==g.return||g.return()}finally{if(m)throw p}}}}}},{key:"createSequencingRule",value:function(e){var t=new Ot(e.action,e.conditionCombination),i=!0,n=!1,r=void 0;try{for(var o,s=e.conditions[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value,u=new Ct(a.condition,a.operator,new Map(Object.entries(a.parameters||{})));a.referencedObjective&&(u.referencedObjective=a.referencedObjective),t.addCondition(u)}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return t}},{key:"applyRollupRulesSettings",value:function(e,t){if(null==t?void 0:t.rules){var i=!0,n=!1,r=void 0;try{for(var o,s=t.rules[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=this.createRollupRule(o.value);e.addRule(a)}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}}}},{key:"createRollupRule",value:function(e){var t=new En(e.action,e.consideration,e.minimumCount,e.minimumPercent),i=!0,n=!1,r=void 0;try{for(var o,s=e.conditions[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=o.value,u=new On(a.condition,new Map(Object.entries(a.parameters||{})));t.addCondition(u)}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return t}},{key:"sanitizeSequencingCollections",value:function(e){if(!e)return{};var t={},i=!0,n=!1,r=void 0;try{for(var o,s=Object.entries(e)[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a=mc(o.value,2),u=a[1],l=a[0].trim();if(l){var c,d={};if(u.sequencingControls&&(d.sequencingControls=hc({},u.sequencingControls)),u.sequencingRules){var f=function(e){var t={action:e.action,conditions:e.conditions.map(function(e){var t={condition:e.condition};return void 0!==e.operator&&(t.operator=e.operator),e.parameters&&(t.parameters=hc({},e.parameters)),void 0!==e.referencedObjective&&(t.referencedObjective=e.referencedObjective),t})};return void 0!==e.conditionCombination&&(t.conditionCombination=e.conditionCombination),t};d.sequencingRules={},u.sequencingRules.preConditionRules&&(d.sequencingRules.preConditionRules=u.sequencingRules.preConditionRules.map(f)),u.sequencingRules.exitConditionRules&&(d.sequencingRules.exitConditionRules=u.sequencingRules.exitConditionRules.map(f)),u.sequencingRules.postConditionRules&&(d.sequencingRules.postConditionRules=u.sequencingRules.postConditionRules.map(f))}u.rollupRules&&(d.rollupRules={rules:null===(c=u.rollupRules.rules)||void 0===c?void 0:c.map(function(e){var t={action:e.action,conditions:e.conditions.map(function(e){var t={condition:e.condition};return e.parameters&&(t.parameters=hc({},e.parameters)),t})};return void 0!==e.consideration&&(t.consideration=e.consideration),void 0!==e.minimumCount&&(t.minimumCount=e.minimumCount),void 0!==e.minimumPercent&&(t.minimumPercent=e.minimumPercent),t})}),u.rollupConsiderations&&(d.rollupConsiderations=hc({},u.rollupConsiderations)),u.selectionRandomizationState&&(d.selectionRandomizationState=this.cloneSelectionRandomizationState(u.selectionRandomizationState)),u.hideLmsUi&&(d.hideLmsUi=this.sanitizeHideLmsUi(u.hideLmsUi)),u.auxiliaryResources&&(d.auxiliaryResources=this.sanitizeAuxiliaryResources(u.auxiliaryResources)),t[l]=d}}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return t}},{key:"normalizeCollectionRefs",value:function(e){if(!e)return[];var t=Array.isArray(e)?e:[e],i=new Set,result=[],n=!0,r=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value.trim();u&&!i.has(u)&&(i.add(u),result.push(u))}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return result}},{key:"applySequencingCollection",value:function(e,t,i){if(t){if(t.sequencingControls&&this.applySequencingControlsSettings(e.sequencingControls,t.sequencingControls),t.sequencingRules&&this.applySequencingRulesSettings(e.sequencingRules,t.sequencingRules),t.rollupRules&&this.applyRollupRulesSettings(e.rollupRules,t.rollupRules),t.rollupConsiderations&&e.applyRollupConsiderations(t.rollupConsiderations),t.hideLmsUi){var n=this.mergeHideLmsUi(e.hideLmsUi,t.hideLmsUi);n.length>0&&(e.hideLmsUi=n)}if(t.auxiliaryResources){var r=this.sanitizeAuxiliaryResources(t.auxiliaryResources);r.length>0&&(e.auxiliaryResources=this.mergeAuxiliaryResources(e.auxiliaryResources,r))}t.selectionRandomizationState&&i.push(this.cloneSelectionRandomizationState(t.selectionRandomizationState))}}},{key:"sanitizeHideLmsUi",value:function(e){if(!e)return[];var t=new Set(at),i=new Set,n=[],r=!0,o=!1,s=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var l=a.value;t.has(l)&&!i.has(l)&&(i.add(l),n.push(l))}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}return n}},{key:"mergeHideLmsUi",value:function(e,t){return t&&0!==t.length?this.sanitizeHideLmsUi(pc(e).concat(pc(t))):e}},{key:"sanitizeAuxiliaryResources",value:function(e){if(!e)return[];var t=new Set,i=[],n=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value;if(u&&u.resourceId&&"string"==typeof u.resourceId&&u.purpose&&"string"==typeof u.purpose){var l=u.resourceId.trim(),c=u.purpose.trim();if(l&&c){var d="".concat(l,"::").concat(c);t.has(d)||(t.add(d),i.push({resourceId:l,purpose:c}))}}}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return i}},{key:"mergeAuxiliaryResources",value:function(e,t){var i=[],n=new Set,r=!0,o=!1,s=void 0;try{for(var a,u=pc(null!=e?e:[]).concat(pc(null!=t?t:[]))[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var l=a.value;if(l){var c=l.resourceId;c&&!n.has(c)&&(n.add(c),i.push({resourceId:c,purpose:l.purpose}))}}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}return i}},{key:"cloneSelectionRandomizationState",value:function(e){var t={};return e.childOrder&&(t.childOrder=pc(e.childOrder)),e.selectedChildIds&&(t.selectedChildIds=pc(e.selectedChildIds)),e.hiddenFromChoiceChildIds&&(t.hiddenFromChoiceChildIds=pc(e.hiddenFromChoiceChildIds)),void 0!==e.selectionCountStatus&&(t.selectionCountStatus=e.selectionCountStatus),void 0!==e.reorderChildren&&(t.reorderChildren=e.reorderChildren),t}},{key:"applySelectionRandomizationState",value:function(e,t){var i=e.sequencingControls;void 0!==t.selectionCountStatus&&(i.selectionCountStatus=t.selectionCountStatus),void 0!==t.reorderChildren&&(i.reorderChildren=t.reorderChildren);var n=t.selectedChildIds?new Set(t.selectedChildIds):null,r=t.hiddenFromChoiceChildIds?new Set(t.hiddenFromChoiceChildIds):null;t.childOrder&&t.childOrder.length>0&&e.setChildOrder(t.childOrder);var o=!1;if(n||r){var s=!0,a=!1,u=void 0;try{for(var l,c=e.children[Symbol.iterator]();!(s=(l=c.next()).done);s=!0){var d=l.value;if(n){var f=n.has(d.id);d.isAvailable=f,r||(d.isHiddenFromChoice=!f),o=!0}r&&(d.isHiddenFromChoice=r.has(d.id),o=!0)}}catch(e){a=!0,u=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw u}}}(o||n||void 0!==t.selectionCountStatus||void 0!==t.reorderChildren||t.childOrder&&t.childOrder.length>0)&&e.setProcessedChildren(e.children.filter(function(e){return e.isAvailable}))}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function _c(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function bc(e){return function(e){if(Array.isArray(e))return _c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return _c(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_c(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Sc=Object.defineProperty,wc=function(e,t,i){return function(e,t,i){return t in e?Sc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Cc=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),wc(this,"sequencingCollections"),wc(this,"sequencingConfigBuilder"),this.sequencingCollections=t||{},this.sequencingConfigBuilder=i||new gc}return t=e,(i=[{key:"setSequencingCollections",value:function(e){this.sequencingCollections=e}},{key:"createActivity",value:function(e){var t=new Vn(e.id,e.title),i=[],n=this.sequencingConfigBuilder.normalizeCollectionRefs(e.sequencingCollectionRefs),r=!0,o=!1,s=void 0;try{for(var a,u=n[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var l=this.sequencingCollections[a.value];l&&this.sequencingConfigBuilder.applySequencingCollection(t,l,i)}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}if(void 0!==e.isVisible&&(t.isVisible=e.isVisible),void 0!==e.isActive&&(t.isActive=e.isActive),void 0!==e.isSuspended&&(t.isSuspended=e.isSuspended),void 0!==e.isCompleted&&(t.isCompleted=e.isCompleted),void 0!==e.isHiddenFromChoice&&(t.isHiddenFromChoice=e.isHiddenFromChoice),void 0!==e.isAvailable&&(t.isAvailable=e.isAvailable),void 0!==e.attemptLimit&&(t.attemptLimit=e.attemptLimit),void 0!==e.attemptAbsoluteDurationLimit&&(t.attemptAbsoluteDurationLimit=e.attemptAbsoluteDurationLimit),void 0!==e.activityAbsoluteDurationLimit&&(t.activityAbsoluteDurationLimit=e.activityAbsoluteDurationLimit),void 0!==e.timeLimitAction&&(t.timeLimitAction=e.timeLimitAction),void 0!==e.timeLimitDuration&&(t.timeLimitDuration=e.timeLimitDuration),void 0!==e.beginTimeLimit&&(t.beginTimeLimit=e.beginTimeLimit),void 0!==e.endTimeLimit&&(t.endTimeLimit=e.endTimeLimit),e.primaryObjective){var c=this.createActivityObjectiveFromSettings(e.primaryObjective,!0);t.primaryObjective=c,null!==c.minNormalizedMeasure&&(t.scaledPassingScore=c.minNormalizedMeasure)}if(e.objectives){var d=!0,f=!1,v=void 0;try{for(var h,m=e.objectives[Symbol.iterator]();!(d=(h=m.next()).done);d=!0){var p=h.value,y=!0===p.isPrimary,g=this.createActivityObjectiveFromSettings(p,y);y?t.primaryObjective=g:t.addObjective(g)}}catch(e){f=!0,v=e}finally{try{d||null==m.return||m.return()}finally{if(f)throw v}}}if(e.sequencingControls&&this.sequencingConfigBuilder.applySequencingControlsSettings(t.sequencingControls,e.sequencingControls),e.sequencingRules&&this.sequencingConfigBuilder.applySequencingRulesSettings(t.sequencingRules,e.sequencingRules),e.rollupRules&&this.sequencingConfigBuilder.applyRollupRulesSettings(t.rollupRules,e.rollupRules),e.rollupConsiderations&&t.applyRollupConsiderations(e.rollupConsiderations),e.hideLmsUi){var _=this.sequencingConfigBuilder.mergeHideLmsUi(t.hideLmsUi,e.hideLmsUi);_.length>0&&(t.hideLmsUi=_)}if(e.auxiliaryResources){var b=this.sequencingConfigBuilder.sanitizeAuxiliaryResources(e.auxiliaryResources);b.length>0&&(t.auxiliaryResources=this.sequencingConfigBuilder.mergeAuxiliaryResources(t.auxiliaryResources,b))}if(e.children){var S=!0,w=!1,C=void 0;try{for(var O,E=e.children[Symbol.iterator]();!(S=(O=E.next()).done);S=!0){var A=this.createActivity(O.value);t.addChild(A)}}catch(e){w=!0,C=e}finally{try{S||null==E.return||E.return()}finally{if(w)throw C}}}e.selectionRandomizationState&&i.push(this.sequencingConfigBuilder.cloneSelectionRandomizationState(e.selectionRandomizationState));var k=!0,j=!1,R=void 0;try{for(var M,T=i[Symbol.iterator]();!(k=(M=T.next()).done);k=!0)this.sequencingConfigBuilder.applySelectionRandomizationState(t,M.value)}catch(e){j=!0,R=e}finally{try{k||null==T.return||T.return()}finally{if(j)throw R}}return t}},{key:"extractActivityIds",value:function(e){var t=[e.id],i=!0,n=!1,r=void 0;try{for(var o,s=e.children[Symbol.iterator]();!(i=(o=s.next()).done);i=!0){var a;(a=t).push.apply(a,bc(this.extractActivityIds(o.value)))}}catch(e){n=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw r}}return t}},{key:"createActivityObjectiveFromSettings",value:function(e,t){var i,n,r,o=(e.mapInfo||[]).map(function(e){var t,i,n,r,o,s,a,u,l,c,d,f,v,h,m;return{targetObjectiveID:e.targetObjectiveID,readSatisfiedStatus:null!==(t=e.readSatisfiedStatus)&&void 0!==t&&t,readNormalizedMeasure:null!==(i=e.readNormalizedMeasure)&&void 0!==i&&i,writeSatisfiedStatus:null!==(n=e.writeSatisfiedStatus)&&void 0!==n&&n,writeNormalizedMeasure:null!==(r=e.writeNormalizedMeasure)&&void 0!==r&&r,readCompletionStatus:null!==(o=e.readCompletionStatus)&&void 0!==o&&o,writeCompletionStatus:null!==(s=e.writeCompletionStatus)&&void 0!==s&&s,readProgressMeasure:null!==(a=e.readProgressMeasure)&&void 0!==a&&a,writeProgressMeasure:null!==(u=e.writeProgressMeasure)&&void 0!==u&&u,readRawScore:null!==(l=e.readRawScore)&&void 0!==l&&l,writeRawScore:null!==(c=e.writeRawScore)&&void 0!==c&&c,readMinScore:null!==(d=e.readMinScore)&&void 0!==d&&d,writeMinScore:null!==(f=e.writeMinScore)&&void 0!==f&&f,readMaxScore:null!==(v=e.readMaxScore)&&void 0!==v&&v,writeMaxScore:null!==(h=e.writeMaxScore)&&void 0!==h&&h,updateAttemptData:null!==(m=e.updateAttemptData)&&void 0!==m&&m}});return new Bn(e.objectiveID,{description:null!==(i=e.description)&&void 0!==i?i:null,satisfiedByMeasure:null!==(n=e.satisfiedByMeasure)&&void 0!==n&&n,minNormalizedMeasure:null!==(r=e.minNormalizedMeasure)&&void 0!==r?r:null,mapInfo:o,isPrimary:t})}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Oc(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function Ec(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Ac(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){Ec(e,t,i[t])})}return e}function kc(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,o=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Oc(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Oc(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 jc(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var Rc=Object.defineProperty,Mc=function(e,t,i){return function(e,t,i){return t in e?Rc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":jc(t))?t+"":t,i)},Tc=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Mc(this,"_globalObjectives",[]),Mc(this,"context"),this.context=t}return t=e,(i=[{key:"globalObjectives",get:function(){return this._globalObjectives},set:function(objectives){this._globalObjectives=objectives}},{key:"updateSequencingService",value:function(e){this.context.sequencingService=e}},{key:"syncGlobalObjectiveIdsFromSequencing",value:function(){if(this.context.sequencingService){var e=this.context.sequencingService.getOverallSequencingProcess();if(e){var t=e.getGlobalObjectiveMap();if(t&&0!==t.size){var i=Array.from(t.keys()),n=this.context.getSettings(),r=Array.from(new Set((n.globalObjectiveIds||[]).concat(i)));n.globalObjectiveIds=r}}}}},{key:"restoreGlobalObjectivesToCMI",value:function(){if(0!==this._globalObjectives.length)for(var e=0;this._globalObjectives.length>e;e++){var t=this._globalObjectives[e];if(t&&t.id&&!this.context.cmi.objectives.findObjectiveById(t.id)){var i=this.context.cmi.objectives.childArray.length;this.context.commonSetCMIValue("RestoreGlobalObjective",!0,"cmi.objectives.".concat(i,".id"),t.id),t.success_status&&"unknown"!==t.success_status&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,"cmi.objectives.".concat(i,".success_status"),t.success_status),t.completion_status&&"unknown"!==t.completion_status&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,"cmi.objectives.".concat(i,".completion_status"),t.completion_status),""!==t.score.scaled&&null!==t.score.scaled&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,"cmi.objectives.".concat(i,".score.scaled"),t.score.scaled),""!==t.score.raw&&null!==t.score.raw&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,"cmi.objectives.".concat(i,".score.raw"),t.score.raw),""!==t.score.min&&null!==t.score.min&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,"cmi.objectives.".concat(i,".score.min"),t.score.min),""!==t.score.max&&null!==t.score.max&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,"cmi.objectives.".concat(i,".score.max"),t.score.max),""!==t.progress_measure&&null!==t.progress_measure&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,"cmi.objectives.".concat(i,".progress_measure"),t.progress_measure),""!==t.description&&this.context.commonSetCMIValue("RestoreGlobalObjective",!0,"cmi.objectives.".concat(i,".description"),t.description)}}}},{key:"updateGlobalObjectiveFromCMI",value:function(e,t){var i;if(e&&this.context.sequencingService){var n=this.context.sequencingService.getOverallSequencingProcess();if(n)if(n.getGlobalObjectiveMap().has(e)){var r={};t.success_status&&t.success_status!==Se&&(r.satisfiedStatus=t.success_status===_e,r.satisfiedStatusKnown=!0);var o=this.parseObjectiveNumber(null===(i=t.score)||void 0===i?void 0:i.scaled);null!==o&&(r.normalizedMeasure=o,r.normalizedMeasureKnown=!0);var s=this.parseObjectiveNumber(t.progress_measure);null!==s&&(r.progressMeasure=s,r.progressMeasureKnown=!0),t.completion_status&&t.completion_status!==Oe&&(r.completionStatus=t.completion_status,r.completionStatusKnown=!0),0!==Object.keys(r).length&&n.updateGlobalObjective(e,r)}else{var a=this.buildObjectiveMapEntryFromCMI(t);n.updateGlobalObjective(e,a)}}}},{key:"buildObjectiveMapEntryFromCMI",value:function(e){var t,entry={id:e.id,satisfiedStatusKnown:!1,normalizedMeasureKnown:!1,progressMeasureKnown:!1,completionStatusKnown:!1,readSatisfiedStatus:!0,writeSatisfiedStatus:!0,readNormalizedMeasure:!0,writeNormalizedMeasure:!0,readCompletionStatus:!0,writeCompletionStatus:!0,readProgressMeasure:!0,writeProgressMeasure:!0};e.success_status&&e.success_status!==Se&&(entry.satisfiedStatus=e.success_status===_e,entry.satisfiedStatusKnown=!0);var i=this.parseObjectiveNumber(null===(t=e.score)||void 0===t?void 0:t.scaled);null!==i&&(entry.normalizedMeasure=i,entry.normalizedMeasureKnown=!0);var n=this.parseObjectiveNumber(e.progress_measure);return null!==n&&(entry.progressMeasure=n,entry.progressMeasureKnown=!0),e.completion_status&&e.completion_status!==Oe&&(entry.completionStatus=e.completion_status,entry.completionStatusKnown=!0),entry}},{key:"buildCMIObjectivesFromMap",value:function(e){var objectives=[];if(!e||"object"!==(void 0===e?"undefined":jc(e)))return objectives;var t=!0,i=!1,n=void 0;try{for(var r,o=Object.entries(e)[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s,a=kc(r.value,2),u=a[0],entry=a[1];if(entry&&"object"===(void 0===entry?"undefined":jc(entry))){var l=new mu;l.id=null!==(s=entry.id)&&void 0!==s?s:u,!0===entry.satisfiedStatusKnown&&(l.success_status=entry.satisfiedStatus?_e:be);var c=this.parseObjectiveNumber(entry.normalizedMeasure);!0===entry.normalizedMeasureKnown&&null!==c&&(l.score.scaled=c+"");var d=this.parseObjectiveNumber(entry.progressMeasure);!0===entry.progressMeasureKnown&&null!==d&&(l.progress_measure=d+""),!0===entry.completionStatusKnown&&"string"==typeof entry.completionStatus&&(l.completion_status=entry.completionStatus),objectives.push(l)}}}catch(e){i=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(i)throw n}}return objectives}},{key:"buildCMIObjectiveFromJSON",value:function(e){var t=new mu;if(!e||"object"!==(void 0===e?"undefined":jc(e)))return t;"string"==typeof e.id&&(t.id=e.id),"string"==typeof e.success_status&&(t.success_status=e.success_status),"string"==typeof e.completion_status&&(t.completion_status=e.completion_status),"string"==typeof e.progress_measure&&""!==e.progress_measure&&(t.progress_measure=e.progress_measure),"string"==typeof e.description&&(t.description=e.description);var score=e.score;return score&&"object"===(void 0===score?"undefined":jc(score))&&("string"==typeof score.scaled&&""!==score.scaled?t.score.scaled=score.scaled:"number"==typeof score.scaled&&Number.isFinite(score.scaled)&&(t.score.scaled=score.scaled+""),"string"==typeof score.raw&&""!==score.raw?t.score.raw=score.raw:"number"==typeof score.raw&&Number.isFinite(score.raw)&&(t.score.raw=score.raw+""),"string"==typeof score.min&&""!==score.min?t.score.min=score.min:"number"==typeof score.min&&Number.isFinite(score.min)&&(t.score.min=score.min+""),"string"==typeof score.max&&""!==score.max?t.score.max=score.max:"number"==typeof score.max&&Number.isFinite(score.max)&&(t.score.max=score.max+"")),t}},{key:"captureGlobalObjectiveSnapshot",value:function(e){var t,i,n={},r=null!==(t=null!=e?e:null===(i=this.context.sequencingService)||void 0===i?void 0:i.getOverallSequencingProcess())&&void 0!==t?t:null;if(r){var o=r.getGlobalObjectiveMapSnapshot(),s=!0,a=!1,u=void 0;try{for(var l,c=Object.entries(o)[Symbol.iterator]();!(s=(l=c.next()).done);s=!0){var d=kc(l.value,2);n[d[0]]=Ac({},d[1])}}catch(e){a=!0,u=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw u}}}var f=!0,v=!1,h=void 0;try{for(var m,p=this._globalObjectives[Symbol.iterator]();!(f=(m=p.next()).done);f=!0){var y=m.value;y.id&&!n[y.id]&&(n[y.id]=this.buildObjectiveMapEntryFromCMI(y))}}catch(e){v=!0,h=e}finally{try{f||null==p.return||p.return()}finally{if(v)throw h}}return n}},{key:"parseObjectiveNumber",value:function(e){if(null==e)return null;if("number"==typeof e&&Number.isFinite(e))return e;var t=parseFloat(e+"");return Number.isFinite(t)?t:null}},{key:"syncCmiToSequencingActivity",value:function(e,t,i){if(this.context.sequencing){var n=this.context.sequencing.getCurrentActivity();if(n&&n.primaryObjective){var r=n.primaryObjective;t!==Se&&(r.satisfiedStatus=t===_e,r.satisfiedStatusKnown=!0,r.measureStatus=!0,n.objectiveMeasureStatus=!0,n.objectiveSatisfiedStatus=t===_e,n.objectiveSatisfiedStatusKnown=!0),e!==Oe&&(r.completionStatus=e),void 0!==(null==i?void 0:i.scaled)&&null!==i.scaled&&(r.normalizedMeasure=i.scaled,r.measureStatus=!0)}}}},{key:"findOrCreateGlobalObjective",value:function(e){var t=this._globalObjectives.findIndex(function(t){return t.id===e});if(-1===t){t=this._globalObjectives.length;var i=new mu;i.id=e,this._globalObjectives.push(i)}return{index:t,objective:this._globalObjectives[t]}}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Pc(e,t,i,n,r,o,s){try{var a=e[o](s),u=a.value}catch(e){return void i(e)}a.done?t(u):Promise.resolve(u).then(n,r)}function Ic(e){return function(){var t=this,i=arguments;return new Promise(function(n,r){var o=e.apply(t,i);function s(e){Pc(o,n,r,s,a,"next",e)}function a(e){Pc(o,n,r,s,a,"throw",e)}s(void 0)})}}function xc(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Nc(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function Dc(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){xc(e,t,i[t])})}return e}function qc(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Lc(e,t){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(s,"next",{value:u(0)}),a(s,"throw",{value:u(1)}),a(s,"return",{value:u(2)}),"function"==typeof Symbol&&a(s,Symbol.iterator,{value:function(){return this}}),s;function u(a){return function(u){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&r[3]>a[1])){o.label=a[1];break}if(6===a[0]&&r[1]>o.label){o.label=r[1],r=a;break}if(r&&r[2]>o.label){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}var zc=Object.defineProperty,Fc=function(e,t,i){return function(e,t,i){return t in e?zc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":qc(t))?t+"":t,i)},Bc=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Fc(this,"context"),Fc(this,"globalObjectiveManager"),this.context=t,this.globalObjectiveManager=i}return t=e,(i=[{key:"saveSequencingState",value:function(e){return Ic(function(){var t,i,n,r,o,s,a;return Lc(this,function(u){switch(u.label){case 0:if(!(t=this.context.getSettings()).sequencingStatePersistence)return this.context.apiLog("saveSequencingState","No persistence configuration provided",Ee.WARN),[2,!1];u.label=1;case 1:if(u.trys.push([1,3,,4]),i=this.serializeSequencingState(),n=Dc({learnerId:this.context.learnerId||"unknown",courseId:t.courseId||"unknown",attemptNumber:1,lastUpdated:(new Date).toISOString(),version:t.sequencingStatePersistence.stateVersion||"1.0"},e),o=i,!1!==(r=t.sequencingStatePersistence).compress&&(o=this.compressStateData(i)),r.maxStateSize&&o.length>r.maxStateSize)throw Error("State size ".concat(o.length," exceeds limit ").concat(r.maxStateSize));return[4,r.persistence.saveState(o,n)];case 2:return s=u.sent(),r.debugPersistence&&this.context.apiLog("saveSequencingState","State save ".concat(s?"succeeded":"failed",": size=").concat(o.length),s?Ee.INFO:Ee.WARN),[2,s];case 3:return a=u.sent(),this.context.apiLog("saveSequencingState","Error saving sequencing state: ".concat(Nc(a,Error)?a.message:a+""),Ee.ERROR),[2,!1];case 4:return[2]}})}).call(this)}},{key:"loadSequencingState",value:function(e){return Ic(function(){var t,i,n,r,o,s,a;return Lc(this,function(u){switch(u.label){case 0:if(!(t=this.context.getSettings()).sequencingStatePersistence)return this.context.apiLog("loadSequencingState","No persistence configuration provided",Ee.WARN),[2,!1];u.label=1;case 1:return u.trys.push([1,3,,4]),i=Dc({learnerId:this.context.learnerId||"unknown",courseId:t.courseId||"unknown",attemptNumber:1,version:t.sequencingStatePersistence.stateVersion||"1.0"},e),[4,(n=t.sequencingStatePersistence).persistence.loadState(i)];case 2:return(r=u.sent())?(o=r,!1!==n.compress&&(o=this.decompressStateData(r)),s=this.deserializeSequencingState(o),n.debugPersistence&&this.context.apiLog("loadSequencingState","State load ".concat(s?"succeeded":"failed",": size=").concat(r.length),s?Ee.INFO:Ee.WARN),[2,s]):(n.debugPersistence&&this.context.apiLog("loadSequencingState","No sequencing state found to load",Ee.INFO),[2,!1]);case 3:return a=u.sent(),this.context.apiLog("loadSequencingState","Error loading sequencing state: ".concat(Nc(a,Error)?a.message:a+""),Ee.ERROR),[2,!1];case 4:return[2]}})}).call(this)}},{key:"serializeSequencingState",value:function(){var e,t={version:(null===(e=this.context.getSettings().sequencingStatePersistence)||void 0===e?void 0:e.stateVersion)||"1.0",timestamp:(new Date).toISOString(),sequencing:null,currentActivityId:null,globalObjectives:this.globalObjectiveManager.globalObjectives.map(function(e){return e.toJSON()}),globalObjectiveMap:{},adlNavState:{request:this.context.adl.nav.request,request_valid:this.context.adl.nav.request_valid},contentDelivered:!1};if(this.context.sequencingService){var i=this.context.sequencingService.getOverallSequencingProcess();if(i){var n=i.getSequencingState();t.sequencing=n,t.contentDelivered=i.hasContentBeenDelivered(),t.globalObjectiveMap=this.globalObjectiveManager.captureGlobalObjectiveSnapshot(i)}var r=this.context.sequencing.getCurrentActivity();r&&(t.currentActivityId=r.id)}return t.globalObjectiveMap&&0!==Object.keys(t.globalObjectiveMap).length||(t.globalObjectiveMap=this.globalObjectiveManager.captureGlobalObjectiveSnapshot()),JSON.stringify(t)}},{key:"deserializeSequencingState",value:function(e){var t=this;try{var i,n=JSON.parse(e),r=(null===(i=this.context.getSettings().sequencingStatePersistence)||void 0===i?void 0:i.stateVersion)||"1.0";if(n.version!==r&&this.context.apiLog("deserializeSequencingState","State version mismatch: ".concat(n.version," vs expected ").concat(r),Ee.WARN),n.globalObjectiveMap&&n.sequencing&&!n.sequencing.globalObjectiveMap&&(n.sequencing.globalObjectiveMap=n.globalObjectiveMap),n.sequencing&&this.context.sequencingService){var o=this.context.sequencingService.getOverallSequencingProcess();o&&(o.restoreSequencingState(n.sequencing),n.contentDelivered&&o.setContentDelivered(!0))}var s=new Map;if(Array.isArray(n.globalObjectives)){var a=!0,u=!1,l=void 0;try{for(var c,d=n.globalObjectives[Symbol.iterator]();!(a=(c=d.next()).done);a=!0){var f=this.globalObjectiveManager.buildCMIObjectiveFromJSON(c.value);f.id&&s.set(f.id,f)}}catch(e){u=!0,l=e}finally{try{a||null==d.return||d.return()}finally{if(u)throw l}}}if(n.globalObjectiveMap&&"object"===qc(n.globalObjectiveMap)){var v=this.globalObjectiveManager.buildCMIObjectivesFromMap(n.globalObjectiveMap),h=!0,m=!1,p=void 0;try{for(var y,g=v[Symbol.iterator]();!(h=(y=g.next()).done);h=!0){var _=y.value;_.id&&(s.has(_.id)||s.set(_.id,_))}}catch(e){m=!0,p=e}finally{try{h||null==g.return||g.return()}finally{if(m)throw p}}}return s.size>0&&(this.globalObjectiveManager.globalObjectives=Array.from(s.values()),this.globalObjectiveManager.globalObjectives.forEach(function(e){e.id&&t.globalObjectiveManager.updateGlobalObjectiveFromCMI(e.id,e)})),n.adlNavState&&(this.context.adl.nav.request=n.adlNavState.request||"_none_",this.context.adl.nav.request_valid=n.adlNavState.request_valid||{}),!0}catch(e){return this.context.apiLog("deserializeSequencingState","Error deserializing sequencing state: ".concat(Nc(e,Error)?e.message:e+""),Ee.ERROR),!1}}},{key:"compressStateData",value:function(e){return"undefined"!=typeof btoa?btoa(encodeURIComponent(e)):e}},{key:"decompressStateData",value:function(e){if("undefined"!=typeof atob)try{return decodeURIComponent(atob(e))}catch(t){return e}return e}}])&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Vc(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}var Hc=Object.defineProperty,Uc=function(e,t,i){return function(e,t,i){return t in e?Hc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t))?t+"":t,i)},Gc=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Uc(this,"context"),Uc(this,"globalObjectiveManager"),this.context=t,this.globalObjectiveManager=i||null}return t=e,i=[{key:"setGlobalObjectiveManager",value:function(e){this.globalObjectiveManager=e}},{key:"updateSequencingService",value:function(e){this.context.sequencingService=e}},{key:"renderCommitCMI",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.context.renderCMIToJSONObject();e||t?i.cmi.total_time=this.context.cmi.getCurrentTotalTime():delete i.cmi.total_time;var n=c(i);switch(this.context.getSettings().dataCommitFormat){case"flattened":return n;case"params":return Object.entries(n).map(function(e){var t,i,n=(i=2,function(e){if(Array.isArray(e))return e}(t=e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,o=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}}(t,i)||function(e,t){if(e){if("string"==typeof e)return Vc(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Vc(e,t):void 0}}(t,i)||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.")}()),r=n[1];return"".concat(n[0],"=").concat(r)});default:return i}}},{key:"renderCommitObject",value:function(e){var t,i,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.renderCommitCMI(e,n),o=e||n?this.context.cmi.getCurrentTotalTime():"",s=u(o,Ve),a=Oe,l=Se;this.context.cmi.completion_status&&("completed"===this.context.cmi.completion_status?a=we:"incomplete"===this.context.cmi.completion_status&&(a=Ce)),this.context.cmi.success_status&&("passed"===this.context.cmi.success_status?l=_e:"failed"===this.context.cmi.success_status&&(l=be));var c=(null===(i=this.context.cmi)||void 0===i||null===(t=i.score)||void 0===t?void 0:t.getScoreObject())||{},d={completionStatus:a,successStatus:l,totalTimeSeconds:s,runtimeData:r};c&&(d.score=c);var f=this.context.getSettings();if(f.autoPopulateCommitMetadata){var v,h;f.courseId&&(d.courseId=f.courseId),f.scoId&&(d.scoId=f.scoId),this.context.cmi.learner_id&&(d.learnerId=this.context.cmi.learner_id),this.context.cmi.learner_name&&(d.learnerName=this.context.cmi.learner_name);var m=null===(v=this.context.sequencingService)||void 0===v?void 0:v.getSequencingState();(null==m||null===(h=m.currentActivity)||void 0===h?void 0:h.id)&&(d.activityId=m.currentActivity.id)}return this.globalObjectiveManager&&this.globalObjectiveManager.syncCmiToSequencingActivity(a,l,c),d}},{key:"determineEntryValue",value:function(e,t){var i=null==e?void 0:e.trim();return""===e||null==e||""===i?"ab-initio":"suspend"===e?"resume":"logout"===e||"normal"===e?"":"time-out"===e&&t?"resume":""}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),e;var t,i}();function Yc(e,t,i,n,r,o,s){try{var a=e[o](s),u=a.value}catch(e){return void i(e)}a.done?t(u):Promise.resolve(u).then(n,r)}function Wc(e){return function(){var t=this,i=arguments;return new Promise(function(n,r){var o=e.apply(t,i);function s(e){Yc(o,n,r,s,a,"next",e)}function a(e){Yc(o,n,r,s,a,"throw",e)}s(void 0)})}}function Jc(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Kc(e){return Kc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Kc(e)}function $c(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function Xc(e,t){return Xc=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Xc(e,t)}function Qc(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Zc(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Zc=function(){return!!result})()}function ed(e,t){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(s,"next",{value:u(0)}),a(s,"throw",{value:u(1)}),a(s,"return",{value:u(2)}),"function"==typeof Symbol&&a(s,Symbol.iterator,{value:function(){return this}}),s;function u(a){return function(u){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&r[3]>a[1])){o.label=a[1];break}if(6===a[0]&&r[1]>o.label){o.label=r[1],r=a;break}if(r&&r[2]>o.label){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}var td=Object.defineProperty,nd=function(e,t,i){return function(e,t,i){return t in e?td(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i}(e,"symbol"!==(void 0===t?"undefined":Qc(t))?t+"":t,i)},rd=new Set(["cmi.suspend_data","cmi.location","cmi.scaled_passing_score","cmi.max_time_allowed","cmi.completion_threshold","cmi.progress_measure","cmi.score.scaled","cmi.score.raw","cmi.score.min","cmi.score.max","cmi.objectives.N.score.scaled","cmi.objectives.N.score.raw","cmi.objectives.N.score.min","cmi.objectives.N.score.max","cmi.objectives.N.progress_measure","cmi.objectives.N.description","cmi.interactions.N.weighting","cmi.interactions.N.type","cmi.interactions.N.timestamp","cmi.interactions.N.result","cmi.interactions.N.latency","cmi.interactions.N.learner_response","cmi.interactions.N.description","cmi.comments_from_learner.N.timestamp"]),Scorm2004API=function(e){function Scorm2004API(e,t){var i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Scorm2004API);var n=e?function(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){Jc(e,t,i[t])})}return e}({},e):void 0;n&&void 0===n.mastery_override&&(n.mastery_override=!1),i=function(e,t,i){return t=Kc(t),n=e,!(r=Zc()?Reflect.construct(t,i||[],Kc(e).constructor):t.apply(e,i))||"object"!==Qc(r)&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n):r;var n,r}(this,Scorm2004API,[ue,n,t]),nd(i,"_version","1.0"),nd(i,"_sequencing"),nd(i,"_sequencingService",null),nd(i,"_extractedScoItemIds",[]),nd(i,"_sequencingCollections",{}),nd(i,"_responseValidator"),nd(i,"_cmiHandler"),nd(i,"_activityTreeBuilder"),nd(i,"_sequencingConfigBuilder"),nd(i,"_globalObjectiveManager"),nd(i,"_statePersistence",null),nd(i,"_dataSerializer"),nd(i,"cmi"),nd(i,"adl"),nd(i,"Initialize"),nd(i,"Terminate"),nd(i,"GetValue"),nd(i,"SetValue"),nd(i,"Commit"),nd(i,"GetLastError"),nd(i,"GetErrorString"),nd(i,"GetDiagnostic"),i.cmi=new gl,i.adl=new Pl,i._sequencing=new sc,i.adl.sequencing=i._sequencing,i._sequencingConfigBuilder=new gc,i._activityTreeBuilder=new Cc({},i._sequencingConfigBuilder);var r={throwSCORMError:function(e,t,n){return i.throwSCORMError(e,t,n)},getLastErrorCode:function(){return i.lastErrorCode},checkCorrectResponseValue:function(e,t,n,r){return i._responseValidator.checkCorrectResponseValue(e,t,n,r)}};i._responseValidator=new uc(r);var o={cmi:i.cmi,isInitialized:function(){return i.isInitialized()},throwSCORMError:function(e,t,n){return i.throwSCORMError(e,t,n)},getLastErrorCode:function(){return i.lastErrorCode}};i._cmiHandler=new dc(o,i._responseValidator);var s={getSettings:function(){return i.settings},cmi:i.cmi,sequencing:i._sequencing,sequencingService:i._sequencingService,commonSetCMIValue:i._commonSetCMIValue.bind(i)};i._globalObjectiveManager=new Tc(s);var a={getSettings:function(){return i.settings},cmi:i.cmi,sequencingService:i._sequencingService,renderCMIToJSONObject:i.renderCMIToJSONObject.bind(i)};return i._dataSerializer=new Gc(a,i._globalObjectiveManager),(null==n?void 0:n.sequencing)&&i.configureSequencing(n.sequencing),i.initializeSequencingService(n),i.Initialize=i.lmsInitialize,i.Terminate=i.lmsFinish,i.GetValue=i.lmsGetValue,i.SetValue=i.lmsSetValue,i.Commit=i.lmsCommit,i.GetLastError=i.lmsGetLastError,i.GetErrorString=i.lmsGetErrorString,i.GetDiagnostic=i.lmsGetDiagnostic,i}return function(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}}),t&&Xc(e,t)}(Scorm2004API,e),t=Scorm2004API,i=[{key:"reset",value:function(e){var t,i;this.commonReset(e),null===(t=this.cmi)||void 0===t||t.reset(),null===(i=this.adl)||void 0===i||i.reset()}},{key:"version",get:function(){return this._version}},{key:"globalObjectives",get:function(){return this._globalObjectiveManager.globalObjectives}},{key:"_globalObjectives",get:function(){return this._globalObjectiveManager.globalObjectives},set:function(objectives){this._globalObjectiveManager.globalObjectives=objectives}},{key:"compressStateData",value:function(e){return this._statePersistence?this._statePersistence.compressStateData(e):"undefined"!=typeof btoa?btoa(encodeURIComponent(e)):e}},{key:"decompressStateData",value:function(e){if(this._statePersistence)return this._statePersistence.decompressStateData(e);if("undefined"!=typeof atob)try{return decodeURIComponent(atob(e))}catch(t){return e}return e}},{key:"lmsInitialize",value:function(){var e=this;if(""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:""))return this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),F;this.cmi.initialize();var result=this.initialize("Initialize","LMS was already initialized!","LMS is already finished!");return result===z&&this._sequencingService&&this._sequencingService.initialize(),result===z&&this._globalObjectiveManager.restoreGlobalObjectivesToCMI(),result===z&&this.settings.sequencingStatePersistence&&this.loadSequencingState().catch(function(){e.apiLog("lmsInitialize","Failed to auto-load sequencing state",Ee.WARN)}),result}},{key:"lmsFinish",value:function(){var e,t,i,n,r;if(""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:""))return this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),F;var o=(null===(i=this.adl)||void 0===i||null===(t=i.nav)||void 0===t?void 0:t.request)||"_none_",s=(null===(n=this.cmi)||void 0===n?void 0:n.getExitValueInternal())||"",a=this.isTerminated(),u=null!==(e=null===(r=this._sequencingService)||void 0===r?void 0:r.isDeliveryInProgress())&&void 0!==e&&e,result=this.terminate("Terminate",!0);if(result===z&&!a&&!u){var l=!1,c=null,d=o,f="",v=RegExp(Je);if("_none_"!==o){var h,m,p,y=o.match(v);if(y)if(null===(h=y.groups)||void 0===h?void 0:h.choice_target)f=null===(p=y.groups)||void 0===p?void 0:p.choice_target,d="choice";else if(null===(m=y.groups)||void 0===m?void 0:m.jump_target){var g;f=null===(g=y.groups)||void 0===g?void 0:g.jump_target,d="jump"}}if(this._sequencingService)try{var _,b=null;"_none_"!==d?(b=d,_=f||void 0):this._sequencing.getCurrentActivity()&&(b="exit"),b&&(l=this._sequencingService.processNavigationRequest(b,_,s),c=b)}catch(e){this.apiLog("lmsFinish","Sequencing navigation failed, falling back to event-based navigation: ".concat(e),Ee.WARN),l=!1}if(!l)if("_none_"!==o){var S={continue:"SequenceNext",previous:"SequencePrevious",choice:"SequenceChoice",jump:"SequenceJump",exit:"SequenceExit",exitAll:"SequenceExitAll",abandon:"SequenceAbandon",abandonAll:"SequenceAbandonAll"}[d];S&&this.processListeners(S,"adl.nav.request",f)}else this.settings.autoProgress&&this.processListeners("SequenceNext",void 0,"next");this._sequencingService&&c&&["exitAll","abandonAll","suspendAll"].includes(c)&&this._sequencingService.terminate(),this.adl.nav.request="_none_"}return result}},{key:"lmsGetValue",value:function(e){if(this.isTerminated())return this.lastErrorCode=ue.RETRIEVE_AFTER_TERM+"","";if(!this.isInitialized())return this.lastErrorCode=ue.RETRIEVE_BEFORE_INIT+"","";if("adl.nav.request"===e)return this.throwSCORMError(e,ue.WRITE_ONLY_ELEMENT,"adl.nav.request is write-only"),"";var t="^adl\\.nav\\.request_valid\\.(choice|jump)\\.{target=([a-zA-Z0-9-_]+)}$";if(f(e,t)){var i=e.match(t);if(i){var n,request=i[1],r=(null===(n=i[2])||void 0===n?void 0:n.replace(/{target=/g,"").replace(/}/g,""))||"";if("choice"===request||"jump"===request){var o,s,a,u=null===(o=this._sequencing)||void 0===o?void 0:o.overallSequencingProcess;return this.settings.scoItemIdValidator?this.settings.scoItemIdValidator(r)+"":(null==u?void 0:u.predictChoiceEnabled)&&"choice"===request?u.predictChoiceEnabled(r)?"true":"false":(null==u?void 0:u.predictJumpEnabled)&&"jump"===request?u.predictJumpEnabled(r)?"true":"false":this._extractedScoItemIds.length>0?this._extractedScoItemIds.includes(r)+"":(null===(a=this.settings)||void 0===a||null===(s=a.scoItemIds)||void 0===s?void 0:s.includes(r))+""}}}return"cmi.completion_status"===e?this._cmiHandler.evaluateCompletionStatus():"cmi.success_status"===e?this._cmiHandler.evaluateSuccessStatus():this.getValue("GetValue",!0,e)}},{key:"lmsSetValue",value:function(e,t){var i,n=this,r=this._peekCMIValue(e),result=this.setValue("SetValue","Commit",!0,e,t);if(result===z&&this._sequencingService)try{this._sequencingService.triggerRollupOnCMIChange(e,r,t)}catch(t){console.warn("Sequencing rollup failed for ".concat(e,": ").concat(t))}return result===z&&"setValue"===(null===(i=this.settings.sequencingStatePersistence)||void 0===i?void 0:i.autoSaveOn)&&["cmi.completion_status","cmi.success_status","cmi.score.scaled","cmi.objectives","adl.nav.request"].some(function(t){return e.startsWith(t)})&&this.saveSequencingState().catch(function(){n.apiLog("lmsSetValue","Failed to auto-save sequencing state",Ee.WARN)}),result}},{key:"lmsCommit",value:function(){var e=this;if(""!==(arguments.length>0&&void 0!==arguments[0]?arguments[0]:""))return this.throwSCORMError("api",this._error_codes.ARGUMENT_ERROR),F;if(this.settings.throttleCommits)return this.scheduleCommit(500,"Commit"),z;var t,result=this.commit("Commit",!0);return result===z&&"commit"===(null===(t=this.settings.sequencingStatePersistence)||void 0===t?void 0:t.autoSaveOn)&&this.saveSequencingState().catch(function(){e.apiLog("lmsCommit","Failed to auto-save sequencing state",Ee.WARN)}),result}},{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){if(f(e,"cmi\\.objectives\\.\\d+")){var i,n,r=+e.split(".")[2],o="cmi.objectives.".concat(r);if(f(e,"cmi\\.objectives\\.\\d+\\.id"))n=t;else{var s=this.cmi.objectives.findObjectiveByIndex(r);n=s?s.id:void 0}if(n&&(null===(i=this.settings.globalObjectiveIds)||void 0===i?void 0:i.includes(n))){var a=this._globalObjectiveManager.findOrCreateGlobalObjective(n).index,u=e.replace(o,"_globalObjectives.".concat(a));this._commonSetCMIValue("SetGlobalObjectiveValue",!0,u,t);var l=this._globalObjectiveManager.globalObjectives[a];n&&l&&this._globalObjectiveManager.updateGlobalObjectiveFromCMI(n,l)}}return this._commonSetCMIValue("SetValue",!0,e,t)}},{key:"getChildElement",value:function(e,t,i){return this._cmiHandler.getChildElement(e,t,i)}},{key:"validateCorrectResponse",value:function(e,t){var i=e.split("."),n=this.cmi.interactions.childArray[+i[2]];n?this._responseValidator.validateCorrectResponse(e,n,t):this.throwSCORMError(e,ue.DEPENDENCY_NOT_ESTABLISHED,e)}},{key:"_peekCMIValue",value:function(e){if(!e||"string"!=typeof e)return null;for(var t=e.split("."),i=this,n=0;t.length>n;n++){var r=t[n];if(null==i)return null;try{i=i[r]}catch(e){return null}if($c(i,me)){var o=n+1;if(o>=t.length)return i;var s=+t[o];if(!Number.isNaN(s)&&Number.isInteger(s)&&s>=0){if(s>=i.childArray.length)return null;i=i.childArray[s],n++}}}return null!=i?i:null}},{key:"getCMIValue",value:function(e){return this._commonGetCMIValue("GetValue",!0,e)}},{key:"checkUninitializedGet",value:function(e,t){var i;""===t&&(this._setCMIElements.has(e)||rd.has(function(e){return e.replace(/\.\d+(?=\.|$)/g,".N")}(e))&&this.throwSCORMError(e,null!==(i=this._error_codes.VALUE_NOT_INITIALIZED)&&void 0!==i?i:403,"The data model element passed to GetValue (".concat(e,") has not been initialized.")))}},{key:"getLmsErrorMessageDetails",value:function(e,t){var i="",n="",r=V.error_descriptions[e+=""];return r&&(i=r.basicMessage,n=r.detailMessage),t?n:i}},{key:"replaceWithAnotherScormAPI",value:function(e){this.cmi=e.cmi,this.adl=e.adl}},{key:"renderCommitCMI",value:function(e){return this._dataSerializer.renderCommitCMI(e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}},{key:"renderCommitObject",value:function(e){return this._dataSerializer.renderCommitObject(e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}},{key:"storeData",value:function(e,t){var i,n,r,o,s;e&&"normal"===this.cmi.mode&&"credit"===this.cmi.credit&&(this.cmi.completion_threshold&&this.cmi.progress_measure&&(this.cmi.completion_status=this.cmi.completion_threshold>this.cmi.progress_measure?"incomplete":"completed"),this.cmi.scaled_passing_score&&this.cmi.score.scaled&&(this.cmi.success_status=this.cmi.scaled_passing_score>this.cmi.score.scaled?"failed":"passed"));var a=!1;this.adl.nav.request!==(null===(r=this.startingData)||void 0===r||null===(n=r.adl)||void 0===n||null===(i=n.nav)||void 0===i?void 0:i.request)&&"_none_"!==this.adl.nav.request&&(a=!0);var u=this.getCommitObject(e),l=(null===(s=this.cmi)||void 0===s||null===(o=s.score)||void 0===o?void 0:o.getScoreObject())||{},c=Oe;"completed"===this.cmi.completion_status?c=we:"incomplete"===this.cmi.completion_status&&(c=Ce);var d=Se;if("passed"===this.cmi.success_status?d=_e:"failed"===this.cmi.success_status&&(d=be),this._globalObjectiveManager.syncCmiToSequencingActivity(c,d,l),"string"==typeof this.settings.lmsCommitUrl){var result=this.processHttpRequest(this.settings.lmsCommitUrl,u,e,t);if(a&&void 0!==result.navRequest&&""!==result.navRequest&&"string"==typeof result.navRequest){var f=function(e){var t=new Set(["start","resumeAll","continue","previous","choice","jump","exit","exitAll","abandon","abandonAll","suspendAll","_none_"]),i=e.trim();if(!i)return{command:"_none_",targetActivityId:null,valid:!1,error:"Empty navigation request"};if(t.has(i))return{command:i,targetActivityId:null,valid:!0};var n=i.indexOf(".");if(n>0){var r=i.substring(0,n),o=i.substring(n+1);if(("choice"===r||"jump"===r)&&o)return/^[a-zA-Z0-9._-]+$/.test(o)?{command:r,targetActivityId:o,valid:!0}:{command:"_none_",targetActivityId:null,valid:!1,error:"Invalid target activity ID: contains disallowed characters"}}return{command:"_none_",targetActivityId:null,valid:!1,error:'Unrecognized navigation command: "'.concat(i,'"')}}(result.navRequest);if(f.valid){var v={start:"SequenceStart",resumeAll:"SequenceResumeAll",continue:"SequenceNext",previous:"SequencePrevious",choice:"SequenceChoice",jump:"SequenceJump",exit:"SequenceExit",exitAll:"SequenceExitAll",abandon:"SequenceAbandon",abandonAll:"SequenceAbandonAll",suspendAll:"SequenceSuspendAll"}[f.command];v&&this.processListeners(v,"adl.nav.request",f.targetActivityId)}else this.apiLog("storeData","Invalid navigation request from LMS: ".concat(f.error),Ee.WARN)}else(null==result?void 0:result.navRequest)&&!a&&"object"===Qc(result.navRequest)&&Object.hasOwnProperty.call(result.navRequest,"name")&&result.navRequest.name&&this.processListeners(result.navRequest.name,result.navRequest.data);return result}return{result:z,errorCode:0}}},{key:"configureSequencing",value:function(e){this._sequencingCollections=this._sequencingConfigBuilder.sanitizeSequencingCollections(e.collections),this._activityTreeBuilder.setSequencingCollections(this._sequencingCollections),e.activityTree&&this.configureActivityTree(e.activityTree),e.sequencingRules&&this.configureSequencingRules(e.sequencingRules),e.sequencingControls&&this.configureSequencingControls(e.sequencingControls),e.rollupRules&&this.configureRollupRules(e.rollupRules),this._sequencing.hideLmsUi=e.hideLmsUi?this._sequencingConfigBuilder.sanitizeHideLmsUi(e.hideLmsUi):[],this._sequencing.auxiliaryResources=e.auxiliaryResources?this._sequencingConfigBuilder.sanitizeAuxiliaryResources(e.auxiliaryResources):[]}},{key:"configureActivityTree",value:function(e){var t=this._activityTreeBuilder.createActivity(e);this._sequencing.activityTree.root=t,this._extractedScoItemIds=this._activityTreeBuilder.extractActivityIds(t)}},{key:"configureSequencingRules",value:function(e){this._sequencingConfigBuilder.applySequencingRulesSettings(this._sequencing.sequencingRules,e)}},{key:"configureSequencingControls",value:function(e){this._sequencingConfigBuilder.applySequencingControlsSettings(this._sequencing.sequencingControls,e)}},{key:"configureRollupRules",value:function(e){this._sequencingConfigBuilder.applyRollupRulesSettings(this._sequencing.rollupRules,e)}},{key:"initializeSequencingService",value:function(e){var t=this;try{var i,n,r,o,s,a,u,l,c,d,f,v={autoRollupOnCMIChange:null===(i=null==e||null===(a=e.sequencing)||void 0===a?void 0:a.autoRollupOnCMIChange)||void 0===i||i,autoProgressOnCompletion:null!==(n=null==e||null===(u=e.sequencing)||void 0===u?void 0:u.autoProgressOnCompletion)&&void 0!==n&&n,validateNavigationRequests:null===(r=null==e||null===(l=e.sequencing)||void 0===l?void 0:l.validateNavigationRequests)||void 0===r||r,enableEventSystem:null===(o=null==e||null===(c=e.sequencing)||void 0===c?void 0:c.enableEventSystem)||void 0===o||o,logLevel:null!==(s=null==e||null===(d=e.sequencing)||void 0===d?void 0:d.logLevel)&&void 0!==s?s:"info"};if(this._sequencingService=new po(this._sequencing,this.cmi,this.adl,this.eventService||this,this.loggingService,v),(null==e||null===(f=e.sequencing)||void 0===f?void 0:f.eventListeners)&&this._sequencingService.setEventListeners(e.sequencing.eventListeners),this._globalObjectiveManager.updateSequencingService(this._sequencingService),this._dataSerializer.updateSequencingService(this._sequencingService),null==e?void 0:e.sequencingStatePersistence){var h={getSettings:function(){return t.settings},apiLog:this.apiLog.bind(this),adl:this.adl,sequencing:this._sequencing,sequencingService:this._sequencingService,learnerId:this.cmi.learner_id};this._statePersistence=new Bc(h,this._globalObjectiveManager)}this._globalObjectiveManager.syncGlobalObjectiveIdsFromSequencing()}catch(e){console.warn("Failed to initialize sequencing service:",e),this._sequencingService=null}}},{key:"getSequencingService",value:function(){return this._sequencingService}},{key:"setSequencingEventListeners",value:function(e){this._sequencingService&&this._sequencingService.setEventListeners(e)}},{key:"updateSequencingConfiguration",value:function(e){this._sequencingService&&this._sequencingService.updateConfiguration(e)}},{key:"getSequencingState",value:function(){return this._sequencingService?this._sequencingService.getSequencingState():{isInitialized:!1,isActive:!1,currentActivity:null,rootActivity:this._sequencing.getRootActivity(),lastSequencingResult:null}}},{key:"processNavigationRequest",value:function(request,e){return!!this._sequencingService&&this._sequencingService.processNavigationRequest(request,e)}},{key:"resetSequencingState",value:function(){var e,t;null===(e=this._sequencing)||void 0===e||e.reset(),null===(t=this._sequencingService)||void 0===t||t.setEventListeners({})}},{key:"getActivityTrackingData",value:function(e){var t,i;if(!(null===(i=this._sequencing)||void 0===i?void 0:i.activityTree))return null;var n=this._sequencing.activityTree.getActivity(e);return n?{completionStatus:n.completionStatus||"unknown",successStatus:n.successStatus||"unknown",progressMeasure:null!==(t=n.progressMeasure)&&void 0!==t?t:null,score:n.objectiveMeasureStatus?n.objectiveNormalizedMeasure:null}:null}},{key:"saveSequencingState",value:function(e){return Wc(function(){var t,i;return ed(this,function(n){return t=this,this._statePersistence?[2,this._statePersistence.saveSequencingState(e)]:this.settings.sequencingStatePersistence?(i={getSettings:function(){return t.settings},apiLog:this.apiLog.bind(this),adl:this.adl,sequencing:this._sequencing,sequencingService:this._sequencingService,learnerId:this.cmi.learner_id},[2,new Bc(i,this._globalObjectiveManager).saveSequencingState(e)]):(this.apiLog("saveSequencingState","No persistence configuration provided",Ee.WARN),[2,!1])})}).call(this)}},{key:"loadSequencingState",value:function(e){return Wc(function(){var t,i;return ed(this,function(n){return t=this,this._statePersistence?[2,this._statePersistence.loadSequencingState(e)]:this.settings.sequencingStatePersistence?(i={getSettings:function(){return t.settings},apiLog:this.apiLog.bind(this),adl:this.adl,sequencing:this._sequencing,sequencingService:this._sequencingService,learnerId:this.cmi.learner_id},[2,new Bc(i,this._globalObjectiveManager).loadSequencingState(e)]):(this.apiLog("loadSequencingState","No persistence configuration provided",Ee.WARN),[2,!1])})}).call(this)}},{key:"serializeSequencingState",value:function(){var e=this;if(this._statePersistence)return this._statePersistence.serializeSequencingState();var t={getSettings:function(){return e.settings},apiLog:this.apiLog.bind(this),adl:this.adl,sequencing:this._sequencing,sequencingService:this._sequencingService,learnerId:this.cmi.learner_id};return new Bc(t,this._globalObjectiveManager).serializeSequencingState()}},{key:"deserializeSequencingState",value:function(e){var t=this;if(this._statePersistence)return this._statePersistence.deserializeSequencingState(e);var i={getSettings:function(){return t.settings},apiLog:this.apiLog.bind(this),adl:this.adl,sequencing:this._sequencing,sequencingService:this._sequencingService,learnerId:this.cmi.learner_id};return new Bc(i,this._globalObjectiveManager).deserializeSequencingState(e)}},{key:"determineEntryValue",value:function(e,t){return this._dataSerializer.determineEntryValue(e,t)}}],i&&function(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),Scorm2004API;var t,i}(Do);"undefined"!=typeof window&&(window.Scorm12API=Scorm12API,window.Scorm2004API=Scorm2004API)}();
2
2
  //# sourceMappingURL=scorm-again.min.js.map