sys-shim 0.0.1-15 → 0.0.1-16

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "sys-shim",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "0.0.1-15",
5
+ "version": "0.0.1-16",
6
6
  "main": "./script/npm-pkg/node/main.min.cjs",
7
7
  "module": "./script/npm-pkg/node/main.min.mjs",
8
8
  "browser": {
@@ -63,7 +63,8 @@
63
63
  "dev": "run-p vite run.shim",
64
64
  "main:build": "npx download-cli https://github.com/wll8/sys-shim/releases/download/example/main.exe -o win-api/",
65
65
  "vite": "vite",
66
- "test": "vitest --reporter=basic",
66
+ "test": "vitest",
67
+ "test:basic": "vitest --reporter=basic",
67
68
  "preview": "vite preview",
68
69
  "gen.npm": "node script/gen.npm.mjs",
69
70
  "gen.npm.push": "cross-env push=yes node script/gen.npm.mjs",
@@ -134,7 +134,7 @@ function zip(cfg) {
134
134
  * -idv 显示详细输出
135
135
  */
136
136
  const outName = nameSuffix ? `${out}-${dayjs(Date.now()).format(`YYYY-MM-DD-HH-mm-ss`)}` : out
137
- const cmd = `${zipBin} a -r -ep1 -y -ibck -sfx -iicon"${icon}" -z"${comment}" "${outName}" "${input}/*"`
137
+ const cmd = `"${zipBin}" a -r -ep1 -y -ibck -sfx -iicon"${icon}" -z"${comment}" "${outName}" "${input}/*"`
138
138
  cp.execSync(cmd, {stdio: `inherit`})
139
139
  }
140
140
 
@@ -1,6 +1,6 @@
1
- function e(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var t={exports:{}};t.exports=function(){function t(r,n,o){function i(a,u){if(!n[a]){if(!r[a]){if(!u&&e)return e(a);if(s)return s(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[a]={exports:{}};r[a][0].call(f.exports,(function(e){return i(r[a][1][e]||e)}),f,f.exports,t,r,n,o)}return n[a].exports}for(var s=e,a=0;a<o.length;a++)i(o[a]);return i}return t}()({1:[function(e,t,r){var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.Client=void 0;var o=n(e("@babel/runtime/helpers/createClass")),i=n(e("@babel/runtime/helpers/classCallCheck")),s=n(e("@babel/runtime/helpers/inherits")),a=n(e("@babel/runtime/helpers/possibleConstructorReturn")),u=n(e("@babel/runtime/helpers/getPrototypeOf")),c=n(e("./lib/client/websocket.browser"));function f(e){var t=l();return function(){var r,n=(0,u.default)(e);if(t){var o=(0,u.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,a.default)(this,r)}}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var h=function(e){(0,s.default)(r,e);var t=f(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ws://localhost:8080",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.autoconnect,s=void 0===o||o,a=n.reconnect,u=void 0===a||a,f=n.reconnect_interval,l=void 0===f?1e3:f,h=n.max_reconnects,p=void 0===h?5:h,d=arguments.length>2?arguments[2]:void 0;return(0,i.default)(this,r),t.call(this,c.default,e,{autoconnect:s,reconnect:u,reconnect_interval:l,max_reconnects:p},d)}return(0,o.default)(r)}(n(e("./lib/client")).default);r.Client=h},{"./lib/client":2,"./lib/client/websocket.browser":3,"@babel/runtime/helpers/classCallCheck":7,"@babel/runtime/helpers/createClass":8,"@babel/runtime/helpers/getPrototypeOf":9,"@babel/runtime/helpers/inherits":10,"@babel/runtime/helpers/interopRequireDefault":11,"@babel/runtime/helpers/possibleConstructorReturn":12}],2:[function(e,t,r){(function(t){(function(){var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var o=n(e("@babel/runtime/regenerator")),i=n(e("@babel/runtime/helpers/asyncToGenerator")),s=n(e("@babel/runtime/helpers/typeof")),a=n(e("@babel/runtime/helpers/classCallCheck")),u=n(e("@babel/runtime/helpers/createClass")),c=n(e("@babel/runtime/helpers/inherits")),f=n(e("@babel/runtime/helpers/possibleConstructorReturn")),l=n(e("@babel/runtime/helpers/getPrototypeOf")),h=e("eventemitter3"),p=e("./utils");function d(e){var t=y();return function(){var r,n=(0,l.default)(e);if(t){var o=(0,l.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,f.default)(this,r)}}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var v=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},g=function(e){(0,c.default)(n,e);var r=d(n);function n(e){var t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ws://localhost:8080",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0,u=arguments.length>4?arguments[4]:void 0;(0,a.default)(this,n);var c=i.autoconnect,f=void 0===c||c,l=i.reconnect,h=void 0===l||l,d=i.reconnect_interval,y=void 0===d?1e3:d,g=i.max_reconnects,m=void 0===g?5:g,w=v(i,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return(t=r.call(this)).webSocketFactory=e,t.queue={},t.rpc_id=0,t.address=o,t.autoconnect=f,t.ready=!1,t.reconnect=h,t.reconnect_timer_id=void 0,t.reconnect_interval=y,t.max_reconnects=m,t.rest_options=w,t.current_reconnects=0,t.generate_request_id=s||function(){return++t.rpc_id},t.dataPack=u||new p.DefaultDataPack,t.autoconnect&&t._connect(t.address,Object.assign({autoconnect:t.autoconnect,reconnect:t.reconnect,reconnect_interval:t.reconnect_interval,max_reconnects:t.max_reconnects},t.rest_options)),t}return(0,u.default)(n,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(e,t,r,n){var o=this;return n||"object"!==(0,s.default)(r)||(n=r,r=null),new Promise((function(i,s){if(!o.ready)return s(new Error("socket not ready"));var a=o.generate_request_id(e,t),u={jsonrpc:"2.0",method:e,params:t||void 0,id:a};o.socket.send(o.dataPack.encode(u),n,(function(e){if(e)return s(e);o.queue[a]={promise:[i,s]},r&&(o.queue[a].timeout=setTimeout((function(){delete o.queue[a],s(new Error("reply timeout"))}),r))}))}))}},{key:"login",value:function(){var e=(0,i.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.call("rpc.login",t);case 2:if(r=e.sent){e.next=5;break}throw new Error("authentication failed");case 5:return e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"listMethods",value:function(){var e=(0,i.default)(o.default.mark((function e(){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.call("__listMethods");case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"notify",value:function(e,t){var r=this;return new Promise((function(n,o){if(!r.ready)return o(new Error("socket not ready"));var i={jsonrpc:"2.0",method:e,params:t};r.socket.send(r.dataPack.encode(i),(function(e){if(e)return o(e);n()}))}))}},{key:"subscribe",value:function(){var e=(0,i.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"string"==typeof t&&(t=[t]),e.next=3,this.call("rpc.on",t);case 3:if(r=e.sent,"string"!=typeof t||"ok"===r[t]){e.next=6;break}throw new Error("Failed subscribing to an event '"+t+"' with: "+r[t]);case 6:return e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"unsubscribe",value:function(){var e=(0,i.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"string"==typeof t&&(t=[t]),e.next=3,this.call("rpc.off",t);case 3:if(r=e.sent,"string"!=typeof t||"ok"===r[t]){e.next=6;break}throw new Error("Failed unsubscribing from an event with: "+r);case 6:return e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"close",value:function(e,t){this.socket.close(e||1e3,t)}},{key:"_connect",value:function(e,r){var n=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,r),this.socket.addEventListener("open",(function(){n.ready=!0,n.emit("open"),n.current_reconnects=0})),this.socket.addEventListener("message",(function(e){var r=e.data;r instanceof ArrayBuffer&&(r=t.from(r).toString());try{r=n.dataPack.decode(r)}catch(e){return}if(r.notification&&n.listeners(r.notification).length){if(!Object.keys(r.params).length)return n.emit(r.notification);var o=[r.notification];if(r.params.constructor===Object)o.push(r.params);else for(var i=0;i<r.params.length;i++)o.push(r.params[i]);return Promise.resolve().then((function(){n.emit.apply(n,o)}))}if(!n.queue[r.id])return r.method?Promise.resolve().then((function(){n.emit(r.method,null==r?void 0:r.params)})):void 0;"error"in r=="result"in r&&n.queue[r.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),n.queue[r.id].timeout&&clearTimeout(n.queue[r.id].timeout),r.error?n.queue[r.id].promise[1](r.error):n.queue[r.id].promise[0](r.result),delete n.queue[r.id]})),this.socket.addEventListener("error",(function(e){return n.emit("error",e)})),this.socket.addEventListener("close",(function(t){var o=t.code,i=t.reason;n.ready&&setTimeout((function(){return n.emit("close",o,i)}),0),n.ready=!1,n.socket=void 0,1e3!==o&&(n.current_reconnects++,n.reconnect&&(n.max_reconnects>n.current_reconnects||0===n.max_reconnects)&&(n.reconnect_timer_id=setTimeout((function(){return n._connect(e,r)}),n.reconnect_interval)))}))}}]),n}(h.EventEmitter);r.default=g}).call(this)}).call(this,e("buffer").Buffer)},{"./utils":4,"@babel/runtime/helpers/asyncToGenerator":6,"@babel/runtime/helpers/classCallCheck":7,"@babel/runtime/helpers/createClass":8,"@babel/runtime/helpers/getPrototypeOf":9,"@babel/runtime/helpers/inherits":10,"@babel/runtime/helpers/interopRequireDefault":11,"@babel/runtime/helpers/possibleConstructorReturn":12,"@babel/runtime/helpers/typeof":15,"@babel/runtime/regenerator":16,buffer:18,eventemitter3:19}],3:[function(e,t,r){var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=h;var o=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/inherits")),a=n(e("@babel/runtime/helpers/possibleConstructorReturn")),u=n(e("@babel/runtime/helpers/getPrototypeOf"));function c(e){var t=f();return function(){var r,n=(0,u.default)(e);if(t){var o=(0,u.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,a.default)(this,r)}}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var l=function(e){(0,s.default)(r,e);var t=c(r);function r(e,n,i){var s;return(0,o.default)(this,r),(s=t.call(this)).socket=new window.WebSocket(e,i),s.socket.onopen=function(){return s.emit("open")},s.socket.onmessage=function(e){return s.emit("message",e.data)},s.socket.onerror=function(e){return s.emit("error",e)},s.socket.onclose=function(e){s.emit("close",e.code,e.reason)},s}return(0,i.default)(r,[{key:"send",value:function(e,t,r){var n=r||t;try{this.socket.send(e),n()}catch(e){n(e)}}},{key:"close",value:function(e,t){this.socket.close(e,t)}},{key:"addEventListener",value:function(e,t,r){this.socket.addEventListener(e,t,r)}}]),r}(e("eventemitter3").EventEmitter);function h(e,t){return new l(e,t)}},{"@babel/runtime/helpers/classCallCheck":7,"@babel/runtime/helpers/createClass":8,"@babel/runtime/helpers/getPrototypeOf":9,"@babel/runtime/helpers/inherits":10,"@babel/runtime/helpers/interopRequireDefault":11,"@babel/runtime/helpers/possibleConstructorReturn":12,eventemitter3:19}],4:[function(e,t,r){var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.DefaultDataPack=void 0,r.createError=u;var o=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=new Map([[-32e3,"Event not provided"],[-32600,"Invalid Request"],[-32601,"Method not found"],[-32602,"Invalid params"],[-32603,"Internal error"],[-32604,"Params not found"],[-32605,"Method forbidden"],[-32606,"Event forbidden"],[-32700,"Parse error"]]),a=function(){function e(){(0,o.default)(this,e)}return(0,i.default)(e,[{key:"encode",value:function(e){return JSON.stringify(e)}},{key:"decode",value:function(e){return JSON.parse(e)}}]),e}();function u(e,t){var r={code:e,message:s.get(e)||"Internal Server Error"};return t&&(r.data=t),r}r.DefaultDataPack=a},{"@babel/runtime/helpers/classCallCheck":7,"@babel/runtime/helpers/createClass":8,"@babel/runtime/helpers/interopRequireDefault":11}],5:[function(e,t,r){function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],6:[function(e,t,r){function n(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var s=e.apply(t,r);function a(e){n(s,o,i,a,u,"next",e)}function u(e){n(s,o,i,a,u,"throw",e)}a(void 0)}))}}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},{}],7:[function(e,t,r){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],8:[function(e,t,r){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},{}],9:[function(e,t,r){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],10:[function(e,t,r){var n=e("./setPrototypeOf.js");function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&n(e,t)}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},{"./setPrototypeOf.js":14}],11:[function(e,t,r){function n(e){return e&&e.__esModule?e:{default:e}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],12:[function(e,t,r){var n=e("./typeof.js").default,o=e("./assertThisInitialized.js");function i(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return o(e)}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports},{"./assertThisInitialized.js":5,"./typeof.js":15}],13:[function(e,t,r){var n=e("./typeof.js").default;function o(){
1
+ function e(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var t={exports:{}};t.exports=function(){function t(r,n,o){function i(a,u){if(!n[a]){if(!r[a]){if(!u&&e)return e(a);if(s)return s(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[a]={exports:{}};r[a][0].call(f.exports,(function(e){return i(r[a][1][e]||e)}),f,f.exports,t,r,n,o)}return n[a].exports}for(var s=e,a=0;a<o.length;a++)i(o[a]);return i}return t}()({1:[function(e,t,r){var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.Client=void 0;var o=n(e("@babel/runtime/helpers/createClass")),i=n(e("@babel/runtime/helpers/classCallCheck")),s=n(e("@babel/runtime/helpers/inherits")),a=n(e("@babel/runtime/helpers/possibleConstructorReturn")),u=n(e("@babel/runtime/helpers/getPrototypeOf")),c=n(e("./lib/client/websocket.browser"));function f(e){var t=l();return function(){var r,n=(0,u.default)(e);if(t){var o=(0,u.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,a.default)(this,r)}}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var h=function(e){(0,s.default)(r,e);var t=f(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ws://localhost:8080",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.autoconnect,s=void 0===o||o,a=n.reconnect,u=void 0===a||a,f=n.reconnect_interval,l=void 0===f?1e3:f,h=n.max_reconnects,p=void 0===h?5:h,d=arguments.length>2?arguments[2]:void 0;return(0,i.default)(this,r),t.call(this,c.default,e,{autoconnect:s,reconnect:u,reconnect_interval:l,max_reconnects:p},d)}return(0,o.default)(r)}(n(e("./lib/client")).default);r.Client=h},{"./lib/client":2,"./lib/client/websocket.browser":3,"@babel/runtime/helpers/classCallCheck":7,"@babel/runtime/helpers/createClass":8,"@babel/runtime/helpers/getPrototypeOf":9,"@babel/runtime/helpers/inherits":10,"@babel/runtime/helpers/interopRequireDefault":11,"@babel/runtime/helpers/possibleConstructorReturn":12}],2:[function(e,t,r){(function(t){(function(){var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var o=n(e("@babel/runtime/regenerator")),i=n(e("@babel/runtime/helpers/asyncToGenerator")),s=n(e("@babel/runtime/helpers/typeof")),a=n(e("@babel/runtime/helpers/classCallCheck")),u=n(e("@babel/runtime/helpers/createClass")),c=n(e("@babel/runtime/helpers/inherits")),f=n(e("@babel/runtime/helpers/possibleConstructorReturn")),l=n(e("@babel/runtime/helpers/getPrototypeOf")),h=e("eventemitter3"),p=e("./utils");function d(e){var t=y();return function(){var r,n=(0,l.default)(e);if(t){var o=(0,l.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,f.default)(this,r)}}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var g=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},v=function(e){(0,c.default)(n,e);var r=d(n);function n(e){var t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ws://localhost:8080",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0,u=arguments.length>4?arguments[4]:void 0;(0,a.default)(this,n);var c=i.autoconnect,f=void 0===c||c,l=i.reconnect,h=void 0===l||l,d=i.reconnect_interval,y=void 0===d?1e3:d,v=i.max_reconnects,m=void 0===v?5:v,w=g(i,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return(t=r.call(this)).webSocketFactory=e,t.queue={},t.rpc_id=0,t.address=o,t.autoconnect=f,t.ready=!1,t.reconnect=h,t.reconnect_timer_id=void 0,t.reconnect_interval=y,t.max_reconnects=m,t.rest_options=w,t.current_reconnects=0,t.generate_request_id=s||function(){return++t.rpc_id},t.dataPack=u||new p.DefaultDataPack,t.autoconnect&&t._connect(t.address,Object.assign({autoconnect:t.autoconnect,reconnect:t.reconnect,reconnect_interval:t.reconnect_interval,max_reconnects:t.max_reconnects},t.rest_options)),t}return(0,u.default)(n,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(e,t,r,n){var o=this;return n||"object"!==(0,s.default)(r)||(n=r,r=null),new Promise((function(i,s){if(!o.ready)return s(new Error("socket not ready"));var a=o.generate_request_id(e,t),u={jsonrpc:"2.0",method:e,params:t||void 0,id:a};o.socket.send(o.dataPack.encode(u),n,(function(e){if(e)return s(e);o.queue[a]={promise:[i,s]},r&&(o.queue[a].timeout=setTimeout((function(){delete o.queue[a],s(new Error("reply timeout"))}),r))}))}))}},{key:"login",value:function(){var e=(0,i.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.call("rpc.login",t);case 2:if(r=e.sent){e.next=5;break}throw new Error("authentication failed");case 5:return e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"listMethods",value:function(){var e=(0,i.default)(o.default.mark((function e(){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.call("__listMethods");case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"notify",value:function(e,t){var r=this;return new Promise((function(n,o){if(!r.ready)return o(new Error("socket not ready"));var i={jsonrpc:"2.0",method:e,params:t};r.socket.send(r.dataPack.encode(i),(function(e){if(e)return o(e);n()}))}))}},{key:"subscribe",value:function(){var e=(0,i.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"string"==typeof t&&(t=[t]),e.next=3,this.call("rpc.on",t);case 3:if(r=e.sent,"string"!=typeof t||"ok"===r[t]){e.next=6;break}throw new Error("Failed subscribing to an event '"+t+"' with: "+r[t]);case 6:return e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"unsubscribe",value:function(){var e=(0,i.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"string"==typeof t&&(t=[t]),e.next=3,this.call("rpc.off",t);case 3:if(r=e.sent,"string"!=typeof t||"ok"===r[t]){e.next=6;break}throw new Error("Failed unsubscribing from an event with: "+r);case 6:return e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"close",value:function(e,t){this.socket.close(e||1e3,t)}},{key:"_connect",value:function(e,r){var n=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,r),this.socket.addEventListener("open",(function(){n.ready=!0,n.emit("open"),n.current_reconnects=0})),this.socket.addEventListener("message",(function(e){var r=e.data;r instanceof ArrayBuffer&&(r=t.from(r).toString());try{r=n.dataPack.decode(r)}catch(e){return}if(r.notification&&n.listeners(r.notification).length){if(!Object.keys(r.params).length)return n.emit(r.notification);var o=[r.notification];if(r.params.constructor===Object)o.push(r.params);else for(var i=0;i<r.params.length;i++)o.push(r.params[i]);return Promise.resolve().then((function(){n.emit.apply(n,o)}))}if(!n.queue[r.id])return r.method?Promise.resolve().then((function(){n.emit(r.method,null==r?void 0:r.params)})):void 0;"error"in r=="result"in r&&n.queue[r.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),n.queue[r.id].timeout&&clearTimeout(n.queue[r.id].timeout),r.error?n.queue[r.id].promise[1](r.error):n.queue[r.id].promise[0](r.result),delete n.queue[r.id]})),this.socket.addEventListener("error",(function(e){return n.emit("error",e)})),this.socket.addEventListener("close",(function(t){var o=t.code,i=t.reason;n.ready&&setTimeout((function(){return n.emit("close",o,i)}),0),n.ready=!1,n.socket=void 0,1e3!==o&&(n.current_reconnects++,n.reconnect&&(n.max_reconnects>n.current_reconnects||0===n.max_reconnects)&&(n.reconnect_timer_id=setTimeout((function(){return n._connect(e,r)}),n.reconnect_interval)))}))}}]),n}(h.EventEmitter);r.default=v}).call(this)}).call(this,e("buffer").Buffer)},{"./utils":4,"@babel/runtime/helpers/asyncToGenerator":6,"@babel/runtime/helpers/classCallCheck":7,"@babel/runtime/helpers/createClass":8,"@babel/runtime/helpers/getPrototypeOf":9,"@babel/runtime/helpers/inherits":10,"@babel/runtime/helpers/interopRequireDefault":11,"@babel/runtime/helpers/possibleConstructorReturn":12,"@babel/runtime/helpers/typeof":15,"@babel/runtime/regenerator":16,buffer:18,eventemitter3:19}],3:[function(e,t,r){var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=h;var o=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/inherits")),a=n(e("@babel/runtime/helpers/possibleConstructorReturn")),u=n(e("@babel/runtime/helpers/getPrototypeOf"));function c(e){var t=f();return function(){var r,n=(0,u.default)(e);if(t){var o=(0,u.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,a.default)(this,r)}}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var l=function(e){(0,s.default)(r,e);var t=c(r);function r(e,n,i){var s;return(0,o.default)(this,r),(s=t.call(this)).socket=new window.WebSocket(e,i),s.socket.onopen=function(){return s.emit("open")},s.socket.onmessage=function(e){return s.emit("message",e.data)},s.socket.onerror=function(e){return s.emit("error",e)},s.socket.onclose=function(e){s.emit("close",e.code,e.reason)},s}return(0,i.default)(r,[{key:"send",value:function(e,t,r){var n=r||t;try{this.socket.send(e),n()}catch(e){n(e)}}},{key:"close",value:function(e,t){this.socket.close(e,t)}},{key:"addEventListener",value:function(e,t,r){this.socket.addEventListener(e,t,r)}}]),r}(e("eventemitter3").EventEmitter);function h(e,t){return new l(e,t)}},{"@babel/runtime/helpers/classCallCheck":7,"@babel/runtime/helpers/createClass":8,"@babel/runtime/helpers/getPrototypeOf":9,"@babel/runtime/helpers/inherits":10,"@babel/runtime/helpers/interopRequireDefault":11,"@babel/runtime/helpers/possibleConstructorReturn":12,eventemitter3:19}],4:[function(e,t,r){var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.DefaultDataPack=void 0,r.createError=u;var o=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=new Map([[-32e3,"Event not provided"],[-32600,"Invalid Request"],[-32601,"Method not found"],[-32602,"Invalid params"],[-32603,"Internal error"],[-32604,"Params not found"],[-32605,"Method forbidden"],[-32606,"Event forbidden"],[-32700,"Parse error"]]),a=function(){function e(){(0,o.default)(this,e)}return(0,i.default)(e,[{key:"encode",value:function(e){return JSON.stringify(e)}},{key:"decode",value:function(e){return JSON.parse(e)}}]),e}();function u(e,t){var r={code:e,message:s.get(e)||"Internal Server Error"};return t&&(r.data=t),r}r.DefaultDataPack=a},{"@babel/runtime/helpers/classCallCheck":7,"@babel/runtime/helpers/createClass":8,"@babel/runtime/helpers/interopRequireDefault":11}],5:[function(e,t,r){function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],6:[function(e,t,r){function n(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var s=e.apply(t,r);function a(e){n(s,o,i,a,u,"next",e)}function u(e){n(s,o,i,a,u,"throw",e)}a(void 0)}))}}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},{}],7:[function(e,t,r){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],8:[function(e,t,r){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},{}],9:[function(e,t,r){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],10:[function(e,t,r){var n=e("./setPrototypeOf.js");function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&n(e,t)}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},{"./setPrototypeOf.js":14}],11:[function(e,t,r){function n(e){return e&&e.__esModule?e:{default:e}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],12:[function(e,t,r){var n=e("./typeof.js").default,o=e("./assertThisInitialized.js");function i(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return o(e)}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports},{"./assertThisInitialized.js":5,"./typeof.js":15}],13:[function(e,t,r){var n=e("./typeof.js").default;function o(){
2
2
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
3
- t.exports=o=function(){return e},t.exports.__esModule=!0,t.exports.default=t.exports;var e={},r=Object.prototype,i=r.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(e){f=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=t&&t.prototype instanceof d?t:d,i=Object.create(o.prototype),s=new R(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return k()}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=x(s,r);if(a){if(a===p)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=h(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,s),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var p={};function d(){}function y(){}function v(){}var g={};f(g,a,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(N([])));w&&w!==r&&i.call(w,a)&&(g=w);var b=v.prototype=d.prototype=Object.create(g);function _(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function r(o,s,a,u){var c=h(e[o],e,s);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==n(l)&&i.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,u)}),(function(e){r("throw",e,a,u)})):t.resolve(l).then((function(e){f.value=e,a(f)}),(function(e){return r("throw",e,a,u)}))}u(c.arg)}var o;this._invoke=function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}}function x(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=h(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,p;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function N(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:k}}function k(){return{value:void 0,done:!0}}return y.prototype=v,f(b,"constructor",v),f(v,"constructor",y),y.displayName=f(v,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,f(e,c,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},_(E.prototype),f(E.prototype,u,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new E(l(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},_(b),f(b,c,"Generator"),f(b,a,(function(){return this})),f(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=N,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=i.call(o,"catchLoc"),u=i.call(o,"finallyLoc");if(a&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:N(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},{"./typeof.js":15}],14:[function(e,t,r){function n(e,r){return t.exports=n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},t.exports.__esModule=!0,t.exports.default=t.exports,n(e,r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],15:[function(e,t,r){function n(e){return t.exports=n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],16:[function(e,t,r){var n=e("../helpers/regeneratorRuntime")();t.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},{"../helpers/regeneratorRuntime":13}],17:[function(e,t,r){r.byteLength=f,r.toByteArray=h,r.fromByteArray=y;for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)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){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n}function l(e,t,r){return 3*(t+r)/4-r}function h(e){var t,r,n=c(e),s=n[0],a=n[1],u=new i(l(e,s,a)),f=0,h=a>0?s-4:s;for(r=0;r<h;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;return 2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,u[f++]=255&t),1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t),u}function p(e){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function d(e,t,r){for(var n,o=[],i=t;i<r;i+=3)n=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(p(n));return o.join("")}function y(e){for(var t,r=e.length,o=r%3,i=[],s=16383,a=0,u=r-o;a<u;a+=s)i.push(d(e,a,a+s>u?u:a+s));return 1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],18:[function(e,t,r){(function(t){(function(){var t=e("base64-js"),n=e("ieee754");r.Buffer=a,r.SlowBuffer=g,r.INSPECT_MAX_BYTES=50;var o=2147483647;function i(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(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 l(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return h(e,t);if(ArrayBuffer.isView(e))return p(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(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return d(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return a.from(n,t,r);var o=y(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function f(e,t,r){return c(e),e<=0?s(e):void 0!==t?"string"==typeof r?s(e).fill(t,r):s(e).fill(t):s(e)}function l(e){return c(e),s(e<0?0:0|v(e))}function h(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|m(e,t),n=s(r),o=n.write(e,t);return o!==r&&(n=n.slice(0,o)),n}function p(e){for(var t=e.length<0?0:0|v(e.length),r=s(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function d(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r)).__proto__=a.prototype,n}function y(e){if(a.isBuffer(e)){var t=0|v(e.length),r=s(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||H(e.length)?s(0):p(e):"Buffer"===e.type&&Array.isArray(e.data)?p(e.data):void 0}function v(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function g(e){return+e!=e&&(e=0),a.alloc(+e)}function m(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(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,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(e).length;default:if(o)return n?-1:Y(e).length;t=(""+t).toLowerCase(),o=!0}}function w(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.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 I(this,t,r);case"utf8":case"utf-8":return P(this,t,r);case"ascii":return B(this,t,r);case"latin1":case"binary":return L(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function b(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function _(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:E(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):E(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function E(e,t,r,n,o){var i,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var f=-1;for(i=r;i<a;i++)if(c(e,i)===c(t,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(e,i+h)!==c(t,h)){l=!1;break}if(l)return i}return-1}function x(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(H(a))return s;e[r+s]=a}return s}function O(e,t,r,n){return J(Y(t,e.length-r),e,r,n)}function T(e,t,r,n){return J(W(t),e,r,n)}function R(e,t,r,n){return T(e,t,r,n)}function N(e,t,r,n){return J(K(t),e,r,n)}function k(e,t,r,n){return J(z(t,e.length-r),e,r,n)}function A(e,r,n){return 0===r&&n===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,n))}function P(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,s,a,u,c=e[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=l}return S(n)}r.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=i(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,r){return u(e,t,r)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,r){return f(e,t,r)},a.allocUnsafe=function(e){return l(e)},a.allocUnsafeSlow=function(e){return l(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),X(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=a.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var i=e[r];if(X(i,Uint8Array)&&(i=a.from(i)),!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},a.byteLength=m,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)b(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)b(this,t,t+3),b(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)b(this,t,t+7),b(this,t+1,t+6),b(this,t+2,t+5),b(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?P(this,0,e):w.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.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+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,r,n,o){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.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===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),u=Math.min(i,s),c=this.slice(n,o),f=e.slice(t,r),l=0;l<u;++l)if(c[l]!==f[l]){i=c[l],s=f[l];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},a.prototype.indexOf=function(e,t,r){return _(this,e,t,r,!0)},a.prototype.lastIndexOf=function(e,t,r){return _(this,e,t,r,!1)},a.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return x(this,e,t,r);case"utf8":case"utf-8":return O(this,e,t,r);case"ascii":return T(this,e,t,r);case"latin1":case"binary":return R(this,e,t,r);case"base64":return N(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function S(e){var t=e.length;if(t<=C)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=C));return r}function B(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function L(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function I(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=V(e[i]);return o}function U(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function D(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function M(e,t,r,n,o,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function j(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function F(e,t,r,o,i){return t=+t,r>>>=0,i||j(e,t,r,4),n.write(e,t,r,o,23,4),r+4}function $(e,t,r,o,i){return t=+t,r>>>=0,i||j(e,t,r,8),n.write(e,t,r,o,52,8),r+8}a.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<e&&(t=e);var n=this.subarray(e,t);return n.__proto__=a.prototype,n},a.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},a.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},a.prototype.readUInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||D(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||D(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||D(e,4,this.length),n.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||D(e,4,this.length),n.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||D(e,8,this.length),n.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||D(e,8,this.length),n.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||M(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},a.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||M(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(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},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(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},a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);M(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);M(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(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},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(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},a.prototype.writeFloatLE=function(e,t,r){return F(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return F(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return $(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return $(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o=n-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,n);else if(this===e&&r<t&&t<n)for(var i=o-1;i>=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return o},a.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var o=e.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(e=o)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=a.isBuffer(e)?e:a.from(e,n),u=s.length;if(0===u)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=s[i%u]}return this};var q=/[^+/0-9A-Za-z-_]/g;function G(e){if((e=(e=e.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function V(e){return e<16?"0"+e.toString(16):e.toString(16)}function Y(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.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;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function z(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}function K(e){return t.toByteArray(G(e))}function J(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function H(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":17,buffer:18,ieee754:20}],19:[function(e,t,r){var n=Object.prototype.hasOwnProperty,o="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,n,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new s(r,n||e,i),u=o?o+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function u(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(o=!1)),c.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)n.call(e,t)&&r.push(o?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},c.prototype.listeners=function(e){var t=o?o+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,i=r.length,s=new Array(i);n<i;n++)s[n]=r[n].fn;return s},c.prototype.listenerCount=function(e){var t=o?o+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,n,i,s){var a=o?o+e:e;if(!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,n),!0;case 5:return f.fn.call(f.context,t,r,n,i),!0;case 6:return f.fn.call(f.context,t,r,n,i,s),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;c<p;c++)switch(f[c].once&&this.removeListener(e,f[c].fn,void 0,!0),l){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,t);break;case 3:f[c].fn.call(f[c].context,t,r);break;case 4:f[c].fn.call(f[c].context,t,r,n);break;default:if(!u)for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},c.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,n){var i=o?o+e:e;if(!this._events[i])return this;if(!t)return u(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||n&&!s.once||r&&s.context!==r||u(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==t||n&&!s[a].once||r&&s[a].context!==r)&&c.push(s[a]);c.length?this._events[i]=1===c.length?c[0]:c:u(this,i)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=o?o+e:e,this._events[t]&&u(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=o,c.EventEmitter=c,void 0!==t&&(t.exports=c)},{}],20:[function(e,t,r){
3
+ t.exports=o=function(){return e},t.exports.__esModule=!0,t.exports.default=t.exports;var e={},r=Object.prototype,i=r.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(e){f=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=t&&t.prototype instanceof d?t:d,i=Object.create(o.prototype),s=new R(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return N()}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=x(s,r);if(a){if(a===p)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=h(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,s),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var p={};function d(){}function y(){}function g(){}var v={};f(v,a,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(A([])));w&&w!==r&&i.call(w,a)&&(v=w);var b=g.prototype=d.prototype=Object.create(v);function _(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function r(o,s,a,u){var c=h(e[o],e,s);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==n(l)&&i.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,u)}),(function(e){r("throw",e,a,u)})):t.resolve(l).then((function(e){f.value=e,a(f)}),(function(e){return r("throw",e,a,u)}))}u(c.arg)}var o;this._invoke=function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}}function x(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=h(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,p;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function A(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:N}}function N(){return{value:void 0,done:!0}}return y.prototype=g,f(b,"constructor",g),f(g,"constructor",y),y.displayName=f(g,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,f(e,c,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},_(E.prototype),f(E.prototype,u,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new E(l(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},_(b),f(b,c,"Generator"),f(b,a,(function(){return this})),f(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=A,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=i.call(o,"catchLoc"),u=i.call(o,"finallyLoc");if(a&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},{"./typeof.js":15}],14:[function(e,t,r){function n(e,r){return t.exports=n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},t.exports.__esModule=!0,t.exports.default=t.exports,n(e,r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],15:[function(e,t,r){function n(e){return t.exports=n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{}],16:[function(e,t,r){var n=e("../helpers/regeneratorRuntime")();t.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},{"../helpers/regeneratorRuntime":13}],17:[function(e,t,r){r.byteLength=f,r.toByteArray=h,r.fromByteArray=y;for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)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){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n}function l(e,t,r){return 3*(t+r)/4-r}function h(e){var t,r,n=c(e),s=n[0],a=n[1],u=new i(l(e,s,a)),f=0,h=a>0?s-4:s;for(r=0;r<h;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;return 2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,u[f++]=255&t),1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t),u}function p(e){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function d(e,t,r){for(var n,o=[],i=t;i<r;i+=3)n=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(p(n));return o.join("")}function y(e){for(var t,r=e.length,o=r%3,i=[],s=16383,a=0,u=r-o;a<u;a+=s)i.push(d(e,a,a+s>u?u:a+s));return 1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],18:[function(e,t,r){(function(t){(function(){var t=e("base64-js"),n=e("ieee754");r.Buffer=a,r.SlowBuffer=v,r.INSPECT_MAX_BYTES=50;var o=2147483647;function i(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(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 l(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return h(e,t);if(ArrayBuffer.isView(e))return p(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(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return d(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return a.from(n,t,r);var o=y(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function f(e,t,r){return c(e),e<=0?s(e):void 0!==t?"string"==typeof r?s(e).fill(t,r):s(e).fill(t):s(e)}function l(e){return c(e),s(e<0?0:0|g(e))}function h(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|m(e,t),n=s(r),o=n.write(e,t);return o!==r&&(n=n.slice(0,o)),n}function p(e){for(var t=e.length<0?0:0|g(e.length),r=s(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function d(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r)).__proto__=a.prototype,n}function y(e){if(a.isBuffer(e)){var t=0|g(e.length),r=s(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||H(e.length)?s(0):p(e):"Buffer"===e.type&&Array.isArray(e.data)?p(e.data):void 0}function g(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function v(e){return+e!=e&&(e=0),a.alloc(+e)}function m(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(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,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(e).length;default:if(o)return n?-1:Y(e).length;t=(""+t).toLowerCase(),o=!0}}function w(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.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 I(this,t,r);case"utf8":case"utf-8":return S(this,t,r);case"ascii":return B(this,t,r);case"latin1":case"binary":return L(this,t,r);case"base64":return k(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function b(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function _(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:E(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):E(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function E(e,t,r,n,o){var i,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var f=-1;for(i=r;i<a;i++)if(c(e,i)===c(t,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(e,i+h)!==c(t,h)){l=!1;break}if(l)return i}return-1}function x(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(H(a))return s;e[r+s]=a}return s}function O(e,t,r,n){return J(Y(t,e.length-r),e,r,n)}function T(e,t,r,n){return J(W(t),e,r,n)}function R(e,t,r,n){return T(e,t,r,n)}function A(e,t,r,n){return J(K(t),e,r,n)}function N(e,t,r,n){return J(z(t,e.length-r),e,r,n)}function k(e,r,n){return 0===r&&n===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,n))}function S(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,s,a,u,c=e[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=l}return C(n)}r.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=i(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,r){return u(e,t,r)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,r){return f(e,t,r)},a.allocUnsafe=function(e){return l(e)},a.allocUnsafeSlow=function(e){return l(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),X(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=a.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var i=e[r];if(X(i,Uint8Array)&&(i=a.from(i)),!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},a.byteLength=m,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)b(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)b(this,t,t+3),b(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)b(this,t,t+7),b(this,t+1,t+6),b(this,t+2,t+5),b(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?S(this,0,e):w.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.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+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,r,n,o){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.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===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),u=Math.min(i,s),c=this.slice(n,o),f=e.slice(t,r),l=0;l<u;++l)if(c[l]!==f[l]){i=c[l],s=f[l];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},a.prototype.indexOf=function(e,t,r){return _(this,e,t,r,!0)},a.prototype.lastIndexOf=function(e,t,r){return _(this,e,t,r,!1)},a.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return x(this,e,t,r);case"utf8":case"utf-8":return O(this,e,t,r);case"ascii":return T(this,e,t,r);case"latin1":case"binary":return R(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var P=4096;function C(e){var t=e.length;if(t<=P)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=P));return r}function B(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function L(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function I(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=V(e[i]);return o}function U(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function D(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,r,n,o,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function M(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function F(e,t,r,o,i){return t=+t,r>>>=0,i||M(e,t,r,4),n.write(e,t,r,o,23,4),r+4}function $(e,t,r,o,i){return t=+t,r>>>=0,i||M(e,t,r,8),n.write(e,t,r,o,52,8),r+8}a.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<e&&(t=e);var n=this.subarray(e,t);return n.__proto__=a.prototype,n},a.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},a.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},a.prototype.readUInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||D(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||D(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||D(e,4,this.length),n.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||D(e,4,this.length),n.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||D(e,8,this.length),n.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||D(e,8,this.length),n.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||j(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},a.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||j(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(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},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(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},a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);j(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);j(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(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},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(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},a.prototype.writeFloatLE=function(e,t,r){return F(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return F(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return $(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return $(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o=n-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,n);else if(this===e&&r<t&&t<n)for(var i=o-1;i>=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return o},a.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var o=e.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(e=o)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=a.isBuffer(e)?e:a.from(e,n),u=s.length;if(0===u)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=s[i%u]}return this};var q=/[^+/0-9A-Za-z-_]/g;function G(e){if((e=(e=e.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function V(e){return e<16?"0"+e.toString(16):e.toString(16)}function Y(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.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;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function z(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}function K(e){return t.toByteArray(G(e))}function J(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function H(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":17,buffer:18,ieee754:20}],19:[function(e,t,r){var n=Object.prototype.hasOwnProperty,o="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,n,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new s(r,n||e,i),u=o?o+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function u(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(o=!1)),c.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)n.call(e,t)&&r.push(o?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},c.prototype.listeners=function(e){var t=o?o+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,i=r.length,s=new Array(i);n<i;n++)s[n]=r[n].fn;return s},c.prototype.listenerCount=function(e){var t=o?o+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,n,i,s){var a=o?o+e:e;if(!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,n),!0;case 5:return f.fn.call(f.context,t,r,n,i),!0;case 6:return f.fn.call(f.context,t,r,n,i,s),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;c<p;c++)switch(f[c].once&&this.removeListener(e,f[c].fn,void 0,!0),l){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,t);break;case 3:f[c].fn.call(f[c].context,t,r);break;case 4:f[c].fn.call(f[c].context,t,r,n);break;default:if(!u)for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},c.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,n){var i=o?o+e:e;if(!this._events[i])return this;if(!t)return u(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||n&&!s.once||r&&s.context!==r||u(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==t||n&&!s[a].once||r&&s[a].context!==r)&&c.push(s[a]);c.length?this._events[i]=1===c.length?c[0]:c:u(this,i)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=o?o+e:e,this._events[t]&&u(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=o,c.EventEmitter=c,void 0!==t&&(t.exports=c)},{}],20:[function(e,t,r){
4
4
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
5
- r.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?o-1:0,h=r?-1:1,p=e[t+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+e[t+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=c}return(p?-1:1)*s*Math.pow(2,i-n)},r.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+p]=255&s,p+=d,s/=256,c-=8);e[r+p-d]|=128*y}},{}]},{},[1])(1);var r=t.exports;function n(e,t){const r=e.slice();return r.push(t),r}const o=["apply","construct","defineProperty","deleteProperty","enumerate","get","getOwnPropertyDescriptor","getPrototypeOf","has","isExtensible","ownKeys","preventExtensions","set","setPrototypeOf"],i={get:1,set:1,deleteProperty:1,has:1,defineProperty:1,getOwnPropertyDescriptor:1};function s(e,t,r){let s=[],a={};return void 0!==r&&void 0!==r.path&&(s=r.path.split(".")),void 0!==r&&void 0!==r.userData&&(a=r.userData),function r(s,u,c={}){const f={rootTarget:e,path:u};Object.assign(f,a,c);const l={};for(const s of o){const o=i[s],a=t[s];void 0!==a&&(l[s]=void 0!==o?function(){const t=arguments[o];return f.nest=function(o,{userData:i={}}={}){return void 0===o&&(o=e),r(o,n(u,t),i)},a.apply(f,arguments)}:function(){return f.nest=function(e,{userData:t={}}={}){return void 0===e&&(e={}),r(e,u,t)},a.apply(f,arguments)})}return new Proxy(s,l)}(e,s)}const a=new Map;function u([e]){return a.get(e)||e}function c(e){const t=e.split("\n"),r=t.filter((e=>e.trim())).map((e=>e.match(/(^\s+)?/)[0].length)).sort(((e,t)=>e-t))[0];return t.map((e=>e.slice(r))).join("\n")}function f(){return`c_${function(){if("object"==typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues&&"function"==typeof Uint8Array)return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>{const t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))}let e=(new Date).getTime(),t="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(r=>{let n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:3&n|8).toString(16)}))}()}`.replace(/[_-]/g,"")}function l(e){return[NaN,null,void 0,"",[],{}].some((t=>("string"!=typeof e||!e)&&JSON.stringify(e)===JSON.stringify(t)))}const h="NE_FS_FILWRER",p="NE_FS_DIRCRER",d="NE_FS_REMVERR",y="NE_RT_NATPRME";function v(e,t=""){switch(e){case"NE_ST_OK":return"";case"NE_ST_INVSTKY":return`Invalid storage key format. The key should match regex: ${t}`;case"NE_ST_NOSTKEX":return`Unable to find storage key: ${t}`;case"NE_ST_STKEYWE":return`Unable to write data to key: ${t}`;case"NE_ST_NOSTDIR":return`Unable to read storage directory: ${t}`;case"NE_OS_UNLTOUP":return`Unable to update process id: ${t}`;case"NE_OS_INVNOTA":return`Invalid notification style arguments: ${t}`;case"NE_OS_INVMSGA":return`Invalid message box style arguments: ${t}`;case"NE_OS_TRAYIER":return"Unable to initialize the tray menu";case"NE_OS_INVKNPT":return`Invalid platform path name: ${t}`;case"NE_EX_EXTNOTC":return`${t} is not connected yet`;case h:return`Unable to write file: ${t}`;case p:return`Cannot create a directory in ${t}`;case d:return`Cannot remove path: ${t}`;case"NE_FS_FILRDER":return`Unable to open file: ${t}`;case"NE_FS_NOPATHE":return`Unable to open path ${t}`;case"NE_FS_COPYERR":return`Cannot perform copy: ${t}`;case"NE_FS_MOVEERR":return`Cannot perform move: ${t}`;case"NE_FS_FILOPER":return`Unable to open file: ${t}`;case"NE_FS_UNLTOUP":return`Unable to update opened file id: ${t}`;case"NE_FS_UNLTFOP":return`Unable to find storage key: ${t}`;case"NE_FS_UNLCWAT":return`Unable to create watcher for path: ${t}`;case"NE_FS_NOWATID":return`Unable to find watcher: ${t}`;case"NE_CF_UNBLWCF":return`Unable to load the window config file: ${t}`;case"NE_RT_INVTOKN":return"Invalid or expired NL_TOKEN value from client";case"NE_RT_APIPRME":return"Missing permission to access Native API";case y:return`Missing permission to execute the native method: ${t}`;case"NE_RT_NATRTER":return"Native method execution error occurred. Make sure that you've provided required parameters properly.";case"NE_RT_NATNTIM":return`${t} is not implemented in the Neutralinojs server`;case"NE_RS_TREEGER":return`Resource file tree generation error. ${t}is missing.`;case"NE_RS_UNBLDRE":return`Unable to load application resource file ${t}`;case"NE_SR_UNBSEND":return"Unable to send native message";case"NE_SR_UNBPARS":return"Unable to parse native call payload";case"NE_CF_UNBLDCF":return"Unable to load the config file: ${key}";case"NE_CF_UNSUPMD":return"Unsupported mode: ${key}. The default mode is selected."}}class g{constructor(e,t=""){return{code:e,message:v(e,t)}}}class m{constructor(e){this.base=e}async writeText(e){const[t,r]=await this.base.native.win.clip.write(e);if(t)throw new g(y,"clipboard.writeText");return r}async readText(){const[e,t]=await this.base.native.win.clip.read();if(e)throw new g(y,"clipboard.readText");return t}}class w{constructor(e){this.base=e}async createDirectory(e){const[t,r]=await this.base.native.fsys.createDir(e);if(t)throw new g(p,e);return r}async remove(e){const[t,r]=await this.base.native.fsys.remove(e);if(t)throw new g(d,e);return r}async writeFile(e,t){const[r,n]=await globalThis.main.ws.call("run",['\n var filename, data = ...\n var file = io.open(filename, "w")\n file.write(data)\n file.close()\n return {\n success: true\n }\n ',e,t]);if(r)throw new g(h,"filesystem.writeFile");return n}async appendFile(e,t){const[r,n]=await globalThis.main.ws.call("run",['\n var filename, data = ...\n var file = io.open(filename, "a") // a 为追加模式\n file.write(data)\n file.close()\n return {\n success: true\n }\n ',e,t]);if(r)throw new g(h,"filesystem.appendFile");return n}async writeBinaryFile(e,t){const r={type:"Buffer",data:[...new Int8Array(t)]};await globalThis.main.ws.call("run",["\n var filename, json = ...\n var buffer = raw.buffer(json)\n string.save(filename, buffer)\n ",e,r])}appendBinaryFile(e,t){console.warn("// todo")}async readFile(e,t={pos:void 0,size:void 0}){const[r,n]=await globalThis.main.ws.call("run",['\n var filename, arg = ...\n var file = io.open(filename, "r")\n file.seek("cur", arg.pos)\n file.setvbuf("full", arg.size)\n var str = file.read()\n file.close()\n return str\n ',e,t]);if(r)throw new g(h,"filesystem.readFile");return n}async readBinaryFile(e,t={pos:void 0,size:void 0}){const[r,n]=await globalThis.main.native.string.loadBuffer(e);return function(e){let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0;t<e.length;t++)r[t]=e[t];return t}(n.data)}openFile(e){console.warn("// todo")}updateOpenedFile(e,t,r){console.warn("// todo")}}let b,_=class{constructor(e){this.base=e}async execCommand(e,t={background:void 0,stdIn:void 0,cwd:void 0}){const[r,n]=await globalThis.main.ws.call("run",["\n var cmd, options = ...\n var back = process.workDir\n if(options.cwd) {\n process.workDir = options.cwd\n }\n var proc = process.popen(cmd)\n process.workDir = back\n if(options.background) {\n return {\n stdOut = '',\n stdErr = '',\n pid = proc.process.id,\n exitCode = -1,\n proc = proc,\n }\n } else {\n return {\n stdOut = proc.read(-1),\n stdErr = proc.readErr(-1),\n pid = proc.process.id,\n exitCode = proc.getExitCode(),\n proc = proc,\n }\n }\n ",e,t]);return n}async getEnv(e){return(await this.base.native.string.getenv(e))[1]}async getEnvs(){const{stdOut:e}=await this.execCommand("cmd /c set");return e.split("\r\n").reduce(((e,t)=>{let[r,...n]=t.split("=");return e[r]=n.join(""),e}),{})}async showOpenDialog(e,t={defaultPath:void 0,filters:[]}){const r=(t.filters||[]).map((e=>`${e.name}|${e.extensions.map((e=>`*.${e}`)).join(";")}`)).join("|");return(await this.base.native.fsys.dlg.open(r,e,t.defaultPath))[1]}async showSaveDialog(e,t={defaultPath:void 0,forceOverwrite:void 0,filters:[]}){const r=(t.filters||[]).map((e=>`${e.name}|${e.extensions.map((e=>`*.${e}`)).join(";")}`)).join("|");return(await this.base.native.fsys.dlg[t.forceOverwrite?"save":"saveOp"](r,e,t.defaultPath))[1]}async showFolderDialog(e,t={defaultPath:void 0}){return(await this.base.native.fsys.dlg.dir(t.defaultPath,void 0,e))[1]}async showMessageBox(e,t,r="OK",n="INFO"){const o={OK:0,OK_CANCEL:1,YES_NO:4,YES_NO_CANCEL:3,RETRY_CANCEL:5,ABORT_RETRY_IGNORE:2},i={INFO:64,WARNING:48,ERROR:16,QUESTION:32},s={ABORT:3,CANCEL:2,CONTINUE:11,IGNORE:5,NO:7,OK:1,RETRY:4,TRYAGAIN:10,YES:6},a=(await this.base.native.win.msgbox(t,e,o[r]|i[n]))[1];return Object.entries(s).find((([,e])=>e===a))[0]}async getPath(e){const t={name:{config:"3EB685DB-65F9-4CF6-A03A-E3EF65729F3D",data:"3EB685DB-65F9-4CF6-A03A-E3EF65729F3D",cache:"F1B32785-6FBA-4FCF-9D55-7B8E7F157091",documents:"FDD39AD0-238F-46AF-ADB4-6C85480369C7",pictures:"33E28130-4E1E-4676-835A-98395C3BC3BB",music:"4BD8D571-6D19-48D3-BE97-422220080E43",video:"18989B1D-99B5-455B-841C-AB7C74E4DDFC",downloads:"374DE290-123F-4565-9164-39C4925E467B",savedGames1:"4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4",savedGames2:"4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4"}},[r,n]=await this.base.native.fsys.knownFolder(t.name[e]);return n}async open(e){const[t,r]=await this.base.native.process.openUrl(e);return r}},E=class{constructor(e){this.base=e}async getOSInfo(){return{description:"Microsoft Windows 10 专业版",name:"Windows NT",version:"10.0.19045-4046"}}},x=class{constructor(e){this.base=e}async exit(e){this.killProcess()}async killProcess(){this.base.nativeMain.G.killAll()}async restartProcess(){console.warn("// todo")}async getConfig(){return(await this.base.nativeMain.G)[1].config}async broadcast(e,...t){return await this.base.nativeMain.G.rpcServer.publish(e,...t)}async readProcessInput(e){console.warn("// todo")}async writeProcessOutput(e){console.warn("// todo")}async writeProcessError(e){console.warn("// todo")}},O=class{constructor(e){this.base=e,this.msg=new this.base.Msg}async on(e,t){this.msg.on(e,t)}async off(e,t){this.msg.off(e,t)}async dispatch(e,t){console.warn("当前封装暂不能根据实例区分事件")}async broadcast(e,t){this.msg.emit(e,{detail:t})}};async function T(){Object.assign(globalThis,{NL_OS:"Windows",NL_ARCH:"// tdo",NL_APPID:"// todo",NL_APPVERSION:"NL_APPVERSION",NL_PORT:(await this.app.getConfig()).socket.port,NL_MODE:"// todo",NL_VERSION:await(async()=>{const[,e]=await this.base.ws.call("run",["return fsys.version.getInfo( io._exepath )"]);return[e.productVersion.build,e.productVersion.major,e.productVersion.minor,e.productVersion.revision].join(".")})(),NL_CVERSION:"// todo",NL_CWD:(await this.base.native.fsys.getCurDir())[1],NL_PATH:(await this.base.native.io.fullpath("~"))[1],NL_ARGS:await(async()=>{const[,e]=await this.base.ws.call("run",["return table.concat({io._exepath}, _ARGV)"]);return e})(),NL_PID:(await this.base.native.process.getId())[1],NL_RESMODE:"directory",NL_EXTENABLED:!0,NL_COMMIT:"// todo",NL_CCOMMIT:"// todo",NL_CMETHODS:"// todo",NL_WSAVSTLOADED:"// todo"})}class R{constructor(e){return this.base=e,this.clipboard=new m(e),this.filesystem=new w(e),this.os=new _(e),this.computer=new E(e),this.app=new x(e),this.events=new O(e),new Promise((async e=>{await T.apply(this),e(this)}))}}class N{constructor(e,{id:t,runType:r="thread"}){let[n,...o]=e;n=c(n).trim();const i="*".repeat((function(e){const t=e.match(/\/\*{1,}/g);if(!t)return 0;let r=0;for(const e of t){const t=e.length-1;t>r&&(r=t)}return r}(n)||0)+1),s=function(e,t){return e.replace(/#\{(\w+)\}/g,((r,n,o)=>{const i=function(e,t){const r=e.split("\n");for(let e=0;e<r.length;e++){const n=r[e].length;if(t<n)return r[e];t-=n+1}return null}(e,o).split("\n").filter((e=>e.trim())).map((e=>e.match(/(^\s+)?/)[0].length)).sort(((e,t)=>e-t))[0];return function(e,t={}){t={num:0,space:" ",skip:0,...t};return e.split("\n").map(((e,r)=>r<=t.skip?e:t.space.repeat(t.num)+e)).join("\n")}(t[n]||"",{num:i})}))}(c({thread:'\n var args = {...}\n thread.create(function(...){\n import lib;\n var tid = thread.getId()\n var runid = "#{id}"\n var args = {...}\n var res = null\n var err = false\n try {\n var code = /#{codeLine}\n var tid = thread.getId()\n var runid = "#{id}"\n var args = {...}\n #{code}\n #{codeLine}/\n fn, err = loadcode(code)\n res = {fn(table.unpack(args))}\n }\n catch (e) {\n err = err || tostring(e);\n }\n var data = {type: err ? "err" : "return", err: err, res: res, tid: tid}\n thread.command.publish(runid, data)\n }, table.unpack(args))\n ',main:'\n var tid = thread.getId()\n var runid = "#{id}"\n var args = {...}\n var res = null\n var err = false\n try {\n var code = /#{codeLine}\n var tid = thread.getId()\n var runid = "#{id}"\n var args = {...}\n #{code}\n #{codeLine}/\n fn, err = loadcode(code)\n res = {fn(table.unpack(args))}\n }\n catch (e) {\n err = err || tostring(e);\n }\n var data = {type: err ? "err" : "return", err: err, res: res, tid: tid}\n global.G.rpcServer.publish(runid, data)\n ',raw:n}[r]).trim(),{id:t,code:n,codeLine:i});this.id=t,this.codeClean=n,this.codeWrap=s,this.codeArg=o,this.newArg=[s,...o]}}class k{constructor(){const e=(e={})=>function({keys:e=["then","catch"],cb:t=(e=>new Promise((async(t,r)=>{setTimeout((()=>{t(e)}),1e3*Math.random())})))}={}){function r(e={}){return e.records||[]}return e.forEach((e=>{let t=Symbol(e);a.set(e,t),a.set(t,e)})),new s({},{get(n,o,i){let s=r(this);if(e.includes(o)){let e=t(s);return s.hackRun=!0,e[o].bind(e)}{s.push({type:"get",key:u([o])});let e=function(){};return this.nest(e,{userData:{records:s}})}},apply(e,n,o){let i=r(this);setTimeout((()=>{let e=r(this);!e.hackRun&&(t(e),e.hackRun=!0)}),0);const s=i[i.length-1].key;return i[i.length-1]={type:"apply",key:s,arg:o},this.nest((function(){}),{userData:{records:i}})},construct(e,t){let n=r(this);return n.push({type:"construct",arg:t}),this.nest((function(){}),{userData:{records:n}})},defineProperty(e,t,n){let o=r(this);return o.push({type:"defineProperty",key:t,arg:n}),this.nest((function(){}),{userData:{records:o}})},deleteProperty(e,t){let n=r(this);return n.push({type:"deleteProperty",key:t}),this.nest((function(){}),{userData:{records:n}})},set(e,t,n){let o=r(this);return o.push({type:"set",key:t,arg:n}),this.nest((function(){}),{userData:{records:o}})},getOwnPropertyDescriptor(e,t){return r(this).push({type:"getOwnPropertyDescriptor",key:t}),{configurable:!0,enumerable:!0,value:this.nest((function(){}))}},getPrototypeOf(e){let t=r(this);return t.push({type:"getPrototypeOf"}),this.nest((function(){}),{userData:{records:t}})},has(e,t){return r(this).push({type:"has",key:t}),!0},isExtensible(e){return r(this).push({type:"isExtensible"}),!0},setPrototypeOf(e,t){return r(this).push({type:"setPrototypeOf",arg:t}),!0},ownKeys(e){return r(this).push({type:"ownKeys"}),Reflect.ownKeys(e)},preventExtensions(e){return r(this).push({type:"preventExtensions"}),Object.preventExtensions(e),!0}})}({cb:t=>new Promise((async r=>{function n(e){return/^\d+$/.test(e)?`[${e}]`:`.${e}`}let o=[],i=-1,s=!1,a=t.reduce(((e,{type:t,key:r,arg:a=[]},u)=>("get"===t&&(e+=n(r)),"apply"===t&&(i+=1,o[i]=a,e+=`${n(r)}(${a.map(((e,t)=>{const r=(()=>{const t=function(e,t){const r=Object.prototype.toString.call(e).match(/\s(.+)]/)[1].toLowerCase();return t?r===t.toLowerCase():r}(e);return"string"===t&&/[\r\n]/.test(e)?"array":t})(),n=["object","array"].includes(r);s=s||n;const o=[i,t].join("_");return["function","asyncfunction"].includes(r)?c(`function(...){\n var args = {...}\n var argPath = "${o}"\n var cmd = thread.command()\n var id = "cb_arg_" ++ runid ++ "_" ++ tid ++ "_" ++ argPath\n var res\n thread.command.publish(runid, {type: "cb-arg", res: args, argPath: argPath, id: id, tid: tid});\n cmd[id] = function(...){\n res = ...\n win.quitMessage()\n }\n win.loopMessage() \n cmd[id] = null\n return res\n }`):n?`args[${i+1}][${t+1}]`:JSON.stringify(e)})).join(", ")})`),e)),"").slice(1);a=c(`\n return ${a}\n `),e._argList=o,r(await b.call("run",[a,...s?o:[]],e))}))});this.native=e(),this.nativeMain=e({runType:"main"})}get api(){return{neutralino:async()=>await new R(this)}}}class A extends k{constructor(...e){return super(),this.key="tray",new Promise((async t=>{const r=await b.call(`${this.key}.create`,e);this.hwnd=r,t(this)}))}on(e,t){return b.call(`${this.key}.on`,[this.hwnd,e]),b.on(`${this.hwnd}.${e}`,t)}off(e){b.call(`${this.key}.off`,[this.hwnd,e])}}class P extends k{constructor(...e){return super(),this.key="view",new Promise((async t=>{const r=await b.call(`${this.key}.create`,e);this.hwnd=r,t(this)}))}}class C extends k{constructor(...e){return super(),this}on(e,t){return b.on(e,(e=>{t(...e)}))}off(e){return b.off(e)}emit(...e){return b.call("run",["\n thread.command.publish(...);\n ",...e])}}let S=class e extends k{constructor(t){var r;t.log=!0===t.log?e=>{const t=String(e.id);let[r="",...n]=Array.from(e.reqRaw);var o;if(r=r.trim(),e.startTime&&(console.group(t),console.log(r),o=n,JSON.parse(JSON.stringify(o),((e,t)=>(!1===l(t)&&Array.isArray(t)&&(t=t.filter((e=>!l(e)))),l(t)?void 0:t)))&&console.table(n)),e.endTime){const[r,...n]=Array.from(e.resRaw);r?console.error(r):console.log(...n),console.groupEnd(t)}}:t.log,t.lib,b=t.ws,super(),this.ws=t.ws,this.log={all:r=r||new Map,on:function(e,t){var n=r.get(e);n?n.push(t):r.set(e,[t])},off:function(e,t){var n=r.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):r.set(e,[]))},emit:function(e,t){var n=r.get(e);n&&n.slice().map((function(e){e(t)})),(n=r.get("*"))&&n.slice().map((function(r){r(e,t)}))}},t.log&&this.log.on("log",t.log);const n=b.call;return b.call=async(e,t=[],r={})=>{r={runType:"thread",...r};const o=(()=>{const e=(t[0]||"").trim(),r=f(),n=new String(r);return n.cbTag=e.startsWith("return thread.command.cb_arg_code_")?e.match(/^return thread.command.cb_arg_(.{41})/)[1]:"",n})(),i=new N(t,{id:o,...r});let s={id:"",action:"",startTime:"",endTime:"",reqRaw:[],resRaw:[],id:o,action:e,startTime:Date.now(),reqRaw:[i.codeClean,...i.codeArg]};return this.log.emit("log",s),new Promise((async t=>{let s={id:"",action:"",startTime:"",endTime:"",reqRaw:[],resRaw:[],id:o,action:e,endTime:Date.now(),reqRaw:[i.codeClean,...i.codeArg],resRaw:[]};const a=async e=>{let{tid:n,type:i,err:a,res:u=[]}=e;if("cb-arg"===i){const{argPath:t,id:n}=e,o=t.split("_").reduce(((e,t)=>e[t]),r._argList),i=await o(...u);this.native.thread.command[n](i)}u=Array.from(u);const c=[a,...u];s.resRaw=c,["return","err"].includes(i)&&(this.log.emit("log",s),t(c),this.msg.off(o))};n.bind(b)(e,i.newArg).then((([e,...t])=>{e&&a({tid:0,type:"err",err:e,res:[]})})),this.msg.on(o,a)}))},new Promise((async(t,r)=>{if("object"==typeof e.instance)return e.instance;e.instance=this,b.on("open",(async()=>{this.Tray=A,this.View=P,this.Msg=C,this.msg=await new C,this.msg.on("native:log",console.debug),t(this)}))}))}};globalThis.ext=globalThis.ext||new Promise((async e=>{globalThis.ext=JSON.parse(await globalThis._ext||"{}"),delete globalThis._ext,e(globalThis.ext)}));const B={encoder:new globalThis.TextEncoder,decoder:new globalThis.TextDecoder};class L extends S{constructor(e={}){return e="string"==typeof e?{wsUrl:e}:e,new Promise((async(t,n)=>{try{globalThis.ext=await globalThis.ext,e.wsUrl=e.wsUrl||`${globalThis.ext.wsUrl}?token=${globalThis.ext.token}`;const n=new r.Client(e.wsUrl),o=await super({...e,ws:n,lib:B});o.hwnd=globalThis.ext.hwnd,t(o)}catch(e){n(e)}}))}}export{L as default};
5
+ r.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?o-1:0,h=r?-1:1,p=e[t+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+e[t+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=c}return(p?-1:1)*s*Math.pow(2,i-n)},r.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+p]=255&s,p+=d,s/=256,c-=8);e[r+p-d]|=128*y}},{}]},{},[1])(1);var r=t.exports;function n(e,t){const r=e.slice();return r.push(t),r}const o=["apply","construct","defineProperty","deleteProperty","enumerate","get","getOwnPropertyDescriptor","getPrototypeOf","has","isExtensible","ownKeys","preventExtensions","set","setPrototypeOf"],i={get:1,set:1,deleteProperty:1,has:1,defineProperty:1,getOwnPropertyDescriptor:1};function s(e,t,r){let s=[],a={};return void 0!==r&&void 0!==r.path&&(s=r.path.split(".")),void 0!==r&&void 0!==r.userData&&(a=r.userData),function r(s,u,c={}){const f={rootTarget:e,path:u};Object.assign(f,a,c);const l={};for(const s of o){const o=i[s],a=t[s];void 0!==a&&(l[s]=void 0!==o?function(){const t=arguments[o];return f.nest=function(o,{userData:i={}}={}){return void 0===o&&(o=e),r(o,n(u,t),i)},a.apply(f,arguments)}:function(){return f.nest=function(e,{userData:t={}}={}){return void 0===e&&(e={}),r(e,u,t)},a.apply(f,arguments)})}return new Proxy(s,l)}(e,s)}const a=new Map;function u([e]){return a.get(e)||e}function c(e){const t=e.split("\n"),r=t.filter((e=>e.trim())).map((e=>e.match(/(^\s+)?/)[0].length)).sort(((e,t)=>e-t))[0];return t.map((e=>e.slice(r))).join("\n")}function f(){return`c_${function(){if("object"==typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues&&"function"==typeof Uint8Array)return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>{const t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))}let e=(new Date).getTime(),t="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(r=>{let n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:3&n|8).toString(16)}))}()}`.replace(/[_-]/g,"")}function l(e){return[NaN,null,void 0,"",[],{}].some((t=>("string"!=typeof e||!e)&&JSON.stringify(e)===JSON.stringify(t)))}const h="NE_FS_FILWRER",p="NE_FS_DIRCRER",d="NE_FS_REMVERR",y="NE_RT_NATPRME";function g(e,t=""){switch(e){case"NE_ST_OK":return"";case"NE_ST_INVSTKY":return`Invalid storage key format. The key should match regex: ${t}`;case"NE_ST_NOSTKEX":return`Unable to find storage key: ${t}`;case"NE_ST_STKEYWE":return`Unable to write data to key: ${t}`;case"NE_ST_NOSTDIR":return`Unable to read storage directory: ${t}`;case"NE_OS_UNLTOUP":return`Unable to update process id: ${t}`;case"NE_OS_INVNOTA":return`Invalid notification style arguments: ${t}`;case"NE_OS_INVMSGA":return`Invalid message box style arguments: ${t}`;case"NE_OS_TRAYIER":return"Unable to initialize the tray menu";case"NE_OS_INVKNPT":return`Invalid platform path name: ${t}`;case"NE_EX_EXTNOTC":return`${t} is not connected yet`;case h:return`Unable to write file: ${t}`;case p:return`Cannot create a directory in ${t}`;case d:return`Cannot remove path: ${t}`;case"NE_FS_FILRDER":return`Unable to open file: ${t}`;case"NE_FS_NOPATHE":return`Unable to open path ${t}`;case"NE_FS_COPYERR":return`Cannot perform copy: ${t}`;case"NE_FS_MOVEERR":return`Cannot perform move: ${t}`;case"NE_FS_FILOPER":return`Unable to open file: ${t}`;case"NE_FS_UNLTOUP":return`Unable to update opened file id: ${t}`;case"NE_FS_UNLTFOP":return`Unable to find storage key: ${t}`;case"NE_FS_UNLCWAT":return`Unable to create watcher for path: ${t}`;case"NE_FS_NOWATID":return`Unable to find watcher: ${t}`;case"NE_CF_UNBLWCF":return`Unable to load the window config file: ${t}`;case"NE_RT_INVTOKN":return"Invalid or expired NL_TOKEN value from client";case"NE_RT_APIPRME":return"Missing permission to access Native API";case y:return`Missing permission to execute the native method: ${t}`;case"NE_RT_NATRTER":return"Native method execution error occurred. Make sure that you've provided required parameters properly.";case"NE_RT_NATNTIM":return`${t} is not implemented in the Neutralinojs server`;case"NE_RS_TREEGER":return`Resource file tree generation error. ${t}is missing.`;case"NE_RS_UNBLDRE":return`Unable to load application resource file ${t}`;case"NE_SR_UNBSEND":return"Unable to send native message";case"NE_SR_UNBPARS":return"Unable to parse native call payload";case"NE_CF_UNBLDCF":return"Unable to load the config file: ${key}";case"NE_CF_UNSUPMD":return"Unsupported mode: ${key}. The default mode is selected."}}class v{constructor(e,t=""){return{code:e,message:g(e,t)}}}class m{constructor(e){this.base=e}async writeText(e){const[t,r]=await this.base.native.win.clip.write(e);if(t)throw new v(y,"clipboard.writeText");return r}async readText(){const[e,t]=await this.base.native.win.clip.read();if(e)throw new v(y,"clipboard.readText");return t}}class w{constructor(e){this.base=e}async createDirectory(e){const[t,r]=await this.base.native.fsys.createDir(e);if(t)throw new v(p,e);return r}async remove(e){const[t,r]=await this.base.native.fsys.remove(e);if(t)throw new v(d,e);return r}async writeFile(e,t){const[r,n]=await globalThis.main.ws.call("run",['\n var filename, data = ...\n var file = io.open(filename, "w")\n file.write(data)\n file.close()\n return {\n success: true\n }\n ',e,t]);if(r)throw new v(h,"filesystem.writeFile");return n}async appendFile(e,t){const[r,n]=await globalThis.main.ws.call("run",['\n var filename, data = ...\n var file = io.open(filename, "a") // a 为追加模式\n file.write(data)\n file.close()\n return {\n success: true\n }\n ',e,t]);if(r)throw new v(h,"filesystem.appendFile");return n}async writeBinaryFile(e,t){const r={type:"Buffer",data:[...new Int8Array(t)]};await globalThis.main.ws.call("run",["\n var filename, json = ...\n var buffer = raw.buffer(json)\n string.save(filename, buffer)\n ",e,r])}appendBinaryFile(e,t){console.warn("// todo")}async readFile(e,t={pos:void 0,size:void 0}){const[r,n]=await globalThis.main.ws.call("run",['\n var filename, arg = ...\n var file = io.open(filename, "r")\n file.seek("cur", arg.pos)\n file.setvbuf("full", arg.size)\n var str = file.read()\n file.close()\n return str\n ',e,t]);if(r)throw new v(h,"filesystem.readFile");return n}async readBinaryFile(e,t={pos:void 0,size:void 0}){const[r,n]=await globalThis.main.native.string.loadBuffer(e);return function(e){let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0;t<e.length;t++)r[t]=e[t];return t}(n.data)}openFile(e){console.warn("// todo")}updateOpenedFile(e,t,r){console.warn("// todo")}}let b,_=class{constructor(e){this.base=e}async execCommand(e,t={background:void 0,stdIn:void 0,cwd:void 0}){const[r,n]=await globalThis.main.ws.call("run",["\n var cmd, options = ...\n var back = process.workDir\n if(options.cwd) {\n process.workDir = options.cwd\n }\n var proc = process.popen(cmd)\n process.workDir = back\n if(options.background) {\n return {\n stdOut = '',\n stdErr = '',\n pid = proc.process.id,\n exitCode = -1,\n proc = proc,\n }\n } else {\n return {\n stdOut = proc.read(-1),\n stdErr = proc.readErr(-1),\n pid = proc.process.id,\n exitCode = proc.getExitCode(),\n proc = proc,\n }\n }\n ",e,t]);return n}async getEnv(e){return(await this.base.native.string.getenv(e))[1]}async getEnvs(){const{stdOut:e}=await this.execCommand("cmd /c set");return e.split("\r\n").reduce(((e,t)=>{let[r,...n]=t.split("=");return e[r]=n.join(""),e}),{})}async showOpenDialog(e,t={defaultPath:void 0,filters:[]}){const r=(t.filters||[]).map((e=>`${e.name}|${e.extensions.map((e=>`*.${e}`)).join(";")}`)).join("|");return(await this.base.native.fsys.dlg.open(r,e,t.defaultPath))[1]}async showSaveDialog(e,t={defaultPath:void 0,forceOverwrite:void 0,filters:[]}){const r=(t.filters||[]).map((e=>`${e.name}|${e.extensions.map((e=>`*.${e}`)).join(";")}`)).join("|");return(await this.base.native.fsys.dlg[t.forceOverwrite?"save":"saveOp"](r,e,t.defaultPath))[1]}async showFolderDialog(e,t={defaultPath:void 0}){return(await this.base.native.fsys.dlg.dir(t.defaultPath,void 0,e))[1]}async showMessageBox(e,t,r="OK",n="INFO"){const o={OK:0,OK_CANCEL:1,YES_NO:4,YES_NO_CANCEL:3,RETRY_CANCEL:5,ABORT_RETRY_IGNORE:2},i={INFO:64,WARNING:48,ERROR:16,QUESTION:32},s={ABORT:3,CANCEL:2,CONTINUE:11,IGNORE:5,NO:7,OK:1,RETRY:4,TRYAGAIN:10,YES:6},a=(await this.base.native.win.msgbox(t,e,o[r]|i[n]))[1];return Object.entries(s).find((([,e])=>e===a))[0]}async getPath(e){const t={name:{config:"3EB685DB-65F9-4CF6-A03A-E3EF65729F3D",data:"3EB685DB-65F9-4CF6-A03A-E3EF65729F3D",cache:"F1B32785-6FBA-4FCF-9D55-7B8E7F157091",documents:"FDD39AD0-238F-46AF-ADB4-6C85480369C7",pictures:"33E28130-4E1E-4676-835A-98395C3BC3BB",music:"4BD8D571-6D19-48D3-BE97-422220080E43",video:"18989B1D-99B5-455B-841C-AB7C74E4DDFC",downloads:"374DE290-123F-4565-9164-39C4925E467B",savedGames1:"4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4",savedGames2:"4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4"}},[r,n]=await this.base.native.fsys.knownFolder(t.name[e]);return n}async open(e){const[t,r]=await this.base.native.process.openUrl(e);return r}},E=class{constructor(e){this.base=e}async getOSInfo(){return{description:"Microsoft Windows 10 专业版",name:"Windows NT",version:"10.0.19045-4046"}}},x=class{constructor(e){this.base=e}async exit(e){this.killProcess()}async killProcess(){this.base.nativeMain.G.killAll()}async restartProcess(){console.warn("// todo")}async getConfig(){return(await this.base.nativeMain.G)[1].config}async broadcast(e,...t){return await this.base.nativeMain.G.rpcServer.publish(e,...t)}async readProcessInput(e){console.warn("// todo")}async writeProcessOutput(e){console.warn("// todo")}async writeProcessError(e){console.warn("// todo")}},O=class{constructor(e){this.base=e,this.msg=new this.base.Msg}async on(e,t){this.msg.on(e,t)}async off(e,t){this.msg.off(e,t)}async dispatch(e,t){console.warn("当前封装暂不能根据实例区分事件")}async broadcast(e,t){this.msg.emit(e,{detail:t})}};async function T(){Object.assign(globalThis,{NL_OS:"Windows",NL_ARCH:"// tdo",NL_APPID:"// todo",NL_APPVERSION:"NL_APPVERSION",NL_PORT:(await this.app.getConfig()).socket.port,NL_MODE:"// todo",NL_VERSION:await(async()=>{const[,e]=await this.base.ws.call("run",["return fsys.version.getInfo( io._exepath )"]);return[e.productVersion.build,e.productVersion.major,e.productVersion.minor,e.productVersion.revision].join(".")})(),NL_CVERSION:"// todo",NL_CWD:(await this.base.native.fsys.getCurDir())[1],NL_PATH:(await this.base.native.io.fullpath("~"))[1],NL_ARGS:await(async()=>{const[,e]=await this.base.ws.call("run",["return table.concat({io._exepath}, _ARGV)"]);return e})(),NL_PID:(await this.base.native.process.getId())[1],NL_RESMODE:"directory",NL_EXTENABLED:!0,NL_COMMIT:"// todo",NL_CCOMMIT:"// todo",NL_CMETHODS:"// todo",NL_WSAVSTLOADED:"// todo"})}class R{constructor(e){return this.base=e,this.clipboard=new m(e),this.filesystem=new w(e),this.os=new _(e),this.computer=new E(e),this.app=new x(e),this.events=new O(e),new Promise((async e=>{await T.apply(this),e(this)}))}}class A{constructor(e,{id:t,runType:r="thread"}){let[n,...o]=e;n=c(n).trim();const i="*".repeat((function(e){const t=e.match(/\/\*{1,}/g);if(!t)return 0;let r=0;for(const e of t){const t=e.length-1;t>r&&(r=t)}return r}(n)||0)+1),s=function(e,t){return e.replace(/#\{(\w+)\}/g,((r,n,o)=>{const i=function(e,t){const r=e.split("\n");for(let e=0;e<r.length;e++){const n=r[e].length;if(t<n)return r[e];t-=n+1}return null}(e,o).split("\n").filter((e=>e.trim())).map((e=>e.match(/(^\s+)?/)[0].length)).sort(((e,t)=>e-t))[0];return function(e,t={}){t={num:0,space:" ",skip:0,...t};return e.split("\n").map(((e,r)=>r<=t.skip?e:t.space.repeat(t.num)+e)).join("\n")}(t[n]||"",{num:i})}))}(c({thread:'\n var args = {...}\n var argsStr = web.json.stringify(args)\n thread.create(function(argsStr){\n import lib;\n var tid = thread.getId()\n var runid = "#{id}"\n var args = web.json.parse(argsStr)\n var res = null\n var err = false\n try {\n var code = /#{codeLine}\n var tid = thread.getId()\n var runid = "#{id}"\n var args = {...}\n #{code}\n #{codeLine}/\n fn, err = loadcode(code)\n res = {fn(table.unpackArgs(args))}\n }\n catch (e) {\n err = err || tostring(e);\n }\n var resStr = web.json.stringify(res)\n var data = {type: err ? "err" : "return", err: err, res: resStr, tid: tid}\n thread.command.publish(runid, data)\n }, argsStr)\n ',main:'\n var tid = thread.getId()\n var runid = "#{id}"\n var args = {...}\n var argsStr = web.json.stringify(args)\n var res = null\n var err = false\n try {\n var code = /#{codeLine}\n var tid = thread.getId()\n var runid = "#{id}"\n var args = {...}\n #{code}\n #{codeLine}/\n fn, err = loadcode(code)\n res = {fn(table.unpackArgs(args))}\n }\n catch (e) {\n err = err || tostring(e);\n }\n var resStr = web.json.stringify(res)\n var data = {type: err ? "err" : "return", err: err, res: resStr, tid: tid}\n global.G.rpcServer.publish(runid, data)\n ',raw:n}[r]).trim(),{id:t,code:n,codeLine:i});this.id=t,this.codeClean=n,this.codeWrap=s,this.codeArg=o,this.newArg=[s,...o]}}class N{constructor(){const e=(e={})=>function({keys:e=["then","catch"],cb:t=(e=>new Promise((async(t,r)=>{setTimeout((()=>{t(e)}),1e3*Math.random())})))}={}){function r(e={}){return e.records||[]}return e.forEach((e=>{let t=Symbol(e);a.set(e,t),a.set(t,e)})),new s({},{get(n,o,i){let s=r(this);if(e.includes(o)){let e=t(s);return s.hackRun=!0,e[o].bind(e)}{s.push({type:"get",key:u([o])});let e=function(){};return this.nest(e,{userData:{records:s}})}},apply(e,n,o){let i=r(this);setTimeout((()=>{let e=r(this);!e.hackRun&&(t(e),e.hackRun=!0)}),0);const s=i[i.length-1].key;return i[i.length-1]={type:"apply",key:s,arg:o},this.nest((function(){}),{userData:{records:i}})},construct(e,t){let n=r(this);return n.push({type:"construct",arg:t}),this.nest((function(){}),{userData:{records:n}})},defineProperty(e,t,n){let o=r(this);return o.push({type:"defineProperty",key:t,arg:n}),this.nest((function(){}),{userData:{records:o}})},deleteProperty(e,t){let n=r(this);return n.push({type:"deleteProperty",key:t}),this.nest((function(){}),{userData:{records:n}})},set(e,t,n){let o=r(this);return o.push({type:"set",key:t,arg:n}),this.nest((function(){}),{userData:{records:o}})},getOwnPropertyDescriptor(e,t){return r(this).push({type:"getOwnPropertyDescriptor",key:t}),{configurable:!0,enumerable:!0,value:this.nest((function(){}))}},getPrototypeOf(e){let t=r(this);return t.push({type:"getPrototypeOf"}),this.nest((function(){}),{userData:{records:t}})},has(e,t){return r(this).push({type:"has",key:t}),!0},isExtensible(e){return r(this).push({type:"isExtensible"}),!0},setPrototypeOf(e,t){return r(this).push({type:"setPrototypeOf",arg:t}),!0},ownKeys(e){return r(this).push({type:"ownKeys"}),Reflect.ownKeys(e)},preventExtensions(e){return r(this).push({type:"preventExtensions"}),Object.preventExtensions(e),!0}})}({cb:t=>new Promise((async r=>{function n(e){return/^\d+$/.test(e)?`[${e}]`:`.${e}`}let o=[],i=-1,s=!1,a=t.reduce(((e,{type:t,key:r,arg:a=[]},u)=>("get"===t&&(e+=n(r)),"apply"===t&&(i+=1,o[i]=a,e+=`${n(r)}(${a.map(((e,t)=>{const r=(()=>{const t=function(e,t){const r=Object.prototype.toString.call(e).match(/\s(.+)]/)[1].toLowerCase();return t?r===t.toLowerCase():r}(e);return"string"===t&&/[\r\n]/.test(e)?"array":t})(),n=["object","array"].includes(r);s=s||n;const o=[i,t].join("_");return["function","asyncfunction"].includes(r)?c(`function(...){\n var args = {...}\n var argsStr = web.json.stringify(args)\n var argPath = "${o}"\n var cmd = thread.command()\n var id = "cb_arg_" ++ runid ++ "_" ++ tid ++ "_" ++ argPath\n var res\n thread.command.publish(runid, {type: "cb-arg", res: argsStr, argPath: argPath, id: id, tid: tid});\n cmd[id] = function(...){\n res = ...\n win.quitMessage()\n }\n win.loopMessage() \n cmd[id] = null\n return res\n }`):n?`args[${i+1}][${t+1}]`:JSON.stringify(e)})).join(", ")})`),e)),"").slice(1);a=c(`\n return ${a}\n `),e._argList=o,r(await b.call("run",[a,...s?o:[]],e))}))});this.native=e(),this.nativeMain=e({runType:"main"})}get api(){return{neutralino:async()=>await new R(this)}}}class k extends N{constructor(...e){return super(),this.key="tray",new Promise((async t=>{const r=await b.call(`${this.key}.create`,e);this.hwnd=r,t(this)}))}on(e,t){return b.call(`${this.key}.on`,[this.hwnd,e]),b.on(`${this.hwnd}.${e}`,t)}off(e){b.call(`${this.key}.off`,[this.hwnd,e])}}class S extends N{constructor(...e){return super(),this.key="view",new Promise((async t=>{const r=await b.call(`${this.key}.create`,e);this.hwnd=r,t(this)}))}}class P extends N{constructor(...e){return super(),this}on(e,t){return b.on(e,(e=>{t(...e)}))}off(e){return b.off(e)}emit(...e){return b.call("run",["\n thread.command.publish(...);\n ",...e])}}let C=class e extends N{constructor(t){var r;t.log=!0===t.log?e=>{const t=String(e.id);let[r="",...n]=Array.from(e.reqRaw);var o;if(r=r.trim(),e.startTime&&(console.group(t),console.log(r),o=n,JSON.parse(JSON.stringify(o),((e,t)=>(!1===l(t)&&Array.isArray(t)&&(t=t.filter((e=>!l(e)))),l(t)?void 0:t)))&&console.table(n)),e.endTime){const[r,...n]=Array.from(e.resRaw);r?console.error(r):console.log(...n),console.groupEnd(t)}}:t.log,t.lib,b=t.ws,super(),this.ws=t.ws,this.log={all:r=r||new Map,on:function(e,t){var n=r.get(e);n?n.push(t):r.set(e,[t])},off:function(e,t){var n=r.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):r.set(e,[]))},emit:function(e,t){var n=r.get(e);n&&n.slice().map((function(e){e(t)})),(n=r.get("*"))&&n.slice().map((function(r){r(e,t)}))}},t.log&&this.log.on("log",t.log);const n=b.call;return b.call=async(e,t=[],r={})=>{r={runType:"thread",...r};const o=(()=>{const e=(t[0]||"").trim(),r=f(),n=new String(r);return n.cbTag=e.startsWith("return thread.command.cb_arg_code_")?e.match(/^return thread.command.cb_arg_(.{41})/)[1]:"",n})(),i=new A(t,{id:o,...r});let s={id:"",action:"",startTime:"",endTime:"",reqRaw:[],resRaw:[],id:o,action:e,startTime:Date.now(),reqRaw:[i.codeClean,...i.codeArg]};return this.log.emit("log",s),new Promise((async t=>{let s={id:"",action:"",startTime:"",endTime:"",reqRaw:[],resRaw:[],id:o,action:e,endTime:Date.now(),reqRaw:[i.codeClean,...i.codeArg],resRaw:[]};const a=async e=>{e.res=JSON.parse(e.res);let{tid:n,type:i,err:a,res:u=[]}=e;if("cb-arg"===i){const{argPath:t,id:n}=e,o=t.split("_").reduce(((e,t)=>e[t]),r._argList),i=await o(...u);this.native.thread.command[n](i)}u=Array.from(u);const c=[a,...u];s.resRaw=c,["return","err"].includes(i)&&(this.log.emit("log",s),t(c),this.msg.off(o))};n.bind(b)(e,i.newArg).then((([e,...t])=>{e&&a({tid:0,type:"err",err:e,res:[]})})),this.msg.on(o,a)}))},new Promise((async(t,r)=>{if("object"==typeof e.instance)return e.instance;e.instance=this,b.on("open",(async()=>{this.Tray=k,this.View=S,this.Msg=P,this.msg=await new P,this.msg.on("native:log",console.debug),t(this)}))}))}};globalThis.ext=globalThis.ext||new Promise((async e=>{globalThis.ext=JSON.parse(await globalThis._ext||"{}"),delete globalThis._ext,e(globalThis.ext)}));const B={encoder:new globalThis.TextEncoder,decoder:new globalThis.TextDecoder};class L extends C{constructor(e={}){return e="string"==typeof e?{wsUrl:e}:e,new Promise((async(t,n)=>{try{globalThis.ext=await globalThis.ext,e.wsUrl=e.wsUrl||`${globalThis.ext.wsUrl}?token=${globalThis.ext.token}`;const n=new r.Client(e.wsUrl),o=await super({...e,ws:n,lib:B});o.hwnd=globalThis.ext.hwnd,t(o)}catch(e){n(e)}}))}}export{L as default};
6
6
  //# sourceMappingURL=main.esm.min.js.map