@semics-tech/emdash-events 1.0.0-rc.3 → 1.0.0-rc.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/index.mjs +6 -2
  3. package/dist/manifest.json +6 -5
  4. package/dist/plugin.mjs +7 -6
  5. package/dist/ts/astro/lib/call.d.ts +2 -0
  6. package/dist/ts/astro/lib/call.js +2 -0
  7. package/dist/ts/astro/lib/page.d.ts +44 -0
  8. package/dist/ts/astro/lib/page.js +123 -0
  9. package/dist/ts/integration/index.d.ts +15 -1
  10. package/dist/ts/integration/index.js +21 -1
  11. package/emdash-plugin.jsonc +8 -3
  12. package/package.json +6 -1
  13. package/src/astro/AttendeeList.astro +36 -15
  14. package/src/astro/BookingPage.astro +72 -10
  15. package/src/astro/BookingStatus.astro +209 -54
  16. package/src/astro/BookingWidget.astro +284 -59
  17. package/src/astro/CancelBooking.astro +80 -0
  18. package/src/astro/PageBrand.astro +18 -0
  19. package/src/astro/PageOrganiser.astro +22 -0
  20. package/src/astro/SetupPage.astro +88 -0
  21. package/src/astro/TicketPass.astro +131 -33
  22. package/src/astro/checkout-endpoint.ts +21 -3
  23. package/src/astro/lib/attendees.ts +76 -10
  24. package/src/astro/lib/book-link.ts +46 -0
  25. package/src/astro/lib/call.ts +4 -0
  26. package/src/astro/lib/checkout-form.ts +49 -1
  27. package/src/astro/lib/encryption.ts +67 -0
  28. package/src/astro/lib/list.ts +22 -0
  29. package/src/astro/lib/mapping.ts +106 -0
  30. package/src/astro/lib/page.ts +143 -0
  31. package/src/astro/lib/pass.ts +9 -0
  32. package/src/astro/lib/payment.ts +6 -10
  33. package/src/astro/lib/setup.ts +129 -0
  34. package/src/astro/lib/widget.ts +172 -7
  35. package/src/astro/virtual.d.ts +25 -1
  36. package/src/client/booking.ts +42 -6
  37. package/src/client/forget-form.ts +16 -0
  38. package/src/client/picker.ts +20 -9
  39. package/src/client/print.ts +12 -0
  40. package/src/i18n/ar.ts +55 -1
  41. package/src/i18n/en.ts +57 -1
@@ -25,6 +25,10 @@ export interface PublicEvent {
25
25
  available?: number | null;
26
26
  minPerOrder?: number | null;
27
27
  maxPerOrder?: number | null;
28
+ /** Events Pro (T174d): a per-person add-on, not a place; the widget lists it under the tickets, capped by the places. */
29
+ addon?: boolean;
30
+ /** Events Pro (T174f): a party package, priced once for its people (`minPerOrder` to `maxPerOrder`). */
31
+ package?: boolean;
28
32
  }>;
29
33
  /** Upcoming open dates, earliest first: up to 200 from the asked `from` (T130). */
30
34
  occurrences?: Array<{ id: string; startsAt: string; endsAt?: string | null; available?: number | null }>;
@@ -32,25 +36,124 @@ export interface PublicEvent {
32
36
  more?: boolean;
33
37
  /** The event sells slots of a schedule (T129): the form uses the day-then-time picker (T130). */
34
38
  slots?: boolean;
39
+ /** The event takes booking requests (T174a): the form asks for a date and a time window instead of a date. */
40
+ requests?: PublicRequests;
35
41
  /** Public Turnstile site key, when the site owner configured one. */
36
42
  turnstileSiteKey?: string;
37
43
  /** True when the event requires a signed waiver (T066): the booking form then asks for attendees. */
38
44
  waiver?: boolean;
45
+ /** Events Pro: that waiver is signed per attendee, so its seat rules can be checked before reserving. */
46
+ waiverEach?: boolean;
47
+ /** Events Pro (T160): the waiver is signed after payment (`waiverTiming: "after-payment"`), for a paid order. */
48
+ waiverAfter?: boolean;
39
49
  /** True when the core takes promo codes (Events Pro, T078): the widget then shows a code field. */
40
50
  promoCodes?: boolean;
51
+ /** True when Events Pro is paired with Vouchers (T166): the widget then shows a "Gift voucher code" field. */
52
+ vouchers?: boolean;
41
53
  /** True when a sold-out event takes a waitlist (T081): the widget then shows a "Join the waitlist" form. */
42
54
  waitlist?: boolean;
43
55
  /** Custom attendee questions (Events Pro, T080): the buyer answers them once per booking. */
44
56
  questions?: PublicQuestion[];
45
57
  }
46
58
 
