"0.50.0";var CryptoJS=CryptoJS||function(a,b){var c={},d=c.lib={},e=function(){},f=d.Base={extend:function(a){e.prototype=this;var b=new e;return a&&b.mixIn(a),b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},g=d.WordArray=f.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=c!=b?c:4*a.length},toString:function(a){return(a||i).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes;if(a=a.sigBytes,this.clamp(),d%4)for(var e=0;e>>2]|=(c[e>>>2]>>>24-8*(e%4)&255)<<24-8*((d+e)%4);else if(65535>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=f.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;d>>2]>>>24-8*(d%4)&255;c.push((e>>>4).toString(16)),c.push((15&e).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return new g.init(c,b/2)}},j=h.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(255&a.charCodeAt(d))<<24-8*(d%4);return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(a){throw Error("Malformed UTF-8 data")}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}},l=d.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=k.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,f=this.blockSize,h=e/(4*f),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0);if(b=h*f,e=a.min(4*b,e),b){for(var i=0;ij;j++){if(16>j)e[j]=0|a[b+j];else{var k=e[j-3]^e[j-8]^e[j-14]^e[j-16];e[j]=k<<1|k>>>31}k=(d<<5|d>>>27)+i+e[j],k=20>j?k+((f&g|~f&h)+1518500249):40>j?k+((f^g^h)+1859775393):60>j?k+((f&g|f&h|g&h)-1894007588):k+((f^g^h)-899497514),i=h,h=g,g=f<<30|f>>>2,f=d,d=k}c[0]=c[0]+d|0,c[1]=c[1]+f|0,c[2]=c[2]+g|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a}});a.SHA1=d._createHelper(b),a.HmacSHA1=d._createHmacHelper(b)}();var CryptoJS=CryptoJS||function(a,b){var c={},d=c.lib={},e=function(){},f=d.Base={extend:function(a){e.prototype=this;var b=new e;return a&&b.mixIn(a),b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},g=d.WordArray=f.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=c!=b?c:4*a.length},toString:function(a){return(a||i).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes;if(a=a.sigBytes,this.clamp(),d%4)for(var e=0;e>>2]|=(c[e>>>2]>>>24-8*(e%4)&255)<<24-8*((d+e)%4);else if(65535>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=f.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;d>>2]>>>24-8*(d%4)&255;c.push((e>>>4).toString(16)),c.push((15&e).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return new g.init(c,b/2)}},j=h.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(255&a.charCodeAt(d))<<24-8*(d%4);return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(a){throw Error("Malformed UTF-8 data")}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}},l=d.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=k.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,f=this.blockSize,h=e/(4*f),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0);if(b=h*f,e=a.min(4*b,e),b){for(var i=0;ij;){var k;a:{k=i;for(var l=a.sqrt(k),m=2;m<=l;m++)if(!(k%m)){k=!1;break a}k=!0}k&&(8>j&&(f[j]=h(a.pow(i,.5))),g[j]=h(a.pow(i,1/3)),j++),i++}var n=[],c=c.SHA256=e.extend({_doReset:function(){this._hash=new d.init(f.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=0;64>m;m++){if(16>m)n[m]=0|a[b+m];else{var o=n[m-15],p=n[m-2];n[m]=((o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3)+n[m-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[m-16]}o=l+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+(i&j^~i&k)+g[m]+n[m],p=((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&e^d&f^e&f),l=k,k=j,j=i,i=h+o|0,h=f,f=e,e=d,d=o+p|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0,c[5]=c[5]+j|0,c[6]=c[6]+k|0,c[7]=c[7]+l|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA256=e._createHelper(c),b.HmacSHA256=e._createHmacHelper(c)}(Math),function(){var a=CryptoJS,b=a.lib,c=b.WordArray,d=a.enc;d.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;f>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;k<4&&f+.75*k>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,d=this._map,e=d.charAt(64);if(e){var f=a.indexOf(e);f!=-1&&(b=f)}for(var g=[],h=0,i=0;i>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return c.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(){if("function"==typeof ArrayBuffer){var a=CryptoJS,b=a.lib,c=b.WordArray,d=c.init,e=c.init=function(a){if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),(a instanceof Int8Array||a instanceof Uint8ClampedArray||a instanceof Int16Array||a instanceof Uint16Array||a instanceof Int32Array||a instanceof Uint32Array||a instanceof Float32Array||a instanceof Float64Array)&&(a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),a instanceof Uint8Array){for(var b=a.byteLength,c=[],e=0;e>>2]|=a[e]<<24-e%4*8;d.call(this,c,b)}else d.apply(this,arguments)};e.prototype=c}}();var TinCan;!function(){"use strict";var a={statementId:!0,voidedStatementId:!0,verb:!0,object:!0,registration:!0,context:!0,actor:!0,since:!0,until:!0,limit:!0,authoritative:!0,sparse:!0,instructor:!0,ascending:!0,continueToken:!0,agent:!0,activityId:!0,stateId:!0,profileId:!0,activity_platform:!0,grouping:!0,"Accept-Language":!0};TinCan=function(a){this.log("constructor"),this.recordStores=[],this.actor=null,this.activity=null,this.registration=null,this.context=null,this.init(a)},TinCan.prototype={LOG_SRC:"TinCan",log:function(a,b){TinCan.DEBUG&&"undefined"!=typeof console&&console.log&&(b=b||this.LOG_SRC||"TinCan",console.log("TinCan."+b+": "+a))},init:function(a){this.log("init");var b;if(a=a||{},a.hasOwnProperty("url")&&""!==a.url&&this._initFromQueryString(a.url),a.hasOwnProperty("recordStores")&&void 0!==a.recordStores)for(b=0;b0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatement - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatement - unexpected record store count: "+h)}),d=0;d0?(d=this.recordStores[0],d.retrieveStatement(a,{callback:b,params:c.params})):void this.log("[warning] getStatement: No LRSs added yet (statement not retrieved)")},voidStatement:function(a,b,c){this.log("voidStatement");var d,e,f,g,h,i=this,j=this.recordStores.length,k=[],l=[];if(a instanceof TinCan.Statement&&(a=a.id),"undefined"!=typeof c.actor?e=c.actor:null!==this.actor&&(e=this.actor),f=new TinCan.Statement({actor:e,verb:{id:"http://adlnet.gov/expapi/verbs/voided"},target:{objectType:"StatementRef",id:a}}),j>0)for("function"==typeof b&&(h=function(a,c){var d;i.log("voidStatement - callbackWrapper: "+j),j>1?(j-=1,l.push({err:a,xhr:c})):1===j?(l.push({err:a,xhr:c}),d=[l,f],b.apply(this,d)):i.log("voidStatement - unexpected record store count: "+j)}),g=0;g0?(c=this.recordStores[0],c.retrieveVoidedStatement(a,{callback:b})):void this.log("[warning] getVoidedStatement: No LRSs added yet (statement not retrieved)")},sendStatements:function(a,b){this.log("sendStatements");var c,d,e,f=this,g=[],h=this.recordStores.length,i=[],j=[];if(0===a.length)"function"==typeof b&&b.apply(this,[null,g]);else{for(d=0;d0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatements - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatements - unexpected record store count: "+h)}),d=0;d0?(b=this.recordStores[0],a=a||{},c=a.params||{},a.sendActor&&null!==this.actor&&("0.9"===b.version||"0.95"===b.version?c.actor=this.actor:c.agent=this.actor),a.sendActivity&&null!==this.activity&&("0.9"===b.version||"0.95"===b.version?c.target=this.activity:c.activity=this.activity),"undefined"==typeof c.registration&&null!==this.registration&&(c.registration=this.registration),d={params:c},"undefined"!=typeof a.callback&&(d.callback=a.callback),b.queryStatements(d)):void this.log("[warning] getStatements: No LRSs added yet (statements not read)")},getState:function(a,b){this.log("getState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveState(a,c)):void this.log("[warning] getState: No LRSs added yet (state not retrieved)")},setState:function(a,b,c){this.log("setState");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor,activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.registration?d.registration=c.registration:null!==this.registration&&(d.registration=this.registration),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&TinCan.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),"undefined"!=typeof c.callback&&(d.callback=c.callback),e.saveState(a,b,d)):void this.log("[warning] setState: No LRSs added yet (state not saved)")},deleteState:function(a,b){this.log("deleteState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropState(a,c)):void this.log("[warning] deleteState: No LRSs added yet (state not deleted)")},getActivityProfile:function(a,b){this.log("getActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveActivityProfile(a,c)):void this.log("[warning] getActivityProfile: No LRSs added yet (activity profile not retrieved)")},setActivityProfile:function(a,b,c){this.log("setActivityProfile");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&TinCan.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),e.saveActivityProfile(a,b,d)):void this.log("[warning] setActivityProfile: No LRSs added yet (activity profile not saved)")},deleteActivityProfile:function(a,b){this.log("deleteActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropActivityProfile(a,c)):void this.log("[warning] deleteActivityProfile: No LRSs added yet (activity profile not deleted)")},getAgentProfile:function(a,b){this.log("getAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveAgentProfile(a,c)):void this.log("[warning] getAgentProfile: No LRSs added yet (agent profile not retrieved)")},setAgentProfile:function(a,b,c){this.log("setAgentProfile");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&TinCan.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),e.saveAgentProfile(a,b,d)):void this.log("[warning] setAgentProfile: No LRSs added yet (agent profile not saved)")},deleteAgentProfile:function(a,b){this.log("deleteAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropAgentProfile(a,c)):void this.log("[warning] deleteAgentProfile: No LRSs added yet (agent profile not deleted)")}},TinCan.DEBUG=!1,TinCan.enableDebug=function(){TinCan.DEBUG=!0},TinCan.disableDebug=function(){TinCan.DEBUG=!1},TinCan.versions=function(){return["1.0.2","1.0.1","1.0.0","0.95","0.9"]},"object"==typeof module&&(module.exports=TinCan)}(),function(){"use strict";TinCan.Utils={defaultEncoding:"utf8",getUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},getISODateString:function(a){function b(a,b){var c,d;for("undefined"!=typeof a&&null!==a||(a=0),"undefined"!=typeof b&&null!==b||(b=2),c=Math.pow(10,b-1),d=a.toString();a1;)d="0"+d,c/=10;return d}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"."+b(a.getUTCMilliseconds(),3)+"Z"},convertISO8601DurationToMilliseconds:function(a){var b,c,d,e,f=a.indexOf("-")>=0,g=a.indexOf("T"),h=a.indexOf("H"),i=a.indexOf("M"),j=a.indexOf("S");if(g===-1||i!==-1&&i0&&(h+=b+"H"),c>0&&(h+=c+"M"),h+=d+"S"},getSHA1String:function(a){return CryptoJS.SHA1(a).toString(CryptoJS.enc.Hex)},getSHA256String:function(a){return"[object ArrayBuffer]"===Object.prototype.toString.call(a)&&(a=CryptoJS.lib.WordArray.create(a)),CryptoJS.SHA256(a).toString(CryptoJS.enc.Hex)},getBase64String:function(a){return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Latin1.parse(a))},getLangDictionaryValue:function(a,b){var c,d=this[a];if("undefined"!=typeof b&&"undefined"!=typeof d[b])return d[b];if("undefined"!=typeof d.und)return d.und;if("undefined"!=typeof d["en-US"])return d["en-US"];for(c in d)if(d.hasOwnProperty(c))return d[c];return""},parseURL:function(a,b){var c,d,e,f,g="/"===a.charAt(0),h=["(/[^?#]*)","(\\?[^#]*|)","(#.*|)$"],i=/\+/g,j=/([^&=]+)=?([^&]*)/g,k=function(a){return decodeURIComponent(a.replace(i," "))};if(b=b||{},g){if("undefined"==typeof b.allowRelative||!b.allowRelative)throw new Error("Refusing to parse relative URL without 'allowRelative' option")}else h.unshift("^(https?:)//","(([^:/?#]*)(?::([0-9]+))?)"),a.indexOf("/",8)===-1&&(a+="/");if(c=new RegExp(h.join("")),d=a.match(c),null===d)throw new Error("Unable to parse URL regular expression did not match: '"+a+"'");if(g?(e={protocol:null,host:null,hostname:null,port:null,path:null,pathname:d[1],search:d[2],hash:d[3],params:{}},e.path=e.pathname):(e={protocol:d[1],host:d[2],hostname:d[3],port:d[4],pathname:d[5],search:d[6],hash:d[7],params:{}},e.path=e.protocol+"//"+e.host+e.pathname),""!==e.search)for(;f=j.exec(e.search.substring(1));)e.params[k(f[1])]=k(f[2]);return e},getServerRoot:function(a){var b=a.split("/");return b[0]+"//"+b[2]},getContentTypeFromHeader:function(a){return String(a).split(";")[0]},isApplicationJSON:function(a){return 0===TinCan.Utils.getContentTypeFromHeader(a).toLowerCase().indexOf("application/json")},stringToArrayBuffer:function(){TinCan.prototype.log("stringToArrayBuffer not overloaded - no environment loaded?")},stringFromArrayBuffer:function(){TinCan.prototype.log("stringFromArrayBuffer not overloaded - no environment loaded?")}}}(),function(){"use strict";var a=TinCan.LRS=function(a){this.log("constructor"),this.endpoint=null,this.version=null,this.auth=null,this.allowFail=!0,this.extended=null,this.init(a)};a.prototype={LOG_SRC:"LRS",log:TinCan.prototype.log,init:function(a){this.log("init");var b,c=TinCan.versions(),d=!1;if(a=a||{},a.hasOwnProperty("alertOnRequestFailure")&&this.log("'alertOnRequestFailure' is deprecated (alerts have been removed) no need to set it now"),!a.hasOwnProperty("endpoint")||null===a.endpoint||""===a.endpoint)throw this.log("[error] LRS invalid: no endpoint"),{code:3,mesg:"LRS invalid: no endpoint"};if(this.endpoint=String(a.endpoint),"/"!==this.endpoint.slice(-1)&&(this.log("adding trailing slash to endpoint"),this.endpoint+="/"),a.hasOwnProperty("allowFail")&&(this.allowFail=a.allowFail),a.hasOwnProperty("auth")?this.auth=a.auth:a.hasOwnProperty("username")&&a.hasOwnProperty("password")&&(this.auth="Basic "+TinCan.Utils.getBase64String(a.username+":"+a.password)),a.hasOwnProperty("extended")&&(this.extended=a.extended),this._initByEnvironment(a),"undefined"!=typeof a.version){for(this.log("version: "+a.version),b=0;b0&&(a.name=a.firstName[0],a.firstName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.lastName&&a.lastName.length>0&&(a.name+=a.lastName[0],a.lastName.length>1&&(this.degraded=!0))):"undefined"==typeof a.familyName&&"undefined"==typeof a.givenName||(a.name="","undefined"!=typeof a.givenName&&a.givenName.length>0&&(a.name=a.givenName[0],a.givenName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.familyName&&a.familyName.length>0&&(a.name+=a.familyName[0],a.familyName.length>1&&(this.degraded=!0))),"object"==typeof a.name&&null!==a.name&&(a.name.length>1&&(this.degraded=!0),a.name=a.name[0]),"object"==typeof a.mbox&&null!==a.mbox&&(a.mbox.length>1&&(this.degraded=!0),a.mbox=a.mbox[0]),"object"==typeof a.mbox_sha1sum&&null!==a.mbox_sha1sum&&(a.mbox_sha1sum.length>1&&(this.degraded=!0),a.mbox_sha1sum=a.mbox_sha1sum[0]),"object"==typeof a.openid&&null!==a.openid&&(a.openid.length>1&&(this.degraded=!0),a.openid=a.openid[0]),"object"==typeof a.account&&null!==a.account&&"undefined"==typeof a.account.homePage&&"undefined"==typeof a.account.name&&(0===a.account.length?delete a.account:(a.account.length>1&&(this.degraded=!0),a.account=a.account[0])),a.hasOwnProperty("account")&&(a.account instanceof TinCan.AgentAccount?this.account=a.account:this.account=new TinCan.AgentAccount(a.account)),b=0;b0)for(b.member=[],c=0;c0))for(c=0;c0)if("0.9"===a||"0.95"===a)this[e[b]].length>1&&this.log("[warning] version does not support multiple values in: "+e[b]),d[e[b]]=this[e[b]][0].asVersion(a);else for(d[e[b]]=[],c=0;c0){if("0.9"===a||"0.95"===a)throw this.log("[error] version does not support the 'category' property: "+a),new Error(a+" does not support the 'category' property"); for(d.category=[],b=0;b>>0;if("function"!=typeof a)throw new TypeError;var d,e=arguments[1];for(d=0;d=200&&f<400||e?b.callback?void b.callback(null,a):d={err:null,xhr:a}:(d={err:f,xhr:a},0===f?log("[warning] There was a problem communicating with the Learning Record Store. Aborted, offline, or invalid CORS endpoint ("+f+")",LOG_SRC):log("[warning] There was a problem communicating with the Learning Record Store. ("+f+" | "+a.responseText+")",LOG_SRC),b.callback&&b.callback(f,a),d))},__IEModeConversion=function(a,b,c,d){var e;for(e in b)b.hasOwnProperty(e)&&c.push(e+"="+encodeURIComponent(b[e]));return"undefined"!=typeof d.data&&c.push("content="+encodeURIComponent(d.data)),b["Content-Type"]="application/x-www-form-urlencoded",a+="?method="+d.method,d.method="POST",d.params={},c.length>0&&(d.data=c.join("&")),a},nativeRequest=function(a,b,c){log("sendRequest using XMLHttpRequest",LOG_SRC);var d,e,f,g,h=this,i=[],j={finished:!1,fakeStatus:null},k="undefined"!=typeof c.callback,l=a,m=2048;log("sendRequest using XMLHttpRequest - async: "+k,LOG_SRC);for(e in c.params)c.params.hasOwnProperty(e)&&i.push(e+"="+encodeURIComponent(c.params[e]));if(i.length>0&&(l+="?"+i.join("&")),l.length>=m){if("undefined"==typeof c.method)return g=new Error("method must not be undefined for an IE Mode Request conversion"),"undefined"!=typeof c.callback&&c.callback(g,null),{err:g,xhr:null};a=__IEModeConversion(a,b,i,c)}else a=l;if("undefined"!=typeof XMLHttpRequest)d=new XMLHttpRequest;else if(d=new ActiveXObject("Microsoft.XMLHTTP"),c.expectMultipart)return g=new Error("Attachment support not available"),"undefined"!=typeof c.callback&&c.callback(g,null),{err:g,xhr:null};d.open(c.method,a,k),c.expectMultipart&&(d.responseType="arraybuffer");for(e in b)b.hasOwnProperty(e)&&d.setRequestHeader(e,b[e]);f=c.data,k&&(d.onreadystatechange=function(){log("xhr.onreadystatechange - xhr.readyState: "+d.readyState,LOG_SRC),4===d.readyState&&requestComplete.call(h,d,c,j)});try{d.send(f)}catch(a){log("sendRequest caught send exception: "+a,LOG_SRC)}return k?d:requestComplete.call(this,d,c,j)},xdrRequest=function(a,b,c){log("sendRequest using XDomainRequest",LOG_SRC);var d,e,f,g,h,i=this,j=[],k={finished:!1,fakeStatus:null};if(c.expectMultipart)return h=new Error("Attachment support not available"),"undefined"!=typeof c.callback&&c.callback(h,null),{err:h,xhr:null};a+="?method="+c.method;for(f in c.params)c.params.hasOwnProperty(f)&&j.push(f+"="+encodeURIComponent(c.params[f]));for(f in b)b.hasOwnProperty(f)&&j.push(f+"="+encodeURIComponent(b[f]));"undefined"!=typeof c.data&&j.push("content="+encodeURIComponent(c.data)),e=j.join("&"),d=new XDomainRequest,d.open("POST",a),c.callback?(d.onload=function(){k.fakeStatus=200,requestComplete.call(i,d,c,k)},d.onerror=function(){k.fakeStatus=400,requestComplete.call(i,d,c,k)},d.ontimeout=function(){k.fakeStatus=0,requestComplete.call(i,d,c,k)}):(d.onload=function(){k.fakeStatus=200},d.onerror=function(){k.fakeStatus=400},d.ontimeout=function(){k.fakeStatus=0}),d.onprogress=function(){},d.timeout=0;try{d.send(e)}catch(a){log("sendRequest caught send exception: "+a,LOG_SRC)}if(!c.callback){for(g=1e4+Date.now(),log("sendRequest - until: "+g+", finished: "+k.finished,LOG_SRC);Date.now()>0}function g(a){return a>>>0}function h(b){function c(a){Object.defineProperty(b,a,{get:function(){return b._getter(a)},set:function(c){b._setter(a,c)},enumerable:!0,configurable:!1})}if(!("TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS"in a)){if(b.length>E)throw RangeError("Array too large for polyfill");var d;for(d=0;d>c}function j(a,b){var c=32-b;return a<>>c}function k(a){return[255&a]}function l(a){return i(a[0],8)}function m(a){return[255&a]}function n(a){return j(a[0],8)}function o(a){return a=M(Number(a)),[a<0?0:a>255?255:255&a]}function p(a){return[255&a,a>>8&255]}function q(a){return i(a[1]<<8|a[0],16)}function r(a){return[255&a,a>>8&255]}function s(a){return j(a[1]<<8|a[0],16)}function t(a){return[255&a,a>>8&255,a>>16&255,a>>24&255]}function u(a){return i(a[3]<<24|a[2]<<16|a[1]<<8|a[0],32)}function v(a){return[255&a,a>>8&255,a>>16&255,a>>24&255]}function w(a){return j(a[3]<<24|a[2]<<16|a[1]<<8|a[0],32)}function x(a,b,c){function d(a){var b=H(a),c=a-b;return c<.5?b:c>.5?b+1:b%2?b+1:b}var e,f,g,h=(1<=L(2,1-h)){f=K(H(I(a)/F),1023);var i=a/L(2,f);i<1&&(f-=1,i*=2),i>=2&&(f+=1,i/=2);var j=L(2,c);g=d(i*j)-j,f+=h,g/j>=1&&(f+=1,g=0),f>2*h&&(f=(1<>=1;return l.reverse(),g=l.join(""),h=(1<0?i*L(2,j-h)*(1+k/L(2,c)):0!==k?i*L(2,-(h-1))*(k/L(2,c)):i<0?-0:0}function z(a){return y(a,11,52)}function A(a){return x(a,11,52)}function B(a){return y(a,8,23)}function C(a){return x(a,8,23)}var D=void 0,E=1e5,F=Math.LN2,G=Math.abs,H=Math.floor,I=Math.log,J=Math.max,K=Math.min,L=Math.pow,M=Math.round;!function(){var a=Object.defineProperty,b=!function(){try{return Object.defineProperty({},"x",{})}catch(a){return!1}}();a&&!b||(Object.defineProperty=function(b,c,d){if(a)try{return a(b,c,d)}catch(a){}if(b!==Object(b))throw TypeError("Object.defineProperty called on non-object");return Object.prototype.__defineGetter__&&"get"in d&&Object.prototype.__defineGetter__.call(b,c,d.get),Object.prototype.__defineSetter__&&"set"in d&&Object.prototype.__defineSetter__.call(b,c,d.set),"value"in d&&(b[c]=d.value),b})}(),function(){function i(a){if(a=f(a),a<0)throw RangeError("ArrayBuffer size is not a small enough positive integer.");Object.defineProperty(this,"byteLength",{value:a}),Object.defineProperty(this,"_bytes",{value:Array(a)});for(var b=0;b=1&&"object"===b(arguments[0])&&arguments[0]instanceof j)return function(a){if(this.constructor!==a.constructor)throw TypeError();var b=a.length*this.BYTES_PER_ELEMENT;Object.defineProperty(this,"buffer",{value:new i(b)}),Object.defineProperty(this,"byteLength",{value:b}),Object.defineProperty(this,"byteOffset",{value:0}),Object.defineProperty(this,"length",{value:a.length});for(var c=0;c=1&&"object"===b(arguments[0])&&!(arguments[0]instanceof j)&&!(arguments[0]instanceof i||"ArrayBuffer"===c(arguments[0])))return function(a){var b=a.length*this.BYTES_PER_ELEMENT;Object.defineProperty(this,"buffer",{value:new i(b)}),Object.defineProperty(this,"byteLength",{value:b}),Object.defineProperty(this,"byteOffset",{value:0}),Object.defineProperty(this,"length",{value:a.length});for(var c=0;c=1&&"object"===b(arguments[0])&&(arguments[0]instanceof i||"ArrayBuffer"===c(arguments[0])))return function(a,b,c){if(b=g(b),b>a.byteLength)throw RangeError("byteOffset out of range");if(b%this.BYTES_PER_ELEMENT)throw RangeError("buffer length minus the byteOffset is not a multiple of the element size.");if(c===D){var d=a.byteLength-b;if(d%this.BYTES_PER_ELEMENT)throw RangeError("length of buffer minus byteOffset not a multiple of the element size");c=d/this.BYTES_PER_ELEMENT}else c=g(c),d=c*this.BYTES_PER_ELEMENT;if(b+d>a.byteLength)throw RangeError("byteOffset and length reference an area beyond the end of the buffer");Object.defineProperty(this,"buffer",{value:a}),Object.defineProperty(this,"byteLength",{value:d}),Object.defineProperty(this,"byteOffset",{value:b}),Object.defineProperty(this,"length",{value:c})}.apply(this,arguments);throw TypeError()}function x(a,b,c){var d=function(){Object.defineProperty(this,"constructor",{value:d}),j.apply(this,arguments),h(this)};"__proto__"in d?d.__proto__=j:(d.from=j.from,d.of=j.of),d.BYTES_PER_ELEMENT=a;var e=function(){};return e.prototype=y,d.prototype=new e,Object.defineProperty(d.prototype,"BYTES_PER_ELEMENT",{value:a}),Object.defineProperty(d.prototype,"_pack",{value:b}),Object.defineProperty(d.prototype,"_unpack",{value:c}),d}a.ArrayBuffer=a.ArrayBuffer||i,Object.defineProperty(j,"from",{value:function(a){return new this(a)}}),Object.defineProperty(j,"of",{value:function(){return new this(arguments)}});var y={};j.prototype=y,Object.defineProperty(j.prototype,"_getter",{value:function(a){if(arguments.length<1)throw SyntaxError("Not enough arguments");if(a=g(a),a>=this.length)return D;var b,c,d=[];for(b=0,c=this.byteOffset+a*this.BYTES_PER_ELEMENT;b=this.length)){var c,d,e=this._pack(b);for(c=0,d=this.byteOffset+a*this.BYTES_PER_ELEMENT;c0;)d._setter(j,d._getter(l)),l+=p,j+=p,q-=1;return d}}),Object.defineProperty(j.prototype,"every",{value:function(a){if(this===D||null===this)throw TypeError();var b=Object(this),c=g(b.length);if(!d(a))throw TypeError();for(var e=arguments[1],f=0;f1?arguments[1]:D,i=0;i1?arguments[1]:D,i=0;i0&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&d!==1/0&&d!==-(1/0)&&(d=(d>0||-1)*H(G(d)))),d>=c)return-1;for(var e=d>=0?d:J(c-G(d),0);e1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&d!==1/0&&d!==-(1/0)&&(d=(d>0||-1)*H(G(d))));for(var e=d>=0?K(d,c-1):c-G(d);e>=0;e--)if(b._getter(e)===a)return e; return-1}}),Object.defineProperty(j.prototype,"map",{value:function(a){if(this===D||null===this)throw TypeError();var b=Object(this),c=g(b.length);if(!d(a))throw TypeError();var e=[];e.length=c;for(var f=arguments[1],h=0;h=2?arguments[1]:b._getter(f++);f=2?arguments[1]:b._getter(f--);f>=0;)e=a.call(D,e,b._getter(f),f,b),f--;return e}}),Object.defineProperty(j.prototype,"reverse",{value:function(){if(this===D||null===this)throw TypeError();for(var a=Object(this),b=g(a.length),c=H(b/2),d=0,e=b-1;dthis.length)throw RangeError("Offset plus length of array is out of range");if(k=this.byteOffset+e*this.BYTES_PER_ELEMENT,l=c.length*this.BYTES_PER_ELEMENT,c.buffer===this.buffer){for(m=[],h=0,i=c.byteOffset;hthis.length)throw RangeError("Offset plus length of array is out of range");for(h=0;hc?c:a}a=f(a),b=f(b),arguments.length<1&&(a=0),arguments.length<2&&(b=this.length),a<0&&(a=this.length+a),b<0&&(b=this.length+b),a=c(a,0,this.length),b=c(b,0,this.length);var d=b-a;return d<0&&(d=0),new this.constructor(this.buffer,this.byteOffset+a*this.BYTES_PER_ELEMENT,d)}});var E=x(1,k,l),F=x(1,m,n),I=x(1,o,n),L=x(2,p,q),M=x(2,r,s),N=x(4,t,u),O=x(4,v,w),P=x(4,C,B),Q=x(8,A,z);a.Int8Array=a.Int8Array||E,a.Uint8Array=a.Uint8Array||F,a.Uint8ClampedArray=a.Uint8ClampedArray||I,a.Int16Array=a.Int16Array||L,a.Uint16Array=a.Uint16Array||M,a.Int32Array=a.Int32Array||N,a.Uint32Array=a.Uint32Array||O,a.Float32Array=a.Float32Array||P,a.Float64Array=a.Float64Array||Q}(),function(){function b(a,b){return d(a.get)?a.get(b):a[b]}function e(a,b,d){if(!(a instanceof ArrayBuffer||"ArrayBuffer"===c(a)))throw TypeError();if(b=g(b),b>a.byteLength)throw RangeError("byteOffset out of range");if(d=d===D?a.byteLength-b:g(d),b+d>a.byteLength)throw RangeError("byteOffset and length reference an area beyond the end of the buffer");Object.defineProperty(this,"buffer",{value:a}),Object.defineProperty(this,"byteLength",{value:d}),Object.defineProperty(this,"byteOffset",{value:b})}function f(a){return function(c,d){if(c=g(c),c+a.BYTES_PER_ELEMENT>this.byteLength)throw RangeError("Array index out of range");c+=this.byteOffset;for(var e=new Uint8Array(this.buffer,c,a.BYTES_PER_ELEMENT),f=[],h=0;hthis.byteLength)throw RangeError("Array index out of range");var f,h,j=new a([d]),k=new Uint8Array(j.buffer),l=[];for(f=0;fg)return new ArrayBuffer(0);var h=g-f,i=new ArrayBuffer(h),j=new Uint8Array(i),k=new Uint8Array(this,f,h);return j.set(k),i})}(),"undefined"!=typeof module&&module.exports&&(this["encoding-indexes"]=require("./encoding-indexes.js")["encoding-indexes"]),function(a){"use strict";function b(a,b,c){return b<=a&&a<=c}function c(a,b){return a.indexOf(b)!==-1}function d(a){if(void 0===a)return{};if(a===Object(a))return a;throw TypeError("Could not convert argument to dictionary")}function e(a){for(var b=String(a),c=b.length,d=0,e=[];d57343)e.push(f);else if(56320<=f&&f<=57343)e.push(65533);else if(55296<=f&&f<=56319)if(d===c-1)e.push(65533);else{var g=a.charCodeAt(d+1);if(56320<=g&&g<=57343){var h=1023&f,i=1023&g;e.push(65536+(h<<10)+i),d+=1}else e.push(65533)}d+=1}return e}function f(a){for(var b="",c=0;c>10)+55296,(1023&d)+56320))}return b}function g(a){return 0<=a&&a<=127}function h(a){this.tokens=[].slice.call(a),this.tokens.reverse()}function i(a,b){if(a)throw TypeError("Decoder error");return b||65533}function j(a){throw TypeError("The code point "+a+" could not be encoded.")}function k(){}function l(){}function m(a){return a=String(a).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(W,a)?W[a]:null}function n(a,b){return b?b[a]||null:null}function o(a,b){var c=b.indexOf(a);return c===-1?null:c}function p(b){if(!("encoding-indexes"in a))throw Error("Indexes missing. Did you forget to include encoding-indexes.js?");return a["encoding-indexes"][b]}function q(a){if(a>39419&&a<189e3||a>1237575)return null;if(7457===a)return 59335;var b,c=0,d=0,e=p("gb18030");for(b=0;b>6*d)+e];d>0;){var g=c>>6*(d-1);f.push(128|63&g),d-=1}return f}}function y(a,b){var c=b.fatal;this.handler=function(b,d){if(d===T)return U;if(g(d))return d;var e=a[d-128];return null===e?i(c):e}}function z(a,b){b.fatal;this.handler=function(b,c){if(c===T)return U;if(S(c))return c;var d=o(c,a);return null===d&&j(c),d+128}}function A(a){var c=a.fatal,d=0,e=0,f=0;this.handler=function(a,h){if(h===T&&0===d&&0===e&&0===f)return U;h!==T||0===d&&0===e&&0===f||(d=0,e=0,f=0,i(c));var j;if(0!==f){j=null,b(h,48,57)&&(j=q(10*(126*(10*(d-129)+(e-48))+(f-129))+h-48));var k=[e,f,h];return d=0,e=0,f=0,null===j?(a.prepend(k),i(c)):j}if(0!==e)return b(h,129,254)?(f=h,null):(a.prepend([e,h]),d=0,e=0,i(c));if(0!==d){if(b(h,48,57))return e=h,null;var l=d,m=null;d=0;var o=h<127?64:65;return(b(h,64,126)||b(h,128,254))&&(m=190*(l-129)+(h-o)),j=null===m?null:n(m,p("gb18030")),null===j&&g(h)&&a.prepend(h),null===j?i(c):j}return g(h)?h:128===h?8364:b(h,129,254)?(d=h,null):i(c)}}function B(a,b){a.fatal;this.handler=function(a,c){if(c===T)return U;if(S(c))return c;if(58853===c)return j(c);if(b&&8364===c)return 128;var d=o(c,p("gb18030"));if(null!==d){var e=R(d/190)+129,f=d%190,g=f<63?64:65;return[e,f+g]}if(b)return j(c);d=r(c);var h=R(d/10/126/10);d-=10*h*126*10;var i=R(d/10/126);d-=10*i*126;var k=R(d/10),l=d-10*k;return[h+129,i+48,k+129,l+48]}}function C(a){var c=a.fatal,d=0;this.handler=function(a,e){if(e===T&&0!==d)return d=0,i(c);if(e===T&&0===d)return U;if(0!==d){var f=d,h=null;d=0;var j=e<127?64:98;switch((b(e,64,126)||b(e,161,254))&&(h=157*(f-129)+(e-j)),h){case 1133:return[202,772];case 1135:return[202,780];case 1164:return[234,772];case 1166:return[234,780]}var k=null===h?null:n(h,p("big5"));return null===k&&g(e)&&a.prepend(e),null===k?i(c):k}return g(e)?e:b(e,129,254)?(d=e,null):i(c)}}function D(a){a.fatal;this.handler=function(a,b){if(b===T)return U;if(S(b))return b;var c=t(b);if(null===c)return j(b);var d=R(c/157)+129;if(d<161)return j(b);var e=c%157,f=e<63?64:98;return[d,e+f]}}function E(a){var c=a.fatal,d=!1,e=0;this.handler=function(a,f){if(f===T&&0!==e)return e=0,i(c);if(f===T&&0===e)return U;if(142===e&&b(f,161,223))return e=0,65377+f-161;if(143===e&&b(f,161,254))return d=!0,e=f,null;if(0!==e){var h=e;e=0;var j=null;return b(h,161,254)&&b(f,161,254)&&(j=n(94*(h-161)+(f-161),p(d?"jis0212":"jis0208"))),d=!1,b(f,161,254)||a.prepend(f),null===j?i(c):j}return g(f)?f:142===f||143===f||b(f,161,254)?(e=f,null):i(c)}}function F(a){a.fatal;this.handler=function(a,c){if(c===T)return U;if(S(c))return c;if(165===c)return 92;if(8254===c)return 126;if(b(c,65377,65439))return[142,c-65377+161];8722===c&&(c=65293);var d=o(c,p("jis0208"));if(null===d)return j(c);var e=R(d/94)+161,f=d%94+161;return[e,f]}}function G(a){var c=a.fatal,d={ASCII:0,Roman:1,Katakana:2,LeadByte:3,TrailByte:4,EscapeStart:5,Escape:6},e=d.ASCII,f=d.ASCII,g=0,h=!1;this.handler=function(a,j){switch(e){default:case d.ASCII:return 27===j?(e=d.EscapeStart,null):b(j,0,127)&&14!==j&&15!==j&&27!==j?(h=!1,j):j===T?U:(h=!1,i(c));case d.Roman:return 27===j?(e=d.EscapeStart,null):92===j?(h=!1,165):126===j?(h=!1,8254):b(j,0,127)&&14!==j&&15!==j&&27!==j&&92!==j&&126!==j?(h=!1,j):j===T?U:(h=!1,i(c));case d.Katakana:return 27===j?(e=d.EscapeStart,null):b(j,33,95)?(h=!1,65377+j-33):j===T?U:(h=!1,i(c));case d.LeadByte:return 27===j?(e=d.EscapeStart,null):b(j,33,126)?(h=!1,g=j,e=d.TrailByte,null):j===T?U:(h=!1,i(c));case d.TrailByte:if(27===j)return e=d.EscapeStart,i(c);if(b(j,33,126)){e=d.LeadByte;var k=94*(g-33)+j-33,l=n(k,p("jis0208"));return null===l?i(c):l}return j===T?(e=d.LeadByte,a.prepend(j),i(c)):(e=d.LeadByte,i(c));case d.EscapeStart:return 36===j||40===j?(g=j,e=d.Escape,null):(a.prepend(j),h=!1,e=f,i(c));case d.Escape:var m=g;g=0;var o=null;if(40===m&&66===j&&(o=d.ASCII),40===m&&74===j&&(o=d.Roman),40===m&&73===j&&(o=d.Katakana),36!==m||64!==j&&66!==j||(o=d.LeadByte),null!==o){e=e=o;var q=h;return h=!0,q?i(c):null}return a.prepend([m,j]),h=!1,e=f,i(c)}}}function H(a){var b=(a.fatal,{ASCII:0,Roman:1,jis0208:2}),c=b.ASCII;this.handler=function(a,d){if(d===T&&c!==b.ASCII)return a.prepend(d),c=b.ASCII,[27,40,66];if(d===T&&c===b.ASCII)return U;if(!(c!==b.ASCII&&c!==b.Roman||14!==d&&15!==d&&27!==d))return j(65533);if(c===b.ASCII&&S(d))return d;if(c===b.Roman&&(S(d)&&92!==d&&126!==d||165==d||8254==d)){if(S(d))return d;if(165===d)return 92;if(8254===d)return 126}if(S(d)&&c!==b.ASCII)return a.prepend(d),c=b.ASCII,[27,40,66];if((165===d||8254===d)&&c!==b.Roman)return a.prepend(d),c=b.Roman,[27,40,74];8722===d&&(d=65293);var e=o(d,p("jis0208"));if(null===e)return j(d);if(c!==b.jis0208)return a.prepend(d),c=b.jis0208,[27,36,66];var f=R(e/94)+33,g=e%94+33;return[f,g]}}function I(a){var c=a.fatal,d=0;this.handler=function(a,e){if(e===T&&0!==d)return d=0,i(c);if(e===T&&0===d)return U;if(0!==d){var f=d,h=null;d=0;var j=e<127?64:65,k=f<160?129:193;(b(e,64,126)||b(e,128,252))&&(h=188*(f-k)+e-j);var l=null===h?null:n(h,p("jis0208"));return null===l&&null!==h&&b(h,8836,10528)?57344+h-8836:(null===l&&g(e)&&a.prepend(e),null===l?i(c):l)}return g(e)||128===e?e:b(e,161,223)?65377+e-161:b(e,129,159)||b(e,224,252)?(d=e,null):i(c)}}function J(a){a.fatal;this.handler=function(a,c){if(c===T)return U;if(S(c)||128===c)return c;if(165===c)return 92;if(8254===c)return 126;if(b(c,65377,65439))return c-65377+161;8722===c&&(c=65293);var d=s(c);if(null===d)return j(c);var e=R(d/188),f=e<31?129:193,g=d%188,h=g<63?64:65;return[e+f,g+h]}}function K(a){var c=a.fatal,d=0;this.handler=function(a,e){if(e===T&&0!==d)return d=0,i(c);if(e===T&&0===d)return U;if(0!==d){var f=d,h=null;d=0,b(e,65,254)&&(h=190*(f-129)+(e-65));var j=null===h?null:n(h,p("euc-kr"));return null===h&&g(e)&&a.prepend(e),null===j?i(c):j}return g(e)?e:b(e,129,254)?(d=e,null):i(c)}}function L(a){a.fatal;this.handler=function(a,b){if(b===T)return U;if(S(b))return b;var c=o(b,p("euc-kr"));if(null===c)return j(b);var d=R(c/190)+129,e=c%190+65;return[d,e]}}function M(a,b){var c=a>>8,d=255&a;return b?[c,d]:[d,c]}function N(a,c){var d=c.fatal,e=null,f=null;this.handler=function(c,g){if(g===T&&(null!==e||null!==f))return i(d);if(g===T&&null===e&&null===f)return U;if(null===e)return e=g,null;var h;if(h=a?(e<<8)+g:(g<<8)+e,e=null,null!==f){var j=f;return f=null,b(h,56320,57343)?65536+1024*(j-55296)+(h-56320):(c.prepend(M(h,a)),i(d))}return b(h,55296,56319)?(f=h,null):b(h,56320,57343)?i(d):h}}function O(a,c){c.fatal;this.handler=function(c,d){if(d===T)return U;if(b(d,0,65535))return M(d,a);var e=M((d-65536>>10)+55296,a),f=M((d-65536&1023)+56320,a);return e.concat(f)}}function P(a){a.fatal;this.handler=function(a,b){return b===T?U:g(b)?b:63360+b-128}}function Q(a){a.fatal;this.handler=function(a,c){return c===T?U:S(c)?c:b(c,63360,63487)?c-63360+128:j(c)}}var R=Math.floor,S=g,T=-1;h.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.pop():T},prepend:function(a){if(Array.isArray(a))for(var b=a;b.length;)this.tokens.push(b.pop());else this.tokens.push(a)},push:function(a){if(Array.isArray(a))for(var b=a;b.length;)this.tokens.unshift(b.shift());else this.tokens.unshift(a)}};var U=-1;k.prototype={handler:function(a,b){}},l.prototype={handler:function(a,b){}};var V=[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"UTF-8"}],heading:"The Encoding"},{encodings:[{labels:["866","cp866","csibm866","ibm866"],name:"IBM866"},{labels:["csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso88592","iso_8859-2","iso_8859-2:1987","l2","latin2"],name:"ISO-8859-2"},{labels:["csisolatin3","iso-8859-3","iso-ir-109","iso8859-3","iso88593","iso_8859-3","iso_8859-3:1988","l3","latin3"],name:"ISO-8859-3"},{labels:["csisolatin4","iso-8859-4","iso-ir-110","iso8859-4","iso88594","iso_8859-4","iso_8859-4:1988","l4","latin4"],name:"ISO-8859-4"},{labels:["csisolatincyrillic","cyrillic","iso-8859-5","iso-ir-144","iso8859-5","iso88595","iso_8859-5","iso_8859-5:1988"],name:"ISO-8859-5"},{labels:["arabic","asmo-708","csiso88596e","csiso88596i","csisolatinarabic","ecma-114","iso-8859-6","iso-8859-6-e","iso-8859-6-i","iso-ir-127","iso8859-6","iso88596","iso_8859-6","iso_8859-6:1987"],name:"ISO-8859-6"},{labels:["csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso-ir-126","iso8859-7","iso88597","iso_8859-7","iso_8859-7:1987","sun_eu_greek"],name:"ISO-8859-7"},{labels:["csiso88598e","csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-e","iso-ir-138","iso8859-8","iso88598","iso_8859-8","iso_8859-8:1988","visual"],name:"ISO-8859-8"},{labels:["csiso88598i","iso-8859-8-i","logical"],name:"ISO-8859-8-I"},{labels:["csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","iso885910","l6","latin6"],name:"ISO-8859-10"},{labels:["iso-8859-13","iso8859-13","iso885913"],name:"ISO-8859-13"},{labels:["iso-8859-14","iso8859-14","iso885914"],name:"ISO-8859-14"},{labels:["csisolatin9","iso-8859-15","iso8859-15","iso885915","iso_8859-15","l9"],name:"ISO-8859-15"},{labels:["iso-8859-16"],name:"ISO-8859-16"},{labels:["cskoi8r","koi","koi8","koi8-r","koi8_r"],name:"KOI8-R"},{labels:["koi8-ru","koi8-u"],name:"KOI8-U"},{labels:["csmacintosh","mac","macintosh","x-mac-roman"],name:"macintosh"},{labels:["dos-874","iso-8859-11","iso8859-11","iso885911","tis-620","windows-874"],name:"windows-874"},{labels:["cp1250","windows-1250","x-cp1250"],name:"windows-1250"},{labels:["cp1251","windows-1251","x-cp1251"],name:"windows-1251"},{labels:["ansi_x3.4-1968","ascii","cp1252","cp819","csisolatin1","ibm819","iso-8859-1","iso-ir-100","iso8859-1","iso88591","iso_8859-1","iso_8859-1:1987","l1","latin1","us-ascii","windows-1252","x-cp1252"],name:"windows-1252"},{labels:["cp1253","windows-1253","x-cp1253"],name:"windows-1253"},{labels:["cp1254","csisolatin5","iso-8859-9","iso-ir-148","iso8859-9","iso88599","iso_8859-9","iso_8859-9:1989","l5","latin5","windows-1254","x-cp1254"],name:"windows-1254"},{labels:["cp1255","windows-1255","x-cp1255"],name:"windows-1255"},{labels:["cp1256","windows-1256","x-cp1256"],name:"windows-1256"},{labels:["cp1257","windows-1257","x-cp1257"],name:"windows-1257"},{labels:["cp1258","windows-1258","x-cp1258"],name:"windows-1258"},{labels:["x-mac-cyrillic","x-mac-ukrainian"],name:"x-mac-cyrillic"}],heading:"Legacy single-byte encodings"},{encodings:[{labels:["chinese","csgb2312","csiso58gb231280","gb2312","gb_2312","gb_2312-80","gbk","iso-ir-58","x-gbk"],name:"GBK"},{labels:["gb18030"],name:"gb18030"}],heading:"Legacy multi-byte Chinese (simplified) encodings"},{encodings:[{labels:["big5","big5-hkscs","cn-big5","csbig5","x-x-big5"],name:"Big5"}],heading:"Legacy multi-byte Chinese (traditional) encodings"},{encodings:[{labels:["cseucpkdfmtjapanese","euc-jp","x-euc-jp"],name:"EUC-JP"},{labels:["csiso2022jp","iso-2022-jp"],name:"ISO-2022-JP"},{labels:["csshiftjis","ms932","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis"],name:"Shift_JIS"}],heading:"Legacy multi-byte Japanese encodings"},{encodings:[{labels:["cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949"],name:"EUC-KR"}],heading:"Legacy multi-byte Korean encodings"},{encodings:[{labels:["csiso2022kr","hz-gb-2312","iso-2022-cn","iso-2022-cn-ext","iso-2022-kr"],name:"replacement"},{labels:["utf-16be"],name:"UTF-16BE"},{labels:["utf-16","utf-16le"],name:"UTF-16LE"},{labels:["x-user-defined"],name:"x-user-defined"}],heading:"Legacy miscellaneous encodings"}],W={};V.forEach(function(a){a.encodings.forEach(function(a){a.labels.forEach(function(b){W[b]=a})})});var X={},Y={},Z="utf-8";Object.defineProperty&&(Object.defineProperty(u.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),Object.defineProperty(u.prototype,"fatal",{get:function(){return"fatal"===this._error_mode}}),Object.defineProperty(u.prototype,"ignoreBOM",{get:function(){return this._ignoreBOM}})),u.prototype.decode=function(a,b){function e(a){return!c(["UTF-8","UTF-16LE","UTF-16BE"],this._encoding.name)||this._ignoreBOM||this._BOMseen||(a.length>0&&65279===a[0]?(this._BOMseen=!0,a.shift()):a.length>0&&(this._BOMseen=!0)),f(a)}var g;g="object"==typeof a&&a instanceof ArrayBuffer?new Uint8Array(a):"object"==typeof a&&"buffer"in a&&a.buffer instanceof ArrayBuffer?new Uint8Array(a.buffer,a.byteOffset,a.byteLength):new Uint8Array(0),b=d(b),this._do_not_flush||(this._decoder=Y[this._encoding.name]({fatal:"fatal"===this._error_mode}),this._BOMseen=!1),this._do_not_flush=Boolean(b.stream);for(var i,j=new h(g),k=[];;){var l=j.read();if(l===T)break;if(i=this._decoder.handler(j,l),i===U)break;null!==i&&(Array.isArray(i)?k.push.apply(k,i):k.push(i))}if(!this._do_not_flush){do{if(i=this._decoder.handler(j,j.read()),i===U)break;null!==i&&(Array.isArray(i)?k.push.apply(k,i):k.push(i))}while(!j.endOfStream());this._decoder=null}return e.call(this,k)},Object.defineProperty&&Object.defineProperty(v.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),v.prototype.encode=function(a,b){a=a?String(a):"",b=d(b),this._do_not_flush||(this._encoder=X[this._encoding.name]({fatal:"fatal"===this._fatal})),this._do_not_flush=Boolean(b.stream);for(var c,f=new h(e(a)),g=[];;){var i=f.read();if(i===T)break;if(c=this._encoder.handler(f,i),c===U)break;Array.isArray(c)?g.push.apply(g,c):g.push(c)}if(!this._do_not_flush){for(;;){if(c=this._encoder.handler(f,f.read()),c===U)break;Array.isArray(c)?g.push.apply(g,c):g.push(c)}this._encoder=null}return new Uint8Array(g)},X["UTF-8"]=function(a){return new x(a)},Y["UTF-8"]=function(a){return new w(a)},function(){"encoding-indexes"in a&&V.forEach(function(a){"Legacy single-byte encodings"===a.heading&&a.encodings.forEach(function(a){var b=a.name,c=p(b.toLowerCase());Y[b]=function(a){return new y(c,a)},X[b]=function(a){return new z(c,a)}})})}(),Y.GBK=function(a){return new A(a)},X.GBK=function(a){return new B(a,!0)},X.gb18030=function(a){return new B(a)},Y.gb18030=function(a){return new A(a)},X.Big5=function(a){return new D(a)},Y.Big5=function(a){return new C(a)},X["EUC-JP"]=function(a){return new F(a)},Y["EUC-JP"]=function(a){return new E(a)},X["ISO-2022-JP"]=function(a){return new H(a)},Y["ISO-2022-JP"]=function(a){return new G(a)},X.Shift_JIS=function(a){return new J(a)},Y.Shift_JIS=function(a){return new I(a)},X["EUC-KR"]=function(a){return new L(a)},Y["EUC-KR"]=function(a){return new K(a)},X["UTF-16BE"]=function(a){return new O(!0,a)},Y["UTF-16BE"]=function(a){return new N(!0,a)},X["UTF-16LE"]=function(a){return new O(!1,a)},Y["UTF-16LE"]=function(a){return new N(!1,a)},X["x-user-defined"]=function(a){return new Q(a)},Y["x-user-defined"]=function(a){return new P(a)},a.TextEncoder||(a.TextEncoder=v),a.TextDecoder||(a.TextDecoder=u),"undefined"!=typeof module&&module.exports&&(module.exports={TextEncoder:a.TextEncoder,TextDecoder:a.TextDecoder,EncodingIndexes:a["encoding-indexes"]})}(this); //# sourceMappingURL=tincan-min.map