@kosdev-code/kos-dispense-sdk 2.0.19 → 2.0.21

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 (32) hide show
  1. package/{dispense-registration-manager-BX9C7jzd.js → dispense-registration-manager-CKFF29mO.js} +8 -6
  2. package/dispense-registration-manager-CKFF29mO.js.map +1 -0
  3. package/{dispense-registration-manager-DRFXN5Fe.cjs → dispense-registration-manager-CjKpNrUy.cjs} +2 -2
  4. package/dispense-registration-manager-CjKpNrUy.cjs.map +1 -0
  5. package/{extension-utils-CaPxvvPM.js → extension-utils-Bb22_AzV.js} +2 -2
  6. package/{extension-utils-CaPxvvPM.js.map → extension-utils-Bb22_AzV.js.map} +1 -1
  7. package/{extension-utils-DiqbAS68.cjs → extension-utils-CScCluY5.cjs} +2 -2
  8. package/{extension-utils-DiqbAS68.cjs.map → extension-utils-CScCluY5.cjs.map} +1 -1
  9. package/index.cjs +1 -1
  10. package/index.js +3 -3
  11. package/models/models/assembly/assembly-model.d.ts.map +1 -1
  12. package/models.cjs +1 -1
  13. package/models.js +2 -2
  14. package/package.json +3 -3
  15. package/pump-provider-Md6crLsu.js +1087 -0
  16. package/pump-provider-Md6crLsu.js.map +1 -0
  17. package/pump-provider-_HlzmMsA.cjs +2 -0
  18. package/pump-provider-_HlzmMsA.cjs.map +1 -0
  19. package/ui/hooks/cui-kit/use-cui-kit.d.ts +1 -0
  20. package/ui/hooks/cui-kit/use-cui-kit.d.ts.map +1 -1
  21. package/ui/hooks/cui-kit/use-dispense-lifecycle.d.ts +2 -1
  22. package/ui/hooks/cui-kit/use-dispense-lifecycle.d.ts.map +1 -1
  23. package/ui/hooks/nozzle-pour/use-nozzle-pour.d.ts +2 -1
  24. package/ui/hooks/nozzle-pour/use-nozzle-pour.d.ts.map +1 -1
  25. package/ui.cjs +1 -1
  26. package/ui.js +2 -2
  27. package/dispense-registration-manager-BX9C7jzd.js.map +0 -1
  28. package/dispense-registration-manager-DRFXN5Fe.cjs.map +0 -1
  29. package/pump-provider-BU_HZL2F.cjs +0 -2
  30. package/pump-provider-BU_HZL2F.cjs.map +0 -1
  31. package/pump-provider-D7OslYhd.js +0 -1070
  32. package/pump-provider-D7OslYhd.js.map +0 -1
