@mlightcad/common 1.2.3 → 1.2.5

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.
Files changed (67) hide show
  1. package/dist/common.js +1478 -0
  2. package/dist/common.umd.cjs +1 -0
  3. package/lib/AcCmColor.d.ts +201 -0
  4. package/lib/AcCmColor.d.ts.map +1 -0
  5. package/lib/AcCmColor.js +641 -0
  6. package/lib/AcCmColor.js.map +1 -0
  7. package/lib/AcCmColorUtil.d.ts +41 -0
  8. package/lib/AcCmColorUtil.d.ts.map +1 -0
  9. package/lib/AcCmColorUtil.js +90 -0
  10. package/lib/AcCmColorUtil.js.map +1 -0
  11. package/lib/AcCmErrors.d.ts +56 -0
  12. package/lib/AcCmErrors.d.ts.map +1 -0
  13. package/lib/AcCmErrors.js +70 -0
  14. package/lib/AcCmErrors.js.map +1 -0
  15. package/lib/AcCmEventDispatcher.d.ts +101 -0
  16. package/lib/AcCmEventDispatcher.d.ts.map +1 -0
  17. package/lib/AcCmEventDispatcher.js +97 -0
  18. package/lib/AcCmEventDispatcher.js.map +1 -0
  19. package/lib/AcCmEventManager.d.ts +66 -0
  20. package/lib/AcCmEventManager.d.ts.map +1 -0
  21. package/lib/AcCmEventManager.js +133 -0
  22. package/lib/AcCmEventManager.js.map +1 -0
  23. package/lib/AcCmLodashUtils.d.ts +145 -0
  24. package/lib/AcCmLodashUtils.d.ts.map +1 -0
  25. package/lib/AcCmLodashUtils.js +293 -0
  26. package/lib/AcCmLodashUtils.js.map +1 -0
  27. package/lib/AcCmLogUtil.d.ts +80 -0
  28. package/lib/AcCmLogUtil.d.ts.map +1 -0
  29. package/lib/AcCmLogUtil.js +72 -0
  30. package/lib/AcCmLogUtil.js.map +1 -0
  31. package/lib/AcCmObject.d.ts +150 -0
  32. package/lib/AcCmObject.d.ts.map +1 -0
  33. package/lib/AcCmObject.js +204 -0
  34. package/lib/AcCmObject.js.map +1 -0
  35. package/lib/AcCmPerformanceCollector.d.ts +89 -0
  36. package/lib/AcCmPerformanceCollector.d.ts.map +1 -0
  37. package/lib/AcCmPerformanceCollector.js +119 -0
  38. package/lib/AcCmPerformanceCollector.js.map +1 -0
  39. package/lib/AcCmStringUtil.d.ts +44 -0
  40. package/lib/AcCmStringUtil.d.ts.map +1 -0
  41. package/lib/AcCmStringUtil.js +58 -0
  42. package/lib/AcCmStringUtil.js.map +1 -0
  43. package/lib/AcCmTaskScheduler.d.ts +188 -0
  44. package/lib/AcCmTaskScheduler.d.ts.map +1 -0
  45. package/lib/AcCmTaskScheduler.js +256 -0
  46. package/lib/AcCmTaskScheduler.js.map +1 -0
  47. package/lib/index.d.ts +12 -0
  48. package/lib/index.d.ts.map +1 -0
  49. package/lib/index.js +12 -0
  50. package/lib/index.js.map +1 -0
  51. package/lib/loader/AcCmFileLoader.d.ts +95 -0
  52. package/lib/loader/AcCmFileLoader.d.ts.map +1 -0
  53. package/lib/loader/AcCmFileLoader.js +275 -0
  54. package/lib/loader/AcCmFileLoader.js.map +1 -0
  55. package/lib/loader/AcCmLoader.d.ts +125 -0
  56. package/lib/loader/AcCmLoader.d.ts.map +1 -0
  57. package/lib/loader/AcCmLoader.js +116 -0
  58. package/lib/loader/AcCmLoader.js.map +1 -0
  59. package/lib/loader/AcCmLoadingManager.d.ts +166 -0
  60. package/lib/loader/AcCmLoadingManager.d.ts.map +1 -0
  61. package/lib/loader/AcCmLoadingManager.js +172 -0
  62. package/lib/loader/AcCmLoadingManager.js.map +1 -0
  63. package/lib/loader/index.d.ts +3 -0
  64. package/lib/loader/index.d.ts.map +1 -0
  65. package/lib/loader/index.js +3 -0
  66. package/lib/loader/index.js.map +1 -0
  67. package/package.json +1 -1
