@gomusdev/web-components 1.57.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist-js/gomus-webcomponents.iife.js +594 -391
  2. package/dist-js/gomus-webcomponents.js +594 -391
  3. package/dist-js/src/components/ticketSelection/TicketSelectionDetails.svelte.d.ts +6 -6
  4. package/dist-js/src/components/ticketSelection/filters/_helpers.d.ts +4 -0
  5. package/dist-js/src/components/ticketSelection/filters/event/admission-day.d.ts +3 -0
  6. package/dist-js/src/components/ticketSelection/filters/event/admission-timeslot.d.ts +3 -0
  7. package/dist-js/src/components/ticketSelection/filters/event/admission.d.ts +3 -0
  8. package/dist-js/src/components/ticketSelection/filters/event/price.d.ts +3 -0
  9. package/dist-js/src/components/ticketSelection/filters/events/admission-day.d.ts +3 -0
  10. package/dist-js/src/components/ticketSelection/filters/events/admission-timeslot.d.ts +3 -0
  11. package/dist-js/src/components/ticketSelection/filters/events/admission.d.ts +3 -0
  12. package/dist-js/src/components/ticketSelection/filters/events/price.d.ts +3 -0
  13. package/dist-js/src/components/ticketSelection/filters/events/spec/admission-day.spec.d.ts +1 -0
  14. package/dist-js/src/components/ticketSelection/filters/events/spec/admission-timeslot.spec.d.ts +1 -0
  15. package/dist-js/src/components/ticketSelection/filters/events/spec/admission.spec.d.ts +1 -0
  16. package/dist-js/src/components/ticketSelection/filters/events/spec/price.spec.d.ts +1 -0
  17. package/dist-js/src/components/ticketSelection/filters/registry.d.ts +4 -0
  18. package/dist-js/src/components/ticketSelection/filters/ticket/annual.d.ts +3 -0
  19. package/dist-js/src/components/ticketSelection/filters/ticket/day.d.ts +3 -0
  20. package/dist-js/src/components/ticketSelection/filters/ticket/spec/annual.spec.d.ts +1 -0
  21. package/dist-js/src/components/ticketSelection/filters/ticket/spec/day.spec.d.ts +1 -0
  22. package/dist-js/src/components/ticketSelection/filters/ticket/spec/timeslot.spec.d.ts +1 -0
  23. package/dist-js/src/components/ticketSelection/filters/ticket/timeslot.d.ts +3 -0
  24. package/dist-js/src/components/ticketSelection/filters/types.d.ts +23 -0
  25. package/dist-js/src/components/ticketSelection/subcomponents/calendar/lib/calendar.svelte.d.ts +2 -1
  26. package/dist-js/src/components/ticketSelection/subcomponents/tickets/subcomponents/segment/SegmentDetails.svelte.d.ts +6 -4
  27. package/dist-js/src/components/ticketSelection/subcomponents/tickets/subcomponents/segment/spec/SegmentDetails.spec.d.ts +1 -0
  28. package/dist-js/src/components/ticketSelection/subcomponents/timeslots/lib/lib.svelte.d.ts +2 -1
  29. package/package.json +1 -1
  30. package/dist-js/src/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/annualTickets.svelte.d.ts +0 -2
  31. package/dist-js/src/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/dayTickets.svelte.d.ts +0 -2
  32. package/dist-js/src/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/event_ScaledPriceTickets.svelte.d.ts +0 -2
  33. package/dist-js/src/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/event_Tickets.svelte.d.ts +0 -2
  34. package/dist-js/src/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/events/events_ScaledPriceTickets.svelte.d.ts +0 -2
  35. package/dist-js/src/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/timeslotTickets.svelte.d.ts +0 -2
  36. /package/dist-js/src/components/ticketSelection/{subcomponents/tickets/subcomponents/segment/TicketSegment.spec.d.ts → filters/event/spec/admission-day.spec.d.ts} +0 -0
  37. /package/dist-js/src/components/ticketSelection/{subcomponents/tickets/subcomponents/segment/lib/event/event_ScaledPriceTickets.spec.d.ts → filters/event/spec/admission-timeslot.spec.d.ts} +0 -0
  38. /package/dist-js/src/components/ticketSelection/{subcomponents/tickets/subcomponents/segment/lib/event/event_Tickets.svelte.spec.d.ts → filters/event/spec/admission.spec.d.ts} +0 -0
  39. /package/dist-js/src/components/ticketSelection/{subcomponents/tickets/subcomponents/segment/lib/events/events_ScaledPriceTickets.spec.d.ts → filters/event/spec/price.spec.d.ts} +0 -0
@@ -17759,18 +17759,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17759
17759
  const parsed = ids.split(",").map((id) => id.trim()).map(Number).filter((num) => !isNaN(num) && num > 0);
17760
17760
  return parsed.length > 0 ? parsed : void 0;
17761
17761
  }
17762
- function parseTokens(tokens, possibleTokens) {
17763
- if (!tokens) {
17764
- return void 0;
17765
- }
17766
- const parsed = tokens.split(",").map((token) => token.trim()).map(String).filter((token) => token.length > 0);
17767
- parsed.forEach((token) => {
17768
- if (!possibleTokens.includes(token)) {
17769
- throw new Error("(parseTokens) Invalid token: " + token);
17770
- }
17771
- });
17772
- return parsed.length > 0 ? parsed : void 0;
17773
- }
17774
17762
  var root_1$f = /* @__PURE__ */ from_html(`<button> </button>`);
17775
17763
  var root_2$o = /* @__PURE__ */ from_html(`<form id="donationForm" action="" novalidate=""><div class="donation-custom form-group"><label for="donation-custom-amount"> </label> <input class="form-control" id="donation-custom-amount" type="number" min="1"/></div></form>`);
17776
17764
  var root$8 = /* @__PURE__ */ from_html(`<div class="donation-selection"><h3> </h3> <div class="donation-options"></div> <!></div>`);
@@ -19246,7 +19234,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19246
19234
  var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
19247
19235
  return attValue === "" || attValue === "true";
19248
19236
  };
19249
- var getCandidates = function getCandidates2(el, includeContainer, filter) {
19237
+ var getCandidates = function getCandidates2(el, includeContainer, filter2) {
19250
19238
  if (_isInert(el)) {
19251
19239
  return [];
19252
19240
  }
@@ -19254,7 +19242,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19254
19242
  if (includeContainer && matches.call(el, candidateSelector)) {
19255
19243
  candidates.unshift(el);
19256
19244
  }
19257
- candidates = candidates.filter(filter);
19245
+ candidates = candidates.filter(filter2);
19258
19246
  return candidates;
19259
19247
  };
19260
19248
  var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
@@ -33984,24 +33972,507 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
33984
33972
  console.error(`Error while evaluating when (${expression}) in go-if: ${error.message}`);
33985
33973
  }
33986
33974
  }
