@vived/component-abb-controller 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/COMPONENT_KNOWLEDGE.md +198 -0
  3. package/LICENSE +15 -0
  4. package/dist/AbbControllerEvents.d.ts +42 -0
  5. package/dist/AbbControllerEvents.d.ts.map +1 -0
  6. package/dist/AbbControllerFacade.d.ts +80 -0
  7. package/dist/AbbControllerFacade.d.ts.map +1 -0
  8. package/dist/AbbControllerState.d.ts +28 -0
  9. package/dist/AbbControllerState.d.ts.map +1 -0
  10. package/dist/Domain/Adapters/abbControllerPMAdapter.d.ts +10 -0
  11. package/dist/Domain/Adapters/abbControllerPMAdapter.d.ts.map +1 -0
  12. package/dist/Domain/Controllers/abbControllerHitboxClicked.d.ts +8 -0
  13. package/dist/Domain/Controllers/abbControllerHitboxClicked.d.ts.map +1 -0
  14. package/dist/Domain/Controllers/abbControllerStateDefaults.d.ts +11 -0
  15. package/dist/Domain/Controllers/abbControllerStateDefaults.d.ts.map +1 -0
  16. package/dist/Domain/Controllers/applyAbbControllerState.d.ts +24 -0
  17. package/dist/Domain/Controllers/applyAbbControllerState.d.ts.map +1 -0
  18. package/dist/Domain/Controllers/checkVoltage.d.ts +7 -0
  19. package/dist/Domain/Controllers/checkVoltage.d.ts.map +1 -0
  20. package/dist/Domain/Controllers/createAbbController.d.ts +12 -0
  21. package/dist/Domain/Controllers/createAbbController.d.ts.map +1 -0
  22. package/dist/Domain/Controllers/disableHitbox.d.ts +7 -0
  23. package/dist/Domain/Controllers/disableHitbox.d.ts.map +1 -0
  24. package/dist/Domain/Controllers/enableHitbox.d.ts +6 -0
  25. package/dist/Domain/Controllers/enableHitbox.d.ts.map +1 -0
  26. package/dist/Domain/Controllers/getAbbControllerState.d.ts +7 -0
  27. package/dist/Domain/Controllers/getAbbControllerState.d.ts.map +1 -0
  28. package/dist/Domain/Controllers/onAbbControllerSelected.d.ts +7 -0
  29. package/dist/Domain/Controllers/onAbbControllerSelected.d.ts.map +1 -0
  30. package/dist/Domain/Controllers/onLockoutBlockedByPower.d.ts +7 -0
  31. package/dist/Domain/Controllers/onLockoutBlockedByPower.d.ts.map +1 -0
  32. package/dist/Domain/Controllers/onLockoutDisengaged.d.ts +7 -0
  33. package/dist/Domain/Controllers/onLockoutDisengaged.d.ts.map +1 -0
  34. package/dist/Domain/Controllers/onLockoutEngaged.d.ts +7 -0
  35. package/dist/Domain/Controllers/onLockoutEngaged.d.ts.map +1 -0
  36. package/dist/Domain/Controllers/onPowerOnBlockedByLockout.d.ts +7 -0
  37. package/dist/Domain/Controllers/onPowerOnBlockedByLockout.d.ts.map +1 -0
  38. package/dist/Domain/Controllers/onPoweredOff.d.ts +11 -0
  39. package/dist/Domain/Controllers/onPoweredOff.d.ts.map +1 -0
  40. package/dist/Domain/Controllers/onPoweredOn.d.ts +11 -0
  41. package/dist/Domain/Controllers/onPoweredOn.d.ts.map +1 -0
  42. package/dist/Domain/Controllers/onVoltageChecked.d.ts +7 -0
  43. package/dist/Domain/Controllers/onVoltageChecked.d.ts.map +1 -0
  44. package/dist/Domain/Controllers/setShowGhostLockHint.d.ts +12 -0
  45. package/dist/Domain/Controllers/setShowGhostLockHint.d.ts.map +1 -0
  46. package/dist/Domain/Controllers/tryLockOut.d.ts +10 -0
  47. package/dist/Domain/Controllers/tryLockOut.d.ts.map +1 -0
  48. package/dist/Domain/Controllers/tryPowerOff.d.ts +8 -0
  49. package/dist/Domain/Controllers/tryPowerOff.d.ts.map +1 -0
  50. package/dist/Domain/Controllers/tryPowerOn.d.ts +10 -0
  51. package/dist/Domain/Controllers/tryPowerOn.d.ts.map +1 -0
  52. package/dist/Domain/Controllers/tryToggleLockout.d.ts +10 -0
  53. package/dist/Domain/Controllers/tryToggleLockout.d.ts.map +1 -0
  54. package/dist/Domain/Controllers/tryTogglePower.d.ts +10 -0
  55. package/dist/Domain/Controllers/tryTogglePower.d.ts.map +1 -0
  56. package/dist/Domain/Controllers/tryUnlock.d.ts +8 -0
  57. package/dist/Domain/Controllers/tryUnlock.d.ts.map +1 -0
  58. package/dist/Domain/Entities/AbbControllerEntity.d.ts +55 -0
  59. package/dist/Domain/Entities/AbbControllerEntity.d.ts.map +1 -0
  60. package/dist/Domain/Entities/AbbControllerRepo.d.ts +28 -0
  61. package/dist/Domain/Entities/AbbControllerRepo.d.ts.map +1 -0
  62. package/dist/Domain/Factory/AbbControllerFeatureFactory.d.ts +26 -0
  63. package/dist/Domain/Factory/AbbControllerFeatureFactory.d.ts.map +1 -0
  64. package/dist/Domain/Factory/setupAbbControllerInstanceFactory.d.ts +11 -0
  65. package/dist/Domain/Factory/setupAbbControllerInstanceFactory.d.ts.map +1 -0
  66. package/dist/Domain/Mocks/MockAbbControllerCheckVoltageUC.d.ts +12 -0
  67. package/dist/Domain/Mocks/MockAbbControllerCheckVoltageUC.d.ts.map +1 -0
  68. package/dist/Domain/Mocks/MockAbbControllerLockoutUC.d.ts +16 -0
  69. package/dist/Domain/Mocks/MockAbbControllerLockoutUC.d.ts.map +1 -0
  70. package/dist/Domain/Mocks/MockAbbControllerPM.d.ts +11 -0
  71. package/dist/Domain/Mocks/MockAbbControllerPM.d.ts.map +1 -0
  72. package/dist/Domain/Mocks/MockAbbControllerPowerUC.d.ts +16 -0
  73. package/dist/Domain/Mocks/MockAbbControllerPowerUC.d.ts.map +1 -0
  74. package/dist/Domain/Mocks/MockAbbControllerSelectUC.d.ts +13 -0
  75. package/dist/Domain/Mocks/MockAbbControllerSelectUC.d.ts.map +1 -0
  76. package/dist/Domain/PMs/AbbControllerPM.d.ts +34 -0
  77. package/dist/Domain/PMs/AbbControllerPM.d.ts.map +1 -0
  78. package/dist/Domain/UCs/AbbControllerCheckVoltageUC.d.ts +24 -0
  79. package/dist/Domain/UCs/AbbControllerCheckVoltageUC.d.ts.map +1 -0
  80. package/dist/Domain/UCs/AbbControllerLockoutUC.d.ts +35 -0
  81. package/dist/Domain/UCs/AbbControllerLockoutUC.d.ts.map +1 -0
  82. package/dist/Domain/UCs/AbbControllerPowerUC.d.ts +31 -0
  83. package/dist/Domain/UCs/AbbControllerPowerUC.d.ts.map +1 -0
  84. package/dist/Domain/UCs/AbbControllerSelectUC.d.ts +32 -0
  85. package/dist/Domain/UCs/AbbControllerSelectUC.d.ts.map +1 -0
  86. package/dist/Domain/makeDomainForTesting.d.ts +18 -0
  87. package/dist/Domain/makeDomainForTesting.d.ts.map +1 -0
  88. package/dist/Frameworks/Babylon/AbbControllerAssetCache.d.ts +5 -0
  89. package/dist/Frameworks/Babylon/AbbControllerAssetCache.d.ts.map +1 -0
  90. package/dist/Frameworks/Babylon/AbbControllerBabylonView.d.ts +30 -0
  91. package/dist/Frameworks/Babylon/AbbControllerBabylonView.d.ts.map +1 -0
  92. package/dist/Frameworks/Babylon/CutoffKnobView.d.ts +28 -0
  93. package/dist/Frameworks/Babylon/CutoffKnobView.d.ts.map +1 -0
  94. package/dist/Frameworks/Babylon/HitboxView.d.ts +23 -0
  95. package/dist/Frameworks/Babylon/HitboxView.d.ts.map +1 -0
  96. package/dist/Frameworks/Babylon/LockView.d.ts +27 -0
  97. package/dist/Frameworks/Babylon/LockView.d.ts.map +1 -0
  98. package/dist/Frameworks/Babylon/SmartComponentView.d.ts +28 -0
  99. package/dist/Frameworks/Babylon/SmartComponentView.d.ts.map +1 -0
  100. package/dist/Frameworks/Babylon/createBabylonAbbController.d.ts +13 -0
  101. package/dist/Frameworks/Babylon/createBabylonAbbController.d.ts.map +1 -0
  102. package/dist/SmartComponent.d.ts +42 -0
  103. package/dist/SmartComponent.d.ts.map +1 -0
  104. package/dist/component.config.d.ts +18 -0
  105. package/dist/component.config.d.ts.map +1 -0
  106. package/dist/index.d.ts +55 -0
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +1313 -0
  109. package/package.json +53 -0
