@scopetickets/checkout 0.1.0 → 0.1.2
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/README.md +18 -1
- package/dist/chunk-4BOPQURW.js +1989 -0
- package/dist/chunk-4BOPQURW.js.map +1 -0
- package/dist/index.cjs +13852 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +3813 -0
- package/dist/index.d.ts +3813 -0
- package/dist/index.js +12004 -0
- package/dist/index.js.map +1 -0
- package/dist/pickers.cjs +1908 -0
- package/dist/pickers.cjs.map +1 -0
- package/dist/pickers.css +1054 -0
- package/dist/pickers.css.map +1 -0
- package/dist/pickers.d.cts +911 -0
- package/dist/pickers.d.ts +911 -0
- package/dist/pickers.js +117 -0
- package/dist/pickers.js.map +1 -0
- package/dist/styles.css +2948 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1989 @@
|
|
|
1
|
+
// src/island/island-press.ts
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState
|
|
9
|
+
} from "react";
|
|
10
|
+
|
|
11
|
+
// src/island/island-motion.ts
|
|
12
|
+
var SURFACE_MORPH_MS = 250;
|
|
13
|
+
var SURFACE_DAMPING = 0.82;
|
|
14
|
+
var SURFACE_SPRING = {
|
|
15
|
+
response: responseForSettle(SURFACE_MORPH_MS / 1e3, SURFACE_DAMPING),
|
|
16
|
+
damping: SURFACE_DAMPING,
|
|
17
|
+
clampOvershoot: false
|
|
18
|
+
};
|
|
19
|
+
var CARRY_SPRING = {
|
|
20
|
+
response: responseForSettle(SURFACE_MORPH_MS / 1e3, 0.95),
|
|
21
|
+
damping: 0.95,
|
|
22
|
+
clampOvershoot: true
|
|
23
|
+
};
|
|
24
|
+
var POP_RETURN_SPRING = { ...SURFACE_SPRING, clampOvershoot: true };
|
|
25
|
+
function responseForSettle(settleSeconds, damping) {
|
|
26
|
+
return settleSeconds * damping * 2 * Math.PI / 4;
|
|
27
|
+
}
|
|
28
|
+
function naturalFrequency({ response }) {
|
|
29
|
+
return 2 * Math.PI / response;
|
|
30
|
+
}
|
|
31
|
+
function settleMs(spring) {
|
|
32
|
+
const exact = 4 / (spring.damping * naturalFrequency(spring)) * 1e3;
|
|
33
|
+
return Math.ceil(Number(exact.toFixed(9)));
|
|
34
|
+
}
|
|
35
|
+
function springAt(spring, t) {
|
|
36
|
+
const wn = naturalFrequency(spring);
|
|
37
|
+
const z = spring.damping;
|
|
38
|
+
const wd = wn * Math.sqrt(1 - z * z);
|
|
39
|
+
const value = 1 - Math.exp(-z * wn * t) * (Math.cos(wd * t) + z / Math.sqrt(1 - z * z) * Math.sin(wd * t));
|
|
40
|
+
return spring.clampOvershoot ? Math.min(value, 1) : value;
|
|
41
|
+
}
|
|
42
|
+
function springEasing(spring, samples = 40) {
|
|
43
|
+
const duration = settleMs(spring) / 1e3;
|
|
44
|
+
const arrival = Math.min(springAt(spring, duration), 1);
|
|
45
|
+
const points = [];
|
|
46
|
+
for (let i = 0; i <= samples; i += 1) {
|
|
47
|
+
const raw = springAt(spring, i / samples * duration);
|
|
48
|
+
const scaled = arrival <= 0 ? raw : raw / arrival;
|
|
49
|
+
const value = i === samples ? 1 : spring.clampOvershoot ? Math.min(1, scaled) : scaled;
|
|
50
|
+
points.push(Number(value.toFixed(4)).toString());
|
|
51
|
+
}
|
|
52
|
+
return `linear(${points.join(", ")})`;
|
|
53
|
+
}
|
|
54
|
+
var OUTGOING_FADE_MS = 125;
|
|
55
|
+
var SURFACE_MORPH_DELAY_MS = OUTGOING_FADE_MS;
|
|
56
|
+
var INCOMING_FADE_DELAY_MS = SURFACE_MORPH_DELAY_MS + SURFACE_MORPH_MS;
|
|
57
|
+
var INCOMING_FADE_MS = 175;
|
|
58
|
+
var DAY_SWAP_STRETCH = 1.6;
|
|
59
|
+
var DAY_SWAP_OUT_MS = Math.round(OUTGOING_FADE_MS * DAY_SWAP_STRETCH);
|
|
60
|
+
var DAY_SWAP_IN_MS = Math.round(INCOMING_FADE_MS * DAY_SWAP_STRETCH);
|
|
61
|
+
var CARRY_MOVE_DELAY_MS = SURFACE_MORPH_DELAY_MS;
|
|
62
|
+
var CARRY_MOVE_MS = settleMs(CARRY_SPRING);
|
|
63
|
+
var ARC_LEAD_EASING = "cubic-bezier(0.61, 1, 0.88, 1)";
|
|
64
|
+
var ARC_TRAIL_EASING = "cubic-bezier(0.12, 0, 0.39, 0)";
|
|
65
|
+
var POP_SCALE = 0.95;
|
|
66
|
+
var SHIELD_POP_SCALE = 1 - (1 - POP_SCALE) / 2;
|
|
67
|
+
var POP_CONTRACT_MS = OUTGOING_FADE_MS;
|
|
68
|
+
var POP_RETURN_MS = settleMs(POP_RETURN_SPRING);
|
|
69
|
+
var POP_MS = POP_CONTRACT_MS + POP_RETURN_MS;
|
|
70
|
+
var POP_TURN_PERCENT = Number((POP_CONTRACT_MS / POP_MS * 100).toFixed(3));
|
|
71
|
+
var PRESS_IN_MS = POP_CONTRACT_MS;
|
|
72
|
+
var PRESS_LETGO_MS = 50;
|
|
73
|
+
var PRESS_RETURN_MS = SURFACE_MORPH_DELAY_MS + SURFACE_MORPH_MS;
|
|
74
|
+
var ISLAND_TRANSITION_MS = Math.max(
|
|
75
|
+
INCOMING_FADE_DELAY_MS + INCOMING_FADE_MS,
|
|
76
|
+
CARRY_MOVE_DELAY_MS + CARRY_MOVE_MS,
|
|
77
|
+
POP_MS
|
|
78
|
+
);
|
|
79
|
+
var BAY_SWAP_IN_PERCENT = Number(
|
|
80
|
+
(INCOMING_FADE_DELAY_MS / ISLAND_TRANSITION_MS * 100).toFixed(3)
|
|
81
|
+
);
|
|
82
|
+
var PROCESSING_FLOOR_MS = 3e3;
|
|
83
|
+
var PAID_GRACE_MS = 6e3;
|
|
84
|
+
var ACCOUNT_CREATING_FLOOR_MS = 3e3;
|
|
85
|
+
var HOLD_TICK_MS = 500;
|
|
86
|
+
|
|
87
|
+
// src/island/island-press.ts
|
|
88
|
+
var PressContext = createContext(null);
|
|
89
|
+
var primaryHeld = (event) => (event.buttons & 1) === 1;
|
|
90
|
+
var AT_REST = { at: "rest" };
|
|
91
|
+
var RISEN = { at: "rising", timer: null };
|
|
92
|
+
function stopWaiting(sink) {
|
|
93
|
+
if (sink.at === "rising" && sink.timer !== null) window.clearTimeout(sink.timer);
|
|
94
|
+
}
|
|
95
|
+
function useIslandPress(scope = "island") {
|
|
96
|
+
const api = useContext(PressContext);
|
|
97
|
+
const [pressedHere, setPressedHere] = useState(false);
|
|
98
|
+
const whole = scope === "island";
|
|
99
|
+
const sink = useRef(AT_REST);
|
|
100
|
+
useEffect(() => () => stopWaiting(sink.current), []);
|
|
101
|
+
const handlers = useMemo(() => {
|
|
102
|
+
const letGo = () => {
|
|
103
|
+
if (sink.current.at !== "down") return;
|
|
104
|
+
const left = PRESS_IN_MS - (Date.now() - sink.current.since);
|
|
105
|
+
if (left <= 0) {
|
|
106
|
+
sink.current = RISEN;
|
|
107
|
+
setPressedHere(false);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
sink.current = {
|
|
111
|
+
at: "rising",
|
|
112
|
+
timer: window.setTimeout(() => {
|
|
113
|
+
sink.current = AT_REST;
|
|
114
|
+
setPressedHere(false);
|
|
115
|
+
}, left)
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
const undo = () => {
|
|
119
|
+
if (sink.current.at !== "down") return;
|
|
120
|
+
sink.current = AT_REST;
|
|
121
|
+
setPressedHere(false);
|
|
122
|
+
};
|
|
123
|
+
const begin = whole ? () => api?.press("island") : () => {
|
|
124
|
+
api?.press("element");
|
|
125
|
+
stopWaiting(sink.current);
|
|
126
|
+
sink.current = { at: "down", since: Date.now() };
|
|
127
|
+
setPressedHere(true);
|
|
128
|
+
};
|
|
129
|
+
const end = whole ? () => api?.release() : () => {
|
|
130
|
+
api?.release();
|
|
131
|
+
letGo();
|
|
132
|
+
};
|
|
133
|
+
const cancel = whole ? () => api?.abandon() : () => {
|
|
134
|
+
api?.abandon();
|
|
135
|
+
undo();
|
|
136
|
+
};
|
|
137
|
+
return {
|
|
138
|
+
onPointerDown: (event) => {
|
|
139
|
+
if (primaryHeld(event)) begin();
|
|
140
|
+
},
|
|
141
|
+
onPointerUp: end,
|
|
142
|
+
onPointerLeave: cancel,
|
|
143
|
+
onPointerEnter: (event) => {
|
|
144
|
+
if (primaryHeld(event)) begin();
|
|
145
|
+
},
|
|
146
|
+
onPointerCancel: cancel
|
|
147
|
+
};
|
|
148
|
+
}, [api, whole]);
|
|
149
|
+
return whole || !pressedHere ? handlers : { ...handlers, "data-pressed": "" };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// src/island/island-calendar.ts
|
|
153
|
+
var HIGH_FROM = 2 / 3;
|
|
154
|
+
var MEDIUM_FROM = 1 / 3;
|
|
155
|
+
function toAvailabilityLevel(remaining) {
|
|
156
|
+
if (!Number.isFinite(remaining) || remaining <= 0) return null;
|
|
157
|
+
if (remaining > HIGH_FROM) return "HIGH";
|
|
158
|
+
if (remaining > MEDIUM_FROM) return "MEDIUM";
|
|
159
|
+
return "LOW";
|
|
160
|
+
}
|
|
161
|
+
function readAvailability(remaining) {
|
|
162
|
+
if (remaining === null) return null;
|
|
163
|
+
const level = toAvailabilityLevel(remaining);
|
|
164
|
+
if (level === null) return null;
|
|
165
|
+
const percent = Math.round(Math.min(remaining, 1) * 100);
|
|
166
|
+
return { level, announcement: `about ${percent}% availability` };
|
|
167
|
+
}
|
|
168
|
+
var RAMP = [
|
|
169
|
+
[0, 0],
|
|
170
|
+
[MEDIUM_FROM, 33],
|
|
171
|
+
[HIGH_FROM, 67],
|
|
172
|
+
[1, 100]
|
|
173
|
+
];
|
|
174
|
+
function availabilityColor(remaining) {
|
|
175
|
+
const stop = (suffix) => `var(--scopetickets-island-availability-${suffix})`;
|
|
176
|
+
if (remaining === null || !Number.isFinite(remaining) || remaining <= 0) return stop(0);
|
|
177
|
+
if (remaining >= 1) return stop(100);
|
|
178
|
+
const top = RAMP.findIndex(([at]) => remaining <= at);
|
|
179
|
+
const [lowAt, lowStop] = RAMP[top - 1];
|
|
180
|
+
const [highAt, highStop] = RAMP[top];
|
|
181
|
+
const towards = Math.round((remaining - lowAt) / (highAt - lowAt) * 100);
|
|
182
|
+
return `color-mix(in srgb, ${stop(highStop)} ${towards}%, ${stop(lowStop)})`;
|
|
183
|
+
}
|
|
184
|
+
function isDatePickerCellSelectable(state) {
|
|
185
|
+
return state === "AVAILABLE" || state === "SELECTED";
|
|
186
|
+
}
|
|
187
|
+
function isSelectableCalendarCell(cell) {
|
|
188
|
+
return cell.kind !== "EMPTY" && isDatePickerCellSelectable(cell.kind);
|
|
189
|
+
}
|
|
190
|
+
function parseMonth(month) {
|
|
191
|
+
return { year: Number(month.slice(0, 4)), monthIndex: Number(month.slice(5, 7)) - 1 };
|
|
192
|
+
}
|
|
193
|
+
function mondayFirstWeekday(date) {
|
|
194
|
+
return (date.getUTCDay() + 6) % 7;
|
|
195
|
+
}
|
|
196
|
+
function toDay(year, monthIndex, dayOfMonth) {
|
|
197
|
+
const month = String(monthIndex + 1).padStart(2, "0");
|
|
198
|
+
return `${year}-${month}-${String(dayOfMonth).padStart(2, "0")}`;
|
|
199
|
+
}
|
|
200
|
+
function eventsOn(series, day) {
|
|
201
|
+
return series.events.filter((event) => event.day === day);
|
|
202
|
+
}
|
|
203
|
+
function eventKeyForDay(series, day) {
|
|
204
|
+
return series === void 0 ? void 0 : eventsOn(series, day)[0]?.eventKey;
|
|
205
|
+
}
|
|
206
|
+
function dateRange(series) {
|
|
207
|
+
let first = null;
|
|
208
|
+
let last = null;
|
|
209
|
+
for (const event of series.events) {
|
|
210
|
+
if (first === null || event.day < first) first = event.day;
|
|
211
|
+
if (last === null || event.day > last) last = event.day;
|
|
212
|
+
}
|
|
213
|
+
return first === null || last === null ? null : { first, last };
|
|
214
|
+
}
|
|
215
|
+
function soonestRelevantDay(series, today) {
|
|
216
|
+
const days = [...new Set(series.events.map((event) => event.day))].sort();
|
|
217
|
+
return days.find((day) => day >= today) ?? days[days.length - 1] ?? null;
|
|
218
|
+
}
|
|
219
|
+
function classifyDay(series, day, span, today, selectedDay) {
|
|
220
|
+
const dayOfMonth = Number(day.slice(8, 10));
|
|
221
|
+
const events = eventsOn(series, day);
|
|
222
|
+
const elapsed = day < today;
|
|
223
|
+
if (events.length > 0) {
|
|
224
|
+
if (elapsed) return { kind: "PAST_BUT_RELEVANT", day, dayOfMonth, events };
|
|
225
|
+
if (day === selectedDay) return { kind: "SELECTED", day, dayOfMonth, events };
|
|
226
|
+
return { kind: "AVAILABLE", day, dayOfMonth, events };
|
|
227
|
+
}
|
|
228
|
+
const insideSpan = span !== null && day >= span.first && day <= span.last;
|
|
229
|
+
return insideSpan && !elapsed ? { kind: "UNAVAILABLE", day, dayOfMonth } : { kind: "OUT_OF_SERIES", day, dayOfMonth };
|
|
230
|
+
}
|
|
231
|
+
function addDays(day, count) {
|
|
232
|
+
const at = /* @__PURE__ */ new Date(`${day}T00:00:00.000Z`);
|
|
233
|
+
at.setUTCDate(at.getUTCDate() + count);
|
|
234
|
+
return at.toISOString().slice(0, 10);
|
|
235
|
+
}
|
|
236
|
+
function startOfWeek(day) {
|
|
237
|
+
return addDays(day, -mondayFirstWeekday(/* @__PURE__ */ new Date(`${day}T00:00:00.000Z`)));
|
|
238
|
+
}
|
|
239
|
+
function monthOfWeek(weekStart) {
|
|
240
|
+
return monthOfDay(addDays(weekStart, 3));
|
|
241
|
+
}
|
|
242
|
+
function weeksInSeries(series) {
|
|
243
|
+
const span = dateRange(series);
|
|
244
|
+
if (!span) return [];
|
|
245
|
+
const last = startOfWeek(span.last);
|
|
246
|
+
const weeks = [];
|
|
247
|
+
for (let week = startOfWeek(span.first); week <= last; week = addDays(week, 7)) {
|
|
248
|
+
weeks.push(week);
|
|
249
|
+
}
|
|
250
|
+
return weeks;
|
|
251
|
+
}
|
|
252
|
+
function weeksInCalendar(series) {
|
|
253
|
+
const span = dateRange(series);
|
|
254
|
+
if (!span) return [];
|
|
255
|
+
const from = parseMonth(monthOfDay(span.first));
|
|
256
|
+
const to = parseMonth(monthOfDay(span.last));
|
|
257
|
+
const lastOfMonth = new Date(Date.UTC(to.year, to.monthIndex + 1, 0)).getUTCDate();
|
|
258
|
+
const first = startOfWeek(toDay(from.year, from.monthIndex, 1));
|
|
259
|
+
const last = startOfWeek(toDay(to.year, to.monthIndex, lastOfMonth));
|
|
260
|
+
const weeks = [];
|
|
261
|
+
for (let week = first; week <= last; week = addDays(week, 7)) weeks.push(week);
|
|
262
|
+
const finalMonth = monthOfDay(span.last);
|
|
263
|
+
const finalMonthRow = monthStartRows(weeks).find(({ month }) => month === finalMonth)?.row ?? 0;
|
|
264
|
+
while (weeks.length < finalMonthRow + CALENDAR_VIEWPORT_ROWS) {
|
|
265
|
+
weeks.push(addDays(weeks[weeks.length - 1], 7));
|
|
266
|
+
}
|
|
267
|
+
return weeks;
|
|
268
|
+
}
|
|
269
|
+
function buildWeekRow(series, weekStart, { today, selectedDay = null }) {
|
|
270
|
+
const span = dateRange(series);
|
|
271
|
+
return Array.from(
|
|
272
|
+
{ length: 7 },
|
|
273
|
+
(_unused, offset) => classifyDay(series, addDays(weekStart, offset), span, today, selectedDay)
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
function buildMonthGrid(series, month, { today, selectedDay = null }) {
|
|
277
|
+
const { year, monthIndex } = parseMonth(month);
|
|
278
|
+
const first = new Date(Date.UTC(year, monthIndex, 1));
|
|
279
|
+
const dayCount = new Date(Date.UTC(year, monthIndex + 1, 0)).getUTCDate();
|
|
280
|
+
const span = dateRange(series);
|
|
281
|
+
const cells = [];
|
|
282
|
+
for (let i = 0; i < mondayFirstWeekday(first); i += 1) cells.push({ kind: "EMPTY" });
|
|
283
|
+
for (let dayOfMonth = 1; dayOfMonth <= dayCount; dayOfMonth += 1) {
|
|
284
|
+
cells.push(classifyDay(series, toDay(year, monthIndex, dayOfMonth), span, today, selectedDay));
|
|
285
|
+
}
|
|
286
|
+
while (cells.length % 7 !== 0) cells.push({ kind: "EMPTY" });
|
|
287
|
+
const weeks = [];
|
|
288
|
+
for (let i = 0; i < cells.length; i += 7) weeks.push(cells.slice(i, i + 7));
|
|
289
|
+
return weeks;
|
|
290
|
+
}
|
|
291
|
+
function weekContainingDay(weeks, day) {
|
|
292
|
+
return weeks.find((week) => week.some((cell) => cell.kind !== "EMPTY" && cell.day === day)) ?? null;
|
|
293
|
+
}
|
|
294
|
+
function locateDayInMonthStack(series, day, { today }) {
|
|
295
|
+
const months = monthsInSeries(series);
|
|
296
|
+
const monthIndex = months.indexOf(monthOfDay(day));
|
|
297
|
+
if (monthIndex < 0) return null;
|
|
298
|
+
const weeks = buildMonthGrid(series, months[monthIndex] ?? day.slice(0, 7), { today });
|
|
299
|
+
const weekIndex = weeks.findIndex(
|
|
300
|
+
(week) => week.some((cell) => cell.kind !== "EMPTY" && cell.day === day)
|
|
301
|
+
);
|
|
302
|
+
if (weekIndex < 0) return null;
|
|
303
|
+
return { monthIndex, weekIndex };
|
|
304
|
+
}
|
|
305
|
+
function monthOfDay(day) {
|
|
306
|
+
return day.slice(0, 7);
|
|
307
|
+
}
|
|
308
|
+
function monthsInSeries(series) {
|
|
309
|
+
const months = [];
|
|
310
|
+
for (const event of series.events) {
|
|
311
|
+
const month = monthOfDay(event.day);
|
|
312
|
+
if (!months.includes(month)) months.push(month);
|
|
313
|
+
}
|
|
314
|
+
return months.sort();
|
|
315
|
+
}
|
|
316
|
+
function openingMonth(series, today) {
|
|
317
|
+
const day = soonestRelevantDay(series, today);
|
|
318
|
+
if (day) return monthOfDay(day);
|
|
319
|
+
return monthsInSeries(series)[0] ?? null;
|
|
320
|
+
}
|
|
321
|
+
function stepMonth(series, month, step) {
|
|
322
|
+
const months = monthsInSeries(series);
|
|
323
|
+
const index = months.indexOf(month);
|
|
324
|
+
if (index === -1) return null;
|
|
325
|
+
return months[index + step] ?? null;
|
|
326
|
+
}
|
|
327
|
+
var CALENDAR_LOCALE = "en-IE";
|
|
328
|
+
function formatMonthYear(month) {
|
|
329
|
+
return month.slice(0, 4);
|
|
330
|
+
}
|
|
331
|
+
function formatMonthName(month) {
|
|
332
|
+
const { year, monthIndex } = parseMonth(month);
|
|
333
|
+
return new Date(Date.UTC(year, monthIndex, 1, 12)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
334
|
+
month: "long",
|
|
335
|
+
timeZone: "UTC"
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function formatMonthNameShort(month) {
|
|
339
|
+
const long = formatMonthName(month);
|
|
340
|
+
const { year, monthIndex } = parseMonth(month);
|
|
341
|
+
const short = new Date(Date.UTC(year, monthIndex, 1, 12)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
342
|
+
month: "short",
|
|
343
|
+
timeZone: "UTC"
|
|
344
|
+
});
|
|
345
|
+
return short.length < long.length ? `${short}.` : long;
|
|
346
|
+
}
|
|
347
|
+
function formatDayDate(day) {
|
|
348
|
+
return (/* @__PURE__ */ new Date(`${day}T12:00:00.000Z`)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
349
|
+
day: "numeric",
|
|
350
|
+
month: "long",
|
|
351
|
+
year: "numeric",
|
|
352
|
+
timeZone: "UTC"
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function formatWeekdayAndDate(day) {
|
|
356
|
+
return (/* @__PURE__ */ new Date(`${day}T12:00:00.000Z`)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
357
|
+
weekday: "long",
|
|
358
|
+
day: "numeric",
|
|
359
|
+
month: "long",
|
|
360
|
+
timeZone: "UTC"
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function formatDayChip(day) {
|
|
364
|
+
const at = /* @__PURE__ */ new Date(`${day}T12:00:00.000Z`);
|
|
365
|
+
return {
|
|
366
|
+
date: at.toLocaleDateString(CALENDAR_LOCALE, { day: "numeric", timeZone: "UTC" }),
|
|
367
|
+
month: at.toLocaleDateString(CALENDAR_LOCALE, { month: "short", timeZone: "UTC" }).replace(/\.$/, "").toUpperCase()
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function formatDayWeekday(day) {
|
|
371
|
+
return (/* @__PURE__ */ new Date(`${day}T12:00:00.000Z`)).toLocaleDateString(CALENDAR_LOCALE, {
|
|
372
|
+
weekday: "long",
|
|
373
|
+
timeZone: "UTC"
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
var DATE_PICKER_ACCESSORY = "NONE";
|
|
377
|
+
var CALENDAR_VIEWPORT_ROWS = 6;
|
|
378
|
+
function monthStartRows(weeks) {
|
|
379
|
+
if (weeks.length === 0) return [];
|
|
380
|
+
const starts = [{ month: monthOfDay(weeks[0]), row: 0 }];
|
|
381
|
+
weeks.forEach((weekStart, row) => {
|
|
382
|
+
for (let offset = 0; offset < 7; offset += 1) {
|
|
383
|
+
const day = addDays(weekStart, offset);
|
|
384
|
+
if (!day.endsWith("-01")) continue;
|
|
385
|
+
const month = monthOfDay(day);
|
|
386
|
+
if (!starts.some((start) => start.month === month)) starts.push({ month, row });
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
return starts;
|
|
390
|
+
}
|
|
391
|
+
function monthAtRow(starts, topRow) {
|
|
392
|
+
let current = starts[0]?.month ?? null;
|
|
393
|
+
for (const start of starts) {
|
|
394
|
+
if (start.row <= topRow) current = start.month;
|
|
395
|
+
}
|
|
396
|
+
return current;
|
|
397
|
+
}
|
|
398
|
+
function lastTopRow({ rowCount, viewportRows }) {
|
|
399
|
+
return Math.max(0, rowCount - viewportRows);
|
|
400
|
+
}
|
|
401
|
+
function rowAfterDrag(drag) {
|
|
402
|
+
const { row, offset, rowHeight } = drag;
|
|
403
|
+
if (rowHeight <= 0) return clampRow(row, drag);
|
|
404
|
+
return clampRow(Math.round(row - offset / rowHeight), drag);
|
|
405
|
+
}
|
|
406
|
+
var CALENDAR_ROW_OVERSHOOT = 1;
|
|
407
|
+
function resist(overshoot, rowHeight) {
|
|
408
|
+
const limit = rowHeight * CALENDAR_ROW_OVERSHOOT;
|
|
409
|
+
return limit * overshoot / (limit + overshoot);
|
|
410
|
+
}
|
|
411
|
+
function rowDragOffset(drag) {
|
|
412
|
+
const { row, offset, rowHeight } = drag;
|
|
413
|
+
if (rowHeight <= 0) return 0;
|
|
414
|
+
const wanted = row * rowHeight - offset;
|
|
415
|
+
const furthest = lastTopRow(drag) * rowHeight;
|
|
416
|
+
const held = wanted < 0 ? -resist(-wanted, rowHeight) : wanted > furthest ? furthest + resist(wanted - furthest, rowHeight) : wanted;
|
|
417
|
+
return row * rowHeight - held;
|
|
418
|
+
}
|
|
419
|
+
function clampRow(row, drag) {
|
|
420
|
+
return Math.max(0, Math.min(lastTopRow(drag), row));
|
|
421
|
+
}
|
|
422
|
+
function rowContainingDay(weeks, day) {
|
|
423
|
+
if (day === null || weeks.length === 0) return 0;
|
|
424
|
+
const rows = Math.floor(daysBetween(weeks[0], day) / 7);
|
|
425
|
+
const lastTop = Math.max(0, weeks.length - CALENDAR_VIEWPORT_ROWS);
|
|
426
|
+
return Math.max(0, Math.min(lastTop, rows));
|
|
427
|
+
}
|
|
428
|
+
function monthOpeningRow(weeks, starts, day) {
|
|
429
|
+
if (day === null || weeks.length === 0) return 0;
|
|
430
|
+
const start = starts.find((candidate) => candidate.month === monthOfDay(day));
|
|
431
|
+
if (start === void 0) return rowContainingDay(weeks, day);
|
|
432
|
+
return Math.min(Math.max(0, weeks.length - CALENDAR_VIEWPORT_ROWS), start.row);
|
|
433
|
+
}
|
|
434
|
+
function daysBetween(from, to) {
|
|
435
|
+
const ms = Date.parse(`${to}T00:00:00Z`) - Date.parse(`${from}T00:00:00Z`);
|
|
436
|
+
return Math.round(ms / 864e5);
|
|
437
|
+
}
|
|
438
|
+
function toggleSelectedDay(selected, day) {
|
|
439
|
+
return selected === day ? null : day;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// src/island/island-timeslots.ts
|
|
443
|
+
function slotFullness(remaining, total) {
|
|
444
|
+
if (!Number.isFinite(remaining) || remaining < 0) return null;
|
|
445
|
+
if (remaining <= 1) return remaining;
|
|
446
|
+
if (!Number.isFinite(total) || total <= 0) return null;
|
|
447
|
+
return Math.min(1, remaining / total);
|
|
448
|
+
}
|
|
449
|
+
var MAX_TIME_INPUT = 40;
|
|
450
|
+
var WALL_CLOCK = /^(?:\d{4}-\d{2}-\d{2}[T ])?(\d{2}):(\d{2})(?::\d{2})?/;
|
|
451
|
+
function parseWallClockTime(value) {
|
|
452
|
+
if (typeof value !== "string" || value.length > MAX_TIME_INPUT) return null;
|
|
453
|
+
const match = WALL_CLOCK.exec(value.trim());
|
|
454
|
+
if (!match) return null;
|
|
455
|
+
if (Number(match[1]) > 23 || Number(match[2]) > 59) return null;
|
|
456
|
+
return `${match[1]}:${match[2]}`;
|
|
457
|
+
}
|
|
458
|
+
function timeOfDayInZone(now, timeZone) {
|
|
459
|
+
const read = (zone) => {
|
|
460
|
+
const parts = new Intl.DateTimeFormat("en-GB", {
|
|
461
|
+
timeZone: zone,
|
|
462
|
+
hour: "2-digit",
|
|
463
|
+
minute: "2-digit",
|
|
464
|
+
hourCycle: "h23"
|
|
465
|
+
}).formatToParts(now);
|
|
466
|
+
const hour = parts.find((part) => part.type === "hour")?.value ?? "00";
|
|
467
|
+
const minute = parts.find((part) => part.type === "minute")?.value ?? "00";
|
|
468
|
+
return `${String(Number(hour) % 24).padStart(2, "0")}:${minute}`;
|
|
469
|
+
};
|
|
470
|
+
try {
|
|
471
|
+
return read(timeZone ?? "UTC");
|
|
472
|
+
} catch {
|
|
473
|
+
return read("UTC");
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
var PART_OF_DAY_LABELS = {
|
|
477
|
+
OVERNIGHT: "OVERNIGHT",
|
|
478
|
+
PRE_DAWN: "PRE-DAWN",
|
|
479
|
+
EARLY_MORNING: "EARLY MORNING",
|
|
480
|
+
LATE_MORNING: "LATE MORNING",
|
|
481
|
+
EARLY_AFTERNOON: "EARLY AFTERNOON",
|
|
482
|
+
LATE_AFTERNOON: "LATE AFTERNOON",
|
|
483
|
+
EARLY_EVENING: "EARLY EVENING",
|
|
484
|
+
LATE_EVENING: "LATE EVENING"
|
|
485
|
+
};
|
|
486
|
+
function partOfDayLabel(part) {
|
|
487
|
+
return PART_OF_DAY_LABELS[part];
|
|
488
|
+
}
|
|
489
|
+
function partOfDay(time) {
|
|
490
|
+
const hour = Number(time.slice(0, 2));
|
|
491
|
+
if (hour < 3) return "OVERNIGHT";
|
|
492
|
+
if (hour < 6) return "PRE_DAWN";
|
|
493
|
+
if (hour < 9) return "EARLY_MORNING";
|
|
494
|
+
if (hour < 12) return "LATE_MORNING";
|
|
495
|
+
if (hour < 15) return "EARLY_AFTERNOON";
|
|
496
|
+
if (hour < 18) return "LATE_AFTERNOON";
|
|
497
|
+
if (hour < 21) return "EARLY_EVENING";
|
|
498
|
+
return "LATE_EVENING";
|
|
499
|
+
}
|
|
500
|
+
var MINUTES_IN_DAY = 24 * 60;
|
|
501
|
+
function minutesOfDay(time) {
|
|
502
|
+
return Number(time.slice(0, 2)) * 60 + Number(time.slice(3, 5));
|
|
503
|
+
}
|
|
504
|
+
function formatSlotRange(startTime, endTime) {
|
|
505
|
+
return endTime === null ? startTime : `${startTime} - ${endTime}`;
|
|
506
|
+
}
|
|
507
|
+
function formatSlotDuration(startTime, endTime) {
|
|
508
|
+
if (endTime === null) return null;
|
|
509
|
+
const minutes = (minutesOfDay(endTime) - minutesOfDay(startTime) + MINUTES_IN_DAY) % MINUTES_IN_DAY;
|
|
510
|
+
if (!Number.isFinite(minutes) || minutes <= 0) return null;
|
|
511
|
+
const hours = Math.floor(minutes / 60);
|
|
512
|
+
const rest = minutes % 60;
|
|
513
|
+
if (hours === 0) return `${rest}m`;
|
|
514
|
+
return rest === 0 ? `${hours}h` : `${hours}h ${rest}m`;
|
|
515
|
+
}
|
|
516
|
+
function withSelectedDay(selection, day) {
|
|
517
|
+
return selection.day === day ? selection : { day, startTime: null };
|
|
518
|
+
}
|
|
519
|
+
function withSelectedTime(selection, startTime) {
|
|
520
|
+
return { day: selection.day, startTime };
|
|
521
|
+
}
|
|
522
|
+
function hasStarted(slot, options) {
|
|
523
|
+
if (options.selection.day < options.today) return true;
|
|
524
|
+
if (options.selection.day > options.today) return false;
|
|
525
|
+
return slot.startTime <= options.nowTime;
|
|
526
|
+
}
|
|
527
|
+
function timeslotState(slot, options) {
|
|
528
|
+
if (hasStarted(slot, options)) return "PAST_BUT_RELEVANT";
|
|
529
|
+
if (slot.remaining !== null && slot.remaining <= 0) return "UNAVAILABLE";
|
|
530
|
+
return slot.startTime === options.selection.startTime ? "SELECTED" : "AVAILABLE";
|
|
531
|
+
}
|
|
532
|
+
function sameTimeslots(a, b) {
|
|
533
|
+
if (a === b) return true;
|
|
534
|
+
if (a.length !== b.length) return false;
|
|
535
|
+
return a.every((slot, index) => {
|
|
536
|
+
const other = b[index];
|
|
537
|
+
return slot.startTime === other.startTime && slot.endTime === other.endTime && slot.remaining === other.remaining;
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
function buildTimeslotGroups(slots, options) {
|
|
541
|
+
const groups = [];
|
|
542
|
+
const byPart = /* @__PURE__ */ new Map();
|
|
543
|
+
const chronological = [...slots].sort((a, b) => a.startTime.localeCompare(b.startTime));
|
|
544
|
+
const cellFor = (slot) => ({
|
|
545
|
+
slot,
|
|
546
|
+
part: partOfDay(slot.startTime),
|
|
547
|
+
state: timeslotState(slot, options),
|
|
548
|
+
duration: formatSlotDuration(slot.startTime, slot.endTime)
|
|
549
|
+
});
|
|
550
|
+
if ((options.grouping ?? "PART_OF_DAY") === "NONE") {
|
|
551
|
+
return chronological.length === 0 ? [] : [{ part: null, label: null, cells: chronological.map(cellFor) }];
|
|
552
|
+
}
|
|
553
|
+
for (const slot of chronological) {
|
|
554
|
+
const part = partOfDay(slot.startTime);
|
|
555
|
+
let group = byPart.get(part);
|
|
556
|
+
if (!group) {
|
|
557
|
+
group = { part, label: partOfDayLabel(part), cells: [] };
|
|
558
|
+
byPart.set(part, group);
|
|
559
|
+
groups.push(group);
|
|
560
|
+
}
|
|
561
|
+
group.cells.push(cellFor(slot));
|
|
562
|
+
}
|
|
563
|
+
return groups;
|
|
564
|
+
}
|
|
565
|
+
function timeslotRequest(day, startTime, schedule) {
|
|
566
|
+
if (day === void 0 || startTime === void 0 || startTime === "") return void 0;
|
|
567
|
+
const slot = schedule?.slotsByDay?.[day]?.find((candidate) => candidate.startTime === startTime);
|
|
568
|
+
if (slot === void 0) return void 0;
|
|
569
|
+
const ends = slot.endTime ?? slot.startTime;
|
|
570
|
+
return { LocalStartTime: `${slot.startTime}:00`, LocalEndTime: `${ends}:00` };
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// src/domain/user-types.ts
|
|
574
|
+
function agreed(values) {
|
|
575
|
+
const first = values[0];
|
|
576
|
+
if (first === void 0) return null;
|
|
577
|
+
return values.every((value) => value === first) ? first : null;
|
|
578
|
+
}
|
|
579
|
+
function groupUserTypes(rows) {
|
|
580
|
+
const byName = /* @__PURE__ */ new Map();
|
|
581
|
+
for (const row of rows) {
|
|
582
|
+
if (row.Name === "") continue;
|
|
583
|
+
const group = byName.get(row.Name);
|
|
584
|
+
if (group === void 0) byName.set(row.Name, [row]);
|
|
585
|
+
else group.push(row);
|
|
586
|
+
}
|
|
587
|
+
return [...byName.entries()].map(([name, group]) => ({
|
|
588
|
+
key: name,
|
|
589
|
+
name,
|
|
590
|
+
note: agreed(group.map((row) => row.Note ?? null))
|
|
591
|
+
}));
|
|
592
|
+
}
|
|
593
|
+
function partyTypes(host, fetched, asking) {
|
|
594
|
+
if (host.length > 0) return { status: "KNOWN", types: host };
|
|
595
|
+
if (fetched !== void 0) return { status: "KNOWN", types: fetched };
|
|
596
|
+
return asking ? { status: "ASKING" } : { status: "KNOWN", types: [] };
|
|
597
|
+
}
|
|
598
|
+
function assignmentFor(product, key) {
|
|
599
|
+
if (product.UserTypes === void 0) return key;
|
|
600
|
+
const offered = product.UserTypes ?? [];
|
|
601
|
+
const byName = offered.find((type) => type.Name === key);
|
|
602
|
+
if (byName !== void 0) return byName.AssignmentKey;
|
|
603
|
+
return offered.some((type) => type.AssignmentKey === key) ? key : void 0;
|
|
604
|
+
}
|
|
605
|
+
function userTypeNames(rows) {
|
|
606
|
+
return Object.fromEntries(rows.map((row) => [row.AssignmentKey, row.Name]));
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// src/island/PartyStepper.tsx
|
|
610
|
+
import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
611
|
+
import { MinusMarkIcon, PlusMarkIcon } from "@scopetickets/icons";
|
|
612
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
613
|
+
function UserTypeRow({
|
|
614
|
+
option,
|
|
615
|
+
count,
|
|
616
|
+
atLimit,
|
|
617
|
+
onAdd,
|
|
618
|
+
onRemove,
|
|
619
|
+
onSet,
|
|
620
|
+
max,
|
|
621
|
+
onRefuse
|
|
622
|
+
}) {
|
|
623
|
+
return /* @__PURE__ */ jsxs("div", { className: "scopetickets-island-party-row", children: [
|
|
624
|
+
/* @__PURE__ */ jsxs("span", { className: "scopetickets-island-party-row__text", children: [
|
|
625
|
+
/* @__PURE__ */ jsx("span", { className: "scopetickets-island-party-row__name", children: option.name }),
|
|
626
|
+
option.note !== null && /* @__PURE__ */ jsx("span", { className: "scopetickets-island-party-row__note", children: option.note })
|
|
627
|
+
] }),
|
|
628
|
+
/* @__PURE__ */ jsx(
|
|
629
|
+
UserTypeStepper,
|
|
630
|
+
{
|
|
631
|
+
name: option.name,
|
|
632
|
+
count,
|
|
633
|
+
atLimit,
|
|
634
|
+
onAdd,
|
|
635
|
+
onRemove,
|
|
636
|
+
onSet,
|
|
637
|
+
max,
|
|
638
|
+
onRefuse
|
|
639
|
+
}
|
|
640
|
+
)
|
|
641
|
+
] });
|
|
642
|
+
}
|
|
643
|
+
function UserTypeStepper({
|
|
644
|
+
name,
|
|
645
|
+
count,
|
|
646
|
+
atLimit,
|
|
647
|
+
onAdd,
|
|
648
|
+
onRemove,
|
|
649
|
+
onSet,
|
|
650
|
+
max,
|
|
651
|
+
onRefuse
|
|
652
|
+
}) {
|
|
653
|
+
const chosen = count > 0;
|
|
654
|
+
return /* @__PURE__ */ jsxs("span", { className: "scopetickets-island-stepper", "data-expanded": chosen ? "" : void 0, children: [
|
|
655
|
+
/* @__PURE__ */ jsx(
|
|
656
|
+
"span",
|
|
657
|
+
{
|
|
658
|
+
className: "scopetickets-island-stepper__opening",
|
|
659
|
+
"aria-hidden": chosen ? void 0 : "true",
|
|
660
|
+
children: /* @__PURE__ */ jsxs("span", { className: "scopetickets-island-stepper__opening-inner", children: [
|
|
661
|
+
/* @__PURE__ */ jsx(
|
|
662
|
+
StepperButton,
|
|
663
|
+
{
|
|
664
|
+
label: `Remove one ${name}`,
|
|
665
|
+
onPress: onRemove,
|
|
666
|
+
kind: "remove",
|
|
667
|
+
state: chosen ? "LIVE" : "CLOSED"
|
|
668
|
+
}
|
|
669
|
+
),
|
|
670
|
+
/* @__PURE__ */ jsx(
|
|
671
|
+
TypedCount,
|
|
672
|
+
{
|
|
673
|
+
count,
|
|
674
|
+
name,
|
|
675
|
+
onSet,
|
|
676
|
+
valueClassName: "scopetickets-island-stepper__value",
|
|
677
|
+
inputClassName: "scopetickets-island-stepper__input",
|
|
678
|
+
closed: !chosen,
|
|
679
|
+
max,
|
|
680
|
+
onRefuse
|
|
681
|
+
}
|
|
682
|
+
)
|
|
683
|
+
] })
|
|
684
|
+
}
|
|
685
|
+
),
|
|
686
|
+
/* @__PURE__ */ jsx(
|
|
687
|
+
StepperButton,
|
|
688
|
+
{
|
|
689
|
+
label: `Add one ${name}`,
|
|
690
|
+
onPress: onAdd,
|
|
691
|
+
kind: "add",
|
|
692
|
+
state: atLimit ? "REFUSING" : "LIVE"
|
|
693
|
+
}
|
|
694
|
+
)
|
|
695
|
+
] });
|
|
696
|
+
}
|
|
697
|
+
function StepperButton({
|
|
698
|
+
label,
|
|
699
|
+
onPress,
|
|
700
|
+
kind,
|
|
701
|
+
state = "LIVE"
|
|
702
|
+
}) {
|
|
703
|
+
const press = useIslandPress("element");
|
|
704
|
+
return /* @__PURE__ */ jsx(
|
|
705
|
+
"button",
|
|
706
|
+
{
|
|
707
|
+
type: "button",
|
|
708
|
+
className: "scopetickets-island-stepper__button",
|
|
709
|
+
"data-kind": kind,
|
|
710
|
+
"aria-label": label,
|
|
711
|
+
"aria-disabled": state === "REFUSING" ? true : void 0,
|
|
712
|
+
disabled: state === "CLOSED",
|
|
713
|
+
onClick: state === "LIVE" ? onPress : void 0,
|
|
714
|
+
...press,
|
|
715
|
+
children: /* @__PURE__ */ jsx("span", { className: "scopetickets-island-stepper__mark", children: kind === "add" ? /* @__PURE__ */ jsx(PlusMarkIcon, { fill: true, color: "currentColor" }) : /* @__PURE__ */ jsx(MinusMarkIcon, { fill: true, color: "currentColor" }) })
|
|
716
|
+
}
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
function SoloPartyStepper({ max, name, count, onSet, onRemove, onRefuse }) {
|
|
720
|
+
return /* @__PURE__ */ jsxs("div", { className: "scopetickets-island-party-solo", children: [
|
|
721
|
+
/* @__PURE__ */ jsx(
|
|
722
|
+
StepperButton,
|
|
723
|
+
{
|
|
724
|
+
label: `Remove one ${name}`,
|
|
725
|
+
onPress: onRemove,
|
|
726
|
+
kind: "remove",
|
|
727
|
+
state: count === 0 ? "REFUSING" : "LIVE"
|
|
728
|
+
}
|
|
729
|
+
),
|
|
730
|
+
/* @__PURE__ */ jsx(
|
|
731
|
+
TypedCount,
|
|
732
|
+
{
|
|
733
|
+
count,
|
|
734
|
+
name,
|
|
735
|
+
onSet,
|
|
736
|
+
valueClassName: "scopetickets-island-party-solo__value",
|
|
737
|
+
inputClassName: "scopetickets-island-party-solo__input",
|
|
738
|
+
max,
|
|
739
|
+
onRefuse
|
|
740
|
+
}
|
|
741
|
+
),
|
|
742
|
+
/* @__PURE__ */ jsx(
|
|
743
|
+
StepperButton,
|
|
744
|
+
{
|
|
745
|
+
label: `Add one ${name}`,
|
|
746
|
+
onPress: () => onSet(count + 1),
|
|
747
|
+
kind: "add",
|
|
748
|
+
state: count >= max ? "REFUSING" : "LIVE"
|
|
749
|
+
}
|
|
750
|
+
)
|
|
751
|
+
] });
|
|
752
|
+
}
|
|
753
|
+
function TypedCount({
|
|
754
|
+
count,
|
|
755
|
+
name,
|
|
756
|
+
onSet,
|
|
757
|
+
valueClassName,
|
|
758
|
+
inputClassName,
|
|
759
|
+
onRefuse,
|
|
760
|
+
closed = false,
|
|
761
|
+
max
|
|
762
|
+
}) {
|
|
763
|
+
const [typing, setTyping] = useState2(null);
|
|
764
|
+
const field = useRef2(null);
|
|
765
|
+
const editing = typing !== null;
|
|
766
|
+
useEffect2(() => {
|
|
767
|
+
if (!editing) return;
|
|
768
|
+
field.current?.focus({ preventScroll: true });
|
|
769
|
+
}, [editing]);
|
|
770
|
+
const commit = () => {
|
|
771
|
+
if (typing === null) return;
|
|
772
|
+
const asked = Number.parseInt(typing, 10);
|
|
773
|
+
setTyping(null);
|
|
774
|
+
if (!Number.isFinite(asked)) return;
|
|
775
|
+
if (max !== void 0 && asked > max) {
|
|
776
|
+
onRefuse?.(asked);
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
onRefuse?.(null);
|
|
780
|
+
onSet(Math.max(0, asked));
|
|
781
|
+
};
|
|
782
|
+
if (typing === null) {
|
|
783
|
+
return /* @__PURE__ */ jsx(
|
|
784
|
+
"button",
|
|
785
|
+
{
|
|
786
|
+
type: "button",
|
|
787
|
+
className: valueClassName,
|
|
788
|
+
"aria-label": `${count} ${name}. Change the number`,
|
|
789
|
+
onClick: () => setTyping(String(count)),
|
|
790
|
+
disabled: closed,
|
|
791
|
+
children: count
|
|
792
|
+
}
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
return /* @__PURE__ */ jsx(
|
|
796
|
+
"input",
|
|
797
|
+
{
|
|
798
|
+
className: inputClassName,
|
|
799
|
+
type: "text",
|
|
800
|
+
inputMode: "numeric",
|
|
801
|
+
pattern: "[0-9]*",
|
|
802
|
+
size: 1,
|
|
803
|
+
ref: field,
|
|
804
|
+
"aria-label": `Number of ${name}`,
|
|
805
|
+
value: typing,
|
|
806
|
+
onChange: (event) => setTyping(event.target.value.replace(/\D/g, "")),
|
|
807
|
+
onBlur: commit,
|
|
808
|
+
onKeyDown: (event) => {
|
|
809
|
+
if (event.key === "Enter") commit();
|
|
810
|
+
else if (event.key === "Escape") setTyping(null);
|
|
811
|
+
else return;
|
|
812
|
+
event.preventDefault();
|
|
813
|
+
event.stopPropagation();
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
);
|
|
817
|
+
}
|
|
818
|
+
function PartyStepper({
|
|
819
|
+
userTypes,
|
|
820
|
+
counts,
|
|
821
|
+
onChange,
|
|
822
|
+
max,
|
|
823
|
+
soloName = "Guests",
|
|
824
|
+
onRefuse,
|
|
825
|
+
refused = null
|
|
826
|
+
}) {
|
|
827
|
+
const headcount = Object.values(counts).reduce((total, n2) => total + n2, 0);
|
|
828
|
+
const refuse = (asked) => onRefuse?.(asked);
|
|
829
|
+
const shown = (count) => refused === null ? count : refused;
|
|
830
|
+
if (userTypes.length === 0) {
|
|
831
|
+
return /* @__PURE__ */ jsx("div", { className: "scopetickets-island-party", "data-excess": refused === null ? void 0 : "", children: /* @__PURE__ */ jsx(
|
|
832
|
+
SoloPartyStepper,
|
|
833
|
+
{
|
|
834
|
+
max,
|
|
835
|
+
name: soloName,
|
|
836
|
+
count: shown(headcount),
|
|
837
|
+
onSet: (next) => {
|
|
838
|
+
refuse(null);
|
|
839
|
+
onChange(SOLO_KEY, next);
|
|
840
|
+
},
|
|
841
|
+
onRemove: () => refused === null ? onChange(SOLO_KEY, Math.max(0, headcount - 1)) : (refuse(null), onChange(SOLO_KEY, max)),
|
|
842
|
+
onRefuse: refuse
|
|
843
|
+
}
|
|
844
|
+
) });
|
|
845
|
+
}
|
|
846
|
+
return /* @__PURE__ */ jsx("div", { className: "scopetickets-island-party", "data-excess": refused === null ? void 0 : "", children: userTypes.map((option) => /* @__PURE__ */ jsx(
|
|
847
|
+
UserTypeRow,
|
|
848
|
+
{
|
|
849
|
+
option,
|
|
850
|
+
count: counts[option.key] ?? 0,
|
|
851
|
+
atLimit: headcount >= max,
|
|
852
|
+
onAdd: () => {
|
|
853
|
+
refuse(null);
|
|
854
|
+
onChange(option.key, (counts[option.key] ?? 0) + 1);
|
|
855
|
+
},
|
|
856
|
+
onRemove: () => {
|
|
857
|
+
refuse(null);
|
|
858
|
+
onChange(option.key, Math.max(0, (counts[option.key] ?? 0) - 1));
|
|
859
|
+
},
|
|
860
|
+
onSet: (next) => {
|
|
861
|
+
refuse(null);
|
|
862
|
+
onChange(option.key, next);
|
|
863
|
+
},
|
|
864
|
+
max,
|
|
865
|
+
onRefuse: refuse
|
|
866
|
+
},
|
|
867
|
+
option.key
|
|
868
|
+
)) });
|
|
869
|
+
}
|
|
870
|
+
var SOLO_KEY = "default";
|
|
871
|
+
|
|
872
|
+
// src/island/ContentFlag.tsx
|
|
873
|
+
import {
|
|
874
|
+
CheckInCircleFilledIcon,
|
|
875
|
+
ExclamationMarkInCircleFilledIcon,
|
|
876
|
+
XMarkInCircleFilledIcon
|
|
877
|
+
} from "@scopetickets/icons";
|
|
878
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
879
|
+
function flagTone(flag) {
|
|
880
|
+
return flag === "none" ? void 0 : flag;
|
|
881
|
+
}
|
|
882
|
+
var GLYPH = {
|
|
883
|
+
success: CheckInCircleFilledIcon,
|
|
884
|
+
warning: ExclamationMarkInCircleFilledIcon,
|
|
885
|
+
error: XMarkInCircleFilledIcon
|
|
886
|
+
};
|
|
887
|
+
function ContentFlag({ tone, title }) {
|
|
888
|
+
const Glyph = GLYPH[tone];
|
|
889
|
+
return /* @__PURE__ */ jsx2("span", { className: `scopetickets-island-content-flag scopetickets-island-content-flag--${tone}`, children: /* @__PURE__ */ jsx2(Glyph, { fill: true, color: "currentColor", title }) });
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// src/island/CounterRing.tsx
|
|
893
|
+
import { IconGlyph } from "@scopetickets/icons";
|
|
894
|
+
|
|
895
|
+
// src/island/island-timer.ts
|
|
896
|
+
var TIMER_GRID = 20;
|
|
897
|
+
var TIMER_CENTRE = TIMER_GRID / 2;
|
|
898
|
+
var RING_OUTER = 10;
|
|
899
|
+
var RING_INNER = 8;
|
|
900
|
+
var RING_RADIUS = (RING_OUTER + RING_INNER) / 2;
|
|
901
|
+
var RING_WIDTH = RING_OUTER - RING_INNER;
|
|
902
|
+
var TURN_DEGREES = 360;
|
|
903
|
+
var SOURCE_GRID = 100;
|
|
904
|
+
var SOURCE_OFFSET_X = 0.2;
|
|
905
|
+
var SOURCE_SCALE = TIMER_GRID / SOURCE_GRID;
|
|
906
|
+
var HAND_SOURCE = "M55.2,49.9l-.7-26c0-1-.4-2.1-1.2-2.9-1.7-1.7-4.4-1.7-6,0s-1.2,1.8-1.2,2.9l-.7,26c0,1.3.4,2.7,1.5,3.7,2,2,5.1,2,7.1,0s1.5-2.4,1.5-3.7Z";
|
|
907
|
+
function n(value) {
|
|
908
|
+
const rounded = Number(value.toFixed(3));
|
|
909
|
+
return String(Object.is(rounded, -0) ? 0 : rounded);
|
|
910
|
+
}
|
|
911
|
+
function pointAt(radius, degrees) {
|
|
912
|
+
const radians = degrees * Math.PI / 180;
|
|
913
|
+
return {
|
|
914
|
+
x: TIMER_CENTRE + radius * Math.sin(radians),
|
|
915
|
+
y: TIMER_CENTRE - radius * Math.cos(radians)
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
function circlePath(centre, radius) {
|
|
919
|
+
const r = `${n(radius)},${n(radius)}`;
|
|
920
|
+
return `M${n(centre.x - radius)},${n(centre.y)}A${r} 0 1 0 ${n(centre.x + radius)},${n(centre.y)}A${r} 0 1 0 ${n(centre.x - radius)},${n(centre.y)}Z`;
|
|
921
|
+
}
|
|
922
|
+
function clampRemaining(remaining) {
|
|
923
|
+
if (!Number.isFinite(remaining)) return 0;
|
|
924
|
+
return Math.min(1, Math.max(0, remaining));
|
|
925
|
+
}
|
|
926
|
+
function handRotation(remaining) {
|
|
927
|
+
return (clampRemaining(remaining) - 1) * TURN_DEGREES;
|
|
928
|
+
}
|
|
929
|
+
function transformPath(source, degrees) {
|
|
930
|
+
const radians = degrees * Math.PI / 180;
|
|
931
|
+
const cos = Math.cos(radians);
|
|
932
|
+
const sin = Math.sin(radians);
|
|
933
|
+
const linear = (x, y) => {
|
|
934
|
+
const sx = x * SOURCE_SCALE;
|
|
935
|
+
const sy = y * SOURCE_SCALE;
|
|
936
|
+
return { x: sx * cos - sy * sin, y: sx * sin + sy * cos };
|
|
937
|
+
};
|
|
938
|
+
const absolute = (x, y) => {
|
|
939
|
+
const to = linear(x - SOURCE_OFFSET_X - SOURCE_GRID / 2, y - SOURCE_GRID / 2);
|
|
940
|
+
return { x: TIMER_CENTRE + to.x, y: TIMER_CENTRE + to.y };
|
|
941
|
+
};
|
|
942
|
+
const pair = (p) => `${n(p.x)},${n(p.y)}`;
|
|
943
|
+
const segments = source.match(/[a-zA-Z][^a-zA-Z]*/g) ?? [];
|
|
944
|
+
return segments.map((segment) => {
|
|
945
|
+
const command = segment[0];
|
|
946
|
+
const numbers = (segment.slice(1).match(/-?(?:\d*\.\d+|\d+)/g) ?? []).map(Number);
|
|
947
|
+
const deltas = (stride) => {
|
|
948
|
+
if (numbers.length === 0 || numbers.length % stride !== 0) {
|
|
949
|
+
throw new Error(`path: \`${command}\` wants multiples of ${stride}`);
|
|
950
|
+
}
|
|
951
|
+
const out = [];
|
|
952
|
+
for (let i = 0; i < numbers.length; i += 2) {
|
|
953
|
+
out.push(pair(linear(numbers[i], numbers[i + 1])));
|
|
954
|
+
}
|
|
955
|
+
return command + out.join(" ");
|
|
956
|
+
};
|
|
957
|
+
switch (command) {
|
|
958
|
+
case "M": {
|
|
959
|
+
if (numbers.length !== 2) throw new Error("path: `M` wants exactly one point");
|
|
960
|
+
return `M${pair(absolute(numbers[0], numbers[1]))}`;
|
|
961
|
+
}
|
|
962
|
+
case "l":
|
|
963
|
+
return deltas(2);
|
|
964
|
+
case "c":
|
|
965
|
+
return deltas(6);
|
|
966
|
+
case "s":
|
|
967
|
+
return deltas(4);
|
|
968
|
+
case "Z":
|
|
969
|
+
case "z":
|
|
970
|
+
return "Z";
|
|
971
|
+
default:
|
|
972
|
+
throw new Error(`path: unsupported command \`${command}\``);
|
|
973
|
+
}
|
|
974
|
+
}).join("");
|
|
975
|
+
}
|
|
976
|
+
function annulus(outer = RING_OUTER, inner = RING_INNER) {
|
|
977
|
+
const centre = pointAt(0, 0);
|
|
978
|
+
return circlePath(centre, outer) + circlePath(centre, inner);
|
|
979
|
+
}
|
|
980
|
+
function ringSector(fraction, outer, inner, direction = "cw") {
|
|
981
|
+
const filled = clampRemaining(fraction);
|
|
982
|
+
if (filled <= 0 || filled >= 1) return null;
|
|
983
|
+
const mirrored = direction === "ccw";
|
|
984
|
+
const sweep = filled * TURN_DEGREES * (mirrored ? -1 : 1);
|
|
985
|
+
const capRadius = (outer - inner) / 2;
|
|
986
|
+
const outerStart = pointAt(outer, 0);
|
|
987
|
+
const outerEnd = pointAt(outer, sweep);
|
|
988
|
+
const innerEnd = pointAt(inner, sweep);
|
|
989
|
+
const innerStart = pointAt(inner, 0);
|
|
990
|
+
const out = mirrored ? 0 : 1;
|
|
991
|
+
const back = mirrored ? 1 : 0;
|
|
992
|
+
const large = Math.abs(sweep) > 180 ? 1 : 0;
|
|
993
|
+
const cap = `${n(capRadius)},${n(capRadius)}`;
|
|
994
|
+
const at = (p) => `${n(p.x)},${n(p.y)}`;
|
|
995
|
+
return {
|
|
996
|
+
d: `M${at(outerStart)}A${n(outer)},${n(outer)} 0 ${large} ${out} ${at(outerEnd)}A${cap} 0 0 ${out} ${at(innerEnd)}A${n(inner)},${n(inner)} 0 ${large} ${back} ${at(innerStart)}A${cap} 0 0 ${out} ${at(outerStart)}Z`
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
function ringAnnulus(outer, inner) {
|
|
1000
|
+
return { d: annulus(outer, inner), evenodd: true };
|
|
1001
|
+
}
|
|
1002
|
+
function trackPaths() {
|
|
1003
|
+
return [{ d: annulus(), evenodd: true }];
|
|
1004
|
+
}
|
|
1005
|
+
function timerPaths(remaining) {
|
|
1006
|
+
const left = clampRemaining(remaining);
|
|
1007
|
+
const paths = [];
|
|
1008
|
+
if (left >= 1) paths.push(ringAnnulus(RING_OUTER, RING_INNER));
|
|
1009
|
+
else {
|
|
1010
|
+
const sector = ringSector(left, RING_OUTER, RING_INNER);
|
|
1011
|
+
if (sector) paths.push(sector);
|
|
1012
|
+
}
|
|
1013
|
+
paths.push({ d: transformPath(HAND_SOURCE, handRotation(left)) });
|
|
1014
|
+
return paths;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// src/island/island-counter-ring.ts
|
|
1018
|
+
var RING_OUTER2 = 10;
|
|
1019
|
+
var RING_STROKE = 2.5;
|
|
1020
|
+
var RING_INNER2 = RING_OUTER2 - RING_STROKE;
|
|
1021
|
+
function counterTrackPaths() {
|
|
1022
|
+
return [ringAnnulus(RING_OUTER2, RING_INNER2)];
|
|
1023
|
+
}
|
|
1024
|
+
function counterRingPaths(progress, direction = "cw") {
|
|
1025
|
+
if (progress >= 1) return [ringAnnulus(RING_OUTER2, RING_INNER2)];
|
|
1026
|
+
const sector = ringSector(progress, RING_OUTER2, RING_INNER2, direction);
|
|
1027
|
+
return sector ? [sector] : [];
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// src/island/CounterRing.tsx
|
|
1031
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1032
|
+
var LAYER = { position: "absolute", inset: 0 };
|
|
1033
|
+
var DEFAULT_FILL = "var(--scopetickets-island-counter-ring-fill)";
|
|
1034
|
+
var DEFAULT_TRACK = "var(--scopetickets-island-counter-ring-track)";
|
|
1035
|
+
function CounterRing({
|
|
1036
|
+
progress,
|
|
1037
|
+
complete,
|
|
1038
|
+
size = "1em",
|
|
1039
|
+
title,
|
|
1040
|
+
color = DEFAULT_FILL,
|
|
1041
|
+
trackColor = DEFAULT_TRACK,
|
|
1042
|
+
direction = "cw",
|
|
1043
|
+
track = true
|
|
1044
|
+
}) {
|
|
1045
|
+
if (complete !== void 0) {
|
|
1046
|
+
return /* @__PURE__ */ jsx3(
|
|
1047
|
+
"span",
|
|
1048
|
+
{
|
|
1049
|
+
className: "scopetickets-island-counter-ring",
|
|
1050
|
+
style: { width: size, height: size, flex: "none" },
|
|
1051
|
+
children: /* @__PURE__ */ jsx3(ContentFlag, { tone: complete, title })
|
|
1052
|
+
}
|
|
1053
|
+
);
|
|
1054
|
+
}
|
|
1055
|
+
return /* @__PURE__ */ jsxs2(
|
|
1056
|
+
"span",
|
|
1057
|
+
{
|
|
1058
|
+
className: "scopetickets-island-counter-ring",
|
|
1059
|
+
style: { position: "relative", display: "block", width: size, height: size, flex: "none" },
|
|
1060
|
+
children: [
|
|
1061
|
+
track ? /* @__PURE__ */ jsx3("span", { style: LAYER, children: /* @__PURE__ */ jsx3(
|
|
1062
|
+
IconGlyph,
|
|
1063
|
+
{
|
|
1064
|
+
glyph: "StepCompletionProgressRingTrack",
|
|
1065
|
+
paths: counterTrackPaths(),
|
|
1066
|
+
color: trackColor,
|
|
1067
|
+
fill: true
|
|
1068
|
+
}
|
|
1069
|
+
) }) : null,
|
|
1070
|
+
/* @__PURE__ */ jsx3("span", { style: LAYER, children: /* @__PURE__ */ jsx3(
|
|
1071
|
+
IconGlyph,
|
|
1072
|
+
{
|
|
1073
|
+
glyph: "StepCompletionProgressRing",
|
|
1074
|
+
paths: counterRingPaths(progress, direction),
|
|
1075
|
+
color,
|
|
1076
|
+
title,
|
|
1077
|
+
fill: true
|
|
1078
|
+
}
|
|
1079
|
+
) })
|
|
1080
|
+
]
|
|
1081
|
+
}
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// src/island/DayPicker.tsx
|
|
1086
|
+
import { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo2, useState as useState4 } from "react";
|
|
1087
|
+
|
|
1088
|
+
// src/island/CalendarMonthHeading.tsx
|
|
1089
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1090
|
+
function CalendarMonthHeading({ month }) {
|
|
1091
|
+
return /* @__PURE__ */ jsx4("h3", { className: "scopetickets-island-calendar__heading", children: formatMonthName(month) });
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
// src/island/CalendarDayIndicator.tsx
|
|
1095
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1096
|
+
var SEGMENTS = 3;
|
|
1097
|
+
var FILLED_SEGMENTS = {
|
|
1098
|
+
LOW: 1,
|
|
1099
|
+
MEDIUM: 2,
|
|
1100
|
+
HIGH: 3
|
|
1101
|
+
};
|
|
1102
|
+
function CalendarDayIndicator({ level }) {
|
|
1103
|
+
const filled = FILLED_SEGMENTS[level];
|
|
1104
|
+
return (
|
|
1105
|
+
// DECORATIVE, and now correctly so.
|
|
1106
|
+
/* @__PURE__ */ jsxs3("span", { className: "scopetickets-island-day-indicator", "aria-hidden": "true", children: [
|
|
1107
|
+
/* @__PURE__ */ jsx5(
|
|
1108
|
+
"span",
|
|
1109
|
+
{
|
|
1110
|
+
className: `scopetickets-island-day-indicator__fill scopetickets-island-day-indicator__fill--${level.toLowerCase()}`,
|
|
1111
|
+
style: { flexGrow: filled }
|
|
1112
|
+
}
|
|
1113
|
+
),
|
|
1114
|
+
filled < SEGMENTS ? /* @__PURE__ */ jsx5("span", { style: { flexGrow: SEGMENTS - filled } }) : null
|
|
1115
|
+
] })
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
// src/island/CalendarDay.tsx
|
|
1120
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1121
|
+
function CalendarDay({
|
|
1122
|
+
cell,
|
|
1123
|
+
accessory,
|
|
1124
|
+
remaining,
|
|
1125
|
+
label,
|
|
1126
|
+
outsideMonth = false,
|
|
1127
|
+
onSelect
|
|
1128
|
+
}) {
|
|
1129
|
+
const press = useIslandPress("element");
|
|
1130
|
+
const dimmed = outsideMonth ? { "data-outside-month": "" } : null;
|
|
1131
|
+
if (cell.kind === "EMPTY") {
|
|
1132
|
+
return /* @__PURE__ */ jsx6("span", { className: "scopetickets-island-day", "aria-hidden": "true" });
|
|
1133
|
+
}
|
|
1134
|
+
if (isSelectableCalendarCell(cell)) {
|
|
1135
|
+
return /* @__PURE__ */ jsx6(
|
|
1136
|
+
CalendarDayButton,
|
|
1137
|
+
{
|
|
1138
|
+
cell,
|
|
1139
|
+
accessory,
|
|
1140
|
+
remaining,
|
|
1141
|
+
label,
|
|
1142
|
+
onSelect,
|
|
1143
|
+
outsideMonth,
|
|
1144
|
+
press
|
|
1145
|
+
}
|
|
1146
|
+
);
|
|
1147
|
+
}
|
|
1148
|
+
if (cell.kind === "UNAVAILABLE") {
|
|
1149
|
+
return /* @__PURE__ */ jsx6(
|
|
1150
|
+
CalendarDayButton,
|
|
1151
|
+
{
|
|
1152
|
+
cell,
|
|
1153
|
+
accessory,
|
|
1154
|
+
remaining: null,
|
|
1155
|
+
label,
|
|
1156
|
+
outsideMonth,
|
|
1157
|
+
press
|
|
1158
|
+
}
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
return /* @__PURE__ */ jsx6("span", { className: "scopetickets-island-day", ...dimmed, ...press, children: /* @__PURE__ */ jsx6("span", { className: "scopetickets-island-day__well", "data-state": cell.kind, children: /* @__PURE__ */ jsx6("span", { className: "scopetickets-island-day__number", children: cell.dayOfMonth }) }) });
|
|
1162
|
+
}
|
|
1163
|
+
function CalendarDayButton({
|
|
1164
|
+
cell,
|
|
1165
|
+
accessory,
|
|
1166
|
+
remaining,
|
|
1167
|
+
label,
|
|
1168
|
+
outsideMonth = false,
|
|
1169
|
+
press,
|
|
1170
|
+
onSelect
|
|
1171
|
+
}) {
|
|
1172
|
+
const selected = cell.kind === "SELECTED";
|
|
1173
|
+
const availability = readAvailability(remaining);
|
|
1174
|
+
return /* @__PURE__ */ jsx6(
|
|
1175
|
+
"button",
|
|
1176
|
+
{
|
|
1177
|
+
type: "button",
|
|
1178
|
+
className: "scopetickets-island-day",
|
|
1179
|
+
...outsideMonth ? { "data-outside-month": "" } : null,
|
|
1180
|
+
"aria-pressed": onSelect ? selected : void 0,
|
|
1181
|
+
"aria-disabled": onSelect ? void 0 : true,
|
|
1182
|
+
"aria-label": availability === null ? label : `${label}, ${availability.announcement}`,
|
|
1183
|
+
onClick: onSelect ? () => onSelect(cell.day) : void 0,
|
|
1184
|
+
...press,
|
|
1185
|
+
children: /* @__PURE__ */ jsxs4("span", { className: "scopetickets-island-day__well", "data-state": cell.kind, children: [
|
|
1186
|
+
/* @__PURE__ */ jsx6("span", { className: "scopetickets-island-day__number", children: cell.dayOfMonth }),
|
|
1187
|
+
cell.kind === "UNAVAILABLE" ? /* @__PURE__ */ jsx6("span", { className: "scopetickets-island-day__strike", "aria-hidden": "true" }) : null,
|
|
1188
|
+
accessory === "LINE" && availability !== null ? /* @__PURE__ */ jsx6("span", { className: "scopetickets-island-day__accessory", children: /* @__PURE__ */ jsx6(CalendarDayIndicator, { level: availability.level }) }) : null
|
|
1189
|
+
] })
|
|
1190
|
+
}
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
// src/island/CalendarRunGrid.tsx
|
|
1195
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1196
|
+
function CalendarRunGrid({
|
|
1197
|
+
series,
|
|
1198
|
+
weeks,
|
|
1199
|
+
currentMonth,
|
|
1200
|
+
accessory,
|
|
1201
|
+
remaining,
|
|
1202
|
+
today,
|
|
1203
|
+
selectedDay,
|
|
1204
|
+
onSelectDay
|
|
1205
|
+
}) {
|
|
1206
|
+
return /* @__PURE__ */ jsx7("div", { className: "scopetickets-island-calendar__grid", children: weeks.map((weekStart) => (
|
|
1207
|
+
// A presentational row: the seven columns are a layout, and announcing "row 3
|
|
1208
|
+
// of 9" describes the grid rather than the run.
|
|
1209
|
+
/* @__PURE__ */ jsx7("div", { className: "scopetickets-island-calendar__week", children: buildWeekRow(series, weekStart, { today, selectedDay }).map((cell, dayIndex) => /* @__PURE__ */ jsx7(
|
|
1210
|
+
CalendarDay,
|
|
1211
|
+
{
|
|
1212
|
+
cell,
|
|
1213
|
+
accessory,
|
|
1214
|
+
remaining: cell.kind === "EMPTY" ? null : remaining?.[cell.day] ?? null,
|
|
1215
|
+
label: cell.kind === "EMPTY" ? "" : formatDayDate(cell.day),
|
|
1216
|
+
outsideMonth: cell.kind !== "EMPTY" && monthOfDay(cell.day) !== currentMonth,
|
|
1217
|
+
onSelect: onSelectDay
|
|
1218
|
+
},
|
|
1219
|
+
cell.kind === "EMPTY" ? `empty-${dayIndex}` : cell.day
|
|
1220
|
+
)) }, weekStart)
|
|
1221
|
+
)) });
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
// src/island/CalendarScroller.tsx
|
|
1225
|
+
import {
|
|
1226
|
+
useCallback,
|
|
1227
|
+
useEffect as useEffect3,
|
|
1228
|
+
useRef as useRef3,
|
|
1229
|
+
useState as useState3
|
|
1230
|
+
} from "react";
|
|
1231
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1232
|
+
var WHEEL_IDLE_MS = 200;
|
|
1233
|
+
var CALENDAR_DRAG_SLOP = 4;
|
|
1234
|
+
function CalendarScroller({
|
|
1235
|
+
children,
|
|
1236
|
+
rowCount,
|
|
1237
|
+
row,
|
|
1238
|
+
onRowChange,
|
|
1239
|
+
onRowPreview,
|
|
1240
|
+
label
|
|
1241
|
+
}) {
|
|
1242
|
+
const viewportRef = useRef3(null);
|
|
1243
|
+
const trackRef = useRef3(null);
|
|
1244
|
+
const startY = useRef3(null);
|
|
1245
|
+
const [offset, setOffset] = useState3(0);
|
|
1246
|
+
const [dragging, setDragging] = useState3(false);
|
|
1247
|
+
const rowRef = useRef3(row);
|
|
1248
|
+
rowRef.current = row;
|
|
1249
|
+
const [rowStep, setRowStep] = useState3(0);
|
|
1250
|
+
const gapPx = (box) => {
|
|
1251
|
+
const gap = Number.parseFloat(
|
|
1252
|
+
getComputedStyle(box).getPropertyValue("--scopetickets-island-day-column-gap")
|
|
1253
|
+
);
|
|
1254
|
+
return Number.isFinite(gap) ? gap : 0;
|
|
1255
|
+
};
|
|
1256
|
+
useEffect3(() => {
|
|
1257
|
+
const track = trackRef.current;
|
|
1258
|
+
if (!track) return void 0;
|
|
1259
|
+
const measure = () => {
|
|
1260
|
+
const row2 = track.querySelector(".scopetickets-island-calendar__week");
|
|
1261
|
+
if (!row2) return;
|
|
1262
|
+
const height = row2.getBoundingClientRect().height;
|
|
1263
|
+
if (height <= 0) return;
|
|
1264
|
+
const step = height + gapPx(track);
|
|
1265
|
+
setRowStep((was) => Math.abs(was - step) < 0.5 ? was : step);
|
|
1266
|
+
};
|
|
1267
|
+
measure();
|
|
1268
|
+
if (typeof ResizeObserver === "undefined") return void 0;
|
|
1269
|
+
const observer = new ResizeObserver(measure);
|
|
1270
|
+
observer.observe(track);
|
|
1271
|
+
return () => observer.disconnect();
|
|
1272
|
+
}, [rowCount]);
|
|
1273
|
+
const rowHeight = useCallback(() => {
|
|
1274
|
+
if (rowStep > 0) return rowStep;
|
|
1275
|
+
const box = viewportRef.current;
|
|
1276
|
+
if (!box) return 0;
|
|
1277
|
+
return (box.clientHeight + gapPx(box)) / CALENDAR_VIEWPORT_ROWS;
|
|
1278
|
+
}, [rowStep]);
|
|
1279
|
+
const drag = useCallback(
|
|
1280
|
+
(dy) => ({
|
|
1281
|
+
row: rowRef.current,
|
|
1282
|
+
rowCount,
|
|
1283
|
+
viewportRows: CALENDAR_VIEWPORT_ROWS,
|
|
1284
|
+
offset: dy,
|
|
1285
|
+
rowHeight: rowHeight()
|
|
1286
|
+
}),
|
|
1287
|
+
[rowCount, rowHeight]
|
|
1288
|
+
);
|
|
1289
|
+
const draw = useCallback(
|
|
1290
|
+
(dy) => {
|
|
1291
|
+
const moving = drag(dy);
|
|
1292
|
+
setOffset(rowDragOffset(moving));
|
|
1293
|
+
onRowPreview?.(rowAfterDrag(moving));
|
|
1294
|
+
},
|
|
1295
|
+
[drag, onRowPreview]
|
|
1296
|
+
);
|
|
1297
|
+
const settle = useCallback(
|
|
1298
|
+
(dy) => {
|
|
1299
|
+
setOffset(0);
|
|
1300
|
+
const landed = rowAfterDrag(drag(dy));
|
|
1301
|
+
if (landed !== rowRef.current) onRowChange(landed);
|
|
1302
|
+
},
|
|
1303
|
+
[drag, onRowChange]
|
|
1304
|
+
);
|
|
1305
|
+
const dragged = useRef3(false);
|
|
1306
|
+
const onPointerDown = (event) => {
|
|
1307
|
+
if ((event.buttons & 1) !== 1) return;
|
|
1308
|
+
startY.current = event.clientY;
|
|
1309
|
+
dragged.current = false;
|
|
1310
|
+
};
|
|
1311
|
+
const onPointerMove = (event) => {
|
|
1312
|
+
if (startY.current === null) return;
|
|
1313
|
+
const dy = event.clientY - startY.current;
|
|
1314
|
+
if (!dragged.current) {
|
|
1315
|
+
if (Math.abs(dy) < CALENDAR_DRAG_SLOP) return;
|
|
1316
|
+
dragged.current = true;
|
|
1317
|
+
setDragging(true);
|
|
1318
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
1319
|
+
}
|
|
1320
|
+
draw(dy);
|
|
1321
|
+
};
|
|
1322
|
+
const onPointerUp = (event) => {
|
|
1323
|
+
if (startY.current === null) return;
|
|
1324
|
+
const dy = event.clientY - startY.current;
|
|
1325
|
+
startY.current = null;
|
|
1326
|
+
if (!dragged.current) return;
|
|
1327
|
+
setDragging(false);
|
|
1328
|
+
settle(dy);
|
|
1329
|
+
};
|
|
1330
|
+
const onClickCapture = (event) => {
|
|
1331
|
+
if (!dragged.current) return;
|
|
1332
|
+
dragged.current = false;
|
|
1333
|
+
event.stopPropagation();
|
|
1334
|
+
event.preventDefault();
|
|
1335
|
+
};
|
|
1336
|
+
const onPointerCancel = () => {
|
|
1337
|
+
startY.current = null;
|
|
1338
|
+
dragged.current = false;
|
|
1339
|
+
setDragging(false);
|
|
1340
|
+
setOffset(0);
|
|
1341
|
+
};
|
|
1342
|
+
const wheel = useRef3(0);
|
|
1343
|
+
const settleTimer = useRef3(null);
|
|
1344
|
+
useEffect3(() => {
|
|
1345
|
+
const viewport = viewportRef.current;
|
|
1346
|
+
if (!viewport) return void 0;
|
|
1347
|
+
const onWheel = (event) => {
|
|
1348
|
+
event.preventDefault();
|
|
1349
|
+
wheel.current -= event.deltaY;
|
|
1350
|
+
wheel.current = rowDragOffset(drag(wheel.current));
|
|
1351
|
+
draw(wheel.current);
|
|
1352
|
+
if (settleTimer.current !== null) window.clearTimeout(settleTimer.current);
|
|
1353
|
+
settleTimer.current = window.setTimeout(() => {
|
|
1354
|
+
settleTimer.current = null;
|
|
1355
|
+
const travelled = wheel.current;
|
|
1356
|
+
wheel.current = 0;
|
|
1357
|
+
settle(travelled);
|
|
1358
|
+
}, WHEEL_IDLE_MS);
|
|
1359
|
+
};
|
|
1360
|
+
viewport.addEventListener("wheel", onWheel, { passive: false });
|
|
1361
|
+
return () => viewport.removeEventListener("wheel", onWheel);
|
|
1362
|
+
}, [drag, draw, settle]);
|
|
1363
|
+
useEffect3(
|
|
1364
|
+
() => () => {
|
|
1365
|
+
if (settleTimer.current !== null) window.clearTimeout(settleTimer.current);
|
|
1366
|
+
},
|
|
1367
|
+
[]
|
|
1368
|
+
);
|
|
1369
|
+
return /* @__PURE__ */ jsxs5(
|
|
1370
|
+
"div",
|
|
1371
|
+
{
|
|
1372
|
+
ref: viewportRef,
|
|
1373
|
+
className: "scopetickets-island-calendar-scroller",
|
|
1374
|
+
role: "group",
|
|
1375
|
+
"aria-label": label,
|
|
1376
|
+
style: {
|
|
1377
|
+
"--scopetickets-island-viewport-rows": CALENDAR_VIEWPORT_ROWS,
|
|
1378
|
+
...rowStep > 0 ? { "--scopetickets-island-calendar-row-step": `${rowStep}px` } : null
|
|
1379
|
+
},
|
|
1380
|
+
onPointerDown,
|
|
1381
|
+
onPointerMove,
|
|
1382
|
+
onPointerUp,
|
|
1383
|
+
onPointerCancel,
|
|
1384
|
+
onClickCapture,
|
|
1385
|
+
children: [
|
|
1386
|
+
/* @__PURE__ */ jsx8("div", { className: "scopetickets-island-calendar-scroller__window", "aria-hidden": "true" }),
|
|
1387
|
+
/* @__PURE__ */ jsx8(
|
|
1388
|
+
"div",
|
|
1389
|
+
{
|
|
1390
|
+
ref: trackRef,
|
|
1391
|
+
className: "scopetickets-island-calendar-scroller__track",
|
|
1392
|
+
"data-dragging": dragging || offset !== 0 ? "" : void 0,
|
|
1393
|
+
style: {
|
|
1394
|
+
translate: `0 calc(${-row} * var(--scopetickets-island-calendar-row-step) + ${offset}px)`
|
|
1395
|
+
},
|
|
1396
|
+
children
|
|
1397
|
+
}
|
|
1398
|
+
)
|
|
1399
|
+
]
|
|
1400
|
+
}
|
|
1401
|
+
);
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
// src/island/CalendarWeekdayNames.tsx
|
|
1405
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1406
|
+
var WEEKDAY_NAMES = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
1407
|
+
function CalendarWeekdayNames() {
|
|
1408
|
+
return (
|
|
1409
|
+
// `aria-hidden`, and it is not a shortcut.
|
|
1410
|
+
/* @__PURE__ */ jsx9("div", { className: "scopetickets-island-calendar__weekdays", "aria-hidden": "true", children: WEEKDAY_NAMES.map((name) => /* @__PURE__ */ jsx9("span", { className: "scopetickets-island-calendar__weekday", children: name }, name)) })
|
|
1411
|
+
);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// src/island/DayPicker.tsx
|
|
1415
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1416
|
+
function DayPicker({
|
|
1417
|
+
series,
|
|
1418
|
+
today,
|
|
1419
|
+
selectedDay,
|
|
1420
|
+
onSelectDay,
|
|
1421
|
+
remaining,
|
|
1422
|
+
accessory = DATE_PICKER_ACCESSORY,
|
|
1423
|
+
onVisibleMonthChange
|
|
1424
|
+
}) {
|
|
1425
|
+
const weeks = useMemo2(() => weeksInCalendar(series), [series]);
|
|
1426
|
+
const starts = useMemo2(() => monthStartRows(weeks), [weeks]);
|
|
1427
|
+
const [row, setRow] = useState4(
|
|
1428
|
+
() => monthOpeningRow(weeks, starts, selectedDay ?? soonestRelevantDay(series, today))
|
|
1429
|
+
);
|
|
1430
|
+
const [shownRow, setShownRow] = useState4(row);
|
|
1431
|
+
const currentMonth = monthAtRow(starts, shownRow);
|
|
1432
|
+
useEffect4(() => {
|
|
1433
|
+
if (currentMonth !== null) onVisibleMonthChange?.(currentMonth);
|
|
1434
|
+
}, [currentMonth, onVisibleMonthChange]);
|
|
1435
|
+
const selectDay = useCallback2(
|
|
1436
|
+
(day) => {
|
|
1437
|
+
const month = monthOfDay(day);
|
|
1438
|
+
const start = starts.find((candidate) => candidate.month === month);
|
|
1439
|
+
if (start !== void 0 && month !== currentMonth) {
|
|
1440
|
+
setRow(start.row);
|
|
1441
|
+
setShownRow(start.row);
|
|
1442
|
+
}
|
|
1443
|
+
onSelectDay(day);
|
|
1444
|
+
},
|
|
1445
|
+
[starts, currentMonth, onSelectDay]
|
|
1446
|
+
);
|
|
1447
|
+
if (weeks.length === 0) return null;
|
|
1448
|
+
return /* @__PURE__ */ jsxs6("div", { className: "scopetickets-island-calendar", "data-accessory": accessory, children: [
|
|
1449
|
+
currentMonth !== null && /* @__PURE__ */ jsx10(CalendarMonthHeading, { month: currentMonth }),
|
|
1450
|
+
/* @__PURE__ */ jsx10(CalendarWeekdayNames, {}),
|
|
1451
|
+
/* @__PURE__ */ jsx10(
|
|
1452
|
+
CalendarScroller,
|
|
1453
|
+
{
|
|
1454
|
+
rowCount: weeks.length,
|
|
1455
|
+
row,
|
|
1456
|
+
onRowChange: setRow,
|
|
1457
|
+
onRowPreview: setShownRow,
|
|
1458
|
+
label: "Weeks of the run",
|
|
1459
|
+
children: /* @__PURE__ */ jsx10(
|
|
1460
|
+
CalendarRunGrid,
|
|
1461
|
+
{
|
|
1462
|
+
series,
|
|
1463
|
+
weeks,
|
|
1464
|
+
currentMonth,
|
|
1465
|
+
accessory,
|
|
1466
|
+
remaining,
|
|
1467
|
+
today,
|
|
1468
|
+
selectedDay,
|
|
1469
|
+
onSelectDay: selectDay
|
|
1470
|
+
}
|
|
1471
|
+
)
|
|
1472
|
+
}
|
|
1473
|
+
)
|
|
1474
|
+
] });
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
// src/island/TimeslotPicker.tsx
|
|
1478
|
+
import { useMemo as useMemo3 } from "react";
|
|
1479
|
+
|
|
1480
|
+
// src/island/Timeslot.tsx
|
|
1481
|
+
import { Fragment, jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1482
|
+
var REMAINING_SIZE = "var(--scopetickets-island-space-4)";
|
|
1483
|
+
var SELECTED_ARC = "var(--scopetickets-island-timeslot-ring-selected)";
|
|
1484
|
+
var TRACK = "var(--scopetickets-island-timeslot-track)";
|
|
1485
|
+
var SELECTED_TRACK = "var(--scopetickets-island-timeslot-track-selected)";
|
|
1486
|
+
var SOLD_OUT = "Sold Out";
|
|
1487
|
+
function Timeslot({ cell, accessory, onSelect }) {
|
|
1488
|
+
if (isDatePickerCellSelectable(cell.state)) {
|
|
1489
|
+
return /* @__PURE__ */ jsx11(TimeslotButton, { cell, accessory, onSelect });
|
|
1490
|
+
}
|
|
1491
|
+
return /* @__PURE__ */ jsx11(TimeslotFixed, { cell });
|
|
1492
|
+
}
|
|
1493
|
+
function TimeslotRow({ cell }) {
|
|
1494
|
+
return /* @__PURE__ */ jsxs7("span", { className: "scopetickets-island-timeslot__times", children: [
|
|
1495
|
+
/* @__PURE__ */ jsx11("span", { className: "scopetickets-island-timeslot__time", children: cell.slot.startTime }),
|
|
1496
|
+
cell.slot.endTime === null ? null : /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
1497
|
+
/* @__PURE__ */ jsx11("span", { className: "scopetickets-island-timeslot__dash", "aria-hidden": "true", children: "-" }),
|
|
1498
|
+
/* @__PURE__ */ jsx11("span", { className: "scopetickets-island-timeslot__time", children: cell.slot.endTime })
|
|
1499
|
+
] }),
|
|
1500
|
+
cell.state === "UNAVAILABLE" ? (
|
|
1501
|
+
/*
|
|
1502
|
+
* THE WORDS INSTEAD OF THE MARK, AND ONLY WHERE THE MARK WOULD SAY NOTHING.
|
|
1503
|
+
*
|
|
1504
|
+
* `UNAVAILABLE` is the one state the ring cannot draw: `timeslotState` reaches it
|
|
1505
|
+
* only for `remaining <= 0`, which is an arc of zero length. A slot that has
|
|
1506
|
+
* merely BEGUN keeps its ring — it still has seats, and "Sold Out" over them
|
|
1507
|
+
* would be false.
|
|
1508
|
+
*/
|
|
1509
|
+
/* @__PURE__ */ jsx11("span", { className: "scopetickets-island-timeslot__soldout", children: SOLD_OUT })
|
|
1510
|
+
) : cell.slot.remaining === null ? null : /* @__PURE__ */ jsx11("span", { className: "scopetickets-island-timeslot__remaining", children: /* @__PURE__ */ jsx11(
|
|
1511
|
+
CounterRing,
|
|
1512
|
+
{
|
|
1513
|
+
progress: cell.slot.remaining,
|
|
1514
|
+
color: cell.state === "SELECTED" ? SELECTED_ARC : availabilityColor(cell.slot.remaining),
|
|
1515
|
+
trackColor: cell.state === "SELECTED" ? SELECTED_TRACK : TRACK,
|
|
1516
|
+
size: REMAINING_SIZE
|
|
1517
|
+
}
|
|
1518
|
+
) })
|
|
1519
|
+
] });
|
|
1520
|
+
}
|
|
1521
|
+
function timeslotLabel(cell, announcement) {
|
|
1522
|
+
const range = cell.slot.endTime === null ? cell.slot.startTime : `${cell.slot.startTime} - ${cell.slot.endTime}`;
|
|
1523
|
+
return [range, cell.duration, announcement].filter((part) => part !== null).join(", ");
|
|
1524
|
+
}
|
|
1525
|
+
function TimeslotButton({ cell, accessory, onSelect }) {
|
|
1526
|
+
const press = useIslandPress("element");
|
|
1527
|
+
const selected = cell.state === "SELECTED";
|
|
1528
|
+
const availability = readAvailability(cell.slot.remaining);
|
|
1529
|
+
return /* @__PURE__ */ jsx11(
|
|
1530
|
+
"button",
|
|
1531
|
+
{
|
|
1532
|
+
type: "button",
|
|
1533
|
+
className: "scopetickets-island-timeslot",
|
|
1534
|
+
"aria-pressed": selected,
|
|
1535
|
+
"aria-label": timeslotLabel(cell, availability?.announcement ?? null),
|
|
1536
|
+
onClick: () => onSelect(cell.slot.startTime),
|
|
1537
|
+
...press,
|
|
1538
|
+
children: /* @__PURE__ */ jsxs7("span", { className: "scopetickets-island-timeslot__pill", "data-state": cell.state, children: [
|
|
1539
|
+
/* @__PURE__ */ jsx11(TimeslotRow, { cell }),
|
|
1540
|
+
accessory === "LINE" && availability !== null ? /* @__PURE__ */ jsx11("span", { className: "scopetickets-island-timeslot__accessory", children: /* @__PURE__ */ jsx11(CalendarDayIndicator, { level: availability.level }) }) : null
|
|
1541
|
+
] })
|
|
1542
|
+
}
|
|
1543
|
+
);
|
|
1544
|
+
}
|
|
1545
|
+
function TimeslotFixed({ cell }) {
|
|
1546
|
+
return /* @__PURE__ */ jsx11("span", { className: "scopetickets-island-timeslot", children: /* @__PURE__ */ jsx11("span", { className: "scopetickets-island-timeslot__pill", "data-state": cell.state, children: /* @__PURE__ */ jsx11(TimeslotRow, { cell }) }) });
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
// src/island/TimeslotGroupSection.tsx
|
|
1550
|
+
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1551
|
+
function TimeslotGroupSection({ group, accessory, onSelect }) {
|
|
1552
|
+
return /* @__PURE__ */ jsxs8("section", { className: "scopetickets-island-timeslots__group", children: [
|
|
1553
|
+
group.label === null ? null : /* @__PURE__ */ jsx12("h4", { className: "scopetickets-island-timeslots__label", children: group.label }),
|
|
1554
|
+
/* @__PURE__ */ jsx12("div", { className: "scopetickets-island-timeslots__list", children: group.cells.map((cell, index) => /* @__PURE__ */ jsx12(
|
|
1555
|
+
Timeslot,
|
|
1556
|
+
{
|
|
1557
|
+
cell,
|
|
1558
|
+
accessory,
|
|
1559
|
+
onSelect
|
|
1560
|
+
},
|
|
1561
|
+
`${cell.slot.startTime}-${index}`
|
|
1562
|
+
)) })
|
|
1563
|
+
] });
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
// src/island/TimeslotPicker.tsx
|
|
1567
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1568
|
+
function TimeslotPicker({
|
|
1569
|
+
slots,
|
|
1570
|
+
selection,
|
|
1571
|
+
today,
|
|
1572
|
+
nowTime,
|
|
1573
|
+
onSelect,
|
|
1574
|
+
accessory,
|
|
1575
|
+
grouping
|
|
1576
|
+
}) {
|
|
1577
|
+
const groups = useMemo3(
|
|
1578
|
+
() => buildTimeslotGroups(slots, { selection, today, nowTime, grouping }),
|
|
1579
|
+
[slots, selection, today, nowTime, grouping]
|
|
1580
|
+
);
|
|
1581
|
+
return /* @__PURE__ */ jsx13("div", { className: "scopetickets-island-timeslots", children: groups.map((group) => /* @__PURE__ */ jsx13(
|
|
1582
|
+
TimeslotGroupSection,
|
|
1583
|
+
{
|
|
1584
|
+
group,
|
|
1585
|
+
accessory,
|
|
1586
|
+
onSelect
|
|
1587
|
+
},
|
|
1588
|
+
group.part ?? "ALL"
|
|
1589
|
+
)) });
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
// src/island/TimePicker.tsx
|
|
1593
|
+
import { useEffect as useEffect6, useReducer } from "react";
|
|
1594
|
+
|
|
1595
|
+
// src/island/CalendarWeekSection.tsx
|
|
1596
|
+
import { useCallback as useCallback3, useEffect as useEffect5, useLayoutEffect, useRef as useRef4, useState as useState5 } from "react";
|
|
1597
|
+
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1598
|
+
function CalendarWeekSection({
|
|
1599
|
+
series,
|
|
1600
|
+
today,
|
|
1601
|
+
selectedDay,
|
|
1602
|
+
onSelectDay,
|
|
1603
|
+
remaining,
|
|
1604
|
+
accessory,
|
|
1605
|
+
onVisibleMonthChange
|
|
1606
|
+
}) {
|
|
1607
|
+
const weeks = weeksInSeries(series);
|
|
1608
|
+
const selectedWeek = startOfWeek(selectedDay);
|
|
1609
|
+
const selectedIndex = Math.max(weeks.indexOf(selectedWeek), 0);
|
|
1610
|
+
const pagerRef = useRef4(null);
|
|
1611
|
+
const pageRefs = useRef4([]);
|
|
1612
|
+
const [visibleIndex, setVisibleIndex] = useState5(selectedIndex);
|
|
1613
|
+
useEffect5(() => {
|
|
1614
|
+
setVisibleIndex(selectedIndex);
|
|
1615
|
+
}, [selectedIndex]);
|
|
1616
|
+
const strideOf = (pager) => {
|
|
1617
|
+
const first = pageRefs.current[0];
|
|
1618
|
+
const second = pageRefs.current[1];
|
|
1619
|
+
if (first && second) return second.offsetLeft - first.offsetLeft;
|
|
1620
|
+
return first?.offsetWidth ?? pager.clientWidth;
|
|
1621
|
+
};
|
|
1622
|
+
const paint = useCallback3(() => {
|
|
1623
|
+
const pager = pagerRef.current;
|
|
1624
|
+
if (!pager) return;
|
|
1625
|
+
const stride = strideOf(pager);
|
|
1626
|
+
if (stride <= 0) return;
|
|
1627
|
+
const at = pager.scrollLeft / stride;
|
|
1628
|
+
pageRefs.current.forEach((page2, index) => {
|
|
1629
|
+
if (!page2) return;
|
|
1630
|
+
page2.style.setProperty(
|
|
1631
|
+
"--scopetickets-island-week-distance",
|
|
1632
|
+
String(Math.min(Math.abs(index - at), 1))
|
|
1633
|
+
);
|
|
1634
|
+
});
|
|
1635
|
+
const page = Math.round(at);
|
|
1636
|
+
setVisibleIndex(Math.min(Math.max(page, 0), Math.max(weeks.length - 1, 0)));
|
|
1637
|
+
}, [weeks.length]);
|
|
1638
|
+
useLayoutEffect(() => {
|
|
1639
|
+
const pager = pagerRef.current;
|
|
1640
|
+
if (!pager) return;
|
|
1641
|
+
pager.scrollLeft = selectedIndex * strideOf(pager);
|
|
1642
|
+
paint();
|
|
1643
|
+
}, [selectedIndex, paint]);
|
|
1644
|
+
const visibleWeek = weeks[Math.min(visibleIndex, weeks.length - 1)] ?? selectedWeek;
|
|
1645
|
+
useEffect5(() => {
|
|
1646
|
+
if (weeks.length === 0) return;
|
|
1647
|
+
onVisibleMonthChange?.(
|
|
1648
|
+
visibleWeek === selectedWeek ? monthOfDay(selectedDay) : monthOfWeek(visibleWeek)
|
|
1649
|
+
);
|
|
1650
|
+
}, [weeks.length, visibleWeek, selectedWeek, selectedDay, onVisibleMonthChange]);
|
|
1651
|
+
if (weeks.length === 0) return null;
|
|
1652
|
+
return /* @__PURE__ */ jsxs9("div", { className: "scopetickets-island-week", children: [
|
|
1653
|
+
/* @__PURE__ */ jsx14(CalendarWeekdayNames, {}),
|
|
1654
|
+
/* @__PURE__ */ jsx14("div", { className: "scopetickets-island-week__pager", ref: pagerRef, onScroll: paint, children: weeks.map((weekStart, index) => /* @__PURE__ */ jsx14(
|
|
1655
|
+
"div",
|
|
1656
|
+
{
|
|
1657
|
+
className: "scopetickets-island-week__page",
|
|
1658
|
+
ref: (node) => {
|
|
1659
|
+
pageRefs.current[index] = node;
|
|
1660
|
+
},
|
|
1661
|
+
children: /* @__PURE__ */ jsx14("div", { className: "scopetickets-island-week__row", children: buildWeekRow(series, weekStart, { today, selectedDay }).map((cell, dayIndex) => /* @__PURE__ */ jsx14(
|
|
1662
|
+
CalendarDay,
|
|
1663
|
+
{
|
|
1664
|
+
cell,
|
|
1665
|
+
accessory,
|
|
1666
|
+
remaining: cell.kind === "EMPTY" ? null : remaining?.[cell.day] ?? null,
|
|
1667
|
+
label: cell.kind === "EMPTY" ? "" : formatDayDate(cell.day),
|
|
1668
|
+
onSelect: onSelectDay
|
|
1669
|
+
},
|
|
1670
|
+
cell.kind === "EMPTY" ? `empty-${dayIndex}` : cell.day
|
|
1671
|
+
)) })
|
|
1672
|
+
},
|
|
1673
|
+
weekStart
|
|
1674
|
+
)) })
|
|
1675
|
+
] });
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
// src/island/SelectedDayHeading.tsx
|
|
1679
|
+
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1680
|
+
function SelectedDayHeading({ day }) {
|
|
1681
|
+
return /* @__PURE__ */ jsxs10("h3", { className: "scopetickets-island-day-heading", children: [
|
|
1682
|
+
/* @__PURE__ */ jsxs10("span", { className: "scopetickets-island-day-heading__weekday", children: [
|
|
1683
|
+
formatDayWeekday(day),
|
|
1684
|
+
","
|
|
1685
|
+
] }),
|
|
1686
|
+
/* @__PURE__ */ jsx15("span", { className: "scopetickets-island-day-heading__date", children: formatDayDate(day) })
|
|
1687
|
+
] });
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
// src/island/island-step-order.ts
|
|
1691
|
+
function dayDirection(from, to) {
|
|
1692
|
+
if (from === to) return "NONE";
|
|
1693
|
+
return to > from ? "FORWARD" : "BACKWARD";
|
|
1694
|
+
}
|
|
1695
|
+
function stepDirectionSign(direction) {
|
|
1696
|
+
if (direction === "FORWARD") return 1;
|
|
1697
|
+
if (direction === "BACKWARD") return -1;
|
|
1698
|
+
return 0;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
// src/island/island-day-swap.ts
|
|
1702
|
+
var DAY_SWAP_OUT_ANIMATION = "scopetickets-island-day-swap-out";
|
|
1703
|
+
var DAY_SWAP_IN_ANIMATION = "scopetickets-island-day-swap-in";
|
|
1704
|
+
function daySwapAtRest(content) {
|
|
1705
|
+
return { phase: "REST", shown: content };
|
|
1706
|
+
}
|
|
1707
|
+
function reduceDaySwap(state, event) {
|
|
1708
|
+
switch (event.type) {
|
|
1709
|
+
case "CONTENT_CHANGED": {
|
|
1710
|
+
const next = event.content;
|
|
1711
|
+
if (next.day === state.shown.day) {
|
|
1712
|
+
const shown = { day: state.shown.day, slots: next.slots };
|
|
1713
|
+
if (state.phase === "LEAVING") {
|
|
1714
|
+
return { phase: "ENTERING", shown, sign: state.sign === 1 ? -1 : 1 };
|
|
1715
|
+
}
|
|
1716
|
+
if (sameTimeslots(next.slots, state.shown.slots)) return state;
|
|
1717
|
+
return { ...state, shown };
|
|
1718
|
+
}
|
|
1719
|
+
if (state.phase === "LEAVING" && state.to === next.day) return state;
|
|
1720
|
+
const sign = stepDirectionSign(dayDirection(state.shown.day, next.day));
|
|
1721
|
+
if (sign === 0) return state;
|
|
1722
|
+
return { phase: "LEAVING", shown: state.shown, to: next.day, sign };
|
|
1723
|
+
}
|
|
1724
|
+
case "LEFT":
|
|
1725
|
+
if (state.phase !== "LEAVING") return state;
|
|
1726
|
+
return { phase: "ENTERING", shown: event.content, sign: state.sign };
|
|
1727
|
+
case "ARRIVED":
|
|
1728
|
+
if (state.phase !== "ENTERING") return state;
|
|
1729
|
+
return { phase: "REST", shown: state.shown };
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
// src/island/TimePicker.tsx
|
|
1734
|
+
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1735
|
+
function TimePicker({
|
|
1736
|
+
series,
|
|
1737
|
+
today,
|
|
1738
|
+
nowTime,
|
|
1739
|
+
selection,
|
|
1740
|
+
onSelectDay,
|
|
1741
|
+
slots,
|
|
1742
|
+
onSelectTime,
|
|
1743
|
+
remaining,
|
|
1744
|
+
accessory = DATE_PICKER_ACCESSORY,
|
|
1745
|
+
onVisibleMonthChange
|
|
1746
|
+
}) {
|
|
1747
|
+
const [swap, dispatch] = useReducer(reduceDaySwap, { day: selection.day, slots }, daySwapAtRest);
|
|
1748
|
+
useEffect6(() => {
|
|
1749
|
+
dispatch({ type: "CONTENT_CHANGED", content: { day: selection.day, slots } });
|
|
1750
|
+
}, [selection.day, slots]);
|
|
1751
|
+
const onSwapAnimationEnd = (event) => {
|
|
1752
|
+
if (event.animationName === DAY_SWAP_OUT_ANIMATION) {
|
|
1753
|
+
dispatch({ type: "LEFT", content: { day: selection.day, slots } });
|
|
1754
|
+
} else if (event.animationName === DAY_SWAP_IN_ANIMATION) {
|
|
1755
|
+
dispatch({ type: "ARRIVED" });
|
|
1756
|
+
}
|
|
1757
|
+
};
|
|
1758
|
+
const shownSelection = swap.shown.day === selection.day ? selection : { day: swap.shown.day, startTime: null };
|
|
1759
|
+
return /* @__PURE__ */ jsxs11("div", { className: "scopetickets-island-time", "data-accessory": accessory, children: [
|
|
1760
|
+
/* @__PURE__ */ jsx16(
|
|
1761
|
+
CalendarWeekSection,
|
|
1762
|
+
{
|
|
1763
|
+
series,
|
|
1764
|
+
today,
|
|
1765
|
+
selectedDay: selection.day,
|
|
1766
|
+
onSelectDay,
|
|
1767
|
+
remaining,
|
|
1768
|
+
accessory,
|
|
1769
|
+
onVisibleMonthChange
|
|
1770
|
+
}
|
|
1771
|
+
),
|
|
1772
|
+
/* @__PURE__ */ jsxs11(
|
|
1773
|
+
"div",
|
|
1774
|
+
{
|
|
1775
|
+
className: "scopetickets-island-time__swap",
|
|
1776
|
+
"data-day-swap": swap.phase,
|
|
1777
|
+
style: swap.phase === "REST" ? void 0 : { "--scopetickets-island-swap-sign": swap.sign },
|
|
1778
|
+
onAnimationEnd: onSwapAnimationEnd,
|
|
1779
|
+
children: [
|
|
1780
|
+
/* @__PURE__ */ jsx16(SelectedDayHeading, { day: swap.shown.day }),
|
|
1781
|
+
/* @__PURE__ */ jsx16(
|
|
1782
|
+
TimeslotPicker,
|
|
1783
|
+
{
|
|
1784
|
+
slots: swap.shown.slots,
|
|
1785
|
+
selection: shownSelection,
|
|
1786
|
+
today,
|
|
1787
|
+
nowTime,
|
|
1788
|
+
onSelect: onSelectTime,
|
|
1789
|
+
accessory
|
|
1790
|
+
}
|
|
1791
|
+
)
|
|
1792
|
+
]
|
|
1793
|
+
}
|
|
1794
|
+
)
|
|
1795
|
+
] });
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
// src/island/CalendarGrainButton.tsx
|
|
1799
|
+
import { useCallback as useCallback4, useLayoutEffect as useLayoutEffect2, useRef as useRef5, useState as useState6 } from "react";
|
|
1800
|
+
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1801
|
+
function useShortenedMonth(long) {
|
|
1802
|
+
const [short, setShort] = useState6(false);
|
|
1803
|
+
const title = useRef5(null);
|
|
1804
|
+
const probe = useRef5(null);
|
|
1805
|
+
const measure = useCallback4(() => {
|
|
1806
|
+
const box = title.current;
|
|
1807
|
+
const full = probe.current;
|
|
1808
|
+
if (!box || !full) return;
|
|
1809
|
+
const wanted = Math.ceil(full.getBoundingClientRect().width);
|
|
1810
|
+
box.style.setProperty("--scopetickets-island-grain-width", `${wanted}px`);
|
|
1811
|
+
setShort(box.clientWidth + 1 < wanted);
|
|
1812
|
+
}, []);
|
|
1813
|
+
useLayoutEffect2(() => {
|
|
1814
|
+
measure();
|
|
1815
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
1816
|
+
const observer = new ResizeObserver(measure);
|
|
1817
|
+
if (title.current) observer.observe(title.current);
|
|
1818
|
+
return () => observer.disconnect();
|
|
1819
|
+
}, [measure, long]);
|
|
1820
|
+
return {
|
|
1821
|
+
short,
|
|
1822
|
+
titleRef: useCallback4(
|
|
1823
|
+
(node) => {
|
|
1824
|
+
title.current = node;
|
|
1825
|
+
measure();
|
|
1826
|
+
},
|
|
1827
|
+
[measure]
|
|
1828
|
+
),
|
|
1829
|
+
probeRef: useCallback4(
|
|
1830
|
+
(node) => {
|
|
1831
|
+
probe.current = node;
|
|
1832
|
+
measure();
|
|
1833
|
+
},
|
|
1834
|
+
[measure]
|
|
1835
|
+
)
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
function CalendarGrainButton({ month, grain, onPress }) {
|
|
1839
|
+
const press = useIslandPress("element");
|
|
1840
|
+
const long = grain === "YEAR" ? formatMonthYear(month) : formatMonthName(month);
|
|
1841
|
+
const { short, titleRef, probeRef } = useShortenedMonth(long);
|
|
1842
|
+
const shown = grain === "MONTH" && short ? formatMonthNameShort(month) : long;
|
|
1843
|
+
const title = /* @__PURE__ */ jsxs12(
|
|
1844
|
+
"span",
|
|
1845
|
+
{
|
|
1846
|
+
className: "scopetickets-island-header-button__title",
|
|
1847
|
+
ref: titleRef,
|
|
1848
|
+
...grain === "MONTH" && short ? { "data-grain-short": "" } : null,
|
|
1849
|
+
children: [
|
|
1850
|
+
shown,
|
|
1851
|
+
grain === "MONTH" ? /* @__PURE__ */ jsx17(
|
|
1852
|
+
"span",
|
|
1853
|
+
{
|
|
1854
|
+
className: "scopetickets-island-header-button__probe",
|
|
1855
|
+
ref: probeRef,
|
|
1856
|
+
"aria-hidden": "true",
|
|
1857
|
+
children: long
|
|
1858
|
+
}
|
|
1859
|
+
) : null
|
|
1860
|
+
]
|
|
1861
|
+
}
|
|
1862
|
+
);
|
|
1863
|
+
if (onPress === void 0) {
|
|
1864
|
+
return /* @__PURE__ */ jsx17("span", { className: "scopetickets-island-chrome-pill scopetickets-island-grain-pill", children: title });
|
|
1865
|
+
}
|
|
1866
|
+
return /* @__PURE__ */ jsx17(
|
|
1867
|
+
"button",
|
|
1868
|
+
{
|
|
1869
|
+
type: "button",
|
|
1870
|
+
className: "scopetickets-island-chrome-pill scopetickets-island-header-button scopetickets-island-grain-pill",
|
|
1871
|
+
onClick: onPress,
|
|
1872
|
+
...press,
|
|
1873
|
+
children: title
|
|
1874
|
+
}
|
|
1875
|
+
);
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
// src/island/Switch.tsx
|
|
1879
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1880
|
+
function Switch({ checked, onChange, label, size = "wide", disabled = false }) {
|
|
1881
|
+
const press = useIslandPress("element");
|
|
1882
|
+
return /* @__PURE__ */ jsx18(
|
|
1883
|
+
"button",
|
|
1884
|
+
{
|
|
1885
|
+
type: "button",
|
|
1886
|
+
role: "switch",
|
|
1887
|
+
"aria-checked": checked,
|
|
1888
|
+
"aria-label": label,
|
|
1889
|
+
disabled,
|
|
1890
|
+
className: `scopetickets-island-switch scopetickets-island-switch--${size}`,
|
|
1891
|
+
onClick: () => onChange(!checked),
|
|
1892
|
+
...disabled ? {} : press,
|
|
1893
|
+
children: /* @__PURE__ */ jsx18("span", { className: "scopetickets-island-switch__thumb", "aria-hidden": "true" })
|
|
1894
|
+
}
|
|
1895
|
+
);
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
export {
|
|
1899
|
+
SURFACE_MORPH_MS,
|
|
1900
|
+
SURFACE_SPRING,
|
|
1901
|
+
CARRY_SPRING,
|
|
1902
|
+
POP_RETURN_SPRING,
|
|
1903
|
+
springEasing,
|
|
1904
|
+
OUTGOING_FADE_MS,
|
|
1905
|
+
SURFACE_MORPH_DELAY_MS,
|
|
1906
|
+
INCOMING_FADE_DELAY_MS,
|
|
1907
|
+
INCOMING_FADE_MS,
|
|
1908
|
+
CARRY_MOVE_DELAY_MS,
|
|
1909
|
+
CARRY_MOVE_MS,
|
|
1910
|
+
ARC_LEAD_EASING,
|
|
1911
|
+
ARC_TRAIL_EASING,
|
|
1912
|
+
POP_SCALE,
|
|
1913
|
+
SHIELD_POP_SCALE,
|
|
1914
|
+
POP_RETURN_MS,
|
|
1915
|
+
POP_MS,
|
|
1916
|
+
PRESS_IN_MS,
|
|
1917
|
+
PRESS_LETGO_MS,
|
|
1918
|
+
ISLAND_TRANSITION_MS,
|
|
1919
|
+
PROCESSING_FLOOR_MS,
|
|
1920
|
+
PAID_GRACE_MS,
|
|
1921
|
+
ACCOUNT_CREATING_FLOOR_MS,
|
|
1922
|
+
HOLD_TICK_MS,
|
|
1923
|
+
PressContext,
|
|
1924
|
+
useIslandPress,
|
|
1925
|
+
toAvailabilityLevel,
|
|
1926
|
+
readAvailability,
|
|
1927
|
+
availabilityColor,
|
|
1928
|
+
isDatePickerCellSelectable,
|
|
1929
|
+
isSelectableCalendarCell,
|
|
1930
|
+
eventsOn,
|
|
1931
|
+
eventKeyForDay,
|
|
1932
|
+
dateRange,
|
|
1933
|
+
soonestRelevantDay,
|
|
1934
|
+
addDays,
|
|
1935
|
+
startOfWeek,
|
|
1936
|
+
monthOfWeek,
|
|
1937
|
+
weeksInSeries,
|
|
1938
|
+
weeksInCalendar,
|
|
1939
|
+
buildWeekRow,
|
|
1940
|
+
buildMonthGrid,
|
|
1941
|
+
weekContainingDay,
|
|
1942
|
+
locateDayInMonthStack,
|
|
1943
|
+
monthOfDay,
|
|
1944
|
+
monthsInSeries,
|
|
1945
|
+
openingMonth,
|
|
1946
|
+
stepMonth,
|
|
1947
|
+
formatMonthYear,
|
|
1948
|
+
formatMonthName,
|
|
1949
|
+
formatMonthNameShort,
|
|
1950
|
+
formatDayDate,
|
|
1951
|
+
formatWeekdayAndDate,
|
|
1952
|
+
formatDayChip,
|
|
1953
|
+
formatDayWeekday,
|
|
1954
|
+
DATE_PICKER_ACCESSORY,
|
|
1955
|
+
monthStartRows,
|
|
1956
|
+
monthAtRow,
|
|
1957
|
+
monthOpeningRow,
|
|
1958
|
+
toggleSelectedDay,
|
|
1959
|
+
slotFullness,
|
|
1960
|
+
parseWallClockTime,
|
|
1961
|
+
timeOfDayInZone,
|
|
1962
|
+
partOfDayLabel,
|
|
1963
|
+
partOfDay,
|
|
1964
|
+
formatSlotRange,
|
|
1965
|
+
formatSlotDuration,
|
|
1966
|
+
withSelectedDay,
|
|
1967
|
+
withSelectedTime,
|
|
1968
|
+
sameTimeslots,
|
|
1969
|
+
buildTimeslotGroups,
|
|
1970
|
+
timeslotRequest,
|
|
1971
|
+
groupUserTypes,
|
|
1972
|
+
partyTypes,
|
|
1973
|
+
assignmentFor,
|
|
1974
|
+
userTypeNames,
|
|
1975
|
+
PartyStepper,
|
|
1976
|
+
SOLO_KEY,
|
|
1977
|
+
flagTone,
|
|
1978
|
+
ContentFlag,
|
|
1979
|
+
clampRemaining,
|
|
1980
|
+
trackPaths,
|
|
1981
|
+
timerPaths,
|
|
1982
|
+
CounterRing,
|
|
1983
|
+
DayPicker,
|
|
1984
|
+
TimeslotPicker,
|
|
1985
|
+
TimePicker,
|
|
1986
|
+
CalendarGrainButton,
|
|
1987
|
+
Switch
|
|
1988
|
+
};
|
|
1989
|
+
//# sourceMappingURL=chunk-4BOPQURW.js.map
|