@scopetickets/checkout 0.5.0 → 0.6.1

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.
@@ -46,6 +46,8 @@ var INCOMING_FADE_MS = 175;
46
46
  var DAY_SWAP_STRETCH = 1.6;
47
47
  var DAY_SWAP_OUT_MS = Math.round(OUTGOING_FADE_MS * DAY_SWAP_STRETCH);
48
48
  var DAY_SWAP_IN_MS = Math.round(INCOMING_FADE_MS * DAY_SWAP_STRETCH);
49
+ var ARC_LEAD_BEZIER = [0.61, 1, 0.88, 1];
50
+ var ARC_TRAIL_BEZIER = [0.12, 0, 0.39, 0];
49
51
  var CARRY_MOVE_DELAY_MS = SURFACE_MORPH_DELAY_MS;
50
52
  var CARRY_MOVE_MS = settleMs(CARRY_SPRING);
51
53
  var POP_SCALE = 0.95;
@@ -172,47 +174,6 @@ function userTypeNames(rows) {
172
174
  return Object.fromEntries(rows.map((row) => [row.AssignmentKey, row.Name]));
173
175
  }
174
176
 
175
- // ../checkout-core/src/domain/money.ts
176
- var MONEY_LOCALE = "en-IE";
177
- function formatterFor(currency) {
178
- return new Intl.NumberFormat(MONEY_LOCALE, { style: "currency", currency });
179
- }
180
- function minorUnitDigits(formatter) {
181
- return formatter.resolvedOptions().maximumFractionDigits ?? 2;
182
- }
183
- function majorUnits(minorUnits, currency) {
184
- const digits = minorUnitDigits(formatterFor(currency));
185
- return Number((minorUnits / 10 ** digits).toFixed(digits));
186
- }
187
- function formatMoney(minorUnits, currency) {
188
- const formatter = formatterFor(currency);
189
- return formatter.format(minorUnits / 10 ** minorUnitDigits(formatter));
190
- }
191
- function moneyParts(minorUnits, currency) {
192
- const formatter = formatterFor(currency);
193
- const digits = minorUnitDigits(formatter);
194
- const plain = new Intl.NumberFormat(MONEY_LOCALE, {
195
- minimumFractionDigits: digits,
196
- maximumFractionDigits: digits
197
- });
198
- const value = minorUnits / 10 ** digits;
199
- const magnitude = Math.abs(value);
200
- const symbol = formatter.format(magnitude).replace(plain.format(magnitude), "").replace(/\s/gu, "");
201
- return { symbol, amount: plain.format(value) };
202
- }
203
- function widestAmount(amounts) {
204
- return amounts.reduce((widest, amount) => Math.max(widest, amount.length), 0);
205
- }
206
- function quoteLines(quote) {
207
- if (quote.kind === "NONE") return null;
208
- const headline = formatMoney(quote.minorUnits, quote.currency);
209
- if (quote.kind === "FROM") return { qualifier: "From", headline };
210
- if (quote.kind === "SAVING") {
211
- return { qualifier: `Save ${formatMoney(quote.savedMinorUnits, quote.currency)}`, headline };
212
- }
213
- return { qualifier: null, headline };
214
- }
215
-
216
177
  // ../checkout-core/src/domain/island-timeslots.ts