package/dist/index.js ADDED
@@ -0,0 +1,1313 @@
1
+ import { AppObjectEntity as H, MemoizedBoolean as C, MemoizedNumber as j, AppObjectEntityRepo as N, getSingletonComponent as G, generateUniqueID as _, AppObjectUC as w, AppObjectPM as W, DomainFactory as T, AppObjectView as O } from "@vived/core";
2
+ import { getAssetBlobURL as F, BabylonEntity as z } from "@vived/app";
3
+ import { LoadAssetContainerAsync as D, Quaternion as x, ActionManager as a, ExecuteCodeAction as y, Material as R } from "@babylonjs/core";
4
+ class r extends H {
5
+ static type = "AbbControllerEntity";
6
+ /**
7
+ * Retrieves the entity from an AppObject
8
+ */
9
+ static get(t) {
10
+ return t.getComponent(this.type);
11
+ }
12
+ /**
13
+ * Retrieves the entity by AppObject ID
14
+ */
15
+ static getById(t, e) {
16
+ return e.get(t)?.getComponent(this.type);
17
+ }
18
+ }
19
+ function v(o) {
20
+ return new K(o);
21
+ }
22
+ class K extends r {
23
+ memoizedIsPoweredOn = new C(!1, this.notifyOnChange);
24
+ memoizedIsLockedOut = new C(!1, this.notifyOnChange);
25
+ memoizedPowerOnVoltage = new j(480, this.notifyOnChange);
26
+ memoizedIsHitboxEnabled = new C(
27
+ !1,
28
+ this.notifyOnChange
29
+ );
30
+ memoizedIsShowingGhostLockHint = new C(
31
+ !1,
32
+ this.notifyOnChange
33
+ );
34
+ get isPoweredOn() {
35
+ return this.memoizedIsPoweredOn.val;
36
+ }
37
+ get isLockedOut() {
38
+ return this.memoizedIsLockedOut.val;
39
+ }
40
+ get powerOnVoltage() {
41
+ return this.memoizedPowerOnVoltage.val;
42
+ }
43
+ set powerOnVoltage(t) {
44
+ this.memoizedPowerOnVoltage.val = t;
45
+ }
46
+ get isHitboxEnabled() {
47
+ return this.memoizedIsHitboxEnabled.val;
48
+ }
49
+ set isHitboxEnabled(t) {
50
+ this.memoizedIsHitboxEnabled.val = t;
51
+ }
52
+ get isShowingGhostLockHint() {
53
+ return this.memoizedIsShowingGhostLockHint.val;
54
+ }
55
+ set isShowingGhostLockHint(t) {
56
+ this.memoizedIsShowingGhostLockHint.val = t;
57
+ }
58
+ tryPowerOn() {
59
+ return this.memoizedIsLockedOut.val ? !1 : (this.memoizedIsPoweredOn.val = !0, !0);
60
+ }
61
+ tryPowerOff() {
62
+ return this.memoizedIsPoweredOn.val = !1, !0;
63
+ }
64
+ tryLockOut() {
65
+ return this.memoizedIsPoweredOn.val ? !1 : (this.memoizedIsLockedOut.val = !0, !0);
66
+ }
67
+ tryUnlock() {
68
+ return this.memoizedIsLockedOut.val = !1, !0;
69
+ }
70
+ constructor(t) {
71
+ super(t, r.type);
72
+ }
73
+ }
74
+ class u extends N {
75
+ static type = "AbbControllerRepo";
76
+ /**
77
+ * Global accessor for the singleton repository
78
+ */
79
+ static get(t) {
80
+ return G(
81
+ u.type,
82
+ t
83
+ );
84
+ }
85
+ }
86
+ function Q(o) {
87
+ return new $(o);
88
+ }
89
+ class $ extends u {
90
+ abbControllerEntityFactory = (t) => {
91
+ const e = this.appObjects.getOrCreate(t);
92
+ return v(e);
93
+ };
94
+ createAbbControllerEntity(t) {
95
+ const e = t ?? _(), n = this.getForAppObject(e);
96
+ if (n)
97
+ return n;
98
+ const i = this.abbControllerEntityFactory(e);
99
+ return this.add(i), i;
100
+ }
101
+ deleteAbbControllerEntity(t) {
102
+ const e = this.getForAppObject(t);
103
+ if (!e) {
104
+ this.warn(`Cannot delete: entity with id '${t}' not found`);
105
+ return;
106
+ }
107
+ e.appObject.dispose(), this.removeForAppObject(t);
108
+ }
109
+ constructor(t) {
110
+ super(t, u.type);
111
+ }
112
+ }
113
+ function q(o, t) {
114
+ const e = u.get(t);
115
+ if (!e) {
116
+ t.submitWarning(
117
+ "createAbbController",
118
+ "Unable to find AbbControllerRepo"
119
+ );
120
+ return;
121
+ }
122
+ return e.createAbbControllerEntity(o).appObject;
123
+ }
124
+ class c extends w {
125
+ static type = "AbbControllerPowerUC";
126
+ static get(t) {
127
+ return t.getComponent(this.type);
128
+ }
129
+ static getById(t, e) {
130
+ return e.get(t)?.getComponent(this.type);
131
+ }
132
+ }
133
+ function Y(o) {
134
+ return new J(o);
135
+ }
136
+ class J extends c {
137
+ onPoweredOnCallbacks = /* @__PURE__ */ new Set();
138
+ onPoweredOffCallbacks = /* @__PURE__ */ new Set();
139
+ onPowerOnBlockedByLockoutCallbacks = /* @__PURE__ */ new Set();
140
+ get entity() {
141
+ try {
142
+ return this.getCachedLocalComponent(
143
+ r.type
144
+ );
145
+ } catch {
146
+ return;
147
+ }
148
+ }
149
+ powerOn = () => {
150
+ const t = this.entity;
151
+ if (!t)
152
+ return this.warn("Missing AbbControllerEntity"), !1;
153
+ const e = t.tryPowerOn();
154
+ return e ? this.notifyCallbacks(this.onPoweredOnCallbacks, "onPoweredOn callback") : this.notifyCallbacks(
155
+ this.onPowerOnBlockedByLockoutCallbacks,
156
+ "onPowerOnBlockedByLockout callback"
157
+ ), e;
158
+ };
159
+ powerOff = () => {
160
+ const t = this.entity;
161
+ if (!t)
162
+ return this.warn("Missing AbbControllerEntity"), !1;
163
+ const e = t.tryPowerOff();
164
+ return e && this.notifyCallbacks(
165
+ this.onPoweredOffCallbacks,
166
+ "onPoweredOff callback"
167
+ ), e;
168
+ };
169
+ togglePower = () => {
170
+ const t = this.entity;
171
+ return t ? t.isPoweredOn ? this.powerOff() : this.powerOn() : (this.warn("Missing AbbControllerEntity"), !1);
172
+ };
173
+ subscribeOnPoweredOn(t) {
174
+ return this.onPoweredOnCallbacks.add(t), () => {
175
+ this.onPoweredOnCallbacks.delete(t);
176
+ };
177
+ }
178
+ subscribeOnPoweredOff(t) {
179
+ return this.onPoweredOffCallbacks.add(t), () => {
180
+ this.onPoweredOffCallbacks.delete(t);
181
+ };
182
+ }
183
+ subscribeOnPowerOnBlockedByLockout(t) {
184
+ return this.onPowerOnBlockedByLockoutCallbacks.add(t), () => {
185
+ this.onPowerOnBlockedByLockoutCallbacks.delete(t);
186
+ };
187
+ }
188
+ notifyCallbacks(t, e) {
189
+ for (const n of t)
190
+ try {
191
+ n();
192
+ } catch {
193
+ this.warn(`${e} threw an error`);
194
+ }
195
+ }
196
+ constructor(t) {
197
+ super(t, c.type);
198
+ }
199
+ }
200
+ function U(o, t) {
201
+ const e = c.getById(o, t);
202
+ return e ? e.togglePower() : (t.submitWarning(
203
+ "tryTogglePower",
204
+ "Unable to find AbbControllerPowerUC"
205
+ ), !1);
206
+ }
207
+ function X(o, t) {
208
+ const e = c.getById(o, t);
209
+ return e ? e.powerOn() : (t.submitWarning(
210
+ "tryPowerOn",
211
+ "Unable to find AbbControllerPowerUC"
212
+ ), !1);
213
+ }
214
+ function Z(o, t) {
215
+ const e = c.getById(o, t);
216
+ return e ? e.powerOff() : (t.submitWarning(
217
+ "tryPowerOff",
218
+ "Unable to find AbbControllerPowerUC"
219
+ ), !1);
220
+ }
221
+ class l extends w {
222
+ static type = "AbbControllerLockoutUC";
223
+ static get(t) {
224
+ return t.getComponent(this.type);
225
+ }
226
+ static getById(t, e) {
227
+ return e.get(t)?.getComponent(this.type);
228
+ }
229
+ }
230
+ function tt(o) {
231
+ return new et(o);
232
+ }
233
+ class et extends l {
234
+ onLockoutEngagedCallbacks = /* @__PURE__ */ new Set();
235
+ onLockoutDisengagedCallbacks = /* @__PURE__ */ new Set();
236
+ onLockoutBlockedByPowerCallbacks = /* @__PURE__ */ new Set();
237
+ get entity() {
238
+ try {
239
+ return this.getCachedLocalComponent(
240
+ r.type
241
+ );
242
+ } catch {
243
+ return;
244
+ }
245
+ }
246
+ lockOut = () => {
247
+ const t = this.entity;
248
+ if (!t)
249
+ return this.warn("Missing AbbControllerEntity"), !1;
250
+ const e = t.tryLockOut();
251
+ return e ? this.notifyCallbacks(
252
+ this.onLockoutEngagedCallbacks,
253
+ "onLockoutEngaged callback"
254
+ ) : this.notifyCallbacks(
255
+ this.onLockoutBlockedByPowerCallbacks,
256
+ "onLockoutBlockedByPower callback"
257
+ ), e;
258
+ };
259
+ unlock = () => {
260
+ const t = this.entity;
261
+ if (!t)
262
+ return this.warn("Missing AbbControllerEntity"), !1;
263
+ const e = t.tryUnlock();
264
+ return e && this.notifyCallbacks(
265
+ this.onLockoutDisengagedCallbacks,
266
+ "onLockoutDisengaged callback"
267
+ ), e;
268
+ };
269
+ toggleLockout = () => {
270
+ const t = this.entity;
271
+ return t ? t.isLockedOut ? this.unlock() : this.lockOut() : (this.warn("Missing AbbControllerEntity"), !1);
272
+ };
273
+ subscribeOnLockoutEngaged(t) {
274
+ return this.onLockoutEngagedCallbacks.add(t), () => {
275
+ this.onLockoutEngagedCallbacks.delete(t);
276
+ };
277
+ }
278
+ subscribeOnLockoutDisengaged(t) {
279
+ return this.onLockoutDisengagedCallbacks.add(t), () => {
280
+ this.onLockoutDisengagedCallbacks.delete(t);
281
+ };
282
+ }
283
+ subscribeOnLockoutBlockedByPower(t) {
284
+ return this.onLockoutBlockedByPowerCallbacks.add(t), () => {
285
+ this.onLockoutBlockedByPowerCallbacks.delete(t);
286
+ };
287
+ }
288
+ notifyCallbacks(t, e) {
289
+ for (const n of t)
290
+ try {
291
+ n();
292
+ } catch {
293
+ this.warn(`${e} threw an error`);
294
+ }
295
+ }
296
+ constructor(t) {
297
+ super(t, l.type);
298
+ }
299
+ }
300
+ function V(o, t) {
301
+ const e = l.getById(o, t);
302
+ return e ? e.toggleLockout() : (t.submitWarning(
303
+ "tryToggleLockout",
304
+ "Unable to find AbbControllerLockoutUC"
305
+ ), !1);
306
+ }
307
+ function ot(o, t) {
308
+ const e = l.getById(o, t);
309
+ return e ? e.lockOut() : (t.submitWarning(
310
+ "tryLockOut",
311
+ "Unable to find AbbControllerLockoutUC"
312
+ ), !1);
313
+ }
314
+ function nt(o, t) {
315
+ const e = l.getById(o, t);
316
+ return e ? e.unlock() : (t.submitWarning(
317
+ "tryUnlock",
318
+ "Unable to find AbbControllerLockoutUC"
319
+ ), !1);
320
+ }
321
+ class d extends w {
322
+ static type = "AbbControllerCheckVoltageUC";
323
+ static get(t) {
324
+ return t.getComponent(this.type);
325
+ }
326
+ static getById(t, e) {
327
+ return e.get(t)?.getComponent(this.type);
328
+ }
329
+ }
330
+ function it(o) {
331
+ return new st(o);
332
+ }
333
+ class st extends d {
334
+ onVoltageCheckedCallbacks = /* @__PURE__ */ new Set();
335
+ get entity() {
336
+ try {
337
+ return this.getCachedLocalComponent(
338
+ r.type
339
+ );
340
+ } catch {
341
+ return;
342
+ }
343
+ }
344
+ execute = () => {
345
+ if (!this.entity) {
346
+ this.warn("Missing AbbControllerEntity");
347
+ return;
348
+ }
349
+ this.notifyCallbacks(
350
+ this.onVoltageCheckedCallbacks,
351
+ "onVoltageChecked callback"
352
+ );
353
+ };
354
+ subscribeOnVoltageChecked(t) {
355
+ return this.onVoltageCheckedCallbacks.add(t), () => {
356
+ this.onVoltageCheckedCallbacks.delete(t);
357
+ };
358
+ }
359
+ notifyCallbacks(t, e) {
360
+ for (const n of t)
361
+ try {
362
+ n();
363
+ } catch {
364
+ this.warn(`${e} threw an error`);
365
+ }
366
+ }
367
+ constructor(t) {
368
+ super(t, d.type);
369
+ }
370
+ }
371
+ function rt(o, t) {
372
+ const e = d.getById(o, t);
373
+ if (!e) {
374
+ t.submitWarning(
375
+ "checkVoltage",
376
+ "Unable to find AbbControllerCheckVoltageUC"
377
+ );
378
+ return;
379
+ }
380
+ e.execute();
381
+ }
382
+ function ct(o, t, e) {
383
+ const n = r.getById(o, t);
384
+ if (!n) {
385
+ t.submitWarning(
386
+ "setShowGhostLockHint",
387
+ "Unable to find AbbControllerEntity"
388
+ );
389
+ return;
390
+ }
391
+ n.isShowingGhostLockHint = e;
392
+ }
393
+ class h extends w {
394
+ static type = "AbbControllerSelectUC";
395
+ static get(t) {
396
+ return t.getComponent(this.type);
397
+ }
398
+ static getById(t, e) {
399
+ return e.get(t)?.getComponent(this.type);
400
+ }
401
+ }
402
+ function lt(o) {
403
+ return new at(o);
404
+ }
405
+ class at extends h {
406
+ onSelectedCallbacks = /* @__PURE__ */ new Set();
407
+ get entity() {
408
+ try {
409
+ return this.getCachedLocalComponent(
410
+ r.type
411
+ );
412
+ } catch {
413
+ return;
414
+ }
415
+ }
416
+ enableHitbox() {
417
+ const t = this.entity;
418
+ if (!t) {
419
+ this.warn("Missing AbbControllerEntity");
420
+ return;
421
+ }
422
+ t.isHitboxEnabled = !0;
423
+ }
424
+ disableHitbox() {
425
+ const t = this.entity;
426
+ if (!t) {
427
+ this.warn("Missing AbbControllerEntity");
428
+ return;
429
+ }
430
+ t.isHitboxEnabled = !1;
431
+ }
432
+ subscribeOnSelected(t) {
433
+ return this.onSelectedCallbacks.add(t), () => {
434
+ this.onSelectedCallbacks.delete(t);
435
+ };
436
+ }
437
+ notifySelected() {
438
+ for (const t of this.onSelectedCallbacks)
439
+ try {
440
+ t();
441
+ } catch {
442
+ this.warn("onSelected callback threw an error");
443
+ }
444
+ }
445
+ constructor(t) {
446
+ super(t, h.type);
447
+ }
448
+ }
449
+ function bt(o, t) {
450
+ const e = h.getById(o, t);
451
+ if (!e) {
452
+ t.submitWarning(
453
+ "enableHitbox",
454
+ "Unable to find AbbControllerSelectUC"
455
+ );
456
+ return;
457
+ }
458
+ e.enableHitbox();
459
+ }
460
+ function ht(o, t) {
461
+ const e = h.getById(o, t);
462
+ if (!e) {
463
+ t.submitWarning(
464
+ "disableHitbox",
465
+ "Unable to find AbbControllerSelectUC"
466
+ );
467
+ return;
468
+ }
469
+ e.disableHitbox();
470
+ }
471
+ function ut(o, t, e) {
472
+ const n = c.getById(o, t);
473
+ return n ? n.subscribeOnPoweredOn(e) : (t.submitWarning(
474
+ "onPoweredOn",
475
+ "Unable to find AbbControllerPowerUC"
476
+ ), () => {
477
+ });
478
+ }
479
+ function dt(o, t, e) {
480
+ const n = c.getById(o, t);
481
+ return n ? n.subscribeOnPoweredOff(e) : (t.submitWarning(
482
+ "onPoweredOff",
483
+ "Unable to find AbbControllerPowerUC"
484
+ ), () => {
485
+ });
486
+ }
487
+ function gt(o, t, e) {
488
+ const n = c.getById(o, t);
489
+ return n ? n.subscribeOnPowerOnBlockedByLockout(e) : (t.submitWarning(
490
+ "onPowerOnBlockedByLockout",
491
+ "Unable to find AbbControllerPowerUC"
492
+ ), () => {
493
+ });
494
+ }
495
+ function ft(o, t, e) {
496
+ const n = l.getById(o, t);
497
+ return n ? n.subscribeOnLockoutEngaged(e) : (t.submitWarning(
498
+ "onLockoutEngaged",
499
+ "Unable to find AbbControllerLockoutUC"
500
+ ), () => {
501
+ });
502
+ }
503
+ function kt(o, t, e) {
504
+ const n = l.getById(o, t);
505
+ return n ? n.subscribeOnLockoutDisengaged(e) : (t.submitWarning(
506
+ "onLockoutDisengaged",
507
+ "Unable to find AbbControllerLockoutUC"
508
+ ), () => {
509
+ });
510
+ }
511
+ function yt(o, t, e) {
512
+ const n = l.getById(o, t);
513
+ return n ? n.subscribeOnLockoutBlockedByPower(e) : (t.submitWarning(
514
+ "onLockoutBlockedByPower",
515
+ "Unable to find AbbControllerLockoutUC"
516
+ ), () => {
517
+ });
518
+ }
519
+ function pt(o, t, e) {
520
+ const n = d.getById(o, t);
521
+ return n ? n.subscribeOnVoltageChecked(e) : (t.submitWarning(
522
+ "onVoltageChecked",
523
+ "Unable to find AbbControllerCheckVoltageUC"
524
+ ), () => {
525
+ });
526
+ }
527
+ function Ct(o, t, e) {
528
+ const n = h.getById(o, t);
529
+ return n ? n.subscribeOnSelected(e) : (t.submitWarning(
530
+ "onAbbControllerSelected",
531
+ "Unable to find AbbControllerSelectUC"
532
+ ), () => {
533
+ });
534
+ }
535
+ const k = {
536
+ isPoweredOn: !1,
537
+ isLockedOut: !1,
538
+ isShowingGhostLockHint: !1,
539
+ isHitboxEnabled: !1
540
+ };
541
+ function wt(o, t, e) {
542
+ const n = r.getById(o, t);
543
+ return n ? {
544
+ version: e,
545
+ isPoweredOn: n.isPoweredOn,
546
+ isLockedOut: n.isLockedOut,
547
+ isShowingGhostLockHint: n.isShowingGhostLockHint,
548
+ isHitboxEnabled: n.isHitboxEnabled
549
+ } : (t.submitWarning(
550
+ "getAbbControllerState",
551
+ "Unable to find AbbControllerEntity"
552
+ ), {
553
+ version: e,
554
+ ...k
555
+ });
556
+ }
557
+ function Ot(o, t, e) {
558
+ const n = r.getById(o, t);
559
+ if (!n) {
560
+ t.submitWarning(
561
+ "applyAbbControllerState",
562
+ "Unable to find AbbControllerEntity"
563
+ );
564
+ return;
565
+ }
566
+ const i = e.isPoweredOn ?? k.isPoweredOn, s = e.isLockedOut ?? k.isLockedOut;
567
+ i && s ? t.submitWarning(
568
+ "applyAbbControllerState",
569
+ "Rejected invalid state: powered on and locked out cannot both be true"
570
+ ) : i ? (n.tryUnlock(), n.tryPowerOn()) : s ? (n.tryPowerOff(), n.tryLockOut()) : (n.tryPowerOff(), n.tryUnlock()), n.isShowingGhostLockHint = e.isShowingGhostLockHint ?? k.isShowingGhostLockHint, n.isHitboxEnabled = e.isHitboxEnabled ?? k.isHitboxEnabled;
571
+ }
572
+ class g extends W {
573
+ static type = "AbbControllerPM";
574
+ static get(t) {
575
+ return t.getComponent(this.type);
576
+ }
577
+ static getById(t, e) {
578
+ return e.get(t)?.getComponent(this.type);
579
+ }
580
+ }
581
+ function mt(o) {
582
+ return new At(o);
583
+ }
584
+ class At extends g {
585
+ get entity() {
586
+ try {
587
+ return this.getCachedLocalComponent(
588
+ r.type
589
+ );
590
+ } catch {
591
+ return;
592
+ }
593
+ }
594
+ vmsAreEqual(t, e) {
595
+ return t.isPoweredOn === e.isPoweredOn && t.isLockedOut === e.isLockedOut && t.canPowerOn === e.canPowerOn && t.canLockOut === e.canLockOut && t.voltage === e.voltage;
596
+ }
597
+ onEntityChange = () => {
598
+ const t = this.entity;
599
+ if (!t) return;
600
+ const e = t.isPoweredOn, n = t.isLockedOut;
601
+ this.doUpdateView({
602
+ isPoweredOn: e,
603
+ isLockedOut: n,
604
+ canPowerOn: !n,
605
+ canLockOut: !e,
606
+ voltage: e ? t.powerOnVoltage : 0
607
+ });
608
+ };
609
+ dispose = () => {
610
+ super.dispose(), this.entity?.removeChangeObserver(this.onEntityChange);
611
+ };
612
+ constructor(t) {
613
+ super(t, g.type), this.entity?.addChangeObserver(this.onEntityChange), this.onEntityChange();
614
+ }
615
+ }
616
+ const b = {
617
+ defaultVM: {
618
+ isPoweredOn: !1,
619
+ isLockedOut: !1,
620
+ canPowerOn: !0,
621
+ canLockOut: !0,
622
+ voltage: 0
623
+ },
624
+ subscribe: (o, t, e) => {
625
+ if (!o) return;
626
+ const n = g.getById(o, t);
627
+ if (!n) {
628
+ t.submitWarning(
629
+ "abbControllerPMAdapter",
630
+ "Unable to find AbbControllerPM"
631
+ );
632
+ return;
633
+ }
634
+ n.addView(e);
635
+ },
636
+ unsubscribe: (o, t, e) => {
637
+ if (!o) return;
638
+ const n = g.getById(o, t);
639
+ n && n.removeView(e);
640
+ }
641
+ }, Lt = 1;
642
+ class zt {
643
+ id;
644
+ interfaceVersion = 1;
645
+ appObjects;
646
+ /**
647
+ * Dispatch map: event key → subscribe controller.
648
+ * Each controller has signature `(id, appObjects, cb: () => void) => () => void`.
649
+ */
650
+ eventDispatchMap = {
651
+ poweredOn: ut,
652
+ poweredOff: dt,
653
+ powerOnBlockedByLockout: gt,
654
+ lockoutEngaged: ft,
655
+ lockoutDisengaged: kt,
656
+ lockoutBlockedByPower: yt,
657
+ voltageChecked: pt,
658
+ selected: Ct
659
+ };
660
+ /**
661
+ * Synchronously wire the domain instance (entity, UCs, PM, adapter).
662
+ * Does NOT touch Babylon.
663
+ */
664
+ constructor(t, e) {
665
+ this.id = t, this.appObjects = e, q(t, e);
666
+ }
667
+ /**
668
+ * Asynchronously load and attach the Babylon view. Required before the
669
+ * component renders in a 3D scene.
670
+ *
671
+ * @param variant - Optional asset variant. No variants are implemented in the
672
+ * starter, so an omitted or unrecognized variant loads the default asset
673
+ * (best-effort, per Contract v1).
674
+ */
675
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
676
+ async load(t) {
677
+ const { makeAbbControllerBabylonView: e } = await Promise.resolve().then(() => _t), n = this.appObjects.get(this.id);
678
+ n && await e(n).load();
679
+ }
680
+ /** Tear down the component and release all resources. */
681
+ destroy() {
682
+ this.appObjects.get(this.id)?.dispose();
683
+ }
684
+ /** Toggle the power state of the component. Returns true if successful. */
685
+ togglePower() {
686
+ return U(this.id, this.appObjects);
687
+ }
688
+ /** Power on. Returns true if successful, false if refused (locked out). */
689
+ powerOn() {
690
+ return X(this.id, this.appObjects);
691
+ }
692
+ /** Power off. Always succeeds. */
693
+ powerOff() {
694
+ return Z(this.id, this.appObjects);
695
+ }
696
+ /** Toggle the lockout state. Returns true if successful. */
697
+ toggleLockout() {
698
+ return V(this.id, this.appObjects);
699
+ }
700
+ /** Engage the lockout. Returns true if successful, false if refused (powered on). */
701
+ lockOut() {
702
+ return ot(this.id, this.appObjects);
703
+ }
704
+ /** Disengage the lockout. Always succeeds. */
705
+ unlock() {
706
+ return nt(this.id, this.appObjects);
707
+ }
708
+ /** Check the controller's voltage. Notifies subscribers of the check. */
709
+ checkVoltage() {
710
+ rt(this.id, this.appObjects);
711
+ }
712
+ /** Show or hide the always-visible ghost lock hint (training mode). */
713
+ setShowGhostLockHint(t) {
714
+ ct(this.id, this.appObjects, t);
715
+ }
716
+ /** Enable the whole-controller hitbox for single-target selection. */
717
+ enableHitbox() {
718
+ bt(this.id, this.appObjects);
719
+ }
720
+ /** Disable the whole-controller hitbox, restoring sub-component interactivity. */
721
+ disableHitbox() {
722
+ ht(this.id, this.appObjects);
723
+ }
724
+ getState() {
725
+ return wt(
726
+ this.id,
727
+ this.appObjects,
728
+ Lt
729
+ );
730
+ }
731
+ applyState(t) {
732
+ Ot(this.id, this.appObjects, t);
733
+ }
734
+ /**
735
+ * Subscribe to a typed event. Returns an unsubscribe function.
736
+ */
737
+ onEvent(t, e) {
738
+ const n = this.eventDispatchMap[t];
739
+ return n(this.id, this.appObjects, e);
740
+ }
741
+ /**
742
+ * Subscribe to the reactive view model. Emits the current VM immediately,
743
+ * then on every change. Returns an unsubscribe function.
744
+ */
745
+ onViewModel(t) {
746
+ return b.subscribe(this.id, this.appObjects, t), () => b.unsubscribe(this.id, this.appObjects, t);
747
+ }
748
+ }
749
+ const Dt = {
750
+ poweredOn: "poweredOn",
751
+ poweredOff: "poweredOff",
752
+ powerOnBlockedByLockout: "powerOnBlockedByLockout",
753
+ lockoutEngaged: "lockoutEngaged",
754
+ lockoutDisengaged: "lockoutDisengaged",
755
+ lockoutBlockedByPower: "lockoutBlockedByPower",
756
+ voltageChecked: "voltageChecked",
757
+ selected: "selected"
758
+ };
759
+ function Pt(o, t) {
760
+ const e = h.getById(o, t);
761
+ if (!e) {
762
+ t.submitWarning(
763
+ "abbControllerHitboxClicked",
764
+ "Unable to find AbbControllerSelectUC"
765
+ );
766
+ return;
767
+ }
768
+ e.notifySelected();
769
+ }
770
+ function Mt(o) {
771
+ return function(t) {
772
+ const e = o.getOrCreate(t), n = v(e);
773
+ return Y(e), tt(e), it(e), lt(e), mt(e), n;
774
+ };
775
+ }
776
+ class Bt extends T {
777
+ factoryName = "AbbControllerFeatureFactory";
778
+ repo = null;
779
+ setupEntities() {
780
+ this.repo = Q(this.appObject), this.repo.abbControllerEntityFactory = Mt(this.appObjects);
781
+ }
782
+ setupUCs() {
783
+ }
784
+ setupPMs() {
785
+ }
786
+ finalSetup() {
787
+ }
788
+ }
789
+ function Rt(o) {
790
+ const t = o.getOrCreate("AbbControllers");
791
+ return new Bt(t);
792
+ }
793
+ const Et = {
794
+ /** Machine-friendly name (used in package name, imports) */
795
+ name: "AbbController",
796
+ /** Human-friendly display name */
797
+ displayName: "ABB Controller",
798
+ /** Semantic version */
799
+ version: "0.1.0",
800
+ /** Whether multiple instances can exist in a scene */
801
+ multiInstance: !0,
802
+ /** 3D asset files to include in the build */
803
+ assets: [
804
+ {
805
+ name: "default",
806
+ id: "d9f9f9a5-b2b3-4fe1-86e4-343336211a23",
807
+ file: "AbbController.glb"
808
+ }
809
+ ]
810
+ };
811
+ let m = /* @__PURE__ */ new WeakMap();
812
+ function It(o) {
813
+ let t = m.get(o);
814
+ return t || (t = /* @__PURE__ */ new Map(), m.set(o, t)), t;
815
+ }
816
+ async function xt(o, t, e) {
817
+ const n = It(o);
818
+ let i = n.get(e);
819
+ i || (i = F(e, t).then(
820
+ (s) => D(s, o, {
821
+ pluginExtension: ".glb"
822
+ })
823
+ ), n.set(e, i));
824
+ try {
825
+ return await i;
826
+ } catch (s) {
827
+ throw n.delete(e), s;
828
+ }
829
+ }
830
+ function Kt() {
831
+ m = /* @__PURE__ */ new WeakMap();
832
+ }
833
+ const L = "cutoff_knob", vt = x.FromEulerAngles(0, -Math.PI / 2, 0);
834
+ class P extends O {
835
+ static type = "CutoffKnobView";
836
+ static get(t) {
837
+ return t.getComponent(this.type);
838
+ }
839
+ }
840
+ function Ut(o) {
841
+ return new Vt(o);
842
+ }
843
+ class Vt extends P {
844
+ knobMesh;
845
+ initialPosition;
846
+ initialRotationQuaternion;
847
+ currentVM = b.defaultVM;
848
+ get entity() {
849
+ return r.getById(this.appObject.id, this.appObjects);
850
+ }
851
+ bindMeshes(t) {
852
+ if (this.knobMesh = t.get(L), !this.knobMesh) {
853
+ this.warn(
854
+ `Unable to find '${L}' mesh; cutoff knob inert until the asset provides it`
855
+ );
856
+ return;
857
+ }
858
+ this.knobMesh.rotationQuaternion || (this.knobMesh.rotationQuaternion = x.FromEulerAngles(
859
+ this.knobMesh.rotation.x,
860
+ this.knobMesh.rotation.y,
861
+ this.knobMesh.rotation.z
862
+ )), this.initialPosition = this.knobMesh.position.clone(), this.initialRotationQuaternion = this.knobMesh.rotationQuaternion.clone(), this.bindClickAction(this.knobMesh), this.knobMesh.isPickable = !(this.entity?.isHitboxEnabled ?? !1), this.applyPowerState(this.currentVM.isPoweredOn);
863
+ }
864
+ applyView = (t) => {
865
+ const e = this.currentVM;
866
+ this.currentVM = t, t.isPoweredOn !== e.isPoweredOn && this.applyPowerState(t.isPoweredOn);
867
+ };
868
+ onEntityChange = () => {
869
+ this.knobMesh && (this.knobMesh.isPickable = !(this.entity?.isHitboxEnabled ?? !1));
870
+ };
871
+ applyPowerState(t) {
872
+ !this.knobMesh || !this.initialPosition || !this.initialRotationQuaternion || (this.knobMesh.position.copyFrom(this.initialPosition), this.knobMesh.rotationQuaternion = t ? this.initialRotationQuaternion.multiply(vt) : this.initialRotationQuaternion.clone());
873
+ }
874
+ bindClickAction(t) {
875
+ const e = t.getScene();
876
+ if (!e) {
877
+ this.warn("Unable to wire cutoff knob without a scene");
878
+ return;
879
+ }
880
+ t.actionManager ??= new a(e), t.actionManager.registerAction(
881
+ new y(a.OnPickTrigger, () => {
882
+ U(this.appObject.id, this.appObjects);
883
+ })
884
+ );
885
+ }
886
+ dispose() {
887
+ b.unsubscribe(
888
+ this.appObject.id,
889
+ this.appObjects,
890
+ this.applyView
891
+ ), this.entity?.removeChangeObserver(this.onEntityChange), super.dispose();
892
+ }
893
+ constructor(t) {
894
+ super(t, P.type), b.subscribe(
895
+ this.appObject.id,
896
+ this.appObjects,
897
+ this.applyView
898
+ ), this.entity?.addChangeObserver(this.onEntityChange);
899
+ }
900
+ }
901
+ const M = "lock", B = "ghost_lock";
902
+ class E extends O {
903
+ static type = "LockView";
904
+ static get(t) {
905
+ return t.getComponent(this.type);
906
+ }
907
+ }
908
+ function St(o) {
909
+ return new Ht(o);
910
+ }
911
+ class Ht extends E {
912
+ lockNode;
913
+ ghostLockMesh;
914
+ currentVM = b.defaultVM;
915
+ get entity() {
916
+ return r.getById(this.appObject.id, this.appObjects);
917
+ }
918
+ get subComponentsInteractive() {
919
+ return !(this.entity?.isHitboxEnabled ?? !1);
920
+ }
921
+ get showGhostLockHint() {
922
+ return this.entity?.isShowingGhostLockHint ?? !1;
923
+ }
924
+ bindMeshes(t) {
925
+ this.lockNode = this.resolveLockNode(t), this.ghostLockMesh = this.resolveGhostLockMesh(t), this.lockNode || this.warn(
926
+ `Unable to find '${M}' node; lock inert until the asset provides it`
927
+ ), this.ghostLockMesh || this.warn(
928
+ `Unable to find '${B}' mesh; ghost lock inert until the asset provides it`
929
+ ), this.bindClickActionsOnLockChildren(), this.bindClickAction(this.ghostLockMesh), this.bindGhostHoverActions(this.ghostLockMesh), this.applyMeshes();
930
+ }
931
+ applyView = (t) => {
932
+ this.currentVM = t, this.applyMeshes();
933
+ };
934
+ onEntityChange = () => {
935
+ this.applyMeshes();
936
+ };
937
+ applyMeshes() {
938
+ this.setLockVisible(this.currentVM.isLockedOut), this.setGhostLockVisible(this.shouldShowGhostLockAffordance());
939
+ }
940
+ shouldShowGhostLockAffordance() {
941
+ return this.currentVM.canLockOut && !this.currentVM.isLockedOut;
942
+ }
943
+ setLockVisible(t) {
944
+ if (this.lockNode) {
945
+ this.lockNode.setEnabled(t);
946
+ for (const e of this.lockNode.getChildMeshes(!1))
947
+ e.isPickable = t && this.subComponentsInteractive, e.setEnabled(t);
948
+ }
949
+ }
950
+ setGhostLockVisible(t) {
951
+ this.ghostLockMesh && (this.ghostLockMesh.setEnabled(t), this.ghostLockMesh.isPickable = t && this.subComponentsInteractive, this.ghostLockMesh.visibility = t && this.showGhostLockHint ? 1 : 0);
952
+ }
953
+ bindClickActionsOnLockChildren() {
954
+ if (this.lockNode)
955
+ for (const t of this.lockNode.getChildMeshes(!1))
956
+ this.bindClickAction(t);
957
+ }
958
+ bindClickAction(t) {
959
+ if (!t) return;
960
+ const e = t.getScene();
961
+ if (!e) {
962
+ this.warn("Unable to wire lock mesh without a scene");
963
+ return;
964
+ }
965
+ t.isPickable = !0, t.actionManager ??= new a(e), t.actionManager.registerAction(
966
+ new y(a.OnPickTrigger, () => {
967
+ V(this.appObject.id, this.appObjects);
968
+ })
969
+ );
970
+ }
971
+ bindGhostHoverActions(t) {
972
+ if (!t) return;
973
+ const e = t.getScene();
974
+ e && (t.actionManager ??= new a(e), t.actionManager.registerAction(
975
+ new y(a.OnPointerOverTrigger, () => {
976
+ t.visibility = 1;
977
+ })
978
+ ), t.actionManager.registerAction(
979
+ new y(a.OnPointerOutTrigger, () => {
980
+ this.showGhostLockHint || (t.visibility = 0);
981
+ })
982
+ ));
983
+ }
984
+ resolveLockNode(t) {
985
+ const e = t.get(M), n = e?.getClassName();
986
+ if (!(!e || n !== "TransformNode" && n !== "Mesh"))
987
+ return e;
988
+ }
989
+ resolveGhostLockMesh(t) {
990
+ const e = t.get(B);
991
+ if (e)
992
+ return e;
993
+ }
994
+ dispose() {
995
+ b.unsubscribe(
996
+ this.appObject.id,
997
+ this.appObjects,
998
+ this.applyView
999
+ ), this.entity?.removeChangeObserver(this.onEntityChange), super.dispose();
1000
+ }
1001
+ constructor(t) {
1002
+ super(t, E.type), b.subscribe(
1003
+ this.appObject.id,
1004
+ this.appObjects,
1005
+ this.applyView
1006
+ ), this.entity?.addChangeObserver(this.onEntityChange);
1007
+ }
1008
+ }
1009
+ const p = "abb_controller_hitbox";
1010
+ class I extends O {
1011
+ static type = "HitboxView";
1012
+ static get(t) {
1013
+ return t.getComponent(this.type);
1014
+ }
1015
+ }
1016
+ function jt(o) {
1017
+ return new Nt(o);
1018
+ }
1019
+ class Nt extends I {
1020
+ hitboxMesh;
1021
+ get entity() {
1022
+ return r.getById(this.appObject.id, this.appObjects);
1023
+ }
1024
+ bindMeshes(t) {
1025
+ if (this.hitboxMesh = t.get(p), !this.hitboxMesh) {
1026
+ this.warn(
1027
+ `Unable to find '${p}' mesh; whole-controller selection inert until the asset provides it`
1028
+ );
1029
+ return;
1030
+ }
1031
+ const e = this.hitboxMesh.material;
1032
+ e && (e.transparencyMode = R.MATERIAL_ALPHABLEND, e.alpha = 0), this.hitboxMesh.visibility = 0, this.hitboxMesh.isPickable = this.entity?.isHitboxEnabled ?? !1, this.bindActions(this.hitboxMesh);
1033
+ }
1034
+ onEntityChange = () => {
1035
+ this.hitboxMesh && (this.hitboxMesh.isPickable = this.entity?.isHitboxEnabled ?? !1);
1036
+ };
1037
+ bindActions(t) {
1038
+ const e = t.getScene();
1039
+ if (!e) {
1040
+ this.warn("Unable to wire hitbox mesh without a scene");
1041
+ return;
1042
+ }
1043
+ t.actionManager ??= new a(e), t.actionManager.registerAction(
1044
+ new y(a.OnPickTrigger, () => {
1045
+ Pt(this.appObject.id, this.appObjects);
1046
+ })
1047
+ );
1048
+ }
1049
+ dispose() {
1050
+ this.entity?.removeChangeObserver(this.onEntityChange), super.dispose();
1051
+ }
1052
+ constructor(t) {
1053
+ super(t, I.type), this.entity?.addChangeObserver(this.onEntityChange);
1054
+ }
1055
+ }
1056
+ class A extends O {
1057
+ static type = "AbbControllerBabylonView";
1058
+ static get(t) {
1059
+ return t.getComponent(this.type);
1060
+ }
1061
+ }
1062
+ function S(o) {
1063
+ return new Gt(o);
1064
+ }
1065
+ class Gt extends A {
1066
+ cutoffKnobView;
1067
+ lockView;
1068
+ hitboxView;
1069
+ meshes = [];
1070
+ _nodesByObjectId = /* @__PURE__ */ new Map();
1071
+ _highlightGroupsByObjectId = /* @__PURE__ */ new Map();
1072
+ _rootTransformNode;
1073
+ instantiatedEntries;
1074
+ loadPromise;
1075
+ async load() {
1076
+ this.meshes.length > 0 || (this.loadPromise || (this.loadPromise = this.loadInternal().catch((t) => {
1077
+ throw this.loadPromise = void 0, t;
1078
+ })), await this.loadPromise);
1079
+ }
1080
+ async loadInternal() {
1081
+ const t = this.getScene(), e = Et.assets[0]?.id;
1082
+ if (!e) {
1083
+ this.appObjects.submitError(
1084
+ "AbbControllerBabylonView.load",
1085
+ "Missing AbbController default asset configuration"
1086
+ );
1087
+ return;
1088
+ }
1089
+ const n = await xt(
1090
+ t,
1091
+ this.appObjects,
1092
+ e
1093
+ );
1094
+ this.instantiatedEntries = n.instantiateModelsToScene(
1095
+ (i) => i
1096
+ ), this._rootTransformNode = this.instantiatedEntries.rootNodes[0], this.meshes = this.collectMeshesFromRoots(
1097
+ this.instantiatedEntries.rootNodes
1098
+ ), this._nodesByObjectId = this.buildNodeLookup(
1099
+ this.instantiatedEntries.rootNodes
1100
+ ), this._highlightGroupsByObjectId = this.buildHighlightGroups(
1101
+ this._nodesByObjectId
1102
+ ), this.cutoffKnobView.bindMeshes(this._nodesByObjectId), this.lockView.bindMeshes(this._nodesByObjectId), this.hitboxView.bindMeshes(this._nodesByObjectId);
1103
+ }
1104
+ /**
1105
+ * `abb_controller_hitbox` → every visible mesh (all meshes except the
1106
+ * invisible hitbox itself), so outlining the invisible hitbox outlines the
1107
+ * whole visible controller. Every other objectId → a single-element array
1108
+ * for its own mesh.
1109
+ */
1110
+ buildHighlightGroups(t) {
1111
+ const e = /* @__PURE__ */ new Map(), n = this.meshes.filter(
1112
+ (i) => i.metadata?.gltf?.extras?.objectId?.toLowerCase() !== p
1113
+ );
1114
+ e.set(p, n);
1115
+ for (const [i, s] of t)
1116
+ i !== p && s.getClassName() === "Mesh" && e.set(i, [s]);
1117
+ return e;
1118
+ }
1119
+ buildNodeLookup(t) {
1120
+ const e = /* @__PURE__ */ new Map(), n = (i) => {
1121
+ const s = i.metadata?.gltf?.extras?.objectId;
1122
+ if (typeof s == "string") {
1123
+ const f = s.toLowerCase();
1124
+ e.has(f) || e.set(f, i);
1125
+ }
1126
+ };
1127
+ for (const i of t) {
1128
+ n(i);
1129
+ for (const s of i.getDescendants(
1130
+ !1
1131
+ ))
1132
+ n(s);
1133
+ }
1134
+ return e;
1135
+ }
1136
+ collectMeshesFromRoots(t) {
1137
+ const e = /* @__PURE__ */ new Set();
1138
+ for (const n of t) {
1139
+ n.getClassName() === "Mesh" && e.add(n);
1140
+ for (const i of n.getChildMeshes(!1))
1141
+ e.add(i);
1142
+ }
1143
+ return [...e];
1144
+ }
1145
+ getScene() {
1146
+ const t = z.get(this.appObjects);
1147
+ if (!t?.scene)
1148
+ throw new Error("BabylonEntity scene is not available");
1149
+ return t.scene;
1150
+ }
1151
+ get rootTransformNode() {
1152
+ return this._rootTransformNode;
1153
+ }
1154
+ get nodesByObjectId() {
1155
+ return this._nodesByObjectId;
1156
+ }
1157
+ get shadowCasters() {
1158
+ return this.meshes;
1159
+ }
1160
+ get highlightGroupsByObjectId() {
1161
+ return this._highlightGroupsByObjectId;
1162
+ }
1163
+ dispose() {
1164
+ this.instantiatedEntries?.dispose(), this.instantiatedEntries = void 0, this.meshes = [], this._nodesByObjectId = /* @__PURE__ */ new Map(), this._highlightGroupsByObjectId = /* @__PURE__ */ new Map(), this._rootTransformNode = void 0, this.loadPromise = void 0, this.cutoffKnobView.dispose(), this.lockView.dispose(), this.hitboxView.dispose(), super.dispose();
1165
+ }
1166
+ constructor(t) {
1167
+ super(t, A.type), this.cutoffKnobView = Ut(t), this.lockView = St(t), this.hitboxView = jt(t);
1168
+ }
1169
+ }
1170
+ const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1171
+ __proto__: null,
1172
+ AbbControllerBabylonView: A,
1173
+ makeAbbControllerBabylonView: S
1174
+ }, Symbol.toStringTag, { value: "Module" }));
1175
+ async function Qt(o) {
1176
+ const { id: t, appObjects: e, createIfMissing: n = !0 } = o;
1177
+ if (!t) {
1178
+ e.submitWarning(
1179
+ "createBabylonAbbController",
1180
+ "Expected non-empty component id"
1181
+ );
1182
+ return;
1183
+ }
1184
+ const i = u.get(e);
1185
+ if (!i) {
1186
+ e.submitWarning(
1187
+ "createBabylonAbbController",
1188
+ "Unable to find AbbControllerRepo"
1189
+ );
1190
+ return;
1191
+ }
1192
+ let s = r.getById(t, e);
1193
+ if (!s && n && (s = i.createAbbControllerEntity(t)), !s) {
1194
+ e.submitWarning(
1195
+ "createBabylonAbbController",
1196
+ "Unable to find AbbControllerEntity"
1197
+ );
1198
+ return;
1199
+ }
1200
+ const f = S(s.appObject);
1201
+ return await f.load(), f;
1202
+ }
1203
+ class $t extends g {
1204
+ vmsAreEqual = () => !0;
1205
+ constructor(t) {
1206
+ super(t, g.type);
1207
+ }
1208
+ }
1209
+ class qt extends c {
1210
+ powerOn = () => !0;
1211
+ powerOff = () => !0;
1212
+ togglePower = () => !0;
1213
+ subscribeOnPoweredOn = () => () => {
1214
+ };
1215
+ subscribeOnPoweredOff = () => () => {
1216
+ };
1217
+ subscribeOnPowerOnBlockedByLockout = () => () => {
1218
+ };
1219
+ constructor(t) {
1220
+ super(t, c.type);
1221
+ }
1222
+ }
1223
+ class Yt extends l {
1224
+ lockOut = () => !0;
1225
+ unlock = () => !0;
1226
+ toggleLockout = () => !0;
1227
+ subscribeOnLockoutEngaged = () => () => {
1228
+ };
1229
+ subscribeOnLockoutDisengaged = () => () => {
1230
+ };
1231
+ subscribeOnLockoutBlockedByPower = () => () => {
1232
+ };
1233
+ constructor(t) {
1234
+ super(t, l.type);
1235
+ }
1236
+ }
1237
+ class Jt extends d {
1238
+ execute = () => {
1239
+ };
1240
+ subscribeOnVoltageChecked = () => () => {
1241
+ };
1242
+ constructor(t) {
1243
+ super(t, d.type);
1244
+ }
1245
+ }
1246
+ class Xt extends h {
1247
+ enableHitbox = () => {
1248
+ };
1249
+ disableHitbox = () => {
1250
+ };
1251
+ subscribeOnSelected = () => () => {
1252
+ };
1253
+ notifySelected = () => {
1254
+ };
1255
+ constructor(t) {
1256
+ super(t, h.type);
1257
+ }
1258
+ }
1259
+ export {
1260
+ Lt as ABB_CONTROLLER_STATE_VERSION,
1261
+ A as AbbControllerBabylonView,
1262
+ d as AbbControllerCheckVoltageUC,
1263
+ r as AbbControllerEntity,
1264
+ Dt as AbbControllerEventKeys,
1265
+ zt as AbbControllerFacade,
1266
+ Bt as AbbControllerFeatureFactory,
1267
+ l as AbbControllerLockoutUC,
1268
+ g as AbbControllerPM,
1269
+ c as AbbControllerPowerUC,
1270
+ u as AbbControllerRepo,
1271
+ h as AbbControllerSelectUC,
1272
+ Jt as MockAbbControllerCheckVoltageUC,
1273
+ Yt as MockAbbControllerLockoutUC,
1274
+ $t as MockAbbControllerPM,
1275
+ qt as MockAbbControllerPowerUC,
1276
+ Xt as MockAbbControllerSelectUC,
1277
+ Pt as abbControllerHitboxClicked,
1278
+ b as abbControllerPMAdapter,
1279
+ Ot as applyAbbControllerState,
1280
+ rt as checkVoltage,
1281
+ Kt as clearAbbControllerAssetCache,
1282
+ Et as componentConfig,
1283
+ q as createAbbController,
1284
+ Qt as createBabylonAbbController,
1285
+ ht as disableHitbox,
1286
+ bt as enableHitbox,
1287
+ xt as getAbbControllerAssetContainer,
1288
+ wt as getAbbControllerState,
1289
+ S as makeAbbControllerBabylonView,
1290
+ it as makeAbbControllerCheckVoltageUC,
1291
+ v as makeAbbControllerEntity,
1292
+ Rt as makeAbbControllerFeatureFactory,
1293
+ tt as makeAbbControllerLockoutUC,
1294
+ mt as makeAbbControllerPM,
1295
+ Y as makeAbbControllerPowerUC,
1296
+ Q as makeAbbControllerRepo,
1297
+ lt as makeAbbControllerSelectUC,
1298
+ Ct as onAbbControllerSelected,
1299
+ yt as onLockoutBlockedByPower,
1300
+ kt as onLockoutDisengaged,
1301
+ ft as onLockoutEngaged,
1302
+ gt as onPowerOnBlockedByLockout,
1303
+ dt as onPoweredOff,
1304
+ ut as onPoweredOn,
1305
+ pt as onVoltageChecked,
1306
+ ct as setShowGhostLockHint,
1307
+ ot as tryLockOut,
1308
+ Z as tryPowerOff,
1309
+ X as tryPowerOn,
1310
+ V as tryToggleLockout,
1311
+ U as tryTogglePower,
1312
+ nt as tryUnlock
1313
+ };