@tsocial/tvweb-sdk.tiki 5.6.2 → 5.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,7 +58,7 @@ function(e){var t=r,n=t.lib,i=n.WordArray,a=n.Hasher,o=t.algo,s=i.create([0,1,2,
58
58
  *
59
59
  * Copyright © 2012-2016 Faisal Salman <fyzlman@gmail.com>
60
60
  * Dual licensed under GPLv2 or MIT
61
- */!function(i,a){var o="function",s="undefined",c="object",u="model",l="name",d="type",f="vendor",p="version",h="architecture",g="console",m="mobile",y="tablet",v="smarttv",b="wearable",C={extend:function(e,t){var r={};for(var n in e)t[n]&&t[n].length%2==0?r[n]=t[n].concat(e[n]):r[n]=e[n];return r},has:function(e,t){return"string"==typeof e&&-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()},major:function(e){return"string"==typeof e?e.replace(/[^\d\.]/g,"").split(".")[0]:a},trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},E={rgx:function(e,t){for(var r,n,i,s,u,l,d=0;d<t.length&&!u;){var f=t[d],p=t[d+1];for(r=n=0;r<f.length&&!u;)if(u=f[r++].exec(e))for(i=0;i<p.length;i++)l=u[++n],typeof(s=p[i])===c&&s.length>0?2==s.length?typeof s[1]==o?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:3==s.length?typeof s[1]!==o||s[1].exec&&s[1].test?this[s[0]]=l?l.replace(s[1],s[2]):a:this[s[0]]=l?s[1].call(this,l,s[2]):a:4==s.length&&(this[s[0]]=l?s[3].call(this,l.replace(s[1],s[2])):a):this[s]=l||a;d+=2}},str:function(e,t){for(var r in t)if(typeof t[r]===c&&t[r].length>0){for(var n=0;n<t[r].length;n++)if(C.has(t[r][n],e))return"?"===r?a:r}else if(C.has(t[r],e))return"?"===r?a:r;return e}},w={browser:{oldsafari:{version:{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}}},device:{amazon:{model:{"Fire Phone":["SD","KF"]}},sprint:{model:{"Evo Shift 4G":"7373KT"},vendor:{HTC:"APA",Sprint:"Sprint"}}},os:{windows:{version:{ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"}}}},k={browser:[[/(opera\smini)\/([\w\.-]+)/i,/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i,/(opera).+version\/([\w\.]+)/i,/(opera)[\/\s]+([\w\.]+)/i],[l,p],[/(opios)[\/\s]+([\w\.]+)/i],[[l,"Opera Mini"],p],[/\s(opr)\/([\w\.]+)/i],[[l,"Opera"],p],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i,/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i,/(?:ms|\()(ie)\s([\w\.]+)/i,/(rekonq)\/([\w\.]*)/i,/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark)\/([\w\.-]+)/i],[l,p],[/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i],[[l,"IE"],p],[/(edge|edgios|edgea)\/((\d+)?[\w\.]+)/i],[[l,"Edge"],p],[/(yabrowser)\/([\w\.]+)/i],[[l,"Yandex"],p],[/(puffin)\/([\w\.]+)/i],[[l,"Puffin"],p],[/((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i],[[l,"UCBrowser"],p],[/(comodo_dragon)\/([\w\.]+)/i],[[l,/_/g," "],p],[/(micromessenger)\/([\w\.]+)/i],[[l,"WeChat"],p],[/(qqbrowserlite)\/([\w\.]+)/i],[l,p],[/(QQ)\/([\d\.]+)/i],[l,p],[/m?(qqbrowser)[\/\s]?([\w\.]+)/i],[l,p],[/(BIDUBrowser)[\/\s]?([\w\.]+)/i],[l,p],[/(2345Explorer)[\/\s]?([\w\.]+)/i],[l,p],[/(MetaSr)[\/\s]?([\w\.]+)/i],[l],[/(LBBROWSER)/i],[l],[/xiaomi\/miuibrowser\/([\w\.]+)/i],[p,[l,"MIUI Browser"]],[/;fbav\/([\w\.]+);/i],[p,[l,"Facebook"]],[/headlesschrome(?:\/([\w\.]+)|\s)/i],[p,[l,"Chrome Headless"]],[/\swv\).+(chrome)\/([\w\.]+)/i],[[l,/(.+)/,"$1 WebView"],p],[/((?:oculus|samsung)browser)\/([\w\.]+)/i],[[l,/(.+(?:g|us))(.+)/,"$1 $2"],p],[/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i],[p,[l,"Android Browser"]],[/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i],[l,p],[/(dolfin)\/([\w\.]+)/i],[[l,"Dolphin"],p],[/((?:android.+)crmo|crios)\/([\w\.]+)/i],[[l,"Chrome"],p],[/(coast)\/([\w\.]+)/i],[[l,"Opera Coast"],p],[/fxios\/([\w\.-]+)/i],[p,[l,"Firefox"]],[/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i],[p,[l,"Mobile Safari"]],[/version\/([\w\.]+).+?(mobile\s?safari|safari)/i],[p,l],[/webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i],[[l,"GSA"],p],[/webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i],[l,[p,E.str,w.browser.oldsafari.version]],[/(konqueror)\/([\w\.]+)/i,/(webkit|khtml)\/([\w\.]+)/i],[l,p],[/(navigator|netscape)\/([\w\.-]+)/i],[[l,"Netscape"],p],[/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i,/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i,/(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i,/(links)\s\(([\w\.]+)/i,/(gobrowser)\/?([\w\.]*)/i,/(ice\s?browser)\/v?([\w\._]+)/i,/(mosaic)[\/\s]([\w\.]+)/i],[l,p]],cpu:[[/(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i],[[h,"amd64"]],[/(ia32(?=;))/i],[[h,C.lowerize]],[/((?:i[346]|x)86)[;\)]/i],[[h,"ia32"]],[/windows\s(ce|mobile);\sppc;/i],[[h,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i],[[h,/ower/,"",C.lowerize]],[/(sun4\w)[;\)]/i],[[h,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+;))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i],[[h,C.lowerize]]],device:[[/\((ipad|playbook);[\w\s\);-]+(rim|apple)/i],[u,f,[d,y]],[/applecoremedia\/[\w\.]+ \((ipad)/],[u,[f,"Apple"],[d,y]],[/(apple\s{0,1}tv)/i],[[u,"Apple TV"],[f,"Apple"]],[/(archos)\s(gamepad2?)/i,/(hp).+(touchpad)/i,/(hp).+(tablet)/i,/(kindle)\/([\w\.]+)/i,/\s(nook)[\w\s]+build\/(\w+)/i,/(dell)\s(strea[kpr\s\d]*[\dko])/i],[f,u,[d,y]],[/(kf[A-z]+)\sbuild\/.+silk\//i],[u,[f,"Amazon"],[d,y]],[/(sd|kf)[0349hijorstuw]+\sbuild\/.+silk\//i],[[u,E.str,w.device.amazon.model],[f,"Amazon"],[d,m]],[/\((ip[honed|\s\w*]+);.+(apple)/i],[u,f,[d,m]],[/\((ip[honed|\s\w*]+);/i],[u,[f,"Apple"],[d,m]],[/(blackberry)[\s-]?(\w+)/i,/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[\s_-]?([\w-]*)/i,/(hp)\s([\w\s]+\w)/i,/(asus)-?(\w+)/i],[f,u,[d,m]],[/\(bb10;\s(\w+)/i],[u,[f,"BlackBerry"],[d,m]],[/android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone)/i],[u,[f,"Asus"],[d,y]],[/(sony)\s(tablet\s[ps])\sbuild\//i,/(sony)?(?:sgp.+)\sbuild\//i],[[f,"Sony"],[u,"Xperia Tablet"],[d,y]],[/android.+\s([c-g]\d{4}|so[-l]\w+)\sbuild\//i],[u,[f,"Sony"],[d,m]],[/\s(ouya)\s/i,/(nintendo)\s([wids3u]+)/i],[f,u,[d,g]],[/android.+;\s(shield)\sbuild/i],[u,[f,"Nvidia"],[d,g]],[/(playstation\s[34portablevi]+)/i],[u,[f,"Sony"],[d,g]],[/(sprint\s(\w+))/i],[[f,E.str,w.device.sprint.vendor],[u,E.str,w.device.sprint.model],[d,m]],[/(lenovo)\s?(S(?:5000|6000)+(?:[-][\w+]))/i],[f,u,[d,y]],[/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i,/(zte)-(\w*)/i,/(alcatel|geeksphone|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i],[f,[u,/_/g," "],[d,m]],[/(nexus\s9)/i],[u,[f,"HTC"],[d,y]],[/d\/huawei([\w\s-]+)[;\)]/i,/(nexus\s6p)/i],[u,[f,"Huawei"],[d,m]],[/(microsoft);\s(lumia[\s\w]+)/i],[f,u,[d,m]],[/[\s\(;](xbox(?:\sone)?)[\s\);]/i],[u,[f,"Microsoft"],[d,g]],[/(kin\.[onetw]{3})/i],[[u,/\./g," "],[f,"Microsoft"],[d,m]],[/\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?:?(\s4g)?)[\w\s]+build\//i,/mot[\s-]?(\w*)/i,/(XT\d{3,4}) build\//i,/(nexus\s6)/i],[u,[f,"Motorola"],[d,m]],[/android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i],[u,[f,"Motorola"],[d,y]],[/hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i],[[f,C.trim],[u,C.trim],[d,v]],[/hbbtv.+maple;(\d+)/i],[[u,/^/,"SmartTV"],[f,"Samsung"],[d,v]],[/\(dtv[\);].+(aquos)/i],[u,[f,"Sharp"],[d,v]],[/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n\d+|sgh-t8[56]9|nexus 10))/i,/((SM-T\w+))/i],[[f,"Samsung"],u,[d,y]],[/smart-tv.+(samsung)/i],[f,[d,v],u],[/((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-\w[\w\d]+))/i,/(sam[sung]*)[\s-]*(\w+-?[\w-]*)/i,/sec-((sgh\w+))/i],[[f,"Samsung"],u,[d,m]],[/sie-(\w*)/i],[u,[f,"Siemens"],[d,m]],[/(maemo|nokia).*(n900|lumia\s\d+)/i,/(nokia)[\s_-]?([\w-]*)/i],[[f,"Nokia"],u,[d,m]],[/android\s3\.[\s\w;-]{10}(a\d{3})/i],[u,[f,"Acer"],[d,y]],[/android.+([vl]k\-?\d{3})\s+build/i],[u,[f,"LG"],[d,y]],[/android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i],[[f,"LG"],u,[d,y]],[/(lg) netcast\.tv/i],[f,u,[d,v]],[/(nexus\s[45])/i,/lg[e;\s\/-]+(\w*)/i,/android.+lg(\-?[\d\w]+)\s+build/i],[u,[f,"LG"],[d,m]],[/android.+(ideatab[a-z0-9\-\s]+)/i],[u,[f,"Lenovo"],[d,y]],[/linux;.+((jolla));/i],[f,u,[d,m]],[/((pebble))app\/[\d\.]+\s/i],[f,u,[d,b]],[/android.+;\s(oppo)\s?([\w\s]+)\sbuild/i],[f,u,[d,m]],[/crkey/i],[[u,"Chromecast"],[f,"Google"]],[/android.+;\s(glass)\s\d/i],[u,[f,"Google"],[d,b]],[/android.+;\s(pixel c)\s/i],[u,[f,"Google"],[d,y]],[/android.+;\s(pixel xl|pixel)\s/i],[u,[f,"Google"],[d,m]],[/android.+;\s(\w+)\s+build\/hm\1/i,/android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i,/android.+(mi[\s\-_]*(?:one|one[\s_]plus|note lte)?[\s_]*(?:\d?\w?)[\s_]*(?:plus)?)\s+build/i,/android.+(redmi[\s\-_]*(?:note)?(?:[\s_]*[\w\s]+))\s+build/i],[[u,/_/g," "],[f,"Xiaomi"],[d,m]],[/android.+(mi[\s\-_]*(?:pad)(?:[\s_]*[\w\s]+))\s+build/i],[[u,/_/g," "],[f,"Xiaomi"],[d,y]],[/android.+;\s(m[1-5]\snote)\sbuild/i],[u,[f,"Meizu"],[d,y]],[/android.+a000(1)\s+build/i,/android.+oneplus\s(a\d{4})\s+build/i],[u,[f,"OnePlus"],[d,m]],[/android.+[;\/]\s*(RCT[\d\w]+)\s+build/i],[u,[f,"RCA"],[d,y]],[/android.+[;\/\s]+(Venue[\d\s]{2,7})\s+build/i],[u,[f,"Dell"],[d,y]],[/android.+[;\/]\s*(Q[T|M][\d\w]+)\s+build/i],[u,[f,"Verizon"],[d,y]],[/android.+[;\/]\s+(Barnes[&\s]+Noble\s+|BN[RT])(V?.*)\s+build/i],[[f,"Barnes & Noble"],u,[d,y]],[/android.+[;\/]\s+(TM\d{3}.*\b)\s+build/i],[u,[f,"NuVision"],[d,y]],[/android.+;\s(k88)\sbuild/i],[u,[f,"ZTE"],[d,y]],[/android.+[;\/]\s*(gen\d{3})\s+build.*49h/i],[u,[f,"Swiss"],[d,m]],[/android.+[;\/]\s*(zur\d{3})\s+build/i],[u,[f,"Swiss"],[d,y]],[/android.+[;\/]\s*((Zeki)?TB.*\b)\s+build/i],[u,[f,"Zeki"],[d,y]],[/(android).+[;\/]\s+([YR]\d{2})\s+build/i,/android.+[;\/]\s+(Dragon[\-\s]+Touch\s+|DT)(\w{5})\sbuild/i],[[f,"Dragon Touch"],u,[d,y]],[/android.+[;\/]\s*(NS-?\w{0,9})\sbuild/i],[u,[f,"Insignia"],[d,y]],[/android.+[;\/]\s*((NX|Next)-?\w{0,9})\s+build/i],[u,[f,"NextBook"],[d,y]],[/android.+[;\/]\s*(Xtreme\_)?(V(1[045]|2[015]|30|40|60|7[05]|90))\s+build/i],[[f,"Voice"],u,[d,m]],[/android.+[;\/]\s*(LVTEL\-)?(V1[12])\s+build/i],[[f,"LvTel"],u,[d,m]],[/android.+[;\/]\s*(V(100MD|700NA|7011|917G).*\b)\s+build/i],[u,[f,"Envizen"],[d,y]],[/android.+[;\/]\s*(Le[\s\-]+Pan)[\s\-]+(\w{1,9})\s+build/i],[f,u,[d,y]],[/android.+[;\/]\s*(Trio[\s\-]*.*)\s+build/i],[u,[f,"MachSpeed"],[d,y]],[/android.+[;\/]\s*(Trinity)[\-\s]*(T\d{3})\s+build/i],[f,u,[d,y]],[/android.+[;\/]\s*TU_(1491)\s+build/i],[u,[f,"Rotor"],[d,y]],[/android.+(KS(.+))\s+build/i],[u,[f,"Amazon"],[d,y]],[/android.+(Gigaset)[\s\-]+(Q\w{1,9})\s+build/i],[f,u,[d,y]],[/\s(tablet|tab)[;\/]/i,/\s(mobile)(?:[;\/]|\ssafari)/i],[[d,C.lowerize],f,u],[/(android[\w\.\s\-]{0,9});.+build/i],[u,[f,"Generic"]]],engine:[[/windows.+\sedge\/([\w\.]+)/i],[p,[l,"EdgeHTML"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i,/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i,/(icab)[\/\s]([23]\.[\d\.]+)/i],[l,p],[/rv\:([\w\.]{1,9}).+(gecko)/i],[p,l]],os:[[/microsoft\s(windows)\s(vista|xp)/i],[l,p],[/(windows)\snt\s6\.2;\s(arm)/i,/(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s\w]*)/i,/(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i],[l,[p,E.str,w.os.windows.version]],[/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],[[l,"Windows"],[p,E.str,w.os.windows.version]],[/\((bb)(10);/i],[[l,"BlackBerry"],p],[/(blackberry)\w*\/?([\w\.]*)/i,/(tizen)[\/\s]([\w\.]+)/i,/(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]*)/i,/linux;.+(sailfish);/i],[l,p],[/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]*)/i],[[l,"Symbian"],p],[/\((series40);/i],[l],[/mozilla.+\(mobile;.+gecko.+firefox/i],[[l,"Firefox OS"],p],[/(nintendo|playstation)\s([wids34portablevu]+)/i,/(mint)[\/\s\(]?(\w*)/i,/(mageia|vectorlinux)[;\s]/i,/(joli|[kxln]?ubuntu|debian|suse|opensuse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?(?!chrom)([\w\.-]*)/i,/(hurd|linux)\s?([\w\.]*)/i,/(gnu)\s?([\w\.]*)/i],[l,p],[/(cros)\s[\w]+\s([\w\.]+\w)/i],[[l,"Chromium OS"],p],[/(sunos)\s?([\w\.\d]*)/i],[[l,"Solaris"],p],[/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]*)/i],[l,p],[/(haiku)\s(\w+)/i],[l,p],[/cfnetwork\/.+darwin/i,/ip[honead]{2,4}(?:.*os\s([\w]+)\slike\smac|;\sopera)/i],[[p,/_/g,"."],[l,"iOS"]],[/(mac\sos\sx)\s?([\w\s\.]*)/i,/(macintosh|mac(?=_powerpc)\s)/i],[[l,"Mac OS"],[p,/_/g,"."]],[/((?:open)?solaris)[\/\s-]?([\w\.]*)/i,/(aix)\s((\d)(?=\.|\)|\s)[\w\.])*/i,/(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms)/i,/(unix)\s?([\w\.]*)/i],[l,p]]},S=function(e,t){if("object"==typeof e&&(t=e,e=a),!(this instanceof S))return new S(e,t).getResult();var r=e||(i&&i.navigator&&i.navigator.userAgent?i.navigator.userAgent:""),n=t?C.extend(k,t):k;return this.getBrowser=function(){var e={name:a,version:a};return E.rgx.call(e,r,n.browser),e.major=C.major(e.version),e},this.getCPU=function(){var e={architecture:a};return E.rgx.call(e,r,n.cpu),e},this.getDevice=function(){var e={vendor:a,model:a,type:a};return E.rgx.call(e,r,n.device),e},this.getEngine=function(){var e={name:a,version:a};return E.rgx.call(e,r,n.engine),e},this.getOS=function(){var e={name:a,version:a};return E.rgx.call(e,r,n.os),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return r},this.setUA=function(e){return r=e,this},this};S.VERSION="0.7.18",S.BROWSER={NAME:l,MAJOR:"major",VERSION:p},S.CPU={ARCHITECTURE:h},S.DEVICE={MODEL:u,VENDOR:f,TYPE:d,CONSOLE:g,MOBILE:m,SMARTTV:v,TABLET:y,WEARABLE:b,EMBEDDED:"embedded"},S.ENGINE={NAME:l,VERSION:p},S.OS={NAME:l,VERSION:p},typeof t!==s?(typeof e!==s&&e.exports&&(t=e.exports=S),t.UAParser=S):r(3)?(n=function(){return S}.call(t,r,t,e))===a||(e.exports=n):i&&(i.UAParser=S);var B=i&&(i.jQuery||i.Zepto);if(typeof B!==s){var T=new S;B.ua=T.getResult(),B.ua.get=function(){return T.getUA()},B.ua.set=function(e){T.setUA(e);var t=T.getResult();for(var r in t)B.ua[r]=t[r]}}}("object"==typeof window?window:this)},function(e,t){(function(t){e.exports=t}).call(t,{})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i=r(0),a=i.DEVICE_TYPES,o=i.defaultData,s=t.getNavigatorInstance=function(){return!("undefined"==typeof window||!window.navigator&&!navigator)&&(window.navigator||navigator)},c=t.isIOS13Check=function(e){var t=s();return t&&t.platform&&(-1!==t.platform.indexOf(e)||"MacIntel"===t.platform&&t.maxTouchPoints>1&&!window.MSStream)};e.exports={checkType:function(e){switch(e){case a.MOBILE:return{isMobile:!0};case a.TABLET:return{isTablet:!0};case a.SMART_TV:return{isSmartTV:!0};case a.CONSOLE:return{isConsole:!0};case a.WEARABLE:return{isWearable:!0};case a.BROWSER:return{isBrowser:!0};default:return o}},broPayload:function(e,t,r,n,i){return{isBrowser:e,browserMajorVersion:t.major,browserFullVersion:t.version,browserName:t.name,engineName:r.name||!1,engineVersion:r.version,osName:n.name,osVersion:n.version,userAgent:i}},mobilePayload:function(e,t,r,i){return n({},e,{vendor:t.vendor,model:t.model,os:r.name,osVersion:r.version,ua:i})},stvPayload:function(e,t,r,n){return{isSmartTV:e,engineName:t.name,engineVersion:t.version,osName:r.name,osVersion:r.version,userAgent:n}},consolePayload:function(e,t,r,n){return{isConsole:e,engineName:t.name,engineVersion:t.version,osName:r.name,osVersion:r.version,userAgent:n}},wearPayload:function(e,t,r,n){return{isWearable:e,engineName:t.name,engineVersion:t.version,osName:r.name,osVersion:r.version,userAgent:n}},getNavigatorInstance:s,isIOS13Check:c}}])})),eG="object"==typeof n&&n&&n.Object===Object&&n,tG="object"==typeof self&&self&&self.Object===Object&&self,rG=eG||tG||Function("return this")(),nG=rG.Symbol,iG=Object.prototype,aG=iG.hasOwnProperty,oG=iG.toString,sG=nG?nG.toStringTag:void 0;var cG=function(e){var t=aG.call(e,sG),r=e[sG];try{e[sG]=void 0;var n=!0}catch(e){}var i=oG.call(e);return n&&(t?e[sG]=r:delete e[sG]),i},uG=Object.prototype.toString;var lG=function(e){return uG.call(e)},dG=nG?nG.toStringTag:void 0;var fG=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":dG&&dG in Object(e)?cG(e):lG(e)};var pG=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};var hG=function(e){if(!pG(e))return!1;var t=fG(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},gG=rG["__core-js_shared__"],mG=function(){var e=/[^.]+$/.exec(gG&&gG.keys&&gG.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();var yG=function(e){return!!mG&&mG in e},vG=Function.prototype.toString;var bG=function(e){if(null!=e){try{return vG.call(e)}catch(e){}try{return e+""}catch(e){}}return""},CG=/^\[object .+?Constructor\]$/,EG=Function.prototype,wG=Object.prototype,kG=EG.toString,SG=wG.hasOwnProperty,BG=RegExp("^"+kG.call(SG).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var TG=function(e){return!(!pG(e)||yG(e))&&(hG(e)?BG:CG).test(bG(e))};var AG=function(e,t){return null==e?void 0:e[t]};var IG=function(e,t){var r=AG(e,t);return TG(r)?r:void 0},_G=function(){try{var e=IG(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var xG=function(e,t,r){"__proto__"==t&&_G?_G(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r};var PG=function(e,t){return e===t||e!=e&&t!=t},RG=Object.prototype.hasOwnProperty;var NG=function(e,t,r){var n=e[t];RG.call(e,t)&&PG(n,r)&&(void 0!==r||t in e)||xG(e,t,r)};var OG=function(e,t,r,n){var i=!r;r||(r={});for(var a=-1,o=t.length;++a<o;){var s=t[a],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?xG(r,s,c):NG(r,s,c)}return r};var LG=function(e){return e};var DG=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)},UG=Math.max;var MG=function(e,t,r){return t=UG(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=UG(n.length-t,0),o=Array(a);++i<a;)o[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(o),DG(e,this,s)}};var VG=function(e){return function(){return e}},jG=_G?function(e,t){return _G(e,"toString",{configurable:!0,enumerable:!1,value:VG(t),writable:!0})}:LG,FG=Date.now;var zG=function(e){var t=0,r=0;return function(){var n=FG(),i=16-(n-r);if(r=n,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(jG);var KG=function(e,t){return zG(MG(e,t,LG),e+"")};var qG=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};var HG=function(e){return null!=e&&qG(e.length)&&!hG(e)},GG=/^(?:0|[1-9]\d*)$/;var QG=function(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&GG.test(e))&&e>-1&&e%1==0&&e<t};var WG=function(e,t,r){if(!pG(r))return!1;var n=typeof t;return!!("number"==n?HG(r)&&QG(t,r.length):"string"==n&&t in r)&&PG(r[t],e)};var XG=function(e){return KG((function(t,r){var n=-1,i=r.length,a=i>1?r[i-1]:void 0,o=i>2?r[2]:void 0;for(a=e.length>3&&"function"==typeof a?(i--,a):void 0,o&&WG(r[0],r[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++n<i;){var s=r[n];s&&e(t,s,n,a)}return t}))};var YG=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n};var $G=function(e){return null!=e&&"object"==typeof e};var ZG=function(e){return $G(e)&&"[object Arguments]"==fG(e)},JG=Object.prototype,eQ=JG.hasOwnProperty,tQ=JG.propertyIsEnumerable,rQ=ZG(function(){return arguments}())?ZG:function(e){return $G(e)&&eQ.call(e,"callee")&&!tQ.call(e,"callee")},nQ=Array.isArray;var iQ=function(){return!1},aQ=a((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r?rG.Buffer:void 0,a=(i?i.isBuffer:void 0)||iQ;e.exports=a})),oQ={};oQ["[object Float32Array]"]=oQ["[object Float64Array]"]=oQ["[object Int8Array]"]=oQ["[object Int16Array]"]=oQ["[object Int32Array]"]=oQ["[object Uint8Array]"]=oQ["[object Uint8ClampedArray]"]=oQ["[object Uint16Array]"]=oQ["[object Uint32Array]"]=!0,oQ["[object Arguments]"]=oQ["[object Array]"]=oQ["[object ArrayBuffer]"]=oQ["[object Boolean]"]=oQ["[object DataView]"]=oQ["[object Date]"]=oQ["[object Error]"]=oQ["[object Function]"]=oQ["[object Map]"]=oQ["[object Number]"]=oQ["[object Object]"]=oQ["[object RegExp]"]=oQ["[object Set]"]=oQ["[object String]"]=oQ["[object WeakMap]"]=!1;var sQ=function(e){return $G(e)&&qG(e.length)&&!!oQ[fG(e)]};var cQ=function(e){return function(t){return e(t)}},uQ=a((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r&&eG.process,a=function(){try{var e=n&&n.require&&n.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=a})),lQ=uQ&&uQ.isTypedArray,dQ=lQ?cQ(lQ):sQ,fQ=Object.prototype.hasOwnProperty;var pQ=function(e,t){var r=nQ(e),n=!r&&rQ(e),i=!r&&!n&&aQ(e),a=!r&&!n&&!i&&dQ(e),o=r||n||i||a,s=o?YG(e.length,String):[],c=s.length;for(var u in e)!t&&!fQ.call(e,u)||o&&("length"==u||i&&("offset"==u||"parent"==u)||a&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||QG(u,c))||s.push(u);return s},hQ=Object.prototype;var gQ=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||hQ)};var mQ=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t},yQ=Object.prototype.hasOwnProperty;var vQ=function(e){if(!pG(e))return mQ(e);var t=gQ(e),r=[];for(var n in e)("constructor"!=n||!t&&yQ.call(e,n))&&r.push(n);return r};var bQ=function(e){return HG(e)?pQ(e,!0):vQ(e)},CQ=XG((function(e,t,r,n){OG(t,bQ(t),e,n)}));var EQ=function(e,t){return function(r){return e(t(r))}},wQ=EQ(Object.getPrototypeOf,Object),kQ=Function.prototype,SQ=Object.prototype,BQ=kQ.toString,TQ=SQ.hasOwnProperty,AQ=BQ.call(Object);var IQ=function(e){if(!$G(e)||"[object Object]"!=fG(e))return!1;var t=wQ(e);if(null===t)return!0;var r=TQ.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&BQ.call(r)==AQ};var _Q=function(e){if(!$G(e))return!1;var t=fG(e);return"[object Error]"==t||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!IQ(e)},xQ=KG((function(e,t){try{return DG(e,void 0,t)}catch(e){return _Q(e)?e:new Error(e)}}));var PQ=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i};var RQ=function(e,t){return PQ(t,(function(t){return e[t]}))},NQ=Object.prototype,OQ=NQ.hasOwnProperty;var LQ=function(e,t,r,n){return void 0===e||PG(e,NQ[r])&&!OQ.call(n,r)?t:e},DQ={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};var UQ=function(e){return"\\"+DQ[e]},MQ=EQ(Object.keys,Object),VQ=Object.prototype.hasOwnProperty;var jQ=function(e){if(!gQ(e))return MQ(e);var t=[];for(var r in Object(e))VQ.call(e,r)&&"constructor"!=r&&t.push(r);return t};var FQ=function(e){return HG(e)?pQ(e):jQ(e)},zQ=/<%=([\s\S]+?)%>/g;var KQ=function(e){return function(t){return null==e?void 0:e[t]}}({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});var qQ=function(e){return"symbol"==typeof e||$G(e)&&"[object Symbol]"==fG(e)},HQ=nG?nG.prototype:void 0,GQ=HQ?HQ.toString:void 0;var QQ=function e(t){if("string"==typeof t)return t;if(nQ(t))return PQ(t,e)+"";if(qQ(t))return GQ?GQ.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r};var WQ=function(e){return null==e?"":QQ(e)},XQ=/[&<>"']/g,YQ=RegExp(XQ.source);var $Q={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:zQ,variable:"",imports:{_:{escape:function(e){return(e=WQ(e))&&YQ.test(e)?e.replace(XQ,KQ):e}}}},ZQ=/\b__p \+= '';/g,JQ=/\b(__p \+=) '' \+/g,eW=/(__e\(.*?\)|\b__t\)) \+\n'';/g,tW=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rW=/($^)/,nW=/['\n\r\u2028\u2029\\]/g,iW=Object.prototype.hasOwnProperty;var aW=function(e,t,r){var n=$Q.imports._.templateSettings||$Q;r&&WG(e,t,r)&&(t=void 0),e=WQ(e),t=CQ({},t,n,LQ);var i,a,o=CQ({},t.imports,n.imports,LQ),s=FQ(o),c=RQ(o,s),u=0,l=t.interpolate||rW,d="__p += '",f=RegExp((t.escape||rW).source+"|"+l.source+"|"+(l===zQ?tW:rW).source+"|"+(t.evaluate||rW).source+"|$","g"),p=iW.call(t,"sourceURL")?"//# sourceURL="+(t.sourceURL+"").replace(/\s/g," ")+"\n":"";e.replace(f,(function(t,r,n,o,s,c){return n||(n=o),d+=e.slice(u,c).replace(nW,UQ),r&&(i=!0,d+="' +\n__e("+r+") +\n'"),s&&(a=!0,d+="';\n"+s+";\n__p += '"),n&&(d+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),d+="';\n";var h=iW.call(t,"variable")&&t.variable;h||(d="with (obj) {\n"+d+"\n}\n"),d=(a?d.replace(ZQ,""):d).replace(JQ,"$1").replace(eW,"$1;"),d="function("+(h||"obj")+") {\n"+(h?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=xQ((function(){return Function(s,p+"return "+d).apply(void 0,c)}));if(g.source=d,_Q(g))throw g;return g},oW="SESSION_TIMEOUT";function sW(){return(sW=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var cW,uW,lW,dW,fW,pW,hW,gW,mW,yW,vW,bW,CW="undefined"!=typeof window?oy.useLayoutEffect:oy.useEffect,EW={popupContent:{tooltip:{position:"absolute",zIndex:999},modal:{position:"relative",margin:"auto"}},popupArrow:{height:"8px",width:"16px",position:"absolute",background:"transparent",color:"#FFF",zIndex:-1},overlay:{tooltip:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",zIndex:999},modal:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",display:"flex",zIndex:999}}},wW=["top left","top center","top right","right top","right center","right bottom","bottom left","bottom center","bottom right","left top","left center","left bottom"],kW=function(e,t,r,n,i){var a=i.offsetX,o=i.offsetY,s=n?8:0,c=r.split(" "),u=e.top+e.height/2,l=e.left+e.width/2,d=t.height,f=t.width,p=u-d/2,h=l-f/2,g="",m="0%",y="0%";switch(c[0]){case"top":p-=d/2+e.height/2+s,g="rotate(180deg) translateX(50%)",m="100%",y="50%";break;case"bottom":p+=d/2+e.height/2+s,g="rotate(0deg) translateY(-100%) translateX(-50%)",y="50%";break;case"left":h-=f/2+e.width/2+s,g=" rotate(90deg) translateY(50%) translateX(-25%)",y="100%",m="50%";break;case"right":h+=f/2+e.width/2+s,g="rotate(-90deg) translateY(-150%) translateX(25%)",m="50%"}switch(c[1]){case"top":p=e.top,m=e.height/2+"px";break;case"bottom":p=e.top-d+e.height,m=d-e.height/2+"px";break;case"left":h=e.left,y=e.width/2+"px";break;case"right":h=e.left-f+e.width,y=f-e.width/2+"px"}return{top:p="top"===c[0]?p-o:p+o,left:h="left"===c[0]?h-a:h+a,transform:g,arrowLeft:y,arrowTop:m}},SW=function(e,t,r,n,i,a){var o=i.offsetX,s=i.offsetY,c={arrowLeft:"0%",arrowTop:"0%",left:0,top:0,transform:"rotate(135deg)"},u=0,l=function(e){var t={top:0,left:0,width:window.innerWidth,height:window.innerHeight};if("string"==typeof e){var r=document.querySelector(e);null!==r&&(t=r.getBoundingClientRect())}return t}(a),d=Array.isArray(r)?r:[r];for((a||Array.isArray(r))&&(d=[].concat(d,wW));u<d.length;){var f={top:(c=kW(e,t,d[u],n,{offsetX:o,offsetY:s})).top,left:c.left,width:t.width,height:t.height};if(!(f.top<=l.top||f.left<=l.left||f.top+f.height>=l.top+l.height||f.left+f.width>=l.left+l.width))break;u++}return c},BW=0,TW=oy.forwardRef((function(e,t){var r=e.trigger,n=void 0===r?null:r,i=e.onOpen,a=void 0===i?function(){}:i,o=e.onClose,s=void 0===o?function(){}:o,c=e.defaultOpen,u=void 0!==c&&c,l=e.open,d=void 0===l?void 0:l,f=e.disabled,p=void 0!==f&&f,h=e.nested,g=void 0!==h&&h,m=e.closeOnDocumentClick,y=void 0===m||m,v=e.repositionOnResize,b=void 0===v||v,C=e.closeOnEscape,E=void 0===C||C,w=e.on,k=void 0===w?["click"]:w,S=e.contentStyle,B=void 0===S?{}:S,T=e.arrowStyle,A=void 0===T?{}:T,I=e.overlayStyle,_=void 0===I?{}:I,x=e.className,P=void 0===x?"":x,R=e.position,N=void 0===R?"bottom center":R,O=e.modal,L=void 0!==O&&O,D=e.lockScroll,U=void 0!==D&&D,M=e.arrow,V=void 0===M||M,j=e.offsetX,F=void 0===j?0:j,z=e.offsetY,K=void 0===z?0:z,q=e.mouseEnterDelay,H=void 0===q?100:q,G=e.mouseLeaveDelay,Q=void 0===G?100:G,W=e.keepTooltipInside,X=void 0!==W&&W,Y=e.children,$=oy.useState(d||u),Z=$[0],J=$[1],ee=oy.useRef(null),te=oy.useRef(null),re=oy.useRef(null),ne=oy.useRef(null),ie=oy.useRef("popup-"+ ++BW),ae=!!L||!n,oe=oy.useRef(0);CW((function(){return Z?(ne.current=document.activeElement,ve(),ge(),pe()):he(),function(){clearTimeout(oe.current)}}),[Z]),oy.useEffect((function(){"boolean"==typeof d&&(d?se():ce())}),[d,p]);var se=function(e){Z||p||(J(!0),setTimeout((function(){return a(e)}),0))},ce=function(e){var t;Z&&!p&&(J(!1),ae&&(null===(t=ne.current)||void 0===t||t.focus()),setTimeout((function(){return s(e)}),0))},ue=function(e){null==e||e.stopPropagation(),Z?ce(e):se(e)},le=function(e){clearTimeout(oe.current),oe.current=setTimeout((function(){return se(e)}),H)},de=function(e){null==e||e.preventDefault(),ue()},fe=function(e){clearTimeout(oe.current),oe.current=setTimeout((function(){return ce(e)}),Q)},pe=function(){ae&&U&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},he=function(){ae&&U&&(document.getElementsByTagName("body")[0].style.overflow="auto")},ge=function(){var e,t=null==te||null===(e=te.current)||void 0===e?void 0:e.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),r=Array.prototype.slice.call(t)[0];null==r||r.focus()};oy.useImperativeHandle(t,(function(){return{open:function(){se()},close:function(){ce()},toggle:function(){ue()}}}));var me,ye,ve=function(){if(!ae&&Z&&(null==ee?void 0:ee.current)&&(null==ee?void 0:ee.current)&&(null==te?void 0:te.current)){var e,t,r=ee.current.getBoundingClientRect(),n=te.current.getBoundingClientRect(),i=SW(r,n,N,V,{offsetX:F,offsetY:K},X);if(te.current.style.top=i.top+window.scrollY+"px",te.current.style.left=i.left+window.scrollX+"px",V&&re.current)re.current.style.transform=i.transform,re.current.style.setProperty("-ms-transform",i.transform),re.current.style.setProperty("-webkit-transform",i.transform),re.current.style.top=(null===(e=A.top)||void 0===e?void 0:e.toString())||i.arrowTop,re.current.style.left=(null===(t=A.left)||void 0===t?void 0:t.toString())||i.arrowLeft}};me=ce,void 0===(ye=E)&&(ye=!0),oy.useEffect((function(){if(ye){var e=function(e){"Escape"===e.key&&me(e)};return document.addEventListener("keyup",e),function(){ye&&document.removeEventListener("keyup",e)}}}),[me,ye]),function(e,t){void 0===t&&(t=!0),oy.useEffect((function(){if(t){var r=function(t){if(9===t.keyCode){var r,n=null==e||null===(r=e.current)||void 0===r?void 0:r.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),i=Array.prototype.slice.call(n);if(1===i.length)return void t.preventDefault();var a=i[0],o=i[i.length-1];t.shiftKey&&document.activeElement===a?(t.preventDefault(),o.focus()):document.activeElement===o&&(t.preventDefault(),a.focus())}};return document.addEventListener("keydown",r),function(){t&&document.removeEventListener("keydown",r)}}}),[e,t])}(te,Z&&ae),function(e,t){void 0===t&&(t=!0),oy.useEffect((function(){if(t){var r=function(){e()};return window.addEventListener("resize",r),function(){t&&window.removeEventListener("resize",r)}}}),[e,t])}(ve,b),function(e,t,r){void 0===r&&(r=!0),oy.useEffect((function(){if(r){var n=function(r){var n=Array.isArray(e)?e:[e],i=!1;n.forEach((function(e){e.current&&!e.current.contains(r.target)||(i=!0)})),r.stopPropagation(),i||t(r)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),function(){r&&(document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n))}}}),[e,t,r])}(n?[te,ee]:[te],ce,y&&!g);var be,Ce=function(){return oy.createElement("div",Object.assign({},(e=ae?EW.popupContent.modal:EW.popupContent.tooltip,t={className:"popup-content "+(""!==P?P.split(" ").map((function(e){return e+"-content"})).join(" "):""),style:sW({},e,B,{pointerEvents:"auto"}),ref:te,onClick:function(e){e.stopPropagation()}},!L&&k.indexOf("hover")>=0&&(t.onMouseEnter=le,t.onMouseLeave=fe),t),{key:"C",role:ae?"dialog":"tooltip",id:ie.current}),V&&!ae&&oy.createElement("div",{ref:re,style:EW.popupArrow},oy.createElement("svg",{"data-testid":"arrow",className:"popup-arrow "+(""!==P?P.split(" ").map((function(e){return e+"-arrow"})).join(" "):""),viewBox:"0 0 32 16",style:sW({position:"absolute"},A)},oy.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),Y&&"function"==typeof Y?Y(ce,Z):Y);var e,t},Ee=!(k.indexOf("hover")>=0),we=ae?EW.overlay.modal:EW.overlay.tooltip,ke=[Ee&&oy.createElement("div",{key:"O","data-testid":"overlay","data-popup":ae?"modal":"tooltip",className:"popup-overlay "+(""!==P?P.split(" ").map((function(e){return e+"-overlay"})).join(" "):""),style:sW({},we,_,{pointerEvents:y&&g||ae?"auto":"none"}),onClick:y&&g?ce:void 0,tabIndex:-1},ae&&Ce()),!ae&&Ce()];return oy.createElement(oy.Fragment,null,function(){for(var e={key:"T",ref:ee,"aria-describedby":ie.current},t=Array.isArray(k)?k:[k],r=0,i=t.length;r<i;r++)switch(t[r]){case"click":e.onClick=ue;break;case"right-click":e.onContextMenu=de;break;case"hover":e.onMouseEnter=le,e.onMouseLeave=fe;break;case"focus":e.onFocus=le,e.onBlur=fe}if("function"==typeof n){var a=n(Z);return!!n&&oy.cloneElement(a,e)}return!!n&&oy.cloneElement(n,e)}(),Z&&NL.createPortal(ke,(null===(be=document.getElementById("popup-root"))&&((be=document.createElement("div")).setAttribute("id","popup-root"),document.body.appendChild(be)),be)))}));function AW(){return"function"==typeof navigator.enumerateDevices?navigator.enumerateDevices():"object"===$g(navigator.mediaDevices)&&"function"==typeof navigator.mediaDevices.enumerateDevices?navigator.mediaDevices.enumerateDevices():new Promise((function(e,t){try{if(null==window.MediaStreamTrack||null==window.MediaStreamTrack.getSources)throw new Error;window.MediaStreamTrack.getSources((function(t){e(t.filter((function(e){return"video"===e.kind.toLowerCase()||"videoinput"===e.kind.toLowerCase()})).map((function(e){return{deviceId:null!=e.deviceId?e.deviceId:"",groupId:e.groupId,kind:"videoinput",label:e.label,toJSON:function(){return this}}})))}))}catch(e){return t(e)}}))}var IW,_W=oC.Errors,xW=eC.div(cW||(cW=dm(["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background: #000;\n display: flex;\n justify-content: center;\n z-index: ",";\n ","\n"])),1e3,(function(e){return e.checkCameraMode&&"opacity: 0;"})),PW=eC.video(uW||(uW=dm(["\n width: 100%;\n ","\n"])),(function(e){return e.flipHorizontal&&"\n transform: scaleX(-1);\n "})),RW=eC.div(lW||(lW=dm(["\n cursor: pointer;\n text-align: center;\n width: 50px;\n\n img {\n width: 100%;\n }\n"]))),NW=eC(RW)(dW||(dW=dm(["\n z-index: ",";\n position: absolute;\n top: 20px;\n right: 20px;\n width: 20px;\n"])),1100),OW=eC.div(fW||(fW=dm(["\n z-index: ",";\n position: absolute;\n top: 40px;\n color: red;\n"])),1020),LW=eC.div(pW||(pW=dm(["\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: ",";\n"])),1030),DW=eC.section(hW||(hW=dm(["\n width: 260px;\n margin: 1.25rem;\n padding: 0.625rem 1.875rem;\n background: #ffffff;\n border-radius: 0.3125rem;\n box-shadow: 2px 2px 14px rgba(0, 0, 0, 0.15);\n"]))),UW=eC.header(gW||(gW=dm(["\n text-align: center;\n padding: 0.625rem 0;\n border-bottom: 1px solid #dddddd;\n"]))),MW=eC.h2(mW||(mW=dm(["\n margin: 0.25rem auto;\n padding: 0;\n font-weight: 600;\n font-size: 1.2rem;\n"]))),VW=eC.p(yW||(yW=dm(["\n padding: 0 0 0.3125rem;\n margin: 0.25rem auto;\n font-size: 0.8rem;\n"]))),jW=eC.ul(vW||(vW=dm(["\n list-style: none;\n padding: 0;\n"]))),FW=eC.li(bW||(bW=dm(["\n padding: 0.625rem 0 0.9375rem;\n margin: 0;\n text-align: left;\n width: 100%;\n cursor: pointer;\n font-size: 0.82rem;\n transition: all 550ms ease-in-out;\n\n &:hover {\n opacity: 0.8;\n }\n"]))),zW=function(){if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)return navigator.mediaDevices;var e=navigator.mozGetUserMedia||navigator.webkitGetUserMedia;return e?{getUserMedia:function(t){return new Promise((function(r,n){e.call(navigator,t,r,n)}))}}:null}();function KW(e){var t=e.checkCameraMode,r=e.frontCamera,n=e.onClose,i=e.children,a=e.onVideoPlayed,o=e.flipHorizontal,s=e.videoSettings,c=e.refVideo,u=e.onError,l=e.closeButton,d=e.videoClassName,f=lC.useSDKSettings().lang,p=ok.useSDKTracking().sendEvent,h=uk.useAsset("ic_close.png"),g=fm(oy.useState(""),2),m=g[0],y=g[1],v=fm(oy.useState([]),2),b=v[0],C=v[1],E=fm(oy.useState(!1),2),w=E[0],k=E[1],S=oy.useRef(!1),B=oy.useRef(!1),T=oy.useCallback((function(){try{var e;(null==c||null===(e=c.current)||void 0===e?void 0:e.srcObject)instanceof MediaStream&&(c.current.srcObject.getTracks().forEach((function(e){return e.stop()})),c.current.srcObject=null)}catch(e){}}),[c]),A=oy.useCallback(function(){var e=Jg(regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},n=JH.isMobile?JH.isIOS?{width:{ideal:1460},aspectRatio:{ideal:window.innerHeight/window.innerWidth}}:{width:{ideal:1650},aspectRatio:{ideal:window.innerHeight/window.innerWidth}}:{height:{ideal:9999}},e.prev=2,e.next=5,zW.getUserMedia({audio:!1,video:om(om({},t?{deviceId:t}:{facingMode:r?"user":"environment"}),s||n)});case 5:return(i=e.sent)||(y(_W.not_supported.msg[f]),u(_W.not_supported)),e.abrupt("return",i);case 10:e.prev=10,e.t0=e.catch(2),"NotAllowedError"===e.t0.name?(y(_W.no_permission.msg[f]),u(_W.no_permission)):(k(!0),y(e.t0.message),u({code:e.t0.name||e.t0.code}));case 13:return e.abrupt("return",null);case 14:case"end":return e.stop()}}),e,null,[[2,10]])})));return function(t){return e.apply(this,arguments)}}(),[r,s,f,u]),I=oy.useCallback(function(){var e=Jg(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=c.current).oncanplaythrough=function(){r.play(),B.current=!0,y("");var e=window.innerWidth,t=window.innerHeight,n=Uk.analyzeVideoAndWindowSizes(r),i=n.lostX,o=void 0===i?0:i,s=n.lostY,c=void 0===s?0:s,u=Math.min(e,Math.floor(e-2*o)),l=Math.min(t,Math.floor(t-2*c));a&&a({clientWidth:e,clientHeight:t,videoAreaWidth:u,videoAreaHeight:l,lostX:o,lostY:c})},e.next=4,A(t);case 4:(n=e.sent)&&(r.srcObject=n);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[c,A,a]);oy.useEffect((function(){function e(){return(e=Jg(regeneratorRuntime.mark((function e(){var t,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,AW();case 3:t=e.sent,r=t.filter((function(e){return e.deviceId&&"videoinput"===e.kind})),C(r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),console.error(e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})))).apply(this,arguments)}w&&!S.current&&(S.current=!0,function(){e.apply(this,arguments)}())}),[w]),oy.useEffect((function(){function e(){return(e=Jg(regeneratorRuntime.mark((function e(){var t,r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,I();case 2:return e.next=4,AW();case 4:t=e.sent,(r=t.filter((function(e){return"videoinput"===e.kind&&e.label.includes("0")}))).length>0&&(n=r[0].deviceId,T(),I(n));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var t=c.current;return!zW||JH.browserName&&["facebook"].includes(JH.browserName.toLowerCase())||JH.getUA.includes("Zalo iOS")?(y(_W.not_supported.msg[f]),u(_W.not_supported)):t&&(JH.isAndroid&&!1===r?function(){e.apply(this,arguments)}():I()),function(){T()}}),[c,f,r,I,T,u]),oy.useEffect((function(){var e=setTimeout((function(){B.current||(y(_W.camera_timeout.msg[f]),u(_W.camera_timeout))}),3e5);return function(){clearTimeout(e)}}),[f,u]);var _=oy.useCallback((function(){T(),n&&n(),p({tag:"result",event:"user_activity.cancel",log:{}})}),[n,T,p]);return oy.createElement(xW,{checkCameraMode:t},w&&null!=b&&b.length?oy.createElement(LW,null,oy.createElement(DW,null,oy.createElement(UW,null,oy.createElement(MW,null,"Không thể mở camera mặc định"),oy.createElement(VW,null,"Vui lòng thử chọn camera khác trong danh sách dưới đây")),oy.createElement(jW,null,b.map((function(e,t){return oy.createElement(FW,{key:e.deviceId,onClick:function(){y(""),T(),k(!1),I(e.deviceId)}},e.label?e.label:"Camera ".concat(t+1))}))))):null,function(){if(!m)return null;var e=_W.no_permission.msg[f];return m===e&&JH.isIOS?oy.createElement(OW,null,m," ",oy.createElement("button",{onClick:function(){window.location.reload()}},{vi:"Cấp lại quyền truy cập camera",en:"Request camera permission"}[f])):oy.createElement(OW,null,m)}(),oy.createElement(PW,{ref:c,playsInline:!0,muted:!0,flipHorizontal:o,className:d}),i,l?oy.cloneElement(l,{onClick:_,"data-testid":"close-camera"}):oy.createElement(NW,{onClick:_,"data-testid":"close-camera"},oy.createElement("img",{src:h,alt:""})))}KW.propTypes={checkCameraMode:Py.bool,frontCamera:Py.bool,onClose:Py.func,onError:Py.func,onVideoPlayed:Py.func,children:Py.node,flipHorizontal:Py.bool,videoSettings:Py.object,refVideo:Py.object,closeButton:Py.node,videoClassName:Py.string},KW.defaultProps={checkCameraMode:!1,frontCamera:!0,onClose:null,onError:function(){},onVideoPlayed:null,children:null,flipHorizontal:!1,videoSettings:null,refVideo:null,closeButton:null,videoClassName:""};var qW,HW,GW,QW,WW,XW,YW,$W,ZW,JW,eX,tX,rX,nX,iX,aX=rC(IW||(IW=dm(["\n .popup-content {\n margin: auto;\n background: #fff;\n width: 100%;\n padding: 5px;\n border: 1px solid #d7d7d7;\n max-width: 568px;\n border-radius: 10px;\n }\n\n [role=tooltip].popup-content {\n width: 200px;\n box-shadow: 0 0 3px rgba(0, 0, 0, .16);\n border-radius: 5px\n }\n\n .popup-overlay {\n background: rgba(0, 0, 0, .5);\n padding: 10px;\n }\n\n [data-popup=tooltip].popup-overlay {\n background: transparent\n }\n\n .popup-arrow {\n -webkit-filter: drop-shadow(0 -3px 3px rgba(0, 0, 0, .16));\n filter: drop-shadow(0 -3px 3px rgba(0, 0, 0, .16));\n color: #fff;\n stroke-width: 2px;\n stroke: #d7d7d7;\n stroke-dasharray: 30px;\n stroke-dashoffset: -54px;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0\n }\n"]))),oX=["open","children","overlayStyle"],sX=function(e){var t=e.open,r=e.children,n=e.overlayStyle,i=lm(e,oX);return oy.createElement(oy.Fragment,null,oy.createElement(TW,im({overlayStyle:om(om({},n),{},{zIndex:2e3}),closeOnDocumentClick:!1,closeOnEscape:!1,modal:!0,open:t},i),r),oy.createElement(aX,null))};sX.propTypes={open:Py.bool,children:Py.node,overlayStyle:Py.shape({})},sX.defaultProps={open:!1,children:null,overlayStyle:{}};var cX,uX,lX,dX=oz.flipY,fX=oz.spin,pX=oz.splash,hX=dX.animationDuration,gX=pX.default,mX=eC.div(qW||(qW=dm(["\n ","\n ","\n"])),dX.default,fX.default),yX=(eC.img(HW||(HW=dm(["\n border-radius: 5px;\n opacity: 0.7;\n height: 38px;\n"]))),eC.div(GW||(GW=dm(["\n cursor: pointer;\n text-align: center;\n width: ","px;\n\n img {\n width: 100%;\n }\n\n z-index: ",";\n position: fixed;\n\n ","\n"])),60,1020,JH.isMobile?Vb(["top:",";"],(function(e){return e.y})):Vb(["bottom:","px;"],10))),vX=eC.div(QW||(QW=dm(["\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n position: absolute;\n margin: auto;\n width: ","px;\n height: ","px;\n\n img {\n width: 100%;\n }\n\n z-index: ",";\n"])),80,80,1020),bX=eC.div(WW||(WW=dm(["\n color: #fff;\n text-align: center;\n"]))),CX=eC.div(XW||(XW=dm(["\n transform: translateZ(1000px); // to fix rotating bug on safari\n transform-style: preserve-3d;\n position: absolute;\n top: ",";\n z-index: ",";\n"])),(function(e){return e.y}),1020),EX=eC.div(YW||(YW=dm(["\n display: flex;\n align-items: center;\n"]))),wX=eC(bX)($W||($W=dm(["\n font-size: ","px;\n color: #38383d;\n font-weight: 500;\n"])),JH.isMobile?16:24),kX=eC.div(ZW||(ZW=dm(["\n margin: 0 auto;\n padding: 0 5px;\n position: absolute;\n top: ",";\n z-index: ",";\n"])),(function(e){return e.y}),1020),SX=eC(bX)(JW||(JW=dm(["\n text-align: center;\n color: ",";\n font-weight: 500;\n padding: 5px 10px;\n font-size: ","px;\n"])),(function(e){return e.theme.dangerColor}),JH.isMobile?14:16),BX=function(e){var t=e.children,r=e.y;return oy.createElement(kX,{y:r},oy.createElement(SX,null,t))},TX=eC(AF)(eX||(eX=dm(["\n position: absolute;\n top: 0;\n left: 0;\n"]))),AX=eC(bX)(tX||(tX=dm(["\n color: ",";\n font-weight: 500;\n padding: 5px 10px;\n font-size: ","px;\n position: absolute;\n text-align: center;\n top: ",";\n z-index: ",";\n"])),(function(e){return e.theme.dangerColor}),JH.isMobile?14:16,(function(e){return e.y}),1020),IX=eC(bX)(rX||(rX=dm(["\n font-weight: normal;\n padding: 5px 10px;\n color: #38383d;\n font-size: ","px;\n position: absolute;\n text-align: center;\n top: ",";\n z-index: ",";\n"])),JH.isMobile?14:16,(function(e){return e.y}),1020),_X=eC.div(nX||(nX=dm(["\n cursor: pointer;\n text-align: center;\n width: 50px;\n\n img {\n width: 100%;\n }\n"]))),xX=eC(_X)(iX||(iX=dm(["\n z-index: ",";\n position: absolute;\n ","\n top: 16px;\n width: 24px;\n"])),1100,JH.isMobile?"left: 16px;":"right: 16px;"),PX=oC.Errors,RX={BTN_OK:{en:"OK",vi:"Tôi đã hiểu"},FRONT:{en:"front",vi:"trước"},BACK:{en:"back",vi:"sau"},BTN_USE_THIS_PICTURE:{en:"Use this picture",vi:"Nhìn ổn đấy!"},BTN_TRY_AGAIN:{en:"Try again",vi:"Chụp lại"},CONFIRM_POPUP_VALID_QR:{en:"QR code scanned",vi:"Đã quét được mã QR"},CONFIRM_POPUP_INVALID_QR:{en:"Could not scan QR code",vi:"Không quét được mã QR"}},NX=om(om({},PX),{},{id_detector_no_cards:{code:"id_detector_no_cards",msg:{en:"Take a photo of your ID card's <%= side %> side. Make sure the image of the card fits in the frame, (minimum 50% of frame).",vi:"Mặt <%= side %> CMND/CCCD cần nằm gọn trong khung hình, chiếm tối thiểu 50%."}},id_detector_validate_angle_error:{code:"id_detector_validate_angle_error",msg:{en:"Please put your ID card straight, not be oblique",vi:"Vui lòng đặt giấy tờ thẳng góc, không bị xô lệch khi chụp"}},id_detector_card_too_small:{code:"id_detector_card_too_small",msg:{en:"Please hold your ID card closer",vi:"Vui lòng đưa CMND/CCCD lại gần hơn"}},id_detector_error_incomplete:{code:"id_detector_error_incomplete",msg:{en:"Please hold your ID card further",vi:"Vui lòng đưa CMND/CCCD ra xa hơn"}},id_detector_error_front_side_no_faces:{code:"id_detector_error_front_side_no_faces",msg:{en:"Take a photo of your ID card's front side",vi:"Vui lòng chụp ảnh mặt trước của CMND/CCCD"}},id_detector_error_front_side_multiple_faces:{code:"id_detector_error_front_side_multiple_faces",msg:{en:"Please remove other items out of the frame",vi:"Vui lòng không để lẫn vật thể khác trong khung chụp hình"}},glare_detected:{code:"glare_detected",msg:{en:"Your photo ID is glare. Please adjust the shooting angle.",vi:"Ảnh chụp bị lóa sáng. Vui lòng chụp lại"}}}),OX=oC.IDCardMessage,LX=eC.div(cX||(cX=dm(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n padding: 10px;\n"]))),DX=eC.div(uX||(uX=dm(["\n text-align: center;\n font-size: 1rem;\n"]))),UX=eC.button(lX||(lX=dm(["\n margin-top: 20px;\n width: 100%;\n max-width: 160px;\n height: 50px;\n background-color: ",";\n border: 0;\n outline: none;\n border-radius: 0.25rem;\n color: #fff;\n font-weight: 400;\n cursor: pointer;\n font-size: 1rem;\n"])),(function(e){return e.theme.primaryColor})),MX=function(e){var t=e.onOk,r=e.maxSessionTime,n=lC.useSDKSettings().lang;return oy.createElement(LX,null,oy.createElement(DX,null,aW(OX.TIMEOUT_INSTRUCTION[n])({x:r})),oy.createElement(UX,{onClick:t},RX.BTN_OK[n]))};MX.propTypes={onOk:Py.func,maxSessionTime:Py.number},MX.defaultProps={onOk:function(){},maxSessionTime:30};var VX,jX,FX,zX=oC.IDCardMessage,KX=oy.forwardRef((function(e,t){var r,n=e.usePortraitMask,i=e.windowAndVideoInfo,a=e.refVideo,o=e.frontSide,s=e.settings,c=e.onCaptureDone,u=e.onUISpacingChange,l=e.outputEncryptionSettings,d=fm(oy.useState({}),2),f=d[0],p=d[1],h=f.yErrorMessage,g=f.yDescription,m=f.yCaptureButton,y=f.yMessage,v=uk.useAsset("ic_camera.png"),b=uk.useAsset("ic_camera_disabled.png"),C=uk.useAsset("ic_id_front.png"),E=uk.useAsset("ic_id_back.png"),w=uk.useAsset("ic_loading.png"),k=lC.useSDKSettings().lang,S=fm(oy.useState(""),2),B=S[0],T=S[1],A=fm(oy.useState(null),2),I=A[0],_=A[1],x=DB.useThemeContext(),P=fm(oy.useState(null),2),R=P[0],N=P[1],O=x.primaryColor,L=x.dangerColor,D=function(){var e=fm(oy.useState(!1),2),t=e[0],r=e[1],n=fm(oy.useState(null),2),i=n[0],a=n[1],o=fm(oy.useState({}),2),s=o[0],c=o[1];return{showPopup:oy.useCallback((function(e){var t=e.popupType,n=e.props;c(void 0===n?{}:n),a(t),r(null!==t)}),[]),popupShown:t,popupType:i,props:s}}(),U=D.showPopup,M=D.popupShown,V=D.popupType,j=oy.useRef((function(){})),F=oy.useCallback((function(e){T(null===e?"":aW(NX[e.code].msg[k])({side:o?RX.FRONT[k]:RX.BACK[k]}))}),[k,o]),z=oy.useCallback((function(){N(""),U({popupType:oW})}),[U]),K=oy.useCallback((function(e){var t=e.curTimeLeft;N(aW(zX.REMAINING_TIME[k])({x:t}))}),[k]),q=uK({shouldStart:!0,refVideo:a,cropArea:I,settings:s,onModelErrorChange:F,frontSide:o,onSessionTimeout:z,onCaptureDone:c,onAboutToTimeout:K,outputEncryptionSettings:l}),H=q.warmupDone,G=q.isProcessing,Q=q.takePictureManually,W=q.restartSession,X=q.resetIsProcessingImageBlobTaken,Y=oy.useCallback((function(){U({popupType:null}),X()}),[U,X]),$=oy.useCallback(Jg(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Y(),e.next=3,W();case 3:case"end":return e.stop()}}),e)}))),[W,Y]);j.current=$,oy.useEffect((function(){if(i){var e,t,r,a,o,s,c,l,d=i.videoAreaWidth,f=i.videoAreaHeight,h=i.lostX,g=i.lostY,m=i.clientHeight;n?(s=.7*(c=f-165),r=(l=(e=g+10)+45)+20,a=l+c+70):(s=JH.isMobile?d-8:Math.floor(.7*d),c=Math.floor(Math.min(s/1.5,m-2*g-80-145)),r=(t=(l=(e=g+16)+(JH.isMobile?40:65))+c+10)+(JH.isMobile?35:25),o=JH.isMobile?t+60:e+30,a=t+158);var y=Math.floor((d-s)/2)+h;_({x:y,y:l,width:s,height:c,surroundStyle:{background:"#fff"}});var v={yTitle:e,yErrorMessage:t,yMessage:r,yDescription:o,yCaptureButton:a};p(v),u(v)}}),[i,n,u]);var Z=oy.useCallback(Jg(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return N(""),e.next=3,Q();case 3:case"end":return e.stop()}}),e)}))),[Q]);oy.useImperativeHandle(t,(function(){return{restartSession:$}}),[$]);var J=!(G||null!=s&&s.disableCaptureButtonIfAlert&&B);return oy.createElement(oy.Fragment,null,!H&&oy.createElement(Pj,null),G&&oy.createElement(vX,null,oy.createElement("img",{src:w,alt:"",className:"spin"})),I&&oy.createElement(UD,{x:"".concat(I.x,"px"),y:"".concat(I.y,"px"),width:"".concat(I.width,"px"),height:"".concat(I.height,"px"),surroundStyle:I.surroundStyle},oy.createElement(TX,{strokeStyles:(r={},nm(r,TF.DEFAULT,{fill:"none",strokeWidth:5,stroke:O}),nm(r,TF.ERROR,{fill:"none",strokeWidth:5,stroke:O}),r),paddingStyle:{fill:"#fff"},strokeWidth:5,errorColor:L,width:I.width,height:I.height,type:B?TF.ERROR:TF.DEFAULT})),B&&oy.createElement(BX,{y:"".concat(h,"px")},B),oy.createElement(IX,{y:"".concat(g,"px")},JH.isMobile&&oy.createElement("div",null,oy.createElement("img",{src:o?C:E,width:70,height:45,alt:""})),"Đặt CMND/CCCD của bạn vào giữa khung. Hình ảnh rõ ràng, không bị chói, mờ & cắt góc."),oy.createElement(yX,{onClick:J?Z:null,y:"".concat(m,"px")},oy.createElement("img",{src:J?v:b,alt:""})),R&&oy.createElement(AX,{key:R,y:"".concat(y,"px")},R),oy.createElement(sX,{open:M},V===oW&&oy.createElement(MX,{onOk:$,maxSessionTime:null==s?void 0:s.idCardSessionTime})))}));KX.propTypes={usePortraitMask:Py.bool,windowAndVideoInfo:Py.shape({}),refVideo:Py.shape({}),frontSide:Py.bool,settings:Py.shape({}),onCaptureDone:Py.func,onUISpacingChange:Py.func,outputEncryptionSettings:Py.shape({})},KX.defaultProps={usePortraitMask:!1,windowAndVideoInfo:{},refVideo:{},frontSide:!0,settings:{},onCaptureDone:function(){},onUISpacingChange:function(){},outputEncryptionSettings:null};var qX,HX,GX,QX,WX,XX,YX,$X,ZX,JX,eY=eC.button(VX||(VX=dm(["\n background: #0b74e5;\n height: 44px;\n border-radius: 4px;\n border: 0;\n padding: 0 20px;\n color: #fff;\n cursor: pointer;\n font-size: 16px;\n font-weight: 500;\n width: 160px;\n"]))),tY=eC.button(jX||(jX=dm(["\n background: #fff;\n height: 44px;\n border-radius: 4px;\n border: 1px solid #0b74e5;\n padding: 0 20px;\n color: #0b74e5;\n cursor: pointer;\n font-size: 16px;\n font-weight: 500;\n width: 160px;\n &:focus {\n outline: none;\n box-shadow: none;\n }\n"]))),rY=(eC.a(FX||(FX=dm(["\n text-decoration: underline;\n font-size: 16px;\n color: #000;\n cursor: pointer;\n"]))),eC.div(qX||(qX=dm(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n padding: 10px;\n"])))),nY=eC.div(HX||(HX=dm(["\n text-align: center;\n font-size: 1rem;\n color: ",";\n margin-top: 10px;\n"])),(function(e){return e.theme.dangerColor})),iY=eC.img(GX||(GX=dm(["\n width: 100%;\n height: 100%;\n object-fit: contain;\n border-radius: 3px;\n"]))),aY=eC.div(QX||(QX=dm(["\n margin: 20px 0;\n width: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n"]))),oY=eC.div(WX||(WX=dm(["\n margin-right: 5px;\n"]))),sY=eC.div(XX||(XX=dm(["\n margin-left: 5px;\n"]))),cY=eC.div(YX||(YX=dm(["\n width: 100%;\n max-width: 960px;\n border: 5px solid #1aa7ff;\n border-radius: 8px;\n margin-top: ","px;\n"])),JH.isMobile?20:0),uY=eC.div($X||($X=dm(["\n font-size: ","px;\n font-weight: 500;\n color: #38383d;\n"])),JH.isMobile?16:24),lY=eC.div(ZX||(ZX=dm(["\n margin: 8px 0;\n font-size: ","px;\n font-weight: normal;\n color: #38383d;\n text-align: center;\n"])),JH.isMobile?14:16),dY=eC.div(JX||(JX=dm(["\n margin-top: 20px;\n font-size: ","px;\n font-weight: normal;\n color: #38383d;\n text-align: center;\n"])),JH.isMobile?14:16),fY=function(e){var t=e.title,r=e.imageTaken,n=e.onConfirm,i=e.onTryAgain,a=e.error,o=e.hasValidQR,s=fm(oy.useState(null),2),c=s[0],u=s[1],l=lC.useSDKSettings().lang,d=uk.useAsset("ic_close.png"),f=uk.useAsset("ic_close_desktop.png");return oy.useEffect((function(){var e;return r&&(e=URL.createObjectURL(r.blob),u(e)),function(){URL.revokeObjectURL(e)}}),[r]),oy.createElement(rY,null,null!==o&&oy.createElement(bK,{mb:"20px"},oy.createElement("div",null,oy.createElement(Rq,{type:o?Bq.SUCCESS:Bq.WARNING},o?RX.CONFIRM_POPUP_VALID_QR[l]:RX.CONFIRM_POPUP_INVALID_QR[l]))),oy.createElement(uY,null,t),!JH.isMobile&&oy.createElement(lY,null,"Đặt CMND / CCCD của bạn vào giữa khung. Hình ảnh rõ ràng, không bị chói mờ & cắt góc."),oy.createElement(cY,null,oy.createElement(HK,{ratio:1.5},oy.createElement(iY,{src:c}))),oy.createElement(dY,null,"Nhìn ổn chứ? Bạn có thể tự chụp lại để có ảnh tốt hơn."),a&&oy.createElement(nY,{className:"confirm-popup-error-message"},a.msg[l]),oy.createElement(aY,null,oy.createElement(oY,null,oy.createElement(tY,{type:"button",onClick:i},RX.BTN_TRY_AGAIN[l])),oy.createElement(sY,null,oy.createElement(eY,{onClick:n},RX.BTN_USE_THIS_PICTURE[l]))),oy.createElement(xX,{onClick:i},oy.createElement("img",{src:JH.isMobile?d:f,alt:""})))};fY.propTypes={imageTaken:Py.shape({}),error:Py.shape({msg:Py.shape({})}),onConfirm:Py.func,onTryAgain:Py.func,hasValidQR:Py.bool,title:Py.string},fY.defaultProps={imageTaken:null,error:null,onConfirm:function(){},onTryAgain:function(){},hasValidQR:null,title:""};var pY,hY={primaryColor:"#1AA7FF",dangerColor:"#FF424E"},gY="CONFIRM",mY=rC(pY||(pY=dm(["\n"]))),yY=oC.IDCardSide,vY=oC.IDCardType,bY="id_card",CY="qr_code",EY=[{scannerType:bY,title:"Chụp mặt trước",cardSide:oC.IDCardSide.FRONT,cardType:vY.VN,frontCamera:!1,enableConfirmPopup:!0},{scannerType:bY,title:"Chụp mặt sau",cardSide:oC.IDCardSide.BACK,cardType:vY.VN,frontCamera:!1,enableConfirmPopup:!0}];function wY(e){var t=e.onClose,r=e.onError,n=e.clientSettings,i=e.onStepDone,a=e.steps,o=e.outputEncryptionSettings,s=fm(oy.useState(0),2),c=s[0],u=s[1],l=fm(oy.useState(a[c]),2),d=l[0],f=l[1],p=oy.useRef(null),h=fm(oy.useState(null),2),g=h[0],m=h[1],y=fm(oy.useState(!1),2),v=y[0],b=y[1],C=fm(oy.useState(0),2),E=C[0],w=C[1],k=oy.useRef(),S=d.scannerType,B=d.frontCamera,T=d.title,A=d.cardSide,I=d.usePortraitMask,_=d.enableConfirmPopup,x=uk.useAsset("ic_close.png"),P=uk.useAsset("ic_close_desktop.png"),R=uk.useAsset("ic_loading.png"),N=A===yY.FRONT,O=Az(),L=O.showPopup,D=O.popupShown,U=O.popupType,M=O.props,V=fm(oy.useState(!1),2),j=V[0],F=V[1],z=oy.useRef(null),K=oy.useRef(null),q=oy.useRef([]),H=tH({clientSettings:n}).settings,G=fm(oy.useState({}),2),Q=G[0],W=G[1],X=Q.yTitle,Y=ok.useSDKTracking().sendEvent,$=oy.useCallback((function(e){m(e),b(!0)}),[]);oy.useEffect((function(){b(!1)}),[B]);var Z=oy.useCallback((function(){L({popupType:null})}),[L]),J=oy.useCallback((function(e){e>=a.length||setTimeout((function(){u(e),f(a[e])}),200)}),[a]),ee=oy.useCallback((function(){J(c+1)}),[J,c]),te=oy.useCallback(Jg(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={stepNumber:c,image:z.current,recordedVideos:null!=H&&H.enableRecording?q.current:[]},S===CY&&(t.qrScannedResult=K.current),F(!0),e.next=5,i(t);case 5:Y({tag:"result",event:"sdk_mode.read_id_card_one_side",log:{result_object:t}}),F(!1),ee();case 8:case"end":return e.stop()}}),e)}))),[H,c,i,ee,S,Y]),re=oy.useCallback((function(){Z(),S===CY?J(c):S===bY&&(Y({tag:N?"id_front":"id_back",event:"user_activity.retry",log:{}}),k.current.restartSession())}),[J,c,Z,S,N,Y]),ne=oy.useCallback((function(){Z(),Y({tag:N?"id_front":"id_back",event:"user_activity.submit",log:{}}),te()}),[te,Z,Y,N]),ie=oy.useCallback(function(){var e=Jg(regeneratorRuntime.mark((function e(t){var r,n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.image,n=t.error,i=t.recordedVideos,z.current=r,q.current=i,w((function(e){return e+1})),_?L({popupType:gY,props:{title:T,imageTaken:z.current,error:n}}):te();case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[_,L,te,T]);return oy.createElement($b,{theme:hY},oy.createElement(mX,null,oy.createElement(PD,{key:B,frontCamera:B,onVideoPlayed:$,onClose:t,flipHorizontal:B,ref:p,onError:r,closeButton:oy.createElement(xX,null,oy.createElement("img",{src:JH.isMobile?x:P,alt:""}))},v&&oy.createElement(oy.Fragment,null,S===bY&&oy.createElement(KX,{key:c,ref:k,windowAndVideoInfo:g,refVideo:p,settings:H,onCaptureDone:ie,onUISpacingChange:W,frontSide:N,usePortraitMask:I,outputEncryptionSettings:o})),oy.createElement(gX,{keyForTransition:E}),oy.createElement(CX,{y:"".concat(X,"px")},oy.createElement(ZH,null,oy.createElement(GH,{key:T,timeout:{enter:hX,exit:hX},classNames:"flipY",unmountOnExit:!0},oy.createElement(EX,null,oy.createElement(wX,null,T))))),j&&oy.createElement(vX,null,oy.createElement("img",{src:R,alt:"",className:"spin"}))),oy.createElement(fj,{open:D,overlayStyle:{padding:0},contentStyle:{maxWidth:"none",width:"100%",height:"100%",borderRadius:0}},U===gY&&oy.createElement(fY,im({},M,{onConfirm:ne,onTryAgain:re})))),oy.createElement(mY,null))}wY.propTypes={onClose:Py.func,onError:Py.func,clientSettings:Py.shape({}),detectIdCard:Py.func,onStepDone:Py.func,steps:Py.arrayOf(Py.shape({})),outputEncryptionSettings:Py.shape({})},wY.defaultProps={onClose:function(){},onError:function(){},clientSettings:{},detectIdCard:function(){return Promise.resolve({card_label:""})},onStepDone:function(){},steps:EY,outputEncryptionSettings:null};var kY=function(e,t,r,n,i,a,o,s){if(!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,i,a,o,s],l=0;(c=new Error(t.replace(/%s/g,(function(){return u[l++]})))).name="Invariant Violation"}throw c.framesToPop=1,c}},SY=i(a((function(e,t){!function(e,t){t=t&&t.hasOwnProperty("default")?t.default:t;var r=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/read_id_card_info_sync",e,t)},e}(),i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};
61
+ */!function(i,a){var o="function",s="undefined",c="object",u="model",l="name",d="type",f="vendor",p="version",h="architecture",g="console",m="mobile",y="tablet",v="smarttv",b="wearable",C={extend:function(e,t){var r={};for(var n in e)t[n]&&t[n].length%2==0?r[n]=t[n].concat(e[n]):r[n]=e[n];return r},has:function(e,t){return"string"==typeof e&&-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()},major:function(e){return"string"==typeof e?e.replace(/[^\d\.]/g,"").split(".")[0]:a},trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},E={rgx:function(e,t){for(var r,n,i,s,u,l,d=0;d<t.length&&!u;){var f=t[d],p=t[d+1];for(r=n=0;r<f.length&&!u;)if(u=f[r++].exec(e))for(i=0;i<p.length;i++)l=u[++n],typeof(s=p[i])===c&&s.length>0?2==s.length?typeof s[1]==o?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:3==s.length?typeof s[1]!==o||s[1].exec&&s[1].test?this[s[0]]=l?l.replace(s[1],s[2]):a:this[s[0]]=l?s[1].call(this,l,s[2]):a:4==s.length&&(this[s[0]]=l?s[3].call(this,l.replace(s[1],s[2])):a):this[s]=l||a;d+=2}},str:function(e,t){for(var r in t)if(typeof t[r]===c&&t[r].length>0){for(var n=0;n<t[r].length;n++)if(C.has(t[r][n],e))return"?"===r?a:r}else if(C.has(t[r],e))return"?"===r?a:r;return e}},w={browser:{oldsafari:{version:{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}}},device:{amazon:{model:{"Fire Phone":["SD","KF"]}},sprint:{model:{"Evo Shift 4G":"7373KT"},vendor:{HTC:"APA",Sprint:"Sprint"}}},os:{windows:{version:{ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"}}}},k={browser:[[/(opera\smini)\/([\w\.-]+)/i,/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i,/(opera).+version\/([\w\.]+)/i,/(opera)[\/\s]+([\w\.]+)/i],[l,p],[/(opios)[\/\s]+([\w\.]+)/i],[[l,"Opera Mini"],p],[/\s(opr)\/([\w\.]+)/i],[[l,"Opera"],p],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i,/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i,/(?:ms|\()(ie)\s([\w\.]+)/i,/(rekonq)\/([\w\.]*)/i,/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark)\/([\w\.-]+)/i],[l,p],[/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i],[[l,"IE"],p],[/(edge|edgios|edgea)\/((\d+)?[\w\.]+)/i],[[l,"Edge"],p],[/(yabrowser)\/([\w\.]+)/i],[[l,"Yandex"],p],[/(puffin)\/([\w\.]+)/i],[[l,"Puffin"],p],[/((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i],[[l,"UCBrowser"],p],[/(comodo_dragon)\/([\w\.]+)/i],[[l,/_/g," "],p],[/(micromessenger)\/([\w\.]+)/i],[[l,"WeChat"],p],[/(qqbrowserlite)\/([\w\.]+)/i],[l,p],[/(QQ)\/([\d\.]+)/i],[l,p],[/m?(qqbrowser)[\/\s]?([\w\.]+)/i],[l,p],[/(BIDUBrowser)[\/\s]?([\w\.]+)/i],[l,p],[/(2345Explorer)[\/\s]?([\w\.]+)/i],[l,p],[/(MetaSr)[\/\s]?([\w\.]+)/i],[l],[/(LBBROWSER)/i],[l],[/xiaomi\/miuibrowser\/([\w\.]+)/i],[p,[l,"MIUI Browser"]],[/;fbav\/([\w\.]+);/i],[p,[l,"Facebook"]],[/headlesschrome(?:\/([\w\.]+)|\s)/i],[p,[l,"Chrome Headless"]],[/\swv\).+(chrome)\/([\w\.]+)/i],[[l,/(.+)/,"$1 WebView"],p],[/((?:oculus|samsung)browser)\/([\w\.]+)/i],[[l,/(.+(?:g|us))(.+)/,"$1 $2"],p],[/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i],[p,[l,"Android Browser"]],[/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i],[l,p],[/(dolfin)\/([\w\.]+)/i],[[l,"Dolphin"],p],[/((?:android.+)crmo|crios)\/([\w\.]+)/i],[[l,"Chrome"],p],[/(coast)\/([\w\.]+)/i],[[l,"Opera Coast"],p],[/fxios\/([\w\.-]+)/i],[p,[l,"Firefox"]],[/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i],[p,[l,"Mobile Safari"]],[/version\/([\w\.]+).+?(mobile\s?safari|safari)/i],[p,l],[/webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i],[[l,"GSA"],p],[/webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i],[l,[p,E.str,w.browser.oldsafari.version]],[/(konqueror)\/([\w\.]+)/i,/(webkit|khtml)\/([\w\.]+)/i],[l,p],[/(navigator|netscape)\/([\w\.-]+)/i],[[l,"Netscape"],p],[/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i,/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i,/(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i,/(links)\s\(([\w\.]+)/i,/(gobrowser)\/?([\w\.]*)/i,/(ice\s?browser)\/v?([\w\._]+)/i,/(mosaic)[\/\s]([\w\.]+)/i],[l,p]],cpu:[[/(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i],[[h,"amd64"]],[/(ia32(?=;))/i],[[h,C.lowerize]],[/((?:i[346]|x)86)[;\)]/i],[[h,"ia32"]],[/windows\s(ce|mobile);\sppc;/i],[[h,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i],[[h,/ower/,"",C.lowerize]],[/(sun4\w)[;\)]/i],[[h,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+;))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i],[[h,C.lowerize]]],device:[[/\((ipad|playbook);[\w\s\);-]+(rim|apple)/i],[u,f,[d,y]],[/applecoremedia\/[\w\.]+ \((ipad)/],[u,[f,"Apple"],[d,y]],[/(apple\s{0,1}tv)/i],[[u,"Apple TV"],[f,"Apple"]],[/(archos)\s(gamepad2?)/i,/(hp).+(touchpad)/i,/(hp).+(tablet)/i,/(kindle)\/([\w\.]+)/i,/\s(nook)[\w\s]+build\/(\w+)/i,/(dell)\s(strea[kpr\s\d]*[\dko])/i],[f,u,[d,y]],[/(kf[A-z]+)\sbuild\/.+silk\//i],[u,[f,"Amazon"],[d,y]],[/(sd|kf)[0349hijorstuw]+\sbuild\/.+silk\//i],[[u,E.str,w.device.amazon.model],[f,"Amazon"],[d,m]],[/\((ip[honed|\s\w*]+);.+(apple)/i],[u,f,[d,m]],[/\((ip[honed|\s\w*]+);/i],[u,[f,"Apple"],[d,m]],[/(blackberry)[\s-]?(\w+)/i,/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[\s_-]?([\w-]*)/i,/(hp)\s([\w\s]+\w)/i,/(asus)-?(\w+)/i],[f,u,[d,m]],[/\(bb10;\s(\w+)/i],[u,[f,"BlackBerry"],[d,m]],[/android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone)/i],[u,[f,"Asus"],[d,y]],[/(sony)\s(tablet\s[ps])\sbuild\//i,/(sony)?(?:sgp.+)\sbuild\//i],[[f,"Sony"],[u,"Xperia Tablet"],[d,y]],[/android.+\s([c-g]\d{4}|so[-l]\w+)\sbuild\//i],[u,[f,"Sony"],[d,m]],[/\s(ouya)\s/i,/(nintendo)\s([wids3u]+)/i],[f,u,[d,g]],[/android.+;\s(shield)\sbuild/i],[u,[f,"Nvidia"],[d,g]],[/(playstation\s[34portablevi]+)/i],[u,[f,"Sony"],[d,g]],[/(sprint\s(\w+))/i],[[f,E.str,w.device.sprint.vendor],[u,E.str,w.device.sprint.model],[d,m]],[/(lenovo)\s?(S(?:5000|6000)+(?:[-][\w+]))/i],[f,u,[d,y]],[/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i,/(zte)-(\w*)/i,/(alcatel|geeksphone|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i],[f,[u,/_/g," "],[d,m]],[/(nexus\s9)/i],[u,[f,"HTC"],[d,y]],[/d\/huawei([\w\s-]+)[;\)]/i,/(nexus\s6p)/i],[u,[f,"Huawei"],[d,m]],[/(microsoft);\s(lumia[\s\w]+)/i],[f,u,[d,m]],[/[\s\(;](xbox(?:\sone)?)[\s\);]/i],[u,[f,"Microsoft"],[d,g]],[/(kin\.[onetw]{3})/i],[[u,/\./g," "],[f,"Microsoft"],[d,m]],[/\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?:?(\s4g)?)[\w\s]+build\//i,/mot[\s-]?(\w*)/i,/(XT\d{3,4}) build\//i,/(nexus\s6)/i],[u,[f,"Motorola"],[d,m]],[/android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i],[u,[f,"Motorola"],[d,y]],[/hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i],[[f,C.trim],[u,C.trim],[d,v]],[/hbbtv.+maple;(\d+)/i],[[u,/^/,"SmartTV"],[f,"Samsung"],[d,v]],[/\(dtv[\);].+(aquos)/i],[u,[f,"Sharp"],[d,v]],[/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n\d+|sgh-t8[56]9|nexus 10))/i,/((SM-T\w+))/i],[[f,"Samsung"],u,[d,y]],[/smart-tv.+(samsung)/i],[f,[d,v],u],[/((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-\w[\w\d]+))/i,/(sam[sung]*)[\s-]*(\w+-?[\w-]*)/i,/sec-((sgh\w+))/i],[[f,"Samsung"],u,[d,m]],[/sie-(\w*)/i],[u,[f,"Siemens"],[d,m]],[/(maemo|nokia).*(n900|lumia\s\d+)/i,/(nokia)[\s_-]?([\w-]*)/i],[[f,"Nokia"],u,[d,m]],[/android\s3\.[\s\w;-]{10}(a\d{3})/i],[u,[f,"Acer"],[d,y]],[/android.+([vl]k\-?\d{3})\s+build/i],[u,[f,"LG"],[d,y]],[/android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i],[[f,"LG"],u,[d,y]],[/(lg) netcast\.tv/i],[f,u,[d,v]],[/(nexus\s[45])/i,/lg[e;\s\/-]+(\w*)/i,/android.+lg(\-?[\d\w]+)\s+build/i],[u,[f,"LG"],[d,m]],[/android.+(ideatab[a-z0-9\-\s]+)/i],[u,[f,"Lenovo"],[d,y]],[/linux;.+((jolla));/i],[f,u,[d,m]],[/((pebble))app\/[\d\.]+\s/i],[f,u,[d,b]],[/android.+;\s(oppo)\s?([\w\s]+)\sbuild/i],[f,u,[d,m]],[/crkey/i],[[u,"Chromecast"],[f,"Google"]],[/android.+;\s(glass)\s\d/i],[u,[f,"Google"],[d,b]],[/android.+;\s(pixel c)\s/i],[u,[f,"Google"],[d,y]],[/android.+;\s(pixel xl|pixel)\s/i],[u,[f,"Google"],[d,m]],[/android.+;\s(\w+)\s+build\/hm\1/i,/android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i,/android.+(mi[\s\-_]*(?:one|one[\s_]plus|note lte)?[\s_]*(?:\d?\w?)[\s_]*(?:plus)?)\s+build/i,/android.+(redmi[\s\-_]*(?:note)?(?:[\s_]*[\w\s]+))\s+build/i],[[u,/_/g," "],[f,"Xiaomi"],[d,m]],[/android.+(mi[\s\-_]*(?:pad)(?:[\s_]*[\w\s]+))\s+build/i],[[u,/_/g," "],[f,"Xiaomi"],[d,y]],[/android.+;\s(m[1-5]\snote)\sbuild/i],[u,[f,"Meizu"],[d,y]],[/android.+a000(1)\s+build/i,/android.+oneplus\s(a\d{4})\s+build/i],[u,[f,"OnePlus"],[d,m]],[/android.+[;\/]\s*(RCT[\d\w]+)\s+build/i],[u,[f,"RCA"],[d,y]],[/android.+[;\/\s]+(Venue[\d\s]{2,7})\s+build/i],[u,[f,"Dell"],[d,y]],[/android.+[;\/]\s*(Q[T|M][\d\w]+)\s+build/i],[u,[f,"Verizon"],[d,y]],[/android.+[;\/]\s+(Barnes[&\s]+Noble\s+|BN[RT])(V?.*)\s+build/i],[[f,"Barnes & Noble"],u,[d,y]],[/android.+[;\/]\s+(TM\d{3}.*\b)\s+build/i],[u,[f,"NuVision"],[d,y]],[/android.+;\s(k88)\sbuild/i],[u,[f,"ZTE"],[d,y]],[/android.+[;\/]\s*(gen\d{3})\s+build.*49h/i],[u,[f,"Swiss"],[d,m]],[/android.+[;\/]\s*(zur\d{3})\s+build/i],[u,[f,"Swiss"],[d,y]],[/android.+[;\/]\s*((Zeki)?TB.*\b)\s+build/i],[u,[f,"Zeki"],[d,y]],[/(android).+[;\/]\s+([YR]\d{2})\s+build/i,/android.+[;\/]\s+(Dragon[\-\s]+Touch\s+|DT)(\w{5})\sbuild/i],[[f,"Dragon Touch"],u,[d,y]],[/android.+[;\/]\s*(NS-?\w{0,9})\sbuild/i],[u,[f,"Insignia"],[d,y]],[/android.+[;\/]\s*((NX|Next)-?\w{0,9})\s+build/i],[u,[f,"NextBook"],[d,y]],[/android.+[;\/]\s*(Xtreme\_)?(V(1[045]|2[015]|30|40|60|7[05]|90))\s+build/i],[[f,"Voice"],u,[d,m]],[/android.+[;\/]\s*(LVTEL\-)?(V1[12])\s+build/i],[[f,"LvTel"],u,[d,m]],[/android.+[;\/]\s*(V(100MD|700NA|7011|917G).*\b)\s+build/i],[u,[f,"Envizen"],[d,y]],[/android.+[;\/]\s*(Le[\s\-]+Pan)[\s\-]+(\w{1,9})\s+build/i],[f,u,[d,y]],[/android.+[;\/]\s*(Trio[\s\-]*.*)\s+build/i],[u,[f,"MachSpeed"],[d,y]],[/android.+[;\/]\s*(Trinity)[\-\s]*(T\d{3})\s+build/i],[f,u,[d,y]],[/android.+[;\/]\s*TU_(1491)\s+build/i],[u,[f,"Rotor"],[d,y]],[/android.+(KS(.+))\s+build/i],[u,[f,"Amazon"],[d,y]],[/android.+(Gigaset)[\s\-]+(Q\w{1,9})\s+build/i],[f,u,[d,y]],[/\s(tablet|tab)[;\/]/i,/\s(mobile)(?:[;\/]|\ssafari)/i],[[d,C.lowerize],f,u],[/(android[\w\.\s\-]{0,9});.+build/i],[u,[f,"Generic"]]],engine:[[/windows.+\sedge\/([\w\.]+)/i],[p,[l,"EdgeHTML"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i,/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i,/(icab)[\/\s]([23]\.[\d\.]+)/i],[l,p],[/rv\:([\w\.]{1,9}).+(gecko)/i],[p,l]],os:[[/microsoft\s(windows)\s(vista|xp)/i],[l,p],[/(windows)\snt\s6\.2;\s(arm)/i,/(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s\w]*)/i,/(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i],[l,[p,E.str,w.os.windows.version]],[/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],[[l,"Windows"],[p,E.str,w.os.windows.version]],[/\((bb)(10);/i],[[l,"BlackBerry"],p],[/(blackberry)\w*\/?([\w\.]*)/i,/(tizen)[\/\s]([\w\.]+)/i,/(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]*)/i,/linux;.+(sailfish);/i],[l,p],[/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]*)/i],[[l,"Symbian"],p],[/\((series40);/i],[l],[/mozilla.+\(mobile;.+gecko.+firefox/i],[[l,"Firefox OS"],p],[/(nintendo|playstation)\s([wids34portablevu]+)/i,/(mint)[\/\s\(]?(\w*)/i,/(mageia|vectorlinux)[;\s]/i,/(joli|[kxln]?ubuntu|debian|suse|opensuse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?(?!chrom)([\w\.-]*)/i,/(hurd|linux)\s?([\w\.]*)/i,/(gnu)\s?([\w\.]*)/i],[l,p],[/(cros)\s[\w]+\s([\w\.]+\w)/i],[[l,"Chromium OS"],p],[/(sunos)\s?([\w\.\d]*)/i],[[l,"Solaris"],p],[/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]*)/i],[l,p],[/(haiku)\s(\w+)/i],[l,p],[/cfnetwork\/.+darwin/i,/ip[honead]{2,4}(?:.*os\s([\w]+)\slike\smac|;\sopera)/i],[[p,/_/g,"."],[l,"iOS"]],[/(mac\sos\sx)\s?([\w\s\.]*)/i,/(macintosh|mac(?=_powerpc)\s)/i],[[l,"Mac OS"],[p,/_/g,"."]],[/((?:open)?solaris)[\/\s-]?([\w\.]*)/i,/(aix)\s((\d)(?=\.|\)|\s)[\w\.])*/i,/(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms)/i,/(unix)\s?([\w\.]*)/i],[l,p]]},S=function(e,t){if("object"==typeof e&&(t=e,e=a),!(this instanceof S))return new S(e,t).getResult();var r=e||(i&&i.navigator&&i.navigator.userAgent?i.navigator.userAgent:""),n=t?C.extend(k,t):k;return this.getBrowser=function(){var e={name:a,version:a};return E.rgx.call(e,r,n.browser),e.major=C.major(e.version),e},this.getCPU=function(){var e={architecture:a};return E.rgx.call(e,r,n.cpu),e},this.getDevice=function(){var e={vendor:a,model:a,type:a};return E.rgx.call(e,r,n.device),e},this.getEngine=function(){var e={name:a,version:a};return E.rgx.call(e,r,n.engine),e},this.getOS=function(){var e={name:a,version:a};return E.rgx.call(e,r,n.os),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return r},this.setUA=function(e){return r=e,this},this};S.VERSION="0.7.18",S.BROWSER={NAME:l,MAJOR:"major",VERSION:p},S.CPU={ARCHITECTURE:h},S.DEVICE={MODEL:u,VENDOR:f,TYPE:d,CONSOLE:g,MOBILE:m,SMARTTV:v,TABLET:y,WEARABLE:b,EMBEDDED:"embedded"},S.ENGINE={NAME:l,VERSION:p},S.OS={NAME:l,VERSION:p},typeof t!==s?(typeof e!==s&&e.exports&&(t=e.exports=S),t.UAParser=S):r(3)?(n=function(){return S}.call(t,r,t,e))===a||(e.exports=n):i&&(i.UAParser=S);var B=i&&(i.jQuery||i.Zepto);if(typeof B!==s){var T=new S;B.ua=T.getResult(),B.ua.get=function(){return T.getUA()},B.ua.set=function(e){T.setUA(e);var t=T.getResult();for(var r in t)B.ua[r]=t[r]}}}("object"==typeof window?window:this)},function(e,t){(function(t){e.exports=t}).call(t,{})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i=r(0),a=i.DEVICE_TYPES,o=i.defaultData,s=t.getNavigatorInstance=function(){return!("undefined"==typeof window||!window.navigator&&!navigator)&&(window.navigator||navigator)},c=t.isIOS13Check=function(e){var t=s();return t&&t.platform&&(-1!==t.platform.indexOf(e)||"MacIntel"===t.platform&&t.maxTouchPoints>1&&!window.MSStream)};e.exports={checkType:function(e){switch(e){case a.MOBILE:return{isMobile:!0};case a.TABLET:return{isTablet:!0};case a.SMART_TV:return{isSmartTV:!0};case a.CONSOLE:return{isConsole:!0};case a.WEARABLE:return{isWearable:!0};case a.BROWSER:return{isBrowser:!0};default:return o}},broPayload:function(e,t,r,n,i){return{isBrowser:e,browserMajorVersion:t.major,browserFullVersion:t.version,browserName:t.name,engineName:r.name||!1,engineVersion:r.version,osName:n.name,osVersion:n.version,userAgent:i}},mobilePayload:function(e,t,r,i){return n({},e,{vendor:t.vendor,model:t.model,os:r.name,osVersion:r.version,ua:i})},stvPayload:function(e,t,r,n){return{isSmartTV:e,engineName:t.name,engineVersion:t.version,osName:r.name,osVersion:r.version,userAgent:n}},consolePayload:function(e,t,r,n){return{isConsole:e,engineName:t.name,engineVersion:t.version,osName:r.name,osVersion:r.version,userAgent:n}},wearPayload:function(e,t,r,n){return{isWearable:e,engineName:t.name,engineVersion:t.version,osName:r.name,osVersion:r.version,userAgent:n}},getNavigatorInstance:s,isIOS13Check:c}}])})),eG="object"==typeof n&&n&&n.Object===Object&&n,tG="object"==typeof self&&self&&self.Object===Object&&self,rG=eG||tG||Function("return this")(),nG=rG.Symbol,iG=Object.prototype,aG=iG.hasOwnProperty,oG=iG.toString,sG=nG?nG.toStringTag:void 0;var cG=function(e){var t=aG.call(e,sG),r=e[sG];try{e[sG]=void 0;var n=!0}catch(e){}var i=oG.call(e);return n&&(t?e[sG]=r:delete e[sG]),i},uG=Object.prototype.toString;var lG=function(e){return uG.call(e)},dG=nG?nG.toStringTag:void 0;var fG=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":dG&&dG in Object(e)?cG(e):lG(e)};var pG=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};var hG=function(e){if(!pG(e))return!1;var t=fG(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},gG=rG["__core-js_shared__"],mG=function(){var e=/[^.]+$/.exec(gG&&gG.keys&&gG.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();var yG=function(e){return!!mG&&mG in e},vG=Function.prototype.toString;var bG=function(e){if(null!=e){try{return vG.call(e)}catch(e){}try{return e+""}catch(e){}}return""},CG=/^\[object .+?Constructor\]$/,EG=Function.prototype,wG=Object.prototype,kG=EG.toString,SG=wG.hasOwnProperty,BG=RegExp("^"+kG.call(SG).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var TG=function(e){return!(!pG(e)||yG(e))&&(hG(e)?BG:CG).test(bG(e))};var AG=function(e,t){return null==e?void 0:e[t]};var IG=function(e,t){var r=AG(e,t);return TG(r)?r:void 0},_G=function(){try{var e=IG(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var xG=function(e,t,r){"__proto__"==t&&_G?_G(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r};var PG=function(e,t){return e===t||e!=e&&t!=t},RG=Object.prototype.hasOwnProperty;var NG=function(e,t,r){var n=e[t];RG.call(e,t)&&PG(n,r)&&(void 0!==r||t in e)||xG(e,t,r)};var OG=function(e,t,r,n){var i=!r;r||(r={});for(var a=-1,o=t.length;++a<o;){var s=t[a],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?xG(r,s,c):NG(r,s,c)}return r};var LG=function(e){return e};var DG=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)},UG=Math.max;var MG=function(e,t,r){return t=UG(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=UG(n.length-t,0),o=Array(a);++i<a;)o[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(o),DG(e,this,s)}};var VG=function(e){return function(){return e}},jG=_G?function(e,t){return _G(e,"toString",{configurable:!0,enumerable:!1,value:VG(t),writable:!0})}:LG,FG=Date.now;var zG=function(e){var t=0,r=0;return function(){var n=FG(),i=16-(n-r);if(r=n,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(jG);var KG=function(e,t){return zG(MG(e,t,LG),e+"")};var qG=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};var HG=function(e){return null!=e&&qG(e.length)&&!hG(e)},GG=/^(?:0|[1-9]\d*)$/;var QG=function(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&GG.test(e))&&e>-1&&e%1==0&&e<t};var WG=function(e,t,r){if(!pG(r))return!1;var n=typeof t;return!!("number"==n?HG(r)&&QG(t,r.length):"string"==n&&t in r)&&PG(r[t],e)};var XG=function(e){return KG((function(t,r){var n=-1,i=r.length,a=i>1?r[i-1]:void 0,o=i>2?r[2]:void 0;for(a=e.length>3&&"function"==typeof a?(i--,a):void 0,o&&WG(r[0],r[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++n<i;){var s=r[n];s&&e(t,s,n,a)}return t}))};var YG=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n};var $G=function(e){return null!=e&&"object"==typeof e};var ZG=function(e){return $G(e)&&"[object Arguments]"==fG(e)},JG=Object.prototype,eQ=JG.hasOwnProperty,tQ=JG.propertyIsEnumerable,rQ=ZG(function(){return arguments}())?ZG:function(e){return $G(e)&&eQ.call(e,"callee")&&!tQ.call(e,"callee")},nQ=Array.isArray;var iQ=function(){return!1},aQ=a((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r?rG.Buffer:void 0,a=(i?i.isBuffer:void 0)||iQ;e.exports=a})),oQ={};oQ["[object Float32Array]"]=oQ["[object Float64Array]"]=oQ["[object Int8Array]"]=oQ["[object Int16Array]"]=oQ["[object Int32Array]"]=oQ["[object Uint8Array]"]=oQ["[object Uint8ClampedArray]"]=oQ["[object Uint16Array]"]=oQ["[object Uint32Array]"]=!0,oQ["[object Arguments]"]=oQ["[object Array]"]=oQ["[object ArrayBuffer]"]=oQ["[object Boolean]"]=oQ["[object DataView]"]=oQ["[object Date]"]=oQ["[object Error]"]=oQ["[object Function]"]=oQ["[object Map]"]=oQ["[object Number]"]=oQ["[object Object]"]=oQ["[object RegExp]"]=oQ["[object Set]"]=oQ["[object String]"]=oQ["[object WeakMap]"]=!1;var sQ=function(e){return $G(e)&&qG(e.length)&&!!oQ[fG(e)]};var cQ=function(e){return function(t){return e(t)}},uQ=a((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r&&eG.process,a=function(){try{var e=n&&n.require&&n.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=a})),lQ=uQ&&uQ.isTypedArray,dQ=lQ?cQ(lQ):sQ,fQ=Object.prototype.hasOwnProperty;var pQ=function(e,t){var r=nQ(e),n=!r&&rQ(e),i=!r&&!n&&aQ(e),a=!r&&!n&&!i&&dQ(e),o=r||n||i||a,s=o?YG(e.length,String):[],c=s.length;for(var u in e)!t&&!fQ.call(e,u)||o&&("length"==u||i&&("offset"==u||"parent"==u)||a&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||QG(u,c))||s.push(u);return s},hQ=Object.prototype;var gQ=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||hQ)};var mQ=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t},yQ=Object.prototype.hasOwnProperty;var vQ=function(e){if(!pG(e))return mQ(e);var t=gQ(e),r=[];for(var n in e)("constructor"!=n||!t&&yQ.call(e,n))&&r.push(n);return r};var bQ=function(e){return HG(e)?pQ(e,!0):vQ(e)},CQ=XG((function(e,t,r,n){OG(t,bQ(t),e,n)}));var EQ=function(e,t){return function(r){return e(t(r))}},wQ=EQ(Object.getPrototypeOf,Object),kQ=Function.prototype,SQ=Object.prototype,BQ=kQ.toString,TQ=SQ.hasOwnProperty,AQ=BQ.call(Object);var IQ=function(e){if(!$G(e)||"[object Object]"!=fG(e))return!1;var t=wQ(e);if(null===t)return!0;var r=TQ.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&BQ.call(r)==AQ};var _Q=function(e){if(!$G(e))return!1;var t=fG(e);return"[object Error]"==t||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!IQ(e)},xQ=KG((function(e,t){try{return DG(e,void 0,t)}catch(e){return _Q(e)?e:new Error(e)}}));var PQ=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i};var RQ=function(e,t){return PQ(t,(function(t){return e[t]}))},NQ=Object.prototype,OQ=NQ.hasOwnProperty;var LQ=function(e,t,r,n){return void 0===e||PG(e,NQ[r])&&!OQ.call(n,r)?t:e},DQ={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};var UQ=function(e){return"\\"+DQ[e]},MQ=EQ(Object.keys,Object),VQ=Object.prototype.hasOwnProperty;var jQ=function(e){if(!gQ(e))return MQ(e);var t=[];for(var r in Object(e))VQ.call(e,r)&&"constructor"!=r&&t.push(r);return t};var FQ=function(e){return HG(e)?pQ(e):jQ(e)},zQ=/<%=([\s\S]+?)%>/g;var KQ=function(e){return function(t){return null==e?void 0:e[t]}}({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});var qQ=function(e){return"symbol"==typeof e||$G(e)&&"[object Symbol]"==fG(e)},HQ=nG?nG.prototype:void 0,GQ=HQ?HQ.toString:void 0;var QQ=function e(t){if("string"==typeof t)return t;if(nQ(t))return PQ(t,e)+"";if(qQ(t))return GQ?GQ.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r};var WQ=function(e){return null==e?"":QQ(e)},XQ=/[&<>"']/g,YQ=RegExp(XQ.source);var $Q={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:zQ,variable:"",imports:{_:{escape:function(e){return(e=WQ(e))&&YQ.test(e)?e.replace(XQ,KQ):e}}}},ZQ=/\b__p \+= '';/g,JQ=/\b(__p \+=) '' \+/g,eW=/(__e\(.*?\)|\b__t\)) \+\n'';/g,tW=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rW=/($^)/,nW=/['\n\r\u2028\u2029\\]/g,iW=Object.prototype.hasOwnProperty;var aW=function(e,t,r){var n=$Q.imports._.templateSettings||$Q;r&&WG(e,t,r)&&(t=void 0),e=WQ(e),t=CQ({},t,n,LQ);var i,a,o=CQ({},t.imports,n.imports,LQ),s=FQ(o),c=RQ(o,s),u=0,l=t.interpolate||rW,d="__p += '",f=RegExp((t.escape||rW).source+"|"+l.source+"|"+(l===zQ?tW:rW).source+"|"+(t.evaluate||rW).source+"|$","g"),p=iW.call(t,"sourceURL")?"//# sourceURL="+(t.sourceURL+"").replace(/\s/g," ")+"\n":"";e.replace(f,(function(t,r,n,o,s,c){return n||(n=o),d+=e.slice(u,c).replace(nW,UQ),r&&(i=!0,d+="' +\n__e("+r+") +\n'"),s&&(a=!0,d+="';\n"+s+";\n__p += '"),n&&(d+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),d+="';\n";var h=iW.call(t,"variable")&&t.variable;h||(d="with (obj) {\n"+d+"\n}\n"),d=(a?d.replace(ZQ,""):d).replace(JQ,"$1").replace(eW,"$1;"),d="function("+(h||"obj")+") {\n"+(h?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=xQ((function(){return Function(s,p+"return "+d).apply(void 0,c)}));if(g.source=d,_Q(g))throw g;return g},oW="SESSION_TIMEOUT";function sW(){return(sW=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var cW,uW,lW,dW,fW,pW,hW,gW,mW,yW,vW,bW,CW="undefined"!=typeof window?oy.useLayoutEffect:oy.useEffect,EW={popupContent:{tooltip:{position:"absolute",zIndex:999},modal:{position:"relative",margin:"auto"}},popupArrow:{height:"8px",width:"16px",position:"absolute",background:"transparent",color:"#FFF",zIndex:-1},overlay:{tooltip:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",zIndex:999},modal:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",display:"flex",zIndex:999}}},wW=["top left","top center","top right","right top","right center","right bottom","bottom left","bottom center","bottom right","left top","left center","left bottom"],kW=function(e,t,r,n,i){var a=i.offsetX,o=i.offsetY,s=n?8:0,c=r.split(" "),u=e.top+e.height/2,l=e.left+e.width/2,d=t.height,f=t.width,p=u-d/2,h=l-f/2,g="",m="0%",y="0%";switch(c[0]){case"top":p-=d/2+e.height/2+s,g="rotate(180deg) translateX(50%)",m="100%",y="50%";break;case"bottom":p+=d/2+e.height/2+s,g="rotate(0deg) translateY(-100%) translateX(-50%)",y="50%";break;case"left":h-=f/2+e.width/2+s,g=" rotate(90deg) translateY(50%) translateX(-25%)",y="100%",m="50%";break;case"right":h+=f/2+e.width/2+s,g="rotate(-90deg) translateY(-150%) translateX(25%)",m="50%"}switch(c[1]){case"top":p=e.top,m=e.height/2+"px";break;case"bottom":p=e.top-d+e.height,m=d-e.height/2+"px";break;case"left":h=e.left,y=e.width/2+"px";break;case"right":h=e.left-f+e.width,y=f-e.width/2+"px"}return{top:p="top"===c[0]?p-o:p+o,left:h="left"===c[0]?h-a:h+a,transform:g,arrowLeft:y,arrowTop:m}},SW=function(e,t,r,n,i,a){var o=i.offsetX,s=i.offsetY,c={arrowLeft:"0%",arrowTop:"0%",left:0,top:0,transform:"rotate(135deg)"},u=0,l=function(e){var t={top:0,left:0,width:window.innerWidth,height:window.innerHeight};if("string"==typeof e){var r=document.querySelector(e);null!==r&&(t=r.getBoundingClientRect())}return t}(a),d=Array.isArray(r)?r:[r];for((a||Array.isArray(r))&&(d=[].concat(d,wW));u<d.length;){var f={top:(c=kW(e,t,d[u],n,{offsetX:o,offsetY:s})).top,left:c.left,width:t.width,height:t.height};if(!(f.top<=l.top||f.left<=l.left||f.top+f.height>=l.top+l.height||f.left+f.width>=l.left+l.width))break;u++}return c},BW=0,TW=oy.forwardRef((function(e,t){var r=e.trigger,n=void 0===r?null:r,i=e.onOpen,a=void 0===i?function(){}:i,o=e.onClose,s=void 0===o?function(){}:o,c=e.defaultOpen,u=void 0!==c&&c,l=e.open,d=void 0===l?void 0:l,f=e.disabled,p=void 0!==f&&f,h=e.nested,g=void 0!==h&&h,m=e.closeOnDocumentClick,y=void 0===m||m,v=e.repositionOnResize,b=void 0===v||v,C=e.closeOnEscape,E=void 0===C||C,w=e.on,k=void 0===w?["click"]:w,S=e.contentStyle,B=void 0===S?{}:S,T=e.arrowStyle,A=void 0===T?{}:T,I=e.overlayStyle,_=void 0===I?{}:I,x=e.className,P=void 0===x?"":x,R=e.position,N=void 0===R?"bottom center":R,O=e.modal,L=void 0!==O&&O,D=e.lockScroll,U=void 0!==D&&D,M=e.arrow,V=void 0===M||M,j=e.offsetX,F=void 0===j?0:j,z=e.offsetY,K=void 0===z?0:z,q=e.mouseEnterDelay,H=void 0===q?100:q,G=e.mouseLeaveDelay,Q=void 0===G?100:G,W=e.keepTooltipInside,X=void 0!==W&&W,Y=e.children,$=oy.useState(d||u),Z=$[0],J=$[1],ee=oy.useRef(null),te=oy.useRef(null),re=oy.useRef(null),ne=oy.useRef(null),ie=oy.useRef("popup-"+ ++BW),ae=!!L||!n,oe=oy.useRef(0);CW((function(){return Z?(ne.current=document.activeElement,ve(),ge(),pe()):he(),function(){clearTimeout(oe.current)}}),[Z]),oy.useEffect((function(){"boolean"==typeof d&&(d?se():ce())}),[d,p]);var se=function(e){Z||p||(J(!0),setTimeout((function(){return a(e)}),0))},ce=function(e){var t;Z&&!p&&(J(!1),ae&&(null===(t=ne.current)||void 0===t||t.focus()),setTimeout((function(){return s(e)}),0))},ue=function(e){null==e||e.stopPropagation(),Z?ce(e):se(e)},le=function(e){clearTimeout(oe.current),oe.current=setTimeout((function(){return se(e)}),H)},de=function(e){null==e||e.preventDefault(),ue()},fe=function(e){clearTimeout(oe.current),oe.current=setTimeout((function(){return ce(e)}),Q)},pe=function(){ae&&U&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},he=function(){ae&&U&&(document.getElementsByTagName("body")[0].style.overflow="auto")},ge=function(){var e,t=null==te||null===(e=te.current)||void 0===e?void 0:e.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),r=Array.prototype.slice.call(t)[0];null==r||r.focus()};oy.useImperativeHandle(t,(function(){return{open:function(){se()},close:function(){ce()},toggle:function(){ue()}}}));var me,ye,ve=function(){if(!ae&&Z&&(null==ee?void 0:ee.current)&&(null==ee?void 0:ee.current)&&(null==te?void 0:te.current)){var e,t,r=ee.current.getBoundingClientRect(),n=te.current.getBoundingClientRect(),i=SW(r,n,N,V,{offsetX:F,offsetY:K},X);if(te.current.style.top=i.top+window.scrollY+"px",te.current.style.left=i.left+window.scrollX+"px",V&&re.current)re.current.style.transform=i.transform,re.current.style.setProperty("-ms-transform",i.transform),re.current.style.setProperty("-webkit-transform",i.transform),re.current.style.top=(null===(e=A.top)||void 0===e?void 0:e.toString())||i.arrowTop,re.current.style.left=(null===(t=A.left)||void 0===t?void 0:t.toString())||i.arrowLeft}};me=ce,void 0===(ye=E)&&(ye=!0),oy.useEffect((function(){if(ye){var e=function(e){"Escape"===e.key&&me(e)};return document.addEventListener("keyup",e),function(){ye&&document.removeEventListener("keyup",e)}}}),[me,ye]),function(e,t){void 0===t&&(t=!0),oy.useEffect((function(){if(t){var r=function(t){if(9===t.keyCode){var r,n=null==e||null===(r=e.current)||void 0===r?void 0:r.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),i=Array.prototype.slice.call(n);if(1===i.length)return void t.preventDefault();var a=i[0],o=i[i.length-1];t.shiftKey&&document.activeElement===a?(t.preventDefault(),o.focus()):document.activeElement===o&&(t.preventDefault(),a.focus())}};return document.addEventListener("keydown",r),function(){t&&document.removeEventListener("keydown",r)}}}),[e,t])}(te,Z&&ae),function(e,t){void 0===t&&(t=!0),oy.useEffect((function(){if(t){var r=function(){e()};return window.addEventListener("resize",r),function(){t&&window.removeEventListener("resize",r)}}}),[e,t])}(ve,b),function(e,t,r){void 0===r&&(r=!0),oy.useEffect((function(){if(r){var n=function(r){var n=Array.isArray(e)?e:[e],i=!1;n.forEach((function(e){e.current&&!e.current.contains(r.target)||(i=!0)})),r.stopPropagation(),i||t(r)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),function(){r&&(document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n))}}}),[e,t,r])}(n?[te,ee]:[te],ce,y&&!g);var be,Ce=function(){return oy.createElement("div",Object.assign({},(e=ae?EW.popupContent.modal:EW.popupContent.tooltip,t={className:"popup-content "+(""!==P?P.split(" ").map((function(e){return e+"-content"})).join(" "):""),style:sW({},e,B,{pointerEvents:"auto"}),ref:te,onClick:function(e){e.stopPropagation()}},!L&&k.indexOf("hover")>=0&&(t.onMouseEnter=le,t.onMouseLeave=fe),t),{key:"C",role:ae?"dialog":"tooltip",id:ie.current}),V&&!ae&&oy.createElement("div",{ref:re,style:EW.popupArrow},oy.createElement("svg",{"data-testid":"arrow",className:"popup-arrow "+(""!==P?P.split(" ").map((function(e){return e+"-arrow"})).join(" "):""),viewBox:"0 0 32 16",style:sW({position:"absolute"},A)},oy.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),Y&&"function"==typeof Y?Y(ce,Z):Y);var e,t},Ee=!(k.indexOf("hover")>=0),we=ae?EW.overlay.modal:EW.overlay.tooltip,ke=[Ee&&oy.createElement("div",{key:"O","data-testid":"overlay","data-popup":ae?"modal":"tooltip",className:"popup-overlay "+(""!==P?P.split(" ").map((function(e){return e+"-overlay"})).join(" "):""),style:sW({},we,_,{pointerEvents:y&&g||ae?"auto":"none"}),onClick:y&&g?ce:void 0,tabIndex:-1},ae&&Ce()),!ae&&Ce()];return oy.createElement(oy.Fragment,null,function(){for(var e={key:"T",ref:ee,"aria-describedby":ie.current},t=Array.isArray(k)?k:[k],r=0,i=t.length;r<i;r++)switch(t[r]){case"click":e.onClick=ue;break;case"right-click":e.onContextMenu=de;break;case"hover":e.onMouseEnter=le,e.onMouseLeave=fe;break;case"focus":e.onFocus=le,e.onBlur=fe}if("function"==typeof n){var a=n(Z);return!!n&&oy.cloneElement(a,e)}return!!n&&oy.cloneElement(n,e)}(),Z&&NL.createPortal(ke,(null===(be=document.getElementById("popup-root"))&&((be=document.createElement("div")).setAttribute("id","popup-root"),document.body.appendChild(be)),be)))}));function AW(){return"function"==typeof navigator.enumerateDevices?navigator.enumerateDevices():"object"===$g(navigator.mediaDevices)&&"function"==typeof navigator.mediaDevices.enumerateDevices?navigator.mediaDevices.enumerateDevices():new Promise((function(e,t){try{if(null==window.MediaStreamTrack||null==window.MediaStreamTrack.getSources)throw new Error;window.MediaStreamTrack.getSources((function(t){e(t.filter((function(e){return"video"===e.kind.toLowerCase()||"videoinput"===e.kind.toLowerCase()})).map((function(e){return{deviceId:null!=e.deviceId?e.deviceId:"",groupId:e.groupId,kind:"videoinput",label:e.label,toJSON:function(){return this}}})))}))}catch(e){return t(e)}}))}var IW,_W=oC.Errors,xW=eC.div(cW||(cW=dm(["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background: #000;\n display: flex;\n justify-content: center;\n z-index: ",";\n ","\n"])),1e3,(function(e){return e.checkCameraMode&&"opacity: 0;"})),PW=eC.video(uW||(uW=dm(["\n width: 100%;\n ","\n"])),(function(e){return e.flipHorizontal&&"\n transform: scaleX(-1);\n "})),RW=eC.div(lW||(lW=dm(["\n cursor: pointer;\n text-align: center;\n width: 50px;\n\n img {\n width: 100%;\n }\n"]))),NW=eC(RW)(dW||(dW=dm(["\n z-index: ",";\n position: absolute;\n top: 20px;\n right: 20px;\n width: 20px;\n"])),1100),OW=eC.div(fW||(fW=dm(["\n z-index: ",";\n position: absolute;\n top: 40px;\n color: red;\n"])),1020),LW=eC.div(pW||(pW=dm(["\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: ",";\n"])),1030),DW=eC.section(hW||(hW=dm(["\n width: 260px;\n margin: 1.25rem;\n padding: 0.625rem 1.875rem;\n background: #ffffff;\n border-radius: 0.3125rem;\n box-shadow: 2px 2px 14px rgba(0, 0, 0, 0.15);\n"]))),UW=eC.header(gW||(gW=dm(["\n text-align: center;\n padding: 0.625rem 0;\n border-bottom: 1px solid #dddddd;\n"]))),MW=eC.h2(mW||(mW=dm(["\n margin: 0.25rem auto;\n padding: 0;\n font-weight: 600;\n font-size: 1.2rem;\n"]))),VW=eC.p(yW||(yW=dm(["\n padding: 0 0 0.3125rem;\n margin: 0.25rem auto;\n font-size: 0.8rem;\n"]))),jW=eC.ul(vW||(vW=dm(["\n list-style: none;\n padding: 0;\n"]))),FW=eC.li(bW||(bW=dm(["\n padding: 0.625rem 0 0.9375rem;\n margin: 0;\n text-align: left;\n width: 100%;\n cursor: pointer;\n font-size: 0.82rem;\n transition: all 550ms ease-in-out;\n\n &:hover {\n opacity: 0.8;\n }\n"]))),zW=function(){if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)return navigator.mediaDevices;var e=navigator.mozGetUserMedia||navigator.webkitGetUserMedia;return e?{getUserMedia:function(t){return new Promise((function(r,n){e.call(navigator,t,r,n)}))}}:null}();function KW(e){var t=e.checkCameraMode,r=e.frontCamera,n=e.onClose,i=e.children,a=e.onVideoPlayed,o=e.flipHorizontal,s=e.videoSettings,c=e.refVideo,u=e.onError,l=e.closeButton,d=e.videoClassName,f=lC.useSDKSettings().lang,p=ok.useSDKTracking().sendEvent,h=uk.useAsset("ic_close.png"),g=fm(oy.useState(""),2),m=g[0],y=g[1],v=fm(oy.useState([]),2),b=v[0],C=v[1],E=fm(oy.useState(!1),2),w=E[0],k=E[1],S=oy.useRef(!1),B=oy.useRef(!1),T=oy.useCallback((function(){try{var e;(null==c||null===(e=c.current)||void 0===e?void 0:e.srcObject)instanceof MediaStream&&(c.current.srcObject.getTracks().forEach((function(e){return e.stop()})),c.current.srcObject=null)}catch(e){}}),[c]),A=oy.useCallback(function(){var e=Jg(regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},n=JH.isMobile?JH.isIOS?{width:{ideal:1460},aspectRatio:{ideal:window.innerHeight/window.innerWidth}}:{width:{ideal:1650},aspectRatio:{ideal:window.innerHeight/window.innerWidth}}:{height:{ideal:9999}},e.prev=2,e.next=5,zW.getUserMedia({audio:!1,video:om(om({},t?{deviceId:t}:{facingMode:r?"user":"environment"}),s||n)});case 5:return(i=e.sent)||(y(_W.not_supported.msg[f]),u(_W.not_supported)),e.abrupt("return",i);case 10:e.prev=10,e.t0=e.catch(2),"NotAllowedError"===e.t0.name?(y(_W.no_permission.msg[f]),u(_W.no_permission)):(k(!0),y(e.t0.message),u({code:e.t0.name||e.t0.code}));case 13:return e.abrupt("return",null);case 14:case"end":return e.stop()}}),e,null,[[2,10]])})));return function(t){return e.apply(this,arguments)}}(),[r,s,f,u]),I=oy.useCallback(function(){var e=Jg(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=c.current).oncanplaythrough=function(){r.play(),B.current=!0,y("");var e=window.innerWidth,t=window.innerHeight,n=Uk.analyzeVideoAndWindowSizes(r),i=n.lostX,o=void 0===i?0:i,s=n.lostY,c=void 0===s?0:s,u=Math.min(e,Math.floor(e-2*o)),l=Math.min(t,Math.floor(t-2*c));a&&a({clientWidth:e,clientHeight:t,videoAreaWidth:u,videoAreaHeight:l,lostX:o,lostY:c})},e.next=4,A(t);case 4:(n=e.sent)&&(r.srcObject=n);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[c,A,a]);oy.useEffect((function(){function e(){return(e=Jg(regeneratorRuntime.mark((function e(){var t,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,AW();case 3:t=e.sent,r=t.filter((function(e){return e.deviceId&&"videoinput"===e.kind})),C(r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),console.error(e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})))).apply(this,arguments)}w&&!S.current&&(S.current=!0,function(){e.apply(this,arguments)}())}),[w]),oy.useEffect((function(){function e(){return(e=Jg(regeneratorRuntime.mark((function e(){var t,r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,I();case 2:return e.next=4,AW();case 4:t=e.sent,(r=t.filter((function(e){return"videoinput"===e.kind&&e.label.includes("0")}))).length>0&&(n=r[0].deviceId,T(),I(n));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var t=c.current;return!zW||JH.browserName&&["facebook"].includes(JH.browserName.toLowerCase())||JH.getUA.includes("Zalo iOS")?(y(_W.not_supported.msg[f]),u(_W.not_supported)):t&&(JH.isAndroid&&!1===r?function(){e.apply(this,arguments)}():I()),function(){T()}}),[c,f,r,I,T,u]),oy.useEffect((function(){var e=setTimeout((function(){B.current||(y(_W.camera_timeout.msg[f]),u(_W.camera_timeout))}),3e5);return function(){clearTimeout(e)}}),[f,u]);var _=oy.useCallback((function(){T(),n&&n(),p({tag:"result",event:"user_activity.cancel",log:{}})}),[n,T,p]);return oy.createElement(xW,{checkCameraMode:t},w&&null!=b&&b.length?oy.createElement(LW,null,oy.createElement(DW,null,oy.createElement(UW,null,oy.createElement(MW,null,"Không thể mở camera mặc định"),oy.createElement(VW,null,"Vui lòng thử chọn camera khác trong danh sách dưới đây")),oy.createElement(jW,null,b.map((function(e,t){return oy.createElement(FW,{key:e.deviceId,onClick:function(){y(""),T(),k(!1),I(e.deviceId)}},e.label?e.label:"Camera ".concat(t+1))}))))):null,function(){if(!m)return null;var e=_W.no_permission.msg[f];return m===e&&JH.isIOS?oy.createElement(OW,null,m," ",oy.createElement("button",{onClick:function(){window.location.reload()}},{vi:"Cấp lại quyền truy cập camera",en:"Request camera permission"}[f])):oy.createElement(OW,null,m)}(),oy.createElement(PW,{ref:c,playsInline:!0,muted:!0,flipHorizontal:o,className:d}),i,l?oy.cloneElement(l,{onClick:_,"data-testid":"close-camera"}):oy.createElement(NW,{onClick:_,"data-testid":"close-camera"},oy.createElement("img",{src:h,alt:""})))}KW.propTypes={checkCameraMode:Py.bool,frontCamera:Py.bool,onClose:Py.func,onError:Py.func,onVideoPlayed:Py.func,children:Py.node,flipHorizontal:Py.bool,videoSettings:Py.object,refVideo:Py.object,closeButton:Py.node,videoClassName:Py.string},KW.defaultProps={checkCameraMode:!1,frontCamera:!0,onClose:null,onError:function(){},onVideoPlayed:null,children:null,flipHorizontal:!1,videoSettings:null,refVideo:null,closeButton:null,videoClassName:""};var qW,HW,GW,QW,WW,XW,YW,$W,ZW,JW,eX,tX,rX,nX,iX,aX=rC(IW||(IW=dm(["\n .popup-content {\n margin: auto;\n background: #fff;\n width: 100%;\n padding: 5px;\n border: 1px solid #d7d7d7;\n max-width: 568px;\n border-radius: 10px;\n }\n\n [role=tooltip].popup-content {\n width: 200px;\n box-shadow: 0 0 3px rgba(0, 0, 0, .16);\n border-radius: 5px\n }\n\n .popup-overlay {\n background: rgba(0, 0, 0, .5);\n padding: 10px;\n }\n\n [data-popup=tooltip].popup-overlay {\n background: transparent\n }\n\n .popup-arrow {\n -webkit-filter: drop-shadow(0 -3px 3px rgba(0, 0, 0, .16));\n filter: drop-shadow(0 -3px 3px rgba(0, 0, 0, .16));\n color: #fff;\n stroke-width: 2px;\n stroke: #d7d7d7;\n stroke-dasharray: 30px;\n stroke-dashoffset: -54px;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0\n }\n"]))),oX=["open","children","overlayStyle"],sX=function(e){var t=e.open,r=e.children,n=e.overlayStyle,i=lm(e,oX);return oy.createElement(oy.Fragment,null,oy.createElement(TW,im({overlayStyle:om(om({},n),{},{zIndex:2e3}),closeOnDocumentClick:!1,closeOnEscape:!1,modal:!0,open:t},i),r),oy.createElement(aX,null))};sX.propTypes={open:Py.bool,children:Py.node,overlayStyle:Py.shape({})},sX.defaultProps={open:!1,children:null,overlayStyle:{}};var cX,uX,lX,dX=oz.flipY,fX=oz.spin,pX=oz.splash,hX=dX.animationDuration,gX=pX.default,mX=eC.div(qW||(qW=dm(["\n ","\n ","\n"])),dX.default,fX.default),yX=(eC.img(HW||(HW=dm(["\n border-radius: 5px;\n opacity: 0.7;\n height: 38px;\n"]))),eC.div(GW||(GW=dm(["\n cursor: pointer;\n text-align: center;\n width: ","px;\n\n img {\n width: 100%;\n }\n\n z-index: ",";\n position: fixed;\n\n ","\n"])),60,1020,JH.isMobile?Vb(["top:",";"],(function(e){return e.y})):Vb(["bottom:","px;"],10))),vX=eC.div(QW||(QW=dm(["\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n position: absolute;\n margin: auto;\n width: ","px;\n height: ","px;\n\n img {\n width: 100%;\n }\n\n z-index: ",";\n"])),80,80,1020),bX=eC.div(WW||(WW=dm(["\n color: #fff;\n text-align: center;\n"]))),CX=eC.div(XW||(XW=dm(["\n transform: translateZ(1000px); // to fix rotating bug on safari\n transform-style: preserve-3d;\n position: absolute;\n top: ",";\n z-index: ",";\n"])),(function(e){return e.y}),1020),EX=eC.div(YW||(YW=dm(["\n display: flex;\n align-items: center;\n"]))),wX=eC(bX)($W||($W=dm(["\n font-size: ","px;\n color: #38383d;\n font-weight: 500;\n"])),JH.isMobile?16:24),kX=eC.div(ZW||(ZW=dm(["\n margin: 0 auto;\n padding: 0 5px;\n position: absolute;\n top: ",";\n z-index: ",";\n"])),(function(e){return e.y}),1020),SX=eC(bX)(JW||(JW=dm(["\n text-align: center;\n color: ",";\n font-weight: 500;\n padding: 5px 10px;\n font-size: ","px;\n"])),(function(e){return e.theme.dangerColor}),JH.isMobile?14:16),BX=function(e){var t=e.children,r=e.y;return oy.createElement(kX,{y:r},oy.createElement(SX,null,t))},TX=eC(AF)(eX||(eX=dm(["\n position: absolute;\n top: 0;\n left: 0;\n"]))),AX=eC(bX)(tX||(tX=dm(["\n color: ",";\n font-weight: 500;\n padding: 5px 10px;\n font-size: ","px;\n position: absolute;\n text-align: center;\n top: ",";\n z-index: ",";\n"])),(function(e){return e.theme.dangerColor}),JH.isMobile?14:16,(function(e){return e.y}),1020),IX=eC(bX)(rX||(rX=dm(["\n font-weight: normal;\n padding: 5px 10px;\n color: #38383d;\n font-size: ","px;\n position: absolute;\n text-align: center;\n top: ",";\n z-index: ",";\n"])),JH.isMobile?14:16,(function(e){return e.y}),1020),_X=eC.div(nX||(nX=dm(["\n cursor: pointer;\n text-align: center;\n width: 50px;\n\n img {\n width: 100%;\n }\n"]))),xX=eC(_X)(iX||(iX=dm(["\n z-index: ",";\n position: absolute;\n ","\n top: 16px;\n width: 24px;\n"])),1100,JH.isMobile?"left: 16px;":"right: 16px;"),PX=oC.Errors,RX={BTN_OK:{en:"OK",vi:"Tôi đã hiểu"},FRONT:{en:"front",vi:"trước"},BACK:{en:"back",vi:"sau"},BTN_USE_THIS_PICTURE:{en:"Use this picture",vi:"Nhìn ổn đấy!"},BTN_TRY_AGAIN:{en:"Try again",vi:"Chụp lại"},CONFIRM_POPUP_VALID_QR:{en:"QR code scanned",vi:"Đã quét được mã QR"},CONFIRM_POPUP_INVALID_QR:{en:"Could not scan QR code",vi:"Không quét được mã QR"}},NX=om(om({},PX),{},{id_detector_no_cards:{code:"id_detector_no_cards",msg:{en:"Take a photo of your ID card's <%= side %> side. Make sure the image of the card fits in the frame, (minimum 50% of frame).",vi:"Mặt <%= side %> CMND/CCCD cần nằm gọn trong khung hình, chiếm tối thiểu 50%."}},id_detector_validate_angle_error:{code:"id_detector_validate_angle_error",msg:{en:"Please put your ID card straight, not be oblique",vi:"Vui lòng đặt giấy tờ thẳng góc, không bị xô lệch khi chụp"}},id_detector_card_too_small:{code:"id_detector_card_too_small",msg:{en:"Please hold your ID card closer",vi:"Vui lòng đưa CMND/CCCD lại gần hơn"}},id_detector_error_incomplete:{code:"id_detector_error_incomplete",msg:{en:"Please hold your ID card further",vi:"Vui lòng đưa CMND/CCCD ra xa hơn"}},id_detector_error_front_side_no_faces:{code:"id_detector_error_front_side_no_faces",msg:{en:"Take a photo of your ID card's front side",vi:"Vui lòng chụp ảnh mặt trước của CMND/CCCD"}},id_detector_error_front_side_multiple_faces:{code:"id_detector_error_front_side_multiple_faces",msg:{en:"Please remove other items out of the frame",vi:"Vui lòng không để lẫn vật thể khác trong khung chụp hình"}},glare_detected:{code:"glare_detected",msg:{en:"Your photo ID is glare. Please adjust the shooting angle.",vi:"Ảnh chụp bị lóa sáng. Vui lòng chụp lại"}}}),OX=oC.IDCardMessage,LX=eC.div(cX||(cX=dm(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n padding: 10px;\n"]))),DX=eC.div(uX||(uX=dm(["\n text-align: center;\n font-size: 1rem;\n"]))),UX=eC.button(lX||(lX=dm(["\n margin-top: 20px;\n width: 100%;\n max-width: 160px;\n height: 50px;\n background-color: ",";\n border: 0;\n outline: none;\n border-radius: 0.25rem;\n color: #fff;\n font-weight: 400;\n cursor: pointer;\n font-size: 1rem;\n"])),(function(e){return e.theme.primaryColor})),MX=function(e){var t=e.onOk,r=e.maxSessionTime,n=lC.useSDKSettings().lang;return oy.createElement(LX,null,oy.createElement(DX,null,aW(OX.TIMEOUT_INSTRUCTION[n])({x:r})),oy.createElement(UX,{onClick:t},RX.BTN_OK[n]))};MX.propTypes={onOk:Py.func,maxSessionTime:Py.number},MX.defaultProps={onOk:function(){},maxSessionTime:30};var VX,jX,FX,zX=oC.IDCardMessage,KX=oy.forwardRef((function(e,t){var r,n=e.usePortraitMask,i=e.windowAndVideoInfo,a=e.refVideo,o=e.frontSide,s=e.settings,c=e.onCaptureDone,u=e.onUISpacingChange,l=e.outputEncryptionSettings,d=fm(oy.useState({}),2),f=d[0],p=d[1],h=f.yErrorMessage,g=f.yDescription,m=f.yCaptureButton,y=f.yMessage,v=uk.useAsset("ic_camera.png"),b=uk.useAsset("ic_camera_disabled.png"),C=uk.useAsset("ic_id_front.png"),E=uk.useAsset("ic_id_back.png"),w=uk.useAsset("ic_loading.png"),k=lC.useSDKSettings().lang,S=fm(oy.useState(""),2),B=S[0],T=S[1],A=fm(oy.useState(null),2),I=A[0],_=A[1],x=DB.useThemeContext(),P=fm(oy.useState(null),2),R=P[0],N=P[1],O=x.primaryColor,L=x.dangerColor,D=function(){var e=fm(oy.useState(!1),2),t=e[0],r=e[1],n=fm(oy.useState(null),2),i=n[0],a=n[1],o=fm(oy.useState({}),2),s=o[0],c=o[1];return{showPopup:oy.useCallback((function(e){var t=e.popupType,n=e.props;c(void 0===n?{}:n),a(t),r(null!==t)}),[]),popupShown:t,popupType:i,props:s}}(),U=D.showPopup,M=D.popupShown,V=D.popupType,j=oy.useRef((function(){})),F=oy.useCallback((function(e){T(null===e?"":aW(NX[e.code].msg[k])({side:o?RX.FRONT[k]:RX.BACK[k]}))}),[k,o]),z=oy.useCallback((function(){N(""),U({popupType:oW})}),[U]),K=oy.useCallback((function(e){var t=e.curTimeLeft;N(aW(zX.REMAINING_TIME[k])({x:t}))}),[k]),q=uK({shouldStart:!0,refVideo:a,cropArea:I,settings:s,onModelErrorChange:F,frontSide:o,onSessionTimeout:z,onCaptureDone:c,onAboutToTimeout:K,outputEncryptionSettings:l}),H=q.warmupDone,G=q.isProcessing,Q=q.takePictureManually,W=q.restartSession,X=q.resetIsProcessingImageBlobTaken,Y=oy.useCallback((function(){U({popupType:null}),X()}),[U,X]),$=oy.useCallback(Jg(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Y(),e.next=3,W();case 3:case"end":return e.stop()}}),e)}))),[W,Y]);j.current=$,oy.useEffect((function(){if(i){var e,t,r,a,o,s,c,l,d=i.videoAreaWidth,f=i.videoAreaHeight,h=i.lostX,g=i.lostY,m=i.clientHeight;n?(s=.7*(c=f-165),r=(l=(e=g+10)+45)+20,a=l+c+70):(s=JH.isMobile?d-8:Math.floor(.7*d),c=Math.floor(Math.min(s/1.5,m-2*g-80-145)),r=(t=(l=(e=g+16)+(JH.isMobile?40:65))+c+10)+(JH.isMobile?35:25),o=JH.isMobile?t+60:e+30,a=t+158);var y=Math.floor((d-s)/2)+h;_({x:y,y:l,width:s,height:c,surroundStyle:{background:"#fff"}});var v={yTitle:e,yErrorMessage:t,yMessage:r,yDescription:o,yCaptureButton:a};p(v),u(v)}}),[i,n,u]);var Z=oy.useCallback(Jg(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return N(""),e.next=3,Q();case 3:case"end":return e.stop()}}),e)}))),[Q]);oy.useImperativeHandle(t,(function(){return{restartSession:$}}),[$]);var J=!(G||null!=s&&s.disableCaptureButtonIfAlert&&B);return oy.createElement(oy.Fragment,null,!H&&oy.createElement(Pj,null),G&&oy.createElement(vX,null,oy.createElement("img",{src:w,alt:"",className:"spin"})),I&&oy.createElement(UD,{x:"".concat(I.x,"px"),y:"".concat(I.y,"px"),width:"".concat(I.width,"px"),height:"".concat(I.height,"px"),surroundStyle:I.surroundStyle},oy.createElement(TX,{strokeStyles:(r={},nm(r,TF.DEFAULT,{fill:"none",strokeWidth:5,stroke:O}),nm(r,TF.ERROR,{fill:"none",strokeWidth:5,stroke:O}),r),paddingStyle:{fill:"#fff"},strokeWidth:5,errorColor:L,width:I.width,height:I.height,type:B?TF.ERROR:TF.DEFAULT})),B&&oy.createElement(BX,{y:"".concat(h,"px")},B),oy.createElement(IX,{y:"".concat(g,"px")},JH.isMobile&&oy.createElement("div",null,oy.createElement("img",{src:o?C:E,width:70,height:45,alt:""})),"Đặt CMND/CCCD của bạn vào giữa khung. Hình ảnh rõ ràng, không bị chói, mờ & cắt góc."),oy.createElement(yX,{onClick:J?Z:null,y:"".concat(m,"px")},oy.createElement("img",{src:J?v:b,alt:""})),R&&oy.createElement(AX,{key:R,y:"".concat(y,"px")},R),oy.createElement(sX,{open:M},V===oW&&oy.createElement(MX,{onOk:$,maxSessionTime:null==s?void 0:s.idCardSessionTime})))}));KX.propTypes={usePortraitMask:Py.bool,windowAndVideoInfo:Py.shape({}),refVideo:Py.shape({}),frontSide:Py.bool,settings:Py.shape({}),onCaptureDone:Py.func,onUISpacingChange:Py.func,outputEncryptionSettings:Py.shape({})},KX.defaultProps={usePortraitMask:!1,windowAndVideoInfo:{},refVideo:{},frontSide:!0,settings:{},onCaptureDone:function(){},onUISpacingChange:function(){},outputEncryptionSettings:null};var qX,HX,GX,QX,WX,XX,YX,$X,ZX,JX=eC.button(VX||(VX=dm(["\n background: #0b74e5;\n height: 44px;\n border-radius: 4px;\n border: 0;\n padding: 0 20px;\n color: #fff;\n cursor: pointer;\n font-size: 16px;\n font-weight: 500;\n width: 160px;\n"]))),eY=eC.button(jX||(jX=dm(["\n background: #fff;\n height: 44px;\n border-radius: 4px;\n border: 1px solid #0b74e5;\n padding: 0 20px;\n color: #0b74e5;\n cursor: pointer;\n font-size: 16px;\n font-weight: 500;\n width: 160px;\n &:focus {\n outline: none;\n box-shadow: none;\n }\n"]))),tY=(eC.a(FX||(FX=dm(["\n text-decoration: underline;\n font-size: 16px;\n color: #000;\n cursor: pointer;\n"]))),eC.div(qX||(qX=dm(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n padding: 10px;\n"])))),rY=eC.div(HX||(HX=dm(["\n text-align: center;\n font-size: 1rem;\n color: ",";\n margin-top: 10px;\n"])),(function(e){return e.theme.dangerColor})),nY=eC.div(GX||(GX=dm(["\n margin: 20px 0;\n width: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n"]))),iY=eC.div(QX||(QX=dm(["\n margin-right: 5px;\n"]))),aY=eC.div(WX||(WX=dm(["\n margin-left: 5px;\n"]))),oY=eC.img(XX||(XX=dm(["\n ",";\n border-radius: 12px;\n border: 5px solid #1aa7ff;\n margin-top: 30px;\n ",";\n"])),!JH.isMobile&&Vb(["height:","px;"],(function(e){return e.calHeight-300})),(function(e){return e.calHeight>0&&JH.isMobile&&Vb(["width:","px;height:","px;border:none;border-radius:8px;"],window.innerWidth-30,e.calHeight)})),sY=eC.div(YX||(YX=dm(["\n font-size: ","px;\n font-weight: 500;\n color: #38383d;\n"])),JH.isMobile?16:24),cY=eC.div($X||($X=dm(["\n margin: 8px 0;\n font-size: ","px;\n font-weight: normal;\n color: #38383d;\n text-align: center;\n"])),JH.isMobile?14:16),uY=eC.div(ZX||(ZX=dm(["\n margin-top: 20px;\n font-size: ","px;\n font-weight: normal;\n color: #38383d;\n text-align: center;\n"])),JH.isMobile?14:16),lY=function(e){var t=e.title,r=e.imageTaken,n=e.onConfirm,i=e.onTryAgain,a=e.error,o=e.hasValidQR,s=fm(oy.useState(null),2),c=s[0],u=s[1],l=lC.useSDKSettings().lang,d=uk.useAsset("ic_close.png"),f=uk.useAsset("ic_close_desktop.png"),p=fm(oy.useState(JH.isMobile?0:window.innerHeight),2),h=p[0],g=p[1],m=oy.useRef();oy.useEffect((function(){var e;return r&&(e=URL.createObjectURL(r.blob),u(e)),function(){URL.revokeObjectURL(e)}}),[r]);return oy.createElement(tY,null,null!==o&&oy.createElement(bK,{mb:"20px"},oy.createElement("div",null,oy.createElement(Rq,{type:o?Bq.SUCCESS:Bq.WARNING},o?RX.CONFIRM_POPUP_VALID_QR[l]:RX.CONFIRM_POPUP_INVALID_QR[l]))),oy.createElement(sY,null,t),!JH.isMobile&&oy.createElement(cY,null,"Đặt CMND / CCCD của bạn vào giữa khung. Hình ảnh rõ ràng, không bị chói mờ & cắt góc."),oy.createElement(oY,{ref:m,src:c,calHeight:h,onLoad:function(){if(JH.isMobile){var e=m.current,t=e.height/e.width,r=(window.innerWidth-30)*t;g(r)}}}),oy.createElement(uY,null,"Nhìn ổn chứ? Bạn có thể tự chụp lại để có ảnh tốt hơn."),a&&oy.createElement(rY,{className:"confirm-popup-error-message"},a.msg[l]),oy.createElement(nY,null,oy.createElement(iY,null,oy.createElement(eY,{type:"button",onClick:i},RX.BTN_TRY_AGAIN[l])),oy.createElement(aY,null,oy.createElement(JX,{onClick:n},RX.BTN_USE_THIS_PICTURE[l]))),oy.createElement(xX,{onClick:i},oy.createElement("img",{src:JH.isMobile?d:f,alt:""})))};lY.propTypes={imageTaken:Py.shape({}),error:Py.shape({msg:Py.shape({})}),onConfirm:Py.func,onTryAgain:Py.func,hasValidQR:Py.bool,title:Py.string},lY.defaultProps={imageTaken:null,error:null,onConfirm:function(){},onTryAgain:function(){},hasValidQR:null,title:""};var dY,fY={primaryColor:"#1AA7FF",dangerColor:"#FF424E"},pY="CONFIRM",hY=rC(dY||(dY=dm(["\n"]))),gY=oC.IDCardSide,mY=oC.IDCardType,yY="id_card",vY="qr_code",bY=[{scannerType:yY,title:"Chụp mặt trước",cardSide:oC.IDCardSide.FRONT,cardType:mY.VN,frontCamera:!1,enableConfirmPopup:!0},{scannerType:yY,title:"Chụp mặt sau",cardSide:oC.IDCardSide.BACK,cardType:mY.VN,frontCamera:!1,enableConfirmPopup:!0}];function CY(e){var t=e.onClose,r=e.onError,n=e.clientSettings,i=e.onStepDone,a=e.steps,o=e.outputEncryptionSettings,s=fm(oy.useState(0),2),c=s[0],u=s[1],l=fm(oy.useState(a[c]),2),d=l[0],f=l[1],p=oy.useRef(null),h=fm(oy.useState(null),2),g=h[0],m=h[1],y=fm(oy.useState(!1),2),v=y[0],b=y[1],C=fm(oy.useState(0),2),E=C[0],w=C[1],k=oy.useRef(),S=d.scannerType,B=d.frontCamera,T=d.title,A=d.cardSide,I=d.usePortraitMask,_=d.enableConfirmPopup,x=uk.useAsset("ic_close.png"),P=uk.useAsset("ic_close_desktop.png"),R=uk.useAsset("ic_loading.png"),N=A===gY.FRONT,O=Az(),L=O.showPopup,D=O.popupShown,U=O.popupType,M=O.props,V=fm(oy.useState(!1),2),j=V[0],F=V[1],z=oy.useRef(null),K=oy.useRef(null),q=oy.useRef([]),H=tH({clientSettings:n}).settings,G=fm(oy.useState({}),2),Q=G[0],W=G[1],X=Q.yTitle,Y=ok.useSDKTracking().sendEvent,$=oy.useCallback((function(e){m(e),b(!0)}),[]);oy.useEffect((function(){b(!1)}),[B]);var Z=oy.useCallback((function(){L({popupType:null})}),[L]),J=oy.useCallback((function(e){e>=a.length||setTimeout((function(){u(e),f(a[e])}),200)}),[a]),ee=oy.useCallback((function(){J(c+1)}),[J,c]),te=oy.useCallback(Jg(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={stepNumber:c,image:z.current,recordedVideos:null!=H&&H.enableRecording?q.current:[]},S===vY&&(t.qrScannedResult=K.current),F(!0),e.next=5,i(t);case 5:Y({tag:"result",event:"sdk_mode.read_id_card_one_side",log:{result_object:t}}),F(!1),ee();case 8:case"end":return e.stop()}}),e)}))),[H,c,i,ee,S,Y]),re=oy.useCallback((function(){Z(),S===vY?J(c):S===yY&&(Y({tag:N?"id_front":"id_back",event:"user_activity.retry",log:{}}),k.current.restartSession())}),[J,c,Z,S,N,Y]),ne=oy.useCallback((function(){Z(),Y({tag:N?"id_front":"id_back",event:"user_activity.submit",log:{}}),te()}),[te,Z,Y,N]),ie=oy.useCallback(function(){var e=Jg(regeneratorRuntime.mark((function e(t){var r,n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.image,n=t.error,i=t.recordedVideos,z.current=r,q.current=i,w((function(e){return e+1})),_?L({popupType:pY,props:{title:T,imageTaken:z.current,error:n}}):te();case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[_,L,te,T]);return oy.createElement($b,{theme:fY},oy.createElement(mX,null,oy.createElement(PD,{key:B,frontCamera:B,onVideoPlayed:$,onClose:t,flipHorizontal:B,ref:p,onError:r,closeButton:oy.createElement(xX,null,oy.createElement("img",{src:JH.isMobile?x:P,alt:""}))},v&&oy.createElement(oy.Fragment,null,S===yY&&oy.createElement(KX,{key:c,ref:k,windowAndVideoInfo:g,refVideo:p,settings:H,onCaptureDone:ie,onUISpacingChange:W,frontSide:N,usePortraitMask:I,outputEncryptionSettings:o})),oy.createElement(gX,{keyForTransition:E}),oy.createElement(CX,{y:"".concat(X,"px")},oy.createElement(ZH,null,oy.createElement(GH,{key:T,timeout:{enter:hX,exit:hX},classNames:"flipY",unmountOnExit:!0},oy.createElement(EX,null,oy.createElement(wX,null,T))))),j&&oy.createElement(vX,null,oy.createElement("img",{src:R,alt:"",className:"spin"}))),oy.createElement(fj,{open:D,overlayStyle:{padding:0},contentStyle:{maxWidth:"none",width:"100%",height:"100%",borderRadius:0}},U===pY&&oy.createElement(lY,im({},M,{onConfirm:ne,onTryAgain:re})))),oy.createElement(hY,null))}CY.propTypes={onClose:Py.func,onError:Py.func,clientSettings:Py.shape({}),detectIdCard:Py.func,onStepDone:Py.func,steps:Py.arrayOf(Py.shape({})),outputEncryptionSettings:Py.shape({})},CY.defaultProps={onClose:function(){},onError:function(){},clientSettings:{},detectIdCard:function(){return Promise.resolve({card_label:""})},onStepDone:function(){},steps:bY,outputEncryptionSettings:null};var EY=function(e,t,r,n,i,a,o,s){if(!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,i,a,o,s],l=0;(c=new Error(t.replace(/%s/g,(function(){return u[l++]})))).name="Invariant Violation"}throw c.framesToPop=1,c}},wY=i(a((function(e,t){!function(e,t){t=t&&t.hasOwnProperty("default")?t.default:t;var r=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/read_id_card_info_sync",e,t)},e}(),i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};
62
62
  /*! *****************************************************************************
63
63
  Copyright (c) Microsoft Corporation. All rights reserved.
64
64
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -72,4 +72,4 @@ function(e){var t=r,n=t.lib,i=n.WordArray,a=n.Hasher,o=t.algo,s=i.create([0,1,2,
72
72
 
73
73
  See the Apache Version 2.0 License for specific language governing permissions
74
74
  and limitations under the License.
75
- ***************************************************************************** */function a(e,t,r,n){var i,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,r,o):i(t,r))||o);return a>3&&o&&Object.defineProperty(t,r,o),o}function o(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function s(e,t,r,n){return new(r||(r=Promise))((function(i,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var u=function(){function e(e){this.httpClient=e}return e.prototype.uploadImage=function(e){return this.httpClient.postFormData("/v1/images",e)},e.prototype.request=function(e){var t="application/pdf"===e.file.type;return this.httpClient.postFormData(t?"/v1/files":"/v1/images",e)},e.prototype.requestWithHeaders=function(e,t){return this.httpClient.postFormData("/v1/images",e,t)},e.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.httpClient.downloadFile("/v1/images/"+e)];case 1:return t=r.sent(),[4,URL.createObjectURL(t)];case 2:return[2,r.sent()]}}))}))},e.prototype.updateMetadata=function(e,t){return this.httpClient.patch("/v1/images/"+e,t)},e}(),l=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/files",e,t)},e.prototype.uploadFile=function(e){return this.httpClient.postFormData("/v1/files",e)},e.prototype.requestWithHeaders=function(e,t){return this.httpClient.postFormData("/v1/files",e,t)},e}(),d=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/compare_faces_sync",e,t)},e}(),f=function(){function e(e){this.httpClient=e}return e.prototype.getClientSettings=function(){return this.httpClient.get("/v1/client_settings")},e.prototype.request=function(){return this.httpClient.get("/v1/client_settings")},e}(),p=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_face_liveness_sync",e,t)},e}(),h=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_id_card_sanity_sync",e,t)},e}(),g=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_portrait_sanity_sync",e,t)},e}(),m=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/detect_id_card_tampering_sync",e,t)},e.prototype.requestWithAuthHeaders=function(e,t){return this.httpClient.post("/v1/detect_id_card_tampering_sync",e,t)},e}(),y=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/search_faces_sync",e,t)},e.prototype.indexFaces=function(e,t){return this.httpClient.post("/v1/index_faces_sync",e,t)},e.prototype.deleteFaces=function(e,t){return this.httpClient.post("/v1/delete_faces",e,t)},e.prototype.downloadFaceImage=function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.httpClient.downloadFile("/v1/face_images/"+e)];case 1:return t=r.sent(),[2,URL.createObjectURL(t)]}}))}))},e}(),v=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.postFormData("/v1/convert_pdf_sync",e,t)},e}(),b=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/ekyc_pdf",e,t)},e}(),C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{};function E(e,t){return e(t={exports:{}},t.exports),t.exports}var w=E((function(e){var t,r;t=C,r=function(){function e(e){var t=[];if(0===e.length)return"";if("string"!=typeof e[0])throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var r=e.shift();e[0]=r+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<e.length;n++){var i=e[n];if("string"!=typeof i)throw new TypeError("Url must be a string. Received "+i);""!==i&&(n>0&&(i=i.replace(/^[\/]+/,"")),i=n<e.length-1?i.replace(/[\/]+$/,""):i.replace(/[\/]+$/,"/"),t.push(i))}var a=t.join("/"),o=(a=a.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return o.shift()+(o.length>0?"?":"")+o.join("&")}return function(){return e("object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments))}},e.exports?e.exports=r():t.urljoin=r()}));function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var S=function(e,t,r,n){t=t||"&",r=r||"=";var i={};if("string"!=typeof e||0===e.length)return i;var a=/\+/g;e=e.split(t);var o=1e3;n&&"number"==typeof n.maxKeys&&(o=n.maxKeys);var s=e.length;o>0&&s>o&&(s=o);for(var c=0;c<s;++c){var u,l,d,f,p=e[c].replace(a,"%20"),h=p.indexOf(r);h>=0?(u=p.substr(0,h),l=p.substr(h+1)):(u=p,l=""),d=decodeURIComponent(u),f=decodeURIComponent(l),k(i,d)?Array.isArray(i[d])?i[d].push(f):i[d]=[i[d],f]:i[d]=f}return i},B=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},T=function(e,t,r,n){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(n){var i=encodeURIComponent(B(n))+r;return Array.isArray(e[n])?e[n].map((function(e){return i+encodeURIComponent(B(e))})).join(t):i+encodeURIComponent(B(e[n]))})).join(t):n?encodeURIComponent(B(n))+r+encodeURIComponent(B(e)):""},A=E((function(e,t){t.decode=t.parse=S,t.encode=t.stringify=T})),I=(A.decode,A.parse,A.encode,A.stringify),_=function(){function e(e){this.authorizer=e.authorizer,this.domain=e.domain,this.onError=e.onError,this.configHeaders=e.headers}return e.prototype.get=function(e,t,r){var n=new URL(this.resolveUrl(e));return t&&(n.search=I(t)),this.request(n.toString(),{requestPath:e,method:"GET",headers:r})},e.prototype.post=function(e,t,r){var n=this.resolveUrl(e);return this.request(n,{requestPath:e,method:"POST",body:JSON.stringify(t),headers:i({"Content-Type":"application/json"},r)})},e.prototype.postFormData=function(e,t,r){var n,i=t instanceof FormData?t:(n=t,Object.entries(n).reduce((function(e,t){var r=t[0],n=t[1];return Array.isArray(n)?n.forEach((function(t,i){return e.append(r+"["+i+"]",n)})):!(n instanceof Object)||n instanceof File||n instanceof Date||n instanceof Blob?e.append(r,n):Object.entries(n).forEach((function(t,i){return e.append(r+"["+i+"]",n[i])})),e}),new FormData)),a=this.resolveUrl(e);return this.request(a,{requestPath:e,method:"POST",body:i,headers:r})},e.prototype.patch=function(e,t,r){var n=this.resolveUrl(e);return this.request(n,{requestPath:e,method:"PATCH",body:JSON.stringify(t),headers:i({"Content-Type":"application/json"},r)})},e.prototype.delete=function(e,t,r){var n=this.resolveUrl(e);return this.request(n,{requestPath:e,method:"DELETE",body:JSON.stringify(t),headers:i({"Content-Type":"application/json"},r)})},e.prototype.downloadFile=function(e){var t=this.resolveUrl(e);return this.request(t,{requestPath:e,method:"GET"},"blob")},e.prototype.request=function(e,t,r){return void 0===r&&(r="json"),s(this,void 0,void 0,(function(){var n,a,o,s;return c(this,(function(c){switch(c.label){case 0:return n={},a={},this.authorizer&&(n=this.authorizer.getHeaders(t)),this.configHeaders&&(a=this.configHeaders),t.headers=i(i(i({},t.headers),n),a),[4,fetch(e,t)];case 1:return o=c.sent(),[4,"blob"===r?o.blob():o.json()];case 2:if((s=c.sent()).errors&&this.onError)throw this.onError(s.errors),s;return[2,s]}}))}))},e.prototype.resolveUrl=function(e){return w(this.domain,e)},e}(),x=function(){function e(e){this.mocks=e}return e.prototype.get=function(e,t){return this.findInMocks(e,t)},e.prototype.post=function(e,t){return this.findInMocks(e)},e.prototype.postFormData=function(e,t){return this.findInMocks(e)},e.prototype.patch=function(e,t){return this.findInMocks(e)},e.prototype.delete=function(e,t){return this.findInMocks(e)},e.prototype.downloadFile=function(e){return this.findInMocks(e)},e.prototype.resolveUrl=function(e){return this.mocks.resolveUrl?this.mocks.resolveUrl(e):e},e.prototype.findInMocks=function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(r){return this.mocks[e]?"function"==typeof this.mocks[e]?[2,Promise.resolve(this.mocks[e](t))]:[2,Promise.resolve(this.mocks[e])]:[2,Promise.reject(new Error(e+" is not presented in mocks"))]}))}))},e}(),P=E((function(e,t){var r;e.exports=r=r||function(e,t){var r=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),n={},i=n.lib={},a=i.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=i.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var a=0;a<i;a++){var o=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=o<<24-(n+a)%4*8}else for(a=0;a<i;a+=4)t[n+a>>>2]=r[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],i=function(t){t=t;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}},a=0;a<t;a+=4){var s=i(4294967296*(r||e.random()));r=987654071*s(),n.push(4294967296*s()|0)}return new o.init(n,t)}}),s=n.enc={},c=s.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new o.init(r,t/2)}},u=s.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(a))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new o.init(r,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},d=i.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,i=r.sigBytes,a=this.blockSize,s=i/(4*a),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,u=e.min(4*c,i);if(c){for(var l=0;l<c;l+=a)this._doProcessBlock(n,l);var d=n.splice(0,c);r.sigBytes-=u}return new o.init(d,u)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),f=(i.Hasher=d.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new f.HMAC.init(e,r).finalize(t)}}}),n.algo={});return n}(Math)})),R=E((function(e,t){var r,n,i;e.exports=(n=(r=i=P).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],a=0;a<r;a+=3)for(var o=(t[a>>>2]>>>24-a%4*8&255)<<16|(t[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|t[a+2>>>2]>>>24-(a+2)%4*8&255,s=0;s<4&&a+.75*s<r;s++)i.push(n.charAt(o>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var a=0;a<r.length;a++)i[r.charCodeAt(a)]=a}var o=r.charAt(64);if(o){var s=e.indexOf(o);-1!==s&&(t=s)}return function(e,t,r){for(var i=[],a=0,o=0;o<t;o++)if(o%4){var s=r[e.charCodeAt(o-1)]<<o%4*2,c=r[e.charCodeAt(o)]>>>6-o%4*2;i[a>>>2]|=(s|c)<<24-a%4*8,a++}return n.create(i,a)}(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)})),N=(E((function(e,t){var r;e.exports=(r=P,function(e){var t=r,n=t.lib,i=n.WordArray,a=n.Hasher,o=t.algo,s=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(s[i]=r(e.pow(n,.5))),c[i]=r(e.pow(n,1/3)),i++),n++}();var u=[],l=o.SHA256=a.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],d=r[6],f=r[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var h=u[p-15],g=(h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3,m=u[p-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[p]=g+u[p-7]+y+u[p-16]}var v=n&i^n&a^i&a,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),C=f+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&l^~s&d)+c[p]+u[p];f=d,d=l,l=s,s=o+C|0,o=a,a=i,i=n,n=C+(b+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+o|0,r[4]=r[4]+s|0,r[5]=r[5]+l|0,r[6]=r[6]+d|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=a._createHelper(l),t.HmacSHA256=a._createHmacHelper(l)}(Math),r.SHA256)})),E((function(e,t){var r,n,i;e.exports=(n=(r=P).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var a=this._oKey=t.clone(),o=this._iKey=t.clone(),s=a.words,c=o.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;a.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))})),E((function(e,t){e.exports=P.HmacSHA256}))),O=function(){function e(e,t){this.accessKey=e,this.keySecret=t}return e.prototype.getHeaders=function(e){var t=function(e){function t(e){return e<10?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+"T"+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+(0===(r=e.getTimezoneOffset())?"Z":(n=r>0?"-":"+",r=Math.abs(r),n+t(Math.floor(r/60))+":"+t(r%60)));var r,n}(new Date);return{Authorization:this.generateAuthorization(e.requestPath,e.method,t),"X-TV-Timestamp":t}},e.prototype.generateAuthorization=function(e,t,r){var n=this.computeStringToSign(e,t,r),i=R.stringify(this.computeSignature(n));return this.formatAuthToken("TV",i)},e.prototype.formatAuthToken=function(e,t){return e+" "+this.accessKey+":"+t},e.prototype.computeStringToSign=function(e,t,r){return t+"\n"+e+"\n"+r},e.prototype.computeSignature=function(e){return N(e,this.keySecret)},e}();function L(e){switch(e){case"testing":return"https://tv-testing.trustingsocial.com/api";case"staging":return"https://tv-staging.trustingsocial.com/api";case"production":return"https://vn-vision.trustingsocial.com/api";default:return e}}function D(e,t,r,n){void 0===r&&(r="production");var i=(void 0===n?{}:n).headers,a=new O(e,t),o=L(r);return new _({authorizer:a,domain:o,headers:i})}var U=function(){function e(e){void 0===e&&(e="production");var t=new _({domain:L(e)});this.imagesService=new u(t),this.detectIDTamperingService=new m(t)}return e.prototype.uploadImage=function(e,t){return this.imagesService.requestWithHeaders(e,t)},e.prototype.detectTampering=function(e,t){return this.detectIDTamperingService.requestWithAuthHeaders(e,t)},e}();function M(e){var t=e.headerIndex;return function(e,r,n){var a=n.value,o=i({},n);return o.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return s(this,void 0,void 0,(function(){var r,n,o,s;return c(this,(function(c){switch(c.label){case 0:return this.transactionEnabled?[4,this.transactionManager.begin()]:[3,4];case 1:return r=c.sent(),n=function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<r;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)n[i]=a[o];return n}(e),(o=i({},n[t]))["X-TV-Transaction"]=r,n[t]=o,[4,a.apply(this,n)];case 2:return s=c.sent(),[4,this.transactionManager.end()];case 3:return c.sent(),[2,s];case 4:return[4,a.apply(this,e)];case 5:return[2,c.sent()]}}))}))},o}}function V(e){return void 0===e&&(e={encryptedField:"data"}),function(t,r,n){var a=n.value,o=i({},n);return o.value=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return s(this,void 0,void 0,(function(){var r,n;return c(this,(function(i){switch(i.label){case 0:return[4,a.apply(this,t)];case 1:return r=i.sent(),this.encryptionEnabled&&"string"==typeof r[e.encryptedField]?(n=this.encryptionService.decrypt(r[e.encryptedField],{transactionID:this.transactionManager.currentTransactionID}),[2,JSON.parse(n)]):[2,r]}}))}))},o}}var j=function(){function e(e){this.httpClient=e,this.transactionID="",this.totalTransactions=0,this.currentTransaction=0}return Object.defineProperty(e.prototype,"currentTransactionID",{get:function(){return this.transactionID},enumerable:!0,configurable:!0}),e.prototype.begin=function(){return s(this,void 0,void 0,(function(){var e,t,r=this;return c(this,(function(n){switch(n.label){case 0:return e=this.totalTransactions++,[4,new Promise((function(t,n){var i=window.performance.now(),a=setInterval((function(){e===r.currentTransaction&&(clearInterval(a),t(!0)),window.performance.now()-i>=3e3&&(clearInterval(a),n(new Error("Transaction timeout")))}),100)}))];case 1:return n.sent(),[4,this.httpClient.post("/v1/transactions",{})];case 2:return t=n.sent().data,this.transactionID=t.id,[2,t.id]}}))}))},e.prototype.end=function(){return s(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return[4,this.httpClient.post("/v1/transactions/"+this.transactionID+"/finish")];case 1:return e=t.sent(),this.transactionID="",this.currentTransaction++,[2,e]}}))}))},e}(),F={options:{usePureJavaScript:!1}},z={},K=z,q={};z.encode=function(e,t,r){if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,a=t.length,o=t.charAt(0),s=[0];for(i=0;i<e.length;++i){for(var c=0,u=e[i];c<s.length;++c)u+=s[c]<<8,s[c]=u%a,u=u/a|0;for(;u>0;)s.push(u%a),u=u/a|0}for(i=0;0===e[i]&&i<e.length-1;++i)n+=o;for(i=s.length-1;i>=0;--i)n+=t[s[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),a=[0];for(r=0;r<e.length();++r){for(var o=0,s=e.at(r);o<a.length;++o)s+=a[o]<<8,a[o]=s%n,s=s/n|0;for(;s>0;)a.push(s%n),s=s/n|0}var c="";for(r=0;0===e.at(r)&&r<e.length()-1;++r)c+=i;for(r=a.length-1;r>=0;--r)c+=t[a[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},z.decode=function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');var r=q[t];if(!r){r=q[t]=[];for(var n=0;n<t.length;++n)r[t.charCodeAt(n)]=n}e=e.replace(/\s/g,"");var i=t.length,a=t.charAt(0),o=[0];for(n=0;n<e.length;n++){var s=r[e.charCodeAt(n)];if(void 0===s)return;for(var c=0,u=s;c<o.length;++c)u+=o[c]*i,o[c]=255&u,u>>=8;for(;u>0;)o.push(255&u),u>>=8}for(var l=0;e[l]===a&&l<e.length-1;++l)o.push(0);return"undefined"!=typeof Buffer?Buffer.from(o.reverse()):new Uint8Array(o.reverse())},E((function(e){var t=e.exports=F.util=F.util||{};function r(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function n(e){if(this.data="",this.read=0,"string"==typeof e)this.data=e;else if(t.isArrayBuffer(e)||t.isArrayBufferView(e))if("undefined"!=typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var r=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,r)}catch(e){for(var i=0;i<r.length;++i)this.putByte(r[i])}}else(e instanceof n||"object"==typeof e&&"string"==typeof e.data&&"number"==typeof e.read)&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}!function(){if("undefined"!=typeof process&&process.nextTick&&!process.browser)return t.nextTick=process.nextTick,void("function"==typeof setImmediate?t.setImmediate=setImmediate:t.setImmediate=t.nextTick);if("function"==typeof setImmediate)return t.setImmediate=function(){return setImmediate.apply(void 0,arguments)},void(t.nextTick=function(e){return setImmediate(e)});if(t.setImmediate=function(e){setTimeout(e,0)},"undefined"!=typeof window&&"function"==typeof window.postMessage){var e="forge.setImmediate",r=[];t.setImmediate=function(t){r.push(t),1===r.length&&window.postMessage(e,"*")},window.addEventListener("message",(function(t){if(t.source===window&&t.data===e){t.stopPropagation();var n=r.slice();r.length=0,n.forEach((function(e){e()}))}}),!0)}if("undefined"!=typeof MutationObserver){var n=Date.now(),i=!0,a=document.createElement("div");r=[],new MutationObserver((function(){var e=r.slice();r.length=0,e.forEach((function(e){e()}))})).observe(a,{attributes:!0});var o=t.setImmediate;t.setImmediate=function(e){Date.now()-n>15?(n=Date.now(),o(e)):(r.push(e),1===r.length&&a.setAttribute("a",i=!i))}}t.nextTick=t.setImmediate}(),t.isNodejs="undefined"!=typeof process&&process.versions&&process.versions.node,t.globalScope=t.isNodejs?C:"undefined"==typeof self?window:self,t.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},t.isArrayBufferView=function(e){return e&&t.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},t.ByteBuffer=n,t.ByteStringBuffer=n,t.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},t.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},t.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},t.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},t.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},t.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},t.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(t.encodeUtf8(e))},t.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},t.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},t.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},t.ByteStringBuffer.prototype.putInt=function(e,t){r(t);var n="";do{t-=8,n+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(n)},t.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},t.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},t.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},t.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},t.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},t.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},t.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},t.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},t.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},t.ByteStringBuffer.prototype.getInt=function(e){r(e);var t=0;do{t=(t<<8)+this.data.charCodeAt(this.read++),e-=8}while(e>0);return t},t.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},t.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},t.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},t.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},t.ByteStringBuffer.prototype.copy=function(){var e=t.createBuffer(this.data);return e.read=this.read,e},t.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},t.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},t.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},t.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);r<16&&(e+="0"),e+=r.toString(16)}return e},t.ByteStringBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())},t.DataBuffer=function(e,r){r=r||{},this.read=r.readOffset||0,this.growSize=r.growSize||1024;var n=t.isArrayBuffer(e),i=t.isArrayBufferView(e);if(n||i)return this.data=n?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),void(this.write="writeOffset"in r?r.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!=e&&this.putBytes(e),"writeOffset"in r&&(this.write=r.writeOffset)},t.DataBuffer.prototype.length=function(){return this.write-this.read},t.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},t.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},t.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},t.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r<t;++r)this.data.setUint8(e);return this},t.DataBuffer.prototype.putBytes=function(e,r){if(t.isArrayBufferView(e)){var n=(i=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).byteLength-i.byteOffset;return this.accommodate(n),new Uint8Array(this.data.buffer,this.write).set(i),this.write+=n,this}if(t.isArrayBuffer(e)){var i=new Uint8Array(e);return this.accommodate(i.byteLength),new Uint8Array(this.data.buffer).set(i,this.write),this.write+=i.byteLength,this}if(e instanceof t.DataBuffer||"object"==typeof e&&"number"==typeof e.read&&"number"==typeof e.write&&t.isArrayBufferView(e.data))return i=new Uint8Array(e.data.byteLength,e.read,e.length()),this.accommodate(i.byteLength),new Uint8Array(e.data.byteLength,this.write).set(i),this.write+=i.byteLength,this;if(e instanceof t.ByteStringBuffer&&(e=e.data,r="binary"),r=r||"binary","string"==typeof e){var a;if("hex"===r)return this.accommodate(Math.ceil(e.length/2)),a=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.hex.decode(e,a,this.write),this;if("base64"===r)return this.accommodate(3*Math.ceil(e.length/4)),a=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.base64.decode(e,a,this.write),this;if("utf8"===r&&(e=t.encodeUtf8(e),r="binary"),"binary"===r||"raw"===r)return this.accommodate(e.length),a=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.raw.decode(a),this;if("utf16"===r)return this.accommodate(2*e.length),a=new Uint16Array(this.data.buffer,this.write),this.write+=t.text.utf16.encode(a),this;throw new Error("Invalid encoding: "+r)}throw Error("Invalid parameter: "+e)},t.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},t.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},t.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},t.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},t.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},t.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},t.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},t.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},t.DataBuffer.prototype.putInt=function(e,t){r(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},t.DataBuffer.prototype.putSignedInt=function(e,t){return r(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},t.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},t.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},t.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},t.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},t.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},t.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},t.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},t.DataBuffer.prototype.getInt=function(e){r(e);var t=0;do{t=(t<<8)+this.data.getInt8(this.read++),e-=8}while(e>0);return t},t.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},t.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},t.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},t.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},t.DataBuffer.prototype.copy=function(){return new t.DataBuffer(this)},t.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},t.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},t.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},t.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var r=this.data.getUint8(t);r<16&&(e+="0"),e+=r.toString(16)}return e},t.DataBuffer.prototype.toString=function(e){var r=new Uint8Array(this.data,this.read,this.length());if("binary"===(e=e||"utf8")||"raw"===e)return t.binary.raw.encode(r);if("hex"===e)return t.binary.hex.encode(r);if("base64"===e)return t.binary.base64.encode(r);if("utf8"===e)return t.text.utf8.decode(r);if("utf16"===e)return t.text.utf16.decode(r);throw new Error("Invalid encoding: "+e)},t.createBuffer=function(e,r){return r=r||"raw",void 0!==e&&"utf8"===r&&(e=t.encodeUtf8(e)),new t.ByteBuffer(e)},t.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},t.xorBytes=function(e,t,r){for(var n="",i="",a="",o=0,s=0;r>0;--r,++o)i=e.charCodeAt(o)^t.charCodeAt(o),s>=10&&(n+=a,a="",s=0),a+=String.fromCharCode(i),++s;return n+a},t.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},t.bytesToHex=function(e){return t.createBuffer(e).toHex()},t.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],o="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";t.encode64=function(e,t){for(var r,n,a,o="",s="",c=0;c<e.length;)r=e.charCodeAt(c++),n=e.charCodeAt(c++),a=e.charCodeAt(c++),o+=i.charAt(r>>2),o+=i.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=i.charAt((15&n)<<2|a>>6),o+=isNaN(a)?"=":i.charAt(63&a)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},t.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,o="",s=0;s<e.length;)t=a[e.charCodeAt(s++)-43],r=a[e.charCodeAt(s++)-43],n=a[e.charCodeAt(s++)-43],i=a[e.charCodeAt(s++)-43],o+=String.fromCharCode(t<<2|r>>4),64!==n&&(o+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(o+=String.fromCharCode((3&n)<<6|i)));return o},t.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},t.decodeUtf8=function(e){return decodeURIComponent(escape(e))},t.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:K.encode,decode:K.decode}},t.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},t.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,a=0;a<e.length;++a)n[i++]=e.charCodeAt(a);return t?i-r:n},t.binary.hex.encode=t.bytesToHex,t.binary.hex.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/2)));var i=0,a=r=r||0;for(1&e.length&&(i=1,n[a++]=parseInt(e[0],16));i<e.length;i+=2)n[a++]=parseInt(e.substr(i,2),16);return t?a-r:n},t.binary.base64.encode=function(e,t){for(var r,n,a,o="",s="",c=0;c<e.byteLength;)r=e[c++],n=e[c++],a=e[c++],o+=i.charAt(r>>2),o+=i.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=i.charAt((15&n)<<2|a>>6),o+=isNaN(a)?"=":i.charAt(63&a)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},t.binary.base64.decode=function(e,t,r){var n,i,o,s,c=t;c||(c=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var u=0,l=r=r||0;u<e.length;)n=a[e.charCodeAt(u++)-43],i=a[e.charCodeAt(u++)-43],o=a[e.charCodeAt(u++)-43],s=a[e.charCodeAt(u++)-43],c[l++]=n<<2|i>>4,64!==o&&(c[l++]=(15&i)<<4|o>>2,64!==s&&(c[l++]=(3&o)<<6|s));return t?l-r:c.subarray(0,l)},t.binary.base58.encode=function(e,r){return t.binary.baseN.encode(e,o,r)},t.binary.base58.decode=function(e,r){return t.binary.baseN.decode(e,o,r)},t.text={utf8:{},utf16:{}},t.text.utf8.encode=function(e,r,n){e=t.encodeUtf8(e);var i=r;i||(i=new Uint8Array(e.length));for(var a=n=n||0,o=0;o<e.length;++o)i[a++]=e.charCodeAt(o);return r?a-n:i},t.text.utf8.decode=function(e){return t.decodeUtf8(String.fromCharCode.apply(null,e))},t.text.utf16.encode=function(e,t,r){var n=t;n||(n=new Uint8Array(2*e.length));for(var i=new Uint16Array(n.buffer),a=r=r||0,o=r,s=0;s<e.length;++s)i[o++]=e.charCodeAt(s),a+=2;return t?a-r:n},t.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},t.deflate=function(e,r,n){if(r=t.decode64(e.deflate(t.encode64(r)).rval),n){var i=2;32&r.charCodeAt(1)&&(i=6),r=r.substring(i,r.length-4)}return r},t.inflate=function(e,r,n){var i=e.inflate(t.encode64(r)).rval;return null===i?null:t.decode64(i)};var s=function(e,r,n){if(!e)throw new Error("WebStorage not available.");var i;if(null===n?i=e.removeItem(r):(n=t.encode64(JSON.stringify(n)),i=e.setItem(r,n)),void 0!==i&&!0!==i.rval){var a=new Error(i.error.message);throw a.id=i.error.id,a.name=i.error.name,a}},c=function(e,r){if(!e)throw new Error("WebStorage not available.");var n=e.getItem(r);if(e.init)if(null===n.rval){if(n.error){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}n=null}else n=n.rval;return null!==n&&(n=JSON.parse(t.decode64(n))),n},u=function(e,t,r,n){var i=c(e,t);null===i&&(i={}),i[r]=n,s(e,t,i)},l=function(e,t,r){var n=c(e,t);return null!==n&&(n=r in n?n[r]:null),n},d=function(e,t,r){var n=c(e,t);if(null!==n&&r in n){delete n[r];var i=!0;for(var a in n){i=!1;break}i&&(n=null),s(e,t,n)}},f=function(e,t){s(e,t,null)},p=function(e,t,r){var n,i=null;void 0===r&&(r=["web","flash"]);var a=!1,o=null;for(var s in r){n=r[s];try{if("flash"===n||"both"===n){if(null===t[0])throw new Error("Flash local storage not available.");i=e.apply(this,t),a="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,i=e.apply(this,t),a=!0)}catch(e){o=e}if(a)break}if(!a)throw o;return i};t.setItem=function(e,t,r,n,i){p(u,arguments,i)},t.getItem=function(e,t,r,n){return p(l,arguments,n)},t.removeItem=function(e,t,r,n){p(d,arguments,n)},t.clearItems=function(e,t,r){p(f,arguments,r)},t.parseUrl=function(e){var t=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;t.lastIndex=0;var r=t.exec(e),n=null===r?null:{full:e,scheme:r[1],host:r[2],port:r[3],path:r[4]};return n&&(n.fullHost=n.host,n.port?(80!==n.port&&"http"===n.scheme||443!==n.port&&"https"===n.scheme)&&(n.fullHost+=":"+n.port):"http"===n.scheme?n.port=80:"https"===n.scheme&&(n.port=443),n.full=n.scheme+"://"+n.fullHost),n};var h=null;t.getQueryVariables=function(e){var t,r=function(e){for(var t={},r=e.split("&"),n=0;n<r.length;n++){var i,a,o=r[n].indexOf("=");o>0?(i=r[n].substring(0,o),a=r[n].substring(o+1)):(i=r[n],a=null),i in t||(t[i]=[]),i in Object.prototype||null===a||t[i].push(unescape(a))}return t};return void 0===e?(null===h&&(h="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=h):t=r(e),t},t.parseFragment=function(e){var r=e,n="",i=e.indexOf("?");i>0&&(r=e.substring(0,i),n=e.substring(i+1));var a=r.split("/");return a.length>0&&""===a[0]&&a.shift(),{pathString:r,queryString:n,path:a,query:""===n?{}:t.getQueryVariables(n)}},t.makeRequest=function(e){var r=t.parseFragment(e),n={path:r.pathString,query:r.queryString,getPath:function(e){return void 0===e?r.path:r.path[e]},getQuery:function(e,t){var n;return void 0===e?n=r.query:(n=r.query[e])&&void 0!==t&&(n=n[t]),n},getQueryLast:function(e,t){var r=n.getQuery(e);return r?r[r.length-1]:t}};return n},t.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var n=jQuery.param(t||{});return r=r||"",e+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")},t.setPath=function(e,t,r){if("object"==typeof e&&null!==e)for(var n=0,i=t.length;n<i;){var a=t[n++];if(n==i)e[a]=r;else{var o=a in e;(!o||o&&"object"!=typeof e[a]||o&&null===e[a])&&(e[a]={}),e=e[a]}}},t.getPath=function(e,t,r){for(var n=0,i=t.length,a=!0;a&&n<i&&"object"==typeof e&&null!==e;){var o=t[n++];(a=o in e)&&(e=e[o])}return a?e:r},t.deletePath=function(e,t){if("object"==typeof e&&null!==e)for(var r=0,n=t.length;r<n;){var i=t[r++];if(r==n)delete e[i];else{if(!(i in e)||"object"!=typeof e[i]||null===e[i])break;e=e[i]}}},t.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},t.format=function(e){for(var t,r,n=/%./g,i=0,a=[],o=0;t=n.exec(e);){(r=e.substring(o,n.lastIndex-2)).length>0&&a.push(r),o=n.lastIndex;var s=t[0][1];switch(s){case"s":case"o":i<arguments.length?a.push(arguments[1+i++]):a.push("<?>");break;case"%":a.push("%");break;default:a.push("<%"+s+"?>")}}return a.push(e.substring(o)),a.join("")},t.formatNumber=function(e,t,r,n){var i=e,a=isNaN(t=Math.abs(t))?2:t,o=void 0===r?",":r,s=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(a),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+s:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+s)+(a?o+Math.abs(i-u).toFixed(a).slice(2):"")},t.formatSize=function(e){return e>=1073741824?t.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?t.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?t.formatNumber(e/1024,0)+" KiB":t.formatNumber(e,0)+" bytes"},t.bytesFromIP=function(e){return-1!==e.indexOf(".")?t.bytesFromIPv4(e):-1!==e.indexOf(":")?t.bytesFromIPv6(e):null},t.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var r=t.createBuffer(),n=0;n<e.length;++n){var i=parseInt(e[n],10);if(isNaN(i))return null;r.putByte(i)}return r.getBytes()},t.bytesFromIPv6=function(e){for(var r=0,n=2*(8-(e=e.split(":").filter((function(e){return 0===e.length&&++r,!0}))).length+r),i=t.createBuffer(),a=0;a<8;++a)if(e[a]&&0!==e[a].length){var o=t.hexToBytes(e[a]);o.length<2&&i.putByte(0),i.putBytes(o)}else i.fillWithByte(0,n),n=0;return i.getBytes()},t.bytesToIP=function(e){return 4===e.length?t.bytesToIPv4(e):16===e.length?t.bytesToIPv6(e):null},t.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")},t.bytesToIPv6=function(e){if(16!==e.length)return null;for(var r=[],n=[],i=0,a=0;a<e.length;a+=2){for(var o=t.bytesToHex(e[a]+e[a+1]);"0"===o[0]&&"0"!==o;)o=o.substr(1);if("0"===o){var s=n[n.length-1],c=r.length;s&&c===s.end+1?(s.end=c,s.end-s.start>n[i].end-n[i].start&&(i=n.length-1)):n.push({start:c,end:c})}r.push(o)}if(n.length>0){var u=n[i];u.end-u.start>0&&(r.splice(u.start,u.end-u.start+1,""),0===u.start&&r.unshift(""),7===u.end&&r.push(""))}return r.join(":")},t.estimateCores=function(e,r){if("function"==typeof e&&(r=e,e={}),e=e||{},"cores"in t&&!e.update)return r(null,t.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return t.cores=navigator.hardwareConcurrency,r(null,t.cores);if("undefined"==typeof Worker)return t.cores=1,r(null,t.cores);if("undefined"==typeof Blob)return t.cores=2,r(null,t.cores);var n=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){var t=Date.now(),r=t+4;self.postMessage({st:t,et:r})}))}.toString(),")()"],{type:"application/javascript"}));!function e(i,a,o){if(0===a){var s=Math.floor(i.reduce((function(e,t){return e+t}),0)/i.length);return t.cores=Math.max(1,s),URL.revokeObjectURL(n),r(null,t.cores)}!function(e,t){for(var r=[],i=[],a=0;a<e;++a){var o=new Worker(n);o.addEventListener("message",(function(n){if(i.push(n.data),i.length===e){for(var a=0;a<e;++a)r[a].terminate();t(null,i)}})),r.push(o)}for(a=0;a<e;++a)r[a].postMessage(a)}(o,(function(t,r){i.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var i=t[n],a=r[n]=[],o=0;o<e;++o)if(n!==o){var s=t[o];(i.st>s.st&&i.st<s.et||s.st>i.st&&s.st<i.et)&&a.push(o)}return r.reduce((function(e,t){return Math.max(e,t.length)}),0)}(o,r)),e(i,a-1,o)}))}([],5,16)}})),F.cipher=F.cipher||{},F.cipher.algorithms=F.cipher.algorithms||{},F.cipher.createCipher=function(e,t){var r=e;if("string"==typeof r&&(r=F.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new F.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},F.cipher.createDecipher=function(e,t){var r=e;if("string"==typeof r&&(r=F.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new F.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},F.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),F.cipher.algorithms[e]=t},F.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in F.cipher.algorithms?F.cipher.algorithms[e]:null};var H=F.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};function G(e,t){F.cipher.registerAlgorithm(e,(function(){return new F.aes.Algorithm(e,t)}))}H.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=F.util.createBuffer(),this.output=e.output||F.util.createBuffer(),this.mode.start(t)},H.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},H.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t)||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))},E((function(e){F.cipher=F.cipher||{};var t=e.exports=F.cipher.modes=F.cipher.modes||{};function r(e,t){if("string"==typeof e&&(e=F.util.createBuffer(e)),F.util.isArray(e)&&e.length>4){var r=e;e=F.util.createBuffer();for(var n=0;n<r.length;++n)e.putByte(r[n])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!F.util.isArray(e)){var i=[],a=t/4;for(n=0;n<a;++n)i.push(e.getInt32());e=i}return e}function n(e){e[e.length-1]=e[e.length-1]+1&4294967295}function i(e){return[e/4294967296|0,4294967295&e]}t.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},t.ecb.prototype.start=function(e){},t.ecb.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},t.ecb.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},t.ecb.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},t.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2||(e.truncate(n),0))},t.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},t.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},t.cbc.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^e.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]);this._prev=this._outBlock},t.cbc.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)},t.cbc.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},t.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2||(e.truncate(n),0))},t.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=F.util.createBuffer(),this._partialBytes=0},t.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32()^this._outBlock[i],t.putInt32(this._inBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;for(a>0&&(a=this.blockSize-a),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32(),t.putInt32(this._inBlock[i]^this._outBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;for(a>0&&(a=this.blockSize-a),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=F.util.createBuffer(),this._partialBytes=0},t.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];else{var a=(this.blockSize-n)%this.blockSize;for(a>0&&(a=this.blockSize-a),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.ofb.prototype.decrypt=t.ofb.prototype.encrypt,t.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=F.util.createBuffer(),this._partialBytes=0},t.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.ctr.prototype.encrypt=function(e,t,r){var i=e.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var a=0;a<this._ints;++a)t.putInt32(e.getInt32()^this._outBlock[a]);else{var o=(this.blockSize-i)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(o>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}n(this._inBlock)},t.ctr.prototype.decrypt=t.ctr.prototype.encrypt,t.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=F.util.createBuffer(),this._partialBytes=0,this._R=3774873600},t.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=F.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?F.util.createBuffer(e.additionalData):F.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=F.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var a=r.length();if(12===a)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(i(8*a)))}this._inBlock=this._j0.slice(0),n(this._inBlock),this._partialBytes=0,t=F.util.createBuffer(t),this._aDataLength=i(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},t.gcm.prototype.encrypt=function(e,t,r){var i=e.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize){for(var a=0;a<this._ints;++a)t.putInt32(this._outBlock[a]^=e.getInt32());this._cipherLength+=this.blockSize}else{var o=(this.blockSize-i)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(o<=0||r){if(r){var s=i%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(a=0;a<this._ints;++a)this._outBlock[a]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),n(this._inBlock)},t.gcm.prototype.decrypt=function(e,t,r){var i=e.length();if(i<this.blockSize&&!(r&&i>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),n(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var a=0;a<this._ints;++a)t.putInt32(this._outBlock[a]^this._hashBlock[a]);i<this.blockSize?this._cipherLength+=i%this.blockSize:this._cipherLength+=this.blockSize},t.gcm.prototype.afterFinish=function(e,t){var r=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=F.util.createBuffer();var n=this._aDataLength.concat(i(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,n);var a=[];this.cipher.encrypt(this._j0,a);for(var o=0;o<this._ints;++o)this.tag.putInt32(this._s[o]^a[o]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r},t.gcm.prototype.multiply=function(e,t){for(var r=[0,0,0,0],n=t.slice(0),i=0;i<128;++i)e[i/32|0]&1<<31-i%32&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n);return r},t.gcm.prototype.pow=function(e,t){for(var r=1&e[3],n=3;n>0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},t.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},t.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},t.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,a=new Array(i),o=0;o<i;++o){var s=[0,0,0,0],c=(n-1-o%n)*t;s[o/n|0]=1<<t-1<<c,a[o]=this.generateSubHashTable(this.multiply(s,e),t)}return a},t.gcm.prototype.generateSubHashTable=function(e,t){var r=1<<t,n=r>>>1,i=new Array(r);i[n]=e.slice(0);for(var a=n>>>1;a>0;)this.pow(i[2*a],i[a]=[]),a>>=1;for(a=2;a<n;){for(var o=1;o<a;++o){var s=i[a],c=i[o];i[a+o]=[s[0]^c[0],s[1]^c[1],s[2]^c[2],s[3]^c[3]]}a*=2}for(i[0]=[0,0,0,0],a=n+1;a<r;++a){var u=i[a^n];i[a]=[e[0]^u[0],e[1]^u[1],e[2]^u[2],e[3]^u[3]]}return i}})),F.aes=F.aes||{},F.aes.startEncrypting=function(e,t,r,n){var i=ne({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},F.aes.createEncryptionCipher=function(e,t){return ne({key:e,output:null,decrypt:!1,mode:t})},F.aes.startDecrypting=function(e,t,r,n){var i=ne({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},F.aes.createDecryptionCipher=function(e,t){return ne({key:e,output:null,decrypt:!0,mode:t})},F.aes.Algorithm=function(e,t){Z||ee();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return re(r._w,e,t,!1)},decrypt:function(e,t){return re(r._w,e,t,!0)}}}),r._init=!1},F.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(F.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=F.util.createBuffer();for(var n=0;n<t.length;++n)r.putByte(t[n])}}else r=F.util.createBuffer(r);if(!F.util.isArray(r)){t=r,r=[];var i=t.length();if(16===i||24===i||32===i)for(i>>>=2,n=0;n<i;++n)r.push(t.getInt32())}if(!F.util.isArray(r)||4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key parameter.");var a=this.mode.name,o=-1!==["CFB","OFB","CTR","GCM"].indexOf(a);this._w=te(r,e.decrypt&&!o),this._init=!0}},F.aes._expandKey=function(e,t){return Z||ee(),te(e,t)},F.aes._updateBlock=re,G("AES-ECB",F.cipher.modes.ecb),G("AES-CBC",F.cipher.modes.cbc),G("AES-CFB",F.cipher.modes.cfb),G("AES-OFB",F.cipher.modes.ofb),G("AES-CTR",F.cipher.modes.ctr),G("AES-GCM",F.cipher.modes.gcm);var Q,W,X,Y,$,Z=!1,J=4;function ee(){Z=!0,X=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;for(Q=new Array(256),W=new Array(256),Y=new Array(4),$=new Array(4),t=0;t<4;++t)Y[t]=new Array(256),$[t]=new Array(256);var r,n,i,a,o,s,c,u=0,l=0;for(t=0;t<256;++t){a=(a=l^l<<1^l<<2^l<<3^l<<4)>>8^255&a^99,Q[u]=a,W[a]=u,s=(o=e[a])<<24^a<<16^a<<8^a^o,c=((r=e[u])^(n=e[r])^(i=e[n]))<<24^(u^i)<<16^(u^n^i)<<8^u^r^i;for(var d=0;d<4;++d)Y[d][u]=s,$[d][a]=c,s=s<<24|s>>>8,c=c<<24|c>>>8;0===u?u=l=1:(u=r^e[e[e[r^i]]],l^=e[e[l]])}}function te(e,t){for(var r,n=e.slice(0),i=1,a=n.length,o=J*(a+6+1),s=a;s<o;++s)r=n[s-1],s%a==0?(r=Q[r>>>16&255]<<24^Q[r>>>8&255]<<16^Q[255&r]<<8^Q[r>>>24]^X[i]<<24,i++):a>6&&s%a==4&&(r=Q[r>>>24]<<24^Q[r>>>16&255]<<16^Q[r>>>8&255]<<8^Q[255&r]),n[s]=n[s-a]^r;if(t){for(var c,u=$[0],l=$[1],d=$[2],f=$[3],p=n.slice(0),h=(s=0,(o=n.length)-J);s<o;s+=J,h-=J)if(0===s||s===o-J)p[s]=n[h],p[s+1]=n[h+3],p[s+2]=n[h+2],p[s+3]=n[h+1];else for(var g=0;g<J;++g)c=n[h+g],p[s+(3&-g)]=u[Q[c>>>24]]^l[Q[c>>>16&255]]^d[Q[c>>>8&255]]^f[Q[255&c]];n=p}return n}function re(e,t,r,n){var i,a,o,s,c,u,l,d,f,p,h,g,m=e.length/4-1;n?(i=$[0],a=$[1],o=$[2],s=$[3],c=W):(i=Y[0],a=Y[1],o=Y[2],s=Y[3],c=Q),u=t[0]^e[0],l=t[n?3:1]^e[1],d=t[2]^e[2],f=t[n?1:3]^e[3];for(var y=3,v=1;v<m;++v)p=i[u>>>24]^a[l>>>16&255]^o[d>>>8&255]^s[255&f]^e[++y],h=i[l>>>24]^a[d>>>16&255]^o[f>>>8&255]^s[255&u]^e[++y],g=i[d>>>24]^a[f>>>16&255]^o[u>>>8&255]^s[255&l]^e[++y],f=i[f>>>24]^a[u>>>16&255]^o[l>>>8&255]^s[255&d]^e[++y],u=p,l=h,d=g;r[0]=c[u>>>24]<<24^c[l>>>16&255]<<16^c[d>>>8&255]<<8^c[255&f]^e[++y],r[n?3:1]=c[l>>>24]<<24^c[d>>>16&255]<<16^c[f>>>8&255]<<8^c[255&u]^e[++y],r[2]=c[d>>>24]<<24^c[f>>>16&255]<<16^c[u>>>8&255]<<8^c[255&l]^e[++y],r[n?1:3]=c[f>>>24]<<24^c[u>>>16&255]<<16^c[l>>>8&255]<<8^c[255&d]^e[++y]}function ne(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?F.cipher.createDecipher(r,e.key):F.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var i=null;r instanceof F.util.ByteBuffer&&(i=r,r={}),(r=r||{}).output=i,r.iv=e,n.call(t,r)},t}function ie(e,t){F.cipher.registerAlgorithm(e,(function(){return new F.des.Algorithm(e,t)}))}E((function(e){F.pki=F.pki||{};var t=e.exports=F.pki.oids=F.oids=F.oids||{};function r(e,r){t[e]=r,t[r]=e}function n(e,r){t[e]=r}r("1.2.840.113549.1.1.1","rsaEncryption"),r("1.2.840.113549.1.1.4","md5WithRSAEncryption"),r("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),r("1.2.840.113549.1.1.7","RSAES-OAEP"),r("1.2.840.113549.1.1.8","mgf1"),r("1.2.840.113549.1.1.9","pSpecified"),r("1.2.840.113549.1.1.10","RSASSA-PSS"),r("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),r("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),r("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),r("1.3.101.112","EdDSA25519"),r("1.2.840.10040.4.3","dsa-with-sha1"),r("1.3.14.3.2.7","desCBC"),r("1.3.14.3.2.26","sha1"),r("2.16.840.1.101.3.4.2.1","sha256"),r("2.16.840.1.101.3.4.2.2","sha384"),r("2.16.840.1.101.3.4.2.3","sha512"),r("1.2.840.113549.2.5","md5"),r("1.2.840.113549.1.7.1","data"),r("1.2.840.113549.1.7.2","signedData"),r("1.2.840.113549.1.7.3","envelopedData"),r("1.2.840.113549.1.7.4","signedAndEnvelopedData"),r("1.2.840.113549.1.7.5","digestedData"),r("1.2.840.113549.1.7.6","encryptedData"),r("1.2.840.113549.1.9.1","emailAddress"),r("1.2.840.113549.1.9.2","unstructuredName"),r("1.2.840.113549.1.9.3","contentType"),r("1.2.840.113549.1.9.4","messageDigest"),r("1.2.840.113549.1.9.5","signingTime"),r("1.2.840.113549.1.9.6","counterSignature"),r("1.2.840.113549.1.9.7","challengePassword"),r("1.2.840.113549.1.9.8","unstructuredAddress"),r("1.2.840.113549.1.9.14","extensionRequest"),r("1.2.840.113549.1.9.20","friendlyName"),r("1.2.840.113549.1.9.21","localKeyId"),r("1.2.840.113549.1.9.22.1","x509Certificate"),r("1.2.840.113549.1.12.10.1.1","keyBag"),r("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),r("1.2.840.113549.1.12.10.1.3","certBag"),r("1.2.840.113549.1.12.10.1.4","crlBag"),r("1.2.840.113549.1.12.10.1.5","secretBag"),r("1.2.840.113549.1.12.10.1.6","safeContentsBag"),r("1.2.840.113549.1.5.13","pkcs5PBES2"),r("1.2.840.113549.1.5.12","pkcs5PBKDF2"),r("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),r("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),r("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),r("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),r("1.2.840.113549.2.7","hmacWithSHA1"),r("1.2.840.113549.2.8","hmacWithSHA224"),r("1.2.840.113549.2.9","hmacWithSHA256"),r("1.2.840.113549.2.10","hmacWithSHA384"),r("1.2.840.113549.2.11","hmacWithSHA512"),r("1.2.840.113549.3.7","des-EDE3-CBC"),r("2.16.840.1.101.3.4.1.2","aes128-CBC"),r("2.16.840.1.101.3.4.1.22","aes192-CBC"),r("2.16.840.1.101.3.4.1.42","aes256-CBC"),r("2.5.4.3","commonName"),r("2.5.4.5","serialName"),r("2.5.4.6","countryName"),r("2.5.4.7","localityName"),r("2.5.4.8","stateOrProvinceName"),r("2.5.4.9","streetAddress"),r("2.5.4.10","organizationName"),r("2.5.4.11","organizationalUnitName"),r("2.5.4.13","description"),r("2.5.4.15","businessCategory"),r("2.5.4.17","postalCode"),r("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),r("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),r("2.16.840.1.113730.1.1","nsCertType"),r("2.16.840.1.113730.1.13","nsComment"),n("2.5.29.1","authorityKeyIdentifier"),n("2.5.29.2","keyAttributes"),n("2.5.29.3","certificatePolicies"),n("2.5.29.4","keyUsageRestriction"),n("2.5.29.5","policyMapping"),n("2.5.29.6","subtreesConstraint"),n("2.5.29.7","subjectAltName"),n("2.5.29.8","issuerAltName"),n("2.5.29.9","subjectDirectoryAttributes"),n("2.5.29.10","basicConstraints"),n("2.5.29.11","nameConstraints"),n("2.5.29.12","policyConstraints"),n("2.5.29.13","basicConstraints"),r("2.5.29.14","subjectKeyIdentifier"),r("2.5.29.15","keyUsage"),n("2.5.29.16","privateKeyUsagePeriod"),r("2.5.29.17","subjectAltName"),r("2.5.29.18","issuerAltName"),r("2.5.29.19","basicConstraints"),n("2.5.29.20","cRLNumber"),n("2.5.29.21","cRLReason"),n("2.5.29.22","expirationDate"),n("2.5.29.23","instructionCode"),n("2.5.29.24","invalidityDate"),n("2.5.29.25","cRLDistributionPoints"),n("2.5.29.26","issuingDistributionPoint"),n("2.5.29.27","deltaCRLIndicator"),n("2.5.29.28","issuingDistributionPoint"),n("2.5.29.29","certificateIssuer"),n("2.5.29.30","nameConstraints"),r("2.5.29.31","cRLDistributionPoints"),r("2.5.29.32","certificatePolicies"),n("2.5.29.33","policyMappings"),n("2.5.29.34","policyConstraints"),r("2.5.29.35","authorityKeyIdentifier"),n("2.5.29.36","policyConstraints"),r("2.5.29.37","extKeyUsage"),n("2.5.29.46","freshestCRL"),n("2.5.29.54","inhibitAnyPolicy"),r("1.3.6.1.4.1.11129.2.4.2","timestampList"),r("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),r("1.3.6.1.5.5.7.3.1","serverAuth"),r("1.3.6.1.5.5.7.3.2","clientAuth"),r("1.3.6.1.5.5.7.3.3","codeSigning"),r("1.3.6.1.5.5.7.3.4","emailProtection"),r("1.3.6.1.5.5.7.3.8","timeStamping")})),E((function(e){var t=e.exports=F.asn1=F.asn1||{};function r(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}t.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},t.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},t.create=function(e,r,n,i,a){if(F.util.isArray(i)){for(var o=[],s=0;s<i.length;++s)void 0!==i[s]&&o.push(i[s]);i=o}var c={tagClass:e,type:r,constructed:n,composed:n||F.util.isArray(i),value:i};return a&&"bitStringContents"in a&&(c.bitStringContents=a.bitStringContents,c.original=t.copy(c)),c},t.copy=function(e,r){var n;if(F.util.isArray(e)){n=[];for(var i=0;i<e.length;++i)n.push(t.copy(e[i],r));return n}return"string"==typeof e?e:(n={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:t.copy(e.value,r)},r&&!r.excludeBitStringContents&&(n.bitStringContents=e.bitStringContents),n)},t.equals=function(e,r,n){if(F.util.isArray(e)){if(!F.util.isArray(r))return!1;if(e.length!==r.length)return!1;for(var i=0;i<e.length;++i)if(!t.equals(e[i],r[i]))return!1;return!0}if(typeof e!=typeof r)return!1;if("string"==typeof e)return e===r;var a=e.tagClass===r.tagClass&&e.type===r.type&&e.constructed===r.constructed&&e.composed===r.composed&&t.equals(e.value,r.value);return n&&n.includeBitStringContents&&(a=a&&e.bitStringContents===r.bitStringContents),a},t.getBerValueLength=function(e){var t=e.getByte();if(128!==t)return 128&t?e.getInt((127&t)<<3):t};var n=function(e,t){var n=e.getByte();if(t--,128!==n){var i;if(128&n){var a=127&n;r(e,t,a),i=e.getInt(a<<3)}else i=n;if(i<0)throw new Error("Negative length: "+i);return i}};t.fromDer=function(e,i){return void 0===i&&(i={strict:!0,decodeBitStrings:!0}),"boolean"==typeof i&&(i={strict:i,decodeBitStrings:!0}),"strict"in i||(i.strict=!0),"decodeBitStrings"in i||(i.decodeBitStrings=!0),"string"==typeof e&&(e=F.util.createBuffer(e)),function e(i,a,o,s){var c;r(i,a,2);var u=i.getByte();a--;var l=192&u,d=31&u;c=i.length();var f,p,h=n(i,a);if(a-=c-i.length(),void 0!==h&&h>a){if(s.strict){var g=new Error("Too few bytes to read ASN.1 value.");throw g.available=i.length(),g.remaining=a,g.requested=h,g}h=a}var m=32==(32&u);if(m)if(f=[],void 0===h)for(;;){if(r(i,a,2),i.bytes(2)===String.fromCharCode(0,0)){i.getBytes(2),a-=2;break}c=i.length(),f.push(e(i,a,o+1,s)),a-=c-i.length()}else for(;h>0;)c=i.length(),f.push(e(i,h,o+1,s)),a-=c-i.length(),h-=c-i.length();if(void 0===f&&l===t.Class.UNIVERSAL&&d===t.Type.BITSTRING&&(p=i.bytes(h)),void 0===f&&s.decodeBitStrings&&l===t.Class.UNIVERSAL&&d===t.Type.BITSTRING&&h>1){var y=i.read,v=a,b=0;if(d===t.Type.BITSTRING&&(r(i,a,1),b=i.getByte(),a--),0===b)try{c=i.length();var C=e(i,a,o+1,{verbose:s.verbose,strict:!0,decodeBitStrings:!0}),E=c-i.length();a-=E,d==t.Type.BITSTRING&&E++;var w=C.tagClass;E!==h||w!==t.Class.UNIVERSAL&&w!==t.Class.CONTEXT_SPECIFIC||(f=[C])}catch(e){}void 0===f&&(i.read=y,a=v)}if(void 0===f){if(void 0===h){if(s.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");h=a}if(d===t.Type.BMPSTRING)for(f="";h>0;h-=2)r(i,a,2),f+=String.fromCharCode(i.getInt16()),a-=2;else f=i.getBytes(h)}var k=void 0===p?null:{bitStringContents:p};return t.create(l,d,m,f,k)}(e,e.length(),0,i)},t.toDer=function(e){var r=F.util.createBuffer(),n=e.tagClass|e.type,i=F.util.createBuffer(),a=!1;if("bitStringContents"in e&&(a=!0,e.original&&(a=t.equals(e,e.original))),a)i.putBytes(e.bitStringContents);else if(e.composed){e.constructed?n|=32:i.putByte(0);for(var o=0;o<e.value.length;++o)void 0!==e.value[o]&&i.putBuffer(t.toDer(e.value[o]))}else if(e.type===t.Type.BMPSTRING)for(o=0;o<e.value.length;++o)i.putInt16(e.value.charCodeAt(o));else e.type===t.Type.INTEGER&&e.value.length>1&&(0===e.value.charCodeAt(0)&&0==(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128==(128&e.value.charCodeAt(1)))?i.putBytes(e.value.substr(1)):i.putBytes(e.value);if(r.putByte(n),i.length()<=127)r.putByte(127&i.length());else{var s=i.length(),c="";do{c+=String.fromCharCode(255&s),s>>>=8}while(s>0);for(r.putByte(128|c.length),o=c.length-1;o>=0;--o)r.putByte(c.charCodeAt(o))}return r.putBuffer(i),r},t.oidToDer=function(e){var t,r,n,i,a=e.split("."),o=F.util.createBuffer();o.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var s=2;s<a.length;++s){t=!0,r=[],n=parseInt(a[s],10);do{i=127&n,n>>>=7,t||(i|=128),r.push(i),t=!1}while(n>0);for(var c=r.length-1;c>=0;--c)o.putByte(r[c])}return o},t.derToOid=function(e){var t;"string"==typeof e&&(e=F.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var n=0;e.length()>0;)n<<=7,128&(r=e.getByte())?n+=127&r:(t+="."+(n+r),n=0);return t},t.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),a=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),s=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(s=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(a,o,s,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},t.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),o=parseInt(e.substr(10,2),10),s=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var d=e.length-5,f=e.charAt(d);return"+"!==f&&"-"!==f||(u=60*parseInt(e.substr(d+1,2),10)+parseInt(e.substr(d+4,2),10),u*=6e4,"+"===f&&(u*=-1),l=!0),"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(a,o,s,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(a,o,s,c)),t},t.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+"Z"},t.dateToGeneralizedTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push(""+e.getUTCFullYear()),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+"Z"},t.integerToDer=function(e){var t=F.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},t.derToInteger=function(e){"string"==typeof e&&(e=F.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},t.validate=function(e,r,n,i){var a=!1;if(e.tagClass!==r.tagClass&&void 0!==r.tagClass||e.type!==r.type&&void 0!==r.type)i&&(e.tagClass!==r.tagClass&&i.push("["+r.name+'] Expected tag class "'+r.tagClass+'", got "'+e.tagClass+'"'),e.type!==r.type&&i.push("["+r.name+'] Expected type "'+r.type+'", got "'+e.type+'"'));else if(e.constructed===r.constructed||void 0===r.constructed){if(a=!0,r.value&&F.util.isArray(r.value))for(var o=0,s=0;a&&s<r.value.length;++s)a=r.value[s].optional||!1,e.value[o]&&((a=t.validate(e.value[o],r.value[s],n,i))?++o:r.value[s].optional&&(a=!0)),!a&&i&&i.push("["+r.name+'] Tag class "'+r.tagClass+'", type "'+r.type+'" expected value length "'+r.value.length+'", got "'+e.value.length+'"');if(a&&n&&(r.capture&&(n[r.capture]=e.value),r.captureAsn1&&(n[r.captureAsn1]=e),r.captureBitStringContents&&"bitStringContents"in e&&(n[r.captureBitStringContents]=e.bitStringContents),r.captureBitStringValue&&"bitStringContents"in e))if(e.bitStringContents.length<2)n[r.captureBitStringValue]="";else{if(0!==e.bitStringContents.charCodeAt(0))throw new Error("captureBitStringValue only supported for zero unused bits");n[r.captureBitStringValue]=e.bitStringContents.slice(1)}}else i&&i.push("["+r.name+'] Expected constructed "'+r.constructed+'", got "'+e.constructed+'"');return a};var i=/[^\\u0000-\\u00ff]/;t.prettyPrint=function(e,r,n){var a="";n=n||2,(r=r||0)>0&&(a+="\n");for(var o="",s=0;s<r*n;++s)o+=" ";switch(a+=o+"Tag: ",e.tagClass){case t.Class.UNIVERSAL:a+="Universal:";break;case t.Class.APPLICATION:a+="Application:";break;case t.Class.CONTEXT_SPECIFIC:a+="Context-Specific:";break;case t.Class.PRIVATE:a+="Private:"}if(e.tagClass===t.Class.UNIVERSAL)switch(a+=e.type,e.type){case t.Type.NONE:a+=" (None)";break;case t.Type.BOOLEAN:a+=" (Boolean)";break;case t.Type.INTEGER:a+=" (Integer)";break;case t.Type.BITSTRING:a+=" (Bit string)";break;case t.Type.OCTETSTRING:a+=" (Octet string)";break;case t.Type.NULL:a+=" (Null)";break;case t.Type.OID:a+=" (Object Identifier)";break;case t.Type.ODESC:a+=" (Object Descriptor)";break;case t.Type.EXTERNAL:a+=" (External or Instance of)";break;case t.Type.REAL:a+=" (Real)";break;case t.Type.ENUMERATED:a+=" (Enumerated)";break;case t.Type.EMBEDDED:a+=" (Embedded PDV)";break;case t.Type.UTF8:a+=" (UTF8)";break;case t.Type.ROID:a+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:a+=" (Sequence)";break;case t.Type.SET:a+=" (Set)";break;case t.Type.PRINTABLESTRING:a+=" (Printable String)";break;case t.Type.IA5String:a+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:a+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:a+=" (Generalized time)";break;case t.Type.BMPSTRING:a+=" (BMP String)"}else a+=e.type;if(a+="\n",a+=o+"Constructed: "+e.constructed+"\n",e.composed){var c=0,u="";for(s=0;s<e.value.length;++s)void 0!==e.value[s]&&(c+=1,u+=t.prettyPrint(e.value[s],r+1,n),s+1<e.value.length&&(u+=","));a+=o+"Sub values: "+c+u}else{if(a+=o+"Value: ",e.type===t.Type.OID){var l=t.derToOid(e.value);a+=l,F.pki&&F.pki.oids&&l in F.pki.oids&&(a+=" ("+F.pki.oids[l]+") ")}if(e.type===t.Type.INTEGER)try{a+=t.derToInteger(e.value)}catch(t){a+="0x"+F.util.bytesToHex(e.value)}else if(e.type===t.Type.BITSTRING){if(e.value.length>1?a+="0x"+F.util.bytesToHex(e.value.slice(1)):a+="(none)",e.value.length>0){var d=e.value.charCodeAt(0);1==d?a+=" (1 unused bit shown)":d>1&&(a+=" ("+d+" unused bits shown)")}}else e.type===t.Type.OCTETSTRING?(i.test(e.value)||(a+="("+e.value+") "),a+="0x"+F.util.bytesToHex(e.value)):e.type===t.Type.UTF8?a+=F.util.decodeUtf8(e.value):e.type===t.Type.PRINTABLESTRING||e.type===t.Type.IA5String?a+=e.value:i.test(e.value)?a+="0x"+F.util.bytesToHex(e.value):0===e.value.length?a+="[null]":a+=e.value}return a}})),F.md=F.md||{},F.md.algorithms=F.md.algorithms||{},E((function(e){(e.exports=F.hmac=F.hmac||{}).create=function(){var e=null,t=null,r=null,n=null,i={start:function(i,a){if(null!==i)if("string"==typeof i){if(!((i=i.toLowerCase())in F.md.algorithms))throw new Error('Unknown hash algorithm "'+i+'"');t=F.md.algorithms[i].create()}else t=i;if(null===a)a=e;else{if("string"==typeof a)a=F.util.createBuffer(a);else if(F.util.isArray(a)){var o=a;a=F.util.createBuffer();for(var s=0;s<o.length;++s)a.putByte(o[s])}var c=a.length();for(c>t.blockLength&&(t.start(),t.update(a.bytes()),a=t.digest()),r=F.util.createBuffer(),n=F.util.createBuffer(),c=a.length(),s=0;s<c;++s)o=a.at(s),r.putByte(54^o),n.putByte(92^o);if(c<t.blockLength)for(o=t.blockLength-c,s=0;s<o;++s)r.putByte(54),n.putByte(92);e=a,r=r.bytes(),n=n.bytes()}t.start(),t.update(r)},update:function(e){t.update(e)},getMac:function(){var e=t.digest().bytes();return t.start(),t.update(n),t.update(e),t.digest()}};return i.digest=i.getMac,i}})),E((function(e){var t=e.exports=F.md5=F.md5||{};F.md.md5=F.md.algorithms.md5=t,t.create=function(){o||function(){r=String.fromCharCode(128),r+=F.util.fillString(String.fromCharCode(0),64),n=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],i=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],a=new Array(64);for(var e=0;e<64;++e)a[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));o=!0}();var e=null,t=F.util.createBuffer(),c=new Array(16),u={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){u.messageLength=0,u.fullMessageLength=u.messageLength64=[];for(var r=u.messageLengthSize/4,n=0;n<r;++n)u.fullMessageLength.push(0);return t=F.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},u}};return u.start(),u.update=function(r,n){"utf8"===n&&(r=F.util.encodeUtf8(r));var i=r.length;u.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var a=u.fullMessageLength.length-1;a>=0;--a)u.fullMessageLength[a]+=i[1],i[1]=i[0]+(u.fullMessageLength[a]/4294967296>>>0),u.fullMessageLength[a]=u.fullMessageLength[a]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(r),s(e,c,t),(t.read>2048||0===t.length())&&t.compact(),u},u.digest=function(){var n=F.util.createBuffer();n.putBytes(t.bytes());var i=u.fullMessageLength[u.fullMessageLength.length-1]+u.messageLengthSize&u.blockLength-1;n.putBytes(r.substr(0,u.blockLength-i));for(var a,o=0,l=u.fullMessageLength.length-1;l>=0;--l)o=(a=8*u.fullMessageLength[l]+o)/4294967296>>>0,n.putInt32Le(a>>>0);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};s(d,c,n);var f=F.util.createBuffer();return f.putInt32Le(d.h0),f.putInt32Le(d.h1),f.putInt32Le(d.h2),f.putInt32Le(d.h3),f},u};var r=null,n=null,i=null,a=null,o=!1;function s(e,t,r){for(var o,s,c,u,l,d,f,p=r.length();p>=64;){for(s=e.h0,c=e.h1,u=e.h2,l=e.h3,f=0;f<16;++f)t[f]=r.getInt32Le(),o=s+(l^c&(u^l))+a[f]+t[f],s=l,l=u,u=c,c+=o<<(d=i[f])|o>>>32-d;for(;f<32;++f)o=s+(u^l&(c^u))+a[f]+t[n[f]],s=l,l=u,u=c,c+=o<<(d=i[f])|o>>>32-d;for(;f<48;++f)o=s+(c^u^l)+a[f]+t[n[f]],s=l,l=u,u=c,c+=o<<(d=i[f])|o>>>32-d;for(;f<64;++f)o=s+(u^(c|~l))+a[f]+t[n[f]],s=l,l=u,u=c,c+=o<<(d=i[f])|o>>>32-d;e.h0=e.h0+s|0,e.h1=e.h1+c|0,e.h2=e.h2+u|0,e.h3=e.h3+l|0,p-=64}}})),E((function(e){var t=e.exports=F.pem=F.pem||{};function r(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i<e.values.length;++i)r.push(e.values[i].replace(/^(\S+\r\n)/,n));t+=r.join(",")+"\r\n";var a=0,o=-1;for(i=0;i<t.length;++i,++a)if(a>65&&-1!==o){var s=t[o];","===s?(++o,t=t.substr(0,o)+"\r\n "+t.substr(o)):t=t.substr(0,o)+"\r\n"+s+t.substr(o+1),a=i-o-1,o=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(o=i);return t}function n(e){return e.replace(/^\s+/,"")}t.encode=function(e,t){t=t||{};var n,i="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(i+=r(n={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=r(n={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(n={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&n.values.push(e.dekInfo.parameters),i+=r(n)),e.headers)for(var a=0;a<e.headers.length;++a)i+=r(e.headers[a]);return e.procType&&(i+="\r\n"),(i+=F.util.encode64(e.body,t.maxline||64)+"\r\n")+"-----END "+e.type+"-----\r\n"},t.decode=function(e){for(var t,r=[],i=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,a=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,o=/\r?\n/;t=i.exec(e);){var s={type:t[1],procType:null,contentDomain:null,dekInfo:null,headers:[],body:F.util.decode64(t[3])};if(r.push(s),t[2]){for(var c=t[2].split(o),u=0;t&&u<c.length;){for(var l=c[u].replace(/\s+$/,""),d=u+1;d<c.length;++d){var f=c[d];if(!/\s/.test(f[0]))break;l+=f,u=d}if(t=l.match(a)){for(var p={name:t[1],values:[]},h=t[2].split(","),g=0;g<h.length;++g)p.values.push(n(h[g]));if(s.procType)if(s.contentDomain||"Content-Domain"!==p.name)if(s.dekInfo||"DEK-Info"!==p.name)s.headers.push(p);else{if(0===p.values.length)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');s.dekInfo={algorithm:h[0],parameters:h[1]||null}}else s.contentDomain=h[0]||"";else{if("Proc-Type"!==p.name)throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==p.values.length)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');s.procType={version:h[0],type:h[1]}}}++u}if("ENCRYPTED"===s.procType&&!s.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(0===r.length)throw new Error("Invalid PEM formatted message.");return r}})),F.des=F.des||{},F.des.startEncrypting=function(e,t,r,n){var i=he({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},F.des.createEncryptionCipher=function(e,t){return he({key:e,output:null,decrypt:!1,mode:t})},F.des.startDecrypting=function(e,t,r,n){var i=he({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},F.des.createDecryptionCipher=function(e,t){return he({key:e,output:null,decrypt:!0,mode:t})},F.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return pe(r._keys,e,t,!1)},decrypt:function(e,t){return pe(r._keys,e,t,!0)}}}),r._init=!1},F.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=F.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],a=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],o=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],s=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],d=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],p=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],h=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],m=e.length()>8?3:1,y=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,C=0;C<m;C++){var E=e.getInt32(),w=e.getInt32();E^=(t=252645135&(E>>>4^w))<<4,E^=t=65535&((w^=t)>>>-16^E),E^=(t=858993459&(E>>>2^(w^=t<<-16)))<<2,E^=t=65535&((w^=t)>>>-16^E),E^=(t=1431655765&(E>>>1^(w^=t<<-16)))<<1,E^=t=16711935&((w^=t)>>>8^E),t=(E^=(t=1431655765&(E>>>1^(w^=t<<8)))<<1)<<8|(w^=t)>>>20&240,E=w<<24|w<<8&16711680|w>>>8&65280|w>>>24&240,w=t;for(var k=0;k<v.length;++k){v[k]?(E=E<<2|E>>>26,w=w<<2|w>>>26):(E=E<<1|E>>>27,w=w<<1|w>>>27);var S=r[(E&=-15)>>>28]|n[E>>>24&15]|i[E>>>20&15]|a[E>>>16&15]|o[E>>>12&15]|s[E>>>8&15]|c[E>>>4&15],B=u[(w&=-15)>>>28]|l[w>>>24&15]|d[w>>>20&15]|f[w>>>16&15]|p[w>>>12&15]|h[w>>>8&15]|g[w>>>4&15];t=65535&(B>>>16^S),y[b++]=S^t,y[b++]=B^t<<16}}return y}(t),this._init=!0}},ie("DES-ECB",F.cipher.modes.ecb),ie("DES-CBC",F.cipher.modes.cbc),ie("DES-CFB",F.cipher.modes.cfb),ie("DES-OFB",F.cipher.modes.ofb),ie("DES-CTR",F.cipher.modes.ctr),ie("3DES-ECB",F.cipher.modes.ecb),ie("3DES-CBC",F.cipher.modes.cbc),ie("3DES-CFB",F.cipher.modes.cfb),ie("3DES-OFB",F.cipher.modes.ofb),ie("3DES-CTR",F.cipher.modes.ctr);var ae=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],oe=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],se=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],ce=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],ue=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],le=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],de=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],fe=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function pe(e,t,r,n){var i,a,o=32===e.length?3:9;i=3===o?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var s=t[0],c=t[1];s^=(a=252645135&(s>>>4^c))<<4,s^=(a=65535&(s>>>16^(c^=a)))<<16,s^=a=858993459&((c^=a)>>>2^s),s^=a=16711935&((c^=a<<2)>>>8^s),s=(s^=(a=1431655765&(s>>>1^(c^=a<<8)))<<1)<<1|s>>>31,c=(c^=a)<<1|c>>>31;for(var u=0;u<o;u+=3){for(var l=i[u+1],d=i[u+2],f=i[u];f!=l;f+=d){var p=c^e[f],h=(c>>>4|c<<28)^e[f+1];a=s,s=c,c=a^(oe[p>>>24&63]|ce[p>>>16&63]|le[p>>>8&63]|fe[63&p]|ae[h>>>24&63]|se[h>>>16&63]|ue[h>>>8&63]|de[63&h])}a=s,s=c,c=a}c=c>>>1|c<<31,c^=a=1431655765&((s=s>>>1|s<<31)>>>1^c),c^=(a=16711935&(c>>>8^(s^=a<<1)))<<8,c^=(a=858993459&(c>>>2^(s^=a)))<<2,c^=a=65535&((s^=a)>>>16^c),c^=a=252645135&((s^=a<<16)>>>4^c),s^=a<<4,r[0]=s,r[1]=c}function he(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?F.cipher.createDecipher(r,e.key):F.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var i=null;r instanceof F.util.ByteBuffer&&(i=r,r={}),(r=r||{}).output=i,r.iv=e,n.call(t,r)},t}var ge,me=F.pkcs5=F.pkcs5||{};F.util.isNodejs&&!F.options.usePureJavaScript&&(ge=t),F.pbkdf2=me.pbkdf2=function(e,t,r,n,i,a){if("function"==typeof i&&(a=i,i=null),F.util.isNodejs&&!F.options.usePureJavaScript&&ge.pbkdf2&&(null===i||"object"!=typeof i)&&(ge.pbkdf2Sync.length>4||!i||"sha1"===i))return"string"!=typeof i&&(i="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),a?4===ge.pbkdf2Sync.length?ge.pbkdf2(e,t,r,n,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):ge.pbkdf2(e,t,r,n,i,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):4===ge.pbkdf2Sync.length?ge.pbkdf2Sync(e,t,r,n).toString("binary"):ge.pbkdf2Sync(e,t,r,n,i).toString("binary");if(null==i&&(i="sha1"),"string"==typeof i){if(!(i in F.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=F.md[i].create()}var o=i.digestLength;if(n>4294967295*o){var s=new Error("Derived key is too long.");if(a)return a(s);throw s}var c=Math.ceil(n/o),u=n-(c-1)*o,l=F.hmac.create();l.start(i,e);var d,f,p,h="";if(!a){for(var g=1;g<=c;++g){l.start(null,null),l.update(t),l.update(F.util.int32ToBytes(g)),d=p=l.digest().getBytes();for(var m=2;m<=r;++m)l.start(null,null),l.update(p),f=l.digest().getBytes(),d=F.util.xorBytes(d,f,o),p=f;h+=g<c?d:d.substr(0,u)}return h}function y(){if(g>c)return a(null,h);l.start(null,null),l.update(t),l.update(F.util.int32ToBytes(g)),d=p=l.digest().getBytes(),m=2,v()}function v(){if(m<=r)return l.start(null,null),l.update(p),f=l.digest().getBytes(),d=F.util.xorBytes(d,f,o),p=f,++m,F.util.setImmediate(v);h+=g<c?d:d.substr(0,u),++g,y()}g=1,y()},E((function(e){var t=e.exports=F.sha256=F.sha256||{};F.md.sha256=F.md.algorithms.sha256=t,t.create=function(){n||(r=String.fromCharCode(128),r+=F.util.fillString(String.fromCharCode(0),64),i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=!0);var e=null,t=F.util.createBuffer(),o=new Array(64),s={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){s.messageLength=0,s.fullMessageLength=s.messageLength64=[];for(var r=s.messageLengthSize/4,n=0;n<r;++n)s.fullMessageLength.push(0);return t=F.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},s}};return s.start(),s.update=function(r,n){"utf8"===n&&(r=F.util.encodeUtf8(r));var i=r.length;s.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var c=s.fullMessageLength.length-1;c>=0;--c)s.fullMessageLength[c]+=i[1],i[1]=i[0]+(s.fullMessageLength[c]/4294967296>>>0),s.fullMessageLength[c]=s.fullMessageLength[c]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(r),a(e,o,t),(t.read>2048||0===t.length())&&t.compact(),s},s.digest=function(){var n=F.util.createBuffer();n.putBytes(t.bytes());var i,c=s.fullMessageLength[s.fullMessageLength.length-1]+s.messageLengthSize&s.blockLength-1;n.putBytes(r.substr(0,s.blockLength-c));for(var u=8*s.fullMessageLength[0],l=0;l<s.fullMessageLength.length-1;++l)u+=(i=8*s.fullMessageLength[l+1])/4294967296>>>0,n.putInt32(u>>>0),u=i>>>0;n.putInt32(u);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};a(d,o,n);var f=F.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f.putInt32(d.h5),f.putInt32(d.h6),f.putInt32(d.h7),f},s};var r=null,n=!1,i=null;function a(e,t,r){for(var n,a,o,s,c,u,l,d,f,p,h,g,m,y=r.length();y>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,a=((a=t[c-15])>>>7|a<<25)^(a>>>18|a<<14)^a>>>3,t[c]=n+t[c-7]+a+t[c-16]|0;for(u=e.h0,l=e.h1,d=e.h2,f=e.h3,p=e.h4,h=e.h5,g=e.h6,m=e.h7,c=0;c<64;++c)o=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&l|d&(u^l),n=m+((p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(g^p&(h^g))+i[c]+t[c],m=g,g=h,h=p,p=f+n>>>0,f=d,d=l,l=u,u=n+(a=o+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+d|0,e.h3=e.h3+f|0,e.h4=e.h4+p|0,e.h5=e.h5+h|0,e.h6=e.h6+g|0,e.h7=e.h7+m|0,y-=64}}})),E((function(e){var r=null;!F.util.isNodejs||F.options.usePureJavaScript||process.versions["node-webkit"]||(r=t),(e.exports=F.prng=F.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},n=e.md,i=new Array(32),a=0;a<32;++a)i[a]=n.create();function o(){if(t.pools[0].messageLength>=32)return s();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),s()}function s(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r==0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function c(e){var t=null,r=F.util.globalScope,n=r.crypto||r.msCrypto;n&&n.getRandomValues&&(t=function(e){return n.getRandomValues(e)});var i=F.util.createBuffer();if(t)for(;i.length()<e;){var a=Math.max(1,Math.min(e-i.length(),65536)/4),o=new Uint32Array(Math.floor(a));try{t(o);for(var s=0;s<o.length;++s)i.putInt32(o[s])}catch(e){if(!("undefined"!=typeof QuotaExceededError&&e instanceof QuotaExceededError))throw e}}if(i.length()<e)for(var c,u,l,d=Math.floor(65536*Math.random());i.length()<e;)for(u=16807*(65535&d),u+=(32767&(c=16807*(d>>16)))<<16,d=4294967295&(u=(2147483647&(u+=c>>15))+(u>>31)),s=0;s<3;++s)l=d>>>(s<<3),l^=Math.floor(256*Math.random()),i.putByte(String.fromCharCode(255&l));return i.getBytes(e)}return t.pools=i,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var n=t.plugin.cipher,i=t.plugin.increment,a=t.plugin.formatKey,o=t.plugin.formatSeed,c=F.util.createBuffer();t.key=null,function u(l){if(l)return r(l);if(c.length()>=e)return r(null,c.getBytes(e));if(t.generated>1048575&&(t.key=null),null===t.key)return F.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return s(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),s(),e()}))}(u)}));var d=n(t.key,t.seed);t.generated+=d.length,c.putBytes(d),t.key=a(n(t.key,i(t.seed))),t.seed=o(n(t.key,t.seed)),F.util.setImmediate(u)}()},t.generateSync=function(e){var r=t.plugin.cipher,n=t.plugin.increment,i=t.plugin.formatKey,a=t.plugin.formatSeed;t.key=null;for(var s=F.util.createBuffer();s.length()<e;){t.generated>1048575&&(t.key=null),null===t.key&&o();var c=r(t.key,t.seed);t.generated+=c.length,s.putBytes(c),t.key=i(r(t.key,n(t.seed))),t.seed=a(r(t.key,t.seed))}return s.getBytes(e)},r?(t.seedFile=function(e,t){r.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return r.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,c(e))}catch(e){t(e)}},t.seedFileSync=c),t.collect=function(e){for(var r=e.length,n=0;n<r;++n)t.pools[t.pool].update(e.substr(n,1)),t.pool=31===t.pool?0:t.pool+1},t.collectInt=function(e,r){for(var n="",i=0;i<r;i+=8)n+=String.fromCharCode(e>>i&255);t.collect(n)},t.registerWorker=function(e){e===self?t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})}:e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))},t}})),E((function(e){F.random&&F.random.getBytes?e.exports=F.random:function(t){var r={},n=new Array(4),i=F.util.createBuffer();function a(){var e=F.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=F.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),F.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=F.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return F.aes._updateBlock(e,t,n,!1),i.putInt32(n[0]),i.putInt32(n[1]),i.putInt32(n[2]),i.putInt32(n[3]),i.getBytes()},r.increment=function(e){return++e[3],e},r.md=F.md.sha256;var o=a(),s=null,c=F.util.globalScope,u=c.crypto||c.msCrypto;if(u&&u.getRandomValues&&(s=function(e){return u.getRandomValues(e)}),!F.util.isNodejs&&!s){if(o.collectInt(+new Date,32),"undefined"!=typeof navigator){var l="";for(var d in navigator)try{"string"==typeof navigator[d]&&(l+=navigator[d])}catch(e){}o.collect(l),l=null}t&&(t().mousemove((function(e){o.collectInt(e.clientX,16),o.collectInt(e.clientY,16)})),t().keypress((function(e){o.collectInt(e.charCode,8)})))}if(F.random)for(var d in o)F.random[d]=o[d];else F.random=o;F.random.createInstance=a,e.exports=F.random}("undefined"!=typeof jQuery?jQuery:null)}));var ye=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],ve=[1,2,3,5],be=function(e,t){return e<<t&65535|(65535&e)>>16-t},Ce=function(e,t){return(65535&e)>>t|e<<16-t&65535};F.rc2=F.rc2||{},F.rc2.expandKey=function(e,t){"string"==typeof e&&(e=F.util.createBuffer(e)),t=t||128;var r,n=e,i=e.length(),a=t,o=Math.ceil(a/8),s=255>>(7&a);for(r=i;r<128;r++)n.putByte(ye[n.at(r-1)+n.at(r-i)&255]);for(n.setAt(128-o,ye[n.at(128-o)&s]),r=127-o;r>=0;r--)n.setAt(r,ye[n.at(r+1)^n.at(r+o)]);return n};var Ee,we=function(e,t,r){var n,i,a,o,s=!1,c=null,u=null,l=null,d=[];for(e=F.rc2.expandKey(e,t),a=0;a<64;a++)d.push(e.getInt16Le());r?(n=function(e){for(a=0;a<4;a++)e[a]+=d[o]+(e[(a+3)%4]&e[(a+2)%4])+(~e[(a+3)%4]&e[(a+1)%4]),e[a]=be(e[a],ve[a]),o++},i=function(e){for(a=0;a<4;a++)e[a]+=d[63&e[(a+3)%4]]}):(n=function(e){for(a=3;a>=0;a--)e[a]=Ce(e[a],ve[a]),e[a]-=d[o]+(e[(a+3)%4]&e[(a+2)%4])+(~e[(a+3)%4]&e[(a+1)%4]),o--},i=function(e){for(a=3;a>=0;a--)e[a]-=d[63&e[(a+3)%4]]});var f=function(e){var t=[];for(a=0;a<4;a++){var n=c.getInt16Le();null!==l&&(r?n^=l.getInt16Le():l.putInt16Le(n)),t.push(65535&n)}o=r?0:63;for(var i=0;i<e.length;i++)for(var s=0;s<e[i][0];s++)e[i][1](t);for(a=0;a<4;a++)null!==l&&(r?l.putInt16Le(t[a]):t[a]^=l.getInt16Le()),u.putInt16Le(t[a])},p=null;return p={start:function(e,t){e&&"string"==typeof e&&(e=F.util.createBuffer(e)),s=!1,c=F.util.createBuffer(),u=t||new F.util.createBuffer,l=e,p.output=u},update:function(e){for(s||c.putBuffer(e);c.length()>=8;)f([[5,n],[1,i],[6,n],[1,i],[5,n]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,c,!r);else{var n=8===c.length()?8:8-c.length();c.fillWithByte(n,n)}if(t&&(s=!0,p.update()),!r&&(t=0===c.length()))if(e)t=e(8,u,!r);else{var i=u.length(),a=u.at(i-1);a>i?t=!1:u.truncate(a)}return t}}};function ke(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function Se(){return new ke(null)}function Be(e,t,r,n,i,a){for(var o=16383&t,s=t>>14;--a>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=s*c+u*o;i=((c=o*c+((16383&l)<<14)+r.data[n]+i)>>28)+(l>>14)+s*u,r.data[n++]=268435455&c}return i}F.rc2.startEncrypting=function(e,t,r){var n=F.rc2.createEncryptionCipher(e,128);return n.start(t,r),n},F.rc2.createEncryptionCipher=function(e,t){return we(e,t,!0)},F.rc2.startDecrypting=function(e,t,r){var n=F.rc2.createDecryptionCipher(e,128);return n.start(t,r),n},F.rc2.createDecryptionCipher=function(e,t){return we(e,t,!1)},F.jsbn=F.jsbn||{},F.jsbn.BigInteger=ke,"undefined"==typeof navigator?(ke.prototype.am=Be,Ee=28):"Microsoft Internet Explorer"==navigator.appName?(ke.prototype.am=function(e,t,r,n,i,a){for(var o=32767&t,s=t>>15;--a>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=s*c+u*o;i=((c=o*c+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+s*u+(i>>>30),r.data[n++]=1073741823&c}return i},Ee=30):"Netscape"!=navigator.appName?(ke.prototype.am=function(e,t,r,n,i,a){for(;--a>=0;){var o=t*this.data[e++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=67108863&o}return i},Ee=26):(ke.prototype.am=Be,Ee=28),ke.prototype.DB=Ee,ke.prototype.DM=(1<<Ee)-1,ke.prototype.DV=1<<Ee,ke.prototype.FV=Math.pow(2,52),ke.prototype.F1=52-Ee,ke.prototype.F2=2*Ee-52;var Te,Ae,Ie="0123456789abcdefghijklmnopqrstuvwxyz",_e=new Array;for(Te="0".charCodeAt(0),Ae=0;Ae<=9;++Ae)_e[Te++]=Ae;for(Te="a".charCodeAt(0),Ae=10;Ae<36;++Ae)_e[Te++]=Ae;for(Te="A".charCodeAt(0),Ae=10;Ae<36;++Ae)_e[Te++]=Ae;function xe(e){return Ie.charAt(e)}function Pe(e,t){var r=_e[e.charCodeAt(t)];return null==r?-1:r}function Re(e){var t=Se();return t.fromInt(e),t}function Ne(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function Oe(e){this.m=e}function Le(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function De(e,t){return e&t}function Ue(e,t){return e|t}function Me(e,t){return e^t}function Ve(e,t){return e&~t}function je(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function Fe(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function ze(){}function Ke(e){return e}function qe(e){this.r2=Se(),this.q3=Se(),ke.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}Oe.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},Oe.prototype.revert=function(e){return e},Oe.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},Oe.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},Oe.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},Le.prototype.convert=function(e){var t=Se();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(ke.ZERO)>0&&this.m.subTo(t,t),t},Le.prototype.revert=function(e){var t=Se();return e.copyTo(t),this.reduce(t),t},Le.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e.data[t],n=r*this.mpl+((r*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},Le.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},Le.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},ke.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},ke.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},ke.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,a=0;--n>=0;){var o=8==r?255&e[n]:Pe(e,n);o<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==a?this.data[this.t++]=o:a+r>this.DB?(this.data[this.t-1]|=(o&(1<<this.DB-a)-1)<<a,this.data[this.t++]=o>>this.DB-a):this.data[this.t-1]|=o<<a,(a+=r)>=this.DB&&(a-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,a>0&&(this.data[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),i&&ke.ZERO.subTo(this,this)},ke.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t},ke.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},ke.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t.data[r-e]=this.data[r];t.t=Math.max(this.t-e,0),t.s=this.s},ke.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,a=(1<<i)-1,o=Math.floor(e/this.DB),s=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+o+1]=this.data[r]>>i|s,s=(this.data[r]&a)<<n;for(r=o-1;r>=0;--r)t.data[r]=0;t.data[o]=s,t.t=this.t+o+1,t.s=this.s,t.clamp()},ke.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,a=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var o=r+1;o<this.t;++o)t.data[o-r-1]|=(this.data[o]&a)<<i,t.data[o-r]=this.data[o]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&a)<<i),t.t=this.t-r,t.clamp()}},ke.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]-e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},ke.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i<n.t;++i)t.data[i+r.t]=r.am(0,n.data[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&ke.ZERO.subTo(t,t)},ke.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e.data[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t.data[r],e,2*r,0,1);(e.data[r+t.t]+=t.am(r+1,2*t.data[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},ke.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Se());var a=Se(),o=this.s,s=e.s,c=this.DB-Ne(n.data[n.t-1]);c>0?(n.lShiftTo(c,a),i.lShiftTo(c,r)):(n.copyTo(a),i.copyTo(r));var u=a.t,l=a.data[u-1];if(0!=l){var d=l*(1<<this.F1)+(u>1?a.data[u-2]>>this.F2:0),f=this.FV/d,p=(1<<this.F1)/d,h=1<<this.F2,g=r.t,m=g-u,y=null==t?Se():t;for(a.dlShiftTo(m,y),r.compareTo(y)>=0&&(r.data[r.t++]=1,r.subTo(y,r)),ke.ONE.dlShiftTo(u,y),y.subTo(a,a);a.t<u;)a.data[a.t++]=0;for(;--m>=0;){var v=r.data[--g]==l?this.DM:Math.floor(r.data[g]*f+(r.data[g-1]+h)*p);if((r.data[g]+=a.am(0,v,r,m,0,u))<v)for(a.dlShiftTo(m,y),r.subTo(y,r);r.data[g]<--v;)r.subTo(y,r)}null!=t&&(r.drShiftTo(u,t),o!=s&&ke.ZERO.subTo(t,t)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),o<0&&ke.ZERO.subTo(r,r)}}},ke.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},ke.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},ke.prototype.exp=function(e,t){if(e>4294967295||e<1)return ke.ONE;var r=Se(),n=Se(),i=t.convert(this),a=Ne(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<<a)>0)t.mulTo(n,i,r);else{var o=r;r=n,n=o}return t.revert(r)},ke.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,a="",o=this.t,s=this.DB-o*this.DB%t;if(o-- >0)for(s<this.DB&&(r=this.data[o]>>s)>0&&(i=!0,a=xe(r));o>=0;)s<t?(r=(this.data[o]&(1<<s)-1)<<t-s,r|=this.data[--o]>>(s+=this.DB-t)):(r=this.data[o]>>(s-=t)&n,s<=0&&(s+=this.DB,--o)),r>0&&(i=!0),i&&(a+=xe(r));return i?a:"0"},ke.prototype.negate=function(){var e=Se();return ke.ZERO.subTo(this,e),e},ke.prototype.abs=function(){return this.s<0?this.negate():this},ke.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},ke.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+Ne(this.data[this.t-1]^this.s&this.DM)},ke.prototype.mod=function(e){var t=Se();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ke.ZERO)>0&&e.subTo(t,t),t},ke.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new Oe(t):new Le(t),this.exp(e,r)},ke.ZERO=Re(0),ke.ONE=Re(1),ze.prototype.convert=Ke,ze.prototype.revert=Ke,ze.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},ze.prototype.sqrTo=function(e,t){e.squareTo(t)},qe.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=Se();return e.copyTo(t),this.reduce(t),t},qe.prototype.revert=function(e){return e},qe.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},qe.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},qe.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var He=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],Ge=(1<<26)/He[He.length-1];if(ke.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},ke.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=Re(r),i=Se(),a=Se(),o="";for(this.divRemTo(n,i,a);i.signum()>0;)o=(r+a.intValue()).toString(e).substr(1)+o,i.divRemTo(n,i,a);return a.intValue().toString(e)+o},ke.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,a=0,o=0,s=0;s<e.length;++s){var c=Pe(e,s);c<0?"-"==e.charAt(s)&&0==this.signum()&&(i=!0):(o=t*o+c,++a>=r&&(this.dMultiply(n),this.dAddOffset(o,0),a=0,o=0))}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(o,0)),i&&ke.ZERO.subTo(this,this)},ke.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(ke.ONE.shiftLeft(e-1),Ue,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(ke.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}},ke.prototype.bitwiseTo=function(e,t,r){var n,i,a=Math.min(e.t,this.t);for(n=0;n<a;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(i=e.s&this.DM,n=a;n<this.t;++n)r.data[n]=t(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=a;n<e.t;++n)r.data[n]=t(i,e.data[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},ke.prototype.changeBit=function(e,t){var r=ke.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r},ke.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]+e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},ke.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},ke.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},ke.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i<n;++i)r.data[i+this.t]=this.am(0,e.data[i],r,i,0,this.t);for(n=Math.min(e.t,t);i<n;++i)this.am(0,e.data[i],r,i,0,t-i);r.clamp()},ke.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r.data[this.t+n-t]=this.am(t-n,e.data[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},ke.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},ke.prototype.millerRabin=function(e){var t=this.subtract(ke.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),a={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},o=0;o<e;++o){do{n=new ke(this.bitLength(),a)}while(n.compareTo(ke.ONE)<=0||n.compareTo(t)>=0);var s=n.modPow(i,this);if(0!=s.compareTo(ke.ONE)&&0!=s.compareTo(t)){for(var c=1;c++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(ke.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0},ke.prototype.clone=function(){var e=Se();return this.copyTo(e),e},ke.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]},ke.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24},ke.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},ke.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},ke.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this.data[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this.data[e]&(1<<n)-1)<<8-n,r|=this.data[--e]>>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},ke.prototype.equals=function(e){return 0==this.compareTo(e)},ke.prototype.min=function(e){return this.compareTo(e)<0?this:e},ke.prototype.max=function(e){return this.compareTo(e)>0?this:e},ke.prototype.and=function(e){var t=Se();return this.bitwiseTo(e,De,t),t},ke.prototype.or=function(e){var t=Se();return this.bitwiseTo(e,Ue,t),t},ke.prototype.xor=function(e){var t=Se();return this.bitwiseTo(e,Me,t),t},ke.prototype.andNot=function(e){var t=Se();return this.bitwiseTo(e,Ve,t),t},ke.prototype.not=function(){for(var e=Se(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e},ke.prototype.shiftLeft=function(e){var t=Se();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},ke.prototype.shiftRight=function(e){var t=Se();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},ke.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this.data[e])return e*this.DB+je(this.data[e]);return this.s<0?this.t*this.DB:-1},ke.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=Fe(this.data[r]^t);return e},ke.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:0!=(this.data[t]&1<<e%this.DB)},ke.prototype.setBit=function(e){return this.changeBit(e,Ue)},ke.prototype.clearBit=function(e){return this.changeBit(e,Ve)},ke.prototype.flipBit=function(e){return this.changeBit(e,Me)},ke.prototype.add=function(e){var t=Se();return this.addTo(e,t),t},ke.prototype.subtract=function(e){var t=Se();return this.subTo(e,t),t},ke.prototype.multiply=function(e){var t=Se();return this.multiplyTo(e,t),t},ke.prototype.divide=function(e){var t=Se();return this.divRemTo(e,t,null),t},ke.prototype.remainder=function(e){var t=Se();return this.divRemTo(e,null,t),t},ke.prototype.divideAndRemainder=function(e){var t=Se(),r=Se();return this.divRemTo(e,t,r),new Array(t,r)},ke.prototype.modPow=function(e,t){var r,n,i=e.bitLength(),a=Re(1);if(i<=0)return a;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new Oe(t):t.isEven()?new qe(t):new Le(t);var o=new Array,s=3,c=r-1,u=(1<<r)-1;if(o[1]=n.convert(this),r>1){var l=Se();for(n.sqrTo(o[1],l);s<=u;)o[s]=Se(),n.mulTo(l,o[s-2],o[s]),s+=2}var d,f,p=e.t-1,h=!0,g=Se();for(i=Ne(e.data[p])-1;p>=0;){for(i>=c?d=e.data[p]>>i-c&u:(d=(e.data[p]&(1<<i+1)-1)<<c-i,p>0&&(d|=e.data[p-1]>>this.DB+i-c)),s=r;0==(1&d);)d>>=1,--s;if((i-=s)<0&&(i+=this.DB,--p),h)o[d].copyTo(a),h=!1;else{for(;s>1;)n.sqrTo(a,g),n.sqrTo(g,a),s-=2;s>0?n.sqrTo(a,g):(f=a,a=g,g=f),n.mulTo(g,o[d],a)}for(;p>=0&&0==(e.data[p]&1<<i);)n.sqrTo(a,g),f=a,a=g,g=f,--i<0&&(i=this.DB-1,--p)}return n.revert(a)},ke.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return ke.ZERO;for(var r=e.clone(),n=this.clone(),i=Re(1),a=Re(0),o=Re(0),s=Re(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&a.isEven()||(i.addTo(this,i),a.subTo(e,a)),i.rShiftTo(1,i)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(e,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(o,i),a.subTo(s,a)):(n.subTo(r,n),t&&o.subTo(i,o),s.subTo(a,s))}return 0!=n.compareTo(ke.ONE)?ke.ZERO:s.compareTo(e)>=0?s.subtract(e):s.signum()<0?(s.addTo(e,s),s.signum()<0?s.add(e):s):s},ke.prototype.pow=function(e){return this.exp(e,new ze)},ke.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),a=r.getLowestSetBit();if(a<0)return t;for(i<a&&(a=i),a>0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r},ke.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=He[He.length-1]){for(t=0;t<He.length;++t)if(r.data[0]==He[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<He.length;){for(var n=He[t],i=t+1;i<He.length&&n<Ge;)n*=He[i++];for(n=r.modInt(n);t<i;)if(n%He[t++]==0)return!1}return r.millerRabin(e)},E((function(e){var t=e.exports=F.sha1=F.sha1||{};F.md.sha1=F.md.algorithms.sha1=t,t.create=function(){n||(r=String.fromCharCode(128),r+=F.util.fillString(String.fromCharCode(0),64),n=!0);var e=null,t=F.util.createBuffer(),a=new Array(80),o={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){o.messageLength=0,o.fullMessageLength=o.messageLength64=[];for(var r=o.messageLengthSize/4,n=0;n<r;++n)o.fullMessageLength.push(0);return t=F.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},o}};return o.start(),o.update=function(r,n){"utf8"===n&&(r=F.util.encodeUtf8(r));var s=r.length;o.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var c=o.fullMessageLength.length-1;c>=0;--c)o.fullMessageLength[c]+=s[1],s[1]=s[0]+(o.fullMessageLength[c]/4294967296>>>0),o.fullMessageLength[c]=o.fullMessageLength[c]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(r),i(e,a,t),(t.read>2048||0===t.length())&&t.compact(),o},o.digest=function(){var n=F.util.createBuffer();n.putBytes(t.bytes());var s,c=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;n.putBytes(r.substr(0,o.blockLength-c));for(var u=8*o.fullMessageLength[0],l=0;l<o.fullMessageLength.length-1;++l)u+=(s=8*o.fullMessageLength[l+1])/4294967296>>>0,n.putInt32(u>>>0),u=s>>>0;n.putInt32(u);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};i(d,a,n);var f=F.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f},o};var r=null,n=!1;function i(e,t,r){for(var n,i,a,o,s,c,u,l=r.length();l>=64;){for(i=e.h0,a=e.h1,o=e.h2,s=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(i<<5|i>>>27)+(s^a&(o^s))+c+1518500249+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(s^a&(o^s))+c+1518500249+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(a^o^s)+c+1859775393+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(a^o^s)+c+1859775393+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(a&o|s&(a^o))+c+2400959708+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(a^o^s)+c+3395469782+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+a|0,e.h2=e.h2+o|0,e.h3=e.h3+s|0,e.h4=e.h4+c|0,l-=64}}})),E((function(e){var t=e.exports=F.pkcs1=F.pkcs1||{};function r(e,t,r){r||(r=F.md.sha1.create());for(var n="",i=Math.ceil(t/r.digestLength),a=0;a<i;++a){var o=String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a);r.start(),r.update(e+o),n+=r.digest().getBytes()}return n.substring(0,t)}t.encode_rsa_oaep=function(e,t,n){var i,a,o,s;"string"==typeof n?(i=n,a=arguments[3]||void 0,o=arguments[4]||void 0):n&&(i=n.label||void 0,a=n.seed||void 0,o=n.md||void 0,n.mgf1&&n.mgf1.md&&(s=n.mgf1.md)),o?o.start():o=F.md.sha1.create(),s||(s=o);var c=Math.ceil(e.n.bitLength()/8),u=c-2*o.digestLength-2;if(t.length>u)throw(h=new Error("RSAES-OAEP input message length is too long.")).length=t.length,h.maxLength=u,h;i||(i=""),o.update(i,"raw");for(var l=o.digest(),d="",f=u-t.length,p=0;p<f;p++)d+="\0";var h,g=l.getBytes()+d+""+t;if(a){if(a.length!==o.digestLength)throw(h=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=a.length,h.digestLength=o.digestLength,h}else a=F.random.getBytes(o.digestLength);var m=r(a,c-o.digestLength-1,s),y=F.util.xorBytes(g,m,g.length),v=r(y,o.digestLength,s);return"\0"+F.util.xorBytes(a,v,a.length)+y},t.decode_rsa_oaep=function(e,t,n){var i,a,o;"string"==typeof n?(i=n,a=arguments[3]||void 0):n&&(i=n.label||void 0,a=n.md||void 0,n.mgf1&&n.mgf1.md&&(o=n.mgf1.md));var s=Math.ceil(e.n.bitLength()/8);if(t.length!==s)throw(m=new Error("RSAES-OAEP encoded message length is invalid.")).length=t.length,m.expectedLength=s,m;if(void 0===a?a=F.md.sha1.create():a.start(),o||(o=a),s<2*a.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");i||(i=""),a.update(i,"raw");for(var c=a.digest().getBytes(),u=t.charAt(0),l=t.substring(1,a.digestLength+1),d=t.substring(1+a.digestLength),f=r(d,a.digestLength,o),p=r(F.util.xorBytes(l,f,l.length),s-a.digestLength-1,o),h=F.util.xorBytes(d,p,d.length),g=h.substring(0,a.digestLength),m="\0"!==u,y=0;y<a.digestLength;++y)m|=c.charAt(y)!==g.charAt(y);for(var v=1,b=a.digestLength,C=a.digestLength;C<h.length;C++){var E=h.charCodeAt(C);m|=E&(v?65534:0),b+=v&=1&E^1}if(m||1!==h.charCodeAt(b))throw new Error("Invalid RSAES-OAEP padding.");return h.substring(b+1)}})),E((function(e){!function(){if(F.prime)e.exports=F.prime;else{var t=e.exports=F.prime=F.prime||{},r=F.jsbn.BigInteger,n=[6,4,2,4,2,4,6,2],i=new r(null);i.fromInt(30);var a=function(e,t){return e|t};t.generateProbablePrime=function(e,t,n){"function"==typeof t&&(n=t,t={});var i=(t=t||{}).algorithm||"PRIMEINC";"string"==typeof i&&(i={name:i}),i.options=i.options||{};var a=t.prng||F.random,c={nextBytes:function(e){for(var t=a.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}};if("PRIMEINC"===i.name)return function(e,t,n,i){return"workers"in n?function(e,t,n,i){if("undefined"==typeof Worker)return o(e,t,n,i);var a=s(e,t),c=n.workers,u=n.workLoad||100,l=30*u/8,d=n.workerScript||"forge/prime.worker.js";if(-1===c)return F.util.estimateCores((function(e,t){e&&(t=2),c=t-1,f()}));function f(){c=Math.max(1,c);for(var n=[],o=0;o<c;++o)n[o]=new Worker(d);for(o=0;o<c;++o)n[o].addEventListener("message",p);var f=!1;function p(o){if(!f){var c=o.data;if(c.found){for(var d=0;d<n.length;++d)n[d].terminate();return f=!0,i(null,new r(c.prime,16))}a.bitLength()>e&&(a=s(e,t));var p=a.toString(16);o.target.postMessage({hex:p,workLoad:u}),a.dAddOffset(l,0)}}}f()}(e,t,n,i):o(e,t,n,i)}(e,c,i.options,n);throw new Error("Invalid prime generation algorithm: "+i.name)}}function o(e,t,r,i){var a=s(e,t),o=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(a.bitLength());"millerRabinTests"in r&&(o=r.millerRabinTests);var c=10;"maxBlockTime"in r&&(c=r.maxBlockTime),function e(t,r,i,a,o,c,u){var l=+new Date;do{if(t.bitLength()>r&&(t=s(r,i)),t.isProbablePrime(o))return u(null,t);t.dAddOffset(n[a++%8],0)}while(c<0||+new Date-l<c);F.util.setImmediate((function(){e(t,r,i,a,o,c,u)}))}(a,e,t,0,o,c,i)}function s(e,t){var n=new r(e,t),o=e-1;return n.testBit(o)||n.bitwiseTo(r.ONE.shiftLeft(o),a,n),n.dAddOffset(31-n.mod(i).byteValue(),0),n}}()})),void 0===Qe)var Qe=F.jsbn.BigInteger;var We=F.util.isNodejs?t:null,Xe=F.asn1,Ye=F.util;F.pki=F.pki||{},F.pki.rsa=F.rsa=F.rsa||{};var $e=F.pki,Ze=[6,4,2,4,2,4,6,2],Je={name:"PrivateKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},et={name:"RSAPrivateKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},tt={name:"RSAPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},rt=F.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},nt=function(e){var t;if(!(e.algorithm in $e.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=$e.oids[e.algorithm];var n=Xe.oidToDer(t).getBytes(),i=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[]),a=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[]);a.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,n)),a.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,""));var o=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(a),i.value.push(o),Xe.toDer(i).getBytes()},it=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var n;t.dP||(t.dP=t.d.mod(t.p.subtract(Qe.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(Qe.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{n=new Qe(F.util.bytesToHex(F.random.getBytes(t.n.bitLength()/8)),16)}while(n.compareTo(t.n)>=0||!n.gcd(t.n).equals(Qe.ONE));for(var i=(e=e.multiply(n.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);i.compareTo(a)<0;)i=i.add(t.p);var o=i.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return o.multiply(n.modInverse(t.n)).mod(t.n)};function at(e,t,r){var n=F.util.createBuffer(),i=Math.ceil(t.n.bitLength()/8);if(e.length>i-11){var a=new Error("Message is too long for PKCS#1 v1.5 padding.");throw a.length=e.length,a.max=i-11,a}n.putByte(0),n.putByte(r);var o,s=i-3-e.length;if(0===r||1===r){o=0===r?0:255;for(var c=0;c<s;++c)n.putByte(o)}else for(;s>0;){var u=0,l=F.random.getBytes(s);for(c=0;c<s;++c)0===(o=l.charCodeAt(c))?++u:n.putByte(o);s=u}return n.putByte(0),n.putBytes(e),n}function ot(e,t,r,n){var i=Math.ceil(t.n.bitLength()/8),a=F.util.createBuffer(e),o=a.getByte(),s=a.getByte();if(0!==o||r&&0!==s&&1!==s||!r&&2!=s||r&&0===s&&void 0===n)throw new Error("Encryption block is invalid.");var c=0;if(0===s){c=i-3-n;for(var u=0;u<c;++u)if(0!==a.getByte())throw new Error("Encryption block is invalid.")}else if(1===s)for(c=0;a.length()>1;){if(255!==a.getByte()){--a.read;break}++c}else if(2===s)for(c=0;a.length()>1;){if(0===a.getByte()){--a.read;break}++c}if(0!==a.getByte()||c!==i-3-a.length())throw new Error("Encryption block is invalid.");return a.getBytes()}function st(e,t,r){"function"==typeof t&&(r=t,t={});var n={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function i(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?o(t,e.q):void a(e.qBits,o))}))}function a(e,t){F.prime.generateProbablePrime(e,n,t)}function o(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var s=e.p;e.p=e.q,e.q=s}if(0!==e.p.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE))return e.p=null,void i();if(0!==e.q.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE))return e.q=null,void a(e.qBits,o);if(e.p1=e.p.subtract(Qe.ONE),e.q1=e.q.subtract(Qe.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(Qe.ONE))return e.p=e.q=null,void i();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,o);var c=e.e.modInverse(e.phi);e.keys={privateKey:$e.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:$e.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(n.prng=t.prng),i()}function ct(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=F.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function ut(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function lt(e){return F.util.isNodejs&&"function"==typeof We[e]}function dt(e){return void 0!==Ye.globalScope&&"object"==typeof Ye.globalScope.crypto&&"object"==typeof Ye.globalScope.crypto.subtle&&"function"==typeof Ye.globalScope.crypto.subtle[e]}function ft(e){return void 0!==Ye.globalScope&&"object"==typeof Ye.globalScope.msCrypto&&"object"==typeof Ye.globalScope.msCrypto.subtle&&"function"==typeof Ye.globalScope.msCrypto.subtle[e]}function pt(e){for(var t=F.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n<t.length;++n)r[n]=t.charCodeAt(n);return r}if($e.rsa.encrypt=function(e,t,r){var n,i=r,a=Math.ceil(t.n.bitLength()/8);!1!==r&&!0!==r?(i=2===r,n=at(e,t,r)):(n=F.util.createBuffer()).putBytes(e);for(var o=new Qe(n.toHex(),16),s=it(o,t,i).toString(16),c=F.util.createBuffer(),u=a-Math.ceil(s.length/2);u>0;)c.putByte(0),--u;return c.putBytes(F.util.hexToBytes(s)),c.getBytes()},$e.rsa.decrypt=function(e,t,r,n){var i=Math.ceil(t.n.bitLength()/8);if(e.length!==i){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=i,a}var o=new Qe(F.util.createBuffer(e).toHex(),16);if(o.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var s=it(o,t,r).toString(16),c=F.util.createBuffer(),u=i-Math.ceil(s.length/2);u>0;)c.putByte(0),--u;return c.putBytes(F.util.hexToBytes(s)),!1!==n?ot(c.getBytes(),t,r):c.getBytes()},$e.rsa.createKeyPairGenerationState=function(e,t,r){"string"==typeof e&&(e=parseInt(e,10)),e=e||2048;var n,i=(r=r||{}).prng||F.random,a={nextBytes:function(e){for(var t=i.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},o=r.algorithm||"PRIMEINC";if("PRIMEINC"!==o)throw new Error("Invalid key generation algorithm: "+o);return(n={algorithm:o,state:0,bits:e,rng:a,eInt:t||65537,e:new Qe(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(n.eInt),n},$e.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new Qe(null);r.fromInt(30);for(var n,i=0,a=function(e,t){return e|t},o=+new Date,s=0;null===e.keys&&(t<=0||s<t);){if(0===e.state){var c=null===e.p?e.pBits:e.qBits,u=c-1;0===e.pqState?(e.num=new Qe(c,e.rng),e.num.testBit(u)||e.num.bitwiseTo(Qe.ONE.shiftLeft(u),a,e.num),e.num.dAddOffset(31-e.num.mod(r).byteValue(),0),i=0,++e.pqState):1===e.pqState?e.num.bitLength()>c?e.pqState=0:e.num.isProbablePrime(ut(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(Ze[i++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(Qe.ONE),e.q1=e.q.subtract(Qe.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(Qe.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var l=e.e.modInverse(e.phi);e.keys={privateKey:$e.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:$e.rsa.setPublicKey(e.n,e.e)}}s+=(n=+new Date)-o,o=n}return null!==e.keys},$e.rsa.generateKeyPair=function(e,t,r,n){if(1===arguments.length?"object"==typeof e?(r=e,e=void 0):"function"==typeof e&&(n=e,e=void 0):2===arguments.length?"number"==typeof e?"function"==typeof t?(n=t,t=void 0):"number"!=typeof t&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):3===arguments.length&&("number"==typeof t?"function"==typeof r&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(n){if(lt("generateKeyPair"))return We.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return n(e);n(null,{privateKey:$e.privateKeyFromPem(r),publicKey:$e.publicKeyFromPem(t)})}));if(dt("generateKey")&&dt("exportKey"))return Ye.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:pt(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return Ye.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){n(e)})).then((function(e){if(e){var t=$e.privateKeyFromAsn1(Xe.fromDer(F.util.createBuffer(e)));n(null,{privateKey:t,publicKey:$e.setRsaPublicKey(t.n,t.e)})}}));if(ft("generateKey")&&ft("exportKey")){var i=Ye.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:pt(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return i.oncomplete=function(e){var t=e.target.result,r=Ye.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=$e.privateKeyFromAsn1(Xe.fromDer(F.util.createBuffer(t)));n(null,{privateKey:r,publicKey:$e.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){n(e)}},void(i.onerror=function(e){n(e)})}}else if(lt("generateKeyPairSync")){var a=We.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:$e.privateKeyFromPem(a.privateKey),publicKey:$e.publicKeyFromPem(a.publicKey)}}var o=$e.rsa.createKeyPairGenerationState(e,t,r);if(!n)return $e.rsa.stepKeyPairGenerationState(o,0),o.keys;st(o,r,n)},$e.setRsaPublicKey=$e.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,n){if("string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return at(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return F.pkcs1.encode_rsa_oaep(t,e,n)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var i=t.encode(e,r,!0);return $e.rsa.encrypt(i,r,!0)},verify:function(e,t,n){"string"==typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(e,t){return t=ot(t,r,!0),e===Xe.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===ot(t,r,!0)}});var i=$e.rsa.decrypt(t,r,!0,!1);return n.verify(e,i,r.n.bitLength())}};return r},$e.setRsaPrivateKey=$e.rsa.setPrivateKey=function(e,t,r,n,i,a,o,s){var c={n:e,e:t,d:r,p:n,q:i,dP:a,dQ:o,qInv:s,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var n=$e.rsa.decrypt(e,c,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:ot};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return F.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(n,c,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:nt},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,c.n.bitLength());return $e.rsa.encrypt(n,c,r)}};return c},$e.wrapRsaPrivateKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,Xe.integerToDer(0).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,Xe.oidToDer($e.oids.rsaEncryption).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,"")]),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OCTETSTRING,!1,Xe.toDer(e).getBytes())])},$e.privateKeyFromAsn1=function(e){var t,r,n,i,a,o,s,c,u={},l=[];if(Xe.validate(e,Je,u,l)&&(e=Xe.fromDer(F.util.createBuffer(u.privateKey))),u={},l=[],!Xe.validate(e,et,u,l)){var d=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw d.errors=l,d}return t=F.util.createBuffer(u.privateKeyModulus).toHex(),r=F.util.createBuffer(u.privateKeyPublicExponent).toHex(),n=F.util.createBuffer(u.privateKeyPrivateExponent).toHex(),i=F.util.createBuffer(u.privateKeyPrime1).toHex(),a=F.util.createBuffer(u.privateKeyPrime2).toHex(),o=F.util.createBuffer(u.privateKeyExponent1).toHex(),s=F.util.createBuffer(u.privateKeyExponent2).toHex(),c=F.util.createBuffer(u.privateKeyCoefficient).toHex(),$e.setRsaPrivateKey(new Qe(t,16),new Qe(r,16),new Qe(n,16),new Qe(i,16),new Qe(a,16),new Qe(o,16),new Qe(s,16),new Qe(c,16))},$e.privateKeyToAsn1=$e.privateKeyToRSAPrivateKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,Xe.integerToDer(0).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.n)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.e)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.d)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.p)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.q)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.dP)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.dQ)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.qInv))])},$e.publicKeyFromAsn1=function(e){var t={},r=[];if(Xe.validate(e,rt,t,r)){var n,i=Xe.derToOid(t.publicKeyOid);if(i!==$e.oids.rsaEncryption)throw(n=new Error("Cannot read public key. Unknown OID.")).oid=i,n;e=t.rsaPublicKey}if(r=[],!Xe.validate(e,tt,t,r))throw(n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,n;var a=F.util.createBuffer(t.publicKeyModulus).toHex(),o=F.util.createBuffer(t.publicKeyExponent).toHex();return $e.setRsaPublicKey(new Qe(a,16),new Qe(o,16))},$e.publicKeyToAsn1=$e.publicKeyToSubjectPublicKeyInfo=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,Xe.oidToDer($e.oids.rsaEncryption).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,"")]),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.BITSTRING,!1,[$e.publicKeyToRSAPublicKey(e)])])},$e.publicKeyToRSAPublicKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.n)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.e))])},void 0===ht)var ht=F.jsbn.BigInteger;var gt=F.asn1,mt=F.pki=F.pki||{},yt=(mt.pbe=F.pbe=F.pbe||{},mt.oids),vt={name:"EncryptedPrivateKeyInfo",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},bt={name:"PBES2Algorithms",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},Ct={name:"pkcs-12PbeParams",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,capture:"iterations"}]};function Et(e,t){return e.start().update(t).digest().getBytes()}function wt(e){var t;if(e){if(!(t=mt.oids[gt.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return kt(t)}function kt(e){var t=F.md;switch(e){case"hmacWithSHA224":t=F.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}mt.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n,i,a,o=F.random.getBytesSync(r.saltSize),s=r.count,c=gt.integerToDer(s);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var u,l,d;switch(r.algorithm){case"aes128":n=16,u=16,l=yt["aes128-CBC"],d=F.aes.createEncryptionCipher;break;case"aes192":n=24,u=16,l=yt["aes192-CBC"],d=F.aes.createEncryptionCipher;break;case"aes256":n=32,u=16,l=yt["aes256-CBC"],d=F.aes.createEncryptionCipher;break;case"des":n=8,u=8,l=yt.desCBC,d=F.des.createEncryptionCipher;break;default:throw(y=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,y}var f="hmacWith"+r.prfAlgorithm.toUpperCase(),p=kt(f),h=F.pkcs5.pbkdf2(t,o,s,n,p),g=F.random.getBytesSync(u);(v=d(h)).start(g),v.update(gt.toDer(e)),v.finish(),a=v.output.getBytes();var m=function(e,t,r,n){var i=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,e),gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,t.getBytes())]);return"hmacWithSHA1"!==n&&i.value.push(gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,F.util.hexToBytes(r.toString(16))),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(mt.oids[n]).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.NULL,!1,"")])),i}(o,c,n,f);i=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt.pkcs5PBES2).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt.pkcs5PBKDF2).getBytes()),m]),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(l).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,g)])])])}else{var y;if("3des"!==r.algorithm)throw(y=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,y;n=24;var v,b=new F.util.ByteBuffer(o);h=mt.pbe.generatePkcs12Key(t,b,1,s,n),g=mt.pbe.generatePkcs12Key(t,b,2,s,n),(v=F.des.createEncryptionCipher(h)).start(g),v.update(gt.toDer(e)),v.finish(),a=v.output.getBytes(),i=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,o),gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,c.getBytes())])])}return gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[i,gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,a)])},mt.decryptPrivateKeyInfo=function(e,t){var r=null,n={},i=[];if(!gt.validate(e,vt,n,i)){var a=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=i,a}var o=gt.derToOid(n.encryptionOid),s=mt.pbe.getCipher(o,n.encryptionParams,t),c=F.util.createBuffer(n.encryptedData);return s.update(c),s.finish()&&(r=gt.fromDer(s.output)),r},mt.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:gt.toDer(e).getBytes()};return F.pem.encode(r,{maxline:t})},mt.encryptedPrivateKeyFromPem=function(e){var t=F.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return gt.fromDer(t.body)},mt.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var n=mt.wrapRsaPrivateKey(mt.privateKeyToAsn1(e));return n=mt.encryptPrivateKeyInfo(n,t,r),mt.encryptedPrivateKeyToPem(n)}var i,a,o,s;switch(r.algorithm){case"aes128":i="AES-128-CBC",o=16,a=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",o=24,a=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",o=32,a=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",o=24,a=F.random.getBytesSync(8),s=F.des.createEncryptionCipher;break;case"des":i="DES-CBC",o=8,a=F.random.getBytesSync(8),s=F.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw c.algorithm=r.algorithm,c}var u=s(F.pbe.opensslDeriveBytes(t,a.substr(0,8),o));u.start(a),u.update(gt.toDer(mt.privateKeyToAsn1(e))),u.finish();var l={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:F.util.bytesToHex(a).toUpperCase()},body:u.output.getBytes()};return F.pem.encode(l)},mt.decryptRsaPrivateKey=function(e,t){var r=null,n=F.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==n.type&&"PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type)throw(o=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=o,o;if(n.procType&&"ENCRYPTED"===n.procType.type){var i,a;switch(n.dekInfo.algorithm){case"DES-CBC":i=8,a=F.des.createDecryptionCipher;break;case"DES-EDE3-CBC":i=24,a=F.des.createDecryptionCipher;break;case"AES-128-CBC":i=16,a=F.aes.createDecryptionCipher;break;case"AES-192-CBC":i=24,a=F.aes.createDecryptionCipher;break;case"AES-256-CBC":i=32,a=F.aes.createDecryptionCipher;break;case"RC2-40-CBC":i=5,a=function(e){return F.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":i=8,a=function(e){return F.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":i=16,a=function(e){return F.rc2.createDecryptionCipher(e,128)};break;default:var o;throw(o=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".')).algorithm=n.dekInfo.algorithm,o}var s=F.util.hexToBytes(n.dekInfo.parameters),c=a(F.pbe.opensslDeriveBytes(t,s.substr(0,8),i));if(c.start(s),c.update(F.util.createBuffer(n.body)),!c.finish())return r;r=c.output.getBytes()}else r=n.body;return null!==(r="ENCRYPTED PRIVATE KEY"===n.type?mt.decryptPrivateKeyInfo(gt.fromDer(r),t):gt.fromDer(r))&&(r=mt.privateKeyFromAsn1(r)),r},mt.pbe.generatePkcs12Key=function(e,t,r,n,i,a){var o,s;if(null==a){if(!("sha1"in F.md))throw new Error('"sha1" hash algorithm unavailable.');a=F.md.sha1.create()}var c=a.digestLength,u=a.blockLength,l=new F.util.ByteBuffer,d=new F.util.ByteBuffer;if(null!=e){for(s=0;s<e.length;s++)d.putInt16(e.charCodeAt(s));d.putInt16(0)}var f=d.length(),p=t.length(),h=new F.util.ByteBuffer;h.fillWithByte(r,u);var g=u*Math.ceil(p/u),m=new F.util.ByteBuffer;for(s=0;s<g;s++)m.putByte(t.at(s%p));var y=u*Math.ceil(f/u),v=new F.util.ByteBuffer;for(s=0;s<y;s++)v.putByte(d.at(s%f));var b=m;b.putBuffer(v);for(var C=Math.ceil(i/c),E=1;E<=C;E++){var w=new F.util.ByteBuffer;w.putBytes(h.bytes()),w.putBytes(b.bytes());for(var k=0;k<n;k++)a.start(),a.update(w.getBytes()),w=a.digest();var S=new F.util.ByteBuffer;for(s=0;s<u;s++)S.putByte(w.at(s%c));var B=Math.ceil(p/u)+Math.ceil(f/u),T=new F.util.ByteBuffer;for(o=0;o<B;o++){var A=new F.util.ByteBuffer(b.getBytes(u)),I=511;for(s=S.length()-1;s>=0;s--)I>>=8,I+=S.at(s)+A.at(s),A.setAt(s,255&I);T.putBuffer(A)}b=T,l.putBuffer(w)}return l.truncate(l.length()-i),l},mt.pbe.getCipher=function(e,t,r){switch(e){case mt.oids.pkcs5PBES2:return mt.pbe.getCipherForPBES2(e,t,r);case mt.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case mt.oids["pbewithSHAAnd40BitRC2-CBC"]:return mt.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},mt.pbe.getCipherForPBES2=function(e,t,r){var n,i={},a=[];if(!gt.validate(t,bt,i,a))throw(n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,n;if((e=gt.derToOid(i.kdfOid))!==mt.oids.pkcs5PBKDF2)throw(n=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,n.supportedOids=["pkcs5PBKDF2"],n;if((e=gt.derToOid(i.encOid))!==mt.oids["aes128-CBC"]&&e!==mt.oids["aes192-CBC"]&&e!==mt.oids["aes256-CBC"]&&e!==mt.oids["des-EDE3-CBC"]&&e!==mt.oids.desCBC)throw(n=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,n.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],n;var o,s,c=i.kdfSalt,u=F.util.createBuffer(i.kdfIterationCount);switch(u=u.getInt(u.length()<<3),mt.oids[e]){case"aes128-CBC":o=16,s=F.aes.createDecryptionCipher;break;case"aes192-CBC":o=24,s=F.aes.createDecryptionCipher;break;case"aes256-CBC":o=32,s=F.aes.createDecryptionCipher;break;case"des-EDE3-CBC":o=24,s=F.des.createDecryptionCipher;break;case"desCBC":o=8,s=F.des.createDecryptionCipher}var l=wt(i.prfOid),d=F.pkcs5.pbkdf2(r,c,u,o,l),f=i.encIv,p=s(d);return p.start(f),p},mt.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},i=[];if(!gt.validate(t,Ct,n,i))throw(l=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=i,l;var a,o,s,c=F.util.createBuffer(n.salt),u=F.util.createBuffer(n.iterations);switch(u=u.getInt(u.length()<<3),e){case mt.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:a=24,o=8,s=F.des.startDecrypting;break;case mt.oids["pbewithSHAAnd40BitRC2-CBC"]:a=5,o=8,s=function(e,t){var r=F.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var l;throw(l=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,l}var d=wt(n.prfOid),f=mt.pbe.generatePkcs12Key(r,c,1,u,a,d);return d.start(),s(f,mt.pbe.generatePkcs12Key(r,c,2,u,o,d))},mt.pbe.opensslDeriveBytes=function(e,t,r,n){if(null==n){if(!("md5"in F.md))throw new Error('"md5" hash algorithm unavailable.');n=F.md.md5.create()}null===t&&(t="");for(var i=[Et(n,e+t)],a=16,o=1;a<r;++o,a+=16)i.push(Et(n,i[o-1]+e+t));return i.join("").substr(0,r)},E((function(e){var t=F.asn1,r=e.exports=F.pkcs7asn1=F.pkcs7asn1||{};F.pkcs7=F.pkcs7||{},F.pkcs7.asn1=r;var n={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};r.contentInfoValidator=n;var i={name:"EncryptedContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};r.envelopedDataValidator={name:"EnvelopedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(i)},r.encryptedDataValidator={name:"EncryptedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"}].concat(i)};var a={name:"SignerInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};r.signedDataValidator={name:"SignedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},n,{name:"SignedData.Certificates",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,capture:"signerInfos",optional:!0,value:[a]}]},r.recipientInfoValidator={name:"RecipientInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}})),E((function(e){F.mgf=F.mgf||{},(e.exports=F.mgf.mgf1=F.mgf1=F.mgf1||{}).create=function(e){return{generate:function(t,r){for(var n=new F.util.ByteBuffer,i=Math.ceil(r/e.digestLength),a=0;a<i;a++){var o=new F.util.ByteBuffer;o.putInt32(a),e.start(),e.update(t+o.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}}}})),F.mgf=F.mgf||{},F.mgf.mgf1=F.mgf1,E((function(e){(e.exports=F.pss=F.pss||{}).create=function(e){3===arguments.length&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t,r=e.md,n=e.mgf,i=r.digestLength,a=e.salt||null;if("string"==typeof a&&(a=F.util.createBuffer(a)),"saltLength"in e)t=e.saltLength;else{if(null===a)throw new Error("Salt length not specified or specific salt not given.");t=a.length()}if(null!==a&&a.length()!==t)throw new Error("Given salt length does not match length of given salt.");var o=e.prng||F.random;return{encode:function(e,s){var c,u,l=s-1,d=Math.ceil(l/8),f=e.digest().getBytes();if(d<i+t+2)throw new Error("Message is too long to encrypt.");u=null===a?o.getBytesSync(t):a.bytes();var p=new F.util.ByteBuffer;p.fillWithByte(0,8),p.putBytes(f),p.putBytes(u),r.start(),r.update(p.getBytes());var h=r.digest().getBytes(),g=new F.util.ByteBuffer;g.fillWithByte(0,d-t-i-2),g.putByte(1),g.putBytes(u);var m=g.getBytes(),y=d-i-1,v=n.generate(h,y),b="";for(c=0;c<y;c++)b+=String.fromCharCode(m.charCodeAt(c)^v.charCodeAt(c));var C=65280>>8*d-l&255;return(b=String.fromCharCode(b.charCodeAt(0)&~C)+b.substr(1))+h+String.fromCharCode(188)},verify:function(e,a,o){var s,c=o-1,u=Math.ceil(c/8);if(a=a.substr(-u),u<i+t+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(188!==a.charCodeAt(u-1))throw new Error("Encoded message does not end in 0xBC.");var l=u-i-1,d=a.substr(0,l),f=a.substr(l,i),p=65280>>8*u-c&255;if(0!=(d.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var h=n.generate(f,l),g="";for(s=0;s<l;s++)g+=String.fromCharCode(d.charCodeAt(s)^h.charCodeAt(s));g=String.fromCharCode(g.charCodeAt(0)&~p)+g.substr(1);var m=u-i-t-2;for(s=0;s<m;s++)if(0!==g.charCodeAt(s))throw new Error("Leftmost octets not zero as expected");if(1!==g.charCodeAt(m))throw new Error("Inconsistent PSS signature, 0x01 marker not found");var y=g.substr(-t),v=new F.util.ByteBuffer;return v.fillWithByte(0,8),v.putBytes(e),v.putBytes(y),r.start(),r.update(v.getBytes()),f===r.digest().getBytes()}}}})),E((function(e){var t=F.asn1,r=e.exports=F.pki=F.pki||{},n=r.oids,i={};i.CN=n.commonName,i.commonName="CN",i.C=n.countryName,i.countryName="C",i.L=n.localityName,i.localityName="L",i.ST=n.stateOrProvinceName,i.stateOrProvinceName="ST",i.O=n.organizationName,i.organizationName="O",i.OU=n.organizationalUnitName,i.organizationalUnitName="OU",i.E=n.emailAddress,i.emailAddress="E";var a=F.pki.rsa.publicKeyValidator,o={name:"Certificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},a,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},s={name:"rsapss",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},c={name:"CertificationRequestInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},a,{name:"CertificationRequestInfo.attributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0}]}]}]},u={name:"CertificationRequest",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[c,{name:"CertificationRequest.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function l(e,t){"string"==typeof t&&(t={shortName:t});for(var r,n=null,i=0;null===n&&i<e.attributes.length;++i)r=e.attributes[i],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(n=r);return n}r.RDNAttributesAsArray=function(e,r){for(var a,o,s,c=[],u=0;u<e.value.length;++u){a=e.value[u];for(var l=0;l<a.value.length;++l)s={},o=a.value[l],s.type=t.derToOid(o.value[0].value),s.value=o.value[1].value,s.valueTagClass=o.value[1].type,s.type in n&&(s.name=n[s.type],s.name in i&&(s.shortName=i[s.name])),r&&(r.update(s.type),r.update(s.value)),c.push(s)}return c},r.CRIAttributesAsArray=function(e){for(var a=[],o=0;o<e.length;++o)for(var s=e[o],c=t.derToOid(s.value[0].value),u=s.value[1].value,l=0;l<u.length;++l){var d={};if(d.type=c,d.value=u[l].value,d.valueTagClass=u[l].type,d.type in n&&(d.name=n[d.type],d.name in i&&(d.shortName=i[d.name])),d.type===n.extensionRequest){d.extensions=[];for(var f=0;f<d.value.length;++f)d.extensions.push(r.certificateExtensionFromAsn1(d.value[f]))}a.push(d)}return a};var d=function(e,r,i){var a={};if(e!==n["RSASSA-PSS"])return a;i&&(a={hash:{algorithmOid:n.sha1},mgf:{algorithmOid:n.mgf1,hash:{algorithmOid:n.sha1}},saltLength:20});var o={},c=[];if(!t.validate(r,s,o,c)){var u=new Error("Cannot read RSASSA-PSS parameter block.");throw u.errors=c,u}return void 0!==o.hashOid&&(a.hash=a.hash||{},a.hash.algorithmOid=t.derToOid(o.hashOid)),void 0!==o.maskGenOid&&(a.mgf=a.mgf||{},a.mgf.algorithmOid=t.derToOid(o.maskGenOid),a.mgf.hash=a.mgf.hash||{},a.mgf.hash.algorithmOid=t.derToOid(o.maskGenHashOid)),void 0!==o.saltLength&&(a.saltLength=o.saltLength.charCodeAt(0)),a};function f(e){for(var r,n,i=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),a=e.attributes,o=0;o<a.length;++o){var s=(r=a[o]).value,c=t.Type.PRINTABLESTRING;"valueTagClass"in r&&(c=r.valueTagClass)===t.Type.UTF8&&(s=F.util.encodeUtf8(s)),n=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.type).getBytes()),t.create(t.Class.UNIVERSAL,c,!1,s)])]),i.value.push(n)}return i}function p(e){for(var a,o=0;o<e.length;++o){if(void 0===(a=e[o]).name&&(a.type&&a.type in r.oids?a.name=r.oids[a.type]:a.shortName&&a.shortName in i&&(a.name=r.oids[i[a.shortName]])),void 0===a.type){if(!a.name||!(a.name in r.oids))throw(c=new Error("Attribute type not specified.")).attribute=a,c;a.type=r.oids[a.name]}if(void 0===a.shortName&&a.name&&a.name in i&&(a.shortName=i[a.name]),a.type===n.extensionRequest&&(a.valueConstructed=!0,a.valueTagClass=t.Type.SEQUENCE,!a.value&&a.extensions)){a.value=[];for(var s=0;s<a.extensions.length;++s)a.value.push(r.certificateExtensionToAsn1(h(a.extensions[s])))}var c;if(void 0===a.value)throw(c=new Error("Attribute value not specified.")).attribute=a,c}}function h(e,i){if(i=i||{},void 0===e.name&&e.id&&e.id in r.oids&&(e.name=r.oids[e.id]),void 0===e.id){if(!e.name||!(e.name in r.oids))throw(C=new Error("Extension ID not specified.")).extension=e,C;e.id=r.oids[e.name]}if(void 0!==e.value)return e;if("keyUsage"===e.name){var a=0,o=0,s=0;e.digitalSignature&&(o|=128,a=7),e.nonRepudiation&&(o|=64,a=6),e.keyEncipherment&&(o|=32,a=5),e.dataEncipherment&&(o|=16,a=4),e.keyAgreement&&(o|=8,a=3),e.keyCertSign&&(o|=4,a=2),e.cRLSign&&(o|=2,a=1),e.encipherOnly&&(o|=1,a=0),e.decipherOnly&&(s|=128,a=7);var c=String.fromCharCode(a);0!==s?c+=String.fromCharCode(o)+String.fromCharCode(s):0!==o&&(c+=String.fromCharCode(o)),e.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,c)}else if("basicConstraints"===e.name)e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in e&&e.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.pathLenConstraint).getBytes()));else if("extKeyUsage"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);var u=e.value.value;for(var l in e)!0===e[l]&&(l in n?u.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n[l]).getBytes())):-1!==l.indexOf(".")&&u.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(l).getBytes())))}else if("nsCertType"===e.name)a=0,o=0,e.client&&(o|=128,a=7),e.server&&(o|=64,a=6),e.email&&(o|=32,a=5),e.objsign&&(o|=16,a=4),e.reserved&&(o|=8,a=3),e.sslCA&&(o|=4,a=2),e.emailCA&&(o|=2,a=1),e.objCA&&(o|=1,a=0),c=String.fromCharCode(a),0!==o&&(c+=String.fromCharCode(o)),e.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,c);else if("subjectAltName"===e.name||"issuerAltName"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);for(var d=0;d<e.altNames.length;++d){if(c=(y=e.altNames[d]).value,7===y.type&&y.ip){if(null===(c=F.util.bytesFromIP(y.ip)))throw(C=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,C}else 8===y.type&&(c=y.oid?t.oidToDer(t.oidToDer(y.oid)):t.oidToDer(c));e.value.value.push(t.create(t.Class.CONTEXT_SPECIFIC,y.type,!1,c))}}else if("nsComment"===e.name&&i.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=t.create(t.Class.UNIVERSAL,t.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&i.cert){var p=i.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=p.toHex(),e.value=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,p.getBytes())}else if("authorityKeyIdentifier"===e.name&&i.cert){if(e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),u=e.value.value,e.keyIdentifier){var h=!0===e.keyIdentifier?i.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;u.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!1,h))}if(e.authorityCertIssuer){var g=[t.create(t.Class.CONTEXT_SPECIFIC,4,!0,[f(!0===e.authorityCertIssuer?i.cert.issuer:e.authorityCertIssuer)])];u.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,g))}if(e.serialNumber){var m=F.util.hexToBytes(!0===e.serialNumber?i.cert.serialNumber:e.serialNumber);u.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!1,m))}}else if("cRLDistributionPoints"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),u=e.value.value;var y,v=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),b=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(d=0;d<e.altNames.length;++d){if(c=(y=e.altNames[d]).value,7===y.type&&y.ip){if(null===(c=F.util.bytesFromIP(y.ip)))throw(C=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,C}else 8===y.type&&(c=y.oid?t.oidToDer(t.oidToDer(y.oid)):t.oidToDer(c));b.value.push(t.create(t.Class.CONTEXT_SPECIFIC,y.type,!1,c))}v.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[b])),u.push(v)}var C;if(void 0===e.value)throw(C=new Error("Extension value not specified.")).extension=e,C;return e}function g(e,r){switch(e){case n["RSASSA-PSS"]:var i=[];return void 0!==r.hash.algorithmOid&&i.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])),void 0!==r.mgf.algorithmOid&&i.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.mgf.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.mgf.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])])),void 0!==r.saltLength&&i.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.saltLength).getBytes())])),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,i);default:return t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")}}function m(e){var r=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===e.attributes.length)return r;for(var n=e.attributes,i=0;i<n.length;++i){var a=n[i],o=a.value,s=t.Type.UTF8;"valueTagClass"in a&&(s=a.valueTagClass),s===t.Type.UTF8&&(o=F.util.encodeUtf8(o));var c=!1;"valueConstructed"in a&&(c=a.valueConstructed);var u=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(a.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,s,c,o)])]);r.value.push(u)}return r}r.certificateFromPem=function(e,n,i){var a=F.pem.decode(e)[0];if("CERTIFICATE"!==a.type&&"X509 CERTIFICATE"!==a.type&&"TRUSTED CERTIFICATE"!==a.type){var o=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw o.headerType=a.type,o}if(a.procType&&"ENCRYPTED"===a.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=t.fromDer(a.body,i);return r.certificateFromAsn1(s,n)},r.certificateToPem=function(e,n){var i={type:"CERTIFICATE",body:t.toDer(r.certificateToAsn1(e)).getBytes()};return F.pem.encode(i,{maxline:n})},r.publicKeyFromPem=function(e){var n=F.pem.decode(e)[0];if("PUBLIC KEY"!==n.type&&"RSA PUBLIC KEY"!==n.type){var i=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert public key from PEM; PEM is encrypted.");var a=t.fromDer(n.body);return r.publicKeyFromAsn1(a)},r.publicKeyToPem=function(e,n){var i={type:"PUBLIC KEY",body:t.toDer(r.publicKeyToAsn1(e)).getBytes()};return F.pem.encode(i,{maxline:n})},r.publicKeyToRSAPublicKeyPem=function(e,n){var i={type:"RSA PUBLIC KEY",body:t.toDer(r.publicKeyToRSAPublicKey(e)).getBytes()};return F.pem.encode(i,{maxline:n})},r.getPublicKeyFingerprint=function(e,n){var i,a=(n=n||{}).md||F.md.sha1.create();switch(n.type||"RSAPublicKey"){case"RSAPublicKey":i=t.toDer(r.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":i=t.toDer(r.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+n.type+'".')}a.start(),a.update(i);var o=a.digest();if("hex"===n.encoding){var s=o.toHex();return n.delimiter?s.match(/.{2}/g).join(n.delimiter):s}if("binary"===n.encoding)return o.getBytes();if(n.encoding)throw new Error('Unknown encoding "'+n.encoding+'".');return o},r.certificationRequestFromPem=function(e,n,i){var a=F.pem.decode(e)[0];if("CERTIFICATE REQUEST"!==a.type){var o=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw o.headerType=a.type,o}if(a.procType&&"ENCRYPTED"===a.procType.type)throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=t.fromDer(a.body,i);return r.certificationRequestFromAsn1(s,n)},r.certificationRequestToPem=function(e,n){var i={type:"CERTIFICATE REQUEST",body:t.toDer(r.certificationRequestToAsn1(e)).getBytes()};return F.pem.encode(i,{maxline:n})},r.createCertificate=function(){var e={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return l(e.issuer,t)},e.issuer.addField=function(t){p([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return l(e.subject,t)},e.subject.addField=function(t){p([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,r){p(t),e.subject.attributes=t,delete e.subject.uniqueId,r&&(e.subject.uniqueId=r),e.subject.hash=null},e.setIssuer=function(t,r){p(t),e.issuer.attributes=t,delete e.issuer.uniqueId,r&&(e.issuer.uniqueId=r),e.issuer.hash=null},e.setExtensions=function(t){for(var r=0;r<t.length;++r)h(t[r],{cert:e});e.extensions=t},e.getExtension=function(t){"string"==typeof t&&(t={name:t});for(var r,n=null,i=0;null===n&&i<e.extensions.length;++i)r=e.extensions[i],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(n=r);return n},e.sign=function(i,a){e.md=a||F.md.sha1.create();var o=n[e.md.algorithm+"WithRSAEncryption"];if(!o){var s=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw s.algorithm=e.md.algorithm,s}e.signatureOid=e.siginfo.algorithmOid=o,e.tbsCertificate=r.getTBSCertificate(e);var c=t.toDer(e.tbsCertificate);e.md.update(c.getBytes()),e.signature=i.sign(e.md)},e.verify=function(i){var a=!1;if(!e.issued(i)){var o=i.issuer,s=e.subject;throw(h=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.")).expectedIssuer=o.attributes,h.actualIssuer=s.attributes,h}var c=i.md;if(null===c){if(i.signatureOid in n)switch(n[i.signatureOid]){case"sha1WithRSAEncryption":c=F.md.sha1.create();break;case"md5WithRSAEncryption":c=F.md.md5.create();break;case"sha256WithRSAEncryption":c=F.md.sha256.create();break;case"sha384WithRSAEncryption":c=F.md.sha384.create();break;case"sha512WithRSAEncryption":c=F.md.sha512.create();break;case"RSASSA-PSS":c=F.md.sha256.create()}if(null===c)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=i.signatureOid,h;var u=i.tbsCertificate||r.getTBSCertificate(i),l=t.toDer(u);c.update(l.getBytes())}if(null!==c){var d;switch(i.signatureOid){case n.sha1WithRSAEncryption:d=void 0;break;case n["RSASSA-PSS"]:var f,p,h;if(void 0===(f=n[i.signatureParameters.mgf.hash.algorithmOid])||void 0===F.md[f])throw(h=new Error("Unsupported MGF hash function.")).oid=i.signatureParameters.mgf.hash.algorithmOid,h.name=f,h;if(void 0===(p=n[i.signatureParameters.mgf.algorithmOid])||void 0===F.mgf[p])throw(h=new Error("Unsupported MGF function.")).oid=i.signatureParameters.mgf.algorithmOid,h.name=p,h;if(p=F.mgf[p].create(F.md[f].create()),void 0===(f=n[i.signatureParameters.hash.algorithmOid])||void 0===F.md[f])throw{message:"Unsupported RSASSA-PSS hash function.",oid:i.signatureParameters.hash.algorithmOid,name:f};d=F.pss.create(F.md[f].create(),p,i.signatureParameters.saltLength)}a=e.publicKey.verify(c.digest().getBytes(),i.signature,d)}return a},e.isIssuer=function(t){var r=!1,n=e.issuer,i=t.subject;if(n.hash&&i.hash)r=n.hash===i.hash;else if(n.attributes.length===i.attributes.length){var a,o;r=!0;for(var s=0;r&&s<n.attributes.length;++s)a=n.attributes[s],o=i.attributes[s],a.type===o.type&&a.value===o.value||(r=!1)}return r},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return r.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=n.subjectKeyIdentifier,r=0;r<e.extensions.length;++r){var i=e.extensions[r];if(i.id===t){var a=e.generateSubjectKeyIdentifier().getBytes();return F.util.hexToBytes(i.subjectKeyIdentifier)===a}}return!1},e},r.certificateFromAsn1=function(e,i){var a={},s=[];if(!t.validate(e,o,a,s))throw(h=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.")).errors=s,h;if(t.derToOid(a.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var c=r.createCertificate();c.version=a.certVersion?a.certVersion.charCodeAt(0):0;var u=F.util.createBuffer(a.certSerialNumber);c.serialNumber=u.toHex(),c.signatureOid=F.asn1.derToOid(a.certSignatureOid),c.signatureParameters=d(c.signatureOid,a.certSignatureParams,!0),c.siginfo.algorithmOid=F.asn1.derToOid(a.certinfoSignatureOid),c.siginfo.parameters=d(c.siginfo.algorithmOid,a.certinfoSignatureParams,!1),c.signature=a.certSignature;var f=[];if(void 0!==a.certValidity1UTCTime&&f.push(t.utcTimeToDate(a.certValidity1UTCTime)),void 0!==a.certValidity2GeneralizedTime&&f.push(t.generalizedTimeToDate(a.certValidity2GeneralizedTime)),void 0!==a.certValidity3UTCTime&&f.push(t.utcTimeToDate(a.certValidity3UTCTime)),void 0!==a.certValidity4GeneralizedTime&&f.push(t.generalizedTimeToDate(a.certValidity4GeneralizedTime)),f.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(f.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=f[0],c.validity.notAfter=f[1],c.tbsCertificate=a.tbsCertificate,i){var h;if(c.md=null,c.signatureOid in n)switch(n[c.signatureOid]){case"sha1WithRSAEncryption":c.md=F.md.sha1.create();break;case"md5WithRSAEncryption":c.md=F.md.md5.create();break;case"sha256WithRSAEncryption":c.md=F.md.sha256.create();break;case"sha384WithRSAEncryption":c.md=F.md.sha384.create();break;case"sha512WithRSAEncryption":c.md=F.md.sha512.create();break;case"RSASSA-PSS":c.md=F.md.sha256.create()}if(null===c.md)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=c.signatureOid,h;var g=t.toDer(c.tbsCertificate);c.md.update(g.getBytes())}var m=F.md.sha1.create();c.issuer.getField=function(e){return l(c.issuer,e)},c.issuer.addField=function(e){p([e]),c.issuer.attributes.push(e)},c.issuer.attributes=r.RDNAttributesAsArray(a.certIssuer,m),a.certIssuerUniqueId&&(c.issuer.uniqueId=a.certIssuerUniqueId),c.issuer.hash=m.digest().toHex();var y=F.md.sha1.create();return c.subject.getField=function(e){return l(c.subject,e)},c.subject.addField=function(e){p([e]),c.subject.attributes.push(e)},c.subject.attributes=r.RDNAttributesAsArray(a.certSubject,y),a.certSubjectUniqueId&&(c.subject.uniqueId=a.certSubjectUniqueId),c.subject.hash=y.digest().toHex(),a.certExtensions?c.extensions=r.certificateExtensionsFromAsn1(a.certExtensions):c.extensions=[],c.publicKey=r.publicKeyFromAsn1(a.subjectPublicKeyInfo),c},r.certificateExtensionsFromAsn1=function(e){for(var t=[],n=0;n<e.value.length;++n)for(var i=e.value[n],a=0;a<i.value.length;++a)t.push(r.certificateExtensionFromAsn1(i.value[a]));return t},r.certificateExtensionFromAsn1=function(e){var r={};if(r.id=t.derToOid(e.value[0].value),r.critical=!1,e.value[1].type===t.Type.BOOLEAN?(r.critical=0!==e.value[1].value.charCodeAt(0),r.value=e.value[2].value):r.value=e.value[1].value,r.id in n)if(r.name=n[r.id],"keyUsage"===r.name){var i=0,a=0;(s=t.fromDer(r.value)).value.length>1&&(i=s.value.charCodeAt(1),a=s.value.length>2?s.value.charCodeAt(2):0),r.digitalSignature=128==(128&i),r.nonRepudiation=64==(64&i),r.keyEncipherment=32==(32&i),r.dataEncipherment=16==(16&i),r.keyAgreement=8==(8&i),r.keyCertSign=4==(4&i),r.cRLSign=2==(2&i),r.encipherOnly=1==(1&i),r.decipherOnly=128==(128&a)}else if("basicConstraints"===r.name){(s=t.fromDer(r.value)).value.length>0&&s.value[0].type===t.Type.BOOLEAN?r.cA=0!==s.value[0].value.charCodeAt(0):r.cA=!1;var o=null;s.value.length>0&&s.value[0].type===t.Type.INTEGER?o=s.value[0].value:s.value.length>1&&(o=s.value[1].value),null!==o&&(r.pathLenConstraint=t.derToInteger(o))}else if("extKeyUsage"===r.name)for(var s=t.fromDer(r.value),c=0;c<s.value.length;++c){var u=t.derToOid(s.value[c].value);u in n?r[n[u]]=!0:r[u]=!0}else if("nsCertType"===r.name)i=0,(s=t.fromDer(r.value)).value.length>1&&(i=s.value.charCodeAt(1)),r.client=128==(128&i),r.server=64==(64&i),r.email=32==(32&i),r.objsign=16==(16&i),r.reserved=8==(8&i),r.sslCA=4==(4&i),r.emailCA=2==(2&i),r.objCA=1==(1&i);else if("subjectAltName"===r.name||"issuerAltName"===r.name){var l;r.altNames=[],s=t.fromDer(r.value);for(var d=0;d<s.value.length;++d){var f={type:(l=s.value[d]).type,value:l.value};switch(r.altNames.push(f),l.type){case 1:case 2:case 6:break;case 7:f.ip=F.util.bytesToIP(l.value);break;case 8:f.oid=t.derToOid(l.value)}}}else"subjectKeyIdentifier"===r.name&&(s=t.fromDer(r.value),r.subjectKeyIdentifier=F.util.bytesToHex(s.value));return r},r.certificationRequestFromAsn1=function(e,i){var a={},o=[];if(!t.validate(e,u,a,o))throw(c=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.")).errors=o,c;if(t.derToOid(a.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var s=r.createCertificationRequest();if(s.version=a.csrVersion?a.csrVersion.charCodeAt(0):0,s.signatureOid=F.asn1.derToOid(a.csrSignatureOid),s.signatureParameters=d(s.signatureOid,a.csrSignatureParams,!0),s.siginfo.algorithmOid=F.asn1.derToOid(a.csrSignatureOid),s.siginfo.parameters=d(s.siginfo.algorithmOid,a.csrSignatureParams,!1),s.signature=a.csrSignature,s.certificationRequestInfo=a.certificationRequestInfo,i){var c;if(s.md=null,s.signatureOid in n)switch(n[s.signatureOid]){case"sha1WithRSAEncryption":s.md=F.md.sha1.create();break;case"md5WithRSAEncryption":s.md=F.md.md5.create();break;case"sha256WithRSAEncryption":s.md=F.md.sha256.create();break;case"sha384WithRSAEncryption":s.md=F.md.sha384.create();break;case"sha512WithRSAEncryption":s.md=F.md.sha512.create();break;case"RSASSA-PSS":s.md=F.md.sha256.create()}if(null===s.md)throw(c=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=s.signatureOid,c;var f=t.toDer(s.certificationRequestInfo);s.md.update(f.getBytes())}var h=F.md.sha1.create();return s.subject.getField=function(e){return l(s.subject,e)},s.subject.addField=function(e){p([e]),s.subject.attributes.push(e)},s.subject.attributes=r.RDNAttributesAsArray(a.certificationRequestInfoSubject,h),s.subject.hash=h.digest().toHex(),s.publicKey=r.publicKeyFromAsn1(a.subjectPublicKeyInfo),s.getAttribute=function(e){return l(s,e)},s.addAttribute=function(e){p([e]),s.attributes.push(e)},s.attributes=r.CRIAttributesAsArray(a.certificationRequestInfoAttributes||[]),s},r.createCertificationRequest=function(){var e={version:0,signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return l(e.subject,t)},e.subject.addField=function(t){p([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return l(e,t)},e.addAttribute=function(t){p([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){p(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){p(t),e.attributes=t},e.sign=function(i,a){e.md=a||F.md.sha1.create();var o=n[e.md.algorithm+"WithRSAEncryption"];if(!o){var s=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw s.algorithm=e.md.algorithm,s}e.signatureOid=e.siginfo.algorithmOid=o,e.certificationRequestInfo=r.getCertificationRequestInfo(e);var c=t.toDer(e.certificationRequestInfo);e.md.update(c.getBytes()),e.signature=i.sign(e.md)},e.verify=function(){var i=!1,a=e.md;if(null===a){if(e.signatureOid in n)switch(n[e.signatureOid]){case"sha1WithRSAEncryption":a=F.md.sha1.create();break;case"md5WithRSAEncryption":a=F.md.md5.create();break;case"sha256WithRSAEncryption":a=F.md.sha256.create();break;case"sha384WithRSAEncryption":a=F.md.sha384.create();break;case"sha512WithRSAEncryption":a=F.md.sha512.create();break;case"RSASSA-PSS":a=F.md.sha256.create()}if(null===a)throw(d=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=e.signatureOid,d;var o=e.certificationRequestInfo||r.getCertificationRequestInfo(e),s=t.toDer(o);a.update(s.getBytes())}if(null!==a){var c;switch(e.signatureOid){case n.sha1WithRSAEncryption:break;case n["RSASSA-PSS"]:var u,l,d;if(void 0===(u=n[e.signatureParameters.mgf.hash.algorithmOid])||void 0===F.md[u])throw(d=new Error("Unsupported MGF hash function.")).oid=e.signatureParameters.mgf.hash.algorithmOid,d.name=u,d;if(void 0===(l=n[e.signatureParameters.mgf.algorithmOid])||void 0===F.mgf[l])throw(d=new Error("Unsupported MGF function.")).oid=e.signatureParameters.mgf.algorithmOid,d.name=l,d;if(l=F.mgf[l].create(F.md[u].create()),void 0===(u=n[e.signatureParameters.hash.algorithmOid])||void 0===F.md[u])throw(d=new Error("Unsupported RSASSA-PSS hash function.")).oid=e.signatureParameters.hash.algorithmOid,d.name=u,d;c=F.pss.create(F.md[u].create(),l,e.signatureParameters.saltLength)}i=e.publicKey.verify(a.digest().getBytes(),e.signature,c)}return i},e};var y=new Date("1950-01-01T00:00:00Z"),v=new Date("2050-01-01T00:00:00Z");function b(e){return e>=y&&e<v?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(e)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(e))}r.getTBSCertificate=function(e){var n=b(e.validity.notBefore),i=b(e.validity.notAfter),a=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,F.util.hexToBytes(e.serialNumber)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.siginfo.algorithmOid).getBytes()),g(e.siginfo.algorithmOid,e.siginfo.parameters)]),f(e.issuer),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,i]),f(e.subject),r.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&a.value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&a.value.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&a.value.push(r.certificateExtensionsToAsn1(e.extensions)),a},r.getCertificationRequestInfo=function(e){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),f(e.subject),r.publicKeyToAsn1(e.publicKey),m(e)])},r.distinguishedNameToAsn1=function(e){return f(e)},r.certificateToAsn1=function(e){var n=e.tbsCertificate||r.getTBSCertificate(e);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureOid).getBytes()),g(e.signatureOid,e.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},r.certificateExtensionsToAsn1=function(e){var n=t.create(t.Class.CONTEXT_SPECIFIC,3,!0,[]),i=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);n.value.push(i);for(var a=0;a<e.length;++a)i.value.push(r.certificateExtensionToAsn1(e[a]));return n},r.certificateExtensionToAsn1=function(e){var r=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.id).getBytes())),e.critical&&r.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255)));var n=e.value;return"string"!=typeof e.value&&(n=t.toDer(n).getBytes()),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n)),r},r.certificationRequestToAsn1=function(e){var n=e.certificationRequestInfo||r.getCertificationRequestInfo(e);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureOid).getBytes()),g(e.signatureOid,e.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},r.createCaStore=function(e){var n={certs:{}};function i(e){return a(e),n.certs[e.hash]||null}function a(e){if(!e.hash){var t=F.md.sha1.create();e.attributes=r.RDNAttributesAsArray(f(e),t),e.hash=t.digest().toHex()}}if(n.getIssuer=function(e){return i(e.issuer)},n.addCertificate=function(e){if("string"==typeof e&&(e=F.pki.certificateFromPem(e)),a(e.subject),!n.hasCertificate(e))if(e.subject.hash in n.certs){var t=n.certs[e.subject.hash];F.util.isArray(t)||(t=[t]),t.push(e),n.certs[e.subject.hash]=t}else n.certs[e.subject.hash]=e},n.hasCertificate=function(e){"string"==typeof e&&(e=F.pki.certificateFromPem(e));var n=i(e.subject);if(!n)return!1;F.util.isArray(n)||(n=[n]);for(var a=t.toDer(r.certificateToAsn1(e)).getBytes(),o=0;o<n.length;++o)if(a===t.toDer(r.certificateToAsn1(n[o])).getBytes())return!0;return!1},n.listAllCertificates=function(){var e=[];for(var t in n.certs)if(n.certs.hasOwnProperty(t)){var r=n.certs[t];if(F.util.isArray(r))for(var i=0;i<r.length;++i)e.push(r[i]);else e.push(r)}return e},n.removeCertificate=function(e){var o;if("string"==typeof e&&(e=F.pki.certificateFromPem(e)),a(e.subject),!n.hasCertificate(e))return null;var s=i(e.subject);if(!F.util.isArray(s))return o=n.certs[e.subject.hash],delete n.certs[e.subject.hash],o;for(var c=t.toDer(r.certificateToAsn1(e)).getBytes(),u=0;u<s.length;++u)c===t.toDer(r.certificateToAsn1(s[u])).getBytes()&&(o=s[u],s.splice(u,1));return 0===s.length&&delete n.certs[e.subject.hash],o},e)for(var o=0;o<e.length;++o){var s=e[o];n.addCertificate(s)}return n},r.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},r.verifyCertificateChain=function(e,t,n){"function"==typeof n&&(n={verify:n}),n=n||{};var i=(t=t.slice(0)).slice(0),a=n.validityCheckDate;void 0===a&&(a=new Date);var o=!0,s=null,c=0;do{var u=t.shift(),l=null,d=!1;if(a&&(a<u.validity.notBefore||a>u.validity.notAfter)&&(s={message:"Certificate is not valid yet or has expired.",error:r.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:a}),null===s){if(null===(l=t[0]||e.getIssuer(u))&&u.isIssuer(u)&&(d=!0,l=u),l){var f=l;F.util.isArray(f)||(f=[f]);for(var p=!1;!p&&f.length>0;){l=f.shift();try{p=l.verify(u)}catch(e){}}p||(s={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}null!==s||l&&!d||e.hasCertificate(u)||(s={message:"Certificate is not trusted.",error:r.certificateError.unknown_ca})}if(null===s&&l&&!u.isIssuer(l)&&(s={message:"Certificate issuer is invalid.",error:r.certificateError.bad_certificate}),null===s)for(var h={keyUsage:!0,basicConstraints:!0},g=0;null===s&&g<u.extensions.length;++g){var m=u.extensions[g];!m.critical||m.name in h||(s={message:"Certificate has an unsupported critical extension.",error:r.certificateError.unsupported_certificate})}if(null===s&&(!o||0===t.length&&(!l||d))){var y=u.getExtension("basicConstraints"),v=u.getExtension("keyUsage");null!==v&&(v.keyCertSign&&null!==y||(s={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:r.certificateError.bad_certificate})),null!==s||null===y||y.cA||(s={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:r.certificateError.bad_certificate}),null===s&&null!==v&&"pathLenConstraint"in y&&c-1>y.pathLenConstraint&&(s={message:"Certificate basicConstraints pathLenConstraint violated.",error:r.certificateError.bad_certificate})}var b=null===s||s.error,C=n.verify?n.verify(b,c,i):b;if(!0!==C)throw!0===b&&(s={message:"The application rejected the certificate.",error:r.certificateError.bad_certificate}),(C||0===C)&&("object"!=typeof C||F.util.isArray(C)?"string"==typeof C&&(s.error=C):(C.message&&(s.message=C.message),C.error&&(s.error=C.error))),s;s=null,o=!1,++c}while(t.length>0);return!0}})),E((function(e){var t=F.asn1,r=F.pki,n=e.exports=F.pkcs12=F.pkcs12||{},i={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},a={name:"PFX",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},i,{name:"PFX.macData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},o={name:"SafeBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},s={name:"Attribute",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,capture:"values"}]},c={name:"CertBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:t.Class.UNIVERSAL,type:t.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function u(e,t,r,n){for(var i=[],a=0;a<e.length;a++)for(var o=0;o<e[a].safeBags.length;o++){var s=e[a].safeBags[o];void 0!==n&&s.type!==n||(null!==t?void 0!==s.attributes[t]&&s.attributes[t].indexOf(r)>=0&&i.push(s):i.push(s))}return i}function l(e){if(e.composed||e.constructed){for(var t=F.util.createBuffer(),r=0;r<e.value.length;++r)t.putBytes(e.value[r].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function d(e,n){var i={},a=[];if(!t.validate(e,F.pkcs7.asn1.encryptedDataValidator,i,a))throw(o=new Error("Cannot read EncryptedContentInfo.")).errors=a,o;var o,s=t.derToOid(i.contentType);if(s!==r.oids.data)throw(o=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.")).oid=s,o;s=t.derToOid(i.encAlgorithm);var c=r.pbe.getCipher(s,i.encParameter,n),u=l(i.encryptedContentAsn1),d=F.util.createBuffer(u.value);if(c.update(d),!c.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return c.output.getBytes()}function f(e,n,i){if(!n&&0===e.length)return[];if((e=t.fromDer(e,n)).tagClass!==t.Class.UNIVERSAL||e.type!==t.Type.SEQUENCE||!0!==e.constructed)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var a=[],s=0;s<e.value.length;s++){var u=e.value[s],l={},d=[];if(!t.validate(u,o,l,d))throw(y=new Error("Cannot read SafeBag.")).errors=d,y;var f,h,g={type:t.derToOid(l.bagId),attributes:p(l.bagAttributes)};a.push(g);var m=l.bagValue.value[0];switch(g.type){case r.oids.pkcs8ShroudedKeyBag:if(null===(m=r.decryptPrivateKeyInfo(m,i)))throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case r.oids.keyBag:try{g.key=r.privateKeyFromAsn1(m)}catch(e){g.key=null,g.asn1=m}continue;case r.oids.certBag:f=c,h=function(){if(t.derToOid(l.certId)!==r.oids.x509Certificate){var e=new Error("Unsupported certificate type, only X.509 supported.");throw e.oid=t.derToOid(l.certId),e}var i=t.fromDer(l.cert,n);try{g.cert=r.certificateFromAsn1(i,!0)}catch(e){g.cert=null,g.asn1=i}};break;default:var y;throw(y=new Error("Unsupported PKCS#12 SafeBag type.")).oid=g.type,y}if(void 0!==f&&!t.validate(m,f,l,d))throw(y=new Error("Cannot read PKCS#12 "+f.name)).errors=d,y;h()}return a}function p(e){var n={};if(void 0!==e)for(var i=0;i<e.length;++i){var a={},o=[];if(!t.validate(e[i],s,a,o)){var c=new Error("Cannot read PKCS#12 BagAttribute.");throw c.errors=o,c}var u=t.derToOid(a.oid);if(void 0!==r.oids[u]){n[r.oids[u]]=[];for(var l=0;l<a.values.length;++l)n[r.oids[u]].push(a.values[l].value)}}return n}n.pkcs12FromAsn1=function(e,o,s){"string"==typeof o?(s=o,o=!0):void 0===o&&(o=!0);var c={};if(!t.validate(e,a,c,[]))throw(p=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.")).errors=p,p;var p,h={version:c.version.charCodeAt(0),safeContents:[],getBags:function(e){var t,r={};return"localKeyId"in e?t=e.localKeyId:"localKeyIdHex"in e&&(t=F.util.hexToBytes(e.localKeyIdHex)),void 0===t&&!("friendlyName"in e)&&"bagType"in e&&(r[e.bagType]=u(h.safeContents,null,null,e.bagType)),void 0!==t&&(r.localKeyId=u(h.safeContents,"localKeyId",t,e.bagType)),"friendlyName"in e&&(r.friendlyName=u(h.safeContents,"friendlyName",e.friendlyName,e.bagType)),r},getBagsByFriendlyName:function(e,t){return u(h.safeContents,"friendlyName",e,t)},getBagsByLocalKeyId:function(e,t){return u(h.safeContents,"localKeyId",e,t)}};if(3!==c.version.charCodeAt(0))throw(p=new Error("PKCS#12 PFX of version other than 3 not supported.")).version=c.version.charCodeAt(0),p;if(t.derToOid(c.contentType)!==r.oids.data)throw(p=new Error("Only PKCS#12 PFX in password integrity mode supported.")).oid=t.derToOid(c.contentType),p;var g=c.content.value[0];if(g.tagClass!==t.Class.UNIVERSAL||g.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(g=l(g),c.mac){var m=null,y=0,v=t.derToOid(c.macAlgorithm);switch(v){case r.oids.sha1:m=F.md.sha1.create(),y=20;break;case r.oids.sha256:m=F.md.sha256.create(),y=32;break;case r.oids.sha384:m=F.md.sha384.create(),y=48;break;case r.oids.sha512:m=F.md.sha512.create(),y=64;break;case r.oids.md5:m=F.md.md5.create(),y=16}if(null===m)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+v);var b=new F.util.ByteBuffer(c.macSalt),C="macIterations"in c?parseInt(F.util.bytesToHex(c.macIterations),16):1,E=n.generateKey(s,b,3,C,y,m),w=F.hmac.create();if(w.start(m,E),w.update(g.value),w.getMac().getBytes()!==c.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return function(e,n,a,o){if((n=t.fromDer(n,a)).tagClass!==t.Class.UNIVERSAL||n.type!==t.Type.SEQUENCE||!0!==n.constructed)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var s=0;s<n.value.length;s++){var c=n.value[s],u={},p=[];if(!t.validate(c,i,u,p))throw(y=new Error("Cannot read ContentInfo.")).errors=p,y;var h={encrypted:!1},g=null,m=u.content.value[0];switch(t.derToOid(u.contentType)){case r.oids.data:if(m.tagClass!==t.Class.UNIVERSAL||m.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");g=l(m).value;break;case r.oids.encryptedData:g=d(m,o),h.encrypted=!0;break;default:var y;throw(y=new Error("Unsupported PKCS#12 contentType.")).contentType=t.derToOid(u.contentType),y}h.safeBags=f(g,a,o),e.safeContents.push(h)}}(h,g.value,o,s),h},n.toPkcs12Asn1=function(e,i,a,o){(o=o||{}).saltSize=o.saltSize||8,o.count=o.count||2048,o.algorithm=o.algorithm||o.encAlgorithm||"aes128","useMac"in o||(o.useMac=!0),"localKeyId"in o||(o.localKeyId=null),"generateLocalKeyId"in o||(o.generateLocalKeyId=!0);var s,c=o.localKeyId;if(null!==c)c=F.util.hexToBytes(c);else if(o.generateLocalKeyId)if(i){var u=F.util.isArray(i)?i[0]:i;"string"==typeof u&&(u=r.certificateFromPem(u)),(T=F.md.sha1.create()).update(t.toDer(r.certificateToAsn1(u)).getBytes()),c=T.digest().getBytes()}else c=F.random.getBytes(20);var l=[];null!==c&&l.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.localKeyId).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,c)])])),"friendlyName"in o&&l.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.friendlyName).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.BMPSTRING,!1,o.friendlyName)])])),l.length>0&&(s=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,l));var d=[],f=[];null!==i&&(f=F.util.isArray(i)?i:[i]);for(var p=[],h=0;h<f.length;++h){"string"==typeof(i=f[h])&&(i=r.certificateFromPem(i));var g=0===h?s:void 0,m=r.certificateToAsn1(i),y=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.certBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.x509Certificate).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(m).getBytes())])])]),g]);p.push(y)}if(p.length>0){var v=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,p),b=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(v).getBytes())])]);d.push(b)}var C=null;if(null!==e){var E=r.wrapRsaPrivateKey(r.privateKeyToAsn1(e));C=null===a?t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.keyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[E]),s]):t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.pkcs8ShroudedKeyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[r.encryptPrivateKeyInfo(E,a,o)]),s]);var w=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[C]),k=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(w).getBytes())])]);d.push(k)}var S,B=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,d);if(o.useMac){var T=F.md.sha1.create(),A=new F.util.ByteBuffer(F.random.getBytes(o.saltSize)),I=o.count,_=(e=n.generateKey(a,A,3,I,20),F.hmac.create());_.start(T,e),_.update(t.toDer(B).getBytes());var x=_.getMac();S=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.sha1).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,x.getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,A.getBytes()),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(I).getBytes())])}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(3).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(B).getBytes())])]),S])},n.generateKey=F.pbe.generatePkcs12Key})),E((function(e){var t=F.asn1,r=e.exports=F.pki=F.pki||{};r.pemToDer=function(e){var t=F.pem.decode(e)[0];if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert PEM to DER; PEM is encrypted.");return F.util.createBuffer(t.body)},r.privateKeyFromPem=function(e){var n=F.pem.decode(e)[0];if("PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type){var i=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert private key from PEM; PEM is encrypted.");var a=t.fromDer(n.body);return r.privateKeyFromAsn1(a)},r.privateKeyToPem=function(e,n){var i={type:"RSA PRIVATE KEY",body:t.toDer(r.privateKeyToAsn1(e)).getBytes()};return F.pem.encode(i,{maxline:n})},r.privateKeyInfoToPem=function(e,r){var n={type:"PRIVATE KEY",body:t.toDer(e).getBytes()};return F.pem.encode(n,{maxline:r})}}));var St=function(e,t,r,n){var i=F.util.createBuffer(),a=e.length>>1,o=a+(1&e.length),s=e.substr(0,o),c=e.substr(a,o),u=F.util.createBuffer(),l=F.hmac.create();r=t+r;var d=Math.ceil(n/16),f=Math.ceil(n/20);l.start("MD5",s);var p=F.util.createBuffer();u.putBytes(r);for(var h=0;h<d;++h)l.start(null,null),l.update(u.getBytes()),u.putBuffer(l.digest()),l.start(null,null),l.update(u.bytes()+r),p.putBuffer(l.digest());l.start("SHA1",c);var g=F.util.createBuffer();for(u.clear(),u.putBytes(r),h=0;h<f;++h)l.start(null,null),l.update(u.getBytes()),u.putBuffer(l.digest()),l.start(null,null),l.update(u.bytes()+r),g.putBuffer(l.digest());return i.putBytes(F.util.xorBytes(p.getBytes(),g.getBytes(),n)),i},Bt=function(e,t,r){var n=!1;try{var i=e.deflate(t.fragment.getBytes());t.fragment=F.util.createBuffer(i),t.length=i.length,n=!0}catch(e){}return n},Tt=function(e,t,r){var n=!1;try{var i=e.inflate(t.fragment.getBytes());t.fragment=F.util.createBuffer(i),t.length=i.length,n=!0}catch(e){}return n},At=function(e,t){var r=0;switch(t){case 1:r=e.getByte();break;case 2:r=e.getInt16();break;case 3:r=e.getInt24();break;case 4:r=e.getInt32()}return F.util.createBuffer(e.getBytes(r))},It=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},_t={Versions:{TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}}};_t.SupportedVersions=[_t.Versions.TLS_1_1,_t.Versions.TLS_1_0],_t.Version=_t.SupportedVersions[0],_t.MaxFragment=15360,_t.ConnectionEnd={server:0,client:1},_t.PRFAlgorithm={tls_prf_sha256:0},_t.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},_t.CipherType={stream:0,block:1,aead:2},_t.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},_t.CompressionMethod={none:0,deflate:1},_t.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},_t.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},_t.Alert={},_t.Alert.Level={warning:1,fatal:2},_t.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,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},_t.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},_t.CipherSuites={},_t.getCipherSuite=function(e){var t=null;for(var r in _t.CipherSuites){var n=_t.CipherSuites[r];if(n.id[0]===e.charCodeAt(0)&&n.id[1]===e.charCodeAt(1)){t=n;break}}return t},_t.handleUnexpected=function(e,t){!e.open&&e.entity===_t.ConnectionEnd.client||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unexpected_message}})},_t.handleHelloRequest=function(e,t,r){!e.handshaking&&e.handshakes>0&&(_t.queue(e,_t.createAlert(e,{level:_t.Alert.Level.warning,description:_t.Alert.Description.no_renegotiation})),_t.flush(e)),e.process()},_t.parseHelloMessage=function(e,t,r){var n=null,i=e.entity===_t.ConnectionEnd.client;if(r<38)e.error(e,{message:i?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});else{var a=t.fragment,o=a.length();if(n={version:{major:a.getByte(),minor:a.getByte()},random:F.util.createBuffer(a.getBytes(32)),session_id:At(a,1),extensions:[]},i?(n.cipher_suite=a.getBytes(2),n.compression_method=a.getByte()):(n.cipher_suites=At(a,2),n.compression_methods=At(a,1)),(o=r-(o-a.length()))>0){for(var s=At(a,2);s.length()>0;)n.extensions.push({type:[s.getByte(),s.getByte()],data:At(s,2)});if(!i)for(var c=0;c<n.extensions.length;++c){var u=n.extensions[c];if(0===u.type[0]&&0===u.type[1])for(var l=At(u.data,2);l.length()>0&&0===l.getByte();)e.session.extensions.server_name.serverNameList.push(At(l,2).getBytes())}}if(e.session.version&&(n.version.major!==e.session.version.major||n.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}});if(i)e.session.cipherSuite=_t.getCipherSuite(n.cipher_suite);else for(var d=F.util.createBuffer(n.cipher_suites.bytes());d.length()>0&&(e.session.cipherSuite=_t.getCipherSuite(d.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.handshake_failure},cipherSuite:F.util.bytesToHex(n.cipher_suite)});e.session.compressionMethod=i?n.compression_method:_t.CompressionMethod.none}return n},_t.createSecurityParameters=function(e,t){var r=e.entity===_t.ConnectionEnd.client,n=t.random.bytes(),i=r?e.session.sp.client_random:n,a=r?n:_t.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:_t.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:i,server_random:a}},_t.handleServerHello=function(e,t,r){var n=_t.parseHelloMessage(e,t,r);if(!e.fail){if(!(n.version.minor<=e.version.minor))return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}});e.version.minor=n.version.minor,e.session.version=e.version;var i=n.session_id.bytes();i.length>0&&i===e.session.id?(e.expect=Ot,e.session.resuming=!0,e.session.sp.server_random=n.random.bytes()):(e.expect=xt,e.session.resuming=!1,_t.createSecurityParameters(e,n)),e.session.id=i,e.process()}},_t.handleClientHello=function(e,t,r){var n=_t.parseHelloMessage(e,t,r);if(!e.fail){var i=n.session_id.bytes(),a=null;if(e.sessionCache&&(null===(a=e.sessionCache.getSession(i))?i="":(a.version.major!==n.version.major||a.version.minor>n.version.minor)&&(a=null,i="")),0===i.length&&(i=F.random.getBytes(32)),e.session.id=i,e.session.clientHelloVersion=n.version,e.session.sp={},a)e.version=e.session.version=a.version,e.session.sp=a.sp;else{for(var o,s=1;s<_t.SupportedVersions.length&&!((o=_t.SupportedVersions[s]).minor<=n.version.minor);++s);e.version={major:o.major,minor:o.minor},e.session.version=e.version}null!==a?(e.expect=Ft,e.session.resuming=!0,e.session.sp.client_random=n.random.bytes()):(e.expect=!1!==e.verifyClient?Mt:Vt,e.session.resuming=!1,_t.createSecurityParameters(e,n)),e.open=!0,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerHello(e)})),e.session.resuming?(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.pending=_t.createConnectionState(e),e.state.current.write=e.state.pending.write,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)}))):(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificate(e)})),e.fail||(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerKeyExchange(e)})),!1!==e.verifyClient&&_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificateRequest(e)})),_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerHelloDone(e)})))),_t.flush(e),e.process()}},_t.handleCertificate=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n,i,a=t.fragment,o={certificate_list:At(a,3)},s=[];try{for(;o.certificate_list.length()>0;)n=At(o.certificate_list,3),i=F.asn1.fromDer(n),n=F.pki.certificateFromAsn1(i,!0),s.push(n)}catch(t){return e.error(e,{message:"Could not parse certificate list.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate}})}var c=e.entity===_t.ConnectionEnd.client;!c&&!0!==e.verifyClient||0!==s.length?0===s.length?e.expect=c?Pt:Vt:(c?e.session.serverCertificate=s[0]:e.session.clientCertificate=s[0],_t.verifyCertificateChain(e,s)&&(e.expect=c?Pt:Vt)):e.error(e,{message:c?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}}),e.process()},_t.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unsupported_certificate}});e.expect=Rt,e.process()},_t.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unsupported_certificate}});var n=t.fragment,i={enc_pre_master_secret:At(n,2).getBytes()},a=null;if(e.getPrivateKey)try{a=e.getPrivateKey(e,e.session.serverCertificate),a=F.pki.privateKeyFromPem(a)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}})}if(null===a)return e.error(e,{message:"No private key set.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}});try{var o=e.session.sp;o.pre_master_secret=a.decrypt(i.enc_pre_master_secret);var s=e.session.clientHelloVersion;if(s.major!==o.pre_master_secret.charCodeAt(0)||s.minor!==o.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){o.pre_master_secret=F.random.getBytes(48)}e.expect=Ft,null!==e.session.clientCertificate&&(e.expect=jt),e.process()},_t.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n=t.fragment,i={certificate_types:At(n,1),certificate_authorities:At(n,2)};e.session.certificateRequest=i,e.expect=Nt,e.process()},_t.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var a={signature:At(n,2).getBytes()},o=F.util.createBuffer();o.putBuffer(e.session.md5.digest()),o.putBuffer(e.session.sha1.digest()),o=o.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(o,a.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(i),e.session.sha1.update(i)}catch(t){return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.handshake_failure}})}e.expect=Ft,e.process()},_t.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.record_overflow}});if(null===e.serverCertificate){var n={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.insufficient_security}},i=e.verify(e,n.alert.description,0,[]);if(!0!==i)return(i||0===i)&&("object"!=typeof i||F.util.isArray(i)?"number"==typeof i&&(n.alert.description=i):(i.message&&(n.message=i.message),i.alert&&(n.alert.description=i.alert))),e.error(e,n)}null!==e.session.certificateRequest&&(t=_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificate(e)}),_t.queue(e,t)),t=_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createClientKeyExchange(e)}),_t.queue(e,t),e.expect=Ut;var a=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificateVerify(e,t)})),_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.pending=_t.createConnectionState(e),e.state.current.write=e.state.pending.write,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)})),e.expect=Ot,_t.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return a(e,null);_t.getClientSignature(e,a)},_t.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var r=e.entity===_t.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=_t.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?Lt:zt,e.process()},_t.handleFinished=function(e,t,r){var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var a=t.fragment.getBytes();(n=F.util.createBuffer()).putBuffer(e.session.md5.digest()),n.putBuffer(e.session.sha1.digest());var o=e.entity===_t.ConnectionEnd.client,s=o?"server finished":"client finished",c=e.session.sp;if((n=St(c.master_secret,s,n.getBytes(),12)).getBytes()!==a)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.decrypt_error}});e.session.md5.update(i),e.session.sha1.update(i),(e.session.resuming&&o||!e.session.resuming&&!o)&&(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)}))),e.expect=o?Dt:Kt,e.handshaking=!1,++e.handshakes,e.peerCertificate=o?e.session.serverCertificate:e.session.clientCertificate,_t.flush(e),e.isConnected=!0,e.connected(e),e.process()},_t.handleAlert=function(e,t){var r,n=t.fragment,i={level:n.getByte(),description:n.getByte()};switch(i.description){case _t.Alert.Description.close_notify:r="Connection closed.";break;case _t.Alert.Description.unexpected_message:r="Unexpected message.";break;case _t.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case _t.Alert.Description.decryption_failed:r="Decryption failed.";break;case _t.Alert.Description.record_overflow:r="Record overflow.";break;case _t.Alert.Description.decompression_failure:r="Decompression failed.";break;case _t.Alert.Description.handshake_failure:r="Handshake failure.";break;case _t.Alert.Description.bad_certificate:r="Bad certificate.";break;case _t.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case _t.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case _t.Alert.Description.certificate_expired:r="Certificate expired.";break;case _t.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case _t.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case _t.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case _t.Alert.Description.access_denied:r="Access denied.";break;case _t.Alert.Description.decode_error:r="Decode error.";break;case _t.Alert.Description.decrypt_error:r="Decrypt error.";break;case _t.Alert.Description.export_restriction:r="Export restriction.";break;case _t.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case _t.Alert.Description.insufficient_security:r="Insufficient security.";break;case _t.Alert.Description.internal_error:r="Internal error.";break;case _t.Alert.Description.user_canceled:r="User canceled.";break;case _t.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(i.description===_t.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===_t.ConnectionEnd.client?"server":"client",alert:i}),e.process()},_t.handleHandshake=function(e,t){var r=t.fragment,n=r.getByte(),i=r.getInt24();if(i>r.length())return e.fragmented=t,t.fragment=F.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var a=r.bytes(i+4);r.read+=4,n in ir[e.entity][e.expect]?(e.entity!==_t.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:F.md.md5.create(),sha1:F.md.sha1.create()}),n!==_t.HandshakeType.hello_request&&n!==_t.HandshakeType.certificate_verify&&n!==_t.HandshakeType.finished&&(e.session.md5.update(a),e.session.sha1.update(a)),ir[e.entity][e.expect][n](e,t,i)):_t.handleUnexpected(e,t)},_t.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},_t.handleHeartbeat=function(e,t){var r=t.fragment,n=r.getByte(),i=r.getInt16(),a=r.getBytes(i);if(n===_t.HeartbeatMessageType.heartbeat_request){if(e.handshaking||i>a.length)return e.process();_t.queue(e,_t.createRecord(e,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_response,a)})),_t.flush(e)}else if(n===_t.HeartbeatMessageType.heartbeat_response){if(a!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,F.util.createBuffer(a))}e.process()};var xt=1,Pt=2,Rt=3,Nt=4,Ot=5,Lt=6,Dt=7,Ut=8,Mt=1,Vt=2,jt=3,Ft=4,zt=5,Kt=6,qt=_t.handleUnexpected,Ht=_t.handleChangeCipherSpec,Gt=_t.handleAlert,Qt=_t.handleHandshake,Wt=_t.handleApplicationData,Xt=_t.handleHeartbeat,Yt=[];Yt[_t.ConnectionEnd.client]=[[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[Ht,Gt,qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,Wt,Xt],[qt,Gt,Qt,qt,Xt]],Yt[_t.ConnectionEnd.server]=[[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[Ht,Gt,qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,Wt,Xt],[qt,Gt,Qt,qt,Xt]];var $t=_t.handleHelloRequest,Zt=_t.handleServerHello,Jt=_t.handleCertificate,er=_t.handleServerKeyExchange,tr=_t.handleCertificateRequest,rr=_t.handleServerHelloDone,nr=_t.handleFinished,ir=[];ir[_t.ConnectionEnd.client]=[[qt,qt,Zt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,Jt,er,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,er,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,nr],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt]];var ar=_t.handleClientHello,or=_t.handleClientKeyExchange,sr=_t.handleCertificateVerify;ir[_t.ConnectionEnd.server]=[[qt,ar,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,Jt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,or,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,sr,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,nr],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt]],_t.generateKeys=function(e,t){var r=St,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var i=2*t.mac_key_length+2*t.enc_key_length,a=e.version.major===_t.Versions.TLS_1_0.major&&e.version.minor===_t.Versions.TLS_1_0.minor;a&&(i+=2*t.fixed_iv_length);var o=r(t.master_secret,"key expansion",n,i),s={client_write_MAC_key:o.getBytes(t.mac_key_length),server_write_MAC_key:o.getBytes(t.mac_key_length),client_write_key:o.getBytes(t.enc_key_length),server_write_key:o.getBytes(t.enc_key_length)};return a&&(s.client_write_IV=o.getBytes(t.fixed_iv_length),s.server_write_IV=o.getBytes(t.fixed_iv_length)),s},_t.createConnectionState=function(e){var t=e.entity===_t.ConnectionEnd.client,r=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},n={read:r(),write:r()};if(n.read.update=function(e,t){return n.read.cipherFunction(t,n.read)?n.read.compressFunction(e,t,n.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_record_mac}}),!e.fail},n.write.update=function(e,t){return n.write.compressFunction(e,t,n.write)?n.write.cipherFunction(t,n.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}),!e.fail},e.session){var i=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(i),i.keys=_t.generateKeys(e,i),n.read.macKey=t?i.keys.server_write_MAC_key:i.keys.client_write_MAC_key,n.write.macKey=t?i.keys.client_write_MAC_key:i.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(n,e,i),i.compression_algorithm){case _t.CompressionMethod.none:break;case _t.CompressionMethod.deflate:n.read.compressFunction=Tt,n.write.compressFunction=Bt;break;default:throw new Error("Unsupported compression algorithm.")}}return n},_t.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),r=F.util.createBuffer();return r.putInt32(t),r.putBytes(F.random.getBytes(28)),r},_t.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},_t.createAlert=function(e,t){var r=F.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),_t.createRecord(e,{type:_t.ContentType.alert,data:r})},_t.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=F.util.createBuffer(),r=0;r<e.cipherSuites.length;++r){var n=e.cipherSuites[r];t.putByte(n.id[0]),t.putByte(n.id[1])}var i=t.length(),a=F.util.createBuffer();a.putByte(_t.CompressionMethod.none);var o=a.length(),s=F.util.createBuffer();if(e.virtualHost){var c=F.util.createBuffer();c.putByte(0),c.putByte(0);var u=F.util.createBuffer();u.putByte(0),It(u,2,F.util.createBuffer(e.virtualHost));var l=F.util.createBuffer();It(l,2,u),It(c,2,l),s.putBuffer(c)}var d=s.length();d>0&&(d+=2);var f=e.session.id,p=f.length+1+2+4+28+2+i+1+o+d,h=F.util.createBuffer();return h.putByte(_t.HandshakeType.client_hello),h.putInt24(p),h.putByte(e.version.major),h.putByte(e.version.minor),h.putBytes(e.session.sp.client_random),It(h,1,F.util.createBuffer(f)),It(h,2,t),It(h,1,a),d>0&&It(h,2,s),h},_t.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,n=F.util.createBuffer();return n.putByte(_t.HandshakeType.server_hello),n.putInt24(r),n.putByte(e.version.major),n.putByte(e.version.minor),n.putBytes(e.session.sp.server_random),It(n,1,F.util.createBuffer(t)),n.putByte(e.session.cipherSuite.id[0]),n.putByte(e.session.cipherSuite.id[1]),n.putByte(e.session.compressionMethod),n},_t.createCertificate=function(e){var t,r=e.entity===_t.ConnectionEnd.client,n=null;e.getCertificate&&(t=r?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,n=e.getCertificate(e,t));var i=F.util.createBuffer();if(null!==n)try{F.util.isArray(n)||(n=[n]);for(var a=null,o=0;o<n.length;++o){var s=F.pem.decode(n[o])[0];if("CERTIFICATE"!==s.type&&"X509 CERTIFICATE"!==s.type&&"TRUSTED CERTIFICATE"!==s.type){var c=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw c.headerType=s.type,c}if(s.procType&&"ENCRYPTED"===s.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var u=F.util.createBuffer(s.body);null===a&&(a=F.asn1.fromDer(u.bytes(),!1));var l=F.util.createBuffer();It(l,3,u),i.putBuffer(l)}n=F.pki.certificateFromAsn1(a),r?e.session.clientCertificate=n:e.session.serverCertificate=n}catch(t){return e.error(e,{message:"Could not send certificate list.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate}})}var d=3+i.length(),f=F.util.createBuffer();return f.putByte(_t.HandshakeType.certificate),f.putInt24(d),It(f,3,i),f},_t.createClientKeyExchange=function(e){var t=F.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(F.random.getBytes(46));var r=e.session.sp;r.pre_master_secret=t.getBytes();var n=(t=e.session.serverCertificate.publicKey.encrypt(r.pre_master_secret)).length+2,i=F.util.createBuffer();return i.putByte(_t.HandshakeType.client_key_exchange),i.putInt24(n),i.putInt16(t.length),i.putBytes(t),i},_t.createServerKeyExchange=function(e){return F.util.createBuffer()},_t.getClientSignature=function(e,t){var r=F.util.createBuffer();r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest()),r=r.getBytes(),e.getSignature=e.getSignature||function(e,t,r){var n=null;if(e.getPrivateKey)try{n=e.getPrivateKey(e,e.session.clientCertificate),n=F.pki.privateKeyFromPem(n)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}})}null===n?e.error(e,{message:"No private key set.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}):t=n.sign(t,null),r(e,t)},e.getSignature(e,r,t)},_t.createCertificateVerify=function(e,t){var r=t.length+2,n=F.util.createBuffer();return n.putByte(_t.HandshakeType.certificate_verify),n.putInt24(r),n.putInt16(t.length),n.putBytes(t),n},_t.createCertificateRequest=function(e){var t=F.util.createBuffer();t.putByte(1);var r=F.util.createBuffer();for(var n in e.caStore.certs){var i=e.caStore.certs[n],a=F.pki.distinguishedNameToAsn1(i.subject),o=F.asn1.toDer(a);r.putInt16(o.length()),r.putBuffer(o)}var s=1+t.length()+2+r.length(),c=F.util.createBuffer();return c.putByte(_t.HandshakeType.certificate_request),c.putInt24(s),It(c,1,t),It(c,2,r),c},_t.createServerHelloDone=function(e){var t=F.util.createBuffer();return t.putByte(_t.HandshakeType.server_hello_done),t.putInt24(0),t},_t.createChangeCipherSpec=function(){var e=F.util.createBuffer();return e.putByte(1),e},_t.createFinished=function(e){var t=F.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var r=e.entity===_t.ConnectionEnd.client,n=e.session.sp,i=r?"client finished":"server finished";t=St(n.master_secret,i,t.getBytes(),12);var a=F.util.createBuffer();return a.putByte(_t.HandshakeType.finished),a.putInt24(t.length()),a.putBuffer(t),a},_t.createHeartbeat=function(e,t,r){void 0===r&&(r=t.length);var n=F.util.createBuffer();n.putByte(e),n.putInt16(r),n.putBytes(t);var i=n.length(),a=Math.max(16,i-r-3);return n.putBytes(F.random.getBytes(a)),n},_t.queue=function(e,t){if(t&&(0!==t.fragment.length()||t.type!==_t.ContentType.handshake&&t.type!==_t.ContentType.alert&&t.type!==_t.ContentType.change_cipher_spec)){if(t.type===_t.ContentType.handshake){var r=t.fragment.bytes();e.session.md5.update(r),e.session.sha1.update(r),r=null}var n;if(t.fragment.length()<=_t.MaxFragment)n=[t];else{n=[];for(var i=t.fragment.bytes();i.length>_t.MaxFragment;)n.push(_t.createRecord(e,{type:t.type,data:F.util.createBuffer(i.slice(0,_t.MaxFragment))})),i=i.slice(_t.MaxFragment);i.length>0&&n.push(_t.createRecord(e,{type:t.type,data:F.util.createBuffer(i)}))}for(var a=0;a<n.length&&!e.fail;++a){var o=n[a];e.state.current.write.update(e,o)&&e.records.push(o)}}},_t.flush=function(e){for(var t=0;t<e.records.length;++t){var r=e.records[t];e.tlsData.putByte(r.type),e.tlsData.putByte(r.version.major),e.tlsData.putByte(r.version.minor),e.tlsData.putInt16(r.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var cr=function(e){switch(e){case!0:return!0;case F.pki.certificateError.bad_certificate:return _t.Alert.Description.bad_certificate;case F.pki.certificateError.unsupported_certificate:return _t.Alert.Description.unsupported_certificate;case F.pki.certificateError.certificate_revoked:return _t.Alert.Description.certificate_revoked;case F.pki.certificateError.certificate_expired:return _t.Alert.Description.certificate_expired;case F.pki.certificateError.certificate_unknown:return _t.Alert.Description.certificate_unknown;case F.pki.certificateError.unknown_ca:return _t.Alert.Description.unknown_ca;default:return _t.Alert.Description.bad_certificate}};for(var ur in _t.verifyCertificateChain=function(e,t){try{var r={};for(var n in e.verifyOptions)r[n]=e.verifyOptions[n];r.verify=function(t,r,n){cr(t);var i=e.verify(e,t,r,n);if(!0!==i){if("object"==typeof i&&!F.util.isArray(i)){var a=new Error("The application rejected the certificate.");throw a.send=!0,a.alert={level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate},i.message&&(a.message=i.message),i.alert&&(a.alert.description=i.alert),a}i!==t&&(i=function(e){switch(e){case!0:return!0;case _t.Alert.Description.bad_certificate:return F.pki.certificateError.bad_certificate;case _t.Alert.Description.unsupported_certificate:return F.pki.certificateError.unsupported_certificate;case _t.Alert.Description.certificate_revoked:return F.pki.certificateError.certificate_revoked;case _t.Alert.Description.certificate_expired:return F.pki.certificateError.certificate_expired;case _t.Alert.Description.certificate_unknown:return F.pki.certificateError.certificate_unknown;case _t.Alert.Description.unknown_ca:return F.pki.certificateError.unknown_ca;default:return F.pki.certificateError.bad_certificate}}(i))}return i},F.pki.verifyCertificateChain(e.caStore,t,r)}catch(t){var i=t;("object"!=typeof i||F.util.isArray(i))&&(i={send:!0,alert:{level:_t.Alert.Level.fatal,description:cr(t)}}),"send"in i||(i.send=!0),"alert"in i||(i.alert={level:_t.Alert.Level.fatal,description:cr(i.error)}),e.error(e,i)}return!e.fail},_t.createSessionCache=function(e,t){var r=null;if(e&&e.getSession&&e.setSession&&e.order)r=e;else{for(var n in(r={}).cache=e||{},r.capacity=Math.max(t||100,1),r.order=[],e)r.order.length<=t?r.order.push(n):delete e[n];r.getSession=function(e){var t=null,n=null;if(e?n=F.util.bytesToHex(e):r.order.length>0&&(n=r.order[0]),null!==n&&n in r.cache)for(var i in t=r.cache[n],delete r.cache[n],r.order)if(r.order[i]===n){r.order.splice(i,1);break}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var n=r.order.shift();delete r.cache[n]}n=F.util.bytesToHex(e),r.order.push(n),r.cache[n]=t}}return r},_t.createConnection=function(e){var t=null;t=e.caStore?F.util.isArray(e.caStore)?F.pki.createCaStore(e.caStore):e.caStore:F.pki.createCaStore();var r=e.cipherSuites||null;if(null===r)for(var n in r=[],_t.CipherSuites)r.push(_t.CipherSuites[n]);var i=e.server?_t.ConnectionEnd.server:_t.ConnectionEnd.client,a=e.sessionCache?_t.createSessionCache(e.sessionCache):null,o={version:{major:_t.Version.major,minor:_t.Version.minor},entity:i,sessionId:e.sessionId,caStore:t,sessionCache:a,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,r,n){return t},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:F.util.createBuffer(),tlsData:F.util.createBuffer(),data:F.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,r){r.origin=r.origin||(t.entity===_t.ConnectionEnd.client?"client":"server"),r.send&&(_t.queue(t,_t.createAlert(t,r.alert)),_t.flush(t));var n=!1!==r.fatal;n&&(t.fail=!0),e.error(t,r),n&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){o.version={major:_t.Version.major,minor:_t.Version.minor},o.record=null,o.session=null,o.peerCertificate=null,o.state={pending:null,current:null},o.expect=(_t.ConnectionEnd.client,0),o.fragmented=null,o.records=[],o.open=!1,o.handshakes=0,o.handshaking=!1,o.isConnected=!1,o.fail=!(e||void 0===e),o.input.clear(),o.tlsData.clear(),o.data.clear(),o.state.current=_t.createConnectionState(o)}};return o.reset(),o.handshake=function(e){if(o.entity!==_t.ConnectionEnd.client)o.error(o,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(o.handshaking)o.error(o,{message:"Handshake already in progress.",fatal:!1});else{o.fail&&!o.open&&0===o.handshakes&&(o.fail=!1),o.handshaking=!0;var t=null;(e=e||"").length>0&&(o.sessionCache&&(t=o.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&o.sessionCache&&null!==(t=o.sessionCache.getSession())&&(e=t.id),o.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:F.md.md5.create(),sha1:F.md.sha1.create()},t&&(o.version=t.version,o.session.sp=t.sp),o.session.sp.client_random=_t.createRandom().getBytes(),o.open=!0,_t.queue(o,_t.createRecord(o,{type:_t.ContentType.handshake,data:_t.createClientHello(o)})),_t.flush(o)}},o.process=function(e){var t=0;return e&&o.input.putBytes(e),o.fail||(null!==o.record&&o.record.ready&&o.record.fragment.isEmpty()&&(o.record=null),null===o.record&&(t=function(e){var t=0,r=e.input,n=r.length();if(n<5)t=5-n;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:F.util.createBuffer(),ready:!1};var i=e.record.version.major===e.version.major;i&&e.session&&e.session.version&&(i=e.record.version.minor===e.version.minor),i||e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}})}return t}(o)),o.fail||null===o.record||o.record.ready||(t=function(e){var t=0,r=e.input,n=r.length();return n<e.record.length?t=e.record.length-n:(e.record.fragment.putBytes(r.getBytes(e.record.length)),r.compact(),e.state.current.read.update(e,e.record)&&(null!==e.fragmented&&(e.fragmented.type===e.record.type?(e.fragmented.fragment.putBuffer(e.record.fragment),e.record=e.fragmented):e.error(e,{message:"Invalid fragmented record.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unexpected_message}})),e.record.ready=!0)),t}(o)),!o.fail&&null!==o.record&&o.record.ready&&function(e,t){var r=t.type-_t.ContentType.change_cipher_spec,n=Yt[e.entity][e.expect];r in n?n[r](e,t):_t.handleUnexpected(e,t)}(o,o.record)),t},o.prepare=function(e){return _t.queue(o,_t.createRecord(o,{type:_t.ContentType.application_data,data:F.util.createBuffer(e)})),_t.flush(o)},o.prepareHeartbeatRequest=function(e,t){return e instanceof F.util.ByteBuffer&&(e=e.bytes()),void 0===t&&(t=e.length),o.expectedHeartbeatPayload=e,_t.queue(o,_t.createRecord(o,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_request,e,t)})),_t.flush(o)},o.close=function(e){if(!o.fail&&o.sessionCache&&o.session){var t={id:o.session.id,version:o.session.version,sp:o.session.sp};t.sp.keys=null,o.sessionCache.setSession(t.id,t)}o.open&&(o.open=!1,o.input.clear(),(o.isConnected||o.handshaking)&&(o.isConnected=o.handshaking=!1,_t.queue(o,_t.createAlert(o,{level:_t.Alert.Level.warning,description:_t.Alert.Description.close_notify})),_t.flush(o)),o.closed(o)),o.reset(e)},o},F.tls=F.tls||{},_t)"function"!=typeof _t[ur]&&(F.tls[ur]=_t[ur]);F.tls.prf_tls1=St,F.tls.hmac_sha1=function(e,t,r){var n=F.hmac.create();n.start("SHA1",e);var i=F.util.createBuffer();return i.putInt32(t[0]),i.putInt32(t[1]),i.putByte(r.type),i.putByte(r.version.major),i.putByte(r.version.minor),i.putInt16(r.length),i.putBytes(r.fragment.bytes()),n.update(i.getBytes()),n.digest().getBytes()},F.tls.createSessionCache=_t.createSessionCache,F.tls.createConnection=_t.createConnection,E((function(e){var t=e.exports=F.tls;function r(e,r,i){var a=r.entity===F.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:F.cipher.createDecipher("AES-CBC",a?i.keys.server_write_key:i.keys.client_write_key),iv:a?i.keys.server_write_IV:i.keys.client_write_IV},e.write.cipherState={init:!1,cipher:F.cipher.createCipher("AES-CBC",a?i.keys.client_write_key:i.keys.server_write_key),iv:a?i.keys.client_write_IV:i.keys.server_write_IV},e.read.cipherFunction=o,e.write.cipherFunction=n,e.read.macLength=e.write.macLength=i.mac_length,e.read.macFunction=e.write.macFunction=t.hmac_sha1}function n(e,r){var n,a=!1,o=r.macFunction(r.macKey,r.sequenceNumber,e);e.fragment.putBytes(o),r.updateSequenceNumber(),n=e.version.minor===t.Versions.TLS_1_0.minor?r.cipherState.init?null:r.cipherState.iv:F.random.getBytesSync(16),r.cipherState.init=!0;var s=r.cipherState.cipher;return s.start({iv:n}),e.version.minor>=t.Versions.TLS_1_1.minor&&s.output.putBytes(n),s.update(e.fragment),s.finish(i)&&(e.fragment=s.output,e.length=e.fragment.length(),a=!0),a}function i(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function a(e,t,r){var n=!0;if(r){for(var i=t.length(),a=t.last(),o=i-1-a;o<i-1;++o)n=n&&t.at(o)==a;n&&t.truncate(a+1)}return n}function o(e,r){var n,i=!1;n=e.version.minor===t.Versions.TLS_1_0.minor?r.cipherState.init?null:r.cipherState.iv:e.fragment.getBytes(16),r.cipherState.init=!0;var o=r.cipherState.cipher;o.start({iv:n}),o.update(e.fragment),i=o.finish(a);var s=r.macLength,c=F.random.getBytesSync(s),u=o.output.length();u>=s?(e.fragment=o.output.getBytes(u-s),c=o.output.getBytes(s)):e.fragment=o.output.getBytes(),e.fragment=F.util.createBuffer(e.fragment),e.length=e.fragment.length();var l=r.macFunction(r.macKey,r.sequenceNumber,e);return r.updateSequenceNumber(),function(e,t,r){var n=F.hmac.create();return n.start("SHA1",e),n.update(t),t=n.digest().getBytes(),n.start(null,null),n.update(r),t===(r=n.digest().getBytes())}(r.macKey,c,l)&&i}t.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes,e.cipher_type=t.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=t.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:r},t.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes,e.cipher_type=t.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=t.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:r}})),F.debug=F.debug||{},F.debug.storage={},F.debug.get=function(e,t){var r;return void 0===e?r=F.debug.storage:e in F.debug.storage&&(r=void 0===t?F.debug.storage[e]:F.debug.storage[e][t]),r},F.debug.set=function(e,t,r){e in F.debug.storage||(F.debug.storage[e]={}),F.debug.storage[e][t]=r},F.debug.clear=function(e,t){void 0===e?F.debug.storage={}:e in F.debug.storage&&(void 0===t?delete F.debug.storage[e]:delete F.debug.storage[e][t])},E((function(e){var t=e.exports=F.sha512=F.sha512||{};F.md.sha512=F.md.algorithms.sha512=t;var r=F.sha384=F.sha512.sha384=F.sha512.sha384||{};r.create=function(){return t.create("SHA-384")},F.md.sha384=F.md.algorithms.sha384=r,F.sha512.sha256=F.sha512.sha256||{create:function(){return t.create("SHA-512/256")}},F.md["sha512/256"]=F.md.algorithms["sha512/256"]=F.sha512.sha256,F.sha512.sha224=F.sha512.sha224||{create:function(){return t.create("SHA-512/224")}},F.md["sha512/224"]=F.md.algorithms["sha512/224"]=F.sha512.sha224,t.create=function(e){if(i||(n=String.fromCharCode(128),n+=F.util.fillString(String.fromCharCode(0),128),a=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(o={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],o["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],o["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],o["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],i=!0),void 0===e&&(e="SHA-512"),!(e in o))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=o[e],r=null,c=F.util.createBuffer(),u=new Array(80),l=0;l<80;++l)u[l]=new Array(2);var d=64;switch(e){case"SHA-384":d=48;break;case"SHA-512/256":d=32;break;case"SHA-512/224":d=28}var f={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:d,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){f.messageLength=0,f.fullMessageLength=f.messageLength128=[];for(var e=f.messageLengthSize/4,n=0;n<e;++n)f.fullMessageLength.push(0);for(c=F.util.createBuffer(),r=new Array(t.length),n=0;n<t.length;++n)r[n]=t[n].slice(0);return f}};return f.start(),f.update=function(e,t){"utf8"===t&&(e=F.util.encodeUtf8(e));var n=e.length;f.messageLength+=n,n=[n/4294967296>>>0,n>>>0];for(var i=f.fullMessageLength.length-1;i>=0;--i)f.fullMessageLength[i]+=n[1],n[1]=n[0]+(f.fullMessageLength[i]/4294967296>>>0),f.fullMessageLength[i]=f.fullMessageLength[i]>>>0,n[0]=n[1]/4294967296>>>0;return c.putBytes(e),s(r,u,c),(c.read>2048||0===c.length())&&c.compact(),f},f.digest=function(){var t=F.util.createBuffer();t.putBytes(c.bytes());var i,a=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize&f.blockLength-1;t.putBytes(n.substr(0,f.blockLength-a));for(var o=8*f.fullMessageLength[0],l=0;l<f.fullMessageLength.length-1;++l)o+=(i=8*f.fullMessageLength[l+1])/4294967296>>>0,t.putInt32(o>>>0),o=i>>>0;t.putInt32(o);var d=new Array(r.length);for(l=0;l<r.length;++l)d[l]=r[l].slice(0);s(d,u,t);var p,h=F.util.createBuffer();for(p="SHA-512"===e?d.length:"SHA-384"===e?d.length-2:d.length-4,l=0;l<p;++l)h.putInt32(d[l][0]),l===p-1&&"SHA-512/224"===e||h.putInt32(d[l][1]);return h},f};var n=null,i=!1,a=null,o=null;function s(e,t,r){for(var n,i,o,s,c,u,l,d,f,p,h,g,m,y,v,b,C,E,w,k,S,B,T,A,I,_,x,P,R,N,O,L,D,U=r.length();U>=128;){for(x=0;x<16;++x)t[x][0]=r.getInt32()>>>0,t[x][1]=r.getInt32()>>>0;for(;x<80;++x)n=(((P=(N=t[x-2])[0])>>>19|(R=N[1])<<13)^(R>>>29|P<<3)^P>>>6)>>>0,i=((P<<13|R>>>19)^(R<<3|P>>>29)^(P<<26|R>>>6))>>>0,o=(((P=(L=t[x-15])[0])>>>1|(R=L[1])<<31)^(P>>>8|R<<24)^P>>>7)>>>0,s=((P<<31|R>>>1)^(P<<24|R>>>8)^(P<<25|R>>>7))>>>0,O=t[x-7],D=t[x-16],R=i+O[1]+s+D[1],t[x][0]=n+O[0]+o+D[0]+(R/4294967296>>>0)>>>0,t[x][1]=R>>>0;for(h=e[0][0],g=e[0][1],m=e[1][0],y=e[1][1],v=e[2][0],b=e[2][1],C=e[3][0],E=e[3][1],w=e[4][0],k=e[4][1],S=e[5][0],B=e[5][1],T=e[6][0],A=e[6][1],I=e[7][0],_=e[7][1],x=0;x<80;++x)l=((w>>>14|k<<18)^(w>>>18|k<<14)^(k>>>9|w<<23))>>>0,d=(T^w&(S^T))>>>0,c=((h>>>28|g<<4)^(g>>>2|h<<30)^(g>>>7|h<<25))>>>0,u=((h<<4|g>>>28)^(g<<30|h>>>2)^(g<<25|h>>>7))>>>0,f=(h&m|v&(h^m))>>>0,p=(g&y|b&(g^y))>>>0,R=_+(((w<<18|k>>>14)^(w<<14|k>>>18)^(k<<23|w>>>9))>>>0)+((A^k&(B^A))>>>0)+a[x][1]+t[x][1],n=I+l+d+a[x][0]+t[x][0]+(R/4294967296>>>0)>>>0,i=R>>>0,o=c+f+((R=u+p)/4294967296>>>0)>>>0,s=R>>>0,I=T,_=A,T=S,A=B,S=w,B=k,w=C+n+((R=E+i)/4294967296>>>0)>>>0,k=R>>>0,C=v,E=b,v=m,b=y,m=h,y=g,h=n+o+((R=i+s)/4294967296>>>0)>>>0,g=R>>>0;R=e[0][1]+g,e[0][0]=e[0][0]+h+(R/4294967296>>>0)>>>0,e[0][1]=R>>>0,R=e[1][1]+y,e[1][0]=e[1][0]+m+(R/4294967296>>>0)>>>0,e[1][1]=R>>>0,R=e[2][1]+b,e[2][0]=e[2][0]+v+(R/4294967296>>>0)>>>0,e[2][1]=R>>>0,R=e[3][1]+E,e[3][0]=e[3][0]+C+(R/4294967296>>>0)>>>0,e[3][1]=R>>>0,R=e[4][1]+k,e[4][0]=e[4][0]+w+(R/4294967296>>>0)>>>0,e[4][1]=R>>>0,R=e[5][1]+B,e[5][0]=e[5][0]+S+(R/4294967296>>>0)>>>0,e[5][1]=R>>>0,R=e[6][1]+A,e[6][0]=e[6][0]+T+(R/4294967296>>>0)>>>0,e[6][1]=R>>>0,R=e[7][1]+_,e[7][0]=e[7][0]+I+(R/4294967296>>>0)>>>0,e[7][1]=R>>>0,U-=128}}}));var lr=F.asn1,dr={privateKeyValidator:{name:"PrivateKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:lr.Class.UNIVERSAL,type:lr.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},publicKeyValidator:{name:"SubjectPublicKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:lr.Class.UNIVERSAL,type:lr.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]}},fr=dr.publicKeyValidator,pr=dr.privateKeyValidator;if(void 0===hr)var hr=F.jsbn.BigInteger;var gr=F.util.ByteBuffer,mr="undefined"==typeof Buffer?Uint8Array:Buffer;F.pki=F.pki||{},F.pki.ed25519=F.ed25519=F.ed25519||{};var yr=F.ed25519;function vr(e){var t=e.message;if(t instanceof Uint8Array||t instanceof mr)return t;var r=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),r="binary"}if("string"==typeof t&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof t){if("undefined"!=typeof Buffer)return Buffer.from(t,r);t=new gr(t,r)}else if(!(t instanceof gr))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var n=new mr(t.length()),i=0;i<n.length;++i)n[i]=t.at(i);return n}yr.constants={},yr.constants.PUBLIC_KEY_BYTE_LENGTH=32,yr.constants.PRIVATE_KEY_BYTE_LENGTH=64,yr.constants.SEED_BYTE_LENGTH=32,yr.constants.SIGN_BYTE_LENGTH=64,yr.constants.HASH_BYTE_LENGTH=64,yr.generateKeyPair=function(e){var t=(e=e||{}).seed;if(void 0===t)t=F.random.getBytesSync(yr.constants.SEED_BYTE_LENGTH);else if("string"==typeof t){if(t.length!==yr.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+yr.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=vr({message:t,encoding:"binary"});for(var r=new mr(yr.constants.PUBLIC_KEY_BYTE_LENGTH),n=new mr(yr.constants.PRIVATE_KEY_BYTE_LENGTH),i=0;i<32;++i)n[i]=t[i];return function(e,t){var r,n=[zr(),zr(),zr(),zr()],i=Ar(t,32);for(i[0]&=248,i[31]&=127,i[31]|=64,Mr(n,i),Rr(e,n),r=0;r<32;++r)t[r+32]=e[r]}(r,n),{publicKey:r,privateKey:n}},yr.privateKeyFromAsn1=function(e){var t={},r=[];if(!F.asn1.validate(e,pr,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var i=F.asn1.derToOid(t.privateKeyOid),a=F.oids.EdDSA25519;if(i!==a)throw new Error('Invalid OID "'+i+'"; OID must be "'+a+'".');var o=t.privateKey;return{privateKeyBytes:vr({message:F.asn1.fromDer(o).value,encoding:"binary"})}},yr.publicKeyFromAsn1=function(e){var t={},r=[];if(!F.asn1.validate(e,fr,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var i=F.asn1.derToOid(t.publicKeyOid),a=F.oids.EdDSA25519;if(i!==a)throw new Error('Invalid OID "'+i+'"; OID must be "'+a+'".');var o=t.ed25519PublicKey;if(o.length!==yr.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return vr({message:o,encoding:"binary"})},yr.publicKeyFromPrivateKey=function(e){var t=vr({message:(e=e||{}).privateKey,encoding:"binary"});if(t.length!==yr.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+yr.constants.PRIVATE_KEY_BYTE_LENGTH);for(var r=new mr(yr.constants.PUBLIC_KEY_BYTE_LENGTH),n=0;n<r.length;++n)r[n]=t[32+n];return r},yr.sign=function(e){var t=vr(e=e||{}),r=vr({message:e.privateKey,encoding:"binary"});if(r.length===yr.constants.SEED_BYTE_LENGTH)r=yr.generateKeyPair({seed:r}).privateKey;else if(r.length!==yr.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+yr.constants.SEED_BYTE_LENGTH+" or "+yr.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length);!function(e,t,r,n){var i,a,o=new Float64Array(64),s=[zr(),zr(),zr(),zr()],c=Ar(n,32);for(c[0]&=248,c[31]&=127,c[31]|=64,i=0;i<r;++i)e[64+i]=t[i];for(i=0;i<32;++i)e[32+i]=c[32+i];var u=Ar(e.subarray(32),r+32);for(_r(u),Mr(s,u),Rr(e,s),i=32;i<64;++i)e[i]=n[i];var l=Ar(e,r+64);for(_r(l),i=32;i<64;++i)o[i]=0;for(i=0;i<32;++i)o[i]=u[i];for(i=0;i<32;++i)for(a=0;a<32;a++)o[i+a]+=l[i]*c[a];Ir(e.subarray(32),o)}(n,t,t.length,r);for(var i=new mr(yr.constants.SIGN_BYTE_LENGTH),a=0;a<i.length;++a)i[a]=n[a];return i},yr.verify=function(e){var t=vr(e=e||{});if(void 0===e.signature)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var r=vr({message:e.signature,encoding:"binary"});if(r.length!==yr.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+yr.constants.SIGN_BYTE_LENGTH);var n=vr({message:e.publicKey,encoding:"binary"});if(n.length!==yr.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+yr.constants.PUBLIC_KEY_BYTE_LENGTH);var i,a=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length),o=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length);for(i=0;i<yr.constants.SIGN_BYTE_LENGTH;++i)a[i]=r[i];for(i=0;i<t.length;++i)a[i+yr.constants.SIGN_BYTE_LENGTH]=t[i];return function(e,t,r,n){var i,a=new mr(32),o=[zr(),zr(),zr(),zr()],s=[zr(),zr(),zr(),zr()];if(r<64)return-1;if(function(e,t){var r=zr(),n=zr(),i=zr(),a=zr(),o=zr(),s=zr(),c=zr();return Vr(e[2],Cr),function(e,t){var r;for(r=0;r<16;++r)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),Hr(i,e[1]),Gr(a,i,Er),qr(i,i,e[2]),Kr(a,e[2],a),Hr(o,a),Hr(s,o),Gr(c,s,o),Gr(r,c,i),Gr(r,r,a),function(e,t){var r,n=zr();for(r=0;r<16;++r)n[r]=t[r];for(r=250;r>=0;--r)Hr(n,n),1!==r&&Gr(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(r,r),Gr(r,r,i),Gr(r,r,a),Gr(r,r,a),Gr(e[0],r,a),Hr(n,e[0]),Gr(n,n,a),Or(n,i)&&Gr(e[0],e[0],Tr),Hr(n,e[0]),Gr(n,n,a),Or(n,i)?-1:(Dr(e[0])===t[31]>>7&&qr(e[0],br,e[0]),Gr(e[3],e[0],e[1]),0)}(s,n))return-1;for(i=0;i<r;++i)e[i]=t[i];for(i=0;i<32;++i)e[i+32]=n[i];var c=Ar(e,r);if(_r(c),Ur(o,s,c),Mr(s,t.subarray(32)),xr(o,s),Rr(a,o),r-=64,Lr(t,0,a,0)){for(i=0;i<r;++i)e[i]=0;return-1}for(i=0;i<r;++i)e[i]=t[i+64];return r}(o,a,a.length,n)>=0};var br=zr(),Cr=zr([1]),Er=zr([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),wr=zr([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),kr=zr([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Sr=zr([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Br=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),Tr=zr([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Ar(e,t){var r=F.md.sha512.create(),n=new gr(e);r.update(n.getBytes(t),"binary");var i=r.digest().getBytes();if("undefined"!=typeof Buffer)return Buffer.from(i,"binary");for(var a=new mr(yr.constants.HASH_BYTE_LENGTH),o=0;o<64;++o)a[o]=i.charCodeAt(o);return a}function Ir(e,t){var r,n,i,a;for(n=63;n>=32;--n){for(r=0,i=n-32,a=n-12;i<a;++i)t[i]+=r-16*t[n]*Br[i-(n-32)],r=t[i]+128>>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;++i)t[i]+=r-(t[31]>>4)*Br[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;++i)t[i]-=r*Br[i];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function _r(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;Ir(e,t)}function xr(e,t){var r=zr(),n=zr(),i=zr(),a=zr(),o=zr(),s=zr(),c=zr(),u=zr(),l=zr();qr(r,e[1],e[0]),qr(l,t[1],t[0]),Gr(r,r,l),Kr(n,e[0],e[1]),Kr(l,t[0],t[1]),Gr(n,n,l),Gr(i,e[3],t[3]),Gr(i,i,wr),Gr(a,e[2],t[2]),Kr(a,a,a),qr(o,n,r),qr(s,a,i),Kr(c,a,i),Kr(u,n,r),Gr(e[0],o,s),Gr(e[1],u,c),Gr(e[2],c,s),Gr(e[3],o,u)}function Pr(e,t,r){for(var n=0;n<4;++n)Fr(e[n],t[n],r)}function Rr(e,t){var r=zr(),n=zr(),i=zr();!function(e,t){var r,n=zr();for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)Hr(n,n),2!==r&&4!==r&&Gr(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(i,t[2]),Gr(r,t[0],i),Gr(n,t[1],i),Nr(e,n),e[31]^=Dr(r)<<7}function Nr(e,t){var r,n,i,a=zr(),o=zr();for(r=0;r<16;++r)o[r]=t[r];for(jr(o),jr(o),jr(o),n=0;n<2;++n){for(a[0]=o[0]-65517,r=1;r<15;++r)a[r]=o[r]-65535-(a[r-1]>>16&1),a[r-1]&=65535;a[15]=o[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,Fr(o,a,1-i)}for(r=0;r<16;r++)e[2*r]=255&o[r],e[2*r+1]=o[r]>>8}function Or(e,t){var r=new mr(32),n=new mr(32);return Nr(r,e),Nr(n,t),Lr(r,0,n,0)}function Lr(e,t,r,n){return function(e,t,r,n,i){var a,o=0;for(a=0;a<i;++a)o|=e[t+a]^r[n+a];return(1&o-1>>>8)-1}(e,t,r,n,32)}function Dr(e){var t=new mr(32);return Nr(t,e),1&t[0]}function Ur(e,t,r){var n,i;for(Vr(e[0],br),Vr(e[1],Cr),Vr(e[2],Cr),Vr(e[3],br),i=255;i>=0;--i)Pr(e,t,n=r[i/8|0]>>(7&i)&1),xr(t,e),xr(e,e),Pr(e,t,n)}function Mr(e,t){var r=[zr(),zr(),zr(),zr()];Vr(r[0],kr),Vr(r[1],Sr),Vr(r[2],Cr),Gr(r[3],kr,Sr),Ur(e,r,t)}function Vr(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function jr(e){var t,r,n=1;for(t=0;t<16;++t)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function Fr(e,t,r){for(var n,i=~(r-1),a=0;a<16;++a)n=i&(e[a]^t[a]),e[a]^=n,t[a]^=n}function zr(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;++t)r[t]=e[t];return r}function Kr(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]+r[n]}function qr(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]-r[n]}function Hr(e,t){Gr(e,t,t)}function Gr(e,t,r){var n,i,a=0,o=0,s=0,c=0,u=0,l=0,d=0,f=0,p=0,h=0,g=0,m=0,y=0,v=0,b=0,C=0,E=0,w=0,k=0,S=0,B=0,T=0,A=0,I=0,_=0,x=0,P=0,R=0,N=0,O=0,L=0,D=r[0],U=r[1],M=r[2],V=r[3],j=r[4],F=r[5],z=r[6],K=r[7],q=r[8],H=r[9],G=r[10],Q=r[11],W=r[12],X=r[13],Y=r[14],$=r[15];a+=(n=t[0])*D,o+=n*U,s+=n*M,c+=n*V,u+=n*j,l+=n*F,d+=n*z,f+=n*K,p+=n*q,h+=n*H,g+=n*G,m+=n*Q,y+=n*W,v+=n*X,b+=n*Y,C+=n*$,o+=(n=t[1])*D,s+=n*U,c+=n*M,u+=n*V,l+=n*j,d+=n*F,f+=n*z,p+=n*K,h+=n*q,g+=n*H,m+=n*G,y+=n*Q,v+=n*W,b+=n*X,C+=n*Y,E+=n*$,s+=(n=t[2])*D,c+=n*U,u+=n*M,l+=n*V,d+=n*j,f+=n*F,p+=n*z,h+=n*K,g+=n*q,m+=n*H,y+=n*G,v+=n*Q,b+=n*W,C+=n*X,E+=n*Y,w+=n*$,c+=(n=t[3])*D,u+=n*U,l+=n*M,d+=n*V,f+=n*j,p+=n*F,h+=n*z,g+=n*K,m+=n*q,y+=n*H,v+=n*G,b+=n*Q,C+=n*W,E+=n*X,w+=n*Y,k+=n*$,u+=(n=t[4])*D,l+=n*U,d+=n*M,f+=n*V,p+=n*j,h+=n*F,g+=n*z,m+=n*K,y+=n*q,v+=n*H,b+=n*G,C+=n*Q,E+=n*W,w+=n*X,k+=n*Y,S+=n*$,l+=(n=t[5])*D,d+=n*U,f+=n*M,p+=n*V,h+=n*j,g+=n*F,m+=n*z,y+=n*K,v+=n*q,b+=n*H,C+=n*G,E+=n*Q,w+=n*W,k+=n*X,S+=n*Y,B+=n*$,d+=(n=t[6])*D,f+=n*U,p+=n*M,h+=n*V,g+=n*j,m+=n*F,y+=n*z,v+=n*K,b+=n*q,C+=n*H,E+=n*G,w+=n*Q,k+=n*W,S+=n*X,B+=n*Y,T+=n*$,f+=(n=t[7])*D,p+=n*U,h+=n*M,g+=n*V,m+=n*j,y+=n*F,v+=n*z,b+=n*K,C+=n*q,E+=n*H,w+=n*G,k+=n*Q,S+=n*W,B+=n*X,T+=n*Y,A+=n*$,p+=(n=t[8])*D,h+=n*U,g+=n*M,m+=n*V,y+=n*j,v+=n*F,b+=n*z,C+=n*K,E+=n*q,w+=n*H,k+=n*G,S+=n*Q,B+=n*W,T+=n*X,A+=n*Y,I+=n*$,h+=(n=t[9])*D,g+=n*U,m+=n*M,y+=n*V,v+=n*j,b+=n*F,C+=n*z,E+=n*K,w+=n*q,k+=n*H,S+=n*G,B+=n*Q,T+=n*W,A+=n*X,I+=n*Y,_+=n*$,g+=(n=t[10])*D,m+=n*U,y+=n*M,v+=n*V,b+=n*j,C+=n*F,E+=n*z,w+=n*K,k+=n*q,S+=n*H,B+=n*G,T+=n*Q,A+=n*W,I+=n*X,_+=n*Y,x+=n*$,m+=(n=t[11])*D,y+=n*U,v+=n*M,b+=n*V,C+=n*j,E+=n*F,w+=n*z,k+=n*K,S+=n*q,B+=n*H,T+=n*G,A+=n*Q,I+=n*W,_+=n*X,x+=n*Y,P+=n*$,y+=(n=t[12])*D,v+=n*U,b+=n*M,C+=n*V,E+=n*j,w+=n*F,k+=n*z,S+=n*K,B+=n*q,T+=n*H,A+=n*G,I+=n*Q,_+=n*W,x+=n*X,P+=n*Y,R+=n*$,v+=(n=t[13])*D,b+=n*U,C+=n*M,E+=n*V,w+=n*j,k+=n*F,S+=n*z,B+=n*K,T+=n*q,A+=n*H,I+=n*G,_+=n*Q,x+=n*W,P+=n*X,R+=n*Y,N+=n*$,b+=(n=t[14])*D,C+=n*U,E+=n*M,w+=n*V,k+=n*j,S+=n*F,B+=n*z,T+=n*K,A+=n*q,I+=n*H,_+=n*G,x+=n*Q,P+=n*W,R+=n*X,N+=n*Y,O+=n*$,C+=(n=t[15])*D,o+=38*(w+=n*M),s+=38*(k+=n*V),c+=38*(S+=n*j),u+=38*(B+=n*F),l+=38*(T+=n*z),d+=38*(A+=n*K),f+=38*(I+=n*q),p+=38*(_+=n*H),h+=38*(x+=n*G),g+=38*(P+=n*Q),m+=38*(R+=n*W),y+=38*(N+=n*X),v+=38*(O+=n*Y),b+=38*(L+=n*$),a=(n=(a+=38*(E+=n*U))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),C=(n=C+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=(a+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),C=(n=C+i+65535)-65536*(i=Math.floor(n/65536)),a+=i-1+37*(i-1),e[0]=a,e[1]=o,e[2]=s,e[3]=c,e[4]=u,e[5]=l,e[6]=d,e[7]=f,e[8]=p,e[9]=h,e[10]=g,e[11]=m,e[12]=y,e[13]=v,e[14]=b,e[15]=C}F.kem=F.kem||{};var Qr=F.jsbn.BigInteger;function Wr(e,t,r,n){e.generate=function(e,i){for(var a=new F.util.ByteBuffer,o=Math.ceil(i/n)+r,s=new F.util.ByteBuffer,c=r;c<o;++c){s.putInt32(c),t.start(),t.update(e+s.getBytes());var u=t.digest();a.putBytes(u.getBytes(n))}return a.truncate(a.length()-i),a.getBytes()}}F.kem.rsa={},F.kem.rsa.create=function(e,t){var r=(t=t||{}).prng||F.random;return{encrypt:function(t,n){var i,a=Math.ceil(t.n.bitLength()/8);do{i=new Qr(F.util.bytesToHex(r.getBytesSync(a)),16).mod(t.n)}while(i.compareTo(Qr.ONE)<=0);var o=a-(i=F.util.hexToBytes(i.toString(16))).length;return o>0&&(i=F.util.fillString(String.fromCharCode(0),o)+i),{encapsulation:t.encrypt(i,"NONE"),key:e.generate(i,n)}},decrypt:function(t,r,n){var i=t.decrypt(r,"NONE");return e.generate(i,n)}}},F.kem.kdf1=function(e,t){Wr(this,e,0,t||e.digestLength)},F.kem.kdf2=function(e,t){Wr(this,e,1,t||e.digestLength)},F.log=F.log||{},F.log.levels=["none","error","warning","info","debug","verbose","max"];var Xr={},Yr=[],$r=null;F.log.LEVEL_LOCKED=2,F.log.NO_LEVEL_CHECK=4,F.log.INTERPOLATE=8;for(var Zr=0;Zr<F.log.levels.length;++Zr){var Jr=F.log.levels[Zr];Xr[Jr]={index:Zr,name:Jr.toUpperCase()}}F.log.logMessage=function(e){for(var t=Xr[e.level].index,r=0;r<Yr.length;++r){var n=Yr[r];n.flags&F.log.NO_LEVEL_CHECK?n.f(e):t<=Xr[n.level].index&&n.f(n,e)}},F.log.prepareStandard=function(e){"standard"in e||(e.standard=Xr[e.level].name+" ["+e.category+"] "+e.message)},F.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]||e.arguments),e.full=F.util.format.apply(this,t)}},F.log.prepareStandardFull=function(e){"standardFull"in e||(F.log.prepareStandard(e),e.standardFull=e.standard)};var en=["error","warning","info","debug","verbose"];for(Zr=0;Zr<en.length;++Zr)!function(e){F.log[e]=function(t,r){var n=Array.prototype.slice.call(arguments).slice(2),i={timestamp:new Date,level:e,category:t,message:r,arguments:n};F.log.logMessage(i)}}(en[Zr]);if(F.log.makeLogger=function(e){var t={flags:0,f:e};return F.log.setLevel(t,"none"),t},F.log.setLevel=function(e,t){var r=!1;if(e&&!(e.flags&F.log.LEVEL_LOCKED))for(var n=0;n<F.log.levels.length;++n)if(t==F.log.levels[n]){e.level=t,r=!0;break}return r},F.log.lock=function(e,t){void 0===t||t?e.flags|=F.log.LEVEL_LOCKED:e.flags&=~F.log.LEVEL_LOCKED},F.log.addLogger=function(e){Yr.push(e)},"undefined"!=typeof console&&"log"in console){var tn;if(console.error&&console.warn&&console.info&&console.debug){var rn={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},nn=function(e,t){F.log.prepareStandard(t);var r=rn[t.level],n=[t.standard];n=n.concat(t.arguments.slice()),r.apply(console,n)};tn=F.log.makeLogger(nn)}else nn=function(e,t){F.log.prepareStandardFull(t),console.log(t.standardFull)},tn=F.log.makeLogger(nn);F.log.setLevel(tn,"debug"),F.log.addLogger(tn),$r=tn}else console={log:function(){}};if(null!==$r){var an=F.util.getQueryVariables();"console.level"in an&&F.log.setLevel($r,an["console.level"].slice(-1)[0]),"console.lock"in an&&"true"==an["console.lock"].slice(-1)[0]&&F.log.lock($r)}F.log.consoleLogger=$r,E((function(e){var t=F.asn1,r=e.exports=F.pkcs7=F.pkcs7||{};function n(e){var n={},i=[];if(!t.validate(e,r.asn1.recipientInfoValidator,n,i)){var a=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw a.errors=i,a}return{version:n.version.charCodeAt(0),issuer:F.pki.RDNAttributesAsArray(n.issuer),serialNumber:F.util.createBuffer(n.serial).toHex(),encryptedContent:{algorithm:t.derToOid(n.encAlgorithm),parameter:n.encParameter.value,content:n.encKey}}}function i(e){for(var r,n=[],i=0;i<e.length;++i)n.push((r=e[i],t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[F.pki.distinguishedNameToAsn1({attributes:r.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,F.util.hexToBytes(r.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.encryptedContent.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.encryptedContent.content)])));return n}function a(e){var r=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[F.pki.distinguishedNameToAsn1({attributes:e.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,F.util.hexToBytes(e.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.digestAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&r.value.push(e.authenticatedAttributesAsn1),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var n=t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[]),i=0;i<e.unauthenticatedAttributes.length;++i){var a=e.unauthenticatedAttributes[i];n.values.push(o(a))}r.value.push(n)}return r}function o(e){var r;if(e.type===F.pki.oids.contentType)r=t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.value).getBytes());else if(e.type===F.pki.oids.messageDigest)r=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===F.pki.oids.signingTime){var n=new Date("1950-01-01T00:00:00Z"),i=new Date("2050-01-01T00:00:00Z"),a=e.value;if("string"==typeof a){var o=Date.parse(a);a=isNaN(o)?13===a.length?t.utcTimeToDate(a):t.generalizedTimeToDate(a):new Date(o)}r=a>=n&&a<i?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(a)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(a))}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[r])])}function s(e,r,n){var i={};if(!t.validate(r,n,i,[])){var a=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw a.errors=a,a}if(t.derToOid(i.contentType)!==F.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(i.encryptedContent){var o="";if(F.util.isArray(i.encryptedContent))for(var s=0;s<i.encryptedContent.length;++s){if(i.encryptedContent[s].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=i.encryptedContent[s].value}else o=i.encryptedContent;e.encryptedContent={algorithm:t.derToOid(i.encAlgorithm),parameter:F.util.createBuffer(i.encParameter.value),content:F.util.createBuffer(o)}}if(i.content){if(o="",F.util.isArray(i.content))for(s=0;s<i.content.length;++s){if(i.content[s].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=i.content[s].value}else o=i.content;e.content=F.util.createBuffer(o)}return e.version=i.version.charCodeAt(0),e.rawCapture=i,i}function c(e){if(void 0===e.encryptedContent.key)throw new Error("Symmetric key not available.");if(void 0===e.content){var t;switch(e.encryptedContent.algorithm){case F.pki.oids["aes128-CBC"]:case F.pki.oids["aes192-CBC"]:case F.pki.oids["aes256-CBC"]:t=F.aes.createDecryptionCipher(e.encryptedContent.key);break;case F.pki.oids.desCBC:case F.pki.oids["des-EDE3-CBC"]:t=F.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}r.messageFromPem=function(e){var n=F.pem.decode(e)[0];if("PKCS7"!==n.type){var i=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var a=t.fromDer(n.body);return r.messageFromAsn1(a)},r.messageToPem=function(e,r){var n={type:"PKCS7",body:t.toDer(e.toAsn1()).getBytes()};return F.pem.encode(n,{maxline:r})},r.messageFromAsn1=function(e){var n={},i=[];if(!t.validate(e,r.asn1.contentInfoValidator,n,i)){var a=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw a.errors=i,a}var o,s=t.derToOid(n.contentType);switch(s){case F.pki.oids.envelopedData:o=r.createEnvelopedData();break;case F.pki.oids.encryptedData:o=r.createEncryptedData();break;case F.pki.oids.signedData:o=r.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+s+" is not (yet) supported.")}return o.fromAsn1(n.content.value[0]),o},r.createSignedData=function(){var e=null;return e={type:F.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(t){if(s(e,t,r.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var n=e.rawCapture.certificates.value,i=0;i<n.length;++i)e.certificates.push(F.pki.certificateFromAsn1(n[i]))},toAsn1:function(){e.contentInfo||e.sign();for(var r=[],n=0;n<e.certificates.length;++n)r.push(F.pki.certificateToAsn1(e.certificates[n]));var i=[],a=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return r.length>0&&a.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,r)),i.length>0&&a.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,i)),a.value[0].value.push(t.create(t.Class.UNIVERSAL,t.Type.SET,!0,e.signerInfos)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),a])},addSigner:function(t){var r=t.issuer,n=t.serialNumber;if(t.certificate){var i=t.certificate;"string"==typeof i&&(i=F.pki.certificateFromPem(i)),r=i.issuer.attributes,n=i.serialNumber}var a=t.key;if(!a)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof a&&(a=F.pki.privateKeyFromPem(a));var o=t.digestAlgorithm||F.pki.oids.sha1;switch(o){case F.pki.oids.sha1:case F.pki.oids.sha256:case F.pki.oids.sha384:case F.pki.oids.sha512:case F.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+o)}var s=t.authenticatedAttributes||[];if(s.length>0){for(var c=!1,u=!1,l=0;l<s.length;++l){var d=s[l];if(c||d.type!==F.pki.oids.contentType){if(u||d.type!==F.pki.oids.messageDigest);else if(u=!0,c)break}else if(c=!0,u)break}if(!c||!u)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:a,version:1,issuer:r,serialNumber:n,digestAlgorithm:o,signatureAlgorithm:F.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:s,unauthenticatedAttributes:[]})},sign:function(r){var n;r=r||{},("object"!=typeof e.content||null===e.contentInfo)&&(e.contentInfo=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(F.pki.oids.data).getBytes())]),"content"in e&&(e.content instanceof F.util.ByteBuffer?n=e.content.bytes():"string"==typeof e.content&&(n=F.util.encodeUtf8(e.content)),r.detached?e.detachedContent=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n):e.contentInfo.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n)])))),0!==e.signers.length&&function(r){var n;if(!(n=e.detachedContent?e.detachedContent:(n=e.contentInfo.value[1]).value[0]))throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var i=t.derToOid(e.contentInfo.value[0].value),s=t.toDer(n);for(var c in s.getByte(),t.getBerValueLength(s),s=s.getBytes(),r)r[c].start().update(s);for(var u=new Date,l=0;l<e.signers.length;++l){var d=e.signers[l];if(0===d.authenticatedAttributes.length){if(i!==F.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{d.authenticatedAttributesAsn1=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[]),p=0;p<d.authenticatedAttributes.length;++p){var h=d.authenticatedAttributes[p];h.type===F.pki.oids.messageDigest?h.value=r[d.digestAlgorithm].digest():h.type===F.pki.oids.signingTime&&(h.value||(h.value=u)),f.value.push(o(h)),d.authenticatedAttributesAsn1.value.push(o(h))}s=t.toDer(f).getBytes(),d.md.start().update(s)}d.signature=d.key.sign(d.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=function(e){for(var t=[],r=0;r<e.length;++r)t.push(a(e[r]));return t}(e.signers)}(function(){for(var r={},n=0;n<e.signers.length;++n){var i=e.signers[n];(a=i.digestAlgorithm)in r||(r[a]=F.md[F.pki.oids[a]].create()),0===i.authenticatedAttributes.length?i.md=r[a]:i.md=F.md[F.pki.oids[a]].create()}for(var a in e.digestAlgorithmIdentifiers=[],r)e.digestAlgorithmIdentifiers.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(a).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]));return r}())},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(t){"string"==typeof t&&(t=F.pki.certificateFromPem(t)),e.certificates.push(t)},addCertificateRevokationList:function(e){throw new Error("PKCS#7 CRL support not yet implemented.")}}},r.createEncryptedData=function(){var e=null;return e={type:F.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:F.pki.oids["aes256-CBC"]},fromAsn1:function(t){s(e,t,r.asn1.encryptedDataValidator)},decrypt:function(t){void 0!==t&&(e.encryptedContent.key=t),c(e)}}},r.createEnvelopedData=function(){var e=null;return e={type:F.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:F.pki.oids["aes256-CBC"]},fromAsn1:function(t){var i=s(e,t,r.asn1.envelopedDataValidator);e.recipients=function(e){for(var t=[],r=0;r<e.length;++r)t.push(n(e[r]));return t}(i.recipientInfos.value)},toAsn1:function(){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,i(e.recipients)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,(r=e.encryptedContent,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(F.pki.oids.data).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.parameter.getBytes())]),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.content.getBytes())])]))])])]);var r},findRecipient:function(t){for(var r=t.issuer.attributes,n=0;n<e.recipients.length;++n){var i=e.recipients[n],a=i.issuer;if(i.serialNumber===t.serialNumber&&a.length===r.length){for(var o=!0,s=0;s<r.length;++s)if(a[s].type!==r[s].type||a[s].value!==r[s].value){o=!1;break}if(o)return i}}return null},decrypt:function(t,r){if(void 0===e.encryptedContent.key&&void 0!==t&&void 0!==r)switch(t.encryptedContent.algorithm){case F.pki.oids.rsaEncryption:case F.pki.oids.desCBC:var n=r.decrypt(t.encryptedContent.content);e.encryptedContent.key=F.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}c(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:F.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,r){if(void 0===e.encryptedContent.content){var n,i,a;switch(r=r||e.encryptedContent.algorithm,t=t||e.encryptedContent.key,r){case F.pki.oids["aes128-CBC"]:n=16,i=16,a=F.aes.createEncryptionCipher;break;case F.pki.oids["aes192-CBC"]:n=24,i=16,a=F.aes.createEncryptionCipher;break;case F.pki.oids["aes256-CBC"]:n=32,i=16,a=F.aes.createEncryptionCipher;break;case F.pki.oids["des-EDE3-CBC"]:n=24,i=8,a=F.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(void 0===t)t=F.util.createBuffer(F.random.getBytes(n));else if(t.length()!=n)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+n+".");e.encryptedContent.algorithm=r,e.encryptedContent.key=t,e.encryptedContent.parameter=F.util.createBuffer(F.random.getBytes(i));var o=a(t);if(o.start(e.encryptedContent.parameter.copy()),o.update(e.content),!o.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=o.output}for(var s=0;s<e.recipients.length;++s){var c=e.recipients[s];if(void 0===c.encryptedContent.content)switch(c.encryptedContent.algorithm){case F.pki.oids.rsaEncryption:c.encryptedContent.content=c.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+c.encryptedContent.algorithm)}}}}}})),E((function(e){var t=e.exports=F.ssh=F.ssh||{};function r(e,t){var r=t.toString(16);r[0]>="8"&&(r="00"+r);var n=F.util.hexToBytes(r);e.putInt32(n.length),e.putBytes(n)}function n(e,t){e.putInt32(t.length),e.putString(t)}function i(){for(var e=F.md.sha1.create(),t=arguments.length,r=0;r<t;++r)e.update(arguments[r]);return e.digest()}t.privateKeyToPutty=function(e,t,a){var o=""===(t=t||"")?"none":"aes256-cbc",s="PuTTY-User-Key-File-2: ssh-rsa\r\n";s+="Encryption: "+o+"\r\n",s+="Comment: "+(a=a||"")+"\r\n";var c=F.util.createBuffer();n(c,"ssh-rsa"),r(c,e.e),r(c,e.n);var u=F.util.encode64(c.bytes(),64),l=Math.floor(u.length/66)+1;s+="Public-Lines: "+l+"\r\n",s+=u;var d,f=F.util.createBuffer();if(r(f,e.d),r(f,e.p),r(f,e.q),r(f,e.qInv),t){var p=f.length()+16-1;p-=p%16;var h=i(f.bytes());h.truncate(h.length()-p+f.length()),f.putBuffer(h);var g=F.util.createBuffer();g.putBuffer(i("\0\0\0\0",t)),g.putBuffer(i("\0\0\0",t));var m=F.aes.createEncryptionCipher(g.truncate(8),"CBC");m.start(F.util.createBuffer().fillWithByte(0,16)),m.update(f.copy()),m.finish();var y=m.output;y.truncate(16),d=F.util.encode64(y.bytes(),64)}else d=F.util.encode64(f.bytes(),64);s+="\r\nPrivate-Lines: "+(l=Math.floor(d.length/66)+1)+"\r\n",s+=d;var v=i("putty-private-key-file-mac-key",t),b=F.util.createBuffer();n(b,"ssh-rsa"),n(b,o),n(b,a),b.putInt32(c.length()),b.putBuffer(c),b.putInt32(f.length()),b.putBuffer(f);var C=F.hmac.create();return C.start("sha1",v),C.update(b.bytes()),s+"\r\nPrivate-MAC: "+C.digest().toHex()+"\r\n"},t.publicKeyToOpenSSH=function(e,t){t=t||"";var i=F.util.createBuffer();return n(i,"ssh-rsa"),r(i,e.e),r(i,e.n),"ssh-rsa "+F.util.encode64(i.bytes())+" "+t},t.privateKeyToOpenSSH=function(e,t){return t?F.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):F.pki.privateKeyToPem(e)},t.getPublicKeyFingerprint=function(e,t){var i=(t=t||{}).md||F.md.md5.create(),a=F.util.createBuffer();n(a,"ssh-rsa"),r(a,e.e),r(a,e.n),i.start(),i.update(a.getBytes());var o=i.digest();if("hex"===t.encoding){var s=o.toHex();return t.delimiter?s.match(/.{2}/g).join(t.delimiter):s}if("binary"===t.encoding)return o.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".');return o}}));var on="forge.task",sn={},cn=0;F.debug.set(on,"tasks",sn);var un={};F.debug.set(on,"queues",un);var ln="ready",dn="running",fn="blocked",pn="sleeping",hn="done",gn="error",mn={ready:{}};mn.ready.stop=ln,mn.ready.start=dn,mn.ready.cancel=hn,mn.ready.fail=gn,mn.running={},mn.running.stop=ln,mn.running.start=dn,mn.running.block=fn,mn.running.unblock=dn,mn.running.sleep=pn,mn.running.wakeup=dn,mn.running.cancel=hn,mn.running.fail=gn,mn.blocked={},mn.blocked.stop=fn,mn.blocked.start=fn,mn.blocked.block=fn,mn.blocked.unblock=fn,mn.blocked.sleep=fn,mn.blocked.wakeup=fn,mn.blocked.cancel=hn,mn.blocked.fail=gn,mn.sleeping={},mn.sleeping.stop=pn,mn.sleeping.start=pn,mn.sleeping.block=pn,mn.sleeping.unblock=pn,mn.sleeping.sleep=pn,mn.sleeping.wakeup=pn,mn.sleeping.cancel=hn,mn.sleeping.fail=gn,mn.done={},mn.done.stop=hn,mn.done.start=hn,mn.done.block=hn,mn.done.unblock=hn,mn.done.sleep=hn,mn.done.wakeup=hn,mn.done.cancel=hn,mn.done.fail=gn,mn.error={},mn.error.stop=gn,mn.error.start=gn,mn.error.block=gn,mn.error.unblock=gn,mn.error.sleep=gn,mn.error.wakeup=gn,mn.error.cancel=gn,mn.error.fail=gn;var yn=function(e){this.id=-1,this.name=e.name||"?",this.parent=e.parent||null,this.run=e.run,this.subtasks=[],this.error=!1,this.state=ln,this.blocks=0,this.timeoutId=null,this.swapTime=null,this.userData=null,this.id=cn++,sn[this.id]=this};yn.prototype.debug=function(e){e=e||"",F.log.debug(on,e,"[%s][%s] task:",this.id,this.name,this,"subtasks:",this.subtasks.length,"queue:",un)},yn.prototype.next=function(e,t){"function"==typeof e&&(t=e,e=this.name);var r=new yn({run:t,name:e,parent:this});return r.state=dn,r.type=this.type,r.successCallback=this.successCallback||null,r.failureCallback=this.failureCallback||null,this.subtasks.push(r),this},yn.prototype.parallel=function(e,t){return F.util.isArray(e)&&(t=e,e=this.name),this.next(e,(function(r){var n=r;n.block(t.length);for(var i=function(e,r){F.task.start({type:e,run:function(e){t[r](e)},success:function(e){n.unblock()},failure:function(e){n.unblock()}})},a=0;a<t.length;a++)i(e+"__parallel-"+r.id+"-"+a,a)}))},yn.prototype.stop=function(){this.state=mn[this.state].stop},yn.prototype.start=function(){this.error=!1,this.state=mn[this.state].start,this.state===dn&&(this.start=new Date,this.run(this),vn(this,0))},yn.prototype.block=function(e){e=void 0===e?1:e,this.blocks+=e,this.blocks>0&&(this.state=mn[this.state].block)},yn.prototype.unblock=function(e){return e=void 0===e?1:e,this.blocks-=e,0===this.blocks&&this.state!==hn&&(this.state=dn,vn(this,0)),this.blocks},yn.prototype.sleep=function(e){e=void 0===e?0:e,this.state=mn[this.state].sleep;var t=this;this.timeoutId=setTimeout((function(){t.timeoutId=null,t.state=dn,vn(t,0)}),e)},yn.prototype.wait=function(e){e.wait(this)},yn.prototype.wakeup=function(){this.state===pn&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state=dn,vn(this,0))},yn.prototype.cancel=function(){this.state=mn[this.state].cancel,this.permitsNeeded=0,null!==this.timeoutId&&(cancelTimeout(this.timeoutId),this.timeoutId=null),this.subtasks=[]},yn.prototype.fail=function(e){if(this.error=!0,bn(this,!0),e)e.error=this.error,e.swapTime=this.swapTime,e.userData=this.userData,vn(e,0);else{if(null!==this.parent){for(var t=this.parent;null!==t.parent;)t.error=this.error,t.swapTime=this.swapTime,t.userData=this.userData,t=t.parent;bn(t,!0)}this.failureCallback&&this.failureCallback(this)}};var vn=function(e,t){var r=t>30||+new Date-e.swapTime>20,n=function(t){if(t++,e.state===dn)if(r&&(e.swapTime=+new Date),e.subtasks.length>0){var n=e.subtasks.shift();n.error=e.error,n.swapTime=e.swapTime,n.userData=e.userData,n.run(n),n.error||vn(n,t)}else bn(e),e.error||null!==e.parent&&(e.parent.error=e.error,e.parent.swapTime=e.swapTime,e.parent.userData=e.userData,vn(e.parent,t))};r?setTimeout(n,0):n(t)},bn=function(e,t){e.state=hn,delete sn[e.id],null===e.parent&&(e.type in un?0===un[e.type].length?F.log.error(on,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):un[e.type][0]!==e?F.log.error(on,"[%s][%s] task not first in queue [%s]",e.id,e.name,e.type):(un[e.type].shift(),0===un[e.type].length?delete un[e.type]:un[e.type][0].start()):F.log.error(on,"[%s][%s] task queue missing [%s]",e.id,e.name,e.type),t||(e.error&&e.failureCallback?e.failureCallback(e):!e.error&&e.successCallback&&e.successCallback(e)))};F.task=F.task||{},F.task.start=function(e){var t=new yn({run:e.run,name:e.name||"?"});t.type=e.type,t.successCallback=e.success||null,t.failureCallback=e.failure||null,t.type in un?un[e.type].push(t):(un[t.type]=[t],function(e){e.error=!1,e.state=mn[e.state].start,setTimeout((function(){e.state===dn&&(e.swapTime=+new Date,e.run(e),vn(e,0))}),0)}(t))},F.task.cancel=function(e){e in un&&(un[e]=[un[e][0]])},F.task.createCondition=function(){var e={tasks:{},wait:function(t){t.id in e.tasks||(t.block(),e.tasks[t.id]=t)},notify:function(){var t=e.tasks;for(var r in e.tasks={},t)t[r].unblock()}};return e};var Cn=F,En=function(){function e(e){this.secretKey=e}return e.prototype.encrypt=function(e,t){throw new Error("Method not implemented.")},e.prototype.decrypt=function(e,t){return function(e,t,r){void 0===r&&(r=Cn.util.createBuffer(Uint8Array.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer));var n,i,a=Cn.cipher.createDecipher("AES-CBC",t);return a.start({iv:r}),a.update(Cn.util.createBuffer(Cn.util.hexToBytes(e))),i=(n=a.output.data).charCodeAt(n.length-1),n.slice(0,-i)}(e,(r=this.secretKey,n=t.transactionID,""+r.slice(0,16)+n.slice(0,16)));var r,n},e}(),wn=function(){function e(e,t,n,i){void 0===n&&(n="production"),void 0===i&&(i={supportTransaction:!1,enableEncryption:!1}),this.transactionEnabled=i.supportTransaction||!1,this.encryptionEnabled=i.enableEncryption||!1;var a=D(e,t,n,{headers:i.httpHeaders});this.transactionManager=new j(a),this.encryptionService=new En(t),this.compareFaceService=new d(a),this.clientSettingsService=new f(a),this.convertPDFService=new v(a),this.ekycPDFService=new b(a),this.readIDCardService=new r(a),this.requestVerifyIDCardService=new h(a),this.requestVerifyPortraitSerivce=new g(a),this.imagesService=new u(a),this.fileService=new l(a),this.verifyFaceLivenessService=new p(a),this.searchFaceService=new y(a),this.detectIDTamperingService=new m(a),this.httpClient=a}return e.prototype.enableTransaction=function(){this.transactionEnabled=!0},e.prototype.disableTransaction=function(){this.transactionEnabled=!1},e.prototype.enableEncryption=function(){this.encryptionEnabled=!0},e.prototype.disableEncryption=function(){this.encryptionEnabled=!1},e.prototype.compareFaces=function(e,t){return this.compareFaceService.request(e,t)},e.prototype.clientSettings=function(){return this.clientSettingsService.request()},e.prototype.uploadImage=function(e){return this.imagesService.request(e)},e.prototype.uploadFile=function(e){return this.fileService.uploadFile(e)},e.prototype.convertPDF=function(e,t){return this.convertPDFService.request(e,t)},e.prototype.ekycPDF=function(e,t){return this.ekycPDFService.request(e,t)},e.prototype.readIDCard=function(e,t){return this.readIDCardService.request(e,t)},e.prototype.requestVerifyIDCard=function(e,t){return this.requestVerifyIDCardService.request(e,t)},e.prototype.requestVerifyPortrait=function(e,t){return this.requestVerifyPortraitSerivce.request(e,t)},e.prototype.verifyFaceLiveness=function(e,t){return this.verifyFaceLivenessService.request(e,t)},e.prototype.searchFaces=function(e,t){return this.searchFaceService.request(e,t)},e.prototype.deleteFaces=function(e,t){return this.searchFaceService.deleteFaces(e,t)},e.prototype.indexFaces=function(e,t){return this.searchFaceService.indexFaces(e,t)},e.prototype.downloadFaceImage=function(e){return this.searchFaceService.downloadFaceImage(e)},e.prototype.downloadImage=function(e){return this.imagesService.download(e)},e.prototype.updateMetadata=function(e,t){return this.imagesService.updateMetadata(e,t)},e.prototype.detectIDTampering=function(e,t){return this.detectIDTamperingService.request(e,t)},a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"compareFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"convertPDF",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"readIDCard",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"requestVerifyIDCard",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"requestVerifyPortrait",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"verifyFaceLiveness",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"searchFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"deleteFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"indexFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"detectIDTampering",null),e}();e.ReadIDCard=r,e.UploadImage=u,e.UploadFile=l,e.CompareFaces=d,e.ClientSettings=f,e.VerifyFaceLiveness=p,e.RequestVerifyIDCard=h,e.RequestVerifyPortrait=g,e.DetectIDTampering=m,e.SearchFaces=y,e.ConvertPDF=v,e.EkycPDF=b,e.HttpClient=_,e.MockClient=x,e.TVAuthorizer=O,e.createHelpers=function(e,t,r){void 0===r&&(r="production");var n=new O(e,t),i=function(e){switch(e){case"testing":return"https://tv-testing.trustingsocial.com/api";case"staging":return"https://tv-staging.trustingsocial.com/api";case"production":default:return"https://vn-vision.trustingsocial.com/api"}}(r);return new _({authorizer:n,domain:i})},e.createHttpClient=D,e.SimpleTrustVisionAPI=U,e.default=wn,Object.defineProperty(e,"__esModule",{value:!0})}(t,r.default)}))),BY=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,TY=/^\w*$/;var AY=function(e,t){if(nQ(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!qQ(e))||(TY.test(e)||!BY.test(e)||null!=t&&e in Object(t))},IY=IG(Object,"create");var _Y=function(){this.__data__=IY?IY(null):{},this.size=0};var xY=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},PY=Object.prototype.hasOwnProperty;var RY=function(e){var t=this.__data__;if(IY){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return PY.call(t,e)?t[e]:void 0},NY=Object.prototype.hasOwnProperty;var OY=function(e){var t=this.__data__;return IY?void 0!==t[e]:NY.call(t,e)};var LY=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=IY&&void 0===t?"__lodash_hash_undefined__":t,this};function DY(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}DY.prototype.clear=_Y,DY.prototype.delete=xY,DY.prototype.get=RY,DY.prototype.has=OY,DY.prototype.set=LY;var UY=DY;var MY=function(){this.__data__=[],this.size=0};var VY=function(e,t){for(var r=e.length;r--;)if(PG(e[r][0],t))return r;return-1},jY=Array.prototype.splice;var FY=function(e){var t=this.__data__,r=VY(t,e);return!(r<0)&&(r==t.length-1?t.pop():jY.call(t,r,1),--this.size,!0)};var zY=function(e){var t=this.__data__,r=VY(t,e);return r<0?void 0:t[r][1]};var KY=function(e){return VY(this.__data__,e)>-1};var qY=function(e,t){var r=this.__data__,n=VY(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function HY(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}HY.prototype.clear=MY,HY.prototype.delete=FY,HY.prototype.get=zY,HY.prototype.has=KY,HY.prototype.set=qY;var GY=HY,QY=IG(rG,"Map");var WY=function(){this.size=0,this.__data__={hash:new UY,map:new(QY||GY),string:new UY}};var XY=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var YY=function(e,t){var r=e.__data__;return XY(t)?r["string"==typeof t?"string":"hash"]:r.map};var $Y=function(e){var t=YY(this,e).delete(e);return this.size-=t?1:0,t};var ZY=function(e){return YY(this,e).get(e)};var JY=function(e){return YY(this,e).has(e)};var e$=function(e,t){var r=YY(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function t$(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}t$.prototype.clear=WY,t$.prototype.delete=$Y,t$.prototype.get=ZY,t$.prototype.has=JY,t$.prototype.set=e$;var r$=t$;function n$(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var o=e.apply(this,n);return r.cache=a.set(i,o)||a,o};return r.cache=new(n$.Cache||r$),r}n$.Cache=r$;var i$=n$;var a$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,o$=/\\(\\)?/g,s$=function(e){var t=i$(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(a$,(function(e,r,n,i){t.push(n?i.replace(o$,"$1"):r||e)})),t}));var c$=function(e,t){return nQ(e)?e:AY(e,t)?[e]:s$(WQ(e))};var u$=function(e){if("string"==typeof e||qQ(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var l$=function(e,t){for(var r=0,n=(t=c$(t,e)).length;null!=e&&r<n;)e=e[u$(t[r++])];return r&&r==n?e:void 0};var d$,f$,p$,h$,g$,m$,y$,v$,b$,C$,E$,w$,k$,S$=function(e,t,r){var n=null==e?void 0:l$(e,t);return void 0===n?r:n};function B$(e){var t=e.className;return oy.createElement("svg",{className:t,width:"320",height:"320",viewBox:"0 0 320 320",fill:"none",xmlns:"http://www.w3.org/2000/svg"},oy.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M320 0H0V320H320V0ZM160 296C235.111 296 296 235.111 296 160C296 84.8893 235.111 24 160 24C84.8893 24 24 84.8893 24 160C24 235.111 84.8893 296 160 296Z",fill:"currentColor"}))}B$.propTypes={className:Py.string},B$.defaultProps={className:""};var T$=nF.Camera,A$=oz.blink,I$=oz.slide,_$=PH.Text,x$=PH.FaceDetectionError,P$=PH.FaceVerificationInstructions,R$=PH.FaceVerificationStepsWrapper,N$=PH.StepItem,O$=PH.BottomButtonsOverlay,L$=PH.Button,D$=PH.CountDownOverlay,U$=PH.InstructionsOverlay,M$=PH.CountdownTime,V$=eC(JV)(d$||(d$=dm(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"]))),j$=eC(B$)(f$||(f$=dm(["\n width: 100%;\n height: 100%;\n vertical-align: middle;\n margin: 0;\n color: ",";\n"])),(function(e){var t=e.color;return null!=t?t:"rgba(0, 0, 0, 0.6)"})),F$=eC(P$)(p$||(p$=dm(["\n font-size: 18px;\n color: #38383d;\n text-shadow: none;\n font-weight: 600;\n"]))),z$=eC(x$)(h$||(h$=dm(["\n color: #ff424e;\n background-color: unset;\n"]))),K$=eC(U$)(g$||(g$=dm(["\n ",";\n ",";\n"])),I$.default,A$.default),q$=eC(M$)(m$||(m$=dm(["\n background-color: unset;\n color: #ff424e;\n font-size: 18px;\n"]))),H$=eC(N$)(y$||(y$=dm(["\n border-color: #1aa7ff;\n color: #1aa7ff;\n"]))),G$=eC(L$)(v$||(v$=dm(["\n z-index: ",";\n position: absolute;\n top: 20px;\n left: 20px;\n width: 12px;\n"])),1100),Q$=eC(_$)(b$||(b$=dm(["\n position: absolute;\n font-style: normal;\n font-weight: 500;\n font-size: 16px;\n text-align: center;\n padding: 0 1.75rem;\n color: #38383d;\n\n ","\n"])),(function(e){var t=e.top;return t&&Vb(["top:","px;"],t)})),W$=eC.span(C$||(C$=dm(["\n position: absolute;\n bottom: 5px;\n color: #38383d;\n font-size: 14px;\n z-index: ",";\n"])),1020),X$=nC(["from{opacity:1;}to{opacity:0;}"]),Y$=eC.div(E$||(E$=dm(["\n position: absolute;\n width: 100%;\n top: 0;\n bottom: 0;\n z-index: -1;\n background: rgba(255, 255, 255, 0.3);\n animation: "," 1s infinite;\n"])),X$),$$=JH.isMobile?{width:640}:null,Z$={background:"#fff",opacity:1};function J$(e){var t,r,n,i=e.apiCheck,a=e.mode,o=e.onLivenessDetectionDone,s=e.onClose,c=e.onError,u=e.captureFrameSettings,l=e.onFramesCaptured,d=e.frontCamera,f=e.customStepTimeConstraints,p=e.onProcessing,h=e.customErrors,g=e.customMessages,m=e.livenessSettings,y=e.customInstructions,v=e.apiCredentials,b=e.title,C=e.subInstructions,E=uk.useAsset("bg_camera_mask.png"),w=uk.useAsset("bg_camera_mask_red.png"),k=uk.useAsset("ic_close_black.png"),S=fm(oy.useState({}),2),B=S[0],T=S[1],A=B.yFaceVerificationStepsWrapper,I=fm(oy.useState(""),2),_=I[0],x=I[1],P=fm(oy.useState(!1),2),R=P[0],N=P[1],O=oy.useCallback((function(e){var t=e.lostY,r=e.height,n=t+25,i=n+30;return T({yFaceDetectionError:n,yFaceVerificationStepsWrapper:i+r-45*r/350/2-8}),{y:Math.floor(i)}}),[]),L=xH({apiCheck:i,mode:a,bgCameraMask:E,bgCameraMaskRed:w,surroundStyle:Z$,onLivenessDetectionDone:o,onError:c,cropAreaDimension:O,captureFrameSettings:u,onFramesCaptured:l,livenessSettings:m,setRemainingTime:x,customStepTimeConstraints:f,onProcessing:p,customErrors:h,customMessages:g,customInstructions:y,apiCredentials:v}),D=L.countdownToTakePicture,U=L.cropArea,M=L.curStepIndex,V=L.directionIcon,j=L.faceDetectionError,F=L.handleTriggerPassiveMode,z=L.handleVideoPlayed,K=L.instructions,q=L.isActiveMode,H=L.refVideo,G=L.showCountdown,Q=L.steps,W=L.videoPlayed,X=L.directionIconAnimation,Y=L.isFirstValidFrameFound,$=L.warmupDone,Z=L.activeCapturing,J=oy.useRef(0);oy.useEffect((function(){var e,t,r;null!==(e=U.current)&&void 0!==e&&e.height&&0===J.current&&(J.current=window.innerHeight-((null===(t=U.current)||void 0===t?void 0:t.y)+(null===(r=U.current)||void 0===r?void 0:r.height))-110)}),[U,null===(t=U.current)||void 0===t?void 0:t.height]);var ee=oy.useRef(0);if(window.innerHeight-((null===(r=U.current)||void 0===r?void 0:r.y)+(null===(n=U.current)||void 0===n?void 0:n.height))-110<60){var te,re=window.innerHeight-(null===(te=U.current)||void 0===te?void 0:te.y)-170;ee.current=(U.current.height-re)/2,U.current.width=re,U.current.height=re}oy.useEffect((function(){Promise.all(Q.map((function(e){return t=e.directionIcon,new Promise((function(e){var r=new Image;r.onload=e,r.onerror=e,r.src=t}));var t}))).then((function(){return N(!0)}))}),[Q]);var ne=oy.useRef(!1);return oy.useEffect((function(){Y||(ne.current=!1)}),[Y]),j&&j.code.includes("terminated")&&(ne.current=!0),oy.createElement(PD,{frontCamera:d,onVideoPlayed:z,flipHorizontal:d,ref:H,videoSettings:$$,onError:c,onClose:s,closeButton:oy.createElement(G$,null,oy.createElement("img",{src:k,alt:""}))},!$&&oy.createElement(Pj,null),W&&R?oy.createElement(oy.Fragment,null,oy.createElement(Q$,{top:20},"".concat(b)),oy.createElement(z$,{top:A-ee.current,className:"face-detection-error",error:j}),_&&oy.createElement(q$,{top:U.current.y-15},_),U.current?oy.createElement(UD,{x:"".concat(U.current.x+ee.current,"px"),y:"".concat(U.current.y,"px"),width:"".concat(U.current.width,"px"),height:"".concat(U.current.height,"px"),surroundStyle:U.current.surroundStyle},oy.createElement(j$,{color:"#fff"}),oy.createElement(V$,{progress:M/Q.length*100,hasError:!!j,showDashedRing:!1,showOutsideRing:!1,insideRingWidth:5,errorRingWidth:0,insideRingStrokeDash:"none",insideRingColor:"#1AA7FF"}),G?oy.createElement(D$,null,D):null,q?oy.createElement(K$,null,V?oy.createElement("img",{className:X,src:V,alt:"",style:{maxWidth:"98px",maxHeight:"98px",marginBottom:"25px"}}):null):null,q&&Z?oy.createElement(Y$,null):null):null,q?oy.createElement(oy.Fragment,null,Y&&!ne.current&&oy.createElement(R$,{bottom:60},Q.map((function(e,t){var r=e.name,n=e.image.objUrl;return oy.createElement(H$,{key:r,active:M>=t,className:"step-item"},n?oy.createElement("img",{src:n,alt:""}):oy.createElement("span",null,t+1))}))),K?oy.createElement(oy.Fragment,null,oy.createElement(F$,{bottom:30,className:"instructions"},"".concat(K)),oy.createElement(W$,null,C)):null):oy.createElement(oy.Fragment,null,j?null:oy.createElement(O$,null,oy.createElement(L$,{onClick:F},oy.createElement(T$,null))))):null)}J$.propTypes={apiCheck:Py.bool,mode:Py.string,onLivenessDetectionDone:Py.func,onClose:Py.func,onError:Py.func,captureFrameSettings:Py.shape({}),onFramesCaptured:Py.func,frontCamera:Py.bool,customStepTimeConstraints:Py.shape({}),onProcessing:Py.func,customErrors:Py.shape({}),customMessages:Py.shape({}),livenessSettings:Py.shape({}),customInstructions:Py.shape({}),apiCredentials:Py.shape({accessKey:Py.string,secretKey:Py.string,apiUrl:Py.string}),title:Py.string,subInstructions:Py.string},J$.defaultProps={apiCheck:!1,mode:null,onLivenessDetectionDone:null,onClose:null,onError:function(){},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:function(){},frontCamera:!0,customStepTimeConstraints:(w$={},nm(w$,oC.FaceDirection.UP,{delayTime:0}),nm(w$,oC.FaceDirection.LEFT,{delayTime:0}),nm(w$,oC.FaceDirection.RIGHT,{delayTime:0}),nm(w$,oC.FaceDirection.FRONTAL,{delayTime:2e3}),w$),onProcessing:function(){},customErrors:{no_face:{code:"no_face",msg:{en:"Face is not detected.",vi:"Không nhận diện được khuôn mặt."}},multiple_faces:{code:"multiple_faces",msg:{en:"There are more than one face in the frame",vi:"Nhiều khuôn mặt xuất hiện trong khung hình"}},face_too_small:{code:"face_too_small",msg:{en:"The face is too small",vi:"Khuôn mặt quá nhỏ"}},face_too_large:{code:"face_too_large",msg:{en:"The face is too big",vi:"Khuôn mặt quá lớn"}},face_out_of_box:{code:"face_out_of_box",msg:{en:"Face is out of box",vi:"Khuôn mặt nằm ngoài khung ảnh"}},liveness_terminated_time_out:{code:"liveness_terminated_time_out",msg:{en:"The face verification need to be completed in <%= x %> seconds.\nPlease try again.",vi:"Xác thực khuôn mặt cần thực hiện trong <%= x %> giây.\nVui lòng thử lại."}}},customMessages:{REMAIN_TIME:{en:"Remaining time: <%= x %> seconds",vi:"Thời gian còn lại: <%= x %>"}},customInstructions:(k$={},nm(k$,oC.FaceDirection.LEFT,{en:"Please turn to the left",vi:"Xoay trái"}),nm(k$,oC.FaceDirection.RIGHT,{en:"Please turn to the right",vi:"Xoay phải"}),nm(k$,oC.FaceDirection.UP,{en:"Please look up",vi:"Ngẩng lên"}),nm(k$,oC.FaceDirection.FRONTAL,{en:"Please look straight to camera",vi:"Nhìn thẳng"}),k$),livenessSettings:null,apiCredentials:{accessKey:"5767c20d-87aa-4cad-8dbb-f5429f76c34b",secretKey:"c1446919-e60a-4575-a05d-304318212a1b",apiUrl:"https://tv-testing.trustingsocial.com/api"},title:"Chụp khuôn mặt",subInstructions:"Xin giữ khuôn mặt nằm trong khung ảnh"};var eZ,tZ=["tracking","clientSettings","livenessSettings"],rZ=oC.Errors,nZ=eC.div(eZ||(eZ=dm(["\n text-align: center;\n font-size: 20px;\n font-weight: 600;\n"])));function iZ(e){var t=e.tracking,r=void 0===t?{enable:!0}:t,n=e.clientSettings,i=e.livenessSettings,a=lm(e,tZ),o=lC.useSDKSettings().lang,s=rZ.wrong_orientation.msg[o],c=aF().curOrientation,u=S$(n,"data.settings.sdk_settings.active_liveness_settings",i),l=S$(n,"data.settings.sdk_settings.server_log_settings.enable",r.enable);return oy.createElement(oy.Fragment,null,c===iF.LANDSCAPE&&oy.createElement(fj,{open:!0},oy.createElement(nZ,null,s)),(c===iF.PORTRAIT||c===iF.DESKTOP)&&oy.createElement(ok.SDKTrackingProvider,{value:{tracking:om(om({},r),{},{enable:l})}},oy.createElement(J$,im({},a,{livenessSettings:u}))))}var aZ=["tracking","clientSettings"];function oZ(e){var t=e.tracking,r=e.clientSettings,n=lm(e,aZ),i=oy.useMemo((function(){return S$(r,"data.settings.sdk_settings.server_log_settings.enable",null==t?void 0:t.enable)}),[r,t]);return oy.createElement(ok.SDKTrackingProvider,{value:{tracking:om(om({},t),{},{enable:i})}},oy.createElement(wY,im({},n,{clientSettings:r})))}oZ.propTypes={tracking:Py.shape({}),clientSettings:Py.shape({})},oZ.defaultProps={tracking:void 0,clientSettings:void 0};var sZ=oC.Errors,cZ=function(e){var t=e.onClose,r=e.onError,n=e.detectIdCard,i=e.steps,a=e.onStepDone,o=e.apiCredentials,s=e.tracking,c=fm(oy.useState(null),2),u=c[0],l=c[1],d=hB.useApiClient({apiCredentials:o,tracking:s}).apiClient,f=oy.useRef(""),p=oy.useRef("");oy.useEffect((function(){function e(){return(e=Jg(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d.clientSettings();case 2:t=e.sent,l(t);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[d]);var h=oy.useCallback(function(){var e=Jg(regeneratorRuntime.mark((function e(t){var n,o,s,c,u,l,h,g;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.stepNumber,o=t.recordedVideos,s=t.qrScannedResult,c=t.image,u=i[n],l=u.cardType,h=u.cardSide,g=null,e.prev=3,e.next=6,SH({image:c,cardSide:h,frontCardId:f.current,qrImageId:p.current,onError:r,apiClient:d,cardType:l,recordedVideos:o,qrScannedResult:s});case 6:g=e.sent,h===oC.IDCardSide.FRONT&&(f.current=g.cardInfo.image1.id),p.current=g.qrImageId,e.next=14;break;case 11:e.prev=11,e.t0=e.catch(3),r(om(om({},sZ.api_call_error),{},{details:e.t0}));case 14:g&&a(om(om({},t),{},{apiResult:g}));case 15:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t){return e.apply(this,arguments)}}(),[d,r,i,a]);return u&&oy.createElement(oZ,{tracking:s,onClose:t,onError:r,clientSettings:u,detectIdCard:n,onStepDone:h,steps:i})};cZ.propTypes={onClose:Py.func,onError:Py.func,detectIdCard:Py.func,onStepDone:Py.func,steps:Py.arrayOf(Py.shape({})),apiCredentials:Py.shape({accessKey:Py.string,secretKey:Py.string,apiUrl:Py.string}),tracking:Py.shape({})},cZ.defaultProps={onClose:function(){},onError:function(){},detectIdCard:function(){return Promise.resolve({card_label:""})},onStepDone:function(){},steps:EY,apiCredentials:{accessKey:"5767c20d-87aa-4cad-8dbb-f5429f76c34b",secretKey:"c1446919-e60a-4575-a05d-304318212a1b",apiUrl:"https://tv-testing.trustingsocial.com/api"},tracking:void 0};var uZ=["apiCheck","mode","accessKey","secretKey","apiUrl","onLivenessDetectionDone","onError"],lZ=Fw.getUAMetadata(),dZ=function(){function e(t){var r=this,n=t.container,i=t.lang,a=void 0===i?"en":i,o=t.assetRoot,s=void 0===o?"https://unpkg.com/@tsocial/tvweb-sdk@latest/assets":o,c=t.customUrls,u=void 0===c?{}:c,l=t.enableAntiDebug,d=void 0===l||l;em(this,e),nm(this,"checkCamera",Jj),nm(this,"initNativeCamera",(function(e){var t=document.createElement("div");document.body.appendChild(t);var r=oy.createRef();return NL.render(oy.createElement(tF,im({},e,{ref:r})),t),{openCamera:function(){r.current.click()}}})),nm(this,"runWarmUpReadIDCard",Jg(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.commonSettings.customUrls,e.abrupt("return",rK(t));case 2:case"end":return e.stop()}}),e)})))),nm(this,"destroyView",(function(){NL.unmountComponentAtNode(r.container)})),kY(n,"container is a required parameter"),this.container=n,this.commonSettings={lang:a,assetRoot:s,customUrls:u,enableAntiDebug:d,debug:!1}}return rm(e,[{key:"readIDCardWithApiCall",value:function(e){NL.render(oy.createElement(lC.SDKSettingsProvider,{value:om({},this.commonSettings)},oy.createElement(cZ,im({onClose:this.destroyView},e))),this.container)}},{key:"readIDCardUIOnly",value:function(e){NL.render(oy.createElement(lC.SDKSettingsProvider,{value:this.commonSettings},oy.createElement(oZ,im({onClose:this.destroyView},e))),this.container)}},{key:"livenessDetection",value:function(e){var t=e.apiCheck,r=e.mode,n=(e.accessKey,e.secretKey,e.apiUrl,e.onLivenessDetectionDone),i=e.onError,a=lm(e,uZ);NL.render(oy.createElement(lC.SDKSettingsProvider,{value:om({},this.commonSettings)},oy.createElement(iZ,im({},a,{apiCheck:t,mode:r,onLivenessDetectionDone:n,onClose:this.destroyView,onError:i}))),this.container)}},{key:"compareFaces",value:function(e){var t=e.accessKey,r=e.secretKey,n=e.apiUrl,i=e.image1,a=e.image2,o=e.onSuccess,s=e.onError;hB.createRetryAPIClient(new SY(t,r,n,{httpHeaders:lZ})).compareFaces({image1:{id:i},image2:{id:a}}).then((function(e){o(e)})).catch((function(e){s(e)}))}}]),e}();exports.APIUtils=hB,exports.Animations=oz,exports.AntiDebugUtils=LB,exports.AssetUtils=uk,exports.AsyncUtils=dk,exports.BASE_Z_INDEX=1e3,exports.BlurUtils=Lk,exports.Button=TK,exports.ButtonLink=AK,exports.Camera=PD,exports.CameraUtils=Uk,exports.CommonUtils=Vk,exports.Constants=oC,exports.CoordinateUtils=qk,exports.CropAreaOverlayWrapper=UD,exports.CryptoUtils=MB,exports.FaceUtils=Zk,exports.GlareUtils=iB,exports.HashUtils=$w,exports.HighlightResult=Rq,exports.HighlightResultType=Bq,exports.Icons=nF,exports.ImageUtils=eB,exports.LivenessDetection=function(e){var t=e.tracking,r=void 0===t?{enable:!0}:t,n=e.clientSettings,i=e.livenessSettings,a=FL(e,oF),o=lC.useSDKSettings().lang,s=sF.wrong_orientation.msg[o],c=aF().curOrientation,u=pV(n,"data.settings.sdk_settings.active_liveness_settings",i),l=pV(n,"data.settings.sdk_settings.server_log_settings.enable",r.enable);return oy.createElement(oy.Fragment,null,c===iF.LANDSCAPE&&oy.createElement(fj,{open:!0},oy.createElement(cF,null,s)),(c===iF.PORTRAIT||c===iF.DESKTOP)&&oy.createElement(ok.SDKTrackingProvider,{value:{tracking:jL(jL({},r),{},{enable:l})}},oy.createElement(Yj,ML({},a,{livenessSettings:u}))))},exports.LivenessDetectionComponents=PH,exports.LoadResourceUtils=wB,exports.LocalStorageUtils=Qw,exports.MobileDetect=lD,exports.ModelUtils=OB,exports.NativeCamera=tF,exports.OrientationMode=iF,exports.PlacementArea=DD,exports.Popup=fj,exports.PredictionUtils=rS,exports.ProgressCircle=JV,exports.RatioWrapper=HK,exports.ReadIDCardUIOnly=dH,exports.ReadIDCardWithApiCall=IH,exports.RectangleMask=AF,exports.RectangleMaskType=TF,exports.SDK=dZ,exports.ScannerType=oH,exports.SettingsContext=lC,exports.Spacing=bK,exports.ThemeUtils=DB,exports.TimeUtils=qw,exports.TrackingContext=ok,exports.UserAgentUtils=Fw,exports.WarmupPopup=Pj,exports.checkCamera=Jj,exports.defaultClientSettings=eH,exports.defaultReadIDCardSteps=EY,exports.getQrScannerWorkerPath=VB,exports.handleApiCheckReadIdCard=SH,exports.readIdCardFromImage=_H,exports.readQRCodeFromImage=yq,exports.useDetectOrientation=aF,exports.useLivenessDetection=xH,exports.useMainProcessQRCodeScanner=vq,exports.useMainProcessReadIdCard=uK,exports.useSettingsReadIdCard=tH,exports.useShowPopup=Az,exports.warmUpQRCodeScanner=nq,exports.warmUpReadIdCard=rK;
75
+ ***************************************************************************** */function a(e,t,r,n){var i,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,r,o):i(t,r))||o);return a>3&&o&&Object.defineProperty(t,r,o),o}function o(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function s(e,t,r,n){return new(r||(r=Promise))((function(i,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var u=function(){function e(e){this.httpClient=e}return e.prototype.uploadImage=function(e){return this.httpClient.postFormData("/v1/images",e)},e.prototype.request=function(e){var t="application/pdf"===e.file.type;return this.httpClient.postFormData(t?"/v1/files":"/v1/images",e)},e.prototype.requestWithHeaders=function(e,t){return this.httpClient.postFormData("/v1/images",e,t)},e.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.httpClient.downloadFile("/v1/images/"+e)];case 1:return t=r.sent(),[4,URL.createObjectURL(t)];case 2:return[2,r.sent()]}}))}))},e.prototype.updateMetadata=function(e,t){return this.httpClient.patch("/v1/images/"+e,t)},e}(),l=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/files",e,t)},e.prototype.uploadFile=function(e){return this.httpClient.postFormData("/v1/files",e)},e.prototype.requestWithHeaders=function(e,t){return this.httpClient.postFormData("/v1/files",e,t)},e}(),d=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/compare_faces_sync",e,t)},e}(),f=function(){function e(e){this.httpClient=e}return e.prototype.getClientSettings=function(){return this.httpClient.get("/v1/client_settings")},e.prototype.request=function(){return this.httpClient.get("/v1/client_settings")},e}(),p=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_face_liveness_sync",e,t)},e}(),h=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_id_card_sanity_sync",e,t)},e}(),g=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_portrait_sanity_sync",e,t)},e}(),m=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/detect_id_card_tampering_sync",e,t)},e.prototype.requestWithAuthHeaders=function(e,t){return this.httpClient.post("/v1/detect_id_card_tampering_sync",e,t)},e}(),y=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/search_faces_sync",e,t)},e.prototype.indexFaces=function(e,t){return this.httpClient.post("/v1/index_faces_sync",e,t)},e.prototype.deleteFaces=function(e,t){return this.httpClient.post("/v1/delete_faces",e,t)},e.prototype.downloadFaceImage=function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.httpClient.downloadFile("/v1/face_images/"+e)];case 1:return t=r.sent(),[2,URL.createObjectURL(t)]}}))}))},e}(),v=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.postFormData("/v1/convert_pdf_sync",e,t)},e}(),b=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/ekyc_pdf",e,t)},e}(),C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{};function E(e,t){return e(t={exports:{}},t.exports),t.exports}var w=E((function(e){var t,r;t=C,r=function(){function e(e){var t=[];if(0===e.length)return"";if("string"!=typeof e[0])throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var r=e.shift();e[0]=r+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<e.length;n++){var i=e[n];if("string"!=typeof i)throw new TypeError("Url must be a string. Received "+i);""!==i&&(n>0&&(i=i.replace(/^[\/]+/,"")),i=n<e.length-1?i.replace(/[\/]+$/,""):i.replace(/[\/]+$/,"/"),t.push(i))}var a=t.join("/"),o=(a=a.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return o.shift()+(o.length>0?"?":"")+o.join("&")}return function(){return e("object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments))}},e.exports?e.exports=r():t.urljoin=r()}));function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var S=function(e,t,r,n){t=t||"&",r=r||"=";var i={};if("string"!=typeof e||0===e.length)return i;var a=/\+/g;e=e.split(t);var o=1e3;n&&"number"==typeof n.maxKeys&&(o=n.maxKeys);var s=e.length;o>0&&s>o&&(s=o);for(var c=0;c<s;++c){var u,l,d,f,p=e[c].replace(a,"%20"),h=p.indexOf(r);h>=0?(u=p.substr(0,h),l=p.substr(h+1)):(u=p,l=""),d=decodeURIComponent(u),f=decodeURIComponent(l),k(i,d)?Array.isArray(i[d])?i[d].push(f):i[d]=[i[d],f]:i[d]=f}return i},B=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},T=function(e,t,r,n){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(n){var i=encodeURIComponent(B(n))+r;return Array.isArray(e[n])?e[n].map((function(e){return i+encodeURIComponent(B(e))})).join(t):i+encodeURIComponent(B(e[n]))})).join(t):n?encodeURIComponent(B(n))+r+encodeURIComponent(B(e)):""},A=E((function(e,t){t.decode=t.parse=S,t.encode=t.stringify=T})),I=(A.decode,A.parse,A.encode,A.stringify),_=function(){function e(e){this.authorizer=e.authorizer,this.domain=e.domain,this.onError=e.onError,this.configHeaders=e.headers}return e.prototype.get=function(e,t,r){var n=new URL(this.resolveUrl(e));return t&&(n.search=I(t)),this.request(n.toString(),{requestPath:e,method:"GET",headers:r})},e.prototype.post=function(e,t,r){var n=this.resolveUrl(e);return this.request(n,{requestPath:e,method:"POST",body:JSON.stringify(t),headers:i({"Content-Type":"application/json"},r)})},e.prototype.postFormData=function(e,t,r){var n,i=t instanceof FormData?t:(n=t,Object.entries(n).reduce((function(e,t){var r=t[0],n=t[1];return Array.isArray(n)?n.forEach((function(t,i){return e.append(r+"["+i+"]",n)})):!(n instanceof Object)||n instanceof File||n instanceof Date||n instanceof Blob?e.append(r,n):Object.entries(n).forEach((function(t,i){return e.append(r+"["+i+"]",n[i])})),e}),new FormData)),a=this.resolveUrl(e);return this.request(a,{requestPath:e,method:"POST",body:i,headers:r})},e.prototype.patch=function(e,t,r){var n=this.resolveUrl(e);return this.request(n,{requestPath:e,method:"PATCH",body:JSON.stringify(t),headers:i({"Content-Type":"application/json"},r)})},e.prototype.delete=function(e,t,r){var n=this.resolveUrl(e);return this.request(n,{requestPath:e,method:"DELETE",body:JSON.stringify(t),headers:i({"Content-Type":"application/json"},r)})},e.prototype.downloadFile=function(e){var t=this.resolveUrl(e);return this.request(t,{requestPath:e,method:"GET"},"blob")},e.prototype.request=function(e,t,r){return void 0===r&&(r="json"),s(this,void 0,void 0,(function(){var n,a,o,s;return c(this,(function(c){switch(c.label){case 0:return n={},a={},this.authorizer&&(n=this.authorizer.getHeaders(t)),this.configHeaders&&(a=this.configHeaders),t.headers=i(i(i({},t.headers),n),a),[4,fetch(e,t)];case 1:return o=c.sent(),[4,"blob"===r?o.blob():o.json()];case 2:if((s=c.sent()).errors&&this.onError)throw this.onError(s.errors),s;return[2,s]}}))}))},e.prototype.resolveUrl=function(e){return w(this.domain,e)},e}(),x=function(){function e(e){this.mocks=e}return e.prototype.get=function(e,t){return this.findInMocks(e,t)},e.prototype.post=function(e,t){return this.findInMocks(e)},e.prototype.postFormData=function(e,t){return this.findInMocks(e)},e.prototype.patch=function(e,t){return this.findInMocks(e)},e.prototype.delete=function(e,t){return this.findInMocks(e)},e.prototype.downloadFile=function(e){return this.findInMocks(e)},e.prototype.resolveUrl=function(e){return this.mocks.resolveUrl?this.mocks.resolveUrl(e):e},e.prototype.findInMocks=function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(r){return this.mocks[e]?"function"==typeof this.mocks[e]?[2,Promise.resolve(this.mocks[e](t))]:[2,Promise.resolve(this.mocks[e])]:[2,Promise.reject(new Error(e+" is not presented in mocks"))]}))}))},e}(),P=E((function(e,t){var r;e.exports=r=r||function(e,t){var r=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),n={},i=n.lib={},a=i.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=i.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var a=0;a<i;a++){var o=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=o<<24-(n+a)%4*8}else for(a=0;a<i;a+=4)t[n+a>>>2]=r[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],i=function(t){t=t;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}},a=0;a<t;a+=4){var s=i(4294967296*(r||e.random()));r=987654071*s(),n.push(4294967296*s()|0)}return new o.init(n,t)}}),s=n.enc={},c=s.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new o.init(r,t/2)}},u=s.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(a))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new o.init(r,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},d=i.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,i=r.sigBytes,a=this.blockSize,s=i/(4*a),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,u=e.min(4*c,i);if(c){for(var l=0;l<c;l+=a)this._doProcessBlock(n,l);var d=n.splice(0,c);r.sigBytes-=u}return new o.init(d,u)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),f=(i.Hasher=d.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new f.HMAC.init(e,r).finalize(t)}}}),n.algo={});return n}(Math)})),R=E((function(e,t){var r,n,i;e.exports=(n=(r=i=P).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],a=0;a<r;a+=3)for(var o=(t[a>>>2]>>>24-a%4*8&255)<<16|(t[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|t[a+2>>>2]>>>24-(a+2)%4*8&255,s=0;s<4&&a+.75*s<r;s++)i.push(n.charAt(o>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var a=0;a<r.length;a++)i[r.charCodeAt(a)]=a}var o=r.charAt(64);if(o){var s=e.indexOf(o);-1!==s&&(t=s)}return function(e,t,r){for(var i=[],a=0,o=0;o<t;o++)if(o%4){var s=r[e.charCodeAt(o-1)]<<o%4*2,c=r[e.charCodeAt(o)]>>>6-o%4*2;i[a>>>2]|=(s|c)<<24-a%4*8,a++}return n.create(i,a)}(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)})),N=(E((function(e,t){var r;e.exports=(r=P,function(e){var t=r,n=t.lib,i=n.WordArray,a=n.Hasher,o=t.algo,s=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(s[i]=r(e.pow(n,.5))),c[i]=r(e.pow(n,1/3)),i++),n++}();var u=[],l=o.SHA256=a.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],d=r[6],f=r[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var h=u[p-15],g=(h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3,m=u[p-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[p]=g+u[p-7]+y+u[p-16]}var v=n&i^n&a^i&a,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),C=f+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&l^~s&d)+c[p]+u[p];f=d,d=l,l=s,s=o+C|0,o=a,a=i,i=n,n=C+(b+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+o|0,r[4]=r[4]+s|0,r[5]=r[5]+l|0,r[6]=r[6]+d|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=a._createHelper(l),t.HmacSHA256=a._createHmacHelper(l)}(Math),r.SHA256)})),E((function(e,t){var r,n,i;e.exports=(n=(r=P).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var a=this._oKey=t.clone(),o=this._iKey=t.clone(),s=a.words,c=o.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;a.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))})),E((function(e,t){e.exports=P.HmacSHA256}))),O=function(){function e(e,t){this.accessKey=e,this.keySecret=t}return e.prototype.getHeaders=function(e){var t=function(e){function t(e){return e<10?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+"T"+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+(0===(r=e.getTimezoneOffset())?"Z":(n=r>0?"-":"+",r=Math.abs(r),n+t(Math.floor(r/60))+":"+t(r%60)));var r,n}(new Date);return{Authorization:this.generateAuthorization(e.requestPath,e.method,t),"X-TV-Timestamp":t}},e.prototype.generateAuthorization=function(e,t,r){var n=this.computeStringToSign(e,t,r),i=R.stringify(this.computeSignature(n));return this.formatAuthToken("TV",i)},e.prototype.formatAuthToken=function(e,t){return e+" "+this.accessKey+":"+t},e.prototype.computeStringToSign=function(e,t,r){return t+"\n"+e+"\n"+r},e.prototype.computeSignature=function(e){return N(e,this.keySecret)},e}();function L(e){switch(e){case"testing":return"https://tv-testing.trustingsocial.com/api";case"staging":return"https://tv-staging.trustingsocial.com/api";case"production":return"https://vn-vision.trustingsocial.com/api";default:return e}}function D(e,t,r,n){void 0===r&&(r="production");var i=(void 0===n?{}:n).headers,a=new O(e,t),o=L(r);return new _({authorizer:a,domain:o,headers:i})}var U=function(){function e(e){void 0===e&&(e="production");var t=new _({domain:L(e)});this.imagesService=new u(t),this.detectIDTamperingService=new m(t)}return e.prototype.uploadImage=function(e,t){return this.imagesService.requestWithHeaders(e,t)},e.prototype.detectTampering=function(e,t){return this.detectIDTamperingService.requestWithAuthHeaders(e,t)},e}();function M(e){var t=e.headerIndex;return function(e,r,n){var a=n.value,o=i({},n);return o.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return s(this,void 0,void 0,(function(){var r,n,o,s;return c(this,(function(c){switch(c.label){case 0:return this.transactionEnabled?[4,this.transactionManager.begin()]:[3,4];case 1:return r=c.sent(),n=function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<r;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)n[i]=a[o];return n}(e),(o=i({},n[t]))["X-TV-Transaction"]=r,n[t]=o,[4,a.apply(this,n)];case 2:return s=c.sent(),[4,this.transactionManager.end()];case 3:return c.sent(),[2,s];case 4:return[4,a.apply(this,e)];case 5:return[2,c.sent()]}}))}))},o}}function V(e){return void 0===e&&(e={encryptedField:"data"}),function(t,r,n){var a=n.value,o=i({},n);return o.value=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return s(this,void 0,void 0,(function(){var r,n;return c(this,(function(i){switch(i.label){case 0:return[4,a.apply(this,t)];case 1:return r=i.sent(),this.encryptionEnabled&&"string"==typeof r[e.encryptedField]?(n=this.encryptionService.decrypt(r[e.encryptedField],{transactionID:this.transactionManager.currentTransactionID}),[2,JSON.parse(n)]):[2,r]}}))}))},o}}var j=function(){function e(e){this.httpClient=e,this.transactionID="",this.totalTransactions=0,this.currentTransaction=0}return Object.defineProperty(e.prototype,"currentTransactionID",{get:function(){return this.transactionID},enumerable:!0,configurable:!0}),e.prototype.begin=function(){return s(this,void 0,void 0,(function(){var e,t,r=this;return c(this,(function(n){switch(n.label){case 0:return e=this.totalTransactions++,[4,new Promise((function(t,n){var i=window.performance.now(),a=setInterval((function(){e===r.currentTransaction&&(clearInterval(a),t(!0)),window.performance.now()-i>=3e3&&(clearInterval(a),n(new Error("Transaction timeout")))}),100)}))];case 1:return n.sent(),[4,this.httpClient.post("/v1/transactions",{})];case 2:return t=n.sent().data,this.transactionID=t.id,[2,t.id]}}))}))},e.prototype.end=function(){return s(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return[4,this.httpClient.post("/v1/transactions/"+this.transactionID+"/finish")];case 1:return e=t.sent(),this.transactionID="",this.currentTransaction++,[2,e]}}))}))},e}(),F={options:{usePureJavaScript:!1}},z={},K=z,q={};z.encode=function(e,t,r){if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,a=t.length,o=t.charAt(0),s=[0];for(i=0;i<e.length;++i){for(var c=0,u=e[i];c<s.length;++c)u+=s[c]<<8,s[c]=u%a,u=u/a|0;for(;u>0;)s.push(u%a),u=u/a|0}for(i=0;0===e[i]&&i<e.length-1;++i)n+=o;for(i=s.length-1;i>=0;--i)n+=t[s[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),a=[0];for(r=0;r<e.length();++r){for(var o=0,s=e.at(r);o<a.length;++o)s+=a[o]<<8,a[o]=s%n,s=s/n|0;for(;s>0;)a.push(s%n),s=s/n|0}var c="";for(r=0;0===e.at(r)&&r<e.length()-1;++r)c+=i;for(r=a.length-1;r>=0;--r)c+=t[a[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},z.decode=function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');var r=q[t];if(!r){r=q[t]=[];for(var n=0;n<t.length;++n)r[t.charCodeAt(n)]=n}e=e.replace(/\s/g,"");var i=t.length,a=t.charAt(0),o=[0];for(n=0;n<e.length;n++){var s=r[e.charCodeAt(n)];if(void 0===s)return;for(var c=0,u=s;c<o.length;++c)u+=o[c]*i,o[c]=255&u,u>>=8;for(;u>0;)o.push(255&u),u>>=8}for(var l=0;e[l]===a&&l<e.length-1;++l)o.push(0);return"undefined"!=typeof Buffer?Buffer.from(o.reverse()):new Uint8Array(o.reverse())},E((function(e){var t=e.exports=F.util=F.util||{};function r(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function n(e){if(this.data="",this.read=0,"string"==typeof e)this.data=e;else if(t.isArrayBuffer(e)||t.isArrayBufferView(e))if("undefined"!=typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var r=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,r)}catch(e){for(var i=0;i<r.length;++i)this.putByte(r[i])}}else(e instanceof n||"object"==typeof e&&"string"==typeof e.data&&"number"==typeof e.read)&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}!function(){if("undefined"!=typeof process&&process.nextTick&&!process.browser)return t.nextTick=process.nextTick,void("function"==typeof setImmediate?t.setImmediate=setImmediate:t.setImmediate=t.nextTick);if("function"==typeof setImmediate)return t.setImmediate=function(){return setImmediate.apply(void 0,arguments)},void(t.nextTick=function(e){return setImmediate(e)});if(t.setImmediate=function(e){setTimeout(e,0)},"undefined"!=typeof window&&"function"==typeof window.postMessage){var e="forge.setImmediate",r=[];t.setImmediate=function(t){r.push(t),1===r.length&&window.postMessage(e,"*")},window.addEventListener("message",(function(t){if(t.source===window&&t.data===e){t.stopPropagation();var n=r.slice();r.length=0,n.forEach((function(e){e()}))}}),!0)}if("undefined"!=typeof MutationObserver){var n=Date.now(),i=!0,a=document.createElement("div");r=[],new MutationObserver((function(){var e=r.slice();r.length=0,e.forEach((function(e){e()}))})).observe(a,{attributes:!0});var o=t.setImmediate;t.setImmediate=function(e){Date.now()-n>15?(n=Date.now(),o(e)):(r.push(e),1===r.length&&a.setAttribute("a",i=!i))}}t.nextTick=t.setImmediate}(),t.isNodejs="undefined"!=typeof process&&process.versions&&process.versions.node,t.globalScope=t.isNodejs?C:"undefined"==typeof self?window:self,t.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},t.isArrayBufferView=function(e){return e&&t.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},t.ByteBuffer=n,t.ByteStringBuffer=n,t.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},t.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},t.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},t.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},t.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},t.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},t.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(t.encodeUtf8(e))},t.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},t.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},t.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},t.ByteStringBuffer.prototype.putInt=function(e,t){r(t);var n="";do{t-=8,n+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(n)},t.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},t.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},t.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},t.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},t.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},t.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},t.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},t.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},t.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},t.ByteStringBuffer.prototype.getInt=function(e){r(e);var t=0;do{t=(t<<8)+this.data.charCodeAt(this.read++),e-=8}while(e>0);return t},t.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},t.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},t.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},t.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},t.ByteStringBuffer.prototype.copy=function(){var e=t.createBuffer(this.data);return e.read=this.read,e},t.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},t.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},t.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},t.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);r<16&&(e+="0"),e+=r.toString(16)}return e},t.ByteStringBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())},t.DataBuffer=function(e,r){r=r||{},this.read=r.readOffset||0,this.growSize=r.growSize||1024;var n=t.isArrayBuffer(e),i=t.isArrayBufferView(e);if(n||i)return this.data=n?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),void(this.write="writeOffset"in r?r.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!=e&&this.putBytes(e),"writeOffset"in r&&(this.write=r.writeOffset)},t.DataBuffer.prototype.length=function(){return this.write-this.read},t.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},t.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},t.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},t.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r<t;++r)this.data.setUint8(e);return this},t.DataBuffer.prototype.putBytes=function(e,r){if(t.isArrayBufferView(e)){var n=(i=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).byteLength-i.byteOffset;return this.accommodate(n),new Uint8Array(this.data.buffer,this.write).set(i),this.write+=n,this}if(t.isArrayBuffer(e)){var i=new Uint8Array(e);return this.accommodate(i.byteLength),new Uint8Array(this.data.buffer).set(i,this.write),this.write+=i.byteLength,this}if(e instanceof t.DataBuffer||"object"==typeof e&&"number"==typeof e.read&&"number"==typeof e.write&&t.isArrayBufferView(e.data))return i=new Uint8Array(e.data.byteLength,e.read,e.length()),this.accommodate(i.byteLength),new Uint8Array(e.data.byteLength,this.write).set(i),this.write+=i.byteLength,this;if(e instanceof t.ByteStringBuffer&&(e=e.data,r="binary"),r=r||"binary","string"==typeof e){var a;if("hex"===r)return this.accommodate(Math.ceil(e.length/2)),a=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.hex.decode(e,a,this.write),this;if("base64"===r)return this.accommodate(3*Math.ceil(e.length/4)),a=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.base64.decode(e,a,this.write),this;if("utf8"===r&&(e=t.encodeUtf8(e),r="binary"),"binary"===r||"raw"===r)return this.accommodate(e.length),a=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.raw.decode(a),this;if("utf16"===r)return this.accommodate(2*e.length),a=new Uint16Array(this.data.buffer,this.write),this.write+=t.text.utf16.encode(a),this;throw new Error("Invalid encoding: "+r)}throw Error("Invalid parameter: "+e)},t.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},t.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},t.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},t.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},t.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},t.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},t.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},t.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},t.DataBuffer.prototype.putInt=function(e,t){r(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},t.DataBuffer.prototype.putSignedInt=function(e,t){return r(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},t.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},t.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},t.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},t.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},t.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},t.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},t.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},t.DataBuffer.prototype.getInt=function(e){r(e);var t=0;do{t=(t<<8)+this.data.getInt8(this.read++),e-=8}while(e>0);return t},t.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},t.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},t.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},t.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},t.DataBuffer.prototype.copy=function(){return new t.DataBuffer(this)},t.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},t.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},t.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},t.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var r=this.data.getUint8(t);r<16&&(e+="0"),e+=r.toString(16)}return e},t.DataBuffer.prototype.toString=function(e){var r=new Uint8Array(this.data,this.read,this.length());if("binary"===(e=e||"utf8")||"raw"===e)return t.binary.raw.encode(r);if("hex"===e)return t.binary.hex.encode(r);if("base64"===e)return t.binary.base64.encode(r);if("utf8"===e)return t.text.utf8.decode(r);if("utf16"===e)return t.text.utf16.decode(r);throw new Error("Invalid encoding: "+e)},t.createBuffer=function(e,r){return r=r||"raw",void 0!==e&&"utf8"===r&&(e=t.encodeUtf8(e)),new t.ByteBuffer(e)},t.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},t.xorBytes=function(e,t,r){for(var n="",i="",a="",o=0,s=0;r>0;--r,++o)i=e.charCodeAt(o)^t.charCodeAt(o),s>=10&&(n+=a,a="",s=0),a+=String.fromCharCode(i),++s;return n+a},t.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},t.bytesToHex=function(e){return t.createBuffer(e).toHex()},t.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],o="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";t.encode64=function(e,t){for(var r,n,a,o="",s="",c=0;c<e.length;)r=e.charCodeAt(c++),n=e.charCodeAt(c++),a=e.charCodeAt(c++),o+=i.charAt(r>>2),o+=i.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=i.charAt((15&n)<<2|a>>6),o+=isNaN(a)?"=":i.charAt(63&a)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},t.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,o="",s=0;s<e.length;)t=a[e.charCodeAt(s++)-43],r=a[e.charCodeAt(s++)-43],n=a[e.charCodeAt(s++)-43],i=a[e.charCodeAt(s++)-43],o+=String.fromCharCode(t<<2|r>>4),64!==n&&(o+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(o+=String.fromCharCode((3&n)<<6|i)));return o},t.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},t.decodeUtf8=function(e){return decodeURIComponent(escape(e))},t.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:K.encode,decode:K.decode}},t.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},t.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,a=0;a<e.length;++a)n[i++]=e.charCodeAt(a);return t?i-r:n},t.binary.hex.encode=t.bytesToHex,t.binary.hex.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/2)));var i=0,a=r=r||0;for(1&e.length&&(i=1,n[a++]=parseInt(e[0],16));i<e.length;i+=2)n[a++]=parseInt(e.substr(i,2),16);return t?a-r:n},t.binary.base64.encode=function(e,t){for(var r,n,a,o="",s="",c=0;c<e.byteLength;)r=e[c++],n=e[c++],a=e[c++],o+=i.charAt(r>>2),o+=i.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=i.charAt((15&n)<<2|a>>6),o+=isNaN(a)?"=":i.charAt(63&a)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},t.binary.base64.decode=function(e,t,r){var n,i,o,s,c=t;c||(c=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var u=0,l=r=r||0;u<e.length;)n=a[e.charCodeAt(u++)-43],i=a[e.charCodeAt(u++)-43],o=a[e.charCodeAt(u++)-43],s=a[e.charCodeAt(u++)-43],c[l++]=n<<2|i>>4,64!==o&&(c[l++]=(15&i)<<4|o>>2,64!==s&&(c[l++]=(3&o)<<6|s));return t?l-r:c.subarray(0,l)},t.binary.base58.encode=function(e,r){return t.binary.baseN.encode(e,o,r)},t.binary.base58.decode=function(e,r){return t.binary.baseN.decode(e,o,r)},t.text={utf8:{},utf16:{}},t.text.utf8.encode=function(e,r,n){e=t.encodeUtf8(e);var i=r;i||(i=new Uint8Array(e.length));for(var a=n=n||0,o=0;o<e.length;++o)i[a++]=e.charCodeAt(o);return r?a-n:i},t.text.utf8.decode=function(e){return t.decodeUtf8(String.fromCharCode.apply(null,e))},t.text.utf16.encode=function(e,t,r){var n=t;n||(n=new Uint8Array(2*e.length));for(var i=new Uint16Array(n.buffer),a=r=r||0,o=r,s=0;s<e.length;++s)i[o++]=e.charCodeAt(s),a+=2;return t?a-r:n},t.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},t.deflate=function(e,r,n){if(r=t.decode64(e.deflate(t.encode64(r)).rval),n){var i=2;32&r.charCodeAt(1)&&(i=6),r=r.substring(i,r.length-4)}return r},t.inflate=function(e,r,n){var i=e.inflate(t.encode64(r)).rval;return null===i?null:t.decode64(i)};var s=function(e,r,n){if(!e)throw new Error("WebStorage not available.");var i;if(null===n?i=e.removeItem(r):(n=t.encode64(JSON.stringify(n)),i=e.setItem(r,n)),void 0!==i&&!0!==i.rval){var a=new Error(i.error.message);throw a.id=i.error.id,a.name=i.error.name,a}},c=function(e,r){if(!e)throw new Error("WebStorage not available.");var n=e.getItem(r);if(e.init)if(null===n.rval){if(n.error){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}n=null}else n=n.rval;return null!==n&&(n=JSON.parse(t.decode64(n))),n},u=function(e,t,r,n){var i=c(e,t);null===i&&(i={}),i[r]=n,s(e,t,i)},l=function(e,t,r){var n=c(e,t);return null!==n&&(n=r in n?n[r]:null),n},d=function(e,t,r){var n=c(e,t);if(null!==n&&r in n){delete n[r];var i=!0;for(var a in n){i=!1;break}i&&(n=null),s(e,t,n)}},f=function(e,t){s(e,t,null)},p=function(e,t,r){var n,i=null;void 0===r&&(r=["web","flash"]);var a=!1,o=null;for(var s in r){n=r[s];try{if("flash"===n||"both"===n){if(null===t[0])throw new Error("Flash local storage not available.");i=e.apply(this,t),a="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,i=e.apply(this,t),a=!0)}catch(e){o=e}if(a)break}if(!a)throw o;return i};t.setItem=function(e,t,r,n,i){p(u,arguments,i)},t.getItem=function(e,t,r,n){return p(l,arguments,n)},t.removeItem=function(e,t,r,n){p(d,arguments,n)},t.clearItems=function(e,t,r){p(f,arguments,r)},t.parseUrl=function(e){var t=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;t.lastIndex=0;var r=t.exec(e),n=null===r?null:{full:e,scheme:r[1],host:r[2],port:r[3],path:r[4]};return n&&(n.fullHost=n.host,n.port?(80!==n.port&&"http"===n.scheme||443!==n.port&&"https"===n.scheme)&&(n.fullHost+=":"+n.port):"http"===n.scheme?n.port=80:"https"===n.scheme&&(n.port=443),n.full=n.scheme+"://"+n.fullHost),n};var h=null;t.getQueryVariables=function(e){var t,r=function(e){for(var t={},r=e.split("&"),n=0;n<r.length;n++){var i,a,o=r[n].indexOf("=");o>0?(i=r[n].substring(0,o),a=r[n].substring(o+1)):(i=r[n],a=null),i in t||(t[i]=[]),i in Object.prototype||null===a||t[i].push(unescape(a))}return t};return void 0===e?(null===h&&(h="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=h):t=r(e),t},t.parseFragment=function(e){var r=e,n="",i=e.indexOf("?");i>0&&(r=e.substring(0,i),n=e.substring(i+1));var a=r.split("/");return a.length>0&&""===a[0]&&a.shift(),{pathString:r,queryString:n,path:a,query:""===n?{}:t.getQueryVariables(n)}},t.makeRequest=function(e){var r=t.parseFragment(e),n={path:r.pathString,query:r.queryString,getPath:function(e){return void 0===e?r.path:r.path[e]},getQuery:function(e,t){var n;return void 0===e?n=r.query:(n=r.query[e])&&void 0!==t&&(n=n[t]),n},getQueryLast:function(e,t){var r=n.getQuery(e);return r?r[r.length-1]:t}};return n},t.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var n=jQuery.param(t||{});return r=r||"",e+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")},t.setPath=function(e,t,r){if("object"==typeof e&&null!==e)for(var n=0,i=t.length;n<i;){var a=t[n++];if(n==i)e[a]=r;else{var o=a in e;(!o||o&&"object"!=typeof e[a]||o&&null===e[a])&&(e[a]={}),e=e[a]}}},t.getPath=function(e,t,r){for(var n=0,i=t.length,a=!0;a&&n<i&&"object"==typeof e&&null!==e;){var o=t[n++];(a=o in e)&&(e=e[o])}return a?e:r},t.deletePath=function(e,t){if("object"==typeof e&&null!==e)for(var r=0,n=t.length;r<n;){var i=t[r++];if(r==n)delete e[i];else{if(!(i in e)||"object"!=typeof e[i]||null===e[i])break;e=e[i]}}},t.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},t.format=function(e){for(var t,r,n=/%./g,i=0,a=[],o=0;t=n.exec(e);){(r=e.substring(o,n.lastIndex-2)).length>0&&a.push(r),o=n.lastIndex;var s=t[0][1];switch(s){case"s":case"o":i<arguments.length?a.push(arguments[1+i++]):a.push("<?>");break;case"%":a.push("%");break;default:a.push("<%"+s+"?>")}}return a.push(e.substring(o)),a.join("")},t.formatNumber=function(e,t,r,n){var i=e,a=isNaN(t=Math.abs(t))?2:t,o=void 0===r?",":r,s=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(a),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+s:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+s)+(a?o+Math.abs(i-u).toFixed(a).slice(2):"")},t.formatSize=function(e){return e>=1073741824?t.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?t.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?t.formatNumber(e/1024,0)+" KiB":t.formatNumber(e,0)+" bytes"},t.bytesFromIP=function(e){return-1!==e.indexOf(".")?t.bytesFromIPv4(e):-1!==e.indexOf(":")?t.bytesFromIPv6(e):null},t.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var r=t.createBuffer(),n=0;n<e.length;++n){var i=parseInt(e[n],10);if(isNaN(i))return null;r.putByte(i)}return r.getBytes()},t.bytesFromIPv6=function(e){for(var r=0,n=2*(8-(e=e.split(":").filter((function(e){return 0===e.length&&++r,!0}))).length+r),i=t.createBuffer(),a=0;a<8;++a)if(e[a]&&0!==e[a].length){var o=t.hexToBytes(e[a]);o.length<2&&i.putByte(0),i.putBytes(o)}else i.fillWithByte(0,n),n=0;return i.getBytes()},t.bytesToIP=function(e){return 4===e.length?t.bytesToIPv4(e):16===e.length?t.bytesToIPv6(e):null},t.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")},t.bytesToIPv6=function(e){if(16!==e.length)return null;for(var r=[],n=[],i=0,a=0;a<e.length;a+=2){for(var o=t.bytesToHex(e[a]+e[a+1]);"0"===o[0]&&"0"!==o;)o=o.substr(1);if("0"===o){var s=n[n.length-1],c=r.length;s&&c===s.end+1?(s.end=c,s.end-s.start>n[i].end-n[i].start&&(i=n.length-1)):n.push({start:c,end:c})}r.push(o)}if(n.length>0){var u=n[i];u.end-u.start>0&&(r.splice(u.start,u.end-u.start+1,""),0===u.start&&r.unshift(""),7===u.end&&r.push(""))}return r.join(":")},t.estimateCores=function(e,r){if("function"==typeof e&&(r=e,e={}),e=e||{},"cores"in t&&!e.update)return r(null,t.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return t.cores=navigator.hardwareConcurrency,r(null,t.cores);if("undefined"==typeof Worker)return t.cores=1,r(null,t.cores);if("undefined"==typeof Blob)return t.cores=2,r(null,t.cores);var n=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){var t=Date.now(),r=t+4;self.postMessage({st:t,et:r})}))}.toString(),")()"],{type:"application/javascript"}));!function e(i,a,o){if(0===a){var s=Math.floor(i.reduce((function(e,t){return e+t}),0)/i.length);return t.cores=Math.max(1,s),URL.revokeObjectURL(n),r(null,t.cores)}!function(e,t){for(var r=[],i=[],a=0;a<e;++a){var o=new Worker(n);o.addEventListener("message",(function(n){if(i.push(n.data),i.length===e){for(var a=0;a<e;++a)r[a].terminate();t(null,i)}})),r.push(o)}for(a=0;a<e;++a)r[a].postMessage(a)}(o,(function(t,r){i.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var i=t[n],a=r[n]=[],o=0;o<e;++o)if(n!==o){var s=t[o];(i.st>s.st&&i.st<s.et||s.st>i.st&&s.st<i.et)&&a.push(o)}return r.reduce((function(e,t){return Math.max(e,t.length)}),0)}(o,r)),e(i,a-1,o)}))}([],5,16)}})),F.cipher=F.cipher||{},F.cipher.algorithms=F.cipher.algorithms||{},F.cipher.createCipher=function(e,t){var r=e;if("string"==typeof r&&(r=F.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new F.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},F.cipher.createDecipher=function(e,t){var r=e;if("string"==typeof r&&(r=F.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new F.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},F.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),F.cipher.algorithms[e]=t},F.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in F.cipher.algorithms?F.cipher.algorithms[e]:null};var H=F.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};function G(e,t){F.cipher.registerAlgorithm(e,(function(){return new F.aes.Algorithm(e,t)}))}H.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=F.util.createBuffer(),this.output=e.output||F.util.createBuffer(),this.mode.start(t)},H.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},H.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t)||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))},E((function(e){F.cipher=F.cipher||{};var t=e.exports=F.cipher.modes=F.cipher.modes||{};function r(e,t){if("string"==typeof e&&(e=F.util.createBuffer(e)),F.util.isArray(e)&&e.length>4){var r=e;e=F.util.createBuffer();for(var n=0;n<r.length;++n)e.putByte(r[n])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!F.util.isArray(e)){var i=[],a=t/4;for(n=0;n<a;++n)i.push(e.getInt32());e=i}return e}function n(e){e[e.length-1]=e[e.length-1]+1&4294967295}function i(e){return[e/4294967296|0,4294967295&e]}t.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},t.ecb.prototype.start=function(e){},t.ecb.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},t.ecb.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},t.ecb.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},t.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2||(e.truncate(n),0))},t.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},t.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},t.cbc.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^e.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]);this._prev=this._outBlock},t.cbc.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)},t.cbc.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},t.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2||(e.truncate(n),0))},t.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=F.util.createBuffer(),this._partialBytes=0},t.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32()^this._outBlock[i],t.putInt32(this._inBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;for(a>0&&(a=this.blockSize-a),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32(),t.putInt32(this._inBlock[i]^this._outBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;for(a>0&&(a=this.blockSize-a),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=F.util.createBuffer(),this._partialBytes=0},t.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];else{var a=(this.blockSize-n)%this.blockSize;for(a>0&&(a=this.blockSize-a),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.ofb.prototype.decrypt=t.ofb.prototype.encrypt,t.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=F.util.createBuffer(),this._partialBytes=0},t.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.ctr.prototype.encrypt=function(e,t,r){var i=e.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var a=0;a<this._ints;++a)t.putInt32(e.getInt32()^this._outBlock[a]);else{var o=(this.blockSize-i)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(o>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}n(this._inBlock)},t.ctr.prototype.decrypt=t.ctr.prototype.encrypt,t.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=F.util.createBuffer(),this._partialBytes=0,this._R=3774873600},t.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=F.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?F.util.createBuffer(e.additionalData):F.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=F.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var a=r.length();if(12===a)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(i(8*a)))}this._inBlock=this._j0.slice(0),n(this._inBlock),this._partialBytes=0,t=F.util.createBuffer(t),this._aDataLength=i(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},t.gcm.prototype.encrypt=function(e,t,r){var i=e.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize){for(var a=0;a<this._ints;++a)t.putInt32(this._outBlock[a]^=e.getInt32());this._cipherLength+=this.blockSize}else{var o=(this.blockSize-i)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(o<=0||r){if(r){var s=i%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(a=0;a<this._ints;++a)this._outBlock[a]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),n(this._inBlock)},t.gcm.prototype.decrypt=function(e,t,r){var i=e.length();if(i<this.blockSize&&!(r&&i>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),n(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var a=0;a<this._ints;++a)t.putInt32(this._outBlock[a]^this._hashBlock[a]);i<this.blockSize?this._cipherLength+=i%this.blockSize:this._cipherLength+=this.blockSize},t.gcm.prototype.afterFinish=function(e,t){var r=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=F.util.createBuffer();var n=this._aDataLength.concat(i(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,n);var a=[];this.cipher.encrypt(this._j0,a);for(var o=0;o<this._ints;++o)this.tag.putInt32(this._s[o]^a[o]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r},t.gcm.prototype.multiply=function(e,t){for(var r=[0,0,0,0],n=t.slice(0),i=0;i<128;++i)e[i/32|0]&1<<31-i%32&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n);return r},t.gcm.prototype.pow=function(e,t){for(var r=1&e[3],n=3;n>0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},t.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},t.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},t.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,a=new Array(i),o=0;o<i;++o){var s=[0,0,0,0],c=(n-1-o%n)*t;s[o/n|0]=1<<t-1<<c,a[o]=this.generateSubHashTable(this.multiply(s,e),t)}return a},t.gcm.prototype.generateSubHashTable=function(e,t){var r=1<<t,n=r>>>1,i=new Array(r);i[n]=e.slice(0);for(var a=n>>>1;a>0;)this.pow(i[2*a],i[a]=[]),a>>=1;for(a=2;a<n;){for(var o=1;o<a;++o){var s=i[a],c=i[o];i[a+o]=[s[0]^c[0],s[1]^c[1],s[2]^c[2],s[3]^c[3]]}a*=2}for(i[0]=[0,0,0,0],a=n+1;a<r;++a){var u=i[a^n];i[a]=[e[0]^u[0],e[1]^u[1],e[2]^u[2],e[3]^u[3]]}return i}})),F.aes=F.aes||{},F.aes.startEncrypting=function(e,t,r,n){var i=ne({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},F.aes.createEncryptionCipher=function(e,t){return ne({key:e,output:null,decrypt:!1,mode:t})},F.aes.startDecrypting=function(e,t,r,n){var i=ne({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},F.aes.createDecryptionCipher=function(e,t){return ne({key:e,output:null,decrypt:!0,mode:t})},F.aes.Algorithm=function(e,t){Z||ee();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return re(r._w,e,t,!1)},decrypt:function(e,t){return re(r._w,e,t,!0)}}}),r._init=!1},F.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(F.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=F.util.createBuffer();for(var n=0;n<t.length;++n)r.putByte(t[n])}}else r=F.util.createBuffer(r);if(!F.util.isArray(r)){t=r,r=[];var i=t.length();if(16===i||24===i||32===i)for(i>>>=2,n=0;n<i;++n)r.push(t.getInt32())}if(!F.util.isArray(r)||4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key parameter.");var a=this.mode.name,o=-1!==["CFB","OFB","CTR","GCM"].indexOf(a);this._w=te(r,e.decrypt&&!o),this._init=!0}},F.aes._expandKey=function(e,t){return Z||ee(),te(e,t)},F.aes._updateBlock=re,G("AES-ECB",F.cipher.modes.ecb),G("AES-CBC",F.cipher.modes.cbc),G("AES-CFB",F.cipher.modes.cfb),G("AES-OFB",F.cipher.modes.ofb),G("AES-CTR",F.cipher.modes.ctr),G("AES-GCM",F.cipher.modes.gcm);var Q,W,X,Y,$,Z=!1,J=4;function ee(){Z=!0,X=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;for(Q=new Array(256),W=new Array(256),Y=new Array(4),$=new Array(4),t=0;t<4;++t)Y[t]=new Array(256),$[t]=new Array(256);var r,n,i,a,o,s,c,u=0,l=0;for(t=0;t<256;++t){a=(a=l^l<<1^l<<2^l<<3^l<<4)>>8^255&a^99,Q[u]=a,W[a]=u,s=(o=e[a])<<24^a<<16^a<<8^a^o,c=((r=e[u])^(n=e[r])^(i=e[n]))<<24^(u^i)<<16^(u^n^i)<<8^u^r^i;for(var d=0;d<4;++d)Y[d][u]=s,$[d][a]=c,s=s<<24|s>>>8,c=c<<24|c>>>8;0===u?u=l=1:(u=r^e[e[e[r^i]]],l^=e[e[l]])}}function te(e,t){for(var r,n=e.slice(0),i=1,a=n.length,o=J*(a+6+1),s=a;s<o;++s)r=n[s-1],s%a==0?(r=Q[r>>>16&255]<<24^Q[r>>>8&255]<<16^Q[255&r]<<8^Q[r>>>24]^X[i]<<24,i++):a>6&&s%a==4&&(r=Q[r>>>24]<<24^Q[r>>>16&255]<<16^Q[r>>>8&255]<<8^Q[255&r]),n[s]=n[s-a]^r;if(t){for(var c,u=$[0],l=$[1],d=$[2],f=$[3],p=n.slice(0),h=(s=0,(o=n.length)-J);s<o;s+=J,h-=J)if(0===s||s===o-J)p[s]=n[h],p[s+1]=n[h+3],p[s+2]=n[h+2],p[s+3]=n[h+1];else for(var g=0;g<J;++g)c=n[h+g],p[s+(3&-g)]=u[Q[c>>>24]]^l[Q[c>>>16&255]]^d[Q[c>>>8&255]]^f[Q[255&c]];n=p}return n}function re(e,t,r,n){var i,a,o,s,c,u,l,d,f,p,h,g,m=e.length/4-1;n?(i=$[0],a=$[1],o=$[2],s=$[3],c=W):(i=Y[0],a=Y[1],o=Y[2],s=Y[3],c=Q),u=t[0]^e[0],l=t[n?3:1]^e[1],d=t[2]^e[2],f=t[n?1:3]^e[3];for(var y=3,v=1;v<m;++v)p=i[u>>>24]^a[l>>>16&255]^o[d>>>8&255]^s[255&f]^e[++y],h=i[l>>>24]^a[d>>>16&255]^o[f>>>8&255]^s[255&u]^e[++y],g=i[d>>>24]^a[f>>>16&255]^o[u>>>8&255]^s[255&l]^e[++y],f=i[f>>>24]^a[u>>>16&255]^o[l>>>8&255]^s[255&d]^e[++y],u=p,l=h,d=g;r[0]=c[u>>>24]<<24^c[l>>>16&255]<<16^c[d>>>8&255]<<8^c[255&f]^e[++y],r[n?3:1]=c[l>>>24]<<24^c[d>>>16&255]<<16^c[f>>>8&255]<<8^c[255&u]^e[++y],r[2]=c[d>>>24]<<24^c[f>>>16&255]<<16^c[u>>>8&255]<<8^c[255&l]^e[++y],r[n?1:3]=c[f>>>24]<<24^c[u>>>16&255]<<16^c[l>>>8&255]<<8^c[255&d]^e[++y]}function ne(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?F.cipher.createDecipher(r,e.key):F.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var i=null;r instanceof F.util.ByteBuffer&&(i=r,r={}),(r=r||{}).output=i,r.iv=e,n.call(t,r)},t}function ie(e,t){F.cipher.registerAlgorithm(e,(function(){return new F.des.Algorithm(e,t)}))}E((function(e){F.pki=F.pki||{};var t=e.exports=F.pki.oids=F.oids=F.oids||{};function r(e,r){t[e]=r,t[r]=e}function n(e,r){t[e]=r}r("1.2.840.113549.1.1.1","rsaEncryption"),r("1.2.840.113549.1.1.4","md5WithRSAEncryption"),r("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),r("1.2.840.113549.1.1.7","RSAES-OAEP"),r("1.2.840.113549.1.1.8","mgf1"),r("1.2.840.113549.1.1.9","pSpecified"),r("1.2.840.113549.1.1.10","RSASSA-PSS"),r("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),r("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),r("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),r("1.3.101.112","EdDSA25519"),r("1.2.840.10040.4.3","dsa-with-sha1"),r("1.3.14.3.2.7","desCBC"),r("1.3.14.3.2.26","sha1"),r("2.16.840.1.101.3.4.2.1","sha256"),r("2.16.840.1.101.3.4.2.2","sha384"),r("2.16.840.1.101.3.4.2.3","sha512"),r("1.2.840.113549.2.5","md5"),r("1.2.840.113549.1.7.1","data"),r("1.2.840.113549.1.7.2","signedData"),r("1.2.840.113549.1.7.3","envelopedData"),r("1.2.840.113549.1.7.4","signedAndEnvelopedData"),r("1.2.840.113549.1.7.5","digestedData"),r("1.2.840.113549.1.7.6","encryptedData"),r("1.2.840.113549.1.9.1","emailAddress"),r("1.2.840.113549.1.9.2","unstructuredName"),r("1.2.840.113549.1.9.3","contentType"),r("1.2.840.113549.1.9.4","messageDigest"),r("1.2.840.113549.1.9.5","signingTime"),r("1.2.840.113549.1.9.6","counterSignature"),r("1.2.840.113549.1.9.7","challengePassword"),r("1.2.840.113549.1.9.8","unstructuredAddress"),r("1.2.840.113549.1.9.14","extensionRequest"),r("1.2.840.113549.1.9.20","friendlyName"),r("1.2.840.113549.1.9.21","localKeyId"),r("1.2.840.113549.1.9.22.1","x509Certificate"),r("1.2.840.113549.1.12.10.1.1","keyBag"),r("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),r("1.2.840.113549.1.12.10.1.3","certBag"),r("1.2.840.113549.1.12.10.1.4","crlBag"),r("1.2.840.113549.1.12.10.1.5","secretBag"),r("1.2.840.113549.1.12.10.1.6","safeContentsBag"),r("1.2.840.113549.1.5.13","pkcs5PBES2"),r("1.2.840.113549.1.5.12","pkcs5PBKDF2"),r("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),r("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),r("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),r("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),r("1.2.840.113549.2.7","hmacWithSHA1"),r("1.2.840.113549.2.8","hmacWithSHA224"),r("1.2.840.113549.2.9","hmacWithSHA256"),r("1.2.840.113549.2.10","hmacWithSHA384"),r("1.2.840.113549.2.11","hmacWithSHA512"),r("1.2.840.113549.3.7","des-EDE3-CBC"),r("2.16.840.1.101.3.4.1.2","aes128-CBC"),r("2.16.840.1.101.3.4.1.22","aes192-CBC"),r("2.16.840.1.101.3.4.1.42","aes256-CBC"),r("2.5.4.3","commonName"),r("2.5.4.5","serialName"),r("2.5.4.6","countryName"),r("2.5.4.7","localityName"),r("2.5.4.8","stateOrProvinceName"),r("2.5.4.9","streetAddress"),r("2.5.4.10","organizationName"),r("2.5.4.11","organizationalUnitName"),r("2.5.4.13","description"),r("2.5.4.15","businessCategory"),r("2.5.4.17","postalCode"),r("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),r("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),r("2.16.840.1.113730.1.1","nsCertType"),r("2.16.840.1.113730.1.13","nsComment"),n("2.5.29.1","authorityKeyIdentifier"),n("2.5.29.2","keyAttributes"),n("2.5.29.3","certificatePolicies"),n("2.5.29.4","keyUsageRestriction"),n("2.5.29.5","policyMapping"),n("2.5.29.6","subtreesConstraint"),n("2.5.29.7","subjectAltName"),n("2.5.29.8","issuerAltName"),n("2.5.29.9","subjectDirectoryAttributes"),n("2.5.29.10","basicConstraints"),n("2.5.29.11","nameConstraints"),n("2.5.29.12","policyConstraints"),n("2.5.29.13","basicConstraints"),r("2.5.29.14","subjectKeyIdentifier"),r("2.5.29.15","keyUsage"),n("2.5.29.16","privateKeyUsagePeriod"),r("2.5.29.17","subjectAltName"),r("2.5.29.18","issuerAltName"),r("2.5.29.19","basicConstraints"),n("2.5.29.20","cRLNumber"),n("2.5.29.21","cRLReason"),n("2.5.29.22","expirationDate"),n("2.5.29.23","instructionCode"),n("2.5.29.24","invalidityDate"),n("2.5.29.25","cRLDistributionPoints"),n("2.5.29.26","issuingDistributionPoint"),n("2.5.29.27","deltaCRLIndicator"),n("2.5.29.28","issuingDistributionPoint"),n("2.5.29.29","certificateIssuer"),n("2.5.29.30","nameConstraints"),r("2.5.29.31","cRLDistributionPoints"),r("2.5.29.32","certificatePolicies"),n("2.5.29.33","policyMappings"),n("2.5.29.34","policyConstraints"),r("2.5.29.35","authorityKeyIdentifier"),n("2.5.29.36","policyConstraints"),r("2.5.29.37","extKeyUsage"),n("2.5.29.46","freshestCRL"),n("2.5.29.54","inhibitAnyPolicy"),r("1.3.6.1.4.1.11129.2.4.2","timestampList"),r("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),r("1.3.6.1.5.5.7.3.1","serverAuth"),r("1.3.6.1.5.5.7.3.2","clientAuth"),r("1.3.6.1.5.5.7.3.3","codeSigning"),r("1.3.6.1.5.5.7.3.4","emailProtection"),r("1.3.6.1.5.5.7.3.8","timeStamping")})),E((function(e){var t=e.exports=F.asn1=F.asn1||{};function r(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}t.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},t.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},t.create=function(e,r,n,i,a){if(F.util.isArray(i)){for(var o=[],s=0;s<i.length;++s)void 0!==i[s]&&o.push(i[s]);i=o}var c={tagClass:e,type:r,constructed:n,composed:n||F.util.isArray(i),value:i};return a&&"bitStringContents"in a&&(c.bitStringContents=a.bitStringContents,c.original=t.copy(c)),c},t.copy=function(e,r){var n;if(F.util.isArray(e)){n=[];for(var i=0;i<e.length;++i)n.push(t.copy(e[i],r));return n}return"string"==typeof e?e:(n={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:t.copy(e.value,r)},r&&!r.excludeBitStringContents&&(n.bitStringContents=e.bitStringContents),n)},t.equals=function(e,r,n){if(F.util.isArray(e)){if(!F.util.isArray(r))return!1;if(e.length!==r.length)return!1;for(var i=0;i<e.length;++i)if(!t.equals(e[i],r[i]))return!1;return!0}if(typeof e!=typeof r)return!1;if("string"==typeof e)return e===r;var a=e.tagClass===r.tagClass&&e.type===r.type&&e.constructed===r.constructed&&e.composed===r.composed&&t.equals(e.value,r.value);return n&&n.includeBitStringContents&&(a=a&&e.bitStringContents===r.bitStringContents),a},t.getBerValueLength=function(e){var t=e.getByte();if(128!==t)return 128&t?e.getInt((127&t)<<3):t};var n=function(e,t){var n=e.getByte();if(t--,128!==n){var i;if(128&n){var a=127&n;r(e,t,a),i=e.getInt(a<<3)}else i=n;if(i<0)throw new Error("Negative length: "+i);return i}};t.fromDer=function(e,i){return void 0===i&&(i={strict:!0,decodeBitStrings:!0}),"boolean"==typeof i&&(i={strict:i,decodeBitStrings:!0}),"strict"in i||(i.strict=!0),"decodeBitStrings"in i||(i.decodeBitStrings=!0),"string"==typeof e&&(e=F.util.createBuffer(e)),function e(i,a,o,s){var c;r(i,a,2);var u=i.getByte();a--;var l=192&u,d=31&u;c=i.length();var f,p,h=n(i,a);if(a-=c-i.length(),void 0!==h&&h>a){if(s.strict){var g=new Error("Too few bytes to read ASN.1 value.");throw g.available=i.length(),g.remaining=a,g.requested=h,g}h=a}var m=32==(32&u);if(m)if(f=[],void 0===h)for(;;){if(r(i,a,2),i.bytes(2)===String.fromCharCode(0,0)){i.getBytes(2),a-=2;break}c=i.length(),f.push(e(i,a,o+1,s)),a-=c-i.length()}else for(;h>0;)c=i.length(),f.push(e(i,h,o+1,s)),a-=c-i.length(),h-=c-i.length();if(void 0===f&&l===t.Class.UNIVERSAL&&d===t.Type.BITSTRING&&(p=i.bytes(h)),void 0===f&&s.decodeBitStrings&&l===t.Class.UNIVERSAL&&d===t.Type.BITSTRING&&h>1){var y=i.read,v=a,b=0;if(d===t.Type.BITSTRING&&(r(i,a,1),b=i.getByte(),a--),0===b)try{c=i.length();var C=e(i,a,o+1,{verbose:s.verbose,strict:!0,decodeBitStrings:!0}),E=c-i.length();a-=E,d==t.Type.BITSTRING&&E++;var w=C.tagClass;E!==h||w!==t.Class.UNIVERSAL&&w!==t.Class.CONTEXT_SPECIFIC||(f=[C])}catch(e){}void 0===f&&(i.read=y,a=v)}if(void 0===f){if(void 0===h){if(s.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");h=a}if(d===t.Type.BMPSTRING)for(f="";h>0;h-=2)r(i,a,2),f+=String.fromCharCode(i.getInt16()),a-=2;else f=i.getBytes(h)}var k=void 0===p?null:{bitStringContents:p};return t.create(l,d,m,f,k)}(e,e.length(),0,i)},t.toDer=function(e){var r=F.util.createBuffer(),n=e.tagClass|e.type,i=F.util.createBuffer(),a=!1;if("bitStringContents"in e&&(a=!0,e.original&&(a=t.equals(e,e.original))),a)i.putBytes(e.bitStringContents);else if(e.composed){e.constructed?n|=32:i.putByte(0);for(var o=0;o<e.value.length;++o)void 0!==e.value[o]&&i.putBuffer(t.toDer(e.value[o]))}else if(e.type===t.Type.BMPSTRING)for(o=0;o<e.value.length;++o)i.putInt16(e.value.charCodeAt(o));else e.type===t.Type.INTEGER&&e.value.length>1&&(0===e.value.charCodeAt(0)&&0==(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128==(128&e.value.charCodeAt(1)))?i.putBytes(e.value.substr(1)):i.putBytes(e.value);if(r.putByte(n),i.length()<=127)r.putByte(127&i.length());else{var s=i.length(),c="";do{c+=String.fromCharCode(255&s),s>>>=8}while(s>0);for(r.putByte(128|c.length),o=c.length-1;o>=0;--o)r.putByte(c.charCodeAt(o))}return r.putBuffer(i),r},t.oidToDer=function(e){var t,r,n,i,a=e.split("."),o=F.util.createBuffer();o.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var s=2;s<a.length;++s){t=!0,r=[],n=parseInt(a[s],10);do{i=127&n,n>>>=7,t||(i|=128),r.push(i),t=!1}while(n>0);for(var c=r.length-1;c>=0;--c)o.putByte(r[c])}return o},t.derToOid=function(e){var t;"string"==typeof e&&(e=F.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var n=0;e.length()>0;)n<<=7,128&(r=e.getByte())?n+=127&r:(t+="."+(n+r),n=0);return t},t.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),a=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),s=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(s=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(a,o,s,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},t.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),o=parseInt(e.substr(10,2),10),s=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var d=e.length-5,f=e.charAt(d);return"+"!==f&&"-"!==f||(u=60*parseInt(e.substr(d+1,2),10)+parseInt(e.substr(d+4,2),10),u*=6e4,"+"===f&&(u*=-1),l=!0),"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(a,o,s,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(a,o,s,c)),t},t.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+"Z"},t.dateToGeneralizedTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push(""+e.getUTCFullYear()),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+"Z"},t.integerToDer=function(e){var t=F.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},t.derToInteger=function(e){"string"==typeof e&&(e=F.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},t.validate=function(e,r,n,i){var a=!1;if(e.tagClass!==r.tagClass&&void 0!==r.tagClass||e.type!==r.type&&void 0!==r.type)i&&(e.tagClass!==r.tagClass&&i.push("["+r.name+'] Expected tag class "'+r.tagClass+'", got "'+e.tagClass+'"'),e.type!==r.type&&i.push("["+r.name+'] Expected type "'+r.type+'", got "'+e.type+'"'));else if(e.constructed===r.constructed||void 0===r.constructed){if(a=!0,r.value&&F.util.isArray(r.value))for(var o=0,s=0;a&&s<r.value.length;++s)a=r.value[s].optional||!1,e.value[o]&&((a=t.validate(e.value[o],r.value[s],n,i))?++o:r.value[s].optional&&(a=!0)),!a&&i&&i.push("["+r.name+'] Tag class "'+r.tagClass+'", type "'+r.type+'" expected value length "'+r.value.length+'", got "'+e.value.length+'"');if(a&&n&&(r.capture&&(n[r.capture]=e.value),r.captureAsn1&&(n[r.captureAsn1]=e),r.captureBitStringContents&&"bitStringContents"in e&&(n[r.captureBitStringContents]=e.bitStringContents),r.captureBitStringValue&&"bitStringContents"in e))if(e.bitStringContents.length<2)n[r.captureBitStringValue]="";else{if(0!==e.bitStringContents.charCodeAt(0))throw new Error("captureBitStringValue only supported for zero unused bits");n[r.captureBitStringValue]=e.bitStringContents.slice(1)}}else i&&i.push("["+r.name+'] Expected constructed "'+r.constructed+'", got "'+e.constructed+'"');return a};var i=/[^\\u0000-\\u00ff]/;t.prettyPrint=function(e,r,n){var a="";n=n||2,(r=r||0)>0&&(a+="\n");for(var o="",s=0;s<r*n;++s)o+=" ";switch(a+=o+"Tag: ",e.tagClass){case t.Class.UNIVERSAL:a+="Universal:";break;case t.Class.APPLICATION:a+="Application:";break;case t.Class.CONTEXT_SPECIFIC:a+="Context-Specific:";break;case t.Class.PRIVATE:a+="Private:"}if(e.tagClass===t.Class.UNIVERSAL)switch(a+=e.type,e.type){case t.Type.NONE:a+=" (None)";break;case t.Type.BOOLEAN:a+=" (Boolean)";break;case t.Type.INTEGER:a+=" (Integer)";break;case t.Type.BITSTRING:a+=" (Bit string)";break;case t.Type.OCTETSTRING:a+=" (Octet string)";break;case t.Type.NULL:a+=" (Null)";break;case t.Type.OID:a+=" (Object Identifier)";break;case t.Type.ODESC:a+=" (Object Descriptor)";break;case t.Type.EXTERNAL:a+=" (External or Instance of)";break;case t.Type.REAL:a+=" (Real)";break;case t.Type.ENUMERATED:a+=" (Enumerated)";break;case t.Type.EMBEDDED:a+=" (Embedded PDV)";break;case t.Type.UTF8:a+=" (UTF8)";break;case t.Type.ROID:a+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:a+=" (Sequence)";break;case t.Type.SET:a+=" (Set)";break;case t.Type.PRINTABLESTRING:a+=" (Printable String)";break;case t.Type.IA5String:a+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:a+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:a+=" (Generalized time)";break;case t.Type.BMPSTRING:a+=" (BMP String)"}else a+=e.type;if(a+="\n",a+=o+"Constructed: "+e.constructed+"\n",e.composed){var c=0,u="";for(s=0;s<e.value.length;++s)void 0!==e.value[s]&&(c+=1,u+=t.prettyPrint(e.value[s],r+1,n),s+1<e.value.length&&(u+=","));a+=o+"Sub values: "+c+u}else{if(a+=o+"Value: ",e.type===t.Type.OID){var l=t.derToOid(e.value);a+=l,F.pki&&F.pki.oids&&l in F.pki.oids&&(a+=" ("+F.pki.oids[l]+") ")}if(e.type===t.Type.INTEGER)try{a+=t.derToInteger(e.value)}catch(t){a+="0x"+F.util.bytesToHex(e.value)}else if(e.type===t.Type.BITSTRING){if(e.value.length>1?a+="0x"+F.util.bytesToHex(e.value.slice(1)):a+="(none)",e.value.length>0){var d=e.value.charCodeAt(0);1==d?a+=" (1 unused bit shown)":d>1&&(a+=" ("+d+" unused bits shown)")}}else e.type===t.Type.OCTETSTRING?(i.test(e.value)||(a+="("+e.value+") "),a+="0x"+F.util.bytesToHex(e.value)):e.type===t.Type.UTF8?a+=F.util.decodeUtf8(e.value):e.type===t.Type.PRINTABLESTRING||e.type===t.Type.IA5String?a+=e.value:i.test(e.value)?a+="0x"+F.util.bytesToHex(e.value):0===e.value.length?a+="[null]":a+=e.value}return a}})),F.md=F.md||{},F.md.algorithms=F.md.algorithms||{},E((function(e){(e.exports=F.hmac=F.hmac||{}).create=function(){var e=null,t=null,r=null,n=null,i={start:function(i,a){if(null!==i)if("string"==typeof i){if(!((i=i.toLowerCase())in F.md.algorithms))throw new Error('Unknown hash algorithm "'+i+'"');t=F.md.algorithms[i].create()}else t=i;if(null===a)a=e;else{if("string"==typeof a)a=F.util.createBuffer(a);else if(F.util.isArray(a)){var o=a;a=F.util.createBuffer();for(var s=0;s<o.length;++s)a.putByte(o[s])}var c=a.length();for(c>t.blockLength&&(t.start(),t.update(a.bytes()),a=t.digest()),r=F.util.createBuffer(),n=F.util.createBuffer(),c=a.length(),s=0;s<c;++s)o=a.at(s),r.putByte(54^o),n.putByte(92^o);if(c<t.blockLength)for(o=t.blockLength-c,s=0;s<o;++s)r.putByte(54),n.putByte(92);e=a,r=r.bytes(),n=n.bytes()}t.start(),t.update(r)},update:function(e){t.update(e)},getMac:function(){var e=t.digest().bytes();return t.start(),t.update(n),t.update(e),t.digest()}};return i.digest=i.getMac,i}})),E((function(e){var t=e.exports=F.md5=F.md5||{};F.md.md5=F.md.algorithms.md5=t,t.create=function(){o||function(){r=String.fromCharCode(128),r+=F.util.fillString(String.fromCharCode(0),64),n=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],i=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],a=new Array(64);for(var e=0;e<64;++e)a[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));o=!0}();var e=null,t=F.util.createBuffer(),c=new Array(16),u={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){u.messageLength=0,u.fullMessageLength=u.messageLength64=[];for(var r=u.messageLengthSize/4,n=0;n<r;++n)u.fullMessageLength.push(0);return t=F.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},u}};return u.start(),u.update=function(r,n){"utf8"===n&&(r=F.util.encodeUtf8(r));var i=r.length;u.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var a=u.fullMessageLength.length-1;a>=0;--a)u.fullMessageLength[a]+=i[1],i[1]=i[0]+(u.fullMessageLength[a]/4294967296>>>0),u.fullMessageLength[a]=u.fullMessageLength[a]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(r),s(e,c,t),(t.read>2048||0===t.length())&&t.compact(),u},u.digest=function(){var n=F.util.createBuffer();n.putBytes(t.bytes());var i=u.fullMessageLength[u.fullMessageLength.length-1]+u.messageLengthSize&u.blockLength-1;n.putBytes(r.substr(0,u.blockLength-i));for(var a,o=0,l=u.fullMessageLength.length-1;l>=0;--l)o=(a=8*u.fullMessageLength[l]+o)/4294967296>>>0,n.putInt32Le(a>>>0);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};s(d,c,n);var f=F.util.createBuffer();return f.putInt32Le(d.h0),f.putInt32Le(d.h1),f.putInt32Le(d.h2),f.putInt32Le(d.h3),f},u};var r=null,n=null,i=null,a=null,o=!1;function s(e,t,r){for(var o,s,c,u,l,d,f,p=r.length();p>=64;){for(s=e.h0,c=e.h1,u=e.h2,l=e.h3,f=0;f<16;++f)t[f]=r.getInt32Le(),o=s+(l^c&(u^l))+a[f]+t[f],s=l,l=u,u=c,c+=o<<(d=i[f])|o>>>32-d;for(;f<32;++f)o=s+(u^l&(c^u))+a[f]+t[n[f]],s=l,l=u,u=c,c+=o<<(d=i[f])|o>>>32-d;for(;f<48;++f)o=s+(c^u^l)+a[f]+t[n[f]],s=l,l=u,u=c,c+=o<<(d=i[f])|o>>>32-d;for(;f<64;++f)o=s+(u^(c|~l))+a[f]+t[n[f]],s=l,l=u,u=c,c+=o<<(d=i[f])|o>>>32-d;e.h0=e.h0+s|0,e.h1=e.h1+c|0,e.h2=e.h2+u|0,e.h3=e.h3+l|0,p-=64}}})),E((function(e){var t=e.exports=F.pem=F.pem||{};function r(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i<e.values.length;++i)r.push(e.values[i].replace(/^(\S+\r\n)/,n));t+=r.join(",")+"\r\n";var a=0,o=-1;for(i=0;i<t.length;++i,++a)if(a>65&&-1!==o){var s=t[o];","===s?(++o,t=t.substr(0,o)+"\r\n "+t.substr(o)):t=t.substr(0,o)+"\r\n"+s+t.substr(o+1),a=i-o-1,o=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(o=i);return t}function n(e){return e.replace(/^\s+/,"")}t.encode=function(e,t){t=t||{};var n,i="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(i+=r(n={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=r(n={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(n={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&n.values.push(e.dekInfo.parameters),i+=r(n)),e.headers)for(var a=0;a<e.headers.length;++a)i+=r(e.headers[a]);return e.procType&&(i+="\r\n"),(i+=F.util.encode64(e.body,t.maxline||64)+"\r\n")+"-----END "+e.type+"-----\r\n"},t.decode=function(e){for(var t,r=[],i=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,a=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,o=/\r?\n/;t=i.exec(e);){var s={type:t[1],procType:null,contentDomain:null,dekInfo:null,headers:[],body:F.util.decode64(t[3])};if(r.push(s),t[2]){for(var c=t[2].split(o),u=0;t&&u<c.length;){for(var l=c[u].replace(/\s+$/,""),d=u+1;d<c.length;++d){var f=c[d];if(!/\s/.test(f[0]))break;l+=f,u=d}if(t=l.match(a)){for(var p={name:t[1],values:[]},h=t[2].split(","),g=0;g<h.length;++g)p.values.push(n(h[g]));if(s.procType)if(s.contentDomain||"Content-Domain"!==p.name)if(s.dekInfo||"DEK-Info"!==p.name)s.headers.push(p);else{if(0===p.values.length)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');s.dekInfo={algorithm:h[0],parameters:h[1]||null}}else s.contentDomain=h[0]||"";else{if("Proc-Type"!==p.name)throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==p.values.length)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');s.procType={version:h[0],type:h[1]}}}++u}if("ENCRYPTED"===s.procType&&!s.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(0===r.length)throw new Error("Invalid PEM formatted message.");return r}})),F.des=F.des||{},F.des.startEncrypting=function(e,t,r,n){var i=he({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},F.des.createEncryptionCipher=function(e,t){return he({key:e,output:null,decrypt:!1,mode:t})},F.des.startDecrypting=function(e,t,r,n){var i=he({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},F.des.createDecryptionCipher=function(e,t){return he({key:e,output:null,decrypt:!0,mode:t})},F.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return pe(r._keys,e,t,!1)},decrypt:function(e,t){return pe(r._keys,e,t,!0)}}}),r._init=!1},F.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=F.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],a=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],o=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],s=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],d=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],p=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],h=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],m=e.length()>8?3:1,y=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,C=0;C<m;C++){var E=e.getInt32(),w=e.getInt32();E^=(t=252645135&(E>>>4^w))<<4,E^=t=65535&((w^=t)>>>-16^E),E^=(t=858993459&(E>>>2^(w^=t<<-16)))<<2,E^=t=65535&((w^=t)>>>-16^E),E^=(t=1431655765&(E>>>1^(w^=t<<-16)))<<1,E^=t=16711935&((w^=t)>>>8^E),t=(E^=(t=1431655765&(E>>>1^(w^=t<<8)))<<1)<<8|(w^=t)>>>20&240,E=w<<24|w<<8&16711680|w>>>8&65280|w>>>24&240,w=t;for(var k=0;k<v.length;++k){v[k]?(E=E<<2|E>>>26,w=w<<2|w>>>26):(E=E<<1|E>>>27,w=w<<1|w>>>27);var S=r[(E&=-15)>>>28]|n[E>>>24&15]|i[E>>>20&15]|a[E>>>16&15]|o[E>>>12&15]|s[E>>>8&15]|c[E>>>4&15],B=u[(w&=-15)>>>28]|l[w>>>24&15]|d[w>>>20&15]|f[w>>>16&15]|p[w>>>12&15]|h[w>>>8&15]|g[w>>>4&15];t=65535&(B>>>16^S),y[b++]=S^t,y[b++]=B^t<<16}}return y}(t),this._init=!0}},ie("DES-ECB",F.cipher.modes.ecb),ie("DES-CBC",F.cipher.modes.cbc),ie("DES-CFB",F.cipher.modes.cfb),ie("DES-OFB",F.cipher.modes.ofb),ie("DES-CTR",F.cipher.modes.ctr),ie("3DES-ECB",F.cipher.modes.ecb),ie("3DES-CBC",F.cipher.modes.cbc),ie("3DES-CFB",F.cipher.modes.cfb),ie("3DES-OFB",F.cipher.modes.ofb),ie("3DES-CTR",F.cipher.modes.ctr);var ae=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],oe=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],se=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],ce=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],ue=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],le=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],de=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],fe=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function pe(e,t,r,n){var i,a,o=32===e.length?3:9;i=3===o?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var s=t[0],c=t[1];s^=(a=252645135&(s>>>4^c))<<4,s^=(a=65535&(s>>>16^(c^=a)))<<16,s^=a=858993459&((c^=a)>>>2^s),s^=a=16711935&((c^=a<<2)>>>8^s),s=(s^=(a=1431655765&(s>>>1^(c^=a<<8)))<<1)<<1|s>>>31,c=(c^=a)<<1|c>>>31;for(var u=0;u<o;u+=3){for(var l=i[u+1],d=i[u+2],f=i[u];f!=l;f+=d){var p=c^e[f],h=(c>>>4|c<<28)^e[f+1];a=s,s=c,c=a^(oe[p>>>24&63]|ce[p>>>16&63]|le[p>>>8&63]|fe[63&p]|ae[h>>>24&63]|se[h>>>16&63]|ue[h>>>8&63]|de[63&h])}a=s,s=c,c=a}c=c>>>1|c<<31,c^=a=1431655765&((s=s>>>1|s<<31)>>>1^c),c^=(a=16711935&(c>>>8^(s^=a<<1)))<<8,c^=(a=858993459&(c>>>2^(s^=a)))<<2,c^=a=65535&((s^=a)>>>16^c),c^=a=252645135&((s^=a<<16)>>>4^c),s^=a<<4,r[0]=s,r[1]=c}function he(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?F.cipher.createDecipher(r,e.key):F.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var i=null;r instanceof F.util.ByteBuffer&&(i=r,r={}),(r=r||{}).output=i,r.iv=e,n.call(t,r)},t}var ge,me=F.pkcs5=F.pkcs5||{};F.util.isNodejs&&!F.options.usePureJavaScript&&(ge=t),F.pbkdf2=me.pbkdf2=function(e,t,r,n,i,a){if("function"==typeof i&&(a=i,i=null),F.util.isNodejs&&!F.options.usePureJavaScript&&ge.pbkdf2&&(null===i||"object"!=typeof i)&&(ge.pbkdf2Sync.length>4||!i||"sha1"===i))return"string"!=typeof i&&(i="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),a?4===ge.pbkdf2Sync.length?ge.pbkdf2(e,t,r,n,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):ge.pbkdf2(e,t,r,n,i,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):4===ge.pbkdf2Sync.length?ge.pbkdf2Sync(e,t,r,n).toString("binary"):ge.pbkdf2Sync(e,t,r,n,i).toString("binary");if(null==i&&(i="sha1"),"string"==typeof i){if(!(i in F.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=F.md[i].create()}var o=i.digestLength;if(n>4294967295*o){var s=new Error("Derived key is too long.");if(a)return a(s);throw s}var c=Math.ceil(n/o),u=n-(c-1)*o,l=F.hmac.create();l.start(i,e);var d,f,p,h="";if(!a){for(var g=1;g<=c;++g){l.start(null,null),l.update(t),l.update(F.util.int32ToBytes(g)),d=p=l.digest().getBytes();for(var m=2;m<=r;++m)l.start(null,null),l.update(p),f=l.digest().getBytes(),d=F.util.xorBytes(d,f,o),p=f;h+=g<c?d:d.substr(0,u)}return h}function y(){if(g>c)return a(null,h);l.start(null,null),l.update(t),l.update(F.util.int32ToBytes(g)),d=p=l.digest().getBytes(),m=2,v()}function v(){if(m<=r)return l.start(null,null),l.update(p),f=l.digest().getBytes(),d=F.util.xorBytes(d,f,o),p=f,++m,F.util.setImmediate(v);h+=g<c?d:d.substr(0,u),++g,y()}g=1,y()},E((function(e){var t=e.exports=F.sha256=F.sha256||{};F.md.sha256=F.md.algorithms.sha256=t,t.create=function(){n||(r=String.fromCharCode(128),r+=F.util.fillString(String.fromCharCode(0),64),i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=!0);var e=null,t=F.util.createBuffer(),o=new Array(64),s={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){s.messageLength=0,s.fullMessageLength=s.messageLength64=[];for(var r=s.messageLengthSize/4,n=0;n<r;++n)s.fullMessageLength.push(0);return t=F.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},s}};return s.start(),s.update=function(r,n){"utf8"===n&&(r=F.util.encodeUtf8(r));var i=r.length;s.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var c=s.fullMessageLength.length-1;c>=0;--c)s.fullMessageLength[c]+=i[1],i[1]=i[0]+(s.fullMessageLength[c]/4294967296>>>0),s.fullMessageLength[c]=s.fullMessageLength[c]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(r),a(e,o,t),(t.read>2048||0===t.length())&&t.compact(),s},s.digest=function(){var n=F.util.createBuffer();n.putBytes(t.bytes());var i,c=s.fullMessageLength[s.fullMessageLength.length-1]+s.messageLengthSize&s.blockLength-1;n.putBytes(r.substr(0,s.blockLength-c));for(var u=8*s.fullMessageLength[0],l=0;l<s.fullMessageLength.length-1;++l)u+=(i=8*s.fullMessageLength[l+1])/4294967296>>>0,n.putInt32(u>>>0),u=i>>>0;n.putInt32(u);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};a(d,o,n);var f=F.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f.putInt32(d.h5),f.putInt32(d.h6),f.putInt32(d.h7),f},s};var r=null,n=!1,i=null;function a(e,t,r){for(var n,a,o,s,c,u,l,d,f,p,h,g,m,y=r.length();y>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,a=((a=t[c-15])>>>7|a<<25)^(a>>>18|a<<14)^a>>>3,t[c]=n+t[c-7]+a+t[c-16]|0;for(u=e.h0,l=e.h1,d=e.h2,f=e.h3,p=e.h4,h=e.h5,g=e.h6,m=e.h7,c=0;c<64;++c)o=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&l|d&(u^l),n=m+((p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(g^p&(h^g))+i[c]+t[c],m=g,g=h,h=p,p=f+n>>>0,f=d,d=l,l=u,u=n+(a=o+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+d|0,e.h3=e.h3+f|0,e.h4=e.h4+p|0,e.h5=e.h5+h|0,e.h6=e.h6+g|0,e.h7=e.h7+m|0,y-=64}}})),E((function(e){var r=null;!F.util.isNodejs||F.options.usePureJavaScript||process.versions["node-webkit"]||(r=t),(e.exports=F.prng=F.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},n=e.md,i=new Array(32),a=0;a<32;++a)i[a]=n.create();function o(){if(t.pools[0].messageLength>=32)return s();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),s()}function s(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r==0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function c(e){var t=null,r=F.util.globalScope,n=r.crypto||r.msCrypto;n&&n.getRandomValues&&(t=function(e){return n.getRandomValues(e)});var i=F.util.createBuffer();if(t)for(;i.length()<e;){var a=Math.max(1,Math.min(e-i.length(),65536)/4),o=new Uint32Array(Math.floor(a));try{t(o);for(var s=0;s<o.length;++s)i.putInt32(o[s])}catch(e){if(!("undefined"!=typeof QuotaExceededError&&e instanceof QuotaExceededError))throw e}}if(i.length()<e)for(var c,u,l,d=Math.floor(65536*Math.random());i.length()<e;)for(u=16807*(65535&d),u+=(32767&(c=16807*(d>>16)))<<16,d=4294967295&(u=(2147483647&(u+=c>>15))+(u>>31)),s=0;s<3;++s)l=d>>>(s<<3),l^=Math.floor(256*Math.random()),i.putByte(String.fromCharCode(255&l));return i.getBytes(e)}return t.pools=i,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var n=t.plugin.cipher,i=t.plugin.increment,a=t.plugin.formatKey,o=t.plugin.formatSeed,c=F.util.createBuffer();t.key=null,function u(l){if(l)return r(l);if(c.length()>=e)return r(null,c.getBytes(e));if(t.generated>1048575&&(t.key=null),null===t.key)return F.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return s(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),s(),e()}))}(u)}));var d=n(t.key,t.seed);t.generated+=d.length,c.putBytes(d),t.key=a(n(t.key,i(t.seed))),t.seed=o(n(t.key,t.seed)),F.util.setImmediate(u)}()},t.generateSync=function(e){var r=t.plugin.cipher,n=t.plugin.increment,i=t.plugin.formatKey,a=t.plugin.formatSeed;t.key=null;for(var s=F.util.createBuffer();s.length()<e;){t.generated>1048575&&(t.key=null),null===t.key&&o();var c=r(t.key,t.seed);t.generated+=c.length,s.putBytes(c),t.key=i(r(t.key,n(t.seed))),t.seed=a(r(t.key,t.seed))}return s.getBytes(e)},r?(t.seedFile=function(e,t){r.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return r.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,c(e))}catch(e){t(e)}},t.seedFileSync=c),t.collect=function(e){for(var r=e.length,n=0;n<r;++n)t.pools[t.pool].update(e.substr(n,1)),t.pool=31===t.pool?0:t.pool+1},t.collectInt=function(e,r){for(var n="",i=0;i<r;i+=8)n+=String.fromCharCode(e>>i&255);t.collect(n)},t.registerWorker=function(e){e===self?t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})}:e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))},t}})),E((function(e){F.random&&F.random.getBytes?e.exports=F.random:function(t){var r={},n=new Array(4),i=F.util.createBuffer();function a(){var e=F.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=F.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),F.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=F.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return F.aes._updateBlock(e,t,n,!1),i.putInt32(n[0]),i.putInt32(n[1]),i.putInt32(n[2]),i.putInt32(n[3]),i.getBytes()},r.increment=function(e){return++e[3],e},r.md=F.md.sha256;var o=a(),s=null,c=F.util.globalScope,u=c.crypto||c.msCrypto;if(u&&u.getRandomValues&&(s=function(e){return u.getRandomValues(e)}),!F.util.isNodejs&&!s){if(o.collectInt(+new Date,32),"undefined"!=typeof navigator){var l="";for(var d in navigator)try{"string"==typeof navigator[d]&&(l+=navigator[d])}catch(e){}o.collect(l),l=null}t&&(t().mousemove((function(e){o.collectInt(e.clientX,16),o.collectInt(e.clientY,16)})),t().keypress((function(e){o.collectInt(e.charCode,8)})))}if(F.random)for(var d in o)F.random[d]=o[d];else F.random=o;F.random.createInstance=a,e.exports=F.random}("undefined"!=typeof jQuery?jQuery:null)}));var ye=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],ve=[1,2,3,5],be=function(e,t){return e<<t&65535|(65535&e)>>16-t},Ce=function(e,t){return(65535&e)>>t|e<<16-t&65535};F.rc2=F.rc2||{},F.rc2.expandKey=function(e,t){"string"==typeof e&&(e=F.util.createBuffer(e)),t=t||128;var r,n=e,i=e.length(),a=t,o=Math.ceil(a/8),s=255>>(7&a);for(r=i;r<128;r++)n.putByte(ye[n.at(r-1)+n.at(r-i)&255]);for(n.setAt(128-o,ye[n.at(128-o)&s]),r=127-o;r>=0;r--)n.setAt(r,ye[n.at(r+1)^n.at(r+o)]);return n};var Ee,we=function(e,t,r){var n,i,a,o,s=!1,c=null,u=null,l=null,d=[];for(e=F.rc2.expandKey(e,t),a=0;a<64;a++)d.push(e.getInt16Le());r?(n=function(e){for(a=0;a<4;a++)e[a]+=d[o]+(e[(a+3)%4]&e[(a+2)%4])+(~e[(a+3)%4]&e[(a+1)%4]),e[a]=be(e[a],ve[a]),o++},i=function(e){for(a=0;a<4;a++)e[a]+=d[63&e[(a+3)%4]]}):(n=function(e){for(a=3;a>=0;a--)e[a]=Ce(e[a],ve[a]),e[a]-=d[o]+(e[(a+3)%4]&e[(a+2)%4])+(~e[(a+3)%4]&e[(a+1)%4]),o--},i=function(e){for(a=3;a>=0;a--)e[a]-=d[63&e[(a+3)%4]]});var f=function(e){var t=[];for(a=0;a<4;a++){var n=c.getInt16Le();null!==l&&(r?n^=l.getInt16Le():l.putInt16Le(n)),t.push(65535&n)}o=r?0:63;for(var i=0;i<e.length;i++)for(var s=0;s<e[i][0];s++)e[i][1](t);for(a=0;a<4;a++)null!==l&&(r?l.putInt16Le(t[a]):t[a]^=l.getInt16Le()),u.putInt16Le(t[a])},p=null;return p={start:function(e,t){e&&"string"==typeof e&&(e=F.util.createBuffer(e)),s=!1,c=F.util.createBuffer(),u=t||new F.util.createBuffer,l=e,p.output=u},update:function(e){for(s||c.putBuffer(e);c.length()>=8;)f([[5,n],[1,i],[6,n],[1,i],[5,n]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,c,!r);else{var n=8===c.length()?8:8-c.length();c.fillWithByte(n,n)}if(t&&(s=!0,p.update()),!r&&(t=0===c.length()))if(e)t=e(8,u,!r);else{var i=u.length(),a=u.at(i-1);a>i?t=!1:u.truncate(a)}return t}}};function ke(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function Se(){return new ke(null)}function Be(e,t,r,n,i,a){for(var o=16383&t,s=t>>14;--a>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=s*c+u*o;i=((c=o*c+((16383&l)<<14)+r.data[n]+i)>>28)+(l>>14)+s*u,r.data[n++]=268435455&c}return i}F.rc2.startEncrypting=function(e,t,r){var n=F.rc2.createEncryptionCipher(e,128);return n.start(t,r),n},F.rc2.createEncryptionCipher=function(e,t){return we(e,t,!0)},F.rc2.startDecrypting=function(e,t,r){var n=F.rc2.createDecryptionCipher(e,128);return n.start(t,r),n},F.rc2.createDecryptionCipher=function(e,t){return we(e,t,!1)},F.jsbn=F.jsbn||{},F.jsbn.BigInteger=ke,"undefined"==typeof navigator?(ke.prototype.am=Be,Ee=28):"Microsoft Internet Explorer"==navigator.appName?(ke.prototype.am=function(e,t,r,n,i,a){for(var o=32767&t,s=t>>15;--a>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=s*c+u*o;i=((c=o*c+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+s*u+(i>>>30),r.data[n++]=1073741823&c}return i},Ee=30):"Netscape"!=navigator.appName?(ke.prototype.am=function(e,t,r,n,i,a){for(;--a>=0;){var o=t*this.data[e++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=67108863&o}return i},Ee=26):(ke.prototype.am=Be,Ee=28),ke.prototype.DB=Ee,ke.prototype.DM=(1<<Ee)-1,ke.prototype.DV=1<<Ee,ke.prototype.FV=Math.pow(2,52),ke.prototype.F1=52-Ee,ke.prototype.F2=2*Ee-52;var Te,Ae,Ie="0123456789abcdefghijklmnopqrstuvwxyz",_e=new Array;for(Te="0".charCodeAt(0),Ae=0;Ae<=9;++Ae)_e[Te++]=Ae;for(Te="a".charCodeAt(0),Ae=10;Ae<36;++Ae)_e[Te++]=Ae;for(Te="A".charCodeAt(0),Ae=10;Ae<36;++Ae)_e[Te++]=Ae;function xe(e){return Ie.charAt(e)}function Pe(e,t){var r=_e[e.charCodeAt(t)];return null==r?-1:r}function Re(e){var t=Se();return t.fromInt(e),t}function Ne(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function Oe(e){this.m=e}function Le(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function De(e,t){return e&t}function Ue(e,t){return e|t}function Me(e,t){return e^t}function Ve(e,t){return e&~t}function je(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function Fe(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function ze(){}function Ke(e){return e}function qe(e){this.r2=Se(),this.q3=Se(),ke.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}Oe.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},Oe.prototype.revert=function(e){return e},Oe.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},Oe.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},Oe.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},Le.prototype.convert=function(e){var t=Se();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(ke.ZERO)>0&&this.m.subTo(t,t),t},Le.prototype.revert=function(e){var t=Se();return e.copyTo(t),this.reduce(t),t},Le.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e.data[t],n=r*this.mpl+((r*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},Le.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},Le.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},ke.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},ke.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},ke.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,a=0;--n>=0;){var o=8==r?255&e[n]:Pe(e,n);o<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==a?this.data[this.t++]=o:a+r>this.DB?(this.data[this.t-1]|=(o&(1<<this.DB-a)-1)<<a,this.data[this.t++]=o>>this.DB-a):this.data[this.t-1]|=o<<a,(a+=r)>=this.DB&&(a-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,a>0&&(this.data[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),i&&ke.ZERO.subTo(this,this)},ke.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t},ke.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},ke.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t.data[r-e]=this.data[r];t.t=Math.max(this.t-e,0),t.s=this.s},ke.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,a=(1<<i)-1,o=Math.floor(e/this.DB),s=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+o+1]=this.data[r]>>i|s,s=(this.data[r]&a)<<n;for(r=o-1;r>=0;--r)t.data[r]=0;t.data[o]=s,t.t=this.t+o+1,t.s=this.s,t.clamp()},ke.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,a=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var o=r+1;o<this.t;++o)t.data[o-r-1]|=(this.data[o]&a)<<i,t.data[o-r]=this.data[o]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&a)<<i),t.t=this.t-r,t.clamp()}},ke.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]-e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},ke.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i<n.t;++i)t.data[i+r.t]=r.am(0,n.data[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&ke.ZERO.subTo(t,t)},ke.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e.data[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t.data[r],e,2*r,0,1);(e.data[r+t.t]+=t.am(r+1,2*t.data[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},ke.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Se());var a=Se(),o=this.s,s=e.s,c=this.DB-Ne(n.data[n.t-1]);c>0?(n.lShiftTo(c,a),i.lShiftTo(c,r)):(n.copyTo(a),i.copyTo(r));var u=a.t,l=a.data[u-1];if(0!=l){var d=l*(1<<this.F1)+(u>1?a.data[u-2]>>this.F2:0),f=this.FV/d,p=(1<<this.F1)/d,h=1<<this.F2,g=r.t,m=g-u,y=null==t?Se():t;for(a.dlShiftTo(m,y),r.compareTo(y)>=0&&(r.data[r.t++]=1,r.subTo(y,r)),ke.ONE.dlShiftTo(u,y),y.subTo(a,a);a.t<u;)a.data[a.t++]=0;for(;--m>=0;){var v=r.data[--g]==l?this.DM:Math.floor(r.data[g]*f+(r.data[g-1]+h)*p);if((r.data[g]+=a.am(0,v,r,m,0,u))<v)for(a.dlShiftTo(m,y),r.subTo(y,r);r.data[g]<--v;)r.subTo(y,r)}null!=t&&(r.drShiftTo(u,t),o!=s&&ke.ZERO.subTo(t,t)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),o<0&&ke.ZERO.subTo(r,r)}}},ke.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},ke.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},ke.prototype.exp=function(e,t){if(e>4294967295||e<1)return ke.ONE;var r=Se(),n=Se(),i=t.convert(this),a=Ne(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<<a)>0)t.mulTo(n,i,r);else{var o=r;r=n,n=o}return t.revert(r)},ke.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,a="",o=this.t,s=this.DB-o*this.DB%t;if(o-- >0)for(s<this.DB&&(r=this.data[o]>>s)>0&&(i=!0,a=xe(r));o>=0;)s<t?(r=(this.data[o]&(1<<s)-1)<<t-s,r|=this.data[--o]>>(s+=this.DB-t)):(r=this.data[o]>>(s-=t)&n,s<=0&&(s+=this.DB,--o)),r>0&&(i=!0),i&&(a+=xe(r));return i?a:"0"},ke.prototype.negate=function(){var e=Se();return ke.ZERO.subTo(this,e),e},ke.prototype.abs=function(){return this.s<0?this.negate():this},ke.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},ke.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+Ne(this.data[this.t-1]^this.s&this.DM)},ke.prototype.mod=function(e){var t=Se();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ke.ZERO)>0&&e.subTo(t,t),t},ke.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new Oe(t):new Le(t),this.exp(e,r)},ke.ZERO=Re(0),ke.ONE=Re(1),ze.prototype.convert=Ke,ze.prototype.revert=Ke,ze.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},ze.prototype.sqrTo=function(e,t){e.squareTo(t)},qe.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=Se();return e.copyTo(t),this.reduce(t),t},qe.prototype.revert=function(e){return e},qe.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},qe.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},qe.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var He=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],Ge=(1<<26)/He[He.length-1];if(ke.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},ke.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=Re(r),i=Se(),a=Se(),o="";for(this.divRemTo(n,i,a);i.signum()>0;)o=(r+a.intValue()).toString(e).substr(1)+o,i.divRemTo(n,i,a);return a.intValue().toString(e)+o},ke.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,a=0,o=0,s=0;s<e.length;++s){var c=Pe(e,s);c<0?"-"==e.charAt(s)&&0==this.signum()&&(i=!0):(o=t*o+c,++a>=r&&(this.dMultiply(n),this.dAddOffset(o,0),a=0,o=0))}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(o,0)),i&&ke.ZERO.subTo(this,this)},ke.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(ke.ONE.shiftLeft(e-1),Ue,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(ke.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}},ke.prototype.bitwiseTo=function(e,t,r){var n,i,a=Math.min(e.t,this.t);for(n=0;n<a;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(i=e.s&this.DM,n=a;n<this.t;++n)r.data[n]=t(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=a;n<e.t;++n)r.data[n]=t(i,e.data[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},ke.prototype.changeBit=function(e,t){var r=ke.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r},ke.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]+e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},ke.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},ke.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},ke.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i<n;++i)r.data[i+this.t]=this.am(0,e.data[i],r,i,0,this.t);for(n=Math.min(e.t,t);i<n;++i)this.am(0,e.data[i],r,i,0,t-i);r.clamp()},ke.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r.data[this.t+n-t]=this.am(t-n,e.data[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},ke.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},ke.prototype.millerRabin=function(e){var t=this.subtract(ke.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),a={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},o=0;o<e;++o){do{n=new ke(this.bitLength(),a)}while(n.compareTo(ke.ONE)<=0||n.compareTo(t)>=0);var s=n.modPow(i,this);if(0!=s.compareTo(ke.ONE)&&0!=s.compareTo(t)){for(var c=1;c++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(ke.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0},ke.prototype.clone=function(){var e=Se();return this.copyTo(e),e},ke.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]},ke.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24},ke.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},ke.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},ke.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this.data[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this.data[e]&(1<<n)-1)<<8-n,r|=this.data[--e]>>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},ke.prototype.equals=function(e){return 0==this.compareTo(e)},ke.prototype.min=function(e){return this.compareTo(e)<0?this:e},ke.prototype.max=function(e){return this.compareTo(e)>0?this:e},ke.prototype.and=function(e){var t=Se();return this.bitwiseTo(e,De,t),t},ke.prototype.or=function(e){var t=Se();return this.bitwiseTo(e,Ue,t),t},ke.prototype.xor=function(e){var t=Se();return this.bitwiseTo(e,Me,t),t},ke.prototype.andNot=function(e){var t=Se();return this.bitwiseTo(e,Ve,t),t},ke.prototype.not=function(){for(var e=Se(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e},ke.prototype.shiftLeft=function(e){var t=Se();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},ke.prototype.shiftRight=function(e){var t=Se();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},ke.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this.data[e])return e*this.DB+je(this.data[e]);return this.s<0?this.t*this.DB:-1},ke.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=Fe(this.data[r]^t);return e},ke.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:0!=(this.data[t]&1<<e%this.DB)},ke.prototype.setBit=function(e){return this.changeBit(e,Ue)},ke.prototype.clearBit=function(e){return this.changeBit(e,Ve)},ke.prototype.flipBit=function(e){return this.changeBit(e,Me)},ke.prototype.add=function(e){var t=Se();return this.addTo(e,t),t},ke.prototype.subtract=function(e){var t=Se();return this.subTo(e,t),t},ke.prototype.multiply=function(e){var t=Se();return this.multiplyTo(e,t),t},ke.prototype.divide=function(e){var t=Se();return this.divRemTo(e,t,null),t},ke.prototype.remainder=function(e){var t=Se();return this.divRemTo(e,null,t),t},ke.prototype.divideAndRemainder=function(e){var t=Se(),r=Se();return this.divRemTo(e,t,r),new Array(t,r)},ke.prototype.modPow=function(e,t){var r,n,i=e.bitLength(),a=Re(1);if(i<=0)return a;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new Oe(t):t.isEven()?new qe(t):new Le(t);var o=new Array,s=3,c=r-1,u=(1<<r)-1;if(o[1]=n.convert(this),r>1){var l=Se();for(n.sqrTo(o[1],l);s<=u;)o[s]=Se(),n.mulTo(l,o[s-2],o[s]),s+=2}var d,f,p=e.t-1,h=!0,g=Se();for(i=Ne(e.data[p])-1;p>=0;){for(i>=c?d=e.data[p]>>i-c&u:(d=(e.data[p]&(1<<i+1)-1)<<c-i,p>0&&(d|=e.data[p-1]>>this.DB+i-c)),s=r;0==(1&d);)d>>=1,--s;if((i-=s)<0&&(i+=this.DB,--p),h)o[d].copyTo(a),h=!1;else{for(;s>1;)n.sqrTo(a,g),n.sqrTo(g,a),s-=2;s>0?n.sqrTo(a,g):(f=a,a=g,g=f),n.mulTo(g,o[d],a)}for(;p>=0&&0==(e.data[p]&1<<i);)n.sqrTo(a,g),f=a,a=g,g=f,--i<0&&(i=this.DB-1,--p)}return n.revert(a)},ke.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return ke.ZERO;for(var r=e.clone(),n=this.clone(),i=Re(1),a=Re(0),o=Re(0),s=Re(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&a.isEven()||(i.addTo(this,i),a.subTo(e,a)),i.rShiftTo(1,i)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(e,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(o,i),a.subTo(s,a)):(n.subTo(r,n),t&&o.subTo(i,o),s.subTo(a,s))}return 0!=n.compareTo(ke.ONE)?ke.ZERO:s.compareTo(e)>=0?s.subtract(e):s.signum()<0?(s.addTo(e,s),s.signum()<0?s.add(e):s):s},ke.prototype.pow=function(e){return this.exp(e,new ze)},ke.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),a=r.getLowestSetBit();if(a<0)return t;for(i<a&&(a=i),a>0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r},ke.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=He[He.length-1]){for(t=0;t<He.length;++t)if(r.data[0]==He[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<He.length;){for(var n=He[t],i=t+1;i<He.length&&n<Ge;)n*=He[i++];for(n=r.modInt(n);t<i;)if(n%He[t++]==0)return!1}return r.millerRabin(e)},E((function(e){var t=e.exports=F.sha1=F.sha1||{};F.md.sha1=F.md.algorithms.sha1=t,t.create=function(){n||(r=String.fromCharCode(128),r+=F.util.fillString(String.fromCharCode(0),64),n=!0);var e=null,t=F.util.createBuffer(),a=new Array(80),o={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){o.messageLength=0,o.fullMessageLength=o.messageLength64=[];for(var r=o.messageLengthSize/4,n=0;n<r;++n)o.fullMessageLength.push(0);return t=F.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},o}};return o.start(),o.update=function(r,n){"utf8"===n&&(r=F.util.encodeUtf8(r));var s=r.length;o.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var c=o.fullMessageLength.length-1;c>=0;--c)o.fullMessageLength[c]+=s[1],s[1]=s[0]+(o.fullMessageLength[c]/4294967296>>>0),o.fullMessageLength[c]=o.fullMessageLength[c]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(r),i(e,a,t),(t.read>2048||0===t.length())&&t.compact(),o},o.digest=function(){var n=F.util.createBuffer();n.putBytes(t.bytes());var s,c=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;n.putBytes(r.substr(0,o.blockLength-c));for(var u=8*o.fullMessageLength[0],l=0;l<o.fullMessageLength.length-1;++l)u+=(s=8*o.fullMessageLength[l+1])/4294967296>>>0,n.putInt32(u>>>0),u=s>>>0;n.putInt32(u);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};i(d,a,n);var f=F.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f},o};var r=null,n=!1;function i(e,t,r){for(var n,i,a,o,s,c,u,l=r.length();l>=64;){for(i=e.h0,a=e.h1,o=e.h2,s=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(i<<5|i>>>27)+(s^a&(o^s))+c+1518500249+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(s^a&(o^s))+c+1518500249+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(a^o^s)+c+1859775393+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(a^o^s)+c+1859775393+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(a&o|s&(a^o))+c+2400959708+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(a^o^s)+c+3395469782+n,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+a|0,e.h2=e.h2+o|0,e.h3=e.h3+s|0,e.h4=e.h4+c|0,l-=64}}})),E((function(e){var t=e.exports=F.pkcs1=F.pkcs1||{};function r(e,t,r){r||(r=F.md.sha1.create());for(var n="",i=Math.ceil(t/r.digestLength),a=0;a<i;++a){var o=String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a);r.start(),r.update(e+o),n+=r.digest().getBytes()}return n.substring(0,t)}t.encode_rsa_oaep=function(e,t,n){var i,a,o,s;"string"==typeof n?(i=n,a=arguments[3]||void 0,o=arguments[4]||void 0):n&&(i=n.label||void 0,a=n.seed||void 0,o=n.md||void 0,n.mgf1&&n.mgf1.md&&(s=n.mgf1.md)),o?o.start():o=F.md.sha1.create(),s||(s=o);var c=Math.ceil(e.n.bitLength()/8),u=c-2*o.digestLength-2;if(t.length>u)throw(h=new Error("RSAES-OAEP input message length is too long.")).length=t.length,h.maxLength=u,h;i||(i=""),o.update(i,"raw");for(var l=o.digest(),d="",f=u-t.length,p=0;p<f;p++)d+="\0";var h,g=l.getBytes()+d+""+t;if(a){if(a.length!==o.digestLength)throw(h=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=a.length,h.digestLength=o.digestLength,h}else a=F.random.getBytes(o.digestLength);var m=r(a,c-o.digestLength-1,s),y=F.util.xorBytes(g,m,g.length),v=r(y,o.digestLength,s);return"\0"+F.util.xorBytes(a,v,a.length)+y},t.decode_rsa_oaep=function(e,t,n){var i,a,o;"string"==typeof n?(i=n,a=arguments[3]||void 0):n&&(i=n.label||void 0,a=n.md||void 0,n.mgf1&&n.mgf1.md&&(o=n.mgf1.md));var s=Math.ceil(e.n.bitLength()/8);if(t.length!==s)throw(m=new Error("RSAES-OAEP encoded message length is invalid.")).length=t.length,m.expectedLength=s,m;if(void 0===a?a=F.md.sha1.create():a.start(),o||(o=a),s<2*a.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");i||(i=""),a.update(i,"raw");for(var c=a.digest().getBytes(),u=t.charAt(0),l=t.substring(1,a.digestLength+1),d=t.substring(1+a.digestLength),f=r(d,a.digestLength,o),p=r(F.util.xorBytes(l,f,l.length),s-a.digestLength-1,o),h=F.util.xorBytes(d,p,d.length),g=h.substring(0,a.digestLength),m="\0"!==u,y=0;y<a.digestLength;++y)m|=c.charAt(y)!==g.charAt(y);for(var v=1,b=a.digestLength,C=a.digestLength;C<h.length;C++){var E=h.charCodeAt(C);m|=E&(v?65534:0),b+=v&=1&E^1}if(m||1!==h.charCodeAt(b))throw new Error("Invalid RSAES-OAEP padding.");return h.substring(b+1)}})),E((function(e){!function(){if(F.prime)e.exports=F.prime;else{var t=e.exports=F.prime=F.prime||{},r=F.jsbn.BigInteger,n=[6,4,2,4,2,4,6,2],i=new r(null);i.fromInt(30);var a=function(e,t){return e|t};t.generateProbablePrime=function(e,t,n){"function"==typeof t&&(n=t,t={});var i=(t=t||{}).algorithm||"PRIMEINC";"string"==typeof i&&(i={name:i}),i.options=i.options||{};var a=t.prng||F.random,c={nextBytes:function(e){for(var t=a.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}};if("PRIMEINC"===i.name)return function(e,t,n,i){return"workers"in n?function(e,t,n,i){if("undefined"==typeof Worker)return o(e,t,n,i);var a=s(e,t),c=n.workers,u=n.workLoad||100,l=30*u/8,d=n.workerScript||"forge/prime.worker.js";if(-1===c)return F.util.estimateCores((function(e,t){e&&(t=2),c=t-1,f()}));function f(){c=Math.max(1,c);for(var n=[],o=0;o<c;++o)n[o]=new Worker(d);for(o=0;o<c;++o)n[o].addEventListener("message",p);var f=!1;function p(o){if(!f){var c=o.data;if(c.found){for(var d=0;d<n.length;++d)n[d].terminate();return f=!0,i(null,new r(c.prime,16))}a.bitLength()>e&&(a=s(e,t));var p=a.toString(16);o.target.postMessage({hex:p,workLoad:u}),a.dAddOffset(l,0)}}}f()}(e,t,n,i):o(e,t,n,i)}(e,c,i.options,n);throw new Error("Invalid prime generation algorithm: "+i.name)}}function o(e,t,r,i){var a=s(e,t),o=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(a.bitLength());"millerRabinTests"in r&&(o=r.millerRabinTests);var c=10;"maxBlockTime"in r&&(c=r.maxBlockTime),function e(t,r,i,a,o,c,u){var l=+new Date;do{if(t.bitLength()>r&&(t=s(r,i)),t.isProbablePrime(o))return u(null,t);t.dAddOffset(n[a++%8],0)}while(c<0||+new Date-l<c);F.util.setImmediate((function(){e(t,r,i,a,o,c,u)}))}(a,e,t,0,o,c,i)}function s(e,t){var n=new r(e,t),o=e-1;return n.testBit(o)||n.bitwiseTo(r.ONE.shiftLeft(o),a,n),n.dAddOffset(31-n.mod(i).byteValue(),0),n}}()})),void 0===Qe)var Qe=F.jsbn.BigInteger;var We=F.util.isNodejs?t:null,Xe=F.asn1,Ye=F.util;F.pki=F.pki||{},F.pki.rsa=F.rsa=F.rsa||{};var $e=F.pki,Ze=[6,4,2,4,2,4,6,2],Je={name:"PrivateKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},et={name:"RSAPrivateKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},tt={name:"RSAPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},rt=F.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},nt=function(e){var t;if(!(e.algorithm in $e.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=$e.oids[e.algorithm];var n=Xe.oidToDer(t).getBytes(),i=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[]),a=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[]);a.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,n)),a.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,""));var o=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(a),i.value.push(o),Xe.toDer(i).getBytes()},it=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var n;t.dP||(t.dP=t.d.mod(t.p.subtract(Qe.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(Qe.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{n=new Qe(F.util.bytesToHex(F.random.getBytes(t.n.bitLength()/8)),16)}while(n.compareTo(t.n)>=0||!n.gcd(t.n).equals(Qe.ONE));for(var i=(e=e.multiply(n.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);i.compareTo(a)<0;)i=i.add(t.p);var o=i.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return o.multiply(n.modInverse(t.n)).mod(t.n)};function at(e,t,r){var n=F.util.createBuffer(),i=Math.ceil(t.n.bitLength()/8);if(e.length>i-11){var a=new Error("Message is too long for PKCS#1 v1.5 padding.");throw a.length=e.length,a.max=i-11,a}n.putByte(0),n.putByte(r);var o,s=i-3-e.length;if(0===r||1===r){o=0===r?0:255;for(var c=0;c<s;++c)n.putByte(o)}else for(;s>0;){var u=0,l=F.random.getBytes(s);for(c=0;c<s;++c)0===(o=l.charCodeAt(c))?++u:n.putByte(o);s=u}return n.putByte(0),n.putBytes(e),n}function ot(e,t,r,n){var i=Math.ceil(t.n.bitLength()/8),a=F.util.createBuffer(e),o=a.getByte(),s=a.getByte();if(0!==o||r&&0!==s&&1!==s||!r&&2!=s||r&&0===s&&void 0===n)throw new Error("Encryption block is invalid.");var c=0;if(0===s){c=i-3-n;for(var u=0;u<c;++u)if(0!==a.getByte())throw new Error("Encryption block is invalid.")}else if(1===s)for(c=0;a.length()>1;){if(255!==a.getByte()){--a.read;break}++c}else if(2===s)for(c=0;a.length()>1;){if(0===a.getByte()){--a.read;break}++c}if(0!==a.getByte()||c!==i-3-a.length())throw new Error("Encryption block is invalid.");return a.getBytes()}function st(e,t,r){"function"==typeof t&&(r=t,t={});var n={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function i(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?o(t,e.q):void a(e.qBits,o))}))}function a(e,t){F.prime.generateProbablePrime(e,n,t)}function o(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var s=e.p;e.p=e.q,e.q=s}if(0!==e.p.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE))return e.p=null,void i();if(0!==e.q.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE))return e.q=null,void a(e.qBits,o);if(e.p1=e.p.subtract(Qe.ONE),e.q1=e.q.subtract(Qe.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(Qe.ONE))return e.p=e.q=null,void i();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,o);var c=e.e.modInverse(e.phi);e.keys={privateKey:$e.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:$e.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(n.prng=t.prng),i()}function ct(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=F.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function ut(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function lt(e){return F.util.isNodejs&&"function"==typeof We[e]}function dt(e){return void 0!==Ye.globalScope&&"object"==typeof Ye.globalScope.crypto&&"object"==typeof Ye.globalScope.crypto.subtle&&"function"==typeof Ye.globalScope.crypto.subtle[e]}function ft(e){return void 0!==Ye.globalScope&&"object"==typeof Ye.globalScope.msCrypto&&"object"==typeof Ye.globalScope.msCrypto.subtle&&"function"==typeof Ye.globalScope.msCrypto.subtle[e]}function pt(e){for(var t=F.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n<t.length;++n)r[n]=t.charCodeAt(n);return r}if($e.rsa.encrypt=function(e,t,r){var n,i=r,a=Math.ceil(t.n.bitLength()/8);!1!==r&&!0!==r?(i=2===r,n=at(e,t,r)):(n=F.util.createBuffer()).putBytes(e);for(var o=new Qe(n.toHex(),16),s=it(o,t,i).toString(16),c=F.util.createBuffer(),u=a-Math.ceil(s.length/2);u>0;)c.putByte(0),--u;return c.putBytes(F.util.hexToBytes(s)),c.getBytes()},$e.rsa.decrypt=function(e,t,r,n){var i=Math.ceil(t.n.bitLength()/8);if(e.length!==i){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=i,a}var o=new Qe(F.util.createBuffer(e).toHex(),16);if(o.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var s=it(o,t,r).toString(16),c=F.util.createBuffer(),u=i-Math.ceil(s.length/2);u>0;)c.putByte(0),--u;return c.putBytes(F.util.hexToBytes(s)),!1!==n?ot(c.getBytes(),t,r):c.getBytes()},$e.rsa.createKeyPairGenerationState=function(e,t,r){"string"==typeof e&&(e=parseInt(e,10)),e=e||2048;var n,i=(r=r||{}).prng||F.random,a={nextBytes:function(e){for(var t=i.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},o=r.algorithm||"PRIMEINC";if("PRIMEINC"!==o)throw new Error("Invalid key generation algorithm: "+o);return(n={algorithm:o,state:0,bits:e,rng:a,eInt:t||65537,e:new Qe(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(n.eInt),n},$e.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new Qe(null);r.fromInt(30);for(var n,i=0,a=function(e,t){return e|t},o=+new Date,s=0;null===e.keys&&(t<=0||s<t);){if(0===e.state){var c=null===e.p?e.pBits:e.qBits,u=c-1;0===e.pqState?(e.num=new Qe(c,e.rng),e.num.testBit(u)||e.num.bitwiseTo(Qe.ONE.shiftLeft(u),a,e.num),e.num.dAddOffset(31-e.num.mod(r).byteValue(),0),i=0,++e.pqState):1===e.pqState?e.num.bitLength()>c?e.pqState=0:e.num.isProbablePrime(ut(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(Ze[i++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(Qe.ONE),e.q1=e.q.subtract(Qe.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(Qe.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var l=e.e.modInverse(e.phi);e.keys={privateKey:$e.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:$e.rsa.setPublicKey(e.n,e.e)}}s+=(n=+new Date)-o,o=n}return null!==e.keys},$e.rsa.generateKeyPair=function(e,t,r,n){if(1===arguments.length?"object"==typeof e?(r=e,e=void 0):"function"==typeof e&&(n=e,e=void 0):2===arguments.length?"number"==typeof e?"function"==typeof t?(n=t,t=void 0):"number"!=typeof t&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):3===arguments.length&&("number"==typeof t?"function"==typeof r&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(n){if(lt("generateKeyPair"))return We.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return n(e);n(null,{privateKey:$e.privateKeyFromPem(r),publicKey:$e.publicKeyFromPem(t)})}));if(dt("generateKey")&&dt("exportKey"))return Ye.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:pt(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return Ye.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){n(e)})).then((function(e){if(e){var t=$e.privateKeyFromAsn1(Xe.fromDer(F.util.createBuffer(e)));n(null,{privateKey:t,publicKey:$e.setRsaPublicKey(t.n,t.e)})}}));if(ft("generateKey")&&ft("exportKey")){var i=Ye.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:pt(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return i.oncomplete=function(e){var t=e.target.result,r=Ye.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=$e.privateKeyFromAsn1(Xe.fromDer(F.util.createBuffer(t)));n(null,{privateKey:r,publicKey:$e.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){n(e)}},void(i.onerror=function(e){n(e)})}}else if(lt("generateKeyPairSync")){var a=We.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:$e.privateKeyFromPem(a.privateKey),publicKey:$e.publicKeyFromPem(a.publicKey)}}var o=$e.rsa.createKeyPairGenerationState(e,t,r);if(!n)return $e.rsa.stepKeyPairGenerationState(o,0),o.keys;st(o,r,n)},$e.setRsaPublicKey=$e.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,n){if("string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return at(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return F.pkcs1.encode_rsa_oaep(t,e,n)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var i=t.encode(e,r,!0);return $e.rsa.encrypt(i,r,!0)},verify:function(e,t,n){"string"==typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(e,t){return t=ot(t,r,!0),e===Xe.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===ot(t,r,!0)}});var i=$e.rsa.decrypt(t,r,!0,!1);return n.verify(e,i,r.n.bitLength())}};return r},$e.setRsaPrivateKey=$e.rsa.setPrivateKey=function(e,t,r,n,i,a,o,s){var c={n:e,e:t,d:r,p:n,q:i,dP:a,dQ:o,qInv:s,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var n=$e.rsa.decrypt(e,c,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:ot};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return F.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(n,c,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:nt},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,c.n.bitLength());return $e.rsa.encrypt(n,c,r)}};return c},$e.wrapRsaPrivateKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,Xe.integerToDer(0).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,Xe.oidToDer($e.oids.rsaEncryption).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,"")]),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OCTETSTRING,!1,Xe.toDer(e).getBytes())])},$e.privateKeyFromAsn1=function(e){var t,r,n,i,a,o,s,c,u={},l=[];if(Xe.validate(e,Je,u,l)&&(e=Xe.fromDer(F.util.createBuffer(u.privateKey))),u={},l=[],!Xe.validate(e,et,u,l)){var d=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw d.errors=l,d}return t=F.util.createBuffer(u.privateKeyModulus).toHex(),r=F.util.createBuffer(u.privateKeyPublicExponent).toHex(),n=F.util.createBuffer(u.privateKeyPrivateExponent).toHex(),i=F.util.createBuffer(u.privateKeyPrime1).toHex(),a=F.util.createBuffer(u.privateKeyPrime2).toHex(),o=F.util.createBuffer(u.privateKeyExponent1).toHex(),s=F.util.createBuffer(u.privateKeyExponent2).toHex(),c=F.util.createBuffer(u.privateKeyCoefficient).toHex(),$e.setRsaPrivateKey(new Qe(t,16),new Qe(r,16),new Qe(n,16),new Qe(i,16),new Qe(a,16),new Qe(o,16),new Qe(s,16),new Qe(c,16))},$e.privateKeyToAsn1=$e.privateKeyToRSAPrivateKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,Xe.integerToDer(0).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.n)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.e)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.d)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.p)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.q)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.dP)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.dQ)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.qInv))])},$e.publicKeyFromAsn1=function(e){var t={},r=[];if(Xe.validate(e,rt,t,r)){var n,i=Xe.derToOid(t.publicKeyOid);if(i!==$e.oids.rsaEncryption)throw(n=new Error("Cannot read public key. Unknown OID.")).oid=i,n;e=t.rsaPublicKey}if(r=[],!Xe.validate(e,tt,t,r))throw(n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,n;var a=F.util.createBuffer(t.publicKeyModulus).toHex(),o=F.util.createBuffer(t.publicKeyExponent).toHex();return $e.setRsaPublicKey(new Qe(a,16),new Qe(o,16))},$e.publicKeyToAsn1=$e.publicKeyToSubjectPublicKeyInfo=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,Xe.oidToDer($e.oids.rsaEncryption).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,"")]),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.BITSTRING,!1,[$e.publicKeyToRSAPublicKey(e)])])},$e.publicKeyToRSAPublicKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.n)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.e))])},void 0===ht)var ht=F.jsbn.BigInteger;var gt=F.asn1,mt=F.pki=F.pki||{},yt=(mt.pbe=F.pbe=F.pbe||{},mt.oids),vt={name:"EncryptedPrivateKeyInfo",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},bt={name:"PBES2Algorithms",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},Ct={name:"pkcs-12PbeParams",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,capture:"iterations"}]};function Et(e,t){return e.start().update(t).digest().getBytes()}function wt(e){var t;if(e){if(!(t=mt.oids[gt.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return kt(t)}function kt(e){var t=F.md;switch(e){case"hmacWithSHA224":t=F.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}mt.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n,i,a,o=F.random.getBytesSync(r.saltSize),s=r.count,c=gt.integerToDer(s);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var u,l,d;switch(r.algorithm){case"aes128":n=16,u=16,l=yt["aes128-CBC"],d=F.aes.createEncryptionCipher;break;case"aes192":n=24,u=16,l=yt["aes192-CBC"],d=F.aes.createEncryptionCipher;break;case"aes256":n=32,u=16,l=yt["aes256-CBC"],d=F.aes.createEncryptionCipher;break;case"des":n=8,u=8,l=yt.desCBC,d=F.des.createEncryptionCipher;break;default:throw(y=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,y}var f="hmacWith"+r.prfAlgorithm.toUpperCase(),p=kt(f),h=F.pkcs5.pbkdf2(t,o,s,n,p),g=F.random.getBytesSync(u);(v=d(h)).start(g),v.update(gt.toDer(e)),v.finish(),a=v.output.getBytes();var m=function(e,t,r,n){var i=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,e),gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,t.getBytes())]);return"hmacWithSHA1"!==n&&i.value.push(gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,F.util.hexToBytes(r.toString(16))),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(mt.oids[n]).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.NULL,!1,"")])),i}(o,c,n,f);i=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt.pkcs5PBES2).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt.pkcs5PBKDF2).getBytes()),m]),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(l).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,g)])])])}else{var y;if("3des"!==r.algorithm)throw(y=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,y;n=24;var v,b=new F.util.ByteBuffer(o);h=mt.pbe.generatePkcs12Key(t,b,1,s,n),g=mt.pbe.generatePkcs12Key(t,b,2,s,n),(v=F.des.createEncryptionCipher(h)).start(g),v.update(gt.toDer(e)),v.finish(),a=v.output.getBytes(),i=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,o),gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,c.getBytes())])])}return gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[i,gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,a)])},mt.decryptPrivateKeyInfo=function(e,t){var r=null,n={},i=[];if(!gt.validate(e,vt,n,i)){var a=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=i,a}var o=gt.derToOid(n.encryptionOid),s=mt.pbe.getCipher(o,n.encryptionParams,t),c=F.util.createBuffer(n.encryptedData);return s.update(c),s.finish()&&(r=gt.fromDer(s.output)),r},mt.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:gt.toDer(e).getBytes()};return F.pem.encode(r,{maxline:t})},mt.encryptedPrivateKeyFromPem=function(e){var t=F.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return gt.fromDer(t.body)},mt.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var n=mt.wrapRsaPrivateKey(mt.privateKeyToAsn1(e));return n=mt.encryptPrivateKeyInfo(n,t,r),mt.encryptedPrivateKeyToPem(n)}var i,a,o,s;switch(r.algorithm){case"aes128":i="AES-128-CBC",o=16,a=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",o=24,a=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",o=32,a=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",o=24,a=F.random.getBytesSync(8),s=F.des.createEncryptionCipher;break;case"des":i="DES-CBC",o=8,a=F.random.getBytesSync(8),s=F.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw c.algorithm=r.algorithm,c}var u=s(F.pbe.opensslDeriveBytes(t,a.substr(0,8),o));u.start(a),u.update(gt.toDer(mt.privateKeyToAsn1(e))),u.finish();var l={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:F.util.bytesToHex(a).toUpperCase()},body:u.output.getBytes()};return F.pem.encode(l)},mt.decryptRsaPrivateKey=function(e,t){var r=null,n=F.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==n.type&&"PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type)throw(o=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=o,o;if(n.procType&&"ENCRYPTED"===n.procType.type){var i,a;switch(n.dekInfo.algorithm){case"DES-CBC":i=8,a=F.des.createDecryptionCipher;break;case"DES-EDE3-CBC":i=24,a=F.des.createDecryptionCipher;break;case"AES-128-CBC":i=16,a=F.aes.createDecryptionCipher;break;case"AES-192-CBC":i=24,a=F.aes.createDecryptionCipher;break;case"AES-256-CBC":i=32,a=F.aes.createDecryptionCipher;break;case"RC2-40-CBC":i=5,a=function(e){return F.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":i=8,a=function(e){return F.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":i=16,a=function(e){return F.rc2.createDecryptionCipher(e,128)};break;default:var o;throw(o=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".')).algorithm=n.dekInfo.algorithm,o}var s=F.util.hexToBytes(n.dekInfo.parameters),c=a(F.pbe.opensslDeriveBytes(t,s.substr(0,8),i));if(c.start(s),c.update(F.util.createBuffer(n.body)),!c.finish())return r;r=c.output.getBytes()}else r=n.body;return null!==(r="ENCRYPTED PRIVATE KEY"===n.type?mt.decryptPrivateKeyInfo(gt.fromDer(r),t):gt.fromDer(r))&&(r=mt.privateKeyFromAsn1(r)),r},mt.pbe.generatePkcs12Key=function(e,t,r,n,i,a){var o,s;if(null==a){if(!("sha1"in F.md))throw new Error('"sha1" hash algorithm unavailable.');a=F.md.sha1.create()}var c=a.digestLength,u=a.blockLength,l=new F.util.ByteBuffer,d=new F.util.ByteBuffer;if(null!=e){for(s=0;s<e.length;s++)d.putInt16(e.charCodeAt(s));d.putInt16(0)}var f=d.length(),p=t.length(),h=new F.util.ByteBuffer;h.fillWithByte(r,u);var g=u*Math.ceil(p/u),m=new F.util.ByteBuffer;for(s=0;s<g;s++)m.putByte(t.at(s%p));var y=u*Math.ceil(f/u),v=new F.util.ByteBuffer;for(s=0;s<y;s++)v.putByte(d.at(s%f));var b=m;b.putBuffer(v);for(var C=Math.ceil(i/c),E=1;E<=C;E++){var w=new F.util.ByteBuffer;w.putBytes(h.bytes()),w.putBytes(b.bytes());for(var k=0;k<n;k++)a.start(),a.update(w.getBytes()),w=a.digest();var S=new F.util.ByteBuffer;for(s=0;s<u;s++)S.putByte(w.at(s%c));var B=Math.ceil(p/u)+Math.ceil(f/u),T=new F.util.ByteBuffer;for(o=0;o<B;o++){var A=new F.util.ByteBuffer(b.getBytes(u)),I=511;for(s=S.length()-1;s>=0;s--)I>>=8,I+=S.at(s)+A.at(s),A.setAt(s,255&I);T.putBuffer(A)}b=T,l.putBuffer(w)}return l.truncate(l.length()-i),l},mt.pbe.getCipher=function(e,t,r){switch(e){case mt.oids.pkcs5PBES2:return mt.pbe.getCipherForPBES2(e,t,r);case mt.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case mt.oids["pbewithSHAAnd40BitRC2-CBC"]:return mt.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},mt.pbe.getCipherForPBES2=function(e,t,r){var n,i={},a=[];if(!gt.validate(t,bt,i,a))throw(n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,n;if((e=gt.derToOid(i.kdfOid))!==mt.oids.pkcs5PBKDF2)throw(n=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,n.supportedOids=["pkcs5PBKDF2"],n;if((e=gt.derToOid(i.encOid))!==mt.oids["aes128-CBC"]&&e!==mt.oids["aes192-CBC"]&&e!==mt.oids["aes256-CBC"]&&e!==mt.oids["des-EDE3-CBC"]&&e!==mt.oids.desCBC)throw(n=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,n.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],n;var o,s,c=i.kdfSalt,u=F.util.createBuffer(i.kdfIterationCount);switch(u=u.getInt(u.length()<<3),mt.oids[e]){case"aes128-CBC":o=16,s=F.aes.createDecryptionCipher;break;case"aes192-CBC":o=24,s=F.aes.createDecryptionCipher;break;case"aes256-CBC":o=32,s=F.aes.createDecryptionCipher;break;case"des-EDE3-CBC":o=24,s=F.des.createDecryptionCipher;break;case"desCBC":o=8,s=F.des.createDecryptionCipher}var l=wt(i.prfOid),d=F.pkcs5.pbkdf2(r,c,u,o,l),f=i.encIv,p=s(d);return p.start(f),p},mt.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},i=[];if(!gt.validate(t,Ct,n,i))throw(l=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=i,l;var a,o,s,c=F.util.createBuffer(n.salt),u=F.util.createBuffer(n.iterations);switch(u=u.getInt(u.length()<<3),e){case mt.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:a=24,o=8,s=F.des.startDecrypting;break;case mt.oids["pbewithSHAAnd40BitRC2-CBC"]:a=5,o=8,s=function(e,t){var r=F.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var l;throw(l=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,l}var d=wt(n.prfOid),f=mt.pbe.generatePkcs12Key(r,c,1,u,a,d);return d.start(),s(f,mt.pbe.generatePkcs12Key(r,c,2,u,o,d))},mt.pbe.opensslDeriveBytes=function(e,t,r,n){if(null==n){if(!("md5"in F.md))throw new Error('"md5" hash algorithm unavailable.');n=F.md.md5.create()}null===t&&(t="");for(var i=[Et(n,e+t)],a=16,o=1;a<r;++o,a+=16)i.push(Et(n,i[o-1]+e+t));return i.join("").substr(0,r)},E((function(e){var t=F.asn1,r=e.exports=F.pkcs7asn1=F.pkcs7asn1||{};F.pkcs7=F.pkcs7||{},F.pkcs7.asn1=r;var n={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};r.contentInfoValidator=n;var i={name:"EncryptedContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};r.envelopedDataValidator={name:"EnvelopedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(i)},r.encryptedDataValidator={name:"EncryptedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"}].concat(i)};var a={name:"SignerInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};r.signedDataValidator={name:"SignedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},n,{name:"SignedData.Certificates",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,capture:"signerInfos",optional:!0,value:[a]}]},r.recipientInfoValidator={name:"RecipientInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}})),E((function(e){F.mgf=F.mgf||{},(e.exports=F.mgf.mgf1=F.mgf1=F.mgf1||{}).create=function(e){return{generate:function(t,r){for(var n=new F.util.ByteBuffer,i=Math.ceil(r/e.digestLength),a=0;a<i;a++){var o=new F.util.ByteBuffer;o.putInt32(a),e.start(),e.update(t+o.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}}}})),F.mgf=F.mgf||{},F.mgf.mgf1=F.mgf1,E((function(e){(e.exports=F.pss=F.pss||{}).create=function(e){3===arguments.length&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t,r=e.md,n=e.mgf,i=r.digestLength,a=e.salt||null;if("string"==typeof a&&(a=F.util.createBuffer(a)),"saltLength"in e)t=e.saltLength;else{if(null===a)throw new Error("Salt length not specified or specific salt not given.");t=a.length()}if(null!==a&&a.length()!==t)throw new Error("Given salt length does not match length of given salt.");var o=e.prng||F.random;return{encode:function(e,s){var c,u,l=s-1,d=Math.ceil(l/8),f=e.digest().getBytes();if(d<i+t+2)throw new Error("Message is too long to encrypt.");u=null===a?o.getBytesSync(t):a.bytes();var p=new F.util.ByteBuffer;p.fillWithByte(0,8),p.putBytes(f),p.putBytes(u),r.start(),r.update(p.getBytes());var h=r.digest().getBytes(),g=new F.util.ByteBuffer;g.fillWithByte(0,d-t-i-2),g.putByte(1),g.putBytes(u);var m=g.getBytes(),y=d-i-1,v=n.generate(h,y),b="";for(c=0;c<y;c++)b+=String.fromCharCode(m.charCodeAt(c)^v.charCodeAt(c));var C=65280>>8*d-l&255;return(b=String.fromCharCode(b.charCodeAt(0)&~C)+b.substr(1))+h+String.fromCharCode(188)},verify:function(e,a,o){var s,c=o-1,u=Math.ceil(c/8);if(a=a.substr(-u),u<i+t+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(188!==a.charCodeAt(u-1))throw new Error("Encoded message does not end in 0xBC.");var l=u-i-1,d=a.substr(0,l),f=a.substr(l,i),p=65280>>8*u-c&255;if(0!=(d.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var h=n.generate(f,l),g="";for(s=0;s<l;s++)g+=String.fromCharCode(d.charCodeAt(s)^h.charCodeAt(s));g=String.fromCharCode(g.charCodeAt(0)&~p)+g.substr(1);var m=u-i-t-2;for(s=0;s<m;s++)if(0!==g.charCodeAt(s))throw new Error("Leftmost octets not zero as expected");if(1!==g.charCodeAt(m))throw new Error("Inconsistent PSS signature, 0x01 marker not found");var y=g.substr(-t),v=new F.util.ByteBuffer;return v.fillWithByte(0,8),v.putBytes(e),v.putBytes(y),r.start(),r.update(v.getBytes()),f===r.digest().getBytes()}}}})),E((function(e){var t=F.asn1,r=e.exports=F.pki=F.pki||{},n=r.oids,i={};i.CN=n.commonName,i.commonName="CN",i.C=n.countryName,i.countryName="C",i.L=n.localityName,i.localityName="L",i.ST=n.stateOrProvinceName,i.stateOrProvinceName="ST",i.O=n.organizationName,i.organizationName="O",i.OU=n.organizationalUnitName,i.organizationalUnitName="OU",i.E=n.emailAddress,i.emailAddress="E";var a=F.pki.rsa.publicKeyValidator,o={name:"Certificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},a,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},s={name:"rsapss",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},c={name:"CertificationRequestInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},a,{name:"CertificationRequestInfo.attributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0}]}]}]},u={name:"CertificationRequest",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[c,{name:"CertificationRequest.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function l(e,t){"string"==typeof t&&(t={shortName:t});for(var r,n=null,i=0;null===n&&i<e.attributes.length;++i)r=e.attributes[i],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(n=r);return n}r.RDNAttributesAsArray=function(e,r){for(var a,o,s,c=[],u=0;u<e.value.length;++u){a=e.value[u];for(var l=0;l<a.value.length;++l)s={},o=a.value[l],s.type=t.derToOid(o.value[0].value),s.value=o.value[1].value,s.valueTagClass=o.value[1].type,s.type in n&&(s.name=n[s.type],s.name in i&&(s.shortName=i[s.name])),r&&(r.update(s.type),r.update(s.value)),c.push(s)}return c},r.CRIAttributesAsArray=function(e){for(var a=[],o=0;o<e.length;++o)for(var s=e[o],c=t.derToOid(s.value[0].value),u=s.value[1].value,l=0;l<u.length;++l){var d={};if(d.type=c,d.value=u[l].value,d.valueTagClass=u[l].type,d.type in n&&(d.name=n[d.type],d.name in i&&(d.shortName=i[d.name])),d.type===n.extensionRequest){d.extensions=[];for(var f=0;f<d.value.length;++f)d.extensions.push(r.certificateExtensionFromAsn1(d.value[f]))}a.push(d)}return a};var d=function(e,r,i){var a={};if(e!==n["RSASSA-PSS"])return a;i&&(a={hash:{algorithmOid:n.sha1},mgf:{algorithmOid:n.mgf1,hash:{algorithmOid:n.sha1}},saltLength:20});var o={},c=[];if(!t.validate(r,s,o,c)){var u=new Error("Cannot read RSASSA-PSS parameter block.");throw u.errors=c,u}return void 0!==o.hashOid&&(a.hash=a.hash||{},a.hash.algorithmOid=t.derToOid(o.hashOid)),void 0!==o.maskGenOid&&(a.mgf=a.mgf||{},a.mgf.algorithmOid=t.derToOid(o.maskGenOid),a.mgf.hash=a.mgf.hash||{},a.mgf.hash.algorithmOid=t.derToOid(o.maskGenHashOid)),void 0!==o.saltLength&&(a.saltLength=o.saltLength.charCodeAt(0)),a};function f(e){for(var r,n,i=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),a=e.attributes,o=0;o<a.length;++o){var s=(r=a[o]).value,c=t.Type.PRINTABLESTRING;"valueTagClass"in r&&(c=r.valueTagClass)===t.Type.UTF8&&(s=F.util.encodeUtf8(s)),n=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.type).getBytes()),t.create(t.Class.UNIVERSAL,c,!1,s)])]),i.value.push(n)}return i}function p(e){for(var a,o=0;o<e.length;++o){if(void 0===(a=e[o]).name&&(a.type&&a.type in r.oids?a.name=r.oids[a.type]:a.shortName&&a.shortName in i&&(a.name=r.oids[i[a.shortName]])),void 0===a.type){if(!a.name||!(a.name in r.oids))throw(c=new Error("Attribute type not specified.")).attribute=a,c;a.type=r.oids[a.name]}if(void 0===a.shortName&&a.name&&a.name in i&&(a.shortName=i[a.name]),a.type===n.extensionRequest&&(a.valueConstructed=!0,a.valueTagClass=t.Type.SEQUENCE,!a.value&&a.extensions)){a.value=[];for(var s=0;s<a.extensions.length;++s)a.value.push(r.certificateExtensionToAsn1(h(a.extensions[s])))}var c;if(void 0===a.value)throw(c=new Error("Attribute value not specified.")).attribute=a,c}}function h(e,i){if(i=i||{},void 0===e.name&&e.id&&e.id in r.oids&&(e.name=r.oids[e.id]),void 0===e.id){if(!e.name||!(e.name in r.oids))throw(C=new Error("Extension ID not specified.")).extension=e,C;e.id=r.oids[e.name]}if(void 0!==e.value)return e;if("keyUsage"===e.name){var a=0,o=0,s=0;e.digitalSignature&&(o|=128,a=7),e.nonRepudiation&&(o|=64,a=6),e.keyEncipherment&&(o|=32,a=5),e.dataEncipherment&&(o|=16,a=4),e.keyAgreement&&(o|=8,a=3),e.keyCertSign&&(o|=4,a=2),e.cRLSign&&(o|=2,a=1),e.encipherOnly&&(o|=1,a=0),e.decipherOnly&&(s|=128,a=7);var c=String.fromCharCode(a);0!==s?c+=String.fromCharCode(o)+String.fromCharCode(s):0!==o&&(c+=String.fromCharCode(o)),e.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,c)}else if("basicConstraints"===e.name)e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in e&&e.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.pathLenConstraint).getBytes()));else if("extKeyUsage"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);var u=e.value.value;for(var l in e)!0===e[l]&&(l in n?u.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n[l]).getBytes())):-1!==l.indexOf(".")&&u.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(l).getBytes())))}else if("nsCertType"===e.name)a=0,o=0,e.client&&(o|=128,a=7),e.server&&(o|=64,a=6),e.email&&(o|=32,a=5),e.objsign&&(o|=16,a=4),e.reserved&&(o|=8,a=3),e.sslCA&&(o|=4,a=2),e.emailCA&&(o|=2,a=1),e.objCA&&(o|=1,a=0),c=String.fromCharCode(a),0!==o&&(c+=String.fromCharCode(o)),e.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,c);else if("subjectAltName"===e.name||"issuerAltName"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);for(var d=0;d<e.altNames.length;++d){if(c=(y=e.altNames[d]).value,7===y.type&&y.ip){if(null===(c=F.util.bytesFromIP(y.ip)))throw(C=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,C}else 8===y.type&&(c=y.oid?t.oidToDer(t.oidToDer(y.oid)):t.oidToDer(c));e.value.value.push(t.create(t.Class.CONTEXT_SPECIFIC,y.type,!1,c))}}else if("nsComment"===e.name&&i.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=t.create(t.Class.UNIVERSAL,t.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&i.cert){var p=i.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=p.toHex(),e.value=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,p.getBytes())}else if("authorityKeyIdentifier"===e.name&&i.cert){if(e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),u=e.value.value,e.keyIdentifier){var h=!0===e.keyIdentifier?i.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;u.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!1,h))}if(e.authorityCertIssuer){var g=[t.create(t.Class.CONTEXT_SPECIFIC,4,!0,[f(!0===e.authorityCertIssuer?i.cert.issuer:e.authorityCertIssuer)])];u.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,g))}if(e.serialNumber){var m=F.util.hexToBytes(!0===e.serialNumber?i.cert.serialNumber:e.serialNumber);u.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!1,m))}}else if("cRLDistributionPoints"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),u=e.value.value;var y,v=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),b=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(d=0;d<e.altNames.length;++d){if(c=(y=e.altNames[d]).value,7===y.type&&y.ip){if(null===(c=F.util.bytesFromIP(y.ip)))throw(C=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,C}else 8===y.type&&(c=y.oid?t.oidToDer(t.oidToDer(y.oid)):t.oidToDer(c));b.value.push(t.create(t.Class.CONTEXT_SPECIFIC,y.type,!1,c))}v.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[b])),u.push(v)}var C;if(void 0===e.value)throw(C=new Error("Extension value not specified.")).extension=e,C;return e}function g(e,r){switch(e){case n["RSASSA-PSS"]:var i=[];return void 0!==r.hash.algorithmOid&&i.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])),void 0!==r.mgf.algorithmOid&&i.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.mgf.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.mgf.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])])),void 0!==r.saltLength&&i.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.saltLength).getBytes())])),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,i);default:return t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")}}function m(e){var r=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===e.attributes.length)return r;for(var n=e.attributes,i=0;i<n.length;++i){var a=n[i],o=a.value,s=t.Type.UTF8;"valueTagClass"in a&&(s=a.valueTagClass),s===t.Type.UTF8&&(o=F.util.encodeUtf8(o));var c=!1;"valueConstructed"in a&&(c=a.valueConstructed);var u=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(a.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,s,c,o)])]);r.value.push(u)}return r}r.certificateFromPem=function(e,n,i){var a=F.pem.decode(e)[0];if("CERTIFICATE"!==a.type&&"X509 CERTIFICATE"!==a.type&&"TRUSTED CERTIFICATE"!==a.type){var o=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw o.headerType=a.type,o}if(a.procType&&"ENCRYPTED"===a.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=t.fromDer(a.body,i);return r.certificateFromAsn1(s,n)},r.certificateToPem=function(e,n){var i={type:"CERTIFICATE",body:t.toDer(r.certificateToAsn1(e)).getBytes()};return F.pem.encode(i,{maxline:n})},r.publicKeyFromPem=function(e){var n=F.pem.decode(e)[0];if("PUBLIC KEY"!==n.type&&"RSA PUBLIC KEY"!==n.type){var i=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert public key from PEM; PEM is encrypted.");var a=t.fromDer(n.body);return r.publicKeyFromAsn1(a)},r.publicKeyToPem=function(e,n){var i={type:"PUBLIC KEY",body:t.toDer(r.publicKeyToAsn1(e)).getBytes()};return F.pem.encode(i,{maxline:n})},r.publicKeyToRSAPublicKeyPem=function(e,n){var i={type:"RSA PUBLIC KEY",body:t.toDer(r.publicKeyToRSAPublicKey(e)).getBytes()};return F.pem.encode(i,{maxline:n})},r.getPublicKeyFingerprint=function(e,n){var i,a=(n=n||{}).md||F.md.sha1.create();switch(n.type||"RSAPublicKey"){case"RSAPublicKey":i=t.toDer(r.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":i=t.toDer(r.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+n.type+'".')}a.start(),a.update(i);var o=a.digest();if("hex"===n.encoding){var s=o.toHex();return n.delimiter?s.match(/.{2}/g).join(n.delimiter):s}if("binary"===n.encoding)return o.getBytes();if(n.encoding)throw new Error('Unknown encoding "'+n.encoding+'".');return o},r.certificationRequestFromPem=function(e,n,i){var a=F.pem.decode(e)[0];if("CERTIFICATE REQUEST"!==a.type){var o=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw o.headerType=a.type,o}if(a.procType&&"ENCRYPTED"===a.procType.type)throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=t.fromDer(a.body,i);return r.certificationRequestFromAsn1(s,n)},r.certificationRequestToPem=function(e,n){var i={type:"CERTIFICATE REQUEST",body:t.toDer(r.certificationRequestToAsn1(e)).getBytes()};return F.pem.encode(i,{maxline:n})},r.createCertificate=function(){var e={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return l(e.issuer,t)},e.issuer.addField=function(t){p([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return l(e.subject,t)},e.subject.addField=function(t){p([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,r){p(t),e.subject.attributes=t,delete e.subject.uniqueId,r&&(e.subject.uniqueId=r),e.subject.hash=null},e.setIssuer=function(t,r){p(t),e.issuer.attributes=t,delete e.issuer.uniqueId,r&&(e.issuer.uniqueId=r),e.issuer.hash=null},e.setExtensions=function(t){for(var r=0;r<t.length;++r)h(t[r],{cert:e});e.extensions=t},e.getExtension=function(t){"string"==typeof t&&(t={name:t});for(var r,n=null,i=0;null===n&&i<e.extensions.length;++i)r=e.extensions[i],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(n=r);return n},e.sign=function(i,a){e.md=a||F.md.sha1.create();var o=n[e.md.algorithm+"WithRSAEncryption"];if(!o){var s=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw s.algorithm=e.md.algorithm,s}e.signatureOid=e.siginfo.algorithmOid=o,e.tbsCertificate=r.getTBSCertificate(e);var c=t.toDer(e.tbsCertificate);e.md.update(c.getBytes()),e.signature=i.sign(e.md)},e.verify=function(i){var a=!1;if(!e.issued(i)){var o=i.issuer,s=e.subject;throw(h=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.")).expectedIssuer=o.attributes,h.actualIssuer=s.attributes,h}var c=i.md;if(null===c){if(i.signatureOid in n)switch(n[i.signatureOid]){case"sha1WithRSAEncryption":c=F.md.sha1.create();break;case"md5WithRSAEncryption":c=F.md.md5.create();break;case"sha256WithRSAEncryption":c=F.md.sha256.create();break;case"sha384WithRSAEncryption":c=F.md.sha384.create();break;case"sha512WithRSAEncryption":c=F.md.sha512.create();break;case"RSASSA-PSS":c=F.md.sha256.create()}if(null===c)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=i.signatureOid,h;var u=i.tbsCertificate||r.getTBSCertificate(i),l=t.toDer(u);c.update(l.getBytes())}if(null!==c){var d;switch(i.signatureOid){case n.sha1WithRSAEncryption:d=void 0;break;case n["RSASSA-PSS"]:var f,p,h;if(void 0===(f=n[i.signatureParameters.mgf.hash.algorithmOid])||void 0===F.md[f])throw(h=new Error("Unsupported MGF hash function.")).oid=i.signatureParameters.mgf.hash.algorithmOid,h.name=f,h;if(void 0===(p=n[i.signatureParameters.mgf.algorithmOid])||void 0===F.mgf[p])throw(h=new Error("Unsupported MGF function.")).oid=i.signatureParameters.mgf.algorithmOid,h.name=p,h;if(p=F.mgf[p].create(F.md[f].create()),void 0===(f=n[i.signatureParameters.hash.algorithmOid])||void 0===F.md[f])throw{message:"Unsupported RSASSA-PSS hash function.",oid:i.signatureParameters.hash.algorithmOid,name:f};d=F.pss.create(F.md[f].create(),p,i.signatureParameters.saltLength)}a=e.publicKey.verify(c.digest().getBytes(),i.signature,d)}return a},e.isIssuer=function(t){var r=!1,n=e.issuer,i=t.subject;if(n.hash&&i.hash)r=n.hash===i.hash;else if(n.attributes.length===i.attributes.length){var a,o;r=!0;for(var s=0;r&&s<n.attributes.length;++s)a=n.attributes[s],o=i.attributes[s],a.type===o.type&&a.value===o.value||(r=!1)}return r},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return r.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=n.subjectKeyIdentifier,r=0;r<e.extensions.length;++r){var i=e.extensions[r];if(i.id===t){var a=e.generateSubjectKeyIdentifier().getBytes();return F.util.hexToBytes(i.subjectKeyIdentifier)===a}}return!1},e},r.certificateFromAsn1=function(e,i){var a={},s=[];if(!t.validate(e,o,a,s))throw(h=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.")).errors=s,h;if(t.derToOid(a.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var c=r.createCertificate();c.version=a.certVersion?a.certVersion.charCodeAt(0):0;var u=F.util.createBuffer(a.certSerialNumber);c.serialNumber=u.toHex(),c.signatureOid=F.asn1.derToOid(a.certSignatureOid),c.signatureParameters=d(c.signatureOid,a.certSignatureParams,!0),c.siginfo.algorithmOid=F.asn1.derToOid(a.certinfoSignatureOid),c.siginfo.parameters=d(c.siginfo.algorithmOid,a.certinfoSignatureParams,!1),c.signature=a.certSignature;var f=[];if(void 0!==a.certValidity1UTCTime&&f.push(t.utcTimeToDate(a.certValidity1UTCTime)),void 0!==a.certValidity2GeneralizedTime&&f.push(t.generalizedTimeToDate(a.certValidity2GeneralizedTime)),void 0!==a.certValidity3UTCTime&&f.push(t.utcTimeToDate(a.certValidity3UTCTime)),void 0!==a.certValidity4GeneralizedTime&&f.push(t.generalizedTimeToDate(a.certValidity4GeneralizedTime)),f.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(f.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=f[0],c.validity.notAfter=f[1],c.tbsCertificate=a.tbsCertificate,i){var h;if(c.md=null,c.signatureOid in n)switch(n[c.signatureOid]){case"sha1WithRSAEncryption":c.md=F.md.sha1.create();break;case"md5WithRSAEncryption":c.md=F.md.md5.create();break;case"sha256WithRSAEncryption":c.md=F.md.sha256.create();break;case"sha384WithRSAEncryption":c.md=F.md.sha384.create();break;case"sha512WithRSAEncryption":c.md=F.md.sha512.create();break;case"RSASSA-PSS":c.md=F.md.sha256.create()}if(null===c.md)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=c.signatureOid,h;var g=t.toDer(c.tbsCertificate);c.md.update(g.getBytes())}var m=F.md.sha1.create();c.issuer.getField=function(e){return l(c.issuer,e)},c.issuer.addField=function(e){p([e]),c.issuer.attributes.push(e)},c.issuer.attributes=r.RDNAttributesAsArray(a.certIssuer,m),a.certIssuerUniqueId&&(c.issuer.uniqueId=a.certIssuerUniqueId),c.issuer.hash=m.digest().toHex();var y=F.md.sha1.create();return c.subject.getField=function(e){return l(c.subject,e)},c.subject.addField=function(e){p([e]),c.subject.attributes.push(e)},c.subject.attributes=r.RDNAttributesAsArray(a.certSubject,y),a.certSubjectUniqueId&&(c.subject.uniqueId=a.certSubjectUniqueId),c.subject.hash=y.digest().toHex(),a.certExtensions?c.extensions=r.certificateExtensionsFromAsn1(a.certExtensions):c.extensions=[],c.publicKey=r.publicKeyFromAsn1(a.subjectPublicKeyInfo),c},r.certificateExtensionsFromAsn1=function(e){for(var t=[],n=0;n<e.value.length;++n)for(var i=e.value[n],a=0;a<i.value.length;++a)t.push(r.certificateExtensionFromAsn1(i.value[a]));return t},r.certificateExtensionFromAsn1=function(e){var r={};if(r.id=t.derToOid(e.value[0].value),r.critical=!1,e.value[1].type===t.Type.BOOLEAN?(r.critical=0!==e.value[1].value.charCodeAt(0),r.value=e.value[2].value):r.value=e.value[1].value,r.id in n)if(r.name=n[r.id],"keyUsage"===r.name){var i=0,a=0;(s=t.fromDer(r.value)).value.length>1&&(i=s.value.charCodeAt(1),a=s.value.length>2?s.value.charCodeAt(2):0),r.digitalSignature=128==(128&i),r.nonRepudiation=64==(64&i),r.keyEncipherment=32==(32&i),r.dataEncipherment=16==(16&i),r.keyAgreement=8==(8&i),r.keyCertSign=4==(4&i),r.cRLSign=2==(2&i),r.encipherOnly=1==(1&i),r.decipherOnly=128==(128&a)}else if("basicConstraints"===r.name){(s=t.fromDer(r.value)).value.length>0&&s.value[0].type===t.Type.BOOLEAN?r.cA=0!==s.value[0].value.charCodeAt(0):r.cA=!1;var o=null;s.value.length>0&&s.value[0].type===t.Type.INTEGER?o=s.value[0].value:s.value.length>1&&(o=s.value[1].value),null!==o&&(r.pathLenConstraint=t.derToInteger(o))}else if("extKeyUsage"===r.name)for(var s=t.fromDer(r.value),c=0;c<s.value.length;++c){var u=t.derToOid(s.value[c].value);u in n?r[n[u]]=!0:r[u]=!0}else if("nsCertType"===r.name)i=0,(s=t.fromDer(r.value)).value.length>1&&(i=s.value.charCodeAt(1)),r.client=128==(128&i),r.server=64==(64&i),r.email=32==(32&i),r.objsign=16==(16&i),r.reserved=8==(8&i),r.sslCA=4==(4&i),r.emailCA=2==(2&i),r.objCA=1==(1&i);else if("subjectAltName"===r.name||"issuerAltName"===r.name){var l;r.altNames=[],s=t.fromDer(r.value);for(var d=0;d<s.value.length;++d){var f={type:(l=s.value[d]).type,value:l.value};switch(r.altNames.push(f),l.type){case 1:case 2:case 6:break;case 7:f.ip=F.util.bytesToIP(l.value);break;case 8:f.oid=t.derToOid(l.value)}}}else"subjectKeyIdentifier"===r.name&&(s=t.fromDer(r.value),r.subjectKeyIdentifier=F.util.bytesToHex(s.value));return r},r.certificationRequestFromAsn1=function(e,i){var a={},o=[];if(!t.validate(e,u,a,o))throw(c=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.")).errors=o,c;if(t.derToOid(a.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var s=r.createCertificationRequest();if(s.version=a.csrVersion?a.csrVersion.charCodeAt(0):0,s.signatureOid=F.asn1.derToOid(a.csrSignatureOid),s.signatureParameters=d(s.signatureOid,a.csrSignatureParams,!0),s.siginfo.algorithmOid=F.asn1.derToOid(a.csrSignatureOid),s.siginfo.parameters=d(s.siginfo.algorithmOid,a.csrSignatureParams,!1),s.signature=a.csrSignature,s.certificationRequestInfo=a.certificationRequestInfo,i){var c;if(s.md=null,s.signatureOid in n)switch(n[s.signatureOid]){case"sha1WithRSAEncryption":s.md=F.md.sha1.create();break;case"md5WithRSAEncryption":s.md=F.md.md5.create();break;case"sha256WithRSAEncryption":s.md=F.md.sha256.create();break;case"sha384WithRSAEncryption":s.md=F.md.sha384.create();break;case"sha512WithRSAEncryption":s.md=F.md.sha512.create();break;case"RSASSA-PSS":s.md=F.md.sha256.create()}if(null===s.md)throw(c=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=s.signatureOid,c;var f=t.toDer(s.certificationRequestInfo);s.md.update(f.getBytes())}var h=F.md.sha1.create();return s.subject.getField=function(e){return l(s.subject,e)},s.subject.addField=function(e){p([e]),s.subject.attributes.push(e)},s.subject.attributes=r.RDNAttributesAsArray(a.certificationRequestInfoSubject,h),s.subject.hash=h.digest().toHex(),s.publicKey=r.publicKeyFromAsn1(a.subjectPublicKeyInfo),s.getAttribute=function(e){return l(s,e)},s.addAttribute=function(e){p([e]),s.attributes.push(e)},s.attributes=r.CRIAttributesAsArray(a.certificationRequestInfoAttributes||[]),s},r.createCertificationRequest=function(){var e={version:0,signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return l(e.subject,t)},e.subject.addField=function(t){p([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return l(e,t)},e.addAttribute=function(t){p([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){p(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){p(t),e.attributes=t},e.sign=function(i,a){e.md=a||F.md.sha1.create();var o=n[e.md.algorithm+"WithRSAEncryption"];if(!o){var s=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw s.algorithm=e.md.algorithm,s}e.signatureOid=e.siginfo.algorithmOid=o,e.certificationRequestInfo=r.getCertificationRequestInfo(e);var c=t.toDer(e.certificationRequestInfo);e.md.update(c.getBytes()),e.signature=i.sign(e.md)},e.verify=function(){var i=!1,a=e.md;if(null===a){if(e.signatureOid in n)switch(n[e.signatureOid]){case"sha1WithRSAEncryption":a=F.md.sha1.create();break;case"md5WithRSAEncryption":a=F.md.md5.create();break;case"sha256WithRSAEncryption":a=F.md.sha256.create();break;case"sha384WithRSAEncryption":a=F.md.sha384.create();break;case"sha512WithRSAEncryption":a=F.md.sha512.create();break;case"RSASSA-PSS":a=F.md.sha256.create()}if(null===a)throw(d=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=e.signatureOid,d;var o=e.certificationRequestInfo||r.getCertificationRequestInfo(e),s=t.toDer(o);a.update(s.getBytes())}if(null!==a){var c;switch(e.signatureOid){case n.sha1WithRSAEncryption:break;case n["RSASSA-PSS"]:var u,l,d;if(void 0===(u=n[e.signatureParameters.mgf.hash.algorithmOid])||void 0===F.md[u])throw(d=new Error("Unsupported MGF hash function.")).oid=e.signatureParameters.mgf.hash.algorithmOid,d.name=u,d;if(void 0===(l=n[e.signatureParameters.mgf.algorithmOid])||void 0===F.mgf[l])throw(d=new Error("Unsupported MGF function.")).oid=e.signatureParameters.mgf.algorithmOid,d.name=l,d;if(l=F.mgf[l].create(F.md[u].create()),void 0===(u=n[e.signatureParameters.hash.algorithmOid])||void 0===F.md[u])throw(d=new Error("Unsupported RSASSA-PSS hash function.")).oid=e.signatureParameters.hash.algorithmOid,d.name=u,d;c=F.pss.create(F.md[u].create(),l,e.signatureParameters.saltLength)}i=e.publicKey.verify(a.digest().getBytes(),e.signature,c)}return i},e};var y=new Date("1950-01-01T00:00:00Z"),v=new Date("2050-01-01T00:00:00Z");function b(e){return e>=y&&e<v?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(e)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(e))}r.getTBSCertificate=function(e){var n=b(e.validity.notBefore),i=b(e.validity.notAfter),a=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,F.util.hexToBytes(e.serialNumber)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.siginfo.algorithmOid).getBytes()),g(e.siginfo.algorithmOid,e.siginfo.parameters)]),f(e.issuer),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,i]),f(e.subject),r.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&a.value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&a.value.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&a.value.push(r.certificateExtensionsToAsn1(e.extensions)),a},r.getCertificationRequestInfo=function(e){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),f(e.subject),r.publicKeyToAsn1(e.publicKey),m(e)])},r.distinguishedNameToAsn1=function(e){return f(e)},r.certificateToAsn1=function(e){var n=e.tbsCertificate||r.getTBSCertificate(e);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureOid).getBytes()),g(e.signatureOid,e.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},r.certificateExtensionsToAsn1=function(e){var n=t.create(t.Class.CONTEXT_SPECIFIC,3,!0,[]),i=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);n.value.push(i);for(var a=0;a<e.length;++a)i.value.push(r.certificateExtensionToAsn1(e[a]));return n},r.certificateExtensionToAsn1=function(e){var r=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.id).getBytes())),e.critical&&r.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255)));var n=e.value;return"string"!=typeof e.value&&(n=t.toDer(n).getBytes()),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n)),r},r.certificationRequestToAsn1=function(e){var n=e.certificationRequestInfo||r.getCertificationRequestInfo(e);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureOid).getBytes()),g(e.signatureOid,e.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},r.createCaStore=function(e){var n={certs:{}};function i(e){return a(e),n.certs[e.hash]||null}function a(e){if(!e.hash){var t=F.md.sha1.create();e.attributes=r.RDNAttributesAsArray(f(e),t),e.hash=t.digest().toHex()}}if(n.getIssuer=function(e){return i(e.issuer)},n.addCertificate=function(e){if("string"==typeof e&&(e=F.pki.certificateFromPem(e)),a(e.subject),!n.hasCertificate(e))if(e.subject.hash in n.certs){var t=n.certs[e.subject.hash];F.util.isArray(t)||(t=[t]),t.push(e),n.certs[e.subject.hash]=t}else n.certs[e.subject.hash]=e},n.hasCertificate=function(e){"string"==typeof e&&(e=F.pki.certificateFromPem(e));var n=i(e.subject);if(!n)return!1;F.util.isArray(n)||(n=[n]);for(var a=t.toDer(r.certificateToAsn1(e)).getBytes(),o=0;o<n.length;++o)if(a===t.toDer(r.certificateToAsn1(n[o])).getBytes())return!0;return!1},n.listAllCertificates=function(){var e=[];for(var t in n.certs)if(n.certs.hasOwnProperty(t)){var r=n.certs[t];if(F.util.isArray(r))for(var i=0;i<r.length;++i)e.push(r[i]);else e.push(r)}return e},n.removeCertificate=function(e){var o;if("string"==typeof e&&(e=F.pki.certificateFromPem(e)),a(e.subject),!n.hasCertificate(e))return null;var s=i(e.subject);if(!F.util.isArray(s))return o=n.certs[e.subject.hash],delete n.certs[e.subject.hash],o;for(var c=t.toDer(r.certificateToAsn1(e)).getBytes(),u=0;u<s.length;++u)c===t.toDer(r.certificateToAsn1(s[u])).getBytes()&&(o=s[u],s.splice(u,1));return 0===s.length&&delete n.certs[e.subject.hash],o},e)for(var o=0;o<e.length;++o){var s=e[o];n.addCertificate(s)}return n},r.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},r.verifyCertificateChain=function(e,t,n){"function"==typeof n&&(n={verify:n}),n=n||{};var i=(t=t.slice(0)).slice(0),a=n.validityCheckDate;void 0===a&&(a=new Date);var o=!0,s=null,c=0;do{var u=t.shift(),l=null,d=!1;if(a&&(a<u.validity.notBefore||a>u.validity.notAfter)&&(s={message:"Certificate is not valid yet or has expired.",error:r.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:a}),null===s){if(null===(l=t[0]||e.getIssuer(u))&&u.isIssuer(u)&&(d=!0,l=u),l){var f=l;F.util.isArray(f)||(f=[f]);for(var p=!1;!p&&f.length>0;){l=f.shift();try{p=l.verify(u)}catch(e){}}p||(s={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}null!==s||l&&!d||e.hasCertificate(u)||(s={message:"Certificate is not trusted.",error:r.certificateError.unknown_ca})}if(null===s&&l&&!u.isIssuer(l)&&(s={message:"Certificate issuer is invalid.",error:r.certificateError.bad_certificate}),null===s)for(var h={keyUsage:!0,basicConstraints:!0},g=0;null===s&&g<u.extensions.length;++g){var m=u.extensions[g];!m.critical||m.name in h||(s={message:"Certificate has an unsupported critical extension.",error:r.certificateError.unsupported_certificate})}if(null===s&&(!o||0===t.length&&(!l||d))){var y=u.getExtension("basicConstraints"),v=u.getExtension("keyUsage");null!==v&&(v.keyCertSign&&null!==y||(s={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:r.certificateError.bad_certificate})),null!==s||null===y||y.cA||(s={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:r.certificateError.bad_certificate}),null===s&&null!==v&&"pathLenConstraint"in y&&c-1>y.pathLenConstraint&&(s={message:"Certificate basicConstraints pathLenConstraint violated.",error:r.certificateError.bad_certificate})}var b=null===s||s.error,C=n.verify?n.verify(b,c,i):b;if(!0!==C)throw!0===b&&(s={message:"The application rejected the certificate.",error:r.certificateError.bad_certificate}),(C||0===C)&&("object"!=typeof C||F.util.isArray(C)?"string"==typeof C&&(s.error=C):(C.message&&(s.message=C.message),C.error&&(s.error=C.error))),s;s=null,o=!1,++c}while(t.length>0);return!0}})),E((function(e){var t=F.asn1,r=F.pki,n=e.exports=F.pkcs12=F.pkcs12||{},i={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},a={name:"PFX",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},i,{name:"PFX.macData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},o={name:"SafeBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},s={name:"Attribute",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,capture:"values"}]},c={name:"CertBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:t.Class.UNIVERSAL,type:t.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function u(e,t,r,n){for(var i=[],a=0;a<e.length;a++)for(var o=0;o<e[a].safeBags.length;o++){var s=e[a].safeBags[o];void 0!==n&&s.type!==n||(null!==t?void 0!==s.attributes[t]&&s.attributes[t].indexOf(r)>=0&&i.push(s):i.push(s))}return i}function l(e){if(e.composed||e.constructed){for(var t=F.util.createBuffer(),r=0;r<e.value.length;++r)t.putBytes(e.value[r].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function d(e,n){var i={},a=[];if(!t.validate(e,F.pkcs7.asn1.encryptedDataValidator,i,a))throw(o=new Error("Cannot read EncryptedContentInfo.")).errors=a,o;var o,s=t.derToOid(i.contentType);if(s!==r.oids.data)throw(o=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.")).oid=s,o;s=t.derToOid(i.encAlgorithm);var c=r.pbe.getCipher(s,i.encParameter,n),u=l(i.encryptedContentAsn1),d=F.util.createBuffer(u.value);if(c.update(d),!c.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return c.output.getBytes()}function f(e,n,i){if(!n&&0===e.length)return[];if((e=t.fromDer(e,n)).tagClass!==t.Class.UNIVERSAL||e.type!==t.Type.SEQUENCE||!0!==e.constructed)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var a=[],s=0;s<e.value.length;s++){var u=e.value[s],l={},d=[];if(!t.validate(u,o,l,d))throw(y=new Error("Cannot read SafeBag.")).errors=d,y;var f,h,g={type:t.derToOid(l.bagId),attributes:p(l.bagAttributes)};a.push(g);var m=l.bagValue.value[0];switch(g.type){case r.oids.pkcs8ShroudedKeyBag:if(null===(m=r.decryptPrivateKeyInfo(m,i)))throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case r.oids.keyBag:try{g.key=r.privateKeyFromAsn1(m)}catch(e){g.key=null,g.asn1=m}continue;case r.oids.certBag:f=c,h=function(){if(t.derToOid(l.certId)!==r.oids.x509Certificate){var e=new Error("Unsupported certificate type, only X.509 supported.");throw e.oid=t.derToOid(l.certId),e}var i=t.fromDer(l.cert,n);try{g.cert=r.certificateFromAsn1(i,!0)}catch(e){g.cert=null,g.asn1=i}};break;default:var y;throw(y=new Error("Unsupported PKCS#12 SafeBag type.")).oid=g.type,y}if(void 0!==f&&!t.validate(m,f,l,d))throw(y=new Error("Cannot read PKCS#12 "+f.name)).errors=d,y;h()}return a}function p(e){var n={};if(void 0!==e)for(var i=0;i<e.length;++i){var a={},o=[];if(!t.validate(e[i],s,a,o)){var c=new Error("Cannot read PKCS#12 BagAttribute.");throw c.errors=o,c}var u=t.derToOid(a.oid);if(void 0!==r.oids[u]){n[r.oids[u]]=[];for(var l=0;l<a.values.length;++l)n[r.oids[u]].push(a.values[l].value)}}return n}n.pkcs12FromAsn1=function(e,o,s){"string"==typeof o?(s=o,o=!0):void 0===o&&(o=!0);var c={};if(!t.validate(e,a,c,[]))throw(p=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.")).errors=p,p;var p,h={version:c.version.charCodeAt(0),safeContents:[],getBags:function(e){var t,r={};return"localKeyId"in e?t=e.localKeyId:"localKeyIdHex"in e&&(t=F.util.hexToBytes(e.localKeyIdHex)),void 0===t&&!("friendlyName"in e)&&"bagType"in e&&(r[e.bagType]=u(h.safeContents,null,null,e.bagType)),void 0!==t&&(r.localKeyId=u(h.safeContents,"localKeyId",t,e.bagType)),"friendlyName"in e&&(r.friendlyName=u(h.safeContents,"friendlyName",e.friendlyName,e.bagType)),r},getBagsByFriendlyName:function(e,t){return u(h.safeContents,"friendlyName",e,t)},getBagsByLocalKeyId:function(e,t){return u(h.safeContents,"localKeyId",e,t)}};if(3!==c.version.charCodeAt(0))throw(p=new Error("PKCS#12 PFX of version other than 3 not supported.")).version=c.version.charCodeAt(0),p;if(t.derToOid(c.contentType)!==r.oids.data)throw(p=new Error("Only PKCS#12 PFX in password integrity mode supported.")).oid=t.derToOid(c.contentType),p;var g=c.content.value[0];if(g.tagClass!==t.Class.UNIVERSAL||g.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(g=l(g),c.mac){var m=null,y=0,v=t.derToOid(c.macAlgorithm);switch(v){case r.oids.sha1:m=F.md.sha1.create(),y=20;break;case r.oids.sha256:m=F.md.sha256.create(),y=32;break;case r.oids.sha384:m=F.md.sha384.create(),y=48;break;case r.oids.sha512:m=F.md.sha512.create(),y=64;break;case r.oids.md5:m=F.md.md5.create(),y=16}if(null===m)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+v);var b=new F.util.ByteBuffer(c.macSalt),C="macIterations"in c?parseInt(F.util.bytesToHex(c.macIterations),16):1,E=n.generateKey(s,b,3,C,y,m),w=F.hmac.create();if(w.start(m,E),w.update(g.value),w.getMac().getBytes()!==c.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return function(e,n,a,o){if((n=t.fromDer(n,a)).tagClass!==t.Class.UNIVERSAL||n.type!==t.Type.SEQUENCE||!0!==n.constructed)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var s=0;s<n.value.length;s++){var c=n.value[s],u={},p=[];if(!t.validate(c,i,u,p))throw(y=new Error("Cannot read ContentInfo.")).errors=p,y;var h={encrypted:!1},g=null,m=u.content.value[0];switch(t.derToOid(u.contentType)){case r.oids.data:if(m.tagClass!==t.Class.UNIVERSAL||m.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");g=l(m).value;break;case r.oids.encryptedData:g=d(m,o),h.encrypted=!0;break;default:var y;throw(y=new Error("Unsupported PKCS#12 contentType.")).contentType=t.derToOid(u.contentType),y}h.safeBags=f(g,a,o),e.safeContents.push(h)}}(h,g.value,o,s),h},n.toPkcs12Asn1=function(e,i,a,o){(o=o||{}).saltSize=o.saltSize||8,o.count=o.count||2048,o.algorithm=o.algorithm||o.encAlgorithm||"aes128","useMac"in o||(o.useMac=!0),"localKeyId"in o||(o.localKeyId=null),"generateLocalKeyId"in o||(o.generateLocalKeyId=!0);var s,c=o.localKeyId;if(null!==c)c=F.util.hexToBytes(c);else if(o.generateLocalKeyId)if(i){var u=F.util.isArray(i)?i[0]:i;"string"==typeof u&&(u=r.certificateFromPem(u)),(T=F.md.sha1.create()).update(t.toDer(r.certificateToAsn1(u)).getBytes()),c=T.digest().getBytes()}else c=F.random.getBytes(20);var l=[];null!==c&&l.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.localKeyId).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,c)])])),"friendlyName"in o&&l.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.friendlyName).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.BMPSTRING,!1,o.friendlyName)])])),l.length>0&&(s=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,l));var d=[],f=[];null!==i&&(f=F.util.isArray(i)?i:[i]);for(var p=[],h=0;h<f.length;++h){"string"==typeof(i=f[h])&&(i=r.certificateFromPem(i));var g=0===h?s:void 0,m=r.certificateToAsn1(i),y=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.certBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.x509Certificate).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(m).getBytes())])])]),g]);p.push(y)}if(p.length>0){var v=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,p),b=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(v).getBytes())])]);d.push(b)}var C=null;if(null!==e){var E=r.wrapRsaPrivateKey(r.privateKeyToAsn1(e));C=null===a?t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.keyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[E]),s]):t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.pkcs8ShroudedKeyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[r.encryptPrivateKeyInfo(E,a,o)]),s]);var w=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[C]),k=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(w).getBytes())])]);d.push(k)}var S,B=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,d);if(o.useMac){var T=F.md.sha1.create(),A=new F.util.ByteBuffer(F.random.getBytes(o.saltSize)),I=o.count,_=(e=n.generateKey(a,A,3,I,20),F.hmac.create());_.start(T,e),_.update(t.toDer(B).getBytes());var x=_.getMac();S=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.sha1).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,x.getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,A.getBytes()),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(I).getBytes())])}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(3).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(B).getBytes())])]),S])},n.generateKey=F.pbe.generatePkcs12Key})),E((function(e){var t=F.asn1,r=e.exports=F.pki=F.pki||{};r.pemToDer=function(e){var t=F.pem.decode(e)[0];if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert PEM to DER; PEM is encrypted.");return F.util.createBuffer(t.body)},r.privateKeyFromPem=function(e){var n=F.pem.decode(e)[0];if("PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type){var i=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert private key from PEM; PEM is encrypted.");var a=t.fromDer(n.body);return r.privateKeyFromAsn1(a)},r.privateKeyToPem=function(e,n){var i={type:"RSA PRIVATE KEY",body:t.toDer(r.privateKeyToAsn1(e)).getBytes()};return F.pem.encode(i,{maxline:n})},r.privateKeyInfoToPem=function(e,r){var n={type:"PRIVATE KEY",body:t.toDer(e).getBytes()};return F.pem.encode(n,{maxline:r})}}));var St=function(e,t,r,n){var i=F.util.createBuffer(),a=e.length>>1,o=a+(1&e.length),s=e.substr(0,o),c=e.substr(a,o),u=F.util.createBuffer(),l=F.hmac.create();r=t+r;var d=Math.ceil(n/16),f=Math.ceil(n/20);l.start("MD5",s);var p=F.util.createBuffer();u.putBytes(r);for(var h=0;h<d;++h)l.start(null,null),l.update(u.getBytes()),u.putBuffer(l.digest()),l.start(null,null),l.update(u.bytes()+r),p.putBuffer(l.digest());l.start("SHA1",c);var g=F.util.createBuffer();for(u.clear(),u.putBytes(r),h=0;h<f;++h)l.start(null,null),l.update(u.getBytes()),u.putBuffer(l.digest()),l.start(null,null),l.update(u.bytes()+r),g.putBuffer(l.digest());return i.putBytes(F.util.xorBytes(p.getBytes(),g.getBytes(),n)),i},Bt=function(e,t,r){var n=!1;try{var i=e.deflate(t.fragment.getBytes());t.fragment=F.util.createBuffer(i),t.length=i.length,n=!0}catch(e){}return n},Tt=function(e,t,r){var n=!1;try{var i=e.inflate(t.fragment.getBytes());t.fragment=F.util.createBuffer(i),t.length=i.length,n=!0}catch(e){}return n},At=function(e,t){var r=0;switch(t){case 1:r=e.getByte();break;case 2:r=e.getInt16();break;case 3:r=e.getInt24();break;case 4:r=e.getInt32()}return F.util.createBuffer(e.getBytes(r))},It=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},_t={Versions:{TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}}};_t.SupportedVersions=[_t.Versions.TLS_1_1,_t.Versions.TLS_1_0],_t.Version=_t.SupportedVersions[0],_t.MaxFragment=15360,_t.ConnectionEnd={server:0,client:1},_t.PRFAlgorithm={tls_prf_sha256:0},_t.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},_t.CipherType={stream:0,block:1,aead:2},_t.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},_t.CompressionMethod={none:0,deflate:1},_t.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},_t.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},_t.Alert={},_t.Alert.Level={warning:1,fatal:2},_t.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,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},_t.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},_t.CipherSuites={},_t.getCipherSuite=function(e){var t=null;for(var r in _t.CipherSuites){var n=_t.CipherSuites[r];if(n.id[0]===e.charCodeAt(0)&&n.id[1]===e.charCodeAt(1)){t=n;break}}return t},_t.handleUnexpected=function(e,t){!e.open&&e.entity===_t.ConnectionEnd.client||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unexpected_message}})},_t.handleHelloRequest=function(e,t,r){!e.handshaking&&e.handshakes>0&&(_t.queue(e,_t.createAlert(e,{level:_t.Alert.Level.warning,description:_t.Alert.Description.no_renegotiation})),_t.flush(e)),e.process()},_t.parseHelloMessage=function(e,t,r){var n=null,i=e.entity===_t.ConnectionEnd.client;if(r<38)e.error(e,{message:i?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});else{var a=t.fragment,o=a.length();if(n={version:{major:a.getByte(),minor:a.getByte()},random:F.util.createBuffer(a.getBytes(32)),session_id:At(a,1),extensions:[]},i?(n.cipher_suite=a.getBytes(2),n.compression_method=a.getByte()):(n.cipher_suites=At(a,2),n.compression_methods=At(a,1)),(o=r-(o-a.length()))>0){for(var s=At(a,2);s.length()>0;)n.extensions.push({type:[s.getByte(),s.getByte()],data:At(s,2)});if(!i)for(var c=0;c<n.extensions.length;++c){var u=n.extensions[c];if(0===u.type[0]&&0===u.type[1])for(var l=At(u.data,2);l.length()>0&&0===l.getByte();)e.session.extensions.server_name.serverNameList.push(At(l,2).getBytes())}}if(e.session.version&&(n.version.major!==e.session.version.major||n.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}});if(i)e.session.cipherSuite=_t.getCipherSuite(n.cipher_suite);else for(var d=F.util.createBuffer(n.cipher_suites.bytes());d.length()>0&&(e.session.cipherSuite=_t.getCipherSuite(d.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.handshake_failure},cipherSuite:F.util.bytesToHex(n.cipher_suite)});e.session.compressionMethod=i?n.compression_method:_t.CompressionMethod.none}return n},_t.createSecurityParameters=function(e,t){var r=e.entity===_t.ConnectionEnd.client,n=t.random.bytes(),i=r?e.session.sp.client_random:n,a=r?n:_t.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:_t.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:i,server_random:a}},_t.handleServerHello=function(e,t,r){var n=_t.parseHelloMessage(e,t,r);if(!e.fail){if(!(n.version.minor<=e.version.minor))return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}});e.version.minor=n.version.minor,e.session.version=e.version;var i=n.session_id.bytes();i.length>0&&i===e.session.id?(e.expect=Ot,e.session.resuming=!0,e.session.sp.server_random=n.random.bytes()):(e.expect=xt,e.session.resuming=!1,_t.createSecurityParameters(e,n)),e.session.id=i,e.process()}},_t.handleClientHello=function(e,t,r){var n=_t.parseHelloMessage(e,t,r);if(!e.fail){var i=n.session_id.bytes(),a=null;if(e.sessionCache&&(null===(a=e.sessionCache.getSession(i))?i="":(a.version.major!==n.version.major||a.version.minor>n.version.minor)&&(a=null,i="")),0===i.length&&(i=F.random.getBytes(32)),e.session.id=i,e.session.clientHelloVersion=n.version,e.session.sp={},a)e.version=e.session.version=a.version,e.session.sp=a.sp;else{for(var o,s=1;s<_t.SupportedVersions.length&&!((o=_t.SupportedVersions[s]).minor<=n.version.minor);++s);e.version={major:o.major,minor:o.minor},e.session.version=e.version}null!==a?(e.expect=Ft,e.session.resuming=!0,e.session.sp.client_random=n.random.bytes()):(e.expect=!1!==e.verifyClient?Mt:Vt,e.session.resuming=!1,_t.createSecurityParameters(e,n)),e.open=!0,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerHello(e)})),e.session.resuming?(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.pending=_t.createConnectionState(e),e.state.current.write=e.state.pending.write,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)}))):(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificate(e)})),e.fail||(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerKeyExchange(e)})),!1!==e.verifyClient&&_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificateRequest(e)})),_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerHelloDone(e)})))),_t.flush(e),e.process()}},_t.handleCertificate=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n,i,a=t.fragment,o={certificate_list:At(a,3)},s=[];try{for(;o.certificate_list.length()>0;)n=At(o.certificate_list,3),i=F.asn1.fromDer(n),n=F.pki.certificateFromAsn1(i,!0),s.push(n)}catch(t){return e.error(e,{message:"Could not parse certificate list.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate}})}var c=e.entity===_t.ConnectionEnd.client;!c&&!0!==e.verifyClient||0!==s.length?0===s.length?e.expect=c?Pt:Vt:(c?e.session.serverCertificate=s[0]:e.session.clientCertificate=s[0],_t.verifyCertificateChain(e,s)&&(e.expect=c?Pt:Vt)):e.error(e,{message:c?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}}),e.process()},_t.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unsupported_certificate}});e.expect=Rt,e.process()},_t.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unsupported_certificate}});var n=t.fragment,i={enc_pre_master_secret:At(n,2).getBytes()},a=null;if(e.getPrivateKey)try{a=e.getPrivateKey(e,e.session.serverCertificate),a=F.pki.privateKeyFromPem(a)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}})}if(null===a)return e.error(e,{message:"No private key set.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}});try{var o=e.session.sp;o.pre_master_secret=a.decrypt(i.enc_pre_master_secret);var s=e.session.clientHelloVersion;if(s.major!==o.pre_master_secret.charCodeAt(0)||s.minor!==o.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){o.pre_master_secret=F.random.getBytes(48)}e.expect=Ft,null!==e.session.clientCertificate&&(e.expect=jt),e.process()},_t.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n=t.fragment,i={certificate_types:At(n,1),certificate_authorities:At(n,2)};e.session.certificateRequest=i,e.expect=Nt,e.process()},_t.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var a={signature:At(n,2).getBytes()},o=F.util.createBuffer();o.putBuffer(e.session.md5.digest()),o.putBuffer(e.session.sha1.digest()),o=o.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(o,a.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(i),e.session.sha1.update(i)}catch(t){return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.handshake_failure}})}e.expect=Ft,e.process()},_t.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.record_overflow}});if(null===e.serverCertificate){var n={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.insufficient_security}},i=e.verify(e,n.alert.description,0,[]);if(!0!==i)return(i||0===i)&&("object"!=typeof i||F.util.isArray(i)?"number"==typeof i&&(n.alert.description=i):(i.message&&(n.message=i.message),i.alert&&(n.alert.description=i.alert))),e.error(e,n)}null!==e.session.certificateRequest&&(t=_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificate(e)}),_t.queue(e,t)),t=_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createClientKeyExchange(e)}),_t.queue(e,t),e.expect=Ut;var a=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificateVerify(e,t)})),_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.pending=_t.createConnectionState(e),e.state.current.write=e.state.pending.write,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)})),e.expect=Ot,_t.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return a(e,null);_t.getClientSignature(e,a)},_t.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var r=e.entity===_t.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=_t.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?Lt:zt,e.process()},_t.handleFinished=function(e,t,r){var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var a=t.fragment.getBytes();(n=F.util.createBuffer()).putBuffer(e.session.md5.digest()),n.putBuffer(e.session.sha1.digest());var o=e.entity===_t.ConnectionEnd.client,s=o?"server finished":"client finished",c=e.session.sp;if((n=St(c.master_secret,s,n.getBytes(),12)).getBytes()!==a)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.decrypt_error}});e.session.md5.update(i),e.session.sha1.update(i),(e.session.resuming&&o||!e.session.resuming&&!o)&&(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)}))),e.expect=o?Dt:Kt,e.handshaking=!1,++e.handshakes,e.peerCertificate=o?e.session.serverCertificate:e.session.clientCertificate,_t.flush(e),e.isConnected=!0,e.connected(e),e.process()},_t.handleAlert=function(e,t){var r,n=t.fragment,i={level:n.getByte(),description:n.getByte()};switch(i.description){case _t.Alert.Description.close_notify:r="Connection closed.";break;case _t.Alert.Description.unexpected_message:r="Unexpected message.";break;case _t.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case _t.Alert.Description.decryption_failed:r="Decryption failed.";break;case _t.Alert.Description.record_overflow:r="Record overflow.";break;case _t.Alert.Description.decompression_failure:r="Decompression failed.";break;case _t.Alert.Description.handshake_failure:r="Handshake failure.";break;case _t.Alert.Description.bad_certificate:r="Bad certificate.";break;case _t.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case _t.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case _t.Alert.Description.certificate_expired:r="Certificate expired.";break;case _t.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case _t.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case _t.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case _t.Alert.Description.access_denied:r="Access denied.";break;case _t.Alert.Description.decode_error:r="Decode error.";break;case _t.Alert.Description.decrypt_error:r="Decrypt error.";break;case _t.Alert.Description.export_restriction:r="Export restriction.";break;case _t.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case _t.Alert.Description.insufficient_security:r="Insufficient security.";break;case _t.Alert.Description.internal_error:r="Internal error.";break;case _t.Alert.Description.user_canceled:r="User canceled.";break;case _t.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(i.description===_t.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===_t.ConnectionEnd.client?"server":"client",alert:i}),e.process()},_t.handleHandshake=function(e,t){var r=t.fragment,n=r.getByte(),i=r.getInt24();if(i>r.length())return e.fragmented=t,t.fragment=F.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var a=r.bytes(i+4);r.read+=4,n in ir[e.entity][e.expect]?(e.entity!==_t.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:F.md.md5.create(),sha1:F.md.sha1.create()}),n!==_t.HandshakeType.hello_request&&n!==_t.HandshakeType.certificate_verify&&n!==_t.HandshakeType.finished&&(e.session.md5.update(a),e.session.sha1.update(a)),ir[e.entity][e.expect][n](e,t,i)):_t.handleUnexpected(e,t)},_t.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},_t.handleHeartbeat=function(e,t){var r=t.fragment,n=r.getByte(),i=r.getInt16(),a=r.getBytes(i);if(n===_t.HeartbeatMessageType.heartbeat_request){if(e.handshaking||i>a.length)return e.process();_t.queue(e,_t.createRecord(e,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_response,a)})),_t.flush(e)}else if(n===_t.HeartbeatMessageType.heartbeat_response){if(a!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,F.util.createBuffer(a))}e.process()};var xt=1,Pt=2,Rt=3,Nt=4,Ot=5,Lt=6,Dt=7,Ut=8,Mt=1,Vt=2,jt=3,Ft=4,zt=5,Kt=6,qt=_t.handleUnexpected,Ht=_t.handleChangeCipherSpec,Gt=_t.handleAlert,Qt=_t.handleHandshake,Wt=_t.handleApplicationData,Xt=_t.handleHeartbeat,Yt=[];Yt[_t.ConnectionEnd.client]=[[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[Ht,Gt,qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,Wt,Xt],[qt,Gt,Qt,qt,Xt]],Yt[_t.ConnectionEnd.server]=[[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[Ht,Gt,qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,Wt,Xt],[qt,Gt,Qt,qt,Xt]];var $t=_t.handleHelloRequest,Zt=_t.handleServerHello,Jt=_t.handleCertificate,er=_t.handleServerKeyExchange,tr=_t.handleCertificateRequest,rr=_t.handleServerHelloDone,nr=_t.handleFinished,ir=[];ir[_t.ConnectionEnd.client]=[[qt,qt,Zt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,Jt,er,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,er,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,nr],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt]];var ar=_t.handleClientHello,or=_t.handleClientKeyExchange,sr=_t.handleCertificateVerify;ir[_t.ConnectionEnd.server]=[[qt,ar,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,Jt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,or,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,sr,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,nr],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt]],_t.generateKeys=function(e,t){var r=St,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var i=2*t.mac_key_length+2*t.enc_key_length,a=e.version.major===_t.Versions.TLS_1_0.major&&e.version.minor===_t.Versions.TLS_1_0.minor;a&&(i+=2*t.fixed_iv_length);var o=r(t.master_secret,"key expansion",n,i),s={client_write_MAC_key:o.getBytes(t.mac_key_length),server_write_MAC_key:o.getBytes(t.mac_key_length),client_write_key:o.getBytes(t.enc_key_length),server_write_key:o.getBytes(t.enc_key_length)};return a&&(s.client_write_IV=o.getBytes(t.fixed_iv_length),s.server_write_IV=o.getBytes(t.fixed_iv_length)),s},_t.createConnectionState=function(e){var t=e.entity===_t.ConnectionEnd.client,r=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},n={read:r(),write:r()};if(n.read.update=function(e,t){return n.read.cipherFunction(t,n.read)?n.read.compressFunction(e,t,n.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_record_mac}}),!e.fail},n.write.update=function(e,t){return n.write.compressFunction(e,t,n.write)?n.write.cipherFunction(t,n.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}),!e.fail},e.session){var i=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(i),i.keys=_t.generateKeys(e,i),n.read.macKey=t?i.keys.server_write_MAC_key:i.keys.client_write_MAC_key,n.write.macKey=t?i.keys.client_write_MAC_key:i.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(n,e,i),i.compression_algorithm){case _t.CompressionMethod.none:break;case _t.CompressionMethod.deflate:n.read.compressFunction=Tt,n.write.compressFunction=Bt;break;default:throw new Error("Unsupported compression algorithm.")}}return n},_t.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),r=F.util.createBuffer();return r.putInt32(t),r.putBytes(F.random.getBytes(28)),r},_t.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},_t.createAlert=function(e,t){var r=F.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),_t.createRecord(e,{type:_t.ContentType.alert,data:r})},_t.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=F.util.createBuffer(),r=0;r<e.cipherSuites.length;++r){var n=e.cipherSuites[r];t.putByte(n.id[0]),t.putByte(n.id[1])}var i=t.length(),a=F.util.createBuffer();a.putByte(_t.CompressionMethod.none);var o=a.length(),s=F.util.createBuffer();if(e.virtualHost){var c=F.util.createBuffer();c.putByte(0),c.putByte(0);var u=F.util.createBuffer();u.putByte(0),It(u,2,F.util.createBuffer(e.virtualHost));var l=F.util.createBuffer();It(l,2,u),It(c,2,l),s.putBuffer(c)}var d=s.length();d>0&&(d+=2);var f=e.session.id,p=f.length+1+2+4+28+2+i+1+o+d,h=F.util.createBuffer();return h.putByte(_t.HandshakeType.client_hello),h.putInt24(p),h.putByte(e.version.major),h.putByte(e.version.minor),h.putBytes(e.session.sp.client_random),It(h,1,F.util.createBuffer(f)),It(h,2,t),It(h,1,a),d>0&&It(h,2,s),h},_t.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,n=F.util.createBuffer();return n.putByte(_t.HandshakeType.server_hello),n.putInt24(r),n.putByte(e.version.major),n.putByte(e.version.minor),n.putBytes(e.session.sp.server_random),It(n,1,F.util.createBuffer(t)),n.putByte(e.session.cipherSuite.id[0]),n.putByte(e.session.cipherSuite.id[1]),n.putByte(e.session.compressionMethod),n},_t.createCertificate=function(e){var t,r=e.entity===_t.ConnectionEnd.client,n=null;e.getCertificate&&(t=r?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,n=e.getCertificate(e,t));var i=F.util.createBuffer();if(null!==n)try{F.util.isArray(n)||(n=[n]);for(var a=null,o=0;o<n.length;++o){var s=F.pem.decode(n[o])[0];if("CERTIFICATE"!==s.type&&"X509 CERTIFICATE"!==s.type&&"TRUSTED CERTIFICATE"!==s.type){var c=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw c.headerType=s.type,c}if(s.procType&&"ENCRYPTED"===s.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var u=F.util.createBuffer(s.body);null===a&&(a=F.asn1.fromDer(u.bytes(),!1));var l=F.util.createBuffer();It(l,3,u),i.putBuffer(l)}n=F.pki.certificateFromAsn1(a),r?e.session.clientCertificate=n:e.session.serverCertificate=n}catch(t){return e.error(e,{message:"Could not send certificate list.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate}})}var d=3+i.length(),f=F.util.createBuffer();return f.putByte(_t.HandshakeType.certificate),f.putInt24(d),It(f,3,i),f},_t.createClientKeyExchange=function(e){var t=F.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(F.random.getBytes(46));var r=e.session.sp;r.pre_master_secret=t.getBytes();var n=(t=e.session.serverCertificate.publicKey.encrypt(r.pre_master_secret)).length+2,i=F.util.createBuffer();return i.putByte(_t.HandshakeType.client_key_exchange),i.putInt24(n),i.putInt16(t.length),i.putBytes(t),i},_t.createServerKeyExchange=function(e){return F.util.createBuffer()},_t.getClientSignature=function(e,t){var r=F.util.createBuffer();r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest()),r=r.getBytes(),e.getSignature=e.getSignature||function(e,t,r){var n=null;if(e.getPrivateKey)try{n=e.getPrivateKey(e,e.session.clientCertificate),n=F.pki.privateKeyFromPem(n)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}})}null===n?e.error(e,{message:"No private key set.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}):t=n.sign(t,null),r(e,t)},e.getSignature(e,r,t)},_t.createCertificateVerify=function(e,t){var r=t.length+2,n=F.util.createBuffer();return n.putByte(_t.HandshakeType.certificate_verify),n.putInt24(r),n.putInt16(t.length),n.putBytes(t),n},_t.createCertificateRequest=function(e){var t=F.util.createBuffer();t.putByte(1);var r=F.util.createBuffer();for(var n in e.caStore.certs){var i=e.caStore.certs[n],a=F.pki.distinguishedNameToAsn1(i.subject),o=F.asn1.toDer(a);r.putInt16(o.length()),r.putBuffer(o)}var s=1+t.length()+2+r.length(),c=F.util.createBuffer();return c.putByte(_t.HandshakeType.certificate_request),c.putInt24(s),It(c,1,t),It(c,2,r),c},_t.createServerHelloDone=function(e){var t=F.util.createBuffer();return t.putByte(_t.HandshakeType.server_hello_done),t.putInt24(0),t},_t.createChangeCipherSpec=function(){var e=F.util.createBuffer();return e.putByte(1),e},_t.createFinished=function(e){var t=F.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var r=e.entity===_t.ConnectionEnd.client,n=e.session.sp,i=r?"client finished":"server finished";t=St(n.master_secret,i,t.getBytes(),12);var a=F.util.createBuffer();return a.putByte(_t.HandshakeType.finished),a.putInt24(t.length()),a.putBuffer(t),a},_t.createHeartbeat=function(e,t,r){void 0===r&&(r=t.length);var n=F.util.createBuffer();n.putByte(e),n.putInt16(r),n.putBytes(t);var i=n.length(),a=Math.max(16,i-r-3);return n.putBytes(F.random.getBytes(a)),n},_t.queue=function(e,t){if(t&&(0!==t.fragment.length()||t.type!==_t.ContentType.handshake&&t.type!==_t.ContentType.alert&&t.type!==_t.ContentType.change_cipher_spec)){if(t.type===_t.ContentType.handshake){var r=t.fragment.bytes();e.session.md5.update(r),e.session.sha1.update(r),r=null}var n;if(t.fragment.length()<=_t.MaxFragment)n=[t];else{n=[];for(var i=t.fragment.bytes();i.length>_t.MaxFragment;)n.push(_t.createRecord(e,{type:t.type,data:F.util.createBuffer(i.slice(0,_t.MaxFragment))})),i=i.slice(_t.MaxFragment);i.length>0&&n.push(_t.createRecord(e,{type:t.type,data:F.util.createBuffer(i)}))}for(var a=0;a<n.length&&!e.fail;++a){var o=n[a];e.state.current.write.update(e,o)&&e.records.push(o)}}},_t.flush=function(e){for(var t=0;t<e.records.length;++t){var r=e.records[t];e.tlsData.putByte(r.type),e.tlsData.putByte(r.version.major),e.tlsData.putByte(r.version.minor),e.tlsData.putInt16(r.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var cr=function(e){switch(e){case!0:return!0;case F.pki.certificateError.bad_certificate:return _t.Alert.Description.bad_certificate;case F.pki.certificateError.unsupported_certificate:return _t.Alert.Description.unsupported_certificate;case F.pki.certificateError.certificate_revoked:return _t.Alert.Description.certificate_revoked;case F.pki.certificateError.certificate_expired:return _t.Alert.Description.certificate_expired;case F.pki.certificateError.certificate_unknown:return _t.Alert.Description.certificate_unknown;case F.pki.certificateError.unknown_ca:return _t.Alert.Description.unknown_ca;default:return _t.Alert.Description.bad_certificate}};for(var ur in _t.verifyCertificateChain=function(e,t){try{var r={};for(var n in e.verifyOptions)r[n]=e.verifyOptions[n];r.verify=function(t,r,n){cr(t);var i=e.verify(e,t,r,n);if(!0!==i){if("object"==typeof i&&!F.util.isArray(i)){var a=new Error("The application rejected the certificate.");throw a.send=!0,a.alert={level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate},i.message&&(a.message=i.message),i.alert&&(a.alert.description=i.alert),a}i!==t&&(i=function(e){switch(e){case!0:return!0;case _t.Alert.Description.bad_certificate:return F.pki.certificateError.bad_certificate;case _t.Alert.Description.unsupported_certificate:return F.pki.certificateError.unsupported_certificate;case _t.Alert.Description.certificate_revoked:return F.pki.certificateError.certificate_revoked;case _t.Alert.Description.certificate_expired:return F.pki.certificateError.certificate_expired;case _t.Alert.Description.certificate_unknown:return F.pki.certificateError.certificate_unknown;case _t.Alert.Description.unknown_ca:return F.pki.certificateError.unknown_ca;default:return F.pki.certificateError.bad_certificate}}(i))}return i},F.pki.verifyCertificateChain(e.caStore,t,r)}catch(t){var i=t;("object"!=typeof i||F.util.isArray(i))&&(i={send:!0,alert:{level:_t.Alert.Level.fatal,description:cr(t)}}),"send"in i||(i.send=!0),"alert"in i||(i.alert={level:_t.Alert.Level.fatal,description:cr(i.error)}),e.error(e,i)}return!e.fail},_t.createSessionCache=function(e,t){var r=null;if(e&&e.getSession&&e.setSession&&e.order)r=e;else{for(var n in(r={}).cache=e||{},r.capacity=Math.max(t||100,1),r.order=[],e)r.order.length<=t?r.order.push(n):delete e[n];r.getSession=function(e){var t=null,n=null;if(e?n=F.util.bytesToHex(e):r.order.length>0&&(n=r.order[0]),null!==n&&n in r.cache)for(var i in t=r.cache[n],delete r.cache[n],r.order)if(r.order[i]===n){r.order.splice(i,1);break}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var n=r.order.shift();delete r.cache[n]}n=F.util.bytesToHex(e),r.order.push(n),r.cache[n]=t}}return r},_t.createConnection=function(e){var t=null;t=e.caStore?F.util.isArray(e.caStore)?F.pki.createCaStore(e.caStore):e.caStore:F.pki.createCaStore();var r=e.cipherSuites||null;if(null===r)for(var n in r=[],_t.CipherSuites)r.push(_t.CipherSuites[n]);var i=e.server?_t.ConnectionEnd.server:_t.ConnectionEnd.client,a=e.sessionCache?_t.createSessionCache(e.sessionCache):null,o={version:{major:_t.Version.major,minor:_t.Version.minor},entity:i,sessionId:e.sessionId,caStore:t,sessionCache:a,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,r,n){return t},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:F.util.createBuffer(),tlsData:F.util.createBuffer(),data:F.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,r){r.origin=r.origin||(t.entity===_t.ConnectionEnd.client?"client":"server"),r.send&&(_t.queue(t,_t.createAlert(t,r.alert)),_t.flush(t));var n=!1!==r.fatal;n&&(t.fail=!0),e.error(t,r),n&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){o.version={major:_t.Version.major,minor:_t.Version.minor},o.record=null,o.session=null,o.peerCertificate=null,o.state={pending:null,current:null},o.expect=(_t.ConnectionEnd.client,0),o.fragmented=null,o.records=[],o.open=!1,o.handshakes=0,o.handshaking=!1,o.isConnected=!1,o.fail=!(e||void 0===e),o.input.clear(),o.tlsData.clear(),o.data.clear(),o.state.current=_t.createConnectionState(o)}};return o.reset(),o.handshake=function(e){if(o.entity!==_t.ConnectionEnd.client)o.error(o,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(o.handshaking)o.error(o,{message:"Handshake already in progress.",fatal:!1});else{o.fail&&!o.open&&0===o.handshakes&&(o.fail=!1),o.handshaking=!0;var t=null;(e=e||"").length>0&&(o.sessionCache&&(t=o.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&o.sessionCache&&null!==(t=o.sessionCache.getSession())&&(e=t.id),o.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:F.md.md5.create(),sha1:F.md.sha1.create()},t&&(o.version=t.version,o.session.sp=t.sp),o.session.sp.client_random=_t.createRandom().getBytes(),o.open=!0,_t.queue(o,_t.createRecord(o,{type:_t.ContentType.handshake,data:_t.createClientHello(o)})),_t.flush(o)}},o.process=function(e){var t=0;return e&&o.input.putBytes(e),o.fail||(null!==o.record&&o.record.ready&&o.record.fragment.isEmpty()&&(o.record=null),null===o.record&&(t=function(e){var t=0,r=e.input,n=r.length();if(n<5)t=5-n;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:F.util.createBuffer(),ready:!1};var i=e.record.version.major===e.version.major;i&&e.session&&e.session.version&&(i=e.record.version.minor===e.version.minor),i||e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}})}return t}(o)),o.fail||null===o.record||o.record.ready||(t=function(e){var t=0,r=e.input,n=r.length();return n<e.record.length?t=e.record.length-n:(e.record.fragment.putBytes(r.getBytes(e.record.length)),r.compact(),e.state.current.read.update(e,e.record)&&(null!==e.fragmented&&(e.fragmented.type===e.record.type?(e.fragmented.fragment.putBuffer(e.record.fragment),e.record=e.fragmented):e.error(e,{message:"Invalid fragmented record.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unexpected_message}})),e.record.ready=!0)),t}(o)),!o.fail&&null!==o.record&&o.record.ready&&function(e,t){var r=t.type-_t.ContentType.change_cipher_spec,n=Yt[e.entity][e.expect];r in n?n[r](e,t):_t.handleUnexpected(e,t)}(o,o.record)),t},o.prepare=function(e){return _t.queue(o,_t.createRecord(o,{type:_t.ContentType.application_data,data:F.util.createBuffer(e)})),_t.flush(o)},o.prepareHeartbeatRequest=function(e,t){return e instanceof F.util.ByteBuffer&&(e=e.bytes()),void 0===t&&(t=e.length),o.expectedHeartbeatPayload=e,_t.queue(o,_t.createRecord(o,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_request,e,t)})),_t.flush(o)},o.close=function(e){if(!o.fail&&o.sessionCache&&o.session){var t={id:o.session.id,version:o.session.version,sp:o.session.sp};t.sp.keys=null,o.sessionCache.setSession(t.id,t)}o.open&&(o.open=!1,o.input.clear(),(o.isConnected||o.handshaking)&&(o.isConnected=o.handshaking=!1,_t.queue(o,_t.createAlert(o,{level:_t.Alert.Level.warning,description:_t.Alert.Description.close_notify})),_t.flush(o)),o.closed(o)),o.reset(e)},o},F.tls=F.tls||{},_t)"function"!=typeof _t[ur]&&(F.tls[ur]=_t[ur]);F.tls.prf_tls1=St,F.tls.hmac_sha1=function(e,t,r){var n=F.hmac.create();n.start("SHA1",e);var i=F.util.createBuffer();return i.putInt32(t[0]),i.putInt32(t[1]),i.putByte(r.type),i.putByte(r.version.major),i.putByte(r.version.minor),i.putInt16(r.length),i.putBytes(r.fragment.bytes()),n.update(i.getBytes()),n.digest().getBytes()},F.tls.createSessionCache=_t.createSessionCache,F.tls.createConnection=_t.createConnection,E((function(e){var t=e.exports=F.tls;function r(e,r,i){var a=r.entity===F.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:F.cipher.createDecipher("AES-CBC",a?i.keys.server_write_key:i.keys.client_write_key),iv:a?i.keys.server_write_IV:i.keys.client_write_IV},e.write.cipherState={init:!1,cipher:F.cipher.createCipher("AES-CBC",a?i.keys.client_write_key:i.keys.server_write_key),iv:a?i.keys.client_write_IV:i.keys.server_write_IV},e.read.cipherFunction=o,e.write.cipherFunction=n,e.read.macLength=e.write.macLength=i.mac_length,e.read.macFunction=e.write.macFunction=t.hmac_sha1}function n(e,r){var n,a=!1,o=r.macFunction(r.macKey,r.sequenceNumber,e);e.fragment.putBytes(o),r.updateSequenceNumber(),n=e.version.minor===t.Versions.TLS_1_0.minor?r.cipherState.init?null:r.cipherState.iv:F.random.getBytesSync(16),r.cipherState.init=!0;var s=r.cipherState.cipher;return s.start({iv:n}),e.version.minor>=t.Versions.TLS_1_1.minor&&s.output.putBytes(n),s.update(e.fragment),s.finish(i)&&(e.fragment=s.output,e.length=e.fragment.length(),a=!0),a}function i(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function a(e,t,r){var n=!0;if(r){for(var i=t.length(),a=t.last(),o=i-1-a;o<i-1;++o)n=n&&t.at(o)==a;n&&t.truncate(a+1)}return n}function o(e,r){var n,i=!1;n=e.version.minor===t.Versions.TLS_1_0.minor?r.cipherState.init?null:r.cipherState.iv:e.fragment.getBytes(16),r.cipherState.init=!0;var o=r.cipherState.cipher;o.start({iv:n}),o.update(e.fragment),i=o.finish(a);var s=r.macLength,c=F.random.getBytesSync(s),u=o.output.length();u>=s?(e.fragment=o.output.getBytes(u-s),c=o.output.getBytes(s)):e.fragment=o.output.getBytes(),e.fragment=F.util.createBuffer(e.fragment),e.length=e.fragment.length();var l=r.macFunction(r.macKey,r.sequenceNumber,e);return r.updateSequenceNumber(),function(e,t,r){var n=F.hmac.create();return n.start("SHA1",e),n.update(t),t=n.digest().getBytes(),n.start(null,null),n.update(r),t===(r=n.digest().getBytes())}(r.macKey,c,l)&&i}t.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes,e.cipher_type=t.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=t.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:r},t.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes,e.cipher_type=t.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=t.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:r}})),F.debug=F.debug||{},F.debug.storage={},F.debug.get=function(e,t){var r;return void 0===e?r=F.debug.storage:e in F.debug.storage&&(r=void 0===t?F.debug.storage[e]:F.debug.storage[e][t]),r},F.debug.set=function(e,t,r){e in F.debug.storage||(F.debug.storage[e]={}),F.debug.storage[e][t]=r},F.debug.clear=function(e,t){void 0===e?F.debug.storage={}:e in F.debug.storage&&(void 0===t?delete F.debug.storage[e]:delete F.debug.storage[e][t])},E((function(e){var t=e.exports=F.sha512=F.sha512||{};F.md.sha512=F.md.algorithms.sha512=t;var r=F.sha384=F.sha512.sha384=F.sha512.sha384||{};r.create=function(){return t.create("SHA-384")},F.md.sha384=F.md.algorithms.sha384=r,F.sha512.sha256=F.sha512.sha256||{create:function(){return t.create("SHA-512/256")}},F.md["sha512/256"]=F.md.algorithms["sha512/256"]=F.sha512.sha256,F.sha512.sha224=F.sha512.sha224||{create:function(){return t.create("SHA-512/224")}},F.md["sha512/224"]=F.md.algorithms["sha512/224"]=F.sha512.sha224,t.create=function(e){if(i||(n=String.fromCharCode(128),n+=F.util.fillString(String.fromCharCode(0),128),a=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(o={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],o["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],o["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],o["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],i=!0),void 0===e&&(e="SHA-512"),!(e in o))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=o[e],r=null,c=F.util.createBuffer(),u=new Array(80),l=0;l<80;++l)u[l]=new Array(2);var d=64;switch(e){case"SHA-384":d=48;break;case"SHA-512/256":d=32;break;case"SHA-512/224":d=28}var f={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:d,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){f.messageLength=0,f.fullMessageLength=f.messageLength128=[];for(var e=f.messageLengthSize/4,n=0;n<e;++n)f.fullMessageLength.push(0);for(c=F.util.createBuffer(),r=new Array(t.length),n=0;n<t.length;++n)r[n]=t[n].slice(0);return f}};return f.start(),f.update=function(e,t){"utf8"===t&&(e=F.util.encodeUtf8(e));var n=e.length;f.messageLength+=n,n=[n/4294967296>>>0,n>>>0];for(var i=f.fullMessageLength.length-1;i>=0;--i)f.fullMessageLength[i]+=n[1],n[1]=n[0]+(f.fullMessageLength[i]/4294967296>>>0),f.fullMessageLength[i]=f.fullMessageLength[i]>>>0,n[0]=n[1]/4294967296>>>0;return c.putBytes(e),s(r,u,c),(c.read>2048||0===c.length())&&c.compact(),f},f.digest=function(){var t=F.util.createBuffer();t.putBytes(c.bytes());var i,a=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize&f.blockLength-1;t.putBytes(n.substr(0,f.blockLength-a));for(var o=8*f.fullMessageLength[0],l=0;l<f.fullMessageLength.length-1;++l)o+=(i=8*f.fullMessageLength[l+1])/4294967296>>>0,t.putInt32(o>>>0),o=i>>>0;t.putInt32(o);var d=new Array(r.length);for(l=0;l<r.length;++l)d[l]=r[l].slice(0);s(d,u,t);var p,h=F.util.createBuffer();for(p="SHA-512"===e?d.length:"SHA-384"===e?d.length-2:d.length-4,l=0;l<p;++l)h.putInt32(d[l][0]),l===p-1&&"SHA-512/224"===e||h.putInt32(d[l][1]);return h},f};var n=null,i=!1,a=null,o=null;function s(e,t,r){for(var n,i,o,s,c,u,l,d,f,p,h,g,m,y,v,b,C,E,w,k,S,B,T,A,I,_,x,P,R,N,O,L,D,U=r.length();U>=128;){for(x=0;x<16;++x)t[x][0]=r.getInt32()>>>0,t[x][1]=r.getInt32()>>>0;for(;x<80;++x)n=(((P=(N=t[x-2])[0])>>>19|(R=N[1])<<13)^(R>>>29|P<<3)^P>>>6)>>>0,i=((P<<13|R>>>19)^(R<<3|P>>>29)^(P<<26|R>>>6))>>>0,o=(((P=(L=t[x-15])[0])>>>1|(R=L[1])<<31)^(P>>>8|R<<24)^P>>>7)>>>0,s=((P<<31|R>>>1)^(P<<24|R>>>8)^(P<<25|R>>>7))>>>0,O=t[x-7],D=t[x-16],R=i+O[1]+s+D[1],t[x][0]=n+O[0]+o+D[0]+(R/4294967296>>>0)>>>0,t[x][1]=R>>>0;for(h=e[0][0],g=e[0][1],m=e[1][0],y=e[1][1],v=e[2][0],b=e[2][1],C=e[3][0],E=e[3][1],w=e[4][0],k=e[4][1],S=e[5][0],B=e[5][1],T=e[6][0],A=e[6][1],I=e[7][0],_=e[7][1],x=0;x<80;++x)l=((w>>>14|k<<18)^(w>>>18|k<<14)^(k>>>9|w<<23))>>>0,d=(T^w&(S^T))>>>0,c=((h>>>28|g<<4)^(g>>>2|h<<30)^(g>>>7|h<<25))>>>0,u=((h<<4|g>>>28)^(g<<30|h>>>2)^(g<<25|h>>>7))>>>0,f=(h&m|v&(h^m))>>>0,p=(g&y|b&(g^y))>>>0,R=_+(((w<<18|k>>>14)^(w<<14|k>>>18)^(k<<23|w>>>9))>>>0)+((A^k&(B^A))>>>0)+a[x][1]+t[x][1],n=I+l+d+a[x][0]+t[x][0]+(R/4294967296>>>0)>>>0,i=R>>>0,o=c+f+((R=u+p)/4294967296>>>0)>>>0,s=R>>>0,I=T,_=A,T=S,A=B,S=w,B=k,w=C+n+((R=E+i)/4294967296>>>0)>>>0,k=R>>>0,C=v,E=b,v=m,b=y,m=h,y=g,h=n+o+((R=i+s)/4294967296>>>0)>>>0,g=R>>>0;R=e[0][1]+g,e[0][0]=e[0][0]+h+(R/4294967296>>>0)>>>0,e[0][1]=R>>>0,R=e[1][1]+y,e[1][0]=e[1][0]+m+(R/4294967296>>>0)>>>0,e[1][1]=R>>>0,R=e[2][1]+b,e[2][0]=e[2][0]+v+(R/4294967296>>>0)>>>0,e[2][1]=R>>>0,R=e[3][1]+E,e[3][0]=e[3][0]+C+(R/4294967296>>>0)>>>0,e[3][1]=R>>>0,R=e[4][1]+k,e[4][0]=e[4][0]+w+(R/4294967296>>>0)>>>0,e[4][1]=R>>>0,R=e[5][1]+B,e[5][0]=e[5][0]+S+(R/4294967296>>>0)>>>0,e[5][1]=R>>>0,R=e[6][1]+A,e[6][0]=e[6][0]+T+(R/4294967296>>>0)>>>0,e[6][1]=R>>>0,R=e[7][1]+_,e[7][0]=e[7][0]+I+(R/4294967296>>>0)>>>0,e[7][1]=R>>>0,U-=128}}}));var lr=F.asn1,dr={privateKeyValidator:{name:"PrivateKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:lr.Class.UNIVERSAL,type:lr.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},publicKeyValidator:{name:"SubjectPublicKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:lr.Class.UNIVERSAL,type:lr.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]}},fr=dr.publicKeyValidator,pr=dr.privateKeyValidator;if(void 0===hr)var hr=F.jsbn.BigInteger;var gr=F.util.ByteBuffer,mr="undefined"==typeof Buffer?Uint8Array:Buffer;F.pki=F.pki||{},F.pki.ed25519=F.ed25519=F.ed25519||{};var yr=F.ed25519;function vr(e){var t=e.message;if(t instanceof Uint8Array||t instanceof mr)return t;var r=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),r="binary"}if("string"==typeof t&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof t){if("undefined"!=typeof Buffer)return Buffer.from(t,r);t=new gr(t,r)}else if(!(t instanceof gr))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var n=new mr(t.length()),i=0;i<n.length;++i)n[i]=t.at(i);return n}yr.constants={},yr.constants.PUBLIC_KEY_BYTE_LENGTH=32,yr.constants.PRIVATE_KEY_BYTE_LENGTH=64,yr.constants.SEED_BYTE_LENGTH=32,yr.constants.SIGN_BYTE_LENGTH=64,yr.constants.HASH_BYTE_LENGTH=64,yr.generateKeyPair=function(e){var t=(e=e||{}).seed;if(void 0===t)t=F.random.getBytesSync(yr.constants.SEED_BYTE_LENGTH);else if("string"==typeof t){if(t.length!==yr.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+yr.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=vr({message:t,encoding:"binary"});for(var r=new mr(yr.constants.PUBLIC_KEY_BYTE_LENGTH),n=new mr(yr.constants.PRIVATE_KEY_BYTE_LENGTH),i=0;i<32;++i)n[i]=t[i];return function(e,t){var r,n=[zr(),zr(),zr(),zr()],i=Ar(t,32);for(i[0]&=248,i[31]&=127,i[31]|=64,Mr(n,i),Rr(e,n),r=0;r<32;++r)t[r+32]=e[r]}(r,n),{publicKey:r,privateKey:n}},yr.privateKeyFromAsn1=function(e){var t={},r=[];if(!F.asn1.validate(e,pr,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var i=F.asn1.derToOid(t.privateKeyOid),a=F.oids.EdDSA25519;if(i!==a)throw new Error('Invalid OID "'+i+'"; OID must be "'+a+'".');var o=t.privateKey;return{privateKeyBytes:vr({message:F.asn1.fromDer(o).value,encoding:"binary"})}},yr.publicKeyFromAsn1=function(e){var t={},r=[];if(!F.asn1.validate(e,fr,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var i=F.asn1.derToOid(t.publicKeyOid),a=F.oids.EdDSA25519;if(i!==a)throw new Error('Invalid OID "'+i+'"; OID must be "'+a+'".');var o=t.ed25519PublicKey;if(o.length!==yr.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return vr({message:o,encoding:"binary"})},yr.publicKeyFromPrivateKey=function(e){var t=vr({message:(e=e||{}).privateKey,encoding:"binary"});if(t.length!==yr.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+yr.constants.PRIVATE_KEY_BYTE_LENGTH);for(var r=new mr(yr.constants.PUBLIC_KEY_BYTE_LENGTH),n=0;n<r.length;++n)r[n]=t[32+n];return r},yr.sign=function(e){var t=vr(e=e||{}),r=vr({message:e.privateKey,encoding:"binary"});if(r.length===yr.constants.SEED_BYTE_LENGTH)r=yr.generateKeyPair({seed:r}).privateKey;else if(r.length!==yr.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+yr.constants.SEED_BYTE_LENGTH+" or "+yr.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length);!function(e,t,r,n){var i,a,o=new Float64Array(64),s=[zr(),zr(),zr(),zr()],c=Ar(n,32);for(c[0]&=248,c[31]&=127,c[31]|=64,i=0;i<r;++i)e[64+i]=t[i];for(i=0;i<32;++i)e[32+i]=c[32+i];var u=Ar(e.subarray(32),r+32);for(_r(u),Mr(s,u),Rr(e,s),i=32;i<64;++i)e[i]=n[i];var l=Ar(e,r+64);for(_r(l),i=32;i<64;++i)o[i]=0;for(i=0;i<32;++i)o[i]=u[i];for(i=0;i<32;++i)for(a=0;a<32;a++)o[i+a]+=l[i]*c[a];Ir(e.subarray(32),o)}(n,t,t.length,r);for(var i=new mr(yr.constants.SIGN_BYTE_LENGTH),a=0;a<i.length;++a)i[a]=n[a];return i},yr.verify=function(e){var t=vr(e=e||{});if(void 0===e.signature)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var r=vr({message:e.signature,encoding:"binary"});if(r.length!==yr.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+yr.constants.SIGN_BYTE_LENGTH);var n=vr({message:e.publicKey,encoding:"binary"});if(n.length!==yr.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+yr.constants.PUBLIC_KEY_BYTE_LENGTH);var i,a=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length),o=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length);for(i=0;i<yr.constants.SIGN_BYTE_LENGTH;++i)a[i]=r[i];for(i=0;i<t.length;++i)a[i+yr.constants.SIGN_BYTE_LENGTH]=t[i];return function(e,t,r,n){var i,a=new mr(32),o=[zr(),zr(),zr(),zr()],s=[zr(),zr(),zr(),zr()];if(r<64)return-1;if(function(e,t){var r=zr(),n=zr(),i=zr(),a=zr(),o=zr(),s=zr(),c=zr();return Vr(e[2],Cr),function(e,t){var r;for(r=0;r<16;++r)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),Hr(i,e[1]),Gr(a,i,Er),qr(i,i,e[2]),Kr(a,e[2],a),Hr(o,a),Hr(s,o),Gr(c,s,o),Gr(r,c,i),Gr(r,r,a),function(e,t){var r,n=zr();for(r=0;r<16;++r)n[r]=t[r];for(r=250;r>=0;--r)Hr(n,n),1!==r&&Gr(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(r,r),Gr(r,r,i),Gr(r,r,a),Gr(r,r,a),Gr(e[0],r,a),Hr(n,e[0]),Gr(n,n,a),Or(n,i)&&Gr(e[0],e[0],Tr),Hr(n,e[0]),Gr(n,n,a),Or(n,i)?-1:(Dr(e[0])===t[31]>>7&&qr(e[0],br,e[0]),Gr(e[3],e[0],e[1]),0)}(s,n))return-1;for(i=0;i<r;++i)e[i]=t[i];for(i=0;i<32;++i)e[i+32]=n[i];var c=Ar(e,r);if(_r(c),Ur(o,s,c),Mr(s,t.subarray(32)),xr(o,s),Rr(a,o),r-=64,Lr(t,0,a,0)){for(i=0;i<r;++i)e[i]=0;return-1}for(i=0;i<r;++i)e[i]=t[i+64];return r}(o,a,a.length,n)>=0};var br=zr(),Cr=zr([1]),Er=zr([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),wr=zr([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),kr=zr([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Sr=zr([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Br=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),Tr=zr([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Ar(e,t){var r=F.md.sha512.create(),n=new gr(e);r.update(n.getBytes(t),"binary");var i=r.digest().getBytes();if("undefined"!=typeof Buffer)return Buffer.from(i,"binary");for(var a=new mr(yr.constants.HASH_BYTE_LENGTH),o=0;o<64;++o)a[o]=i.charCodeAt(o);return a}function Ir(e,t){var r,n,i,a;for(n=63;n>=32;--n){for(r=0,i=n-32,a=n-12;i<a;++i)t[i]+=r-16*t[n]*Br[i-(n-32)],r=t[i]+128>>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;++i)t[i]+=r-(t[31]>>4)*Br[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;++i)t[i]-=r*Br[i];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function _r(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;Ir(e,t)}function xr(e,t){var r=zr(),n=zr(),i=zr(),a=zr(),o=zr(),s=zr(),c=zr(),u=zr(),l=zr();qr(r,e[1],e[0]),qr(l,t[1],t[0]),Gr(r,r,l),Kr(n,e[0],e[1]),Kr(l,t[0],t[1]),Gr(n,n,l),Gr(i,e[3],t[3]),Gr(i,i,wr),Gr(a,e[2],t[2]),Kr(a,a,a),qr(o,n,r),qr(s,a,i),Kr(c,a,i),Kr(u,n,r),Gr(e[0],o,s),Gr(e[1],u,c),Gr(e[2],c,s),Gr(e[3],o,u)}function Pr(e,t,r){for(var n=0;n<4;++n)Fr(e[n],t[n],r)}function Rr(e,t){var r=zr(),n=zr(),i=zr();!function(e,t){var r,n=zr();for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)Hr(n,n),2!==r&&4!==r&&Gr(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(i,t[2]),Gr(r,t[0],i),Gr(n,t[1],i),Nr(e,n),e[31]^=Dr(r)<<7}function Nr(e,t){var r,n,i,a=zr(),o=zr();for(r=0;r<16;++r)o[r]=t[r];for(jr(o),jr(o),jr(o),n=0;n<2;++n){for(a[0]=o[0]-65517,r=1;r<15;++r)a[r]=o[r]-65535-(a[r-1]>>16&1),a[r-1]&=65535;a[15]=o[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,Fr(o,a,1-i)}for(r=0;r<16;r++)e[2*r]=255&o[r],e[2*r+1]=o[r]>>8}function Or(e,t){var r=new mr(32),n=new mr(32);return Nr(r,e),Nr(n,t),Lr(r,0,n,0)}function Lr(e,t,r,n){return function(e,t,r,n,i){var a,o=0;for(a=0;a<i;++a)o|=e[t+a]^r[n+a];return(1&o-1>>>8)-1}(e,t,r,n,32)}function Dr(e){var t=new mr(32);return Nr(t,e),1&t[0]}function Ur(e,t,r){var n,i;for(Vr(e[0],br),Vr(e[1],Cr),Vr(e[2],Cr),Vr(e[3],br),i=255;i>=0;--i)Pr(e,t,n=r[i/8|0]>>(7&i)&1),xr(t,e),xr(e,e),Pr(e,t,n)}function Mr(e,t){var r=[zr(),zr(),zr(),zr()];Vr(r[0],kr),Vr(r[1],Sr),Vr(r[2],Cr),Gr(r[3],kr,Sr),Ur(e,r,t)}function Vr(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function jr(e){var t,r,n=1;for(t=0;t<16;++t)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function Fr(e,t,r){for(var n,i=~(r-1),a=0;a<16;++a)n=i&(e[a]^t[a]),e[a]^=n,t[a]^=n}function zr(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;++t)r[t]=e[t];return r}function Kr(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]+r[n]}function qr(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]-r[n]}function Hr(e,t){Gr(e,t,t)}function Gr(e,t,r){var n,i,a=0,o=0,s=0,c=0,u=0,l=0,d=0,f=0,p=0,h=0,g=0,m=0,y=0,v=0,b=0,C=0,E=0,w=0,k=0,S=0,B=0,T=0,A=0,I=0,_=0,x=0,P=0,R=0,N=0,O=0,L=0,D=r[0],U=r[1],M=r[2],V=r[3],j=r[4],F=r[5],z=r[6],K=r[7],q=r[8],H=r[9],G=r[10],Q=r[11],W=r[12],X=r[13],Y=r[14],$=r[15];a+=(n=t[0])*D,o+=n*U,s+=n*M,c+=n*V,u+=n*j,l+=n*F,d+=n*z,f+=n*K,p+=n*q,h+=n*H,g+=n*G,m+=n*Q,y+=n*W,v+=n*X,b+=n*Y,C+=n*$,o+=(n=t[1])*D,s+=n*U,c+=n*M,u+=n*V,l+=n*j,d+=n*F,f+=n*z,p+=n*K,h+=n*q,g+=n*H,m+=n*G,y+=n*Q,v+=n*W,b+=n*X,C+=n*Y,E+=n*$,s+=(n=t[2])*D,c+=n*U,u+=n*M,l+=n*V,d+=n*j,f+=n*F,p+=n*z,h+=n*K,g+=n*q,m+=n*H,y+=n*G,v+=n*Q,b+=n*W,C+=n*X,E+=n*Y,w+=n*$,c+=(n=t[3])*D,u+=n*U,l+=n*M,d+=n*V,f+=n*j,p+=n*F,h+=n*z,g+=n*K,m+=n*q,y+=n*H,v+=n*G,b+=n*Q,C+=n*W,E+=n*X,w+=n*Y,k+=n*$,u+=(n=t[4])*D,l+=n*U,d+=n*M,f+=n*V,p+=n*j,h+=n*F,g+=n*z,m+=n*K,y+=n*q,v+=n*H,b+=n*G,C+=n*Q,E+=n*W,w+=n*X,k+=n*Y,S+=n*$,l+=(n=t[5])*D,d+=n*U,f+=n*M,p+=n*V,h+=n*j,g+=n*F,m+=n*z,y+=n*K,v+=n*q,b+=n*H,C+=n*G,E+=n*Q,w+=n*W,k+=n*X,S+=n*Y,B+=n*$,d+=(n=t[6])*D,f+=n*U,p+=n*M,h+=n*V,g+=n*j,m+=n*F,y+=n*z,v+=n*K,b+=n*q,C+=n*H,E+=n*G,w+=n*Q,k+=n*W,S+=n*X,B+=n*Y,T+=n*$,f+=(n=t[7])*D,p+=n*U,h+=n*M,g+=n*V,m+=n*j,y+=n*F,v+=n*z,b+=n*K,C+=n*q,E+=n*H,w+=n*G,k+=n*Q,S+=n*W,B+=n*X,T+=n*Y,A+=n*$,p+=(n=t[8])*D,h+=n*U,g+=n*M,m+=n*V,y+=n*j,v+=n*F,b+=n*z,C+=n*K,E+=n*q,w+=n*H,k+=n*G,S+=n*Q,B+=n*W,T+=n*X,A+=n*Y,I+=n*$,h+=(n=t[9])*D,g+=n*U,m+=n*M,y+=n*V,v+=n*j,b+=n*F,C+=n*z,E+=n*K,w+=n*q,k+=n*H,S+=n*G,B+=n*Q,T+=n*W,A+=n*X,I+=n*Y,_+=n*$,g+=(n=t[10])*D,m+=n*U,y+=n*M,v+=n*V,b+=n*j,C+=n*F,E+=n*z,w+=n*K,k+=n*q,S+=n*H,B+=n*G,T+=n*Q,A+=n*W,I+=n*X,_+=n*Y,x+=n*$,m+=(n=t[11])*D,y+=n*U,v+=n*M,b+=n*V,C+=n*j,E+=n*F,w+=n*z,k+=n*K,S+=n*q,B+=n*H,T+=n*G,A+=n*Q,I+=n*W,_+=n*X,x+=n*Y,P+=n*$,y+=(n=t[12])*D,v+=n*U,b+=n*M,C+=n*V,E+=n*j,w+=n*F,k+=n*z,S+=n*K,B+=n*q,T+=n*H,A+=n*G,I+=n*Q,_+=n*W,x+=n*X,P+=n*Y,R+=n*$,v+=(n=t[13])*D,b+=n*U,C+=n*M,E+=n*V,w+=n*j,k+=n*F,S+=n*z,B+=n*K,T+=n*q,A+=n*H,I+=n*G,_+=n*Q,x+=n*W,P+=n*X,R+=n*Y,N+=n*$,b+=(n=t[14])*D,C+=n*U,E+=n*M,w+=n*V,k+=n*j,S+=n*F,B+=n*z,T+=n*K,A+=n*q,I+=n*H,_+=n*G,x+=n*Q,P+=n*W,R+=n*X,N+=n*Y,O+=n*$,C+=(n=t[15])*D,o+=38*(w+=n*M),s+=38*(k+=n*V),c+=38*(S+=n*j),u+=38*(B+=n*F),l+=38*(T+=n*z),d+=38*(A+=n*K),f+=38*(I+=n*q),p+=38*(_+=n*H),h+=38*(x+=n*G),g+=38*(P+=n*Q),m+=38*(R+=n*W),y+=38*(N+=n*X),v+=38*(O+=n*Y),b+=38*(L+=n*$),a=(n=(a+=38*(E+=n*U))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),C=(n=C+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=(a+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),C=(n=C+i+65535)-65536*(i=Math.floor(n/65536)),a+=i-1+37*(i-1),e[0]=a,e[1]=o,e[2]=s,e[3]=c,e[4]=u,e[5]=l,e[6]=d,e[7]=f,e[8]=p,e[9]=h,e[10]=g,e[11]=m,e[12]=y,e[13]=v,e[14]=b,e[15]=C}F.kem=F.kem||{};var Qr=F.jsbn.BigInteger;function Wr(e,t,r,n){e.generate=function(e,i){for(var a=new F.util.ByteBuffer,o=Math.ceil(i/n)+r,s=new F.util.ByteBuffer,c=r;c<o;++c){s.putInt32(c),t.start(),t.update(e+s.getBytes());var u=t.digest();a.putBytes(u.getBytes(n))}return a.truncate(a.length()-i),a.getBytes()}}F.kem.rsa={},F.kem.rsa.create=function(e,t){var r=(t=t||{}).prng||F.random;return{encrypt:function(t,n){var i,a=Math.ceil(t.n.bitLength()/8);do{i=new Qr(F.util.bytesToHex(r.getBytesSync(a)),16).mod(t.n)}while(i.compareTo(Qr.ONE)<=0);var o=a-(i=F.util.hexToBytes(i.toString(16))).length;return o>0&&(i=F.util.fillString(String.fromCharCode(0),o)+i),{encapsulation:t.encrypt(i,"NONE"),key:e.generate(i,n)}},decrypt:function(t,r,n){var i=t.decrypt(r,"NONE");return e.generate(i,n)}}},F.kem.kdf1=function(e,t){Wr(this,e,0,t||e.digestLength)},F.kem.kdf2=function(e,t){Wr(this,e,1,t||e.digestLength)},F.log=F.log||{},F.log.levels=["none","error","warning","info","debug","verbose","max"];var Xr={},Yr=[],$r=null;F.log.LEVEL_LOCKED=2,F.log.NO_LEVEL_CHECK=4,F.log.INTERPOLATE=8;for(var Zr=0;Zr<F.log.levels.length;++Zr){var Jr=F.log.levels[Zr];Xr[Jr]={index:Zr,name:Jr.toUpperCase()}}F.log.logMessage=function(e){for(var t=Xr[e.level].index,r=0;r<Yr.length;++r){var n=Yr[r];n.flags&F.log.NO_LEVEL_CHECK?n.f(e):t<=Xr[n.level].index&&n.f(n,e)}},F.log.prepareStandard=function(e){"standard"in e||(e.standard=Xr[e.level].name+" ["+e.category+"] "+e.message)},F.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]||e.arguments),e.full=F.util.format.apply(this,t)}},F.log.prepareStandardFull=function(e){"standardFull"in e||(F.log.prepareStandard(e),e.standardFull=e.standard)};var en=["error","warning","info","debug","verbose"];for(Zr=0;Zr<en.length;++Zr)!function(e){F.log[e]=function(t,r){var n=Array.prototype.slice.call(arguments).slice(2),i={timestamp:new Date,level:e,category:t,message:r,arguments:n};F.log.logMessage(i)}}(en[Zr]);if(F.log.makeLogger=function(e){var t={flags:0,f:e};return F.log.setLevel(t,"none"),t},F.log.setLevel=function(e,t){var r=!1;if(e&&!(e.flags&F.log.LEVEL_LOCKED))for(var n=0;n<F.log.levels.length;++n)if(t==F.log.levels[n]){e.level=t,r=!0;break}return r},F.log.lock=function(e,t){void 0===t||t?e.flags|=F.log.LEVEL_LOCKED:e.flags&=~F.log.LEVEL_LOCKED},F.log.addLogger=function(e){Yr.push(e)},"undefined"!=typeof console&&"log"in console){var tn;if(console.error&&console.warn&&console.info&&console.debug){var rn={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},nn=function(e,t){F.log.prepareStandard(t);var r=rn[t.level],n=[t.standard];n=n.concat(t.arguments.slice()),r.apply(console,n)};tn=F.log.makeLogger(nn)}else nn=function(e,t){F.log.prepareStandardFull(t),console.log(t.standardFull)},tn=F.log.makeLogger(nn);F.log.setLevel(tn,"debug"),F.log.addLogger(tn),$r=tn}else console={log:function(){}};if(null!==$r){var an=F.util.getQueryVariables();"console.level"in an&&F.log.setLevel($r,an["console.level"].slice(-1)[0]),"console.lock"in an&&"true"==an["console.lock"].slice(-1)[0]&&F.log.lock($r)}F.log.consoleLogger=$r,E((function(e){var t=F.asn1,r=e.exports=F.pkcs7=F.pkcs7||{};function n(e){var n={},i=[];if(!t.validate(e,r.asn1.recipientInfoValidator,n,i)){var a=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw a.errors=i,a}return{version:n.version.charCodeAt(0),issuer:F.pki.RDNAttributesAsArray(n.issuer),serialNumber:F.util.createBuffer(n.serial).toHex(),encryptedContent:{algorithm:t.derToOid(n.encAlgorithm),parameter:n.encParameter.value,content:n.encKey}}}function i(e){for(var r,n=[],i=0;i<e.length;++i)n.push((r=e[i],t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[F.pki.distinguishedNameToAsn1({attributes:r.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,F.util.hexToBytes(r.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.encryptedContent.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.encryptedContent.content)])));return n}function a(e){var r=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[F.pki.distinguishedNameToAsn1({attributes:e.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,F.util.hexToBytes(e.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.digestAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&r.value.push(e.authenticatedAttributesAsn1),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var n=t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[]),i=0;i<e.unauthenticatedAttributes.length;++i){var a=e.unauthenticatedAttributes[i];n.values.push(o(a))}r.value.push(n)}return r}function o(e){var r;if(e.type===F.pki.oids.contentType)r=t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.value).getBytes());else if(e.type===F.pki.oids.messageDigest)r=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===F.pki.oids.signingTime){var n=new Date("1950-01-01T00:00:00Z"),i=new Date("2050-01-01T00:00:00Z"),a=e.value;if("string"==typeof a){var o=Date.parse(a);a=isNaN(o)?13===a.length?t.utcTimeToDate(a):t.generalizedTimeToDate(a):new Date(o)}r=a>=n&&a<i?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(a)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(a))}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[r])])}function s(e,r,n){var i={};if(!t.validate(r,n,i,[])){var a=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw a.errors=a,a}if(t.derToOid(i.contentType)!==F.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(i.encryptedContent){var o="";if(F.util.isArray(i.encryptedContent))for(var s=0;s<i.encryptedContent.length;++s){if(i.encryptedContent[s].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=i.encryptedContent[s].value}else o=i.encryptedContent;e.encryptedContent={algorithm:t.derToOid(i.encAlgorithm),parameter:F.util.createBuffer(i.encParameter.value),content:F.util.createBuffer(o)}}if(i.content){if(o="",F.util.isArray(i.content))for(s=0;s<i.content.length;++s){if(i.content[s].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=i.content[s].value}else o=i.content;e.content=F.util.createBuffer(o)}return e.version=i.version.charCodeAt(0),e.rawCapture=i,i}function c(e){if(void 0===e.encryptedContent.key)throw new Error("Symmetric key not available.");if(void 0===e.content){var t;switch(e.encryptedContent.algorithm){case F.pki.oids["aes128-CBC"]:case F.pki.oids["aes192-CBC"]:case F.pki.oids["aes256-CBC"]:t=F.aes.createDecryptionCipher(e.encryptedContent.key);break;case F.pki.oids.desCBC:case F.pki.oids["des-EDE3-CBC"]:t=F.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}r.messageFromPem=function(e){var n=F.pem.decode(e)[0];if("PKCS7"!==n.type){var i=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var a=t.fromDer(n.body);return r.messageFromAsn1(a)},r.messageToPem=function(e,r){var n={type:"PKCS7",body:t.toDer(e.toAsn1()).getBytes()};return F.pem.encode(n,{maxline:r})},r.messageFromAsn1=function(e){var n={},i=[];if(!t.validate(e,r.asn1.contentInfoValidator,n,i)){var a=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw a.errors=i,a}var o,s=t.derToOid(n.contentType);switch(s){case F.pki.oids.envelopedData:o=r.createEnvelopedData();break;case F.pki.oids.encryptedData:o=r.createEncryptedData();break;case F.pki.oids.signedData:o=r.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+s+" is not (yet) supported.")}return o.fromAsn1(n.content.value[0]),o},r.createSignedData=function(){var e=null;return e={type:F.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(t){if(s(e,t,r.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var n=e.rawCapture.certificates.value,i=0;i<n.length;++i)e.certificates.push(F.pki.certificateFromAsn1(n[i]))},toAsn1:function(){e.contentInfo||e.sign();for(var r=[],n=0;n<e.certificates.length;++n)r.push(F.pki.certificateToAsn1(e.certificates[n]));var i=[],a=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return r.length>0&&a.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,r)),i.length>0&&a.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,i)),a.value[0].value.push(t.create(t.Class.UNIVERSAL,t.Type.SET,!0,e.signerInfos)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),a])},addSigner:function(t){var r=t.issuer,n=t.serialNumber;if(t.certificate){var i=t.certificate;"string"==typeof i&&(i=F.pki.certificateFromPem(i)),r=i.issuer.attributes,n=i.serialNumber}var a=t.key;if(!a)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof a&&(a=F.pki.privateKeyFromPem(a));var o=t.digestAlgorithm||F.pki.oids.sha1;switch(o){case F.pki.oids.sha1:case F.pki.oids.sha256:case F.pki.oids.sha384:case F.pki.oids.sha512:case F.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+o)}var s=t.authenticatedAttributes||[];if(s.length>0){for(var c=!1,u=!1,l=0;l<s.length;++l){var d=s[l];if(c||d.type!==F.pki.oids.contentType){if(u||d.type!==F.pki.oids.messageDigest);else if(u=!0,c)break}else if(c=!0,u)break}if(!c||!u)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:a,version:1,issuer:r,serialNumber:n,digestAlgorithm:o,signatureAlgorithm:F.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:s,unauthenticatedAttributes:[]})},sign:function(r){var n;r=r||{},("object"!=typeof e.content||null===e.contentInfo)&&(e.contentInfo=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(F.pki.oids.data).getBytes())]),"content"in e&&(e.content instanceof F.util.ByteBuffer?n=e.content.bytes():"string"==typeof e.content&&(n=F.util.encodeUtf8(e.content)),r.detached?e.detachedContent=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n):e.contentInfo.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n)])))),0!==e.signers.length&&function(r){var n;if(!(n=e.detachedContent?e.detachedContent:(n=e.contentInfo.value[1]).value[0]))throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var i=t.derToOid(e.contentInfo.value[0].value),s=t.toDer(n);for(var c in s.getByte(),t.getBerValueLength(s),s=s.getBytes(),r)r[c].start().update(s);for(var u=new Date,l=0;l<e.signers.length;++l){var d=e.signers[l];if(0===d.authenticatedAttributes.length){if(i!==F.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{d.authenticatedAttributesAsn1=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[]),p=0;p<d.authenticatedAttributes.length;++p){var h=d.authenticatedAttributes[p];h.type===F.pki.oids.messageDigest?h.value=r[d.digestAlgorithm].digest():h.type===F.pki.oids.signingTime&&(h.value||(h.value=u)),f.value.push(o(h)),d.authenticatedAttributesAsn1.value.push(o(h))}s=t.toDer(f).getBytes(),d.md.start().update(s)}d.signature=d.key.sign(d.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=function(e){for(var t=[],r=0;r<e.length;++r)t.push(a(e[r]));return t}(e.signers)}(function(){for(var r={},n=0;n<e.signers.length;++n){var i=e.signers[n];(a=i.digestAlgorithm)in r||(r[a]=F.md[F.pki.oids[a]].create()),0===i.authenticatedAttributes.length?i.md=r[a]:i.md=F.md[F.pki.oids[a]].create()}for(var a in e.digestAlgorithmIdentifiers=[],r)e.digestAlgorithmIdentifiers.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(a).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]));return r}())},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(t){"string"==typeof t&&(t=F.pki.certificateFromPem(t)),e.certificates.push(t)},addCertificateRevokationList:function(e){throw new Error("PKCS#7 CRL support not yet implemented.")}}},r.createEncryptedData=function(){var e=null;return e={type:F.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:F.pki.oids["aes256-CBC"]},fromAsn1:function(t){s(e,t,r.asn1.encryptedDataValidator)},decrypt:function(t){void 0!==t&&(e.encryptedContent.key=t),c(e)}}},r.createEnvelopedData=function(){var e=null;return e={type:F.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:F.pki.oids["aes256-CBC"]},fromAsn1:function(t){var i=s(e,t,r.asn1.envelopedDataValidator);e.recipients=function(e){for(var t=[],r=0;r<e.length;++r)t.push(n(e[r]));return t}(i.recipientInfos.value)},toAsn1:function(){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,i(e.recipients)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,(r=e.encryptedContent,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(F.pki.oids.data).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.parameter.getBytes())]),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.content.getBytes())])]))])])]);var r},findRecipient:function(t){for(var r=t.issuer.attributes,n=0;n<e.recipients.length;++n){var i=e.recipients[n],a=i.issuer;if(i.serialNumber===t.serialNumber&&a.length===r.length){for(var o=!0,s=0;s<r.length;++s)if(a[s].type!==r[s].type||a[s].value!==r[s].value){o=!1;break}if(o)return i}}return null},decrypt:function(t,r){if(void 0===e.encryptedContent.key&&void 0!==t&&void 0!==r)switch(t.encryptedContent.algorithm){case F.pki.oids.rsaEncryption:case F.pki.oids.desCBC:var n=r.decrypt(t.encryptedContent.content);e.encryptedContent.key=F.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}c(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:F.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,r){if(void 0===e.encryptedContent.content){var n,i,a;switch(r=r||e.encryptedContent.algorithm,t=t||e.encryptedContent.key,r){case F.pki.oids["aes128-CBC"]:n=16,i=16,a=F.aes.createEncryptionCipher;break;case F.pki.oids["aes192-CBC"]:n=24,i=16,a=F.aes.createEncryptionCipher;break;case F.pki.oids["aes256-CBC"]:n=32,i=16,a=F.aes.createEncryptionCipher;break;case F.pki.oids["des-EDE3-CBC"]:n=24,i=8,a=F.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(void 0===t)t=F.util.createBuffer(F.random.getBytes(n));else if(t.length()!=n)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+n+".");e.encryptedContent.algorithm=r,e.encryptedContent.key=t,e.encryptedContent.parameter=F.util.createBuffer(F.random.getBytes(i));var o=a(t);if(o.start(e.encryptedContent.parameter.copy()),o.update(e.content),!o.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=o.output}for(var s=0;s<e.recipients.length;++s){var c=e.recipients[s];if(void 0===c.encryptedContent.content)switch(c.encryptedContent.algorithm){case F.pki.oids.rsaEncryption:c.encryptedContent.content=c.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+c.encryptedContent.algorithm)}}}}}})),E((function(e){var t=e.exports=F.ssh=F.ssh||{};function r(e,t){var r=t.toString(16);r[0]>="8"&&(r="00"+r);var n=F.util.hexToBytes(r);e.putInt32(n.length),e.putBytes(n)}function n(e,t){e.putInt32(t.length),e.putString(t)}function i(){for(var e=F.md.sha1.create(),t=arguments.length,r=0;r<t;++r)e.update(arguments[r]);return e.digest()}t.privateKeyToPutty=function(e,t,a){var o=""===(t=t||"")?"none":"aes256-cbc",s="PuTTY-User-Key-File-2: ssh-rsa\r\n";s+="Encryption: "+o+"\r\n",s+="Comment: "+(a=a||"")+"\r\n";var c=F.util.createBuffer();n(c,"ssh-rsa"),r(c,e.e),r(c,e.n);var u=F.util.encode64(c.bytes(),64),l=Math.floor(u.length/66)+1;s+="Public-Lines: "+l+"\r\n",s+=u;var d,f=F.util.createBuffer();if(r(f,e.d),r(f,e.p),r(f,e.q),r(f,e.qInv),t){var p=f.length()+16-1;p-=p%16;var h=i(f.bytes());h.truncate(h.length()-p+f.length()),f.putBuffer(h);var g=F.util.createBuffer();g.putBuffer(i("\0\0\0\0",t)),g.putBuffer(i("\0\0\0",t));var m=F.aes.createEncryptionCipher(g.truncate(8),"CBC");m.start(F.util.createBuffer().fillWithByte(0,16)),m.update(f.copy()),m.finish();var y=m.output;y.truncate(16),d=F.util.encode64(y.bytes(),64)}else d=F.util.encode64(f.bytes(),64);s+="\r\nPrivate-Lines: "+(l=Math.floor(d.length/66)+1)+"\r\n",s+=d;var v=i("putty-private-key-file-mac-key",t),b=F.util.createBuffer();n(b,"ssh-rsa"),n(b,o),n(b,a),b.putInt32(c.length()),b.putBuffer(c),b.putInt32(f.length()),b.putBuffer(f);var C=F.hmac.create();return C.start("sha1",v),C.update(b.bytes()),s+"\r\nPrivate-MAC: "+C.digest().toHex()+"\r\n"},t.publicKeyToOpenSSH=function(e,t){t=t||"";var i=F.util.createBuffer();return n(i,"ssh-rsa"),r(i,e.e),r(i,e.n),"ssh-rsa "+F.util.encode64(i.bytes())+" "+t},t.privateKeyToOpenSSH=function(e,t){return t?F.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):F.pki.privateKeyToPem(e)},t.getPublicKeyFingerprint=function(e,t){var i=(t=t||{}).md||F.md.md5.create(),a=F.util.createBuffer();n(a,"ssh-rsa"),r(a,e.e),r(a,e.n),i.start(),i.update(a.getBytes());var o=i.digest();if("hex"===t.encoding){var s=o.toHex();return t.delimiter?s.match(/.{2}/g).join(t.delimiter):s}if("binary"===t.encoding)return o.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".');return o}}));var on="forge.task",sn={},cn=0;F.debug.set(on,"tasks",sn);var un={};F.debug.set(on,"queues",un);var ln="ready",dn="running",fn="blocked",pn="sleeping",hn="done",gn="error",mn={ready:{}};mn.ready.stop=ln,mn.ready.start=dn,mn.ready.cancel=hn,mn.ready.fail=gn,mn.running={},mn.running.stop=ln,mn.running.start=dn,mn.running.block=fn,mn.running.unblock=dn,mn.running.sleep=pn,mn.running.wakeup=dn,mn.running.cancel=hn,mn.running.fail=gn,mn.blocked={},mn.blocked.stop=fn,mn.blocked.start=fn,mn.blocked.block=fn,mn.blocked.unblock=fn,mn.blocked.sleep=fn,mn.blocked.wakeup=fn,mn.blocked.cancel=hn,mn.blocked.fail=gn,mn.sleeping={},mn.sleeping.stop=pn,mn.sleeping.start=pn,mn.sleeping.block=pn,mn.sleeping.unblock=pn,mn.sleeping.sleep=pn,mn.sleeping.wakeup=pn,mn.sleeping.cancel=hn,mn.sleeping.fail=gn,mn.done={},mn.done.stop=hn,mn.done.start=hn,mn.done.block=hn,mn.done.unblock=hn,mn.done.sleep=hn,mn.done.wakeup=hn,mn.done.cancel=hn,mn.done.fail=gn,mn.error={},mn.error.stop=gn,mn.error.start=gn,mn.error.block=gn,mn.error.unblock=gn,mn.error.sleep=gn,mn.error.wakeup=gn,mn.error.cancel=gn,mn.error.fail=gn;var yn=function(e){this.id=-1,this.name=e.name||"?",this.parent=e.parent||null,this.run=e.run,this.subtasks=[],this.error=!1,this.state=ln,this.blocks=0,this.timeoutId=null,this.swapTime=null,this.userData=null,this.id=cn++,sn[this.id]=this};yn.prototype.debug=function(e){e=e||"",F.log.debug(on,e,"[%s][%s] task:",this.id,this.name,this,"subtasks:",this.subtasks.length,"queue:",un)},yn.prototype.next=function(e,t){"function"==typeof e&&(t=e,e=this.name);var r=new yn({run:t,name:e,parent:this});return r.state=dn,r.type=this.type,r.successCallback=this.successCallback||null,r.failureCallback=this.failureCallback||null,this.subtasks.push(r),this},yn.prototype.parallel=function(e,t){return F.util.isArray(e)&&(t=e,e=this.name),this.next(e,(function(r){var n=r;n.block(t.length);for(var i=function(e,r){F.task.start({type:e,run:function(e){t[r](e)},success:function(e){n.unblock()},failure:function(e){n.unblock()}})},a=0;a<t.length;a++)i(e+"__parallel-"+r.id+"-"+a,a)}))},yn.prototype.stop=function(){this.state=mn[this.state].stop},yn.prototype.start=function(){this.error=!1,this.state=mn[this.state].start,this.state===dn&&(this.start=new Date,this.run(this),vn(this,0))},yn.prototype.block=function(e){e=void 0===e?1:e,this.blocks+=e,this.blocks>0&&(this.state=mn[this.state].block)},yn.prototype.unblock=function(e){return e=void 0===e?1:e,this.blocks-=e,0===this.blocks&&this.state!==hn&&(this.state=dn,vn(this,0)),this.blocks},yn.prototype.sleep=function(e){e=void 0===e?0:e,this.state=mn[this.state].sleep;var t=this;this.timeoutId=setTimeout((function(){t.timeoutId=null,t.state=dn,vn(t,0)}),e)},yn.prototype.wait=function(e){e.wait(this)},yn.prototype.wakeup=function(){this.state===pn&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state=dn,vn(this,0))},yn.prototype.cancel=function(){this.state=mn[this.state].cancel,this.permitsNeeded=0,null!==this.timeoutId&&(cancelTimeout(this.timeoutId),this.timeoutId=null),this.subtasks=[]},yn.prototype.fail=function(e){if(this.error=!0,bn(this,!0),e)e.error=this.error,e.swapTime=this.swapTime,e.userData=this.userData,vn(e,0);else{if(null!==this.parent){for(var t=this.parent;null!==t.parent;)t.error=this.error,t.swapTime=this.swapTime,t.userData=this.userData,t=t.parent;bn(t,!0)}this.failureCallback&&this.failureCallback(this)}};var vn=function(e,t){var r=t>30||+new Date-e.swapTime>20,n=function(t){if(t++,e.state===dn)if(r&&(e.swapTime=+new Date),e.subtasks.length>0){var n=e.subtasks.shift();n.error=e.error,n.swapTime=e.swapTime,n.userData=e.userData,n.run(n),n.error||vn(n,t)}else bn(e),e.error||null!==e.parent&&(e.parent.error=e.error,e.parent.swapTime=e.swapTime,e.parent.userData=e.userData,vn(e.parent,t))};r?setTimeout(n,0):n(t)},bn=function(e,t){e.state=hn,delete sn[e.id],null===e.parent&&(e.type in un?0===un[e.type].length?F.log.error(on,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):un[e.type][0]!==e?F.log.error(on,"[%s][%s] task not first in queue [%s]",e.id,e.name,e.type):(un[e.type].shift(),0===un[e.type].length?delete un[e.type]:un[e.type][0].start()):F.log.error(on,"[%s][%s] task queue missing [%s]",e.id,e.name,e.type),t||(e.error&&e.failureCallback?e.failureCallback(e):!e.error&&e.successCallback&&e.successCallback(e)))};F.task=F.task||{},F.task.start=function(e){var t=new yn({run:e.run,name:e.name||"?"});t.type=e.type,t.successCallback=e.success||null,t.failureCallback=e.failure||null,t.type in un?un[e.type].push(t):(un[t.type]=[t],function(e){e.error=!1,e.state=mn[e.state].start,setTimeout((function(){e.state===dn&&(e.swapTime=+new Date,e.run(e),vn(e,0))}),0)}(t))},F.task.cancel=function(e){e in un&&(un[e]=[un[e][0]])},F.task.createCondition=function(){var e={tasks:{},wait:function(t){t.id in e.tasks||(t.block(),e.tasks[t.id]=t)},notify:function(){var t=e.tasks;for(var r in e.tasks={},t)t[r].unblock()}};return e};var Cn=F,En=function(){function e(e){this.secretKey=e}return e.prototype.encrypt=function(e,t){throw new Error("Method not implemented.")},e.prototype.decrypt=function(e,t){return function(e,t,r){void 0===r&&(r=Cn.util.createBuffer(Uint8Array.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer));var n,i,a=Cn.cipher.createDecipher("AES-CBC",t);return a.start({iv:r}),a.update(Cn.util.createBuffer(Cn.util.hexToBytes(e))),i=(n=a.output.data).charCodeAt(n.length-1),n.slice(0,-i)}(e,(r=this.secretKey,n=t.transactionID,""+r.slice(0,16)+n.slice(0,16)));var r,n},e}(),wn=function(){function e(e,t,n,i){void 0===n&&(n="production"),void 0===i&&(i={supportTransaction:!1,enableEncryption:!1}),this.transactionEnabled=i.supportTransaction||!1,this.encryptionEnabled=i.enableEncryption||!1;var a=D(e,t,n,{headers:i.httpHeaders});this.transactionManager=new j(a),this.encryptionService=new En(t),this.compareFaceService=new d(a),this.clientSettingsService=new f(a),this.convertPDFService=new v(a),this.ekycPDFService=new b(a),this.readIDCardService=new r(a),this.requestVerifyIDCardService=new h(a),this.requestVerifyPortraitSerivce=new g(a),this.imagesService=new u(a),this.fileService=new l(a),this.verifyFaceLivenessService=new p(a),this.searchFaceService=new y(a),this.detectIDTamperingService=new m(a),this.httpClient=a}return e.prototype.enableTransaction=function(){this.transactionEnabled=!0},e.prototype.disableTransaction=function(){this.transactionEnabled=!1},e.prototype.enableEncryption=function(){this.encryptionEnabled=!0},e.prototype.disableEncryption=function(){this.encryptionEnabled=!1},e.prototype.compareFaces=function(e,t){return this.compareFaceService.request(e,t)},e.prototype.clientSettings=function(){return this.clientSettingsService.request()},e.prototype.uploadImage=function(e){return this.imagesService.request(e)},e.prototype.uploadFile=function(e){return this.fileService.uploadFile(e)},e.prototype.convertPDF=function(e,t){return this.convertPDFService.request(e,t)},e.prototype.ekycPDF=function(e,t){return this.ekycPDFService.request(e,t)},e.prototype.readIDCard=function(e,t){return this.readIDCardService.request(e,t)},e.prototype.requestVerifyIDCard=function(e,t){return this.requestVerifyIDCardService.request(e,t)},e.prototype.requestVerifyPortrait=function(e,t){return this.requestVerifyPortraitSerivce.request(e,t)},e.prototype.verifyFaceLiveness=function(e,t){return this.verifyFaceLivenessService.request(e,t)},e.prototype.searchFaces=function(e,t){return this.searchFaceService.request(e,t)},e.prototype.deleteFaces=function(e,t){return this.searchFaceService.deleteFaces(e,t)},e.prototype.indexFaces=function(e,t){return this.searchFaceService.indexFaces(e,t)},e.prototype.downloadFaceImage=function(e){return this.searchFaceService.downloadFaceImage(e)},e.prototype.downloadImage=function(e){return this.imagesService.download(e)},e.prototype.updateMetadata=function(e,t){return this.imagesService.updateMetadata(e,t)},e.prototype.detectIDTampering=function(e,t){return this.detectIDTamperingService.request(e,t)},a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"compareFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"convertPDF",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"readIDCard",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"requestVerifyIDCard",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"requestVerifyPortrait",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"verifyFaceLiveness",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"searchFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"deleteFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"indexFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"detectIDTampering",null),e}();e.ReadIDCard=r,e.UploadImage=u,e.UploadFile=l,e.CompareFaces=d,e.ClientSettings=f,e.VerifyFaceLiveness=p,e.RequestVerifyIDCard=h,e.RequestVerifyPortrait=g,e.DetectIDTampering=m,e.SearchFaces=y,e.ConvertPDF=v,e.EkycPDF=b,e.HttpClient=_,e.MockClient=x,e.TVAuthorizer=O,e.createHelpers=function(e,t,r){void 0===r&&(r="production");var n=new O(e,t),i=function(e){switch(e){case"testing":return"https://tv-testing.trustingsocial.com/api";case"staging":return"https://tv-staging.trustingsocial.com/api";case"production":default:return"https://vn-vision.trustingsocial.com/api"}}(r);return new _({authorizer:n,domain:i})},e.createHttpClient=D,e.SimpleTrustVisionAPI=U,e.default=wn,Object.defineProperty(e,"__esModule",{value:!0})}(t,r.default)}))),kY=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,SY=/^\w*$/;var BY=function(e,t){if(nQ(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!qQ(e))||(SY.test(e)||!kY.test(e)||null!=t&&e in Object(t))},TY=IG(Object,"create");var AY=function(){this.__data__=TY?TY(null):{},this.size=0};var IY=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},_Y=Object.prototype.hasOwnProperty;var xY=function(e){var t=this.__data__;if(TY){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return _Y.call(t,e)?t[e]:void 0},PY=Object.prototype.hasOwnProperty;var RY=function(e){var t=this.__data__;return TY?void 0!==t[e]:PY.call(t,e)};var NY=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=TY&&void 0===t?"__lodash_hash_undefined__":t,this};function OY(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}OY.prototype.clear=AY,OY.prototype.delete=IY,OY.prototype.get=xY,OY.prototype.has=RY,OY.prototype.set=NY;var LY=OY;var DY=function(){this.__data__=[],this.size=0};var UY=function(e,t){for(var r=e.length;r--;)if(PG(e[r][0],t))return r;return-1},MY=Array.prototype.splice;var VY=function(e){var t=this.__data__,r=UY(t,e);return!(r<0)&&(r==t.length-1?t.pop():MY.call(t,r,1),--this.size,!0)};var jY=function(e){var t=this.__data__,r=UY(t,e);return r<0?void 0:t[r][1]};var FY=function(e){return UY(this.__data__,e)>-1};var zY=function(e,t){var r=this.__data__,n=UY(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function KY(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}KY.prototype.clear=DY,KY.prototype.delete=VY,KY.prototype.get=jY,KY.prototype.has=FY,KY.prototype.set=zY;var qY=KY,HY=IG(rG,"Map");var GY=function(){this.size=0,this.__data__={hash:new LY,map:new(HY||qY),string:new LY}};var QY=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var WY=function(e,t){var r=e.__data__;return QY(t)?r["string"==typeof t?"string":"hash"]:r.map};var XY=function(e){var t=WY(this,e).delete(e);return this.size-=t?1:0,t};var YY=function(e){return WY(this,e).get(e)};var $Y=function(e){return WY(this,e).has(e)};var ZY=function(e,t){var r=WY(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function JY(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}JY.prototype.clear=GY,JY.prototype.delete=XY,JY.prototype.get=YY,JY.prototype.has=$Y,JY.prototype.set=ZY;var e$=JY;function t$(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var o=e.apply(this,n);return r.cache=a.set(i,o)||a,o};return r.cache=new(t$.Cache||e$),r}t$.Cache=e$;var r$=t$;var n$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i$=/\\(\\)?/g,a$=function(e){var t=r$(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(n$,(function(e,r,n,i){t.push(n?i.replace(i$,"$1"):r||e)})),t}));var o$=function(e,t){return nQ(e)?e:BY(e,t)?[e]:a$(WQ(e))};var s$=function(e){if("string"==typeof e||qQ(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var c$=function(e,t){for(var r=0,n=(t=o$(t,e)).length;null!=e&&r<n;)e=e[s$(t[r++])];return r&&r==n?e:void 0};var u$,l$,d$,f$,p$,h$,g$,m$,y$,v$,b$,C$,E$=function(e,t,r){var n=null==e?void 0:c$(e,t);return void 0===n?r:n};function w$(e){var t=e.className;return oy.createElement("svg",{className:t,width:"320",height:"320",viewBox:"0 0 320 320",fill:"none",xmlns:"http://www.w3.org/2000/svg"},oy.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M320 0H0V320H320V0ZM160 296C235.111 296 296 235.111 296 160C296 84.8893 235.111 24 160 24C84.8893 24 24 84.8893 24 160C24 235.111 84.8893 296 160 296Z",fill:"currentColor"}))}function k$(e){var t=e.isActive;return oy.createElement("svg",{width:"45",height:"44",viewBox:"0 0 45 44",fill:"none",xmlns:"http://www.w3.org/2000/svg"},oy.createElement("g",{opacity:t?1:.3},oy.createElement("rect",{x:"0.5",width:"44",height:"44",rx:"8",fill:"url(#paint0_linear_1680_23125)"}),oy.createElement("g",{clipPath:"url(#clip0_1680_23125)"},oy.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.5 12C16.9772 12 12.5 16.4772 12.5 22C12.5 27.5228 16.9772 32 22.5 32C28.0228 32 32.5 27.5228 32.5 22C32.5 16.4772 28.0228 12 22.5 12ZM10.5 22C10.5 15.3726 15.8726 10 22.5 10C29.1274 10 34.5 15.3726 34.5 22C34.5 28.6274 29.1274 34 22.5 34C15.8726 34 10.5 28.6274 10.5 22Z",fill:"white"}),oy.createElement("path",{d:"M18.5 19.5C18.5 20.3284 17.8284 21 17 21C16.1716 21 15.5 20.3284 15.5 19.5C15.5 18.6716 16.1716 18 17 18C17.8284 18 18.5 18.6716 18.5 19.5Z",fill:"white"}),oy.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.5 27C12.5 26.4477 12.9477 26 13.5 26H19C19.5523 26 20 26.4477 20 27C20 27.5523 19.5523 28 19 28H13.5C12.9477 28 12.5 27.5523 12.5 27Z",fill:"white"}))),oy.createElement("defs",null,oy.createElement("linearGradient",{id:"paint0_linear_1680_23125",x1:"22.5",y1:"0",x2:"22.5",y2:"44",gradientUnits:"userSpaceOnUse"},oy.createElement("stop",{stopColor:"#1797FF"}),oy.createElement("stop",{offset:"1",stopColor:"#7DD8FF"})),oy.createElement("clipPath",{id:"clip0_1680_23125"},oy.createElement("rect",{width:"24",height:"24",fill:"white",transform:"translate(10.5 10)"}))))}function S$(e){var t=e.isActive;return oy.createElement("svg",{width:"45",height:"44",viewBox:"0 0 45 44",fill:"none",xmlns:"http://www.w3.org/2000/svg"},oy.createElement("g",{opacity:t?1:.3},oy.createElement("rect",{width:"44",height:"44",rx:"8",transform:"matrix(-1 0 0 1 44.5 0)",fill:"url(#paint0_linear_1680_23314)"}),oy.createElement("g",{clipPath:"url(#clip0_1680_23314)"},oy.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.5 12C28.0228 12 32.5 16.4772 32.5 22C32.5 27.5228 28.0228 32 22.5 32C16.9772 32 12.5 27.5228 12.5 22C12.5 16.4772 16.9772 12 22.5 12ZM34.5 22C34.5 15.3726 29.1274 10 22.5 10C15.8726 10 10.5 15.3726 10.5 22C10.5 28.6274 15.8726 34 22.5 34C29.1274 34 34.5 28.6274 34.5 22Z",fill:"white"}),oy.createElement("path",{d:"M26.5 19.5C26.5 20.3284 27.1716 21 28 21C28.8284 21 29.5 20.3284 29.5 19.5C29.5 18.6716 28.8284 18 28 18C27.1716 18 26.5 18.6716 26.5 19.5Z",fill:"white"}),oy.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M32.5 27C32.5 26.4477 32.0523 26 31.5 26H26C25.4477 26 25 26.4477 25 27C25 27.5523 25.4477 28 26 28H31.5C32.0523 28 32.5 27.5523 32.5 27Z",fill:"white"}))),oy.createElement("defs",null,oy.createElement("linearGradient",{id:"paint0_linear_1680_23314",x1:"22",y1:"0",x2:"22",y2:"44",gradientUnits:"userSpaceOnUse"},oy.createElement("stop",{stopColor:"#1797FF"}),oy.createElement("stop",{offset:"1",stopColor:"#7DD8FF"})),oy.createElement("clipPath",{id:"clip0_1680_23314"},oy.createElement("rect",{width:"24",height:"24",fill:"white",transform:"matrix(-1 0 0 1 34.5 10)"}))))}function B$(e){var t=e.isActive;return oy.createElement("svg",{width:"45",height:"44",viewBox:"0 0 45 44",fill:"none",xmlns:"http://www.w3.org/2000/svg"},oy.createElement("g",{opacity:t?1:.3},oy.createElement("rect",{x:"0.5",width:"44",height:"44",rx:"8",fill:"url(#paint0_linear_1680_23117)"}),oy.createElement("g",{clipPath:"url(#clip0_1680_23117)"},oy.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.5 12C28.0228 12 32.5 16.4772 32.5 22C32.5 27.5228 28.0228 32 22.5 32C16.9772 32 12.5 27.5228 12.5 22C12.5 16.4772 16.9772 12 22.5 12ZM34.5 22C34.5 15.3726 29.1274 10 22.5 10C15.8726 10 10.5 15.3726 10.5 22C10.5 28.6274 15.8726 34 22.5 34C29.1274 34 34.5 28.6274 34.5 22Z",fill:"white"}),oy.createElement("path",{d:"M25.5 16.5C25.5 17.3284 26.1716 18 27 18C27.8284 18 28.5 17.3284 28.5 16.5C28.5 15.6716 27.8284 15 27 15C26.1716 15 25.5 15.6716 25.5 16.5Z",fill:"white"}),oy.createElement("path",{d:"M16.5 16.5C16.5 17.3284 17.1716 18 18 18C18.8284 18 19.5 17.3284 19.5 16.5C19.5 15.6716 18.8284 15 18 15C17.1716 15 16.5 15.6716 16.5 16.5Z",fill:"white"}),oy.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M26.5 22C26.5 21.4477 26.0224 21 25.4333 21H19.5667C18.9776 21 18.5 21.4477 18.5 22C18.5 22.5523 18.9776 23 19.5667 23H25.4333C26.0224 23 26.5 22.5523 26.5 22Z",fill:"white"}))),oy.createElement("defs",null,oy.createElement("linearGradient",{id:"paint0_linear_1680_23117",x1:"22.5",y1:"0",x2:"22.5",y2:"44",gradientUnits:"userSpaceOnUse"},oy.createElement("stop",{stopColor:"#1797FF"}),oy.createElement("stop",{offset:"1",stopColor:"#7DD8FF"})),oy.createElement("clipPath",{id:"clip0_1680_23117"},oy.createElement("rect",{width:"24",height:"24",fill:"white",transform:"matrix(-1 0 0 1 34.5 10)"}))))}function T$(e){var t=e.isActive;return oy.createElement("svg",{width:"45",height:"44",viewBox:"0 0 45 44",fill:"none",xmlns:"http://www.w3.org/2000/svg"},oy.createElement("g",{opacity:t?1:.3},oy.createElement("rect",{x:"0.5",width:"44",height:"44",rx:"8",fill:"url(#paint0_linear_1680_23140)"}),oy.createElement("g",{clipPath:"url(#clip0_1680_23140)"},oy.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.5 12C28.0228 12 32.5 16.4772 32.5 22C32.5 27.5228 28.0228 32 22.5 32C16.9772 32 12.5 27.5228 12.5 22C12.5 16.4772 16.9772 12 22.5 12ZM34.5 22C34.5 15.3726 29.1274 10 22.5 10C15.8726 10 10.5 15.3726 10.5 22C10.5 28.6274 15.8726 34 22.5 34C29.1274 34 34.5 28.6274 34.5 22Z",fill:"white"}),oy.createElement("path",{d:"M25.5 18.5C25.5 19.3284 26.1716 20 27 20C27.8284 20 28.5 19.3284 28.5 18.5C28.5 17.6716 27.8284 17 27 17C26.1716 17 25.5 17.6716 25.5 18.5Z",fill:"white"}),oy.createElement("path",{d:"M16.5 18.5C16.5 19.3284 17.1716 20 18 20C18.8284 20 19.5 19.3284 19.5 18.5C19.5 17.6716 18.8284 17 18 17C17.1716 17 16.5 17.6716 16.5 18.5Z",fill:"white"}),oy.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M26.5 26C26.5 25.4477 26.0224 25 25.4333 25H19.5667C18.9776 25 18.5 25.4477 18.5 26C18.5 26.5523 18.9776 27 19.5667 27H25.4333C26.0224 27 26.5 26.5523 26.5 26Z",fill:"white"}))),oy.createElement("defs",null,oy.createElement("linearGradient",{id:"paint0_linear_1680_23140",x1:"22.5",y1:"0",x2:"22.5",y2:"44",gradientUnits:"userSpaceOnUse"},oy.createElement("stop",{stopColor:"#1797FF"}),oy.createElement("stop",{offset:"1",stopColor:"#7DD8FF"})),oy.createElement("clipPath",{id:"clip0_1680_23140"},oy.createElement("rect",{width:"24",height:"24",fill:"white",transform:"matrix(-1 0 0 1 34.5 10)"}))))}w$.propTypes={className:Py.string},w$.defaultProps={className:""},k$.propTypes={isActive:Py.bool},k$.defaultProps={isActive:!0},S$.propTypes={isActive:Py.bool},S$.defaultProps={isActive:!0},B$.propTypes={isActive:Py.bool},B$.defaultProps={isActive:!0},T$.propTypes={isActive:Py.bool},T$.defaultProps={isActive:!0};var A$=nF.Camera,I$=PH.Text,_$=PH.FaceDetectionError,x$=PH.FaceVerificationInstructions,P$=PH.FaceVerificationStepsWrapper,R$=PH.StepItem,N$=PH.BottomButtonsOverlay,O$=PH.Button,L$=PH.CountDownOverlay,D$=PH.CountdownTime,U$=eC(JV)(u$||(u$=dm(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"]))),M$=eC(w$)(l$||(l$=dm(["\n width: 100%;\n height: 100%;\n vertical-align: middle;\n margin: 0;\n color: ",";\n"])),(function(e){var t=e.color;return null!=t?t:"rgba(0, 0, 0, 0.6)"})),V$=eC(x$)(d$||(d$=dm(["\n font-size: 18px;\n color: #38383d;\n text-shadow: none;\n font-weight: 600;\n"]))),j$=eC(_$)(f$||(f$=dm(["\n color: #ff424e;\n background-color: unset;\n"]))),F$=eC(D$)(p$||(p$=dm(["\n background-color: unset;\n color: #ff424e;\n font-size: 18px;\n"]))),z$=eC(R$)(h$||(h$=dm(["\n /* border-color: #1aa7ff;\n color: #1aa7ff; */\n width: 44px;\n height: 44px;\n opacity: 1;\n img {\n border-radius: 8px;\n width: 44px;\n }\n"]))),K$=eC(O$)(g$||(g$=dm(["\n z-index: ",";\n position: absolute;\n top: 20px;\n left: 20px;\n width: 12px;\n"])),1100),q$=eC(I$)(m$||(m$=dm(["\n position: absolute;\n font-style: normal;\n font-weight: 500;\n font-size: 16px;\n text-align: center;\n padding: 0 1.75rem;\n color: #38383d;\n\n ","\n"])),(function(e){var t=e.top;return t&&Vb(["top:","px;"],t)})),H$=eC.span(y$||(y$=dm(["\n position: absolute;\n bottom: 5px;\n color: #38383d;\n font-size: 14px;\n z-index: ",";\n"])),1020),G$=nC(["from{opacity:1;}to{opacity:0;}"]),Q$=eC.div(v$||(v$=dm(["\n position: absolute;\n width: 100%;\n top: 0;\n bottom: 0;\n z-index: -1;\n background: rgba(255, 255, 255, 0.3);\n animation: "," 1s infinite;\n"])),G$),W$=JH.isMobile?{width:640}:null,X$={background:"#fff",opacity:1};function Y$(e){var t,r,n=e.apiCheck,i=e.mode,a=e.onLivenessDetectionDone,o=e.onClose,s=e.onError,c=e.captureFrameSettings,u=e.onFramesCaptured,l=e.frontCamera,d=e.customStepTimeConstraints,f=e.onProcessing,p=e.customErrors,h=e.customMessages,g=e.livenessSettings,m=e.customInstructions,y=e.apiCredentials,v=e.title,b=e.subInstructions,C=uk.useAsset("bg_camera_mask.png"),E=uk.useAsset("bg_camera_mask_red.png"),w=uk.useAsset("ic_close_black.png"),k=fm(oy.useState({}),2),S=k[0],B=k[1],T=S.yFaceVerificationStepsWrapper,A=fm(oy.useState(""),2),I=A[0],_=A[1],x=fm(oy.useState(!1),2),P=x[0],R=x[1],N=oy.useCallback((function(e){var t=e.lostY,r=e.height,n=t+25,i=n+30;return B({yFaceDetectionError:n,yFaceVerificationStepsWrapper:i+r-45*r/350/2-8}),{y:Math.floor(i)}}),[]),O=xH({apiCheck:n,mode:i,bgCameraMask:C,bgCameraMaskRed:E,surroundStyle:X$,onLivenessDetectionDone:a,onError:s,cropAreaDimension:N,captureFrameSettings:c,onFramesCaptured:u,livenessSettings:g,setRemainingTime:_,customStepTimeConstraints:d,onProcessing:f,customErrors:p,customMessages:h,customInstructions:m,apiCredentials:y}),L=O.countdownToTakePicture,D=O.cropArea,U=O.curStepIndex,M=O.faceDetectionError,V=O.handleTriggerPassiveMode,j=O.handleVideoPlayed,F=O.instructions,z=O.isActiveMode,K=O.refVideo,q=O.showCountdown,H=O.steps,G=O.videoPlayed,Q=O.isFirstValidFrameFound,W=O.warmupDone,X=O.activeCapturing,Y=oy.useRef(0);if(window.innerHeight-((null===(t=D.current)||void 0===t?void 0:t.y)+(null===(r=D.current)||void 0===r?void 0:r.height))-110<60){var $,Z=window.innerHeight-(null===($=D.current)||void 0===$?void 0:$.y)-170;Y.current=(D.current.height-Z)/2,D.current.width=Z,D.current.height=Z}oy.useEffect((function(){Promise.all(H.map((function(e){return t=e.directionIcon,new Promise((function(e){var r=new Image;r.onload=e,r.onerror=e,r.src=t}));var t}))).then((function(){return R(!0)}))}),[H]);var J=oy.useRef(!1);oy.useEffect((function(){Q||(J.current=!1)}),[Q]),M&&M.code.includes("terminated")&&(J.current=!0);var ee=oy.useCallback((function(e,t){switch(e){case"left":return oy.createElement(k$,{isActive:t});case"right":return oy.createElement(S$,{isActive:t});case"up":return oy.createElement(B$,{isActive:t});case"frontal":return oy.createElement(T$,{isActive:t});default:return null}}),[]);return oy.createElement(PD,{frontCamera:l,onVideoPlayed:j,flipHorizontal:l,ref:K,videoSettings:W$,onError:s,onClose:o,closeButton:oy.createElement(K$,null,oy.createElement("img",{src:w,alt:""}))},!W&&oy.createElement(Pj,null),G&&P?oy.createElement(oy.Fragment,null,oy.createElement(q$,{top:20},"".concat(v)),oy.createElement(j$,{top:T-Y.current,className:"face-detection-error",error:M}),I&&oy.createElement(F$,{top:D.current.y-15},I),D.current?oy.createElement(UD,{x:"".concat(D.current.x+Y.current,"px"),y:"".concat(D.current.y,"px"),width:"".concat(D.current.width,"px"),height:"".concat(D.current.height,"px"),surroundStyle:D.current.surroundStyle},oy.createElement(M$,{color:"#fff"}),oy.createElement(U$,{progress:U/H.length*100,hasError:!!M,showDashedRing:!1,showOutsideRing:!1,insideRingWidth:5,errorRingWidth:0,insideRingStrokeDash:"none",insideRingColor:"#1AA7FF"}),q?oy.createElement(L$,null,L):null,z&&X?oy.createElement(Q$,null):null):null,z?oy.createElement(oy.Fragment,null,Q&&!J.current&&oy.createElement(P$,{bottom:60},H.map((function(e,t){var r=e.name,n=e.image.objUrl;return oy.createElement(z$,{key:r,className:"step-item"},n?oy.createElement("img",{src:n,alt:""}):ee(e.name,U>=t))}))),F?oy.createElement(oy.Fragment,null,oy.createElement(V$,{bottom:30,className:"instructions"},"".concat(F)),oy.createElement(H$,null,b)):null):oy.createElement(oy.Fragment,null,M?null:oy.createElement(N$,null,oy.createElement(O$,{onClick:V},oy.createElement(A$,null))))):null)}Y$.propTypes={apiCheck:Py.bool,mode:Py.string,onLivenessDetectionDone:Py.func,onClose:Py.func,onError:Py.func,captureFrameSettings:Py.shape({}),onFramesCaptured:Py.func,frontCamera:Py.bool,customStepTimeConstraints:Py.shape({}),onProcessing:Py.func,customErrors:Py.shape({}),customMessages:Py.shape({}),livenessSettings:Py.shape({}),customInstructions:Py.shape({}),apiCredentials:Py.shape({accessKey:Py.string,secretKey:Py.string,apiUrl:Py.string}),title:Py.string,subInstructions:Py.string},Y$.defaultProps={apiCheck:!1,mode:null,onLivenessDetectionDone:null,onClose:null,onError:function(){},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:function(){},frontCamera:!0,customStepTimeConstraints:(b$={},nm(b$,oC.FaceDirection.UP,{delayTime:0}),nm(b$,oC.FaceDirection.LEFT,{delayTime:0}),nm(b$,oC.FaceDirection.RIGHT,{delayTime:0}),nm(b$,oC.FaceDirection.FRONTAL,{delayTime:2e3}),b$),onProcessing:function(){},customErrors:{no_face:{code:"no_face",msg:{en:"Face is not detected.",vi:"Không nhận diện được khuôn mặt."}},multiple_faces:{code:"multiple_faces",msg:{en:"There are more than one face in the frame",vi:"Nhiều khuôn mặt xuất hiện trong khung hình"}},face_too_small:{code:"face_too_small",msg:{en:"The face is too small",vi:"Khuôn mặt quá nhỏ"}},face_too_large:{code:"face_too_large",msg:{en:"The face is too big",vi:"Khuôn mặt quá lớn"}},face_out_of_box:{code:"face_out_of_box",msg:{en:"Face is out of box",vi:"Khuôn mặt nằm ngoài khung ảnh"}},liveness_terminated_time_out:{code:"liveness_terminated_time_out",msg:{en:"The face verification need to be completed in <%= x %> seconds.\nPlease try again.",vi:"Xác thực khuôn mặt cần thực hiện trong <%= x %> giây.\nVui lòng thử lại."}}},customMessages:{REMAIN_TIME:{en:"Remaining time: <%= x %> seconds",vi:"Thời gian còn lại: <%= x %>"}},customInstructions:(C$={},nm(C$,oC.FaceDirection.LEFT,{en:"Please turn to the left",vi:"Xoay trái"}),nm(C$,oC.FaceDirection.RIGHT,{en:"Please turn to the right",vi:"Xoay phải"}),nm(C$,oC.FaceDirection.UP,{en:"Please look up",vi:"Ngẩng lên"}),nm(C$,oC.FaceDirection.FRONTAL,{en:"Please look straight to camera",vi:"Nhìn thẳng"}),C$),livenessSettings:null,apiCredentials:{accessKey:"5767c20d-87aa-4cad-8dbb-f5429f76c34b",secretKey:"c1446919-e60a-4575-a05d-304318212a1b",apiUrl:"https://tv-testing.trustingsocial.com/api"},title:"Chụp khuôn mặt",subInstructions:"Xin giữ khuôn mặt nằm trong khung ảnh"};var $$,Z$=["tracking","clientSettings","livenessSettings"],J$=oC.Errors,eZ=eC.div($$||($$=dm(["\n text-align: center;\n font-size: 20px;\n font-weight: 600;\n"])));function tZ(e){var t=e.tracking,r=void 0===t?{enable:!0}:t,n=e.clientSettings,i=e.livenessSettings,a=lm(e,Z$),o=lC.useSDKSettings().lang,s=J$.wrong_orientation.msg[o],c=aF().curOrientation,u=E$(n,"data.settings.sdk_settings.active_liveness_settings",i),l=E$(n,"data.settings.sdk_settings.server_log_settings.enable",r.enable);return oy.createElement(oy.Fragment,null,c===iF.LANDSCAPE&&oy.createElement(fj,{open:!0},oy.createElement(eZ,null,s)),(c===iF.PORTRAIT||c===iF.DESKTOP)&&oy.createElement(ok.SDKTrackingProvider,{value:{tracking:om(om({},r),{},{enable:l})}},oy.createElement(Y$,im({},a,{livenessSettings:u}))))}var rZ=["tracking","clientSettings"];function nZ(e){var t=e.tracking,r=e.clientSettings,n=lm(e,rZ),i=oy.useMemo((function(){return E$(r,"data.settings.sdk_settings.server_log_settings.enable",null==t?void 0:t.enable)}),[r,t]);return oy.createElement(ok.SDKTrackingProvider,{value:{tracking:om(om({},t),{},{enable:i})}},oy.createElement(CY,im({},n,{clientSettings:r})))}nZ.propTypes={tracking:Py.shape({}),clientSettings:Py.shape({})},nZ.defaultProps={tracking:void 0,clientSettings:void 0};var iZ=oC.Errors,aZ=function(e){var t=e.onClose,r=e.onError,n=e.detectIdCard,i=e.steps,a=e.onStepDone,o=e.apiCredentials,s=e.tracking,c=fm(oy.useState(null),2),u=c[0],l=c[1],d=hB.useApiClient({apiCredentials:o,tracking:s}).apiClient,f=oy.useRef(""),p=oy.useRef("");oy.useEffect((function(){function e(){return(e=Jg(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d.clientSettings();case 2:t=e.sent,l(t);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[d]);var h=oy.useCallback(function(){var e=Jg(regeneratorRuntime.mark((function e(t){var n,o,s,c,u,l,h,g;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.stepNumber,o=t.recordedVideos,s=t.qrScannedResult,c=t.image,u=i[n],l=u.cardType,h=u.cardSide,g=null,e.prev=3,e.next=6,SH({image:c,cardSide:h,frontCardId:f.current,qrImageId:p.current,onError:r,apiClient:d,cardType:l,recordedVideos:o,qrScannedResult:s});case 6:g=e.sent,h===oC.IDCardSide.FRONT&&(f.current=g.cardInfo.image1.id),p.current=g.qrImageId,e.next=14;break;case 11:e.prev=11,e.t0=e.catch(3),r(om(om({},iZ.api_call_error),{},{details:e.t0}));case 14:g&&a(om(om({},t),{},{apiResult:g}));case 15:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t){return e.apply(this,arguments)}}(),[d,r,i,a]);return u&&oy.createElement(nZ,{tracking:s,onClose:t,onError:r,clientSettings:u,detectIdCard:n,onStepDone:h,steps:i})};aZ.propTypes={onClose:Py.func,onError:Py.func,detectIdCard:Py.func,onStepDone:Py.func,steps:Py.arrayOf(Py.shape({})),apiCredentials:Py.shape({accessKey:Py.string,secretKey:Py.string,apiUrl:Py.string}),tracking:Py.shape({})},aZ.defaultProps={onClose:function(){},onError:function(){},detectIdCard:function(){return Promise.resolve({card_label:""})},onStepDone:function(){},steps:bY,apiCredentials:{accessKey:"5767c20d-87aa-4cad-8dbb-f5429f76c34b",secretKey:"c1446919-e60a-4575-a05d-304318212a1b",apiUrl:"https://tv-testing.trustingsocial.com/api"},tracking:void 0};var oZ=["apiCheck","mode","accessKey","secretKey","apiUrl","onLivenessDetectionDone","onError"],sZ=Fw.getUAMetadata(),cZ=function(){function e(t){var r=this,n=t.container,i=t.lang,a=void 0===i?"en":i,o=t.assetRoot,s=void 0===o?"https://unpkg.com/@tsocial/tvweb-sdk@latest/assets":o,c=t.customUrls,u=void 0===c?{}:c,l=t.enableAntiDebug,d=void 0===l||l;em(this,e),nm(this,"checkCamera",Jj),nm(this,"initNativeCamera",(function(e){var t=document.createElement("div");document.body.appendChild(t);var r=oy.createRef();return NL.render(oy.createElement(tF,im({},e,{ref:r})),t),{openCamera:function(){r.current.click()}}})),nm(this,"runWarmUpReadIDCard",Jg(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.commonSettings.customUrls,e.abrupt("return",rK(t));case 2:case"end":return e.stop()}}),e)})))),nm(this,"destroyView",(function(){NL.unmountComponentAtNode(r.container)})),EY(n,"container is a required parameter"),this.container=n,this.commonSettings={lang:a,assetRoot:s,customUrls:u,enableAntiDebug:d,debug:!1}}return rm(e,[{key:"readIDCardWithApiCall",value:function(e){NL.render(oy.createElement(lC.SDKSettingsProvider,{value:om({},this.commonSettings)},oy.createElement(aZ,im({onClose:this.destroyView},e))),this.container)}},{key:"readIDCardUIOnly",value:function(e){NL.render(oy.createElement(lC.SDKSettingsProvider,{value:this.commonSettings},oy.createElement(nZ,im({onClose:this.destroyView},e))),this.container)}},{key:"livenessDetection",value:function(e){var t=e.apiCheck,r=e.mode,n=(e.accessKey,e.secretKey,e.apiUrl,e.onLivenessDetectionDone),i=e.onError,a=lm(e,oZ);NL.render(oy.createElement(lC.SDKSettingsProvider,{value:om({},this.commonSettings)},oy.createElement(tZ,im({},a,{apiCheck:t,mode:r,onLivenessDetectionDone:n,onClose:this.destroyView,onError:i}))),this.container)}},{key:"compareFaces",value:function(e){var t=e.accessKey,r=e.secretKey,n=e.apiUrl,i=e.image1,a=e.image2,o=e.onSuccess,s=e.onError;hB.createRetryAPIClient(new wY(t,r,n,{httpHeaders:sZ})).compareFaces({image1:{id:i},image2:{id:a}}).then((function(e){o(e)})).catch((function(e){s(e)}))}}]),e}();exports.APIUtils=hB,exports.Animations=oz,exports.AntiDebugUtils=LB,exports.AssetUtils=uk,exports.AsyncUtils=dk,exports.BASE_Z_INDEX=1e3,exports.BlurUtils=Lk,exports.Button=TK,exports.ButtonLink=AK,exports.Camera=PD,exports.CameraUtils=Uk,exports.CommonUtils=Vk,exports.Constants=oC,exports.CoordinateUtils=qk,exports.CropAreaOverlayWrapper=UD,exports.CryptoUtils=MB,exports.FaceUtils=Zk,exports.GlareUtils=iB,exports.HashUtils=$w,exports.HighlightResult=Rq,exports.HighlightResultType=Bq,exports.Icons=nF,exports.ImageUtils=eB,exports.LivenessDetection=function(e){var t=e.tracking,r=void 0===t?{enable:!0}:t,n=e.clientSettings,i=e.livenessSettings,a=FL(e,oF),o=lC.useSDKSettings().lang,s=sF.wrong_orientation.msg[o],c=aF().curOrientation,u=pV(n,"data.settings.sdk_settings.active_liveness_settings",i),l=pV(n,"data.settings.sdk_settings.server_log_settings.enable",r.enable);return oy.createElement(oy.Fragment,null,c===iF.LANDSCAPE&&oy.createElement(fj,{open:!0},oy.createElement(cF,null,s)),(c===iF.PORTRAIT||c===iF.DESKTOP)&&oy.createElement(ok.SDKTrackingProvider,{value:{tracking:jL(jL({},r),{},{enable:l})}},oy.createElement(Yj,ML({},a,{livenessSettings:u}))))},exports.LivenessDetectionComponents=PH,exports.LoadResourceUtils=wB,exports.LocalStorageUtils=Qw,exports.MobileDetect=lD,exports.ModelUtils=OB,exports.NativeCamera=tF,exports.OrientationMode=iF,exports.PlacementArea=DD,exports.Popup=fj,exports.PredictionUtils=rS,exports.ProgressCircle=JV,exports.RatioWrapper=HK,exports.ReadIDCardUIOnly=dH,exports.ReadIDCardWithApiCall=IH,exports.RectangleMask=AF,exports.RectangleMaskType=TF,exports.SDK=cZ,exports.ScannerType=oH,exports.SettingsContext=lC,exports.Spacing=bK,exports.ThemeUtils=DB,exports.TimeUtils=qw,exports.TrackingContext=ok,exports.UserAgentUtils=Fw,exports.WarmupPopup=Pj,exports.checkCamera=Jj,exports.defaultClientSettings=eH,exports.defaultReadIDCardSteps=bY,exports.getQrScannerWorkerPath=VB,exports.handleApiCheckReadIdCard=SH,exports.readIdCardFromImage=_H,exports.readQRCodeFromImage=yq,exports.useDetectOrientation=aF,exports.useLivenessDetection=xH,exports.useMainProcessQRCodeScanner=vq,exports.useMainProcessReadIdCard=uK,exports.useSettingsReadIdCard=tH,exports.useShowPopup=Az,exports.warmUpQRCodeScanner=nq,exports.warmUpReadIdCard=rK;