@tsocial/tvweb-sdk.tcb.bss 5.8.3 → 5.8.4

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,o=n.Hasher,a=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,o){var a="function",s="undefined",c="object",u="model",l="name",f="type",d="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]:o},trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},w={rgx:function(e,t){for(var r,n,i,s,u,l,f=0;f<t.length&&!u;){var d=t[f],p=t[f+1];for(r=n=0;r<d.length&&!u;)if(u=d[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]==a?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:3==s.length?typeof s[1]!==a||s[1].exec&&s[1].test?this[s[0]]=l?l.replace(s[1],s[2]):o:this[s[0]]=l?s[1].call(this,l,s[2]):o:4==s.length&&(this[s[0]]=l?s[3].call(this,l.replace(s[1],s[2])):o):this[s]=l||o;f+=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?o:r}else if(C.has(t[r],e))return"?"===r?o:r;return e}},E={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,w.str,E.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,d,[f,y]],[/applecoremedia\/[\w\.]+ \((ipad)/],[u,[d,"Apple"],[f,y]],[/(apple\s{0,1}tv)/i],[[u,"Apple TV"],[d,"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],[d,u,[f,y]],[/(kf[A-z]+)\sbuild\/.+silk\//i],[u,[d,"Amazon"],[f,y]],[/(sd|kf)[0349hijorstuw]+\sbuild\/.+silk\//i],[[u,w.str,E.device.amazon.model],[d,"Amazon"],[f,m]],[/\((ip[honed|\s\w*]+);.+(apple)/i],[u,d,[f,m]],[/\((ip[honed|\s\w*]+);/i],[u,[d,"Apple"],[f,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],[d,u,[f,m]],[/\(bb10;\s(\w+)/i],[u,[d,"BlackBerry"],[f,m]],[/android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone)/i],[u,[d,"Asus"],[f,y]],[/(sony)\s(tablet\s[ps])\sbuild\//i,/(sony)?(?:sgp.+)\sbuild\//i],[[d,"Sony"],[u,"Xperia Tablet"],[f,y]],[/android.+\s([c-g]\d{4}|so[-l]\w+)\sbuild\//i],[u,[d,"Sony"],[f,m]],[/\s(ouya)\s/i,/(nintendo)\s([wids3u]+)/i],[d,u,[f,g]],[/android.+;\s(shield)\sbuild/i],[u,[d,"Nvidia"],[f,g]],[/(playstation\s[34portablevi]+)/i],[u,[d,"Sony"],[f,g]],[/(sprint\s(\w+))/i],[[d,w.str,E.device.sprint.vendor],[u,w.str,E.device.sprint.model],[f,m]],[/(lenovo)\s?(S(?:5000|6000)+(?:[-][\w+]))/i],[d,u,[f,y]],[/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i,/(zte)-(\w*)/i,/(alcatel|geeksphone|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i],[d,[u,/_/g," "],[f,m]],[/(nexus\s9)/i],[u,[d,"HTC"],[f,y]],[/d\/huawei([\w\s-]+)[;\)]/i,/(nexus\s6p)/i],[u,[d,"Huawei"],[f,m]],[/(microsoft);\s(lumia[\s\w]+)/i],[d,u,[f,m]],[/[\s\(;](xbox(?:\sone)?)[\s\);]/i],[u,[d,"Microsoft"],[f,g]],[/(kin\.[onetw]{3})/i],[[u,/\./g," "],[d,"Microsoft"],[f,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,[d,"Motorola"],[f,m]],[/android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i],[u,[d,"Motorola"],[f,y]],[/hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i],[[d,C.trim],[u,C.trim],[f,v]],[/hbbtv.+maple;(\d+)/i],[[u,/^/,"SmartTV"],[d,"Samsung"],[f,v]],[/\(dtv[\);].+(aquos)/i],[u,[d,"Sharp"],[f,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],[[d,"Samsung"],u,[f,y]],[/smart-tv.+(samsung)/i],[d,[f,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],[[d,"Samsung"],u,[f,m]],[/sie-(\w*)/i],[u,[d,"Siemens"],[f,m]],[/(maemo|nokia).*(n900|lumia\s\d+)/i,/(nokia)[\s_-]?([\w-]*)/i],[[d,"Nokia"],u,[f,m]],[/android\s3\.[\s\w;-]{10}(a\d{3})/i],[u,[d,"Acer"],[f,y]],[/android.+([vl]k\-?\d{3})\s+build/i],[u,[d,"LG"],[f,y]],[/android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i],[[d,"LG"],u,[f,y]],[/(lg) netcast\.tv/i],[d,u,[f,v]],[/(nexus\s[45])/i,/lg[e;\s\/-]+(\w*)/i,/android.+lg(\-?[\d\w]+)\s+build/i],[u,[d,"LG"],[f,m]],[/android.+(ideatab[a-z0-9\-\s]+)/i],[u,[d,"Lenovo"],[f,y]],[/linux;.+((jolla));/i],[d,u,[f,m]],[/((pebble))app\/[\d\.]+\s/i],[d,u,[f,b]],[/android.+;\s(oppo)\s?([\w\s]+)\sbuild/i],[d,u,[f,m]],[/crkey/i],[[u,"Chromecast"],[d,"Google"]],[/android.+;\s(glass)\s\d/i],[u,[d,"Google"],[f,b]],[/android.+;\s(pixel c)\s/i],[u,[d,"Google"],[f,y]],[/android.+;\s(pixel xl|pixel)\s/i],[u,[d,"Google"],[f,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," "],[d,"Xiaomi"],[f,m]],[/android.+(mi[\s\-_]*(?:pad)(?:[\s_]*[\w\s]+))\s+build/i],[[u,/_/g," "],[d,"Xiaomi"],[f,y]],[/android.+;\s(m[1-5]\snote)\sbuild/i],[u,[d,"Meizu"],[f,y]],[/android.+a000(1)\s+build/i,/android.+oneplus\s(a\d{4})\s+build/i],[u,[d,"OnePlus"],[f,m]],[/android.+[;\/]\s*(RCT[\d\w]+)\s+build/i],[u,[d,"RCA"],[f,y]],[/android.+[;\/\s]+(Venue[\d\s]{2,7})\s+build/i],[u,[d,"Dell"],[f,y]],[/android.+[;\/]\s*(Q[T|M][\d\w]+)\s+build/i],[u,[d,"Verizon"],[f,y]],[/android.+[;\/]\s+(Barnes[&\s]+Noble\s+|BN[RT])(V?.*)\s+build/i],[[d,"Barnes & Noble"],u,[f,y]],[/android.+[;\/]\s+(TM\d{3}.*\b)\s+build/i],[u,[d,"NuVision"],[f,y]],[/android.+;\s(k88)\sbuild/i],[u,[d,"ZTE"],[f,y]],[/android.+[;\/]\s*(gen\d{3})\s+build.*49h/i],[u,[d,"Swiss"],[f,m]],[/android.+[;\/]\s*(zur\d{3})\s+build/i],[u,[d,"Swiss"],[f,y]],[/android.+[;\/]\s*((Zeki)?TB.*\b)\s+build/i],[u,[d,"Zeki"],[f,y]],[/(android).+[;\/]\s+([YR]\d{2})\s+build/i,/android.+[;\/]\s+(Dragon[\-\s]+Touch\s+|DT)(\w{5})\sbuild/i],[[d,"Dragon Touch"],u,[f,y]],[/android.+[;\/]\s*(NS-?\w{0,9})\sbuild/i],[u,[d,"Insignia"],[f,y]],[/android.+[;\/]\s*((NX|Next)-?\w{0,9})\s+build/i],[u,[d,"NextBook"],[f,y]],[/android.+[;\/]\s*(Xtreme\_)?(V(1[045]|2[015]|30|40|60|7[05]|90))\s+build/i],[[d,"Voice"],u,[f,m]],[/android.+[;\/]\s*(LVTEL\-)?(V1[12])\s+build/i],[[d,"LvTel"],u,[f,m]],[/android.+[;\/]\s*(V(100MD|700NA|7011|917G).*\b)\s+build/i],[u,[d,"Envizen"],[f,y]],[/android.+[;\/]\s*(Le[\s\-]+Pan)[\s\-]+(\w{1,9})\s+build/i],[d,u,[f,y]],[/android.+[;\/]\s*(Trio[\s\-]*.*)\s+build/i],[u,[d,"MachSpeed"],[f,y]],[/android.+[;\/]\s*(Trinity)[\-\s]*(T\d{3})\s+build/i],[d,u,[f,y]],[/android.+[;\/]\s*TU_(1491)\s+build/i],[u,[d,"Rotor"],[f,y]],[/android.+(KS(.+))\s+build/i],[u,[d,"Amazon"],[f,y]],[/android.+(Gigaset)[\s\-]+(Q\w{1,9})\s+build/i],[d,u,[f,y]],[/\s(tablet|tab)[;\/]/i,/\s(mobile)(?:[;\/]|\ssafari)/i],[[f,C.lowerize],d,u],[/(android[\w\.\s\-]{0,9});.+build/i],[u,[d,"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,w.str,E.os.windows.version]],[/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],[[l,"Windows"],[p,w.str,E.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=o),!(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:o,version:o};return w.rgx.call(e,r,n.browser),e.major=C.major(e.version),e},this.getCPU=function(){var e={architecture:o};return w.rgx.call(e,r,n.cpu),e},this.getDevice=function(){var e={vendor:o,model:o,type:o};return w.rgx.call(e,r,n.device),e},this.getEngine=function(){var e={name:o,version:o};return w.rgx.call(e,r,n.engine),e},this.getOS=function(){var e={name:o,version:o};return w.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:d,TYPE:f,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))===o||(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),o=i.DEVICE_TYPES,a=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 o.MOBILE:return{isMobile:!0};case o.TABLET:return{isTablet:!0};case o.SMART_TV:return{isSmartTV:!0};case o.CONSOLE:return{isConsole:!0};case o.WEARABLE:return{isWearable:!0};case o.BROWSER:return{isBrowser:!0};default:return a}},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}}])})),wG="object"==typeof n&&n&&n.Object===Object&&n,EG="object"==typeof self&&self&&self.Object===Object&&self,kG=wG||EG||Function("return this")(),SG=kG.Symbol,BG=Object.prototype,TG=BG.hasOwnProperty,AG=BG.toString,IG=SG?SG.toStringTag:void 0;var _G=function(e){var t=TG.call(e,IG),r=e[IG];try{e[IG]=void 0;var n=!0}catch(e){}var i=AG.call(e);return n&&(t?e[IG]=r:delete e[IG]),i},xG=Object.prototype.toString;var RG=function(e){return xG.call(e)},PG=SG?SG.toStringTag:void 0;var NG=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":PG&&PG in Object(e)?_G(e):RG(e)};var LG=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};var OG=function(e){if(!LG(e))return!1;var t=NG(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},DG=kG["__core-js_shared__"],UG=function(){var e=/[^.]+$/.exec(DG&&DG.keys&&DG.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();var MG=function(e){return!!UG&&UG in e},VG=Function.prototype.toString;var jG=function(e){if(null!=e){try{return VG.call(e)}catch(e){}try{return e+""}catch(e){}}return""},FG=/^\[object .+?Constructor\]$/,zG=Function.prototype,KG=Object.prototype,qG=zG.toString,HG=KG.hasOwnProperty,GG=RegExp("^"+qG.call(HG).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var QG=function(e){return!(!LG(e)||MG(e))&&(OG(e)?GG:FG).test(jG(e))};var WG=function(e,t){return null==e?void 0:e[t]};var XG=function(e,t){var r=WG(e,t);return QG(r)?r:void 0},YG=function(){try{var e=XG(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var $G=function(e,t,r){"__proto__"==t&&YG?YG(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r};var ZG=function(e,t){return e===t||e!=e&&t!=t},JG=Object.prototype.hasOwnProperty;var eQ=function(e,t,r){var n=e[t];JG.call(e,t)&&ZG(n,r)&&(void 0!==r||t in e)||$G(e,t,r)};var tQ=function(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?$G(r,s,c):eQ(r,s,c)}return r};var rQ=function(e){return e};var nQ=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)},iQ=Math.max;var oQ=function(e,t,r){return t=iQ(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=iQ(n.length-t,0),a=Array(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),nQ(e,this,s)}};var aQ=function(e){return function(){return e}},sQ=YG?function(e,t){return YG(e,"toString",{configurable:!0,enumerable:!1,value:aQ(t),writable:!0})}:rQ,cQ=Date.now;var uQ=function(e){var t=0,r=0;return function(){var n=cQ(),i=16-(n-r);if(r=n,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(sQ);var lQ=function(e,t){return uQ(oQ(e,t,rQ),e+"")};var fQ=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};var dQ=function(e){return null!=e&&fQ(e.length)&&!OG(e)},pQ=/^(?:0|[1-9]\d*)$/;var hQ=function(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&pQ.test(e))&&e>-1&&e%1==0&&e<t};var gQ=function(e,t,r){if(!LG(r))return!1;var n=typeof t;return!!("number"==n?dQ(r)&&hQ(t,r.length):"string"==n&&t in r)&&ZG(r[t],e)};var mQ=function(e){return lQ((function(t,r){var n=-1,i=r.length,o=i>1?r[i-1]:void 0,a=i>2?r[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,a&&gQ(r[0],r[1],a)&&(o=i<3?void 0:o,i=1),t=Object(t);++n<i;){var s=r[n];s&&e(t,s,n,o)}return t}))};var yQ=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n};var vQ=function(e){return null!=e&&"object"==typeof e};var bQ=function(e){return vQ(e)&&"[object Arguments]"==NG(e)},CQ=Object.prototype,wQ=CQ.hasOwnProperty,EQ=CQ.propertyIsEnumerable,kQ=bQ(function(){return arguments}())?bQ:function(e){return vQ(e)&&wQ.call(e,"callee")&&!EQ.call(e,"callee")},SQ=Array.isArray;var BQ=function(){return!1},TQ=o((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r?kG.Buffer:void 0,o=(i?i.isBuffer:void 0)||BQ;e.exports=o})),AQ={};AQ["[object Float32Array]"]=AQ["[object Float64Array]"]=AQ["[object Int8Array]"]=AQ["[object Int16Array]"]=AQ["[object Int32Array]"]=AQ["[object Uint8Array]"]=AQ["[object Uint8ClampedArray]"]=AQ["[object Uint16Array]"]=AQ["[object Uint32Array]"]=!0,AQ["[object Arguments]"]=AQ["[object Array]"]=AQ["[object ArrayBuffer]"]=AQ["[object Boolean]"]=AQ["[object DataView]"]=AQ["[object Date]"]=AQ["[object Error]"]=AQ["[object Function]"]=AQ["[object Map]"]=AQ["[object Number]"]=AQ["[object Object]"]=AQ["[object RegExp]"]=AQ["[object Set]"]=AQ["[object String]"]=AQ["[object WeakMap]"]=!1;var IQ=function(e){return vQ(e)&&fQ(e.length)&&!!AQ[NG(e)]};var _Q=function(e){return function(t){return e(t)}},xQ=o((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r&&wG.process,o=function(){try{var e=n&&n.require&&n.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=o})),RQ=xQ&&xQ.isTypedArray,PQ=RQ?_Q(RQ):IQ,NQ=Object.prototype.hasOwnProperty;var LQ=function(e,t){var r=SQ(e),n=!r&&kQ(e),i=!r&&!n&&TQ(e),o=!r&&!n&&!i&&PQ(e),a=r||n||i||o,s=a?yQ(e.length,String):[],c=s.length;for(var u in e)!t&&!NQ.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||hQ(u,c))||s.push(u);return s},OQ=Object.prototype;var DQ=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||OQ)};var UQ=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t},MQ=Object.prototype.hasOwnProperty;var VQ=function(e){if(!LG(e))return UQ(e);var t=DQ(e),r=[];for(var n in e)("constructor"!=n||!t&&MQ.call(e,n))&&r.push(n);return r};var jQ=function(e){return dQ(e)?LQ(e,!0):VQ(e)},FQ=mQ((function(e,t,r,n){tQ(t,jQ(t),e,n)}));var zQ=function(e,t){return function(r){return e(t(r))}},KQ=zQ(Object.getPrototypeOf,Object),qQ=Function.prototype,HQ=Object.prototype,GQ=qQ.toString,QQ=HQ.hasOwnProperty,WQ=GQ.call(Object);var XQ=function(e){if(!vQ(e)||"[object Object]"!=NG(e))return!1;var t=KQ(e);if(null===t)return!0;var r=QQ.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&GQ.call(r)==WQ};var YQ=function(e){if(!vQ(e))return!1;var t=NG(e);return"[object Error]"==t||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!XQ(e)},$Q=lQ((function(e,t){try{return nQ(e,void 0,t)}catch(e){return YQ(e)?e:new Error(e)}}));var ZQ=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 JQ=function(e,t){return ZQ(t,(function(t){return e[t]}))},eW=Object.prototype,tW=eW.hasOwnProperty;var rW=function(e,t,r,n){return void 0===e||ZG(e,eW[r])&&!tW.call(n,r)?t:e},nW={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};var iW=function(e){return"\\"+nW[e]},oW=zQ(Object.keys,Object),aW=Object.prototype.hasOwnProperty;var sW=function(e){if(!DQ(e))return oW(e);var t=[];for(var r in Object(e))aW.call(e,r)&&"constructor"!=r&&t.push(r);return t};var cW=function(e){return dQ(e)?LQ(e):sW(e)},uW=/<%=([\s\S]+?)%>/g;var lW=function(e){return function(t){return null==e?void 0:e[t]}}({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});var fW=function(e){return"symbol"==typeof e||vQ(e)&&"[object Symbol]"==NG(e)},dW=SG?SG.prototype:void 0,pW=dW?dW.toString:void 0;var hW=function e(t){if("string"==typeof t)return t;if(SQ(t))return ZQ(t,e)+"";if(fW(t))return pW?pW.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r};var gW=function(e){return null==e?"":hW(e)},mW=/[&<>"']/g,yW=RegExp(mW.source);var vW={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:uW,variable:"",imports:{_:{escape:function(e){return(e=gW(e))&&yW.test(e)?e.replace(mW,lW):e}}}},bW=/\b__p \+= '';/g,CW=/\b(__p \+=) '' \+/g,wW=/(__e\(.*?\)|\b__t\)) \+\n'';/g,EW=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,kW=/($^)/,SW=/['\n\r\u2028\u2029\\]/g,BW=Object.prototype.hasOwnProperty;var TW=function(e,t,r){var n=vW.imports._.templateSettings||vW;r&&gQ(e,t,r)&&(t=void 0),e=gW(e),t=FQ({},t,n,rW);var i,o,a=FQ({},t.imports,n.imports,rW),s=cW(a),c=JQ(a,s),u=0,l=t.interpolate||kW,f="__p += '",d=RegExp((t.escape||kW).source+"|"+l.source+"|"+(l===uW?EW:kW).source+"|"+(t.evaluate||kW).source+"|$","g"),p=BW.call(t,"sourceURL")?"//# sourceURL="+(t.sourceURL+"").replace(/\s/g," ")+"\n":"";e.replace(d,(function(t,r,n,a,s,c){return n||(n=a),f+=e.slice(u,c).replace(SW,iW),r&&(i=!0,f+="' +\n__e("+r+") +\n'"),s&&(o=!0,f+="';\n"+s+";\n__p += '"),n&&(f+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),f+="';\n";var h=BW.call(t,"variable")&&t.variable;h||(f="with (obj) {\n"+f+"\n}\n"),f=(o?f.replace(bW,""):f).replace(CW,"$1").replace(wW,"$1;"),f="function("+(h||"obj")+") {\n"+(h?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var g=$Q((function(){return Function(s,p+"return "+f).apply(void 0,c)}));if(g.source=f,YQ(g))throw g;return g},AW="SESSION_TIMEOUT";function IW(){return(IW=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 _W,xW,RW,PW,NW,LW,OW,DW,UW,MW,VW,jW,FW="undefined"!=typeof window?ay.useLayoutEffect:ay.useEffect,zW={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}}},KW=["top left","top center","top right","right top","right center","right bottom","bottom left","bottom center","bottom right","left top","left center","left bottom"],qW=function(e,t,r,n,i){var o=i.offsetX,a=i.offsetY,s=n?8:0,c=r.split(" "),u=e.top+e.height/2,l=e.left+e.width/2,f=t.height,d=t.width,p=u-f/2,h=l-d/2,g="",m="0%",y="0%";switch(c[0]){case"top":p-=f/2+e.height/2+s,g="rotate(180deg) translateX(50%)",m="100%",y="50%";break;case"bottom":p+=f/2+e.height/2+s,g="rotate(0deg) translateY(-100%) translateX(-50%)",y="50%";break;case"left":h-=d/2+e.width/2+s,g=" rotate(90deg) translateY(50%) translateX(-25%)",y="100%",m="50%";break;case"right":h+=d/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-f+e.height,m=f-e.height/2+"px";break;case"left":h=e.left,y=e.width/2+"px";break;case"right":h=e.left-d+e.width,y=d-e.width/2+"px"}return{top:p="top"===c[0]?p-a:p+a,left:h="left"===c[0]?h-o:h+o,transform:g,arrowLeft:y,arrowTop:m}},HW=function(e,t,r,n,i,o){var a=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}(o),f=Array.isArray(r)?r:[r];for((o||Array.isArray(r))&&(f=[].concat(f,KW));u<f.length;){var d={top:(c=qW(e,t,f[u],n,{offsetX:a,offsetY:s})).top,left:c.left,width:t.width,height:t.height};if(!(d.top<=l.top||d.left<=l.left||d.top+d.height>=l.top+l.height||d.left+d.width>=l.left+l.width))break;u++}return c},GW=0,QW=ay.forwardRef((function(e,t){var r=e.trigger,n=void 0===r?null:r,i=e.onOpen,o=void 0===i?function(){}:i,a=e.onClose,s=void 0===a?function(){}:a,c=e.defaultOpen,u=void 0!==c&&c,l=e.open,f=void 0===l?void 0:l,d=e.disabled,p=void 0!==d&&d,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,w=void 0===C||C,E=e.on,k=void 0===E?["click"]:E,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,R=void 0===x?"":x,P=e.position,N=void 0===P?"bottom center":P,L=e.modal,O=void 0!==L&&L,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,$=ay.useState(f||u),Z=$[0],J=$[1],ee=ay.useRef(null),te=ay.useRef(null),re=ay.useRef(null),ne=ay.useRef(null),ie=ay.useRef("popup-"+ ++GW),oe=!!O||!n,ae=ay.useRef(0);FW((function(){return Z?(ne.current=document.activeElement,ve(),ge(),pe()):he(),function(){clearTimeout(ae.current)}}),[Z]),ay.useEffect((function(){"boolean"==typeof f&&(f?se():ce())}),[f,p]);var se=function(e){Z||p||(J(!0),setTimeout((function(){return o(e)}),0))},ce=function(e){var t;Z&&!p&&(J(!1),oe&&(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(ae.current),ae.current=setTimeout((function(){return se(e)}),H)},fe=function(e){null==e||e.preventDefault(),ue()},de=function(e){clearTimeout(ae.current),ae.current=setTimeout((function(){return ce(e)}),Q)},pe=function(){oe&&U&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},he=function(){oe&&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()};ay.useImperativeHandle(t,(function(){return{open:function(){se()},close:function(){ce()},toggle:function(){ue()}}}));var me,ye,ve=function(){if(!oe&&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=HW(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=w)&&(ye=!0),ay.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),ay.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 o=i[0],a=i[i.length-1];t.shiftKey&&document.activeElement===o?(t.preventDefault(),a.focus()):document.activeElement===a&&(t.preventDefault(),o.focus())}};return document.addEventListener("keydown",r),function(){t&&document.removeEventListener("keydown",r)}}}),[e,t])}(te,Z&&oe),function(e,t){void 0===t&&(t=!0),ay.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),ay.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 ay.createElement("div",Object.assign({},(e=oe?zW.popupContent.modal:zW.popupContent.tooltip,t={className:"popup-content "+(""!==R?R.split(" ").map((function(e){return e+"-content"})).join(" "):""),style:IW({},e,B,{pointerEvents:"auto"}),ref:te,onClick:function(e){e.stopPropagation()}},!O&&k.indexOf("hover")>=0&&(t.onMouseEnter=le,t.onMouseLeave=de),t),{key:"C",role:oe?"dialog":"tooltip",id:ie.current}),V&&!oe&&ay.createElement("div",{ref:re,style:zW.popupArrow},ay.createElement("svg",{"data-testid":"arrow",className:"popup-arrow "+(""!==R?R.split(" ").map((function(e){return e+"-arrow"})).join(" "):""),viewBox:"0 0 32 16",style:IW({position:"absolute"},A)},ay.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),Y&&"function"==typeof Y?Y(ce,Z):Y);var e,t},we=!(k.indexOf("hover")>=0),Ee=oe?zW.overlay.modal:zW.overlay.tooltip,ke=[we&&ay.createElement("div",{key:"O","data-testid":"overlay","data-popup":oe?"modal":"tooltip",className:"popup-overlay "+(""!==R?R.split(" ").map((function(e){return e+"-overlay"})).join(" "):""),style:IW({},Ee,_,{pointerEvents:y&&g||oe?"auto":"none"}),onClick:y&&g?ce:void 0,tabIndex:-1},oe&&Ce()),!oe&&Ce()];return ay.createElement(ay.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=fe;break;case"hover":e.onMouseEnter=le,e.onMouseLeave=de;break;case"focus":e.onFocus=le,e.onBlur=de}if("function"==typeof n){var o=n(Z);return!!n&&ay.cloneElement(o,e)}return!!n&&ay.cloneElement(n,e)}(),Z&&yD.createPortal(ke,(null===(be=document.getElementById("popup-root"))&&((be=document.createElement("div")).setAttribute("id","popup-root"),document.body.appendChild(be)),be)))}));function WW(){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 XW,YW=aC.Errors,$W=eC.div(_W||(_W=fm(["\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;"})),ZW=eC.video(xW||(xW=fm(["\n width: 100%;\n ","\n"])),(function(e){return e.flipHorizontal&&"\n transform: scaleX(-1);\n "})),JW=eC.div(RW||(RW=fm(["\n cursor: pointer;\n text-align: center;\n width: 50px;\n\n img {\n width: 100%;\n }\n"]))),eX=eC(JW)(PW||(PW=fm(["\n z-index: ",";\n position: absolute;\n top: 20px;\n right: 20px;\n width: 20px;\n"])),1100),tX=eC.div(NW||(NW=fm(["\n z-index: ",";\n position: absolute;\n top: 40px;\n color: red;\n"])),1020),rX=eC.div(LW||(LW=fm(["\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: ",";\n"])),1030),nX=eC.section(OW||(OW=fm(["\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"]))),iX=eC.header(DW||(DW=fm(["\n text-align: center;\n padding: 0.625rem 0;\n border-bottom: 1px solid #dddddd;\n"]))),oX=eC.h2(UW||(UW=fm(["\n margin: 0.25rem auto;\n padding: 0;\n font-weight: 600;\n font-size: 1.2rem;\n"]))),aX=eC.p(MW||(MW=fm(["\n padding: 0 0 0.3125rem;\n margin: 0.25rem auto;\n font-size: 0.8rem;\n"]))),sX=eC.ul(VW||(VW=fm(["\n list-style: none;\n padding: 0;\n"]))),cX=eC.li(jW||(jW=fm(["\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"]))),uX=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 lX(e){var t=e.checkCameraMode,r=e.frontCamera,n=e.onClose,i=e.children,o=e.onVideoPlayed,a=e.flipHorizontal,s=e.videoSettings,c=e.refVideo,u=e.onError,l=e.closeButton,f=e.videoClassName,d=lk.useSDKSettings().lang,p=zk.useSDKTracking().sendEvent,h=Hk.useAsset("ic_close.png"),g=dm(ay.useState(""),2),m=g[0],y=g[1],v=dm(ay.useState([]),2),b=v[0],C=v[1],w=dm(ay.useState(!1),2),E=w[0],k=w[1],S=ay.useRef(!1),B=ay.useRef(!1),T=ay.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=ay.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=CG.isMobile?CG.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,uX.getUserMedia({audio:!1,video:am(am({},t?{deviceId:t}:{facingMode:r?"user":"environment"}),s||n)});case 5:return(i=e.sent)||(y(YW.not_supported.msg[d]),u(YW.not_supported)),e.abrupt("return",i);case 10:e.prev=10,e.t0=e.catch(2),"NotAllowedError"===e.t0.name?(y(YW.no_permission.msg[d]),u(YW.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,d,u]),I=ay.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=bS.analyzeVideoAndWindowSizes(r),i=n.lostX,a=void 0===i?0:i,s=n.lostY,c=void 0===s?0:s,u=Math.min(e,Math.floor(e-2*a)),l=Math.min(t,Math.floor(t-2*c));o&&o({clientWidth:e,clientHeight:t,videoAreaWidth:u,videoAreaHeight:l,lostX:a,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,o]);ay.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,WW();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)}E&&!S.current&&(S.current=!0,function(){e.apply(this,arguments)}())}),[E]),ay.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,WW();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!uX||CG.browserName&&["facebook"].includes(CG.browserName.toLowerCase())||CG.getUA.includes("Zalo iOS")?(y(YW.not_supported.msg[d]),u(YW.not_supported)):t&&(CG.isAndroid&&!1===r?function(){e.apply(this,arguments)}():I()),function(){T()}}),[c,d,r,I,T,u]),ay.useEffect((function(){var e=setTimeout((function(){B.current||(y(YW.camera_timeout.msg[d]),u(YW.camera_timeout))}),3e5);return function(){clearTimeout(e)}}),[d,u]);var _=ay.useCallback((function(){T(),n&&n(),p({tag:"result",event:"user_activity.cancel",log:{}})}),[n,T,p]);return ay.createElement($W,{checkCameraMode:t},E&&null!=b&&b.length?ay.createElement(rX,null,ay.createElement(nX,null,ay.createElement(iX,null,ay.createElement(oX,null,"Không thể mở camera mặc định"),ay.createElement(aX,null,"Vui lòng thử chọn camera khác trong danh sách dưới đây")),ay.createElement(sX,null,b.map((function(e,t){return ay.createElement(cX,{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=YW.no_permission.msg[d];return m===e&&CG.isIOS?ay.createElement(tX,null,m," ",ay.createElement("button",{onClick:function(){window.location.reload()}},{vi:"Cấp lại quyền truy cập camera",en:"Request camera permission"}[d])):ay.createElement(tX,null,m)}(),ay.createElement(ZW,{ref:c,playsInline:!0,muted:!0,flipHorizontal:a,className:f}),i,l?ay.cloneElement(l,{onClick:_,"data-testid":"close-camera"}):ay.createElement(eX,{onClick:_,"data-testid":"close-camera"},ay.createElement("img",{src:h,alt:""})))}lX.propTypes={checkCameraMode:Ry.bool,frontCamera:Ry.bool,onClose:Ry.func,onError:Ry.func,onVideoPlayed:Ry.func,children:Ry.node,flipHorizontal:Ry.bool,videoSettings:Ry.object,refVideo:Ry.object,closeButton:Ry.node,videoClassName:Ry.string},lX.defaultProps={checkCameraMode:!1,frontCamera:!0,onClose:null,onError:function(){},onVideoPlayed:null,children:null,flipHorizontal:!1,videoSettings:null,refVideo:null,closeButton:null,videoClassName:""};var fX=rC(XW||(XW=fm(["\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"]))),dX=["open","children","overlayStyle"],pX=function(e){var t=e.open,r=e.children,n=e.overlayStyle,i=lm(e,dX);return ay.createElement(ay.Fragment,null,ay.createElement(QW,im({overlayStyle:am(am({},n),{},{zIndex:2e3}),closeOnDocumentClick:!1,closeOnEscape:!1,modal:!0,open:t},i),r),ay.createElement(fX,null))};pX.propTypes={open:Ry.bool,children:Ry.node,overlayStyle:Ry.shape({})},pX.defaultProps={open:!1,children:null,overlayStyle:{}};var hX,gX,mX,yX,vX,bX,CX,wX,EX,kX,SX,BX,TX,AX,IX,_X,xX,RX,PX,NX,LX,OX,DX,UX,MX={primaryColor:"#FDB913",errorBgColor:"#D32F2F",dangerColor:"#dedede",textColor:"#000000",errorColor:"#FF3B30",borderColor:"#dedede",titleSize:"1rem",titlelineHeight:"1.5rem",subTitleSize:"0.938rem",subTitleLineHeight:"1.25rem",fontBold:"600",fontNormal:"400"},VX=Gz.flipY,jX=Gz.spin,FX=Gz.splash,zX=(VX.animationDuration,FX.default),KX=eC.div(hX||(hX=fm(["\n ","\n ","\n"])),VX.default,jX.default),qX=(eC.img(gX||(gX=fm(["\n border-radius: 5px;\n opacity: 0.7;\n height: 38px;\n"]))),eC.div(mX||(mX=fm(["\n cursor: pointer;\n text-align: center;\n width: ","px;\n height: ","px;\n\n img {\n width: 100%;\n }\n\n z-index: ",";\n position: absolute;\n bottom: ","px;\n"])),60,60,1025,20)),HX=eC.div(yX||(yX=fm(["\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"])),100,100,1020),GX=eC.div(vX||(vX=fm(["\n color: #fff;\n text-align: center;\n"]))),QX=(eC.div(bX||(bX=fm(["\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),eC.div(CX||(CX=fm(["\n // display: flex;\n flex-direction: row;\n align-items: center;\n"])))),WX=eC(GX)(wX||(wX=fm(["\n font-size: ","px;\n z-index: ",";\n position: fixed;\n top: 5px;\n left: 0;\n right: 0;\n text-align: center;\n color: ",";\n padding: 0 3rem 0 2rem;\n"])),CG.isMobile?16:24,1020,MX.textColor),XX=eC(WX)(EX||(EX=fm(["\n font-size: ","px;\n color: ",";\n top: ",";\n padding: 0 1rem;\n"])),CG.isMobile?16:18,MX.textColor,(function(e){return e.y})),YX=eC(GX)(kX||(kX=fm(["\n font-size: 20px;\n margin-left: 10px;\n color: green;\n position: absolute;\n left: 0;\n top: 10px;\n background: white;\n z-index: ",";\n"])),1030),$X=eC(GX)(SX||(SX=fm(["\n position: absolute;\n font-size: 1rem;\n text-align: center;\n color: ",";\n top: ",";\n z-index: ",";\n"])),MX.textColor,(function(e){return e.y}),1020),ZX=eC($X)(BX||(BX=fm(["\n color: ",";\n padding: 5px 10px;\n border-radius: 3px;\n"])),MX.errorColor),JX=eC(GX)(TX||(TX=fm(["\n position: absolute;\n font-size: 1rem;\n text-align: center;\n border-radius: 3px;\n padding: 5px 10px;\n color: ",";\n margin: 0 10px;\n top: ",";\n z-index: ",";\n"])),MX.errorColor,(function(e){return e.y}),1020),eY=(eC.div(AX||(AX=fm(["\n font-size: 1rem;\n text-align: center;\n padding: 10px;\n"]))),eC(pz)(IX||(IX=fm(["\n position: absolute;\n top: 0;\n left: 0;\n"])))),tY=eC.div(_X||(_X=fm(["\n cursor: pointer;\n text-align: center;\n width: 50px;\n\n img {\n width: 100%;\n }\n"]))),rY=eC(tY)(xX||(xX=fm(["\n z-index: ",";\n position: absolute;\n top: 0px;\n right: 15px;\n width: 25px;\n"])),1100),nY=eC.div(RX||(RX=fm(["\n height: 50%;\n z-index: 1010;\n width: 100%;\n position: absolute;\n top: 670px;\n left: 0;\n background-color: #fff;\n"]))),iY={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 photo",vi:"Dùng ảnh này"},BTN_TRY_AGAIN:{en:"Retake",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"},IDCARD_TITLE:{en:"Take photos of National ID card",vi:"Chụp ảnh CCCD/CMND"},IDCARD_SUBTITLE:{en:"Make sure the card fits into the frame",vi:"Đảm bảo CCCD/CMND được đặt trong khung hình"},SELFIE_TITLE:{en:"Identity verification",vi:"Xác thực danh tính"}},oY=aC.IDCardMessage,aY=eC.div(PX||(PX=fm(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n padding: 10px;\n"]))),sY=eC.div(NX||(NX=fm(["\n text-align: center;\n font-size: 1rem;\n"]))),cY=eC.button(LX||(LX=fm(["\n margin-top: 20px;\n width: 100%;\n max-width: 160px;\n height: 50px;\n background-color: #eb6719;\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"]))),uY=function(e){var t=e.onOk,r=e.maxSessionTime,n=lk.useSDKSettings().lang;return ay.createElement(aY,null,ay.createElement(sY,{className:"popup-message"},TW(oY.TIMEOUT_INSTRUCTION[n])({x:r})),ay.createElement(cY,{className:"popup-button",onClick:t},iY.BTN_OK[n]))};uY.propTypes={onOk:Ry.func,maxSessionTime:Ry.number},uY.defaultProps={onOk:function(){},maxSessionTime:30};var lY,fY,dY,pY,hY,gY,mY,yY,vY,bY,CY,wY=aC.IDCardMessage,EY=eC.div(OX||(OX=fm(["\n position: absolute;\n top: ",";\n z-index: ",";\n"])),(function(e){return e.y}),1020),kY=eC(WX)(DX||(DX=fm(["\n position: initial;\n text-align: center;\n color: ",";\n font-weight: 600;\n font-size: ","px;\n"])),MX.textColor,CG.isMobile?16:18),SY=eC(nY)(UX||(UX=fm(["\n top: ",";\n background-image: url(",");\n"])),(function(e){return e.y}),(function(e){return e.url})),BY=ay.forwardRef((function(e,t){var r,n=e.title,i=e.usePortraitMask,o=e.windowAndVideoInfo,a=e.refVideo,s=e.frontSide,c=e.settings,u=e.onCaptureDone,l=e.onUISpacingChange,f=e.outputEncryptionSettings,d=dm(ay.useState({}),2),p=d[0],h=d[1],g=p.yDescription,m=p.yMessage,y=Hk.useAsset("ic_camera.svg"),v=Hk.useAsset("ic_camera_disabled.svg"),b=Hk.useAsset("ic_loading.png"),C=Hk.useAsset("watermark.png"),w=dm(ay.useState(""),2),E=w[0],k=w[1],S=lk.useSDKSettings(),B=S.debug,T=S.lang,A=dm(ay.useState(null),2),I=A[0],_=A[1],x=dm(ay.useState(""),2),R=x[0],P=x[1],N=dm(ay.useState(null),2),L=N[0],O=N[1],D=function(){var e=dm(ay.useState(!1),2),t=e[0],r=e[1],n=dm(ay.useState(null),2),i=n[0],o=n[1],a=dm(ay.useState({}),2),s=a[0],c=a[1];return{showPopup:ay.useCallback((function(e){var t=e.popupType,n=e.props;c(void 0===n?{}:n),o(t),r(null!==t)}),[]),popupShown:t,popupType:i,props:s}}(),U=D.showPopup,M=D.popupShown,V=D.popupType,j=CT.useThemeContext(),F=j.dangerColor,z=j.borderColor,K=ay.useCallback((function(e){P(null===e?"":TW(e.msg[T])({side:s?iY.FRONT[T]:iY.BACK[T]}))}),[T,s]),q=ay.useCallback((function(){_(""),U({popupType:AW})}),[U]),H=ay.useCallback((function(){_(""),u.apply(void 0,arguments)}),[u]),G=ay.useCallback((function(e){var t=e.curTimeLeft;_(TW(wY.REMAINING_TIME[T])({x:t}))}),[T]),Q=XK({shouldStart:!0,refVideo:a,cropArea:L,settings:c,onModelErrorChange:K,frontSide:s,onDebugInfoChange:k,onSessionTimeout:q,onCaptureDone:H,onAboutToTimeout:G,outputEncryptionSettings:f}),W=Q.warmupDone,X=Q.isProcessing,Y=Q.takePictureManually,$=Q.restartSession,Z=Q.resetIsProcessingImageBlobTaken,J=ay.useCallback((function(){U({popupType:null}),Z()}),[U,Z]),ee=ay.useCallback(Jg(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return J(),e.next=3,$();case 3:case"end":return e.stop()}}),e)}))),[$,J]);ay.useEffect((function(){if(o){var e,t,r,n,a,s,c,u=o.videoAreaWidth,f=o.videoAreaHeight,d=o.lostX,p=o.lostY,g=o.clientHeight;i?(a=.7*(s=f-165),r=(c=(e=p+10)+45)-60,n=(t=c+s+10)+60):(a=CG.isMobile?u-6:Math.floor(.7*u),r=(c=(e=p+10)+50)-60,n=(t=c+(s=Math.floor(Math.min(a/1.5,g-2*p-100-100)))+10)+60);var m=Math.floor((u-a)/2)+d;O({x:Math.ceil(m+.5),y:Math.ceil(c+50),width:Math.ceil(a),height:Math.ceil(s),surroundStyle:{opacity:1,background:"#fff"}});var y={yTitle:e,yDescription:t+50,yMessage:r+50,yCaptureButton:n-50};h(y),l(y)}}),[o,i,l]);var te=ay.useCallback(Jg(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _(""),e.next=3,Y();case 3:case"end":return e.stop()}}),e)}))),[Y]);return ay.useImperativeHandle(t,(function(){return{restartSession:ee}}),[ee]),ay.createElement(ay.Fragment,null,!W&&ay.createElement(gF,null),B&&ay.createElement(YX,null,E),X&&ay.createElement(HX,null,ay.createElement("img",{src:b,alt:"",className:"spin"})),L&&ay.createElement(wU,{x:"".concat(L.x,"px"),y:"".concat(L.y,"px"),width:"".concat(L.width,"px"),height:"".concat(L.height,"px"),surroundStyle:L.surroundStyle},ay.createElement(eY,{strokeStyles:(r={},nm(r,dz.DEFAULT,{fill:"none",strokeWidth:2,stroke:z}),nm(r,dz.ERROR,{fill:"none",strokeWidth:2,stroke:F}),r),paddingStyle:{fill:"#fff"},strokeWidth:2,radius:10,errorColor:F,width:L.width,height:L.height,type:R?dz.ERROR:dz.DEFAULT})),R&&ay.createElement(ZX,{y:"".concat(g+20,"px")},R),ay.createElement(XX,{className:"subtitle",y:"".concat(m+20,"px")},iY.IDCARD_SUBTITLE[T]),ay.createElement(qX,null,ay.createElement("img",{src:v,alt:""})),!X&&(!(null!=c&&c.disableCaptureButtonIfAlert)||!R)&&ay.createElement(qX,{onClick:te},ay.createElement("img",{src:y,alt:""})),ay.createElement(EY,{y:"".concat(g,"px")},ay.createElement(kY,null,n)),I&&ay.createElement(JX,{key:I,className:"message",y:"".concat(g+60,"px")},I),ay.createElement(SY,{y:"".concat(g,"px"),className:"waterMarkWrapper",url:C}),ay.createElement(pX,{open:M},V===AW&&ay.createElement(uY,{onOk:ee,maxSessionTime:null==c?void 0:c.idCardSessionTime})))}));BY.propTypes={usePortraitMask:Ry.bool,title:Ry.string,windowAndVideoInfo:Ry.shape({}),refVideo:Ry.shape({}),frontSide:Ry.bool,settings:Ry.shape({}),onCaptureDone:Ry.func,onUISpacingChange:Ry.func,outputEncryptionSettings:Ry.shape({})},BY.defaultProps={usePortraitMask:!1,title:"",windowAndVideoInfo:{},refVideo:{},frontSide:!0,settings:{},onCaptureDone:function(){},onUISpacingChange:function(){},outputEncryptionSettings:null};var TY=eC.div(lY||(lY=fm(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n height: 100%;\n justify-content: normal;\n"]))),AY=eC.div(fY||(fY=fm(["\n text-align: center;\n font-size: 1rem;\n color: ",";\n margin-top: 10px;\n"])),MX.errorColor),IY=eC.button(dY||(dY=fm(["\n width: 100%;\n height: 44px;\n background-color: ",";\n border: 0;\n outline: none;\n border-radius: 9.375rem;\n color: ",";\n font-weight: 600;\n cursor: pointer;\n font-size: 17px;\n border: 1px solid #fff;\n border-color: ",";\n"])),(function(e){return e.bgColor}),(function(e){return e.color?e.color:"#fff"}),(function(e){return e.color?e.color:"#fff"})),_Y=eC.img(pY||(pY=fm(["\n ",";\n border-radius: 20px;\n margin-top: 10px;\n ",";\n"])),!CG.isMobile&&Vb(["height:","px;"],(function(e){return e.calHeight-300})),(function(e){return e.calHeight>0&&CG.isMobile&&Vb(["width:","px;height:","px;border:none;"],window.innerWidth-30,e.calHeight)})),xY=eC.div(hY||(hY=fm(["\n font-weight: 600;\n font-size: ","px;\n text-align: center;\n color: ",";\n padding: 0 3rem 0 2rem;\n"])),CG.isMobile?16:24,MX.textColor),RY=eC.div(gY||(gY=fm(["\n font-size: ","px;\n color: ",";\n padding: 0 1rem;\n text-align: center;\n margin-top: 1.5rem;\n min-height: 30px;\n"])),CG.isMobile?16:18,MX.textColor),PY=eC.div(mY||(mY=fm(["\n margin-top: 1rem;\n font-size: ","px;\n font-weight: 600;\n"])),CG.isMobile?16:18),NY=eC.div(yY||(yY=fm(["\n width: 95%;\n display: flex;\n justify-content: space-evenly;\n flex-direction: column;\n position: absolute;\n bottom: 20px;\n left: 0;\n right: 0;\n margin: 0 auto;\n background: transparent;\n"]))),LY=eC.div(vY||(vY=fm(["\n width: 100%;\n margin-top: 0.625rem;\n"]))),OY=eC.div(bY||(bY=fm(["\n width: 100%;\n"]))),DY=eC(nY)(CY||(CY=fm(["\n top: ",";\n background-image: url(",");\n position: static;\n height: 100%;\n text-align: center;\n"])),(function(e){return e.y}),(function(e){return e.url})),UY=function(e){var t=e.title,r=e.imageTaken,n=e.onConfirm,i=e.onTryAgain,o=e.error,a=e.hasValidQR,s=dm(ay.useState(null),2),c=s[0],u=s[1],l=lk.useSDKSettings().lang,f=dm(ay.useState(0),2),d=f[0],p=f[1],h=ay.useRef(),g=Hk.useAsset("ic_close.svg"),m=Hk.useAsset("ic_close.svg"),y=Hk.useAsset("watermark.png");ay.useEffect((function(){var e;return r&&(e=URL.createObjectURL(r.blob),u(e)),function(){URL.revokeObjectURL(e)}}),[r]);return ay.createElement(TY,{className:"popup_detail"},null!==a&&ay.createElement(oq,{mb:"20px"},ay.createElement("div",null,ay.createElement(vH,{type:a?fH.SUCCESS:fH.WARNING},a?iY.CONFIRM_POPUP_VALID_QR[l]:iY.CONFIRM_POPUP_INVALID_QR[l]))),ay.createElement(QX,null,ay.createElement(xY,{className:"title"},iY.IDCARD_TITLE[l]),ay.createElement(RY,null,iY.IDCARD_SUBTITLE[l])),ay.createElement(_Y,{ref:h,src:c,calHeight:d,onLoad:function(){if(CG.isMobile){var e=h.current,t=e.height/e.width,r=(window.innerWidth-30)*t;p(r)}}}),o&&ay.createElement(AY,{className:"confirm-popup-error-message"},o.msg[l]),ay.createElement(DY,{className:"waterMarkWrapper",url:y},ay.createElement(PY,null," ",t),ay.createElement(NY,null,ay.createElement(OY,null,ay.createElement(IY,{onClick:n,bgColor:"#000"},iY.BTN_USE_THIS_PICTURE[l])),ay.createElement(LY,null,ay.createElement(IY,{onClick:i,bgColor:"#fff",color:"#000"},iY.BTN_TRY_AGAIN[l])))),ay.createElement(rY,{onClick:i},ay.createElement("img",{src:CG.isMobile?g:m,alt:""})))};UY.propTypes={imageTaken:Ry.shape({}),error:Ry.shape({msg:Ry.shape({})}),onConfirm:Ry.func,onTryAgain:Ry.func,hasValidQR:Ry.bool,title:Ry.string},UY.defaultProps={imageTaken:null,error:null,onConfirm:function(){},onTryAgain:function(){},hasValidQR:null,title:""};var MY,VY,jY,FY="CONFIRM",zY=rC(MY||(MY=fm(["\n .text-primary {\n color: ",";\n }\n\n .popup-content {\n width: 90%;\n margin: 0;\n textt-align: center;\n border: 0!important;\n }\n"])),(function(e){return e.theme.tsBlue})),KY=aC.IDCardSide,qY=aC.IDCardType,HY="id_card",GY="qr_code",QY=[{scannerType:HY,title:"Mặt trước",description:"Vui lòng chụp mặt trước CCCD/CMND",titleIcon:"id_card_front.svg",cardSide:aC.IDCardSide.FRONT,cardType:qY.VN,frontCamera:!1,enableConfirmPopup:!0,title_vi:"Mặt trước",title_en:"Front Face"},{scannerType:HY,title:"Mặt sau",description:"Vui lòng chụp mặt sau CCCD/CMND",titleIcon:"id_card_back.svg",cardSide:aC.IDCardSide.BACK,cardType:qY.VN,frontCamera:!1,enableConfirmPopup:!0,title_vi:"Mặt sau",title_en:"Rear Face"}],WY=eC.div(VY||(VY=fm(["\n cursor: pointer;\n text-align: center;\n img {\n width: 100%;\n }\n z-index: ",";\n position: absolute;\n top: 0px;\n right: 1rem;\n width: 25px;\n"])),1100),XY=eC(WX)(jY||(jY=fm(["\n padding: 0 3rem 0 2rem;\n font-size: ","px;\n font-weight: 600;\n"])),CG.isMobile?16:24);function YY(e){var t=e.onClose,r=e.onError,n=e.clientSettings,i=e.onStepDone,o=e.steps,a=e.outputEncryptionSettings,s=e.title,c=dm(ay.useState(0),2),u=c[0],l=c[1],f=dm(ay.useState(o[u]),2),d=f[0],p=f[1],h=ay.useRef(null),g=dm(ay.useState(null),2),m=g[0],y=g[1],v=dm(ay.useState(!1),2),b=v[0],C=v[1],w=dm(ay.useState(0),2),E=w[0],k=w[1],S=ay.useRef(),B=d.scannerType,T=d.frontCamera,A=d.cardSide,I=d.usePortraitMask,_=d.enableConfirmPopup,x=A===KY.FRONT,R=pK(),P=R.showPopup,N=R.popupShown,L=R.popupType,O=R.props,D=dm(ay.useState(!1),2),U=D[0],M=D[1],V=Hk.useAsset("ic_loading.png"),j=Hk.useAsset("ic_close.svg"),F=ay.useRef({}),z=ay.useRef(null),K=ay.useRef([]),q=FH({clientSettings:n}).settings,H=lk.useSDKSettings().lang,G=d["title_".concat(H)]||d.title,Q=ay.useCallback((function(e){y(e),C(!0)}),[]);ay.useEffect((function(){var e=document.querySelector("html").style.overflow,t=document.body.style.overflow;return document.querySelector("html").style.overflow="hidden",document.body.style.overflow="hidden",function(){document.querySelector("html").style.overflow=e,document.body.style.overflow=t}}),[]),ay.useEffect((function(){C(!1)}),[T]);var W=ay.useCallback((function(){P({popupType:null})}),[P]),X=ay.useCallback((function(e){e>=o.length||setTimeout((function(){l(e),p(o[e])}),200)}),[o]),Y=ay.useCallback((function(){X(u+1)}),[X,u]),$=ay.useCallback(Jg(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={stepNumber:u,image:F.current,recordedVideos:null!=q&&q.enableRecording?K.current:[]},B===GY&&(t.qrScannedResult=z.current),M(!0),e.next=5,i(t);case 5:M(!1),Y();case 7:case"end":return e.stop()}}),e)}))),[q,u,i,Y,B]),Z=ay.useCallback((function(){W(),B===GY?X(u):B===HY&&S.current.restartSession()}),[X,u,W,B]),J=ay.useCallback((function(){W(),$()}),[$,W]),ee=ay.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,F.current=r,K.current=i,k((function(e){return e+1})),_?P({popupType:FY,props:{title:s,imageTaken:F.current,error:n}}):$();case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[_,P,$,s]);return ay.createElement($b,{theme:MX},ay.createElement(KX,null,ay.createElement(gU,{key:T,frontCamera:T,onVideoPlayed:Q,flipHorizontal:T,ref:h,onError:r,onClose:t,closeButton:ay.createElement(WY,null,ay.createElement("img",{src:j,alt:""}))},ay.createElement(QX,null,ay.createElement(XY,{className:"title"},iY.IDCARD_TITLE[H])),b&&ay.createElement(ay.Fragment,null,B===HY&&ay.createElement(BY,{key:u,ref:S,windowAndVideoInfo:m,refVideo:h,settings:q,onCaptureDone:ee,frontSide:x,title:G,usePortraitMask:I,outputEncryptionSettings:a})),ay.createElement(zX,{keyForTransition:E}),U&&ay.createElement(HX,null,ay.createElement("img",{src:V,alt:"",className:"spin"}))),ay.createElement(Yj,{open:N,overlayStyle:{padding:0},contentStyle:{maxWidth:"none",width:"100%",height:"100%",borderRadius:0}},L===FY&&ay.createElement(UY,im({},O,{onConfirm:J,onTryAgain:Z,title:G})))),ay.createElement(zY,null))}YY.propTypes={onClose:Ry.func,onError:Ry.func,clientSettings:Ry.shape({}),detectIdCard:Ry.func,onStepDone:Ry.func,steps:Ry.arrayOf(Ry.shape({})),outputEncryptionSettings:Ry.shape({}),title:Ry.string},YY.defaultProps={onClose:function(){},onError:function(){},clientSettings:{},detectIdCard:function(){return Promise.resolve({card_label:""})},onStepDone:function(){},steps:QY,outputEncryptionSettings:null,title:""};var $Y,ZY,JY,e$,t$,r$,n$,i$,o$,a$=function(e,t,r,n,i,o,a,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,o,a,s],l=0;(c=new Error(t.replace(/%s/g,(function(){return u[l++]})))).name="Invariant Violation"}throw c.framesToPop=1,c}},s$=i(o((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,o){var a="function",s="undefined",c="object",u="model",l="name",f="type",d="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]:o},trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},w={rgx:function(e,t){for(var r,n,i,s,u,l,f=0;f<t.length&&!u;){var d=t[f],p=t[f+1];for(r=n=0;r<d.length&&!u;)if(u=d[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]==a?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:3==s.length?typeof s[1]!==a||s[1].exec&&s[1].test?this[s[0]]=l?l.replace(s[1],s[2]):o:this[s[0]]=l?s[1].call(this,l,s[2]):o:4==s.length&&(this[s[0]]=l?s[3].call(this,l.replace(s[1],s[2])):o):this[s]=l||o;f+=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?o:r}else if(C.has(t[r],e))return"?"===r?o:r;return e}},E={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,w.str,E.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,d,[f,y]],[/applecoremedia\/[\w\.]+ \((ipad)/],[u,[d,"Apple"],[f,y]],[/(apple\s{0,1}tv)/i],[[u,"Apple TV"],[d,"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],[d,u,[f,y]],[/(kf[A-z]+)\sbuild\/.+silk\//i],[u,[d,"Amazon"],[f,y]],[/(sd|kf)[0349hijorstuw]+\sbuild\/.+silk\//i],[[u,w.str,E.device.amazon.model],[d,"Amazon"],[f,m]],[/\((ip[honed|\s\w*]+);.+(apple)/i],[u,d,[f,m]],[/\((ip[honed|\s\w*]+);/i],[u,[d,"Apple"],[f,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],[d,u,[f,m]],[/\(bb10;\s(\w+)/i],[u,[d,"BlackBerry"],[f,m]],[/android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone)/i],[u,[d,"Asus"],[f,y]],[/(sony)\s(tablet\s[ps])\sbuild\//i,/(sony)?(?:sgp.+)\sbuild\//i],[[d,"Sony"],[u,"Xperia Tablet"],[f,y]],[/android.+\s([c-g]\d{4}|so[-l]\w+)\sbuild\//i],[u,[d,"Sony"],[f,m]],[/\s(ouya)\s/i,/(nintendo)\s([wids3u]+)/i],[d,u,[f,g]],[/android.+;\s(shield)\sbuild/i],[u,[d,"Nvidia"],[f,g]],[/(playstation\s[34portablevi]+)/i],[u,[d,"Sony"],[f,g]],[/(sprint\s(\w+))/i],[[d,w.str,E.device.sprint.vendor],[u,w.str,E.device.sprint.model],[f,m]],[/(lenovo)\s?(S(?:5000|6000)+(?:[-][\w+]))/i],[d,u,[f,y]],[/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i,/(zte)-(\w*)/i,/(alcatel|geeksphone|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i],[d,[u,/_/g," "],[f,m]],[/(nexus\s9)/i],[u,[d,"HTC"],[f,y]],[/d\/huawei([\w\s-]+)[;\)]/i,/(nexus\s6p)/i],[u,[d,"Huawei"],[f,m]],[/(microsoft);\s(lumia[\s\w]+)/i],[d,u,[f,m]],[/[\s\(;](xbox(?:\sone)?)[\s\);]/i],[u,[d,"Microsoft"],[f,g]],[/(kin\.[onetw]{3})/i],[[u,/\./g," "],[d,"Microsoft"],[f,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,[d,"Motorola"],[f,m]],[/android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i],[u,[d,"Motorola"],[f,y]],[/hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i],[[d,C.trim],[u,C.trim],[f,v]],[/hbbtv.+maple;(\d+)/i],[[u,/^/,"SmartTV"],[d,"Samsung"],[f,v]],[/\(dtv[\);].+(aquos)/i],[u,[d,"Sharp"],[f,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],[[d,"Samsung"],u,[f,y]],[/smart-tv.+(samsung)/i],[d,[f,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],[[d,"Samsung"],u,[f,m]],[/sie-(\w*)/i],[u,[d,"Siemens"],[f,m]],[/(maemo|nokia).*(n900|lumia\s\d+)/i,/(nokia)[\s_-]?([\w-]*)/i],[[d,"Nokia"],u,[f,m]],[/android\s3\.[\s\w;-]{10}(a\d{3})/i],[u,[d,"Acer"],[f,y]],[/android.+([vl]k\-?\d{3})\s+build/i],[u,[d,"LG"],[f,y]],[/android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i],[[d,"LG"],u,[f,y]],[/(lg) netcast\.tv/i],[d,u,[f,v]],[/(nexus\s[45])/i,/lg[e;\s\/-]+(\w*)/i,/android.+lg(\-?[\d\w]+)\s+build/i],[u,[d,"LG"],[f,m]],[/android.+(ideatab[a-z0-9\-\s]+)/i],[u,[d,"Lenovo"],[f,y]],[/linux;.+((jolla));/i],[d,u,[f,m]],[/((pebble))app\/[\d\.]+\s/i],[d,u,[f,b]],[/android.+;\s(oppo)\s?([\w\s]+)\sbuild/i],[d,u,[f,m]],[/crkey/i],[[u,"Chromecast"],[d,"Google"]],[/android.+;\s(glass)\s\d/i],[u,[d,"Google"],[f,b]],[/android.+;\s(pixel c)\s/i],[u,[d,"Google"],[f,y]],[/android.+;\s(pixel xl|pixel)\s/i],[u,[d,"Google"],[f,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," "],[d,"Xiaomi"],[f,m]],[/android.+(mi[\s\-_]*(?:pad)(?:[\s_]*[\w\s]+))\s+build/i],[[u,/_/g," "],[d,"Xiaomi"],[f,y]],[/android.+;\s(m[1-5]\snote)\sbuild/i],[u,[d,"Meizu"],[f,y]],[/android.+a000(1)\s+build/i,/android.+oneplus\s(a\d{4})\s+build/i],[u,[d,"OnePlus"],[f,m]],[/android.+[;\/]\s*(RCT[\d\w]+)\s+build/i],[u,[d,"RCA"],[f,y]],[/android.+[;\/\s]+(Venue[\d\s]{2,7})\s+build/i],[u,[d,"Dell"],[f,y]],[/android.+[;\/]\s*(Q[T|M][\d\w]+)\s+build/i],[u,[d,"Verizon"],[f,y]],[/android.+[;\/]\s+(Barnes[&\s]+Noble\s+|BN[RT])(V?.*)\s+build/i],[[d,"Barnes & Noble"],u,[f,y]],[/android.+[;\/]\s+(TM\d{3}.*\b)\s+build/i],[u,[d,"NuVision"],[f,y]],[/android.+;\s(k88)\sbuild/i],[u,[d,"ZTE"],[f,y]],[/android.+[;\/]\s*(gen\d{3})\s+build.*49h/i],[u,[d,"Swiss"],[f,m]],[/android.+[;\/]\s*(zur\d{3})\s+build/i],[u,[d,"Swiss"],[f,y]],[/android.+[;\/]\s*((Zeki)?TB.*\b)\s+build/i],[u,[d,"Zeki"],[f,y]],[/(android).+[;\/]\s+([YR]\d{2})\s+build/i,/android.+[;\/]\s+(Dragon[\-\s]+Touch\s+|DT)(\w{5})\sbuild/i],[[d,"Dragon Touch"],u,[f,y]],[/android.+[;\/]\s*(NS-?\w{0,9})\sbuild/i],[u,[d,"Insignia"],[f,y]],[/android.+[;\/]\s*((NX|Next)-?\w{0,9})\s+build/i],[u,[d,"NextBook"],[f,y]],[/android.+[;\/]\s*(Xtreme\_)?(V(1[045]|2[015]|30|40|60|7[05]|90))\s+build/i],[[d,"Voice"],u,[f,m]],[/android.+[;\/]\s*(LVTEL\-)?(V1[12])\s+build/i],[[d,"LvTel"],u,[f,m]],[/android.+[;\/]\s*(V(100MD|700NA|7011|917G).*\b)\s+build/i],[u,[d,"Envizen"],[f,y]],[/android.+[;\/]\s*(Le[\s\-]+Pan)[\s\-]+(\w{1,9})\s+build/i],[d,u,[f,y]],[/android.+[;\/]\s*(Trio[\s\-]*.*)\s+build/i],[u,[d,"MachSpeed"],[f,y]],[/android.+[;\/]\s*(Trinity)[\-\s]*(T\d{3})\s+build/i],[d,u,[f,y]],[/android.+[;\/]\s*TU_(1491)\s+build/i],[u,[d,"Rotor"],[f,y]],[/android.+(KS(.+))\s+build/i],[u,[d,"Amazon"],[f,y]],[/android.+(Gigaset)[\s\-]+(Q\w{1,9})\s+build/i],[d,u,[f,y]],[/\s(tablet|tab)[;\/]/i,/\s(mobile)(?:[;\/]|\ssafari)/i],[[f,C.lowerize],d,u],[/(android[\w\.\s\-]{0,9});.+build/i],[u,[d,"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,w.str,E.os.windows.version]],[/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],[[l,"Windows"],[p,w.str,E.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=o),!(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:o,version:o};return w.rgx.call(e,r,n.browser),e.major=C.major(e.version),e},this.getCPU=function(){var e={architecture:o};return w.rgx.call(e,r,n.cpu),e},this.getDevice=function(){var e={vendor:o,model:o,type:o};return w.rgx.call(e,r,n.device),e},this.getEngine=function(){var e={name:o,version:o};return w.rgx.call(e,r,n.engine),e},this.getOS=function(){var e={name:o,version:o};return w.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:d,TYPE:f,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))===o||(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),o=i.DEVICE_TYPES,a=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 o.MOBILE:return{isMobile:!0};case o.TABLET:return{isTablet:!0};case o.SMART_TV:return{isSmartTV:!0};case o.CONSOLE:return{isConsole:!0};case o.WEARABLE:return{isWearable:!0};case o.BROWSER:return{isBrowser:!0};default:return a}},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}}])})),wG="object"==typeof n&&n&&n.Object===Object&&n,EG="object"==typeof self&&self&&self.Object===Object&&self,kG=wG||EG||Function("return this")(),SG=kG.Symbol,BG=Object.prototype,TG=BG.hasOwnProperty,AG=BG.toString,IG=SG?SG.toStringTag:void 0;var _G=function(e){var t=TG.call(e,IG),r=e[IG];try{e[IG]=void 0;var n=!0}catch(e){}var i=AG.call(e);return n&&(t?e[IG]=r:delete e[IG]),i},xG=Object.prototype.toString;var RG=function(e){return xG.call(e)},PG=SG?SG.toStringTag:void 0;var NG=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":PG&&PG in Object(e)?_G(e):RG(e)};var LG=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};var OG=function(e){if(!LG(e))return!1;var t=NG(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},DG=kG["__core-js_shared__"],UG=function(){var e=/[^.]+$/.exec(DG&&DG.keys&&DG.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();var MG=function(e){return!!UG&&UG in e},VG=Function.prototype.toString;var jG=function(e){if(null!=e){try{return VG.call(e)}catch(e){}try{return e+""}catch(e){}}return""},FG=/^\[object .+?Constructor\]$/,zG=Function.prototype,KG=Object.prototype,qG=zG.toString,HG=KG.hasOwnProperty,GG=RegExp("^"+qG.call(HG).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var QG=function(e){return!(!LG(e)||MG(e))&&(OG(e)?GG:FG).test(jG(e))};var WG=function(e,t){return null==e?void 0:e[t]};var XG=function(e,t){var r=WG(e,t);return QG(r)?r:void 0},YG=function(){try{var e=XG(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var $G=function(e,t,r){"__proto__"==t&&YG?YG(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r};var ZG=function(e,t){return e===t||e!=e&&t!=t},JG=Object.prototype.hasOwnProperty;var eQ=function(e,t,r){var n=e[t];JG.call(e,t)&&ZG(n,r)&&(void 0!==r||t in e)||$G(e,t,r)};var tQ=function(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?$G(r,s,c):eQ(r,s,c)}return r};var rQ=function(e){return e};var nQ=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)},iQ=Math.max;var oQ=function(e,t,r){return t=iQ(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=iQ(n.length-t,0),a=Array(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),nQ(e,this,s)}};var aQ=function(e){return function(){return e}},sQ=YG?function(e,t){return YG(e,"toString",{configurable:!0,enumerable:!1,value:aQ(t),writable:!0})}:rQ,cQ=Date.now;var uQ=function(e){var t=0,r=0;return function(){var n=cQ(),i=16-(n-r);if(r=n,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(sQ);var lQ=function(e,t){return uQ(oQ(e,t,rQ),e+"")};var fQ=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};var dQ=function(e){return null!=e&&fQ(e.length)&&!OG(e)},pQ=/^(?:0|[1-9]\d*)$/;var hQ=function(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&pQ.test(e))&&e>-1&&e%1==0&&e<t};var gQ=function(e,t,r){if(!LG(r))return!1;var n=typeof t;return!!("number"==n?dQ(r)&&hQ(t,r.length):"string"==n&&t in r)&&ZG(r[t],e)};var mQ=function(e){return lQ((function(t,r){var n=-1,i=r.length,o=i>1?r[i-1]:void 0,a=i>2?r[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,a&&gQ(r[0],r[1],a)&&(o=i<3?void 0:o,i=1),t=Object(t);++n<i;){var s=r[n];s&&e(t,s,n,o)}return t}))};var yQ=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n};var vQ=function(e){return null!=e&&"object"==typeof e};var bQ=function(e){return vQ(e)&&"[object Arguments]"==NG(e)},CQ=Object.prototype,wQ=CQ.hasOwnProperty,EQ=CQ.propertyIsEnumerable,kQ=bQ(function(){return arguments}())?bQ:function(e){return vQ(e)&&wQ.call(e,"callee")&&!EQ.call(e,"callee")},SQ=Array.isArray;var BQ=function(){return!1},TQ=o((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r?kG.Buffer:void 0,o=(i?i.isBuffer:void 0)||BQ;e.exports=o})),AQ={};AQ["[object Float32Array]"]=AQ["[object Float64Array]"]=AQ["[object Int8Array]"]=AQ["[object Int16Array]"]=AQ["[object Int32Array]"]=AQ["[object Uint8Array]"]=AQ["[object Uint8ClampedArray]"]=AQ["[object Uint16Array]"]=AQ["[object Uint32Array]"]=!0,AQ["[object Arguments]"]=AQ["[object Array]"]=AQ["[object ArrayBuffer]"]=AQ["[object Boolean]"]=AQ["[object DataView]"]=AQ["[object Date]"]=AQ["[object Error]"]=AQ["[object Function]"]=AQ["[object Map]"]=AQ["[object Number]"]=AQ["[object Object]"]=AQ["[object RegExp]"]=AQ["[object Set]"]=AQ["[object String]"]=AQ["[object WeakMap]"]=!1;var IQ=function(e){return vQ(e)&&fQ(e.length)&&!!AQ[NG(e)]};var _Q=function(e){return function(t){return e(t)}},xQ=o((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r&&wG.process,o=function(){try{var e=n&&n.require&&n.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=o})),RQ=xQ&&xQ.isTypedArray,PQ=RQ?_Q(RQ):IQ,NQ=Object.prototype.hasOwnProperty;var LQ=function(e,t){var r=SQ(e),n=!r&&kQ(e),i=!r&&!n&&TQ(e),o=!r&&!n&&!i&&PQ(e),a=r||n||i||o,s=a?yQ(e.length,String):[],c=s.length;for(var u in e)!t&&!NQ.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||hQ(u,c))||s.push(u);return s},OQ=Object.prototype;var DQ=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||OQ)};var UQ=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t},MQ=Object.prototype.hasOwnProperty;var VQ=function(e){if(!LG(e))return UQ(e);var t=DQ(e),r=[];for(var n in e)("constructor"!=n||!t&&MQ.call(e,n))&&r.push(n);return r};var jQ=function(e){return dQ(e)?LQ(e,!0):VQ(e)},FQ=mQ((function(e,t,r,n){tQ(t,jQ(t),e,n)}));var zQ=function(e,t){return function(r){return e(t(r))}},KQ=zQ(Object.getPrototypeOf,Object),qQ=Function.prototype,HQ=Object.prototype,GQ=qQ.toString,QQ=HQ.hasOwnProperty,WQ=GQ.call(Object);var XQ=function(e){if(!vQ(e)||"[object Object]"!=NG(e))return!1;var t=KQ(e);if(null===t)return!0;var r=QQ.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&GQ.call(r)==WQ};var YQ=function(e){if(!vQ(e))return!1;var t=NG(e);return"[object Error]"==t||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!XQ(e)},$Q=lQ((function(e,t){try{return nQ(e,void 0,t)}catch(e){return YQ(e)?e:new Error(e)}}));var ZQ=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 JQ=function(e,t){return ZQ(t,(function(t){return e[t]}))},eW=Object.prototype,tW=eW.hasOwnProperty;var rW=function(e,t,r,n){return void 0===e||ZG(e,eW[r])&&!tW.call(n,r)?t:e},nW={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};var iW=function(e){return"\\"+nW[e]},oW=zQ(Object.keys,Object),aW=Object.prototype.hasOwnProperty;var sW=function(e){if(!DQ(e))return oW(e);var t=[];for(var r in Object(e))aW.call(e,r)&&"constructor"!=r&&t.push(r);return t};var cW=function(e){return dQ(e)?LQ(e):sW(e)},uW=/<%=([\s\S]+?)%>/g;var lW=function(e){return function(t){return null==e?void 0:e[t]}}({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});var fW=function(e){return"symbol"==typeof e||vQ(e)&&"[object Symbol]"==NG(e)},dW=SG?SG.prototype:void 0,pW=dW?dW.toString:void 0;var hW=function e(t){if("string"==typeof t)return t;if(SQ(t))return ZQ(t,e)+"";if(fW(t))return pW?pW.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r};var gW=function(e){return null==e?"":hW(e)},mW=/[&<>"']/g,yW=RegExp(mW.source);var vW={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:uW,variable:"",imports:{_:{escape:function(e){return(e=gW(e))&&yW.test(e)?e.replace(mW,lW):e}}}},bW=/\b__p \+= '';/g,CW=/\b(__p \+=) '' \+/g,wW=/(__e\(.*?\)|\b__t\)) \+\n'';/g,EW=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,kW=/($^)/,SW=/['\n\r\u2028\u2029\\]/g,BW=Object.prototype.hasOwnProperty;var TW=function(e,t,r){var n=vW.imports._.templateSettings||vW;r&&gQ(e,t,r)&&(t=void 0),e=gW(e),t=FQ({},t,n,rW);var i,o,a=FQ({},t.imports,n.imports,rW),s=cW(a),c=JQ(a,s),u=0,l=t.interpolate||kW,f="__p += '",d=RegExp((t.escape||kW).source+"|"+l.source+"|"+(l===uW?EW:kW).source+"|"+(t.evaluate||kW).source+"|$","g"),p=BW.call(t,"sourceURL")?"//# sourceURL="+(t.sourceURL+"").replace(/\s/g," ")+"\n":"";e.replace(d,(function(t,r,n,a,s,c){return n||(n=a),f+=e.slice(u,c).replace(SW,iW),r&&(i=!0,f+="' +\n__e("+r+") +\n'"),s&&(o=!0,f+="';\n"+s+";\n__p += '"),n&&(f+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),f+="';\n";var h=BW.call(t,"variable")&&t.variable;h||(f="with (obj) {\n"+f+"\n}\n"),f=(o?f.replace(bW,""):f).replace(CW,"$1").replace(wW,"$1;"),f="function("+(h||"obj")+") {\n"+(h?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var g=$Q((function(){return Function(s,p+"return "+f).apply(void 0,c)}));if(g.source=f,YQ(g))throw g;return g},AW="SESSION_TIMEOUT";function IW(){return(IW=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 _W,xW,RW,PW,NW,LW,OW,DW,UW,MW,VW,jW,FW="undefined"!=typeof window?ay.useLayoutEffect:ay.useEffect,zW={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}}},KW=["top left","top center","top right","right top","right center","right bottom","bottom left","bottom center","bottom right","left top","left center","left bottom"],qW=function(e,t,r,n,i){var o=i.offsetX,a=i.offsetY,s=n?8:0,c=r.split(" "),u=e.top+e.height/2,l=e.left+e.width/2,f=t.height,d=t.width,p=u-f/2,h=l-d/2,g="",m="0%",y="0%";switch(c[0]){case"top":p-=f/2+e.height/2+s,g="rotate(180deg) translateX(50%)",m="100%",y="50%";break;case"bottom":p+=f/2+e.height/2+s,g="rotate(0deg) translateY(-100%) translateX(-50%)",y="50%";break;case"left":h-=d/2+e.width/2+s,g=" rotate(90deg) translateY(50%) translateX(-25%)",y="100%",m="50%";break;case"right":h+=d/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-f+e.height,m=f-e.height/2+"px";break;case"left":h=e.left,y=e.width/2+"px";break;case"right":h=e.left-d+e.width,y=d-e.width/2+"px"}return{top:p="top"===c[0]?p-a:p+a,left:h="left"===c[0]?h-o:h+o,transform:g,arrowLeft:y,arrowTop:m}},HW=function(e,t,r,n,i,o){var a=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}(o),f=Array.isArray(r)?r:[r];for((o||Array.isArray(r))&&(f=[].concat(f,KW));u<f.length;){var d={top:(c=qW(e,t,f[u],n,{offsetX:a,offsetY:s})).top,left:c.left,width:t.width,height:t.height};if(!(d.top<=l.top||d.left<=l.left||d.top+d.height>=l.top+l.height||d.left+d.width>=l.left+l.width))break;u++}return c},GW=0,QW=ay.forwardRef((function(e,t){var r=e.trigger,n=void 0===r?null:r,i=e.onOpen,o=void 0===i?function(){}:i,a=e.onClose,s=void 0===a?function(){}:a,c=e.defaultOpen,u=void 0!==c&&c,l=e.open,f=void 0===l?void 0:l,d=e.disabled,p=void 0!==d&&d,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,w=void 0===C||C,E=e.on,k=void 0===E?["click"]:E,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,R=void 0===x?"":x,P=e.position,N=void 0===P?"bottom center":P,L=e.modal,O=void 0!==L&&L,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,$=ay.useState(f||u),Z=$[0],J=$[1],ee=ay.useRef(null),te=ay.useRef(null),re=ay.useRef(null),ne=ay.useRef(null),ie=ay.useRef("popup-"+ ++GW),oe=!!O||!n,ae=ay.useRef(0);FW((function(){return Z?(ne.current=document.activeElement,ve(),ge(),pe()):he(),function(){clearTimeout(ae.current)}}),[Z]),ay.useEffect((function(){"boolean"==typeof f&&(f?se():ce())}),[f,p]);var se=function(e){Z||p||(J(!0),setTimeout((function(){return o(e)}),0))},ce=function(e){var t;Z&&!p&&(J(!1),oe&&(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(ae.current),ae.current=setTimeout((function(){return se(e)}),H)},fe=function(e){null==e||e.preventDefault(),ue()},de=function(e){clearTimeout(ae.current),ae.current=setTimeout((function(){return ce(e)}),Q)},pe=function(){oe&&U&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},he=function(){oe&&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()};ay.useImperativeHandle(t,(function(){return{open:function(){se()},close:function(){ce()},toggle:function(){ue()}}}));var me,ye,ve=function(){if(!oe&&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=HW(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=w)&&(ye=!0),ay.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),ay.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 o=i[0],a=i[i.length-1];t.shiftKey&&document.activeElement===o?(t.preventDefault(),a.focus()):document.activeElement===a&&(t.preventDefault(),o.focus())}};return document.addEventListener("keydown",r),function(){t&&document.removeEventListener("keydown",r)}}}),[e,t])}(te,Z&&oe),function(e,t){void 0===t&&(t=!0),ay.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),ay.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 ay.createElement("div",Object.assign({},(e=oe?zW.popupContent.modal:zW.popupContent.tooltip,t={className:"popup-content "+(""!==R?R.split(" ").map((function(e){return e+"-content"})).join(" "):""),style:IW({},e,B,{pointerEvents:"auto"}),ref:te,onClick:function(e){e.stopPropagation()}},!O&&k.indexOf("hover")>=0&&(t.onMouseEnter=le,t.onMouseLeave=de),t),{key:"C",role:oe?"dialog":"tooltip",id:ie.current}),V&&!oe&&ay.createElement("div",{ref:re,style:zW.popupArrow},ay.createElement("svg",{"data-testid":"arrow",className:"popup-arrow "+(""!==R?R.split(" ").map((function(e){return e+"-arrow"})).join(" "):""),viewBox:"0 0 32 16",style:IW({position:"absolute"},A)},ay.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),Y&&"function"==typeof Y?Y(ce,Z):Y);var e,t},we=!(k.indexOf("hover")>=0),Ee=oe?zW.overlay.modal:zW.overlay.tooltip,ke=[we&&ay.createElement("div",{key:"O","data-testid":"overlay","data-popup":oe?"modal":"tooltip",className:"popup-overlay "+(""!==R?R.split(" ").map((function(e){return e+"-overlay"})).join(" "):""),style:IW({},Ee,_,{pointerEvents:y&&g||oe?"auto":"none"}),onClick:y&&g?ce:void 0,tabIndex:-1},oe&&Ce()),!oe&&Ce()];return ay.createElement(ay.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=fe;break;case"hover":e.onMouseEnter=le,e.onMouseLeave=de;break;case"focus":e.onFocus=le,e.onBlur=de}if("function"==typeof n){var o=n(Z);return!!n&&ay.cloneElement(o,e)}return!!n&&ay.cloneElement(n,e)}(),Z&&yD.createPortal(ke,(null===(be=document.getElementById("popup-root"))&&((be=document.createElement("div")).setAttribute("id","popup-root"),document.body.appendChild(be)),be)))}));function WW(){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 XW,YW=aC.Errors,$W=eC.div(_W||(_W=fm(["\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;"})),ZW=eC.video(xW||(xW=fm(["\n width: 100%;\n ","\n"])),(function(e){return e.flipHorizontal&&"\n transform: scaleX(-1);\n "})),JW=eC.div(RW||(RW=fm(["\n cursor: pointer;\n text-align: center;\n width: 50px;\n\n img {\n width: 100%;\n }\n"]))),eX=eC(JW)(PW||(PW=fm(["\n z-index: ",";\n position: absolute;\n top: 20px;\n right: 20px;\n width: 20px;\n"])),1100),tX=eC.div(NW||(NW=fm(["\n z-index: ",";\n position: absolute;\n top: 40px;\n color: red;\n"])),1020),rX=eC.div(LW||(LW=fm(["\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: ",";\n"])),1030),nX=eC.section(OW||(OW=fm(["\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"]))),iX=eC.header(DW||(DW=fm(["\n text-align: center;\n padding: 0.625rem 0;\n border-bottom: 1px solid #dddddd;\n"]))),oX=eC.h2(UW||(UW=fm(["\n margin: 0.25rem auto;\n padding: 0;\n font-weight: 600;\n font-size: 1.2rem;\n"]))),aX=eC.p(MW||(MW=fm(["\n padding: 0 0 0.3125rem;\n margin: 0.25rem auto;\n font-size: 0.8rem;\n"]))),sX=eC.ul(VW||(VW=fm(["\n list-style: none;\n padding: 0;\n"]))),cX=eC.li(jW||(jW=fm(["\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"]))),uX=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 lX(e){var t=e.checkCameraMode,r=e.frontCamera,n=e.onClose,i=e.children,o=e.onVideoPlayed,a=e.flipHorizontal,s=e.videoSettings,c=e.refVideo,u=e.onError,l=e.closeButton,f=e.videoClassName,d=lk.useSDKSettings().lang,p=zk.useSDKTracking().sendEvent,h=Hk.useAsset("ic_close.png"),g=dm(ay.useState(""),2),m=g[0],y=g[1],v=dm(ay.useState([]),2),b=v[0],C=v[1],w=dm(ay.useState(!1),2),E=w[0],k=w[1],S=ay.useRef(!1),B=ay.useRef(!1),T=ay.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=ay.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=CG.isMobile?CG.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,uX.getUserMedia({audio:!1,video:am(am({},t?{deviceId:t}:{facingMode:r?"user":"environment"}),s||n)});case 5:return(i=e.sent)||(y(YW.not_supported.msg[d]),u(YW.not_supported)),e.abrupt("return",i);case 10:e.prev=10,e.t0=e.catch(2),"NotAllowedError"===e.t0.name?(y(YW.no_permission.msg[d]),u(YW.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,d,u]),I=ay.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=bS.analyzeVideoAndWindowSizes(r),i=n.lostX,a=void 0===i?0:i,s=n.lostY,c=void 0===s?0:s,u=Math.min(e,Math.floor(e-2*a)),l=Math.min(t,Math.floor(t-2*c));o&&o({clientWidth:e,clientHeight:t,videoAreaWidth:u,videoAreaHeight:l,lostX:a,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,o]);ay.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,WW();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)}E&&!S.current&&(S.current=!0,function(){e.apply(this,arguments)}())}),[E]),ay.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,WW();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!uX||CG.browserName&&["facebook"].includes(CG.browserName.toLowerCase())||CG.getUA.includes("Zalo iOS")?(y(YW.not_supported.msg[d]),u(YW.not_supported)):t&&(CG.isAndroid&&!1===r?function(){e.apply(this,arguments)}():I()),function(){T()}}),[c,d,r,I,T,u]),ay.useEffect((function(){var e=setTimeout((function(){B.current||(y(YW.camera_timeout.msg[d]),u(YW.camera_timeout))}),3e5);return function(){clearTimeout(e)}}),[d,u]);var _=ay.useCallback((function(){T(),n&&n(),p({tag:"result",event:"user_activity.cancel",log:{}})}),[n,T,p]);return ay.createElement($W,{checkCameraMode:t},E&&null!=b&&b.length?ay.createElement(rX,null,ay.createElement(nX,null,ay.createElement(iX,null,ay.createElement(oX,null,"Không thể mở camera mặc định"),ay.createElement(aX,null,"Vui lòng thử chọn camera khác trong danh sách dưới đây")),ay.createElement(sX,null,b.map((function(e,t){return ay.createElement(cX,{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=YW.no_permission.msg[d];return m===e&&CG.isIOS?ay.createElement(tX,null,m," ",ay.createElement("button",{onClick:function(){window.location.reload()}},{vi:"Cấp lại quyền truy cập camera",en:"Request camera permission"}[d])):ay.createElement(tX,null,m)}(),ay.createElement(ZW,{ref:c,playsInline:!0,muted:!0,flipHorizontal:a,className:f}),i,l?ay.cloneElement(l,{onClick:_,"data-testid":"close-camera"}):ay.createElement(eX,{onClick:_,"data-testid":"close-camera"},ay.createElement("img",{src:h,alt:""})))}lX.propTypes={checkCameraMode:Ry.bool,frontCamera:Ry.bool,onClose:Ry.func,onError:Ry.func,onVideoPlayed:Ry.func,children:Ry.node,flipHorizontal:Ry.bool,videoSettings:Ry.object,refVideo:Ry.object,closeButton:Ry.node,videoClassName:Ry.string},lX.defaultProps={checkCameraMode:!1,frontCamera:!0,onClose:null,onError:function(){},onVideoPlayed:null,children:null,flipHorizontal:!1,videoSettings:null,refVideo:null,closeButton:null,videoClassName:""};var fX=rC(XW||(XW=fm(["\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"]))),dX=["open","children","overlayStyle"],pX=function(e){var t=e.open,r=e.children,n=e.overlayStyle,i=lm(e,dX);return ay.createElement(ay.Fragment,null,ay.createElement(QW,im({overlayStyle:am(am({},n),{},{zIndex:2e3}),closeOnDocumentClick:!1,closeOnEscape:!1,modal:!0,open:t},i),r),ay.createElement(fX,null))};pX.propTypes={open:Ry.bool,children:Ry.node,overlayStyle:Ry.shape({})},pX.defaultProps={open:!1,children:null,overlayStyle:{}};var hX,gX,mX,yX,vX,bX,CX,wX,EX,kX,SX,BX,TX,AX,IX,_X,xX,RX,PX,NX,LX,OX,DX={primaryColor:"#FDB913",errorBgColor:"#D32F2F",dangerColor:"#dedede",textColor:"#000000",errorColor:"#FF3B30",borderColor:"#dedede",titleSize:"1rem",titlelineHeight:"1.5rem",subTitleSize:"0.938rem",subTitleLineHeight:"1.25rem",fontBold:"600",fontNormal:"400"},UX=Gz.flipY,MX=Gz.spin,VX=Gz.splash,jX=(UX.animationDuration,VX.default),FX=eC.div(hX||(hX=fm(["\n ","\n ","\n"])),UX.default,MX.default),zX=(eC.img(gX||(gX=fm(["\n border-radius: 5px;\n opacity: 0.7;\n height: 38px;\n"]))),eC.div(mX||(mX=fm(["\n cursor: pointer;\n text-align: center;\n width: ","px;\n height: ","px;\n\n img {\n width: 100%;\n }\n\n z-index: ",";\n position: absolute;\n bottom: ","px;\n"])),60,60,1025,20)),KX=eC.div(yX||(yX=fm(["\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"])),100,100,1020),qX=eC.div(vX||(vX=fm(["\n color: #fff;\n text-align: center;\n"]))),HX=(eC.div(bX||(bX=fm(["\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),eC.div(CX||(CX=fm(["\n // display: flex;\n flex-direction: row;\n align-items: center;\n"])))),GX=eC(qX)(wX||(wX=fm(["\n font-size: ","px;\n z-index: ",";\n position: fixed;\n top: 16px;\n left: 0;\n right: 0;\n text-align: center;\n color: ",";\n padding: 0 3rem 0 2rem;\n"])),CG.isMobile?16:24,1020,DX.textColor),QX=eC(GX)(EX||(EX=fm(["\n font-size: ","px;\n color: ",";\n top: ",";\n padding: 0 1rem;\n"])),CG.isMobile?16:18,DX.textColor,(function(e){return e.y})),WX=eC(qX)(kX||(kX=fm(["\n font-size: 20px;\n margin-left: 10px;\n color: green;\n position: absolute;\n left: 0;\n top: 10px;\n background: white;\n z-index: ",";\n"])),1030),XX=eC(qX)(SX||(SX=fm(["\n position: absolute;\n font-size: 1rem;\n text-align: center;\n color: ",";\n top: ",";\n z-index: ",";\n"])),DX.textColor,(function(e){return e.y}),1020),YX=eC(XX)(BX||(BX=fm(["\n color: ",";\n padding: 5px 10px;\n border-radius: 3px;\n"])),DX.errorColor),$X=eC(qX)(TX||(TX=fm(["\n position: absolute;\n font-size: 1rem;\n text-align: center;\n border-radius: 3px;\n padding: 5px 10px;\n color: ",";\n margin: 0 10px;\n top: ",";\n z-index: ",";\n"])),DX.errorColor,(function(e){return e.y}),1020),ZX=(eC.div(AX||(AX=fm(["\n font-size: 1rem;\n text-align: center;\n padding: 10px;\n"]))),eC(pz)(IX||(IX=fm(["\n position: absolute;\n top: 0;\n left: 0;\n"])))),JX=eC.div(_X||(_X=fm(["\n cursor: pointer;\n text-align: center;\n width: 50px;\n\n img {\n width: 100%;\n }\n"]))),eY=eC(JX)(xX||(xX=fm(["\n z-index: ",";\n position: absolute;\n top: 10px;\n right: 1rem;\n width: 25px;\n"])),1100),tY={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 photo",vi:"Dùng ảnh này"},BTN_TRY_AGAIN:{en:"Retake",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"},IDCARD_TITLE:{en:"Take photos of National ID card",vi:"Chụp ảnh CCCD/CMND"},IDCARD_SUBTITLE:{en:"Make sure the card fits into the frame",vi:"Đảm bảo CCCD/CMND được đặt trong khung hình"},SELFIE_TITLE:{en:"Identity verification",vi:"Xác thực danh tính"}},rY=aC.IDCardMessage,nY=eC.div(RX||(RX=fm(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n padding: 10px;\n"]))),iY=eC.div(PX||(PX=fm(["\n text-align: center;\n font-size: 1rem;\n"]))),oY=eC.button(NX||(NX=fm(["\n margin-top: 20px;\n width: 100%;\n max-width: 160px;\n height: 50px;\n background-color: #eb6719;\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"]))),aY=function(e){var t=e.onOk,r=e.maxSessionTime,n=lk.useSDKSettings().lang;return ay.createElement(nY,null,ay.createElement(iY,{className:"popup-message"},TW(rY.TIMEOUT_INSTRUCTION[n])({x:r})),ay.createElement(oY,{className:"popup-button",onClick:t},tY.BTN_OK[n]))};aY.propTypes={onOk:Ry.func,maxSessionTime:Ry.number},aY.defaultProps={onOk:function(){},maxSessionTime:30};var sY,cY,uY,lY,fY,dY,pY,hY,gY,mY,yY=aC.IDCardMessage,vY=eC.div(LX||(LX=fm(["\n position: absolute;\n top: ",";\n z-index: ",";\n"])),(function(e){return e.y}),1020),bY=eC(GX)(OX||(OX=fm(["\n position: initial;\n text-align: center;\n color: ",";\n font-weight: 600;\n font-size: ","px;\n"])),DX.textColor,CG.isMobile?16:18),CY=ay.forwardRef((function(e,t){var r,n=e.title,i=e.usePortraitMask,o=e.windowAndVideoInfo,a=e.refVideo,s=e.frontSide,c=e.settings,u=e.onCaptureDone,l=e.onUISpacingChange,f=e.outputEncryptionSettings,d=dm(ay.useState({}),2),p=d[0],h=d[1],g=p.yDescription,m=p.yMessage,y=Hk.useAsset("ic_camera.svg"),v=Hk.useAsset("ic_camera_disabled.svg"),b=Hk.useAsset("ic_loading.png"),C=dm(ay.useState(""),2),w=C[0],E=C[1],k=lk.useSDKSettings(),S=k.debug,B=k.lang,T=dm(ay.useState(null),2),A=T[0],I=T[1],_=dm(ay.useState(""),2),x=_[0],R=_[1],P=dm(ay.useState(null),2),N=P[0],L=P[1],O=function(){var e=dm(ay.useState(!1),2),t=e[0],r=e[1],n=dm(ay.useState(null),2),i=n[0],o=n[1],a=dm(ay.useState({}),2),s=a[0],c=a[1];return{showPopup:ay.useCallback((function(e){var t=e.popupType,n=e.props;c(void 0===n?{}:n),o(t),r(null!==t)}),[]),popupShown:t,popupType:i,props:s}}(),D=O.showPopup,U=O.popupShown,M=O.popupType,V=CT.useThemeContext(),j=V.dangerColor,F=V.borderColor,z=ay.useCallback((function(e){R(null===e?"":TW(e.msg[B])({side:s?tY.FRONT[B]:tY.BACK[B]}))}),[B,s]),K=ay.useCallback((function(){I(""),D({popupType:AW})}),[D]),q=ay.useCallback((function(){I(""),u.apply(void 0,arguments)}),[u]),H=ay.useCallback((function(e){var t=e.curTimeLeft;I(TW(yY.REMAINING_TIME[B])({x:t}))}),[B]),G=XK({shouldStart:!0,refVideo:a,cropArea:N,settings:c,onModelErrorChange:z,frontSide:s,onDebugInfoChange:E,onSessionTimeout:K,onCaptureDone:q,onAboutToTimeout:H,outputEncryptionSettings:f}),Q=G.warmupDone,W=G.isProcessing,X=G.takePictureManually,Y=G.restartSession,$=G.resetIsProcessingImageBlobTaken,Z=ay.useCallback((function(){D({popupType:null}),$()}),[D,$]),J=ay.useCallback(Jg(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Z(),e.next=3,Y();case 3:case"end":return e.stop()}}),e)}))),[Y,Z]);ay.useEffect((function(){if(o){var e,t,r,n,a,s,c,u=o.videoAreaWidth,f=o.videoAreaHeight,d=o.lostX,p=o.lostY,g=o.clientHeight;i?(a=.7*(s=f-165),r=(c=(e=p+10)+45)-60,n=(t=c+s+10)+60):(a=CG.isMobile?u-32:Math.floor(.7*u),r=(c=(e=p+10)+50)-60,n=(t=c+(s=Math.floor(Math.min(a/1.5,g-2*p-100-100)))+10)+60);var m=Math.floor((u-a)/2)+d;L({x:Math.ceil(m+.5),y:Math.ceil(c+50),width:Math.ceil(a),height:Math.ceil(s),surroundStyle:{opacity:1,background:"#fff"}});var y={yTitle:e,yDescription:t+50,yMessage:r+50,yCaptureButton:n-50};h(y),l(y)}}),[o,i,l]);var ee=ay.useCallback(Jg(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return I(""),e.next=3,X();case 3:case"end":return e.stop()}}),e)}))),[X]);return ay.useImperativeHandle(t,(function(){return{restartSession:J}}),[J]),ay.createElement(ay.Fragment,null,!Q&&ay.createElement(gF,null),S&&ay.createElement(WX,null,w),W&&ay.createElement(KX,null,ay.createElement("img",{src:b,alt:"",className:"spin"})),N&&ay.createElement(wU,{x:"".concat(N.x,"px"),y:"".concat(N.y,"px"),width:"".concat(N.width,"px"),height:"".concat(N.height,"px"),surroundStyle:N.surroundStyle},ay.createElement(ZX,{strokeStyles:(r={},nm(r,dz.DEFAULT,{fill:"none",strokeWidth:2,stroke:F}),nm(r,dz.ERROR,{fill:"none",strokeWidth:2,stroke:j}),r),paddingStyle:{fill:"#fff"},strokeWidth:2,radius:10,errorColor:j,width:N.width,height:N.height,type:x?dz.ERROR:dz.DEFAULT})),x&&ay.createElement(YX,{y:"".concat(g+20,"px")},x),ay.createElement(QX,{className:"subtitle",y:"".concat(m+20,"px")},tY.IDCARD_SUBTITLE[B]),ay.createElement(zX,null,ay.createElement("img",{src:v,alt:""})),!W&&(!(null!=c&&c.disableCaptureButtonIfAlert)||!x)&&ay.createElement(zX,{onClick:ee},ay.createElement("img",{src:y,alt:""})),ay.createElement(vY,{y:"".concat(g,"px")},ay.createElement(bY,null,n)),A&&ay.createElement($X,{key:A,className:"message",y:"".concat(g+60,"px")},A),ay.createElement(pX,{open:U},M===AW&&ay.createElement(aY,{onOk:J,maxSessionTime:null==c?void 0:c.idCardSessionTime})))}));CY.propTypes={usePortraitMask:Ry.bool,title:Ry.string,windowAndVideoInfo:Ry.shape({}),refVideo:Ry.shape({}),frontSide:Ry.bool,settings:Ry.shape({}),onCaptureDone:Ry.func,onUISpacingChange:Ry.func,outputEncryptionSettings:Ry.shape({})},CY.defaultProps={usePortraitMask:!1,title:"",windowAndVideoInfo:{},refVideo:{},frontSide:!0,settings:{},onCaptureDone:function(){},onUISpacingChange:function(){},outputEncryptionSettings:null};var wY=eC.div(sY||(sY=fm(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n height: 100%;\n justify-content: normal;\n background: #fff;\n"]))),EY=eC.div(cY||(cY=fm(["\n text-align: center;\n font-size: 1rem;\n color: ",";\n margin-top: 10px;\n"])),DX.errorColor),kY=eC.button(uY||(uY=fm(["\n width: 100%;\n height: 44px;\n background-color: ",";\n border: 0;\n outline: none;\n border-radius: 9.375rem;\n color: ",";\n font-weight: 600;\n cursor: pointer;\n font-size: 17px;\n border: 1px solid #fff;\n border-color: ",";\n"])),(function(e){return e.bgColor}),(function(e){return e.color?e.color:"#fff"}),(function(e){return e.color?e.color:"#fff"})),SY=eC.img(lY||(lY=fm(["\n ",";\n border-radius: 10px;\n border: 2px solid rgb(222, 222, 222);\n margin-top: 10px;\n ",";\n"])),!CG.isMobile&&Vb(["height:","px;"],(function(e){return e.calHeight-300})),(function(e){return e.calHeight>0&&CG.isMobile&&Vb(["width:","px;height:","px;"],window.innerWidth-30,e.calHeight)})),BY=eC.div(fY||(fY=fm(["\n font-weight: 600;\n font-size: ","px;\n text-align: center;\n color: ",";\n padding: 8px 3rem 0 2rem;\n"])),CG.isMobile?16:24,DX.textColor),TY=eC.div(dY||(dY=fm(["\n font-size: ","px;\n color: ",";\n text-align: center;\n padding: 0 1rem;\n margin-top: 1.5rem;\n min-height: 30px;\n"])),CG.isMobile?16:18,DX.textColor),AY=eC.div(pY||(pY=fm(["\n margin-top: 1rem;\n font-size: ","px;\n font-weight: 600;\n"])),CG.isMobile?16:18),IY=eC.div(hY||(hY=fm(["\n width: 95%;\n display: flex;\n justify-content: space-evenly;\n flex-direction: column;\n position: absolute;\n bottom: 20px;\n left: 0;\n right: 0;\n margin: 0 auto;\n background: transparent;\n"]))),_Y=eC.div(gY||(gY=fm(["\n width: 100%;\n margin-top: 0.625rem;\n"]))),xY=eC.div(mY||(mY=fm(["\n width: 100%;\n"]))),RY=function(e){var t=e.title,r=e.imageTaken,n=e.onConfirm,i=e.onTryAgain,o=e.error,a=e.hasValidQR,s=dm(ay.useState(null),2),c=s[0],u=s[1],l=lk.useSDKSettings().lang,f=dm(ay.useState(0),2),d=f[0],p=f[1],h=ay.useRef(),g=Hk.useAsset("ic_close.svg"),m=Hk.useAsset("ic_close.svg");ay.useEffect((function(){var e;return r&&(e=URL.createObjectURL(r.blob),u(e)),function(){URL.revokeObjectURL(e)}}),[r]);return ay.createElement(wY,{className:"popup_detail"},null!==a&&ay.createElement(oq,{mb:"20px"},ay.createElement("div",null,ay.createElement(vH,{type:a?fH.SUCCESS:fH.WARNING},a?tY.CONFIRM_POPUP_VALID_QR[l]:tY.CONFIRM_POPUP_INVALID_QR[l]))),ay.createElement(HX,null,ay.createElement(BY,{className:"title"},tY.IDCARD_TITLE[l]),ay.createElement(TY,null,tY.IDCARD_SUBTITLE[l])),ay.createElement(SY,{ref:h,src:c,calHeight:d,onLoad:function(){if(CG.isMobile){var e=h.current,t=e.height/e.width,r=(window.innerWidth-30)*t;p(r)}}}),o&&ay.createElement(EY,{className:"confirm-popup-error-message"},o.msg[l]),ay.createElement(AY,null," ",t),ay.createElement(IY,null,ay.createElement(xY,null,ay.createElement(kY,{onClick:n,bgColor:"#000"},tY.BTN_USE_THIS_PICTURE[l])),ay.createElement(_Y,null,ay.createElement(kY,{onClick:i,bgColor:"#fff",color:"#000"},tY.BTN_TRY_AGAIN[l]))),ay.createElement(eY,{onClick:i},ay.createElement("img",{src:CG.isMobile?g:m,alt:""})))};RY.propTypes={imageTaken:Ry.shape({}),error:Ry.shape({msg:Ry.shape({})}),onConfirm:Ry.func,onTryAgain:Ry.func,hasValidQR:Ry.bool,title:Ry.string},RY.defaultProps={imageTaken:null,error:null,onConfirm:function(){},onTryAgain:function(){},hasValidQR:null,title:""};var PY,NY,LY,OY="CONFIRM",DY=rC(PY||(PY=fm(["\n .text-primary {\n color: ",";\n }\n\n .popup-content {\n width: 90%;\n margin: 0;\n textt-align: center;\n border: 0!important;\n }\n"])),(function(e){return e.theme.tsBlue})),UY=aC.IDCardSide,MY=aC.IDCardType,VY="id_card",jY="qr_code",FY=[{scannerType:VY,title:"Mặt trước",description:"Vui lòng chụp mặt trước CCCD/CMND",titleIcon:"id_card_front.svg",cardSide:aC.IDCardSide.FRONT,cardType:MY.VN,frontCamera:!1,enableConfirmPopup:!0,title_vi:"Mặt trước",title_en:"Front Face"},{scannerType:VY,title:"Mặt sau",description:"Vui lòng chụp mặt sau CCCD/CMND",titleIcon:"id_card_back.svg",cardSide:aC.IDCardSide.BACK,cardType:MY.VN,frontCamera:!1,enableConfirmPopup:!0,title_vi:"Mặt sau",title_en:"Rear Face"}],zY=eC.div(NY||(NY=fm(["\n cursor: pointer;\n text-align: center;\n img {\n width: 100%;\n }\n z-index: ",";\n position: absolute;\n top: 13px;\n right: 1rem;\n width: 25px;\n"])),1100),KY=eC(GX)(LY||(LY=fm(["\n padding: 0 3rem 0 2rem;\n font-size: ","px;\n font-weight: 600;\n"])),CG.isMobile?16:24);function qY(e){var t=e.onClose,r=e.onError,n=e.clientSettings,i=e.onStepDone,o=e.steps,a=e.outputEncryptionSettings,s=e.title,c=dm(ay.useState(0),2),u=c[0],l=c[1],f=dm(ay.useState(o[u]),2),d=f[0],p=f[1],h=ay.useRef(null),g=dm(ay.useState(null),2),m=g[0],y=g[1],v=dm(ay.useState(!1),2),b=v[0],C=v[1],w=dm(ay.useState(0),2),E=w[0],k=w[1],S=ay.useRef(),B=d.scannerType,T=d.frontCamera,A=d.cardSide,I=d.usePortraitMask,_=d.enableConfirmPopup,x=A===UY.FRONT,R=pK(),P=R.showPopup,N=R.popupShown,L=R.popupType,O=R.props,D=dm(ay.useState(!1),2),U=D[0],M=D[1],V=Hk.useAsset("ic_loading.png"),j=Hk.useAsset("ic_close.svg"),F=ay.useRef({}),z=ay.useRef(null),K=ay.useRef([]),q=FH({clientSettings:n}).settings,H=lk.useSDKSettings().lang,G=d["title_".concat(H)]||d.title,Q=s||tY.IDCARD_TITLE[H],W=ay.useCallback((function(e){y(e),C(!0)}),[]);ay.useEffect((function(){var e=document.querySelector("html").style.overflow,t=document.body.style.overflow;return document.querySelector("html").style.overflow="hidden",document.body.style.overflow="hidden",function(){document.querySelector("html").style.overflow=e,document.body.style.overflow=t}}),[]),ay.useEffect((function(){C(!1)}),[T]);var X=ay.useCallback((function(){P({popupType:null})}),[P]),Y=ay.useCallback((function(e){e>=o.length||setTimeout((function(){l(e),p(o[e])}),200)}),[o]),$=ay.useCallback((function(){Y(u+1)}),[Y,u]),Z=ay.useCallback(Jg(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={stepNumber:u,image:F.current,recordedVideos:null!=q&&q.enableRecording?K.current:[]},B===jY&&(t.qrScannedResult=z.current),M(!0),e.next=5,i(t);case 5:M(!1),$();case 7:case"end":return e.stop()}}),e)}))),[q,u,i,$,B]),J=ay.useCallback((function(){X(),B===jY?Y(u):B===VY&&S.current.restartSession()}),[Y,u,X,B]),ee=ay.useCallback((function(){X(),Z()}),[Z,X]),te=ay.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,F.current=r,K.current=i,k((function(e){return e+1})),_?P({popupType:OY,props:{imageTaken:F.current,error:n}}):Z();case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[_,P,Z]);return ay.createElement($b,{theme:DX},ay.createElement(FX,null,ay.createElement(gU,{key:T,frontCamera:T,onVideoPlayed:W,flipHorizontal:T,ref:h,onError:r,onClose:t,closeButton:ay.createElement(zY,null,ay.createElement("img",{src:j,alt:""}))},ay.createElement(HX,null,ay.createElement(KY,{className:"title"},Q)),b&&ay.createElement(ay.Fragment,null,B===VY&&ay.createElement(CY,{key:u,ref:S,windowAndVideoInfo:m,refVideo:h,settings:q,onCaptureDone:te,frontSide:x,title:G,usePortraitMask:I,outputEncryptionSettings:a})),ay.createElement(jX,{keyForTransition:E}),U&&ay.createElement(KX,null,ay.createElement("img",{src:V,alt:"",className:"spin"}))),ay.createElement(Yj,{open:N,overlayStyle:{padding:0},contentStyle:{maxWidth:"none",width:"100%",height:"100%",borderRadius:0}},L===OY&&ay.createElement(RY,im({},O,{onConfirm:ee,onTryAgain:J,title:G})))),ay.createElement(DY,null))}qY.propTypes={onClose:Ry.func,onError:Ry.func,clientSettings:Ry.shape({}),detectIdCard:Ry.func,onStepDone:Ry.func,steps:Ry.arrayOf(Ry.shape({})),outputEncryptionSettings:Ry.shape({}),title:Ry.string},qY.defaultProps={onClose:function(){},onError:function(){},clientSettings:{},detectIdCard:function(){return Promise.resolve({card_label:""})},onStepDone:function(){},steps:FY,outputEncryptionSettings:null,title:""};var HY,GY,QY,WY,XY,YY,$Y,ZY,JY,e$=function(e,t,r,n,i,o,a,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,o,a,s],l=0;(c=new Error(t.replace(/%s/g,(function(){return u[l++]})))).name="Invariant Violation"}throw c.framesToPop=1,c}},t$=i(o((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,o=n.Hasher,a=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 o(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function a(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,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(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(a,s)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,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}(),f=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}(),d=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 w(e,t){return e(t={exports:{}},t.exports),t.exports}var E=w((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 o=t.join("/"),a=(o=o.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return a.shift()+(a.length>0?"?":"")+a.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 o=/\+/g;e=e.split(t);var a=1e3;n&&"number"==typeof n.maxKeys&&(a=n.maxKeys);var s=e.length;a>0&&s>a&&(s=a);for(var c=0;c<s;++c){var u,l,f,d,p=e[c].replace(o,"%20"),h=p.indexOf(r);h>=0?(u=p.substr(0,h),l=p.substr(h+1)):(u=p,l=""),f=decodeURIComponent(u),d=decodeURIComponent(l),k(i,f)?Array.isArray(i[f])?i[f].push(d):i[f]=[i[f],d]:i[f]=d}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=w((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)),o=this.resolveUrl(e);return this.request(o,{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,o,a,s;return c(this,(function(c){switch(c.label){case 0:return n={},o={},this.authorizer&&(n=this.authorizer.getHeaders(t)),this.configHeaders&&(o=this.configHeaders),t.headers=i(i(i({},t.headers),n),o),[4,fetch(e,t)];case 1:return a=c.sent(),[4,"blob"===r?a.blob():a.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 E(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}(),R=w((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={},o=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)}},a=i.WordArray=o.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 o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>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=o.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)}},o=0;o<t;o+=4){var s=i(4294967296*(r||e.random()));r=987654071*s(),n.push(4294967296*s()|0)}return new a.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 o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).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 a.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 o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}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 a.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)))}},f=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new a.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,o=this.blockSize,s=i/(4*o),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*o,u=e.min(4*c,i);if(c){for(var l=0;l<c;l+=o)this._doProcessBlock(n,l);var f=n.splice(0,c);r.sigBytes-=u}return new a.init(f,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),d=(i.Hasher=f.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.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 d.HMAC.init(e,r).finalize(t)}}}),n.algo={});return n}(Math)})),P=w((function(e,t){var r,n,i;e.exports=(n=(r=i=R).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>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 o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(t=s)}return function(e,t,r){for(var i=[],o=0,a=0;a<t;a++)if(a%4){var s=r[e.charCodeAt(a-1)]<<a%4*2,c=r[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=(s|c)<<24-o%4*8,o++}return n.create(i,o)}(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)})),N=(w((function(e,t){var r;e.exports=(r=R,function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=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=a.SHA256=o.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],o=r[2],a=r[3],s=r[4],l=r[5],f=r[6],d=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&o^i&o,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),C=d+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&l^~s&f)+c[p]+u[p];d=f,f=l,l=s,s=a+C|0,a=o,o=i,i=n,n=C+(b+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+s|0,r[5]=r[5]+l|0,r[6]=r[6]+f|0,r[7]=r[7]+d|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=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=o._createHelper(l),t.HmacSHA256=o._createHmacHelper(l)}(Math),r.SHA256)})),w((function(e,t){var r,n,i;e.exports=(n=(r=R).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 o=this._oKey=t.clone(),a=this._iKey=t.clone(),s=o.words,c=a.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=a.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))}})))})),w((function(e,t){e.exports=R.HmacSHA256}))),L=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=P.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 O(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,o=new L(e,t),a=O(r);return new _({authorizer:o,domain:a,headers:i})}var U=function(){function e(e){void 0===e&&(e="production");var t=new _({domain:O(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 o=n.value,a=i({},n);return a.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,a,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 o=arguments[t],a=0,s=o.length;a<s;a++,i++)n[i]=o[a];return n}(e),(a=i({},n[t]))["X-TV-Transaction"]=r,n[t]=a,[4,o.apply(this,n)];case 2:return s=c.sent(),[4,this.transactionManager.end()];case 3:return c.sent(),[2,s];case 4:return[4,o.apply(this,e)];case 5:return[2,c.sent()]}}))}))},a}}function V(e){return void 0===e&&(e={encryptedField:"data"}),function(t,r,n){var o=n.value,a=i({},n);return a.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,o.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]}}))}))},a}}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(),o=setInterval((function(){e===r.currentTransaction&&(clearInterval(o),t(!0)),window.performance.now()-i>=3e3&&(clearInterval(o),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,o=t.length,a=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%o,u=u/o|0;for(;u>0;)s.push(u%o),u=u/o|0}for(i=0;0===e[i]&&i<e.length-1;++i)n+=a;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),o=[0];for(r=0;r<e.length();++r){for(var a=0,s=e.at(r);a<o.length;++a)s+=o[a]<<8,o[a]=s%n,s=s/n|0;for(;s>0;)o.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=o.length-1;r>=0;--r)c+=t[o[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,o=t.charAt(0),a=[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<a.length;++c)u+=a[c]*i,a[c]=255&u,u>>=8;for(;u>0;)a.push(255&u),u>>=8}for(var l=0;e[l]===o&&l<e.length-1;++l)a.push(0);return"undefined"!=typeof Buffer?Buffer.from(a.reverse()):new Uint8Array(a.reverse())},w((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,o=document.createElement("div");r=[],new MutationObserver((function(){var e=r.slice();r.length=0,e.forEach((function(e){e()}))})).observe(o,{attributes:!0});var a=t.setImmediate;t.setImmediate=function(e){Date.now()-n>15?(n=Date.now(),a(e)):(r.push(e),1===r.length&&o.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 o;if("hex"===r)return this.accommodate(Math.ceil(e.length/2)),o=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.hex.decode(e,o,this.write),this;if("base64"===r)return this.accommodate(3*Math.ceil(e.length/4)),o=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.base64.decode(e,o,this.write),this;if("utf8"===r&&(e=t.encodeUtf8(e),r="binary"),"binary"===r||"raw"===r)return this.accommodate(e.length),o=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.raw.decode(o),this;if("utf16"===r)return this.accommodate(2*e.length),o=new Uint16Array(this.data.buffer,this.write),this.write+=t.text.utf16.encode(o),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="",o="",a=0,s=0;r>0;--r,++a)i=e.charCodeAt(a)^t.charCodeAt(a),s>=10&&(n+=o,o="",s=0),o+=String.fromCharCode(i),++s;return n+o},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+/=",o=[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],a="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";t.encode64=function(e,t){for(var r,n,o,a="",s="",c=0;c<e.length;)r=e.charCodeAt(c++),n=e.charCodeAt(c++),o=e.charCodeAt(c++),a+=i.charAt(r>>2),a+=i.charAt((3&r)<<4|n>>4),isNaN(n)?a+="==":(a+=i.charAt((15&n)<<2|o>>6),a+=isNaN(o)?"=":i.charAt(63&o)),t&&a.length>t&&(s+=a.substr(0,t)+"\r\n",a=a.substr(t));return s+a},t.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,a="",s=0;s<e.length;)t=o[e.charCodeAt(s++)-43],r=o[e.charCodeAt(s++)-43],n=o[e.charCodeAt(s++)-43],i=o[e.charCodeAt(s++)-43],a+=String.fromCharCode(t<<2|r>>4),64!==n&&(a+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(a+=String.fromCharCode((3&n)<<6|i)));return a},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,o=0;o<e.length;++o)n[i++]=e.charCodeAt(o);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,o=r=r||0;for(1&e.length&&(i=1,n[o++]=parseInt(e[0],16));i<e.length;i+=2)n[o++]=parseInt(e.substr(i,2),16);return t?o-r:n},t.binary.base64.encode=function(e,t){for(var r,n,o,a="",s="",c=0;c<e.byteLength;)r=e[c++],n=e[c++],o=e[c++],a+=i.charAt(r>>2),a+=i.charAt((3&r)<<4|n>>4),isNaN(n)?a+="==":(a+=i.charAt((15&n)<<2|o>>6),a+=isNaN(o)?"=":i.charAt(63&o)),t&&a.length>t&&(s+=a.substr(0,t)+"\r\n",a=a.substr(t));return s+a},t.binary.base64.decode=function(e,t,r){var n,i,a,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=o[e.charCodeAt(u++)-43],i=o[e.charCodeAt(u++)-43],a=o[e.charCodeAt(u++)-43],s=o[e.charCodeAt(u++)-43],c[l++]=n<<2|i>>4,64!==a&&(c[l++]=(15&i)<<4|a>>2,64!==s&&(c[l++]=(3&a)<<6|s));return t?l-r:c.subarray(0,l)},t.binary.base58.encode=function(e,r){return t.binary.baseN.encode(e,a,r)},t.binary.base58.decode=function(e,r){return t.binary.baseN.decode(e,a,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 o=n=n||0,a=0;a<e.length;++a)i[o++]=e.charCodeAt(a);return r?o-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),o=r=r||0,a=r,s=0;s<e.length;++s)i[a++]=e.charCodeAt(s),o+=2;return t?o-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 o=new Error(i.error.message);throw o.id=i.error.id,o.name=i.error.name,o}},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},f=function(e,t,r){var n=c(e,t);if(null!==n&&r in n){delete n[r];var i=!0;for(var o in n){i=!1;break}i&&(n=null),s(e,t,n)}},d=function(e,t){s(e,t,null)},p=function(e,t,r){var n,i=null;void 0===r&&(r=["web","flash"]);var o=!1,a=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),o="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,i=e.apply(this,t),o=!0)}catch(e){a=e}if(o)break}if(!o)throw a;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(f,arguments,n)},t.clearItems=function(e,t,r){p(d,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,o,a=r[n].indexOf("=");a>0?(i=r[n].substring(0,a),o=r[n].substring(a+1)):(i=r[n],o=null),i in t||(t[i]=[]),i in Object.prototype||null===o||t[i].push(unescape(o))}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 o=r.split("/");return o.length>0&&""===o[0]&&o.shift(),{pathString:r,queryString:n,path:o,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 o=t[n++];if(n==i)e[o]=r;else{var a=o in e;(!a||a&&"object"!=typeof e[o]||a&&null===e[o])&&(e[o]={}),e=e[o]}}},t.getPath=function(e,t,r){for(var n=0,i=t.length,o=!0;o&&n<i&&"object"==typeof e&&null!==e;){var a=t[n++];(o=a in e)&&(e=e[a])}return o?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,o=[],a=0;t=n.exec(e);){(r=e.substring(a,n.lastIndex-2)).length>0&&o.push(r),a=n.lastIndex;var s=t[0][1];switch(s){case"s":case"o":i<arguments.length?o.push(arguments[1+i++]):o.push("<?>");break;case"%":o.push("%");break;default:o.push("<%"+s+"?>")}}return o.push(e.substring(a)),o.join("")},t.formatNumber=function(e,t,r,n){var i=e,o=isNaN(t=Math.abs(t))?2:t,a=void 0===r?",":r,s=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(o),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)+(o?a+Math.abs(i-u).toFixed(o).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(),o=0;o<8;++o)if(e[o]&&0!==e[o].length){var a=t.hexToBytes(e[o]);a.length<2&&i.putByte(0),i.putBytes(a)}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,o=0;o<e.length;o+=2){for(var a=t.bytesToHex(e[o]+e[o+1]);"0"===a[0]&&"0"!==a;)a=a.substr(1);if("0"===a){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(a)}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,o,a){if(0===o){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=[],o=0;o<e;++o){var a=new Worker(n);a.addEventListener("message",(function(n){if(i.push(n.data),i.length===e){for(var o=0;o<e;++o)r[o].terminate();t(null,i)}})),r.push(a)}for(o=0;o<e;++o)r[o].postMessage(o)}(a,(function(t,r){i.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var i=t[n],o=r[n]=[],a=0;a<e;++a)if(n!==a){var s=t[a];(i.st>s.st&&i.st<s.et||s.st>i.st&&s.st<i.et)&&o.push(a)}return r.reduce((function(e,t){return Math.max(e,t.length)}),0)}(a,r)),e(i,o-1,a)}))}([],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)))},w((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=[],o=t/4;for(n=0;n<o;++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 o=(this.blockSize-n)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(o>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),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!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 o=(this.blockSize-n)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(o>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),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!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 o=(this.blockSize-n)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o>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),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!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 o=0;o<this._ints;++o)t.putInt32(e.getInt32()^this._outBlock[o]);else{var a=(this.blockSize-i)%this.blockSize;for(a>0&&(a=this.blockSize-a),this._partialOutput.clear(),o=0;o<this._ints;++o)this._partialOutput.putInt32(e.getInt32()^this._outBlock[o]);if(a>0&&(e.read-=this.blockSize),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(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 o=r.length();if(12===o)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*o)))}this._inBlock=this._j0.slice(0),n(this._inBlock),this._partialBytes=0,t=F.util.createBuffer(t),this._aDataLength=i(8*t.length());var a=t.length()%this.blockSize;for(a&&t.fillWithByte(0,this.blockSize-a),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 o=0;o<this._ints;++o)t.putInt32(this._outBlock[o]^=e.getInt32());this._cipherLength+=this.blockSize}else{var a=(this.blockSize-i)%this.blockSize;for(a>0&&(a=this.blockSize-a),this._partialOutput.clear(),o=0;o<this._ints;++o)this._partialOutput.putInt32(e.getInt32()^this._outBlock[o]);if(a<=0||r){if(r){var s=i%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(o=0;o<this._ints;++o)this._outBlock[o]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!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 o=0;o<this._ints;++o)t.putInt32(this._outBlock[o]^this._hashBlock[o]);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 o=[];this.cipher.encrypt(this._j0,o);for(var a=0;a<this._ints;++a)this.tag.putInt32(this._s[a]^o[a]);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,o=new Array(i),a=0;a<i;++a){var s=[0,0,0,0],c=(n-1-a%n)*t;s[a/n|0]=1<<t-1<<c,o[a]=this.generateSubHashTable(this.multiply(s,e),t)}return o},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 o=n>>>1;o>0;)this.pow(i[2*o],i[o]=[]),o>>=1;for(o=2;o<n;){for(var a=1;a<o;++a){var s=i[o],c=i[a];i[o+a]=[s[0]^c[0],s[1]^c[1],s[2]^c[2],s[3]^c[3]]}o*=2}for(i[0]=[0,0,0,0],o=n+1;o<r;++o){var u=i[o^n];i[o]=[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 o=this.mode.name,a=-1!==["CFB","OFB","CTR","GCM"].indexOf(o);this._w=te(r,e.decrypt&&!a),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,o,a,s,c,u=0,l=0;for(t=0;t<256;++t){o=(o=l^l<<1^l<<2^l<<3^l<<4)>>8^255&o^99,Q[u]=o,W[o]=u,s=(a=e[o])<<24^o<<16^o<<8^o^a,c=((r=e[u])^(n=e[r])^(i=e[n]))<<24^(u^i)<<16^(u^n^i)<<8^u^r^i;for(var f=0;f<4;++f)Y[f][u]=s,$[f][o]=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,o=n.length,a=J*(o+6+1),s=o;s<a;++s)r=n[s-1],s%o==0?(r=Q[r>>>16&255]<<24^Q[r>>>8&255]<<16^Q[255&r]<<8^Q[r>>>24]^X[i]<<24,i++):o>6&&s%o==4&&(r=Q[r>>>24]<<24^Q[r>>>16&255]<<16^Q[r>>>8&255]<<8^Q[255&r]),n[s]=n[s-o]^r;if(t){for(var c,u=$[0],l=$[1],f=$[2],d=$[3],p=n.slice(0),h=(s=0,(a=n.length)-J);s<a;s+=J,h-=J)if(0===s||s===a-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]]^f[Q[c>>>8&255]]^d[Q[255&c]];n=p}return n}function re(e,t,r,n){var i,o,a,s,c,u,l,f,d,p,h,g,m=e.length/4-1;n?(i=$[0],o=$[1],a=$[2],s=$[3],c=W):(i=Y[0],o=Y[1],a=Y[2],s=Y[3],c=Q),u=t[0]^e[0],l=t[n?3:1]^e[1],f=t[2]^e[2],d=t[n?1:3]^e[3];for(var y=3,v=1;v<m;++v)p=i[u>>>24]^o[l>>>16&255]^a[f>>>8&255]^s[255&d]^e[++y],h=i[l>>>24]^o[f>>>16&255]^a[d>>>8&255]^s[255&u]^e[++y],g=i[f>>>24]^o[d>>>16&255]^a[u>>>8&255]^s[255&l]^e[++y],d=i[d>>>24]^o[u>>>16&255]^a[l>>>8&255]^s[255&f]^e[++y],u=p,l=h,f=g;r[0]=c[u>>>24]<<24^c[l>>>16&255]<<16^c[f>>>8&255]<<8^c[255&d]^e[++y],r[n?3:1]=c[l>>>24]<<24^c[f>>>16&255]<<16^c[d>>>8&255]<<8^c[255&u]^e[++y],r[2]=c[f>>>24]<<24^c[d>>>16&255]<<16^c[u>>>8&255]<<8^c[255&l]^e[++y],r[n?1:3]=c[d>>>24]<<24^c[u>>>16&255]<<16^c[l>>>8&255]<<8^c[255&f]^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)}))}w((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")})),w((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,o){if(F.util.isArray(i)){for(var a=[],s=0;s<i.length;++s)void 0!==i[s]&&a.push(i[s]);i=a}var c={tagClass:e,type:r,constructed:n,composed:n||F.util.isArray(i),value:i};return o&&"bitStringContents"in o&&(c.bitStringContents=o.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 o=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&&(o=o&&e.bitStringContents===r.bitStringContents),o},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 o=127&n;r(e,t,o),i=e.getInt(o<<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,o,a,s){var c;r(i,o,2);var u=i.getByte();o--;var l=192&u,f=31&u;c=i.length();var d,p,h=n(i,o);if(o-=c-i.length(),void 0!==h&&h>o){if(s.strict){var g=new Error("Too few bytes to read ASN.1 value.");throw g.available=i.length(),g.remaining=o,g.requested=h,g}h=o}var m=32==(32&u);if(m)if(d=[],void 0===h)for(;;){if(r(i,o,2),i.bytes(2)===String.fromCharCode(0,0)){i.getBytes(2),o-=2;break}c=i.length(),d.push(e(i,o,a+1,s)),o-=c-i.length()}else for(;h>0;)c=i.length(),d.push(e(i,h,a+1,s)),o-=c-i.length(),h-=c-i.length();if(void 0===d&&l===t.Class.UNIVERSAL&&f===t.Type.BITSTRING&&(p=i.bytes(h)),void 0===d&&s.decodeBitStrings&&l===t.Class.UNIVERSAL&&f===t.Type.BITSTRING&&h>1){var y=i.read,v=o,b=0;if(f===t.Type.BITSTRING&&(r(i,o,1),b=i.getByte(),o--),0===b)try{c=i.length();var C=e(i,o,a+1,{verbose:s.verbose,strict:!0,decodeBitStrings:!0}),w=c-i.length();o-=w,f==t.Type.BITSTRING&&w++;var E=C.tagClass;w!==h||E!==t.Class.UNIVERSAL&&E!==t.Class.CONTEXT_SPECIFIC||(d=[C])}catch(e){}void 0===d&&(i.read=y,o=v)}if(void 0===d){if(void 0===h){if(s.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");h=o}if(f===t.Type.BMPSTRING)for(d="";h>0;h-=2)r(i,o,2),d+=String.fromCharCode(i.getInt16()),o-=2;else d=i.getBytes(h)}var k=void 0===p?null:{bitStringContents:p};return t.create(l,f,m,d,k)}(e,e.length(),0,i)},t.toDer=function(e){var r=F.util.createBuffer(),n=e.tagClass|e.type,i=F.util.createBuffer(),o=!1;if("bitStringContents"in e&&(o=!0,e.original&&(o=t.equals(e,e.original))),o)i.putBytes(e.bitStringContents);else if(e.composed){e.constructed?n|=32:i.putByte(0);for(var a=0;a<e.value.length;++a)void 0!==e.value[a]&&i.putBuffer(t.toDer(e.value[a]))}else if(e.type===t.Type.BMPSTRING)for(a=0;a<e.value.length;++a)i.putInt16(e.value.charCodeAt(a));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),a=c.length-1;a>=0;--a)r.putByte(c.charCodeAt(a))}return r.putBuffer(i),r},t.oidToDer=function(e){var t,r,n,i,o=e.split("."),a=F.util.createBuffer();a.putByte(40*parseInt(o[0],10)+parseInt(o[1],10));for(var s=2;s<o.length;++s){t=!0,r=[],n=parseInt(o[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)a.putByte(r[c])}return a},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),o=parseInt(e.substr(6,2),10),a=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(o,a,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),o=parseInt(e.substr(8,2),10),a=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 f=e.length-5,d=e.charAt(f);return"+"!==d&&"-"!==d||(u=60*parseInt(e.substr(f+1,2),10)+parseInt(e.substr(f+4,2),10),u*=6e4,"+"===d&&(u*=-1),l=!0),"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(o,a,s,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(o,a,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 o=!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(o=!0,r.value&&F.util.isArray(r.value))for(var a=0,s=0;o&&s<r.value.length;++s)o=r.value[s].optional||!1,e.value[a]&&((o=t.validate(e.value[a],r.value[s],n,i))?++a:r.value[s].optional&&(o=!0)),!o&&i&&i.push("["+r.name+'] Tag class "'+r.tagClass+'", type "'+r.type+'" expected value length "'+r.value.length+'", got "'+e.value.length+'"');if(o&&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 o};var i=/[^\\u0000-\\u00ff]/;t.prettyPrint=function(e,r,n){var o="";n=n||2,(r=r||0)>0&&(o+="\n");for(var a="",s=0;s<r*n;++s)a+=" ";switch(o+=a+"Tag: ",e.tagClass){case t.Class.UNIVERSAL:o+="Universal:";break;case t.Class.APPLICATION:o+="Application:";break;case t.Class.CONTEXT_SPECIFIC:o+="Context-Specific:";break;case t.Class.PRIVATE:o+="Private:"}if(e.tagClass===t.Class.UNIVERSAL)switch(o+=e.type,e.type){case t.Type.NONE:o+=" (None)";break;case t.Type.BOOLEAN:o+=" (Boolean)";break;case t.Type.INTEGER:o+=" (Integer)";break;case t.Type.BITSTRING:o+=" (Bit string)";break;case t.Type.OCTETSTRING:o+=" (Octet string)";break;case t.Type.NULL:o+=" (Null)";break;case t.Type.OID:o+=" (Object Identifier)";break;case t.Type.ODESC:o+=" (Object Descriptor)";break;case t.Type.EXTERNAL:o+=" (External or Instance of)";break;case t.Type.REAL:o+=" (Real)";break;case t.Type.ENUMERATED:o+=" (Enumerated)";break;case t.Type.EMBEDDED:o+=" (Embedded PDV)";break;case t.Type.UTF8:o+=" (UTF8)";break;case t.Type.ROID:o+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:o+=" (Sequence)";break;case t.Type.SET:o+=" (Set)";break;case t.Type.PRINTABLESTRING:o+=" (Printable String)";break;case t.Type.IA5String:o+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:o+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:o+=" (Generalized time)";break;case t.Type.BMPSTRING:o+=" (BMP String)"}else o+=e.type;if(o+="\n",o+=a+"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+=","));o+=a+"Sub values: "+c+u}else{if(o+=a+"Value: ",e.type===t.Type.OID){var l=t.derToOid(e.value);o+=l,F.pki&&F.pki.oids&&l in F.pki.oids&&(o+=" ("+F.pki.oids[l]+") ")}if(e.type===t.Type.INTEGER)try{o+=t.derToInteger(e.value)}catch(t){o+="0x"+F.util.bytesToHex(e.value)}else if(e.type===t.Type.BITSTRING){if(e.value.length>1?o+="0x"+F.util.bytesToHex(e.value.slice(1)):o+="(none)",e.value.length>0){var f=e.value.charCodeAt(0);1==f?o+=" (1 unused bit shown)":f>1&&(o+=" ("+f+" unused bits shown)")}}else e.type===t.Type.OCTETSTRING?(i.test(e.value)||(o+="("+e.value+") "),o+="0x"+F.util.bytesToHex(e.value)):e.type===t.Type.UTF8?o+=F.util.decodeUtf8(e.value):e.type===t.Type.PRINTABLESTRING||e.type===t.Type.IA5String?o+=e.value:i.test(e.value)?o+="0x"+F.util.bytesToHex(e.value):0===e.value.length?o+="[null]":o+=e.value}return o}})),F.md=F.md||{},F.md.algorithms=F.md.algorithms||{},w((function(e){(e.exports=F.hmac=F.hmac||{}).create=function(){var e=null,t=null,r=null,n=null,i={start:function(i,o){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===o)o=e;else{if("string"==typeof o)o=F.util.createBuffer(o);else if(F.util.isArray(o)){var a=o;o=F.util.createBuffer();for(var s=0;s<a.length;++s)o.putByte(a[s])}var c=o.length();for(c>t.blockLength&&(t.start(),t.update(o.bytes()),o=t.digest()),r=F.util.createBuffer(),n=F.util.createBuffer(),c=o.length(),s=0;s<c;++s)a=o.at(s),r.putByte(54^a),n.putByte(92^a);if(c<t.blockLength)for(a=t.blockLength-c,s=0;s<a;++s)r.putByte(54),n.putByte(92);e=o,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}})),w((function(e){var t=e.exports=F.md5=F.md5||{};F.md.md5=F.md.algorithms.md5=t,t.create=function(){a||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],o=new Array(64);for(var e=0;e<64;++e)o[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));a=!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 o=u.fullMessageLength.length-1;o>=0;--o)u.fullMessageLength[o]+=i[1],i[1]=i[0]+(u.fullMessageLength[o]/4294967296>>>0),u.fullMessageLength[o]=u.fullMessageLength[o]>>>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 o,a=0,l=u.fullMessageLength.length-1;l>=0;--l)a=(o=8*u.fullMessageLength[l]+a)/4294967296>>>0,n.putInt32Le(o>>>0);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};s(f,c,n);var d=F.util.createBuffer();return d.putInt32Le(f.h0),d.putInt32Le(f.h1),d.putInt32Le(f.h2),d.putInt32Le(f.h3),d},u};var r=null,n=null,i=null,o=null,a=!1;function s(e,t,r){for(var a,s,c,u,l,f,d,p=r.length();p>=64;){for(s=e.h0,c=e.h1,u=e.h2,l=e.h3,d=0;d<16;++d)t[d]=r.getInt32Le(),a=s+(l^c&(u^l))+o[d]+t[d],s=l,l=u,u=c,c+=a<<(f=i[d])|a>>>32-f;for(;d<32;++d)a=s+(u^l&(c^u))+o[d]+t[n[d]],s=l,l=u,u=c,c+=a<<(f=i[d])|a>>>32-f;for(;d<48;++d)a=s+(c^u^l)+o[d]+t[n[d]],s=l,l=u,u=c,c+=a<<(f=i[d])|a>>>32-f;for(;d<64;++d)a=s+(u^(c|~l))+o[d]+t[n[d]],s=l,l=u,u=c,c+=a<<(f=i[d])|a>>>32-f;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}}})),w((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 o=0,a=-1;for(i=0;i<t.length;++i,++o)if(o>65&&-1!==a){var s=t[a];","===s?(++a,t=t.substr(0,a)+"\r\n "+t.substr(a)):t=t.substr(0,a)+"\r\n"+s+t.substr(a+1),o=i-a-1,a=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(a=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 o=0;o<e.headers.length;++o)i+=r(e.headers[o]);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,o=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,a=/\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(a),u=0;t&&u<c.length;){for(var l=c[u].replace(/\s+$/,""),f=u+1;f<c.length;++f){var d=c[f];if(!/\s/.test(d[0]))break;l+=d,u=f}if(t=l.match(o)){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],o=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],a=[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],f=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[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 w=e.getInt32(),E=e.getInt32();w^=(t=252645135&(w>>>4^E))<<4,w^=t=65535&((E^=t)>>>-16^w),w^=(t=858993459&(w>>>2^(E^=t<<-16)))<<2,w^=t=65535&((E^=t)>>>-16^w),w^=(t=1431655765&(w>>>1^(E^=t<<-16)))<<1,w^=t=16711935&((E^=t)>>>8^w),t=(w^=(t=1431655765&(w>>>1^(E^=t<<8)))<<1)<<8|(E^=t)>>>20&240,w=E<<24|E<<8&16711680|E>>>8&65280|E>>>24&240,E=t;for(var k=0;k<v.length;++k){v[k]?(w=w<<2|w>>>26,E=E<<2|E>>>26):(w=w<<1|w>>>27,E=E<<1|E>>>27);var S=r[(w&=-15)>>>28]|n[w>>>24&15]|i[w>>>20&15]|o[w>>>16&15]|a[w>>>12&15]|s[w>>>8&15]|c[w>>>4&15],B=u[(E&=-15)>>>28]|l[E>>>24&15]|f[E>>>20&15]|d[E>>>16&15]|p[E>>>12&15]|h[E>>>8&15]|g[E>>>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 oe=[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],ae=[-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],fe=[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],de=[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,o,a=32===e.length?3:9;i=3===a?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^=(o=252645135&(s>>>4^c))<<4,s^=(o=65535&(s>>>16^(c^=o)))<<16,s^=o=858993459&((c^=o)>>>2^s),s^=o=16711935&((c^=o<<2)>>>8^s),s=(s^=(o=1431655765&(s>>>1^(c^=o<<8)))<<1)<<1|s>>>31,c=(c^=o)<<1|c>>>31;for(var u=0;u<a;u+=3){for(var l=i[u+1],f=i[u+2],d=i[u];d!=l;d+=f){var p=c^e[d],h=(c>>>4|c<<28)^e[d+1];o=s,s=c,c=o^(ae[p>>>24&63]|ce[p>>>16&63]|le[p>>>8&63]|de[63&p]|oe[h>>>24&63]|se[h>>>16&63]|ue[h>>>8&63]|fe[63&h])}o=s,s=c,c=o}c=c>>>1|c<<31,c^=o=1431655765&((s=s>>>1|s<<31)>>>1^c),c^=(o=16711935&(c>>>8^(s^=o<<1)))<<8,c^=(o=858993459&(c>>>2^(s^=o)))<<2,c^=o=65535&((s^=o)>>>16^c),c^=o=252645135&((s^=o<<16)>>>4^c),s^=o<<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,o){if("function"==typeof i&&(o=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"),o?4===ge.pbkdf2Sync.length?ge.pbkdf2(e,t,r,n,(function(e,t){if(e)return o(e);o(null,t.toString("binary"))})):ge.pbkdf2(e,t,r,n,i,(function(e,t){if(e)return o(e);o(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 a=i.digestLength;if(n>4294967295*a){var s=new Error("Derived key is too long.");if(o)return o(s);throw s}var c=Math.ceil(n/a),u=n-(c-1)*a,l=F.hmac.create();l.start(i,e);var f,d,p,h="";if(!o){for(var g=1;g<=c;++g){l.start(null,null),l.update(t),l.update(F.util.int32ToBytes(g)),f=p=l.digest().getBytes();for(var m=2;m<=r;++m)l.start(null,null),l.update(p),d=l.digest().getBytes(),f=F.util.xorBytes(f,d,a),p=d;h+=g<c?f:f.substr(0,u)}return h}function y(){if(g>c)return o(null,h);l.start(null,null),l.update(t),l.update(F.util.int32ToBytes(g)),f=p=l.digest().getBytes(),m=2,v()}function v(){if(m<=r)return l.start(null,null),l.update(p),d=l.digest().getBytes(),f=F.util.xorBytes(f,d,a),p=d,++m,F.util.setImmediate(v);h+=g<c?f:f.substr(0,u),++g,y()}g=1,y()},w((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(),a=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),o(e,a,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 f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};o(f,a,n);var d=F.util.createBuffer();return d.putInt32(f.h0),d.putInt32(f.h1),d.putInt32(f.h2),d.putInt32(f.h3),d.putInt32(f.h4),d.putInt32(f.h5),d.putInt32(f.h6),d.putInt32(f.h7),d},s};var r=null,n=!1,i=null;function o(e,t,r){for(var n,o,a,s,c,u,l,f,d,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,o=((o=t[c-15])>>>7|o<<25)^(o>>>18|o<<14)^o>>>3,t[c]=n+t[c-7]+o+t[c-16]|0;for(u=e.h0,l=e.h1,f=e.h2,d=e.h3,p=e.h4,h=e.h5,g=e.h6,m=e.h7,c=0;c<64;++c)a=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&l|f&(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=d+n>>>0,d=f,f=l,l=u,u=n+(o=a+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+f|0,e.h3=e.h3+d|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}}})),w((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),o=0;o<32;++o)i[o]=n.create();function a(){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 o=Math.max(1,Math.min(e-i.length(),65536)/4),a=new Uint32Array(Math.floor(o));try{t(a);for(var s=0;s<a.length;++s)i.putInt32(a[s])}catch(e){if(!("undefined"!=typeof QuotaExceededError&&e instanceof QuotaExceededError))throw e}}if(i.length()<e)for(var c,u,l,f=Math.floor(65536*Math.random());i.length()<e;)for(u=16807*(65535&f),u+=(32767&(c=16807*(f>>16)))<<16,f=4294967295&(u=(2147483647&(u+=c>>15))+(u>>31)),s=0;s<3;++s)l=f>>>(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,o=t.plugin.formatKey,a=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 f=n(t.key,t.seed);t.generated+=f.length,c.putBytes(f),t.key=o(n(t.key,i(t.seed))),t.seed=a(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,o=t.plugin.formatSeed;t.key=null;for(var s=F.util.createBuffer();s.length()<e;){t.generated>1048575&&(t.key=null),null===t.key&&a();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=o(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}})),w((function(e){F.random&&F.random.getBytes?e.exports=F.random:function(t){var r={},n=new Array(4),i=F.util.createBuffer();function o(){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 a=o(),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(a.collectInt(+new Date,32),"undefined"!=typeof navigator){var l="";for(var f in navigator)try{"string"==typeof navigator[f]&&(l+=navigator[f])}catch(e){}a.collect(l),l=null}t&&(t().mousemove((function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)})),t().keypress((function(e){a.collectInt(e.charCode,8)})))}if(F.random)for(var f in a)F.random[f]=a[f];else F.random=a;F.random.createInstance=o,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(),o=t,a=Math.ceil(o/8),s=255>>(7&o);for(r=i;r<128;r++)n.putByte(ye[n.at(r-1)+n.at(r-i)&255]);for(n.setAt(128-a,ye[n.at(128-a)&s]),r=127-a;r>=0;r--)n.setAt(r,ye[n.at(r+1)^n.at(r+a)]);return n};var we,Ee=function(e,t,r){var n,i,o,a,s=!1,c=null,u=null,l=null,f=[];for(e=F.rc2.expandKey(e,t),o=0;o<64;o++)f.push(e.getInt16Le());r?(n=function(e){for(o=0;o<4;o++)e[o]+=f[a]+(e[(o+3)%4]&e[(o+2)%4])+(~e[(o+3)%4]&e[(o+1)%4]),e[o]=be(e[o],ve[o]),a++},i=function(e){for(o=0;o<4;o++)e[o]+=f[63&e[(o+3)%4]]}):(n=function(e){for(o=3;o>=0;o--)e[o]=Ce(e[o],ve[o]),e[o]-=f[a]+(e[(o+3)%4]&e[(o+2)%4])+(~e[(o+3)%4]&e[(o+1)%4]),a--},i=function(e){for(o=3;o>=0;o--)e[o]-=f[63&e[(o+3)%4]]});var d=function(e){var t=[];for(o=0;o<4;o++){var n=c.getInt16Le();null!==l&&(r?n^=l.getInt16Le():l.putInt16Le(n)),t.push(65535&n)}a=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(o=0;o<4;o++)null!==l&&(r?l.putInt16Le(t[o]):t[o]^=l.getInt16Le()),u.putInt16Le(t[o])},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;)d([[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(),o=u.at(i-1);o>i?t=!1:u.truncate(o)}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,o){for(var a=16383&t,s=t>>14;--o>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=s*c+u*a;i=((c=a*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 Ee(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 Ee(e,t,!1)},F.jsbn=F.jsbn||{},F.jsbn.BigInteger=ke,"undefined"==typeof navigator?(ke.prototype.am=Be,we=28):"Microsoft Internet Explorer"==navigator.appName?(ke.prototype.am=function(e,t,r,n,i,o){for(var a=32767&t,s=t>>15;--o>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=s*c+u*a;i=((c=a*c+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+s*u+(i>>>30),r.data[n++]=1073741823&c}return i},we=30):"Netscape"!=navigator.appName?(ke.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var a=t*this.data[e++]+r.data[n]+i;i=Math.floor(a/67108864),r.data[n++]=67108863&a}return i},we=26):(ke.prototype.am=Be,we=28),ke.prototype.DB=we,ke.prototype.DM=(1<<we)-1,ke.prototype.DV=1<<we,ke.prototype.FV=Math.pow(2,52),ke.prototype.F1=52-we,ke.prototype.F2=2*we-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 Re(e,t){var r=_e[e.charCodeAt(t)];return null==r?-1:r}function Pe(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 Le(e){this.m=e}function Oe(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}Le.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},Le.prototype.revert=function(e){return e},Le.prototype.reduce=function(e){e.divRemTo(this.m,null,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)},Oe.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},Oe.prototype.revert=function(e){var t=Se();return e.copyTo(t),this.reduce(t),t},Oe.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)},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)},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,o=0;--n>=0;){var a=8==r?255&e[n]:Re(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this.data[this.t++]=a:o+r>this.DB?(this.data[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this.data[this.t++]=a>>this.DB-o):this.data[this.t-1]|=a<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<<this.DB-o)-1<<o)),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,o=(1<<i)-1,a=Math.floor(e/this.DB),s=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+a+1]=this.data[r]>>i|s,s=(this.data[r]&o)<<n;for(r=a-1;r>=0;--r)t.data[r]=0;t.data[a]=s,t.t=this.t+a+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,o=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var a=r+1;a<this.t;++a)t.data[a-r-1]|=(this.data[a]&o)<<i,t.data[a-r]=this.data[a]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&o)<<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 o=Se(),a=this.s,s=e.s,c=this.DB-Ne(n.data[n.t-1]);c>0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var u=o.t,l=o.data[u-1];if(0!=l){var f=l*(1<<this.F1)+(u>1?o.data[u-2]>>this.F2:0),d=this.FV/f,p=(1<<this.F1)/f,h=1<<this.F2,g=r.t,m=g-u,y=null==t?Se():t;for(o.dlShiftTo(m,y),r.compareTo(y)>=0&&(r.data[r.t++]=1,r.subTo(y,r)),ke.ONE.dlShiftTo(u,y),y.subTo(o,o);o.t<u;)o.data[o.t++]=0;for(;--m>=0;){var v=r.data[--g]==l?this.DM:Math.floor(r.data[g]*d+(r.data[g-1]+h)*p);if((r.data[g]+=o.am(0,v,r,m,0,u))<v)for(o.dlShiftTo(m,y),r.subTo(y,r);r.data[g]<--v;)r.subTo(y,r)}null!=t&&(r.drShiftTo(u,t),a!=s&&ke.ZERO.subTo(t,t)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),a<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),o=Ne(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<<o)>0)t.mulTo(n,i,r);else{var a=r;r=n,n=a}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,o="",a=this.t,s=this.DB-a*this.DB%t;if(a-- >0)for(s<this.DB&&(r=this.data[a]>>s)>0&&(i=!0,o=xe(r));a>=0;)s<t?(r=(this.data[a]&(1<<s)-1)<<t-s,r|=this.data[--a]>>(s+=this.DB-t)):(r=this.data[a]>>(s-=t)&n,s<=0&&(s+=this.DB,--a)),r>0&&(i=!0),i&&(o+=xe(r));return i?o:"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 Le(t):new Oe(t),this.exp(e,r)},ke.ZERO=Pe(0),ke.ONE=Pe(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=Pe(r),i=Se(),o=Se(),a="";for(this.divRemTo(n,i,o);i.signum()>0;)a=(r+o.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,o);return o.intValue().toString(e)+a},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,o=0,a=0,s=0;s<e.length;++s){var c=Re(e,s);c<0?"-"==e.charAt(s)&&0==this.signum()&&(i=!0):(a=t*a+c,++o>=r&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(a,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,o=Math.min(e.t,this.t);for(n=0;n<o;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(i=e.s&this.DM,n=o;n<this.t;++n)r.data[n]=t(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;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),o={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},a=0;a<e;++a){do{n=new ke(this.bitLength(),o)}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(),o=Pe(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new Le(t):t.isEven()?new qe(t):new Oe(t);var a=new Array,s=3,c=r-1,u=(1<<r)-1;if(a[1]=n.convert(this),r>1){var l=Se();for(n.sqrTo(a[1],l);s<=u;)a[s]=Se(),n.mulTo(l,a[s-2],a[s]),s+=2}var f,d,p=e.t-1,h=!0,g=Se();for(i=Ne(e.data[p])-1;p>=0;){for(i>=c?f=e.data[p]>>i-c&u:(f=(e.data[p]&(1<<i+1)-1)<<c-i,p>0&&(f|=e.data[p-1]>>this.DB+i-c)),s=r;0==(1&f);)f>>=1,--s;if((i-=s)<0&&(i+=this.DB,--p),h)a[f].copyTo(o),h=!1;else{for(;s>1;)n.sqrTo(o,g),n.sqrTo(g,o),s-=2;s>0?n.sqrTo(o,g):(d=o,o=g,g=d),n.mulTo(g,a[f],o)}for(;p>=0&&0==(e.data[p]&1<<i);)n.sqrTo(o,g),d=o,o=g,g=d,--i<0&&(i=this.DB-1,--p)}return n.revert(o)},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=Pe(1),o=Pe(0),a=Pe(0),s=Pe(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),t?(a.isEven()&&s.isEven()||(a.addTo(this,a),s.subTo(e,s)),a.rShiftTo(1,a)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(a,i),o.subTo(s,o)):(n.subTo(r,n),t&&a.subTo(i,a),s.subTo(o,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(),o=r.getLowestSetBit();if(o<0)return t;for(i<o&&(o=i),o>0&&(t.rShiftTo(o,t),r.rShiftTo(o,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 o>0&&r.lShiftTo(o,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)},w((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(),o=new Array(80),a={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){a.messageLength=0,a.fullMessageLength=a.messageLength64=[];for(var r=a.messageLengthSize/4,n=0;n<r;++n)a.fullMessageLength.push(0);return t=F.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},a}};return a.start(),a.update=function(r,n){"utf8"===n&&(r=F.util.encodeUtf8(r));var s=r.length;a.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var c=a.fullMessageLength.length-1;c>=0;--c)a.fullMessageLength[c]+=s[1],s[1]=s[0]+(a.fullMessageLength[c]/4294967296>>>0),a.fullMessageLength[c]=a.fullMessageLength[c]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(r),i(e,o,t),(t.read>2048||0===t.length())&&t.compact(),a},a.digest=function(){var n=F.util.createBuffer();n.putBytes(t.bytes());var s,c=a.fullMessageLength[a.fullMessageLength.length-1]+a.messageLengthSize&a.blockLength-1;n.putBytes(r.substr(0,a.blockLength-c));for(var u=8*a.fullMessageLength[0],l=0;l<a.fullMessageLength.length-1;++l)u+=(s=8*a.fullMessageLength[l+1])/4294967296>>>0,n.putInt32(u>>>0),u=s>>>0;n.putInt32(u);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};i(f,o,n);var d=F.util.createBuffer();return d.putInt32(f.h0),d.putInt32(f.h1),d.putInt32(f.h2),d.putInt32(f.h3),d.putInt32(f.h4),d},a};var r=null,n=!1;function i(e,t,r){for(var n,i,o,a,s,c,u,l=r.length();l>=64;){for(i=e.h0,o=e.h1,a=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^o&(a^s))+c+1518500249+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=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^o&(a^s))+c+1518500249+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=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)+(o^a^s)+c+1859775393+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=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)+(o^a^s)+c+1859775393+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=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)+(o&a|s&(o^a))+c+2400959708+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=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)+(o^a^s)+c+3395469782+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+o|0,e.h2=e.h2+a|0,e.h3=e.h3+s|0,e.h4=e.h4+c|0,l-=64}}})),w((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),o=0;o<i;++o){var a=String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,255&o);r.start(),r.update(e+a),n+=r.digest().getBytes()}return n.substring(0,t)}t.encode_rsa_oaep=function(e,t,n){var i,o,a,s;"string"==typeof n?(i=n,o=arguments[3]||void 0,a=arguments[4]||void 0):n&&(i=n.label||void 0,o=n.seed||void 0,a=n.md||void 0,n.mgf1&&n.mgf1.md&&(s=n.mgf1.md)),a?a.start():a=F.md.sha1.create(),s||(s=a);var c=Math.ceil(e.n.bitLength()/8),u=c-2*a.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=""),a.update(i,"raw");for(var l=a.digest(),f="",d=u-t.length,p=0;p<d;p++)f+="\0";var h,g=l.getBytes()+f+""+t;if(o){if(o.length!==a.digestLength)throw(h=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=o.length,h.digestLength=a.digestLength,h}else o=F.random.getBytes(a.digestLength);var m=r(o,c-a.digestLength-1,s),y=F.util.xorBytes(g,m,g.length),v=r(y,a.digestLength,s);return"\0"+F.util.xorBytes(o,v,o.length)+y},t.decode_rsa_oaep=function(e,t,n){var i,o,a;"string"==typeof n?(i=n,o=arguments[3]||void 0):n&&(i=n.label||void 0,o=n.md||void 0,n.mgf1&&n.mgf1.md&&(a=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===o?o=F.md.sha1.create():o.start(),a||(a=o),s<2*o.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");i||(i=""),o.update(i,"raw");for(var c=o.digest().getBytes(),u=t.charAt(0),l=t.substring(1,o.digestLength+1),f=t.substring(1+o.digestLength),d=r(f,o.digestLength,a),p=r(F.util.xorBytes(l,d,l.length),s-o.digestLength-1,a),h=F.util.xorBytes(f,p,f.length),g=h.substring(0,o.digestLength),m="\0"!==u,y=0;y<o.digestLength;++y)m|=c.charAt(y)!==g.charAt(y);for(var v=1,b=o.digestLength,C=o.digestLength;C<h.length;C++){var w=h.charCodeAt(C);m|=w&(v?65534:0),b+=v&=1&w^1}if(m||1!==h.charCodeAt(b))throw new Error("Invalid RSAES-OAEP padding.");return h.substring(b+1)}})),w((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 o=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 o=t.prng||F.random,c={nextBytes:function(e){for(var t=o.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 a(e,t,n,i);var o=s(e,t),c=n.workers,u=n.workLoad||100,l=30*u/8,f=n.workerScript||"forge/prime.worker.js";if(-1===c)return F.util.estimateCores((function(e,t){e&&(t=2),c=t-1,d()}));function d(){c=Math.max(1,c);for(var n=[],a=0;a<c;++a)n[a]=new Worker(f);for(a=0;a<c;++a)n[a].addEventListener("message",p);var d=!1;function p(a){if(!d){var c=a.data;if(c.found){for(var f=0;f<n.length;++f)n[f].terminate();return d=!0,i(null,new r(c.prime,16))}o.bitLength()>e&&(o=s(e,t));var p=o.toString(16);a.target.postMessage({hex:p,workLoad:u}),o.dAddOffset(l,0)}}}d()}(e,t,n,i):a(e,t,n,i)}(e,c,i.options,n);throw new Error("Invalid prime generation algorithm: "+i.name)}}function a(e,t,r,i){var o=s(e,t),a=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}(o.bitLength());"millerRabinTests"in r&&(a=r.millerRabinTests);var c=10;"maxBlockTime"in r&&(c=r.maxBlockTime),function e(t,r,i,o,a,c,u){var l=+new Date;do{if(t.bitLength()>r&&(t=s(r,i)),t.isProbablePrime(a))return u(null,t);t.dAddOffset(n[o++%8],0)}while(c<0||+new Date-l<c);F.util.setImmediate((function(){e(t,r,i,o,a,c,u)}))}(o,e,t,0,a,c,i)}function s(e,t){var n=new r(e,t),a=e-1;return n.testBit(a)||n.bitwiseTo(r.ONE.shiftLeft(a),o,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,[]),o=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[]);o.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,n)),o.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,""));var a=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(o),i.value.push(a),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),o=e.mod(t.q).modPow(t.dQ,t.q);i.compareTo(o)<0;)i=i.add(t.p);var a=i.subtract(o).multiply(t.qInv).mod(t.p).multiply(t.q).add(o);return a.multiply(n.modInverse(t.n)).mod(t.n)};function ot(e,t,r){var n=F.util.createBuffer(),i=Math.ceil(t.n.bitLength()/8);if(e.length>i-11){var o=new Error("Message is too long for PKCS#1 v1.5 padding.");throw o.length=e.length,o.max=i-11,o}n.putByte(0),n.putByte(r);var a,s=i-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var c=0;c<s;++c)n.putByte(a)}else for(;s>0;){var u=0,l=F.random.getBytes(s);for(c=0;c<s;++c)0===(a=l.charCodeAt(c))?++u:n.putByte(a);s=u}return n.putByte(0),n.putBytes(e),n}function at(e,t,r,n){var i=Math.ceil(t.n.bitLength()/8),o=F.util.createBuffer(e),a=o.getByte(),s=o.getByte();if(0!==a||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!==o.getByte())throw new Error("Encryption block is invalid.")}else if(1===s)for(c=0;o.length()>1;){if(255!==o.getByte()){--o.read;break}++c}else if(2===s)for(c=0;o.length()>1;){if(0===o.getByte()){--o.read;break}++c}if(0!==o.getByte()||c!==i-3-o.length())throw new Error("Encryption block is invalid.");return o.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(){o(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?a(t,e.q):void o(e.qBits,a))}))}function o(e,t){F.prime.generateProbablePrime(e,n,t)}function a(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 o(e.qBits,a);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 o(e.qBits,a);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 ft(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 dt(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,o=Math.ceil(t.n.bitLength()/8);!1!==r&&!0!==r?(i=2===r,n=ot(e,t,r)):(n=F.util.createBuffer()).putBytes(e);for(var a=new Qe(n.toHex(),16),s=it(a,t,i).toString(16),c=F.util.createBuffer(),u=o-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 o=new Error("Encrypted message length is invalid.");throw o.length=e.length,o.expected=i,o}var a=new Qe(F.util.createBuffer(e).toHex(),16);if(a.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var s=it(a,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?at(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,o={nextBytes:function(e){for(var t=i.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},a=r.algorithm||"PRIMEINC";if("PRIMEINC"!==a)throw new Error("Invalid key generation algorithm: "+a);return(n={algorithm:a,state:0,bits:e,rng:o,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,o=function(e,t){return e|t},a=+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),o,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)-a,a=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(ft("generateKey")&&ft("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(dt("generateKey")&&dt("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 o=We.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:$e.privateKeyFromPem(o.privateKey),publicKey:$e.publicKeyFromPem(o.publicKey)}}var a=$e.rsa.createKeyPairGenerationState(e,t,r);if(!n)return $e.rsa.stepKeyPairGenerationState(a,0),a.keys;st(a,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 ot(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=at(t,r,!0),e===Xe.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===at(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,o,a,s){var c={n:e,e:t,d:r,p:n,q:i,dP:o,dQ:a,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:at};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,o,a,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 f=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw f.errors=l,f}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(),o=F.util.createBuffer(u.privateKeyPrime2).toHex(),a=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(o,16),new Qe(a,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 o=F.util.createBuffer(t.publicKeyModulus).toHex(),a=F.util.createBuffer(t.publicKeyExponent).toHex();return $e.setRsaPublicKey(new Qe(o,16),new Qe(a,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 wt(e,t){return e.start().update(t).digest().getBytes()}function Et(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,o,a=F.random.getBytesSync(r.saltSize),s=r.count,c=gt.integerToDer(s);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var u,l,f;switch(r.algorithm){case"aes128":n=16,u=16,l=yt["aes128-CBC"],f=F.aes.createEncryptionCipher;break;case"aes192":n=24,u=16,l=yt["aes192-CBC"],f=F.aes.createEncryptionCipher;break;case"aes256":n=32,u=16,l=yt["aes256-CBC"],f=F.aes.createEncryptionCipher;break;case"des":n=8,u=8,l=yt.desCBC,f=F.des.createEncryptionCipher;break;default:throw(y=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,y}var d="hmacWith"+r.prfAlgorithm.toUpperCase(),p=kt(d),h=F.pkcs5.pbkdf2(t,a,s,n,p),g=F.random.getBytesSync(u);(v=f(h)).start(g),v.update(gt.toDer(e)),v.finish(),o=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}(a,c,n,d);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(a);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(),o=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,a),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,o)])},mt.decryptPrivateKeyInfo=function(e,t){var r=null,n={},i=[];if(!gt.validate(e,vt,n,i)){var o=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw o.errors=i,o}var a=gt.derToOid(n.encryptionOid),s=mt.pbe.getCipher(a,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,o,a,s;switch(r.algorithm){case"aes128":i="AES-128-CBC",a=16,o=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",a=24,o=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",a=32,o=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",a=24,o=F.random.getBytesSync(8),s=F.des.createEncryptionCipher;break;case"des":i="DES-CBC",a=8,o=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,o.substr(0,8),a));u.start(o),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(o).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(a=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=a,a;if(n.procType&&"ENCRYPTED"===n.procType.type){var i,o;switch(n.dekInfo.algorithm){case"DES-CBC":i=8,o=F.des.createDecryptionCipher;break;case"DES-EDE3-CBC":i=24,o=F.des.createDecryptionCipher;break;case"AES-128-CBC":i=16,o=F.aes.createDecryptionCipher;break;case"AES-192-CBC":i=24,o=F.aes.createDecryptionCipher;break;case"AES-256-CBC":i=32,o=F.aes.createDecryptionCipher;break;case"RC2-40-CBC":i=5,o=function(e){return F.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":i=8,o=function(e){return F.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":i=16,o=function(e){return F.rc2.createDecryptionCipher(e,128)};break;default:var a;throw(a=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".')).algorithm=n.dekInfo.algorithm,a}var s=F.util.hexToBytes(n.dekInfo.parameters),c=o(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,o){var a,s;if(null==o){if(!("sha1"in F.md))throw new Error('"sha1" hash algorithm unavailable.');o=F.md.sha1.create()}var c=o.digestLength,u=o.blockLength,l=new F.util.ByteBuffer,f=new F.util.ByteBuffer;if(null!=e){for(s=0;s<e.length;s++)f.putInt16(e.charCodeAt(s));f.putInt16(0)}var d=f.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(d/u),v=new F.util.ByteBuffer;for(s=0;s<y;s++)v.putByte(f.at(s%d));var b=m;b.putBuffer(v);for(var C=Math.ceil(i/c),w=1;w<=C;w++){var E=new F.util.ByteBuffer;E.putBytes(h.bytes()),E.putBytes(b.bytes());for(var k=0;k<n;k++)o.start(),o.update(E.getBytes()),E=o.digest();var S=new F.util.ByteBuffer;for(s=0;s<u;s++)S.putByte(E.at(s%c));var B=Math.ceil(p/u)+Math.ceil(d/u),T=new F.util.ByteBuffer;for(a=0;a<B;a++){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(E)}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={},o=[];if(!gt.validate(t,bt,i,o))throw(n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=o,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 a,s,c=i.kdfSalt,u=F.util.createBuffer(i.kdfIterationCount);switch(u=u.getInt(u.length()<<3),mt.oids[e]){case"aes128-CBC":a=16,s=F.aes.createDecryptionCipher;break;case"aes192-CBC":a=24,s=F.aes.createDecryptionCipher;break;case"aes256-CBC":a=32,s=F.aes.createDecryptionCipher;break;case"des-EDE3-CBC":a=24,s=F.des.createDecryptionCipher;break;case"desCBC":a=8,s=F.des.createDecryptionCipher}var l=Et(i.prfOid),f=F.pkcs5.pbkdf2(r,c,u,a,l),d=i.encIv,p=s(f);return p.start(d),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 o,a,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"]:o=24,a=8,s=F.des.startDecrypting;break;case mt.oids["pbewithSHAAnd40BitRC2-CBC"]:o=5,a=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 f=Et(n.prfOid),d=mt.pbe.generatePkcs12Key(r,c,1,u,o,f);return f.start(),s(d,mt.pbe.generatePkcs12Key(r,c,2,u,a,f))},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=[wt(n,e+t)],o=16,a=1;o<r;++a,o+=16)i.push(wt(n,i[a-1]+e+t));return i.join("").substr(0,r)},w((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 o={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:[o]}]},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"}]}})),w((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),o=0;o<i;o++){var a=new F.util.ByteBuffer;a.putInt32(o),e.start(),e.update(t+a.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}}}})),F.mgf=F.mgf||{},F.mgf.mgf1=F.mgf1,w((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,o=e.salt||null;if("string"==typeof o&&(o=F.util.createBuffer(o)),"saltLength"in e)t=e.saltLength;else{if(null===o)throw new Error("Salt length not specified or specific salt not given.");t=o.length()}if(null!==o&&o.length()!==t)throw new Error("Given salt length does not match length of given salt.");var a=e.prng||F.random;return{encode:function(e,s){var c,u,l=s-1,f=Math.ceil(l/8),d=e.digest().getBytes();if(f<i+t+2)throw new Error("Message is too long to encrypt.");u=null===o?a.getBytesSync(t):o.bytes();var p=new F.util.ByteBuffer;p.fillWithByte(0,8),p.putBytes(d),p.putBytes(u),r.start(),r.update(p.getBytes());var h=r.digest().getBytes(),g=new F.util.ByteBuffer;g.fillWithByte(0,f-t-i-2),g.putByte(1),g.putBytes(u);var m=g.getBytes(),y=f-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*f-l&255;return(b=String.fromCharCode(b.charCodeAt(0)&~C)+b.substr(1))+h+String.fromCharCode(188)},verify:function(e,o,a){var s,c=a-1,u=Math.ceil(c/8);if(o=o.substr(-u),u<i+t+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(188!==o.charCodeAt(u-1))throw new Error("Encoded message does not end in 0xBC.");var l=u-i-1,f=o.substr(0,l),d=o.substr(l,i),p=65280>>8*u-c&255;if(0!=(f.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var h=n.generate(d,l),g="";for(s=0;s<l;s++)g+=String.fromCharCode(f.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()),d===r.digest().getBytes()}}}})),w((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 o=F.pki.rsa.publicKeyValidator,a={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"},o,{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"},o,{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 o,a,s,c=[],u=0;u<e.value.length;++u){o=e.value[u];for(var l=0;l<o.value.length;++l)s={},a=o.value[l],s.type=t.derToOid(a.value[0].value),s.value=a.value[1].value,s.valueTagClass=a.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 o=[],a=0;a<e.length;++a)for(var s=e[a],c=t.derToOid(s.value[0].value),u=s.value[1].value,l=0;l<u.length;++l){var f={};if(f.type=c,f.value=u[l].value,f.valueTagClass=u[l].type,f.type in n&&(f.name=n[f.type],f.name in i&&(f.shortName=i[f.name])),f.type===n.extensionRequest){f.extensions=[];for(var d=0;d<f.value.length;++d)f.extensions.push(r.certificateExtensionFromAsn1(f.value[d]))}o.push(f)}return o};var f=function(e,r,i){var o={};if(e!==n["RSASSA-PSS"])return o;i&&(o={hash:{algorithmOid:n.sha1},mgf:{algorithmOid:n.mgf1,hash:{algorithmOid:n.sha1}},saltLength:20});var a={},c=[];if(!t.validate(r,s,a,c)){var u=new Error("Cannot read RSASSA-PSS parameter block.");throw u.errors=c,u}return void 0!==a.hashOid&&(o.hash=o.hash||{},o.hash.algorithmOid=t.derToOid(a.hashOid)),void 0!==a.maskGenOid&&(o.mgf=o.mgf||{},o.mgf.algorithmOid=t.derToOid(a.maskGenOid),o.mgf.hash=o.mgf.hash||{},o.mgf.hash.algorithmOid=t.derToOid(a.maskGenHashOid)),void 0!==a.saltLength&&(o.saltLength=a.saltLength.charCodeAt(0)),o};function d(e){for(var r,n,i=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),o=e.attributes,a=0;a<o.length;++a){var s=(r=o[a]).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 o,a=0;a<e.length;++a){if(void 0===(o=e[a]).name&&(o.type&&o.type in r.oids?o.name=r.oids[o.type]:o.shortName&&o.shortName in i&&(o.name=r.oids[i[o.shortName]])),void 0===o.type){if(!o.name||!(o.name in r.oids))throw(c=new Error("Attribute type not specified.")).attribute=o,c;o.type=r.oids[o.name]}if(void 0===o.shortName&&o.name&&o.name in i&&(o.shortName=i[o.name]),o.type===n.extensionRequest&&(o.valueConstructed=!0,o.valueTagClass=t.Type.SEQUENCE,!o.value&&o.extensions)){o.value=[];for(var s=0;s<o.extensions.length;++s)o.value.push(r.certificateExtensionToAsn1(h(o.extensions[s])))}var c;if(void 0===o.value)throw(c=new Error("Attribute value not specified.")).attribute=o,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 o=0,a=0,s=0;e.digitalSignature&&(a|=128,o=7),e.nonRepudiation&&(a|=64,o=6),e.keyEncipherment&&(a|=32,o=5),e.dataEncipherment&&(a|=16,o=4),e.keyAgreement&&(a|=8,o=3),e.keyCertSign&&(a|=4,o=2),e.cRLSign&&(a|=2,o=1),e.encipherOnly&&(a|=1,o=0),e.decipherOnly&&(s|=128,o=7);var c=String.fromCharCode(o);0!==s?c+=String.fromCharCode(a)+String.fromCharCode(s):0!==a&&(c+=String.fromCharCode(a)),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)o=0,a=0,e.client&&(a|=128,o=7),e.server&&(a|=64,o=6),e.email&&(a|=32,o=5),e.objsign&&(a|=16,o=4),e.reserved&&(a|=8,o=3),e.sslCA&&(a|=4,o=2),e.emailCA&&(a|=2,o=1),e.objCA&&(a|=1,o=0),c=String.fromCharCode(o),0!==a&&(c+=String.fromCharCode(a)),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 f=0;f<e.altNames.length;++f){if(c=(y=e.altNames[f]).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,[d(!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(f=0;f<e.altNames.length;++f){if(c=(y=e.altNames[f]).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 o=n[i],a=o.value,s=t.Type.UTF8;"valueTagClass"in o&&(s=o.valueTagClass),s===t.Type.UTF8&&(a=F.util.encodeUtf8(a));var c=!1;"valueConstructed"in o&&(c=o.valueConstructed);var u=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(o.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,s,c,a)])]);r.value.push(u)}return r}r.certificateFromPem=function(e,n,i){var o=F.pem.decode(e)[0];if("CERTIFICATE"!==o.type&&"X509 CERTIFICATE"!==o.type&&"TRUSTED CERTIFICATE"!==o.type){var a=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw a.headerType=o.type,a}if(o.procType&&"ENCRYPTED"===o.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=t.fromDer(o.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 o=t.fromDer(n.body);return r.publicKeyFromAsn1(o)},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,o=(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+'".')}o.start(),o.update(i);var a=o.digest();if("hex"===n.encoding){var s=a.toHex();return n.delimiter?s.match(/.{2}/g).join(n.delimiter):s}if("binary"===n.encoding)return a.getBytes();if(n.encoding)throw new Error('Unknown encoding "'+n.encoding+'".');return a},r.certificationRequestFromPem=function(e,n,i){var o=F.pem.decode(e)[0];if("CERTIFICATE REQUEST"!==o.type){var a=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw a.headerType=o.type,a}if(o.procType&&"ENCRYPTED"===o.procType.type)throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=t.fromDer(o.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,o){e.md=o||F.md.sha1.create();var a=n[e.md.algorithm+"WithRSAEncryption"];if(!a){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=a,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 o=!1;if(!e.issued(i)){var a=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=a.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 f;switch(i.signatureOid){case n.sha1WithRSAEncryption:f=void 0;break;case n["RSASSA-PSS"]:var d,p,h;if(void 0===(d=n[i.signatureParameters.mgf.hash.algorithmOid])||void 0===F.md[d])throw(h=new Error("Unsupported MGF hash function.")).oid=i.signatureParameters.mgf.hash.algorithmOid,h.name=d,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[d].create()),void 0===(d=n[i.signatureParameters.hash.algorithmOid])||void 0===F.md[d])throw{message:"Unsupported RSASSA-PSS hash function.",oid:i.signatureParameters.hash.algorithmOid,name:d};f=F.pss.create(F.md[d].create(),p,i.signatureParameters.saltLength)}o=e.publicKey.verify(c.digest().getBytes(),i.signature,f)}return o},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 o,a;r=!0;for(var s=0;r&&s<n.attributes.length;++s)o=n.attributes[s],a=i.attributes[s],o.type===a.type&&o.value===a.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 o=e.generateSubjectKeyIdentifier().getBytes();return F.util.hexToBytes(i.subjectKeyIdentifier)===o}}return!1},e},r.certificateFromAsn1=function(e,i){var o={},s=[];if(!t.validate(e,a,o,s))throw(h=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.")).errors=s,h;if(t.derToOid(o.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var c=r.createCertificate();c.version=o.certVersion?o.certVersion.charCodeAt(0):0;var u=F.util.createBuffer(o.certSerialNumber);c.serialNumber=u.toHex(),c.signatureOid=F.asn1.derToOid(o.certSignatureOid),c.signatureParameters=f(c.signatureOid,o.certSignatureParams,!0),c.siginfo.algorithmOid=F.asn1.derToOid(o.certinfoSignatureOid),c.siginfo.parameters=f(c.siginfo.algorithmOid,o.certinfoSignatureParams,!1),c.signature=o.certSignature;var d=[];if(void 0!==o.certValidity1UTCTime&&d.push(t.utcTimeToDate(o.certValidity1UTCTime)),void 0!==o.certValidity2GeneralizedTime&&d.push(t.generalizedTimeToDate(o.certValidity2GeneralizedTime)),void 0!==o.certValidity3UTCTime&&d.push(t.utcTimeToDate(o.certValidity3UTCTime)),void 0!==o.certValidity4GeneralizedTime&&d.push(t.generalizedTimeToDate(o.certValidity4GeneralizedTime)),d.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(d.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=d[0],c.validity.notAfter=d[1],c.tbsCertificate=o.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(o.certIssuer,m),o.certIssuerUniqueId&&(c.issuer.uniqueId=o.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(o.certSubject,y),o.certSubjectUniqueId&&(c.subject.uniqueId=o.certSubjectUniqueId),c.subject.hash=y.digest().toHex(),o.certExtensions?c.extensions=r.certificateExtensionsFromAsn1(o.certExtensions):c.extensions=[],c.publicKey=r.publicKeyFromAsn1(o.subjectPublicKeyInfo),c},r.certificateExtensionsFromAsn1=function(e){for(var t=[],n=0;n<e.value.length;++n)for(var i=e.value[n],o=0;o<i.value.length;++o)t.push(r.certificateExtensionFromAsn1(i.value[o]));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,o=0;(s=t.fromDer(r.value)).value.length>1&&(i=s.value.charCodeAt(1),o=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&o)}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 a=null;s.value.length>0&&s.value[0].type===t.Type.INTEGER?a=s.value[0].value:s.value.length>1&&(a=s.value[1].value),null!==a&&(r.pathLenConstraint=t.derToInteger(a))}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 f=0;f<s.value.length;++f){var d={type:(l=s.value[f]).type,value:l.value};switch(r.altNames.push(d),l.type){case 1:case 2:case 6:break;case 7:d.ip=F.util.bytesToIP(l.value);break;case 8:d.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 o={},a=[];if(!t.validate(e,u,o,a))throw(c=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.")).errors=a,c;if(t.derToOid(o.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var s=r.createCertificationRequest();if(s.version=o.csrVersion?o.csrVersion.charCodeAt(0):0,s.signatureOid=F.asn1.derToOid(o.csrSignatureOid),s.signatureParameters=f(s.signatureOid,o.csrSignatureParams,!0),s.siginfo.algorithmOid=F.asn1.derToOid(o.csrSignatureOid),s.siginfo.parameters=f(s.siginfo.algorithmOid,o.csrSignatureParams,!1),s.signature=o.csrSignature,s.certificationRequestInfo=o.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 d=t.toDer(s.certificationRequestInfo);s.md.update(d.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(o.certificationRequestInfoSubject,h),s.subject.hash=h.digest().toHex(),s.publicKey=r.publicKeyFromAsn1(o.subjectPublicKeyInfo),s.getAttribute=function(e){return l(s,e)},s.addAttribute=function(e){p([e]),s.attributes.push(e)},s.attributes=r.CRIAttributesAsArray(o.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,o){e.md=o||F.md.sha1.create();var a=n[e.md.algorithm+"WithRSAEncryption"];if(!a){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=a,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,o=e.md;if(null===o){if(e.signatureOid in n)switch(n[e.signatureOid]){case"sha1WithRSAEncryption":o=F.md.sha1.create();break;case"md5WithRSAEncryption":o=F.md.md5.create();break;case"sha256WithRSAEncryption":o=F.md.sha256.create();break;case"sha384WithRSAEncryption":o=F.md.sha384.create();break;case"sha512WithRSAEncryption":o=F.md.sha512.create();break;case"RSASSA-PSS":o=F.md.sha256.create()}if(null===o)throw(f=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=e.signatureOid,f;var a=e.certificationRequestInfo||r.getCertificationRequestInfo(e),s=t.toDer(a);o.update(s.getBytes())}if(null!==o){var c;switch(e.signatureOid){case n.sha1WithRSAEncryption:break;case n["RSASSA-PSS"]:var u,l,f;if(void 0===(u=n[e.signatureParameters.mgf.hash.algorithmOid])||void 0===F.md[u])throw(f=new Error("Unsupported MGF hash function.")).oid=e.signatureParameters.mgf.hash.algorithmOid,f.name=u,f;if(void 0===(l=n[e.signatureParameters.mgf.algorithmOid])||void 0===F.mgf[l])throw(f=new Error("Unsupported MGF function.")).oid=e.signatureParameters.mgf.algorithmOid,f.name=l,f;if(l=F.mgf[l].create(F.md[u].create()),void 0===(u=n[e.signatureParameters.hash.algorithmOid])||void 0===F.md[u])throw(f=new Error("Unsupported RSASSA-PSS hash function.")).oid=e.signatureParameters.hash.algorithmOid,f.name=u,f;c=F.pss.create(F.md[u].create(),l,e.signatureParameters.saltLength)}i=e.publicKey.verify(o.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),o=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)]),d(e.issuer),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,i]),d(e.subject),r.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&o.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&&o.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&&o.value.push(r.certificateExtensionsToAsn1(e.extensions)),o},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()),d(e.subject),r.publicKeyToAsn1(e.publicKey),m(e)])},r.distinguishedNameToAsn1=function(e){return d(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 o=0;o<e.length;++o)i.value.push(r.certificateExtensionToAsn1(e[o]));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 o(e),n.certs[e.hash]||null}function o(e){if(!e.hash){var t=F.md.sha1.create();e.attributes=r.RDNAttributesAsArray(d(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)),o(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 o=t.toDer(r.certificateToAsn1(e)).getBytes(),a=0;a<n.length;++a)if(o===t.toDer(r.certificateToAsn1(n[a])).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 a;if("string"==typeof e&&(e=F.pki.certificateFromPem(e)),o(e.subject),!n.hasCertificate(e))return null;var s=i(e.subject);if(!F.util.isArray(s))return a=n.certs[e.subject.hash],delete n.certs[e.subject.hash],a;for(var c=t.toDer(r.certificateToAsn1(e)).getBytes(),u=0;u<s.length;++u)c===t.toDer(r.certificateToAsn1(s[u])).getBytes()&&(a=s[u],s.splice(u,1));return 0===s.length&&delete n.certs[e.subject.hash],a},e)for(var a=0;a<e.length;++a){var s=e[a];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),o=n.validityCheckDate;void 0===o&&(o=new Date);var a=!0,s=null,c=0;do{var u=t.shift(),l=null,f=!1;if(o&&(o<u.validity.notBefore||o>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:o}),null===s){if(null===(l=t[0]||e.getIssuer(u))&&u.isIssuer(u)&&(f=!0,l=u),l){var d=l;F.util.isArray(d)||(d=[d]);for(var p=!1;!p&&d.length>0;){l=d.shift();try{p=l.verify(u)}catch(e){}}p||(s={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}null!==s||l&&!f||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&&(!a||0===t.length&&(!l||f))){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,a=!1,++c}while(t.length>0);return!0}})),w((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"}]},o={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"}]}]},a={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=[],o=0;o<e.length;o++)for(var a=0;a<e[o].safeBags.length;a++){var s=e[o].safeBags[a];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 f(e,n){var i={},o=[];if(!t.validate(e,F.pkcs7.asn1.encryptedDataValidator,i,o))throw(a=new Error("Cannot read EncryptedContentInfo.")).errors=o,a;var a,s=t.derToOid(i.contentType);if(s!==r.oids.data)throw(a=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.")).oid=s,a;s=t.derToOid(i.encAlgorithm);var c=r.pbe.getCipher(s,i.encParameter,n),u=l(i.encryptedContentAsn1),f=F.util.createBuffer(u.value);if(c.update(f),!c.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return c.output.getBytes()}function d(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 o=[],s=0;s<e.value.length;s++){var u=e.value[s],l={},f=[];if(!t.validate(u,a,l,f))throw(y=new Error("Cannot read SafeBag.")).errors=f,y;var d,h,g={type:t.derToOid(l.bagId),attributes:p(l.bagAttributes)};o.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:d=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!==d&&!t.validate(m,d,l,f))throw(y=new Error("Cannot read PKCS#12 "+d.name)).errors=f,y;h()}return o}function p(e){var n={};if(void 0!==e)for(var i=0;i<e.length;++i){var o={},a=[];if(!t.validate(e[i],s,o,a)){var c=new Error("Cannot read PKCS#12 BagAttribute.");throw c.errors=a,c}var u=t.derToOid(o.oid);if(void 0!==r.oids[u]){n[r.oids[u]]=[];for(var l=0;l<o.values.length;++l)n[r.oids[u]].push(o.values[l].value)}}return n}n.pkcs12FromAsn1=function(e,a,s){"string"==typeof a?(s=a,a=!0):void 0===a&&(a=!0);var c={};if(!t.validate(e,o,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,w=n.generateKey(s,b,3,C,y,m),E=F.hmac.create();if(E.start(m,w),E.update(g.value),E.getMac().getBytes()!==c.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return function(e,n,o,a){if((n=t.fromDer(n,o)).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=f(m,a),h.encrypted=!0;break;default:var y;throw(y=new Error("Unsupported PKCS#12 contentType.")).contentType=t.derToOid(u.contentType),y}h.safeBags=d(g,o,a),e.safeContents.push(h)}}(h,g.value,a,s),h},n.toPkcs12Asn1=function(e,i,o,a){(a=a||{}).saltSize=a.saltSize||8,a.count=a.count||2048,a.algorithm=a.algorithm||a.encAlgorithm||"aes128","useMac"in a||(a.useMac=!0),"localKeyId"in a||(a.localKeyId=null),"generateLocalKeyId"in a||(a.generateLocalKeyId=!0);var s,c=a.localKeyId;if(null!==c)c=F.util.hexToBytes(c);else if(a.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 a&&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,a.friendlyName)])])),l.length>0&&(s=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,l));var f=[],d=[];null!==i&&(d=F.util.isArray(i)?i:[i]);for(var p=[],h=0;h<d.length;++h){"string"==typeof(i=d[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())])]);f.push(b)}var C=null;if(null!==e){var w=r.wrapRsaPrivateKey(r.privateKeyToAsn1(e));C=null===o?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,[w]),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(w,o,a)]),s]);var E=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(E).getBytes())])]);f.push(k)}var S,B=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,f);if(a.useMac){var T=F.md.sha1.create(),A=new F.util.ByteBuffer(F.random.getBytes(a.saltSize)),I=a.count,_=(e=n.generateKey(o,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})),w((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 o=t.fromDer(n.body);return r.privateKeyFromAsn1(o)},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(),o=e.length>>1,a=o+(1&e.length),s=e.substr(0,a),c=e.substr(o,a),u=F.util.createBuffer(),l=F.hmac.create();r=t+r;var f=Math.ceil(n/16),d=Math.ceil(n/20);l.start("MD5",s);var p=F.util.createBuffer();u.putBytes(r);for(var 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),p.putBuffer(l.digest());l.start("SHA1",c);var g=F.util.createBuffer();for(u.clear(),u.putBytes(r),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),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 o=t.fragment,a=o.length();if(n={version:{major:o.getByte(),minor:o.getByte()},random:F.util.createBuffer(o.getBytes(32)),session_id:At(o,1),extensions:[]},i?(n.cipher_suite=o.getBytes(2),n.compression_method=o.getByte()):(n.cipher_suites=At(o,2),n.compression_methods=At(o,1)),(a=r-(a-o.length()))>0){for(var s=At(o,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 f=F.util.createBuffer(n.cipher_suites.bytes());f.length()>0&&(e.session.cipherSuite=_t.getCipherSuite(f.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,o=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:o}},_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=Lt,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(),o=null;if(e.sessionCache&&(null===(o=e.sessionCache.getSession(i))?i="":(o.version.major!==n.version.major||o.version.minor>n.version.minor)&&(o=null,i="")),0===i.length&&(i=F.random.getBytes(32)),e.session.id=i,e.session.clientHelloVersion=n.version,e.session.sp={},o)e.version=e.session.version=o.version,e.session.sp=o.sp;else{for(var a,s=1;s<_t.SupportedVersions.length&&!((a=_t.SupportedVersions[s]).minor<=n.version.minor);++s);e.version={major:a.major,minor:a.minor},e.session.version=e.version}null!==o?(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,o=t.fragment,a={certificate_list:At(o,3)},s=[];try{for(;a.certificate_list.length()>0;)n=At(a.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?Rt:Vt:(c?e.session.serverCertificate=s[0]:e.session.clientCertificate=s[0],_t.verifyCertificateChain(e,s)&&(e.expect=c?Rt: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=Pt,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()},o=null;if(e.getPrivateKey)try{o=e.getPrivateKey(e,e.session.serverCertificate),o=F.pki.privateKeyFromPem(o)}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===o)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 a=e.session.sp;a.pre_master_secret=o.decrypt(i.enc_pre_master_secret);var s=e.session.clientHelloVersion;if(s.major!==a.pre_master_secret.charCodeAt(0)||s.minor!==a.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){a.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 o={signature:At(n,2).getBytes()},a=F.util.createBuffer();a.putBuffer(e.session.md5.digest()),a.putBuffer(e.session.sha1.digest()),a=a.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(a,o.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 o=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=Lt,_t.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return o(e,null);_t.getClientSignature(e,o)},_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?Ot:zt,e.process()},_t.handleFinished=function(e,t,r){var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var o=t.fragment.getBytes();(n=F.util.createBuffer()).putBuffer(e.session.md5.digest()),n.putBuffer(e.session.sha1.digest());var a=e.entity===_t.ConnectionEnd.client,s=a?"server finished":"client finished",c=e.session.sp;if((n=St(c.master_secret,s,n.getBytes(),12)).getBytes()!==o)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&&a||!e.session.resuming&&!a)&&(_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=a?Dt:Kt,e.handshaking=!1,++e.handshakes,e.peerCertificate=a?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 o=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(o),e.session.sha1.update(o)),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(),o=r.getBytes(i);if(n===_t.HeartbeatMessageType.heartbeat_request){if(e.handshaking||i>o.length)return e.process();_t.queue(e,_t.createRecord(e,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_response,o)})),_t.flush(e)}else if(n===_t.HeartbeatMessageType.heartbeat_response){if(o!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,F.util.createBuffer(o))}e.process()};var xt=1,Rt=2,Pt=3,Nt=4,Lt=5,Ot=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 or=_t.handleClientHello,ar=_t.handleClientKeyExchange,sr=_t.handleCertificateVerify;ir[_t.ConnectionEnd.server]=[[qt,or,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,ar,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,o=e.version.major===_t.Versions.TLS_1_0.major&&e.version.minor===_t.Versions.TLS_1_0.minor;o&&(i+=2*t.fixed_iv_length);var a=r(t.master_secret,"key expansion",n,i),s={client_write_MAC_key:a.getBytes(t.mac_key_length),server_write_MAC_key:a.getBytes(t.mac_key_length),client_write_key:a.getBytes(t.enc_key_length),server_write_key:a.getBytes(t.enc_key_length)};return o&&(s.client_write_IV=a.getBytes(t.fixed_iv_length),s.server_write_IV=a.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(),o=F.util.createBuffer();o.putByte(_t.CompressionMethod.none);var a=o.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 f=s.length();f>0&&(f+=2);var d=e.session.id,p=d.length+1+2+4+28+2+i+1+a+f,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(d)),It(h,2,t),It(h,1,o),f>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 o=null,a=0;a<n.length;++a){var s=F.pem.decode(n[a])[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===o&&(o=F.asn1.fromDer(u.bytes(),!1));var l=F.util.createBuffer();It(l,3,u),i.putBuffer(l)}n=F.pki.certificateFromAsn1(o),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 f=3+i.length(),d=F.util.createBuffer();return d.putByte(_t.HandshakeType.certificate),d.putInt24(f),It(d,3,i),d},_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],o=F.pki.distinguishedNameToAsn1(i.subject),a=F.asn1.toDer(o);r.putInt16(a.length()),r.putBuffer(a)}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 o=F.util.createBuffer();return o.putByte(_t.HandshakeType.finished),o.putInt24(t.length()),o.putBuffer(t),o},_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(),o=Math.max(16,i-r-3);return n.putBytes(F.random.getBytes(o)),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 o=0;o<n.length&&!e.fail;++o){var a=n[o];e.state.current.write.update(e,a)&&e.records.push(a)}}},_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 o=new Error("The application rejected the certificate.");throw o.send=!0,o.alert={level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate},i.message&&(o.message=i.message),i.alert&&(o.alert.description=i.alert),o}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,o=e.sessionCache?_t.createSessionCache(e.sessionCache):null,a={version:{major:_t.Version.major,minor:_t.Version.minor},entity:i,sessionId:e.sessionId,caStore:t,sessionCache:o,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){a.version={major:_t.Version.major,minor:_t.Version.minor},a.record=null,a.session=null,a.peerCertificate=null,a.state={pending:null,current:null},a.expect=(_t.ConnectionEnd.client,0),a.fragmented=null,a.records=[],a.open=!1,a.handshakes=0,a.handshaking=!1,a.isConnected=!1,a.fail=!(e||void 0===e),a.input.clear(),a.tlsData.clear(),a.data.clear(),a.state.current=_t.createConnectionState(a)}};return a.reset(),a.handshake=function(e){if(a.entity!==_t.ConnectionEnd.client)a.error(a,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(a.handshaking)a.error(a,{message:"Handshake already in progress.",fatal:!1});else{a.fail&&!a.open&&0===a.handshakes&&(a.fail=!1),a.handshaking=!0;var t=null;(e=e||"").length>0&&(a.sessionCache&&(t=a.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&a.sessionCache&&null!==(t=a.sessionCache.getSession())&&(e=t.id),a.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&&(a.version=t.version,a.session.sp=t.sp),a.session.sp.client_random=_t.createRandom().getBytes(),a.open=!0,_t.queue(a,_t.createRecord(a,{type:_t.ContentType.handshake,data:_t.createClientHello(a)})),_t.flush(a)}},a.process=function(e){var t=0;return e&&a.input.putBytes(e),a.fail||(null!==a.record&&a.record.ready&&a.record.fragment.isEmpty()&&(a.record=null),null===a.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}(a)),a.fail||null===a.record||a.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}(a)),!a.fail&&null!==a.record&&a.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)}(a,a.record)),t},a.prepare=function(e){return _t.queue(a,_t.createRecord(a,{type:_t.ContentType.application_data,data:F.util.createBuffer(e)})),_t.flush(a)},a.prepareHeartbeatRequest=function(e,t){return e instanceof F.util.ByteBuffer&&(e=e.bytes()),void 0===t&&(t=e.length),a.expectedHeartbeatPayload=e,_t.queue(a,_t.createRecord(a,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_request,e,t)})),_t.flush(a)},a.close=function(e){if(!a.fail&&a.sessionCache&&a.session){var t={id:a.session.id,version:a.session.version,sp:a.session.sp};t.sp.keys=null,a.sessionCache.setSession(t.id,t)}a.open&&(a.open=!1,a.input.clear(),(a.isConnected||a.handshaking)&&(a.isConnected=a.handshaking=!1,_t.queue(a,_t.createAlert(a,{level:_t.Alert.Level.warning,description:_t.Alert.Description.close_notify})),_t.flush(a)),a.closed(a)),a.reset(e)},a},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,w((function(e){var t=e.exports=F.tls;function r(e,r,i){var o=r.entity===F.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:F.cipher.createDecipher("AES-CBC",o?i.keys.server_write_key:i.keys.client_write_key),iv:o?i.keys.server_write_IV:i.keys.client_write_IV},e.write.cipherState={init:!1,cipher:F.cipher.createCipher("AES-CBC",o?i.keys.client_write_key:i.keys.server_write_key),iv:o?i.keys.client_write_IV:i.keys.server_write_IV},e.read.cipherFunction=a,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,o=!1,a=r.macFunction(r.macKey,r.sequenceNumber,e);e.fragment.putBytes(a),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(),o=!0),o}function i(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function o(e,t,r){var n=!0;if(r){for(var i=t.length(),o=t.last(),a=i-1-o;a<i-1;++a)n=n&&t.at(a)==o;n&&t.truncate(o+1)}return n}function a(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 a=r.cipherState.cipher;a.start({iv:n}),a.update(e.fragment),i=a.finish(o);var s=r.macLength,c=F.random.getBytesSync(s),u=a.output.length();u>=s?(e.fragment=a.output.getBytes(u-s),c=a.output.getBytes(s)):e.fragment=a.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])},w((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),o=[[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]],(a={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],a["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],a["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],a["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 a))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=a[e],r=null,c=F.util.createBuffer(),u=new Array(80),l=0;l<80;++l)u[l]=new Array(2);var f=64;switch(e){case"SHA-384":f=48;break;case"SHA-512/256":f=32;break;case"SHA-512/224":f=28}var d={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:f,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){d.messageLength=0,d.fullMessageLength=d.messageLength128=[];for(var e=d.messageLengthSize/4,n=0;n<e;++n)d.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 d}};return d.start(),d.update=function(e,t){"utf8"===t&&(e=F.util.encodeUtf8(e));var n=e.length;d.messageLength+=n,n=[n/4294967296>>>0,n>>>0];for(var i=d.fullMessageLength.length-1;i>=0;--i)d.fullMessageLength[i]+=n[1],n[1]=n[0]+(d.fullMessageLength[i]/4294967296>>>0),d.fullMessageLength[i]=d.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(),d},d.digest=function(){var t=F.util.createBuffer();t.putBytes(c.bytes());var i,o=d.fullMessageLength[d.fullMessageLength.length-1]+d.messageLengthSize&d.blockLength-1;t.putBytes(n.substr(0,d.blockLength-o));for(var a=8*d.fullMessageLength[0],l=0;l<d.fullMessageLength.length-1;++l)a+=(i=8*d.fullMessageLength[l+1])/4294967296>>>0,t.putInt32(a>>>0),a=i>>>0;t.putInt32(a);var f=new Array(r.length);for(l=0;l<r.length;++l)f[l]=r[l].slice(0);s(f,u,t);var p,h=F.util.createBuffer();for(p="SHA-512"===e?f.length:"SHA-384"===e?f.length-2:f.length-4,l=0;l<p;++l)h.putInt32(f[l][0]),l===p-1&&"SHA-512/224"===e||h.putInt32(f[l][1]);return h},d};var n=null,i=!1,o=null,a=null;function s(e,t,r){for(var n,i,a,s,c,u,l,f,d,p,h,g,m,y,v,b,C,w,E,k,S,B,T,A,I,_,x,R,P,N,L,O,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=(((R=(N=t[x-2])[0])>>>19|(P=N[1])<<13)^(P>>>29|R<<3)^R>>>6)>>>0,i=((R<<13|P>>>19)^(P<<3|R>>>29)^(R<<26|P>>>6))>>>0,a=(((R=(O=t[x-15])[0])>>>1|(P=O[1])<<31)^(R>>>8|P<<24)^R>>>7)>>>0,s=((R<<31|P>>>1)^(R<<24|P>>>8)^(R<<25|P>>>7))>>>0,L=t[x-7],D=t[x-16],P=i+L[1]+s+D[1],t[x][0]=n+L[0]+a+D[0]+(P/4294967296>>>0)>>>0,t[x][1]=P>>>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],w=e[3][1],E=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=((E>>>14|k<<18)^(E>>>18|k<<14)^(k>>>9|E<<23))>>>0,f=(T^E&(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,d=(h&m|v&(h^m))>>>0,p=(g&y|b&(g^y))>>>0,P=_+(((E<<18|k>>>14)^(E<<14|k>>>18)^(k<<23|E>>>9))>>>0)+((A^k&(B^A))>>>0)+o[x][1]+t[x][1],n=I+l+f+o[x][0]+t[x][0]+(P/4294967296>>>0)>>>0,i=P>>>0,a=c+d+((P=u+p)/4294967296>>>0)>>>0,s=P>>>0,I=T,_=A,T=S,A=B,S=E,B=k,E=C+n+((P=w+i)/4294967296>>>0)>>>0,k=P>>>0,C=v,w=b,v=m,b=y,m=h,y=g,h=n+a+((P=i+s)/4294967296>>>0)>>>0,g=P>>>0;P=e[0][1]+g,e[0][0]=e[0][0]+h+(P/4294967296>>>0)>>>0,e[0][1]=P>>>0,P=e[1][1]+y,e[1][0]=e[1][0]+m+(P/4294967296>>>0)>>>0,e[1][1]=P>>>0,P=e[2][1]+b,e[2][0]=e[2][0]+v+(P/4294967296>>>0)>>>0,e[2][1]=P>>>0,P=e[3][1]+w,e[3][0]=e[3][0]+C+(P/4294967296>>>0)>>>0,e[3][1]=P>>>0,P=e[4][1]+k,e[4][0]=e[4][0]+E+(P/4294967296>>>0)>>>0,e[4][1]=P>>>0,P=e[5][1]+B,e[5][0]=e[5][0]+S+(P/4294967296>>>0)>>>0,e[5][1]=P>>>0,P=e[6][1]+A,e[6][0]=e[6][0]+T+(P/4294967296>>>0)>>>0,e[6][1]=P>>>0,P=e[7][1]+_,e[7][0]=e[7][0]+I+(P/4294967296>>>0)>>>0,e[7][1]=P>>>0,U-=128}}}));var lr=F.asn1,fr={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"}]}},dr=fr.publicKeyValidator,pr=fr.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),Pr(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),o=F.oids.EdDSA25519;if(i!==o)throw new Error('Invalid OID "'+i+'"; OID must be "'+o+'".');var a=t.privateKey;return{privateKeyBytes:vr({message:F.asn1.fromDer(a).value,encoding:"binary"})}},yr.publicKeyFromAsn1=function(e){var t={},r=[];if(!F.asn1.validate(e,dr,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var i=F.asn1.derToOid(t.publicKeyOid),o=F.oids.EdDSA25519;if(i!==o)throw new Error('Invalid OID "'+i+'"; OID must be "'+o+'".');var a=t.ed25519PublicKey;if(a.length!==yr.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return vr({message:a,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,o,a=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),Pr(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)a[i]=0;for(i=0;i<32;++i)a[i]=u[i];for(i=0;i<32;++i)for(o=0;o<32;o++)a[i+o]+=l[i]*c[o];Ir(e.subarray(32),a)}(n,t,t.length,r);for(var i=new mr(yr.constants.SIGN_BYTE_LENGTH),o=0;o<i.length;++o)i[o]=n[o];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,o=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length),a=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length);for(i=0;i<yr.constants.SIGN_BYTE_LENGTH;++i)o[i]=r[i];for(i=0;i<t.length;++i)o[i+yr.constants.SIGN_BYTE_LENGTH]=t[i];return function(e,t,r,n){var i,o=new mr(32),a=[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(),o=zr(),a=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(o,i,wr),qr(i,i,e[2]),Kr(o,e[2],o),Hr(a,o),Hr(s,a),Gr(c,s,a),Gr(r,c,i),Gr(r,r,o),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,o),Gr(r,r,o),Gr(e[0],r,o),Hr(n,e[0]),Gr(n,n,o),Lr(n,i)&&Gr(e[0],e[0],Tr),Hr(n,e[0]),Gr(n,n,o),Lr(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(a,s,c),Mr(s,t.subarray(32)),xr(a,s),Pr(o,a),r-=64,Or(t,0,o,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}(a,o,o.length,n)>=0};var br=zr(),Cr=zr([1]),wr=zr([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),Er=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 o=new mr(yr.constants.HASH_BYTE_LENGTH),a=0;a<64;++a)o[a]=i.charCodeAt(a);return o}function Ir(e,t){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i<o;++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(),o=zr(),a=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,Er),Gr(o,e[2],t[2]),Kr(o,o,o),qr(a,n,r),qr(s,o,i),Kr(c,o,i),Kr(u,n,r),Gr(e[0],a,s),Gr(e[1],u,c),Gr(e[2],c,s),Gr(e[3],a,u)}function Rr(e,t,r){for(var n=0;n<4;++n)Fr(e[n],t[n],r)}function Pr(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,o=zr(),a=zr();for(r=0;r<16;++r)a[r]=t[r];for(jr(a),jr(a),jr(a),n=0;n<2;++n){for(o[0]=a[0]-65517,r=1;r<15;++r)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),i=o[15]>>16&1,o[14]&=65535,Fr(a,o,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function Lr(e,t){var r=new mr(32),n=new mr(32);return Nr(r,e),Nr(n,t),Or(r,0,n,0)}function Or(e,t,r,n){return function(e,t,r,n,i){var o,a=0;for(o=0;o<i;++o)a|=e[t+o]^r[n+o];return(1&a-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)Rr(e,t,n=r[i/8|0]>>(7&i)&1),xr(t,e),xr(e,e),Rr(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),o=0;o<16;++o)n=i&(e[o]^t[o]),e[o]^=n,t[o]^=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,o=0,a=0,s=0,c=0,u=0,l=0,f=0,d=0,p=0,h=0,g=0,m=0,y=0,v=0,b=0,C=0,w=0,E=0,k=0,S=0,B=0,T=0,A=0,I=0,_=0,x=0,R=0,P=0,N=0,L=0,O=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];o+=(n=t[0])*D,a+=n*U,s+=n*M,c+=n*V,u+=n*j,l+=n*F,f+=n*z,d+=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*$,a+=(n=t[1])*D,s+=n*U,c+=n*M,u+=n*V,l+=n*j,f+=n*F,d+=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,w+=n*$,s+=(n=t[2])*D,c+=n*U,u+=n*M,l+=n*V,f+=n*j,d+=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,w+=n*Y,E+=n*$,c+=(n=t[3])*D,u+=n*U,l+=n*M,f+=n*V,d+=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,w+=n*X,E+=n*Y,k+=n*$,u+=(n=t[4])*D,l+=n*U,f+=n*M,d+=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,w+=n*W,E+=n*X,k+=n*Y,S+=n*$,l+=(n=t[5])*D,f+=n*U,d+=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,w+=n*Q,E+=n*W,k+=n*X,S+=n*Y,B+=n*$,f+=(n=t[6])*D,d+=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,w+=n*G,E+=n*Q,k+=n*W,S+=n*X,B+=n*Y,T+=n*$,d+=(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,w+=n*H,E+=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,w+=n*q,E+=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,w+=n*K,E+=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,w+=n*z,E+=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,w+=n*F,E+=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,R+=n*$,y+=(n=t[12])*D,v+=n*U,b+=n*M,C+=n*V,w+=n*j,E+=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,R+=n*Y,P+=n*$,v+=(n=t[13])*D,b+=n*U,C+=n*M,w+=n*V,E+=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,R+=n*X,P+=n*Y,N+=n*$,b+=(n=t[14])*D,C+=n*U,w+=n*M,E+=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,R+=n*W,P+=n*X,N+=n*Y,L+=n*$,C+=(n=t[15])*D,a+=38*(E+=n*M),s+=38*(k+=n*V),c+=38*(S+=n*j),u+=38*(B+=n*F),l+=38*(T+=n*z),f+=38*(A+=n*K),d+=38*(I+=n*q),p+=38*(_+=n*H),h+=38*(x+=n*G),g+=38*(R+=n*Q),m+=38*(P+=n*W),y+=38*(N+=n*X),v+=38*(L+=n*Y),b+=38*(O+=n*$),o=(n=(o+=38*(w+=n*U))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+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)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+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)),o=(n=(o+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+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)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+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)),o+=i-1+37*(i-1),e[0]=o,e[1]=a,e[2]=s,e[3]=c,e[4]=u,e[5]=l,e[6]=f,e[7]=d,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 o=new F.util.ByteBuffer,a=Math.ceil(i/n)+r,s=new F.util.ByteBuffer,c=r;c<a;++c){s.putInt32(c),t.start(),t.update(e+s.getBytes());var u=t.digest();o.putBytes(u.getBytes(n))}return o.truncate(o.length()-i),o.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,o=Math.ceil(t.n.bitLength()/8);do{i=new Qr(F.util.bytesToHex(r.getBytesSync(o)),16).mod(t.n)}while(i.compareTo(Qr.ONE)<=0);var a=o-(i=F.util.hexToBytes(i.toString(16))).length;return a>0&&(i=F.util.fillString(String.fromCharCode(0),a)+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 on=F.util.getQueryVariables();"console.level"in on&&F.log.setLevel($r,on["console.level"].slice(-1)[0]),"console.lock"in on&&"true"==on["console.lock"].slice(-1)[0]&&F.log.lock($r)}F.log.consoleLogger=$r,w((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 o=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw o.errors=i,o}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 o(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 o=e.unauthenticatedAttributes[i];n.values.push(a(o))}r.value.push(n)}return r}function a(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"),o=e.value;if("string"==typeof o){var a=Date.parse(o);o=isNaN(a)?13===o.length?t.utcTimeToDate(o):t.generalizedTimeToDate(o):new Date(a)}r=o>=n&&o<i?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(o)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(o))}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 o=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw o.errors=o,o}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 a="";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.");a+=i.encryptedContent[s].value}else a=i.encryptedContent;e.encryptedContent={algorithm:t.derToOid(i.encAlgorithm),parameter:F.util.createBuffer(i.encParameter.value),content:F.util.createBuffer(a)}}if(i.content){if(a="",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.");a+=i.content[s].value}else a=i.content;e.content=F.util.createBuffer(a)}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 o=t.fromDer(n.body);return r.messageFromAsn1(o)},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 o=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw o.errors=i,o}var a,s=t.derToOid(n.contentType);switch(s){case F.pki.oids.envelopedData:a=r.createEnvelopedData();break;case F.pki.oids.encryptedData:a=r.createEncryptedData();break;case F.pki.oids.signedData:a=r.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+s+" is not (yet) supported.")}return a.fromAsn1(n.content.value[0]),a},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=[],o=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&&o.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,r)),i.length>0&&o.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,i)),o.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()),o])},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 o=t.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof o&&(o=F.pki.privateKeyFromPem(o));var a=t.digestAlgorithm||F.pki.oids.sha1;switch(a){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: "+a)}var s=t.authenticatedAttributes||[];if(s.length>0){for(var c=!1,u=!1,l=0;l<s.length;++l){var f=s[l];if(c||f.type!==F.pki.oids.contentType){if(u||f.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:o,version:1,issuer:r,serialNumber:n,digestAlgorithm:a,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 f=e.signers[l];if(0===f.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{f.authenticatedAttributesAsn1=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var d=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[]),p=0;p<f.authenticatedAttributes.length;++p){var h=f.authenticatedAttributes[p];h.type===F.pki.oids.messageDigest?h.value=r[f.digestAlgorithm].digest():h.type===F.pki.oids.signingTime&&(h.value||(h.value=u)),d.value.push(a(h)),f.authenticatedAttributesAsn1.value.push(a(h))}s=t.toDer(d).getBytes(),f.md.start().update(s)}f.signature=f.key.sign(f.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=function(e){for(var t=[],r=0;r<e.length;++r)t.push(o(e[r]));return t}(e.signers)}(function(){for(var r={},n=0;n<e.signers.length;++n){var i=e.signers[n];(o=i.digestAlgorithm)in r||(r[o]=F.md[F.pki.oids[o]].create()),0===i.authenticatedAttributes.length?i.md=r[o]:i.md=F.md[F.pki.oids[o]].create()}for(var o 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(o).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],o=i.issuer;if(i.serialNumber===t.serialNumber&&o.length===r.length){for(var a=!0,s=0;s<r.length;++s)if(o[s].type!==r[s].type||o[s].value!==r[s].value){a=!1;break}if(a)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,o;switch(r=r||e.encryptedContent.algorithm,t=t||e.encryptedContent.key,r){case F.pki.oids["aes128-CBC"]:n=16,i=16,o=F.aes.createEncryptionCipher;break;case F.pki.oids["aes192-CBC"]:n=24,i=16,o=F.aes.createEncryptionCipher;break;case F.pki.oids["aes256-CBC"]:n=32,i=16,o=F.aes.createEncryptionCipher;break;case F.pki.oids["des-EDE3-CBC"]:n=24,i=8,o=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 a=o(t);if(a.start(e.encryptedContent.parameter.copy()),a.update(e.content),!a.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=a.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)}}}}}})),w((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,o){var a=""===(t=t||"")?"none":"aes256-cbc",s="PuTTY-User-Key-File-2: ssh-rsa\r\n";s+="Encryption: "+a+"\r\n",s+="Comment: "+(o=o||"")+"\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 f,d=F.util.createBuffer();if(r(d,e.d),r(d,e.p),r(d,e.q),r(d,e.qInv),t){var p=d.length()+16-1;p-=p%16;var h=i(d.bytes());h.truncate(h.length()-p+d.length()),d.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(d.copy()),m.finish();var y=m.output;y.truncate(16),f=F.util.encode64(y.bytes(),64)}else f=F.util.encode64(d.bytes(),64);s+="\r\nPrivate-Lines: "+(l=Math.floor(f.length/66)+1)+"\r\n",s+=f;var v=i("putty-private-key-file-mac-key",t),b=F.util.createBuffer();n(b,"ssh-rsa"),n(b,a),n(b,o),b.putInt32(c.length()),b.putBuffer(c),b.putInt32(d.length()),b.putBuffer(d);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(),o=F.util.createBuffer();n(o,"ssh-rsa"),r(o,e.e),r(o,e.n),i.start(),i.update(o.getBytes());var a=i.digest();if("hex"===t.encoding){var s=a.toHex();return t.delimiter?s.match(/.{2}/g).join(t.delimiter):s}if("binary"===t.encoding)return a.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".');return a}}));var an="forge.task",sn={},cn=0;F.debug.set(an,"tasks",sn);var un={};F.debug.set(an,"queues",un);var ln="ready",fn="running",dn="blocked",pn="sleeping",hn="done",gn="error",mn={ready:{}};mn.ready.stop=ln,mn.ready.start=fn,mn.ready.cancel=hn,mn.ready.fail=gn,mn.running={},mn.running.stop=ln,mn.running.start=fn,mn.running.block=dn,mn.running.unblock=fn,mn.running.sleep=pn,mn.running.wakeup=fn,mn.running.cancel=hn,mn.running.fail=gn,mn.blocked={},mn.blocked.stop=dn,mn.blocked.start=dn,mn.blocked.block=dn,mn.blocked.unblock=dn,mn.blocked.sleep=dn,mn.blocked.wakeup=dn,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(an,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=fn,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()}})},o=0;o<t.length;o++)i(e+"__parallel-"+r.id+"-"+o,o)}))},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===fn&&(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=fn,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=fn,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=fn,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===fn)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(an,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):un[e.type][0]!==e?F.log.error(an,"[%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(an,"[%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===fn&&(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,wn=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,o=Cn.cipher.createDecipher("AES-CBC",t);return o.start({iv:r}),o.update(Cn.util.createBuffer(Cn.util.hexToBytes(e))),i=(n=o.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}(),En=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 o=D(e,t,n,{headers:i.httpHeaders});this.transactionManager=new j(o),this.encryptionService=new wn(t),this.compareFaceService=new f(o),this.clientSettingsService=new d(o),this.convertPDFService=new v(o),this.ekycPDFService=new b(o),this.readIDCardService=new r(o),this.requestVerifyIDCardService=new h(o),this.requestVerifyPortraitSerivce=new g(o),this.imagesService=new u(o),this.fileService=new l(o),this.verifyFaceLivenessService=new p(o),this.searchFaceService=new y(o),this.detectIDTamperingService=new m(o),this.httpClient=o}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)},o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"compareFaces",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"convertPDF",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"readIDCard",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"requestVerifyIDCard",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"requestVerifyPortrait",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"verifyFaceLiveness",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"searchFaces",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"deleteFaces",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"indexFaces",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"detectIDTampering",null),e}();e.ReadIDCard=r,e.UploadImage=u,e.UploadFile=l,e.CompareFaces=f,e.ClientSettings=d,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=L,e.createHelpers=function(e,t,r){void 0===r&&(r="production");var n=new L(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=En,Object.defineProperty(e,"__esModule",{value:!0})}(t,r.default)})));function c$(e){var t=e.className;return ay.createElement("svg",{className:t,width:"320",height:"320",viewBox:"0 0 320 320",fill:"none",xmlns:"http://www.w3.org/2000/svg"},ay.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"}))}c$.propTypes={className:Ry.string},c$.defaultProps={className:""};var u$,l$,f$,d$,p$,h$,g$,m$,y$,v$,b$,C$,w$,E$,k$,S$=(nm($Y={},aC.FaceDirection.LEFT,90),nm($Y,aC.FaceDirection.RIGHT,270),nm($Y,aC.FaceDirection.UP,180),nm($Y,aC.FaceDirection.DOWN,0),$Y),B$=nC(["0%{background:#0A84FF;}50%{background:#DAECFF;}100%{background:#DAECFF;}"]),T$=eC.div(ZY||(ZY=fm(["\n width: 100%;\n height: 100%;\n position: relative;\n\n .top,\n .right,\n .bottom,\n .left {\n position: absolute;\n }\n\n .top {\n top: 0px;\n left: 50%;\n transform: rotate(","deg) translateX(-50%);\n }\n\n .right {\n right: 0px;\n top: 50%;\n transform: rotate(","deg) translateX(-50%);\n }\n\n .bottom {\n bottom: 0px;\n left: 50%;\n transform: rotate(","deg) translateX(50%);\n }\n\n .left {\n left: 0px;\n top: 50%;\n transform: rotate(","deg) translateX(50%);\n }\n"])),S$[aC.FaceDirection.DOWN],S$[aC.FaceDirection.LEFT],S$[aC.FaceDirection.UP],S$[aC.FaceDirection.RIGHT]),A$=eC.div(JY||(JY=fm(["\n width: 3rem;\n transform: rotate(","deg);\n\n &.ic_up,\n &.ic_right,\n &.ic_bottom,\n &.ic_left {\n position: absolute;\n }\n &.ic_up {\n top: 35px;\n }\n\n &.ic_right {\n right: 35px;\n }\n\n &.ic_bottom {\n bottom: 35px;\n }\n\n &.ic_left {\n left: 35px;\n }\n"])),(function(e){var t,r=e.direction;return null!==(t=S$[r])&&void 0!==t?t:0})),I$=eC.span(e$||(e$=fm(["\n display: flex;\n margin: 5px 0;\n width: 100%;\n height: 11px;\n\n &::before,\n &::after {\n content: '';\n height: 100%;\n width: 50%;\n background: rgb(10, 132, 255);\n animation: "," 1s linear infinite;\n animation-direction: alternate;\n }\n\n &::before {\n transform: skewY(35deg);\n }\n\n &::after {\n width: 50%;\n transform: skewY(-35deg);\n }\n"])),B$),_$=eC(I$)(t$||(t$=fm(["\n &::before,\n &::after {\n animation-delay: 0s;\n }\n"]))),x$=eC(I$)(r$||(r$=fm(["\n &::before,\n &::after {\n animation-delay: 0.5s;\n }\n"]))),R$=eC(I$)(n$||(n$=fm(["\n &::before,\n &::after {\n animation-delay: 1s;\n }\n"]))),P$=nC(["0%{-webkit-transform:translateY(0px);-moz-transform:translateY(0px);-ms-transform:translateY(0px);transform:translateY(0px);}100%{-webkit-transform:translateY(30px);-moz-transform:translateY(30px);-ms-transform:translateY(30px);transform:translateY(30px);}"]),N$=eC.span(i$||(i$=fm(["\n display: flex;\n margin: 5px 0;\n width: 100%;\n height: 11px;\n animation: "," 0.5s infinite;\n animation-direction: alternate;\n\n &::before,\n &::after {\n content: '';\n height: 100%;\n width: 50%;\n background: rgb(10, 132, 255);\n }\n\n &::before {\n transform: skewY(35deg);\n }\n\n &::after {\n width: 50%;\n transform: skewY(-35deg);\n }\n"])),P$),L$=eC(N$)(o$||(o$=fm(["\n animation-delay: 0.1s;\n"])));function O$(e){var t=e.type;return t!==aC.FaceDirection.FRONTAL?ay.createElement(A$,{direction:t,className:"ic_".concat(t)},ay.createElement(_$,null),ay.createElement(x$,null),ay.createElement(R$,null)):ay.createElement(T$,null,ay.createElement(A$,{className:"top"},ay.createElement(L$,null)),ay.createElement(A$,{className:"right"},ay.createElement(L$,null)),ay.createElement(A$,{className:"bottom"},ay.createElement(L$,null)),ay.createElement(A$,{className:"left"},ay.createElement(L$,null)))}O$.propTypes={type:Ry.oneOf([aC.FaceDirection.LEFT,aC.FaceDirection.RIGHT,aC.FaceDirection.UP,aC.FaceDirection.FRONTAL])},O$.defaultProps={type:aC.FaceDirection.LEFT};var D$=650,U$=750,M$=FF.Camera,V$=bG.Text,j$=bG.FaceDetectionError,F$=bG.FaceVerificationInstructions,z$=bG.FaceVerificationStepsWrapper,K$=bG.StepItem,q$=bG.BottomButtonsOverlay,H$=bG.Button,G$=bG.CountDownOverlay,Q$=bG.InstructionsOverlay,W$=eC(z$)(u$||(u$=fm(["\n height: 50px;\n"]))),X$=eC(j$)(l$||(l$=fm(["\n position: absolute;\n font-size: 0.938rem;\n text-align: center;\n background: none;\n color: ",";\n max-width: 95%;\n"])),MX.errorColor),Y$=eC(F$)(f$||(f$=fm(["\n position: absolute;\n font-size: 1.125rem;\n text-align: center;\n padding: 0 1.75rem 0.625rem 1.75rem;\n color: ",";\n text-shadow: none;\n z-index: 1020;\n\n ",";\n"])),(function(e){return e.color}),(function(e){return e.isMobile&&Vb(["font-size:1.125rem;"])})),$$=eC(c$)(d$||(d$=fm(["\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:"#06243c"})),Z$=eC.img(p$||(p$=fm(["\n && {\n width: 100%;\n border-radius: 4px;\n margin: 0;\n\n ","\n }\n"])),(function(e){return"preview"===e.mode&&Vb(["width:39px;"])})),J$=eC(K$)(h$||(h$=fm(["\n width: 40px;\n height: 40px;\n border: 1px solid #000;\n border-radius: 4px;\n opacity: 1;\n\n & + & {\n margin-left: 16px;\n }\n"]))),eZ=eC(H$)(g$||(g$=fm(["\n z-index: 1100;\n position: absolute;\n top: 5px;\n right: 17px;\n width: 25px;\n"]))),tZ=eC(V$)(m$||(m$=fm(["\n position: absolute;\n font-style: normal;\n font-weight: 600;\n font-size: 16px;\n text-align: center;\n padding: 0 1.75rem;\n color: #000000;\n\n ","\n"])),(function(e){var t=e.top;return t&&Vb(["top:","px;"],t)})),rZ=eC(Uj)(y$||(y$=fm(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"]))),nZ=eC(Q$)(v$||(v$=fm(["\n position: absolute;\n width: 100%;\n top: 0;\n bottom: 0;\n"]))),iZ=eC.div(b$||(b$=fm(["\n position: absolute;\n width: 100%;\n top: 0;\n bottom: 0;\n z-index: -1;\n"]))),oZ=nC(["from{opacity:1;}to{opacity:0;}"]),aZ=eC(iZ)(C$||(C$=fm(["\n background: rgba(255, 255, 255, 0.3);\n animation: "," 1s infinite;\n"])),oZ),sZ=eC.div(w$||(w$=fm(["\n background-image: url(",");\n background-color: transparent;\n height: 50%;\n z-index: 1011;\n width: 100%;\n position: absolute;\n left: 0;\n top: ",";\n"])),(function(e){return e.url}),(function(e){return e.top})),cZ=WD.isMobile?{width:640}:null;function uZ(e){var t=e.className,r=e.apiCheck,n=e.enableInstructionsOverlay,i=e.enableCapturingOverlay,o=e.mode,a=e.minPadding,s=e.backgroundColor,c=e.textColor,u=e.progressProps,l=e.customInstructions,f=e.customIcon,d=e.customDirectionIcon,p=e.onLivenessDetectionDone,h=e.onClose,g=e.onError,m=e.captureFrameSettings,y=e.onFramesCaptured,v=e.apiCredentials,b=e.onProcessing,C=e.customErrors,w=e.livenessSettings,E=e.outputEncryptionSettings,k=Hk.useAsset("ic_close.svg"),S=Hk.useAsset("watermark.png"),B=lk.useSDKSettings().lang;ay.useEffect((function(){var e=document.querySelector("html").style.overflow,t=document.body.style.overflow;return document.querySelector("html").style.overflow="hidden",document.body.style.overflow="hidden",function(){document.querySelector("html").style.overflow=e,document.body.style.overflow=t}}),[]);var T=ay.useCallback((function(e){var t=e.clientWidth,r=e.clientHeight,n=e.videoAreaWidth,i=e.videoAreaHeight,o=e.lostX,s=e.lostY,c=Math.max(60,s),u=Math.max(90,s);r>D$&&(c=Math.max(70,s),u=Math.max(140,s)),r>U$&&(c=Math.max(70,s),u=Math.max(140,s));var l=Math.max(a,o),f=Math.max(a,o),d=Math.min(n,i),p=Math.max(Math.floor(Math.min(t-(l+f),r-(c+u),d)),160);return{x:Math.min(Math.floor(l+(t-f-l)/2-p/2),t-p),y:Math.min(Math.floor(c+(r-u-c)/2-p/2),r-p),width:p,height:p}}),[a]),A=ay.useMemo((function(){return{background:s,opacity:1}}),[s]),I=vG({apiCheck:r,mode:o,bgCameraMask:null,bgCameraMaskRed:null,surroundStyle:A,cropAreaDimension:T,customInstructions:l,customIcon:f,customDirectionIcon:d,onLivenessDetectionDone:p,captureFrameSettings:m,onFramesCaptured:y,apiCredentials:v,onError:g,livenessSettings:w,onProcessing:b,customErrors:C,outputEncryptionSettings:E}),_=I.countdownToTakePicture,x=I.cropArea,R=I.curStepIndex,P=I.directionIcon,N=I.faceDetectionError,L=I.handleTriggerPassiveMode,O=I.handleVideoPlayed,D=I.instructions,U=I.isActiveMode,M=I.refVideo,V=I.showCountdown,j=I.steps,F=I.videoPlayed,z=I.activeCapturing,K=I.warmupDone,q=50,H=12,G=14;window.innerHeight>D$&&(q=50,H=24,G=34),window.innerHeight>U$&&(q=50,H=24,G=40);var Q=G+q+H;var W=N?{dashedRingColor:"#FF3B30",activeColor:"#FF3B30"}:{};return ay.createElement(gU,{ref:M,className:t,frontCamera:!0,flipHorizontal:!0,videoSettings:cZ,onVideoPlayed:O,onClose:h,onError:g,closeButton:ay.createElement(eZ,null,ay.createElement("img",{src:k,alt:""}))},!K&&ay.createElement(gF,null),F?ay.createElement(ay.Fragment,null,ay.createElement(tZ,{top:10},iY.SELFIE_TITLE[B]),ay.createElement(X$,{top:x.current.y-35,className:"face-detection-error",error:N}),ay.createElement(sZ,{top:"".concat(x.current.y+x.current.height-10,"px"),className:"waterMarkWrapper",url:S}),x.current?ay.createElement(wU,{x:"".concat(x.current.x,"px"),y:"".concat(x.current.y,"px"),width:"".concat(x.current.width,"px"),height:"".concat(x.current.height,"px"),surroundStyle:x.current.surroundStyle},ay.createElement($$,{color:s}),ay.createElement(rZ,im({progress:R/j.length*100,showOutsideRing:!1,showInsideRing:!1},u,W)),4===R?ay.createElement(rZ,{activeColor:"#15B000",dashedRingWidth:5,dashedRingColor:"#15B000",dashedRingOpacity:1,dashedInsideRingWidth:0,dashedRingLineThick:2,dashedRingLineSpacing:2,errorRingWidth:2,showOutsideRing:!1,showInsideRing:!1}):null,V?ay.createElement(G$,null,_):null,U&&n&&P?ay.createElement(nZ,null,P):null,U&&i&&z?ay.createElement(aZ,null):null):null,U?ay.createElement(ay.Fragment,null,D?ay.createElement(Y$,{bottom:Q,isMobile:WD.isMobile,color:c},D):null,ay.createElement(W$,{bottom:G},j.map((function(e,t){var r=e.name,n=e.icon,i=e.image.objUrl,o=R>=t;return ay.createElement(J$,{key:r,active:o},i?ay.createElement(Z$,{src:i,alt:"",mode:"preview"}):function(e,t){return"string"==typeof e?ay.createElement(Z$,{src:e,alt:""}):ay.cloneElement(e,t)}(n,{active:o}))})))):ay.createElement(ay.Fragment,null,N?null:ay.createElement(q$,null,ay.createElement(H$,{onClick:L},ay.createElement(M$,null))))):null)}function lZ(e){return ay.createElement(WF,im({},e,{livenessComponent:uZ}))}uZ.propTypes={className:Ry.string,apiCheck:Ry.bool,enableInstructionsOverlay:Ry.bool,enableErrorOverlay:Ry.bool,enableCapturingOverlay:Ry.bool,mode:Ry.string,minPadding:Ry.number,backgroundColor:Ry.string,textColor:Ry.string,progressProps:Ry.shape({className:Ry.string,style:Ry.shape({}),radius:Ry.number,strokeWidth:Ry.number,progress:Ry.number,activeColor:Ry.string,innerPadding:Ry.number,outsideRingColor:Ry.string,insideRingColor:Ry.string,insideRingWidth:Ry.number,dashedRingColor:Ry.string,dashedRingWidth:Ry.number,dashedRingLineThick:Ry.number,dashedRingLineSpacing:Ry.number,showOutsideRing:Ry.bool,showDashedRing:Ry.bool,showInsideRing:Ry.bool}),title:Ry.string,description:Ry.string,customInstructions:Ry.shape({}),customIcon:Ry.shape({}),customDirectionIcon:Ry.shape({}),onLivenessDetectionDone:Ry.func,onClose:Ry.func,onError:Ry.func,captureFrameSettings:Ry.shape({}),onFramesCaptured:Ry.func,apiCredentials:Ry.shape({accessKey:Ry.string,secretKey:Ry.string,apiUrl:Ry.string}),onProcessing:Ry.func,customErrors:Ry.shape({}),livenessSettings:Ry.shape({}),outputEncryptionSettings:Ry.shape({})},uZ.defaultProps={className:"",apiCheck:!1,mode:null,minPadding:5,description:"",customIcon:null,customDirectionIcon:(E$={},nm(E$,aC.FaceDirection.LEFT,ay.createElement(O$,{type:aC.FaceDirection.LEFT})),nm(E$,aC.FaceDirection.RIGHT,ay.createElement(O$,{type:aC.FaceDirection.RIGHT})),nm(E$,aC.FaceDirection.UP,ay.createElement(O$,{type:aC.FaceDirection.UP})),nm(E$,aC.FaceDirection.FRONTAL,ay.createElement(O$,{type:aC.FaceDirection.FRONTAL})),E$),onLivenessDetectionDone:null,onClose:null,onError:function(){},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:function(){},apiCredentials:{accessKey:"5767c20d-87aa-4cad-8dbb-f5429f76c34b",secretKey:"c1446919-e60a-4575-a05d-304318212a1b",apiUrl:"https://tv-testing.trustingsocial.com/api"},enableInstructionsOverlay:!0,enableErrorOverlay:!0,enableCapturingOverlay:!0,backgroundColor:"#ffffff",textColor:"inherit",progressProps:{activeColor:"#06498C",dashedRingWidth:5,dashedRingColor:"#DAECFF",dashedRingOpacity:1,dashedInsideRingWidth:0,dashedRingLineThick:2,dashedRingLineSpacing:2,errorRingWidth:2},title:"Identity verification",customInstructions:(k$={},nm(k$,aC.FaceDirection.LEFT,{vi:"Vui lòng quay đầu sang trái",en:"Please turn to the left"}),nm(k$,aC.FaceDirection.RIGHT,{vi:"Vui lòng quay đầu sang phải",en:"Please turn to the right"}),nm(k$,aC.FaceDirection.UP,{vi:"Vui lòng nhìn lên",en:"Please look up"}),nm(k$,aC.FaceDirection.FRONTAL,{vi:"Vui lòng nhìn thẳng vào máy ảnh",en:"Please look straight into the camera"}),k$),onProcessing:function(){},customErrors:null,livenessSettings:null,outputEncryptionSettings:null};var fZ=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dZ=/^\w*$/;var pZ=function(e,t){if(SQ(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!fW(e))||(dZ.test(e)||!fZ.test(e)||null!=t&&e in Object(t))},hZ=XG(Object,"create");var gZ=function(){this.__data__=hZ?hZ(null):{},this.size=0};var mZ=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},yZ=Object.prototype.hasOwnProperty;var vZ=function(e){var t=this.__data__;if(hZ){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return yZ.call(t,e)?t[e]:void 0},bZ=Object.prototype.hasOwnProperty;var CZ=function(e){var t=this.__data__;return hZ?void 0!==t[e]:bZ.call(t,e)};var wZ=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=hZ&&void 0===t?"__lodash_hash_undefined__":t,this};function EZ(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])}}EZ.prototype.clear=gZ,EZ.prototype.delete=mZ,EZ.prototype.get=vZ,EZ.prototype.has=CZ,EZ.prototype.set=wZ;var kZ=EZ;var SZ=function(){this.__data__=[],this.size=0};var BZ=function(e,t){for(var r=e.length;r--;)if(ZG(e[r][0],t))return r;return-1},TZ=Array.prototype.splice;var AZ=function(e){var t=this.__data__,r=BZ(t,e);return!(r<0)&&(r==t.length-1?t.pop():TZ.call(t,r,1),--this.size,!0)};var IZ=function(e){var t=this.__data__,r=BZ(t,e);return r<0?void 0:t[r][1]};var _Z=function(e){return BZ(this.__data__,e)>-1};var xZ=function(e,t){var r=this.__data__,n=BZ(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function RZ(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])}}RZ.prototype.clear=SZ,RZ.prototype.delete=AZ,RZ.prototype.get=IZ,RZ.prototype.has=_Z,RZ.prototype.set=xZ;var PZ=RZ,NZ=XG(kG,"Map");var LZ=function(){this.size=0,this.__data__={hash:new kZ,map:new(NZ||PZ),string:new kZ}};var OZ=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var DZ=function(e,t){var r=e.__data__;return OZ(t)?r["string"==typeof t?"string":"hash"]:r.map};var UZ=function(e){var t=DZ(this,e).delete(e);return this.size-=t?1:0,t};var MZ=function(e){return DZ(this,e).get(e)};var VZ=function(e){return DZ(this,e).has(e)};var jZ=function(e,t){var r=DZ(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function FZ(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])}}FZ.prototype.clear=LZ,FZ.prototype.delete=UZ,FZ.prototype.get=MZ,FZ.prototype.has=VZ,FZ.prototype.set=jZ;var zZ=FZ;function KZ(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],o=r.cache;if(o.has(i))return o.get(i);var a=e.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(KZ.Cache||zZ),r}KZ.Cache=zZ;var qZ=KZ;var HZ=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,GZ=/\\(\\)?/g,QZ=function(e){var t=qZ(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(HZ,(function(e,r,n,i){t.push(n?i.replace(GZ,"$1"):r||e)})),t}));var WZ=function(e,t){return SQ(e)?e:pZ(e,t)?[e]:QZ(gW(e))};var XZ=function(e){if("string"==typeof e||fW(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var YZ=function(e,t){for(var r=0,n=(t=WZ(t,e)).length;null!=e&&r<n;)e=e[XZ(t[r++])];return r&&r==n?e:void 0};var $Z=function(e,t,r){var n=null==e?void 0:YZ(e,t);return void 0===n?r:n},ZZ=["tracking","clientSettings"];function JZ(e){var t=e.tracking,r=e.clientSettings,n=lm(e,ZZ),i=ay.useMemo((function(){return $Z(r,"data.settings.sdk_settings.server_log_settings.enable",null==t?void 0:t.enable)}),[r,t]);return ay.createElement(zk.SDKTrackingProvider,{value:{tracking:am(am({},t),{},{enable:i})}},ay.createElement(YY,im({},n,{clientSettings:r})))}JZ.propTypes={tracking:Ry.shape({}),clientSettings:Ry.shape({})},JZ.defaultProps={tracking:void 0,clientSettings:void 0};var eJ=["onClose","onError","detectIdCard","steps","onStepDone","apiCredentials","tracking","outputEncryptionSettings"],tJ=aC.Errors,rJ=function(e){var t=e.onClose,r=e.onError,n=e.detectIdCard,i=e.steps,o=e.onStepDone,a=e.apiCredentials,s=e.tracking,c=e.outputEncryptionSettings,u=lm(e,eJ),l=dm(ay.useState(null),2),f=l[0],d=l[1],p=YB.useApiClient({apiCredentials:a,tracking:s}).apiClient,h=ay.useRef(""),g=ay.useRef("");ay.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,p.clientSettings();case 2:t=e.sent,d(t);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[p]);var m=ay.useCallback(function(){var e=Jg(regeneratorRuntime.mark((function e(t){var n,a,s,u,l,f,d,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.stepNumber,a=t.recordedVideos,s=t.qrScannedResult,u=t.image,l=i[n],f=l.cardType,d=l.cardSide,m=null,e.prev=3,e.next=6,lG({image:u,cardSide:d,frontCardId:h.current,qrImageId:g.current,onError:r,apiClient:p,cardType:f,recordedVideos:a,qrScannedResult:s,outputEncryptionSettings:c});case 6:m=e.sent,d===aC.IDCardSide.FRONT&&(h.current=m.cardInfo.image1.id),g.current=m.qrImageId,e.next=14;break;case 11:e.prev=11,e.t0=e.catch(3),r(am(am({},tJ.api_call_error),{},{details:e.t0}));case 14:m&&o(am(am({},t),{},{apiResult:m}));case 15:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t){return e.apply(this,arguments)}}(),[p,r,i,o,c]);return f&&ay.createElement(JZ,im({tracking:s,onClose:t,onError:r,detectIdCard:n,onStepDone:m,steps:i,outputEncryptionSettings:c},u,{clientSettings:f}))};rJ.propTypes={onClose:Ry.func,onError:Ry.func,detectIdCard:Ry.func,onStepDone:Ry.func,steps:Ry.arrayOf(Ry.shape({})),apiCredentials:Ry.shape({accessKey:Ry.string,secretKey:Ry.string,apiUrl:Ry.string}),tracking:Ry.shape({}),outputEncryptionSettings:Ry.shape({})},rJ.defaultProps={onClose:function(){},onError:function(){},detectIdCard:function(){return Promise.resolve({card_label:""})},onStepDone:function(){},steps:QY,apiCredentials:{accessKey:"5767c20d-87aa-4cad-8dbb-f5429f76c34b",secretKey:"c1446919-e60a-4575-a05d-304318212a1b",apiUrl:"https://tv-testing.trustingsocial.com/api"},outputEncryptionSettings:{key:""},tracking:void 0};var nJ=kk.getUAMetadata(),iJ=function(){function e(t){var r=this,n=t.container,i=t.lang,o=void 0===i?"en":i,a=t.assetRoot,s=void 0===a?"https://unpkg.com/@tsocial/tvweb-sdk@latest/assets":a,c=t.resourceRoot,u=t.customUrls,l=void 0===u?{}:u,f=t.enableAntiDebug,d=void 0===f||f;em(this,e),nm(this,"checkCamera",UF),nm(this,"initNativeCamera",(function(e){var t=document.createElement("div");document.body.appendChild(t);var r=ay.createRef();return yD.render(ay.createElement(VF,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",zK(t));case 2:case"end":return e.stop()}}),e)})))),nm(this,"runPreloadEKYCResources",Jg(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.commonSettings.customUrls,mG(t);case 2:case"end":return e.stop()}}),e)})))),nm(this,"destroyView",(function(){yD.unmountComponentAtNode(r.container)})),a$(n,"container is a required parameter"),this.container=n,this.container.style="touch-action: none; -ms-touch-action: none;";var p=ok({resourceRoot:c,initCustomUrls:l});this.commonSettings={lang:o,assetRoot:s,customUrls:p,enableAntiDebug:d,debug:!1}}return rm(e,[{key:"readIDCardWithApiCall",value:function(e){yD.render(ay.createElement(lk.SDKSettingsProvider,{value:am(am({},this.commonSettings),{},{container:this.container})},ay.createElement(rJ,im({onClose:this.destroyView},e))),this.container)}},{key:"readIDCardUIOnly",value:function(e){yD.render(ay.createElement(lk.SDKSettingsProvider,{value:am(am({},this.commonSettings),{},{container:this.container})},ay.createElement(JZ,e)),this.container)}},{key:"livenessDetection",value:function(e){yD.render(ay.createElement(lk.SDKSettingsProvider,{value:am(am({},this.commonSettings),{},{container:this.container})},ay.createElement(lZ,e)),this.container)}},{key:"compareFaces",value:function(e){var t=e.accessKey,r=e.secretKey,n=e.apiUrl,i=e.image1,o=e.image2,a=e.onSuccess,s=e.onError;YB.createRetryAPIClient(new s$(t,r,n,{httpHeaders:nJ})).compareFaces({image1:{id:i},image2:{id:o}}).then((function(e){a(e)})).catch((function(e){s(e)}))}}]),e}();exports.APIUtils=YB,exports.Animations=Gz,exports.AntiDebugUtils=bT,exports.AssetUtils=Hk,exports.AsyncUtils=Qk,exports.BASE_Z_INDEX=1e3,exports.BlurUtils=yS,exports.Button=dq,exports.ButtonLink=pq,exports.Camera=gU,exports.CameraUtils=bS,exports.CommonUtils=wS,exports.Constants=aC,exports.CoordinateUtils=TS,exports.CropAreaOverlayWrapper=wU,exports.CryptoUtils=ET,exports.FaceUtils=LS,exports.GlareUtils=jB,exports.HashUtils=Nk,exports.HighlightResult=vH,exports.HighlightResultType=fH,exports.Icons=FF,exports.ImageUtils=DB,exports.LivenessDetection=WF,exports.LivenessDetectionComponents=bG,exports.LoadResourceUtils=oT,exports.LocalStorageUtils=_k,exports.MobileDetect=WD,exports.ModelUtils=vT,exports.NativeCamera=VF,exports.PlacementArea=CU,exports.Popup=Yj,exports.PredictionUtils=MS,exports.ProgressCircle=Uj,exports.RatioWrapper=Rq,exports.ReadIDCardUIOnly=$H,exports.ReadIDCardWithApiCall=hG,exports.RectangleMask=pz,exports.RectangleMaskType=dz,exports.SDK=iJ,exports.ScannerType=GH,exports.SettingsContext=lk,exports.Spacing=oq,exports.ThemeUtils=CT,exports.TimeUtils=Tk,exports.TrackingContext=zk,exports.UserAgentUtils=kk,exports.WarmupPopup=gF,exports.checkCamera=UF,exports.defaultClientSettings=jH,exports.defaultReadIDCardSteps=QY,exports.getCustomUrlsBySettings=ok,exports.getQrScannerWorkerPath=kT,exports.handleApiCheckReadIdCard=lG,exports.preloadEKYCResources=mG,exports.readIdCardFromImage=yG,exports.readQRCodeFromImage=nH,exports.useLivenessDetection=vG,exports.useMainProcessQRCodeScanner=iH,exports.useMainProcessReadIdCard=XK,exports.useSettingsReadIdCard=FH,exports.useShowPopup=pK,exports.warmUpQRCodeScanner=Kq,exports.warmUpReadIdCard=zK,exports.warmupSelfieActive=fj;
75
+ ***************************************************************************** */function o(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function a(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,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(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(a,s)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,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}(),f=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}(),d=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 w(e,t){return e(t={exports:{}},t.exports),t.exports}var E=w((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 o=t.join("/"),a=(o=o.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return a.shift()+(a.length>0?"?":"")+a.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 o=/\+/g;e=e.split(t);var a=1e3;n&&"number"==typeof n.maxKeys&&(a=n.maxKeys);var s=e.length;a>0&&s>a&&(s=a);for(var c=0;c<s;++c){var u,l,f,d,p=e[c].replace(o,"%20"),h=p.indexOf(r);h>=0?(u=p.substr(0,h),l=p.substr(h+1)):(u=p,l=""),f=decodeURIComponent(u),d=decodeURIComponent(l),k(i,f)?Array.isArray(i[f])?i[f].push(d):i[f]=[i[f],d]:i[f]=d}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=w((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)),o=this.resolveUrl(e);return this.request(o,{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,o,a,s;return c(this,(function(c){switch(c.label){case 0:return n={},o={},this.authorizer&&(n=this.authorizer.getHeaders(t)),this.configHeaders&&(o=this.configHeaders),t.headers=i(i(i({},t.headers),n),o),[4,fetch(e,t)];case 1:return a=c.sent(),[4,"blob"===r?a.blob():a.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 E(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}(),R=w((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={},o=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)}},a=i.WordArray=o.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 o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>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=o.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)}},o=0;o<t;o+=4){var s=i(4294967296*(r||e.random()));r=987654071*s(),n.push(4294967296*s()|0)}return new a.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 o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).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 a.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 o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}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 a.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)))}},f=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new a.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,o=this.blockSize,s=i/(4*o),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*o,u=e.min(4*c,i);if(c){for(var l=0;l<c;l+=o)this._doProcessBlock(n,l);var f=n.splice(0,c);r.sigBytes-=u}return new a.init(f,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),d=(i.Hasher=f.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.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 d.HMAC.init(e,r).finalize(t)}}}),n.algo={});return n}(Math)})),P=w((function(e,t){var r,n,i;e.exports=(n=(r=i=R).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>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 o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(t=s)}return function(e,t,r){for(var i=[],o=0,a=0;a<t;a++)if(a%4){var s=r[e.charCodeAt(a-1)]<<a%4*2,c=r[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=(s|c)<<24-o%4*8,o++}return n.create(i,o)}(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)})),N=(w((function(e,t){var r;e.exports=(r=R,function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=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=a.SHA256=o.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],o=r[2],a=r[3],s=r[4],l=r[5],f=r[6],d=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&o^i&o,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),C=d+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&l^~s&f)+c[p]+u[p];d=f,f=l,l=s,s=a+C|0,a=o,o=i,i=n,n=C+(b+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+s|0,r[5]=r[5]+l|0,r[6]=r[6]+f|0,r[7]=r[7]+d|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=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=o._createHelper(l),t.HmacSHA256=o._createHmacHelper(l)}(Math),r.SHA256)})),w((function(e,t){var r,n,i;e.exports=(n=(r=R).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 o=this._oKey=t.clone(),a=this._iKey=t.clone(),s=o.words,c=a.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=a.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))}})))})),w((function(e,t){e.exports=R.HmacSHA256}))),L=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=P.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 O(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,o=new L(e,t),a=O(r);return new _({authorizer:o,domain:a,headers:i})}var U=function(){function e(e){void 0===e&&(e="production");var t=new _({domain:O(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 o=n.value,a=i({},n);return a.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,a,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 o=arguments[t],a=0,s=o.length;a<s;a++,i++)n[i]=o[a];return n}(e),(a=i({},n[t]))["X-TV-Transaction"]=r,n[t]=a,[4,o.apply(this,n)];case 2:return s=c.sent(),[4,this.transactionManager.end()];case 3:return c.sent(),[2,s];case 4:return[4,o.apply(this,e)];case 5:return[2,c.sent()]}}))}))},a}}function V(e){return void 0===e&&(e={encryptedField:"data"}),function(t,r,n){var o=n.value,a=i({},n);return a.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,o.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]}}))}))},a}}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(),o=setInterval((function(){e===r.currentTransaction&&(clearInterval(o),t(!0)),window.performance.now()-i>=3e3&&(clearInterval(o),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,o=t.length,a=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%o,u=u/o|0;for(;u>0;)s.push(u%o),u=u/o|0}for(i=0;0===e[i]&&i<e.length-1;++i)n+=a;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),o=[0];for(r=0;r<e.length();++r){for(var a=0,s=e.at(r);a<o.length;++a)s+=o[a]<<8,o[a]=s%n,s=s/n|0;for(;s>0;)o.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=o.length-1;r>=0;--r)c+=t[o[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,o=t.charAt(0),a=[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<a.length;++c)u+=a[c]*i,a[c]=255&u,u>>=8;for(;u>0;)a.push(255&u),u>>=8}for(var l=0;e[l]===o&&l<e.length-1;++l)a.push(0);return"undefined"!=typeof Buffer?Buffer.from(a.reverse()):new Uint8Array(a.reverse())},w((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,o=document.createElement("div");r=[],new MutationObserver((function(){var e=r.slice();r.length=0,e.forEach((function(e){e()}))})).observe(o,{attributes:!0});var a=t.setImmediate;t.setImmediate=function(e){Date.now()-n>15?(n=Date.now(),a(e)):(r.push(e),1===r.length&&o.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 o;if("hex"===r)return this.accommodate(Math.ceil(e.length/2)),o=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.hex.decode(e,o,this.write),this;if("base64"===r)return this.accommodate(3*Math.ceil(e.length/4)),o=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.base64.decode(e,o,this.write),this;if("utf8"===r&&(e=t.encodeUtf8(e),r="binary"),"binary"===r||"raw"===r)return this.accommodate(e.length),o=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.raw.decode(o),this;if("utf16"===r)return this.accommodate(2*e.length),o=new Uint16Array(this.data.buffer,this.write),this.write+=t.text.utf16.encode(o),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="",o="",a=0,s=0;r>0;--r,++a)i=e.charCodeAt(a)^t.charCodeAt(a),s>=10&&(n+=o,o="",s=0),o+=String.fromCharCode(i),++s;return n+o},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+/=",o=[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],a="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";t.encode64=function(e,t){for(var r,n,o,a="",s="",c=0;c<e.length;)r=e.charCodeAt(c++),n=e.charCodeAt(c++),o=e.charCodeAt(c++),a+=i.charAt(r>>2),a+=i.charAt((3&r)<<4|n>>4),isNaN(n)?a+="==":(a+=i.charAt((15&n)<<2|o>>6),a+=isNaN(o)?"=":i.charAt(63&o)),t&&a.length>t&&(s+=a.substr(0,t)+"\r\n",a=a.substr(t));return s+a},t.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,a="",s=0;s<e.length;)t=o[e.charCodeAt(s++)-43],r=o[e.charCodeAt(s++)-43],n=o[e.charCodeAt(s++)-43],i=o[e.charCodeAt(s++)-43],a+=String.fromCharCode(t<<2|r>>4),64!==n&&(a+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(a+=String.fromCharCode((3&n)<<6|i)));return a},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,o=0;o<e.length;++o)n[i++]=e.charCodeAt(o);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,o=r=r||0;for(1&e.length&&(i=1,n[o++]=parseInt(e[0],16));i<e.length;i+=2)n[o++]=parseInt(e.substr(i,2),16);return t?o-r:n},t.binary.base64.encode=function(e,t){for(var r,n,o,a="",s="",c=0;c<e.byteLength;)r=e[c++],n=e[c++],o=e[c++],a+=i.charAt(r>>2),a+=i.charAt((3&r)<<4|n>>4),isNaN(n)?a+="==":(a+=i.charAt((15&n)<<2|o>>6),a+=isNaN(o)?"=":i.charAt(63&o)),t&&a.length>t&&(s+=a.substr(0,t)+"\r\n",a=a.substr(t));return s+a},t.binary.base64.decode=function(e,t,r){var n,i,a,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=o[e.charCodeAt(u++)-43],i=o[e.charCodeAt(u++)-43],a=o[e.charCodeAt(u++)-43],s=o[e.charCodeAt(u++)-43],c[l++]=n<<2|i>>4,64!==a&&(c[l++]=(15&i)<<4|a>>2,64!==s&&(c[l++]=(3&a)<<6|s));return t?l-r:c.subarray(0,l)},t.binary.base58.encode=function(e,r){return t.binary.baseN.encode(e,a,r)},t.binary.base58.decode=function(e,r){return t.binary.baseN.decode(e,a,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 o=n=n||0,a=0;a<e.length;++a)i[o++]=e.charCodeAt(a);return r?o-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),o=r=r||0,a=r,s=0;s<e.length;++s)i[a++]=e.charCodeAt(s),o+=2;return t?o-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 o=new Error(i.error.message);throw o.id=i.error.id,o.name=i.error.name,o}},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},f=function(e,t,r){var n=c(e,t);if(null!==n&&r in n){delete n[r];var i=!0;for(var o in n){i=!1;break}i&&(n=null),s(e,t,n)}},d=function(e,t){s(e,t,null)},p=function(e,t,r){var n,i=null;void 0===r&&(r=["web","flash"]);var o=!1,a=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),o="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,i=e.apply(this,t),o=!0)}catch(e){a=e}if(o)break}if(!o)throw a;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(f,arguments,n)},t.clearItems=function(e,t,r){p(d,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,o,a=r[n].indexOf("=");a>0?(i=r[n].substring(0,a),o=r[n].substring(a+1)):(i=r[n],o=null),i in t||(t[i]=[]),i in Object.prototype||null===o||t[i].push(unescape(o))}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 o=r.split("/");return o.length>0&&""===o[0]&&o.shift(),{pathString:r,queryString:n,path:o,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 o=t[n++];if(n==i)e[o]=r;else{var a=o in e;(!a||a&&"object"!=typeof e[o]||a&&null===e[o])&&(e[o]={}),e=e[o]}}},t.getPath=function(e,t,r){for(var n=0,i=t.length,o=!0;o&&n<i&&"object"==typeof e&&null!==e;){var a=t[n++];(o=a in e)&&(e=e[a])}return o?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,o=[],a=0;t=n.exec(e);){(r=e.substring(a,n.lastIndex-2)).length>0&&o.push(r),a=n.lastIndex;var s=t[0][1];switch(s){case"s":case"o":i<arguments.length?o.push(arguments[1+i++]):o.push("<?>");break;case"%":o.push("%");break;default:o.push("<%"+s+"?>")}}return o.push(e.substring(a)),o.join("")},t.formatNumber=function(e,t,r,n){var i=e,o=isNaN(t=Math.abs(t))?2:t,a=void 0===r?",":r,s=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(o),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)+(o?a+Math.abs(i-u).toFixed(o).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(),o=0;o<8;++o)if(e[o]&&0!==e[o].length){var a=t.hexToBytes(e[o]);a.length<2&&i.putByte(0),i.putBytes(a)}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,o=0;o<e.length;o+=2){for(var a=t.bytesToHex(e[o]+e[o+1]);"0"===a[0]&&"0"!==a;)a=a.substr(1);if("0"===a){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(a)}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,o,a){if(0===o){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=[],o=0;o<e;++o){var a=new Worker(n);a.addEventListener("message",(function(n){if(i.push(n.data),i.length===e){for(var o=0;o<e;++o)r[o].terminate();t(null,i)}})),r.push(a)}for(o=0;o<e;++o)r[o].postMessage(o)}(a,(function(t,r){i.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var i=t[n],o=r[n]=[],a=0;a<e;++a)if(n!==a){var s=t[a];(i.st>s.st&&i.st<s.et||s.st>i.st&&s.st<i.et)&&o.push(a)}return r.reduce((function(e,t){return Math.max(e,t.length)}),0)}(a,r)),e(i,o-1,a)}))}([],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)))},w((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=[],o=t/4;for(n=0;n<o;++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 o=(this.blockSize-n)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(o>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),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!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 o=(this.blockSize-n)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(o>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),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!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 o=(this.blockSize-n)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o>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),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!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 o=0;o<this._ints;++o)t.putInt32(e.getInt32()^this._outBlock[o]);else{var a=(this.blockSize-i)%this.blockSize;for(a>0&&(a=this.blockSize-a),this._partialOutput.clear(),o=0;o<this._ints;++o)this._partialOutput.putInt32(e.getInt32()^this._outBlock[o]);if(a>0&&(e.read-=this.blockSize),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(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 o=r.length();if(12===o)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*o)))}this._inBlock=this._j0.slice(0),n(this._inBlock),this._partialBytes=0,t=F.util.createBuffer(t),this._aDataLength=i(8*t.length());var a=t.length()%this.blockSize;for(a&&t.fillWithByte(0,this.blockSize-a),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 o=0;o<this._ints;++o)t.putInt32(this._outBlock[o]^=e.getInt32());this._cipherLength+=this.blockSize}else{var a=(this.blockSize-i)%this.blockSize;for(a>0&&(a=this.blockSize-a),this._partialOutput.clear(),o=0;o<this._ints;++o)this._partialOutput.putInt32(e.getInt32()^this._outBlock[o]);if(a<=0||r){if(r){var s=i%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(o=0;o<this._ints;++o)this._outBlock[o]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!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 o=0;o<this._ints;++o)t.putInt32(this._outBlock[o]^this._hashBlock[o]);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 o=[];this.cipher.encrypt(this._j0,o);for(var a=0;a<this._ints;++a)this.tag.putInt32(this._s[a]^o[a]);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,o=new Array(i),a=0;a<i;++a){var s=[0,0,0,0],c=(n-1-a%n)*t;s[a/n|0]=1<<t-1<<c,o[a]=this.generateSubHashTable(this.multiply(s,e),t)}return o},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 o=n>>>1;o>0;)this.pow(i[2*o],i[o]=[]),o>>=1;for(o=2;o<n;){for(var a=1;a<o;++a){var s=i[o],c=i[a];i[o+a]=[s[0]^c[0],s[1]^c[1],s[2]^c[2],s[3]^c[3]]}o*=2}for(i[0]=[0,0,0,0],o=n+1;o<r;++o){var u=i[o^n];i[o]=[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 o=this.mode.name,a=-1!==["CFB","OFB","CTR","GCM"].indexOf(o);this._w=te(r,e.decrypt&&!a),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,o,a,s,c,u=0,l=0;for(t=0;t<256;++t){o=(o=l^l<<1^l<<2^l<<3^l<<4)>>8^255&o^99,Q[u]=o,W[o]=u,s=(a=e[o])<<24^o<<16^o<<8^o^a,c=((r=e[u])^(n=e[r])^(i=e[n]))<<24^(u^i)<<16^(u^n^i)<<8^u^r^i;for(var f=0;f<4;++f)Y[f][u]=s,$[f][o]=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,o=n.length,a=J*(o+6+1),s=o;s<a;++s)r=n[s-1],s%o==0?(r=Q[r>>>16&255]<<24^Q[r>>>8&255]<<16^Q[255&r]<<8^Q[r>>>24]^X[i]<<24,i++):o>6&&s%o==4&&(r=Q[r>>>24]<<24^Q[r>>>16&255]<<16^Q[r>>>8&255]<<8^Q[255&r]),n[s]=n[s-o]^r;if(t){for(var c,u=$[0],l=$[1],f=$[2],d=$[3],p=n.slice(0),h=(s=0,(a=n.length)-J);s<a;s+=J,h-=J)if(0===s||s===a-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]]^f[Q[c>>>8&255]]^d[Q[255&c]];n=p}return n}function re(e,t,r,n){var i,o,a,s,c,u,l,f,d,p,h,g,m=e.length/4-1;n?(i=$[0],o=$[1],a=$[2],s=$[3],c=W):(i=Y[0],o=Y[1],a=Y[2],s=Y[3],c=Q),u=t[0]^e[0],l=t[n?3:1]^e[1],f=t[2]^e[2],d=t[n?1:3]^e[3];for(var y=3,v=1;v<m;++v)p=i[u>>>24]^o[l>>>16&255]^a[f>>>8&255]^s[255&d]^e[++y],h=i[l>>>24]^o[f>>>16&255]^a[d>>>8&255]^s[255&u]^e[++y],g=i[f>>>24]^o[d>>>16&255]^a[u>>>8&255]^s[255&l]^e[++y],d=i[d>>>24]^o[u>>>16&255]^a[l>>>8&255]^s[255&f]^e[++y],u=p,l=h,f=g;r[0]=c[u>>>24]<<24^c[l>>>16&255]<<16^c[f>>>8&255]<<8^c[255&d]^e[++y],r[n?3:1]=c[l>>>24]<<24^c[f>>>16&255]<<16^c[d>>>8&255]<<8^c[255&u]^e[++y],r[2]=c[f>>>24]<<24^c[d>>>16&255]<<16^c[u>>>8&255]<<8^c[255&l]^e[++y],r[n?1:3]=c[d>>>24]<<24^c[u>>>16&255]<<16^c[l>>>8&255]<<8^c[255&f]^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)}))}w((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")})),w((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,o){if(F.util.isArray(i)){for(var a=[],s=0;s<i.length;++s)void 0!==i[s]&&a.push(i[s]);i=a}var c={tagClass:e,type:r,constructed:n,composed:n||F.util.isArray(i),value:i};return o&&"bitStringContents"in o&&(c.bitStringContents=o.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 o=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&&(o=o&&e.bitStringContents===r.bitStringContents),o},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 o=127&n;r(e,t,o),i=e.getInt(o<<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,o,a,s){var c;r(i,o,2);var u=i.getByte();o--;var l=192&u,f=31&u;c=i.length();var d,p,h=n(i,o);if(o-=c-i.length(),void 0!==h&&h>o){if(s.strict){var g=new Error("Too few bytes to read ASN.1 value.");throw g.available=i.length(),g.remaining=o,g.requested=h,g}h=o}var m=32==(32&u);if(m)if(d=[],void 0===h)for(;;){if(r(i,o,2),i.bytes(2)===String.fromCharCode(0,0)){i.getBytes(2),o-=2;break}c=i.length(),d.push(e(i,o,a+1,s)),o-=c-i.length()}else for(;h>0;)c=i.length(),d.push(e(i,h,a+1,s)),o-=c-i.length(),h-=c-i.length();if(void 0===d&&l===t.Class.UNIVERSAL&&f===t.Type.BITSTRING&&(p=i.bytes(h)),void 0===d&&s.decodeBitStrings&&l===t.Class.UNIVERSAL&&f===t.Type.BITSTRING&&h>1){var y=i.read,v=o,b=0;if(f===t.Type.BITSTRING&&(r(i,o,1),b=i.getByte(),o--),0===b)try{c=i.length();var C=e(i,o,a+1,{verbose:s.verbose,strict:!0,decodeBitStrings:!0}),w=c-i.length();o-=w,f==t.Type.BITSTRING&&w++;var E=C.tagClass;w!==h||E!==t.Class.UNIVERSAL&&E!==t.Class.CONTEXT_SPECIFIC||(d=[C])}catch(e){}void 0===d&&(i.read=y,o=v)}if(void 0===d){if(void 0===h){if(s.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");h=o}if(f===t.Type.BMPSTRING)for(d="";h>0;h-=2)r(i,o,2),d+=String.fromCharCode(i.getInt16()),o-=2;else d=i.getBytes(h)}var k=void 0===p?null:{bitStringContents:p};return t.create(l,f,m,d,k)}(e,e.length(),0,i)},t.toDer=function(e){var r=F.util.createBuffer(),n=e.tagClass|e.type,i=F.util.createBuffer(),o=!1;if("bitStringContents"in e&&(o=!0,e.original&&(o=t.equals(e,e.original))),o)i.putBytes(e.bitStringContents);else if(e.composed){e.constructed?n|=32:i.putByte(0);for(var a=0;a<e.value.length;++a)void 0!==e.value[a]&&i.putBuffer(t.toDer(e.value[a]))}else if(e.type===t.Type.BMPSTRING)for(a=0;a<e.value.length;++a)i.putInt16(e.value.charCodeAt(a));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),a=c.length-1;a>=0;--a)r.putByte(c.charCodeAt(a))}return r.putBuffer(i),r},t.oidToDer=function(e){var t,r,n,i,o=e.split("."),a=F.util.createBuffer();a.putByte(40*parseInt(o[0],10)+parseInt(o[1],10));for(var s=2;s<o.length;++s){t=!0,r=[],n=parseInt(o[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)a.putByte(r[c])}return a},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),o=parseInt(e.substr(6,2),10),a=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(o,a,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),o=parseInt(e.substr(8,2),10),a=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 f=e.length-5,d=e.charAt(f);return"+"!==d&&"-"!==d||(u=60*parseInt(e.substr(f+1,2),10)+parseInt(e.substr(f+4,2),10),u*=6e4,"+"===d&&(u*=-1),l=!0),"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(o,a,s,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(o,a,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 o=!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(o=!0,r.value&&F.util.isArray(r.value))for(var a=0,s=0;o&&s<r.value.length;++s)o=r.value[s].optional||!1,e.value[a]&&((o=t.validate(e.value[a],r.value[s],n,i))?++a:r.value[s].optional&&(o=!0)),!o&&i&&i.push("["+r.name+'] Tag class "'+r.tagClass+'", type "'+r.type+'" expected value length "'+r.value.length+'", got "'+e.value.length+'"');if(o&&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 o};var i=/[^\\u0000-\\u00ff]/;t.prettyPrint=function(e,r,n){var o="";n=n||2,(r=r||0)>0&&(o+="\n");for(var a="",s=0;s<r*n;++s)a+=" ";switch(o+=a+"Tag: ",e.tagClass){case t.Class.UNIVERSAL:o+="Universal:";break;case t.Class.APPLICATION:o+="Application:";break;case t.Class.CONTEXT_SPECIFIC:o+="Context-Specific:";break;case t.Class.PRIVATE:o+="Private:"}if(e.tagClass===t.Class.UNIVERSAL)switch(o+=e.type,e.type){case t.Type.NONE:o+=" (None)";break;case t.Type.BOOLEAN:o+=" (Boolean)";break;case t.Type.INTEGER:o+=" (Integer)";break;case t.Type.BITSTRING:o+=" (Bit string)";break;case t.Type.OCTETSTRING:o+=" (Octet string)";break;case t.Type.NULL:o+=" (Null)";break;case t.Type.OID:o+=" (Object Identifier)";break;case t.Type.ODESC:o+=" (Object Descriptor)";break;case t.Type.EXTERNAL:o+=" (External or Instance of)";break;case t.Type.REAL:o+=" (Real)";break;case t.Type.ENUMERATED:o+=" (Enumerated)";break;case t.Type.EMBEDDED:o+=" (Embedded PDV)";break;case t.Type.UTF8:o+=" (UTF8)";break;case t.Type.ROID:o+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:o+=" (Sequence)";break;case t.Type.SET:o+=" (Set)";break;case t.Type.PRINTABLESTRING:o+=" (Printable String)";break;case t.Type.IA5String:o+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:o+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:o+=" (Generalized time)";break;case t.Type.BMPSTRING:o+=" (BMP String)"}else o+=e.type;if(o+="\n",o+=a+"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+=","));o+=a+"Sub values: "+c+u}else{if(o+=a+"Value: ",e.type===t.Type.OID){var l=t.derToOid(e.value);o+=l,F.pki&&F.pki.oids&&l in F.pki.oids&&(o+=" ("+F.pki.oids[l]+") ")}if(e.type===t.Type.INTEGER)try{o+=t.derToInteger(e.value)}catch(t){o+="0x"+F.util.bytesToHex(e.value)}else if(e.type===t.Type.BITSTRING){if(e.value.length>1?o+="0x"+F.util.bytesToHex(e.value.slice(1)):o+="(none)",e.value.length>0){var f=e.value.charCodeAt(0);1==f?o+=" (1 unused bit shown)":f>1&&(o+=" ("+f+" unused bits shown)")}}else e.type===t.Type.OCTETSTRING?(i.test(e.value)||(o+="("+e.value+") "),o+="0x"+F.util.bytesToHex(e.value)):e.type===t.Type.UTF8?o+=F.util.decodeUtf8(e.value):e.type===t.Type.PRINTABLESTRING||e.type===t.Type.IA5String?o+=e.value:i.test(e.value)?o+="0x"+F.util.bytesToHex(e.value):0===e.value.length?o+="[null]":o+=e.value}return o}})),F.md=F.md||{},F.md.algorithms=F.md.algorithms||{},w((function(e){(e.exports=F.hmac=F.hmac||{}).create=function(){var e=null,t=null,r=null,n=null,i={start:function(i,o){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===o)o=e;else{if("string"==typeof o)o=F.util.createBuffer(o);else if(F.util.isArray(o)){var a=o;o=F.util.createBuffer();for(var s=0;s<a.length;++s)o.putByte(a[s])}var c=o.length();for(c>t.blockLength&&(t.start(),t.update(o.bytes()),o=t.digest()),r=F.util.createBuffer(),n=F.util.createBuffer(),c=o.length(),s=0;s<c;++s)a=o.at(s),r.putByte(54^a),n.putByte(92^a);if(c<t.blockLength)for(a=t.blockLength-c,s=0;s<a;++s)r.putByte(54),n.putByte(92);e=o,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}})),w((function(e){var t=e.exports=F.md5=F.md5||{};F.md.md5=F.md.algorithms.md5=t,t.create=function(){a||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],o=new Array(64);for(var e=0;e<64;++e)o[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));a=!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 o=u.fullMessageLength.length-1;o>=0;--o)u.fullMessageLength[o]+=i[1],i[1]=i[0]+(u.fullMessageLength[o]/4294967296>>>0),u.fullMessageLength[o]=u.fullMessageLength[o]>>>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 o,a=0,l=u.fullMessageLength.length-1;l>=0;--l)a=(o=8*u.fullMessageLength[l]+a)/4294967296>>>0,n.putInt32Le(o>>>0);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};s(f,c,n);var d=F.util.createBuffer();return d.putInt32Le(f.h0),d.putInt32Le(f.h1),d.putInt32Le(f.h2),d.putInt32Le(f.h3),d},u};var r=null,n=null,i=null,o=null,a=!1;function s(e,t,r){for(var a,s,c,u,l,f,d,p=r.length();p>=64;){for(s=e.h0,c=e.h1,u=e.h2,l=e.h3,d=0;d<16;++d)t[d]=r.getInt32Le(),a=s+(l^c&(u^l))+o[d]+t[d],s=l,l=u,u=c,c+=a<<(f=i[d])|a>>>32-f;for(;d<32;++d)a=s+(u^l&(c^u))+o[d]+t[n[d]],s=l,l=u,u=c,c+=a<<(f=i[d])|a>>>32-f;for(;d<48;++d)a=s+(c^u^l)+o[d]+t[n[d]],s=l,l=u,u=c,c+=a<<(f=i[d])|a>>>32-f;for(;d<64;++d)a=s+(u^(c|~l))+o[d]+t[n[d]],s=l,l=u,u=c,c+=a<<(f=i[d])|a>>>32-f;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}}})),w((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 o=0,a=-1;for(i=0;i<t.length;++i,++o)if(o>65&&-1!==a){var s=t[a];","===s?(++a,t=t.substr(0,a)+"\r\n "+t.substr(a)):t=t.substr(0,a)+"\r\n"+s+t.substr(a+1),o=i-a-1,a=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(a=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 o=0;o<e.headers.length;++o)i+=r(e.headers[o]);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,o=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,a=/\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(a),u=0;t&&u<c.length;){for(var l=c[u].replace(/\s+$/,""),f=u+1;f<c.length;++f){var d=c[f];if(!/\s/.test(d[0]))break;l+=d,u=f}if(t=l.match(o)){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],o=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],a=[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],f=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[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 w=e.getInt32(),E=e.getInt32();w^=(t=252645135&(w>>>4^E))<<4,w^=t=65535&((E^=t)>>>-16^w),w^=(t=858993459&(w>>>2^(E^=t<<-16)))<<2,w^=t=65535&((E^=t)>>>-16^w),w^=(t=1431655765&(w>>>1^(E^=t<<-16)))<<1,w^=t=16711935&((E^=t)>>>8^w),t=(w^=(t=1431655765&(w>>>1^(E^=t<<8)))<<1)<<8|(E^=t)>>>20&240,w=E<<24|E<<8&16711680|E>>>8&65280|E>>>24&240,E=t;for(var k=0;k<v.length;++k){v[k]?(w=w<<2|w>>>26,E=E<<2|E>>>26):(w=w<<1|w>>>27,E=E<<1|E>>>27);var S=r[(w&=-15)>>>28]|n[w>>>24&15]|i[w>>>20&15]|o[w>>>16&15]|a[w>>>12&15]|s[w>>>8&15]|c[w>>>4&15],B=u[(E&=-15)>>>28]|l[E>>>24&15]|f[E>>>20&15]|d[E>>>16&15]|p[E>>>12&15]|h[E>>>8&15]|g[E>>>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 oe=[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],ae=[-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],fe=[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],de=[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,o,a=32===e.length?3:9;i=3===a?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^=(o=252645135&(s>>>4^c))<<4,s^=(o=65535&(s>>>16^(c^=o)))<<16,s^=o=858993459&((c^=o)>>>2^s),s^=o=16711935&((c^=o<<2)>>>8^s),s=(s^=(o=1431655765&(s>>>1^(c^=o<<8)))<<1)<<1|s>>>31,c=(c^=o)<<1|c>>>31;for(var u=0;u<a;u+=3){for(var l=i[u+1],f=i[u+2],d=i[u];d!=l;d+=f){var p=c^e[d],h=(c>>>4|c<<28)^e[d+1];o=s,s=c,c=o^(ae[p>>>24&63]|ce[p>>>16&63]|le[p>>>8&63]|de[63&p]|oe[h>>>24&63]|se[h>>>16&63]|ue[h>>>8&63]|fe[63&h])}o=s,s=c,c=o}c=c>>>1|c<<31,c^=o=1431655765&((s=s>>>1|s<<31)>>>1^c),c^=(o=16711935&(c>>>8^(s^=o<<1)))<<8,c^=(o=858993459&(c>>>2^(s^=o)))<<2,c^=o=65535&((s^=o)>>>16^c),c^=o=252645135&((s^=o<<16)>>>4^c),s^=o<<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,o){if("function"==typeof i&&(o=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"),o?4===ge.pbkdf2Sync.length?ge.pbkdf2(e,t,r,n,(function(e,t){if(e)return o(e);o(null,t.toString("binary"))})):ge.pbkdf2(e,t,r,n,i,(function(e,t){if(e)return o(e);o(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 a=i.digestLength;if(n>4294967295*a){var s=new Error("Derived key is too long.");if(o)return o(s);throw s}var c=Math.ceil(n/a),u=n-(c-1)*a,l=F.hmac.create();l.start(i,e);var f,d,p,h="";if(!o){for(var g=1;g<=c;++g){l.start(null,null),l.update(t),l.update(F.util.int32ToBytes(g)),f=p=l.digest().getBytes();for(var m=2;m<=r;++m)l.start(null,null),l.update(p),d=l.digest().getBytes(),f=F.util.xorBytes(f,d,a),p=d;h+=g<c?f:f.substr(0,u)}return h}function y(){if(g>c)return o(null,h);l.start(null,null),l.update(t),l.update(F.util.int32ToBytes(g)),f=p=l.digest().getBytes(),m=2,v()}function v(){if(m<=r)return l.start(null,null),l.update(p),d=l.digest().getBytes(),f=F.util.xorBytes(f,d,a),p=d,++m,F.util.setImmediate(v);h+=g<c?f:f.substr(0,u),++g,y()}g=1,y()},w((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(),a=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),o(e,a,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 f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};o(f,a,n);var d=F.util.createBuffer();return d.putInt32(f.h0),d.putInt32(f.h1),d.putInt32(f.h2),d.putInt32(f.h3),d.putInt32(f.h4),d.putInt32(f.h5),d.putInt32(f.h6),d.putInt32(f.h7),d},s};var r=null,n=!1,i=null;function o(e,t,r){for(var n,o,a,s,c,u,l,f,d,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,o=((o=t[c-15])>>>7|o<<25)^(o>>>18|o<<14)^o>>>3,t[c]=n+t[c-7]+o+t[c-16]|0;for(u=e.h0,l=e.h1,f=e.h2,d=e.h3,p=e.h4,h=e.h5,g=e.h6,m=e.h7,c=0;c<64;++c)a=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&l|f&(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=d+n>>>0,d=f,f=l,l=u,u=n+(o=a+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+f|0,e.h3=e.h3+d|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}}})),w((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),o=0;o<32;++o)i[o]=n.create();function a(){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 o=Math.max(1,Math.min(e-i.length(),65536)/4),a=new Uint32Array(Math.floor(o));try{t(a);for(var s=0;s<a.length;++s)i.putInt32(a[s])}catch(e){if(!("undefined"!=typeof QuotaExceededError&&e instanceof QuotaExceededError))throw e}}if(i.length()<e)for(var c,u,l,f=Math.floor(65536*Math.random());i.length()<e;)for(u=16807*(65535&f),u+=(32767&(c=16807*(f>>16)))<<16,f=4294967295&(u=(2147483647&(u+=c>>15))+(u>>31)),s=0;s<3;++s)l=f>>>(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,o=t.plugin.formatKey,a=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 f=n(t.key,t.seed);t.generated+=f.length,c.putBytes(f),t.key=o(n(t.key,i(t.seed))),t.seed=a(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,o=t.plugin.formatSeed;t.key=null;for(var s=F.util.createBuffer();s.length()<e;){t.generated>1048575&&(t.key=null),null===t.key&&a();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=o(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}})),w((function(e){F.random&&F.random.getBytes?e.exports=F.random:function(t){var r={},n=new Array(4),i=F.util.createBuffer();function o(){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 a=o(),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(a.collectInt(+new Date,32),"undefined"!=typeof navigator){var l="";for(var f in navigator)try{"string"==typeof navigator[f]&&(l+=navigator[f])}catch(e){}a.collect(l),l=null}t&&(t().mousemove((function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)})),t().keypress((function(e){a.collectInt(e.charCode,8)})))}if(F.random)for(var f in a)F.random[f]=a[f];else F.random=a;F.random.createInstance=o,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(),o=t,a=Math.ceil(o/8),s=255>>(7&o);for(r=i;r<128;r++)n.putByte(ye[n.at(r-1)+n.at(r-i)&255]);for(n.setAt(128-a,ye[n.at(128-a)&s]),r=127-a;r>=0;r--)n.setAt(r,ye[n.at(r+1)^n.at(r+a)]);return n};var we,Ee=function(e,t,r){var n,i,o,a,s=!1,c=null,u=null,l=null,f=[];for(e=F.rc2.expandKey(e,t),o=0;o<64;o++)f.push(e.getInt16Le());r?(n=function(e){for(o=0;o<4;o++)e[o]+=f[a]+(e[(o+3)%4]&e[(o+2)%4])+(~e[(o+3)%4]&e[(o+1)%4]),e[o]=be(e[o],ve[o]),a++},i=function(e){for(o=0;o<4;o++)e[o]+=f[63&e[(o+3)%4]]}):(n=function(e){for(o=3;o>=0;o--)e[o]=Ce(e[o],ve[o]),e[o]-=f[a]+(e[(o+3)%4]&e[(o+2)%4])+(~e[(o+3)%4]&e[(o+1)%4]),a--},i=function(e){for(o=3;o>=0;o--)e[o]-=f[63&e[(o+3)%4]]});var d=function(e){var t=[];for(o=0;o<4;o++){var n=c.getInt16Le();null!==l&&(r?n^=l.getInt16Le():l.putInt16Le(n)),t.push(65535&n)}a=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(o=0;o<4;o++)null!==l&&(r?l.putInt16Le(t[o]):t[o]^=l.getInt16Le()),u.putInt16Le(t[o])},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;)d([[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(),o=u.at(i-1);o>i?t=!1:u.truncate(o)}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,o){for(var a=16383&t,s=t>>14;--o>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=s*c+u*a;i=((c=a*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 Ee(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 Ee(e,t,!1)},F.jsbn=F.jsbn||{},F.jsbn.BigInteger=ke,"undefined"==typeof navigator?(ke.prototype.am=Be,we=28):"Microsoft Internet Explorer"==navigator.appName?(ke.prototype.am=function(e,t,r,n,i,o){for(var a=32767&t,s=t>>15;--o>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=s*c+u*a;i=((c=a*c+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+s*u+(i>>>30),r.data[n++]=1073741823&c}return i},we=30):"Netscape"!=navigator.appName?(ke.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var a=t*this.data[e++]+r.data[n]+i;i=Math.floor(a/67108864),r.data[n++]=67108863&a}return i},we=26):(ke.prototype.am=Be,we=28),ke.prototype.DB=we,ke.prototype.DM=(1<<we)-1,ke.prototype.DV=1<<we,ke.prototype.FV=Math.pow(2,52),ke.prototype.F1=52-we,ke.prototype.F2=2*we-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 Re(e,t){var r=_e[e.charCodeAt(t)];return null==r?-1:r}function Pe(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 Le(e){this.m=e}function Oe(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}Le.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},Le.prototype.revert=function(e){return e},Le.prototype.reduce=function(e){e.divRemTo(this.m,null,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)},Oe.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},Oe.prototype.revert=function(e){var t=Se();return e.copyTo(t),this.reduce(t),t},Oe.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)},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)},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,o=0;--n>=0;){var a=8==r?255&e[n]:Re(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this.data[this.t++]=a:o+r>this.DB?(this.data[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this.data[this.t++]=a>>this.DB-o):this.data[this.t-1]|=a<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<<this.DB-o)-1<<o)),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,o=(1<<i)-1,a=Math.floor(e/this.DB),s=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+a+1]=this.data[r]>>i|s,s=(this.data[r]&o)<<n;for(r=a-1;r>=0;--r)t.data[r]=0;t.data[a]=s,t.t=this.t+a+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,o=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var a=r+1;a<this.t;++a)t.data[a-r-1]|=(this.data[a]&o)<<i,t.data[a-r]=this.data[a]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&o)<<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 o=Se(),a=this.s,s=e.s,c=this.DB-Ne(n.data[n.t-1]);c>0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var u=o.t,l=o.data[u-1];if(0!=l){var f=l*(1<<this.F1)+(u>1?o.data[u-2]>>this.F2:0),d=this.FV/f,p=(1<<this.F1)/f,h=1<<this.F2,g=r.t,m=g-u,y=null==t?Se():t;for(o.dlShiftTo(m,y),r.compareTo(y)>=0&&(r.data[r.t++]=1,r.subTo(y,r)),ke.ONE.dlShiftTo(u,y),y.subTo(o,o);o.t<u;)o.data[o.t++]=0;for(;--m>=0;){var v=r.data[--g]==l?this.DM:Math.floor(r.data[g]*d+(r.data[g-1]+h)*p);if((r.data[g]+=o.am(0,v,r,m,0,u))<v)for(o.dlShiftTo(m,y),r.subTo(y,r);r.data[g]<--v;)r.subTo(y,r)}null!=t&&(r.drShiftTo(u,t),a!=s&&ke.ZERO.subTo(t,t)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),a<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),o=Ne(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<<o)>0)t.mulTo(n,i,r);else{var a=r;r=n,n=a}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,o="",a=this.t,s=this.DB-a*this.DB%t;if(a-- >0)for(s<this.DB&&(r=this.data[a]>>s)>0&&(i=!0,o=xe(r));a>=0;)s<t?(r=(this.data[a]&(1<<s)-1)<<t-s,r|=this.data[--a]>>(s+=this.DB-t)):(r=this.data[a]>>(s-=t)&n,s<=0&&(s+=this.DB,--a)),r>0&&(i=!0),i&&(o+=xe(r));return i?o:"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 Le(t):new Oe(t),this.exp(e,r)},ke.ZERO=Pe(0),ke.ONE=Pe(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=Pe(r),i=Se(),o=Se(),a="";for(this.divRemTo(n,i,o);i.signum()>0;)a=(r+o.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,o);return o.intValue().toString(e)+a},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,o=0,a=0,s=0;s<e.length;++s){var c=Re(e,s);c<0?"-"==e.charAt(s)&&0==this.signum()&&(i=!0):(a=t*a+c,++o>=r&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(a,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,o=Math.min(e.t,this.t);for(n=0;n<o;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(i=e.s&this.DM,n=o;n<this.t;++n)r.data[n]=t(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;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),o={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},a=0;a<e;++a){do{n=new ke(this.bitLength(),o)}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(),o=Pe(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new Le(t):t.isEven()?new qe(t):new Oe(t);var a=new Array,s=3,c=r-1,u=(1<<r)-1;if(a[1]=n.convert(this),r>1){var l=Se();for(n.sqrTo(a[1],l);s<=u;)a[s]=Se(),n.mulTo(l,a[s-2],a[s]),s+=2}var f,d,p=e.t-1,h=!0,g=Se();for(i=Ne(e.data[p])-1;p>=0;){for(i>=c?f=e.data[p]>>i-c&u:(f=(e.data[p]&(1<<i+1)-1)<<c-i,p>0&&(f|=e.data[p-1]>>this.DB+i-c)),s=r;0==(1&f);)f>>=1,--s;if((i-=s)<0&&(i+=this.DB,--p),h)a[f].copyTo(o),h=!1;else{for(;s>1;)n.sqrTo(o,g),n.sqrTo(g,o),s-=2;s>0?n.sqrTo(o,g):(d=o,o=g,g=d),n.mulTo(g,a[f],o)}for(;p>=0&&0==(e.data[p]&1<<i);)n.sqrTo(o,g),d=o,o=g,g=d,--i<0&&(i=this.DB-1,--p)}return n.revert(o)},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=Pe(1),o=Pe(0),a=Pe(0),s=Pe(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),t?(a.isEven()&&s.isEven()||(a.addTo(this,a),s.subTo(e,s)),a.rShiftTo(1,a)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(a,i),o.subTo(s,o)):(n.subTo(r,n),t&&a.subTo(i,a),s.subTo(o,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(),o=r.getLowestSetBit();if(o<0)return t;for(i<o&&(o=i),o>0&&(t.rShiftTo(o,t),r.rShiftTo(o,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 o>0&&r.lShiftTo(o,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)},w((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(),o=new Array(80),a={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){a.messageLength=0,a.fullMessageLength=a.messageLength64=[];for(var r=a.messageLengthSize/4,n=0;n<r;++n)a.fullMessageLength.push(0);return t=F.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},a}};return a.start(),a.update=function(r,n){"utf8"===n&&(r=F.util.encodeUtf8(r));var s=r.length;a.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var c=a.fullMessageLength.length-1;c>=0;--c)a.fullMessageLength[c]+=s[1],s[1]=s[0]+(a.fullMessageLength[c]/4294967296>>>0),a.fullMessageLength[c]=a.fullMessageLength[c]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(r),i(e,o,t),(t.read>2048||0===t.length())&&t.compact(),a},a.digest=function(){var n=F.util.createBuffer();n.putBytes(t.bytes());var s,c=a.fullMessageLength[a.fullMessageLength.length-1]+a.messageLengthSize&a.blockLength-1;n.putBytes(r.substr(0,a.blockLength-c));for(var u=8*a.fullMessageLength[0],l=0;l<a.fullMessageLength.length-1;++l)u+=(s=8*a.fullMessageLength[l+1])/4294967296>>>0,n.putInt32(u>>>0),u=s>>>0;n.putInt32(u);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};i(f,o,n);var d=F.util.createBuffer();return d.putInt32(f.h0),d.putInt32(f.h1),d.putInt32(f.h2),d.putInt32(f.h3),d.putInt32(f.h4),d},a};var r=null,n=!1;function i(e,t,r){for(var n,i,o,a,s,c,u,l=r.length();l>=64;){for(i=e.h0,o=e.h1,a=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^o&(a^s))+c+1518500249+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=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^o&(a^s))+c+1518500249+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=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)+(o^a^s)+c+1859775393+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=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)+(o^a^s)+c+1859775393+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=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)+(o&a|s&(o^a))+c+2400959708+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=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)+(o^a^s)+c+3395469782+n,c=s,s=a,a=(o<<30|o>>>2)>>>0,o=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+o|0,e.h2=e.h2+a|0,e.h3=e.h3+s|0,e.h4=e.h4+c|0,l-=64}}})),w((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),o=0;o<i;++o){var a=String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,255&o);r.start(),r.update(e+a),n+=r.digest().getBytes()}return n.substring(0,t)}t.encode_rsa_oaep=function(e,t,n){var i,o,a,s;"string"==typeof n?(i=n,o=arguments[3]||void 0,a=arguments[4]||void 0):n&&(i=n.label||void 0,o=n.seed||void 0,a=n.md||void 0,n.mgf1&&n.mgf1.md&&(s=n.mgf1.md)),a?a.start():a=F.md.sha1.create(),s||(s=a);var c=Math.ceil(e.n.bitLength()/8),u=c-2*a.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=""),a.update(i,"raw");for(var l=a.digest(),f="",d=u-t.length,p=0;p<d;p++)f+="\0";var h,g=l.getBytes()+f+""+t;if(o){if(o.length!==a.digestLength)throw(h=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=o.length,h.digestLength=a.digestLength,h}else o=F.random.getBytes(a.digestLength);var m=r(o,c-a.digestLength-1,s),y=F.util.xorBytes(g,m,g.length),v=r(y,a.digestLength,s);return"\0"+F.util.xorBytes(o,v,o.length)+y},t.decode_rsa_oaep=function(e,t,n){var i,o,a;"string"==typeof n?(i=n,o=arguments[3]||void 0):n&&(i=n.label||void 0,o=n.md||void 0,n.mgf1&&n.mgf1.md&&(a=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===o?o=F.md.sha1.create():o.start(),a||(a=o),s<2*o.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");i||(i=""),o.update(i,"raw");for(var c=o.digest().getBytes(),u=t.charAt(0),l=t.substring(1,o.digestLength+1),f=t.substring(1+o.digestLength),d=r(f,o.digestLength,a),p=r(F.util.xorBytes(l,d,l.length),s-o.digestLength-1,a),h=F.util.xorBytes(f,p,f.length),g=h.substring(0,o.digestLength),m="\0"!==u,y=0;y<o.digestLength;++y)m|=c.charAt(y)!==g.charAt(y);for(var v=1,b=o.digestLength,C=o.digestLength;C<h.length;C++){var w=h.charCodeAt(C);m|=w&(v?65534:0),b+=v&=1&w^1}if(m||1!==h.charCodeAt(b))throw new Error("Invalid RSAES-OAEP padding.");return h.substring(b+1)}})),w((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 o=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 o=t.prng||F.random,c={nextBytes:function(e){for(var t=o.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 a(e,t,n,i);var o=s(e,t),c=n.workers,u=n.workLoad||100,l=30*u/8,f=n.workerScript||"forge/prime.worker.js";if(-1===c)return F.util.estimateCores((function(e,t){e&&(t=2),c=t-1,d()}));function d(){c=Math.max(1,c);for(var n=[],a=0;a<c;++a)n[a]=new Worker(f);for(a=0;a<c;++a)n[a].addEventListener("message",p);var d=!1;function p(a){if(!d){var c=a.data;if(c.found){for(var f=0;f<n.length;++f)n[f].terminate();return d=!0,i(null,new r(c.prime,16))}o.bitLength()>e&&(o=s(e,t));var p=o.toString(16);a.target.postMessage({hex:p,workLoad:u}),o.dAddOffset(l,0)}}}d()}(e,t,n,i):a(e,t,n,i)}(e,c,i.options,n);throw new Error("Invalid prime generation algorithm: "+i.name)}}function a(e,t,r,i){var o=s(e,t),a=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}(o.bitLength());"millerRabinTests"in r&&(a=r.millerRabinTests);var c=10;"maxBlockTime"in r&&(c=r.maxBlockTime),function e(t,r,i,o,a,c,u){var l=+new Date;do{if(t.bitLength()>r&&(t=s(r,i)),t.isProbablePrime(a))return u(null,t);t.dAddOffset(n[o++%8],0)}while(c<0||+new Date-l<c);F.util.setImmediate((function(){e(t,r,i,o,a,c,u)}))}(o,e,t,0,a,c,i)}function s(e,t){var n=new r(e,t),a=e-1;return n.testBit(a)||n.bitwiseTo(r.ONE.shiftLeft(a),o,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,[]),o=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[]);o.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,n)),o.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,""));var a=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(o),i.value.push(a),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),o=e.mod(t.q).modPow(t.dQ,t.q);i.compareTo(o)<0;)i=i.add(t.p);var a=i.subtract(o).multiply(t.qInv).mod(t.p).multiply(t.q).add(o);return a.multiply(n.modInverse(t.n)).mod(t.n)};function ot(e,t,r){var n=F.util.createBuffer(),i=Math.ceil(t.n.bitLength()/8);if(e.length>i-11){var o=new Error("Message is too long for PKCS#1 v1.5 padding.");throw o.length=e.length,o.max=i-11,o}n.putByte(0),n.putByte(r);var a,s=i-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var c=0;c<s;++c)n.putByte(a)}else for(;s>0;){var u=0,l=F.random.getBytes(s);for(c=0;c<s;++c)0===(a=l.charCodeAt(c))?++u:n.putByte(a);s=u}return n.putByte(0),n.putBytes(e),n}function at(e,t,r,n){var i=Math.ceil(t.n.bitLength()/8),o=F.util.createBuffer(e),a=o.getByte(),s=o.getByte();if(0!==a||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!==o.getByte())throw new Error("Encryption block is invalid.")}else if(1===s)for(c=0;o.length()>1;){if(255!==o.getByte()){--o.read;break}++c}else if(2===s)for(c=0;o.length()>1;){if(0===o.getByte()){--o.read;break}++c}if(0!==o.getByte()||c!==i-3-o.length())throw new Error("Encryption block is invalid.");return o.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(){o(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?a(t,e.q):void o(e.qBits,a))}))}function o(e,t){F.prime.generateProbablePrime(e,n,t)}function a(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 o(e.qBits,a);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 o(e.qBits,a);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 ft(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 dt(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,o=Math.ceil(t.n.bitLength()/8);!1!==r&&!0!==r?(i=2===r,n=ot(e,t,r)):(n=F.util.createBuffer()).putBytes(e);for(var a=new Qe(n.toHex(),16),s=it(a,t,i).toString(16),c=F.util.createBuffer(),u=o-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 o=new Error("Encrypted message length is invalid.");throw o.length=e.length,o.expected=i,o}var a=new Qe(F.util.createBuffer(e).toHex(),16);if(a.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var s=it(a,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?at(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,o={nextBytes:function(e){for(var t=i.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},a=r.algorithm||"PRIMEINC";if("PRIMEINC"!==a)throw new Error("Invalid key generation algorithm: "+a);return(n={algorithm:a,state:0,bits:e,rng:o,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,o=function(e,t){return e|t},a=+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),o,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)-a,a=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(ft("generateKey")&&ft("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(dt("generateKey")&&dt("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 o=We.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:$e.privateKeyFromPem(o.privateKey),publicKey:$e.publicKeyFromPem(o.publicKey)}}var a=$e.rsa.createKeyPairGenerationState(e,t,r);if(!n)return $e.rsa.stepKeyPairGenerationState(a,0),a.keys;st(a,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 ot(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=at(t,r,!0),e===Xe.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===at(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,o,a,s){var c={n:e,e:t,d:r,p:n,q:i,dP:o,dQ:a,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:at};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,o,a,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 f=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw f.errors=l,f}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(),o=F.util.createBuffer(u.privateKeyPrime2).toHex(),a=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(o,16),new Qe(a,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 o=F.util.createBuffer(t.publicKeyModulus).toHex(),a=F.util.createBuffer(t.publicKeyExponent).toHex();return $e.setRsaPublicKey(new Qe(o,16),new Qe(a,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 wt(e,t){return e.start().update(t).digest().getBytes()}function Et(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,o,a=F.random.getBytesSync(r.saltSize),s=r.count,c=gt.integerToDer(s);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var u,l,f;switch(r.algorithm){case"aes128":n=16,u=16,l=yt["aes128-CBC"],f=F.aes.createEncryptionCipher;break;case"aes192":n=24,u=16,l=yt["aes192-CBC"],f=F.aes.createEncryptionCipher;break;case"aes256":n=32,u=16,l=yt["aes256-CBC"],f=F.aes.createEncryptionCipher;break;case"des":n=8,u=8,l=yt.desCBC,f=F.des.createEncryptionCipher;break;default:throw(y=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,y}var d="hmacWith"+r.prfAlgorithm.toUpperCase(),p=kt(d),h=F.pkcs5.pbkdf2(t,a,s,n,p),g=F.random.getBytesSync(u);(v=f(h)).start(g),v.update(gt.toDer(e)),v.finish(),o=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}(a,c,n,d);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(a);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(),o=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,a),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,o)])},mt.decryptPrivateKeyInfo=function(e,t){var r=null,n={},i=[];if(!gt.validate(e,vt,n,i)){var o=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw o.errors=i,o}var a=gt.derToOid(n.encryptionOid),s=mt.pbe.getCipher(a,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,o,a,s;switch(r.algorithm){case"aes128":i="AES-128-CBC",a=16,o=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",a=24,o=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",a=32,o=F.random.getBytesSync(16),s=F.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",a=24,o=F.random.getBytesSync(8),s=F.des.createEncryptionCipher;break;case"des":i="DES-CBC",a=8,o=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,o.substr(0,8),a));u.start(o),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(o).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(a=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=a,a;if(n.procType&&"ENCRYPTED"===n.procType.type){var i,o;switch(n.dekInfo.algorithm){case"DES-CBC":i=8,o=F.des.createDecryptionCipher;break;case"DES-EDE3-CBC":i=24,o=F.des.createDecryptionCipher;break;case"AES-128-CBC":i=16,o=F.aes.createDecryptionCipher;break;case"AES-192-CBC":i=24,o=F.aes.createDecryptionCipher;break;case"AES-256-CBC":i=32,o=F.aes.createDecryptionCipher;break;case"RC2-40-CBC":i=5,o=function(e){return F.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":i=8,o=function(e){return F.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":i=16,o=function(e){return F.rc2.createDecryptionCipher(e,128)};break;default:var a;throw(a=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".')).algorithm=n.dekInfo.algorithm,a}var s=F.util.hexToBytes(n.dekInfo.parameters),c=o(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,o){var a,s;if(null==o){if(!("sha1"in F.md))throw new Error('"sha1" hash algorithm unavailable.');o=F.md.sha1.create()}var c=o.digestLength,u=o.blockLength,l=new F.util.ByteBuffer,f=new F.util.ByteBuffer;if(null!=e){for(s=0;s<e.length;s++)f.putInt16(e.charCodeAt(s));f.putInt16(0)}var d=f.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(d/u),v=new F.util.ByteBuffer;for(s=0;s<y;s++)v.putByte(f.at(s%d));var b=m;b.putBuffer(v);for(var C=Math.ceil(i/c),w=1;w<=C;w++){var E=new F.util.ByteBuffer;E.putBytes(h.bytes()),E.putBytes(b.bytes());for(var k=0;k<n;k++)o.start(),o.update(E.getBytes()),E=o.digest();var S=new F.util.ByteBuffer;for(s=0;s<u;s++)S.putByte(E.at(s%c));var B=Math.ceil(p/u)+Math.ceil(d/u),T=new F.util.ByteBuffer;for(a=0;a<B;a++){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(E)}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={},o=[];if(!gt.validate(t,bt,i,o))throw(n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=o,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 a,s,c=i.kdfSalt,u=F.util.createBuffer(i.kdfIterationCount);switch(u=u.getInt(u.length()<<3),mt.oids[e]){case"aes128-CBC":a=16,s=F.aes.createDecryptionCipher;break;case"aes192-CBC":a=24,s=F.aes.createDecryptionCipher;break;case"aes256-CBC":a=32,s=F.aes.createDecryptionCipher;break;case"des-EDE3-CBC":a=24,s=F.des.createDecryptionCipher;break;case"desCBC":a=8,s=F.des.createDecryptionCipher}var l=Et(i.prfOid),f=F.pkcs5.pbkdf2(r,c,u,a,l),d=i.encIv,p=s(f);return p.start(d),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 o,a,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"]:o=24,a=8,s=F.des.startDecrypting;break;case mt.oids["pbewithSHAAnd40BitRC2-CBC"]:o=5,a=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 f=Et(n.prfOid),d=mt.pbe.generatePkcs12Key(r,c,1,u,o,f);return f.start(),s(d,mt.pbe.generatePkcs12Key(r,c,2,u,a,f))},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=[wt(n,e+t)],o=16,a=1;o<r;++a,o+=16)i.push(wt(n,i[a-1]+e+t));return i.join("").substr(0,r)},w((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 o={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:[o]}]},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"}]}})),w((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),o=0;o<i;o++){var a=new F.util.ByteBuffer;a.putInt32(o),e.start(),e.update(t+a.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}}}})),F.mgf=F.mgf||{},F.mgf.mgf1=F.mgf1,w((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,o=e.salt||null;if("string"==typeof o&&(o=F.util.createBuffer(o)),"saltLength"in e)t=e.saltLength;else{if(null===o)throw new Error("Salt length not specified or specific salt not given.");t=o.length()}if(null!==o&&o.length()!==t)throw new Error("Given salt length does not match length of given salt.");var a=e.prng||F.random;return{encode:function(e,s){var c,u,l=s-1,f=Math.ceil(l/8),d=e.digest().getBytes();if(f<i+t+2)throw new Error("Message is too long to encrypt.");u=null===o?a.getBytesSync(t):o.bytes();var p=new F.util.ByteBuffer;p.fillWithByte(0,8),p.putBytes(d),p.putBytes(u),r.start(),r.update(p.getBytes());var h=r.digest().getBytes(),g=new F.util.ByteBuffer;g.fillWithByte(0,f-t-i-2),g.putByte(1),g.putBytes(u);var m=g.getBytes(),y=f-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*f-l&255;return(b=String.fromCharCode(b.charCodeAt(0)&~C)+b.substr(1))+h+String.fromCharCode(188)},verify:function(e,o,a){var s,c=a-1,u=Math.ceil(c/8);if(o=o.substr(-u),u<i+t+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(188!==o.charCodeAt(u-1))throw new Error("Encoded message does not end in 0xBC.");var l=u-i-1,f=o.substr(0,l),d=o.substr(l,i),p=65280>>8*u-c&255;if(0!=(f.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var h=n.generate(d,l),g="";for(s=0;s<l;s++)g+=String.fromCharCode(f.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()),d===r.digest().getBytes()}}}})),w((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 o=F.pki.rsa.publicKeyValidator,a={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"},o,{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"},o,{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 o,a,s,c=[],u=0;u<e.value.length;++u){o=e.value[u];for(var l=0;l<o.value.length;++l)s={},a=o.value[l],s.type=t.derToOid(a.value[0].value),s.value=a.value[1].value,s.valueTagClass=a.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 o=[],a=0;a<e.length;++a)for(var s=e[a],c=t.derToOid(s.value[0].value),u=s.value[1].value,l=0;l<u.length;++l){var f={};if(f.type=c,f.value=u[l].value,f.valueTagClass=u[l].type,f.type in n&&(f.name=n[f.type],f.name in i&&(f.shortName=i[f.name])),f.type===n.extensionRequest){f.extensions=[];for(var d=0;d<f.value.length;++d)f.extensions.push(r.certificateExtensionFromAsn1(f.value[d]))}o.push(f)}return o};var f=function(e,r,i){var o={};if(e!==n["RSASSA-PSS"])return o;i&&(o={hash:{algorithmOid:n.sha1},mgf:{algorithmOid:n.mgf1,hash:{algorithmOid:n.sha1}},saltLength:20});var a={},c=[];if(!t.validate(r,s,a,c)){var u=new Error("Cannot read RSASSA-PSS parameter block.");throw u.errors=c,u}return void 0!==a.hashOid&&(o.hash=o.hash||{},o.hash.algorithmOid=t.derToOid(a.hashOid)),void 0!==a.maskGenOid&&(o.mgf=o.mgf||{},o.mgf.algorithmOid=t.derToOid(a.maskGenOid),o.mgf.hash=o.mgf.hash||{},o.mgf.hash.algorithmOid=t.derToOid(a.maskGenHashOid)),void 0!==a.saltLength&&(o.saltLength=a.saltLength.charCodeAt(0)),o};function d(e){for(var r,n,i=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),o=e.attributes,a=0;a<o.length;++a){var s=(r=o[a]).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 o,a=0;a<e.length;++a){if(void 0===(o=e[a]).name&&(o.type&&o.type in r.oids?o.name=r.oids[o.type]:o.shortName&&o.shortName in i&&(o.name=r.oids[i[o.shortName]])),void 0===o.type){if(!o.name||!(o.name in r.oids))throw(c=new Error("Attribute type not specified.")).attribute=o,c;o.type=r.oids[o.name]}if(void 0===o.shortName&&o.name&&o.name in i&&(o.shortName=i[o.name]),o.type===n.extensionRequest&&(o.valueConstructed=!0,o.valueTagClass=t.Type.SEQUENCE,!o.value&&o.extensions)){o.value=[];for(var s=0;s<o.extensions.length;++s)o.value.push(r.certificateExtensionToAsn1(h(o.extensions[s])))}var c;if(void 0===o.value)throw(c=new Error("Attribute value not specified.")).attribute=o,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 o=0,a=0,s=0;e.digitalSignature&&(a|=128,o=7),e.nonRepudiation&&(a|=64,o=6),e.keyEncipherment&&(a|=32,o=5),e.dataEncipherment&&(a|=16,o=4),e.keyAgreement&&(a|=8,o=3),e.keyCertSign&&(a|=4,o=2),e.cRLSign&&(a|=2,o=1),e.encipherOnly&&(a|=1,o=0),e.decipherOnly&&(s|=128,o=7);var c=String.fromCharCode(o);0!==s?c+=String.fromCharCode(a)+String.fromCharCode(s):0!==a&&(c+=String.fromCharCode(a)),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)o=0,a=0,e.client&&(a|=128,o=7),e.server&&(a|=64,o=6),e.email&&(a|=32,o=5),e.objsign&&(a|=16,o=4),e.reserved&&(a|=8,o=3),e.sslCA&&(a|=4,o=2),e.emailCA&&(a|=2,o=1),e.objCA&&(a|=1,o=0),c=String.fromCharCode(o),0!==a&&(c+=String.fromCharCode(a)),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 f=0;f<e.altNames.length;++f){if(c=(y=e.altNames[f]).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,[d(!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(f=0;f<e.altNames.length;++f){if(c=(y=e.altNames[f]).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 o=n[i],a=o.value,s=t.Type.UTF8;"valueTagClass"in o&&(s=o.valueTagClass),s===t.Type.UTF8&&(a=F.util.encodeUtf8(a));var c=!1;"valueConstructed"in o&&(c=o.valueConstructed);var u=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(o.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,s,c,a)])]);r.value.push(u)}return r}r.certificateFromPem=function(e,n,i){var o=F.pem.decode(e)[0];if("CERTIFICATE"!==o.type&&"X509 CERTIFICATE"!==o.type&&"TRUSTED CERTIFICATE"!==o.type){var a=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw a.headerType=o.type,a}if(o.procType&&"ENCRYPTED"===o.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=t.fromDer(o.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 o=t.fromDer(n.body);return r.publicKeyFromAsn1(o)},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,o=(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+'".')}o.start(),o.update(i);var a=o.digest();if("hex"===n.encoding){var s=a.toHex();return n.delimiter?s.match(/.{2}/g).join(n.delimiter):s}if("binary"===n.encoding)return a.getBytes();if(n.encoding)throw new Error('Unknown encoding "'+n.encoding+'".');return a},r.certificationRequestFromPem=function(e,n,i){var o=F.pem.decode(e)[0];if("CERTIFICATE REQUEST"!==o.type){var a=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw a.headerType=o.type,a}if(o.procType&&"ENCRYPTED"===o.procType.type)throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=t.fromDer(o.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,o){e.md=o||F.md.sha1.create();var a=n[e.md.algorithm+"WithRSAEncryption"];if(!a){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=a,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 o=!1;if(!e.issued(i)){var a=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=a.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 f;switch(i.signatureOid){case n.sha1WithRSAEncryption:f=void 0;break;case n["RSASSA-PSS"]:var d,p,h;if(void 0===(d=n[i.signatureParameters.mgf.hash.algorithmOid])||void 0===F.md[d])throw(h=new Error("Unsupported MGF hash function.")).oid=i.signatureParameters.mgf.hash.algorithmOid,h.name=d,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[d].create()),void 0===(d=n[i.signatureParameters.hash.algorithmOid])||void 0===F.md[d])throw{message:"Unsupported RSASSA-PSS hash function.",oid:i.signatureParameters.hash.algorithmOid,name:d};f=F.pss.create(F.md[d].create(),p,i.signatureParameters.saltLength)}o=e.publicKey.verify(c.digest().getBytes(),i.signature,f)}return o},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 o,a;r=!0;for(var s=0;r&&s<n.attributes.length;++s)o=n.attributes[s],a=i.attributes[s],o.type===a.type&&o.value===a.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 o=e.generateSubjectKeyIdentifier().getBytes();return F.util.hexToBytes(i.subjectKeyIdentifier)===o}}return!1},e},r.certificateFromAsn1=function(e,i){var o={},s=[];if(!t.validate(e,a,o,s))throw(h=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.")).errors=s,h;if(t.derToOid(o.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var c=r.createCertificate();c.version=o.certVersion?o.certVersion.charCodeAt(0):0;var u=F.util.createBuffer(o.certSerialNumber);c.serialNumber=u.toHex(),c.signatureOid=F.asn1.derToOid(o.certSignatureOid),c.signatureParameters=f(c.signatureOid,o.certSignatureParams,!0),c.siginfo.algorithmOid=F.asn1.derToOid(o.certinfoSignatureOid),c.siginfo.parameters=f(c.siginfo.algorithmOid,o.certinfoSignatureParams,!1),c.signature=o.certSignature;var d=[];if(void 0!==o.certValidity1UTCTime&&d.push(t.utcTimeToDate(o.certValidity1UTCTime)),void 0!==o.certValidity2GeneralizedTime&&d.push(t.generalizedTimeToDate(o.certValidity2GeneralizedTime)),void 0!==o.certValidity3UTCTime&&d.push(t.utcTimeToDate(o.certValidity3UTCTime)),void 0!==o.certValidity4GeneralizedTime&&d.push(t.generalizedTimeToDate(o.certValidity4GeneralizedTime)),d.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(d.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=d[0],c.validity.notAfter=d[1],c.tbsCertificate=o.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(o.certIssuer,m),o.certIssuerUniqueId&&(c.issuer.uniqueId=o.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(o.certSubject,y),o.certSubjectUniqueId&&(c.subject.uniqueId=o.certSubjectUniqueId),c.subject.hash=y.digest().toHex(),o.certExtensions?c.extensions=r.certificateExtensionsFromAsn1(o.certExtensions):c.extensions=[],c.publicKey=r.publicKeyFromAsn1(o.subjectPublicKeyInfo),c},r.certificateExtensionsFromAsn1=function(e){for(var t=[],n=0;n<e.value.length;++n)for(var i=e.value[n],o=0;o<i.value.length;++o)t.push(r.certificateExtensionFromAsn1(i.value[o]));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,o=0;(s=t.fromDer(r.value)).value.length>1&&(i=s.value.charCodeAt(1),o=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&o)}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 a=null;s.value.length>0&&s.value[0].type===t.Type.INTEGER?a=s.value[0].value:s.value.length>1&&(a=s.value[1].value),null!==a&&(r.pathLenConstraint=t.derToInteger(a))}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 f=0;f<s.value.length;++f){var d={type:(l=s.value[f]).type,value:l.value};switch(r.altNames.push(d),l.type){case 1:case 2:case 6:break;case 7:d.ip=F.util.bytesToIP(l.value);break;case 8:d.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 o={},a=[];if(!t.validate(e,u,o,a))throw(c=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.")).errors=a,c;if(t.derToOid(o.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var s=r.createCertificationRequest();if(s.version=o.csrVersion?o.csrVersion.charCodeAt(0):0,s.signatureOid=F.asn1.derToOid(o.csrSignatureOid),s.signatureParameters=f(s.signatureOid,o.csrSignatureParams,!0),s.siginfo.algorithmOid=F.asn1.derToOid(o.csrSignatureOid),s.siginfo.parameters=f(s.siginfo.algorithmOid,o.csrSignatureParams,!1),s.signature=o.csrSignature,s.certificationRequestInfo=o.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 d=t.toDer(s.certificationRequestInfo);s.md.update(d.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(o.certificationRequestInfoSubject,h),s.subject.hash=h.digest().toHex(),s.publicKey=r.publicKeyFromAsn1(o.subjectPublicKeyInfo),s.getAttribute=function(e){return l(s,e)},s.addAttribute=function(e){p([e]),s.attributes.push(e)},s.attributes=r.CRIAttributesAsArray(o.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,o){e.md=o||F.md.sha1.create();var a=n[e.md.algorithm+"WithRSAEncryption"];if(!a){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=a,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,o=e.md;if(null===o){if(e.signatureOid in n)switch(n[e.signatureOid]){case"sha1WithRSAEncryption":o=F.md.sha1.create();break;case"md5WithRSAEncryption":o=F.md.md5.create();break;case"sha256WithRSAEncryption":o=F.md.sha256.create();break;case"sha384WithRSAEncryption":o=F.md.sha384.create();break;case"sha512WithRSAEncryption":o=F.md.sha512.create();break;case"RSASSA-PSS":o=F.md.sha256.create()}if(null===o)throw(f=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=e.signatureOid,f;var a=e.certificationRequestInfo||r.getCertificationRequestInfo(e),s=t.toDer(a);o.update(s.getBytes())}if(null!==o){var c;switch(e.signatureOid){case n.sha1WithRSAEncryption:break;case n["RSASSA-PSS"]:var u,l,f;if(void 0===(u=n[e.signatureParameters.mgf.hash.algorithmOid])||void 0===F.md[u])throw(f=new Error("Unsupported MGF hash function.")).oid=e.signatureParameters.mgf.hash.algorithmOid,f.name=u,f;if(void 0===(l=n[e.signatureParameters.mgf.algorithmOid])||void 0===F.mgf[l])throw(f=new Error("Unsupported MGF function.")).oid=e.signatureParameters.mgf.algorithmOid,f.name=l,f;if(l=F.mgf[l].create(F.md[u].create()),void 0===(u=n[e.signatureParameters.hash.algorithmOid])||void 0===F.md[u])throw(f=new Error("Unsupported RSASSA-PSS hash function.")).oid=e.signatureParameters.hash.algorithmOid,f.name=u,f;c=F.pss.create(F.md[u].create(),l,e.signatureParameters.saltLength)}i=e.publicKey.verify(o.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),o=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)]),d(e.issuer),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,i]),d(e.subject),r.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&o.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&&o.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&&o.value.push(r.certificateExtensionsToAsn1(e.extensions)),o},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()),d(e.subject),r.publicKeyToAsn1(e.publicKey),m(e)])},r.distinguishedNameToAsn1=function(e){return d(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 o=0;o<e.length;++o)i.value.push(r.certificateExtensionToAsn1(e[o]));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 o(e),n.certs[e.hash]||null}function o(e){if(!e.hash){var t=F.md.sha1.create();e.attributes=r.RDNAttributesAsArray(d(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)),o(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 o=t.toDer(r.certificateToAsn1(e)).getBytes(),a=0;a<n.length;++a)if(o===t.toDer(r.certificateToAsn1(n[a])).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 a;if("string"==typeof e&&(e=F.pki.certificateFromPem(e)),o(e.subject),!n.hasCertificate(e))return null;var s=i(e.subject);if(!F.util.isArray(s))return a=n.certs[e.subject.hash],delete n.certs[e.subject.hash],a;for(var c=t.toDer(r.certificateToAsn1(e)).getBytes(),u=0;u<s.length;++u)c===t.toDer(r.certificateToAsn1(s[u])).getBytes()&&(a=s[u],s.splice(u,1));return 0===s.length&&delete n.certs[e.subject.hash],a},e)for(var a=0;a<e.length;++a){var s=e[a];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),o=n.validityCheckDate;void 0===o&&(o=new Date);var a=!0,s=null,c=0;do{var u=t.shift(),l=null,f=!1;if(o&&(o<u.validity.notBefore||o>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:o}),null===s){if(null===(l=t[0]||e.getIssuer(u))&&u.isIssuer(u)&&(f=!0,l=u),l){var d=l;F.util.isArray(d)||(d=[d]);for(var p=!1;!p&&d.length>0;){l=d.shift();try{p=l.verify(u)}catch(e){}}p||(s={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}null!==s||l&&!f||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&&(!a||0===t.length&&(!l||f))){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,a=!1,++c}while(t.length>0);return!0}})),w((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"}]},o={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"}]}]},a={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=[],o=0;o<e.length;o++)for(var a=0;a<e[o].safeBags.length;a++){var s=e[o].safeBags[a];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 f(e,n){var i={},o=[];if(!t.validate(e,F.pkcs7.asn1.encryptedDataValidator,i,o))throw(a=new Error("Cannot read EncryptedContentInfo.")).errors=o,a;var a,s=t.derToOid(i.contentType);if(s!==r.oids.data)throw(a=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.")).oid=s,a;s=t.derToOid(i.encAlgorithm);var c=r.pbe.getCipher(s,i.encParameter,n),u=l(i.encryptedContentAsn1),f=F.util.createBuffer(u.value);if(c.update(f),!c.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return c.output.getBytes()}function d(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 o=[],s=0;s<e.value.length;s++){var u=e.value[s],l={},f=[];if(!t.validate(u,a,l,f))throw(y=new Error("Cannot read SafeBag.")).errors=f,y;var d,h,g={type:t.derToOid(l.bagId),attributes:p(l.bagAttributes)};o.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:d=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!==d&&!t.validate(m,d,l,f))throw(y=new Error("Cannot read PKCS#12 "+d.name)).errors=f,y;h()}return o}function p(e){var n={};if(void 0!==e)for(var i=0;i<e.length;++i){var o={},a=[];if(!t.validate(e[i],s,o,a)){var c=new Error("Cannot read PKCS#12 BagAttribute.");throw c.errors=a,c}var u=t.derToOid(o.oid);if(void 0!==r.oids[u]){n[r.oids[u]]=[];for(var l=0;l<o.values.length;++l)n[r.oids[u]].push(o.values[l].value)}}return n}n.pkcs12FromAsn1=function(e,a,s){"string"==typeof a?(s=a,a=!0):void 0===a&&(a=!0);var c={};if(!t.validate(e,o,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,w=n.generateKey(s,b,3,C,y,m),E=F.hmac.create();if(E.start(m,w),E.update(g.value),E.getMac().getBytes()!==c.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return function(e,n,o,a){if((n=t.fromDer(n,o)).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=f(m,a),h.encrypted=!0;break;default:var y;throw(y=new Error("Unsupported PKCS#12 contentType.")).contentType=t.derToOid(u.contentType),y}h.safeBags=d(g,o,a),e.safeContents.push(h)}}(h,g.value,a,s),h},n.toPkcs12Asn1=function(e,i,o,a){(a=a||{}).saltSize=a.saltSize||8,a.count=a.count||2048,a.algorithm=a.algorithm||a.encAlgorithm||"aes128","useMac"in a||(a.useMac=!0),"localKeyId"in a||(a.localKeyId=null),"generateLocalKeyId"in a||(a.generateLocalKeyId=!0);var s,c=a.localKeyId;if(null!==c)c=F.util.hexToBytes(c);else if(a.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 a&&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,a.friendlyName)])])),l.length>0&&(s=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,l));var f=[],d=[];null!==i&&(d=F.util.isArray(i)?i:[i]);for(var p=[],h=0;h<d.length;++h){"string"==typeof(i=d[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())])]);f.push(b)}var C=null;if(null!==e){var w=r.wrapRsaPrivateKey(r.privateKeyToAsn1(e));C=null===o?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,[w]),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(w,o,a)]),s]);var E=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(E).getBytes())])]);f.push(k)}var S,B=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,f);if(a.useMac){var T=F.md.sha1.create(),A=new F.util.ByteBuffer(F.random.getBytes(a.saltSize)),I=a.count,_=(e=n.generateKey(o,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})),w((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 o=t.fromDer(n.body);return r.privateKeyFromAsn1(o)},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(),o=e.length>>1,a=o+(1&e.length),s=e.substr(0,a),c=e.substr(o,a),u=F.util.createBuffer(),l=F.hmac.create();r=t+r;var f=Math.ceil(n/16),d=Math.ceil(n/20);l.start("MD5",s);var p=F.util.createBuffer();u.putBytes(r);for(var 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),p.putBuffer(l.digest());l.start("SHA1",c);var g=F.util.createBuffer();for(u.clear(),u.putBytes(r),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),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 o=t.fragment,a=o.length();if(n={version:{major:o.getByte(),minor:o.getByte()},random:F.util.createBuffer(o.getBytes(32)),session_id:At(o,1),extensions:[]},i?(n.cipher_suite=o.getBytes(2),n.compression_method=o.getByte()):(n.cipher_suites=At(o,2),n.compression_methods=At(o,1)),(a=r-(a-o.length()))>0){for(var s=At(o,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 f=F.util.createBuffer(n.cipher_suites.bytes());f.length()>0&&(e.session.cipherSuite=_t.getCipherSuite(f.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,o=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:o}},_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=Lt,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(),o=null;if(e.sessionCache&&(null===(o=e.sessionCache.getSession(i))?i="":(o.version.major!==n.version.major||o.version.minor>n.version.minor)&&(o=null,i="")),0===i.length&&(i=F.random.getBytes(32)),e.session.id=i,e.session.clientHelloVersion=n.version,e.session.sp={},o)e.version=e.session.version=o.version,e.session.sp=o.sp;else{for(var a,s=1;s<_t.SupportedVersions.length&&!((a=_t.SupportedVersions[s]).minor<=n.version.minor);++s);e.version={major:a.major,minor:a.minor},e.session.version=e.version}null!==o?(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,o=t.fragment,a={certificate_list:At(o,3)},s=[];try{for(;a.certificate_list.length()>0;)n=At(a.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?Rt:Vt:(c?e.session.serverCertificate=s[0]:e.session.clientCertificate=s[0],_t.verifyCertificateChain(e,s)&&(e.expect=c?Rt: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=Pt,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()},o=null;if(e.getPrivateKey)try{o=e.getPrivateKey(e,e.session.serverCertificate),o=F.pki.privateKeyFromPem(o)}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===o)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 a=e.session.sp;a.pre_master_secret=o.decrypt(i.enc_pre_master_secret);var s=e.session.clientHelloVersion;if(s.major!==a.pre_master_secret.charCodeAt(0)||s.minor!==a.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){a.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 o={signature:At(n,2).getBytes()},a=F.util.createBuffer();a.putBuffer(e.session.md5.digest()),a.putBuffer(e.session.sha1.digest()),a=a.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(a,o.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 o=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=Lt,_t.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return o(e,null);_t.getClientSignature(e,o)},_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?Ot:zt,e.process()},_t.handleFinished=function(e,t,r){var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var o=t.fragment.getBytes();(n=F.util.createBuffer()).putBuffer(e.session.md5.digest()),n.putBuffer(e.session.sha1.digest());var a=e.entity===_t.ConnectionEnd.client,s=a?"server finished":"client finished",c=e.session.sp;if((n=St(c.master_secret,s,n.getBytes(),12)).getBytes()!==o)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&&a||!e.session.resuming&&!a)&&(_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=a?Dt:Kt,e.handshaking=!1,++e.handshakes,e.peerCertificate=a?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 o=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(o),e.session.sha1.update(o)),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(),o=r.getBytes(i);if(n===_t.HeartbeatMessageType.heartbeat_request){if(e.handshaking||i>o.length)return e.process();_t.queue(e,_t.createRecord(e,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_response,o)})),_t.flush(e)}else if(n===_t.HeartbeatMessageType.heartbeat_response){if(o!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,F.util.createBuffer(o))}e.process()};var xt=1,Rt=2,Pt=3,Nt=4,Lt=5,Ot=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 or=_t.handleClientHello,ar=_t.handleClientKeyExchange,sr=_t.handleCertificateVerify;ir[_t.ConnectionEnd.server]=[[qt,or,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,ar,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,o=e.version.major===_t.Versions.TLS_1_0.major&&e.version.minor===_t.Versions.TLS_1_0.minor;o&&(i+=2*t.fixed_iv_length);var a=r(t.master_secret,"key expansion",n,i),s={client_write_MAC_key:a.getBytes(t.mac_key_length),server_write_MAC_key:a.getBytes(t.mac_key_length),client_write_key:a.getBytes(t.enc_key_length),server_write_key:a.getBytes(t.enc_key_length)};return o&&(s.client_write_IV=a.getBytes(t.fixed_iv_length),s.server_write_IV=a.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(),o=F.util.createBuffer();o.putByte(_t.CompressionMethod.none);var a=o.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 f=s.length();f>0&&(f+=2);var d=e.session.id,p=d.length+1+2+4+28+2+i+1+a+f,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(d)),It(h,2,t),It(h,1,o),f>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 o=null,a=0;a<n.length;++a){var s=F.pem.decode(n[a])[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===o&&(o=F.asn1.fromDer(u.bytes(),!1));var l=F.util.createBuffer();It(l,3,u),i.putBuffer(l)}n=F.pki.certificateFromAsn1(o),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 f=3+i.length(),d=F.util.createBuffer();return d.putByte(_t.HandshakeType.certificate),d.putInt24(f),It(d,3,i),d},_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],o=F.pki.distinguishedNameToAsn1(i.subject),a=F.asn1.toDer(o);r.putInt16(a.length()),r.putBuffer(a)}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 o=F.util.createBuffer();return o.putByte(_t.HandshakeType.finished),o.putInt24(t.length()),o.putBuffer(t),o},_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(),o=Math.max(16,i-r-3);return n.putBytes(F.random.getBytes(o)),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 o=0;o<n.length&&!e.fail;++o){var a=n[o];e.state.current.write.update(e,a)&&e.records.push(a)}}},_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 o=new Error("The application rejected the certificate.");throw o.send=!0,o.alert={level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate},i.message&&(o.message=i.message),i.alert&&(o.alert.description=i.alert),o}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,o=e.sessionCache?_t.createSessionCache(e.sessionCache):null,a={version:{major:_t.Version.major,minor:_t.Version.minor},entity:i,sessionId:e.sessionId,caStore:t,sessionCache:o,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){a.version={major:_t.Version.major,minor:_t.Version.minor},a.record=null,a.session=null,a.peerCertificate=null,a.state={pending:null,current:null},a.expect=(_t.ConnectionEnd.client,0),a.fragmented=null,a.records=[],a.open=!1,a.handshakes=0,a.handshaking=!1,a.isConnected=!1,a.fail=!(e||void 0===e),a.input.clear(),a.tlsData.clear(),a.data.clear(),a.state.current=_t.createConnectionState(a)}};return a.reset(),a.handshake=function(e){if(a.entity!==_t.ConnectionEnd.client)a.error(a,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(a.handshaking)a.error(a,{message:"Handshake already in progress.",fatal:!1});else{a.fail&&!a.open&&0===a.handshakes&&(a.fail=!1),a.handshaking=!0;var t=null;(e=e||"").length>0&&(a.sessionCache&&(t=a.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&a.sessionCache&&null!==(t=a.sessionCache.getSession())&&(e=t.id),a.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&&(a.version=t.version,a.session.sp=t.sp),a.session.sp.client_random=_t.createRandom().getBytes(),a.open=!0,_t.queue(a,_t.createRecord(a,{type:_t.ContentType.handshake,data:_t.createClientHello(a)})),_t.flush(a)}},a.process=function(e){var t=0;return e&&a.input.putBytes(e),a.fail||(null!==a.record&&a.record.ready&&a.record.fragment.isEmpty()&&(a.record=null),null===a.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}(a)),a.fail||null===a.record||a.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}(a)),!a.fail&&null!==a.record&&a.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)}(a,a.record)),t},a.prepare=function(e){return _t.queue(a,_t.createRecord(a,{type:_t.ContentType.application_data,data:F.util.createBuffer(e)})),_t.flush(a)},a.prepareHeartbeatRequest=function(e,t){return e instanceof F.util.ByteBuffer&&(e=e.bytes()),void 0===t&&(t=e.length),a.expectedHeartbeatPayload=e,_t.queue(a,_t.createRecord(a,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_request,e,t)})),_t.flush(a)},a.close=function(e){if(!a.fail&&a.sessionCache&&a.session){var t={id:a.session.id,version:a.session.version,sp:a.session.sp};t.sp.keys=null,a.sessionCache.setSession(t.id,t)}a.open&&(a.open=!1,a.input.clear(),(a.isConnected||a.handshaking)&&(a.isConnected=a.handshaking=!1,_t.queue(a,_t.createAlert(a,{level:_t.Alert.Level.warning,description:_t.Alert.Description.close_notify})),_t.flush(a)),a.closed(a)),a.reset(e)},a},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,w((function(e){var t=e.exports=F.tls;function r(e,r,i){var o=r.entity===F.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:F.cipher.createDecipher("AES-CBC",o?i.keys.server_write_key:i.keys.client_write_key),iv:o?i.keys.server_write_IV:i.keys.client_write_IV},e.write.cipherState={init:!1,cipher:F.cipher.createCipher("AES-CBC",o?i.keys.client_write_key:i.keys.server_write_key),iv:o?i.keys.client_write_IV:i.keys.server_write_IV},e.read.cipherFunction=a,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,o=!1,a=r.macFunction(r.macKey,r.sequenceNumber,e);e.fragment.putBytes(a),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(),o=!0),o}function i(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function o(e,t,r){var n=!0;if(r){for(var i=t.length(),o=t.last(),a=i-1-o;a<i-1;++a)n=n&&t.at(a)==o;n&&t.truncate(o+1)}return n}function a(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 a=r.cipherState.cipher;a.start({iv:n}),a.update(e.fragment),i=a.finish(o);var s=r.macLength,c=F.random.getBytesSync(s),u=a.output.length();u>=s?(e.fragment=a.output.getBytes(u-s),c=a.output.getBytes(s)):e.fragment=a.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])},w((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),o=[[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]],(a={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],a["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],a["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],a["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 a))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=a[e],r=null,c=F.util.createBuffer(),u=new Array(80),l=0;l<80;++l)u[l]=new Array(2);var f=64;switch(e){case"SHA-384":f=48;break;case"SHA-512/256":f=32;break;case"SHA-512/224":f=28}var d={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:f,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){d.messageLength=0,d.fullMessageLength=d.messageLength128=[];for(var e=d.messageLengthSize/4,n=0;n<e;++n)d.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 d}};return d.start(),d.update=function(e,t){"utf8"===t&&(e=F.util.encodeUtf8(e));var n=e.length;d.messageLength+=n,n=[n/4294967296>>>0,n>>>0];for(var i=d.fullMessageLength.length-1;i>=0;--i)d.fullMessageLength[i]+=n[1],n[1]=n[0]+(d.fullMessageLength[i]/4294967296>>>0),d.fullMessageLength[i]=d.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(),d},d.digest=function(){var t=F.util.createBuffer();t.putBytes(c.bytes());var i,o=d.fullMessageLength[d.fullMessageLength.length-1]+d.messageLengthSize&d.blockLength-1;t.putBytes(n.substr(0,d.blockLength-o));for(var a=8*d.fullMessageLength[0],l=0;l<d.fullMessageLength.length-1;++l)a+=(i=8*d.fullMessageLength[l+1])/4294967296>>>0,t.putInt32(a>>>0),a=i>>>0;t.putInt32(a);var f=new Array(r.length);for(l=0;l<r.length;++l)f[l]=r[l].slice(0);s(f,u,t);var p,h=F.util.createBuffer();for(p="SHA-512"===e?f.length:"SHA-384"===e?f.length-2:f.length-4,l=0;l<p;++l)h.putInt32(f[l][0]),l===p-1&&"SHA-512/224"===e||h.putInt32(f[l][1]);return h},d};var n=null,i=!1,o=null,a=null;function s(e,t,r){for(var n,i,a,s,c,u,l,f,d,p,h,g,m,y,v,b,C,w,E,k,S,B,T,A,I,_,x,R,P,N,L,O,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=(((R=(N=t[x-2])[0])>>>19|(P=N[1])<<13)^(P>>>29|R<<3)^R>>>6)>>>0,i=((R<<13|P>>>19)^(P<<3|R>>>29)^(R<<26|P>>>6))>>>0,a=(((R=(O=t[x-15])[0])>>>1|(P=O[1])<<31)^(R>>>8|P<<24)^R>>>7)>>>0,s=((R<<31|P>>>1)^(R<<24|P>>>8)^(R<<25|P>>>7))>>>0,L=t[x-7],D=t[x-16],P=i+L[1]+s+D[1],t[x][0]=n+L[0]+a+D[0]+(P/4294967296>>>0)>>>0,t[x][1]=P>>>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],w=e[3][1],E=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=((E>>>14|k<<18)^(E>>>18|k<<14)^(k>>>9|E<<23))>>>0,f=(T^E&(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,d=(h&m|v&(h^m))>>>0,p=(g&y|b&(g^y))>>>0,P=_+(((E<<18|k>>>14)^(E<<14|k>>>18)^(k<<23|E>>>9))>>>0)+((A^k&(B^A))>>>0)+o[x][1]+t[x][1],n=I+l+f+o[x][0]+t[x][0]+(P/4294967296>>>0)>>>0,i=P>>>0,a=c+d+((P=u+p)/4294967296>>>0)>>>0,s=P>>>0,I=T,_=A,T=S,A=B,S=E,B=k,E=C+n+((P=w+i)/4294967296>>>0)>>>0,k=P>>>0,C=v,w=b,v=m,b=y,m=h,y=g,h=n+a+((P=i+s)/4294967296>>>0)>>>0,g=P>>>0;P=e[0][1]+g,e[0][0]=e[0][0]+h+(P/4294967296>>>0)>>>0,e[0][1]=P>>>0,P=e[1][1]+y,e[1][0]=e[1][0]+m+(P/4294967296>>>0)>>>0,e[1][1]=P>>>0,P=e[2][1]+b,e[2][0]=e[2][0]+v+(P/4294967296>>>0)>>>0,e[2][1]=P>>>0,P=e[3][1]+w,e[3][0]=e[3][0]+C+(P/4294967296>>>0)>>>0,e[3][1]=P>>>0,P=e[4][1]+k,e[4][0]=e[4][0]+E+(P/4294967296>>>0)>>>0,e[4][1]=P>>>0,P=e[5][1]+B,e[5][0]=e[5][0]+S+(P/4294967296>>>0)>>>0,e[5][1]=P>>>0,P=e[6][1]+A,e[6][0]=e[6][0]+T+(P/4294967296>>>0)>>>0,e[6][1]=P>>>0,P=e[7][1]+_,e[7][0]=e[7][0]+I+(P/4294967296>>>0)>>>0,e[7][1]=P>>>0,U-=128}}}));var lr=F.asn1,fr={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"}]}},dr=fr.publicKeyValidator,pr=fr.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),Pr(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),o=F.oids.EdDSA25519;if(i!==o)throw new Error('Invalid OID "'+i+'"; OID must be "'+o+'".');var a=t.privateKey;return{privateKeyBytes:vr({message:F.asn1.fromDer(a).value,encoding:"binary"})}},yr.publicKeyFromAsn1=function(e){var t={},r=[];if(!F.asn1.validate(e,dr,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var i=F.asn1.derToOid(t.publicKeyOid),o=F.oids.EdDSA25519;if(i!==o)throw new Error('Invalid OID "'+i+'"; OID must be "'+o+'".');var a=t.ed25519PublicKey;if(a.length!==yr.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return vr({message:a,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,o,a=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),Pr(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)a[i]=0;for(i=0;i<32;++i)a[i]=u[i];for(i=0;i<32;++i)for(o=0;o<32;o++)a[i+o]+=l[i]*c[o];Ir(e.subarray(32),a)}(n,t,t.length,r);for(var i=new mr(yr.constants.SIGN_BYTE_LENGTH),o=0;o<i.length;++o)i[o]=n[o];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,o=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length),a=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length);for(i=0;i<yr.constants.SIGN_BYTE_LENGTH;++i)o[i]=r[i];for(i=0;i<t.length;++i)o[i+yr.constants.SIGN_BYTE_LENGTH]=t[i];return function(e,t,r,n){var i,o=new mr(32),a=[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(),o=zr(),a=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(o,i,wr),qr(i,i,e[2]),Kr(o,e[2],o),Hr(a,o),Hr(s,a),Gr(c,s,a),Gr(r,c,i),Gr(r,r,o),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,o),Gr(r,r,o),Gr(e[0],r,o),Hr(n,e[0]),Gr(n,n,o),Lr(n,i)&&Gr(e[0],e[0],Tr),Hr(n,e[0]),Gr(n,n,o),Lr(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(a,s,c),Mr(s,t.subarray(32)),xr(a,s),Pr(o,a),r-=64,Or(t,0,o,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}(a,o,o.length,n)>=0};var br=zr(),Cr=zr([1]),wr=zr([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),Er=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 o=new mr(yr.constants.HASH_BYTE_LENGTH),a=0;a<64;++a)o[a]=i.charCodeAt(a);return o}function Ir(e,t){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i<o;++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(),o=zr(),a=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,Er),Gr(o,e[2],t[2]),Kr(o,o,o),qr(a,n,r),qr(s,o,i),Kr(c,o,i),Kr(u,n,r),Gr(e[0],a,s),Gr(e[1],u,c),Gr(e[2],c,s),Gr(e[3],a,u)}function Rr(e,t,r){for(var n=0;n<4;++n)Fr(e[n],t[n],r)}function Pr(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,o=zr(),a=zr();for(r=0;r<16;++r)a[r]=t[r];for(jr(a),jr(a),jr(a),n=0;n<2;++n){for(o[0]=a[0]-65517,r=1;r<15;++r)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),i=o[15]>>16&1,o[14]&=65535,Fr(a,o,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function Lr(e,t){var r=new mr(32),n=new mr(32);return Nr(r,e),Nr(n,t),Or(r,0,n,0)}function Or(e,t,r,n){return function(e,t,r,n,i){var o,a=0;for(o=0;o<i;++o)a|=e[t+o]^r[n+o];return(1&a-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)Rr(e,t,n=r[i/8|0]>>(7&i)&1),xr(t,e),xr(e,e),Rr(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),o=0;o<16;++o)n=i&(e[o]^t[o]),e[o]^=n,t[o]^=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,o=0,a=0,s=0,c=0,u=0,l=0,f=0,d=0,p=0,h=0,g=0,m=0,y=0,v=0,b=0,C=0,w=0,E=0,k=0,S=0,B=0,T=0,A=0,I=0,_=0,x=0,R=0,P=0,N=0,L=0,O=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];o+=(n=t[0])*D,a+=n*U,s+=n*M,c+=n*V,u+=n*j,l+=n*F,f+=n*z,d+=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*$,a+=(n=t[1])*D,s+=n*U,c+=n*M,u+=n*V,l+=n*j,f+=n*F,d+=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,w+=n*$,s+=(n=t[2])*D,c+=n*U,u+=n*M,l+=n*V,f+=n*j,d+=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,w+=n*Y,E+=n*$,c+=(n=t[3])*D,u+=n*U,l+=n*M,f+=n*V,d+=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,w+=n*X,E+=n*Y,k+=n*$,u+=(n=t[4])*D,l+=n*U,f+=n*M,d+=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,w+=n*W,E+=n*X,k+=n*Y,S+=n*$,l+=(n=t[5])*D,f+=n*U,d+=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,w+=n*Q,E+=n*W,k+=n*X,S+=n*Y,B+=n*$,f+=(n=t[6])*D,d+=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,w+=n*G,E+=n*Q,k+=n*W,S+=n*X,B+=n*Y,T+=n*$,d+=(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,w+=n*H,E+=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,w+=n*q,E+=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,w+=n*K,E+=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,w+=n*z,E+=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,w+=n*F,E+=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,R+=n*$,y+=(n=t[12])*D,v+=n*U,b+=n*M,C+=n*V,w+=n*j,E+=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,R+=n*Y,P+=n*$,v+=(n=t[13])*D,b+=n*U,C+=n*M,w+=n*V,E+=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,R+=n*X,P+=n*Y,N+=n*$,b+=(n=t[14])*D,C+=n*U,w+=n*M,E+=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,R+=n*W,P+=n*X,N+=n*Y,L+=n*$,C+=(n=t[15])*D,a+=38*(E+=n*M),s+=38*(k+=n*V),c+=38*(S+=n*j),u+=38*(B+=n*F),l+=38*(T+=n*z),f+=38*(A+=n*K),d+=38*(I+=n*q),p+=38*(_+=n*H),h+=38*(x+=n*G),g+=38*(R+=n*Q),m+=38*(P+=n*W),y+=38*(N+=n*X),v+=38*(L+=n*Y),b+=38*(O+=n*$),o=(n=(o+=38*(w+=n*U))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+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)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+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)),o=(n=(o+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+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)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+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)),o+=i-1+37*(i-1),e[0]=o,e[1]=a,e[2]=s,e[3]=c,e[4]=u,e[5]=l,e[6]=f,e[7]=d,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 o=new F.util.ByteBuffer,a=Math.ceil(i/n)+r,s=new F.util.ByteBuffer,c=r;c<a;++c){s.putInt32(c),t.start(),t.update(e+s.getBytes());var u=t.digest();o.putBytes(u.getBytes(n))}return o.truncate(o.length()-i),o.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,o=Math.ceil(t.n.bitLength()/8);do{i=new Qr(F.util.bytesToHex(r.getBytesSync(o)),16).mod(t.n)}while(i.compareTo(Qr.ONE)<=0);var a=o-(i=F.util.hexToBytes(i.toString(16))).length;return a>0&&(i=F.util.fillString(String.fromCharCode(0),a)+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 on=F.util.getQueryVariables();"console.level"in on&&F.log.setLevel($r,on["console.level"].slice(-1)[0]),"console.lock"in on&&"true"==on["console.lock"].slice(-1)[0]&&F.log.lock($r)}F.log.consoleLogger=$r,w((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 o=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw o.errors=i,o}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 o(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 o=e.unauthenticatedAttributes[i];n.values.push(a(o))}r.value.push(n)}return r}function a(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"),o=e.value;if("string"==typeof o){var a=Date.parse(o);o=isNaN(a)?13===o.length?t.utcTimeToDate(o):t.generalizedTimeToDate(o):new Date(a)}r=o>=n&&o<i?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(o)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(o))}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 o=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw o.errors=o,o}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 a="";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.");a+=i.encryptedContent[s].value}else a=i.encryptedContent;e.encryptedContent={algorithm:t.derToOid(i.encAlgorithm),parameter:F.util.createBuffer(i.encParameter.value),content:F.util.createBuffer(a)}}if(i.content){if(a="",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.");a+=i.content[s].value}else a=i.content;e.content=F.util.createBuffer(a)}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 o=t.fromDer(n.body);return r.messageFromAsn1(o)},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 o=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw o.errors=i,o}var a,s=t.derToOid(n.contentType);switch(s){case F.pki.oids.envelopedData:a=r.createEnvelopedData();break;case F.pki.oids.encryptedData:a=r.createEncryptedData();break;case F.pki.oids.signedData:a=r.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+s+" is not (yet) supported.")}return a.fromAsn1(n.content.value[0]),a},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=[],o=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&&o.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,r)),i.length>0&&o.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,i)),o.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()),o])},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 o=t.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof o&&(o=F.pki.privateKeyFromPem(o));var a=t.digestAlgorithm||F.pki.oids.sha1;switch(a){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: "+a)}var s=t.authenticatedAttributes||[];if(s.length>0){for(var c=!1,u=!1,l=0;l<s.length;++l){var f=s[l];if(c||f.type!==F.pki.oids.contentType){if(u||f.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:o,version:1,issuer:r,serialNumber:n,digestAlgorithm:a,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 f=e.signers[l];if(0===f.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{f.authenticatedAttributesAsn1=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var d=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[]),p=0;p<f.authenticatedAttributes.length;++p){var h=f.authenticatedAttributes[p];h.type===F.pki.oids.messageDigest?h.value=r[f.digestAlgorithm].digest():h.type===F.pki.oids.signingTime&&(h.value||(h.value=u)),d.value.push(a(h)),f.authenticatedAttributesAsn1.value.push(a(h))}s=t.toDer(d).getBytes(),f.md.start().update(s)}f.signature=f.key.sign(f.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=function(e){for(var t=[],r=0;r<e.length;++r)t.push(o(e[r]));return t}(e.signers)}(function(){for(var r={},n=0;n<e.signers.length;++n){var i=e.signers[n];(o=i.digestAlgorithm)in r||(r[o]=F.md[F.pki.oids[o]].create()),0===i.authenticatedAttributes.length?i.md=r[o]:i.md=F.md[F.pki.oids[o]].create()}for(var o 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(o).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],o=i.issuer;if(i.serialNumber===t.serialNumber&&o.length===r.length){for(var a=!0,s=0;s<r.length;++s)if(o[s].type!==r[s].type||o[s].value!==r[s].value){a=!1;break}if(a)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,o;switch(r=r||e.encryptedContent.algorithm,t=t||e.encryptedContent.key,r){case F.pki.oids["aes128-CBC"]:n=16,i=16,o=F.aes.createEncryptionCipher;break;case F.pki.oids["aes192-CBC"]:n=24,i=16,o=F.aes.createEncryptionCipher;break;case F.pki.oids["aes256-CBC"]:n=32,i=16,o=F.aes.createEncryptionCipher;break;case F.pki.oids["des-EDE3-CBC"]:n=24,i=8,o=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 a=o(t);if(a.start(e.encryptedContent.parameter.copy()),a.update(e.content),!a.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=a.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)}}}}}})),w((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,o){var a=""===(t=t||"")?"none":"aes256-cbc",s="PuTTY-User-Key-File-2: ssh-rsa\r\n";s+="Encryption: "+a+"\r\n",s+="Comment: "+(o=o||"")+"\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 f,d=F.util.createBuffer();if(r(d,e.d),r(d,e.p),r(d,e.q),r(d,e.qInv),t){var p=d.length()+16-1;p-=p%16;var h=i(d.bytes());h.truncate(h.length()-p+d.length()),d.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(d.copy()),m.finish();var y=m.output;y.truncate(16),f=F.util.encode64(y.bytes(),64)}else f=F.util.encode64(d.bytes(),64);s+="\r\nPrivate-Lines: "+(l=Math.floor(f.length/66)+1)+"\r\n",s+=f;var v=i("putty-private-key-file-mac-key",t),b=F.util.createBuffer();n(b,"ssh-rsa"),n(b,a),n(b,o),b.putInt32(c.length()),b.putBuffer(c),b.putInt32(d.length()),b.putBuffer(d);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(),o=F.util.createBuffer();n(o,"ssh-rsa"),r(o,e.e),r(o,e.n),i.start(),i.update(o.getBytes());var a=i.digest();if("hex"===t.encoding){var s=a.toHex();return t.delimiter?s.match(/.{2}/g).join(t.delimiter):s}if("binary"===t.encoding)return a.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".');return a}}));var an="forge.task",sn={},cn=0;F.debug.set(an,"tasks",sn);var un={};F.debug.set(an,"queues",un);var ln="ready",fn="running",dn="blocked",pn="sleeping",hn="done",gn="error",mn={ready:{}};mn.ready.stop=ln,mn.ready.start=fn,mn.ready.cancel=hn,mn.ready.fail=gn,mn.running={},mn.running.stop=ln,mn.running.start=fn,mn.running.block=dn,mn.running.unblock=fn,mn.running.sleep=pn,mn.running.wakeup=fn,mn.running.cancel=hn,mn.running.fail=gn,mn.blocked={},mn.blocked.stop=dn,mn.blocked.start=dn,mn.blocked.block=dn,mn.blocked.unblock=dn,mn.blocked.sleep=dn,mn.blocked.wakeup=dn,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(an,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=fn,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()}})},o=0;o<t.length;o++)i(e+"__parallel-"+r.id+"-"+o,o)}))},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===fn&&(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=fn,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=fn,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=fn,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===fn)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(an,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):un[e.type][0]!==e?F.log.error(an,"[%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(an,"[%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===fn&&(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,wn=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,o=Cn.cipher.createDecipher("AES-CBC",t);return o.start({iv:r}),o.update(Cn.util.createBuffer(Cn.util.hexToBytes(e))),i=(n=o.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}(),En=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 o=D(e,t,n,{headers:i.httpHeaders});this.transactionManager=new j(o),this.encryptionService=new wn(t),this.compareFaceService=new f(o),this.clientSettingsService=new d(o),this.convertPDFService=new v(o),this.ekycPDFService=new b(o),this.readIDCardService=new r(o),this.requestVerifyIDCardService=new h(o),this.requestVerifyPortraitSerivce=new g(o),this.imagesService=new u(o),this.fileService=new l(o),this.verifyFaceLivenessService=new p(o),this.searchFaceService=new y(o),this.detectIDTamperingService=new m(o),this.httpClient=o}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)},o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"compareFaces",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"convertPDF",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"readIDCard",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"requestVerifyIDCard",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"requestVerifyPortrait",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"verifyFaceLiveness",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"searchFaces",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"deleteFaces",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"indexFaces",null),o([M({headerIndex:1}),V(),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],e.prototype,"detectIDTampering",null),e}();e.ReadIDCard=r,e.UploadImage=u,e.UploadFile=l,e.CompareFaces=f,e.ClientSettings=d,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=L,e.createHelpers=function(e,t,r){void 0===r&&(r="production");var n=new L(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=En,Object.defineProperty(e,"__esModule",{value:!0})}(t,r.default)})));function r$(e){var t=e.className;return ay.createElement("svg",{className:t,width:"320",height:"320",viewBox:"0 0 320 320",fill:"none",xmlns:"http://www.w3.org/2000/svg"},ay.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"}))}r$.propTypes={className:Ry.string},r$.defaultProps={className:""};var n$,i$,o$,a$,s$,c$,u$,l$,f$,d$,p$,h$,g$,m$,y$=(nm(HY={},aC.FaceDirection.LEFT,90),nm(HY,aC.FaceDirection.RIGHT,270),nm(HY,aC.FaceDirection.UP,180),nm(HY,aC.FaceDirection.DOWN,0),HY),v$=nC(["0%{background:#0A84FF;}50%{background:#DAECFF;}100%{background:#DAECFF;}"]),b$=eC.div(GY||(GY=fm(["\n width: 100%;\n height: 100%;\n position: relative;\n\n .top,\n .right,\n .bottom,\n .left {\n position: absolute;\n }\n\n .top {\n top: 0px;\n left: 50%;\n transform: rotate(","deg) translateX(-50%);\n }\n\n .right {\n right: 0px;\n top: 50%;\n transform: rotate(","deg) translateX(-50%);\n }\n\n .bottom {\n bottom: 0px;\n left: 50%;\n transform: rotate(","deg) translateX(50%);\n }\n\n .left {\n left: 0px;\n top: 50%;\n transform: rotate(","deg) translateX(50%);\n }\n"])),y$[aC.FaceDirection.DOWN],y$[aC.FaceDirection.LEFT],y$[aC.FaceDirection.UP],y$[aC.FaceDirection.RIGHT]),C$=eC.div(QY||(QY=fm(["\n width: 3rem;\n transform: rotate(","deg);\n\n &.ic_up,\n &.ic_right,\n &.ic_bottom,\n &.ic_left {\n position: absolute;\n }\n &.ic_up {\n top: 35px;\n }\n\n &.ic_right {\n right: 35px;\n }\n\n &.ic_bottom {\n bottom: 35px;\n }\n\n &.ic_left {\n left: 35px;\n }\n"])),(function(e){var t,r=e.direction;return null!==(t=y$[r])&&void 0!==t?t:0})),w$=eC.span(WY||(WY=fm(["\n display: flex;\n margin: 5px 0;\n width: 100%;\n height: 11px;\n\n &::before,\n &::after {\n content: '';\n height: 100%;\n width: 50%;\n background: rgb(10, 132, 255);\n animation: "," 1s linear infinite;\n animation-direction: alternate;\n }\n\n &::before {\n transform: skewY(35deg);\n }\n\n &::after {\n width: 50%;\n transform: skewY(-35deg);\n }\n"])),v$),E$=eC(w$)(XY||(XY=fm(["\n &::before,\n &::after {\n animation-delay: 0s;\n }\n"]))),k$=eC(w$)(YY||(YY=fm(["\n &::before,\n &::after {\n animation-delay: 0.5s;\n }\n"]))),S$=eC(w$)($Y||($Y=fm(["\n &::before,\n &::after {\n animation-delay: 1s;\n }\n"]))),B$=nC(["0%{-webkit-transform:translateY(0px);-moz-transform:translateY(0px);-ms-transform:translateY(0px);transform:translateY(0px);}100%{-webkit-transform:translateY(30px);-moz-transform:translateY(30px);-ms-transform:translateY(30px);transform:translateY(30px);}"]),T$=eC.span(ZY||(ZY=fm(["\n display: flex;\n margin: 5px 0;\n width: 100%;\n height: 11px;\n animation: "," 0.5s infinite;\n animation-direction: alternate;\n\n &::before,\n &::after {\n content: '';\n height: 100%;\n width: 50%;\n background: rgb(10, 132, 255);\n }\n\n &::before {\n transform: skewY(35deg);\n }\n\n &::after {\n width: 50%;\n transform: skewY(-35deg);\n }\n"])),B$),A$=eC(T$)(JY||(JY=fm(["\n animation-delay: 0.1s;\n"])));function I$(e){var t=e.type;return t!==aC.FaceDirection.FRONTAL?ay.createElement(C$,{direction:t,className:"ic_".concat(t)},ay.createElement(E$,null),ay.createElement(k$,null),ay.createElement(S$,null)):ay.createElement(b$,null,ay.createElement(C$,{className:"top"},ay.createElement(A$,null)),ay.createElement(C$,{className:"right"},ay.createElement(A$,null)),ay.createElement(C$,{className:"bottom"},ay.createElement(A$,null)),ay.createElement(C$,{className:"left"},ay.createElement(A$,null)))}I$.propTypes={type:Ry.oneOf([aC.FaceDirection.LEFT,aC.FaceDirection.RIGHT,aC.FaceDirection.UP,aC.FaceDirection.FRONTAL])},I$.defaultProps={type:aC.FaceDirection.LEFT};var _$=650,x$=750,R$=FF.Camera,P$=bG.Text,N$=bG.FaceDetectionError,L$=bG.FaceVerificationInstructions,O$=bG.FaceVerificationStepsWrapper,D$=bG.StepItem,U$=bG.BottomButtonsOverlay,M$=bG.Button,V$=bG.CountDownOverlay,j$=bG.InstructionsOverlay,F$=eC(O$)(n$||(n$=fm(["\n height: 50px;\n"]))),z$=eC(N$)(i$||(i$=fm(["\n position: absolute;\n font-size: 0.938rem;\n text-align: center;\n background: none;\n color: ",";\n max-width: 95%;\n"])),DX.errorColor),K$=eC(L$)(o$||(o$=fm(["\n position: absolute;\n font-size: 1.125rem;\n text-align: center;\n padding: 0 1.75rem 0.625rem 1.75rem;\n color: ",";\n text-shadow: none;\n z-index: 1020;\n\n ",";\n"])),(function(e){return e.color}),(function(e){return e.isMobile&&Vb(["font-size:1.125rem;"])})),q$=eC(r$)(a$||(a$=fm(["\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:"#06243c"})),H$=eC.img(s$||(s$=fm(["\n && {\n width: 100%;\n border-radius: 4px;\n margin: 0;\n\n ","\n }\n"])),(function(e){return"preview"===e.mode&&Vb(["width:39px;"])})),G$=eC(D$)(c$||(c$=fm(["\n width: 40px;\n height: 40px;\n border: 1px solid #000;\n border-radius: 4px;\n opacity: 1;\n\n & + & {\n margin-left: 16px;\n }\n"]))),Q$=eC(M$)(u$||(u$=fm(["\n z-index: 1100;\n position: absolute;\n top: 13px;\n right: 16px;\n width: 25px;\n"]))),W$=eC(P$)(l$||(l$=fm(["\n position: absolute;\n font-style: normal;\n font-weight: 600;\n font-size: 16px;\n text-align: center;\n padding: 0 1.75rem;\n color: #000000;\n\n ","\n"])),(function(e){var t=e.top;return t&&Vb(["top:","px;"],t)})),X$=eC(Uj)(f$||(f$=fm(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"]))),Y$=eC(j$)(d$||(d$=fm(["\n position: absolute;\n width: 100%;\n top: 0;\n bottom: 0;\n"]))),$$=eC.div(p$||(p$=fm(["\n position: absolute;\n width: 100%;\n top: 0;\n bottom: 0;\n z-index: -1;\n"]))),Z$=nC(["from{opacity:1;}to{opacity:0;}"]),J$=eC($$)(h$||(h$=fm(["\n background: rgba(255, 255, 255, 0.3);\n animation: "," 1s infinite;\n"])),Z$),eZ=WD.isMobile?{width:640}:null;function tZ(e){var t=e.className,r=e.apiCheck,n=e.enableInstructionsOverlay,i=e.enableCapturingOverlay,o=e.mode,a=e.minPadding,s=e.backgroundColor,c=e.textColor,u=e.progressProps,l=e.customInstructions,f=e.customIcon,d=e.customDirectionIcon,p=e.onLivenessDetectionDone,h=e.onClose,g=e.onError,m=e.captureFrameSettings,y=e.onFramesCaptured,v=e.apiCredentials,b=e.onProcessing,C=e.customErrors,w=e.livenessSettings,E=e.outputEncryptionSettings,k=e.title,S=Hk.useAsset("ic_close.svg"),B=lk.useSDKSettings().lang,T=k||tY.SELFIE_TITLE[B];ay.useEffect((function(){var e=document.querySelector("html").style.overflow,t=document.body.style.overflow;return document.querySelector("html").style.overflow="hidden",document.body.style.overflow="hidden",function(){document.querySelector("html").style.overflow=e,document.body.style.overflow=t}}),[]);var A=ay.useCallback((function(e){var t=e.clientWidth,r=e.clientHeight,n=e.videoAreaWidth,i=e.videoAreaHeight,o=e.lostX,s=e.lostY,c=Math.max(60,s),u=Math.max(90,s);r>_$&&(c=Math.max(70,s),u=Math.max(140,s)),r>x$&&(c=Math.max(70,s),u=Math.max(140,s));var l=Math.max(a,o),f=Math.max(a,o),d=Math.min(n,i),p=Math.max(Math.floor(Math.min(t-(l+f),r-(c+u),d)),160);return{x:Math.min(Math.floor(l+(t-f-l)/2-p/2),t-p),y:Math.min(Math.floor(c+(r-u-c)/2-p/2),r-p),width:p,height:p}}),[a]),I=ay.useMemo((function(){return{background:s,opacity:1}}),[s]),_=vG({apiCheck:r,mode:o,bgCameraMask:null,bgCameraMaskRed:null,surroundStyle:I,cropAreaDimension:A,customInstructions:l,customIcon:f,customDirectionIcon:d,onLivenessDetectionDone:p,captureFrameSettings:m,onFramesCaptured:y,apiCredentials:v,onError:g,livenessSettings:w,onProcessing:b,customErrors:C,outputEncryptionSettings:E}),x=_.countdownToTakePicture,R=_.cropArea,P=_.curStepIndex,N=_.directionIcon,L=_.faceDetectionError,O=_.handleTriggerPassiveMode,D=_.handleVideoPlayed,U=_.instructions,M=_.isActiveMode,V=_.refVideo,j=_.showCountdown,F=_.steps,z=_.videoPlayed,K=_.activeCapturing,q=_.warmupDone,H=50,G=12,Q=14;window.innerHeight>_$&&(H=50,G=24,Q=34),window.innerHeight>x$&&(H=50,G=24,Q=40);var W=Q+H+G;var X=L?{dashedRingColor:"#FF3B30",activeColor:"#FF3B30"}:{};return ay.createElement(gU,{ref:V,className:t,frontCamera:!0,flipHorizontal:!0,videoSettings:eZ,onVideoPlayed:D,onClose:h,onError:g,closeButton:ay.createElement(Q$,null,ay.createElement("img",{src:S,alt:""}))},!q&&ay.createElement(gF,null),z?ay.createElement(ay.Fragment,null,ay.createElement(W$,{top:16},T),ay.createElement(z$,{top:R.current.y-35,className:"face-detection-error",error:L}),R.current?ay.createElement(wU,{x:"".concat(R.current.x,"px"),y:"".concat(R.current.y,"px"),width:"".concat(R.current.width,"px"),height:"".concat(R.current.height,"px"),surroundStyle:R.current.surroundStyle},ay.createElement(q$,{color:s}),ay.createElement(X$,im({progress:P/F.length*100,showOutsideRing:!1,showInsideRing:!1},u,X)),4===P?ay.createElement(X$,{activeColor:"#15B000",dashedRingWidth:5,dashedRingColor:"#15B000",dashedRingOpacity:1,dashedInsideRingWidth:0,dashedRingLineThick:2,dashedRingLineSpacing:2,errorRingWidth:2,showOutsideRing:!1,showInsideRing:!1}):null,j?ay.createElement(V$,null,x):null,M&&n&&N?ay.createElement(Y$,null,N):null,M&&i&&K?ay.createElement(J$,null):null):null,M?ay.createElement(ay.Fragment,null,U?ay.createElement(K$,{bottom:W,isMobile:WD.isMobile,color:c},U):null,ay.createElement(F$,{bottom:Q},F.map((function(e,t){var r=e.name,n=e.icon,i=e.image.objUrl,o=P>=t;return ay.createElement(G$,{key:r,active:o},i?ay.createElement(H$,{src:i,alt:"",mode:"preview"}):function(e,t){return"string"==typeof e?ay.createElement(H$,{src:e,alt:""}):ay.cloneElement(e,t)}(n,{active:o}))})))):ay.createElement(ay.Fragment,null,L?null:ay.createElement(U$,null,ay.createElement(M$,{onClick:O},ay.createElement(R$,null))))):null)}function rZ(e){return ay.createElement(WF,im({},e,{livenessComponent:tZ}))}tZ.propTypes={className:Ry.string,apiCheck:Ry.bool,enableInstructionsOverlay:Ry.bool,enableErrorOverlay:Ry.bool,enableCapturingOverlay:Ry.bool,mode:Ry.string,minPadding:Ry.number,backgroundColor:Ry.string,textColor:Ry.string,progressProps:Ry.shape({className:Ry.string,style:Ry.shape({}),radius:Ry.number,strokeWidth:Ry.number,progress:Ry.number,activeColor:Ry.string,innerPadding:Ry.number,outsideRingColor:Ry.string,insideRingColor:Ry.string,insideRingWidth:Ry.number,dashedRingColor:Ry.string,dashedRingWidth:Ry.number,dashedRingLineThick:Ry.number,dashedRingLineSpacing:Ry.number,showOutsideRing:Ry.bool,showDashedRing:Ry.bool,showInsideRing:Ry.bool}),title:Ry.string,description:Ry.string,customInstructions:Ry.shape({}),customIcon:Ry.shape({}),customDirectionIcon:Ry.shape({}),onLivenessDetectionDone:Ry.func,onClose:Ry.func,onError:Ry.func,captureFrameSettings:Ry.shape({}),onFramesCaptured:Ry.func,apiCredentials:Ry.shape({accessKey:Ry.string,secretKey:Ry.string,apiUrl:Ry.string}),onProcessing:Ry.func,customErrors:Ry.shape({}),livenessSettings:Ry.shape({}),outputEncryptionSettings:Ry.shape({})},tZ.defaultProps={className:"",apiCheck:!1,mode:null,minPadding:5,description:"",customIcon:null,customDirectionIcon:(g$={},nm(g$,aC.FaceDirection.LEFT,ay.createElement(I$,{type:aC.FaceDirection.LEFT})),nm(g$,aC.FaceDirection.RIGHT,ay.createElement(I$,{type:aC.FaceDirection.RIGHT})),nm(g$,aC.FaceDirection.UP,ay.createElement(I$,{type:aC.FaceDirection.UP})),nm(g$,aC.FaceDirection.FRONTAL,ay.createElement(I$,{type:aC.FaceDirection.FRONTAL})),g$),onLivenessDetectionDone:null,onClose:null,onError:function(){},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:function(){},apiCredentials:{accessKey:"5767c20d-87aa-4cad-8dbb-f5429f76c34b",secretKey:"c1446919-e60a-4575-a05d-304318212a1b",apiUrl:"https://tv-testing.trustingsocial.com/api"},enableInstructionsOverlay:!0,enableErrorOverlay:!0,enableCapturingOverlay:!0,backgroundColor:"#ffffff",textColor:"inherit",progressProps:{activeColor:"#06498C",dashedRingWidth:5,dashedRingColor:"#DAECFF",dashedRingOpacity:1,dashedInsideRingWidth:0,dashedRingLineThick:2,dashedRingLineSpacing:2,errorRingWidth:2},title:"",customInstructions:(m$={},nm(m$,aC.FaceDirection.LEFT,{vi:"Vui lòng quay đầu sang trái",en:"Please turn to the left"}),nm(m$,aC.FaceDirection.RIGHT,{vi:"Vui lòng quay đầu sang phải",en:"Please turn to the right"}),nm(m$,aC.FaceDirection.UP,{vi:"Vui lòng nhìn lên",en:"Please look up"}),nm(m$,aC.FaceDirection.FRONTAL,{vi:"Vui lòng nhìn thẳng vào máy ảnh",en:"Please look straight into the camera"}),m$),onProcessing:function(){},customErrors:null,livenessSettings:null,outputEncryptionSettings:null};var nZ=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,iZ=/^\w*$/;var oZ=function(e,t){if(SQ(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!fW(e))||(iZ.test(e)||!nZ.test(e)||null!=t&&e in Object(t))},aZ=XG(Object,"create");var sZ=function(){this.__data__=aZ?aZ(null):{},this.size=0};var cZ=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},uZ=Object.prototype.hasOwnProperty;var lZ=function(e){var t=this.__data__;if(aZ){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return uZ.call(t,e)?t[e]:void 0},fZ=Object.prototype.hasOwnProperty;var dZ=function(e){var t=this.__data__;return aZ?void 0!==t[e]:fZ.call(t,e)};var pZ=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=aZ&&void 0===t?"__lodash_hash_undefined__":t,this};function hZ(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])}}hZ.prototype.clear=sZ,hZ.prototype.delete=cZ,hZ.prototype.get=lZ,hZ.prototype.has=dZ,hZ.prototype.set=pZ;var gZ=hZ;var mZ=function(){this.__data__=[],this.size=0};var yZ=function(e,t){for(var r=e.length;r--;)if(ZG(e[r][0],t))return r;return-1},vZ=Array.prototype.splice;var bZ=function(e){var t=this.__data__,r=yZ(t,e);return!(r<0)&&(r==t.length-1?t.pop():vZ.call(t,r,1),--this.size,!0)};var CZ=function(e){var t=this.__data__,r=yZ(t,e);return r<0?void 0:t[r][1]};var wZ=function(e){return yZ(this.__data__,e)>-1};var EZ=function(e,t){var r=this.__data__,n=yZ(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function kZ(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])}}kZ.prototype.clear=mZ,kZ.prototype.delete=bZ,kZ.prototype.get=CZ,kZ.prototype.has=wZ,kZ.prototype.set=EZ;var SZ=kZ,BZ=XG(kG,"Map");var TZ=function(){this.size=0,this.__data__={hash:new gZ,map:new(BZ||SZ),string:new gZ}};var AZ=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var IZ=function(e,t){var r=e.__data__;return AZ(t)?r["string"==typeof t?"string":"hash"]:r.map};var _Z=function(e){var t=IZ(this,e).delete(e);return this.size-=t?1:0,t};var xZ=function(e){return IZ(this,e).get(e)};var RZ=function(e){return IZ(this,e).has(e)};var PZ=function(e,t){var r=IZ(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function NZ(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])}}NZ.prototype.clear=TZ,NZ.prototype.delete=_Z,NZ.prototype.get=xZ,NZ.prototype.has=RZ,NZ.prototype.set=PZ;var LZ=NZ;function OZ(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],o=r.cache;if(o.has(i))return o.get(i);var a=e.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(OZ.Cache||LZ),r}OZ.Cache=LZ;var DZ=OZ;var UZ=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,MZ=/\\(\\)?/g,VZ=function(e){var t=DZ(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(UZ,(function(e,r,n,i){t.push(n?i.replace(MZ,"$1"):r||e)})),t}));var jZ=function(e,t){return SQ(e)?e:oZ(e,t)?[e]:VZ(gW(e))};var FZ=function(e){if("string"==typeof e||fW(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var zZ=function(e,t){for(var r=0,n=(t=jZ(t,e)).length;null!=e&&r<n;)e=e[FZ(t[r++])];return r&&r==n?e:void 0};var KZ=function(e,t,r){var n=null==e?void 0:zZ(e,t);return void 0===n?r:n},qZ=["tracking","clientSettings"];function HZ(e){var t=e.tracking,r=e.clientSettings,n=lm(e,qZ),i=ay.useMemo((function(){return KZ(r,"data.settings.sdk_settings.server_log_settings.enable",null==t?void 0:t.enable)}),[r,t]);return ay.createElement(zk.SDKTrackingProvider,{value:{tracking:am(am({},t),{},{enable:i})}},ay.createElement(qY,im({},n,{clientSettings:r})))}HZ.propTypes={tracking:Ry.shape({}),clientSettings:Ry.shape({})},HZ.defaultProps={tracking:void 0,clientSettings:void 0};var GZ=["onClose","onError","detectIdCard","steps","onStepDone","apiCredentials","tracking","outputEncryptionSettings"],QZ=aC.Errors,WZ=function(e){var t=e.onClose,r=e.onError,n=e.detectIdCard,i=e.steps,o=e.onStepDone,a=e.apiCredentials,s=e.tracking,c=e.outputEncryptionSettings,u=lm(e,GZ),l=dm(ay.useState(null),2),f=l[0],d=l[1],p=YB.useApiClient({apiCredentials:a,tracking:s}).apiClient,h=ay.useRef(""),g=ay.useRef("");ay.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,p.clientSettings();case 2:t=e.sent,d(t);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[p]);var m=ay.useCallback(function(){var e=Jg(regeneratorRuntime.mark((function e(t){var n,a,s,u,l,f,d,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.stepNumber,a=t.recordedVideos,s=t.qrScannedResult,u=t.image,l=i[n],f=l.cardType,d=l.cardSide,m=null,e.prev=3,e.next=6,lG({image:u,cardSide:d,frontCardId:h.current,qrImageId:g.current,onError:r,apiClient:p,cardType:f,recordedVideos:a,qrScannedResult:s,outputEncryptionSettings:c});case 6:m=e.sent,d===aC.IDCardSide.FRONT&&(h.current=m.cardInfo.image1.id),g.current=m.qrImageId,e.next=14;break;case 11:e.prev=11,e.t0=e.catch(3),r(am(am({},QZ.api_call_error),{},{details:e.t0}));case 14:m&&o(am(am({},t),{},{apiResult:m}));case 15:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t){return e.apply(this,arguments)}}(),[p,r,i,o,c]);return f&&ay.createElement(HZ,im({tracking:s,onClose:t,onError:r,detectIdCard:n,onStepDone:m,steps:i,outputEncryptionSettings:c},u,{clientSettings:f}))};WZ.propTypes={onClose:Ry.func,onError:Ry.func,detectIdCard:Ry.func,onStepDone:Ry.func,steps:Ry.arrayOf(Ry.shape({})),apiCredentials:Ry.shape({accessKey:Ry.string,secretKey:Ry.string,apiUrl:Ry.string}),tracking:Ry.shape({}),outputEncryptionSettings:Ry.shape({})},WZ.defaultProps={onClose:function(){},onError:function(){},detectIdCard:function(){return Promise.resolve({card_label:""})},onStepDone:function(){},steps:FY,apiCredentials:{accessKey:"5767c20d-87aa-4cad-8dbb-f5429f76c34b",secretKey:"c1446919-e60a-4575-a05d-304318212a1b",apiUrl:"https://tv-testing.trustingsocial.com/api"},outputEncryptionSettings:{key:""},tracking:void 0};var XZ=kk.getUAMetadata(),YZ=function(){function e(t){var r=this,n=t.container,i=t.lang,o=void 0===i?"en":i,a=t.assetRoot,s=void 0===a?"https://unpkg.com/@tsocial/tvweb-sdk@latest/assets":a,c=t.resourceRoot,u=t.customUrls,l=void 0===u?{}:u,f=t.enableAntiDebug,d=void 0===f||f;em(this,e),nm(this,"checkCamera",UF),nm(this,"initNativeCamera",(function(e){var t=document.createElement("div");document.body.appendChild(t);var r=ay.createRef();return yD.render(ay.createElement(VF,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",zK(t));case 2:case"end":return e.stop()}}),e)})))),nm(this,"runPreloadEKYCResources",Jg(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.commonSettings.customUrls,mG(t);case 2:case"end":return e.stop()}}),e)})))),nm(this,"destroyView",(function(){yD.unmountComponentAtNode(r.container)})),e$(n,"container is a required parameter"),this.container=n,this.container.style="touch-action: none; -ms-touch-action: none;";var p=ok({resourceRoot:c,initCustomUrls:l});this.commonSettings={lang:o,assetRoot:s,customUrls:p,enableAntiDebug:d,debug:!1}}return rm(e,[{key:"readIDCardWithApiCall",value:function(e){yD.render(ay.createElement(lk.SDKSettingsProvider,{value:am(am({},this.commonSettings),{},{container:this.container})},ay.createElement(WZ,im({onClose:this.destroyView},e))),this.container)}},{key:"readIDCardUIOnly",value:function(e){yD.render(ay.createElement(lk.SDKSettingsProvider,{value:am(am({},this.commonSettings),{},{container:this.container})},ay.createElement(HZ,e)),this.container)}},{key:"livenessDetection",value:function(e){yD.render(ay.createElement(lk.SDKSettingsProvider,{value:am(am({},this.commonSettings),{},{container:this.container})},ay.createElement(rZ,e)),this.container)}},{key:"compareFaces",value:function(e){var t=e.accessKey,r=e.secretKey,n=e.apiUrl,i=e.image1,o=e.image2,a=e.onSuccess,s=e.onError;YB.createRetryAPIClient(new t$(t,r,n,{httpHeaders:XZ})).compareFaces({image1:{id:i},image2:{id:o}}).then((function(e){a(e)})).catch((function(e){s(e)}))}}]),e}();exports.APIUtils=YB,exports.Animations=Gz,exports.AntiDebugUtils=bT,exports.AssetUtils=Hk,exports.AsyncUtils=Qk,exports.BASE_Z_INDEX=1e3,exports.BlurUtils=yS,exports.Button=dq,exports.ButtonLink=pq,exports.Camera=gU,exports.CameraUtils=bS,exports.CommonUtils=wS,exports.Constants=aC,exports.CoordinateUtils=TS,exports.CropAreaOverlayWrapper=wU,exports.CryptoUtils=ET,exports.FaceUtils=LS,exports.GlareUtils=jB,exports.HashUtils=Nk,exports.HighlightResult=vH,exports.HighlightResultType=fH,exports.Icons=FF,exports.ImageUtils=DB,exports.LivenessDetection=WF,exports.LivenessDetectionComponents=bG,exports.LoadResourceUtils=oT,exports.LocalStorageUtils=_k,exports.MobileDetect=WD,exports.ModelUtils=vT,exports.NativeCamera=VF,exports.PlacementArea=CU,exports.Popup=Yj,exports.PredictionUtils=MS,exports.ProgressCircle=Uj,exports.RatioWrapper=Rq,exports.ReadIDCardUIOnly=$H,exports.ReadIDCardWithApiCall=hG,exports.RectangleMask=pz,exports.RectangleMaskType=dz,exports.SDK=YZ,exports.ScannerType=GH,exports.SettingsContext=lk,exports.Spacing=oq,exports.ThemeUtils=CT,exports.TimeUtils=Tk,exports.TrackingContext=zk,exports.UserAgentUtils=kk,exports.WarmupPopup=gF,exports.checkCamera=UF,exports.defaultClientSettings=jH,exports.defaultReadIDCardSteps=FY,exports.getCustomUrlsBySettings=ok,exports.getQrScannerWorkerPath=kT,exports.handleApiCheckReadIdCard=lG,exports.preloadEKYCResources=mG,exports.readIdCardFromImage=yG,exports.readQRCodeFromImage=nH,exports.useLivenessDetection=vG,exports.useMainProcessQRCodeScanner=iH,exports.useMainProcessReadIdCard=XK,exports.useSettingsReadIdCard=FH,exports.useShowPopup=pK,exports.warmUpQRCodeScanner=Kq,exports.warmUpReadIdCard=zK,exports.warmupSelfieActive=fj;