@kosdev-code/kos-dispense-sdk 2.0.22 → 2.0.23

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