217
178
  function slotFullness(remaining, total) {
218
179
  if (!Number.isFinite(remaining) || remaining < 0) return null;
@@ -674,2056 +635,2163 @@ function toggleSelectedDay(selected, day) {
674
635
  return selected === day ? null : day;
675
636
  }
676
637
 
677
- // src/island/ContentFlag.tsx
678
- import {
679
- CheckInCircleFilledIcon,
680
- ExclamationMarkInCircleFilledIcon,
681
- XMarkInCircleFilledIcon
682
- } from "@scopetickets/icons";
683
-
684
- // ../api/src/environment.ts
685
- var ENVIRONMENT_URLS = {
686
- sandbox: {
687
- apiUrl: "https://testlink.scopetickets.com",
688
- paymentHostUrl: "https://sandbox.pay.scopetickets.com",
689
- artworkUrl: "https://cdn.scopetickets.com",
690
- passkeyRpId: "testlink.scopetickets.com",
691
- passkeyHostUrl: "https://passkeys.testlink.scopetickets.com"
692
- },
693
- production: {
694
- apiUrl: "https://link.scopetickets.com",
695
- paymentHostUrl: "https://pay.scopetickets.com",
696
- artworkUrl: "https://cdn.scopetickets.com",
697
- passkeyRpId: "link.scopetickets.com",
698
- passkeyHostUrl: "https://passkeys.link.scopetickets.com"
699
- },
700
- internal: {
701
- apiUrl: "https://testlink.scopetickets.com",
702
- paymentHostUrl: "http://localhost:3001",
703
- artworkUrl: "https://cdn.scopetickets.com",
704
- /*
705
- * `localhost` IS ITS OWN RP ID, and the one origin a browser will do WebAuthn on
706
- * without TLS. A local host cannot borrow the staging id: `localhost` is not a
707
- * suffix of `testlink.scopetickets.com`, so a credential made here is a local one
708
- * and does not carry to staging.
709
- */
710
- passkeyRpId: "localhost",
711
- passkeyHostUrl: "http://localhost:3002"
712
- }
713
- };
714
- var MAX_HOST_URL_LENGTH = 256;
715
- var HOST_PROTOCOLS = /* @__PURE__ */ new Set(["https:", "http:"]);
716
- function acceptableHostUrl(value) {
717
- if (typeof value !== "string") return null;
718
- const text = value.trim();
719
- if (text.length === 0 || text.length > MAX_HOST_URL_LENGTH) return null;
720
- let url;
721
- try {
722
- url = new URL(text);
723
- } catch {
724
- return null;
725
- }
726
- if (!HOST_PROTOCOLS.has(url.protocol)) return null;
727
- if (url.username !== "" || url.password !== "") return null;
728
- if (url.search !== "" || url.hash !== "") return null;
729
- return `${url.origin}${url.pathname.replace(/\/+$/, "")}`;
638
+ // ../checkout-core/src/domain/money.ts
639
+ var MONEY_LOCALE = "en-IE";
640
+ function formatterFor(currency) {
641
+ return new Intl.NumberFormat(MONEY_LOCALE, { style: "currency", currency });
730
642
  }
731
- function resolveEnvironmentUrls(environment, overrides = {}) {
732
- const defaults = ENVIRONMENT_URLS[environment];
733
- return {
734
- apiUrl: acceptableHostUrl(overrides.apiUrl) ?? defaults.apiUrl,
735
- paymentHostUrl: acceptableHostUrl(overrides.paymentHostUrl) ?? defaults.paymentHostUrl,
736
- artworkUrl: acceptableHostUrl(overrides.artworkUrl) ?? defaults.artworkUrl,
737
- passkeyRpId: defaults.passkeyRpId,
738
- passkeyHostUrl: acceptableHostUrl(overrides.passkeyHostUrl) ?? defaults.passkeyHostUrl
739
- };
643
+ function minorUnitDigits(formatter) {
644
+ return formatter.resolvedOptions().maximumFractionDigits ?? 2;
740
645
  }
741
-
742
- // ../api/src/client.ts
743
- var ApiError = class extends Error {
744
- constructor(reason, message) {
745
- super(message);
746
- this.reason = reason;
747
- this.name = "ApiError";
646
+ function majorUnits(minorUnits, currency) {
647
+ const digits = minorUnitDigits(formatterFor(currency));
648
+ return Number((minorUnits / 10 ** digits).toFixed(digits));
649
+ }
650
+ function formatMoney(minorUnits, currency) {
651
+ const formatter = formatterFor(currency);
652
+ return formatter.format(minorUnits / 10 ** minorUnitDigits(formatter));
653
+ }
654
+ function moneyParts(minorUnits, currency) {
655
+ const formatter = formatterFor(currency);
656
+ const digits = minorUnitDigits(formatter);
657
+ const plain = new Intl.NumberFormat(MONEY_LOCALE, {
658
+ minimumFractionDigits: digits,
659
+ maximumFractionDigits: digits
660
+ });
661
+ const value = minorUnits / 10 ** digits;
662
+ const magnitude = Math.abs(value);
663
+ const symbol = formatter.format(magnitude).replace(plain.format(magnitude), "").replace(/\s/gu, "");
664
+ return { symbol, amount: plain.format(value) };
665
+ }
666
+ function widestAmount(amounts) {
667
+ return amounts.reduce((widest, amount) => Math.max(widest, amount.length), 0);
668
+ }
669
+ function quoteLines(quote) {
670
+ if (quote.kind === "NONE") return null;
671
+ const headline = formatMoney(quote.minorUnits, quote.currency);
672
+ if (quote.kind === "FROM") return { qualifier: "From", headline };
673
+ if (quote.kind === "SAVING") {
674
+ return { qualifier: `Save ${formatMoney(quote.savedMinorUnits, quote.currency)}`, headline };
748
675
  }
676
+ return { qualifier: null, headline };
677
+ }
678
+
679
+ // src/island/PartyStepper.tsx
680
+ import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
681
+ import { MinusMarkIcon, PlusMarkIcon } from "@scopetickets/icons";
682
+
683
+ // ../checkout-core/src/view/component-copy.ts
684
+ var FIELD_COPY = {
685
+ firstName: "First Name",
686
+ lastName: "Last Name",
687
+ email: "Email",
688
+ countryCode: "Country Code",
689
+ phoneNumber: "Phone Number",
690
+ confirmPassword: "Confirm Password",
691
+ verificationCode: "Verification code"
749
692
  };
750
- var ScopeClient = class {
751
- constructor(config) {
752
- this.sessionAuthorization = null;
753
- this.onRefused = null;
754
- this.config = config;
755
- }
693
+ var PARTY_COPY = {
694
+ remove: (name) => `Remove one ${name}`,
695
+ add: (name) => `Add one ${name}`,
696
+ count: (count, name) => `${count} ${name}. Change the number`,
697
+ field: (name) => `Number of ${name}`,
756
698
  /**
757
- * WHO TO TELL WHEN A SESSION IS REFUSED — the one signal a session has that it is over.
758
- *
759
- * `LoginResult` carries no expiry, so nothing can know a header has stopped working
760
- * until the platform says so. This is where that arrives, and it is a callback on the
761
- * INSTANCE rather than anything global: this library runs inside somebody else's page,
762
- * and a handler registered anywhere a host could also reach is a handler two things
763
- * fight over.
699
+ * AND WHAT AN UNDIFFERENTIATED PARTY IS CALLED — a run selling a single UserType has no
700
+ * name worth showing per row, so the one line it draws names the whole party.
764
701
  *
765
- * IT FIRES ONLY WHERE A USER SESSION WAS ACTUALLY SENT. A 401 on the app key alone is
766
- * the app being wrong about itself, not a buyer being signed out, and waking the session
767
- * machinery for it would expire somebody who was never signed in.
702
+ * A PROP DEFAULT ON THE WEB IS INVISIBLE TO THE OTHER RENDERER, which is why this is
703
+ * here: `PartyStepper`'s own `soloName = 'Guests'` could not be read from native, so
704
+ * native re-typed it.
768
705
  */
769
- setRefusedHandler(handler) {
770
- this.onRefused = handler;
771
- }
706
+ soloName: "Guests"
707
+ };
708
+ var ACTION_COPY = {
709
+ cancel: "Cancel",
710
+ confirm: "Confirm",
711
+ returnToOrder: "Return to Order",
712
+ payNow: "Pay Now",
713
+ tryAgain: "Try Again"
714
+ };
715
+ var DISMISS_COPY = {
716
+ back: "Back",
717
+ close: "Close",
718
+ /*
719
+ * ASKING ABOUT LEAVING IS STILL LEAVING, as far as the button's NAME is concerned: what
720
+ * a buyer presses it for is the same thing, and "Close, but we will check first" is a
721
+ * sentence nobody needs read to them.
722
+ */
723
+ abandon: "Close"
724
+ };
725
+ var ISLAND_COPY = {
726
+ order: "Your order",
727
+ runWeeks: "Weeks of the run",
728
+ inventories: "Show sessions"
729
+ };
730
+ var TIMESLOT_COPY = {
772
731
  /**
773
- * Holds the header a signed-in user's session gave us, or clears it on sign-out.
774
- *
775
- * Stored and sent VERBATIM, which is right: staging answers `POST /api/Auth/Login`
776
- * with the `Bearer ` already on it. Nothing here adds a scheme, and nothing should.
732
+ * WHAT A SLOT WITH NOTHING LEFT SAYS, IN WORDS. The ring is a reading of how full a
733
+ * slot is, and at zero it draws nothing — an arc of no length is an absence, not a
734
+ * statement, and a buyer scanning a column for a time cannot be asked to notice an
735
+ * opacity.
777
736
  */
778
- setAuthorization(authorization) {
779
- this.sessionAuthorization = authorization;
780
- }
781
- /** Whether a user session is in force, rather than the app key alone. */
782
- hasAuthorization() {
783
- return this.sessionAuthorization !== null;
784
- }
785
- getAuthHeaders() {
786
- if (this.sessionAuthorization !== null) {
787
- return { Authorization: this.sessionAuthorization };
788
- }
789
- if (this.config.apiKey) {
790
- return { Authorization: `Bearer ${this.config.apiKey}` };
791
- }
792
- return {};
793
- }
794
- /** A 401 on a call that carried a session, and nothing else. See `setRefusedHandler`. */
795
- reportIfRefused(status) {
796
- if (status === 401 && this.sessionAuthorization !== null) this.onRefused?.();
797
- }
798
- async fetch(endpoint, options) {
799
- const response = await fetch(`${this.config.apiUrl}${endpoint}`, {
800
- ...options,
801
- headers: {
802
- "Content-Type": "application/json",
803
- ...this.getAuthHeaders(),
804
- ...options?.headers
805
- }
806
- });
807
- if (!response.ok) {
808
- this.reportIfRefused(response.status);
809
- let errorResponse;
810
- try {
811
- errorResponse = await response.json();
812
- } catch (e) {
813
- console.error("Failed to parse API error response:", e);
814
- throw new ApiError("UnknownError", `API error: ${response.status} ${response.statusText}`);
815
- }
816
- throw new ApiError(errorResponse.Reason, errorResponse.Message);
817
- }
818
- const text = await response.text();
819
- if (!text) {
820
- return void 0;
821
- }
822
- try {
823
- return JSON.parse(text);
824
- } catch {
825
- return text;
737
+ soldOut: "Sold Out",
738
+ /**
739
+ * AND WHAT QUALIFIES THE PRICE — IN THE ROW'S NAME ONLY, not on its face. A column of
740
+ * forty rows each repeating the word says it forty times and the figure once. A screen
741
+ * reader gets one row at a time and no column, so a bare "€17.90" beside a time is a
742
+ * price with no qualifier at all.
743
+ */
744
+ from: "From"
745
+ };
746
+
747
+ // src/island/PartyStepper.tsx
748
+ import { jsx, jsxs } from "react/jsx-runtime";
749
+ function UserTypeRow({
750
+ option,
751
+ count,
752
+ atLimit,
753
+ onAdd,
754
+ onRemove,
755
+ onSet,
756
+ max,
757
+ onRefuse
758
+ }) {
759
+ return /* @__PURE__ */ jsxs("div", { className: "scopetickets-island-party-row", children: [
760
+ /* @__PURE__ */ jsxs("span", { className: "scopetickets-island-party-row__text", children: [
761
+ /* @__PURE__ */ jsx("span", { className: "scopetickets-island-party-row__name", children: option.name }),
762
+ option.note !== null && /* @__PURE__ */ jsx("span", { className: "scopetickets-island-party-row__note", children: option.note })
763
+ ] }),
764
+ /* @__PURE__ */ jsx(
765
+ UserTypeStepper,
766
+ {
767
+ name: option.name,
768
+ count,
769
+ atLimit,
770
+ onAdd,
771
+ onRemove,
772
+ onSet,
773
+ max,
774
+ onRefuse
775
+ }
776
+ )
777
+ ] });
778
+ }
779
+ function UserTypeStepper({
780
+ name,
781
+ count,
782
+ atLimit,
783
+ onAdd,
784
+ onRemove,
785
+ onSet,
786
+ max,
787
+ onRefuse
788
+ }) {
789
+ const chosen = count > 0;
790
+ return /* @__PURE__ */ jsxs("span", { className: "scopetickets-island-stepper", "data-expanded": chosen ? "" : void 0, children: [
791
+ /* @__PURE__ */ jsx(
792
+ "span",
793
+ {
794
+ className: "scopetickets-island-stepper__opening",
795
+ "aria-hidden": chosen ? void 0 : "true",
796
+ children: /* @__PURE__ */ jsxs("span", { className: "scopetickets-island-stepper__opening-inner", children: [
797
+ /* @__PURE__ */ jsx(
798
+ StepperButton,
799
+ {
800
+ label: PARTY_COPY.remove(name),
801
+ onPress: onRemove,
802
+ kind: "remove",
803
+ state: chosen ? "LIVE" : "CLOSED"
804
+ }
805
+ ),
806
+ /* @__PURE__ */ jsx(
807
+ TypedCount,
808
+ {
809
+ count,
810
+ name,
811
+ onSet,
812
+ valueClassName: "scopetickets-island-stepper__value",
813
+ inputClassName: "scopetickets-island-stepper__input",
814
+ closed: !chosen,
815
+ max,
816
+ onRefuse
817
+ }
818
+ )
819
+ ] })
820
+ }
821
+ ),
822
+ /* @__PURE__ */ jsx(
823
+ StepperButton,
824
+ {
825
+ label: PARTY_COPY.add(name),
826
+ onPress: onAdd,
827
+ kind: "add",
828
+ state: atLimit ? "REFUSING" : "LIVE"
829
+ }
830
+ )
831
+ ] });
832
+ }
833
+ function StepperButton({
834
+ label,
835
+ onPress,
836
+ kind,
837
+ state = "LIVE"
838
+ }) {
839
+ const press = useIslandPress("element");
840
+ return /* @__PURE__ */ jsx(
841
+ "button",
842
+ {
843
+ type: "button",
844
+ className: "scopetickets-island-stepper__button",
845
+ "data-kind": kind,
846
+ "aria-label": label,
847
+ "aria-disabled": state === "REFUSING" ? true : void 0,
848
+ disabled: state === "CLOSED",
849
+ onClick: state === "LIVE" ? onPress : void 0,
850
+ ...press,
851
+ children: /* @__PURE__ */ jsx("span", { className: "scopetickets-island-stepper__mark", children: kind === "add" ? /* @__PURE__ */ jsx(PlusMarkIcon, { fill: true, color: "currentColor" }) : /* @__PURE__ */ jsx(MinusMarkIcon, { fill: true, color: "currentColor" }) })
826
852
  }
827
- }
828
- async fetchVoid(endpoint, options) {
829
- const response = await fetch(`${this.config.apiUrl}${endpoint}`, {
830
- ...options,
831
- headers: {
832
- "Content-Type": "application/json",
833
- ...this.getAuthHeaders(),
834
- ...options?.headers
853
+ );
854
+ }
855
+ function SoloPartyStepper({ max, name, count, onSet, onRemove, onRefuse }) {
856
+ return /* @__PURE__ */ jsxs("div", { className: "scopetickets-island-party-solo", children: [
857
+ /* @__PURE__ */ jsx(
858
+ StepperButton,
859
+ {
860
+ label: PARTY_COPY.remove(name),
861
+ onPress: onRemove,
862
+ kind: "remove",
863
+ state: count === 0 ? "REFUSING" : "LIVE"
835
864
  }
836
- });
837
- if (!response.ok) {
838
- this.reportIfRefused(response.status);
839
- let errorResponse;
840
- try {
841
- errorResponse = await response.json();
842
- } catch (e) {
843
- console.error("Failed to parse API error response:", e);
844
- throw new ApiError("UnknownError", `API error: ${response.status} ${response.statusText}`);
865
+ ),
866
+ /* @__PURE__ */ jsx(
867
+ TypedCount,
868
+ {
869
+ count,
870
+ name,
871
+ onSet,
872
+ valueClassName: "scopetickets-island-party-solo__value",
873
+ inputClassName: "scopetickets-island-party-solo__input",
874
+ max,
875
+ onRefuse
845
876
  }
846
- throw new ApiError(errorResponse.Reason, errorResponse.Message);
877
+ ),
878
+ /* @__PURE__ */ jsx(
879
+ StepperButton,
880
+ {
881
+ label: PARTY_COPY.add(name),
882
+ onPress: () => onSet(count + 1),
883
+ kind: "add",
884
+ state: count >= max ? "REFUSING" : "LIVE"
885
+ }
886
+ )
887
+ ] });
888
+ }
889
+ function TypedCount({
890
+ count,
891
+ name,
892
+ onSet,
893
+ valueClassName,
894
+ inputClassName,
895
+ onRefuse,
896
+ closed = false,
897
+ max
898
+ }) {
899
+ const [typing, setTyping] = useState2(null);
900
+ const field = useRef2(null);
901
+ const editing = typing !== null;
902
+ useEffect2(() => {
903
+ if (!editing) return;
904
+ field.current?.focus({ preventScroll: true });
905
+ }, [editing]);
906
+ const commit = () => {
907
+ if (typing === null) return;
908
+ const asked = Number.parseInt(typing, 10);
909
+ setTyping(null);
910
+ if (!Number.isFinite(asked)) return;
911
+ if (max !== void 0 && asked > max) {
912
+ onRefuse?.(asked);
913
+ return;
847
914
  }
848
- }
849
- // ===========================================================================
850
- // v2 Events
851
- // ===========================================================================
852
- async getDisplayEvents(signal) {
853
- const response = await this.fetch("/api/v2/EventSummaries", { signal });
854
- return response.Events;
855
- }
856
- async getEventInfo(eventKey, read) {
857
- return this.eventInformation("event", eventKey, read);
858
- }
859
- async getSeriesInfo(seriesKey, read) {
860
- return this.eventInformation("series", seriesKey, read);
861
- }
862
- /**
863
- * `EventInformation`, for a run or a single event.
864
- *
865
- * `inventories` NARROWS THE RUN ITSELF, and the platform does the narrowing: the events
866
- * that sell nothing from those inventories are gone from `Events`, and the user types are
867
- * the ones those inventories' products assign. Repeated on the wire, like
868
- * `TicketInformation`'s — see `TicketInformationQuery.inventories`, which is the same
869
- * parameter on the other endpoint and the reason both are ANDed rather than substituted.
870
- */
871
- async eventInformation(type, key, read) {
872
- const params = new URLSearchParams({ type, key });
873
- for (const inventory of read?.inventories ?? []) params.append("inventories", inventory);
874
- return this.fetch(`/api/v2/EventInformation?${params}`, {
875
- signal: read?.signal
876
- });
877
- }
878
- /**
879
- * Tickets for any number of events or whole series in one request, each row naming the
880
- * events it sells for in `EventKeys`.
881
- *
882
- * THE ROUTE TO READ TICKETS FROM. `Events/{key}/Tickets` omits a timeslot at
883
- * `Remaining: 0` rather than reporting it sold out, so a sold-out session never reaches
884
- * the picker at all.
885
- *
886
- * A MISSPELT PARAMETER IS NOT REFUSED: the platform answers `200 {"Tickets":[]}`, which
887
- * reads exactly like an event that sells nothing.
888
- */
889
- async getTicketInformation(query, signal) {
890
- const params = new URLSearchParams();
891
- for (const key of query.events ?? []) params.append("events", key);
892
- for (const key of query.series ?? []) params.append("series", key);
893
- for (const key of query.inventories ?? []) params.append("inventories", key);
894
- if (query.includeTimeslots) params.set("include_timeslots", "true");
895
- if (query.includeQuestions) params.set("include_questions", "true");
896
- const response = await this.fetch(
897
- `/api/v2/TicketInformation?${params}`,
898
- { signal }
899
- );
900
- return response.Tickets ?? [];
901
- }
902
- /** @deprecated Use getTicketInformation(), which also reports sold-out timeslots */
903
- async getEventTickets(eventKey, signal) {
904
- const response = await this.fetch(
905
- `/api/v2/Events/${eventKey}/Tickets?include_timeslots=true`,
906
- { signal }
915
+ onRefuse?.(null);
916
+ onSet(Math.max(0, asked));
917
+ };
918
+ if (typing === null) {
919
+ return /* @__PURE__ */ jsx(
920
+ "button",
921
+ {
922
+ type: "button",
923
+ className: valueClassName,
924
+ "aria-label": PARTY_COPY.count(count, name),
925
+ onClick: () => setTyping(String(count)),
926
+ disabled: closed,
927
+ children: count
928
+ }
907
929
  );
908
- return response.Tickets;
909
930
  }
910
- // ===========================================================================
911
- // v1 Events (deprecated — kept for cart/timeslot compat)
912
- // ===========================================================================
913
- /** @deprecated Use getDisplayEvents() or getEventInfo() instead */
914
- async getEvents(count) {
915
- const params = count ? `?count=${count}` : "";
916
- return this.fetch(`/api/Events/ByOrganisationKey/${this.config.orgKey}${params}`);
917
- }
918
- /** @deprecated Use getEventTickets() instead */
919
- async getTickets(eventId) {
920
- return this.fetch(`/api/Ticket/Event/${eventId}`);
921
- }
922
- // ===========================================================================
923
- // Cart
924
- // ===========================================================================
925
- async createCart(eventId) {
926
- const body = typeof eventId === "string" ? { EventKey: eventId } : { EventId: eventId };
927
- return this.fetch("/api/Cart", {
928
- method: "POST",
929
- body: JSON.stringify(body)
930
- });
931
- }
932
- async getCart(cartKey) {
933
- return this.fetch(`/api/Cart/${cartKey}`);
934
- }
935
- async addToCart(cartKey, ticketId, timeslot) {
936
- const body = timeslot ? { Type: "ticket", ItemId: ticketId, Timeslot: timeslot } : { Type: "ticket", ItemId: ticketId };
937
- return this.fetch(`/api/Cart/${cartKey}/Items`, {
938
- method: "POST",
939
- body: JSON.stringify(body)
940
- });
941
- }
942
- async removeFromCart(cartKey, itemKey) {
943
- return this.fetch(`/api/Cart/${cartKey}/Items/${itemKey}`, {
944
- method: "DELETE"
945
- });
946
- }
947
- /**
948
- * WHETHER A CODE MAY BE USED, AND WHY NOT — the one call that answers the second half.
949
- *
950
- * THE `PUT` BELOW ONLY APPLIES. It refuses with an `ApiError` whose message is a
951
- * transport failure's message, which is not a sentence about a promo code; `Reason` here
952
- * is the platform's own words for an expired, spent or wrong-event code, and it is what
953
- * the card shows the buyer.
954
- *
955
- * `event_id` IS WHAT THE WIDGET KNOWS. The endpoint also narrows by ticket, series and
956
- * organisation; the cart carries its event and nothing else, so that is what is asked.
957
- */
958
- async checkPromoCode(promoCode, eventId) {
959
- const params = new URLSearchParams({ code: promoCode, event_id: String(eventId) });
960
- return this.fetch(`/api/PromoCode/Check?${params}`);
961
- }
962
- /**
963
- * PUT A PROMO CODE ON THE CART, and take back the cart it made — `TotalAmount` already
964
- * discounted, `DiscountAmount` saying by how much, `PromoCode` naming what did it.
965
- *
966
- * ONE PER CART, which is the wire's rule and not this client's: the field is a single
967
- * string, so a second code REPLACES the first rather than stacking on it.
968
- *
969
- * A REFUSED CODE IS AN `ApiError` like any other refusal — expired, spent, or for a
970
- * different event. The reason is the platform's own words; see `promoRefusal`, which is
971
- * the only thing allowed to put them in front of a buyer.
972
- */
973
- async setCartPromoCode(cartKey, promoCode) {
974
- return this.fetch(`/api/Cart/${encodeURIComponent(cartKey)}/PromoCode`, {
975
- method: "PUT",
976
- body: JSON.stringify({ PromoCode: promoCode })
977
- });
978
- }
979
- /** Take it off again, and the cart comes back at its full price. */
980
- async clearCartPromoCode(cartKey) {
981
- return this.fetch(`/api/Cart/${encodeURIComponent(cartKey)}/PromoCode`, {
982
- method: "DELETE"
983
- });
984
- }
985
- /**
986
- * `allowPartial` asks the platform to reserve what it can — see
987
- * `BulkAddItemsRequest.AllowPartialFulfillment`. OMITTED rather than sent as `false`
988
- * when it is not asked for: a body without it is what every caller already sends.
989
- */
990
- async addItemsBulk(cartKey, items, { allowPartial = false } = {}) {
991
- const body = {
992
- Items: items,
993
- ...allowPartial ? { AllowPartialFulfillment: true } : {}
994
- };
995
- return this.fetch(`/api/v2/Carts/${cartKey}/Items`, {
996
- method: "POST",
997
- body: JSON.stringify(body)
998
- });
999
- }
1000
- // ===========================================================================
1001
- // Questionnaire
1002
- // ===========================================================================
1003
- async getQuestionnaireQuestions(eventId, signal) {
1004
- return this.fetch(`/api/Questionnaires/Events/${eventId}/Questions`, {
1005
- signal
1006
- });
1007
- }
1008
- // ── Passcodes ──────────────────────────────────────────────────────────
1009
- //
1010
- // @Zsolt — AUTH SURFACE. Transport only: these three make the calls and return what
1011
- // comes back. Which of them runs when, and what a failure means, is the account
1012
- // flow's business — see `domain/passcode.ts` in @scopetickets/checkout.
1013
- /** Sends a verification code to an address. */
1014
- async sendEmailPasscode(body) {
1015
- return this.fetch("/api/Passcodes/Email", {
1016
- method: "POST",
1017
- body: JSON.stringify(body)
1018
- });
931
+ return /* @__PURE__ */ jsx(
932
+ "input",
933
+ {
934
+ className: inputClassName,
935
+ type: "text",
936
+ inputMode: "numeric",
937
+ pattern: "[0-9]*",
938
+ size: 1,
939
+ ref: field,
940
+ "aria-label": PARTY_COPY.field(name),
941
+ value: typing,
942
+ onChange: (event) => setTyping(event.target.value.replace(/\D/g, "")),
943
+ onBlur: commit,
944
+ onKeyDown: (event) => {
945
+ if (event.key === "Enter") commit();
946
+ else if (event.key === "Escape") setTyping(null);
947
+ else return;
948
+ event.preventDefault();
949
+ event.stopPropagation();
950
+ }
951
+ }
952
+ );
953
+ }
954
+ function PartyStepper({
955
+ userTypes,
956
+ counts,
957
+ onChange,
958
+ max,
959
+ soloName = PARTY_COPY.soloName,
960
+ onRefuse,
961
+ refused = null
962
+ }) {
963
+ const headcount = Object.values(counts).reduce((total, n2) => total + n2, 0);
964
+ const refuse = (asked) => onRefuse?.(asked);
965
+ const shown = (count) => refused === null ? count : refused;
966
+ if (userTypes.length === 0) {
967
+ return /* @__PURE__ */ jsx("div", { className: "scopetickets-island-party", "data-excess": refused === null ? void 0 : "", children: /* @__PURE__ */ jsx(
968
+ SoloPartyStepper,
969
+ {
970
+ max,
971
+ name: soloName,
972
+ count: shown(headcount),
973
+ onSet: (next) => {
974
+ refuse(null);
975
+ onChange(SOLO_KEY, next);
976
+ },
977
+ onRemove: () => refused === null ? onChange(SOLO_KEY, Math.max(0, headcount - 1)) : (refuse(null), onChange(SOLO_KEY, max)),
978
+ onRefuse: refuse
979
+ }
980
+ ) });
1019
981
  }
1020
- /** Submits the code the buyer typed. */
1021
- async verifyPasscode(body) {
1022
- await this.fetch("/api/Passcodes/Verification", {
1023
- method: "POST",
1024
- body: JSON.stringify(body)
1025
- });
982
+ return /* @__PURE__ */ jsx("div", { className: "scopetickets-island-party", "data-excess": refused === null ? void 0 : "", children: userTypes.map((option) => /* @__PURE__ */ jsx(
983
+ UserTypeRow,
984
+ {
985
+ option,
986
+ count: counts[option.key] ?? 0,
987
+ atLimit: headcount >= max,
988
+ onAdd: () => {
989
+ refuse(null);
990
+ onChange(option.key, (counts[option.key] ?? 0) + 1);
991
+ },
992
+ onRemove: () => {
993
+ refuse(null);
994
+ onChange(option.key, Math.max(0, (counts[option.key] ?? 0) - 1));
995
+ },
996
+ onSet: (next) => {
997
+ refuse(null);
998
+ onChange(option.key, next);
999
+ },
1000
+ max,
1001
+ onRefuse: refuse
1002
+ },
1003
+ option.key
1004
+ )) });
1005
+ }
1006
+
1007
+ // src/island/DayPicker.tsx
1008
+ import { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo2, useState as useState4 } from "react";
1009
+
1010
+ // src/island/CalendarMonthHeading.tsx
1011
+ import { jsx as jsx2 } from "react/jsx-runtime";
1012
+ function CalendarMonthHeading({ month }) {
1013
+ return /* @__PURE__ */ jsx2("h3", { className: "scopetickets-island-calendar__heading", children: formatMonthName(month) });
1014
+ }
1015
+
1016
+ // src/island/CalendarDayIndicator.tsx
1017
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1018
+ var SEGMENTS = 3;
1019
+ var FILLED_SEGMENTS = {
1020
+ LOW: 1,
1021
+ MEDIUM: 2,
1022
+ HIGH: 3
1023
+ };
1024
+ function CalendarDayIndicator({ level }) {
1025
+ const filled = FILLED_SEGMENTS[level];
1026
+ return (
1027
+ // DECORATIVE, and now correctly so.
1028
+ /* @__PURE__ */ jsxs2("span", { className: "scopetickets-island-day-indicator", "aria-hidden": "true", children: [
1029
+ /* @__PURE__ */ jsx3(
1030
+ "span",
1031
+ {
1032
+ className: `scopetickets-island-day-indicator__fill scopetickets-island-day-indicator__fill--${level.toLowerCase()}`,
1033
+ style: { flexGrow: filled }
1034
+ }
1035
+ ),
1036
+ filled < SEGMENTS ? /* @__PURE__ */ jsx3("span", { style: { flexGrow: SEGMENTS - filled } }) : null
1037
+ ] })
1038
+ );
1039
+ }
1040
+
1041
+ // src/island/CalendarDay.tsx
1042
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1043
+ function CalendarDay({
1044
+ cell,
1045
+ accessory,
1046
+ remaining,
1047
+ label,
1048
+ outsideMonth = false,
1049
+ onSelect
1050
+ }) {
1051
+ const press = useIslandPress("element");
1052
+ const dimmed = outsideMonth ? { "data-outside-month": "" } : null;
1053
+ if (cell.kind === "EMPTY") {
1054
+ return /* @__PURE__ */ jsx4("span", { className: "scopetickets-island-day", "aria-hidden": "true" });
1026
1055
  }
1027
- /**
1028
- * Reads whether a passcode has been verified.
1029
- *
1030
- * The authoritative answer, and separate from `verifyPasscode` on purpose: a code
1031
- * submitted in another tab, or on the phone the mail arrived on, is verified without
1032
- * this browser ever having posted it.
1033
- */
1034
- async getPasscodeStatus(passcodeKey) {
1035
- return this.fetch(
1036
- `/api/Passcodes/${encodeURIComponent(passcodeKey)}/Status`
1056
+ if (isSelectableCalendarCell(cell)) {
1057
+ return /* @__PURE__ */ jsx4(
1058
+ CalendarDayButton,
1059
+ {
1060
+ cell,
1061
+ accessory,
1062
+ remaining,
1063
+ label,
1064
+ onSelect,
1065
+ outsideMonth,
1066
+ press
1067
+ }
1037
1068
  );
1038
1069
  }
1039
- async submitQuestionnaireResponses(cartKey, body) {
1040
- return this.fetch(`/api/Cart/${cartKey}/Questionnaires/Responses`, {
1041
- method: "POST",
1042
- body: JSON.stringify(body)
1043
- });
1044
- }
1045
- async setBuyer(cartKey, buyer) {
1046
- return this.fetch(`/api/Cart/${cartKey}/Buyer`, {
1047
- method: "POST",
1048
- body: JSON.stringify(buyer)
1049
- });
1050
- }
1051
- async getBuyer(cartKey) {
1052
- return this.fetch(`/api/Cart/${cartKey}/Buyer`);
1053
- }
1054
- async deleteCart(cartKey) {
1055
- return this.fetchVoid(`/api/Cart/${cartKey}`, {
1056
- method: "DELETE"
1057
- });
1058
- }
1059
- // ===========================================================================
1060
- // Payment
1061
- // ===========================================================================
1062
- async createPaymentIntent(cartKey, options) {
1063
- const retryQuery = options?.retry ? "?retry=true" : "";
1064
- return this.fetch(`/api/Cart/${cartKey}/Payment${retryQuery}`, {
1065
- method: "POST"
1066
- });
1067
- }
1068
- async getPaymentStatus(cartKey) {
1069
- return this.fetch(`/api/Cart/${cartKey}/Payment/Status`);
1070
- }
1071
- // ===========================================================================
1072
- // Transactions
1073
- // ===========================================================================
1074
- async convertCartToTransaction(cartKey) {
1075
- return this.fetch("/api/Transactions/FromCart", {
1076
- method: "POST",
1077
- body: JSON.stringify({ CartKey: cartKey })
1078
- });
1079
- }
1080
- async getTransactionItems(transactionKey) {
1081
- return this.fetch(`/api/Transactions/${transactionKey}/Items`);
1082
- }
1083
- async getTransactionByCartKey(cartKey) {
1084
- return this.fetch(`/api/Transactions/ByKey/${cartKey}`);
1085
- }
1086
- // ===========================================================================
1087
- // Attendees
1088
- // ===========================================================================
1089
- /**
1090
- * AMENDS ATTENDEES A TRANSACTION ALREADY OWNS, and refuses everything else with
1091
- * `AttendeesNotMatchingTransaction`. It cannot create one — the v2 `setItemAttendee`
1092
- * below is what a first naming goes through.
1093
- *
1094
- * THE TRANSACTION-WIDE CALL, and `packages/sdk`'s ticket-confirmation flow still wants
1095
- * it: it amends an attendee that already exists (buyer-as-holder on a portal-style
1096
- * purchase) and declines politely where none does. New code should prefer the
1097
- * key-addressed call, which needs no id read first and cannot erase anybody by omission.
1098
- */
1099
- async saveAttendees(transactionKey, attendees) {
1100
- return this.fetch(`/api/Transactions/${transactionKey}/Attendees`, {
1101
- method: "PUT",
1102
- body: JSON.stringify(attendees)
1103
- });
1104
- }
1105
- /**
1106
- * WHO A TICKET IS FOR — creating the attendee where there is none and rebinding the
1107
- * ticket where there is, addressed by keys on both counts.
1108
- *
1109
- * The route takes the TRANSACTION's key and the ITEM's — the same value the bulk add
1110
- * returned as `item_key` and the booking reads as `AttendeeTicketKey` — so there is no
1111
- * attendee id to have read first and nothing integer-shaped on the wire. The platform
1112
- * scopes the item to the transaction and refuses a pair that does not match with
1113
- * `ItemNotFound`.
1114
- *
1115
- * Answers `204`-shaped success with no body: the call either went or it did not, and the
1116
- * name it saved is read back on the next booking read rather than off the response.
1117
- */
1118
- async setItemAttendee(transactionKey, itemKey, body) {
1119
- await this.fetchVoid(`/api/v2/Transactions/${transactionKey}/Items/${itemKey}/Attendee`, {
1120
- method: "PUT",
1121
- body: JSON.stringify(body)
1122
- });
1123
- }
1124
- // ===========================================================================
1125
- // Accounts
1126
- // ===========================================================================
1127
- //
1128
- // Transport only: these make the calls and return what comes back. WHICH of them runs
1129
- // when, and what a failure means, is the account flow's business — see `domain/auth.ts`
1130
- // and `domain/account-creation.ts` in @scopetickets/checkout.
1131
- /**
1132
- * Makes an account, and signs into it.
1133
- *
1134
- * `LoginUser` defaults to `true` here and is omitted from the type's own default,
1135
- * because every caller in this workspace wants the session: an account created without
1136
- * one leaves the buyer holding credentials they would then have to spend immediately.
1137
- */
1138
- async createAccount(body) {
1139
- return this.fetch("/api/Users", {
1140
- method: "POST",
1141
- body: JSON.stringify({ LoginUser: true, ...body })
1142
- });
1143
- }
1144
- /** An address and a password. */
1145
- async signIn(body) {
1146
- return this.fetch("/api/Auth/Login", {
1147
- method: "POST",
1148
- body: JSON.stringify(body)
1149
- });
1150
- }
1151
- /** Ends the session at the platform. The caller still has to forget its own copy. */
1152
- async signOut() {
1153
- return this.fetch("/api/Auth/Logout");
1154
- }
1155
- /**
1156
- * A fresh `Authorization` for a session that still holds its refresh token.
1157
- *
1158
- * The answer carries no new refresh token, so the one held is spent again rather than
1159
- * rotated.
1160
- */
1161
- async refreshAuthorization(body) {
1162
- return this.fetch("/api/Auth/Tokens", {
1163
- method: "POST",
1164
- body: JSON.stringify(body)
1165
- });
1166
- }
1167
- /**
1168
- * WHO THE SESSION BELONGS TO. The one call that turns a header into a person: every
1169
- * door into an account answers with a `LoginResult` carrying no name, no address and no
1170
- * key, so this is what the flow asks immediately after one opens.
1171
- *
1172
- * IT NEEDS A USER SESSION, not merely the app key. Measured against staging: with no
1173
- * `Authorization` at all it answers `401 NotAuthorized`, and with the app key alone it
1174
- * answers `500` — so `hasAuthorization` gates the call rather than the answer being
1175
- * read for which of the two happened.
1176
- */
1177
- async getCurrentUser(signal) {
1178
- return this.fetch("/api/Users/Me", { signal });
1179
- }
1180
- /** The signed-in user's own details. */
1181
- async updateUser(body) {
1182
- return this.fetchVoid("/api/Users", { method: "PUT", body: JSON.stringify(body) });
1183
- }
1184
- /** Changes the password of the signed-in user, who therefore knows the old one. */
1185
- async updatePassword(body) {
1186
- return this.fetchVoid("/api/Users/Password", { method: "PUT", body: JSON.stringify(body) });
1187
- }
1188
- /** Starts recovery for somebody who cannot sign in. Needs no session, by definition. */
1189
- async requestPasswordReset(body) {
1190
- return this.fetchVoid("/api/Users/PasswordReset", {
1191
- method: "POST",
1192
- body: JSON.stringify(body)
1193
- });
1194
- }
1195
- /** Sets the signed-in user's photo. Needs the session, so it runs after creation. */
1196
- async updatePhoto(body) {
1197
- return this.fetchVoid("/api/Users/Photo", { method: "PUT", body: JSON.stringify(body) });
1198
- }
1199
- // ===========================================================================
1200
- // Following
1201
- // ===========================================================================
1202
- async getFollowing(userKey, signal) {
1203
- return this.fetch(`/api/Users/${encodeURIComponent(userKey)}/Following`, {
1204
- signal
1205
- });
1206
- }
1207
- async followOrganisation(userKey, body) {
1208
- return this.fetchVoid(`/api/Users/${encodeURIComponent(userKey)}/Following/Organisation`, {
1209
- method: "POST",
1210
- body: JSON.stringify(body)
1211
- });
1212
- }
1213
- async unfollowOrganisation(userKey, organisationKey) {
1214
- return this.fetchVoid(
1215
- `/api/Users/${encodeURIComponent(userKey)}/Following/Organisation/${encodeURIComponent(organisationKey)}`,
1216
- { method: "DELETE" }
1217
- );
1218
- }
1219
- async followVenue(userKey, body) {
1220
- return this.fetchVoid(`/api/Users/${encodeURIComponent(userKey)}/Following/Venue`, {
1221
- method: "POST",
1222
- body: JSON.stringify(body)
1223
- });
1224
- }
1225
- async unfollowVenue(userKey, venueKey) {
1226
- return this.fetchVoid(
1227
- `/api/Users/${encodeURIComponent(userKey)}/Following/Venue/${encodeURIComponent(venueKey)}`,
1228
- { method: "DELETE" }
1070
+ if (cell.kind === "UNAVAILABLE") {
1071
+ return /* @__PURE__ */ jsx4(
1072
+ CalendarDayButton,
1073
+ {
1074
+ cell,
1075
+ accessory,
1076
+ remaining: null,
1077
+ label,
1078
+ outsideMonth,
1079
+ press
1080
+ }
1229
1081
  );
1230
1082
  }
1231
- // ===========================================================================
1232
- // Passkeys
1233
- // ===========================================================================
1234
- //
1235
- // Four calls and no ceremony. The browser half cannot run in a page a customer serves —
1236
- // see `packages/passkey-host` — so these hand challenges out and take credentials back,
1237
- // and something on a Scope origin does the part in between.
1238
- /** Opens a registration. Names nobody: the user comes from the session. */
1239
- async createPasskeyRegistrationChallenge(body) {
1240
- return this.fetch("/api/Passkeys/Registrations/Challenges", {
1241
- method: "POST",
1242
- body: JSON.stringify(body)
1243
- });
1244
- }
1245
- /** Lodges the credential the device made. */
1246
- async registerPasskey(body) {
1247
- return this.fetchVoid("/api/Passkeys/Registrations", {
1248
- method: "POST",
1249
- body: JSON.stringify(body)
1250
- });
1251
- }
1252
- /** Opens a sign-in. Needs no session — proving who you are is the point of it. */
1253
- async createPasskeyAuthenticationChallenge(body) {
1254
- return this.fetch("/api/Passkeys/Authentications/Challenges", {
1255
- method: "POST",
1256
- body: JSON.stringify(body)
1257
- });
1258
- }
1259
- /** Spends the assertion, and opens a session with it. */
1260
- async authenticateWithPasskey(body) {
1261
- return this.fetch("/api/Passkeys/Authentications", {
1262
- method: "POST",
1263
- body: JSON.stringify(body)
1264
- });
1265
- }
1266
- // ===========================================================================
1267
- // Feedback
1268
- // ===========================================================================
1269
- /**
1270
- * How the buyer rated a ticket. Answers 200 and nothing else, so there is no receipt
1271
- * to hold on to — the call either went or it did not.
1272
- */
1273
- async submitFeedback(body) {
1274
- return this.fetchVoid("/api/Feedback", { method: "POST", body: JSON.stringify(body) });
1275
- }
1276
- // ===========================================================================
1277
- // Utilities
1278
- // ===========================================================================
1279
- /**
1280
- * SEND ONE TICKET TO AN ADDRESS — the platform's own email, to whoever the buyer names.
1281
- *
1282
- * `template` IS OMITTED ON PURPOSE. The parameter takes a free string, the spec documents
1283
- * no values for it and nothing else in the API names one; left off, the platform sends
1284
- * its default. Conall, 2026-09-13.
1285
- *
1286
- * IT IS A `GET` THAT SENDS MAIL, which is the platform's shape and not a choice made
1287
- * here. A `GET` is the one method browsers, proxies, prefetchers and generic retry layers
1288
- * treat as free to repeat, so at-most-once cannot be delegated to any of them: every
1289
- * caller has to fire this from one deliberate press and never from anything that can
1290
- * re-run. See `sendTicket` in the booking gateway, which is the only caller.
1291
- */
1292
- async sendTicketEmail(attendeeTicketId, email) {
1293
- const params = new URLSearchParams({
1294
- email,
1295
- attendee_ticket_id: String(attendeeTicketId)
1296
- });
1297
- await this.fetch(`/api/AttendeeTicket/SendSingleEmail?${params}`);
1298
- }
1299
- async getQrCode(content, foreground = "000000", background = "FFFFFF") {
1300
- const params = new URLSearchParams({
1301
- content,
1302
- foreground,
1303
- background,
1304
- drawQuietZone: "false"
1305
- });
1306
- return this.fetch(`/api/Utils/GetQrCodeAsSVG?${params}`);
1307
- }
1308
- };
1309
-
1310
- // ../api/src/payment-protocol/parent.ts
1311
- var CARRIED_CHECKOUT_PARAMS = ["event", "eventKey"];
1312
- function buildFrameUrl(hostUrl, cartKey, identity, options) {
1313
- const url = new URL(`/checkout/${cartKey}`, hostUrl);
1314
- url.searchParams.set("method", identity.method);
1315
- url.searchParams.set("instanceId", identity.instanceId);
1316
- if (options.checkoutSessionId !== void 0)
1317
- url.searchParams.set("checkoutSessionId", options.checkoutSessionId);
1318
- url.searchParams.set("displayMode", "prewarm");
1319
- url.searchParams.set("origin", options.parentOrigin);
1320
- if (options.debug === true) url.searchParams.set("scopePaymentDebug", "1");
1321
- if (options.retry === true) url.searchParams.set("paymentRetry", "1");
1322
- for (const name of options.carriedParams ?? []) {
1323
- const value = options.parentSearchParams?.get(name);
1324
- if (value) url.searchParams.set(name, value);
1325
- }
1326
- return url.toString();
1327
- }
1328
- function allowedFrameOrigin(hostUrl) {
1329
- try {
1330
- return new URL(hostUrl).origin;
1331
- } catch {
1332
- return hostUrl;
1333
- }
1334
- }
1335
- var PAYMENT_DIAGNOSTIC_EVENTS = /* @__PURE__ */ new Set([
1336
- "revolut.provider_init_started",
1337
- "revolut.provider_init_finished",
1338
- "revolut.provider_init_failed",
1339
- "revolut.button_pressed",
1340
- "revolut.create_order_callback_started",
1341
- "revolut.create_order_callback_returned",
1342
- "revolut.inline_journey_detected",
1343
- "revolut.external_handoff_detected",
1344
- "revolut.detector_state"
1345
- ]);
1346
- var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1347
- function parsePaymentDiagnostic(value) {
1348
- if (!isPlainObject(value)) return null;
1349
- const payload = value;
1350
- if (typeof payload.event !== "string" || !PAYMENT_DIAGNOSTIC_EVENTS.has(payload.event))
1351
- return null;
1352
- const sourceData = isPlainObject(payload.data) ? payload.data : void 0;
1353
- const data = {};
1354
- if (sourceData?.paymentHostClass === "local_tunnel" || sourceData?.paymentHostClass === "other") {
1355
- data.paymentHostClass = sourceData.paymentHostClass;
1356
- }
1357
- if (typeof sourceData?.active === "boolean") data.active = sourceData.active;
1358
- if (typeof sourceData?.tokenPresent === "boolean") data.tokenPresent = sourceData.tokenPresent;
1359
- if (typeof sourceData?.errorType === "string" && /^[A-Za-z][A-Za-z0-9]{0,63}$/.test(sourceData.errorType)) {
1360
- data.errorType = sourceData.errorType;
1361
- }
1362
- if (sourceData?.evidence === "provider_frame_loaded" || sourceData?.evidence === "provider_frame_replaced" || sourceData?.evidence === "mobile_inline_provisional") {
1363
- data.evidence = sourceData.evidence;
1364
- }
1365
- if (typeof sourceData?.generation === "number" && Number.isSafeInteger(sourceData.generation)) {
1366
- data.generation = sourceData.generation;
1367
- }
1368
- if (typeof sourceData?.mobile === "boolean") data.mobile = sourceData.mobile;
1369
- if (typeof sourceData?.visible === "boolean") data.visible = sourceData.visible;
1370
- if (sourceData?.state === "initialized" || sourceData?.state === "attempt_started" || sourceData?.state === "order_returned" || sourceData?.state === "inline_provisional" || sourceData?.state === "external_handoff" || sourceData?.state === "disconnected") {
1371
- data.state = sourceData.state;
1372
- }
1373
- if (sourceData?.reason === "not_mobile" || sourceData?.reason === "no_attempt" || sourceData?.reason === "terminal" || sourceData?.reason === "external_handoff" || sourceData?.reason === "hidden") {
1374
- data.reason = sourceData.reason;
1375
- }
1376
- return { event: payload.event, ...Object.keys(data).length > 0 ? { data } : {} };
1377
- }
1378
- function parsePaymentPresentation(value, expectedInstanceId, latestGeneration) {
1379
- if (!isPlainObject(value)) return null;
1380
- const payload = value;
1381
- if (payload.instanceId !== expectedInstanceId || payload.method !== "revolut_pay" || payload.mode !== "inline_provisional" && payload.mode !== "external_handoff" || typeof payload.attemptGeneration !== "number" || !Number.isSafeInteger(payload.attemptGeneration) || payload.attemptGeneration <= 0 || payload.attemptGeneration < latestGeneration) {
1382
- return null;
1383
- }
1384
- return {
1385
- instanceId: payload.instanceId,
1386
- method: payload.method,
1387
- mode: payload.mode,
1388
- attemptGeneration: payload.attemptGeneration
1389
- };
1390
- }
1391
- function parseFrameEvent(event, expected) {
1392
- if (expected.source == null || event.origin !== expected.allowedOrigin || event.source !== expected.source || !isPlainObject(event.data))
1393
- return null;
1394
- const { type } = event.data;
1395
- if (typeof type !== "string" || !type.startsWith("SCOPE_PAYMENT_")) return null;
1396
- const payload = isPlainObject(event.data.payload) ? event.data.payload : {};
1397
- if (payload.instanceId !== void 0 && payload.instanceId !== expected.identity.instanceId)
1398
- return null;
1399
- if (payload.method !== void 0 && payload.method !== expected.identity.method) return null;
1400
- const frameMessage = { type, payload };
1401
- switch (type) {
1402
- case "SCOPE_PAYMENT_READY":
1403
- case "SCOPE_PAYMENT_CONFIG_REQUESTED":
1404
- case "SCOPE_PAYMENT_CANCELLED":
1405
- case "SCOPE_PAYMENT_SUBMIT_REQUESTED":
1406
- return frameMessage;
1407
- case "SCOPE_PAYMENT_RESIZE":
1408
- if (typeof payload.height !== "number" || !Number.isFinite(payload.height)) return null;
1409
- return frameMessage;
1410
- case "SCOPE_PAYMENT_SUCCESS":
1411
- if (typeof payload.cartKey !== "string" || !payload.cartKey) return null;
1412
- return frameMessage;
1413
- case "SCOPE_PAYMENT_ERROR":
1414
- if (typeof payload.code !== "string" || typeof payload.message !== "string") return null;
1415
- return frameMessage;
1416
- case "SCOPE_PAYMENT_METHOD_STATUS":
1417
- if (typeof payload.ready !== "boolean") return null;
1418
- if (payload.wallet !== void 0 && payload.wallet !== "applePay" && payload.wallet !== "googlePay")
1419
- return null;
1420
- return frameMessage;
1421
- case "SCOPE_PAYMENT_DIAGNOSTIC": {
1422
- const diagnostic = parsePaymentDiagnostic(payload);
1423
- return diagnostic === null ? null : { type, payload: diagnostic };
1424
- }
1425
- case "SCOPE_PAYMENT_PRESENTATION": {
1426
- const presentation = parsePaymentPresentation(payload, expected.identity.instanceId, 0);
1427
- return presentation === null ? null : { type, payload: presentation };
1428
- }
1429
- default:
1430
- return null;
1431
- }
1083
+ return /* @__PURE__ */ jsx4("span", { className: "scopetickets-island-day", ...dimmed, ...press, children: /* @__PURE__ */ jsx4("span", { className: "scopetickets-island-day__well", "data-state": cell.kind, children: /* @__PURE__ */ jsx4("span", { className: "scopetickets-island-day__number", children: cell.dayOfMonth }) }) });
1432
1084
  }
1433
- function buildConfigMessage(identity, config) {
1434
- return {
1435
- type: "SCOPE_PAYMENT_CONFIG",
1436
- payload: {
1437
- ...config.apiKey === void 0 ? {} : { apiKey: config.apiKey },
1438
- ...config.selectedMethod === void 0 ? {} : { selectedMethod: config.selectedMethod },
1439
- ...config.theme === void 0 ? {} : { theme: config.theme },
1440
- instanceId: identity.instanceId,
1441
- method: identity.method
1085
+ function CalendarDayButton({
1086
+ cell,
1087
+ accessory,
1088
+ remaining,
1089
+ label,
1090
+ outsideMonth = false,
1091
+ press,
1092
+ onSelect
1093
+ }) {
1094
+ const selected = cell.kind === "SELECTED";
1095
+ const availability = readAvailability(remaining);
1096
+ return /* @__PURE__ */ jsx4(
1097
+ "button",
1098
+ {
1099
+ type: "button",
1100
+ className: "scopetickets-island-day",
1101
+ ...outsideMonth ? { "data-outside-month": "" } : null,
1102
+ "aria-pressed": onSelect ? selected : void 0,
1103
+ "aria-disabled": onSelect ? void 0 : true,
1104
+ "aria-label": availability === null ? label : `${label}, ${availability.announcement}`,
1105
+ onClick: onSelect ? () => onSelect(cell.day) : void 0,
1106
+ ...press,
1107
+ children: /* @__PURE__ */ jsxs3("span", { className: "scopetickets-island-day__well", "data-state": cell.kind, children: [
1108
+ /* @__PURE__ */ jsx4("span", { className: "scopetickets-island-day__number", children: cell.dayOfMonth }),
1109
+ cell.kind === "UNAVAILABLE" ? /* @__PURE__ */ jsx4("span", { className: "scopetickets-island-day__strike", "aria-hidden": "true" }) : null,
1110
+ accessory === "LINE" && availability !== null ? /* @__PURE__ */ jsx4("span", { className: "scopetickets-island-day__accessory", children: /* @__PURE__ */ jsx4(CalendarDayIndicator, { level: availability.level }) }) : null
1111
+ ] })
1442
1112
  }
1443
- };
1444
- }
1445
- function buildSubmitConfirmedMessage(identity, buyer) {
1446
- return {
1447
- type: "SCOPE_PAYMENT_SUBMIT_CONFIRMED",
1448
- payload: { ...buyer, instanceId: identity.instanceId, method: identity.method }
1449
- };
1450
- }
1451
- function buildSubmitRejectedMessage(identity, reason) {
1452
- return {
1453
- type: "SCOPE_PAYMENT_SUBMIT_REJECTED",
1454
- payload: { reason, instanceId: identity.instanceId, method: identity.method }
1455
- };
1456
- }
1457
- function buildTriggerSubmitMessage(identity) {
1458
- return {
1459
- type: "SCOPE_PAYMENT_TRIGGER_SUBMIT",
1460
- payload: { instanceId: identity.instanceId, method: identity.method }
1461
- };
1462
- }
1463
- function buildCancelRequestedMessage(identity) {
1464
- return {
1465
- type: "SCOPE_PAYMENT_CANCEL_REQUESTED",
1466
- payload: { instanceId: identity.instanceId, method: identity.method }
1467
- };
1113
+ );
1468
1114
  }
1469
1115
 
1470
- // ../api/src/buyer.ts
1471
- var MAX_EMAIL_LENGTH = 254;
1472
- var MAX_LOCAL_LENGTH = 64;
1473
- var MAX_LABEL_LENGTH = 63;
1474
- var MAX_DOMAIN_LENGTH = 255;
1475
- var LOCAL_PART = /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*$/;
1476
- var DOMAIN_LABEL = /^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?$/;
1477
- var TOP_LEVEL_LABEL = /^[A-Za-z]{2,}$/;
1478
- function isAcceptableEmail(value) {
1479
- const email = value.trim();
1480
- if (email.length === 0 || email.length > MAX_EMAIL_LENGTH) return false;
1481
- const at = email.lastIndexOf("@");
1482
- if (at <= 0 || at === email.length - 1) return false;
1483
- const local = email.slice(0, at);
1484
- if (local.length > MAX_LOCAL_LENGTH || !LOCAL_PART.test(local)) return false;
1485
- const domain = email.slice(at + 1);
1486
- if (domain.length > MAX_DOMAIN_LENGTH) return false;
1487
- const labels = domain.split(".");
1488
- if (labels.length < 2) return false;
1489
- if (labels.some((label) => label.length > MAX_LABEL_LENGTH || !DOMAIN_LABEL.test(label))) {
1490
- return false;
1491
- }
1492
- return TOP_LEVEL_LABEL.test(labels[labels.length - 1]);
1493
- }
1494
- var E164 = /^\+[1-9]\d{1,14}$/;
1495
- function isE164(value) {
1496
- return E164.test(value.trim());
1497
- }
1498
- var CONTROL_CHARACTERS = /[\x00-\x1F\x7F]/;
1499
- function isAcceptableName(value) {
1500
- const name = value.trim();
1501
- return name.length > 0 && name.length <= 256 && !CONTROL_CHARACTERS.test(name);
1116
+ // src/island/CalendarRunGrid.tsx
1117
+ import { jsx as jsx5 } from "react/jsx-runtime";
1118
+ function CalendarRunGrid({
1119
+ series,
1120
+ weeks,
1121
+ currentMonth,
1122
+ accessory,
1123
+ remaining,
1124
+ today,
1125
+ selectedDay,
1126
+ onSelectDay
1127
+ }) {
1128
+ return /* @__PURE__ */ jsx5("div", { className: "scopetickets-island-calendar__grid", children: weeks.map((weekStart) => (
1129
+ // A presentational row: the seven columns are a layout, and announcing "row 3
1130
+ // of 9" describes the grid rather than the run.
1131
+ /* @__PURE__ */ jsx5("div", { className: "scopetickets-island-calendar__week", children: buildWeekRow(series, weekStart, { today, selectedDay }).map((cell, dayIndex) => /* @__PURE__ */ jsx5(
1132
+ CalendarDay,
1133
+ {
1134
+ cell,
1135
+ accessory,
1136
+ remaining: cell.kind === "EMPTY" ? null : remaining?.[cell.day] ?? null,
1137
+ label: cell.kind === "EMPTY" ? "" : formatDayDate(cell.day),
1138
+ outsideMonth: cell.kind !== "EMPTY" && monthOfDay(cell.day) !== currentMonth,
1139
+ onSelect: onSelectDay
1140
+ },
1141
+ cell.kind === "EMPTY" ? `empty-${dayIndex}` : cell.day
1142
+ )) }, weekStart)
1143
+ )) });
1502
1144
  }
1503
1145
 
1504
- // ../api/src/email-typos.ts
1505
- var KNOWN_DOMAINS = [
1506
- "gmail.com",
1507
- "googlemail.com",
1508
- "icloud.com",
1509
- "me.com",
1510
- "mac.com",
1511
- "mail.com",
1512
- "hotmail.com",
1513
- "outlook.com",
1514
- "live.com",
1515
- "yahoo.com",
1516
- "aol.com",
1517
- "proton.me",
1518
- "protonmail.com",
1519
- "eircom.net"
1520
- ];
1521
- var NEAR_MISS_TARGETS = [
1522
- "gmail.com",
1523
- "googlemail.com",
1524
- "icloud.com",
1525
- "hotmail.com",
1526
- "outlook.com",
1527
- "yahoo.com",
1528
- "protonmail.com",
1529
- "eircom.net"
1530
- ];
1531
- var MIN_DISTINCTIVE_BODY = 4;
1532
- var TOP_LEVEL_SLIPS = {
1533
- co: "com",
1534
- con: "com",
1535
- cim: "com",
1536
- cmo: "com",
1537
- ocm: "com",
1538
- comm: "com",
1539
- coom: "com",
1540
- cpm: "com",
1541
- vom: "com",
1542
- xom: "com",
1543
- nte: "net",
1544
- ner: "net",
1545
- ogr: "org",
1546
- orh: "org"
1547
- };
1548
- function editDistance(a, b) {
1549
- const columns = b.length + 1;
1550
- const d = new Uint16Array((a.length + 1) * columns);
1551
- for (let j = 0; j < columns; j += 1) d[j] = j;
1552
- for (let i = 1; i <= a.length; i += 1) {
1553
- const row = i * columns;
1554
- const previous = row - columns;
1555
- d[row] = i;
1556
- for (let j = 1; j <= b.length; j += 1) {
1557
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
1558
- let best = Math.min(
1559
- (d[previous + j] ?? 0) + 1,
1560
- (d[row + j - 1] ?? 0) + 1,
1561
- (d[previous + j - 1] ?? 0) + cost
1562
- );
1563
- if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
1564
- best = Math.min(best, (d[previous - columns + j - 2] ?? 0) + 1);
1565
- }
1566
- d[row + j] = best;
1146
+ // src/island/CalendarScroller.tsx
1147
+ import {
1148
+ useCallback,
1149
+ useEffect as useEffect3,
1150
+ useRef as useRef3,
1151
+ useState as useState3
1152
+ } from "react";
1153
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
1154
+ var WHEEL_IDLE_MS = 200;
1155
+ var CALENDAR_DRAG_SLOP = 4;
1156
+ function CalendarScroller({
1157
+ children,
1158
+ rowCount,
1159
+ row,
1160
+ onRowChange,
1161
+ onRowPreview,
1162
+ label
1163
+ }) {
1164
+ const viewportRef = useRef3(null);
1165
+ const trackRef = useRef3(null);
1166
+ const startY = useRef3(null);
1167
+ const [offset, setOffset] = useState3(0);
1168
+ const [dragging, setDragging] = useState3(false);
1169
+ const rowRef = useRef3(row);
1170
+ rowRef.current = row;
1171
+ const [rowStep, setRowStep] = useState3(0);
1172
+ const gapPx = (box) => {
1173
+ const gap = Number.parseFloat(
1174
+ getComputedStyle(box).getPropertyValue("--scopetickets-island-day-column-gap")
1175
+ );
1176
+ return Number.isFinite(gap) ? gap : 0;
1177
+ };
1178
+ useEffect3(() => {
1179
+ const track = trackRef.current;
1180
+ if (!track) return void 0;
1181
+ const measure = () => {
1182
+ const row2 = track.querySelector(".scopetickets-island-calendar__week");
1183
+ if (!row2) return;
1184
+ const height = row2.getBoundingClientRect().height;
1185
+ if (height <= 0) return;
1186
+ const step = height + gapPx(track);
1187
+ setRowStep((was) => Math.abs(was - step) < 0.5 ? was : step);
1188
+ };
1189
+ measure();
1190
+ if (typeof ResizeObserver === "undefined") return void 0;
1191
+ const observer = new ResizeObserver(measure);
1192
+ observer.observe(track);
1193
+ return () => observer.disconnect();
1194
+ }, [rowCount]);
1195
+ const rowHeight = useCallback(() => {
1196
+ if (rowStep > 0) return rowStep;
1197
+ const box = viewportRef.current;
1198
+ if (!box) return 0;
1199
+ return (box.clientHeight + gapPx(box)) / CALENDAR_VIEWPORT_ROWS;
1200
+ }, [rowStep]);
1201
+ const drag = useCallback(
1202
+ (dy) => ({
1203
+ row: rowRef.current,
1204
+ rowCount,
1205
+ viewportRows: CALENDAR_VIEWPORT_ROWS,
1206
+ offset: dy,
1207
+ rowHeight: rowHeight()
1208
+ }),
1209
+ [rowCount, rowHeight]
1210
+ );
1211
+ const draw = useCallback(
1212
+ (dy) => {
1213
+ const moving = drag(dy);
1214
+ setOffset(rowDragOffset(moving));
1215
+ onRowPreview?.(rowAfterDrag(moving));
1216
+ },
1217
+ [drag, onRowPreview]
1218
+ );
1219
+ const settle = useCallback(
1220
+ (dy) => {
1221
+ setOffset(0);
1222
+ const landed = rowAfterDrag(drag(dy));
1223
+ if (landed !== rowRef.current) onRowChange(landed);
1224
+ },
1225
+ [drag, onRowChange]
1226
+ );
1227
+ const dragged = useRef3(false);
1228
+ const onPointerDown = (event) => {
1229
+ if ((event.buttons & 1) !== 1) return;
1230
+ startY.current = event.clientY;
1231
+ dragged.current = false;
1232
+ };
1233
+ const onPointerMove = (event) => {
1234
+ if (startY.current === null) return;
1235
+ const dy = event.clientY - startY.current;
1236
+ if (!dragged.current) {
1237
+ if (Math.abs(dy) < CALENDAR_DRAG_SLOP) return;
1238
+ dragged.current = true;
1239
+ setDragging(true);
1240
+ event.currentTarget.setPointerCapture(event.pointerId);
1567
1241
  }
1568
- }
1569
- return d[a.length * columns + b.length] ?? 0;
1570
- }
1571
- function splitDomain(domain) {
1572
- const lastDot = domain.lastIndexOf(".");
1573
- if (lastDot <= 0 || lastDot === domain.length - 1) return null;
1574
- return { body: domain.slice(0, lastDot), top: domain.slice(lastDot + 1) };
1575
- }
1576
- function nearestKnownDomain(domain) {
1577
- const typed = splitDomain(domain);
1578
- if (typed === null || typed.body.length < MIN_DISTINCTIVE_BODY) return null;
1579
- for (const candidate of NEAR_MISS_TARGETS) {
1580
- const known = splitDomain(candidate);
1581
- if (known === null || known.top !== typed.top) continue;
1582
- if (known.body.length < MIN_DISTINCTIVE_BODY) continue;
1583
- if (editDistance(typed.body, known.body) === 1) return candidate;
1584
- }
1585
- return null;
1242
+ draw(dy);
1243
+ };
1244
+ const onPointerUp = (event) => {
1245
+ if (startY.current === null) return;
1246
+ const dy = event.clientY - startY.current;
1247
+ startY.current = null;
1248
+ if (!dragged.current) return;
1249
+ setDragging(false);
1250
+ settle(dy);
1251
+ };
1252
+ const onClickCapture = (event) => {
1253
+ if (!dragged.current) return;
1254
+ dragged.current = false;
1255
+ event.stopPropagation();
1256
+ event.preventDefault();
1257
+ };
1258
+ const onPointerCancel = () => {
1259
+ startY.current = null;
1260
+ dragged.current = false;
1261
+ setDragging(false);
1262
+ setOffset(0);
1263
+ };
1264
+ const wheel = useRef3(0);
1265
+ const settleTimer = useRef3(null);
1266
+ useEffect3(() => {
1267
+ const viewport = viewportRef.current;
1268
+ if (!viewport) return void 0;
1269
+ const onWheel = (event) => {
1270
+ event.preventDefault();
1271
+ wheel.current -= event.deltaY;
1272
+ wheel.current = rowDragOffset(drag(wheel.current));
1273
+ draw(wheel.current);
1274
+ if (settleTimer.current !== null) window.clearTimeout(settleTimer.current);
1275
+ settleTimer.current = window.setTimeout(() => {
1276
+ settleTimer.current = null;
1277
+ const travelled = wheel.current;
1278
+ wheel.current = 0;
1279
+ settle(travelled);
1280
+ }, WHEEL_IDLE_MS);
1281
+ };
1282
+ viewport.addEventListener("wheel", onWheel, { passive: false });
1283
+ return () => viewport.removeEventListener("wheel", onWheel);
1284
+ }, [drag, draw, settle]);
1285
+ useEffect3(
1286
+ () => () => {
1287
+ if (settleTimer.current !== null) window.clearTimeout(settleTimer.current);
1288
+ },
1289
+ []
1290
+ );
1291
+ return /* @__PURE__ */ jsxs4(
1292
+ "div",
1293
+ {
1294
+ ref: viewportRef,
1295
+ className: "scopetickets-island-calendar-scroller",
1296
+ role: "group",
1297
+ "aria-label": label,
1298
+ style: {
1299
+ "--scopetickets-island-viewport-rows": CALENDAR_VIEWPORT_ROWS,
1300
+ ...rowStep > 0 ? { "--scopetickets-island-calendar-row-step": `${rowStep}px` } : null
1301
+ },
1302
+ onPointerDown,
1303
+ onPointerMove,
1304
+ onPointerUp,
1305
+ onPointerCancel,
1306
+ onClickCapture,
1307
+ children: [
1308
+ /* @__PURE__ */ jsx6("div", { className: "scopetickets-island-calendar-scroller__window", "aria-hidden": "true" }),
1309
+ /* @__PURE__ */ jsx6(
1310
+ "div",
1311
+ {
1312
+ ref: trackRef,
1313
+ className: "scopetickets-island-calendar-scroller__track",
1314
+ "data-dragging": dragging || offset !== 0 ? "" : void 0,
1315
+ style: {
1316
+ translate: `0 calc(${-row} * var(--scopetickets-island-calendar-row-step) + ${offset}px)`
1317
+ },
1318
+ children
1319
+ }
1320
+ )
1321
+ ]
1322
+ }
1323
+ );
1586
1324
  }
1587
- function repairTopLevel(domain) {
1588
- const labels = domain.split(".");
1589
- if (labels.length < 2) return null;
1590
- const top = labels[labels.length - 1];
1591
- const meant = TOP_LEVEL_SLIPS[top];
1592
- if (meant === void 0) return null;
1593
- return [...labels.slice(0, -1), meant].join(".");
1594
- }
1595
- function suspectedEmailTypo(email) {
1596
- const trimmed = email.trim().toLowerCase();
1597
- const at = trimmed.lastIndexOf("@");
1598
- if (at <= 0 || at === trimmed.length - 1) return null;
1599
- const local = trimmed.slice(0, at);
1600
- const domain = trimmed.slice(at + 1);
1601
- if (KNOWN_DOMAINS.includes(domain)) return null;
1602
- const repaired = repairTopLevel(domain);
1603
- const corrected = nearestKnownDomain(repaired ?? domain) ?? repaired;
1604
- if (corrected === null || corrected === domain) return null;
1605
- return `${local}@${corrected}`;
1325
+
1326
+ // src/island/CalendarWeekdayNames.tsx
1327
+ import { jsx as jsx7 } from "react/jsx-runtime";
1328
+ var WEEKDAY_NAMES = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
1329
+ function CalendarWeekdayNames() {
1330
+ return (
1331
+ // `aria-hidden`, and it is not a shortcut.
1332
+ /* @__PURE__ */ jsx7("div", { className: "scopetickets-island-calendar__weekdays", "aria-hidden": "true", children: WEEKDAY_NAMES.map((name) => /* @__PURE__ */ jsx7("span", { className: "scopetickets-island-calendar__weekday", children: name }, name)) })
1333
+ );
1606
1334
  }
1607
1335
 
1608
- // ../checkout-core/src/domain/contact.ts
1609
- function isValidEmail(email) {
1610
- return isAcceptableEmail(email);
1611
- }
1612
- function flagTone(flag) {
1613
- return flag === "none" ? void 0 : flag;
1614
- }
1615
- function emailFlag(email) {
1616
- if (email.length === 0) return "none";
1617
- if (!isValidEmail(email)) return "error";
1618
- return suspectedEmailTypo(email) === null ? "success" : "warning";
1619
- }
1620
- function emailFlagTitle(email) {
1621
- const meant = emailFlag(email) === "warning" ? suspectedEmailTypo(email) : null;
1622
- return meant === null ? void 0 : `Did you mean ${meant}?`;
1336
+ // src/island/DayPicker.tsx
1337
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1338
+ function DayPicker({
1339
+ series,
1340
+ offered = series,
1341
+ today,
1342
+ selectedDay,
1343
+ onSelectDay,
1344
+ remaining,
1345
+ accessory = DATE_PICKER_ACCESSORY,
1346
+ onVisibleMonthChange
1347
+ }) {
1348
+ const weeks = useMemo2(() => weeksInCalendar(series), [series]);
1349
+ const starts = useMemo2(() => monthStartRows(weeks), [weeks]);
1350
+ const [row, setRow] = useState4(
1351
+ () => monthOpeningRow(weeks, starts, selectedDay ?? soonestRelevantDay(offered, today))
1352
+ );
1353
+ const [shownRow, setShownRow] = useState4(row);
1354
+ const currentMonth = monthAtRow(starts, shownRow);
1355
+ useEffect4(() => {
1356
+ if (currentMonth !== null) onVisibleMonthChange?.(currentMonth);
1357
+ }, [currentMonth, onVisibleMonthChange]);
1358
+ const selectDay = useCallback2(
1359
+ (day) => {
1360
+ const month = monthOfDay(day);
1361
+ const start = starts.find((candidate) => candidate.month === month);
1362
+ if (start !== void 0 && month !== currentMonth) {
1363
+ setRow(start.row);
1364
+ setShownRow(start.row);
1365
+ }
1366
+ onSelectDay(day);
1367
+ },
1368
+ [starts, currentMonth, onSelectDay]
1369
+ );
1370
+ if (weeks.length === 0) return null;
1371
+ return /* @__PURE__ */ jsxs5("div", { className: "scopetickets-island-calendar", "data-accessory": accessory, children: [
1372
+ currentMonth !== null && /* @__PURE__ */ jsx8(CalendarMonthHeading, { month: currentMonth }),
1373
+ /* @__PURE__ */ jsx8(CalendarWeekdayNames, {}),
1374
+ /* @__PURE__ */ jsx8(
1375
+ CalendarScroller,
1376
+ {
1377
+ rowCount: weeks.length,
1378
+ row,
1379
+ onRowChange: setRow,
1380
+ onRowPreview: setShownRow,
1381
+ label: ISLAND_COPY.runWeeks,
1382
+ children: /* @__PURE__ */ jsx8(
1383
+ CalendarRunGrid,
1384
+ {
1385
+ series: offered,
1386
+ weeks,
1387
+ currentMonth,
1388
+ accessory,
1389
+ remaining,
1390
+ today,
1391
+ selectedDay,
1392
+ onSelectDay: selectDay
1393
+ }
1394
+ )
1395
+ }
1396
+ )
1397
+ ] });
1623
1398
  }
1624
- var E164_MAX_DIGITS = 15;
1625
- var GENERIC_NATIONAL_DIGITS = { min: 4, max: E164_MAX_DIGITS - 1 };
1626
- var COUNTRIES = [
1627
- // ── Ireland, the default, and the United Kingdom ────────────
1628
- {
1629
- code: "IE",
1630
- name: "Ireland",
1631
- dialCode: "+353",
1632
- trunkPrefix: "0",
1633
- nationalDigits: { min: 7, max: 9 },
1634
- // `08X XXX XXXX`, which is what the design draws.
1635
- grouping: [{ startsWith: ["8"], digits: 9, groups: [2, 3, 4] }]
1636
- },
1637
- {
1638
- code: "GB",
1639
- name: "United Kingdom",
1640
- dialCode: "+44",
1641
- trunkPrefix: "0",
1642
- nationalDigits: { min: 9, max: 10 },
1643
- // London is also ten digits and is grouped `020 7946 0958`, so nothing beyond the
1644
- // `7` may be assumed.
1645
- grouping: [{ startsWith: ["7"], digits: 10, groups: [4, 6] }]
1646
- },
1647
- // ── The rest of the EU, alphabetically ──────────────────────
1648
- {
1649
- code: "AT",
1650
- name: "Austria",
1651
- dialCode: "+43",
1652
- trunkPrefix: "0",
1653
- // Austria's plan is the widest in the EU — subscriber numbers run from four digits
1654
- // to thirteen.
1655
- nationalDigits: { min: 4, max: 13 },
1656
- grouping: [{ startsWith: ["6"], digits: 10, groups: [3, 7] }]
1657
- },
1658
- {
1659
- code: "BE",
1660
- name: "Belgium",
1661
- dialCode: "+32",
1662
- trunkPrefix: "0",
1663
- nationalDigits: { min: 8, max: 9 },
1664
- grouping: [{ startsWith: ["4"], digits: 9, groups: [3, 2, 2, 2] }]
1665
- },
1666
- {
1667
- code: "BG",
1668
- name: "Bulgaria",
1669
- dialCode: "+359",
1670
- trunkPrefix: "0",
1671
- nationalDigits: { min: 8, max: 9 },
1672
- grouping: [{ startsWith: ["87", "88", "89"], digits: 9, groups: [2, 3, 4] }]
1673
- },
1674
- {
1675
- code: "HR",
1676
- name: "Croatia",
1677
- dialCode: "+385",
1678
- trunkPrefix: "0",
1679
- nationalDigits: { min: 8, max: 9 },
1680
- grouping: [{ startsWith: ["9"], digits: 9, groups: [2, 3, 4] }]
1681
- },
1682
- {
1683
- code: "CY",
1684
- name: "Cyprus",
1685
- dialCode: "+357",
1686
- nationalDigits: { min: 8, max: 8 },
1687
- grouping: [{ startsWith: ["9"], digits: 8, groups: [2, 6] }]
1688
- },
1689
- {
1690
- code: "CZ",
1691
- name: "Czechia",
1692
- dialCode: "+420",
1693
- nationalDigits: { min: 9, max: 9 },
1694
- // Threes throughout, and Czechia has no trunk prefix.
1695
- grouping: [{ digits: 9, groups: [3, 3, 3] }]
1696
- },
1697
- {
1698
- code: "DK",
1699
- name: "Denmark",
1700
- dialCode: "+45",
1701
- nationalDigits: { min: 8, max: 8 },
1702
- // Every Danish number is eight digits in pairs, mobile or not — so this needs no
1703
- // prefix to disambiguate.
1704
- grouping: [{ digits: 8, groups: [2, 2, 2, 2] }]
1705
- },
1706
- {
1707
- code: "EE",
1708
- name: "Estonia",
1709
- dialCode: "+372",
1710
- nationalDigits: { min: 7, max: 8 },
1711
- grouping: [
1712
- { startsWith: ["5"], digits: 8, groups: [4, 4] },
1713
- { startsWith: ["5"], digits: 7, groups: [3, 4] }
1714
- ]
1715
- },
1716
- {
1717
- code: "FI",
1718
- name: "Finland",
1719
- dialCode: "+358",
1720
- trunkPrefix: "0",
1721
- nationalDigits: { min: 6, max: 10 },
1722
- grouping: [{ startsWith: ["4", "5"], digits: 9, groups: [2, 3, 4] }]
1723
- },
1724
- {
1725
- code: "FR",
1726
- name: "France",
1727
- dialCode: "+33",
1728
- trunkPrefix: "0",
1729
- nationalDigits: { min: 9, max: 9 },
1730
- // Pairs throughout — `06 12 34 56 78`.
1731
- grouping: [{ startsWith: ["6", "7"], digits: 9, groups: [1, 2, 2, 2, 2] }]
1732
- },
1733
- {
1734
- code: "DE",
1735
- name: "Germany",
1736
- dialCode: "+49",
1737
- trunkPrefix: "0",
1738
- nationalDigits: { min: 6, max: 11 }
1739
- // NO GROUPING, deliberately, and the one EU country without it.
1740
- },
1741
- {
1742
- code: "GR",
1743
- name: "Greece",
1744
- dialCode: "+30",
1745
- nationalDigits: { min: 10, max: 10 },
1746
- // Ten digits, no trunk prefix, and the leading digit is kept when dialling.
1747
- grouping: [{ startsWith: ["69"], digits: 10, groups: [3, 3, 4] }]
1748
- },
1749
- {
1750
- code: "HU",
1751
- name: "Hungary",
1752
- dialCode: "+36",
1753
- // `06`, and written apart from the number — see `formatNational`.
1754
- trunkPrefix: "06",
1755
- nationalDigits: { min: 8, max: 9 },
1756
- grouping: [{ startsWith: ["20", "30", "31", "50", "70"], digits: 9, groups: [2, 3, 4] }]
1757
- },
1758
- {
1759
- code: "IT",
1760
- name: "Italy",
1761
- dialCode: "+39",
1762
- // NO TRUNK PREFIX, and Italy is the exception worth knowing: the leading `0` of a
1763
- // landline is part of the number and is dialled internationally too.
1764
- nationalDigits: { min: 6, max: 11 },
1765
- grouping: [{ startsWith: ["3"], digits: 10, groups: [3, 3, 4] }]
1399
+
1400
+ // src/island/ContentFlag.tsx
1401
+ import {
1402
+ CheckInCircleFilledIcon,
1403
+ ExclamationMarkInCircleFilledIcon,
1404
+ XMarkInCircleFilledIcon
1405
+ } from "@scopetickets/icons";
1406
+
1407
+ // ../api/src/environment.ts
1408
+ var ENVIRONMENT_URLS = {
1409
+ sandbox: {
1410
+ apiUrl: "https://testlink.scopetickets.com",
1411
+ paymentHostUrl: "https://sandbox.pay.scopetickets.com",
1412
+ artworkUrl: "https://cdn.scopetickets.com",
1413
+ passkeyRpId: "testlink.scopetickets.com",
1414
+ passkeyHostUrl: "https://passkeys.testlink.scopetickets.com"
1766
1415
  },
1767
- {
1768
- code: "LV",
1769
- name: "Latvia",
1770
- dialCode: "+371",
1771
- nationalDigits: { min: 8, max: 8 },
1772
- grouping: [{ startsWith: ["2"], digits: 8, groups: [2, 3, 3] }]
1416
+ production: {
1417
+ apiUrl: "https://link.scopetickets.com",
1418
+ paymentHostUrl: "https://pay.scopetickets.com",
1419
+ artworkUrl: "https://cdn.scopetickets.com",
1420
+ passkeyRpId: "link.scopetickets.com",
1421
+ passkeyHostUrl: "https://passkeys.link.scopetickets.com"
1773
1422
  },
1774
- {
1775
- code: "LT",
1776
- name: "Lithuania",
1777
- dialCode: "+370",
1778
- // `8`, and written apart from the number — see `formatNational`.
1779
- trunkPrefix: "8",
1780
- nationalDigits: { min: 8, max: 8 },
1781
- grouping: [{ startsWith: ["6"], digits: 8, groups: [3, 5] }]
1782
- },
1783
- {
1784
- code: "LU",
1785
- name: "Luxembourg",
1786
- dialCode: "+352",
1787
- nationalDigits: { min: 4, max: 11 },
1788
- grouping: [{ startsWith: ["6"], digits: 9, groups: [3, 3, 3] }]
1789
- },
1790
- {
1791
- code: "MT",
1792
- name: "Malta",
1793
- dialCode: "+356",
1794
- nationalDigits: { min: 8, max: 8 },
1795
- grouping: [{ startsWith: ["7", "9"], digits: 8, groups: [4, 4] }]
1796
- },
1797
- {
1798
- code: "NL",
1799
- name: "Netherlands",
1800
- dialCode: "+31",
1801
- trunkPrefix: "0",
1802
- nationalDigits: { min: 9, max: 9 },
1803
- // `06 12345678` — the mobile prefix, then the number unbroken.
1804
- grouping: [{ startsWith: ["6"], digits: 9, groups: [1, 8] }]
1805
- },
1806
- {
1807
- code: "PL",
1808
- name: "Poland",
1809
- dialCode: "+48",
1810
- // Poland dropped its trunk prefix; the nine digits are dialled as they are.
1811
- nationalDigits: { min: 9, max: 9 },
1812
- grouping: [{ digits: 9, groups: [3, 3, 3] }]
1813
- },
1814
- {
1815
- code: "PT",
1816
- name: "Portugal",
1817
- dialCode: "+351",
1818
- nationalDigits: { min: 9, max: 9 },
1819
- grouping: [{ digits: 9, groups: [3, 3, 3] }]
1820
- },
1821
- {
1822
- code: "RO",
1823
- name: "Romania",
1824
- dialCode: "+40",
1825
- trunkPrefix: "0",
1826
- nationalDigits: { min: 9, max: 9 },
1827
- grouping: [{ startsWith: ["7"], digits: 9, groups: [3, 3, 3] }]
1828
- },
1829
- {
1830
- code: "SK",
1831
- name: "Slovakia",
1832
- dialCode: "+421",
1833
- trunkPrefix: "0",
1834
- nationalDigits: { min: 9, max: 9 },
1835
- grouping: [{ startsWith: ["9"], digits: 9, groups: [3, 3, 3] }]
1836
- },
1837
- {
1838
- code: "SI",
1839
- name: "Slovenia",
1840
- dialCode: "+386",
1841
- trunkPrefix: "0",
1842
- nationalDigits: { min: 8, max: 8 },
1843
- grouping: [{ startsWith: ["3", "4", "5", "6", "7"], digits: 8, groups: [2, 3, 3] }]
1844
- },
1845
- {
1846
- code: "ES",
1847
- name: "Spain",
1848
- dialCode: "+34",
1849
- // No trunk prefix; the nine digits are the whole number.
1850
- nationalDigits: { min: 9, max: 9 },
1851
- grouping: [{ digits: 9, groups: [3, 3, 3] }]
1852
- },
1853
- {
1854
- code: "SE",
1855
- name: "Sweden",
1856
- dialCode: "+46",
1857
- trunkPrefix: "0",
1858
- nationalDigits: { min: 7, max: 9 },
1859
- grouping: [{ startsWith: ["7"], digits: 9, groups: [2, 3, 4] }]
1860
- },
1861
- /*
1862
- * Named and length-checked so a number from one of them is not read as nonsense, but
1863
- * NOT formatted: the brief is the EU and the UK, and a grouping rule written for a
1864
- * market nobody asked about is a rule nobody will check. The NANP is the exception — it
1865
- * was already here, and it is one shape throughout.
1866
- */
1867
- {
1868
- code: "US",
1869
- name: "United States",
1870
- dialCode: "+1",
1871
- nationalDigits: { min: 10, max: 10 },
1872
- grouping: [{ digits: 10, groups: [3, 3, 4] }]
1873
- },
1874
- { code: "CH", name: "Switzerland", dialCode: "+41", trunkPrefix: "0" },
1875
- { code: "NO", name: "Norway", dialCode: "+47" },
1876
- { code: "AU", name: "Australia", dialCode: "+61", trunkPrefix: "0" },
1877
- { code: "NZ", name: "New Zealand", dialCode: "+64", trunkPrefix: "0" },
1878
- { code: "ZA", name: "South Africa", dialCode: "+27", trunkPrefix: "0" },
1879
- { code: "AE", name: "United Arab Emirates", dialCode: "+971", trunkPrefix: "0" },
1880
- { code: "IN", name: "India", dialCode: "+91", trunkPrefix: "0" },
1881
- { code: "BR", name: "Brazil", dialCode: "+55", trunkPrefix: "0" }
1882
- ];
1883
- var DEFAULT_COUNTRY_CODE = "IE";
1884
- function countryByCode(code) {
1885
- const found = COUNTRIES.find((country) => country.code === code);
1886
- if (!found) throw new Error(`unknown country: ${code}`);
1887
- return found;
1888
- }
1889
- var DEFAULT_DIAL_CODE = countryByCode(DEFAULT_COUNTRY_CODE).dialCode;
1890
- var digitsOf = (value) => value.replace(/\D/g, "");
1891
- function countryByDialCode(dialCode) {
1892
- const raw = digitsOf(dialCode);
1893
- const digits = raw.startsWith("00") && raw.length > 2 ? raw.slice(2) : raw;
1894
- if (digits.length === 0) return null;
1895
- return COUNTRIES.find((country) => country.dialCode.slice(1) === digits) ?? null;
1423
+ internal: {
1424
+ apiUrl: "https://testlink.scopetickets.com",
1425
+ paymentHostUrl: "http://localhost:3001",
1426
+ artworkUrl: "https://cdn.scopetickets.com",
1427
+ /*
1428
+ * `localhost` IS ITS OWN RP ID, and the one origin a browser will do WebAuthn on
1429
+ * without TLS. A local host cannot borrow the staging id: `localhost` is not a
1430
+ * suffix of `testlink.scopetickets.com`, so a credential made here is a local one
1431
+ * and does not carry to staging.
1432
+ */
1433
+ passkeyRpId: "localhost",
1434
+ passkeyHostUrl: "http://localhost:3002"
1435
+ }
1436
+ };
1437
+ var MAX_HOST_URL_LENGTH = 256;
1438
+ var HOST_PROTOCOLS = /* @__PURE__ */ new Set(["https:", "http:"]);
1439
+ function acceptableHostUrl(value) {
1440
+ if (typeof value !== "string") return null;
1441
+ const text = value.trim();
1442
+ if (text.length === 0 || text.length > MAX_HOST_URL_LENGTH) return null;
1443
+ let url;
1444
+ try {
1445
+ url = new URL(text);
1446
+ } catch {
1447
+ return null;
1448
+ }
1449
+ if (!HOST_PROTOCOLS.has(url.protocol)) return null;
1450
+ if (url.username !== "" || url.password !== "") return null;
1451
+ if (url.search !== "" || url.hash !== "") return null;
1452
+ return `${url.origin}${url.pathname.replace(/\/+$/, "")}`;
1896
1453
  }
1897
- function splitPhoneNumber(raw) {
1898
- const trimmed = raw.trim();
1899
- const digits = digitsOf(trimmed);
1900
- const international = trimmed.startsWith("+") || digits.startsWith("00") && digits.length > 2;
1901
- if (!international || digits.length === 0) return { dialCode: null, national: trimmed };
1902
- const body = trimmed.startsWith("+") ? digits : digits.slice(2);
1903
- const match = [...COUNTRIES].sort((a, b) => b.dialCode.length - a.dialCode.length).find((country) => body.startsWith(country.dialCode.slice(1)));
1904
- if (!match) return { dialCode: null, national: trimmed };
1905
- return { dialCode: match.dialCode, national: body.slice(match.dialCode.length - 1) };
1454
+ function resolveEnvironmentUrls(environment, overrides = {}) {
1455
+ const defaults = ENVIRONMENT_URLS[environment];
1456
+ return {
1457
+ apiUrl: acceptableHostUrl(overrides.apiUrl) ?? defaults.apiUrl,
1458
+ paymentHostUrl: acceptableHostUrl(overrides.paymentHostUrl) ?? defaults.paymentHostUrl,
1459
+ artworkUrl: acceptableHostUrl(overrides.artworkUrl) ?? defaults.artworkUrl,
1460
+ passkeyRpId: defaults.passkeyRpId,
1461
+ passkeyHostUrl: acceptableHostUrl(overrides.passkeyHostUrl) ?? defaults.passkeyHostUrl
1462
+ };
1906
1463
  }
1907
- var MAX_DIAL_DIGITS = Math.max(...COUNTRIES.map((country) => country.dialCode.length - 1));
1908
- var NOT_PHONE = /[^\d+]/g;
1909
- function routePhoneInput(typed, field, current) {
1910
- const raw = typed.replace(NOT_PHONE, "");
1911
- const parts = splitPhoneNumber(raw);
1912
- if (field === "national") {
1913
- if (parts.dialCode === null) return { ...current, national: raw };
1914
- return { dialCode: parts.dialCode, national: parts.national };
1464
+
1465
+ // ../api/src/client.ts
1466
+ var ApiError = class extends Error {
1467
+ constructor(reason, message) {
1468
+ super(message);
1469
+ this.reason = reason;
1470
+ this.name = "ApiError";
1915
1471
  }
1916
- if (parts.dialCode !== null) {
1917
- return {
1918
- dialCode: parts.dialCode,
1919
- /*
1920
- * A remainder long enough to BE a number takes the row below; one too short to be
1921
- * anything replaces nothing. `+3531` is a slipped keystroke after a complete code, and
1922
- * letting its `1` overwrite an entered number is the same bug in the other direction —
1923
- * so it is dropped, unless the row below is empty and there is nothing to lose.
1924
- */
1925
- national: digitsOf(parts.national).length >= GENERIC_NATIONAL_DIGITS.min || current.national.length === 0 ? parts.national : current.national
1926
- };
1472
+ };
1473
+ var ScopeClient = class {
1474
+ constructor(config) {
1475
+ this.sessionAuthorization = null;
1476
+ this.onRefused = null;
1477
+ this.config = config;
1927
1478
  }
1928
- if (digitsOf(raw).length > MAX_DIAL_DIGITS) {
1929
- return { dialCode: current.dialCode, national: raw };
1479
+ /**
1480
+ * WHO TO TELL WHEN A SESSION IS REFUSED — the one signal a session has that it is over.
1481
+ *
1482
+ * `LoginResult` carries no expiry, so nothing can know a header has stopped working
1483
+ * until the platform says so. This is where that arrives, and it is a callback on the
1484
+ * INSTANCE rather than anything global: this library runs inside somebody else's page,
1485
+ * and a handler registered anywhere a host could also reach is a handler two things
1486
+ * fight over.
1487
+ *
1488
+ * IT FIRES ONLY WHERE A USER SESSION WAS ACTUALLY SENT. A 401 on the app key alone is
1489
+ * the app being wrong about itself, not a buyer being signed out, and waking the session
1490
+ * machinery for it would expire somebody who was never signed in.
1491
+ */
1492
+ setRefusedHandler(handler) {
1493
+ this.onRefused = handler;
1930
1494
  }
1931
- if (raw.trim().length === 0) return { ...current, dialCode: DEFAULT_DIAL_CODE };
1932
- return { ...current, dialCode: raw };
1933
- }
1934
- function nationalDigits(phone, country) {
1935
- let digits = digitsOf(phone);
1936
- const dial = country.dialCode.slice(1);
1937
- if (digits.startsWith(dial) && digits.length > dial.length) digits = digits.slice(dial.length);
1938
- const trunk = country.trunkPrefix;
1939
- if (trunk !== void 0 && digits.startsWith(trunk)) digits = digits.slice(trunk.length);
1940
- return digits;
1941
- }
1942
- function formatNational(value, country) {
1943
- const digits = digitsOf(value);
1944
- if (digits.length === 0) return value.trim() === "+" ? "+" : "";
1945
- const trunk = country.trunkPrefix !== void 0 && digits.startsWith(country.trunkPrefix) ? country.trunkPrefix : "";
1946
- const nsn = digits.slice(trunk.length);
1947
- const pattern = country.grouping?.find(
1948
- (candidate) => nsn.length <= candidate.digits && (candidate.startsWith === void 0 || candidate.startsWith.some((start) => nsn.startsWith(start)))
1949
- );
1950
- if (pattern === void 0) return value;
1951
- const parts = [];
1952
- let at = 0;
1953
- for (const size of pattern.groups) {
1954
- if (at >= nsn.length) break;
1955
- parts.push(nsn.slice(at, at + size));
1956
- at += size;
1495
+ /**
1496
+ * Holds the header a signed-in user's session gave us, or clears it on sign-out.
1497
+ *
1498
+ * Stored and sent VERBATIM, which is right: staging answers `POST /api/Auth/Login`
1499
+ * with the `Bearer ` already on it. Nothing here adds a scheme, and nothing should.
1500
+ */
1501
+ setAuthorization(authorization) {
1502
+ this.sessionAuthorization = authorization;
1503
+ }
1504
+ /** Whether a user session is in force, rather than the app key alone. */
1505
+ hasAuthorization() {
1506
+ return this.sessionAuthorization !== null;
1957
1507
  }
1958
- if (trunk === "") return parts.join(" ");
1959
- return trunk === "0" ? [trunk + (parts[0] ?? ""), ...parts.slice(1)].join(" ") : [trunk, ...parts].join(" ");
1960
- }
1961
- function digitsAllowed(country) {
1962
- return country.nationalDigits ?? GENERIC_NATIONAL_DIGITS;
1963
- }
1964
- function isValidPhone(phone, country) {
1965
- const national = nationalDigits(phone, country);
1966
- const { min, max } = digitsAllowed(country);
1967
- return national.length >= min && national.length <= max;
1968
- }
1969
- function phoneFlag(phone, country) {
1970
- if (phone.trim().length === 0) return "none";
1971
- return isValidPhone(phone, country) ? "success" : "error";
1972
- }
1973
- function e164(dialCode, phone) {
1974
- const country = countryByDialCode(dialCode);
1975
- if (country === null) return null;
1976
- const national = nationalDigits(phone, country);
1977
- if (!isValidPhone(phone, country)) return null;
1978
- const composed = `${country.dialCode}${national}`;
1979
- return isE164(composed) ? composed : null;
1980
- }
1981
- function normalizeE164(value) {
1982
- const { dialCode, national } = splitPhoneNumber(value);
1983
- if (dialCode === null) return null;
1984
- return e164(dialCode, national);
1985
- }
1986
- function isCompleteName(firstName, lastName) {
1987
- return firstName.trim().length > 0 && lastName.trim().length > 0;
1988
- }
1989
- function splitFullName(full) {
1990
- const parts = full.trim().split(/\s+/).filter(Boolean);
1991
- if (parts.length < 2) return null;
1992
- const [firstName, ...rest] = parts;
1993
- return { firstName, lastName: rest.join(" ") };
1994
- }
1995
-
1996
- // src/island/ContentFlag.tsx
1997
- import { jsx } from "react/jsx-runtime";
1998
- var GLYPH = {
1999
- success: CheckInCircleFilledIcon,
2000
- warning: ExclamationMarkInCircleFilledIcon,
2001
- error: XMarkInCircleFilledIcon
2002
- };
2003
- function ContentFlag({ tone, title }) {
2004
- const Glyph = GLYPH[tone];
2005
- return /* @__PURE__ */ jsx("span", { className: `scopetickets-island-content-flag scopetickets-island-content-flag--${tone}`, children: /* @__PURE__ */ jsx(Glyph, { fill: true, color: "currentColor", title }) });
2006
- }
2007
-
2008
- // src/island/PartyStepper.tsx
2009
- import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
2010
- import { MinusMarkIcon, PlusMarkIcon } from "@scopetickets/icons";
2011
-
2012
- // ../checkout-core/src/view/component-copy.ts
2013
- var FIELD_COPY = {
2014
- firstName: "First Name",
2015
- lastName: "Last Name",
2016
- email: "Email",
2017
- countryCode: "Country Code",
2018
- phoneNumber: "Phone Number",
2019
- confirmPassword: "Confirm Password",
2020
- verificationCode: "Verification code"
2021
- };
2022
- var PARTY_COPY = {
2023
- remove: (name) => `Remove one ${name}`,
2024
- add: (name) => `Add one ${name}`,
2025
- count: (count, name) => `${count} ${name}. Change the number`,
2026
- field: (name) => `Number of ${name}`,
2027
1508
  /**
2028
- * AND WHAT AN UNDIFFERENTIATED PARTY IS CALLED — a run selling a single UserType has no
2029
- * name worth showing per row, so the one line it draws names the whole party.
1509
+ * WHICH IDENTITY A CALL CARRIES, and it is the CALL's, not the client's.
2030
1510
  *
2031
- * A PROP DEFAULT ON THE WEB IS INVISIBLE TO THE OTHER RENDERER, which is why this is
2032
- * here: `PartyStepper`'s own `soloName = 'Guests'` could not be read from native, so
2033
- * native re-typed it.
2034
- */
2035
- soloName: "Guests"
2036
- };
2037
- var ACTION_COPY = {
2038
- cancel: "Cancel",
2039
- confirm: "Confirm",
2040
- returnToOrder: "Return to Order",
2041
- payNow: "Pay Now",
2042
- tryAgain: "Try Again"
2043
- };
2044
- var DISMISS_COPY = {
2045
- back: "Back",
2046
- close: "Close",
2047
- /*
2048
- * ASKING ABOUT LEAVING IS STILL LEAVING, as far as the button's NAME is concerned: what
2049
- * a buyer presses it for is the same thing, and "Close, but we will check first" is a
2050
- * sentence nobody needs read to them.
2051
- */
2052
- abandon: "Close"
2053
- };
2054
- var ISLAND_COPY = {
2055
- order: "Your order",
2056
- runWeeks: "Weeks of the run",
2057
- inventories: "Show sessions"
2058
- };
2059
- var TIMESLOT_COPY = {
2060
- /**
2061
- * WHAT A SLOT WITH NOTHING LEFT SAYS, IN WORDS. The ring is a reading of how full a
2062
- * slot is, and at zero it draws nothing — an arc of no length is an absence, not a
2063
- * statement, and a buyer scanning a column for a time cannot be asked to notice an
2064
- * opacity.
1511
+ * THE APP KEY ON EVERY APP CALL, EVEN WITH A BUYER SIGNED IN. The platform's event and
1512
+ * ticket reads take whatever follows `Bearer ` as the APPLICATION's key and look it up;
1513
+ * a user session in its place finds no application and answers 401. It used to replace
1514
+ * the app key on every call, so the moment a buyer signed in every event read failed —
1515
+ * "We Could Not Load This Event" on every event, first seen on a device once the native
1516
+ * island could sign somebody in before an event loaded. A session carries no app
1517
+ * identity and there is no second header, so the two cannot travel together.
1518
+ *
1519
+ * THE SESSION ONLY WHERE THE CALL IS THE ACCOUNT'S — who the user is, their profile,
1520
+ * photo, password, follows, passkey registration, and logout — and the app key there
1521
+ * where nobody is signed in. No buyer-flow endpoint reads the caller at all (carts,
1522
+ * transactions, attendees, payments, questionnaires, feedback), so nothing they did is
1523
+ * lost by the app key.
2065
1524
  */
2066
- soldOut: "Sold Out",
1525
+ getAuthHeaders(as) {
1526
+ if (as === "USER" && this.sessionAuthorization !== null) {
1527
+ return { Authorization: this.sessionAuthorization };
1528
+ }
1529
+ if (this.config.apiKey) {
1530
+ return { Authorization: `Bearer ${this.config.apiKey}` };
1531
+ }
1532
+ return {};
1533
+ }
2067
1534
  /**
2068
- * AND WHAT QUALIFIES THE PRICE — IN THE ROW'S NAME ONLY, not on its face. A column of
2069
- * forty rows each repeating the word says it forty times and the figure once. A screen
2070
- * reader gets one row at a time and no column, so a bare "€17.90" beside a time is a
2071
- * price with no qualifier at all.
1535
+ * A 401 on a call that CARRIED the session, and nothing else — see `setRefusedHandler`.
1536
+ * An app call refused under the app key says nothing about the buyer; read as a session
1537
+ * refusal it spent the refresh pair and signed a buyer out over an event read.
2072
1538
  */
2073
- from: "From"
2074
- };
2075
-
2076
- // src/island/PartyStepper.tsx
2077
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
2078
- function UserTypeRow({
2079
- option,
2080
- count,
2081
- atLimit,
2082
- onAdd,
2083
- onRemove,
2084
- onSet,
2085
- max,
2086
- onRefuse
2087
- }) {
2088
- return /* @__PURE__ */ jsxs("div", { className: "scopetickets-island-party-row", children: [
2089
- /* @__PURE__ */ jsxs("span", { className: "scopetickets-island-party-row__text", children: [
2090
- /* @__PURE__ */ jsx2("span", { className: "scopetickets-island-party-row__name", children: option.name }),
2091
- option.note !== null && /* @__PURE__ */ jsx2("span", { className: "scopetickets-island-party-row__note", children: option.note })
2092
- ] }),
2093
- /* @__PURE__ */ jsx2(
2094
- UserTypeStepper,
2095
- {
2096
- name: option.name,
2097
- count,
2098
- atLimit,
2099
- onAdd,
2100
- onRemove,
2101
- onSet,
2102
- max,
2103
- onRefuse
2104
- }
2105
- )
2106
- ] });
2107
- }
2108
- function UserTypeStepper({
2109
- name,
2110
- count,
2111
- atLimit,
2112
- onAdd,
2113
- onRemove,
2114
- onSet,
2115
- max,
2116
- onRefuse
2117
- }) {
2118
- const chosen = count > 0;
2119
- return /* @__PURE__ */ jsxs("span", { className: "scopetickets-island-stepper", "data-expanded": chosen ? "" : void 0, children: [
2120
- /* @__PURE__ */ jsx2(
2121
- "span",
2122
- {
2123
- className: "scopetickets-island-stepper__opening",
2124
- "aria-hidden": chosen ? void 0 : "true",
2125
- children: /* @__PURE__ */ jsxs("span", { className: "scopetickets-island-stepper__opening-inner", children: [
2126
- /* @__PURE__ */ jsx2(
2127
- StepperButton,
2128
- {
2129
- label: PARTY_COPY.remove(name),
2130
- onPress: onRemove,
2131
- kind: "remove",
2132
- state: chosen ? "LIVE" : "CLOSED"
2133
- }
2134
- ),
2135
- /* @__PURE__ */ jsx2(
2136
- TypedCount,
2137
- {
2138
- count,
2139
- name,
2140
- onSet,
2141
- valueClassName: "scopetickets-island-stepper__value",
2142
- inputClassName: "scopetickets-island-stepper__input",
2143
- closed: !chosen,
2144
- max,
2145
- onRefuse
2146
- }
2147
- )
2148
- ] })
1539
+ reportIfRefused(status, as) {
1540
+ if (status === 401 && as === "USER" && this.sessionAuthorization !== null) {
1541
+ this.onRefused?.();
1542
+ }
1543
+ }
1544
+ async fetch(endpoint, options, as = "APP") {
1545
+ const response = await fetch(`${this.config.apiUrl}${endpoint}`, {
1546
+ ...options,
1547
+ headers: {
1548
+ "Content-Type": "application/json",
1549
+ ...this.getAuthHeaders(as),
1550
+ ...options?.headers
2149
1551
  }
2150
- ),
2151
- /* @__PURE__ */ jsx2(
2152
- StepperButton,
2153
- {
2154
- label: PARTY_COPY.add(name),
2155
- onPress: onAdd,
2156
- kind: "add",
2157
- state: atLimit ? "REFUSING" : "LIVE"
1552
+ });
1553
+ if (!response.ok) {
1554
+ this.reportIfRefused(response.status, as);
1555
+ let errorResponse;
1556
+ try {
1557
+ errorResponse = await response.json();
1558
+ } catch (e) {
1559
+ console.error("Failed to parse API error response:", e);
1560
+ throw new ApiError("UnknownError", `API error: ${response.status} ${response.statusText}`);
2158
1561
  }
2159
- )
2160
- ] });
2161
- }
2162
- function StepperButton({
2163
- label,
2164
- onPress,
2165
- kind,
2166
- state = "LIVE"
2167
- }) {
2168
- const press = useIslandPress("element");
2169
- return /* @__PURE__ */ jsx2(
2170
- "button",
2171
- {
2172
- type: "button",
2173
- className: "scopetickets-island-stepper__button",
2174
- "data-kind": kind,
2175
- "aria-label": label,
2176
- "aria-disabled": state === "REFUSING" ? true : void 0,
2177
- disabled: state === "CLOSED",
2178
- onClick: state === "LIVE" ? onPress : void 0,
2179
- ...press,
2180
- children: /* @__PURE__ */ jsx2("span", { className: "scopetickets-island-stepper__mark", children: kind === "add" ? /* @__PURE__ */ jsx2(PlusMarkIcon, { fill: true, color: "currentColor" }) : /* @__PURE__ */ jsx2(MinusMarkIcon, { fill: true, color: "currentColor" }) })
1562
+ throw new ApiError(errorResponse.Reason, errorResponse.Message);
2181
1563
  }
2182
- );
2183
- }
2184
- function SoloPartyStepper({ max, name, count, onSet, onRemove, onRefuse }) {
2185
- return /* @__PURE__ */ jsxs("div", { className: "scopetickets-island-party-solo", children: [
2186
- /* @__PURE__ */ jsx2(
2187
- StepperButton,
2188
- {
2189
- label: PARTY_COPY.remove(name),
2190
- onPress: onRemove,
2191
- kind: "remove",
2192
- state: count === 0 ? "REFUSING" : "LIVE"
1564
+ const text = await response.text();
1565
+ if (!text) {
1566
+ return void 0;
1567
+ }
1568
+ try {
1569
+ return JSON.parse(text);
1570
+ } catch {
1571
+ return text;
1572
+ }
1573
+ }
1574
+ async fetchVoid(endpoint, options, as = "APP") {
1575
+ const response = await fetch(`${this.config.apiUrl}${endpoint}`, {
1576
+ ...options,
1577
+ headers: {
1578
+ "Content-Type": "application/json",
1579
+ ...this.getAuthHeaders(as),
1580
+ ...options?.headers
2193
1581
  }
2194
- ),
2195
- /* @__PURE__ */ jsx2(
2196
- TypedCount,
2197
- {
2198
- count,
2199
- name,
2200
- onSet,
2201
- valueClassName: "scopetickets-island-party-solo__value",
2202
- inputClassName: "scopetickets-island-party-solo__input",
2203
- max,
2204
- onRefuse
2205
- }
2206
- ),
2207
- /* @__PURE__ */ jsx2(
2208
- StepperButton,
2209
- {
2210
- label: PARTY_COPY.add(name),
2211
- onPress: () => onSet(count + 1),
2212
- kind: "add",
2213
- state: count >= max ? "REFUSING" : "LIVE"
1582
+ });
1583
+ if (!response.ok) {
1584
+ this.reportIfRefused(response.status, as);
1585
+ let errorResponse;
1586
+ try {
1587
+ errorResponse = await response.json();
1588
+ } catch (e) {
1589
+ console.error("Failed to parse API error response:", e);
1590
+ throw new ApiError("UnknownError", `API error: ${response.status} ${response.statusText}`);
2214
1591
  }
2215
- )
2216
- ] });
2217
- }
2218
- function TypedCount({
2219
- count,
2220
- name,
2221
- onSet,
2222
- valueClassName,
2223
- inputClassName,
2224
- onRefuse,
2225
- closed = false,
2226
- max
2227
- }) {
2228
- const [typing, setTyping] = useState2(null);
2229
- const field = useRef2(null);
2230
- const editing = typing !== null;
2231
- useEffect2(() => {
2232
- if (!editing) return;
2233
- field.current?.focus({ preventScroll: true });
2234
- }, [editing]);
2235
- const commit = () => {
2236
- if (typing === null) return;
2237
- const asked = Number.parseInt(typing, 10);
2238
- setTyping(null);
2239
- if (!Number.isFinite(asked)) return;
2240
- if (max !== void 0 && asked > max) {
2241
- onRefuse?.(asked);
2242
- return;
1592
+ throw new ApiError(errorResponse.Reason, errorResponse.Message);
2243
1593
  }
2244
- onRefuse?.(null);
2245
- onSet(Math.max(0, asked));
2246
- };
2247
- if (typing === null) {
2248
- return /* @__PURE__ */ jsx2(
2249
- "button",
2250
- {
2251
- type: "button",
2252
- className: valueClassName,
2253
- "aria-label": PARTY_COPY.count(count, name),
2254
- onClick: () => setTyping(String(count)),
2255
- disabled: closed,
2256
- children: count
2257
- }
2258
- );
2259
1594
  }
2260
- return /* @__PURE__ */ jsx2(
2261
- "input",
2262
- {
2263
- className: inputClassName,
2264
- type: "text",
2265
- inputMode: "numeric",
2266
- pattern: "[0-9]*",
2267
- size: 1,
2268
- ref: field,
2269
- "aria-label": PARTY_COPY.field(name),
2270
- value: typing,
2271
- onChange: (event) => setTyping(event.target.value.replace(/\D/g, "")),
2272
- onBlur: commit,
2273
- onKeyDown: (event) => {
2274
- if (event.key === "Enter") commit();
2275
- else if (event.key === "Escape") setTyping(null);
2276
- else return;
2277
- event.preventDefault();
2278
- event.stopPropagation();
2279
- }
2280
- }
2281
- );
2282
- }
2283
- function PartyStepper({
2284
- userTypes,
2285
- counts,
2286
- onChange,
2287
- max,
2288
- soloName = PARTY_COPY.soloName,
2289
- onRefuse,
2290
- refused = null
2291
- }) {
2292
- const headcount = Object.values(counts).reduce((total, n2) => total + n2, 0);
2293
- const refuse = (asked) => onRefuse?.(asked);
2294
- const shown = (count) => refused === null ? count : refused;
2295
- if (userTypes.length === 0) {
2296
- return /* @__PURE__ */ jsx2("div", { className: "scopetickets-island-party", "data-excess": refused === null ? void 0 : "", children: /* @__PURE__ */ jsx2(
2297
- SoloPartyStepper,
2298
- {
2299
- max,
2300
- name: soloName,
2301
- count: shown(headcount),
2302
- onSet: (next) => {
2303
- refuse(null);
2304
- onChange(SOLO_KEY, next);
2305
- },
2306
- onRemove: () => refused === null ? onChange(SOLO_KEY, Math.max(0, headcount - 1)) : (refuse(null), onChange(SOLO_KEY, max)),
2307
- onRefuse: refuse
2308
- }
2309
- ) });
1595
+ // ===========================================================================
1596
+ // v2 Events
1597
+ // ===========================================================================
1598
+ async getDisplayEvents(signal) {
1599
+ const response = await this.fetch("/api/v2/EventSummaries", { signal });
1600
+ return response.Events;
2310
1601
  }
2311
- return /* @__PURE__ */ jsx2("div", { className: "scopetickets-island-party", "data-excess": refused === null ? void 0 : "", children: userTypes.map((option) => /* @__PURE__ */ jsx2(
2312
- UserTypeRow,
2313
- {
2314
- option,
2315
- count: counts[option.key] ?? 0,
2316
- atLimit: headcount >= max,
2317
- onAdd: () => {
2318
- refuse(null);
2319
- onChange(option.key, (counts[option.key] ?? 0) + 1);
2320
- },
2321
- onRemove: () => {
2322
- refuse(null);
2323
- onChange(option.key, Math.max(0, (counts[option.key] ?? 0) - 1));
2324
- },
2325
- onSet: (next) => {
2326
- refuse(null);
2327
- onChange(option.key, next);
2328
- },
2329
- max,
2330
- onRefuse: refuse
2331
- },
2332
- option.key
2333
- )) });
2334
- }
2335
-
2336
- // src/island/DayPicker.tsx
2337
- import { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo2, useState as useState4 } from "react";
2338
-
2339
- // src/island/CalendarMonthHeading.tsx
2340
- import { jsx as jsx3 } from "react/jsx-runtime";
2341
- function CalendarMonthHeading({ month }) {
2342
- return /* @__PURE__ */ jsx3("h3", { className: "scopetickets-island-calendar__heading", children: formatMonthName(month) });
2343
- }
2344
-
2345
- // src/island/CalendarDayIndicator.tsx
2346
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
2347
- var SEGMENTS = 3;
2348
- var FILLED_SEGMENTS = {
2349
- LOW: 1,
2350
- MEDIUM: 2,
2351
- HIGH: 3
2352
- };
2353
- function CalendarDayIndicator({ level }) {
2354
- const filled = FILLED_SEGMENTS[level];
2355
- return (
2356
- // DECORATIVE, and now correctly so.
2357
- /* @__PURE__ */ jsxs2("span", { className: "scopetickets-island-day-indicator", "aria-hidden": "true", children: [
2358
- /* @__PURE__ */ jsx4(
2359
- "span",
2360
- {
2361
- className: `scopetickets-island-day-indicator__fill scopetickets-island-day-indicator__fill--${level.toLowerCase()}`,
2362
- style: { flexGrow: filled }
2363
- }
2364
- ),
2365
- filled < SEGMENTS ? /* @__PURE__ */ jsx4("span", { style: { flexGrow: SEGMENTS - filled } }) : null
2366
- ] })
2367
- );
2368
- }
2369
-
2370
- // src/island/CalendarDay.tsx
2371
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
2372
- function CalendarDay({
2373
- cell,
2374
- accessory,
2375
- remaining,
2376
- label,
2377
- outsideMonth = false,
2378
- onSelect
2379
- }) {
2380
- const press = useIslandPress("element");
2381
- const dimmed = outsideMonth ? { "data-outside-month": "" } : null;
2382
- if (cell.kind === "EMPTY") {
2383
- return /* @__PURE__ */ jsx5("span", { className: "scopetickets-island-day", "aria-hidden": "true" });
1602
+ async getEventInfo(eventKey, read) {
1603
+ return this.eventInformation("event", eventKey, read);
2384
1604
  }
2385
- if (isSelectableCalendarCell(cell)) {
2386
- return /* @__PURE__ */ jsx5(
2387
- CalendarDayButton,
2388
- {
2389
- cell,
2390
- accessory,
2391
- remaining,
2392
- label,
2393
- onSelect,
2394
- outsideMonth,
2395
- press
2396
- }
1605
+ async getSeriesInfo(seriesKey, read) {
1606
+ return this.eventInformation("series", seriesKey, read);
1607
+ }
1608
+ /**
1609
+ * `EventInformation`, for a run or a single event.
1610
+ *
1611
+ * `inventories` NARROWS THE RUN ITSELF, and the platform does the narrowing: the events
1612
+ * that sell nothing from those inventories are gone from `Events`, and the user types are
1613
+ * the ones those inventories' products assign. Repeated on the wire, like
1614
+ * `TicketInformation`'s — see `TicketInformationQuery.inventories`, which is the same
1615
+ * parameter on the other endpoint and the reason both are ANDed rather than substituted.
1616
+ */
1617
+ async eventInformation(type, key, read) {
1618
+ const params = new URLSearchParams({ type, key });
1619
+ for (const inventory of read?.inventories ?? []) params.append("inventories", inventory);
1620
+ return this.fetch(`/api/v2/EventInformation?${params}`, {
1621
+ signal: read?.signal
1622
+ });
1623
+ }
1624
+ /**
1625
+ * Tickets for any number of events or whole series in one request, each row naming the
1626
+ * events it sells for in `EventKeys`.
1627
+ *
1628
+ * THE ROUTE TO READ TICKETS FROM. `Events/{key}/Tickets` omits a timeslot at
1629
+ * `Remaining: 0` rather than reporting it sold out, so a sold-out session never reaches
1630
+ * the picker at all.
1631
+ *
1632
+ * A MISSPELT PARAMETER IS NOT REFUSED: the platform answers `200 {"Tickets":[]}`, which
1633
+ * reads exactly like an event that sells nothing.
1634
+ */
1635
+ async getTicketInformation(query, signal) {
1636
+ const params = new URLSearchParams();
1637
+ for (const key of query.events ?? []) params.append("events", key);
1638
+ for (const key of query.series ?? []) params.append("series", key);
1639
+ for (const key of query.inventories ?? []) params.append("inventories", key);
1640
+ if (query.includeTimeslots) params.set("include_timeslots", "true");
1641
+ if (query.includeQuestions) params.set("include_questions", "true");
1642
+ const response = await this.fetch(
1643
+ `/api/v2/TicketInformation?${params}`,
1644
+ { signal }
2397
1645
  );
1646
+ return response.Tickets ?? [];
2398
1647
  }
2399
- if (cell.kind === "UNAVAILABLE") {
2400
- return /* @__PURE__ */ jsx5(
2401
- CalendarDayButton,
2402
- {
2403
- cell,
2404
- accessory,
2405
- remaining: null,
2406
- label,
2407
- outsideMonth,
2408
- press
2409
- }
1648
+ /** @deprecated Use getTicketInformation(), which also reports sold-out timeslots */
1649
+ async getEventTickets(eventKey, signal) {
1650
+ const response = await this.fetch(
1651
+ `/api/v2/Events/${eventKey}/Tickets?include_timeslots=true`,
1652
+ { signal }
2410
1653
  );
1654
+ return response.Tickets;
2411
1655
  }
2412
- return /* @__PURE__ */ jsx5("span", { className: "scopetickets-island-day", ...dimmed, ...press, children: /* @__PURE__ */ jsx5("span", { className: "scopetickets-island-day__well", "data-state": cell.kind, children: /* @__PURE__ */ jsx5("span", { className: "scopetickets-island-day__number", children: cell.dayOfMonth }) }) });
2413
- }
2414
- function CalendarDayButton({
2415
- cell,
2416
- accessory,
2417
- remaining,
2418
- label,
2419
- outsideMonth = false,
2420
- press,
2421
- onSelect
2422
- }) {
2423
- const selected = cell.kind === "SELECTED";
2424
- const availability = readAvailability(remaining);
2425
- return /* @__PURE__ */ jsx5(
2426
- "button",
2427
- {
2428
- type: "button",
2429
- className: "scopetickets-island-day",
2430
- ...outsideMonth ? { "data-outside-month": "" } : null,
2431
- "aria-pressed": onSelect ? selected : void 0,
2432
- "aria-disabled": onSelect ? void 0 : true,
2433
- "aria-label": availability === null ? label : `${label}, ${availability.announcement}`,
2434
- onClick: onSelect ? () => onSelect(cell.day) : void 0,
2435
- ...press,
2436
- children: /* @__PURE__ */ jsxs3("span", { className: "scopetickets-island-day__well", "data-state": cell.kind, children: [
2437
- /* @__PURE__ */ jsx5("span", { className: "scopetickets-island-day__number", children: cell.dayOfMonth }),
2438
- cell.kind === "UNAVAILABLE" ? /* @__PURE__ */ jsx5("span", { className: "scopetickets-island-day__strike", "aria-hidden": "true" }) : null,
2439
- accessory === "LINE" && availability !== null ? /* @__PURE__ */ jsx5("span", { className: "scopetickets-island-day__accessory", children: /* @__PURE__ */ jsx5(CalendarDayIndicator, { level: availability.level }) }) : null
2440
- ] })
2441
- }
2442
- );
2443
- }
2444
-
2445
- // src/island/CalendarRunGrid.tsx
2446
- import { jsx as jsx6 } from "react/jsx-runtime";
2447
- function CalendarRunGrid({
2448
- series,
2449
- weeks,
2450
- currentMonth,
2451
- accessory,
2452
- remaining,
2453
- today,
2454
- selectedDay,
2455
- onSelectDay
2456
- }) {
2457
- return /* @__PURE__ */ jsx6("div", { className: "scopetickets-island-calendar__grid", children: weeks.map((weekStart) => (
2458
- // A presentational row: the seven columns are a layout, and announcing "row 3
2459
- // of 9" describes the grid rather than the run.
2460
- /* @__PURE__ */ jsx6("div", { className: "scopetickets-island-calendar__week", children: buildWeekRow(series, weekStart, { today, selectedDay }).map((cell, dayIndex) => /* @__PURE__ */ jsx6(
2461
- CalendarDay,
2462
- {
2463
- cell,
2464
- accessory,
2465
- remaining: cell.kind === "EMPTY" ? null : remaining?.[cell.day] ?? null,
2466
- label: cell.kind === "EMPTY" ? "" : formatDayDate(cell.day),
2467
- outsideMonth: cell.kind !== "EMPTY" && monthOfDay(cell.day) !== currentMonth,
2468
- onSelect: onSelectDay
2469
- },
2470
- cell.kind === "EMPTY" ? `empty-${dayIndex}` : cell.day
2471
- )) }, weekStart)
2472
- )) });
2473
- }
2474
-
2475
- // src/island/CalendarScroller.tsx
2476
- import {
2477
- useCallback,
2478
- useEffect as useEffect3,
2479
- useRef as useRef3,
2480
- useState as useState3
2481
- } from "react";
2482
- import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
2483
- var WHEEL_IDLE_MS = 200;
2484
- var CALENDAR_DRAG_SLOP = 4;
2485
- function CalendarScroller({
2486
- children,
2487
- rowCount,
2488
- row,
2489
- onRowChange,
2490
- onRowPreview,
2491
- label
2492
- }) {
2493
- const viewportRef = useRef3(null);
2494
- const trackRef = useRef3(null);
2495
- const startY = useRef3(null);
2496
- const [offset, setOffset] = useState3(0);
2497
- const [dragging, setDragging] = useState3(false);
2498
- const rowRef = useRef3(row);
2499
- rowRef.current = row;
2500
- const [rowStep, setRowStep] = useState3(0);
2501
- const gapPx = (box) => {
2502
- const gap = Number.parseFloat(
2503
- getComputedStyle(box).getPropertyValue("--scopetickets-island-day-column-gap")
2504
- );
2505
- return Number.isFinite(gap) ? gap : 0;
2506
- };
2507
- useEffect3(() => {
2508
- const track = trackRef.current;
2509
- if (!track) return void 0;
2510
- const measure = () => {
2511
- const row2 = track.querySelector(".scopetickets-island-calendar__week");
2512
- if (!row2) return;
2513
- const height = row2.getBoundingClientRect().height;
2514
- if (height <= 0) return;
2515
- const step = height + gapPx(track);
2516
- setRowStep((was) => Math.abs(was - step) < 0.5 ? was : step);
1656
+ // ===========================================================================
1657
+ // v1 Events (deprecated — kept for cart/timeslot compat)
1658
+ // ===========================================================================
1659
+ /** @deprecated Use getDisplayEvents() or getEventInfo() instead */
1660
+ async getEvents(count) {
1661
+ const params = count ? `?count=${count}` : "";
1662
+ return this.fetch(`/api/Events/ByOrganisationKey/${this.config.orgKey}${params}`);
1663
+ }
1664
+ /** @deprecated Use getEventTickets() instead */
1665
+ async getTickets(eventId) {
1666
+ return this.fetch(`/api/Ticket/Event/${eventId}`);
1667
+ }
1668
+ // ===========================================================================
1669
+ // Cart
1670
+ // ===========================================================================
1671
+ async createCart(eventId) {
1672
+ const body = typeof eventId === "string" ? { EventKey: eventId } : { EventId: eventId };
1673
+ return this.fetch("/api/Cart", {
1674
+ method: "POST",
1675
+ body: JSON.stringify(body)
1676
+ });
1677
+ }
1678
+ async getCart(cartKey) {
1679
+ return this.fetch(`/api/Cart/${cartKey}`);
1680
+ }
1681
+ async addToCart(cartKey, ticketId, timeslot) {
1682
+ const body = timeslot ? { Type: "ticket", ItemId: ticketId, Timeslot: timeslot } : { Type: "ticket", ItemId: ticketId };
1683
+ return this.fetch(`/api/Cart/${cartKey}/Items`, {
1684
+ method: "POST",
1685
+ body: JSON.stringify(body)
1686
+ });
1687
+ }
1688
+ async removeFromCart(cartKey, itemKey) {
1689
+ return this.fetch(`/api/Cart/${cartKey}/Items/${itemKey}`, {
1690
+ method: "DELETE"
1691
+ });
1692
+ }
1693
+ /**
1694
+ * WHETHER A CODE MAY BE USED, AND WHY NOT — the one call that answers the second half.
1695
+ *
1696
+ * THE `PUT` BELOW ONLY APPLIES. It refuses with an `ApiError` whose message is a
1697
+ * transport failure's message, which is not a sentence about a promo code; `Reason` here
1698
+ * is the platform's own words for an expired, spent or wrong-event code, and it is what
1699
+ * the card shows the buyer.
1700
+ *
1701
+ * `event_id` IS WHAT THE WIDGET KNOWS. The endpoint also narrows by ticket, series and
1702
+ * organisation; the cart carries its event and nothing else, so that is what is asked.
1703
+ */
1704
+ async checkPromoCode(promoCode, eventId) {
1705
+ const params = new URLSearchParams({ code: promoCode, event_id: String(eventId) });
1706
+ return this.fetch(`/api/PromoCode/Check?${params}`);
1707
+ }
1708
+ /**
1709
+ * PUT A PROMO CODE ON THE CART, and take back the cart it made — `TotalAmount` already
1710
+ * discounted, `DiscountAmount` saying by how much, `PromoCode` naming what did it.
1711
+ *
1712
+ * ONE PER CART, which is the wire's rule and not this client's: the field is a single
1713
+ * string, so a second code REPLACES the first rather than stacking on it.
1714
+ *
1715
+ * A REFUSED CODE IS AN `ApiError` like any other refusal — expired, spent, or for a
1716
+ * different event. The reason is the platform's own words; see `promoRefusal`, which is
1717
+ * the only thing allowed to put them in front of a buyer.
1718
+ */
1719
+ async setCartPromoCode(cartKey, promoCode) {
1720
+ return this.fetch(`/api/Cart/${encodeURIComponent(cartKey)}/PromoCode`, {
1721
+ method: "PUT",
1722
+ body: JSON.stringify({ PromoCode: promoCode })
1723
+ });
1724
+ }
1725
+ /** Take it off again, and the cart comes back at its full price. */
1726
+ async clearCartPromoCode(cartKey) {
1727
+ return this.fetch(`/api/Cart/${encodeURIComponent(cartKey)}/PromoCode`, {
1728
+ method: "DELETE"
1729
+ });
1730
+ }
1731
+ /**
1732
+ * `allowPartial` asks the platform to reserve what it can — see
1733
+ * `BulkAddItemsRequest.AllowPartialFulfillment`. OMITTED rather than sent as `false`
1734
+ * when it is not asked for: a body without it is what every caller already sends.
1735
+ */
1736
+ async addItemsBulk(cartKey, items, { allowPartial = false } = {}) {
1737
+ const body = {
1738
+ Items: items,
1739
+ ...allowPartial ? { AllowPartialFulfillment: true } : {}
2517
1740
  };
2518
- measure();
2519
- if (typeof ResizeObserver === "undefined") return void 0;
2520
- const observer = new ResizeObserver(measure);
2521
- observer.observe(track);
2522
- return () => observer.disconnect();
2523
- }, [rowCount]);
2524
- const rowHeight = useCallback(() => {
2525
- if (rowStep > 0) return rowStep;
2526
- const box = viewportRef.current;
2527
- if (!box) return 0;
2528
- return (box.clientHeight + gapPx(box)) / CALENDAR_VIEWPORT_ROWS;
2529
- }, [rowStep]);
2530
- const drag = useCallback(
2531
- (dy) => ({
2532
- row: rowRef.current,
2533
- rowCount,
2534
- viewportRows: CALENDAR_VIEWPORT_ROWS,
2535
- offset: dy,
2536
- rowHeight: rowHeight()
2537
- }),
2538
- [rowCount, rowHeight]
2539
- );
2540
- const draw = useCallback(
2541
- (dy) => {
2542
- const moving = drag(dy);
2543
- setOffset(rowDragOffset(moving));
2544
- onRowPreview?.(rowAfterDrag(moving));
2545
- },
2546
- [drag, onRowPreview]
2547
- );
2548
- const settle = useCallback(
2549
- (dy) => {
2550
- setOffset(0);
2551
- const landed = rowAfterDrag(drag(dy));
2552
- if (landed !== rowRef.current) onRowChange(landed);
2553
- },
2554
- [drag, onRowChange]
2555
- );
2556
- const dragged = useRef3(false);
2557
- const onPointerDown = (event) => {
2558
- if ((event.buttons & 1) !== 1) return;
2559
- startY.current = event.clientY;
2560
- dragged.current = false;
2561
- };
2562
- const onPointerMove = (event) => {
2563
- if (startY.current === null) return;
2564
- const dy = event.clientY - startY.current;
2565
- if (!dragged.current) {
2566
- if (Math.abs(dy) < CALENDAR_DRAG_SLOP) return;
2567
- dragged.current = true;
2568
- setDragging(true);
2569
- event.currentTarget.setPointerCapture(event.pointerId);
2570
- }
2571
- draw(dy);
2572
- };
2573
- const onPointerUp = (event) => {
2574
- if (startY.current === null) return;
2575
- const dy = event.clientY - startY.current;
2576
- startY.current = null;
2577
- if (!dragged.current) return;
2578
- setDragging(false);
2579
- settle(dy);
2580
- };
2581
- const onClickCapture = (event) => {
2582
- if (!dragged.current) return;
2583
- dragged.current = false;
2584
- event.stopPropagation();
2585
- event.preventDefault();
2586
- };
2587
- const onPointerCancel = () => {
2588
- startY.current = null;
2589
- dragged.current = false;
2590
- setDragging(false);
2591
- setOffset(0);
2592
- };
2593
- const wheel = useRef3(0);
2594
- const settleTimer = useRef3(null);
2595
- useEffect3(() => {
2596
- const viewport = viewportRef.current;
2597
- if (!viewport) return void 0;
2598
- const onWheel = (event) => {
2599
- event.preventDefault();
2600
- wheel.current -= event.deltaY;
2601
- wheel.current = rowDragOffset(drag(wheel.current));
2602
- draw(wheel.current);
2603
- if (settleTimer.current !== null) window.clearTimeout(settleTimer.current);
2604
- settleTimer.current = window.setTimeout(() => {
2605
- settleTimer.current = null;
2606
- const travelled = wheel.current;
2607
- wheel.current = 0;
2608
- settle(travelled);
2609
- }, WHEEL_IDLE_MS);
1741
+ return this.fetch(`/api/v2/Carts/${cartKey}/Items`, {
1742
+ method: "POST",
1743
+ body: JSON.stringify(body)
1744
+ });
1745
+ }
1746
+ // ===========================================================================
1747
+ // Questionnaire
1748
+ // ===========================================================================
1749
+ async getQuestionnaireQuestions(eventId, signal) {
1750
+ return this.fetch(`/api/Questionnaires/Events/${eventId}/Questions`, {
1751
+ signal
1752
+ });
1753
+ }
1754
+ // ── Passcodes ──────────────────────────────────────────────────────────
1755
+ //
1756
+ // @Zsolt — AUTH SURFACE. Transport only: these three make the calls and return what
1757
+ // comes back. Which of them runs when, and what a failure means, is the account
1758
+ // flow's business — see `domain/passcode.ts` in @scopetickets/checkout.
1759
+ /** Sends a verification code to an address. */
1760
+ async sendEmailPasscode(body) {
1761
+ return this.fetch("/api/Passcodes/Email", {
1762
+ method: "POST",
1763
+ body: JSON.stringify(body)
1764
+ });
1765
+ }
1766
+ /** Submits the code the buyer typed. */
1767
+ async verifyPasscode(body) {
1768
+ await this.fetch("/api/Passcodes/Verification", {
1769
+ method: "POST",
1770
+ body: JSON.stringify(body)
1771
+ });
1772
+ }
1773
+ /**
1774
+ * Reads whether a passcode has been verified.
1775
+ *
1776
+ * The authoritative answer, and separate from `verifyPasscode` on purpose: a code
1777
+ * submitted in another tab, or on the phone the mail arrived on, is verified without
1778
+ * this browser ever having posted it.
1779
+ */
1780
+ async getPasscodeStatus(passcodeKey) {
1781
+ return this.fetch(
1782
+ `/api/Passcodes/${encodeURIComponent(passcodeKey)}/Status`
1783
+ );
1784
+ }
1785
+ async submitQuestionnaireResponses(cartKey, body) {
1786
+ return this.fetch(`/api/Cart/${cartKey}/Questionnaires/Responses`, {
1787
+ method: "POST",
1788
+ body: JSON.stringify(body)
1789
+ });
1790
+ }
1791
+ async setBuyer(cartKey, buyer) {
1792
+ return this.fetch(`/api/Cart/${cartKey}/Buyer`, {
1793
+ method: "POST",
1794
+ body: JSON.stringify(buyer)
1795
+ });
1796
+ }
1797
+ async getBuyer(cartKey) {
1798
+ return this.fetch(`/api/Cart/${cartKey}/Buyer`);
1799
+ }
1800
+ async deleteCart(cartKey) {
1801
+ return this.fetchVoid(`/api/Cart/${cartKey}`, {
1802
+ method: "DELETE"
1803
+ });
1804
+ }
1805
+ // ===========================================================================
1806
+ // Payment
1807
+ // ===========================================================================
1808
+ async createPaymentIntent(cartKey, options) {
1809
+ const retryQuery = options?.retry ? "?retry=true" : "";
1810
+ return this.fetch(`/api/Cart/${cartKey}/Payment${retryQuery}`, {
1811
+ method: "POST"
1812
+ });
1813
+ }
1814
+ async getPaymentStatus(cartKey) {
1815
+ return this.fetch(`/api/Cart/${cartKey}/Payment/Status`);
1816
+ }
1817
+ // ===========================================================================
1818
+ // Transactions
1819
+ // ===========================================================================
1820
+ async convertCartToTransaction(cartKey) {
1821
+ return this.fetch("/api/Transactions/FromCart", {
1822
+ method: "POST",
1823
+ body: JSON.stringify({ CartKey: cartKey })
1824
+ });
1825
+ }
1826
+ async getTransactionItems(transactionKey) {
1827
+ return this.fetch(`/api/Transactions/${transactionKey}/Items`);
1828
+ }
1829
+ async getTransactionByCartKey(cartKey) {
1830
+ return this.fetch(`/api/Transactions/ByKey/${cartKey}`);
1831
+ }
1832
+ // ===========================================================================
1833
+ // Attendees
1834
+ // ===========================================================================
1835
+ /**
1836
+ * AMENDS ATTENDEES A TRANSACTION ALREADY OWNS, and refuses everything else with
1837
+ * `AttendeesNotMatchingTransaction`. It cannot create one — the v2 `setItemAttendee`
1838
+ * below is what a first naming goes through.
1839
+ *
1840
+ * THE TRANSACTION-WIDE CALL, and `packages/sdk`'s ticket-confirmation flow still wants
1841
+ * it: it amends an attendee that already exists (buyer-as-holder on a portal-style
1842
+ * purchase) and declines politely where none does. New code should prefer the
1843
+ * key-addressed call, which needs no id read first and cannot erase anybody by omission.
1844
+ */
1845
+ async saveAttendees(transactionKey, attendees) {
1846
+ return this.fetch(`/api/Transactions/${transactionKey}/Attendees`, {
1847
+ method: "PUT",
1848
+ body: JSON.stringify(attendees)
1849
+ });
1850
+ }
1851
+ /**
1852
+ * WHO A TICKET IS FOR — creating the attendee where there is none and rebinding the
1853
+ * ticket where there is, addressed by keys on both counts.
1854
+ *
1855
+ * The route takes the TRANSACTION's key and the ITEM's — the same value the bulk add
1856
+ * returned as `item_key` and the booking reads as `AttendeeTicketKey` — so there is no
1857
+ * attendee id to have read first and nothing integer-shaped on the wire. The platform
1858
+ * scopes the item to the transaction and refuses a pair that does not match with
1859
+ * `ItemNotFound`.
1860
+ *
1861
+ * Answers `204`-shaped success with no body: the call either went or it did not, and the
1862
+ * name it saved is read back on the next booking read rather than off the response.
1863
+ */
1864
+ async setItemAttendee(transactionKey, itemKey, body) {
1865
+ await this.fetchVoid(`/api/v2/Transactions/${transactionKey}/Items/${itemKey}/Attendee`, {
1866
+ method: "PUT",
1867
+ body: JSON.stringify(body)
1868
+ });
1869
+ }
1870
+ // ===========================================================================
1871
+ // Accounts
1872
+ // ===========================================================================
1873
+ //
1874
+ // Transport only: these make the calls and return what comes back. WHICH of them runs
1875
+ // when, and what a failure means, is the account flow's business — see `domain/auth.ts`
1876
+ // and `domain/account-creation.ts` in @scopetickets/checkout.
1877
+ /**
1878
+ * Makes an account, and signs into it.
1879
+ *
1880
+ * `LoginUser` defaults to `true` here and is omitted from the type's own default,
1881
+ * because every caller in this workspace wants the session: an account created without
1882
+ * one leaves the buyer holding credentials they would then have to spend immediately.
1883
+ */
1884
+ async createAccount(body) {
1885
+ return this.fetch("/api/Users", {
1886
+ method: "POST",
1887
+ body: JSON.stringify({ LoginUser: true, ...body })
1888
+ });
1889
+ }
1890
+ /** An address and a password. */
1891
+ async signIn(body) {
1892
+ return this.fetch("/api/Auth/Login", {
1893
+ method: "POST",
1894
+ body: JSON.stringify(body)
1895
+ });
1896
+ }
1897
+ /** Ends the session at the platform. The caller still has to forget its own copy. */
1898
+ async signOut() {
1899
+ return this.fetch("/api/Auth/Logout", void 0, "USER");
1900
+ }
1901
+ /**
1902
+ * A fresh `Authorization` for a session that still holds its refresh token.
1903
+ *
1904
+ * The answer carries no new refresh token, so the one held is spent again rather than
1905
+ * rotated.
1906
+ */
1907
+ async refreshAuthorization(body) {
1908
+ return this.fetch("/api/Auth/Tokens", {
1909
+ method: "POST",
1910
+ body: JSON.stringify(body)
1911
+ });
1912
+ }
1913
+ /**
1914
+ * WHO THE SESSION BELONGS TO. The one call that turns a header into a person: every
1915
+ * door into an account answers with a `LoginResult` carrying no name, no address and no
1916
+ * key, so this is what the flow asks immediately after one opens.
1917
+ *
1918
+ * IT NEEDS A USER SESSION, not merely the app key. Measured against staging: with no
1919
+ * `Authorization` at all it answers `401 NotAuthorized`, and with the app key alone it
1920
+ * answers `500` — so `hasAuthorization` gates the call rather than the answer being
1921
+ * read for which of the two happened.
1922
+ */
1923
+ async getCurrentUser(signal) {
1924
+ return this.fetch("/api/Users/Me", { signal }, "USER");
1925
+ }
1926
+ /** The signed-in user's own details. */
1927
+ async updateUser(body) {
1928
+ return this.fetchVoid("/api/Users", { method: "PUT", body: JSON.stringify(body) }, "USER");
1929
+ }
1930
+ /** Changes the password of the signed-in user, who therefore knows the old one. */
1931
+ async updatePassword(body) {
1932
+ return this.fetchVoid(
1933
+ "/api/Users/Password",
1934
+ { method: "PUT", body: JSON.stringify(body) },
1935
+ "USER"
1936
+ );
1937
+ }
1938
+ /** Starts recovery for somebody who cannot sign in. Needs no session, by definition. */
1939
+ async requestPasswordReset(body) {
1940
+ return this.fetchVoid("/api/Users/PasswordReset", {
1941
+ method: "POST",
1942
+ body: JSON.stringify(body)
1943
+ });
1944
+ }
1945
+ /** Sets the signed-in user's photo. Needs the session, so it runs after creation. */
1946
+ async updatePhoto(body) {
1947
+ return this.fetchVoid(
1948
+ "/api/Users/Photo",
1949
+ { method: "PUT", body: JSON.stringify(body) },
1950
+ "USER"
1951
+ );
1952
+ }
1953
+ // ===========================================================================
1954
+ // Following
1955
+ // ===========================================================================
1956
+ async getFollowing(userKey, signal) {
1957
+ return this.fetch(
1958
+ `/api/Users/${encodeURIComponent(userKey)}/Following`,
1959
+ {
1960
+ signal
1961
+ },
1962
+ "USER"
1963
+ );
1964
+ }
1965
+ async followOrganisation(userKey, body) {
1966
+ return this.fetchVoid(
1967
+ `/api/Users/${encodeURIComponent(userKey)}/Following/Organisation`,
1968
+ {
1969
+ method: "POST",
1970
+ body: JSON.stringify(body)
1971
+ },
1972
+ "USER"
1973
+ );
1974
+ }
1975
+ async unfollowOrganisation(userKey, organisationKey) {
1976
+ return this.fetchVoid(
1977
+ `/api/Users/${encodeURIComponent(userKey)}/Following/Organisation/${encodeURIComponent(organisationKey)}`,
1978
+ { method: "DELETE" },
1979
+ "USER"
1980
+ );
1981
+ }
1982
+ async followVenue(userKey, body) {
1983
+ return this.fetchVoid(
1984
+ `/api/Users/${encodeURIComponent(userKey)}/Following/Venue`,
1985
+ {
1986
+ method: "POST",
1987
+ body: JSON.stringify(body)
1988
+ },
1989
+ "USER"
1990
+ );
1991
+ }
1992
+ async unfollowVenue(userKey, venueKey) {
1993
+ return this.fetchVoid(
1994
+ `/api/Users/${encodeURIComponent(userKey)}/Following/Venue/${encodeURIComponent(venueKey)}`,
1995
+ { method: "DELETE" },
1996
+ "USER"
1997
+ );
1998
+ }
1999
+ // ===========================================================================
2000
+ // Passkeys
2001
+ // ===========================================================================
2002
+ //
2003
+ // Four calls and no ceremony. The browser half cannot run in a page a customer serves —
2004
+ // see `packages/passkey-host` — so these hand challenges out and take credentials back,
2005
+ // and something on a Scope origin does the part in between.
2006
+ /** Opens a registration. Names nobody: the user comes from the session. */
2007
+ async createPasskeyRegistrationChallenge(body) {
2008
+ return this.fetch(
2009
+ "/api/Passkeys/Registrations/Challenges",
2010
+ {
2011
+ method: "POST",
2012
+ body: JSON.stringify(body)
2013
+ },
2014
+ "USER"
2015
+ );
2016
+ }
2017
+ /** Lodges the credential the device made. */
2018
+ async registerPasskey(body) {
2019
+ return this.fetchVoid(
2020
+ "/api/Passkeys/Registrations",
2021
+ {
2022
+ method: "POST",
2023
+ body: JSON.stringify(body)
2024
+ },
2025
+ "USER"
2026
+ );
2027
+ }
2028
+ /** Opens a sign-in. Needs no session — proving who you are is the point of it. */
2029
+ async createPasskeyAuthenticationChallenge(body) {
2030
+ return this.fetch("/api/Passkeys/Authentications/Challenges", {
2031
+ method: "POST",
2032
+ body: JSON.stringify(body)
2033
+ });
2034
+ }
2035
+ /** Spends the assertion, and opens a session with it. */
2036
+ async authenticateWithPasskey(body) {
2037
+ return this.fetch("/api/Passkeys/Authentications", {
2038
+ method: "POST",
2039
+ body: JSON.stringify(body)
2040
+ });
2041
+ }
2042
+ // ===========================================================================
2043
+ // Feedback
2044
+ // ===========================================================================
2045
+ /**
2046
+ * How the buyer rated a ticket. Answers 200 and nothing else, so there is no receipt
2047
+ * to hold on to — the call either went or it did not.
2048
+ */
2049
+ async submitFeedback(body) {
2050
+ return this.fetchVoid("/api/Feedback", { method: "POST", body: JSON.stringify(body) });
2051
+ }
2052
+ // ===========================================================================
2053
+ // Utilities
2054
+ // ===========================================================================
2055
+ /**
2056
+ * SEND ONE TICKET TO AN ADDRESS — the platform's own email, to whoever the buyer names.
2057
+ *
2058
+ * `template` IS OMITTED ON PURPOSE. The parameter takes a free string, the spec documents
2059
+ * no values for it and nothing else in the API names one; left off, the platform sends
2060
+ * its default. Conall, 2026-09-13.
2061
+ *
2062
+ * IT IS A `GET` THAT SENDS MAIL, which is the platform's shape and not a choice made
2063
+ * here. A `GET` is the one method browsers, proxies, prefetchers and generic retry layers
2064
+ * treat as free to repeat, so at-most-once cannot be delegated to any of them: every
2065
+ * caller has to fire this from one deliberate press and never from anything that can
2066
+ * re-run. See `sendTicket` in the booking gateway, which is the only caller.
2067
+ */
2068
+ async sendTicketEmail(attendeeTicketId, email) {
2069
+ const params = new URLSearchParams({
2070
+ email,
2071
+ attendee_ticket_id: String(attendeeTicketId)
2072
+ });
2073
+ await this.fetch(`/api/AttendeeTicket/SendSingleEmail?${params}`);
2074
+ }
2075
+ /**
2076
+ * WHERE A TICKET'S APPLE WALLET PASS IS SERVED — a URL, not a fetch.
2077
+ *
2078
+ * THE BROWSER HAS TO NAVIGATE TO IT. Safari only offers a pass to Wallet when it arrives
2079
+ * as a download with Apple's media type, so there is nothing here to read and hand on: a
2080
+ * pass fetched into script and re-served from a `blob:` is not reliably offered on iOS.
2081
+ * It is the same link the platform's own ticket emails carry, and it needs no
2082
+ * authorization, which is why none is attached.
2083
+ */
2084
+ applePassUrl(attendeeTicketKey) {
2085
+ const params = new URLSearchParams({ attendee_ticket_key: attendeeTicketKey });
2086
+ return `${this.config.apiUrl}/api/Wallet/ApplePass?${params}`;
2087
+ }
2088
+ async getQrCode(content, foreground = "000000", background = "FFFFFF") {
2089
+ const params = new URLSearchParams({
2090
+ content,
2091
+ foreground,
2092
+ background,
2093
+ drawQuietZone: "false"
2094
+ });
2095
+ return this.fetch(`/api/Utils/GetQrCodeAsSVG?${params}`);
2096
+ }
2097
+ };
2098
+
2099
+ // ../api/src/payment-protocol/parent.ts
2100
+ var CARRIED_CHECKOUT_PARAMS = ["event", "eventKey"];
2101
+ function buildFrameUrl(hostUrl, cartKey, identity, options) {
2102
+ const url = new URL(`/checkout/${cartKey}`, hostUrl);
2103
+ url.searchParams.set("method", identity.method);
2104
+ url.searchParams.set("instanceId", identity.instanceId);
2105
+ if (options.checkoutSessionId !== void 0)
2106
+ url.searchParams.set("checkoutSessionId", options.checkoutSessionId);
2107
+ url.searchParams.set("displayMode", "prewarm");
2108
+ url.searchParams.set("origin", options.parentOrigin);
2109
+ if (options.debug === true) url.searchParams.set("scopePaymentDebug", "1");
2110
+ if (options.retry === true) url.searchParams.set("paymentRetry", "1");
2111
+ for (const name of options.carriedParams ?? []) {
2112
+ const value = options.parentSearchParams?.get(name);
2113
+ if (value) url.searchParams.set(name, value);
2114
+ }
2115
+ return url.toString();
2116
+ }
2117
+ function allowedFrameOrigin(hostUrl) {
2118
+ try {
2119
+ return new URL(hostUrl).origin;
2120
+ } catch {
2121
+ return hostUrl;
2122
+ }
2123
+ }
2124
+ var PAYMENT_DIAGNOSTIC_EVENTS = /* @__PURE__ */ new Set([
2125
+ "revolut.provider_init_started",
2126
+ "revolut.provider_init_finished",
2127
+ "revolut.provider_init_failed",
2128
+ "revolut.button_pressed",
2129
+ "revolut.create_order_callback_started",
2130
+ "revolut.create_order_callback_returned",
2131
+ "revolut.inline_journey_detected",
2132
+ "revolut.external_handoff_detected",
2133
+ "revolut.detector_state"
2134
+ ]);
2135
+ var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2136
+ function parsePaymentDiagnostic(value) {
2137
+ if (!isPlainObject(value)) return null;
2138
+ const payload = value;
2139
+ if (typeof payload.event !== "string" || !PAYMENT_DIAGNOSTIC_EVENTS.has(payload.event))
2140
+ return null;
2141
+ const sourceData = isPlainObject(payload.data) ? payload.data : void 0;
2142
+ const data = {};
2143
+ if (sourceData?.paymentHostClass === "local_tunnel" || sourceData?.paymentHostClass === "other") {
2144
+ data.paymentHostClass = sourceData.paymentHostClass;
2145
+ }
2146
+ if (typeof sourceData?.active === "boolean") data.active = sourceData.active;
2147
+ if (typeof sourceData?.tokenPresent === "boolean") data.tokenPresent = sourceData.tokenPresent;
2148
+ if (typeof sourceData?.errorType === "string" && /^[A-Za-z][A-Za-z0-9]{0,63}$/.test(sourceData.errorType)) {
2149
+ data.errorType = sourceData.errorType;
2150
+ }
2151
+ if (sourceData?.evidence === "provider_frame_loaded" || sourceData?.evidence === "provider_frame_replaced" || sourceData?.evidence === "mobile_inline_provisional") {
2152
+ data.evidence = sourceData.evidence;
2153
+ }
2154
+ if (typeof sourceData?.generation === "number" && Number.isSafeInteger(sourceData.generation)) {
2155
+ data.generation = sourceData.generation;
2156
+ }
2157
+ if (typeof sourceData?.mobile === "boolean") data.mobile = sourceData.mobile;
2158
+ if (typeof sourceData?.visible === "boolean") data.visible = sourceData.visible;
2159
+ if (sourceData?.state === "initialized" || sourceData?.state === "attempt_started" || sourceData?.state === "order_returned" || sourceData?.state === "inline_provisional" || sourceData?.state === "external_handoff" || sourceData?.state === "disconnected") {
2160
+ data.state = sourceData.state;
2161
+ }
2162
+ if (sourceData?.reason === "not_mobile" || sourceData?.reason === "no_attempt" || sourceData?.reason === "terminal" || sourceData?.reason === "external_handoff" || sourceData?.reason === "hidden") {
2163
+ data.reason = sourceData.reason;
2164
+ }
2165
+ return { event: payload.event, ...Object.keys(data).length > 0 ? { data } : {} };
2166
+ }
2167
+ function parsePaymentPresentation(value, expectedInstanceId, latestGeneration) {
2168
+ if (!isPlainObject(value)) return null;
2169
+ const payload = value;
2170
+ if (payload.instanceId !== expectedInstanceId || payload.method !== "revolut_pay" || payload.mode !== "inline_provisional" && payload.mode !== "external_handoff" || typeof payload.attemptGeneration !== "number" || !Number.isSafeInteger(payload.attemptGeneration) || payload.attemptGeneration <= 0 || payload.attemptGeneration < latestGeneration) {
2171
+ return null;
2172
+ }
2173
+ return {
2174
+ instanceId: payload.instanceId,
2175
+ method: payload.method,
2176
+ mode: payload.mode,
2177
+ attemptGeneration: payload.attemptGeneration
2178
+ };
2179
+ }
2180
+ function parseFrameEvent(event, expected) {
2181
+ if (expected.source == null || event.origin !== expected.allowedOrigin || event.source !== expected.source || !isPlainObject(event.data))
2182
+ return null;
2183
+ const { type } = event.data;
2184
+ if (typeof type !== "string" || !type.startsWith("SCOPE_PAYMENT_")) return null;
2185
+ const payload = isPlainObject(event.data.payload) ? event.data.payload : {};
2186
+ if (payload.instanceId !== void 0 && payload.instanceId !== expected.identity.instanceId)
2187
+ return null;
2188
+ if (payload.method !== void 0 && payload.method !== expected.identity.method) return null;
2189
+ const frameMessage = { type, payload };
2190
+ switch (type) {
2191
+ case "SCOPE_PAYMENT_READY":
2192
+ case "SCOPE_PAYMENT_CONFIG_REQUESTED":
2193
+ case "SCOPE_PAYMENT_CANCELLED":
2194
+ case "SCOPE_PAYMENT_SUBMIT_REQUESTED":
2195
+ return frameMessage;
2196
+ case "SCOPE_PAYMENT_RESIZE":
2197
+ if (typeof payload.height !== "number" || !Number.isFinite(payload.height)) return null;
2198
+ return frameMessage;
2199
+ case "SCOPE_PAYMENT_SUCCESS":
2200
+ if (typeof payload.cartKey !== "string" || !payload.cartKey) return null;
2201
+ return frameMessage;
2202
+ case "SCOPE_PAYMENT_ERROR":
2203
+ if (typeof payload.code !== "string" || typeof payload.message !== "string") return null;
2204
+ return frameMessage;
2205
+ case "SCOPE_PAYMENT_METHOD_STATUS":
2206
+ if (typeof payload.ready !== "boolean") return null;
2207
+ if (payload.wallet !== void 0 && payload.wallet !== "applePay" && payload.wallet !== "googlePay")
2208
+ return null;
2209
+ return frameMessage;
2210
+ case "SCOPE_PAYMENT_DIAGNOSTIC": {
2211
+ const diagnostic = parsePaymentDiagnostic(payload);
2212
+ return diagnostic === null ? null : { type, payload: diagnostic };
2213
+ }
2214
+ case "SCOPE_PAYMENT_PRESENTATION": {
2215
+ const presentation = parsePaymentPresentation(payload, expected.identity.instanceId, 0);
2216
+ return presentation === null ? null : { type, payload: presentation };
2217
+ }
2218
+ default:
2219
+ return null;
2220
+ }
2221
+ }
2222
+ function buildConfigMessage(identity, config) {
2223
+ return {
2224
+ type: "SCOPE_PAYMENT_CONFIG",
2225
+ payload: {
2226
+ ...config.apiKey === void 0 ? {} : { apiKey: config.apiKey },
2227
+ ...config.selectedMethod === void 0 ? {} : { selectedMethod: config.selectedMethod },
2228
+ ...config.theme === void 0 ? {} : { theme: config.theme },
2229
+ instanceId: identity.instanceId,
2230
+ method: identity.method
2231
+ }
2232
+ };
2233
+ }
2234
+ function buildSubmitConfirmedMessage(identity, buyer) {
2235
+ return {
2236
+ type: "SCOPE_PAYMENT_SUBMIT_CONFIRMED",
2237
+ payload: { ...buyer, instanceId: identity.instanceId, method: identity.method }
2238
+ };
2239
+ }
2240
+ function buildSubmitRejectedMessage(identity, reason) {
2241
+ return {
2242
+ type: "SCOPE_PAYMENT_SUBMIT_REJECTED",
2243
+ payload: { reason, instanceId: identity.instanceId, method: identity.method }
2244
+ };
2245
+ }
2246
+ function buildTriggerSubmitMessage(identity) {
2247
+ return {
2248
+ type: "SCOPE_PAYMENT_TRIGGER_SUBMIT",
2249
+ payload: { instanceId: identity.instanceId, method: identity.method }
2250
+ };
2251
+ }
2252
+ function buildCancelRequestedMessage(identity) {
2253
+ return {
2254
+ type: "SCOPE_PAYMENT_CANCEL_REQUESTED",
2255
+ payload: { instanceId: identity.instanceId, method: identity.method }
2256
+ };
2257
+ }
2258
+
2259
+ // ../api/src/buyer.ts
2260
+ var MAX_EMAIL_LENGTH = 254;
2261
+ var MAX_LOCAL_LENGTH = 64;
2262
+ var MAX_LABEL_LENGTH = 63;
2263
+ var MAX_DOMAIN_LENGTH = 255;
2264
+ var LOCAL_PART = /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*$/;
2265
+ var DOMAIN_LABEL = /^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?$/;
2266
+ var TOP_LEVEL_LABEL = /^[A-Za-z]{2,}$/;
2267
+ function isAcceptableEmail(value) {
2268
+ const email = value.trim();
2269
+ if (email.length === 0 || email.length > MAX_EMAIL_LENGTH) return false;
2270
+ const at = email.lastIndexOf("@");
2271
+ if (at <= 0 || at === email.length - 1) return false;
2272
+ const local = email.slice(0, at);
2273
+ if (local.length > MAX_LOCAL_LENGTH || !LOCAL_PART.test(local)) return false;
2274
+ const domain = email.slice(at + 1);
2275
+ if (domain.length > MAX_DOMAIN_LENGTH) return false;
2276
+ const labels = domain.split(".");
2277
+ if (labels.length < 2) return false;
2278
+ if (labels.some((label) => label.length > MAX_LABEL_LENGTH || !DOMAIN_LABEL.test(label))) {
2279
+ return false;
2280
+ }
2281
+ return TOP_LEVEL_LABEL.test(labels[labels.length - 1]);
2282
+ }
2283
+ var E164 = /^\+[1-9]\d{1,14}$/;
2284
+ function isE164(value) {
2285
+ return E164.test(value.trim());
2286
+ }
2287
+ var CONTROL_CHARACTERS = /[\x00-\x1F\x7F]/;
2288
+ function isAcceptableName(value) {
2289
+ const name = value.trim();
2290
+ return name.length > 0 && name.length <= 256 && !CONTROL_CHARACTERS.test(name);
2291
+ }
2292
+
2293
+ // ../api/src/email-typos.ts
2294
+ var KNOWN_DOMAINS = [
2295
+ "gmail.com",
2296
+ "googlemail.com",
2297
+ "icloud.com",
2298
+ "me.com",
2299
+ "mac.com",
2300
+ "mail.com",
2301
+ "hotmail.com",
2302
+ "outlook.com",
2303
+ "live.com",
2304
+ "yahoo.com",
2305
+ "aol.com",
2306
+ "proton.me",
2307
+ "protonmail.com",
2308
+ "eircom.net"
2309
+ ];
2310
+ var NEAR_MISS_TARGETS = [
2311
+ "gmail.com",
2312
+ "googlemail.com",
2313
+ "icloud.com",
2314
+ "hotmail.com",
2315
+ "outlook.com",
2316
+ "yahoo.com",
2317
+ "protonmail.com",
2318
+ "eircom.net"
2319
+ ];
2320
+ var MIN_DISTINCTIVE_BODY = 4;
2321
+ var TOP_LEVEL_SLIPS = {
2322
+ co: "com",
2323
+ con: "com",
2324
+ cim: "com",
2325
+ cmo: "com",
2326
+ ocm: "com",
2327
+ comm: "com",
2328
+ coom: "com",
2329
+ cpm: "com",
2330
+ vom: "com",
2331
+ xom: "com",
2332
+ nte: "net",
2333
+ ner: "net",
2334
+ ogr: "org",
2335
+ orh: "org"
2336
+ };
2337
+ function editDistance(a, b) {
2338
+ const columns = b.length + 1;
2339
+ const d = new Uint16Array((a.length + 1) * columns);
2340
+ for (let j = 0; j < columns; j += 1) d[j] = j;
2341
+ for (let i = 1; i <= a.length; i += 1) {
2342
+ const row = i * columns;
2343
+ const previous = row - columns;
2344
+ d[row] = i;
2345
+ for (let j = 1; j <= b.length; j += 1) {
2346
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
2347
+ let best = Math.min(
2348
+ (d[previous + j] ?? 0) + 1,
2349
+ (d[row + j - 1] ?? 0) + 1,
2350
+ (d[previous + j - 1] ?? 0) + cost
2351
+ );
2352
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
2353
+ best = Math.min(best, (d[previous - columns + j - 2] ?? 0) + 1);
2354
+ }
2355
+ d[row + j] = best;
2356
+ }
2357
+ }
2358
+ return d[a.length * columns + b.length] ?? 0;
2359
+ }
2360
+ function splitDomain(domain) {
2361
+ const lastDot = domain.lastIndexOf(".");
2362
+ if (lastDot <= 0 || lastDot === domain.length - 1) return null;
2363
+ return { body: domain.slice(0, lastDot), top: domain.slice(lastDot + 1) };
2364
+ }
2365
+ function nearestKnownDomain(domain) {
2366
+ const typed = splitDomain(domain);
2367
+ if (typed === null || typed.body.length < MIN_DISTINCTIVE_BODY) return null;
2368
+ for (const candidate of NEAR_MISS_TARGETS) {
2369
+ const known = splitDomain(candidate);
2370
+ if (known === null || known.top !== typed.top) continue;
2371
+ if (known.body.length < MIN_DISTINCTIVE_BODY) continue;
2372
+ if (editDistance(typed.body, known.body) === 1) return candidate;
2373
+ }
2374
+ return null;
2375
+ }
2376
+ function repairTopLevel(domain) {
2377
+ const labels = domain.split(".");
2378
+ if (labels.length < 2) return null;
2379
+ const top = labels[labels.length - 1];
2380
+ const meant = TOP_LEVEL_SLIPS[top];
2381
+ if (meant === void 0) return null;
2382
+ return [...labels.slice(0, -1), meant].join(".");
2383
+ }
2384
+ function suspectedEmailTypo(email) {
2385
+ const trimmed = email.trim().toLowerCase();
2386
+ const at = trimmed.lastIndexOf("@");
2387
+ if (at <= 0 || at === trimmed.length - 1) return null;
2388
+ const local = trimmed.slice(0, at);
2389
+ const domain = trimmed.slice(at + 1);
2390
+ if (KNOWN_DOMAINS.includes(domain)) return null;
2391
+ const repaired = repairTopLevel(domain);
2392
+ const corrected = nearestKnownDomain(repaired ?? domain) ?? repaired;
2393
+ if (corrected === null || corrected === domain) return null;
2394
+ return `${local}@${corrected}`;
2395
+ }
2396
+
2397
+ // ../checkout-core/src/domain/contact.ts
2398
+ function isValidEmail(email) {
2399
+ return isAcceptableEmail(email);
2400
+ }
2401
+ function flagTone(flag) {
2402
+ return flag === "none" ? void 0 : flag;
2403
+ }
2404
+ function emailFlag(email) {
2405
+ if (email.length === 0) return "none";
2406
+ if (!isValidEmail(email)) return "error";
2407
+ return suspectedEmailTypo(email) === null ? "success" : "warning";
2408
+ }
2409
+ function emailFlagTitle(email) {
2410
+ const meant = emailFlag(email) === "warning" ? suspectedEmailTypo(email) : null;
2411
+ return meant === null ? void 0 : `Did you mean ${meant}?`;
2412
+ }
2413
+ var E164_MAX_DIGITS = 15;
2414
+ var GENERIC_NATIONAL_DIGITS = { min: 4, max: E164_MAX_DIGITS - 1 };
2415
+ var COUNTRIES = [
2416
+ // ── Ireland, the default, and the United Kingdom ────────────
2417
+ {
2418
+ code: "IE",
2419
+ name: "Ireland",
2420
+ dialCode: "+353",
2421
+ trunkPrefix: "0",
2422
+ nationalDigits: { min: 7, max: 9 },
2423
+ // `08X XXX XXXX`, which is what the design draws.
2424
+ grouping: [{ startsWith: ["8"], digits: 9, groups: [2, 3, 4] }]
2425
+ },
2426
+ {
2427
+ code: "GB",
2428
+ name: "United Kingdom",
2429
+ dialCode: "+44",
2430
+ trunkPrefix: "0",
2431
+ nationalDigits: { min: 9, max: 10 },
2432
+ // London is also ten digits and is grouped `020 7946 0958`, so nothing beyond the
2433
+ // `7` may be assumed.
2434
+ grouping: [{ startsWith: ["7"], digits: 10, groups: [4, 6] }]
2435
+ },
2436
+ // ── The rest of the EU, alphabetically ──────────────────────
2437
+ {
2438
+ code: "AT",
2439
+ name: "Austria",
2440
+ dialCode: "+43",
2441
+ trunkPrefix: "0",
2442
+ // Austria's plan is the widest in the EU — subscriber numbers run from four digits
2443
+ // to thirteen.
2444
+ nationalDigits: { min: 4, max: 13 },
2445
+ grouping: [{ startsWith: ["6"], digits: 10, groups: [3, 7] }]
2446
+ },
2447
+ {
2448
+ code: "BE",
2449
+ name: "Belgium",
2450
+ dialCode: "+32",
2451
+ trunkPrefix: "0",
2452
+ nationalDigits: { min: 8, max: 9 },
2453
+ grouping: [{ startsWith: ["4"], digits: 9, groups: [3, 2, 2, 2] }]
2454
+ },
2455
+ {
2456
+ code: "BG",
2457
+ name: "Bulgaria",
2458
+ dialCode: "+359",
2459
+ trunkPrefix: "0",
2460
+ nationalDigits: { min: 8, max: 9 },
2461
+ grouping: [{ startsWith: ["87", "88", "89"], digits: 9, groups: [2, 3, 4] }]
2462
+ },
2463
+ {
2464
+ code: "HR",
2465
+ name: "Croatia",
2466
+ dialCode: "+385",
2467
+ trunkPrefix: "0",
2468
+ nationalDigits: { min: 8, max: 9 },
2469
+ grouping: [{ startsWith: ["9"], digits: 9, groups: [2, 3, 4] }]
2470
+ },
2471
+ {
2472
+ code: "CY",
2473
+ name: "Cyprus",
2474
+ dialCode: "+357",
2475
+ nationalDigits: { min: 8, max: 8 },
2476
+ grouping: [{ startsWith: ["9"], digits: 8, groups: [2, 6] }]
2477
+ },
2478
+ {
2479
+ code: "CZ",
2480
+ name: "Czechia",
2481
+ dialCode: "+420",
2482
+ nationalDigits: { min: 9, max: 9 },
2483
+ // Threes throughout, and Czechia has no trunk prefix.
2484
+ grouping: [{ digits: 9, groups: [3, 3, 3] }]
2485
+ },
2486
+ {
2487
+ code: "DK",
2488
+ name: "Denmark",
2489
+ dialCode: "+45",
2490
+ nationalDigits: { min: 8, max: 8 },
2491
+ // Every Danish number is eight digits in pairs, mobile or not — so this needs no
2492
+ // prefix to disambiguate.
2493
+ grouping: [{ digits: 8, groups: [2, 2, 2, 2] }]
2494
+ },
2495
+ {
2496
+ code: "EE",
2497
+ name: "Estonia",
2498
+ dialCode: "+372",
2499
+ nationalDigits: { min: 7, max: 8 },
2500
+ grouping: [
2501
+ { startsWith: ["5"], digits: 8, groups: [4, 4] },
2502
+ { startsWith: ["5"], digits: 7, groups: [3, 4] }
2503
+ ]
2504
+ },
2505
+ {
2506
+ code: "FI",
2507
+ name: "Finland",
2508
+ dialCode: "+358",
2509
+ trunkPrefix: "0",
2510
+ nationalDigits: { min: 6, max: 10 },
2511
+ grouping: [{ startsWith: ["4", "5"], digits: 9, groups: [2, 3, 4] }]
2512
+ },
2513
+ {
2514
+ code: "FR",
2515
+ name: "France",
2516
+ dialCode: "+33",
2517
+ trunkPrefix: "0",
2518
+ nationalDigits: { min: 9, max: 9 },
2519
+ // Pairs throughout — `06 12 34 56 78`.
2520
+ grouping: [{ startsWith: ["6", "7"], digits: 9, groups: [1, 2, 2, 2, 2] }]
2521
+ },
2522
+ {
2523
+ code: "DE",
2524
+ name: "Germany",
2525
+ dialCode: "+49",
2526
+ trunkPrefix: "0",
2527
+ nationalDigits: { min: 6, max: 11 }
2528
+ // NO GROUPING, deliberately, and the one EU country without it.
2529
+ },
2530
+ {
2531
+ code: "GR",
2532
+ name: "Greece",
2533
+ dialCode: "+30",
2534
+ nationalDigits: { min: 10, max: 10 },
2535
+ // Ten digits, no trunk prefix, and the leading digit is kept when dialling.
2536
+ grouping: [{ startsWith: ["69"], digits: 10, groups: [3, 3, 4] }]
2537
+ },
2538
+ {
2539
+ code: "HU",
2540
+ name: "Hungary",
2541
+ dialCode: "+36",
2542
+ // `06`, and written apart from the number — see `formatNational`.
2543
+ trunkPrefix: "06",
2544
+ nationalDigits: { min: 8, max: 9 },
2545
+ grouping: [{ startsWith: ["20", "30", "31", "50", "70"], digits: 9, groups: [2, 3, 4] }]
2546
+ },
2547
+ {
2548
+ code: "IT",
2549
+ name: "Italy",
2550
+ dialCode: "+39",
2551
+ // NO TRUNK PREFIX, and Italy is the exception worth knowing: the leading `0` of a
2552
+ // landline is part of the number and is dialled internationally too.
2553
+ nationalDigits: { min: 6, max: 11 },
2554
+ grouping: [{ startsWith: ["3"], digits: 10, groups: [3, 3, 4] }]
2555
+ },
2556
+ {
2557
+ code: "LV",
2558
+ name: "Latvia",
2559
+ dialCode: "+371",
2560
+ nationalDigits: { min: 8, max: 8 },
2561
+ grouping: [{ startsWith: ["2"], digits: 8, groups: [2, 3, 3] }]
2562
+ },
2563
+ {
2564
+ code: "LT",
2565
+ name: "Lithuania",
2566
+ dialCode: "+370",
2567
+ // `8`, and written apart from the number — see `formatNational`.
2568
+ trunkPrefix: "8",
2569
+ nationalDigits: { min: 8, max: 8 },
2570
+ grouping: [{ startsWith: ["6"], digits: 8, groups: [3, 5] }]
2571
+ },
2572
+ {
2573
+ code: "LU",
2574
+ name: "Luxembourg",
2575
+ dialCode: "+352",
2576
+ nationalDigits: { min: 4, max: 11 },
2577
+ grouping: [{ startsWith: ["6"], digits: 9, groups: [3, 3, 3] }]
2578
+ },
2579
+ {
2580
+ code: "MT",
2581
+ name: "Malta",
2582
+ dialCode: "+356",
2583
+ nationalDigits: { min: 8, max: 8 },
2584
+ grouping: [{ startsWith: ["7", "9"], digits: 8, groups: [4, 4] }]
2585
+ },
2586
+ {
2587
+ code: "NL",
2588
+ name: "Netherlands",
2589
+ dialCode: "+31",
2590
+ trunkPrefix: "0",
2591
+ nationalDigits: { min: 9, max: 9 },
2592
+ // `06 12345678` — the mobile prefix, then the number unbroken.
2593
+ grouping: [{ startsWith: ["6"], digits: 9, groups: [1, 8] }]
2594
+ },
2595
+ {
2596
+ code: "PL",
2597
+ name: "Poland",
2598
+ dialCode: "+48",
2599
+ // Poland dropped its trunk prefix; the nine digits are dialled as they are.
2600
+ nationalDigits: { min: 9, max: 9 },
2601
+ grouping: [{ digits: 9, groups: [3, 3, 3] }]
2602
+ },
2603
+ {
2604
+ code: "PT",
2605
+ name: "Portugal",
2606
+ dialCode: "+351",
2607
+ nationalDigits: { min: 9, max: 9 },
2608
+ grouping: [{ digits: 9, groups: [3, 3, 3] }]
2609
+ },
2610
+ {
2611
+ code: "RO",
2612
+ name: "Romania",
2613
+ dialCode: "+40",
2614
+ trunkPrefix: "0",
2615
+ nationalDigits: { min: 9, max: 9 },
2616
+ grouping: [{ startsWith: ["7"], digits: 9, groups: [3, 3, 3] }]
2617
+ },
2618
+ {
2619
+ code: "SK",
2620
+ name: "Slovakia",
2621
+ dialCode: "+421",
2622
+ trunkPrefix: "0",
2623
+ nationalDigits: { min: 9, max: 9 },
2624
+ grouping: [{ startsWith: ["9"], digits: 9, groups: [3, 3, 3] }]
2625
+ },
2626
+ {
2627
+ code: "SI",
2628
+ name: "Slovenia",
2629
+ dialCode: "+386",
2630
+ trunkPrefix: "0",
2631
+ nationalDigits: { min: 8, max: 8 },
2632
+ grouping: [{ startsWith: ["3", "4", "5", "6", "7"], digits: 8, groups: [2, 3, 3] }]
2633
+ },
2634
+ {
2635
+ code: "ES",
2636
+ name: "Spain",
2637
+ dialCode: "+34",
2638
+ // No trunk prefix; the nine digits are the whole number.
2639
+ nationalDigits: { min: 9, max: 9 },
2640
+ grouping: [{ digits: 9, groups: [3, 3, 3] }]
2641
+ },
2642
+ {
2643
+ code: "SE",
2644
+ name: "Sweden",
2645
+ dialCode: "+46",
2646
+ trunkPrefix: "0",
2647
+ nationalDigits: { min: 7, max: 9 },
2648
+ grouping: [{ startsWith: ["7"], digits: 9, groups: [2, 3, 4] }]
2649
+ },
2650
+ /*
2651
+ * Named and length-checked so a number from one of them is not read as nonsense, but
2652
+ * NOT formatted: the brief is the EU and the UK, and a grouping rule written for a
2653
+ * market nobody asked about is a rule nobody will check. The NANP is the exception — it
2654
+ * was already here, and it is one shape throughout.
2655
+ */
2656
+ {
2657
+ code: "US",
2658
+ name: "United States",
2659
+ dialCode: "+1",
2660
+ nationalDigits: { min: 10, max: 10 },
2661
+ grouping: [{ digits: 10, groups: [3, 3, 4] }]
2662
+ },
2663
+ { code: "CH", name: "Switzerland", dialCode: "+41", trunkPrefix: "0" },
2664
+ { code: "NO", name: "Norway", dialCode: "+47" },
2665
+ { code: "AU", name: "Australia", dialCode: "+61", trunkPrefix: "0" },
2666
+ { code: "NZ", name: "New Zealand", dialCode: "+64", trunkPrefix: "0" },
2667
+ { code: "ZA", name: "South Africa", dialCode: "+27", trunkPrefix: "0" },
2668
+ { code: "AE", name: "United Arab Emirates", dialCode: "+971", trunkPrefix: "0" },
2669
+ { code: "IN", name: "India", dialCode: "+91", trunkPrefix: "0" },
2670
+ { code: "BR", name: "Brazil", dialCode: "+55", trunkPrefix: "0" }
2671
+ ];
2672
+ var DEFAULT_COUNTRY_CODE = "IE";
2673
+ function countryByCode(code) {
2674
+ const found = COUNTRIES.find((country) => country.code === code);
2675
+ if (!found) throw new Error(`unknown country: ${code}`);
2676
+ return found;
2677
+ }
2678
+ var DEFAULT_DIAL_CODE = countryByCode(DEFAULT_COUNTRY_CODE).dialCode;
2679
+ var digitsOf = (value) => value.replace(/\D/g, "");
2680
+ function countryByDialCode(dialCode) {
2681
+ const raw = digitsOf(dialCode);
2682
+ const digits = raw.startsWith("00") && raw.length > 2 ? raw.slice(2) : raw;
2683
+ if (digits.length === 0) return null;
2684
+ return COUNTRIES.find((country) => country.dialCode.slice(1) === digits) ?? null;
2685
+ }
2686
+ function splitPhoneNumber(raw) {
2687
+ const trimmed = raw.trim();
2688
+ const digits = digitsOf(trimmed);
2689
+ const international = trimmed.startsWith("+") || digits.startsWith("00") && digits.length > 2;
2690
+ if (!international || digits.length === 0) return { dialCode: null, national: trimmed };
2691
+ const body = trimmed.startsWith("+") ? digits : digits.slice(2);
2692
+ const match = [...COUNTRIES].sort((a, b) => b.dialCode.length - a.dialCode.length).find((country) => body.startsWith(country.dialCode.slice(1)));
2693
+ if (!match) return { dialCode: null, national: trimmed };
2694
+ return { dialCode: match.dialCode, national: body.slice(match.dialCode.length - 1) };
2695
+ }
2696
+ var MAX_DIAL_DIGITS = Math.max(...COUNTRIES.map((country) => country.dialCode.length - 1));
2697
+ var NOT_PHONE = /[^\d+]/g;
2698
+ function routePhoneInput(typed, field, current) {
2699
+ const raw = typed.replace(NOT_PHONE, "");
2700
+ const parts = splitPhoneNumber(raw);
2701
+ if (field === "national") {
2702
+ if (parts.dialCode === null) return { ...current, national: raw };
2703
+ return { dialCode: parts.dialCode, national: parts.national };
2704
+ }
2705
+ if (parts.dialCode !== null) {
2706
+ return {
2707
+ dialCode: parts.dialCode,
2708
+ /*
2709
+ * A remainder long enough to BE a number takes the row below; one too short to be
2710
+ * anything replaces nothing. `+3531` is a slipped keystroke after a complete code, and
2711
+ * letting its `1` overwrite an entered number is the same bug in the other direction —
2712
+ * so it is dropped, unless the row below is empty and there is nothing to lose.
2713
+ */
2714
+ national: digitsOf(parts.national).length >= GENERIC_NATIONAL_DIGITS.min || current.national.length === 0 ? parts.national : current.national
2610
2715
  };
2611
- viewport.addEventListener("wheel", onWheel, { passive: false });
2612
- return () => viewport.removeEventListener("wheel", onWheel);
2613
- }, [drag, draw, settle]);
2614
- useEffect3(
2615
- () => () => {
2616
- if (settleTimer.current !== null) window.clearTimeout(settleTimer.current);
2617
- },
2618
- []
2619
- );
2620
- return /* @__PURE__ */ jsxs4(
2621
- "div",
2622
- {
2623
- ref: viewportRef,
2624
- className: "scopetickets-island-calendar-scroller",
2625
- role: "group",
2626
- "aria-label": label,
2627
- style: {
2628
- "--scopetickets-island-viewport-rows": CALENDAR_VIEWPORT_ROWS,
2629
- ...rowStep > 0 ? { "--scopetickets-island-calendar-row-step": `${rowStep}px` } : null
2630
- },
2631
- onPointerDown,
2632
- onPointerMove,
2633
- onPointerUp,
2634
- onPointerCancel,
2635
- onClickCapture,
2636
- children: [
2637
- /* @__PURE__ */ jsx7("div", { className: "scopetickets-island-calendar-scroller__window", "aria-hidden": "true" }),
2638
- /* @__PURE__ */ jsx7(
2639
- "div",
2640
- {
2641
- ref: trackRef,
2642
- className: "scopetickets-island-calendar-scroller__track",
2643
- "data-dragging": dragging || offset !== 0 ? "" : void 0,
2644
- style: {
2645
- translate: `0 calc(${-row} * var(--scopetickets-island-calendar-row-step) + ${offset}px)`
2646
- },
2647
- children
2648
- }
2649
- )
2650
- ]
2651
- }
2652
- );
2716
+ }
2717
+ if (digitsOf(raw).length > MAX_DIAL_DIGITS) {
2718
+ return { dialCode: current.dialCode, national: raw };
2719
+ }
2720
+ if (raw.trim().length === 0) return { ...current, dialCode: DEFAULT_DIAL_CODE };
2721
+ return { ...current, dialCode: raw };
2653
2722
  }
2654
-
2655
- // src/island/CalendarWeekdayNames.tsx
2656
- import { jsx as jsx8 } from "react/jsx-runtime";
2657
- var WEEKDAY_NAMES = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
2658
- function CalendarWeekdayNames() {
2659
- return (
2660
- // `aria-hidden`, and it is not a shortcut.
2661
- /* @__PURE__ */ jsx8("div", { className: "scopetickets-island-calendar__weekdays", "aria-hidden": "true", children: WEEKDAY_NAMES.map((name) => /* @__PURE__ */ jsx8("span", { className: "scopetickets-island-calendar__weekday", children: name }, name)) })
2723
+ function nationalDigits(phone, country) {
2724
+ let digits = digitsOf(phone);
2725
+ const dial = country.dialCode.slice(1);
2726
+ if (digits.startsWith(dial) && digits.length > dial.length) digits = digits.slice(dial.length);
2727
+ const trunk = country.trunkPrefix;
2728
+ if (trunk !== void 0 && digits.startsWith(trunk)) digits = digits.slice(trunk.length);
2729
+ return digits;
2730
+ }
2731
+ function formatNational(value, country) {
2732
+ const digits = digitsOf(value);
2733
+ if (digits.length === 0) return value.trim() === "+" ? "+" : "";
2734
+ const trunk = country.trunkPrefix !== void 0 && digits.startsWith(country.trunkPrefix) ? country.trunkPrefix : "";
2735
+ const nsn = digits.slice(trunk.length);
2736
+ const pattern = country.grouping?.find(
2737
+ (candidate) => nsn.length <= candidate.digits && (candidate.startsWith === void 0 || candidate.startsWith.some((start) => nsn.startsWith(start)))
2662
2738
  );
2739
+ if (pattern === void 0) return value;
2740
+ const parts = [];
2741
+ let at = 0;
2742
+ for (const size of pattern.groups) {
2743
+ if (at >= nsn.length) break;
2744
+ parts.push(nsn.slice(at, at + size));
2745
+ at += size;
2746
+ }
2747
+ if (trunk === "") return parts.join(" ");
2748
+ return trunk === "0" ? [trunk + (parts[0] ?? ""), ...parts.slice(1)].join(" ") : [trunk, ...parts].join(" ");
2749
+ }
2750
+ function digitsAllowed(country) {
2751
+ return country.nationalDigits ?? GENERIC_NATIONAL_DIGITS;
2752
+ }
2753
+ function isValidPhone(phone, country) {
2754
+ const national = nationalDigits(phone, country);
2755
+ const { min, max } = digitsAllowed(country);
2756
+ return national.length >= min && national.length <= max;
2757
+ }
2758
+ function phoneFlag(phone, country) {
2759
+ if (phone.trim().length === 0) return "none";
2760
+ return isValidPhone(phone, country) ? "success" : "error";
2761
+ }
2762
+ function e164(dialCode, phone) {
2763
+ const country = countryByDialCode(dialCode);
2764
+ if (country === null) return null;
2765
+ const national = nationalDigits(phone, country);
2766
+ if (!isValidPhone(phone, country)) return null;
2767
+ const composed = `${country.dialCode}${national}`;
2768
+ return isE164(composed) ? composed : null;
2769
+ }
2770
+ function normalizeE164(value) {
2771
+ const { dialCode, national } = splitPhoneNumber(value);
2772
+ if (dialCode === null) return null;
2773
+ return e164(dialCode, national);
2774
+ }
2775
+ function isCompleteName(firstName, lastName) {
2776
+ return firstName.trim().length > 0 && lastName.trim().length > 0;
2777
+ }
2778
+ function splitFullName(full) {
2779
+ const parts = full.trim().split(/\s+/).filter(Boolean);
2780
+ if (parts.length < 2) return null;
2781
+ const [firstName, ...rest] = parts;
2782
+ return { firstName, lastName: rest.join(" ") };
2663
2783
  }
2664
2784
 
2665
- // src/island/DayPicker.tsx
2666
- import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
2667
- function DayPicker({
2668
- series,
2669
- offered = series,
2670
- today,
2671
- selectedDay,
2672
- onSelectDay,
2673
- remaining,
2674
- accessory = DATE_PICKER_ACCESSORY,
2675
- onVisibleMonthChange
2676
- }) {
2677
- const weeks = useMemo2(() => weeksInCalendar(series), [series]);
2678
- const starts = useMemo2(() => monthStartRows(weeks), [weeks]);
2679
- const [row, setRow] = useState4(
2680
- () => monthOpeningRow(weeks, starts, selectedDay ?? soonestRelevantDay(offered, today))
2681
- );
2682
- const [shownRow, setShownRow] = useState4(row);
2683
- const currentMonth = monthAtRow(starts, shownRow);
2684
- useEffect4(() => {
2685
- if (currentMonth !== null) onVisibleMonthChange?.(currentMonth);
2686
- }, [currentMonth, onVisibleMonthChange]);
2687
- const selectDay = useCallback2(
2688
- (day) => {
2689
- const month = monthOfDay(day);
2690
- const start = starts.find((candidate) => candidate.month === month);
2691
- if (start !== void 0 && month !== currentMonth) {
2692
- setRow(start.row);
2693
- setShownRow(start.row);
2694
- }
2695
- onSelectDay(day);
2696
- },
2697
- [starts, currentMonth, onSelectDay]
2698
- );
2699
- if (weeks.length === 0) return null;
2700
- return /* @__PURE__ */ jsxs5("div", { className: "scopetickets-island-calendar", "data-accessory": accessory, children: [
2701
- currentMonth !== null && /* @__PURE__ */ jsx9(CalendarMonthHeading, { month: currentMonth }),
2702
- /* @__PURE__ */ jsx9(CalendarWeekdayNames, {}),
2703
- /* @__PURE__ */ jsx9(
2704
- CalendarScroller,
2705
- {
2706
- rowCount: weeks.length,
2707
- row,
2708
- onRowChange: setRow,
2709
- onRowPreview: setShownRow,
2710
- label: ISLAND_COPY.runWeeks,
2711
- children: /* @__PURE__ */ jsx9(
2712
- CalendarRunGrid,
2713
- {
2714
- series: offered,
2715
- weeks,
2716
- currentMonth,
2717
- accessory,
2718
- remaining,
2719
- today,
2720
- selectedDay,
2721
- onSelectDay: selectDay
2722
- }
2723
- )
2724
- }
2725
- )
2726
- ] });
2785
+ // src/island/ContentFlag.tsx
2786
+ import { jsx as jsx9 } from "react/jsx-runtime";
2787
+ var GLYPH = {
2788
+ success: CheckInCircleFilledIcon,
2789
+ warning: ExclamationMarkInCircleFilledIcon,
2790
+ error: XMarkInCircleFilledIcon
2791
+ };
2792
+ function ContentFlag({ tone, title }) {
2793
+ const Glyph = GLYPH[tone];
2794
+ return /* @__PURE__ */ jsx9("span", { className: `scopetickets-island-content-flag scopetickets-island-content-flag--${tone}`, children: /* @__PURE__ */ jsx9(Glyph, { fill: true, color: "currentColor", title }) });
2727
2795
  }
2728
2796
 
2729
2797
  // src/island/CounterRing.tsx
@@ -3366,6 +3434,8 @@ export {
3366
3434
  SURFACE_MORPH_DELAY_MS,
3367
3435
  INCOMING_FADE_DELAY_MS,
3368
3436
  INCOMING_FADE_MS,
3437
+ ARC_LEAD_BEZIER,
3438
+ ARC_TRAIL_BEZIER,
3369
3439
  CARRY_MOVE_DELAY_MS,
3370
3440
  CARRY_MOVE_MS,
3371
3441
  POP_SCALE,
@@ -3422,11 +3492,6 @@ export {
3422
3492
  clampRemaining,
3423
3493
  trackPaths,
3424
3494
  timerPaths,
3425
- majorUnits,
3426
- formatMoney,
3427
- moneyParts,
3428
- widestAmount,
3429
- quoteLines,
3430
3495
  slotFullness,
3431
3496
  parseWallClockTime,
3432
3497
  timeOfDayInZone,
@@ -3474,13 +3539,18 @@ export {
3474
3539
  monthAtRow,
3475
3540
  monthOpeningRow,
3476
3541
  toggleSelectedDay,
3477
- ContentFlag,
3542
+ majorUnits,
3543
+ formatMoney,
3544
+ moneyParts,
3545
+ widestAmount,
3546
+ quoteLines,
3478
3547
  PartyStepper,
3479
3548
  DayPicker,
3549
+ ContentFlag,
3480
3550
  CounterRing,
3481
3551
  TimeslotPicker,
3482
3552
  TimePicker,
3483
3553
  CalendarGrainButton,
3484
3554
  Switch
3485
3555
  };
3486
- //# sourceMappingURL=chunk-SUAJAOHM.js.map
3556
+ //# sourceMappingURL=chunk-VS7ACUTQ.js.map