package/dist/common.js ADDED
@@ -0,0 +1,1478 @@
1
+ function H(n, e) {
2
+ for (var t = 0; t < e.length; t++) {
3
+ const r = e[t];
4
+ if (typeof r != "string" && !Array.isArray(r)) {
5
+ for (const o in r)
6
+ if (o !== "default" && !(o in n)) {
7
+ const i = Object.getOwnPropertyDescriptor(r, o);
8
+ i && Object.defineProperty(n, o, i.get ? i : {
9
+ enumerable: !0,
10
+ get: () => r[o]
11
+ });
12
+ }
13
+ }
14
+ }
15
+ return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
16
+ }
17
+ const I = {
18
+ aliceblue: 15792383,
19
+ antiquewhite: 16444375,
20
+ aqua: 65535,
21
+ aquamarine: 8388564,
22
+ azure: 15794175,
23
+ beige: 16119260,
24
+ bisque: 16770244,
25
+ black: 0,
26
+ blanchedalmond: 16772045,
27
+ blue: 255,
28
+ blueviolet: 9055202,
29
+ brown: 10824234,
30
+ burlywood: 14596231,
31
+ cadetblue: 6266528,
32
+ chartreuse: 8388352,
33
+ chocolate: 13789470,
34
+ coral: 16744272,
35
+ cornflowerblue: 6591981,
36
+ cornsilk: 16775388,
37
+ crimson: 14423100,
38
+ cyan: 65535,
39
+ darkblue: 139,
40
+ darkcyan: 35723,
41
+ darkgoldenrod: 12092939,
42
+ darkgray: 11119017,
43
+ darkgreen: 25600,
44
+ darkkhaki: 12433259,
45
+ darkmagenta: 9109643,
46
+ darkolivegreen: 5597999,
47
+ darkorange: 16747520,
48
+ darkorchid: 10040012,
49
+ darkred: 9109504,
50
+ darksalmon: 15308410,
51
+ darkseagreen: 9419919,
52
+ darkslateblue: 4734347,
53
+ darkslategray: 3100495,
54
+ darkturquoise: 52945,
55
+ darkviolet: 9699539,
56
+ deeppink: 16716947,
57
+ deepskyblue: 49151,
58
+ dimgrey: 6908265,
59
+ dodgerblue: 2003199,
60
+ firebrick: 11674146,
61
+ floralwhite: 16775920,
62
+ forestgreen: 2263842,
63
+ fuchsia: 16711935,
64
+ gainsboro: 14474460,
65
+ ghostwhite: 16316671,
66
+ gold: 16766720,
67
+ goldenrod: 14329120,
68
+ gray: 8421504,
69
+ green: 32768,
70
+ greenyellow: 11403055,
71
+ grey: 8421504,
72
+ honeydew: 15794160,
73
+ hotpink: 16738740,
74
+ indianred: 13458524,
75
+ indigo: 4915330,
76
+ ivory: 16777200,
77
+ khaki: 15787660,
78
+ lavender: 15132410,
79
+ lavenderblush: 16773365,
80
+ lawngreen: 8190976,
81
+ lemonchiffon: 16775885,
82
+ lightblue: 11393254,
83
+ lightcoral: 15761536,
84
+ lightcyan: 14745599,
85
+ lightgoldenrodyellow: 16448210,
86
+ lightgray: 13882323,
87
+ lightgreen: 9498256,
88
+ lightgrey: 13882323,
89
+ lightpink: 16758465,
90
+ lightsalmon: 16752762,
91
+ lightseagreen: 2142890,
92
+ lightskyblue: 8900346,
93
+ lightslategray: 7833753,
94
+ lightslategrey: 7833753,
95
+ lightsteelblue: 11584734,
96
+ lightyellow: 16777184,
97
+ lime: 65280,
98
+ limegreen: 3329330,
99
+ linen: 16445670,
100
+ magenta: 16711935,
101
+ maroon: 8388608,
102
+ mediumaquamarine: 6737322,
103
+ mediumblue: 205,
104
+ mediumorchid: 12211667,
105
+ mediumpurple: 9662683,
106
+ mediumseagreen: 3978097,
107
+ mediumslateblue: 8087790,
108
+ mediumspringgreen: 64154,
109
+ mediumturquoise: 4772300,
110
+ mediumvioletred: 13047173,
111
+ midnightblue: 1644912,
112
+ mintcream: 16121850,
113
+ mistyrose: 16770273,
114
+ moccasin: 16770229,
115
+ navajowhite: 16768685,
116
+ navy: 128,
117
+ oldlace: 16643558,
118
+ olive: 8421376,
119
+ olivedrab: 7048739,
120
+ orange: 16753920,
121
+ orangered: 16729344,
122
+ orchid: 14315734,
123
+ palegoldenrod: 15657130,
124
+ palegreen: 10025880,
125
+ paleturquoise: 11529966,
126
+ palevioletred: 14381203,
127
+ papayawhip: 16773077,
128
+ peachpuff: 16767673,
129
+ peru: 13468991,
130
+ pink: 16761035,
131
+ plum: 14524637,
132
+ powderblue: 11591910,
133
+ purple: 8388736,
134
+ rebeccapurple: 6697881,
135
+ red: 16711680,
136
+ rosybrown: 12357519,
137
+ royalblue: 4286945,
138
+ saddlebrown: 9127187,
139
+ salmon: 16416882,
140
+ sandybrown: 16032864,
141
+ seagreen: 3050327,
142
+ seashell: 16774638,
143
+ sienna: 10506797,
144
+ silver: 12632256,
145
+ skyblue: 8900331,
146
+ slateblue: 6970061,
147
+ slategrey: 7372944,
148
+ snow: 16775930,
149
+ springgreen: 65407,
150
+ steelblue: 4620980,
151
+ tan: 13808780,
152
+ teal: 32896,
153
+ thistle: 14204888,
154
+ tomato: 16737095,
155
+ turquoise: 4251856,
156
+ violet: 15631086,
157
+ wheat: 16113331,
158
+ white: 16777215,
159
+ whitesmoke: 16119285,
160
+ yellow: 16776960,
161
+ yellowgreen: 10145074
162
+ }, T = [
163
+ 0,
164
+ 16711680,
165
+ 16776960,
166
+ 65280,
167
+ 65535,
168
+ 255,
169
+ 16711935,
170
+ 16777215,
171
+ 8421504,
172
+ 12632256,
173
+ 16711680,
174
+ 16744319,
175
+ 13369344,
176
+ 13395558,
177
+ 10027008,
178
+ 10046540,
179
+ 8323072,
180
+ 8339263,
181
+ 4980736,
182
+ 4990502,
183
+ 16727808,
184
+ 16752511,
185
+ 13382400,
186
+ 13401958,
187
+ 10036736,
188
+ 10051404,
189
+ 8331008,
190
+ 8343359,
191
+ 4985600,
192
+ 4992806,
193
+ 16744192,
194
+ 16760703,
195
+ 13395456,
196
+ 13408614,
197
+ 10046464,
198
+ 10056268,
199
+ 8339200,
200
+ 8347455,
201
+ 4990464,
202
+ 4995366,
203
+ 16760576,
204
+ 16768895,
205
+ 13408512,
206
+ 13415014,
207
+ 10056192,
208
+ 10061132,
209
+ 8347392,
210
+ 8351551,
211
+ 4995328,
212
+ 4997670,
213
+ 16776960,
214
+ 16777087,
215
+ 13421568,
216
+ 13421670,
217
+ 10000384,
218
+ 10000460,
219
+ 8355584,
220
+ 8355647,
221
+ 5000192,
222
+ 5000230,
223
+ 12582656,
224
+ 14679935,
225
+ 10079232,
226
+ 11717734,
227
+ 7510016,
228
+ 8755276,
229
+ 6258432,
230
+ 7307071,
231
+ 3755008,
232
+ 4344870,
233
+ 8388352,
234
+ 12582783,
235
+ 6736896,
236
+ 10079334,
237
+ 5019648,
238
+ 7510092,
239
+ 4161280,
240
+ 6258495,
241
+ 2509824,
242
+ 3755046,
243
+ 4194048,
244
+ 10485631,
245
+ 3394560,
246
+ 8375398,
247
+ 2529280,
248
+ 6264908,
249
+ 2064128,
250
+ 5209919,
251
+ 1264640,
252
+ 3099686,
253
+ 65280,
254
+ 8388479,
255
+ 52224,
256
+ 6736998,
257
+ 38912,
258
+ 5019724,
259
+ 32512,
260
+ 4161343,
261
+ 19456,
262
+ 2509862,
263
+ 65343,
264
+ 8388511,
265
+ 52275,
266
+ 6737023,
267
+ 38950,
268
+ 5019743,
269
+ 32543,
270
+ 4161359,
271
+ 19475,
272
+ 2509871,
273
+ 65407,
274
+ 8388543,
275
+ 52326,
276
+ 6737049,
277
+ 38988,
278
+ 5019762,
279
+ 32575,
280
+ 4161375,
281
+ 19494,
282
+ 2509881,
283
+ 65471,
284
+ 8388575,
285
+ 52377,
286
+ 6737074,
287
+ 39026,
288
+ 5019781,
289
+ 32607,
290
+ 4161391,
291
+ 19513,
292
+ 2509890,
293
+ 65535,
294
+ 8388607,
295
+ 52428,
296
+ 6737100,
297
+ 39064,
298
+ 5019800,
299
+ 32639,
300
+ 4161407,
301
+ 19532,
302
+ 2509900,
303
+ 49151,
304
+ 8380415,
305
+ 39372,
306
+ 6730444,
307
+ 29336,
308
+ 5014936,
309
+ 24447,
310
+ 4157311,
311
+ 14668,
312
+ 2507340,
313
+ 32767,
314
+ 8372223,
315
+ 26316,
316
+ 6724044,
317
+ 19608,
318
+ 5010072,
319
+ 16255,
320
+ 4153215,
321
+ 9804,
322
+ 2505036,
323
+ 16383,
324
+ 8364031,
325
+ 13260,
326
+ 6717388,
327
+ 9880,
328
+ 5005208,
329
+ 8063,
330
+ 4149119,
331
+ 4940,
332
+ 2502476,
333
+ 255,
334
+ 8355839,
335
+ 204,
336
+ 6710988,
337
+ 152,
338
+ 5000344,
339
+ 127,
340
+ 4145023,
341
+ 76,
342
+ 2500172,
343
+ 4129023,
344
+ 10452991,
345
+ 3342540,
346
+ 8349388,
347
+ 2490520,
348
+ 6245528,
349
+ 2031743,
350
+ 5193599,
351
+ 1245260,
352
+ 3089996,
353
+ 8323327,
354
+ 12550143,
355
+ 6684876,
356
+ 10053324,
357
+ 4980888,
358
+ 7490712,
359
+ 4128895,
360
+ 6242175,
361
+ 2490444,
362
+ 3745356,
363
+ 12517631,
364
+ 14647295,
365
+ 10027212,
366
+ 11691724,
367
+ 7471256,
368
+ 8735896,
369
+ 6226047,
370
+ 7290751,
371
+ 3735628,
372
+ 4335180,
373
+ 16711935,
374
+ 16744447,
375
+ 13369548,
376
+ 13395660,
377
+ 9961624,
378
+ 9981080,
379
+ 8323199,
380
+ 8339327,
381
+ 4980812,
382
+ 4990540,
383
+ 16711871,
384
+ 16744415,
385
+ 13369497,
386
+ 13395634,
387
+ 9961586,
388
+ 9981061,
389
+ 8323167,
390
+ 8339311,
391
+ 4980793,
392
+ 4990530,
393
+ 16711807,
394
+ 16744383,
395
+ 13369446,
396
+ 13395609,
397
+ 9961548,
398
+ 9981042,
399
+ 8323135,
400
+ 8339295,
401
+ 4980774,
402
+ 4990521,
403
+ 16711743,
404
+ 16744351,
405
+ 13369395,
406
+ 13395583,
407
+ 9961510,
408
+ 9981023,
409
+ 8323103,
410
+ 8339279,
411
+ 4980755,
412
+ 4990511,
413
+ 3355443,
414
+ 5987163,
415
+ 8684676,
416
+ 11382189,
417
+ 14079702,
418
+ 16777215,
419
+ 0
420
+ ];
421
+ function w(n, e, t) {
422
+ return Math.max(e, Math.min(t, n));
423
+ }
424
+ const C = class C {
425
+ /**
426
+ * Constructs a new AcCmColor instance.
427
+ * Initializes the color to "ByLayer" (index 256) and null RGB values.
428
+ */
429
+ constructor() {
430
+ this._colorIndex = 256, this._color = null, this._colorName = null;
431
+ }
432
+ /**
433
+ * Gets the current color value.
434
+ *
435
+ * @returns {number | null} The color value (RGB or index).
436
+ */
437
+ get color() {
438
+ return this._color;
439
+ }
440
+ /**
441
+ * Sets the color value.
442
+ *
443
+ * @param {number | null} value - The color value to set (RGB or index).
444
+ */
445
+ set color(e) {
446
+ e == null ? this._color = null : (this._color = Math.round(w(e, 0, 256 * 256 * 256 - 1)), this._colorIndex = this.getColorIndexByValue(this._color), this._colorName = this.getColorNameByValue(this._color));
447
+ }
448
+ /**
449
+ * Gets the hexadecimal representation of the current color.
450
+ *
451
+ * @returns {string} The hexadecimal color string (e.g., "0xFFFFFF").
452
+ */
453
+ get hexColor() {
454
+ if (this._color && this._color > 0 && this._color <= 16777215) {
455
+ let e = this._color.toString(16).toUpperCase();
456
+ for (; e.length < 6; )
457
+ e = "0" + e;
458
+ return `0x${e}`;
459
+ }
460
+ return "";
461
+ }
462
+ /**
463
+ * Gets the CSS RGB color string representation.
464
+ *
465
+ * @returns {string} The CSS RGB color string (e.g., "rgb(255,255,255)").
466
+ */
467
+ get cssColor() {
468
+ return `rgb(${this.red},${this.green},${this.blue})`;
469
+ }
470
+ /**
471
+ * Gets the red component of the current color.
472
+ *
473
+ * @returns {number | null} The red component (0-255).
474
+ */
475
+ get red() {
476
+ return this.color ? this.color >> 16 & 255 : null;
477
+ }
478
+ /**
479
+ * Gets the green component of the current color.
480
+ *
481
+ * @returns {number | null} The green component (0-255).
482
+ */
483
+ get green() {
484
+ return this.color ? this.color >> 8 & 255 : null;
485
+ }
486
+ /**
487
+ * Gets the blue component of the current color.
488
+ *
489
+ * @returns {number | null} The blue component (0-255).
490
+ */
491
+ get blue() {
492
+ return this.color ? this.color & 255 : null;
493
+ }
494
+ /**
495
+ * Gets the AutoCAD color index value. The index value will be in the range 0 to 256.
496
+ * 0 and 256 are special values.
497
+ *
498
+ * @returns {number | null} The color index.
499
+ */
500
+ get colorIndex() {
501
+ return this._colorIndex;
502
+ }
503
+ /**
504
+ * Sets the AutoCAD color index value. If value less than 0 is set, 0 will be used. If value greater than
505
+ * 256 is set, 256 will be used.
506
+ * - 0 indicates that the entity uses the color of the BlockReference that's displaying it. If the entity
507
+ * is not displayed through a block reference (for example, it is directly owned by the model space
508
+ * block table record) and its color is 0, then it will display as though its color were 7.
509
+ * - 256 indicates that the entity uses the color specified in the layer table record it references.
510
+ *
511
+ * @param {number | null} value - The color index to set (0-256).
512
+ */
513
+ set colorIndex(e) {
514
+ e == null ? this._colorIndex = null : (this._colorIndex = w(e, 0, 256), this._colorIndex > 0 && this._colorIndex < 256 ? (this._color = T[e], this._colorName = this.getColorNameByValue(this._color)) : (this._color = null, this._colorName = null));
515
+ }
516
+ /**
517
+ * Gets the name of the current color.
518
+ *
519
+ * @returns {string | null} The color name.
520
+ */
521
+ get colorName() {
522
+ return this._colorName;
523
+ }
524
+ /**
525
+ * Sets the color by name.
526
+ *
527
+ * @param {string | null} value - The color name to set.
528
+ */
529
+ set colorName(e) {
530
+ if (e) {
531
+ const t = I[e.toLowerCase()];
532
+ t !== void 0 ? (this._colorName = e, this._color = t, this._colorIndex = this.getColorIndexByValue(this._color)) : console.warn("Unknown color: " + e);
533
+ } else
534
+ this._colorName = null;
535
+ }
536
+ /**
537
+ * Checks if the color has a name.
538
+ *
539
+ * @returns {boolean} True if the color has no name, false otherwise.
540
+ */
541
+ get hasColorName() {
542
+ return this._colorName == null;
543
+ }
544
+ /**
545
+ * Checks if the color has an index.
546
+ *
547
+ * @returns {boolean} True if the color has no index, false otherwise.
548
+ */
549
+ get hasColorIndex() {
550
+ return this._colorIndex == null;
551
+ }
552
+ /**
553
+ * Checks if the color is set to "ByLayer".
554
+ *
555
+ * @returns {boolean} True if the color is "ByLayer", false otherwise.
556
+ */
557
+ get isByLayer() {
558
+ return this.colorIndex == 256;
559
+ }
560
+ /**
561
+ * Sets the color to "ByLayer".
562
+ *
563
+ * @returns {AcCmColor} The current instance.
564
+ */
565
+ setByLayer() {
566
+ return this.colorIndex = 256, this;
567
+ }
568
+ /**
569
+ * Checks if the color is set to "ByBlock".
570
+ *
571
+ * @returns {boolean} True if the color is "ByBlock", false otherwise.
572
+ */
573
+ get isByBlock() {
574
+ return this.colorIndex == 0;
575
+ }
576
+ /**
577
+ * Sets the color to "ByBlock".
578
+ *
579
+ * @returns {AcCmColor} The current instance.
580
+ */
581
+ setByBlock() {
582
+ return this.colorIndex = 0, this;
583
+ }
584
+ /**
585
+ * Sets the color using a scalar value (RGB).
586
+ *
587
+ * @param {number} scalar - The scalar value (0-255).
588
+ * @returns {AcCmColor} The current instance.
589
+ */
590
+ setScalar(e) {
591
+ return this.setRGB(e, e, e), this;
592
+ }
593
+ /**
594
+ * Sets the color using RGB values.
595
+ *
596
+ * @param {number} r - The red component (0-255).
597
+ * @param {number} g - The green component (0-255).
598
+ * @param {number} b - The blue component (0-255).
599
+ * @returns {AcCmColor} The current instance.
600
+ */
601
+ setRGB(e, t, r) {
602
+ const o = Math.round(w(e, 0, 255)), i = Math.round(w(t, 0, 255)), l = Math.round(w(r, 0, 255));
603
+ return this.color = (o << 16) + (i << 8) + l, this;
604
+ }
605
+ /**
606
+ * Sets the color by name.
607
+ *
608
+ * @param {string} style - The color name to set.
609
+ * @returns {AcCmColor} The current instance.
610
+ */
611
+ setColorName(e) {
612
+ const t = I[e.toLowerCase()];
613
+ return t !== void 0 ? this.color = t : console.warn("Unknown color " + e), this;
614
+ }
615
+ /**
616
+ * Clones the current AcCmColor instance.
617
+ *
618
+ * @returns {AcCmColor} A new AcCmColor instance with the same color and index.
619
+ */
620
+ clone() {
621
+ const e = new C();
622
+ return e.colorIndex = this.colorIndex, e.color = this.color, e._colorName = this._colorName, this;
623
+ }
624
+ /**
625
+ * Copies the color from another AcCmColor instance.
626
+ *
627
+ * @param {AcCmColor} color - The color to copy from.
628
+ * @returns {AcCmColor} The current instance.
629
+ */
630
+ copy(e) {
631
+ return this.colorIndex = e.colorIndex, this.color = e.color, this._colorName = e._colorName, this;
632
+ }
633
+ /**
634
+ * Checks if two AcCmColor instances are equal.
635
+ *
636
+ * @param {AcCmColor} c - The color to compare with.
637
+ * @returns {boolean} True if the colors and their indices are the same.
638
+ */
639
+ equals(e) {
640
+ return e.color == this.color && e.colorIndex == this.colorIndex && e._colorName == this._colorName;
641
+ }
642
+ /**
643
+ * Returns a string representation of the color.
644
+ *
645
+ * @returns {string} The color name or hexadecimal string.
646
+ */
647
+ toString() {
648
+ return this.isByLayer ? "ByLayer" : this.isByBlock ? "ByBlock" : this.colorName ? this.colorName : this.hexColor;
649
+ }
650
+ /**
651
+ * Finds the color name associated with a given RGB value.
652
+ *
653
+ * @private
654
+ * @param {number} target - The RGB value to find a name for.
655
+ * @returns {string | null} The color name if found, null otherwise.
656
+ */
657
+ getColorNameByValue(e) {
658
+ for (const [t, r] of Object.entries(I))
659
+ if (r === e)
660
+ return t;
661
+ return null;
662
+ }
663
+ /**
664
+ * Finds the AutoCAD color index associated with a given RGB value.
665
+ *
666
+ * @private
667
+ * @param {number} target - The RGB value to find an index for.
668
+ * @returns {number | null} The color index if found, null otherwise.
669
+ */
670
+ getColorIndexByValue(e) {
671
+ const t = T.length - 1;
672
+ for (let r = 1; r < t; ++r)
673
+ if (T[r] === e)
674
+ return r;
675
+ return null;
676
+ }
677
+ };
678
+ C.NAMES = I;
679
+ let R = C;
680
+ const te = {
681
+ /**
682
+ * Throw error ILLEGAL_PARAMETERS when cannot instantiate from given parameter
683
+ */
684
+ get ILLEGAL_PARAMETERS() {
685
+ return new ReferenceError("Illegal Parameters");
686
+ },
687
+ /**
688
+ * Throw error ZERO_DIVISION to catch situation of zero division
689
+ */
690
+ get ZERO_DIVISION() {
691
+ return new Error("Zero division");
692
+ },
693
+ /**
694
+ * Error to throw from BooleanOperations module in case when fixBoundaryConflicts not capable to fix it
695
+ */
696
+ get UNRESOLVED_BOUNDARY_CONFLICT() {
697
+ return new Error("Unresolved boundary conflict in boolean operation");
698
+ },
699
+ /**
700
+ * Error to throw from LinkedList:testInfiniteLoop static method
701
+ * in case when circular loop detected in linked list
702
+ */
703
+ get INFINITE_LOOP() {
704
+ return new Error("Infinite loop");
705
+ },
706
+ get CANNOT_INVOKE_ABSTRACT_METHOD() {
707
+ return new Error("Abstract method cannot be invoked");
708
+ },
709
+ get OPERATION_IS_NOT_SUPPORTED() {
710
+ return new Error("Operation is not supported");
711
+ },
712
+ get NOT_IMPLEMENTED() {
713
+ return new Error("Not implemented yet");
714
+ }
715
+ };
716
+ class re {
717
+ /**
718
+ * Creates {@link AcCmEventDispatcher} object.
719
+ */
720
+ constructor() {
721
+ this._listeners = {};
722
+ }
723
+ addEventListener(e, t) {
724
+ this._listeners === void 0 && (this._listeners = {});
725
+ const r = this._listeners;
726
+ r[e] === void 0 && (r[e] = []), r[e].indexOf(t) === -1 && r[e].push(t);
727
+ }
728
+ hasEventListener(e, t) {
729
+ if (this._listeners === void 0) return !1;
730
+ const r = this._listeners;
731
+ return r[e] !== void 0 && r[e].indexOf(t) !== -1;
732
+ }
733
+ removeEventListener(e, t) {
734
+ if (this._listeners === void 0) return;
735
+ const o = this._listeners[e];
736
+ if (o !== void 0) {
737
+ const i = o.indexOf(t);
738
+ i !== -1 && o.splice(i, 1);
739
+ }
740
+ }
741
+ /**
742
+ * Fire an event type.
743
+ * @param event The event that gets fired.
744
+ */
745
+ dispatchEvent(e) {
746
+ if (this._listeners === void 0) return;
747
+ const r = this._listeners[e.type];
748
+ if (r !== void 0) {
749
+ e.target = this;
750
+ const o = r.slice(0);
751
+ for (let i = 0, l = o.length; i < l; i++)
752
+ o[i].call(this, e);
753
+ }
754
+ }
755
+ }
756
+ class U {
757
+ constructor() {
758
+ this.listeners = [];
759
+ }
760
+ /**
761
+ * Add the event listener
762
+ * @param listener Input listener to be added
763
+ */
764
+ addEventListener(e) {
765
+ this.listeners.push(e);
766
+ }
767
+ /**
768
+ * Remove the listener
769
+ * @param listener Input listener to be removed
770
+ */
771
+ removeEventListener(e) {
772
+ this.listeners = this.listeners.filter((t) => t !== e);
773
+ }
774
+ /**
775
+ * Remove all listeners bound to the target and add one new listener
776
+ * @param listener Input listener to be added
777
+ */
778
+ replaceEventListener(e) {
779
+ this.removeEventListener(e), this.addEventListener(e);
780
+ }
781
+ /**
782
+ * Notify all listeners
783
+ * @param payload Input payload passed to listener
784
+ */
785
+ dispatch(e, ...t) {
786
+ for (const r of this.listeners)
787
+ r.call(null, e, ...t);
788
+ }
789
+ }
790
+ var K = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
791
+ function z(n) {
792
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
793
+ }
794
+ var q = { exports: {} };
795
+ (function(n) {
796
+ (function(e, t) {
797
+ n.exports ? n.exports = t() : e.log = t();
798
+ })(K, function() {
799
+ var e = function() {
800
+ }, t = "undefined", r = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), o = [
801
+ "trace",
802
+ "debug",
803
+ "info",
804
+ "warn",
805
+ "error"
806
+ ], i = {}, l = null;
807
+ function g(a, h) {
808
+ var s = a[h];
809
+ if (typeof s.bind == "function")
810
+ return s.bind(a);
811
+ try {
812
+ return Function.prototype.bind.call(s, a);
813
+ } catch {
814
+ return function() {
815
+ return Function.prototype.apply.apply(s, [a, arguments]);
816
+ };
817
+ }
818
+ }
819
+ function L() {
820
+ console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
821
+ }
822
+ function y(a) {
823
+ return a === "debug" && (a = "log"), typeof console === t ? !1 : a === "trace" && r ? L : console[a] !== void 0 ? g(console, a) : console.log !== void 0 ? g(console, "log") : e;
824
+ }
825
+ function p() {
826
+ for (var a = this.getLevel(), h = 0; h < o.length; h++) {
827
+ var s = o[h];
828
+ this[s] = h < a ? e : this.methodFactory(s, a, this.name);
829
+ }
830
+ if (this.log = this.debug, typeof console === t && a < this.levels.SILENT)
831
+ return "No console available for logging";
832
+ }
833
+ function O(a) {
834
+ return function() {
835
+ typeof console !== t && (p.call(this), this[a].apply(this, arguments));
836
+ };
837
+ }
838
+ function d(a, h, s) {
839
+ return y(a) || O.apply(this, arguments);
840
+ }
841
+ function M(a, h) {
842
+ var s = this, E, N, m, f = "loglevel";
843
+ typeof a == "string" ? f += ":" + a : typeof a == "symbol" && (f = void 0);
844
+ function V(c) {
845
+ var u = (o[c] || "silent").toUpperCase();
846
+ if (!(typeof window === t || !f)) {
847
+ try {
848
+ window.localStorage[f] = u;
849
+ return;
850
+ } catch {
851
+ }
852
+ try {
853
+ window.document.cookie = encodeURIComponent(f) + "=" + u + ";";
854
+ } catch {
855
+ }
856
+ }
857
+ }
858
+ function B() {
859
+ var c;
860
+ if (!(typeof window === t || !f)) {
861
+ try {
862
+ c = window.localStorage[f];
863
+ } catch {
864
+ }
865
+ if (typeof c === t)
866
+ try {
867
+ var u = window.document.cookie, k = encodeURIComponent(f), S = u.indexOf(k + "=");
868
+ S !== -1 && (c = /^([^;]+)/.exec(
869
+ u.slice(S + k.length + 1)
870
+ )[1]);
871
+ } catch {
872
+ }
873
+ return s.levels[c] === void 0 && (c = void 0), c;
874
+ }
875
+ }
876
+ function $() {
877
+ if (!(typeof window === t || !f)) {
878
+ try {
879
+ window.localStorage.removeItem(f);
880
+ } catch {
881
+ }
882
+ try {
883
+ window.document.cookie = encodeURIComponent(f) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
884
+ } catch {
885
+ }
886
+ }
887
+ }
888
+ function v(c) {
889
+ var u = c;
890
+ if (typeof u == "string" && s.levels[u.toUpperCase()] !== void 0 && (u = s.levels[u.toUpperCase()]), typeof u == "number" && u >= 0 && u <= s.levels.SILENT)
891
+ return u;
892
+ throw new TypeError("log.setLevel() called with invalid level: " + c);
893
+ }
894
+ s.name = a, s.levels = {
895
+ TRACE: 0,
896
+ DEBUG: 1,
897
+ INFO: 2,
898
+ WARN: 3,
899
+ ERROR: 4,
900
+ SILENT: 5
901
+ }, s.methodFactory = h || d, s.getLevel = function() {
902
+ return m ?? N ?? E;
903
+ }, s.setLevel = function(c, u) {
904
+ return m = v(c), u !== !1 && V(m), p.call(s);
905
+ }, s.setDefaultLevel = function(c) {
906
+ N = v(c), B() || s.setLevel(c, !1);
907
+ }, s.resetLevel = function() {
908
+ m = null, $(), p.call(s);
909
+ }, s.enableAll = function(c) {
910
+ s.setLevel(s.levels.TRACE, c);
911
+ }, s.disableAll = function(c) {
912
+ s.setLevel(s.levels.SILENT, c);
913
+ }, s.rebuild = function() {
914
+ if (l !== s && (E = v(l.getLevel())), p.call(s), l === s)
915
+ for (var c in i)
916
+ i[c].rebuild();
917
+ }, E = v(
918
+ l ? l.getLevel() : "WARN"
919
+ );
920
+ var P = B();
921
+ P != null && (m = v(P)), p.call(s);
922
+ }
923
+ l = new M(), l.getLogger = function(h) {
924
+ if (typeof h != "symbol" && typeof h != "string" || h === "")
925
+ throw new TypeError("You must supply a name when creating a logger.");
926
+ var s = i[h];
927
+ return s || (s = i[h] = new M(
928
+ h,
929
+ l.methodFactory
930
+ )), s;
931
+ };
932
+ var j = typeof window !== t ? window.log : void 0;
933
+ return l.noConflict = function() {
934
+ return typeof window !== t && window.log === l && (window.log = j), l;
935
+ }, l.getLoggers = function() {
936
+ return i;
937
+ }, l.default = l, l;
938
+ });
939
+ })(q);
940
+ var D = q.exports;
941
+ const W = /* @__PURE__ */ z(D), Y = /* @__PURE__ */ H({
942
+ __proto__: null,
943
+ default: W
944
+ }, [D]), ne = !0, x = Y;
945
+ x.setLevel("debug");
946
+ const oe = (n) => {
947
+ try {
948
+ x.setLevel(n);
949
+ } catch (e) {
950
+ x.setLevel("error"), x.error(e);
951
+ }
952
+ };
953
+ function A(n) {
954
+ return n === null || typeof n != "object" ? n : Array.isArray(n) ? [...n] : { ...n };
955
+ }
956
+ function Z(n, ...e) {
957
+ for (const t of e)
958
+ if (t)
959
+ for (const r in t)
960
+ Object.prototype.hasOwnProperty.call(t, r) && n[r] === void 0 && (n[r] = t[r]);
961
+ return n;
962
+ }
963
+ function J(n, e) {
964
+ return n != null && Object.prototype.hasOwnProperty.call(n, e);
965
+ }
966
+ function X(n) {
967
+ return n == null ? !0 : Array.isArray(n) || typeof n == "string" ? n.length === 0 : n instanceof Map || n instanceof Set ? n.size === 0 : typeof n == "object" ? Object.keys(n).length === 0 : !1;
968
+ }
969
+ function _(n, e) {
970
+ if (n === e)
971
+ return !0;
972
+ if (n == null || e == null)
973
+ return n === e;
974
+ if (typeof n != typeof e)
975
+ return !1;
976
+ if (typeof n != "object")
977
+ return n === e;
978
+ if (Array.isArray(n) !== Array.isArray(e))
979
+ return !1;
980
+ if (Array.isArray(n)) {
981
+ if (n.length !== e.length)
982
+ return !1;
983
+ for (let o = 0; o < n.length; o++)
984
+ if (!_(n[o], e[o]))
985
+ return !1;
986
+ return !0;
987
+ }
988
+ const t = Object.keys(n), r = Object.keys(e);
989
+ if (t.length !== r.length)
990
+ return !1;
991
+ for (const o of t)
992
+ if (!Object.prototype.hasOwnProperty.call(
993
+ e,
994
+ o
995
+ ) || !_(
996
+ n[o],
997
+ e[o]
998
+ ))
999
+ return !1;
1000
+ return !0;
1001
+ }
1002
+ class F {
1003
+ /**
1004
+ * Create one object to store attributes. For performance reason, values of attributes passed to constructor
1005
+ * will not be cloned to `attributes` property. So it means that value of `attributes` property in this object
1006
+ * is just a reference to arguments `attributes` passed to constructor.
1007
+ * @param attributes Input attributes to store in this object
1008
+ */
1009
+ constructor(e, t) {
1010
+ this.events = {
1011
+ attrChanged: new U(),
1012
+ modelChanged: new U()
1013
+ }, this._changing = !1, this._previousAttributes = {}, this._pending = !1;
1014
+ const r = e || {};
1015
+ t && Z(r, t), this.attributes = r, this.changed = {};
1016
+ }
1017
+ /**
1018
+ * Gets the value of an attribute.
1019
+ *
1020
+ * For strongly-typed access to attributes, use the `get` method privately in public getter properties.
1021
+ *
1022
+ * @template A - The key type extending string keys of T.
1023
+ * @param {A} key - The attribute key to retrieve.
1024
+ * @returns {T[A] | undefined} The attribute value or undefined if not set.
1025
+ *
1026
+ * @example
1027
+ * ```typescript
1028
+ * // Get a single attribute value
1029
+ * const name = obj.get('name')
1030
+ * const visible = obj.get('visible')
1031
+ *
1032
+ * // Check if attribute exists
1033
+ * if (obj.get('name') !== undefined) {
1034
+ * console.log('Name is set')
1035
+ * }
1036
+ *
1037
+ * // For strongly-typed subclasses
1038
+ * get name(): string {
1039
+ * return super.get("name")
1040
+ * }
1041
+ * ```
1042
+ */
1043
+ get(e) {
1044
+ return this.attributes[e];
1045
+ }
1046
+ set(e, t, r) {
1047
+ if (e == null) return this;
1048
+ let o;
1049
+ typeof e == "object" ? (o = e, r = t) : (o = {}, o[e] = t), r || (r = {});
1050
+ const i = r.unset, l = r.silent, g = [], L = this._changing;
1051
+ this._changing = !0, L || (this._previousAttributes = A(this.attributes), this.changed = {});
1052
+ const y = this.attributes, p = this.changed, O = this._previousAttributes;
1053
+ for (const d in o)
1054
+ t = o[d], _(y[d], t) || g.push(d), _(O[d], t) ? delete p[d] : p[d] = t, i ? delete y[d] : y[d] = t;
1055
+ if (!l) {
1056
+ g.length && (this._pending = r);
1057
+ for (let d = 0; d < g.length; d++)
1058
+ this.events.attrChanged.dispatch({
1059
+ object: this,
1060
+ attrName: g[d],
1061
+ attrValue: y[g[d]],
1062
+ options: r
1063
+ });
1064
+ }
1065
+ if (L) return this;
1066
+ if (!l)
1067
+ for (; this._pending; )
1068
+ r = this._pending, this._pending = !1, this.events.modelChanged.dispatch({
1069
+ object: this,
1070
+ options: r
1071
+ });
1072
+ return this._pending = !1, this._changing = !1, this;
1073
+ }
1074
+ has(e) {
1075
+ return this.get(e) != null;
1076
+ }
1077
+ /**
1078
+ * Determine if the model has changed since the last `"change"` event.
1079
+ * If you specify an attribute name, determine if that attribute has changed.
1080
+ */
1081
+ hasChanged(e) {
1082
+ return e == null ? !X(this.changed) : J(this.changed, e);
1083
+ }
1084
+ /**
1085
+ * Return an object containing all the attributes that have changed. Useful for determining what parts
1086
+ * of a view need to be updated and/or what attributes need to be persisted to the server.
1087
+ *
1088
+ * Unset attributes will be set to undefined. You can also pass an attributes object to diff against
1089
+ * the model, determining if there *would be* a change.
1090
+ */
1091
+ changedAttributes(e) {
1092
+ if (!e) return this.hasChanged() ? A(this.changed) : {};
1093
+ const t = this._changing ? this._previousAttributes : this.attributes, r = {};
1094
+ for (const o in e) {
1095
+ const i = e[o];
1096
+ _(t[o], i) || (r[o] = i);
1097
+ }
1098
+ return r;
1099
+ }
1100
+ /**
1101
+ * Get the previous value of an attribute, recorded at the time the last `"change"` event was fired.
1102
+ */
1103
+ previous(e) {
1104
+ return e == null || !this._previousAttributes ? null : this._previousAttributes[e];
1105
+ }
1106
+ /**
1107
+ * Get all of the attributes of the model at the time of the previous `"change"` event.
1108
+ */
1109
+ previousAttributes() {
1110
+ return A(this._previousAttributes);
1111
+ }
1112
+ /**
1113
+ * Create a new model with identical attributes to this one.
1114
+ */
1115
+ clone() {
1116
+ const e = A(this.attributes);
1117
+ return new F(e);
1118
+ }
1119
+ }
1120
+ class b {
1121
+ /**
1122
+ * Private constructor to enforce singleton pattern.
1123
+ */
1124
+ constructor() {
1125
+ this.entries = /* @__PURE__ */ new Map();
1126
+ }
1127
+ /**
1128
+ * Retrieves the singleton instance of the AcCmPerformanceCollector.
1129
+ * @returns The shared AcCmPerformanceCollector instance.
1130
+ */
1131
+ static getInstance() {
1132
+ return b.instance || (b.instance = new b()), b.instance;
1133
+ }
1134
+ /**
1135
+ * Adds or replaces a performance entry by name.
1136
+ * @template T The type of the performance data.
1137
+ * @param entry A performance entry object with name, data, and format method.
1138
+ */
1139
+ collect(e) {
1140
+ this.entries.set(e.name, e);
1141
+ }
1142
+ /**
1143
+ * Logs all performance entries to the console using their format method.
1144
+ */
1145
+ printAll() {
1146
+ for (const [e, t] of this.entries)
1147
+ console.log(`${e}:`), console.log(t.format());
1148
+ }
1149
+ /**
1150
+ * Clears all collected performance entries.
1151
+ */
1152
+ clear() {
1153
+ this.entries.clear();
1154
+ }
1155
+ /**
1156
+ * Retrieves all entries as an array.
1157
+ * @returns A copy of all performance entries.
1158
+ */
1159
+ getAll() {
1160
+ return Array.from(this.entries.values());
1161
+ }
1162
+ /**
1163
+ * Gets a single entry by name.
1164
+ * @param name The unique name of the entry.
1165
+ * @returns The matching entry or undefined.
1166
+ */
1167
+ getEntry(e) {
1168
+ return this.entries.get(e);
1169
+ }
1170
+ /**
1171
+ * Removes an entry by name.
1172
+ * @param name The name of the entry to remove.
1173
+ * @returns True if the entry was removed; false if not found.
1174
+ */
1175
+ remove(e) {
1176
+ return this.entries.delete(e);
1177
+ }
1178
+ }
1179
+ class se {
1180
+ /**
1181
+ * Converts a byte count to a human-readable string using appropriate size units.
1182
+ *
1183
+ * Automatically selects the most appropriate unit (B, KB, MB, GB, TB) based on the size
1184
+ * and formats the result with the specified number of decimal places.
1185
+ *
1186
+ * @param {number} bytes - The number of bytes to format.
1187
+ * @param {number} [decimals=2] - Number of decimal places to include in the result.
1188
+ * @returns {string} A formatted string with the appropriate unit.
1189
+ *
1190
+ * @example
1191
+ * ```typescript
1192
+ * import { AcTrStringUtil } from './AcCmStringUtil'
1193
+ *
1194
+ * // Format different byte sizes
1195
+ * AcTrStringUtil.formatBytes(0) // "0 B"
1196
+ * AcTrStringUtil.formatBytes(1024) // "1 KB"
1197
+ * AcTrStringUtil.formatBytes(1024 * 1024) // "1 MB"
1198
+ * AcTrStringUtil.formatBytes(1536, 1) // "1.5 KB"
1199
+ * AcTrStringUtil.formatBytes(2048000, 0) // "2 MB"
1200
+ * ```
1201
+ */
1202
+ static formatBytes(e, t = 2) {
1203
+ if (e === 0) return "0 B";
1204
+ const r = 1024, o = Math.max(0, t), i = ["B", "KB", "MB", "GB", "TB"], l = Math.floor(Math.log(e) / Math.log(r)), g = e / Math.pow(r, l);
1205
+ return `${parseFloat(g.toFixed(o))} ${i[l]}`;
1206
+ }
1207
+ }
1208
+ class ie {
1209
+ /**
1210
+ * Creates a new task with the specified name.
1211
+ *
1212
+ * @param {string} name - The name identifier for this task.
1213
+ */
1214
+ constructor(e) {
1215
+ this.name = e;
1216
+ }
1217
+ /**
1218
+ * Executes the task with the given input.
1219
+ *
1220
+ * This method must be implemented by subclasses to define the actual work
1221
+ * performed by the task. Can return either a synchronous result or a Promise.
1222
+ *
1223
+ * @param {TIn} _input - The input data for the task.
1224
+ * @returns {TOut | Promise<TOut>} The task result, either synchronous or asynchronous.
1225
+ * @throws {Error} When the method is not implemented by a subclass.
1226
+ */
1227
+ run(e) {
1228
+ throw new Error("run() must be implemented by subclass");
1229
+ }
1230
+ }
1231
+ class le {
1232
+ constructor() {
1233
+ this.tasks = [], this.onProgress = () => {
1234
+ }, this.onComplete = () => {
1235
+ }, this.onError = () => !1;
1236
+ }
1237
+ /**
1238
+ * Schedules a task to be executed asynchronously.
1239
+ *
1240
+ * This method uses requestAnimationFrame in browser environments or setTimeout
1241
+ * in Node.js environments to schedule the task.
1242
+ *
1243
+ * @param callback - The callback function to schedule
1244
+ * @returns Promise that resolves with the result of the callback
1245
+ */
1246
+ scheduleTask(e) {
1247
+ return new Promise((t, r) => {
1248
+ const o = () => {
1249
+ Promise.resolve(e()).then(t).catch(r);
1250
+ };
1251
+ typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(o) : setTimeout(o, 0);
1252
+ });
1253
+ }
1254
+ /**
1255
+ * Adds a task to the execution queue.
1256
+ *
1257
+ * @param task Task instance with name and run function
1258
+ */
1259
+ addTask(e) {
1260
+ this.tasks.push(e);
1261
+ }
1262
+ /**
1263
+ * Sets a callback to receive progress updates.
1264
+ */
1265
+ setProgressCallback(e) {
1266
+ this.onProgress = e;
1267
+ }
1268
+ /**
1269
+ * Sets a callback to be called after successful completion of all tasks.
1270
+ */
1271
+ setCompleteCallback(e) {
1272
+ this.onComplete = e;
1273
+ }
1274
+ /**
1275
+ * Sets a callback to be called if any task throws an error.
1276
+ */
1277
+ setErrorCallback(e) {
1278
+ this.onError = e;
1279
+ }
1280
+ /**
1281
+ * Starts execution of the task queue with the given initial input.
1282
+ */
1283
+ async run(e) {
1284
+ const t = this.tasks.length;
1285
+ let r = e;
1286
+ for (let o = 0; o < t; o++) {
1287
+ const i = this.tasks[o];
1288
+ try {
1289
+ r = await this.scheduleTask(async () => {
1290
+ const l = await i.run(r);
1291
+ return this.onProgress((o + 1) / t, i), l;
1292
+ });
1293
+ } catch (l) {
1294
+ if (this.onError({ error: l, taskIndex: o, task: i }))
1295
+ break;
1296
+ }
1297
+ }
1298
+ this.onComplete(r);
1299
+ }
1300
+ }
1301
+ class Q {
1302
+ /**
1303
+ * Create a new AcCmLoadingManager instance
1304
+ * @param onLoad this function will be called when all loaders are done.
1305
+ * @param onProgress this function will be called when an item is complete.
1306
+ * @param onError this function will be called a loader encounters errors.
1307
+ */
1308
+ constructor(e, t, r) {
1309
+ this.isLoading = !1, this.itemsLoaded = 0, this.itemsTotal = 0, this.urlModifier = void 0, this.handlers = [], this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = r;
1310
+ }
1311
+ /**
1312
+ * This should be called by any loader using the manager when the loader starts loading an url.
1313
+ * @param url The loaded url
1314
+ */
1315
+ itemStart(e) {
1316
+ this.itemsTotal++, this.isLoading === !1 && this.onStart !== void 0 && this.onStart(e, this.itemsLoaded, this.itemsTotal), this.isLoading = !0;
1317
+ }
1318
+ /**
1319
+ * This should be called by any loader using the manager when the loader ended loading an url.
1320
+ * @param url The loaded url
1321
+ */
1322
+ itemEnd(e) {
1323
+ this.itemsLoaded++, this.onProgress !== void 0 && this.onProgress(e, this.itemsLoaded, this.itemsTotal), this.itemsLoaded === this.itemsTotal && (this.isLoading = !1, this.onLoad !== void 0 && this.onLoad());
1324
+ }
1325
+ /**
1326
+ * This should be called by any loader using the manager when the loader errors loading an url.
1327
+ * @param url The loaded url
1328
+ */
1329
+ itemError(e) {
1330
+ this.onError !== void 0 && this.onError(e);
1331
+ }
1332
+ /**
1333
+ * Given a URL, uses the URL modifier callback (if any) and returns a resolved URL. If no URL
1334
+ * modifier is set, returns the original URL.
1335
+ * @param url The url to load
1336
+ * @returns Return resolved URL
1337
+ */
1338
+ resolveURL(e) {
1339
+ return this.urlModifier ? this.urlModifier(e) : e;
1340
+ }
1341
+ /**
1342
+ * If provided, the callback will be passed each resource URL before a request is sent. The callback
1343
+ * may return the original URL, or a new URL to override loading behavior. This behavior can be used
1344
+ * to load assets from .ZIP files, drag-and-drop APIs, and Data URIs.
1345
+ * @param transform URL modifier callback. Called with url argument, and must return resolvedURL.
1346
+ * @returns Return this object
1347
+ */
1348
+ setURLModifier(e) {
1349
+ return this.urlModifier = e, this;
1350
+ }
1351
+ /**
1352
+ * Register a loader with the given regular expression. Can be used to define what loader should
1353
+ * be used in order to load specific files. A typical use case is to overwrite the default loader
1354
+ * for textures.
1355
+ * @param regex A regular expression.
1356
+ * @param loader The loader.
1357
+ * @returns Return this object
1358
+ */
1359
+ addHandler(e, t) {
1360
+ return this.handlers.push(e, t), this;
1361
+ }
1362
+ /**
1363
+ * Remove the loader for the given regular expression.
1364
+ * @param regex A regular expression.
1365
+ * @returns Return this object
1366
+ */
1367
+ removeHandler(e) {
1368
+ const t = this.handlers.indexOf(e);
1369
+ return t !== -1 && this.handlers.splice(t, 2), this;
1370
+ }
1371
+ /**
1372
+ * Retrieve the registered loader for the given file path.
1373
+ * @param file The file path.
1374
+ * @returns Return the registered loader for the given file path.
1375
+ */
1376
+ getHandler(e) {
1377
+ for (let t = 0, r = this.handlers.length; t < r; t += 2) {
1378
+ const o = this.handlers[t], i = this.handlers[t + 1];
1379
+ if (o.global && (o.lastIndex = 0), o.test(e))
1380
+ return i;
1381
+ }
1382
+ return null;
1383
+ }
1384
+ }
1385
+ const ee = /* @__PURE__ */ new Q();
1386
+ class ae {
1387
+ /**
1388
+ * Creates a new AcCmLoader instance.
1389
+ * @param manager The loadingManager for the loader to use. Default is DefaultLoadingManager.
1390
+ */
1391
+ constructor(e) {
1392
+ this.manager = e !== void 0 ? e : ee, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {};
1393
+ }
1394
+ /**
1395
+ * This method is equivalent to 'load', but returns a Promise.
1396
+ * @param url A string containing the path/URL of the file to be loaded.
1397
+ * @param onProgress (optional) — A function to be called while the loading is in progress.
1398
+ * The argument will be the ProgressEvent instance, which contains .lengthComputable, .total
1399
+ * and .loaded. If the server does not set the Content-Length header; .total will be 0.
1400
+ * @returns Return a promise.
1401
+ */
1402
+ loadAsync(e, t) {
1403
+ return new Promise((r, o) => {
1404
+ this.load(e, r, t, o);
1405
+ });
1406
+ }
1407
+ /**
1408
+ * This method needs to be implement by all concrete loaders. It holds the logic for parsing the asset.
1409
+ */
1410
+ parse(e) {
1411
+ }
1412
+ /**
1413
+ * Set the crossOrigin string to implement CORS for loading the url from a different domain that allows
1414
+ * CORS.
1415
+ * @param crossOrigin The crossOrigin string
1416
+ * @returns Return this object
1417
+ */
1418
+ setCrossOrigin(e) {
1419
+ return this.crossOrigin = e, this;
1420
+ }
1421
+ /**
1422
+ * Set whether the XMLHttpRequest uses credentials such as cookies, authorization headers or TLS
1423
+ * client certificates.
1424
+ * Note that this has no effect if you are loading files locally or from the same domain.
1425
+ * @param value The flag whether the XMLHttpRequest uses credentials.
1426
+ * @returns Return this object
1427
+ */
1428
+ setWithCredentials(e) {
1429
+ return this.withCredentials = e, this;
1430
+ }
1431
+ /**
1432
+ * Set the base path for the asset.
1433
+ * @param path The base path for the asset.
1434
+ * @returns Return this object
1435
+ */
1436
+ setPath(e) {
1437
+ return this.path = e, this;
1438
+ }
1439
+ /**
1440
+ * Set the base path for dependent resources like textures.
1441
+ * @param resourcePath The base path for dependent resources like textures.
1442
+ * @returns Return this object
1443
+ */
1444
+ setResourcePath(e) {
1445
+ return this.resourcePath = e, this;
1446
+ }
1447
+ /**
1448
+ * Set the request header used in HTTP request.
1449
+ * @param requestHeader key: The name of the header whose value is to be set. value: The value
1450
+ * to set as the body of the header.
1451
+ * @returns Return this object
1452
+ */
1453
+ setRequestHeader(e) {
1454
+ return this.requestHeader = e, this;
1455
+ }
1456
+ }
1457
+ export {
1458
+ R as AcCmColor,
1459
+ te as AcCmErrors,
1460
+ re as AcCmEventDispatcher,
1461
+ U as AcCmEventManager,
1462
+ ae as AcCmLoader,
1463
+ Q as AcCmLoadingManager,
1464
+ F as AcCmObject,
1465
+ b as AcCmPerformanceCollector,
1466
+ ie as AcCmTask,
1467
+ le as AcCmTaskScheduler,
1468
+ se as AcTrStringUtil,
1469
+ ne as DEBUG_MODE,
1470
+ ee as DefaultLoadingManager,
1471
+ A as clone,
1472
+ Z as defaults,
1473
+ J as has,
1474
+ X as isEmpty,
1475
+ _ as isEqual,
1476
+ x as log,
1477
+ oe as setLogLevel
1478
+ };