gis-common 3.1.11 → 4.1.1

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.
@@ -1,7 +1,7 @@
1
- var z = Object.defineProperty;
2
- var H = (e, t, n) => t in e ? z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var f = (e, t, n) => H(e, typeof t != "symbol" ? t + "" : t, n);
4
- const x = {
1
+ var S = Object.defineProperty;
2
+ var x = (t, e, n) => e in t ? S(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var f = (t, e, n) => x(t, typeof e != "symbol" ? e + "" : e, n);
4
+ const M = {
5
5
  MAP_RENDER: "mapRender",
6
6
  MAP_READY: "mapReady",
7
7
  MOUSE_CLICK: "click",
@@ -23,7 +23,7 @@ const x = {
23
23
  WEB_SOCKET_ERROR: "webSocketError",
24
24
  WEB_SOCKET_MESSAGE: "webSocketMessage",
25
25
  WEB_SOCKET_CLOSE: "webSocketClose"
26
- }, p = {
26
+ }, D = {
27
27
  LOGIN_EXPIRED: "登录信息过期,请重新登录",
28
28
  CROSS_ERROR: "跨域访问",
29
29
  UNEXIST_RESOURCE: "资源不存在",
@@ -44,7 +44,7 @@ const x = {
44
44
  PARAMETER_ERROR_OBJECT: "格式类型验证失败:必须是对象",
45
45
  PARAMETER_ERROR_LACK: "参数缺失",
46
46
  STRING_CHECK_LOSS: "字符缺少关键字"
47
- }, Q = {
47
+ }, C = {
48
48
  SUPER_MAP_IMAGES: "SuperMapImages",
49
49
  // 超图影像服务 栅格数据
50
50
  SUPER_MAP_DATA: "SuperMapData",
@@ -58,7 +58,7 @@ const x = {
58
58
  // addS3MGroupLayer(url, options, index) 添加S3M分组图层。
59
59
  TERRAIN_LAYER: "TerrainFileLayer"
60
60
  // 地形图层, 需要单独处理
61
- }, X = {
61
+ }, I = {
62
62
  POINT: "point",
63
63
  POLYLINE: "polyline",
64
64
  POLYGON: "polygon",
@@ -68,91 +68,74 @@ const x = {
68
68
  LABEL: "label",
69
69
  MODEL: "model",
70
70
  WALL: "wall"
71
- }, V = {
71
+ }, _ = {
72
72
  DISTANCE: "distance",
73
73
  AREA: "area",
74
74
  HEIGHT: "height"
75
- }, Z = {
75
+ }, T = {
76
76
  ADD: "add",
77
77
  REMOVE: "remove",
78
78
  INIT: "init"
79
- }, tt = {
80
- /**
81
- * 多属性的动画函数
82
- * @param {*} ele 需要运动的节点
83
- * @param {*} attr_options 传入的是一个需要运动的属性包括运动的目标值,操作的节点属性
84
- * @param {*} timefn 运动的形式,默认是缓冲运动
85
- * @param {*} speed 运动的速度
86
- */
87
- animate(e, t, n, s = "swing", a = 5) {
88
- for (var r in t)
89
- t[r] = {
90
- target: r === "opacity" ? parseInt(t[r] * 100) : t[r],
91
- // 需要计算得到
92
- iNow: parseInt(r === "opacity" ? getComputedStyle(e)[r] * 100 : getComputedStyle(e)[r])
93
- };
94
- s === "liner" && (a = t[r].iNow < t[r].target ? Math.abs(a) : -Math.abs(a)), clearInterval(e.timer), e.timer = setInterval(function() {
95
- for (var i in t) {
96
- var o = t[i].target, c = t[i].iNow;
97
- if (s === "swing" && (a = (o - c) / 20, a = a > 0 ? Math.ceil(a) : Math.floor(a)), Math.abs(o - c) <= Math.abs(a)) {
98
- i === "opacity" ? e.style[i] = o / 100 : e.style[i] = o + "px", delete t[i];
99
- for (var l in t)
100
- return !1;
101
- clearInterval(e.timer), typeof n == "function" && n();
102
- } else
103
- t[i].iNow += a, i === "opacity" ? e.style[i] = t[i].iNow / 100 : e.style[i] = t[i].iNow + "px";
104
- }
105
- }, 30);
79
+ };
80
+ class v {
81
+ constructor(e) {
82
+ /**
83
+ * Creates an instance of AudioPlayer.
84
+ * @param {*} url
85
+ */
86
+ f(this, "audio");
87
+ this.audio = new Audio(), this.audio.src = e;
88
+ }
89
+ play() {
90
+ !this.muted && this.audio.play();
91
+ }
92
+ pause() {
93
+ this.audio.pause();
94
+ }
95
+ get muted() {
96
+ return this.audio.muted;
97
+ }
98
+ /**
99
+ * @description 设置静音状态,如果静音,autoplay属性将失效
100
+ */
101
+ set muted(e) {
102
+ this.audio.muted = e;
106
103
  }
107
- }, E = {
104
+ }
105
+ const y = {
108
106
  /**
109
107
  * 获取数据类型
110
108
  *
111
109
  * @param data 待判断的数据
112
110
  * @returns 返回数据类型字符串
113
111
  */
114
- getDataType(e) {
115
- return Object.prototype.toString.call(e).slice(8, -1);
112
+ getDataType(t) {
113
+ return Object.prototype.toString.call(t).slice(8, -1);
116
114
  },
117
- isEmpty(e) {
118
- if (e == null)
115
+ isEmpty(t) {
116
+ if (t == null)
119
117
  return !0;
120
- switch (this.getDataType(e)) {
118
+ switch (this.getDataType(t)) {
121
119
  case "String":
122
- return e.trim() === "";
120
+ return t.trim() === "";
123
121
  case "Array":
124
- return !e.length;
122
+ return !t.length;
125
123
  case "Object":
126
- return !Object.keys(e).length;
124
+ return !Object.keys(t).length;
127
125
  case "Boolean":
128
- return !e;
126
+ return !t;
129
127
  default:
130
128
  return !1;
131
129
  }
132
130
  },
133
- isNotEmpty(e) {
134
- return !this.isEmpty(e);
131
+ isNotEmpty(t) {
132
+ return !this.isEmpty(t);
135
133
  },
136
- json2form(e) {
137
- const t = new FormData();
138
- return Object.keys(e).forEach((n) => {
139
- t.append(n, e[n] instanceof Object ? JSON.stringify(e[n]) : e[n]);
140
- }), t;
141
- },
142
- /**
143
- * 将json对象转换为查询字符串
144
- *
145
- * @param json 待转换的json对象
146
- * @returns 转换后的查询字符串
147
- */
148
- json2Query(e) {
149
- var t = [];
150
- for (var n in e) {
151
- var s = n, a = e[n];
152
- t.push(s + "=" + a);
153
- }
154
- var r = t.join("&");
155
- return r;
134
+ json2form(t) {
135
+ const e = new FormData();
136
+ return Object.keys(t).forEach((n) => {
137
+ e.append(n, t[n] instanceof Object ? JSON.stringify(t[n]) : t[n]);
138
+ }), e;
156
139
  },
157
140
  /**
158
141
  * 生成GUID
@@ -160,10 +143,10 @@ const x = {
160
143
  * @returns 返回一个由8个16进制数组成的GUID字符串
161
144
  */
162
145
  generateGuid() {
163
- const e = function() {
146
+ const t = function() {
164
147
  return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
165
148
  };
166
- return e() + e() + e() + e() + e() + e() + e() + e();
149
+ return t() + t() + t() + t() + t() + t() + t() + t();
167
150
  },
168
151
  /**
169
152
  * 将参数进行解码并返回解码后的字符串
@@ -171,18 +154,18 @@ const x = {
171
154
  * @param args 参数
172
155
  * @returns 解码后的字符串
173
156
  */
174
- decodeDict(...e) {
175
- let t = "";
176
- if (e.length > 1) {
177
- const n = e.slice(1, e.length % 2 === 0 ? e.length - 1 : e.length);
157
+ decodeDict(...t) {
158
+ let e = "";
159
+ if (t.length > 1) {
160
+ const n = t.slice(1, t.length % 2 === 0 ? t.length - 1 : t.length);
178
161
  for (let s = 0; s < n.length; s = s + 2) {
179
- const a = n[s];
180
- e[0] === a && (t = n[s + 1]);
162
+ const r = n[s];
163
+ t[0] === r && (e = n[s + 1]);
181
164
  }
182
- !t && e.length % 2 === 0 && (t = e[e.length - 1]);
165
+ !e && t.length % 2 === 0 && (e = t[t.length - 1]);
183
166
  } else
184
- t = e[0];
185
- return t;
167
+ e = t[0];
168
+ return e;
186
169
  },
187
170
  /**
188
171
  * 将一个或多个对象的所有可枚举属性复制到目标对象。
@@ -191,23 +174,13 @@ const x = {
191
174
  * @param args 一个或多个源对象,用于提供要复制的属性。
192
175
  * @returns 返回目标对象,包含所有复制的属性。
193
176
  */
194
- extend(e, ...t) {
195
- let n, s, a, r;
196
- for (s = 0, a = t.length; s < a; s++) {
197
- r = t[s];
198
- for (n in r)
199
- e[n] = r[n];
177
+ extend(t, ...e) {
178
+ let n, s, r, i;
179
+ for (s = 0, r = e.length; s < r; s++) {
180
+ i = e[s];
181
+ for (n in i)
182
+ t[n] = i[n];
200
183
  }
201
- return e;
202
- },
203
- /**
204
- * 将RGB颜色值转换为十六进制颜色值
205
- *
206
- * @param rgb RGB颜色值数组,包含三个0-255之间的整数
207
- * @returns 转换后的十六进制颜色值,以#开头
208
- */
209
- rgb2hex(e) {
210
- var t = "#" + (16777216 + (e[0] << 16) + (e[1] << 8) + e[2]).toString(16).slice(1);
211
184
  return t;
212
185
  },
213
186
  /**
@@ -219,31 +192,31 @@ const x = {
219
192
  * @param childrenPropertyName 树形结构中标识子节点的字段名,默认为'children'
220
193
  * @returns 转换后的树形结构数组
221
194
  */
222
- convertToTree2(e, t = "id", n = "parentId", s = "children") {
223
- const a = [];
224
- function r(i) {
225
- const o = e.filter((c) => c[n] === i[t]).map((c) => (a.some((l) => l[t] === c[t]) || r(c), c));
226
- o.length > 0 && (i[s] = o);
195
+ convertToTree2(t, e = "id", n = "parentId", s = "children") {
196
+ const r = [];
197
+ function i(a) {
198
+ const o = t.filter((c) => c[n] === a[e]).map((c) => (r.some((l) => l[e] === c[e]) || i(c), c));
199
+ o.length > 0 && (a[s] = o);
227
200
  }
228
- return e.forEach((i) => {
229
- e.some((o) => o[n] === i[t]) || (r(i), a.push(i));
230
- }), a;
201
+ return t.forEach((a) => {
202
+ t.some((o) => o[n] === a[e]) || (i(a), r.push(a));
203
+ }), r;
231
204
  },
232
205
  /**
233
206
  * 异步加载script
234
207
  *
235
208
  * @param {*} url
236
209
  */
237
- asyncLoadScript(e) {
238
- return new Promise((t, n) => {
210
+ asyncLoadScript(t) {
211
+ return new Promise((e, n) => {
239
212
  try {
240
213
  const s = document.createElement("script");
241
- s.type = "text/javascript", s.src = e, "readyState" in s ? s.onreadystatechange = function() {
242
- (s.readyState === "complete" || s.readyState === "loaded") && t(s);
214
+ s.type = "text/javascript", s.src = t, "readyState" in s ? s.onreadystatechange = function() {
215
+ (s.readyState === "complete" || s.readyState === "loaded") && e(s);
243
216
  } : (s.onload = function() {
244
- t(s);
217
+ e(s);
245
218
  }, s.onerror = function() {
246
- n(new Error("Script failed to load for URL: " + e));
219
+ n(new Error("Script failed to load for URL: " + t));
247
220
  }), document.body.appendChild(s);
248
221
  } catch (s) {
249
222
  n(s);
@@ -256,11 +229,11 @@ const x = {
256
229
  * @param urls 样式文件URL数组
257
230
  * @returns 无返回值
258
231
  */
259
- loadStyle(e) {
260
- e.forEach((t) => {
232
+ loadStyle(t) {
233
+ t.forEach((e) => {
261
234
  const n = document.createElement("link");
262
- n.href = t, n.rel = "stylesheet", n.type = "text/css", n.onerror = function() {
263
- console.error(`Style loading failed for URL: ${t}`);
235
+ n.href = e, n.rel = "stylesheet", n.type = "text/css", n.onerror = function() {
236
+ console.error(`Style loading failed for URL: ${e}`);
264
237
  }, document.head.appendChild(n);
265
238
  });
266
239
  },
@@ -272,13 +245,13 @@ const x = {
272
245
  * @returns 替换后的字符串
273
246
  * @throws 当对象中没有找到与占位符对应的值时,抛出错误
274
247
  */
275
- template(e, t) {
248
+ template(t, e) {
276
249
  const n = /\{ *([\w_-]+) *\}/g;
277
- return e.replace(n, (s, a) => {
278
- const r = t[a];
279
- if (r === void 0)
280
- throw new Error(`${p.JSON_VALUE_ERROR}: ${s}`);
281
- return typeof r == "function" ? r(t) : r;
250
+ return t.replace(n, (s, r) => {
251
+ const i = e[r];
252
+ if (i === void 0)
253
+ throw new Error(`${D.JSON_VALUE_ERROR}: ${s}`);
254
+ return typeof i == "function" ? i(e) : i;
282
255
  });
283
256
  },
284
257
  /**
@@ -287,18 +260,18 @@ const x = {
287
260
  * @param data 待处理的对象
288
261
  * @returns 返回处理后的对象
289
262
  */
290
- deleteEmptyProperty(e) {
263
+ deleteEmptyProperty(t) {
291
264
  return Object.fromEntries(
292
- Object.keys(e).filter((t) => !this.isEmpty(e[t])).map((t) => [t, e[t]])
265
+ Object.keys(t).filter((e) => !this.isEmpty(t[e])).map((e) => [e, t[e]])
293
266
  );
294
267
  },
295
- deepAssign(e, ...t) {
296
- (typeof e != "object" || e === null) && (e = {});
297
- for (const n of t)
268
+ deepAssign(t, ...e) {
269
+ (typeof t != "object" || t === null) && (t = {});
270
+ for (const n of e)
298
271
  if (typeof n == "object" && n !== null)
299
272
  for (const s in n)
300
- Object.prototype.hasOwnProperty.call(n, s) && (typeof n[s] == "object" && n[s] !== null ? (e[s] || (e[s] = Array.isArray(n[s]) ? [] : {}), this.deepAssign(e[s], n[s])) : e[s] = n[s]);
301
- return e;
273
+ Object.prototype.hasOwnProperty.call(n, s) && (typeof n[s] == "object" && n[s] !== null ? (t[s] || (t[s] = Array.isArray(n[s]) ? [] : {}), this.deepAssign(t[s], n[s])) : t[s] = n[s]);
274
+ return t;
302
275
  },
303
276
  /**
304
277
  * 复制文本到剪贴板
@@ -306,36 +279,298 @@ const x = {
306
279
  * @param text 要复制的文本
307
280
  * @returns 返回一个Promise,表示复制操作的结果
308
281
  */
309
- handleCopyValue(e) {
282
+ handleCopyValue(t) {
310
283
  if (navigator.clipboard && window.isSecureContext)
311
- return navigator.clipboard.writeText(e);
284
+ return navigator.clipboard.writeText(t);
312
285
  {
313
- const t = document.createElement("textarea");
314
- return t.style.position = "fixed", t.style.top = t.style.left = "-100vh", t.style.opacity = "0", t.value = e, document.body.appendChild(t), t.focus(), t.select(), new Promise((n, s) => {
286
+ const e = document.createElement("textarea");
287
+ return e.style.position = "fixed", e.style.top = e.style.left = "-100vh", e.style.opacity = "0", e.value = t, document.body.appendChild(e), e.focus(), e.select(), new Promise((n, s) => {
315
288
  try {
316
289
  document.execCommand("copy"), n();
317
290
  } catch {
318
291
  s(new Error("copy failed"));
319
292
  } finally {
320
- t.remove();
293
+ e.remove();
321
294
  }
322
295
  });
323
296
  }
297
+ },
298
+ isArray(t) {
299
+ return Array.isArray(t);
300
+ },
301
+ isObject(t) {
302
+ return Object.prototype.toString.call(t).indexOf("Object") > -1;
303
+ },
304
+ isNil(t) {
305
+ return typeof t > "u" || t === null;
306
+ }
307
+ }, m = {
308
+ DEG2RAD: Math.PI / 180,
309
+ RAD2DEG: 180 / Math.PI,
310
+ randInt(t, e) {
311
+ return t + Math.floor(Math.random() * (e - t + 1));
312
+ },
313
+ randFloat(t, e) {
314
+ return t + Math.random() * (e - t);
315
+ },
316
+ /**
317
+ * 角度转弧度
318
+ *
319
+ * @param {*} degrees
320
+ * @returns {*}
321
+ */
322
+ degreesToRadians(t) {
323
+ return t * this.DEG2RAD;
324
+ },
325
+ /**
326
+ * 角度转弧度
327
+ *
328
+ * @param {*} degrees
329
+ * @returns {*}
330
+ */
331
+ toRadians(t) {
332
+ return t * this.DEG2RAD;
333
+ },
334
+ /**
335
+ * 弧度转角度
336
+ *
337
+ * @param {*} radians
338
+ * @returns {*}
339
+ */
340
+ radiansToDegrees(t) {
341
+ return t * this.RAD2DEG;
342
+ },
343
+ /**
344
+ * 弧度转角度
345
+ *
346
+ * @param {*} radians
347
+ * @returns {*}
348
+ */
349
+ toDegrees(t) {
350
+ return t * this.RAD2DEG;
351
+ },
352
+ formatFloat(t, e = 2) {
353
+ return Math.round(t * Math.pow(10, e)) / Math.pow(10, e);
324
354
  }
325
355
  };
326
- Array.prototype.groupBy = function(e) {
327
- var t = {};
356
+ class P {
357
+ constructor(e) {
358
+ y.getDataType(e) === "String" && (e = document.querySelector("#" + e)), this.ctx = e.getContext("2d");
359
+ }
360
+ drawLine(e, n, s, r, i = {}) {
361
+ this.cxt.beginPath();
362
+ const a = i.width || 1, o = i.color || "#000";
363
+ this.cxt.lineWidth = a, this.cxt.fillStyle = o, this.cxt.moveTo(e, n), this.cxt.lineTo(s, r), this.cxt.closePath(), this.cxt.fill();
364
+ }
365
+ /**
366
+ * 绘制圆弧
367
+ * @param {*} x 圆心X坐标
368
+ * @param {*} y 圆心Y坐标
369
+ * @param {*} radius 半径
370
+ * @param {*} startAngle 开始的弧度
371
+ * @param {*} endAngle 结束的弧度
372
+ * @param {*} anticlockwise true为逆时针,false为顺时针
373
+ * @param {boolean} isOnlyArc
374
+ * @param {boolean} isFill 是否是填充,false为绘制边框,true为绘制填充
375
+ * @param {*} bgColor 圆弧的颜色
376
+ * @memberof CanvasDrawer
377
+ */
378
+ drawArc(e, n, s, r, i, a, o, c) {
379
+ o ? (this.cxt.fillStyle = c, this.cxt.beginPath(), this.cxt.arc(e, n, s, m.degreesToRadians(r), m.degreesToRadians(i), a), this.cxt.closePath(), this.cxt.fill()) : (this.cxt.strokeStyle = c, this.cxt.beginPath(), this.cxt.arc(e, n, s, m.degreesToRadians(r), m.degreesToRadians(i), a), this.cxt.stroke());
380
+ }
381
+ }
382
+ class L {
383
+ constructor(e = 1) {
384
+ this.magnification = e;
385
+ }
386
+ // 获取系统类型
387
+ _getSystem() {
388
+ var e = navigator.userAgent.toLowerCase();
389
+ if (e.indexOf("windows") >= 0)
390
+ return !0;
391
+ }
392
+ // 获取页面缩放比例
393
+ // _getDevicePixelRatio() {
394
+ // let t = this;
395
+ // }
396
+ // 监听方法兼容写法
397
+ _addHandler(e, n, s) {
398
+ e.addEventListener ? e.addEventListener(n, s, !1) : e.attachEvent ? e.attachEvent("on" + n, s) : e["on" + n] = s;
399
+ }
400
+ // 校正浏览器缩放比例
401
+ _correct() {
402
+ let e = window.innerWidth;
403
+ if (typeof e != "number" && (document.compatMode == "CSS1Compat" ? e = document.documentElement.clientWidth : e = document.body.clientWidth), e <= 750) {
404
+ const s = document.documentElement.clientWidth / e;
405
+ document.documentElement.style.fontSize = this.magnification * 75 * Math.min(s, 2) + "px";
406
+ } else if (e > 750 && e <= 1200) {
407
+ const s = document.documentElement.clientWidth / e;
408
+ document.documentElement.style.fontSize = this.magnification * 85 * Math.min(s, 2) + "px";
409
+ } else {
410
+ const s = document.documentElement.clientWidth / 1920;
411
+ document.documentElement.style.fontSize = this.magnification * 100 * Math.min(s, 2) + "px";
412
+ }
413
+ }
414
+ // 监听页面缩放
415
+ _watch() {
416
+ let e = this;
417
+ e._addHandler(window, "resize", function() {
418
+ e._correct();
419
+ });
420
+ }
421
+ // 初始化页面比例
422
+ init() {
423
+ let e = this;
424
+ e._getSystem() && (e._correct(), e._watch());
425
+ }
426
+ }
427
+ class A {
428
+ constructor() {
429
+ f(this, "_listeners");
430
+ f(this, "_mutex", {});
431
+ f(this, "_context");
432
+ }
433
+ addEventListener(e, n, s, r = !1) {
434
+ this._listeners === void 0 && (this._listeners = {}), this._context = s;
435
+ const i = this._mutex, a = this._listeners;
436
+ return a[e] === void 0 && (a[e] = []), a[e].indexOf(n) === -1 && (r && (i[e] = n), a[e].push(n)), this;
437
+ }
438
+ hasEventListener(e, n) {
439
+ if (this._listeners === null || this._listeners === void 0) return !1;
440
+ const s = this._listeners;
441
+ return s[e] !== void 0 && s[e].indexOf(n) !== -1;
442
+ }
443
+ removeEventListener(e, n) {
444
+ if (this._listeners === void 0) return;
445
+ const r = this._listeners[e];
446
+ if (this._mutex[e] === n && (this._mutex[e] = null), r !== void 0) {
447
+ const i = r.map((a) => a.toString()).indexOf(n.toString());
448
+ i !== -1 && r.splice(i, 1);
449
+ }
450
+ }
451
+ dispatchEvent(e) {
452
+ if (this._listeners === void 0) return;
453
+ const s = this._listeners[e.type];
454
+ if (s !== void 0) {
455
+ e.target = this;
456
+ const r = s.slice(0);
457
+ if (this._mutex[e.type] !== void 0) {
458
+ const i = r.find((a) => a === this._mutex[e.type]);
459
+ if (i) {
460
+ i.call(this._context || this, e);
461
+ return;
462
+ }
463
+ }
464
+ for (let i = 0, a = r.length; i < a; i++) {
465
+ const o = r[i];
466
+ typeof o == "function" && o.call(this._context || this, e);
467
+ }
468
+ }
469
+ }
470
+ removeAllListener() {
471
+ this._mutex = {};
472
+ for (const e in this._listeners)
473
+ this._listeners[e] = [];
474
+ }
475
+ }
476
+ class E extends Map {
477
+ isEmpty() {
478
+ return this.size === 0;
479
+ }
480
+ _values() {
481
+ return Array.from(this.values());
482
+ }
483
+ _keys() {
484
+ return Array.from(this.keys());
485
+ }
486
+ _entries() {
487
+ return Array.from(this.entries());
488
+ }
489
+ fromEntries() {
490
+ }
491
+ }
492
+ E.prototype.fromEntries = function(t = []) {
493
+ const e = new E();
494
+ return t.forEach((n) => {
495
+ Array.isArray(n) && n.length === 2 && e.set(n[0], n[1]);
496
+ }), e;
497
+ };
498
+ class U extends A {
499
+ constructor(n = "ws://127.0.0.1:10088") {
500
+ super();
501
+ f(this, "maxCheckTimes", 10);
502
+ f(this, "url");
503
+ f(this, "checkTimes", 0);
504
+ f(this, "connectStatus", !1);
505
+ f(this, "client", null);
506
+ this.maxCheckTimes = 10, this.url = n, this.checkTimes = 0, this.connect(), this.connCheckStatus(this.maxCheckTimes);
507
+ }
508
+ connect() {
509
+ if (this.disconnect(), this.url)
510
+ try {
511
+ if (console.info("创建ws连接>>>" + this.url), this.client = new WebSocket(this.url), this.client) {
512
+ const n = this;
513
+ this.client.onopen = function(s) {
514
+ n.dispatchEvent({
515
+ type: M.WEB_SOCKET_CONNECT,
516
+ message: s
517
+ });
518
+ }, this.client.onmessage = function(s) {
519
+ n.connectStatus = !0, n.dispatchEvent({
520
+ type: M.WEB_SOCKET_MESSAGE,
521
+ message: s
522
+ });
523
+ }, this.client.onclose = function(s) {
524
+ n.dispatchEvent({
525
+ type: M.WEB_SOCKET_CLOSE,
526
+ message: s
527
+ });
528
+ }, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(s) {
529
+ n.dispatchEvent({
530
+ type: M.WEB_SOCKET_ERROR,
531
+ message: s
532
+ });
533
+ });
534
+ }
535
+ } catch (n) {
536
+ console.error("创建ws连接失败" + this.url + ":" + n);
537
+ }
538
+ }
539
+ disconnect() {
540
+ if (this.client)
541
+ try {
542
+ console.log("ws断开连接" + this.url), this.client.close(), this.client = null;
543
+ } catch {
544
+ this.client = null;
545
+ }
546
+ }
547
+ connCheckStatus(n) {
548
+ this.checkTimes > n || setTimeout(() => {
549
+ this.checkTimes++, this.client && this.client.readyState !== 0 && this.client.readyState !== 1 && this.connect(), this.connCheckStatus(n);
550
+ }, 2e3);
551
+ }
552
+ send(n) {
553
+ return this.client && this.client.readyState === 1 ? (this.client.send(n), !0) : (console.error(this.url + "消息发送失败:" + n), !1);
554
+ }
555
+ heartbeat() {
556
+ setTimeout(() => {
557
+ this.client && this.client.readyState === 1 && this.send("HeartBeat"), console.log("HeartBeat," + this.url), setTimeout(this.heartbeat, 3e4);
558
+ }, 1e3);
559
+ }
560
+ }
561
+ Array.prototype.groupBy = function(t) {
562
+ var e = {};
328
563
  return this.forEach(function(n) {
329
- var s = JSON.stringify(e(n));
330
- t[s] = t[s] || [], t[s].push(n);
331
- }), Object.keys(t).map((n) => t[n]);
564
+ var s = JSON.stringify(t(n));
565
+ e[s] = e[s] || [], e[s].push(n);
566
+ }), Object.keys(e).map((n) => e[n]);
332
567
  };
333
- Array.prototype.distinct = function(e = (t) => t) {
334
- const t = [], n = {};
568
+ Array.prototype.distinct = function(t = (e) => e) {
569
+ const e = [], n = {};
335
570
  return this.forEach((s) => {
336
- const a = e(s);
337
- !n[a] && (n[a] = t.push(s));
338
- }), t;
571
+ const r = t(s), i = String(r);
572
+ n[i] || (n[i] = !0, e.push(s));
573
+ }), e;
339
574
  };
340
575
  Array.prototype.max = function() {
341
576
  return Math.max.apply({}, this);
@@ -344,204 +579,314 @@ Array.prototype.min = function() {
344
579
  return Math.min.apply({}, this);
345
580
  };
346
581
  Array.prototype.sum = function() {
347
- return this.length > 0 ? this.reduce((e = 0, t = 0) => e + t) : 0;
582
+ return this.length > 0 ? this.reduce((t = 0, e = 0) => t + e) : 0;
348
583
  };
349
584
  Array.prototype.avg = function() {
350
585
  return this.length ? this.sum() / this.length : 0;
351
586
  };
352
- Array.prototype.desc = function(e = (t) => t) {
353
- return this.sort((t, n) => e(n) - e(t));
587
+ Array.prototype.desc = function(t = (e) => e) {
588
+ return this.sort((e, n) => t(n) - t(e));
354
589
  };
355
- Array.prototype.asc = function(e = (t) => t) {
356
- return this.sort((t, n) => e(t) - e(n));
590
+ Array.prototype.asc = function(t = (e) => e) {
591
+ return this.sort((e, n) => t(e) - t(n));
357
592
  };
358
593
  Array.prototype.clear = function() {
359
594
  return this.length = 0, this;
360
595
  };
361
- const et = {
362
- asArray(e) {
363
- return E.isEmpty(e) ? [] : Array.isArray(e) ? e : [e];
364
- },
365
- generateArray(e) {
366
- return [...new Array(e).keys()];
367
- },
368
- union(...e) {
369
- let t = [];
370
- return e.forEach((n) => {
371
- Array.isArray(n) && (t = t.concat(n.filter((s) => !t.includes(s))));
372
- }), t;
373
- },
374
- intersection(...e) {
375
- let t = e[0] || [];
376
- return e.forEach((n) => {
377
- Array.isArray(n) && (t = t.filter((s) => n.includes(s)));
378
- }), t;
379
- },
380
- unionAll(...e) {
381
- return [...e].flat().filter((t) => !!t);
382
- },
383
- difference(...e) {
384
- return this.union(...e).filter((t) => !this.intersection(...e).includes(t));
596
+ const k = {
597
+ asArray(t) {
598
+ return y.isEmpty(t) ? [] : Array.isArray(t) ? t : [t];
599
+ },
600
+ generateArray(t) {
601
+ return [...new Array(t).keys()];
602
+ },
603
+ /**
604
+ * 合并多个数组,并去重
605
+ *
606
+ * @param args 需要合并的数组
607
+ * @returns 合并后的去重数组
608
+ */
609
+ union(...t) {
610
+ let e = [];
611
+ return t.forEach((n) => {
612
+ Array.isArray(n) && (e = e.concat(n.filter((s) => !e.includes(s))));
613
+ }), e;
614
+ },
615
+ /**
616
+ * 求多个数组的交集
617
+ *
618
+ * @param args 多个需要求交集的数组
619
+ * @returns 返回多个数组的交集数组
620
+ */
621
+ intersection(...t) {
622
+ let e = t[0] || [];
623
+ return t.forEach((n) => {
624
+ Array.isArray(n) && (e = e.filter((s) => n.includes(s)));
625
+ }), e;
626
+ },
627
+ /**
628
+ * 将多个数组拼接为一个数组,并去除其中的空值。
629
+ *
630
+ * @param args 需要拼接的数组列表。
631
+ * @returns 拼接并去空后的数组。
632
+ */
633
+ unionAll(...t) {
634
+ return [...t].flat().filter((e) => !!e);
635
+ },
636
+ /**
637
+ * 求差集
638
+ *
639
+ * @param args 任意个集合
640
+ * @returns 返回差集结果
641
+ */
642
+ difference(...t) {
643
+ return this.union(...t).filter((e) => !this.intersection(...t).includes(e));
385
644
  }
386
- }, nt = {
387
- getUrlParams(e = window.location.href, t = !0) {
388
- const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: s, hash: a } = new URL(e), r = [s, a];
389
- let i = {};
390
- for (let o = 0; o < r.length; o++) {
391
- const c = r[o];
645
+ }, N = {
646
+ /**
647
+ * URL 中解析出查询参数和哈希参数,并以对象的形式返回
648
+ *
649
+ * @param href 需要解析的 URL 链接,默认为当前窗口的 URL
650
+ * @param needDecode 是否需要解码参数值,默认为 true
651
+ * @returns 返回一个包含解析后参数的对象,其中键为参数名,值为参数值
652
+ */
653
+ getUrlParams(t = window.location.href, e = !0) {
654
+ const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: s, hash: r } = new URL(t), i = [s, r];
655
+ let a = {};
656
+ for (let o = 0; o < i.length; o++) {
657
+ const c = i[o];
392
658
  if (c) {
393
659
  const h = c.replace(/#|\//g, "").split("?");
394
660
  if (h.length > 1)
395
661
  for (let u = 1; u < h.length; u++) {
396
662
  let d;
397
663
  for (; d = n.exec(h[u]); )
398
- i[d[1]] = t ? decodeURIComponent(d[2]) : d[2];
664
+ a[d[1]] = e ? decodeURIComponent(d[2]) : d[2];
399
665
  }
400
666
  }
401
667
  }
402
- return i;
668
+ return a;
403
669
  },
670
+ /**
671
+ * 获取浏览器类型
672
+ *
673
+ * @returns 返回浏览器类型字符串,可能的值为 'IE'、'Firefox'、'Chrome'、'Opera'、'Safari' 或 'Unknown'
674
+ */
404
675
  getExplorer() {
405
- var e = window.navigator.userAgent;
406
- if (e.indexOf("MSIE") >= 0 || window.ActiveXObject || "ActiveXObject" in window)
407
- return "IE";
408
- if (e.indexOf("Firefox") >= 0)
409
- return "Firefox";
410
- if (e.indexOf("Chrome") >= 0)
411
- return "Chrome";
412
- if (e.indexOf("Opera") >= 0)
413
- return "Opera";
414
- if (e.indexOf("Safari") >= 0)
415
- return "Safari";
676
+ var t = window.navigator.userAgent;
677
+ return t.indexOf("MSIE") >= 0 || /Trident\//.test(t) ? "IE" : t.indexOf("Firefox") >= 0 ? "Firefox" : t.indexOf("Chrome") >= 0 ? "Chrome" : t.indexOf("Opera") >= 0 ? "Opera" : t.indexOf("Safari") >= 0 && t.indexOf("Chrome") === -1 ? "Safari" : "Unknown";
416
678
  },
679
+ /**
680
+ * 检测操作系统类型
681
+ *
682
+ * @returns 返回操作系统类型字符串,可能的值有:'MS Windows'、'Apple mac'、'Linux'、'Unix'
683
+ */
417
684
  detectOS() {
418
- let e = "";
419
- const t = navigator.userAgent.indexOf("Windows", 0) != -1 ? 1 : 0, n = navigator.userAgent.indexOf("mac", 0) != -1 ? 1 : 0, s = navigator.userAgent.indexOf("Linux", 0) != -1 ? 1 : 0, a = navigator.userAgent.indexOf("X11", 0) != -1 ? 1 : 0;
420
- return t ? e = "MS Windows" : n ? e = "Apple mac" : s ? e = "Linux" : a && (e = "Unix"), e;
685
+ let t = "";
686
+ const e = navigator.userAgent.indexOf("Windows", 0) != -1 ? 1 : 0, n = navigator.userAgent.indexOf("mac", 0) != -1 ? 1 : 0, s = navigator.userAgent.indexOf("Linux", 0) != -1 ? 1 : 0, r = navigator.userAgent.indexOf("X11", 0) != -1 ? 1 : 0;
687
+ return e ? t = "MS Windows" : n ? t = "Apple mac" : s ? t = "Linux" : r && (t = "Unix"), t;
421
688
  },
422
- switchFullScreen(e) {
423
- if (e) {
424
- const t = document.documentElement;
425
- t.requestFullscreen ? t.requestFullscreen() : t.msRequestFullscreen ? t.msRequestFullscreen() : t.mozRequestFullScreen ? t.mozRequestFullScreen() : t.webkitRequestFullscreen && t.webkitRequestFullscreen();
689
+ /**
690
+ * 切换全屏状态
691
+ *
692
+ * @param status 是否全屏
693
+ */
694
+ switchFullScreen(t) {
695
+ if (t) {
696
+ const e = document.documentElement;
697
+ e.requestFullscreen ? e.requestFullscreen() : "msRequestFullscreen" in e ? e.msRequestFullscreen() : "mozRequestFullScreen" in e ? e.mozRequestFullScreen() : "webkitRequestFullscreen" in e && e.webkitRequestFullscreen();
426
698
  } else
427
- document.exitFullscreen ? document.exitFullscreen() : document.msExitFullscreen ? document.msExitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen();
699
+ document.exitFullscreen ? document.exitFullscreen() : "msExitFullscreen" in document ? document.msExitFullscreen() : "mozCancelFullScreen" in document ? document.mozCancelFullScreen() : "webkitExitFullscreen" in document && document.webkitExitFullscreen();
428
700
  },
429
701
  /**
430
- * scale屏幕适配方案
702
+ * 刷新缩放比例
703
+ *
704
+ * @returns 无返回值
431
705
  */
432
706
  refreshScale() {
433
- const e = document.documentElement.clientWidth, t = document.documentElement.clientHeight, n = document.getElementById("app").style, s = e / t, a = 16 / 9;
434
- let r = e / 1920;
435
- s > a && (r = t / 1080), n.transformOrigin = "left top", n.transform = `scale(${r}) translateX(-49.99%)`, n.width = `${e / r}px`;
707
+ const t = document.documentElement.clientWidth || 0, e = document.documentElement.clientHeight || 0, n = document.getElementById("app");
708
+ if (!n) return;
709
+ const s = n.style, r = t / e, i = 16 / 9;
710
+ let a = t / 1920;
711
+ r > i && (a = e / 1080), s.transformOrigin = "left top", s.transform = `scale(${a}) translateX(-49.99%)`, s.width = `${t / a}px`;
436
712
  },
437
713
  /**
438
- * rem屏幕适配方案
714
+ * 获取HTML字体大小
715
+ *
716
+ * @returns 无返回值,该函数会直接修改HTML元素的字体大小
439
717
  */
440
718
  getHtmlFontSize() {
441
- const e = document.documentElement.clientWidth || document.body.clientWidth, t = document.querySelector("html");
442
- t.style.fontSize = e / 192 + "px";
719
+ const t = document.documentElement.clientWidth || document.body.clientWidth, e = document.querySelector("html");
720
+ e && (e.style.fontSize = t / 192 + "px");
443
721
  }
444
- }, st = {
445
- set: function(e, t, n = 30) {
722
+ }, F = {
723
+ set: function(t, e, n = 30) {
446
724
  var s = /* @__PURE__ */ new Date();
447
- s.setTime(s.getTime() + n * 24 * 60 * 60 * 1e3), document.cookie = e + "=" + escape(t) + ";expires=" + s.toUTCString();
725
+ s.setTime(s.getTime() + n * 24 * 60 * 60 * 1e3), document.cookie = t + "=" + escape(e) + ";expires=" + s.toUTCString();
448
726
  },
449
- remove: function(e) {
450
- var t = /* @__PURE__ */ new Date();
451
- t.setTime(t.getTime() - 1);
452
- var n = this.get(e);
453
- n != null && (document.cookie = e + "=" + n + ";expires=" + t.toUTCString());
727
+ remove: function(t) {
728
+ var e = /* @__PURE__ */ new Date();
729
+ e.setTime(e.getTime() - 1);
730
+ var n = this.get(t);
731
+ n != null && (document.cookie = t + "=" + n + ";expires=" + e.toUTCString());
454
732
  },
455
- get: function(e) {
456
- var t = document.cookie.match(new RegExp("(^| )" + e + "=([^;]*)(;|$)"));
457
- return t != null ? t[2] : "";
733
+ get: function(t) {
734
+ var e = document.cookie.match(new RegExp("(^| )" + t + "=([^;]*)(;|$)"));
735
+ return e != null ? e[2] : "";
458
736
  }
459
- }, rt = {
737
+ }, $ = {
460
738
  PI: 3.141592653589793,
461
739
  XPI: 3.141592653589793 * 3e3 / 180,
462
- delta(e, t) {
740
+ delta(t, e) {
463
741
  const s = 0.006693421622965943;
464
- let a = this.transformLat(t - 105, e - 35), r = this.transformLon(t - 105, e - 35);
465
- const i = e / 180 * this.PI;
466
- let o = Math.sin(i);
742
+ let r = this.transformLat(e - 105, t - 35), i = this.transformLon(e - 105, t - 35);
743
+ const a = t / 180 * this.PI;
744
+ let o = Math.sin(a);
467
745
  o = 1 - s * o * o;
468
746
  const c = Math.sqrt(o);
469
- return a = a * 180 / (6378245 * (1 - s) / (o * c) * this.PI), r = r * 180 / (6378245 / c * Math.cos(i) * this.PI), { lat: a, lng: r };
747
+ return r = r * 180 / (6378245 * (1 - s) / (o * c) * this.PI), i = i * 180 / (6378245 / c * Math.cos(a) * this.PI), { lat: r, lng: i };
470
748
  },
471
749
  // WGS-84 to GCJ-02
472
- gcjEncrypt(e, t) {
473
- if (this.outOfChina(e, t))
474
- return { lat: e, lng: t };
475
- const n = this.delta(e, t);
476
- return { lat: e + n.lat, lng: t + n.lng };
750
+ gcjEncrypt(t, e) {
751
+ if (this.outOfChina(t, e))
752
+ return { lat: t, lng: e };
753
+ const n = this.delta(t, e);
754
+ return { lat: t + n.lat, lng: e + n.lng };
477
755
  },
478
756
  // GCJ-02 to WGS-84
479
- gcjDecrypt(e, t) {
480
- if (this.outOfChina(e, t))
481
- return { lat: e, lng: t };
482
- const n = this.delta(e, t);
483
- return { lat: e - n.lat, lng: t - n.lng };
757
+ gcjDecrypt(t, e) {
758
+ if (this.outOfChina(t, e))
759
+ return { lat: t, lng: e };
760
+ const n = this.delta(t, e);
761
+ return { lat: t - n.lat, lng: e - n.lng };
484
762
  },
485
763
  // GCJ-02 to WGS-84 exactly
486
- gcjDecryptExact(e, t) {
487
- let a = 0.01, r = 0.01, i = e - a, o = t - r, c = e + a, l = t + r, h = 0, u = 0, d = 0;
764
+ gcjDecryptExact(t, e) {
765
+ let r = 0.01, i = 0.01, a = t - r, o = e - i, c = t + r, l = e + i, h = 0, u = 0, d = 0;
488
766
  for (; ; ) {
489
- h = (i + c) / 2, u = (o + l) / 2;
490
- const R = this.gcjEncrypt(h, u);
491
- if (a = R.lat - e, r = R.lng - t, Math.abs(a) < 1e-9 && Math.abs(r) < 1e-9 || (a > 0 ? c = h : i = h, r > 0 ? l = u : o = u, ++d > 1e4)) break;
767
+ h = (a + c) / 2, u = (o + l) / 2;
768
+ const g = this.gcjEncrypt(h, u);
769
+ if (r = g.lat - t, i = g.lng - e, Math.abs(r) < 1e-9 && Math.abs(i) < 1e-9 || (r > 0 ? c = h : a = h, i > 0 ? l = u : o = u, ++d > 1e4)) break;
492
770
  }
493
771
  return { lat: h, lng: u };
494
772
  },
495
773
  // GCJ-02 to BD-09
496
- bdEncrypt(e, t) {
497
- const n = t, s = e, a = Math.sqrt(n * n + s * s) + 2e-5 * Math.sin(s * this.XPI), r = Math.atan2(s, n) + 3e-6 * Math.cos(n * this.XPI), i = a * Math.cos(r) + 65e-4;
498
- return { lat: a * Math.sin(r) + 6e-3, lng: i };
774
+ bdEncrypt(t, e) {
775
+ const n = e, s = t, r = Math.sqrt(n * n + s * s) + 2e-5 * Math.sin(s * this.XPI), i = Math.atan2(s, n) + 3e-6 * Math.cos(n * this.XPI), a = r * Math.cos(i) + 65e-4;
776
+ return { lat: r * Math.sin(i) + 6e-3, lng: a };
499
777
  },
500
778
  // BD-09 to GCJ-02
501
- bdDecrypt(e, t) {
502
- const n = t - 65e-4, s = e - 6e-3, a = Math.sqrt(n * n + s * s) - 2e-5 * Math.sin(s * this.XPI), r = Math.atan2(s, n) - 3e-6 * Math.cos(n * this.XPI), i = a * Math.cos(r);
503
- return { lat: a * Math.sin(r), lng: i };
779
+ bdDecrypt(t, e) {
780
+ const n = e - 65e-4, s = t - 6e-3, r = Math.sqrt(n * n + s * s) - 2e-5 * Math.sin(s * this.XPI), i = Math.atan2(s, n) - 3e-6 * Math.cos(n * this.XPI), a = r * Math.cos(i);
781
+ return { lat: r * Math.sin(i), lng: a };
504
782
  },
505
783
  // WGS-84 to Web mercator
506
784
  // mercatorLat -> y mercatorLon -> x
507
- mercatorEncrypt(e, t) {
508
- const n = t * 2003750834e-2 / 180;
509
- let s = Math.log(Math.tan((90 + e) * this.PI / 360)) / (this.PI / 180);
785
+ mercatorEncrypt(t, e) {
786
+ const n = e * 2003750834e-2 / 180;
787
+ let s = Math.log(Math.tan((90 + t) * this.PI / 360)) / (this.PI / 180);
510
788
  return s = s * 2003750834e-2 / 180, { lat: s, lng: n };
511
789
  },
512
790
  // Web mercator to WGS-84
513
791
  // mercatorLat -> y mercatorLon -> x
514
- mercatorDecrypt(e, t) {
515
- const n = t / 2003750834e-2 * 180;
516
- let s = e / 2003750834e-2 * 180;
792
+ mercatorDecrypt(t, e) {
793
+ const n = e / 2003750834e-2 * 180;
794
+ let s = t / 2003750834e-2 * 180;
517
795
  return s = 180 / this.PI * (2 * Math.atan(Math.exp(s * this.PI / 180)) - this.PI / 2), { lat: s, lng: n };
518
796
  },
519
- // two point's distance
520
- distance(e, t, n, s) {
521
- const r = Math.cos(e * this.PI / 180) * Math.cos(n * this.PI / 180) * Math.cos((t - s) * this.PI / 180), i = Math.sin(e * this.PI / 180) * Math.sin(n * this.PI / 180);
522
- let o = r + i;
523
- return o > 1 && (o = 1), o < -1 && (o = -1), Math.acos(o) * 6371e3;
797
+ transformLat(t, e) {
798
+ let n = -100 + 2 * t + 3 * e + 0.2 * e * e + 0.1 * t * e + 0.2 * Math.sqrt(Math.abs(t));
799
+ return n += (20 * Math.sin(6 * t * this.PI) + 20 * Math.sin(2 * t * this.PI)) * 2 / 3, n += (20 * Math.sin(e * this.PI) + 40 * Math.sin(e / 3 * this.PI)) * 2 / 3, n += (160 * Math.sin(e / 12 * this.PI) + 320 * Math.sin(e * this.PI / 30)) * 2 / 3, n;
524
800
  },
525
- outOfChina(e, t) {
526
- return t < 72.004 || t > 137.8347 || e < 0.8293 || e > 55.8271;
527
- },
528
- transformLat(e, t) {
529
- let n = -100 + 2 * e + 3 * t + 0.2 * t * t + 0.1 * e * t + 0.2 * Math.sqrt(Math.abs(e));
530
- return n += (20 * Math.sin(6 * e * this.PI) + 20 * Math.sin(2 * e * this.PI)) * 2 / 3, n += (20 * Math.sin(t * this.PI) + 40 * Math.sin(t / 3 * this.PI)) * 2 / 3, n += (160 * Math.sin(t / 12 * this.PI) + 320 * Math.sin(t * this.PI / 30)) * 2 / 3, n;
531
- },
532
- transformLon(e, t) {
533
- let n = 300 + e + 2 * t + 0.1 * e * e + 0.1 * e * t + 0.1 * Math.sqrt(Math.abs(e));
534
- return n += (20 * Math.sin(6 * e * this.PI) + 20 * Math.sin(2 * e * this.PI)) * 2 / 3, n += (20 * Math.sin(e * this.PI) + 40 * Math.sin(e / 3 * this.PI)) * 2 / 3, n += (150 * Math.sin(e / 12 * this.PI) + 300 * Math.sin(e / 30 * this.PI)) * 2 / 3, n;
801
+ transformLon(t, e) {
802
+ let n = 300 + t + 2 * e + 0.1 * t * t + 0.1 * t * e + 0.1 * Math.sqrt(Math.abs(t));
803
+ return n += (20 * Math.sin(6 * t * this.PI) + 20 * Math.sin(2 * t * this.PI)) * 2 / 3, n += (20 * Math.sin(t * this.PI) + 40 * Math.sin(t / 3 * this.PI)) * 2 / 3, n += (150 * Math.sin(t / 12 * this.PI) + 300 * Math.sin(t / 30 * this.PI)) * 2 / 3, n;
535
804
  },
536
- randomCoordinate(e, t, n, s) {
805
+ randomCoordinate(t, e, n, s) {
537
806
  return {
538
- lat: Math.random() * (s - t) + t,
539
- lng: Math.random() * (n - e) + e
807
+ lat: Math.random() * (s - e) + e,
808
+ lng: Math.random() * (n - t) + t
540
809
  };
541
810
  }
811
+ }, B = {
812
+ /**
813
+ * 将RGB颜色值转换为十六进制颜色值
814
+ *
815
+ * @param rgb RGB颜色值数组,包含三个0-255之间的整数
816
+ * @returns 转换后的十六进制颜色值,以#开头
817
+ */
818
+ rgb2hex(t) {
819
+ var e = "#" + (16777216 + (t[0] << 16) + (t[1] << 8) + t[2]).toString(16).slice(1);
820
+ return e;
821
+ },
822
+ /**
823
+ * 将RGB颜色值转换为RGBA颜色值,并返回转换后的颜色值。
824
+ *
825
+ * @param rgbValue RGB颜色值,格式为"rgb(r, g, b)"。
826
+ * @returns 转换后的RGBA颜色值,格式为"rgba(r, g, b, 1)"。如果输入值不符合RGB格式,则返回原值。
827
+ */
828
+ rgbToRgba(t) {
829
+ const e = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(t);
830
+ return e ? `rgba(${e[1]}, 1)` : t;
831
+ },
832
+ /**
833
+ * 将十六进制颜色值转换为rgba格式的颜色值
834
+ *
835
+ * @param hexValue 十六进制颜色值,可带或不带#前缀,支持3位和6位表示
836
+ * @returns 返回rgba格式的颜色值,格式为rgba(r,g,b,1)
837
+ */
838
+ hexToRgba(t) {
839
+ const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, n = t.replace(e, (c, l, h, u) => l + l + h + h + u + u), r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);
840
+ if (!r)
841
+ return t;
842
+ const i = parseInt(r[1], 16), a = parseInt(r[2], 16), o = parseInt(r[3], 16);
843
+ return `rgba(${i},${a},${o},1)`;
844
+ },
845
+ /**
846
+ * 将 HSL 颜色值转换为 RGBA 颜色值
847
+ *
848
+ * @param hslValue HSL 颜色值字符串,格式为 "hsl(h, s%, l%)" 或 "hsla(h, s%, l%, a)",其中 h 为色相,s 为饱和度,l 为亮度,a 为透明度(可选)。
849
+ * @returns 转换后的 RGBA 颜色值字符串,格式为 "rgba(r, g, b, a)",其中 r、g、b 为红绿蓝分量,a 为透明度。若输入为空或无效,则返回 null。
850
+ */
851
+ hslToRgba(t) {
852
+ if (!t)
853
+ return null;
854
+ const e = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t);
855
+ if (!e)
856
+ return null;
857
+ const n = parseInt(e[1], 10) / 360, s = parseInt(e[2], 10) / 100, r = parseInt(e[3], 10) / 100, i = e[4] ? parseFloat(e[4]) : 1;
858
+ function a(h, u, d) {
859
+ return d < 0 && (d += 1), d > 1 && (d -= 1), d < 1 / 6 ? h + (u - h) * 6 * d : d < 1 / 2 ? u : d < 2 / 3 ? h + (u - h) * (2 / 3 - d) * 6 : h;
860
+ }
861
+ let o, c, l;
862
+ if (s === 0)
863
+ o = c = l = r;
864
+ else {
865
+ const h = r < 0.5 ? r * (1 + s) : r + s - r * s, u = 2 * r - h;
866
+ o = a(u, h, n + 1 / 3), c = a(u, h, n), l = a(u, h, n - 1 / 3);
867
+ }
868
+ return `rgba(${Math.round(o * 255)},${Math.round(c * 255)},${Math.round(l * 255)},${i})`;
869
+ },
870
+ isHex(t) {
871
+ return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t);
872
+ },
873
+ isRgb(t) {
874
+ return /^rgb/.test(t);
875
+ },
876
+ isHsl(t) {
877
+ return /^hsl/.test(t);
878
+ },
879
+ isColor(t) {
880
+ return this.isHex(t) || this.isRgb(t) || this.isHsl(t);
881
+ },
882
+ colorToRgb(t) {
883
+ if (this.isRgb(t)) return this.rgbToRgba(t);
884
+ if (this.isHex(t)) return this.hexToRgba(t);
885
+ if (this.isHsl(t)) return this.hslToRgba(t);
886
+ }
542
887
  };
543
- Date.prototype.format = function(e) {
544
- const t = {
888
+ Date.prototype.format = function(t) {
889
+ const e = {
545
890
  "M+": this.getMonth() + 1,
546
891
  // 月份
547
892
  "d+": this.getDate(),
@@ -559,48 +904,48 @@ Date.prototype.format = function(e) {
559
904
  S: this.getMilliseconds()
560
905
  // 毫秒
561
906
  };
562
- /(y+)/.test(e) && (e = e.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)));
563
- for (const n in t)
564
- if (new RegExp("(" + n + ")").test(e)) {
907
+ /(y+)/.test(t) && (t = t.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)));
908
+ for (const n in e)
909
+ if (new RegExp("(" + n + ")").test(t)) {
565
910
  const s = n.length === 1 ? 1 : Number(n.slice(1));
566
- e = e.replace(RegExp.$1, ("00" + t[n]).substr(("" + t[n]).length + s - (t[n] + "").length));
911
+ t = t.replace(RegExp.$1, ("00" + e[n]).substr(("" + e[n]).length + s - (e[n] + "").length));
567
912
  }
568
- return e;
913
+ return t;
569
914
  };
570
- Date.prototype.addDate = function(e, t) {
915
+ Date.prototype.addDate = function(t, e) {
571
916
  const n = new Date(this);
572
- switch (e) {
917
+ switch (t) {
573
918
  case "y":
574
- n.setFullYear(this.getFullYear() + t);
919
+ n.setFullYear(this.getFullYear() + e);
575
920
  break;
576
921
  case "q":
577
- n.setMonth(this.getMonth() + t * 3);
922
+ n.setMonth(this.getMonth() + e * 3);
578
923
  break;
579
924
  case "M":
580
- n.setMonth(this.getMonth() + t);
925
+ n.setMonth(this.getMonth() + e);
581
926
  break;
582
927
  case "w":
583
- n.setDate(this.getDate() + t * 7);
928
+ n.setDate(this.getDate() + e * 7);
584
929
  break;
585
930
  case "d":
586
- n.setDate(this.getDate() + t);
931
+ n.setDate(this.getDate() + e);
587
932
  break;
588
933
  case "h":
589
- n.setHours(this.getHours() + t);
934
+ n.setHours(this.getHours() + e);
590
935
  break;
591
936
  case "m":
592
- n.setMinutes(this.getMinutes() + t);
937
+ n.setMinutes(this.getMinutes() + e);
593
938
  break;
594
939
  case "s":
595
- n.setSeconds(this.getSeconds() + t);
940
+ n.setSeconds(this.getSeconds() + e);
596
941
  break;
597
942
  default:
598
- n.setDate(this.getDate() + t);
943
+ n.setDate(this.getDate() + e);
599
944
  break;
600
945
  }
601
946
  return n;
602
947
  };
603
- const at = {
948
+ const W = {
604
949
  lastMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1),
605
950
  thisMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
606
951
  nextMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 1),
@@ -610,28 +955,28 @@ const at = {
610
955
  lastDayDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() - 1),
611
956
  thisDayDate: new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)),
612
957
  nextDayDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1),
613
- parseDate(e) {
614
- if (typeof e == "string") {
615
- var t = e.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
616
- if (t && t.length > 3) return new Date(parseInt(t[1]), parseInt(t[2]) - 1, parseInt(t[3]));
617
- if (t = e.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/), t && t.length > 6)
958
+ parseDate(t) {
959
+ if (typeof t == "string") {
960
+ var e = t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
961
+ if (e && e.length > 3) return new Date(parseInt(e[1]), parseInt(e[2]) - 1, parseInt(e[3]));
962
+ if (e = t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/), e && e.length > 6)
618
963
  return new Date(
619
- parseInt(t[1]),
620
- parseInt(t[2]) - 1,
621
- parseInt(t[3]),
622
- parseInt(t[4]),
623
- parseInt(t[5]),
624
- parseInt(t[6])
964
+ parseInt(e[1]),
965
+ parseInt(e[2]) - 1,
966
+ parseInt(e[3]),
967
+ parseInt(e[4]),
968
+ parseInt(e[5]),
969
+ parseInt(e[6])
625
970
  );
626
- if (t = e.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/), t && t.length > 7)
971
+ if (e = t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/), e && e.length > 7)
627
972
  return new Date(
628
- parseInt(t[1]),
629
- parseInt(t[2]) - 1,
630
- parseInt(t[3]),
631
- parseInt(t[4]),
632
- parseInt(t[5]),
633
- parseInt(t[6]),
634
- parseInt(t[7])
973
+ parseInt(e[1]),
974
+ parseInt(e[2]) - 1,
975
+ parseInt(e[3]),
976
+ parseInt(e[4]),
977
+ parseInt(e[5]),
978
+ parseInt(e[6]),
979
+ parseInt(e[7])
635
980
  );
636
981
  }
637
982
  return null;
@@ -643,27 +988,27 @@ const at = {
643
988
  * @param {*} endTime
644
989
  * @returns {*}
645
990
  */
646
- formatDateInterval(e, t) {
647
- const n = new Date(e), a = new Date(t).getTime() - n.getTime(), r = Math.floor(a / (24 * 3600 * 1e3)), i = a % (24 * 3600 * 1e3), o = Math.floor(i / (3600 * 1e3)), c = i % (3600 * 1e3), l = Math.floor(c / (60 * 1e3)), h = c % (60 * 1e3), u = Math.round(h / 1e3);
991
+ formatDateInterval(t, e) {
992
+ const n = new Date(t), r = new Date(e).getTime() - n.getTime(), i = Math.floor(r / (24 * 3600 * 1e3)), a = r % (24 * 3600 * 1e3), o = Math.floor(a / (3600 * 1e3)), c = a % (3600 * 1e3), l = Math.floor(c / (60 * 1e3)), h = c % (60 * 1e3), u = Math.round(h / 1e3);
648
993
  let d = "";
649
- return r > 0 && (d += r + "天"), o > 0 && (d += o + "时"), l > 0 && (d += l + "分"), u > 0 && (d += u + "秒"), r === 0 && o === 0 && l === 0 && u === 0 && (d = "少于1秒"), d;
994
+ return i > 0 && (d += i + "天"), o > 0 && (d += o + "时"), l > 0 && (d += l + "分"), u > 0 && (d += u + "秒"), i === 0 && o === 0 && l === 0 && u === 0 && (d = "少于1秒"), d;
650
995
  },
651
- formatterCounter(e) {
652
- const t = function(o) {
996
+ formatterCounter(t) {
997
+ const e = function(o) {
653
998
  return (o > 10 ? "" : "0") + (o || 0);
654
- }, n = t(Math.floor(e / 3600)), s = e % 3600, a = t(Math.floor(s / 60)), r = s % 60, i = t(Math.round(r));
655
- return `${n}:${a}:${i}`;
999
+ }, n = e(Math.floor(t / 3600)), s = t % 3600, r = e(Math.floor(s / 60)), i = s % 60, a = e(Math.round(i));
1000
+ return `${n}:${r}:${a}`;
656
1001
  },
657
- sleep(e) {
1002
+ sleep(t) {
658
1003
  }
659
1004
  };
660
- function j(e) {
661
- return e.trim ? e.trim() : e.replace(/^\s+|\s+$/g, "");
1005
+ function O(t) {
1006
+ return t.trim ? t.trim() : t.replace(/^\s+|\s+$/g, "");
662
1007
  }
663
- function U(e) {
664
- return j(e).split(/\s+/);
1008
+ function R(t) {
1009
+ return O(t).split(/\s+/);
665
1010
  }
666
- const it = {
1011
+ const q = {
667
1012
  /**
668
1013
  * 获取元素的样式值
669
1014
  *
@@ -671,12 +1016,12 @@ const it = {
671
1016
  * @param style 样式属性名称
672
1017
  * @returns 元素的样式值,如果获取不到则返回 null
673
1018
  */
674
- getStyle(e, t) {
1019
+ getStyle(t, e) {
675
1020
  var s;
676
- let n = e.style[t];
1021
+ let n = t.style[e];
677
1022
  if (!n || n === "auto") {
678
- const a = (s = document.defaultView) == null ? void 0 : s.getComputedStyle(e, null);
679
- n = a ? a[t] : null, n === "auto" && (n = null);
1023
+ const r = (s = document.defaultView) == null ? void 0 : s.getComputedStyle(t, null);
1024
+ n = r ? r[e] : null, n === "auto" && (n = null);
680
1025
  }
681
1026
  return n;
682
1027
  },
@@ -688,45 +1033,45 @@ const it = {
688
1033
  * @param container 父容器,若传入,则新创建的元素会被添加到该容器中
689
1034
  * @returns 返回新创建的HTML元素
690
1035
  */
691
- create(e, t, n) {
692
- const s = document.createElement(e);
693
- return s.className = t || "", n && n.appendChild(s), s;
1036
+ create(t, e, n) {
1037
+ const s = document.createElement(t);
1038
+ return s.className = e || "", n && n.appendChild(s), s;
694
1039
  },
695
1040
  /**
696
1041
  * 从父节点中移除指定元素。
697
1042
  *
698
1043
  * @param el 要移除的元素对象,必须包含parentNode属性。
699
1044
  */
700
- remove(e) {
701
- const t = e.parentNode;
702
- t && t.removeChild(e);
1045
+ remove(t) {
1046
+ const e = t.parentNode;
1047
+ e && e.removeChild(t);
703
1048
  },
704
1049
  /**
705
1050
  * 清空给定元素的子节点
706
1051
  *
707
1052
  * @param el 要清空子节点的元素,包含firstChild和removeChild属性
708
1053
  */
709
- empty(e) {
710
- for (; e.firstChild; )
711
- e.removeChild(e.firstChild);
1054
+ empty(t) {
1055
+ for (; t.firstChild; )
1056
+ t.removeChild(t.firstChild);
712
1057
  },
713
1058
  /**
714
1059
  * 将元素移到父节点的最前面
715
1060
  *
716
1061
  * @param el 要移动的元素,需要包含 parentNode 属性
717
1062
  */
718
- toFront(e) {
719
- const t = e.parentNode;
720
- t && t.lastChild !== e && t.appendChild(e);
1063
+ toFront(t) {
1064
+ const e = t.parentNode;
1065
+ e && e.lastChild !== t && e.appendChild(t);
721
1066
  },
722
1067
  /**
723
1068
  * 将元素移动到其父节点的最前面
724
1069
  *
725
1070
  * @param el 要移动的元素,需要包含parentNode属性
726
1071
  */
727
- toBack(e) {
728
- const t = e.parentNode;
729
- t && t.firstChild !== e && t.insertBefore(e, t.firstChild);
1072
+ toBack(t) {
1073
+ const e = t.parentNode;
1074
+ e && e.firstChild !== t && e.insertBefore(t, e.firstChild);
730
1075
  },
731
1076
  /**
732
1077
  * 获取元素的类名
@@ -737,8 +1082,8 @@ const it = {
737
1082
  * @param el.className.baseVal 类名字符串
738
1083
  * @returns 返回元素的类名字符串
739
1084
  */
740
- getClass(e) {
741
- return ((e == null ? void 0 : e.host) || e).className.toString();
1085
+ getClass(t) {
1086
+ return ((t == null ? void 0 : t.host) || t).className.toString();
742
1087
  },
743
1088
  /**
744
1089
  * 判断元素是否包含指定类名
@@ -747,12 +1092,12 @@ const it = {
747
1092
  * @param name 要判断的类名
748
1093
  * @returns 返回一个布尔值,表示元素是否包含指定类名
749
1094
  */
750
- hasClass(e, t) {
1095
+ hasClass(t, e) {
751
1096
  var s;
752
- if ((s = e.classList) != null && s.contains(t))
1097
+ if ((s = t.classList) != null && s.contains(e))
753
1098
  return !0;
754
- const n = this.getClass(e);
755
- return n.length > 0 && new RegExp(`(^|\\s)${t}(\\s|$)`).test(n);
1099
+ const n = this.getClass(t);
1100
+ return n.length > 0 && new RegExp(`(^|\\s)${e}(\\s|$)`).test(n);
756
1101
  },
757
1102
  /**
758
1103
  * 给指定的 HTML 元素添加类名
@@ -760,92 +1105,44 @@ const it = {
760
1105
  * @param el 要添加类名的 HTML 元素
761
1106
  * @param name 要添加的类名,多个类名之间用空格分隔
762
1107
  */
763
- addClass(e, t) {
764
- if (e.classList !== void 0) {
765
- const n = U(t);
766
- for (let s = 0, a = n.length; s < a; s++)
767
- e.classList.add(n[s]);
768
- } else if (!this.hasClass(e, t)) {
769
- const n = this.getClass(e);
770
- this.setClass(e, (n ? n + " " : "") + t);
1108
+ addClass(t, e) {
1109
+ if (t.classList !== void 0) {
1110
+ const n = R(e);
1111
+ for (let s = 0, r = n.length; s < r; s++)
1112
+ t.classList.add(n[s]);
1113
+ } else if (!this.hasClass(t, e)) {
1114
+ const n = this.getClass(t);
1115
+ this.setClass(t, (n ? n + " " : "") + e);
771
1116
  }
772
1117
  },
773
1118
  /**
774
1119
  * 从元素中移除指定类名
775
1120
  *
776
1121
  * @param el 要移除类名的元素
777
- * @param name 要移除的类名,多个类名用空格分隔
778
- */
779
- removeClass(e, t) {
780
- e.classList !== void 0 ? U(t).forEach((s) => e.classList.remove(s)) : this.setClass(e, (" " + this.getClass(e) + " ").replace(" " + t + " ", " ").trim());
781
- },
782
- /**
783
- * 设置元素的 CSS 类名
784
- *
785
- * @param el HTML 或 SVG 元素
786
- * @param name 要设置的类名,多个类名之间用空格分隔
787
- */
788
- setClass(e, t) {
789
- "classList" in e && (e.classList.value = "", t.split(" ").forEach((n) => e.classList.add(n)));
790
- },
791
- /**
792
- * 从字符串中解析XML文档,并返回根节点
793
- *
794
- * @param str 要解析的XML字符串
795
- * @returns 解析后的XML文档的根节点
796
- */
797
- parseFromString(e) {
798
- return new DOMParser().parseFromString(e, "text/xml").children[0];
799
- }
800
- }, g = {
801
- DEG2RAD: Math.PI / 180,
802
- RAD2DEG: 180 / Math.PI,
803
- randInt(e, t) {
804
- return e + Math.floor(Math.random() * (t - e + 1));
805
- },
806
- randFloat(e, t) {
807
- return e + Math.random() * (t - e);
808
- },
809
- /**
810
- * 角度转弧度
811
- *
812
- * @param {*} degrees
813
- * @returns {*}
814
- */
815
- degreesToRadians(e) {
816
- return e * this.DEG2RAD;
817
- },
818
- /**
819
- * 角度转弧度
820
- *
821
- * @param {*} degrees
822
- * @returns {*}
1122
+ * @param name 要移除的类名,多个类名用空格分隔
823
1123
  */
824
- toRadians(e) {
825
- return e * this.DEG2RAD;
1124
+ removeClass(t, e) {
1125
+ t.classList !== void 0 ? R(e).forEach((s) => t.classList.remove(s)) : this.setClass(t, (" " + this.getClass(t) + " ").replace(" " + e + " ", " ").trim());
826
1126
  },
827
1127
  /**
828
- * 弧度转角度
1128
+ * 设置元素的 CSS 类名
829
1129
  *
830
- * @param {*} radians
831
- * @returns {*}
1130
+ * @param el HTML 或 SVG 元素
1131
+ * @param name 要设置的类名,多个类名之间用空格分隔
832
1132
  */
833
- radiansToDegrees(e) {
834
- return e * this.RAD2DEG;
1133
+ setClass(t, e) {
1134
+ "classList" in t && (t.classList.value = "", e.split(" ").forEach((n) => t.classList.add(n)));
835
1135
  },
836
1136
  /**
837
- * 弧度转角度
1137
+ * 从字符串中解析XML文档,并返回根节点
838
1138
  *
839
- * @param {*} radians
840
- * @returns {*}
1139
+ * @param str 要解析的XML字符串
1140
+ * @returns 解析后的XML文档的根节点
841
1141
  */
842
- toDegrees(e) {
843
- return e * this.RAD2DEG;
844
- },
845
- formatFloat(e, t = 2) {
846
- return Math.round(e * Math.pow(10, t)) / Math.pow(10, t);
1142
+ parseFromString(t) {
1143
+ return new DOMParser().parseFromString(t, "text/xml").children[0];
847
1144
  }
848
- }, q = {
1145
+ }, G = {
849
1146
  toRadian: Math.PI / 180,
850
1147
  R: 6371393,
851
1148
  /**
@@ -855,8 +1152,40 @@ const it = {
855
1152
  * @param lat 纬度值
856
1153
  * @returns 如果经纬度合法,返回true;否则返回false
857
1154
  */
858
- isLnglat(e, t) {
859
- return !isNaN(e) && !isNaN(t) && +t > -90 && +t < 90 && +e > -180 && +e < 180;
1155
+ isLnglat(t, e) {
1156
+ return !isNaN(t) && !isNaN(e) && +e > -90 && +e < 90 && +t > -180 && +t < 180;
1157
+ },
1158
+ /**
1159
+ * 判断经纬度是否不在中国境内
1160
+ *
1161
+ * @param lng 经度
1162
+ * @param lat 纬度
1163
+ * @returns 如果经纬度不在中国境内则返回true,否则返回false
1164
+ */
1165
+ outOfChina({ lng: t, lat: e }) {
1166
+ return t < 72.004 || t > 137.8347 || e < 0.8293 || e > 55.8271;
1167
+ },
1168
+ /**
1169
+ * 计算两哥平面坐标点间的距离
1170
+ *
1171
+ * @param p1 坐标点1,包含x和y属性
1172
+ * @param p2 坐标点2,包含x和y属性
1173
+ * @returns 返回两点间的欧几里得距离
1174
+ */
1175
+ distance(t, e) {
1176
+ return Math.sqrt(Math.pow(e.x - t.x, 2) + Math.pow(e.y - t.y, 2));
1177
+ },
1178
+ /**
1179
+ * 计算两个经纬度点之间的距离
1180
+ *
1181
+ * @param A 经纬度点A,包含lng(经度)和lat(纬度)两个属性
1182
+ * @param B 经纬度点B,包含lng(经度)和lat(纬度)两个属性
1183
+ * @returns 返回两点之间的距离,单位为米
1184
+ */
1185
+ distanceByPoints(t, e) {
1186
+ const { lng: n, lat: s } = t, { lng: r, lat: i } = e, a = 6371e3, o = Math.cos(s * Math.PI / 180) * Math.cos(i * Math.PI / 180) * Math.cos((n - r) * Math.PI / 180), c = Math.sin(s * Math.PI / 180) * Math.sin(i * Math.PI / 180);
1187
+ let l = o + c;
1188
+ return l > 1 && (l = 1), l < -1 && (l = -1), Math.acos(l) * a;
860
1189
  },
861
1190
  /**
862
1191
  * 格式化经纬度为度分秒格式
@@ -865,13 +1194,13 @@ const it = {
865
1194
  * @param lat 纬度
866
1195
  * @returns 返回格式化后的经纬度字符串,格式为:经度度分秒,纬度度分秒
867
1196
  */
868
- formatLnglat(e, t) {
1197
+ formatLnglat(t, e) {
869
1198
  let n = "";
870
- function s(a) {
871
- const r = Math.floor(a), i = Math.floor((a - r) * 60), o = (a - r) * 3600 - i * 60;
872
- return `${r}°${i}′${o.toFixed(2)}″`;
1199
+ function s(r) {
1200
+ const i = Math.floor(r), a = Math.floor((r - i) * 60), o = (r - i) * 3600 - a * 60;
1201
+ return `${i}°${a}′${o.toFixed(2)}″`;
873
1202
  }
874
- return this.isLnglat(e, t) ? n = s(e) + "," + s(t) : isNaN(e) ? isNaN(t) || (n = s(t)) : n = s(e), n;
1203
+ return this.isLnglat(t, e) ? n = s(t) + "," + s(e) : isNaN(t) ? isNaN(e) || (n = s(e)) : n = s(t), n;
875
1204
  },
876
1205
  /**
877
1206
  * 将经纬度字符串转换为度
@@ -880,19 +1209,19 @@ const it = {
880
1209
  * @param lat 纬度字符串
881
1210
  * @returns 转换后的经纬度对象
882
1211
  */
883
- transformLnglat(e, t) {
1212
+ transformLnglat(t, e) {
884
1213
  function n(s) {
885
- let r = /[sw]/i.test(s) ? -1 : 1;
886
- const i = s.match(/[\d.]+/g) || [];
1214
+ let i = /[sw]/i.test(s) ? -1 : 1;
1215
+ const a = s.match(/[\d.]+/g) || [];
887
1216
  let o = 0;
888
- for (let c = 0; c < i.length; c++)
889
- o += parseFloat(i[c]) / r, r *= 60;
1217
+ for (let c = 0; c < a.length; c++)
1218
+ o += parseFloat(a[c]) / i, i *= 60;
890
1219
  return o;
891
1220
  }
892
- if (e && t)
1221
+ if (t && e)
893
1222
  return {
894
- lng: n(e),
895
- lat: n(t)
1223
+ lng: n(t),
1224
+ lat: n(e)
896
1225
  };
897
1226
  },
898
1227
  /**
@@ -902,50 +1231,19 @@ const it = {
902
1231
  * @param poly 多边形顶点数组,可以是字符串数组或对象数组
903
1232
  * @returns 返回字符串,表示点相对于多边形的位置:'in'表示在多边形内,'out'表示在多边形外,'on'表示在多边形上
904
1233
  */
905
- rayCasting(e, t) {
906
- for (var n = e.x, s = e.y, a = !1, r = 0, i = t.length, o = i - 1; r < i; o = r, r++) {
907
- var c = t[r].x, l = t[r].y, h = t[o].x, u = t[o].y;
1234
+ rayCasting(t, e) {
1235
+ for (var n = t.x, s = t.y, r = !1, i = 0, a = e.length, o = a - 1; i < a; o = i, i++) {
1236
+ var c = e[i].x, l = e[i].y, h = e[o].x, u = e[o].y;
908
1237
  if (c === n && l === s || h === n && u === s)
909
1238
  return "on";
910
1239
  if (l < s && u >= s || l >= s && u < s) {
911
1240
  var d = c + (s - l) * (h - c) / (u - l);
912
1241
  if (d === n)
913
1242
  return "on";
914
- d > n && (a = !a);
1243
+ d > n && (r = !r);
915
1244
  }
916
1245
  }
917
- return a ? "in" : "out";
918
- },
919
- /**
920
- * 计算两个WGS-84坐标点之间的距离
921
- *
922
- * @param fromPoint 起始点坐标
923
- * @param toPoint 目标点坐标
924
- * @returns 返回两个坐标点之间的距离,单位为米
925
- */
926
- wgs84PointsDistance(e, t) {
927
- var n = Math.PI;
928
- function s(G) {
929
- return G * n / 180;
930
- }
931
- if (arguments.length != 2)
932
- return 0;
933
- const a = e.x, r = e.y, i = t.x, o = t.y;
934
- var c = 6378137, l = 63567523142e-4, h = 1 / 298.257223563, u = s(i - a), d = Math.atan((1 - h) * Math.tan(s(r))), R = Math.atan((1 - h) * Math.tan(s(o))), O = Math.sin(d), v = Math.cos(d), A = Math.sin(R), w = Math.cos(R), D = u, L, N = 100;
935
- do {
936
- var I = Math.sin(D), T = Math.cos(D), y = Math.sqrt(
937
- w * I * (w * I) + (v * A - O * w * T) * (v * A - O * w * T)
938
- );
939
- if (y == 0) return 0;
940
- var S = O * A + v * w * T, k = Math.atan2(y, S), C = v * w * I / y, b = 1 - C * C, m = S - 2 * O * A / b;
941
- isNaN(m) && (m = 0);
942
- var _ = h / 16 * b * (4 + h * (4 - 3 * b));
943
- L = D, D = u + (1 - _) * h * C * (k + _ * y * (m + _ * S * (-1 + 2 * m * m)));
944
- } while (Math.abs(D - L) > 1e-12 && --N > 0);
945
- if (N == 0)
946
- return NaN;
947
- var M = b * (c * c - l * l) / (l * l), $ = 1 + M / 16384 * (4096 + M * (-768 + M * (320 - 175 * M))), P = M / 1024 * (256 + M * (-128 + M * (74 - 47 * M))), B = P * y * (m + P / 4 * (S * (-1 + 2 * m * m) - P / 6 * m * (-3 + 4 * y * y) * (-3 + 4 * m * m))), W = l * $ * (k - B);
948
- return W;
1246
+ return r ? "in" : "out";
949
1247
  },
950
1248
  /**
951
1249
  * 旋转点
@@ -955,9 +1253,9 @@ const it = {
955
1253
  * @param θ 旋转角度(顺时针旋转为正)
956
1254
  * @returns 旋转后点坐标
957
1255
  */
958
- rotatePoint(e, t, n) {
959
- const s = (e.x - t.x) * Math.cos(Math.PI / 180 * -n) - (e.y - t.y) * Math.sin(Math.PI / 180 * -n) + t.x, a = (e.x - t.x) * Math.sin(Math.PI / 180 * -n) + (e.y - t.y) * Math.cos(Math.PI / 180 * -n) + t.y;
960
- return { x: s, y: a };
1256
+ rotatePoint(t, e, n) {
1257
+ const s = (t.x - e.x) * Math.cos(Math.PI / 180 * -n) - (t.y - e.y) * Math.sin(Math.PI / 180 * -n) + e.x, r = (t.x - e.x) * Math.sin(Math.PI / 180 * -n) + (t.y - e.y) * Math.cos(Math.PI / 180 * -n) + e.y;
1258
+ return { x: s, y: r };
961
1259
  },
962
1260
  /**
963
1261
  * 根据两个平面坐标点计算方位角和距离
@@ -966,9 +1264,9 @@ const it = {
966
1264
  * @param p2 第二个点的坐标对象
967
1265
  * @returns 返回一个对象,包含angle和distance属性,分别表示两点之间的角度(以度为单位,取值范围为0~359)和距离
968
1266
  */
969
- calcBearAndDis(e, t) {
970
- const { x: n, y: s } = e, { x: a, y: r } = t, i = a - n, o = r - s, c = Math.sqrt(i * i + o * o);
971
- return { angle: (Math.atan2(o, i) * (180 / Math.PI) + 360 + 90) % 360, distance: c };
1267
+ calcBearAndDis(t, e) {
1268
+ const { x: n, y: s } = t, { x: r, y: i } = e, a = r - n, o = i - s, c = Math.sqrt(a * a + o * o);
1269
+ return { angle: (Math.atan2(o, a) * (180 / Math.PI) + 360 + 90) % 360, distance: c };
972
1270
  },
973
1271
  /**
974
1272
  * 根据两个经纬度点计算方位角和距离
@@ -977,13 +1275,31 @@ const it = {
977
1275
  * @param latlng2 第二个经纬度点
978
1276
  * @returns 包含方位角和距离的对象
979
1277
  */
980
- calcBearAndDisByPoints(e, t) {
981
- var n = e.lat * 1, s = e.lng * 1, a = t.lat * 1, r = t.lng * 1, i = Math.sin((r - s) * this.toRadian) * Math.cos(a * this.toRadian), o = Math.cos(n * this.toRadian) * Math.sin(a * this.toRadian) - Math.sin(n * this.toRadian) * Math.cos(a * this.toRadian) * Math.cos((r - s) * this.toRadian), c = Math.atan2(i, o) * (180 / Math.PI), l = (a - n) * this.toRadian, h = (r - s) * this.toRadian, u = Math.sin(l / 2) * Math.sin(l / 2) + Math.cos(n * this.toRadian) * Math.cos(a * this.toRadian) * Math.sin(h / 2) * Math.sin(h / 2), d = 2 * Math.atan2(Math.sqrt(u), Math.sqrt(1 - u)), R = this.R * d;
1278
+ calcBearAndDisByPoints(t, e) {
1279
+ var n = t.lat * 1, s = t.lng * 1, r = e.lat * 1, i = e.lng * 1, a = Math.sin((i - s) * this.toRadian) * Math.cos(r * this.toRadian), o = Math.cos(n * this.toRadian) * Math.sin(r * this.toRadian) - Math.sin(n * this.toRadian) * Math.cos(r * this.toRadian) * Math.cos((i - s) * this.toRadian), c = Math.atan2(a, o) * (180 / Math.PI), l = (r - n) * this.toRadian, h = (i - s) * this.toRadian, u = Math.sin(l / 2) * Math.sin(l / 2) + Math.cos(n * this.toRadian) * Math.cos(r * this.toRadian) * Math.sin(h / 2) * Math.sin(h / 2), d = 2 * Math.atan2(Math.sqrt(u), Math.sqrt(1 - u)), g = this.R * d;
982
1280
  return {
983
1281
  angle: c,
984
- distance: R
1282
+ distance: g
985
1283
  };
986
1284
  },
1285
+ /**
1286
+ * 计算点P到线段P1P2的最短距离
1287
+ *
1288
+ * @param p 点P的坐标
1289
+ * @param p1 线段起点P1的坐标
1290
+ * @param p2 线段终点P2的坐标
1291
+ * @returns 点P到线段P1P2的最短距离
1292
+ */
1293
+ distanceToSegment(t, e, n) {
1294
+ const s = t.x, r = t.y, i = e.x, a = e.y, o = n.x, c = n.y, l = (o - i) * (s - i) + (c - a) * (r - a);
1295
+ if (l <= 0)
1296
+ return Math.sqrt((s - i) * (s - i) + (r - a) * (r - a));
1297
+ const h = (o - i) * (o - i) + (c - a) * (c - a);
1298
+ if (l >= h)
1299
+ return Math.sqrt((s - o) * (s - o) + (r - c) * (r - c));
1300
+ const u = l / h, d = i + (o - i) * u, g = a + (c - a) * u;
1301
+ return Math.sqrt((s - d) * (s - d) + (r - g) * (r - g));
1302
+ },
987
1303
  /**
988
1304
  * 根据给定的经纬度、角度和距离计算新的经纬度点
989
1305
  *
@@ -992,13 +1308,13 @@ const it = {
992
1308
  * @param distance 距离值,单位为米,表示从当前点出发的距离
993
1309
  * @returns 返回计算后的新经纬度点,类型为{lat: number, lng: number}
994
1310
  */
995
- calcPointByBearAndDis(e, t, n) {
996
- const s = g.toRadians(e.lat * 1), a = g.toRadians(e.lng * 1), r = n / this.R;
997
- t = g.toRadians(t);
998
- const i = Math.asin(Math.sin(s) * Math.cos(r) + Math.cos(s) * Math.sin(r) * Math.cos(t)), o = a + Math.atan2(Math.sin(t) * Math.sin(r) * Math.cos(s), Math.cos(r) - Math.sin(s) * Math.sin(i));
1311
+ calcPointByBearAndDis(t, e, n) {
1312
+ const s = m.toRadians(t.lat * 1), r = m.toRadians(t.lng * 1), i = n / this.R;
1313
+ e = m.toRadians(e);
1314
+ const a = Math.asin(Math.sin(s) * Math.cos(i) + Math.cos(s) * Math.sin(i) * Math.cos(e)), o = r + Math.atan2(Math.sin(e) * Math.sin(i) * Math.cos(s), Math.cos(i) - Math.sin(s) * Math.sin(a));
999
1315
  return {
1000
- lat: g.toDegrees(i),
1001
- lng: g.toDegrees(o)
1316
+ lat: m.toDegrees(a),
1317
+ lng: m.toDegrees(o)
1002
1318
  };
1003
1319
  },
1004
1320
  /**
@@ -1008,11 +1324,11 @@ const it = {
1008
1324
  * @param y 墨卡托坐标的y值
1009
1325
  * @returns 返回包含转换后的经度lng和纬度lat的对象
1010
1326
  */
1011
- mercatorTolonlat(e, t) {
1012
- const n = e / 2003750834e-2 * 180;
1013
- var s = t / 2003750834e-2 * 180;
1014
- const a = 180 / Math.PI * (2 * Math.atan(Math.exp(s * Math.PI / 180)) - Math.PI / 2);
1015
- return { lng: n, lat: a };
1327
+ mercatorTolonlat(t, e) {
1328
+ const n = t / 2003750834e-2 * 180;
1329
+ var s = e / 2003750834e-2 * 180;
1330
+ const r = 180 / Math.PI * (2 * Math.atan(Math.exp(s * Math.PI / 180)) - Math.PI / 2);
1331
+ return { lng: n, lat: r };
1016
1332
  },
1017
1333
  /**
1018
1334
  * 将经纬度坐标转换为墨卡托坐标
@@ -1021,26 +1337,33 @@ const it = {
1021
1337
  * @param lat 纬度值
1022
1338
  * @returns 墨卡托坐标对象,包含x和y属性
1023
1339
  */
1024
- lonlatToMercator(e, t) {
1340
+ lonlatToMercator(t, e) {
1025
1341
  var n = 6378137;
1026
- const s = e * Math.PI / 180 * n;
1027
- var a = t * Math.PI / 180;
1028
- const r = n / 2 * Math.log((1 + Math.sin(a)) / (1 - Math.sin(a)));
1029
- return { x: s, y: r };
1342
+ const s = t * Math.PI / 180 * n;
1343
+ var r = e * Math.PI / 180;
1344
+ const i = n / 2 * Math.log((1 + Math.sin(r)) / (1 - Math.sin(r)));
1345
+ return { x: s, y: i };
1346
+ }
1347
+ }, H = {
1348
+ deepClone(t) {
1349
+ return structuredClone(t);
1350
+ },
1351
+ isEqual(t, e) {
1352
+ return JSON.stringify(t) === JSON.stringify(e);
1030
1353
  }
1031
- }, ot = {
1354
+ }, z = {
1032
1355
  /**
1033
1356
  * 将Base64编码的字符串转换为Blob对象
1034
1357
  *
1035
1358
  * @param data Base64编码的字符串
1036
1359
  * @returns 转换后的Blob对象
1037
1360
  */
1038
- convertBase64ToBlob(e) {
1039
- const t = e.split(",")[0].split(":")[1].split(";")[0], n = atob(e.split(",")[1]), s = new Array(n.length);
1040
- for (let i = 0; i < n.length; i++)
1041
- s[i] = n.charCodeAt(i);
1042
- const a = new Uint8Array(s);
1043
- return new Blob([a], { type: t });
1361
+ convertBase64ToBlob(t) {
1362
+ const e = t.split(",")[0].split(":")[1].split(";")[0], n = atob(t.split(",")[1]), s = new Array(n.length);
1363
+ for (let a = 0; a < n.length; a++)
1364
+ s[a] = n.charCodeAt(a);
1365
+ const r = new Uint8Array(s);
1366
+ return new Blob([r], { type: e });
1044
1367
  },
1045
1368
  /**
1046
1369
  * 将图片的URL转换为Base64编码
@@ -1050,25 +1373,25 @@ const it = {
1050
1373
  * @param height 图片的高度,默认为图片原始高度
1051
1374
  * @returns 返回Promise对象,解析后得到包含Base64编码数据的对象
1052
1375
  */
1053
- convertUrlToBase64(e, t, n) {
1054
- return new Promise((s, a) => {
1055
- var r = new Image();
1056
- r.crossOrigin = "Anonymous", r.src = e, r.onload = function() {
1057
- var i = document.createElement("canvas");
1058
- i.width = t || r.width, i.height = n || r.height;
1059
- var o = i.getContext("2d");
1376
+ convertUrlToBase64(t, e, n) {
1377
+ return new Promise((s, r) => {
1378
+ var i = new Image();
1379
+ i.crossOrigin = "Anonymous", i.src = t, i.onload = function() {
1380
+ var a = document.createElement("canvas");
1381
+ a.width = e || i.width, a.height = n || i.height;
1382
+ var o = a.getContext("2d");
1060
1383
  if (!o) {
1061
- a(new Error("Failed to get canvas context"));
1384
+ r(new Error("Failed to get canvas context"));
1062
1385
  return;
1063
1386
  }
1064
- o.drawImage(r, 0, 0, r.width, r.height);
1065
- var c = r.src.substring(r.src.lastIndexOf(".") + 1).toLowerCase(), l = i.toDataURL("image/" + c), h = {
1387
+ o.drawImage(i, 0, 0, i.width, i.height);
1388
+ var c = i.src.substring(i.src.lastIndexOf(".") + 1).toLowerCase(), l = a.toDataURL("image/" + c), h = {
1066
1389
  dataURL: l,
1067
1390
  type: "image/" + c,
1068
1391
  ext: c
1069
1392
  };
1070
1393
  s(h);
1071
- }, r.onerror = a;
1394
+ }, i.onerror = r;
1072
1395
  });
1073
1396
  },
1074
1397
  /**
@@ -1078,64 +1401,89 @@ const it = {
1078
1401
  * @param filename 文件的名称
1079
1402
  * @returns 返回文件对象
1080
1403
  */
1081
- convertBase64ToFile(e, t) {
1082
- const n = e.split(","), s = n[0].match(/:(.*?);/), a = s ? s[1] : "image/png", r = atob(n[1]), i = new Uint8Array(r.length);
1083
- for (let c = 0; c < r.length; c++)
1084
- i[c] = r.charCodeAt(c);
1085
- return new File([i], t, { type: a });
1404
+ convertBase64ToFile(t, e) {
1405
+ const n = t.split(","), s = n[0].match(/:(.*?);/), r = s ? s[1] : "image/png", i = atob(n[1]), a = new Uint8Array(i.length);
1406
+ for (let c = 0; c < i.length; c++)
1407
+ a[c] = i.charCodeAt(c);
1408
+ return new File([a], e, { type: r });
1086
1409
  },
1087
1410
  /**
1088
- * 直接下载文件,支持blob类型和url类型
1411
+ * 从文件下载数据
1089
1412
  *
1090
- * @param {*} data
1091
- * @param {*} saveName
1413
+ * @param data 要下载的数据,可以是字符串数组、BlobPart 或 MediaSource
1414
+ * @param saveName 下载后文件的保存名称
1092
1415
  */
1093
- downloadFromFile(e, t) {
1094
- if (typeof e == "object")
1095
- if (e instanceof Blob)
1096
- e = URL.createObjectURL(e);
1416
+ downloadFromFile(t, e) {
1417
+ if (typeof t == "object")
1418
+ if (t instanceof Blob)
1419
+ t = URL.createObjectURL(t);
1097
1420
  else {
1098
- const s = JSON.stringify(e), a = new Blob([s], { type: "text/json" });
1099
- e = window.URL.createObjectURL(a);
1421
+ const s = JSON.stringify(t), r = new Blob([s], { type: "text/json" });
1422
+ t = window.URL.createObjectURL(r);
1100
1423
  }
1101
- else if (typeof e == "string" && e.indexOf("http") === -1) {
1102
- const s = new Blob([e], { type: "text/json" });
1103
- e = window.URL.createObjectURL(s);
1424
+ else if (typeof t == "string" && t.indexOf("http") === -1) {
1425
+ const s = new Blob([t], { type: "text/json" });
1426
+ t = window.URL.createObjectURL(s);
1104
1427
  }
1105
1428
  var n = document.createElement("a");
1106
- n.href = e, n.download = t || "", n.click(), window.URL.revokeObjectURL(n.href);
1429
+ n.href = t, n.download = e || "", n.click(), window.URL.revokeObjectURL(n.href);
1107
1430
  }
1108
- }, ct = {
1431
+ }, j = {
1109
1432
  /**
1110
- * 防抖函数,在指定的等待时间内,如果连续触发事件,则只在最后一次触发后执行函数。
1433
+ * 防抖函数,在指定的等待时间内,如果连续触发事件,则只在最后一次触发后执行函数。适用于像搜索输入框这种需要用户停止输入后才调用的场景
1111
1434
  *
1112
1435
  * @param func 需要防抖的函数。
1113
1436
  * @param wait 等待时间,单位毫秒。
1114
1437
  * @param immediate 是否立即执行函数,默认为true。
1115
1438
  * @returns 返回防抖后的函数。
1116
1439
  */
1117
- debounce(e, t, n = !0) {
1118
- let s = null, a, r, i, o;
1119
- const c = function() {
1120
- const l = Date.now() - i;
1121
- l < t && l > 0 ? s = setTimeout(c, t - l) : (s = null, n || (o = e.apply(r, a)));
1440
+ debounce(t, e, n = !0) {
1441
+ let s = null, r, i, a;
1442
+ const o = () => {
1443
+ const c = Date.now() - i;
1444
+ c < e && c > 0 ? s = setTimeout(o, e - c) : (s = null, n || (a = t.apply(this, r)));
1122
1445
  };
1123
- return function(...l) {
1124
- r = this, i = Date.now();
1125
- const h = n && !s;
1126
- return s || (s = setTimeout(c, t)), h && (o = e.apply(r, l), s || (r = l = null)), o;
1446
+ return (...c) => {
1447
+ i = Date.now();
1448
+ const l = n && !s;
1449
+ return s || (s = setTimeout(o, e)), l && (a = t.apply(this, c), s || (c = null)), a;
1127
1450
  };
1128
1451
  },
1129
- throttle(e, t, n) {
1130
- let s = 0, a = null;
1131
- return function(...r) {
1132
- const i = this;
1452
+ /**
1453
+ * 节流函数,适用于像滚动事件、窗口resize事件这种需要限制调用频率的场景
1454
+ *
1455
+ * @param func 需要节流的函数
1456
+ * @param wait 节流间隔,单位为毫秒
1457
+ * @param type 节流类型,1表示时间戳方式,2表示定时器方式
1458
+ * @returns 返回一个新的函数,该函数在节流控制下执行传入的函数
1459
+ */
1460
+ throttle(t, e, n = 1) {
1461
+ let s = 0, r = null;
1462
+ return (...i) => {
1133
1463
  if (n === 1) {
1134
- const o = Date.now();
1135
- o - s > t && (e.apply(i, r), s = o);
1136
- } else n === 2 && (a || (a = setTimeout(() => {
1137
- a = null, e.apply(i, r);
1138
- }, t)));
1464
+ const a = Date.now();
1465
+ a - s >= e && (t.apply(this, i), s = a);
1466
+ } else n === 2 && (r || (r = setTimeout(() => {
1467
+ r = null, t.apply(this, i);
1468
+ }, e)));
1469
+ };
1470
+ },
1471
+ /**
1472
+ * 缓存函数,将传入的函数fn的计算结果缓存,提高重复计算的效率
1473
+ *
1474
+ * @param fn 传入待缓存的函数
1475
+ * @returns 返回缓存后的函数
1476
+ */
1477
+ memoize(t) {
1478
+ const e = /* @__PURE__ */ new Map();
1479
+ return (...n) => {
1480
+ const s = JSON.stringify(n);
1481
+ if (e.has(s))
1482
+ return e.get(s);
1483
+ {
1484
+ const r = t.apply(this, n);
1485
+ return e.set(s, r), r;
1486
+ }
1139
1487
  };
1140
1488
  },
1141
1489
  /**
@@ -1145,13 +1493,13 @@ const it = {
1145
1493
  * @param frequency 每次调用函数之间的时间间隔,单位为毫秒,默认为500毫秒。
1146
1494
  * @param duration 函数递归调用的总时长,单位为毫秒,默认为5000毫秒。
1147
1495
  */
1148
- recurve(e, t = 500, n = 5e3) {
1496
+ recurve(t, e = 500, n = 5e3) {
1149
1497
  let s = 0;
1150
1498
  setTimeout(() => {
1151
- s++, s < Math.floor(n / t) && (e.call(this), setTimeout(this.recurve.bind(this, e, t, n), t));
1152
- }, t);
1499
+ s++, s < Math.floor(n / e) && (t.call(this), setTimeout(this.recurve.bind(this, t, e, n), e));
1500
+ }, e);
1153
1501
  }
1154
- }, Y = {
1502
+ }, K = {
1155
1503
  /**
1156
1504
  * 校验字符串是否符合指定类型
1157
1505
  *
@@ -1176,42 +1524,42 @@ const it = {
1176
1524
  * - 'HTML': HTML标记
1177
1525
  * @returns 校验结果,符合返回true,否则返回false
1178
1526
  */
1179
- checkStr(e, t) {
1180
- switch (t) {
1527
+ checkStr(t, e) {
1528
+ switch (e) {
1181
1529
  case "phone":
1182
- return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(e);
1530
+ return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(t);
1183
1531
  case "tel":
1184
- return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(e);
1532
+ return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(t);
1185
1533
  case "card":
1186
- return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(e);
1534
+ return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(t);
1187
1535
  case "pwd":
1188
- return /^[a-zA-Z]\w{5,17}$/.test(e);
1536
+ return /^[a-zA-Z]\w{5,17}$/.test(t);
1189
1537
  case "postal":
1190
- return /[1-9]\d{5}(?!\d)/.test(e);
1538
+ return /[1-9]\d{5}(?!\d)/.test(t);
1191
1539
  case "QQ":
1192
- return /^[1-9][0-9]{4,9}$/.test(e);
1540
+ return /^[1-9][0-9]{4,9}$/.test(t);
1193
1541
  case "email":
1194
- return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(e);
1542
+ return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(t);
1195
1543
  case "money":
1196
- return /^\d*(?:\.\d{0,2})?$/.test(e);
1544
+ return /^\d*(?:\.\d{0,2})?$/.test(t);
1197
1545
  case "URL":
1198
- return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(e);
1546
+ return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(t);
1199
1547
  case "IP":
1200
- return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(e);
1548
+ return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(t);
1201
1549
  case "date":
1202
- return /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(e) || /^(\d{4})\-(\d{2})\-(\d{2})$/.test(e);
1550
+ return /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(t) || /^(\d{4})\-(\d{2})\-(\d{2})$/.test(t);
1203
1551
  case "number":
1204
- return /^[0-9]$/.test(e);
1552
+ return /^[0-9]$/.test(t);
1205
1553
  case "english":
1206
- return /^[a-zA-Z]+$/.test(e);
1554
+ return /^[a-zA-Z]+$/.test(t);
1207
1555
  case "chinese":
1208
- return /^[\u4E00-\u9FA5]+$/.test(e);
1556
+ return /^[\u4E00-\u9FA5]+$/.test(t);
1209
1557
  case "lower":
1210
- return /^[a-z]+$/.test(e);
1558
+ return /^[a-z]+$/.test(t);
1211
1559
  case "upper":
1212
- return /^[A-Z]+$/.test(e);
1560
+ return /^[A-Z]+$/.test(t);
1213
1561
  case "HTML":
1214
- return /<("[^"]*"|'[^']*'|[^'">])*>/.test(e);
1562
+ return /<("[^"]*"|'[^']*'|[^'">])*>/.test(t);
1215
1563
  default:
1216
1564
  return !0;
1217
1565
  }
@@ -1228,26 +1576,26 @@ const it = {
1228
1576
  * 5:全部小写
1229
1577
  * @returns 转换后的字符串
1230
1578
  */
1231
- changeCase(e, t) {
1232
- switch (t = t || 4, t) {
1579
+ changeCase(t, e) {
1580
+ switch (e = e || 4, e) {
1233
1581
  case 1:
1234
- return e.replace(/\b\w+\b/g, function(n) {
1582
+ return t.replace(/\b\w+\b/g, function(n) {
1235
1583
  return n.substring(0, 1).toUpperCase() + n.substring(1).toLowerCase();
1236
1584
  });
1237
1585
  case 2:
1238
- return e.replace(/\b\w+\b/g, function(n) {
1586
+ return t.replace(/\b\w+\b/g, function(n) {
1239
1587
  return n.substring(0, 1).toLowerCase() + n.substring(1).toUpperCase();
1240
1588
  });
1241
1589
  case 3:
1242
- return e.split("").map(function(n) {
1590
+ return t.split("").map(function(n) {
1243
1591
  return /[a-z]/.test(n) ? n.toUpperCase() : n.toLowerCase();
1244
1592
  }).join("");
1245
1593
  case 4:
1246
- return e.toUpperCase();
1594
+ return t.toUpperCase();
1247
1595
  case 5:
1248
- return e.toLowerCase();
1596
+ return t.toLowerCase();
1249
1597
  default:
1250
- return e;
1598
+ return t;
1251
1599
  }
1252
1600
  },
1253
1601
  /**
@@ -1257,9 +1605,9 @@ const it = {
1257
1605
  * @param args 可变参数列表,支持 Object、Array 类型和任意其他类型,若为 null 或 undefined,则按类型默认转换为 '{}'、'[]' 或 ''
1258
1606
  * @returns 返回生成的新字符串
1259
1607
  */
1260
- tag(e, ...t) {
1261
- return t = t.map((n) => {
1262
- switch (E.getDataType(n)) {
1608
+ tag(t, ...e) {
1609
+ return e = e.map((n) => {
1610
+ switch (y.getDataType(n)) {
1263
1611
  case "Object":
1264
1612
  return n || "{}";
1265
1613
  case "Array":
@@ -1267,7 +1615,7 @@ const it = {
1267
1615
  default:
1268
1616
  return n || "";
1269
1617
  }
1270
- }), e.reduce((n, s, a) => `${n}${t[a - 1]}${s}`);
1618
+ }), t.reduce((n, s, r) => `${n}${e[r - 1]}${s}`);
1271
1619
  },
1272
1620
  /**
1273
1621
  * 计算字符串的字节长度
@@ -1275,8 +1623,8 @@ const it = {
1275
1623
  * @param str 需要计算字节长度的字符串
1276
1624
  * @returns 返回字符串的字节长度
1277
1625
  */
1278
- getByteLength(e) {
1279
- return e.replace(/[\u0391-\uFFE5]/g, "aa").length;
1626
+ getByteLength(t) {
1627
+ return t.replace(/[\u0391-\uFFE5]/g, "aa").length;
1280
1628
  },
1281
1629
  /**
1282
1630
  * 截取字符串中指定字节长度的子串
@@ -1286,16 +1634,16 @@ const it = {
1286
1634
  * @param n 截取字节长度
1287
1635
  * @returns 返回截取后的子串
1288
1636
  */
1289
- subStringByte(e, t, n) {
1637
+ subStringByte(t, e, n) {
1290
1638
  var s = /[^\x00-\xff]/g;
1291
- if (e.replace(s, "mm").length <= n)
1292
- return e;
1293
- for (var a = Math.floor(n / 2), r = a; r < e.length; r++) {
1294
- let i = e.substring(t, r);
1295
- if (i.replace(s, "mm").length >= n)
1296
- return i;
1639
+ if (t.replace(s, "mm").length <= n)
1640
+ return t;
1641
+ for (var r = Math.floor(n / 2), i = r; i < t.length; i++) {
1642
+ let a = t.substring(e, i);
1643
+ if (a.replace(s, "mm").length >= n)
1644
+ return a;
1297
1645
  }
1298
- return e;
1646
+ return t;
1299
1647
  },
1300
1648
  /**
1301
1649
  * 将值转换为字符串
@@ -1303,430 +1651,124 @@ const it = {
1303
1651
  * @param value 要转换的值
1304
1652
  * @returns 转换后的字符串,如果值为空,则返回空字符串
1305
1653
  */
1306
- asString(e) {
1307
- if (E.isEmpty(e))
1654
+ asString(t) {
1655
+ if (y.isEmpty(t))
1308
1656
  return "";
1309
- switch (E.getDataType(e)) {
1657
+ switch (y.getDataType(t)) {
1310
1658
  case "Object":
1311
1659
  case "Array":
1312
- return JSON.stringify(e);
1660
+ return JSON.stringify(t);
1313
1661
  default:
1314
- return e;
1662
+ return t;
1315
1663
  }
1316
1664
  }
1317
- }, lt = {
1318
- notNull(e) {
1319
- if (E.isEmpty(e))
1320
- throw Error("不能为空:>>>" + e);
1321
- },
1322
- legalLnglat(e, t) {
1323
- if (!q.isLnglat(e, t))
1324
- throw Error(p.COORDINATE_ERROR);
1325
- },
1326
- contain(e, ...t) {
1327
- let n = !1;
1328
- const s = t.length || 0;
1329
- for (let a = 0, r = s; a < r; a++)
1330
- n = e.indexOf(t[a]) >= 0;
1331
- if (n)
1332
- throw Error(p.STRING_CHECK_LOSS);
1333
- },
1334
- verify: {
1335
- array(e) {
1336
- if (E.getDataType(e) !== "Array")
1337
- throw Error(p.PARAMETER_ERROR_ARRAY + ":>>>" + e);
1338
- },
1339
- function(e) {
1340
- if (E.getDataType(e) !== "Function")
1341
- throw Error(p.PARAMETER_ERROR_FUNCTION + ":>>>" + e);
1342
- },
1343
- object(e) {
1344
- if (E.getDataType(e) !== "Object")
1345
- throw Error(p.PARAMETER_ERROR_OBJECT + ":>>>" + e);
1346
- }
1347
- },
1348
- legalJSON(e) {
1665
+ }, p = class p {
1666
+ static set(e, n = null, s = null) {
1667
+ var r = this._getPrefixedKey(e, s);
1349
1668
  try {
1350
- JSON.parse(e);
1669
+ localStorage.setItem(r, JSON.stringify({ data: n }));
1351
1670
  } catch {
1352
- throw Error(p.JSON_PARSE_ERROR + ":>>>" + e);
1353
- }
1354
- },
1355
- legalData(e, t) {
1356
- const n = Y.checkStr(e, t);
1357
- let s = "";
1358
- switch (t) {
1359
- case "phone":
1360
- s = "电话";
1361
- break;
1362
- case "tel":
1363
- s = "座机";
1364
- break;
1365
- case "card":
1366
- s = "身份证";
1367
- break;
1368
- case "pwd":
1369
- s = "密码";
1370
- break;
1371
- case "postal":
1372
- s = "邮政编码";
1373
- break;
1374
- case "QQ":
1375
- s = "QQ";
1376
- break;
1377
- case "email":
1378
- s = "邮箱";
1379
- break;
1380
- case "money":
1381
- s = "金额";
1382
- break;
1383
- case "URL":
1384
- s = "网址";
1385
- break;
1386
- case "IP":
1387
- s = "IP";
1388
- break;
1389
- case "date":
1390
- s = "日期时间";
1391
- break;
1392
- case "number":
1393
- s = "数字";
1394
- break;
1395
- case "english":
1396
- s = "英文";
1397
- break;
1398
- case "chinese":
1399
- s = "中文";
1400
- break;
1401
- case "lower":
1402
- s = "小写";
1403
- break;
1404
- case "upper":
1405
- s = "大写";
1406
- break;
1407
- case "HTML":
1408
- s = "HTML标记";
1409
- break;
1671
+ console && console.warn("StoreUtil didn't successfully save the '{" + e + ": " + n + "}' pair, because the localStorage is full.");
1410
1672
  }
1411
- if (!n)
1412
- throw Error(p.PARAMETER_ERROR + ":>>>不是" + s);
1413
- }
1414
- };
1415
- class ht {
1416
- constructor(t) {
1417
- /**
1418
- * Creates an instance of AudioPlayer.
1419
- * @param {*} url
1420
- */
1421
- f(this, "audio");
1422
- this.audio = new Audio(), this.audio.src = t;
1423
- }
1424
- play() {
1425
- !this.muted && this.audio.play();
1426
- }
1427
- pause() {
1428
- this.audio.pause();
1429
- }
1430
- get muted() {
1431
- return this.audio.muted;
1432
- }
1433
- /**
1434
- * @description 设置静音状态,如果静音,autoplay属性将失效
1435
- */
1436
- set muted(t) {
1437
- this.audio.muted = t;
1438
1673
  }
1439
- }
1440
- class ut {
1441
- constructor(t) {
1442
- E.getDataType(t) === "String" && (t = document.querySelector("#" + t)), this.ctx = t.getContext("2d");
1443
- }
1444
- drawLine(t, n, s, a, r = {}) {
1445
- this.cxt.beginPath();
1446
- const i = r.width || 1, o = r.color || "#000";
1447
- this.cxt.lineWidth = i, this.cxt.fillStyle = o, this.cxt.moveTo(t, n), this.cxt.lineTo(s, a), this.cxt.closePath(), this.cxt.fill();
1448
- }
1449
- /**
1450
- * 绘制圆弧
1451
- * @param {*} x 圆心X坐标
1452
- * @param {*} y 圆心Y坐标
1453
- * @param {*} radius 半径
1454
- * @param {*} startAngle 开始的弧度
1455
- * @param {*} endAngle 结束的弧度
1456
- * @param {*} anticlockwise true为逆时针,false为顺时针
1457
- * @param {boolean} isOnlyArc
1458
- * @param {boolean} isFill 是否是填充,false为绘制边框,true为绘制填充
1459
- * @param {*} bgColor 圆弧的颜色
1460
- * @memberof CanvasDrawer
1461
- */
1462
- drawArc(t, n, s, a, r, i, o, c) {
1463
- o ? (this.cxt.fillStyle = c, this.cxt.beginPath(), this.cxt.arc(t, n, s, g.degreesToRadians(a), g.degreesToRadians(r), i), this.cxt.closePath(), this.cxt.fill()) : (this.cxt.strokeStyle = c, this.cxt.beginPath(), this.cxt.arc(t, n, s, g.degreesToRadians(a), g.degreesToRadians(r), i), this.cxt.stroke());
1464
- }
1465
- }
1466
- class dt {
1467
- constructor(t = 1) {
1468
- this.magnification = t;
1469
- }
1470
- // 获取系统类型
1471
- _getSystem() {
1472
- var t = navigator.userAgent.toLowerCase();
1473
- if (t.indexOf("windows") >= 0)
1474
- return !0;
1475
- }
1476
- // 获取页面缩放比例
1477
- // _getDevicePixelRatio() {
1478
- // let t = this;
1479
- // }
1480
- // 监听方法兼容写法
1481
- _addHandler(t, n, s) {
1482
- t.addEventListener ? t.addEventListener(n, s, !1) : t.attachEvent ? t.attachEvent("on" + n, s) : t["on" + n] = s;
1483
- }
1484
- // 校正浏览器缩放比例
1485
- _correct() {
1486
- let t = window.innerWidth;
1487
- if (typeof t != "number" && (document.compatMode == "CSS1Compat" ? t = document.documentElement.clientWidth : t = document.body.clientWidth), t <= 750) {
1488
- const s = document.documentElement.clientWidth / t;
1489
- document.documentElement.style.fontSize = this.magnification * 75 * Math.min(s, 2) + "px";
1490
- } else if (t > 750 && t <= 1200) {
1491
- const s = document.documentElement.clientWidth / t;
1492
- document.documentElement.style.fontSize = this.magnification * 85 * Math.min(s, 2) + "px";
1493
- } else {
1494
- const s = document.documentElement.clientWidth / 1920;
1495
- document.documentElement.style.fontSize = this.magnification * 100 * Math.min(s, 2) + "px";
1674
+ static get(e, n, s) {
1675
+ var r = this._getPrefixedKey(e, s), i;
1676
+ try {
1677
+ i = JSON.parse(localStorage.getItem(r) || "");
1678
+ } catch {
1679
+ localStorage[r] ? i = { data: localStorage.getItem(r) } : i = null;
1496
1680
  }
1681
+ if (i) {
1682
+ if (typeof i == "object" && typeof i.data < "u")
1683
+ return i.data;
1684
+ } else return n;
1497
1685
  }
1498
- // 监听页面缩放
1499
- _watch() {
1500
- let t = this;
1501
- t._addHandler(window, "resize", function() {
1502
- t._correct();
1503
- });
1504
- }
1505
- // 初始化页面比例
1506
- init() {
1507
- let t = this;
1508
- t._getSystem() && (t._correct(), t._watch());
1509
- }
1510
- }
1511
- class K {
1512
- constructor() {
1513
- f(this, "_listeners");
1514
- f(this, "_mutex", {});
1515
- f(this, "_context");
1516
- }
1517
- addEventListener(t, n, s, a = !1) {
1518
- this._listeners === void 0 && (this._listeners = {}), this._context = s;
1519
- const r = this._mutex, i = this._listeners;
1520
- return i[t] === void 0 && (i[t] = []), i[t].indexOf(n) === -1 && (a && (r[t] = n), i[t].push(n)), this;
1521
- }
1522
- hasEventListener(t, n) {
1523
- if (this._listeners === null || this._listeners === void 0) return !1;
1524
- const s = this._listeners;
1525
- return s[t] !== void 0 && s[t].indexOf(n) !== -1;
1526
- }
1527
- removeEventListener(t, n) {
1528
- if (this._listeners === void 0) return;
1529
- const a = this._listeners[t];
1530
- if (this._mutex[t] === n && (this._mutex[t] = null), a !== void 0) {
1531
- const r = a.map((i) => i.toString()).indexOf(n.toString());
1532
- r !== -1 && a.splice(r, 1);
1533
- }
1686
+ static keys() {
1687
+ const e = [];
1688
+ var n = Object.keys(localStorage);
1689
+ return p.prefix.length === 0 ? n : (n.forEach(function(s) {
1690
+ s.indexOf(p.prefix) !== -1 && e.push(s.replace(p.prefix, ""));
1691
+ }), e);
1534
1692
  }
1535
- dispatchEvent(t) {
1536
- if (this._listeners === void 0) return;
1537
- const s = this._listeners[t.type];
1538
- if (s !== void 0) {
1539
- t.target = this;
1540
- const a = s.slice(0);
1541
- if (this._mutex[t.type] !== void 0) {
1542
- const r = a.find((i) => i === this._mutex[t.type]);
1543
- if (r) {
1544
- r.call(this._context || this, t);
1545
- return;
1693
+ static getAll(e) {
1694
+ var n = p.keys();
1695
+ if (e) {
1696
+ const s = [];
1697
+ return n.forEach((r) => {
1698
+ if (e.includes(r)) {
1699
+ const i = {};
1700
+ i[r] = p.get(r, null, null), s.push(i);
1546
1701
  }
1547
- }
1548
- for (let r = 0, i = a.length; r < i; r++) {
1549
- const o = a[r];
1550
- typeof o == "function" && o.call(this._context || this, t);
1551
- }
1702
+ }), s;
1552
1703
  }
1704
+ return n.map((s) => p.get(s, null, null));
1553
1705
  }
1554
- removeAllListener() {
1555
- this._mutex = {};
1556
- for (const t in this._listeners)
1557
- this._listeners[t] = [];
1558
- }
1559
- }
1560
- class F extends Map {
1561
- isEmpty() {
1562
- return this.size === 0;
1563
- }
1564
- _values() {
1565
- return Array.from(this.values());
1566
- }
1567
- _keys() {
1568
- return Array.from(this.keys());
1569
- }
1570
- _entries() {
1571
- return Array.from(this.entries());
1706
+ static remove(e, n) {
1707
+ var s = this._getPrefixedKey(e, n);
1708
+ localStorage.removeItem(s);
1572
1709
  }
1573
- fromEntries() {
1710
+ static clear(e) {
1711
+ p.prefix.length ? this.keys().forEach((n) => {
1712
+ localStorage.removeItem(this._getPrefixedKey(n, e));
1713
+ }) : localStorage.clear();
1574
1714
  }
1575
- }
1576
- F.prototype.fromEntries = function(e = []) {
1577
- const t = new F();
1578
- return e.forEach((n) => {
1579
- Array.isArray(n) && n.length === 2 && t.set(n[0], n[1]);
1580
- }), t;
1581
1715
  };
1582
- class ft extends K {
1583
- constructor(n = "ws://127.0.0.1:10088") {
1584
- super();
1585
- f(this, "maxCheckTimes", 10);
1586
- f(this, "url");
1587
- f(this, "checkTimes", 0);
1588
- f(this, "connectStatus", !1);
1589
- f(this, "client", null);
1590
- this.maxCheckTimes = 10, this.url = n, this.checkTimes = 0, this.connect(), this.connCheckStatus(this.maxCheckTimes);
1591
- }
1592
- connect() {
1593
- if (this.disconnect(), this.url)
1594
- try {
1595
- if (console.info("创建ws连接>>>" + this.url), this.client = new WebSocket(this.url), this.client) {
1596
- const n = this;
1597
- this.client.onopen = function(s) {
1598
- n.dispatchEvent({
1599
- type: x.WEB_SOCKET_CONNECT,
1600
- message: s
1601
- });
1602
- }, this.client.onmessage = function(s) {
1603
- n.connectStatus = !0, n.dispatchEvent({
1604
- type: x.WEB_SOCKET_MESSAGE,
1605
- message: s
1606
- });
1607
- }, this.client.onclose = function(s) {
1608
- n.dispatchEvent({
1609
- type: x.WEB_SOCKET_CLOSE,
1610
- message: s
1611
- });
1612
- }, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(s) {
1613
- n.dispatchEvent({
1614
- type: x.WEB_SOCKET_ERROR,
1615
- message: s
1616
- });
1617
- });
1618
- }
1619
- } catch (n) {
1620
- console.error("创建ws连接失败" + this.url + ":" + n);
1621
- }
1622
- }
1623
- disconnect() {
1624
- if (this.client)
1625
- try {
1626
- console.log("ws断开连接" + this.url), this.client.close(), this.client = null;
1627
- } catch {
1628
- this.client = null;
1629
- }
1630
- }
1631
- connCheckStatus(n) {
1632
- this.checkTimes > n || setTimeout(() => {
1633
- this.checkTimes++, this.client && this.client.readyState !== 0 && this.client.readyState !== 1 && this.connect(), this.connCheckStatus(n);
1634
- }, 2e3);
1635
- }
1636
- send(n) {
1637
- return this.client && this.client.readyState === 1 ? (this.client.send(n), !0) : (console.error(this.url + "消息发送失败:" + n), !1);
1638
- }
1639
- heartbeat() {
1640
- setTimeout(() => {
1641
- this.client && this.client.readyState === 1 && this.send("HeartBeat"), console.log("HeartBeat," + this.url), setTimeout(this.heartbeat, 3e4);
1642
- }, 1e3);
1643
- }
1644
- }
1645
- class mt {
1646
- constructor(t = 1) {
1647
- f(this, "cacheType");
1648
- f(this, "storage");
1649
- if (this.cacheType = t, t === 1)
1650
- this.storage = window.localStorage;
1651
- else if (t === 2)
1652
- this.storage = window.sessionStorage;
1653
- else
1654
- throw new Error(p.PARAMETER_ERROR);
1655
- }
1656
- /**
1657
- * 设置带过期时间的LocalStorage
1658
- * @param key 缓存关键字
1659
- * @param value 缓存对象,可以是任意类型
1660
- * @param expired 以秒为单位,默认为1小时
1661
- * @returns {Object}
1662
- */
1663
- setItem(t, n, s) {
1664
- const a = { key: t, value: n };
1665
- if (this.cacheType === 1) {
1666
- const r = Date.now();
1667
- s && (a.expired = r + s * 1e3);
1668
- }
1669
- return this.storage[t] = JSON.stringify(a), a;
1670
- }
1671
- /***
1672
- * 获取带过期时间的缓存
1673
- * @param key
1674
- * @returns {null|*}
1675
- */
1676
- getItem(t) {
1677
- const n = this.storage.getItem(t);
1678
- if (n === null)
1679
- return null;
1680
- const s = JSON.parse(n) || {};
1681
- if (this.cacheType === 1) {
1682
- const a = s.expired ? new Date(s.expired).getTime() : Date.now();
1683
- if (Date.now() > a)
1684
- return this.remove(t), null;
1685
- }
1686
- return s.value;
1687
- }
1688
- /**
1689
- * 移除指定缓存
1690
- * @param keys
1691
- */
1692
- remove(t) {
1693
- t && (t.indexOf(",") > -1 ? t.split(",").forEach((n) => {
1694
- this.storage.removeItem(n);
1695
- }) : this.storage.removeItem(t));
1696
- }
1716
+ f(p, "prefix", ""), f(p, "_getPrefixedKey", function(e, n) {
1717
+ return n = n || {}, n.noPrefix ? e : p.prefix + e;
1718
+ });
1719
+ let w = p;
1720
+ const Y = {
1697
1721
  /**
1698
- * 移出全部缓存
1722
+ * 将json对象转换为查询字符串
1723
+ *
1724
+ * @param json 待转换的json对象
1725
+ * @returns 转换后的查询字符串
1699
1726
  */
1700
- clear() {
1701
- this.storage.clear();
1727
+ json2Query(t) {
1728
+ var e = [];
1729
+ for (var n in t)
1730
+ if (t.hasOwnProperty(n)) {
1731
+ var s = n, r = t[n];
1732
+ e.push(encodeURIComponent(s) + "=" + encodeURIComponent(r));
1733
+ }
1734
+ var i = e.join("&");
1735
+ return i;
1736
+ },
1737
+ query2Json(t) {
1738
+ t.startsWith("http") || (t = "http://dummy?" + t);
1739
+ const e = new URL(t), n = new URLSearchParams(e.search), s = {};
1740
+ for (let r in n)
1741
+ s[r] = decodeURIComponent(n[r]);
1742
+ return s;
1702
1743
  }
1703
- }
1744
+ };
1704
1745
  export {
1705
- tt as AnimateUtils,
1706
- et as ArrayUtils,
1707
- lt as AssertUtils,
1708
- ht as AudioPlayer,
1709
- nt as BrowserUtils,
1710
- ut as CanvasDrawer,
1711
- st as Cookie,
1712
- rt as CoordsUtils,
1713
- at as DateUtils,
1714
- dt as DevicePixelRatio,
1715
- it as DomUtils,
1716
- p as ErrorType,
1717
- K as EventDispatcher,
1718
- x as EventType,
1719
- ot as FileUtils,
1720
- q as GeoUtils,
1721
- X as GraphicType,
1722
- F as HashMap,
1723
- Q as LayerType,
1724
- g as MathUtils,
1725
- V as MeasureMode,
1726
- Z as ObjectState,
1727
- ct as OptimizeUtils,
1728
- Y as StringUtils,
1729
- E as Utils,
1730
- ft as WebSocketClient,
1731
- mt as WebStorage
1746
+ k as ArrayUtil,
1747
+ v as AudioPlayer,
1748
+ N as BrowserUtil,
1749
+ P as CanvasDrawer,
1750
+ B as ColorUtil,
1751
+ F as Cookie,
1752
+ $ as CoordsUtil,
1753
+ W as DateUtil,
1754
+ L as DevicePixelRatio,
1755
+ q as DomUtil,
1756
+ D as ErrorType,
1757
+ A as EventDispatcher,
1758
+ M as EventType,
1759
+ z as FileUtil,
1760
+ G as GeoUtil,
1761
+ I as GraphicType,
1762
+ E as HashMap,
1763
+ H as JsonUtil,
1764
+ C as LayerType,
1765
+ m as MathUtil,
1766
+ _ as MeasureMode,
1767
+ T as ObjectState,
1768
+ j as OptimizeUtil,
1769
+ w as StoreUtil,
1770
+ K as StringUtil,
1771
+ Y as UrlUtil,
1772
+ y as Util,
1773
+ U as WebSocketClient
1732
1774
  };