@@ -0,0 +1,1087 @@
1
+ var Ve = Object.defineProperty;
2
+ var je = (e, t, r) => t in e ? Ve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var y = (e, t, r) => (je(e, typeof t != "symbol" ? t + "" : t, r), r);
4
+ import { jsx as u } from "@emotion/react/jsx-runtime";
5
+ import { useKosModel as x, getKosCompanionModel as ae, kosAutoEffect as We, KosLog as w, usePressGesture as ce, EventBus as T, TimerManager as Pe } from "@kosdev-code/kos-ui-sdk";
6
+ import qe, { createContext as E, useMemo as $, useContext as g, useState as A, useCallback as a, useEffect as F } from "react";
7
+ import { A as ue, a as le, d as Je, c as he, N as Qe, e as me, H as Xe, f as pe, I as fe, g as be, G as Ze, P as ve } from "./dispense-registration-manager-CKFF29mO.js";
8
+ const Ie = () => {
9
+ const e = ue.type;
10
+ return x({
11
+ modelId: e,
12
+ modelType: ue.type,
13
+ options: {}
14
+ });
15
+ };
16
+ function At(e) {
17
+ return (t) => {
18
+ const { model: r, status: n, KosModelLoader: s } = Ie();
19
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, assembly: r }) });
20
+ };
21
+ }
22
+ const Te = () => {
23
+ const e = le.type;
24
+ return x({
25
+ modelId: e,
26
+ modelType: le.type,
27
+ options: {}
28
+ });
29
+ };
30
+ function xt(e) {
31
+ return (t) => {
32
+ const { model: r, status: n, KosModelLoader: s } = Te();
33
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, beverage: r }) });
34
+ };
35
+ }
36
+ const Ae = (e) => x({
37
+ modelId: e,
38
+ modelType: Je.type,
39
+ options: {}
40
+ });
41
+ function gt(e) {
42
+ return (t) => (r) => {
43
+ const { model: n, status: s, KosModelLoader: i } = Ae(t);
44
+ return /* @__PURE__ */ u(i, { ...s, children: /* @__PURE__ */ u(e, { ...r, board: n }) });
45
+ };
46
+ }
47
+ const xe = () => {
48
+ const e = he.type;
49
+ return x({
50
+ modelId: e,
51
+ modelType: he.type,
52
+ options: {}
53
+ });
54
+ };
55
+ function kt(e) {
56
+ return (t) => {
57
+ const { model: r, status: n, KosModelLoader: s } = xe();
58
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, boardContainer: r }) });
59
+ };
60
+ }
61
+ const ge = (e) => x({
62
+ modelId: e,
63
+ modelType: Qe.type,
64
+ options: {
65
+ path: e
66
+ }
67
+ }), ke = E(void 0), ze = ({ children: e, path: t }) => {
68
+ const { model: r, ready: n } = ge(t), s = $(() => n && r ? { model: r } : {}, [n, r]);
69
+ return /* @__PURE__ */ u(ke.Provider, { value: s, children: e });
70
+ }, B = () => {
71
+ const e = g(ke);
72
+ if (!e)
73
+ throw new Error("useNozzleContext must be used within a NozzleProvider");
74
+ return e;
75
+ }, et = ({
76
+ onBeverageSelected: e,
77
+ onClearBeverage: t,
78
+ companionType: r
79
+ }) => {
80
+ const { model: n } = B(), [s, i] = A([]), [c, l] = A(null), p = $(() => r ? s.map(
81
+ (h) => ae(h, r)
82
+ ) : [], [s, r]), m = a(
83
+ async (h) => {
84
+ l(h), await (n == null ? void 0 : n.setSelectedPourable({ beverage: h })), e == null || e(h);
85
+ },
86
+ [n, e]
87
+ ), d = a(async () => {
88
+ l(null), await (n == null ? void 0 : n.setSelectedPourable({ beverage: void 0 })), t == null || t();
89
+ }, [n, t]);
90
+ return F(() => {
91
+ const h = We(() => {
92
+ if (!n)
93
+ return;
94
+ const v = n.selectedBrand;
95
+ if (!v) {
96
+ const k = n.getGroupAvailabilityItems("beverages").filter((b) => b.visible);
97
+ i(k ?? []);
98
+ return;
99
+ }
100
+ const o = n.getAvailabilityByParent(v.id).filter((k) => k.visible);
101
+ i(o ?? []);
102
+ });
103
+ return () => {
104
+ h();
105
+ };
106
+ }, [n]), {
107
+ beverages: s,
108
+ beverageCompanions: p,
109
+ selectBeverage: m,
110
+ selectedBeverage: c,
111
+ clearBeverage: d
112
+ };
113
+ }, tt = ({
114
+ onBrandSelected: e,
115
+ onBrandCleared: t,
116
+ companionType: r
117
+ }) => {
118
+ const { model: n } = B(), [s, i] = A(null), c = $(
119
+ () => (n == null ? void 0 : n.getGroupAvailabilityItems("brands").filter((d) => d.visible)) ?? [],
120
+ [n]
121
+ ), l = $(() => r ? c.map((d) => ae(d, r)) : [], [c, r]), p = a(
122
+ async (d) => {
123
+ i(d), n == null || n.setSelectedBrand(d), e == null || e(d);
124
+ },
125
+ [n, e]
126
+ ), m = a(() => {
127
+ i(null), n == null || n.setSelectedBrand(void 0), t == null || t();
128
+ }, [n, t]);
129
+ return {
130
+ brands: c,
131
+ brandCompanions: l,
132
+ selectedBrand: s,
133
+ selectBrand: p,
134
+ clearBrand: m
135
+ };
136
+ }, st = w.createLogger({
137
+ name: "HoldToPourStrategy",
138
+ group: "kos-hooks"
139
+ }), Ee = {
140
+ name: "HoldToPourStrategy",
141
+ async initiate(e) {
142
+ if (!(e != null && e.canPour)) {
143
+ st.debug(`Nozzle ${e == null ? void 0 : e.id} cannot pour. Returning early.`);
144
+ return;
145
+ }
146
+ await (e == null ? void 0 : e.pour());
147
+ },
148
+ async initiateEnded(e) {
149
+ await (e == null ? void 0 : e.cancelPour());
150
+ }
151
+ }, Q = w.createLogger({
152
+ name: "useNozzlePour",
153
+ group: "kos-hooks"
154
+ }), rt = ({
155
+ onPour: e,
156
+ onPourCancel: t,
157
+ onBeforePour: r,
158
+ strategy: n = Ee
159
+ }) => {
160
+ const { model: s } = B(), i = a(async () => {
161
+ (r ? await (r == null ? void 0 : r()) : !0) ? (Q.debug(
162
+ `[${n == null ? void 0 : n.name}] - Pour initiated for nozzle ${s == null ? void 0 : s.id}.`
163
+ ), n == null || n.initiate(s), e == null || e()) : (Q.debug(
164
+ `[${n == null ? void 0 : n.name}] - Pour cancelled for nozzle ${s == null ? void 0 : s.id}.`
165
+ ), t == null || t());
166
+ }, [e, s, n, r, t]), c = a(() => {
167
+ var m;
168
+ Q.debug(
169
+ `[${n == null ? void 0 : n.name}] - Pour initiate ended called for nozzle ${s == null ? void 0 : s.id}.`
170
+ ), (m = n == null ? void 0 : n.initiateEnded) == null || m.call(n, s), t == null || t();
171
+ }, [t, s, n]), l = a(() => {
172
+ Q.debug(`Force cancelling pour for nozzle ${s == null ? void 0 : s.id}.`), s == null || s.cancelPour(), t == null || t();
173
+ }, [t, s]);
174
+ return {
175
+ handlers: ce({
176
+ onPressed: i,
177
+ onRelease: c
178
+ }).dom,
179
+ cancel: l,
180
+ status: s
181
+ };
182
+ }, nt = ({
183
+ onFlavorSelected: e,
184
+ onFlavorCleared: t,
185
+ companionType: r
186
+ }) => {
187
+ const { model: n } = B(), s = $(
188
+ () => (n == null ? void 0 : n.getGroupAvailabilityItems("flavors").filter((d) => d.visible)) ?? [],
189
+ [n]
190
+ ), i = $(() => r ? s.map(
191
+ (d) => ae(d, r)
192
+ ) : [], [s, r]), [c, l] = A([]), p = a(
193
+ async (d) => {
194
+ if (l(
195
+ (h) => h != null && h.includes(d) ? [...h.filter((v) => v !== d)] : [...h ?? [], d]
196
+ ), n != null && n.selectedPourable) {
197
+ const { beverage: h } = n.selectedPourable;
198
+ await n.setSelectedPourable({
199
+ beverage: h,
200
+ additional: c ?? []
201
+ });
202
+ }
203
+ e == null || e(d, c ?? []);
204
+ },
205
+ [n, e, c]
206
+ ), m = a(async () => {
207
+ if (l([]), n != null && n.selectedPourable) {
208
+ const { beverage: d } = n.selectedPourable;
209
+ n.setSelectedPourable({ beverage: d }), t == null || t();
210
+ }
211
+ }, [n, t]);
212
+ return {
213
+ flavors: s,
214
+ flavorCompanions: i,
215
+ selectFlavor: p,
216
+ selectedFlavors: c,
217
+ clearFlavors: m
218
+ };
219
+ }, C = "brands", X = "beverages", O = "flavors", it = ({
220
+ initialGroup: e = C,
221
+ options: t = {}
222
+ }) => {
223
+ var W, q, J;
224
+ const [r, n] = A(e), { model: s } = B(), i = a(
225
+ (f) => {
226
+ n(O);
227
+ const M = `/kos/dispense/${s == null ? void 0 : s.path}/brand/selected/`;
228
+ T.publish(M, f);
229
+ },
230
+ [s == null ? void 0 : s.path]
231
+ ), c = a(() => {
232
+ const f = `/kos/dispense/${s == null ? void 0 : s.path}/brand/cleared/`;
233
+ T.publish(f, {});
234
+ }, [s == null ? void 0 : s.path]), l = a(
235
+ (f) => {
236
+ n(O);
237
+ const M = `/kos/dispense/${s == null ? void 0 : s.path}/beverage/selected/`;
238
+ T.publish(M, f);
239
+ },
240
+ [s == null ? void 0 : s.path]
241
+ ), p = a(() => {
242
+ const f = `/kos/dispense/${s == null ? void 0 : s.path}/beverage/cleared/`;
243
+ T.publish(f, {});
244
+ }, [s == null ? void 0 : s.path]), m = a(
245
+ (f) => {
246
+ const M = `/kos/dispense/${s == null ? void 0 : s.path}/flavor/selected/`;
247
+ T.publish(M, f);
248
+ },
249
+ [s == null ? void 0 : s.path]
250
+ ), d = a(() => {
251
+ const f = `/kos/dispense/${s == null ? void 0 : s.path}/flavor/cleared/`;
252
+ T.publish(f, {});
253
+ }, [s == null ? void 0 : s.path]), h = a(() => {
254
+ const f = `/kos/dispense/${s == null ? void 0 : s.path}/pour/`;
255
+ T.publish(f, {});
256
+ }, [s == null ? void 0 : s.path]), v = a(async () => {
257
+ const f = `/kos/dispense/${s == null ? void 0 : s.path}/pre/pour/`;
258
+ return T.publish(f, {}), await (S == null ? void 0 : S()) || !0;
259
+ }, [s == null ? void 0 : s.path]), o = a(() => {
260
+ const f = `/kos/dispense/${s == null ? void 0 : s.path}/pour/cancel/`;
261
+ T.publish(f, {});
262
+ }, [s == null ? void 0 : s.path]), { brands: k, selectBrand: b, selectedBrand: H, clearBrand: P, brandCompanions: D } = tt({
263
+ companionType: (W = t.companionTypes) == null ? void 0 : W.brand,
264
+ onBrandSelected: i,
265
+ onBrandCleared: c
266
+ }), {
267
+ beverages: U,
268
+ selectBeverage: V,
269
+ selectedBeverage: z,
270
+ clearBeverage: N,
271
+ beverageCompanions: ee
272
+ } = et({
273
+ companionType: (q = t.companionTypes) == null ? void 0 : q.beverage,
274
+ onBeverageSelected: l,
275
+ onClearBeverage: p
276
+ }), {
277
+ clearFlavors: R,
278
+ flavors: L,
279
+ selectFlavor: te,
280
+ selectedFlavors: j,
281
+ flavorCompanions: I
282
+ } = nt({
283
+ companionType: (J = t.companionTypes) == null ? void 0 : J.flavor,
284
+ onFlavorSelected: m,
285
+ onFlavorCleared: d
286
+ }), [S, K] = A(), Y = a((f) => {
287
+ K(() => f);
288
+ }, []), se = rt({
289
+ onPour: h,
290
+ onPourCancel: o,
291
+ onBeforePour: v
292
+ }), re = a(() => {
293
+ switch (r) {
294
+ case C:
295
+ N(), P();
296
+ break;
297
+ case X:
298
+ case O:
299
+ n(e), N(), P();
300
+ break;
301
+ }
302
+ }, [N, P, r, e]), ne = a(() => {
303
+ const f = `/kos/dispense/${s == null ? void 0 : s.path}/home/`;
304
+ T.publish(f, {}), n(e), e === C && (N(), P()), e === X && N();
305
+ }, [N, P, e]);
306
+ return {
307
+ nav: {
308
+ currentGroup: r,
309
+ back: re,
310
+ home: ne
311
+ },
312
+ pour: se,
313
+ updateOnBeforePour: Y,
314
+ selections: {
315
+ [C]: H,
316
+ [X]: z,
317
+ [O]: j
318
+ },
319
+ [C]: {
320
+ models: k,
321
+ companions: D,
322
+ clear: P,
323
+ handlers: {
324
+ onSelected: b
325
+ }
326
+ },
327
+ [X]: {
328
+ models: U,
329
+ companions: ee,
330
+ clear: N,
331
+ handlers: {
332
+ onSelected: V
333
+ }
334
+ },
335
+ [O]: {
336
+ models: L,
337
+ companions: I,
338
+ clear: R,
339
+ handlers: {
340
+ onSelected: te
341
+ }
342
+ }
343
+ };
344
+ }, ot = (e) => {
345
+ const { model: t } = B(), [r, n] = A(null), {
346
+ onAmbientTimer: s,
347
+ onAttractTimer: i,
348
+ onResetAttractTimer: c,
349
+ onResumeAttractTimer: l,
350
+ defaultAttractTime: p,
351
+ defaultAmbientTime: m
352
+ } = e, d = a(() => {
353
+ s && (w.info("Ambient timer expired. Calling callback"), s == null || s());
354
+ }, [s]), h = a(() => {
355
+ i && (w.info("Attract timer expired. Calling callback"), i == null || i());
356
+ }, [i]), v = a(() => {
357
+ r && (r.restart(), c == null || c());
358
+ }, [r, c]), o = a(() => {
359
+ r && (r.reset(), c == null || c());
360
+ }, [r, c]), k = a(() => {
361
+ r && (r.pause(), l == null || l());
362
+ }, [r, l]);
363
+ return F(() => {
364
+ if (t && p) {
365
+ w.info("Nozzle is available. Creating timers");
366
+ const b = Pe.createTimer(
367
+ "attract-timer-" + t.path,
368
+ p
369
+ );
370
+ return p && (b == null || b.addTimeoutAction({
371
+ name: "attract-timer",
372
+ remainingTime: 0,
373
+ action: h
374
+ })), m && (b == null || b.addTimeoutAction({
375
+ name: "ambient-timer",
376
+ remainingTime: m,
377
+ action: d
378
+ })), p && (b == null || b.start()), n(b ?? null), () => {
379
+ b == null || b.reset(), n(null);
380
+ };
381
+ }
382
+ return () => {
383
+ w.info("Nozzle is not available. No timers to clear");
384
+ };
385
+ }, [
386
+ m,
387
+ p,
388
+ d,
389
+ h,
390
+ t
391
+ ]), {
392
+ attractTimer: r,
393
+ restart: v,
394
+ pause: o,
395
+ resume: k
396
+ };
397
+ }, at = (e, t) => {
398
+ if (t)
399
+ return T.subscribe(e, t).unsubscribe;
400
+ }, ct = ({
401
+ onInit: e,
402
+ onBrandSelected: t,
403
+ onBrandCleared: r,
404
+ onBeverageCleared: n,
405
+ onBeverageSelected: s,
406
+ onFlavorCleared: i,
407
+ onFlavorSelected: c,
408
+ onReturnToHome: l,
409
+ onPour: p,
410
+ onPourCancel: m,
411
+ onAmbientTimer: d,
412
+ onAttractTimer: h,
413
+ onResumeAttractTimer: v
414
+ }) => {
415
+ const { model: o } = B();
416
+ F(() => {
417
+ const b = [
418
+ {
419
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/brand/selected/`,
420
+ callback: t
421
+ },
422
+ {
423
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/brand/cleared/`,
424
+ callback: r
425
+ },
426
+ {
427
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/beverage/selected/`,
428
+ callback: s
429
+ },
430
+ {
431
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/beverage/cleared/`,
432
+ callback: n
433
+ },
434
+ {
435
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/flavor/selected/`,
436
+ callback: c
437
+ },
438
+ {
439
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/flavor/cleared/`,
440
+ callback: i
441
+ },
442
+ { topic: `/kos/dispense/${o == null ? void 0 : o.path}/pour/`, callback: p },
443
+ {
444
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/pour/cancel/`,
445
+ callback: m
446
+ },
447
+ {
448
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/ambient/start/`,
449
+ callback: d
450
+ },
451
+ {
452
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/attract/start/`,
453
+ callback: h
454
+ },
455
+ {
456
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/attract/resume/`,
457
+ callback: v
458
+ },
459
+ {
460
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/init/`,
461
+ callback: e
462
+ },
463
+ {
464
+ topic: `/kos/dispense/${o == null ? void 0 : o.path}/home/`,
465
+ callback: l
466
+ }
467
+ ].map(
468
+ ({ topic: H, callback: P }) => at(H, P)
469
+ );
470
+ return () => {
471
+ b.forEach((H) => H == null ? void 0 : H());
472
+ };
473
+ }, [
474
+ o == null ? void 0 : o.path,
475
+ d,
476
+ h,
477
+ n,
478
+ s,
479
+ r,
480
+ t,
481
+ i,
482
+ c,
483
+ p,
484
+ m,
485
+ v,
486
+ e,
487
+ l
488
+ ]);
489
+ }, we = (e) => {
490
+ const { model: t } = B(), [r, n] = A(null), {
491
+ onAreYouThereTimer: s,
492
+ onIdleTimer: i,
493
+ onResetIdleTimer: c,
494
+ defaultAreYouThereTime: l = 10,
495
+ defaultIdleTime: p = 20
496
+ } = e, m = a(() => {
497
+ s && (w.info("Are you there timer expired. Calling callback"), s == null || s());
498
+ }, [s]), d = a(() => {
499
+ i && (w.info("Idle timer expired. Calling callback"), i == null || i());
500
+ }, [i]), h = a(() => {
501
+ r && (r.restart(), c == null || c());
502
+ }, [r, c]), v = a(() => {
503
+ r && (r.reset(), c == null || c());
504
+ }, [r, c]);
505
+ return F(() => {
506
+ if (t) {
507
+ w.info("Nozzle is available. Creating timers");
508
+ const o = Pe.createTimer(
509
+ `${e.prefix ?? ""}idle-timer-${t.path}`,
510
+ p
511
+ );
512
+ return o == null || o.addTimeoutAction({
513
+ name: "idle-timer",
514
+ remainingTime: 0,
515
+ action: d
516
+ }), o == null || o.addTimeoutAction({
517
+ name: "are-you-there-timer",
518
+ remainingTime: l,
519
+ action: m
520
+ }), n(o ?? null), () => {
521
+ o == null || o.reset(), n(null);
522
+ };
523
+ }
524
+ return () => {
525
+ w.info("Nozzle is not available. No timers to clear");
526
+ };
527
+ }, [
528
+ l,
529
+ p,
530
+ m,
531
+ d,
532
+ t,
533
+ e.prefix
534
+ ]), {
535
+ idleTimer: r,
536
+ restart: h,
537
+ pause: v
538
+ };
539
+ }, Et = ({
540
+ kit: e,
541
+ inactivity: t,
542
+ pour: r,
543
+ screens: n
544
+ }) => {
545
+ var de;
546
+ const [s, i] = A(!1), [c, l] = A(!1), [p, m] = A(!1), { model: d } = B(), [h, v] = A(!1), o = (t == null ? void 0 : t.idleTimeout) ?? 15, k = (t == null ? void 0 : t.areYouThereTimeoutOffset) ?? 10, b = (r == null ? void 0 : r.idleTimeout) ?? (t == null ? void 0 : t.idleTimeout) ?? 10, H = (r == null ? void 0 : r.areYouThereTimeoutOffset) ?? (t == null ? void 0 : t.areYouThereTimeoutOffset) ?? 5, P = n == null ? void 0 : n.ambientTimeoutOffset, D = n == null ? void 0 : n.attractTimeout, U = a(() => {
547
+ i(!0);
548
+ }, []), V = a(() => {
549
+ i(!1), e == null || e.nav.home();
550
+ }, [(de = e == null ? void 0 : e.nav) == null ? void 0 : de.home]), z = a(() => {
551
+ P && (l(!0), m(!1));
552
+ }, [P]), N = a(() => {
553
+ D && (m(!0), l(!1));
554
+ }, [D]), ee = a(() => {
555
+ D && (m(!1), l(!1), e == null || e.nav.home());
556
+ }, [e == null ? void 0 : e.nav, D]), {
557
+ pause: R,
558
+ restart: L,
559
+ resume: te,
560
+ attractTimer: j
561
+ } = ot({
562
+ defaultAmbientTime: P,
563
+ defaultAttractTime: D,
564
+ onAmbientTimer: z,
565
+ onAttractTimer: N,
566
+ onResumeAttractTimer: ee
567
+ }), { pause: I, restart: S } = we({
568
+ defaultAreYouThereTime: k,
569
+ defaultIdleTime: o,
570
+ onAreYouThereTimer: U,
571
+ onIdleTimer: V
572
+ }), { pause: K, restart: Y } = we({
573
+ defaultAreYouThereTime: H,
574
+ defaultIdleTime: b,
575
+ onAreYouThereTimer: U,
576
+ onIdleTimer: V,
577
+ prefix: "pour-"
578
+ }), se = a(() => {
579
+ v(!1), K(), I();
580
+ }, [I, K]), re = a(() => {
581
+ v(!0), console.log("restarting pour timer"), Y(), I();
582
+ }, [I, Y]), ne = a(() => {
583
+ i(!1), h ? (Y(), I()) : (S(), K());
584
+ }, [h, I, K, S, Y]), W = a(() => {
585
+ R(), m(!1), l(!1), S();
586
+ }, [R, S]), q = a(() => {
587
+ m(!1), l(!1), v(!1), K(), L();
588
+ }, [L, K]), J = a(() => {
589
+ m(!1), l(!1), v(!1), R(), S();
590
+ }, [R, S]), f = a(() => {
591
+ m(!1), l(!1), v(!1), L(), I(), K();
592
+ }, [L, I, K]), M = a(() => {
593
+ m(!1), l(!1), L(), I();
594
+ }, [L, I]);
595
+ ct({
596
+ onBrandSelected: W,
597
+ onBrandCleared: q,
598
+ onBeverageSelected: J,
599
+ onBeverageCleared: f,
600
+ onPour: se,
601
+ onPourCancel: re,
602
+ onInit: M
603
+ });
604
+ const Fe = h ? H : k;
605
+ return F(() => {
606
+ if (d && j) {
607
+ const Ue = `/kos/dispense/${d == null ? void 0 : d.path}/init/`;
608
+ T.publish(Ue, {});
609
+ }
610
+ }, [d, j]), {
611
+ showAreYouThere: s,
612
+ clearAreYouThere: ne,
613
+ areYouThereCountdown: Fe,
614
+ showAmbientScreen: c,
615
+ showAttractScreen: p,
616
+ pauseScreenTimer: te
617
+ };
618
+ }, He = () => {
619
+ const e = me.type;
620
+ return x({
621
+ modelId: e,
622
+ modelType: me.type,
623
+ options: {}
624
+ });
625
+ };
626
+ function Ht(e) {
627
+ return (t) => {
628
+ const { model: r, status: n, KosModelLoader: s } = He();
629
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, deviceAssembly: r }) });
630
+ };
631
+ }
632
+ const Se = (e) => x({
633
+ modelId: e,
634
+ modelType: Xe.type,
635
+ options: {}
636
+ });
637
+ function St(e, t) {
638
+ return (r) => {
639
+ const { model: n, status: s, KosModelLoader: i } = Se(e);
640
+ return /* @__PURE__ */ u(i, { ...s, children: /* @__PURE__ */ u(t, { ...r, holder: n }) });
641
+ };
642
+ }
643
+ const Ke = () => {
644
+ const e = pe.type;
645
+ return x({
646
+ modelId: e,
647
+ modelType: pe.type,
648
+ options: {}
649
+ });
650
+ };
651
+ function Kt(e) {
652
+ return (t) => {
653
+ const { model: r, status: n, KosModelLoader: s } = Ke();
654
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, holderContainer: r }) });
655
+ };
656
+ }
657
+ const Ne = () => {
658
+ const e = fe.type;
659
+ return x({
660
+ modelId: e,
661
+ modelType: fe.type,
662
+ options: {}
663
+ });
664
+ }, ie = w.createLogger({
665
+ name: "HoldToPourIntentStrategy",
666
+ group: "kos-hooks"
667
+ }), dt = {
668
+ name: "HoldToPourIntentStrategy",
669
+ async initiate(e, t) {
670
+ if (!(e != null && e.canPour)) {
671
+ ie.debug(`${e == null ? void 0 : e.id} cannot pour. Returning early.`);
672
+ return;
673
+ }
674
+ t ? (ie.debug(`performing intent: ${t}`), await (e == null ? void 0 : e.performIntent(t))) : ie.debug("no intent provided. Returning early.");
675
+ },
676
+ async initiateEnded(e) {
677
+ await (e == null ? void 0 : e.cancelPour());
678
+ }
679
+ }, oe = w.createLogger({
680
+ name: "useNozzlePour",
681
+ group: "kos-hooks"
682
+ }), Nt = ({
683
+ onPour: e,
684
+ onPourCancel: t,
685
+ intentContainer: r,
686
+ strategy: n = dt
687
+ }) => {
688
+ const s = a(() => {
689
+ oe.debug(
690
+ `[${n == null ? void 0 : n.name}] - Pour initiated for model ${r == null ? void 0 : r.id}.`
691
+ ), n == null || n.initiate(r), e == null || e();
692
+ }, [e, r, n]), i = a(() => {
693
+ var p;
694
+ oe.debug(
695
+ `[${n == null ? void 0 : n.name}] - Pour initiate ended called for nozzle ${r == null ? void 0 : r.id}.`
696
+ ), (p = n == null ? void 0 : n.initiateEnded) == null || p.call(n, r), t == null || t();
697
+ }, [t, r, n]), c = a(() => {
698
+ oe.debug(`Force cancelling pour for nozzle ${r == null ? void 0 : r.id}.`), r == null || r.cancelPour(), t == null || t();
699
+ }, [t, r]);
700
+ return {
701
+ handlers: ce({
702
+ onPressed: s,
703
+ onRelease: i
704
+ }).dom,
705
+ cancel: c,
706
+ status: r
707
+ };
708
+ };
709
+ function Bt(e) {
710
+ return (t) => {
711
+ const { model: r, status: n, KosModelLoader: s } = Ne();
712
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, ingredient: r }) });
713
+ };
714
+ }
715
+ const Be = () => {
716
+ const e = be.type;
717
+ return x({
718
+ modelId: e,
719
+ modelType: be.type,
720
+ options: {}
721
+ });
722
+ };
723
+ function Lt(e) {
724
+ return (t) => {
725
+ const { model: r, status: n, KosModelLoader: s } = Be();
726
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, ingredientContainer: r }) });
727
+ };
728
+ }
729
+ function Dt(e, t) {
730
+ return (r) => {
731
+ const { model: n, status: s, KosModelLoader: i } = ge(e);
732
+ return /* @__PURE__ */ u(i, { ...s, children: /* @__PURE__ */ u(t, { ...r, nozzle: n }) });
733
+ };
734
+ }
735
+ const G = w.createLogger({
736
+ name: "usePour",
737
+ group: "kos-hooks"
738
+ }), Mt = ({
739
+ onBeforePour: e,
740
+ onPour: t,
741
+ onPourCancel: r,
742
+ onPourAbort: n,
743
+ pourTarget: s,
744
+ strategy: i = Ee
745
+ }) => {
746
+ const c = a(async () => {
747
+ G.debug(
748
+ `[${i == null ? void 0 : i.name}] - calling before pour for pour target ${s == null ? void 0 : s.id}.`
749
+ ), (e ? await (e == null ? void 0 : e()) : !0) ? (G.debug(
750
+ `[${i == null ? void 0 : i.name}] - Pour initiated for pour target ${s == null ? void 0 : s.id}.`
751
+ ), await (i == null ? void 0 : i.initiate(s)), t == null || t(), s != null && s.isPouring || n == null || n()) : (G.debug(
752
+ `[${i == null ? void 0 : i.name}] - Pour cancelled for pour target ${s == null ? void 0 : s.id}.`
753
+ ), r == null || r());
754
+ }, [t, s, i]), l = a(async () => {
755
+ var h;
756
+ G.debug(
757
+ `[${i == null ? void 0 : i.name}] - Pour initiate ended called for pour target ${s == null ? void 0 : s.id}.`
758
+ ), await ((h = i == null ? void 0 : i.initiateEnded) == null ? void 0 : h.call(i, s)) || r == null || r();
759
+ }, [r, s, i]), p = a(async () => {
760
+ G.debug(`Force cancelling pour for pour target ${s == null ? void 0 : s.id}.`), await (s == null ? void 0 : s.cancelPour()), r == null || r();
761
+ }, [r, s]);
762
+ return {
763
+ handlers: ce({
764
+ onPressed: c,
765
+ onRelease: l
766
+ }).dom,
767
+ cancel: p,
768
+ status: s
769
+ };
770
+ }, _ = w.createLogger({
771
+ name: "TapOrHoldIntentStrategy",
772
+ group: "kos-hooks"
773
+ });
774
+ class Rt {
775
+ constructor(t) {
776
+ y(this, "intent");
777
+ y(this, "name", "TapOrHoldIntentStrategy");
778
+ y(this, "isHold", !1);
779
+ y(this, "disposer", null);
780
+ this.intent = t;
781
+ }
782
+ async initiate(t, r) {
783
+ if (this.disposer = setTimeout(() => {
784
+ this.isHold = !0;
785
+ }, 250), t != null && t.isPouring && !this.isHold) {
786
+ _.debug("additional tap detected. cancelling pour"), await t.cancelPour();
787
+ return;
788
+ }
789
+ if (!(t != null && t.canPour)) {
790
+ _.debug(`${t == null ? void 0 : t.id} cannot pour. Returning early.`);
791
+ return;
792
+ }
793
+ r ? (_.debug(`performing intent: ${r}`), await (t == null ? void 0 : t.performIntent(r))) : _.debug("no intent provided. Returning early.");
794
+ }
795
+ async initiateEnded(t) {
796
+ return this.disposer && clearTimeout(this.disposer), this.disposer = null, this.isHold ? (await (t == null ? void 0 : t.cancelPour()), !1) : (_.debug("Tap detected. don't cancel and return."), !0);
797
+ }
798
+ }
799
+ const Z = w.createLogger({
800
+ name: "TapToPourIntentStrategy",
801
+ group: "kos-hooks"
802
+ }), Yt = {
803
+ name: "TapToPourIntentStrategy",
804
+ async initiate(e, t) {
805
+ if (e != null && e.isPouring) {
806
+ Z.debug(`Nozzle ${e == null ? void 0 : e.id} is already pouring. cancelling pour`), await e.cancelPour();
807
+ return;
808
+ }
809
+ if (!(e != null && e.canPour)) {
810
+ Z.debug(`Nozzle ${e == null ? void 0 : e.id} cannot pour. Returning early.`);
811
+ return;
812
+ }
813
+ t ? (Z.debug(`performing intent: ${t}`), await (e == null ? void 0 : e.performIntent(t))) : Z.debug("no intent provided. Returning early.");
814
+ },
815
+ async initiateEnded(e) {
816
+ return !0;
817
+ }
818
+ }, $e = w.createLogger({
819
+ name: "HoldToPourStrategy",
820
+ group: "kos-hooks"
821
+ }), yt = {
822
+ name: "TapToPourStrategy",
823
+ async initiate(e) {
824
+ if (e != null && e.isPouring) {
825
+ $e.debug(`Nozzle ${e == null ? void 0 : e.id} is already pouring. cancelling pour`), await e.cancelPour();
826
+ return;
827
+ }
828
+ if (!(e != null && e.canPour)) {
829
+ $e.debug(`Nozzle ${e == null ? void 0 : e.id} cannot pour. Returning early.`);
830
+ return;
831
+ }
832
+ await (e == null ? void 0 : e.pour());
833
+ },
834
+ async initiateEnded(e) {
835
+ return !0;
836
+ }
837
+ }, ut = (e, t, r) => x({
838
+ modelId: e,
839
+ modelType: Ze.type,
840
+ options: {
841
+ servicePathFactory: t,
842
+ selectedId: r
843
+ }
844
+ });
845
+ function Ct(e) {
846
+ return (t) => {
847
+ const { model: r, status: n, KosModelLoader: s } = ut(
848
+ t.id,
849
+ t.servicePathFactory,
850
+ t.itemId
851
+ );
852
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, genericPour: r }) });
853
+ };
854
+ }
855
+ const Le = E(void 0), Ot = ({ children: e }) => {
856
+ const { model: t, ready: r } = Ie(), n = $(() => r && t ? { model: t } : {}, [r, t]);
857
+ return /* @__PURE__ */ u(Le.Provider, { value: n, children: e });
858
+ }, Gt = () => {
859
+ const e = g(
860
+ Le
861
+ );
862
+ if (!e)
863
+ throw new Error(
864
+ "useAssemblyContext must be used within a AssemblyProvider"
865
+ );
866
+ return e;
867
+ }, De = E(void 0), _t = ({ children: e }) => {
868
+ const { model: t, ready: r } = Te(), n = $(() => r && t ? { model: t } : {}, [r, t]);
869
+ return /* @__PURE__ */ u(De.Provider, { value: n, children: e });
870
+ }, Ft = () => {
871
+ const e = g(De);
872
+ if (!e)
873
+ throw new Error(
874
+ "useAvailabilityContext must be used within a AvailabilityProvider"
875
+ );
876
+ return e;
877
+ }, Me = E(void 0), Ut = ({ children: e, id: t }) => {
878
+ const { model: r, ready: n } = Ae(t), s = $(() => n && r ? { model: r } : {}, [n, r]);
879
+ return /* @__PURE__ */ u(Me.Provider, { value: s, children: e });
880
+ }, Vt = () => {
881
+ const e = g(Me);
882
+ if (!e)
883
+ throw new Error("useBoardContext must be used within a BoardProvider");
884
+ return e;
885
+ }, Re = E(void 0), jt = ({ children: e }) => {
886
+ const { model: t, ready: r } = xe(), n = $(() => r && t ? { model: t } : {}, [r, t]);
887
+ return /* @__PURE__ */ u(Re.Provider, { value: n, children: e });
888
+ }, Wt = () => {
889
+ const e = g(Re);
890
+ if (!e)
891
+ throw new Error(
892
+ "useBoardContainerContext must be used within a BoardContainerProvider"
893
+ );
894
+ return e;
895
+ }, Ye = E(
896
+ void 0
897
+ ), lt = ({ children: e }) => {
898
+ const { model: t, ready: r } = He(), n = $(() => {
899
+ if (r && t) {
900
+ const i = t.nozzlePaths;
901
+ return { model: t, nozzlePaths: i };
902
+ }
903
+ return {};
904
+ }, [r, t]), s = r && t ? e : null;
905
+ return /* @__PURE__ */ u(Ye.Provider, { value: n, children: s });
906
+ }, ht = () => {
907
+ const e = g(Ye);
908
+ if (!e)
909
+ throw new Error(
910
+ "useDeviceAssemblyContext must be used within a DeviceAssemblyProvider"
911
+ );
912
+ return e;
913
+ };
914
+ function mt() {
915
+ const e = qe.createContext(null);
916
+ return [() => {
917
+ const r = g(e);
918
+ if (r === void 0)
919
+ throw new Error("useDispenseKitContext must be used within a Provider");
920
+ return r;
921
+ }, e.Provider];
922
+ }
923
+ function pt({ children: e, provider: t, props: r }) {
924
+ const n = it(r);
925
+ return /* @__PURE__ */ u(t, { value: n, children: e({}) });
926
+ }
927
+ function ft({
928
+ children: e,
929
+ provider: t,
930
+ props: r
931
+ }) {
932
+ const { nozzlePaths: n } = ht();
933
+ return (n == null ? void 0 : n.map((i) => /* @__PURE__ */ u(ze, { path: i, children: /* @__PURE__ */ u(
934
+ pt,
935
+ {
936
+ provider: t,
937
+ props: r,
938
+ children: e
939
+ }
940
+ ) }, i))) || [];
941
+ }
942
+ function bt({
943
+ provider: e,
944
+ props: t
945
+ }) {
946
+ return ({ children: r }) => e ? /* @__PURE__ */ u(lt, { children: /* @__PURE__ */ u(
947
+ ft,
948
+ {
949
+ provider: e,
950
+ props: t,
951
+ children: r
952
+ }
953
+ ) }) : null;
954
+ }
955
+ function qt(e) {
956
+ const [t, r] = mt();
957
+ return [
958
+ t,
959
+ bt({ provider: r, props: e })
960
+ ];
961
+ }
962
+ const ye = E(void 0), Jt = ({ children: e, id: t }) => {
963
+ const { model: r, ready: n } = Se(t || ""), s = $(() => n && r ? { model: r } : {}, [n, r]);
964
+ return /* @__PURE__ */ u(ye.Provider, { value: s, children: e });
965
+ }, Qt = () => {
966
+ const e = g(ye);
967
+ if (!e)
968
+ throw new Error("useHolderContext must be used within a HolderProvider");
969
+ return e;
970
+ }, Ce = E(
971
+ void 0
972
+ ), Xt = ({ children: e }) => {
973
+ const { model: t, ready: r } = Ke(), n = $(() => r && t ? { model: t } : {}, [r, t]);
974
+ return /* @__PURE__ */ u(Ce.Provider, { value: n, children: e });
975
+ }, Zt = () => {
976
+ const e = g(Ce);
977
+ if (!e)
978
+ throw new Error(
979
+ "useHolderContainerContext must be used within a HolderContainerProvider"
980
+ );
981
+ return e;
982
+ }, Oe = E(void 0), zt = ({ children: e }) => {
983
+ const { model: t, ready: r } = Ne(), n = $(() => r && t ? { model: t } : {}, [r, t]);
984
+ return /* @__PURE__ */ u(Oe.Provider, { value: n, children: e });
985
+ }, es = () => {
986
+ const e = g(Oe);
987
+ if (!e)
988
+ throw new Error(
989
+ "useIngredientContext must be used within a IngredientProvider"
990
+ );
991
+ return e;
992
+ }, Ge = E(
993
+ void 0
994
+ ), ts = ({ children: e }) => {
995
+ const { model: t, ready: r } = Be(), n = $(() => r && t ? { model: t } : {}, [r, t]);
996
+ return /* @__PURE__ */ u(Ge.Provider, { value: n, children: e });
997
+ }, ss = () => {
998
+ const e = g(Ge);
999
+ if (!e)
1000
+ throw new Error(
1001
+ "useIngredientContainerContext must be used within a IngredientContainerProvider"
1002
+ );
1003
+ return e;
1004
+ }, vt = () => {
1005
+ const e = ve.type;
1006
+ return x({
1007
+ modelId: e,
1008
+ modelType: ve.type,
1009
+ options: {}
1010
+ });
1011
+ }, _e = E(void 0), rs = ({ children: e }) => {
1012
+ const { model: t, ready: r } = vt(), n = $(() => r && t ? { model: t } : {}, [r, t]);
1013
+ return /* @__PURE__ */ u(_e.Provider, { value: n, children: e });
1014
+ }, ns = () => {
1015
+ const e = g(_e);
1016
+ if (!e)
1017
+ throw new Error("usePumpContext must be used within a PumpProvider");
1018
+ return e;
1019
+ };
1020
+ export {
1021
+ Lt as $,
1022
+ Ot as A,
1023
+ Ut as B,
1024
+ pt as C,
1025
+ lt as D,
1026
+ tt as E,
1027
+ C as F,
1028
+ X as G,
1029
+ Jt as H,
1030
+ zt as I,
1031
+ O as J,
1032
+ it as K,
1033
+ Et as L,
1034
+ ct as M,
1035
+ ze as N,
1036
+ we as O,
1037
+ rs as P,
1038
+ nt as Q,
1039
+ He as R,
1040
+ Ht as S,
1041
+ Se as T,
1042
+ St as U,
1043
+ Ke as V,
1044
+ Kt as W,
1045
+ Ne as X,
1046
+ Nt as Y,
1047
+ Bt as Z,
1048
+ Be as _,
1049
+ _t as a,
1050
+ ge as a0,
1051
+ Dt as a1,
1052
+ rt as a2,
1053
+ Mt as a3,
1054
+ dt as a4,
1055
+ Ee as a5,
1056
+ Rt as a6,
1057
+ Yt as a7,
1058
+ yt as a8,
1059
+ ut as a9,
1060
+ Ct as aa,
1061
+ Ft as b,
1062
+ Vt as c,
1063
+ jt as d,
1064
+ Wt as e,
1065
+ bt as f,
1066
+ ht as g,
1067
+ Qt as h,
1068
+ qt as i,
1069
+ Xt as j,
1070
+ Zt as k,
1071
+ es as l,
1072
+ ts as m,
1073
+ ss as n,
1074
+ B as o,
1075
+ ns as p,
1076
+ Ie as q,
1077
+ Te as r,
1078
+ xt as s,
1079
+ Ae as t,
1080
+ Gt as u,
1081
+ gt as v,
1082
+ At as w,
1083
+ xe as x,
1084
+ kt as y,
1085
+ et as z
1086
+ };
1087
+ //# sourceMappingURL=pump-provider-Md6crLsu.js.map