33987
- const validTicketSelectionFilters = [
33988
- "timeslot",
33989
- "day",
33990
- "annual",
33991
- "event:scaled-price",
33992
- "event:ticket",
33993
- "events:scaled-price"
33975
+ const FILTER_NAMES = [
33976
+ "ticket:timeslot",
33977
+ "ticket:day",
33978
+ "ticket:annual",
33979
+ "event:admission",
33980
+ "event:admission:day",
33981
+ "event:admission:timeslot",
33982
+ "event:price",
33983
+ "events:admission",
33984
+ "events:admission:day",
33985
+ "events:admission:timeslot",
33986
+ "events:price"
33994
33987
  ];
33988
+ const filter$a = {
33989
+ name: "ticket:timeslot",
33990
+ calendarEndpoint: "tickets",
33991
+ apiToken: "time_slot",
33992
+ requires: [
33993
+ { kind: "tsd", field: "selectedDate" },
33994
+ { kind: "tsd", field: "selectedTimeslot" }
33995
+ ],
33996
+ isCalendarVisible: () => true,
33997
+ isTimeslotsVisible: (tsd) => Boolean(tsd.selectedDate),
33998
+ isTicketsVisible: (tsd) => Boolean(tsd.selectedDate && tsd.selectedTimeslot),
33999
+ async loadTimeslots(tsd) {
34000
+ if (!tsd?.selectedDate) return;
34001
+ const { quotas } = await shop.asyncFetch(
34002
+ () => shop.ticketsAndQuotas({
34003
+ by_bookable: true,
34004
+ valid_at: tsd.selectedDate.toString(),
34005
+ // @ts-ignore
34006
+ by_ticket_type: "time_slot",
34007
+ "by_museum_ids[]": tsd.museumIds,
34008
+ "by_exhibition_ids[]": tsd.exhibitionIds,
34009
+ "by_ticket_ids[]": tsd.ticketIds,
34010
+ "by_ticket_group_ids[]": tsd.ticketGroupIds
34011
+ })
34012
+ );
34013
+ shop.capacityManager.addQuotas(quotas);
34014
+ },
34015
+ async loadProducts(segment) {
34016
+ const tsd = segment.ticketSelectionDetails;
34017
+ if (!tsd?.selectedDate || !tsd.selectedTimeslot) return;
34018
+ const { tickets, quotas } = await shop.asyncFetch(
34019
+ () => shop.ticketsAndQuotas({
34020
+ by_bookable: true,
34021
+ valid_at: tsd.selectedDate.toString(),
34022
+ // @ts-ignore
34023
+ by_ticket_type: "time_slot",
34024
+ "by_museum_ids[]": segment.museumIds ?? tsd.museumIds,
34025
+ "by_exhibition_ids[]": tsd.exhibitionIds,
34026
+ "by_ticket_ids[]": tsd.ticketIds,
34027
+ "by_ticket_group_ids[]": segment.ticketGroupIds ?? tsd.ticketGroupIds
34028
+ })
34029
+ );
34030
+ shop.capacityManager.addQuotas(quotas);
34031
+ const available = filterAvailabletickets(tickets, tsd.selectedTime);
34032
+ const uiTickets = initUITimeslotTickets(available, tsd.selectedTime);
34033
+ for (const ticket of uiTickets) segment.preCart.addItem(createCartItem(ticket, { time: tsd.selectedTime }));
34034
+ }
34035
+ };
34036
+ const filter$9 = {
34037
+ name: "ticket:day",
34038
+ calendarEndpoint: "tickets",
34039
+ apiToken: "normal",
34040
+ requires: [{ kind: "tsd", field: "selectedDate" }],
34041
+ isCalendarVisible: () => true,
34042
+ isTimeslotsVisible: () => false,
34043
+ isTicketsVisible: (tsd) => Boolean(tsd.selectedDate),
34044
+ async loadTimeslots() {
34045
+ },
34046
+ async loadProducts(segment) {
34047
+ const tsd = segment.ticketSelectionDetails;
34048
+ if (!tsd?.selectedDate) return;
34049
+ const { tickets, quotas } = await shop.asyncFetch(
34050
+ () => shop.ticketsAndQuotas({
34051
+ by_bookable: true,
34052
+ valid_at: tsd.selectedDate.toString(),
34053
+ // @ts-ignore
34054
+ "by_ticket_types[]": ["normal"],
34055
+ "by_museum_ids[]": segment.museumIds ?? tsd.museumIds,
34056
+ "by_exhibition_ids[]": tsd.exhibitionIds,
34057
+ "by_ticket_ids[]": tsd.ticketIds,
34058
+ "by_ticket_group_ids[]": segment.ticketGroupIds ?? tsd.ticketGroupIds
34059
+ })
34060
+ );
34061
+ shop.capacityManager.addQuotas(quotas);
34062
+ const firstQuota = Object.values(quotas)[0];
34063
+ const timeslot = firstQuota ? Object.keys(firstQuota.capacities)[0] : void 0;
34064
+ const available = filterAvailabletickets(tickets, timeslot);
34065
+ const uiTickets = initUITimeslotTickets(available, timeslot);
34066
+ for (const ticket of uiTickets) segment.preCart.addItem(createCartItem(ticket, { time: timeslot }));
34067
+ }
34068
+ };
34069
+ const filter$8 = {
34070
+ name: "ticket:annual",
34071
+ calendarEndpoint: null,
34072
+ apiToken: "annual",
34073
+ requires: [],
34074
+ isCalendarVisible: () => false,
34075
+ isTimeslotsVisible: () => false,
34076
+ isTicketsVisible: () => true,
34077
+ async loadTimeslots() {
34078
+ },
34079
+ async loadProducts(segment) {
34080
+ const tsd = segment.ticketSelectionDetails;
34081
+ if (!tsd) return;
34082
+ const tickets = await shop.asyncFetch(
34083
+ () => shop.tickets({
34084
+ by_bookable: true,
34085
+ // @ts-ignore
34086
+ "by_ticket_types[]": ["annual"],
34087
+ "by_ticket_ids[]": tsd.ticketIds,
34088
+ "by_ticket_group_ids[]": segment.ticketGroupIds ?? tsd.ticketGroupIds
34089
+ })
34090
+ );
34091
+ for (const t of Object.values(tickets)) {
34092
+ segment.preCart.addItem(createCartItem(createUITicket(t)));
34093
+ }
34094
+ }
34095
+ };
34096
+ const filter$7 = {
34097
+ name: "event:admission",
34098
+ calendarEndpoint: "events",
34099
+ requires: [
34100
+ { kind: "tsd", field: "eventIds" },
34101
+ { kind: "tsd", field: "selectedDate" }
34102
+ ],
34103
+ isCalendarVisible: () => true,
34104
+ isTimeslotsVisible: (tsd) => Boolean(tsd.selectedDate),
34105
+ isTicketsVisible: (tsd) => Boolean(tsd.selectedDate && tsd.selectedTimeslot),
34106
+ async loadTimeslots(tsd) {
34107
+ if (!tsd?.eventIds?.length || !tsd.selectedDate) return;
34108
+ const event2 = await shop.asyncFetch(() => shop.getEvent(tsd.eventIds[0]));
34109
+ if (!event2.tickets?.length) return;
34110
+ const { quotas } = await shop.asyncFetch(
34111
+ () => shop.ticketsAndQuotas({
34112
+ "by_ticket_ids[]": event2.tickets,
34113
+ by_bookable: true,
34114
+ valid_at: tsd.selectedDate.toString()
34115
+ })
34116
+ );
34117
+ shop.capacityManager.addQuotas(quotas);
34118
+ },
34119
+ async loadProducts(segment) {
34120
+ const tsd = segment.ticketSelectionDetails;
34121
+ if (!tsd?.eventIds?.length || !tsd.selectedDate) return;
34122
+ const event2 = await shop.asyncFetch(() => shop.getEvent(tsd.eventIds[0]));
34123
+ if (!event2.tickets?.length) return;
34124
+ const { tickets, quotas } = await shop.asyncFetch(
34125
+ () => shop.ticketsAndQuotas({
34126
+ by_bookable: true,
34127
+ valid_at: tsd.selectedDate.toString(),
34128
+ date_id: segment.dateId
34129
+ })
34130
+ );
34131
+ shop.capacityManager.addQuotas(quotas);
34132
+ const available = filterAvailabletickets(tickets, tsd.selectedTime);
34133
+ const uiTickets = initUITimeslotTickets(available, tsd.selectedTime);
34134
+ for (const ticket of uiTickets) segment.preCart.addItem(createCartItem(ticket, { time: tsd.selectedTime }));
34135
+ }
34136
+ };
34137
+ const filter$6 = {
34138
+ name: "event:admission:day",
34139
+ calendarEndpoint: "events",
34140
+ requires: [
34141
+ { kind: "tsd", field: "eventIds" },
34142
+ { kind: "tsd", field: "selectedDate" }
34143
+ ],
34144
+ isCalendarVisible: () => true,
34145
+ isTimeslotsVisible: () => false,
34146
+ isTicketsVisible: (tsd) => Boolean(tsd.selectedDate),
34147
+ async loadTimeslots() {
34148
+ },
34149
+ async loadProducts(segment) {
34150
+ const tsd = segment.ticketSelectionDetails;
34151
+ if (!tsd?.eventIds?.length || !tsd.selectedDate) return;
34152
+ const event2 = await shop.asyncFetch(() => shop.getEvent(tsd.eventIds[0]));
34153
+ if (!event2.tickets?.length) return;
34154
+ const { tickets, quotas } = await shop.asyncFetch(
34155
+ () => shop.ticketsAndQuotas({
34156
+ "by_ticket_ids[]": event2.tickets,
34157
+ // @ts-ignore — backend has_scope :by_ticket_types accepts ('normal' | 'time_slot' | 'annual')[]
34158
+ "by_ticket_types[]": ["normal"],
34159
+ by_bookable: true,
34160
+ valid_at: tsd.selectedDate.toString()
34161
+ })
34162
+ );
34163
+ shop.capacityManager.addQuotas(quotas);
34164
+ const firstQuota = Object.values(quotas)[0];
34165
+ const time2 = firstQuota ? Object.keys(firstQuota.capacities)[0] : void 0;
34166
+ const available = filterAvailabletickets(tickets, time2);
34167
+ const uiTickets = initUITimeslotTickets(available, time2);
34168
+ for (const t of uiTickets) segment.preCart.addItem(createCartItem(t, { time: time2 }));
34169
+ }
34170
+ };
34171
+ const filter$5 = {
34172
+ name: "event:admission:timeslot",
34173
+ calendarEndpoint: "events",
34174
+ requires: [
34175
+ { kind: "tsd", field: "eventIds" },
34176
+ { kind: "tsd", field: "selectedDate" },
34177
+ { kind: "tsd", field: "selectedTimeslot" }
34178
+ ],
34179
+ isCalendarVisible: () => true,
34180
+ isTimeslotsVisible: (tsd) => Boolean(tsd.selectedDate),
34181
+ isTicketsVisible: (tsd) => Boolean(tsd.selectedDate && tsd.selectedTimeslot),
34182
+ async loadTimeslots(tsd) {
34183
+ if (!tsd?.eventIds?.length || !tsd.selectedDate) return;
34184
+ const event2 = await shop.asyncFetch(() => shop.getEvent(tsd.eventIds[0]));
34185
+ if (!event2.tickets?.length) return;
34186
+ const { quotas } = await shop.asyncFetch(
34187
+ () => shop.ticketsAndQuotas({
34188
+ "by_ticket_ids[]": event2.tickets,
34189
+ // @ts-ignore — backend has_scope :by_ticket_type accepts 'time_slot' | 'normal' | 'annual'
34190
+ by_ticket_type: "time_slot",
34191
+ by_bookable: true,
34192
+ valid_at: tsd.selectedDate.toString()
34193
+ })
34194
+ );
34195
+ shop.capacityManager.addQuotas(quotas);
34196
+ },
34197
+ async loadProducts(segment) {
34198
+ const tsd = segment.ticketSelectionDetails;
34199
+ if (!tsd?.eventIds?.length || !tsd.selectedDate || !tsd.selectedTimeslot) return;
34200
+ const event2 = await shop.asyncFetch(() => shop.getEvent(tsd.eventIds[0]));
34201
+ if (!event2.tickets?.length) return;
34202
+ const { tickets, quotas } = await shop.asyncFetch(
34203
+ () => shop.ticketsAndQuotas({
34204
+ "by_ticket_ids[]": event2.tickets,
34205
+ // @ts-ignore
34206
+ by_ticket_type: "time_slot",
34207
+ by_bookable: true,
34208
+ valid_at: tsd.selectedDate.toString()
34209
+ })
34210
+ );
34211
+ shop.capacityManager.addQuotas(quotas);
34212
+ const available = filterAvailabletickets(tickets, tsd.selectedTime);
34213
+ const uiTickets = initUITimeslotTickets(available, tsd.selectedTime);
34214
+ for (const t of uiTickets) segment.preCart.addItem(createCartItem(t, { time: tsd.selectedTime }));
34215
+ }
34216
+ };
34217
+ const filter$4 = {
34218
+ name: "event:price",
34219
+ calendarEndpoint: "events",
34220
+ requires: [
34221
+ { kind: "tsd", field: "eventIds" },
34222
+ { kind: "segment", field: "dateId" }
34223
+ ],
34224
+ isCalendarVisible: () => false,
34225
+ isTimeslotsVisible: () => false,
34226
+ isTicketsVisible: (tsd) => Boolean(tsd.eventIds?.length),
34227
+ loadTimeslots: async () => {
34228
+ },
34229
+ async loadProducts(segment) {
34230
+ const tsd = segment.ticketSelectionDetails;
34231
+ if (!tsd?.eventIds?.length || segment.dateId === void 0) return;
34232
+ const date2 = await shop.asyncFetch(() => shop.getEventDetailsOnDate(tsd.eventIds[0], segment.dateId));
34233
+ if (!date2.prices?.length) return;
34234
+ for (const price of date2.prices) {
34235
+ const ticket = createUIEventTicket(price, date2.id, { event_title: date2.event_title });
34236
+ segment.preCart.addItem(createCartItem(ticket, { time: date2.start_time }));
34237
+ }
34238
+ if (date2.seats) shop.capacityManager.addSeats(date2.id, date2.seats);
34239
+ }
34240
+ };
34241
+ const TWO_HOURS_MS = 2 * 60 * 60 * 1e3;
34242
+ function filterDatesInWindow(dates, selectedDate, selectedTime) {
34243
+ const selectedMs = Date.parse(selectedTime);
34244
+ return dates.filter((d) => {
34245
+ const datePart = d.start_time.slice(0, 10);
34246
+ const startMs = Date.parse(d.start_time);
34247
+ return datePart === selectedDate && startMs >= selectedMs && startMs <= selectedMs + TWO_HOURS_MS && (d.seats?.available ?? 0) > 0;
34248
+ });
34249
+ }
34250
+ async function loadEventsTimeslots(tsd) {
34251
+ if (!tsd?.selectedDate) return;
34252
+ const { quotas } = await shop.asyncFetch(
34253
+ () => shop.ticketsAndQuotas({
34254
+ by_bookable: true,
34255
+ valid_at: tsd.selectedDate.toString(),
34256
+ // @ts-ignore
34257
+ "by_ticket_types[]": ["time_slot"],
34258
+ "by_museum_ids[]": tsd.museumIds,
34259
+ "by_exhibition_ids[]": tsd.exhibitionIds,
34260
+ "by_ticket_ids[]": tsd.ticketIds,
34261
+ "by_ticket_group_ids[]": tsd.ticketGroupIds
34262
+ })
34263
+ );
34264
+ shop.capacityManager.addQuotas(quotas);
34265
+ }
34266
+ const filter$3 = {
34267
+ name: "events:admission",
34268
+ calendarEndpoint: "events",
34269
+ requires: [
34270
+ { kind: "tsd", field: "selectedDate" },
34271
+ { kind: "tsd", field: "selectedTimeslot" }
34272
+ ],
34273
+ isCalendarVisible: () => true,
34274
+ isTimeslotsVisible: () => true,
34275
+ isTicketsVisible: () => true,
34276
+ loadTimeslots: (tsd) => loadEventsTimeslots(tsd),
34277
+ async loadProducts(segment) {
34278
+ const tsd = segment.ticketSelectionDetails;
34279
+ if (!tsd?.selectedDate || !tsd.selectedTime) return;
34280
+ const all = await shop.asyncFetch(
34281
+ () => shop.getDates({
34282
+ by_bookable: true,
34283
+ // @ts-ignore — bracketed array params are accepted by API
34284
+ "by_museum_ids[]": segment.museumIds ?? tsd.museumIds,
34285
+ "by_exhibition_ids[]": tsd.exhibitionIds,
34286
+ "by_event_ids[]": tsd.eventIds,
34287
+ "by_language_ids[]": segment.languageIds,
34288
+ "by_catch_word_ids[]": segment.catchWordIds,
34289
+ start_at: tsd.selectedDate.toString(),
34290
+ per_page: segment.limit || 30
34291
+ })
34292
+ );
34293
+ const dates = filterDatesInWindow(all, tsd.selectedDate.toString(), tsd.selectedTime);
34294
+ for (const date2 of dates) {
34295
+ if (!date2.event_id || !date2.start_time) continue;
34296
+ const event2 = await shop.asyncFetch(() => shop.getEvent(date2.event_id));
34297
+ if (!event2?.tickets?.length) continue;
34298
+ const { tickets, quotas } = await shop.asyncFetch(
34299
+ () => shop.ticketsAndQuotas({
34300
+ "by_ticket_ids[]": event2.tickets,
34301
+ by_bookable: true,
34302
+ valid_at: date2.start_time.slice(0, 10)
34303
+ })
34304
+ );
34305
+ shop.capacityManager.addQuotas(quotas);
34306
+ const available = filterAvailabletickets(tickets, date2.start_time);
34307
+ const uiTickets = initUITimeslotTickets(available, date2.start_time);
34308
+ for (const ticket of uiTickets) segment.preCart.addItem(createCartItem(ticket, { time: date2.start_time }));
34309
+ }
34310
+ }
34311
+ };
34312
+ const filter$2 = {
34313
+ name: "events:admission:day",
34314
+ calendarEndpoint: "events",
34315
+ requires: [
34316
+ { kind: "tsd", field: "selectedDate" },
34317
+ { kind: "tsd", field: "selectedTimeslot" }
34318
+ ],
34319
+ isCalendarVisible: () => true,
34320
+ isTimeslotsVisible: () => true,
34321
+ isTicketsVisible: () => true,
34322
+ loadTimeslots: (tsd) => loadEventsTimeslots(tsd),
34323
+ async loadProducts(segment) {
34324
+ const tsd = segment.ticketSelectionDetails;
34325
+ if (!tsd?.selectedDate || !tsd.selectedTime) return;
34326
+ const all = await shop.asyncFetch(
34327
+ () => shop.getDates({
34328
+ by_bookable: true,
34329
+ // @ts-ignore — bracketed array params are accepted by API
34330
+ "by_museum_ids[]": segment.museumIds ?? tsd.museumIds,
34331
+ "by_exhibition_ids[]": tsd.exhibitionIds,
34332
+ "by_event_ids[]": tsd.eventIds,
34333
+ "by_language_ids[]": segment.languageIds,
34334
+ "by_catch_word_ids[]": segment.catchWordIds,
34335
+ start_at: tsd.selectedDate.toString(),
34336
+ per_page: segment.limit || 30
34337
+ })
34338
+ );
34339
+ const dates = filterDatesInWindow(all, tsd.selectedDate.toString(), tsd.selectedTime);
34340
+ for (const date2 of dates) {
34341
+ if (!date2.event_id || !date2.start_time) continue;
34342
+ const event2 = await shop.asyncFetch(() => shop.getEvent(date2.event_id));
34343
+ if (!event2?.tickets?.length) continue;
34344
+ const { tickets, quotas } = await shop.asyncFetch(
34345
+ () => shop.ticketsAndQuotas({
34346
+ "by_ticket_ids[]": event2.tickets,
34347
+ // @ts-ignore
34348
+ "by_ticket_types[]": ["normal"],
34349
+ by_bookable: true,
34350
+ valid_at: date2.start_time.slice(0, 10)
34351
+ })
34352
+ );
34353
+ shop.capacityManager.addQuotas(quotas);
34354
+ const firstQuota = Object.values(quotas)[0];
34355
+ const time2 = firstQuota ? Object.keys(firstQuota.capacities)[0] : date2.start_time;
34356
+ const available = filterAvailabletickets(tickets, time2);
34357
+ const uiTickets = initUITimeslotTickets(available, time2);
34358
+ for (const t of uiTickets) segment.preCart.addItem(createCartItem(t, { time: time2 }));
34359
+ }
34360
+ }
34361
+ };
34362
+ const filter$1 = {
34363
+ name: "events:admission:timeslot",
34364
+ calendarEndpoint: "events",
34365
+ requires: [
34366
+ { kind: "tsd", field: "selectedDate" },
34367
+ { kind: "tsd", field: "selectedTimeslot" }
34368
+ ],
34369
+ isCalendarVisible: () => true,
34370
+ isTimeslotsVisible: () => true,
34371
+ isTicketsVisible: () => true,
34372
+ loadTimeslots: (tsd) => loadEventsTimeslots(tsd),
34373
+ async loadProducts(segment) {
34374
+ const tsd = segment.ticketSelectionDetails;
34375
+ if (!tsd?.selectedDate || !tsd.selectedTime) return;
34376
+ const all = await shop.asyncFetch(
34377
+ () => shop.getDates({
34378
+ by_bookable: true,
34379
+ // @ts-ignore — bracketed array params are accepted by API
34380
+ "by_museum_ids[]": segment.museumIds ?? tsd.museumIds,
34381
+ "by_exhibition_ids[]": tsd.exhibitionIds,
34382
+ "by_event_ids[]": tsd.eventIds,
34383
+ "by_language_ids[]": segment.languageIds,
34384
+ "by_catch_word_ids[]": segment.catchWordIds,
34385
+ start_at: tsd.selectedDate.toString(),
34386
+ per_page: segment.limit || 30
34387
+ })
34388
+ );
34389
+ const dates = filterDatesInWindow(all, tsd.selectedDate.toString(), tsd.selectedTime);
34390
+ for (const date2 of dates) {
34391
+ if (!date2.event_id || !date2.start_time) continue;
34392
+ const event2 = await shop.asyncFetch(() => shop.getEvent(date2.event_id));
34393
+ if (!event2?.tickets?.length) continue;
34394
+ const { tickets, quotas } = await shop.asyncFetch(
34395
+ () => shop.ticketsAndQuotas({
34396
+ "by_ticket_ids[]": event2.tickets,
34397
+ // @ts-ignore
34398
+ by_ticket_type: "time_slot",
34399
+ by_bookable: true,
34400
+ valid_at: date2.start_time.slice(0, 10)
34401
+ })
34402
+ );
34403
+ shop.capacityManager.addQuotas(quotas);
34404
+ const available = filterAvailabletickets(tickets, date2.start_time);
34405
+ const uiTickets = initUITimeslotTickets(available, date2.start_time);
34406
+ for (const t of uiTickets) segment.preCart.addItem(createCartItem(t, { time: date2.start_time }));
34407
+ }
34408
+ }
34409
+ };
34410
+ const filter = {
34411
+ name: "events:price",
34412
+ calendarEndpoint: "events",
34413
+ requires: [
34414
+ { kind: "tsd", field: "selectedDate" },
34415
+ { kind: "tsd", field: "selectedTimeslot" }
34416
+ ],
34417
+ isCalendarVisible: () => true,
34418
+ isTimeslotsVisible: () => true,
34419
+ isTicketsVisible: () => true,
34420
+ loadTimeslots: (tsd) => loadEventsTimeslots(tsd),
34421
+ async loadProducts(segment) {
34422
+ const tsd = segment.ticketSelectionDetails;
34423
+ if (!tsd?.selectedDate || !tsd.selectedTime) return;
34424
+ const all = await shop.asyncFetch(
34425
+ () => shop.getDates({
34426
+ by_bookable: true,
34427
+ // @ts-ignore — bracketed array params are accepted by API
34428
+ "by_museum_ids[]": segment.museumIds ?? tsd.museumIds,
34429
+ "by_exhibition_ids[]": tsd.exhibitionIds,
34430
+ "by_event_ids[]": tsd.eventIds,
34431
+ "by_language_ids[]": segment.languageIds,
34432
+ "by_catch_word_ids[]": segment.catchWordIds,
34433
+ start_at: tsd.selectedDate.toString(),
34434
+ per_page: segment.limit || 30
34435
+ })
34436
+ );
34437
+ const dates = filterDatesInWindow(all, tsd.selectedDate.toString(), tsd.selectedTime);
34438
+ const query = segment.query;
34439
+ for (const date2 of dates) {
34440
+ if (!date2.prices?.length) continue;
34441
+ const prices = query ? date2.prices.filter((p2) => p2.title?.includes(query)) : date2.prices;
34442
+ for (const price of prices) {
34443
+ const ticket = createUIEventTicket(price, date2.id, { event_title: date2.event_title });
34444
+ segment.preCart.addItem(createCartItem(ticket, { time: date2.start_time }));
34445
+ }
34446
+ if (date2.seats) shop.capacityManager.addSeats(date2.id, date2.seats);
34447
+ }
34448
+ }
34449
+ };
34450
+ const REGISTRY = {
34451
+ "ticket:timeslot": filter$a,
34452
+ "ticket:day": filter$9,
34453
+ "ticket:annual": filter$8,
34454
+ "event:admission": filter$7,
34455
+ "event:admission:day": filter$6,
34456
+ "event:admission:timeslot": filter$5,
34457
+ "event:price": filter$4,
34458
+ "events:admission": filter$3,
34459
+ "events:admission:day": filter$2,
34460
+ "events:admission:timeslot": filter$1,
34461
+ "events:price": filter
34462
+ };
34463
+ function getFilter(name) {
34464
+ const filter2 = REGISTRY[name];
34465
+ if (!filter2) {
34466
+ console.warn(
34467
+ `[ticket-selection] Unknown filter "${name}". Valid filters: ${FILTER_NAMES.join(", ")}`
34468
+ );
34469
+ }
34470
+ return filter2;
34471
+ }
34472
+ const validFilterNames = FILTER_NAMES;
33995
34473
  let lastUId = 0;
33996
34474
  class TicketSelectionDetails {
33997
34475
  uid = lastUId++;
33998
- #mode = /* @__PURE__ */ state();
33999
- get mode() {
34000
- return get$2(this.#mode);
34001
- }
34002
- set mode(value) {
34003
- set(this.#mode, value, true);
34004
- }
34005
34476
  #filters = /* @__PURE__ */ state();
34006
34477
  get filters() {
34007
34478
  return get$2(this.#filters);
@@ -34089,48 +34560,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
34089
34560
  addTicketSegment(ticketGroup) {
34090
34561
  this.ticketSegments.push(ticketGroup);
34091
34562
  }
34563
+ get isCalendarVisible() {
34564
+ return Boolean(this.filters?.some((f) => getFilter(f).isCalendarVisible(this)));
34565
+ }
34092
34566
  get isTimeslotsVisible() {
34093
- if (this.filters?.includes("events:scaled-price")) return true;
34094
- if (this.mode === "event") return false;
34095
- return Boolean(this.filters?.includes("timeslot") && this.selectedDate);
34567
+ return Boolean(this.filters?.some((f) => getFilter(f).isTimeslotsVisible(this)));
34096
34568
  }
34097
34569
  get isTicketsVisible() {
34098
- const byFilter = (filter) => {
34099
- switch (filter) {
34100
- case "day":
34101
- return Boolean(this.selectedDate);
34102
- case "annual":
34103
- return true;
34104
- case "event:scaled-price":
34105
- return Boolean(this.selectedDate);
34106
- case "events:scaled-price":
34107
- return true;
34108
- case "event:ticket":
34109
- return Boolean(this.selectedDate);
34110
- case "timeslot":
34111
- switch (this.mode) {
34112
- case "event":
34113
- return Boolean(this.selectedDate);
34114
- case "ticket":
34115
- return Boolean(this.selectedDate && this.selectedTimeslot);
34116
- case "tour":
34117
- return true;
34118
- case void 0:
34119
- return false;
34120
- default:
34121
- const exhaustedChecking2 = this.mode;
34122
- throw new Error(`(isTicketsVisible) Unhandled case: ${exhaustedChecking2}`);
34123
- }
34124
- default:
34125
- const exhaustedChecking = filter;
34126
- throw new Error(`(isTicketsVisible) Unhandled case: ${exhaustedChecking}`);
34127
- }
34128
- };
34129
- return this.filters?.some(byFilter);
34130
- }
34131
- get isCalendarVisible() {
34132
- if (this.filters?.includes("events:scaled-price")) return true;
34133
- return Boolean(this.filters?.includes("timeslot") || this.filters?.includes("day"));
34570
+ return Boolean(this.filters?.some((f) => getFilter(f).isTicketsVisible(this)));
34134
34571
  }
34135
34572
  }
34136
34573
  const KEY$2 = "go-ticket-selection";
@@ -34997,11 +35434,29 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
34997
35434
  customElements.define("go-profile-overview", create_custom_element(Overview, {}, [], []));
34998
35435
  function TicketSelection($$anchor, $$props) {
34999
35436
  push($$props, true);
35000
- let mode = prop($$props, "mode", 7), filters = prop($$props, "filters", 7), eventIds = prop($$props, "eventIds", 7), museumIds = prop($$props, "museumIds", 7), exhibitionIds = prop($$props, "exhibitionIds", 7), selectedDate = prop($$props, "selectedDate", 7), selectedTimeslot = prop($$props, "selectedTimeslot", 7), ticketIds = prop($$props, "ticketIds", 7), ticketGroupIds = prop($$props, "ticketGroupIds", 7);
35437
+ function parseFilters(value) {
35438
+ if (!value) return void 0;
35439
+ const out = [];
35440
+ for (const raw of value.split(",")) {
35441
+ const t = raw.trim();
35442
+ if (!t) continue;
35443
+ if (validFilterNames.includes(t)) {
35444
+ out.push(t);
35445
+ } else {
35446
+ console.warn(`[go-ticket-selection] Unknown filter "${t}". Valid filters: ${validFilterNames.join(", ")}`);
35447
+ }
35448
+ }
35449
+ return out.length ? out : void 0;
35450
+ }
35451
+ let filters = prop($$props, "filters", 7), eventIds = prop($$props, "eventIds", 7), museumIds = prop($$props, "museumIds", 7), exhibitionIds = prop($$props, "exhibitionIds", 7), selectedDate = prop($$props, "selectedDate", 7), selectedTimeslot = prop($$props, "selectedTimeslot", 7), ticketIds = prop($$props, "ticketIds", 7), ticketGroupIds = prop($$props, "ticketGroupIds", 7);
35001
35452
  const details = new TicketSelectionDetails();
35002
35453
  user_effect(() => {
35003
- details.mode = mode();
35004
- details.filters = parseTokens(filters(), validTicketSelectionFilters);
35454
+ if ($$props.$$host.hasAttribute("mode")) {
35455
+ console.warn('[go-ticket-selection] `mode` attribute is deprecated and ignored. Use `filters` instead, e.g. filters="ticket:timeslot".');
35456
+ }
35457
+ });
35458
+ user_effect(() => {
35459
+ details.filters = parseFilters(filters());
35005
35460
  details.eventIds = parseIds(eventIds());
35006
35461
  details.museumIds = parseIds(museumIds());
35007
35462
  details.exhibitionIds = parseIds(exhibitionIds());
@@ -35020,13 +35475,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35020
35475
  setTicketSelectionDetails($$props.$$host, details);
35021
35476
  var $$exports = {
35022
35477
  details,
35023
- get mode() {
35024
- return mode();
35025
- },
35026
- set mode($$value) {
35027
- mode($$value);
35028
- flushSync();
35029
- },
35030
35478
  get filters() {
35031
35479
  return filters();
35032
35480
  },
@@ -35089,7 +35537,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35089
35537
  customElements.define("go-ticket-selection", create_custom_element(
35090
35538
  TicketSelection,
35091
35539
  {
35092
- mode: { attribute: "mode", reflect: true, type: "String" },
35093
35540
  filters: { attribute: "filters", reflect: true, type: "String" },
35094
35541
  eventIds: { attribute: "event-ids", reflect: true, type: "String" },
35095
35542
  ticketIds: { attribute: "ticket-ids", reflect: true, type: "String" },
@@ -35144,232 +35591,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35144
35591
  pop();
35145
35592
  }
35146
35593
  customElements.define("go-tickets-sum", create_custom_element(TicketsSum, {}, [], []));
35147
- async function loadAnnualTickets(segment) {
35148
- const tsd = segment.ticketSelectionDetails;
35149
- if (!tsd || !tsd.filters?.includes("annual")) {
35150
- segment.clear();
35151
- return;
35152
- }
35153
- const tickets = await shop.asyncFetch(() => shop.tickets({
35154
- by_bookable: true,
35155
- // @ts-ignore
35156
- "by_ticket_types[]": ["annual"],
35157
- "by_ticket_ids[]": tsd.ticketIds,
35158
- "by_ticket_group_ids[]": segment.ticketGroupIds ?? tsd.ticketGroupIds
35159
- }));
35160
- const uiTickets = Object.values(tickets).map((t) => createUITicket(t));
35161
- segment.preCart = createCart(uiTickets);
35162
- }
35163
- async function loadDayTickets(segment) {
35164
- const tsd = segment.ticketSelectionDetails;
35165
- if (!tsd) {
35166
- console.warn("(loadDayTickets) tsd is undefined");
35167
- segment.clear();
35168
- return;
35169
- }
35170
- if (!tsd.selectedDate) {
35171
- console.warn("(loadDayTickets) selected-date is not given to the go-ticket-selection");
35172
- segment.clear();
35173
- return;
35174
- }
35175
- const { tickets, quotas } = await shop.asyncFetch(() => shop.ticketsAndQuotas({
35176
- by_bookable: true,
35177
- valid_at: tsd.selectedDate?.toString(),
35178
- // @ts-ignore
35179
- "by_ticket_types[]": ["normal"],
35180
- "by_museum_ids[]": segment.museumIds ?? tsd.museumIds,
35181
- "by_exhibition_ids[]": tsd.exhibitionIds,
35182
- "by_ticket_ids[]": tsd.ticketIds,
35183
- "by_ticket_group_ids[]": segment.ticketGroupIds ?? tsd.ticketGroupIds
35184
- }));
35185
- let timeslot;
35186
- if (quotas && Object.values(quotas).length > 0 && Object.keys(Object.values(quotas)[0].capacities).length > 0) {
35187
- timeslot = Object.keys(Object.values(quotas)[0].capacities)[0];
35188
- }
35189
- shop.capacityManager.addQuotas(quotas);
35190
- const available = filterAvailabletickets(tickets, timeslot);
35191
- const uiTickets = initUITimeslotTickets(available, timeslot);
35192
- segment.preCart = createCart();
35193
- for (const ticket of uiTickets) {
35194
- segment.preCart.addItem(createCartItem(ticket, { time: timeslot }));
35195
- }
35196
- }
35197
- async function load_Event_ScaledPricesTickets(segment) {
35198
- const tsd = segment.ticketSelectionDetails;
35199
- if (!tsd) {
35200
- console.warn("(loadEventScaledPricesTickets) tsd is undefined");
35201
- segment.clear();
35202
- return;
35203
- }
35204
- if (!tsd.eventIds?.length) {
35205
- console.warn("(loadEventScaledPricesTickets) eventIds is undefined");
35206
- segment.clear();
35207
- return;
35208
- }
35209
- if (!segment.filters?.includes("event:scaled-price")) {
35210
- console.warn("(loadEventScaledPricesTickets) filters should include event:scaled-price");
35211
- segment.clear();
35212
- return;
35213
- }
35214
- if (segment.dateId === void 0) {
35215
- console.warn("(loadEventScaledPricesTickets) date-id is not given to the go-ticket-segment");
35216
- segment.clear();
35217
- return;
35218
- }
35219
- if (tsd.eventIds.length > 1) throw new Error("(loadEventScaledPricesTickets) currently we support only one eventId in go-ticket-selection");
35220
- const eid = tsd.eventIds[0];
35221
- const eventDate = await shop.asyncFetch(() => shop.getEventDetailsOnDate(eid, segment.dateId));
35222
- if (eventDate.prices) {
35223
- segment.preCart = createCart();
35224
- for (const price of eventDate.prices) {
35225
- const ticket = createUIEventTicket(price, segment.dateId, { event_title: eventDate.event_title });
35226
- segment.preCart.addItem(createCartItem(ticket, { time: eventDate.start_time }));
35227
- }
35228
- } else console.warn("(loadEventScaledPricesTickets) event.prices is undefined");
35229
- if (eventDate.seats) shop.capacityManager.addSeats(segment.dateId, eventDate.seats);
35230
- else console.warn("(loadEventScaledPricesTickets) event.seats is undefined");
35231
- }
35232
- async function loadEventTickets(segment) {
35233
- const tsd = segment.ticketSelectionDetails;
35234
- if (!tsd) {
35235
- console.warn("(loadEventTickets) tsd is undefined");
35236
- segment.clear();
35237
- return;
35238
- }
35239
- if (!tsd.eventIds?.length) {
35240
- console.warn("(loadEventTickets) eventIds is undefined");
35241
- segment.clear();
35242
- return;
35243
- }
35244
- if (!segment.filters?.includes("event:ticket")) {
35245
- console.warn("(loadEventTickets) filters should include event:tickets");
35246
- segment.clear();
35247
- return;
35248
- }
35249
- if (!tsd.selectedDate) {
35250
- console.warn("(loadEventTickets) selected-date is not given to the go-ticket-selection");
35251
- segment.clear();
35252
- return;
35253
- }
35254
- if (tsd.eventIds.length > 1) throw new Error("(loadEventTickets) currently we support only one eventId in go-ticket-selection");
35255
- const eid = tsd.eventIds[0];
35256
- const event2 = await shop.asyncFetch(() => shop.getEvent(eid));
35257
- const ticketIds = event2.tickets;
35258
- if (ticketIds.length === 0) {
35259
- segment.clear();
35260
- return;
35261
- }
35262
- const { tickets, quotas } = await shop.asyncFetch(() => shop.ticketsAndQuotas({
35263
- "by_ticket_ids[]": ticketIds,
35264
- by_bookable: true,
35265
- valid_at: tsd.selectedDate?.toString(),
35266
- date_id: segment.dateId
35267
- }));
35268
- shop.capacityManager.addQuotas(quotas);
35269
- const available = filterAvailabletickets(tickets, tsd.selectedTime);
35270
- const uiTickets = initUITimeslotTickets(available, tsd.selectedTime);
35271
- segment.preCart = createCart();
35272
- for (const ticket of uiTickets) {
35273
- segment.preCart.addItem(createCartItem(ticket, { time: tsd.selectedTime }));
35274
- }
35275
- }
35276
- const TWO_HOURS_IN_MILLISECONDS = 2 * 60 * 60 * 1e3;
35277
- async function load_Events_ScaledPricesTickets(segment) {
35278
- const tsd = segment.ticketSelectionDetails;
35279
- if (!tsd) {
35280
- console.warn("(load_Events_ScaledPricesTickets) tsd is undefined");
35281
- segment.clear();
35282
- return;
35283
- }
35284
- if (!segment.filters?.includes("events:scaled-price")) {
35285
- console.warn("(load_Events_ScaledPricesTickets) filters should include events:scaled-price");
35286
- segment.clear();
35287
- return;
35288
- }
35289
- if (!tsd.selectedDate) {
35290
- console.warn("(load_Events_ScaledPricesTickets) go-ticket-selection does not have a selected date");
35291
- segment.clear();
35292
- return;
35293
- }
35294
- if (!tsd.selectedTime) {
35295
- console.warn("(load_Events_ScaledPricesTickets) go-ticket-selection does not have a selected time");
35296
- segment.clear();
35297
- return;
35298
- }
35299
- let dates = await shop.asyncFetch(() => shop.getDates({
35300
- // q?: string
35301
- by_bookable: true,
35302
- "by_museum_ids[]": segment.museumIds ?? tsd.museumIds,
35303
- "by_exhibition_ids[]": tsd.exhibitionIds,
35304
- "by_event_ids[]": tsd.eventIds,
35305
- "by_language_ids[]": segment.languageIds,
35306
- "by_catch_word_ids[]": segment.catchWordIds,
35307
- // by_category_ids?: number[]
35308
- start_at: tsd.selectedDate?.toString(),
35309
- //YYYY-MM-DD format
35310
- // end_at?: string // YYYY-MM-DD format
35311
- per_page: segment.limit || 30
35312
- // page?: number
35313
- }));
35314
- segment.preCart = createCart();
35315
- dates = dates.filter((d) => {
35316
- const datePart = d.start_time.slice(0, 10);
35317
- const sameDay = tsd.selectedDate?.toString() == datePart;
35318
- const selectedMs = Date.parse(tsd.selectedTime);
35319
- const startMs = Date.parse(d.start_time);
35320
- const after = startMs >= selectedMs && startMs <= selectedMs + TWO_HOURS_IN_MILLISECONDS;
35321
- const availableSeats = (d.seats?.available ?? 0) > 0;
35322
- return sameDay && after && availableSeats;
35323
- });
35324
- for (const date2 of dates) {
35325
- if (date2.prices) {
35326
- let prices = date2.prices;
35327
- if (segment.query) prices = prices.filter((p2) => p2.title.includes(segment.query));
35328
- for (const price of prices) {
35329
- const ticket = createUIEventTicket(price, date2.id, { event_title: date2.event_title });
35330
- segment.preCart.addItem(createCartItem(ticket, { time: date2.start_time }));
35331
- }
35332
- } else console.warn("(load_Events_ScaledPricesTickets) event.prices is undefined");
35333
- if (date2.seats) {
35334
- shop.capacityManager.addSeats(date2.id, date2.seats);
35335
- } else console.warn("(load_Events_ScaledPricesTickets) event.seats is undefined");
35336
- }
35337
- }
35338
- async function loadTimeslotTickets(segment) {
35339
- const tsd = segment.ticketSelectionDetails;
35340
- if (!tsd) {
35341
- console.warn("(loadTimeslotTickets) tsd is undefined");
35342
- segment.clear();
35343
- return;
35344
- }
35345
- if (!tsd.selectedDate) {
35346
- console.warn("(loadTimeslotTickets) selectedDate is not given to the go-ticket-selection");
35347
- segment.clear();
35348
- return;
35349
- }
35350
- if (!tsd.selectedTimeslot) {
35351
- console.warn("(loadTimeslotTickets) selectedTimeslot is not given to the go-ticket-selection");
35352
- segment.clear();
35353
- return;
35354
- }
35355
- const { tickets, quotas } = await shop.asyncFetch(() => shop.ticketsAndQuotas({
35356
- by_bookable: true,
35357
- valid_at: tsd.selectedDate?.toString(),
35358
- // @ts-ignore
35359
- by_ticket_type: "time_slot",
35360
- "by_museum_ids[]": segment.museumIds ?? tsd.museumIds,
35361
- "by_exhibition_ids[]": tsd.exhibitionIds,
35362
- "by_ticket_ids[]": tsd.ticketIds,
35363
- "by_ticket_group_ids[]": segment.ticketGroupIds ?? tsd.ticketGroupIds
35364
- }));
35365
- shop.capacityManager.addQuotas(quotas);
35366
- const available = filterAvailabletickets(tickets, tsd.selectedTime);
35367
- const uiTickets = initUITimeslotTickets(available, tsd.selectedTime);
35368
- segment.preCart = createCart();
35369
- for (const ticket of uiTickets) {
35370
- segment.preCart.addItem(createCartItem(ticket, { time: tsd.selectedTime }));
35371
- }
35372
- }
35373
35594
  class SegmentDetails {
35374
35595
  #ticketSelectionDetails;
35375
35596
  get ticketSelectionDetails() {
@@ -35385,7 +35606,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35385
35606
  set preCart(value) {
35386
35607
  set(this.#preCart, value, true);
35387
35608
  }
35388
- #filters = /* @__PURE__ */ state("timeslot");
35609
+ #filters = /* @__PURE__ */ state();
35389
35610
  get filters() {
35390
35611
  return get$2(this.#filters);
35391
35612
  }
@@ -35441,28 +35662,27 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35441
35662
  set museumIds(value) {
35442
35663
  set(this.#museumIds, value, true);
35443
35664
  }
35444
- constructor(type, tsdWrapper) {
35445
- this.filters = type;
35665
+ constructor(filters, tsdWrapper) {
35666
+ this.filters = filters === void 0 ? void 0 : Array.isArray(filters) ? filters : [filters];
35446
35667
  this.#ticketSelectionDetails = /* @__PURE__ */ user_derived(() => tsdWrapper.value);
35447
35668
  }
35669
+ get effectiveFilters() {
35670
+ if (this.filters?.length) return this.filters;
35671
+ return this.ticketSelectionDetails?.filters ?? [];
35672
+ }
35448
35673
  clear() {
35449
35674
  this.preCart = createCart([]);
35450
35675
  }
35451
35676
  toString() {
35452
- return JSON.stringify({ filters: this.filters, preCart: this.preCart.toString() });
35453
- }
35454
- loadTickets() {
35455
- const method = {
35456
- timeslot: loadTimeslotTickets,
35457
- annual: loadAnnualTickets,
35458
- day: loadDayTickets,
35459
- custom: () => {
35460
- },
35461
- "event:scaled-price": load_Event_ScaledPricesTickets,
35462
- "events:scaled-price": load_Events_ScaledPricesTickets,
35463
- "event:ticket": loadEventTickets
35464
- }[this.filters];
35465
- method(this);
35677
+ return JSON.stringify({
35678
+ filters: this.effectiveFilters,
35679
+ preCart: this.preCart.toString()
35680
+ });
35681
+ }
35682
+ async loadTickets() {
35683
+ this.preCart = createCart();
35684
+ const filters = this.effectiveFilters.filter((f) => f !== "custom");
35685
+ await Promise.all(filters.map((f) => getFilter(f).loadProducts(this)));
35466
35686
  }
35467
35687
  }
35468
35688
  const KEY = "go-ticket-segment";
@@ -35471,13 +35691,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35471
35691
  function TicketSegment($$anchor, $$props) {
35472
35692
  push($$props, true);
35473
35693
  const filters = prop($$props, "filters", 7), dateId = prop($$props, "dateId", 7), query = prop($$props, "query", 7), limit = prop($$props, "limit", 7), ticketGroupIds = prop($$props, "ticketGroupIds", 7), languageIds = prop($$props, "languageIds", 7), catchWordIds = prop($$props, "catchWordIds", 7), museumIds = prop($$props, "museumIds", 7);
35474
- if (!filters()) throw new Error("filters is required");
35694
+ function parseFilters(value) {
35695
+ if (!value) return void 0;
35696
+ const out = value.split(",").map((s) => s.trim()).filter(Boolean);
35697
+ return out.length ? out : void 0;
35698
+ }
35475
35699
  const tsdWrapper = getTicketSelectionDetails($$props.$$host);
35476
35700
  const tsd = tsdWrapper.value;
35477
- const details = new SegmentDetails(filters(), tsdWrapper);
35701
+ const details = new SegmentDetails(parseFilters(filters()), tsdWrapper);
35478
35702
  setSegmentDetails($$props.$$host, details);
35479
35703
  user_effect(() => {
35480
- details.filters = filters();
35704
+ details.filters = parseFilters(filters());
35481
35705
  details.dateId = dateId();
35482
35706
  details.query = query();
35483
35707
  details.limit = limit();
@@ -35489,13 +35713,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35489
35713
  user_effect(() => {
35490
35714
  details.dateId;
35491
35715
  details.filters;
35492
- details.dateId;
35493
35716
  details.ticketGroupIds;
35494
35717
  details.museumIds;
35495
35718
  details.languageIds;
35496
35719
  details.catchWordIds;
35497
35720
  details.query;
35498
35721
  details.limit;
35722
+ tsd?.filters;
35499
35723
  tsd?.selectedTimeslot;
35500
35724
  tsd?.selectedTime;
35501
35725
  tsd?.selectedDate;
@@ -35807,6 +36031,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35807
36031
  set tsd(value) {
35808
36032
  set(this.#tsd, value);
35809
36033
  }
36034
+ #timeslots = /* @__PURE__ */ state(proxy([]));
36035
+ get timeslots() {
36036
+ return get$2(this.#timeslots);
36037
+ }
36038
+ set timeslots(value) {
36039
+ set(this.#timeslots, value, true);
36040
+ }
35810
36041
  constructor(tsdWrapper) {
35811
36042
  if (!tsdWrapper) return;
35812
36043
  this.#tsd = /* @__PURE__ */ user_derived(() => tsdWrapper.value);
@@ -35815,33 +36046,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35815
36046
  get boockedOutCount() {
35816
36047
  return this.timeslots.filter((t) => t.capacity == 0).length;
35817
36048
  }
35818
- get timeslots() {
35819
- const tsd = this.tsd;
35820
- if (!tsd) return [];
35821
- const date2 = tsd.selectedDate;
35822
- if (!date2) return [];
35823
- const result = snapshot(shop.ticketsAndQuotas({
35824
- by_bookable: true,
35825
- valid_at: date2.toString(),
35826
- // @ts-ignore
35827
- "by_ticket_types[]": ["time_slot"],
35828
- "by_museum_ids[]": tsd.museumIds,
35829
- "by_exhibition_ids[]": tsd.exhibitionIds,
35830
- "by_ticket_ids[]": tsd.ticketIds,
35831
- "by_ticket_group_ids[]": tsd.ticketGroupIds
36049
+ recalculateCapacities() {
36050
+ const date2 = this.tsd?.selectedDate;
36051
+ if (!date2) {
36052
+ this.timeslots = [];
36053
+ return;
36054
+ }
36055
+ this.timeslots = shop.capacityManager.quotaManager.timeslotsOn(date2).map((x) => ({
36056
+ ...x,
36057
+ startAt: x.timeSlot,
36058
+ timeFormatted: x.timeSlot.substring(11, 16),
36059
+ available: x.capacity > 0
35832
36060
  }));
35833
- if (!result) return [];
35834
- let ret = [];
35835
- untrack(() => {
35836
- shop.capacityManager.addQuotas(result.quotas);
35837
- ret = shop.capacityManager.quotaManager.timeslotsOn(tsd.selectedDate).map((x) => ({
35838
- ...x,
35839
- startAt: x.timeSlot,
35840
- timeFormatted: x.timeSlot.substring(11, 16),
35841
- available: x.capacity > 0
35842
- }));
35843
- });
35844
- return ret;
35845
36061
  }
35846
36062
  };
35847
36063
  var root_2$1 = /* @__PURE__ */ from_html(`<li><label> <input type="radio" name="timeslot"/></label></li>`);
@@ -35851,6 +36067,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35851
36067
  const binding_group = [];
35852
36068
  const _tsd = getTicketSelectionDetails($$props.$$host);
35853
36069
  const details = new Details$1(_tsd);
36070
+ user_effect(() => {
36071
+ const tsd = details.tsd;
36072
+ if (!tsd) return;
36073
+ const filters = tsd.filters;
36074
+ const date2 = tsd.selectedDate;
36075
+ untrack(async () => {
36076
+ if (filters?.length && date2) {
36077
+ await Promise.all(filters.map((f) => getFilter(f).loadTimeslots(tsd)));
36078
+ }
36079
+ details.recalculateCapacities();
36080
+ });
36081
+ });
35854
36082
  const dispatchTimeslotSelect = (target, selected) => {
35855
36083
  if (!target || !("dispatchEvent" in target)) return;
35856
36084
  target.dispatchEvent(new CustomEvent("go-timeslot-select", { detail: { selected }, bubbles: true, composed: true }));
@@ -35918,7 +36146,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35918
36146
  append($$anchor2, ul);
35919
36147
  };
35920
36148
  if_block(node, ($$render) => {
35921
- if (details.tsd && details.tsd.filters?.includes("timeslot")) $$render(consequent);
36149
+ if (details.tsd?.isTimeslotsVisible) $$render(consequent);
35922
36150
  });
35923
36151
  }
35924
36152
  append($$anchor, fragment);
@@ -35948,55 +36176,37 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35948
36176
  set selected(value) {
35949
36177
  set(this.#selected, value, true);
35950
36178
  }
36179
+ get endpoint() {
36180
+ const endpoints = this.details?.filters?.map((f) => getFilter(f).calendarEndpoint).filter(Boolean) ?? [];
36181
+ return endpoints[0] ?? null;
36182
+ }
35951
36183
  get dates() {
35952
- if (!this.details) {
35953
- return void 0;
35954
- }
35955
- switch (this.details.mode) {
35956
- case "ticket":
36184
+ if (!this.details) return void 0;
36185
+ switch (this.endpoint) {
36186
+ case "tickets":
35957
36187
  return this.ticketsDates();
35958
- case "event":
36188
+ case "events":
35959
36189
  return this.eventsDates();
35960
- case "tour":
35961
- throw new Error("(Calendar) Tour mode not supported");
35962
- case void 0:
35963
- console.error("(Calendar) Mode is undefined");
35964
- return void 0;
35965
36190
  default:
35966
- const exhaustedChecking = this.details.mode;
35967
- throw new Error(`(Calendar) Unhandled case: ${exhaustedChecking}`);
36191
+ return void 0;
35968
36192
  }
35969
36193
  }
35970
36194
  isDateDisabled(date2) {
35971
36195
  if (this.dates) {
35972
36196
  return date2.compare($ad063034c8620db8$export$d0bdf45af03a6ea3($ad063034c8620db8$export$aa8b41735afcabd2())) < 0 || this.dates[date2.toString()] == "unavailable";
35973
- } else {
35974
- return date2.compare($ad063034c8620db8$export$d0bdf45af03a6ea3($ad063034c8620db8$export$aa8b41735afcabd2())) < 0;
35975
36197
  }
36198
+ return date2.compare($ad063034c8620db8$export$d0bdf45af03a6ea3($ad063034c8620db8$export$aa8b41735afcabd2())) < 0;
35976
36199
  }
35977
36200
  isDateUnavailable(date2) {
35978
- if (this.dates) {
35979
- return this.dates[date2.toString()] == "fully_booked";
35980
- }
35981
- return false;
36201
+ return this.dates?.[date2.toString()] == "fully_booked";
35982
36202
  }
35983
- // @ts-ignore
35984
36203
  get apiFilters() {
35985
- return this.details?.filters?.map((f) => ({
35986
- day: "normal",
35987
- timeslot: "time_slot",
35988
- annual: "annual",
35989
- "event:scaled-price": "scaled_price",
35990
- "events:scaled-price": "not implemented",
35991
- "event:ticket": "not implemented"
35992
- })[f]);
36204
+ return this.details?.filters?.map((f) => getFilter(f).apiToken).filter(Boolean);
35993
36205
  }
35994
36206
  params(startAt) {
35995
36207
  if (!this.details) return {};
35996
36208
  const params = {
35997
36209
  by_bookable: true,
35998
- // This should give a type error, but it doesn't because we are using by_ticket_types[] which the type doesn't know
35999
- // we filter out undefined values
36000
36210
  //@ts-ignore
36001
36211
  "by_ticket_types[]": this.apiFilters,
36002
36212
  "by_ticket_ids[]": this.details.ticketIds,
@@ -36005,7 +36215,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
36005
36215
  "by_exhibition_ids[]": this.details.exhibitionIds,
36006
36216
  "by_event_ids[]": this.details.eventIds,
36007
36217
  depth: "availability_status",
36008
- // these logic are there to minimize fetches
36009
36218
  start_at: startAt.toString(),
36010
36219
  end_at: startAt.add({ months: 1 }).toString()
36011
36220
  };
@@ -36022,13 +36231,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
36022
36231
  }
36023
36232
  eventsDates() {
36024
36233
  const method = shop.calendar.bind(shop);
36025
- const ret = this.fetchPeriod().reduce((prev, startAt) => assign(prev, method(this.params(startAt))), {});
36026
- return ret;
36234
+ return this.fetchPeriod().reduce((prev, startAt) => assign(prev, method(this.params(startAt))), {});
36027
36235
  }
36028
36236
  ticketsDates() {
36029
36237
  const method = shop.ticketsCalendar.bind(shop);
36030
- const ret = this.fetchPeriod().reduce((prev, startAt) => assign(prev, method(this.params(startAt))), {});
36031
- return ret;
36238
+ return this.fetchPeriod().reduce((prev, startAt) => assign(prev, method(this.params(startAt))), {});
36032
36239
  }
36033
36240
  }
36034
36241
  var root_3 = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
@@ -36276,10 +36483,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
36276
36483
  const ticketSelectionDetails = /* @__PURE__ */ user_derived(() => _ticketSelectionDetails.value);
36277
36484
  user_effect(() => {
36278
36485
  ticketsCalendar.details = get$2(ticketSelectionDetails);
36279
- if (get$2(ticketSelectionDetails)) {
36280
- get$2(ticketSelectionDetails).mode;
36281
- get$2(ticketSelectionDetails).selectedDate = void 0;
36282
- }
36283
36486
  });
36284
36487
  $$props.$$host.addEventListener("go-date-select", (e) => {
36285
36488
  if (get$2(ticketSelectionDetails)) {