riverbankcms 0.34.0 → 0.36.0

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.
@@ -1660,543 +1660,213 @@ function toPageSurfaceSubjectWire(subject) {
1660
1660
  }
1661
1661
 
1662
1662
  //#endregion
1663
- //#region ../core/src/ticket-quantity.ts
1664
- function toPositiveTicketQuantity(value) {
1665
- if (!Number.isFinite(value) || !Number.isInteger(value) || value <= 0) {
1666
- return err("invalid_quantity");
1663
+ //#region ../core/src/date-time-formatter.ts
1664
+ /** Shared Intl engine, internal to core's date presentation owners. */
1665
+ const FORMATTER_CACHE_LIMIT$1 = 100;
1666
+ const dateTimeFormatterCache = new Map();
1667
+ /** Intl's boolean clock option can select h11/h24 on other ICU builds. */
1668
+ function resolveClockCycle(format) {
1669
+ const { hour12, ...explicitFormat } = format;
1670
+ return hour12 === undefined ? explicitFormat : {
1671
+ ...explicitFormat,
1672
+ hourCycle: hour12 ? "h12" : "h23"
1673
+ };
1674
+ }
1675
+ function getDateTimeFormatter(locale, timeZone, format) {
1676
+ const explicitFormat = resolveClockCycle(format);
1677
+ const formatKey = JSON.stringify(Object.entries(explicitFormat).sort(([left], [right]) => left.localeCompare(right)));
1678
+ const key = `${locale}\u0000${timeZone}\u0000${formatKey}`;
1679
+ const cached = dateTimeFormatterCache.get(key);
1680
+ if (cached !== undefined) {
1681
+ return cached;
1667
1682
  }
1668
- return ok(value);
1683
+ if (typeof locale !== "string" || Intl.DateTimeFormat.supportedLocalesOf([locale]).length === 0) {
1684
+ throw new RangeError("An explicit supported locale is required");
1685
+ }
1686
+ if (typeof timeZone !== "string" || timeZone.length === 0) {
1687
+ throw new RangeError("An explicit time zone is required");
1688
+ }
1689
+ const formatter = new Intl.DateTimeFormat(locale, {
1690
+ ...explicitFormat,
1691
+ timeZone
1692
+ });
1693
+ if (dateTimeFormatterCache.size >= FORMATTER_CACHE_LIMIT$1) {
1694
+ dateTimeFormatterCache.clear();
1695
+ }
1696
+ dateTimeFormatterCache.set(key, formatter);
1697
+ return formatter;
1669
1698
  }
1670
- /**
1671
- * The places a booking holds: the sum of its ticket lines' quantities. The one
1672
- * derivation for selections, persisted lines and a booking outcome's lines;
1673
- * null when the total is not a positive whole number.
1674
- */
1675
- function deriveTotalTicketQuantity(lines) {
1676
- const total = lines.reduce((sum, line$1) => sum + line$1.quantity, 0);
1677
- const parsed = toPositiveTicketQuantity(total);
1678
- return parsed.ok ? parsed.value : null;
1699
+ function formatIntlRange(formatter, start, end) {
1700
+ const nativeFormatRange = Reflect.get(formatter, "formatRange");
1701
+ if (typeof nativeFormatRange !== "function") throw new Error("Intl.DateTimeFormat.formatRange is required");
1702
+ const output = Reflect.apply(nativeFormatRange, formatter, [start, end]);
1703
+ if (typeof output !== "string") throw new Error("Intl.DateTimeFormat.formatRange returned a non-string value");
1704
+ return output;
1679
1705
  }
1680
1706
 
1681
1707
  //#endregion
1682
- //#region ../core/src/booking-flexible-balance.ts
1683
- function clampFlexibleBalanceConfiguredAmount(amountCents, totalAmountCents) {
1684
- return Math.max(0, Math.min(amountCents, totalAmountCents));
1685
- }
1686
- function resolveFlexibleBalanceInitialPaymentCents(input) {
1687
- return clampFlexibleBalanceConfiguredAmount(input.config.upfrontAmountCents, input.totalAmountCents);
1688
- }
1689
- function calculateFlexibleBalanceRemainingBalanceCents(input) {
1690
- return Math.max(0, input.totalAmountCents - input.paidAmountCents);
1708
+ //#region ../core/src/booking-date-time/parts.ts
1709
+ function formatToPartsLookup(date, locale, timeZone, format) {
1710
+ return new Map(getDateTimeFormatter(locale, timeZone, format).formatToParts(date).map((part) => [part.type, part.value]));
1691
1711
  }
1692
- function resolveFlexibleBalanceDueAt(input) {
1693
- switch (input.dueDateRule.kind) {
1694
- case "relative_to_start_date": return subtractDaysFromIso(input.bookingStartAt, input.dueDateRule.daysBeforeStart);
1695
- case "fixed_calendar_date": return input.dueDateRule.dueAt;
1696
- default: return assertNever$5(input.dueDateRule);
1712
+
1713
+ //#endregion
1714
+ //#region ../core/src/booking-time-zone.ts
1715
+ const TIME_ZONE_VALIDITY_CACHE_LIMIT = 100;
1716
+ const timeZoneValidityCache = new Map();
1717
+ const NUMERIC_OFFSET_TIME_ZONE_PATTERN = /^(?:[+-]\d{2}(?::?\d{2})?|(?:UTC|GMT)[+-]\d{1,2}(?::?\d{2})?)$/iu;
1718
+ function isValidBookingTimeZone(timeZone) {
1719
+ const normalized = timeZone.trim();
1720
+ if (NUMERIC_OFFSET_TIME_ZONE_PATTERN.test(normalized)) return false;
1721
+ const cached = timeZoneValidityCache.get(normalized);
1722
+ if (cached !== undefined) return cached;
1723
+ let isValid;
1724
+ try {
1725
+ new Intl.DateTimeFormat("en-US", { timeZone: normalized }).format(new Date());
1726
+ isValid = true;
1727
+ } catch {
1728
+ isValid = false;
1697
1729
  }
1730
+ if (timeZoneValidityCache.size >= TIME_ZONE_VALIDITY_CACHE_LIMIT) {
1731
+ timeZoneValidityCache.clear();
1732
+ }
1733
+ timeZoneValidityCache.set(normalized, isValid);
1734
+ return isValid;
1698
1735
  }
1699
- function calculateFlexibleBalanceMinimumPaymentCents(input) {
1700
- if (input.remainingBalanceCents <= 0) {
1701
- return 0;
1736
+ function parseBookingTimeZone(timeZone) {
1737
+ if (typeof timeZone !== "string") return err("invalid-time-zone");
1738
+ const normalized = timeZone.trim();
1739
+ if (normalized.length === 0 || NUMERIC_OFFSET_TIME_ZONE_PATTERN.test(normalized) || !isValidBookingTimeZone(normalized)) {
1740
+ return err("invalid-time-zone");
1702
1741
  }
1703
- const minimumPercentageBps = input.minimumPercentageBps ?? 1e3;
1704
- const percentageFloor = Math.ceil(input.remainingBalanceCents * minimumPercentageBps / 1e4);
1705
- return Math.min(input.remainingBalanceCents, Math.max(input.stripeMinimumChargeCents, percentageFloor));
1742
+ return ok(normalized);
1706
1743
  }
1707
- function assertNever$5(value) {
1708
- throw new Error(`Unexpected value: ${String(value)}`);
1744
+
1745
+ //#endregion
1746
+ //#region ../core/src/booking-date-time/time-zone.ts
1747
+ const FALLBACK_TIMEZONE = "UTC";
1748
+ function getSafeTimeZone(timeZone) {
1749
+ const normalized = typeof timeZone === "string" ? timeZone.trim() : "";
1750
+ return normalized.length > 0 && isValidBookingTimeZone(normalized) ? normalized : FALLBACK_TIMEZONE;
1751
+ }
1752
+ function toBookingTimeZone(timeZone) {
1753
+ return getSafeTimeZone(timeZone);
1754
+ }
1755
+ const DEFAULT_BOOKING_TIME_ZONE = FALLBACK_TIMEZONE;
1756
+ function resolveBookingTimezone(venueTimezone, siteDefaultTimezone) {
1757
+ return venueTimezone ?? siteDefaultTimezone;
1758
+ }
1759
+ function resolveBookingTimeZoneId(...candidates) {
1760
+ const normalized = candidates.map((candidate$1) => typeof candidate$1 === "string" ? candidate$1.trim() : "");
1761
+ return normalized.find((candidate$1) => candidate$1.length > 0 && isValidBookingTimeZone(candidate$1)) ?? FALLBACK_TIMEZONE;
1762
+ }
1763
+ /** Canonical business-zone admission, shared by server and public wire boundaries. */
1764
+ const DEFAULT_BOOKING_BUSINESS_TIME_ZONE = "Europe/London";
1765
+ /** Stored site zones must be valid; a broken read must not silently choose another zone. */
1766
+ function requireBookingTimeZone(value) {
1767
+ const parsed = parseBookingTimeZone(value);
1768
+ if (!parsed.ok) throw new Error("Expected a valid canonical site time zone");
1769
+ return parsed.value;
1770
+ }
1771
+ /** Effect boundary for browser-authored local inputs; formats no displayed date. */
1772
+ function getRuntimeBookingTimeZone() {
1773
+ return resolveBookingTimeZoneId(new Intl.DateTimeFormat("en-GB").resolvedOptions().timeZone);
1774
+ }
1775
+ function resolveBookingBusinessTimeZone(value) {
1776
+ return resolveBookingTimeZoneId(value, DEFAULT_BOOKING_BUSINESS_TIME_ZONE);
1709
1777
  }
1710
1778
 
1711
1779
  //#endregion
1712
- //#region ../core/src/booking-refunds.ts
1713
- function normalizeBookingProtectedDepositPolicyState(value) {
1714
- return value === "not_applicable" || value === "refundable" || value === "non_refundable" ? value : "not_applicable";
1780
+ //#region ../core/src/booking-date-time/instant.ts
1781
+ function parseUtcIsoDateTimeString(value) {
1782
+ const normalized = value.trim();
1783
+ const hasUtcSuffix = normalized.endsWith("Z");
1784
+ const hasExplicitOffset = /[+-]\d{2}:\d{2}$/u.test(normalized);
1785
+ if (!hasUtcSuffix && !hasExplicitOffset) {
1786
+ return err("missing-timezone-offset");
1787
+ }
1788
+ const date = new Date(normalized);
1789
+ if (Number.isNaN(date.getTime())) {
1790
+ return err("invalid-date-time");
1791
+ }
1792
+ return ok(date.toISOString());
1715
1793
  }
1716
- function shouldAllowProtectedDepositOverride(command) {
1717
- return command.protectedDepositOverride === "allow_protected_deposit_override";
1794
+ function toUtcIsoDateTimeString(value) {
1795
+ const parsed = parseUtcIsoDateTimeString(value);
1796
+ if (!parsed.ok) {
1797
+ const message = parsed.error === "missing-timezone-offset" ? `Expected an offset-aware ISO datetime, received "${value}"` : `Expected a valid ISO datetime, received "${value}"`;
1798
+ throw new Error(message);
1799
+ }
1800
+ return parsed.value;
1718
1801
  }
1719
- function createBookingRefundAmountRequest(amountCents) {
1720
- return amountCents == null ? { kind: "full_remaining" } : {
1721
- kind: "partial_amount",
1722
- amountCents
1802
+
1803
+ //#endregion
1804
+ //#region ../core/src/booking-date-time/local.ts
1805
+ const LOCAL_DATE_PATTERN = /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/u;
1806
+ function getZonedDateTimeParts(date, timeZone) {
1807
+ const parts = formatToPartsLookup(date, "en-GB", timeZone, {
1808
+ year: "numeric",
1809
+ month: "2-digit",
1810
+ day: "2-digit",
1811
+ hour: "2-digit",
1812
+ minute: "2-digit",
1813
+ second: "2-digit",
1814
+ hourCycle: "h23"
1815
+ });
1816
+ const read = (type) => Number(parts.get(type) ?? "");
1817
+ return {
1818
+ year: read("year"),
1819
+ month: read("month"),
1820
+ day: read("day"),
1821
+ hour: read("hour"),
1822
+ minute: read("minute"),
1823
+ second: read("second")
1723
1824
  };
1724
1825
  }
1725
- function createOriginalPaymentRefundCommand(options) {
1726
- const protectedDepositOverride = options.protectedDepositOverride ?? "respect_policy";
1727
- return options.kind === "refund_and_revoke" ? {
1728
- kind: "refund_and_revoke",
1729
- amount: { kind: "full_remaining" },
1730
- requestedRefundMethod: "original_payment",
1731
- protectedDepositOverride
1732
- } : {
1733
- kind: "refund_only",
1734
- amount: options.amount ?? { kind: "full_remaining" },
1735
- requestedRefundMethod: "original_payment",
1736
- protectedDepositOverride
1737
- };
1826
+ function formatDateKey(date) {
1827
+ const year = String(date.year).padStart(4, "0");
1828
+ const month = String(date.month).padStart(2, "0");
1829
+ const day = String(date.day).padStart(2, "0");
1830
+ return `${year}-${month}-${day}`;
1738
1831
  }
1739
- /** Narrow an already typed run or schedule write response to its accepted receipt. */
1740
- function isAcceptedEventScheduleUpdate(response) {
1741
- return "kind" in response && response.kind === "accepted_unavailable";
1832
+ function getBookingLocalDateKey(input) {
1833
+ return formatDateKey(getLocalScheduleDate(new Date(input.startsAt), input.timeZone));
1742
1834
  }
1743
- function refundDestinationAmounts(destination, amountCents) {
1835
+ function compareLocalScheduleDates(left, right) {
1836
+ return Date.UTC(left.year, left.month - 1, left.day) - Date.UTC(right.year, right.month - 1, right.day);
1837
+ }
1838
+ function parseBookingLocalDate(value) {
1839
+ const match = LOCAL_DATE_PATTERN.exec(value.trim());
1840
+ if (match === null || match.groups === undefined) {
1841
+ throw new Error(`Invalid booking date format: "${value}" (expected YYYY-MM-DD)`);
1842
+ }
1843
+ const year = Number(match.groups.year);
1844
+ const month = Number(match.groups.month);
1845
+ const day = Number(match.groups.day);
1846
+ const candidate$1 = new Date(Date.UTC(year, month - 1, day, 12, 0, 0));
1847
+ if (Number.isNaN(candidate$1.getTime()) || candidate$1.getUTCFullYear() !== year || candidate$1.getUTCMonth() + 1 !== month || candidate$1.getUTCDate() !== day) {
1848
+ throw new Error(`Invalid booking date format: "${value}" (expected YYYY-MM-DD)`);
1849
+ }
1744
1850
  return {
1745
- cardCents: destination === "card" ? amountCents : 0,
1746
- directCents: destination === "direct" ? amountCents : 0,
1747
- creditCents: destination === "credit" ? amountCents : 0
1851
+ year,
1852
+ month,
1853
+ day
1748
1854
  };
1749
1855
  }
1750
- function addRefundDestinationAmounts(a, b) {
1856
+ /** Canonical schedule text at command and SDK boundaries: HH:MM or HH:MM:SS. */
1857
+ const localScheduleTimePattern = /^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/u;
1858
+ function parseLocalScheduleTime(value) {
1859
+ const match = /^(?<hour>[01]?\d|2[0-3]):(?<minute>[0-5]\d)(?::(?<second>[0-5]\d))?$/u.exec(value.trim());
1860
+ if (match === null || match.groups === undefined) {
1861
+ throw new Error(`Invalid start time format: "${value}" (expected HH:MM or HH:MM:SS)`);
1862
+ }
1863
+ const hour = Number(match.groups.hour);
1864
+ const minute = Number(match.groups.minute);
1865
+ const second = Number(match.groups.second ?? "0");
1751
1866
  return {
1752
- cardCents: a.cardCents + b.cardCents,
1753
- directCents: a.directCents + b.directCents,
1754
- creditCents: a.creditCents + b.creditCents
1755
- };
1756
- }
1757
- function hasDirectRefundFunding(funding) {
1758
- return funding?.some((line$1) => line$1.destination === "direct" && line$1.remainingCents > 0) ?? false;
1759
- }
1760
- /** A refund cut-off as a span of time: "24 hours", "2 days", "1 hour". */
1761
- function formatCancellationCutoffSpan(cutoffHours) {
1762
- if (cutoffHours > 24 && cutoffHours % 24 === 0) return `${cutoffHours / 24} days`;
1763
- return cutoffHours === 1 ? "1 hour" : `${cutoffHours} hours`;
1764
- }
1765
- /** Closed refusal and reconciliation reasons shared by stored reviews and receipts. */
1766
- const scheduleBookingReasonCodes = [
1767
- "closed",
1768
- "switched_off",
1769
- "course_booking",
1770
- "checked_in",
1771
- "cancelled",
1772
- "waitlisted",
1773
- "past",
1774
- "date_missing",
1775
- "payment_pending",
1776
- "not_owner",
1777
- "full",
1778
- "not_enough_room",
1779
- "needs_ticket_choice",
1780
- "ticket_not_usable",
1781
- "tickets_collide",
1782
- "pass_not_accepted",
1783
- "already_booked",
1784
- "not_bookable",
1785
- "not_found",
1786
- "source_changed",
1787
- "source_unavailable",
1788
- "target_full",
1789
- "target_not_bookable",
1790
- "target_changed",
1791
- "already_booked_on_target",
1792
- "no_replacement_in_week",
1793
- "changed_after_review",
1794
- "added_after_review",
1795
- "cancellation_chosen",
1796
- "move_refused"
1797
- ];
1798
- const businessCancellationRefusalCodes = [
1799
- "review_changed",
1800
- "not_found",
1801
- "payment_in_progress",
1802
- "payment_check_unavailable",
1803
- "partial_payment_terms",
1804
- "settlement_not_allowed"
1805
- ];
1806
- const businessCancellationRefusalCopy = {
1807
- review_changed: "Bookings have changed since you reviewed this schedule. Review the changes again before saving.",
1808
- not_found: "One of these dates could not be found. Refresh the dates and review your changes again.",
1809
- payment_in_progress: "A payment is still being processed for one of these bookings. Wait for it to finish, then review the cancellation again.",
1810
- payment_check_unavailable: "We could not check a payment for one of these bookings. Review the cancellation again later, or contact us for help.",
1811
- partial_payment_terms: "One of these bookings shares a payment arrangement with another booking. Cancel the bookings together or contact us for help.",
1812
- settlement_not_allowed: "A refund choice can't be used any more: account credit may have been turned off, or how a booking was paid has changed. Review the cancellation again and choose again."
1813
- };
1814
-
1815
- //#endregion
1816
- //#region ../core/src/booking-instalments.ts
1817
- function isDepositBearingBookingInstalmentPlan(plan) {
1818
- switch (plan.kind) {
1819
- case "deposit_plus_one_remainder":
1820
- case "deposit_plus_scheduled_instalments": return true;
1821
- case "equal_scheduled_instalments": return false;
1822
- default: return assertNever$4(plan);
1823
- }
1824
- }
1825
- function getBookingInstalmentDepositRefundability(plan) {
1826
- return isDepositBearingBookingInstalmentPlan(plan) ? plan.depositRefundability : null;
1827
- }
1828
- function getBookingInstalmentProtectedDepositAmountCents(plan) {
1829
- return isDepositBearingBookingInstalmentPlan(plan) ? plan.depositAmountCents : null;
1830
- }
1831
- function clampConfiguredAmount(amountCents, totalAmountCents) {
1832
- return Math.max(0, Math.min(amountCents, totalAmountCents));
1833
- }
1834
- function splitAmountWithRemainderInFirst(totalAmountCents, partCount) {
1835
- if (partCount <= 0) {
1836
- return [];
1837
- }
1838
- const baseAmountCents = Math.floor(totalAmountCents / partCount);
1839
- const remainderCents = totalAmountCents - baseAmountCents * partCount;
1840
- return Array.from({ length: partCount }, (_, index) => index === 0 ? baseAmountCents + remainderCents : baseAmountCents);
1841
- }
1842
- function addIntervalPreservingMonthAnchor(isoString, intervalCount, intervalUnit) {
1843
- const date = new Date(isoString);
1844
- if (!Number.isFinite(date.getTime())) {
1845
- return isoString;
1846
- }
1847
- switch (intervalUnit) {
1848
- case "day":
1849
- date.setUTCDate(date.getUTCDate() + intervalCount);
1850
- return date.toISOString();
1851
- case "week":
1852
- date.setUTCDate(date.getUTCDate() + intervalCount * 7);
1853
- return date.toISOString();
1854
- case "month": return addMonthsPreservingAnchorDay(date, intervalCount).toISOString();
1855
- default: return assertNever$4(intervalUnit);
1856
- }
1857
- }
1858
- function getBookingInstalmentPlanIntervalCount(plan) {
1859
- switch (plan.kind) {
1860
- case "deposit_plus_one_remainder": return plan.remainderDueCount;
1861
- case "deposit_plus_scheduled_instalments":
1862
- case "equal_scheduled_instalments": return plan.intervalCount;
1863
- default: return assertNever$4(plan);
1864
- }
1865
- }
1866
- function omitZeroAmountFutureRows(rows) {
1867
- if (rows.length <= 1) {
1868
- return rows;
1869
- }
1870
- const firstRow = rows[0];
1871
- if (firstRow === undefined) {
1872
- return [];
1873
- }
1874
- const futureRows = rows.slice(1);
1875
- return [firstRow, ...futureRows.filter((row) => row.amountCents > 0)];
1876
- }
1877
- function formatOrderInstalmentStatusLabel(input) {
1878
- switch (input.status) {
1879
- case "pending_initial_payment": return input.phaseKind === "initial" ? "Due today" : "Scheduled";
1880
- case "scheduled": return "Scheduled";
1881
- case "paid": return input.phaseKind === "initial" ? "Paid today" : "Paid";
1882
- case "failed": return "Payment failed";
1883
- case "waived": return "Waived";
1884
- case "cancelled": return "Cancelled";
1885
- case "cancelled_as_paid_early": return "Paid early";
1886
- case "refunded": return "Refunded";
1887
- default: return assertNever$4(input.status);
1888
- }
1889
- }
1890
- const NEXT_DUE_STATUSES = new Set(["scheduled", "failed"]);
1891
- function buildOrderInstalmentSummary(input) {
1892
- const nextDue = input.instalments.find((instalment) => NEXT_DUE_STATUSES.has(instalment.status)) ?? null;
1893
- return {
1894
- status: input.paymentPlan.status,
1895
- remainingBalanceCents: input.paymentPlan.remainingBalanceCents,
1896
- nextDueAt: nextDue?.dueAt ?? null,
1897
- nextDueAmountCents: nextDue?.amountCents ?? null,
1898
- rows: [...input.instalments]
1899
- };
1900
- }
1901
- function addMonthsPreservingAnchorDay(date, intervalCount) {
1902
- const anchorDay = date.getUTCDate();
1903
- const nextMonth = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + intervalCount, 1, date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds()));
1904
- const lastDayOfTargetMonth = new Date(Date.UTC(nextMonth.getUTCFullYear(), nextMonth.getUTCMonth() + 1, 0)).getUTCDate();
1905
- nextMonth.setUTCDate(Math.min(anchorDay, lastDayOfTargetMonth));
1906
- return nextMonth;
1907
- }
1908
- function assertNever$4(value) {
1909
- throw new Error(`Unexpected value: ${String(value)}`);
1910
- }
1911
-
1912
- //#endregion
1913
- //#region ../core/src/booking-instalment-deposit.ts
1914
- /**
1915
- * A plan that starts with a deposit takes it by card when the customer books
1916
- * and saves the card for the later payments, so the deposit must be at least
1917
- * the card minimum for the site's currency. Plans without a deposit step
1918
- * (equal instalments) charge their first instalment instead and are not
1919
- * checked here.
1920
- */
1921
- function checkInstalmentPlanDeposit(plan, minimumCents) {
1922
- if (!isDepositBearingBookingInstalmentPlan(plan)) return ok(undefined);
1923
- return plan.depositAmountCents >= minimumCents ? ok(undefined) : err({
1924
- kind: "instalment_deposit_below_minimum",
1925
- minimumCents,
1926
- option: "instalment_plan"
1927
- });
1928
- }
1929
- /** The deposit check for whichever instalment option a set of payment options offers. */
1930
- function checkPaymentOptionsInstalmentDeposit(allowedOptions, minimumCents) {
1931
- const failure = allowedOptions.map((option) => option.kind === "instalment_plan" ? checkInstalmentPlanDeposit(option.plan, minimumCents) : option.kind === "flexible_balance" && option.config.upfrontAmountCents < minimumCents ? err({
1932
- kind: "instalment_deposit_below_minimum",
1933
- minimumCents,
1934
- option: "flexible_balance"
1935
- }) : ok(undefined)).find((checked) => !checked.ok);
1936
- return failure ?? ok(undefined);
1937
- }
1938
- /** The one message for a deposit below the minimum, shown in the editor and returned by the server. */
1939
- function describeInstalmentDepositBelowMinimum(failure, currency) {
1940
- const minimum = formatCurrencyAmount(failure.minimumCents, currency);
1941
- switch (failure.option) {
1942
- case "instalment_plan": return `Enter a deposit of at least ${minimum}. We take it when the customer books and save their card for the later payments.`;
1943
- case "flexible_balance": return `The deposit needs to be at least ${minimum}.`;
1944
- }
1945
- }
1946
-
1947
- //#endregion
1948
- //#region ../core/src/booking-live-payment-terms.ts
1949
- /**
1950
- * Stored instalment-provider outcomes used by schedule coordination.
1951
- * Order money admissions and flexible-balance liveness come from the position.
1952
- * The table is total over the plan status union.
1953
- */
1954
- const LIVE_PLAN_STATUSES = {
1955
- pending_initial_payment: true,
1956
- active: true,
1957
- payment_failed: true,
1958
- reconciliation_required: true,
1959
- completed: false,
1960
- cancelled: false,
1961
- cancelled_as_paid_early: false,
1962
- refunded: false
1963
- };
1964
- function isLiveOrderInstalmentPlanStatus(status) {
1965
- return LIVE_PLAN_STATUSES[status];
1966
- }
1967
- /** The live plan statuses as a list, for queries that select plans to collect. */
1968
- const LIVE_ORDER_INSTALMENT_PLAN_STATUSES = Object.keys(LIVE_PLAN_STATUSES).filter(isLiveOrderInstalmentPlanStatus);
1969
- /** Shared reason for closing either form of booking payment terms. */
1970
- const PAYMENT_TERMS_CLOSURE_REASONS = ["cancelled", "refunded"];
1971
-
1972
- //#endregion
1973
- //#region ../core/src/booking-payment-options.ts
1974
- /**
1975
- * One way a customer may pay for a booking. This is the single definition of
1976
- * the option type; `booking-payment-schemas.typetest.ts` keeps it equal to the
1977
- * schema's output in both directions.
1978
- */
1979
- /** When a course's instalments must all be paid by: before its first or its last live session. */
1980
- const BOOKING_COURSE_INSTALMENT_DEADLINES = ["first_session", "last_session"];
1981
- /** Automatic instalments and a flexible balance cannot share one booking offer. */
1982
- function validateBookingPaymentOptionKinds(kinds) {
1983
- if (kinds.length === 0) return err("no_options");
1984
- const uniqueKinds = new Set(kinds);
1985
- if (uniqueKinds.size !== kinds.length) return err("duplicate_kind");
1986
- if (uniqueKinds.has("instalment_plan") && uniqueKinds.has("flexible_balance")) {
1987
- return err("incompatible_collection_options");
1988
- }
1989
- return ok(undefined);
1990
- }
1991
-
1992
- //#endregion
1993
- //#region ../core/src/booking-date-time/instant.ts
1994
- function parseUtcIsoDateTimeString(value) {
1995
- const normalized = value.trim();
1996
- const hasUtcSuffix = normalized.endsWith("Z");
1997
- const hasExplicitOffset = /[+-]\d{2}:\d{2}$/u.test(normalized);
1998
- if (!hasUtcSuffix && !hasExplicitOffset) {
1999
- return err("missing-timezone-offset");
2000
- }
2001
- const date = new Date(normalized);
2002
- if (Number.isNaN(date.getTime())) {
2003
- return err("invalid-date-time");
2004
- }
2005
- return ok(date.toISOString());
2006
- }
2007
- function toUtcIsoDateTimeString(value) {
2008
- const parsed = parseUtcIsoDateTimeString(value);
2009
- if (!parsed.ok) {
2010
- const message = parsed.error === "missing-timezone-offset" ? `Expected an offset-aware ISO datetime, received "${value}"` : `Expected a valid ISO datetime, received "${value}"`;
2011
- throw new Error(message);
2012
- }
2013
- return parsed.value;
2014
- }
2015
-
2016
- //#endregion
2017
- //#region ../core/src/date-time-formatter.ts
2018
- /** Shared Intl engine, internal to core's date presentation owners. */
2019
- const FORMATTER_CACHE_LIMIT$1 = 100;
2020
- const dateTimeFormatterCache = new Map();
2021
- /** Intl's boolean clock option can select h11/h24 on other ICU builds. */
2022
- function resolveClockCycle(format) {
2023
- const { hour12, ...explicitFormat } = format;
2024
- return hour12 === undefined ? explicitFormat : {
2025
- ...explicitFormat,
2026
- hourCycle: hour12 ? "h12" : "h23"
2027
- };
2028
- }
2029
- function getDateTimeFormatter(locale, timeZone, format) {
2030
- const explicitFormat = resolveClockCycle(format);
2031
- const formatKey = JSON.stringify(Object.entries(explicitFormat).sort(([left], [right]) => left.localeCompare(right)));
2032
- const key = `${locale}\u0000${timeZone}\u0000${formatKey}`;
2033
- const cached = dateTimeFormatterCache.get(key);
2034
- if (cached !== undefined) {
2035
- return cached;
2036
- }
2037
- if (typeof locale !== "string" || Intl.DateTimeFormat.supportedLocalesOf([locale]).length === 0) {
2038
- throw new RangeError("An explicit supported locale is required");
2039
- }
2040
- if (typeof timeZone !== "string" || timeZone.length === 0) {
2041
- throw new RangeError("An explicit time zone is required");
2042
- }
2043
- const formatter = new Intl.DateTimeFormat(locale, {
2044
- ...explicitFormat,
2045
- timeZone
2046
- });
2047
- if (dateTimeFormatterCache.size >= FORMATTER_CACHE_LIMIT$1) {
2048
- dateTimeFormatterCache.clear();
2049
- }
2050
- dateTimeFormatterCache.set(key, formatter);
2051
- return formatter;
2052
- }
2053
- function formatIntlRange(formatter, start, end) {
2054
- const nativeFormatRange = Reflect.get(formatter, "formatRange");
2055
- if (typeof nativeFormatRange !== "function") throw new Error("Intl.DateTimeFormat.formatRange is required");
2056
- const output = Reflect.apply(nativeFormatRange, formatter, [start, end]);
2057
- if (typeof output !== "string") throw new Error("Intl.DateTimeFormat.formatRange returned a non-string value");
2058
- return output;
2059
- }
2060
-
2061
- //#endregion
2062
- //#region ../core/src/booking-date-time/parts.ts
2063
- function formatToPartsLookup(date, locale, timeZone, format) {
2064
- return new Map(getDateTimeFormatter(locale, timeZone, format).formatToParts(date).map((part) => [part.type, part.value]));
2065
- }
2066
-
2067
- //#endregion
2068
- //#region ../core/src/booking-time-zone.ts
2069
- const TIME_ZONE_VALIDITY_CACHE_LIMIT = 100;
2070
- const timeZoneValidityCache = new Map();
2071
- const NUMERIC_OFFSET_TIME_ZONE_PATTERN = /^(?:[+-]\d{2}(?::?\d{2})?|(?:UTC|GMT)[+-]\d{1,2}(?::?\d{2})?)$/iu;
2072
- function isValidBookingTimeZone(timeZone) {
2073
- const normalized = timeZone.trim();
2074
- if (NUMERIC_OFFSET_TIME_ZONE_PATTERN.test(normalized)) return false;
2075
- const cached = timeZoneValidityCache.get(normalized);
2076
- if (cached !== undefined) return cached;
2077
- let isValid;
2078
- try {
2079
- new Intl.DateTimeFormat("en-US", { timeZone: normalized }).format(new Date());
2080
- isValid = true;
2081
- } catch {
2082
- isValid = false;
2083
- }
2084
- if (timeZoneValidityCache.size >= TIME_ZONE_VALIDITY_CACHE_LIMIT) {
2085
- timeZoneValidityCache.clear();
2086
- }
2087
- timeZoneValidityCache.set(normalized, isValid);
2088
- return isValid;
2089
- }
2090
- function parseBookingTimeZone(timeZone) {
2091
- if (typeof timeZone !== "string") return err("invalid-time-zone");
2092
- const normalized = timeZone.trim();
2093
- if (normalized.length === 0 || NUMERIC_OFFSET_TIME_ZONE_PATTERN.test(normalized) || !isValidBookingTimeZone(normalized)) {
2094
- return err("invalid-time-zone");
2095
- }
2096
- return ok(normalized);
2097
- }
2098
-
2099
- //#endregion
2100
- //#region ../core/src/booking-date-time/time-zone.ts
2101
- const FALLBACK_TIMEZONE = "UTC";
2102
- function getSafeTimeZone(timeZone) {
2103
- const normalized = typeof timeZone === "string" ? timeZone.trim() : "";
2104
- return normalized.length > 0 && isValidBookingTimeZone(normalized) ? normalized : FALLBACK_TIMEZONE;
2105
- }
2106
- function toBookingTimeZone(timeZone) {
2107
- return getSafeTimeZone(timeZone);
2108
- }
2109
- const DEFAULT_BOOKING_TIME_ZONE = FALLBACK_TIMEZONE;
2110
- function resolveBookingTimezone(venueTimezone, siteDefaultTimezone) {
2111
- return venueTimezone ?? siteDefaultTimezone;
2112
- }
2113
- function resolveBookingTimeZoneId(...candidates) {
2114
- const normalized = candidates.map((candidate$1) => typeof candidate$1 === "string" ? candidate$1.trim() : "");
2115
- return normalized.find((candidate$1) => candidate$1.length > 0 && isValidBookingTimeZone(candidate$1)) ?? FALLBACK_TIMEZONE;
2116
- }
2117
- /** Canonical business-zone admission, shared by server and public wire boundaries. */
2118
- const DEFAULT_BOOKING_BUSINESS_TIME_ZONE = "Europe/London";
2119
- /** Stored site zones must be valid; a broken read must not silently choose another zone. */
2120
- function requireBookingTimeZone(value) {
2121
- const parsed = parseBookingTimeZone(value);
2122
- if (!parsed.ok) throw new Error("Expected a valid canonical site time zone");
2123
- return parsed.value;
2124
- }
2125
- /** Effect boundary for browser-authored local inputs; formats no displayed date. */
2126
- function getRuntimeBookingTimeZone() {
2127
- return resolveBookingTimeZoneId(new Intl.DateTimeFormat("en-GB").resolvedOptions().timeZone);
2128
- }
2129
- function resolveBookingBusinessTimeZone(value) {
2130
- return resolveBookingTimeZoneId(value, DEFAULT_BOOKING_BUSINESS_TIME_ZONE);
2131
- }
2132
-
2133
- //#endregion
2134
- //#region ../core/src/booking-date-time/local.ts
2135
- const LOCAL_DATE_PATTERN = /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/u;
2136
- function getZonedDateTimeParts(date, timeZone) {
2137
- const parts = formatToPartsLookup(date, "en-GB", timeZone, {
2138
- year: "numeric",
2139
- month: "2-digit",
2140
- day: "2-digit",
2141
- hour: "2-digit",
2142
- minute: "2-digit",
2143
- second: "2-digit",
2144
- hourCycle: "h23"
2145
- });
2146
- const read = (type) => Number(parts.get(type) ?? "");
2147
- return {
2148
- year: read("year"),
2149
- month: read("month"),
2150
- day: read("day"),
2151
- hour: read("hour"),
2152
- minute: read("minute"),
2153
- second: read("second")
2154
- };
2155
- }
2156
- function formatDateKey(date) {
2157
- const year = String(date.year).padStart(4, "0");
2158
- const month = String(date.month).padStart(2, "0");
2159
- const day = String(date.day).padStart(2, "0");
2160
- return `${year}-${month}-${day}`;
2161
- }
2162
- function getBookingLocalDateKey(input) {
2163
- return formatDateKey(getLocalScheduleDate(new Date(input.startsAt), input.timeZone));
2164
- }
2165
- function compareLocalScheduleDates(left, right) {
2166
- return Date.UTC(left.year, left.month - 1, left.day) - Date.UTC(right.year, right.month - 1, right.day);
2167
- }
2168
- function parseBookingLocalDate(value) {
2169
- const match = LOCAL_DATE_PATTERN.exec(value.trim());
2170
- if (match === null || match.groups === undefined) {
2171
- throw new Error(`Invalid booking date format: "${value}" (expected YYYY-MM-DD)`);
2172
- }
2173
- const year = Number(match.groups.year);
2174
- const month = Number(match.groups.month);
2175
- const day = Number(match.groups.day);
2176
- const candidate$1 = new Date(Date.UTC(year, month - 1, day, 12, 0, 0));
2177
- if (Number.isNaN(candidate$1.getTime()) || candidate$1.getUTCFullYear() !== year || candidate$1.getUTCMonth() + 1 !== month || candidate$1.getUTCDate() !== day) {
2178
- throw new Error(`Invalid booking date format: "${value}" (expected YYYY-MM-DD)`);
2179
- }
2180
- return {
2181
- year,
2182
- month,
2183
- day
2184
- };
2185
- }
2186
- /** Canonical schedule text at command and SDK boundaries: HH:MM or HH:MM:SS. */
2187
- const localScheduleTimePattern = /^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/u;
2188
- function parseLocalScheduleTime(value) {
2189
- const match = /^(?<hour>[01]?\d|2[0-3]):(?<minute>[0-5]\d)(?::(?<second>[0-5]\d))?$/u.exec(value.trim());
2190
- if (match === null || match.groups === undefined) {
2191
- throw new Error(`Invalid start time format: "${value}" (expected HH:MM or HH:MM:SS)`);
2192
- }
2193
- const hour = Number(match.groups.hour);
2194
- const minute = Number(match.groups.minute);
2195
- const second = Number(match.groups.second ?? "0");
2196
- return {
2197
- hour,
2198
- minute,
2199
- second
1867
+ hour,
1868
+ minute,
1869
+ second
2200
1870
  };
2201
1871
  }
2202
1872
  function getLocalScheduleDate(date, timeZone) {
@@ -2282,80 +1952,20 @@ function zonedDateTimeLocalToUtcIso(localValue, timeZone) {
2282
1952
  return null;
2283
1953
  }
2284
1954
  }
2285
- /** A date is valid through its whole local day; storage ends at the next midnight. */
2286
- function localDateToExclusiveDeadlineIso(value, timeZone) {
2287
- return localScheduleDateTimeToUtcDate(addLocalScheduleDays(parseBookingLocalDate(value), 1), {
2288
- hour: 0,
2289
- minute: 0,
2290
- second: 0
2291
- }, timeZone).toISOString();
2292
- }
2293
- /** Subtract before projecting into the zone, just as an exclusive deadline is displayed. */
2294
- function exclusiveDeadlineToLocalDateInput(iso, timeZone) {
2295
- if (iso === null || iso === "") return "";
2296
- const instant = Date.parse(iso);
2297
- if (Number.isNaN(instant)) return "";
2298
- return formatLocalScheduleDate(getLocalScheduleDate(new Date(instant - 1), timeZone));
2299
- }
2300
-
2301
- //#endregion
2302
- //#region ../core/src/booking-date-time/window.ts
2303
- const START_OF_DAY = {
2304
- hour: 0,
2305
- minute: 0,
2306
- second: 0
2307
- };
2308
- function parseWindowDate(value, field) {
2309
- try {
2310
- return {
2311
- ok: true,
2312
- value: parseBookingLocalDate(value)
2313
- };
2314
- } catch {
2315
- return {
2316
- ok: false,
2317
- field,
2318
- reason: "invalid_date_format",
2319
- value
2320
- };
2321
- }
2322
- }
2323
- function parseBookingUtcDateWindow(input) {
2324
- const timeZone = resolveBookingTimeZoneId(input.timeZone);
2325
- const start = parseWindowDate(input.startDate, "startDate");
2326
- if (!start.ok) return start;
2327
- const end = parseWindowDate(input.endDate, "endDate");
2328
- if (!end.ok) return end;
2329
- const startLocalDate = start.value;
2330
- const endLocalDate = end.value;
2331
- if (compareLocalScheduleDates(startLocalDate, endLocalDate) > 0) {
2332
- return {
2333
- ok: false,
2334
- field: "endDate",
2335
- reason: "invalid_date_range",
2336
- value: input.endDate
2337
- };
2338
- }
2339
- return {
2340
- ok: true,
2341
- value: {
2342
- timeZone,
2343
- startLocalDate,
2344
- endLocalDate,
2345
- startAt: localScheduleDateTimeToUtcDate(startLocalDate, START_OF_DAY, timeZone),
2346
- endExclusive: localScheduleDateTimeToUtcDate(addLocalScheduleDays(endLocalDate, 1), START_OF_DAY, timeZone)
2347
- }
2348
- };
2349
- }
2350
- function buildBookingUtcDateWindow(input) {
2351
- const result = parseBookingUtcDateWindow(input);
2352
- if (result.ok) {
2353
- return result.value;
2354
- }
2355
- if (result.reason === "invalid_date_range") {
2356
- throw new Error(`Invalid booking date range: startDate "${input.startDate}" must be on or before endDate "${input.endDate}"`);
2357
- }
2358
- throw new Error(`Invalid booking date format: "${result.value}" (expected YYYY-MM-DD)`);
1955
+ /** A date is valid through its whole local day; storage ends at the next midnight. */
1956
+ function localDateToExclusiveDeadlineIso(value, timeZone) {
1957
+ return localScheduleDateTimeToUtcDate(addLocalScheduleDays(parseBookingLocalDate(value), 1), {
1958
+ hour: 0,
1959
+ minute: 0,
1960
+ second: 0
1961
+ }, timeZone).toISOString();
1962
+ }
1963
+ /** Subtract before projecting into the zone, just as an exclusive deadline is displayed. */
1964
+ function exclusiveDeadlineToLocalDateInput(iso, timeZone) {
1965
+ if (iso === null || iso === "") return "";
1966
+ const instant = Date.parse(iso);
1967
+ if (Number.isNaN(instant)) return "";
1968
+ return formatLocalScheduleDate(getLocalScheduleDate(new Date(instant - 1), timeZone));
2359
1969
  }
2360
1970
 
2361
1971
  //#endregion
@@ -2691,208 +2301,681 @@ function presentDate(value, context, profile) {
2691
2301
  const normalized = normalizeDisplay(output);
2692
2302
  return profile.dateFormat.weekday && new Intl.Locale(context.locale).language === "en" ? normalized.replace(/^([^,]+), /u, "$1 ") : normalized;
2693
2303
  }
2694
- function presentDateRange(start, end, context, profile) {
2695
- if (dateCarrier(end).getTime() < dateCarrier(start).getTime()) throw new RangeError("Date range end must be on or after its start");
2696
- if (profile.kind === "display" && compareLocalScheduleDates(projectDate(start, context), projectDate(end, context)) === 0) {
2697
- return presentDate(start, context, profile);
2698
- }
2699
- const output = formatIntlRange(getDateTimeFormatter(context.locale, start.kind === "civil" ? "UTC" : context.timeZone, profile.dateFormat), dateCarrier(start), dateCarrier(end));
2700
- if (profile.kind === "sdk") return output;
2701
- const startDate = projectDate(start, context);
2702
- const endDate = projectDate(end, context);
2703
- const separator = startDate.month === endDate.month && startDate.year === endDate.year ? "–" : " – ";
2704
- return normalizeDisplay(output).replace(/\s*–\s*/gu, separator);
2304
+ function presentDateRange(start, end, context, profile) {
2305
+ if (dateCarrier(end).getTime() < dateCarrier(start).getTime()) throw new RangeError("Date range end must be on or after its start");
2306
+ if (profile.kind === "display" && compareLocalScheduleDates(projectDate(start, context), projectDate(end, context)) === 0) {
2307
+ return presentDate(start, context, profile);
2308
+ }
2309
+ const output = formatIntlRange(getDateTimeFormatter(context.locale, start.kind === "civil" ? "UTC" : context.timeZone, profile.dateFormat), dateCarrier(start), dateCarrier(end));
2310
+ if (profile.kind === "sdk") return output;
2311
+ const startDate = projectDate(start, context);
2312
+ const endDate = projectDate(end, context);
2313
+ const separator = startDate.month === endDate.month && startDate.year === endDate.year ? "–" : " – ";
2314
+ return normalizeDisplay(output).replace(/\s*–\s*/gu, separator);
2315
+ }
2316
+ function presentTime(value, context, profile) {
2317
+ const clock = presentClock(value, context, profile.clock);
2318
+ return profile.zone === "always" ? `${clock} ${zoneLabel(value, context)}` : clock;
2319
+ }
2320
+ function presentDateTime(value, context, profile) {
2321
+ if (profile.clock.kind === "intl") {
2322
+ return getDateTimeFormatter(context.locale, context.timeZone, combinedFormat(profile.dateFormat, profile.clock)).format(new Date(value));
2323
+ }
2324
+ return `${presentDate({
2325
+ kind: "instant",
2326
+ value
2327
+ }, context, profile)}, ${presentTime(value, context, profile)}`;
2328
+ }
2329
+ function presentTimeRange(span, context, profile) {
2330
+ assertOrdered(span.start, span.end);
2331
+ if (profile.clock.kind === "intl") return presentNativeRange(span, context, profile.clock.format);
2332
+ const startClock = presentClock(span.start, context, profile.clock);
2333
+ const endClock = presentClock(span.end, context, profile.clock);
2334
+ const equal = profile.kind === "sdk" ? startClock === endClock : span.start === span.end;
2335
+ const clocks = equal ? startClock : `${startClock}–${endClock}`;
2336
+ const labels = decideRangeLabels(span, context, profile);
2337
+ switch (labels.kind) {
2338
+ case "omit": return clocks;
2339
+ case "shared": return `${clocks} ${labels.label}`;
2340
+ case "endpoints": return `${startClock} ${labels.start} – ${endClock} ${labels.end}`;
2341
+ }
2342
+ }
2343
+ function presentDateTimeRange(span, context, profile) {
2344
+ assertOrdered(span.start, span.end);
2345
+ if (profile.clock.kind === "intl") return presentNativeRange(span, context, combinedFormat(profile.dateFormat, profile.clock));
2346
+ const startDate = getLocalScheduleDate(new Date(span.start), context.timeZone);
2347
+ const endDate = getLocalScheduleDate(new Date(span.end), context.timeZone);
2348
+ if (compareLocalScheduleDates(startDate, endDate) === 0) {
2349
+ return `${presentDate({
2350
+ kind: "instant",
2351
+ value: span.start
2352
+ }, context, profile)}, ${presentTimeRange(span, context, profile)}`;
2353
+ }
2354
+ const labels = decideRangeLabels(span, context, profile);
2355
+ const startProfile = profile.kind === "display" && startDate.year === endDate.year ? {
2356
+ ...profile,
2357
+ dateFormat: {
2358
+ ...profile.dateFormat,
2359
+ year: undefined
2360
+ }
2361
+ } : profile;
2362
+ const start = presentRangeEndpoint(span.start, context, startProfile, labels.kind === "endpoints" ? labels.start : undefined);
2363
+ const end = presentRangeEndpoint(span.end, context, profile, labels.kind === "endpoints" ? labels.end : undefined);
2364
+ const separator = profile.kind === "sdk" ? "–" : " – ";
2365
+ return profile.kind === "sdk" && start === end ? start : `${start}${separator}${end}`;
2366
+ }
2367
+ /** Offset changes override ordinary venue omission for the approved display profile. */
2368
+ function decideRangeLabels(span, context, profile) {
2369
+ if (profile.kind === "sdk") return { kind: "omit" };
2370
+ const offsetsDiffer = offsetToken(span.start, context) !== offsetToken(span.end, context);
2371
+ if (!offsetsDiffer && profile.zone === "omit") return { kind: "omit" };
2372
+ const start = zoneLabel(span.start, context);
2373
+ const end = zoneLabel(span.end, context);
2374
+ return offsetsDiffer || start !== end ? {
2375
+ kind: "endpoints",
2376
+ start,
2377
+ end
2378
+ } : {
2379
+ kind: "shared",
2380
+ label: start
2381
+ };
2382
+ }
2383
+ function presentRangeEndpoint(value, context, profile, label$1) {
2384
+ const date = presentDate({
2385
+ kind: "instant",
2386
+ value
2387
+ }, context, profile);
2388
+ const time = label$1 === undefined ? presentTime(value, context, profile) : `${presentClock(value, context, profile.clock)} ${label$1}`;
2389
+ return `${date}, ${time}`;
2390
+ }
2391
+ function presentNativeRange(span, context, format) {
2392
+ return formatIntlRange(getDateTimeFormatter(context.locale, context.timeZone, format), new Date(span.start), new Date(span.end));
2393
+ }
2394
+ function combinedFormat(date, clock) {
2395
+ return {
2396
+ ...date,
2397
+ ...clock.format
2398
+ };
2399
+ }
2400
+ function displayProfile(options, zone, seconds) {
2401
+ return {
2402
+ kind: "display",
2403
+ dateFormat: dateFormat(options),
2404
+ clock: {
2405
+ kind: "compact",
2406
+ localeSource: "product",
2407
+ seconds
2408
+ },
2409
+ zone
2410
+ };
2411
+ }
2412
+ function dateCarrier(value) {
2413
+ return value.kind === "civil" ? civilCarrier(value.value) : new Date(value.value);
2414
+ }
2415
+ function presentClock(value, context, clock) {
2416
+ return clock.kind === "compact" ? formatBookingCompactEnglishTime({
2417
+ startsAt: value,
2418
+ timeZone: context.timeZone,
2419
+ locale: clock.localeSource === "product" ? "en-GB" : context.locale
2420
+ }, { seconds: clock.seconds }) : getDateTimeFormatter(context.locale, context.timeZone, clock.format).format(new Date(value));
2421
+ }
2422
+ function offsetToken(value, context) {
2423
+ return getDateTimeFormatter("en-GB", context.timeZone, { timeZoneName: "longOffset" }).formatToParts(new Date(value)).find((part) => part.type === "timeZoneName")?.value ?? "";
2424
+ }
2425
+ function formatTimeAgo(value, now, context) {
2426
+ return formatRelative(value, now, context, "past");
2427
+ }
2428
+ function formatTimeUntil(value, now, context) {
2429
+ return formatRelative(value, now, context, "future");
2430
+ }
2431
+ const DATE_STYLE_PARTS = {
2432
+ numeric: {
2433
+ day: "2-digit",
2434
+ month: "2-digit"
2435
+ },
2436
+ short: {
2437
+ day: "numeric",
2438
+ month: "short"
2439
+ },
2440
+ long: {
2441
+ day: "numeric",
2442
+ month: "long"
2443
+ },
2444
+ omit: {
2445
+ day: undefined,
2446
+ month: undefined
2447
+ }
2448
+ };
2449
+ function dateFormat(options) {
2450
+ return {
2451
+ ...DATE_STYLE_PARTS[options.date ?? "long"],
2452
+ ...options.day ? { day: options.day === "omit" ? undefined : options.day } : {},
2453
+ ...options.month === "omit" ? { month: undefined } : {},
2454
+ ...options.year === "omit" ? {} : { year: "numeric" },
2455
+ ...options.weekday ? { weekday: options.weekday } : {}
2456
+ };
2457
+ }
2458
+ function civilCarrier(value) {
2459
+ return new Date(Date.UTC(value.year, value.month - 1, value.day, 12));
2460
+ }
2461
+ function projectDate(value, context) {
2462
+ return value.kind === "civil" ? value.value : getLocalScheduleDate(new Date(value.value), context.timeZone);
2463
+ }
2464
+ function normalizeDisplay(value) {
2465
+ return value.replace(/[\u00a0\u202f]/gu, " ");
2466
+ }
2467
+ function zoneToken(value, context, locale) {
2468
+ return getDateTimeFormatter(locale, context.timeZone, { timeZoneName: "short" }).formatToParts(new Date(value)).find((part) => part.type === "timeZoneName")?.value ?? "";
2469
+ }
2470
+ function zoneLabel(value, context) {
2471
+ const tokens = [zoneToken(value, context, "en-GB"), zoneToken(value, context, "en-US")];
2472
+ const abbreviation = tokens.find((token) => /^[A-Z]{2,6}$/u.test(token));
2473
+ return abbreviation ?? formatTimeZoneCityLabel(context.timeZone);
2474
+ }
2475
+ function assertOrdered(start, end) {
2476
+ if (new Date(end).getTime() < new Date(start).getTime()) {
2477
+ throw new RangeError("Date/time range end must be on or after its start");
2478
+ }
2479
+ }
2480
+ function calendarDayDifference(value, now, context) {
2481
+ return compareLocalScheduleDates(getLocalScheduleDate(new Date(value), context.timeZone), getLocalScheduleDate(new Date(now), context.timeZone)) / 864e5;
2482
+ }
2483
+ function formatRelative(value, now, context, direction) {
2484
+ const seconds = (new Date(value).getTime() - new Date(now).getTime()) / 1e3;
2485
+ const magnitude = Math.abs(seconds);
2486
+ if (direction === "past" && seconds > 0 && seconds <= 120) return relativeNearNow(context.locale, "past");
2487
+ if (magnitude < 60) return relativeNearNow(context.locale, direction);
2488
+ const days = calendarDayDifference(value, now, context);
2489
+ if (Math.abs(days) > 7) return formatDate({
2490
+ kind: "instant",
2491
+ value
2492
+ }, context, { date: "short" });
2493
+ const formatter = new Intl.RelativeTimeFormat(context.locale, { numeric: "auto" });
2494
+ if (days !== 0) return formatter.format(days, "day");
2495
+ const unit = magnitude < 3600 ? "minute" : "hour";
2496
+ const signedCount = Math.sign(seconds) * Math.floor(magnitude / (unit === "minute" ? 60 : 3600));
2497
+ return formatter.format(signedCount, unit);
2498
+ }
2499
+ function relativeNearNow(locale, direction) {
2500
+ if (new Intl.Locale(locale).language === "en") return direction === "past" ? "just now" : "in a moment";
2501
+ return new Intl.RelativeTimeFormat(locale, { numeric: "auto" }).format(0, "second");
2502
+ }
2503
+ /** Same city vocabulary as clock-label fallback, for explanatory timezone copy. */
2504
+ function formatTimeZoneCityLabel(timeZone) {
2505
+ return timeZone.startsWith("Etc/") ? "local time" : `${timeZone.split("/").slice(-1)[0]?.replace(/_/gu, " ") ?? timeZone} time`;
2506
+ }
2507
+
2508
+ //#endregion
2509
+ //#region ../core/src/event-booking-cut-off.ts
2510
+ /**
2511
+ * How long before an event starts online bookings stop.
2512
+ *
2513
+ * This file is the one owner of the arithmetic. The SQL admission gates apply
2514
+ * the same sum in `public.event_booking_closes_at_v1`, so the page and the gate
2515
+ * agree on the same instant: whole hours counted back from the start, never
2516
+ * calendar hours, so a clock change can't move it.
2517
+ */
2518
+ /** The largest cut-off anyone can choose: 30 days. The database enforces it too. */
2519
+ const MAX_BOOKING_CUT_OFF_HOURS = 720;
2520
+ /** Zero is "when it starts": today's behaviour, and what a site that never chose gets. */
2521
+ const BOOKING_CUT_OFF_AT_START = 0;
2522
+ /**
2523
+ * What a form holds while "A different number of hours" has nothing usable in it.
2524
+ * The form's number stays the only value there is, and this one is out of range
2525
+ * on purpose: the save checks and the server's schemas all refuse it, so a blank
2526
+ * field can't quietly save as something else.
2527
+ */
2528
+ const BOOKING_CUT_OFF_HOURS_BLANK = -1;
2529
+ const BOOKING_CUT_OFF_HOURS_MESSAGE = `Enter a whole number of hours, from 1 to ${MAX_BOOKING_CUT_OFF_HOURS}.`;
2530
+ /** Whether a form's value can be saved. Null follows the site, zero is "when it starts". */
2531
+ function isValidBookingCutOffHours(hours) {
2532
+ return hours === null || Number.isInteger(hours) && hours >= BOOKING_CUT_OFF_AT_START && hours <= MAX_BOOKING_CUT_OFF_HOURS;
2533
+ }
2534
+ const MS_PER_HOUR = 36e5;
2535
+ const MS_PER_WEEK = 7 * 24 * MS_PER_HOUR;
2536
+ /** An event's own choice wins. Null on the event means it follows the site. */
2537
+ function resolveBookingCutOffHours(input) {
2538
+ return input.eventHours ?? input.siteHours;
2539
+ }
2540
+ const STARTS_BOOKING = { kind: "startsBooking" };
2541
+ /** The cut-off a request is admitted against. Carrying on a booking only has the start to beat. */
2542
+ function admissionCutOffHours(continuation, cutOffHours) {
2543
+ return continuation.kind === "continuesBooking" ? BOOKING_CUT_OFF_AT_START : cutOffHours;
2544
+ }
2545
+ /** The instant bookings stop for something starting at `startsAt`. */
2546
+ function bookingClosesAt(startsAt, cutOffHours) {
2547
+ return new Date(Date.parse(startsAt) - cutOffHours * MS_PER_HOUR).toISOString();
2548
+ }
2549
+ /** Closing is inclusive, matching the gate: at the exact instant it has closed. */
2550
+ function hasBookingClosed(closesAt, now) {
2551
+ return Date.parse(closesAt) <= now.getTime();
2552
+ }
2553
+ /**
2554
+ * What the public wire says: an instant only when it's earlier than the start.
2555
+ * Absent means "when it starts", so events with no cut-off read exactly as they
2556
+ * did before the field existed.
2557
+ */
2558
+ function publicBookingClosesAt(startsAt, cutOffHours) {
2559
+ return cutOffHours > 0 ? { bookingClosesAt: bookingClosesAt(startsAt, cutOffHours) } : {};
2560
+ }
2561
+ /** The whole hours between closing and the start, for "2 hours before the start". */
2562
+ function bookingCutOffHoursBetween(startsAt, closesAt) {
2563
+ return Math.round((Date.parse(startsAt) - Date.parse(closesAt)) / MS_PER_HOUR);
2564
+ }
2565
+ /**
2566
+ * When bookings closed, in the event's own time zone: "5pm" on the day it starts,
2567
+ * "7pm on Tuesday" earlier in the week, and with the date if it's further back
2568
+ * than that, when a weekday alone could mean the wrong one.
2569
+ */
2570
+ function formatBookingClosedTime(closesAt, startsAt, timeZone) {
2571
+ const time = formatSiteInstantTime(closesAt, timeZone);
2572
+ const dayOf = (iso) => formatSiteInstantDate(iso, timeZone);
2573
+ if (dayOf(closesAt) === dayOf(startsAt)) return time;
2574
+ const further = Date.parse(startsAt) - Date.parse(closesAt) >= MS_PER_WEEK;
2575
+ const day = formatSiteInstantDate(closesAt, timeZone, further ? {
2576
+ date: "long",
2577
+ weekday: "long",
2578
+ year: "omit"
2579
+ } : {
2580
+ date: "omit",
2581
+ weekday: "long",
2582
+ year: "omit"
2583
+ });
2584
+ return `${time} on ${day}`;
2585
+ }
2586
+ /** "1 hour" or "24 hours". */
2587
+ function formatBookingCutOffHours(hours) {
2588
+ return hours === 1 ? "1 hour" : `${hours} hours`;
2589
+ }
2590
+
2591
+ //#endregion
2592
+ //#region ../core/src/ticket-quantity.ts
2593
+ function toPositiveTicketQuantity(value) {
2594
+ if (!Number.isFinite(value) || !Number.isInteger(value) || value <= 0) {
2595
+ return err("invalid_quantity");
2596
+ }
2597
+ return ok(value);
2598
+ }
2599
+ /**
2600
+ * The places a booking holds: the sum of its ticket lines' quantities. The one
2601
+ * derivation for selections, persisted lines and a booking outcome's lines;
2602
+ * null when the total is not a positive whole number.
2603
+ */
2604
+ function deriveTotalTicketQuantity(lines) {
2605
+ const total = lines.reduce((sum, line$1) => sum + line$1.quantity, 0);
2606
+ const parsed = toPositiveTicketQuantity(total);
2607
+ return parsed.ok ? parsed.value : null;
2608
+ }
2609
+
2610
+ //#endregion
2611
+ //#region ../core/src/booking-flexible-balance.ts
2612
+ function clampFlexibleBalanceConfiguredAmount(amountCents, totalAmountCents) {
2613
+ return Math.max(0, Math.min(amountCents, totalAmountCents));
2614
+ }
2615
+ function resolveFlexibleBalanceInitialPaymentCents(input) {
2616
+ return clampFlexibleBalanceConfiguredAmount(input.config.upfrontAmountCents, input.totalAmountCents);
2705
2617
  }
2706
- function presentTime(value, context, profile) {
2707
- const clock = presentClock(value, context, profile.clock);
2708
- return profile.zone === "always" ? `${clock} ${zoneLabel(value, context)}` : clock;
2618
+ function calculateFlexibleBalanceRemainingBalanceCents(input) {
2619
+ return Math.max(0, input.totalAmountCents - input.paidAmountCents);
2709
2620
  }
2710
- function presentDateTime(value, context, profile) {
2711
- if (profile.clock.kind === "intl") {
2712
- return getDateTimeFormatter(context.locale, context.timeZone, combinedFormat(profile.dateFormat, profile.clock)).format(new Date(value));
2621
+ function resolveFlexibleBalanceDueAt(input) {
2622
+ switch (input.dueDateRule.kind) {
2623
+ case "relative_to_start_date": return subtractDaysFromIso(input.bookingStartAt, input.dueDateRule.daysBeforeStart);
2624
+ case "fixed_calendar_date": return input.dueDateRule.dueAt;
2625
+ default: return assertNever$5(input.dueDateRule);
2713
2626
  }
2714
- return `${presentDate({
2715
- kind: "instant",
2716
- value
2717
- }, context, profile)}, ${presentTime(value, context, profile)}`;
2718
2627
  }
2719
- function presentTimeRange(span, context, profile) {
2720
- assertOrdered(span.start, span.end);
2721
- if (profile.clock.kind === "intl") return presentNativeRange(span, context, profile.clock.format);
2722
- const startClock = presentClock(span.start, context, profile.clock);
2723
- const endClock = presentClock(span.end, context, profile.clock);
2724
- const equal = profile.kind === "sdk" ? startClock === endClock : span.start === span.end;
2725
- const clocks = equal ? startClock : `${startClock}–${endClock}`;
2726
- const labels = decideRangeLabels(span, context, profile);
2727
- switch (labels.kind) {
2728
- case "omit": return clocks;
2729
- case "shared": return `${clocks} ${labels.label}`;
2730
- case "endpoints": return `${startClock} ${labels.start} – ${endClock} ${labels.end}`;
2628
+ function calculateFlexibleBalanceMinimumPaymentCents(input) {
2629
+ if (input.remainingBalanceCents <= 0) {
2630
+ return 0;
2731
2631
  }
2632
+ const minimumPercentageBps = input.minimumPercentageBps ?? 1e3;
2633
+ const percentageFloor = Math.ceil(input.remainingBalanceCents * minimumPercentageBps / 1e4);
2634
+ return Math.min(input.remainingBalanceCents, Math.max(input.stripeMinimumChargeCents, percentageFloor));
2732
2635
  }
2733
- function presentDateTimeRange(span, context, profile) {
2734
- assertOrdered(span.start, span.end);
2735
- if (profile.clock.kind === "intl") return presentNativeRange(span, context, combinedFormat(profile.dateFormat, profile.clock));
2736
- const startDate = getLocalScheduleDate(new Date(span.start), context.timeZone);
2737
- const endDate = getLocalScheduleDate(new Date(span.end), context.timeZone);
2738
- if (compareLocalScheduleDates(startDate, endDate) === 0) {
2739
- return `${presentDate({
2740
- kind: "instant",
2741
- value: span.start
2742
- }, context, profile)}, ${presentTimeRange(span, context, profile)}`;
2743
- }
2744
- const labels = decideRangeLabels(span, context, profile);
2745
- const startProfile = profile.kind === "display" && startDate.year === endDate.year ? {
2746
- ...profile,
2747
- dateFormat: {
2748
- ...profile.dateFormat,
2749
- year: undefined
2750
- }
2751
- } : profile;
2752
- const start = presentRangeEndpoint(span.start, context, startProfile, labels.kind === "endpoints" ? labels.start : undefined);
2753
- const end = presentRangeEndpoint(span.end, context, profile, labels.kind === "endpoints" ? labels.end : undefined);
2754
- const separator = profile.kind === "sdk" ? "–" : " – ";
2755
- return profile.kind === "sdk" && start === end ? start : `${start}${separator}${end}`;
2636
+ function assertNever$5(value) {
2637
+ throw new Error(`Unexpected value: ${String(value)}`);
2756
2638
  }
2757
- /** Offset changes override ordinary venue omission for the approved display profile. */
2758
- function decideRangeLabels(span, context, profile) {
2759
- if (profile.kind === "sdk") return { kind: "omit" };
2760
- const offsetsDiffer = offsetToken(span.start, context) !== offsetToken(span.end, context);
2761
- if (!offsetsDiffer && profile.zone === "omit") return { kind: "omit" };
2762
- const start = zoneLabel(span.start, context);
2763
- const end = zoneLabel(span.end, context);
2764
- return offsetsDiffer || start !== end ? {
2765
- kind: "endpoints",
2766
- start,
2767
- end
2768
- } : {
2769
- kind: "shared",
2770
- label: start
2639
+
2640
+ //#endregion
2641
+ //#region ../core/src/booking-refunds.ts
2642
+ function normalizeBookingProtectedDepositPolicyState(value) {
2643
+ return value === "not_applicable" || value === "refundable" || value === "non_refundable" ? value : "not_applicable";
2644
+ }
2645
+ function shouldAllowProtectedDepositOverride(command) {
2646
+ return command.protectedDepositOverride === "allow_protected_deposit_override";
2647
+ }
2648
+ function createBookingRefundAmountRequest(amountCents) {
2649
+ return amountCents == null ? { kind: "full_remaining" } : {
2650
+ kind: "partial_amount",
2651
+ amountCents
2771
2652
  };
2772
2653
  }
2773
- function presentRangeEndpoint(value, context, profile, label$1) {
2774
- const date = presentDate({
2775
- kind: "instant",
2776
- value
2777
- }, context, profile);
2778
- const time = label$1 === undefined ? presentTime(value, context, profile) : `${presentClock(value, context, profile.clock)} ${label$1}`;
2779
- return `${date}, ${time}`;
2654
+ function createOriginalPaymentRefundCommand(options) {
2655
+ const protectedDepositOverride = options.protectedDepositOverride ?? "respect_policy";
2656
+ return options.kind === "refund_and_revoke" ? {
2657
+ kind: "refund_and_revoke",
2658
+ amount: { kind: "full_remaining" },
2659
+ requestedRefundMethod: "original_payment",
2660
+ protectedDepositOverride
2661
+ } : {
2662
+ kind: "refund_only",
2663
+ amount: options.amount ?? { kind: "full_remaining" },
2664
+ requestedRefundMethod: "original_payment",
2665
+ protectedDepositOverride
2666
+ };
2780
2667
  }
2781
- function presentNativeRange(span, context, format) {
2782
- return formatIntlRange(getDateTimeFormatter(context.locale, context.timeZone, format), new Date(span.start), new Date(span.end));
2668
+ /** Narrow an already typed run or schedule write response to its accepted receipt. */
2669
+ function isAcceptedEventScheduleUpdate(response) {
2670
+ return "kind" in response && response.kind === "accepted_unavailable";
2783
2671
  }
2784
- function combinedFormat(date, clock) {
2672
+ function refundDestinationAmounts(destination, amountCents) {
2785
2673
  return {
2786
- ...date,
2787
- ...clock.format
2674
+ cardCents: destination === "card" ? amountCents : 0,
2675
+ directCents: destination === "direct" ? amountCents : 0,
2676
+ creditCents: destination === "credit" ? amountCents : 0
2788
2677
  };
2789
2678
  }
2790
- function displayProfile(options, zone, seconds) {
2679
+ function addRefundDestinationAmounts(a, b) {
2791
2680
  return {
2792
- kind: "display",
2793
- dateFormat: dateFormat(options),
2794
- clock: {
2795
- kind: "compact",
2796
- localeSource: "product",
2797
- seconds
2798
- },
2799
- zone
2681
+ cardCents: a.cardCents + b.cardCents,
2682
+ directCents: a.directCents + b.directCents,
2683
+ creditCents: a.creditCents + b.creditCents
2800
2684
  };
2801
2685
  }
2802
- function dateCarrier(value) {
2803
- return value.kind === "civil" ? civilCarrier(value.value) : new Date(value.value);
2686
+ function hasDirectRefundFunding(funding) {
2687
+ return funding?.some((line$1) => line$1.destination === "direct" && line$1.remainingCents > 0) ?? false;
2804
2688
  }
2805
- function presentClock(value, context, clock) {
2806
- return clock.kind === "compact" ? formatBookingCompactEnglishTime({
2807
- startsAt: value,
2808
- timeZone: context.timeZone,
2809
- locale: clock.localeSource === "product" ? "en-GB" : context.locale
2810
- }, { seconds: clock.seconds }) : getDateTimeFormatter(context.locale, context.timeZone, clock.format).format(new Date(value));
2689
+ /** A refund cut-off as a span of time: "24 hours", "2 days", "1 hour". */
2690
+ function formatCancellationCutoffSpan(cutoffHours) {
2691
+ if (cutoffHours > 24 && cutoffHours % 24 === 0) return `${cutoffHours / 24} days`;
2692
+ return cutoffHours === 1 ? "1 hour" : `${cutoffHours} hours`;
2811
2693
  }
2812
- function offsetToken(value, context) {
2813
- return getDateTimeFormatter("en-GB", context.timeZone, { timeZoneName: "longOffset" }).formatToParts(new Date(value)).find((part) => part.type === "timeZoneName")?.value ?? "";
2694
+ /** Closed refusal and reconciliation reasons shared by stored reviews and receipts. */
2695
+ const scheduleBookingReasonCodes = [
2696
+ "closed",
2697
+ "switched_off",
2698
+ "course_booking",
2699
+ "checked_in",
2700
+ "cancelled",
2701
+ "waitlisted",
2702
+ "past",
2703
+ "date_missing",
2704
+ "payment_pending",
2705
+ "not_owner",
2706
+ "full",
2707
+ "not_enough_room",
2708
+ "needs_ticket_choice",
2709
+ "ticket_not_usable",
2710
+ "tickets_collide",
2711
+ "pass_not_accepted",
2712
+ "already_booked",
2713
+ "not_bookable",
2714
+ "not_found",
2715
+ "source_changed",
2716
+ "source_unavailable",
2717
+ "target_full",
2718
+ "target_not_bookable",
2719
+ "target_changed",
2720
+ "already_booked_on_target",
2721
+ "no_replacement_in_week",
2722
+ "changed_after_review",
2723
+ "added_after_review",
2724
+ "cancellation_chosen",
2725
+ "move_refused"
2726
+ ];
2727
+ const businessCancellationRefusalCodes = [
2728
+ "review_changed",
2729
+ "not_found",
2730
+ "payment_in_progress",
2731
+ "payment_check_unavailable",
2732
+ "partial_payment_terms",
2733
+ "settlement_not_allowed"
2734
+ ];
2735
+ const businessCancellationRefusalCopy = {
2736
+ review_changed: "Bookings have changed since you reviewed this schedule. Review the changes again before saving.",
2737
+ not_found: "One of these dates could not be found. Refresh the dates and review your changes again.",
2738
+ payment_in_progress: "A payment is still being processed for one of these bookings. Wait for it to finish, then review the cancellation again.",
2739
+ payment_check_unavailable: "We could not check a payment for one of these bookings. Review the cancellation again later, or contact us for help.",
2740
+ partial_payment_terms: "One of these bookings shares a payment arrangement with another booking. Cancel the bookings together or contact us for help.",
2741
+ settlement_not_allowed: "A refund choice can't be used any more: account credit may have been turned off, or how a booking was paid has changed. Review the cancellation again and choose again."
2742
+ };
2743
+
2744
+ //#endregion
2745
+ //#region ../core/src/booking-instalments.ts
2746
+ function isDepositBearingBookingInstalmentPlan(plan) {
2747
+ switch (plan.kind) {
2748
+ case "deposit_plus_one_remainder":
2749
+ case "deposit_plus_scheduled_instalments": return true;
2750
+ case "equal_scheduled_instalments": return false;
2751
+ default: return assertNever$4(plan);
2752
+ }
2753
+ }
2754
+ function getBookingInstalmentDepositRefundability(plan) {
2755
+ return isDepositBearingBookingInstalmentPlan(plan) ? plan.depositRefundability : null;
2756
+ }
2757
+ function getBookingInstalmentProtectedDepositAmountCents(plan) {
2758
+ return isDepositBearingBookingInstalmentPlan(plan) ? plan.depositAmountCents : null;
2759
+ }
2760
+ function clampConfiguredAmount(amountCents, totalAmountCents) {
2761
+ return Math.max(0, Math.min(amountCents, totalAmountCents));
2762
+ }
2763
+ function splitAmountWithRemainderInFirst(totalAmountCents, partCount) {
2764
+ if (partCount <= 0) {
2765
+ return [];
2766
+ }
2767
+ const baseAmountCents = Math.floor(totalAmountCents / partCount);
2768
+ const remainderCents = totalAmountCents - baseAmountCents * partCount;
2769
+ return Array.from({ length: partCount }, (_, index) => index === 0 ? baseAmountCents + remainderCents : baseAmountCents);
2770
+ }
2771
+ function addIntervalPreservingMonthAnchor(isoString, intervalCount, intervalUnit) {
2772
+ const date = new Date(isoString);
2773
+ if (!Number.isFinite(date.getTime())) {
2774
+ return isoString;
2775
+ }
2776
+ switch (intervalUnit) {
2777
+ case "day":
2778
+ date.setUTCDate(date.getUTCDate() + intervalCount);
2779
+ return date.toISOString();
2780
+ case "week":
2781
+ date.setUTCDate(date.getUTCDate() + intervalCount * 7);
2782
+ return date.toISOString();
2783
+ case "month": return addMonthsPreservingAnchorDay(date, intervalCount).toISOString();
2784
+ default: return assertNever$4(intervalUnit);
2785
+ }
2814
2786
  }
2815
- function formatTimeAgo(value, now, context) {
2816
- return formatRelative(value, now, context, "past");
2787
+ function getBookingInstalmentPlanIntervalCount(plan) {
2788
+ switch (plan.kind) {
2789
+ case "deposit_plus_one_remainder": return plan.remainderDueCount;
2790
+ case "deposit_plus_scheduled_instalments":
2791
+ case "equal_scheduled_instalments": return plan.intervalCount;
2792
+ default: return assertNever$4(plan);
2793
+ }
2817
2794
  }
2818
- function formatTimeUntil(value, now, context) {
2819
- return formatRelative(value, now, context, "future");
2795
+ function omitZeroAmountFutureRows(rows) {
2796
+ if (rows.length <= 1) {
2797
+ return rows;
2798
+ }
2799
+ const firstRow = rows[0];
2800
+ if (firstRow === undefined) {
2801
+ return [];
2802
+ }
2803
+ const futureRows = rows.slice(1);
2804
+ return [firstRow, ...futureRows.filter((row) => row.amountCents > 0)];
2820
2805
  }
2821
- const DATE_STYLE_PARTS = {
2822
- numeric: {
2823
- day: "2-digit",
2824
- month: "2-digit"
2825
- },
2826
- short: {
2827
- day: "numeric",
2828
- month: "short"
2829
- },
2830
- long: {
2831
- day: "numeric",
2832
- month: "long"
2833
- },
2834
- omit: {
2835
- day: undefined,
2836
- month: undefined
2806
+ function formatOrderInstalmentStatusLabel(input) {
2807
+ switch (input.status) {
2808
+ case "pending_initial_payment": return input.phaseKind === "initial" ? "Due today" : "Scheduled";
2809
+ case "scheduled": return "Scheduled";
2810
+ case "paid": return input.phaseKind === "initial" ? "Paid today" : "Paid";
2811
+ case "failed": return "Payment failed";
2812
+ case "waived": return "Waived";
2813
+ case "cancelled": return "Cancelled";
2814
+ case "cancelled_as_paid_early": return "Paid early";
2815
+ case "refunded": return "Refunded";
2816
+ default: return assertNever$4(input.status);
2837
2817
  }
2838
- };
2839
- function dateFormat(options) {
2818
+ }
2819
+ const NEXT_DUE_STATUSES = new Set(["scheduled", "failed"]);
2820
+ function buildOrderInstalmentSummary(input) {
2821
+ const nextDue = input.instalments.find((instalment) => NEXT_DUE_STATUSES.has(instalment.status)) ?? null;
2840
2822
  return {
2841
- ...DATE_STYLE_PARTS[options.date ?? "long"],
2842
- ...options.day ? { day: options.day === "omit" ? undefined : options.day } : {},
2843
- ...options.month === "omit" ? { month: undefined } : {},
2844
- ...options.year === "omit" ? {} : { year: "numeric" },
2845
- ...options.weekday ? { weekday: options.weekday } : {}
2823
+ status: input.paymentPlan.status,
2824
+ remainingBalanceCents: input.paymentPlan.remainingBalanceCents,
2825
+ nextDueAt: nextDue?.dueAt ?? null,
2826
+ nextDueAmountCents: nextDue?.amountCents ?? null,
2827
+ rows: [...input.instalments]
2846
2828
  };
2847
2829
  }
2848
- function civilCarrier(value) {
2849
- return new Date(Date.UTC(value.year, value.month - 1, value.day, 12));
2850
- }
2851
- function projectDate(value, context) {
2852
- return value.kind === "civil" ? value.value : getLocalScheduleDate(new Date(value.value), context.timeZone);
2830
+ function addMonthsPreservingAnchorDay(date, intervalCount) {
2831
+ const anchorDay = date.getUTCDate();
2832
+ const nextMonth = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + intervalCount, 1, date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds()));
2833
+ const lastDayOfTargetMonth = new Date(Date.UTC(nextMonth.getUTCFullYear(), nextMonth.getUTCMonth() + 1, 0)).getUTCDate();
2834
+ nextMonth.setUTCDate(Math.min(anchorDay, lastDayOfTargetMonth));
2835
+ return nextMonth;
2853
2836
  }
2854
- function normalizeDisplay(value) {
2855
- return value.replace(/[\u00a0\u202f]/gu, " ");
2837
+ function assertNever$4(value) {
2838
+ throw new Error(`Unexpected value: ${String(value)}`);
2856
2839
  }
2857
- function zoneToken(value, context, locale) {
2858
- return getDateTimeFormatter(locale, context.timeZone, { timeZoneName: "short" }).formatToParts(new Date(value)).find((part) => part.type === "timeZoneName")?.value ?? "";
2840
+
2841
+ //#endregion
2842
+ //#region ../core/src/booking-instalment-deposit.ts
2843
+ /**
2844
+ * A plan that starts with a deposit takes it by card when the customer books
2845
+ * and saves the card for the later payments, so the deposit must be at least
2846
+ * the card minimum for the site's currency. Plans without a deposit step
2847
+ * (equal instalments) charge their first instalment instead and are not
2848
+ * checked here.
2849
+ */
2850
+ function checkInstalmentPlanDeposit(plan, minimumCents) {
2851
+ if (!isDepositBearingBookingInstalmentPlan(plan)) return ok(undefined);
2852
+ return plan.depositAmountCents >= minimumCents ? ok(undefined) : err({
2853
+ kind: "instalment_deposit_below_minimum",
2854
+ minimumCents,
2855
+ option: "instalment_plan"
2856
+ });
2859
2857
  }
2860
- function zoneLabel(value, context) {
2861
- const tokens = [zoneToken(value, context, "en-GB"), zoneToken(value, context, "en-US")];
2862
- const abbreviation = tokens.find((token) => /^[A-Z]{2,6}$/u.test(token));
2863
- return abbreviation ?? formatTimeZoneCityLabel(context.timeZone);
2858
+ /** The deposit check for whichever instalment option a set of payment options offers. */
2859
+ function checkPaymentOptionsInstalmentDeposit(allowedOptions, minimumCents) {
2860
+ const failure = allowedOptions.map((option) => option.kind === "instalment_plan" ? checkInstalmentPlanDeposit(option.plan, minimumCents) : option.kind === "flexible_balance" && option.config.upfrontAmountCents < minimumCents ? err({
2861
+ kind: "instalment_deposit_below_minimum",
2862
+ minimumCents,
2863
+ option: "flexible_balance"
2864
+ }) : ok(undefined)).find((checked) => !checked.ok);
2865
+ return failure ?? ok(undefined);
2864
2866
  }
2865
- function assertOrdered(start, end) {
2866
- if (new Date(end).getTime() < new Date(start).getTime()) {
2867
- throw new RangeError("Date/time range end must be on or after its start");
2867
+ /** The one message for a deposit below the minimum, shown in the editor and returned by the server. */
2868
+ function describeInstalmentDepositBelowMinimum(failure, currency) {
2869
+ const minimum = formatCurrencyAmount(failure.minimumCents, currency);
2870
+ switch (failure.option) {
2871
+ case "instalment_plan": return `Enter a deposit of at least ${minimum}. We take it when the customer books and save their card for the later payments.`;
2872
+ case "flexible_balance": return `The deposit needs to be at least ${minimum}.`;
2868
2873
  }
2869
2874
  }
2870
- function calendarDayDifference(value, now, context) {
2871
- return compareLocalScheduleDates(getLocalScheduleDate(new Date(value), context.timeZone), getLocalScheduleDate(new Date(now), context.timeZone)) / 864e5;
2875
+
2876
+ //#endregion
2877
+ //#region ../core/src/booking-live-payment-terms.ts
2878
+ /**
2879
+ * Stored instalment-provider outcomes used by schedule coordination.
2880
+ * Order money admissions and flexible-balance liveness come from the position.
2881
+ * The table is total over the plan status union.
2882
+ */
2883
+ const LIVE_PLAN_STATUSES = {
2884
+ pending_initial_payment: true,
2885
+ active: true,
2886
+ payment_failed: true,
2887
+ reconciliation_required: true,
2888
+ completed: false,
2889
+ cancelled: false,
2890
+ cancelled_as_paid_early: false,
2891
+ refunded: false
2892
+ };
2893
+ function isLiveOrderInstalmentPlanStatus(status) {
2894
+ return LIVE_PLAN_STATUSES[status];
2872
2895
  }
2873
- function formatRelative(value, now, context, direction) {
2874
- const seconds = (new Date(value).getTime() - new Date(now).getTime()) / 1e3;
2875
- const magnitude = Math.abs(seconds);
2876
- if (direction === "past" && seconds > 0 && seconds <= 120) return relativeNearNow(context.locale, "past");
2877
- if (magnitude < 60) return relativeNearNow(context.locale, direction);
2878
- const days = calendarDayDifference(value, now, context);
2879
- if (Math.abs(days) > 7) return formatDate({
2880
- kind: "instant",
2881
- value
2882
- }, context, { date: "short" });
2883
- const formatter = new Intl.RelativeTimeFormat(context.locale, { numeric: "auto" });
2884
- if (days !== 0) return formatter.format(days, "day");
2885
- const unit = magnitude < 3600 ? "minute" : "hour";
2886
- const signedCount = Math.sign(seconds) * Math.floor(magnitude / (unit === "minute" ? 60 : 3600));
2887
- return formatter.format(signedCount, unit);
2896
+ /** The live plan statuses as a list, for queries that select plans to collect. */
2897
+ const LIVE_ORDER_INSTALMENT_PLAN_STATUSES = Object.keys(LIVE_PLAN_STATUSES).filter(isLiveOrderInstalmentPlanStatus);
2898
+ /** Shared reason for closing either form of booking payment terms. */
2899
+ const PAYMENT_TERMS_CLOSURE_REASONS = ["cancelled", "refunded"];
2900
+
2901
+ //#endregion
2902
+ //#region ../core/src/booking-payment-options.ts
2903
+ /**
2904
+ * One way a customer may pay for a booking. This is the single definition of
2905
+ * the option type; `booking-payment-schemas.typetest.ts` keeps it equal to the
2906
+ * schema's output in both directions.
2907
+ */
2908
+ /** When a course's instalments must all be paid by: before its first or its last live session. */
2909
+ const BOOKING_COURSE_INSTALMENT_DEADLINES = ["first_session", "last_session"];
2910
+ /** Automatic instalments and a flexible balance cannot share one booking offer. */
2911
+ function validateBookingPaymentOptionKinds(kinds) {
2912
+ if (kinds.length === 0) return err("no_options");
2913
+ const uniqueKinds = new Set(kinds);
2914
+ if (uniqueKinds.size !== kinds.length) return err("duplicate_kind");
2915
+ if (uniqueKinds.has("instalment_plan") && uniqueKinds.has("flexible_balance")) {
2916
+ return err("incompatible_collection_options");
2917
+ }
2918
+ return ok(undefined);
2888
2919
  }
2889
- function relativeNearNow(locale, direction) {
2890
- if (new Intl.Locale(locale).language === "en") return direction === "past" ? "just now" : "in a moment";
2891
- return new Intl.RelativeTimeFormat(locale, { numeric: "auto" }).format(0, "second");
2920
+
2921
+ //#endregion
2922
+ //#region ../core/src/booking-date-time/window.ts
2923
+ const START_OF_DAY = {
2924
+ hour: 0,
2925
+ minute: 0,
2926
+ second: 0
2927
+ };
2928
+ function parseWindowDate(value, field) {
2929
+ try {
2930
+ return {
2931
+ ok: true,
2932
+ value: parseBookingLocalDate(value)
2933
+ };
2934
+ } catch {
2935
+ return {
2936
+ ok: false,
2937
+ field,
2938
+ reason: "invalid_date_format",
2939
+ value
2940
+ };
2941
+ }
2892
2942
  }
2893
- /** Same city vocabulary as clock-label fallback, for explanatory timezone copy. */
2894
- function formatTimeZoneCityLabel(timeZone) {
2895
- return timeZone.startsWith("Etc/") ? "local time" : `${timeZone.split("/").slice(-1)[0]?.replace(/_/gu, " ") ?? timeZone} time`;
2943
+ function parseBookingUtcDateWindow(input) {
2944
+ const timeZone = resolveBookingTimeZoneId(input.timeZone);
2945
+ const start = parseWindowDate(input.startDate, "startDate");
2946
+ if (!start.ok) return start;
2947
+ const end = parseWindowDate(input.endDate, "endDate");
2948
+ if (!end.ok) return end;
2949
+ const startLocalDate = start.value;
2950
+ const endLocalDate = end.value;
2951
+ if (compareLocalScheduleDates(startLocalDate, endLocalDate) > 0) {
2952
+ return {
2953
+ ok: false,
2954
+ field: "endDate",
2955
+ reason: "invalid_date_range",
2956
+ value: input.endDate
2957
+ };
2958
+ }
2959
+ return {
2960
+ ok: true,
2961
+ value: {
2962
+ timeZone,
2963
+ startLocalDate,
2964
+ endLocalDate,
2965
+ startAt: localScheduleDateTimeToUtcDate(startLocalDate, START_OF_DAY, timeZone),
2966
+ endExclusive: localScheduleDateTimeToUtcDate(addLocalScheduleDays(endLocalDate, 1), START_OF_DAY, timeZone)
2967
+ }
2968
+ };
2969
+ }
2970
+ function buildBookingUtcDateWindow(input) {
2971
+ const result = parseBookingUtcDateWindow(input);
2972
+ if (result.ok) {
2973
+ return result.value;
2974
+ }
2975
+ if (result.reason === "invalid_date_range") {
2976
+ throw new Error(`Invalid booking date range: startDate "${input.startDate}" must be on or before endDate "${input.endDate}"`);
2977
+ }
2978
+ throw new Error(`Invalid booking date format: "${result.value}" (expected YYYY-MM-DD)`);
2896
2979
  }
2897
2980
 
2898
2981
  //#endregion
@@ -8389,16 +8472,17 @@ function nextLiveRunSessionStartMs(sessions, now) {
8389
8472
  return next === undefined ? null : sessionStartMs(next);
8390
8473
  }
8391
8474
  /**
8392
- * Booking stays open until the run's first surviving session has started.
8475
+ * Booking stays open until the run's cut-off, counted from its first surviving
8476
+ * session. A cut-off of zero closes it as that session starts.
8393
8477
  *
8394
8478
  * There has to be something left to sell: a run with no schedule at all, or one
8395
8479
  * whose every session has been cancelled, is closed rather than open. Adding a
8396
8480
  * future session opens it again, subject to the usual status, visibility and
8397
8481
  * admission rules.
8398
8482
  */
8399
- function isWholeSeriesRegistrationOpen(sessions, now) {
8400
- const firstStart = firstLiveRunSessionStartMs(sessions);
8401
- return firstStart !== null && firstStart > now.getTime();
8483
+ function isWholeSeriesRegistrationOpen(sessions, now, cutOffHours) {
8484
+ const first = orderedLiveRunSessions(sessions)[0];
8485
+ return first !== undefined && !hasBookingClosed(bookingClosesAt(first.startsAt, cutOffHours), now);
8402
8486
  }
8403
8487
  /**
8404
8488
  * Where the run sits in its own life, independent of any one session.
@@ -8423,8 +8507,8 @@ function resolveWholeSeriesRunLifecycle(input, now) {
8423
8507
  * Whether a prepared run is still inviting bookings at render time.
8424
8508
  *
8425
8509
  * `lifecycle` and `enrollmentOpen` come from the projection; the first session
8426
- * start is the one fact re-read against `now`, because that is the boundary a
8427
- * cached page can cross while it sits in front of a visitor.
8510
+ * start and the cut-off are the facts re-read against `now`, because those are
8511
+ * the boundaries a cached page can cross while it sits in front of a visitor.
8428
8512
  */
8429
8513
  function resolveWholeSeriesBookingPhase(run, now) {
8430
8514
  switch (run.lifecycle) {
@@ -8447,12 +8531,18 @@ function resolveWholeSeriesBookingPhase(run, now) {
8447
8531
  reason: "no-sessions"
8448
8532
  };
8449
8533
  }
8450
- if (!isWholeSeriesRegistrationOpen(run.sessions, now)) {
8534
+ if (!isWholeSeriesRegistrationOpen(run.sessions, now, BOOKING_CUT_OFF_AT_START)) {
8451
8535
  return {
8452
8536
  kind: "closed",
8453
8537
  reason: "in-progress"
8454
8538
  };
8455
8539
  }
8540
+ if (run.bookingClosesAt !== undefined && hasBookingClosed(run.bookingClosesAt, now)) {
8541
+ return {
8542
+ kind: "closed",
8543
+ reason: "bookings-closed"
8544
+ };
8545
+ }
8456
8546
  return run.enrollmentOpen ? { kind: "open" } : {
8457
8547
  kind: "closed",
8458
8548
  reason: "enrolment-closed"
@@ -8513,7 +8603,6 @@ const PUBLIC_READ_CACHE_POLICIES = {
8513
8603
  "public_memberships"
8514
8604
  ], "batch_only"),
8515
8605
  getPublicMapLocation: availability(["public_events", "public_event_filters"], "batch_only"),
8516
- resolveEventSubroute: availability(["public_events", "public_event_filters"], "direct"),
8517
8606
  listPublicRouteCandidates: content(["published_content"], "batch_only"),
8518
8607
  listPublicTeamMembers: content(["public_team_members"]),
8519
8608
  listPublicProducts: availability(["public_products"], "direct"),
@@ -10644,6 +10733,11 @@ const EMAIL_DEFINITIONS = {
10644
10733
  perEvent: false,
10645
10734
  templateStorage: true
10646
10735
  },
10736
+ event_booking_ticket_changed_admin: {
10737
+ wording: "editable",
10738
+ perEvent: false,
10739
+ templateStorage: true
10740
+ },
10647
10741
  membership_purchase_confirmation: {
10648
10742
  wording: "editable",
10649
10743
  perEvent: false,
@@ -11265,6 +11359,12 @@ function decideBookingEmbedChange(current, change) {
11265
11359
 
11266
11360
  //#endregion
11267
11361
  //#region ../core/src/ownerAppointmentTime.ts
11362
+ function googleBusy(check) {
11363
+ return check.kind === "checked" ? check.busy : [];
11364
+ }
11365
+ function googleCalendarWarning(check) {
11366
+ return check.kind === "unchecked" ? check.warning : null;
11367
+ }
11268
11368
  /** Owners may waive public rules, but cannot waive real clashes or book into the past. */
11269
11369
  function decideOwnerAppointmentTime(proposed, rules, nowMs) {
11270
11370
  const start = Date.parse(proposed.startAt);
@@ -11296,11 +11396,12 @@ function decideOwnerAppointmentTime(proposed, rules, nowMs) {
11296
11396
  booking_window: rules.bookingNotice.maxBookingNoticeMinutes !== null && start > nowMs + rules.bookingNotice.maxBookingNoticeMinutes * 6e4,
11297
11397
  buffer: rules.occupiedWindows.some((window) => overlaps$1(window, occupiedStart, occupiedEnd)),
11298
11398
  closure: rules.closures.some((window) => overlaps$1(window, occupiedStart, occupiedEnd)),
11299
- google_busy: rules.googleBusy.some((window) => overlaps$1(window, occupiedStart, occupiedEnd))
11399
+ google_busy: googleBusy(rules.googleCalendar).some((window) => overlaps$1(window, occupiedStart, occupiedEnd))
11300
11400
  };
11301
11401
  return {
11302
11402
  kind: "allowed",
11303
- ruleBreaks: Object.keys(breaks).filter((key) => breaks[key])
11403
+ ruleBreaks: Object.keys(breaks).filter((key) => breaks[key]),
11404
+ googleCalendarWarning: googleCalendarWarning(rules.googleCalendar)
11304
11405
  };
11305
11406
  }
11306
11407
  function regularRefusalFromBreaks(breaks) {
@@ -11339,7 +11440,10 @@ const OWNER_APPOINTMENT_RULE_COPY = {
11339
11440
  closure: "During a closure or time off",
11340
11441
  google_busy: "Busy in Google Calendar"
11341
11442
  };
11342
- const OWNER_APPOINTMENT_GOOGLE_UNAVAILABLE_COPY = "We couldn’t check Google Calendar, so this time might clash with something there.";
11443
+ const OWNER_APPOINTMENT_GOOGLE_WARNING_COPY = {
11444
+ read_failed: "We couldn’t check Google Calendar just now, so this time might clash with something there.",
11445
+ needs_reconnecting: "Google Calendar needs reconnecting, so this time hasn’t been checked against it."
11446
+ };
11343
11447
  const OWNER_APPOINTMENT_REFUSAL_COPY = {
11344
11448
  nonexistent_time: "The clocks go forward on this date, so that time is skipped. Choose another time.",
11345
11449
  invalid_time: "Choose a valid time for this service.",
@@ -11389,4 +11493,4 @@ function isEventOccurrenceRouteSegment(segment) {
11389
11493
  }
11390
11494
 
11391
11495
  //#endregion
11392
- export { footerLayoutForLookId as $, unsafeAsFileChecksumSha256 as $n, isLiveOrderInstalmentPlanStatus as $t, publicReadBatchFreshnessSeconds as A, toCents as An, blockInteractionContextSchema as Ar, formatTimeRange as At, parseManagementKey as B, unsafeAsAppointmentResourceId as Bn, getLocalScheduleDate as Bt, ORDINARY_EVENT_PRESET_VALUES as C, resolvePricingOptionsPriceDisplay as Cn, unsafeAsEventInstanceId as Cr, mapDrawingSchema as Ct, PUBLIC_CONTENT_FRESHNESS_SECONDS as D, isNonNegativeWholeCents as Dn, unsafeAsPricingOptionId as Dr, formatDateTime as Dt, PUBLIC_AVAILABILITY_FRESHNESS_SECONDS as E, mapReadonlyNonEmptyArray as En, unsafeAsOccurrenceId as Er, formatDateRange as Et, orderedLiveRunSessions as F, parseCurrencyCode as Fn, addLocalScheduleDays as Ft, parseMailingListRuntimeContext as G, unsafeAsEntitlementId as Gn, resolveBookingBusinessTimeZone as Gt, parseMailingListBlockId as H, parseCustomerId as Hn, localScheduleTimePattern as Ht, resolveWholeSeriesBookingPhase as I, assertNever as In, compareLocalScheduleDates as It, parseMailingListGlobalForm as J, parseDatedOfferingCapacityHoldId as Jn, parseBookingTimeZone as Jt, assessMailingListTargeting as K, unsafeAsPassId as Kn, resolveBookingTimeZoneId as Kt, resolveWholeSeriesRunLifecycle as L, formatDurationUnitLabel as Ln, formatLocalScheduleDate as Lt, CANCELLED_SESSION_STATUS as M, unsafeAsNonNegativeCents as Mn, resolveBookingDisplayContext as Mt, firstLiveRunSessionStartMs as N, unsafeAsPositiveCents as Nn, toScheduledBookingDateTime as Nt, getPublicReadCachePolicy as O, parseNonNegativeCents as On, err as Or, formatDateTimeRange as Ot, nextLiveRunSessionStartMs as P, formatCurrencyAmount as Pn, buildBookingUtcDateWindow as Pt, parseFooterCompositionV1 as Q, unsafeAsDetectedMimeType as Qn, validateBookingPaymentOptionKinds as Qt, createSecret as R, unsafeAsBookingRequirementId as Rn, formatLocalScheduleTime as Rt, EVENT_PRESET_VALUES as S, resolveExactOrFreePriceDisplay as Sn, unsafeAsEventCategoryId as Sr, trimmedStringOrNull as St, WHOLE_SERIES_EVENT_PRESET_VALUES as T, mapNonEmptyArray as Tn, unsafeAsEventSeriesId as Tr, formatDate as Tt, parseMailingListContentVersionId as U, parseSiteTermsVersionId as Un, parseBookingLocalDate as Ut, slugify as V, unsafeAsStaffMemberId as Vn, getLocalScheduleTime as Vt, parseMailingListSignedSourceToken as W, parseMembershipId as Wn, parseLocalScheduleTime as Wt, DEFAULT_MAILING_LIST_SUCCESS_MESSAGE as X, parseMediaAssetId as Xn, toUtcIsoDateTimeString as Xt, DEFAULT_MAILING_LIST_PRIVACY_NOTE as Y, unsafeAsBookingSessionId as Yn, parseUtcIsoDateTimeString as Yt, parseMailingListProviderScope as Z, unsafeAsDeclaredMimeType as Zn, BOOKING_COURSE_INSTALMENT_DEADLINES as Zt, canonicalizeConfiguredBookingVerticalConfig as _, publicEventPricingCurrency as _n, parseUserId as _r, parseLocationValue as _t, authoredValuesEqual as a, omitZeroAmountFutureRows as an, unsafeAsSiteScopedStoragePath as ar, formatOpeningHoursRows as at, resolveSiteVerticalBookingConfig as b, publicEventPricingStrategy as bn, parseEventSeriesId as br, toLocationCoordinates as bt, STAFF_OPERATIONAL_CAPABILITIES as c, scheduleBookingReasonCodes as cn, unsafeAsUploadSessionId as cr, assertAllowedPublicUrl as ct, formatCreditProductUnits as d, deriveTotalTicketQuantity as dn, unsafeAsOrderFlexibleBalanceContractId as dr, decideLocationSave as dt, addIntervalPreservingMonthAnchor as en, unsafeAsMediaAssetId as er, parseMailingListPlacementTargeting as et, planTurningOnCourses as f, parsePageSurfaceSubject as fn, unsafeAsOrderPaymentPlanId as fr, stableJsonStringify as ft, areConfiguredBookingVerticalConfigsEqual as g, isPublicEventPricingOptionDisplayable as gn, parseSiteId as gr, normalizeLocationAddressText as gt, NAVIGATION_LOCATIONS as h, formatEventPricing as hn, parseApiKeyId as hr, locationValueSchema as ht, isRecord as i, getBookingInstalmentProtectedDepositAmountCents as in, unsafeAsSafeDownloadFilename as ir, richTextHasText as it, publicReadFreshnessSeconds as j, toNonNegativeCents as jn, inferSiteDateLocale as jt, isPublicReadEndpoint as k, parsePositiveCents as kn, ok as kr, formatTime as kt, creditProductUnitNoun as l, resolveFlexibleBalanceDueAt as ln, unsafeAsProductId as lr, SENSITIVE_COLLECTION_CONFIRMATION_VERSION as lt, withBookingModulesForSelectionChange as m, formatBookingPriceDisplay as mn, unsafeAsSiteFontId as mr, EVENT_ADDRESS_AFTER_BOOKING_LABEL as mt, OFFLINE_PAYMENT_METHODS as n, getBookingInstalmentDepositRefundability as nn, unsafeAsPositiveByteCount as nr, planMailingListChoicePresentation as nt, applyClearable as o, splitAmountWithRemainderInFirst as on, unsafeAsStorageBucketName as or, parsePublicContactDetails as ot, resolveEventCatalogue as p, EVENT_PRESET_VOCABULARY as pn, parseEditorSessionGeneration as pr, locationMapLinks as pt, parseConfiguredMailingListProvider as q, parseDatedOfferingCapacityHoldAuditRef as qn, toBookingTimeZone as qt, committedWriteProofSchema as r, getBookingInstalmentPlanIntervalCount as rn, unsafeAsPositiveSeconds as rr, isCanonicalRichTextDoc as rt, clearableFrom as s, businessCancellationRefusalCodes as sn, unsafeAsStoragePath as sr, parseWeeklyOpeningHours as st, isEventOccurrenceRouteSegment as t, clampConfiguredAmount as tn, unsafeAsOriginalFilename as tr, DEFAULT_MAILING_LIST_TARGETING as tt, formatCreditProductPayment as u, resolveFlexibleBalanceInitialPaymentCents as un, unsafeAsCheckoutLineId as ur, SENSITIVE_COLLECTION_MODES as ut, parseVerticalId as v, publicEventPricingDisplay as vn, unsafeAsSiteId as vr, projectPublicLocation as vt, SURFACE_EVENT_PRESET_VALUES as w, fromArray as wn, unsafeAsEventOfferingId as wr, selectCategoryView as wt, DEFAULT_EVENT_TYPE_PRESETS as x, publicEventPricingType as xn, parseRetiredCourseId as xr, isPresent as xt, parseVerticalPresetId as y, publicEventPricingOptions as yn, unsafeAsUserId as yr, publicLocationSchema as yt, exposeSecret as z, unsafeAsDemoCapability as zn, getBookingLocalDateKey as zt };
11496
+ export { footerLayoutForLookId as $, parseDatedOfferingCapacityHoldId as $n, resolveBookingDisplayContext as $t, publicReadBatchFreshnessSeconds as A, mapNonEmptyArray as An, unsafeAsEventSeriesId as Ar, clampConfiguredAmount as At, parseManagementKey as B, parseCurrencyCode as Bn, deriveTotalTicketQuantity as Bt, ORDINARY_EVENT_PRESET_VALUES as C, publicEventPricingDisplay as Cn, unsafeAsSiteId as Cr, mapDrawingSchema as Ct, PUBLIC_CONTENT_FRESHNESS_SECONDS as D, resolveExactOrFreePriceDisplay as Dn, unsafeAsEventCategoryId as Dr, validateBookingPaymentOptionKinds as Dt, PUBLIC_AVAILABILITY_FRESHNESS_SECONDS as E, publicEventPricingType as En, parseRetiredCourseId as Er, BOOKING_COURSE_INSTALMENT_DEADLINES as Et, orderedLiveRunSessions as F, toCents as Fn, blockInteractionContextSchema as Fr, splitAmountWithRemainderInFirst as Ft, parseMailingListRuntimeContext as G, unsafeAsAppointmentResourceId as Gn, hasBookingClosed as Gt, parseMailingListBlockId as H, formatDurationUnitLabel as Hn, bookingCutOffHoursBetween as Ht, resolveWholeSeriesBookingPhase as I, toNonNegativeCents as In, businessCancellationRefusalCodes as It, parseMailingListGlobalForm as J, parseSiteTermsVersionId as Jn, formatDateTime as Jt, assessMailingListTargeting as K, unsafeAsStaffMemberId as Kn, formatDate as Kt, resolveWholeSeriesRunLifecycle as L, unsafeAsNonNegativeCents as Ln, scheduleBookingReasonCodes as Lt, CANCELLED_SESSION_STATUS as M, isNonNegativeWholeCents as Mn, unsafeAsPricingOptionId as Mr, getBookingInstalmentPlanIntervalCount as Mt, firstLiveRunSessionStartMs as N, parseNonNegativeCents as Nn, err as Nr, getBookingInstalmentProtectedDepositAmountCents as Nt, getPublicReadCachePolicy as O, resolvePricingOptionsPriceDisplay as On, unsafeAsEventInstanceId as Or, isLiveOrderInstalmentPlanStatus as Ot, nextLiveRunSessionStartMs as P, parsePositiveCents as Pn, ok as Pr, omitZeroAmountFutureRows as Pt, parseFooterCompositionV1 as Q, parseDatedOfferingCapacityHoldAuditRef as Qn, inferSiteDateLocale as Qt, createSecret as R, unsafeAsPositiveCents as Rn, resolveFlexibleBalanceDueAt as Rt, EVENT_PRESET_VALUES as S, publicEventPricingCurrency as Sn, parseUserId as Sr, trimmedStringOrNull as St, WHOLE_SERIES_EVENT_PRESET_VALUES as T, publicEventPricingStrategy as Tn, parseEventSeriesId as Tr, buildBookingUtcDateWindow as Tt, parseMailingListContentVersionId as U, unsafeAsBookingRequirementId as Un, formatBookingClosedTime as Ut, slugify as V, assertNever as Vn, MAX_BOOKING_CUT_OFF_HOURS as Vt, parseMailingListSignedSourceToken as W, unsafeAsDemoCapability as Wn, formatBookingCutOffHours as Wt, DEFAULT_MAILING_LIST_SUCCESS_MESSAGE as X, unsafeAsEntitlementId as Xn, formatTime as Xt, DEFAULT_MAILING_LIST_PRIVACY_NOTE as Y, parseMembershipId as Yn, formatDateTimeRange as Yt, parseMailingListProviderScope as Z, unsafeAsPassId as Zn, formatTimeRange as Zt, canonicalizeConfiguredBookingVerticalConfig as _, parsePageSurfaceSubject as _n, unsafeAsOrderPaymentPlanId as _r, parseLocationValue as _t, authoredValuesEqual as a, getBookingLocalDateKey as an, unsafeAsMediaAssetId as ar, formatOpeningHoursRows as at, resolveSiteVerticalBookingConfig as b, formatEventPricing as bn, parseApiKeyId as br, toLocationCoordinates as bt, STAFF_OPERATIONAL_CAPABILITIES as c, localScheduleTimePattern as cn, unsafeAsPositiveSeconds as cr, assertAllowedPublicUrl as ct, formatCreditProductUnits as d, parseUtcIsoDateTimeString as dn, unsafeAsStorageBucketName as dr, decideLocationSave as dt, toScheduledBookingDateTime as en, unsafeAsBookingSessionId as er, parseMailingListPlacementTargeting as et, planTurningOnCourses as f, toUtcIsoDateTimeString as fn, unsafeAsStoragePath as fr, stableJsonStringify as ft, areConfiguredBookingVerticalConfigsEqual as g, parseBookingTimeZone as gn, unsafeAsOrderFlexibleBalanceContractId as gr, normalizeLocationAddressText as gt, NAVIGATION_LOCATIONS as h, toBookingTimeZone as hn, unsafeAsCheckoutLineId as hr, locationValueSchema as ht, isRecord as i, formatLocalScheduleTime as in, unsafeAsFileChecksumSha256 as ir, richTextHasText as it, publicReadFreshnessSeconds as j, mapReadonlyNonEmptyArray as jn, unsafeAsOccurrenceId as jr, getBookingInstalmentDepositRefundability as jt, isPublicReadEndpoint as k, fromArray as kn, unsafeAsEventOfferingId as kr, addIntervalPreservingMonthAnchor as kt, creditProductUnitNoun as l, parseBookingLocalDate as ln, unsafeAsSafeDownloadFilename as lr, SENSITIVE_COLLECTION_CONFIRMATION_VERSION as lt, withBookingModulesForSelectionChange as m, resolveBookingTimeZoneId as mn, unsafeAsProductId as mr, EVENT_ADDRESS_AFTER_BOOKING_LABEL as mt, OFFLINE_PAYMENT_METHODS as n, compareLocalScheduleDates as nn, unsafeAsDeclaredMimeType as nr, planMailingListChoicePresentation as nt, applyClearable as o, getLocalScheduleDate as on, unsafeAsOriginalFilename as or, parsePublicContactDetails as ot, resolveEventCatalogue as p, resolveBookingBusinessTimeZone as pn, unsafeAsUploadSessionId as pr, locationMapLinks as pt, parseConfiguredMailingListProvider as q, parseCustomerId as qn, formatDateRange as qt, committedWriteProofSchema as r, formatLocalScheduleDate as rn, unsafeAsDetectedMimeType as rr, isCanonicalRichTextDoc as rt, clearableFrom as s, getLocalScheduleTime as sn, unsafeAsPositiveByteCount as sr, parseWeeklyOpeningHours as st, isEventOccurrenceRouteSegment as t, addLocalScheduleDays as tn, parseMediaAssetId as tr, DEFAULT_MAILING_LIST_TARGETING as tt, formatCreditProductPayment as u, parseLocalScheduleTime as un, unsafeAsSiteScopedStoragePath as ur, SENSITIVE_COLLECTION_MODES as ut, parseVerticalId as v, EVENT_PRESET_VOCABULARY as vn, parseEditorSessionGeneration as vr, projectPublicLocation as vt, SURFACE_EVENT_PRESET_VALUES as w, publicEventPricingOptions as wn, unsafeAsUserId as wr, selectCategoryView as wt, DEFAULT_EVENT_TYPE_PRESETS as x, isPublicEventPricingOptionDisplayable as xn, parseSiteId as xr, isPresent as xt, parseVerticalPresetId as y, formatBookingPriceDisplay as yn, unsafeAsSiteFontId as yr, publicLocationSchema as yt, exposeSecret as z, formatCurrencyAmount as zn, resolveFlexibleBalanceInitialPaymentCents as zt };