59
+ /** What an event takes booking requests for (T174a): windows in local `HH:MM`, weekdays `MO`..`SU`. */
60
+ export interface PublicRequests {
61
+ windows: RequestWindowView[];
62
+ days: string[];
63
+ aheadDays: number;
64
+ noticeDays: number;
65
+ closedDates: string[];
66
+ /**
67
+ * T176: the first rule that matches a date replaces `windows` that day: its weekday in `days`, the date
68
+ * `from` to `to` (`MM-DD`, inclusive, wrapping the year), and with `summer` the zone on daylight-saving time.
69
+ */
70
+ rules?: Array<{ days?: string[]; from?: string; to?: string; summer?: boolean; windows: RequestWindowView[] }>;
71
+ }
72
+
73
+ export interface RequestWindowView {
74
+ id: string;
75
+ label: string;
76
+ start: string;
77
+ end: string;
78
+ }
79
+
80
+ const WEEKDAYS = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"];
81
+
82
+ /** Every window an event's requests offer (T176): the event's, then each rule's not already listed. */
83
+ export function requestWindows(r: PublicRequests): RequestWindowView[] {
84
+ const all = [r, ...(r.rules ?? [])].flatMap((x) => x.windows);
85
+ return all.filter((w, i) => all.findIndex((x) => x.id === w.id) === i);
86
+ }
87
+
88
+ /** The zone's UTC offset in minutes at an instant (0 when the zone is unknown). */
89
+ function offsets(zone: string): (at: number) => number {
90
+ let format: Intl.DateTimeFormat;
91
+ try {
92
+ format = new Intl.DateTimeFormat("en-US", { timeZone: zone, timeZoneName: "longOffset" });
93
+ } catch {
94
+ return () => 0;
95
+ }
96
+ return (at) => {
97
+ const name = format.formatToParts(at).find((p) => p.type === "timeZoneName")?.value;
98
+ const m = /([+-])(\d\d):(\d\d)/.exec(name ?? "");
99
+ return m ? (m[1] === "-" ? -1 : 1) * (Number(m[2]) * 60 + Number(m[3])) : 0;
100
+ };
101
+ }
102
+
103
+ /**
104
+ * The ids of the windows a request may ask for on a local date (T176), as the core checks them: the first
105
+ * matching rule's, else the event's. `summer`: the zone's offset that day is above its least of the year.
106
+ */
107
+ function windowIdsOn(r: PublicRequests, day: Date, off: (at: number) => number): string[] {
108
+ const md = day.toISOString().slice(5, 10);
109
+ const y = day.getUTCFullYear();
110
+ const rule = r.rules?.find(
111
+ ({ days, from = "01-01", to = "12-31", summer }) =>
112
+ (!days || days.includes(WEEKDAYS[day.getUTCDay()] as string)) &&
113
+ (from <= to ? from <= md && md <= to : from <= md || md <= to) &&
114
+ (!summer || off(day.getTime() + 432e5) > Math.min(off(Date.UTC(y, 0)), off(Date.UTC(y, 6)))),
115
+ );
116
+ return (rule ?? r).windows.map((w) => w.id);
117
+ }
118
+
119
+ /**
120
+ * The dates a request may ask for (T174a), as the core checks them: allowed weekdays from `noticeDays` to
121
+ * `aheadDays` after today in the event's zone, without closed dates. `value` is the local `YYYY-MM-DD`;
122
+ * `windows` the ids of the windows offered that day (T176).
123
+ */
124
+ export function requestDates(
125
+ r: PublicRequests,
126
+ zone: string,
127
+ now: number,
128
+ locale?: string,
129
+ ): Array<{ value: string; label: string; windows: string[] }> {
130
+ let today: string;
131
+ try {
132
+ today = new Intl.DateTimeFormat("en-CA", { timeZone: zone }).format(new Date(now));
133
+ } catch {
134
+ today = new Date(now).toISOString().slice(0, 10);
135
+ }
136
+ const start = Date.parse(`${today}T00:00:00Z`);
137
+ const label = new Intl.DateTimeFormat(locale, { dateStyle: "full", timeZone: "UTC" });
138
+ const out: Array<{ value: string; label: string; windows: string[] }> = [];
139
+ const off = offsets(zone);
140
+ for (let i = r.noticeDays; i <= r.aheadDays; i++) {
141
+ const day = new Date(start + i * 864e5);
142
+ const value = day.toISOString().slice(0, 10);
143
+ if (r.days.includes(WEEKDAYS[day.getUTCDay()] as string) && !r.closedDates.includes(value)) {
144
+ out.push({ value, label: label.format(day), windows: windowIdsOn(r, day, off) });
145
+ }
146
+ }
147
+ return out;
148
+ }
149
+
47
150
  /**
48
151
  * Ticket type names by id from a `public/event` answer, for `<BookingStatus>` (T134): the booking's
49
152
  * lines carry only ids (UUIDs for types made in the editor). A hidden type is not listed there.
50
153
  */
51
154
  /** Whether the booking page hands the booking to the suite's reconciliation: lookups, or void intents (T152). */
52
- export const reconcileWanted = (b: Pick<BookingView, "waiver"> | undefined): boolean =>
53
- Boolean(b?.waiver?.lookups || b?.waiver?.voids);
155
+ export const reconcileWanted = (b: Pick<BookingView, "waiver" | "voucher"> | undefined): boolean =>
156
+ Boolean(b?.waiver?.lookups || b?.waiver?.voids || b?.voucher?.settle);
54
157
 
