mx3d 0.1.4 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -2,8 +2,8 @@
2
2
  @author gzmaijing
3
3
  @email mj@gzmaijing.com
4
4
  */
5
- declare module MX3D {
6
- export class App {
5
+
6
+ export class App {
7
7
  canvas: HTMLCanvasElement;
8
8
  engine: any;
9
9
  scene: any;
@@ -16,84 +16,84 @@ declare module MX3D {
16
16
  Project: Project;
17
17
  ToolTips: ToolTips;
18
18
  constructor(_config: {
19
- container: HTMLElement;
20
- sl?: string;
21
- rl?: string;
19
+ container: HTMLElement;
20
+ sl?: string;
21
+ rl?: string;
22
22
  });
23
23
  load(_config: {
24
- pk: string;
25
- progress?: Function;
26
- complete?: Function;
24
+ pk: string;
25
+ progress?: Function;
26
+ complete?: Function;
27
27
  }): Promise<void>;
28
28
  dispose(): void;
29
- }
29
+ }
30
30
 
31
- export class Builder {
31
+ export class Builder {
32
32
  static createCapacity(_obj: IObject, _RATIO: number, _text: string, _fontSize?: string): void;
33
33
  static createTextMesh(_obj: IObject, _text: string, _RATIO: number, _fontSize?: string, _color?: string): void;
34
34
  static createMatrixCloud(_data: {
35
- anchor: IObject;
36
- value: {
37
- maxX: number;
38
- maxY: number;
39
- data: Array<{
40
- x: number;
41
- y: number;
42
- value: number;
43
- }>;
44
- };
45
- displayValues: boolean;
46
- height: number;
47
- isLevelRender: boolean;
48
- isAlpha: boolean;
49
- isParticle: boolean;
50
- radius: number;
51
- range: {
52
- max: number;
53
- min: number;
54
- };
35
+ anchor: IObject;
36
+ value: {
37
+ maxX: number;
38
+ maxY: number;
39
+ data: Array<{
40
+ x: number;
41
+ y: number;
42
+ value: number;
43
+ }>;
44
+ };
45
+ displayValues: boolean;
46
+ height: number;
47
+ isLevelRender: boolean;
48
+ isAlpha: boolean;
49
+ isParticle: boolean;
50
+ radius: number;
51
+ range: {
52
+ max: number;
53
+ min: number;
54
+ };
55
55
  }): void;
56
56
  static createPunctateCloud(_data: {
57
- anchor: IObject;
58
- value: number;
59
- radius: number;
60
- isLevelRender: boolean;
61
- displayValues: boolean;
62
- isAlpha: boolean;
63
- isParticle: boolean;
64
- range: {
65
- max: number;
66
- min: number;
67
- };
57
+ anchor: IObject;
58
+ value: number;
59
+ radius: number;
60
+ isLevelRender: boolean;
61
+ displayValues: boolean;
62
+ isAlpha: boolean;
63
+ isParticle: boolean;
64
+ range: {
65
+ max: number;
66
+ min: number;
67
+ };
68
68
  }): void;
69
69
  createColumnCloud(_data: {
70
- anchor: IObject;
71
- data: Array<{
72
- index: number;
73
- value: number;
74
- }>;
75
- isLevelRender: boolean;
76
- displayValues: boolean;
77
- isAlpha: boolean;
78
- isParticle: boolean;
79
- radius: number;
80
- range: {
81
- max: number;
82
- min: number;
83
- };
70
+ anchor: IObject;
71
+ data: Array<{
72
+ index: number;
73
+ value: number;
74
+ }>;
75
+ isLevelRender: boolean;
76
+ displayValues: boolean;
77
+ isAlpha: boolean;
78
+ isParticle: boolean;
79
+ radius: number;
80
+ range: {
81
+ max: number;
82
+ min: number;
83
+ };
84
84
  }): void;
85
85
  static create2DLine(_id: string, _objs: Array<IObject>, _options?: {
86
- _width: number;
87
- _color: string;
88
- isDotted: boolean;
86
+ _width: number;
87
+ _color: string;
88
+ isDotted: boolean;
89
89
  }): void;
90
90
  static create3DLine(_id: string, _objs: Array<IObject>, _options?: {
91
- _width: number;
92
- _color: string;
91
+ _width: number;
92
+ _color: string;
93
93
  }): void;
94
- }
94
+ }
95
95
 
96
- export class Capacity {
96
+ export class Capacity {
97
97
  anchor: IObject;
98
98
  mesh: any;
99
99
  ratio: number;
@@ -101,20 +101,20 @@ declare module MX3D {
101
101
  textMesh: any;
102
102
  constructor(_object: IObject, _RATIO: number);
103
103
  dispose(): void;
104
- }
104
+ }
105
105
 
106
- export class EffectMgr {
106
+ export class EffectMgr {
107
107
  static colors: {};
108
108
  static init(): void;
109
- }
109
+ }
110
110
 
111
- export enum EffectType {
111
+ export enum EffectType {
112
112
  Opaque = 0,
113
113
  Flash = 1,
114
114
  Transparent = 2
115
- }
115
+ }
116
116
 
117
- export class Environment {
117
+ export class Environment {
118
118
  app: App;
119
119
  lights: any;
120
120
  _color: any;
@@ -138,16 +138,16 @@ declare module MX3D {
138
138
  hideFps(): void;
139
139
  showDebug(): void;
140
140
  setLightIntensity(_intensity?: number): void;
141
- }
141
+ }
142
142
 
143
- export class DefaultEvent implements IEvent {
143
+ export class DefaultEvent implements IEvent {
144
144
  app: App;
145
145
  runRender(): void;
146
146
  onPointer(_pointerInfo: any): void;
147
147
  onKeyboard(_kbInfo: any): void;
148
- }
148
+ }
149
149
 
150
- export class FPSCameraEvent implements IEvent {
150
+ export class FPSCameraEvent implements IEvent {
151
151
  app: App;
152
152
  isFPS: boolean;
153
153
  angle: number;
@@ -159,24 +159,24 @@ declare module MX3D {
159
159
  runRender(): void;
160
160
  onPointer(_pointerInfo: any): void;
161
161
  onKeyboard(_e: any): void;
162
- }
162
+ }
163
163
 
164
- export interface IEvent {
164
+ export interface IEvent {
165
165
  runRender(): void;
166
166
  onPointer(e: any): void;
167
167
  onKeyboard(e: any): void;
168
- }
168
+ }
169
169
 
170
- export enum EventType {
170
+ export enum EventType {
171
171
  leftClick = "leftClick",
172
172
  rightClick = "rightClick",
173
173
  doubleClick = "doubleClick",
174
174
  eover = "eover",
175
175
  longPress = "longPress",
176
176
  out = "out"
177
- }
177
+ }
178
178
 
179
- export class HeatMap implements BaseNode {
179
+ export class HeatMap implements BaseNode {
180
180
  id: string;
181
181
  anchor: IObject;
182
182
  mesh: any;
@@ -186,17 +186,17 @@ declare module MX3D {
186
186
  isEnabled(_bool: boolean): void;
187
187
  set displayValues(_value: boolean);
188
188
  dispose(): void;
189
- }
189
+ }
190
190
 
191
- export class Icon implements BaseNode {
191
+ export class Icon implements BaseNode {
192
192
  id: string;
193
193
  scene: any;
194
194
  pint: any;
195
195
  rect: any;
196
196
  onPointerClick: Function;
197
197
  size: {
198
- width: number;
199
- height: number;
198
+ width: number;
199
+ height: number;
200
200
  };
201
201
  height: number;
202
202
  container: any;
@@ -204,21 +204,21 @@ declare module MX3D {
204
204
  set background(_url: string);
205
205
  addEventListener(_action: Function): void;
206
206
  setTexts(_textArr: [{
207
- text: string;
208
- fontSize: string;
209
- color: string;
210
- top: number;
211
- left: number;
207
+ text: string;
208
+ fontSize: string;
209
+ color: string;
210
+ top: number;
211
+ left: number;
212
212
  }]): void;
213
213
  line(_line: {
214
- width: number;
215
- color: string;
214
+ width: number;
215
+ color: string;
216
216
  }): void;
217
217
  dispose(): void;
218
218
  isEnabled(_isEnabled: boolean): void;
219
- }
219
+ }
220
220
 
221
- export class IconFromMesh implements BaseNode {
221
+ export class IconFromMesh implements BaseNode {
222
222
  id: string;
223
223
  scene: any;
224
224
  instance: any;
@@ -229,44 +229,60 @@ declare module MX3D {
229
229
  addEventListener(_action: Function): void;
230
230
  setColor(_color: string): void;
231
231
  setContents(_textArr: [{
232
- text: string;
233
- fontSize: string;
234
- top: number;
235
- left: number;
236
- color?: string;
232
+ text: string;
233
+ fontSize: string;
234
+ top: number;
235
+ left: number;
236
+ color?: string;
237
237
  }]): void;
238
238
  dispose(): void;
239
239
  isEnabled(_bool: boolean): void;
240
- }
240
+ }
241
241
 
242
- export class UI {
242
+ export class UI {
243
243
  static createIconFromMesh(_id: string, _anchor: IObject, _url: string, _scaling: number, _height: number): void;
244
244
  static createIcon(_id: string, _anchor: IObject, _size: {
245
- width: number;
246
- height: number;
245
+ width: number;
246
+ height: number;
247
247
  }, _height: number): void;
248
- }
248
+ }
249
249
 
250
- export class HubService {
250
+ export class HubService {
251
251
  static connection: any;
252
252
  static listener(_Url: string): Promise<void>;
253
253
  static start(): Promise<void>;
254
- }
255
-
256
- export class Directional extends LightObject {
254
+ }
255
+
256
+ export default class MX3D {
257
+ static accessToken: string;
258
+ static pk: string;
259
+ static sl: string;
260
+ static rl: string;
261
+ static App: typeof App;
262
+ static Tools: typeof Tools;
263
+ static Earth: typeof Earth;
264
+ static EffectMgr: typeof EffectMgr;
265
+ static HubService: typeof HubService;
266
+ static UI: typeof UI;
267
+ static Builder: typeof Builder;
268
+ static EffectType: typeof EffectType;
269
+ static EventType: typeof EventType;
270
+ }
271
+
272
+ export class Directional extends LightObject {
257
273
  direction: any;
258
274
  position: any;
259
275
  light: any;
260
276
  load(): void;
261
- }
277
+ }
262
278
 
263
- export class Hemispheric extends LightObject {
279
+ export class Hemispheric extends LightObject {
264
280
  direction: any;
265
281
  light: any;
266
282
  load(): void;
267
- }
283
+ }
268
284
 
269
- export interface ILightObject {
285
+ export interface ILightObject {
270
286
  id: string;
271
287
  sceneId: string;
272
288
  name: string;
@@ -275,9 +291,9 @@ declare module MX3D {
275
291
  lightType: string;
276
292
  intensity: number;
277
293
  load: Function;
278
- }
294
+ }
279
295
 
280
- export class LightObject implements ILightObject {
296
+ export class LightObject implements ILightObject {
281
297
  id: string;
282
298
  sceneId: string;
283
299
  name: string;
@@ -289,23 +305,23 @@ declare module MX3D {
289
305
  app: App;
290
306
  constructor(_app: App);
291
307
  load(): void;
292
- }
308
+ }
293
309
 
294
- export enum LightType {
310
+ export enum LightType {
295
311
  Point = "Point",
296
312
  Spot = "Spot",
297
313
  Directional = "Directional",
298
314
  Hemispheric = "Hemispheric"
299
- }
315
+ }
300
316
 
301
- export class Point extends LightObject {
317
+ export class Point extends LightObject {
302
318
  position: any;
303
319
  light: any;
304
320
  range: number;
305
321
  load(): void;
306
- }
322
+ }
307
323
 
308
- export class Spot extends LightObject {
324
+ export class Spot extends LightObject {
309
325
  direction: any;
310
326
  position: any;
311
327
  angle: number;
@@ -313,35 +329,36 @@ declare module MX3D {
313
329
  range: number;
314
330
  light: any;
315
331
  load(): void;
316
- }
332
+ }
317
333
 
318
- export class BabylonLayer {
334
+ export class BabylonLayer {
319
335
  readonly id: string;
320
336
  readonly type: "custom";
321
337
  readonly renderingMode: "3d";
322
338
  drones: {
323
- x: number;
324
- y: number;
325
- z: number;
339
+ x: number;
340
+ y: number;
341
+ z: number;
326
342
  };
327
343
  initialCoordinates: [];
328
344
  recalculateProjectionMatrix(_coordinates: []): void;
329
345
  onAdd: (_map: any, _gl: WebGLRenderingContext) => void;
330
346
  render: (_gl: WebGLRenderingContext, _matrix: number[]) => void;
331
- }
347
+ }
332
348
 
333
- export class Earth {
349
+ export class Earth {
334
350
  initialCoordinates: [];
335
351
  map: any;
336
352
  load(_action: Function): void;
337
- laodScene(_url: string, _initialCoordinates: []): void;
353
+ constructor(_container: string, _initialCoordinates?: []);
354
+ laodScene(_url?: string, _initialCoordinates?: []): void;
338
355
  flyTo(_center?: [], _zoom?: number, _bearing?: number, _pitch?: number, _duration?: number): void;
339
- }
356
+ }
340
357
 
341
- export class CabinetObject extends DefaultObject {
342
- }
358
+ export class CabinetObject extends DefaultObject {
359
+ }
343
360
 
344
- export class ConduitObject extends DefaultObject {
361
+ export class ConduitObject extends DefaultObject {
345
362
  alpha: number;
346
363
  color: string;
347
364
  bind(_m: any): void;
@@ -351,14 +368,14 @@ declare module MX3D {
351
368
  setFlash(_level?: number): void;
352
369
  setOpaque(): void;
353
370
  setTransparent(_alpha?: number): void;
354
- }
371
+ }
355
372
 
356
- export class CornerObject extends DefaultObject {
373
+ export class CornerObject extends DefaultObject {
357
374
  height: number;
358
375
  bind(_m: any): void;
359
- }
376
+ }
360
377
 
361
- export class DefaultObject implements IObject {
378
+ export class DefaultObject implements IObject {
362
379
  app: App;
363
380
  id: string;
364
381
  name: string;
@@ -391,27 +408,27 @@ declare module MX3D {
391
408
  setTransparent(_alpha?: number): void;
392
409
  play(): void;
393
410
  stop(): void;
394
- }
411
+ }
395
412
 
396
- export class DoorObject extends DefaultObject {
413
+ export class DoorObject extends DefaultObject {
397
414
  height: number;
398
415
  bind(_m: any): void;
399
- }
416
+ }
400
417
 
401
- export class FloorObject extends DefaultObject {
418
+ export class FloorObject extends DefaultObject {
402
419
  height: number;
403
420
  bind(_m: any): void;
404
- }
421
+ }
405
422
 
406
- export interface IBase {
423
+ export interface IBase {
407
424
  app: App;
408
425
  id: string;
409
426
  name: string;
410
427
  parentId: string;
411
428
  objectType: string;
412
- }
429
+ }
413
430
 
414
- export interface IObject extends IBase {
431
+ export interface IObject extends IBase {
415
432
  customNumber: string;
416
433
  customType: string;
417
434
  modelId: string;
@@ -430,16 +447,16 @@ declare module MX3D {
430
447
  play(isloop: boolean): any;
431
448
  stop(): any;
432
449
  computeView(): any;
433
- }
450
+ }
434
451
 
435
- export class LeakWaterObject extends DefaultObject {
452
+ export class LeakWaterObject extends DefaultObject {
436
453
  bind(_l: any): void;
437
454
  computeView(): void;
438
455
  addEventListener(_type: string, _callback: Function): void;
439
456
  removeEventListener(_type: string): void;
440
- }
457
+ }
441
458
 
442
- export enum ObjectType {
459
+ export enum ObjectType {
443
460
  Region = "Region",
444
461
  Cabinet = "Cabinet",
445
462
  Corner = "Corner",
@@ -452,9 +469,9 @@ declare module MX3D {
452
469
  Wall = "Wall",
453
470
  Window = "Window",
454
471
  Conduit = "Conduit"
455
- }
472
+ }
456
473
 
457
- export class Project {
474
+ export class Project {
458
475
  app: App;
459
476
  id: string;
460
477
  root: IObject;
@@ -473,9 +490,9 @@ declare module MX3D {
473
490
  findObjectByCustomNumber(): void;
474
491
  findObjectsByCustomType(): void;
475
492
  switchLevel(_id?: string, _isFocus?: boolean, _includeSub?: boolean): void;
476
- }
493
+ }
477
494
 
478
- export class RegionObject extends DefaultObject {
495
+ export class RegionObject extends DefaultObject {
479
496
  index: number;
480
497
  height: number;
481
498
  constructor(app: App, _storey: any);
@@ -486,39 +503,39 @@ declare module MX3D {
486
503
  setEnabled(_value: boolean): void;
487
504
  getBounding(): void;
488
505
  dispose(): void;
489
- }
506
+ }
490
507
 
491
- export class UI3DTextObject extends DefaultObject {
508
+ export class UI3DTextObject extends DefaultObject {
492
509
  bind(_u: any): void;
493
- }
510
+ }
494
511
 
495
- export class VirtualBoxObject extends DefaultObject {
512
+ export class VirtualBoxObject extends DefaultObject {
496
513
  bind(_m: any): Promise<void>;
497
- }
514
+ }
498
515
 
499
- export class WallObject extends DefaultObject {
516
+ export class WallObject extends DefaultObject {
500
517
  nativeMaterial: any;
501
518
  baseModel: any;
502
519
  height: number;
503
520
  bind(_w: any): void;
504
- }
521
+ }
505
522
 
506
- export class WindowObject extends DefaultObject {
523
+ export class WindowObject extends DefaultObject {
507
524
  height: number;
508
525
  bind(_m: any): void;
509
- }
526
+ }
510
527
 
511
- export class ArrayEx<T> extends Array<T> {
528
+ export class ArrayEx<T> extends Array<T> {
512
529
  remove(_val: any): void;
513
- }
530
+ }
514
531
 
515
- export interface BaseNode {
532
+ export interface BaseNode {
516
533
  id: string;
517
534
  dispose(): any;
518
535
  isEnabled(bool: boolean): any;
519
- }
536
+ }
520
537
 
521
- export class CameraController {
538
+ export class CameraController {
522
539
  app: App;
523
540
  camera: any;
524
541
  frustrum: number;
@@ -533,11 +550,11 @@ declare module MX3D {
533
550
  _wheel(_p: any): void;
534
551
  switchArcRotateCamera(): void;
535
552
  switchFPSCamera(): void;
536
- }
553
+ }
537
554
 
538
- export class Dictionary<T> {
555
+ export class Dictionary<T> {
539
556
  map: {
540
- [key: string]: T;
557
+ [key: string]: T;
541
558
  };
542
559
  constructor();
543
560
  add(_key: string, _value: T): void;
@@ -547,13 +564,13 @@ declare module MX3D {
547
564
  showAll(): void;
548
565
  count(): void;
549
566
  clear(): void;
550
- }
567
+ }
551
568
 
552
- export class GUID {
569
+ export class GUID {
553
570
  static getGUID(_length: number): void;
554
- }
571
+ }
555
572
 
556
- export class Resources {
573
+ export class Resources {
557
574
  app: App;
558
575
  walls: Dictionary<any>;
559
576
  resources: Dictionary<any>;
@@ -572,9 +589,9 @@ declare module MX3D {
572
589
  GetMergeMaterial(_textureData: any, _scene: any): void;
573
590
  delete(_isAll?: boolean): void;
574
591
  GetWalls(_url: string, _projectId: string): Promise<void>;
575
- }
592
+ }
576
593
 
577
- export class Sight {
594
+ export class Sight {
578
595
  alpha: number;
579
596
  focus: any;
580
597
  radius: number;
@@ -587,9 +604,9 @@ declare module MX3D {
587
604
  toString(): void;
588
605
  setLimit(_miniLimit: number, _maxiLimit: number): void;
589
606
  setBeta(_minBeta: number, _maxBeta: number): void;
590
- }
607
+ }
591
608
 
592
- export class Tools {
609
+ export class Tools {
593
610
  static vector3ToJson(_old: any): any;
594
611
  static vector3ARRToJson(_olds: any[]): void;
595
612
  static ToVector3(_old: any): void;
@@ -606,9 +623,9 @@ declare module MX3D {
606
623
  static getAngleFromVector2(_startV: any, _coreV: any, _endV: any): void;
607
624
  static getAngleFromVector3(_startV: any, _coreV: any, _endV: any): void;
608
625
  static RandomNumBoth(_Min: any, _Max: any): void;
609
- }
626
+ }
610
627
 
611
- export class ToolTips {
628
+ export class ToolTips {
612
629
  app: App;
613
630
  url: string;
614
631
  ele: HTMLDivElement;
@@ -621,5 +638,5 @@ declare module MX3D {
621
638
  close(): void;
622
639
  setBackground(_url: string): void;
623
640
  dispose(): void;
624
- }
625
- }
641
+ }
642
+
package/mx3d.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.MX3D=e():t.MX3D=e()}(window,(function(){return function(t){var e={};function o(r){if(e[r])return e[r].exports;var c=e[r]={i:r,l:!1,exports:{}};return t[r].call(c.exports,c,c.exports,o),c.l=!0,c.exports}return o.m=t,o.c=e,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var c in t)o.d(r,c,function(e){return t[e]}.bind(null,c));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";o.r(e),o.d(e,"default",(function(){return s}));class r{static init(){}}r.colors={};var c,n;!function(t){t[t.Opaque=0]="Opaque",t[t.Flash=1]="Flash",t[t.Transparent=2]="Transparent"}(c||(c={})),function(t){t.leftClick="leftClick",t.rightClick="rightClick",t.doubleClick="doubleClick",t.eover="eover",t.longPress="longPress",t.out="out"}(n||(n={}));class s{}s.sl="https://www.wodashijie.com/",s.rl="https://models.wodashijie.com/",s.App=class{constructor(t){}async load(t){}dispose(){}},s.Tools=class{static vector3ToJson(t){}static vector3ARRToJson(t){}static ToVector3(t){}static ToARRVector3(t){}static computeBounds(t){}static computeBoundsToARR(t){}static Expand(t,e){}static norm(t,e){}static MergeMeshes(t,e){}static DeconsTructMesh(t,e,o){}static getVisualAngle(t,e){}static pathTransformation(t,e){}static createTube(t,e,o=.05,r){}static getAngleFromVector2(t,e,o){}static getAngleFromVector3(t,e,o){}static RandomNumBoth(t,e){}},s.Earth=class{constructor(){this.initialCoordinates=[]}load(t){}laodScene(t,e){}flyTo(t=this.initialCoordinates,e=18,o=130,r=75,c=12e3){}},s.EffectMgr=r,s.HubService=class{static async listener(t){}static async start(){}},s.UI=class{static createIconFromMesh(t,e,o,r,c){}static createIcon(t,e,o,r){}},s.Builder=class{static createCapacity(t,e,o,r="200px"){}static createTextMesh(t,e,o,r="200px",c="white"){}static createMatrixCloud(t){}static createPunctateCloud(t){}createColumnCloud(t){}static create2DLine(t,e,o){}static create3DLine(t,e,o){}},s.EffectType=c,s.EventType=n}]).default}));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.MX3D=e():t.MX3D=e()}(window,(function(){return function(t){var e={};function o(r){if(e[r])return e[r].exports;var c=e[r]={i:r,l:!1,exports:{}};return t[r].call(c.exports,c,c.exports,o),c.l=!0,c.exports}return o.m=t,o.c=e,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var c in t)o.d(r,c,function(e){return t[e]}.bind(null,c));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";o.r(e),o.d(e,"default",(function(){return s}));class r{static init(){}}r.colors={};var c,n;!function(t){t[t.Opaque=0]="Opaque",t[t.Flash=1]="Flash",t[t.Transparent=2]="Transparent"}(c||(c={})),function(t){t.leftClick="leftClick",t.rightClick="rightClick",t.doubleClick="doubleClick",t.eover="eover",t.longPress="longPress",t.out="out"}(n||(n={}));class s{}s.sl="https://www.wodashijie.com/",s.rl="https://models.wodashijie.com/",s.App=class{constructor(t){}async load(t){}dispose(){}},s.Tools=class{static vector3ToJson(t){}static vector3ARRToJson(t){}static ToVector3(t){}static ToARRVector3(t){}static computeBounds(t){}static computeBoundsToARR(t){}static Expand(t,e){}static norm(t,e){}static MergeMeshes(t,e){}static DeconsTructMesh(t,e,o){}static getVisualAngle(t,e){}static pathTransformation(t,e){}static createTube(t,e,o=.05,r){}static getAngleFromVector2(t,e,o){}static getAngleFromVector3(t,e,o){}static RandomNumBoth(t,e){}},s.Earth=class{constructor(t,e){this.initialCoordinates=[]}load(t){}laodScene(t,e){}flyTo(t=this.initialCoordinates,e=18,o=130,r=75,c=12e3){}},s.EffectMgr=r,s.HubService=class{static async listener(t){}static async start(){}},s.UI=class{static createIconFromMesh(t,e,o,r,c){}static createIcon(t,e,o,r){}},s.Builder=class{static createCapacity(t,e,o,r="200px"){}static createTextMesh(t,e,o,r="200px",c="white"){}static createMatrixCloud(t){}static createPunctateCloud(t){}createColumnCloud(t){}static create2DLine(t,e,o){}static create3DLine(t,e,o){}},s.EffectType=c,s.EventType=n}]).default}));
package/mx3d.min.js CHANGED
@@ -22,7 +22,7 @@
22
22
  diffuseColor = res.rgb;
23
23
  alpha = res.a;
24
24
  }
25
- `),r.freeze()}return r}delete(e=!1){if(this.BOX&&this.BOX.dispose(),this.transparentBox&&this.transparentBox.dispose(!0,!0),this.BOX=null,this.transparentBox=null,e){for(const t in this.resources.map)this.resources.find(t).removeAllFromScene(),this.resources.remove(t);this.resources.clear()}}async GetWalls(e,t){let i=await BABYLON.SceneLoader.LoadAssetContainerAsync(e,t+".gltf",this.app.scene);if(i.meshes){var r=i.meshes[0].getChildMeshes();for(let e=0;e<r.length;e++)this.walls.add(r[e].id,r[e])}}}t=i(32);const O=i.n(t).a.create();O.defaults.headers.post["Content-Type"]="application/json",O.interceptors.request.use(e=>{var t=localStorage.getItem("mx3d-token");return t&&(e.headers.Authorization="Bearer "+t),e},e=>Promise.reject(e)),O.interceptors.response.use(e=>e,e=>{if(e.response)switch(e.response.status){case 401:console.error("开发者授权码异常");break;case 403:console.error("当前用户没有权限");break;case 400:console.error(e.response.data.message)}return Promise.reject(e)});var F=O,t=i(6),N=i.n(t);class U{constructor(e,t){this.textDics=new Array,this.id=e,this.scene=t}set background(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._background&&this._background.dispose(),this._background=new BABYLON.GUI.Image(a.getGUID(12)+"_Image",e),this._background.width=this.size.width+"px",this._background.height=this.size.height+"px",this.rect.addControl(this._background),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e?(this._background.isPointerBlocker=!1,this._background.onPointerClickObservable.add(()=>{e(this.id)})):this._background.onPointerClickObservable.clear(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setTexts(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.textDics.forEach(e=>e.dispose());for(let t=this.textDics.length=0;t<i.length;t++){let e=new BABYLON.GUI.TextBlock;e.text=i[t].text,e.fontSize=i[t].fontSize||"20px",e.color=i[t].color||"white",e.top=i[t].top||0,e.left=i[t].left||0,this.rect.addControl(e),this.textDics.push(e)}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}line(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._line&&this._line.dispose(),this._line=new BABYLON.GUI.Line,this._line.lineWidth=e.width||1.5,this._line.color=e.color||"green",this._line.y2=this.size.height/2,this.container.addControl(this._line),this._line.linkWithMesh(this.pint),this._line.connectedControl=this.rect,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&this.rect.dispose(),this._line&&this._line.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&(this.rect.isVisible=e),this._line&&(this._line.isVisible=e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class j{constructor(e,t,i,r,n,o){this.id=e,this.scene=o,this.url=i,this.scaling=r,this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance=BABYLON.Mesh.CreatePlane(this.id,r,this.scene,!0,BABYLON.Mesh.DOUBLESIDE),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.position=t.clone(),this.instance.position.y+=n,this.instance.billboardMode=BABYLON.Mesh.BILLBOARDMODE_Y;let s=new BABYLON.StandardMaterial("Mat_"+this.id,this.scene);s.diffuseColor=BABYLON.Color3.White(),s.emissiveColor=BABYLON.Color3.White(),this.instance.material=s,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setBackground(){let i=new Image;i.src=this.url,i.onload=()=>{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.scaling.y=this.scaling/(i.width/i.height)/this.scaling;let e=new BABYLON.DynamicTexture(this.id,{width:i.width,height:i.height},this.scene,!1);e.hasAlpha=!0,this.instance.material.diffuseTexture=e;let t=e.getContext();t.drawImage(i,0,0),e.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}addEventListener(t){if(this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,t){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let e=new BABYLON.ActionManager(this.scene);e.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>t(this.id))),this.instance.actionManager=e}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setColor(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(e),this.instance.material.emissiveColor=BABYLON.Color3.FromHexString(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setContents(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let r=new Image;r.src=this.url,r.onload=()=>{this.instance.scaling.y=this.scaling/(r.width/r.height)/this.scaling;let t=new BABYLON.DynamicTexture(this.id,{width:r.width,height:r.height},this.scene,!1);t.hasAlpha=!0,this.instance.material.diffuseTexture=t;let e=t.getContext();e.drawImage(r,0,0),i.forEach(e=>t.drawText(e.text,e.left,e.top,"bold "+e.fontSize+" monospace",e.color||"#fffffb","",!0,!0)),t.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class V{constructor(e,t){this.anchor=e,this.ratio=t}dispose(){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh&&this.mesh.dispose(),this.textMesh&&this.textMesh.dispose(),this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class G{constructor(e){this.displayValue=!1,this.anchor=e,this.id=a.getGUID(12),this.texts=new Array}isEnabled(t){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh.setEnabled(t),this.texts.forEach(e=>e.isVisible=!!t&&this.displayValue),this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}set displayValues(t){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.texts.forEach(e=>e.isVisible=t),this.displayValue=t,this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh&&this.mesh.dispose();for(let e=0;e<this.texts.length;e++)this.texts[e].linkedMesh&&this.texts[e].linkedMesh.dispose(),this.texts[e].dispose();this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}var $=i(15);class q{constructor(){this.color="#00ff00",this.width=1}update(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose();let t=[];this.objs.forEach(e=>t.push(e.instance.getAbsolutePosition().clone())),this.instance=p.createTube(this.id,t,this.width/100,this.objs[0].app);let e=new BABYLON.StandardMaterial("mat_"+this.id,this.objs[0].app.scene);e.diffuseColor=BABYLON.Color3.FromHexString(this.color),this.instance.material=e,this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(t){if(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,t){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let e=new BABYLON.ActionManager(this.objs[0].app.scene);e.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>t(this.id))),this.instance.actionManager=e}this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.instance&&(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1)}dispose(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class Z{constructor(){this.color="#00ff00",this.width=5,this.isDotted=!1}update(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.instance=new BABYLON.GUI.MultiLine,this.objs[0].app.container.addControl(this.instance),this.instance.lineWidth=this.width,this.instance.color=this.color,this.isDotted&&(this.instance.dash=[1]),this.objs.forEach(e=>this.instance.add(e.instance)),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e?(this.instance.isPointerBlocker=!1,this.instance.onPointerClickObservable.add(()=>{e(this.id)})):this.instance.onPointerClickObservable.clear(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.instance&&(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.isVisible=e,this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1)}dispose(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}const Y=[0,2e3,1e4,3e4,null];class W{constructor(e){this._retryDelays=void 0!==e?[...e,null]:Y}nextRetryDelayInMilliseconds(e){return this._retryDelays[e.previousRetryCount]}}class X extends Error{constructor(e,t){var i=new.target.prototype;super(`${e}: Status code '${t}'`),this.statusCode=t,this.__proto__=i}}class H extends Error{constructor(e="A timeout occurred."){var t=new.target.prototype;super(e),this.__proto__=t}}class K extends Error{constructor(e="An abort occurred."){var t=new.target.prototype;super(e),this.__proto__=t}}class J extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="UnsupportedTransportError",this.__proto__=i}}class Q extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="DisabledTransportError",this.__proto__=i}}class ee extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="FailedToStartTransportError",this.__proto__=i}}class te extends Error{constructor(e){var t=new.target.prototype;super(e),this.errorType="FailedToNegotiateWithServerError",this.__proto__=t}}class ie extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.innerErrors=t,this.__proto__=i}}class re{constructor(e,t,i){this.statusCode=e,this.statusText=t,this.content=i}}class ne{get(e,t){return this.send({...t,method:"GET",url:e})}post(e,t){return this.send({...t,method:"POST",url:e})}delete(e,t){return this.send({...t,method:"DELETE",url:e})}getCookieString(e){return""}}var oe,se,ae,le,ce=i(0),he=i(1);class ue extends ne{constructor(e){if(super(),this._logger=e,"undefined"==typeof fetch){const t=require;this._jar=new(t("tough-cookie").CookieJar),this._fetchType=t("node-fetch"),this._fetchType=t("fetch-cookie")(this._fetchType,this._jar)}else this._fetchType=fetch.bind(Object(he.h)());if("undefined"==typeof AbortController){const i=require;this._abortControllerType=i("abort-controller")}else this._abortControllerType=AbortController}async send(e){if(e.abortSignal&&e.abortSignal.aborted)throw new K;if(!e.method)throw new Error("No method defined.");if(!e.url)throw new Error("No url defined.");const t=new this._abortControllerType;let i;e.abortSignal&&(e.abortSignal.onabort=()=>{t.abort(),i=new K});let r=null;e.timeout&&(o=e.timeout,r=setTimeout(()=>{t.abort(),this._logger.log(ce.a.Warning,"Timeout from HTTP request."),i=new H},o));let n;try{n=await this._fetchType(e.url,{body:e.content,cache:"no-cache",credentials:!0===e.withCredentials?"include":"same-origin",headers:{"Content-Type":"text/plain;charset=UTF-8","X-Requested-With":"XMLHttpRequest",...e.headers},method:e.method,mode:"cors",redirect:"follow",signal:t.signal})}catch(e){if(i)throw i;throw this._logger.log(ce.a.Warning,`Error from HTTP request. ${e}.`),e}finally{r&&clearTimeout(r),e.abortSignal&&(e.abortSignal.onabort=null)}if(!n.ok){var o=await pe(n,"text");throw new X(o||n.statusText,n.status)}e=await pe(n,e.responseType);return new re(n.status,n.statusText,e)}getCookieString(e){let i="";return he.c.isNode&&this._jar&&this._jar.getCookies(e,(e,t)=>i=t.join("; ")),i}}function pe(e,t){let i;switch(t){case"arraybuffer":i=e.arrayBuffer();break;case"text":i=e.text();break;case"blob":case"document":case"json":throw new Error(`${t} is not supported.`);default:i=e.text()}return i}class de extends ne{constructor(e){super(),this._logger=e}send(n){return n.abortSignal&&n.abortSignal.aborted?Promise.reject(new K):n.method?n.url?new Promise((e,t)=>{const i=new XMLHttpRequest;i.open(n.method,n.url,!0),i.withCredentials=void 0===n.withCredentials||n.withCredentials,i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.setRequestHeader("Content-Type","text/plain;charset=UTF-8");const r=n.headers;r&&Object.keys(r).forEach(e=>{i.setRequestHeader(e,r[e])}),n.responseType&&(i.responseType=n.responseType),n.abortSignal&&(n.abortSignal.onabort=()=>{i.abort(),t(new K)}),n.timeout&&(i.timeout=n.timeout),i.onload=()=>{n.abortSignal&&(n.abortSignal.onabort=null),200<=i.status&&i.status<300?e(new re(i.status,i.statusText,i.response||i.responseText)):t(new X(i.response||i.responseText||i.statusText,i.status))},i.onerror=()=>{this._logger.log(ce.a.Warning,`Error from HTTP request. ${i.status}: ${i.statusText}.`),t(new X(i.statusText,i.status))},i.ontimeout=()=>{this._logger.log(ce.a.Warning,"Timeout from HTTP request."),t(new H)},i.send(n.content||"")}):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class fe extends ne{constructor(e){if(super(),"undefined"!=typeof fetch||he.c.isNode)this._httpClient=new ue(e);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this._httpClient=new de(e)}}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new K):e.method?e.url?this._httpClient.send(e):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(e){return this._httpClient.getCookieString(e)}}class me{}me.Authorization="Authorization",me.Cookie="Cookie",(t=oe=oe||{})[t.None=0]="None",t[t.WebSockets=1]="WebSockets",t[t.ServerSentEvents=2]="ServerSentEvents",t[t.LongPolling=4]="LongPolling",(t=se=se||{})[t.Text=1]="Text",t[t.Binary=2]="Binary";class _e{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}}class ge{constructor(e,t,i,r){this._httpClient=e,this._accessTokenFactory=t,this._logger=i,this._pollAbort=new _e,this._options=r,this._running=!1,this.onreceive=null,this.onclose=null}get pollAborted(){return this._pollAbort.aborted}async connect(e,t){if(he.a.isRequired(e,"url"),he.a.isRequired(t,"transferFormat"),he.a.isIn(t,se,"transferFormat"),this._url=e,this._logger.log(ce.a.Trace,"(LongPolling transport) Connecting."),t===se.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");var[i,r]=Object(he.i)(),r={[i]:r,...this._options.headers};const n={abortSignal:this._pollAbort.signal,headers:r,timeout:1e5,withCredentials:this._options.withCredentials};t===se.Binary&&(n.responseType="arraybuffer");t=await this._getAccessToken();this._updateHeaderToken(n,t);e=`${e}&_=${Date.now()}`;this._logger.log(ce.a.Trace,`(LongPolling transport) polling: ${e}.`);e=await this._httpClient.get(e,n);200!==e.statusCode?(this._logger.log(ce.a.Error,`(LongPolling transport) Unexpected response code: ${e.statusCode}.`),this._closeError=new X(e.statusText||"",e.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,n)}async _getAccessToken(){return this._accessTokenFactory?this._accessTokenFactory():null}_updateHeaderToken(e,t){e.headers||(e.headers={}),t?e.headers[me.Authorization]=`Bearer ${t}`:e.headers[me.Authorization]&&delete e.headers[me.Authorization]}async _poll(e,t){try{for(;this._running;){var i=await this._getAccessToken();this._updateHeaderToken(t,i);try{var r=`${e}&_=${Date.now()}`;this._logger.log(ce.a.Trace,`(LongPolling transport) polling: ${r}.`);var n=await this._httpClient.get(r,t);204===n.statusCode?(this._logger.log(ce.a.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):200!==n.statusCode?(this._logger.log(ce.a.Error,`(LongPolling transport) Unexpected response code: ${n.statusCode}.`),this._closeError=new X(n.statusText||"",n.statusCode),this._running=!1):n.content?(this._logger.log(ce.a.Trace,`(LongPolling transport) data received. ${Object(he.f)(n.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(n.content)):this._logger.log(ce.a.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(e){this._running?e instanceof H?this._logger.log(ce.a.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=e,this._running=!1):this._logger.log(ce.a.Trace,`(LongPolling transport) Poll errored after shutdown: ${e.message}`)}}}finally{this._logger.log(ce.a.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(e){return this._running?Object(he.k)(this._logger,"LongPolling",this._httpClient,this._url,this._accessTokenFactory,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(ce.a.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(ce.a.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const n={};var[e,t]=Object(he.i)();n[e]=t;var i={headers:{...n,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials},r=await this._getAccessToken();this._updateHeaderToken(i,r),await this._httpClient.delete(this._url,i),this._logger.log(ce.a.Trace,"(LongPolling transport) DELETE request sent.")}finally{this._logger.log(ce.a.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let e="(LongPolling transport) Firing onclose event.";this._closeError&&(e+=" Error: "+this._closeError),this._logger.log(ce.a.Trace,e),this.onclose(this._closeError)}}}class ye{constructor(e,t,i,r){this._httpClient=e,this._accessTokenFactory=t,this._logger=i,this._options=r,this.onreceive=null,this.onclose=null}async connect(a,e){var t;return he.a.isRequired(a,"url"),he.a.isRequired(e,"transferFormat"),he.a.isIn(e,se,"transferFormat"),this._logger.log(ce.a.Trace,"(SSE transport) Connecting."),this._url=a,!this._accessTokenFactory||(t=await this._accessTokenFactory())&&(a+=(a.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(t)}`),new Promise((t,i)=>{let r=!1;if(e===se.Text){let e;if(he.c.isBrowser||he.c.isWebWorker)e=new this._options.EventSource(a,{withCredentials:this._options.withCredentials});else{var n=this._httpClient.getCookieString(a);const s={};s.Cookie=n;var[o,n]=Object(he.i)();s[o]=n,e=new this._options.EventSource(a,{withCredentials:this._options.withCredentials,headers:{...s,...this._options.headers}})}try{e.onmessage=e=>{if(this.onreceive)try{this._logger.log(ce.a.Trace,`(SSE transport) data received. ${Object(he.f)(e.data,this._options.logMessageContent)}.`),this.onreceive(e.data)}catch(e){return void this._close(e)}},e.onerror=e=>{r?this._close():i(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},e.onopen=()=>{this._logger.log(ce.a.Information,`SSE connected to ${this._url}`),this._eventSource=e,r=!0,t()}}catch(e){return void i(e)}}else i(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))})}async send(e){return this._eventSource?Object(he.k)(this._logger,"SSE",this._httpClient,this._url,this._accessTokenFactory,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(e){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(e))}}class xe{constructor(e,t,i,r,n,o){this._logger=i,this._accessTokenFactory=t,this._logMessageContent=r,this._webSocketConstructor=n,this._httpClient=e,this.onreceive=null,this.onclose=null,this._headers=o}async connect(l,c){var e;return he.a.isRequired(l,"url"),he.a.isRequired(c,"transferFormat"),he.a.isIn(c,se,"transferFormat"),this._logger.log(ce.a.Trace,"(WebSockets transport) Connecting."),!this._accessTokenFactory||(e=await this._accessTokenFactory())&&(l+=(l.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(e)}`),new Promise((t,i)=>{l=l.replace(/^http/,"ws");let r;var e=this._httpClient.getCookieString(l);let n=!1;if(he.c.isNode){const a={};var[o,s]=Object(he.i)();a[o]=s,e&&(a[me.Cookie]=`${e}`),r=new this._webSocketConstructor(l,void 0,{headers:{...a,...this._headers}})}r=r||new this._webSocketConstructor(l),c===se.Binary&&(r.binaryType="arraybuffer"),r.onopen=e=>{this._logger.log(ce.a.Information,`WebSocket connected to ${l}.`),this._webSocket=r,n=!0,t()},r.onerror=e=>{let t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:"There was an error with the transport",this._logger.log(ce.a.Information,`(WebSockets transport) ${t}.`)},r.onmessage=e=>{if(this._logger.log(ce.a.Trace,`(WebSockets transport) data received. ${Object(he.f)(e.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(e.data)}catch(e){return void this._close(e)}},r.onclose=t=>{if(n)this._close(t);else{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",i(new Error(e))}}})}send(e){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(ce.a.Trace,`(WebSockets transport) sending data. ${Object(he.f)(e,this._logMessageContent)}.`),this._webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(e){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(ce.a.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this._isCloseEvent(e)||!1!==e.wasClean&&1e3===e.code?e instanceof Error?this.onclose(e):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${e.code} (${e.reason||"no reason given"}).`)))}_isCloseEvent(e){return e&&"boolean"==typeof e.wasClean&&"number"==typeof e.code}}class ve{constructor(e,t={}){if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,he.a.isRequired(e,"url"),this._logger=Object(he.e)(t.logger),this.baseUrl=this._resolveUrl(e),(t=t||{}).logMessageContent=void 0!==t.logMessageContent&&t.logMessageContent,"boolean"!=typeof t.withCredentials&&void 0!==t.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");t.withCredentials=void 0===t.withCredentials||t.withCredentials,t.timeout=void 0===t.timeout?1e5:t.timeout;let i=null,r=null;if(he.c.isNode){const n=require;i=n("ws"),r=n("eventsource")}he.c.isNode||"undefined"==typeof WebSocket||t.WebSocket?he.c.isNode&&!t.WebSocket&&i&&(t.WebSocket=i):t.WebSocket=WebSocket,he.c.isNode||"undefined"==typeof EventSource||t.EventSource?he.c.isNode&&!t.EventSource&&void 0!==r&&(t.EventSource=r):t.EventSource=EventSource,this._httpClient=t.httpClient||new fe(this._logger),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=t,this.onreceive=null,this.onclose=null}async start(e){if(e=e||se.Binary,he.a.isIn(e,se,"transferFormat"),this._logger.log(ce.a.Debug,`Starting connection with transfer format '${se[e]}'.`),"Disconnected"!==this._connectionState)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(e),await this._startInternalPromise,"Disconnecting"===this._connectionState){var t="Failed to start the HttpConnection before stop() was called.";return this._logger.log(ce.a.Error,t),await this._stopPromise,Promise.reject(new Error(t))}if("Connected"!==this._connectionState){t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(ce.a.Error,t),Promise.reject(new Error(t))}this._connectionStarted=!0}send(e){return"Connected"!==this._connectionState?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new be(this.transport)),this._sendQueue.send(e))}async stop(e){return"Disconnected"===this._connectionState?(this._logger.log(ce.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this._connectionState?(this._logger.log(ce.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState="Disconnecting",this._stopPromise=new Promise(e=>{this._stopPromiseResolver=e}),await this._stopInternal(e),void await this._stopPromise)}async _stopInternal(e){this._stopError=e;try{await this._startInternalPromise}catch(e){}if(this.transport){try{await this.transport.stop()}catch(e){this._logger.log(ce.a.Error,`HttpConnection.transport.stop() threw error '${e}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(ce.a.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(i){let r=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory;try{if(this._options.skipNegotiation){if(this._options.transport!==oe.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this._constructTransport(oe.WebSockets),await this._startTransport(r,i)}else{let e=null,t=0;do{if(e=await this._getNegotiationResponse(r),"Disconnecting"===this._connectionState||"Disconnected"===this._connectionState)throw new Error("The connection was stopped during negotiation.");if(e.error)throw new Error(e.error);if(e.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(e.url&&(r=e.url),e.accessToken){const n=e.accessToken;this._accessTokenFactory=()=>n}}while(t++,e.url&&t<100);if(100===t&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(r,this._options.transport,e,i)}this.transport instanceof ge&&(this.features.inherentKeepAlive=!0),"Connecting"===this._connectionState&&(this._logger.log(ce.a.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(e){return this._logger.log(ce.a.Error,"Failed to start the connection: "+e),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(e)}}async _getNegotiationResponse(e){const t={};!this._accessTokenFactory||(r=await this._accessTokenFactory())&&(t[me.Authorization]=`Bearer ${r}`);var[i,r]=Object(he.i)();t[i]=r;e=this._resolveNegotiateUrl(e);this._logger.log(ce.a.Debug,`Sending negotiation request: ${e}.`);try{var n=await this._httpClient.post(e,{content:"",headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(200!==n.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${n.statusCode}'`));const o=JSON.parse(n.content);return(!o.negotiateVersion||o.negotiateVersion<1)&&(o.connectionToken=o.connectionId),o}catch(e){let t="Failed to complete negotiation with the server: "+e;return e instanceof X&&404===e.statusCode&&(t+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(ce.a.Error,t),Promise.reject(new te(t))}}_createConnectUrl(e,t){return t?e+(-1===e.indexOf("?")?"?":"&")+`id=${t}`:e}async _createTransport(e,t,i,r){let n=this._createConnectUrl(e,i.connectionToken);if(this._isITransport(t))return this._logger.log(ce.a.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=t,await this._startTransport(n,r),void(this.connectionId=i.connectionId);const o=[];let s=i;for(const l of i.availableTransports||[]){var a=this._resolveTransportOrError(l,t,r);if(a instanceof Error)o.push(`${l.transport} failed:`),o.push(a);else if(this._isITransport(a)){if(this.transport=a,!s){try{s=await this._getNegotiationResponse(e)}catch(e){return Promise.reject(e)}n=this._createConnectUrl(e,s.connectionToken)}try{return await this._startTransport(n,r),void(this.connectionId=s.connectionId)}catch(e){if(this._logger.log(ce.a.Error,`Failed to start the transport '${l.transport}': ${e}`),s=void 0,o.push(new ee(`${l.transport} failed: ${e}`,oe[l.transport])),"Connecting"!==this._connectionState){a="Failed to select transport before stop() was called.";return this._logger.log(ce.a.Debug,a),Promise.reject(new Error(a))}}}}return 0<o.length?Promise.reject(new ie(`Unable to connect to the server with any of the available transports. ${o.join(" ")}`,o)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(e){switch(e){case oe.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new xe(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case oe.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new ye(this._httpClient,this._accessTokenFactory,this._logger,this._options);case oe.LongPolling:return new ge(this._httpClient,this._accessTokenFactory,this._logger,this._options);default:throw new Error(`Unknown transport: ${e}.`)}}_startTransport(e,t){return this.transport.onreceive=this.onreceive,this.transport.onclose=e=>this._stopConnection(e),this.transport.connect(e,t)}_resolveTransportOrError(e,t,i){var r,n=oe[e.transport];if(null==n)return this._logger.log(ce.a.Debug,`Skipping transport '${e.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);if(r=n,(t=t)&&0==(r&t))return this._logger.log(ce.a.Debug,`Skipping transport '${oe[n]}' because it was disabled by the client.`),new Q(`'${oe[n]}' is disabled by the client.`,n);{const o=e.transferFormats.map(e=>se[e]);if(!(0<=o.indexOf(i)))return this._logger.log(ce.a.Debug,`Skipping transport '${oe[n]}' because it does not support the requested transfer format '${se[i]}'.`),new Error(`'${oe[n]}' does not support ${se[i]}.`);if(n===oe.WebSockets&&!this._options.WebSocket||n===oe.ServerSentEvents&&!this._options.EventSource)return this._logger.log(ce.a.Debug,`Skipping transport '${oe[n]}' because it is not supported in your environment.'`),new J(`'${oe[n]}' is not supported in your environment.`,n);this._logger.log(ce.a.Debug,`Selecting transport '${oe[n]}'.`);try{return this._constructTransport(n)}catch(e){return e}}}_isITransport(e){return e&&"object"==typeof e&&"connect"in e}_stopConnection(t){if(this._logger.log(ce.a.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this._connectionState}.`),this.transport=void 0,t=this._stopError||t,this._stopError=void 0,"Disconnected"!==this._connectionState){if("Connecting"===this._connectionState)throw this._logger.log(ce.a.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this._connectionState&&this._stopPromiseResolver(),t?this._logger.log(ce.a.Error,`Connection disconnected with error '${t}'.`):this._logger.log(ce.a.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch(e=>{this._logger.log(ce.a.Error,`TransportSendQueue.stop() threw error '${e}'.`)}),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(t)}catch(e){this._logger.log(ce.a.Error,`HttpConnection.onclose(${t}) threw error '${e}'.`)}}}else this._logger.log(ce.a.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}_resolveUrl(e){if(0===e.lastIndexOf("https://",0)||0===e.lastIndexOf("http://",0))return e;if(!he.c.isBrowser)throw new Error(`Cannot resolve '${e}'.`);const t=window.document.createElement("a");return t.href=e,this._logger.log(ce.a.Information,`Normalizing '${e}' to '${t.href}'.`),t.href}_resolveNegotiateUrl(e){var t=e.indexOf("?");let i=e.substring(0,-1===t?e.length:t);return"/"!==i[i.length-1]&&(i+="/"),i+="negotiate",i+=-1===t?"":e.substring(t),-1===i.indexOf("negotiateVersion")&&(i+=-1===t?"?":"&",i+="negotiateVersion="+this._negotiateVersion),i}}class be{constructor(e){this._transport=e,this._buffer=[],this._executing=!0,this._sendBufferedData=new we,this._transportResult=new we,this._sendLoopPromise=this._sendLoop()}send(e){return this._bufferData(e),this._transportResult||(this._transportResult=new we),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(e){if(this._buffer.length&&typeof this._buffer[0]!=typeof e)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof e}`);this._buffer.push(e),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new we;const t=this._transportResult;this._transportResult=void 0;var e="string"==typeof this._buffer[0]?this._buffer.join(""):be._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(e),t.resolve()}catch(e){t.reject(e)}}}static _concatBuffers(e){var t=e.map(e=>e.byteLength).reduce((e,t)=>e+t);const i=new Uint8Array(t);let r=0;for(const n of e)i.set(new Uint8Array(n),r),r+=n.byteLength;return i.buffer}}class we{constructor(){this.promise=new Promise((e,t)=>[this._resolver,this._rejecter]=[e,t])}resolve(){this._resolver()}reject(e){this._rejecter(e)}}class Te{static write(e){return`${e}${Te.RecordSeparator}`}static parse(e){if(e[e.length-1]!==Te.RecordSeparator)throw new Error("Message is incomplete.");const t=e.split(Te.RecordSeparator);return t.pop(),t}}Te.RecordSeparatorCode=30,Te.RecordSeparator=String.fromCharCode(Te.RecordSeparatorCode);class Ee{writeHandshakeRequest(e){return Te.write(JSON.stringify(e))}parseHandshakeResponse(e){let t,i;if(Object(he.j)(e)){const o=new Uint8Array(e);var r=o.indexOf(Te.RecordSeparatorCode);if(-1===r)throw new Error("Message is incomplete.");r=r+1;t=String.fromCharCode.apply(null,Array.prototype.slice.call(o.slice(0,r))),i=o.byteLength>r?o.slice(r).buffer:null}else{const s=e;var n=s.indexOf(Te.RecordSeparator);if(-1===n)throw new Error("Message is incomplete.");n=n+1;t=s.substring(0,n),i=s.length>n?s.substring(n):null}n=Te.parse(t),n=JSON.parse(n[0]);if(n.type)throw new Error("Expected a handshake response from the server.");return[i,n]}}(t=ae=ae||{})[t.Invocation=1]="Invocation",t[t.StreamItem=2]="StreamItem",t[t.Completion=3]="Completion",t[t.StreamInvocation=4]="StreamInvocation",t[t.CancelInvocation=5]="CancelInvocation",t[t.Ping=6]="Ping",t[t.Close=7]="Close";class Ae{constructor(){this.observers=[]}next(e){for(const t of this.observers)t.next(e)}error(e){for(const t of this.observers)t.error&&t.error(e)}complete(){for(const e of this.observers)e.complete&&e.complete()}subscribe(e){return this.observers.push(e),new he.d(this,e)}}(t=le=le||{}).Disconnected="Disconnected",t.Connecting="Connecting",t.Connected="Connected",t.Disconnecting="Disconnecting",t.Reconnecting="Reconnecting";class Se{constructor(e,t,i,r){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(ce.a.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},he.a.isRequired(e,"connection"),he.a.isRequired(t,"logger"),he.a.isRequired(i,"protocol"),this.serverTimeoutInMilliseconds=3e4,this.keepAliveIntervalInMilliseconds=15e3,this._logger=t,this._protocol=i,this.connection=e,this._reconnectPolicy=r,this._handshakeProtocol=new Ee,this.connection.onreceive=e=>this._processIncomingData(e),this.connection.onclose=e=>this._connectionClosed(e),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=le.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:ae.Ping})}static create(e,t,i,r){return new Se(e,t,i,r)}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(e){if(this._connectionState!==le.Disconnected&&this._connectionState!==le.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!e)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=e}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==le.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=le.Connecting,this._logger.log(ce.a.Debug,"Starting HubConnection.");try{await this._startInternal(),he.c.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=le.Connected,this._connectionStarted=!0,this._logger.log(ce.a.Debug,"HubConnection connected successfully.")}catch(e){return this._connectionState=le.Disconnected,this._logger.log(ce.a.Debug,`HubConnection failed to start successfully because of error '${e}'.`),Promise.reject(e)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;var e=new Promise((e,t)=>{this._handshakeResolver=e,this._handshakeRejecter=t});await this.connection.start(this._protocol.transferFormat);try{var t={protocol:this._protocol.name,version:this._protocol.version};if(this._logger.log(ce.a.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(t)),this._logger.log(ce.a.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await e,this._stopDuringStartError)throw this._stopDuringStartError}catch(e){throw this._logger.log(ce.a.Debug,`Hub handshake failed with error '${e}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(e),e}}async stop(){var e=this._startPromise;this._stopPromise=this._stopInternal(),await this._stopPromise;try{await e}catch(e){}}_stopInternal(e){return this._connectionState===le.Disconnected?(this._logger.log(ce.a.Debug,`Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`),Promise.resolve()):this._connectionState===le.Disconnecting?(this._logger.log(ce.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState=le.Disconnecting,this._logger.log(ce.a.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(ce.a.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=e||new Error("The connection was stopped before the hub handshake could complete."),this.connection.stop(e)))}stream(e,...t){var[i,r]=this._replaceStreamingParams(t);const n=this._createStreamInvocation(e,t,r);let o;const s=new Ae;return s.cancelCallback=()=>{const e=this._createCancelInvocation(n.invocationId);return delete this._callbacks[n.invocationId],o.then(()=>this._sendWithProtocol(e))},this._callbacks[n.invocationId]=(e,t)=>{t?s.error(t):e&&(e.type===ae.Completion?e.error?s.error(new Error(e.error)):s.complete():s.next(e.item))},o=this._sendWithProtocol(n).catch(e=>{s.error(e),delete this._callbacks[n.invocationId]}),this._launchStreams(i,o),s}_sendMessage(e){return this._resetKeepAliveInterval(),this.connection.send(e)}_sendWithProtocol(e){return this._sendMessage(this._protocol.writeMessage(e))}send(e,...t){var[i,r]=this._replaceStreamingParams(t),r=this._sendWithProtocol(this._createInvocation(e,t,!0,r));return this._launchStreams(i,r),r}invoke(e,...t){const[n,i]=this._replaceStreamingParams(t),o=this._createInvocation(e,t,!1,i);return new Promise((i,r)=>{this._callbacks[o.invocationId]=(e,t)=>{t?r(t):e&&(e.type===ae.Completion?e.error?r(new Error(e.error)):i(e.result):r(new Error(`Unexpected message type: ${e.type}`)))};var e=this._sendWithProtocol(o).catch(e=>{r(e),delete this._callbacks[o.invocationId]});this._launchStreams(n,e)})}on(e,t){e&&t&&(e=e.toLowerCase(),this._methods[e]||(this._methods[e]=[]),-1===this._methods[e].indexOf(t)&&this._methods[e].push(t))}off(e,t){if(e){e=e.toLowerCase();const i=this._methods[e];i&&(t?-1!==(t=i.indexOf(t))&&(i.splice(t,1),0===i.length&&delete this._methods[e]):delete this._methods[e])}}onclose(e){e&&this._closedCallbacks.push(e)}onreconnecting(e){e&&this._reconnectingCallbacks.push(e)}onreconnected(e){e&&this._reconnectedCallbacks.push(e)}_processIncomingData(e){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(e=this._processHandshakeResponse(e),this._receivedHandshakeResponse=!0),e)for(const i of this._protocol.parseMessages(e,this._logger))switch(i.type){case ae.Invocation:this._invokeClientMethod(i);break;case ae.StreamItem:case ae.Completion:{const r=this._callbacks[i.invocationId];if(r){i.type===ae.Completion&&delete this._callbacks[i.invocationId];try{r(i)}catch(e){this._logger.log(ce.a.Error,`Stream callback threw error: ${Object(he.g)(e)}`)}}break}case ae.Ping:break;case ae.Close:this._logger.log(ce.a.Information,"Close message received from server.");var t=i.error?new Error("Server returned an error on close: "+i.error):void 0;!0===i.allowReconnect?this.connection.stop(t):this._stopPromise=this._stopInternal(t);break;default:this._logger.log(ce.a.Warning,`Invalid message type: ${i.type}.`)}this._resetTimeoutPeriod()}_processHandshakeResponse(e){let t,i;try{[i,t]=this._handshakeProtocol.parseHandshakeResponse(e)}catch(e){var r="Error parsing handshake response: "+e;this._logger.log(ce.a.Error,r);r=new Error(r);throw this._handshakeRejecter(r),r}if(t.error){r="Server returned handshake error: "+t.error;this._logger.log(ce.a.Error,r);r=new Error(r);throw this._handshakeRejecter(r),r}return this._logger.log(ce.a.Debug,"Server handshake complete."),this._handshakeResolver(),i}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this._timeoutHandle=setTimeout(()=>this.serverTimeout(),this.serverTimeoutInMilliseconds),void 0!==this._pingServerHandle))){let e=this._nextKeepAlive-(new Date).getTime();e<0&&(e=0),this._pingServerHandle=setTimeout(async()=>{if(this._connectionState===le.Connected)try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}},e)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}_invokeClientMethod(t){const e=this._methods[t.target.toLowerCase()];if(e){try{e.forEach(e=>e.apply(this,t.arguments))}catch(e){this._logger.log(ce.a.Error,`A callback for the method ${t.target.toLowerCase()} threw error '${e}'.`)}var i;t.invocationId&&(this._logger.log(ce.a.Error,i="Server requested a response, which is not supported in this version of the client."),this._stopPromise=this._stopInternal(new Error(i)))}else this._logger.log(ce.a.Warning,`No client method with the name '${t.target}' found.`)}_connectionClosed(e){this._logger.log(ce.a.Debug,`HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||e||new Error("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(e||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===le.Disconnecting?this._completeClose(e):this._connectionState===le.Connected&&this._reconnectPolicy?this._reconnect(e):this._connectionState===le.Connected&&this._completeClose(e)}_completeClose(t){if(this._connectionStarted){this._connectionState=le.Disconnected,this._connectionStarted=!1,he.c.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach(e=>e.apply(this,[t]))}catch(e){this._logger.log(ce.a.Error,`An onclose callback called with error '${t}' threw error '${e}'.`)}}}async _reconnect(t){var i=Date.now();let r=0;var n=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error.");let o=this._getNextRetryDelay(r++,0,n);if(null===o)return this._logger.log(ce.a.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this._completeClose(t);if(this._connectionState=le.Reconnecting,t?this._logger.log(ce.a.Information,`Connection reconnecting because of error '${t}'.`):this._logger.log(ce.a.Information,"Connection reconnecting."),0!==this._reconnectingCallbacks.length){try{this._reconnectingCallbacks.forEach(e=>e.apply(this,[t]))}catch(e){this._logger.log(ce.a.Error,`An onreconnecting callback called with error '${t}' threw error '${e}'.`)}if(this._connectionState!==le.Reconnecting)return void this._logger.log(ce.a.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==o;){if(this._logger.log(ce.a.Information,`Reconnect attempt number ${r} will start in ${o} ms.`),await new Promise(e=>{this._reconnectDelayHandle=setTimeout(e,o)}),this._reconnectDelayHandle=void 0,this._connectionState!==le.Reconnecting)return void this._logger.log(ce.a.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this._startInternal(),this._connectionState=le.Connected,this._logger.log(ce.a.Information,"HubConnection reconnected successfully."),0!==this._reconnectedCallbacks.length)try{this._reconnectedCallbacks.forEach(e=>e.apply(this,[this.connection.connectionId]))}catch(e){this._logger.log(ce.a.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${e}'.`)}return}catch(e){if(this._logger.log(ce.a.Information,`Reconnect attempt failed because of error '${e}'.`),this._connectionState!==le.Reconnecting)return this._logger.log(ce.a.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this._connectionState===le.Disconnecting&&this._completeClose());n=e instanceof Error?e:new Error(e.toString()),o=this._getNextRetryDelay(r++,Date.now()-i,n)}}this._logger.log(ce.a.Information,`Reconnect retries have been exhausted after ${Date.now()-i} ms and ${r} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(t,i,e){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:i,previousRetryCount:t,retryReason:e})}catch(e){return this._logger.log(ce.a.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${i}) threw error '${e}'.`),null}}_cancelCallbacksWithError(i){const r=this._callbacks;this._callbacks={},Object.keys(r).forEach(e=>{const t=r[e];try{t(null,i)}catch(e){this._logger.log(ce.a.Error,`Stream 'error' callback called with '${i}' threw error: ${Object(he.g)(e)}`)}})}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(e,t,i,r){if(i)return 0!==r.length?{arguments:t,streamIds:r,target:e,type:ae.Invocation}:{arguments:t,target:e,type:ae.Invocation};{const n=this._invocationId;return this._invocationId++,0!==r.length?{arguments:t,invocationId:n.toString(),streamIds:r,target:e,type:ae.Invocation}:{arguments:t,invocationId:n.toString(),target:e,type:ae.Invocation}}}_launchStreams(e,i){if(0!==e.length){i=i||Promise.resolve();for(const r in e)e[r].subscribe({complete:()=>{i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(r)))},error:e=>{let t;t=e instanceof Error?e.message:e&&e.toString?e.toString():"Unknown error",i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(r,t)))},next:e=>{i=i.then(()=>this._sendWithProtocol(this._createStreamItemMessage(r,e)))}})}}_replaceStreamingParams(t){const i=[],r=[];for(let e=0;e<t.length;e++){var n=t[e];if(this._isObservable(n)){const o=this._invocationId;this._invocationId++,i[o]=n,r.push(o.toString()),t.splice(e,1)}}return[i,r]}_isObservable(e){return e&&e.subscribe&&"function"==typeof e.subscribe}_createStreamInvocation(e,t,i){const r=this._invocationId;return this._invocationId++,0!==i.length?{arguments:t,invocationId:r.toString(),streamIds:i,target:e,type:ae.StreamInvocation}:{arguments:t,invocationId:r.toString(),target:e,type:ae.StreamInvocation}}_createCancelInvocation(e){return{invocationId:e,type:ae.CancelInvocation}}_createStreamItemMessage(e,t){return{invocationId:e,item:t,type:ae.StreamItem}}_createCompletionMessage(e,t,i){return t?{error:t,invocationId:e,type:ae.Completion}:{invocationId:e,result:i,type:ae.Completion}}}var Ce=i(11);class Me{constructor(){this.name="json",this.version=1,this.transferFormat=se.Text}parseMessages(e,t){if("string"!=typeof e)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!e)return[];null===t&&(t=Ce.a.instance);const i=[];for(const n of Te.parse(e)){var r=JSON.parse(n);if("number"!=typeof r.type)throw new Error("Invalid payload.");switch(r.type){case ae.Invocation:this._isInvocationMessage(r);break;case ae.StreamItem:this._isStreamItemMessage(r);break;case ae.Completion:this._isCompletionMessage(r);break;case ae.Ping:case ae.Close:break;default:t.log(ce.a.Information,"Unknown message type '"+r.type+"' ignored.");continue}i.push(r)}return i}writeMessage(e){return Te.write(JSON.stringify(e))}_isInvocationMessage(e){this._assertNotEmptyString(e.target,"Invalid payload for Invocation message."),void 0!==e.invocationId&&this._assertNotEmptyString(e.invocationId,"Invalid payload for Invocation message.")}_isStreamItemMessage(e){if(this._assertNotEmptyString(e.invocationId,"Invalid payload for StreamItem message."),void 0===e.item)throw new Error("Invalid payload for StreamItem message.")}_isCompletionMessage(e){if(e.result&&e.error)throw new Error("Invalid payload for Completion message.");!e.result&&e.error&&this._assertNotEmptyString(e.error,"Invalid payload for Completion message."),this._assertNotEmptyString(e.invocationId,"Invalid payload for Completion message.")}_assertNotEmptyString(e,t){if("string"!=typeof e||""===e)throw new Error(t)}}const Ie={trace:ce.a.Trace,debug:ce.a.Debug,info:ce.a.Information,information:ce.a.Information,warn:ce.a.Warning,warning:ce.a.Warning,error:ce.a.Error,critical:ce.a.Critical,none:ce.a.None};class Be{configureLogging(e){var t;return he.a.isRequired(e,"logging"),void 0!==e.log?this.logger=e:"string"==typeof e?(t=function(e){var t=Ie[e.toLowerCase()];if(void 0!==t)return t;throw new Error(`Unknown log level: ${e}`)}(e),this.logger=new he.b(t)):this.logger=new he.b(e),this}withUrl(e,t){return he.a.isRequired(e,"url"),he.a.isNotEmpty(e,"url"),this.url=e,this.httpConnectionOptions="object"==typeof t?{...this.httpConnectionOptions,...t}:{...this.httpConnectionOptions,transport:t},this}withHubProtocol(e){return he.a.isRequired(e,"protocol"),this.protocol=e,this}withAutomaticReconnect(e){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return e?Array.isArray(e)?this.reconnectPolicy=new W(e):this.reconnectPolicy=e:this.reconnectPolicy=new W,this}build(){const e=this.httpConnectionOptions||{};if(void 0===e.logger&&(e.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");var t=new ve(this.url,e);return Se.create(t,this.logger||Ce.a.instance,this.protocol||new Me,this.reconnectPolicy)}}var t=i(12),ke=i.n(t);class ze{constructor(e,t="540E5CBA3D09480F8CDE2F69C55934EF",i=[117.28688541016095,39.094144209740534]){this.type="custom",this.renderingMode="3d",this.drones={x:39.094144209740534,y:117.28688541016095,z:0},this.onAdd=(e,t)=>{this.map=e;const i=new BABYLON.Engine(t,!0,{useHighPrecisionMatrix:!0},!0);this.scene=new BABYLON.Scene(i),this.scene.autoClear=!1,this.scene.detachControl(),this.scene.beforeRender=function(){i.wipeCaches(!0)},this.camera=new BABYLON.Camera("mapbox-camera",new BABYLON.Vector3,this.scene);let r=new BABYLON.HemisphericLight("light",new BABYLON.Vector3(1,1,0),this.scene);r.intensity=1,r.diffuse=BABYLON.Color3.FromHexString("#FFFFFF"),r.specular=BABYLON.Color3.Black();let n=new BABYLON.HemisphericLight("light1",new BABYLON.Vector3(-1,1,0),this.scene);n.intensity=.7,n.diffuse=BABYLON.Color3.FromHexString("#FFFFFF"),n.specular=BABYLON.Color3.Black(),e.on("click",e=>{console.log(e)}),this.recalculateProjectionMatrix(this.initialCoordinates),BABYLON.SceneLoader.LoadAssetContainerAsync(Pe.rl+"bundle/"+this.modelsId+"/",this.modelsId+".gltf",this.scene).then(e=>{e.addAllToScene();const t=e.meshes[0];e=ke.a.MercatorCoordinate.fromLngLat(this.initialCoordinates,0);t.position=new BABYLON.Vector3((e.x-this.sceneOrigin.x)/this.modelScale,0,-(e.y-this.sceneOrigin.y)/this.modelScale),t.rotation=new BABYLON.Vector3(0,Math.PI/13,0)})},this.render=(e,t)=>{t=BABYLON.Matrix.FromArray(t),t=this.modelMatrix.multiply(t);this.camera.freezeProjectionMatrix(t),this.scene.render(!1),this.map.triggerRepaint()},this.id=e,this.modelsId=t,this.initialCoordinates=i}recalculateProjectionMatrix(e){var t=[Math.PI/2,0,0];const i=ke.a.MercatorCoordinate.fromLngLat(e,0);this.modelScale=i.meterInMercatorCoordinateUnits(),this.sceneOrigin=new BABYLON.Vector3(i.x,i.y,i.z),this.modelMatrix=BABYLON.Matrix.Compose(new BABYLON.Vector3(this.modelScale,this.modelScale,this.modelScale),BABYLON.Quaternion.FromEulerAngles(t[0],t[1],t[2]),this.sceneOrigin)}}class Pe{}Pe.sl="https://www.wodashijie.com/",Pe.rl="https://models.wodashijie.com/",Pe.App=class{constructor(e){e.sl&&(Pe.sl=e.sl),e.rl&&(Pe.rl=e.rl),F.defaults.baseURL=Pe.sl,this.canvas=document.createElement("canvas"),this.canvas.style.cssText="width: 100%;height: 100%;background-color: transparent;outline-width: 0;-webkit-tap-highlight-color:transparent;",e.container.appendChild(this.canvas),this.engine=new BABYLON.Engine(this.canvas,!0,{premultipliedAlpha:!0,preserveDrawingBuffer:!0,stencil:!0,doNotHandleContextLost:!1}),this.engine.setHardwareScalingLevel(.5),this.scene=new BABYLON.Scene(this.engine,{useGeometryUniqueIdsMap:!0,useClonedMeshMap:!0,useMaterialMeshMap:!0}),this.scene.useRightHandedSystem=!0,this.scene.getBoundingBoxRenderer().frontColor=BABYLON.Color3.Green(),this.scene.getBoundingBoxRenderer().showBackLines=!1,this.CameraController=new s(this),this.HighlightLayer=new BABYLON.HighlightLayer("highlightLayer",this.scene),this.IEvent=new r(this),this.container=BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("screenUI"),this.Environment=new g(this),this.Environment.defaultLights(),this.Environment.openAllLight(),this.Resources=new R(this),this.Project=new D(this),Pe.EffectMgr.init(),this.engine.runRenderLoop(()=>{this.fps&&(this.fps.innerText=this.engine.getFps().toFixed()+" fps"),this.scene.render(),v.a.update(),this.IEvent&&this.IEvent.runRender()}),window.addEventListener("resize",()=>{this.engine.resize()}),this.scene.onPointerObservable.add(e=>{this.IEvent&&this.IEvent.onPointer(e)}),this.scene.onKeyboardObservable.add(e=>{this.IEvent&&this.IEvent.onKeyboard(e)})}async load(u){if(u){u.isDefaultLevel=null==u.isDefaultLevel||u.isDefaultLevel,Pe.pk=u.pk;var e=await F.get(`api/service/GetToken?accessToken=${Pe.accessToken}`);if(200==e.status){localStorage.setItem("mx3d-token",e.data);e=await F.get("api/service");if(200==e.status){localStorage.setItem("mx3d-long",e.data);e=await F.get(`api/service/${Pe.pk}`);if(200==e.status){let h=JSON.parse(class{static de(e){let t=localStorage.getItem("mx3d-long");var i=N.a.enc.Utf8.parse(t.substring(0,32)),r=N.a.enc.Utf8.parse(t.substring(32,48)),e=N.a.enc.Hex.parse(e),e=N.a.enc.Base64.stringify(e);return N.a.AES.decrypt(e,i,{iv:r,mode:N.a.mode.CBC,padding:N.a.pad.Pkcs7}).toString(N.a.enc.Utf8).toString()}}.de(e.data));return new Promise(async(r,t)=>{try{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let t=new d;for(let e=0;e<h.length;e++){const a=h[e];!a.baseModel||".gltf"!=a.baseModel.extension||t.find(a.baseModel.modelId)||this.Resources.resources.find(a.baseModel.modelId)||(a.baseModel.objectType=a.objectType,t.add(a.baseModel.modelId,a.baseModel))}let e=0;for(const l in t.map)await this.Resources.loadModelMesh(t.find(l)),e++,u&&u.progress&&u.progress(e/t.count()*.3);e=0,t=null;let i=new d;for(let e=0;e<h.length;e++){var n,o=h[e];o.objectType==f.Region&&(n=new L(this,o),this.Project.objectDatas.add(n.id,n),i.add(n.id,new Array),"0"==n.parentId&&(this.Project.root=n))}for(let e=0;e<h.length;e++){var s=h[e];if(s.objectType!=f.Region){let e=i.find(s.parentId);e.push(s)}}for(const c in i.map)await this.Project.objectDatas.find(c).bind(i.find(c)),e++,u&&u.progress&&u.progress(.3+e/i.count()*.7);i=null,this.Project.optimization(),u.isDefaultLevel&&this.Project.switchLevel(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1,r(null),this.engine.resize(),u&&u.complete&&u.complete()}catch(e){t(e)}})}}}}else console.error("场景编号不能为空!")}dispose(){this.Environment.hideFps(),this.Project.clear(),this.Resources.delete(),this.engine.dispose()}},Pe.Earth=class{constructor(e,t=[117.28688541016095,39.094144209740534]){this.initialCoordinates=[117.28688541016095,39.094144209740534],this.initialCoordinates=t,ke.a.accessToken="pk.eyJ1IjoibGl1ayIsImEiOiJjanczNmJoZjkwY3IxM3lxcTd1NmMwZWxjIn0.11SpcY8De0c1q6S3a-2Qcg",this.map=new ke.a.Map({container:e,style:"mapbox://styles/mapbox/satellite-streets-v11",zoom:1.5,center:this.initialCoordinates,projection:"globe"})}load(e){this.map.on("style.load",()=>{this.map.setFog({color:"rgb(220, 159, 159)","high-color":"rgb(36, 92, 223)","horizon-blend":.4}),this.map.addSource("mapbox-dem",{type:"raster-dem",url:"mapbox://mapbox.terrain-rgb"}),this.map.setTerrain({source:"mapbox-dem",exaggeration:1.5}),e&&e()})}laodScene(e,t=this.initialCoordinates){t=new ze("babylon-layer",e,t);this.map.addLayer(t)}flyTo(e=this.initialCoordinates,t=18,i=130,r=75,n=12e3){this.map.flyTo({center:e,zoom:t,bearing:i,pitch:r,duration:n,essential:!0})}},Pe.Tools=p,Pe.EffectMgr=b,Pe.HubService=class{static async listener(e){this.connection=(new Be).withUrl(e).configureLogging(ce.a.Error).build(),this.connection.onclose(async()=>{await this.start()}),await this.start()}static async start(){try{await this.connection.start()}catch(e){console.log("无法连接服务器"),setTimeout(this.start,5e3)}}},Pe.UI=class{static createIconFromMesh(e,t,i,r,n){let o=t.Sight.focus.clone();var s=t.instance.getBoundingInfo();return o.y+=(s.boundingBox.maximum.y-s.boundingBox.minimum.y)/2,new j(e,o,i,r,n,t.app.scene)}static createIcon(e,t,i,r){let n;t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,n=new U(e,t.app.scene),n.size=i,n.height=r,n.pint=new BABYLON.Mesh(e+"_pint");e=t.Sight.focus.clone();return n.pint.position=e,n.pint.position.y+=r,n.rect=new BABYLON.GUI.Rectangle,n.rect.isPointerBlocker=!1,n.rect.width=i.width+"px",n.rect.height=i.height+"px",n.rect.thickness=0,t.app.container.addControl(n.rect),n.rect.linkWithMesh(n.pint),t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,n}},Pe.Builder=class{static createMatrixCloud(n){n.displayValues=null!=n.displayValues&&n.displayValues,n.isAlpha=null==n.isAlpha||n.isAlpha,n.isParticle=null==n.isParticle||n.isParticle,n.height=n.height||.5,n.radius=n.radius||2.8,n.isLevelRender=null==n.isLevelRender||n.isLevelRender,n.range=n.range||{max:30,min:16};let o;if(!(n.value||n.value.maxX||n.value.maxY||n.value.data||n.anchor))return o;n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,o=new G(n.anchor);var s=n.anchor.instance.getBoundingInfo();o.mesh=n.anchor.instance.clone(o.id),o.mesh.position.y+=n.height;var a=s.maximum.x-s.minimum.x,l=a/(2*n.value.maxX),c=s.maximum.z-s.minimum.z,h=c/(2*n.value.maxY);let e=new Array;for(let r=0;r<2*n.value.maxX;r++)for(let i=0;i<2*n.value.maxY;i++){let t={x:r,y:i,value:n.range.min};for(let e=0;e<n.value.data.length;e++){var u=n.value.data[e];2*u.x+1==r&&2*u.y+1==i&&(t.value=u.value,u=new BABYLON.Vector3(s.boundingSphere.center.x-(a/2-l*r),o.mesh.position.y,s.boundingSphere.center.z-(c/2-h*i)),o.texts.push(this.createTempVlaue(t.value+"℃",u,n.anchor.app.scene,n.anchor.app.container)))}e.push(t)}o.displayValues=n.displayValues;let t=$.create({width:2*n.value.maxX,height:2*n.value.maxY,radius:n.radius});t.setData({min:n.range.min,max:n.range.max,data:e});let i=new BABYLON.StandardMaterial(o.id,n.anchor.app.scene);return i.diffuseTexture=new BABYLON.Texture(t.getDataURL(),n.anchor.app.scene,!1,!1),i.specularColor=new BABYLON.Color3(0,0,0),i.alpha=.5,n.isAlpha&&(i.diffuseTexture.hasAlpha=!0),n.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getMatrixParticleTex(Pe.rl,n.anchor.app.Resources.FogTex,i.diffuseTexture,o.mesh,n.anchor.app.scene,n.isLevelRender),o.mesh.isVisible=!1),n.isLevelRender&&(o.mesh.renderingGroupId=1),o.mesh.material=i,o.mesh.alwaysSelectAsActiveMesh=!0,o.mesh.freezeWorldMatrix(),n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,o}static _getMatrixParticleTex(e,t,i,r,n,o){let s,a=t.clone(),l=r.getBoundingInfo().boundingBox;var c=(l.extendSizeWorld.x+l.extendSizeWorld.z)/9,t=1500*c*c;l.minimumWorld.subtract(new BABYLON.Vector3(-0,0,-0)),l.maximumWorld.subtract(new BABYLON.Vector3(0,0,0));s&&s.dispose(),BABYLON.GPUParticleSystem.IsSupported&&(s=new BABYLON.GPUParticleSystem("particles",{capacity:t},n),s.activeParticleCount=t,s.manualEmitCount=s.activeParticleCount,s.minEmitBox=l.minimumWorld,s.maxEmitBox=l.maximumWorld),s.particleTexture=a,s.emitter=r,o&&(s.renderingGroupId=1),s.isLocal=!0;let h=new BABYLON.NodeMaterial("nm_heatmapBox_"+r.id,n);return h.loadAsync(e+"resources/horizontalNodeMat.json").then(()=>{h.build(!1),h.getBlockByName("boxTex").texture=i,h.getBlockByName("emitXMin").value=s.minEmitBox.x,h.getBlockByName("emitXMax").value=s.maxEmitBox.x,h.getBlockByName("emitYMin").value=s.minEmitBox.z,h.getBlockByName("emitYMax").value=s.maxEmitBox.z,h.createEffectForParticles(s)}),r.onDispose=()=>{s&&s.dispose()},s.onDispose=()=>{h&&h.dispose(),a&&a.dispose()},s.color1=new BABYLON.Color4(.8,.8,.8,.1),s.color2=new BABYLON.Color4(.95,.95,.95,.15),s.colorDead=new BABYLON.Color4(.9,.9,.9,.1),s.minSize=1.4,s.maxSize=2,s.minLifeTime=Number.MAX_SAFE_INTEGER,s.emitRate=5e4*c,s.blendMode=BABYLON.ParticleSystem.BLENDMODE_STANDARD,s.gravity=new BABYLON.Vector3(0,0,0),s.direction1=new BABYLON.Vector3(0,0,0),s.direction2=new BABYLON.Vector3(0,0,0),s.minAngularSpeed=-2,s.maxAngularSpeed=2,s.minEmitPower=.5,s.maxEmitPower=1,s.updateSpeed=.005,s.start(),s}static createPunctateCloud(r){if(r.displayValues=null!=r.displayValues&&r.displayValues,r.isAlpha=null==r.isAlpha||r.isAlpha,r.isParticle=null==r.isParticle||r.isParticle,r.radius=r.radius||1,r.isLevelRender=null==r.isLevelRender||r.isLevelRender,r.range=r.range||{max:30,min:16},!r.value&&!r.anchor)return console.error("要创建的云图数值为空!"),null;let e;r.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e=new G(r.anchor),e.mesh=BABYLON.MeshBuilder.CreatePlane(e.id,{width:1,height:1,sideOrientation:2},r.anchor.app.scene),e.mesh.scaling=new BABYLON.Vector3(r.radius,r.radius,r.radius),e.mesh.alwaysSelectAsActiveMesh=!0,e.mesh.enablePointerMoveEvents=!1,e.mesh.isPickable=!1,e.mesh.position=r.anchor.instance.position.clone(),e.mesh.rotation.x=Math.PI/2;let n=[];for(let i=0;i<6;i++)for(let t=0;t<6;t++){let e={x:i,y:t,value:r.range.min};2==i&&2==t||3==i&&2==t||2==i&&3==t||3==i&&3==t?e.value=r.value:e.value=r.value-2*(Math.abs(2-i)+Math.abs(2-t)),n.push(e)}e.displayValues=r.displayValues;let t=$.create({width:5,height:5,radius:2});t.setData({min:r.range.min,max:r.range.max,data:n});let i=new BABYLON.StandardMaterial(e.id,r.anchor.app.scene);return i.diffuseTexture=new BABYLON.Texture(t.getDataURL(),r.anchor.app.scene,!1,!1),i.specularColor=new BABYLON.Color3(0,0,0),i.alpha=.5,r.isAlpha&&(i.diffuseTexture.hasAlpha=!0),r.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getColumnarParticleTex(i.diffuseTexture,e.mesh,r.anchor.app.scene,e.anchor.app.Resources.FogTex,r.isLevelRender),e.mesh.isVisible=!1),r.isLevelRender&&(e.mesh.renderingGroupId=1),e.mesh.material=i,e.mesh.alwaysSelectAsActiveMesh=!0,e.mesh.freezeWorldMatrix(),r.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,e}static createColumnCloud(n){if(n.displayValues=null!=n.displayValues&&n.displayValues,n.isAlpha=null==n.isAlpha||n.isAlpha,n.isParticle=null==n.isParticle||n.isParticle,n.radius=n.radius||4,n.isLevelRender=null==n.isLevelRender||n.isLevelRender,n.range=n.range||{max:30,min:16},!n.data&&n.data.length<1&&!n.anchor)return console.error("要创建的云图数值为空!"),null;let i;n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,i=new G(n.anchor);var r=.98*n.anchor.instance.scaling.y;i.mesh=BABYLON.MeshBuilder.CreatePlane(i.id,{width:.98*n.anchor.instance.scaling.x,height:r,sideOrientation:2},n.anchor.app.scene),i.mesh.alwaysSelectAsActiveMesh=!0,i.mesh.enablePointerMoveEvents=!1,i.mesh.isPickable=!1,i.mesh.position=n.anchor.instance.position.clone(),i.mesh.rotation.z=Math.PI,i.mesh.rotation.y=n.anchor.instance.rotation.y,n.isLevelRender&&(i.mesh.renderingGroupId=1);let e=[];for(let r=0;r<4;r++)for(let i=0;i<3*n.data.length;i++){let t={x:r,y:i,value:n.range.min};for(let e=0;e<n.data.length;e++){var o=n.data[e];2==r&&3*e+2==i&&(t.value=o.value)}e.push(t)}var s=r/n.data.length;for(let t=0;t<n.data.length;t++){let e=i.mesh.position.clone();e.y=e.y-r/2+(r-s*t-s/2),i.texts.push(this.createTempVlaue(n.data[t].value+"℃",e,n.anchor.app.scene,i.anchor.app.container))}i.displayValues=n.displayValues;let t=$.create({width:4,height:3*n.data.length,radius:n.radius});t.setData({min:n.range.min,max:n.range.max,data:e});let a=new BABYLON.StandardMaterial(i.id,n.anchor.app.scene);return a.diffuseTexture=new BABYLON.Texture(t.getDataURL(),n.anchor.app.scene,!1,!1),a.specularColor=new BABYLON.Color3(0,0,0),a.alpha=.5,n.isAlpha&&(a.diffuseTexture.hasAlpha=!0),n.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getColumnarParticleTex(a.diffuseTexture,i.mesh,n.anchor.app.scene,i.anchor.app.Resources.FogTex,n.isLevelRender),i.mesh.isVisible=!1),i.mesh.material=a,i.mesh.alwaysSelectAsActiveMesh=!0,i.mesh.freezeWorldMatrix(),n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,i}static _getColumnarParticleTex(e,t,i,r,n){let o,s=r.clone();r=t.getBoundingInfo().boundingBox,r.extendSizeWorld.x,r.extendSizeWorld.z;BABYLON.Effect.ShadersStore.particlesVertexShader=`
25
+ `),r.freeze()}return r}delete(e=!1){if(this.BOX&&this.BOX.dispose(),this.transparentBox&&this.transparentBox.dispose(!0,!0),this.BOX=null,this.transparentBox=null,e){for(const t in this.resources.map)this.resources.find(t).removeAllFromScene(),this.resources.remove(t);this.resources.clear()}}async GetWalls(e,t){let i=await BABYLON.SceneLoader.LoadAssetContainerAsync(e,t+".gltf",this.app.scene);if(i.meshes){var r=i.meshes[0].getChildMeshes();for(let e=0;e<r.length;e++)this.walls.add(r[e].id,r[e])}}}t=i(32);const O=i.n(t).a.create();O.defaults.headers.post["Content-Type"]="application/json",O.interceptors.request.use(e=>{var t=localStorage.getItem("mx3d-token");return t&&(e.headers.Authorization="Bearer "+t),e},e=>Promise.reject(e)),O.interceptors.response.use(e=>e,e=>{if(e.response)switch(e.response.status){case 401:console.error("开发者授权码异常");break;case 403:console.error("当前用户没有权限");break;case 400:console.error(e.response.data.message)}return Promise.reject(e)});var F=O,t=i(6),N=i.n(t);class U{constructor(e,t){this.textDics=new Array,this.id=e,this.scene=t}set background(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._background&&this._background.dispose(),this._background=new BABYLON.GUI.Image(a.getGUID(12)+"_Image",e),this._background.width=this.size.width+"px",this._background.height=this.size.height+"px",this.rect.addControl(this._background),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e?(this._background.isPointerBlocker=!1,this._background.onPointerClickObservable.add(()=>{e(this.id)})):this._background.onPointerClickObservable.clear(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setTexts(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.textDics.forEach(e=>e.dispose());for(let t=this.textDics.length=0;t<i.length;t++){let e=new BABYLON.GUI.TextBlock;e.text=i[t].text,e.fontSize=i[t].fontSize||"20px",e.color=i[t].color||"white",e.top=i[t].top||0,e.left=i[t].left||0,this.rect.addControl(e),this.textDics.push(e)}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}line(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._line&&this._line.dispose(),this._line=new BABYLON.GUI.Line,this._line.lineWidth=e.width||1.5,this._line.color=e.color||"green",this._line.y2=this.size.height/2,this.container.addControl(this._line),this._line.linkWithMesh(this.pint),this._line.connectedControl=this.rect,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&this.rect.dispose(),this._line&&this._line.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&(this.rect.isVisible=e),this._line&&(this._line.isVisible=e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class j{constructor(e,t,i,r,n,o){this.id=e,this.scene=o,this.url=i,this.scaling=r,this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance=BABYLON.Mesh.CreatePlane(this.id,r,this.scene,!0,BABYLON.Mesh.DOUBLESIDE),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.position=t.clone(),this.instance.position.y+=n,this.instance.billboardMode=BABYLON.Mesh.BILLBOARDMODE_Y;let s=new BABYLON.StandardMaterial("Mat_"+this.id,this.scene);s.diffuseColor=BABYLON.Color3.White(),s.emissiveColor=BABYLON.Color3.White(),this.instance.material=s,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setBackground(){let i=new Image;i.src=this.url,i.onload=()=>{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.scaling.y=this.scaling/(i.width/i.height)/this.scaling;let e=new BABYLON.DynamicTexture(this.id,{width:i.width,height:i.height},this.scene,!1);e.hasAlpha=!0,this.instance.material.diffuseTexture=e;let t=e.getContext();t.drawImage(i,0,0),e.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}addEventListener(t){if(this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,t){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let e=new BABYLON.ActionManager(this.scene);e.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>t(this.id))),this.instance.actionManager=e}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setColor(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(e),this.instance.material.emissiveColor=BABYLON.Color3.FromHexString(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setContents(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let r=new Image;r.src=this.url,r.onload=()=>{this.instance.scaling.y=this.scaling/(r.width/r.height)/this.scaling;let t=new BABYLON.DynamicTexture(this.id,{width:r.width,height:r.height},this.scene,!1);t.hasAlpha=!0,this.instance.material.diffuseTexture=t;let e=t.getContext();e.drawImage(r,0,0),i.forEach(e=>t.drawText(e.text,e.left,e.top,"bold "+e.fontSize+" monospace",e.color||"#fffffb","",!0,!0)),t.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class V{constructor(e,t){this.anchor=e,this.ratio=t}dispose(){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh&&this.mesh.dispose(),this.textMesh&&this.textMesh.dispose(),this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class G{constructor(e){this.displayValue=!1,this.anchor=e,this.id=a.getGUID(12),this.texts=new Array}isEnabled(t){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh.setEnabled(t),this.texts.forEach(e=>e.isVisible=!!t&&this.displayValue),this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}set displayValues(t){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.texts.forEach(e=>e.isVisible=t),this.displayValue=t,this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh&&this.mesh.dispose();for(let e=0;e<this.texts.length;e++)this.texts[e].linkedMesh&&this.texts[e].linkedMesh.dispose(),this.texts[e].dispose();this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}var $=i(15);class q{constructor(){this.color="#00ff00",this.width=1}update(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose();let t=[];this.objs.forEach(e=>t.push(e.instance.getAbsolutePosition().clone())),this.instance=p.createTube(this.id,t,this.width/100,this.objs[0].app);let e=new BABYLON.StandardMaterial("mat_"+this.id,this.objs[0].app.scene);e.diffuseColor=BABYLON.Color3.FromHexString(this.color),this.instance.material=e,this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(t){if(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,t){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let e=new BABYLON.ActionManager(this.objs[0].app.scene);e.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>t(this.id))),this.instance.actionManager=e}this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.instance&&(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1)}dispose(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class Z{constructor(){this.color="#00ff00",this.width=5,this.isDotted=!1}update(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.instance=new BABYLON.GUI.MultiLine,this.objs[0].app.container.addControl(this.instance),this.instance.lineWidth=this.width,this.instance.color=this.color,this.isDotted&&(this.instance.dash=[1]),this.objs.forEach(e=>this.instance.add(e.instance)),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e?(this.instance.isPointerBlocker=!1,this.instance.onPointerClickObservable.add(()=>{e(this.id)})):this.instance.onPointerClickObservable.clear(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.instance&&(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.isVisible=e,this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1)}dispose(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}const Y=[0,2e3,1e4,3e4,null];class W{constructor(e){this._retryDelays=void 0!==e?[...e,null]:Y}nextRetryDelayInMilliseconds(e){return this._retryDelays[e.previousRetryCount]}}class X extends Error{constructor(e,t){var i=new.target.prototype;super(`${e}: Status code '${t}'`),this.statusCode=t,this.__proto__=i}}class H extends Error{constructor(e="A timeout occurred."){var t=new.target.prototype;super(e),this.__proto__=t}}class K extends Error{constructor(e="An abort occurred."){var t=new.target.prototype;super(e),this.__proto__=t}}class J extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="UnsupportedTransportError",this.__proto__=i}}class Q extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="DisabledTransportError",this.__proto__=i}}class ee extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="FailedToStartTransportError",this.__proto__=i}}class te extends Error{constructor(e){var t=new.target.prototype;super(e),this.errorType="FailedToNegotiateWithServerError",this.__proto__=t}}class ie extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.innerErrors=t,this.__proto__=i}}class re{constructor(e,t,i){this.statusCode=e,this.statusText=t,this.content=i}}class ne{get(e,t){return this.send({...t,method:"GET",url:e})}post(e,t){return this.send({...t,method:"POST",url:e})}delete(e,t){return this.send({...t,method:"DELETE",url:e})}getCookieString(e){return""}}var oe,se,ae,le,ce=i(0),he=i(1);class ue extends ne{constructor(e){if(super(),this._logger=e,"undefined"==typeof fetch){const t=require;this._jar=new(t("tough-cookie").CookieJar),this._fetchType=t("node-fetch"),this._fetchType=t("fetch-cookie")(this._fetchType,this._jar)}else this._fetchType=fetch.bind(Object(he.h)());if("undefined"==typeof AbortController){const i=require;this._abortControllerType=i("abort-controller")}else this._abortControllerType=AbortController}async send(e){if(e.abortSignal&&e.abortSignal.aborted)throw new K;if(!e.method)throw new Error("No method defined.");if(!e.url)throw new Error("No url defined.");const t=new this._abortControllerType;let i;e.abortSignal&&(e.abortSignal.onabort=()=>{t.abort(),i=new K});let r=null;e.timeout&&(o=e.timeout,r=setTimeout(()=>{t.abort(),this._logger.log(ce.a.Warning,"Timeout from HTTP request."),i=new H},o));let n;try{n=await this._fetchType(e.url,{body:e.content,cache:"no-cache",credentials:!0===e.withCredentials?"include":"same-origin",headers:{"Content-Type":"text/plain;charset=UTF-8","X-Requested-With":"XMLHttpRequest",...e.headers},method:e.method,mode:"cors",redirect:"follow",signal:t.signal})}catch(e){if(i)throw i;throw this._logger.log(ce.a.Warning,`Error from HTTP request. ${e}.`),e}finally{r&&clearTimeout(r),e.abortSignal&&(e.abortSignal.onabort=null)}if(!n.ok){var o=await pe(n,"text");throw new X(o||n.statusText,n.status)}e=await pe(n,e.responseType);return new re(n.status,n.statusText,e)}getCookieString(e){let i="";return he.c.isNode&&this._jar&&this._jar.getCookies(e,(e,t)=>i=t.join("; ")),i}}function pe(e,t){let i;switch(t){case"arraybuffer":i=e.arrayBuffer();break;case"text":i=e.text();break;case"blob":case"document":case"json":throw new Error(`${t} is not supported.`);default:i=e.text()}return i}class de extends ne{constructor(e){super(),this._logger=e}send(n){return n.abortSignal&&n.abortSignal.aborted?Promise.reject(new K):n.method?n.url?new Promise((e,t)=>{const i=new XMLHttpRequest;i.open(n.method,n.url,!0),i.withCredentials=void 0===n.withCredentials||n.withCredentials,i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.setRequestHeader("Content-Type","text/plain;charset=UTF-8");const r=n.headers;r&&Object.keys(r).forEach(e=>{i.setRequestHeader(e,r[e])}),n.responseType&&(i.responseType=n.responseType),n.abortSignal&&(n.abortSignal.onabort=()=>{i.abort(),t(new K)}),n.timeout&&(i.timeout=n.timeout),i.onload=()=>{n.abortSignal&&(n.abortSignal.onabort=null),200<=i.status&&i.status<300?e(new re(i.status,i.statusText,i.response||i.responseText)):t(new X(i.response||i.responseText||i.statusText,i.status))},i.onerror=()=>{this._logger.log(ce.a.Warning,`Error from HTTP request. ${i.status}: ${i.statusText}.`),t(new X(i.statusText,i.status))},i.ontimeout=()=>{this._logger.log(ce.a.Warning,"Timeout from HTTP request."),t(new H)},i.send(n.content||"")}):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class fe extends ne{constructor(e){if(super(),"undefined"!=typeof fetch||he.c.isNode)this._httpClient=new ue(e);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this._httpClient=new de(e)}}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new K):e.method?e.url?this._httpClient.send(e):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(e){return this._httpClient.getCookieString(e)}}class me{}me.Authorization="Authorization",me.Cookie="Cookie",(t=oe=oe||{})[t.None=0]="None",t[t.WebSockets=1]="WebSockets",t[t.ServerSentEvents=2]="ServerSentEvents",t[t.LongPolling=4]="LongPolling",(t=se=se||{})[t.Text=1]="Text",t[t.Binary=2]="Binary";class _e{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}}class ge{constructor(e,t,i,r){this._httpClient=e,this._accessTokenFactory=t,this._logger=i,this._pollAbort=new _e,this._options=r,this._running=!1,this.onreceive=null,this.onclose=null}get pollAborted(){return this._pollAbort.aborted}async connect(e,t){if(he.a.isRequired(e,"url"),he.a.isRequired(t,"transferFormat"),he.a.isIn(t,se,"transferFormat"),this._url=e,this._logger.log(ce.a.Trace,"(LongPolling transport) Connecting."),t===se.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");var[i,r]=Object(he.i)(),r={[i]:r,...this._options.headers};const n={abortSignal:this._pollAbort.signal,headers:r,timeout:1e5,withCredentials:this._options.withCredentials};t===se.Binary&&(n.responseType="arraybuffer");t=await this._getAccessToken();this._updateHeaderToken(n,t);e=`${e}&_=${Date.now()}`;this._logger.log(ce.a.Trace,`(LongPolling transport) polling: ${e}.`);e=await this._httpClient.get(e,n);200!==e.statusCode?(this._logger.log(ce.a.Error,`(LongPolling transport) Unexpected response code: ${e.statusCode}.`),this._closeError=new X(e.statusText||"",e.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,n)}async _getAccessToken(){return this._accessTokenFactory?this._accessTokenFactory():null}_updateHeaderToken(e,t){e.headers||(e.headers={}),t?e.headers[me.Authorization]=`Bearer ${t}`:e.headers[me.Authorization]&&delete e.headers[me.Authorization]}async _poll(e,t){try{for(;this._running;){var i=await this._getAccessToken();this._updateHeaderToken(t,i);try{var r=`${e}&_=${Date.now()}`;this._logger.log(ce.a.Trace,`(LongPolling transport) polling: ${r}.`);var n=await this._httpClient.get(r,t);204===n.statusCode?(this._logger.log(ce.a.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):200!==n.statusCode?(this._logger.log(ce.a.Error,`(LongPolling transport) Unexpected response code: ${n.statusCode}.`),this._closeError=new X(n.statusText||"",n.statusCode),this._running=!1):n.content?(this._logger.log(ce.a.Trace,`(LongPolling transport) data received. ${Object(he.f)(n.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(n.content)):this._logger.log(ce.a.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(e){this._running?e instanceof H?this._logger.log(ce.a.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=e,this._running=!1):this._logger.log(ce.a.Trace,`(LongPolling transport) Poll errored after shutdown: ${e.message}`)}}}finally{this._logger.log(ce.a.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(e){return this._running?Object(he.k)(this._logger,"LongPolling",this._httpClient,this._url,this._accessTokenFactory,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(ce.a.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(ce.a.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const n={};var[e,t]=Object(he.i)();n[e]=t;var i={headers:{...n,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials},r=await this._getAccessToken();this._updateHeaderToken(i,r),await this._httpClient.delete(this._url,i),this._logger.log(ce.a.Trace,"(LongPolling transport) DELETE request sent.")}finally{this._logger.log(ce.a.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let e="(LongPolling transport) Firing onclose event.";this._closeError&&(e+=" Error: "+this._closeError),this._logger.log(ce.a.Trace,e),this.onclose(this._closeError)}}}class ye{constructor(e,t,i,r){this._httpClient=e,this._accessTokenFactory=t,this._logger=i,this._options=r,this.onreceive=null,this.onclose=null}async connect(a,e){var t;return he.a.isRequired(a,"url"),he.a.isRequired(e,"transferFormat"),he.a.isIn(e,se,"transferFormat"),this._logger.log(ce.a.Trace,"(SSE transport) Connecting."),this._url=a,!this._accessTokenFactory||(t=await this._accessTokenFactory())&&(a+=(a.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(t)}`),new Promise((t,i)=>{let r=!1;if(e===se.Text){let e;if(he.c.isBrowser||he.c.isWebWorker)e=new this._options.EventSource(a,{withCredentials:this._options.withCredentials});else{var n=this._httpClient.getCookieString(a);const s={};s.Cookie=n;var[o,n]=Object(he.i)();s[o]=n,e=new this._options.EventSource(a,{withCredentials:this._options.withCredentials,headers:{...s,...this._options.headers}})}try{e.onmessage=e=>{if(this.onreceive)try{this._logger.log(ce.a.Trace,`(SSE transport) data received. ${Object(he.f)(e.data,this._options.logMessageContent)}.`),this.onreceive(e.data)}catch(e){return void this._close(e)}},e.onerror=e=>{r?this._close():i(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},e.onopen=()=>{this._logger.log(ce.a.Information,`SSE connected to ${this._url}`),this._eventSource=e,r=!0,t()}}catch(e){return void i(e)}}else i(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))})}async send(e){return this._eventSource?Object(he.k)(this._logger,"SSE",this._httpClient,this._url,this._accessTokenFactory,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(e){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(e))}}class xe{constructor(e,t,i,r,n,o){this._logger=i,this._accessTokenFactory=t,this._logMessageContent=r,this._webSocketConstructor=n,this._httpClient=e,this.onreceive=null,this.onclose=null,this._headers=o}async connect(l,c){var e;return he.a.isRequired(l,"url"),he.a.isRequired(c,"transferFormat"),he.a.isIn(c,se,"transferFormat"),this._logger.log(ce.a.Trace,"(WebSockets transport) Connecting."),!this._accessTokenFactory||(e=await this._accessTokenFactory())&&(l+=(l.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(e)}`),new Promise((t,i)=>{l=l.replace(/^http/,"ws");let r;var e=this._httpClient.getCookieString(l);let n=!1;if(he.c.isNode){const a={};var[o,s]=Object(he.i)();a[o]=s,e&&(a[me.Cookie]=`${e}`),r=new this._webSocketConstructor(l,void 0,{headers:{...a,...this._headers}})}r=r||new this._webSocketConstructor(l),c===se.Binary&&(r.binaryType="arraybuffer"),r.onopen=e=>{this._logger.log(ce.a.Information,`WebSocket connected to ${l}.`),this._webSocket=r,n=!0,t()},r.onerror=e=>{let t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:"There was an error with the transport",this._logger.log(ce.a.Information,`(WebSockets transport) ${t}.`)},r.onmessage=e=>{if(this._logger.log(ce.a.Trace,`(WebSockets transport) data received. ${Object(he.f)(e.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(e.data)}catch(e){return void this._close(e)}},r.onclose=t=>{if(n)this._close(t);else{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",i(new Error(e))}}})}send(e){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(ce.a.Trace,`(WebSockets transport) sending data. ${Object(he.f)(e,this._logMessageContent)}.`),this._webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(e){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(ce.a.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this._isCloseEvent(e)||!1!==e.wasClean&&1e3===e.code?e instanceof Error?this.onclose(e):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${e.code} (${e.reason||"no reason given"}).`)))}_isCloseEvent(e){return e&&"boolean"==typeof e.wasClean&&"number"==typeof e.code}}class ve{constructor(e,t={}){if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,he.a.isRequired(e,"url"),this._logger=Object(he.e)(t.logger),this.baseUrl=this._resolveUrl(e),(t=t||{}).logMessageContent=void 0!==t.logMessageContent&&t.logMessageContent,"boolean"!=typeof t.withCredentials&&void 0!==t.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");t.withCredentials=void 0===t.withCredentials||t.withCredentials,t.timeout=void 0===t.timeout?1e5:t.timeout;let i=null,r=null;if(he.c.isNode){const n=require;i=n("ws"),r=n("eventsource")}he.c.isNode||"undefined"==typeof WebSocket||t.WebSocket?he.c.isNode&&!t.WebSocket&&i&&(t.WebSocket=i):t.WebSocket=WebSocket,he.c.isNode||"undefined"==typeof EventSource||t.EventSource?he.c.isNode&&!t.EventSource&&void 0!==r&&(t.EventSource=r):t.EventSource=EventSource,this._httpClient=t.httpClient||new fe(this._logger),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=t,this.onreceive=null,this.onclose=null}async start(e){if(e=e||se.Binary,he.a.isIn(e,se,"transferFormat"),this._logger.log(ce.a.Debug,`Starting connection with transfer format '${se[e]}'.`),"Disconnected"!==this._connectionState)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(e),await this._startInternalPromise,"Disconnecting"===this._connectionState){var t="Failed to start the HttpConnection before stop() was called.";return this._logger.log(ce.a.Error,t),await this._stopPromise,Promise.reject(new Error(t))}if("Connected"!==this._connectionState){t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(ce.a.Error,t),Promise.reject(new Error(t))}this._connectionStarted=!0}send(e){return"Connected"!==this._connectionState?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new be(this.transport)),this._sendQueue.send(e))}async stop(e){return"Disconnected"===this._connectionState?(this._logger.log(ce.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this._connectionState?(this._logger.log(ce.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState="Disconnecting",this._stopPromise=new Promise(e=>{this._stopPromiseResolver=e}),await this._stopInternal(e),void await this._stopPromise)}async _stopInternal(e){this._stopError=e;try{await this._startInternalPromise}catch(e){}if(this.transport){try{await this.transport.stop()}catch(e){this._logger.log(ce.a.Error,`HttpConnection.transport.stop() threw error '${e}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(ce.a.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(i){let r=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory;try{if(this._options.skipNegotiation){if(this._options.transport!==oe.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this._constructTransport(oe.WebSockets),await this._startTransport(r,i)}else{let e=null,t=0;do{if(e=await this._getNegotiationResponse(r),"Disconnecting"===this._connectionState||"Disconnected"===this._connectionState)throw new Error("The connection was stopped during negotiation.");if(e.error)throw new Error(e.error);if(e.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(e.url&&(r=e.url),e.accessToken){const n=e.accessToken;this._accessTokenFactory=()=>n}}while(t++,e.url&&t<100);if(100===t&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(r,this._options.transport,e,i)}this.transport instanceof ge&&(this.features.inherentKeepAlive=!0),"Connecting"===this._connectionState&&(this._logger.log(ce.a.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(e){return this._logger.log(ce.a.Error,"Failed to start the connection: "+e),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(e)}}async _getNegotiationResponse(e){const t={};!this._accessTokenFactory||(r=await this._accessTokenFactory())&&(t[me.Authorization]=`Bearer ${r}`);var[i,r]=Object(he.i)();t[i]=r;e=this._resolveNegotiateUrl(e);this._logger.log(ce.a.Debug,`Sending negotiation request: ${e}.`);try{var n=await this._httpClient.post(e,{content:"",headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(200!==n.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${n.statusCode}'`));const o=JSON.parse(n.content);return(!o.negotiateVersion||o.negotiateVersion<1)&&(o.connectionToken=o.connectionId),o}catch(e){let t="Failed to complete negotiation with the server: "+e;return e instanceof X&&404===e.statusCode&&(t+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(ce.a.Error,t),Promise.reject(new te(t))}}_createConnectUrl(e,t){return t?e+(-1===e.indexOf("?")?"?":"&")+`id=${t}`:e}async _createTransport(e,t,i,r){let n=this._createConnectUrl(e,i.connectionToken);if(this._isITransport(t))return this._logger.log(ce.a.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=t,await this._startTransport(n,r),void(this.connectionId=i.connectionId);const o=[];let s=i;for(const l of i.availableTransports||[]){var a=this._resolveTransportOrError(l,t,r);if(a instanceof Error)o.push(`${l.transport} failed:`),o.push(a);else if(this._isITransport(a)){if(this.transport=a,!s){try{s=await this._getNegotiationResponse(e)}catch(e){return Promise.reject(e)}n=this._createConnectUrl(e,s.connectionToken)}try{return await this._startTransport(n,r),void(this.connectionId=s.connectionId)}catch(e){if(this._logger.log(ce.a.Error,`Failed to start the transport '${l.transport}': ${e}`),s=void 0,o.push(new ee(`${l.transport} failed: ${e}`,oe[l.transport])),"Connecting"!==this._connectionState){a="Failed to select transport before stop() was called.";return this._logger.log(ce.a.Debug,a),Promise.reject(new Error(a))}}}}return 0<o.length?Promise.reject(new ie(`Unable to connect to the server with any of the available transports. ${o.join(" ")}`,o)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(e){switch(e){case oe.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new xe(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case oe.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new ye(this._httpClient,this._accessTokenFactory,this._logger,this._options);case oe.LongPolling:return new ge(this._httpClient,this._accessTokenFactory,this._logger,this._options);default:throw new Error(`Unknown transport: ${e}.`)}}_startTransport(e,t){return this.transport.onreceive=this.onreceive,this.transport.onclose=e=>this._stopConnection(e),this.transport.connect(e,t)}_resolveTransportOrError(e,t,i){var r,n=oe[e.transport];if(null==n)return this._logger.log(ce.a.Debug,`Skipping transport '${e.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);if(r=n,(t=t)&&0==(r&t))return this._logger.log(ce.a.Debug,`Skipping transport '${oe[n]}' because it was disabled by the client.`),new Q(`'${oe[n]}' is disabled by the client.`,n);{const o=e.transferFormats.map(e=>se[e]);if(!(0<=o.indexOf(i)))return this._logger.log(ce.a.Debug,`Skipping transport '${oe[n]}' because it does not support the requested transfer format '${se[i]}'.`),new Error(`'${oe[n]}' does not support ${se[i]}.`);if(n===oe.WebSockets&&!this._options.WebSocket||n===oe.ServerSentEvents&&!this._options.EventSource)return this._logger.log(ce.a.Debug,`Skipping transport '${oe[n]}' because it is not supported in your environment.'`),new J(`'${oe[n]}' is not supported in your environment.`,n);this._logger.log(ce.a.Debug,`Selecting transport '${oe[n]}'.`);try{return this._constructTransport(n)}catch(e){return e}}}_isITransport(e){return e&&"object"==typeof e&&"connect"in e}_stopConnection(t){if(this._logger.log(ce.a.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this._connectionState}.`),this.transport=void 0,t=this._stopError||t,this._stopError=void 0,"Disconnected"!==this._connectionState){if("Connecting"===this._connectionState)throw this._logger.log(ce.a.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this._connectionState&&this._stopPromiseResolver(),t?this._logger.log(ce.a.Error,`Connection disconnected with error '${t}'.`):this._logger.log(ce.a.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch(e=>{this._logger.log(ce.a.Error,`TransportSendQueue.stop() threw error '${e}'.`)}),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(t)}catch(e){this._logger.log(ce.a.Error,`HttpConnection.onclose(${t}) threw error '${e}'.`)}}}else this._logger.log(ce.a.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}_resolveUrl(e){if(0===e.lastIndexOf("https://",0)||0===e.lastIndexOf("http://",0))return e;if(!he.c.isBrowser)throw new Error(`Cannot resolve '${e}'.`);const t=window.document.createElement("a");return t.href=e,this._logger.log(ce.a.Information,`Normalizing '${e}' to '${t.href}'.`),t.href}_resolveNegotiateUrl(e){var t=e.indexOf("?");let i=e.substring(0,-1===t?e.length:t);return"/"!==i[i.length-1]&&(i+="/"),i+="negotiate",i+=-1===t?"":e.substring(t),-1===i.indexOf("negotiateVersion")&&(i+=-1===t?"?":"&",i+="negotiateVersion="+this._negotiateVersion),i}}class be{constructor(e){this._transport=e,this._buffer=[],this._executing=!0,this._sendBufferedData=new we,this._transportResult=new we,this._sendLoopPromise=this._sendLoop()}send(e){return this._bufferData(e),this._transportResult||(this._transportResult=new we),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(e){if(this._buffer.length&&typeof this._buffer[0]!=typeof e)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof e}`);this._buffer.push(e),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new we;const t=this._transportResult;this._transportResult=void 0;var e="string"==typeof this._buffer[0]?this._buffer.join(""):be._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(e),t.resolve()}catch(e){t.reject(e)}}}static _concatBuffers(e){var t=e.map(e=>e.byteLength).reduce((e,t)=>e+t);const i=new Uint8Array(t);let r=0;for(const n of e)i.set(new Uint8Array(n),r),r+=n.byteLength;return i.buffer}}class we{constructor(){this.promise=new Promise((e,t)=>[this._resolver,this._rejecter]=[e,t])}resolve(){this._resolver()}reject(e){this._rejecter(e)}}class Te{static write(e){return`${e}${Te.RecordSeparator}`}static parse(e){if(e[e.length-1]!==Te.RecordSeparator)throw new Error("Message is incomplete.");const t=e.split(Te.RecordSeparator);return t.pop(),t}}Te.RecordSeparatorCode=30,Te.RecordSeparator=String.fromCharCode(Te.RecordSeparatorCode);class Ee{writeHandshakeRequest(e){return Te.write(JSON.stringify(e))}parseHandshakeResponse(e){let t,i;if(Object(he.j)(e)){const o=new Uint8Array(e);var r=o.indexOf(Te.RecordSeparatorCode);if(-1===r)throw new Error("Message is incomplete.");r=r+1;t=String.fromCharCode.apply(null,Array.prototype.slice.call(o.slice(0,r))),i=o.byteLength>r?o.slice(r).buffer:null}else{const s=e;var n=s.indexOf(Te.RecordSeparator);if(-1===n)throw new Error("Message is incomplete.");n=n+1;t=s.substring(0,n),i=s.length>n?s.substring(n):null}n=Te.parse(t),n=JSON.parse(n[0]);if(n.type)throw new Error("Expected a handshake response from the server.");return[i,n]}}(t=ae=ae||{})[t.Invocation=1]="Invocation",t[t.StreamItem=2]="StreamItem",t[t.Completion=3]="Completion",t[t.StreamInvocation=4]="StreamInvocation",t[t.CancelInvocation=5]="CancelInvocation",t[t.Ping=6]="Ping",t[t.Close=7]="Close";class Ae{constructor(){this.observers=[]}next(e){for(const t of this.observers)t.next(e)}error(e){for(const t of this.observers)t.error&&t.error(e)}complete(){for(const e of this.observers)e.complete&&e.complete()}subscribe(e){return this.observers.push(e),new he.d(this,e)}}(t=le=le||{}).Disconnected="Disconnected",t.Connecting="Connecting",t.Connected="Connected",t.Disconnecting="Disconnecting",t.Reconnecting="Reconnecting";class Se{constructor(e,t,i,r){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(ce.a.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},he.a.isRequired(e,"connection"),he.a.isRequired(t,"logger"),he.a.isRequired(i,"protocol"),this.serverTimeoutInMilliseconds=3e4,this.keepAliveIntervalInMilliseconds=15e3,this._logger=t,this._protocol=i,this.connection=e,this._reconnectPolicy=r,this._handshakeProtocol=new Ee,this.connection.onreceive=e=>this._processIncomingData(e),this.connection.onclose=e=>this._connectionClosed(e),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=le.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:ae.Ping})}static create(e,t,i,r){return new Se(e,t,i,r)}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(e){if(this._connectionState!==le.Disconnected&&this._connectionState!==le.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!e)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=e}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==le.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=le.Connecting,this._logger.log(ce.a.Debug,"Starting HubConnection.");try{await this._startInternal(),he.c.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=le.Connected,this._connectionStarted=!0,this._logger.log(ce.a.Debug,"HubConnection connected successfully.")}catch(e){return this._connectionState=le.Disconnected,this._logger.log(ce.a.Debug,`HubConnection failed to start successfully because of error '${e}'.`),Promise.reject(e)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;var e=new Promise((e,t)=>{this._handshakeResolver=e,this._handshakeRejecter=t});await this.connection.start(this._protocol.transferFormat);try{var t={protocol:this._protocol.name,version:this._protocol.version};if(this._logger.log(ce.a.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(t)),this._logger.log(ce.a.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await e,this._stopDuringStartError)throw this._stopDuringStartError}catch(e){throw this._logger.log(ce.a.Debug,`Hub handshake failed with error '${e}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(e),e}}async stop(){var e=this._startPromise;this._stopPromise=this._stopInternal(),await this._stopPromise;try{await e}catch(e){}}_stopInternal(e){return this._connectionState===le.Disconnected?(this._logger.log(ce.a.Debug,`Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`),Promise.resolve()):this._connectionState===le.Disconnecting?(this._logger.log(ce.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState=le.Disconnecting,this._logger.log(ce.a.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(ce.a.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=e||new Error("The connection was stopped before the hub handshake could complete."),this.connection.stop(e)))}stream(e,...t){var[i,r]=this._replaceStreamingParams(t);const n=this._createStreamInvocation(e,t,r);let o;const s=new Ae;return s.cancelCallback=()=>{const e=this._createCancelInvocation(n.invocationId);return delete this._callbacks[n.invocationId],o.then(()=>this._sendWithProtocol(e))},this._callbacks[n.invocationId]=(e,t)=>{t?s.error(t):e&&(e.type===ae.Completion?e.error?s.error(new Error(e.error)):s.complete():s.next(e.item))},o=this._sendWithProtocol(n).catch(e=>{s.error(e),delete this._callbacks[n.invocationId]}),this._launchStreams(i,o),s}_sendMessage(e){return this._resetKeepAliveInterval(),this.connection.send(e)}_sendWithProtocol(e){return this._sendMessage(this._protocol.writeMessage(e))}send(e,...t){var[i,r]=this._replaceStreamingParams(t),r=this._sendWithProtocol(this._createInvocation(e,t,!0,r));return this._launchStreams(i,r),r}invoke(e,...t){const[n,i]=this._replaceStreamingParams(t),o=this._createInvocation(e,t,!1,i);return new Promise((i,r)=>{this._callbacks[o.invocationId]=(e,t)=>{t?r(t):e&&(e.type===ae.Completion?e.error?r(new Error(e.error)):i(e.result):r(new Error(`Unexpected message type: ${e.type}`)))};var e=this._sendWithProtocol(o).catch(e=>{r(e),delete this._callbacks[o.invocationId]});this._launchStreams(n,e)})}on(e,t){e&&t&&(e=e.toLowerCase(),this._methods[e]||(this._methods[e]=[]),-1===this._methods[e].indexOf(t)&&this._methods[e].push(t))}off(e,t){if(e){e=e.toLowerCase();const i=this._methods[e];i&&(t?-1!==(t=i.indexOf(t))&&(i.splice(t,1),0===i.length&&delete this._methods[e]):delete this._methods[e])}}onclose(e){e&&this._closedCallbacks.push(e)}onreconnecting(e){e&&this._reconnectingCallbacks.push(e)}onreconnected(e){e&&this._reconnectedCallbacks.push(e)}_processIncomingData(e){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(e=this._processHandshakeResponse(e),this._receivedHandshakeResponse=!0),e)for(const i of this._protocol.parseMessages(e,this._logger))switch(i.type){case ae.Invocation:this._invokeClientMethod(i);break;case ae.StreamItem:case ae.Completion:{const r=this._callbacks[i.invocationId];if(r){i.type===ae.Completion&&delete this._callbacks[i.invocationId];try{r(i)}catch(e){this._logger.log(ce.a.Error,`Stream callback threw error: ${Object(he.g)(e)}`)}}break}case ae.Ping:break;case ae.Close:this._logger.log(ce.a.Information,"Close message received from server.");var t=i.error?new Error("Server returned an error on close: "+i.error):void 0;!0===i.allowReconnect?this.connection.stop(t):this._stopPromise=this._stopInternal(t);break;default:this._logger.log(ce.a.Warning,`Invalid message type: ${i.type}.`)}this._resetTimeoutPeriod()}_processHandshakeResponse(e){let t,i;try{[i,t]=this._handshakeProtocol.parseHandshakeResponse(e)}catch(e){var r="Error parsing handshake response: "+e;this._logger.log(ce.a.Error,r);r=new Error(r);throw this._handshakeRejecter(r),r}if(t.error){r="Server returned handshake error: "+t.error;this._logger.log(ce.a.Error,r);r=new Error(r);throw this._handshakeRejecter(r),r}return this._logger.log(ce.a.Debug,"Server handshake complete."),this._handshakeResolver(),i}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this._timeoutHandle=setTimeout(()=>this.serverTimeout(),this.serverTimeoutInMilliseconds),void 0!==this._pingServerHandle))){let e=this._nextKeepAlive-(new Date).getTime();e<0&&(e=0),this._pingServerHandle=setTimeout(async()=>{if(this._connectionState===le.Connected)try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}},e)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}_invokeClientMethod(t){const e=this._methods[t.target.toLowerCase()];if(e){try{e.forEach(e=>e.apply(this,t.arguments))}catch(e){this._logger.log(ce.a.Error,`A callback for the method ${t.target.toLowerCase()} threw error '${e}'.`)}var i;t.invocationId&&(this._logger.log(ce.a.Error,i="Server requested a response, which is not supported in this version of the client."),this._stopPromise=this._stopInternal(new Error(i)))}else this._logger.log(ce.a.Warning,`No client method with the name '${t.target}' found.`)}_connectionClosed(e){this._logger.log(ce.a.Debug,`HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||e||new Error("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(e||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===le.Disconnecting?this._completeClose(e):this._connectionState===le.Connected&&this._reconnectPolicy?this._reconnect(e):this._connectionState===le.Connected&&this._completeClose(e)}_completeClose(t){if(this._connectionStarted){this._connectionState=le.Disconnected,this._connectionStarted=!1,he.c.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach(e=>e.apply(this,[t]))}catch(e){this._logger.log(ce.a.Error,`An onclose callback called with error '${t}' threw error '${e}'.`)}}}async _reconnect(t){var i=Date.now();let r=0;var n=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error.");let o=this._getNextRetryDelay(r++,0,n);if(null===o)return this._logger.log(ce.a.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this._completeClose(t);if(this._connectionState=le.Reconnecting,t?this._logger.log(ce.a.Information,`Connection reconnecting because of error '${t}'.`):this._logger.log(ce.a.Information,"Connection reconnecting."),0!==this._reconnectingCallbacks.length){try{this._reconnectingCallbacks.forEach(e=>e.apply(this,[t]))}catch(e){this._logger.log(ce.a.Error,`An onreconnecting callback called with error '${t}' threw error '${e}'.`)}if(this._connectionState!==le.Reconnecting)return void this._logger.log(ce.a.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==o;){if(this._logger.log(ce.a.Information,`Reconnect attempt number ${r} will start in ${o} ms.`),await new Promise(e=>{this._reconnectDelayHandle=setTimeout(e,o)}),this._reconnectDelayHandle=void 0,this._connectionState!==le.Reconnecting)return void this._logger.log(ce.a.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this._startInternal(),this._connectionState=le.Connected,this._logger.log(ce.a.Information,"HubConnection reconnected successfully."),0!==this._reconnectedCallbacks.length)try{this._reconnectedCallbacks.forEach(e=>e.apply(this,[this.connection.connectionId]))}catch(e){this._logger.log(ce.a.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${e}'.`)}return}catch(e){if(this._logger.log(ce.a.Information,`Reconnect attempt failed because of error '${e}'.`),this._connectionState!==le.Reconnecting)return this._logger.log(ce.a.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this._connectionState===le.Disconnecting&&this._completeClose());n=e instanceof Error?e:new Error(e.toString()),o=this._getNextRetryDelay(r++,Date.now()-i,n)}}this._logger.log(ce.a.Information,`Reconnect retries have been exhausted after ${Date.now()-i} ms and ${r} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(t,i,e){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:i,previousRetryCount:t,retryReason:e})}catch(e){return this._logger.log(ce.a.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${i}) threw error '${e}'.`),null}}_cancelCallbacksWithError(i){const r=this._callbacks;this._callbacks={},Object.keys(r).forEach(e=>{const t=r[e];try{t(null,i)}catch(e){this._logger.log(ce.a.Error,`Stream 'error' callback called with '${i}' threw error: ${Object(he.g)(e)}`)}})}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(e,t,i,r){if(i)return 0!==r.length?{arguments:t,streamIds:r,target:e,type:ae.Invocation}:{arguments:t,target:e,type:ae.Invocation};{const n=this._invocationId;return this._invocationId++,0!==r.length?{arguments:t,invocationId:n.toString(),streamIds:r,target:e,type:ae.Invocation}:{arguments:t,invocationId:n.toString(),target:e,type:ae.Invocation}}}_launchStreams(e,i){if(0!==e.length){i=i||Promise.resolve();for(const r in e)e[r].subscribe({complete:()=>{i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(r)))},error:e=>{let t;t=e instanceof Error?e.message:e&&e.toString?e.toString():"Unknown error",i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(r,t)))},next:e=>{i=i.then(()=>this._sendWithProtocol(this._createStreamItemMessage(r,e)))}})}}_replaceStreamingParams(t){const i=[],r=[];for(let e=0;e<t.length;e++){var n=t[e];if(this._isObservable(n)){const o=this._invocationId;this._invocationId++,i[o]=n,r.push(o.toString()),t.splice(e,1)}}return[i,r]}_isObservable(e){return e&&e.subscribe&&"function"==typeof e.subscribe}_createStreamInvocation(e,t,i){const r=this._invocationId;return this._invocationId++,0!==i.length?{arguments:t,invocationId:r.toString(),streamIds:i,target:e,type:ae.StreamInvocation}:{arguments:t,invocationId:r.toString(),target:e,type:ae.StreamInvocation}}_createCancelInvocation(e){return{invocationId:e,type:ae.CancelInvocation}}_createStreamItemMessage(e,t){return{invocationId:e,item:t,type:ae.StreamItem}}_createCompletionMessage(e,t,i){return t?{error:t,invocationId:e,type:ae.Completion}:{invocationId:e,result:i,type:ae.Completion}}}var Ce=i(11);class Me{constructor(){this.name="json",this.version=1,this.transferFormat=se.Text}parseMessages(e,t){if("string"!=typeof e)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!e)return[];null===t&&(t=Ce.a.instance);const i=[];for(const n of Te.parse(e)){var r=JSON.parse(n);if("number"!=typeof r.type)throw new Error("Invalid payload.");switch(r.type){case ae.Invocation:this._isInvocationMessage(r);break;case ae.StreamItem:this._isStreamItemMessage(r);break;case ae.Completion:this._isCompletionMessage(r);break;case ae.Ping:case ae.Close:break;default:t.log(ce.a.Information,"Unknown message type '"+r.type+"' ignored.");continue}i.push(r)}return i}writeMessage(e){return Te.write(JSON.stringify(e))}_isInvocationMessage(e){this._assertNotEmptyString(e.target,"Invalid payload for Invocation message."),void 0!==e.invocationId&&this._assertNotEmptyString(e.invocationId,"Invalid payload for Invocation message.")}_isStreamItemMessage(e){if(this._assertNotEmptyString(e.invocationId,"Invalid payload for StreamItem message."),void 0===e.item)throw new Error("Invalid payload for StreamItem message.")}_isCompletionMessage(e){if(e.result&&e.error)throw new Error("Invalid payload for Completion message.");!e.result&&e.error&&this._assertNotEmptyString(e.error,"Invalid payload for Completion message."),this._assertNotEmptyString(e.invocationId,"Invalid payload for Completion message.")}_assertNotEmptyString(e,t){if("string"!=typeof e||""===e)throw new Error(t)}}const Ie={trace:ce.a.Trace,debug:ce.a.Debug,info:ce.a.Information,information:ce.a.Information,warn:ce.a.Warning,warning:ce.a.Warning,error:ce.a.Error,critical:ce.a.Critical,none:ce.a.None};class Be{configureLogging(e){var t;return he.a.isRequired(e,"logging"),void 0!==e.log?this.logger=e:"string"==typeof e?(t=function(e){var t=Ie[e.toLowerCase()];if(void 0!==t)return t;throw new Error(`Unknown log level: ${e}`)}(e),this.logger=new he.b(t)):this.logger=new he.b(e),this}withUrl(e,t){return he.a.isRequired(e,"url"),he.a.isNotEmpty(e,"url"),this.url=e,this.httpConnectionOptions="object"==typeof t?{...this.httpConnectionOptions,...t}:{...this.httpConnectionOptions,transport:t},this}withHubProtocol(e){return he.a.isRequired(e,"protocol"),this.protocol=e,this}withAutomaticReconnect(e){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return e?Array.isArray(e)?this.reconnectPolicy=new W(e):this.reconnectPolicy=e:this.reconnectPolicy=new W,this}build(){const e=this.httpConnectionOptions||{};if(void 0===e.logger&&(e.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");var t=new ve(this.url,e);return Se.create(t,this.logger||Ce.a.instance,this.protocol||new Me,this.reconnectPolicy)}}var t=i(12),ke=i.n(t);class ze{constructor(e,t="540E5CBA3D09480F8CDE2F69C55934EF",i=[117.28688541016095,39.094144209740534],r=Math.PI){this.type="custom",this.renderingMode="3d",this.drones={x:39.094144209740534,y:117.28688541016095,z:0},this.rotation=Math.PI,this.onAdd=(e,t)=>{this.map=e;const i=new BABYLON.Engine(t,!0,{useHighPrecisionMatrix:!0},!0);this.scene=new BABYLON.Scene(i),this.scene.autoClear=!1,this.scene.detachControl(),this.scene.beforeRender=function(){i.wipeCaches(!0)},this.camera=new BABYLON.Camera("mapbox-camera",new BABYLON.Vector3,this.scene);let r=new BABYLON.HemisphericLight("light",new BABYLON.Vector3(1,1,0),this.scene);r.intensity=1,r.diffuse=BABYLON.Color3.FromHexString("#FFFFFF"),r.specular=BABYLON.Color3.Black();let n=new BABYLON.HemisphericLight("light1",new BABYLON.Vector3(-1,1,0),this.scene);n.intensity=.7,n.diffuse=BABYLON.Color3.FromHexString("#FFFFFF"),n.specular=BABYLON.Color3.Black(),this.recalculateProjectionMatrix(this.initialCoordinates),BABYLON.SceneLoader.LoadAssetContainerAsync(Pe.rl+"bundle/"+this.modelsId+"/",this.modelsId+".gltf",this.scene).then(e=>{e.addAllToScene();const t=e.meshes[0];e=ke.a.MercatorCoordinate.fromLngLat(this.initialCoordinates,0);t.position=new BABYLON.Vector3((e.x-this.sceneOrigin.x)/this.modelScale,0,-(e.y-this.sceneOrigin.y)/this.modelScale),t.rotation=new BABYLON.Vector3(0,this.rotation,0)})},this.render=(e,t)=>{t=BABYLON.Matrix.FromArray(t),t=this.modelMatrix.multiply(t);this.camera.freezeProjectionMatrix(t),this.scene.render(!1),this.map.triggerRepaint()},this.id=e,this.modelsId=t,this.initialCoordinates=i,this.rotation=r}recalculateProjectionMatrix(e){var t=[Math.PI/2,0,0];const i=ke.a.MercatorCoordinate.fromLngLat(e,0);this.modelScale=i.meterInMercatorCoordinateUnits(),this.sceneOrigin=new BABYLON.Vector3(i.x,i.y,i.z),this.modelMatrix=BABYLON.Matrix.Compose(new BABYLON.Vector3(this.modelScale,this.modelScale,this.modelScale),BABYLON.Quaternion.FromEulerAngles(t[0],t[1],t[2]),this.sceneOrigin)}}class Pe{}Pe.sl="https://www.wodashijie.com/",Pe.rl="https://models.wodashijie.com/",Pe.App=class{constructor(e){e.sl&&(Pe.sl=e.sl),e.rl&&(Pe.rl=e.rl),F.defaults.baseURL=Pe.sl,this.canvas=document.createElement("canvas"),this.canvas.style.cssText="width: 100%;height: 100%;background-color: transparent;outline-width: 0;-webkit-tap-highlight-color:transparent;",e.container.appendChild(this.canvas),this.engine=new BABYLON.Engine(this.canvas,!0,{premultipliedAlpha:!0,preserveDrawingBuffer:!0,stencil:!0,doNotHandleContextLost:!1}),this.engine.setHardwareScalingLevel(.5),this.scene=new BABYLON.Scene(this.engine,{useGeometryUniqueIdsMap:!0,useClonedMeshMap:!0,useMaterialMeshMap:!0}),this.scene.useRightHandedSystem=!0,this.scene.getBoundingBoxRenderer().frontColor=BABYLON.Color3.Green(),this.scene.getBoundingBoxRenderer().showBackLines=!1,this.CameraController=new s(this),this.HighlightLayer=new BABYLON.HighlightLayer("highlightLayer",this.scene),this.IEvent=new r(this),this.container=BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("screenUI"),this.Environment=new g(this),this.Environment.defaultLights(),this.Environment.openAllLight(),this.Resources=new R(this),this.Project=new D(this),Pe.EffectMgr.init(),this.engine.runRenderLoop(()=>{this.fps&&(this.fps.innerText=this.engine.getFps().toFixed()+" fps"),this.scene.render(),v.a.update(),this.IEvent&&this.IEvent.runRender()}),window.addEventListener("resize",()=>{this.engine.resize()}),this.scene.onPointerObservable.add(e=>{this.IEvent&&this.IEvent.onPointer(e)}),this.scene.onKeyboardObservable.add(e=>{this.IEvent&&this.IEvent.onKeyboard(e)})}async load(u){if(u){u.isDefaultLevel=null==u.isDefaultLevel||u.isDefaultLevel,Pe.pk=u.pk;var e=await F.get(`api/service/GetToken?accessToken=${Pe.accessToken}`);if(200==e.status){localStorage.setItem("mx3d-token",e.data);e=await F.get("api/service");if(200==e.status){localStorage.setItem("mx3d-long",e.data);e=await F.get(`api/service/${Pe.pk}`);if(200==e.status){let h=JSON.parse(class{static de(e){let t=localStorage.getItem("mx3d-long");var i=N.a.enc.Utf8.parse(t.substring(0,32)),r=N.a.enc.Utf8.parse(t.substring(32,48)),e=N.a.enc.Hex.parse(e),e=N.a.enc.Base64.stringify(e);return N.a.AES.decrypt(e,i,{iv:r,mode:N.a.mode.CBC,padding:N.a.pad.Pkcs7}).toString(N.a.enc.Utf8).toString()}}.de(e.data));return new Promise(async(r,t)=>{try{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let t=new d;for(let e=0;e<h.length;e++){const a=h[e];!a.baseModel||".gltf"!=a.baseModel.extension||t.find(a.baseModel.modelId)||this.Resources.resources.find(a.baseModel.modelId)||(a.baseModel.objectType=a.objectType,t.add(a.baseModel.modelId,a.baseModel))}let e=0;for(const l in t.map)await this.Resources.loadModelMesh(t.find(l)),e++,u&&u.progress&&u.progress(e/t.count()*.3);e=0,t=null;let i=new d;for(let e=0;e<h.length;e++){var n,o=h[e];o.objectType==f.Region&&(n=new L(this,o),this.Project.objectDatas.add(n.id,n),i.add(n.id,new Array),"0"==n.parentId&&(this.Project.root=n))}for(let e=0;e<h.length;e++){var s=h[e];if(s.objectType!=f.Region){let e=i.find(s.parentId);e.push(s)}}for(const c in i.map)await this.Project.objectDatas.find(c).bind(i.find(c)),e++,u&&u.progress&&u.progress(.3+e/i.count()*.7);i=null,this.Project.optimization(),u.isDefaultLevel&&this.Project.switchLevel(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1,r(null),this.engine.resize(),u&&u.complete&&u.complete()}catch(e){t(e)}})}}}}else console.error("场景编号不能为空!")}dispose(){this.Environment.hideFps(),this.Project.clear(),this.Resources.delete(),this.engine.dispose()}},Pe.Earth=class{constructor(e,t=[117.28688541016095,39.094144209740534]){this.initialCoordinates=[117.28688541016095,39.094144209740534],this.initialCoordinates=t,ke.a.accessToken="pk.eyJ1IjoibGl1ayIsImEiOiJjanczNmJoZjkwY3IxM3lxcTd1NmMwZWxjIn0.11SpcY8De0c1q6S3a-2Qcg",this.map=new ke.a.Map({container:e,style:"mapbox://styles/mapbox/satellite-streets-v11",zoom:1.5,center:this.initialCoordinates,projection:"globe"})}load(e){this.map.on("style.load",()=>{this.map.setFog({color:"rgb(220, 159, 159)","high-color":"rgb(36, 92, 223)","horizon-blend":.4}),this.map.addSource("mapbox-dem",{type:"raster-dem",url:"mapbox://mapbox.terrain-rgb"}),this.map.setTerrain({source:"mapbox-dem",exaggeration:1.5}),e&&e()})}laodScene(e,t=this.initialCoordinates,i=Math.PI){i=new ze("babylon-layer",e,t,i);this.map.addLayer(i)}flyTo(e=this.initialCoordinates,t=18,i=130,r=75,n=12e3){this.map.flyTo({center:e,zoom:t,bearing:i,pitch:r,duration:n,essential:!0})}},Pe.Tools=p,Pe.EffectMgr=b,Pe.HubService=class{static async listener(e){this.connection=(new Be).withUrl(e).configureLogging(ce.a.Error).build(),this.connection.onclose(async()=>{await this.start()}),await this.start()}static async start(){try{await this.connection.start()}catch(e){console.log("无法连接服务器"),setTimeout(this.start,5e3)}}},Pe.UI=class{static createIconFromMesh(e,t,i,r,n){let o=t.Sight.focus.clone();var s=t.instance.getBoundingInfo();return o.y+=(s.boundingBox.maximum.y-s.boundingBox.minimum.y)/2,new j(e,o,i,r,n,t.app.scene)}static createIcon(e,t,i,r){let n;t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,n=new U(e,t.app.scene),n.size=i,n.height=r,n.pint=new BABYLON.Mesh(e+"_pint");e=t.Sight.focus.clone();return n.pint.position=e,n.pint.position.y+=r,n.rect=new BABYLON.GUI.Rectangle,n.rect.isPointerBlocker=!1,n.rect.width=i.width+"px",n.rect.height=i.height+"px",n.rect.thickness=0,t.app.container.addControl(n.rect),n.rect.linkWithMesh(n.pint),t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,n}},Pe.Builder=class{static createMatrixCloud(n){n.displayValues=null!=n.displayValues&&n.displayValues,n.isAlpha=null==n.isAlpha||n.isAlpha,n.isParticle=null==n.isParticle||n.isParticle,n.height=n.height||.5,n.radius=n.radius||2.8,n.isLevelRender=null==n.isLevelRender||n.isLevelRender,n.range=n.range||{max:30,min:16};let o;if(!(n.value||n.value.maxX||n.value.maxY||n.value.data||n.anchor))return o;n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,o=new G(n.anchor);var s=n.anchor.instance.getBoundingInfo();o.mesh=n.anchor.instance.clone(o.id),o.mesh.position.y+=n.height;var a=s.maximum.x-s.minimum.x,l=a/(2*n.value.maxX),c=s.maximum.z-s.minimum.z,h=c/(2*n.value.maxY);let e=new Array;for(let r=0;r<2*n.value.maxX;r++)for(let i=0;i<2*n.value.maxY;i++){let t={x:r,y:i,value:n.range.min};for(let e=0;e<n.value.data.length;e++){var u=n.value.data[e];2*u.x+1==r&&2*u.y+1==i&&(t.value=u.value,u=new BABYLON.Vector3(s.boundingSphere.center.x-(a/2-l*r),o.mesh.position.y,s.boundingSphere.center.z-(c/2-h*i)),o.texts.push(this.createTempVlaue(t.value+"℃",u,n.anchor.app.scene,n.anchor.app.container)))}e.push(t)}o.displayValues=n.displayValues;let t=$.create({width:2*n.value.maxX,height:2*n.value.maxY,radius:n.radius});t.setData({min:n.range.min,max:n.range.max,data:e});let i=new BABYLON.StandardMaterial(o.id,n.anchor.app.scene);return i.diffuseTexture=new BABYLON.Texture(t.getDataURL(),n.anchor.app.scene,!1,!1),i.specularColor=new BABYLON.Color3(0,0,0),i.alpha=.5,n.isAlpha&&(i.diffuseTexture.hasAlpha=!0),n.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getMatrixParticleTex(Pe.rl,n.anchor.app.Resources.FogTex,i.diffuseTexture,o.mesh,n.anchor.app.scene,n.isLevelRender),o.mesh.isVisible=!1),n.isLevelRender&&(o.mesh.renderingGroupId=1),o.mesh.material=i,o.mesh.alwaysSelectAsActiveMesh=!0,o.mesh.freezeWorldMatrix(),n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,o}static _getMatrixParticleTex(e,t,i,r,n,o){let s,a=t.clone(),l=r.getBoundingInfo().boundingBox;var c=(l.extendSizeWorld.x+l.extendSizeWorld.z)/9,t=1500*c*c;l.minimumWorld.subtract(new BABYLON.Vector3(-0,0,-0)),l.maximumWorld.subtract(new BABYLON.Vector3(0,0,0));s&&s.dispose(),BABYLON.GPUParticleSystem.IsSupported&&(s=new BABYLON.GPUParticleSystem("particles",{capacity:t},n),s.activeParticleCount=t,s.manualEmitCount=s.activeParticleCount,s.minEmitBox=l.minimumWorld,s.maxEmitBox=l.maximumWorld),s.particleTexture=a,s.emitter=r,o&&(s.renderingGroupId=1),s.isLocal=!0;let h=new BABYLON.NodeMaterial("nm_heatmapBox_"+r.id,n);return h.loadAsync(e+"resources/horizontalNodeMat.json").then(()=>{h.build(!1),h.getBlockByName("boxTex").texture=i,h.getBlockByName("emitXMin").value=s.minEmitBox.x,h.getBlockByName("emitXMax").value=s.maxEmitBox.x,h.getBlockByName("emitYMin").value=s.minEmitBox.z,h.getBlockByName("emitYMax").value=s.maxEmitBox.z,h.createEffectForParticles(s)}),r.onDispose=()=>{s&&s.dispose()},s.onDispose=()=>{h&&h.dispose(),a&&a.dispose()},s.color1=new BABYLON.Color4(.8,.8,.8,.1),s.color2=new BABYLON.Color4(.95,.95,.95,.15),s.colorDead=new BABYLON.Color4(.9,.9,.9,.1),s.minSize=1.4,s.maxSize=2,s.minLifeTime=Number.MAX_SAFE_INTEGER,s.emitRate=5e4*c,s.blendMode=BABYLON.ParticleSystem.BLENDMODE_STANDARD,s.gravity=new BABYLON.Vector3(0,0,0),s.direction1=new BABYLON.Vector3(0,0,0),s.direction2=new BABYLON.Vector3(0,0,0),s.minAngularSpeed=-2,s.maxAngularSpeed=2,s.minEmitPower=.5,s.maxEmitPower=1,s.updateSpeed=.005,s.start(),s}static createPunctateCloud(r){if(r.displayValues=null!=r.displayValues&&r.displayValues,r.isAlpha=null==r.isAlpha||r.isAlpha,r.isParticle=null==r.isParticle||r.isParticle,r.radius=r.radius||1,r.isLevelRender=null==r.isLevelRender||r.isLevelRender,r.range=r.range||{max:30,min:16},!r.value&&!r.anchor)return console.error("要创建的云图数值为空!"),null;let e;r.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e=new G(r.anchor),e.mesh=BABYLON.MeshBuilder.CreatePlane(e.id,{width:1,height:1,sideOrientation:2},r.anchor.app.scene),e.mesh.scaling=new BABYLON.Vector3(r.radius,r.radius,r.radius),e.mesh.alwaysSelectAsActiveMesh=!0,e.mesh.enablePointerMoveEvents=!1,e.mesh.isPickable=!1,e.mesh.position=r.anchor.instance.position.clone(),e.mesh.rotation.x=Math.PI/2;let n=[];for(let i=0;i<6;i++)for(let t=0;t<6;t++){let e={x:i,y:t,value:r.range.min};2==i&&2==t||3==i&&2==t||2==i&&3==t||3==i&&3==t?e.value=r.value:e.value=r.value-2*(Math.abs(2-i)+Math.abs(2-t)),n.push(e)}e.displayValues=r.displayValues;let t=$.create({width:5,height:5,radius:2});t.setData({min:r.range.min,max:r.range.max,data:n});let i=new BABYLON.StandardMaterial(e.id,r.anchor.app.scene);return i.diffuseTexture=new BABYLON.Texture(t.getDataURL(),r.anchor.app.scene,!1,!1),i.specularColor=new BABYLON.Color3(0,0,0),i.alpha=.5,r.isAlpha&&(i.diffuseTexture.hasAlpha=!0),r.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getColumnarParticleTex(i.diffuseTexture,e.mesh,r.anchor.app.scene,e.anchor.app.Resources.FogTex,r.isLevelRender),e.mesh.isVisible=!1),r.isLevelRender&&(e.mesh.renderingGroupId=1),e.mesh.material=i,e.mesh.alwaysSelectAsActiveMesh=!0,e.mesh.freezeWorldMatrix(),r.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,e}static createColumnCloud(n){if(n.displayValues=null!=n.displayValues&&n.displayValues,n.isAlpha=null==n.isAlpha||n.isAlpha,n.isParticle=null==n.isParticle||n.isParticle,n.radius=n.radius||4,n.isLevelRender=null==n.isLevelRender||n.isLevelRender,n.range=n.range||{max:30,min:16},!n.data&&n.data.length<1&&!n.anchor)return console.error("要创建的云图数值为空!"),null;let i;n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,i=new G(n.anchor);var r=.98*n.anchor.instance.scaling.y;i.mesh=BABYLON.MeshBuilder.CreatePlane(i.id,{width:.98*n.anchor.instance.scaling.x,height:r,sideOrientation:2},n.anchor.app.scene),i.mesh.alwaysSelectAsActiveMesh=!0,i.mesh.enablePointerMoveEvents=!1,i.mesh.isPickable=!1,i.mesh.position=n.anchor.instance.position.clone(),i.mesh.rotation.z=Math.PI,i.mesh.rotation.y=n.anchor.instance.rotation.y,n.isLevelRender&&(i.mesh.renderingGroupId=1);let e=[];for(let r=0;r<4;r++)for(let i=0;i<3*n.data.length;i++){let t={x:r,y:i,value:n.range.min};for(let e=0;e<n.data.length;e++){var o=n.data[e];2==r&&3*e+2==i&&(t.value=o.value)}e.push(t)}var s=r/n.data.length;for(let t=0;t<n.data.length;t++){let e=i.mesh.position.clone();e.y=e.y-r/2+(r-s*t-s/2),i.texts.push(this.createTempVlaue(n.data[t].value+"℃",e,n.anchor.app.scene,i.anchor.app.container))}i.displayValues=n.displayValues;let t=$.create({width:4,height:3*n.data.length,radius:n.radius});t.setData({min:n.range.min,max:n.range.max,data:e});let a=new BABYLON.StandardMaterial(i.id,n.anchor.app.scene);return a.diffuseTexture=new BABYLON.Texture(t.getDataURL(),n.anchor.app.scene,!1,!1),a.specularColor=new BABYLON.Color3(0,0,0),a.alpha=.5,n.isAlpha&&(a.diffuseTexture.hasAlpha=!0),n.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getColumnarParticleTex(a.diffuseTexture,i.mesh,n.anchor.app.scene,i.anchor.app.Resources.FogTex,n.isLevelRender),i.mesh.isVisible=!1),i.mesh.material=a,i.mesh.alwaysSelectAsActiveMesh=!0,i.mesh.freezeWorldMatrix(),n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,i}static _getColumnarParticleTex(e,t,i,r,n){let o,s=r.clone();r=t.getBoundingInfo().boundingBox,r.extendSizeWorld.x,r.extendSizeWorld.z;BABYLON.Effect.ShadersStore.particlesVertexShader=`
26
26
  precision highp float;
27
27
  in vec3 position;
28
28
  in vec4 color;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mx3d",
3
- "version": "0.1.4",
3
+ "version": "0.1.7",
4
4
  "description": "分支版本",
5
5
  "main": "mx3d.js",
6
6
  "typings": "./dist/index.d.ts",