app-info-parser
Version:
Exact info from apk or ipa file.
1 lines • 459 kB
JavaScript
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).AppInfoParser=e()}}(function(){return function(){return function e(t,r,n){function i(a,s){if(!r[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[a]={exports:{}};t[a][0].call(f.exports,function(e){return i(t[a][1][e]||e)},f,f.exports,e,t,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a<n.length;a++)i(n[a]);return i}}()({1:[function(e,t,r){"use strict";function n(e){"@babel/helpers - typeof";return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}function o(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:String(t)}function a(e,t){return(a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=f(e);if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return u(this,r)}}function u(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return l(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var c=e("./zip"),h=e("./utils"),d=h.mapInfoResource,p=h.findApkIconPath,g=h.getBase64FromBuffer,y=/^androidmanifest\.xml$/,b=/^resources\.arsc$/,m=e("./xml-parser/manifest"),v=e("./resource-finder"),w=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(f,c);var t,r,n,o=s(f);function f(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,f),l(t=o.call(this,e))instanceof f?t:u(t,new f(e))}return t=f,(r=[{key:"parse",value:function(){var e=this;return new Promise(function(t,r){e.getEntries([y,b]).then(function(r){if(!r[y])throw new Error("AndroidManifest.xml can't be found.");var n,i=e._parseManifest(r[y]);if(r[b]){n=e._parseResourceMap(r[b]),i=d(i,n);var o=p(i);o?e.getEntry(o).then(function(e){i.icon=e?g(e):null,t(i)}).catch(function(e){i.icon=null,t(i),console.warn("[Warning] failed to parse icon: ",e)}):(i.icon=null,t(i))}else t(i)}).catch(function(e){r(e)})})}},{key:"_parseManifest",value:function(e){try{return new m(e,{ignore:["application.activity","application.service","application.receiver","application.provider","permission-group"]}).parse()}catch(e){throw new Error("Parse AndroidManifest.xml error: ",e)}}},{key:"_parseResourceMap",value:function(e){try{return(new v).processResourceTable(e)}catch(e){throw new Error("Parser resources.arsc error: "+e)}}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),f}();t.exports=w},{"./resource-finder":4,"./utils":5,"./xml-parser/manifest":7,"./zip":8}],2:[function(e,t,r){"use strict";function n(e){"@babel/helpers - typeof";return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}function o(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:String(t)}var a=e("./apk"),s=e("./ipa"),u=["ipa","apk"],l=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw new Error("Param miss: file(file's path in Node, instance of File or Blob in browser).");var r=(t.name||t).split("."),n=r[r.length-1].toLowerCase();if(!u.includes(n))throw new Error("Unsupported file type, only support .ipa or .apk file.");switch(this.file=t,n){case"ipa":this.parser=new s(this.file);break;case"apk":this.parser=new a(this.file)}}var t,r,n;return t=e,(r=[{key:"parse",value:function(){return this.parser.parse()}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.exports=l},{"./apk":1,"./ipa":3}],3:[function(e,t,r){"use strict";function n(e){"@babel/helpers - typeof";return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,s(n.key),n)}}function s(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:String(t)}function u(e,t){return(u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=h(e);if(t){var i=h(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}function f(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return c(e)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var d=e("plist").parse,p=e("bplist-parser").parseBuffer,g=e("cgbi-to-png"),y=e("./zip"),b=e("./utils"),m=b.findIpaIconPath,v=b.getBase64FromBuffer,w=b.isBrowser,_=new RegExp("payload/[^/]+?.app/info.plist$","i"),E=/payload\/.+?\.app\/embedded.mobileprovision/,x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(s,y);var t,r,n,o=l(s);function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),c(t=o.call(this,e))instanceof s?t:f(t,new s(e))}return t=s,(r=[{key:"parse",value:function(){var e=this;return new Promise(function(t,r){e.getEntries([_,E]).then(function(n){if(!n[_])throw new Error("Info.plist can't be found.");var o=e._parsePlist(n[_]),a=e._parseProvision(n[E]);o.mobileProvision=a;var s=new RegExp(m(o).toLowerCase());e.getEntry(s).then(function(e){try{o.icon=e?v(g.revert(e)):null}catch(t){w()?o.icon=e?v(window.btoa(String.fromCharCode.apply(String,i(e)))):null:(o.icon=null,console.warn("[Warning] failed to parse icon: ",t))}t(o)}).catch(function(e){r(e)})}).catch(function(e){r(e)})})}},{key:"_parsePlist",value:function(e){var t,r=e[0];if(60===r||"<"===r||239===r)t=d(e.toString());else{if(98!==r)throw new Error("Unknown plist buffer type.");t=p(e)[0]}return t}},{key:"_parseProvision",value:function(e){var t={};if(e){var r=e.toString("utf-8"),n=r.indexOf("<?xml"),i=r.indexOf("</plist>");(r=r.slice(n,i+8))&&(t=d(r))}return t}}])&&a(t.prototype,r),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),s}();t.exports=x},{"./utils":5,"./zip":8,"bplist-parser":18,"cgbi-to-png":28,plist:93}],4:[function(e,t,r){"use strict";var n=e("bytebuffer");function i(){this.valueStringPool=null,this.typeStringPool=null,this.keyStringPool=null,this.package_id=0,this.responseMap={},this.entryMap={}}i.readBytes=function(e,t){for(var r=new Uint8Array(t),i=0;i<t;i++)r[i]=e.readUint8();return n.wrap(r,"binary",!0)},i.prototype.processResourceTable=function(e){var t,r,i=n.wrap(e,"binary",!0),o=i.readShort(),a=i.readShort(),s=i.readInt(),u=i.readInt();if(2!=o)throw new Error("No RES_TABLE_TYPE found!");if(s!=i.limit)throw new Error("The buffer size not matches to the resource table size.");i.offset=a;for(var l=0,f=0;;){var c,h,d;try{c=i.offset,h=i.readShort(),i.readShort(),d=i.readInt()}catch(e){break}if(1==h)0==l&&(t=new n(d),i.offset=c,i.prependTo(t),(r=n.wrap(t,"binary",!0)).LE(),this.valueStringPool=this.processStringPool(r)),l++;else{if(512!=h)throw new Error("Unsupported type");t=new n(d),i.offset=c,i.prependTo(t),(r=n.wrap(t,"binary",!0)).LE(),this.processPackage(r),f++}if(i.offset=c+d,!i.remaining())break}if(1!=l)throw new Error("More than 1 string pool found!");if(f!=u)throw new Error("Real package count not equals the declared count.");return this.responseMap},i.prototype.processPackage=function(e){e.readShort();var t=e.readShort(),r=(e.readInt(),e.readInt());this.package_id=r;for(var n=0;n<256;++n)e.readUint8();var o=e.readInt(),a=(e.readInt(),e.readInt());e.readInt();if(o!=t)throw new Error("TypeStrings must immediately following the package structure header.");var s=e.offset;e.offset=o;var u=i.readBytes(e,e.limit-e.offset);e.offset=s,this.typeStringPool=this.processStringPool(u),e.offset=a;e.readShort(),e.readShort();var l=e.readInt();s=e.offset,e.offset=a;var f=i.readBytes(e,e.limit-e.offset);e.offset=s,this.keyStringPool=this.processStringPool(f);var c;for(e.offset=a+l;;){var h=e.offset;try{var d=e.readShort(),p=(e.readShort(),e.readInt())}catch(e){break}if(514==d?(e.offset=h,c=i.readBytes(e,p),this.processTypeSpec(c),0):513==d&&(e.offset=h,c=i.readBytes(e,p),this.processType(c),0),0==p)break;if(e.offset=h+p,!e.remaining())break}},i.prototype.processType=function(e){e.readShort();var t=e.readShort(),r=(e.readInt(),e.readByte()),n=(e.readByte(),e.readShort(),e.readInt()),i=e.readInt(),o={};e.readInt();if(e.offset=t,t+4*n!=i)throw new Error("HeaderSize, entryCount and entriesStart are not valid.");for(var a=new Array(n),s=0;s<n;++s)a[s]=e.readInt();for(s=0;s<n;++s)if(-1!=a[s]){var u,l,f,c,h=this.package_id<<24|r<<16|s;e.offset;try{e.readShort(),u=e.readShort(),l=e.readInt()}catch(e){break}if(0==(1&u)){e.readShort(),e.readByte(),f=e.readByte(),c=e.readInt();var d=Number(h).toString(16),p=this.keyStringPool[l],g=null;0;var y=parseInt(d,16),b=this.entryMap[y];if(null==b&&(b=[]),b.push(p),this.entryMap[y]=b,3==f)g=this.valueStringPool[c];else if(1==f){Number(c).toString(16);o[d]=c}else g=""+c;this.putIntoMap("@"+d,g)}else{e.readInt();for(var m=e.readInt(),v=0;v<m;++v){e.readInt();e.readShort(),e.readByte(),f=e.readByte(),c=e.readInt()}0}}for(var w in o){var _=this.responseMap["@"+Number(o[w]).toString(16).toUpperCase()];if(null!=_&&Object.keys(_).length<1e3)for(var E in _)this.putIntoMap("@"+w,_[E])}},i.prototype.processStringPool=function(e){e.readShort(),e.readShort(),e.readInt();for(var t,r,o=e.readInt(),a=(e.readInt(),e.readInt()),s=e.readInt(),u=(e.readInt(),0!=(256&a)),l=new Array(o),f=0;f<o;++f)l[f]=e.readInt();var c=new Array(o);for(f=0;f<o;++f){var h=s+l[f];if(e.offset=h,c[f]="",u){0!=(128&(t=e.readUint8()))&&(t=((127&t)<<8)+e.readUint8());var d=e.readUint8();if(0!=(128&d)&&(d=((127&d)<<8)+e.readUint8()),d>0){r=i.readBytes(e,d);try{c[f]=n.wrap(r,"utf8",!0).toString("utf8")}catch(e){0}}else c[f]=""}else if(0!=(32768&(t=e.readUint16()))&&(t=((32767&t)<<16)+e.readUint16()),t>0){var p=2*t;r=i.readBytes(e,p);try{c[f]=n.wrap(r,"utf8",!0).toString("utf8")}catch(e){0}}0}return c},i.prototype.processTypeSpec=function(e){e.readShort(),e.readShort(),e.readInt(),e.readByte(),e.readByte(),e.readShort();var t=e.readInt();for(var r=new Array(t),n=0;n<t;++n)r[n]=e.readInt()},i.prototype.putIntoMap=function(e,t){null==this.responseMap[e.toUpperCase()]&&(this.responseMap[e.toUpperCase()]=[]),t&&this.responseMap[e.toUpperCase()].push(t)},t.exports=i},{bytebuffer:25}],5:[function(e,t,r){(function(e){(function(){"use strict";function r(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function n(e){return"array"===r(e)}function i(e){return"object"===r(e)}function o(e){return null===e||["boolean","number","string","undefined"].includes(r(e))}t.exports={isArray:n,isObject:i,isPrimitive:o,isBrowser:function(){return void 0===e||"[object process]"!==Object.prototype.toString.call(e)},mapInfoResource:function(e,t){return r(e),e;function r(e){for(var l in e)n(e[l])?a(e[l]):i(e[l])?r(e[l]):o(e[l])&&s(e[l])&&(e[l]=t[u(e[l])])}function a(e){for(var l=e.length,f=0;f<l;f++)n(e[f])?a(e[f]):i(e[f])?r(e[f]):o(e[f])&&s(e[f])&&(e[f]=t[u(e[f])])}function s(e){return!!e&&("string"!=typeof e&&(e=e.toString()),0===e.indexOf("resourceId:"))}function u(e){return"@"+e.replace("resourceId:0x","").toUpperCase()}},findApkIconPath:function(e){if(!e.application.icon||!e.application.icon.splice)return"";var t={mdpi:48,hdpi:72,xhdpi:96,xxdpi:144,xxxhdpi:192},r={},n={dpi:120,icon:""},i=function(i){e.application.icon.some(function(e){if(e&&-1!==e.indexOf(i))return r["application-icon-"+t[i]]=e,!0}),r["application-icon-"+t[i]]&&t[i]>=n.dpi&&(n.dpi=t[i],n.icon=r["application-icon-"+t[i]])};for(var o in t)i(o);return 0!==Object.keys(r).length&&n.icon||(n.dpi=120,n.icon=e.application.icon[0]||"",r["applicataion-icon-120"]=n.icon),n.icon},findIpaIconPath:function(e){return e.CFBundleIcons&&e.CFBundleIcons.CFBundlePrimaryIcon&&e.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles&&e.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles.length?e.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles[e.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles.length-1]:e.CFBundleIconFiles&&e.CFBundleIconFiles.length?e.CFBundleIconFiles[e.CFBundleIconFiles.length-1]:".app/Icon.png"},getBase64FromBuffer:function(e){return"data:image/png;base64,"+e.toString("base64")},decodeNullUnicode:function(e){return"string"==typeof e&&(e=e.replace(/\u0000/g,"")),e}}}).call(this)}).call(this,e("_process"))},{_process:97}],6:[function(e,t,r){"use strict";function n(e){"@babel/helpers - typeof";return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}function o(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:String(t)}var a=1,s=2,u=4,l=0,f=1,c=3,h=256,d=257,p=258,g=259,y=260,b=384,m=1,v=256,w=1,_=0,E=1,x=4,T=5,k=3,N=0,S=2,I=5,A=6,D=18,L=30,O=28,M=31,U=29,C=16,B=17,R=0,P=1,j=3,F=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.buffer=t,this.cursor=0,this.strings=[],this.resources=[],this.document=null,this.parent=null,this.stack=[],this.debug=r.debug||!1}var t,r,n;return t=e,(r=[{key:"readU8",value:function(){this.debug&&console.group("readU8"),this.debug&&console.debug("cursor:",this.cursor);var e=this.buffer[this.cursor];return this.debug&&console.debug("value:",e),this.cursor+=1,this.debug&&console.groupEnd(),e}},{key:"readU16",value:function(){this.debug&&console.group("readU16"),this.debug&&console.debug("cursor:",this.cursor);var e=this.buffer.readUInt16LE(this.cursor);return this.debug&&console.debug("value:",e),this.cursor+=2,this.debug&&console.groupEnd(),e}},{key:"readS32",value:function(){this.debug&&console.group("readS32"),this.debug&&console.debug("cursor:",this.cursor);var e=this.buffer.readInt32LE(this.cursor);return this.debug&&console.debug("value:",e),this.cursor+=4,this.debug&&console.groupEnd(),e}},{key:"readU32",value:function(){this.debug&&console.group("readU32"),this.debug&&console.debug("cursor:",this.cursor);var e=this.buffer.readUInt32LE(this.cursor);return this.debug&&console.debug("value:",e),this.cursor+=4,this.debug&&console.groupEnd(),e}},{key:"readLength8",value:function(){this.debug&&console.group("readLength8");var e=this.readU8();return 128&e&&(e=(127&e)<<8,e+=this.readU8()),this.debug&&console.debug("length:",e),this.debug&&console.groupEnd(),e}},{key:"readLength16",value:function(){this.debug&&console.group("readLength16");var e=this.readU16();return 32768&e&&(e=(32767&e)<<16,e+=this.readU16()),this.debug&&console.debug("length:",e),this.debug&&console.groupEnd(),e}},{key:"readDimension",value:function(){this.debug&&console.group("readDimension");var e={value:null,unit:null,rawUnit:null},t=this.readU32(),r=255&e.value;switch(e.value=t>>8,e.rawUnit=r,r){case T:e.unit="mm";break;case N:e.unit="px";break;case w:e.unit="dp";break;case S:e.unit="sp";break;case k:e.unit="pt";break;case x:e.unit="in"}return this.debug&&console.groupEnd(),e}},{key:"readFraction",value:function(){this.debug&&console.group("readFraction");var e={value:null,type:null,rawType:null},t=this.readU32(),r=15&t;switch(e.value=this.convertIntToFloat(t>>4),e.rawType=r,r){case _:e.type="%";break;case E:e.type="%p"}return this.debug&&console.groupEnd(),e}},{key:"readHex24",value:function(){this.debug&&console.group("readHex24");var e=(16777215&this.readU32()).toString(16);return this.debug&&console.groupEnd(),e}},{key:"readHex32",value:function(){this.debug&&console.group("readHex32");var e=this.readU32().toString(16);return this.debug&&console.groupEnd(),e}},{key:"readTypedValue",value:function(){this.debug&&console.group("readTypedValue");var e={value:null,type:null,rawType:null},t=this.cursor,r=this.readU16();this.readU8();var n=this.readU8();switch(0===r&&(r=8),e.rawType=n,n){case C:e.value=this.readS32(),e.type="int_dec";break;case B:e.value=this.readS32(),e.type="int_hex";break;case j:var i=this.readS32();e.value=i>0?this.strings[i]:"",e.type="string";break;case P:var o=this.readU32();e.value="resourceId:0x".concat(o.toString(16)),e.type="reference";break;case D:e.value=0!==this.readS32(),e.type="boolean";break;case R:this.readU32(),e.value=null,e.type="null";break;case U:e.value=this.readHex24(),e.type="rgb8";break;case M:e.value=this.readHex24(),e.type="rgb4";break;case O:e.value=this.readHex32(),e.type="argb8";break;case L:e.value=this.readHex32(),e.type="argb4";break;case I:e.value=this.readDimension(),e.type="dimension";break;case A:e.value=this.readFraction(),e.type="fraction";break;default:var a=n.toString(16);console.debug("Not sure what to do with typed value of type 0x".concat(a,", falling back to reading an uint32.")),e.value=this.readU32(),e.type="unknown"}var s=t+r;if(this.cursor!==s){var u=n.toString(16),l=s-this.cursor;console.debug("Cursor is off by ".concat(l," bytes at ").concat(this.cursor," at supposed end of typed value of type 0x").concat(u,". The typed value started at offset ").concat(t," and is supposed to end at offset ").concat(s,". Ignoring the rest of the value.")),this.cursor=s}return this.debug&&console.groupEnd(),e}},{key:"convertIntToFloat",value:function(e){var t=new ArrayBuffer(4);return new Int32Array(t)[0]=e,new Float32Array(t)[0]}},{key:"readString",value:function(e){switch(this.debug&&console.group("readString",e),e){case"utf-8":var t=this.readLength8(e);this.debug&&console.debug("stringLength:",t);var r=this.readLength8(e);this.debug&&console.debug("byteLength:",r);var n=this.buffer.toString(e,this.cursor,this.cursor+=r);return this.debug&&console.debug("value:",n),this.debug&&console.groupEnd(),n;case"ucs2":return t=this.readLength16(e),this.debug&&console.debug("stringLength:",t),r=2*t,this.debug&&console.debug("byteLength:",r),n=this.buffer.toString(e,this.cursor,this.cursor+=r),this.debug&&console.debug("value:",n),this.debug&&console.groupEnd(),n;default:throw new Error("Unsupported encoding '".concat(e,"'"))}}},{key:"readChunkHeader",value:function(){this.debug&&console.group("readChunkHeader");var e={startOffset:this.cursor,chunkType:this.readU16(),headerSize:this.readU16(),chunkSize:this.readU32()};return this.debug&&console.debug("startOffset:",e.startOffset),this.debug&&console.debug("chunkType:",e.chunkType),this.debug&&console.debug("headerSize:",e.headerSize),this.debug&&console.debug("chunkSize:",e.chunkSize),this.debug&&console.groupEnd(),e}},{key:"readStringPool",value:function(e){if(this.debug&&console.group("readStringPool"),e.stringCount=this.readU32(),this.debug&&console.debug("stringCount:",e.stringCount),e.styleCount=this.readU32(),this.debug&&console.debug("styleCount:",e.styleCount),e.flags=this.readU32(),this.debug&&console.debug("flags:",e.flags),e.stringsStart=this.readU32(),this.debug&&console.debug("stringsStart:",e.stringsStart),e.stylesStart=this.readU32(),this.debug&&console.debug("stylesStart:",e.stylesStart),e.chunkType!==f)throw new Error("Invalid string pool header");for(var t=[],r=0,n=e.stringCount;r<n;++r)this.debug&&console.debug("offset:",r),t.push(this.readU32());var i=(e.flags&m)===m;this.debug&&console.debug("sorted:",i);var o=(e.flags&v)===v?"utf-8":"ucs2";this.debug&&console.debug("encoding:",o);var a=e.startOffset+e.stringsStart;this.cursor=a;for(var s=0,u=e.stringCount;s<u;++s)this.debug&&console.debug("string:",s),this.debug&&console.debug("offset:",t[s]),this.cursor=a+t[s],this.strings.push(this.readString(o));return this.cursor=e.startOffset+e.chunkSize,this.debug&&console.groupEnd(),null}},{key:"readResourceMap",value:function(e){this.debug&&console.group("readResourceMap");for(var t=Math.floor((e.chunkSize-e.headerSize)/4),r=0;r<t;++r)this.resources.push(this.readU32());return this.debug&&console.groupEnd(),null}},{key:"readXmlNamespaceStart",value:function(){return this.debug&&console.group("readXmlNamespaceStart"),this.readU32(),this.readU32(),this.readS32(),this.readS32(),this.debug&&console.groupEnd(),null}},{key:"readXmlNamespaceEnd",value:function(){return this.debug&&console.group("readXmlNamespaceEnd"),this.readU32(),this.readU32(),this.readS32(),this.readS32(),this.debug&&console.groupEnd(),null}},{key:"readXmlElementStart",value:function(){this.debug&&console.group("readXmlElementStart");var e={namespaceURI:null,nodeType:a,nodeName:null,attributes:[],childNodes:[]};this.readU32(),this.readU32();var t=this.readS32(),r=this.readS32();t>0&&(e.namespaceURI=this.strings[t]),e.nodeName=this.strings[r],this.readU16(),this.readU16();var n=this.readU16();this.readU16(),this.readU16(),this.readU16();for(var i=0;i<n;++i)e.attributes.push(this.readXmlAttribute());return this.document?(this.parent.childNodes.push(e),this.parent=e):this.document=this.parent=e,this.stack.push(e),this.debug&&console.groupEnd(),e}},{key:"readXmlAttribute",value:function(){this.debug&&console.group("readXmlAttribute");var e={namespaceURI:null,nodeType:s,nodeName:null,name:null,value:null,typedValue:null},t=this.readS32(),r=this.readS32(),n=this.readS32();return t>0&&(e.namespaceURI=this.strings[t]),e.nodeName=e.name=this.strings[r],n>0&&("versionName"===e.name&&(this.strings[n]=this.strings[n].replace(/[^\d\w-.]/g,"")),e.value=this.strings[n]),e.typedValue=this.readTypedValue(),this.debug&&console.groupEnd(),e}},{key:"readXmlElementEnd",value:function(){return this.debug&&console.group("readXmlCData"),this.readU32(),this.readU32(),this.readS32(),this.readS32(),this.stack.pop(),this.parent=this.stack[this.stack.length-1],this.debug&&console.groupEnd(),null}},{key:"readXmlCData",value:function(){this.debug&&console.group("readXmlCData");var e={namespaceURI:null,nodeType:u,nodeName:"#cdata",data:null,typedValue:null};this.readU32(),this.readU32();var t=this.readS32();return t>0&&(e.data=this.strings[t]),e.typedValue=this.readTypedValue(),this.parent.childNodes.push(e),this.debug&&console.groupEnd(),e}},{key:"readNull",value:function(e){return this.debug&&console.group("readNull"),this.cursor+=e.chunkSize-e.headerSize,this.debug&&console.groupEnd(),null}},{key:"parse",value:function(){if(this.debug&&console.group("BinaryXmlParser.parse"),this.readChunkHeader().chunkType!==c)throw new Error("Invalid XML header");for(;this.cursor<this.buffer.length;){this.debug&&console.group("chunk");var e=this.cursor,t=this.readChunkHeader();switch(t.chunkType){case f:this.readStringPool(t);break;case b:this.readResourceMap(t);break;case h:this.readXmlNamespaceStart(t);break;case d:this.readXmlNamespaceEnd(t);break;case p:this.readXmlElementStart(t);break;case g:this.readXmlElementEnd(t);break;case y:this.readXmlCData(t);break;case l:this.readNull(t);break;default:throw new Error("Unsupported chunk type '".concat(t.chunkType,"'"))}var r=e+t.chunkSize;if(this.cursor!==r){var n=r-this.cursor,i=t.chunkType.toString(16);console.debug("Cursor is off by ".concat(n," bytes at ").concat(this.cursor," at supposed end of chunk of type 0x").concat(i,". The chunk started at offset ").concat(e," and is supposed to end at offset ").concat(r,". Ignoring the rest of the chunk.")),this.cursor=r}this.debug&&console.groupEnd()}return this.debug&&console.groupEnd(),this.document}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.exports=F},{}],7:[function(e,t,r){"use strict";function n(e){"@babel/helpers - typeof";return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}function o(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:String(t)}var a=e("./binary"),s=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.buffer=t,this.xmlParser=new a(this.buffer,r)}var t,r,n;return t=e,(r=[{key:"collapseAttributes",value:function(e){for(var t=Object.create(null),r=0,n=Array.from(e.attributes);r<n.length;r++){var i=n[r];t[i.name]=i.typedValue.value}return t}},{key:"parseIntents",value:function(e,t){var r=this;return t.intentFilters=[],t.metaData=[],e.childNodes.forEach(function(e){switch(e.nodeName){case"intent-filter":var n=r.collapseAttributes(e);n.actions=[],n.categories=[],n.data=[],e.childNodes.forEach(function(e){switch(e.nodeName){case"action":n.actions.push(r.collapseAttributes(e));break;case"category":n.categories.push(r.collapseAttributes(e));break;case"data":n.data.push(r.collapseAttributes(e))}}),t.intentFilters.push(n);break;case"meta-data":t.metaData.push(r.collapseAttributes(e))}})}},{key:"parseApplication",value:function(e){var t=this,r=this.collapseAttributes(e);return r.activities=[],r.activityAliases=[],r.launcherActivities=[],r.services=[],r.receivers=[],r.providers=[],r.usesLibraries=[],r.metaData=[],e.childNodes.forEach(function(e){switch(e.nodeName){case"activity":var n=t.collapseAttributes(e);t.parseIntents(e,n),r.activities.push(n),t.isLauncherActivity(n)&&r.launcherActivities.push(n);break;case"activity-alias":var i=t.collapseAttributes(e);t.parseIntents(e,i),r.activityAliases.push(i),t.isLauncherActivity(i)&&r.launcherActivities.push(i);break;case"service":var o=t.collapseAttributes(e);t.parseIntents(e,o),r.services.push(o);break;case"receiver":var a=t.collapseAttributes(e);t.parseIntents(e,a),r.receivers.push(a);break;case"provider":var s=t.collapseAttributes(e);s.grantUriPermissions=[],s.metaData=[],s.pathPermissions=[],e.childNodes.forEach(function(e){switch(e.nodeName){case"grant-uri-permission":s.grantUriPermissions.push(t.collapseAttributes(e));break;case"meta-data":s.metaData.push(t.collapseAttributes(e));break;case"path-permission":s.pathPermissions.push(t.collapseAttributes(e))}}),r.providers.push(s);break;case"uses-library":r.usesLibraries.push(t.collapseAttributes(e));break;case"meta-data":r.metaData.push(t.collapseAttributes(e))}}),r}},{key:"isLauncherActivity",value:function(e){return e.intentFilters.some(function(e){return!!e.actions.some(function(e){return"android.intent.action.MAIN"===e.name})&&e.categories.some(function(e){return"android.intent.category.LAUNCHER"===e.name})})}},{key:"parse",value:function(){var e=this,t=this.xmlParser.parse(),r=this.collapseAttributes(t);return r.usesPermissions=[],r.usesPermissionsSDK23=[],r.permissions=[],r.permissionTrees=[],r.permissionGroups=[],r.instrumentation=null,r.usesSdk=null,r.usesConfiguration=null,r.usesFeatures=[],r.supportsScreens=null,r.compatibleScreens=[],r.supportsGlTextures=[],r.application=Object.create(null),t.childNodes.forEach(function(t){switch(t.nodeName){case"uses-permission":r.usesPermissions.push(e.collapseAttributes(t));break;case"uses-permission-sdk-23":r.usesPermissionsSDK23.push(e.collapseAttributes(t));break;case"permission":r.permissions.push(e.collapseAttributes(t));break;case"permission-tree":r.permissionTrees.push(e.collapseAttributes(t));break;case"permission-group":r.permissionGroups.push(e.collapseAttributes(t));break;case"instrumentation":r.instrumentation=e.collapseAttributes(t);break;case"uses-sdk":r.usesSdk=e.collapseAttributes(t);break;case"uses-configuration":r.usesConfiguration=e.collapseAttributes(t);break;case"uses-feature":r.usesFeatures.push(e.collapseAttributes(t));break;case"supports-screens":r.supportsScreens=e.collapseAttributes(t);break;case"compatible-screens":t.childNodes.forEach(function(t){return r.compatibleScreens.push(e.collapseAttributes(t))});break;case"supports-gl-texture":r.supportsGlTextures.push(e.collapseAttributes(t));break;case"application":r.application=e.parseApplication(t)}}),r}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.exports=s},{"./binary":6}],8:[function(e,t,r){"use strict";function n(e){"@babel/helpers - typeof";return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}function o(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:String(t)}var a=e("isomorphic-unzip"),s=e("./utils"),u=s.isBrowser,l=s.decodeNullUnicode,f=function(){function t(r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),u()){if(!(r instanceof window.Blob||void 0!==r.size))throw new Error("Param error: [file] must be an instance of Blob or File in browser.");this.file=r}else{if("string"!=typeof r)throw new Error("Param error: [file] must be file path in Node.");this.file=e("path").resolve(r)}this.unzip=new a(this.file)}var r,n,o;return r=t,(n=[{key:"getEntries",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"buffer";return e=e.map(function(e){return l(e)}),new Promise(function(n,i){t.unzip.getBuffer(e,{type:r},function(e,t){e?i(e):n(t)})})}},{key:"getEntry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"buffer";return e=l(e),new Promise(function(n,i){t.unzip.getBuffer([e],{type:r},function(t,r){t?i(t):n(r[e])})})}}])&&i(r.prototype,n),o&&i(r,o),Object.defineProperty(r,"prototype",{writable:!1}),t}();t.exports=f},{"./utils":5,"isomorphic-unzip":74,path:92}],9:[function(e,t,r){"use strict";function n(e,t){return void 0===t&&(t=Object),t&&"function"==typeof t.freeze?t.freeze(e):e}var i=n({HTML:"text/html",isHTML:function(e){return e===i.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),o=n({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===o.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});r.assign=function(e,t){if(null===e||"object"!=typeof e)throw new TypeError("target is not an object");for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},r.find=function(e,t,r){if(void 0===r&&(r=Array.prototype),e&&"function"==typeof r.find)return r.find.call(e,t);for(var n=0;n<e.length;n++)if(Object.prototype.hasOwnProperty.call(e,n)){var i=e[n];if(t.call(void 0,i,n,e))return i}},r.freeze=n,r.MIME_TYPE=i,r.NAMESPACE=o},{}],10:[function(e,t,r){var n=e("./conventions"),i=e("./dom"),o=e("./entities"),a=e("./sax"),s=i.DOMImplementation,u=n.NAMESPACE,l=a.ParseError,f=a.XMLReader;function c(e){return e.replace(/\r[\n\u0085]/g,"\n").replace(/[\r\u0085\u2028]/g,"\n")}function h(e){this.options=e||{locator:{}}}function d(){this.cdata=!1}function p(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function g(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function y(e,t,r){return"string"==typeof e?e.substr(t,r):e.length>=t+r||t?new java.lang.String(e,t,r)+"":e}function b(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}h.prototype.parseFromString=function(e,t){var r=this.options,n=new f,i=r.domBuilder||new d,a=r.errorHandler,s=r.locator,l=r.xmlns||{},h=/\/x?html?$/.test(t),p=h?o.HTML_ENTITIES:o.XML_ENTITIES;s&&i.setDocumentLocator(s),n.errorHandler=function(e,t,r){if(!e){if(t instanceof d)return t;e=t}var n={},i=e instanceof Function;function o(t){var o=e[t];!o&&i&&(o=2==e.length?function(r){e(t,r)}:e),n[t]=o&&function(e){o("[xmldom "+t+"]\t"+e+g(r))}||function(){}}return r=r||{},o("warning"),o("error"),o("fatalError"),n}(a,i,s),n.domBuilder=r.domBuilder||i,h&&(l[""]=u.HTML),l.xml=l.xml||u.XML;var y=r.normalizeLineEndings||c;return e&&"string"==typeof e?n.parse(y(e),l,p):n.errorHandler.error("invalid doc source"),i.doc},d.prototype={startDocument:function(){this.doc=(new s).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,r,n){var i=this.doc,o=i.createElementNS(e,r||t),a=n.length;b(this,o),this.currentElement=o,this.locator&&p(this.locator,o);for(var s=0;s<a;s++){e=n.getURI(s);var u=n.getValue(s),l=(r=n.getQName(s),i.createAttributeNS(e,r));this.locator&&p(n.getLocator(s),l),l.value=l.nodeValue=u,o.setAttributeNode(l)}},endElement:function(e,t,r){var n=this.currentElement;n.tagName;this.currentElement=n.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var r=this.doc.createProcessingInstruction(e,t);this.locator&&p(this.locator,r),b(this,r)},ignorableWhitespace:function(e,t,r){},characters:function(e,t,r){if(e=y.apply(this,arguments)){if(this.cdata)var n=this.doc.createCDATASection(e);else n=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(n):/^\s*$/.test(e)&&this.doc.appendChild(n),this.locator&&p(this.locator,n)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,r){e=y.apply(this,arguments);var n=this.doc.createComment(e);this.locator&&p(this.locator,n),b(this,n)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,r){var n=this.doc.implementation;if(n&&n.createDocumentType){var i=n.createDocumentType(e,t,r);this.locator&&p(this.locator,i),b(this,i),this.doc.doctype=i}},warning:function(e){console.warn("[xmldom warning]\t"+e,g(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,g(this.locator))},fatalError:function(e){throw new l(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){d.prototype[e]=function(){return null}}),r.__DOMHandler=d,r.normalizeLineEndings=c,r.DOMParser=h},{"./conventions":9,"./dom":11,"./entities":12,"./sax":14}],11:[function(e,t,r){var n=e("./conventions"),i=n.find,o=n.NAMESPACE;function a(e){return""!==e}function s(e,t){return e.hasOwnProperty(t)||(e[t]=!0),e}function u(e){if(!e)return[];var t=function(e){return e?e.split(/[\t\n\f\r ]+/).filter(a):[]}(e);return Object.keys(t.reduce(s,{}))}function l(e,t){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}function f(e,t){var r=e.prototype;if(!(r instanceof t)){function n(){}n.prototype=t.prototype,l(r,n=new n),e.prototype=r=n}r.constructor!=e&&("function"!=typeof e&&console.error("unknown Class:"+e),r.constructor=e)}var c={},h=c.ELEMENT_NODE=1,d=c.ATTRIBUTE_NODE=2,p=c.TEXT_NODE=3,g=c.CDATA_SECTION_NODE=4,y=c.ENTITY_REFERENCE_NODE=5,b=c.ENTITY_NODE=6,m=c.PROCESSING_INSTRUCTION_NODE=7,v=c.COMMENT_NODE=8,w=c.DOCUMENT_NODE=9,_=c.DOCUMENT_TYPE_NODE=10,E=c.DOCUMENT_FRAGMENT_NODE=11,x=c.NOTATION_NODE=12,T={},k={},N=(T.INDEX_SIZE_ERR=(k[1]="Index size error",1),T.DOMSTRING_SIZE_ERR=(k[2]="DOMString size error",2),T.HIERARCHY_REQUEST_ERR=(k[3]="Hierarchy request error",3)),S=(T.WRONG_DOCUMENT_ERR=(k[4]="Wrong document",4),T.INVALID_CHARACTER_ERR=(k[5]="Invalid character",5),T.NO_DATA_ALLOWED_ERR=(k[6]="No data allowed",6),T.NO_MODIFICATION_ALLOWED_ERR=(k[7]="No modification allowed",7),T.NOT_FOUND_ERR=(k[8]="Not found",8)),I=(T.NOT_SUPPORTED_ERR=(k[9]="Not supported",9),T.INUSE_ATTRIBUTE_ERR=(k[10]="Attribute in use",10));T.INVALID_STATE_ERR=(k[11]="Invalid state",11),T.SYNTAX_ERR=(k[12]="Syntax error",12),T.INVALID_MODIFICATION_ERR=(k[13]="Invalid modification",13),T.NAMESPACE_ERR=(k[14]="Invalid namespace",14),T.INVALID_ACCESS_ERR=(k[15]="Invalid access",15);function A(e,t){if(t instanceof Error)var r=t;else r=this,Error.call(this,k[e]),this.message=k[e],Error.captureStackTrace&&Error.captureStackTrace(this,A);return r.code=e,t&&(this.message=this.message+": "+t),r}function D(){}function L(e,t){this._node=e,this._refresh=t,O(this)}function O(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!==t){var r=e._refresh(e._node);if(ye(e,"length",r.length),!e.$$length||r.length<e.$$length)for(var n=r.length;n in e;n++)Object.prototype.hasOwnProperty.call(e,n)&&delete e[n];l(r,e),e._inc=t}}function M(){}function U(e,t){for(var r=e.length;r--;)if(e[r]===t)return r}function C(e,t,r,n){if(n?t[U(t,n)]=r:t[t.length++]=r,e){r.ownerElement=e;var i=e.ownerDocument;i&&(n&&q(i,e,n),function(e,t,r){e&&e._inc++,r.namespaceURI===o.XMLNS&&(t._nsMap[r.prefix?r.localName:""]=r.value)}(i,e,r))}}function B(e,t,r){var n=U(t,r);if(!(n>=0))throw new A(S,new Error(e.tagName+"@"+r));for(var i=t.length-1;n<i;)t[n]=t[++n];if(t.length=i,e){var o=e.ownerDocument;o&&(q(o,e,r),r.ownerElement=null)}}function R(){}function P(){}function j(e){return("<"==e?"<":">"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function F(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(F(e,t))return!0}while(e=e.nextSibling)}function z(){this.ownerDocument=this}function q(e,t,r,n){e&&e._inc++,r.namespaceURI===o.XMLNS&&delete t._nsMap[r.prefix?r.localName:""]}function X(e,t,r){if(e&&e._inc){e._inc++;var n=t.childNodes;if(r)n[n.length++]=r;else{for(var i=t.firstChild,o=0;i;)n[o++]=i,i=i.nextSibling;n.length=o,delete n[n.length]}}}function Z(e,t){var r=t.previousSibling,n=t.nextSibling;return r?r.nextSibling=n:e.firstChild=n,n?n.previousSibling=r:e.lastChild=r,t.parentNode=null,t.previousSibling=null,t.nextSibling=null,X(e.ownerDocument,e),t}function V(e){return e&&e.nodeType===P.DOCUMENT_TYPE_NODE}function H(e){return e&&e.nodeType===P.ELEMENT_NODE}function W(e){return e&&e.nodeType===P.TEXT_NODE}function G(e,t){var r=e.childNodes||[];if(i(r,H)||V(t))return!1;var n=i(r,V);return!(t&&n&&r.indexOf(n)>r.indexOf(t))}function K(e,t){var r=e.childNodes||[];if(i(r,function(e){return H(e)&&e!==t}))return!1;var n=i(r,V);return!(t&&n&&r.indexOf(n)>r.indexOf(t))}function $(e,t,r){if(!function(e){return e&&(e.nodeType===P.DOCUMENT_NODE||e.nodeType===P.DOCUMENT_FRAGMENT_NODE||e.nodeType===P.ELEMENT_NODE)}(e))throw new A(N,"Unexpected parent node type "+e.nodeType);if(r&&r.parentNode!==e)throw new A(S,"child not in parent");if(!function(e){return e&&(H(e)||W(e)||V(e)||e.nodeType===P.DOCUMENT_FRAGMENT_NODE||e.nodeType===P.COMMENT_NODE||e.nodeType===P.PROCESSING_INSTRUCTION_NODE)}(t)||V(t)&&e.nodeType!==P.DOCUMENT_NODE)throw new A(N,"Unexpected node type "+t.nodeType+" for parent node type "+e.nodeType)}function Y(e,t,r){var n=e.childNodes||[],o=t.childNodes||[];if(t.nodeType===P.DOCUMENT_FRAGMENT_NODE){var a=o.filter(H);if(a.length>1||i(o,W))throw new A(N,"More than one element or text in fragment");if(1===a.length&&!K(e,r))throw new A(N,"Element in fragment can not be inserted before doctype")}if(H(t)&&!K(e,r))throw new A(N,"Only one element can be added and only after doctype");if(V(t)){if(i(n,function(e){return V(e)&&e!==r}))throw new A(N,"Only one doctype is allowed");var s=i(n,H);if(r&&n.indexOf(s)<n.indexOf(r))throw new A(N,"Doctype can only be inserted before an element")}}function J(e,t,r,n){$(e,t,r),e.nodeType===P.DOCUMENT_NODE&&(n||function(e,t,r){var n=e.childNodes||[],o=t.childNodes||[];if(t.nodeType===P.DOCUMENT_FRAGMENT_NODE){var a=o.filter(H);if(a.length>1||i(o,W))throw new A(N,"More than one element or text in fragment");if(1===a.length&&!G(e,r))throw new A(N,"Element in fragment can not be inserted before doctype")}if(H(t)&&!G(e,r))throw new A(N,"Only one element can be added and only after doctype");if(V(t)){if(i(n,V))throw new A(N,"Only one doctype is allowed");var s=i(n,H);if(r&&n.indexOf(s)<n.indexOf(r))throw new A(N,"Doctype can only be inserted before an element");if(!r&&s)throw new A(N,"Doctype can not be appended since element is present")}})(e,t,r);var o=t.parentNode;if(o&&o.removeChild(t),t.nodeType===E){var a=t.firstChild;if(null==a)return t;var s=t.lastChild}else a=s=t;var u=r?r.previousSibling:e.lastChild;a.previousSibling=u,s.nextSibling=r,u?u.nextSibling=a:e.firstChild=a,null==r?e.lastChild=s:r.previousSibling=s;do{a.parentNode=e}while(a!==s&&(a=a.nextSibling));return X(e.ownerDocument||e,e),t.nodeType==E&&(t.firstChild=t.lastChild=null),t}function Q(){this._nsMap={}}function ee(){}function te(){}function re(){}function ne(){}function ie(){}function oe(){}function ae(){}function se(){}function ue(){}function le(){}function fe(){}function ce(){}function he(e,t){var r=[],n=9==this.nodeType&&this.documentElement||this,i=n.prefix,o=n.namespaceURI;if(o&&null==i&&null==(i=n.lookupPrefix(o)))var a=[{namespace:o,prefix:null}];return ge(this,r,e,t,a),r.join("")}function de(e,t,r){var n=e.prefix||"",i=e.namespaceURI;if(!i)return!1;if("xml"===n&&i===o.XML||i===o.XMLNS)return!1;for(var a=r.length;a--;){var s=r[a];if(s.prefix===n)return s.namespace!==i}return!0}function pe(e,t,r){e.push(" ",t,'="',r.replace(/[<>&"\t\n\r]/g,j),'"')}function ge(e,t,r,n,i){if(i||(i=[]),n){if(!(e=n(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case h:var a=e.attributes,s=a.length,u=e.firstChild,l=e.tagName,f=l;if(!(r=o.isHTML(e.namespaceURI)||r)&&!e.prefix&&e.namespaceURI){for(var c,b=0;b<a.length;b++)if("xmlns"===a.item(b).name){c=a.item(b).value;break}if(!c)for(var x=i.length-1;x>=0;x--){if(""===(T=i[x]).prefix&&T.namespace===e.namespaceURI){c=T.namespace;break}}if(c!==e.namespaceURI)for(x=i.length-1;x>=0;x--){var T;if((T=i[x]).namespace===e.namespaceURI){T.prefix&&(f=T.prefix+":"+l);break}}}t.push("<",f);for(var k=0;k<s;k++){"xmlns"==(N=a.item(k)).prefix?i.push({prefix:N.localName,namespace:N.value}):"xmlns"==N.nodeName&&i.push({prefix:"",namespace:N.value})}for(k=0;k<s;k++){var N;if(de(N=a.item(k),0,i)){var S=N.prefix||"",I=N.namespaceURI;pe(t,S?"xmlns:"+S:"xmlns",I),i.push({prefix:S,namespace:I})}ge(N,t,r,n,i)}if(l===f&&de(e,0,i)){S=e.prefix||"",I=e.namespaceURI;pe(t,S?"xmlns:"+S:"xmlns",I),i.push({prefix:S,namespace:I})}if(u||r&&!/^(?:meta|link|img|br|hr|input)$/i.test(l)){if(t.push(">"),r&&/^script$/i.test(l))for(;u;)u.data?t.push(u.data):ge(u,t,r,n,i.slice()),u=u.nextSibling;else for(;u;)ge(u,t,r,n,i.slice()),u=u.nextSibling;t.push("</",f,">")}else t.push("/>");return;case w:case E:for(u=e.firstChild;u;)ge(u,t,r,n,i.slice()),u=u.nextSibling;return;case d:return pe(t,e.name,e.value);case p:return t.push(e.data.replace(/[<&>]/g,j));case g:return t.push("<![CDATA[",e.data,"]]>");case v:return t.push("\x3c!--",e.data,"--\x3e");case _:var A=e.publicId,D=e.systemId;if(t.push("<!DOCTYPE ",e.name),A)t.push(" PUBLIC ",A),D&&"."!=D&&t.push(" ",D),t.push(">");else if(D&&"."!=D)t.push(" SYSTEM ",D,">");else{var L=e.internalSubset;L&&t.push(" [",L,"]"),t.push(">")}return;case m:return t.push("<?",e.target," ",e.data,"?>");case y:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function ye(e,t,r){e[t]=r}A.prototype=Error.prototype,l(T,A),D.prototype={length:0,item:function(e){return e>=0&&e<this.length?this[e]:null},toString:function(e,t){for(var r=[],n=0;n<this.length;n++)ge(this[n],r,e,t);return r.join("")},filter:function(e){return Array.prototype.filter.call(this,e)},indexOf:function(e){return Array.prototype.indexOf.call(this,e)}},L.prototype.item=function(e){return O(this),this[e]||null},f(L,D),M.prototype={length:0,item:D.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var r=this[t];if(r.nodeName==e)return r}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new A(I);var r=this.getNamedItem(e.nodeName);return C(this._ownerElement,this,e,r),r},setNamedItemNS:function(e){var t,r=e.ownerElement;if(r&&r!=this._ownerElement)throw new A(I);return t=this.getNamedItemNS(e.namespaceURI,e.localName),C(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return B(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var r=this.getNamedItemNS(e,t);return B(this._ownerElement,this,r),r},getNamedItemNS:function(e,t){for(var r=this.length;r--;){var n=this[r];if(n.localName==t&&n.namespaceURI==e)return n}return null}},R.prototype={hasFeature:function(e,t){return!0},createDocument:function(e,t,r){var n=new z;if(n.implementation=this,n.childNodes=new D,n.doctype=r||null,r&&n.appendChild(r),t){var i=n.createElementNS(e,t);n.appendChild(i)}return n},createDocumentType:function(e,t,r){var n=new oe;return n.name=e,n.nodeName=e,n.publicId=t||"",n.systemId=r||"",n}},P.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return J(this,e,t)},replaceChild:function(e,t){J(this,e,t,Y),t&&this.removeChild(t)},removeChild:function(e){return Z(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return function e(t,r,n){var i=new r.constructor;for(var o in r)if(Object.prototype.hasOwnProperty.call(r,o)){var a=r[o];"object"!=typeof a&&a!=i[o]&&(i[o]=a)}r.childNodes&&(i.childNodes=new D);i.ownerDocument=t;switch