55
158
  export function ticketNames(event: Pick<PublicEvent, "ticketTypes"> | undefined): Record<string, string> {
56
159
  return Object.fromEntries((event?.ticketTypes ?? []).map((t) => [t.id, t.name]));
@@ -71,9 +174,28 @@ export interface BookingView {
71
174
  bookingRef: string;
72
175
  status: string;
73
176
  eventId?: string;
74
- lines: Array<{ ticketTypeId: string; qty: number }>;
75
- totals: { totalMinor: number; currency: string };
177
+ /** `addon` (T174d): a per-person add-on line, not a place. `people` (T174f): a party package's places. */
178
+ lines: Array<{ ticketTypeId: string; qty: number; addon?: boolean; people?: number }>;
179
+ /** `voucherMinor`: what a gift voucher paid (Events Pro, T166), already taken off `totalMinor`. */
180
+ totals: { totalMinor: number; currency: string; voucherMinor?: number };
181
+ /** Events Pro (T166): the voucher hold's signed outcome, which the suite passes to Vouchers. */
182
+ voucher?: { settle?: string | null };
76
183
  holdExpiresAt?: string;
184
+ /** The event's public info: the booked session (`startsAt`, in `timezone`) and `venue` lead the page (T157); `slug` for "Book again". */
185
+ event?: { title?: string; startsAt?: string; timezone?: string | null; venue?: string | null; slug?: string | null };
186
+ /** A booking request whose time is still to be agreed (T174a): what was asked for, "Sat 12 Dec, AM". */
187
+ requested?: string;
188
+ /**
189
+ * Events Pro (T174c): another time the organiser proposed for a request awaiting approval. The buyer accepts it or
190
+ * says it doesn't work (`public/booking/request/accept` / `.../refuse`) by `holdExpiresAt`.
191
+ */
192
+ proposed?: { startsAt: string; endsAt?: string };
193
+ /** Why the organiser declined (`status: "declined"`), when they said. */
194
+ declineReason?: string | null;
195
+ /** Declined, a price was due and no money was taken (`closeBooking`). */
196
+ notCharged?: boolean;
197
+ /** Expired, this means it ran out waiting for the organiser's decision (Pro: not one approved but left unpaid). */
198
+ undecided?: boolean;
77
199
  /** `qr`: Events Pro's QR matrix of `code` (T082), drawn by `<TicketPass>`; Free sends none. */
78
200
  attendees: Array<{ name: string; ticketTypeId?: string; status: string; code?: string; qr?: unknown }>;
79
201
  canCancel: boolean;
@@ -86,23 +208,26 @@ export interface BookingView {
86
208
  * has ended (expired, cancelled), Pro lists instead a void intent per seat not signed (T152).
87
209
  */
88
210
  waiver?: { refs: string[]; lookups?: Record<string, string>; voids?: Record<string, string> };
211
+ /** Events Pro (T160): the booking's waiver comes after payment, so a paid booking is confirmed with seats still to sign. */
212
+ waiverAfter?: boolean;
89
213
  /**
90
214
  * Events Pro (T133): a waiver booking's attendee signing list. Each attendee then also carries
91
215
  * `seat`, `signing`, `signs`, `email` and `minor` (`SigningAttendee` in `lib/attendees.ts`);
92
216
  * `editable` says whether names and emails may still be changed, until `editUntil`.
93
217
  */
94
- signingList?: { editable: boolean; editUntil?: string };
218
+ /** `minors` (T174e): a booking request, whose seats the edit form may also mark under 18. */
219
+ signingList?: { editable: boolean; editUntil?: string; minors?: boolean };
95
220
  }
96
221
 
97
222
  /** A custom question's field is `q:<question id>` (T080). */
98
223
  export type QuestionField = `q:${string}`;
99
- export type WidgetField = "occurrence" | "promo" | "tickets" | "name" | "email" | QuestionField;
224
+ export type WidgetField = "occurrence" | "promo" | "voucher" | "tickets" | "name" | "email" | QuestionField;
100
225
 
101
226
  /** Question ids safe in HTML ids, field names and the widget's error URL. */
102
227
  export const QUESTION_ID = /^[A-Za-z0-9_-]{1,64}$/;
103
228
 
104
229
  /** In form order: the first one is where focus goes. */
105
- export const WIDGET_FIELDS = ["occurrence", "promo", "tickets", "name", "email"] as const;
230
+ export const WIDGET_FIELDS = ["occurrence", "promo", "voucher", "tickets", "name", "email"] as const;
106
231
 
107
232
  export const WIDGET_PARAMS = { error: "booking_error", fields: "booking_fields", event: "booking_event" } as const;
108
233
 
@@ -121,6 +246,11 @@ const ERROR_CODES = [
121
246
  "PROMO_EXHAUSTED",
122
247
  "PROMO_ORDER_TOO_LARGE",
123
248
  "PROMO_UNAVAILABLE",
249
+ "VOUCHER_INVALID",
250
+ "VOUCHER_NO_BALANCE",
251
+ "VOUCHER_WRONG_ACTIVITY",
252
+ "VOUCHER_CURRENCY",
253
+ "VOUCHER_UNAVAILABLE",
124
254
  "INTERNAL",
125
255
  ] as const;
126
256
 
@@ -228,6 +358,8 @@ export function validateCheckoutFields(v: CheckoutFieldValues): WidgetField[] {
228
358
 
229
359
  const ISSUE_FIELDS: Array<[RegExp, WidgetField]> = [
230
360
  [/^occurrenceId/, "occurrence"],
361
+ // A refused booking request's date or window (T174a): the request's date field is the "occurrence" one.
362
+ [/^request/, "occurrence"],
231
363
  [/^lines/, "tickets"],
232
364
  [/^buyer\.name/, "name"],
233
365
  [/^buyer\.email/, "email"],
@@ -302,3 +434,36 @@ export const statusLabel = (status: string, locale?: string) =>
302
434
 
303
435
  /** English status labels (the 1.0 API; components use `statusLabel`). */
304
436
  export const STATUS_LABELS: Record<string, string> = Object.fromEntries(STATUSES.map((s) => [s, statusLabel(s, "en")]));
437
+
438
+ /**
439
+ * The booking as it stands at `now`: a hold past its deadline has lapsed even before the sweeper moves it (the core
440
+ * refuses anything on it, and the waiver page already says so), so the page shows it as expired.
441
+ */
442
+ export function asOfNow<T extends Pick<BookingView, "status" | "holdExpiresAt" | "canCancel">>(
443
+ booking: T,
444
+ now: number,
445
+ ): T {
446
+ const until = booking.holdExpiresAt ? Date.parse(booking.holdExpiresAt) : Number.NaN;
447
+ if (!(until <= now)) return booking;
448
+ const { holdExpiresAt: _gone, ...rest } = booking;
449
+ return { ...rest, status: "expired", canCancel: false } as T;
450
+ }
451
+
452
+ /** What a booking that ended without going ahead should say beyond its status (declined, or lapsed). */
453
+ export function endedNotes(
454
+ booking: Pick<BookingView, "status" | "declineReason" | "notCharged" | "undecided"> & {
455
+ totals?: BookingView["totals"];
456
+ },
457
+ locale?: string,
458
+ ) {
459
+ if (booking.status === "expired") {
460
+ if (booking.undecided) return [t(locale, "booking.undecided")];
461
+ // A paid one has the payment section's "This booking expired": only what that does not say.
462
+ return [t(locale, booking.totals?.totalMinor ? "booking.signAgain" : "booking.lapsed")];
463
+ }
464
+ if (booking.status !== "declined") return [];
465
+ return [
466
+ ...(booking.declineReason ? [t(locale, "booking.declinedReason", { reason: booking.declineReason })] : []),
467
+ ...(booking.notCharged ? [t(locale, "booking.notCharged")] : []),
468
+ ];
469
+ }
@@ -1,6 +1,8 @@
1
1
  // Provided by the integration's Vite plugin (`eventsIntegration({ pluginId })`).
2
2
  declare module "virtual:semics-events/config" {
3
3
  export const pluginId: string;
4
+ /** How the site dresses the plugin's own pages (`eventsIntegration({ page })`). */
5
+ export const page: import("./lib/page").PageOptions;
4
6
  /** The e-sign core's plugin id, or `null` when e-sign is not configured (`eventsIntegration({ esignPluginId })`). */
5
7
  export const esignPluginId: string | null;
6
8
  /**
@@ -10,7 +12,29 @@ declare module "virtual:semics-events/config" {
10
12
  export const reconcile:
11
13
  | ((
12
14
  ctx: import("./lib/call").PublicRouteContext,
13
- input: { booking: import("./lib/widget").BookingView; pluginId: string; esignPluginId: string },
15
+ input: {
16
+ booking: import("./lib/widget").BookingView;
17
+ pluginId: string;
18
+ esignPluginId: string;
19
+ vouchersPluginId?: string;
20
+ },
14
21
  ) => Promise<{ forwarded: number }>)
15
22
  | null;
23
+ /** Gift vouchers (T166): only exported with `eventsIntegration({ vouchers })`; read through a namespace import. */
24
+ export const vouchersPluginId: string | undefined;
25
+ export const holdVoucher:
26
+ | ((
27
+ ctx: import("./lib/call").PublicRouteContext,
28
+ input: { code: string; bookingRef: string; accessToken: string },
29
+ ids: { eventsPluginId: string; vouchersPluginId: string },
30
+ ) => Promise<import("./lib/checkout-form").VoucherHoldResult>)
31
+ | undefined;
32
+ /** T168: the suite's check of a code before reserving; exported with `holdVoucher`. */
33
+ export const checkVoucher:
34
+ | ((
35
+ ctx: import("./lib/call").PublicRouteContext,
36
+ input: { code: string; eventId: string; ticketTypeIds: string[] },
37
+ ids: { vouchersPluginId: string },
38
+ ) => Promise<{ ok: true } | { ok: false; code: string }>)
39
+ | undefined;
16
40
  }
@@ -66,12 +66,24 @@ export function validateBooking(v: BookingValues): BookingField[] {
66
66
  return bad;
67
67
  }
68
68
 
69
- export function orderTotalMinor(lines: ReadonlyArray<{ qty: number; priceMinor: number }>): number {
69
+ /** A party package (T174f) is priced once for its people; every other line per ticket. */
70
+ export function orderTotalMinor(lines: ReadonlyArray<{ qty: number; priceMinor: number; package?: boolean }>): number {
70
71
  let total = 0;
71
- for (const line of lines) if (line.qty > 0) total += line.qty * line.priceMinor;
72
+ for (const line of lines) if (line.qty > 0) total += (line.package ? 1 : line.qty) * line.priceMinor;
72
73
  return total;
73
74
  }
74
75
 
76
+ /** Fewer than a ticket type's fewest per order (a party package's people, T174g); none is fine. Reserve refuses it too. */
77
+ export const tooFew = (qty: number, min: number) => qty > 0 && qty < min;
78
+
79
+ /**
80
+ * The most of a per-person add-on (T174d) the buyer may order: one each for the places chosen, within the add-on's
81
+ * own limit. Pro's reserve refuses more (`INVALID_QUANTITY`), so without this script the server says so.
82
+ */
83
+ export function addonMax(places: number, own: number): number {
84
+ return Math.max(0, Math.min(own, places));
85
+ }
86
+
75
87
  /** `free` is the page's word for a zero total (the widget renders it as `data-free`, T102). */
76
88
  export function formatMinor(minor: number, currency: string, locale: string, free: string): string {
77
89
  if (minor === 0) return free;
@@ -131,12 +143,27 @@ export function enhance(form: HTMLFormElement): void {
131
143
  if (button) button.disabled = false;
132
144
 
133
145
  const qtyInputs = Array.from(form.querySelectorAll<HTMLInputElement>('input[name^="qty:"]'));
146
+ // Per-person add-ons (T174d) are not places: capped live by the places chosen.
147
+ const addons = qtyInputs.filter((i) => i.dataset.addon !== undefined);
148
+ const places = qtyInputs.filter((i) => i.dataset.addon === undefined);
149
+ const capAddons = () => {
150
+ const chosen = places.reduce((n, i) => n + Math.max(qtyOf(i), 0), 0);
151
+ for (const a of addons) {
152
+ const most = addonMax(chosen, Number(a.dataset.max) || 50);
153
+ a.max = String(most);
154
+ if (qtyOf(a) > most) a.value = String(most);
155
+ }
156
+ };
134
157
  const total = form.querySelector<HTMLElement>("[data-total]");
135
158
  const totalValue = total?.querySelector<HTMLElement>("[data-total-value]");
136
159
  const updateTotal = () => {
137
160
  if (!total || !totalValue) return;
138
161
  const minor = orderTotalMinor(
139
- qtyInputs.map((i) => ({ qty: qtyOf(i), priceMinor: Number(i.dataset.priceMinor) || 0 })),
162
+ qtyInputs.map((i) => ({
163
+ qty: qtyOf(i),
164
+ priceMinor: Number(i.dataset.priceMinor) || 0,
165
+ package: i.dataset.package !== undefined,
166
+ })),
140
167
  );
141
168
  totalValue.textContent = formatMinor(
142
169
  minor,
@@ -146,8 +173,12 @@ export function enhance(form: HTMLFormElement): void {
146
173
  );
147
174
  total.hidden = false;
148
175
  };
149
- for (const input of qtyInputs) input.addEventListener("input", updateTotal);
150
- updateTotal();
176
+ const changed = () => {
177
+ capAddons();
178
+ updateTotal();
179
+ };
180
+ for (const input of qtyInputs) input.addEventListener("input", changed);
181
+ changed();
151
182
 
152
183
  form.addEventListener("submit", (event) => {
153
184
  if (form.dataset.submitting) {
@@ -158,17 +189,22 @@ export function enhance(form: HTMLFormElement): void {
158
189
  ...validateBooking({
159
190
  name: fieldValue(form, "name"),
160
191
  email: fieldValue(form, "email"),
161
- lines: qtyInputs.filter((i) => qtyOf(i) > 0).length,
192
+ // Add-ons alone are no order: only places count as lines here.
193
+ lines: places.filter((i) => qtyOf(i) > 0).length,
162
194
  needsOccurrence: fieldValue(form, "needsOccurrence") === "1",
163
195
  occurrenceId: fieldValue(form, "occurrenceId"),
164
196
  }),
165
197
  ...missingAnswers(questionStates(form)),
166
198
  ];
199
+ const short = places.find((i) => tooFew(qtyOf(i), Number(i.dataset.min)));
200
+ if (short && !bad.includes("tickets")) bad.push("tickets");
167
201
  const needsCheck = form.dataset.turnstile === "on" && fieldValue(form, "cf-turnstile-response") === "";
168
202
  if (bad.length > 0 || needsCheck) {
169
203
  event.preventDefault();
170
204
  formAlert(form, needsCheck && bad.length === 0 ? (form.dataset.turnstileMessage ?? "") : "");
171
205
  showErrors(form, bad);
206
+ const message = short && form.querySelector<HTMLElement>('[data-error-for="tickets"]');
207
+ if (message) message.textContent = short.dataset.minMessage ?? "";
172
208
  return;
173
209
  }
174
210
  formAlert(form, "");
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Forgets what the suite's booking form kept for a refusal (`keep-form.ts` in the suite): a person who reaches the
3
+ * booking page has got past the form, and on a shared device their details must not linger. Self-contained.
4
+ */
5
+ export function forgetKeptForms(storage: Pick<Storage, "length" | "key" | "removeItem">): void {
6
+ for (let i = storage.length - 1; i >= 0; i--) {
7
+ const key = storage.key(i);
8
+ if (key?.startsWith("semics-waiver-form:")) storage.removeItem(key);
9
+ }
10
+ }
11
+
12
+ try {
13
+ if (typeof document !== "undefined") forgetKeptForms(sessionStorage);
14
+ } catch {
15
+ // Storage is blocked: nothing was kept either.
16
+ }
@@ -60,10 +60,14 @@ export function enhancePicker(picker: HTMLElement): void {
60
60
  const radios = (group: HTMLElement) => Array.from(group.querySelectorAll<HTMLButtonElement>('[role="radio"]'));
61
61
  const isOpen = (b: HTMLElement) => b.getAttribute("aria-disabled") !== "true";
62
62
 
63
+ // The picker's own changes, which `showSelected` (below) need not follow.
64
+ let own = false;
63
65
  const setSelect = (value: string) => {
64
66
  if (select.value === value) return;
65
67
  select.value = value;
68
+ own = true;
66
69
  select.dispatchEvent(new Event("change", { bubbles: true }));
70
+ own = false;
67
71
  };
68
72
 
69
73
  const chooseTime = (button: HTMLButtonElement, focus: boolean) => {
@@ -127,15 +131,22 @@ export function enhancePicker(picker: HTMLElement): void {
127
131
  }
128
132
  }
129
133
 
130
- // A value the browser kept (back/forward, a failed submit): show its day and time.
131
- const kept =
132
- select.value && picker.querySelector<HTMLButtonElement>(`[data-occurrence="${CSS.escape(select.value)}"]`);
133
- const keptDay =
134
- kept && dayButtons.find((b) => b.dataset.day === kept.closest<HTMLElement>("[data-times]")?.dataset.times);
135
- if (kept && keptDay) {
136
- showDay(keptDay, false);
137
- chooseTime(kept, false);
138
- }
134
+ // A value the browser kept (back/forward, a failed submit): show its day and time. Also when a script sets
135
+ // the select later and says so with `change` (the suite's refused-form restore, whose script may run after
136
+ // this one, T157); the picker's own changes are skipped.
137
+ const showSelected = () => {
138
+ if (own) return;
139
+ const kept =
140
+ select.value && picker.querySelector<HTMLButtonElement>(`[data-occurrence="${CSS.escape(select.value)}"]`);
141
+ const keptDay =
142
+ kept && dayButtons.find((b) => b.dataset.day === kept.closest<HTMLElement>("[data-times]")?.dataset.times);
143
+ if (kept && keptDay) {
144
+ showDay(keptDay, false);
145
+ chooseTime(kept, false);
146
+ }
147
+ };
148
+ select.addEventListener("change", showSelected);
149
+ showSelected();
139
150
  }
140
151
 
141
152
  if (typeof document !== "undefined") {
@@ -0,0 +1,12 @@
1
+ /**
2
+ * "Print or save as PDF" on the booking page (T157): the button stays hidden without JavaScript (it could do
3
+ * nothing there; the browser's own Print still uses the page's print stylesheet). Self-contained; no text.
4
+ */
5
+ export function wirePrint(doc: Document, print: () => void): void {
6
+ for (const button of doc.querySelectorAll<HTMLButtonElement>("button[data-print]")) {
7
+ button.hidden = false;
8
+ button.addEventListener("click", () => print());
9
+ }
10
+ }
11
+
12
+ if (typeof document !== "undefined") wirePrint(document, () => window.print());
package/src/i18n/ar.ts CHANGED
@@ -3,7 +3,6 @@ import type { Messages } from "./index";
3
3
  /** Arabic (right to left). Plural forms follow `Intl.PluralRules("ar")`: zero, one, two, few, many, other. */
4
4
  export const ar: Messages = {
5
5
  "money.free": "مجاني",
6
- "time.utc": "{time} بالتوقيت العالمي",
7
6
 
8
7
  "list.heading": "الفعاليات القادمة",
9
8
  "list.error": "الفعاليات غير متاحة الآن.",
@@ -20,6 +19,7 @@ export const ar: Messages = {
20
19
  "widget.date": "التاريخ",
21
20
  "widget.chooseDate": "اختر تاريخًا",
22
21
  "widget.dateSoldOut": "{date} (نفدت التذاكر)",
22
+ "widget.window": "الفترة",
23
23
  "widget.picker.earlier": "تواريخ سابقة",
24
24
  "widget.picker.later": "تواريخ لاحقة",
25
25
  "widget.picker.hint": "اختر يومًا لعرض مواعيده.",
@@ -34,7 +34,14 @@ export const ar: Messages = {
34
34
  "widget.promo.label": "رمز الخصم",
35
35
  "widget.promo.apply": "تطبيق الرمز",
36
36
  "widget.promo.update": "تحديث الرمز",
37
+ "widget.voucher.label": "رمز قسيمة الهدية",
38
+ "widget.voucher.have": "هل لديك قسيمة هدية؟",
37
39
  "widget.tickets": "التذاكر",
40
+ "widget.addons": "الإضافات",
41
+ "widget.addonsHint": "لكل شخص، واحدة على الأكثر لكل مكان تحجزه.",
42
+ "widget.addonPrice": "{price} للشخص",
43
+ "widget.packagePrice": "{price} للمجموعة",
44
+ "widget.packagePeople": "كم عدد الأشخاص؟ من {min} إلى {max}",
38
45
  "widget.soldOut": "نفدت التذاكر",
39
46
  "widget.name": "اسمك",
40
47
  "widget.email": "البريد الإلكتروني",
@@ -45,7 +52,9 @@ export const ar: Messages = {
45
52
  "widget.book": "احجز",
46
53
  "widget.field.occurrence": "اختر تاريخًا.",
47
54
  "widget.field.promo": "تحقق من الرمز، أو اترك الحقل فارغًا.",
55
+ "widget.field.voucher": "تحقق من الرمز، أو اترك الحقل فارغًا.",
48
56
  "widget.field.tickets": "اختر تذكرة واحدة على الأقل.",
57
+ "widget.field.minimum": "اختر {min} على الأقل من {name}، أو لا شيء.",
49
58
  "widget.field.name": "أدخل اسمك.",
50
59
  "widget.field.email": "أدخل بريدًا إلكترونيًا صحيحًا.",
51
60
  "widget.error.BAD_REQUEST": "يُرجى مراجعة البيانات المحددة.",
@@ -60,6 +69,11 @@ export const ar: Messages = {
60
69
  "widget.error.PROMO_ORDER_TOO_LARGE":
61
70
  "لا يمكن استخدام هذا الرمز لطلب بهذا الحجم. اطلب أنواعًا أقل من التذاكر في المرة الواحدة.",
62
71
  "widget.error.PROMO_UNAVAILABLE": "لا يمكن استخدام هذا الرمز الآن. احذفه للحجز من دونه.",
72
+ "widget.error.VOUCHER_INVALID": "رمز قسيمة الهدية هذا غير صالح.",
73
+ "widget.error.VOUCHER_NO_BALANCE": "لم يتبقَّ رصيد في قسيمة الهدية هذه.",
74
+ "widget.error.VOUCHER_WRONG_ACTIVITY": "قسيمة الهدية هذه مخصصة لنشاط آخر.",
75
+ "widget.error.VOUCHER_CURRENCY": "قسيمة الهدية هذه بعملة مختلفة.",
76
+ "widget.error.VOUCHER_UNAVAILABLE": "لا يمكن استخدام قسائم الهدايا الآن. احذف الرمز للحجز بدونه.",
63
77
  "widget.error.INTERNAL": "حدث خطأ ما. يُرجى المحاولة مرة أخرى.",
64
78
 
65
79
  "waitlist.heading": "انضم إلى قائمة الانتظار",
@@ -101,12 +115,38 @@ export const ar: Messages = {
101
115
  "booking.status": "حالة الحجز",
102
116
  "booking.reference": "الرقم المرجعي",
103
117
  "booking.heldUntil": "تذاكرك محجوزة حتى {time}.",
118
+ "booking.declinedReason": "سبب المنظّم: {reason}",
119
+ "booking.notCharged": "لم يُخصم أي مبلغ من بطاقتك.",
120
+ "booking.lapsed":
121
+ "انتهت صلاحية هذا الحجز لأنه لم يكتمل في الوقت المحدد، لذا أُتيحت أماكنه للآخرين. للمتابعة، ابدأ حجزًا جديدًا؛ وإذا كان هناك إقرار تنازل فستوقّعه مرة أخرى.",
122
+ "booking.undecided":
123
+ "لم يبتّ المنظّم في هذا الطلب في الوقت المحدد، لذا انتهت صلاحيته وأُتيحت أماكنه للآخرين. للمتابعة، ابدأ حجزًا جديدًا؛ وإذا كان هناك إقرار تنازل فستوقّعه مرة أخرى.",
124
+ "booking.signAgain": "إذا كان هناك إقرار تنازل، فستوقّعه مرة أخرى عند الحجز.",
125
+ "booking.bookAgain": "احجز مرة أخرى",
104
126
  "booking.decideBy": "سيوافق المنظّم على طلبك أو يرفضه بحلول {time}، وسنراسلك بالبريد الإلكتروني.",
127
+ "booking.requestSent": "أُرسل الطلب: سنتفق معك على موعد.",
128
+ "booking.requested": "المطلوب: {when}، والموعد قيد الاتفاق.",
129
+ "booking.proposal.title": "اقترح المنظّم موعدًا آخر",
130
+ "booking.proposal.lead": "لا يمكننا الالتزام بالموعد الذي طلبته، لكن يمكننا تقديم هذا الموعد:",
131
+ "booking.proposal.answerBy": "يُرجى الرد بحلول {time}. إن لم تفعل، يسقط الطلب ويُردّ أي مبلغ مدفوع كاملًا.",
132
+ "booking.proposal.accept": "قبول هذا الموعد",
133
+ "booking.proposal.refuse": "هذا الموعد لا يناسبني",
134
+ "booking.proposal.refuseNote": "سيُلغى طلبك ويُردّ أي مبلغ مدفوع كاملًا.",
135
+ "booking.proposal.accepted": "شكرًا لك: تأكّد حجزك في الموعد الجديد.",
136
+ "booking.proposal.refused": "أُلغي طلبك. سيُردّ أي مبلغ مدفوع كاملًا.",
137
+ "booking.proposal.failed": "تعذّر علينا تسجيل ردّك. يُرجى المحاولة مرة أخرى.",
105
138
  "booking.line": "{qty} × {name}",
139
+ "booking.packageLine": "{name} لـ {people} أشخاص",
140
+ "booking.voucher": "قسيمة هدية",
106
141
  "booking.total": "المجموع",
107
142
  "booking.cancelUntil": "يمكنك الإلغاء حتى {time}.",
108
143
  "booking.cancel": "إلغاء الحجز",
109
144
  "booking.cancelFailed": "تعذّر علينا إلغاء هذا الحجز.",
145
+ "booking.cancelConfirm": "يؤدي الإلغاء إلى تحرير أماكنك، ولا يمكن التراجع عنه.",
146
+ "booking.cancelYes": "نعم، ألغِ هذا الحجز",
147
+ "booking.attendeesHeading": "الحضور",
148
+ "booking.print": "اطبع أو احفظ بصيغة PDF",
149
+ "booking.organiser": "المنظِّم: {name}",
110
150
  "booking.offer.intro": "التذاكر من قائمة الانتظار محجوزة لك. استلمها على هذا الجهاز؛ يعمل الرابط مرة واحدة.",
111
151
  "booking.offer.button": "استلم تذاكري",
112
152
  "booking.open.intro": "افتح حجزك على هذا الجهاز. يعمل الرابط مرة واحدة، وبعدها يتذكر هذا المتصفح حجزك.",
@@ -133,6 +173,8 @@ export const ar: Messages = {
133
173
  "booking.attendees.signed": "موقَّع",
134
174
  "booking.attendees.waiting": "بانتظار التوقيع",
135
175
  "booking.attendees.minor": "دون 18 عامًا: توقّع أنت بصفتك وليّ الأمر.",
176
+ "booking.attendees.notArrived":
177
+ "لم تصل الدعوة؟ تحقّق من العنوان وأعد إرسالها، أو استخدم التوقيع الآن. لا يمكننا رؤية الرسائل المرتجعة: تبقى هذه القائمة على حالة الانتظار حتى يوقّعوا.",
136
178
  "booking.attendees.emailed": "أُرسلت دعوة بالبريد الإلكتروني إلى {email}.",
137
179
  "booking.attendees.signNow": "وقّع الآن على هذا الجهاز",
138
180
  "booking.attendees.resend": "أعد إرسال الدعوة",
@@ -143,6 +185,17 @@ export const ar: Messages = {
143
185
  "booking.attendees.save": "حفظ التغييرات",
144
186
  "booking.attendees.saved": "حُفظت بيانات الحضور. كل من تغيّرت بياناته سيصله طلب توقيع جديد.",
145
187
  "booking.attendees.resent": "أعدنا إرسال دعوة التوقيع.",
188
+ "booking.attendees.pending": "التنازل بانتظار التوقيع",
189
+ "booking.attendees.unnamed": "أضف اسم هذا الشخص وبريده الإلكتروني أدناه: تُرسل إليه دعوة توقيع التنازل عند الحفظ.",
190
+ "booking.attendees.under18": "دون 18 عامًا",
191
+ "booking.attendees.invited": "أرسلنا التنازل بالبريد الإلكتروني إلى البالغين الآخرين لتوقيعه.",
192
+ "booking.waiverStep.title": "الخطوة الأخيرة: وقّع التنازل",
193
+ "booking.waiverStep.lead":
194
+ "استلمنا الدفع. لا يزال على كل مشارك توقيع التنازل: إلى أن يفعل يظهر بانتظار التوقيع ولا يمكن تسجيل حضوره.",
195
+ "booking.waiverStep.sign": "وقّع التنازل",
196
+ "booking.waiverStep.invite": "أرسل التنازلات بالبريد",
197
+ "booking.waiverStep.emailed":
198
+ "يُرسل إلى البالغين الذين لديهم بريد إلكتروني خاص بهم التنازل لتوقيعه عند الضغط على الزر.",
146
199
  "booking.error.ATTENDEE_SIGNED": "لا يمكن تغيير بيانات شخص وقّع إقرار التنازل.",
147
200
  "booking.error.ATTENDEES_LOCKED": "لم يعد بالإمكان تغيير بيانات الحضور عبر الإنترنت.",
148
201
  "booking.error.ATTENDEE_INVALID": "تحقّق من اسم كل شخص وعنوان بريده الإلكتروني.",
@@ -156,6 +209,7 @@ export const ar: Messages = {
156
209
 
157
210
  "pass.qr": "رمز QR لرمز تسجيل الحضور",
158
211
  "pass.code": "رمز تسجيل الحضور",
212
+ "pass.codeShow": "إظهار الرمز لكتابته يدويًا",
159
213
  "pass.status.pending": "بانتظار توقيع إقرار التنازل",
160
214
  "pass.status.cancelled": "ملغاة",
161
215
  "calendar.add": "أضف إلى التقويم",