/* Copyright (c) 2022 Synology Inc. All rights reserved. */ Ext.ns("SYNO.SDS.C2FS.Utils.LocalStatusWatch"),SYNO.SDS.C2FS.Utils.LocalStatusWatch.WatchStoreInterface=class e{constructor(){if(this.constructor===e)throw new Error("Abstract class cannot be initiated")}get paths(){throw new Error("Abstract method not implemented")}getLocalStatusCallback(e,t){throw new Error("Abstract method not implemented")}},Ext.ns("SYNO.SDS.C2FS.Utils.LocalStatusWatch"),Ext.define("SYNO.SDS.C2FS.Utils.LocalStatusWatch.Watcher",{extend:"Ext.Component",initComponent:function(...e){SYNO.SDS.C2FS.Utils.LocalStatusWatch.Watcher.superclass.initComponent.apply(this,e),this._pathToStores=new Map,this._webapiTask=this.addWebAPITask(this._getWebAPIRequestConfig())},watchByFilePaths(e,t){if(!(t instanceof SYNO.SDS.C2FS.Utils.LocalStatusWatch.WatchStoreInterface))throw new TypeError(`Invalid argument: ${t}`);e.forEach(e=>{this._pathToStores.has(e)?this._pathToStores.get(e).add(t):this._pathToStores.set(e,new Set([t]))}),this.hasMoreWatches()&&(this._updateWebAPIWatchingFiles(),this._webapiTask.start())},stopWatchingByWatchStore(e){if(!(e instanceof SYNO.SDS.C2FS.Utils.LocalStatusWatch.WatchStoreInterface))throw new TypeError(`Invalid argument: ${e}`);e.paths.forEach(t=>{this._removeStores(t,[e])}),this.hasMoreWatches()?this._updateWebAPIWatchingFiles():this._webapiTask.stop()},hasMoreWatches(){return 0!==this._pathToStores.size},_updateWebAPIWatchingFiles(){this._webapiTask.apply(this._getWebAPIRequestConfig())},_getWebAPIRequestConfig(){return{interval:5e3,api:"SYNO.C2FS.File",method:"get_local_status",version:1,params:{paths:this._getWatchFilePaths()},scope:this,callback:this._getLocalStatusCallback}},_getWatchFilePaths(){return Array.from(this._pathToStores.keys())},_getLocalStatusCallback(e,t,r,i){if(e){for(const[e,r]of Object.entries(t)){const t=this._pathToStores.get(e).filter(t=>{try{return t.getLocalStatusCallback(e,r)}catch(e){return SYNO.Debug(e),!0}});this._removeStores(e,t)}this.hasMoreWatches()?this._updateWebAPIWatchingFiles():this._webapiTask.stop()}else SYNO.Debug("Failed to do webapi SYNO.C2FS.File.get_local_status:1, "+`params: [${r}], resp: [${t}].`)},_removeStores:function(e,t){const r=this._pathToStores.get(e);void 0!==r&&(t.forEach(e=>{r.delete(e)}),0===r.size&&this._pathToStores.delete(e))}}),Ext.apply(SYNO.SDS.C2FS.Utils.LocalStatusWatch,{_watcher:null,watchByFilePaths(e,t){const r=SYNO.SDS.C2FS.Utils.LocalStatusWatch;null===r._watcher&&(r._watcher=new SYNO.SDS.C2FS.Utils.LocalStatusWatch.Watcher),r._watcher.watchByFilePaths(e,t)},stopWatchingByWatchStore(e){const t=SYNO.SDS.C2FS.Utils.LocalStatusWatch;null!==t._watcher&&(t._watcher.stopWatchingByWatchStore(e),t._watcher.hasMoreWatches()||(t._watcher=null))}}),Ext.ns("SYNO.SDS.C2FS"),SYNO.SDS.C2FS.Helper={PKG_ID:"HybridShare",GLOBAL_CONF:{},T:function(e,t){return _TT("SYNO.SDS.C2FS.Application",e,t)||_T(e,t)||String.format("{0}",t)},pkgVersion:function(){return Object.prototype.hasOwnProperty.call(SYNO.SDS.Config.FnMap["SYNO.SDS.C2FS.Application"],"config")&&Object.prototype.hasOwnProperty.call(SYNO.SDS.Config.FnMap["SYNO.SDS.C2FS.Application"].config,"version")?SYNO.SDS.Config.FnMap["SYNO.SDS.C2FS.Application"].config.version:""},setGlobalConf:function(e){SYNO.SDS.C2FS.Helper.GLOBAL_CONF=e},getGlobalConf:function(e,t){const r=SYNO.SDS.C2FS.Helper.GLOBAL_CONF[e];return void 0!==r?r:t},getMaxC2fsNumFromGlobalConf:function(e){return SYNO.SDS.C2FS.Helper.getGlobalConf("max_c2fs_num",e)},maxC2fsNum:function(){return SYNO.SDS.Utils.isInVirtualDSM()?SYNO.SDS.C2FS.Helper.getMaxC2fsNumFromGlobalConf(8):SYNO.SDS.C2FS.Helper.getMaxC2fsNumFromGlobalConf(parseInt(_D("max_c2fs_num")))},toolTipRenderer:function(e,t,r){if(!e||"-"===e)return"-";const i=Ext.util.Format.htmlEncode(e),n=Ext.util.Format.htmlEncode(i);return String.format('{1}',n,i)},getSelectedObjectFromCombobox:function(e){return e&&Object.prototype.hasOwnProperty.call(e,"selectedIndex")&&Object.prototype.hasOwnProperty.call(e,"store")?e.getStore().getAt(e.selectedIndex)||e.getStore().getById(e.getValue()):null},popupErrorMessage:function(e,t,r){const i=SYNO.SDS.C2FS.Helper.ErrorMap.T(t)||SYNO.SDS.C2FS.Helper.T("common","error_system");if(!e||!e.getMsgBox)return!1;e.getMsgBox().alert(e.title,i,r||Ext.emptyFn)},popupFeasibilityCheckMsg:function(e,t,r){let i=SYNO.SDS.C2FS.Helper.T("common","error_system");return t&&t.hard?(i=SYNO.SDS.C2FS.Helper.T("share","edit_hard_check_fail"),i+="
"+SYNO.SDS.Utils.GetFeasibilityCheckMsgJoin(t.hard)+"",void e.getMsgBox().alert("warning_msg",i)):t&&t.soft?(i=SYNO.SDS.C2FS.Helper.T("share","edit_soft_check_fail"),i+="
"+SYNO.SDS.Utils.GetFeasibilityCheckMsgJoin(t.soft)+"",void e.getMsgBox().confirm("warning_msg",i,function(e){"yes"===e&&r()},e)):void e.getMsgBox().alert("warning_msg",i)},timeRender:function(e,t,r){const i={s:1,m:2,h:3,d:4};(r=i[r]?i[r]:i.d)<(t=i[t]?i[t]:i.s)&&(r=[t,t=r][0]);const n=[];let s=0,o=0,a=0;return r>i.s&&(s=e/60,e%=60),r>i.m&&(o=s/60,s%=60),r>i.h&&(a=o/24,o%=24),e=Math.floor(e),s=Math.floor(s),o=Math.floor(o),a=Math.floor(a),t<=i.d&&0!==a&&n.push(String.format("{0} {1}",a,1===a?SYNO.SDS.C2FS.Helper.T("common","time_day"):SYNO.SDS.C2FS.Helper.T("common","time_days"))),t<=i.h&&0!==o&&n.push(String.format("{0} {1}",o,1===o?SYNO.SDS.C2FS.Helper.T("common","time_hour"):SYNO.SDS.C2FS.Helper.T("common","time_hours"))),t<=i.m&&0!==s&&n.push(String.format("{0} {1}",s,1===s?SYNO.SDS.C2FS.Helper.T("common","time_minute"):SYNO.SDS.C2FS.Helper.T("common","time_minutes"))),t<=i.s&&0!==e&&n.push(String.format("{0} {1}",e,1===e?SYNO.SDS.C2FS.Helper.T("common","time_second"):SYNO.SDS.C2FS.Helper.T("common","time_seconds"))),0===n.length&&(t===i.d&&n.push(String.format("{0} {1}",a,SYNO.SDS.C2FS.Helper.T("common","time_day"))),t===i.h&&n.push(String.format("{0} {1}",o,SYNO.SDS.C2FS.Helper.T("common","time_hour"))),t===i.m&&n.push(String.format("{0} {1}",s,SYNO.SDS.C2FS.Helper.T("common","time_minute"))),t===i.s&&n.push(String.format("{0} {1}",e,SYNO.SDS.C2FS.Helper.T("common","time_second")))),n.join(" ")},approximateTime:(e,t)=>e?(t||(t=4),[86400,3600,60,1].reduce((r,i)=>t?(r+=e-e%i,e%=i,r>0&&t--,r):r,0)):0,percentRender:function(e,t,r){return parseFloat((100*e/t).toFixed(r||2))+"%"},capacityRender:function(e,t){let r=SYNO.SDS.C2FS.Helper.T("common","size_kb"),i=e;return i<0&&(i=0),i>=1024&&(i/=1024,r=SYNO.SDS.C2FS.Helper.T("common","size_mb")),i>=1024&&(i/=1024,r=SYNO.SDS.C2FS.Helper.T("common","size_gb")),i>=1024&&(i/=1024,r=SYNO.SDS.C2FS.Helper.T("common","size_tb")),i.toFixed(Number.isInteger(t)&&t>=0?t:2)+" "+r},addAlignedBullet:e=>String.format('
{0}
',e),addWhiteTipHtml:e=>"
',addLinkForString:(e,t,...r)=>String.format.apply(this,[t,'',""].concat(r)),periodForConcat:function(){return this.T("common","period")+(["cht","chs","jpn"].includes(_S("lang"))?"":" ")}},SYNO.SDS.C2FS.Helper.ErrorMap={ERR_NO_SUCH_API:102,ERR_NO_SUCH_METHODS:103,ERR_BAD_PARAMETER:401,ERR_OPERATION:402,ERR_BACKUP:403,ERR_RESTORE:404,ERR_OPEN_FILE:405,ERR_READ_FILE:406,ERR_NO_FILE:407,ERR_NOT_JSON:408,ERR_NOT_SUBVOLUME:409,ERR_NOT_FEASIBLE:410,ERR_INVALID_SHARENAME:500,ERR_NO_SUCH_SHARE:501,ERR_NOT_C2SHARE:502,ERR_VOLUME_IS_NOT_BTRFS:503,ERR_VOLUME_IS_READ_ONLY:504,ERR_TARGET_SHARE_NAME_EXISTED:505,ERR_TARGET_VOLUME_IS_NOT_BTRFS:506,ERR_TARGET_VOLUME_IS_READ_ONLY:507,ERR_TARGET_SHARE_PATH_EXISTS:508,ERR_MULTI_MOUNT:509,ERR_UPDATE_ATTRIBUTE:510,ERR_LOCAL_CACHE_MAX_EXCEED:510,ERR_BAD_CONF:512,ERR_CACHE_SIZE_TOO_LOW:513,ERR_DESCRIPTION_TOO_LONG:514,ERR_UNSYNC_EXCEED_CACHE_SIZE:515,ERR_EXCEED_C2_SHARE_NUM:518,ERR_SHARE_NAME_RESERVED:519,ERR_NEED_SPACE_USAGE:520,ERR_BUCKET_CONNECT:600,ERR_BUCKET_INFO:601,ERR_BUCKET_NOT_FOUND:602,ERR_BUCKET_INVALID_SCOPED_TOKEN:603,ERR_BUCKET_NOT_SUITABLE_PASSWORD:604,ERR_BUCKET_ENCRYPT_FAILED:605,ERR_BUCKET_IS_ALREADY_MOUNT:606,ERR_BUCKET_ALREADY_ENCRYPT:607,ERR_BUCKET_WRONG_PASSWORD:608,ERR_BUCKET_BAD_PASSWORD_KEY:609,ERR_C2FS_CLIENT_VERSION_INCOMPATIBLE:700,ERR_C2FS_TRANSFORM_UNCANCELLABLE:702,ERR_C2FS_FILE_PIN_OPERATION_FAILED:800,ERR_C2FS_FILE_UNPIN_OPERATION_FAILED:801,ERR_C2FS_FILE_PIN_PARTIAL_FAILED:802,ERR_C2FS_FILE_UNPIN_PARTIAL_FAILED:803,T:function(e){switch(e){case this.ERR_NO_SUCH_API:case this.ERR_NO_SUCH_METHODS:return SYNO.SDS.C2FS.Helper.T("share","c2_need_package");case this.ERR_BAD_PARAMETER:case this.ERR_OPERATION:case this.ERR_BACKUP:case this.ERR_RESTORE:case this.ERR_OPEN_FILE:case this.ERR_READ_FILE:case this.ERR_NO_FILE:case this.ERR_NOT_JSON:case this.ERR_NOT_SUBVOLUME:case this.ERR_NOT_FEASIBLE:return"";case this.ERR_INVALID_SHARENAME:return SYNO.SDS.C2FS.Helper.T("share","error_badname");case this.ERR_NO_SUCH_SHARE:return SYNO.SDS.C2FS.Helper.T("share","no_such_share");case this.ERR_NOT_C2SHARE:return SYNO.SDS.C2FS.Helper.T("error","not_c2share");case this.ERR_VOLUME_IS_NOT_BTRFS:return"";case this.ERR_VOLUME_IS_READ_ONLY:return SYNO.SDS.C2FS.Helper.T("share","error_volume_read_only");case this.ERR_TARGET_SHARE_NAME_EXISTED:return SYNO.SDS.C2FS.Helper.T("share","share_already_exist");case this.ERR_TARGET_VOLUME_IS_NOT_BTRFS:return SYNO.SDS.C2FS.Helper.T("error","target_volume_is_not_btrfs");case this.ERR_TARGET_VOLUME_IS_READ_ONLY:return SYNO.SDS.C2FS.Helper.T("error","target_volume_is_read_only");case this.ERR_TARGET_SHARE_PATH_EXISTS:return SYNO.SDS.C2FS.Helper.T("error","target_share_path_exists");case this.ERR_MULTI_MOUNT:return SYNO.SDS.C2FS.Helper.T("error","multi_mount");case this.ERR_UPDATE_ATTRIBUTE:return SYNO.SDS.C2FS.Helper.T("error","update_attribute");case this.ERR_LOCAL_CACHE_MAX_EXCEED:return SYNO.SDS.C2FS.Helper.T("error","local_cache_max_exceed");case this.ERR_BAD_CONF:return SYNO.SDS.C2FS.Helper.T("error","broken_share");case this.ERR_CACHE_SIZE_TOO_LOW:return SYNO.SDS.C2FS.Helper.T("error","local_cache_min_exceed_strong");case this.ERR_DESCRIPTION_TOO_LONG:return"";case this.ERR_UNSYNC_EXCEED_CACHE_SIZE:return SYNO.SDS.C2FS.Helper.T("error","local_cache_min_exceed_soft");case this.ERR_EXCEED_C2_SHARE_NUM:return String.format(SYNO.SDS.C2FS.Helper.T("error","exceed_c2_share_num"),SYNO.SDS.C2FS.Helper.maxC2fsNum());case this.ERR_SHARE_NAME_RESERVED:return SYNO.SDS.C2FS.Helper.T("share","error_nameused");case this.ERR_NEED_SPACE_USAGE:return SYNO.SDS.C2FS.Helper.T("error","need_enable_space_usage");case this.ERR_BUCKET_CONNECT:return SYNO.SDS.C2FS.Helper.T("error","bucket_connect_failed");case this.ERR_BUCKET_INFO:return"";case this.ERR_BUCKET_NOT_FOUND:return SYNO.SDS.C2FS.Helper.T("error","bucket_not_found");case this.ERR_BUCKET_INVALID_SCOPED_TOKEN:return SYNO.SDS.C2FS.Helper.T("error","bucket_invalid_scoped_token");case this.ERR_BUCKET_NOT_SUITABLE_PASSWORD:return SYNO.SDS.C2FS.Helper.T("error","bucket_bad_password");case this.ERR_BUCKET_ENCRYPT_FAILED:return SYNO.SDS.C2FS.Helper.T("error","bucket_encrypt_failed");case this.ERR_BUCKET_IS_ALREADY_MOUNT:return SYNO.SDS.C2FS.Helper.T("error","bucket_is_already_mount");case this.ERR_BUCKET_ALREADY_ENCRYPT:return SYNO.SDS.C2FS.Helper.T("error","bucket_has_been_encrypt");case this.ERR_BUCKET_WRONG_PASSWORD:return SYNO.SDS.C2FS.Helper.T("error","bucket_wrong_password");case this.ERR_BUCKET_BAD_PASSWORD_KEY:return SYNO.SDS.C2FS.Helper.T("share","error_key_file");case this.ERR_C2FS_CLIENT_VERSION_INCOMPATIBLE:return SYNO.SDS.C2FS.Helper.T("error","client_version_incompatible");case this.ERR_C2FS_TRANSFORM_UNCANCELLABLE:return SYNO.SDS.C2FS.Helper.T("error","transform_cancel_fail");case this.ERR_C2FS_FILE_PIN_OPERATION_FAILED:return SYNO.SDS.C2FS.Helper.T("error","file_pin_operation_failed");case this.ERR_C2FS_FILE_UNPIN_OPERATION_FAILED:return SYNO.SDS.C2FS.Helper.T("error","file_unpin_operation_failed");case this.ERR_C2FS_FILE_PIN_PARTIAL_FAILED:return SYNO.SDS.C2FS.Helper.T("error","file_pin_partial_failed");case this.ERR_C2FS_FILE_UNPIN_PARTIAL_FAILED:return SYNO.SDS.C2FS.Helper.T("error","file_unpin_partial_failed");default:return""}}},function(){return function e(t,r,i){function n(o,a){if(!r[o]){if(!t[o]){var h="function"==typeof require&&require;if(!a&&h)return h(o,!0);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[o]={exports:{}};t[o][0].call(f.exports,function(e){return n(t[o][1][e]||e)},f,f.exports,e,t,r,i)}return r[o].exports}for(var s="function"==typeof require&&require,o=0;o>6],n=0==(32&r);if(31==(31&r)){let i=r;for(r=0;128==(128&i);){if(i=e.readUInt8(t),e.isError(i))return i;r<<=7,r|=127&i}}else r&=31;return{cls:i,primitive:n,tag:r,tagStr:a.tag[r]}}function u(e,t,r){let i=e.readUInt8(r);if(e.isError(i))return i;if(!t&&128===i)return null;if(0==(128&i))return i;const n=127&i;if(n>4)return e.error("length octect is too long");i=0;for(let t=0;t=31)return i.error("Multi-octet tag encoding unsupported");t||(n|=32);return n|=o.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(i.length<128){const e=n.alloc(2);return e[0]=s,e[1]=i.length,this._createEncoderBuffer([e,i])}let a=1;for(let e=i.length;e>=256;e>>=8)a++;const h=n.alloc(2+a);h[0]=s,h[1]=128|a;for(let e=1+a,t=i.length;t>0;e--,t>>=8)h[e]=255&t;return this._createEncoderBuffer([h,i])},h.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=n.alloc(2*e.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let i=0;for(let t=0;t=128;r>>=7)i++}const s=n.alloc(i);let o=s.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(s[o--]=127&r;(r>>=7)>0;)s[o--]=128|127&r}return this._createEncoderBuffer(s)},h.prototype._encodeTime=function(e,t){let r;const i=new Date(e);return"gentime"===t?r=[c(i.getUTCFullYear()),c(i.getUTCMonth()+1),c(i.getUTCDate()),c(i.getUTCHours()),c(i.getUTCMinutes()),c(i.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[c(i.getUTCFullYear()%100),c(i.getUTCMonth()+1),c(i.getUTCDate()),c(i.getUTCHours()),c(i.getUTCMinutes()),c(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},h.prototype._encodeNull=function(){return this._createEncoderBuffer("")},h.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!n.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=n.from(t)}if(n.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=n.alloc(t);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let r=1;for(let t=e;t>=256;t>>=8)r++;const i=new Array(r);for(let t=i.length-1;t>=0;t--)i[t]=255&e,e>>=8;return 128&i[0]&&i.unshift(0),this._createEncoderBuffer(n.from(i))},h.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},h.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},h.prototype._skipDefault=function(e,t,r){const i=this._baseState;let n;if(null===i.default)return!1;const s=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),s.length!==i.defaultBuffer.length)return!1;for(n=0;n=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function h(e,t,r){var i=a(e,r);return r-1>=t&&(i|=a(e,r-1)<<4),i}function c(e,t,r,i){for(var n=0,s=Math.min(e.length,r),o=t;o=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(e){return e instanceof s||null!==e&&"object"==typeof e&&e.constructor.wordSize===s.wordSize&&Array.isArray(e.words)},s.max=function(e,t){return e.cmp(t)>0?e:t},s.min=function(e,t){return e.cmp(t)<0?e:t},s.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n=0;n-=3)o=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var i=0;i=t;i-=2)n=h(e,t,i)<=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(e.length-t)%2==0?t+1:t;i=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this.strip()},s.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var s=e.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;r.length=i,i=i-1|0;var n=0|e.words[0],s=0|t.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var c=1;c>>26,u=67108863&h,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(o=(n=0|e.words[p])*(s=0|t.words[d])+u)/67108864|0,u=67108863&o}r.words[c]=0|u,h=0|f}return 0!==h?r.words[c]=0|h:r.length--,r.strip()}s.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var n=0,s=0,o=0;o>>24-n&16777215)||o!==this.length-1?f[6-h.length]+h+r:h+r,(n+=2)>=26&&(n-=26,o--)}for(0!==s&&(r=s.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=u[e],d=l[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?m+r:f[c-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(e,t){return i(void 0!==o),this.toArrayLike(o,e,t)},s.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},s.prototype.toArrayLike=function(e,t,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0"),this.strip();var o,a,h="le"===t,c=new e(s),f=this.clone();if(h){for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),c[a]=o;for(;a=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},s.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},s.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},s.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},s.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},s.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},s.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},s.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},s.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(e){return this.clone().inotn(e)},s.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var r=e/26|0,n=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,i=e):(r=e,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;se.length?this.clone().iadd(e):e.clone().iadd(this)},s.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=e):(r=e,i=this);for(var s=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==s&&o>26,this.words[o]=67108863&t;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,b=0|o[2],g=8191&b,y=b>>>13,S=0|o[3],_=8191&S,v=S>>>13,w=0|o[4],E=8191&w,M=w>>>13,O=0|o[5],k=8191&O,N=O>>>13,T=0|o[6],C=8191&T,x=T>>>13,A=0|o[7],D=8191&A,I=A>>>13,R=0|o[8],B=8191&R,P=R>>>13,F=0|o[9],L=8191&F,Y=F>>>13,U=0|a[0],j=8191&U,W=U>>>13,z=0|a[1],q=8191&z,H=z>>>13,V=0|a[2],G=8191&V,K=V>>>13,$=0|a[3],X=8191&$,Z=$>>>13,J=0|a[4],Q=8191&J,ee=J>>>13,te=0|a[5],re=8191&te,ie=te>>>13,ne=0|a[6],se=8191&ne,oe=ne>>>13,ae=0|a[7],he=8191&ae,ce=ae>>>13,fe=0|a[8],ue=8191&fe,le=fe>>>13,de=0|a[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(c+(i=Math.imul(u,j))|0)+((8191&(n=(n=Math.imul(u,W))+Math.imul(l,j)|0))<<13)|0;c=((s=Math.imul(l,W))+(n>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(p,j),n=(n=Math.imul(p,W))+Math.imul(m,j)|0,s=Math.imul(m,W);var ge=(c+(i=i+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,H)|0)+Math.imul(l,q)|0))<<13)|0;c=((s=s+Math.imul(l,H)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(g,j),n=(n=Math.imul(g,W))+Math.imul(y,j)|0,s=Math.imul(y,W),i=i+Math.imul(p,q)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,q)|0,s=s+Math.imul(m,H)|0;var ye=(c+(i=i+Math.imul(u,G)|0)|0)+((8191&(n=(n=n+Math.imul(u,K)|0)+Math.imul(l,G)|0))<<13)|0;c=((s=s+Math.imul(l,K)|0)+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(_,j),n=(n=Math.imul(_,W))+Math.imul(v,j)|0,s=Math.imul(v,W),i=i+Math.imul(g,q)|0,n=(n=n+Math.imul(g,H)|0)+Math.imul(y,q)|0,s=s+Math.imul(y,H)|0,i=i+Math.imul(p,G)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,G)|0,s=s+Math.imul(m,K)|0;var Se=(c+(i=i+Math.imul(u,X)|0)|0)+((8191&(n=(n=n+Math.imul(u,Z)|0)+Math.imul(l,X)|0))<<13)|0;c=((s=s+Math.imul(l,Z)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(E,j),n=(n=Math.imul(E,W))+Math.imul(M,j)|0,s=Math.imul(M,W),i=i+Math.imul(_,q)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(v,q)|0,s=s+Math.imul(v,H)|0,i=i+Math.imul(g,G)|0,n=(n=n+Math.imul(g,K)|0)+Math.imul(y,G)|0,s=s+Math.imul(y,K)|0,i=i+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,Z)|0;var _e=(c+(i=i+Math.imul(u,Q)|0)|0)+((8191&(n=(n=n+Math.imul(u,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((s=s+Math.imul(l,ee)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(k,j),n=(n=Math.imul(k,W))+Math.imul(N,j)|0,s=Math.imul(N,W),i=i+Math.imul(E,q)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(M,q)|0,s=s+Math.imul(M,H)|0,i=i+Math.imul(_,G)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(v,G)|0,s=s+Math.imul(v,K)|0,i=i+Math.imul(g,X)|0,n=(n=n+Math.imul(g,Z)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,Z)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,ee)|0;var ve=(c+(i=i+Math.imul(u,re)|0)|0)+((8191&(n=(n=n+Math.imul(u,ie)|0)+Math.imul(l,re)|0))<<13)|0;c=((s=s+Math.imul(l,ie)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(C,j),n=(n=Math.imul(C,W))+Math.imul(x,j)|0,s=Math.imul(x,W),i=i+Math.imul(k,q)|0,n=(n=n+Math.imul(k,H)|0)+Math.imul(N,q)|0,s=s+Math.imul(N,H)|0,i=i+Math.imul(E,G)|0,n=(n=n+Math.imul(E,K)|0)+Math.imul(M,G)|0,s=s+Math.imul(M,K)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,Z)|0)+Math.imul(v,X)|0,s=s+Math.imul(v,Z)|0,i=i+Math.imul(g,Q)|0,n=(n=n+Math.imul(g,ee)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(m,re)|0,s=s+Math.imul(m,ie)|0;var we=(c+(i=i+Math.imul(u,se)|0)|0)+((8191&(n=(n=n+Math.imul(u,oe)|0)+Math.imul(l,se)|0))<<13)|0;c=((s=s+Math.imul(l,oe)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(D,j),n=(n=Math.imul(D,W))+Math.imul(I,j)|0,s=Math.imul(I,W),i=i+Math.imul(C,q)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(x,q)|0,s=s+Math.imul(x,H)|0,i=i+Math.imul(k,G)|0,n=(n=n+Math.imul(k,K)|0)+Math.imul(N,G)|0,s=s+Math.imul(N,K)|0,i=i+Math.imul(E,X)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(M,X)|0,s=s+Math.imul(M,Z)|0,i=i+Math.imul(_,Q)|0,n=(n=n+Math.imul(_,ee)|0)+Math.imul(v,Q)|0,s=s+Math.imul(v,ee)|0,i=i+Math.imul(g,re)|0,n=(n=n+Math.imul(g,ie)|0)+Math.imul(y,re)|0,s=s+Math.imul(y,ie)|0,i=i+Math.imul(p,se)|0,n=(n=n+Math.imul(p,oe)|0)+Math.imul(m,se)|0,s=s+Math.imul(m,oe)|0;var Ee=(c+(i=i+Math.imul(u,he)|0)|0)+((8191&(n=(n=n+Math.imul(u,ce)|0)+Math.imul(l,he)|0))<<13)|0;c=((s=s+Math.imul(l,ce)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(B,j),n=(n=Math.imul(B,W))+Math.imul(P,j)|0,s=Math.imul(P,W),i=i+Math.imul(D,q)|0,n=(n=n+Math.imul(D,H)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,H)|0,i=i+Math.imul(C,G)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(x,G)|0,s=s+Math.imul(x,K)|0,i=i+Math.imul(k,X)|0,n=(n=n+Math.imul(k,Z)|0)+Math.imul(N,X)|0,s=s+Math.imul(N,Z)|0,i=i+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,ee)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,ee)|0,i=i+Math.imul(_,re)|0,n=(n=n+Math.imul(_,ie)|0)+Math.imul(v,re)|0,s=s+Math.imul(v,ie)|0,i=i+Math.imul(g,se)|0,n=(n=n+Math.imul(g,oe)|0)+Math.imul(y,se)|0,s=s+Math.imul(y,oe)|0,i=i+Math.imul(p,he)|0,n=(n=n+Math.imul(p,ce)|0)+Math.imul(m,he)|0,s=s+Math.imul(m,ce)|0;var Me=(c+(i=i+Math.imul(u,ue)|0)|0)+((8191&(n=(n=n+Math.imul(u,le)|0)+Math.imul(l,ue)|0))<<13)|0;c=((s=s+Math.imul(l,le)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(L,j),n=(n=Math.imul(L,W))+Math.imul(Y,j)|0,s=Math.imul(Y,W),i=i+Math.imul(B,q)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,H)|0,i=i+Math.imul(D,G)|0,n=(n=n+Math.imul(D,K)|0)+Math.imul(I,G)|0,s=s+Math.imul(I,K)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,Z)|0)+Math.imul(x,X)|0,s=s+Math.imul(x,Z)|0,i=i+Math.imul(k,Q)|0,n=(n=n+Math.imul(k,ee)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,ee)|0,i=i+Math.imul(E,re)|0,n=(n=n+Math.imul(E,ie)|0)+Math.imul(M,re)|0,s=s+Math.imul(M,ie)|0,i=i+Math.imul(_,se)|0,n=(n=n+Math.imul(_,oe)|0)+Math.imul(v,se)|0,s=s+Math.imul(v,oe)|0,i=i+Math.imul(g,he)|0,n=(n=n+Math.imul(g,ce)|0)+Math.imul(y,he)|0,s=s+Math.imul(y,ce)|0,i=i+Math.imul(p,ue)|0,n=(n=n+Math.imul(p,le)|0)+Math.imul(m,ue)|0,s=s+Math.imul(m,le)|0;var Oe=(c+(i=i+Math.imul(u,pe)|0)|0)+((8191&(n=(n=n+Math.imul(u,me)|0)+Math.imul(l,pe)|0))<<13)|0;c=((s=s+Math.imul(l,me)|0)+(n>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,i=Math.imul(L,q),n=(n=Math.imul(L,H))+Math.imul(Y,q)|0,s=Math.imul(Y,H),i=i+Math.imul(B,G)|0,n=(n=n+Math.imul(B,K)|0)+Math.imul(P,G)|0,s=s+Math.imul(P,K)|0,i=i+Math.imul(D,X)|0,n=(n=n+Math.imul(D,Z)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,Z)|0,i=i+Math.imul(C,Q)|0,n=(n=n+Math.imul(C,ee)|0)+Math.imul(x,Q)|0,s=s+Math.imul(x,ee)|0,i=i+Math.imul(k,re)|0,n=(n=n+Math.imul(k,ie)|0)+Math.imul(N,re)|0,s=s+Math.imul(N,ie)|0,i=i+Math.imul(E,se)|0,n=(n=n+Math.imul(E,oe)|0)+Math.imul(M,se)|0,s=s+Math.imul(M,oe)|0,i=i+Math.imul(_,he)|0,n=(n=n+Math.imul(_,ce)|0)+Math.imul(v,he)|0,s=s+Math.imul(v,ce)|0,i=i+Math.imul(g,ue)|0,n=(n=n+Math.imul(g,le)|0)+Math.imul(y,ue)|0,s=s+Math.imul(y,le)|0;var ke=(c+(i=i+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;c=((s=s+Math.imul(m,me)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(L,G),n=(n=Math.imul(L,K))+Math.imul(Y,G)|0,s=Math.imul(Y,K),i=i+Math.imul(B,X)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(P,X)|0,s=s+Math.imul(P,Z)|0,i=i+Math.imul(D,Q)|0,n=(n=n+Math.imul(D,ee)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,ee)|0,i=i+Math.imul(C,re)|0,n=(n=n+Math.imul(C,ie)|0)+Math.imul(x,re)|0,s=s+Math.imul(x,ie)|0,i=i+Math.imul(k,se)|0,n=(n=n+Math.imul(k,oe)|0)+Math.imul(N,se)|0,s=s+Math.imul(N,oe)|0,i=i+Math.imul(E,he)|0,n=(n=n+Math.imul(E,ce)|0)+Math.imul(M,he)|0,s=s+Math.imul(M,ce)|0,i=i+Math.imul(_,ue)|0,n=(n=n+Math.imul(_,le)|0)+Math.imul(v,ue)|0,s=s+Math.imul(v,le)|0;var Ne=(c+(i=i+Math.imul(g,pe)|0)|0)+((8191&(n=(n=n+Math.imul(g,me)|0)+Math.imul(y,pe)|0))<<13)|0;c=((s=s+Math.imul(y,me)|0)+(n>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,i=Math.imul(L,X),n=(n=Math.imul(L,Z))+Math.imul(Y,X)|0,s=Math.imul(Y,Z),i=i+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,ee)|0,i=i+Math.imul(D,re)|0,n=(n=n+Math.imul(D,ie)|0)+Math.imul(I,re)|0,s=s+Math.imul(I,ie)|0,i=i+Math.imul(C,se)|0,n=(n=n+Math.imul(C,oe)|0)+Math.imul(x,se)|0,s=s+Math.imul(x,oe)|0,i=i+Math.imul(k,he)|0,n=(n=n+Math.imul(k,ce)|0)+Math.imul(N,he)|0,s=s+Math.imul(N,ce)|0,i=i+Math.imul(E,ue)|0,n=(n=n+Math.imul(E,le)|0)+Math.imul(M,ue)|0,s=s+Math.imul(M,le)|0;var Te=(c+(i=i+Math.imul(_,pe)|0)|0)+((8191&(n=(n=n+Math.imul(_,me)|0)+Math.imul(v,pe)|0))<<13)|0;c=((s=s+Math.imul(v,me)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(L,Q),n=(n=Math.imul(L,ee))+Math.imul(Y,Q)|0,s=Math.imul(Y,ee),i=i+Math.imul(B,re)|0,n=(n=n+Math.imul(B,ie)|0)+Math.imul(P,re)|0,s=s+Math.imul(P,ie)|0,i=i+Math.imul(D,se)|0,n=(n=n+Math.imul(D,oe)|0)+Math.imul(I,se)|0,s=s+Math.imul(I,oe)|0,i=i+Math.imul(C,he)|0,n=(n=n+Math.imul(C,ce)|0)+Math.imul(x,he)|0,s=s+Math.imul(x,ce)|0,i=i+Math.imul(k,ue)|0,n=(n=n+Math.imul(k,le)|0)+Math.imul(N,ue)|0,s=s+Math.imul(N,le)|0;var Ce=(c+(i=i+Math.imul(E,pe)|0)|0)+((8191&(n=(n=n+Math.imul(E,me)|0)+Math.imul(M,pe)|0))<<13)|0;c=((s=s+Math.imul(M,me)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(L,re),n=(n=Math.imul(L,ie))+Math.imul(Y,re)|0,s=Math.imul(Y,ie),i=i+Math.imul(B,se)|0,n=(n=n+Math.imul(B,oe)|0)+Math.imul(P,se)|0,s=s+Math.imul(P,oe)|0,i=i+Math.imul(D,he)|0,n=(n=n+Math.imul(D,ce)|0)+Math.imul(I,he)|0,s=s+Math.imul(I,ce)|0,i=i+Math.imul(C,ue)|0,n=(n=n+Math.imul(C,le)|0)+Math.imul(x,ue)|0,s=s+Math.imul(x,le)|0;var xe=(c+(i=i+Math.imul(k,pe)|0)|0)+((8191&(n=(n=n+Math.imul(k,me)|0)+Math.imul(N,pe)|0))<<13)|0;c=((s=s+Math.imul(N,me)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(L,se),n=(n=Math.imul(L,oe))+Math.imul(Y,se)|0,s=Math.imul(Y,oe),i=i+Math.imul(B,he)|0,n=(n=n+Math.imul(B,ce)|0)+Math.imul(P,he)|0,s=s+Math.imul(P,ce)|0,i=i+Math.imul(D,ue)|0,n=(n=n+Math.imul(D,le)|0)+Math.imul(I,ue)|0,s=s+Math.imul(I,le)|0;var Ae=(c+(i=i+Math.imul(C,pe)|0)|0)+((8191&(n=(n=n+Math.imul(C,me)|0)+Math.imul(x,pe)|0))<<13)|0;c=((s=s+Math.imul(x,me)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(L,he),n=(n=Math.imul(L,ce))+Math.imul(Y,he)|0,s=Math.imul(Y,ce),i=i+Math.imul(B,ue)|0,n=(n=n+Math.imul(B,le)|0)+Math.imul(P,ue)|0,s=s+Math.imul(P,le)|0;var De=(c+(i=i+Math.imul(D,pe)|0)|0)+((8191&(n=(n=n+Math.imul(D,me)|0)+Math.imul(I,pe)|0))<<13)|0;c=((s=s+Math.imul(I,me)|0)+(n>>>13)|0)+(De>>>26)|0,De&=67108863,i=Math.imul(L,ue),n=(n=Math.imul(L,le))+Math.imul(Y,ue)|0,s=Math.imul(Y,le);var Ie=(c+(i=i+Math.imul(B,pe)|0)|0)+((8191&(n=(n=n+Math.imul(B,me)|0)+Math.imul(P,pe)|0))<<13)|0;c=((s=s+Math.imul(P,me)|0)+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863;var Re=(c+(i=Math.imul(L,pe))|0)+((8191&(n=(n=Math.imul(L,me))+Math.imul(Y,pe)|0))<<13)|0;return c=((s=Math.imul(Y,me))+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863,h[0]=be,h[1]=ge,h[2]=ye,h[3]=Se,h[4]=_e,h[5]=ve,h[6]=we,h[7]=Ee,h[8]=Me,h[9]=Oe,h[10]=ke,h[11]=Ne,h[12]=Te,h[13]=Ce,h[14]=xe,h[15]=Ae,h[16]=De,h[17]=Ie,h[18]=Re,0!==c&&(h[19]=c,r.length++),r};function m(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(p=d),s.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,t):r<63?d(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,e,t):m(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=s.prototype._countBits(e)-1,i=0;i>=1;return i},b.prototype.permute=function(e,t,r,i,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*t;o>=26,t+=n/67108864|0,t+=s>>>26,this.words[r]=67108863&s}return 0!==t&&(this.words[r]=t,this.length++),this},s.prototype.muln=function(e){return this.clone().imuln(e)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>n}return t}(e);if(0===t.length)return new s(1);for(var r=this,i=0;i=0);var t,r=e%26,n=(e-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(t=0;t>>26-r}o&&(this.words[t]=o,this.length++)}if(0!==n){for(t=this.length-1;t>=0;t--)this.words[t+n]=this.words[t];for(t=0;t=0),n=t?(t-t%26)/26:0;var s=e%26,o=Math.min((e-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,c=0;c=0&&(0!==f||c>=n);c--){var u=0|this.words[c];this.words[c]=f<<26-s|u>>>s,f=u&a}return h&&0!==f&&(h.words[h.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(e,t,r){return i(0===this.negative),this.iushrn(e,t,r)},s.prototype.shln=function(e){return this.clone().ishln(e)},s.prototype.ushln=function(e){return this.clone().iushln(e)},s.prototype.shrn=function(e){return this.clone().ishrn(e)},s.prototype.ushrn=function(e){return this.clone().iushrn(e)},s.prototype.testn=function(e){i("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,n=1<=0);var t=e%26,r=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var n=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},s.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(e,t){var r=(this.length,e.length),i=this.clone(),n=e,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if("mod"!==t){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var c=0;c=0;u--){var l=67108864*(0|i.words[n.length+u])+(0|i.words[n.length+u-1]);for(l=Math.min(l/o|0,67108863),i._ishlnsubmul(n,l,u);0!==i.negative;)l--,i.negative=0,i._ishlnsubmul(n,1,u),i.isZero()||(i.negative^=1);a&&(a.words[u]=l)}return a&&a.strip(),i.strip(),"div"!==t&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(e,t,r){return i(!e.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(n=a.div.neg()),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(e)),{div:n,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new s(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new s(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new s(this.modn(e.words[0]))}:this._wordDiv(e,t);var n,o,a},s.prototype.div=function(e){return this.divmod(e,"div",!1).div},s.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},s.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},s.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),n=e.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},s.prototype.modn=function(e){i(e<=67108863);for(var t=(1<<26)%e,r=0,n=this.length-1;n>=0;n--)r=(t*r+(0|this.words[n]))%e;return r},s.prototype.idivn=function(e){i(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*t;this.words[r]=n/e|0,t=n%e}return this.strip()},s.prototype.divn=function(e){return this.clone().idivn(e)},s.prototype.egcd=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),u=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(f),o.isub(u)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(f),h.isub(u)),a.iushrn(1),h.iushrn(1);t.cmp(r)>=0?(t.isub(r),n.isub(a),o.isub(h)):(r.isub(t),a.isub(n),h.isub(o))}return{a:a,b:h,gcd:r.iushln(c)}},s.prototype._invmp=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var u=0,l=1;0==(r.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(r.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(a)):(r.isub(t),a.isub(o))}return(n=0===t.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(e),n},s.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var i=0;t.isEven()&&r.isEven();i++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=t.cmp(r);if(n<0){var s=t;t=r,r=s}else if(0===n||0===r.cmpn(1))break;t.isub(r)}return r.iushln(i)},s.prototype.invm=function(e){return this.egcd(e).a.umod(e)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(e){return this.words[0]&e},s.prototype.bincn=function(e){i("number"==typeof e);var t=e%26,r=(e-t)/26,n=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),i(e<=67108863,"Number is too big");var n=0|this.words[0];t=n===e?0:ne.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|e.words[r];if(i!==n){in&&(t=1);break}}return t},s.prototype.gtn=function(e){return 1===this.cmpn(e)},s.prototype.gt=function(e){return 1===this.cmp(e)},s.prototype.gten=function(e){return this.cmpn(e)>=0},s.prototype.gte=function(e){return this.cmp(e)>=0},s.prototype.ltn=function(e){return-1===this.cmpn(e)},s.prototype.lt=function(e){return-1===this.cmp(e)},s.prototype.lten=function(e){return this.cmpn(e)<=0},s.prototype.lte=function(e){return this.cmp(e)<=0},s.prototype.eqn=function(e){return 0===this.cmpn(e)},s.prototype.eq=function(e){return 0===this.cmp(e)},s.red=function(e){return new E(e)},s.prototype.toRed=function(e){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(e){return this.red=e,this},s.prototype.forceRed=function(e){return i(!this.red,"Already a number in reduction context"),this._forceRed(e)},s.prototype.redAdd=function(e){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},s.prototype.redIAdd=function(e){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},s.prototype.redSub=function(e){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},s.prototype.redISub=function(e){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},s.prototype.redShl=function(e){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},s.prototype.redMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},s.prototype.redIMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(e){return i(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new s(t,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function S(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function v(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=s._prime(e);this.m=t.p,this.prime=t}else i(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function M(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new s(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var i=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},n(S,y),S.prototype.split=function(e,t){for(var r=Math.min(e.length,9),i=0;i>>22,n=s}n>>>=22,e.words[i-10]=n,0===n&&e.length>10?e.length-=10:e.length-=9},S.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=n,t=i}return 0!==t&&(e.words[e.length++]=t),e},s._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new S;else if("p224"===e)t=new _;else if("p192"===e)t=new v;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new w}return g[e]=t,t},E.prototype._verify1=function(e){i(0===e.negative,"red works only with positives"),i(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){i(0==(e.negative|t.negative),"red works only with positives"),i(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(i(t%2==1),3===t){var r=this.m.add(new s(1)).iushrn(2);return this.pow(e,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,c).cmp(h);)f.redIAdd(h);for(var u=this.pow(f,n),l=this.pow(e,n.addn(1).iushrn(1)),d=this.pow(e,n),p=o;0!==d.cmp(a);){for(var m=d,b=0;0!==m.cmp(a);b++)m=m.redSqr();i(b=0;i--){for(var c=t.words[i],f=h-1;f>=0;f--){var u=c>>f&1;n!==r[0]&&(n=this.sqr(n)),0!==u||0!==o?(o<<=1,o|=u,(4===++a||0===i&&0===f)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},s.mont=function(e){return new M(e)},n(M,E),M.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},M.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},M.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},M.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new s(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},M.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:25}],16:[function(e,t,r){t.exports={newInvalidAsn1Error:function(e){var t=new Error;return t.name="InvalidAsn1Error",t.message=e||"",t}}},{}],17:[function(e,t,r){var i=e("./errors"),n=e("./types"),s=e("./reader"),o=e("./writer");for(var a in t.exports={Reader:s,Writer:o},n)n.hasOwnProperty(a)&&(t.exports[a]=n[a]);for(var h in i)i.hasOwnProperty(h)&&(t.exports[h]=i[h])},{"./errors":16,"./reader":18,"./types":19,"./writer":20}],18:[function(e,t,r){var i=e("assert"),n=e("safer-buffer").Buffer,s=e("./types"),o=e("./errors").newInvalidAsn1Error;function a(e){if(!e||!n.isBuffer(e))throw new TypeError("data must be a node Buffer");this._buf=e,this._size=e.length,this._len=0,this._offset=0}Object.defineProperty(a.prototype,"length",{enumerable:!0,get:function(){return this._len}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){return this._offset}}),Object.defineProperty(a.prototype,"remain",{get:function(){return this._size-this._offset}}),Object.defineProperty(a.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}}),a.prototype.readByte=function(e){if(this._size-this._offset<1)return null;var t=255&this._buf[this._offset];return e||(this._offset+=1),t},a.prototype.peek=function(){return this.readByte(!0)},a.prototype.readLength=function(e){if(void 0===e&&(e=this._offset),e>=this._size)return null;var t=255&this._buf[e++];if(null===t)return null;if(128==(128&t)){if(0===(t&=127))throw o("Indefinite length not supported");if(t>4)throw o("encoding too long");if(this._size-ethis._size-i)return null;if(this._offset=i,0===this.length)return t?n.alloc(0):"";var a=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?a:a.toString("utf8")},a.prototype.readOID=function(e){e||(e=s.OID);var t=this.readString(e,!0);if(null===t)return null;for(var r=[],i=0,n=0;n>0),r.join(".")},a.prototype._readTag=function(e){i.ok(void 0!==e);var t=this.peek();if(null===t)return null;if(t!==e)throw o("Expected 0x"+e.toString(16)+": got 0x"+t.toString(16));var r=this.readLength(this._offset+1);if(null===r)return null;if(this.length>4)throw o("Integer too long: "+this.length);if(this.length>this._size-r)return null;this._offset=r;for(var n=this._buf[this._offset],s=0,a=0;a>0},t.exports=a},{"./errors":16,"./types":19,assert:68,"safer-buffer":190}],19:[function(e,t,r){t.exports={EOC:0,Boolean:1,Integer:2,BitString:3,OctetString:4,Null:5,OID:6,ObjectDescriptor:7,External:8,Real:9,Enumeration:10,PDV:11,Utf8String:12,RelativeOID:13,Sequence:16,Set:17,NumericString:18,PrintableString:19,T61String:20,VideotexString:21,IA5String:22,UTCTime:23,GeneralizedTime:24,GraphicString:25,VisibleString:26,GeneralString:28,UniversalString:29,CharacterString:30,BMPString:31,Constructor:32,Context:128}},{}],20:[function(e,t,r){var i=e("assert"),n=e("safer-buffer").Buffer,s=e("./types"),o=e("./errors").newInvalidAsn1Error,a={size:1024,growthFactor:8};function h(e){var t,r;t=a,r=e||{},i.ok(t),i.equal(typeof t,"object"),i.ok(r),i.equal(typeof r,"object"),Object.getOwnPropertyNames(t).forEach(function(e){if(!r[e]){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,i)}}),e=r,this._buf=n.alloc(e.size||1024),this._size=this._buf.length,this._offset=0,this._options=e,this._seq=[]}Object.defineProperty(h.prototype,"buffer",{get:function(){if(this._seq.length)throw o(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)}}),h.prototype.writeByte=function(e){if("number"!=typeof e)throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=e},h.prototype.writeInt=function(e,t){if("number"!=typeof e)throw new TypeError("argument must be a Number");"number"!=typeof t&&(t=s.Integer);for(var r=4;(0==(4286578688&e)||-8388608==(4286578688&e))&&r>1;)r--,e<<=8;if(r>4)throw o("BER ints cannot be > 0xffffffff");for(this._ensure(2+r),this._buf[this._offset++]=t,this._buf[this._offset++]=r;r-- >0;)this._buf[this._offset++]=(4278190080&e)>>>24,e<<=8},h.prototype.writeNull=function(){this.writeByte(s.Null),this.writeByte(0)},h.prototype.writeEnumeration=function(e,t){if("number"!=typeof e)throw new TypeError("argument must be a Number");return"number"!=typeof t&&(t=s.Enumeration),this.writeInt(e,t)},h.prototype.writeBoolean=function(e,t){if("boolean"!=typeof e)throw new TypeError("argument must be a Boolean");"number"!=typeof t&&(t=s.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=e?255:0},h.prototype.writeString=function(e,t){if("string"!=typeof e)throw new TypeError("argument must be a string (was: "+typeof e+")");"number"!=typeof t&&(t=s.OctetString);var r=n.byteLength(e);this.writeByte(t),this.writeLength(r),r&&(this._ensure(r),this._buf.write(e,this._offset),this._offset+=r)},h.prototype.writeBuffer=function(e,t){if("number"!=typeof t)throw new TypeError("tag must be a number");if(!n.isBuffer(e))throw new TypeError("argument must be a buffer");this.writeByte(t),this.writeLength(e.length),this._ensure(e.length),e.copy(this._buf,this._offset,0,e.length),this._offset+=e.length},h.prototype.writeStringArray=function(e){if(!e instanceof Array)throw new TypeError("argument must be an Array[String]");var t=this;e.forEach(function(e){t.writeString(e)})},h.prototype.writeOID=function(e,t){if("string"!=typeof e)throw new TypeError("argument must be a string");if("number"!=typeof t&&(t=s.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(e))throw new Error("argument is not a valid OID string");var r=e.split("."),i=[];i.push(40*parseInt(r[0],10)+parseInt(r[1],10)),r.slice(2).forEach(function(e){!function(e,t){t<128?e.push(t):t<16384?(e.push(t>>>7|128),e.push(127&t)):t<2097152?(e.push(t>>>14|128),e.push(255&(t>>>7|128)),e.push(127&t)):t<268435456?(e.push(t>>>21|128),e.push(255&(t>>>14|128)),e.push(255&(t>>>7|128)),e.push(127&t)):(e.push(255&(t>>>28|128)),e.push(255&(t>>>21|128)),e.push(255&(t>>>14|128)),e.push(255&(t>>>7|128)),e.push(127&t))}(i,parseInt(e,10))});var n=this;this._ensure(2+i.length),this.writeByte(t),this.writeLength(i.length),i.forEach(function(e){n.writeByte(e)})},h.prototype.writeLength=function(e){if("number"!=typeof e)throw new TypeError("argument must be a Number");if(this._ensure(4),e<=127)this._buf[this._offset++]=e;else if(e<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=e;else if(e<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=e>>8,this._buf[this._offset++]=e;else{if(!(e<=16777215))throw o("Length too long (> 4 bytes)");this._buf[this._offset++]=131,this._buf[this._offset++]=e>>16,this._buf[this._offset++]=e>>8,this._buf[this._offset++]=e}},h.prototype.startSequence=function(e){"number"!=typeof e&&(e=s.Sequence|s.Constructor),this.writeByte(e),this._seq.push(this._offset),this._ensure(3),this._offset+=3},h.prototype.endSequence=function(){var e=this._seq.pop(),t=e+3,r=this._offset-t;if(r<=127)this._shift(t,r,-2),this._buf[e]=r;else if(r<=255)this._shift(t,r,-1),this._buf[e]=129,this._buf[e+1]=r;else if(r<=65535)this._buf[e]=130,this._buf[e+1]=r>>8,this._buf[e+2]=r;else{if(!(r<=16777215))throw o("Sequence too long");this._shift(t,r,1),this._buf[e]=131,this._buf[e+1]=r>>16,this._buf[e+2]=r>>8,this._buf[e+3]=r}},h.prototype._shift=function(e,t,r){i.ok(void 0!==e),i.ok(void 0!==t),i.ok(r),this._buf.copy(this._buf,e+r,e,e+t),this._offset+=r},h.prototype._ensure=function(e){if(i.ok(e),this._size-this._offset0?o-4:o;for(r=0;r>16&255,h[f++]=t>>8&255,h[f++]=255&t;2===a&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,h[f++]=255&t);1===a&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,h[f++]=t>>8&255,h[f++]=255&t);return h},r.fromByteArray=function(e){for(var t,r=e.length,n=r%3,s=[],o=0,a=r-n;oa?a:o+16383));1===n?(t=e[r-1],s.push(i[t>>2]+i[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return s.join("")};for(var i=[],n=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var n,s,o=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},{}],23:[function(e,t,r){!function(t,r){"use strict";function i(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function s(e,t,r){if(s.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof t?t.exports=s:r.BN=s,s.BN=s,s.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:e("buffer").Buffer}catch(e){}function a(e,t){var r=e.charCodeAt(t);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void i(!1,"Invalid character in "+e)}function h(e,t,r){var i=a(e,r);return r-1>=t&&(i|=a(e,r-1)<<4),i}function c(e,t,r,n){for(var s=0,o=0,a=Math.min(e.length,r),h=t;h=49?c-49+10:c>=17?c-17+10:c,i(c>=0&&o0?e:t},s.min=function(e,t){return e.cmp(t)<0?e:t},s.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n=0;n-=3)o=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},s.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var i=0;i=t;i-=2)n=h(e,t,i)<=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(e.length-t)%2==0?t+1:t;i=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this._strip()},s.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var s=e.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=u}catch(e){s.prototype.inspect=u}else s.prototype.inspect=u;function u(){return(this.red?""}var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var n=0,s=0,o=0;o>>24-n&16777215)||o!==this.length-1?l[6-h.length]+h+r:h+r,(n+=2)>=26&&(n-=26,o--)}for(0!==s&&(r=s.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=d[e],f=p[e];r="";var u=this.clone();for(u.negative=0;!u.isZero();){var m=u.modrn(f).toString(e);r=(u=u.idivn(f)).isZero()?m+r:l[c-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(e,t){return this.toArrayLike(o,e,t)}),s.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function m(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;r.length=i,i=i-1|0;var n=0|e.words[0],s=0|t.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var c=1;c>>26,u=67108863&h,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(o=(n=0|e.words[p])*(s=0|t.words[d])+u)/67108864|0,u=67108863&o}r.words[c]=0|u,h=0|f}return 0!==h?r.words[c]=0|h:r.length--,r._strip()}s.prototype.toArrayLike=function(e,t,r){this._strip();var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0");var o=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,s);return this["_toArrayLike"+("le"===t?"LE":"BE")](o,n),o},s.prototype._toArrayLikeLE=function(e,t){for(var r=0,i=0,n=0,s=0;n>8&255),r>16&255),6===s?(r>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r=0&&(e[r--]=o>>8&255),r>=0&&(e[r--]=o>>16&255),6===s?(r>=0&&(e[r--]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r>=0)for(e[r--]=i;r>=0;)e[r--]=0},Math.clz32?s.prototype._countBits=function(e){return 32-Math.clz32(e)}:s.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},s.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},s.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},s.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},s.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},s.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},s.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},s.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},s.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},s.prototype.notn=function(e){return this.clone().inotn(e)},s.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var r=e/26|0,n=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,i=e):(r=e,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;se.length?this.clone().iadd(e):e.clone().iadd(this)},s.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=e):(r=e,i=this);for(var s=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==s&&o>26,this.words[o]=67108863&t;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,b=0|o[2],g=8191&b,y=b>>>13,S=0|o[3],_=8191&S,v=S>>>13,w=0|o[4],E=8191&w,M=w>>>13,O=0|o[5],k=8191&O,N=O>>>13,T=0|o[6],C=8191&T,x=T>>>13,A=0|o[7],D=8191&A,I=A>>>13,R=0|o[8],B=8191&R,P=R>>>13,F=0|o[9],L=8191&F,Y=F>>>13,U=0|a[0],j=8191&U,W=U>>>13,z=0|a[1],q=8191&z,H=z>>>13,V=0|a[2],G=8191&V,K=V>>>13,$=0|a[3],X=8191&$,Z=$>>>13,J=0|a[4],Q=8191&J,ee=J>>>13,te=0|a[5],re=8191&te,ie=te>>>13,ne=0|a[6],se=8191&ne,oe=ne>>>13,ae=0|a[7],he=8191&ae,ce=ae>>>13,fe=0|a[8],ue=8191&fe,le=fe>>>13,de=0|a[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(c+(i=Math.imul(u,j))|0)+((8191&(n=(n=Math.imul(u,W))+Math.imul(l,j)|0))<<13)|0;c=((s=Math.imul(l,W))+(n>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(p,j),n=(n=Math.imul(p,W))+Math.imul(m,j)|0,s=Math.imul(m,W);var ge=(c+(i=i+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,H)|0)+Math.imul(l,q)|0))<<13)|0;c=((s=s+Math.imul(l,H)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(g,j),n=(n=Math.imul(g,W))+Math.imul(y,j)|0,s=Math.imul(y,W),i=i+Math.imul(p,q)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,q)|0,s=s+Math.imul(m,H)|0;var ye=(c+(i=i+Math.imul(u,G)|0)|0)+((8191&(n=(n=n+Math.imul(u,K)|0)+Math.imul(l,G)|0))<<13)|0;c=((s=s+Math.imul(l,K)|0)+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(_,j),n=(n=Math.imul(_,W))+Math.imul(v,j)|0,s=Math.imul(v,W),i=i+Math.imul(g,q)|0,n=(n=n+Math.imul(g,H)|0)+Math.imul(y,q)|0,s=s+Math.imul(y,H)|0,i=i+Math.imul(p,G)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,G)|0,s=s+Math.imul(m,K)|0;var Se=(c+(i=i+Math.imul(u,X)|0)|0)+((8191&(n=(n=n+Math.imul(u,Z)|0)+Math.imul(l,X)|0))<<13)|0;c=((s=s+Math.imul(l,Z)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(E,j),n=(n=Math.imul(E,W))+Math.imul(M,j)|0,s=Math.imul(M,W),i=i+Math.imul(_,q)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(v,q)|0,s=s+Math.imul(v,H)|0,i=i+Math.imul(g,G)|0,n=(n=n+Math.imul(g,K)|0)+Math.imul(y,G)|0,s=s+Math.imul(y,K)|0,i=i+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,Z)|0;var _e=(c+(i=i+Math.imul(u,Q)|0)|0)+((8191&(n=(n=n+Math.imul(u,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((s=s+Math.imul(l,ee)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(k,j),n=(n=Math.imul(k,W))+Math.imul(N,j)|0,s=Math.imul(N,W),i=i+Math.imul(E,q)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(M,q)|0,s=s+Math.imul(M,H)|0,i=i+Math.imul(_,G)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(v,G)|0,s=s+Math.imul(v,K)|0,i=i+Math.imul(g,X)|0,n=(n=n+Math.imul(g,Z)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,Z)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,ee)|0;var ve=(c+(i=i+Math.imul(u,re)|0)|0)+((8191&(n=(n=n+Math.imul(u,ie)|0)+Math.imul(l,re)|0))<<13)|0;c=((s=s+Math.imul(l,ie)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(C,j),n=(n=Math.imul(C,W))+Math.imul(x,j)|0,s=Math.imul(x,W),i=i+Math.imul(k,q)|0,n=(n=n+Math.imul(k,H)|0)+Math.imul(N,q)|0,s=s+Math.imul(N,H)|0,i=i+Math.imul(E,G)|0,n=(n=n+Math.imul(E,K)|0)+Math.imul(M,G)|0,s=s+Math.imul(M,K)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,Z)|0)+Math.imul(v,X)|0,s=s+Math.imul(v,Z)|0,i=i+Math.imul(g,Q)|0,n=(n=n+Math.imul(g,ee)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(m,re)|0,s=s+Math.imul(m,ie)|0;var we=(c+(i=i+Math.imul(u,se)|0)|0)+((8191&(n=(n=n+Math.imul(u,oe)|0)+Math.imul(l,se)|0))<<13)|0;c=((s=s+Math.imul(l,oe)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(D,j),n=(n=Math.imul(D,W))+Math.imul(I,j)|0,s=Math.imul(I,W),i=i+Math.imul(C,q)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(x,q)|0,s=s+Math.imul(x,H)|0,i=i+Math.imul(k,G)|0,n=(n=n+Math.imul(k,K)|0)+Math.imul(N,G)|0,s=s+Math.imul(N,K)|0,i=i+Math.imul(E,X)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(M,X)|0,s=s+Math.imul(M,Z)|0,i=i+Math.imul(_,Q)|0,n=(n=n+Math.imul(_,ee)|0)+Math.imul(v,Q)|0,s=s+Math.imul(v,ee)|0,i=i+Math.imul(g,re)|0,n=(n=n+Math.imul(g,ie)|0)+Math.imul(y,re)|0,s=s+Math.imul(y,ie)|0,i=i+Math.imul(p,se)|0,n=(n=n+Math.imul(p,oe)|0)+Math.imul(m,se)|0,s=s+Math.imul(m,oe)|0;var Ee=(c+(i=i+Math.imul(u,he)|0)|0)+((8191&(n=(n=n+Math.imul(u,ce)|0)+Math.imul(l,he)|0))<<13)|0;c=((s=s+Math.imul(l,ce)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(B,j),n=(n=Math.imul(B,W))+Math.imul(P,j)|0,s=Math.imul(P,W),i=i+Math.imul(D,q)|0,n=(n=n+Math.imul(D,H)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,H)|0,i=i+Math.imul(C,G)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(x,G)|0,s=s+Math.imul(x,K)|0,i=i+Math.imul(k,X)|0,n=(n=n+Math.imul(k,Z)|0)+Math.imul(N,X)|0,s=s+Math.imul(N,Z)|0,i=i+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,ee)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,ee)|0,i=i+Math.imul(_,re)|0,n=(n=n+Math.imul(_,ie)|0)+Math.imul(v,re)|0,s=s+Math.imul(v,ie)|0,i=i+Math.imul(g,se)|0,n=(n=n+Math.imul(g,oe)|0)+Math.imul(y,se)|0,s=s+Math.imul(y,oe)|0,i=i+Math.imul(p,he)|0,n=(n=n+Math.imul(p,ce)|0)+Math.imul(m,he)|0,s=s+Math.imul(m,ce)|0;var Me=(c+(i=i+Math.imul(u,ue)|0)|0)+((8191&(n=(n=n+Math.imul(u,le)|0)+Math.imul(l,ue)|0))<<13)|0;c=((s=s+Math.imul(l,le)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(L,j),n=(n=Math.imul(L,W))+Math.imul(Y,j)|0,s=Math.imul(Y,W),i=i+Math.imul(B,q)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,H)|0,i=i+Math.imul(D,G)|0,n=(n=n+Math.imul(D,K)|0)+Math.imul(I,G)|0,s=s+Math.imul(I,K)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,Z)|0)+Math.imul(x,X)|0,s=s+Math.imul(x,Z)|0,i=i+Math.imul(k,Q)|0,n=(n=n+Math.imul(k,ee)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,ee)|0,i=i+Math.imul(E,re)|0,n=(n=n+Math.imul(E,ie)|0)+Math.imul(M,re)|0,s=s+Math.imul(M,ie)|0,i=i+Math.imul(_,se)|0,n=(n=n+Math.imul(_,oe)|0)+Math.imul(v,se)|0,s=s+Math.imul(v,oe)|0,i=i+Math.imul(g,he)|0,n=(n=n+Math.imul(g,ce)|0)+Math.imul(y,he)|0,s=s+Math.imul(y,ce)|0,i=i+Math.imul(p,ue)|0,n=(n=n+Math.imul(p,le)|0)+Math.imul(m,ue)|0,s=s+Math.imul(m,le)|0;var Oe=(c+(i=i+Math.imul(u,pe)|0)|0)+((8191&(n=(n=n+Math.imul(u,me)|0)+Math.imul(l,pe)|0))<<13)|0;c=((s=s+Math.imul(l,me)|0)+(n>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,i=Math.imul(L,q),n=(n=Math.imul(L,H))+Math.imul(Y,q)|0,s=Math.imul(Y,H),i=i+Math.imul(B,G)|0,n=(n=n+Math.imul(B,K)|0)+Math.imul(P,G)|0,s=s+Math.imul(P,K)|0,i=i+Math.imul(D,X)|0,n=(n=n+Math.imul(D,Z)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,Z)|0,i=i+Math.imul(C,Q)|0,n=(n=n+Math.imul(C,ee)|0)+Math.imul(x,Q)|0,s=s+Math.imul(x,ee)|0,i=i+Math.imul(k,re)|0,n=(n=n+Math.imul(k,ie)|0)+Math.imul(N,re)|0,s=s+Math.imul(N,ie)|0,i=i+Math.imul(E,se)|0,n=(n=n+Math.imul(E,oe)|0)+Math.imul(M,se)|0,s=s+Math.imul(M,oe)|0,i=i+Math.imul(_,he)|0,n=(n=n+Math.imul(_,ce)|0)+Math.imul(v,he)|0,s=s+Math.imul(v,ce)|0,i=i+Math.imul(g,ue)|0,n=(n=n+Math.imul(g,le)|0)+Math.imul(y,ue)|0,s=s+Math.imul(y,le)|0;var ke=(c+(i=i+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;c=((s=s+Math.imul(m,me)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(L,G),n=(n=Math.imul(L,K))+Math.imul(Y,G)|0,s=Math.imul(Y,K),i=i+Math.imul(B,X)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(P,X)|0,s=s+Math.imul(P,Z)|0,i=i+Math.imul(D,Q)|0,n=(n=n+Math.imul(D,ee)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,ee)|0,i=i+Math.imul(C,re)|0,n=(n=n+Math.imul(C,ie)|0)+Math.imul(x,re)|0,s=s+Math.imul(x,ie)|0,i=i+Math.imul(k,se)|0,n=(n=n+Math.imul(k,oe)|0)+Math.imul(N,se)|0,s=s+Math.imul(N,oe)|0,i=i+Math.imul(E,he)|0,n=(n=n+Math.imul(E,ce)|0)+Math.imul(M,he)|0,s=s+Math.imul(M,ce)|0,i=i+Math.imul(_,ue)|0,n=(n=n+Math.imul(_,le)|0)+Math.imul(v,ue)|0,s=s+Math.imul(v,le)|0;var Ne=(c+(i=i+Math.imul(g,pe)|0)|0)+((8191&(n=(n=n+Math.imul(g,me)|0)+Math.imul(y,pe)|0))<<13)|0;c=((s=s+Math.imul(y,me)|0)+(n>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,i=Math.imul(L,X),n=(n=Math.imul(L,Z))+Math.imul(Y,X)|0,s=Math.imul(Y,Z),i=i+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,ee)|0,i=i+Math.imul(D,re)|0,n=(n=n+Math.imul(D,ie)|0)+Math.imul(I,re)|0,s=s+Math.imul(I,ie)|0,i=i+Math.imul(C,se)|0,n=(n=n+Math.imul(C,oe)|0)+Math.imul(x,se)|0,s=s+Math.imul(x,oe)|0,i=i+Math.imul(k,he)|0,n=(n=n+Math.imul(k,ce)|0)+Math.imul(N,he)|0,s=s+Math.imul(N,ce)|0,i=i+Math.imul(E,ue)|0,n=(n=n+Math.imul(E,le)|0)+Math.imul(M,ue)|0,s=s+Math.imul(M,le)|0;var Te=(c+(i=i+Math.imul(_,pe)|0)|0)+((8191&(n=(n=n+Math.imul(_,me)|0)+Math.imul(v,pe)|0))<<13)|0;c=((s=s+Math.imul(v,me)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(L,Q),n=(n=Math.imul(L,ee))+Math.imul(Y,Q)|0,s=Math.imul(Y,ee),i=i+Math.imul(B,re)|0,n=(n=n+Math.imul(B,ie)|0)+Math.imul(P,re)|0,s=s+Math.imul(P,ie)|0,i=i+Math.imul(D,se)|0,n=(n=n+Math.imul(D,oe)|0)+Math.imul(I,se)|0,s=s+Math.imul(I,oe)|0,i=i+Math.imul(C,he)|0,n=(n=n+Math.imul(C,ce)|0)+Math.imul(x,he)|0,s=s+Math.imul(x,ce)|0,i=i+Math.imul(k,ue)|0,n=(n=n+Math.imul(k,le)|0)+Math.imul(N,ue)|0,s=s+Math.imul(N,le)|0;var Ce=(c+(i=i+Math.imul(E,pe)|0)|0)+((8191&(n=(n=n+Math.imul(E,me)|0)+Math.imul(M,pe)|0))<<13)|0;c=((s=s+Math.imul(M,me)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(L,re),n=(n=Math.imul(L,ie))+Math.imul(Y,re)|0,s=Math.imul(Y,ie),i=i+Math.imul(B,se)|0,n=(n=n+Math.imul(B,oe)|0)+Math.imul(P,se)|0,s=s+Math.imul(P,oe)|0,i=i+Math.imul(D,he)|0,n=(n=n+Math.imul(D,ce)|0)+Math.imul(I,he)|0,s=s+Math.imul(I,ce)|0,i=i+Math.imul(C,ue)|0,n=(n=n+Math.imul(C,le)|0)+Math.imul(x,ue)|0,s=s+Math.imul(x,le)|0;var xe=(c+(i=i+Math.imul(k,pe)|0)|0)+((8191&(n=(n=n+Math.imul(k,me)|0)+Math.imul(N,pe)|0))<<13)|0;c=((s=s+Math.imul(N,me)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(L,se),n=(n=Math.imul(L,oe))+Math.imul(Y,se)|0,s=Math.imul(Y,oe),i=i+Math.imul(B,he)|0,n=(n=n+Math.imul(B,ce)|0)+Math.imul(P,he)|0,s=s+Math.imul(P,ce)|0,i=i+Math.imul(D,ue)|0,n=(n=n+Math.imul(D,le)|0)+Math.imul(I,ue)|0,s=s+Math.imul(I,le)|0;var Ae=(c+(i=i+Math.imul(C,pe)|0)|0)+((8191&(n=(n=n+Math.imul(C,me)|0)+Math.imul(x,pe)|0))<<13)|0;c=((s=s+Math.imul(x,me)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(L,he),n=(n=Math.imul(L,ce))+Math.imul(Y,he)|0,s=Math.imul(Y,ce),i=i+Math.imul(B,ue)|0,n=(n=n+Math.imul(B,le)|0)+Math.imul(P,ue)|0,s=s+Math.imul(P,le)|0;var De=(c+(i=i+Math.imul(D,pe)|0)|0)+((8191&(n=(n=n+Math.imul(D,me)|0)+Math.imul(I,pe)|0))<<13)|0;c=((s=s+Math.imul(I,me)|0)+(n>>>13)|0)+(De>>>26)|0,De&=67108863,i=Math.imul(L,ue),n=(n=Math.imul(L,le))+Math.imul(Y,ue)|0,s=Math.imul(Y,le);var Ie=(c+(i=i+Math.imul(B,pe)|0)|0)+((8191&(n=(n=n+Math.imul(B,me)|0)+Math.imul(P,pe)|0))<<13)|0;c=((s=s+Math.imul(P,me)|0)+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863;var Re=(c+(i=Math.imul(L,pe))|0)+((8191&(n=(n=Math.imul(L,me))+Math.imul(Y,pe)|0))<<13)|0;return c=((s=Math.imul(Y,me))+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863,h[0]=be,h[1]=ge,h[2]=ye,h[3]=Se,h[4]=_e,h[5]=ve,h[6]=we,h[7]=Ee,h[8]=Me,h[9]=Oe,h[10]=ke,h[11]=Ne,h[12]=Te,h[13]=Ce,h[14]=xe,h[15]=Ae,h[16]=De,h[17]=Ie,h[18]=Re,0!==c&&(h[19]=c,r.length++),r};function g(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r._strip()}function y(e,t,r){return g(e,t,r)}function S(e,t){this.x=e,this.y=t}Math.imul||(b=m),s.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?b(this,e,t):r<63?m(this,e,t):r<1024?g(this,e,t):y(this,e,t)},S.prototype.makeRBT=function(e){for(var t=new Array(e),r=s.prototype._countBits(e)-1,i=0;i>=1;return i},S.prototype.permute=function(e,t,r,i,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*t;o>=26,r+=s/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),t?this.ineg():this},s.prototype.muln=function(e){return this.clone().imuln(e)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>n&1}return t}(e);if(0===t.length)return new s(1);for(var r=this,i=0;i=0);var t,r=e%26,n=(e-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(t=0;t>>26-r}o&&(this.words[t]=o,this.length++)}if(0!==n){for(t=this.length-1;t>=0;t--)this.words[t+n]=this.words[t];for(t=0;t=0),n=t?(t-t%26)/26:0;var s=e%26,o=Math.min((e-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,c=0;c=0&&(0!==f||c>=n);c--){var u=0|this.words[c];this.words[c]=f<<26-s|u>>>s,f=u&a}return h&&0!==f&&(h.words[h.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(e,t,r){return i(0===this.negative),this.iushrn(e,t,r)},s.prototype.shln=function(e){return this.clone().ishln(e)},s.prototype.ushln=function(e){return this.clone().iushln(e)},s.prototype.shrn=function(e){return this.clone().ishrn(e)},s.prototype.ushrn=function(e){return this.clone().iushrn(e)},s.prototype.testn=function(e){i("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,n=1<=0);var t=e%26,r=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var n=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},s.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n>26,this.words[n+r]=67108863&s;if(0===a)return this._strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&s;return this.negative=1,this._strip()},s.prototype._wordDiv=function(e,t){var r=(this.length,e.length),i=this.clone(),n=e,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if("mod"!==t){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var c=0;c=0;u--){var l=67108864*(0|i.words[n.length+u])+(0|i.words[n.length+u-1]);for(l=Math.min(l/o|0,67108863),i._ishlnsubmul(n,l,u);0!==i.negative;)l--,i.negative=0,i._ishlnsubmul(n,1,u),i.isZero()||(i.negative^=1);a&&(a.words[u]=l)}return a&&a._strip(),i._strip(),"div"!==t&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(e,t,r){return i(!e.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(n=a.div.neg()),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(e)),{div:n,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new s(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new s(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new s(this.modrn(e.words[0]))}:this._wordDiv(e,t);var n,o,a},s.prototype.div=function(e){return this.divmod(e,"div",!1).div},s.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},s.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},s.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),n=e.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},s.prototype.modrn=function(e){var t=e<0;t&&(e=-e),i(e<=67108863);for(var r=(1<<26)%e,n=0,s=this.length-1;s>=0;s--)n=(r*n+(0|this.words[s]))%e;return t?-n:n},s.prototype.modn=function(e){return this.modrn(e)},s.prototype.idivn=function(e){var t=e<0;t&&(e=-e),i(e<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var s=(0|this.words[n])+67108864*r;this.words[n]=s/e|0,r=s%e}return this._strip(),t?this.ineg():this},s.prototype.divn=function(e){return this.clone().idivn(e)},s.prototype.egcd=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),u=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(f),o.isub(u)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(f),h.isub(u)),a.iushrn(1),h.iushrn(1);t.cmp(r)>=0?(t.isub(r),n.isub(a),o.isub(h)):(r.isub(t),a.isub(n),h.isub(o))}return{a:a,b:h,gcd:r.iushln(c)}},s.prototype._invmp=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var u=0,l=1;0==(r.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(r.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(a)):(r.isub(t),a.isub(o))}return(n=0===t.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(e),n},s.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var i=0;t.isEven()&&r.isEven();i++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=t.cmp(r);if(n<0){var s=t;t=r,r=s}else if(0===n||0===r.cmpn(1))break;t.isub(r)}return r.iushln(i)},s.prototype.invm=function(e){return this.egcd(e).a.umod(e)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(e){return this.words[0]&e},s.prototype.bincn=function(e){i("number"==typeof e);var t=e%26,r=(e-t)/26,n=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),i(e<=67108863,"Number is too big");var n=0|this.words[0];t=n===e?0:ne.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|e.words[r];if(i!==n){in&&(t=1);break}}return t},s.prototype.gtn=function(e){return 1===this.cmpn(e)},s.prototype.gt=function(e){return 1===this.cmp(e)},s.prototype.gten=function(e){return this.cmpn(e)>=0},s.prototype.gte=function(e){return this.cmp(e)>=0},s.prototype.ltn=function(e){return-1===this.cmpn(e)},s.prototype.lt=function(e){return-1===this.cmp(e)},s.prototype.lten=function(e){return this.cmpn(e)<=0},s.prototype.lte=function(e){return this.cmp(e)<=0},s.prototype.eqn=function(e){return 0===this.cmpn(e)},s.prototype.eq=function(e){return 0===this.cmp(e)},s.red=function(e){return new k(e)},s.prototype.toRed=function(e){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(e){return this.red=e,this},s.prototype.forceRed=function(e){return i(!this.red,"Already a number in reduction context"),this._forceRed(e)},s.prototype.redAdd=function(e){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},s.prototype.redIAdd=function(e){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},s.prototype.redSub=function(e){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},s.prototype.redISub=function(e){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},s.prototype.redShl=function(e){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},s.prototype.redMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},s.prototype.redIMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(e){return i(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var _={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new s(t,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function O(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function k(e){if("string"==typeof e){var t=s._prime(e);this.m=t.p,this.prime=t}else i(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function N(e){k.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var e=new s(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var i=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},n(w,v),w.prototype.split=function(e,t){for(var r=Math.min(e.length,9),i=0;i>>22,n=s}n>>>=22,e.words[i-10]=n,0===n&&e.length>10?e.length-=10:e.length-=9},w.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=n,t=i}return 0!==t&&(e.words[e.length++]=t),e},s._prime=function(e){if(_[e])return _[e];var t;if("k256"===e)t=new w;else if("p224"===e)t=new E;else if("p192"===e)t=new M;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new O}return _[e]=t,t},k.prototype._verify1=function(e){i(0===e.negative,"red works only with positives"),i(e.red,"red works only with red numbers")},k.prototype._verify2=function(e,t){i(0==(e.negative|t.negative),"red works only with positives"),i(e.red&&e.red===t.red,"red works only with red numbers")},k.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(f(e,e.umod(this.m)._forceRed(this)),e)},k.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},k.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},k.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},k.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},k.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},k.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},k.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},k.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},k.prototype.isqr=function(e){return this.imul(e,e.clone())},k.prototype.sqr=function(e){return this.mul(e,e)},k.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(i(t%2==1),3===t){var r=this.m.add(new s(1)).iushrn(2);return this.pow(e,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,c).cmp(h);)f.redIAdd(h);for(var u=this.pow(f,n),l=this.pow(e,n.addn(1).iushrn(1)),d=this.pow(e,n),p=o;0!==d.cmp(a);){for(var m=d,b=0;0!==m.cmp(a);b++)m=m.redSqr();i(b=0;i--){for(var c=t.words[i],f=h-1;f>=0;f--){var u=c>>f&1;n!==r[0]&&(n=this.sqr(n)),0!==u||0!==o?(o<<=1,o|=u,(4===++a||0===i&&0===f)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},k.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},k.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},s.mont=function(e){return new N(e)},n(N,k),N.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},N.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},N.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},N.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new s(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},N.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:25}],24:[function(e,t,r){var i;function n(e){this.rand=e}if(t.exports=function(e){return i||(i=new n(null)),i.generate(e)},t.exports.Rand=n,n.prototype.generate=function(e){return this._rand(e)},n.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^f[p>>>16&255]^u[m>>>8&255]^l[255&b]^t[g++],o=c[p>>>24]^f[m>>>16&255]^u[b>>>8&255]^l[255&d]^t[g++],a=c[m>>>24]^f[b>>>16&255]^u[d>>>8&255]^l[255&p]^t[g++],h=c[b>>>24]^f[d>>>16&255]^u[p>>>8&255]^l[255&m]^t[g++],d=s,p=o,m=a,b=h;return s=(i[d>>>24]<<24|i[p>>>16&255]<<16|i[m>>>8&255]<<8|i[255&b])^t[g++],o=(i[p>>>24]<<24|i[m>>>16&255]<<16|i[b>>>8&255]<<8|i[255&d])^t[g++],a=(i[m>>>24]<<24|i[b>>>16&255]<<16|i[d>>>8&255]<<8|i[255&p])^t[g++],h=(i[b>>>24]<<24|i[d>>>16&255]<<16|i[p>>>8&255]<<8|i[255&m])^t[g++],[s>>>=0,o>>>=0,a>>>=0,h>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],h=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],i=[],n=[[],[],[],[]],s=[[],[],[],[]],o=0,a=0,h=0;h<256;++h){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[o]=c,i[c]=o;var f=e[o],u=e[f],l=e[u],d=257*e[c]^16843008*c;n[0][o]=d<<24|d>>>8,n[1][o]=d<<16|d>>>16,n[2][o]=d<<8|d>>>24,n[3][o]=d,d=16843009*l^65537*u^257*f^16843008*o,s[0][c]=d<<24|d>>>8,s[1][c]=d<<16|d>>>16,s[2][c]=d<<8|d>>>24,s[3][c]=d,0===o?o=a=1:(o=f^e[e[e[l^f]]],a^=e[e[a]])}return{SBOX:r,INV_SBOX:i,SUB_MIX:n,INV_SUB_MIX:s}}();function c(e){this._key=n(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,i=4*(r+1),n=[],s=0;s>>24,o=h.SBOX[o>>>24]<<24|h.SBOX[o>>>16&255]<<16|h.SBOX[o>>>8&255]<<8|h.SBOX[255&o],o^=a[s/t|0]<<24):t>6&&s%t==4&&(o=h.SBOX[o>>>24]<<24|h.SBOX[o>>>16&255]<<16|h.SBOX[o>>>8&255]<<8|h.SBOX[255&o]),n[s]=n[s-t]^o}for(var c=[],f=0;f>>24]]^h.INV_SUB_MIX[1][h.SBOX[l>>>16&255]]^h.INV_SUB_MIX[2][h.SBOX[l>>>8&255]]^h.INV_SUB_MIX[3][h.SBOX[255&l]]}this._nRounds=r,this._keySchedule=n,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return o(e=n(e),this._keySchedule,h.SUB_MIX,h.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=i.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=n(e))[1];e[1]=e[3],e[3]=t;var r=o(e,this._invKeySchedule,h.INV_SUB_MIX,h.INV_SBOX,this._nRounds),s=i.allocUnsafe(16);return s.writeUInt32BE(r[0],0),s.writeUInt32BE(r[3],4),s.writeUInt32BE(r[2],8),s.writeUInt32BE(r[1],12),s},c.prototype.scrub=function(){s(this._keySchedule),s(this._invKeySchedule),s(this._key)},t.exports.AES=c},{"safe-buffer":189}],27:[function(e,t,r){var i=e("./aes"),n=e("safe-buffer").Buffer,s=e("cipher-base"),o=e("inherits"),a=e("./ghash"),h=e("buffer-xor"),c=e("./incr32");function f(e,t,r,o){s.call(this);var h=n.alloc(4,0);this._cipher=new i.AES(t);var f=this._cipher.encryptBlock(h);this._ghash=new a(f),r=function(e,t,r){if(12===t.length)return e._finID=n.concat([t,n.from([0,0,0,1])]),n.concat([t,n.from([0,0,0,2])]);var i=new a(r),s=t.length,o=s%16;i.update(t),o&&(o=16-o,i.update(n.alloc(o,0))),i.update(n.alloc(8,0));var h=8*s,f=n.alloc(8);f.writeUIntBE(h,0,8),i.update(f),e._finID=i.state;var u=n.from(e._finID);return c(u),u}(this,r,f),this._prev=n.from(r),this._cache=n.allocUnsafe(0),this._secCache=n.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}o(f,s),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=n.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=h(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var i=Math.min(e.length,t.length),n=0;n16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},u.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=s[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var i=c(t,!1,r.key,r.iv);return l(e,i.key,i.iv)},r.createDecipheriv=l},{"./aes":26,"./authCipher":27,"./modes":39,"./streamCipher":42,"cipher-base":74,evp_bytestokey:112,inherits:143,"safe-buffer":189}],30:[function(e,t,r){var i=e("./modes"),n=e("./authCipher"),s=e("safe-buffer").Buffer,o=e("./streamCipher"),a=e("cipher-base"),h=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){a.call(this),this._cache=new l,this._cipher=new h.AES(t),this._prev=s.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,a),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var i=[];t=this._cache.get();)r=this._mode.encrypt(this,t),i.push(r);return s.concat(i)};var u=s.alloc(16,16);function l(){this.cache=s.allocUnsafe(0)}function d(e,t,r){var a=i[e.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=s.from(t)),t.length!==a.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=s.from(r)),"GCM"!==a.mode&&r.length!==a.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===a.type?new o(a.module,t,r):"auth"===a.type?new n(a.module,t,r):new f(a.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(u))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=s.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=s.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function o(e){this.h=e,this.state=i.alloc(16,0),this.cache=i.allocUnsafe(0)}o.prototype.ghash=function(e){for(var t=-1;++t0;t--)i[t]=i[t]>>>1|(1&i[t-1])<<31;i[0]=i[0]>>>1,r&&(i[0]=i[0]^225<<24)}this.state=s(n)},o.prototype.update=function(e){var t;for(this.cache=i.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},o.prototype.final=function(e,t){return this.cache.length&&this.ghash(i.concat([this.cache,n],16)),this.ghash(s([0,e,0,t])),this.state},t.exports=o},{"safe-buffer":189}],32:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],33:[function(e,t,r){var i=e("buffer-xor");r.encrypt=function(e,t){var r=i(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var n=e._cipher.decryptBlock(t);return i(n,r)}},{"buffer-xor":73}],34:[function(e,t,r){var i=e("safe-buffer").Buffer,n=e("buffer-xor");function s(e,t,r){var s=t.length,o=n(t,e._cache);return e._cache=e._cache.slice(s),e._prev=i.concat([e._prev,r?t:o]),o}r.encrypt=function(e,t,r){for(var n,o=i.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=i.allocUnsafe(0)),!(e._cache.length<=t.length)){o=i.concat([o,s(e,t,r)]);break}n=e._cache.length,o=i.concat([o,s(e,t.slice(0,n),r)]),t=t.slice(n)}return o}},{"buffer-xor":73,"safe-buffer":189}],35:[function(e,t,r){var i=e("safe-buffer").Buffer;function n(e,t,r){for(var i,n,o=-1,a=0;++o<8;)i=t&1<<7-o?128:0,a+=(128&(n=e._cipher.encryptBlock(e._prev)[0]^i))>>o%8,e._prev=s(e._prev,r?i:n);return a}function s(e,t){var r=e.length,n=-1,s=i.allocUnsafe(e.length);for(e=i.concat([e,i.from([t])]);++n>7;return s}r.encrypt=function(e,t,r){for(var s=t.length,o=i.allocUnsafe(s),a=-1;++a=0||!t.umod(e.prime1)||!t.umod(e.prime2));return t}function o(e,t){var n=function(e){var t=s(e);return{blinder:t.toRed(i.mont(e.modulus)).redPow(new i(e.publicExponent)).fromRed(),unblinder:t.invm(e.modulus)}}(t),o=t.modulus.byteLength(),a=new i(e).mul(n.blinder).umod(t.modulus),h=a.toRed(i.mont(t.prime1)),c=a.toRed(i.mont(t.prime2)),f=t.coefficient,u=t.prime1,l=t.prime2,d=h.redPow(t.exponent1).fromRed(),p=c.redPow(t.exponent2).fromRed(),m=d.isub(p).imul(f).umod(u).imul(l);return p.iadd(m).imul(n.unblinder).umod(t.modulus).toArrayLike(r,"be",o)}o.getr=s,t.exports=o}).call(this)}).call(this,e("buffer").Buffer)},{"bn.js":23,buffer:72,randombytes:186}],47:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":48}],48:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],49:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],50:[function(e,t,r){var i=e("safe-buffer").Buffer,n=e("create-hash"),s=e("readable-stream"),o=e("inherits"),a=e("./sign"),h=e("./verify"),c=e("./algorithms.json");function f(e){s.Writable.call(this);var t=c[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function u(e){s.Writable.call(this);var t=c[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function l(e){return new f(e)}function d(e){return new u(e)}Object.keys(c).forEach(function(e){c[e].id=i.from(c[e].id,"hex"),c[e.toLowerCase()]=c[e]}),o(f,s.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=i.from(e,t)),this._hash.update(e),this},f.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),i=a(r,e,this._hashType,this._signType,this._tag);return t?i.toString(t):i},o(u,s.Writable),u.prototype._write=function(e,t,r){this._hash.update(e),r()},u.prototype.update=function(e,t){return"string"==typeof e&&(e=i.from(e,t)),this._hash.update(e),this},u.prototype.verify=function(e,t,r){"string"==typeof t&&(t=i.from(t,r)),this.end();var n=this._hash.digest();return h(t,n,e,this._signType,this._tag)},t.exports={Sign:l,Verify:d,createSign:l,createVerify:d}},{"./algorithms.json":48,"./sign":51,"./verify":52,"create-hash":78,inherits:143,"readable-stream":67,"safe-buffer":189}],51:[function(e,t,r){var i=e("safe-buffer").Buffer,n=e("create-hmac"),s=e("browserify-rsa"),o=e("elliptic").ec,a=e("bn.js"),h=e("parse-asn1"),c=e("./curves.json");function f(e,t,r,s){if((e=i.from(e.toArray())).length0&&r.ishrn(i),r}function l(e,t,r){var s,o;do{for(s=i.alloc(0);8*s.length=t)throw new Error("invalid sig")}t.exports=function(e,t,r,c,f){var u=o(r);if("ec"===u.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=a[r.data.algorithm.curve.join(".")];if(!i)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var n=new s(i),o=r.data.subjectPrivateKey.data;return n.verify(t,e,o)}(e,t,u)}if("dsa"===u.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,s=r.data.q,a=r.data.g,c=r.data.pub_key,f=o.signature.decode(e,"der"),u=f.s,l=f.r;h(u,s),h(l,s);var d=n.mont(i),p=u.invm(s);return 0===a.toRed(d).redPow(new n(t).mul(p).mod(s)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(s)).fromRed()).mod(i).mod(s).cmp(l)}(e,t,u)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=i.concat([f,t]);for(var l=u.modulus.byteLength(),d=[1],p=0;t.length+d.length+22?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}n("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),n("ERR_INVALID_ARG_TYPE",function(e,t,r){var i,n,o,a;if("string"==typeof t&&(n="not ",t.substr(!o||o<0?0:+o,n.length)===n)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))a="The ".concat(e," ").concat(i," ").concat(s(t,"type"));else{var h=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(h," ").concat(i," ").concat(s(t,"type"))}return a+=". Received type ".concat(typeof r)},TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=i},{}],54:[function(e,t,r){(function(r){(function(){ // distribute, sublicense, and/or sell copies of the Software, and to permit "use strict";var i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=c;var n=e("./_stream_readable"),s=e("./_stream_writable");e("inherits")(c,n);for(var o=i(s.prototype),a=0;a0)if("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),i)o.endEmitted?w(e,new v):N(e,o,t,!0);else if(o.ended)w(e,new S);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||0!==t.length?N(e,o,t,!1):D(e,o)):N(e,o,t,!1)}else i||(o.reading=!1,D(e,o));return!o.ended&&(o.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=T?e=T:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;c("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(c("emitReadable",t.flowing),t.emittedReadable=!0,r.nextTick(A,e))}function A(e){var t=e._readableState;c("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,F(e)}function D(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(I,e,t))}function I(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function B(e){c("readable nexttick read 0"),e.read(0)}function P(e,t){c("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),F(e),t.flowing&&!t.reading&&e.read(0)}function F(e){var t=e._readableState;for(c("flow",t.flowing);t.flowing&&null!==e.read(););}function L(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function Y(e){var t=e._readableState;c("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,r.nextTick(U,t,e))}function U(e,t){if(c("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function j(e,t){for(var r=0,i=e.length;r=t.highWaterMark:t.length>0)||t.ended))return c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Y(this):x(this),null;if(0===(e=C(e,t))&&t.ended)return 0===t.length&&Y(this),null;var i,n=t.needReadable;return c("need readable",n),(0===t.length||t.length-e0?L(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Y(this)),null!==i&&this.emit("data",i),i},O.prototype._read=function(e){w(this,new _("_read()"))},O.prototype.pipe=function(e,t){var i=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,c("pipe count=%d opts=%j",n.pipesCount,t);var o=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?h:b;function a(t,r){c("onunpipe"),t===i&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),e.removeListener("close",p),e.removeListener("finish",m),e.removeListener("drain",f),e.removeListener("error",d),e.removeListener("unpipe",a),i.removeListener("end",h),i.removeListener("end",b),i.removeListener("data",l),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||f())}function h(){c("onend"),e.end()}n.endEmitted?r.nextTick(o):i.once("end",o),e.on("unpipe",a);var f=function(e){return function(){var t=e._readableState;c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,F(e))}}(i);e.on("drain",f);var u=!1;function l(t){c("ondata");var r=e.write(t);c("dest.write",r),!1===r&&((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==j(n.pipes,e))&&!u&&(c("false write response, pause",n.awaitDrain),n.awaitDrain++),i.pause())}function d(t){c("onerror",t),b(),e.removeListener("error",d),0===s(e,"error")&&w(e,t)}function p(){e.removeListener("finish",m),b()}function m(){c("onfinish"),e.removeListener("close",p),b()}function b(){c("unpipe"),i.unpipe(e)}return i.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",p),e.once("finish",m),e.emit("pipe",i),n.flowing||(c("pipe resume"),i.resume()),e},O.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s0,!1!==n.flowing&&this.resume()):"readable"===e&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,c("on readable",n.length,n.reading),n.length?x(this):n.reading||r.nextTick(B,this))),i},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(e,t){var i=o.prototype.removeListener.call(this,e,t);return"readable"===e&&r.nextTick(R,this),i},O.prototype.removeAllListeners=function(e){var t=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||r.nextTick(R,this),t},O.prototype.resume=function(){var e=this._readableState;return e.flowing||(c("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,r.nextTick(P,e,t))}(this,e)),e.paused=!1,this},O.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},O.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;for(var n in e.on("end",function(){if(c("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(n){(c("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(t.push(n)||(i=!0,e.pause()))}),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));for(var s=0;s-1))throw new v(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),O.prototype._write=function(e,t,r){r(new m("_write()"))},O.prototype._writev=null,O.prototype.end=function(e,t,i){var n=this._writableState;return"function"==typeof e?(i=e,e=null,t=null):"function"==typeof t&&(i=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||function(e,t,i){t.ending=!0,A(e,t),i&&(t.finished?r.nextTick(i):e.once("finish",i));t.ended=!0,e.writable=!1}(this,n,i),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),O.prototype.destroy=u.destroy,O.prototype._undestroy=u.undestroy,O.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":53,"./_stream_duplex":54,"./internal/streams/destroy":61,"./internal/streams/state":65,"./internal/streams/stream":66,_process:178,buffer:72,inherits:143,"util-deprecate":215}],59:[function(e,t,r){(function(r){(function(){"use strict";var i;function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=e("./end-of-stream"),o=Symbol("lastResolve"),a=Symbol("lastReject"),h=Symbol("error"),c=Symbol("ended"),f=Symbol("lastPromise"),u=Symbol("handlePromise"),l=Symbol("stream");function d(e,t){return{value:e,done:t}}function p(e){var t=e[o];if(null!==t){var r=e[l].read();null!==r&&(e[f]=null,e[o]=null,e[a]=null,t(d(r,!1)))}}var m=Object.getPrototypeOf(function(){}),b=Object.setPrototypeOf((n(i={get stream(){return this[l]},next:function(){var e=this,t=this[h];if(null!==t)return Promise.reject(t);if(this[c])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(t,i){r.nextTick(function(){e[h]?i(e[h]):t(d(void 0,!0))})});var i,n=this[f];if(n)i=new Promise(function(e,t){return function(r,i){e.then(function(){t[c]?r(d(void 0,!0)):t[u](r,i)},i)}}(n,this));else{var s=this[l].read();if(null!==s)return Promise.resolve(d(s,!1));i=new Promise(this[u])}return this[f]=i,i}},Symbol.asyncIterator,function(){return this}),n(i,"return",function(){var e=this;return new Promise(function(t,r){e[l].destroy(null,function(e){e?r(e):t(d(void 0,!0))})})}),i),m);t.exports=function(e){var t,i=Object.create(b,(n(t={},l,{value:e,writable:!0}),n(t,o,{value:null,writable:!0}),n(t,a,{value:null,writable:!0}),n(t,h,{value:null,writable:!0}),n(t,c,{value:e._readableState.endEmitted,writable:!0}),n(t,u,{value:function(e,t){var r=i[l].read();r?(i[f]=null,i[o]=null,i[a]=null,e(d(r,!1))):(i[o]=e,i[a]=t)},writable:!0}),t));return i[f]=null,s(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=i[a];return null!==t&&(i[f]=null,i[o]=null,i[a]=null,t(e)),void(i[h]=e)}var r=i[o];null!==r&&(i[f]=null,i[o]=null,i[a]=null,r(d(void 0,!0))),i[c]=!0}),e.on("readable",function(e){r.nextTick(p,e)}.bind(null,i)),i}}).call(this)}).call(this,e("_process"))},{"./end-of-stream":62,_process:178}],60:[function(e,t,r){"use strict";function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){for(var r=0;r0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return o.alloc(0);for(var t,r,i,n=o.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,r=n,i=a,o.prototype.copy.call(t,r,i),a+=s.data.length,s=s.next;return n}},{key:"consume",value:function(e,t){var r;return en.length?n.length:e;if(s===n.length?i+=n:i+=n.slice(0,e),0===(e-=s)){s===n.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=n.slice(s));break}++r}return this.length-=r,i}},{key:"_getBuffer",value:function(e){var t=o.allocUnsafe(e),r=this.head,i=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var n=r.data,s=e>n.length?n.length:e;if(n.copy(t,t.length-e,0,s),0===(e-=s)){s===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(s));break}++i}return this.length-=i,t}},{key:h,value:function(e,t){return a(this,function(e){for(var t=1;t0,function(e){f||(f=e),e&&l.forEach(h),s||(l.forEach(h),u(f))})});return r.reduce(c)}},{"../../../errors":53,"./end-of-stream":62}],65:[function(e,t,r){"use strict";var i=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(e,t,r,n){var s=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,n,r);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new i(n?r:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}}},{"../../../errors":53}],66:[function(e,t,r){t.exports=e("events").EventEmitter},{events:111}],67:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js"),r.finished=e("./lib/internal/streams/end-of-stream.js"),r.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":54,"./lib/_stream_passthrough.js":55,"./lib/_stream_readable.js":56,"./lib/_stream_transform.js":57,"./lib/_stream_writable.js":58,"./lib/internal/streams/end-of-stream.js":62,"./lib/internal/streams/pipeline.js":64}],68:[function(e,t,r){(function(r){(function(){"use strict";var i=e("object-assign"); /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */function n(e,t){if(e===t)return 0;for(var r=e.length,i=t.length,n=0,s=Math.min(r,i);n=0;c--)if(f[c]!==u[c])return!1;for(c=f.length-1;c>=0;c--)if(a=f[c],!S(e[a],t[a],r,i))return!1;return!0}(e,t,r,i))}return r?e===t:e==t}function _(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function v(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function w(e,t,r,i){var n;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(i=r,r=null),n=function(e){var t;try{e()}catch(e){t=e}return t}(t),i=(r&&r.name?" ("+r.name+").":".")+(i?" "+i:"."),e&&!n&&g(n,r,"Missing expected exception"+i);var s="string"==typeof i,a=!e&&n&&!r;if((!e&&o.isError(n)&&s&&v(n,r)||a)&&g(n,r,"Got unwanted exception"+i),e&&n&&r&&!v(n,r)||!e&&n)throw n}l.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=m(b((t=this).actual),128)+" "+t.operator+" "+m(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var i=new Error;if(i.stack){var n=i.stack,s=p(r),o=n.indexOf("\n"+s);if(o>=0){var a=n.indexOf("\n",o+1);n=n.substring(a+1)}this.stack=n}}},o.inherits(l.AssertionError,Error),l.fail=g,l.ok=y,l.equal=function(e,t,r){e!=t&&g(e,t,r,"==",l.equal)},l.notEqual=function(e,t,r){e==t&&g(e,t,r,"!=",l.notEqual)},l.deepEqual=function(e,t,r){S(e,t,!1)||g(e,t,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(e,t,r){S(e,t,!0)||g(e,t,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(e,t,r){S(e,t,!1)&&g(e,t,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function e(t,r,i){S(t,r,!0)&&g(t,r,i,"notDeepStrictEqual",e)},l.strictEqual=function(e,t,r){e!==t&&g(e,t,r,"===",l.strictEqual)},l.notStrictEqual=function(e,t,r){e===t&&g(e,t,r,"!==",l.notStrictEqual)},l.throws=function(e,t,r){w(!0,e,t,r)},l.doesNotThrow=function(e,t,r){w(!1,e,t,r)},l.ifError=function(e){if(e)throw e},l.strict=i(function e(t,r){t||g(t,!0,r,"==",e)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var E=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":166,"util/":71}],69:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],70:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],71:[function(e,t,r){(function(t,i){(function(){ // distribute, sublicense, and/or sell copies of the Software, and to permit var n=/%[sdj%]/g;r.format=function(e){if(!g(e)){for(var t=[],r=0;r=s)return e;switch(e){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":try{return JSON.stringify(i[r++])}catch(e){return"[Circular]"}default:return e}}),h=i[r];r=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),p(t)?i.showHidden=t:t&&r._extend(i,t),y(i.showHidden)&&(i.showHidden=!1),y(i.depth)&&(i.depth=2),y(i.colors)&&(i.colors=!1),y(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=h),f(i,e,i.depth)}function h(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function c(e,t){return e}function f(e,t,i){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(i,e);return g(n)||(n=f(e,n,i)),n}var s=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(g(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(b(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(m(t))return e.stylize("null","null")}(e,t);if(s)return s;var o=Object.keys(t),a=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),w(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return u(t);if(0===o.length){if(E(t)){var h=t.name?": "+t.name:"";return e.stylize("[Function"+h+"]","special")}if(S(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(v(t))return e.stylize(Date.prototype.toString.call(t),"date");if(w(t))return u(t)}var c,_="",M=!1,k=["{","}"];(d(t)&&(M=!0,k=["[","]"]),E(t))&&(_=" [Function"+(t.name?": "+t.name:"")+"]");return S(t)&&(_=" "+RegExp.prototype.toString.call(t)),v(t)&&(_=" "+Date.prototype.toUTCString.call(t)),w(t)&&(_=" "+u(t)),0!==o.length||M&&0!=t.length?i<0?S(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=M?function(e,t,r,i,n){for(var s=[],o=0,a=t.length;o=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,_,k)):k[0]+_+k[1]}function u(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,i,n,s){var o,a,h;if((h=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?a=h.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):h.set&&(a=e.stylize("[Setter]","special")),O(i,n)||(o="["+n+"]"),a||(e.seen.indexOf(h.value)<0?(a=m(r)?f(e,h.value,null):f(e,h.value,r-1)).indexOf("\n")>-1&&(a=s?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),y(o)){if(s&&n.match(/^\d+$/))return a;(o=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+a}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function m(e){return null===e}function b(e){return"number"==typeof e}function g(e){return"string"==typeof e}function y(e){return void 0===e}function S(e){return _(e)&&"[object RegExp]"===M(e)}function _(e){return"object"==typeof e&&null!==e}function v(e){return _(e)&&"[object Date]"===M(e)}function w(e){return _(e)&&("[object Error]"===M(e)||e instanceof Error)}function E(e){return"function"==typeof e}function M(e){return Object.prototype.toString.call(e)}r.debuglog=function(e){if(y(s)&&(s=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!o[e])if(new RegExp("\\b"+e+"\\b","i").test(s)){t.pid;o[e]=function(){r.format.apply(r,arguments)}}else o[e]=function(){};return o[e]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=m,r.isNullOrUndefined=function(e){return null==e},r.isNumber=b,r.isString=g,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=y,r.isRegExp=S,r.isObject=_,r.isDate=v,r.isError=w,r.isFunction=E,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");function O(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!_(t))return e;for(var r=Object.keys(t),i=r.length;i--;)e[r[i]]=t[r[i]];return e}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":70,_process:178,inherits:69}],72:[function(e,t,r){(function(t){(function(){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */"use strict";var t=e("base64-js"),i=e("ieee754");r.Buffer=o,r.SlowBuffer=function(e){+e!=e&&(e=0);return o.alloc(+e)},r.INSPECT_MAX_BYTES=50;var n=2147483647;function s(e){if(e>n)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=o.prototype,t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return c(e)}return a(e,t,r)}function a(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|l(e,t),i=s(r),n=i.write(e,t);n!==r&&(i=i.slice(0,n));return i}(e,t);if(ArrayBuffer.isView(e))return f(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|e}function l(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return P(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return i?-1:P(e).length;t=(""+t).toLowerCase(),n=!0}}function d(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function p(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=o.from(t,i)),o.isBuffer(t))return 0===t.length?-1:m(e,t,r,i,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,i,n){var s,o=1,a=e.length,h=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,a/=2,h/=2,r/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n){var f=-1;for(s=r;sa&&(r=a-h),s=r;s>=0;s--){for(var u=!0,l=0;ln&&(i=n):i=n;var s=t.length;i>s/2&&(i=s/2);for(var o=0;o>8,n=r%256,s.push(n),s.push(i);return s}(t,e.length-r),e,r,i)}function w(e,r,i){return 0===r&&i===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,i))}function E(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n239?4:c>223?3:c>191?2:1;if(n+u<=r)switch(u){case 1:c<128&&(f=c);break;case 2:128==(192&(s=e[n+1]))&&(h=(31&c)<<6|63&s)>127&&(f=h);break;case 3:s=e[n+1],o=e[n+2],128==(192&s)&&128==(192&o)&&(h=(15&c)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(f=h);break;case 4:s=e[n+1],o=e[n+2],a=e[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&c)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(f=h)}null===f?(f=65533,u=1):f>65535&&(f-=65536,i.push(f>>>10&1023|55296),f=56320|1023&f),i.push(f),n+=u}return function(e){var t=e.length;if(t<=M)return String.fromCharCode.apply(String,e);var r="",i=0;for(;ithis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,r);case"utf8":case"utf-8":return E(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return k(this,t,r);case"base64":return w(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),""},o.prototype.compare=function(e,t,r,i,n){if(Y(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=r)return 0;if(i>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(n>>>=0)-(i>>>=0),a=(r>>>=0)-(t>>>=0),h=Math.min(s,a),c=this.slice(i,n),f=e.slice(t,r),u=0;u>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return g(this,e,t,r);case"ascii":return y(this,e,t,r);case"latin1":case"binary":return S(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var M=4096;function O(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;ni)&&(r=i);for(var n="",s=t;sr)throw new RangeError("Trying to access beyond buffer length")}function x(e,t,r,i,n,s){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||te.length)throw new RangeError("Index out of range")}function A(e,t,r,i,n,s){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(e,t,r,n,s){return t=+t,r>>>=0,s||A(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function I(e,t,r,n,s){return t=+t,r>>>=0,s||A(e,0,r,8),i.write(e,t,r,n,52,8),r+8}o.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||C(e,t,this.length);for(var i=this[e],n=1,s=0;++s>>=0,t>>>=0,r||C(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},o.prototype.readUInt8=function(e,t){return e>>>=0,t||C(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||C(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||C(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||C(e,t,this.length);for(var i=this[e],n=1,s=0;++s=(n*=128)&&(i-=Math.pow(2,8*t)),i},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||C(e,t,this.length);for(var i=t,n=1,s=this[e+--i];i>0&&(n*=256);)s+=this[e+--i]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*t)),s},o.prototype.readInt8=function(e,t){return e>>>=0,t||C(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||C(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(e,t){e>>>=0,t||C(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||C(e,4,this.length),i.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||C(e,4,this.length),i.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||C(e,8,this.length),i.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||C(e,8,this.length),i.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||x(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,s=0;for(this[t]=255&e;++s>>=0,r>>>=0,i)||x(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,s=1;for(this[t+n]=255&e;--n>=0&&(s*=256);)this[t+n]=e/s&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);x(this,e,t,r,n-1,-n)}var s=0,o=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+r},o.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);x(this,e,t,r,n-1,-n)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeFloatLE=function(e,t,r){return D(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return D(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return I(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return I(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,i){if(!o.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t=0;--s)e[s+t]=this[s+r];else Uint8Array.prototype.set.call(e,this.subarray(r,i),t);return n},o.prototype.fill=function(e,t,r,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!o.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var n=e.charCodeAt(0);("utf8"===i&&n<128||"latin1"===i)&&(e=n)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function F(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function L(e,t,r,i){for(var n=0;n=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function U(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":22,buffer:72,ieee754:142}],73:[function(e,t,r){(function(e){(function(){t.exports=function(t,r){for(var i=Math.min(t.length,r.length),n=new e(i),s=0;sr)?t=("rmd160"===e?new h:c(e)).update(t).digest():t.lengtha?t=e(t):t.length0;i--)t+=this._buffer(e,t),r+=this._flushBuffer(n,r);return t+=this._buffer(e,t),n},n.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},n.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=s.r28shl(r,a),n=s.r28shl(n,a),s.pc2(r,n,e.keys,o)}},h.prototype._update=function(e,t,r,i){var n=this._desState,o=s.readUInt32BE(e,t),a=s.readUInt32BE(e,t+4);s.ip(o,a,n.tmp,0),o=n.tmp[0],a=n.tmp[1],"encrypt"===this.type?this._encrypt(n,o,a,n.tmp,0):this._decrypt(n,o,a,n.tmp,0),o=n.tmp[0],a=n.tmp[1],s.writeUInt32BE(r,o,i),s.writeUInt32BE(r,a,i+4)},h.prototype._pad=function(e,t){for(var r=e.length-t,i=t;i>>0,o=l}s.rip(a,o,i,n)},h.prototype._decrypt=function(e,t,r,i,n){for(var o=r,a=t,h=e.keys.length-2;h>=0;h-=2){var c=e.keys[h],f=e.keys[h+1];s.expand(o,e.tmp,0),c^=e.tmp[0],f^=e.tmp[1];var u=s.substitute(c,f),l=o;o=(a^s.permute(u))>>>0,a=l}s.rip(o,a,i,n)}},{"./cipher":85,"./utils":88,inherits:143,"minimalistic-assert":147}],87:[function(e,t,r){"use strict";var i=e("minimalistic-assert"),n=e("inherits"),s=e("./cipher"),o=e("./des");function a(e,t){i.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),n=t.slice(8,16),s=t.slice(16,24);this.ciphers="encrypt"===e?[o.create({type:"encrypt",key:r}),o.create({type:"decrypt",key:n}),o.create({type:"encrypt",key:s})]:[o.create({type:"decrypt",key:s}),o.create({type:"encrypt",key:n}),o.create({type:"decrypt",key:r})]}function h(e){s.call(this,e);var t=new a(this.type,this.options.key);this._edeState=t}n(h,s),t.exports=h,h.create=function(e){return new h(e)},h.prototype._update=function(e,t,r,i){var n=this._edeState;n.ciphers[0]._update(e,t,r,i),n.ciphers[1]._update(r,i,r,i),n.ciphers[2]._update(r,i,r,i)},h.prototype._pad=o.prototype._pad,h.prototype._unpad=o.prototype._unpad},{"./cipher":85,"./des":86,inherits:143,"minimalistic-assert":147}],88:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,i){for(var n=0,s=0,o=6;o>=0;o-=2){for(var a=0;a<=24;a+=8)n<<=1,n|=t>>>a+o&1;for(a=0;a<=24;a+=8)n<<=1,n|=e>>>a+o&1}for(o=6;o>=0;o-=2){for(a=1;a<=25;a+=8)s<<=1,s|=t>>>a+o&1;for(a=1;a<=25;a+=8)s<<=1,s|=e>>>a+o&1}r[i+0]=n>>>0,r[i+1]=s>>>0},r.rip=function(e,t,r,i){for(var n=0,s=0,o=0;o<4;o++)for(var a=24;a>=0;a-=8)n<<=1,n|=t>>>a+o&1,n<<=1,n|=e>>>a+o&1;for(o=4;o<8;o++)for(a=24;a>=0;a-=8)s<<=1,s|=t>>>a+o&1,s<<=1,s|=e>>>a+o&1;r[i+0]=n>>>0,r[i+1]=s>>>0},r.pc1=function(e,t,r,i){for(var n=0,s=0,o=7;o>=5;o--){for(var a=0;a<=24;a+=8)n<<=1,n|=t>>a+o&1;for(a=0;a<=24;a+=8)n<<=1,n|=e>>a+o&1}for(a=0;a<=24;a+=8)n<<=1,n|=t>>a+o&1;for(o=1;o<=3;o++){for(a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1;for(a=0;a<=24;a+=8)s<<=1,s|=e>>a+o&1}for(a=0;a<=24;a+=8)s<<=1,s|=e>>a+o&1;r[i+0]=n>>>0,r[i+1]=s>>>0},r.r28shl=function(e,t){return e<>>28-t};var i=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,n){for(var s=0,o=0,a=i.length>>>1,h=0;h>>i[h]&1;for(h=a;h>>i[h]&1;r[n+0]=s>>>0,r[n+1]=o>>>0},r.expand=function(e,t,r){var i=0,n=0;i=(1&e)<<5|e>>>27;for(var s=23;s>=15;s-=4)i<<=6,i|=e>>>s&63;for(s=11;s>=3;s-=4)n|=e>>>s&63,n<<=6;n|=(31&e)<<1|e>>>31,t[r+0]=i>>>0,t[r+1]=n>>>0};var n=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,i=0;i<4;i++){r<<=4,r|=n[64*i+(e>>>18-6*i&63)]}for(i=0;i<4;i++){r<<=4,r|=n[256+64*i+(t>>>18-6*i&63)]}return r>>>0};var s=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>s[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var i=e.toString(2);i.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(h),t.cmp(h)){if(!t.cmp(c))for(;r.mod(f).cmp(u);)r.iadd(d)}else for(;r.mod(s).cmp(l);)r.iadd(d);if(b(p=r.shrn(1))&&b(r)&&g(p)&&g(r)&&o.test(p)&&o.test(r))return r}}},{"bn.js":93,"miller-rabin":145,randombytes:186}],92:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],93:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{buffer:25,dup:15}],94:[function(e,t,r){"use strict";var i=r;i.version=e("../package.json").version,i.utils=e("./elliptic/utils"),i.rand=e("brorand"),i.curve=e("./elliptic/curve"),i.curves=e("./elliptic/curves"),i.ec=e("./elliptic/ec"),i.eddsa=e("./elliptic/eddsa")},{"../package.json":110,"./elliptic/curve":97,"./elliptic/curves":100,"./elliptic/ec":101,"./elliptic/eddsa":104,"./elliptic/utils":108,brorand:24}],95:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../utils"),s=n.getNAF,o=n.getJSF,a=n.assert;function h(e,t){this.type=e,this.p=new i(t.p,16),this.red=t.prime?i.red(t.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=t.n&&new i(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=h,h.prototype.point=function(){throw new Error("Not implemented")},h.prototype.validate=function(){throw new Error("Not implemented")},h.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),i=s(t,1,this._bitLength),n=(1<=o;f--)h=(h<<1)+i[f];c.push(h)}for(var u=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=n;d>0;d--){for(o=0;o=0;c--){for(var f=0;c>=0&&0===o[c];c--)f++;if(c>=0&&f++,h=h.dblp(f),c<0)break;var u=o[c];a(0!==u),h="affine"===e.type?u>0?h.mixedAdd(n[u-1>>1]):h.mixedAdd(n[-u-1>>1].neg()):u>0?h.add(n[u-1>>1]):h.add(n[-u-1>>1].neg())}return"affine"===e.type?h.toP():h},h.prototype._wnafMulAdd=function(e,t,r,i,n){var a,h,c,f=this._wnafT1,u=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var m=a-1,b=a;if(1===f[m]&&1===f[b]){var g=[t[m],null,null,t[b]];0===t[m].y.cmp(t[b].y)?(g[1]=t[m].add(t[b]),g[2]=t[m].toJ().mixedAdd(t[b].neg())):0===t[m].y.cmp(t[b].y.redNeg())?(g[1]=t[m].toJ().mixedAdd(t[b]),g[2]=t[m].add(t[b].neg())):(g[1]=t[m].toJ().mixedAdd(t[b]),g[2]=t[m].toJ().mixedAdd(t[b].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],S=o(r[m],r[b]);for(d=Math.max(S[0].length,d),l[m]=new Array(d),l[b]=new Array(d),h=0;h=0;a--){for(var M=0;a>=0;){var O=!0;for(h=0;h=0&&M++,w=w.dblp(M),a<0)break;for(h=0;h0?c=u[h][k-1>>1]:k<0&&(c=u[h][-k-1>>1].neg()),w="affine"===c.type?w.mixedAdd(c):w.add(c))}}for(a=0;a=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n":""},c.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},c.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(e),n=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),s=i.redAdd(t),o=s.redSub(r),a=i.redSub(t),h=n.redMul(o),c=s.redMul(a),f=n.redMul(a),u=o.redMul(s);return this.curve.point(h,c,u,f)},c.prototype._projDbl=function(){var e,t,r,i,n,s,o=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),h=this.y.redSqr();if(this.curve.twisted){var c=(i=this.curve._mulA(a)).redAdd(h);this.zOne?(e=o.redSub(a).redSub(h).redMul(c.redSub(this.curve.two)),t=c.redMul(i.redSub(h)),r=c.redSqr().redSub(c).redSub(c)):(n=this.z.redSqr(),s=c.redSub(n).redISub(n),e=o.redSub(a).redISub(h).redMul(s),t=c.redMul(i.redSub(h)),r=c.redMul(s))}else i=a.redAdd(h),n=this.curve._mulC(this.z).redSqr(),s=i.redSub(n).redSub(n),e=this.curve._mulC(o.redISub(i)).redMul(s),t=this.curve._mulC(i).redMul(a.redISub(h)),r=i.redMul(s);return this.curve.point(e,t,r)},c.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),n=this.z.redMul(e.z.redAdd(e.z)),s=r.redSub(t),o=n.redSub(i),a=n.redAdd(i),h=r.redAdd(t),c=s.redMul(o),f=a.redMul(h),u=s.redMul(h),l=o.redMul(a);return this.curve.point(c,f,l,u)},c.prototype._projAdd=function(e){var t,r,i=this.z.redMul(e.z),n=i.redSqr(),s=this.x.redMul(e.x),o=this.y.redMul(e.y),a=this.curve.d.redMul(s).redMul(o),h=n.redSub(a),c=n.redAdd(a),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(s).redISub(o),u=i.redMul(h).redMul(f);return this.curve.twisted?(t=i.redMul(c).redMul(o.redSub(this.curve._mulA(s))),r=h.redMul(c)):(t=i.redMul(c).redMul(o.redSub(s)),r=this.curve._mulC(h).redMul(c)),this.curve.point(u,t,r)},c.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},c.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},c.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},c.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function(){return this.normalize(),this.y.fromRed()},c.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},c.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},{"../utils":108,"./base":95,"bn.js":109,inherits:143}],97:[function(e,t,r){"use strict";var i=r;i.base=e("./base"),i.short=e("./short"),i.mont=e("./mont"),i.edwards=e("./edwards")},{"./base":95,"./edwards":96,"./mont":98,"./short":99}],98:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("inherits"),s=e("./base"),o=e("../utils");function a(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function h(e,t,r){s.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}n(a,s),t.exports=a,a.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),i=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===i.redSqrt().redSqr().cmp(i)},n(h,s.BasePoint),a.prototype.decodePoint=function(e,t){return this.point(o.toArray(e,t),1)},a.prototype.point=function(e,t){return new h(this,e,t)},a.prototype.pointFromJSON=function(e){return h.fromJSON(this,e)},h.prototype.precompute=function(){},h.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},h.fromJSON=function(e,t){return new h(e,t[0],t[1]||e.one)},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},h.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),i=e.redMul(t),n=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},h.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},h.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=e.x.redAdd(e.z),s=e.x.redSub(e.z).redMul(r),o=n.redMul(i),a=t.z.redMul(s.redAdd(o).redSqr()),h=t.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,h)},h.prototype.mul=function(e){for(var t=e.clone(),r=this,i=this.curve.point(null,null),n=[];0!==t.cmpn(0);t.iushrn(1))n.push(t.andln(1));for(var s=n.length-1;s>=0;s--)0===n[s]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},h.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},h.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},h.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},h.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},h.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":108,"./base":95,"bn.js":109,inherits:143}],99:[function(e,t,r){"use strict";var i=e("../utils"),n=e("bn.js"),s=e("inherits"),o=e("./base"),a=i.assert;function h(e){o.call(this,"short",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function c(e,t,r,i){o.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new n(t,16),this.y=new n(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,r,i){o.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new n(0)):(this.x=new n(t,16),this.y=new n(r,16),this.z=new n(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}s(h,o),t.exports=h,h.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new n(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=(t=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(e.lambda)r=new n(e.lambda,16);else{var s=this._getEndoRoots(this.n);0===this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))?r=s[0]:(r=s[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new n(e.a,16),b:new n(e.b,16)}}):this._getEndoBasis(r)}}},h.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:n.mont(e),r=new n(2).toRed(t).redInvm(),i=r.redNeg(),s=new n(3).toRed(t).redNeg().redSqrt().redMul(r);return[i.redAdd(s).fromRed(),i.redSub(s).fromRed()]},h.prototype._getEndoBasis=function(e){for(var t,r,i,s,o,a,h,c,f,u=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new n(1),m=new n(0),b=new n(0),g=new n(1),y=0;0!==l.cmpn(0);){var S=d.div(l);c=d.sub(S.mul(l)),f=b.sub(S.mul(p));var _=g.sub(S.mul(m));if(!i&&c.cmp(u)<0)t=h.neg(),r=p,i=c.neg(),s=f;else if(i&&2==++y)break;h=c,d=l,l=c,b=p,p=f,g=m,m=_}o=c.neg(),a=f;var v=i.sqr().add(s.sqr());return o.sqr().add(a.sqr()).cmp(v)>=0&&(o=t,a=r),i.negative&&(i=i.neg(),s=s.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:i,b:s},{a:o,b:a}]},h.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],i=t[1],n=i.b.mul(e).divRound(this.n),s=r.b.neg().mul(e).divRound(this.n),o=n.mul(r.a),a=s.mul(i.a),h=n.mul(r.b),c=s.mul(i.b);return{k1:e.sub(o).sub(a),k2:h.add(c).neg()}},h.prototype.pointFromX=function(e,t){(e=new n(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(e,i)},h.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,i=this.a.redMul(t),n=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},h.prototype._endoWnafMulAdd=function(e,t,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s":""},c.prototype.isInfinity=function(){return this.inf},c.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},c.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),i=e.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},c.prototype.getX=function(){return this.x.fromRed()},c.prototype.getY=function(){return this.y.fromRed()},c.prototype.mul=function(e){return e=new n(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},c.prototype.jmulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},c.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},c.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t},c.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(f,o.BasePoint),h.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(r,i)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(t),n=e.x.redMul(r),s=this.y.redMul(t.redMul(e.z)),o=e.y.redMul(r.redMul(this.z)),a=i.redSub(n),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),u=i.redMul(c),l=h.redSqr().redIAdd(f).redISub(u).redISub(u),d=h.redMul(u.redISub(l)).redISub(s.redMul(f)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(l,d,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,i=e.x.redMul(t),n=this.y,s=e.y.redMul(t).redMul(this.z),o=r.redSub(i),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),c=h.redMul(o),f=r.redMul(h),u=a.redSqr().redIAdd(c).redISub(f).redISub(f),l=a.redMul(f.redISub(u)).redISub(n.redMul(c)),d=this.z.redMul(o);return this.curve.jpoint(u,l,d)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":108,"./base":95,"bn.js":109,inherits:143}],100:[function(e,t,r){"use strict";var i,n=r,s=e("hash.js"),o=e("./curve"),a=e("./utils").assert;function h(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new h(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=h,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:s.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:s.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:s.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:s.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:s.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{i=e("./precomputed/secp256k1")}catch(e){i=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:s.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",i]})},{"./curve":97,"./precomputed/secp256k1":107,"./utils":108,"hash.js":129}],101:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("hmac-drbg"),s=e("../utils"),o=e("../curves"),a=e("brorand"),h=s.assert,c=e("./key"),f=e("./signature");function u(e){if(!(this instanceof u))return new u(e);"string"==typeof e&&(h(Object.prototype.hasOwnProperty.call(o,e),"Unknown curve "+e),e=o[e]),e instanceof o.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=u,u.prototype.keyPair=function(e){return new c(this,e)},u.prototype.keyFromPrivate=function(e,t){return c.fromPrivate(this,e,t)},u.prototype.keyFromPublic=function(e,t){return c.fromPublic(this,e,t)},u.prototype.genKeyPair=function(e){e||(e={});for(var t=new n({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||a(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),s=this.n.sub(new i(2));;){var o=new i(t.generate(r));if(!(o.cmp(s)>0))return o.iaddn(1),this.keyFromPrivate(o)}},u.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},u.prototype.sign=function(e,t,r,s){"object"==typeof r&&(s=r,r=null),s||(s={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new i(e,16));for(var o=this.n.byteLength(),a=t.getPrivate().toArray("be",o),h=e.toArray("be",o),c=new n({hash:this.hash,entropy:a,nonce:h,pers:s.pers,persEnc:s.persEnc||"utf8"}),u=this.n.sub(new i(1)),l=0;;l++){var d=s.k?s.k(l):new i(c.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(u)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var m=p.getX(),b=m.umod(this.n);if(0!==b.cmpn(0)){var g=d.invm(this.n).mul(b.mul(t.getPrivate()).iadd(e));if(0!==(g=g.umod(this.n)).cmpn(0)){var y=(p.getY().isOdd()?1:0)|(0!==m.cmp(b)?2:0);return s.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),y^=1),new f({r:b,s:g,recoveryParam:y})}}}}}},u.prototype.verify=function(e,t,r,n){e=this._truncateToN(new i(e,16)),r=this.keyFromPublic(r,n);var s=(t=new f(t,"hex")).r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,h=o.invm(this.n),c=h.mul(e).umod(this.n),u=h.mul(s).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(c,r.getPublic(),u)).isInfinity()&&a.eqXToP(s):!(a=this.g.mulAdd(c,r.getPublic(),u)).isInfinity()&&0===a.getX().umod(this.n).cmp(s)},u.prototype.recoverPubKey=function(e,t,r,n){h((3&r)===r,"The recovery param is more than two bits"),t=new f(t,n);var s=this.n,o=new i(e),a=t.r,c=t.s,u=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),u):this.curve.pointFromX(a,u);var d=t.r.invm(s),p=s.sub(o).mul(d).umod(s),m=c.mul(d).umod(s);return this.g.mulAdd(p,a,m)},u.prototype.getKeyRecoveryParam=function(e,t,r,i){if(null!==(t=new f(t,i)).recoveryParam)return t.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(e,t,n)}catch(e){continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")}},{"../curves":100,"../utils":108,"./key":102,"./signature":103,"bn.js":109,brorand:24,"hmac-drbg":141}],102:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../utils").assert;function s(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=s,s.fromPublic=function(e,t,r){return t instanceof s?t:new s(e,{pub:t,pubEnc:r})},s.fromPrivate=function(e,t,r){return t instanceof s?t:new s(e,{priv:t,privEnc:r})},s.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},s.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},s.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},s.prototype._importPrivate=function(e,t){this.priv=new i(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},s.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?n(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||n(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},s.prototype.derive=function(e){return e.validate()||n(e.validate(),"public point not validated"),e.mul(this.priv).getX()},s.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},s.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},s.prototype.inspect=function(){return""}},{"../utils":108,"bn.js":109}],103:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../utils"),s=n.assert;function o(e,t){if(e instanceof o)return e;this._importDER(e,t)||(s(e.r&&e.s,"Signature without r or s"),this.r=new i(e.r,16),this.s=new i(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(){this.place=0}function h(e,t){var r=e[t.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,s=0,o=t.place;s>>=0;return!(n<=127)&&(t.place=o,n)}function c(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=o,o.prototype._importDER=function(e,t){e=n.toArray(e,t);var r=new a;if(48!==e[r.place++])return!1;var s=h(e,r);if(!1===s)return!1;if(s+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=h(e,r);if(!1===o)return!1;var c=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var f=h(e,r);if(!1===f)return!1;if(e.length!==f+r.place)return!1;var u=e.slice(r.place,f+r.place);if(0===c[0]){if(!(128&c[1]))return!1;c=c.slice(1)}if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}return this.r=new i(c),this.s=new i(u),this.recoveryParam=null,!0},o.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=c(t),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];f(i,t.length),(i=i.concat(t)).push(2),f(i,r.length);var s=i.concat(r),o=[48];return f(o,s.length),o=o.concat(s),n.encode(o,e)}},{"../utils":108,"bn.js":109}],104:[function(e,t,r){"use strict";var i=e("hash.js"),n=e("../curves"),s=e("../utils"),o=s.assert,a=s.parseBytes,h=e("./key"),c=e("./signature");function f(e){if(o("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=n[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=i.sha512}t.exports=f,f.prototype.sign=function(e,t){e=a(e);var r=this.keyFromSecret(t),i=this.hashInt(r.messagePrefix(),e),n=this.g.mul(i),s=this.encodePoint(n),o=this.hashInt(s,r.pubBytes(),e).mul(r.priv()),h=i.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:h,Rencoded:s})},f.prototype.verify=function(e,t,r){e=a(e),t=this.makeSignature(t);var i=this.keyFromPublic(r),n=this.hashInt(t.Rencoded(),i.pubBytes(),e),s=this.g.mul(t.S());return t.R().add(i.pub().mul(n)).eq(s)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t(n>>1)-1?(n>>1)-h:h,s.isubn(a)):a=0,i[o]=a,s.iushrn(1)}return i},i.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var i,n=0,s=0;e.cmpn(-n)>0||t.cmpn(-s)>0;){var o,a,h=e.andln(3)+n&3,c=t.andln(3)+s&3;3===h&&(h=-1),3===c&&(c=-1),o=0==(1&h)?0:3!=(i=e.andln(7)+n&7)&&5!==i||2!==c?h:-h,r[0].push(o),a=0==(1&c)?0:3!=(i=t.andln(7)+s&7)&&5!==i||2!==h?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),e.iushrn(1),t.iushrn(1)}return r},i.cachedProperty=function(e,t,r){var i="_"+t;e.prototype[t]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},i.parseBytes=function(e){return"string"==typeof e?i.toArray(e,"hex"):e},i.intFromLE=function(e){return new n(e,"hex","le")}},{"bn.js":109,"minimalistic-assert":147,"minimalistic-crypto-utils":148}],109:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{buffer:25,dup:15}],110:[function(e,t,r){t.exports={_args:[["elliptic@6.5.4","/source/synoc2fs-pkg/ui"]],_development:!0,_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://npm.synology.inc/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/source/synoc2fs-pkg/ui",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],111:[function(e,t,r){ // distribute, sublicense, and/or sell copies of the Software, and to permit "use strict";var i,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};i=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}t.exports=a,t.exports.once=function(e,t){return new Promise(function(r,i){function n(r){e.removeListener(t,s),i(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}b(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&b(e,"error",t,r)}(e,n,{once:!0})})},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var h=10;function c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function f(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function u(e,t,r,i){var n,s,o;if(c(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=f(e))>0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,console&&console.warn}return e}function l(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(i);return n.listener=r,i.wrapFn=n,n}function d(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=n[e];if(void 0===h)return!1;if("function"==typeof h)s(h,this,t);else{var c=h.length,f=m(h,c);for(r=0;r=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},a.prototype.listeners=function(e){return d(this,e,!0)},a.prototype.rawListeners=function(e){return d(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},a.prototype.listenerCount=p,a.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},{}],112:[function(e,t,r){var i=e("safe-buffer").Buffer,n=e("md5.js");t.exports=function(e,t,r,s){if(i.isBuffer(e)||(e=i.from(e,"binary")),t&&(i.isBuffer(t)||(t=i.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,a=i.alloc(o),h=i.alloc(s||0),c=i.alloc(0);o>0||s>0;){var f=new n;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var u=0;if(o>0){var l=a.length-o;u=Math.min(o,c.length),c.copy(a,l,0,u),o-=u}if(u0){var d=h.length-s,p=Math.min(s,c.length-u);c.copy(h,d,u,u+p),s-=p}}return c.fill(0),{key:a,iv:h}}},{"md5.js":144,"safe-buffer":189}],113:[function(e,t,r){"use strict";var i=e("safe-buffer").Buffer,n=e("readable-stream").Transform;function s(e){n.call(this),this._block=i.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(s,n),s.prototype._transform=function(e,t,r){var i=null;try{this.update(e,t)}catch(e){i=e}r(i)},s.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},s.prototype.update=function(e,t){if(function(e,t){if(!i.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");i.isBuffer(e)||(e=i.from(e,t));for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var s=this._blockOffset;s0;++o)this._length[o]+=a,(a=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*a);return this},s.prototype._update=function(){throw new Error("_update is not implemented")},s.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},s.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=s},{inherits:143,"readable-stream":128,"safe-buffer":189}],114:[function(e,t,r){arguments[4][53][0].apply(r,arguments)},{dup:53}],115:[function(e,t,r){arguments[4][54][0].apply(r,arguments)},{"./_stream_readable":117,"./_stream_writable":119,_process:178,dup:54,inherits:143}],116:[function(e,t,r){arguments[4][55][0].apply(r,arguments)},{"./_stream_transform":118,dup:55,inherits:143}],117:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"../errors":114,"./_stream_duplex":115,"./internal/streams/async_iterator":120,"./internal/streams/buffer_list":121,"./internal/streams/destroy":122,"./internal/streams/from":124,"./internal/streams/state":126,"./internal/streams/stream":127,_process:178,buffer:72,dup:56,events:111,inherits:143,"string_decoder/":214,util:25}],118:[function(e,t,r){arguments[4][57][0].apply(r,arguments)},{"../errors":114,"./_stream_duplex":115,dup:57,inherits:143}],119:[function(e,t,r){arguments[4][58][0].apply(r,arguments)},{"../errors":114,"./_stream_duplex":115,"./internal/streams/destroy":122,"./internal/streams/state":126,"./internal/streams/stream":127,_process:178,buffer:72,dup:58,inherits:143,"util-deprecate":215}],120:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{"./end-of-stream":123,_process:178,dup:59}],121:[function(e,t,r){arguments[4][60][0].apply(r,arguments)},{buffer:72,dup:60,util:25}],122:[function(e,t,r){arguments[4][61][0].apply(r,arguments)},{_process:178,dup:61}],123:[function(e,t,r){arguments[4][62][0].apply(r,arguments)},{"../../../errors":114,dup:62}],124:[function(e,t,r){arguments[4][63][0].apply(r,arguments)},{dup:63}],125:[function(e,t,r){arguments[4][64][0].apply(r,arguments)},{"../../../errors":114,"./end-of-stream":123,dup:64}],126:[function(e,t,r){arguments[4][65][0].apply(r,arguments)},{"../../../errors":114,dup:65}],127:[function(e,t,r){arguments[4][66][0].apply(r,arguments)},{dup:66,events:111}],128:[function(e,t,r){arguments[4][67][0].apply(r,arguments)},{"./lib/_stream_duplex.js":115,"./lib/_stream_passthrough.js":116,"./lib/_stream_readable.js":117,"./lib/_stream_transform.js":118,"./lib/_stream_writable.js":119,"./lib/internal/streams/end-of-stream.js":123,"./lib/internal/streams/pipeline.js":125,dup:67}],129:[function(e,t,r){var i=r;i.utils=e("./hash/utils"),i.common=e("./hash/common"),i.sha=e("./hash/sha"),i.ripemd=e("./hash/ripemd"),i.hmac=e("./hash/hmac"),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},{"./hash/common":130,"./hash/hmac":131,"./hash/ripemd":132,"./hash/sha":133,"./hash/utils":140}],130:[function(e,t,r){"use strict";var i=e("./utils"),n=e("minimalistic-assert");function s(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=s,s.prototype.update=function(e,t){if(e=i.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=i.join32(e,0,e.length-r,this.endian);for(var n=0;n>>24&255,i[n++]=e>>>16&255,i[n++]=e>>>8&255,i[n++]=255&e}else for(i[n++]=255&e,i[n++]=e>>>8&255,i[n++]=e>>>16&255,i[n++]=e>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;sthis.blockSize&&(e=(new this.Hash).update(e).digest()),n(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return i(e,17)^i(e,19)^e>>>10}},{"../utils":140}],140:[function(e,t,r){"use strict";var i=e("minimalistic-assert"),n=e("inherits");function s(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function h(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=n,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>6|192,r[i++]=63&o|128):s(e,n)?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++n)),r[i++]=o>>18|240,r[i++]=o>>12&63|128,r[i++]=o>>6&63|128,r[i++]=63&o|128):(r[i++]=o>>12|224,r[i++]=o>>6&63|128,r[i++]=63&o|128)}else for(n=0;n>>0}return o},r.split32=function(e,t){for(var r=new Array(4*e.length),i=0,n=0;i>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=255&s):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=255&s)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,i){return e+t+r+i>>>0},r.sum32_5=function(e,t,r,i,n){return e+t+r+i+n>>>0},r.sum64=function(e,t,r,i){var n=e[t],s=i+e[t+1]>>>0,o=(s>>0,e[t+1]=s},r.sum64_hi=function(e,t,r,i){return(t+i>>>0>>0},r.sum64_lo=function(e,t,r,i){return t+i>>>0},r.sum64_4_hi=function(e,t,r,i,n,s,o,a){var h=0,c=t;return h+=(c=c+i>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,i,n,s,o,a){return t+i+s+a>>>0},r.sum64_5_hi=function(e,t,r,i,n,s,o,a,h,c){var f=0,u=t;return f+=(u=u+i>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,i,n,s,o,a,h,c){return t+i+s+a+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:143,"minimalistic-assert":147}],141:[function(e,t,r){"use strict";var i=e("hash.js"),n=e("minimalistic-crypto-utils"),s=e("minimalistic-assert");function o(e){if(!(this instanceof o))return new o(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=n.toArray(e.entropy,e.entropyEnc||"hex"),r=n.toArray(e.nonce,e.nonceEnc||"hex"),i=n.toArray(e.pers,e.persEnc||"hex");s(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,i)}t.exports=o,o.prototype._init=function(e,t,r){var i=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},o.prototype.generate=function(e,t,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(i=r,r=t,t=null),r&&(r=n.toArray(r,i||"hex"),this._update(r));for(var s=[];s.length */r.read=function(e,t,r,i,n){var s,o,a=8*n-i-1,h=(1<>1,f=-7,u=r?n-1:0,l=r?-1:1,d=e[t+u];for(u+=l,s=d&(1<<-f)-1,d>>=-f,f+=a;f>0;s=256*s+e[t+u],u+=l,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=i;f>0;o=256*o+e[t+u],u+=l,f-=8);if(0===s)s=1-c;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),s-=c}return(d?-1:1)*o*Math.pow(2,s-i)},r.write=function(e,t,r,i,n,s){var o,a,h,c=8*s-n-1,f=(1<>1,l=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,p=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=f):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),(t+=o+u>=1?l/h:l*Math.pow(2,1-u))*h>=2&&(o++,h/=2),o+u>=f?(a=0,o=f):o+u>=1?(a=(t*h-1)*Math.pow(2,n),o+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,n),o=0));n>=8;e[r+d]=255&a,d+=p,a/=256,n-=8);for(o=o<0;e[r+d]=255&o,d+=p,o/=256,c-=8);e[r+d-p]|=128*m}},{}],143:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},{}],144:[function(e,t,r){"use strict";var i=e("inherits"),n=e("hash-base"),s=e("safe-buffer").Buffer,o=new Array(16);function a(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function h(e,t){return e<>>32-t}function c(e,t,r,i,n,s,o){return h(e+(t&r|~t&i)+n+s|0,o)+t|0}function f(e,t,r,i,n,s,o){return h(e+(t&i|r&~i)+n+s|0,o)+t|0}function u(e,t,r,i,n,s,o){return h(e+(t^r^i)+n+s|0,o)+t|0}function l(e,t,r,i,n,s,o){return h(e+(r^(t|~i))+n+s|0,o)+t|0}i(a,n),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,i=this._b,n=this._c,s=this._d;r=c(r,i,n,s,e[0],3614090360,7),s=c(s,r,i,n,e[1],3905402710,12),n=c(n,s,r,i,e[2],606105819,17),i=c(i,n,s,r,e[3],3250441966,22),r=c(r,i,n,s,e[4],4118548399,7),s=c(s,r,i,n,e[5],1200080426,12),n=c(n,s,r,i,e[6],2821735955,17),i=c(i,n,s,r,e[7],4249261313,22),r=c(r,i,n,s,e[8],1770035416,7),s=c(s,r,i,n,e[9],2336552879,12),n=c(n,s,r,i,e[10],4294925233,17),i=c(i,n,s,r,e[11],2304563134,22),r=c(r,i,n,s,e[12],1804603682,7),s=c(s,r,i,n,e[13],4254626195,12),n=c(n,s,r,i,e[14],2792965006,17),r=f(r,i=c(i,n,s,r,e[15],1236535329,22),n,s,e[1],4129170786,5),s=f(s,r,i,n,e[6],3225465664,9),n=f(n,s,r,i,e[11],643717713,14),i=f(i,n,s,r,e[0],3921069994,20),r=f(r,i,n,s,e[5],3593408605,5),s=f(s,r,i,n,e[10],38016083,9),n=f(n,s,r,i,e[15],3634488961,14),i=f(i,n,s,r,e[4],3889429448,20),r=f(r,i,n,s,e[9],568446438,5),s=f(s,r,i,n,e[14],3275163606,9),n=f(n,s,r,i,e[3],4107603335,14),i=f(i,n,s,r,e[8],1163531501,20),r=f(r,i,n,s,e[13],2850285829,5),s=f(s,r,i,n,e[2],4243563512,9),n=f(n,s,r,i,e[7],1735328473,14),r=u(r,i=f(i,n,s,r,e[12],2368359562,20),n,s,e[5],4294588738,4),s=u(s,r,i,n,e[8],2272392833,11),n=u(n,s,r,i,e[11],1839030562,16),i=u(i,n,s,r,e[14],4259657740,23),r=u(r,i,n,s,e[1],2763975236,4),s=u(s,r,i,n,e[4],1272893353,11),n=u(n,s,r,i,e[7],4139469664,16),i=u(i,n,s,r,e[10],3200236656,23),r=u(r,i,n,s,e[13],681279174,4),s=u(s,r,i,n,e[0],3936430074,11),n=u(n,s,r,i,e[3],3572445317,16),i=u(i,n,s,r,e[6],76029189,23),r=u(r,i,n,s,e[9],3654602809,4),s=u(s,r,i,n,e[12],3873151461,11),n=u(n,s,r,i,e[15],530742520,16),r=l(r,i=u(i,n,s,r,e[2],3299628645,23),n,s,e[0],4096336452,6),s=l(s,r,i,n,e[7],1126891415,10),n=l(n,s,r,i,e[14],2878612391,15),i=l(i,n,s,r,e[5],4237533241,21),r=l(r,i,n,s,e[12],1700485571,6),s=l(s,r,i,n,e[3],2399980690,10),n=l(n,s,r,i,e[10],4293915773,15),i=l(i,n,s,r,e[1],2240044497,21),r=l(r,i,n,s,e[8],1873313359,6),s=l(s,r,i,n,e[15],4264355552,10),n=l(n,s,r,i,e[6],2734768916,15),i=l(i,n,s,r,e[13],1309151649,21),r=l(r,i,n,s,e[4],4149444226,6),s=l(s,r,i,n,e[11],3174756917,10),n=l(n,s,r,i,e[2],718787259,15),i=l(i,n,s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+n|0,this._d=this._d+s|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=s.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a},{"hash-base":113,inherits:143,"safe-buffer":189}],145:[function(e,t,r){var i=e("bn.js"),n=e("brorand");function s(e){this.rand=e||new n.Rand}t.exports=s,s.create=function(e){return new s(e)},s.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var n=new i(this.rand.generate(r))}while(n.cmp(e)>=0);return n},s.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},s.prototype.test=function(e,t,r){var n=e.bitLength(),s=i.mont(e),o=new i(1).toRed(s);t||(t=Math.max(1,n/48|0));for(var a=e.subn(1),h=0;!a.testn(h);h++);for(var c=e.shrn(h),f=a.toRed(s);t>0;t--){var u=this._randrange(new i(2),a);r&&r(u);var l=u.toRed(s).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(f)){for(var d=1;d0;t--){var f=this._randrange(new i(2),o),u=e.gcd(f);if(0!==u.cmpn(1))return u;var l=f.toRed(n).redPow(h);if(0!==l.cmp(s)&&0!==l.cmp(c)){for(var d=1;d>8,o=255&n;s?r.push(s,o):r.push(o)}return r},i.zero2=n,i.toHex=s,i.encode=function(e,t){return"hex"===t?s(e):e}},{}],149:[function(e,t,r){(function(r){(function(){ /*! * RSA library for Node.js * * Author: rzcoder * License MIT */ var i=e("constants"),n=e("./libs/rsa.js"),s=(e("crypto"),e("asn1").Ber,e("./utils")._),o=e("./utils"),a=e("./schemes/schemes.js"),h=e("./formats/formats.js");void 0===i.RSA_NO_PADDING&&(i.RSA_NO_PADDING=3),t.exports=function(){var e={node10:["md4","md5","ripemd160","sha1","sha224","sha256","sha384","sha512"],node:["md4","md5","ripemd160","sha1","sha224","sha256","sha384","sha512"],iojs:["md4","md5","ripemd160","sha1","sha224","sha256","sha384","sha512"],browser:["md5","ripemd160","sha1","sha256","sha512"]},t="pkcs1_oaep",i="pkcs1",c={private:"pkcs1-private-pem","private-der":"pkcs1-private-der",public:"pkcs8-public-pem","public-der":"pkcs8-public-der"};function f(e,a,h){if(!(this instanceof f))return new f(e,a,h);s.isObject(a)&&(h=a,a=void 0),this.$options={signingScheme:i,signingSchemeOptions:{hash:"sha256",saltLength:null},encryptionScheme:t,encryptionSchemeOptions:{hash:"sha1",label:null},environment:o.detectEnvironment(),rsaUtils:this},this.keyPair=new n.Key,this.$cache={},r.isBuffer(e)||s.isString(e)?this.importKey(e,a):s.isObject(e)&&this.generateKeyPair(e.b,e.e),this.setOptions(h)}return f.prototype.setOptions=function(r){if((r=r||{}).environment&&(this.$options.environment=r.environment),r.signingScheme){if(s.isString(r.signingScheme)){var n=r.signingScheme.toLowerCase().split("-");1==n.length?e.node.indexOf(n[0])>-1?(this.$options.signingSchemeOptions={hash:n[0]},this.$options.signingScheme=i):(this.$options.signingScheme=n[0],this.$options.signingSchemeOptions={hash:null}):(this.$options.signingSchemeOptions={hash:n[1]},this.$options.signingScheme=n[0])}else s.isObject(r.signingScheme)&&(this.$options.signingScheme=r.signingScheme.scheme||i,this.$options.signingSchemeOptions=s.omit(r.signingScheme,"scheme"));if(!a.isSignature(this.$options.signingScheme))throw Error("Unsupported signing scheme");if(this.$options.signingSchemeOptions.hash&&-1===e[this.$options.environment].indexOf(this.$options.signingSchemeOptions.hash))throw Error("Unsupported hashing algorithm for "+this.$options.environment+" environment")}if(r.encryptionScheme){if(s.isString(r.encryptionScheme)?(this.$options.encryptionScheme=r.encryptionScheme.toLowerCase(),this.$options.encryptionSchemeOptions={}):s.isObject(r.encryptionScheme)&&(this.$options.encryptionScheme=r.encryptionScheme.scheme||t,this.$options.encryptionSchemeOptions=s.omit(r.encryptionScheme,"scheme")),!a.isEncryption(this.$options.encryptionScheme))throw Error("Unsupported encryption scheme");if(this.$options.encryptionSchemeOptions.hash&&-1===e[this.$options.environment].indexOf(this.$options.encryptionSchemeOptions.hash))throw Error("Unsupported hashing algorithm for "+this.$options.environment+" environment")}this.keyPair.setOptions(this.$options)},f.prototype.generateKeyPair=function(e,t){if(t=t||65537,(e=e||2048)%8!=0)throw Error("Key size must be a multiple of 8.");return this.keyPair.generate(e,t.toString(16)),this.$cache={},this},f.prototype.importKey=function(e,t){if(!e)throw Error("Empty key given");if(t&&(t=c[t]||t),!h.detectAndImport(this.keyPair,e,t)&&void 0===t)throw Error("Key format must be specified");return this.$cache={},this},f.prototype.exportKey=function(e){return e=c[e=e||"private"]||e,this.$cache[e]||(this.$cache[e]=h.detectAndExport(this.keyPair,e)),this.$cache[e]},f.prototype.isPrivate=function(){return this.keyPair.isPrivate()},f.prototype.isPublic=function(e){return this.keyPair.isPublic(e)},f.prototype.isEmpty=function(e){return!(this.keyPair.n||this.keyPair.e||this.keyPair.d)},f.prototype.encrypt=function(e,t,r){return this.$$encryptKey(!1,e,t,r)},f.prototype.decrypt=function(e,t){return this.$$decryptKey(!1,e,t)},f.prototype.encryptPrivate=function(e,t,r){return this.$$encryptKey(!0,e,t,r)},f.prototype.decryptPublic=function(e,t){return this.$$decryptKey(!0,e,t)},f.prototype.$$encryptKey=function(e,t,r,i){try{var n=this.keyPair.encrypt(this.$getDataForEncrypt(t,i),e);return"buffer"!=r&&r?n.toString(r):n}catch(e){throw Error("Error during encryption. Original error: "+e)}},f.prototype.$$decryptKey=function(e,t,i){try{t=s.isString(t)?r.from(t,"base64"):t;var n=this.keyPair.decrypt(t,e);if(null===n)throw Error("Key decrypt method returns null.");return this.$getDecryptedData(n,i)}catch(e){throw Error("Error during decryption (probably incorrect key). Original error: "+e)}},f.prototype.sign=function(e,t,r){if(!this.isPrivate())throw Error("This is not private key");var i=this.keyPair.sign(this.$getDataForEncrypt(e,r));return t&&"buffer"!=t&&(i=i.toString(t)),i},f.prototype.verify=function(e,t,r,i){if(!this.isPublic())throw Error("This is not public key");return i=i&&"buffer"!=i?i:null,this.keyPair.verify(this.$getDataForEncrypt(e,r),t,i)},f.prototype.getKeySize=function(){return this.keyPair.keySize},f.prototype.getMaxMessageSize=function(){return this.keyPair.maxMessageLength},f.prototype.$getDataForEncrypt=function(e,t){if(s.isString(e)||s.isNumber(e))return r.from(""+e,t||"utf8");if(r.isBuffer(e))return e;if(s.isObject(e))return r.from(JSON.stringify(e));throw Error("Unexpected data type")},f.prototype.$getDecryptedData=function(e,t){return"buffer"==(t=t||"buffer")?e:"json"==t?JSON.parse(e.toString()):e.toString(t)},f}()}).call(this)}).call(this,e("buffer").Buffer)},{"./formats/formats.js":155,"./libs/rsa.js":160,"./schemes/schemes.js":164,"./utils":165,asn1:21,buffer:72,constants:75,crypto:82}],150:[function(e,t,r){var i=e("crypto");t.exports={getEngine:function(t,r){var n=e("./js.js");return"node"===r.environment&&"function"==typeof i.publicEncrypt&&"function"==typeof i.privateDecrypt&&(n="function"==typeof i.privateEncrypt&&"function"==typeof i.publicDecrypt?e("./io.js"):e("./node12.js")),n(t,r)}}},{"./io.js":151,"./js.js":152,"./node12.js":153,crypto:82}],151:[function(e,t,r){var i=e("crypto"),n=e("constants"),s=e("../schemes/schemes.js");t.exports=function(e,t){var r=s.pkcs1.makeScheme(e,t);return{encrypt:function(e,s){var o;if(s)return o=n.RSA_PKCS1_PADDING,t.encryptionSchemeOptions&&t.encryptionSchemeOptions.padding&&(o=t.encryptionSchemeOptions.padding),i.privateEncrypt({key:t.rsaUtils.exportKey("private"),padding:o},e);o=n.RSA_PKCS1_OAEP_PADDING,"pkcs1"===t.encryptionScheme&&(o=n.RSA_PKCS1_PADDING),t.encryptionSchemeOptions&&t.encryptionSchemeOptions.padding&&(o=t.encryptionSchemeOptions.padding);var a=e;return o===n.RSA_NO_PADDING&&(a=r.pkcs0pad(e)),i.publicEncrypt({key:t.rsaUtils.exportKey("public"),padding:o},a)},decrypt:function(e,s){var o;if(s)return o=n.RSA_PKCS1_PADDING,t.encryptionSchemeOptions&&t.encryptionSchemeOptions.padding&&(o=t.encryptionSchemeOptions.padding),i.publicDecrypt({key:t.rsaUtils.exportKey("public"),padding:o},e);o=n.RSA_PKCS1_OAEP_PADDING,"pkcs1"===t.encryptionScheme&&(o=n.RSA_PKCS1_PADDING),t.encryptionSchemeOptions&&t.encryptionSchemeOptions.padding&&(o=t.encryptionSchemeOptions.padding);var a=i.privateDecrypt({key:t.rsaUtils.exportKey("private"),padding:o},e);return o===n.RSA_NO_PADDING?r.pkcs0unpad(a):a}}}},{"../schemes/schemes.js":164,constants:75,crypto:82}],152:[function(e,t,r){var i=e("../libs/jsbn.js"),n=e("../schemes/schemes.js");t.exports=function(e,t){var r=n.pkcs1.makeScheme(e,t);return{encrypt:function(t,n){var s,o;return n?(s=new i(r.encPad(t,{type:1})),o=e.$doPrivate(s)):(s=new i(e.encryptionScheme.encPad(t)),o=e.$doPublic(s)),o.toBuffer(e.encryptedDataLength)},decrypt:function(t,n){var s,o=new i(t);return n?(s=e.$doPublic(o),r.encUnPad(s.toBuffer(e.encryptedDataLength),{type:1})):(s=e.$doPrivate(o),e.encryptionScheme.encUnPad(s.toBuffer(e.encryptedDataLength)))}}}},{"../libs/jsbn.js":159,"../schemes/schemes.js":164}],153:[function(e,t,r){var i=e("crypto"),n=e("constants"),s=e("../schemes/schemes.js");t.exports=function(t,r){var o=e("./js.js")(t,r),a=s.pkcs1.makeScheme(t,r);return{encrypt:function(e,t){if(t)return o.encrypt(e,t);var s=n.RSA_PKCS1_OAEP_PADDING;"pkcs1"===r.encryptionScheme&&(s=n.RSA_PKCS1_PADDING),r.encryptionSchemeOptions&&r.encryptionSchemeOptions.padding&&(s=r.encryptionSchemeOptions.padding);var h=e;return s===n.RSA_NO_PADDING&&(h=a.pkcs0pad(e)),i.publicEncrypt({key:r.rsaUtils.exportKey("public"),padding:s},h)},decrypt:function(e,t){if(t)return o.decrypt(e,t);var s=n.RSA_PKCS1_OAEP_PADDING;"pkcs1"===r.encryptionScheme&&(s=n.RSA_PKCS1_PADDING),r.encryptionSchemeOptions&&r.encryptionSchemeOptions.padding&&(s=r.encryptionSchemeOptions.padding);var h=i.privateDecrypt({key:r.rsaUtils.exportKey("private"),padding:s},e);return s===n.RSA_NO_PADDING?a.pkcs0unpad(h):h}}}},{"../schemes/schemes.js":164,"./js.js":152,constants:75,crypto:82}],154:[function(e,t,r){e("../utils")._,e("../utils");t.exports={privateExport:function(e,t){return{n:e.n.toBuffer(),e:e.e,d:e.d.toBuffer(),p:e.p.toBuffer(),q:e.q.toBuffer(),dmp1:e.dmp1.toBuffer(),dmq1:e.dmq1.toBuffer(),coeff:e.coeff.toBuffer()}},privateImport:function(e,t,r){if(!(t.n&&t.e&&t.d&&t.p&&t.q&&t.dmp1&&t.dmq1&&t.coeff))throw Error("Invalid key data");e.setPrivate(t.n,t.e,t.d,t.p,t.q,t.dmp1,t.dmq1,t.coeff)},publicExport:function(e,t){return{n:e.n.toBuffer(),e:e.e}},publicImport:function(e,t,r){if(!t.n||!t.e)throw Error("Invalid key data");e.setPublic(t.n,t.e)},autoImport:function(e,r){return!(!r.n||!r.e)&&(r.d&&r.p&&r.q&&r.dmp1&&r.dmq1&&r.coeff?(t.exports.privateImport(e,r),!0):(t.exports.publicImport(e,r),!0))}}},{"../utils":165}],155:[function(e,t,r){e("../utils")._;function i(e){e=e.split("-");for(var t="private",r={type:"default"},i=1;i>14;--s>=0;){var h=16383&this[e],c=this[e++]>>14,f=a*h+c*o;n=((h=o*h+((16383&f)<<14)+r[i]+n)>>28)+(f>>14)+a*c,r[i++]=268435455&h}return n},s.prototype.DB=28,s.prototype.DM=268435455,s.prototype.DV=1<<28;s.prototype.FV=Math.pow(2,52),s.prototype.F1=24,s.prototype.F2=4;var a,h,c="0123456789abcdefghijklmnopqrstuvwxyz",f=new Array;for(a="0".charCodeAt(0),h=0;h<=9;++h)f[a++]=h;for(a="a".charCodeAt(0),h=10;h<36;++h)f[a++]=h;for(a="A".charCodeAt(0),h=10;h<36;++h)f[a++]=h;function u(e){return c.charAt(e)}function l(e,t){var r=f[e.charCodeAt(t)];return null==r?-1:r}function d(e){var t=o();return t.fromInt(e),t}function p(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 m(e){this.m=e}function b(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=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 w(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function E(){}function M(e){return e}function O(e){this.r2=o(),this.q3=o(),s.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}m.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},m.prototype.revert=function(e){return e},m.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},m.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},m.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},b.prototype.convert=function(e){var t=o();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(s.ZERO)>0&&this.m.subTo(t,t),t},b.prototype.revert=function(e){var t=o();return e.copyTo(t),this.reduce(t),t},b.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,i,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},b.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},b.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},E.prototype.convert=M,E.prototype.revert=M,E.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},E.prototype.sqrTo=function(e,t){e.squareTo(t)},O.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=o();return e.copyTo(t),this.reduce(t),t},O.prototype.revert=function(e){return e},O.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)},O.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},O.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var k=[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,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],N=(1<<26)/k[k.length-1];s.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},s.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+DV:this.t=0},s.prototype.fromString=function(e,t,r){var i;switch(t){case 2:i=1;break;case 4:i=2;break;case 8:i=3;break;case 16:i=4;break;case 32:i=5;break;case 256:i=8;break;default:return void this.fromRadix(e,t)}this.t=0,this.s=0;for(var n=e.length,o=!1,a=0;--n>=0;){var h=8==i?255&e[n]:l(e,n);h<0?"-"==e.charAt(n)&&(o=!0):(o=!1,0===a?this[this.t++]=h:a+i>this.DB?(this[this.t-1]|=(h&(1<>this.DB-a):this[this.t-1]|=h<=this.DB&&(a-=this.DB))}r||8!=i||0==(128&e[0])||(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},s.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},s.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+o+1]=this[r]>>n|a,a=(this[r]&s)<=0;--r)t[r]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},s.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 i=e%this.DB,n=this.DB-i,s=(1<>i;for(var o=r+1;o>i;i>0&&(t[this.t-r-1]|=(this.s&s)<>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i-=e.s}t.s=i<0?-1:0,i<-1?t[r++]=this.DV+i:i>0&&(t[r++]=i),t.t=r,t.clamp()},s.prototype.multiplyTo=function(e,t){var r=this.abs(),i=e.abs(),n=r.t;for(t.t=n+i.t;--n>=0;)t[n]=0;for(n=0;n=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},s.prototype.divRemTo=function(e,t,r){var i=e.abs();if(!(i.t<=0)){var n=this.abs();if(n.t0?(i.lShiftTo(f,a),n.lShiftTo(f,r)):(i.copyTo(a),n.copyTo(r));var u=a.t,l=a[u-1];if(0!==l){var d=l*(1<1?a[u-2]>>this.F2:0),m=this.FV/d,b=(1<=0&&(r[r.t++]=1,r.subTo(_,r)),s.ONE.dlShiftTo(u,_),_.subTo(a,a);a.t=0;){var v=r[--y]==l?this.DM:Math.floor(r[y]*m+(r[y-1]+g)*b);if((r[y]+=a.am(0,v,r,S,0,u))0&&r.rShiftTo(f,r),h<0&&s.ZERO.subTo(r,r)}}},s.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[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},s.prototype.isEven=function(){return 0===(this.t>0?1&this[0]:this.s)},s.prototype.exp=function(e,t){if(e>4294967295||e<1)return s.ONE;var r=o(),i=o(),n=t.convert(this),a=p(e)-1;for(n.copyTo(r);--a>=0;)if(t.sqrTo(r,i),(e&1<0)t.mulTo(i,n,r);else{var h=r;r=i,i=h}return t.revert(r)},s.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},s.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),i=d(r),n=o(),s=o(),a="";for(this.divRemTo(i,n,s);n.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,n.divRemTo(i,n,s);return s.intValue().toString(e)+a},s.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),i=Math.pow(t,r),n=!1,o=0,a=0,h=0;h=r&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(a,0)),n&&s.ZERO.subTo(this,this)},s.prototype.fromNumber=function(e,t){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e),this.testBit(e-1)||this.bitwiseTo(s.ONE.shiftLeft(e-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(s.ONE.shiftLeft(e-1),this);else{var r=i.randomBytes(1+(e>>3)),n=7&e;n>0?r[0]&=(1<>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i+=e.s}t.s=i<0?-1:0,i>0?t[r++]=i:i<-1&&(t[r++]=this.DV+i),t.t=r,t.clamp()},s.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},s.prototype.dAddOffset=function(e,t){if(0!==e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},s.prototype.multiplyLowerTo=function(e,t,r){var i,n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(i=r.t-this.t;n=0;)r[i]=0;for(i=Math.max(t-this.t,0);i0)if(0===t)r=this[0]%e;else for(var i=this.t-1;i>=0;--i)r=(t*r+this[i])%e;return r},s.prototype.millerRabin=function(e){var t=this.subtract(s.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var i=t.shiftRight(r);(e=e+1>>1)>k.length&&(e=k.length);for(var n=o(),a=0;a0)for(a>a)>0&&(n=!0,s=u(r));o>=0;)a>(a+=this.DB-t)):(r=this[o]>>(a-=t)&i,a<=0&&(a+=this.DB,--o)),r>0&&(n=!0),n&&(s+=u(r));return n?s:"0"},s.prototype.negate=function(){var e=o();return s.ZERO.subTo(this,e),e},s.prototype.abs=function(){return this.s<0?this.negate():this},s.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[r]-e[r]))return t;return 0},s.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this[this.t-1]^this.s&this.DM)},s.prototype.mod=function(e){var t=o();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(s.ZERO)>0&&e.subTo(t,t),t},s.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new m(t):new b(t),this.exp(e,r)} // See "LICENSE" for details. ,s.prototype.clone=function(){var e=o();return this.copyTo(e),e},s.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0===this.t)return-1}else{if(1==this.t)return this[0];if(0===this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24},s.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},s.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},s.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,i=this.DB-e*this.DB%8,n=0;if(e-- >0)for(i>i)!=(this.s&this.DM)>>i&&(t[n++]=r|this.s<=0;)i<8?(r=(this[e]&(1<>(i+=this.DB-8)):(r=this[e]>>(i-=8)&255,i<=0&&(i+=this.DB,--e)),0!=(128&r)&&(r|=-256),0===n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t},s.prototype.toBuffer=function(e){var t=r.from(this.toByteArray());if(!0===e&&0===t[0])t=t.slice(1);else if(n.isNumber(e)){if(t.length>e){for(var i=0;i0?this:e},s.prototype.and=function(e){var t=o();return this.bitwiseTo(e,g,t),t},s.prototype.or=function(e){var t=o();return this.bitwiseTo(e,y,t),t},s.prototype.xor=function(e){var t=o();return this.bitwiseTo(e,S,t),t},s.prototype.andNot=function(e){var t=o();return this.bitwiseTo(e,_,t),t},s.prototype.not=function(){for(var e=o(),t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var u=o();for(i.sqrTo(a[1],u);h<=f;)a[h]=o(),i.mulTo(u,a[h-2],a[h]),h+=2}var l,g,y=e.t-1,S=!0,_=o();for(n=p(e[y])-1;y>=0;){for(n>=c?l=e[y]>>n-c&f:(l=(e[y]&(1<0&&(l|=e[y-1]>>this.DB+n-c)),h=r;0==(1&l);)l>>=1,--h;if((n-=h)<0&&(n+=this.DB,--y),S)a[l].copyTo(s),S=!1;else{for(;h>1;)i.sqrTo(s,_),i.sqrTo(_,s),h-=2;h>0?i.sqrTo(s,_):(g=s,s=_,_=g),i.mulTo(_,a[l],s)}for(;y>=0&&0==(e[y]&1<=0?(r.subTo(i,r),t&&n.subTo(a,n),o.subTo(h,o)):(i.subTo(r,i),t&&a.subTo(n,a),h.subTo(o,h))}return 0!=i.compareTo(s.ONE)?s.ZERO:h.compareTo(e)>=0?h.subtract(e):h.signum()<0?(h.addTo(e,h),h.signum()<0?h.add(e):h):h},s.prototype.pow=function(e){return this.exp(e,new E)},s.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 i=t;t=r,r=i}var n=t.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return t;for(n0&&(t.rShiftTo(s,t),r.rShiftTo(s,r));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},s.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(t=0;t>1;this.e=parseInt(t,16);for(var i=new s(t,16);;){for(;this.p=new s(e-r,1),0!==this.p.subtract(s.ONE).gcd(i).compareTo(s.ONE)||!this.p.isProbablePrime(10););for(;this.q=new s(r,1),0!==this.q.subtract(s.ONE).gcd(i).compareTo(s.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var n=this.p;this.p=this.q,this.q=n}var o=this.p.subtract(s.ONE),a=this.q.subtract(s.ONE),h=o.multiply(a);if(0===h.gcd(i).compareTo(s.ONE)){if(this.n=this.p.multiply(this.q),this.n.bitLength()0&&(n.isNumber(t)||t.length>0)&&r.length>0))throw Error("Invalid RSA private key");this.n=new s(e),this.e=n.isNumber(t)?t:o.get32IntFromBuffer(t,0),this.d=new s(r),i&&a&&h&&c&&f&&(this.p=new s(i),this.q=new s(a),this.dmp1=new s(h),this.dmq1=new s(c),this.coeff=new s(f)),this.$$recalculateCache()},e.prototype.setPublic=function(e,t){if(!(e&&t&&e.length>0&&(n.isNumber(t)||t.length>0)))throw Error("Invalid RSA public key");this.n=new s(e),this.e=n.isNumber(t)?t:o.get32IntFromBuffer(t,0),this.$$recalculateCache()},e.prototype.$doPrivate=function(e){if(this.p||this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),r=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(r)<0;)t=t.add(this.p);return t.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)},e.prototype.$doPublic=function(e){return e.modPowInt(this.e,this.n)},e.prototype.encrypt=function(e,t){var r=[],n=[],s=e.length,o=Math.ceil(s/this.maxMessageLength)||1,a=Math.ceil(s/o||1);if(1==o)r.push(e);else for(var h=0;h0)throw Error("Incorrect data or key");for(var r=[],n=0,s=0,o=e.length/this.encryptedDataLength,a=0;a>3},e}()}).call(this)}).call(this,e("buffer").Buffer)},{"../encryptEngines/encryptEngines.js":150,"../schemes/schemes.js":164,"../utils":165,"../utils.js":165,"./jsbn.js":159,buffer:72,crypto:82}],161:[function(e,t,r){(function(r){(function(){e("../libs/jsbn");var i=e("crypto");t.exports={isEncryption:!0,isSignature:!1},t.exports.digestLength={md4:16,md5:16,ripemd160:20,rmd160:20,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64};t.exports.eme_oaep_mgf1=function(e,n,s){s=s||"sha1";for(var o=t.exports.digestLength[s],a=Math.ceil(n/o),h=r.alloc(o*a),c=r.alloc(4),f=0;fa-2*h-2)throw new Error("Message is too long to encode into an encoded message with a length of "+a+" bytes, increaseemLen to fix this error (minimum value for given parameters and options: "+(a-2*h-2)+")");var c=i.createHash(n);c.update(o),c=c.digest();var f=r.alloc(a-e.length-2*h-1);f.fill(0),f[f.length-1]=1;for(var u=r.concat([c,f,e]),l=i.randomBytes(h),d=s(l,u.length,n),p=0;pthis.key.maxMessageLength)throw new Error("Message too long for RSA (n="+this.key.encryptedDataLength+", l="+e.length+")");if(this.options.encryptionSchemeOptions&&this.options.encryptionSchemeOptions.padding==s.RSA_NO_PADDING)return(i=r.alloc(this.key.maxMessageLength-e.length)).fill(0),r.concat([i,e]);if(1===t.type)return(i=r.alloc(this.key.encryptedDataLength-e.length-1)).fill(255,0,i.length-1),i[0]=1,i[i.length-1]=0,r.concat([i,e]);(i=r.alloc(this.key.encryptedDataLength-e.length))[0]=0,i[1]=2;for(var o=n.randomBytes(i.length-3),a=0;a=e.length)return null}else{if(0!==e[0]||2!==e[1])return null;for(r=3;0!==e[r];)if(++r>=e.length)return null}return e.slice(r+1,e.length)},h.prototype.sign=function(e){var t=this.options.signingSchemeOptions.hash||"sha256";if("browser"===this.options.environment){t=a[t]||t;var r=n.createHash(t);r.update(e);var s=this.pkcs1pad(r.digest(),t);return this.key.$doPrivate(new i(s)).toBuffer(this.key.encryptedDataLength)}var o=n.createSign("RSA-"+t.toUpperCase());return o.update(e),o.sign(this.options.rsaUtils.exportKey("private"))},h.prototype.verify=function(e,t,o){if(this.options.encryptionSchemeOptions&&this.options.encryptionSchemeOptions.padding==s.RSA_NO_PADDING)return!1;var h=this.options.signingSchemeOptions.hash||"sha256";if("browser"===this.options.environment){h=a[h]||h,o&&(t=r.from(t,o));var c=n.createHash(h);c.update(e);var f=this.pkcs1pad(c.digest(),h);return this.key.$doPublic(new i(t)).toBuffer().toString("hex")==f.toString("hex")}var u=n.createVerify("RSA-"+h.toUpperCase());return u.update(e),u.verify(this.options.rsaUtils.exportKey("public"),t,o)},h.prototype.pkcs0pad=function(e){var t=r.alloc(this.key.maxMessageLength-e.length);return t.fill(0),r.concat([t,e])},h.prototype.pkcs0unpad=function(e){return"function"==typeof e.lastIndexOf?e.slice(e.lastIndexOf("\0")+1,e.length):e.slice(String.prototype.lastIndexOf.call(e,"\0")+1,e.length)},h.prototype.pkcs1pad=function(e,t){var i=o[t];if(!i)throw Error("Unsupported hash algorithm");var n=r.concat([i,e]);if(n.length+10>this.key.encryptedDataLength)throw Error("Key is too short for signing algorithm ("+t+")");var s=r.alloc(this.key.encryptedDataLength-n.length-1);return s.fill(255,0,s.length-1),s[0]=1,s[s.length-1]=0,r.concat([s,n])},new h(e,t)}}).call(this)}).call(this,e("buffer").Buffer)},{"../libs/jsbn":159,buffer:72,constants:75,crypto:82}],163:[function(e,t,r){(function(r){(function(){var i=e("../libs/jsbn"),n=e("crypto");t.exports={isEncryption:!1,isSignature:!0};t.exports.makeScheme=function(t,s){var o=e("./schemes").pkcs1_oaep;function a(e,t){this.key=e,this.options=t}return a.prototype.sign=function(e){var t=n.createHash(this.options.signingSchemeOptions.hash||"sha1");t.update(e);var r=this.emsa_pss_encode(t.digest(),this.key.keySize-1);return this.key.$doPrivate(new i(r)).toBuffer(this.key.encryptedDataLength)},a.prototype.verify=function(e,t,s){s&&(t=r.from(t,s)),t=new i(t);var o=Math.ceil((this.key.keySize-1)/8),a=this.key.$doPublic(t).toBuffer(o),h=n.createHash(this.options.signingSchemeOptions.hash||"sha1");return h.update(e),this.emsa_pss_verify(h.digest(),a,this.key.keySize-1)},a.prototype.emsa_pss_encode=function(e,t){var i=this.options.signingSchemeOptions.hash||"sha1",s=this.options.signingSchemeOptions.mgf||o.eme_oaep_mgf1,a=this.options.signingSchemeOptions.saltLength||20,h=o.digestLength[i],c=Math.ceil(t/8);if(c>8-y<<8-y;b[0]=b[0]&S;var _=r.alloc(b.length+l.length+1);return b.copy(_,0),l.copy(_,b.length),_[_.length-1]=188,_},a.prototype.emsa_pss_verify=function(e,t,i){var s=this.options.signingSchemeOptions.hash||"sha1",a=this.options.signingSchemeOptions.mgf||o.eme_oaep_mgf1,h=this.options.signingSchemeOptions.saltLength||20,c=o.digestLength[s],f=Math.ceil(i/8);if(f>8-(p=8*f-i)<<8-p,u[0]=u[0]&l,d=0;0===u[d]&&d0){if(r>=4)return e.readUIntBE(t,r);for(var i=0,n=t+r,s=0;n>t;n--,s+=2)i+=e[n-1]*Math.pow(16,s);return i}return NaN},t.exports._={isObject:function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)},isString:function(e){return"string"==typeof e||e instanceof String},isNumber:function(e){return"number"==typeof e||!isNaN(parseFloat(e))&&isFinite(e)},omit:function(e,t){var r={};for(var i in e)e.hasOwnProperty(i)&&i!==t&&(r[i]=e[i]);return r}},t.exports.trimSurroundingText=function(e,t,r){var i=0,n=e.length,s=e.indexOf(t);s>=0&&(i=s+t.length);var o=e.indexOf(r,s);return o>=0&&(n=o),e.substring(i,n)}}).call(this)}).call(this,e("_process"))},{_process:178,crypto:82}],166:[function(e,t,r){ /* object-assign (c) Sindre Sorhus @license MIT */ "use strict";var i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(e){i[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,o,a=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),h=1;h=6?"utf-8":"binary"}else i="utf-8";t.exports=i}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:178}],175:[function(e,t,r){var i=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>i||t!=t)throw new TypeError("Bad key length")}},{}],176:[function(e,t,r){var i=e("create-hash/md5"),n=e("ripemd160"),s=e("sha.js"),o=e("safe-buffer").Buffer,a=e("./precondition"),h=e("./default-encoding"),c=e("./to-buffer"),f=o.alloc(128),u={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function l(e,t,r){var a=function(e){return"rmd160"===e||"ripemd160"===e?function(e){return(new n).update(e).digest()}:"md5"===e?i:function(t){return s(e).update(t).digest()}}(e),h="sha512"===e||"sha384"===e?128:64;t.length>h?t=a(t):t.length1)for(var r=1;rp||new o(t).cmp(d.modulus)>=0)throw new Error("decryption error");l=r?c(new o(t),d):a(t,d);var m=f.alloc(p-l.length);if(l=f.concat([m,l],p),4===u)return function(e,t){var r=e.modulus.byteLength(),i=h("sha1").update(f.alloc(0)).digest(),o=i.length;if(0!==t[0])throw new Error("decryption error");var a=t.slice(1,o+1),c=t.slice(o+1),u=s(a,n(c,o)),l=s(c,n(u,r-o-1));if(function(e,t){e=f.from(e),t=f.from(t);var r=0,i=e.length;e.length!==t.length&&(r++,i=Math.min(e.length,t.length));var n=-1;for(;++n=t.length){s++;break}var o=t.slice(2,n-1);("0002"!==i.toString("hex")&&!r||"0001"!==i.toString("hex")&&r)&&s++;o.length<8&&s++;if(s)throw new Error("decryption error");return t.slice(n)}(0,l,r);if(3===u)return l;throw new Error("unknown padding")}},{"./mgf":180,"./withPublic":184,"./xor":185,"bn.js":181,"browserify-rsa":46,"create-hash":78,"parse-asn1":171,"safe-buffer":189}],183:[function(e,t,r){var i=e("parse-asn1"),n=e("randombytes"),s=e("create-hash"),o=e("./mgf"),a=e("./xor"),h=e("bn.js"),c=e("./withPublic"),f=e("browserify-rsa"),u=e("safe-buffer").Buffer;t.exports=function(e,t,r){var l;l=e.padding?e.padding:r?1:4;var d,p=i(e);if(4===l)d=function(e,t){var r=e.modulus.byteLength(),i=t.length,c=s("sha1").update(u.alloc(0)).digest(),f=c.length,l=2*f;if(i>r-l-2)throw new Error("message too long");var d=u.alloc(r-i-l-2),p=r-f-1,m=n(f),b=a(u.concat([c,d,u.alloc(1,1),t],p),o(m,p)),g=a(m,o(b,f));return new h(u.concat([u.alloc(1),g,b],r))}(p,t);else if(1===l)d=function(e,t,r){var i,s=t.length,o=e.modulus.byteLength();if(s>o-11)throw new Error("message too long");i=r?u.alloc(o-s-3,255):function(e){var t,r=u.allocUnsafe(e),i=0,s=n(2*e),o=0;for(;i=0)throw new Error("data too long for modulus")}return r?f(d,p):c(d,p)}},{"./mgf":180,"./withPublic":184,"./xor":185,"bn.js":181,"browserify-rsa":46,"create-hash":78,"parse-asn1":171,randombytes:186,"safe-buffer":189}],184:[function(e,t,r){var i=e("bn.js"),n=e("safe-buffer").Buffer;t.exports=function(e,t){return n.from(e.toRed(i.mont(t.modulus)).redPow(new i(t.publicExponent)).fromRed().toArray())}},{"bn.js":181,"safe-buffer":189}],185:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,i=-1;++is)throw new RangeError("requested too many random bytes");var i=o.allocUnsafe(e);if(e>0)if(e>n)for(var h=0;hf||e<0)throw new TypeError("offset must be a uint32");if(e>h||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>h)throw new RangeError("buffer too small")}function d(e,r,i,n){if(t.browser){var s=e.buffer,a=new Uint8Array(s,r,i);return c.getRandomValues(a),n?void t.nextTick(function(){n(null,e)}):e}if(!n)return o(i).copy(e,r),e;o(i,function(t,i){if(t)return n(t);i.copy(e,r),n(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,n){if(!(a.isBuffer(e)||e instanceof i.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)n=t,t=0,r=e.length;else if("function"==typeof r)n=r,r=e.length-t;else if("function"!=typeof n)throw new TypeError('"cb" argument must be a function');return u(t,e.length),l(r,t,e.length),d(e,t,r,n)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(a.isBuffer(e)||e instanceof i.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');u(t,e.length),void 0===r&&(r=e.length-t);return l(r,t,e.length),d(e,t,r)}):(r.randomFill=n,r.randomFillSync=n)}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:178,randombytes:186,"safe-buffer":189}],188:[function(e,t,r){"use strict";var i=e("buffer").Buffer,n=e("inherits"),s=e("hash-base"),o=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],h=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],u=[0,1518500249,1859775393,2400959708,2840853838],l=[1352829926,1548603684,1836072691,2053994217,0];function d(){s.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function p(e,t){return e<>>32-t}function m(e,t,r,i,n,s,o,a){return p(e+(t^r^i)+s+o|0,a)+n|0}function b(e,t,r,i,n,s,o,a){return p(e+(t&r|~t&i)+s+o|0,a)+n|0}function g(e,t,r,i,n,s,o,a){return p(e+((t|~r)^i)+s+o|0,a)+n|0}function y(e,t,r,i,n,s,o,a){return p(e+(t&i|r&~i)+s+o|0,a)+n|0}function S(e,t,r,i,n,s,o,a){return p(e+(t^(r|~i))+s+o|0,a)+n|0}n(d,s),d.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,i=0|this._b,n=0|this._c,s=0|this._d,d=0|this._e,_=0|this._a,v=0|this._b,w=0|this._c,E=0|this._d,M=0|this._e,O=0;O<80;O+=1){var k,N;O<16?(k=m(r,i,n,s,d,e[a[O]],u[0],c[O]),N=S(_,v,w,E,M,e[h[O]],l[0],f[O])):O<32?(k=b(r,i,n,s,d,e[a[O]],u[1],c[O]),N=y(_,v,w,E,M,e[h[O]],l[1],f[O])):O<48?(k=g(r,i,n,s,d,e[a[O]],u[2],c[O]),N=g(_,v,w,E,M,e[h[O]],l[2],f[O])):O<64?(k=y(r,i,n,s,d,e[a[O]],u[3],c[O]),N=b(_,v,w,E,M,e[h[O]],l[3],f[O])):(k=S(r,i,n,s,d,e[a[O]],u[4],c[O]),N=m(_,v,w,E,M,e[h[O]],l[4],f[O])),r=d,d=s,s=p(n,10),n=i,i=k,_=M,M=E,E=p(w,10),w=v,v=N}var T=this._b+n+E|0;this._b=this._c+s+M|0,this._c=this._d+d+_|0,this._d=this._e+r+v|0,this._e=this._a+i+w|0,this._a=T},d.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=i.alloc?i.alloc(20):new i(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=d},{buffer:72,"hash-base":113,inherits:143}],189:[function(e,t,r){/*! safe-buffer. MIT License. Feross Aboukhadijeh */var i=e("buffer"),n=i.Buffer;function s(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(s(i,r),r.Buffer=o),o.prototype=Object.create(n.prototype),s(n,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},{buffer:72}],190:[function(e,t,r){(function(r){(function(){"use strict";var i,n=e("buffer"),s=n.Buffer,o={};for(i in n)n.hasOwnProperty(i)&&"SlowBuffer"!==i&&"Buffer"!==i&&(o[i]=n[i]);var a=o.Buffer={};for(i in s)s.hasOwnProperty(i)&&"allocUnsafe"!==i&&"allocUnsafeSlow"!==i&&(a[i]=s[i]);if(o.Buffer.prototype=s.prototype,a.from&&a.from!==Uint8Array.from||(a.from=function(e,t,r){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return s(e,t,r)}),a.alloc||(a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var i=s(e);return t&&0!==t.length?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i}),!o.kStringMaxLength)try{o.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(e){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),t.exports=o}).call(this)}).call(this,e("_process"))},{_process:178,buffer:72}],191:[function(e,t,r){var i=e("safe-buffer").Buffer;function n(e,t){this._block=i.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}n.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=i.from(e,t));for(var r=this._block,n=this._blockSize,s=e.length,o=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(4294967295&r)>>>0,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=n},{"safe-buffer":189}],192:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":193,"./sha1":194,"./sha224":195,"./sha256":196,"./sha384":197,"./sha512":198}],193:[function(e,t,r){var i=e("inherits"),n=e("./hash"),s=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function h(){this.init(),this._w=a,n.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,i){return 0===e?t&r|~t&i:2===e?t&r|t&i|r&i:t^r^i}i(h,n),h.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},h.prototype._update=function(e){for(var t,r=this._w,i=0|this._a,n=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,u=0;u<16;++u)r[u]=e.readInt32BE(4*u);for(;u<80;++u)r[u]=r[u-3]^r[u-8]^r[u-14]^r[u-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=i)<<5|t>>>27)+f(d,n,s,a)+h+r[l]+o[d];h=a,a=s,s=c(n),n=i,i=p}this._a=i+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},h.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=h},{"./hash":191,inherits:143,"safe-buffer":189}],194:[function(e,t,r){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined * in FIPS PUB 180-1 * Version 2.1a Copyright Paul Johnston 2000 - 2002. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for details. */ var i=e("inherits"),n=e("./hash"),s=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function h(){this.init(),this._w=a,n.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function u(e,t,r,i){return 0===e?t&r|~t&i:2===e?t&r|t&i|r&i:t^r^i}i(h,n),h.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},h.prototype._update=function(e){for(var t,r=this._w,i=0|this._a,n=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),m=c(i)+u(p,n,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=f(n),n=i,i=m}this._a=i+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},h.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=h},{"./hash":191,inherits:143,"safe-buffer":189}],195:[function(e,t,r){var i=e("inherits"),n=e("./sha256"),s=e("./hash"),o=e("safe-buffer").Buffer,a=new Array(64);function h(){this.init(),this._w=a,s.call(this,64,56)}i(h,n),h.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},h.prototype._hash=function(){var e=o.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=h},{"./hash":191,"./sha256":196,inherits:143,"safe-buffer":189}],196:[function(e,t,r){var i=e("inherits"),n=e("./hash"),s=e("safe-buffer").Buffer,o=[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],a=new Array(64);function h(){this.init(),this._w=a,n.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function u(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}i(h,n),h.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},h.prototype._update=function(e){for(var t,r=this._w,i=0|this._a,n=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,p=0|this._f,m=0|this._g,b=0|this._h,g=0;g<16;++g)r[g]=e.readInt32BE(4*g);for(;g<64;++g)r[g]=0|(((t=r[g-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[g-7]+d(r[g-15])+r[g-16];for(var y=0;y<64;++y){var S=b+l(h)+c(h,p,m)+o[y]+r[y]|0,_=u(i)+f(i,n,s)|0;b=m,m=p,p=h,h=a+S|0,a=s,s=n,n=i,i=S+_|0}this._a=i+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0,this._f=p+this._f|0,this._g=m+this._g|0,this._h=b+this._h|0},h.prototype._hash=function(){var e=s.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=h},{"./hash":191,inherits:143,"safe-buffer":189}],197:[function(e,t,r){var i=e("inherits"),n=e("./sha512"),s=e("./hash"),o=e("safe-buffer").Buffer,a=new Array(160);function h(){this.init(),this._w=a,s.call(this,128,112)}i(h,n),h.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},h.prototype._hash=function(){var e=o.allocUnsafe(48);function t(t,r,i){e.writeInt32BE(t,i),e.writeInt32BE(r,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=h},{"./hash":191,"./sha512":198,inherits:143,"safe-buffer":189}],198:[function(e,t,r){var i=e("inherits"),n=e("./hash"),s=e("safe-buffer").Buffer,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=new Array(160);function h(){this.init(),this._w=a,n.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function u(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function m(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function g(e,t){return e>>>0>>0?1:0}i(h,n),h.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},h.prototype._update=function(e){for(var t=this._w,r=0|this._ah,i=0|this._bh,n=0|this._ch,s=0|this._dh,a=0|this._eh,h=0|this._fh,y=0|this._gh,S=0|this._hh,_=0|this._al,v=0|this._bl,w=0|this._cl,E=0|this._dl,M=0|this._el,O=0|this._fl,k=0|this._gl,N=0|this._hl,T=0;T<32;T+=2)t[T]=e.readInt32BE(4*T),t[T+1]=e.readInt32BE(4*T+4);for(;T<160;T+=2){var C=t[T-30],x=t[T-30+1],A=d(C,x),D=p(x,C),I=m(C=t[T-4],x=t[T-4+1]),R=b(x,C),B=t[T-14],P=t[T-14+1],F=t[T-32],L=t[T-32+1],Y=D+P|0,U=A+B+g(Y,D)|0;U=(U=U+I+g(Y=Y+R|0,R)|0)+F+g(Y=Y+L|0,L)|0,t[T]=U,t[T+1]=Y}for(var j=0;j<160;j+=2){U=t[j],Y=t[j+1];var W=f(r,i,n),z=f(_,v,w),q=u(r,_),H=u(_,r),V=l(a,M),G=l(M,a),K=o[j],$=o[j+1],X=c(a,h,y),Z=c(M,O,k),J=N+G|0,Q=S+V+g(J,N)|0;Q=(Q=(Q=Q+X+g(J=J+Z|0,Z)|0)+K+g(J=J+$|0,$)|0)+U+g(J=J+Y|0,Y)|0;var ee=H+z|0,te=q+W+g(ee,H)|0;S=y,N=k,y=h,k=O,h=a,O=M,a=s+Q+g(M=E+J|0,E)|0,s=n,E=w,n=i,w=v,i=r,v=_,r=Q+te+g(_=J+ee|0,J)|0}this._al=this._al+_|0,this._bl=this._bl+v|0,this._cl=this._cl+w|0,this._dl=this._dl+E|0,this._el=this._el+M|0,this._fl=this._fl+O|0,this._gl=this._gl+k|0,this._hl=this._hl+N|0,this._ah=this._ah+r+g(this._al,_)|0,this._bh=this._bh+i+g(this._bl,v)|0,this._ch=this._ch+n+g(this._cl,w)|0,this._dh=this._dh+s+g(this._dl,E)|0,this._eh=this._eh+a+g(this._el,M)|0,this._fh=this._fh+h+g(this._fl,O)|0,this._gh=this._gh+y+g(this._gl,k)|0,this._hh=this._hh+S+g(this._hl,N)|0},h.prototype._hash=function(){var e=s.allocUnsafe(64);function t(t,r,i){e.writeInt32BE(t,i),e.writeInt32BE(r,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=h},{"./hash":191,inherits:143,"safe-buffer":189}],199:[function(e,t,r){ // distribute, sublicense, and/or sell copies of the Software, and to permit t.exports=n;var i=e("events").EventEmitter;function n(){i.call(this)}e("inherits")(n,i),n.Readable=e("readable-stream/lib/_stream_readable.js"),n.Writable=e("readable-stream/lib/_stream_writable.js"),n.Duplex=e("readable-stream/lib/_stream_duplex.js"),n.Transform=e("readable-stream/lib/_stream_transform.js"),n.PassThrough=e("readable-stream/lib/_stream_passthrough.js"),n.finished=e("readable-stream/lib/internal/streams/end-of-stream.js"),n.pipeline=e("readable-stream/lib/internal/streams/pipeline.js"),n.Stream=n,n.prototype.pipe=function(e,t){var r=this;function n(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on("data",n),e.on("drain",s),e._isStdio||t&&!1===t.end||(r.on("end",a),r.on("close",h));var o=!1;function a(){o||(o=!0,e.end())}function h(){o||(o=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===i.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",n),e.removeListener("drain",s),r.removeListener("end",a),r.removeListener("close",h),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},{events:111,inherits:143,"readable-stream/lib/_stream_duplex.js":201,"readable-stream/lib/_stream_passthrough.js":202,"readable-stream/lib/_stream_readable.js":203,"readable-stream/lib/_stream_transform.js":204,"readable-stream/lib/_stream_writable.js":205,"readable-stream/lib/internal/streams/end-of-stream.js":209,"readable-stream/lib/internal/streams/pipeline.js":211}],200:[function(e,t,r){arguments[4][53][0].apply(r,arguments)},{dup:53}],201:[function(e,t,r){arguments[4][54][0].apply(r,arguments)},{"./_stream_readable":203,"./_stream_writable":205,_process:178,dup:54,inherits:143}],202:[function(e,t,r){arguments[4][55][0].apply(r,arguments)},{"./_stream_transform":204,dup:55,inherits:143}],203:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"../errors":200,"./_stream_duplex":201,"./internal/streams/async_iterator":206,"./internal/streams/buffer_list":207,"./internal/streams/destroy":208,"./internal/streams/from":210,"./internal/streams/state":212,"./internal/streams/stream":213,_process:178,buffer:72,dup:56,events:111,inherits:143,"string_decoder/":214,util:25}],204:[function(e,t,r){arguments[4][57][0].apply(r,arguments)},{"../errors":200,"./_stream_duplex":201,dup:57,inherits:143}],205:[function(e,t,r){arguments[4][58][0].apply(r,arguments)},{"../errors":200,"./_stream_duplex":201,"./internal/streams/destroy":208,"./internal/streams/state":212,"./internal/streams/stream":213,_process:178,buffer:72,dup:58,inherits:143,"util-deprecate":215}],206:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{"./end-of-stream":209,_process:178,dup:59}],207:[function(e,t,r){arguments[4][60][0].apply(r,arguments)},{buffer:72,dup:60,util:25}],208:[function(e,t,r){arguments[4][61][0].apply(r,arguments)},{_process:178,dup:61}],209:[function(e,t,r){arguments[4][62][0].apply(r,arguments)},{"../../../errors":200,dup:62}],210:[function(e,t,r){arguments[4][63][0].apply(r,arguments)},{dup:63}],211:[function(e,t,r){arguments[4][64][0].apply(r,arguments)},{"../../../errors":200,"./end-of-stream":209,dup:64}],212:[function(e,t,r){arguments[4][65][0].apply(r,arguments)},{"../../../errors":200,dup:65}],213:[function(e,t,r){arguments[4][66][0].apply(r,arguments)},{dup:66,events:111}],214:[function(e,t,r){ // distribute, sublicense, and/or sell copies of the Software, and to permit "use strict";var i=e("safe-buffer").Buffer,n=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=h,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=f,this.end=u,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function h(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return n>0&&(e.lastNeed=n-1),n;if(--i=0)return n>0&&(e.lastNeed=n-2),n;if(--i=0)return n>0&&(2===n?n=0:e.lastNeed=n-3),n;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":189}],215:[function(e,t,r){(function(e){(function(){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var i=!1;return function(){if(!i){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation"),i=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],216:[function(e,t,r){Ext.ns("SYNO.SDS.C2FS"),SYNO.SDS.C2FS.NPM={nodeRSA:function(){return e("node-rsa")}}},{"node-rsa":149}]},{},[216]),Ext.ns("SYNO.SDS.C2FS.Utils"),SYNO.SDS.C2FS.Utils.C2WebHandler={helper:SYNO.SDS.C2FS.Helper,generateUrl:function(e){return`${this.getEverestUrl()}/${e}?`+`origin=${this.getWindowOrigin()}&version=${this.helper.pkgVersion()}&host_name=${encodeURIComponent(_S("hostname"))}`},getWindowOrigin:function(){return encodeURIComponent(String.format("{0}//{1}",window.location.protocol,window.location.host))},isKnownOrigin:function(e){return e.endsWith(".synology.com")||e.endsWith(".synology.inc")||e.endsWith(".c2go.dev")},getEverestUrl:function(){const e=Ext.urlDecode(window.location.href.split("?")[1]);return"test"==e.everest?"https://account.c2test.synology.com":"staging"==e.everest?"https://account.c2.c2go.dev":"https://account.c2.synology.com"},generateHybridShareDashboardUrl:function(){return this.getEverestUrl()+"/hybrid_share"}},Ext.define("SYNO.SDS.C2FS.WelcomeStep",{extend:"SYNO.SDS.Wizard.WelcomeStep",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)]),this.shareStore=e.module.panel.store},fillConfig:function(e){this.panel=this.createPanel();const t={headline:this.helper.T("common","hybrid_share"),items:[this.panel],listeners:{destroy:this.unregister}};return Ext.apply(t,e),t},createPanel:function(){return this.newShareDescriptionLearnMoreId=Ext.id(),new SYNO.ux.Panel({cls:"c2fs-panel-no-padding",layout:"vbox",listeners:{afterrender:function(){this.appWin.setStatusBusy({text:this.helper.T("common","msg_waiting")}),this.checkCanCreateShare()}.bind(this)},items:[{xtype:"label",name:"create_wizard_image",width:740,height:240,cls:"c2-create-wizard-img"},{xtype:"syno_displayfield",cls:"c2-create-wizard-welcome-txt",htmlEncode:!1,value:String.format(this.helper.T("common","new_share_detail_description"),'',"",'',""),listeners:{afterrender:function(){Ext.get(this.newShareDescriptionLearnMoreId).on("click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.C2FS.Application"},!1)},this)},scope:this}}]})},checkHybridShareNum:function(){return new Promise(function(e,t){this.shareStore.getRange().filter(function(e){return!0===e.get("is_c2_share")}).length>=this.helper.maxC2fsNum()?e():t()}.bind(this))},checkCanCreateShare:function(){this.checkHybridShareNum().then(function(){this.appWin.getMsgBox().alert(this.appWin.title,String.format(this.helper.T("error","exceed_c2_share_num"),this.helper.maxC2fsNum()),function(){this.appWin.close()}.bind(this))}.bind(this),function(){this.checkVolumeExist()}.bind(this))},checkVolumeExist:function(){return this.checkHasBtrfs().then(this.checkPoolExist.bind(this))},checkHasBtrfs:function(){return this.sendWebAPIPromise({api:"SYNO.Core.Storage.Volume",method:"list",version:1,params:{limit:-1,offset:0,location:"internal"},scope:this}).then(function(e){let t=!1;if(!Ext.isArray(e.volumes)||0===e.total)return t;if(t=!0,e.volumes.some(function(e){return"btrfs"===e.fs_type&&SYNO.SDS.C2FS.Share.Utils.idealLocalCacheGB({total_mb:e.size_total_byte/1024/1024})}))return t;const r=String.format(this.helper.T("error","no_available_volume"),SYNO.SDS.Utils.CapacityRender(1024*SYNO.SDS.C2FS.Share.Utils.basicVolumeSizeGB()))+' '+this.helper.T("common","learn_more")+"",i=this.appWin.getMsgBox();return i.alert(this.appWin.title,r,function(){this.appWin.close()}.bind(this)),i.getDialog().el.child(".link-font").on("click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.C2FS.Application:getting_started.html"},!1)}),t}.bind(this),this.sendDsmWebApiFailure.bind(this))},checkPoolExist:function(e){if(!0!==e)return this.sendWebAPIPromise({api:"SYNO.Core.Storage.Pool",method:"list",version:1,params:{limit:-1,offset:0},scope:this}).then(function(e){let t,r={};return e.pools.length>0?(t=this.helper.T("warn","go_create_volume_wizard"),r={fn:"SYNO.SDS.StorageManager.Pool.Main",vueWizard:"CreateWizard",modalParam:{width:820,height:560,title:this.helper.T("volume","volume_raid_creation_title"),mode:"volume"}}):t=this.helper.T("warn","go_storage_first_time_wizard"),this.alertGoStorageManager(t,r),!1}.bind(this),this.sendDsmWebApiFailure.bind(this));this.appWin.clearStatusBusy()},alertGoStorageManager:function(e,t){const r=this.appWin;r.getMsgBox().show({title:r.title,msg:e,buttons:{ok:this.helper.T("warn","go_storage_manager")},fn:function(){"SYNO.SDS.CMS.Application"!==this.findAppWindow().getOpenConfig("className")&&SYNO.SDS.AppLaunch("SYNO.SDS.StorageManager.Instance",t),r.close()}.bind(this),scope:r,minWidth:r.minWidth},r)},sendDsmWebApiFailure:function(e){SYNO.Debug("err: ",e);const t=this.helper.ErrorMap.T(e.error.code)||this.helper.T("common","error_system"),r=this.findWindow();return r.getMsgBox().alert(this.title,t,function(){r.close()}),!1},goDecryptStep:function(){this.appWin.reloadData(!0),this.appWin.goNext(this.decryptId)},goEncryptStep:function(){const e=this.appWin.getServerInfo().bucket_name;this.appWin.reloadData(!0),this.appWin.getStep(this.encryptId).updateBucketName(e),this.appWin.goNext(this.encryptId)},getNext:function(){return _S("is_admin")?this.adminUserCheckNtpSetting():this.delegatedUserCheckNtpSetting(),!1},delegatedUserCheckNtpSetting:function(){this.sendWebAPIPromise({api:"SYNO.C2FS.Utils",version:1,method:"check_ntp_enable",scope:this}).then(function(e){e.is_ntp_enable?this.popC2LoginWeb():this.appWin.getMsgBox().alert(this.title,this.helper.T("warn","inform_admin_of_enabling_ntp"))}.bind(this),this.sendDsmWebApiFailure.bind(this))},adminUserCheckNtpSetting:function(){const e=this;this.sendWebAPIPromise({api:"SYNO.Core.Region.NTP",version:2,method:"get",scope:this}).then(function(t){if("ntp"!==t.enable_ntp){const r=String.format(e.helper.T("warn","need_enable_ntp_sync_setting"),'',""),i=e.appWin.getMsgBox();return i.confirm(e.appWin.title,r,function(r){return"yes"===r?function(t){return e.sendWebAPIPromise({api:"SYNO.Core.Region.NTP",version:1,method:"set",params:{timezone:t.timezone?t.timezone:"Dublin",enable_ntp:"ntp",server:t.server?t.server:"time.google.com"}})}(t).then(function(t){const r=e._D("product"),i=SYNO.SDS.AdminCenter.Region.Utils.ntpUpdateFailedMsg(r,t.server),n=SYNO.SDS.AdminCenter.Region.Utils.ntpUpdateProgressMsg(r,t.server);e.appWin.setStatusBusy({text:n},.1,100),SYNO.SDS.AdminCenter.Region.Utils.trySendSyncAPI(t.server,function(t,r){e.appWin.clearStatusBusy(),t?e.popC2LoginWeb():e.appWin.getMsgBox().alert(e.title,i,function(){e.popC2LoginWeb()})},e.appWin)}(t),e.sendDsmWebApiFailure.bind(e)):(e.appWin.close(),!1)},e.appWin,{yes:{text:e.helper.T("common","ok")},no:{text:e.helper.T("common","cancel")}}),i.getDialog().el.child(".link-font").on("click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.C2FS.Application:create_hybrid_share.html"},!1)}),!1}return e.popC2LoginWeb(),!1},e.sendDsmWebApiFailure.bind(e))},popC2LoginWeb:function(){this.unregister();const e=SYNO.SDS.C2FS.Utils.C2WebHandler.generateUrl("c2share/mount"),t=SYNO.SDS.C2FS.NPM.nodeRSA();this.rsaKey=new t({b:1024}),this.register(this.c2PostMessageManager.createDelegate(this),"C2Share"),this.popup=window.open(e,"mywindow","menubar=1, resizable=0, width=1080, height=800, top=100, left=300"),this.popup||this.appWin.getMsgBox().alert(this.appWin.title,this.helper.T("warn","popup_c2_web_failed"),Ext.emptyFn)},processC2LoginResponse:function(e){!1!==e.authorize&&(this.isLogined=!0)},c2PostMessageManager:function(e){if(!SYNO.SDS.C2FS.Utils.C2WebHandler.isKnownOrigin(e.origin))return!1;switch(e.data.cmd){case"ask_ds_info_and_mount":if(!e.data.account)return!1;this.responseDsInfoAndMountedShare(e);break;case"authorize":{const t=e.data,r=t.share;r&&t.c2_api_url&&(this.owner.fireEvent("setServerInfo",{metadata:r.metadata?r.metadata:"",c2share_api_url:t.c2_api_url,share_id:r.share_id,share_key:r.share_key,synology_account:t.account,bucket_name:r.share_name,bucket_used_mb:r.bytes_used?r.bytes_used/1024/1024:0,bucket_total_mb:r.quota_limit/1024/1024,scoped_c2auth_access_tokens:this.rsaKey.decrypt(t.access_tokens,"json"),scoped_c2auth_public_key:this.rsaKey.decrypt(t.public_key,"base64"),scoped_c2auth_private_key:this.rsaKey.decrypt(t.private_key,"base64")}),r.share_key&&SYNO.SDS.Utils.IsJson(r.share_key)?this.goDecryptStep():(this.owner.fireEvent("setBucketEncryptStatus",!1),this.goEncryptStep()));break}}},getAccountFromEvent:function(e){try{return e.data.account}catch(t){return SYNO.Debug("Invalid event for get account, event:",e,t),""}},sendWepApiForMountedShare:async function(e){return this.sendWebAPIPromise({api:"SYNO.C2FS.Bucket",method:"get_account_mount",version:1,params:{synology_account:e},scope:this})},sendWebApiForDsInfo:async function(){return this.sendWebAPIPromise({api:"SYNO.C2FS.Utils",method:"get_ds_info",version:1,scope:this})},responseDsInfoAndMountedShare:async function(e){const t=this.getAccountFromEvent(e);if(!t)return!1;try{const[r,i]=await Promise.all([this.sendWepApiForMountedShare(t),this.sendWebApiForDsInfo()]);this.popup.postMessage({shares:r,ds_info:i,rsa_public_key:this.rsaKey.exportKey("pkcs8-public-pem")},e.origin)}catch(e){this.helper.popupErrorMessage(this.appWin,e.code,Ext.emptyFn)}},register:function(e,t){const r=this;this.receiveMessage=function(i){/setImmediate/.test(i.browserEvent.data)||i.browserEvent.data.pkg_name===t&&e.call(r,i.browserEvent)},Ext.EventManager.addListener(window,"message",this.receiveMessage)},unregister:function(){Ext.EventManager.removeListener(window,"message",this.receiveMessage)}}),Ext.ns("SYNO.SDS.C2FS.Share.Utils"),SYNO.SDS.C2FS.Share.Utils={VOLUME_USAGE_MAX_RATIO:.9,LOCAL_CACHE:{MIN_SIZE_GB:500,DEFAULT_SIZE_GB:500},MIN_RATIO_OF_BUCKET:.05,isNormalStatus:function(e){return"uploading"===e||"updating"===e||"building"===e||"resync"===e||"transform_check"===e||"transform_upload"===e||"transform_prepare"===e||"transform_cancel"===e||"confirming_connection"===e||"restore"===e},isWarningStatus:function(e){return"slow_uploading"===e||"in_write_throttle"===e},isErrorStatus:function(e){return"disconnected"===e||"incompatible"===e||"no_config"===e||"volume_full"===e||"disable"==e||"unauth"===e||"c2_space_full"===e||"in_grace"===e||"in_downgrade"===e||"bad_space_usage"===e||"share_offline"===e},idealLocalCacheGB:function(e,t){if(!e.total_mb)return SYNO.Debug("Invalid volumeInfo: ",e),NaN;let r=Math.min(t&&t.total_mb?t.total_mb:1048576,e.total_mb*this.VOLUME_USAGE_MAX_RATIO);return(r=Math.floor(r/1024))["ActiveBackupforBusiness","MailPlus","chat","docker","Surveillance","surveillance","music","video","photo","web","web_packages","homes"].includes(e),genLocalReservationSizeForNewShareValidator:function(e,t,r,i){const n=SYNO.SDS.C2FS.Share.Utils.minLocalCacheGB(),s=t*SYNO.SDS.C2FS.Share.Utils.VOLUME_USAGE_MAX_RATIO,o=SYNO.SDS.C2FS.Helper;return t=>t>e?s>r?String.format(o.T("warn","reservation_size_exceed_bucket"),SYNO.SDS.Utils.CapacityRender(r,2)):String.format(o.T("warn","set_reservation_size_exceed_volume"),i,SYNO.SDS.Utils.CapacityRender(s,2)):!(t'+this.helper.T("common","star")+"",labelHtmlEncode:!1,allowBlank:!1,blankText:this.helper.T("share","error_noname"),width:300,vtype:"sharename"},e)])}}),Ext.define("SYNO.SDS.C2FS.Share.RequiredDisplayField",{extend:"SYNO.ux.DisplayField",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([Ext.apply({htmlEncode:!1,value:''+this.helper.T("common","star")+" "+this.helper.T("firewall","firewall_field_blank_alert")},e)])}}),Ext.define("SYNO.SDS.C2FS.Share.GeneralForm",{extend:"SYNO.SDS.Utils.FormPanel",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)]),this.isShareRecycleCleaning=!1},fillConfig:function(e){e&&e.highlightBox||(e.highlightBox={}),(!Object.prototype.hasOwnProperty.call(e.highlightBox,"marginRight")||!Number.isInteger(e.highlightBox.marginRight)||e.highlightBox.marginRight<0)&&(e.highlightBox.marginRight=0),e.openMode||(e.openMode="create");const t={title:this.helper.T("share","share_subject"),border:!1,frame:!1,header:!1,labelWidth:300,trackResetOnLoad:!0,items:[new SYNO.SDS.C2FS.Share.NameTextField,{xtype:"syno_textfield",name:"description",ref:"description",maxlength:64,width:300,fieldLabel:this.helper.T("share","share_comment")},{xtype:"syno_share_combobox",name:"volume_path",ref:"volumePath",fieldLabel:this.helper.T("volume","volume_share_position"),hidden:"create"!==e.openMode,store:new Ext.data.JsonStore({idProperty:"volume_path",fields:["volume_path","for_display","size_total_mb","volume_name","description","tooltip","size_free_mb"]}),displayField:"for_display",descriptionField:"description",tooltip:"tooltip",valueField:"volume_path",allowBlank:"create"!==e.openMode,width:300},{xtype:"syno_displayfield",name:"read_only_volume_path",ref:"readOnlyVolumePath",fieldLabel:this.helper.T("volume","volume_share_position"),hidden:"edit"!==e.openMode,value:""},{xtype:"syno_checkbox",name:"disableBrowsable",ref:"disableBrowsable",boxLabel:this.helper.T("common","share_hide")},{xtype:"syno_checkbox",name:"hide_unreadable",ref:"hideUnreadable",boxLabel:this.helper.T("share","share_hide_unreadable"),hideLabel:!0},{xtype:"syno_checkbox",name:"enable_recycle_bin",ref:"enableRecyleBin",boxLabel:this.helper.T("share","share_enable_recycle_bin"),hideLabel:!0,hidden:!_S("is_admin"),listeners:{scope:this,check:function(e,t){t?this.recyleBinAdminOnly.enable():this.recyleBinAdminOnly.disable()}}},{xtype:"syno_checkbox",name:"recycle_bin_admin_only",ref:"recyleBinAdminOnly",boxLabel:this.helper.T("network","cifs_safe_recycle_bin"),width:500,indent:1,hidden:!_S("is_admin")},{xtype:"syno_button",ref:"cleanRecyleBin",indent:1,width:"auto",text:this.helper.T("share","share_clean_recycle_bin"),hidden:!0,scope:this,handler:this.onCleanBinBtnClick},{xtype:"syno_displayfield",indent:1,tabIndex:-1,htmlEncode:!1,hidden:!_S("is_admin"),value:''+this.helper.T("common","note")+this.helper.T("common","colon")+''+this.helper.T("network","cifs_recycle_bin_help_link")+"",listeners:{afterrender:SYNO.SDS.AdminCenter.Share.Utils.ShowHelpCallback(SYNO.SDS.AdminCenter.TaskScheduler.Main.prototype.getHelpParam()),scope:this}},new SYNO.SDS.C2FS.Share.RequiredDisplayField]};return Ext.apply(t,e),t},setRecycleStatus:function(e){!0===e?(this.isShareRecycleCleaning=!0,this.cleanRecyleBin.setText(this.helper.T("share","share_clean_recycle_bin_abort"))):(this.isShareRecycleCleaning=!1,this.cleanRecyleBin.setText(this.helper.T("share","share_clean_recycle_bin")))},onCleanBinBtnClick:function(e,t){let r,i;!0===this.isShareRecycleCleaning?(r="stop",i=this.helper.T("share","share_recycle_bin_clean_abort_warn")):(r="start",i=this.helper.T("share","share_recycle_bin_clean_warn"));const n={yes:{text:Ext.MessageBox.buttonText.yes,btnStyle:"red"},no:{text:Ext.MessageBox.buttonText.no}};this.findWindow().getMsgBox().confirmDelete(this.helper.T("share","share_clean_recycle_bin"),i,function(e){"yes"===e&&(this.cleanRecyleBin.disable(),this.sendWebAPI({api:"SYNO.Core.RecycleBin",method:r,version:1,params:{id:this.shareName.originalValue},scope:this,callback:function(e,t,r){e?(t.is_cleaning?(this.isShareRecycleCleaning=!0,this.cleanRecyleBin.setText(this.helper.T("share","share_clean_recycle_bin_abort")),this.startPollRecycleStatus()):(this.isShareRecycleCleaning=!1,this.cleanRecyleBin.setText(this.helper.T("share","share_clean_recycle_bin")),this.stopPollRecycleStatus()),this.cleanRecyleBin.enable()):this.startPollRecycleStatus()}}))},this,n)},startPollRecycleStatus:function(){this.PollTaskRecycleBinId||(this.PollTaskRecycleBinId=this.pollReg({interval:5,immediate:!0,webapi:{api:"SYNO.Core.RecycleBin",method:"get",version:1,params:{id:this.shareName.originalValue}},scope:this,status_callback:function(e,t,r){if(!e)return!1;t.is_cleaning?(this.isShareRecycleCleaning=!0,this.cleanRecyleBin.setText(this.helper.T("share","share_clean_recycle_bin_abort")),this.cleanRecyleBin.enable()):(this.isShareRecycleCleaning=!1,this.cleanRecyleBin.setText(this.helper.T("share","share_clean_recycle_bin")),this.cleanRecyleBin.enable(),this.stopPollRecycleStatus())}}))},stopPollRecycleStatus:function(){this.PollTaskRecycleBinId&&(this.pollUnreg(this.PollTaskRecycleBinId),this.PollTaskRecycleBinId=null)}}),Ext.define("SYNO.SDS.C2FS.FillBasicInfoStep",{extend:"SYNO.SDS.Wizard.Step",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)]),this.mon(this.generalForm.volumePath,"afterrender",()=>{SYNO.ux.AddWhiteTipWithMsg(this.generalForm.volumePath,this.helper.T("common","btrfs_volume_only"))})},fillConfig:function(e){this.generalform=new SYNO.SDS.C2FS.Share.GeneralForm({module:e.module,cls:"c2fs-panel-no-padding",ref:"generalForm",owner:this,itemId:"generalForm",autoHeight:!0,openMode:"create"});const t={shareStore:e.module.panel.store,headline:this.helper.T("share","create_wizard_basic_info"),layout:"fit",items:[this.generalform],listeners:{afterrender:this.setDefaultOptionAndValidator,scope:this}};return Ext.apply(t,e),t},validate:function(){return this.generalform.getForm().isValid()},fetchAllVolumes:async function(){return this.sendWebAPIPromise({api:"SYNO.Core.Storage.Volume",method:"list",params:{limit:-1,offset:0,location:"internal"},version:1})},filterAvailableVolumeForStore:function(e){const t=e.volumes;return Ext.isArray(t)?t.filter((e,t)=>!e.readonly&&"btrfs"===e.fs_type&&SYNO.SDS.C2FS.Share.Utils.idealLocalCacheGB({total_mb:e.size_total_byte/1024/1024})).map((e,t)=>({volume_path:e.volume_path,for_display:SYNO.SDS.Utils.StorageUtils.VolumeNameRenderer(e)+this.helper.T("common","colon")+e.fs_type,size_total_mb:e.size_total_byte/1024/1024,size_free_mb:e.size_free_byte/1024/1024,volume_name:e.display_name,description:String.format("{0}{1}{2}",this.helper.T("volume","volume_freesize"),this.helper.T("common","colon"),SYNO.SDS.Utils.StorageUtils.UiRenderHelper.SizeRender(e.size_free_byte)),tooltip:e.description?e.description:""})):(SYNO.Debug("Bad request no volumes ",e),[])},alertNoAvailableVolume(){this.findWindow().getMsgBox().alert(this.title,String.format(this.helper.T("error","no_proper_volume_for_this_bucket"),SYNO.SDS.Utils.CapacityRender(1024*SYNO.SDS.C2FS.Share.Utils.basicVolumeSizeGB())))},findProperNameByBucket:function(){const e=this.owner.getServerInfo().bucket_name;if(e){if(!0===this.validateShareName(e))return e;for(let t=1;t<100;t++){const r=e+"_"+t;if(!0===this.validateShareName(r))return r}}},fillShareNameIfEmpty:function(){if(this.generalForm.shareName.getValue())return;const e=this.findProperNameByBucket();e&&this.generalForm.shareName.setValue(e)},activate:async function(){try{this.findWindow().setStatusBusy();const e=await this.fetchAllVolumes(),t=this.filterAvailableVolumeForStore(e);if(0===t.length)return void this.alertNoAvailableVolume();this.generalForm.volumePath.store.loadData(t),this.generalForm.volumePath.getValue()||this.generalForm.volumePath.setValue(t[0].volume_path),this.fillShareNameIfEmpty()}catch(e){SYNO.Debug("error: ",e),this.helper.popupErrorMessage(this.findWindow(),e.code)}finally{this.findWindow().clearStatusBusy()}},getValues:function(){const e=this.generalForm.volumePath.store.getById(this.generalform.volumePath.getValue());return Ext.apply(this.generalform.getForm().getValues(),{volume_desc:this.generalform.volumePath.rawValue,volume_free_size_mb:e.get("size_free_mb"),volume_total_size_mb:e.get("size_total_mb"),volume_display_name:e.get("for_display")})},confirmEnableSpaceUsage:function(){return new Promise((e,t)=>{this.appWin.getMsgBox().confirm(this.appWin.title,this.helper.T("warn","enable_space_usage"),r=>{"yes"===r?e():t(new Error("User cancelled"))})})},checkSpaceUsage:async function(){const e=SYNO.SDS.C2FS.Utils.Volume;try{this.appWin.setStatusBusy({text:this.helper.T("common","msg_waiting")});const t=await e.getSpaceUsageStatus(this.generalForm.volumePath.value);return"enabled"===t||"enabling"===t}finally{this.appWin.clearStatusBusy()}},tryEnableSpaceUsage:async function(){if(!await this.checkSpaceUsage()){try{await this.confirmEnableSpaceUsage()}catch(e){return this.helper.popupErrorMessage(this.owner,SYNO.SDS.C2FS.Helper.ErrorMap.ERR_NEED_SPACE_USAGE),!1}if(await SYNO.SDS.C2FS.Utils.Volume.setSpaceUsageStatus(this.generalForm.volumePath.value,"enable"),!await this.checkSpaceUsage())throw new Error("Space usage remains disabled after enabling")}return!0},getNext:function(){return!!this.validate()&&((async()=>{try{await this.tryEnableSpaceUsage()&&(this.appWin.reloadData(!0),this.appWin.goNext(this.nextId))}catch(e){e&&SYNO.Debug(e),this.helper.popupErrorMessage(this.owner,SYNO.SDS.C2FS.Helper.ErrorMap.ERR_OPERATION)}})(),!1)},isShareNameConflict:function(e){let t=!1;return this.shareStore.each(r=>{if(r.get("name").toLowerCase()===e.toLowerCase())return t=!0,!1}),t},validateShareName:function(e){return SYNO.SDS.C2FS.Share.Utils.isNoSupportShareName(e)?this.helper.T("error","reserved_share_name"):!this.shareStore||(!this.isShareNameConflict(e)||this.helper.T("share","share_already_exist"))},setDefaultOptionAndValidator:function(){this.generalform.recyleBinAdminOnly.setValue(!0),this.generalform.enableRecyleBin.setValue(!0),this.generalForm.shareName.validator=this.validateShareName}}),Ext.define("SYNO.SDS.C2FS.SetC2FSStep",{extend:"SYNO.SDS.Wizard.Step",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){this.setupC2FSForm=new SYNO.SDS.C2FS.Share.SetupC2FSForm({module:e.module,cls:"c2fs-panel-no-padding",ref:"setupC2FSForm",owner:this,itemId:"setupC2FSForm",bottomDisplayFieldStyle:"padding: 4px 0 0 0;"});const t={headline:this.helper.T("common","create_wizard_local_cache_rule"),layout:"fit",items:[this.setupC2FSForm]};return Ext.apply(t,e),t},activate:function(){const e=this.setupC2FSForm.reservationSize.sizeGb;if(e.getValue())return;const{volume_total_size_mb:t,volume_display_name:r}=this.owner.getValues().fillBasicInfo,{bucket_total_mb:i}=this.owner.getServerInfo(),n=SYNO.SDS.C2FS.Share.Utils.idealLocalCacheGB({total_mb:t},{total_mb:i}),s=SYNO.SDS.C2FS.Share.Utils.minLocalCacheGB();Number.isNaN(n)&&this.appWin.getMsgBox().alert(this.title,String.format(this.helper.T("error","target_volume_no_space"),SYNO.SDS.Utils.CapacityRender(1024*s)),Ext.emptyFn),e.setValue(SYNO.SDS.C2FS.Share.Utils.LOCAL_CACHE.DEFAULT_SIZE_GB),e.validator=SYNO.SDS.C2FS.Share.Utils.genLocalReservationSizeForNewShareValidator(n,t,i,r)},validate:function(){return this.setupC2FSForm.getForm().isValid()},getValues:function(){return this.setupC2FSForm.getForm().getValues()},getNext:function(){return!!this.validate()&&(this.appWin.reloadData(!0),this.nextId)}}),Ext.define("SYNO.SDS.C2FS.DecryptBucketStep",{extend:"SYNO.SDS.Wizard.Step",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){this.formPanel=this.createFormPanel(e);const t={headline:this.helper.T("common","decryption_title"),layout:"fit",items:[this.formPanel],listeners:{scope:this}};return Ext.apply(t,e),t},createFormPanel:function(e){const t={cls:"c2fs-panel-no-padding",itemId:"decryptBucketForm",ref:"decryptBucketForm",height:350,items:[{xtype:"syno_displayfield",style:"margin-bottom: 6px;",hideLabel:!0,htmlEncode:!1,value:String.format(this.helper.T("common","decryption_desc"),'',""),listeners:{afterrender:function(e){const t=e.el.query("a");t[0]?Ext.get(t[0].id).on("click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.C2FS.Application:create_hybrid_share.html"},!1)},this):SYNO.Debug("Failed to find link element: ",t)},scope:this}},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_radio",name:"decrypt_method",width:260,inputValue:"manual",boxLabel:this.helper.T("share","share_encryption_keyinput")+this.helper.T("common","colon"),checked:!0},{xtype:"syno_textfield",textType:"password",name:"password",allowBlank:!1,width:220,validator:function(e){return-1===e.indexOf("=")&&-1===e.indexOf(",")&&-1===e.indexOf(":")||this.helper.T("share","encryption_password_invalid")}.bind(this)}]},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_radio",name:"decrypt_method",width:260,inputValue:"keyfile",boxLabel:this.helper.T("share","share_encryption_importfrom")},{xtype:"syno_filebutton",ref:"../keyFileButton",allowBlank:!1,name:"key_file",textConfig:{width:204}}],listeners:{afterrender:function(){const e=this.formPanel.getForm();new SYNO.ux.Utils.EnableRadioGroup(e,"decrypt_method",{manual:["password"],keyfile:["key_file"]})}.bind(this)}}]};return Ext.apply(t,e),new SYNO.SDS.Utils.FormPanel(t)},isValid:function(){return this.formPanel.getForm().isValid()},getValues:function(){return null},sendDecryptWebApi:function(e){const t=this.owner.getServerInfo(),r={api:"SYNO.C2FS.Bucket",version:1,method:"decrypt",encryption:["share_key","share_id"],params:{share_key:t.share_key,share_id:t.share_id}};e?(r.params.decrypt_key_in_base64=e,r.encryption.push("decrypt_key_in_base64")):(r.params.decrypt_password=this.formPanel.getForm().findField("password").getValue(),r.encryption.push("decrypt_password")),this.sendWebAPIPromise(r).then(function(){this.appWin.clearStatusBusy(),this.appWin.reloadData(!0),this.appWin.goNext(this.nextId)}.bind(this),function(e){return this.appWin.clearStatusBusy(),this.helper.popupErrorMessage(this.findWindow(),e.code),!1}.bind(this))},getNext:function(){if(!this.isValid())return!1;if(this.appWin.setStatusBusy({text:this.helper.T("common","msg_waiting")}),"keyfile"===this.formPanel.getForm().findField("decrypt_method").getGroupValue()){const e=this.formPanel.keyFileButton.el.dom.files[0];if(32!==e.size)return this.helper.popupErrorMessage(this.findWindow(),this.helper.ErrorMap.ERR_BUCKET_BAD_PASSWORD_KEY,function(){this.appWin.clearStatusBusy()}.bind(this)),!1;const t=new FileReader;t.onload=function(){let e="";const r=new Uint8Array(t.result);for(let t=0;t',""),listeners:{afterrender:function(e){const t=e.el.query("a");t[0]?Ext.get(t[0].id).on("click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.C2FS.Application:create_hybrid_share.html"},!1)},this):SYNO.Debug("Failed to find link element: ",t)},scope:this}},{xtype:"syno_textfield",textType:"password",name:"enc_passwd",minLength:8,maxLength:64,width:220,allowBlank:!1,fieldLabel:this.helper.T("share","share_encryption_key"),validator:function(e){return-1===e.indexOf("=")&&-1===e.indexOf(",")&&-1===e.indexOf(":")||this.helper.T("share","encryption_password_invalid")}.bind(this)},{xtype:"syno_textfield",textType:"password_confirm",name:"enc_passwd_confirm",confirmFor:"enc_passwd",confirmFailedText:this.helper.T("share","share_encryption_key_confirm_mismatch"),maxlength:64,width:220,allowBlank:!1,fieldLabel:this.helper.T("share","share_encryption_key_confirm")}]};return Ext.apply(t,e),new SYNO.SDS.Utils.FormPanel(t)},isValid:function(){return this.formPanel.getForm().isValid()},getValues:function(){return null},getNext:function(){if(this.isValid()){const e='

'+this.helper.T("warn","encrypt_note")+'

'+this.helper.T("warn","encrypt_key_cant_modified")+'

'+this.helper.T("warn","encrypt_key_no_save_on_server")+"

";this.appWin.getMsgBox().confirm(this.helper.T("warn","encrypting_confirm_title"),e,function(e){"yes"===e&&(this.appWin.setStatusBusy({text:this.helper.T("common","msg_waiting")}),this.sendWebAPIPromise({api:"SYNO.C2FS.Bucket",method:"encrypt",version:1,encryption:["encrypt_password","server_info"],params:{encrypt_password:this.formPanel.getForm().getValues().enc_passwd,server_info:this.owner.getServerInfo()},scope:this}).then(function(){return this.appWin.clearStatusBusy(),this.downloadKey(),this.appWin.reloadData(!0),this.appWin.goNext(this.nextId),!1}.bind(this),function(e){return this.appWin.clearStatusBusy(),this.helper.popupErrorMessage(this.findWindow(),e.code),!1}.bind(this)))},this,{yes:!0,no:!0},{useMessageTitle:!0,hideBrElement:!0})}return!1},downloadKey:function(){const e=this.owner.getServerInfo();this.findAppWindow().downloadWebAPI({webapi:{api:"SYNO.C2FS.Bucket",method:"password_key_export",version:1,params:{share_id:e.share_id,bucket_name:e.bucket_name}},scope:this,callback:function(e,t,r,i){"timeout"!==e&&!1===r&&this.findWindow().getMsgBox().alert(this.title,this.helper.T("status","status_err_load"))}.bind(this)})},updateBucketName:function(e){this.getHeadLine().update(String.format(this.helper.T("common","encryption_title_with_bucket"),e))}}),Ext.define("SYNO.SDS.C2FS.SummaryStep",{extend:"SYNO.SDS.Wizard.SummaryStep",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([e])},activate:function(){const e=this.owner.getValues(),t=e.fillBasicInfo,r=e.setC2FSSStep,i=[];t.disableBrowsable&&i.push(this.helper.T("share","share_hide_in_windows")),t.hide_unreadable&&i.push(this.helper.T("share","share_hide_without_perm")),this.getStore().removeAll(!0),this.getStore().append(this.helper.T("share","share_name"),t.name),this.getStore().append(this.helper.T("share","share_comment"),t.description),this.getStore().append(this.helper.T("volume","volume_share_position"),t.volume_desc),this.getStore().append(this.helper.T("attribute","local_reservation_size_display"),r.reservation_size_gb+" GB"),this.getStore().append(this.helper.T("share","share_visibility"),i.join("; ")),this.getStore().append(this.helper.T("share","recycle_bin"),t.enable_recycle_bin?this.helper.T("share",t.recycle_bin_admin_only?"recycle_bin_enabled_admin_only":"create_wizard_enabled"):""),this.getView().syncFocusEl(0),this.getView().refresh()},checkState:function(){this.callParent(),!1===this.needGoToNextStep()&&this.owner.fireEvent("setNextButtonText",this.helper.T("common","done"))},needGoToNextStep:function(){return!1===this.owner.getBucketEncryptStatus().is_encrypt},confirmEnableSpaceUsage:function(){return new Promise((e,t)=>{this.appWin.getMsgBox().confirm(this.appWin.title,this.helper.T("warn","enable_space_usage"),r=>{"yes"===r?e():t(new Error("User cancelled"))})})},checkSpaceUsage:async function(){const e=SYNO.SDS.C2FS.Utils.Volume,{volume_path:t}=this.owner.getValues().fillBasicInfo;try{this.appWin.setStatusBusy({text:this.helper.T("common","msg_waiting")});const r=await e.getSpaceUsageStatus(t);return"enabled"===r||"enabling"===r}finally{this.appWin.clearStatusBusy()}},tryEnableSpaceUsage:async function(){if(!await this.checkSpaceUsage()){try{await this.confirmEnableSpaceUsage()}catch(e){return this.helper.popupErrorMessage(this.owner,SYNO.SDS.C2FS.Helper.ErrorMap.ERR_NEED_SPACE_USAGE),!1}const{volume_path:e}=this.owner.getValues().fillBasicInfo;if(await SYNO.SDS.C2FS.Utils.Volume.setSpaceUsageStatus(e,"enable"),!await this.checkSpaceUsage())throw new Error("Space usage remains disabled after enabling")}return!0},getNext:function(){return(async()=>{try{await this.tryEnableSpaceUsage()&&this.createShare()}catch(e){e&&SYNO.Debug(e),this.helper.popupErrorMessage(this.owner,SYNO.SDS.C2FS.Helper.ErrorMap.ERR_OPERATION)}})(),!1},createShare:function(){this.appWin.setStatusBusy({text:this.helper.T("common","msg_waiting")});const e=this.owner.getValues(),t=e.fillBasicInfo,r=e.setC2FSSStep,i=this.owner.getServerInfo();this.sendWebAPIPromise({api:"SYNO.C2FS.Share",method:"create",version:1,scope:this,encryption:["volume_path","reservation_size_mb","server_info","share_attribute"],params:{name:t.name,volume_path:t.volume_path,reservation_size_mb:1024*r.reservation_size_gb,server_info:i,is_enable_immediately:!1,share_attribute:{is_recycle_bin_admin_only:t.recycle_bin_admin_only,is_enable_recycle_bin:t.enable_recycle_bin,is_hide_unreadable:t.hide_unreadable,is_browsable:!t.disableBrowsable,description:t.description}}}).then(function(e){this.owner.isNeedCloseWarnMsg=!1,this.appWin.clearStatusBusy();const n=i.c2share_api_url.match(/(?:[^:]+):\/\/c2share.([^.]+).c2(?:test)?.synology.com/+/(?:[^:]+):\/\/c2share.([^.]+).c2.c2go.dev/);SYNO.SDS.C2FS.UtilForDSM.updateOldInfoOfShare(t.name,{bucket_total_mb:i.bucket_total_mb,bucket_used_mb:i.bucket_used_mb,reservation_size_mb:1024*r.reservation_size_gb,status:["building"],cache_used_mb:0,sync_speed_mb_s:0,unsync_data_mb:0,synology_account:i.synology_account,zone:null!==n?n[1]:"-"}),this.module.panel.store.load(),this.module.panel.fireEvent("sharefolderchanged",t.name),SYNO.SDS.StatusNotifier.fireEvent("sharefolderchanged","permission"),this.appWin.reloadData(!0),this.appWin.goNext(this.needGoToNextStep()?this.nextId:null)}.bind(this),function(e){this.appWin.clearStatusBusy(),e.code!=this.helper.ErrorMap.ERR_NOT_FEASIBLE?this.helper.popupErrorMessage(this.owner,e.code):this.helper.popupFeasibilityCheckMsg(this.owner,e.errors.feasibility_check)}.bind(this))}}),Ext.define("SYNO.SDS.C2FS.Share.PermissionGrid",{extend:"SYNO.SDS.Share.ShareGrid",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){let t=e.hideCustomColumn;"SYNO.SDS.CMS.Application"===e.module.appWin.getOpenConfig("className")&&(t=t||e.module.appWin._S("version")<4475),this.colCu=new SYNO.SDS.Share.CustomColumn({module:e.module,owner:e.owner,ownerGrid:this,dataIndex:"is_custom",id:"is_custom",hidden:t,applyCallback:function(){this.store.load()},applyTarget:this}),e.colCu=this.colCu,e.cls="without-dirty-red-grid syno-position-disable-position-absolute",e.isShowPreview=!0,this.callParent([e])},loadFormData:function(e){const t=[{api:"SYNO.Core.Directory.LDAP",method:"get",version:1},{api:"SYNO.Core.Storage.Volume",method:"get",version:1,params:{volume_path:e.get("vol_path")}}];return this.getKnownAPI("SYNO.Core.Directory.Domain")&&(t.push({api:"SYNO.Core.Directory.Domain",method:"get",version:1}),t.push({api:"SYNO.Core.Directory.Domain",method:"test_dc",version:1}),"yes"===this._D("supportdomain")&&t.push({api:"SYNO.Core.Directory.Domain",method:"get_domain_list",version:2})),this.sendWebAPIPromise({compound:{stopwhenerror:!1,params:t},params:{},scope:this}).then(function(t){if(t.has_fail)return this.showAlertMsg(t),Promise.reject(t);if(this.getKnownAPI("SYNO.Core.Directory.Domain")){const e=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","get","enable_domain"),r=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","test_dc","test_join_success");e&&!r&&this.findWindow().getMsgBox().alert("warning_msg",_T("share","warning_directory_service_offline"))}const r=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Storage.Volume","get").volume;e.set("share_path",String.format("{0}/{1}",r.volume_path,e.get("name"))),e.set("readonly",r.readonly),this.loadPermissions(e,t)}.bind(this),function(e){return this.showAlertMsg(e),Promise.reject(e)}.bind(this))},showAlertMsg:function(e){const t=SYNO.API.Response.GetFirstError(e),r=SYNO.API.Errors.core[t.code]||this.helper.T("common","commfail");this.findWindow().getMsgBox().alert(this.title,r,function(){this.findWindow().close()},this)}}),Ext.define("SYNO.SDS.C2FS.Share.DefaultPermissionGrid",{extend:"SYNO.SDS.C2FS.Share.PermissionGrid",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([e])},createStore:function(e){return new SYNO.API.JsonStore({autoDestroy:!0,remoteSort:!0,appWindow:e.owner,api:"SYNO.Core.Share.Permission",method:"list",version:1,baseParams:{offset:0,limit:this.pageSize,is_unite_permission:e.isAdvancedMode||!1,with_inherit:e.isShowPreview||!1},listeners:{exception:{scope:this,fn:this.onStoreException},beforeload:{scope:this,fn:this.onBeforeLoad},load:{scope:this,fn:function(e,t){t.forEach(function(e){e.data.inherit=!0===e.get("is_admin")?"rw":"-",e.data.is_custom=!1,e.data.name===this._S("user")&&!1===this._S("is_admin")&&(e.data.is_writable=!0)}),this.onLoad()}}},root:"items",idProperty:"name",totalProperty:"total",fields:["name","is_writable","is_readonly","is_deny","is_custom","is_admin","inherit",{name:"preview",persist:!1}]})},sendApplyRequest:function(){const e=this.getWebAPI()[0];Object.assign(e,{api:"SYNO.C2FS.Share",method:"set_permission",version:1}),this.sendWebAPIPromise(e).then(function(){return!1},function(e){return SYNO.Debug("err",e),!1})}}),Ext.define("SYNO.SDS.C2FS.PermissionStep",{extend:"SYNO.SDS.Wizard.Step",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){this.gridPanel=new SYNO.SDS.C2FS.Share.DefaultPermissionGrid({module:e.module,owner:e.owner,itemId:"permissionGrid",ref:"permissionGrid"});const t={headline:this.helper.T("share","create_wizard_perm_setting"),layout:"fit",items:new SYNO.ux.Panel({ref:"wrapPanel",cls:"c2fs-panel-no-padding",items:this.gridPanel})};return Ext.apply(t,e),t},activate:function(){this.gridPanel.setHeight(this.wrapPanel.getHeight()),this.gridPanel.nameFilter.updateElSize();const e=this.owner.getValues().fillBasicInfo,t=new Ext.data.Record({name:e.name,vol_path:e.volume_path,is_aclmode:!0});this.findWindow().setStatusBusy({text:this.helper.T("common","msg_waiting")}),this.gridPanel.loadFormData(t).then(function(){this.findWindow().clearStatusBusy()}.bind(this),function(e){SYNO.Debug("Promise reject:",e),this.findWindow().clearStatusBusy()}.bind(this))},getNext:function(){return this.gridPanel.isChanged()?(this.gridPanel.sendApplyRequest(),this.nextId):this.nextId}}),Ext.define("SYNO.SDS.C2FS.Wizard",{extend:"SYNO.SDS.Wizard.ModalWindow",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)]),this.setAllStepSize(),this.bucketEncryptStatus=!0},fillConfig:function(e){const t=[new SYNO.SDS.C2FS.WelcomeStep({appWin:this,owner:this,module:e.module,itemId:"welcome",nextId:"fillBasicInfo",encryptId:"encryptBucketStep",decryptId:"decryptBucketStep"}),new SYNO.SDS.C2FS.EncryptBucketStep({appWin:this,owner:this,module:e.module,itemId:"encryptBucketStep",nextId:"fillBasicInfo"}),new SYNO.SDS.C2FS.DecryptBucketStep({appWin:this,owner:this,module:e.module,itemId:"decryptBucketStep",nextId:"fillBasicInfo"}),new SYNO.SDS.C2FS.FillBasicInfoStep({appWin:this,owner:this,module:e.module,itemId:"fillBasicInfo",nextId:"setC2FSSStep"}),new SYNO.SDS.C2FS.SetC2FSStep({appWin:this,owner:this,module:e.module,itemId:"setC2FSSStep",nextId:"summary"}),new SYNO.SDS.C2FS.SummaryStep({appWin:this,owner:this,module:e.module,itemId:"summary",nextId:"permissionStep"}),new SYNO.SDS.C2FS.PermissionStep({appWin:this,owner:this,module:e.module,itemId:"permissionStep",nextId:null})],r={title:this.helper.T("action","create_wizard"),steps:t,cls:"c2-create-wizard",listeners:{beforeclose:this.onBeforeClose,setServerInfo:this.setServerInfo,setBucketEncryptStatus:this.setBucketEncryptStatus,setNextButtonText:this.setNextButtonText,scope:this},isNeedCloseWarnMsg:!0};return Ext.apply(r,e),r},setNextButtonText:function(e){this.getButton("next").setText(e)},setServerInfo:function(e){this.serverInfo=e},getServerInfo:function(){return Object.assign({},this.serverInfo)},setBucketEncryptStatus:function(e){this.bucketEncryptStatus=e},getBucketEncryptStatus:function(){return{is_encrypt:this.bucketEncryptStatus}},reloadData:function(e){this.getAllSteps().forEach(function(t){void 0!==t.reloadStore&&(t.reloadStore=e)})},setAllStepSize:function(){this.getAllSteps().forEach(function(e){e.setHeight(Math.max(this.height-155,155)),e.setWidth(Math.max(this.width-80,80)),e.doLayout()},this)},getValues:function(){return this.getAllSteps().reduce(function(e,t){return Ext.isFunction(t.getValues)&&(e[t.itemId]=t.getValues()),e},{})},onBeforeClose:function(){if(!this.isNeedCloseWarnMsg||!this.stepStack.includes("encryptBucketStep")&&!this.stepStack.includes("decryptBucketStep"))return!0;const e=this.findWindow(),t='

'+this.helper.T("warn","create_leave_content")+"

";return e.getMsgBox().confirm(this.helper.T("warn","create_leave_title"),t,function(e){"yes"===e&&(this.isNeedCloseWarnMsg=!1,this.close())},this,{yes:!0,no:!0},{useMessageTitle:!0,hideBrElement:!0}),!1},hasHistory:function(){if(this.stepStack.includes("summary"))return 0;return this.stepStack.filter(function(e){return"welcome"!==e&&"encryptBucketStep"!==e&&"decryptBucketStep"!==e}).length}}),Ext.define("SYNO.SDS.C2FS.Share.SetupC2FSForm",{extend:"SYNO.SDS.Utils.FormPanel",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){const t={title:this.helper.T("common","local_cache_form_title"),headline:this.helper.T("common","create_wizard_local_cache_rule"),border:!1,frame:!1,header:!1,width:"95%",layout:{type:"vbox"},items:[{xtype:"syno_displayfield",style:"padding: 4px 0 12px 0;",htmlEncode:!1,value:this.helper.T("common","local_cache_usage")},{xtype:"syno_compositefield",ref:"reservationSize",name:"reservation_size",items:[{xtype:"syno_displayfield",width:280,value:this.helper.T("attribute","local_reservation_size")+this.helper.T("common","colon")},{xtype:"syno_numberfield",ref:"sizeGb",name:"reservation_size_gb",style:"margin-left: 280px;",minValue:0,width:120,allowBlank:!1},{xtype:"syno_displayfield",width:20,name:"unit",value:"GB"}]},{xtype:"spacer",flex:1},{xtype:"syno_displayfield",htmlEncode:!1,style:e.bottomDisplayFieldStyle,value:''+this.helper.T("common","note")+this.helper.T("common","colon")+""+String.format(this.helper.T("common","local_cache_rule_description"),'',"")}]};return Ext.apply(t,e),t},validate:function(){return this.form.getForm().isValid()},getValues:function(){return this.form.getForm().getValues()}}),Ext.define("SYNO.SDS.C2FS.Share.AdvancedPermissionForm",{extend:"SYNO.SDS.Share.AdvanceForm",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([e])},loadPermissions:function(e,t){return new Promise(function(r,i){SYNO.SDS.ControlPanel.Share.isHomes(e.get("name"))&&Ext.getCmp(this.advSettingsSet).hide(),this.shareRecord=e,this.getForm().setValues(t),e.get("readonly")&&this.getForm().findField("disable_modify").disable(),e.get("is_aclmode")||this.getComponent("advFieldSet").hide(),r()}.bind(this))}}),Ext.define("SYNO.SDS.C2FS.Share.EditDialog",{extend:"SYNO.SDS.ModalWindow",helper:SYNO.SDS.C2FS.Helper,moveShareMsg:_T("share","init_status"),constructor:function(e){this.module=e.module,this.owner=e.owner,this.share=e.share,this.mode=e.mode,this.callParent([this.fillConfig(e)]),this.loadEachFormData(),this.mon(this,"deactivate",function(){return this.tabPanel.generalForm.stopPollRecycleStatus(),!0},this)},fillConfig:function(e){const t={title:String.format(this.helper.T("action","edit_title"),this.share.get("name")),width:860,height:570,layout:"fit",buttons:[{xtype:"syno_button",text:this.helper.T("common","alt_cancel"),scope:this,handler:function(){this.isAnyFormDirty()?this.getMsgBox().confirm(this.title,_T("common","confirm_lostchange"),function(e){"yes"===e&&this.close()},this):this.close()}},{xtype:"syno_button",text:this.helper.T("common","save"),btnStyle:"blue",scope:this,handler:function(){if(!this.isAnyFormDirty())return void this.close();if(!this.tabPanel.generalForm.getForm().isValid())return this.tabPanel.setActiveTab("generalForm"),void this.setStatusError({text:this.helper.T("error","error_bad_field"),clear:!0});if(!this.tabPanel.setupC2FSForm.getForm().isValid())return this.tabPanel.setActiveTab("setupC2FSForm"),void this.setStatusError({text:this.helper.T("error","error_bad_field"),clear:!0});if(!0===this.share.get("is_aclmode")&&"surveillance"===this.tabPanel.generalForm.shareName.getValue().toLowerCase())return void this.getMsgBox().alert(this.title,this.helper.T("share","share_acl_share_not_support"));let e=[];e=e.concat(this.tabPanel.permissionGrid.disabled?[]:this.tabPanel.permissionGrid.getWebAPI()),"yes"===this._D("supportNFS","no")&&_S("is_admin")&&(e=e.concat(this.tabPanel.nfsGrid.disabled?[]:this.tabPanel.nfsGrid.getWebAPI()));const t=this.getWebApiParamFromEachForm();e=e.concat([{api:"SYNO.C2FS.Share",method:"set",params:t,encryption:["shareinfo"],version:1}]),this.shareSetCheck(t).then(this.tempDisableWarn.bind(this)).then(this.unitPermissionWarn.bind(this)).then(this.shareSet.bind(this)).then(this.sendApplyRequest.bind(this,e))}}],items:this.createTabPanel(e)};return Ext.apply(t,e),t},createTabPanel:function(e){const t=[new SYNO.SDS.C2FS.Share.GeneralForm({module:this.module,ref:"generalForm",owner:this,shareStore:this.module.panel.store,highlightBox:{marginRight:12},openMode:"edit",itemId:"generalForm"}),new SYNO.SDS.C2FS.Share.SetupC2FSForm({module:e.module,ref:"setupC2FSForm",owner:this,itemId:"setupC2FSForm",bottomDisplayFieldStyle:"padding: 4px 0 12px 0;"}),new SYNO.SDS.C2FS.Share.PermissionGrid({module:this.module,owner:this,itemId:"permissionGrid",ref:"permissionGrid",disabled:!1===this.share.get("is_aclmode"),hidden:!1===this.share.get("is_aclmode"),hideCustomColumn:!SYNO.SDS.ControlPanel.Share.isCustomizable(this.share.data)}),new SYNO.SDS.C2FS.Share.AdvancedPermissionForm({module:this.module,owner:this,disabled:this.share.get("is_aclmode")&&"homes"===this.share.get("name").toLowerCase(),ref:"advancedPermissionForm",itemId:"advancedPermissionForm"})];"yes"===this._D("supportNFS","no")&&_S("is_admin")&&t.push(new SYNO.SDS.AdminCenter.Share.NFSGridPanel({module:this.module,owner:this,itemId:"nfsgrid",ref:"nfsGrid",blNfsEnabled:e.blNfsEnabled,blKerberosSupport:e.blKerberosSupport,blKerberosEnabled:e.blKerberosEnabled}));const r={itemId:"tab",ref:"tabPanel",activeTab:0,deferredRender:!1,useDefaultBtn:!1,items:t};return Ext.apply(r,e),new SYNO.SDS.Utils.TabPanel(r)},waitShareConfig:function(e,t,r){const i=this;return new Promise(function(n,s){return e().then(n,function(o){0!==t?setTimeout(function(){i.waitShareConfig(e,t-1,r).then(n,s)},r):s(o)})})},loadEachFormData:function(){this.setStatusBusy({text:this.helper.T("common","msg_waiting")}),this.share.get("in_transform")&&(this.tabPanel.generalForm.shareName.disable(),SYNO.ux.AddWhiteTipWithMsg(this.tabPanel.generalForm.shareName,this.helper.T("common","forbid_modify_in_transform")),this.tabPanel.setupC2FSForm.reservationSize.disable()),this.tabPanel.generalForm.shareName.resetValue(this.share.get("name")),this.tabPanel.generalForm.description.resetValue(this.share.get("desc")),this.tabPanel.setupC2FSForm.reservationSize.sizeGb.resetValue(this.share.get("reservation_size_mb")),_S("is_admin")&&this.tabPanel.generalForm.cleanRecyleBin.show(),this.tabPanel.generalForm.shareName.validator=(e=>{if(this.tabPanel.generalForm.shareName.originalValue.toLowerCase()===e.toLowerCase())return!0;if(SYNO.SDS.C2FS.Share.Utils.isNoSupportShareName(e))return this.helper.T("error","reserved_share_name");let t=!1;return this.module.panel.store.each(r=>{if(r.get("name").toLowerCase()===e.toLowerCase())return t=!0,!1}),!t||this.helper.T("share","share_already_exist")});this.waitShareConfig(function(e){return new Promise(function(t,r){e.reservation_size_mb?t():r(e)})}.bind(this,this.share.data),100,100).then(function(){this.processLoadEachForm()}.bind(this),function(e){SYNO.Debug("Share Config:",e),this.findWindow().getMsgBox().alert(this.title,this.helper.T("share","c2_need_package"),function(){this.findWindow().close()},this)}.bind(this))},processLoadEachForm:function(){const e=[{api:"SYNO.Core.Storage.Volume",method:"list",params:{limit:-1,offset:0,location:"internal"},version:1},{api:"SYNO.Core.Share",method:"get",version:1,params:{name:this.share.get("name"),additional:["recyclebin","disable_list","disable_modify","disable_download","unite_permission","is_aclmode","hidden","advance_setting"]}}];_S("is_admin")&&e.push({api:"SYNO.Core.RecycleBin",method:"get",version:1,params:{id:this.share.get("name")}}),this.sendWebAPIPromise({params:{},compound:{stopwhenerror:!1,params:e},scope:this}).then(e=>{const t=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Share","get"),r=Object.assign({},this.share.data,t);this.tabPanel.generalForm.enableRecyleBin.resetValue(t.enable_recycle_bin),t.enable_recycle_bin?(this.tabPanel.generalForm.recyleBinAdminOnly.resetValue(t.recycle_bin_admin_only),this.tabPanel.generalForm.cleanRecyleBin.enable()):(this.tabPanel.generalForm.recyleBinAdminOnly.disable(),this.tabPanel.generalForm.cleanRecyleBin.disable()),this.tabPanel.generalForm.disableBrowsable.resetValue(t.hidden),this.tabPanel.generalForm.hideUnreadable.resetValue(t.hide_unreadable);const i=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Storage.Volume","list").volumes.find(e=>e.volume_path===this.share.get("vol_path"));this.tabPanel.generalForm.readOnlyVolumePath.resetValue(SYNO.SDS.Utils.StorageUtils.VolumeNameRenderer(i)+this.helper.T("common","colon")+i.fs_type);const n=i.size_total_byte/1024/1024,s=1024*this.share.get("bucket_size_gb"),o=SYNO.SDS.C2FS.Share.Utils.minLocalCacheGB(),a=SYNO.SDS.C2FS.Share.Utils.idealLocalCacheGB({total_mb:n},{total_mb:s});if(Number.isNaN(a)&&this.getMsgBox().alert(this.title,String.format(this.helper.T("error","target_volume_no_space"),SYNO.SDS.Utils.CapacityRender(1024*o)),Ext.emptyFn),this.tabPanel.setupC2FSForm.reservationSize.sizeGb.validator=SYNO.SDS.C2FS.Share.Utils.genLocalReservationSizeForNewShareValidator(a,n,s,i.display_name),_S("is_admin")){const t=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.RecycleBin","get");this.tabPanel.generalForm.setRecycleStatus(t.is_cleaning)}return Promise.all([this.tabPanel.permissionGrid.loadFormData(this.share),this.tabPanel.advancedPermissionForm.loadPermissions(this.share,r)])}).catch(e=>{SYNO.Debug("webapi error:",e);const t=SYNO.API.getErrorString(SYNO.API.Response.GetFirstError(e))||this.helper.T("common","proc_conflict");this.getMsgBox().alert(this.title,t,()=>{this.close()},this)}).then(e=>{this.tabPanel.nfsGrid&&this.tabPanel.nfsGrid.getStore()&&this.tabPanel.nfsGrid.getStore().load(),this.clearStatusBusy()}).catch(e=>{SYNO.Debug("Promise reject:",e),this.clearStatusBusy()})},getWebApiParamFromEachForm:function(){const e=this.tabPanel.generalForm,t=this.tabPanel.advancedPermissionForm.getForm(),r=e.getForm().getValues(),i={original_name:e.shareName.originalValue,new_share_attribute:{description:e.description.isDirty()?r.description:null,is_browsable:e.disableBrowsable.isDirty()?!r.disableBrowsable:null,is_enable_recycle_bin:e.enableRecyleBin.isDirty()?r.enable_recycle_bin:null,is_recycle_bin_admin_only:e.recyleBinAdminOnly.isDirty()?r.recycle_bin_admin_only:null,is_hide_unreadable:e.hideUnreadable.isDirty()?r.hide_unreadable:null},new_share_basic_info:{reservation_size_mb:1024*this.tabPanel.setupC2FSForm.reservationSize.sizeGb.getValue(),name:e.shareName.getValue(),volume_path:this.share.get("vol_path")}};return t.isDirty()&&Object.assign(i.new_share_attribute,{is_disable_list:t.findField("disable_list").getValue(),is_disable_modify:t.findField("disable_modify").getValue(),is_disable_download:t.findField("disable_download").getValue(),is_unite_permission:t.findField("unite_permission").getValue()}),Object.keys(i.new_share_attribute).forEach(function(e){null!==i.new_share_attribute[e]&&void 0!==i.new_share_attribute[e]||delete i.new_share_attribute[e]}),i},shareSetCheck:function(e){return this.setStatusBusy({text:this.helper.T("common","msg_waiting")}),new Promise(function(t){this.sendWebAPI({api:"SYNO.C2FS.Share",method:"validate_set",params:e,encryption:["shareinfo"],version:1,scope:this,callback:function(e,r,i){this.clearStatusBusy(),e?t():r.code!=this.helper.ErrorMap.ERR_NOT_FEASIBLE?this.helper.popupErrorMessage(this,r.code):this.helper.popupFeasibilityCheckMsg(this,r.errors.feasibility_check,t)}})}.bind(this))},tempDisableWarn:function(){return new Promise(function(e){const t=[],r=this.tabPanel.generalForm;r.shareName.isDirty()&&t.push(String.format(this.helper.T("warn","set_temp_disable_by_rename"),r.shareName.getValue()));const i=0!==t.length,n=this.tabPanel.setupC2FSForm.reservationSize.sizeGb.getValue();if(this.tabPanel.setupC2FSForm.reservationSize.isDirty()&&n")+"

"+this.helper.T("common","ask_cont");s=i?this.helper.T("warn","set_temp_unaccessible"):this.helper.T("warn","set_local_cache_smaller_affect"),this.getMsgBox().confirm(this.title,s+o,function(t){"yes"===t&&e()},this)}.bind(this))},unitPermissionWarn:function(){return new Promise(function(e){const t=this.tabPanel.advancedPermissionForm.getForm().findField("unite_permission");t.isDirty()&&!0===t.getValue()?this.getMsgBox().alert(this.title,this.helper.T("share","warn_enable_advanced_permission"),function(){e()},this):e()}.bind(this))},shareSet:function(){const e={name:this.share.get("name"),is_sync_share:this.share.get("is_sync_share"),permissions:this.tabPanel.permissionGrid.getModifiedPermissions(),no_check_permission:this.tabPanel.advancedPermissionForm.isAdvPermissionDisabled()};return new Promise(function(t){SYNO.SDS.Utils.S2S.confirmIfSyncShareAffected(!1,e,{dialogTitle:this.title,dialogMsg:this.helper.T("s2s","s2s_warn_share_change_priv"),dialogOwner:this,continueHandler:t,abortHandler:this.clearStatusBusy(),scope:this})}.bind(this))},sendApplyRequest:function(e){this.setStatusBusy({text:this.helper.T("common","msg_waiting")}),this.sendWebAPI({params:{},compound:{stopwhenerror:!0,params:e},encryption:["shareinfo"],scope:this,callback:function(e,t,r){this.clearStatusBusy();const i=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Share.Permission","set"),n=SYNO.API.Response.GetValByAPI(t,"SYNO.C2FS.Share","set");if(!e||t.has_fail){let e="";if(n&&n.code)switch(n.code){case this.helper.ErrorMap.ERR_CACHE_SIZE_TOO_LOW:e=String.format(this.helper.ErrorMap[n.code],Math.ceil(n.errors.local_cache_lower_limit_mb/1024));break;case this.helper.ErrorMap.ERR_UNSYNC_EXCEED_CACHE_SIZE:e=String.format(this.helper.ErrorMap.T(n.code),Math.ceil(n.errors.local_cache_lower_limit_mb/1024));break;default:e=this.helper.ErrorMap.T(n.code)}return i&&i.code&&(e=e||SYNO.API.Errors.core[i.code]),void this.getMsgBox().alert(this.title,e||this.helper.T("common","error_system"))}n&&n.name?(this.module.getPanel().fireEvent("sharefolderchanged",n.name),SYNO.SDS.StatusNotifier.fireEvent("sharefolderchanged","permission"),i&&i.is_ftp_anonymous_chroot_conflict?this.tabPanel.permissionGrid.confirmToShowFTPAdvancedSetting({closeDialog:!0}):this.close()):this.close()}})},isAnyFormDirty:function(){return this.tabPanel.generalForm.isFormDirty()||this.tabPanel.setupC2FSForm.isFormDirty()||this.tabPanel.permissionGrid.isChanged()||this.tabPanel.advancedPermissionForm.getForm().isDirty()||this.tabPanel.nfsGrid&&0!==this.tabPanel.nfsGrid.dataModified}}),Ext.ns("SYNO.SDS.C2FS.Share.FullResync"),SYNO.SDS.C2FS.Share.FullResync={helper:SYNO.SDS.C2FS.Helper,generateIssue:function(e){return{level:this.helper.T("common","info"),levelClass:"blue-status",event:String.format(this.helper.T("issue","event_full_resync"),e.toFixed(2)),summary:this.helper.T("issue","summary_full_resync"),suggest:"-"}}},Ext.define("SYNO.SDS.C2FS.Share.Issue",{extend:"SYNO.SDS.ModalWindow",helper:SYNO.SDS.C2FS.Helper,initActionLink:!1,constructor:function(e){this.shareName=e.shareName,this.updateData=e.updateData,this.share=e.share,this.callParent([this.fillConfig(e)])},fillConfig:function(e){this.store=this.createStore(),this.gridPanel=this.createGridPanel();const t={title:String.format(this.helper.T("common","share_issue"),this.shareName),layout:"fit",width:820,height:560,items:[this.gridPanel],listeners:{scope:this,afterrender:function(){setTimeout(()=>{this.maskWindow();const e=this.generateIssues(this.filterStatus());this.store.loadData(e),this.unmaskWindow()},0)},afterlayout:function(){this.momActionLink()},destroy:function(){this.unregister()}},buttons:[{xtype:"syno_button",text:this.helper.T("common","alt_close"),scope:this,handler:function(){this.close()}}]};return Ext.apply(t,e),t},createStore:function(){return new Ext.data.JsonStore({autoDestroy:!0,fields:["level","levelClass","event","summary","suggest","suggestPartNeedLink","suggestLinkAdditionalEvent"]})},createGridPanel:function(){return new SYNO.ux.GridPanel({store:this.store,border:!1,enableHdMenu:!1,autoExpandColumn:!0,view:new SYNO.ux.FleXcroll.grid.GridView,colModel:new Ext.grid.ColumnModel({columns:[{width:30,dataIndex:"level",header:this.helper.T("common","issue_level"),renderer:function(e,t,r){return String.format('',r.get("levelClass"))+this.helper.toolTipRenderer(e,t,r)+""}.bind(this)},{width:75,header:this.helper.T("common","issue_event"),dataIndex:"event",renderer:function(e,t,r){return''+this.helper.toolTipRenderer(e)+""}.bind(this)},{header:this.helper.T("common","issue_summary"),dataIndex:"summary",renderer:function(e,t,r){return''+this.helper.toolTipRenderer(e)+""}.bind(this)},{header:this.helper.T("common","issue_suggest"),dataIndex:"suggest",renderer:this.suggestRender.bind(this)}]})})},suggestRender:function(e,t,r){const i=e=>{const t=e.replace(/{.}/g,""),r=Ext.util.Format.htmlEncode(t);return Ext.util.Format.htmlEncode(r)},n=e=>`\n ${e}\n `;if(r.get("suggestPartNeedLink")){if(!e||"-"===e)return"-";const t=``,s="",o=String.format(e,t,s);return n(`${o}`)}if(r.get("suggestLinkAdditionalEvent")){const t=``,s="",o=String.format(e,t,s);return n(`${o}`)}return n(this.helper.toolTipRenderer(e))},filterStatus:function(){const e=this.updateData.status.filter(e=>"full_resync"===e),t=this.updateData.status.filter(SYNO.SDS.C2FS.Share.Utils.isWarningStatus),r=this.updateData.status.filter(SYNO.SDS.C2FS.Share.Utils.isErrorStatus);return r.length>0?r.concat(e):t.length>0?t.concat(e):e},generateIssues:function(e){const t=[];return e.forEach(function(e){switch(e){case"no_config":t.push({level:this.helper.T("error","error_error"),levelClass:"red-status",event:this.helper.T("issue","event_no_config"),summary:this.helper.T("issue","summary_no_config"),suggest:this.helper.T("issue","suggest_no_config")});break;case"slow_uploading":{const e=this.updateData.unsync_data_mb/this.updateData.sync_speed_mb_s;t.push({level:this.helper.T("error","error_system_abnormal_warning"),levelClass:"orange-status",event:this.helper.T("issue","event_slow_uploading"),summary:String.format(this.helper.T("issue","summary_slow_uploading"),this.helper.timeRender(e,"m")),suggest:this.helper.T("issue","suggest_slow_uploading"),suggestPartNeedLink:"https://www.synology.com/company/contact_us"});break}case"volume_full":t.push({level:this.helper.T("error","error_error"),levelClass:"red-status",event:this.helper.T("issue","event_volume_full_v2"),summary:this.helper.T("issue","summary_volume_full_v2"),suggest:this.helper.T("issue","suggest_volume_full_v2")});break;case"disconnected":t.push({level:this.helper.T("error","error_error"),levelClass:"red-status",event:this.helper.T("issue","event_disconnected"),summary:this.helper.T("issue","summary_disconnected"),suggest:this.helper.T("issue","suggest_disconnected"),suggestPartNeedLink:"https://www.synology.com/company/contact_us"});break;case"incompatible":t.push({level:this.helper.T("error","error_error"),levelClass:"red-status",event:this.helper.T("issue","event_version_incompatible"),summary:this.helper.T("issue","summary_version_incompatible"),suggest:this.helper.T("issue","suggest_version_incompatible")});break;case"unauth":t.push({level:this.helper.T("error","error_error"),levelClass:"red-status",event:this.helper.T("issue","event_unauth"),summary:this.helper.T("issue","summary_unauth"),suggest:this.helper.T("issue","suggest_unauth_v2"),suggestLinkAdditionalEvent:{id:Ext.id(),eventType:"click",eventAction:this.reAuth}});break;case"in_write_throttle":t.push({level:this.helper.T("error","error_system_abnormal_warning"),levelClass:"orange-status",event:this.helper.T("issue","event_in_write_throttle"),summary:this.helper.T("issue","summary_in_write_throttle_v2"),suggest:this.helper.T("issue","suggest_in_write_throttle_v2")});break;case"c2_space_full":t.push({level:this.helper.T("error","error_error"),levelClass:"red-status",event:this.helper.T("issue","event_c2_space_full"),summary:this.helper.T("issue","summary_c2_space_full"),suggest:this.helper.T("issue","suggest_c2_space_full")});break;case"full_resync":t.push(SYNO.SDS.C2FS.Share.FullResync.generateIssue(this.updateData.full_resync_progress.progress));break;case"in_grace":t.push({level:this.helper.T("error","error_error"),levelClass:"red-status",event:this.helper.T("issue","event_in_grace"),summary:this.helper.T("issue","summary_in_grace"),suggest:this.helper.T("issue","suggest_in_grace"),suggestPartNeedLink:SYNO.SDS.C2FS.Utils.C2WebHandler.getEverestUrl()+"/hybrid_share"});break;case"in_downgrade":t.push({level:this.helper.T("error","error_error"),levelClass:"red-status",event:this.helper.T("issue","event_total_c2_usage_exceeded"),summary:this.helper.T("issue","summary_total_c2_usage_exceeded"),suggest:this.helper.T("issue","suggest_in_downgrade"),suggestPartNeedLink:SYNO.SDS.C2FS.Utils.C2WebHandler.getEverestUrl()+"/hybrid_share"});break;case"bad_space_usage":t.push({level:this.helper.T("error","error_error"),levelClass:"red-status",event:this.helper.T("issue","event_bad_space_usage"),summary:this.helper.T("issue","summary_bad_space_usage"),suggest:this.helper.T("issue","suggest_bad_space_usage"),suggestLinkAdditionalEvent:{id:Ext.id(),eventType:"click",eventAction:this.activate}});break;case"share_offline":t.push({level:this.helper.T("error","error_error"),levelClass:"red-status",event:this.helper.T("issue","event_share_offline"),summary:this.helper.T("issue","summary_share_offline"),suggest:this.helper.T("issue","suggest_share_offline")})}}.bind(this)),t},momActionLink:function(){this.initActionLink||this.store.each(e=>{const t=e.get("suggestLinkAdditionalEvent");t&&(Ext.get(t.id).on({scope:this,[t.eventType]:t.eventAction}),this.initActionLink=!0)})},reAuth:function(){this.popC2LoginWeb()},activate:async function(){try{this.maskWindow(),await this.sendWebAPIPromise({api:"SYNO.C2FS.Share",method:"mount",version:1,params:{fsid:this.updateData.share_id}}),this.close()}catch(e){this.helper.popupErrorMessage(this.appWin,e.code,Ext.emptyFn),SYNO.Debug(e)}finally{this.unmaskWindow()}},popC2LoginWeb:function(){this.unregister();const e=SYNO.SDS.C2FS.Utils.C2WebHandler.generateUrl("c2share/reauth"),t=SYNO.SDS.C2FS.NPM.nodeRSA();this.rsaKey=new t({b:1024}),this.register(this.c2PostMessageManager.bind(this),"C2Share"),this.popup=window.open(e,"mywindow","menubar=1, resizable=0, width=1080, height=800, top=100, left=300"),this.popup||this.messageAlert(this.helper.T("warn","popup_c2_web_failed"))},register:function(e,t){const r=this;this.receiveMessage=function(i){/setImmediate/.test(i.browserEvent.data)||i.browserEvent.data.pkg_name===t&&e.call(r,i.browserEvent)},Ext.EventManager.addListener(window,"message",this.receiveMessage)},unregister:function(){Ext.EventManager.removeListener(window,"message",this.receiveMessage)},sendWebApiForDsInfo:async function(){return this.sendWebAPIPromise({api:"SYNO.C2FS.Utils",method:"get_ds_info",version:1,scope:this})},responseDsInfoAndShareId:async function(e){try{const t=await this.sendWebApiForDsInfo();this.popup.postMessage({shareId:this.updateData.share_id,ds_info:t,rsa_pub_key:this.rsaKey.exportKey("pkcs8-public-pem")},e.origin)}catch(e){this.helper.popupErrorMessage(this.appWin,e.code,Ext.emptyFn)}},reAuthFromServerEvent:async function(e){try{this.maskWindow(),await this.sendWebAPIPromise({api:"SYNO.C2FS.Share",method:"reauth",version:1,encryption:["c2share_api_url","share_id","scoped_c2auth_access_tokens","scoped_c2auth_public_key","scoped_c2auth_private_key"],params:{c2share_api_url:e.data.c2_api_url,share_id:this.updateData.share_id,scoped_c2auth_access_tokens:this.rsaKey.decrypt(e.data.access_tokens,"json"),scoped_c2auth_public_key:this.rsaKey.decrypt(e.data.public_key,"base64"),scoped_c2auth_private_key:this.rsaKey.decrypt(e.data.private_key,"base64")}}),this.close()}catch(e){SYNO.Debug(this),this.messageAlert(this.helper.T("error","reauth_share_failed"))}finally{this.unmaskWindow()}},c2PostMessageManager:function(e){if(SYNO.SDS.C2FS.Utils.C2WebHandler.isKnownOrigin(e.origin))switch(e.data.cmd){case"get_share_id":this.responseDsInfoAndShareId(e);break;case"reauth":this.reAuthFromServerEvent(e)}},maskWindow:function(){this.setStatusBusy({text:this.helper.T("common","msg_waiting")})},unmaskWindow:function(){this.clearStatusBusy()},messageAlert:function(e){this.getMsgBox().alert(this.title,e)}}),Ext.ns("SYNO.SDS.C2FS.Share.Status"),SYNO.SDS.C2FS.Share.Status={helper:SYNO.SDS.C2FS.Helper,shareUtils:SYNO.SDS.C2FS.Share.Utils,setDisable:function(e){e.set("condition",this.helper.T("common","disabled")),e.set("conditionCls","red-status"),e.set("localCacheSize",this.helper.T("common","disabled")),e.set("localCacheUsage",this.helper.T("common","disabled")),e.set("bucketStorageSize",this.helper.T("common","disabled")),e.set("bucketStorageUsage",this.helper.T("common","disabled")),e.set("uploadQueue",this.helper.T("common","disabled")),e.set("uploadStatus",this.helper.T("common","disabled")),e.set("bucketAccount",this.helper.T("common","disabled")),e.set("zone",this.helper.T("common","disabled")),e.set("protection",this.helper.T("common","disabled"))},setLoadingForStatus(e){e.set("condition",this.helper.T("common","loading")),e.set("conditionCls","blue-status"),e.set("localCacheSize","-"),e.set("localCacheUsage","-"),e.set("bucketStorageSize","-"),e.set("bucketStorageUsage","-"),e.set("bucketAccount","-"),e.set("zone","-"),e.set("protection","-"),e.set("uploadQueue",SYNO.SDS.Utils.CapacityRender(0))},setLoading:function(e){e.set("bucketName","-"),this.setLoadingForStatus(e),e.set("uploadStatus",SYNO.SDS.C2FS.Helper.capacityRender(0)+"/s")},validateData:function(e){return!!(e&&Array.isArray(e.status)&&Array.isArray(e.enabled_feature)&&Object.prototype.hasOwnProperty.call(e,"bucket_total_mb")&&Object.prototype.hasOwnProperty.call(e,"bucket_used_mb")&&Object.prototype.hasOwnProperty.call(e,"reservation_size_mb")&&Object.prototype.hasOwnProperty.call(e,"cache_used_mb")&&Object.prototype.hasOwnProperty.call(e,"sync_speed_mb_s")&&Object.prototype.hasOwnProperty.call(e,"unsync_data_mb")&&Object.prototype.hasOwnProperty.call(e,"synology_account"))},fillInvalidData:function(e){e||(e={}),Array.isArray(e.status)||(e.status=[]),e.bucket_total_mb||(e.bucket_total_mb=0),e.bucket_used_mb||(e.bucket_used_mb=0),e.reservation_size_mb||(e.reservation_size_mb=0),e.cache_used_mb||(e.cache_used_mb=0),e.sync_speed_mb_s||(e.sync_speed_mb_s=0),e.unsync_data_mb||(e.unsync_data_mb=0),e.synology_account||(e.synology_account="-"),e.zone||(e.zone="-"),Array.isArray(e.enabled_feature)||(e.enabled_feature=[])},setCondition:function(e,t,r){const i=t.status.filter(e=>this.shareUtils.isNormalStatus(e)),n=t.status.filter(e=>this.shareUtils.isWarningStatus(e)),s=t.status.filter(e=>this.shareUtils.isErrorStatus(e));if(s.length>1)return e.set("condition",this.helper.addLinkForString(r,this.helper.T("status","multi_abnormal_status"),s.length)),e.set("conditionCls","red-status"),void e.set("statusIconCls","c2-share-offline-icon");if(e.set("statusIconCls","syno-admincenter-c2share-icon"),s.length>0)return e.set("conditionCls","red-status"),e.set("condition",this.generateErrorStatus(s,r)),this.containOfflineStatus(s)&&e.set("statusIconCls","c2-share-offline-icon"),void(this.hasFatalErrorStatus(s)&&this.setDisable(e));if(n.length>0)return e.set("conditionCls","orange-status"),void e.set("condition",this.generateWarningStatus(n,r));switch(i[0]){case void 0:case"nothing_need_upload":case"uploading":return e.set("condition",this.helper.T("status","connected")),void e.set("conditionCls","green-status");case"resync":return e.set("condition",String.format(this.helper.T("status","full_resync"),t.resync_progress.progress.toFixed(2))),void e.set("conditionCls","blue-status");case"confirming_connection":return e.set("condition",this.helper.T("status","confirming_connection")),void e.set("conditionCls","blue-status");case"building":return e.set("condition",this.helper.T("status","building")),void e.set("conditionCls","blue-status");default:return SYNO.Debug("Unknown hybrid share status ",i[0]),e.set("condition",this.helper.T("common","disabled")),void e.set("conditionCls","red-status")}},calculateCheckFilesCount:function(e){try{const t=e.transform_to_c2_progress.dir_count+e.transform_to_c2_progress.file_count;return isNaN(t)?0:t}catch(t){return SYNO.Debug("Bad newData",e),SYNO.Debug(t),0}},setRecordAsTransformCheck:function(e,t){e.set("condition",String.format(this.helper.T("status","transform_check"),this.calculateCheckFilesCount(t))),e.set("statusIconCls","c2-share-offline-icon"),e.set("conditionCls","blue-status")},setRecordAsTransformCancel:function(e){e.set("condition",this.helper.T("status","transform_cancel")),e.set("statusIconCls","c2-share-offline-icon"),e.set("conditionCls","blue-status")},getTransformProgress:function(e){try{return e.transform_to_c2_progress.progress.toFixed(2)}catch(t){return SYNO.Debug("Bad newData",e),SYNO.Debug(t),0}},generatePrefixStatusInTransform(e,t){switch(e[0]){case"transform_upload":return String.format(this.helper.T("status","transform_upload"),this.getTransformProgress(t));case"confirming_connection":case"transform_prepare":return this.helper.T("status","transform_prepare");default:return SYNO.Debug("Unknown hybrid share status ",e[0]),String.format(this.helper.T("status","transform_upload"),this.getTransformProgress(t))}},reflectWarningStatusToString:function(e){switch(e){case"slow_uploading":return this.helper.T("status","slow_uploading");case"in_write_throttle":return this.helper.T("status","in_write_throttle");default:return SYNO.Debug("Unknown warning status ",e),""}},generateWarningStatusWithPrefix:function(e,t,r){const i=e+this.helper.periodForConcat();return t.length>1?this.helper.addLinkForString(r,i+this.helper.T("status","multi_abnormal_status"),t.length):this.helper.addLinkForString(r,i+this.reflectWarningStatusToString(t[0]))},generateWarningStatus:function(e,t){return e.length>1?this.helper.addLinkForString(t,this.helper.T("status","multi_abnormal_status"),e.length):this.helper.addLinkForString(t,this.reflectWarningStatusToString(e[0]))},reflectErrorStatusToString:function(e){switch(e){case"disconnected":return this.helper.T("status","disconnected");case"incompatible":return this.helper.T("status","version_incompatible");case"unauth":return this.helper.T("status","unauth");case"no_config":return this.helper.T("status","no_config");case"volume_full":return this.helper.T("status","volume_full_v2");case"c2_space_full":return this.helper.T("status","c2_space_full");case"in_grace":return this.helper.T("status","in_grace");case"in_downgrade":return this.helper.T("status","in_downgrade");case"disable":return this.helper.T("common","disabled");case"bad_space_usage":return this.helper.T("status","bad_space_usage");case"share_offline":return this.helper.T("status","share_offline");default:return SYNO.Debug("Unknown error status ",e),this.helper.T("common","disabled")}},generateErrorStatusWithPrefix:function(e,t,r){const i=e+this.helper.periodForConcat();return t.length>1?this.helper.addLinkForString(r,i+this.helper.T("status","multi_abnormal_status"),t.length):this.helper.addLinkForString(r,i+this.reflectErrorStatusToString(t[0]))},generateErrorStatus:function(e,t){return e.length>1?this.helper.addLinkForString(t,this.helper.T("status","multi_abnormal_status"),e.length):this.helper.addLinkForString(t,this.reflectErrorStatusToString(e[0]))},containOfflineStatus:function(e){return null!=e.find(e=>{["unauth","no_config","version_incompatible","disconnected","bad_space_usage","disable","share_offline"].includes(e)})},hasFatalErrorStatus:function(e){return null!=e.find(e=>{["no_config","disable","share_offline"].includes(e)})},setTransformCondition:function(e,t,r){const i=t.status.filter(e=>this.shareUtils.isNormalStatus(e));if(i.includes("transform_cancel"))return void this.setRecordAsTransformCancel(e);if(i.includes("transform_check"))return void this.setRecordAsTransformCheck(e,t);e.set("statusIconCls","syno-admincenter-c2share-icon");const n=this.generatePrefixStatusInTransform(i,t),s=t.status.filter(e=>this.shareUtils.isWarningStatus(e)),o=t.status.filter(e=>this.shareUtils.isErrorStatus(e));return o.length>0?(e.set("conditionCls","red-status"),e.set("condition",this.generateErrorStatusWithPrefix(n,o,r)),this.containOfflineStatus(o)&&e.set("statusIconCls","c2-share-offline-icon"),void(this.hasFatalErrorStatus(o)&&this.setDisable(e))):s.length>0?(e.set("conditionCls","orange-status"),void e.set("condition",this.generateWarningStatusWithPrefix(n,s,r))):(e.set("condition",n),void e.set("conditionCls","blue-status"))},setRestoreCondition:function(e){e.set("condition",this.helper.T("status","restore")),e.set("conditionCls","blue-status")},isUseLimitMeetBucket:function(e){return e&&e.bucket_total_mb&&e.transform_to_c2_progress&&e.transform_to_c2_progress.used_limit_gb?e.bucket_total_mb===1024*e.transform_to_c2_progress.used_limit_gb:(SYNO.Debug("Bad data",e),!1)},hasTransformStatus:function(e){return e?e.filter(e=>e.includes("transform")).length>0:(SYNO.Debug("Bad status",e),!1)},hasRestoreStatus:function(e){return e?e.filter(e=>e.includes("restore")).length>0:(SYNO.Debug("Bad status",e),!1)},update:function(e,t,r){if(this.validateData(t)||SYNO.Debug("Bad status",t),this.fillInvalidData(t),e.set("localCacheSize",SYNO.SDS.Utils.CapacityRender(t.reservation_size_mb)),e.set("localCacheUsage",SYNO.SDS.Utils.CapacityRender(t.cache_used_mb)),e.set("bucketStorageSize",SYNO.SDS.Utils.CapacityRender(t.bucket_total_mb)),e.set("bucketAccount",t.synology_account?t.synology_account:this.helper.T("common","disabled")),e.set("zone",t.zone.toUpperCase()),e.set("bucketStorageUsage",SYNO.SDS.Utils.CapacityRender(t.bucket_used_mb)+" ("+this.helper.percentRender(t.bucket_used_mb,t.bucket_total_mb)+")"),e.set("uploadQueue",SYNO.SDS.Utils.CapacityRender(t.unsync_data_mb)),t.status.includes("resync"))e.set("uploadStatus",this.helper.T("status","pause_syncing_file"));else if(t.status.includes("uploading")||t.status.includes("transform_upload"))if(t.unsync_data_mb<.01||0===t.sync_speed_mb_s)e.set("uploadStatus",this.helper.T("status","syncing_file"));else{const r=t.unsync_data_mb/t.sync_speed_mb_s;e.set("uploadStatus",SYNO.SDS.C2FS.Helper.capacityRender(1024*t.sync_speed_mb_s,2)+"/s, "+String.format(this.helper.T("status","remain"),this.helper.timeRender(r,"s")))}else e.set("uploadStatus",SYNO.SDS.C2FS.Helper.capacityRender(0,2)+"/s");t.enabled_feature.includes("snapshot")?e.set("protection",this.helper.T("common","enable")):e.set("protection",this.helper.T("common","not_enable")),e.set("bucketName",Object.prototype.hasOwnProperty.call(t,"bucket_name")?t.bucket_name:"-"),this.hasTransformStatus(t.status)?(this.setTransformCondition(e,t,r),e.set("localCacheUsagePostfix",this.helper.addWhiteTipHtml(this.getWhiteTipForLocalCacheUsageInTransform(e,t)))):this.hasRestoreStatus(t.status)?(this.setRestoreCondition(e),e.set("localCacheUsagePostfix",this.helper.addWhiteTipHtml(String.format(this.helper.T("common","local_usage_description"),'',"")))):(this.setCondition(e,t,r),e.set("localCacheUsagePostfix",this.helper.addWhiteTipHtml(String.format(this.helper.T("common","local_usage_description"),'',""))))},getWhiteTipForLocalCacheUsageInTransform:function(e,t){if(this.isUseLimitMeetBucket(t)){const e="Hybrid Share Beta";return String.format(this.helper.T("transform","local_usage_meet_c2_description"),e,SYNO.SDS.Utils.CapacityRender(t.bucket_total_mb))}return String.format(this.helper.T("transform","local_usage_description"),e.get("status"),SYNO.SDS.Utils.CapacityRender(1024*t.transform_to_c2_progress.volume_size_gb))},category:function(e){return'
'+e+"
"},key:function(e){return'
'+e+this.helper.T("common","colon")+"
"},value:function(e){return'
'+e+"
"},record:function(e,t){return'
'+this.key(e)+this.value(t)+"
"},displayForServerSite:function(){return this.category(this.helper.T("common","c2"))+this.record(this.helper.T("common","quota"),"{bucketStorageSize}")+this.record(this.helper.T("common","usage"),"{bucketStorageUsage}")+this.record(this.helper.T("common","synology_account"),"{bucketAccount}")+this.record(this.helper.T("common","zone"),"{zone}")+this.record(this.helper.T("common","protection"),"{protection}")},displayForLocalSite:function(){return this.category(this.helper.T("common","local_cache_form_title"))+this.record(this.helper.T("attribute","local_reservation_size_display"),"{localCacheSize}")+this.record(this.helper.T("status","cache_usage"),"{localCacheUsage}{LocalCacheUsagePostfix}")+this.record(this.helper.T("status","upload_queue"),"{uploadQueue}")+this.record(this.helper.T("status","upload_status"),"{uploadStatus}")}},Ext.ns("SYNO.SDS.C2FS"),SYNO.SDS.C2FS.UtilForDSM={helper:SYNO.SDS.C2FS.Helper,shareStatus:SYNO.SDS.C2FS.Share.Status,object:new Ext.Component,listWebapiTask:null,shareStore:null,getAndCheckNotSupportReason:function(){return"no"===_D("support_c2fs","no")||"Beijing"===_S("timezone")?_T("share","c2_not_support"):!0===_S("is_hybrid_ha")?this.helper.T("error","hybrid_ha_is_running"):""},exclusiveDeleteErrorMsg:function(e){if(!e)return[];const t=[];return t.push(this.helper.ErrorMap.T(e.code)||this.helper.T("common","error_system")),t},exclusiveValidateDeleteWarnMsg:function(e){if(!e)return[];const t=[];return t.push(this.helper.ErrorMap.T(e.code)||this.helper.T("common","error_system")),t},c2ShareTpl:function(){return(new Ext.XTemplate).html},c2ShareInnerTpl:function(){return new Ext.XTemplate(this.shareStatus.displayForServerSite(),this.shareStatus.displayForLocalSite()).html},updateC2ShareRecord:function(e,t,r){this.updateOldInfoOfShare(e.get("name"),t),this.shareStatus.update(e,t,r),e.set("in_transform",this.shareStatus.hasTransformStatus(t.status)),e.set("reservation_size_mb",t.reservation_size_mb/1024),e.set("bucket_size_gb",t.bucket_total_mb/1024),e.set("local_cache_used_gb",t.cache_used_mb/1024)},onPackageStatusChange:function(e){"start"!==e&&(this.listWebapiTask&&this.listWebapiTask.stop(),this.shareStore.each(function(e){!1!==e.get("is_c2_share")&&(e.beginEdit(),this.shareStatus.setDisable(e),e.set("condition",this.helper.T("share","c2_no_package_status")),e.endEdit())}.bind(this)))},initTransformC2ShareWizard:function(e){return new SYNO.SDS.C2FS.Share.Transform.Wizard(e)},canTransformToC2Share:function(e){return!1===e.get("is_c2_share")},initEvents:function(e){const t=function(){this.listWebapiTask&&this.listWebapiTask.stop(),SYNO.SDS.Packages.unregisterPackageStatusChange(this.onPackageStatusChange,this)}.bind(this);t(),this.object.clearMons(),this.object.mon(e,"beforedestroy",t,this,{single:!0}),this.object.mon(e,"deactivate",t,this,{single:!0}),SYNO.SDS.Packages.registerPackageStatusChange(this.onPackageStatusChange,this,this.helper.PKG_ID)},updateOldInfoOfShare:function(e,t){this.shareOldData||(this.shareOldData={}),this.shareStatus.validateData(t)||SYNO.Debug("Bad info: ",t),this.shareOldData[e]=t},fetchInfoOfC2Share:function(e){if(!e||!e.suspendEvents||!e.each)return;if(this.shareStore=e,this.initEvents(e.appWindow.activePage),!SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.C2FS.Application"))return void e.each(function(e){!1!==e.get("is_c2_share")&&(e.beginEdit(),this.shareStatus.setDisable(e),e.set("condition",this.helper.T("share","c2_no_package_status")),e.endEdit())}.bind(this));if(-1===e.find("is_c2_share",!0))return;this.shareStatusLink||(this.shareStatusLink={}),this.shareOldData||(this.shareOldData={}),e.each(e=>{!1!==e.get("is_c2_share")&&(Object.prototype.hasOwnProperty.call(this.shareStatusLink,e.get("name"))||(this.shareStatusLink[e.get("name")]=Ext.id()),this.shareOldData[e.get("name")]?this.updateC2ShareRecord(e,this.shareOldData[e.get("name")],this.shareStatusLink[e.get("name")]):this.shareStatus.setLoading(e))});const t=()=>{SYNO.Assert(null===this.listWebapiTask),this.listWebapiTask=this.object.addWebAPITask({interval:5e3,api:"SYNO.C2FS.Share",method:"list",version:1,scope:this,callback:this.shareListPollingCallback}).start()};this.listWebapiTask?this.listWebapiTask.start():SYNO.API.currentManager.queryAPI("SYNO.C2FS.Share",t,this),this.object.sendWebAPIPromise({api:"SYNO.C2FS.Account",method:"fetch_info",version:1})},shareListPollingCallback:function(e,t){return this.shareStore.suspendEvents(!1),this.shareStore.each(function(r){if(!1===r.get("is_c2_share"))return;if(!1===e||!t)return SYNO.Debug("Failed to list hybrid share, err:",t),this.shareStatus.setDisable(r),void(t&&t.error&&(t.error.code==this.helper.ErrorMap.ERR_NO_SUCH_API||t.error.code==this.helper.ErrorMap.ERR_NO_SUCH_METHODS)&&(r.set("condition",this.helper.T("share","c2_no_package_status")),r.set("conditionCls","red-status")));const i=t[r.get("name")];if(!i)return this.shareStatus.setDisable(r),delete this.shareOldData[r.get("name")],void(0==this.shareStore.appWindow.ctMaskCnt&&this.shareStore.load());this.updateC2ShareRecord(r,i,this.shareStatusLink[r.get("name")])}.bind(this)),this.shareStore.resumeEvents(),this.shareStore.fireEvent("datachanged",this.shareStore),Object.keys(this.shareStatusLink).forEach(function(e){const r=this.shareStatusLink[e];if(!Ext.get(r))return!1;Ext.get(r).on({scope:this,click:function(){new SYNO.SDS.C2FS.Share.Issue({owner:this.shareStore.appWindow,shareName:e,updateData:t[e],share:this.shareStore.getById(e)}).onOpen()}},this)}.bind(this)),!1},initCreateC2ShareWizard:function(e){return new SYNO.SDS.C2FS.Wizard(e)},initEditC2ShareWizard:function(e){return new SYNO.SDS.C2FS.Share.EditDialog(e)}},Ext.define("SYNO.SDS.C2FS.Share.Transform.WelcomeStep",{extend:"SYNO.SDS.Wizard.WelcomeStep",helper:SYNO.SDS.C2FS.Helper,OpError:class extends Error{constructor(e,t){super(e),this.alert=t}},constructor:function(e){this.shareStore=e.module.panel.store,this.targetShare=e.share,this.callParent([this.fillConfig(e)])},fillConfig:function(e){const t={headline:this.helper.T("common","hybrid_share"),items:[this.createPanel()],listeners:{destroy:this.unregister}};return Ext.apply(t,e),t},sendWebAPIPromiseAndPendingWithStatus:async function(e,t){try{return this.appWin.setStatusBusy(t),await this.sendWebAPIPromise(e)}finally{this.appWin.clearStatusBusy()}},getVolumeInfo:async function(){return await this.sendWebAPIPromise({api:"SYNO.Core.Storage.Volume",method:"get",version:1,params:{volume_path:this.targetShare.get("vol_path")}})},getShareQuotaStatus:async function(){return await this.sendWebAPIPromise({api:"SYNO.C2FS.Utils",method:"get_share_quota_status",version:1,params:{share_name:this.targetShare.get("name")}})},isVolumeSizeValid:function(e){return e>=SYNO.SDS.C2FS.Share.Utils.basicVolumeSizeGB()},checkReasonForInvalidVolume:function(e){const t=e.size_total_byte/1024/1024/1024;if(!this.isVolumeSizeValid(t)){const e=SYNO.SDS.C2FS.Share.Utils.basicVolumeSizeGB();return String.format(this.helper.T("warn","transform_volume_not_enough"),SYNO.SDS.Utils.CapacityRender(1024*e))}return""},checkReasonForInvalidQuotaStatus:function(e){return"convertable"===e?String.format(this.helper.T("warn","transform_volume_quota_convertable")):""},popupWarningMessage:function(e){this.appWin.getMsgBox().confirm(this.appWin.title,e,e=>{"yes"!==e&&this.appWin.close()})},popupForbidMessage:function(e){this.appWin.getMsgBox().alert(this.appWin.title,e,()=>this.appWin.close())},loadShare:function(e){return new Promise((t,r)=>{const i=function(){this.shareStore.removeListener("exception",n,this),t(this.shareStore.getById(e))},n=function(e){this.shareStore.removeListener("load",i,this),r(new Error(`Failed to load share store, err: [${e}].`))};this.shareStore.addListener("load",i,this,{single:!0}),this.shareStore.addListener("exception",n,this,{single:!0}),this.shareStore.load()})},validateSourceShareFlow:async function(){try{this.appWin.setStatusBusy(),this.targetShare=await this.loadShare(this.targetShare.id);const e=this.checkReasonForCannotTransform();if(e)return this.appWin.clearStatusBusy(),void this.popupForbidMessage(e);const[{volume:t},{status:r}]=await Promise.all([this.getVolumeInfo(),this.getShareQuotaStatus()]);this.appWin.clearStatusBusy();const i=this.checkReasonForInvalidVolume(t)||this.checkReasonForInvalidQuotaStatus(r);if(i)return void this.popupForbidMessage(i);const n=this.hasAttributeNeedBeRemove();if(n)return void this.popupWarningMessage(n)}catch(e){SYNO.Debug(e),this.appWin.clearStatusBusy(),this.helper.popupErrorMessage(this.appWin,void 0,()=>this.appWin.close())}},createPanel:function(){return this.newShareDescriptionLearnMoreId=Ext.id(),new SYNO.ux.Panel({cls:"c2fs-panel-no-padding",layout:"vbox",listeners:{afterrender:this.validateSourceShareFlow,scope:this},items:[{xtype:"label",name:"create_wizard_image",width:740,height:240,cls:"c2-create-wizard-img"},{xtype:"syno_displayfield",cls:"c2-create-wizard-welcome-txt",htmlEncode:!1,value:String.format(this.helper.T("common","new_share_detail_description"),'',"",'',""),listeners:{afterrender:()=>{Ext.get(this.newShareDescriptionLearnMoreId).on("click",()=>{SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.C2FS.Application"},!1)},this)},scope:this}}]})},exceedHybridShareNum:function(){return this.shareStore.getRange().filter(e=>!0===e.get("is_c2_share")).length>=this.helper.maxC2fsNum()},hasShareQuota:function(){return this.targetShare.json.quota_value},hasSetCow:function(){return this.targetShare.json.enable_share_cow},isEncryptionShare:function(){return 0!==this.targetShare.get("encryption")},hasAttributeNeedBeRemove:function(){const e=[];return this.hasShareQuota()&&e.push(this.helper.T("warn","transform_will_remove_share_quota")),e.join("
")},checkReasonForInvalidAttribute:function(){return this.hasSetCow()&&!this.helper.getGlobalConf("support_cow",!1)?this.helper.T("warn","transform_cow_share_no_way"):this.isEncryptionShare()?this.helper.T("warn","transform_encryption_share_no_way"):void 0},checkReasonForInvalidType:function(){return!0===this.targetShare.get("is_cold_storage_share")?this.helper.T("warn","transform_cold_storage_share_no_way"):!0===this.targetShare.get("is_cluster_share")?this.helper.T("warn","transform_cluster_share_no_way"):!1===this.targetShare.get("is_btrfs_share")?this.helper.T("warn","transform_not_btrfs_share_no_way"):""},checkReasonForCannotTransform:function(){return!0===this.exceedHybridShareNum()?String.format(this.helper.T("error","exceed_c2_share_num"),this.helper.maxC2fsNum()):SYNO.SDS.C2FS.Share.Utils.isNoSupportShareName(this.targetShare.get("name"))?this.helper.T("warn","transform_reserved_share_no_way"):this.checkReasonForInvalidType()||this.checkReasonForInvalidAttribute()},getDsmWebApiErrMsg:function(e){var t;return SYNO.API.Errors.core[null==e?void 0:null===(t=e.error)||void 0===t?void 0:t.code]||this.helper.T("common","error_system")},getNext:function(){return(async()=>{try{await this.tryEnableNTP(),await this.tryEnableSpaceUsage(),this.popC2LoginWeb()}catch(e){e instanceof this.OpError?!1!==e.alert&&this.appWin.getMsgBox().alert(this.appWin.title,e.message):(SYNO.Debug.error(e),this.appWin.getMsgBox().alert(this.appWin.title,this.helper.T("common","error_system")))}})(),!1},confirmEnableNTP:function(){const e=this.appWin.getMsgBox();return new Promise((t,r)=>{e.confirm(this.appWin.title,String.format(this.helper.T("warn","need_enable_ntp_sync_setting"),'',""),e=>{"yes"===e?t():r(new this.OpError("User cancelled",!1))},this.appWin,{yes:{text:this.helper.T("common","ok")},no:{text:this.helper.T("common","cancel")}}),e.getDialog().el.child(".link-font").on("click",()=>{SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.C2FS.Application:create_hybrid_share.html"},!1)})})},getNTPInfo:async function(){try{return await this.sendWebAPIPromise({api:"SYNO.Core.Region.NTP",method:"get",version:2})}catch(e){throw new this.OpError(this.getDsmWebApiErrMsg(e))}},tryEnableNTP:async function(){const e=async e=>{const t=this._D("product");try{await this.sendWebAPIPromiseAndPendingWithStatus({api:"SYNO.Core.Region.NTP",method:"ensure_ntp_sync_and_enable",version:1},{text:SYNO.SDS.AdminCenter.Region.Utils.ntpUpdateProgressMsg(t,e.server)})}catch(r){throw SYNO.Debug("Sync ntp, err: ",r),new this.OpError(SYNO.SDS.AdminCenter.Region.Utils.ntpUpdateFailedMsg(t,e.server))}},t=await this.getNTPInfo();"manual"===t.enable_ntp&&(await this.confirmEnableNTP(),await e(t))},getShareSpaceUsage:function(){return this.sendWebAPIPromise({api:"SYNO.C2FS.Utils",method:"get_share_space_usage",version:1,params:{share_name:this.targetShare.data.name}})},confirmEnableSpaceUsage:function(){return new Promise((e,t)=>{this.appWin.getMsgBox().confirm(this.appWin.title,this.helper.T("warn","enable_space_usage"),r=>{if("yes"===r)e();else{const e=this.helper.ErrorMap;t(new this.OpError(e.T(e.ERR_NEED_SPACE_USAGE)))}})})},checkSpaceUsage:async function(){const e=SYNO.SDS.C2FS.Utils.Volume;try{this.appWin.setStatusBusy({text:this.helper.T("common","msg_waiting")});const t=await e.getSpaceUsageStatus(this.targetShare.get("vol_path"));return"enabled"===t||"enabling"===t}catch(e){throw new this.OpError(this.getDsmWebApiErrMsg(e))}finally{this.appWin.clearStatusBusy()}},tryEnableSpaceUsage:async function(){if(!await this.checkSpaceUsage()){await this.confirmEnableSpaceUsage();try{await SYNO.SDS.C2FS.Utils.Volume.setSpaceUsageStatus(this.targetShare.get("vol_path"),"enable")}catch(e){throw new this.OpError(this.getDsmWebApiErrMsg(e))}if(!await this.checkSpaceUsage())throw SYNO.Debug.error("Space usage remains disabled after enabling"),new this.OpError(this.helper.T("common","error_system"))}},popC2LoginWeb:function(){this.unregister();const e=SYNO.SDS.C2FS.NPM.nodeRSA();this.rsaKey=new e({b:1024}),this.register(this.c2PostMessageManager,"C2Share");const t=SYNO.SDS.C2FS.Utils.C2WebHandler.generateUrl("c2share/transform");this.popup=window.open(t,"c2_web","menubar=1, resizable=0, width=1080, height=800, top=100, left=300"),this.popup||this.appWin.getMsgBox().alert(this.appWin.title,this.helper.T("warn","popup_c2_web_failed"),Ext.emptyFn)},isShareInit:function(e){return e.share_key&&SYNO.SDS.Utils.IsJson(e.share_key)},c2PostMessageManager:async function(e){if(!SYNO.SDS.C2FS.Utils.C2WebHandler.isKnownOrigin(e.origin))return!1;switch(e.data.cmd){case"ask_ds_info_and_mount":if(!e.data.account)return!1;this.responseDsInfoAndMountedShare(e);break;case"authorize":{const t=e.data.share,r=e.data;if(this.isShareInit(t))return this.appWin.getMsgBox().alert(this.appWin.title,this.helper.T("warn","bucket_is_init")),!1;const{used_bytes:i}=await(async()=>{try{return await this.getShareSpaceUsage()}catch{return{}}})();if(void 0===i)return this.appWin.getMsgBox().alert(this.appWin.title,this.helper.T("common","error_system")),!1;const n=i/1024/1024,s=t.quota_limit/1024/1024;if(n>s)return this.appWin.getMsgBox().alert(this.appWin.title,String.format(this.helper.T("warn","share_used_exceed_bucket_size"),SYNO.SDS.Utils.CapacityRender(s))),!1;this.owner.fireEvent("setServerInfo",{metadata:t.metadata?t.metadata:"",c2share_api_url:r.c2_api_url,share_id:t.share_id,share_key:t.share_key,synology_account:r.account,bucket_name:t.share_name,bucket_used_mb:0,bucket_total_mb:s,scoped_c2auth_access_tokens:this.rsaKey.decrypt(r.access_tokens,"json"),scoped_c2auth_public_key:this.rsaKey.decrypt(r.public_key,"base64"),scoped_c2auth_private_key:this.rsaKey.decrypt(r.private_key,"base64")}),this.sendWebAPIPromiseAndPendingWithStatus({api:"SYNO.C2FS.Transform",method:"validate_for_service",version:1,params:{share_name:this.targetShare.get("name")},scope:this}).then(()=>(this.appWin.goNext(this.nextId),!1)).catch(e=>e.code!==this.helper.ErrorMap.ERR_NOT_FEASIBLE?(SYNO.Debug("err",e),this.helper.popupErrorMessage(this.appWin,e.code),!1):(this.owner.fireEvent("recordFeasibilityCheck",e.errors),this.appWin.goNext(this.validateId),!1));break}}},getAccountFromEvent:function(e){try{return e.data.account}catch(t){return SYNO.Debug("Invalid event for get account, event:",e,t),""}},sendWepApiForMountedShare:async function(e){return this.sendWebAPIPromise({api:"SYNO.C2FS.Bucket",method:"get_account_mount",version:1,params:{synology_account:e},scope:this})},sendWebApiForDsInfo:async function(){return this.sendWebAPIPromise({api:"SYNO.C2FS.Utils",method:"get_ds_info",version:1,scope:this})},responseDsInfoAndMountedShare:async function(e){const t=this.getAccountFromEvent(e);if(!t)return!1;try{const[r,i]=await Promise.all([this.sendWepApiForMountedShare(t),this.sendWebApiForDsInfo()]);this.popup.postMessage({shares:r,ds_info:i,rsa_public_key:this.rsaKey.exportKey("pkcs8-public-pem")},e.origin)}catch(e){this.helper.popupErrorMessage(this.appWin,e.code,Ext.emptyFn)}},register:function(e,t){this.receiveMessage=(r=>{/setImmediate/.test(r.browserEvent.data)||r.browserEvent.data.pkg_name===t&&e.call(this,r.browserEvent)}),Ext.EventManager.addListener(window,"message",this.receiveMessage)},unregister:function(){Ext.EventManager.removeListener(window,"message",this.receiveMessage)}}),Ext.ns("SYNO.SDS.C2FS.Utils"),SYNO.SDS.C2FS.Utils.FileExpoter={export:function(e,t,r){const i=new Blob([r],{type:e}),n=URL.createObjectURL(i),s=document.createElement("a");document.body.appendChild(s),s.href=n,s.download=t,s.click()}},Ext.ns("SYNO.SDS.C2FS.Share.Transform"),SYNO.SDS.C2FS.Share.Transform.CSVExpoter={helper:SYNO.SDS.C2FS.Helper,exportFile:function(e,t){const r=e+"_feasibility_check.csv",i=t.hard||t.soft,n=this.helper.T("common","issue_suggest")+i.reduce((e,t)=>e+='\n"'+SYNO.SDS.Utils.GetFeasibilityCheckMsg(t).replace(/<[^>]+>/g,"").replace(/"/g,'""')+'"',"");SYNO.SDS.C2FS.Utils.FileExpoter.export("text/csv",r,n)}},SYNO.SDS.C2FS.Share.Transform.HtmlExporter={helper:SYNO.SDS.C2FS.Helper,exportFile:function(e,t){const r=e+"_feasibility_check.html",i=t.hard||t.soft,n='"+i.reduce((e,t)=>e+="","")+"
'+this.helper.T("common","issue_suggest")+"
"+SYNO.SDS.Utils.GetFeasibilityCheckMsg(t)+"
";SYNO.SDS.C2FS.Utils.FileExpoter.export("text/html",r,n)}},Ext.ns("SYNO.SDS.C2FS.Share.Transform"),SYNO.SDS.C2FS.Share.Transform.CheckResultRecorder={helper:SYNO.SDS.C2FS.Helper,recorder:{},Save:function(e,t){t&&(t.soft||t.hard)?this.recorder[e]=t:SYNO.Debug("Bad check result: ",t)},Get:function(e){return this.recorder[e]}},Ext.define("SYNO.SDS.C2FS.Share.Transform.ValidateStep",{extend:"SYNO.SDS.Wizard.Step",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.targetShare=e.share,this.callParent([this.fillConfig(e)])},fillConfig:function(e){this.store=new Ext.data.JsonStore({autoDestroy:!0,fields:["issue"]});const t={headline:this.helper.T("transform","invalid_check_title"),layout:"vbox",items:[new SYNO.SDS.Utils.FormPanel({title:this.helper.T("share","share_subject"),border:!1,frame:!1,autoScroll:!0,header:!1,autoHeight:!0,width:"100%",ref:"form",itemId:"form",cls:"c2fs-panel-no-padding",items:[{xtype:"syno_displayfield",fieldLabel:this.helper.T("share","share_name"),value:this.targetShare.get("name")},{xtype:"syno_displayfield",ref:"description",name:"description",value:this.helper.T("transform","invalid_check_description")}]}),new SYNO.ux.SplitButton({text:this.helper.T("delegation","export"),autoWidth:!0,scope:this,handler:this.exportHTML,menu:new SYNO.ux.Menu({items:[{text:this.helper.T("log","html_type"),scope:this,handler:this.exportHTML},{text:this.helper.T("log","csv_type"),scope:this,handler:this.exportCSV}]})}),new SYNO.ux.GridPanel({store:this.store,flex:1,width:"100%",autoExpandColumn:"value",autoExpand:!0,colModel:new Ext.grid.ColumnModel({columns:[{header:this.helper.T("common","issue_suggest"),dataIndex:"issue",renderer:(e,t,r)=>''+e+""}]})})]};return Ext.apply(t,e),t},getValues:function(){return null},getNext:function(){return this.checkResult&&this.checkResult.hard?null:this.nextId},checkState:function(){this.callParent(),this.checkResult&&this.checkResult.hard&&this.owner.getButton("next").setText(this.helper.T("common","done"))},activate:function(){if(this.checkResult=this.owner.getFeasibilityCheck(),SYNO.SDS.C2FS.Share.Transform.CheckResultRecorder.Save(this.targetShare.get("name"),this.checkResult),this.checkResult.hard){const e=this.checkResult.hard.map(e=>({issue:SYNO.SDS.Utils.GetFeasibilityCheckMsg(e)}));this.store.loadData(e)}else{if(this.checkResult.soft){const e=this.checkResult.soft.map(e=>({issue:SYNO.SDS.Utils.GetFeasibilityCheckMsg(e)}));return this.setHeader(this.helper.T("transform","warning_check_title")),this.form.description.setValue(this.helper.T("transform","warning_check_description")),void this.store.loadData(e)}this.appWin.goNext()}},exportFile:function(e,t,r){const i=new Blob([r],{type:e}),n=URL.createObjectURL(i),s=document.createElement("a");document.body.appendChild(s),s.href=n,s.download=t,s.click()},exportHTML:function(){SYNO.SDS.C2FS.Share.Transform.HtmlExporter.exportFile(this.targetShare.get("name"),this.checkResult)},exportCSV:function(){SYNO.SDS.C2FS.Share.Transform.CSVExpoter.exportFile(this.targetShare.get("name"),this.checkResult)}}),Ext.define("SYNO.SDS.C2FS.Share.Transform.EncryptBucketStep",{extend:"SYNO.SDS.Wizard.Step",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){this.formPanel=this.createFormPanel(e);const t={headline:this.helper.T("common","encryption_title"),layout:"fit",items:[this.formPanel],listeners:{scope:this}};return Ext.apply(t,e),t},createFormPanel:function(e){const t={cls:"c2fs-panel-no-padding",itemId:"encryptBucketForm",autoFlexcroll:!1,labelWidth:265,items:[{xtype:"syno_displayfield",style:"margin-bottom: 6px;",hideLabel:!0,htmlEncode:!1,value:String.format(this.helper.T("common","encryption_desc"),'',""),listeners:{afterrender:e=>{const t=e.el.query("a");t[0]?Ext.get(t[0].id).on("click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.C2FS.Application:create_hybrid_share.html"},!1)},this):SYNO.Debug("Failed to find link element: ",t)},scope:this}},{xtype:"syno_textfield",textType:"password",width:220,minLength:8,maxLength:64,name:"enc_passwd",allowBlank:!1,fieldLabel:this.helper.T("share","share_encryption_key"),validator:e=>-1===e.indexOf("=")&&-1===e.indexOf(",")&&-1===e.indexOf(":")||this.helper.T("share","encryption_password_invalid")},{xtype:"syno_textfield",textType:"password_confirm",name:"enc_passwd_confirm",confirmFor:"enc_passwd",confirmFailedText:this.helper.T("share","share_encryption_key_confirm_mismatch"),maxlength:64,width:220,allowBlank:!1,fieldLabel:this.helper.T("share","share_encryption_key_confirm")}]};return Ext.apply(t,e),new SYNO.SDS.Utils.FormPanel(t)},isValid:function(){return this.formPanel.getForm().isValid()},getValues:function(){return null},getNext:function(){if(this.isValid()){const e='

'+this.helper.T("warn","encrypt_note")+'

'+this.helper.T("warn","encrypt_key_cant_modified")+'

'+this.helper.T("warn","encrypt_key_no_save_on_server")+"

";this.appWin.getMsgBox().confirm(this.helper.T("warn","encrypting_confirm_title"),e,e=>{"yes"===e&&(this.appWin.setStatusBusy({text:this.helper.T("common","msg_waiting")}),this.sendWebAPIPromise({api:"SYNO.C2FS.Bucket",method:"encrypt",version:1,encryption:["encrypt_password","server_info"],params:{encrypt_password:this.formPanel.getForm().getValues().enc_passwd,server_info:this.owner.getServerInfo()},scope:this}).then(()=>(this.appWin.clearStatusBusy(),this.downloadKey(),this.appWin.goNext(this.nextId),!1)).catch(e=>(this.appWin.clearStatusBusy(),this.helper.popupErrorMessage(this.findWindow(),e.code),!1)))},this,{yes:!0,no:!0},{useMessageTitle:!0,hideBrElement:!0})}return!1},downloadKey:function(){const e=this.owner.getServerInfo();this.findAppWindow().downloadWebAPI({webapi:{api:"SYNO.C2FS.Bucket",method:"password_key_export",version:1,params:{share_id:e.share_id,bucket_name:e.bucket_name}},scope:this,callback:function(e,t,r,i){"timeout"!==e&&!1===r&&this.findWindow().getMsgBox().alert(this.title,this.helper.T("status","status_err_load"))}.bind(this)})}}),Ext.define("SYNO.SDS.C2FS.Share.Transform.FillBasicInfoStep",{extend:"SYNO.SDS.Wizard.Step",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.targetShare=e.share,this.callParent([this.fillConfig(e)])},fillConfig:function(e){const t={headline:this.helper.T("common","create_wizard_local_cache_rule"),layout:"fit",items:[new SYNO.SDS.Utils.FormPanel(Ext.apply({title:this.helper.T("share","share_subject"),border:!1,frame:!1,header:!1,height:350,labelWidth:280,layout:"vbox",ref:"form",itemId:"form",cls:"c2fs-panel-no-padding",items:[{xtype:"syno_displayfield",style:"margin-bottom: 6px;",htmlEncode:!1,value:this.helper.T("common","local_cache_usage")},{xtype:"syno_compositefield",ref:"shareName",name:"name",style:"padding: 6px 0 0 0;",items:[{xtype:"syno_displayfield",width:280,value:this.helper.T("share","share_name")+this.helper.T("common","colon")},{xtype:"syno_displayfield",width:450,value:this.targetShare.get("name")}]},{xtype:"syno_compositefield",ref:"volumePath",name:"volume_path",style:"padding: 6px 0 0 0;",items:[{xtype:"syno_displayfield",width:280,value:this.helper.T("volume","volume_share_position")+this.helper.T("common","colon")},{xtype:"syno_displayfield",width:450,value:this.targetShare.get("status")}]},{xtype:"syno_compositefield",ref:"reservationSize",name:"reservation_size",style:"padding: 6px 0 0 0;",items:[{xtype:"syno_displayfield",width:280,value:this.helper.T("attribute","local_reservation_size")+this.helper.T("common","colon")},{xtype:"syno_numberfield",ref:"sizeGb",name:"reservation_size_gb",style:"margin-left: 280px;",minValue:0,width:120,allowBlank:!1},{xtype:"syno_displayfield",width:20,name:"unit",value:"GB"}]},{xtype:"spacer",flex:1},{xtype:"syno_displayfield",htmlEncode:!1,style:"padding: 4px 0 0 0;",value:''+this.helper.T("common","note")+this.helper.T("common","colon")+""+String.format(this.helper.T("common","local_cache_rule_description"),'',"")}]},e))],listeners:{scope:this}};return Ext.apply(t,e),t},activate:function(){const e=this.form.reservationSize.sizeGb;e.getValue()||(this.appWin.setStatusBusy(),this.sendWebAPIPromise({api:"SYNO.Core.Storage.Volume",method:"get",version:1,scope:this,params:{volume_path:this.targetShare.get("vol_path")}}).then(t=>{this.volume=t.volume;const{bucket_total_mb:r}=this.owner.getServerInfo(),i=SYNO.SDS.C2FS.Share.Utils.idealLocalCacheGB({total_mb:this.volume.size_total_byte/1024/1024},{total_mb:r}),n=SYNO.SDS.C2FS.Share.Utils.minLocalCacheGB();Number.isNaN(i)&&this.appWin.getMsgBox().alert(this.title,String.format(this.helper.T("error","target_volume_no_space"),SYNO.SDS.Utils.CapacityRender(1024*n)),Ext.emptyFn),this.form.volumePath.setValue(String.format("{0} ({1})",SYNO.SDS.Utils.StorageUtils.VolumeNameRenderer(this.volume),this.volume.fs_type));const s=SYNO.SDS.C2FS.Share.Utils.LOCAL_CACHE.DEFAULT_SIZE_GB;e.setValue(Math.min(i,s)),e.validator=SYNO.SDS.C2FS.Share.Utils.genLocalReservationSizeForNewShareValidator(i,this.volume.size_total_byte/1024/1024,r,this.volume.display_name),this.appWin.clearStatusBusy()}).catch(e=>{this.appWin.clearStatusBusy(),SYNO.Debug(e)}))},validate:function(){return this.form.getForm().isValid()},getValues:function(){return this.form.getForm().getValues()},getNext:function(){return!!this.validate()&&this.nextId}}),Ext.define("SYNO.SDS.C2FS.Share.Transform.SummaryDiagramTitle",{extend:"SYNO.ux.DisplayField",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([Ext.apply({ref:"title",htmlEncode:!1,cls:"c2fs-text-line",value:"-"},e)])},refresh:function(e,t,r,i){this.setValue(String.format(this.helper.T("transform","summary_diagram_title"),e+" ("+t+")","","")+this.helper.addWhiteTipHtml(String.format(this.helper.T("transform","summary_diagram_white_tip"),this.helper.capacityRender(i,0),this.helper.capacityRender(r,0))))}}),Ext.define("SYNO.SDS.C2FS.Share.Transform.SummaryDiagramOriginShow",{extend:"Ext.BoxComponent",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){return Ext.apply({cls:"c2-transform-summary",htmlEncode:!1,autoHeight:!0,data:{name:"-",used:"-"},tpl:'
{name}
'+this.helper.T("share","share_size")+'
{used}
'},e)},refresh:function(e,t){this.update({name:e,used:this.helper.capacityRender(t,0)})}}),Ext.define("SYNO.SDS.C2FS.Share.Transform.SummaryDiagramTransitionShow",{extend:"Ext.BoxComponent",constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){return Ext.apply({htmlEncode:!1,data:{},style:"text-align: center;",autoHeight:!0,tpl:'
'},e)}}),Ext.define("SYNO.SDS.C2FS.Share.Transform.SummaryDiagramAfterShow",{extend:"Ext.BoxComponent",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){return Ext.apply({htmlEncode:!1,cls:"c2-transform-summary",data:{cache_size:"-",c2_size:"-",name:"-"},autoHeight:!0,tpl:'
{name}
'+this.helper.T("bucket","c2_storage_size")+'
{c2_size}
'+this.helper.T("attribute","local_reservation_size_display")+'
{cache_size}
'},e)},refresh:function(e,t,r){this.update({name:e,cache_size:this.helper.capacityRender(t,0),c2_size:this.helper.capacityRender(r,0)})}}),Ext.define("SYNO.SDS.C2FS.Share.Transform.SummaryDiagram",{extend:"SYNO.ux.Panel",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){return Ext.apply({padding:"10px 0 0 0",ref:"diagram",items:[new SYNO.SDS.C2FS.Share.Transform.SummaryDiagramTitle({ref:"title"}),{xtype:"syno_panel",layout:{type:"hbox",align:"middle"},padding:"8px 2px 0 0",items:[new SYNO.SDS.C2FS.Share.Transform.SummaryDiagramOriginShow({flex:1,ref:"../origin"}),new SYNO.SDS.C2FS.Share.Transform.SummaryDiagramTransitionShow({flex:1,width:78}),new SYNO.SDS.C2FS.Share.Transform.SummaryDiagramAfterShow({flex:1,ref:"../after"})]}]},e)},_validate:function(e,t,r){return e&&e.name&&e.volume?t&&t.cache_size_kb?r&&r.size_kb?(e.used_kb||(e.used_kb=0),!0):(SYNO.Debug("Bad bucket",r),!1):(SYNO.Debug("Bad c2fs",t),!1):(SYNO.Debug("Bad share",e),!1)},refresh:function(e,t,r){this._validate(e,t,r)&&(this.title.refresh(e.name,e.volume,e.used_kb,t.cache_size_kb),this.origin.refresh(e.name,e.used_kb),this.after.refresh(e.name,t.cache_size_kb,r.size_kb))}}),Ext.define("SYNO.SDS.C2FS.Share.Transform.SummaryStep",{extend:"SYNO.SDS.Wizard.Step",helper:SYNO.SDS.C2FS.Helper,estimatedSec:60,constructor:function(e){this.targetShare=e.share,this.ASSUMED_UPLOAD_SPEED=2.5,this.callParent([this.fillConfig(e)])},fillConfig:function(e){const t={layout:"fit",headline:this.helper.T("transform","summary_title"),items:[new SYNO.SDS.Utils.FormPanel(Ext.apply({header:!1,labelWidth:280,ref:"form",cls:"c2fs-panel-no-padding",items:[{xtype:"syno_displayfield",value:this.helper.T("transform","summary_description")},{xtype:"syno_displayfield",ref:"account",fieldLabel:this.helper.T("common","synology_account"),value:"-"},{xtype:"syno_displayfield",ref:"estimatedTime",htmlEncode:!1,fieldLabel:this.helper.T("transform","estimated_time"),value:"-"},new SYNO.SDS.C2FS.Share.Transform.SummaryDiagram]}))]};return Ext.apply(t,e),t},activate:async function(){this.appWin.setStatusBusy();let e=0;try{const{used_bytes:t}=await this.getShareSpaceUsage();e=t}catch(e){SYNO.Debug.error("Failed to get share space usage, treat it as 0",e)}this.appWin.clearStatusBusy();const t=e/1024/1024;this.estimatedSec=Math.max(t/this.ASSUMED_UPLOAD_SPEED,this.estimatedSec),this.form.estimatedTime.setValue(String.format(this.helper.T("transform","display_about_time"),this.helper.timeRender(this.helper.approximateTime(this.estimatedSec,2)))+this.helper.addWhiteTipHtml(String.format(this.helper.T("transform","summary_estimate_time_white_tip"),8*this.ASSUMED_UPLOAD_SPEED)));const r=this.owner.getServerInfo(),i=1048576*this.owner.getValues().fillBasicInfo.reservation_size_gb;this.form.diagram.refresh({name:this.targetShare.get("name"),volume:this.targetShare.get("status"),used_kb:e/1024},{cache_size_kb:i},{size_kb:1024*r.bucket_total_mb}),this.form.account.setValue(r.synology_account)},getShareSpaceUsage:function(){return this.sendWebAPIPromise({api:"SYNO.C2FS.Utils",method:"get_share_space_usage",version:1,params:{share_name:this.targetShare.data.name}})},sendTransformWebapi:function(){return this.appWin.setStatusBusy(),this.sendWebAPIPromise({api:"SYNO.C2FS.Transform",method:"transform_to_c2share",version:1,scope:this,encryption:["server_info"],params:{share_name:this.targetShare.get("name"),reservation_size_gb:this.owner.getValues().fillBasicInfo.reservation_size_gb,server_info:this.owner.getServerInfo()}}).then(e=>{this.owner.isNeedCloseWarnMsg=!1,this.appWin.clearStatusBusy(),SYNO.SDS.StatusNotifier.fireEvent("sharefolderchanged",this.targetShare.get("name")),this.appWin.goNext(this.nextId),this.module.panel.store.load()}).catch(e=>(SYNO.Debug(e),this.appWin.clearStatusBusy(),this.helper.popupErrorMessage(this.appWin,e.code),!1)),!1},confirmEnableSpaceUsage:function(){return new Promise((e,t)=>{this.appWin.getMsgBox().confirm(this.appWin.title,this.helper.T("warn","enable_space_usage"),r=>{"yes"===r?e():t(new Error("User cancelled"))})})},checkSpaceUsage:async function(){const e=SYNO.SDS.C2FS.Utils.Volume,{vol_path:t}=this.share.data;try{this.appWin.setStatusBusy({text:this.helper.T("common","msg_waiting")});const r=await e.getSpaceUsageStatus(t);return"enabled"===r||"enabling"===r}finally{this.appWin.clearStatusBusy()}},tryEnableSpaceUsage:async function(){if(!await this.checkSpaceUsage()){try{await this.confirmEnableSpaceUsage()}catch(e){return this.helper.popupErrorMessage(this.owner,SYNO.SDS.C2FS.Helper.ErrorMap.ERR_NEED_SPACE_USAGE),!1}const{vol_path:e}=this.share.data;if(await SYNO.SDS.C2FS.Utils.Volume.setSpaceUsageStatus(e,"enable"),!await this.checkSpaceUsage())throw new Error("Space usage remains disabled after enabling")}return!0},showConfirmDialog:function(e,t){this.appWin.getMsgBox().confirm(this.appWin.title,String.format(this.helper.T("transform","confirm_dialog_content"),""+this.targetShare.get("name")+""),r=>{"cancel"===r?t():e()},this,{ok:!0,cancel:!0})},getNext:function(){return this.showConfirmDialog(async()=>{try{await this.tryEnableSpaceUsage()&&this.sendTransformWebapi()}catch(e){e&&SYNO.Debug(e),this.helper.popupErrorMessage(this.owner,SYNO.SDS.C2FS.Helper.ErrorMap.ERR_OPERATION)}},Ext.emptyFn),!1},checkState:function(){this.callParent(),this.owner.getButton("next").setText(this.helper.T("transform","last_button"))}}),Ext.define("SYNO.SDS.C2FS.Share.Transform.Wizard",{extend:"SYNO.SDS.Wizard.ModalWindow",helper:SYNO.SDS.C2FS.Helper,constructor:function(e){this.isNeedCloseWarnMsg=!0,this.callParent([this.fillConfig(e)]),this.setAllStepSize()},fillConfig:function(e){const t=[new SYNO.SDS.C2FS.Share.Transform.WelcomeStep({appWin:this,owner:this,module:e.module,itemId:"welcome",nextId:"encryptBucket",validateId:"validate",share:e.share}),new SYNO.SDS.C2FS.Share.Transform.ValidateStep({appWin:this,owner:this,module:e.module,itemId:"validate",nextId:"encryptBucket",share:e.share}),new SYNO.SDS.C2FS.Share.Transform.EncryptBucketStep({appWin:this,owner:this,module:e.module,itemId:"encryptBucket",nextId:"fillBasicInfo",share:e.share}),new SYNO.SDS.C2FS.Share.Transform.FillBasicInfoStep({appWin:this,owner:this,module:e.module,itemId:"fillBasicInfo",nextId:"summary",share:e.share}),new SYNO.SDS.C2FS.Share.Transform.SummaryStep({appWin:this,owner:this,module:e.module,itemId:"summary",nextId:null,share:e.share})],r={title:this.helper.T("action","transform_wizard"),steps:t,width:820,height:560,cls:"c2-create-wizard",listeners:{beforeclose:this.onBeforeClose,setServerInfo:this.setServerInfo,recordFeasibilityCheck:this.recordFeasibilityCheck,scope:this}};return Ext.apply(r,e),r},setAllStepSize:function(){this.getAllSteps().forEach(function(e){e.setHeight(Math.max(this.height-155,155)),e.setWidth(Math.max(this.width-80,80)),e.doLayout()},this)},setServerInfo:function(e){this.serverInfo=e},getServerInfo:function(){return Object.assign({},this.serverInfo)},recordFeasibilityCheck:function(e){e&&(e.soft||e.hard)||SYNO.Debug("Bad feasibility check: ",e),this.feasibilityCheck=e},getFeasibilityCheck:function(){return this.feasibilityCheck?Object.assign({},this.feasibilityCheck):{}},getValues:function(){return this.getAllSteps().reduce(function(e,t){return Ext.isFunction(t.getValues)&&(e[t.itemId]=t.getValues()),e},{})},onBeforeClose:function(){return!this.stepStack.includes("encryptBucket")||!this.isNeedCloseWarnMsg||(this.findWindow().getMsgBox().confirm(this.helper.T("warn","create_leave_title"),'

'+this.helper.T("warn","transform_leave_content")+"

",e=>{"yes"===e&&(this.isNeedCloseWarnMsg=!1,this.close())},this,{yes:!0,no:!0},{useMessageTitle:!0,hideBrElement:!0}),!1)},hasHistory:function(){switch(this.getActiveStep().itemId){case"welcome":case"validate":case"fillBasicInfo":return 0;case"encryptBucket":return"welcome"===this.stepStack.lastItem?0:this.stepStack.length;default:return this.stepStack.length}}}),Ext.ns("SYNO.SDS.C2FS.File"),SYNO.SDS.C2FS.File.LocalStatus={Unknown:-1,Unpin:0,Pin:1,InProcess:0,HasFail:1,NotFullyMapped:2,FullyMapped:3,PinFullyMapped:4,PinRecord:"hybridshare_pin_status",CacheRecord:"hybridshare_cache_status",RecordUpdateLimit:25,isPinable:function(e){return e.get(SYNO.SDS.C2FS.File.LocalStatus.PinRecord)===SYNO.SDS.C2FS.File.LocalStatus.Unpin},isUnpinable:function(e){return e.get(SYNO.SDS.C2FS.File.LocalStatus.PinRecord)===SYNO.SDS.C2FS.File.LocalStatus.Pin},isValidPinStatus:function(e){return!SYNO.webfm.utils.isRecycleBinFolder(e.get("path"))&&void 0!==e.get(SYNO.SDS.C2FS.File.LocalStatus.PinRecord)},isEvictable:function(e){const t=e.get(SYNO.SDS.C2FS.File.LocalStatus.CacheRecord);return t===SYNO.SDS.C2FS.File.LocalStatus.FullyMapped||t===SYNO.SDS.C2FS.File.LocalStatus.PinFullyMapped},isRetryable:function(e){return e.get(SYNO.SDS.C2FS.File.LocalStatus.CacheRecord)===SYNO.SDS.C2FS.File.LocalStatus.HasFail}},Ext.define("SYNO.SDS.C2FS.Application",{extend:"SYNO.SDS.AppInstance",onOpen:function(e){this.sendWebAPIPromise({params:{},compound:{stopwhenerror:!1,params:[{api:"SYNO.Core.Storage.Volume",version:1,method:"list",params:{limit:-1,offset:0,location:""===_D("usbstation")?"internal":"external",option:"include_cold_storage"}},{api:"SYNO.C2FS.Share",method:"list",version:1}]},scope:this}).then(e=>{SYNO.Debug(e);const t=SYNO.API.Response.GetValByAPI(e,"SYNO.C2FS.Share","list"),r=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Storage.Volume","list");0===Object.keys(t).length&&0!==r.volumes.length?SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.Share.Main",dlg:"create",type:"c2_share"}):SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.Share.Main",c2share_name:Object.keys(e)[0]})}).catch(e=>{SYNO.Debug(e),SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.Share.Main"})}),this.destroy()}}),Ext.define("SYNO.SDS.C2FS.App.LaunchForDSMNotification",{extend:"SYNO.SDS.AppInstance",onOpen:function(e){this.sendWebAPIPromise({api:"SYNO.C2FS.Share",method:"list",version:1,scope:this}).then(function(e){SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.Share.Main",c2share_name:Object.keys(e)[0]})}),this.destroy()}}),Ext.define("SYNO.SDS.C2FS.App.DownloadForDSMNotification",{extend:"SYNO.SDS.AppInstance",statics:{downloadTransformInfo:function(e){"key"in e&&"type"in e&&"share_name"in e?SYNO.SDS.Utils.IFrame.requestWebAPI({webapi:{api:"SYNO.C2FS.Transform",method:"export_invalid_files",version:1,params:e},appWindow:!1}):SYNO.Debug("Invalid parameter, param: ",e)}}}),Ext.define("SYNO.SDS.C2FS.App.PopUpNotification",{extend:"SYNO.SDS.AppInstance",statics:{popupC2Web:function(e){const t=SYNO.SDS.C2FS.Utils.C2WebHandler;return window.open(t.generateHybridShareDashboardUrl(),"c2_web","menubar=1, resizable=0, width=1080, height=800, top=100, left=300"),!1},popupExitBeta:function(){const e=SYNO.SDS.C2FS.Utils.C2WebHandler;return window.open(e.generateUrl("c2share/exit_beta"),"c2_web","menubar=1, resizable=0, width=1080, height=800, top=100, left=300"),!1}}}),Ext.define("SYNO.SDS.C2FS.App.ConfigLoader",{extend:"SYNO.SDS.AppInstance",helper:SYNO.SDS.C2FS.Helper,onOpen:function(e){this.sendWebAPIPromise({api:"SYNO.C2FS.Utils",method:"load_global_config",version:1,scope:this,params:{}}).then(e=>{this.helper.setGlobalConf(e)}).catch(e=>{SYNO.Debug("Failed to load config ",e),this.helper.setGlobalConf({})})}}),Ext.ns("SYNO.SDS.C2FS.FileBrowserExtension.Evict"),SYNO.SDS.C2FS.FileBrowserExtension.Evict={enableIf:(e,t)=>!0===_S("is_admin")&&t.some(SYNO.SDS.C2FS.File.LocalStatus.isEvictable),onClicked(e){this.maskView(_WFT("common","loading"),"x-mask-loading"),this.sendWebAPIPromise({api:"SYNO.C2FS.File",method:"evict",version:2,params:{paths:e.filter(SYNO.SDS.C2FS.File.LocalStatus.isEvictable).map(e=>e.data.real_path)}}).then(t=>{t.has_some_failed&&this.appWindow.getMsgBox().alert(void 0,SYNO.SDS.C2FS.Helper.T("file_station",1===e.length?"warn_file_in_use":"warn_files_in_use"));const r=this.grid.store;Object.entries(t.successes_list).length>=SYNO.SDS.C2FS.File.LocalStatus.RecordUpdateLimit?this.paging.doRefresh():t.successes_list.map(e=>r.getAt(r.findExact("real_path",e))).filter(e=>e.get("filesize")>0).forEach(e=>{e.set(SYNO.SDS.C2FS.File.LocalStatus.CacheRecord,SYNO.SDS.C2FS.File.LocalStatus.NotFullyMapped),e.set(SYNO.SDS.C2FS.File.LocalStatus.PinRecord,SYNO.SDS.C2FS.File.LocalStatus.Unpin)})},e=>{Ext.isDefined(e.code)?SYNO.SDS.C2FS.Helper.popupErrorMessage(this.appWindow,e.code):SYNO.Debug.error("non-API failure",e)}).finally(()=>this.unmaskView())}},Ext.ns("SYNO.SDS.C2FS.FileBrowser"),SYNO.SDS.C2FS.FileBrowser._IconWatchStore=class e extends SYNO.SDS.C2FS.Utils.LocalStatusWatch.WatchStoreInterface{constructor(e,t){super(),this._fileStationStore=e,this._filePaths=new Set(t)}addFiles(e){e.forEach(e=>this._filePaths.add(e))}get paths(){return this._filePaths}getLocalStatusCallback(t,r){if(!e._isCompleteStatus(r))return!1;const i=this._fileStationStore.getAt(this._fileStationStore.findExact("real_path",t));return null!==i&&i.set(SYNO.SDS.C2FS.File.LocalStatus.CacheRecord,r.cache_status),this._filePaths.delete(t),!0}static _isCompleteStatus(e){return[SYNO.SDS.C2FS.File.LocalStatus.HasFail,SYNO.SDS.C2FS.File.LocalStatus.FullyMapped,SYNO.SDS.C2FS.File.LocalStatus.PinFullyMapped].includes(e.cache_status)}},Ext.apply(SYNO.SDS.C2FS.FileBrowser,{getParams:(e,t,r)=>({api:"SYNO.C2FS.File",method:"pin",version:1,params:{paths:t.filter(r).map(e=>e.data.real_path),action:e===SYNO.SDS.C2FS.File.LocalStatus.Pin?"pin":"unpin"}}),updateRecord(e,t,r,i){if(Object.entries(t).length>=SYNO.SDS.C2FS.File.LocalStatus.RecordUpdateLimit)i.doRefresh();else for(const[i,n]of Object.entries(t)){const t=e.getAt(e.findExact("real_path",i));t.set(SYNO.SDS.C2FS.File.LocalStatus.CacheRecord,n.status),t.set(SYNO.SDS.C2FS.File.LocalStatus.PinRecord,r)}},canPin:(e,t)=>!0===_S("is_admin")&&t.every(SYNO.SDS.C2FS.File.LocalStatus.isValidPinStatus)&&t.some(SYNO.SDS.C2FS.File.LocalStatus.isPinable),canUnpin:(e,t)=>!0===_S("is_admin")&&t.every(SYNO.SDS.C2FS.File.LocalStatus.isValidPinStatus)&&t.some(SYNO.SDS.C2FS.File.LocalStatus.isUnpinable),canRetry:(e,t)=>!0===_S("is_admin")&&t.some(SYNO.SDS.C2FS.File.LocalStatus.isRetryable),onPinClicked(e){(async()=>{this.maskView(_WFT("common","loading"),"x-mask-loading");try{const t=SYNO.SDS.C2FS.File.LocalStatus.Pin,r=await this.sendWebAPIPromise(SYNO.SDS.C2FS.FileBrowser.getParams(t,e,SYNO.SDS.C2FS.File.LocalStatus.isValidPinStatus));r.has_some_failed&&SYNO.SDS.C2FS.Helper.popupErrorMessage(this.appWindow,SYNO.SDS.C2FS.Helper.ErrorMap.ERR_C2FS_FILE_PIN_PARTIAL_FAILED),SYNO.SDS.C2FS.FileBrowser.updateRecord(this.grid.store,r.successes_list,t,this.paging),SYNO.SDS.C2FS.FileBrowser.watchForCacheIcons(this,Object.keys(r.successes_list))}catch(e){SYNO.Debug(e),SYNO.SDS.C2FS.Helper.popupErrorMessage(this.appWindow,e.code)}finally{this.unmaskView()}})()},onUnpinClicked(e){(async()=>{this.maskView(_WFT("common","loading"),"x-mask-loading");try{const t=SYNO.SDS.C2FS.File.LocalStatus.Unpin,r=await this.sendWebAPIPromise(SYNO.SDS.C2FS.FileBrowser.getParams(t,e,SYNO.SDS.C2FS.File.LocalStatus.isValidPinStatus));r.has_some_failed&&SYNO.SDS.C2FS.Helper.popupErrorMessage(this.appWindow,SYNO.SDS.C2FS.Helper.ErrorMap.ERR_C2FS_FILE_UNPIN_PARTIAL_FAILED),SYNO.SDS.C2FS.FileBrowser.updateRecord(this.grid.store,r.successes_list,t,this.paging)}catch(e){SYNO.Debug(e),SYNO.SDS.C2FS.Helper.popupErrorMessage(this.appWindow,e.code)}finally{this.unmaskView()}})()},onRetryClicked(e){(async()=>{this.maskView(_WFT("common","loading"),"x-mask-loading");try{const t=SYNO.SDS.C2FS.File.LocalStatus.Pin,r=await this.sendWebAPIPromise(SYNO.SDS.C2FS.FileBrowser.getParams(t,e,SYNO.SDS.C2FS.File.LocalStatus.isRetryable));r.has_some_failed&&SYNO.SDS.C2FS.Helper.popupErrorMessage(this.appWindow,SYNO.SDS.C2FS.Helper.ErrorMap.ERR_C2FS_FILE_PIN_PARTIAL_FAILED),SYNO.SDS.C2FS.FileBrowser.updateRecord(this.grid.store,r.successes_list,t,this.paging),SYNO.SDS.C2FS.FileBrowser.watchForCacheIcons(this,Object.keys(r.successes_list))}catch(e){SYNO.Debug(e),SYNO.SDS.C2FS.Helper.popupErrorMessage(this.appWindow,e.code)}finally{this.unmaskView()}})()},_panelToFileIconWatchStore:new Map,watchForCacheIcons(e,t){const r=SYNO.SDS.C2FS.FileBrowser;if(r._panelToFileIconWatchStore.has(e)){const i=r._panelToFileIconWatchStore.get(e);i.addFiles(t),SYNO.SDS.C2FS.Utils.LocalStatusWatch.watchByFilePaths(t,i)}else{const i=new SYNO.SDS.C2FS.FileBrowser._IconWatchStore(e.grid.store,t);SYNO.SDS.C2FS.Utils.LocalStatusWatch.watchByFilePaths(t,i),r._panelToFileIconWatchStore.set(e,i)}},clearCacheIconWatches(e){const t=SYNO.SDS.C2FS.FileBrowser,r=t._panelToFileIconWatchStore.get(e);void 0!==r&&(t._panelToFileIconWatchStore.delete(e),SYNO.SDS.C2FS.Utils.LocalStatusWatch.stopWatchingByWatchStore(r))}}),Ext.ns("SYNO.SDS.C2FS.Utils"),SYNO.SDS.C2FS.Utils.Volume={async getSpaceUsageStatus(e){const t=this.extractPath(e),r=await synowebapi.promises.request({api:"SYNO.Storage.CGI.Volume",method:"get_space_usage",version:1,params:{volume_path:t}}),{status:i}=r;if("disabled"===(n=i)||"disabling"===n||"enabled"===n||"enabling"===n)return i;var n;throw new Error(`Unknown response: ${JSON.stringify(r)}`)},async setSpaceUsageStatus(e,t){const r=this.extractPath(e);await synowebapi.promises.request({api:"SYNO.Storage.CGI.Volume",method:`${t}_space_usage`,version:1,params:{volume_path:r}})},extractPath:function(e){const t=e.match("^(/volume[^/]+)");if(!t)throw new Error(`Invalid path: ${e}`);return t[0]}},function(){"use strict";var e={n:function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,{a:r}),r},d:function(t,r){for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=Vue,r=e.n(t),i=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("bkg-task-instance",{attrs:{task:e.task,"status-api":e.statusApi,"stop-api":e.stopApi}},[r("bkg-basic-task-card",{attrs:{"detail-app":e.detailApp,task:e.task},scopedSlots:e._u([{key:"info-wrapper",fn:function(){return[e._l(e.taskIds,function(t,i){return[0!==i?r("bkg-hr",{key:t+"-hdr"}):e._e(),e._v(" "),r("background-task-card-content",{key:t+"-content",attrs:{"task-id":t,"transform-status":e.apiData[t].transform_status,"share-name":e.apiData[t].share_name,progress:e.apiData[t].progress,"initial-cache-used-mb":e.apiData[t].initial_cache_used_mb},on:{"cancel-task":e.onCancel}})]})]},proxy:!0}])})],1)};i._withStripped=!0;var n=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("bkg-info-block",[r("div",{staticClass:"status-wrapper"},[r("bkg-status",{attrs:{status:e.status}}),e._v(" "),r("bkg-status-title",{attrs:{status:e.status,"status-title":e.statusTitle}}),e._v(" "),r("div",{staticClass:"status-actions"},[e._t("status-actions",function(){return[r("bkg-cancel-btn",{on:{click:function(t){return e.$emit("cancel-task",e.taskId)}}})]})],2)],1),e._v(" "),r("div",{staticClass:"info"},[r("bkg-progress-bar",{attrs:{title:e.shareName,"percent-text":e.progressRounded+"%",percent:e.progress,info:e.progressBarInfo}})],1)])};function s(e,t,r,i,n,s,o,a){var h,c="function"==typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=r,c._compiled=!0),i&&(c.functional=!0),s&&(c._scopeId="data-v-"+s),o?(h=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),n&&n.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},c._ssrRegister=h):n&&(h=a?function(){n.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:n),h)if(c.functional){c._injectStyles=h;var f=c.render;c.render=function(e,t){return h.call(t),f(e,t)}}else{var u=c.beforeCreate;c.beforeCreate=u?[].concat(u,h):[h]}return{exports:e,options:c}}n._withStripped=!0;var o=s({props:{taskId:{type:String,required:!0},transformStatus:{type:String,required:!0},shareName:{type:String,required:!0},progress:{type:Number,default:0,validator:e=>0<=e&&e<=100},initialCacheUsedMb:{type:Number,default:0}},data:()=>({helper:SYNO.SDS.C2FS.Helper}),computed:{status(){return this.isTransformUploading?"running":"prepare"},statusTitle(){return this.isTransformUploading?this.helper.T("transform","background_process_status"):this.helper.T("transform","background_prepare_status")},progressRounded(){return Math.round(this.progress)},progressBarInfo(){if(!this.isTransformUploading)return"";const e=this.initialCacheUsedMb*(this.progress/100);return`${SYNO.SDS.Utils.CapacityRender(e,1)} / ${SYNO.SDS.Utils.CapacityRender(this.initialCacheUsedMb,1)}`},isTransformUploading(){return"transform_upload"===this.transformStatus}}},n,[],!1,null,null,null),a=s({components:{BackgroundTaskCardContent:o.exports},props:{task:{type:Object,default:()=>({})}},data:()=>({statusApi:{api:"SYNO.API.Example",method:"status",version:1,params:{}},stopApi:{api:"SYNO.API.Example",method:"stop",version:1,params:{}},detailApp:{appJsId:"SYNO.SDS.C2FS.Application",params:{}},apiData:{},helper:SYNO.SDS.C2FS.Helper}),computed:{taskIds(){return Object.keys(this.apiData)}},async created(){if(Object.prototype.hasOwnProperty.call(this.task,"tasksData")){const e=Object.keys(this.task.tasksData);await this.updateTransformProgress(e)}},methods:{async _auth(){try{return await synowebapi.promises.request({api:"SYNO.C2FS.Transform",method:"list_progress",version:1}),!0}catch(e){SYNO.Debug("Unauthorized ",e)}return!1},async onCancel(e){const t=this.apiData[e].share_name;await this.confirmForCancel(t)&&await this.cancelTransform(e)},generateCancelConfirmMessage(e){if(e){const e=Ext.id(),t=Ext.id();return{htmlId:e,csvId:t,msg:String.format(this.helper.T("transform","cancel_confirm_notice"),'',"",``,"",``,"")}}return{htmlId:null,csvId:null,msg:""}},setCancelMessageExporter(e,t,r,i){Ext.get(e).on({scope:this,click:function(){t.exportFile(r,i)}},this)},confirmForCancel(e){const t=SYNO.SDS.C2FS.Share.Transform.CheckResultRecorder.Get(e),{htmlId:r,csvId:i,msg:n}=this.generateCancelConfirmMessage(t);return new Promise((s,o)=>{SYNO.SDS.Desktop.getMsgBox().confirm(String.format(this.helper.T("transform","cancel_confirm_title"),e),n,function(e){s("yes"===e)},this,{yes:!0,no:!0},{useMessageTitle:!0}),t&&(this.setCancelMessageExporter(r,SYNO.SDS.C2FS.Share.Transform.HtmlExporter,e,t),this.setCancelMessageExporter(i,SYNO.SDS.C2FS.Share.Transform.CSVExpoter,e,t))})},async cancelTransform(e){const t=this.apiData[e].share_name;try{await synowebapi.promises.request({api:"SYNO.C2FS.Transform",method:"cancel",version:1,params:{share_name:t}})}catch(e){return void this.alertCancelFailure(t)}this.$delete(this.apiData,e)},alertCancelFailure(e){SYNO.SDS.Desktop.getMsgBox().alert(String.format(this.helper.T("transform","cancel_failure_title"),e),String.format(this.helper.T("transform","cancel_failure_message"),'',""),null,null,{useMessageTitle:!0})},async onPostTask(e){await this.updateTransformProgress([e.task])},async updateTransformProgress(e){let t;try{t=await this.pollTransformProgress(e)}catch(t){return SYNO.Debug("Failed polling for transformation progress"),void e.forEach(e=>{this.$delete(this.apiData,e)})}for(const[r,i]of e.entries()){const e=t.result[r].data;if(void 0===e)continue;if(e.finished){this.$delete(this.apiData,i);continue}const n={share_name:e.share_name,transform_status:e.status,progress:e.progress.progress,initial_cache_used_mb:e.progress.initial_cache_used_mb};this.$set(this.apiData,i,n)}},pollTransformProgress(e){const t=e.map(e=>({api:"SYNO.C2FS.Transform",method:"get_progress",version:1,params:{task_id:e}}));return synowebapi.promises.request({api:"SYNO.Entry.Request",method:"request",version:1,compound:{stopwhenerror:!1,mode:"parallel",params:t}})},onDeleteTask(e){this.$delete(this.apiData,e.task)}}},i,[],!1,null,null,null).exports,h=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("bkg-task-instance",{attrs:{task:e.task,"status-api":e.statusApi,"stop-api":e.stopApi}},[r("bkg-basic-task-card",{attrs:{"detail-app":e.detailApp,task:e.task},scopedSlots:e._u([{key:"info-wrapper",fn:function(){return[e._l(e.taskIds,function(t,i){return[0!==i?r("bkg-hr",{key:t+"-hdr"}):e._e(),e._v(" "),r("pin-download-background-task-card-content",{key:t+"-content",attrs:{"share-name":e.taskData[t].share_name,"downloaded-bytes":e.taskData[t].downloaded_bytes,"will-download-bytes":e.taskData[t].will_download_bytes}})]})]},proxy:!0}])})],1)};h._withStripped=!0;var c=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("bkg-info-block",[r("div",{staticClass:"status-wrapper"},[r("bkg-status",{attrs:{status:"running"}}),e._v(" "),r("bkg-status-title",{attrs:{status:"running","status-title":e.statusTitle}})],1),e._v(" "),r("div",{staticClass:"info"},[r("bkg-progress-bar",{attrs:{title:e.shareName,"percent-text":e.progressRounded+"%",percent:e.progress,info:e.progressBarInfo}})],1)])};c._withStripped=!0;var f=s({props:{shareName:{type:String,required:!0},downloadedBytes:{type:Number,required:!0,validator:e=>e>=0},willDownloadBytes:{type:Number,required:!0,validator:e=>e>0}},data:()=>({statusTitle:SYNO.SDS.C2FS.Helper.T("app","pin_download_bkg_task_status_title")}),computed:{progress(){return 100*this.downloadedBytes/this.willDownloadBytes},progressRounded(){return Math.round(this.progress)},progressBarInfo(){const e=this.downloadedBytes/1024/1024,t=SYNO.SDS.Utils.CapacityRender(e,1),r=this.willDownloadBytes/1024/1024;return`${t} / ${SYNO.SDS.Utils.CapacityRender(r,1)}`}}},c,[],!1,null,null,null),u=s({components:{PinDownloadBackgroundTaskCardContent:f.exports},props:{task:{type:Object,default:()=>({})}},data:()=>({statusApi:{api:"SYNO.API.Example",method:"status",version:1,params:{}},stopApi:{api:"SYNO.API.Example",method:"stop",version:1,params:{}},detailApp:{appJsId:"SYNO.SDS.C2FS.Application",params:{}},taskData:{}}),computed:{taskIds(){return Object.keys(this.taskData)}},async created(){if(Object.prototype.hasOwnProperty.call(this.task,"tasksData")){const e={};for(const[t,r]of Object.entries(this.task.tasksData))e[t]=r.custom_data;await this.updateTaskData(e)}},methods:{async _auth(){try{return(await this.listShareWithPermission()).length>0}catch(e){SYNO.Debug("Unauthorized ",e)}return!1},async onPostTask(e){const t={};t[e.task]=e.custom_data,await this.updateTaskData(t)},onDeleteTask(e){const t=e.task;Object.prototype.hasOwnProperty.call(this.taskData,t)&&this.$delete(this.taskData,t)},listShareWithPermission:()=>synowebapi.promises.request({api:"SYNO.C2FS.Share",method:"list_accessible",version:1}),async updateTaskData(e){const t=await this.listShareWithPermission();for(const[r,i]of Object.entries(e))t.includes(i.share_name)&&this.$set(this.taskData,r,i)}}},h,[],!1,null,null,null).exports;Ext.ns("SYNO.SDS.C2FS.Share.Transform"),SYNO.SDS.C2FS.Share.Transform.BackgroundTask=r().extend(a),Ext.ns("SYNO.SDS.C2FS.App"),SYNO.SDS.C2FS.App.PinDownloadBackgroundTask=r().extend(u)}();