w-orm-lowdb 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,7 +19,11 @@ npm i w-orm-lowdb
19
19
  #### Example
20
20
  > **Link:** [[dev source code](https://github.com/yuda-lyu/w-orm-lowdblob/master/g-basic.mjs)]
21
21
  ```alias
22
- import wo from 'w-orm-lowdb'
22
+ import WOrm from './src/WOrmLowdb.mjs'
23
+ //import WOrm from './dist/w-orm-lowdb.umd.js'
24
+ // import w from 'wsemi'
25
+
26
+ // w.fsDeleteFile('./db.json')
23
27
 
24
28
  let opt = {
25
29
  url: './db.json',
@@ -30,15 +34,18 @@ let opt = {
30
34
  let rs = [
31
35
  {
32
36
  id: 'id-peter',
33
- name: 'peter'
37
+ name: 'peter',
38
+ value: 123,
34
39
  },
35
40
  {
36
41
  id: 'id-rosemary',
37
- name: 'rosemary'
42
+ name: 'rosemary',
43
+ value: 123.456,
38
44
  },
39
45
  {
40
46
  id: '',
41
- name: 'kettle'
47
+ name: 'kettle',
48
+ value: 456,
42
49
  },
43
50
  ]
44
51
 
@@ -59,104 +66,119 @@ let rsm = [
59
66
 
60
67
  async function test() {
61
68
 
62
-
63
- //w
64
- let w = wo(opt)
65
-
69
+ //wo
70
+ let wo = WOrm(opt)
66
71
 
67
72
  //on
68
- w.on('change', function(mode, data, res) {
73
+ wo.on('change', function(mode, data, res) {
69
74
  console.log('change', mode)
70
75
  })
71
76
 
72
-
73
77
  //delAll
74
- await w.delAll()
78
+ await wo.delAll()
75
79
  .then(function(msg) {
76
80
  console.log('delAll then', msg)
77
81
  })
78
82
  .catch(function(msg) {
79
83
  console.log('delAll catch', msg)
80
84
  })
81
- // => delAll then { n: 2, nDeleted: 2, ok: 1 }
82
-
83
85
 
84
86
  //insert
85
- await w.insert(rs)
87
+ await wo.insert(rs)
86
88
  .then(function(msg) {
87
89
  console.log('insert then', msg)
88
90
  })
89
91
  .catch(function(msg) {
90
92
  console.log('insert catch', msg)
91
93
  })
92
- // => insert then { n: 3, nInserted: 3, ok: 1 }
93
-
94
94
 
95
95
  //save
96
- await w.save(rsm, { autoInsert: false })
96
+ await wo.save(rsm, { autoInsert: false })
97
97
  .then(function(msg) {
98
98
  console.log('save then', msg)
99
99
  })
100
100
  .catch(function(msg) {
101
101
  console.log('save catch', msg)
102
102
  })
103
- // => save then [
104
- // { n: 1, nModified: 1, ok: 1 },
105
- // { n: 1, nModified: 1, ok: 1 },
106
- // { n: 0, nModified: 0, ok: 1 }, //autoInsert=false
107
- // { n: 1, nInserted: 1, ok: 1 } //autoInsert=true
108
- // ]
109
-
110
103
 
111
104
  //select all
112
- let ss = await w.select()
105
+ let ss = await wo.select()
113
106
  console.log('select all', ss)
114
- // => select all [
115
- // { id: 'id-peter', name: 'peter(modify)', value: 123 },
116
- // { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
117
- // { id: '{random id}', name: 'kettle', value: 456 },
118
- // { id: '{random id}', name: 'kettle(modify)' } //autoInsert=true
119
- // ]
120
-
121
107
 
122
108
  //select
123
- let so = await w.select({ id: 'id-rosemary' })
124
- // => select [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
125
-
109
+ let so = await wo.select({ id: 'id-rosemary' })
110
+ console.log('select', so)
126
111
 
127
112
  //select by $and, $gt, $lt
128
- let spa = await w.select({ '$and': [{ value: { '$gt': 123 } }, { value: { '$lt': 200 } }] })
129
- // => select [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
130
-
113
+ let spa = await wo.select({ '$and': [{ value: { '$gt': 123 } }, { value: { '$lt': 200 } }] })
114
+ console.log('select by $and, $gt, $lt', spa)
131
115
 
132
116
  //select by $or, $gte, $lte
133
- let spb = await w.select({ '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 200 } }] })
134
- // => select [ { id: '{random id}', name: 'kettle', value: 456 } ]
135
-
117
+ let spb = await wo.select({ '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 200 } }] })
118
+ console.log('select by $or, $gte, $lte', spb)
136
119
 
137
120
  //select by $or, $and, $ne, $in, $nin
138
- let spc = await w.select({ '$or': [{ '$and': [{ value: { '$ne': 123 } }, { value: { '$in': [123, 321, 123.456, 456] } }, { value: { '$nin': [456, 654] } }] }, { '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 400 } }] }] })
121
+ let spc = await wo.select({ '$or': [{ '$and': [{ value: { '$ne': 123 } }, { value: { '$in': [123, 321, 123.456, 456] } }, { value: { '$nin': [456, 654] } }] }, { '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 400 } }] }] })
139
122
  console.log('select by $or, $and, $ne, $in, $nin', spc)
140
- // => select [
141
- // { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
142
- // { id: '{random id}', name: 'kettle', value: 456 }
143
- // ]
144
123
 
124
+ // //select by regex //mingo不支援regex
125
+ // let sr = await wo.select({ name: { $regex: 'PeT', $options: '$i' } })
126
+ // console.log('selectReg', sr)
145
127
 
146
128
  //del
147
129
  let d = ss.filter(function(v) {
148
130
  return v.name === 'kettle'
149
131
  })
150
- w.del(d)
132
+ await wo.del(d)
151
133
  .then(function(msg) {
152
134
  console.log('del then', msg)
153
135
  })
154
136
  .catch(function(msg) {
155
137
  console.log('del catch', msg)
156
138
  })
157
- // => del then [ { n: 1, nDeleted: 1, ok: 1 } ]
158
-
159
139
 
160
140
  }
161
141
  test()
142
+ // change delAll
143
+ // delAll then { n: 2, nDeleted: 2, ok: 1 }
144
+ // change insert
145
+ // insert then { n: 3, nInserted: 3, ok: 1 }
146
+ // change save
147
+ // save then [
148
+ // { n: 1, nModified: 1, ok: 1 },
149
+ // { n: 1, nModified: 1, ok: 1 },
150
+ // { n: 0, nModified: 0, ok: 1 }
151
+ // ]
152
+ // select all [
153
+ // { id: 'id-peter', name: 'peter(modify)', value: 123 },
154
+ // { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
155
+ // {
156
+ // id: {random id},
157
+ // name: 'kettle',
158
+ // value: 456
159
+ // }
160
+ // ]
161
+ // select [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
162
+ // select by $and, $gt, $lt [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
163
+ // select by $or, $gte, $lte [
164
+ // {
165
+ // id: {random id},
166
+ // name: 'kettle',
167
+ // value: 456
168
+ // }
169
+ // ]
170
+ // select by $or, $and, $ne, $in, $nin [
171
+ // {
172
+ // id: 'id-rosemary',
173
+ // name: 'rosemary(modify)',
174
+ // value: 123.456
175
+ // },
176
+ // {
177
+ // id: {random id},
178
+ // name: 'kettle',
179
+ // value: 456
180
+ // }
181
+ // ]
182
+ // change del
183
+ // del then [ { n: 1, nDeleted: 1, ok: 1 } ]
162
184
  ```
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * w-orm-lowdb v1.0.0
2
+ * w-orm-lowdb v1.0.2
3
3
  * (c) 2018-2021 yuda-lyu(semisphere)
4
4
  * Released under the MIT License.
5
5
  */
6
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("events"),require("node:fs"),require("node:fs/promises"),require("node:path"),require("node:url"),require("mingo")):"function"==typeof define&&define.amd?define(["events","node:fs","node:fs/promises","node:path","node:url","mingo"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["w-orm-lowdb"]=e(t.events,null,t.promises,t.path,t.node_url,t.mingo)}(this,(function(t,e,r,n,o,i){"use strict";class u{adapter;data;constructor(t,e){!function(t,e){if(void 0===t)throw new Error("lowdb: missing adapter");if(void 0===e)throw new Error("lowdb: missing default data")}(t,e),this.adapter=t,this.data=e}async read(){const t=await this.adapter.read();t&&(this.data=t)}async write(){this.data&&await this.adapter.write(this.data)}async update(t){t(this.data),await this.write()}}class a{#t;#e;#r=!1;#n=null;#o=null;#i=null;#u=null;#a(t){return this.#u=t,this.#i||=new Promise(((t,e)=>{this.#o=[t,e]})),new Promise(((t,e)=>{var r;null===(r=this.#i)||void 0===r||r.then(t).catch(e)}))}async#c(t){this.#r=!0;try{var e;await r.writeFile(this.#e,t,"utf-8"),await async function(t,e,r){for(let n=0;n<e;n++)try{return await t()}catch(t){if(!(n<e-1))throw t;await new Promise((t=>setTimeout(t,r)))}}((async()=>{await r.rename(this.#e,this.#t)}),10,100),null===(e=this.#n)||void 0===e||e[0]()}catch(t){var n;if(t instanceof Error)null===(n=this.#n)||void 0===n||n[1](t);throw t}finally{if(this.#r=!1,this.#n=this.#o,this.#o=this.#i=null,null!==this.#u){const t=this.#u;this.#u=null,await this.write(t)}}}constructor(t){this.#t=t,this.#e=function(t){const e=t instanceof URL?o.fileURLToPath(t):t.toString();return n.join(n.dirname(e),`.${n.basename(e)}.tmp`)}(t)}async write(t){return this.#r?this.#a(t):this.#c(t)}}class c{#t;#f;constructor(t){this.#t=t,this.#f=new a(t)}async read(){let t;try{t=await r.readFile(this.#t,"utf-8")}catch(t){if("ENOENT"===t.code)return null;throw t}return t}write(t){return this.#f.write(t)}}class f{#l;#s;#v;constructor(t,e){let{parse:r,stringify:n}=e;this.#l=new c(t),this.#s=r,this.#v=n}async read(){const t=await this.#l.read();return null===t?null:this.#s(t)}write(t){return this.#l.write(this.#v(t))}}class l extends f{constructor(t){super(t,{parse:JSON.parse,stringify:t=>JSON.stringify(t,null,2)})}}var s=Array.isArray,v="object"==typeof global&&global&&global.Object===Object&&global,p="object"==typeof self&&self&&self.Object===Object&&self,d=v||p||Function("return this")(),h=d.Symbol,b=Object.prototype,y=b.hasOwnProperty,j=b.toString,g=h?h.toStringTag:void 0;var _=Object.prototype.toString;var w=h?h.toStringTag:void 0;function m(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":w&&w in Object(t)?function(t){var e=y.call(t,g),r=t[g];try{t[g]=void 0;var n=!0}catch(t){}var o=j.call(t);return n&&(e?t[g]=r:delete t[g]),o}(t):function(t){return _.call(t)}(t)}function O(t){return null!=t&&"object"==typeof t}function A(t){return"symbol"==typeof t||O(t)&&"[object Symbol]"==m(t)}var x=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,S=/^\w*$/;function P(t,e){if(s(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!A(t))||(S.test(t)||!x.test(t)||null!=e&&t in Object(e))}function k(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function z(t){if(!k(t))return!1;var e=m(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var E,F=d["__core-js_shared__"],D=(E=/[^.]+$/.exec(F&&F.keys&&F.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"";var M=Function.prototype.toString;function I(t){if(null!=t){try{return M.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var N=/^\[object .+?Constructor\]$/,U=Function.prototype,T=Object.prototype,$=U.toString,B=T.hasOwnProperty,R=RegExp("^"+$.call(B).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function L(t){return!(!k(t)||(e=t,D&&D in e))&&(z(t)?R:N).test(I(t));var e}function q(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return L(r)?r:void 0}var C=q(Object,"create");var V=Object.prototype.hasOwnProperty;var W=Object.prototype.hasOwnProperty;function G(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function J(t,e){return t===e||t!=t&&e!=e}function Q(t,e){for(var r=t.length;r--;)if(J(t[r][0],e))return r;return-1}G.prototype.clear=function(){this.__data__=C?C(null):{},this.size=0},G.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},G.prototype.get=function(t){var e=this.__data__;if(C){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return V.call(e,t)?e[t]:void 0},G.prototype.has=function(t){var e=this.__data__;return C?void 0!==e[t]:W.call(e,t)},G.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=C&&void 0===e?"__lodash_hash_undefined__":e,this};var H=Array.prototype.splice;function K(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}K.prototype.clear=function(){this.__data__=[],this.size=0},K.prototype.delete=function(t){var e=this.__data__,r=Q(e,t);return!(r<0)&&(r==e.length-1?e.pop():H.call(e,r,1),--this.size,!0)},K.prototype.get=function(t){var e=this.__data__,r=Q(e,t);return r<0?void 0:e[r][1]},K.prototype.has=function(t){return Q(this.__data__,t)>-1},K.prototype.set=function(t,e){var r=this.__data__,n=Q(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var X=q(d,"Map");function Y(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Z(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Z.prototype.clear=function(){this.size=0,this.__data__={hash:new G,map:new(X||K),string:new G}},Z.prototype.delete=function(t){var e=Y(this,t).delete(t);return this.size-=e?1:0,e},Z.prototype.get=function(t){return Y(this,t).get(t)},Z.prototype.has=function(t){return Y(this,t).has(t)},Z.prototype.set=function(t,e){var r=Y(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function tt(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return r.cache=i.set(o,u)||i,u};return r.cache=new(tt.Cache||Z),r}tt.Cache=Z;var et,rt,nt,ot=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,it=/\\(\\)?/g,ut=(et=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(ot,(function(t,r,n,o){e.push(n?o.replace(it,"$1"):r||t)})),e},rt=tt(et,(function(t){return 500===nt.size&&nt.clear(),t})),nt=rt.cache,rt),at=ut;function ct(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var ft=h?h.prototype:void 0,lt=ft?ft.toString:void 0;function st(t){if("string"==typeof t)return t;if(s(t))return ct(t,st)+"";if(A(t))return lt?lt.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function vt(t){return null==t?"":st(t)}function pt(t,e){return s(t)?t:P(t,e)?[t]:at(vt(t))}function dt(t){if("string"==typeof t||A(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function ht(t,e){for(var r=0,n=(e=pt(e,t)).length;null!=t&&r<n;)t=t[dt(e[r++])];return r&&r==n?t:void 0}function bt(t,e,r){var n=null==t?void 0:ht(t,e);return void 0===n?r:n}function yt(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}var jt,gt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),u=i.length;u--;){var a=i[jt?u:++n];if(!1===e(o[a],a,o))break}return t};function _t(t){return O(t)&&"[object Arguments]"==m(t)}var wt=Object.prototype,mt=wt.hasOwnProperty,Ot=wt.propertyIsEnumerable,At=_t(function(){return arguments}())?_t:function(t){return O(t)&&mt.call(t,"callee")&&!Ot.call(t,"callee")},xt=At;var St="object"==typeof exports&&exports&&!exports.nodeType&&exports,Pt=St&&"object"==typeof module&&module&&!module.nodeType&&module,kt=Pt&&Pt.exports===St?d.Buffer:void 0,zt=(kt?kt.isBuffer:void 0)||function(){return!1},Et=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Et.test(t))&&t>-1&&t%1==0&&t<e}function Dt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Mt={};function It(t){return function(e){return t(e)}}Mt["[object Float32Array]"]=Mt["[object Float64Array]"]=Mt["[object Int8Array]"]=Mt["[object Int16Array]"]=Mt["[object Int32Array]"]=Mt["[object Uint8Array]"]=Mt["[object Uint8ClampedArray]"]=Mt["[object Uint16Array]"]=Mt["[object Uint32Array]"]=!0,Mt["[object Arguments]"]=Mt["[object Array]"]=Mt["[object ArrayBuffer]"]=Mt["[object Boolean]"]=Mt["[object DataView]"]=Mt["[object Date]"]=Mt["[object Error]"]=Mt["[object Function]"]=Mt["[object Map]"]=Mt["[object Number]"]=Mt["[object Object]"]=Mt["[object RegExp]"]=Mt["[object Set]"]=Mt["[object String]"]=Mt["[object WeakMap]"]=!1;var Nt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ut=Nt&&"object"==typeof module&&module&&!module.nodeType&&module,Tt=Ut&&Ut.exports===Nt&&v.process,$t=function(){try{var t=Ut&&Ut.require&&Ut.require("util").types;return t||Tt&&Tt.binding&&Tt.binding("util")}catch(t){}}(),Bt=$t&&$t.isTypedArray,Rt=Bt?It(Bt):function(t){return O(t)&&Dt(t.length)&&!!Mt[m(t)]},Lt=Object.prototype.hasOwnProperty;function qt(t,e){var r=s(t),n=!r&&xt(t),o=!r&&!n&&zt(t),i=!r&&!n&&!o&&Rt(t),u=r||n||o||i,a=u?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var f in t)!e&&!Lt.call(t,f)||u&&("length"==f||o&&("offset"==f||"parent"==f)||i&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||Ft(f,c))||a.push(f);return a}var Ct=Object.prototype;function Vt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ct)}function Wt(t,e){return function(r){return t(e(r))}}var Gt=Wt(Object.keys,Object),Jt=Object.prototype.hasOwnProperty;function Qt(t){if(!Vt(t))return Gt(t);var e=[];for(var r in Object(t))Jt.call(t,r)&&"constructor"!=r&&e.push(r);return e}function Ht(t){return null!=t&&Dt(t.length)&&!z(t)}function Kt(t){return Ht(t)?qt(t):Qt(t)}var Xt=function(t,e){return function(r,n){if(null==r)return r;if(!Ht(r))return t(r,n);for(var o=r.length,i=e?o:-1,u=Object(r);(e?i--:++i<o)&&!1!==n(u[i],i,u););return r}}((function(t,e){return t&&gt(t,e,Kt)})),Yt=Xt;function Zt(t){return t}function te(t,e){var r;return(s(t)?yt:Yt)(t,"function"==typeof(r=e)?r:Zt)}function ee(t){var e=this.__data__=new K(t);this.size=e.size}ee.prototype.clear=function(){this.__data__=new K,this.size=0},ee.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},ee.prototype.get=function(t){return this.__data__.get(t)},ee.prototype.has=function(t){return this.__data__.has(t)},ee.prototype.set=function(t,e){var r=this.__data__;if(r instanceof K){var n=r.__data__;if(!X||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Z(n)}return r.set(t,e),this.size=r.size,this};function re(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Z;++e<r;)this.add(t[e])}function ne(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function oe(t,e){return t.has(e)}re.prototype.add=re.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},re.prototype.has=function(t){return this.__data__.has(t)};function ie(t,e,r,n,o,i){var u=1&r,a=t.length,c=e.length;if(a!=c&&!(u&&c>a))return!1;var f=i.get(t),l=i.get(e);if(f&&l)return f==e&&l==t;var s=-1,v=!0,p=2&r?new re:void 0;for(i.set(t,e),i.set(e,t);++s<a;){var d=t[s],h=e[s];if(n)var b=u?n(h,d,s,e,t,i):n(d,h,s,t,e,i);if(void 0!==b){if(b)continue;v=!1;break}if(p){if(!ne(e,(function(t,e){if(!oe(p,e)&&(d===t||o(d,t,r,n,i)))return p.push(e)}))){v=!1;break}}else if(d!==h&&!o(d,h,r,n,i)){v=!1;break}}return i.delete(t),i.delete(e),v}var ue=d.Uint8Array;function ae(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function ce(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var fe=h?h.prototype:void 0,le=fe?fe.valueOf:void 0;function se(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function ve(t,e,r){var n=e(t);return s(t)?n:se(n,r(t))}function pe(){return[]}var de=Object.prototype.propertyIsEnumerable,he=Object.getOwnPropertySymbols,be=he?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var u=t[r];e(u,r,t)&&(i[o++]=u)}return i}(he(t),(function(e){return de.call(t,e)})))}:pe,ye=be;function je(t){return ve(t,Kt,ye)}var ge=Object.prototype.hasOwnProperty;var _e=q(d,"DataView"),we=q(d,"Promise"),me=q(d,"Set"),Oe=q(d,"WeakMap"),Ae="[object Map]",xe="[object Promise]",Se="[object Set]",Pe="[object WeakMap]",ke="[object DataView]",ze=I(_e),Ee=I(X),Fe=I(we),De=I(me),Me=I(Oe),Ie=m;(_e&&Ie(new _e(new ArrayBuffer(1)))!=ke||X&&Ie(new X)!=Ae||we&&Ie(we.resolve())!=xe||me&&Ie(new me)!=Se||Oe&&Ie(new Oe)!=Pe)&&(Ie=function(t){var e=m(t),r="[object Object]"==e?t.constructor:void 0,n=r?I(r):"";if(n)switch(n){case ze:return ke;case Ee:return Ae;case Fe:return xe;case De:return Se;case Me:return Pe}return e});var Ne=Ie,Ue="[object Arguments]",Te="[object Array]",$e="[object Object]",Be=Object.prototype.hasOwnProperty;function Re(t,e,r,n,o,i){var u=s(t),a=s(e),c=u?Te:Ne(t),f=a?Te:Ne(e),l=(c=c==Ue?$e:c)==$e,v=(f=f==Ue?$e:f)==$e,p=c==f;if(p&&zt(t)){if(!zt(e))return!1;u=!0,l=!1}if(p&&!l)return i||(i=new ee),u||Rt(t)?ie(t,e,r,n,o,i):function(t,e,r,n,o,i,u){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!i(new ue(t),new ue(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return J(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=ae;case"[object Set]":var c=1&n;if(a||(a=ce),t.size!=e.size&&!c)return!1;var f=u.get(t);if(f)return f==e;n|=2,u.set(t,e);var l=ie(a(t),a(e),n,o,i,u);return u.delete(t),l;case"[object Symbol]":if(le)return le.call(t)==le.call(e)}return!1}(t,e,c,r,n,o,i);if(!(1&r)){var d=l&&Be.call(t,"__wrapped__"),h=v&&Be.call(e,"__wrapped__");if(d||h){var b=d?t.value():t,y=h?e.value():e;return i||(i=new ee),o(b,y,r,n,i)}}return!!p&&(i||(i=new ee),function(t,e,r,n,o,i){var u=1&r,a=je(t),c=a.length;if(c!=je(e).length&&!u)return!1;for(var f=c;f--;){var l=a[f];if(!(u?l in e:ge.call(e,l)))return!1}var s=i.get(t),v=i.get(e);if(s&&v)return s==e&&v==t;var p=!0;i.set(t,e),i.set(e,t);for(var d=u;++f<c;){var h=t[l=a[f]],b=e[l];if(n)var y=u?n(b,h,l,e,t,i):n(h,b,l,t,e,i);if(!(void 0===y?h===b||o(h,b,r,n,i):y)){p=!1;break}d||(d="constructor"==l)}if(p&&!d){var j=t.constructor,g=e.constructor;j==g||!("constructor"in t)||!("constructor"in e)||"function"==typeof j&&j instanceof j&&"function"==typeof g&&g instanceof g||(p=!1)}return i.delete(t),i.delete(e),p}(t,e,r,n,o,i))}function Le(t,e,r,n,o){return t===e||(null==t||null==e||!O(t)&&!O(e)?t!=t&&e!=e:Re(t,e,r,n,Le,o))}function qe(t){return t==t&&!k(t)}function Ce(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function Ve(t){var e=function(t){for(var e=Kt(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,qe(o)]}return e}(t);return 1==e.length&&e[0][2]?Ce(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var o=r.length,i=o,u=!n;if(null==t)return!i;for(t=Object(t);o--;){var a=r[o];if(u&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++o<i;){var c=(a=r[o])[0],f=t[c],l=a[1];if(u&&a[2]){if(void 0===f&&!(c in t))return!1}else{var s=new ee;if(n)var v=n(f,l,c,t,e,s);if(!(void 0===v?Le(l,f,3,n,s):v))return!1}}return!0}(r,t,e)}}function We(t,e){return null!=t&&e in Object(t)}function Ge(t,e){return null!=t&&function(t,e,r){for(var n=-1,o=(e=pt(e,t)).length,i=!1;++n<o;){var u=dt(e[n]);if(!(i=null!=t&&r(t,u)))break;t=t[u]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&Dt(o)&&Ft(u,o)&&(s(t)||xt(t))}(t,e,We)}function Je(t){return function(e){return null==e?void 0:e[t]}}function Qe(t){return P(t)?Je(dt(t)):function(t){return function(e){return ht(e,t)}}(t)}function He(t){return"function"==typeof t?t:null==t?Zt:"object"==typeof t?s(t)?function(t,e){return P(t)&&qe(e)?Ce(dt(t),e):function(r){var n=bt(r,t);return void 0===n&&n===e?Ge(r,t):Le(e,n,3)}}(t[0],t[1]):Ve(t):Qe(t)}function Ke(t,e){var r=-1,n=Ht(t)?Array(t.length):[];return Yt(t,(function(t,o,i){n[++r]=e(t,o,i)})),n}function Xe(t,e){return(s(t)?ct:Ke)(t,He(e))}var Ye=function(){try{var t=q(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Ze=Ye;function tr(t,e,r){"__proto__"==e&&Ze?Ze(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function er(t,e,r){(void 0!==r&&!J(t[e],r)||void 0===r&&!(e in t))&&tr(t,e,r)}var rr="object"==typeof exports&&exports&&!exports.nodeType&&exports,nr=rr&&"object"==typeof module&&module&&!module.nodeType&&module,or=nr&&nr.exports===rr?d.Buffer:void 0,ir=or?or.allocUnsafe:void 0;function ur(t,e){if(e)return t.slice();var r=t.length,n=ir?ir(r):new t.constructor(r);return t.copy(n),n}function ar(t){var e=new t.constructor(t.byteLength);return new ue(e).set(new ue(t)),e}function cr(t,e){var r=e?ar(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function fr(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var lr=Object.create,sr=function(){function t(){}return function(e){if(!k(e))return{};if(lr)return lr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),vr=sr,pr=Wt(Object.getPrototypeOf,Object);function dr(t){return"function"!=typeof t.constructor||Vt(t)?{}:vr(pr(t))}var hr=Function.prototype,br=Object.prototype,yr=hr.toString,jr=br.hasOwnProperty,gr=yr.call(Object);function _r(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var wr=Object.prototype.hasOwnProperty;function mr(t,e,r){var n=t[e];wr.call(t,e)&&J(n,r)&&(void 0!==r||e in t)||tr(t,e,r)}function Or(t,e,r,n){var o=!r;r||(r={});for(var i=-1,u=e.length;++i<u;){var a=e[i],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),o?tr(r,a,c):mr(r,a,c)}return r}var Ar=Object.prototype.hasOwnProperty;function xr(t){if(!k(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Vt(t),r=[];for(var n in t)("constructor"!=n||!e&&Ar.call(t,n))&&r.push(n);return r}function Sr(t){return Ht(t)?qt(t,!0):xr(t)}function Pr(t,e,r,n,o,i,u){var a=_r(t,r),c=_r(e,r),f=u.get(c);if(f)er(t,r,f);else{var l,v=i?i(a,c,r+"",t,e,u):void 0,p=void 0===v;if(p){var d=s(c),h=!d&&zt(c),b=!d&&!h&&Rt(c);v=c,d||h||b?s(a)?v=a:O(l=a)&&Ht(l)?v=fr(a):h?(p=!1,v=ur(c,!0)):b?(p=!1,v=cr(c,!0)):v=[]:function(t){if(!O(t)||"[object Object]"!=m(t))return!1;var e=pr(t);if(null===e)return!0;var r=jr.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&yr.call(r)==gr}(c)||xt(c)?(v=a,xt(a)?v=function(t){return Or(t,Sr(t))}(a):k(a)&&!z(a)||(v=dr(c))):p=!1}p&&(u.set(c,v),o(v,c,n,i,u),u.delete(c)),er(t,r,v)}}function kr(t,e,r,n,o){t!==e&&gt(e,(function(i,u){if(o||(o=new ee),k(i))Pr(t,e,u,r,kr,n,o);else{var a=n?n(_r(t,u),i,u+"",t,e,o):void 0;void 0===a&&(a=i),er(t,u,a)}}),Sr)}var zr=Math.max;function Er(t,e,r){return e=zr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=zr(n.length-e,0),u=Array(i);++o<i;)u[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(u),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,a)}}var Fr=Ze?function(t,e){return Ze(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:Zt,Dr=Fr,Mr=Date.now;var Ir=function(t){var e=0,r=0;return function(){var n=Mr(),o=16-(n-r);if(r=n,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Dr),Nr=Ir;var Ur,Tr=(Ur=function(t,e,r){kr(t,e,r)},function(t,e){return Nr(Er(t,e,Zt),t+"")}((function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Ur.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!k(r))return!1;var n=typeof e;return!!("number"==n?Ht(r)&&Ft(e,r.length):"string"==n&&e in r)&&J(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var u=e[r];u&&Ur(t,u,r,o)}return t}))),$r=Tr;var Br=Je("length"),Rr=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Lr="\\ud800-\\udfff",qr="["+Lr+"]",Cr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Vr="\\ud83c[\\udffb-\\udfff]",Wr="[^"+Lr+"]",Gr="(?:\\ud83c[\\udde6-\\uddff]){2}",Jr="[\\ud800-\\udbff][\\udc00-\\udfff]",Qr="(?:"+Cr+"|"+Vr+")"+"?",Hr="[\\ufe0e\\ufe0f]?",Kr=Hr+Qr+("(?:\\u200d(?:"+[Wr,Gr,Jr].join("|")+")"+Hr+Qr+")*"),Xr="(?:"+[Wr+Cr+"?",Cr,Gr,Jr,qr].join("|")+")",Yr=RegExp(Vr+"(?="+Vr+")|"+Xr+Kr,"g");function Zr(t){return function(t){return Rr.test(t)}(t)?function(t){for(var e=Yr.lastIndex=0;Yr.test(t);)++e;return e}(t):Br(t)}function tn(t){if(null==t)return 0;if(Ht(t))return"string"==typeof(e=t)||!s(e)&&O(e)&&"[object String]"==m(e)?Zr(t):t.length;var e,r=Ne(t);return"[object Map]"==r||"[object Set]"==r?t.size:Qt(t).length}var en=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)se(e,ye(t)),t=pr(t);return e}:pe,rn=en;function nn(t){return ve(t,Sr,rn)}var on=Object.prototype.hasOwnProperty;var un=/\w*$/;var an=h?h.prototype:void 0,cn=an?an.valueOf:void 0;function fn(t,e,r){var n,o=t.constructor;switch(e){case"[object ArrayBuffer]":return ar(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var r=e?ar(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return cr(t,r);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,un.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,cn?Object(cn.call(n)):{}}}var ln=$t&&$t.isMap,sn=ln?It(ln):function(t){return O(t)&&"[object Map]"==Ne(t)};var vn=$t&&$t.isSet,pn=vn?It(vn):function(t){return O(t)&&"[object Set]"==Ne(t)},dn="[object Arguments]",hn="[object Function]",bn="[object Object]",yn={};function jn(t,e,r,n,o,i){var u,a=1&e,c=2&e,f=4&e;if(r&&(u=o?r(t,n,o,i):r(t)),void 0!==u)return u;if(!k(t))return t;var l=s(t);if(l){if(u=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&on.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return fr(t,u)}else{var v=Ne(t),p=v==hn||"[object GeneratorFunction]"==v;if(zt(t))return ur(t,a);if(v==bn||v==dn||p&&!o){if(u=c||p?{}:dr(t),!a)return c?function(t,e){return Or(t,rn(t),e)}(t,function(t,e){return t&&Or(e,Sr(e),t)}(u,t)):function(t,e){return Or(t,ye(t),e)}(t,function(t,e){return t&&Or(e,Kt(e),t)}(u,t))}else{if(!yn[v])return o?t:{};u=fn(t,v,a)}}i||(i=new ee);var d=i.get(t);if(d)return d;i.set(t,u),pn(t)?t.forEach((function(n){u.add(jn(n,e,r,n,t,i))})):sn(t)&&t.forEach((function(n,o){u.set(o,jn(n,e,r,o,t,i))}));var h=l?void 0:(f?c?nn:je:c?Sr:Kt)(t);return yt(h||t,(function(n,o){h&&(n=t[o=n]),mr(u,o,jn(n,e,r,o,t,i))})),u}yn[dn]=yn["[object Array]"]=yn["[object ArrayBuffer]"]=yn["[object DataView]"]=yn["[object Boolean]"]=yn["[object Date]"]=yn["[object Float32Array]"]=yn["[object Float64Array]"]=yn["[object Int8Array]"]=yn["[object Int16Array]"]=yn["[object Int32Array]"]=yn["[object Map]"]=yn["[object Number]"]=yn[bn]=yn["[object RegExp]"]=yn["[object Set]"]=yn["[object String]"]=yn["[object Symbol]"]=yn["[object Uint8Array]"]=yn["[object Uint8ClampedArray]"]=yn["[object Uint16Array]"]=yn["[object Uint32Array]"]=!0,yn["[object Error]"]=yn[hn]=yn["[object WeakMap]"]=!1;function gn(t){return jn(t,5)}var _n=/\s/;var wn=/^\s+/;function mn(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&_n.test(t.charAt(e)););return e}(t)+1).replace(wn,""):t}var On=/^[-+]0x[0-9a-f]+$/i,An=/^0b[01]+$/i,xn=/^0o[0-7]+$/i,Sn=parseInt;function Pn(t){if("number"==typeof t)return t;if(A(t))return NaN;if(k(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=k(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=mn(t);var r=An.test(t);return r||xn.test(t)?Sn(t.slice(2),r?2:8):On.test(t)?NaN:+t}var kn=1/0;function zn(t){return t?(t=Pn(t))===kn||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function En(t){var e=zn(t),r=e%1;return e==e?r?e-r:e:0}function Fn(t){return"[object String]"===Object.prototype.toString.call(t)}function Dn(t){return!(!Fn(t)||""===t)}function Mn(t){return t!=t}function In(t){let e=!1;if(Dn(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(Mn(t))return!1;e=!0}return e}function Nn(t){if(!In(t))return 0;return zn(t)}function Un(t){return!!In(t)&&(t=Nn(t),"number"==typeof(e=t)&&e==En(e));var e}var Tn=d.isFinite,$n=Math.min;var Bn=function(t){var e=Math[t];return function(t,r){if(t=Pn(t),(r=null==r?0:$n(En(r),292))&&Tn(t)){var n=(vt(t)+"e").split("e");return+((n=(vt(e(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return e(t)}}("round"),Rn=Bn;function Ln(t){if(!In(t))return 0;t=Nn(t);let e=Rn(t);return"0"===String(e)?0:e}let qn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Cn=qn.length;function Vn(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32,e=[];var r;t=Un(r=t)&&Ln(r)>0?Ln(t):32;for(let r=0;r<t;r++)e[r]=qn[0|Math.random()*Cn];return e.join("")}function Wn(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+e];return i}function Gn(t){return"[object Array]"===Object.prototype.toString.call(t)}function Jn(t){return"[object Object]"===Object.prototype.toString.call(t)}function Qn(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}function Hn(t,e){let r=function(){let t,e,r=new Promise((function(){t=arguments[0],e=arguments[1]}));return r.resolve=t,r.reject=e,r}();if(!Gn(t)&&!Jn(t))return r.reject("rs is not an array or object"),r;let n=!1;if(Jn(t)){n=!0;let e=[];te(t,((t,r)=>{e.push({k:r,v:t})})),t=e}Qn(e)||(e=function(t){return t});let o=-1,i=[];return t.reduce((function(t,r){return t.then((function(t){i.push(t),o+=1;let u=o,a=r;return n&&(u=r.k,a=r.v),Qn(e)?e(a,u):a}))}),Promise.resolve()).then((function(t){var e,n,o,u;i.push(t),u=null==(e=i)?0:e.length,i=u?Wn(e,(n=o||void 0===n?1:En(n))<0?0:n,u):[],r.resolve(i)})).catch((function(t){r.reject(t)})),r}function Kn(t){if(Jn(t)){for(let e in t)return!0;return!1}return!1}function Xn(t){return!!function(t){return"[object Undefined]"===Object.prototype.toString.call(t)}(t)||(!!function(t){return"[object Null]"===Object.prototype.toString.call(t)}(t)||(!!function(t){if(Jn(t)){for(let e in t)return!1;return!0}return!1}(t)||(!!function(t){return!(!Fn(t)||""!==t)}(t)||(!!function(t){return!!Gn(t)&&0===t.length}(t)||!!Mn(t)))))}function Yn(t){return!!Gn(t)&&(0!==t.length&&(1!==t.length||!Xn(t[0])))}function Zn(t,e){return!!Jn(t)&&(!(!Dn(e)&&!In(e))&&e in t)}function to(t,e){return null==(t=function(t,e){return e.length<2?t:ht(t,Wn(e,0,-1))}(t,e=pt(e,t)))||delete t[dt((r=e,n=null==r?0:r.length,n?r[n-1]:void 0))];var r,n}var eo=Array.prototype.splice;function ro(t,e){if(t!==e){var r=void 0!==t,n=null===t,o=t==t,i=A(t),u=void 0!==e,a=null===e,c=e==e,f=A(e);if(!a&&!f&&!i&&t>e||i&&u&&c&&!a&&!f||n&&u&&c||!r&&c||!o)return 1;if(!n&&!i&&!f&&t<e||f&&r&&o&&!n&&!i||a&&r&&o||!u&&o||!c)return-1}return 0}var no=h?h.isConcatSpreadable:void 0;function oo(t){return s(t)||xt(t)||!!(no&&t&&t[no])}function io(t,e,r,n,o){var i=-1,u=t.length;for(r||(r=oo),o||(o=[]);++i<u;){var a=t[i];e>0&&r(a)?e>1?io(a,e-1,r,n,o):se(o,a):n||(o[o.length]=a)}return o}function uo(t){return(null==t?0:t.length)?io(t,1):[]}var ao=function(t){return Nr(Er(t,void 0,uo),t+"")}((function(t,e){var r=null==t?0:t.length,n=function(t,e){for(var r=-1,n=e.length,o=Array(n),i=null==t;++r<n;)o[r]=i?void 0:bt(t,e[r]);return o}(t,e);return function(t,e){for(var r=t?e.length:0,n=r-1;r--;){var o=e[r];if(r==n||o!==i){var i=o;Ft(o)?eo.call(t,o,1):to(t,o)}}}(t,ct(e,(function(t){return Ft(t,r)?+t:t})).sort(ro)),n})),co=ao;function fo(t,e){if(!Yn(t))return[];var r;if(Un(r=e)&&Ln(r)>=0&&(e=[e]),!Yn(e))return t;e=Xe(e,(t=>Ln(t)));let n=gn(t);return co(n,e),n}return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=bt(e,"url");Dn(r)||(r="./db.json");let n=bt(e,"db");Dn(n)||(n="worm");let o=bt(e,"cl");Dn(o)||(o="test");let a=`${n}:${o}`,c=new l(r),f=new u(c,{});Zn(f.data,a)||(f.data[a]=[]);let s=new t.EventEmitter;async function v(t){let e=!1;if(!Kn(t)&&!Yn(t))return Promise.reject("data is not an effective object or array");t=gn(t);let r=null;try{Gn(t)||(t=[t]),t=Xe(t,(function(t){return Dn(t.id)||(t.id=Vn()),t})),await f.read();let e={};te(f.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let n=tn(t),o=0,i=!1;te(t,(t=>{Zn(e,t.id)||(f.data[a].push(t),o++,i=!0)})),i&&await f.write(),r={n:n,nInserted:o,ok:1},s.emit("change","insert",t,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r}return s.select=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=null;try{if(await f.read(),Kn(t)){r=new i.Query(t).find(f.data[a]).all()}else r=f.data[a]}catch(t){e=!0,r=t}return e?Promise.reject(r):r},s.insert=v,s.save=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!1;if(!Kn(t)&&!Yn(t))return Promise.reject("data is not an effective object or array");t=gn(t);let n=bt(e,"autoInsert",!0),o=null;try{Gn(t)||(t=[t]),t=Xe(t,(function(t){return Dn(t.id)||(t.id=Vn()),t})),await f.read();let e={};te(f.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let r=!1;o=await Hn(t,(async t=>{let o=null,i=bt(t,"id",""),u=bt(e,i,null);var c,l;return Kn(u)&&(c=t,l=u.v,Le(c,l)||(f.data[a][u.k]=$r(f.data[a][u.k],t),o={update:!0},r=!0)),o=Kn(o)?{n:1,nModified:1,ok:1}:{n:0,nModified:0,ok:1},n&&0===o.n&&(o=await v(t)),o})),r&&await f.write(),s.emit("change","save",t,o)}catch(t){r=!0,o=t}return r?Promise.reject(o):o},s.del=async function(t){let e=!1;if(!Kn(t)&&!Yn(t))return Promise.reject("data is not an effective object or array");t=gn(t);let r=null;try{Gn(t)||(t=[t]),await f.read();let e={};te(f.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let n=[],o=!1;r=await Hn(t,(async t=>{let r=null,i=bt(t,"id","");if(Dn(i)){let t=bt(e,i,null);Kn(t)?(n.push(t.k),o=!0,r={n:1,nDeleted:1,ok:1}):r={n:1,nDeleted:0,ok:1}}else r={n:1,nDeleted:0,ok:0};return r})),o&&(f.data[a]=fo(f.data[a],n)),o&&await f.write(),s.emit("change","del",t,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r},s.delAll=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=null;try{await f.read();let e=tn(f.data[a]),n=0,o=!1;if(Kn(t)){let r=new i.Query(t).find(f.data[a]).all();if(n=tn(r),0===n);else if(e===n)f.data[a]=[],o=!0;else{let t={};te(r,((e,r)=>{t[e.id]={k:r,v:e}}));let e=[];te(f.data[a],((r,n)=>{Zn(t,r.id)||e.push(r)})),f.data[a]=e,o=!0}}else n=e,f.data[a]=[],o=!0;o&&await f.write(),r={n:e,nDeleted:n,ok:1},s.emit("change","delAll",null,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r},s}}));
6
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("events"),require("lowdb"),require("node:fs"),require("node:fs/promises"),require("node:path"),require("node:url"),require("mingo")):"function"==typeof define&&define.amd?define(["events","lowdb","node:fs","node:fs/promises","node:path","node:url","mingo"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["w-orm-lowdb"]=e(t.events,t.lowdb,null,t.promises,t.path,t.node_url,t.mingo)}(this,(function(t,e,r,n,o,i,u){"use strict";class a{#t;#e;#r=!1;#n=null;#o=null;#i=null;#u=null;#a(t){return this.#u=t,this.#i||=new Promise(((t,e)=>{this.#o=[t,e]})),new Promise(((t,e)=>{var r;null===(r=this.#i)||void 0===r||r.then(t).catch(e)}))}async#c(t){this.#r=!0;try{var e;await n.writeFile(this.#e,t,"utf-8"),await async function(t,e,r){for(let n=0;n<e;n++)try{return await t()}catch(t){if(!(n<e-1))throw t;await new Promise((t=>setTimeout(t,r)))}}((async()=>{await n.rename(this.#e,this.#t)}),10,100),null===(e=this.#n)||void 0===e||e[0]()}catch(t){var r;if(t instanceof Error)null===(r=this.#n)||void 0===r||r[1](t);throw t}finally{if(this.#r=!1,this.#n=this.#o,this.#o=this.#i=null,null!==this.#u){const t=this.#u;this.#u=null,await this.write(t)}}}constructor(t){this.#t=t,this.#e=function(t){const e=t instanceof URL?i.fileURLToPath(t):t.toString();return o.join(o.dirname(e),`.${o.basename(e)}.tmp`)}(t)}async write(t){return this.#r?this.#a(t):this.#c(t)}}class c{#t;#l;constructor(t){this.#t=t,this.#l=new a(t)}async read(){let t;try{t=await n.readFile(this.#t,"utf-8")}catch(t){if("ENOENT"===t.code)return null;throw t}return t}write(t){return this.#l.write(t)}}class l{#f;#s;#h;constructor(t,e){let{parse:r,stringify:n}=e;this.#f=new c(t),this.#s=r,this.#h=n}async read(){const t=await this.#f.read();return null===t?null:this.#s(t)}write(t){return this.#f.write(this.#h(t))}}class f extends l{constructor(t){super(t,{parse:JSON.parse,stringify:t=>JSON.stringify(t,null,2)})}}const s=new Error("request for lock canceled");var h=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}c((n=n.apply(t,e||[])).next())}))};class v{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s;this._value=t,this._cancelError=e,this._queue=[],this._weightedWaiters=[]}acquire(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return new Promise(((r,n)=>{const o={resolve:r,reject:n,weight:t,priority:e},i=d(this._queue,(t=>e<=t.priority));-1===i&&t<=this._value?this._dispatchItem(o):this._queue.splice(i+1,0,o)}))}runExclusive(t){return h(this,arguments,void 0,(function(t){var e=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return function*(){const[o,i]=yield e.acquire(r,n);try{return yield t(o)}finally{i()}}()}))}waitForUnlock(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return this._couldLockImmediately(t,e)?Promise.resolve():new Promise((r=>{this._weightedWaiters[t-1]||(this._weightedWaiters[t-1]=[]),function(t,e){const r=d(t,(t=>e.priority<=t.priority));t.splice(r+1,0,e)}(this._weightedWaiters[t-1],{resolve:r,priority:e})}))}isLocked(){return this._value<=0}getValue(){return this._value}setValue(t){this._value=t,this._dispatchQueue()}release(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);this._value+=t,this._dispatchQueue()}cancel(){this._queue.forEach((t=>t.reject(this._cancelError))),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(t){const e=this._value;this._value-=t.weight,t.resolve([e,this._newReleaser(t.weight)])}_newReleaser(t){let e=!1;return()=>{e||(e=!0,this.release(t))}}_drainUnlockWaiters(){if(0===this._queue.length)for(let t=this._value;t>0;t--){const e=this._weightedWaiters[t-1];e&&(e.forEach((t=>t.resolve())),this._weightedWaiters[t-1]=[])}else{const t=this._queue[0].priority;for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];if(!r)continue;const n=r.findIndex((e=>e.priority<=t));(-1===n?r:r.splice(0,n)).forEach((t=>t.resolve()))}}}_couldLockImmediately(t,e){return(0===this._queue.length||this._queue[0].priority<e)&&t<=this._value}}function d(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var p=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}c((n=n.apply(t,e||[])).next())}))};class y{constructor(t){this._semaphore=new v(1,t)}acquire(){return p(this,arguments,void 0,(function(){var t=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){const[,r]=yield t._semaphore.acquire(1,e);return r}()}))}runExclusive(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this._semaphore.runExclusive((()=>t()),1,e)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._semaphore.waitForUnlock(1,t)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}var b=Array.isArray,j="object"==typeof global&&global&&global.Object===Object&&global,g="object"==typeof self&&self&&self.Object===Object&&self,_=j||g||Function("return this")(),w=_.Symbol,m=Object.prototype,O=m.hasOwnProperty,x=m.toString,A=w?w.toStringTag:void 0;var k=Object.prototype.toString;var P=w?w.toStringTag:void 0;function S(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":P&&P in Object(t)?function(t){var e=O.call(t,A),r=t[A];try{t[A]=void 0;var n=!0}catch(t){}var o=x.call(t);return n&&(e?t[A]=r:delete t[A]),o}(t):function(t){return k.call(t)}(t)}function E(t){return null!=t&&"object"==typeof t}function F(t){return"symbol"==typeof t||E(t)&&"[object Symbol]"==S(t)}var q=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,z=/^\w*$/;function I(t,e){if(b(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!F(t))||(z.test(t)||!q.test(t)||null!=e&&t in Object(e))}function U(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function D(t){if(!U(t))return!1;var e=S(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var M,$=_["__core-js_shared__"],N=(M=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||""))?"Symbol(src)_1."+M:"";var L=Function.prototype.toString;function T(t){if(null!=t){try{return L.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var W=/^\[object .+?Constructor\]$/,B=Function.prototype,R=Object.prototype,C=B.toString,V=R.hasOwnProperty,Q=RegExp("^"+C.call(V).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function G(t){return!(!U(t)||(e=t,N&&N in e))&&(D(t)?Q:W).test(T(t));var e}function J(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return G(r)?r:void 0}var H=J(Object,"create");var K=Object.prototype.hasOwnProperty;var X=Object.prototype.hasOwnProperty;function Y(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Z(t,e){return t===e||t!=t&&e!=e}function tt(t,e){for(var r=t.length;r--;)if(Z(t[r][0],e))return r;return-1}Y.prototype.clear=function(){this.__data__=H?H(null):{},this.size=0},Y.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Y.prototype.get=function(t){var e=this.__data__;if(H){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return K.call(e,t)?e[t]:void 0},Y.prototype.has=function(t){var e=this.__data__;return H?void 0!==e[t]:X.call(e,t)},Y.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=H&&void 0===e?"__lodash_hash_undefined__":e,this};var et=Array.prototype.splice;function rt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}rt.prototype.clear=function(){this.__data__=[],this.size=0},rt.prototype.delete=function(t){var e=this.__data__,r=tt(e,t);return!(r<0)&&(r==e.length-1?e.pop():et.call(e,r,1),--this.size,!0)},rt.prototype.get=function(t){var e=this.__data__,r=tt(e,t);return r<0?void 0:e[r][1]},rt.prototype.has=function(t){return tt(this.__data__,t)>-1},rt.prototype.set=function(t,e){var r=this.__data__,n=tt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var nt=J(_,"Map");function ot(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function it(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}it.prototype.clear=function(){this.size=0,this.__data__={hash:new Y,map:new(nt||rt),string:new Y}},it.prototype.delete=function(t){var e=ot(this,t).delete(t);return this.size-=e?1:0,e},it.prototype.get=function(t){return ot(this,t).get(t)},it.prototype.has=function(t){return ot(this,t).has(t)},it.prototype.set=function(t,e){var r=ot(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function ut(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return r.cache=i.set(o,u)||i,u};return r.cache=new(ut.Cache||it),r}ut.Cache=it;var at,ct,lt,ft=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,st=/\\(\\)?/g,ht=(at=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(ft,(function(t,r,n,o){e.push(n?o.replace(st,"$1"):r||t)})),e},ct=ut(at,(function(t){return 500===lt.size&&lt.clear(),t})),lt=ct.cache,ct),vt=ht;function dt(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var pt=w?w.prototype:void 0,yt=pt?pt.toString:void 0;function bt(t){if("string"==typeof t)return t;if(b(t))return dt(t,bt)+"";if(F(t))return yt?yt.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function jt(t){return null==t?"":bt(t)}function gt(t,e){return b(t)?t:I(t,e)?[t]:vt(jt(t))}function _t(t){if("string"==typeof t||F(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function wt(t,e){for(var r=0,n=(e=gt(e,t)).length;null!=t&&r<n;)t=t[_t(e[r++])];return r&&r==n?t:void 0}function mt(t,e,r){var n=null==t?void 0:wt(t,e);return void 0===n?r:n}function Ot(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}var xt,At=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),u=i.length;u--;){var a=i[xt?u:++n];if(!1===e(o[a],a,o))break}return t};function kt(t){return E(t)&&"[object Arguments]"==S(t)}var Pt=Object.prototype,St=Pt.hasOwnProperty,Et=Pt.propertyIsEnumerable,Ft=kt(function(){return arguments}())?kt:function(t){return E(t)&&St.call(t,"callee")&&!Et.call(t,"callee")},qt=Ft;var zt="object"==typeof exports&&exports&&!exports.nodeType&&exports,It=zt&&"object"==typeof module&&module&&!module.nodeType&&module,Ut=It&&It.exports===zt?_.Buffer:void 0,Dt=(Ut?Ut.isBuffer:void 0)||function(){return!1},Mt=/^(?:0|[1-9]\d*)$/;function $t(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Mt.test(t))&&t>-1&&t%1==0&&t<e}function Nt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Lt={};function Tt(t){return function(e){return t(e)}}Lt["[object Float32Array]"]=Lt["[object Float64Array]"]=Lt["[object Int8Array]"]=Lt["[object Int16Array]"]=Lt["[object Int32Array]"]=Lt["[object Uint8Array]"]=Lt["[object Uint8ClampedArray]"]=Lt["[object Uint16Array]"]=Lt["[object Uint32Array]"]=!0,Lt["[object Arguments]"]=Lt["[object Array]"]=Lt["[object ArrayBuffer]"]=Lt["[object Boolean]"]=Lt["[object DataView]"]=Lt["[object Date]"]=Lt["[object Error]"]=Lt["[object Function]"]=Lt["[object Map]"]=Lt["[object Number]"]=Lt["[object Object]"]=Lt["[object RegExp]"]=Lt["[object Set]"]=Lt["[object String]"]=Lt["[object WeakMap]"]=!1;var Wt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bt=Wt&&"object"==typeof module&&module&&!module.nodeType&&module,Rt=Bt&&Bt.exports===Wt&&j.process,Ct=function(){try{var t=Bt&&Bt.require&&Bt.require("util").types;return t||Rt&&Rt.binding&&Rt.binding("util")}catch(t){}}(),Vt=Ct&&Ct.isTypedArray,Qt=Vt?Tt(Vt):function(t){return E(t)&&Nt(t.length)&&!!Lt[S(t)]},Gt=Object.prototype.hasOwnProperty;function Jt(t,e){var r=b(t),n=!r&&qt(t),o=!r&&!n&&Dt(t),i=!r&&!n&&!o&&Qt(t),u=r||n||o||i,a=u?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var l in t)!e&&!Gt.call(t,l)||u&&("length"==l||o&&("offset"==l||"parent"==l)||i&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||$t(l,c))||a.push(l);return a}var Ht=Object.prototype;function Kt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ht)}function Xt(t,e){return function(r){return t(e(r))}}var Yt=Xt(Object.keys,Object),Zt=Object.prototype.hasOwnProperty;function te(t){if(!Kt(t))return Yt(t);var e=[];for(var r in Object(t))Zt.call(t,r)&&"constructor"!=r&&e.push(r);return e}function ee(t){return null!=t&&Nt(t.length)&&!D(t)}function re(t){return ee(t)?Jt(t):te(t)}var ne=function(t,e){return function(r,n){if(null==r)return r;if(!ee(r))return t(r,n);for(var o=r.length,i=e?o:-1,u=Object(r);(e?i--:++i<o)&&!1!==n(u[i],i,u););return r}}((function(t,e){return t&&At(t,e,re)})),oe=ne;function ie(t){return t}function ue(t,e){var r;return(b(t)?Ot:oe)(t,"function"==typeof(r=e)?r:ie)}function ae(t){var e=this.__data__=new rt(t);this.size=e.size}ae.prototype.clear=function(){this.__data__=new rt,this.size=0},ae.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},ae.prototype.get=function(t){return this.__data__.get(t)},ae.prototype.has=function(t){return this.__data__.has(t)},ae.prototype.set=function(t,e){var r=this.__data__;if(r instanceof rt){var n=r.__data__;if(!nt||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new it(n)}return r.set(t,e),this.size=r.size,this};function ce(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new it;++e<r;)this.add(t[e])}function le(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function fe(t,e){return t.has(e)}ce.prototype.add=ce.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},ce.prototype.has=function(t){return this.__data__.has(t)};function se(t,e,r,n,o,i){var u=1&r,a=t.length,c=e.length;if(a!=c&&!(u&&c>a))return!1;var l=i.get(t),f=i.get(e);if(l&&f)return l==e&&f==t;var s=-1,h=!0,v=2&r?new ce:void 0;for(i.set(t,e),i.set(e,t);++s<a;){var d=t[s],p=e[s];if(n)var y=u?n(p,d,s,e,t,i):n(d,p,s,t,e,i);if(void 0!==y){if(y)continue;h=!1;break}if(v){if(!le(e,(function(t,e){if(!fe(v,e)&&(d===t||o(d,t,r,n,i)))return v.push(e)}))){h=!1;break}}else if(d!==p&&!o(d,p,r,n,i)){h=!1;break}}return i.delete(t),i.delete(e),h}var he=_.Uint8Array;function ve(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function de(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var pe=w?w.prototype:void 0,ye=pe?pe.valueOf:void 0;function be(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function je(t,e,r){var n=e(t);return b(t)?n:be(n,r(t))}function ge(){return[]}var _e=Object.prototype.propertyIsEnumerable,we=Object.getOwnPropertySymbols,me=we?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var u=t[r];e(u,r,t)&&(i[o++]=u)}return i}(we(t),(function(e){return _e.call(t,e)})))}:ge,Oe=me;function xe(t){return je(t,re,Oe)}var Ae=Object.prototype.hasOwnProperty;var ke=J(_,"DataView"),Pe=J(_,"Promise"),Se=J(_,"Set"),Ee=J(_,"WeakMap"),Fe="[object Map]",qe="[object Promise]",ze="[object Set]",Ie="[object WeakMap]",Ue="[object DataView]",De=T(ke),Me=T(nt),$e=T(Pe),Ne=T(Se),Le=T(Ee),Te=S;(ke&&Te(new ke(new ArrayBuffer(1)))!=Ue||nt&&Te(new nt)!=Fe||Pe&&Te(Pe.resolve())!=qe||Se&&Te(new Se)!=ze||Ee&&Te(new Ee)!=Ie)&&(Te=function(t){var e=S(t),r="[object Object]"==e?t.constructor:void 0,n=r?T(r):"";if(n)switch(n){case De:return Ue;case Me:return Fe;case $e:return qe;case Ne:return ze;case Le:return Ie}return e});var We=Te,Be="[object Arguments]",Re="[object Array]",Ce="[object Object]",Ve=Object.prototype.hasOwnProperty;function Qe(t,e,r,n,o,i){var u=b(t),a=b(e),c=u?Re:We(t),l=a?Re:We(e),f=(c=c==Be?Ce:c)==Ce,s=(l=l==Be?Ce:l)==Ce,h=c==l;if(h&&Dt(t)){if(!Dt(e))return!1;u=!0,f=!1}if(h&&!f)return i||(i=new ae),u||Qt(t)?se(t,e,r,n,o,i):function(t,e,r,n,o,i,u){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!i(new he(t),new he(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Z(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=ve;case"[object Set]":var c=1&n;if(a||(a=de),t.size!=e.size&&!c)return!1;var l=u.get(t);if(l)return l==e;n|=2,u.set(t,e);var f=se(a(t),a(e),n,o,i,u);return u.delete(t),f;case"[object Symbol]":if(ye)return ye.call(t)==ye.call(e)}return!1}(t,e,c,r,n,o,i);if(!(1&r)){var v=f&&Ve.call(t,"__wrapped__"),d=s&&Ve.call(e,"__wrapped__");if(v||d){var p=v?t.value():t,y=d?e.value():e;return i||(i=new ae),o(p,y,r,n,i)}}return!!h&&(i||(i=new ae),function(t,e,r,n,o,i){var u=1&r,a=xe(t),c=a.length;if(c!=xe(e).length&&!u)return!1;for(var l=c;l--;){var f=a[l];if(!(u?f in e:Ae.call(e,f)))return!1}var s=i.get(t),h=i.get(e);if(s&&h)return s==e&&h==t;var v=!0;i.set(t,e),i.set(e,t);for(var d=u;++l<c;){var p=t[f=a[l]],y=e[f];if(n)var b=u?n(y,p,f,e,t,i):n(p,y,f,t,e,i);if(!(void 0===b?p===y||o(p,y,r,n,i):b)){v=!1;break}d||(d="constructor"==f)}if(v&&!d){var j=t.constructor,g=e.constructor;j==g||!("constructor"in t)||!("constructor"in e)||"function"==typeof j&&j instanceof j&&"function"==typeof g&&g instanceof g||(v=!1)}return i.delete(t),i.delete(e),v}(t,e,r,n,o,i))}function Ge(t,e,r,n,o){return t===e||(null==t||null==e||!E(t)&&!E(e)?t!=t&&e!=e:Qe(t,e,r,n,Ge,o))}function Je(t){return t==t&&!U(t)}function He(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function Ke(t){var e=function(t){for(var e=re(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,Je(o)]}return e}(t);return 1==e.length&&e[0][2]?He(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var o=r.length,i=o,u=!n;if(null==t)return!i;for(t=Object(t);o--;){var a=r[o];if(u&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++o<i;){var c=(a=r[o])[0],l=t[c],f=a[1];if(u&&a[2]){if(void 0===l&&!(c in t))return!1}else{var s=new ae;if(n)var h=n(l,f,c,t,e,s);if(!(void 0===h?Ge(f,l,3,n,s):h))return!1}}return!0}(r,t,e)}}function Xe(t,e){return null!=t&&e in Object(t)}function Ye(t,e){return null!=t&&function(t,e,r){for(var n=-1,o=(e=gt(e,t)).length,i=!1;++n<o;){var u=_t(e[n]);if(!(i=null!=t&&r(t,u)))break;t=t[u]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&Nt(o)&&$t(u,o)&&(b(t)||qt(t))}(t,e,Xe)}function Ze(t){return function(e){return null==e?void 0:e[t]}}function tr(t){return I(t)?Ze(_t(t)):function(t){return function(e){return wt(e,t)}}(t)}function er(t){return"function"==typeof t?t:null==t?ie:"object"==typeof t?b(t)?function(t,e){return I(t)&&Je(e)?He(_t(t),e):function(r){var n=mt(r,t);return void 0===n&&n===e?Ye(r,t):Ge(e,n,3)}}(t[0],t[1]):Ke(t):tr(t)}function rr(t,e){var r=-1,n=ee(t)?Array(t.length):[];return oe(t,(function(t,o,i){n[++r]=e(t,o,i)})),n}function nr(t,e){return(b(t)?dt:rr)(t,er(e))}var or=function(){try{var t=J(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),ir=or;function ur(t,e,r){"__proto__"==e&&ir?ir(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function ar(t,e,r){(void 0!==r&&!Z(t[e],r)||void 0===r&&!(e in t))&&ur(t,e,r)}var cr="object"==typeof exports&&exports&&!exports.nodeType&&exports,lr=cr&&"object"==typeof module&&module&&!module.nodeType&&module,fr=lr&&lr.exports===cr?_.Buffer:void 0,sr=fr?fr.allocUnsafe:void 0;function hr(t,e){if(e)return t.slice();var r=t.length,n=sr?sr(r):new t.constructor(r);return t.copy(n),n}function vr(t){var e=new t.constructor(t.byteLength);return new he(e).set(new he(t)),e}function dr(t,e){var r=e?vr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function pr(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var yr=Object.create,br=function(){function t(){}return function(e){if(!U(e))return{};if(yr)return yr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),jr=br,gr=Xt(Object.getPrototypeOf,Object);function _r(t){return"function"!=typeof t.constructor||Kt(t)?{}:jr(gr(t))}var wr=Function.prototype,mr=Object.prototype,Or=wr.toString,xr=mr.hasOwnProperty,Ar=Or.call(Object);function kr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Pr=Object.prototype.hasOwnProperty;function Sr(t,e,r){var n=t[e];Pr.call(t,e)&&Z(n,r)&&(void 0!==r||e in t)||ur(t,e,r)}function Er(t,e,r,n){var o=!r;r||(r={});for(var i=-1,u=e.length;++i<u;){var a=e[i],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),o?ur(r,a,c):Sr(r,a,c)}return r}var Fr=Object.prototype.hasOwnProperty;function qr(t){if(!U(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Kt(t),r=[];for(var n in t)("constructor"!=n||!e&&Fr.call(t,n))&&r.push(n);return r}function zr(t){return ee(t)?Jt(t,!0):qr(t)}function Ir(t,e,r,n,o,i,u){var a=kr(t,r),c=kr(e,r),l=u.get(c);if(l)ar(t,r,l);else{var f,s=i?i(a,c,r+"",t,e,u):void 0,h=void 0===s;if(h){var v=b(c),d=!v&&Dt(c),p=!v&&!d&&Qt(c);s=c,v||d||p?b(a)?s=a:E(f=a)&&ee(f)?s=pr(a):d?(h=!1,s=hr(c,!0)):p?(h=!1,s=dr(c,!0)):s=[]:function(t){if(!E(t)||"[object Object]"!=S(t))return!1;var e=gr(t);if(null===e)return!0;var r=xr.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Or.call(r)==Ar}(c)||qt(c)?(s=a,qt(a)?s=function(t){return Er(t,zr(t))}(a):U(a)&&!D(a)||(s=_r(c))):h=!1}h&&(u.set(c,s),o(s,c,n,i,u),u.delete(c)),ar(t,r,s)}}function Ur(t,e,r,n,o){t!==e&&At(e,(function(i,u){if(o||(o=new ae),U(i))Ir(t,e,u,r,Ur,n,o);else{var a=n?n(kr(t,u),i,u+"",t,e,o):void 0;void 0===a&&(a=i),ar(t,u,a)}}),zr)}var Dr=Math.max;function Mr(t,e,r){return e=Dr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Dr(n.length-e,0),u=Array(i);++o<i;)u[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(u),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,a)}}var $r=ir?function(t,e){return ir(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:ie,Nr=$r,Lr=Date.now;var Tr=function(t){var e=0,r=0;return function(){var n=Lr(),o=16-(n-r);if(r=n,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Nr),Wr=Tr;var Br,Rr=(Br=function(t,e,r){Ur(t,e,r)},function(t,e){return Wr(Mr(t,e,ie),t+"")}((function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Br.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!U(r))return!1;var n=typeof e;return!!("number"==n?ee(r)&&$t(e,r.length):"string"==n&&e in r)&&Z(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var u=e[r];u&&Br(t,u,r,o)}return t}))),Cr=Rr;var Vr=Ze("length"),Qr=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Gr="\\ud800-\\udfff",Jr="["+Gr+"]",Hr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Kr="\\ud83c[\\udffb-\\udfff]",Xr="[^"+Gr+"]",Yr="(?:\\ud83c[\\udde6-\\uddff]){2}",Zr="[\\ud800-\\udbff][\\udc00-\\udfff]",tn="(?:"+Hr+"|"+Kr+")"+"?",en="[\\ufe0e\\ufe0f]?",rn=en+tn+("(?:\\u200d(?:"+[Xr,Yr,Zr].join("|")+")"+en+tn+")*"),nn="(?:"+[Xr+Hr+"?",Hr,Yr,Zr,Jr].join("|")+")",on=RegExp(Kr+"(?="+Kr+")|"+nn+rn,"g");function un(t){return function(t){return Qr.test(t)}(t)?function(t){for(var e=on.lastIndex=0;on.test(t);)++e;return e}(t):Vr(t)}function an(t){if(null==t)return 0;if(ee(t))return"string"==typeof(e=t)||!b(e)&&E(e)&&"[object String]"==S(e)?un(t):t.length;var e,r=We(t);return"[object Map]"==r||"[object Set]"==r?t.size:te(t).length}var cn=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)be(e,Oe(t)),t=gr(t);return e}:ge,ln=cn;function fn(t){return je(t,zr,ln)}var sn=Object.prototype.hasOwnProperty;var hn=/\w*$/;var vn=w?w.prototype:void 0,dn=vn?vn.valueOf:void 0;function pn(t,e,r){var n,o=t.constructor;switch(e){case"[object ArrayBuffer]":return vr(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var r=e?vr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return dr(t,r);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,hn.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,dn?Object(dn.call(n)):{}}}var yn=Ct&&Ct.isMap,bn=yn?Tt(yn):function(t){return E(t)&&"[object Map]"==We(t)};var jn=Ct&&Ct.isSet,gn=jn?Tt(jn):function(t){return E(t)&&"[object Set]"==We(t)},_n="[object Arguments]",wn="[object Function]",mn="[object Object]",On={};function xn(t,e,r,n,o,i){var u,a=1&e,c=2&e,l=4&e;if(r&&(u=o?r(t,n,o,i):r(t)),void 0!==u)return u;if(!U(t))return t;var f=b(t);if(f){if(u=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&sn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return pr(t,u)}else{var s=We(t),h=s==wn||"[object GeneratorFunction]"==s;if(Dt(t))return hr(t,a);if(s==mn||s==_n||h&&!o){if(u=c||h?{}:_r(t),!a)return c?function(t,e){return Er(t,ln(t),e)}(t,function(t,e){return t&&Er(e,zr(e),t)}(u,t)):function(t,e){return Er(t,Oe(t),e)}(t,function(t,e){return t&&Er(e,re(e),t)}(u,t))}else{if(!On[s])return o?t:{};u=pn(t,s,a)}}i||(i=new ae);var v=i.get(t);if(v)return v;i.set(t,u),gn(t)?t.forEach((function(n){u.add(xn(n,e,r,n,t,i))})):bn(t)&&t.forEach((function(n,o){u.set(o,xn(n,e,r,o,t,i))}));var d=f?void 0:(l?c?fn:xe:c?zr:re)(t);return Ot(d||t,(function(n,o){d&&(n=t[o=n]),Sr(u,o,xn(n,e,r,o,t,i))})),u}On[_n]=On["[object Array]"]=On["[object ArrayBuffer]"]=On["[object DataView]"]=On["[object Boolean]"]=On["[object Date]"]=On["[object Float32Array]"]=On["[object Float64Array]"]=On["[object Int8Array]"]=On["[object Int16Array]"]=On["[object Int32Array]"]=On["[object Map]"]=On["[object Number]"]=On[mn]=On["[object RegExp]"]=On["[object Set]"]=On["[object String]"]=On["[object Symbol]"]=On["[object Uint8Array]"]=On["[object Uint8ClampedArray]"]=On["[object Uint16Array]"]=On["[object Uint32Array]"]=!0,On["[object Error]"]=On[wn]=On["[object WeakMap]"]=!1;function An(t){return xn(t,5)}var kn=/\s/;var Pn=/^\s+/;function Sn(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&kn.test(t.charAt(e)););return e}(t)+1).replace(Pn,""):t}var En=/^[-+]0x[0-9a-f]+$/i,Fn=/^0b[01]+$/i,qn=/^0o[0-7]+$/i,zn=parseInt;function In(t){if("number"==typeof t)return t;if(F(t))return NaN;if(U(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=U(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Sn(t);var r=Fn.test(t);return r||qn.test(t)?zn(t.slice(2),r?2:8):En.test(t)?NaN:+t}var Un=1/0;function Dn(t){return t?(t=In(t))===Un||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function Mn(t){var e=Dn(t),r=e%1;return e==e?r?e-r:e:0}function $n(t){return"[object String]"===Object.prototype.toString.call(t)}function Nn(t){return!(!$n(t)||""===t)}function Ln(t){return t!=t}function Tn(t){let e=!1;if(Nn(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(Ln(t))return!1;e=!0}return e}function Wn(t){if(!Tn(t))return 0;return Dn(t)}function Bn(t){return!!Tn(t)&&(t=Wn(t),"number"==typeof(e=t)&&e==Mn(e));var e}var Rn=_.isFinite,Cn=Math.min;var Vn=function(t){var e=Math[t];return function(t,r){if(t=In(t),(r=null==r?0:Cn(Mn(r),292))&&Rn(t)){var n=(jt(t)+"e").split("e");return+((n=(jt(e(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return e(t)}}("round"),Qn=Vn;function Gn(t){if(!Tn(t))return 0;t=Wn(t);let e=Qn(t);return"0"===String(e)?0:e}let Jn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Hn=Jn.length;function Kn(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32,e=[];var r;t=Bn(r=t)&&Gn(r)>0?Gn(t):32;for(let r=0;r<t;r++)e[r]=Jn[0|Math.random()*Hn];return e.join("")}function Xn(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+e];return i}function Yn(t){return"[object Array]"===Object.prototype.toString.call(t)}function Zn(t){return"[object Object]"===Object.prototype.toString.call(t)}function to(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}function eo(t,e){let r=function(){let t,e,r=new Promise((function(){t=arguments[0],e=arguments[1]}));return r.resolve=t,r.reject=e,r}();if(!Yn(t)&&!Zn(t))return r.reject("rs is not an array or object"),r;let n=!1;if(Zn(t)){n=!0;let e=[];ue(t,((t,r)=>{e.push({k:r,v:t})})),t=e}to(e)||(e=function(t){return t});let o=-1,i=[];return t.reduce((function(t,r){return t.then((function(t){i.push(t),o+=1;let u=o,a=r;return n&&(u=r.k,a=r.v),to(e)?e(a,u):a}))}),Promise.resolve()).then((function(t){var e,n,o,u;i.push(t),u=null==(e=i)?0:e.length,i=u?Xn(e,(n=o||void 0===n?1:Mn(n))<0?0:n,u):[],r.resolve(i)})).catch((function(t){r.reject(t)})),r}function ro(t){if(Zn(t)){for(let e in t)return!0;return!1}return!1}function no(t){return!!function(t){return"[object Undefined]"===Object.prototype.toString.call(t)}(t)||(!!function(t){return"[object Null]"===Object.prototype.toString.call(t)}(t)||(!!function(t){if(Zn(t)){for(let e in t)return!1;return!0}return!1}(t)||(!!function(t){return!(!$n(t)||""!==t)}(t)||(!!function(t){return!!Yn(t)&&0===t.length}(t)||!!Ln(t)))))}function oo(t){return!!Yn(t)&&(0!==t.length&&(1!==t.length||!no(t[0])))}function io(t,e){return!!Zn(t)&&(!(!Nn(e)&&!Tn(e))&&e in t)}function uo(t,e){return null==(t=function(t,e){return e.length<2?t:wt(t,Xn(e,0,-1))}(t,e=gt(e,t)))||delete t[_t((r=e,n=null==r?0:r.length,n?r[n-1]:void 0))];var r,n}var ao=Array.prototype.splice;function co(t,e){if(t!==e){var r=void 0!==t,n=null===t,o=t==t,i=F(t),u=void 0!==e,a=null===e,c=e==e,l=F(e);if(!a&&!l&&!i&&t>e||i&&u&&c&&!a&&!l||n&&u&&c||!r&&c||!o)return 1;if(!n&&!i&&!l&&t<e||l&&r&&o&&!n&&!i||a&&r&&o||!u&&o||!c)return-1}return 0}var lo=w?w.isConcatSpreadable:void 0;function fo(t){return b(t)||qt(t)||!!(lo&&t&&t[lo])}function so(t,e,r,n,o){var i=-1,u=t.length;for(r||(r=fo),o||(o=[]);++i<u;){var a=t[i];e>0&&r(a)?e>1?so(a,e-1,r,n,o):be(o,a):n||(o[o.length]=a)}return o}function ho(t){return(null==t?0:t.length)?so(t,1):[]}var vo=function(t){return Wr(Mr(t,void 0,ho),t+"")}((function(t,e){var r=null==t?0:t.length,n=function(t,e){for(var r=-1,n=e.length,o=Array(n),i=null==t;++r<n;)o[r]=i?void 0:mt(t,e[r]);return o}(t,e);return function(t,e){for(var r=t?e.length:0,n=r-1;r--;){var o=e[r];if(r==n||o!==i){var i=o;$t(o)?ao.call(t,o,1):uo(t,o)}}}(t,dt(e,(function(t){return $t(t,r)?+t:t})).sort(co)),n})),po=vo;function yo(t,e){if(!oo(t))return[];var r;if(Bn(r=e)&&Gn(r)>=0&&(e=[e]),!oo(e))return t;e=nr(e,(t=>Gn(t)));let n=An(t);return po(n,e),n}return function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=mt(r,"url");Nn(n)||(n="./db.json");let o=mt(r,"db");Nn(o)||(o="worm");let i=mt(r,"cl");Nn(i)||(i="test");let a=`${o}:${i}`,c=new f(n),l=new e.Low(c,{}),s=new y,h=new t.EventEmitter;async function v(t){return await s.runExclusive((async()=>{let e=!1;if(!ro(t)&&!oo(t))return Promise.reject("data is not an effective object or array");t=An(t);let r=null;try{Yn(t)||(t=[t]),t=nr(t,(function(t){return Nn(t.id)||(t.id=Kn()),t})),await l.read(),io(l.data,a)||(l.data[a]=[]);let e={};ue(l.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let n=an(t),o=0,i=!1;ue(t,(t=>{io(e,t.id)||(l.data[a].push(t),o++,i=!0)})),i&&await l.write(),r={n:n,nInserted:o,ok:1},h.emit("change","insert",t,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r}))}return h.select=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!1,r=null;try{if(await l.read(),io(l.data,a)||(l.data[a]=[]),ro(t)){r=new u.Query(t).find(l.data[a]).all()}else r=l.data[a]}catch(t){e=!0,r=t}return e?Promise.reject(r):r},h.insert=v,h.save=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await s.runExclusive((async()=>{let r=!1;if(!ro(t)&&!oo(t))return Promise.reject("data is not an effective object or array");t=An(t);let n=mt(e,"autoInsert",!0),o=null;try{Yn(t)||(t=[t]),t=nr(t,(function(t){return Nn(t.id)||(t.id=Kn()),t})),await l.read(),io(l.data,a)||(l.data[a]=[]);let e={};ue(l.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let r=!1;o=await eo(t,(async t=>{let o=null,i=mt(e,t.id,null);var u,c;return ro(i)&&(u=t,c=i.v,Ge(u,c)||(l.data[a][i.k]=Cr(l.data[a][i.k],t),o={update:!0},r=!0)),o=ro(o)?{n:1,nModified:1,ok:1}:{n:0,nModified:0,ok:1},n&&0===o.n&&(o=await v(t)),o})),r&&await l.write(),h.emit("change","save",t,o)}catch(t){r=!0,o=t}return r?Promise.reject(o):o}))},h.del=async function(t){return await s.runExclusive((async()=>{let e=!1;if(!ro(t)&&!oo(t))return Promise.reject("data is not an effective object or array");t=An(t);let r=null;try{Yn(t)||(t=[t]),await l.read(),io(l.data,a)||(l.data[a]=[]);let e={};ue(l.data[a],((t,r)=>{e[t.id]={k:r,v:t}}));let n=[],o=!1;r=await eo(t,(async t=>{let r=null,i=mt(t,"id","");if(Nn(i)){let t=mt(e,i,null);ro(t)?(n.push(t.k),o=!0,r={n:1,nDeleted:1,ok:1}):r={n:1,nDeleted:0,ok:1}}else r={n:1,nDeleted:0,ok:0};return r})),o&&(l.data[a]=yo(l.data[a],n)),o&&await l.write(),h.emit("change","del",t,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r}))},h.delAll=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return await s.runExclusive((async()=>{let e=!1,r=null;try{await l.read(),io(l.data,a)||(l.data[a]=[]);let e=an(l.data[a]),n=0,o=!1;if(ro(t)){let r=new u.Query(t).find(l.data[a]).all();if(n=an(r),0===n);else if(e===n)l.data[a]=[],o=!0;else{let t={};ue(r,((e,r)=>{t[e.id]={k:r,v:e}}));let e=[];ue(l.data[a],((r,n)=>{io(t,r.id)||e.push(r)})),l.data[a]=e,o=!0}}else n=e,l.data[a]=[],o=!0;o&&await l.write(),r={n:e,nDeleted:n,ok:1},h.emit("change","delAll",null,r)}catch(t){e=!0,r=t}return e?Promise.reject(r):r}))},h}}));
7
7
  //# sourceMappingURL=w-orm-lowdb.umd.js.map