riverbankcms 0.31.2 → 0.32.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.
@@ -629,6 +629,13 @@ function eventPricingRequiresPayment(pricing) {
629
629
  default: return assertNever(pricing);
630
630
  }
631
631
  }
632
+ /** Entitlements that can pay for the current scope and number of participants. */
633
+ function eventRegistrationEntitlementPolicy(input) {
634
+ return {
635
+ passes: input.participantCount === 1 && input.scope === "occurrence",
636
+ memberships: input.participantCount === 1
637
+ };
638
+ }
632
639
 
633
640
  //#endregion
634
641
  //#region ../core/src/currency-format.ts
@@ -868,6 +875,17 @@ function mapReadonlyNonEmptyArray(items, map) {
868
875
  const [first, ...rest] = items;
869
876
  return [map(first, 0), ...rest.map((item, index) => map(item, index + 1))];
870
877
  }
878
+ /** Promise.all with the input's non-empty cardinality preserved. */
879
+ async function allReadonlyNonEmpty(promises) {
880
+ const [first, ...rest] = await Promise.all(promises);
881
+ return [first, ...rest];
882
+ }
883
+ /** Keep ordered successes only when every member succeeded. */
884
+ function collectReadonlyNonEmptyResults(results) {
885
+ const [first, ...rest] = results;
886
+ if (!first.ok) return first;
887
+ return rest.reduce((collected, result) => !collected.ok ? collected : !result.ok ? result : ok([...collected.value, result.value]), ok([first.value]));
888
+ }
871
889
 
872
890
  //#endregion
873
891
  //#region ../core/src/event-booking-offer-parser.ts
