function inputBoxFocus(a){Q(a).focus();var b=Q(a).value;Q(a).value="";Q(a).value=b}function ReadShort(a,b){return(a.charCodeAt(b)<<8)+a.charCodeAt(b+1)}functionReadShortX(a,b){return(a.charCodeAt(b+1)<<8)+a.charCodeAt(b)}functionReadInt(a,b){return16777216*a.charCodeAt(b)+(a.charCodeAt(b+1)<<16)+(a.charCodeAt(b+2)<<8)+a.charCodeAt(b+3)}functionReadSInt(a,b){return(a.charCodeAt(b)<<24)+(a.charCodeAt(b+1)<<16)+(a.charCodeAt(b+2)<<8)+a.charCodeAt(b+3)}
function ObjectToStringEx(a,b){var c="";if(0!=a&&(!a||null==a))return"(Null)";if(a instanceof Array)for(var d in a)c+="<br/>"+gap(b)+"Item #"+d+": "+ObjectToStringEx(a[d],b+1);else if(a instanceof Object)for(d in a)c+="<br/>"+gap(b)+d+" = "+ObjectToStringEx(a[d],b+1);else c+=EscapeHtml(a);return c}
function ObjectToStringEx2(a,b){var c="";if(0!=a&&(!a||null==a))return"(Null)";if(a instanceof Array)for(var d in a)c+="\r\n"+gap2(b)+"Item #"+d+": "+ObjectToStringEx2(a[d],b+1);else if(a instanceof Object)for(d in a)c+="\r\n"+gap2(b)+d+" = "+ObjectToStringEx2(a[d],b+1);else c+=EscapeHtml(a);return c}function gap(a){for(var b="",c=0;c<4*a;c++)b+=" ";returnb}functiongap2(a){for(varb="",c=0;c<4*a;c++)b+="";returnb}functionObjectToString(a){returnObjectToStringEx(a,0)}
function decode_utf8(a){return decodeURIComponent(escape(a))}function data2blob(a){for(var b=Array(a.length),c=0;c<a.length;c++)b[c]=a.charCodeAt(c);returnnewBlob([newUint8Array(b)])}functionrandom(a){returnMath.floor(Math.random()*a)}functiontrademarks(a){returna.replace(/\(R\)/g,"®").replace(/\(TM\)/g,"™")}
var CreateWsmanComm=function(a,b,c,d,f){function n(){k.socketState=2;k.socketParseState=0;k.socketAccumulator="";k.socketHeader=null;k.socketData="";for(i in k.pendingAjaxCall)k.sendRequest(k.pendingAjaxCall[i][0],k.pendingAjaxCall[i][3],k.pendingAjaxCall[i][4])}function p(a){k.inDataCount++;if("object"==typeof a.data){var c=new FileReader;if(c.readAsBinaryString)c.onload=function(a){r(a.target.result)},c.readAsBinaryString(new Blob([a.data]));else if(c.readAsArrayBuffer)c.onloadend=function(a){r(a.target.result)},
if(null==k.amtVersion)for(l in k.socketHeader)0==k.socketHeader[l].indexOf("Server: Intel(R) Active Management Technology ")&&(k.amtVersion=k.socketHeader[l].substring(46));k.socketAccumulator=k.socketAccumulator.substring(a+4);k.socketParseState=1;k.socketData="";k.socketXHeader={Directive:k.socketHeader[0].split(" ")};for(l in k.socketHeader)0!=l&&(a=k.socketHeader[l].indexOf(":"),k.socketXHeader[k.socketHeader[l].substring(0,a).toLowerCase()]=k.socketHeader[l].substring(a+2))}if(1==k.socketParseState){c=
k.ExecPut=function(a,c,b,d,h,g){g="http://schemas.xmlsoap.org/ws/2004/09/transfer/Put</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout>"+l(g)+"</Header><Body>";if(a&&null!=c){var D=k.GetNameFromUrl(a);a="<r:"+D+'xmlns:r="'+a+'">';for(var m in c)if(c.hasOwnProperty(m)&&
"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+l(g)+"</Header><Body><g:"+D+'xmlns:g="'+a+'">';for(var m in c)a+="<g:"+m+">"+c[m]+"</g:"+m+">";k.PerformAjax(a+"</g:"+D+"></Body></Envelope>",b,d,h)};k.ExecDelete=function(a,c,b,d,h){a="http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +
c,b,l)};k.ExecMethod=function(a,c,b,l,h,g,d){var m="",E;for(E in b)if(null!=b[E])if(Array.isArray(b[E]))for(var x in b[E])m+="<r:"+E+">"+b[E][x]+"</r:"+E+">";else m+="<r:"+E+">"+b[E]+"</r:"+E+">";k.ExecMethodXml(a,c,m,l,h,g,d)};k.ExecMethodXml=function(a,c,b,d,h,g,D){k.PerformAjax(a+"/"+c+"</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+
function AmtStackCreateService(a){function b(){var a=e.GetPendingActions();u<a&&(u=a);null!=e.onProcessChanged&&B!=a&&(B=a,e.onProcessChanged(a,u));0==a&&(u=0)}functionc(a,c,b,l,g,h,y){200!=g?(b(e,a,null,g,h),f(1)):null!=c&&"EnumerateResponse"==c.Header.Method&&c.Body.EnumerationContext?e.wsman.ExecPull(l,c.Body.EnumerationContext,function(c,l,g,x){d(a,g,b,l,[],x,h,y)}):(b(e,a,null,603,h),f(1))}functiond(a,c,l,g,h,m,y,k){if(200!=m)l(e,a,null,m,y),f(1);elseif(null==c||"PullResponse"!=c.Header.Method)l(e,
a,null,604,y),f(1);else{for(var v in c.Body.Items)if(c.Body.Items[v]instanceof Array)for(var u in c.Body.Items[v])"function"!=typeof c.Body.Items[v][u]&&h.push(c.Body.Items[v][u]);else"function"!=typeof c.Body.Items[v]&&h.push(c.Body.Items[v]);c.Body.EnumerationContext?e.wsman.ExecPull(g,c.Body.EnumerationContext,function(c,b,g,x){d(a,g,l,b,h,x,y,1)}):(f(1),l(e,a,h,m,y),b())}}function f(a){e.ActiveEnumsCount-=a;e.ActiveEnumsCount>=e.MaxActiveEnumsCount||0==e.PendingEnums.length?b():(a=e.PendingEnums.shift(),
48==b[1]){if(0==b[2])return"A remote Serial Over LAN session was established.";if(1==b[2])return"Remote Serial Over LAN session finished. User control was restored.";if(2==b[2])return"A remote IDE-Redirection session was established.";if(3==b[2])return"Remote IDE-Redirection session finished. User control was restored."}if(36==a)return a=(b[1]<<24)+(b[2]<<16)+(b[3]<<8)+b[4],c="#"+b[0],170==b[0]&&(c="wired"),4294967293==a?"Allreceivedpacketfilterwasmatchedon"+c+"interface.":4294967292==a?"Alloutboundpacketfilterwasmatchedon"+
c+" interface.":4294967290==a?"Spoofed packet filter was matched on "+c+" interface.":"Filter "+a+" was matched on "+c+" interface.";if(192==a)return 0==b[2]?"Security policy invoked. Some or all network traffic (TX) was stopped.":2==b[2]?"Security policy invoked. Some or all network traffic (RX) was stopped.":"Security policy invoked.";if(193==a){if(170==b[0]&&48==b[1]&&0==b[2]&&0==b[3])return"User request for remote connection.";if(170==b[0]&&32==b[1]&&3==b[2]&&1==b[3])return"EAC error: attempt to get posture while NAC in Intel\ufffd AMT is disabled.";
[a,c,[]])};var h="Unspecified.;No system memory is physically installed in the system.;No usable system memory, all installed memory has experienced an unrecoverable failure.;Unrecoverable hard-disk/ATAPI/IDE device failure.;Unrecoverable system-board failure.;Unrecoverable diskette subsystem failure.;Unrecoverable hard-disk controller failure.;Unrecoverable PS/2 or USB keyboard failure.;Removable boot media not found.;Unrecoverable video controller failure.;No video device detected.;Firmware (BIOS) ROM corruption detected.;CPU voltage mismatch (processors that share same supply have mismatched voltage requirements);CPU speed matching failure".split(";"),
function execArgumentsToXml(a){if(void 0===a||null===a)return null;var b="",c;for(c in a){var d=a[c];d&&(b="reference"===d.__parameterType?b+referenceToXml(c,d):b+instanceToXml(c,d))}return b}
function instanceToXml(a,b){if(void 0===b||null===b)return null;var c=!!b.__namespace,d=c?"<q:":"<",f=c?"</q:":"</",c="<r:"+a+(c?'xmlns:q="'+b.__namespace+'"':"")+">",n;for(n in b)b.hasOwnProperty(n)&&0!==n.indexOf("__")&&("function"===typeof b[n]||Array.isArray(b[n])||("object"===typeof b[n]?console.error("only convert one level down..."):c+=d+n+">"+b[n].toString()+f+n+">"));return c+("</r:"+a+">")}
function referenceToXml(a,b){if(void 0===b||null===b)return null;var c="<r:"+a+"><a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>"+b.__resourceUri+"</w:ResourceURI><w:SelectorSet>",d;for(d in b)b.hasOwnProperty(d)&&0!==d.indexOf("__")&&("function"===typeof b[d]||"object"===typeof b[d]||Array.isArray(b[d])||(c+='<w:SelectorName="'+d+'">'+b[d].toString()+"</w:Selector>"));return c+("</w:SelectorSet></a:ReferenceParameters></r:"+a+">")}
function GetSidString(a){for(var b="S-"+a.charCodeAt(0)+"-"+a.charCodeAt(7),c=2;c<a.length/4;c++)b+="-"+ReadIntX(a,4*c);returnb}
function GetSidByteArray(a){if(!a||null==a)return null;a=a.split("-");if(4>a.length||"s"!=a[0]&&"S"!=a[0])return null;for(var b=1;b<a.length;b++){varc=parseInt(a[b]);if(c!=a[b])returnnull;a[b]=c}c=String.fromCharCode(a[1])+String.fromCharCode(a.length-3)+ShortToStr(Math.floor(a[2]/Math.pow(2,32)))+IntToStr(a[2]&65535);for(b=3;b<a.length;b++)c+=IntToStrX(a[b]);returnc}
(new MutationObserver(function(){var c=a.slice();a.length=0;c.forEach(function(a){a()})})).observe(l,{attributes:!0});var h=d.setImmediate;d.setImmediate=function(d){15<Date.now()-c?(c=Date.now(),h(d)):(a.push(d),1===a.length&&l.setAttribute("a",b=!b))}}d.nextTick=d.setImmediate}})();d.isArray=Array.isArray||function(a){return"[objectArray]"===Object.prototype.toString.call(a)};d.isArrayBuffer=function(a){return"undefined"!==typeofArrayBuffer&&ainstanceofArrayBuffer};d.isArrayBufferView=function(a){returna&&
(c||"raw")&&(a=d.encodeUtf8(a));return new d.ByteBuffer(a)};d.fillString=function(a,c){for(var b="";0<c;)c&1&&(b+=a),c>>>=1,0<c&&(a+=a);returnb};d.xorBytes=function(a,c,b){for(varl="",d="",h="",g=0,m=0;0<b;--b,++g)d=a.charCodeAt(g)^c.charCodeAt(g),10<=m&&(l+=h,h="",m=0),h+=String.fromCharCode(d),++m;returnl+h};d.hexToBytes=function(a){varc="",b=0;a.length&1&&(b=1,c+=String.fromCharCode(parseInt(a[0],16)));for(;b<a.length;b+=2)c+=String.fromCharCode(parseInt(a.substr(b,2),16));returnc};d.bytesToHex=
var l=c;l||(l=new Uint8Array(a.length));for(var h=b=b||0,g=0;g<a.length;++g)l[h++]=a.charCodeAt(g);returnc?h-b:l};d.text.utf8.decode=function(a){returnd.decodeUtf8(String.fromCharCode.apply(null,a))};d.text.utf16.encode=function(a,c,b){varl=c;l||(l=newUint8Array(2*a.length));for(vard=newUint16Array(l.buffer),h=b=b||0,g=b,m=0;m<a.length;++m)d[g++]=a.charCodeAt(m),h+=2;returnc?h-b:l};d.text.utf16.decode=function(a){returnString.fromCharCode.apply(null,newUint16Array(a.buffer))};d.deflate=function(a,
c,b){c=d.decode64(a.deflate(d.encode64(c)).rval);b&&(a=2,c.charCodeAt(1)&32&&(a=6),c=c.substring(a,c.length-4));return c};d.inflate=function(a,c,b){a=a.inflate(d.encode64(c)).rval;return null===a?null:d.decode64(a)};var u=function(a,c,b){if(!a)throw Error("WebStorage not available.");null===b?a=a.removeItem(c):(b=d.encode64(JSON.stringify(b)),a=a.setItem(c,b));if("undefined"!==typeof a&&!0!==a.rval)throw c=Error(a.error.message),c.id=a.error.id,c.name=a.error.name,c;},B=function(a,c){if(!a)throw Error("WebStorage not available.");
var b=a.getItem(c);if(a.init)if(null===b.rval){if(b.error){var l=Error(b.error.message);l.id=b.error.id;l.name=b.error.name;throw l;}b=null}else b=b.rval;null!==b&&(b=JSON.parse(d.decode64(b)));return b},h=function(a,c,b,l){var d=B(a,c);null===d&&(d={});d[b]=l;u(a,c,d)},g=function(a,c,b){a=B(a,c);null!==a&&(a=b in a?a[b]:null);return a},D=function(a,c,b){var l=B(a,c);if(null!==l&&b in l){delete l[b];b=!0;for(var d in l){b=!1;break}b&&(l=null);u(a,c,l)}},m=function(a,c){u(a,c,null)},f=function(a,c,
b){var l=null;"undefined"===typeof b&&(b=["web","flash"]);var d,h=!1,g=null,m;for(m in b){d=b[m];try{if("flash"===d||"both"===d){if(null===c[0])throw Error("Flash local storage not available.");l=a.apply(this,c);h="flash"===d}if("web"===d||"both"===d)c[0]=localStorage,l=a.apply(this,c),h=!0}catch(e){g=e}if(h)break}if(!h)throw g;return l};d.setItem=function(a,c,b,l,d){f(h,arguments,d)};d.getItem=function(a,c,b,l){return f(g,arguments,l)};d.removeItem=function(a,c,b,l){f(D,arguments,l)};d.clearItems=
(d=d());if(!d)throw Error("Unsupported algorithm: "+a);return new c.cipher.BlockCipher({algorithm:d,key:b,decrypt:!1})};c.cipher.createDecipher=function(a,b){var d=a;"string"===typeof d&&(d=c.cipher.getAlgorithm(d))&&(d=d());if(!d)throw Error("Unsupported algorithm: "+a);return new c.cipher.BlockCipher({algorithm:d,key:b,decrypt:!0})};c.cipher.registerAlgorithm=function(a,b){a=a.toUpperCase();c.cipher.algorithms[a]=b};c.cipher.getAlgorithm=function(a){a=a.toUpperCase();return a in c.cipher.algorithms?
c.cipher.algorithms[a]:null};var b=c.cipher.BlockCipher=function(a){this.algorithm=a.algorithm;this.mode=this.algorithm.mode;this.blockSize=this.mode.blockSize;this._finish=!1;this.output=this._input=null;this._op=a.decrypt?this.mode.decrypt:this.mode.encrypt;this._decrypt=a.decrypt;this.algorithm.initialize(a)};b.prototype.start=function(a){a=a||{};var b={},d;for(d in a)b[d]=a[d];b.decrypt=this._decrypt;this._finish=!1;this._input=c.util.createBuffer();this.output=a.output||c.util.createBuffer();
this._outBlock=Array(this._ints)};u.cbc.prototype.start=function(a){if(null===a.iv){if(!this._prev)throw Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in a)this._iv=b(a.iv),this._prev=this._iv.slice(0);else throw Error("Invalid IV parameter.");};u.cbc.prototype.encrypt=function(a,c,b){if(a.length()<this.blockSize&&!(b&&0<a.length()))return!0;for(b=0;b<this._ints;++b)this._inBlock[b]=this._prev[b]^a.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(b=0;b<this._ints;++b)c.putInt32(this._outBlock[b]);
g="additionalData"in a?c.util.createBuffer(a.additionalData):c.util.createBuffer();this._tagLength="tagLength"in a?a.tagLength:128;this._tag=null;if(a.decrypt&&(this._tag=c.util.createBuffer(a.tag).getBytes(),this._tag.length!==this._tagLength/8))throw Error("Authentication tag does not match tag length.");this._hashBlock=Array(this._ints);this.tag=null;this._hashSubkey=Array(this._ints);this.cipher.encrypt([0,0,0,0],this._hashSubkey);this.componentBits=4;this._m=this.generateHashTable(this._hashSubkey,
"string"===typeof a&&(a=c.util.createBuffer(a));if(2>a.length()){var h=Error("Too few bytes to parse DER.");h.bytes=a.length();throw h;}var g=a.getByte(),h=g&192,f=g&31,m=d(a);if(a.length()<m){if(e)throwh=Error("ToofewbytestoreadASN.1value."),h.detail=a.length()+"<"+m,h;m=a.length()}varE,x=32===(g&32);E=x;if(!E&&h===b.Class.UNIVERSAL&&f===b.Type.BITSTRING&&1<m){varw=a.read;if(0===a.getByte()&&(g=a.getByte(),g&=192,g===b.Class.UNIVERSAL||g===b.Class.CONTEXT_SPECIFIC))try{if(E=d(a)===m-(a.read-
a)return b.putSignedInt(a,32);b=Error("Integer too large; max is 32-bits.");b.integer=a;throw b;};b.derToInteger=function(a){"string"===typeof a&&(a=c.util.createBuffer(a));var b=8*a.length();if(32<b)throwError("Integertoolarge;maxis32-bits.");returna.getSignedInt(b)};b.validate=function(a,d,h,g){vare=!1;if(a.tagClass!==d.tagClass&&"undefined"!==typeofd.tagClass||a.type!==d.type&&"undefined"!==typeofd.type)g&&(a.tagClass!==d.tagClass&&g.push("["+d.name+']Expectedtagclass"'+d.tagClass+
'", got "'+a.tagClass+'"'),a.type!==d.type&&g.push("["+d.name+'] Expected type "'+d.type+'", got "'+a.type+'"'));else if(a.constructed===d.constructed||"undefined"===typeof d.constructed){e=!0;if(d.value&&c.util.isArray(d.value))for(var m=0,f=0;e&&f<d.value.length;++f)e=d.value[f].optional||!1,a.value[m]&&((e=b.validate(a.value[m],d.value[f],h,g))?++m:d.value[f].optional&&(e=!0)),!e&&g&&g.push("["+d.name+'] Tag class "'+d.tagClass+'", type "'+d.type+'" expected value length "'+d.value.length+'", got "'+
"DEK-Info"!==w.name)f.headers.push(w);else{if(0===w.values.length)throw Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');f.dekInfo={algorithm:n[0],parameters:n[1]||null}}else f.contentDomain=n[0]||"";else{if("Proc-Type"!==w.name)throw Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==w.values.length)throw Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');f.procType={version:n[0],
var I=I&-15,H=H&-15,Y=b[I>>>28]|d[I>>>24&15]|g[I>>>20&15]|e[I>>>16&15]|h[I>>>12&15]|k[I>>>8&15]|f[I>>>4&15],Z=m[H>>>28]|q[H>>>24&15]|u[H>>>20&15]|v[H>>>16&15]|K[H>>>12&15]|x[H>>>8&15]|n[H>>>4&15];r=(Z>>>16^Y)&65535;E[p++]=Y^r;E[p++]=Z^r<<16}}this._keys=E;this._init=!0}};b("DES-ECB",c.cipher.modes.ecb);b("DES-CBC",c.cipher.modes.cbc);b("DES-CFB",c.cipher.modes.cfb);b("DES-OFB",c.cipher.modes.ofb);b("DES-CTR",c.cipher.modes.ctr);b("3DES-ECB",c.cipher.modes.ecb);b("3DES-CBC",c.cipher.modes.cbc);b("3DES-CFB",
x||(x=n);a=Math.ceil(a.n.bitLength()/8);f=a-2*n.digestLength-2;if(d.length>f)throw x=Error("RSAES-OAEP input message length is too long."),x.length=d.length,x.maxLength=f,x;v||(v="");n.update(v,"raw");v=n.digest();h="";f-=d.length;for(g=0;g<f;g++)h+="\x00";d=v.getBytes()+h+"\u0001"+d;if(!m)m=c.random.getBytes(n.digestLength);elseif(m.length!==n.digestLength)throwx=Error("InvalidRSAES-OAEPseed.Theseedlengthmustmatchthedigestlength."),x.seedLength=m.length,x.digestLength=n.digestLength,
2)throw Error("RSAES-OAEP key is too short for the hash function.");g||(g="");v.update(g,"raw");g=v.digest().getBytes();a=d.charAt(0);h=d.substring(1,v.digestLength+1);d=d.substring(1+v.digestLength);var n=b(d,v.digestLength,m);h=c.util.xorBytes(h,n,h.length);m=b(h,f-v.digestLength-1,m);d=c.util.xorBytes(d,m,d.length);f=d.substring(0,v.digestLength);m="\x00"!==a;for(a=0;a<v.digestLength;++a)m|=g.charAt(a)!==f.charAt(a);g=1;for(v=a=v.digestLength;v<d.length;v++)f=d.charCodeAt(v),h=f&1^1,m|=f&(g?65534:
Error("Message is too long for PKCS#1 v1.5 padding."),g.length=a.length,g.max=d-11,g;g.putByte(0);g.putByte(e);d=d-3-a.length;if(0===e||1===e){e=0===e?0:255;for(var h=0;h<d;++h)g.putByte(e)}elsefor(;0<d;){for(varf=0,k=c.random.getBytes(d),h=0;h<d;++h)e=k.charCodeAt(h),0===e?++f:g.putByte(e);d=f}g.putByte(0);g.putBytes(a);returng}functiond(a,b,e,g){b=Math.ceil(b.n.bitLength()/8);a=c.util.createBuffer(a);varh=a.getByte(),f=a.getByte();if(0!==h||e&&0!==f&&1!==f||!e&&2!=f||e&&0===f&&"undefined"===
typeof g)throw Error("Encryption block is invalid.");e=0;if(0===f)for(e=b-3-g,g=0;g<e;++g){if(0!==a.getByte())throwError("Encryptionblockisinvalid.");}elseif(1===f)for(e=0;1<a.length();){if(255!==a.getByte()){--a.read;break}++e}elseif(2===f)for(e=0;1<a.length();){if(0===a.getByte()){--a.read;break}++e}if(0!==a.getByte()||e!==b-3-a.length())throwError("Encryptionblockisinvalid.");returna.getBytes()}functione(a,b,d){functione(){g(a.pBits,function(c,b){if(c)returnd(c);a.p=b;if(null!==a.q)returnf(c,
type:g.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:g.Class.UNIVERSAL,type:g.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},A=function(a){var c;if(a.algorithm in p.oids)c=p.oids[a.algorithm];
[g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,g.integerToDer(0).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(p.oids.rsaEncryption).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")]),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,g.toDer(a).getBytes())])};p.privateKeyFromAsn1=function(a){var b={},d=[];g.validate(a,r,b,d)&&(a=g.fromDer(c.util.createBuffer(b.privateKey)));b={};d=[];if(!g.validate(a,x,b,d))throw b=Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey."),
g.Type.INTEGER,!1,f(a.q)),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.dP)),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.dQ)),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.qInv))])};p.publicKeyFromAsn1=function(a){var b={},d=[];if(g.validate(a,F,b,d)){d=g.derToOid(b.publicKeyOid);if(d!==p.oids.rsaEncryption)throw b=Error("Cannot read public key. Unknown OID."),b.oid=d,b;a=b.rsaPublicKey}d=[];if(!g.validate(a,w,b,d))throw b=Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey."),
var D=n*Math.ceil(q/n);d=new c.util.ByteBuffer;for(k=0;k<D;k++)d.putByte(b.at(k%q));D=n*Math.ceil(a/n);b=newc.util.ByteBuffer;for(k=0;k<D;k++)b.putByte(p.at(k%a));p=d;p.putBuffer(b);b=Math.ceil(e/v);for(d=1;d<=b;d++){D=newc.util.ByteBuffer;D.putBytes(r.bytes());D.putBytes(p.bytes());for(k=0;k<g;k++)h.start(),h.update(D.getBytes()),D=h.digest();varB=newc.util.ByteBuffer;for(k=0;k<n;k++)B.putByte(D.at(k%v));varP=Math.ceil(q/n)+Math.ceil(a/n),L=newc.util.ByteBuffer;for(f=0;f<P;f++){varW=newc.util.ByteBuffer(p.getBytes(n)),
case "aes256-CBC":n=32;k=c.aes.createDecryptionCipher;break;case "des-EDE3-CBC":n=24;k=c.des.createDecryptionCipher;break;case "desCBC":n=8,k=c.des.createDecryptionCipher}a=c.pkcs5.pbkdf2(d,b,v,n);h=h.encIv;k=k(a);k.start(h);return k};f.pbe.getCipherForPKCS12PBE=function(a,b,d){var g={},h=[];if(!e.validate(b,p,g,h))throw d=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo."),d.errors=h,d;var h=c.util.createBuffer(g.salt),g=c.util.createBuffer(g.iterations),
(a={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var b=a.md,d=a.mgf,f=b.digestLength,n=a.salt||null;"string"===typeof n&&(n=c.util.createBuffer(n));var h;if("saltLength"in a)h=a.saltLength;else if(null!==n)h=n.length();else throw Error("Salt length not specified or specific salt not given.");if(null!==n&&n.length()!==h)throw Error("Given salt length does not match length of given salt.");var g=a.prng||c.random;return{encode:function(a,k){var p,x=k-1,w=Math.ceil(x/8),r=a.digest().getBytes();
return A+r+String.fromCharCode(188)},verify:function(a,g,k){var n;n=k-1;k=Math.ceil(n/8);g=g.substr(-k);if(k<f+h+2)throwError("InconsistentparameterstoPSSsignatureverification.");if(188!==g.charCodeAt(k-1))throwError("Encodedmessagedoesnotendin0xBC.");varp=k-f-1,r=g.substr(0,p);g=g.substr(p,f);varA=65280>>8*k-n&255;if(0!==(r.charCodeAt(0)&A))throw Error("Bits beyond keysize not zero as expected.");var B=d.generate(g,p),y="";for(n=0;n<p;n++)y+=String.fromCharCode(r.charCodeAt(n)^B.charCodeAt(n));
var f=e.value,k=g.Type.PRINTABLESTRING;"valueTagClass"in e&&(k=e.valueTagClass,k===g.Type.UTF8&&(f=c.util.encodeUtf8(f)));e=g.create(g.Class.UNIVERSAL,g.Type.SET,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(e.type).getBytes()),g.create(g.Class.UNIVERSAL,k,!1,f)])]);b.value.push(e)}return b}function e(a){for(var c,b=0;b<a.length;++b){c=a[b];"undefined"===typeofc.name&&(c.type&&c.typeinp.oids?c.name=p.oids[c.type]:c.shortName&&c.shortNamein
r&&(c.name=p.oids[r[c.shortName]]));if("undefined"===typeof c.type)if(c.name&&c.name in p.oids)c.type=p.oids[c.name];else throw a=Error("Attribute type not specified."),a.attribute=c,a;"undefined"===typeof c.shortName&&c.name&&c.name in r&&(c.shortName=r[c.name]);if(c.type===m.extensionRequest&&(c.valueConstructed=!0,c.valueTagClass=g.Type.SEQUENCE,!c.value&&c.extensions)){c.value=[];for(var d=0;d<c.extensions.length;++d)c.value.push(p.certificateExtensionToAsn1(f(c.extensions[d])))}if("undefined"===
typeof c.value)throw a=Error("Attribute value not specified."),a.attribute=c,a;}}function f(a,b){b=b||{};"undefined"===typeof a.name&&a.id&&a.id in p.oids&&(a.name=p.oids[a.id]);if("undefined"===typeof a.id)if(a.name&&a.name in p.oids)a.id=p.oids[a.name];else{var d=Error("Extension ID not specified.");d.extension=a;throw d;}if("undefined"!==typeof a.value)return a;if("keyUsage"===a.name){var e=d=0,h=0;a.digitalSignature&&(e|=128,d=7);a.nonRepudiation&&(e|=64,d=6);a.keyEncipherment&&(e|=32,d=5);a.dataEncipherment&&
"pathLenConstraint"in a&&a.value.value.push(g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,g.integerToDer(a.pathLenConstraint).getBytes()));else if("extKeyUsage"===a.name)for(e in a.value=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[]),d=a.value.value,a)!0===a[e]&&(e in m?d.push(g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m[e]).getBytes())):-1!==e.indexOf(".")&&d.push(g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(e).getBytes())));else if("nsCertType"===a.name)e=d=0,a.client&&(e|=128,
null===d)throw d=Error('Extension "ip" value is not a valid IPv4 or IPv6 address.'),d.extension=a,d;}else 8===e.type&&(d=e.oid?g.oidToDer(g.oidToDer(e.oid)):g.oidToDer(d));a.value.value.push(g.create(g.Class.CONTEXT_SPECIFIC,e.type,!1,d))}else"subjectKeyIdentifier"===a.name&&b.cert&&(d=b.cert.generateSubjectKeyIdentifier(),a.subjectKeyIdentifier=d.toHex(),a.value=g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,d.getBytes()));if("undefined"===typeof a.value)throw d=Error("Extension value not specified."),
a.type&&"X509 CERTIFICATE"!==a.type&&"TRUSTED CERTIFICATE"!==a.type)throw b=Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".'),b.headerType=a.type,b;if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert certificate from PEM; PEM is encrypted.");d=g.fromDer(a.body,d);return p.certificateFromAsn1(d,b)};p.certificateToPem=function(a,b){var d={type:"CERTIFICATE",body:g.toDer(p.certificateToAsn1(a)).getBytes()};
return c.pem.encode(d,{maxline:b})};p.publicKeyFromPem=function(a){a=c.pem.decode(a)[0];if("PUBLIC KEY"!==a.type&&"RSA PUBLIC KEY"!==a.type){var b=Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');b.headerType=a.type;throw b;}if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert public key from PEM; PEM is encrypted.");a=g.fromDer(a.body);return p.publicKeyFromAsn1(a)};p.publicKeyToPem=function(a,b){var d={type:"PUBLIC KEY",
body:g.toDer(p.publicKeyToAsn1(a)).getBytes()};return c.pem.encode(d,{maxline:b})};p.publicKeyToRSAPublicKeyPem=function(a,b){var d={type:"RSA PUBLIC KEY",body:g.toDer(p.publicKeyToRSAPublicKey(a)).getBytes()};return c.pem.encode(d,{maxline:b})};p.getPublicKeyFingerprint=function(a,b){b=b||{};var d=b.md||c.md.sha1.create(),e;switch(b.type||"RSAPublicKey"){case "RSAPublicKey":e=g.toDer(p.publicKeyToRSAPublicKey(a)).getBytes();break;case "SubjectPublicKeyInfo":e=g.toDer(p.publicKeyToAsn1(a)).getBytes();
break;default:throw Error('Unknown fingerprint type "'+b.type+'".');}d.start();d.update(e);d=d.digest();if("hex"===b.encoding)return d=d.toHex(),b.delimiter?d.match(/.{2}/g).join(b.delimiter):d;if("binary"===b.encoding)return d.getBytes();if(b.encoding)throw Error('Unknown encoding "'+b.encoding+'".');return d};p.certificationRequestFromPem=function(a,b,d){a=c.pem.decode(a)[0];if("CERTIFICATE REQUEST"!==a.type)throw b=Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".'),
b.headerType=a.type,b;if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert certification request from PEM; PEM is encrypted.");d=g.fromDer(a.body,d);return p.certificationRequestFromAsn1(d,b)};p.certificationRequestToPem=function(a,b){var d={type:"CERTIFICATE REQUEST",body:g.toDer(p.certificationRequestToAsn1(a)).getBytes()};return c.pem.encode(d,{maxline:b})};p.createCertificate=function(){var a={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};a.siginfo.algorithmOid=
a.sign=function(b,d){a.md=d||c.md.sha1.create();var e=m[a.md.algorithm+"WithRSAEncryption"];if(!e)throw e=Error("Could not compute certificate digest. Unknown message digest algorithm OID."),e.algorithm=a.md.algorithm,e;a.signatureOid=a.siginfo.algorithmOid=e;a.tbsCertificate=p.getTBSCertificate(a);e=g.toDer(a.tbsCertificate);a.md.update(e.getBytes());a.signature=b.sign(a.md)};a.verify=function(b){var d=!1;if(!a.issued(b)){var d=a.subject,e=Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");
e.expectedIssuer=b.issuer.attributes;e.actualIssuer=d.attributes;throw e;}e=b.md;if(null===e){if(b.signatureOid in m)switch(m[b.signatureOid]){case "sha1WithRSAEncryption":e=c.md.sha1.create();break;case "md5WithRSAEncryption":e=c.md.md5.create();break;case "sha256WithRSAEncryption":e=c.md.sha256.create();break;case "sha512WithRSAEncryption":e=c.md.sha512.create();break;case "RSASSA-PSS":e=c.md.sha256.create()}if(null===e)throw e=Error("Could not compute certificate digest. Unknown signature OID."),
c.util.hexToBytes(e.subjectKeyIdentifier)===b}return!1};return a};p.certificateFromAsn1=function(a,d){var h={},f=[];if(!g.validate(a,w,h,f))throw h=Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate."),h.errors=f,h;if("string"!==typeof h.certSignature){for(var f="\x00",n=0;n<h.certSignature.length;++n)f+=g.toDer(h.certSignature[n]).getBytes();h.certSignature=f}f=g.derToOid(h.publicKeyOid);if(f!==p.oids.rsaEncryption)throwError("Cannotreadpublickey.OIDisnotRSA.");
var q=p.createCertificate();q.version=h.certVersion?h.certVersion.charCodeAt(0):0;f=c.util.createBuffer(h.certSerialNumber);q.serialNumber=f.toHex();q.signatureOid=c.asn1.derToOid(h.certSignatureOid);q.signatureParameters=J(q.signatureOid,h.certSignatureParams,!0);q.siginfo.algorithmOid=c.asn1.derToOid(h.certinfoSignatureOid);q.siginfo.parameters=J(q.siginfo.algorithmOid,h.certinfoSignatureParams,!1);f=c.util.createBuffer(h.certSignature);++f.read;q.signature=f.getBytes();f=[];void 0!==h.certValidity1UTCTime&&
f.push(g.utcTimeToDate(h.certValidity1UTCTime));void 0!==h.certValidity2GeneralizedTime&&f.push(g.generalizedTimeToDate(h.certValidity2GeneralizedTime));void 0!==h.certValidity3UTCTime&&f.push(g.utcTimeToDate(h.certValidity3UTCTime));void 0!==h.certValidity4GeneralizedTime&&f.push(g.generalizedTimeToDate(h.certValidity4GeneralizedTime));if(2<f.length)throwError("CannotreadnotBefore/notAftervaliditytimes;morethantwotimeswereprovidedinthecertificate.");if(2>f.length)throw Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");
q.validity.notBefore=f[0];q.validity.notAfter=f[1];q.tbsCertificate=h.tbsCertificate;if(d){q.md=null;if(q.signatureOid in m)switch(f=m[q.signatureOid],f){case "sha1WithRSAEncryption":q.md=c.md.sha1.create();break;case "md5WithRSAEncryption":q.md=c.md.md5.create();break;case "sha256WithRSAEncryption":q.md=c.md.sha256.create();break;case "sha512WithRSAEncryption":q.md=c.md.sha512.create();break;case "RSASSA-PSS":q.md=c.md.sha256.create()}if(null===q.md)throw h=Error("Could not compute certificate digest. Unknown signature OID."),
function(a){var b={};b.id=g.derToOid(a.value[0].value);b.critical=!1;a.value[1].type===g.Type.BOOLEAN?(b.critical=0!==a.value[1].value.charCodeAt(0),b.value=a.value[2].value):b.value=a.value[1].value;if(b.id in m)if(b.name=m[b.id],"keyUsage"===b.name){a=g.fromDer(b.value);var d=0,e=0;1<a.value.length&&(d=a.value.charCodeAt(1),e=2<a.value.length?a.value.charCodeAt(2):0);b.digitalSignature=128===(d&128);b.nonRepudiation=64===(d&64);b.keyEncipherment=32===(d&32);b.dataEncipherment=16===(d&16);b.keyAgreement=
g.derToOid(a.value[d].value),e in m?b[m[e]]=!0:b[e]=!0;else if("nsCertType"===b.name)a=g.fromDer(b.value),d=0,1<a.value.length&&(d=a.value.charCodeAt(1)),b.client=128===(d&128),b.server=64===(d&64),b.email=32===(d&32),b.objsign=16===(d&16),b.reserved=8===(d&8),b.sslCA=4===(d&4),b.emailCA=2===(d&2),b.objCA=1===(d&1);elseif("subjectAltName"===b.name||"issuerAltName"===b.name)for(b.altNames=[],a=g.fromDer(b.value),e=0;e<a.value.length;++e){vard=a.value[e],h={type:d.type,value:d.value};b.altNames.push(h);
switch(d.type){case 7:h.ip=c.util.bytesToIP(d.value);break;case 8:h.oid=g.derToOid(d.value)}}else"subjectKeyIdentifier"===b.name&&(a=g.fromDer(b.value),b.subjectKeyIdentifier=c.util.bytesToHex(a.value));return b};p.certificationRequestFromAsn1=function(a,d){var h={},f=[];if(!g.validate(a,A,h,f))throw h=Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest."),h.errors=f,h;if("string"!==typeof h.csrSignature){for(var f="\x00",n=0;n<h.csrSignature.length;++n)f+=
g.toDer(h.csrSignature[n]).getBytes();h.csrSignature=f}f=g.derToOid(h.publicKeyOid);if(f!==p.oids.rsaEncryption)throw Error("Cannot read public key. OID is not RSA.");var q=p.createCertificationRequest();q.version=h.csrVersion?h.csrVersion.charCodeAt(0):0;q.signatureOid=c.asn1.derToOid(h.csrSignatureOid);q.signatureParameters=J(q.signatureOid,h.csrSignatureParams,!0);q.siginfo.algorithmOid=c.asn1.derToOid(h.csrSignatureOid);q.siginfo.parameters=J(q.siginfo.algorithmOid,h.csrSignatureParams,!1);f=
c.util.createBuffer(h.csrSignature);++f.read;q.signature=f.getBytes();q.certificationRequestInfo=h.certificationRequestInfo;if(d){q.md=null;if(q.signatureOid in m)switch(f=m[q.signatureOid],f){case "sha1WithRSAEncryption":q.md=c.md.sha1.create();break;case "md5WithRSAEncryption":q.md=c.md.md5.create();break;case "sha256WithRSAEncryption":q.md=c.md.sha256.create();break;case "sha512WithRSAEncryption":q.md=c.md.sha512.create();break;case "RSASSA-PSS":q.md=c.md.sha256.create()}if(null===q.md)throw h=
Error("Could not compute certification request digest. Unknown signature OID."),h.signatureOid=q.signatureOid,h;f=g.toDer(q.certificationRequestInfo);q.md.update(f.getBytes())}f=c.md.sha1.create();q.subject.getField=function(a){return b(q.subject,a)};q.subject.addField=function(a){e([a]);q.subject.attributes.push(a)};q.subject.attributes=p.RDNAttributesAsArray(h.certificationRequestInfoSubject,f);q.subject.hash=f.digest().toHex();q.publicKey=p.publicKeyFromAsn1(h.subjectPublicKeyInfo);q.getAttribute=
p.verifyCertificateChain=function(a,b,d){b=b.slice(0);var e=b.slice(0),h=new Date,g=!0,f=null,k=0;do{var m=b.shift(),n=null,u=!1;if(h<m.validity.notBefore||h>m.validity.notAfter)f={message:"Certificate is not valid yet or has expired.",error:p.certificateError.certificate_expired,notBefore:m.validity.notBefore,notAfter:m.validity.notAfter,now:h};if(null===f){n=b[0]||a.getIssuer(m);null===n&&m.isIssuer(m)&&(u=!0,n=m);if(n){var v=n;c.util.isArray(v)||(v=[v]);for(var r=!1;!r&&0<v.length;){n=v.shift();
try{r=n.verify(m)}catch(w){}}r||(f={message:"Certificate signature is invalid.",error:p.certificateError.bad_certificate})}null!==f||n&&!u||a.hasCertificate(m)||(f={message:"Certificate is not trusted.",error:p.certificateError.unknown_ca})}null===f&&n&&!m.isIssuer(n)&&(f={message:"Certificate issuer is invalid.",error:p.certificateError.bad_certificate});if(null===f)for(v={keyUsage:!0,basicConstraints:!0},r=0;null===f&&r<m.extensions.length;++r){var x=m.extensions[r];!x.critical||x.name in v||(f=
{message:"Certificate has an unsupported critical extension.",error:p.certificateError.unsupported_certificate})}null!==f||g&&(0!==b.length||n&&!u)||(g=m.getExtension("basicConstraints"),m=m.getExtension("keyUsage"),null!==m&&(m.keyCertSign&&null!==g||(f={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:p.certificateError.bad_certificate})),
null!==f||null===g||g.cA||(f={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:p.certificateError.bad_certificate}),null===f&&null!==m&&"pathLenConstraint"in g&&k-1>g.pathLenConstraint&&(f={message:"Certificate basicConstraints pathLenConstraint violated.",error:p.certificateError.bad_certificate}));m=null===f?!0:f.error;g=d?d(m,k,e):m;if(!0===g)f=null;else{!0===m&&(f={message:"The application rejected the certificate.",error:p.certificateError.bad_certificate});
a.errors=x,a;q=h.derToOid(p.contentType);if(q!==g.oids.data)throw a=Error("PKCS#12 EncryptedContentInfo ContentType is not Data."),a.oid=q,a;q=h.derToOid(p.encAlgorithm);q=g.pbe.getCipher(q,p.encParameter,w);p=d(p.encryptedContentAsn1);p=c.util.createBuffer(p.value);q.update(p);if(!q.finish())throw Error("Failed to decrypt PKCS#12 SafeContents.");q=q.output.getBytes();r.encrypted=!0;break;default:throw a=Error("Unsupported PKCS#12 contentType."),a.contentType=h.derToOid(p.contentType),a;}r.safeBags=
f(q,e,k);a.safeContents.push(r)}}function f(a,c,b){if(!c&&0===a.length)return[];a=h.fromDer(a,c);if(a.tagClass!==h.Class.UNIVERSAL||a.type!==h.Type.SEQUENCE||!0!==a.constructed)throw Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var d=[],e=0;e<a.value.length;e++){varl={},k=[];if(!h.validate(a.value[e],x,l,k))throwa=Error("CannotreadSafeBag."),a.errors=k,a;varm={type:h.derToOid(l.bagId),attributes:n(l.bagAttributes)};d.push(m);varp,u,v=l.bagValue.value[0];switch(m.type){caseg.oids.pkcs8ShroudedKeyBag:if(v=
p.pkcs12FromAsn1=function(a,f,m){"string"===typeof f?(m=f,f=!0):void 0===f&&(f=!0);var n={};if(!h.validate(a,r,n,[]))throw f=Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX."),f.errors=f,f;var u={version:n.version.charCodeAt(0),safeContents:[],getBags:function(a){var d={},e;"localKeyId"in a?e=a.localKeyId:"localKeyIdHex"in a&&(e=c.util.hexToBytes(a.localKeyIdHex));void 0===e&&!("friendlyName"in a)&&"bagType"in a&&(d[a.bagType]=b(u.safeContents,null,null,a.bagType));void 0!==e&&
(d.localKeyId=b(u.safeContents,"localKeyId",e,a.bagType));"friendlyName"in a&&(d.friendlyName=b(u.safeContents,"friendlyName",a.friendlyName,a.bagType));return d},getBagsByFriendlyName:function(a,c){return b(u.safeContents,"friendlyName",a,c)},getBagsByLocalKeyId:function(a,c){return b(u.safeContents,"localKeyId",a,c)}};if(3!==n.version.charCodeAt(0))throw f=Error("PKCS#12 PFX of version other than 3 not supported."),f.version=n.version.charCodeAt(0),f;if(h.derToOid(n.contentType)!==g.oids.data)throw f=
Error("Only PKCS#12 PFX in password integrity mode supported."),f.oid=h.derToOid(n.contentType),f;a=n.content.value[0];if(a.tagClass!==h.Class.UNIVERSAL||a.type!==h.Type.OCTETSTRING)throw Error("PKCS#12 authSafe content data is not an OCTET STRING.");a=d(a);if(n.mac){var w=null,x=0,q=h.derToOid(n.macAlgorithm);switch(q){case g.oids.sha1:w=c.md.sha1.create();x=20;break;case g.oids.sha256:w=c.md.sha256.create();x=32;break;case g.oids.sha384:w=c.md.sha384.create();x=48;break;case g.oids.sha512:w=c.md.sha512.create();
x=64;break;case g.oids.md5:w=c.md.md5.create(),x=16}if(null===w)throw Error("PKCS#12 uses unsupported MAC algorithm: "+q);var q=new c.util.ByteBuffer(n.macSalt),B="macIterations"in n?parseInt(c.util.bytesToHex(n.macIterations),16):1,x=p.generateKey(m,q,3,B,x,w),q=c.hmac.create();q.start(w,x);q.update(a.value);if(q.getMac().getBytes()!==n.macDigest)throw Error("PKCS#12 MAC could not be verified. Invalid password?");}e(u,a.value,f,m);return u};p.toPkcs12Asn1=function(a,b,d,e){e=e||{};e.saltSize=e.saltSize||
function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){var b=c.asn1,d=c.pki=c.pki||{};d.pemToDer=function(a){a=c.pem.decode(a)[0];if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert PEM to DER; PEM is encrypted.");return c.util.createBuffer(a.body)};d.privateKeyFromPem=function(a){a=c.pem.decode(a)[0];if("PRIVATE KEY"!==a.type&&"RSA PRIVATE KEY"!==a.type){var f=Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');
f.headerType=a.type;throw f;}if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert private key from PEM; PEM is encrypted.");a=b.fromDer(a.body);return d.privateKeyFromAsn1(a)};d.privateKeyToPem=function(a,f){var n={type:"RSA PRIVATE KEY",body:b.toDer(d.privateKeyToAsn1(a)).getBytes()};return c.pem.encode(n,{maxline:f})};d.privateKeyInfoToPem=function(a,d){var f={type:"PRIVATE KEY",body:b.toDer(a).getBytes()};return c.pem.encode(f,{maxline:d})}}if("function"!==typeof c)if("object"===
certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100};h.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2};h.CipherSuites={};h.getCipherSuite=function(a){var c=null,b;for(b in h.CipherSuites){var d=h.CipherSuites[b];if(d.id[0]===a.charCodeAt(0)&&d.id[1]===a.charCodeAt(1)){c=d;break}}return c};
h.handleUnexpected=function(a,c){(a.open||a.entity!==h.ConnectionEnd.client)&&a.error(a,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unexpected_message}})};h.handleHelloRequest=function(a,c,b){!a.handshaking&&0<a.handshakes&&(h.queue(a,h.createAlert(a,{level:h.Alert.Level.warning,description:h.Alert.Description.no_renegotiation})),h.flush(a));a.process()};h.parseHelloMessage=function(a,b,d){var e=null,g=a.entity===
h.ConnectionEnd.client;if(38>d)a.error(a,{message:g?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});else{b=b.fragment;var k=b.length(),e={version:{major:b.getByte(),minor:b.getByte()},random:c.util.createBuffer(b.getBytes(32)),session_id:f(b,1),extensions:[]};g?(e.cipher_suite=b.getBytes(2),e.compression_method=b.getByte()):(e.cipher_suites=f(b,2),e.compression_methods=
f(d,3),g=c.asn1.fromDer(e),e=c.pki.certificateFromAsn1(g,!0),b.push(e)}catch(k){return a.error(a,{message:"Could not parse certificate list.",cause:k,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.bad_certificate}})}e=a.entity===h.ConnectionEnd.client;!e&&!0!==a.verifyClient||0!==b.length?0===b.length?a.expect=e?p:y:(e?a.session.serverCertificate=b[0]:a.session.clientCertificate=b[0],h.verifyCertificateChain(a,b)&&(a.expect=e?p:y)):a.error(a,{message:e?"No server certificate provided.":
"No client certificate provided.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});a.process()};h.handleServerKeyExchange=function(a,c,b){if(0<b)returna.error(a,{message:"Invalidkeyparameters.OnlyRSAissupported.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unsupported_certificate}});a.expect=m;a.process()};h.handleClientKeyExchange=function(a,b,d){if(48>d)return a.error(a,{message:"Invalid key parameters. Only RSA is supported.",
send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unsupported_certificate}});b=f(b.fragment,2).getBytes();d=null;if(a.getPrivateKey)try{d=a.getPrivateKey(a,a.session.serverCertificate),d=c.pki.privateKeyFromPem(d)}catch(e){a.error(a,{message:"Could not get private key.",cause:e,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}})}if(null===d)return a.error(a,{message:"No private key set.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}});
try{var g=a.session.sp;g.pre_master_secret=d.decrypt(b);var k=a.session.clientHelloVersion;if(k.major!==g.pre_master_secret.charCodeAt(0)||k.minor!==g.pre_master_secret.charCodeAt(1))throw Error("TLS version rollback attack detected.");}catch(e){g.pre_master_secret=c.random.getBytes(48)}a.expect=z;null!==a.session.clientCertificate&&(a.expect=C);a.process()};h.handleCertificateRequest=function(a,c,b){if(3>b)return a.error(a,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:h.Alert.Level.fatal,
description:h.Alert.Description.illegal_parameter}});c=c.fragment;c={certificate_types:f(c,1),certificate_authorities:f(c,2)};a.session.certificateRequest=c;a.expect=r;a.process()};h.handleCertificateVerify=function(a,b,d){if(2>d)return a.error(a,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});d=b.fragment;d.read-=4;b=d.bytes();d.read+=4;d=f(d,2).getBytes();var e=c.util.createBuffer();e.putBuffer(a.session.md5.digest());
e.putBuffer(a.session.sha1.digest());e=e.getBytes();try{if(!a.session.clientCertificate.publicKey.verify(e,d,"NONE"))throw Error("CertificateVerify signature does not match.");a.session.md5.update(b);a.session.sha1.update(b)}catch(g){return a.error(a,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.handshake_failure}})}a.expect=z;a.process()};h.handleServerHelloDone=function(a,b,d){if(0<d)returna.error(a,{message:"InvalidServerHelloDonemessage.Invalidlength.",
send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.record_overflow}});if(null===a.serverCertificate&&(b={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.insufficient_security}},d=a.verify(a,b.alert.description,0,[]),!0!==d)){if(d||0===d)"object"!==typeof d||c.util.isArray(d)?"number"===typeof d&&(b.alert.description=d):(d.message&&(b.message=d.message),d.alert&&(b.alert.description=d.alert));
break;case h.Alert.Description.no_renegotiation:d="Renegotiation not supported.";break;default:d="Unknown error."}if(b.description===h.Alert.Description.close_notify)return a.close();a.error(a,{message:d,send:!1,origin:a.entity===h.ConnectionEnd.client?"server":"client",alert:b});a.process()};h.handleHandshake=function(a,b){var d=b.fragment,e=d.getByte(),g=d.getInt24();if(g>d.length())return a.fragmented=b,b.fragment=c.util.createBuffer(),d.read-=4,a.process();a.fragmented=null;d.read-=4;var f=d.bytes(g+
4);d.read+=4;e in T[a.entity][a.expect]?(a.entity!==h.ConnectionEnd.server||a.open||a.fail||(a.handshaking=!0,a.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:c.md.md5.create(),sha1:c.md.sha1.create()}),e!==h.HandshakeType.hello_request&&e!==h.HandshakeType.certificate_verify&&e!==h.HandshakeType.finished&&(a.session.md5.update(f),a.session.sha1.update(f)),T[a.entity][a.expect][e](a,b,g)):
cipherState:null,cipherFunction:function(a){return!0},compressionState:null,compressFunction:function(a){return!0},updateSequenceNumber:function(){4294967295===a.sequenceNumber[1]?(a.sequenceNumber[1]=0,++a.sequenceNumber[0]):++a.sequenceNumber[1]}};return a},g={read:b(),write:b()};g.read.update=function(a,c){g.read.cipherFunction(c,g.read)?g.read.compressFunction(a,c,g.read)||a.error(a,{message:"Could not decompress record.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.decompression_failure}}):
a.error(a,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.bad_record_mac}});return!a.fail};g.write.update=function(a,c){g.write.compressFunction(a,c,g.write)?g.write.cipherFunction(c,g.write)||a.error(a,{message:"Could not encrypt record.",send:!1,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}}):a.error(a,{message:"Could not compress record.",send:!1,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}});
var q=c.util.createBuffer();n(q,3,p);e.putBuffer(q)}d=c.pki.certificateFromAsn1(g);b?a.session.clientCertificate=d:a.session.serverCertificate=d}catch(u){return a.error(a,{message:"Could not send certificate list.",cause:u,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.bad_certificate}})}a=3+e.length();b=c.util.createBuffer();b.putByte(h.HandshakeType.certificate);b.putInt24(a);n(b,3,e);return b};h.createClientKeyExchange=function(a){var b=c.util.createBuffer();b.putByte(a.session.clientHelloVersion.major);
d.putBuffer(a.session.sha1.digest());d=d.getBytes();a.getSignature=a.getSignature||function(a,b,d){var e=null;if(a.getPrivateKey)try{e=a.getPrivateKey(a,a.session.clientCertificate),e=c.pki.privateKeyFromPem(e)}catch(g){a.error(a,{message:"Could not get private key.",cause:g,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}})}null===e?a.error(a,{message:"No private key set.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}}):
b=e.sign(b,null);d(a,b)};a.getSignature(a,d,b)};h.createCertificateVerify=function(a,b){var d=b.length+2,e=c.util.createBuffer();e.putByte(h.HandshakeType.certificate_verify);e.putInt24(d);e.putInt16(b.length);e.putBytes(b);return e};h.createCertificateRequest=function(a){var b=c.util.createBuffer();b.putByte(1);var d=c.util.createBuffer(),e;for(e in a.caStore.certs){var g=c.pki.distinguishedNameToAsn1(a.caStore.certs[e].subject);d.putBuffer(c.asn1.toDer(g))}a=1+b.length()+2+d.length();e=c.util.createBuffer();
function(a,b){var d=null;if(a&&a.getSession&&a.setSession&&a.order)d=a;else{d={};d.cache=a||{};d.capacity=Math.max(b||100,1);d.order=[];for(var e in a)d.order.length<=b?d.order.push(e):delete a[e];d.getSession=function(a){var b=null,e=null;a?e=c.util.bytesToHex(a):0<d.order.length&&(e=d.order[0]);if(null!==e&&eind.cache){b=d.cache[e];deleted.cache[e];for(vargind.order)if(d.order[g]===e){d.order.splice(g,1);break}}returnb};d.setSession=function(a,b){if(d.order.length===d.capacity){vare=d.order.shift();
delete d.cache[e]}e=c.util.bytesToHex(a);d.order.push(e);d.cache[e]=b}}return d};h.createConnection=function(a){var b=null,b=a.caStore?c.util.isArray(a.caStore)?c.pki.createCaStore(a.caStore):a.caStore:c.pki.createCaStore(),d=a.cipherSuites||null;if(null===d){var d=[],e;for(e in h.CipherSuites)d.push(h.CipherSuites[e])}e=a.server?h.ConnectionEnd.server:h.ConnectionEnd.client;var g=a.sessionCache?h.createSessionCache(a.sessionCache):null,f={version:{major:h.Version.major,minor:h.Version.minor},entity:e,
!1;f.fail=!(a||"undefined"===typeof a);f.input.clear();f.tlsData.clear();f.data.clear();f.state.current=h.createConnectionState(f)}};f.reset();f.handshake=function(a){if(f.entity!==h.ConnectionEnd.client)f.error(f,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(f.handshaking)f.error(f,{message:"Handshake already in progress.",fatal:!1});else{f.fail&&!f.open&&0===f.handshakes&&(f.fail=!1);f.handshaking=!0;a=a||"";var b=null;0<a.length&&(f.sessionCache&&(b=f.sessionCache.getSession(a)),
h.createAlert(f,{level:h.Alert.Level.warning,description:h.Alert.Description.close_notify})),h.flush(f);f.closed(f)}f.reset(a)};return f};c.tls=c.tls||{};for(var R in h)"function"!==typeof h[R]&&(c.tls[R]=h[R]);c.tls.prf_tls1=b;c.tls.hmac_sha1=function(a,b,d){var e=c.hmac.create();e.start("SHA1",a);a=c.util.createBuffer();a.putInt32(b[0]);a.putInt32(b[1]);a.putByte(d.type);a.putByte(d.version.major);a.putByte(d.version.minor);a.putInt16(d.length);a.putBytes(d.fragment.bytes());e.update(a.getBytes());
m.Type.OCTETSTRING,!1,a.parameter.getBytes())]),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,a.content.getBytes())])]}function g(a,b,d){var e={};if(!m.validate(b,d,e,[]))throw a=Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message."),a.errors=a,a;if(m.derToOid(e.contentType)!==c.pki.oids.data)throw Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(e.encryptedContent){b="";if(c.util.isArray(e.encryptedContent))for(d=
break;default:throw Error("Unsupported symmetric cipher, OID "+a.encryptedContent.algorithm);}b.start(a.encryptedContent.parameter);b.update(a.encryptedContent.content);if(!b.finish())throw Error("Symmetric decryption failed.");a.content=b.output}}var m=c.asn1,r=c.pkcs7=c.pkcs7||{};r.messageFromPem=function(a){a=c.pem.decode(a)[0];if("PKCS7"!==a.type){var b=Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');b.headerType=a.type;throw b;}if(a.procType&&"ENCRYPTED"===
a.procType.type)throw Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");a=m.fromDer(a.body);return r.messageFromAsn1(a)};r.messageToPem=function(a,b){var d={type:"PKCS7",body:m.toDer(a.toAsn1()).getBytes()};return c.pem.encode(d,{maxline:b})};r.messageFromAsn1=function(a){var b={},d=[];if(!m.validate(a,r.asn1.contentInfoValidator,b,d))throw b=Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo."),b.errors=d,b;d=m.derToOid(b.contentType);switch(d){case c.pki.oids.envelopedData:d=
r.createEnvelopedData();break;case c.pki.oids.encryptedData:d=r.createEncryptedData();break;case c.pki.oids.signedData:d=r.createSignedData();break;default:throw Error("Cannot read PKCS#7 message. ContentType with OID "+d+" is not (yet) supported.");}d.fromAsn1(b.content.value[0]);return d};r.createSignedData=function(){var a=null;return a={type:c.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(b){g(a,
m.Type.NULL,!1,"")]));if(2>a.contentInfo.value.length)throw Error("Could not sign PKCS#7 message; there is no content to sign.");var g=m.derToOid(a.contentInfo.value[0].value),d=a.contentInfo.value[1],d=d.value[0],h=m.toDer(d);h.getByte();m.getBerValueLength(h);var h=h.getBytes(),k;for(k in b)b[k].start().update(h);k=new Date;for(d=0;d<a.signers.length;++d){e=a.signers[d];if(0===e.authenticatedAttributes.length){if(g!==c.pki.oids.data)throwError("Invalidsigner;authenticatedAttributesmustbepresentwhentheContentInfocontenttypeisnotPKCS#7Data.");
null===a.parent||(a.parent.error=a.error,a.parent.swapTime=a.swapTime,a.parent.userData=a.userData,g(a.parent,c))};b?setTimeout(d,0):d(c)},p=function(a,d){a.state="done";delete b[a.id];null===a.parent&&(a.type in e?0===e[a.type].length?c.log.error("forge.task","[%s][%s] task queue empty [%s]",a.id,a.name,a.type):e[a.type][0]!==a?c.log.error("forge.task","[%s][%s] task not first in queue [%s]",a.id,a.name,a.type):(e[a.type].shift(),0===e[a.type].length?delete e[a.type]:e[a.type][0].start()):c.log.error("forge.task",
"[%s][%s] task queue missing [%s]",a.id,a.name,a.type),d||(a.error&&a.failureCallback?a.failureCallback(a):!a.error&&a.successCallback&&a.successCallback(a)))};c.task=c.task||{};c.task.start=function(a){var c=new n({run:a.run,name:a.name||"?"});c.type=a.type;c.successCallback=a.success||null;c.failureCallback=a.failure||null;c.type in e?e[a.type].push(c):(e[c.type]=[c],h(c))};c.task.cancel=function(a){a in e&&(e[a]=[e[a][0]])};c.task.createCondition=function(){var a={tasks:{},wait:function(c){c.id in
a.tasks||(c.block(),a.tasks[c.id]=c)},notify:function(){var c=a.tasks;a.tasks={};for(var b in c)c[b].unblock()}};return a}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.task)return b.task;b.defined.task=!0;for(var f=0;f<e.length;++f)e[f](b);returnb.task}},
function(){n.apply(null,Array.prototype.slice.call(arguments,0))})})();return b("js/forge")});function amtcert_linkCertPrivateKey(a,b){for(var c in a){var d=a[c];try{if(0==xxCertPrivateKeys.length)break;for(var f=forge.pki.publicKeyToPem(forge.pki.certificateFromAsn1(forge.asn1.fromDer(d.X509Certificate)).publicKey).substring(60).replace(/(\r\n|\n|\r)/gm,""),n=0;n<b.length;n++)f===b[n].DERKey+"-----ENDPUBLICKEY-----"&&(b[n].XCert=d,d.XPrivateKey=b[n])}catch(p){console.log(p)}}}
function amtcert_loadP12File(a,b,c){try{var d=window.forge.util.decode64(btoa(a)),f=window.forge.asn1.fromDer(d),n=window.forge.pkcs12.pkcs12FromAsn1(f,b),p=n.getBags({bagType:window.forge.pki.oids.pkcs8ShroudedKeyBag});console.assert(p[window.forge.pki.oids.pkcs8ShroudedKeyBag]&&0<p[window.forge.pki.oids.pkcs8ShroudedKeyBag].length);var r=p[window.forge.pki.oids.pkcs8ShroudedKeyBag][0].key,l=window.forge.pki.privateKeyToAsn1(r),k=window.forge.pki.wrapRsaPrivateKey(l);window.forge.asn1.toDer(k).getBytes();
var v=n.getBags({bagType:window.forge.pki.oids.certBag})[window.forge.pki.oids.certBag][0].cert.subject.attributes,e=n.getBags({bagType:forge.pki.oids.certBag})[forge.pki.oids.certBag][0].cert;c(r,v,e);return!0}catch(u){}return!1}function amtcert_signWithCaKey(a,b,c,d,f){b&&null!=b||(b=amtcert_createCertificate(d).key);return amtcert_createCertificate(c,b,a,d,f)}
function amtcert_createCertificate(a,b,c,d,f){var n,p=forge.pki.createCertificate();c?p.publicKey=forge.pki.publicKeyFromPem("-----BEGIN PUBLIC KEY-----"+c+"-----END PUBLIC KEY-----"):(n=forge.pki.rsa.generateKeyPair(2048),p.publicKey=n.publicKey);p.serialNumber=""+Math.floor(1E5*Math.random()+1);p.validity.notBefore=new Date;p.validity.notBefore.setFullYear(p.validity.notBefore.getFullYear()-1);p.validity.notAfter=new Date;p.validity.notAfter.setFullYear(p.validity.notAfter.getFullYear()+30);var r=
c.ip+4),p=c.ip+6,r=[],l;for(l in c.variables)l.startsWith("__")&&delete c.variables[l];for(l=0;l<n;l++){vark=ReadShort(c.script,p),v=c.script.substring(p+2,p+2+k),e=v.charCodeAt(0),v=v.substring(1);if(2>e){for(;1<v.split("{").length;)varu=v.split("{").pop().split("}").shift(),v=v.replace("{"+u+"}",c.getVar(u));1==e&&(c.variables["__"+l]=decodeURI(v),v="__"+l);r.push(v)}if(2==e||3==e)c.variables["__"+l]=ReadSInt(v,0),r.push("__"+l);p+=2+k}c.ip+=b;b=[];for(l=0;10>l;l++)b.push(c.getVar(r[l]));var B;
function script_compile(a,b){var c="",d=a.split("\n"),f={},n=[],p=[],r;for(r in d){var l=d[r];if(l.startsWith("##SWAP ")){var k=l.split(" ");3==k.length&&(p[k[1]]=k[2])}if("#"!=l[0]&&0!=l.length){for(k in p)l=l.split(k).join(p[k]);var v=l.match(/"[^"]*"|[^\s"]+/g);if(0!=v.length)if(":"==l[0])f[v[0].toUpperCase()]=c.length;else{l=script_functionTable1.indexOf(v[0].toLowerCase());-1==l&&(l=script_functionTable2.indexOf(v[0].toLowerCase()),0<=l&&(l+=1E4));-1==l&&(l=script_functionTable3.indexOf(v[0].toLowerCase()),
0<=l&&(l+=2E4));if(-1==l)return b&&b("Unabled to compile, unknown command: "+v[0]),"";var e=ShortToStr(v.length-1),u;for(u in v)if(0!=u)if(":"==v[u][0])n.push([v[u],c.length+e.length+7]),e+=ShortToStr(5)+String.fromCharCode(3)+IntToStr(4294967295);else var B=parseInt(v[u]),e=B==v[u]?e+(ShortToStr(5)+String.fromCharCode(2)+IntToStr(B)):'"'==v[u][0]&&'"'==v[u][v[u].length-1]?e+(ShortToStr(v[u].length-1)+String.fromCharCode(1)+v[u].substring(1,v[u].length-1)):e+(ShortToStr(v[u].length+1)+String.fromCharCode(0)+
v[u]);e=ShortToStr(l)+ShortToStr(e.length+4)+e;c+=e}}}for(r in n){d=n[r][0].toUpperCase();p=n[r][1];k=f[d];if(void 0==k)return b&&b("Unabled to compile, unknown label: "+d),"";c=c.substr(0,p)+IntToStr(k)+c.substr(p+4)}return IntToStr(612182341)+ShortToStr(1)+c}
function startup(){var a=document.getElementsByTagName("input");for(t=0;t<a.length;t++)a[t].id&&(window[a[t].id]=a[t]);urlvars=getUrlVars();for(varbinAllWsman)a=document.createElement("option"),a.text=AllWsman[b],a.id="WSB-"+AllWsman[b],Q(22).add(a);document.addEventListener("dragover",haltEvent,!1);document.addEventListener("dragleave",haltEvent,!1);document.addEventListener("drop",documentFileSelectHandler,!1);Q("p16").addEventListener("dragover",haltEvent,!1);Q("p16").addEventListener("dragleave",
function documentFileSelectHandler(a){haltEvent(a);if(null!=a.dataTransfer&&1==a.dataTransfer.files.length){var b=null,c=a.dataTransfer.files[0].name.toLowerCase();21==currentView?UploadToStorage(a.dataTransfer.files[0],c):(null!=wsstack&&(c.endsWith(".mescript")||c.endsWith(".meblocks"))&&(b=script_onScriptRead),null!=b&&(c=new FileReader,c.onload=b,c.readAsBinaryString(a.dataTransfer.files[0])))}}
function connectButtonfunction(){wsstack&&0!=wsstack.socketState?disconnect():meshcentral2credCallback()}function connectButtonfunctionEx(){currentMeshNode=parent.getCurrentNode();connect(currentMeshNode._id,16992,null,null,0);Q("xconnectbutton1").value="Disconnect"}function getCurrentMeshNode(){return currentMeshNode}function setConnectionState(a){QE("xconnectbutton1",a);0==a&&disconnect()}function setFrameHeight(a){}function setAuthCallback(a){meshcentral2credCallback=a}function cleanup(){}
function handleKeyUp(a){}function handleKeyDown(a){}function handleKeyPress(a){}
function connect(a,b,c,d,f){go(0);wsstack=WsmanStackCreateService(a,b,c,d,f);amtstack=AmtStackCreateService(wsstack);amtstack.onProcessChanged=onProcessChanged;for(a=2;25>a;a++)QV("go"+a,!1);QV("go8",!0);QV("go12",!0);QV("go20",!0);amtversion=amtversionmin=amtFirstPull=0;amtsysstate=amtdeltatime=amtlogicalelements=HardwareInventory=void 0;amtPowerBootCapabilities=null;xxAccountFetch=999;QH(15,LoadingHtml);QH(19,LoadingHtml);amtwirelessif=-1;xxWireless=void 0;
function disconnect(){StopDefenseStatsTimer();script_Stop();breakScriptButton();dialogclose(0);amtstack&&(amtstack.onProcessChanged=null,amtstack.CancelAllQueries(999),amtstack=null);cleanup();wsstack=null;delete amtstack;onProcessChanged(0,1);go(101);Q("xconnectbutton1").value="Connect";QH(5,"Disconnected");go(100)}
function onProcessChanged(a,b){QS(3).width=100*a/b+"%";0==a&&refreshButtons(!0);0==a&&amtstack&&(0<amtversion&&0==(amtFirstPull&64)?(amtFirstPull|=64,PullPowerPolicy(),subscriptionsFilters=null,PullEventSubscriptions(),PullWatchdog(),scriptViewButton(script_BuildingBlocks?1:0),5<amtversion&&(PullCertificates(),PullRemoteAccess())):0==(amtFirstPull&1)?PullHardware():0==(amtFirstPull&16)?PullEventLog():0==(amtFirstPull&32)&&PullAuditLog())}
function checkAmtVersion(a){var b=a.split(".");a=parseInt(b[0]);var c=parseInt(b[1]),b=parseInt(b[2]),b=1E3*c+b,d=0;5>=a||12<=a?d=1:6==a&&2061<=b?d=1:7==a&&1091<=b?d=1:8==a&&1071<=b?d=1:9==a?5>c&&1041<=b?d=1:5061<=b&&(d=1):10==a&&55<=b?d=1:11==a&&(5>c&&25<=b?d=1:6027<=b&&(d=1));return 0==d}
function processSystemVersion(a,b,c,d){if(200==d||400==d){if(200==d){amtlogicalelements=[];null!=c&&null!=c.CIM_SoftwareIdentity&&null!=c.CIM_SoftwareIdentity.responses&&(amtlogicalelements=c.CIM_SoftwareIdentity.responses,null!=c.AMT_SetupAndConfigurationService&&null!=c.AMT_SetupAndConfigurationService.response&&amtlogicalelements.push(c.AMT_SetupAndConfigurationService.response));if(0==amtlogicalelements.length){console.error("ERROR: Could not get Intel AMT version.");disconnect();return}b=getInstance(amtlogicalelements,
function refreshButtons(a){if(refreshButtonsState!=a){refreshButtonsState=a;for(var b=0,c=document.getElementsByTagName("input");b<c.length;b++)"refreshbtn"==c[b].name&&(c[b].disabled=!a)}}functionPullPowerState(){amtstack&&0==amtstack.GetPendingActions()&&amtsysstate&&amtsysstate.CIM_ServiceAvailableToElement&&amtstack.Enum("CIM_ServiceAvailableToElement",function(a,b,c,d){errcheck(d,a)||(amtsysstate.CIM_ServiceAvailableToElement.responses=c,updateSystemStatus())})}
function PullSystemStatus(a){refreshButtons(!1);amtstack.AMT_TimeSynchronizationService_GetLowAccuracyTimeSynch(processSystemTime);var b=["CIM_ServiceAvailableToElement","*AMT_GeneralSettings","AMT_EthernetPortSettings","*AMT_RedirectionService","CIM_ElementSettingData"];5<amtversion&&b.push("IPS_IPv6PortSettings","*CIM_KVMRedirectionSAP","*IPS_OptInService","*IPS_KVMRedirectionSettingData");9<amtversion&&b.push("*IPS_ScreenConfigurationService");amtstack.BatchEnum("",b,processSystemStatus,!0);1==
function processSystemStatus(a,b,c,d){if(void 0==c.IPS_ScreenConfigurationService||400==c.IPS_ScreenConfigurationService.status)c.IPS_ScreenConfigurationService=null;if(void 0==c.IPS_KVMRedirectionSettingData||400==c.IPS_KVMRedirectionSettingData.status)c.IPS_KVMRedirectionSettingData=null;if(void 0==c.CIM_KVMRedirectionSAP||400==c.CIM_KVMRedirectionSAP.status)c.CIM_KVMRedirectionSAP=null;if(void 0==c.IPS_OptInService||400==c.IPS_OptInService.status)c.IPS_OptInService=null;200==c.AMT_RedirectionService.status&&
QV("go13",!0);d=0;for(var f in c)null!=c[f]&&c[f].status>d&&(d=c[f].status);400!=d&&errcheck(d,a)||(amtsysstate=c,updateSystemStatus())}var DMTFPowerStates=";;Power on;Light sleep;Deep sleep;Power cycle (Soft off);Off - Hard;Hibernate (Off soft);Soft off;Power cycle (Off-hard);Master bus reset;Diagnostic interrupt (NMI);Not applicable;Off - Soft graceful;Off - Hard graceful;Master bus reset graceful;Power cycle (Off - Soft graceful);Power cycle (Off - Hard graceful);Diagnostic interrupt (INIT)".split(";");
function updateSystemStatus(){if(amtsysstate&&!(99<currentView)){vara=0,b,c,d=TableStart(),f="",n=amtsysstate.AMT_GeneralSettings.response;t="Unknown";null!=amtsysstate.CIM_ServiceAvailableToElement&&(t=DMTFPowerStates[amtsysstate.CIM_ServiceAvailableToElement.responses[0].PowerState]);n.PowerSource&&(t+=[",Plugged-in",",OnBattery"][n.PowerSource]);d+=TableEntry("Power",addLink(t,"showPowerActionDlg()"));b=n.HostName;c=n.DomainName;null!=c&&0<c.length&&(b+="."+c);b=0==b.length?"<i>None</i>":EscapeHtml(b);
d+=TableEntry("Name & Domain",addLinkConditional(b,"showEditNameDlg()",xxAccountAdminName));HardwareInventory&&(d+=TableEntry("System ID",guidToStr(HardwareInventory.CIM_ComputerSystemPackage.response.PlatformGUID.toLowerCase())));if(amtlogicalelements){var p="",r=getItem(amtlogicalelements,"CreationClassName","AMT_SetupAndConfigurationService");2==r.ProvisioningState&&5<amtversion&&(p=" activated in Admin Control Mode (ACM)",4==r.ProvisioningMode&&(p="activatedinClientControlMode(CCM)",a=9));
d);d="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px>"+TableEnd("<div> "+AddRefreshButton("PullSystemStatus(1)")+" Changing network settings may cause this page to becaume unavailable.");d=d+"<br><h2>General Settings</h2>"+TableStart();f="";"<i>None</i>"!=b&&(1==n.SharedFQDN&&(f=", shared with OS"),0==n.SharedFQDN&&(f=", different from OS"));d+=TableEntry("Name & Domain",addLinkConditional(b+f,"showEditNameDlg(1)",xxAccountAdminName));b="Disabled";1==n.DDNSUpdateEnabled?
b="Enabled each "+n.DDNSPeriodicUpdateInterval+" minutes, TTL is "+n.DDNSTTL+" minutes":1==n.DDNSUpdateByDHCPServerEnabled&&(b="Update by DHCP server");d+=TableEntry("Dynamic DNS",addLinkConditional(b,"showEditDnsDlg()",xxAccountAdminName));d+=TableEnd();for(c in amtsysstate.AMT_EthernetPortSettings.responses){b=amtsysstate.AMT_EthernetPortSettings.responses[c];if(b.WLANLinkProtectionLevel||1==c)amtwirelessif=c;if(0!=c||amtwirelessif==c||"00-00-00-00-00-00"!=b.MACAddress){0==c&&a++;d+="<br><h2>"+
(amtwirelessif==c?"Wireless":"Wired")+" Interface</h2>";d+=TableStart();d+=TableEntry("Link state",1==b.LinkIsUp?"Link is up":"Link is down");"00-00-00-00-00-00"!=b.MACAddress&&(d+=TableEntry("MAC address",b.MACAddress));amtwirelessif==c&&xxWireless&&xxWireless.CIM_WiFiPortCapabilities.response&&(d+=TableEntry("State",addLinkConditional(xxWifiState[xxWireless.CIM_WiFiPort.response.EnabledState],"showWifiStateDlg()",xxAccountAdminName)),s=xxWireless.CIM_WiFiEndpoint.response.LANID,d+=TableEntry("Radio State",
xxRadioState[xxWireless.CIM_WiFiEndpoint.response.EnabledState]+", SSID: "+(s?s:"<i>None</i>")));amtwirelessif!=c&&(d+=TableEntry("Respond to ping",addLinkConditional(["Disabled","ICMP response","RMCP response","ICMP & RMCP response"][n.PingResponseEnabled+(n.RmcpPingResponseEnabled<<1)],"showPingActionDlg()",xxAccountAdminName)),d+=TableEntry("IPv4state",addLinkConditional(1==b.DHCPEnabled?"AutomaticusingDHCPserver":"StaticIPaddress","showIPSetupDlg()",xxAccountAdminName)));d+=TableEntry("IPv4address",
function saveEntireAmtState(){if(!xxdialogMode){var a="",b=new Date;amtsysstate&&(a="-"+amtsysstate.AMT_GeneralSettings.response.HostName);a+="-"+b.getFullYear()+"-"+("0"+(b.getMonth()+1)).slice(-2)+"-"+("0"+b.getDate()).slice(-2)+"-"+("0"+b.getHours()).slice(-2)+"-"+("0"+b.getMinutes()).slice(-2);c18.value="amtstate"+a+".json";setDialogMode(19,"Save Entire Intel® AMT State",3,saveEntireAmtStateOk)}}
function saveEntireAmtStateOk(){IntelAmtEntireState={webappversion:version,localtime:Date(),utctime:(new Date).toUTCString(),isotime:(new Date).toISOString()};QH(36,"Fetching entire state, please wait...");setDialogMode(1,"Save Entire Intel® AMT State",0,null);IntelAmtEntireStateCalls=3;amtstack.BatchEnum(null,AllWsman,saveEntireAmtStateOk2,null,!0);amtstack.GetAuditLog(saveEntireAmtStateOk3);amtstack.GetMessageLog(saveEntireAmtStateOk4)}
function saveEntireAmtStateOk2(a,b,c,d){IntelAmtEntireState.wsmanenums=c;saveEntireAmtStateDone()}function saveEntireAmtStateOk3(a,b){IntelAmtEntireState.auditlog=b;saveEntireAmtStateDone()}function saveEntireAmtStateOk4(a,b){IntelAmtEntireState.eventlog=b;saveEntireAmtStateDone()}function saveEntireAmtStateDone(){0==--IntelAmtEntireStateCalls&&(setDialogMode(),saveAs(data2blob(JSON.stringify(IntelAmtEntireState,null," ").replace(/\n/g,"\r\n")),c18.value))}
function PullEventLog(a){1==a&&xxdialogMode||(amtFirstPull|=16,amtstack.Enum("AMT_MessageLog",processMessageLog0),amtstack.GetMessageLog(processMessageLog1))}var processMessageLog0responses=null;
function processMessageLog0(a,b,c,d){200==d&&(d&&QV("go6",!0),c&&(processMessageLog0responses=c),a="",b="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px>",null!=processMessageLog0responses&&(a=1==processMessageLog0responses[0].IsFrozen?AddButton("Un-freeze Log","FreezeLog(0)"):AddButton("Freeze Log","FreezeLog(1)")),b+=TableEnd("<divstyle=float:right><inputid=eventFilterplaceholder=Filterstyle=margin:4pxonkeyup=eventFilter()> </div><div> "+AddRefreshButton("PullEventLog(1)")+
AddButton("Clear Log","ClearLog()")+AddButton("Save...","SaveEventLog()")+a),QH(17,b+"<br>"))}function SaveEventLog(){xxdialogMode||null==eventmessages||SaveJsonFile("IntelAmtEventlog","events","Intel AMT Event Log",eventmessages)}var eventmessages=null;
function processMessageLog1(a,b){eventmessages=b;var c,d=0,f;f="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px><tr><tdwidth=80px><p><td><td><td><tr><tdclass=r1style=width:90px><b> Event</b><tdclass=r1style=width:110px><b>Time</b><tdclass=r1style=width:160px><b>Source</b><tdclass=r1><b>Description</b>";for(c in b){d++;var n=1,p=b[c];8<=p.EventSeverity&&(n=2);16<=p.EventSeverity&&(n=3);f+="<trid=xamtevent"+c+"class=r3onclick=showEventDetails("+
function FreezeLog(a){xxdialogMode||amtstack.AMT_MessageLog_FreezeLog(a,function(){amtstack.Enum("AMT_MessageLog",processMessageLog0)})}function ClearLog(a){xxdialogMode||(QH(36,"Clear event log?"),setDialogMode(1,"Event Log",3,ClearLogEx))}function ClearLogEx(){amtstack.AMT_MessageLog_ClearLog(function(a,b,c,d){200!=d?messagebox("Event Log","Unable to clear, Error: "+d):PullEventLog()})}
function showEventDetails(a){if(!xxdialogMode){var b=eventmessages[a],c;c="<divstyle=text-align:left>"+addHtmlValue("Time",b.Time.toLocaleString());c+=addHtmlValue("Source",b.EntityStr.replace("(r)","®"));c+=addHtmlValue("Description",b.Desc);c+=MoreStart();c+=addHtmlValue("Device Address",b.DeviceAddress);c+=addHtmlValue("Entity",b.Entity);c+=addHtmlValue("Entity Instance",b.EntityInstance);var d="",f;for(f in b.EventData)0<d.length&&(d+=","),d+=b.EventData[f];c+=addHtmlValue("Data",d);c+=addHtmlValue("Offset",
function eventFilter(){var a=Q("eventFilter").value.toLowerCase(),b;for(b in eventmessages)QV("xamtevent"+b,""==a||0<=eventmessages[b].Desc.toLowerCase().indexOf(a)||0<=eventmessages[b].EntityStr.toLowerCase().indexOf(a))}var subscriptionsFilters=null,subscriptionsListeners=null;
function PullEventSubscriptions(){null==subscriptionsFilters&&amtstack.Enum("CIM_FilterCollection",processEventSubscriptions0);amtstack.BatchEnum(null,["CIM_ListenerDestination","CIM_FilterCollectionSubscription"],processEventSubscriptions1)}function processEventSubscriptions0(a,b,c,d){408!=d&&400!=d&&(d&&errcheck(d,a)||(subscriptionsFilters=c))}
function processEventSubscriptions1(a,b,c,d){if(!(408==d||400==d||d&&errcheck(d,a))){d&&QV("go22",!0);c&&(subscriptionsListeners=c);b=0;a=TableStart2()+"<tr><tdclass=r1style=padding-left:15px><br>Manage event subscribers.<br><br>";for(var f in subscriptionsListeners.CIM_ListenerDestination.responses)c=subscriptionsListeners.CIM_FilterCollectionSubscription.responses[f].Filter.ReferenceParameters.SelectorSet.Selector.Value.replace("(r)","®"),d=subscriptionsListeners.CIM_ListenerDestination.responses[f],
TableEnd(f+"</div>");QH(32,a)}}var subscriptionDeliveryModes={2:"Push",3:"Push with ACK",4:"Events",5:"Pull"};
function showSubscriptionDetails(a){if(!xxdialogMode){var b=subscriptionsListeners.CIM_FilterCollectionSubscription.responses[a].Filter.ReferenceParameters.SelectorSet.Selector.Value.replace("(r)","®"),c=subscriptionsListeners.CIM_ListenerDestination.responses[a],d;d="<divstyle=text-align:left>"+addHtmlValue("Destination",c.Destination);d+=addHtmlValue("Filter",b);d+=addHtmlValue("Delivery Mode",subscriptionDeliveryModes[c.DeliveryMode]);setDialogMode(11,"Subscription "+(a+1),xxAccountAdminName?
5:1,deleteSubscriptionButton,d+"</div>",a)}}
function deleteSubscriptionButton(a,b){2==a&&amtstack.UnSubscribe("CIM_FilterCollectionSubscription",PullEventSubscriptions,null,1,{Filter:'<a:EndpointReference><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address><a:ReferenceParameters><w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_FilterCollection</w:ResourceURI><w:SelectorSet><w:SelectorName="InstanceID">'+subscriptionsListeners.CIM_FilterCollectionSubscription.responses[b].Filter.ReferenceParameters.SelectorSet.Selector.Value+"</w:Selector></w:SelectorSet></a:ReferenceParameters></a:EndpointReference>",
function newSubscriptionButton(){if(!xxdialogMode&&null!=subscriptionsFilters){var a;a="<divstyle=height:26px;margin-top:4px><selectid=subtypestyle=float:right;width:260px><optionvalue=Push>Push</option><optionvalue=PushWithAck>Push with ACK</option></select><divstyle=padding-top:4px>Type</div></div><divstyle=height:26px;margin-top:4px><selectid=subfilterstyle=float:right;width:260px>";for(var b in subscriptionsFilters)a+="<optionvalue='"+subscriptionsFilters[b].InstanceID+"'>"+subscriptionsFilters[b].CollectionName.substring(13)+
function newSubscriptionButtonOk(){var a=0==Q("subuser").value.length?void 0:Q("subuser").value,b=0==Q("subpass").value.length?void 0:Q("subpass").value;amtstack.Subscribe("CIM_FilterCollection",Q("subtype").value,Q("suburl").value,newSubscriptionButtonOk2,null,1,{InstanceID:Q("subfilter").value},0<Q("subargs").value.length?Q("subargs").value:null,a,b)}functionnewSubscriptionButtonOk2(a,b,c,d){200==d&&PullEventSubscriptions()}
function PullAuditLog(a){1==a&&xxdialogMode||(amtFirstPull|=32,amtstack.Enum("AMT_AuditLog",processAuditLog0))}var auditLog=null,auditLogEnabledStates="Unknown;Other;Enabled;Disabled;Shutting Down;Not Applicable;Enabled but Offline;In Test;Deferred;Quiesce;Starting".split(";");
function processAuditLog0(a,b,c,d){200==d&&(QV("go15",!0),b=c[0].AuditState,a=b&1?"Disabled":"Enabled",b&2&&(a+=", Locked"),b&4&&(a+=", Almost Full"),b&8&&(a+=", Full"),b&16&&(a+=", NoKey"),b="<h1>Audit Log Settings</h1>"+TableStart(),b+=TableEntry("State",a),b+=TableEntry("Storage",c[0].CurrentNumberOfRecords+" record(s), "+c[0].PercentageFree+"% free"),b+=TableEntry("Overwrite policy",2==c[0].OverwritePolicy?"Wraps when full":"Never overwrites"),b+=TableEnd(),QH(25,b),amtstack.GetAuditLog(processAuditLog1))}
function processAuditLog1(a,b){auditLog=b;var c,d;d="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px>"+(TableEnd("<divstyle=float:right><inputid=auditFilterplaceholder=Filterstyle=margin:4pxonkeyup=auditFilter()> </div><div> "+AddRefreshButton("PullAuditLog(1)")+AddButton("Save...","SaveAuditLog()")+AddButton("Clear Log","ClearAuditLog()"))+"<br>");if(0==b.length)d="No audit log events found.";else{var f=0;d+="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px><tr><tdwidth=80px><p><td><td><td><tr><tdclass=r1style=width:110px> <b>Time</b><tdclass=r1style=width:260px><b>Initiator</b><tdclass=r1><b>Action</b>";
for(c in b){var n=b[c],p=n.AuditApp,r=n.Initiator;f++;var l="";0<n.NetAddress.length&&(l=n.NetAddress.replace("0000:0000:0000:0000:0000:0000:0000:0001","::1"));n.Event&&(p+=","+n.Event);null!=n.ExStr&&(p+=","+n.ExStr);""!=r&&""!=l&&(r+=",");d+="<trid=xamtaudit"+c+"class=r3onclick=showAuditDetails("+c+")><tdclass=r1title='"+n.Time.toLocaleString()+"'> "+n.Time.toLocaleDateString("en",{year:"numeric",month:"2-digit",day:"numeric"})+"<br> "+n.Time.toLocaleTimeString("en",
{hour:"2-digit",minute:"2-digit",second:"2-digit"})+"<tdclass=r1>"+r+l+"<tdclass=r1>"+p}d+=TableEnd(0==f?" ":"")+"<br>"}QH(26,d)}function auditFilter(){var a=Q("auditFilter").value.toLowerCase(),b;for(b in auditLog)QV("xamtaudit"+b,""==a||0<=JSON.stringify(auditLog[b]).toLowerCase().indexOf(a))}function SaveAuditLog(){xxdialogMode||null==auditLog||SaveJsonFile("IntelAmtAuditlog","auditevents","Intel AMT Audit Log",auditLog)}
function ClearAuditLog(a){QH(36,"Clear audit log?");setDialogMode(1,"Audit Log",3,ClearAuditLogEx)}function ClearAuditLogEx(){var a=amtstack.AMT_AuditLog_SetAuditLock(1,0,a,function(){amtstack.AMT_AuditLog_ClearLog(function(){amtstack.AMT_AuditLog_SetAuditLock(0,2,a,function(){setTimeout(PullAuditLog,1E3)})})})}function ShowAuditLogSettings(){xxdialogMode||amtstack.AMT_AuditLog_RequestStateChange(2,0,AuditLogSettingsCompleted)}
function AuditLogSettingsCompleted(a,b,c,d){200==d?PullAuditLog():messagebox("Audit Log","Error: "+d)}
function showAuditDetails(a){if(!xxdialogMode){var b,c=auditLog[a],d;d="<divstyle=text-align:left>"+addHtmlValue("Time",c.Time.toLocaleString());""!=c.Initiator&&(d+=addHtmlValue("Initiator",c.Initiator));""!=c.NetAddress&&(d+=addHtmlValue("Address",c.NetAddress));d+=addHtmlValue("Application",c.AuditApp);d+=addHtmlValue("Event",c.Event);if(null!=c.ExStr)d+=addHtmlValue("Extended Data",c.ExStr);else if(0<c.Ex.length){varf="";for(binc.Ex)0<f.length&&(f+=","),f+=c.Ex.charCodeAt(b);""!=f&&(d+=addHtmlValue("DataValues",
function processCerts1(a,b,c,d){if(400!=d&&!errcheck(d,a)){QV("go16",!0);xxCertificates=c.AMT_PublicKeyCertificate.responses;xxCertPrivateKeys=c.AMT_PublicPrivateKeyPair.responses;xxTlsSettings=c.AMT_TLSSettingData.responses;xxTLSCredentialContext=c.AMT_TLSCredentialContext.responses;xxTlsCurrentCert=null;if(0<xxTLSCredentialContext.length){a=xxTLSCredentialContext[0].ElementInContext.ReferenceParameters.SelectorSet.Selector.Value;for(varfinxxCertificates)xxCertificates[f].InstanceID==a&&(xxTlsCurrentCert=
f)}for(f in xxCertificates)xxCertificates[f].TrustedRootCertficate=1==xxCertificates[f].TrustedRootCertficate,xxCertificates[f].X509Certificate=window.atob(xxCertificates[f].X509Certificate),xxCertificates[f].XIssuer=parseCertName(xxCertificates[f].Issuer),xxCertificates[f].XSubject=parseCertName(xxCertificates[f].Subject);amtcert_linkCertPrivateKey(xxCertificates,xxCertPrivateKeys);updateCertificates()}}
function parseCertName(a){var b={},c=a.split(","),d;for(d in c)a=c[d].indexOf("="),b[c[d].substring(0,a)]=c[d].substring(a+1);return b}
function getTlsSecurityState(a){if(0==xxTlsSettings[a].Enabled)return"Disabled";var b=(1==xxTlsSettings[a].MutualAuthentication?"Mutual-auth TLS":"Server-auth TLS")+(1==xxTlsSettings[a].AcceptNonSecureConnections?" and non-TLS":"");1==xxTlsSettings[a].MutualAuthentication&&xxTlsSettings[a].TrustedCN&&(a=MakeToArray(xxTlsSettings[a].TrustedCN),0<a.length&&(b+=",Trustedname"+(1<a.length?"s":"")+":"+a.join(",")+"."));returnb}
function updateCertificates(){if(null!=xxCertificates){var a="Intel(r) AMT LMS TLS Settings"==xxTlsSettings[0].InstanceID?0:1,b=1-a,c=TableStart(),c=c+TableEntry("Remote TLS security",addLinkConditional(getTlsSecurityState(b),"showSetTlsSecurityDlg()",xxAccountAdminName)),c=c+TableEntry("Local TLS security",addLinkConditional(getTlsSecurityState(a),"showSetTlsSecurityDlg()",xxAccountAdminName)),c=c+TableEnd(),c=c+("<br>"+TableStart2()+"<tr><tdclass=r1style=padding-left:15px><br>Manage Intel® AMT certificates for this computer.<br><br>");
if(0==xxCertificates.length&&0==xxCertPrivateKeys.length)c+="<divstyle=padding-left:15px><br><i>No certificates found.</i></div><br>";else{for(var d in xxCertificates)a="",xxCertificates[d].TrustedRootCertficate&&(a=", Trusted Root"),xxCertificates[d].XPrivateKey&&(a=", Private Key"),d==xxTlsCurrentCert&&(a+=", TLS cert"),c+="<divclass=itemBaronclick=showCertDetails("+d+")><divstyle=padding-top:3px><b>"+EscapeHtml(xxCertificates[d].XSubject.CN)+"</b><i>"+a+"</i></div></div>";for(d in xxCertPrivateKeys)xxCertPrivateKeys[d].XCert||
function showKeyPairDetails(a){setDialogMode(11,"Key Pair #"+a,5,function(b){2==b&&amtstack.Delete("AMT_PublicPrivateKeyPair",{InstanceID:xxCertPrivateKeys[a].InstanceID},PullCertificates,0,1)},"This is a public/private certificate key pair that does not belong to any certificates. This entry should be temporary.")}var xxCertSubjectNames={CN:"Common Name",O:"Organization",OU:"Org Unit",S:"State/Province",ST:"State/Province",L:"Locality",C:"Country",SN:"Surname",GN:"Given name"};
function showCertDetails(a){if(!xxdialogMode){var b=xxCertificates[a],c;c="<br>"+addHtmlValue("Certificate",b.X509Certificate.length+" bytes, <astyle=cursor:pointer;color:blueonclick=downloadCert("+a+")>Download</a>");c+=addHtmlValue("Trusted root",b.TrustedRootCertficate?"Yes":"No");0==b.TrustedRootCertficate&&b.XPrivateKey&&(c+=addHtmlValue("Private key","Present"));c+='<br><divstyle="border-bottom:1px solid gray"><i>Certificate Subject</i></div><br>';for(var d in b.XSubject)b.XSubject[d]&&(c+=
addHtmlValue(xxCertSubjectNames[d]?xxCertSubjectNames[d]:d,EscapeHtml(b.XSubject[d])));c+='<br><divstyle="border-bottom:1px solid gray"><i>Issuer Certificate</i></div><br>';for(d in b.XIssuer)b.XIssuer[d]&&(c+=addHtmlValue(xxCertSubjectNames[d]?xxCertSubjectNames[d]:d,EscapeHtml(b.XIssuer[d])));setDialogMode(11,"Certificate - "+EscapeHtml(b.XSubject.CN),5,function(b){2==b&&(xxCertificates[a].XPrivateKey&&amtstack.Delete("AMT_PublicPrivateKeyPair",{InstanceID:xxCertificates[a].XPrivateKey.InstanceID},
function addCertButtonOk2(a){a=a.target.result;var b=a.indexOf("-----BEGIN CERTIFICATE-----");0<b?(a=a.substring(b+27),b=a.indexOf("-----ENDCERTIFICATE-----"),0<b&&(a=a.substring(0,b)),a=a.replace(/\r\n/g,"")):a=btoa(a);1==getSelectElement("certtype").value?amtstack.AMT_PublicKeyManagementService_AddTrustedRootCertificate(a,certificateAdded):amtstack.AMT_PublicKeyManagementService_AddCertificate(a,certificateAdded)}
function issueCertButton(a){!xxdialogMode&&xxAccountAdminName&&(xxDragDropCertFiles=a,a="<inputid=certopentype=filestyle=float:right;width:230pxonchange=issueCertButtonUpdate()accept='.p12'>",xxDragDropCertFiles&&(a='<inputstyle=float:right;width:230pxreadonlydisabledvalue="'+xxDragDropCertFiles[0].name+'">'),a=""+("<divstyleheight:26px;margin-top:14px>"+a+"<divstyle=padding-top:4px>Certificate file</div></div>")+"<divstyle=height:26px;margin-top:4px><inputonkeyup=issueCertButtonUpdate()id=certopenpasstype=passwordautocomplete=offstyle=float:right;width:230px><divstyle=padding-top:4px>Certificate password</div></div>",
a+='<br><divstyle="border-bottom:1px solid gray"><i>Intel® AMT Certificate</i></div>',a+="<divstyle=height:26px;margin-top:4px><inputonkeyup=issueCertButtonUpdate()id=certcnstyle=float:right;width:230px><divstyle=padding-top:4px>Common Name</div></div>",a+="<divstyle=height:26px;margin-top:4px><inputonkeyup=issueCertButtonUpdate()id=certostyle=float:right;width:230px><divstyle=padding-top:4px>Organization</div></div>",a+="<divstyle=height:26px;margin-top:4px><inputonkeyup=issueCertButtonUpdate()id=certststyle=float:right;width:230px><divstyle=padding-top:4px>State/Province</div></div>",
a+="<divstyle=height:26px;margin-top:4px><inputonkeyup=issueCertButtonUpdate()id=certcstyle=float:right;width:230px><divstyle=padding-top:4px>Country</div></div>",a+='<div>Certificate Usages</div><ulstyle="list-style-type:none;height:100px;overflow:auto;width:100%;border: 1px solid #000;background-color:white;overflow-x:hidden;margin:0;padding:0">',a+="<li><label><inputtype=checkboxid=d11_cu4checked>TLS Server (HTTPS)</label></li>",a+="<li><label><inputtype=checkboxid=d11_cu5>TLS Client (HTTPS)</label></li>",
function issueCertButtonUpdate(){var a=getInputElement("certopen");QE("certopenpass",!a||a&&1==a.files.length);var b=!a||2>a.files.length;1==(!a||a&&a.files.length)&&""==Q("certopenpass").value&&(b=!1);if(""==getInputElement("certcn").value||""==getInputElement("certo").value||""==getInputElement("certst").value||""==getInputElement("certc").value)b=!1;QE("c37",b)}
function issueCertButtonOk(){var a=getInputElement("certopen"),b=xxDragDropCertFiles;a&&(b=a.files);b&&1==b.length?(a=new FileReader,a.onload=issueCertButtonOk2,a.readAsBinaryString(b[0])):issueCertButtonOk3(null)}function issueCertButtonOk2(a){0==amtcert_loadP12File(a.target.result,Q("certopenpass").value,issueCertButtonOk3)&&messagebox("Issue Certificate","Unable to decrypt/decode certificate.")}
function issueCertButtonOk3(a,b,c){xxCaPrivateKey=a;xxCaSubjectAttributes=b;amtstack.AMT_PublicKeyManagementService_GenerateKeyPair(0,2048,GenerateKeyPairResponse)}
function GenerateKeyPairResponse(a,b,c,d){200!=d?messagebox("Issue Certificate","Failed to generate key pair. Status: "+d):0!=c.Body.ReturnValue?messagebox("Issue Certificate","Failed to generate key pair, "+c.Body.ReturnValueStr):amtstack.Enum("AMT_PublicPrivateKeyPair",GenerateKeyPairResponse2,c.Body.KeyPair.ReferenceParameters.SelectorSet.Selector.Value)}
function GenerateKeyPairResponse2(a,b,c,d,f){if(200!=d)messagebox("Issue Certificate","Failed to generate key pair. Status: "+d);else{a=null;for(var n in c)c[n].InstanceID==f&&(a=c[n].DERKey);c={CN:getInputElement("certcn").value,O:getInputElement("certo").value,ST:getInputElement("certst").value,C:getInputElement("certc").value};f={CN:"Untrusted Root Certificate"};if(null!=xxCaPrivateKey&&xxCaSubjectAttributes)for(n in f={},xxCaSubjectAttributes)f[xxCaSubjectAttributes[n].shortName]=xxCaSubjectAttributes[n].value;
n={name:"extKeyUsage"};Q("d11_cu4").checked&&(n.serverAuth=!0);Q("d11_cu5").checked&&(n.clientAuth=!0);Q("d11_cu6").checked&&(n.emailProtection=!0);Q("d11_cu7").checked&&(n.codeSigning=!0);Q("d11_cu8").checked&&(n.timeStamping=!0);n=amtcert_signWithCaKey(a,xxCaPrivateKey,c,f,n);null==n?messagebox("Issue Certificate","Unable to sign certificate."):(n=forge.pki.certificateToPem(n).replace(/(\r\n|\n|\r)/gm,""),amtstack.AMT_PublicKeyManagementService_AddCertificate(n.substring(27,n.length-25),GenerateKeyPairResponse4))}}
function GenerateKeyPairResponse4(a,b,c,d){200!=d?messagebox("Issue Certificate","Failed to generate key pair. Status: "+d):PullCertificates()}function certificateAdded(a,b,c,d){200!=d||0!=c.Body.ReturnValue?messagebox("Add Certificate","Unable to add certificate, error "+(200!=d?d:c.Body.ReturnValueStr)):PullCertificates()}function certificateRemoved(a,b,c,d){200!=d?messagebox("Remove Certificate","Unable to remove certificate, error "+d):PullCertificates()}
function getInputElement(a){var b=document.getElementsByTagName("input");for(t=0;t<b.length;t++)if(b[t].id==a)returnb[t]}functiongetSelectElement(a){varb=document.getElementsByTagName("select");for(t=0;t<b.length;t++)if(b[t].id==a)returnb[t]}
function showSetTlsSecurityDlg(a){if(!xxdialogMode){a="<divstyle=height:26px;margin-top:4px><selectonchange=showSetTlsSecurityDlgUpdate()id=tlscertstyle=float:right;width:260px><optionvalue=-1>No Certificate, TLS Disabled</option>";for(var b in xxCertificates)0!=xxCertificates[b].TrustedRootCertficate||!xxCertificates[b].XPrivateKey||null!=xxTlsCurrentCert&&xxTlsCurrentCert!=b||(a+="<optionvalue="+b+">"+xxCertificates[b].XSubject.CN+"</option>");a+="</select><divstyle=padding-top:4px>Certificate</div></div><divstyle=height:26px;margin-top:4px><selectid=tlsremotestyle=float:right;width:260pxonchange=showSetTlsSecurityDlgUpdate()><optionvalue=0>Server-auth TLS only</option><optionvalue=1>Server-auth, non-TLS allowed</option>";
8>amtversion&&(a+="<optionvalue=2>Mutual-auth TLS only</option><optionvalue=3>Mutual-auth, non-TLS allowed</option>");a+="</select><divstyle=padding-top:4px>Security</div></div><divstyle=height:26pxid=d11rcntitle='Comma seperated list of certificate common names that will be allowed to connect remotely.'><inputid=d11_rcnstyle=float:right;width:260pxonkeyup=showSetTlsSecurityDlgUpdate()placeholder='name1, name2'><divstyle=padding-top:4px>Remote CN's</div></div>";setDialogMode(11,"TLS Settings",
3,showSetTlsSecurityDlgOk,a);if(0==xxTLSCredentialContext.length||0==xxTlsSettings[0].Enabled||0==xxTlsSettings[1].Enabled)getSelectElement("tlscert").value=-1;else for(b in a=xxTLSCredentialContext[0].ElementInContext.ReferenceParameters.SelectorSet.Selector.Value,xxCertificates)xxCertificates[b].InstanceID==a&&(getSelectElement("tlscert").value=b);b=1-("Intel(r) AMT LMS TLS Settings"==xxTlsSettings[0].InstanceID?0:1);getSelectElement("tlsremote").value=(1==xxTlsSettings[b].MutualAuthentication?
function showSetTlsSecurityDlgOk(){var a=getSelectElement("tlscert").value,b=getSelectElement("tlsremote").value,c=Clone(xxTlsSettings);setTlsSecurityPendingCalls=0;setTlsSecurityDeleteCredentialContext=null;if(-1!=a){if(0<xxTLSCredentialContext.length){vard=Clone(xxTLSCredentialContext[0]);d.ElementInContext.ReferenceParameters.SelectorSet.Selector.Value=xxCertificates[a].InstanceID;amtstack.Put("AMT_TLSCredentialContext",d,setTlsSecurityResponse,0,1)}elseamtstack.Create("AMT_TLSCredentialContext",
setTlsSecurityResponse);setTlsSecurityPendingCalls++}else 0<xxTLSCredentialContext.length&&(setTlsSecurityDeleteCredentialContext=Clone(xxTLSCredentialContext[0]));vard="Intel(r) AMT LMS TLS Settings"==xxTlsSettings[0].InstanceID?0:1,f=1-d;c[f].Enabled=-1!=a;c[f].MutualAuthentication=2<=b;c[f].AcceptNonSecureConnections=1==b%2;c[f].TrustedCN=splitDomains(Q("d11_rcn").value);c[d].Enabled=-1!=a;amtstack.Put("AMT_TLSSettingData",c[0],setTlsSecurityResponse,0,1,c[0]);amtstack.Put("AMT_TLSSettingData",
c[1],setTlsSecurityResponse,0,1,c[1]);setTlsSecurityPendingCalls+=2;statusbox("TLS Settings","Applying new security settings...")}function splitDomains(a){a=a.split(",");if(0!=a.length){for(var b in a)if(a[b]=a[b].trim(),0<=a[b].indexOf(" ")||0==a[b].length)return;if(!(4<a.length))returna}}
function setTlsSecurityResponse(a,b,c,d,f){200!=d?messagebox("","Failed to set TLS security, status = "+d):c.Body.ReturnValueStr&&!methodcheck(c)||0!=--setTlsSecurityPendingCalls||amtstack.AMT_SetupAndConfigurationService_CommitChanges(null,setTlsSecurityResponse2)}function setTlsSecurityResponse2(a,b,c,d){200!=d?messagebox("","Failed to set TLS security, status = "+d):setTimeout(setTlsSecurityResponse3,2E3)}
function setTlsSecurityResponse3(){null!=setTlsSecurityDeleteCredentialContext&&amtstack.Delete("AMT_TLSCredentialContext",setTlsSecurityDeleteCredentialContext,function(){});PullCertificates();setDialogMode()}var xxWatchdog=null;function PullWatchdog(){amtstack.BatchEnum(null,["*AMT_AgentPresenceCapabilities","AMT_AgentPresenceWatchdog","AMT_AgentPresenceWatchdogAction","AMT_StateTransitionCondition","CIM_ConcreteDependency"],PullWatchdogResponse)}
function PullWatchdogResponse(a,b,c,d){if(200==d&&200==c.AMT_AgentPresenceCapabilities.status){xxWatchdog=c;for(var f in xxWatchdog.CIM_ConcreteDependency.responses)a=xxWatchdog.CIM_ConcreteDependency.responses[f],(b=getItem(a.Antecedent.ReferenceParameters.SelectorSet.Selector,"@Name","CreationClassName"))&&"AMT_AgentPresenceWatchdog"==b.Value&&(d=getItem(a.Antecedent.ReferenceParameters.SelectorSet.Selector,"@Name","DeviceID").Value,c=getItem(a.Dependent.ReferenceParameters.SelectorSet.Selector,
"PolicyConditionName",c),a=getItem(xxWatchdog.AMT_AgentPresenceWatchdogAction.responses,"PolicyActionName",a),c.actions||(c.actions=[]),c.actions.push(a));updateWatchdog();QV("go19",!0)}}var watchdogEnabledStates="Unknown;Other;Enabled;Disabled;Shutting Down;Not Applicable;Enabled but Offline;In Test;Deferred;Quiesce;Starting".split(";"),watchdogMonitoredEntity="Unknown;Other;Operating System;Operating System Boot Process;Operating System Shutdown Process;Firmware Boot Process;BIOS Boot Process;Application;Service Processor".split(";");
function updateWatchdog(){if(null!=xxWatchdog){var a;a=""+TableStart();a+=TableEntry("Maximum Watchdogs",xxWatchdog.AMT_AgentPresenceCapabilities.response.MaxTotalAgents+" watchdogs");a+=TableEntry("Maximum Total Actions",xxWatchdog.AMT_AgentPresenceCapabilities.response.MaxTotalActions+" actions");a+=TableEnd()+"<br>";a+=TableStart2();a+="<tr><tdclass=r1style=padding-left:15px><br>Manage Intel® AMT agent presence watchdogs.<br><br>";if(null==xxWatchdog.AMT_AgentPresenceWatchdog.responses||
0==xxWatchdog.AMT_AgentPresenceWatchdog.responses.length)a+="<divstyle=padding-left:15px><i>No agent presence watchdog found.</i></div><br>";else for(var b in xxWatchdog.AMT_AgentPresenceWatchdog.responses){var c=xxWatchdog.AMT_AgentPresenceWatchdog.responses[b],d=guidToStr(rstr2hex(atob(c.DeviceID)));c.MonitoredEntityDescription&&""!=c.MonitoredEntityDescription&&(d=EscapeHtml(c.MonitoredEntityDescription));a+="<divclass=itemBaronclick=showWatchdogDetails("+b+")><inputtype=buttonstyle=float:rightvalue='Add Action...'onclick=addWatchdogAction(event,"+
b+")>";c.transitions&&(a+="<inputtype=buttonstyle=float:rightvalue='Delete Actions...'onclick=deleteWatchdogActions(event,"+b+")>");a+="<divstyle=padding-top:3px><b>"+d+"</b>, "+amtstack.WatchdogCurrentStates[c.CurrentState]+"</div>";var d="",f;for(f in c.transitions){var n=c.transitions[f];""!=d&&(d+="<br>");d+=getWatchdogTransitionStr(n.OldState)+" → "+getWatchdogTransitionStr(n.NewState);n.actions&&1==n.actions[0].EventOnTransition&&(d+=" : Event to log")}""!=d&&(a+="<divstyle=padding:12px>"+
d+"</div>");a+="</div>"}a=a+"<br>"+TableEnd(AddRefreshButton("PullWatchdog()")+AddButton("Add Watchdog...","AddWatchdog()"));a+="<br>";QH(30,a)}}function getWatchdogTransitionStr(a){if(31==a)return"Any State";var b="",c;for(c in amtstack.WatchdogCurrentStates)0!=(a&c)&&(b+=", "+amtstack.WatchdogCurrentStates[c]);return b.substring(2)}
function showWatchdogDetails(a){a=xxWatchdog.AMT_AgentPresenceWatchdog.responses[a];var b="";a.MonitoredEntityDescription&&""!=a.MonitoredEntityDescription&&(b+=addHtmlValue("Description",EscapeHtml(a.MonitoredEntityDescription)));b+=addHtmlValue("Monitored Entity",watchdogMonitoredEntity[a.MonitoredEntity]);b+=addHtmlValue("Current State",amtstack.WatchdogCurrentStates[a.CurrentState]);b+=addHtmlValue("Enabled State",watchdogEnabledStates[a.EnabledState]);b+=addHtmlValue("Startup Interval",a.StartupInterval+
function AddWatchdog(){var a;a="<divstyle=height:26px;margin-top:4px><inputid=wgnamestyle=float:right;width:240pxmaxlength=16onkeyup=AddWatchdogUpdate()><divstyle=padding-top:4px>Name</div></div>"+("<divstyle=height:26px;margin-top:4px><inputid=wgguidstyle=float:right;width:240pxmaxlength=36onkeyup=AddWatchdogUpdate()><divstyle=padding-top:4pxtitle='Generate random DeviceID'>"+addLink("DeviceID","GenerateWatchdogGuid()")+"</div></div>");a+="<divstyle=height:26px;margin-top:4px><inputid=wgstartstyle=float:right;width:240pxmaxlength=8placeholder=3600onkeyup=AddWatchdogUpdate()><divstyle=padding-top:4px>Startup (seconds)</div></div>";
function AddWatchdogUpdate(){for(var a=(""==Q("wgstart").value||0<parseInt(Q("wgstart").value))&&(""==Q("wgtimeout").value||0<parseInt(Q("wgtimeout").value)),b=0,c=Q("wgguid").value.toLowerCase(),d=0;d<c.length;d++){varf=c.charCodeAt(d);45!=f&&(48<=f&&57>=f||97<=f&&102>=f?b++:a=!1)}32!=b&&(a=!1);QE("dlgOkButton",a)}
function AddWatchdogOk(){var a=Q("wgtimeout").value,b=Q("wgstart").value;""==a&&(a=60);""==b&&(b=3600);a={CreationClassName:0,DeviceID:btoa(hex2rstr(guidToStr(Q("wgguid").value.replace(/-/g,"")).replace(/-/g,""))),StartupInterval:b,SystemCreationClassName:0,SystemName:0,TimeoutInterval:a,MonitoredEntityDescription:Q("wgname").value};amtstack.Create("AMT_AgentPresenceWatchdog",a,AddWatchdogOk2)}
function AddWatchdogOk2(a,b,c,d){200!=d?messagebox("Watchdog","Unable to add watchdog, error #"+d):PullWatchdog()}
function addWatchdogAction(a,b){var c=xxWatchdog.AMT_AgentPresenceWatchdog.responses[b],d;d="<table><tdstyle=width:180px>From<br>";for(b in amtstack.WatchdogCurrentStates)d+="<inputid=wgsa"+b+"type=checkboxonclick=addWatchdogActionUpdate()> "+amtstack.WatchdogCurrentStates[b]+"<br/>";d+="<td>To<br>";for(b in amtstack.WatchdogCurrentStates)d+="<inputid=wgsb"+b+"type=checkboxonclick=addWatchdogActionUpdate()> "+amtstack.WatchdogCurrentStates[b]+"<br/>";setDialogMode(11,"Add Watchdog Action",
3,addWatchdogActionOk,d+"</table><br>Perform Action<br><inputid=wgseventtype=checkboxcheckedonclick=addWatchdogActionUpdate()>Write to event log<br/>",c);addWatchdogActionUpdate();haltEvent(a)}function addWatchdogActionUpdate(){var a=0,b=0,c;for(c in amtstack.WatchdogCurrentStates)1==Q("wgsa"+c).checked&&(a+=parseInt(c)),1==Q("wgsb"+c).checked&&(b+=parseInt(c));QE("dlgOkButton",0<a&&0<b&&1==Q("wgsevent").checked)}
function addWatchdogActionOk(a,b){var c=0,d=0,f;for(f in amtstack.WatchdogCurrentStates)1==Q("wgsa"+f).checked&&(c+=parseInt(f)),1==Q("wgsb"+f).checked&&(d+=parseInt(f));amtstack.AMT_AgentPresenceWatchdog_AddAction(c,d,Q("wgsevent").checked,null,null,AddWatchdogActionResponse,null,0,{DeviceID:b.DeviceID})}function AddWatchdogActionResponse(a,b,c,d){200!=d?messagebox("Watchdog Action","Unable to add watchdog action, error #"+d):PullWatchdog()}
function deleteWatchdogActions(a,b){setDialogMode(11,"Delete Watchdog Actions",3,deleteWatchdogActionsOk,"Delete all actions for this watchdog?",xxWatchdog.AMT_AgentPresenceWatchdog.responses[b]);haltEvent(a)}function deleteWatchdogActionsOk(a,b){amtstack.AMT_AgentPresenceWatchdog_DeleteAllActions(deleteWatchdogActionResponse,null,0,{DeviceID:b.DeviceID})}
function deleteWatchdogActionResponse(a,b,c,d){200!=d?messagebox("Watchdog Action","Unable to remove watchdog actions, error #"+d):PullWatchdog()}
var xxSystemDefense=null,xxSystemDefenceLinkedPolicy={},xxUpdatingDefenseStats=!1,xxFilterStatistics=[{},{}],xxFilterStatisticsTimer=null,xxFilterStatisticsTimerActive=!1,xxSystemDefenceFilterEthernetTypes={2048:"All IP Packets",2054:"All ARP Packets"},xxSystemDefenceFilterIPTypes={4:"IPv4",6:"IPv6"},xxSystemDefenceFilterDesc={0:"Allow, Count",1:"Drop, Count",2:"Rate limit",3:"Allow",4:"Drop"},xxSystemDefenceFilters={HdrProtocolID:1,HdrDestAddress:2,HdrDestMask:2,HdrSrcAddress:2,HdrSrcMask:2,HdrSrcPortStart:1,
function updateSystemDefense(){if(null!=xxSystemDefense){var a="";xxSystemDefenceLinkedPolicy={};for(var b in xxSystemDefense.AMT_NetworkPortSystemDefensePolicy.responses){var c=xxSystemDefense.AMT_NetworkPortSystemDefensePolicy.responses[b],d=+getItem(c.Antecedent.ReferenceParameters.SelectorSet.Selector,"@Name","DeviceID").Value.substring(27),c=getItem(xxSystemDefense.AMT_SystemDefensePolicy.responses,"InstanceID",c.Dependent.ReferenceParameters.SelectorSet.Selector.Value);xxSystemDefenceLinkedPolicy[d]=
c}a+=TableStart();b="<i>None</i>";xxSystemDefenceLinkedPolicy[0]&&(b=xxSystemDefenceLinkedPolicy[0].PolicyName);a+=TableEntry("Default Wired Policy",addLink(b,"changeDefaultPolicy(0)"));for(b=0;2>b;b++){var c=xxFilterStatistics[b],f;for(f in c)d=c[f],d=1==d?d+" packet":d+" packets",a+=TableEntry((0==b?"Wired ":"Wireless ")+f,d)}a+=TableEnd();a=a+"<br>"+TableStart2();a+="<tr><tdclass=r1style=padding-left:15px;border:0><br>Manage Intel® AMT system defense policies.<br><br>";if(0==xxSystemDefense.AMT_SystemDefensePolicy.responses.length)a+=
"<divstyle=padding-left:15px><i>No system defense policies found.</i></div><br>";else for(b in xxSystemDefense.AMT_SystemDefensePolicy.responses)c=xxSystemDefense.AMT_SystemDefensePolicy.responses[b],d="",c.FilterCreationHandles&&(c.FilterCreationHandles=MakeToArray(c.FilterCreationHandles),d=c.FilterCreationHandles.length,d=", "+d+" filter"+(1<d?"s":"")),a+="<divclass=itemBaronclick=showPolicyDetails("+b+")><divstyle=padding-top:3px><b>"+EscapeHtml(c.PolicyName)+"</b>"+d+"</div></div>";a+="<tr><tdclass=r1style=padding-left:15px><br>Manage Intel® AMT system defense filters.<br><br>";
if(0==xxSystemDefense.AMT_Hdr8021Filter.responses.length&&0==xxSystemDefense.AMT_IPHeadersFilter.responses.length)a+="<divstyle=padding-left:15px><i>No system defense filters found.</i></div><br>";else{for(b in xxSystemDefense.AMT_Hdr8021Filter.responses)c=xxSystemDefense.AMT_Hdr8021Filter.responses[b],(d=xxSystemDefenceFilterEthernetTypes[c.HdrProtocolID8021])||(d="All Ethernet Protocol "+c.HdrProtocolID8021),d+=", "+xxSystemDefenceFilterDesc[c.FilterProfile],2==c.FilterProfile&&(d+=" at "+c.FilterProfileData+
" packet / sec"),1==c.ActionEventOnMatch&&(d+=", Event on match"),a+="<divclass=itemBaronclick=showFilterDetails(0,"+b+")><divstyle=padding-top:3px><b>"+(0==c.FilterDirection?"← ":"→ ")+EscapeHtml(c.Name)+"</b>, "+d+"</div></div>";for(b in xxSystemDefense.AMT_IPHeadersFilter.responses){c=xxSystemDefense.AMT_IPHeadersFilter.responses[b];(d=xxSystemDefenceFilterIPTypes[c.HdrIPVersion])||(d="All Ethernet Protocol "+c.HdrIPVersion);d+=", "+xxSystemDefenceFilterDesc[c.FilterProfile];2==
c.FilterProfile&&(d+=" at "+c.FilterProfileData+" packet / sec");1==c.ActionEventOnMatch&&(d+=", Event on match");var n=0;for(f in xxSystemDefenceFilters)c[f]&&n++;0<n&&(d+=","+n+"filter"+(1<n?"s":""));a+="<divclass=itemBaronclick=showFilterDetails(1,"+b+")><divstyle=padding-top:3px><b>"+(0==c.FilterDirection?"← ":"→ ")+EscapeHtml(c.Name)+"</b>, "+d+"</div></div>"}}a+="<br><tdclass=r1>"+TableEnd(AddRefreshButton("PullSystemDefense()")+AddButton("Add Filter...","AddDefenseFilter()")+
function UpdateDefenseStats(a){if(a||1!=xxFilterStatisticsTimerActive)xxFilterStatisticsTimerActive=!0,a=a?a:0,xxSystemDefenceLinkedPolicy[a]?amtstack.AMT_SystemDefensePolicy_UpdateStatistics('<a:Address></a:Address><a:ReferenceParameters><w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_EthernetPort</w:ResourceURI><w:SelectorSet><w:SelectorName="DeviceID">Intel(r) AMT Ethernet Port '+a+"</w:Selector></w:SelectorSet></a:ReferenceParameters>",!1,UpdateDefenseStats2,a,0,{InstanceID:xxSystemDefenceLinkedPolicy[a].InstanceID}):
function UpdateDefenseStats3(a,b,c,d,f){a=0;if(200==d){xxFilterStatistics[f]={};for(var n in c)d=c[n].ReadCount,b=getItem(c[n].Dependent.ReferenceParameters.SelectorSet.Selector[1].Value.EndpointReference.ReferenceParameters.SelectorSet.Selector,"@Name","Name").Value,xxFilterStatistics[f][b]=d,a++;updateSystemDefense()}xxFilterStatisticsTimerActive=!1;0==a&&StopDefenseStatsTimer()}
function changeDefaultPolicy(a){if(!xxdialogMode){var b;b="<divstyle=height:26px;margin-top:4px><selectid=policySelectionstyle=float:right;width:266px><optionvalue=-1>None";for(var c in xxSystemDefense.AMT_SystemDefensePolicy.responses)b+="<optionvalue="+c+(xxSystemDefenceLinkedPolicy[a]&&xxSystemDefense.AMT_SystemDefensePolicy.responses[c].InstanceID==xxSystemDefenceLinkedPolicy[a].InstanceID?"selected":"")+">"+xxSystemDefense.AMT_SystemDefensePolicy.responses[c].PolicyName;setDialogMode(11,
"Default System Defense Policy",3,changeDefaultPolicyOk,b+"</select><divstyle=padding-top:4px>Default Policy</div></div>",a)}}
function changeDefaultPolicyOk(a,b){var c=Q("policySelection").value,d=xxSystemDefenceLinkedPolicy[b];d&&amtstack.Delete("AMT_NetworkPortSystemDefensePolicy",'<w:SelectorSet><w:SelectorName="Antecedent"><a:EndpointReferencexmlns:b="http://schemas.xmlsoap.org/ws/2004/08/addressing"xmlns:c="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address><a:ReferenceParameters><w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_EthernetPort</w:ResourceURI><w:SelectorSet><w:SelectorName="CreationClassName">CIM_EthernetPort</w:Selector><w:SelectorName="DeviceID">Intel(r) AMT Ethernet Port '+b+
d.InstanceID+"</w:Selector></w:SelectorSet></a:ReferenceParameters></a:EndpointReference></w:Selector></w:SelectorSet>",-1==c?PullSystemDefense:function(){});0<=c&&amtstack.Create("AMT_NetworkPortSystemDefensePolicy",{Antecedent:'<Addressxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParametersxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURIxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_EthernetPort</ResourceURI><SelectorSetxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><SelectorName="DeviceID">Intel(r) AMT Ethernet Port '+
xxSystemDefense.AMT_SystemDefensePolicy.responses[c].InstanceID+"</Selector></SelectorSet></ReferenceParameters>"},changeDefaultPolicyOk2)}function changeDefaultPolicyOk2(a,b,c,d){200!=d?messagebox("Default System Defense Policy","Unable to set policy, error "+d):PullSystemDefense()}
function AddDefenseFilter(){if(!xxdialogMode){var a;a="<divstyle=height:26px;margin-top:4px><inputid=filternamestyle=float:right;width:260pxmaxlength=16onkeyup=AddDefenseFilterUpdate()><divstyle=padding-top:4px>Name</div></div><divstyle=height:26px;margin-top:4px><selectid=filtertypestyle=float:right;width:266pxonchange=AddDefenseFilterUpdate()><optionvalue=0>Ethernet IP Packet Filter<optionvalue=1>Ethernet ARP Packet Filter<optionvalue=2>IPv4 Packet Filter<optionvalue=3>IPv6 Packet Filter</select><divstyle=padding-top:4px>Type</div></div>";a+=
a+="<divstyle=height:26px;margin-top:4pxid=filterdatadiv><inputid=filterdatastyle=float:right;width:260pxmaxlength=8onkeyup=AddDefenseFilterUpdate()><divstyle=padding-top:4px>Packets / second</div></div>";a+="<divstyle=height:26px;margin-top:4px><selectid=filteractionstyle=float:right;width:266pxonchange=AddDefenseFilterUpdate()><optionvalue=false>Do Nothing<optionvalue=1>Event on match</select><divstyle=padding-top:4px>Event Log</div></div>";setDialogMode(11,"Add System Defense Filter",
function AddDefenseFilterOk(){if(1>=Q("filtertype").value){var a=0==Q("filtertype").value?2048:2054,b={"InstanceID ":0,Name:Q("filtername").value,CreationClassName:0,SystemName:0,SystemCreationClassName:0,HdrProtocolID8021:a,FilterProfile:Q("filterprofile").value,FilterDirection:Q("filterdir").value,ActionEventOnMatch:Q("filteraction").value};2==Q("filterprofile").value&&(b.FilterProfileData=Q("filterdata").value);amtstack.Create("AMT_Hdr8021Filter",b,AddDefenseFilterOk2)}else{var a=2==Q("filtertype").value?
4:6,b={"InstanceID ":0,Name:Q("filtername").value,CreationClassName:0,SystemName:0,SystemCreationClassName:0,HdrIPVersion:a,FilterProfile:Q("filterprofile").value,FilterDirection:Q("filterdir").value,ActionEventOnMatch:Q("filteraction").value},c=Q("ipfilter").value.split(","),d;for(d in c){var f=c[d].indexOf("="),n=c[d].substring(0,f),f=c[d].substring(f+1),p=xxSystemDefenceFilters[n];p||(n="Hdr"+n,p=xxSystemDefenceFilters[n]);p&&(2==p&&4==a?(f=f.split("."),4==f.length&&(b[n]=rstr2hex(String.fromCharCode(parseInt(f[0]),
function AddDefenseFilterOk2(a,b,c,d){200!=d?messagebox("Add System Defense Filter","Unable to add filter, error #"+d):PullSystemDefense()}
function showFilterDetails(a,b){if(!xxdialogMode){var c,d,f,n;0==a?(n="AMT_Hdr8021Filter",f="Ethernet Traffic",d=xxSystemDefense[n].responses[b],(c=xxSystemDefenceFilterEthernetTypes[d.HdrProtocolID8021])||(c="All Ethernet Protocol "+d.HdrProtocolID8021)):(n="AMT_IPHeadersFilter",f="IP Traffic",d=xxSystemDefense[n].responses[b],(c=xxSystemDefenceFilterIPTypes[d.HdrIPVersion])||(c="All IP Protocol "+d.HdrIPVersion));var p;p=""+addHtmlValue("Name",EscapeHtml(d.Name));p+=addHtmlValue("Type",f);p+=addHtmlValue("Matching Traffic",
c);p+=addHtmlValue("Direction",0==d.FilterDirection?"Outbound / Transmit":"Inbound / Receive");if(1==a)for(var r in xxSystemDefenceFilters)d[r]&&(c=r,f=d[r],a=xxSystemDefenceFilters[r],2==a&&4==f.length&&(f=hex2rstr(f),f=f.charCodeAt(0)+"."+f.charCodeAt(1)+"."+f.charCodeAt(2)+"."+f.charCodeAt(3)),c.startsWith("Hdr")&&(c=c.substring(3)),p+=addHtmlValue("Filter "+c,f));p+=addHtmlValue("Event on match",1==d.ActionEventOnMatch?"Yes":"No");setDialogMode(11,"Ethernet Filter #"+d.InstanceID,5,showFilterDetailsOk,
p,[n,d])}}function showFilterDetailsOk(a,b){2==a&&amtstack.Delete(b[0],b[1],deleteDefenseFilter)}function deleteDefenseFilter(a,b,c,d){200!=d?messagebox("Remove Filter","Unable to remove filter, make sure it's not in use."):PullSystemDefense()}var xxAddDefensePolicyFilters;
function AddDefensePolicy(){if(!xxdialogMode){xxAddDefensePolicyFilters=[];var a;a="<divstyle=height:26px;margin-top:4px><inputid=policynametitle='<policy name>:<policy precedence number>'style=float:right;width:260pxmaxlength=16onkeyup=AddDefensePolicyUpdate()><divstyle=padding-top:4px>Name</div></div><divstyle=height:26px;margin-top:4px><selectid=policytxtitle='Default action to take for outbound traffic'style=float:right;width:133px><optionvalue=0>Allow<optionvalue=1>Drop<optionvalue=2>Allow,Count<optionvalue=3>Drop,Count<optionvalue=4>Allow,Count,Event<optionvalue=5>Drop,Count,Event</select><selectid=policyrxstyle=float:right;width:133pxtitle='Default action to take for inbound traffic'><optionvalue=0>Allow<optionvalue=1>Drop<optionvalue=2>Allow,Count<optionvalue=3>Drop,Count<optionvalue=4>Allow,Count,Event<optionvalue=5>Drop,Count,Event</select><divstyle=padding-top:4px>Default TX / RX</div></div>";a+=
"<divid=policyFilters></div>";if(0<xxSystemDefense.AMT_Hdr8021Filter.responses.length||0<xxSystemDefense.AMT_IPHeadersFilter.responses.length){a+="<divstyle=height:26px;margin-top:4px><divstyle=float:right><selectid=xfilterstyle=width:186px>";for(var b in xxSystemDefense.AMT_Hdr8021Filter.responses){var c=xxSystemDefense.AMT_Hdr8021Filter.responses[b];a+="<optionvalue="+c.InstanceID+">"+c.Name}for(b in xxSystemDefense.AMT_IPHeadersFilter.responses)c=xxSystemDefense.AMT_IPHeadersFilter.responses[b],
a+="<optionvalue="+c.InstanceID+">"+c.Name;a+="</select><inputid=addFilterButtontype=buttonvalue=Addstyle=width:80pxonclick=addFilterButton()></div><divstyle=padding-top:4px>Add Filter</div></div>"}setDialogMode(11,"Add System Defense Policy",3,AddDefensePolicyOk,a);AddDefensePolicyUpdate()}}function addFilterButton(){0<=xxAddDefensePolicyFilters.indexOf(Q("xfilter").value)||(xxAddDefensePolicyFilters.push(Q("xfilter").value),AddDefensePolicyUpdate())}
function removeFilterButton(a){xxAddDefensePolicyFilters.splice(a,1);AddDefensePolicyUpdate()}
function AddDefensePolicyUpdate(){var a=0<Q("policyname").value.split(":")[0].length;QE("c37",a);if(0==xxAddDefensePolicyFilters.length)QH("policyFilters","<br><i>This policy contains no filters.</i><br><br>");else{var a="",b;for(b in xxAddDefensePolicyFilters)a+="<divclass=itemBarstyle=margin-right:0><divstyle=float:right>"+AddButton2("Remove","removeFilterButton("+b+")")+"</div><divstyle=padding-top:3px;max-width:260px;overflow:hidden><b>"+GetFilterById(xxAddDefensePolicyFilters[b]).Name+
"</b></div></div>";QH("policyFilters",a)}}function GetFilterById(a){for(var b in xxSystemDefense.AMT_Hdr8021Filter.responses){var c=xxSystemDefense.AMT_Hdr8021Filter.responses[b];if(c.InstanceID==a)return c}for(b in xxSystemDefense.AMT_IPHeadersFilter.responses)if(c=xxSystemDefense.AMT_IPHeadersFilter.responses[b],c.InstanceID==a)return c}
function AddDefensePolicyOk(){var a=Q("policytx").value,b=Q("policyrx").value,c=0,d=Q("policyname").value.split(":");2==d.length&&(c=parseInt(d[1]));a={"InstanceID ":0,PolicyName:d[0],PolicyPrecedence:c,TxDefaultCount:1<a,TxDefaultDrop:1==a%2,TxDefaultMatchEvent:3<a,RxDefaultCount:1<b,RxDefaultDrop:1==b%2,RxDefaultMatchEvent:3<b};0<xxAddDefensePolicyFilters.length&&(a.FilterCreationHandles=xxAddDefensePolicyFilters);amtstack.Create("AMT_SystemDefensePolicy",a,AddDefensePolicyOk2)}
function AddDefensePolicyOk2(a,b,c,d){200!=d?messagebox("Add System Defense Policy","Unable to add policy, error #"+d):PullSystemDefense()}
function showPolicyDetails(a){if(!xxdialogMode){var b=xxSystemDefense.AMT_SystemDefensePolicy.responses[a],c;c=""+addHtmlValue("Name",EscapeHtml(b.PolicyName));0!=b.PolicyPrecedence&&(c+=addHtmlValue("Precedence",b.PolicyPrecedence));var d=1==b.TxDefaultDrop?"Drop":"Allow";1==b.TxDefaultCount&&(d+=", Count");1==b.TxDefaultMatchEvent&&(d+=", Event");c+=addHtmlValue("Default TX Action",d);d=1==b.RxDefaultDrop?"Drop":"Allow";1==b.RxDefaultCount&&(d+=", Count");1==b.RxDefaultMatchEvent&&(d+=", Event");
c+=addHtmlValue("Default RX Action",d);if(b.FilterCreationHandles)for(a in b.FilterCreationHandles)c+=addHtmlValue("Filter #"+(+a+1),GetFilterById(b.FilterCreationHandles[a]).Name);setDialogMode(11,"Policy #"+b.InstanceID.substring(20),5,showPolicyDetailsOk,c,b)}}function showPolicyDetailsOk(a,b){2==a&&amtstack.Delete("AMT_SystemDefensePolicy",b,deleteDefensePolicy)}
function deleteDefensePolicy(a,b,c,d){200!=d?messagebox("Remove Policy","Unable to remove policy, make sure it's not in use."):PullSystemDefense()}var xxWireless;function PullWireless(){amtFirstPull|=2;-1!=amtwirelessif&&amtstack.BatchEnum("",["*CIM_WiFiPortCapabilities","*CIM_WiFiPort","*CIM_WiFiEndpoint","CIM_WiFiEndpointSettings"],processWireless)}function wifiRefresh(){xxdialogMode||PullWireless()}
var xxWifiState={3:"Disabled",32768:"Enabled in S0",32769:"Enabled in S0, Sx/AC"},xxRadioState={2:"On, Connected",3:"Off",6:"On, Disconnected"},xxWifiAuthenticationMethod={1:"Other",2:"Open",3:"Shared Key",4:"WPA PSK",5:"WPA IEEE 802.1x",6:"WPA2 PSK",7:"WPA2 IEEE 802.1x"},xxWifiEncryptionMethod={1:"Other",2:"WEP",3:"TKIP-RC4",4:"CCMP-AES",5:"None"};function processWireless(a,b,c,d){xxWireless=200==d?c:void 0;updateSystemStatus();showWirelessInfo()}
function showWirelessInfo(){if(xxWireless){var a,b,c="",d,f;if(xxWireless.CIM_WiFiPortCapabilities.response){f="<br><h2>Wireless Profiles</h2>"+TableStart2();f+="<tr><tdclass=r2style=padding-left:15px><br>Wireless profiles that Intel® AMT will use for network connectivity.<br><br>";for(a=c=0;256>a;a++)for(b in xxWireless.CIM_WiFiEndpointSettings.responses)d=xxWireless.CIM_WiFiEndpointSettings.responses[b],1!=d.AuthenticationMethod&&d.Priority==a&&(f+="<divclass=itemBaronclick=showWifiDetails("+
QH(20,f+"<br>")}}}function showWifiStateDlg(){if(!xxdialogMode){var a="",b;for(b in xxWifiState)a+="<inputtype=radioname=d11id=wl"+b+"value="+b+""+(xxWireless.CIM_WiFiPort.response.EnabledState==b?"checked":"")+">"+xxWifiState[b]+"<br>";setDialogMode(11,"Wireless State",3,wifiStateDlg,a)}}
function wifiStateDlg(){amtstack.CIM_WiFiPort_RequestStateChange(document.querySelector("input[name=d11]:checked").value,null,function(){amtstack.Get("CIM_WiFiPort",function(a,b,c,d){200==d&&(xxWireless.CIM_WiFiPort.response=c.Body,showWirelessInfo())})})}
function showWifiDetails(a){if(!xxdialogMode){a=xxWireless.CIM_WiFiEndpointSettings.responses[a];var b;b="<divstyle=text-align:left>"+addHtmlValue("Profile Name",EscapeHtml(a.ElementName));b+=addHtmlValue("SSID",a.SSID);b+=addHtmlValue("Authentication",xxWifiAuthenticationMethod[a.AuthenticationMethod]);b+=addHtmlValue("Encryption",xxWifiEncryptionMethod[a.EncryptionMethod]);b+=addHtmlValue("Priority",a.Priority);messagebox("Wireless Profile",b+"</div>")}}
function wifiRemoveButton(a){xxdialogMode||(QH(36,'Remove wireless profile "'+xxWireless.CIM_WiFiEndpointSettings.responses[a].ElementName+'"?'),setDialogMode(1,"Wireless Profile",3,function(){removeWifiButtonEx(a)}))}function removeWifiButtonEx(a){amtstack.Delete("CIM_WiFiEndpointSettings",{InstanceID:xxWireless.CIM_WiFiEndpointSettings.responses[a].InstanceID},removeWifiEntryResponse,0,1)}
function removeWifiEntryResponse(a,b,c,d,f){methodcheck(c)||amtstack.Enum("CIM_WiFiEndpointSettings",function(a,b,c,d){200==d&&(xxWireless.CIM_WiFiEndpointSettings.responses=c,showWirelessInfo())})}
function showWifiNewProfile(){if(!xxdialogMode){var a="";for(i=1;256>i;i++){var b=1;for(j in xxWireless.CIM_WiFiEndpointSettings.responses)xxWireless.CIM_WiFiEndpointSettings.responses[j].Priority==i&&(b=0);b&&(a+="<optionvalue="+i+">"+i)}QH("c13",a);c14.value=6;c15.value=4;c11.value=c12.value=c16.value=c17.value="";setDialogMode(12,"Add Wireless Profile",3,function(){addWifiProfile()});updateWifiDialog()}}
function addWifiProfile(){amtstack.AMT_WiFiPortConfigurationService_AddWiFiSettings({__parameterType:"reference",__resourceUri:amtstack.CompleteName("CIM_WiFiEndpoint"),Name:"WiFi Endpoint 0"},{__parameterType:"instance",__namespace:amtstack.CompleteName("CIM_WiFiEndpointSettings"),ElementName:c11.value,InstanceID:"Intel(r) AMT:WiFi Endpoint Settings "+c11.value,AuthenticationMethod:c14.value,EncryptionMethod:c15.value,SSID:c12.value,Priority:c13.value,
function updateWifiDialog(){var a=!0,b=c14.value,c=c15.value;QV(42,4>b);QV(41,3<b);QV(40,3<b);QV(43,4>b);4>b&&(3==c||4==c)&&(c15.value=2);3<b&&(2==c||5==c)&&(c15.value=3);for(vardinxxWireless.CIM_WiFiEndpointSettings.responses)xxWireless.CIM_WiFiEndpointSettings.responses[d].ElementName==c11.value&&(a=!1);QE("c37",1==a&&0<c11.value.length&&0<c12.value.length&&7<c16.value.length&&c16.value==
var DMTFCPUStatus="Unknown;Enabled;Disabled by User;Disabled By BIOS (POST Error);Idle;Other".split(";"),DMTFMemType="Unknown;Other;DRAM;Synchronous DRAM;Cache DRAM;EDO;EDRAM;VRAM;SRAM;RAM;ROM;Flash;EEPROM;FEPROM;EPROM;CDRAM;3DRAM;SDRAM;SGRAM;RDRAM;DDR;DDR-2;BRAM;FB-DIMM;DDR3;FBD2;DDR4;LPDDR;LPDDR2;LPDDR3;LPDDR4".split(";"),DMTFMemFormFactor=";Other;Unknown;SIMM;SIP;Chip;DIP;ZIP;Proprietary Card;DIMM;TSOP;Row of chips;RIMM;SODIMM;SRIMM;FB-DIM".split(";"),DMTFProcFamilly={191:"Intel® Core™ 2 Duo Processor",
192:"Intel® Core™ 2 Solo processor",193:"Intel® Core™ 2 Extreme processor",194:"Intel® Core™ 2 Quad processor",195:"Intel® Core™ 2 Extreme mobile processor",196:"Intel® Core™ 2 Duo mobile processor",197:"Intel® Core™ 2 Solo mobile processor",198:"Intel® Core™ i7 processor",199:"Dual-Core Intel® Celeron® processor"},HardwareInventory;
function processHardware(a,b,c,d){if(200==d){var f;a="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px>";HardwareInventory=c;QV("go2",!0);a+=TableEnd("<div> "+AddRefreshButton("PullHardware(1)")+AddButton("Save...","SaveHardwareLog()")+" Hardware information is gathered at system boot time.");b=c.CIM_Chassis.response;d=c.CIM_Card.response;var n=c.CIM_BIOSElement.response.SoftwareElementID;a=a+"<br><h2>Platform</h2>"+FullTable({"Computer model":b.Model,Manufacturer:b.Manufacturer,
{timeZone:"UTC"})},"");a+="<br>";for(f in c.CIM_Processor.responses)b=c.CIM_Processor.responses[f],d=c.CIM_Chip.responses[f],a+="<h2>Processor "+(parseInt(f)+1)+"</h2>",a+=FullTable({Manufacturer:trademarks(d.Manufacturer),Family:DMTFProcFamilly[b.Family],Version:trademarks(d.Version),"Maximum socket speed":b.MaxClockSpeed+" MHz",Status:DMTFCPUStatus[b.CPUStatus]},"");a+="<br>";for(f in c.CIM_PhysicalMemory.responses)b=c.CIM_PhysicalMemory.responses[f],a+="<h2>Memory Module "+(+f+1)+"</h2>",a+=FullTable({"Bank Label":b.BankLabel,
Manufacturer:b.Manufacturer,"Serial Number":b.SerialNumber,Size:parseInt(b.Capacity/1048576)+" MB","Form factor":DMTFMemFormFactor[b.FormFactor],Type:DMTFMemType[b.MemoryType],"Asset tag":b.Tag,"Part number":b.PartNumber},"");a+="<br>";for(f in c.CIM_MediaAccessDevice.responses)b=c.CIM_MediaAccessDevice.responses[f],d=c.CIM_PhysicalPackage.responses[+f+1],a+="<h2>Storage Media "+(parseInt(f)+1)+"</h2>",a+=FullTable({Model:d.Model,"Serial number":""==d.SerialNumber?"Unknown":d.SerialNumber,Size:parseInt(Math.round(1E3*
b.MaxMediaSize/1048576))+" MB"},"");a+="<br>";QH(16,a);updateSystemStatus()}}function SaveHardwareLog(){!xxdialogMode&&HardwareInventory&&SaveJsonFile("IntelAmtHardware","hardware","Intel AMT Hardware Information",HardwareInventory)}var AmtSystemPowerSchemes=null;function PullPowerPolicy(){amtstack.Enum("AMT_SystemPowerScheme",powerPolicyResponse)}function powerPolicyResponse(a,b,c,d){AmtSystemPowerSchemes=c;updateSystemStatus()}
function showPowerPolicyDlg(a){if(!xxdialogMode){for(var b="",c=0;c<AmtSystemPowerSchemes.length;c++)b+='<inputtype=radioname=powerpolicyvalue="'+AmtSystemPowerSchemes[c].InstanceID+'"'+(AmtSystemPowerSchemes[c].SchemeGUID==a?"checked":"")+">"+AmtSystemPowerSchemes[c].Description+"<br>";setDialogMode(11,"Intel® AMT Power Policy",3,showPowerPolicyDlgOk,b)}}
function showPowerPolicyDlgOk(){for(var a=null,b=0,c=document.getElementsByTagName("input");b<c.length;b++)"powerpolicy"==c[b].name&&c[b].checked&&(a=c[b].value);amtstack.AMT_SystemPowerScheme_SetPowerScheme(showPowerPolicyDlgOkDone,a)}functionshowPowerPolicyDlgOkDone(a,b,c,d){200==d&&PullSystemStatus()}varxxAccountAdminName,xxAccountRealmInfo,xxAccountEnabledInfo={},xxAccountFetch,showHiddenAccounts=!1;
function PullUserInfo(){xxAccountFetch=1;delete xxAccountAdminName;xxAccountRealmInfo={};amtstack.AMT_AuthorizationService_GetAdminAclEntry(getAdminAclEntryResponse);amtstack.AMT_AuthorizationService_EnumerateUserAclEntries(1,enumerateUserAclEntriesResponse)}function getAdminAclEntryResponse(a,b,c,d){200==d&&(xxAccountRealmInfo[-1]={AccessPermission:999,DigestUsername:c.Body.Username,Realms:null},xxAccountAdminName=c.Body.Username,updateAccounts())}
function enumerateUserAclEntriesResponse(a,b,c,d){if(200==d){methodcheck(c);QV("go11",!0);xxAccountFetch=c.Body.Handles.length;for(var f in c.Body.Handles)a=c.Body.Handles[f],amtstack.AMT_AuthorizationService_GetAclEnabledState(a,getAclEnabledStateResponse,a),amtstack.AMT_AuthorizationService_GetUserAclEntryEx(a,getUserAclEntryExResponse,a);updateAccounts()}}
function getUserAclEntryExResponse(a,b,c,d,f){xxAccountFetch--;200==d&&(c.Body.Handle=f,c.Body.Realms?Array.isArray(c.Body.Realms)||(c.Body.Realms=[c.Body.Realms]):c.Body.Realms=[],xxAccountRealmInfo[f]=c.Body,updateAccounts())}function getAclEnabledStateResponse(a,b,c,d,f){200==d&&(xxAccountEnabledInfo[f]=c.Body,updateAccounts())}function setAclEnabledStateResponse(a,b,c,d,f){errcheck(d,a)||(methodcheck(c),amtstack.AMT_AuthorizationService_GetAclEnabledState(f,getAclEnabledStateResponse,f))}
function updateAccounts(){if(!(0<xxAccountFetch)){vara=TableStart2(),a=a+"<tr><tdclass=r1style=padding-left:15px><br>Manage the Intel® AMT user accounts for this computer.<br><br>",b;for(b in xxAccountRealmInfo){var c=xxAccountRealmInfo[b],d,f=!1,n=0;c.DigestUsername?(d=c.DigestUsername,f="$"==d[0]&&"$"==d[1]):d=GetSidString(atob(c.KerberosUserSid));xxAccountEnabledInfo[b]&&"$$OsAdmin"!=d&&(n=1==xxAccountEnabledInfo[b].Enabled?1:2);if(showHiddenAccounts||!f){var p="";if(999!=c.AccessPermission){2==
n&&(p+="Disabled, ");var r=0;for(b in c.Realms)""!=amtstack.RealmNames[c.Realms[b]]&&r++;0<=c.Realms.indexOf(20)&&(p+="Auditor, ");p=0<=c.Realms.indexOf(3)?p+"Administrator":1==r?p+"1 realm":p+(r+" realms")}else p+="Administrator",c.Handle=-1;a+="<divclass=itemBaronclick=showUserDetails("+c.Handle+")><divstyle=float:right>";0<n&&xxAccountAdminName&&(a+=""+AddButton2(1==n?"Disable":"Enable","changeAccountStateButton(event,"+c.Handle+","+n+")"));!f&&xxAccountAdminName&&(a+=""+AddButton2("Edit...",
function changeAccountButton(a,b){haltEvent(a);xxdialogMode||(updateRealms(xxAccountRealmInfo[b].Realms),d2username.value=xxAccountRealmInfo[b].DigestUsername?xxAccountRealmInfo[b].DigestUsername:GetSidString(atob(xxAccountRealmInfo[b].KerberosUserSid)),d2password1.value=d2password2.value="",d2permission.value=xxAccountRealmInfo[b].AccessPermission,setDialogMode(2,"Edit Account",-1==b?3:7,function(a){changeAccountButtonEx(b,a)}),updateAccountDialog())}
function newAccountButton(){xxdialogMode||(updateRealms([]),d2username.value=d2password1.value=d2password2.value="",d2permission.value=2,setDialogMode(2,"New Account",3,function(){changeAccountButtonEx(null,1)}),updateAccountDialog())}
function changeAccountButtonEx(a,b){if(1==b){var c=[],d=d2username.value,f=d2permission.value,n=d2password1.value,p=GetSidByteArray(Q("d2username").value),r=null;if(0==d.length||n!=d2password2.value){messagebox("Account Error","Invalid Parameters");return}null==p?r=window.btoa(rstr_md5(d+":"+amtsysstate.AMT_GeneralSettings.response.DigestRealm+":"+n)):(d=null,p=btoa(p));if(-1!=a)for(var l in amtstack.RealmNames)(amtstack.RealmNames[l]||3==l)&&Q("rx"+l).checked&&c.push(l);null==a?amtstack.AMT_AuthorizationService_AddUserAclEntryEx(d,
function updateRealms(a){QV(37,null!=a);if(null!=a){var b="<li><label><inputtype=checkboxonchange=updateAccountDialog()id=rx3"+(0<=a.indexOf(3)?"checked":"")+">Administrator</label></li><hr/>",c;for(c in amtstack.RealmNames){var d="";0<=a.indexOf(parseInt(c))&&(d=" checked");amtstack.RealmNames[c]&&(b+="<li><label><inputtype=checkboxonchange=updateAccountDialog()id=rx"+c+d+">"+amtstack.RealmNames[c]+"</label></li>")}QH(38,b)}}
function updateAccountDialog(){var a=!1,b;for(b in amtstack.RealmNames)(amtstack.RealmNames[b]||3==b)&&Q("rx"+b).checked&&(a=!0);a&=0<d2username.value.length&&passwordcheck(d2password1.value)&&d2password1.value==d2password2.value;QE("c37",a)}var xxUserPermissions=["Local only","Network only","All (Local & Network)"];
function showUserDetails(a){if(!xxdialogMode){var b=xxAccountRealmInfo[a],c="<divstyle=text-align:left>",d,f=b.DigestUsername;f||(f=GetSidString(atob(b.KerberosUserSid)));c+=addHtmlValue("Name",f);xxAccountEnabledInfo[a]&&(c+=addHtmlValue("State",1==xxAccountEnabledInfo[a].Enabled?"Enabled":"Disabled"));if(f==xxAccountAdminName)c+=addHtmlValue("Permission","Administrator");else{var c=c+addHtmlValue("Permission",xxUserPermissions[b.AccessPermission]),n="";if(0<=b.Realms.indexOf(3))n="Administrator",
0<=b.Realms.indexOf(20)&&(n+=", Auditor");else for(d in xxAccountRealmInfo[a].Realms)""!=amtstack.RealmNames[b.Realms[d]]&&(0<n.length&&(n+=","),n+=amtstack.RealmNames[b.Realms[d]]);0==n.length&&(n="None");c+=addHtmlValue("Realms","")+"<b>"+n+"</b>"}messagebox("Account "+f,c+"</div>")}}
function wsmanQuery(){QH(24,"");var a=getSelectedOptions(Q(22)),b=[],c;for(c in a)""==QS("WSB-"+a[c]).display&&b.push(a[c]);0!=b.length&&(QE(23,!1),b&&0<b.length&&amtstack.BatchEnum("Browser",b,browserResponse,null,!0))}
function browserResponse(a,b,c,d){QE(23,!0);a="";for(var f in c)b=c[f],a+="<h2>"+f+"</h2><divstyle=margin-left:20px>",a=200==b.status?0==b.responses.length?a+"<br>(Empty)":a+ObjectToString(b.responses).replace(/Intel\(r\)/g,"Intel®"):a+("<br><divstyle=color:red>Error #"+b.status+"</div>"),a+="</div><br>";QH(24,a)}
function wsmanFilter(){var a=c0.value.toLowerCase(),b;for(b in AllWsman)QV("WSB-"+AllWsman[b],""==a||0<=AllWsman[b].toLowerCase().indexOf(a))}var xxRemoteAccess=null,xxEnvironementDetection=null,xxCiraServers=null,xxUserInitiatedCira=null,xxUserInitiatedEnabledState={32768:"Disabled",32769:"BIOS enabled",32770:"OS enable",32771:"BIOS & OS enabled"},xxRemoteAccessCredentiaLinks=null,xxMPSUserPass=null,xxPolicies=null;
function processRemote1(a,b,c,d){if(400!=d&&!errcheck(d,a)&&void 0!=c.AMT_UserInitiatedConnectionService&&void 0!=c.AMT_UserInitiatedConnectionService.response){QV("go17",!0);xxRemoteAccess=c;xxEnvironementDetection=c.AMT_EnvironmentDetectionSettingData.response;xxEnvironementDetection.DetectionStrings=MakeToArray(xxEnvironementDetection.DetectionStrings);xxCiraServers=c.AMT_ManagementPresenceRemoteSAP.responses;xxUserInitiatedCira=c.AMT_UserInitiatedConnectionService.response;xxRemoteAccessCredentiaLinks=
c.AMT_RemoteAccessCredentialContext.responses;xxMPSUserPass=c.AMT_MPSUsernamePassword.responses;xxPolicies={User:[],Alert:[],Periodic:[]};for(var f in c.AMT_RemoteAccessPolicyAppliesToMPS.responses)b=c.AMT_RemoteAccessPolicyAppliesToMPS.responses[f],a=getItem(xxCiraServers,"Name",getItem(b.ManagedElement.ReferenceParameters.SelectorSet.Selector,"@Name","Name").Value),b=getItem(b.PolicySet.ReferenceParameters.SelectorSet.Selector,"@Name","PolicyRuleName").Value.split(" ")[0],xxPolicies[b].push(a);
function updateRemoteAccess(){if(null!=xxEnvironementDetection){var a,b="Disabled",c=xxRemoteAccess.IPS_HTTPProxyService&&xxRemoteAccess.IPS_HTTPProxyAccessPoint;xxEnvironementDetection.DetectionStrings&&0<xxEnvironementDetection.DetectionStrings.length&&(b="Enabled, "+xxEnvironementDetection.DetectionStrings.length+"domain"+(1<xxEnvironementDetection.DetectionStrings.length?"s":""));a=""+TableStart();a+=TableEntry("Environmentdetection",addLink(b,"editEnvironmentDetection()"));a+=TableEntry("Userinitiationoptions",
", at "+f+":"+n+" daily")}a+=TableEntry("Periodic connection",addLinkConditional(b,'editMpsPolicy("Periodic")',xxAccountAdminName));a+=TableEnd();a=a+"<br>"+TableStart2();a+="<tr><tdclass=r1style=padding-left:15px><br>Manage Intel® AMT remote management servers.<br><br>";if(0==xxCiraServers.length)a+="<divstyle=padding-left:15px><br><i>No remote servers found.</i></div><br>";else for(d in xxCiraServers)b=":"+xxCiraServers[d].Port,xxCiraServers[d].CN&&(b+=", "+xxCiraServers[d].CN),a+="<divclass=itemBaronclick=showServerDetails("+
d+")><divstyle=padding-top:3px><b>"+xxCiraServers[d].AccessInfo+"</b>"+EscapeHtml(b)+"</div></div>";if(c)if(a+="<br>Manage HTTP proxies used for management connections.<br><br>",b=xxRemoteAccess.IPS_HTTPProxyAccessPoint.responses,0==b.length)a+="<divstyle=padding-left:15px><br><i>No proxies configured.</i></div><br>";else for(d in b)a+="<divclass=itemBaronclick=showProxyDetails("+d+")><divstyle=padding-top:3px><b>"+EscapeHtml(b[d].AccessInfo)+":"+b[d].Port+"</b> / "+EscapeHtml(b[d].NetworkDnsSuffix)+
function editMpsPolicy(a){var b="",c=xxEditMpsPolicyType=a;"User"==c&&(c="User Initiated");var d=getItem(xxRemoteAccess.AMT_RemoteAccessPolicyRule.responses,"PolicyRuleName",c),b=b+"<divstyle=height:26px><selectid=d2server1style=float:right;width:206pxonchange=editMpsPolicyUpdate()><optionvalue=-1>(None)",f;for(f in xxCiraServers)b+="<optionvalue="+f+""+(xxPolicies[a][0]&&xxPolicies[a][0].Name==xxCiraServers[f].Name?"selected":"")+">"+xxCiraServers[f].AccessInfo;b+="</select><div>Primary server</div></div>";
if(1<xxCiraServers.length){b+="<divstyle=height:26px><selectid=d2server2style=float:right;width:206pxonchange=editMpsPolicyUpdate()>";b+="<optionvalue=-1>(None)";for(f in xxCiraServers)b+="<optionvalue="+f+""+(xxPolicies[a][1]&&xxPolicies[a][1].Name==xxCiraServers[f].Name?"selected":"")+">"+xxCiraServers[f].AccessInfo;b+="</select><div>Secondary server</div></div>"}c=0;d&&(c=d.TunnelLifeTime);b+="<divstyle=height:26px><inputid=d2lifetimestyle=float:right;width:200pxonchange=editMpsPolicyUpdate()value="+
c+">";b+="<div>Tunnel lifetime (Seconds)</div></div>";"Periodic"==a&&(f=0,c=3600,d&&(d=atob(d.ExtendedData),f=ReadInt(d,0),c=ReadInt(d,4),1==f&&(d=ReadInt(d,8),10>d&&(d="0"+d),c+=":"+d)),b+="<divstyle=height:26px><selectid=d2ttypestyle=float:right;width:206pxonchange=editMpsPolicyUpdate()>",b+="<optionvalue=0"+(0==f?"selected":"")+">Periodic, time interval<optionvalue=1"+(1==f?"selected":"")+">Time of day, once a day",b+="</select><div>Trigger type</div></div><divstyle=height:26px><inputid=d2timerstyle=float:right;width:200pxonkeyup=editMpsPolicyUpdate()value="+
function editMpsPolicyUpdate(){var a=1>=xxCiraServers.length||-1==Q("d2server1").value||Q("d2server1").value!=Q("d2server2").value;if(1==a&&"Periodic"==xxEditMpsPolicyType&&1==Q("d2ttype").value){var b=Q("d2timer").value.split(":");if(2!=b.length)a=!1;else{var c=parseInt(b[0]),b=parseInt(b[1]);if(0>c||23<c||0>b||59<b)a=!1}}QE("c37",a);1<xxCiraServers.length&&QE("d2server2",-1!=Q("d2server1").value);"Periodic"==xxEditMpsPolicyType&&(QE("d2timer",-1!=Q("d2server1").value),QH("ttypelabel",
0==Q("d2ttype").value?"Trigger interval (Seconds)":"Time of day (HH:MM)"),QE("d2ttype",-1!=Q("d2server1").value));QE("d2lifetime",-1!=Q("d2server1").value)}function editMpsPolicyOk(){var a=xxEditMpsPolicyType;"User"==a&&(a="User Initiated");getItem(xxRemoteAccess.AMT_RemoteAccessPolicyRule.responses,"PolicyRuleName",a)?amtstack.Delete("AMT_RemoteAccessPolicyRule",{PolicyRuleName:a},editMpsPolicyOk2):editMpsPolicyOk2()}
function editMpsPolicyOk2(a,b,c,d){-1==Q("d2server1").value?PullRemoteAccess():(a=0,"Alert"==xxEditMpsPolicyType&&(a=1),"Periodic"==xxEditMpsPolicyType&&(a=2),b=null,2==a&&(b=Q("d2ttype").value,c=IntToStr(Q("d2timer").value),1==b&&(c=Q("d2timer").value.split(":"),c=IntToStr(parseInt(c[0]))+IntToStr(parseInt(c[1]))),b=btoa(IntToStr(b)+c)),c=[],0<=Q("d2server1").value&&c.push('<Addressxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</Address><ReferenceParametersxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURIxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP</ResourceURI><SelectorSetxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><SelectorName="Name">'+
function editEnvironmentDetection(a){1!=a&&(editEnvironmentDetectionTmp=xxEnvironementDetection.DetectionStrings?Clone(xxEnvironementDetection.DetectionStrings):[]);var b="";xxAccountAdminName&&(b+="Enter up to 4 intranet domain suffix. If the computer is outside these domains, Intel® AMT local ports will be closed and remote server connections will be active.<br><br>");0==editEnvironmentDetectionTmp.length&&(b+="<i>No intranet domains, Environemnt detection disabled.</i><br>");for(var c in editEnvironmentDetectionTmp)b+=
function editEnvironmentDetectionDlg2(a,b,c,d){200!=d?messagebox("Environment Detection","Failed to add server, status "+d):c.Body.ReturnValue&&0!=c.Body.ReturnValue?messagebox("Environment Detection",c.Body.ReturnValueStr.replace(/_/g," ")):PullRemoteAccess()}function edInputChg(){4>editEnvironmentDetectionTmp.length&&QE("edAdd",0<Q("edInput").value.length)}functioneditEnvironmentDetectionAdd(){editEnvironmentDetectionTmp.push(Q("edInput").value);editEnvironmentDetection(1)}
function editEnvironmentDetectionRemove(a){editEnvironmentDetectionTmp.splice(a,1);editEnvironmentDetection(1)}function editUserInitiatedCira(){if(!xxdialogMode){var a="",b;for(b in xxUserInitiatedEnabledState)a+="<inputtype=radioname=d11id=wl"+b+"value="+b+""+(xxUserInitiatedCira.EnabledState==b?"checked":"")+">"+xxUserInitiatedEnabledState[b]+"<br>";setDialogMode(11,"User Initiated Tunnel",3,editUserInitiatedCiraDlg,a)}}
function editUserInitiatedCiraDlg(){amtstack.AMT_UserInitiatedConnectionService_RequestStateChange(document.querySelector("input[name=d11]:checked").value,null,editUserInitiatedCiraDlg2)}function editUserInitiatedCiraDlg2(a,b,c,d){200==d&&amtstack.Get("AMT_UserInitiatedConnectionService",editUserInitiatedCiraDlg3,0,1)}function editUserInitiatedCiraDlg3(a,b,c,d){200==d&&(xxUserInitiatedCira=c.Body,updateRemoteAccess())}var xxShowServerDetailsHandle;
function showServerDetails(a){xxShowServerDetailsHandle=a;var b=xxCiraServers[a],c;c=""+addHtmlValue("Access Name",b.AccessInfo);b.Port&&(c+=addHtmlValue("Port",b.Port));b.CN&&(c+=addHtmlValue("Common Name",b.CN));if(b=getElementWithContextSelectorValue(xxRemoteAccessCredentiaLinks,b.Name))b=b.ElementInContext.ReferenceParameters.SelectorSet.Selector.Value,0<b.indexOf("Username")?(c+=addHtmlValue("AuthenticationType","User&Pass/Server-AuthTLS"),c+=addHtmlValue("RemoteID",getInstance(xxMPSUserPass,
b).RemoteID)):(c+=addHtmlValue("Authentication Type","Certificate / Mutual-Auth TLS"),b=getInstance(xxCertificates,b),c+=addHtmlValue("Certificate Name",parseCertName(b.Subject).CN));b=1;xxAccountAdminName&&(b=5);setDialogMode(11,"Remote Server #"+(a+1),b,showServerDetailsOk,c)}
function getElementWithContextSelectorValue(a,b){for(var c in a){a[c].ElementProvidingContext.ReferenceParameters.SelectorSet.Selector=MakeToArray(a[c].ElementProvidingContext.ReferenceParameters.SelectorSet.Selector);for(var d in a[c].ElementProvidingContext.ReferenceParameters.SelectorSet.Selector)if(a[c].ElementProvidingContext.ReferenceParameters.SelectorSet.Selector[d].Value==b)return a[c]}return null}
function showServerDetailsOk(a){2==a&&amtstack.Delete("AMT_ManagementPresenceRemoteSAP",{Name:xxCiraServers[xxShowServerDetailsHandle].Name},showServerDetailsOk2)}function showServerDetailsOk2(a,b,c,d){408==d?messagebox("Remote Server Removal","Unable to remove server, access denied."):PullRemoteAccess()}function parseCertName(a){var b={},c=a.split(","),d;for(d in c)a=c[d].indexOf("="),b[c[d].substring(0,a)]=c[d].substring(a+1);return b}
function AddRemoteAccessProxyUpdate(){var a=0!=Q("d2host").value.length&&0!=Q("d2domain").value.length;if(0==Q("d2port").value.length||65535<parseInt(Q("d2port").value))a=!1;QE("c37",a);QH("d2typespan",["","","FQDN/hostname","IPv4address","IPv6address"][Q("d2type").value])}functionAddRemoteAccessProxyOk(){amtstack.IPS_HTTPProxyService_AddProxyAccessPoint(Q("d2host").value,Q("d2type").value,parseInt(Q("d2port").value),Q("d2domain").value,AddRemoteAccessProxyOk2)}
function AddRemoteAccessProxyOk2(a,b,c,d){200!=d?messagebox("Add Proxy Server","Failed to add proxy, status "+d):0!=c.Body.ReturnValue?messagebox("Add Proxy Server",c.Body.ReturnValueStr.replace(/_/g," ")):PullRemoteAccess()}
c+="<divstyle=height:26pxid=d2ucn><inputid=d2cnstyle=float:right;width:200pxonkeyup=AddRemoteAccessServerUpdate()><div>Server Common Name</div></div>";c+="<divstyle=height:26px><selectid=d2authstyle=float:right;width:206pxonchange=AddRemoteAccessServerUpdate()>";0<a.length&&(c+="<optionvalue=1>Certificate");c+="<optionvalue=2>Username/Password</select><div>Authentication type</div></div>";c+="<spanid=d2utype>";c+="<divstyle=height:26px><inputid=d2userstyle=float:right;width:200pxonkeyup=AddRemoteAccessServerUpdate()><div>Username</div></div>";
c+="<divstyle=height:26px><inputid=d2passstyle=float:right;width:200pxonkeyup=AddRemoteAccessServerUpdate()><div>Strong Password</div></div>";c+="</span>";c+="<spanid=d2ctype>";c+="<divstyle=height:26px><selectid=d2certstyle=float:right;width:206pxonchange=AddRemoteAccessServerUpdate()>";for(b in a)c+="<optionvalue="+a[b].InstanceID.substring(34)+">"+parseCertName(a[b].Subject).CN;c+="</select><div>Certificate</div></div></span>";setDialogMode(11,"Add Remote Server",3,AddRemoteAccessServerOk,
c);AddRemoteAccessServerUpdate()}
function AddRemoteAccessServerOk(){var a,b,c,d;1==Q("d2auth").value?a='<Addressxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParametersxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURIxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate</ResourceURI><SelectorSetxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><SelectorName="InstanceID">Intel(r) AMT Certificate: Handle: '+Q("d2cert").value+
function AddRemoteAccessServerOk2(a,b,c,d){200!=d?messagebox("Add Internet Server","Failed to add server, status "+d):0!=c.Body.ReturnValue?messagebox("Add Internet Server",c.Body.ReturnValueStr.replace(/_/g," ")):PullRemoteAccess()}
function AddRemoteAccessServerUpdate(){var a=0!=Q("d2name").value.length;3==Q("d2type").value&&1==a&&(a=0!=Q("d2cn").value.length);2==Q("d2auth").value&&1==a&&(a=0!=Q("d2user").value.length&&passwordcheck(Q("d2pass").value));if(0==Q("d2port").value.length||65535<parseInt(Q("d2port").value))a=!1;if(-1!=Q("d2name").value.indexOf(":")||3==Q("d2type").value&&-1!=Q("d2cn").value.indexOf(":"))a=!1;QH("d2lname",201==Q("d2type").value?"Hostname":"IPv4Address");QV("d2utype",2==Q("d2auth").value);QV("d2ucn",
function showEditNameDlg(a){if(!xxdialogMode){var b=amtsysstate.AMT_GeneralSettings.response.HostName,c=amtsysstate.AMT_GeneralSettings.response.DomainName;null!=c&&0<c.length&&(b+="."+c);b='<br><divstyle=height:26px><inputid=d11namevalue="'+b+'"style=float:right;width:200px><div>Name & Domain</div></div>';1==a&&(a=1==amtsysstate.AMT_GeneralSettings.response.SharedFQDN,b+="<divstyle=height:26px><selectid=d11fqdnstyle=float:right;width:200px><optionvalue=true"+(a?"selected":"")+'>Shared, same as OS<optionvalue="false"'+
(a?"":"selected")+">Dedicated, different from OS</select><div>Name Sharing</div></div>");setDialogMode(11,"Computer Name",3,editNameDlgOk,b)}}function editNameDlgOk(){var a=Q("d11name").value,b=a.indexOf("."),c="";0<=b&&(c=a.substring(b+1),a=a.substring(0,b));b=Clone(amtsysstate.AMT_GeneralSettings.response);b.HostName=a;b.DomainName=c;Q("d11fqdn")&&(b.SharedFQDN=d11fqdn.value);amtstack.Put("AMT_GeneralSettings",b,function(){amtstack.Get("AMT_GeneralSettings",computerNameGet,0,1)},0,1)}
function computerNameGet(a,b,c,d){200==d&&(amtsysstate.AMT_GeneralSettings.response=c.Body,updateSystemStatus())}function showEditDnsDlg(){if(!xxdialogMode){var a=amtsysstate.AMT_GeneralSettings.response,b=0;1==a.DDNSUpdateByDHCPServerEnabled&&(b=1);1==a.DDNSUpdateEnabled&&(b=2);c24.value=b;c25.value=a.DDNSPeriodicUpdateInterval;c26.value=a.DDNSTTL;showEditDnsDlgChange();setDialogMode(23,"Dynamic DNS client",3,showEditDnsDlgOk)}}
function showEditDnsDlgOk(){var a=Clone(amtsysstate.AMT_GeneralSettings.response);a.DDNSUpdateEnabled=2==c24.value?!0:!1;a.DDNSUpdateByDHCPServerEnabled=1==c24.value?!0:!1;2==c24.value&&(a.DDNSPeriodicUpdateInterval=c25.value,a.DDNSTTL=c26.value);amtstack.Put("AMT_GeneralSettings",a,function(){amtstack.Get("AMT_GeneralSettings",computerNameGet,0,1)},0,1)}
function showEditDnsDlgChange(){QE("c25",2==c24.value);QE("c26",2==c24.value)}function showFeaturesDlg(){!xxdialogMode&&xxAccountAdminName&&(c3.checked=amtfeatures[0],c5.checked=amtfeatures[3],c6.checked=amtfeatures[2],c7.checked=amtfeatures[1],QV("c4",void 0!=amtfeatures[3]),setDialogMode(9,"Intel® AMT Features",3,featuresDlgOk))}
function featuresDlgOk(){var a=amtsysstate.AMT_RedirectionService.response;a.ListenerEnabled=c3.checked;a.EnabledState=32768+((c6.checked?1:0)+(c7.checked?2:0));amtstack.AMT_RedirectionService_RequestStateChange(a.EnabledState,function(b,c,d,f){200!=f?messagebox("Error","RedirectionService, RequestStateChange Error "+f):amtstack.CIM_KVMRedirectionSAP_RequestStateChange(c5.checked?2:3,0,function(b,c,d,f){200!=f?messagebox("Error","KVMRedirectionSAP, RequestStateChange Error "+
f):amtstack.Put("AMT_RedirectionService",a,function(a,b,c,d){200!=d?messagebox("Error","RedirectionService PUT Error "+d):(amtstack.Get("AMT_RedirectionService",featuresDlgGet1,0,1),amtstack.Get("CIM_KVMRedirectionSAP",featuresDlgGet2,0,1))},0,1)})})}function featuresDlgGet1(a,b,c,d){200==d&&(amtsysstate.AMT_RedirectionService.response=c.Body,updateSystemStatus())}function featuresDlgGet2(a,b,c,d){200==d&&(amtsysstate.CIM_KVMRedirectionSAP.response=c.Body,updateSystemStatus())}
function showConsentDlg(){if(!xxdialogMode){var a=amtsysstate.IPS_OptInService.response.OptInRequired;c8.checked=0==a;c9.checked=1==a;c10.checked=4294967295==a;setDialogMode(10,"User Consent",3,consentDlgOk)}}function consentDlgOk(){amtsysstate.IPS_OptInService.response.OptInRequired=document.querySelector("input[name=d10]:checked").value;amtstack.Put("IPS_OptInService",amtsysstate.IPS_OptInService.response,function(){amtstack.Get("IPS_OptInService",consentGet,0,1)},0,1)}
function consentGet(a,b,c,d){200==d&&PullSystemStatus()}var ipv6addrtype="Link local address;Network local address;Global address;User configured;Not allowed;DAD in progress;valid;deprecated;preferred/deprecated;expired;collision;not allowed".split(";");
function showIPv6AddrDlg(a,b){if(!xxdialogMode){var c=TableStart();t=b.split(",");for(var d=0;d<t.length;d+=3)c+=TableEntry("<b>"+t[d]+"</b><br><spanstyle=font-size:10px>"+ipv6addrtype[t[d+1]]+", "+ipv6addrtype[+t[d+2]+5]+"</span>","");setDialogMode(11,"IPv6 addresses for "+(0==a?"wired":"wireless")+" interface",1,null,c+TableEnd())}}
b&&ipv6manual;c19.value=isIpAddress(c.IPv6Address,"");c21.value=isIpAddress(c.DefaultRouter,"");c22.value=isIpAddress(c.PrimaryDNS,"");c23.value=isIpAddress(c.SecondaryDNS,"");updateIPSetupDlg();setDialogMode(21,"IPv6 support for "+(0==a?"wired":"wireless")+" interface",3,function(){showIPv6StateDlgOk(a)})}}
function showIPv6StateDlgOk(a){var b=amtsysstate.IPS_IPv6PortSettings.responses[a];0==a&&(d21o1.checked&&(b.IPv6Address=b.DefaultRouter=b.PrimaryDNS=b.SecondaryDNS="::",amtstack.Put("IPS_IPv6PortSettings",b,showIPv6StateDlgDone)),d21o2.checked&&(b.IPv6Address=c19.value,b.DefaultRouter=c21.value,b.PrimaryDNS=c22.value,b.SecondaryDNS=c23.value,amtstack.Put("IPS_IPv6PortSettings",b,showIPv6StateDlgDone)));for(var b=amtsysstate.CIM_ElementSettingData.responses,c=
function showPingActionDlg(){if(!xxdialogMode){var a=amtsysstate.AMT_GeneralSettings.response,a=(1==a.PingResponseEnabled)+((1==a.RmcpPingResponseEnabled)<<1);d20a.checked=0==a;d20b.checked=1==a;d20c.checked=2==a;d20d.checked=3==a;setDialogMode(20,"Intel®AMTPingResponse",3,showPingActionDlgOk)}}
function showPingActionDlgOk(){var a=Clone(amtsysstate.AMT_GeneralSettings.response),b=document.querySelector("input[name=d20]:checked").value;a.PingResponseEnabled=0!=(b&1);a.RmcpPingResponseEnabled=0!=(b&2);amtstack.Put("AMT_GeneralSettings",a,PullSystemStatus,0,1)}
function showIPSetupDlg(){if(!xxdialogMode){var a=amtsysstate.AMT_EthernetPortSettings.responses[0];QV(44,!0);QV(45,!0);QV("d21o0",!1);QV("d21l0",!1);QH("d21l1","Automatic configuration using DHCP server");QH("d21l2","Static configuration using IPv4 settings below");d21o1.checked=1==a.DHCPEnabled;d21o2.checked=!d21o1.checked;c19.value=isIpAddress(a.IPAddress,"");c20.value=isIpAddress(a.SubnetMask,"");c21.value=isIpAddress(a.DefaultGateway,
function powerActionResponse00(a,b,c,d){200==d?(amtPowerBootCapabilities=c.Body,QH("d5actionSelect",""),addOption("d5actionSelect","Power up",2),addOption("d5actionSelect","Power cycle",5),addOption("d5actionSelect","Power down",8),addOption("d5actionSelect","Reset",10),1==amtPowerBootCapabilities.ForceDiagnosticBoot&&(addOption("d5actionSelect","Power on to diagnostic",300),addOption("d5actionSelect","Reset to diagnostic",301)),9<amtversion&&(addOption("d5actionSelect","Soft-off",12),addOption("d5actionSelect",
"Soft-reset",14),addOption("d5actionSelect","Sleep",4),addOption("d5actionSelect","Hibernate",7)),1==amtPowerBootCapabilities.BIOSSetup&&(addOption("d5actionSelect","Power up to BIOS",100),addOption("d5actionSelect","Reset to BIOS",101)),1==amtPowerBootCapabilities.SecureErase&&(addOption("d5actionSelect","Power up to Secure Erase",104),addOption("d5actionSelect","Reset to Secure Erase",105)),addOption("d5actionSelect","Reset to PXE",400),addOption("d5actionSelect","Power on to PXE",401),addOption("d5actionSelect",
function powerActionDlgCheck(){var a=d5actionSelect.value;104==a||105==a?(a="Confirm execution of Intel® Remote Secure Erase?<br>Enter Secure Erase password if required.<br><br><divstyle=height:16px><inputtype=passwordid=rsepassmaxlength=32style=float:right;width:240px><div>Password</div></div><br><divstyle=color:red><b>WARNING:</b> This will wipe data on the remote system.</div>",rsepass=1,setDialogMode(11,"Power Actions",3,powerActionDlg,a)):powerActionDlg()}
function powerActionDlg(){var a=d5actionSelect.value;if(999==a)showAdvPowerDlg();else if(998==a)amtstack.Get("IPS_OptInService",powerActionResponse0,0,1);else{statusbox("Power Action","Checking state...");null!=rsepass&&1===rsepass&&(rsepass=Q("rsepass").value);var b=!0;6>amtversion&&(b=!1);13==currentView&&8==a&&(b=!1);13!=currentView&&10>=a&&(b=!1);b?amtstack.Get("IPS_OptInService",powerActionResponse0,0,1):amtstack.Get("AMT_BootSettingData",powerActionResponse1,0,1)}}var AvdPowerDlg;
function showAdvPowerDlg(){QV("d24dBiosPause",1==amtPowerBootCapabilities.BIOSPause);QV("d24dReflashBios",1==amtPowerBootCapabilities.BIOSReflash);QV("d24dBiosSetup",1==amtPowerBootCapabilities.BIOSSetup);QV("d24dForceProgressEvents",1==amtPowerBootCapabilities.ForcedProgressEvents);QV("d24dUseIDER",1==amtPowerBootCapabilities.IDER);QV("d24dLockKeyboard",1==amtPowerBootCapabilities.KeyboardLock);QV("d24dLockPowerButton",1==amtPowerBootCapabilities.PowerButtonLock);QV("d24dLockResetButton",1==amtPowerBootCapabilities.ResetButtonLock);
QV("d24dSerialOverLan",1==amtPowerBootCapabilities.SOL);QV("d24dSecureErase",1==amtPowerBootCapabilities.SecureErase);QV("d24dLockSleepButton",1==amtPowerBootCapabilities.SleepButtonLock);QV("d24dUserPasswordBypass",1==amtPowerBootCapabilities.UserPasswordBypass);QV("c33",1==amtPowerBootCapabilities.VerbosityQuiet);QV("c34",1==amtPowerBootCapabilities.VerbosityVerbose);QV("c35",1==amtPowerBootCapabilities.VerbosityScreenBlank);setDialogMode(24,"Custom Power Action",
function showAdvPowerDlgOk(){AvdPowerDlg={};AvdPowerDlg.Action=Q("c27").value;AvdPowerDlg.BIOSPause=Q("d24BiosPause").checked;AvdPowerDlg.BIOSSetup=Q("d24BiosSetup").checked;AvdPowerDlg.BootMediaIndex=Q("c30").value;AvdPowerDlg.FirmwareVerbosity=Q("c32").value;AvdPowerDlg.ForcedProgressEvents=Q("d24ForceProgressEvents").checked;AvdPowerDlg.IDERBootDevice=Q("c31").value;AvdPowerDlg.LockKeyboard=Q("d24LockKeyboard").checked;AvdPowerDlg.LockPowerButton=
function powerActionResponseC1(a,b,c,d){200!=d?messagebox("Power Action","Error #"+d):0!=c.Body.ReturnValue?messagebox("User Consent Error",c.Body.ReturnValueStr.replace(/_/g," ")):(d6ConsentText.value="",setDialogMode(6,"User Consent",11,powerActionSendConsent),checkConsentDisplay(),consentChanged(),amtstack.Enum("CIM_ServiceAvailableToElement",function(a,b,c,d){errcheck(d,a)||(amtsysstate.CIM_ServiceAvailableToElement.responses=c,updateSystemStatus(),2!=amtsysstate.CIM_ServiceAvailableToElement.responses[0].PowerState&&
amtstack.RequestPowerStateChange(2,function(a,b,c,d){}))}))}function powerActionSendConsent(a){0==a?amtstack.IPS_OptInService_CancelOptIn(function(){}):(statusbox("Power Action","Sending user consent..."),amtstack.IPS_OptInService_SendOptInCode(d6ConsentText.value,powerActionResponseC2,0,1))}
function powerActionResponseC2(a,b,c,d){200!=d?messagebox("Power Action","Error #"+d):0!=c.Body.ReturnValue?amtstack.Get("IPS_OptInService",powerActionResponse0,0,1):998==d5actionSelect.value?messagebox("User Consent","User consent succesful."):(statusbox("Power Action","Checking state..."),amtstack.Get("AMT_BootSettingData",powerActionResponse1,0,1))}
function powerActionResponse1(a,b,c,d){200!=d?messagebox("Power Action","Error #"+d):(a=d5actionSelect.value,c=c.Body,c.ConfigurationDataReset=!1,999==a?(c.BIOSPause=AvdPowerDlg.BIOSPause,c.BIOSSetup=AvdPowerDlg.BIOSSetup,c.BootMediaIndex=AvdPowerDlg.BootMediaIndex,c.FirmwareVerbosity=AvdPowerDlg.FirmwareVerbosity,c.ForcedProgressEvents=AvdPowerDlg.ForcedProgressEvents,c.IDERBootDevice=AvdPowerDlg.IDERBootDevice,c.LockKeyboard=AvdPowerDlg.LockKeyboard,c.LockPowerButton=AvdPowerDlg.LockPowerButton,
function powerActionResponse3x(a,b,c,d){a=d5actionSelect.value;b=null;if(999==a)0<c29.value&&(b=["ForceCD/DVDBoot","ForcePXEBoot","ForceHard-driveBoot","ForceDiagnosticBoot"][c29.value-1]);else{if(300==a||301==a)b="ForceDiagnosticBoot";if(400==a||401==a)b="ForcePXEBoot"}console.log("ChangeBootOrder:"+b);amtstack.CIM_BootConfigSetting_ChangeBootOrder(null==b?b:'<Addressxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParametersxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURIxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting</ResourceURI><SelectorSetxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><SelectorName="InstanceID">Intel(r) AMT: '+
function powerActionResponse3(a,b,c,d){console.log("powerActionResponse3("+b+","+c+","+d+")");if(!errcheck(d,a)){statusbox("Power Action","Performing power action...");a=d5actionSelect.value;if(100==a||201==a||203==a||300==a||401==a)a=2;if(101==a||200==a||202==a||301==a||400==a)a=10;104==a&&(a=2);105==a&&(a=10);999==a&&(a=AvdPowerDlg.Action);targetPowerAction=a;11==a&&(a=10);999>a?(console.log("RequestPowerStateChange("+a+")"),amtstack.RequestPowerStateChange(a,powerActionResponse4)):messagebox("Power Action",
function checkConsentDisplay(){amtstack.Get("IPS_SecIOService",checkConsentDisplayResponse1)}var xxchangeConsentDisplay=!1;
function checkConsentDisplayResponse1(a,b,c,d){200==d&&(c.Body.DefaultScreen&&(c.Body.DefaultScreen=parseInt(c.Body.DefaultScreen)),c.Body.NumberOfScreens&&(c.Body.NumberOfScreens=parseInt(c.Body.NumberOfScreens)),1==xxchangeConsentDisplay?(xxchangeConsentDisplay=!1,c.Body.DefaultScreen=d6Display.value,amtstack.Put("IPS_SecIOService",c.Body,checkConsentDisplayResponse1)):(d6Display.value=c.Body.DefaultScreen,QV("d6ThirdDisplay",2<c.Body.NumberOfScreens)))}
var xxStorage=null,xxStorageVendors=[],xxStorageApplications=[];function PullStorage(){amtFirstPull|=8;wsstack.comm.PerformAjax("",PullStorageResponse,null,0,"/amt-storage/","GET")}
function PullStorageResponse(a,b,c){0==amtstack.PendingBatchOperations&&refreshButtons(!0);if(200==b){QV("go21",!0);for(b=0;32>b;b++){do c=a.length,a=a.replace(String.fromCharCode(b),"");while(c>a.length)}try{xxStorage=JSON.parse(a)}catch(u){return}xxStorageVendors=[];xxStorageApplications=[];a=xxStorage.content;if(Array.isArray(a)){c={};for(b in a){var d=a[b].vendor?a[b].vendor:"";c[d]||(c[d]={});var f=a[b].app?a[b].app:"";c[d][f]||(c[d][f]={});a[b].name&&(c[d][f][a[b].name]=a[b])}xxStorage.content=
a=c}else{if(a["index.htm"]||a["logon.htm"])a[""]={"":{}};a["index.htm"]&&(a[""][""]["index.htm"]=a["index.htm"],delete a["index.htm"]);a["logon.htm"]&&(a[""][""]["logon.htm"]=a["logon.htm"],delete a["logon.htm"])}c=0;var d=TableStart2()+"<tr><tdclass=r1style=padding-left:15px><br>Manage Intel® AMT storage for this computer.<br><br>",n,p,f="";for(b in a){var r=0,l;for(l in a[b]){r++;var k=0,v;for(v in a[b][l]){k++;if(b!=n||l!=p)""!=f&&(d+=f,f="<br>"),n=b,p=l,f=""!=b?f+EscapeHtml(b+" / "+l):f+
function(){},null,0,"/amt-storage/"+b+"/"+l,"DELETE")}0==r&&wsstack.comm.PerformAjax("",function(){},null,0,"/amt-storage/"+b,"DELETE")}""!=f&&(d+=f);0==c&&(d+="<divstyle=padding-left:15px><br><i>No files found.</i></div><br>");d+="<br><tdclass=r1>"+TableEnd(AddRefreshButton("PullStorage()")+AddButton("Upload...","UploadToStorage()"));QH(31,d)}else QH(31,"Unable to load storage data...<br/>"+AddButton("Refresh","PullStorage()"))}
function showStorageDetails(a,b,c,d){if(!xxdialogMode){var f="",n=xxStorage.content[a][b][c];""!=a&&(f+=addHtmlValue("Vendor",a));""!=b&&(f+=addHtmlValue("Application",b));f+=addHtmlValue("Name",c);f+=addHtmlValue("Size",n.size+" bytes");n.link&&(f+=addHtmlValue("Link",n.link));setDialogMode(11,"Storage Item",5,showStorageDetailsEx,f,d)}}function showStorageDetailsEx(a,b){2==a&&wsstack.comm.PerformAjax("",storageDeleteResponse,null,0,"/amt-storage/"+b,"DELETE")}
function storageDeleteResponse(a,b){200!=b?messagebox("Storage","Unable to delete file (ERR"+b+"), check that the computer is powered on."):PullStorage()}function DownloadFromStorage(a,b,c){xxdialogMode||(haltEvent(c),wsstack.comm.PerformAjax("",DownloadFromStorageEx,b,0,"/amt-storage/"+a,"GET"))}function DownloadFromStorageEx(a,b,c){200!=b||null==a?console.log(b,"Data = null"):saveAs(data2blob(a),c)}
function OpenFromStorage(a,b){xxdialogMode||(haltEvent(b),window.open("http://"+wsstack.comm.host+":"+wsstack.comm.port+"/amt-storage/"+a,"_blank").focus())}function PushToStorage(a,b,c){var d=null;7E3<b.length&&(d=[a,b.substring(7E3)],b=b.substring(0,7E3));wsstack.comm.PerformAjax(b,PushToStorageResponse,d,0,"/amt-storage/"+a+(1==c?"?append=":""),"PUT")}
function PushToStorageResponse(a,b,c){200!=b?messagebox("Storage","Unable to push file (ERR"+b+"), check that the computer is powered on."):null!=c?PushToStorage(c[0],c[1],!0):PullStorage()}
function UploadToStorage(a,b){if(!xxdialogMode){b||(b="");var c;c="<br>Select a small file to upload to storage and enter a vendor, application and filename.<br>";c=(a?c+('<br><divstyle=height:20px><inputid=mstoragefilestyle=float:right;width:240pxreadonlydisabled=disabledvalue="'+b+'"><div>Upload file</div></div>'):c+"<br><divstyle=height:20px><inputtype=fileid=mstoragefilestyle=float:right;width:240pxonchange=SetStorageName()><div>Upload file</div></div>")+"<br><divstyle=height:16px><inputid=mstoragevendorplaceholder=Vendorlist=mstoragevendorlistmaxlength=11style=float:right;width:240px><div>Vendor name</div></div>";
c+='<br><divstyle=height:16px><inputid=mstoragelinkstyle=float:right;width:240px><divtitle="If set, creates a link to this content from the main web page">Link</div></div><br>';c+="<datalistid=mstoragevendorlist>";for(var d in xxStorageVendors)c+='<optionvalue="'+xxStorageVendors[d]+'">';c+="</datalist>";c+="<datalistid=mstorageapplicationlist>";for(d in xxStorageApplications)c+='<optionvalue="'+xxStorageApplications[d]+'">';c+='</datalist><datalistid=mstoragetypelist><optionvalue="application/octet-stream"><optionvalue="image/jpeg"><optionvalue="text/html"><optionvalue="text/plain"></datalist>';
function SetStorageName(a){a||(a=Q("mstoragefile"),a=1==a.files.length?a.files[0].name:"");a=a.split(" ").join("");var b=a.split("-");3==b.length&&12>b[0].length&&12>b[1].length&&(Q("mstoragevendor").value=b[0],Q("mstorageapplication").value=b[1],a=b[2]);a=a.split("-").join("");a.endsWith(".gz")&&(a=a.substring(0,a.length-3));a.endsWith(".htm")||a.endsWith(".html")?Q("mstoragetype").value="text/html":a.endsWith(".txt")&&(Q("mstoragetype").value="text/plain");11<a.length&&(a=a.substring(0,11));Q("mstoragefilename").value=
a}
function UploadToStorageEx2(a){var b;b=Q("mstoragevendor").value;var c=Q("mstorageapplication").value,d=Q("mstoragefilename").value;""==d&&(d="Filename");var f=Q("mstoragetype").value;""==f&&(f="application/octet-stream");var n=Q("mstoragelink").value;""!=b||""!=c||"logon.htm"!=d.toLowerCase()&&"index.htm"!=d.toLowerCase()?(""==b&&(b="Vendor"),""==c&&(c="App"),b=b+"/"+c+"/"+d):b=d.toLowerCase();c="<metadata><headers>";d=a.target.filename;d||(d=Q("mstoragefile").files[0].name);d.endsWith(".gz")&&(c+=
function _fmtinterval(a){a=a.replace("T","").substring(a.indexOf("P")+1);a=" "+a.replace("D"," days ").replace("H"," hours ").replace("M"," minutes ");a=a.replace(" 1 days "," 1 day ").replace(" 1 hours "," 1 hour ").replace(" 1 minutes "," 1 minute ");return a.substring(0,a.length-1)}function _fmttimepad(a){for(a=""+a;2>a.length;)a="0"+a;return a}var xxAlarms=null;
function PullAlarms(){var a=TableStart2()+"<tr><tdclass=r1style=padding-left:15px><br>Manage wake alarms.<br><br>";amtstack.Enum("IPS_AlarmClockOccurrence",function(b,c,d,f){if(200==f){QV("go23",!0);if(0<d.length)for(xxAlarms=d,b=0;b<d.length;b++)c="<b>"+d[b].ElementName+"</b>, wake on "+(new Date(d[b].StartTime.Datetime)).toLocaleString().replace(", "," at "),void 0!=d[b].Interval&&(c+=" and each"+_fmtinterval(d[b].Interval.Interval)),1==d[b].DeleteOnCompletion&&(c+=", delete when done"),a+="<divclass=itemBaronclick=showAlertDetails("+
b+")><divstyle=float:right>",xxAccountAdminName&&(a+=" "+AddButton2("Edit...","showAddAlarm("+b+")")),a+="</div><divstyle=padding-top:3px;width:auto;float:left;overflow-x:hidden>"+c+"</div></div>";else xxAlarms=null,a+="<divstyle=padding-left:15px><br><i>No wake alarms registered.</i></div><br>";d="<div> "+AddRefreshButton("PullAlarms()");xxAccountAdminName&&(d+=AddButton("Remove all alarms","RemoveAllAlarms()")+AddButton("Add","showAddAlarm()"));a+="<br><tdclass=r1>"+TableEnd(d+"</div>");
QH(33,a)}},null,!0)}
function prepareAlarmOccurenceTemplate(a,b,c,d,f){return'<d:AlarmTemplatexmlns:d="http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AlarmClockService"xmlns:s="http://intel.com/wbem/wscim/1/ips-schema/1/IPS_AlarmClockOccurrence"><s:InstanceID>'+a+"</s:InstanceID><s:ElementName>"+b+'</s:ElementName><s:StartTime><p:Datetimexmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+c+'</p:Datetime></s:StartTime><s:Interval><p:Intervalxmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+d+"</p:Interval></s:Interval><s:DeleteOnCompletion>"+
f+"</s:DeleteOnCompletion></d:AlarmTemplate>"}function RemoveAllAlarms(){setDialogMode(1,"Remove all wake alarms",3,RemoveAllAlarmsEx,"Confirm removal of all wake alarms?")}function RemoveAllAlarmsEx(){var a=xxAlarms.length,b;for(b in xxAlarms)amtstack.Delete("IPS_AlarmClockOccurrence",xxAlarms[b],function(b,d,f,n){0==--a&&PullAlarms()})}
function showAddAlarm(a){if(!xxdialogMode){QE("d25alarm_name",!a);if(void 0!=a){var b=xxAlarms[a],c=new Date(b.StartTime.Datetime);Q("d25alarm_name").value=b.ElementName;Q("d25alarm_sdate").value=c.getFullYear()+"-"+_fmttimepad(c.getMonth()+1)+"-"+_fmttimepad(c.getDate());Q("d25alarm_stime").value=c.getHours()+":"+_fmttimepad(c.getMinutes())+":"+_fmttimepad(c.getSeconds());if(b.Interval){var c=b.Interval.Interval.replace("P","").replace("T","").replace("D","D,").replace("H","H,").replace("M","M,").split(","),
d=[0,0,0],f;for(f in c){var n=c[f].length-1;"D"==c[f][n]&&(d[0]=parseInt(c[f].substring(0,n)));"H"==c[f][n]&&(d[1]=parseInt(c[f].substring(0,n)));"M"==c[f][n]&&(d[2]=parseInt(c[f].substring(0,n)))}Q("d25alarm_interval").value=d.join("-")}else Q("d25alarm_interval").value="";Q("d25alarm_doc").value=1==b.DeleteOnCompletion?1:0}else b=new Date,b.setDate((new Date).getDate()+1),Q("d25alarm_name").value="",Q("d25alarm_sdate").value=b.getFullYear()+"-"+_fmttimepad(b.getMonth()+1)+"-"+_fmttimepad(b.getDate()),
Q("d25alarm_stime").value=b.getHours()+":"+_fmttimepad(b.getMinutes())+":00",Q("d25alarm_interval").value="",Q("d25alarm_doc").value=0;setDialogMode(25,"Add new alarm",void 0!=a?7:3,showAddAlarmOk,"",a);alertDialogUpdate()}}function alertDialogUpdate(){var a=Q("d25alarm_interval").value.split("-").length,a=0<Q("d25alarm_name").value.length&&3==Q("d25alarm_sdate").value.split("-").length&&3==Q("d25alarm_stime").value.split(":").length&&(1==a||3==a);QE("c37",a)}
function showAddAlarmOk(a,b){if(2==a)showAlertDetailsDelete(a,b);else{var c=Q("d25alarm_name").value,d=Q("d25alarm_sdate").value.split("-"),f=Q("d25alarm_stime").value.split(":"),d=new Date(d[0],d[1],d[2],f[0],f[1],f[2],0),d=_fmttimepad(d.getUTCFullYear())+"-"+_fmttimepad(d.getUTCMonth())+"-"+_fmttimepad(d.getUTCDate())+"T"+_fmttimepad(d.getUTCHours())+":"+_fmttimepad(d.getUTCMinutes())+":"+_fmttimepad(d.getUTCSeconds())+"Z",f=Q("d25alarm_interval").value.split("-");3!=f.length&&(f=[0,0,0]);var f=
"P"+f[0]+"DT"+f[1]+"H"+f[2]+"M",n=1==Q("d25alarm_doc").value,c=prepareAlarmOccurenceTemplate(c,c,d,f,n);void 0==b?wsstack.ExecMethodXml(amtstack.CompleteName("AMT_AlarmClockService"),"AddAlarm",c,function(a,b,c,d){200!=d?messagebox("Add alarm","Failed to add alarm. Status: "+d):0!=c.Body.ReturnValue?messagebox("Add alarm","Failed to add alarm, "+c.Body.ReturnValueStr):PullAlarms()}):(c=Clone(xxAlarms[b]),c.StartTime='<p:Datetimexmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+d+"</p:Datetime>",
c.Interval='<p:Intervalxmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+f+"</p:Interval>",c.DeleteOnCompletion=n,amtstack.Put("IPS_AlarmClockOccurrence",c,function(a,b,c,d){200!=d?messagebox("Edit alarm","Failed to change alarm. Status: "+d):PullAlarms()},null,null,{InstanceID:c.InstanceID}))}}
function showAlertDetails(a){if(!xxdialogMode){var b=xxAlarms[a],c=new Date(b.StartTime.Datetime),c="<divstyle=text-align:left>"+addHtmlValue("Name",b.ElementName)+addHtmlValue("Wake time",c.toLocaleString().replace(", "," at "));void 0!=b.Interval&&(c+=addHtmlValue("Internal",_fmtinterval(b.Interval.Interval)));c+=addHtmlValue("After wake",1==b.DeleteOnCompletion?"Delete Alarm":"Keep Alarm")+"</div>";messagebox("Alarm "+b.ElementName,c);setDialogMode(11,"Alarm "+b.ElementName,5,showAlertDetailsDelete,
function script_onScriptRead(a){var b;try{b=JSON.parse(a.target.result)}catch(f){}if(20==currentView){b.scriptText&&(Q("scriptarea").value=b.scriptText);b.mescript&&(Q("compiledarea").value=rstr2hex(atob(b.mescript)));b.blocks?(script_setBuildBlocks(b.blocks),scriptViewButton(1)):(script_setBuildBlocks(),scriptViewButton(0));b.scriptBlocks?script_BlockScript=b.scriptBlocks:script_BuildingBlocks||(script_BlockScript=[]);for(var c in script_BlockScript)if(b=script_BlockScript[c],a=script_BuildingBlocks[b.xname]){a=
Clone(a);a.id=b.id;a.xname=b.xname;for(var d in a.vars)b.vars[d]&&(a.vars[d].value=b.vars[d].value);script_BlockScript[c]=a}fupdatescript();delete scriptstate;resetScriptButton()}else c={_interactive:1,_certificates:1,_mode:"Firmware"},b&&b.mescript&&(scriptstate=script_setup(atob(b.mescript),c)),scriptstate?(scriptstate.wsstack=wsstack,scriptstate.amtstack=amtstack,scriptstate.onStep=script_updateScriptState,scriptstate.onConsole=script_console,scriptstate.start(100)):messagebox("Run Script","Invalid script file.")}
function script_updateScriptState(){scriptstate&&(QV(9,0<scriptstate.state),center(),0==scriptstate.state&&(scriptstate=void0))}functionscript_console(a){0==a.indexOf("INFO:")&&(a=a.substring(6));0==a.indexOf("SUCCESS:")&&(a=a.substring(9));0==a.indexOf("ERROR:")&&(a=a.substring(7));QH(10,","+a)}functionscript_Stop(){scriptstate&&(1==scriptstate.dialog&&setDialogMode(0),scriptstate.stop(),scriptstate.state=0,script_updateScriptState())}
var script_BuildingBlocks,script_StartingBuildingBlocks,script_BlockScript=[],script_BlockScriptSelectedId=null,script_BuilderView=0,editscriptstate;
function scriptLoadStartingBlocks(){var a=new XMLHttpRequest;a.onload=function(){if(200<=a.status&&400>a.status){var b;try{b=JSON.parse(a.responseText)}catch(c){}b&&b.blocks&&(script_StartingBuildingBlocks=b.blocks,script_setBuildBlocks(script_StartingBuildingBlocks))}};a.onerror=function(){console.log("Failed to get script blocks")};a.open("GET","scriptblocks.txt",!0);a.send()}
function scriptViewButton(a){script_BuilderView=a;QV("scripteditor",0==a);QV("scriptbuilder",1==a);QV("viewEditorButton",script_BuildingBlocks&&1==a);QV("viewBuilderButton",script_BuildingBlocks&&0==a)}
function script_setBuildBlocks(a){script_BuildingBlocks=a;var b="";if(a)for(var c in a)95!=c.charCodeAt(0)&&(b+="<divid=sblock_"+c+'style=cursor:pointer;background-color:#ccc;width:auto;padding:5px;margin:2pxondblclick=script_faddblock("'+c+'")draggable=trueondragstart=script_fondragstart(event,this)ondragend=script_fondragend(event,this)title="'+a[c].desc+'"',b+=">"+a[c].name+"</div>");QH("blocks",b);script_fonfilterchanged();scriptViewButton(script_BuildingBlocks?1:0)}
function script_faddblock(a){var b=Clone(script_BuildingBlocks[a]);b.id=Math.random();b.xname=a;script_BlockScript.push(b);script_BlockScriptSelectedId=script_BlockScript.length-1;fupdatescript()}function script_feditblock(a){xxdialogMode||setDialogMode(11,"Edit "+script_BuildingBlocks[a].name,3,script_feditblockEx,"Edit this block? This operation will reset the block editor and load the block code into the code editor.",a)}
function script_feditblockEx(a,b){script_newScriptDlgOk();scriptViewButton(0);var c,d=script_BuildingBlocks[b];c=""+("##!BLOCK!##\r\n#id="+b+"\r\n#name="+d.name+"\r\n#desc="+d.desc+"\r\n##!BLOCK!##\r\n");for(var f in d.vars){var n=d.vars[f];c+="##!VAR!##\r\n#id="+f+"\r\n#name="+n.name+"\r\n#desc="+n.desc+"\r\n#type="+n.type+"\r\n";n.maxlength&&(c+="#maxlength="+n.maxlength+"\r\n");if(n.values)for(var p in n.values)c+="#values-"+p+"="+n.values[p]+"\r\n";c+="#value="+n.value+"\r\n##SWAP %%%"+f+"%%% "+
function script_fConvertScriptToJsonBlock(a){var b={};a=a.split("##!BLOCK!##\n");var c=a[1].split("\n"),d;for(d in c){var f=c[d].split("=");2==f.length&&(b[f[0].substring(1)]=f[1])}b.vars={};scriptvariables=a[2].split("##!VAR!##\n");for(d in scriptvariables){var c=scriptvariables[d].split("\n"),n={},p={},r=0,l;for(l in c)f=c[l].split("="),2==f.length&&f[1]&&f[0]&&0<f[0].length&&("#values-"==f[0].substring(0,8)?(p[f[0].substring(8)]=f[1],r++):n[f[0].substring(1)]=f[1]);n.id&&(0<r&&(n.values=p),c=n.id,
delete n.id,b.vars[c]=n)}b.code=a[3];c=b.id;delete b.id;d={};d[c]=b;return JSON.stringify(d,null," ")}function script_fonfilterchanged(){var a=Q("blockfilter").value.toLowerCase(),b;for(b in script_BuildingBlocks)95!=b.charCodeAt(0)&&QV("sblock_"+b,0<=script_BuildingBlocks[b].name.toLowerCase().indexOf(a)||0<=script_BuildingBlocks[b].desc.toLowerCase().indexOf(a))}var script_fonclickDblClickDetectIndex=null,script_fonclickDblClickDetectTime=null;
function script_fonclick(a,b){if(!xxdialogMode){script_BlockScriptSelectedId=null;b&&(b=fgetParentWithId(b),b.id.startsWith("xblock_")&&(script_BlockScriptSelectedId=b.id.substring(7)));fupdatescript();haltEvent(a);if(script_fonclickDblClickDetectIndex==script_BlockScriptSelectedId&&250>(new Date).getTime()-script_fonclickDblClickDetectTime)return script_foneditclick(script_BlockScriptSelectedId);script_fonclickDblClickDetectIndex=script_BlockScriptSelectedId;script_fonclickDblClickDetectTime=(new Date).getTime()}}
function script_fondragstart(a,b){xxdialogMode||(b=fgetParentWithId(b),b.style.opacity="0.4",a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("scriptbuilder/block",b.id))}function script_fondragend(a,b){xxdialogMode||(b=fgetParentWithId(b),b.style.opacity="1.0")}function script_fondragenter(a,b){xxdialogMode||(fgetParentWithId(b).style["border-top"]="solid 2px black")}
function script_fondragleave(a,b){if(!xxdialogMode){a=a.originalEvent||a;var c=document.elementFromPoint(a.pageX,a.pageY);b.contains(c)||(fgetParentWithId(b).style["border-top"]="none")}}
function script_fondrop(a,b){if(!xxdialogMode){b=fgetParentWithId(b);var c,d=a.dataTransfer.getData("scriptbuilder/block"),f=parseInt(b.id.substring(7));""==d?documentFileSelectHandler(a):(d.startsWith("sblock_")?(c=Clone(script_BuildingBlocks[d.substring(7)]),c.id=Math.random(),c.xname=d.substring(7)):(d=parseInt(d.substring(7)),c=script_BlockScript[d],script_BlockScript.splice(d,1),f>d&&f--),"scriptblocks"==b.id?(c&&script_BlockScript.push(c),script_BlockScriptSelectedId=script_BlockScript.length-
function script_foneditclick(a){if(!xxdialogMode){var b=script_BlockScript[a];script_BlockScriptSelectedId=a;fupdatescript();if(null!=b){var c=b.vars?7:5,d=b.desc+"<br><br>";if(b.vars)for(var f in b.vars){var n=b.vars[f].value,p="";b.vars[f].maxlength&&(p+=" maxlength="+b.vars[f].maxlength);2==b.vars[f].type&&(p+=" onkeypress='return numbersOnly(event)'");if(1==b.vars[f].type||2==b.vars[f].type)n="<inputtitle='"+b.vars[f].desc+"'id=scriptXvalue_"+f+"value='"+b.vars[f].value+"'"+p+"style=width:100%></input>";
if(3==b.vars[f].type){var n="<selecttitle='"+b.vars[f].desc+"'id=scriptXvalue_"+f+"style=width:100%;padding:0;margin:0>",r;for(r in b.vars[f].values)n+="<optionvalue="+r+(r==b.vars[f].value?"selected":"")+">"+b.vars[f].values[r]+"</option>";n+="</select>"}4==b.vars[f].type&&(n="<inputtype=passwordautocomplete=offtitle='"+b.vars[f].desc+"'id=scriptXvalue_"+f+"value='"+b.vars[f].value+"'"+p+"style=width:100%></input>");5==b.vars[f].type&&(n="");6==b.vars[f].type&&(n="<inputtype=filetitle='"+
b.vars[f].desc+"' id=scriptXvalue_"+f+" "+p+" style=width:100%></input>");d+='<tablestyle=width:100%title="'+b.vars[f].desc+'"><tdstyle=width:120px>'+b.vars[f].name+"<td><b>"+n+"</b></table>";if(5==b.vars[f].type){var d=d+("<ulid=scriptXvalue_"+f+'style="list-style-type:none;height:100px;overflow:auto;width:100%;border:1px solid #000;background-color:white;overflow-x:hidden;margin:0;padding:0">'),l;for(l in b.vars[f].values)n="",0<=b.vars[f].value.indexOf(l)&&(n=" checked"),d+="<li><label><inputtype=checkboxid=scriptXvaluex_"+
function script_foneditclickEx(a,b){if(!xxdialogMode){if(2==a)script_BlockScript.splice(b,1),script_BlockScriptSelectedId==b&&(script_BlockScriptSelectedId=null);else{var c=script_BlockScript[b];if(c.vars)for(var d in c.vars)if(5==c.vars[d].type){c.vars[d].value=[];for(var f in c.vars[d].values)Q("scriptXvaluex_"+d+"-"+f).checked&&c.vars[d].value.push(f)}else if(6==c.vars[d].type){var n=Q("scriptXvalue_"+d);if(1==n.files.length){var p=new FileReader;p.onload=function(a){c.vars[d].value=btoa(a.target.result);
function fupdatescript(){var a="",b;for(b in script_BlockScript){a+="<divid=xblock_"+b+"style=cursor:pointer;min-height:24px;background-color:#"+(script_BlockScriptSelectedId==b?"aaa":"ccc")+';width:auto;padding:5px;margin:2pxdraggable=trueonclick=script_fonclick(event,this)ondragenter=script_fondragenter(event,this)ondragleave=script_fondragleave(event,this)ondragstart=script_fondragstart(event,this)ondragend=script_fondragend(event,this)ondrop=script_fondrop(event,this)title="'+script_BlockScript[b].desc+
'"';a+="><inputstyle=float:righttype=buttonvalue=Edit...onclick=script_foneditclick("+b+")><divstyle=font-size:16px><b>"+script_BlockScript[b].name+"</b>";if(script_BlockScript[b].vars){var c=0,a=a+"<tableclass='scriptBlockVar us'cellpadding=0cellspacing=0style=width:100%;border-radius:5px;margin-top:8px>",d;for(d in script_BlockScript[b].vars){var f=script_BlockScript[b].vars[d].value;4==script_BlockScript[b].vars[d].type&&0<script_BlockScript[b].vars[d].value.length&&(f="*****");3==script_BlockScript[b].vars[d].type&&
"</div></div>"}""==a&&(a='<divstyle="padding:15px;color:gray">Start your script by drag & dropping blocks from the left side into this scripting box.<div>');QH("scriptblocks",a+"<divstyle=height:80px></div>");for(b in script_BlockScript)QS("xblock_"+b).borderLeft=script_CurrentHighlightBlock==b?"3px solid black":"";script_blocksToScript()}
function script_blocksToScript(){var a="";if(script_BuildingBlocks){script_BuildingBlocks._start&&(a+="##### Starting Block #####\r\n"+script_BuildingBlocks._start.code+"\r\n\r\n");for(var b in script_BlockScript){var c=script_BlockScript[b].code,c=c.split("%%%~%%%").join(b),d;for(d in script_BlockScript[b].vars)c=c.split("%%%"+d+"%%%").join(script_BlockScript[b].vars[d].value);a+="##### Block: "+script_BlockScript[b].name+" #####\r\nHighlightBlock __t "+b+"\r\n"+c+"\r\n\r\n"}script_BuildingBlocks._end&&
(a+="##### Ending Block #####\r\n"+script_BuildingBlocks._end.code+"\r\nHighlightBlock\r\n")}Q("scriptarea").value=a}var script_CurrentHighlightBlock;function script_HighlightBlock(a,b){if(a==editscriptstate){script_CurrentHighlightBlock=b;for(var c in script_BlockScript)QS("xblock_"+c).borderLeft=script_CurrentHighlightBlock==c?"3px solid black":""}}function script_newScriptDlg(){xxdialogMode||setDialogMode(11,"New Script",3,script_newScriptDlgOk,"<br>Reset & clear the script editor?")}
function script_newScriptDlgOk(){script_setBuildBlocks(script_StartingBuildingBlocks);script_BlockScript=[];script_BlockScriptSelectedId=null;delete editscriptstate;scriptViewButton(script_BuildingBlocks?1:0);QH("variables","");Q("scriptarea").value="";resetScriptButton()}
function resetScriptButton(){breakScriptButton();Q("compiledarea").value=rstr2hex(script_compile(Q("scriptarea").value,function(a){messagebox("Script Compile Error",a)}));delete editscriptstate;Q("console").value="";QH("variables","");QH("EditScriptStatus","Stopped");1==script_BuilderView&&fupdatescript();0!=Q("compiledarea").value.length&&(editscriptstate=script_setup(hex2rstr(Q("compiledarea").value),{_interactive:1,_certificates:1,_mode:"Firmware"}),editscriptstate.wsstack=wsstack,editscriptstate.amtstack=
function editscript_console(a){Q("console").value+=a+"\n"}var script_states=["Stopped","Running","Paused"];
function editscript_updateScriptState(a){var b="";if(a&&null!=a){var c=[],d;for(d in a.variables)d.startsWith("__")||c.push(d);c.sort();for(d in c)b="object"==typeof a.variables[c[d]]?b+("<b>"+c[d]+"</b> = "+ObjectToStringEx(a.variables[c[d]],2)+"<br>"):b+("<b>"+c[d]+"</b> = "+EscapeHtml(script_toString(a.variables[c[d]]))+"<br>")}QH("variables",b);b="Stopped, No Script";a&&null!=a&&(b=script_states[a.state],0<a.state&&(b+=","+a.ip+":"+script_decompile(a.script,a.ip)));50<b.length&&(b=b.substring(0,
function script_saveScript(a){xxdialogMode||scriptstate||(a&&1==a.shiftKey?(setDialogMode(11,"Script Block",1,null,"<br><textareaid=scriptSaveScriptJsonBlockstyle=width:100%;height:200px;resize:vertical/>"),QH("scriptSaveScriptJsonBlock",script_fConvertScriptToJsonBlock(Q("scriptarea").value))):setDialogMode(11,"Save Script",3,script_saveScriptOk,"<br><inputid=scriptsavenamestyle=width:100%value=test.mescript>"))}
function script_saveScriptOk(){if(!xxdialogMode){var a=JSON.stringify({scriptText:Q("scriptarea").value,mescript:btoa(script_compile(Q("scriptarea").value)),blocks:script_StartingBuildingBlocks,scriptBlocks:script_BlockScript},null," ");saveAs(data2blob(a),Q("scriptsavename").value)}}var xxdialogMode,xxdialogFunc,xxdialogButtons,xxdialogTag;
function setDialogMode(a,b,c,d,f,n){xxdialogMode=a;xxdialogFunc=d;xxdialogButtons=c;xxdialogTag=n;QE("c37",!0);QV("c37",c&1);QV("c36",c&2);QV(34,c&2);QV("c38",c&4);b&&QH(35,b);for(b=1;26>b;b++)QV("dialog"+b,b==a);QV("dialog",a);f&&(11==a?QH(39,f):QH(36,f))}function dialogclose(a){var b=xxdialogFunc,c=xxdialogButtons,d=xxdialogTag;setDialogMode();(c&8||a)&&b&&b(a,d)}
function center(){QS("dialog").left=(getDocWidth()-400)/2+"px"}function messagebox(a,b){QH(36,b);setDialogMode(1,a,1)}function statusbox(a,b){QH(36,b);setDialogMode(1,a)}
function SaveJsonFile(a,b,c,d){var f="",n={},p=new Date;amtsysstate&&(f="-"+amtsysstate.AMT_GeneralSettings.response.HostName,n={webappversion:version,description:c,hostname:amtsysstate.AMT_GeneralSettings.response.HostName,localtime:Date(),utctime:(new Date).toUTCString(),isotime:(new Date).toISOString()},HardwareInventory&&(n.systemid=guidToStr(HardwareInventory.CIM_ComputerSystemPackage.response.PlatformGUID.toLowerCase())));f+="-"+p.getFullYear()+"-"+("0"+(p.getMonth()+1)).slice(-2)+"-"+("0"+
function errcheck(a,b){if(null==wsstack||amtstack!=b)return!0;200!=a&&9!=a&&(setDialogMode(),wsstack.comm.FailAllError=999,amtstack.CancelAllQueries(999),QH(5,httpErrorTable[a]?httpErrorTable[a]:"Error #"+a),401==a&&QH(5,'Authentication Error<br/><br/><inputtype=buttonvalue="Set new credentials"onclick=meshcentral2credCallback(true)></input>'),go(100),QS(3).width=0);return 200!=a}
function goiFrame(a,b,c){if(!xxdialogMode){go(b);if(1==a.shiftKey||0==Q(13).src.endsWith(c))Q(13).src=c;QV(14,!1);QV(12,!0)}}function go(a,b){if(!xxdialogMode||1==b){QV(12,!1);QV(14,!0);QV(4,100==a);QV(6,100>a);for(var c=0;80>c;c++){QV("p"+c,c==a);var d=QS("go"+c);d&&(d["background-color"]=c==a?"#abcae1":"");d&&(d["background-color"]=c==a?"gray":"")}currentView=a}}
function portsFromHost(a,b){var c=decodeURIComponent(a).split(":"),d=0==b?16992:16993,f=0==b?16994:16995;1<c.length&&(d=parseInt(c[1]));2<c.length&&(f=parseInt(c[2]));return{host:c[0],http:d,redir:f}}functionaddLink(a,b){return"<astyle=cursor:pointer;color:blueonclick='"+b+"'>♦ "+a+"</a>"}function addLinkConditional(a,b,c){return c?addLink(a,b):a}function haltEvent(a){a.preventDefault&&a.preventDefault();a.stopPropagation&&a.stopPropagation();return!1}
function addOption(a,b,c){var d=document.createElement("option");d.text=b;d.value=c;Q(a).add(d)}function addDisabledOption(a,b,c){var d=document.createElement("option");d.text=b;d.value=c;d.disabled=1;Q(a).add(d)}function passwordcheck(a){if(8>a.length)return!1;var b=0,c=0,d=0,f=0,n;for(n in a){var p=a.charCodeAt(n);64<p&&91>p?b=1:96<p&&123>p?c=1:47<p&&58>p?d=1:f=1}return 4==b+c+d+f}
function methodcheck(a){return a&&null!=a&&a.Body&&0!=a.Body.ReturnValue?(messagebox("Call Error",a.Header.Method+": "+(a.Body.ReturnValueStr+"").replace("_"," ")),!0):!1}function TableStart(){return"<tableclass='log1 us'cellpadding=0cellspacing=0style=width:100%;border-radius:8px><tr><tdwidth=200px><p><td>"}function TableStart2(){return"<tableclass='log1 us'cellpadding=0cellspacing=0style=width:100%;border-radius:8px><tr><td><p><td>"}
function TableEntry(a,b){return"<tr><tdclass=r1><p>"+a+"<tdclass=r1>"+b}function FullTable(a,b){var c=TableStart();for(i in a)i&&a[i]&&(c+=TableEntry(i,a[i]));return c+TableEnd(b)}function TableEnd(a){return"<tr><tdcolspan=2><p>"+(a?a:"")+"</table>"}function AddButton(a,b){return"<inputtype=buttonvalue='"+a+"'onclick='"+b+"'style=margin:4px>"}function AddButton2(a,b){return"<inputtype=buttonvalue='"+a+"'onclick='"+b+"'>"}
function AddRefreshButton(a){return"<inputtype=buttonname=refreshbtnvalue=Refreshonclick='refreshButtons(false);"+a+"'style=margin:4px"+(0==refreshButtonsState?"disabled":"")+">"}function MoreStart(){return'<astyle=cursor:pointer;color:blueid=morexxx1onclick=QV("morexxx1",false);QV("morexxx2",true)>▼ More</a><divid=morexxx2style=display:none><br><hr>'}
function MoreEnd(){return'<astyle=cursor:pointer;color:blueonclick=QV("morexxx2",false);QV("morexxx1",true)>▲ Less</a></div>'}function getSelectedOptions(a){for(var b=[],c,d=0,f=a.options.length;d<f;d++)c=a.options[d],c.selected&&b.push(c.value);returnb}functiongetInstance(a,b){for(varcina)if(a[c].InstanceID==b)returna[c];returnnull}functiongetItem(a,b,c){for(vardina)if(a[d][b]==c)returna[d];returnnull}
function guidToStr(a){return a.substring(6,8)+a.substring(4,6)+a.substring(2,4)+a.substring(0,2)+"-"+a.substring(10,12)+a.substring(8,10)+"-"+a.substring(14,16)+a.substring(12,14)+"-"+a.substring(16,20)+"-"+a.substring(20)}function getUrlVars(){for(var a,b=[],c=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),d=0;d<c.length;d++)a=c[d].indexOf("="),0<a&&(b[c[d].substring(0,a)]=c[d].substring(a+1,c[d].length));returnb}
function getDocWidth(){return window.innerWidth?window.innerWidth:document.documentElement&&document.documentElement.clientWidth&&0!=document.documentElement.clientWidth?document.documentElement.clientWidth:document.getElementsByTagName("body")[0].clientWidth}
function getDocHeight(){return window.innerHeight?window.innerHeight:document.documentElement&&document.documentElement.clientHeight&&0!=document.documentElement.clientHeight?document.documentElement.clientHeight:document.getElementsByTagName("body")[0].clientHeight}function addHtmlValue(a,b){return'<divstyle=height:20px><divstyle=float:right;width:220px;overflow:hidden><btitle="'+b+'">'+b+"</b></div><div>"+a+"</div></div>"}
function addHtmlValueNoTitle(a,b){return"<divstyle=height:20px><divstyle=float:right;width:220px;overflow:hidden>"+b+"</b></div><div>"+a+"</div></div>"}function numbersOnly(a,b){return 0==event.charCode||event.charCode==b||48<=event.charCode&&57>=event.charCode}startup();