denotify-client 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -96,12 +96,19 @@ export class DeNotifyClient {
96
96
  return ret.hash;
97
97
  }
98
98
  async setAlertName(triggerId, name) {
99
+ throw new Error('Not yet supported - Sorry!');
99
100
  }
100
101
  async enableAlert(triggerId) {
102
+ throw new Error('Not yet supported - Sorry!');
101
103
  }
102
104
  async disableAlert(triggerId) {
105
+ throw new Error('Not yet supported - Sorry!');
106
+ }
107
+ async updateNotification(triggerId) {
108
+ throw new Error('Not yet supported - Sorry!');
103
109
  }
104
110
  async updateTrigger(triggerId, update) {
111
+ // TODO - Input validation
105
112
  const ret = await this.request('patch', `alerts/trigger-handler/${triggerId}`, { body: update });
106
113
  return ret;
107
114
  }
@@ -1,50 +1,47 @@
1
+ import { AlertBuilder } from "../alertbuilder.js";
1
2
  import { DeNotifyClient } from "../denotifyclient.js";
3
+ import { FunctionBuilder } from "../functionbuilder.js";
2
4
  import { FilterBuilder } from "../util/filter.js";
3
5
  // Simple App to demonstrate usage. Created a balance monitoring alert, updates it and deletes it
4
6
  async function main() {
5
7
  const api = await DeNotifyClient.create({
6
- email: 's.battenally@gmail.com',
7
- password: 'Password',
8
- projectId: 'xfxplbmdcoukaitzxzei',
9
- anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhmeHBsYm1kY291a2FpdHp4emVpIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzgwMDg4NzMsImV4cCI6MTk5MzU4NDg3M30.WLk7bR5syQ4YJ8_jNOAuaT1UMvl7E2MS_VYMs7sN56c'
8
+ email: process.env.EMAIL,
9
+ password: process.env.PASSWORD,
10
10
  });
11
- // const network = 'avalanche'
12
- // const address = '0x26985888d5b7019ff2A7444fB567D8F386c3b538'
13
- // const myAddress = '0x7601630eC802952ba1ED2B6e4db16F699A0a5A87'
14
- // const { abi } = await api.getAbi(network, address)
15
- // const webhook = 'https://discord.com/api/webhooks/1063967722276388874/VrdsvfyCTEtnRIk5Vzhj1Y0Fi7pFueN5dH9Bz7OeXyNpwJUI7ucIzdIQwpOq8amVgCbW'
16
- // const builder = FunctionBuilder.create(api)
17
- // await builder.addFunction(address, 'getBalance', [myAddress], abi)
18
- // // Create the Balance Monitor alert
19
- // const alert = AlertBuilder.create('Test Alert')
20
- // .onNetwork('avalanche')
21
- // .withTrigger<PollFunctionV2>('PollFunctionV2', {
22
- // timeBase: 'time',
23
- // timePeriod: '100s',
24
- // functions: builder.get(),
25
- // triggerOn: 'always',
26
- // })
27
- // .withNotification<DiscordWebhook>('Discord', {
28
- // url: webhook,
29
- // message:
30
- // `
31
- // Your avax balance is [{func_0_ret_0 / 1e18}](https://snowtrace.io/address/${myAddress})
32
- // `,
33
- // })
34
- // .config()
35
- // // Create the alert with the API
36
- // const triggerId = await api.createAlert(alert)
37
- // console.log(triggerId)
38
- // // Update the period to every 10s
39
- // await api.updateTrigger(triggerId, { timePeriod: '10s' })
11
+ const network = 'avalanche';
12
+ const address = '0x26985888d5b7019ff2A7444fB567D8F386c3b538';
13
+ const myAddress = '0x7601630eC802952ba1ED2B6e4db16F699A0a5A87';
14
+ const { abi } = await api.getAbi(network, address);
15
+ const webhook = process.env.DISCORD_WEBHOOK;
16
+ const builder = FunctionBuilder.create(api);
17
+ await builder.addFunction(address, 'getBalance', [myAddress], abi);
18
+ // Create the Balance Monitor alert
19
+ const alert = AlertBuilder.create('Test Alert')
20
+ .onNetwork('avalanche')
21
+ .withTrigger('PollFunctionV2', {
22
+ timeBase: 'time',
23
+ timePeriod: '100s',
24
+ functions: builder.get(),
25
+ triggerOn: 'always',
26
+ })
27
+ .withNotification('Discord', {
28
+ url: webhook,
29
+ message: `Your avax balance is [{func_0_ret_0 / 1e18}](https://snowtrace.io/address/${myAddress})`,
30
+ })
31
+ .config();
32
+ // Create the alert with the API
33
+ const triggerId = await api.createAlert(alert);
34
+ console.log(triggerId);
35
+ // Update the period to every 10s
36
+ await api.updateTrigger(triggerId, { timePeriod: '10s' });
40
37
  // Update the Filter using the filter builder
41
38
  const filter = FilterBuilder.new()
42
39
  .addCondition('WHERE', 'func_0_ret_0', 'Number', 'gt', 3)
43
40
  .finalise();
44
41
  await api.updateTrigger(13, { triggerOn: 'filter', filter, filterVersion: FilterBuilder.version() });
45
42
  // Delete the filter in 10s
46
- // setTimeout(async () => {
47
- // await api.deleteAlert(triggerId)
48
- // }, 10 * 1000)
43
+ setTimeout(async () => {
44
+ await api.deleteAlert(triggerId);
45
+ }, 10 * 1000);
49
46
  }
50
47
  main();
@@ -2,10 +2,8 @@ import { DeNotifyClient } from "../denotifyclient.js";
2
2
  // Simple App to demonstrate deleting an alert
3
3
  async function main() {
4
4
  const api = await DeNotifyClient.create({
5
- email: 's.battenally@gmail.com',
6
- password: 'Password',
7
- projectId: 'xfxplbmdcoukaitzxzei',
8
- anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhmeHBsYm1kY291a2FpdHp4emVpIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzgwMDg4NzMsImV4cCI6MTk5MzU4NDg3M30.WLk7bR5syQ4YJ8_jNOAuaT1UMvl7E2MS_VYMs7sN56c'
5
+ email: process.env.EMAIL,
6
+ password: process.env.PASSWORD,
9
7
  });
10
8
  const alertId = 11;
11
9
  await api.deleteAlert(alertId);
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ var followRedirects = require('follow-redirects');
11
11
  var zlib = require('zlib');
12
12
  var stream = require('stream');
13
13
  var EventEmitter = require('events');
14
+ var ethers = require('ethers');
14
15
 
15
16
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
17
 
@@ -4084,6 +4085,32 @@ class Notification {
4084
4085
  }
4085
4086
  }
4086
4087
 
4088
+ const HANDLER_FUNCTION_CALL_V1_RAW_ID = 'handler_function_call';
4089
+ class HandlerFunctionCall {
4090
+ static SimpleToRaw(name, network, config) {
4091
+ return {
4092
+ alertType: 'event',
4093
+ network,
4094
+ nickname: name,
4095
+ type: HANDLER_FUNCTION_CALL_V1_RAW_ID,
4096
+ handler: config
4097
+ };
4098
+ }
4099
+ }
4100
+
4101
+ const HANDLER_ONCHAIN_EVENT_V1_RAW_ID = 'handler_onchain_event';
4102
+ class HandlerOnchainEvent {
4103
+ static SimpleToRaw(name, network, config) {
4104
+ return {
4105
+ alertType: 'event',
4106
+ network,
4107
+ nickname: name,
4108
+ type: HANDLER_ONCHAIN_EVENT_V1_RAW_ID,
4109
+ handler: config
4110
+ };
4111
+ }
4112
+ }
4113
+
4087
4114
  const HANDLER_FUNCTION_CALL_V2_RAW_ID = 'handler_function_call_v2';