@@ -1662,7 +1680,6 @@ function deriveTotalTicketQuantity(lines) {
1662
1680
 
1663
1681
  //#endregion
1664
1682
  //#region ../core/src/booking-flexible-balance.ts
1665
- const DEFAULT_FLEXIBLE_BALANCE_STRIPE_MINIMUM_CHARGE_CENTS = 50;
1666
1683
  function clampFlexibleBalanceConfiguredAmount(amountCents, totalAmountCents) {
1667
1684
  return Math.max(0, Math.min(amountCents, totalAmountCents));
1668
1685
  }
@@ -1687,86 +1704,6 @@ function calculateFlexibleBalanceMinimumPaymentCents(input) {
1687
1704
  const percentageFloor = Math.ceil(input.remainingBalanceCents * minimumPercentageBps / 1e4);
1688
1705
  return Math.min(input.remainingBalanceCents, Math.max(input.stripeMinimumChargeCents, percentageFloor));
1689
1706
  }
1690
- function resolveFlexibleBalancePaymentEligibility(input) {
1691
- if (input.remainingBalanceCents <= 0 || input.status === "completed") {
1692
- return {
1693
- kind: "unavailable",
1694
- reason: "already_settled"
1695
- };
1696
- }
1697
- switch (input.status) {
1698
- case "payment_pending":
1699
- case "cancelled_due_to_non_payment":
1700
- case "refunded":
1701
- case "waived": return {
1702
- kind: "unavailable",
1703
- reason: input.status
1704
- };
1705
- case "closed_order_failed": return {
1706
- kind: "unavailable",
1707
- reason: "order_failed"
1708
- };
1709
- case "overdue": return {
1710
- kind: "full_balance_only",
1711
- remainingBalanceCents: input.remainingBalanceCents,
1712
- reason: "overdue"
1713
- };
1714
- case "active": {
1715
- const minimumAmountCents = calculateFlexibleBalanceMinimumPaymentCents({
1716
- remainingBalanceCents: input.remainingBalanceCents,
1717
- stripeMinimumChargeCents: input.stripeMinimumChargeCents,
1718
- minimumPercentageBps: input.minimumPercentageBps
1719
- });
1720
- if (minimumAmountCents >= input.remainingBalanceCents) {
1721
- return {
1722
- kind: "full_balance_only",
1723
- remainingBalanceCents: input.remainingBalanceCents,
1724
- reason: "dust_balance"
1725
- };
1726
- }
1727
- return {
1728
- kind: "eligible",
1729
- minimumAmountCents,
1730
- maximumCustomAmountCents: input.remainingBalanceCents,
1731
- suggestedPayFullAmountCents: input.remainingBalanceCents
1732
- };
1733
- }
1734
- default: return assertNever$5(input.status);
1735
- }
1736
- }
1737
- function isFlexibleBalanceReminderSuppressed(input) {
1738
- const suppressionWindowHours = input.suppressionWindowHours ?? 24;
1739
- const bookedAtMs = Date.parse(input.bookedAt);
1740
- const reminderDueAtMs = Date.parse(input.reminderDueAt);
1741
- if (!Number.isFinite(bookedAtMs) || !Number.isFinite(reminderDueAtMs)) {
1742
- return false;
1743
- }
1744
- return reminderDueAtMs - bookedAtMs < suppressionWindowHours * 60 * 60 * 1e3;
1745
- }
1746
- function buildFlexibleBalanceReminderSchedule(input) {
1747
- const schedule = [
1748
- {
1749
- kind: "due_7_days",
1750
- scheduledFor: subtractDaysFromIso(input.dueAt, 7)
1751
- },
1752
- {
1753
- kind: "due_1_day",
1754
- scheduledFor: subtractDaysFromIso(input.dueAt, 1)
1755
- },
1756
- {
1757
- kind: "overdue_1_day",
1758
- scheduledFor: addDaysToIso(input.dueAt, 1)
1759
- }
1760
- ];
1761
- return schedule.map((entry) => ({
1762
- kind: entry.kind,
1763
- scheduledFor: entry.scheduledFor,
1764
- suppressed: isFlexibleBalanceReminderSuppressed({
1765
- bookedAt: input.bookedAt,
1766
- reminderDueAt: entry.scheduledFor
1767
- })
1768
- }));
1769
- }
1770
1707
  function assertNever$5(value) {
1771
1708
  throw new Error(`Unexpected value: ${String(value)}`);
1772
1709
  }
@@ -1820,6 +1757,11 @@ function addRefundDestinationAmounts(a, b) {
1820
1757
  function hasDirectRefundFunding(funding) {
1821
1758
  return funding?.some((line$1) => line$1.destination === "direct" && line$1.remainingCents > 0) ?? false;
1822
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
+ }
1823
1765
  /** Closed refusal and reconciliation reasons shared by stored reviews and receipts. */
1824
1766
  const scheduleBookingReasonCodes = [
1825
1767
  "closed",
@@ -1858,14 +1800,16 @@ const businessCancellationRefusalCodes = [
1858
1800
  "not_found",
1859
1801
  "payment_in_progress",
1860
1802
  "payment_check_unavailable",
1861
- "partial_payment_terms"
1803
+ "partial_payment_terms",
1804
+ "settlement_not_allowed"
1862
1805
  ];
1863
1806
  const businessCancellationRefusalCopy = {
1864
1807
  review_changed: "Bookings have changed since you reviewed this schedule. Review the changes again before saving.",
1865
1808
  not_found: "One of these dates could not be found. Refresh the dates and review your changes again.",
1866
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.",
1867
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.",
1868
- partial_payment_terms: "One of these bookings shares a payment arrangement with another booking. Cancel the bookings together 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."
1869
1813
  };
1870
1814
 
1871
1815
  //#endregion
@@ -2003,11 +1947,9 @@ function describeInstalmentDepositBelowMinimum(failure, currency) {
2003
1947
  //#endregion
2004
1948
  //#region ../core/src/booking-live-payment-terms.ts
2005
1949
  /**
2006
- * Whether an order still has payment terms being collected: an instalment plan
2007
- * or a flexible-balance contract that hasn't been settled, closed or cancelled.
2008
- *
2009
- * Both tables are total over their status unions, so a new status is a compile
2010
- * error here until someone decides whether it counts as live.
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.
2011
1953
  */
2012
1954
  const LIVE_PLAN_STATUSES = {
2013
1955
  pending_initial_payment: true,
@@ -2019,79 +1961,13 @@ const LIVE_PLAN_STATUSES = {
2019
1961
  cancelled_as_paid_early: false,
2020
1962
  refunded: false
2021
1963
  };
2022
- const LIVE_CONTRACT_STATUSES = {
2023
- active: true,
2024
- payment_pending: true,
2025
- overdue: true,
2026
- completed: false,
2027
- waived: false,
2028
- refunded: false,
2029
- cancelled_due_to_non_payment: false,
2030
- closed_order_failed: false
2031
- };
2032
1964
  function isLiveOrderInstalmentPlanStatus(status) {
2033
1965
  return LIVE_PLAN_STATUSES[status];
2034
1966
  }
2035
1967
  /** The live plan statuses as a list, for queries that select plans to collect. */
2036
1968
  const LIVE_ORDER_INSTALMENT_PLAN_STATUSES = Object.keys(LIVE_PLAN_STATUSES).filter(isLiveOrderInstalmentPlanStatus);
2037
- function isLiveFlexibleBalanceContractStatus(status) {
2038
- return LIVE_CONTRACT_STATUSES[status];
2039
- }
2040
- function hasLivePaymentTerms(input) {
2041
- return input.plan !== null && isLiveOrderInstalmentPlanStatus(input.plan.status) || input.contract !== null && isLiveFlexibleBalanceContractStatus(input.contract.status);
2042
- }
2043
- /** Partial refunds must also protect a cancelled contract that staff can reopen. */
2044
- function paymentTermsBlockPartialRefund(input) {
2045
- return hasLivePaymentTerms(input) || input.contract?.status === "cancelled_due_to_non_payment";
2046
- }
2047
- /**
2048
- * Live statuses where a collection is already in flight: the first payment,
2049
- * a card charge, or a Stripe reconciliation hasn't resolved yet. Nobody may
2050
- * settle the balance by hand while one of these is running. Both tables are
2051
- * total over the live statuses, so a new live status must be classified here.
2052
- */
2053
- const PLAN_COLLECTION_IN_FLIGHT = {
2054
- pending_initial_payment: true,
2055
- reconciliation_required: true,
2056
- active: false,
2057
- payment_failed: false
2058
- };
2059
- const CONTRACT_COLLECTION_IN_FLIGHT = {
2060
- payment_pending: true,
2061
- active: false,
2062
- overdue: false
2063
- };
2064
- /**
2065
- * Whether an instalment plan's remaining balance can take a payment now, by
2066
- * hand or online: it's live and no collection is in flight.
2067
- */
2068
- function isSettleableOrderInstalmentPlanStatus(status) {
2069
- return isLiveOrderInstalmentPlanStatus(status) && !PLAN_COLLECTION_IN_FLIGHT[status];
2070
- }
2071
- /**
2072
- * Whether a flexible-balance contract's remaining balance can take a payment
2073
- * now, by hand or online: it's live and no collection is in flight.
2074
- */
2075
- function isSettleableFlexibleBalanceContractStatus(status) {
2076
- return isLiveFlexibleBalanceContractStatus(status) && !CONTRACT_COLLECTION_IN_FLIGHT[status];
2077
- }
2078
1969
  /** Shared reason for closing either form of booking payment terms. */
2079
1970
  const PAYMENT_TERMS_CLOSURE_REASONS = ["cancelled", "refunded"];
2080
- /** Refund closure records its outcome even when collection has already ended. */
2081
- function decideContractClosure(status, reason) {
2082
- if (reason === "refunded") {
2083
- return status === "refunded" ? { kind: "keep" } : {
2084
- kind: "close",
2085
- from: status,
2086
- to: "refunded"
2087
- };
2088
- }
2089
- return isLiveFlexibleBalanceContractStatus(status) ? {
2090
- kind: "close",
2091
- from: status,
2092
- to: "closed_order_failed"
2093
- } : { kind: "keep" };
2094
- }
2095
1971
 
2096
1972
  //#endregion
2097
1973
  //#region ../core/src/booking-payment-options.ts
@@ -3822,25 +3698,20 @@ function resolvePermittedLocation(permission, location, siteCountry) {
3822
3698
 
3823
3699
  //#endregion
3824
3700
  //#region ../core/src/venue-location.ts
3825
- const venueLocationAudience = Symbol("venue-location-audience");
3826
3701
  /** Eligibility to read the venue is decided by the resource owner before disclosure. */
3827
3702
  function decidePublicVenueLocation(venue, siteCountry) {
3828
- const audience = { [venueLocationAudience]: "public" };
3829
3703
  if (venue.location === null) return {
3830
- ...audience,
3831
3704
  kind: "none",
3832
3705
  name: venue.name
3833
3706
  };
3834
3707
  if (venue.addressVisibility === "booked") {
3835
3708
  return {
3836
- ...audience,
3837
3709
  kind: "area",
3838
3710
  name: venue.name,
3839
3711
  area: deriveLocationArea(venue.location.address)
3840
3712
  };
3841
3713
  }
3842
3714
  return {
3843
- ...audience,
3844
3715
  kind: "full",
3845
3716
  name: venue.name,
3846
3717
  ...projectPublicLocation(venue.location, siteCountry)
@@ -3848,19 +3719,39 @@ function decidePublicVenueLocation(venue, siteCountry) {
3848
3719
  }
3849
3720
  /** Caller must already hold confirmed-booking or staff authorisation. */
3850
3721
  function decideArrivalVenueLocation(venue, siteCountry) {
3851
- const audience = { [venueLocationAudience]: "arrival" };
3852
3722
  return venue.location === null ? {
3853
- ...audience,
3854
3723
  kind: "none",
3855
3724
  name: venue.name
3856
3725
  } : {
3857
- ...audience,
3858
3726
  kind: "full",
3859
3727
  name: venue.name,
3860
3728
  ...projectPublicLocation(venue.location, siteCountry)
3861
3729
  };
3862
3730
  }
3863
3731
 
3732
+ //#endregion
3733
+ //#region ../core/src/first-name.ts
3734
+ const NAME_TITLES = new Set([
3735
+ "dr",
3736
+ "mr",
3737
+ "mrs",
3738
+ "ms",
3739
+ "mx",
3740
+ "miss",
3741
+ "prof",
3742
+ "professor",
3743
+ "sir",
3744
+ "rev"
3745
+ ]);
3746
+ /**
3747
+ * The name to use for someone in a sentence: "Jane" from "Dr. Jane Smith". A
3748
+ * title on its own is kept, since it's all we have. Empty when there's no name.
3749
+ */
3750
+ function firstNameFrom(name) {
3751
+ const words = name.trim().split(/\s+/);
3752
+ return words.find((word) => !NAME_TITLES.has(word.toLowerCase().replace(/\.$/, ""))) ?? words[0] ?? "";
3753
+ }
3754
+
3864
3755
  //#endregion
3865
3756
  //#region ../core/src/locationLinks.ts
3866
3757
  /** Both outbound actions use the arrival pin, never match evidence. */
@@ -5517,6 +5408,16 @@ function publishedContactDetails(profile) {
5517
5408
  };
5518
5409
  return null;
5519
5410
  }
5411
+ /** Public payloads and authoring previews publish the same permitted facts. */
5412
+ function publishedProfileFacts(profile, businessAddress) {
5413
+ return {
5414
+ publicProfile: {
5415
+ ...profile,
5416
+ contact: publishedContactDetails(profile)
5417
+ },
5418
+ businessAddress: profile.addressVisibility === "shown" ? businessAddress : null
5419
+ };
5420
+ }
5520
5421
  function parseAddressVisibility(value) {
5521
5422
  if (value === undefined || value === null) return ok("shown");
5522
5423
  if (value === "shown" || value === "hidden") return ok(value);
@@ -5583,6 +5484,15 @@ const openingHoursWeekdayLabels = {
5583
5484
  saturday: "Saturday",
5584
5485
  sunday: "Sunday"
5585
5486
  };
5487
+ const shortWeekdayLabels = {
5488
+ monday: "Mon",
5489
+ tuesday: "Tue",
5490
+ wednesday: "Wed",
5491
+ thursday: "Thu",
5492
+ friday: "Fri",
5493
+ saturday: "Sat",
5494
+ sunday: "Sun"
5495
+ };
5586
5496
  function formatOpeningHoursTime(value) {
5587
5497
  const time = parseLocalScheduleTime(value);
5588
5498
  return formatBookingCompactEnglishTime(toScheduledBookingDateTime({
@@ -5594,14 +5504,15 @@ function formatOpeningHoursTime(value) {
5594
5504
  function formatDayHours(day) {
5595
5505
  return day.kind === "closed" ? "Closed" : day.intervals.map((interval) => `${formatOpeningHoursTime(interval.opensAt)} to ${formatOpeningHoursTime(interval.closesAt)}`).join(", ");
5596
5506
  }
5597
- function weekdayRangeLabel(weekdays) {
5507
+ function weekdayRangeLabel(weekdays, style) {
5598
5508
  const first = weekdays[0];
5599
5509
  const last = weekdays[weekdays.length - 1];
5600
5510
  if (!first || !last) return "";
5601
- return first === last ? openingHoursWeekdayLabels[first] : `${openingHoursWeekdayLabels[first]} to ${openingHoursWeekdayLabels[last]}`;
5511
+ const labels = style === "short" ? shortWeekdayLabels : openingHoursWeekdayLabels;
5512
+ return first === last ? labels[first] : `${labels[first]}${style === "short" ? "–" : " to "}${labels[last]}`;
5602
5513
  }
5603
5514
  /** Monday-first table rows; only adjacent days with identical ranges are grouped. */
5604
- function formatOpeningHoursRows(hours) {
5515
+ function formatOpeningHoursRows(hours, options = {}) {
5605
5516
  return (hours?.days ?? []).reduce((rows, day) => {
5606
5517
  const text = formatDayHours(day);
5607
5518
  const previous = rows[rows.length - 1];
@@ -5609,7 +5520,7 @@ function formatOpeningHoursRows(hours) {
5609
5520
  const row = {
5610
5521
  kind: day.kind,
5611
5522
  weekdays,
5612
- label: weekdayRangeLabel(weekdays),
5523
+ label: weekdayRangeLabel(weekdays, options.labels ?? "full"),
5613
5524
  hours: text
5614
5525
  };
5615
5526
  return weekdays.length > 1 ? [...rows.slice(0, -1), row] : [...rows, row];
@@ -5664,6 +5575,13 @@ function isTipTapNode(value) {
5664
5575
  function isCanonicalRichTextDoc(value) {
5665
5576
  return isRecord$8(value) && hasOnlyKeys(value, rootKeys) && value.type === "doc" && Array.isArray(value.content) && isDenseArrayOf(value.content, isTipTapNode);
5666
5577
  }
5578
+ /** Whether a document contains non-whitespace text, including in nested nodes. */
5579
+ function richTextHasText(document) {
5580
+ return document.content.some(nodeHasText);
5581
+ }
5582
+ function nodeHasText(node) {
5583
+ return Boolean(node.text?.trim()) || (node.content ?? []).some(nodeHasText);
5584
+ }
5667
5585
 
5668
5586
  //#endregion
5669
5587
  //#region ../core/src/mailing-list-identifiers.ts
@@ -6086,17 +6004,12 @@ function parseBoundedText(value, path, options) {
6086
6004
  }
6087
6005
  return text.length <= options.maxLength ? ok(text) : err(invalid(path, `Footer engagement copy must be ${options.maxLength} characters or fewer.`));
6088
6006
  }
6089
- function parseTreatment(value, path) {
6090
- return value === "integrated" || value === "separate-row" ? ok(value) : err(invalid(path, "Footer engagement treatment is invalid."));
6091
- }
6092
6007
  function parseEngagementBase(value, base, path) {
6093
6008
  const heading = parseBoundedText(value.heading, `${path}.heading`, { maxLength: 80 });
6094
6009
  if (!heading.ok) return heading;
6095
6010
  if (heading.value === null) {
6096
6011
  return err(invalid(`${path}.heading`, "Footer engagement heading cannot be empty."));
6097
6012
  }
6098
- const treatment = parseTreatment(value.treatment, `${path}.treatment`);
6099
- if (!treatment.ok) return treatment;
6100
6013
  if (!isRecord$6(value.source)) {
6101
6014
  return err(invalid(`${path}.source`, "Footer engagement source is invalid."));
6102
6015
  }
@@ -6107,7 +6020,6 @@ function parseEngagementBase(value, base, path) {
6107
6020
  return intro.ok ? ok({
6108
6021
  ...base,
6109
6022
  heading: heading.value,
6110
- treatment: treatment.value,
6111
6023
  intro: intro.value
6112
6024
  }) : intro;
6113
6025
  }
@@ -6155,156 +6067,121 @@ function parseFooterEngagementSectionValue(value, sectionBase, path) {
6155
6067
  }
6156
6068
 
6157
6069
  //#endregion
6158
- //#region ../core/src/footer-navigation-layout.ts
6159
- const footerNavigationLayouts = ["stack", "inline-wrap"];
6160
- const defaultFooterNavigationLayout = "inline-wrap";
6161
- function normalizeFooterNavigationLayout(value) {
6162
- return value === "stack" ? "stack" : defaultFooterNavigationLayout;
6163
- }
6164
- /** The arrangement chooses presentation; the stored preference remains intact. */
6165
- function effectiveFooterNavigationLayout(arrangement, stored) {
6166
- return arrangement === "centred" ? "inline-wrap" : stored;
6167
- }
6168
-
6169
- //#endregion
6170
- //#region ../core/src/footer-arrangement.ts
6171
- const sectionKinds = [
6172
- "brand",
6173
- "supporting-text",
6174
- "social-links",
6175
- "navigation",
6176
- "business-address",
6177
- "contact",
6178
- "opening-hours",
6179
- "engagement",
6180
- "legal-navigation",
6181
- "legal"
6182
- ];
6183
- const centredSectionKinds = [
6184
- "brand",
6185
- "supporting-text",
6186
- "navigation",
6187
- "contact",
6188
- "business-address",
6189
- "opening-hours",
6190
- "social-links",
6191
- "engagement",
6192
- "legal-navigation",
6193
- "legal"
6194
- ];
6195
- /** Section ownership is exhaustive for both arrangements; content never changes placement. */
6196
- const rowSectionGroups = {
6197
- brand: "identity",
6198
- "supporting-text": "identity",
6199
- "social-links": "contact",
6200
- navigation: "main-navigation",
6201
- "business-address": "visit",
6202
- contact: "contact",
6203
- "opening-hours": "hours",
6204
- engagement: "engagement",
6205
- "legal-navigation": "legal-ending",
6206
- legal: "legal-ending"
6070
+ //#region ../core/src/footer-layout.ts
6071
+ /** The catalogue id and the rendered layout meet at this one total map. */
6072
+ const layouts = {
6073
+ "footer-beside-links": "beside-links",
6074
+ "footer-centred": "centred",
6075
+ "footer-compact": "compact"
6207
6076
  };
6208
- const centredSectionGroups = {
6209
- ...rowSectionGroups,
6210
- contact: "visit",
6211
- "opening-hours": "visit",
6212
- "social-links": "social"
6213
- };
6214
- const rowGroupOrder = [
6215
- "identity",
6216
- "main-navigation",
6217
- "visit",
6218
- "hours",
6219
- "contact",
6220
- "engagement",
6221
- "legal-ending"
6222
- ];
6223
- const centredGroupOrder = [
6224
- "identity",
6225
- "main-navigation",
6226
- "visit",
6227
- "social",
6228
- "engagement",
6229
- "legal-ending"
6230
- ];
6231
- const groupSlots = {
6232
- identity: "head",
6233
- "main-navigation": "navigation",
6234
- visit: "contact",
6235
- hours: "contact",
6236
- contact: "contact",
6237
- social: "social",
6238
- engagement: "panel",
6239
- "legal-ending": "base"
6240
- };
6241
- const regionSlots = {
6242
- "engagement-row": "panel",
6243
- main: "stack",
6244
- bottom: "base"
6245
- };
6246
- /** One policy owner for the served footer and its composition preview. */
6247
- function footerArrangementPolicy(input) {
6248
- const arrangement = input.arrangement ?? "simple";
6077
+ function footerLayoutForLookId(id) {
6078
+ return layouts[id];
6079
+ }
6080
+ function footerLookIdForLayout(layout) {
6081
+ return `footer-${layout}`;
6082
+ }
6083
+ function decideFooterPresentation(facts, selection) {
6084
+ const small = facts.navigationGroupCount <= 1 && !facts.hasNavigationLabels && !facts.hasAddress && !facts.hasHours && !facts.hasEngagement;
6085
+ const offered = withoutCompactForLabelledGroups(facts, selection.offered);
6086
+ const stored = offeredStoredLayout(selection.stored, offered);
6087
+ const effective = small && stored === "beside-links" ? "compact" : stored;
6088
+ const cycle = offered.filter((layout) => !(small && layout === "beside-links" && offered.includes("compact")));
6089
+ const restriction = cycle.length === selection.offered.length ? null : small ? "small-footer" : "labelled-link-groups";
6249
6090
  return {
6250
- arrangement,
6251
- navigationLayout: effectiveFooterNavigationLayout(arrangement, normalizeFooterNavigationLayout(input.storedNavigationLayout))
6252
- };
6253
- }
6254
- /** Address and hours pair up only in row arrangements, and only when both have content. */
6255
- function placementFor(kind, sections, policy) {
6256
- if (kind === "engagement" || kind === "main-navigation" && policy.navigationLayout === "inline-wrap") return "full-row";
6257
- const paired = policy.arrangement !== "centred" && (kind === "visit" || kind === "hours") && sections.some((section) => section.kind === "business-address") && sections.some((section) => section.kind === "opening-hours");
6258
- return paired ? "paired-column" : "column";
6259
- }
6260
- function buildGroups(sections, policy) {
6261
- const centred = policy.arrangement === "centred";
6262
- const order = centred ? centredGroupOrder : rowGroupOrder;
6263
- const owners = centred ? centredSectionGroups : rowSectionGroups;
6264
- const sectionOrder = centred ? centredSectionKinds : [...sectionKinds.filter((kind) => kind !== "social-links"), "social-links"];
6265
- return order.flatMap((kind) => {
6266
- const groupSections = sections.filter((section) => owners[section.kind] === kind).sort((left, right) => sectionOrder.indexOf(left.kind) - sectionOrder.indexOf(right.kind));
6267
- return groupSections.length === 0 ? [] : [{
6268
- kind,
6269
- placement: placementFor(kind, sections, policy),
6270
- sections: groupSections,
6271
- ...centred ? { slot: groupSlots[kind] } : {}
6272
- }];
6273
- });
6091
+ effective,
6092
+ cycle,
6093
+ current: cycle.includes(effective) ? effective : stored,
6094
+ restriction
6095
+ };
6096
+ }
6097
+ /** A stored layout that's no longer offered draws the first offered one instead. */
6098
+ function offeredStoredLayout(stored, offered) {
6099
+ return stored === "compact" && !offered.includes("compact") ? offered[0] ?? stored : stored;
6100
+ }
6101
+ /** Compact strip flattens labelled link groups into one unlabelled row, so it
6102
+ * isn't offered for them unless it's the style's only layout. */
6103
+ function withoutCompactForLabelledGroups(facts, offered) {
6104
+ if (facts.navigationGroupCount < 2 || !facts.hasNavigationLabels) return offered;
6105
+ const rest = offered.filter((layout) => layout !== "compact");
6106
+ return rest.length > 0 ? rest : offered;
6274
6107
  }
6275
6108
  function footerMembershipKey(sections) {
6276
- const tokens = sections.map((section) => ({
6277
- rank: sectionKinds.indexOf(section.kind),
6278
- value: section.kind === "engagement" ? `engagement:${section.treatment}` : section.kind
6279
- })).sort((left, right) => left.rank - right.rank);
6280
- return tokens.map(({ value }) => value).join("+") || "empty";
6281
- }
6282
- function renderRegion(kind, groups, policy) {
6283
- if (groups.length === 0) return [];
6284
- const columns = kind !== "main" || policy.arrangement === "centred" ? 1 : Math.max(1, Math.min(groups.filter((group) => group.placement !== "full-row").length, 5));
6285
- return [{
6286
- kind,
6287
- columns,
6288
- groups,
6289
- ...policy.arrangement === "centred" ? { slot: regionSlots[kind] } : {}
6290
- }];
6109
+ return sections.map(({ kind }) => kind).sort().join("+") || "empty";
6291
6110
  }
6292
- function planFooterArrangement(renderableSections, policy) {
6293
- const selectedSections = renderableSections.map(({ section }) => section);
6294
- const groups = buildGroups(selectedSections, policy);
6295
- const separateEngagement = groups.filter((group) => group.kind === "engagement" && group.sections.some((section) => section.kind === "engagement" && section.treatment === "separate-row"));
6296
- const layoutGroups = groups.filter((group) => !separateEngagement.includes(group));
6297
- const legalGroups = layoutGroups.filter((group) => group.kind === "legal-ending");
6298
- const unsortedMainGroups = layoutGroups.filter((group) => !legalGroups.includes(group));
6299
- const mainGroups = policy.arrangement === "centred" ? unsortedMainGroups : [...unsortedMainGroups.filter((group) => group.placement !== "full-row"), ...unsortedMainGroups.filter((group) => group.placement === "full-row")];
6111
+ /**
6112
+ * Areas own content; the layout's CSS owns geometry. Each layout lists its areas
6113
+ * top to bottom, as the agreed mockups draw them:
6114
+ * - beside-links: the signup band on top, then the name beside the links, the
6115
+ * details strip and the base.
6116
+ * - centred: everything stacked down the middle, the signup as a tier under it,
6117
+ * then the details strip and the base.
6118
+ * - compact: one main area (its CSS puts the details and signup on a second
6119
+ * row), then the base. There's no band or strip.
6120
+ * Details go in a strip only when there's an address or opening hours to show;
6121
+ * a lone phone or email stays with the name (beside-links) or on the inline line.
6122
+ */
6123
+ function planFooterLayout(renderable, input) {
6124
+ const sections = renderable.map(({ section }) => section).filter((section) => !(input.suppressSignup === true && section.kind === "engagement"));
6125
+ const pick = (kinds) => kinds.flatMap((kind) => sections.filter((section) => section.kind === kind));
6126
+ const group = (kind, slot, kinds) => {
6127
+ const members = pick(kinds);
6128
+ return members.length === 0 ? [] : [{
6129
+ kind,
6130
+ ...slot ? { slot } : {},
6131
+ sections: members
6132
+ }];
6133
+ };
6134
+ const region = (slot, groups) => groups.length === 0 ? [] : [{
6135
+ slot,
6136
+ groups
6137
+ }];
6138
+ const hasStrip = input.layout !== "compact" && pick(["business-address", "opening-hours"]).length > 0;
6139
+ const details = group("visit", "details", [
6140
+ "business-address",
6141
+ "opening-hours",
6142
+ "contact"
6143
+ ]);
6144
+ const links = group("main-navigation", "links", ["navigation"]);
6145
+ const signup = group("engagement", "signup", ["engagement"]);
6146
+ const social = group("social", "social", ["social-links"]);
6147
+ const base = region("base", group("legal-ending", undefined, ["legal-navigation", "legal"]));
6148
+ const strip = hasStrip ? region("strip", details) : [];
6149
+ const regions = (() => {
6150
+ switch (input.layout) {
6151
+ case "beside-links": return [
6152
+ ...region("band", signup),
6153
+ ...region("main", [...group("identity", "brand", [
6154
+ "brand",
6155
+ "supporting-text",
6156
+ ...hasStrip ? [] : ["contact"],
6157
+ "social-links"
6158
+ ]), ...links]),
6159
+ ...strip,
6160
+ ...base
6161
+ ];
6162
+ case "centred": return [
6163
+ ...region("main", [
6164
+ ...group("identity", "brand", ["brand", "supporting-text"]),
6165
+ ...links,
6166
+ ...hasStrip ? [] : details,
6167
+ ...social
6168
+ ]),
6169
+ ...region("band", signup),
6170
+ ...strip,
6171
+ ...base
6172
+ ];
6173
+ case "compact": return [...region("main", [
6174
+ ...group("identity", "brand", ["brand", "supporting-text"]),
6175
+ ...links,
6176
+ ...social,
6177
+ ...details,
6178
+ ...signup
6179
+ ]), ...base];
6180
+ }
6181
+ })();
6300
6182
  return {
6301
- membershipKey: footerMembershipKey(selectedSections),
6302
- regions: [
6303
- ...renderRegion("engagement-row", separateEngagement, policy),
6304
- ...renderRegion("main", mainGroups, policy),
6305
- ...renderRegion("bottom", legalGroups, policy)
6306
- ],
6307
- mobileGroups: separateEngagement.length === 0 ? groups : [...separateEngagement, ...layoutGroups]
6183
+ membershipKey: footerMembershipKey(sections),
6184
+ regions
6308
6185
  };
6309
6186
  }
6310
6187
 
@@ -6647,10 +6524,21 @@ function repairTargetFor(section) {
6647
6524
  };
6648
6525
  }
6649
6526
  }
6527
+ /**
6528
+ * The brand as the footer draws it. The owner picks the name, the logo, or
6529
+ * both; with no logo uploaded (or a stored brand that hid both, which is no
6530
+ * longer offered) the name shows.
6531
+ */
6532
+ function brandAsShown(section, hasLogo) {
6533
+ return {
6534
+ ...section,
6535
+ showTitle: section.showTitle || !(section.showLogo && hasLogo)
6536
+ };
6537
+ }
6650
6538
  function resolveFooterSections(composition, availability$1) {
6651
6539
  return composition.sections.filter((section) => section.selected).map((section) => isSectionRenderable(section, availability$1) ? {
6652
6540
  kind: "renderable",
6653
- section
6541
+ section: section.kind === "brand" ? brandAsShown(section, availability$1.hasLogo) : section
6654
6542
  } : {
6655
6543
  kind: "missing-source",
6656
6544
  section,
@@ -6659,7 +6547,7 @@ function resolveFooterSections(composition, availability$1) {
6659
6547
  }
6660
6548
  function isSectionRenderable(section, availability$1) {
6661
6549
  switch (section.kind) {
6662
- case "brand": return section.showLogo && availability$1.hasLogo || section.showTitle;
6550
+ case "brand": return true;
6663
6551
  case "navigation": return availability$1.hasMainNavigation;
6664
6552
  case "legal-navigation": return availability$1.hasLegalPolicyNavigation;
6665
6553
  case "business-address": return availability$1.hasBusinessAddress;
@@ -8822,6 +8710,12 @@ const VERTICAL_DEFINITIONS = [
8822
8710
  id: "venue_event_space",
8823
8711
  label: "Venue or event space",
8824
8712
  description: "Room, resource, or access bookings. Depends on the future capacity-booking domain."
8713
+ },
8714
+ {
8715
+ id: "something_else",
8716
+ label: "Something else",
8717
+ description: "Anything people book with you that doesn't fit the other choices.",
8718
+ describesBusiness: false
8825
8719
  }
8826
8720
  ];
8827
8721
  const VERTICAL_IDS = VERTICAL_DEFINITIONS.map(({ id }) => id);
@@ -8906,7 +8800,12 @@ const VERTICAL_BOOKING_PRESETS = [
8906
8800
  verticalBookingPreset("community_wellbeing.courses", "community_wellbeing", "course", "Course", "Courses", "Fixed-schedule courses, study groups, or multi-session programmes."),
8907
8801
  verticalBookingPreset("community_wellbeing.appointments", "community_wellbeing", "appointment", "Appointment", "Appointments", "One-to-one appointments, consultations, or support sessions."),
8908
8802
  verticalBookingPreset("community_wellbeing.retreats", "community_wellbeing", "retreat", "Retreat", "Retreats", "Multi-day or residential retreats."),
8909
- verticalBookingPreset("venue_event_space.resource_hire", "venue_event_space", "appointment", "Hire slot", "Hire slots", "Future room, venue, and resource hire bookings.", "future")
8803
+ verticalBookingPreset("venue_event_space.resource_hire", "venue_event_space", "appointment", "Hire slot", "Hire slots", "Future room, venue, and resource hire bookings.", "future"),
8804
+ verticalBookingPreset("something_else.classes", "something_else", "class", "Class", "Classes", "Regular sessions that run every week, like an evening group or a Saturday morning drop-in."),
8805
+ verticalBookingPreset("something_else.courses", "something_else", "course", "Course", "Courses", "A set of sessions that people book together, like a six-week beginners' course."),
8806
+ verticalBookingPreset("something_else.workshops", "something_else", "workshop", "Workshop", "Workshops", "One-off sessions, like a taster evening or a hands-on day."),
8807
+ verticalBookingPreset("something_else.retreats", "something_else", "retreat", "Retreat", "Retreats", "A few days away together, like a weekend course with meals and somewhere to stay."),
8808
+ verticalBookingPreset("something_else.appointments", "something_else", "appointment", "Appointment", "Appointments", "One-to-one time that people book from your availability, like a private lesson.")
8910
8809
  ];
8911
8810
 
8912
8811
  //#endregion
@@ -8927,7 +8826,8 @@ const DEFAULT_ONBOARDING_PRESET_ID_BY_VERTICAL = {
8927
8826
  voice_singing: null,
8928
8827
  performing_arts_school: null,
8929
8828
  community_wellbeing: null,
8930
- venue_event_space: null
8829
+ venue_event_space: null,
8830
+ something_else: null
8931
8831
  };
8932
8832
  const VERTICAL_ID_SET = new Set(VERTICAL_DEFINITIONS.map(({ id }) => id));
8933
8833
  const VERTICAL_PRESET_ID_SET = new Set(VERTICAL_BOOKING_PRESETS.map((presetDefinition) => presetDefinition.id));
@@ -8944,6 +8844,16 @@ function getVerticalDefinition(verticalId) {
8944
8844
  }
8945
8845
  return definition;
8946
8846
  }
8847
+ /**
8848
+ * How to name the business in prompts and sentences ("a dance school"). Null
8849
+ * when there's no business type, or when the owner picked a catch-all such as
8850
+ * "Something else", whose label describes the choice rather than the business.
8851
+ */
8852
+ function getVerticalBusinessKindLabel(verticalId) {
8853
+ if (!verticalId) return null;
8854
+ const definition = getVerticalDefinition(verticalId);
8855
+ return definition.describesBusiness === false ? null : definition.label;
8856
+ }
8947
8857
  function getVerticalPresetDefinition(presetId) {
8948
8858
  const definition = VERTICAL_BOOKING_PRESETS.find((presetDefinition) => presetDefinition.id === presetId);
8949
8859
  if (definition === undefined) {
@@ -9429,6 +9339,45 @@ function eventCatalogueChoices(catalogue) {
9429
9339
  ...EVENT_PRESET_VOCABULARY.event
9430
9340
  }];
9431
9341
  }
9342
+ /**
9343
+ * Whether a site can have courses but hasn't them on, and what ticking them in
9344
+ * Booking settings would change. A site with a business type chooses from that
9345
+ * type's list; a site without one chooses from the plain list of event types.
9346
+ *
9347
+ * A business type offering only appointments reads the plain list but shows no
9348
+ * tick-boxes for it, and its own Courses tick would replace that whole list. So
9349
+ * courses aren't offered there: turning on one type shouldn't take away others.
9350
+ */
9351
+ function planTurningOnCourses(settings) {
9352
+ const catalogue = resolveEventCatalogue(settings);
9353
+ if (catalogue.entries.some(({ preset }) => preset === "course")) return { kind: "already_on" };
9354
+ const vertical = resolveSiteVerticalBookingConfig(settings.verticalConfig);
9355
+ if (!vertical.config.verticalId) return {
9356
+ kind: "turn_on",
9357
+ choice: {
9358
+ preset: "course",
9359
+ verticalPresetId: null,
9360
+ ...EVENT_PRESET_VOCABULARY.course
9361
+ },
9362
+ settings: { eventTypePresets: [...settings.eventTypePresets, "course"] }
9363
+ };
9364
+ if (catalogue.source !== "business_profile") return { kind: "not_offered" };
9365
+ const course = getVerticalPresetSelectionOptions(settings.verticalConfig).filter(({ checked }) => !checked).map(({ preset }) => preset).filter(isEventSeriesVerticalPresetDefinition).find((preset) => eventPresetForVerticalPreset(preset) === "course");
9366
+ if (course === undefined) return { kind: "not_offered" };
9367
+ const selection = setVerticalPresetsSelected(settings.verticalConfig, [...vertical.config.selectedPresetIds, course.id]);
9368
+ if (!selection.ok) return { kind: "not_offered" };
9369
+ return {
9370
+ kind: "turn_on",
9371
+ choice: {
9372
+ preset: "course",
9373
+ verticalPresetId: course.id,
9374
+ label: course.label,
9375
+ pluralLabel: course.pluralLabel,
9376
+ description: course.description
9377
+ },
9378
+ settings: { verticalConfig: selection.config }
9379
+ };
9380
+ }
9432
9381
 
9433
9382
  //#endregion
9434
9383
  //#region ../core/src/business-vocabulary.ts
@@ -9436,8 +9385,9 @@ const person = (singular, plural) => ({
9436
9385
  singular,
9437
9386
  plural
9438
9387
  });
9388
+ /** A site with no business type set doesn't say who leads its sessions. */
9439
9389
  const GENERIC_BUSINESS_VOCABULARY = {
9440
- person: person("practitioner", "practitioners"),
9390
+ person: null,
9441
9391
  offeringsExample: "weekly classes, one-to-one sessions and the occasional workshop"
9442
9392
  };
9443
9393
  const BUSINESS_VOCABULARY_BY_VERTICAL = {
@@ -9504,12 +9454,61 @@ const BUSINESS_VOCABULARY_BY_VERTICAL = {
9504
9454
  venue_event_space: {
9505
9455
  person: null,
9506
9456
  offeringsExample: "room hire, community events and regular classes run by local teachers"
9457
+ },
9458
+ something_else: {
9459
+ person: person("teacher", "teachers"),
9460
+ offeringsExample: "weekly evening classes, a six-week beginners' course and the odd one-to-one session"
9507
9461
  }
9508
9462
  };
9509
- /** A site with no business type set gets the generic vocabulary. */
9463
+ /** A site with no business type set gets the generic vocabulary, which names nobody. */
9510
9464
  function resolveBusinessVocabulary(verticalId) {
9511
9465
  return verticalId ? BUSINESS_VOCABULARY_BY_VERTICAL[verticalId] : GENERIC_BUSINESS_VOCABULARY;
9512
9466
  }
9467
+ /** What the dashboard calls the person where the business type names nobody. */
9468
+ const TEAM_MEMBER_NOUN = person("team member", "team members");
9469
+ const indefiniteArticle = (word) => /^[aeiou]/i.test(word) ? "an" : "a";
9470
+ function businessPersonPhrases(noun) {
9471
+ const withArticle = `${indefiniteArticle(noun.singular)} ${noun.singular}`;
9472
+ return {
9473
+ singular: noun.singular,
9474
+ plural: noun.plural,
9475
+ singularLabel: capitalize(noun.singular),
9476
+ pluralLabel: capitalize(noun.plural),
9477
+ withArticle,
9478
+ chooseOne: `Choose ${withArticle}`,
9479
+ chooseAnother: `Choose another ${noun.singular}`,
9480
+ anyOne: `Any ${noun.singular}`,
9481
+ all: `All ${noun.plural}`
9482
+ };
9483
+ }
9484
+ /**
9485
+ * Dashboard copy always names someone: the business's word, or "team member"
9486
+ * where the business type names nobody (a venue, or no type set).
9487
+ */
9488
+ function dashboardPersonPhrases(noun) {
9489
+ return businessPersonPhrases(noun ?? TEAM_MEMBER_NOUN);
9490
+ }
9491
+ function clientPersonPhrases(noun) {
9492
+ if (noun == null) {
9493
+ return {
9494
+ label: "Who with",
9495
+ chooseAnother: "Choose someone else",
9496
+ anyone: "Anyone who's free",
9497
+ chooseYours: "Choose who you'd like to see",
9498
+ withName: (name) => `With ${name}`,
9499
+ listLabel: () => "With"
9500
+ };
9501
+ }
9502
+ const singularLabel = capitalize(noun.singular);
9503
+ return {
9504
+ label: singularLabel,
9505
+ chooseAnother: `Choose another ${noun.singular}`,
9506
+ anyone: `Any ${noun.singular}`,
9507
+ chooseYours: `Choose your ${noun.singular}`,
9508
+ withName: (name) => `${singularLabel}: ${name}`,
9509
+ listLabel: (count) => count === 1 ? singularLabel : capitalize(noun.plural)
9510
+ };
9511
+ }
9513
9512
  /** "Our trainers", or "The team" where nobody leads sessions or the type is unknown. */
9514
9513
  function businessTeamPageTitle(verticalId) {
9515
9514
  const people = verticalId ? BUSINESS_VOCABULARY_BY_VERTICAL[verticalId].person : null;
@@ -9578,7 +9577,12 @@ const TITLE_EXAMPLE_BY_PRESET = {
9578
9577
  "community_wellbeing.workshops": "e.g., Community Wellbeing Workshop, Grief Support Day",
9579
9578
  "community_wellbeing.courses": "e.g., Mindfulness Course, Peer Support Programme",
9580
9579
  "community_wellbeing.appointments": "e.g., Support Session, Initial Consultation",
9581
- "community_wellbeing.retreats": "e.g., Community Retreat Weekend, Rest and Reflect Retreat"
9580
+ "community_wellbeing.retreats": "e.g., Community Retreat Weekend, Rest and Reflect Retreat",
9581
+ "something_else.classes": "e.g., Tuesday Evening Beginners, Saturday Morning Group",
9582
+ "something_else.courses": "e.g., Six-Week Beginners' Course, Next Steps Course",
9583
+ "something_else.workshops": "e.g., Saturday Taster Session, Hands-On Day",
9584
+ "something_else.retreats": "e.g., Weekend Away, Summer Residential",
9585
+ "something_else.appointments": "e.g., Private Lesson, One-to-One Session"
9582
9586
  };
9583
9587
  function verticalPresetTitleExample(presetId) {
9584
9588
  return TITLE_EXAMPLE_BY_PRESET[presetId] ?? null;
@@ -10539,6 +10543,16 @@ const EMAIL_DEFINITIONS = {
10539
10543
  perEvent: false,
10540
10544
  templateStorage: true
10541
10545
  },
10546
+ membership_ended: {
10547
+ wording: "editable",
10548
+ perEvent: false,
10549
+ templateStorage: true
10550
+ },
10551
+ membership_dates_changed: {
10552
+ wording: "editable",
10553
+ perEvent: false,
10554
+ templateStorage: true
10555
+ },
10542
10556
  membership_payment_refund: {
10543
10557
  wording: "editable",
10544
10558
  perEvent: false,
@@ -10805,6 +10819,11 @@ const EMAIL_DEFINITIONS = {
10805
10819
  perEvent: false,
10806
10820
  templateStorage: false
10807
10821
  },
10822
+ mailing_list_signup_failure: {
10823
+ wording: "fixed",
10824
+ perEvent: false,
10825
+ templateStorage: false
10826
+ },
10808
10827
  form_owner_notification: {
10809
10828
  wording: "fixed",
10810
10829
  perEvent: false,
@@ -10845,6 +10864,11 @@ const EMAIL_DEFINITIONS = {
10845
10864
  perEvent: false,
10846
10865
  templateStorage: false
10847
10866
  },
10867
+ auth_new_device: {
10868
+ wording: "fixed",
10869
+ perEvent: false,
10870
+ templateStorage: false
10871
+ },
10848
10872
  auth_confirmation: {
10849
10873
  wording: "fixed",
10850
10874
  perEvent: false,
@@ -11126,7 +11150,7 @@ function decideOwnerAppointmentTime(proposed, rules, nowMs) {
11126
11150
  const occupiedStart = start - rules.service.prepMinutes * 6e4;
11127
11151
  const occupiedEnd = end + rules.service.cleanupMinutes * 6e4;
11128
11152
  const breaks = {
11129
- working_hours: !isOwnerWorkingTime(start, end, rules),
11153
+ working_hours: !fitsWorkingTimes(proposed, rules),
11130
11154
  minimum_notice: start < nowMs + rules.bookingNotice.minLeadMinutes * 6e4,
11131
11155
  booking_window: rules.bookingNotice.maxBookingNoticeMinutes !== null && start > nowMs + rules.bookingNotice.maxBookingNoticeMinutes * 6e4,
11132
11156
  buffer: rules.occupiedWindows.some((window) => overlaps$1(window, occupiedStart, occupiedEnd)),
@@ -11138,8 +11162,33 @@ function decideOwnerAppointmentTime(proposed, rules, nowMs) {
11138
11162
  ruleBreaks: Object.keys(breaks).filter((key) => breaks[key])
11139
11163
  };
11140
11164
  }
11141
- function isOwnerWorkingTime(start, end, rules) {
11142
- return Boolean(rules.workingStarts?.some((value) => Date.parse(value) === start)) || rules.workingWindows.some((window) => start >= Date.parse(window.startAt) && end <= Date.parse(window.endAt));
11165
+ function regularRefusalFromBreaks(breaks) {
11166
+ if (breaks.includes("closure")) return "closure";
11167
+ if (breaks.includes("working_hours")) return "outside_hours";
11168
+ return breaks.includes("buffer") ? "too_close" : null;
11169
+ }
11170
+ /**
11171
+ * A regular time follows the owner's rule for a typed time, without the grid of
11172
+ * advertised starts. Nobody ticks "Book this time anyway" for each date, so what
11173
+ * the owner could confirm on a one-off refuses here instead. Booking notice is
11174
+ * waived because the owner has agreed these dates with the client.
11175
+ */
11176
+ function decideRegularAppointmentTime(proposed, rules, nowMs) {
11177
+ const decision = decideOwnerAppointmentTime(proposed, rules, nowMs);
11178
+ if (decision.kind === "allowed") return regularRefusalFromBreaks(decision.ruleBreaks);
11179
+ switch (decision.reason) {
11180
+ case "reservation_overlap": return "held";
11181
+ case "appointment_overlap": return "booked";
11182
+ case "invalid_time":
11183
+ case "nonexistent_time":
11184
+ case "past": return "other";
11185
+ }
11186
+ }
11187
+ /** Whether a time starts on a fixed start, or sits wholly inside a working window. */
11188
+ function fitsWorkingTimes(proposed, times) {
11189
+ const start = Date.parse(proposed.startAt);
11190
+ const end = Date.parse(proposed.endAt);
11191
+ return Boolean(times.workingStarts?.some((value) => Date.parse(value) === start)) || times.workingWindows.some((window) => start >= Date.parse(window.startAt) && end <= Date.parse(window.endAt));
11143
11192
  }
11144
11193
  const OWNER_APPOINTMENT_RULE_COPY = {
11145
11194
  working_hours: "Outside working hours",
@@ -11154,7 +11203,7 @@ const OWNER_APPOINTMENT_REFUSAL_COPY = {
11154
11203
  nonexistent_time: "The clocks go forward on this date, so that time is skipped. Choose another time.",
11155
11204
  invalid_time: "Choose a valid time for this service.",
11156
11205
  past: "That time has already passed.",
11157
- appointment_overlap: "This practitioner already has an appointment at this time.",
11206
+ appointment_overlap: "That time’s already booked.",
11158
11207
  reservation_overlap: "This time is held for another client’s regular session."
11159
11208
  };
11160
11209
 
@@ -11199,4 +11248,4 @@ function isEventOccurrenceRouteSegment(segment) {
11199
11248
  }
11200
11249
 
11201
11250
  //#endregion
11202
- export { parseWeeklyOpeningHours as $, unsafeAsUploadSessionId as $n, businessCancellationRefusalCodes as $t, resolveWholeSeriesRunLifecycle as A, unsafeAsDemoCapability as An, getLocalScheduleDate as At, parseConfiguredMailingListProvider as B, unsafeAsBookingSessionId as Bn, toUtcIsoDateTimeString as Bt, isPublicReadEndpoint as C, unsafeAsNonNegativeCents as Cn, resolveBookingDisplayContext as Ct, nextLiveRunSessionStartMs as D, assertNever as Dn, formatLocalScheduleDate as Dt, firstLiveRunSessionStartMs as E, parseCurrencyCode as En, compareLocalScheduleDates as Et, parseMailingListBlockId as F, parseMembershipId as Fn, resolveBookingBusinessTimeZone as Ft, parseFooterCompositionV1 as G, unsafeAsMediaAssetId as Gn, isSettleableOrderInstalmentPlanStatus as Gt, DEFAULT_MAILING_LIST_PRIVACY_NOTE as H, unsafeAsDeclaredMimeType as Hn, validateBookingPaymentOptionKinds as Ht, parseMailingListContentVersionId as I, unsafeAsEntitlementId as In, resolveBookingTimeZoneId as It, DEFAULT_MAILING_LIST_TARGETING as J, unsafeAsPositiveSeconds as Jn, getBookingInstalmentDepositRefundability as Jt, footerNavigationLayouts as K, unsafeAsOriginalFilename as Kn, addIntervalPreservingMonthAnchor as Kt, parseMailingListSignedSourceToken as L, unsafeAsPassId as Ln, toBookingTimeZone as Lt, exposeSecret as M, unsafeAsStaffMemberId as Mn, localScheduleTimePattern as Mt, parseManagementKey as N, parseCustomerId as Nn, parseBookingLocalDate as Nt, orderedLiveRunSessions as O, formatDurationUnitLabel as On, formatLocalScheduleTime as Ot, slugify as P, parseSiteTermsVersionId as Pn, parseLocalScheduleTime as Pt, parsePublicContactDetails as Q, unsafeAsStoragePath as Qn, splitAmountWithRemainderInFirst as Qt, parseMailingListRuntimeContext as R, parseDatedOfferingCapacityHoldAuditRef as Rn, parseBookingTimeZone as Rt, getPublicReadCachePolicy as S, toNonNegativeCents as Sn, inferSiteDateLocale as St, CANCELLED_SESSION_STATUS as T, formatCurrencyAmount as Tn, buildBookingUtcDateWindow as Tt, DEFAULT_MAILING_LIST_SUCCESS_MESSAGE as U, unsafeAsDetectedMimeType as Un, isLiveOrderInstalmentPlanStatus as Ut, parseMailingListGlobalForm as V, parseMediaAssetId as Vn, BOOKING_COURSE_INSTALMENT_DEADLINES as Vt, parseMailingListProviderScope as W, unsafeAsFileChecksumSha256 as Wn, isSettleableFlexibleBalanceContractStatus as Wt, isCanonicalRichTextDoc as X, unsafeAsSiteScopedStoragePath as Xn, getBookingInstalmentProtectedDepositAmountCents as Xt, planMailingListChoicePresentation as Y, unsafeAsSafeDownloadFilename as Yn, getBookingInstalmentPlanIntervalCount as Yt, formatOpeningHoursRows as Z, unsafeAsStorageBucketName as Zn, omitZeroAmountFutureRows as Zt, ORDINARY_EVENT_PRESET_VALUES as _, mapReadonlyNonEmptyArray as _n, unsafeAsPricingOptionId as _r, formatDateRange as _t, authoredValuesEqual as a, EVENT_PRESET_VOCABULARY as an, parseApiKeyId as ar, locationMapLinks as at, PUBLIC_AVAILABILITY_FRESHNESS_SECONDS as b, parsePositiveCents as bn, blockInteractionContextSchema as br, formatTime as bt, resolveEventCatalogue as c, isPublicEventPricingOptionDisplayable as cn, unsafeAsSiteId as cr, parseLocationValue as ct, canonicalizeConfiguredBookingVerticalConfig as d, publicEventPricingOptions as dn, parseRetiredCourseId as dr, toLocationCoordinates as dt, scheduleBookingReasonCodes as en, unsafeAsProductId as er, assertAllowedPublicUrl as et, parseVerticalId as f, publicEventPricingType as fn, unsafeAsEventCategoryId as fr, isPresent as ft, EVENT_PRESET_VALUES as g, mapNonEmptyArray as gn, unsafeAsOccurrenceId as gr, formatDate as gt, DEFAULT_EVENT_TYPE_PRESETS as h, fromArray as hn, unsafeAsEventSeriesId as hr, selectCategoryView as ht, isRecord as i, parsePageSurfaceSubject as in, unsafeAsSiteFontId as ir, stableJsonStringify as it, createSecret as j, unsafeAsAppointmentResourceId as jn, getLocalScheduleTime as jt, resolveWholeSeriesBookingPhase as k, unsafeAsBookingRequirementId as kn, getBookingLocalDateKey as kt, NAVIGATION_LOCATIONS as l, publicEventPricingCurrency as ln, unsafeAsUserId as lr, projectPublicLocation as lt, resolveSiteVerticalBookingConfig as m, resolvePricingOptionsPriceDisplay as mn, unsafeAsEventOfferingId as mr, mapDrawingSchema as mt, OFFLINE_PAYMENT_METHODS as n, resolveFlexibleBalanceInitialPaymentCents as nn, parseEditorSessionGeneration as nr, SENSITIVE_COLLECTION_MODES as nt, creditProductUnitNoun as o, formatBookingPriceDisplay as on, parseSiteId as or, locationValueSchema as ot, parseVerticalPresetId as p, resolveExactOrFreePriceDisplay as pn, unsafeAsEventInstanceId as pr, trimmedStringOrNull as pt, parseMailingListPlacementTargeting as q, unsafeAsPositiveByteCount as qn, clampConfiguredAmount as qt, committedWriteProofSchema as r, deriveTotalTicketQuantity as rn, parsePageId as rr, decideLocationSave as rt, formatCreditProductUnits as s, formatEventPricing as sn, parseUserId as sr, normalizeLocationAddressText as st, isEventOccurrenceRouteSegment as t, resolveFlexibleBalanceDueAt as tn, unsafeAsCheckoutLineId as tr, SENSITIVE_COLLECTION_CONFIRMATION_VERSION as tt, areConfiguredBookingVerticalConfigsEqual as u, publicEventPricingDisplay as un, parseEventSeriesId as ur, publicLocationSchema as ut, SURFACE_EVENT_PRESET_VALUES as v, isNonNegativeWholeCents as vn, err as vr, formatDateTime as vt, publicReadFreshnessSeconds as w, unsafeAsPositiveCents as wn, toScheduledBookingDateTime as wt, PUBLIC_CONTENT_FRESHNESS_SECONDS as x, toCents as xn, formatTimeRange as xt, WHOLE_SERIES_EVENT_PRESET_VALUES as y, parseNonNegativeCents as yn, ok as yr, formatDateTimeRange as yt, assessMailingListTargeting as z, parseDatedOfferingCapacityHoldId as zn, parseUtcIsoDateTimeString as zt };
11251
+ export { formatOpeningHoursRows as $, unsafeAsStoragePath as $n, businessCancellationRefusalCodes as $t, resolveWholeSeriesBookingPhase as A, unsafeAsBookingRequirementId as An, formatLocalScheduleDate as At, assessMailingListTargeting as B, parseDatedOfferingCapacityHoldId as Bn, toBookingTimeZone as Bt, getPublicReadCachePolicy as C, toNonNegativeCents as Cn, blockInteractionContextSchema as Cr, formatTimeRange as Ct, firstLiveRunSessionStartMs as D, parseCurrencyCode as Dn, buildBookingUtcDateWindow as Dt, CANCELLED_SESSION_STATUS as E, formatCurrencyAmount as En, toScheduledBookingDateTime as Et, slugify as F, parseSiteTermsVersionId as Fn, localScheduleTimePattern as Ft, parseMailingListProviderScope as G, unsafeAsFileChecksumSha256 as Gn, validateBookingPaymentOptionKinds as Gt, parseMailingListGlobalForm as H, parseMediaAssetId as Hn, parseUtcIsoDateTimeString as Ht, parseMailingListBlockId as I, parseMembershipId as In, parseBookingLocalDate as It, parseMailingListPlacementTargeting as J, unsafeAsPositiveByteCount as Jn, clampConfiguredAmount as Jt, parseFooterCompositionV1 as K, unsafeAsMediaAssetId as Kn, isLiveOrderInstalmentPlanStatus as Kt, parseMailingListContentVersionId as L, unsafeAsEntitlementId as Ln, parseLocalScheduleTime as Lt, createSecret as M, unsafeAsAppointmentResourceId as Mn, getBookingLocalDateKey as Mt, exposeSecret as N, unsafeAsStaffMemberId as Nn, getLocalScheduleDate as Nt, nextLiveRunSessionStartMs as O, assertNever as On, addLocalScheduleDays as Ot, parseManagementKey as P, parseCustomerId as Pn, getLocalScheduleTime as Pt, richTextHasText as Q, unsafeAsStorageBucketName as Qn, splitAmountWithRemainderInFirst as Qt, parseMailingListSignedSourceToken as R, unsafeAsPassId as Rn, resolveBookingBusinessTimeZone as Rt, PUBLIC_CONTENT_FRESHNESS_SECONDS as S, toCents as Sn, ok as Sr, formatTime as St, publicReadFreshnessSeconds as T, unsafeAsPositiveCents as Tn, resolveBookingDisplayContext as Tt, DEFAULT_MAILING_LIST_PRIVACY_NOTE as U, unsafeAsDeclaredMimeType as Un, toUtcIsoDateTimeString as Ut, parseConfiguredMailingListProvider as V, unsafeAsBookingSessionId as Vn, parseBookingTimeZone as Vt, DEFAULT_MAILING_LIST_SUCCESS_MESSAGE as W, unsafeAsDetectedMimeType as Wn, BOOKING_COURSE_INSTALMENT_DEADLINES as Wt, planMailingListChoicePresentation as X, unsafeAsSafeDownloadFilename as Xn, getBookingInstalmentPlanIntervalCount as Xt, DEFAULT_MAILING_LIST_TARGETING as Y, unsafeAsPositiveSeconds as Yn, getBookingInstalmentDepositRefundability as Yt, isCanonicalRichTextDoc as Z, unsafeAsSiteScopedStoragePath as Zn, omitZeroAmountFutureRows as Zt, EVENT_PRESET_VALUES as _, mapNonEmptyArray as _n, unsafeAsEventOfferingId as _r, selectCategoryView as _t, authoredValuesEqual as a, EVENT_PRESET_VOCABULARY as an, parseEditorSessionGeneration as ar, decideLocationSave as at, WHOLE_SERIES_EVENT_PRESET_VALUES as b, parseNonNegativeCents as bn, unsafeAsPricingOptionId as br, formatDateTime as bt, planTurningOnCourses as c, isPublicEventPricingOptionDisplayable as cn, parseApiKeyId as cr, locationValueSchema as ct, areConfiguredBookingVerticalConfigsEqual as d, publicEventPricingOptions as dn, unsafeAsSiteId as dr, projectPublicLocation as dt, scheduleBookingReasonCodes as en, unsafeAsUploadSessionId as er, parsePublicContactDetails as et, canonicalizeConfiguredBookingVerticalConfig as f, publicEventPricingStrategy as fn, unsafeAsUserId as fr, publicLocationSchema as ft, DEFAULT_EVENT_TYPE_PRESETS as g, fromArray as gn, unsafeAsEventInstanceId as gr, mapDrawingSchema as gt, resolveSiteVerticalBookingConfig as h, resolvePricingOptionsPriceDisplay as hn, unsafeAsEventCategoryId as hr, trimmedStringOrNull as ht, isRecord as i, parsePageSurfaceSubject as in, unsafeAsOrderPaymentPlanId as ir, SENSITIVE_COLLECTION_MODES as it, resolveWholeSeriesRunLifecycle as j, unsafeAsDemoCapability as jn, formatLocalScheduleTime as jt, orderedLiveRunSessions as k, formatDurationUnitLabel as kn, compareLocalScheduleDates as kt, resolveEventCatalogue as l, publicEventPricingCurrency as ln, parseSiteId as lr, normalizeLocationAddressText as lt, parseVerticalPresetId as m, resolveExactOrFreePriceDisplay as mn, parseRetiredCourseId as mr, isPresent as mt, OFFLINE_PAYMENT_METHODS as n, resolveFlexibleBalanceInitialPaymentCents as nn, unsafeAsCheckoutLineId as nr, assertAllowedPublicUrl as nt, creditProductUnitNoun as o, formatBookingPriceDisplay as on, parsePageId as or, stableJsonStringify as ot, parseVerticalId as p, publicEventPricingType as pn, parseEventSeriesId as pr, toLocationCoordinates as pt, footerLayoutForLookId as q, unsafeAsOriginalFilename as qn, addIntervalPreservingMonthAnchor as qt, committedWriteProofSchema as r, deriveTotalTicketQuantity as rn, unsafeAsOrderFlexibleBalanceContractId as rr, SENSITIVE_COLLECTION_CONFIRMATION_VERSION as rt, formatCreditProductUnits as s, formatEventPricing as sn, unsafeAsSiteFontId as sr, locationMapLinks as st, isEventOccurrenceRouteSegment as t, resolveFlexibleBalanceDueAt as tn, unsafeAsProductId as tr, parseWeeklyOpeningHours as tt, NAVIGATION_LOCATIONS as u, publicEventPricingDisplay as un, parseUserId as ur, parseLocationValue as ut, ORDINARY_EVENT_PRESET_VALUES as v, mapReadonlyNonEmptyArray as vn, unsafeAsEventSeriesId as vr, formatDate as vt, isPublicReadEndpoint as w, unsafeAsNonNegativeCents as wn, inferSiteDateLocale as wt, PUBLIC_AVAILABILITY_FRESHNESS_SECONDS as x, parsePositiveCents as xn, err as xr, formatDateTimeRange as xt, SURFACE_EVENT_PRESET_VALUES as y, isNonNegativeWholeCents as yn, unsafeAsOccurrenceId as yr, formatDateRange as yt, parseMailingListRuntimeContext as z, parseDatedOfferingCapacityHoldAuditRef as zn, resolveBookingTimeZoneId as zt };