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