4088
4115
  class HandlerFunctionCallV2 {
4089
4116
  static SimpleToRaw(name, network, config) {
@@ -4101,6 +4128,8 @@ class Trigger {
4101
4128
  static SimpleToRaw(name, id, network, config) {
4102
4129
  switch (id) {
4103
4130
  case 'PollFunctionV2': return HandlerFunctionCallV2.SimpleToRaw(name, network, config);
4131
+ case 'PollFunctionV1': return HandlerFunctionCall.SimpleToRaw(name, network, config);
4132
+ case 'OnchainEventV2': return HandlerOnchainEvent.SimpleToRaw(name, network, config);
4104
4133
  default:
4105
4134
  throw new Error('Invalid Trigger ID');
4106
4135
  }
@@ -4201,15 +4230,249 @@ class DeNotifyClient {
4201
4230
  return ret.hash;
4202
4231
  }
4203
4232
  async setAlertName(triggerId, name) {
4233
+ throw new Error('Not yet supported - Sorry!');
4204
4234
  }
4205
4235
  async enableAlert(triggerId) {
4236
+ throw new Error('Not yet supported - Sorry!');
4206
4237
  }
4207
4238
  async disableAlert(triggerId) {
4239
+ throw new Error('Not yet supported - Sorry!');
4240
+ }
4241
+ async updateNotification(triggerId) {
4242
+ throw new Error('Not yet supported - Sorry!');
4208
4243
  }
4209
4244
  async updateTrigger(triggerId, update) {
4245
+ // TODO - Input validation
4210
4246
  const ret = await this.request('patch', `alerts/trigger-handler/${triggerId}`, { body: update });
4211
4247
  return ret;
4212
4248
  }
4213
4249
  }
4214
4250
 
4251
+ class AlertBuilder {
4252
+ name;
4253
+ network;
4254
+ triggerId;
4255
+ trigger;
4256
+ notificationId;
4257
+ notification;
4258
+ constructor(name) {
4259
+ this.name = name;
4260
+ }
4261
+ static create(name) {
4262
+ return new AlertBuilder(name);
4263
+ }
4264
+ onNetwork(network) {
4265
+ this.network = network;
4266
+ return this;
4267
+ }
4268
+ withTrigger(id, options) {
4269
+ this.triggerId = id;
4270
+ this.trigger = options;
4271
+ return this;
4272
+ }
4273
+ withNotification(id, options) {
4274
+ this.notificationId = id;
4275
+ this.notification = options;
4276
+ return this;
4277
+ }
4278
+ config() {
4279
+ if (this.trigger === undefined || this.triggerId === undefined)
4280
+ throw new Error('Trigger not configured');
4281
+ if (this.notification === undefined || this.notificationId === undefined)
4282
+ throw new Error('Notification not configured');
4283
+ if (this.network === undefined)
4284
+ throw new Error('Network not configured');
4285
+ return {
4286
+ name: this.name,
4287
+ network: this.network,
4288
+ triggerId: this.triggerId,
4289
+ trigger: this.trigger,
4290
+ notificationId: this.notificationId,
4291
+ notification: this.notification,
4292
+ };
4293
+ }
4294
+ }
4295
+
4296
+ class FunctionBuilder {
4297
+ api;
4298
+ data = [];
4299
+ constructor(api) {
4300
+ this.api = api;
4301
+ }
4302
+ static create(api) {
4303
+ return new FunctionBuilder(api);
4304
+ }
4305
+ getAbiHash(abi) {
4306
+ if (this.api === undefined)
4307
+ throw new Error('FunctionBuilder must be initialised with api');
4308
+ return this.api.getAbiHash(abi);
4309
+ }
4310
+ async addFunction(address, func, args, abi) {
4311
+ const contract = new ethers.ethers.Contract(address, abi);
4312
+ contract.interface.encodeFunctionData(func, args);
4313
+ this.data.push({
4314
+ address,
4315
+ bytecode: contract.interface.encodeFunctionData(func, args),
4316
+ abiHash: await this.getAbiHash(abi),
4317
+ function: func,
4318
+ });
4319
+ return this;
4320
+ }
4321
+ get() {
4322
+ return this.data;
4323
+ }
4324
+ }
4325
+
4326
+ class Filter {
4327
+ static version() {
4328
+ return 'v1';
4329
+ }
4330
+ static execute(record, groupsIn, version = 'v1') {
4331
+ // Deep copy to so we can edit the object during recursion
4332
+ const groups = JSON.parse(JSON.stringify(groupsIn));
4333
+ let lhs = true;
4334
+ for (const group of groups) {
4335
+ const rhs = Filter.process(record, group.conditions);
4336
+ lhs = Filter.execLogic(lhs, group.logic, rhs);
4337
+ }
4338
+ return lhs;
4339
+ }
4340
+ static process(record, conditions, lhs) {
4341
+ const condition = conditions.shift();
4342
+ if (!condition) {
4343
+ if (lhs === undefined)
4344
+ return true;
4345
+ return lhs;
4346
+ }
4347
+ // lhs <logic> rhs
4348
+ const rhs = Filter.execCondition(record, condition);
4349
+ if (lhs === undefined || condition.logic === 'WHERE')
4350
+ return Filter.process(record, conditions, rhs);
4351
+ if (condition.logic === undefined)
4352
+ throw new Error('Invalid filter. Condition must have logic value');
4353
+ const next = Filter.execLogic(lhs, condition.logic, rhs);
4354
+ return Filter.process(record, conditions, next);
4355
+ }
4356
+ static execLogic(lhs, logic, rhs) {
4357
+ switch (logic) {
4358
+ case 'AND': return lhs && rhs;
4359
+ case 'OR': return lhs || rhs;
4360
+ case 'XOR': return (lhs || rhs) && !(lhs && rhs);
4361
+ case 'NAND': return !(lhs && rhs);
4362
+ case 'NOR': return !(lhs && rhs);
4363
+ case 'WHERE': return rhs;
4364
+ default: throw new Error(`Invalid Filter. Bad logic value: ${logic}`);
4365
+ }
4366
+ }
4367
+ static execCondition(record, condition) {
4368
+ const data = record[condition.key];
4369
+ if (condition.type === 'Number') {
4370
+ if (typeof condition.constant !== 'number' || typeof data !== 'number')
4371
+ throw new Error(`Invalid filter. Type miss-match. Type: ${condition.type}, Variable: ${condition.constant}, Data: ${data}`);
4372
+ const n = data;
4373
+ const constant = condition.constant;
4374
+ switch (condition.operation) {
4375
+ case 'eq': return n === constant;
4376
+ case '!eq': return n !== constant;
4377
+ case 'gt': return n > constant;
4378
+ case 'gte': return n >= constant;
4379
+ case 'lt': return n < constant;
4380
+ case 'lte': return n <= constant;
4381
+ default: throw new Error('Invalid Filter. Operation does not match type');
4382
+ }
4383
+ }
4384
+ if (condition.type === 'String') {
4385
+ if (typeof condition.constant !== 'string' || typeof data !== 'string')
4386
+ throw new Error(`Invalid filter. Type miss-match. Type: ${condition.type}, Variable: ${condition.constant}, Data: ${data}`);
4387
+ const str = data;
4388
+ const constant = condition.constant;
4389
+ switch (condition.operation) {
4390
+ case 'contains': return str.includes(constant);
4391
+ case '!contains': return !str.includes(constant);
4392
+ case 'is': return str === constant;
4393
+ case '!is': return str !== constant;
4394
+ case 'isEmpty': return str === '';
4395
+ case '!isEmpty': return str !== '';
4396
+ default: throw new Error('Invalid Filter. Operation does not match type');
4397
+ }
4398
+ }
4399
+ if (condition.type === 'Address') {
4400
+ if (typeof condition.constant !== 'string' || typeof data !== 'string')
4401
+ throw new Error(`Invalid filter. Type miss-match. Type: ${condition.type}, Variable: ${condition.constant}, Data: ${data}`);
4402
+ const str = data;
4403
+ const constant = condition.constant;
4404
+ switch (condition.operation) {
4405
+ case 'contains': return str.toLowerCase().includes(constant.toLowerCase());
4406
+ case '!contains': return !str.toLowerCase().includes(constant.toLowerCase());
4407
+ case 'is': return str.toLowerCase() === constant.toLowerCase();
4408
+ case '!is': return str.toLowerCase() !== constant.toLowerCase();
4409
+ case 'isEmpty': return str === '';
4410
+ case '!isEmpty': return str !== '';
4411
+ default: throw new Error('Invalid Filter. Operation does not match type');
4412
+ }
4413
+ }
4414
+ throw new Error('Invalid Filter. Unknown Type');
4415
+ }
4416
+ }
4417
+ class FilterBuilder {
4418
+ groups = [];
4419
+ constructor() {
4420
+ this.newGroup('WHERE');
4421
+ }
4422
+ static version() {
4423
+ return Filter.version();
4424
+ }
4425
+ static new() {
4426
+ return new FilterBuilder();
4427
+ }
4428
+ newGroup(logic) {
4429
+ if (this.groups.length !== 0 && logic === 'WHERE')
4430
+ throw new Error('Only the first groups can start with "WHERE"');
4431
+ this.groups.push({ logic: 'WHERE', conditions: [] });
4432
+ return this;
4433
+ }
4434
+ addCondition(logic, key, type, operation, constant) {
4435
+ const group = this.groups[this.groups.length - 1];
4436
+ if (group.conditions.length === 0 && logic !== 'WHERE')
4437
+ throw new Error('Logic for the first condition of a group must be "WHERE"');
4438
+ if (group.conditions.length > 0 && logic === 'WHERE')
4439
+ throw new Error('Only the first condition of a group can be "WHERE"');
4440
+ group.conditions.push({
4441
+ logic,
4442
+ key,
4443
+ type,
4444
+ operation,
4445
+ constant
4446
+ });
4447
+ return this;
4448
+ }
4449
+ finalise() {
4450
+ for (const group of this.groups) {
4451
+ if (group.conditions.length === 0)
4452
+ throw new Error('Bad Filter. All Groups must have atleast one condition');
4453
+ }
4454
+ return this.groups;
4455
+ }
4456
+ }
4457
+
4458
+ var index$1 = /*#__PURE__*/Object.freeze({
4459
+ __proto__: null,
4460
+ Trigger: Trigger,
4461
+ HandlerFunctionCallV2: HandlerFunctionCallV2,
4462
+ HandlerFunctionCall: HandlerFunctionCall,
4463
+ HandlerOnchainEvent: HandlerOnchainEvent
4464
+ });
4465
+
4466
+ var index = /*#__PURE__*/Object.freeze({
4467
+ __proto__: null,
4468
+ NOTIFY_DISCORD_WEBHOOK_RAW_ID: NOTIFY_DISCORD_WEBHOOK_RAW_ID,
4469
+ NotifyDiscordWebhook: NotifyDiscordWebhook,
4470
+ Notification: Notification
4471
+ });
4472
+
4473
+ exports.AlertBuilder = AlertBuilder;
4215
4474
  exports.DeNotifyClient = DeNotifyClient;
4475
+ exports.FilterBuilder = FilterBuilder;
4476
+ exports.FunctionBuilder = FunctionBuilder;
4477
+ exports.Notification = index;
4478
+ exports.Trigger = index$1;
package/dist/index.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@supabase/supabase-js"),require("form-data"),require("url"),require("proxy-from-env"),require("http"),require("https"),require("util"),require("follow-redirects"),require("zlib"),require("stream"),require("events")):"function"==typeof define&&define.amd?define(["exports","@supabase/supabase-js","form-data","url","proxy-from-env","http","https","util","follow-redirects","zlib","stream","events"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["denotify-client"]={},e.supabaseJs,e.FormData$1,e.url,e.proxyFromEnv,e.http,e.https,e.util,e.followRedirects,e.zlib,e.stream,e.EventEmitter)}(this,(function(e,t,n,r,o,s,i,a,c,u,l,f){"use strict";function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=d(n),p=d(r),m=d(s),y=d(i),g=d(a),b=d(c),w=d(u),R=d(l),E=d(f);function O(e,t){return function(){return e.apply(t,arguments)}}const{toString:S}=Object.prototype,{getPrototypeOf:T}=Object,A=(x=Object.create(null),e=>{const t=S.call(e);return x[t]||(x[t]=t.slice(8,-1).toLowerCase())});var x;const C=e=>(e=e.toLowerCase(),t=>A(t)===e),_=e=>t=>typeof t===e,{isArray:L}=Array,v=_("undefined");const N=C("ArrayBuffer");const P=_("string"),B=_("function"),j=_("number"),k=e=>null!==e&&"object"==typeof e,U=e=>{if("object"!==A(e))return!1;const t=T(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},D=C("Date"),F=C("File"),I=C("Blob"),z=C("FileList"),q=C("URLSearchParams");function M(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),L(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(r=0;r<s;r++)i=o[r],t.call(null,e[i],i,e)}}function H(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const J="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,$=e=>!v(e)&&e!==J;const V=(W="undefined"!=typeof Uint8Array&&T(Uint8Array),e=>W&&e instanceof W);var W;const K=C("HTMLFormElement"),G=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Z=C("RegExp"),Q=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};M(n,((n,o)=>{!1!==t(n,o,e)&&(r[o]=n)})),Object.defineProperties(e,r)},X="abcdefghijklmnopqrstuvwxyz",Y="0123456789",ee={DIGIT:Y,ALPHA:X,ALPHA_DIGIT:X+X.toUpperCase()+Y};var te={isArray:L,isArrayBuffer:N,isBuffer:function(e){return null!==e&&!v(e)&&null!==e.constructor&&!v(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{const t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||S.call(e)===t||B(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&N(e.buffer),t},isString:P,isNumber:j,isBoolean:e=>!0===e||!1===e,isObject:k,isPlainObject:U,isUndefined:v,isDate:D,isFile:F,isBlob:I,isRegExp:Z,isFunction:B,isStream:e=>k(e)&&B(e.pipe),isURLSearchParams:q,isTypedArray:V,isFileList:z,forEach:M,merge:function e(){const{caseless:t}=$(this)&&this||{},n={},r=(r,o)=>{const s=t&&H(n,o)||o;U(n[s])&&U(r)?n[s]=e(n[s],r):U(r)?n[s]=e({},r):L(r)?n[s]=r.slice():n[s]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&M(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:r}={})=>(M(t,((t,r)=>{n&&B(t)?e[r]=O(t,n):e[r]=t}),{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],r&&!r(i,e,t)||a[i]||(t[i]=e[i],a[i]=!0);e=!1!==n&&T(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:A,kindOfTest:C,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(L(e))return e;let t=e.length;if(!j(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:K,hasOwnProperty:G,hasOwnProp:G,reduceDescriptors:Q,freezeMethods:e=>{Q(e,((t,n)=>{if(B(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];B(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return L(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:H,global:J,isContextDefined:$,ALPHABET:ee,generateString:(e=16,t=ee.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&B(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(k(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const o=L(e)?[]:{};return M(e,((e,t)=>{const s=n(e,r+1);!v(s)&&(o[t]=s)})),t[r]=void 0,o}}return e};return n(e,0)}};function ne(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}te.inherits(ne,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:te.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const re=ne.prototype,oe={};function se(e){return te.isPlainObject(e)||te.isArray(e)}function ie(e){return te.endsWith(e,"[]")?e.slice(0,-2):e}function ae(e,t,n){return e?e.concat(t).map((function(e,t){return e=ie(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{oe[e]={value:e}})),Object.defineProperties(ne,oe),Object.defineProperty(re,"isAxiosError",{value:!0}),ne.from=(e,t,n,r,o,s)=>{const i=Object.create(re);return te.toFlatObject(e,i,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),ne.call(i,e.message,t,n,r,o),i.cause=e,i.name=e.name,s&&Object.assign(i,s),i};const ce=te.toFlatObject(te,{},null,(function(e){return/^is[A-Z]/.test(e)}));function ue(e,t,n){if(!te.isObject(e))throw new TypeError("target must be an object");t=t||new(h.default||FormData);const r=(n=te.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!te.isUndefined(t[e])}))).metaTokens,o=n.visitor||u,s=n.dots,i=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&te.isSpecCompliantForm(t);if(!te.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(te.isDate(e))return e.toISOString();if(!a&&te.isBlob(e))throw new ne("Blob is not supported. Use a Buffer instead.");return te.isArrayBuffer(e)||te.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(te.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(te.isArray(e)&&function(e){return te.isArray(e)&&!e.some(se)}(e)||(te.isFileList(e)||te.endsWith(n,"[]"))&&(a=te.toArray(e)))return n=ie(n),a.forEach((function(e,r){!te.isUndefined(e)&&null!==e&&t.append(!0===i?ae([n],r,s):null===i?n:n+"[]",c(e))})),!1;return!!se(e)||(t.append(ae(o,n,s),c(e)),!1)}const l=[],f=Object.assign(ce,{defaultVisitor:u,convertValue:c,isVisitable:se});if(!te.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!te.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),te.forEach(n,(function(n,s){!0===(!(te.isUndefined(n)||null===n)&&o.call(t,n,te.isString(s)?s.trim():s,r,f))&&e(n,r?r.concat(s):[s])})),l.pop()}}(e),t}function le(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function fe(e,t){this._pairs=[],e&&ue(e,this,t)}const de=fe.prototype;function he(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function pe(e,t,n){if(!t)return e;const r=n&&n.encode||he,o=n&&n.serialize;let s;if(s=o?o(t,n):te.isURLSearchParams(t)?t.toString():new fe(t,n).toString(r),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}de.append=function(e,t){this._pairs.push([e,t])},de.toString=function(e){const t=e?function(t){return e.call(this,t,le)}:le;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var me=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){te.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},ye={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ge={isNode:!0,classes:{URLSearchParams:p.default.URLSearchParams,FormData:h.default,Blob:"undefined"!=typeof Blob&&Blob||null},protocols:["http","https","file","data"]};function be(e){function t(e,n,r,o){let s=e[o++];const i=Number.isFinite(+s),a=o>=e.length;if(s=!s&&te.isArray(r)?r.length:s,a)return te.hasOwnProp(r,s)?r[s]=[r[s],n]:r[s]=n,!i;r[s]&&te.isObject(r[s])||(r[s]=[]);return t(e,n,r[s],o)&&te.isArray(r[s])&&(r[s]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}(r[s])),!i}if(te.isFormData(e)&&te.isFunction(e.entries)){const n={};return te.forEachEntry(e,((e,r)=>{t(function(e){return te.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null}const we={"Content-Type":void 0};const Re={transitional:ye,adapter:["xhr","http"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=te.isObject(e);o&&te.isHTMLForm(e)&&(e=new FormData(e));if(te.isFormData(e))return r&&r?JSON.stringify(be(e)):e;if(te.isArrayBuffer(e)||te.isBuffer(e)||te.isStream(e)||te.isFile(e)||te.isBlob(e))return e;if(te.isArrayBufferView(e))return e.buffer;if(te.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return ue(e,new ge.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return te.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((s=te.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return ue(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(te.isString(e))try{return(t||JSON.parse)(e),te.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Re.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(e&&te.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw ne.from(e,ne.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ge.classes.FormData,Blob:ge.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};te.forEach(["delete","get","head"],(function(e){Re.headers[e]={}})),te.forEach(["post","put","patch"],(function(e){Re.headers[e]=te.merge(we)}));var Ee=Re;const Oe=te.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const Se=Symbol("internals");function Te(e){return e&&String(e).trim().toLowerCase()}function Ae(e){return!1===e||null==e?e:te.isArray(e)?e.map(Ae):String(e)}function xe(e,t,n,r,o){return te.isFunction(r)?r.call(this,t,n):(o&&(t=n),te.isString(t)?te.isString(r)?-1!==t.indexOf(r):te.isRegExp(r)?r.test(t):void 0:void 0)}class Ce{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Te(t);if(!o)throw new Error("header name must be a non-empty string");const s=te.findKey(r,o);(!s||void 0===r[s]||!0===n||void 0===n&&!1!==r[s])&&(r[s||t]=Ae(e))}const s=(e,t)=>te.forEach(e,((e,n)=>o(e,n,t)));return te.isPlainObject(e)||e instanceof this.constructor?s(e,t):te.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z]+$/.test(e.trim())?s((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Oe[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t):null!=e&&o(t,e,n),this}get(e,t){if(e=Te(e)){const n=te.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(te.isFunction(t))return t.call(this,e,n);if(te.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Te(e)){const n=te.findKey(this,e);return!(!n||void 0===this[n]||t&&!xe(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Te(e)){const o=te.findKey(n,e);!o||t&&!xe(0,n[o],o,t)||(delete n[o],r=!0)}}return te.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!xe(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return te.forEach(this,((r,o)=>{const s=te.findKey(n,o);if(s)return t[s]=Ae(r),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(o):String(o).trim();i!==o&&delete t[o],t[i]=Ae(r),n[i]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return te.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&te.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[Se]=this[Se]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Te(e);t[r]||(!function(e,t){const n=te.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})}))}(n,e),t[r]=!0)}return te.isArray(e)?e.forEach(r):r(e),this}}Ce.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),te.freezeMethods(Ce.prototype),te.freezeMethods(Ce);var _e=Ce;function Le(e,t){const n=this||Ee,r=t||n,o=_e.from(r.headers);let s=r.data;return te.forEach(e,(function(e){s=e.call(n,s,o.normalize(),t?t.status:void 0)})),o.normalize(),s}function ve(e){return!(!e||!e.__CANCEL__)}function Ne(e,t,n){ne.call(this,null==e?"canceled":e,ne.ERR_CANCELED,t,n),this.name="CanceledError"}function Pe(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new ne("Request failed with status code "+n.status,[ne.ERR_BAD_REQUEST,ne.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}function Be(e,t){return e&&!function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}te.inherits(Ne,ne,{__CANCEL__:!0});const je="1.3.4";function ke(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}const Ue=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function De(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,s=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=r[i];o||(o=c),n[s]=a,r[s]=c;let l=i,f=0;for(;l!==s;)f+=n[l++],l%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),c-o<t)return;const d=u&&c-u;return d?Math.round(1e3*f/d):void 0}}const Fe=Symbol("internals");class Ie extends R.default.Transform{constructor(e){super({readableHighWaterMark:(e=te.toFlatObject(e,{maxRate:0,chunkSize:65536,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,((e,t)=>!te.isUndefined(t[e])))).chunkSize});const t=this,n=this[Fe]={length:e.length,timeWindow:e.timeWindow,ticksRate:e.ticksRate,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null},r=De(n.ticksRate*e.samplesCount,n.timeWindow);this.on("newListener",(e=>{"progress"===e&&(n.isCaptured||(n.isCaptured=!0))}));let o=0;n.updateProgress=function(e,t){let n=0;const r=1e3/t;let o=null;return function(t,s){const i=Date.now();if(t||i-n>r)return o&&(clearTimeout(o),o=null),n=i,e.apply(null,s);o||(o=setTimeout((()=>(o=null,n=Date.now(),e.apply(null,s))),r-(i-n)))}}((function(){const e=n.length,s=n.bytesSeen,i=s-o;if(!i||t.destroyed)return;const a=r(i);o=s,process.nextTick((()=>{t.emit("progress",{loaded:s,total:e,progress:e?s/e:void 0,bytes:i,rate:a||void 0,estimated:a&&e&&s<=e?(e-s)/a:void 0})}))}),n.ticksRate);const s=()=>{n.updateProgress(!0)};this.once("end",s),this.once("error",s)}_read(e){const t=this[Fe];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,n){const r=this,o=this[Fe],s=o.maxRate,i=this.readableHighWaterMark,a=o.timeWindow,c=s/(1e3/a),u=!1!==o.minChunkSize?Math.max(o.minChunkSize,.01*c):0;const l=(e,t)=>{const n=Buffer.byteLength(e);let l,f=null,d=i,h=0;if(s){const e=Date.now();(!o.ts||(h=e-o.ts)>=a)&&(o.ts=e,l=c-o.bytes,o.bytes=l<0?-l:0,h=0),l=c-o.bytes}if(s){if(l<=0)return setTimeout((()=>{t(null,e)}),a-h);l<d&&(d=l)}d&&n>d&&n-d>u&&(f=e.subarray(d),e=e.subarray(0,d)),function(e,t){const n=Buffer.byteLength(e);o.bytesSeen+=n,o.bytes+=n,o.isCaptured&&o.updateProgress(),r.push(e)?process.nextTick(t):o.onReadCallback=()=>{o.onReadCallback=null,process.nextTick(t)}}(e,f?()=>{process.nextTick(t,null,f)}:t)};l(e,(function e(t,r){if(t)return n(t);r?l(r,e):n(null)}))}setLength(e){return this[Fe].length=+e,this}}var ze=Ie;const{asyncIterator:qe}=Symbol;var Me=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[qe]?yield*e[qe]():yield e};const He=te.ALPHABET.ALPHA_DIGIT+"-_",Je=new a.TextEncoder,$e="\r\n",Ve=Je.encode($e);class We{constructor(e,t){const{escapeName:n}=this.constructor,r=te.isString(t);let o=`Content-Disposition: form-data; name="${n(e)}"${!r&&t.name?`; filename="${n(t.name)}"`:""}${$e}`;r?t=Je.encode(String(t).replace(/\r?\n|\r\n?/g,$e)):o+=`Content-Type: ${t.type||"application/octet-stream"}${$e}`,this.headers=Je.encode(o+$e),this.contentLength=r?t.byteLength:t.size,this.size=this.headers.byteLength+this.contentLength+2,this.name=e,this.value=t}async*encode(){yield this.headers;const{value:e}=this;te.isTypedArray(e)?yield e:yield*Me(e),yield Ve}static escapeName(e){return String(e).replace(/[\r\n"]/g,(e=>({"\r":"%0D","\n":"%0A",'"':"%22"}[e])))}}var Ke=(e,t,n)=>{const{tag:r="form-data-boundary",size:o=25,boundary:s=r+"-"+te.generateString(o,He)}=n||{};if(!te.isFormData(e))throw TypeError("FormData instance required");if(s.length<1||s.length>70)throw Error("boundary must be 10-70 characters long");const i=Je.encode("--"+s+$e),a=Je.encode("--"+s+"--"+$e+$e);let c=a.byteLength;const u=Array.from(e.entries()).map((([e,t])=>{const n=new We(e,t);return c+=n.size,n}));c+=i.byteLength*u.length,c=te.toFiniteNumber(c);const f={"Content-Type":`multipart/form-data; boundary=${s}`};return Number.isFinite(c)&&(f["Content-Length"]=c),t&&t(f),l.Readable.from(async function*(){for(const e of u)yield i,yield*e.encode();yield a}())};class Ge extends R.default.Transform{__transform(e,t,n){this.push(e),n()}_transform(e,t,n){if(0!==e.length&&(this._transform=this.__transform,120!==e[0])){const e=Buffer.alloc(2);e[0]=120,e[1]=156,this.push(e,t)}this.__transform(e,t,n)}}var Ze=Ge;const Qe={flush:w.default.constants.Z_SYNC_FLUSH,finishFlush:w.default.constants.Z_SYNC_FLUSH},Xe={flush:w.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:w.default.constants.BROTLI_OPERATION_FLUSH},Ye=te.isFunction(w.default.createBrotliDecompress),{http:et,https:tt}=b.default,nt=/https:?/,rt=ge.protocols.map((e=>e+":"));function ot(e){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e)}function st(e,t,n){let r=t;if(!r&&!1!==r){const e=o.getProxyForUrl(n);e&&(r=new URL(e))}if(r){if(r.username&&(r.auth=(r.username||"")+":"+(r.password||"")),r.auth){(r.auth.username||r.auth.password)&&(r.auth=(r.auth.username||"")+":"+(r.auth.password||""));const t=Buffer.from(r.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+t}e.headers.host=e.hostname+(e.port?":"+e.port:"");const t=r.hostname||r.host;e.hostname=t,e.host=t,e.port=r.port,e.path=n,r.protocol&&(e.protocol=r.protocol.includes(":")?r.protocol:`${r.protocol}:`)}e.beforeRedirects.proxy=function(e){st(e,t,e.href)}}const it="undefined"!=typeof process&&"process"===te.kindOf(process);function at(e,t){let n=0;const r=De(50,250);return o=>{const s=o.loaded,i=o.lengthComputable?o.total:void 0,a=s-n,c=r(a);n=s;const u={loaded:s,total:i,progress:i?s/i:void 0,bytes:a,rate:c||void 0,estimated:c&&i&&s<=i?(i-s)/c:void 0,event:o};u[t?"download":"upload"]=!0,e(u)}}const ct={http:it&&function(e){return t=async function(t,n,r){let{data:o}=e;const{responseType:s,responseEncoding:i}=e,a=e.method.toUpperCase();let c,u,l=!1;const f=new E.default,d=()=>{e.cancelToken&&e.cancelToken.unsubscribe(h),e.signal&&e.signal.removeEventListener("abort",h),f.removeAllListeners()};function h(t){f.emit("abort",!t||t.type?new Ne(null,e,u):t)}r(((e,t)=>{c=!0,t&&(l=!0,d())})),f.once("abort",n),(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(h),e.signal&&(e.signal.aborted?h():e.signal.addEventListener("abort",h)));const p=Be(e.baseURL,e.url),b=new URL(p,"http://localhost"),O=b.protocol||rt[0];if("data:"===O){let r;if("GET"!==a)return Pe(t,n,{status:405,statusText:"method not allowed",headers:{},config:e});try{r=function(e,t,n){const r=n&&n.Blob||ge.classes.Blob,o=ke(e);if(void 0===t&&r&&(t=!0),"data"===o){e=o.length?e.slice(o.length+1):e;const n=Ue.exec(e);if(!n)throw new ne("Invalid URL",ne.ERR_INVALID_URL);const s=n[1],i=n[2],a=n[3],c=Buffer.from(decodeURIComponent(a),i?"base64":"utf8");if(t){if(!r)throw new ne("Blob is not supported",ne.ERR_NOT_SUPPORT);return new r([c],{type:s})}return c}throw new ne("Unsupported protocol "+o,ne.ERR_NOT_SUPPORT)}(e.url,"blob"===s,{Blob:e.env&&e.env.Blob})}catch(t){throw ne.from(t,ne.ERR_BAD_REQUEST,e)}return"text"===s?(r=r.toString(i),i&&"utf8"!==i||(r=te.stripBOM(r))):"stream"===s&&(r=R.default.Readable.from(r)),Pe(t,n,{data:r,status:200,statusText:"OK",headers:new _e,config:e})}if(-1===rt.indexOf(O))return n(new ne("Unsupported protocol "+O,ne.ERR_BAD_REQUEST,e));const S=_e.from(e.headers).normalize();S.set("User-Agent","axios/"+je,!1);const T=e.onDownloadProgress,A=e.onUploadProgress,x=e.maxRate;let C,_;if(te.isSpecCompliantForm(o)){const e=S.getContentType(/boundary=([-_\w\d]{10,70})/i);o=Ke(o,(e=>{S.set(e)}),{tag:`axios-${je}-boundary`,boundary:e&&e[1]||void 0})}else if(te.isFormData(o)&&te.isFunction(o.getHeaders)){if(S.set(o.getHeaders()),!S.hasContentLength())try{const e=await g.default.promisify(o.getLength).call(o);Number.isFinite(e)&&e>=0&&S.setContentLength(e)}catch(e){}}else if(te.isBlob(o))o.size&&S.setContentType(o.type||"application/octet-stream"),S.setContentLength(o.size||0),o=R.default.Readable.from(Me(o));else if(o&&!te.isStream(o)){if(Buffer.isBuffer(o));else if(te.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else{if(!te.isString(o))return n(new ne("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",ne.ERR_BAD_REQUEST,e));o=Buffer.from(o,"utf-8")}if(S.setContentLength(o.length,!1),e.maxBodyLength>-1&&o.length>e.maxBodyLength)return n(new ne("Request body larger than maxBodyLength limit",ne.ERR_BAD_REQUEST,e))}const L=te.toFiniteNumber(S.getContentLength());let v,N;te.isArray(x)?(C=x[0],_=x[1]):C=_=x,o&&(A||C)&&(te.isStream(o)||(o=R.default.Readable.from(o,{objectMode:!1})),o=R.default.pipeline([o,new ze({length:L,maxRate:te.toFiniteNumber(C)})],te.noop),A&&o.on("progress",(e=>{A(Object.assign(e,{upload:!0}))}))),e.auth&&(v=(e.auth.username||"")+":"+(e.auth.password||"")),!v&&b.username&&(v=b.username+":"+b.password),v&&S.delete("authorization");try{N=pe(b.pathname+b.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(t){const r=new Error(t.message);return r.config=e,r.url=e.url,r.exists=!0,n(r)}S.set("Accept-Encoding","gzip, compress, deflate"+(Ye?", br":""),!1);const P={path:N,method:a,headers:S.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:v,protocol:O,beforeRedirect:ot,beforeRedirects:{}};let B;e.socketPath?P.socketPath=e.socketPath:(P.hostname=b.hostname,P.port=b.port,st(P,e.proxy,O+"//"+b.hostname+(b.port?":"+b.port:"")+P.path));const j=nt.test(P.protocol);if(P.agent=j?e.httpsAgent:e.httpAgent,e.transport?B=e.transport:0===e.maxRedirects?B=j?y.default:m.default:(e.maxRedirects&&(P.maxRedirects=e.maxRedirects),e.beforeRedirect&&(P.beforeRedirects.config=e.beforeRedirect),B=j?tt:et),e.maxBodyLength>-1?P.maxBodyLength=e.maxBodyLength:P.maxBodyLength=1/0,e.insecureHTTPParser&&(P.insecureHTTPParser=e.insecureHTTPParser),u=B.request(P,(function(r){if(u.destroyed)return;const o=[r],c=+r.headers["content-length"];if(T){const e=new ze({length:te.toFiniteNumber(c),maxRate:te.toFiniteNumber(_)});T&&e.on("progress",(e=>{T(Object.assign(e,{download:!0}))})),o.push(e)}let h=r;const p=r.req||u;if(!1!==e.decompress&&r.headers["content-encoding"])switch("HEAD"!==a&&204!==r.statusCode||delete r.headers["content-encoding"],r.headers["content-encoding"]){case"gzip":case"x-gzip":case"compress":case"x-compress":o.push(w.default.createUnzip(Qe)),delete r.headers["content-encoding"];break;case"deflate":o.push(new Ze),o.push(w.default.createUnzip(Qe)),delete r.headers["content-encoding"];break;case"br":Ye&&(o.push(w.default.createBrotliDecompress(Xe)),delete r.headers["content-encoding"])}h=o.length>1?R.default.pipeline(o,te.noop):o[0];const m=R.default.finished(h,(()=>{m(),d()})),y={status:r.statusCode,statusText:r.statusMessage,headers:new _e(r.headers),config:e,request:p};if("stream"===s)y.data=h,Pe(t,n,y);else{const r=[];let o=0;h.on("data",(function(t){r.push(t),o+=t.length,e.maxContentLength>-1&&o>e.maxContentLength&&(l=!0,h.destroy(),n(new ne("maxContentLength size of "+e.maxContentLength+" exceeded",ne.ERR_BAD_RESPONSE,e,p)))})),h.on("aborted",(function(){if(l)return;const t=new ne("maxContentLength size of "+e.maxContentLength+" exceeded",ne.ERR_BAD_RESPONSE,e,p);h.destroy(t),n(t)})),h.on("error",(function(t){u.destroyed||n(ne.from(t,null,e,p))})),h.on("end",(function(){try{let e=1===r.length?r[0]:Buffer.concat(r);"arraybuffer"!==s&&(e=e.toString(i),i&&"utf8"!==i||(e=te.stripBOM(e))),y.data=e}catch(t){n(ne.from(t,null,e,y.request,y))}Pe(t,n,y)}))}f.once("abort",(e=>{h.destroyed||(h.emit("error",e),h.destroy())}))})),f.once("abort",(e=>{n(e),u.destroy(e)})),u.on("error",(function(t){n(ne.from(t,null,e,u))})),u.on("socket",(function(e){e.setKeepAlive(!0,6e4)})),e.timeout){const t=parseInt(e.timeout,10);if(isNaN(t))return void n(new ne("error trying to parse `config.timeout` to int",ne.ERR_BAD_OPTION_VALUE,e,u));u.setTimeout(t,(function(){if(c)return;let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const r=e.transitional||ye;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new ne(t,r.clarifyTimeoutError?ne.ETIMEDOUT:ne.ECONNABORTED,e,u)),h()}))}if(te.isStream(o)){let t=!1,n=!1;o.on("end",(()=>{t=!0})),o.once("error",(e=>{n=!0,u.destroy(e)})),o.on("close",(()=>{t||n||h(new Ne("Request stream has been aborted",e,u))})),o.pipe(u)}else u.end(o)},new Promise(((e,n)=>{let r,o;const s=(e,t)=>{o||(o=!0,r&&r(e,t))},i=e=>{s(e,!0),n(e)};t((t=>{s(t),e(t)}),i,(e=>r=e)).catch(i)}));var t},xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){let r=e.data;const o=_e.from(e.headers).normalize(),s=e.responseType;let i;function a(){e.cancelToken&&e.cancelToken.unsubscribe(i),e.signal&&e.signal.removeEventListener("abort",i)}te.isFormData(r)&&ge.isStandardBrowserWebWorkerEnv&&o.setContentType(!1);let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",n=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(t+":"+n))}const u=Be(e.baseURL,e.url);function l(){if(!c)return;const r=_e.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());Pe((function(e){t(e),a()}),(function(e){n(e),a()}),{data:s&&"text"!==s&&"json"!==s?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:r,config:e,request:c}),c=null}c.open(e.method.toUpperCase(),pe(u,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=l:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(l)},c.onabort=function(){c&&(n(new ne("Request aborted",ne.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new ne("Network Error",ne.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const r=e.transitional||ye;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new ne(t,r.clarifyTimeoutError?ne.ETIMEDOUT:ne.ECONNABORTED,e,c)),c=null},void 0===r&&o.setContentType(null),"setRequestHeader"in c&&te.forEach(o.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),te.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),s&&"json"!==s&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",at(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",at(e.onUploadProgress)),(e.cancelToken||e.signal)&&(i=t=>{c&&(n(!t||t.type?new Ne(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(i),e.signal&&(e.signal.aborted?i():e.signal.addEventListener("abort",i)));const f=ke(u);f&&-1===ge.protocols.indexOf(f)?n(new ne("Unsupported protocol "+f+":",ne.ERR_BAD_REQUEST,e)):c.send(r||null)}))}};te.forEach(ct,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var ut={getAdapter:e=>{e=te.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let o=0;o<t&&(n=e[o],!(r=te.isString(n)?ct[n.toLowerCase()]:n));o++);if(!r){if(!1===r)throw new ne(`Adapter ${n} is not supported by the environment`,"ERR_NOT_SUPPORT");throw new Error(te.hasOwnProp(ct,n)?`Adapter '${n}' is not available in the build`:`Unknown adapter '${n}'`)}if(!te.isFunction(r))throw new TypeError("adapter is not a function");return r},adapters:ct};function lt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ne(null,e)}function ft(e){lt(e),e.headers=_e.from(e.headers),e.data=Le.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return ut.getAdapter(e.adapter||Ee.adapter)(e).then((function(t){return lt(e),t.data=Le.call(e,e.transformResponse,t),t.headers=_e.from(t.headers),t}),(function(t){return ve(t)||(lt(e),t&&t.response&&(t.response.data=Le.call(e,e.transformResponse,t.response),t.response.headers=_e.from(t.response.headers))),Promise.reject(t)}))}const dt=e=>e instanceof _e?e.toJSON():e;function ht(e,t){t=t||{};const n={};function r(e,t,n){return te.isPlainObject(e)&&te.isPlainObject(t)?te.merge.call({caseless:n},e,t):te.isPlainObject(t)?te.merge({},t):te.isArray(t)?t.slice():t}function o(e,t,n){return te.isUndefined(t)?te.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function s(e,t){if(!te.isUndefined(t))return r(void 0,t)}function i(e,t){return te.isUndefined(t)?te.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,s){return s in t?r(n,o):s in e?r(void 0,n):void 0}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(e,t)=>o(dt(e),dt(t),!0)};return te.forEach(Object.keys(e).concat(Object.keys(t)),(function(r){const s=c[r]||o,i=s(e[r],t[r],r);te.isUndefined(i)&&s!==a||(n[r]=i)})),n}const pt={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{pt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const mt={};pt.transitional=function(e,t,n){function r(e,t){return"[Axios v"+je+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,s)=>{if(!1===e)throw new ne(r(o," has been removed"+(t?" in "+t:"")),ne.ERR_DEPRECATED);return t&&!mt[o]&&(mt[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,s)}};var yt={assertOptions:function(e,t,n){if("object"!=typeof e)throw new ne("options must be an object",ne.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const t=e[s],n=void 0===t||i(t,s,e);if(!0!==n)throw new ne("option "+s+" must be "+n,ne.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new ne("Unknown option "+s,ne.ERR_BAD_OPTION)}},validators:pt};const gt=yt.validators;class bt{constructor(e){this.defaults=e,this.interceptors={request:new me,response:new me}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=ht(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;let s;void 0!==n&&yt.assertOptions(n,{silentJSONParsing:gt.transitional(gt.boolean),forcedJSONParsing:gt.transitional(gt.boolean),clarifyTimeoutError:gt.transitional(gt.boolean)},!1),void 0!==r&&yt.assertOptions(r,{encode:gt.function,serialize:gt.function},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase(),s=o&&te.merge(o.common,o[t.method]),s&&te.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete o[e]})),t.headers=_e.concat(s,o);const i=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,i.unshift(e.fulfilled,e.rejected))}));const c=[];let u;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let l,f=0;if(!a){const e=[ft.bind(this),void 0];for(e.unshift.apply(e,i),e.push.apply(e,c),l=e.length,u=Promise.resolve(t);f<l;)u=u.then(e[f++],e[f++]);return u}l=i.length;let d=t;for(f=0;f<l;){const e=i[f++],t=i[f++];try{d=e(d)}catch(e){t.call(this,e);break}}try{u=ft.call(this,d)}catch(e){return Promise.reject(e)}for(f=0,l=c.length;f<l;)u=u.then(c[f++],c[f++]);return u}getUri(e){return pe(Be((e=ht(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}te.forEach(["delete","get","head","options"],(function(e){bt.prototype[e]=function(t,n){return this.request(ht(n||{},{method:e,url:t,data:(n||{}).data}))}})),te.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(ht(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}bt.prototype[e]=t(),bt.prototype[e+"Form"]=t(!0)}));var wt=bt;class Rt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,o){n.reason||(n.reason=new Ne(e,r,o),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new Rt((function(t){e=t})),cancel:e}}}var Et=Rt;const Ot={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ot).forEach((([e,t])=>{Ot[t]=e}));var St=Ot;const Tt=function e(t){const n=new wt(t),r=O(wt.prototype.request,n);return te.extend(r,wt.prototype,n,{allOwnKeys:!0}),te.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(ht(t,n))},r}(Ee);Tt.Axios=wt,Tt.CanceledError=Ne,Tt.CancelToken=Et,Tt.isCancel=ve,Tt.VERSION=je,Tt.toFormData=ue,Tt.AxiosError=ne,Tt.Cancel=Tt.CanceledError,Tt.all=function(e){return Promise.all(e)},Tt.spread=function(e){return function(t){return e.apply(null,t)}},Tt.isAxiosError=function(e){return te.isObject(e)&&!0===e.isAxiosError},Tt.mergeConfig=ht,Tt.AxiosHeaders=_e,Tt.formToJSON=e=>be(te.isHTMLForm(e)?new FormData(e):e),Tt.HttpStatusCode=St,Tt.default=Tt;var At=Tt;class xt{static SimpleToRaw(e){return{name:"",notify_type:"notify_discord_webhook",notify:e}}}class Ct{static SimpleToRaw(e,t){if("Discord"===e)return xt.SimpleToRaw(t)}}class _t{static SimpleToRaw(e,t,n){return{alertType:"event",network:t,nickname:e,type:"handler_function_call_v2",handler:n}}}class Lt{static SimpleToRaw(e,t,n,r){if("PollFunctionV2"===t)return _t.SimpleToRaw(e,n,r);throw new Error("Invalid Trigger ID")}}const vt=e=>`https://${e}.functions.supabase.co/`,Nt=e=>`https://${e}.supabase.co/`,Pt="fdgtrxmmrtlokhgkvcjz";class Bt{url;token;headers={};constructor(e,t){this.url=e,this.token=t,this.headers={Authorization:`Bearer ${t}`,"Content-Type":"application/json"}}static async create(e){if(e.key)throw new Error("Auth by key not yet supported");if(e.email&&e.password){const n=e.projectId?Nt(e.projectId):Nt(Pt),r=e.projectId?vt(e.projectId):vt(Pt),o=e.anonKey?e.anonKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZkZ3RyeG1tcnRsb2toZ2t2Y2p6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzMwODcwNzYsImV4cCI6MTk4ODY2MzA3Nn0.sAMxjlcJSSozBGr-LNcsudyxzUEM9e-UspMHHQLqLr4",s=t.createClient(n,o),{data:i,error:a}=await s.auth.signInWithPassword({email:e.email,password:e.password});if(a)throw a;if(void 0===i.session?.access_token)throw new Error("Access token not found");return new Bt(r,i.session?.access_token)}throw new Error("Authentication Required. DeNotify supports either username/password or API key authentication")}async alertHistory(e,t={}){return await this.request("get","alert-history"+(e?"/"+e:""),{params:t})}async getAlert(e){return(await this.request("get",`alerts/${e}`))[0]}async getAlerts(){return await this.request("get","alerts")}async createAlert(e){const t=Lt.SimpleToRaw(e.name,e.triggerId,e.network,e.trigger),n=Ct.SimpleToRaw(e.notificationId,e.notification);return await this.request("post","alerts",{body:{trigger:t,notification:n}})}async deleteAlert(e){return await this.request("delete",`alerts/${e}`)}async request(e,t,n={}){const r=new URL(`${this.url}${t}`);if(n.params)for(const e of Object.keys(n.params))r.searchParams.append(e,n.params[e]);const o={method:e,url:r.toString(),headers:this.headers};n.body&&(o.data=n.body);return(await At(o)).data}async getAbi(e,t){return await this.request("get",`abi/${e}/${t}`)}async getAbiHash(e){return(await this.request("post","abi",{body:e})).hash}async setAlertName(e,t){}async enableAlert(e){}async disableAlert(e){}async updateTrigger(e,t){return await this.request("patch",`alerts/trigger-handler/${e}`,{body:t})}}e.DeNotifyClient=Bt}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@supabase/supabase-js"),require("form-data"),require("url"),require("proxy-from-env"),require("http"),require("https"),require("util"),require("follow-redirects"),require("zlib"),require("stream"),require("events"),require("ethers")):"function"==typeof define&&define.amd?define(["exports","@supabase/supabase-js","form-data","url","proxy-from-env","http","https","util","follow-redirects","zlib","stream","events","ethers"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["denotify-client"]={},e.supabaseJs,e.FormData$1,e.url,e.proxyFromEnv,e.http,e.https,e.util,e.followRedirects,e.zlib,e.stream,e.EventEmitter,e.ethers)}(this,(function(e,t,n,r,o,s,i,a,c,u,l,f,d){"use strict";function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=h(n),m=h(r),g=h(s),y=h(i),w=h(a),b=h(c),E=h(u),R=h(l),O=h(f);function S(e,t){return function(){return e.apply(t,arguments)}}const{toString:T}=Object.prototype,{getPrototypeOf:A}=Object,v=(x=Object.create(null),e=>{const t=T.call(e);return x[t]||(x[t]=t.slice(8,-1).toLowerCase())});var x;const C=e=>(e=e.toLowerCase(),t=>v(t)===e),_=e=>t=>typeof t===e,{isArray:N}=Array,L=_("undefined");const P=C("ArrayBuffer");const k=_("string"),B=_("function"),j=_("number"),F=e=>null!==e&&"object"==typeof e,D=e=>{if("object"!==v(e))return!1;const t=A(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},U=C("Date"),I=C("File"),z=C("Blob"),q=C("FileList"),H=C("URLSearchParams");function M(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),N(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(r=0;r<s;r++)i=o[r],t.call(null,e[i],i,e)}}function $(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const J="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,W=e=>!L(e)&&e!==J;const V=(K="undefined"!=typeof Uint8Array&&A(Uint8Array),e=>K&&e instanceof K);var K;const G=C("HTMLFormElement"),Z=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Q=C("RegExp"),X=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};M(n,((n,o)=>{!1!==t(n,o,e)&&(r[o]=n)})),Object.defineProperties(e,r)},Y="abcdefghijklmnopqrstuvwxyz",ee="0123456789",te={DIGIT:ee,ALPHA:Y,ALPHA_DIGIT:Y+Y.toUpperCase()+ee};var ne={isArray:N,isArrayBuffer:P,isBuffer:function(e){return null!==e&&!L(e)&&null!==e.constructor&&!L(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{const t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||T.call(e)===t||B(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&P(e.buffer),t},isString:k,isNumber:j,isBoolean:e=>!0===e||!1===e,isObject:F,isPlainObject:D,isUndefined:L,isDate:U,isFile:I,isBlob:z,isRegExp:Q,isFunction:B,isStream:e=>F(e)&&B(e.pipe),isURLSearchParams:H,isTypedArray:V,isFileList:q,forEach:M,merge:function e(){const{caseless:t}=W(this)&&this||{},n={},r=(r,o)=>{const s=t&&$(n,o)||o;D(n[s])&&D(r)?n[s]=e(n[s],r):D(r)?n[s]=e({},r):N(r)?n[s]=r.slice():n[s]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&M(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:r}={})=>(M(t,((t,r)=>{n&&B(t)?e[r]=S(t,n):e[r]=t}),{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],r&&!r(i,e,t)||a[i]||(t[i]=e[i],a[i]=!0);e=!1!==n&&A(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:v,kindOfTest:C,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(N(e))return e;let t=e.length;if(!j(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:G,hasOwnProperty:Z,hasOwnProp:Z,reduceDescriptors:X,freezeMethods:e=>{X(e,((t,n)=>{if(B(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];B(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return N(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:$,global:J,isContextDefined:W,ALPHABET:te,generateString:(e=16,t=te.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&B(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(F(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const o=N(e)?[]:{};return M(e,((e,t)=>{const s=n(e,r+1);!L(s)&&(o[t]=s)})),t[r]=void 0,o}}return e};return n(e,0)}};function re(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}ne.inherits(re,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ne.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const oe=re.prototype,se={};function ie(e){return ne.isPlainObject(e)||ne.isArray(e)}function ae(e){return ne.endsWith(e,"[]")?e.slice(0,-2):e}function ce(e,t,n){return e?e.concat(t).map((function(e,t){return e=ae(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{se[e]={value:e}})),Object.defineProperties(re,se),Object.defineProperty(oe,"isAxiosError",{value:!0}),re.from=(e,t,n,r,o,s)=>{const i=Object.create(oe);return ne.toFlatObject(e,i,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),re.call(i,e.message,t,n,r,o),i.cause=e,i.name=e.name,s&&Object.assign(i,s),i};const ue=ne.toFlatObject(ne,{},null,(function(e){return/^is[A-Z]/.test(e)}));function le(e,t,n){if(!ne.isObject(e))throw new TypeError("target must be an object");t=t||new(p.default||FormData);const r=(n=ne.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!ne.isUndefined(t[e])}))).metaTokens,o=n.visitor||u,s=n.dots,i=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&ne.isSpecCompliantForm(t);if(!ne.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(ne.isDate(e))return e.toISOString();if(!a&&ne.isBlob(e))throw new re("Blob is not supported. Use a Buffer instead.");return ne.isArrayBuffer(e)||ne.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(ne.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(ne.isArray(e)&&function(e){return ne.isArray(e)&&!e.some(ie)}(e)||(ne.isFileList(e)||ne.endsWith(n,"[]"))&&(a=ne.toArray(e)))return n=ae(n),a.forEach((function(e,r){!ne.isUndefined(e)&&null!==e&&t.append(!0===i?ce([n],r,s):null===i?n:n+"[]",c(e))})),!1;return!!ie(e)||(t.append(ce(o,n,s),c(e)),!1)}const l=[],f=Object.assign(ue,{defaultVisitor:u,convertValue:c,isVisitable:ie});if(!ne.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!ne.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),ne.forEach(n,(function(n,s){!0===(!(ne.isUndefined(n)||null===n)&&o.call(t,n,ne.isString(s)?s.trim():s,r,f))&&e(n,r?r.concat(s):[s])})),l.pop()}}(e),t}function fe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function de(e,t){this._pairs=[],e&&le(e,this,t)}const he=de.prototype;function pe(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function me(e,t,n){if(!t)return e;const r=n&&n.encode||pe,o=n&&n.serialize;let s;if(s=o?o(t,n):ne.isURLSearchParams(t)?t.toString():new de(t,n).toString(r),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}he.append=function(e,t){this._pairs.push([e,t])},he.toString=function(e){const t=e?function(t){return e.call(this,t,fe)}:fe;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var ge=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ne.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},ye={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},we={isNode:!0,classes:{URLSearchParams:m.default.URLSearchParams,FormData:p.default,Blob:"undefined"!=typeof Blob&&Blob||null},protocols:["http","https","file","data"]};function be(e){function t(e,n,r,o){let s=e[o++];const i=Number.isFinite(+s),a=o>=e.length;if(s=!s&&ne.isArray(r)?r.length:s,a)return ne.hasOwnProp(r,s)?r[s]=[r[s],n]:r[s]=n,!i;r[s]&&ne.isObject(r[s])||(r[s]=[]);return t(e,n,r[s],o)&&ne.isArray(r[s])&&(r[s]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}(r[s])),!i}if(ne.isFormData(e)&&ne.isFunction(e.entries)){const n={};return ne.forEachEntry(e,((e,r)=>{t(function(e){return ne.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null}const Ee={"Content-Type":void 0};const Re={transitional:ye,adapter:["xhr","http"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=ne.isObject(e);o&&ne.isHTMLForm(e)&&(e=new FormData(e));if(ne.isFormData(e))return r&&r?JSON.stringify(be(e)):e;if(ne.isArrayBuffer(e)||ne.isBuffer(e)||ne.isStream(e)||ne.isFile(e)||ne.isBlob(e))return e;if(ne.isArrayBufferView(e))return e.buffer;if(ne.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return le(e,new we.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return ne.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((s=ne.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return le(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(ne.isString(e))try{return(t||JSON.parse)(e),ne.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Re.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(e&&ne.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw re.from(e,re.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:we.classes.FormData,Blob:we.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};ne.forEach(["delete","get","head"],(function(e){Re.headers[e]={}})),ne.forEach(["post","put","patch"],(function(e){Re.headers[e]=ne.merge(Ee)}));var Oe=Re;const Se=ne.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const Te=Symbol("internals");function Ae(e){return e&&String(e).trim().toLowerCase()}function ve(e){return!1===e||null==e?e:ne.isArray(e)?e.map(ve):String(e)}function xe(e,t,n,r,o){return ne.isFunction(r)?r.call(this,t,n):(o&&(t=n),ne.isString(t)?ne.isString(r)?-1!==t.indexOf(r):ne.isRegExp(r)?r.test(t):void 0:void 0)}class Ce{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Ae(t);if(!o)throw new Error("header name must be a non-empty string");const s=ne.findKey(r,o);(!s||void 0===r[s]||!0===n||void 0===n&&!1!==r[s])&&(r[s||t]=ve(e))}const s=(e,t)=>ne.forEach(e,((e,n)=>o(e,n,t)));return ne.isPlainObject(e)||e instanceof this.constructor?s(e,t):ne.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z]+$/.test(e.trim())?s((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Se[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t):null!=e&&o(t,e,n),this}get(e,t){if(e=Ae(e)){const n=ne.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(ne.isFunction(t))return t.call(this,e,n);if(ne.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ae(e)){const n=ne.findKey(this,e);return!(!n||void 0===this[n]||t&&!xe(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Ae(e)){const o=ne.findKey(n,e);!o||t&&!xe(0,n[o],o,t)||(delete n[o],r=!0)}}return ne.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!xe(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return ne.forEach(this,((r,o)=>{const s=ne.findKey(n,o);if(s)return t[s]=ve(r),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(o):String(o).trim();i!==o&&delete t[o],t[i]=ve(r),n[i]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return ne.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&ne.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[Te]=this[Te]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Ae(e);t[r]||(!function(e,t){const n=ne.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})}))}(n,e),t[r]=!0)}return ne.isArray(e)?e.forEach(r):r(e),this}}Ce.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ne.freezeMethods(Ce.prototype),ne.freezeMethods(Ce);var _e=Ce;function Ne(e,t){const n=this||Oe,r=t||n,o=_e.from(r.headers);let s=r.data;return ne.forEach(e,(function(e){s=e.call(n,s,o.normalize(),t?t.status:void 0)})),o.normalize(),s}function Le(e){return!(!e||!e.__CANCEL__)}function Pe(e,t,n){re.call(this,null==e?"canceled":e,re.ERR_CANCELED,t,n),this.name="CanceledError"}function ke(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new re("Request failed with status code "+n.status,[re.ERR_BAD_REQUEST,re.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}function Be(e,t){return e&&!function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}ne.inherits(Pe,re,{__CANCEL__:!0});const je="1.3.4";function Fe(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}const De=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function Ue(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,s=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=r[i];o||(o=c),n[s]=a,r[s]=c;let l=i,f=0;for(;l!==s;)f+=n[l++],l%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),c-o<t)return;const d=u&&c-u;return d?Math.round(1e3*f/d):void 0}}const Ie=Symbol("internals");class ze extends R.default.Transform{constructor(e){super({readableHighWaterMark:(e=ne.toFlatObject(e,{maxRate:0,chunkSize:65536,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,((e,t)=>!ne.isUndefined(t[e])))).chunkSize});const t=this,n=this[Ie]={length:e.length,timeWindow:e.timeWindow,ticksRate:e.ticksRate,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null},r=Ue(n.ticksRate*e.samplesCount,n.timeWindow);this.on("newListener",(e=>{"progress"===e&&(n.isCaptured||(n.isCaptured=!0))}));let o=0;n.updateProgress=function(e,t){let n=0;const r=1e3/t;let o=null;return function(t,s){const i=Date.now();if(t||i-n>r)return o&&(clearTimeout(o),o=null),n=i,e.apply(null,s);o||(o=setTimeout((()=>(o=null,n=Date.now(),e.apply(null,s))),r-(i-n)))}}((function(){const e=n.length,s=n.bytesSeen,i=s-o;if(!i||t.destroyed)return;const a=r(i);o=s,process.nextTick((()=>{t.emit("progress",{loaded:s,total:e,progress:e?s/e:void 0,bytes:i,rate:a||void 0,estimated:a&&e&&s<=e?(e-s)/a:void 0})}))}),n.ticksRate);const s=()=>{n.updateProgress(!0)};this.once("end",s),this.once("error",s)}_read(e){const t=this[Ie];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,n){const r=this,o=this[Ie],s=o.maxRate,i=this.readableHighWaterMark,a=o.timeWindow,c=s/(1e3/a),u=!1!==o.minChunkSize?Math.max(o.minChunkSize,.01*c):0;const l=(e,t)=>{const n=Buffer.byteLength(e);let l,f=null,d=i,h=0;if(s){const e=Date.now();(!o.ts||(h=e-o.ts)>=a)&&(o.ts=e,l=c-o.bytes,o.bytes=l<0?-l:0,h=0),l=c-o.bytes}if(s){if(l<=0)return setTimeout((()=>{t(null,e)}),a-h);l<d&&(d=l)}d&&n>d&&n-d>u&&(f=e.subarray(d),e=e.subarray(0,d)),function(e,t){const n=Buffer.byteLength(e);o.bytesSeen+=n,o.bytes+=n,o.isCaptured&&o.updateProgress(),r.push(e)?process.nextTick(t):o.onReadCallback=()=>{o.onReadCallback=null,process.nextTick(t)}}(e,f?()=>{process.nextTick(t,null,f)}:t)};l(e,(function e(t,r){if(t)return n(t);r?l(r,e):n(null)}))}setLength(e){return this[Ie].length=+e,this}}var qe=ze;const{asyncIterator:He}=Symbol;var Me=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[He]?yield*e[He]():yield e};const $e=ne.ALPHABET.ALPHA_DIGIT+"-_",Je=new a.TextEncoder,We="\r\n",Ve=Je.encode(We);class Ke{constructor(e,t){const{escapeName:n}=this.constructor,r=ne.isString(t);let o=`Content-Disposition: form-data; name="${n(e)}"${!r&&t.name?`; filename="${n(t.name)}"`:""}${We}`;r?t=Je.encode(String(t).replace(/\r?\n|\r\n?/g,We)):o+=`Content-Type: ${t.type||"application/octet-stream"}${We}`,this.headers=Je.encode(o+We),this.contentLength=r?t.byteLength:t.size,this.size=this.headers.byteLength+this.contentLength+2,this.name=e,this.value=t}async*encode(){yield this.headers;const{value:e}=this;ne.isTypedArray(e)?yield e:yield*Me(e),yield Ve}static escapeName(e){return String(e).replace(/[\r\n"]/g,(e=>({"\r":"%0D","\n":"%0A",'"':"%22"}[e])))}}var Ge=(e,t,n)=>{const{tag:r="form-data-boundary",size:o=25,boundary:s=r+"-"+ne.generateString(o,$e)}=n||{};if(!ne.isFormData(e))throw TypeError("FormData instance required");if(s.length<1||s.length>70)throw Error("boundary must be 10-70 characters long");const i=Je.encode("--"+s+We),a=Je.encode("--"+s+"--"+We+We);let c=a.byteLength;const u=Array.from(e.entries()).map((([e,t])=>{const n=new Ke(e,t);return c+=n.size,n}));c+=i.byteLength*u.length,c=ne.toFiniteNumber(c);const f={"Content-Type":`multipart/form-data; boundary=${s}`};return Number.isFinite(c)&&(f["Content-Length"]=c),t&&t(f),l.Readable.from(async function*(){for(const e of u)yield i,yield*e.encode();yield a}())};class Ze extends R.default.Transform{__transform(e,t,n){this.push(e),n()}_transform(e,t,n){if(0!==e.length&&(this._transform=this.__transform,120!==e[0])){const e=Buffer.alloc(2);e[0]=120,e[1]=156,this.push(e,t)}this.__transform(e,t,n)}}var Qe=Ze;const Xe={flush:E.default.constants.Z_SYNC_FLUSH,finishFlush:E.default.constants.Z_SYNC_FLUSH},Ye={flush:E.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:E.default.constants.BROTLI_OPERATION_FLUSH},et=ne.isFunction(E.default.createBrotliDecompress),{http:tt,https:nt}=b.default,rt=/https:?/,ot=we.protocols.map((e=>e+":"));function st(e){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e)}function it(e,t,n){let r=t;if(!r&&!1!==r){const e=o.getProxyForUrl(n);e&&(r=new URL(e))}if(r){if(r.username&&(r.auth=(r.username||"")+":"+(r.password||"")),r.auth){(r.auth.username||r.auth.password)&&(r.auth=(r.auth.username||"")+":"+(r.auth.password||""));const t=Buffer.from(r.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+t}e.headers.host=e.hostname+(e.port?":"+e.port:"");const t=r.hostname||r.host;e.hostname=t,e.host=t,e.port=r.port,e.path=n,r.protocol&&(e.protocol=r.protocol.includes(":")?r.protocol:`${r.protocol}:`)}e.beforeRedirects.proxy=function(e){it(e,t,e.href)}}const at="undefined"!=typeof process&&"process"===ne.kindOf(process);function ct(e,t){let n=0;const r=Ue(50,250);return o=>{const s=o.loaded,i=o.lengthComputable?o.total:void 0,a=s-n,c=r(a);n=s;const u={loaded:s,total:i,progress:i?s/i:void 0,bytes:a,rate:c||void 0,estimated:c&&i&&s<=i?(i-s)/c:void 0,event:o};u[t?"download":"upload"]=!0,e(u)}}const ut={http:at&&function(e){return t=async function(t,n,r){let{data:o}=e;const{responseType:s,responseEncoding:i}=e,a=e.method.toUpperCase();let c,u,l=!1;const f=new O.default,d=()=>{e.cancelToken&&e.cancelToken.unsubscribe(h),e.signal&&e.signal.removeEventListener("abort",h),f.removeAllListeners()};function h(t){f.emit("abort",!t||t.type?new Pe(null,e,u):t)}r(((e,t)=>{c=!0,t&&(l=!0,d())})),f.once("abort",n),(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(h),e.signal&&(e.signal.aborted?h():e.signal.addEventListener("abort",h)));const p=Be(e.baseURL,e.url),m=new URL(p,"http://localhost"),b=m.protocol||ot[0];if("data:"===b){let r;if("GET"!==a)return ke(t,n,{status:405,statusText:"method not allowed",headers:{},config:e});try{r=function(e,t,n){const r=n&&n.Blob||we.classes.Blob,o=Fe(e);if(void 0===t&&r&&(t=!0),"data"===o){e=o.length?e.slice(o.length+1):e;const n=De.exec(e);if(!n)throw new re("Invalid URL",re.ERR_INVALID_URL);const s=n[1],i=n[2],a=n[3],c=Buffer.from(decodeURIComponent(a),i?"base64":"utf8");if(t){if(!r)throw new re("Blob is not supported",re.ERR_NOT_SUPPORT);return new r([c],{type:s})}return c}throw new re("Unsupported protocol "+o,re.ERR_NOT_SUPPORT)}(e.url,"blob"===s,{Blob:e.env&&e.env.Blob})}catch(t){throw re.from(t,re.ERR_BAD_REQUEST,e)}return"text"===s?(r=r.toString(i),i&&"utf8"!==i||(r=ne.stripBOM(r))):"stream"===s&&(r=R.default.Readable.from(r)),ke(t,n,{data:r,status:200,statusText:"OK",headers:new _e,config:e})}if(-1===ot.indexOf(b))return n(new re("Unsupported protocol "+b,re.ERR_BAD_REQUEST,e));const S=_e.from(e.headers).normalize();S.set("User-Agent","axios/"+je,!1);const T=e.onDownloadProgress,A=e.onUploadProgress,v=e.maxRate;let x,C;if(ne.isSpecCompliantForm(o)){const e=S.getContentType(/boundary=([-_\w\d]{10,70})/i);o=Ge(o,(e=>{S.set(e)}),{tag:`axios-${je}-boundary`,boundary:e&&e[1]||void 0})}else if(ne.isFormData(o)&&ne.isFunction(o.getHeaders)){if(S.set(o.getHeaders()),!S.hasContentLength())try{const e=await w.default.promisify(o.getLength).call(o);Number.isFinite(e)&&e>=0&&S.setContentLength(e)}catch(e){}}else if(ne.isBlob(o))o.size&&S.setContentType(o.type||"application/octet-stream"),S.setContentLength(o.size||0),o=R.default.Readable.from(Me(o));else if(o&&!ne.isStream(o)){if(Buffer.isBuffer(o));else if(ne.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else{if(!ne.isString(o))return n(new re("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",re.ERR_BAD_REQUEST,e));o=Buffer.from(o,"utf-8")}if(S.setContentLength(o.length,!1),e.maxBodyLength>-1&&o.length>e.maxBodyLength)return n(new re("Request body larger than maxBodyLength limit",re.ERR_BAD_REQUEST,e))}const _=ne.toFiniteNumber(S.getContentLength());let N,L;ne.isArray(v)?(x=v[0],C=v[1]):x=C=v,o&&(A||x)&&(ne.isStream(o)||(o=R.default.Readable.from(o,{objectMode:!1})),o=R.default.pipeline([o,new qe({length:_,maxRate:ne.toFiniteNumber(x)})],ne.noop),A&&o.on("progress",(e=>{A(Object.assign(e,{upload:!0}))}))),e.auth&&(N=(e.auth.username||"")+":"+(e.auth.password||"")),!N&&m.username&&(N=m.username+":"+m.password),N&&S.delete("authorization");try{L=me(m.pathname+m.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(t){const r=new Error(t.message);return r.config=e,r.url=e.url,r.exists=!0,n(r)}S.set("Accept-Encoding","gzip, compress, deflate"+(et?", br":""),!1);const P={path:L,method:a,headers:S.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:N,protocol:b,beforeRedirect:st,beforeRedirects:{}};let k;e.socketPath?P.socketPath=e.socketPath:(P.hostname=m.hostname,P.port=m.port,it(P,e.proxy,b+"//"+m.hostname+(m.port?":"+m.port:"")+P.path));const B=rt.test(P.protocol);if(P.agent=B?e.httpsAgent:e.httpAgent,e.transport?k=e.transport:0===e.maxRedirects?k=B?y.default:g.default:(e.maxRedirects&&(P.maxRedirects=e.maxRedirects),e.beforeRedirect&&(P.beforeRedirects.config=e.beforeRedirect),k=B?nt:tt),e.maxBodyLength>-1?P.maxBodyLength=e.maxBodyLength:P.maxBodyLength=1/0,e.insecureHTTPParser&&(P.insecureHTTPParser=e.insecureHTTPParser),u=k.request(P,(function(r){if(u.destroyed)return;const o=[r],c=+r.headers["content-length"];if(T){const e=new qe({length:ne.toFiniteNumber(c),maxRate:ne.toFiniteNumber(C)});T&&e.on("progress",(e=>{T(Object.assign(e,{download:!0}))})),o.push(e)}let h=r;const p=r.req||u;if(!1!==e.decompress&&r.headers["content-encoding"])switch("HEAD"!==a&&204!==r.statusCode||delete r.headers["content-encoding"],r.headers["content-encoding"]){case"gzip":case"x-gzip":case"compress":case"x-compress":o.push(E.default.createUnzip(Xe)),delete r.headers["content-encoding"];break;case"deflate":o.push(new Qe),o.push(E.default.createUnzip(Xe)),delete r.headers["content-encoding"];break;case"br":et&&(o.push(E.default.createBrotliDecompress(Ye)),delete r.headers["content-encoding"])}h=o.length>1?R.default.pipeline(o,ne.noop):o[0];const m=R.default.finished(h,(()=>{m(),d()})),g={status:r.statusCode,statusText:r.statusMessage,headers:new _e(r.headers),config:e,request:p};if("stream"===s)g.data=h,ke(t,n,g);else{const r=[];let o=0;h.on("data",(function(t){r.push(t),o+=t.length,e.maxContentLength>-1&&o>e.maxContentLength&&(l=!0,h.destroy(),n(new re("maxContentLength size of "+e.maxContentLength+" exceeded",re.ERR_BAD_RESPONSE,e,p)))})),h.on("aborted",(function(){if(l)return;const t=new re("maxContentLength size of "+e.maxContentLength+" exceeded",re.ERR_BAD_RESPONSE,e,p);h.destroy(t),n(t)})),h.on("error",(function(t){u.destroyed||n(re.from(t,null,e,p))})),h.on("end",(function(){try{let e=1===r.length?r[0]:Buffer.concat(r);"arraybuffer"!==s&&(e=e.toString(i),i&&"utf8"!==i||(e=ne.stripBOM(e))),g.data=e}catch(t){n(re.from(t,null,e,g.request,g))}ke(t,n,g)}))}f.once("abort",(e=>{h.destroyed||(h.emit("error",e),h.destroy())}))})),f.once("abort",(e=>{n(e),u.destroy(e)})),u.on("error",(function(t){n(re.from(t,null,e,u))})),u.on("socket",(function(e){e.setKeepAlive(!0,6e4)})),e.timeout){const t=parseInt(e.timeout,10);if(isNaN(t))return void n(new re("error trying to parse `config.timeout` to int",re.ERR_BAD_OPTION_VALUE,e,u));u.setTimeout(t,(function(){if(c)return;let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const r=e.transitional||ye;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new re(t,r.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,e,u)),h()}))}if(ne.isStream(o)){let t=!1,n=!1;o.on("end",(()=>{t=!0})),o.once("error",(e=>{n=!0,u.destroy(e)})),o.on("close",(()=>{t||n||h(new Pe("Request stream has been aborted",e,u))})),o.pipe(u)}else u.end(o)},new Promise(((e,n)=>{let r,o;const s=(e,t)=>{o||(o=!0,r&&r(e,t))},i=e=>{s(e,!0),n(e)};t((t=>{s(t),e(t)}),i,(e=>r=e)).catch(i)}));var t},xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){let r=e.data;const o=_e.from(e.headers).normalize(),s=e.responseType;let i;function a(){e.cancelToken&&e.cancelToken.unsubscribe(i),e.signal&&e.signal.removeEventListener("abort",i)}ne.isFormData(r)&&we.isStandardBrowserWebWorkerEnv&&o.setContentType(!1);let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",n=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(t+":"+n))}const u=Be(e.baseURL,e.url);function l(){if(!c)return;const r=_e.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());ke((function(e){t(e),a()}),(function(e){n(e),a()}),{data:s&&"text"!==s&&"json"!==s?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:r,config:e,request:c}),c=null}c.open(e.method.toUpperCase(),me(u,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=l:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(l)},c.onabort=function(){c&&(n(new re("Request aborted",re.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new re("Network Error",re.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const r=e.transitional||ye;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new re(t,r.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,e,c)),c=null},void 0===r&&o.setContentType(null),"setRequestHeader"in c&&ne.forEach(o.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),ne.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),s&&"json"!==s&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",ct(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",ct(e.onUploadProgress)),(e.cancelToken||e.signal)&&(i=t=>{c&&(n(!t||t.type?new Pe(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(i),e.signal&&(e.signal.aborted?i():e.signal.addEventListener("abort",i)));const f=Fe(u);f&&-1===we.protocols.indexOf(f)?n(new re("Unsupported protocol "+f+":",re.ERR_BAD_REQUEST,e)):c.send(r||null)}))}};ne.forEach(ut,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var lt={getAdapter:e=>{e=ne.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let o=0;o<t&&(n=e[o],!(r=ne.isString(n)?ut[n.toLowerCase()]:n));o++);if(!r){if(!1===r)throw new re(`Adapter ${n} is not supported by the environment`,"ERR_NOT_SUPPORT");throw new Error(ne.hasOwnProp(ut,n)?`Adapter '${n}' is not available in the build`:`Unknown adapter '${n}'`)}if(!ne.isFunction(r))throw new TypeError("adapter is not a function");return r},adapters:ut};function ft(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Pe(null,e)}function dt(e){ft(e),e.headers=_e.from(e.headers),e.data=Ne.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return lt.getAdapter(e.adapter||Oe.adapter)(e).then((function(t){return ft(e),t.data=Ne.call(e,e.transformResponse,t),t.headers=_e.from(t.headers),t}),(function(t){return Le(t)||(ft(e),t&&t.response&&(t.response.data=Ne.call(e,e.transformResponse,t.response),t.response.headers=_e.from(t.response.headers))),Promise.reject(t)}))}const ht=e=>e instanceof _e?e.toJSON():e;function pt(e,t){t=t||{};const n={};function r(e,t,n){return ne.isPlainObject(e)&&ne.isPlainObject(t)?ne.merge.call({caseless:n},e,t):ne.isPlainObject(t)?ne.merge({},t):ne.isArray(t)?t.slice():t}function o(e,t,n){return ne.isUndefined(t)?ne.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function s(e,t){if(!ne.isUndefined(t))return r(void 0,t)}function i(e,t){return ne.isUndefined(t)?ne.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,s){return s in t?r(n,o):s in e?r(void 0,n):void 0}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(e,t)=>o(ht(e),ht(t),!0)};return ne.forEach(Object.keys(e).concat(Object.keys(t)),(function(r){const s=c[r]||o,i=s(e[r],t[r],r);ne.isUndefined(i)&&s!==a||(n[r]=i)})),n}const mt={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{mt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const gt={};mt.transitional=function(e,t,n){function r(e,t){return"[Axios v"+je+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,s)=>{if(!1===e)throw new re(r(o," has been removed"+(t?" in "+t:"")),re.ERR_DEPRECATED);return t&&!gt[o]&&(gt[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,s)}};var yt={assertOptions:function(e,t,n){if("object"!=typeof e)throw new re("options must be an object",re.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const t=e[s],n=void 0===t||i(t,s,e);if(!0!==n)throw new re("option "+s+" must be "+n,re.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new re("Unknown option "+s,re.ERR_BAD_OPTION)}},validators:mt};const wt=yt.validators;class bt{constructor(e){this.defaults=e,this.interceptors={request:new ge,response:new ge}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=pt(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;let s;void 0!==n&&yt.assertOptions(n,{silentJSONParsing:wt.transitional(wt.boolean),forcedJSONParsing:wt.transitional(wt.boolean),clarifyTimeoutError:wt.transitional(wt.boolean)},!1),void 0!==r&&yt.assertOptions(r,{encode:wt.function,serialize:wt.function},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase(),s=o&&ne.merge(o.common,o[t.method]),s&&ne.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete o[e]})),t.headers=_e.concat(s,o);const i=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,i.unshift(e.fulfilled,e.rejected))}));const c=[];let u;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let l,f=0;if(!a){const e=[dt.bind(this),void 0];for(e.unshift.apply(e,i),e.push.apply(e,c),l=e.length,u=Promise.resolve(t);f<l;)u=u.then(e[f++],e[f++]);return u}l=i.length;let d=t;for(f=0;f<l;){const e=i[f++],t=i[f++];try{d=e(d)}catch(e){t.call(this,e);break}}try{u=dt.call(this,d)}catch(e){return Promise.reject(e)}for(f=0,l=c.length;f<l;)u=u.then(c[f++],c[f++]);return u}getUri(e){return me(Be((e=pt(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}ne.forEach(["delete","get","head","options"],(function(e){bt.prototype[e]=function(t,n){return this.request(pt(n||{},{method:e,url:t,data:(n||{}).data}))}})),ne.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(pt(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}bt.prototype[e]=t(),bt.prototype[e+"Form"]=t(!0)}));var Et=bt;class Rt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,o){n.reason||(n.reason=new Pe(e,r,o),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new Rt((function(t){e=t})),cancel:e}}}var Ot=Rt;const St={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(St).forEach((([e,t])=>{St[t]=e}));var Tt=St;const At=function e(t){const n=new Et(t),r=S(Et.prototype.request,n);return ne.extend(r,Et.prototype,n,{allOwnKeys:!0}),ne.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(pt(t,n))},r}(Oe);At.Axios=Et,At.CanceledError=Pe,At.CancelToken=Ot,At.isCancel=Le,At.VERSION=je,At.toFormData=le,At.AxiosError=re,At.Cancel=At.CanceledError,At.all=function(e){return Promise.all(e)},At.spread=function(e){return function(t){return e.apply(null,t)}},At.isAxiosError=function(e){return ne.isObject(e)&&!0===e.isAxiosError},At.mergeConfig=pt,At.AxiosHeaders=_e,At.formToJSON=e=>be(ne.isHTMLForm(e)?new FormData(e):e),At.HttpStatusCode=Tt,At.default=At;var vt=At;const xt="notify_discord_webhook";class Ct{static SimpleToRaw(e){return{name:"",notify_type:xt,notify:e}}}class _t{static SimpleToRaw(e,t){if("Discord"===e)return Ct.SimpleToRaw(t)}}class Nt{static SimpleToRaw(e,t,n){return{alertType:"event",network:t,nickname:e,type:"handler_function_call",handler:n}}}class Lt{static SimpleToRaw(e,t,n){return{alertType:"event",network:t,nickname:e,type:"handler_onchain_event",handler:n}}}class Pt{static SimpleToRaw(e,t,n){return{alertType:"event",network:t,nickname:e,type:"handler_function_call_v2",handler:n}}}class kt{static SimpleToRaw(e,t,n,r){switch(t){case"PollFunctionV2":return Pt.SimpleToRaw(e,n,r);case"PollFunctionV1":return Nt.SimpleToRaw(e,n,r);case"OnchainEventV2":return Lt.SimpleToRaw(e,n,r);default:throw new Error("Invalid Trigger ID")}}}const Bt=e=>`https://${e}.functions.supabase.co/`,jt=e=>`https://${e}.supabase.co/`,Ft="fdgtrxmmrtlokhgkvcjz";class Dt{url;token;headers={};constructor(e,t){this.url=e,this.token=t,this.headers={Authorization:`Bearer ${t}`,"Content-Type":"application/json"}}static async create(e){if(e.key)throw new Error("Auth by key not yet supported");if(e.email&&e.password){const n=e.projectId?jt(e.projectId):jt(Ft),r=e.projectId?Bt(e.projectId):Bt(Ft),o=e.anonKey?e.anonKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZkZ3RyeG1tcnRsb2toZ2t2Y2p6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzMwODcwNzYsImV4cCI6MTk4ODY2MzA3Nn0.sAMxjlcJSSozBGr-LNcsudyxzUEM9e-UspMHHQLqLr4",s=t.createClient(n,o),{data:i,error:a}=await s.auth.signInWithPassword({email:e.email,password:e.password});if(a)throw a;if(void 0===i.session?.access_token)throw new Error("Access token not found");return new Dt(r,i.session?.access_token)}throw new Error("Authentication Required. DeNotify supports either username/password or API key authentication")}async alertHistory(e,t={}){return await this.request("get","alert-history"+(e?"/"+e:""),{params:t})}async getAlert(e){return(await this.request("get",`alerts/${e}`))[0]}async getAlerts(){return await this.request("get","alerts")}async createAlert(e){const t=kt.SimpleToRaw(e.name,e.triggerId,e.network,e.trigger),n=_t.SimpleToRaw(e.notificationId,e.notification);return await this.request("post","alerts",{body:{trigger:t,notification:n}})}async deleteAlert(e){return await this.request("delete",`alerts/${e}`)}async request(e,t,n={}){const r=new URL(`${this.url}${t}`);if(n.params)for(const e of Object.keys(n.params))r.searchParams.append(e,n.params[e]);const o={method:e,url:r.toString(),headers:this.headers};n.body&&(o.data=n.body);return(await vt(o)).data}async getAbi(e,t){return await this.request("get",`abi/${e}/${t}`)}async getAbiHash(e){return(await this.request("post","abi",{body:e})).hash}async setAlertName(e,t){throw new Error("Not yet supported - Sorry!")}async enableAlert(e){throw new Error("Not yet supported - Sorry!")}async disableAlert(e){throw new Error("Not yet supported - Sorry!")}async updateNotification(e){throw new Error("Not yet supported - Sorry!")}async updateTrigger(e,t){return await this.request("patch",`alerts/trigger-handler/${e}`,{body:t})}}class Ut{name;network;triggerId;trigger;notificationId;notification;constructor(e){this.name=e}static create(e){return new Ut(e)}onNetwork(e){return this.network=e,this}withTrigger(e,t){return this.triggerId=e,this.trigger=t,this}withNotification(e,t){return this.notificationId=e,this.notification=t,this}config(){if(void 0===this.trigger||void 0===this.triggerId)throw new Error("Trigger not configured");if(void 0===this.notification||void 0===this.notificationId)throw new Error("Notification not configured");if(void 0===this.network)throw new Error("Network not configured");return{name:this.name,network:this.network,triggerId:this.triggerId,trigger:this.trigger,notificationId:this.notificationId,notification:this.notification}}}class It{api;data=[];constructor(e){this.api=e}static create(e){return new It(e)}getAbiHash(e){if(void 0===this.api)throw new Error("FunctionBuilder must be initialised with api");return this.api.getAbiHash(e)}async addFunction(e,t,n,r){const o=new d.ethers.Contract(e,r);return o.interface.encodeFunctionData(t,n),this.data.push({address:e,bytecode:o.interface.encodeFunctionData(t,n),abiHash:await this.getAbiHash(r),function:t}),this}get(){return this.data}}class zt{static version(){return"v1"}static execute(e,t,n="v1"){const r=JSON.parse(JSON.stringify(t));let o=!0;for(const t of r){const n=zt.process(e,t.conditions);o=zt.execLogic(o,t.logic,n)}return o}static process(e,t,n){const r=t.shift();if(!r)return void 0===n||n;const o=zt.execCondition(e,r);if(void 0===n||"WHERE"===r.logic)return zt.process(e,t,o);if(void 0===r.logic)throw new Error("Invalid filter. Condition must have logic value");const s=zt.execLogic(n,r.logic,o);return zt.process(e,t,s)}static execLogic(e,t,n){switch(t){case"AND":return e&&n;case"OR":return e||n;case"XOR":return(e||n)&&!(e&&n);case"NAND":case"NOR":return!(e&&n);case"WHERE":return n;default:throw new Error(`Invalid Filter. Bad logic value: ${t}`)}}static execCondition(e,t){const n=e[t.key];if("Number"===t.type){if("number"!=typeof t.constant||"number"!=typeof n)throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${n}`);const e=n,r=t.constant;switch(t.operation){case"eq":return e===r;case"!eq":return e!==r;case"gt":return e>r;case"gte":return e>=r;case"lt":return e<r;case"lte":return e<=r;default:throw new Error("Invalid Filter. Operation does not match type")}}if("String"===t.type){if("string"!=typeof t.constant||"string"!=typeof n)throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${n}`);const e=n,r=t.constant;switch(t.operation){case"contains":return e.includes(r);case"!contains":return!e.includes(r);case"is":return e===r;case"!is":return e!==r;case"isEmpty":return""===e;case"!isEmpty":return""!==e;default:throw new Error("Invalid Filter. Operation does not match type")}}if("Address"===t.type){if("string"!=typeof t.constant||"string"!=typeof n)throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${n}`);const e=n,r=t.constant;switch(t.operation){case"contains":return e.toLowerCase().includes(r.toLowerCase());case"!contains":return!e.toLowerCase().includes(r.toLowerCase());case"is":return e.toLowerCase()===r.toLowerCase();case"!is":return e.toLowerCase()!==r.toLowerCase();case"isEmpty":return""===e;case"!isEmpty":return""!==e;default:throw new Error("Invalid Filter. Operation does not match type")}}throw new Error("Invalid Filter. Unknown Type")}}class qt{groups=[];constructor(){this.newGroup("WHERE")}static version(){return zt.version()}static new(){return new qt}newGroup(e){if(0!==this.groups.length&&"WHERE"===e)throw new Error('Only the first groups can start with "WHERE"');return this.groups.push({logic:"WHERE",conditions:[]}),this}addCondition(e,t,n,r,o){const s=this.groups[this.groups.length-1];if(0===s.conditions.length&&"WHERE"!==e)throw new Error('Logic for the first condition of a group must be "WHERE"');if(s.conditions.length>0&&"WHERE"===e)throw new Error('Only the first condition of a group can be "WHERE"');return s.conditions.push({logic:e,key:t,type:n,operation:r,constant:o}),this}finalise(){for(const e of this.groups)if(0===e.conditions.length)throw new Error("Bad Filter. All Groups must have atleast one condition");return this.groups}}var Ht=Object.freeze({__proto__:null,Trigger:kt,HandlerFunctionCallV2:Pt,HandlerFunctionCall:Nt,HandlerOnchainEvent:Lt}),Mt=Object.freeze({__proto__:null,NOTIFY_DISCORD_WEBHOOK_RAW_ID:xt,NotifyDiscordWebhook:Ct,Notification:_t});e.AlertBuilder=Ut,e.DeNotifyClient=Dt,e.FilterBuilder=qt,e.FunctionBuilder=It,e.Notification=Mt,e.Trigger=Ht}));
package/dist/index.mjs CHANGED
@@ -9,6 +9,7 @@ import followRedirects from 'follow-redirects';
9
9
  import zlib from 'zlib';
10
10
  import stream, { Readable } from 'stream';
11
11
  import EventEmitter from 'events';
12
+ import { ethers } from 'ethers';
12
13
 
13
14
  function bind(fn, thisArg) {
14
15
  return function wrap() {
@@ -4070,6 +4071,32 @@ class Notification {
4070
4071
  }
4071
4072
  }
4072
4073
 
4074
+ const HANDLER_FUNCTION_CALL_V1_RAW_ID = 'handler_function_call';
4075
+ class HandlerFunctionCall {
4076
+ static SimpleToRaw(name, network, config) {
4077
+ return {
4078
+ alertType: 'event',
4079
+ network,
4080
+ nickname: name,
4081
+ type: HANDLER_FUNCTION_CALL_V1_RAW_ID,
4082
+ handler: config
4083
+ };
4084
+ }
4085
+ }
4086
+
4087
+ const HANDLER_ONCHAIN_EVENT_V1_RAW_ID = 'handler_onchain_event';
4088
+ class HandlerOnchainEvent {
4089
+ static SimpleToRaw(name, network, config) {
4090
+ return {
4091
+ alertType: 'event',
4092
+ network,
4093
+ nickname: name,
4094
+ type: HANDLER_ONCHAIN_EVENT_V1_RAW_ID,
4095
+ handler: config
4096
+ };
4097
+ }
4098
+ }
4099
+
4073
4100
  const HANDLER_FUNCTION_CALL_V2_RAW_ID = 'handler_function_call_v2';
4074
4101
  class HandlerFunctionCallV2 {
4075
4102
  static SimpleToRaw(name, network, config) {
@@ -4087,6 +4114,8 @@ class Trigger {
4087
4114
  static SimpleToRaw(name, id, network, config) {
4088
4115
  switch (id) {
4089
4116
  case 'PollFunctionV2': return HandlerFunctionCallV2.SimpleToRaw(name, network, config);
4117
+ case 'PollFunctionV1': return HandlerFunctionCall.SimpleToRaw(name, network, config);
4118
+ case 'OnchainEventV2': return HandlerOnchainEvent.SimpleToRaw(name, network, config);
4090
4119
  default:
4091
4120
  throw new Error('Invalid Trigger ID');
4092
4121
  }
@@ -4187,15 +4216,244 @@ class DeNotifyClient {
4187
4216
  return ret.hash;
4188
4217
  }
4189
4218
  async setAlertName(triggerId, name) {
4219
+ throw new Error('Not yet supported - Sorry!');
4190
4220
  }
4191
4221
  async enableAlert(triggerId) {
4222
+ throw new Error('Not yet supported - Sorry!');
4192
4223
  }
4193
4224
  async disableAlert(triggerId) {
4225
+ throw new Error('Not yet supported - Sorry!');
4226
+ }
4227
+ async updateNotification(triggerId) {
4228
+ throw new Error('Not yet supported - Sorry!');
4194
4229
  }
4195
4230
  async updateTrigger(triggerId, update) {
4231
+ // TODO - Input validation
4196
4232
  const ret = await this.request('patch', `alerts/trigger-handler/${triggerId}`, { body: update });
4197
4233
  return ret;
4198
4234
  }
4199
4235
  }
4200
4236
 
4201
- export { DeNotifyClient };
4237
+ class AlertBuilder {
4238
+ name;
4239
+ network;
4240
+ triggerId;
4241
+ trigger;
4242
+ notificationId;
4243
+ notification;
4244
+ constructor(name) {
4245
+ this.name = name;
4246
+ }
4247
+ static create(name) {
4248
+ return new AlertBuilder(name);
4249
+ }
4250
+ onNetwork(network) {
4251
+ this.network = network;
4252
+ return this;
4253
+ }
4254
+ withTrigger(id, options) {
4255
+ this.triggerId = id;
4256
+ this.trigger = options;
4257
+ return this;
4258
+ }
4259
+ withNotification(id, options) {
4260
+ this.notificationId = id;
4261
+ this.notification = options;
4262
+ return this;
4263
+ }
4264
+ config() {
4265
+ if (this.trigger === undefined || this.triggerId === undefined)
4266
+ throw new Error('Trigger not configured');
4267
+ if (this.notification === undefined || this.notificationId === undefined)
4268
+ throw new Error('Notification not configured');
4269
+ if (this.network === undefined)
4270
+ throw new Error('Network not configured');
4271
+ return {
4272
+ name: this.name,
4273
+ network: this.network,
4274
+ triggerId: this.triggerId,
4275
+ trigger: this.trigger,
4276
+ notificationId: this.notificationId,
4277
+ notification: this.notification,
4278
+ };
4279
+ }
4280
+ }
4281
+
4282
+ class FunctionBuilder {
4283
+ api;
4284
+ data = [];
4285
+ constructor(api) {
4286
+ this.api = api;
4287
+ }
4288
+ static create(api) {
4289
+ return new FunctionBuilder(api);
4290
+ }
4291
+ getAbiHash(abi) {
4292
+ if (this.api === undefined)
4293
+ throw new Error('FunctionBuilder must be initialised with api');
4294
+ return this.api.getAbiHash(abi);
4295
+ }
4296
+ async addFunction(address, func, args, abi) {
4297
+ const contract = new ethers.Contract(address, abi);
4298
+ contract.interface.encodeFunctionData(func, args);
4299
+ this.data.push({
4300
+ address,
4301
+ bytecode: contract.interface.encodeFunctionData(func, args),
4302
+ abiHash: await this.getAbiHash(abi),
4303
+ function: func,
4304
+ });
4305
+ return this;
4306
+ }
4307
+ get() {
4308
+ return this.data;
4309
+ }
4310
+ }
4311
+
4312
+ class Filter {
4313
+ static version() {
4314
+ return 'v1';
4315
+ }
4316
+ static execute(record, groupsIn, version = 'v1') {
4317
+ // Deep copy to so we can edit the object during recursion
4318
+ const groups = JSON.parse(JSON.stringify(groupsIn));
4319
+ let lhs = true;
4320
+ for (const group of groups) {
4321
+ const rhs = Filter.process(record, group.conditions);
4322
+ lhs = Filter.execLogic(lhs, group.logic, rhs);
4323
+ }
4324
+ return lhs;
4325
+ }
4326
+ static process(record, conditions, lhs) {
4327
+ const condition = conditions.shift();
4328
+ if (!condition) {
4329
+ if (lhs === undefined)
4330
+ return true;
4331
+ return lhs;
4332
+ }
4333
+ // lhs <logic> rhs
4334
+ const rhs = Filter.execCondition(record, condition);
4335
+ if (lhs === undefined || condition.logic === 'WHERE')
4336
+ return Filter.process(record, conditions, rhs);
4337
+ if (condition.logic === undefined)
4338
+ throw new Error('Invalid filter. Condition must have logic value');
4339
+ const next = Filter.execLogic(lhs, condition.logic, rhs);
4340
+ return Filter.process(record, conditions, next);
4341
+ }
4342
+ static execLogic(lhs, logic, rhs) {
4343
+ switch (logic) {
4344
+ case 'AND': return lhs && rhs;
4345
+ case 'OR': return lhs || rhs;
4346
+ case 'XOR': return (lhs || rhs) && !(lhs && rhs);
4347
+ case 'NAND': return !(lhs && rhs);
4348
+ case 'NOR': return !(lhs && rhs);
4349
+ case 'WHERE': return rhs;
4350
+ default: throw new Error(`Invalid Filter. Bad logic value: ${logic}`);
4351
+ }
4352
+ }
4353
+ static execCondition(record, condition) {
4354
+ const data = record[condition.key];
4355
+ if (condition.type === 'Number') {
4356
+ if (typeof condition.constant !== 'number' || typeof data !== 'number')
4357
+ throw new Error(`Invalid filter. Type miss-match. Type: ${condition.type}, Variable: ${condition.constant}, Data: ${data}`);
4358
+ const n = data;
4359
+ const constant = condition.constant;
4360
+ switch (condition.operation) {
4361
+ case 'eq': return n === constant;
4362
+ case '!eq': return n !== constant;
4363
+ case 'gt': return n > constant;
4364
+ case 'gte': return n >= constant;
4365
+ case 'lt': return n < constant;
4366
+ case 'lte': return n <= constant;
4367
+ default: throw new Error('Invalid Filter. Operation does not match type');
4368
+ }
4369
+ }
4370
+ if (condition.type === 'String') {
4371
+ if (typeof condition.constant !== 'string' || typeof data !== 'string')
4372
+ throw new Error(`Invalid filter. Type miss-match. Type: ${condition.type}, Variable: ${condition.constant}, Data: ${data}`);
4373
+ const str = data;
4374
+ const constant = condition.constant;
4375
+ switch (condition.operation) {
4376
+ case 'contains': return str.includes(constant);
4377
+ case '!contains': return !str.includes(constant);
4378
+ case 'is': return str === constant;
4379
+ case '!is': return str !== constant;
4380
+ case 'isEmpty': return str === '';
4381
+ case '!isEmpty': return str !== '';
4382
+ default: throw new Error('Invalid Filter. Operation does not match type');
4383
+ }
4384
+ }
4385
+ if (condition.type === 'Address') {
4386
+ if (typeof condition.constant !== 'string' || typeof data !== 'string')
4387
+ throw new Error(`Invalid filter. Type miss-match. Type: ${condition.type}, Variable: ${condition.constant}, Data: ${data}`);
4388
+ const str = data;
4389
+ const constant = condition.constant;
4390
+ switch (condition.operation) {
4391
+ case 'contains': return str.toLowerCase().includes(constant.toLowerCase());
4392
+ case '!contains': return !str.toLowerCase().includes(constant.toLowerCase());
4393
+ case 'is': return str.toLowerCase() === constant.toLowerCase();
4394
+ case '!is': return str.toLowerCase() !== constant.toLowerCase();
4395
+ case 'isEmpty': return str === '';
4396
+ case '!isEmpty': return str !== '';
4397
+ default: throw new Error('Invalid Filter. Operation does not match type');
4398
+ }
4399
+ }
4400
+ throw new Error('Invalid Filter. Unknown Type');
4401
+ }
4402
+ }
4403
+ class FilterBuilder {
4404
+ groups = [];
4405
+ constructor() {
4406
+ this.newGroup('WHERE');
4407
+ }
4408
+ static version() {
4409
+ return Filter.version();
4410
+ }
4411
+ static new() {
4412
+ return new FilterBuilder();
4413
+ }
4414
+ newGroup(logic) {
4415
+ if (this.groups.length !== 0 && logic === 'WHERE')
4416
+ throw new Error('Only the first groups can start with "WHERE"');
4417
+ this.groups.push({ logic: 'WHERE', conditions: [] });
4418
+ return this;
4419
+ }
4420
+ addCondition(logic, key, type, operation, constant) {
4421
+ const group = this.groups[this.groups.length - 1];
4422
+ if (group.conditions.length === 0 && logic !== 'WHERE')
4423
+ throw new Error('Logic for the first condition of a group must be "WHERE"');
4424
+ if (group.conditions.length > 0 && logic === 'WHERE')
4425
+ throw new Error('Only the first condition of a group can be "WHERE"');
4426
+ group.conditions.push({
4427
+ logic,
4428
+ key,
4429
+ type,
4430
+ operation,
4431
+ constant
4432
+ });
4433
+ return this;
4434
+ }
4435
+ finalise() {
4436
+ for (const group of this.groups) {
4437
+ if (group.conditions.length === 0)
4438
+ throw new Error('Bad Filter. All Groups must have atleast one condition');
4439
+ }
4440
+ return this.groups;
4441
+ }
4442
+ }
4443
+
4444
+ var index$1 = /*#__PURE__*/Object.freeze({
4445
+ __proto__: null,
4446
+ Trigger: Trigger,
4447
+ HandlerFunctionCallV2: HandlerFunctionCallV2,
4448
+ HandlerFunctionCall: HandlerFunctionCall,
4449
+ HandlerOnchainEvent: HandlerOnchainEvent
4450
+ });
4451
+
4452
+ var index = /*#__PURE__*/Object.freeze({
4453
+ __proto__: null,
4454
+ NOTIFY_DISCORD_WEBHOOK_RAW_ID: NOTIFY_DISCORD_WEBHOOK_RAW_ID,
4455
+ NotifyDiscordWebhook: NotifyDiscordWebhook,
4456
+ Notification: Notification
4457
+ });
4458
+
4459
+ export { AlertBuilder, DeNotifyClient, FilterBuilder, FunctionBuilder, index as Notification, index$1 as Trigger };
@@ -0,0 +1,3 @@
1
+ import { Notification, } from "./notification.js";
2
+ import { NOTIFY_DISCORD_WEBHOOK_RAW_ID, NotifyDiscordWebhook, } from "./notify_discord_webhook.js";
3
+ export { NOTIFY_DISCORD_WEBHOOK_RAW_ID, NotifyDiscordWebhook, Notification, };
@@ -1 +1,12 @@
1
- export {};
1
+ const HANDLER_FUNCTION_CALL_V1_RAW_ID = 'handler_function_call';
2
+ export class HandlerFunctionCall {
3
+ static SimpleToRaw(name, network, config) {
4
+ return {
5
+ alertType: 'event',
6
+ network,
7
+ nickname: name,
8
+ type: HANDLER_FUNCTION_CALL_V1_RAW_ID,
9
+ handler: config
10
+ };
11
+ }
12
+ }
@@ -1 +1,12 @@
1
- export {};
1
+ const HANDLER_ONCHAIN_EVENT_V1_RAW_ID = 'handler_onchain_event';
2
+ export class HandlerOnchainEvent {
3
+ static SimpleToRaw(name, network, config) {
4
+ return {
5
+ alertType: 'event',
6
+ network,
7
+ nickname: name,
8
+ type: HANDLER_ONCHAIN_EVENT_V1_RAW_ID,
9
+ handler: config
10
+ };
11
+ }
12
+ }
@@ -0,0 +1,5 @@
1
+ import { Trigger } from "./trigger.js";
2
+ import { HandlerFunctionCallV2 } from "./handler_function_call_v2.js";
3
+ import { HandlerFunctionCall } from "./handler_function_call.js";
4
+ import { HandlerOnchainEvent } from "./handler_onchain_event.js";
5
+ export { Trigger, HandlerFunctionCallV2, HandlerFunctionCall, HandlerOnchainEvent, };
@@ -1,8 +1,12 @@
1
+ import { HandlerFunctionCall } from "./handler_function_call.js";
2
+ import { HandlerOnchainEvent } from "./handler_onchain_event.js";
1
3
  import { HandlerFunctionCallV2 } from "./handler_function_call_v2.js";
2
4
  export class Trigger {
3
5
  static SimpleToRaw(name, id, network, config) {
4
6
  switch (id) {
5
7
  case 'PollFunctionV2': return HandlerFunctionCallV2.SimpleToRaw(name, network, config);
8
+ case 'PollFunctionV1': return HandlerFunctionCall.SimpleToRaw(name, network, config);
9
+ case 'OnchainEventV2': return HandlerOnchainEvent.SimpleToRaw(name, network, config);
6
10
  default:
7
11
  throw new Error('Invalid Trigger ID');
8
12
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0",
2
+ "version": "1.1.0",
3
3
  "name": "denotify-client",
4
4
  "umd:name": "denotify-client",
5
5
  "repository": "robo-labs/denotify-client",
@@ -23,5 +23,6 @@ export declare class DeNotifyClient {
23
23
  setAlertName(triggerId: number, name: string): Promise<void>;
24
24
  enableAlert(triggerId: number): Promise<void>;
25
25
  disableAlert(triggerId: number): Promise<void>;
26
+ updateNotification(triggerId: number): Promise<void>;
26
27
  updateTrigger(triggerId: number, update: TriggerUpdate): Promise<any>;
27
28
  }
package/types/index.d.ts CHANGED
@@ -1,2 +1,7 @@
1
1
  import { DeNotifyClient } from "./denotifyclient.js";
2
- export { DeNotifyClient };
2
+ import { AlertBuilder } from "./alertbuilder.js";
3
+ import { FunctionBuilder } from "./functionbuilder.js";
4
+ import { FilterBuilder } from "./util/filter.js";
5
+ import * as Trigger from "./triggers/index.js";
6
+ import * as Notification from "./notifications/index.js";
7
+ export { DeNotifyClient, AlertBuilder, FilterBuilder, FunctionBuilder, Trigger, Notification, };
@@ -0,0 +1,3 @@
1
+ import { NotificationTypeId, NotificationConfig, NotifyRawId, NotifyRawConfig, NotifyRawResponse, NotifyRawUpdate, NotificationRawConfig, Notification } from "./notification.js";
2
+ import { DiscordWebhook, NotifyDiscordWebhookRawId, NOTIFY_DISCORD_WEBHOOK_RAW_ID, NotifyDiscordWebhookRawConfig, NotifyDiscordWebhookRawResponse, NotifyDiscordWebhookRawUpdate, NotifyDiscordWebhook } from "./notify_discord_webhook.js";
3
+ export { DiscordWebhook, NotifyDiscordWebhookRawId, NOTIFY_DISCORD_WEBHOOK_RAW_ID, NotifyDiscordWebhookRawConfig, NotifyDiscordWebhookRawResponse, NotifyDiscordWebhookRawUpdate, NotifyDiscordWebhook, NotificationTypeId, NotificationConfig, NotifyRawId, NotifyRawConfig, NotifyRawResponse, NotifyRawUpdate, NotificationRawConfig, Notification, };
@@ -1,5 +1,16 @@
1
1
  import { Condition } from "../types/types.js";
2
- export declare type PollFunctionV1 = {};
2
+ import { Network, TriggerRawConfig } from "./trigger.js";
3
+ export declare type PollFunctionV1 = {
4
+ nBlocks: number;
5
+ address: string;
6
+ abi: any;
7
+ fixedArgs?: (string | number)[];
8
+ function: string;
9
+ condition: Condition;
10
+ responseArgIndex?: number;
11
+ responseArgDecimals?: number;
12
+ constant?: number;
13
+ };
3
14
  export declare type HandlerFunctionCallRawConfig = {
4
15
  nBlocks: number;
5
16
  address: string;
@@ -37,3 +48,6 @@ export declare type HandlerFunctionCallRawUpdate = {
37
48
  responseArgIndex?: number;
38
49
  responseArgDecimals?: number;
39
50
  };
51
+ export declare class HandlerFunctionCall {
52
+ static SimpleToRaw(name: string, network: Network, config: PollFunctionV1): TriggerRawConfig;
53
+ }
@@ -1,5 +1,14 @@
1
1
  import { Condition } from "../util/filter.js";
2
- export declare type OnchainEventV1 = {};
2
+ import { Network, TriggerRawConfig } from "./trigger.js";
3
+ export declare type OnchainEventV1 = {
4
+ address: string;
5
+ event: string;
6
+ abi: any;
7
+ condition: Condition;
8
+ paramsIndex?: number;
9
+ paramsDecimals?: number;
10
+ constant?: number;
11
+ };
3
12
  export declare type HandlerOnchainEventRawConfig = {
4
13
  address: string;
5
14
  event: string;
@@ -29,3 +38,6 @@ export declare type HandlerOnchainEventRawUpdate = {
29
38
  paramsDecimals?: number;
30
39
  constant?: number;
31
40
  };
41
+ export declare class HandlerOnchainEvent {
42
+ static SimpleToRaw(name: string, network: Network, config: OnchainEventV1): TriggerRawConfig;
43
+ }
@@ -0,0 +1,5 @@
1
+ import { Network, TriggerConfig, TriggerTypeId, TriggerUpdate, TriggerTypeRawId, TriggerOn, HandlerRawConfig, TriggerRawConfig, Trigger } from "./trigger.js";
2
+ import { PollFunctionV2, HandlerFunctionCallV2RawConfig, HandlerFunctionCallV2Update, HandlerFunctionCallV2RawResponse, HandlerFunctionCallV2RawUpdate, HandlerFunctionCallV2 } from "./handler_function_call_v2.js";
3
+ import { PollFunctionV1, HandlerFunctionCallRawConfig, HandlerFunctionCallUpdate, HandlerFunctionCallRawResponse, HandlerFunctionCallRawUpdate, HandlerFunctionCall } from "./handler_function_call.js";
4
+ import { OnchainEventV1, HandlerOnchainEventRawConfig, HandlerOnchainEventUpdate, HandlerOnchainEventRawResponse, HandlerOnchainEventRawUpdate, HandlerOnchainEvent } from "./handler_onchain_event.js";
5
+ export { Network, TriggerConfig, TriggerTypeId, TriggerUpdate, TriggerTypeRawId, TriggerOn, HandlerRawConfig, TriggerRawConfig, Trigger, PollFunctionV2, HandlerFunctionCallV2RawConfig, HandlerFunctionCallV2Update, HandlerFunctionCallV2RawResponse, HandlerFunctionCallV2RawUpdate, HandlerFunctionCallV2, PollFunctionV1, HandlerFunctionCallRawConfig, HandlerFunctionCallUpdate, HandlerFunctionCallRawResponse, HandlerFunctionCallRawUpdate, HandlerFunctionCall, OnchainEventV1, HandlerOnchainEventRawConfig, HandlerOnchainEventUpdate, HandlerOnchainEventRawResponse, HandlerOnchainEventRawUpdate, HandlerOnchainEvent, };
@@ -3,9 +3,9 @@ import { HandlerOnchainEventRawConfig, HandlerOnchainEventUpdate, OnchainEventV1
3
3
  import { HandlerFunctionCallV2RawConfig, HandlerFunctionCallV2Update, PollFunctionV2 } from "./handler_function_call_v2.js";
4
4
  export declare type Network = 'avalanche' | 'ethereum';
5
5
  export declare type TriggerConfig = PollFunctionV2 | PollFunctionV1 | OnchainEventV1;
6
- export declare type TriggerTypeId = 'PollFunctionV2' | 'OnchainEventV2' | 'FunctionEventV2';
6
+ export declare type TriggerTypeId = 'PollFunctionV2' | 'OnchainEventV2' | 'PollFunctionV1';
7
7
  export declare type TriggerUpdate = HandlerFunctionCallV2Update | HandlerFunctionCallUpdate | HandlerOnchainEventUpdate;
8
- export declare type TriggerTypeRawId = 'handler_function_call' | 'onchain_event_call_v2' | 'handler_function_call_v2';
8
+ export declare type TriggerTypeRawId = 'handler_function_call' | 'handler_onchain_event' | 'handler_function_call_v2';
9
9
  export declare type TriggerOn = 'event' | 'latch';
10
10
  export declare type HandlerRawConfig = HandlerFunctionCallRawConfig | HandlerOnchainEventRawConfig | HandlerFunctionCallV2RawConfig;
11
11
  export declare type TriggerRawConfig = {