@gomusdev/web-components 1.33.1 → 1.35.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 (40) hide show
  1. package/dist-js/components/couponRedemption/CouponRedemption.svelte.d.ts +1 -0
  2. package/dist-js/components/couponRedemption/entry.d.ts +0 -0
  3. package/dist-js/components/couponRedemption/lib.d.ts +2 -0
  4. package/dist-js/components/forms/ui/generic/FormDetails.svelte.d.ts +14 -1
  5. package/dist-js/components/forms/ui/specs/onsubmit.spec.d.ts +1 -0
  6. package/dist-js/components/profile/details/Details.spec.d.ts +1 -0
  7. package/dist-js/components/profile/details/Details.svelte.d.ts +1 -0
  8. package/dist-js/components/profile/entry.d.ts +0 -0
  9. package/dist-js/components/profile/overview/Overview.spec.d.ts +1 -0
  10. package/dist-js/components/profile/overview/Overview.svelte.d.ts +1 -0
  11. package/dist-js/components/profile/password/Password.spec.d.ts +1 -0
  12. package/dist-js/components/profile/password/Password.svelte.d.ts +1 -0
  13. package/dist-js/components/ticketSelection/TicketSelectionDetails.svelte.d.ts +4 -4
  14. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/{TicketSegmentDetails.svelte.d.ts → SegmentDetails.svelte.d.ts} +15 -6
  15. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/TicketSegmentEmpty.svelte.d.ts +1 -0
  16. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/annualTickets.svelte.d.ts +2 -2
  17. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/dayTickets.svelte.d.ts +2 -2
  18. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/event_ScaledPriceTickets.spec.d.ts +1 -0
  19. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/event_ScaledPriceTickets.svelte.d.ts +2 -0
  20. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/event_Tickets.svelte.d.ts +2 -0
  21. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/event_Tickets.svelte.spec.d.ts +1 -0
  22. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/events/events_ScaledPriceTickets.spec.d.ts +1 -0
  23. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/events/events_ScaledPriceTickets.svelte.d.ts +2 -0
  24. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/timeslotTickets.svelte.d.ts +2 -2
  25. package/dist-js/factories/DateFactories.d.ts +161 -0
  26. package/dist-js/factories/ScalingPriceFactories.d.ts +11 -0
  27. package/dist-js/gomus-webcomponents.css +25 -36
  28. package/dist-js/gomus-webcomponents.iife.js +699 -237
  29. package/dist-js/gomus-webcomponents.js +699 -237
  30. package/dist-js/lib/models/cart/cart.svelte.d.ts +10 -2
  31. package/dist-js/lib/models/scalePrice/UIScaledPrice.svelte.d.ts +5 -5
  32. package/dist-js/lib/stores/auth.svelte.d.ts +1 -1
  33. package/dist-js/lib/stores/shop.svelte.d.ts +89 -3
  34. package/dist-js/mocks/MSWMocks.d.ts +1 -0
  35. package/dist-js/mocks/mocks.d.ts +15 -3
  36. package/package.json +1 -1
  37. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/eventScaledPriceTickets.svelte.d.ts +0 -2
  38. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/eventTickets.svelte.d.ts +0 -2
  39. /package/dist-js/components/{ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/eventScaledPriceTickets.spec.d.ts → couponRedemption/CouponRedemption.spec.d.ts} +0 -0
  40. /package/dist-js/components/{ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/eventTickets.svelte.spec.d.ts → forms/ui/specs/fill.spec.d.ts} +0 -0
@@ -2045,8 +2045,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
2045
2045
  set_active_effect(previous_effect);
2046
2046
  }
2047
2047
  }
2048
- function listen_to_event_and_reset_event(element, event, handler, on_reset = handler) {
2049
- element.addEventListener(event, () => without_reactive_context(handler));
2048
+ function listen_to_event_and_reset_event(element, event2, handler, on_reset = handler) {
2049
+ element.addEventListener(event2, () => without_reactive_context(handler));
2050
2050
  const prev = element.__on_r;
2051
2051
  if (prev) {
2052
2052
  element.__on_r = () => {
@@ -2828,13 +2828,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
2828
2828
  const all_registered_events = /* @__PURE__ */ new Set();
2829
2829
  const root_event_handles = /* @__PURE__ */ new Set();
2830
2830
  function create_event(event_name, dom, handler, options = {}) {
2831
- function target_handler(event) {
2831
+ function target_handler(event2) {
2832
2832
  if (!options.capture) {
2833
- handle_event_propagation.call(dom, event);
2833
+ handle_event_propagation.call(dom, event2);
2834
2834
  }
2835
- if (!event.cancelBubble) {
2835
+ if (!event2.cancelBubble) {
2836
2836
  return without_reactive_context(() => {
2837
- return handler?.call(this, event);
2837
+ return handler?.call(this, event2);
2838
2838
  });
2839
2839
  }
2840
2840
  }
@@ -2853,6 +2853,18 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
2853
2853
  element.removeEventListener(type, target_handler, options);
2854
2854
  };
2855
2855
  }
2856
+ function event(event_name, dom, handler, capture2, passive) {
2857
+ var options = { capture: capture2, passive };
2858
+ var target_handler = create_event(event_name, dom, handler, options);
2859
+ if (dom === document.body || // @ts-ignore
2860
+ dom === window || // @ts-ignore
2861
+ dom === document || // Firefox has quirky behavior, it can happen that we still get "canplay" events when the element is already removed
2862
+ dom instanceof HTMLMediaElement) {
2863
+ teardown(() => {
2864
+ dom.removeEventListener(event_name, target_handler, options);
2865
+ });
2866
+ }
2867
+ }
2856
2868
  function delegate(events) {
2857
2869
  for (var i = 0; i < events.length; i++) {
2858
2870
  all_registered_events.add(events[i]);
@@ -2862,26 +2874,26 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
2862
2874
  }
2863
2875
  }
2864
2876
  let last_propagated_event = null;
2865
- function handle_event_propagation(event) {
2877
+ function handle_event_propagation(event2) {
2866
2878
  var handler_element = this;
2867
2879
  var owner_document = (
2868
2880
  /** @type {Node} */
2869
2881
  handler_element.ownerDocument
2870
2882
  );
2871
- var event_name = event.type;
2872
- var path = event.composedPath?.() || [];
2883
+ var event_name = event2.type;
2884
+ var path = event2.composedPath?.() || [];
2873
2885
  var current_target = (
2874
2886
  /** @type {null | Element} */
2875
- path[0] || event.target
2887
+ path[0] || event2.target
2876
2888
  );
2877
- last_propagated_event = event;
2889
+ last_propagated_event = event2;
2878
2890
  var path_idx = 0;
2879
- var handled_at = last_propagated_event === event && event.__root;
2891
+ var handled_at = last_propagated_event === event2 && event2.__root;
2880
2892
  if (handled_at) {
2881
2893
  var at_idx = path.indexOf(handled_at);
2882
2894
  if (at_idx !== -1 && (handler_element === document || handler_element === /** @type {any} */
2883
2895
  window)) {
2884
- event.__root = handler_element;
2896
+ event2.__root = handler_element;
2885
2897
  return;
2886
2898
  }
2887
2899
  var handler_idx = path.indexOf(handler_element);
@@ -2893,9 +2905,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
2893
2905
  }
2894
2906
  }
2895
2907
  current_target = /** @type {Element} */
2896
- path[path_idx] || event.target;
2908
+ path[path_idx] || event2.target;
2897
2909
  if (current_target === handler_element) return;
2898
- define_property(event, "currentTarget", {
2910
+ define_property(event2, "currentTarget", {
2899
2911
  configurable: true,
2900
2912
  get() {
2901
2913
  return current_target || owner_document;
@@ -2916,8 +2928,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
2916
2928
  if (delegated != null && (!/** @type {any} */
2917
2929
  current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
2918
2930
  // -> the target could not have been disabled because it emits the event in the first place
2919
- event.target === current_target)) {
2920
- delegated.call(current_target, event);
2931
+ event2.target === current_target)) {
2932
+ delegated.call(current_target, event2);
2921
2933
  }
2922
2934
  } catch (error) {
2923
2935
  if (throw_error) {
@@ -2926,7 +2938,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
2926
2938
  throw_error = error;
2927
2939
  }
2928
2940
  }
2929
- if (event.cancelBubble || parent_element === handler_element || parent_element === null) {
2941
+ if (event2.cancelBubble || parent_element === handler_element || parent_element === null) {
2930
2942
  break;
2931
2943
  }
2932
2944
  current_target = parent_element;
@@ -2940,8 +2952,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
2940
2952
  throw throw_error;
2941
2953
  }
2942
2954
  } finally {
2943
- event.__root = handler_element;
2944
- delete event.currentTarget;
2955
+ event2.__root = handler_element;
2956
+ delete event2.currentTarget;
2945
2957
  set_active_reaction(previous_reaction);
2946
2958
  set_active_effect(previous_effect);
2947
2959
  }
@@ -4752,6 +4764,24 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
4752
4764
  }
4753
4765
  });
4754
4766
  }
4767
+ function bind_checked(input, get2, set2 = get2) {
4768
+ listen_to_event_and_reset_event(input, "change", (is_reset) => {
4769
+ var value = is_reset ? input.defaultChecked : input.checked;
4770
+ set2(value);
4771
+ });
4772
+ if (
4773
+ // If we are hydrating and the value has since changed,
4774
+ // then use the update value from the input instead.
4775
+ hydrating && input.defaultChecked !== input.checked || // If defaultChecked is set, then checked == defaultChecked
4776
+ untrack(get2) == null
4777
+ ) {
4778
+ set2(input.checked);
4779
+ }
4780
+ render_effect(() => {
4781
+ var value = get2();
4782
+ input.checked = Boolean(value);
4783
+ });
4784
+ }
4755
4785
  function get_binding_group_value(group, __value, checked) {
4756
4786
  var value = /* @__PURE__ */ new Set();
4757
4787
  for (var i = 0; i < group.length; i += 1) {
@@ -5157,12 +5187,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
5157
5187
  * @param {(...args: any[]) => any} callback
5158
5188
  * @returns {any}
5159
5189
  */
5160
- $on(event, callback) {
5161
- this.#events[event] = this.#events[event] || [];
5190
+ $on(event2, callback) {
5191
+ this.#events[event2] = this.#events[event2] || [];
5162
5192
  const cb = (...args) => callback.call(this, ...args);
5163
- this.#events[event].push(cb);
5193
+ this.#events[event2].push(cb);
5164
5194
  return () => {
5165
- this.#events[event] = this.#events[event].filter(
5195
+ this.#events[event2] = this.#events[event2].filter(
5166
5196
  /** @param {any} fn */
5167
5197
  (fn) => fn !== cb
5168
5198
  );
@@ -5660,6 +5690,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
5660
5690
  // Unix time (seconds)
5661
5691
  };
5662
5692
  constructor() {
5693
+ this.load();
5663
5694
  setInterval(() => this.load(), 1e3);
5664
5695
  }
5665
5696
  customerLevel() {
@@ -10970,8 +11001,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
10970
11001
  quotaManager.setPrecartItemQuantity(product.id, i.quantity);
10971
11002
  }
10972
11003
  }
10973
- console.log("checking quotas for", p2.id, "on", p2.selectedTime);
10974
- console.log("available timeslots", quotaManager.timeslots());
10975
11004
  const cap = quotaManager.ticketCapacity(p2.id, p2.selectedTime);
10976
11005
  const total = quotaManager.totalCapacity(p2.id, p2.selectedTime);
10977
11006
  return {
@@ -10981,11 +11010,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
10981
11010
  unavailable: total === 0
10982
11011
  };
10983
11012
  };
10984
- function isUIEventTicket(x) {
11013
+ function isUIScaledPricesTicket(x) {
10985
11014
  return x.product_type === "Event";
10986
11015
  }
10987
11016
  let uuid$1 = 1;
10988
- function createUIEventTicket(apiTicket, dateId, options) {
11017
+ function createUIScaledPricesTicket(apiTicket, dateId, options) {
10989
11018
  const finalOptions = {
10990
11019
  minAvailableCapacity: 0,
10991
11020
  selectedTime: "",
@@ -11012,7 +11041,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11012
11041
  }
11013
11042
  const maxQuantity_Seats = function(manager, cart, item, preCart) {
11014
11043
  if (manager.capacityPolicy(item) !== "seats") throw new Error("(getMaxQuantitySeats) impossible");
11015
- if (!isUIEventTicket(item.product)) {
11044
+ if (!isUIScaledPricesTicket(item.product)) {
11016
11045
  throw new Error("(getMaxQuantitySeats) impossible");
11017
11046
  }
11018
11047
  const p2 = item.product;
@@ -11140,9 +11169,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11140
11169
  if (cart.items.length === lastLength) {
11141
11170
  return;
11142
11171
  }
11143
- const event = cart.items.length > lastLength ? "go-cart-item-added" : "go-cart-item-removed";
11172
+ const event2 = cart.items.length > lastLength ? "go-cart-item-added" : "go-cart-item-removed";
11144
11173
  lastLength = cart.items.length;
11145
- document.dispatchEvent(new CustomEvent(event, { detail: cart.items.length }));
11174
+ document.dispatchEvent(new CustomEvent(event2, { detail: cart.items.length }));
11146
11175
  });
11147
11176
  });
11148
11177
  }
@@ -11173,7 +11202,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11173
11202
  ...base
11174
11203
  };
11175
11204
  case "Event":
11176
- if (!isUIEventTicket(this.product)) {
11205
+ if (!isUIScaledPricesTicket(this.product)) {
11177
11206
  throw new Error("Event ticket is not a scale ticket");
11178
11207
  }
11179
11208
  const scaleTicket = this.product;
@@ -11191,7 +11220,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11191
11220
  return this.type + "-" + this.product.id + this.subUId;
11192
11221
  },
11193
11222
  get subUId() {
11194
- if (isUIEventTicket(this.product)) {
11223
+ if (isUIScaledPricesTicket(this.product)) {
11195
11224
  return ` (scale_price: ${this.product.scale_price_id})`;
11196
11225
  }
11197
11226
  return "";
@@ -11221,7 +11250,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11221
11250
  };
11222
11251
  }
11223
11252
  function updateLocalStorage(cart) {
11224
- const content = JSON.stringify(cart.items || []);
11253
+ const content = JSON.stringify({ items: cart.items || [], coupons: cart.coupons || [] });
11225
11254
  localStorage.setItem("go-cart", content);
11226
11255
  return content;
11227
11256
  }
@@ -11233,8 +11262,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11233
11262
  const ticket = createUITicket(cartItem.product);
11234
11263
  return createCartItem(ticket, { time: cartItem.time, quantity: cartItem.quantity });
11235
11264
  case "Event":
11236
- const event = createUIEventTicket(cartItem.product, cartItem.id);
11237
- return createCartItem(event, { time: cartItem.time, quantity: cartItem.quantity });
11265
+ const event2 = createUIScaledPricesTicket(cartItem.product, cartItem.id);
11266
+ return createCartItem(event2, { time: cartItem.time, quantity: cartItem.quantity });
11238
11267
  default:
11239
11268
  const _exhaustiveCheck = type;
11240
11269
  throw new Error(`Unhandled case: ${_exhaustiveCheck}`);
@@ -11242,23 +11271,32 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11242
11271
  }
11243
11272
  function loadFromLocalStorage(cart) {
11244
11273
  let lsItems = [];
11274
+ let lsCoupons = [];
11245
11275
  try {
11246
11276
  const content = localStorage.getItem("go-cart");
11247
11277
  if (!content) return [];
11248
- lsItems = JSON.parse(content);
11249
- if (!Array.isArray(lsItems)) {
11250
- console.dir({ lsItems, content });
11251
- throw new Error("go-cart is not an array");
11278
+ const parsed = JSON.parse(content);
11279
+ if (Array.isArray(parsed)) {
11280
+ lsItems = parsed;
11281
+ lsCoupons = [];
11282
+ } else if (typeof parsed === "object" && parsed !== null) {
11283
+ lsItems = parsed.items || [];
11284
+ lsCoupons = parsed.coupons || [];
11285
+ } else {
11286
+ console.dir({ parsed, content });
11287
+ throw new Error("go-cart has invalid format");
11252
11288
  }
11253
11289
  if (lsItems.length === 0) {
11254
11290
  cart.clearItems();
11255
- return [];
11291
+ } else {
11292
+ cart.items = lsItems.map(generateCartItem).filter(defined);
11256
11293
  }
11257
- cart.items = lsItems.map(generateCartItem).filter(defined);
11294
+ cart.clearCoupons();
11295
+ lsCoupons.forEach((coupon) => cart.addCoupon(coupon));
11258
11296
  return cart.items;
11259
11297
  } catch (e) {
11260
11298
  console.error(e);
11261
- localStorage.setItem("go-cart", JSON.stringify([]));
11299
+ localStorage.setItem("go-cart", JSON.stringify({ items: [], coupons: [] }));
11262
11300
  return [];
11263
11301
  }
11264
11302
  }
@@ -11295,8 +11333,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11295
11333
  let lastUuid = 0;
11296
11334
  function createCart(products, contingent = 20) {
11297
11335
  const items = proxy([]);
11336
+ const coupons = proxy([]);
11298
11337
  const cart = {
11299
11338
  items,
11339
+ coupons,
11300
11340
  contingent,
11301
11341
  // caps the total number of items in the cart
11302
11342
  uid: `cart-${lastUuid++}`,
@@ -11322,7 +11362,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11322
11362
  comment: null,
11323
11363
  reference: null,
11324
11364
  payment_mode_id: shop.settings?.defaultPaymentModeId,
11325
- coupons: [],
11365
+ coupons: this.coupons,
11326
11366
  donations: [],
11327
11367
  affiliate: {},
11328
11368
  total: this.totalPriceCents
@@ -11348,6 +11388,20 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11348
11388
  },
11349
11389
  addProducts(products2) {
11350
11390
  products2.forEach((p2) => this.addItem(createCartItem(p2)));
11391
+ },
11392
+ addCoupon(token) {
11393
+ if (!this.coupons.includes(token)) {
11394
+ this.coupons.push(token);
11395
+ }
11396
+ },
11397
+ removeCoupon(token) {
11398
+ const index2 = this.coupons.indexOf(token);
11399
+ if (index2 > -1) {
11400
+ this.coupons.splice(index2, 1);
11401
+ }
11402
+ },
11403
+ clearCoupons() {
11404
+ while (this.coupons.length > 0) this.coupons.pop();
11351
11405
  }
11352
11406
  };
11353
11407
  if (products) products.forEach((p2) => cart.addItem(createCartItem(p2)));
@@ -12305,6 +12359,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12305
12359
  }
12306
12360
  const CALENDAR_ENDPOINT = "/api/v4/calendar";
12307
12361
  const TICKETS_CALENDAR_ENDPOINT = "/api/v4/tickets/calendar";
12362
+ const VALIDATE_TOKEN_ENDPOINT = "/api/v4/auth/validate_token";
12308
12363
  const TICKET_AND_QUOTAS_ENDPOINT = "/api/v4/tickets/list_and_quotas";
12309
12364
  const TICKETS_ENDPOINT = "/api/v4/tickets";
12310
12365
  const SIGN_IN_ENDPOINT = "/api/v4/auth/sign_in";
@@ -12422,6 +12477,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12422
12477
  get _data() {
12423
12478
  return get$2(this.#data);
12424
12479
  }
12480
+ validateToken() {
12481
+ return this.fetchAndCache(VALIDATE_TOKEN_ENDPOINT, `validateToken`, "", { cache: 5 });
12482
+ }
12425
12483
  ticketsCalendar(params) {
12426
12484
  return this.fetchAndCache(TICKETS_CALENDAR_ENDPOINT, `ticketsCalendar-${JSON.stringify(params)}`, "data", { cache: 60, query: params });
12427
12485
  }
@@ -12457,6 +12515,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12457
12515
  if (!asGuest) requiredFields.push("password", "password_confirmation");
12458
12516
  return this.apiPost(SIGN_UP_ENDPOINT, { body: params, requiredFields });
12459
12517
  }
12518
+ getDates(query) {
12519
+ return this.fetchAndCache("/api/v4/dates", `dates-${JSON.stringify(query)}`, "dates", { query, cache: 60 });
12520
+ }
12521
+ updatePassword(params) {
12522
+ return this.apiPut("/api/v4/auth/password", {
12523
+ body: params,
12524
+ requiredFields: ["current_password", "password", "password_confirmation"]
12525
+ });
12526
+ }
12460
12527
  passwordReset(params) {
12461
12528
  return this.apiPost("/api/v4/auth/password", { body: params, requiredFields: ["email"] });
12462
12529
  }
@@ -12492,7 +12559,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12492
12559
  console.warn("(fetchAndCache) Couldn't fetch, Shop not loaded!");
12493
12560
  return get$2(this.#data)[dataKey];
12494
12561
  }
12495
- const query = assign(options.query, { per_page: 1e3 });
12562
+ const query = assign({ per_page: 1e3 }, options.query);
12496
12563
  const fetchId = endpoint + JSON.stringify(query);
12497
12564
  const isNotFetchedYet = !this.#fetchStatus[fetchId];
12498
12565
  const isCacheExpired = this.#fetchStatus[fetchId]?.fetchedAt < Date.now() - options.cache * 1e3;
@@ -12522,6 +12589,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12522
12589
  requiredFields: ["date", "ticket_ids"]
12523
12590
  });
12524
12591
  }
12592
+ getCouponSaleByBarcode(token) {
12593
+ return this.fetchAndCache(`/api/v4/coupon_sales/barcode/${token}`, `coupon_sale_barcode_${token}`, "coupon_sale");
12594
+ }
12525
12595
  getEventDetailsOnDate(eventId, dateId) {
12526
12596
  return this.fetchAndCache(`/api/v4/events/${eventId}/dates/${dateId}`, `/api/v4/events/${eventId}/dates/${dateId}`, "date");
12527
12597
  }
@@ -12568,13 +12638,23 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12568
12638
  * @return {Promise<T>} A promise that resolves with the typed response of the POST request.
12569
12639
  */
12570
12640
  async apiPost(path, options) {
12641
+ return this.apiCall(path, { method: "POST", ...options });
12642
+ }
12643
+ async apiPut(path, options) {
12644
+ return this.apiCall(path, { method: "PUT", ...options });
12645
+ }
12646
+ async apiDELETE(path, options) {
12647
+ return this.apiCall(path, { method: "DELETE", ...options });
12648
+ }
12649
+ async apiCall(path, options) {
12571
12650
  this.#ensureApi();
12572
12651
  const { body, params = {}, requiredFields } = options;
12573
12652
  const validationErrors = validateApiPostBody(body, requiredFields);
12574
12653
  if (Object.keys(validationErrors).length > 0) {
12575
12654
  return { error: { errors: validationErrors } };
12576
12655
  }
12577
- const ret = await this.client.POST(path, { body, params: assign(this.#defaultApiParams, params) });
12656
+ const httpMethod = this.client[options.method];
12657
+ const ret = await httpMethod(path, { body, params: assign(this.#defaultApiParams, params) });
12578
12658
  return ret;
12579
12659
  }
12580
12660
  /**
@@ -12603,7 +12683,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12603
12683
  }
12604
12684
  const ret = await this.client.GET(path, params);
12605
12685
  this.#fetchStatus[fetchId] = { status: "completed", fetchedAt: Date.now() };
12606
- return ret.data;
12686
+ return ret.data || ret;
12607
12687
  }
12608
12688
  #canFetch = () => {
12609
12689
  return this.apiUrl !== void 0 && this.shopDomain !== void 0 && this.locale !== void 0 && this.client !== void 0;
@@ -15169,6 +15249,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15169
15249
  description: "",
15170
15250
  autocomplete: "current-password"
15171
15251
  },
15252
+ currentPassword: {
15253
+ key: "current_password",
15254
+ apiKey: "current_password",
15255
+ type: "password",
15256
+ label: "user.registration.form.password",
15257
+ placeholder: "",
15258
+ description: "",
15259
+ autocomplete: "current-password"
15260
+ },
15172
15261
  newPassword: {
15173
15262
  key: "password",
15174
15263
  apiKey: "password",
@@ -15278,6 +15367,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15278
15367
  description: "",
15279
15368
  autocomplete: "off",
15280
15369
  validator: string().date()
15370
+ },
15371
+ token: {
15372
+ key: "token",
15373
+ apiKey: "id",
15374
+ type: "text",
15375
+ label: "cart.coupon.form.code",
15376
+ placeholder: "",
15377
+ description: "",
15378
+ autocomplete: "off"
15281
15379
  }
15282
15380
  };
15283
15381
  function createField(data, required) {
@@ -15524,7 +15622,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15524
15622
  this.formId = formId;
15525
15623
  this.form = form;
15526
15624
  }
15527
- #fields = /* @__PURE__ */ state(proxy([]));
15528
15625
  #apiErrors = /* @__PURE__ */ state(proxy([]));
15529
15626
  #isValid = /* @__PURE__ */ user_derived(() => errors(this.fields) == 0);
15530
15627
  get isValid() {
@@ -15557,6 +15654,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15557
15654
  /**
15558
15655
  * Sets API errors for the current instance.
15559
15656
  *
15657
+ * The API returns errors in very different shapes, this method should consume all those shapes
15658
+ *
15560
15659
  * @param {string[] | Record<string, string[]>} errors - Errors passed as an array or an object where keys are API field keys and values are arrays of error messages. If an array is provided, it assigns the errors directly. If an object is provided, it maps the errors to the respective fields based on their API keys.
15561
15660
  */
15562
15661
  set apiErrors(errors2) {
@@ -15565,12 +15664,17 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15565
15664
  set(this.#apiErrors, errors2, true);
15566
15665
  return;
15567
15666
  }
15667
+ if (errors2.errors && isArray(errors2.errors)) {
15668
+ set(this.#apiErrors, errors2.errors, true);
15669
+ }
15568
15670
  if (isString(errors2.error)) {
15569
15671
  set(this.#apiErrors, [errors2.error], true);
15570
15672
  return;
15571
15673
  }
15572
15674
  for (const [key, value] of Object.entries(errors2)) {
15573
15675
  if (key === "full_messages ") continue;
15676
+ if (key === "success") continue;
15677
+ if (key === "errors") continue;
15574
15678
  const field = this.fields.find((f) => f.apiKey === key);
15575
15679
  if (!field) {
15576
15680
  console.error(`(set apiErrors) Field with API key ${key} not found`);
@@ -15603,6 +15707,36 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15603
15707
  const parent = this.form.closest("go-form");
15604
15708
  return Array.from(this.form.querySelectorAll("go-field")).filter((fe) => fe.closest("go-form") === parent).map((fe) => fe.getField?.()).filter((f) => f);
15605
15709
  }
15710
+ toString() {
15711
+ return `Form: ${this.formId}, Fields: [${this.fields.map((f) => f.key).join(", ")}], Data: ${JSON.stringify(this.formData)}`;
15712
+ }
15713
+ /**
15714
+ * Populates the fields of the current instance with the corresponding values from the provided data object.
15715
+ * Filters the fields by matching their `apiKey` to keys in the data object and updates their `value`.
15716
+ *
15717
+ * @param {Record<string, any>} data - An object containing key-value pairs where keys represent the `apiKey` of fields and values represent the data to be filled into each field.
15718
+ */
15719
+ fill(data) {
15720
+ const fs = this.fields;
15721
+ Object.entries(data).forEach(([key, val]) => {
15722
+ console.log(key, val);
15723
+ const f = fs.find((f2) => f2.apiKey === key);
15724
+ if (!f) {
15725
+ console.warn(`(FormDetails.fill) Field with API key ${key} not found.`);
15726
+ return;
15727
+ }
15728
+ if (f.type === "select") {
15729
+ console.log(f.options());
15730
+ if (!f.options?.().find((o) => o.value === val)) {
15731
+ throw new Error(`(FormDetails.fill) Field ${key} has invalid value: ${val}`);
15732
+ }
15733
+ }
15734
+ if (f.type === "checkbox") {
15735
+ if (![true, false].includes(val)) throw new Error(`(FormDetails.fill) Field ${key} has invalid value: ${val}`);
15736
+ }
15737
+ f.value = val;
15738
+ });
15739
+ }
15606
15740
  }
15607
15741
  const KEY$3 = "go-form-details";
15608
15742
  const setDetails$1 = createSetDetails(KEY$3);
@@ -15630,19 +15764,21 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15630
15764
  host.replaceChildren(element);
15631
15765
  return element;
15632
15766
  }
15633
- var root_1$h = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit>Submit</go-submit>`, 3);
15767
+ var root_1$i = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit>Submit</go-submit>`, 3);
15634
15768
  function Form($$anchor, $$props) {
15635
15769
  push($$props, true);
15636
15770
  let formId = prop($$props, "formId", 7), custom2 = prop($$props, "custom", 7);
15637
15771
  const details = new FormDetails(formId(), $$props.$$host);
15638
15772
  setDetails$1($$props.$$host, details);
15639
- async function handleSubmit(event) {
15640
- event.preventDefault();
15773
+ async function handleSubmit(event2) {
15774
+ event2.preventDefault();
15775
+ event2.stopPropagation();
15641
15776
  details.validateForm();
15642
- details?.form?.dispatchEvent(new Event("go-after-validation", event));
15777
+ details?.form?.dispatchEvent(new Event("go-after-validation", event2));
15643
15778
  if (details.isValid) {
15644
15779
  details.apiErrors = {};
15645
- details?.form?.dispatchEvent(new Event("go-submit", event));
15780
+ details?.form?.dispatchEvent(new Event("go-submit", event2));
15781
+ $$props.$$host.dispatchEvent(new Event("submit", { bubbles: true, composed: true }));
15646
15782
  }
15647
15783
  }
15648
15784
  onMount(() => {
@@ -15671,7 +15807,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15671
15807
  var node = first_child(fragment);
15672
15808
  {
15673
15809
  var consequent = ($$anchor2) => {
15674
- var fragment_1 = root_1$h();
15810
+ var fragment_1 = root_1$i();
15675
15811
  var go_all_fields = first_child(fragment_1);
15676
15812
  var go_form_feedback = sibling(go_all_fields, 2);
15677
15813
  sibling(go_form_feedback, 2);
@@ -15694,31 +15830,26 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15694
15830
  ["details"],
15695
15831
  false
15696
15832
  ));
15697
- var root$9 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15833
+ var root$c = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15698
15834
  function PasswordReset($$anchor, $$props) {
15699
15835
  push($$props, true);
15700
- let form;
15701
15836
  let custom2 = prop($$props, "custom", 7, false);
15702
15837
  Forms.defineForm({
15703
15838
  id: "passwordReset",
15704
15839
  fields: [{ key: "email", required: true }]
15705
15840
  });
15706
- async function passwordReset() {
15707
- if (!form) {
15708
- throw new Error("(go-password-reset: form not found");
15709
- }
15710
- const result = await shop.passwordReset(form.details.formData);
15841
+ async function passwordReset(event2) {
15842
+ const form = event2.target;
15843
+ const details = form.details;
15844
+ const result = await shop.passwordReset(details.formData);
15711
15845
  if (result.data) {
15712
15846
  $$props.$$host.dispatchEvent(new Event("go-success", { bubbles: true, composed: true }));
15713
- form.details.successMessage = result.data.message;
15714
- form.details.apiErrors = [];
15847
+ details.successMessage = result.data.message;
15848
+ details.apiErrors = [];
15715
15849
  } else {
15716
- form.details.apiErrors = result.error.errors;
15850
+ details.apiErrors = result.error.errors;
15717
15851
  }
15718
15852
  }
15719
- onMount(() => {
15720
- $$props.$$host.addEventListener("go-submit", passwordReset);
15721
- });
15722
15853
  var $$exports = {
15723
15854
  get custom() {
15724
15855
  return custom2();
@@ -15728,18 +15859,17 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15728
15859
  flushSync();
15729
15860
  }
15730
15861
  };
15731
- var go_form = root$9();
15862
+ var go_form = root$c();
15732
15863
  set_custom_element_data(go_form, "formId", "passwordReset");
15733
15864
  template_effect(() => set_custom_element_data(go_form, "custom", custom2()));
15734
- bind_this(go_form, ($$value) => form = $$value, () => form);
15865
+ event("submit", go_form, passwordReset);
15735
15866
  append($$anchor, go_form);
15736
15867
  return pop($$exports);
15737
15868
  }
15738
15869
  customElements.define("go-password-reset", create_custom_element(PasswordReset, { custom: {} }, [], [], false));
15739
- var root$8 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15870
+ var root$b = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15740
15871
  function SignIn($$anchor, $$props) {
15741
15872
  push($$props, true);
15742
- let form;
15743
15873
  Forms.defineForm({
15744
15874
  id: "signIn",
15745
15875
  fields: [
@@ -15747,23 +15877,19 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15747
15877
  { key: "password", required: true }
15748
15878
  ]
15749
15879
  });
15750
- async function signIn() {
15751
- if (!form) {
15752
- throw new Error("(go-sign-in: form not found");
15753
- }
15754
- const result = await shop.signIn(form.details.formData);
15880
+ async function signIn(event2) {
15881
+ const form = event2.target;
15882
+ const details = form.details;
15883
+ const result = await shop.signIn(details.formData);
15755
15884
  if (result.data) {
15756
15885
  $$props.$$host.dispatchEvent(new Event("go-success", { bubbles: true, composed: true }));
15757
15886
  } else {
15758
- form.details.apiErrors = result.error.errors;
15887
+ details.apiErrors = result.error.errors;
15759
15888
  }
15760
15889
  }
15761
- onMount(() => {
15762
- $$props.$$host.addEventListener("go-submit", signIn);
15763
- });
15764
- var go_form = root$8();
15890
+ var go_form = root$b();
15765
15891
  set_custom_element_data(go_form, "formId", "signIn");
15766
- bind_this(go_form, ($$value) => form = $$value, () => form);
15892
+ event("submit", go_form, signIn);
15767
15893
  append($$anchor, go_form);
15768
15894
  pop();
15769
15895
  }
@@ -15776,7 +15902,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15776
15902
  [],
15777
15903
  false
15778
15904
  ));
15779
- var root$7 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15905
+ var root$a = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
15780
15906
  function SignUp($$anchor, $$props) {
15781
15907
  push($$props, true);
15782
15908
  Forms.defineForm({
@@ -15798,24 +15924,19 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15798
15924
  { key: "acceptTerms", required: true }
15799
15925
  ]
15800
15926
  });
15801
- let form;
15802
- async function signUp() {
15803
- if (!form) {
15804
- return;
15805
- }
15806
- const result = await shop.signUp(form.details.formData, false);
15927
+ async function signUp(event2) {
15928
+ const form = event2.target;
15929
+ const details = form.details;
15930
+ const result = await shop.signUp(details.formData, false);
15807
15931
  if (result.data) {
15808
15932
  $$props.$$host.dispatchEvent(new Event("go-success", { bubbles: true, composed: true }));
15809
15933
  } else {
15810
- form.details.apiErrors = result.error.errors;
15934
+ details.apiErrors = result.error.errors;
15811
15935
  }
15812
15936
  }
15813
- onMount(() => {
15814
- $$props.$$host.addEventListener("go-submit", signUp);
15815
- });
15816
- var go_form = root$7();
15937
+ var go_form = root$a();
15817
15938
  set_custom_element_data(go_form, "formId", "signUp");
15818
- bind_this(go_form, ($$value) => form = $$value, () => form);
15939
+ event("submit", go_form, signUp);
15819
15940
  append($$anchor, go_form);
15820
15941
  pop();
15821
15942
  }
@@ -15828,12 +15949,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15828
15949
  [],
15829
15950
  false
15830
15951
  ));
15831
- var root_1$g = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span><span class="go-cart-item-time" data-testid="cart-item-time"> </span>`, 1);
15832
- var root$6 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"><span class="go-cart-item-title-event-title"> </span><span class="go-cart-item-title-ticket-title"> </span></span><!></li>`);
15952
+ var root_1$h = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span><span class="go-cart-item-time" data-testid="cart-item-time"> </span>`, 1);
15953
+ var root$9 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"><span class="go-cart-item-title-event-title"> </span><span class="go-cart-item-title-ticket-title"> </span></span><!></li>`);
15833
15954
  function Event$2($$anchor, $$props) {
15834
15955
  push($$props, true);
15835
15956
  let cartItem = prop($$props, "cartItem", 7);
15836
- if (!isUIEventTicket(cartItem().product)) throw new Error("Product is not an event ticket");
15957
+ if (!isUIScaledPricesTicket(cartItem().product)) throw new Error("Product is not an event ticket");
15837
15958
  const product = cartItem().product;
15838
15959
  var $$exports = {
15839
15960
  get cartItem() {
@@ -15844,7 +15965,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15844
15965
  flushSync();
15845
15966
  }
15846
15967
  };
15847
- var li = root$6();
15968
+ var li = root$9();
15848
15969
  var span = child(li);
15849
15970
  var span_1 = child(span);
15850
15971
  var text2 = child(span_1, true);
@@ -15856,7 +15977,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15856
15977
  var node = sibling(span);
15857
15978
  {
15858
15979
  var consequent = ($$anchor2) => {
15859
- var fragment = root_1$g();
15980
+ var fragment = root_1$h();
15860
15981
  var span_3 = first_child(fragment);
15861
15982
  var text_2 = child(span_3, true);
15862
15983
  reset(span_3);
@@ -15889,8 +16010,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15889
16010
  }
15890
16011
  create_custom_element(Event$2, { cartItem: {} }, [], [], true);
15891
16012
  var root_2$q = /* @__PURE__ */ from_html(`<span class="go-cart-item-time" data-testid="cart-item-time"> </span>`);
15892
- var root_1$f = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span> <!>`, 1);
15893
- var root$5 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"> </span> <!></li>`);
16013
+ var root_1$g = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span> <!>`, 1);
16014
+ var root$8 = /* @__PURE__ */ from_html(`<li data-go-cart-item-title=""><span class="go-cart-item-title" data-testid="cart-item-title"> </span> <!></li>`);
15894
16015
  function Ticket($$anchor, $$props) {
15895
16016
  push($$props, true);
15896
16017
  let cartItem = prop($$props, "cartItem", 7);
@@ -15903,14 +16024,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15903
16024
  flushSync();
15904
16025
  }
15905
16026
  };
15906
- var li = root$5();
16027
+ var li = root$8();
15907
16028
  var span = child(li);
15908
16029
  var text2 = child(span, true);
15909
16030
  reset(span);
15910
16031
  var node = sibling(span, 2);
15911
16032
  {
15912
16033
  var consequent_1 = ($$anchor2) => {
15913
- var fragment = root_1$f();
16034
+ var fragment = root_1$g();
15914
16035
  var span_1 = first_child(fragment);
15915
16036
  var text_1 = child(span_1, true);
15916
16037
  reset(span_1);
@@ -15946,7 +16067,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15946
16067
  var root_7$4 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove" data-go-cart-item-remove=""><button>⨉</button></li>`);
15947
16068
  var root_3$7 = /* @__PURE__ */ from_html(`<li class="go-cart-item" data-go-cart-item=""><article><ul><!> <li class="go-cart-item-price" data-go-cart-item-price=""> </li> <li class="go-cart-item-count" data-go-cart-item-count=""> </li> <!> <li class="go-cart-item-sum" data-go-cart-item-sum=""> </li></ul></article></li>`);
15948
16069
  var root_8$1 = /* @__PURE__ */ from_html(`<li class="go-cart-footer-remove" data-go-cart-footer-remove=""></li>`);
15949
- var root_1$e = /* @__PURE__ */ from_html(`<ol data-testid="cart"><li class="go-cart-header" data-go-cart-header="" data-testid="cart-header"><ul><li class="go-cart-header-title" data-go-cart-header-title=""> </li> <li class="go-cart-header-price" data-go-cart-header-price=""> </li> <li class="go-cart-header-count" data-go-cart-header-count=""> </li> <!> <li class="go-cart-header-sum" data-go-cart-header-sum=""> </li></ul></li> <!> <li class="go-cart-footer" data-go-cart-footer="" data-testid="cart-footer"><ul><li class="go-cart-footer-title" data-go-cart-footer-title=""></li> <li class="go-cart-footer-price" data-go-cart-footer-price=""></li> <li class="go-cart-footer-count" data-go-cart-footer-count=""></li> <!> <li class="go-cart-footer-sum" data-go-cart-footer-sum="" data-go-cart-sum=""> </li></ul></li></ol>`);
16070
+ var root_1$f = /* @__PURE__ */ from_html(`<ol data-testid="cart"><li class="go-cart-header" data-go-cart-header="" data-testid="cart-header"><ul><li class="go-cart-header-title" data-go-cart-header-title=""> </li> <li class="go-cart-header-price" data-go-cart-header-price=""> </li> <li class="go-cart-header-count" data-go-cart-header-count=""> </li> <!> <li class="go-cart-header-sum" data-go-cart-header-sum=""> </li></ul></li> <!> <li class="go-cart-footer" data-go-cart-footer="" data-testid="cart-footer"><ul><li class="go-cart-footer-title" data-go-cart-footer-title=""></li> <li class="go-cart-footer-price" data-go-cart-footer-price=""></li> <li class="go-cart-footer-count" data-go-cart-footer-count=""></li> <!> <li class="go-cart-footer-sum" data-go-cart-footer-sum="" data-go-cart-sum=""> </li></ul></li></ol>`);
15950
16071
  function Cart($$anchor, $$props) {
15951
16072
  push($$props, true);
15952
16073
  const preview = prop($$props, "preview", 7, false);
@@ -15964,7 +16085,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
15964
16085
  var node = first_child(fragment);
15965
16086
  {
15966
16087
  var consequent_5 = ($$anchor2) => {
15967
- var ol = root_1$e();
16088
+ var ol = root_1$f();
15968
16089
  var li = child(ol);
15969
16090
  var ul = child(li);
15970
16091
  var li_1 = child(ul);
@@ -16172,6 +16293,67 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
16172
16293
  return pop($$exports);
16173
16294
  }
16174
16295
  customElements.define("go-checkout-form", create_custom_element(CheckoutForm, { custom: {} }, [], [], false));
16296
+ async function redeem(form, host) {
16297
+ if (!form) {
16298
+ throw new Error("(go-coupon-redemption): form not found");
16299
+ }
16300
+ if (!shop.cart) {
16301
+ throw new Error("(go-coupon-redemption): cart not found");
16302
+ }
16303
+ const result = await shop.asyncFetch(() => shop.getCouponSaleByBarcode(form.details.formData.id));
16304
+ if (result?.is_valid && result.is_voucher_for) {
16305
+ const tickets = await shop.asyncFetch(
16306
+ () => shop.tickets({
16307
+ // @ts-ignore - api supports filter even if schema doesn't yet.
16308
+ "by_ticket_ids[]": [result.is_voucher_for]
16309
+ })
16310
+ );
16311
+ const ticket = tickets.find((t) => t.id === result.is_voucher_for);
16312
+ if (!ticket) {
16313
+ form.details.apiErrors ??= [];
16314
+ form.details.apiErrors = [shop.t("cart.coupon.form.errors.error")];
16315
+ return;
16316
+ }
16317
+ const voucherTicket = { ...ticket, price_cents: 0 };
16318
+ shop.cart.addItem(createCartItem(createUITicket(voucherTicket), { quantity: 1 }));
16319
+ const token = form.details.formData.id;
16320
+ shop.cart.addCoupon(token);
16321
+ const tokenField = form.details.fields.find((f) => f.key === "token");
16322
+ if (tokenField) tokenField.value = "";
16323
+ host.dispatchEvent(new Event("go-success", { bubbles: true, composed: true }));
16324
+ } else {
16325
+ form.details.apiErrors ??= [];
16326
+ form.details.apiErrors = [shop.t("cart.coupon.form.errors.notValid")];
16327
+ }
16328
+ }
16329
+ var root$7 = /* @__PURE__ */ from_html(`<go-form><go-field></go-field> <go-errors-feedback></go-errors-feedback> <go-submit> </go-submit></go-form>`, 2);
16330
+ function CouponRedemption($$anchor, $$props) {
16331
+ push($$props, true);
16332
+ let form;
16333
+ Forms.defineForm({
16334
+ id: "couponRedemption",
16335
+ fields: [{ key: "token", required: true }]
16336
+ });
16337
+ async function redeem$1() {
16338
+ await redeem(form, $$props.$$host);
16339
+ }
16340
+ var go_form = root$7();
16341
+ set_custom_element_data(go_form, "formId", "couponRedemption");
16342
+ set_custom_element_data(go_form, "custom", true);
16343
+ var go_field = child(go_form);
16344
+ set_custom_element_data(go_field, "key", "token");
16345
+ var go_errors_feedback = sibling(go_field, 2);
16346
+ var go_submit = sibling(go_errors_feedback, 2);
16347
+ var text2 = child(go_submit, true);
16348
+ reset(go_submit);
16349
+ reset(go_form);
16350
+ bind_this(go_form, ($$value) => form = $$value, () => form);
16351
+ template_effect(($0) => set_text(text2, $0), [() => shop.t("cart.coupon.form.submit")]);
16352
+ event("submit", go_form, redeem$1);
16353
+ append($$anchor, go_form);
16354
+ pop();
16355
+ }
16356
+ customElements.define("go-coupon-redemption", create_custom_element(CouponRedemption, {}, [], [], false));
16175
16357
  function isFunction$1(value) {
16176
16358
  return typeof value === "function";
16177
16359
  }
@@ -17464,8 +17646,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
17464
17646
  function getOwnerDocument(el) {
17465
17647
  return el?.ownerDocument ?? document;
17466
17648
  }
17467
- function isClickTrulyOutside(event, contentNode) {
17468
- const { clientX, clientY } = event;
17649
+ function isClickTrulyOutside(event2, contentNode) {
17650
+ const { clientX, clientY } = event2;
17469
17651
  const rect = contentNode.getBoundingClientRect();
17470
17652
  return clientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom;
17471
17653
  }
@@ -17889,13 +18071,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
17889
18071
  unsubEvents();
17890
18072
  });
17891
18073
  }
17892
- #handleFocus = (event) => {
17893
- if (event.defaultPrevented) return;
18074
+ #handleFocus = (event2) => {
18075
+ if (event2.defaultPrevented) return;
17894
18076
  if (!this.opts.ref.current) return;
17895
18077
  afterTick(() => {
17896
- if (!this.opts.ref.current || this.#isTargetWithinLayer(event.target)) return;
17897
- if (event.target && !this.#isFocusInsideDOMTree) {
17898
- this.#onFocusOutside.current?.(event);
18078
+ if (!this.opts.ref.current || this.#isTargetWithinLayer(event2.target)) return;
18079
+ if (event2.target && !this.#isFocusInsideDOMTree) {
18080
+ this.#onFocusOutside.current?.(event2);
17899
18081
  }
17900
18082
  });
17901
18083
  };
@@ -17922,9 +18104,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
17922
18104
  );
17923
18105
  }
17924
18106
  #handleDismiss = (e) => {
17925
- let event = e;
17926
- if (event.defaultPrevented) {
17927
- event = createWrappedEvent(e);
18107
+ let event2 = e;
18108
+ if (event2.defaultPrevented) {
18109
+ event2 = createWrappedEvent(e);
17928
18110
  }
17929
18111
  this.#interactOutsideProp.current(e);
17930
18112
  };
@@ -17939,9 +18121,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
17939
18121
  this.#unsubClickListener();
17940
18122
  return;
17941
18123
  }
17942
- let event = e;
17943
- if (event.defaultPrevented) {
17944
- event = createWrappedEvent(event);
18124
+ let event2 = e;
18125
+ if (event2.defaultPrevented) {
18126
+ event2 = createWrappedEvent(event2);
17945
18127
  }
17946
18128
  if (this.#behaviorType.current !== "close" && this.#behaviorType.current !== "defer-otherwise-close") {
17947
18129
  this.#unsubClickListener();
@@ -17951,7 +18133,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
17951
18133
  this.#unsubClickListener();
17952
18134
  this.#unsubClickListener = on(this.#documentObj, "click", this.#handleDismiss, { once: true });
17953
18135
  } else {
17954
- this.#interactOutsideProp.current(event);
18136
+ this.#interactOutsideProp.current(event2);
17955
18137
  }
17956
18138
  },
17957
18139
  10
@@ -18346,9 +18528,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
18346
18528
  }
18347
18529
  #handleOpenAutoFocus() {
18348
18530
  if (!this.#container) return;
18349
- const event = new CustomEvent("focusScope.onOpenAutoFocus", { bubbles: false, cancelable: true });
18350
- this.#opts.onOpenAutoFocus.current(event);
18351
- if (!event.defaultPrevented) {
18531
+ const event2 = new CustomEvent("focusScope.onOpenAutoFocus", { bubbles: false, cancelable: true });
18532
+ this.#opts.onOpenAutoFocus.current(event2);
18533
+ if (!event2.defaultPrevented) {
18352
18534
  requestAnimationFrame(() => {
18353
18535
  if (!this.#container) return;
18354
18536
  const firstTabbable = this.#getFirstTabbable();
@@ -18362,9 +18544,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
18362
18544
  }
18363
18545
  }
18364
18546
  #handleCloseAutoFocus() {
18365
- const event = new CustomEvent("focusScope.onCloseAutoFocus", { bubbles: false, cancelable: true });
18366
- this.#opts.onCloseAutoFocus.current?.(event);
18367
- if (!event.defaultPrevented) {
18547
+ const event2 = new CustomEvent("focusScope.onCloseAutoFocus", { bubbles: false, cancelable: true });
18548
+ this.#opts.onCloseAutoFocus.current?.(event2);
18549
+ if (!event2.defaultPrevented) {
18368
18550
  const preFocusedElement = this.#manager.getPreFocusMemory(this);
18369
18551
  if (preFocusedElement && document.contains(preFocusedElement)) {
18370
18552
  try {
@@ -19857,27 +20039,27 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
19857
20039
  ARROW_RIGHT
19858
20040
  ];
19859
20041
  const SELECT_KEYS = [ENTER, SPACE];
19860
- function handleCalendarKeydown({ event, handleCellClick, shiftFocus, placeholderValue }) {
19861
- const currentCell = event.target;
20042
+ function handleCalendarKeydown({ event: event2, handleCellClick, shiftFocus, placeholderValue }) {
20043
+ const currentCell = event2.target;
19862
20044
  if (!isCalendarDayNode(currentCell)) return;
19863
- if (!ARROW_KEYS.includes(event.key) && !SELECT_KEYS.includes(event.key)) return;
19864
- event.preventDefault();
20045
+ if (!ARROW_KEYS.includes(event2.key) && !SELECT_KEYS.includes(event2.key)) return;
20046
+ event2.preventDefault();
19865
20047
  const kbdFocusMap = {
19866
20048
  [ARROW_DOWN]: 7,
19867
20049
  [ARROW_UP]: -7,
19868
20050
  [ARROW_LEFT]: -1,
19869
20051
  [ARROW_RIGHT]: 1
19870
20052
  };
19871
- if (ARROW_KEYS.includes(event.key)) {
19872
- const add = kbdFocusMap[event.key];
20053
+ if (ARROW_KEYS.includes(event2.key)) {
20054
+ const add = kbdFocusMap[event2.key];
19873
20055
  if (add !== void 0) {
19874
20056
  shiftFocus(currentCell, add);
19875
20057
  }
19876
20058
  }
19877
- if (SELECT_KEYS.includes(event.key)) {
20059
+ if (SELECT_KEYS.includes(event2.key)) {
19878
20060
  const cellValue = currentCell.getAttribute("data-value");
19879
20061
  if (!cellValue) return;
19880
- handleCellClick(event, parseStringToDateValue(cellValue, placeholderValue));
20062
+ handleCellClick(event2, parseStringToDateValue(cellValue, placeholderValue));
19881
20063
  }
19882
20064
  }
19883
20065
  function handleCalendarNextPage({
@@ -20538,9 +20720,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
20538
20720
  }
20539
20721
  return date2;
20540
20722
  }
20541
- onkeydown(event) {
20723
+ onkeydown(event2) {
20542
20724
  handleCalendarKeydown({
20543
- event,
20725
+ event: event2,
20544
20726
  handleCellClick: this.handleCellClick,
20545
20727
  shiftFocus: this.shiftFocus,
20546
20728
  placeholderValue: this.opts.placeholder.current
@@ -22299,7 +22481,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
22299
22481
  }
22300
22482
  create_custom_element(Calendar_prev_button, { children: {}, child: {}, id: {}, ref: {}, tabindex: {} }, [], [], true);
22301
22483
  enable_legacy_mode_flag();
22302
- var root_1$d = /* @__PURE__ */ from_html(`<input/>`);
22484
+ var root_1$e = /* @__PURE__ */ from_html(`<input/>`);
22303
22485
  var root_2$c = /* @__PURE__ */ from_html(`<input/>`);
22304
22486
  function Hidden_input($$anchor, $$props) {
22305
22487
  push($$props, true);
@@ -22322,7 +22504,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
22322
22504
  var node = first_child(fragment);
22323
22505
  {
22324
22506
  var consequent = ($$anchor2) => {
22325
- var input = root_1$d();
22507
+ var input = root_1$e();
22326
22508
  attribute_effect(input, () => ({ ...get$2(mergedProps), value: value() }), void 0, void 0, void 0, void 0, true);
22327
22509
  append($$anchor2, input);
22328
22510
  };
@@ -24770,7 +24952,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
24770
24952
  return pop($$exports);
24771
24953
  }
24772
24954
  create_custom_element(Popper_content, { content: {}, isStatic: {}, onPlaced: {} }, [], [], true);
24773
- var root_1$c = /* @__PURE__ */ from_html(`<!> <!>`, 1);
24955
+ var root_1$d = /* @__PURE__ */ from_html(`<!> <!>`, 1);
24774
24956
  function Popper_layer_inner($$anchor, $$props) {
24775
24957
  push($$props, true);
24776
24958
  let popper = prop($$props, "popper", 7), onEscapeKeydown = prop($$props, "onEscapeKeydown", 7), escapeKeydownBehavior = prop($$props, "escapeKeydownBehavior", 7), preventOverflowTextSelection = prop($$props, "preventOverflowTextSelection", 7), id = prop($$props, "id", 7), onPointerDown = prop($$props, "onPointerDown", 7), onPointerUp = prop($$props, "onPointerUp", 7), side = prop($$props, "side", 7), sideOffset = prop($$props, "sideOffset", 7), align = prop($$props, "align", 7), alignOffset = prop($$props, "alignOffset", 7), arrowPadding = prop($$props, "arrowPadding", 7), avoidCollisions = prop($$props, "avoidCollisions", 7), collisionBoundary = prop($$props, "collisionBoundary", 7), collisionPadding = prop($$props, "collisionPadding", 7), sticky = prop($$props, "sticky", 7), hideWhenDetached = prop($$props, "hideWhenDetached", 7), updatePositionStrategy = prop($$props, "updatePositionStrategy", 7), strategy = prop($$props, "strategy", 7), dir = prop($$props, "dir", 7), preventScroll = prop($$props, "preventScroll", 7), wrapperId = prop($$props, "wrapperId", 7), style = prop($$props, "style", 7), onPlaced = prop($$props, "onPlaced", 7), onInteractOutside = prop($$props, "onInteractOutside", 7), onCloseAutoFocus = prop($$props, "onCloseAutoFocus", 7), onOpenAutoFocus = prop($$props, "onOpenAutoFocus", 7), onFocusOutside = prop($$props, "onFocusOutside", 7), interactOutsideBehavior = prop($$props, "interactOutsideBehavior", 7, "close"), loop = prop($$props, "loop", 7), trapFocus = prop($$props, "trapFocus", 7, true), isValidEvent2 = prop($$props, "isValidEvent", 7, () => false), customAnchor = prop($$props, "customAnchor", 7, null), isStatic = prop($$props, "isStatic", 7, false), enabled = prop($$props, "enabled", 7), ref = prop($$props, "ref", 7), tooltip = prop($$props, "tooltip", 7, false), restProps = /* @__PURE__ */ rest_props($$props, [
@@ -25081,7 +25263,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
25081
25263
  const content = ($$anchor2, $$arg0) => {
25082
25264
  let floatingProps = () => $$arg0?.().props;
25083
25265
  let wrapperProps = () => $$arg0?.().wrapperProps;
25084
- var fragment_1 = root_1$c();
25266
+ var fragment_1 = root_1$d();
25085
25267
  var node = first_child(fragment_1);
25086
25268
  {
25087
25269
  var consequent = ($$anchor3) => {
@@ -27536,7 +27718,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
27536
27718
  }
27537
27719
  create_custom_element(Date_field_hidden_input, {}, [], [], true);
27538
27720
  var root_2$b = /* @__PURE__ */ from_html(`<div><!></div>`);
27539
- var root$4 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
27721
+ var root$6 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
27540
27722
  function Date_field_input($$anchor, $$props) {
27541
27723
  const uid = props_id();
27542
27724
  push($$props, true);
@@ -27594,7 +27776,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
27594
27776
  flushSync();
27595
27777
  }
27596
27778
  };
27597
- var fragment = root$4();
27779
+ var fragment = root$6();
27598
27780
  var node = first_child(fragment);
27599
27781
  {
27600
27782
  var consequent = ($$anchor2) => {
@@ -28946,7 +29128,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
28946
29128
  var root_7$3 = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
28947
29129
  var root_9$2 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
28948
29130
  var root_6$2 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
28949
- var root_1$b = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
29131
+ var root_1$c = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
28950
29132
  function DatePicker_1($$anchor, $$props) {
28951
29133
  push($$props, true);
28952
29134
  let dateString = prop($$props, "dateString", 15), labelClass = prop($$props, "labelClass", 7), inputClass = prop($$props, "inputClass", 7);
@@ -28988,7 +29170,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
28988
29170
  set(date2, $$value, true);
28989
29171
  },
28990
29172
  children: ($$anchor3, $$slotProps) => {
28991
- var fragment_1 = root_1$b();
29173
+ var fragment_1 = root_1$c();
28992
29174
  var node_1 = first_child(fragment_1);
28993
29175
  component(node_1, () => Date_field_label, ($$anchor4, DatePicker_Label) => {
28994
29176
  DatePicker_Label($$anchor4, {
@@ -29196,7 +29378,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29196
29378
  }
29197
29379
  create_custom_element(DatePicker_1, { dateString: {}, labelClass: {}, inputClass: {} }, [], [], true);
29198
29380
  var root_2$6 = /* @__PURE__ */ from_html(`<span class="go-field-star" aria-hidden="true">*</span>`);
29199
- var root_1$a = /* @__PURE__ */ from_html(` <!>`, 1);
29381
+ var root_1$b = /* @__PURE__ */ from_html(` <!>`, 1);
29200
29382
  var root_3$5 = /* @__PURE__ */ from_html(`<label><!></label> <input/>`, 1);
29201
29383
  var root_4$3 = /* @__PURE__ */ from_html(`<label><input/> <span class="go-checkbox-label"><!></span></label>`);
29202
29384
  var root_7$2 = /* @__PURE__ */ from_html(`<option> </option>`);
@@ -29208,7 +29390,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29208
29390
  push($$props, true);
29209
29391
  const labelText = ($$anchor2) => {
29210
29392
  next();
29211
- var fragment = root_1$a();
29393
+ var fragment = root_1$b();
29212
29394
  var text2 = first_child(fragment);
29213
29395
  var node = sibling(text2);
29214
29396
  {
@@ -29256,7 +29438,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29256
29438
  const checkbox = ($$anchor2) => {
29257
29439
  var label_2 = root_4$3();
29258
29440
  var input_2 = child(label_2);
29259
- var event_handler = (e) => field(field().value = e.target.checked, true);
29260
29441
  attribute_effect(
29261
29442
  input_2,
29262
29443
  () => ({
@@ -29264,7 +29445,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29264
29445
  ...restProps,
29265
29446
  name: field().key,
29266
29447
  type: "checkbox",
29267
- onchange: event_handler
29448
+ value: "true"
29268
29449
  }),
29269
29450
  void 0,
29270
29451
  void 0,
@@ -29281,6 +29462,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29281
29462
  set_class(label_2, 1, clsx(labelClass()));
29282
29463
  set_attribute(label_2, "for", get$2(inputId));
29283
29464
  });
29465
+ bind_checked(
29466
+ input_2,
29467
+ () => {
29468
+ return field().value === true;
29469
+ },
29470
+ (value) => {
29471
+ field(field().value = value, true);
29472
+ }
29473
+ );
29284
29474
  append($$anchor2, label_2);
29285
29475
  };
29286
29476
  const select = ($$anchor2) => {
@@ -29427,7 +29617,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29427
29617
  const snippet$1 = /* @__PURE__ */ user_derived(() => map[field().type]);
29428
29618
  let inputId = /* @__PURE__ */ user_derived(() => $$props.id || `go-field-${Math.random().toString(36).substring(2, 9)}`);
29429
29619
  function onblur() {
29430
- if (field().type == "checkbox") return;
29620
+ if (field().type === "checkbox") return;
29431
29621
  if (field().value) if (get$2(details))
29432
29622
  get$2(details).validateField(field());
29433
29623
  else field().validate();
@@ -29507,10 +29697,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29507
29697
  [],
29508
29698
  true
29509
29699
  );
29510
- var root_1$9 = /* @__PURE__ */ from_html(`<span> </span>`);
29700
+ var root_1$a = /* @__PURE__ */ from_html(`<span> </span>`);
29511
29701
  var root_3$4 = /* @__PURE__ */ from_html(`<li> </li>`);
29512
29702
  var root_2$5 = /* @__PURE__ */ from_html(`<ul class="go-field-errors" role="alert"></ul>`);
29513
- var root$3 = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
29703
+ var root$5 = /* @__PURE__ */ from_html(`<!> <!> <!>`, 1);
29514
29704
  function Field($$anchor, $$props) {
29515
29705
  push($$props, true);
29516
29706
  let key = prop($$props, "key", 7), required = prop($$props, "required", 7, false), labelClass = prop($$props, "labelClass", 7), inputClass = prop($$props, "inputClass", 7);
@@ -29569,7 +29759,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29569
29759
  flushSync();
29570
29760
  }
29571
29761
  };
29572
- var fragment = root$3();
29762
+ var fragment = root$5();
29573
29763
  var node = first_child(fragment);
29574
29764
  InputAndLabel(node, {
29575
29765
  get describedById() {
@@ -29592,7 +29782,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29592
29782
  var node_1 = sibling(node, 2);
29593
29783
  {
29594
29784
  var consequent = ($$anchor2) => {
29595
- var span = root_1$9();
29785
+ var span = root_1$a();
29596
29786
  var text2 = child(span, true);
29597
29787
  reset(span);
29598
29788
  template_effect(() => {
@@ -29639,7 +29829,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29639
29829
  ["getField"],
29640
29830
  false
29641
29831
  ));
29642
- var root_1$8 = /* @__PURE__ */ from_html(`<go-field></go-field>`, 2);
29832
+ var root_1$9 = /* @__PURE__ */ from_html(`<go-field></go-field>`, 2);
29643
29833
  function AllFields($$anchor, $$props) {
29644
29834
  push($$props, true);
29645
29835
  let _details = getDetails$1($$props.$$host);
@@ -29648,7 +29838,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29648
29838
  var fragment = comment();
29649
29839
  var node = first_child(fragment);
29650
29840
  each(node, 17, () => get$2(allFields2), index$1, ($$anchor2, field) => {
29651
- var go_field = root_1$8();
29841
+ var go_field = root_1$9();
29652
29842
  template_effect(() => set_custom_element_data(go_field, "key", get$2(field).key));
29653
29843
  template_effect(() => set_custom_element_data(go_field, "required", get$2(field).required));
29654
29844
  append($$anchor2, go_field);
@@ -29661,7 +29851,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29661
29851
  var root_4$2 = /* @__PURE__ */ from_html(`<li> </li>`);
29662
29852
  var root_3$3 = /* @__PURE__ */ from_html(`<ul class="go-error-feedback-api-errors"></ul>`);
29663
29853
  var root_5 = /* @__PURE__ */ from_html(`<p aria-hidden="true"> </p>`);
29664
- var root_1$7 = /* @__PURE__ */ from_html(`<div><!> <!> <!></div>`);
29854
+ var root_1$8 = /* @__PURE__ */ from_html(`<div><!> <!> <!></div>`);
29665
29855
  function ErrorsFeedback($$anchor, $$props) {
29666
29856
  push($$props, true);
29667
29857
  const _details = getDetails$1($$props.$$host);
@@ -29684,7 +29874,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29684
29874
  var node = first_child(fragment);
29685
29875
  {
29686
29876
  var consequent_3 = ($$anchor2) => {
29687
- var div = root_1$7();
29877
+ var div = root_1$8();
29688
29878
  let classes;
29689
29879
  var node_1 = child(div);
29690
29880
  {
@@ -29748,9 +29938,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29748
29938
  pop();
29749
29939
  }
29750
29940
  customElements.define("go-errors-feedback", create_custom_element(ErrorsFeedback, {}, [], [], false));
29751
- var root$2 = /* @__PURE__ */ from_html(`<div class="go-form-feedback"><!></div>`);
29941
+ var root$4 = /* @__PURE__ */ from_html(`<div class="go-form-feedback"><!></div>`);
29752
29942
  function FormFeedback($$anchor, $$props) {
29753
- var div = root$2();
29943
+ var div = root$4();
29754
29944
  var node = child(div);
29755
29945
  slot(node, $$props, "default", {});
29756
29946
  reset(div);
@@ -29783,7 +29973,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29783
29973
  [],
29784
29974
  false
29785
29975
  ));
29786
- var root_1$6 = /* @__PURE__ */ from_html(`<div aria-live="assertive"> </div>`);
29976
+ var root_1$7 = /* @__PURE__ */ from_html(`<div aria-live="assertive"> </div>`);
29787
29977
  function SuccessFeedback($$anchor, $$props) {
29788
29978
  push($$props, true);
29789
29979
  const _details = getDetails$1($$props.$$host);
@@ -29792,7 +29982,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29792
29982
  var node = first_child(fragment);
29793
29983
  {
29794
29984
  var consequent = ($$anchor2) => {
29795
- var div = root_1$6();
29985
+ var div = root_1$7();
29796
29986
  let classes;
29797
29987
  var text2 = child(div, true);
29798
29988
  reset(div);
@@ -29823,7 +30013,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29823
30013
  "day",
29824
30014
  "annual",
29825
30015
  "event:scaled-price",
29826
- "event:ticket"
30016
+ "event:ticket",
30017
+ "events:scaled-price"
29827
30018
  ];
29828
30019
  let lastUId = 0;
29829
30020
  class TicketSelectionDetails {
@@ -29916,6 +30107,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29916
30107
  this.ticketSegments.push(ticketGroup);
29917
30108
  }
29918
30109
  get isTimeslotsVisible() {
30110
+ if (this.filters?.includes("events:scaled-price")) return true;
29919
30111
  if (this.mode === "event") return false;
29920
30112
  return Boolean(this.filters?.includes("timeslot") && this.selectedDate);
29921
30113
  }
@@ -29928,6 +30120,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29928
30120
  return true;
29929
30121
  case "event:scaled-price":
29930
30122
  return Boolean(this.selectedDate);
30123
+ case "events:scaled-price":
30124
+ return true;
29931
30125
  case "event:ticket":
29932
30126
  return Boolean(this.selectedDate);
29933
30127
  case "timeslot":
@@ -29952,6 +30146,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
29952
30146
  return this.filters?.some(byFilter);
29953
30147
  }
29954
30148
  get isCalendarVisible() {
30149
+ if (this.filters?.includes("events:scaled-price")) return true;
29955
30150
  return Boolean(this.filters?.includes("timeslot") || this.filters?.includes("day"));
29956
30151
  }
29957
30152
  }
@@ -30121,6 +30316,39 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30121
30316
  [],
30122
30317
  false
30123
30318
  ));
30319
+ function Link($$anchor, $$props) {
30320
+ push($$props, true);
30321
+ const to = prop($$props, "to", 7);
30322
+ const href = /* @__PURE__ */ user_derived(() => go.config.urls[to()]);
30323
+ const a2 = wrapInElement($$props.$$host, "a");
30324
+ user_effect(() => {
30325
+ if (!get$2(href)) {
30326
+ console.warn(`[go-link] No URL found for route "${to()}".`);
30327
+ a2.removeAttribute("href");
30328
+ return;
30329
+ }
30330
+ a2.setAttribute("href", get$2(href)());
30331
+ });
30332
+ a2.addEventListener("click", (e) => {
30333
+ e.preventDefault();
30334
+ if (!go.config.urls[to()]) {
30335
+ console.warn(`[go-link] No URL found for route "${to()}". You can define it with go.config.urls.${to()} = () => 'https://example.com/my-route'`);
30336
+ return;
30337
+ }
30338
+ go.config.navigateTo(go.config.urls[to()]());
30339
+ });
30340
+ var $$exports = {
30341
+ get to() {
30342
+ return to();
30343
+ },
30344
+ set to($$value) {
30345
+ to($$value);
30346
+ flushSync();
30347
+ }
30348
+ };
30349
+ return pop($$exports);
30350
+ }
30351
+ customElements.define("go-link", create_custom_element(Link, { to: { attribute: "to", reflect: true, type: "String" } }, [], [], false));
30124
30352
  class OrderDetails {
30125
30353
  #token = /* @__PURE__ */ state();
30126
30354
  get token() {
@@ -30181,9 +30409,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30181
30409
  return pop($$exports);
30182
30410
  }
30183
30411
  customElements.define("go-order", create_custom_element(Order, { token: { attribute: "token", reflect: true, type: "String" } }, [], ["orderDetails"], false));
30184
- var root_1$5 = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span> <span class="go-cart-item-time" data-testid="cart-item-time"> </span>`, 1);
30412
+ var root_1$6 = /* @__PURE__ */ from_html(`<span class="go-cart-item-date" data-testid="cart-item-date"> </span> <span class="go-cart-item-time" data-testid="cart-item-time"> </span>`, 1);
30185
30413
  var root_2$3 = /* @__PURE__ */ from_html(`<br/> <span class="go-order-item-quantities"> </span>`, 1);
30186
- var root$1 = /* @__PURE__ */ from_html(`<li><article><ul><li class="go-order-breakdown-count">1</li> <li class="go-order-breakdown-product"><span class="go-order-item-title"> </span> <!> <!> <a class="go-ticket-download" target="_blank">Download</a></li> <li class="go-order-breakdown-item-price"> </li> <li class="go-order-breakdown-passbook"></li></ul></article></li>`);
30414
+ var root$3 = /* @__PURE__ */ from_html(`<li><article><ul><li class="go-order-breakdown-count">1</li> <li class="go-order-breakdown-product"><span class="go-order-item-title"> </span> <!> <!> <a class="go-ticket-download" target="_blank">Download</a></li> <li class="go-order-breakdown-item-price"> </li> <li class="go-order-breakdown-passbook"></li></ul></article></li>`);
30187
30415
  function Event$1($$anchor, $$props) {
30188
30416
  push($$props, true);
30189
30417
  let item = prop($$props, "item", 7), orderDetails = prop($$props, "orderDetails", 7);
@@ -30203,7 +30431,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30203
30431
  flushSync();
30204
30432
  }
30205
30433
  };
30206
- var li = root$1();
30434
+ var li = root$3();
30207
30435
  var article = child(li);
30208
30436
  var ul = child(article);
30209
30437
  var li_1 = sibling(child(ul), 2);
@@ -30213,7 +30441,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30213
30441
  var node = sibling(span, 2);
30214
30442
  {
30215
30443
  var consequent = ($$anchor2) => {
30216
- var fragment = root_1$5();
30444
+ var fragment = root_1$6();
30217
30445
  var span_1 = first_child(fragment);
30218
30446
  var text_1 = child(span_1, true);
30219
30447
  reset(span_1);
@@ -30475,7 +30703,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30475
30703
  return pop($$exports);
30476
30704
  }
30477
30705
  create_custom_element(TicketSale, { item: {}, orderDetails: {} }, [], [], true);
30478
- var root_1$4 = /* @__PURE__ */ from_html(`<ol><li class="data-go-order-breakdown-header"><ul><li class="go-order-breakdown-header-count">Count</li> <li class="go-order-breakdown-header-product">Product</li> <li class="go-order-breakdown-header-price">Price</li> <li class="go-order-breakdown-header-passbook"></li></ul></li> <!> <li class="go-order-breakdown-footer"><ul><li class="go-cart-footer-title"></li> <li class="go-cart-footer-count"></li> <li class="go-cart-footer-price"> </li> <li class="go-cart-footer-passbook"></li></ul></li></ol>`);
30706
+ var root_1$5 = /* @__PURE__ */ from_html(`<ol><li class="data-go-order-breakdown-header"><ul><li class="go-order-breakdown-header-count">Count</li> <li class="go-order-breakdown-header-product">Product</li> <li class="go-order-breakdown-header-price">Price</li> <li class="go-order-breakdown-header-passbook"></li></ul></li> <!> <li class="go-order-breakdown-footer"><ul><li class="go-cart-footer-title"></li> <li class="go-cart-footer-count"></li> <li class="go-cart-footer-price"> </li> <li class="go-cart-footer-passbook"></li></ul></li></ol>`);
30479
30707
  function Breakdown($$anchor, $$props) {
30480
30708
  push($$props, true);
30481
30709
  const _orderDetails = getDetails($$props.$$host);
@@ -30485,7 +30713,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30485
30713
  var node = first_child(fragment);
30486
30714
  {
30487
30715
  var consequent_2 = ($$anchor2) => {
30488
- var ol = root_1$4();
30716
+ var ol = root_1$5();
30489
30717
  var node_1 = sibling(child(ol), 2);
30490
30718
  each(node_1, 17, () => get$2(order).items, (item) => item.id, ($$anchor3, item) => {
30491
30719
  var fragment_1 = comment();
@@ -30744,14 +30972,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30744
30972
  // @ts-ignore
30745
30973
  "by_ticket_types[]": ["annual"],
30746
30974
  "by_ticket_ids[]": tsd.ticketIds,
30747
- "by_ticket_group_ids[]": tsd.ticketGroupIds
30975
+ "by_ticket_group_ids[]": segment.ticketGroupIds ?? tsd.ticketGroupIds
30748
30976
  }));
30749
30977
  const uiTickets = Object.values(tickets).map((t) => createUITicket(t));
30750
30978
  segment.preCart = createCart(uiTickets);
30751
30979
  }
30752
30980
  async function loadDayTickets(segment) {
30753
30981
  const tsd = segment.ticketSelectionDetails;
30754
- if (!tsd || !tsd.filters?.includes("day")) {
30982
+ if (!tsd) {
30983
+ console.warn("(loadDayTickets) tsd is undefined");
30755
30984
  segment.clear();
30756
30985
  return;
30757
30986
  }
@@ -30768,7 +30997,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30768
30997
  "by_museum_ids[]": tsd.museumIds,
30769
30998
  "by_exhibition_ids[]": tsd.exhibitionIds,
30770
30999
  "by_ticket_ids[]": tsd.ticketIds,
30771
- "by_ticket_group_ids[]": tsd.ticketGroupIds
31000
+ "by_ticket_group_ids[]": segment.ticketGroupIds ?? tsd.ticketGroupIds
30772
31001
  }));
30773
31002
  let timeslot;
30774
31003
  if (quotas && Object.values(quotas).length > 0 && Object.keys(Object.values(quotas)[0].capacities).length > 0) {
@@ -30779,7 +31008,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30779
31008
  const uiTickets = initUITimeslotTickets(available, timeslot);
30780
31009
  segment.preCart = createCart(uiTickets);
30781
31010
  }
30782
- async function loadEventScaledPricesTickets(segment) {
31011
+ async function load_Event_ScaledPricesTickets(segment) {
30783
31012
  const tsd = segment.ticketSelectionDetails;
30784
31013
  if (!tsd) {
30785
31014
  console.warn("(loadEventScaledPricesTickets) tsd is undefined");
@@ -30805,7 +31034,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30805
31034
  const eid = tsd.eventIds[0];
30806
31035
  const eventDate = await shop.asyncFetch(() => shop.getEventDetailsOnDate(eid, segment.dateId));
30807
31036
  if (eventDate.prices) {
30808
- const UITickets = eventDate.prices.map((t) => createUIEventTicket(t, segment.dateId, {
31037
+ const UITickets = eventDate.prices.map((t) => createUIScaledPricesTicket(t, segment.dateId, {
30809
31038
  selectedTime: eventDate.start_time,
30810
31039
  event_title: eventDate.event_title
30811
31040
  })) || [];
@@ -30838,8 +31067,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30838
31067
  }
30839
31068
  if (tsd.eventIds.length > 1) throw new Error("(loadEventTickets) currently we support only one eventId in go-ticket-selection");
30840
31069
  const eid = tsd.eventIds[0];
30841
- const event = await shop.asyncFetch(() => shop.getEvent(eid));
30842
- const ticketIds = event.tickets;
31070
+ const event2 = await shop.asyncFetch(() => shop.getEvent(eid));
31071
+ const ticketIds = event2.tickets;
30843
31072
  if (ticketIds.length === 0) {
30844
31073
  segment.clear();
30845
31074
  return;
@@ -30854,9 +31083,77 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30854
31083
  const uiTickets = initUITimeslotTickets(available, tsd.selectedTime);
30855
31084
  segment.preCart = createCart(uiTickets);
30856
31085
  }
31086
+ async function load_Events_ScaledPricesTickets(segment) {
31087
+ const tsd = segment.ticketSelectionDetails;
31088
+ if (!tsd) {
31089
+ console.warn("(load_Events_ScaledPricesTickets) tsd is undefined");
31090
+ segment.clear();
31091
+ return;
31092
+ }
31093
+ if (!segment.filters?.includes("events:scaled-price")) {
31094
+ console.warn("(load_Events_ScaledPricesTickets) filters should include events:scaled-price");
31095
+ segment.clear();
31096
+ return;
31097
+ }
31098
+ if (!tsd.selectedDate) {
31099
+ console.warn("(load_Events_ScaledPricesTickets) go-ticket-selection does not have a selected date");
31100
+ segment.clear();
31101
+ return;
31102
+ }
31103
+ if (!tsd.selectedTime) {
31104
+ console.warn("(load_Events_ScaledPricesTickets) go-ticket-selection does not have a selected time");
31105
+ segment.clear();
31106
+ return;
31107
+ }
31108
+ let dates = await shop.asyncFetch(() => shop.getDates({
31109
+ // q?: string
31110
+ by_bookable: true,
31111
+ "by_museum_ids[]": tsd.museumIds,
31112
+ "by_exhibition_ids[]": tsd.exhibitionIds,
31113
+ "by_event_ids[]": tsd.eventIds,
31114
+ "by_language_ids[]": segment.languageIds,
31115
+ "by_catch_word_ids[]": segment.catchWordIds,
31116
+ // by_category_ids?: number[]
31117
+ start_at: tsd.selectedDate?.toString(),
31118
+ //YYYY-MM-DD format
31119
+ // end_at?: string // YYYY-MM-DD format
31120
+ per_page: segment.limit || 30
31121
+ // page?: number
31122
+ }));
31123
+ segment.preCart = createCart();
31124
+ dates = dates.filter((d) => {
31125
+ const datePart = d.start_time.slice(0, 10);
31126
+ const sameDay = tsd.selectedDate?.toString() == datePart;
31127
+ const after = Date.parse(d.start_time) >= Date.parse(tsd.selectedTime);
31128
+ return sameDay && after;
31129
+ });
31130
+ for (const date2 of dates) {
31131
+ if (date2.prices) {
31132
+ let prices = date2.prices;
31133
+ if (segment.query) prices = prices.filter((p2) => p2.title.includes(segment.query));
31134
+ const tickets = prices.map((t) => createUIScaledPricesTicket(t, date2.id, { selectedTime: date2.start_time, event_title: date2.event_title }));
31135
+ const cartItems = tickets.map((t) => createCartItem(t));
31136
+ segment.preCart.addItems(cartItems);
31137
+ } else console.warn("(load_Events_ScaledPricesTickets) event.prices is undefined");
31138
+ if (date2.seats) {
31139
+ shop.capacityManager.addSeats(date2.id, date2.seats);
31140
+ } else console.warn("(load_Events_ScaledPricesTickets) event.seats is undefined");
31141
+ }
31142
+ }
30857
31143
  async function loadTimeslotTickets(segment) {
30858
31144
  const tsd = segment.ticketSelectionDetails;
30859
- if (!tsd || !(tsd.selectedDate && tsd.selectedTimeslot && tsd.filters?.includes("timeslot"))) {
31145
+ if (!tsd) {
31146
+ console.warn("(loadTimeslotTickets) tsd is undefined");
31147
+ segment.clear();
31148
+ return;
31149
+ }
31150
+ if (!tsd.selectedDate) {
31151
+ console.warn("(loadTimeslotTickets) selectedDate is not given to the go-ticket-selection");
31152
+ segment.clear();
31153
+ return;
31154
+ }
31155
+ if (!tsd.selectedTimeslot) {
31156
+ console.warn("(loadTimeslotTickets) selectedTimeslot is not given to the go-ticket-selection");
30860
31157
  segment.clear();
30861
31158
  return;
30862
31159
  }
@@ -30868,14 +31165,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30868
31165
  "by_museum_ids[]": tsd.museumIds,
30869
31166
  "by_exhibition_ids[]": tsd.exhibitionIds,
30870
31167
  "by_ticket_ids[]": tsd.ticketIds,
30871
- "by_ticket_group_ids[]": tsd.ticketGroupIds
31168
+ "by_ticket_group_ids[]": segment.ticketGroupIds ?? tsd.ticketGroupIds
30872
31169
  }));
30873
31170
  shop.capacityManager.addQuotas(quotas);
30874
31171
  const available = filterAvailabletickets(tickets, tsd.selectedTime);
30875
31172
  const uiTickets = initUITimeslotTickets(available, tsd.selectedTime);
30876
31173
  segment.preCart = createCart(uiTickets);
30877
31174
  }
30878
- class TicketSegmentDetails {
31175
+ class SegmentDetails {
30879
31176
  #ticketSelectionDetails;
30880
31177
  get ticketSelectionDetails() {
30881
31178
  return get$2(this.#ticketSelectionDetails);
@@ -30904,6 +31201,41 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30904
31201
  set dateId(value) {
30905
31202
  set(this.#dateId, value, true);
30906
31203
  }
31204
+ #limit = /* @__PURE__ */ state();
31205
+ get limit() {
31206
+ return get$2(this.#limit);
31207
+ }
31208
+ set limit(value) {
31209
+ set(this.#limit, value, true);
31210
+ }
31211
+ #query = /* @__PURE__ */ state();
31212
+ get query() {
31213
+ return get$2(this.#query);
31214
+ }
31215
+ set query(value) {
31216
+ set(this.#query, value, true);
31217
+ }
31218
+ #ticketGroupIds = /* @__PURE__ */ state(proxy([]));
31219
+ get ticketGroupIds() {
31220
+ return get$2(this.#ticketGroupIds);
31221
+ }
31222
+ set ticketGroupIds(value) {
31223
+ set(this.#ticketGroupIds, value, true);
31224
+ }
31225
+ #languageIds = /* @__PURE__ */ state(proxy([]));
31226
+ get languageIds() {
31227
+ return get$2(this.#languageIds);
31228
+ }
31229
+ set languageIds(value) {
31230
+ set(this.#languageIds, value, true);
31231
+ }
31232
+ #catchWordIds = /* @__PURE__ */ state(proxy([]));
31233
+ get catchWordIds() {
31234
+ return get$2(this.#catchWordIds);
31235
+ }
31236
+ set catchWordIds(value) {
31237
+ set(this.#catchWordIds, value, true);
31238
+ }
30907
31239
  constructor(type, tsdWrapper) {
30908
31240
  this.filters = type;
30909
31241
  this.#ticketSelectionDetails = /* @__PURE__ */ user_derived(() => tsdWrapper.value);
@@ -30912,7 +31244,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30912
31244
  this.preCart = createCart([]);
30913
31245
  }
30914
31246
  toString() {
30915
- return JSON.stringify({ filters: this.filters, preCart: this.preCart.pretty() });
31247
+ return JSON.stringify({ filters: this.filters, preCart: this.preCart.toString() });
30916
31248
  }
30917
31249
  loadTickets() {
30918
31250
  const method = {
@@ -30921,34 +31253,40 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30921
31253
  day: loadDayTickets,
30922
31254
  custom: () => {
30923
31255
  },
30924
- "event:scaled-price": loadEventScaledPricesTickets,
31256
+ "event:scaled-price": load_Event_ScaledPricesTickets,
31257
+ "events:scaled-price": load_Events_ScaledPricesTickets,
30925
31258
  "event:ticket": loadEventTickets
30926
31259
  }[this.filters];
30927
31260
  method(this);
30928
31261
  }
30929
31262
  }
30930
31263
  const KEY = "go-ticket-segment";
30931
- const setTicketSegmentDetails = createSetDetails(KEY);
30932
- const getTicketSegmentDetails = createGetDetails(KEY);
31264
+ const setSegmentDetails = createSetDetails(KEY);
31265
+ const getSegmentDetails = createGetDetails(KEY);
30933
31266
  function TicketSegment($$anchor, $$props) {
30934
31267
  push($$props, true);
30935
- const filters = prop($$props, "filters", 7), dateId = prop($$props, "dateId", 7);
31268
+ 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);
30936
31269
  if (!filters()) throw new Error("filters is required");
30937
31270
  const tsdWrapper = getTicketSelectionDetails($$props.$$host);
30938
31271
  const tsd = tsdWrapper.value;
30939
- const details = new TicketSegmentDetails(filters(), tsdWrapper);
30940
- setTicketSegmentDetails($$props.$$host, details);
30941
- details.filters = filters();
30942
- details.dateId = dateId();
31272
+ const details = new SegmentDetails(filters(), tsdWrapper);
31273
+ setSegmentDetails($$props.$$host, details);
30943
31274
  user_effect(() => {
30944
31275
  details.filters = filters();
30945
31276
  details.dateId = dateId();
31277
+ details.query = query();
31278
+ details.limit = limit();
31279
+ details.ticketGroupIds = parseIds(ticketGroupIds());
31280
+ details.languageIds = parseIds(languageIds());
31281
+ details.catchWordIds = parseIds(catchWordIds());
30946
31282
  });
30947
31283
  user_effect(() => {
30948
31284
  details.dateId;
30949
31285
  details.filters;
30950
31286
  details.dateId;
31287
+ details.ticketGroupIds;
30951
31288
  tsd?.selectedTimeslot;
31289
+ tsd?.selectedTime;
30952
31290
  tsd?.selectedDate;
30953
31291
  untrack(() => {
30954
31292
  details.loadTickets();
@@ -30977,6 +31315,41 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30977
31315
  set dateId($$value) {
30978
31316
  dateId($$value);
30979
31317
  flushSync();
31318
+ },
31319
+ get query() {
31320
+ return query();
31321
+ },
31322
+ set query($$value) {
31323
+ query($$value);
31324
+ flushSync();
31325
+ },
31326
+ get limit() {
31327
+ return limit();
31328
+ },
31329
+ set limit($$value) {
31330
+ limit($$value);
31331
+ flushSync();
31332
+ },
31333
+ get ticketGroupIds() {
31334
+ return ticketGroupIds();
31335
+ },
31336
+ set ticketGroupIds($$value) {
31337
+ ticketGroupIds($$value);
31338
+ flushSync();
31339
+ },
31340
+ get languageIds() {
31341
+ return languageIds();
31342
+ },
31343
+ set languageIds($$value) {
31344
+ languageIds($$value);
31345
+ flushSync();
31346
+ },
31347
+ get catchWordIds() {
31348
+ return catchWordIds();
31349
+ },
31350
+ set catchWordIds($$value) {
31351
+ catchWordIds($$value);
31352
+ flushSync();
30980
31353
  }
30981
31354
  };
30982
31355
  return pop($$exports);
@@ -30984,13 +31357,34 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
30984
31357
  customElements.define("go-ticket-segment", create_custom_element(
30985
31358
  TicketSegment,
30986
31359
  {
31360
+ catchWordIds: { attribute: "catch-word-ids", reflect: true, type: "String" },
30987
31361
  dateId: { attribute: "date-id", reflect: true, type: "Number" },
30988
- filters: { attribute: "filters", reflect: true, type: "String" }
31362
+ filters: { attribute: "filters", reflect: true, type: "String" },
31363
+ languageIds: { attribute: "language-ids", reflect: true, type: "String" },
31364
+ limit: { attribute: "limit", reflect: true, type: "Number" },
31365
+ query: { attribute: "query", reflect: true, type: "String" },
31366
+ ticketGroupIds: { attribute: "ticket-group-ids", reflect: true, type: "String" }
30989
31367
  },
30990
31368
  [],
30991
31369
  ["details"],
30992
31370
  false
30993
31371
  ));
31372
+ function TicketSegmentEmpty($$anchor, $$props) {
31373
+ push($$props, true);
31374
+ const tsdWrapper = getTicketSelectionDetails($$props.$$host);
31375
+ const tsd = tsdWrapper.value;
31376
+ const _details = getSegmentDetails($$props.$$host);
31377
+ const details = _details.value;
31378
+ const numTickets = /* @__PURE__ */ user_derived(() => details?.preCart.items.length);
31379
+ const isVisible = /* @__PURE__ */ user_derived(() => !tsd?.isTicketsVisible || tsd?.isTicketsVisible && get$2(numTickets) === 0);
31380
+ user_effect(() => {
31381
+ $$props.$$host.style.display = get$2(isVisible) ? "block" : "none";
31382
+ $$props.$$host.classList.toggle("is-hidden", !get$2(isVisible));
31383
+ $$props.$$host.classList.toggle("is-visible", get$2(isVisible));
31384
+ });
31385
+ pop();
31386
+ }
31387
+ customElements.define("go-ticket-segment-empty", create_custom_element(TicketSegmentEmpty, {}, [], [], false));
30994
31388
  function selectedTime(product, tsd) {
30995
31389
  switch (product.product_type) {
30996
31390
  case "Ticket":
@@ -31015,7 +31409,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31015
31409
  throw new Error(`(selectedTime) Unhandled Ticket Type: ${exhaustedChecking2}`);
31016
31410
  }
31017
31411
  case "Event":
31018
- if (!isUIEventTicket(product)) {
31412
+ if (!isUIScaledPricesTicket(product)) {
31019
31413
  throw new Error("(selectedTime) this should not happen");
31020
31414
  }
31021
31415
  return product.selectedTime || "";
@@ -31046,13 +31440,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31046
31440
  }
31047
31441
  return options;
31048
31442
  }
31049
- var root_1$3 = /* @__PURE__ */ from_html(`<span class="go-tickets-item-title-event-title"> </span> <span class="go-tickets-item-title-product-title"> </span>`, 1);
31443
+ var root_1$4 = /* @__PURE__ */ from_html(`<span class="go-tickets-item-title-event-title"> </span> <span class="go-tickets-item-title-product-title"> </span>`, 1);
31050
31444
  var root_4 = /* @__PURE__ */ from_html(`<option> </option>`);
31051
31445
  var root_3$1 = /* @__PURE__ */ from_html(`<li><article><ul><li class="go-tickets-item-title"><!></li> <li class="go-tickets-item-description" data-go-tickets-description=""><!></li> <li class="go-tickets-item-price" data-go-tickets-price=""> </li> <li class="go-tickets-item-quality" data-go-tickets-quality=""><select></select></li></ul></article></li>`);
31052
31446
  function Item($$anchor, $$props) {
31053
31447
  push($$props, true);
31054
31448
  const scaled_title = ($$anchor2) => {
31055
- var fragment = root_1$3();
31449
+ var fragment = root_1$4();
31056
31450
  var span = first_child(fragment);
31057
31451
  var text2 = child(span, true);
31058
31452
  reset(span);
@@ -31085,7 +31479,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31085
31479
  ci.time = selectedTime(ci.product, tsd);
31086
31480
  }
31087
31481
  let titleSnippet = default_title;
31088
- if (isUIEventTicket(item().product)) titleSnippet = scaled_title;
31482
+ if (isUIScaledPricesTicket(item().product)) titleSnippet = scaled_title;
31089
31483
  var $$exports = {
31090
31484
  get item() {
31091
31485
  return item();
@@ -31161,17 +31555,17 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31161
31555
  }
31162
31556
  delegate(["change"]);
31163
31557
  create_custom_element(Item, { item: {}, details: {} }, [], [], true);
31164
- var root_1$2 = /* @__PURE__ */ from_html(`<ol class="go-tickets" data-testid="tickets"><li class="go-tickets-header" data-go-tickets-header="" data-testid="tickets-header"><ul><li class="go-tickets-header-title" data-go-tickets-title=""> </li> <li class="go-tickets-header-description" data-go-tickets-description=""> </li> <li class="go-tickets-header-price" data-go-tickets-price=""> </li> <li class="go-tickets-header-quality" data-go-tickets-quality=""> </li></ul></li> <!></ol>`);
31558
+ var root_1$3 = /* @__PURE__ */ from_html(`<ol class="go-tickets" data-testid="tickets"><li class="go-tickets-header" data-go-tickets-header="" data-testid="tickets-header"><ul><li class="go-tickets-header-title" data-go-tickets-title=""> </li> <li class="go-tickets-header-description" data-go-tickets-description=""> </li> <li class="go-tickets-header-price" data-go-tickets-price=""> </li> <li class="go-tickets-header-quality" data-go-tickets-quality=""> </li></ul></li> <!></ol>`);
31165
31559
  function Body($$anchor, $$props) {
31166
31560
  push($$props, true);
31167
- const _details = getTicketSegmentDetails($$props.$$host);
31561
+ const _details = getSegmentDetails($$props.$$host);
31168
31562
  const details = /* @__PURE__ */ user_derived(() => _details.value);
31169
31563
  const anyItems = /* @__PURE__ */ user_derived(() => get$2(details)?.preCart?.items.length && get$2(details)?.preCart?.items.length > 0);
31170
31564
  var fragment = comment();
31171
31565
  var node = first_child(fragment);
31172
31566
  {
31173
31567
  var consequent = ($$anchor2) => {
31174
- var ol = root_1$2();
31568
+ var ol = root_1$3();
31175
31569
  var li = child(ol);
31176
31570
  var ul = child(li);
31177
31571
  var li_1 = child(ul);
@@ -31226,7 +31620,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31226
31620
  customElements.define("go-ticket-segment-body", create_custom_element(Body, {}, [], [], false));
31227
31621
  function Sum($$anchor, $$props) {
31228
31622
  push($$props, true);
31229
- const _details = getTicketSegmentDetails($$props.$$host);
31623
+ const _details = getSegmentDetails($$props.$$host);
31230
31624
  const details = /* @__PURE__ */ user_derived(() => _details.value);
31231
31625
  next();
31232
31626
  var text$1 = text();
@@ -31235,7 +31629,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31235
31629
  pop();
31236
31630
  }
31237
31631
  customElements.define("go-ticket-segment-sum", create_custom_element(Sum, {}, [], [], false));
31238
- let Details$1 = class Details {
31632
+ let Details$2 = class Details {
31239
31633
  #tsd;
31240
31634
  get tsd() {
31241
31635
  return get$2(this.#tsd);
@@ -31282,12 +31676,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31282
31676
  }
31283
31677
  };
31284
31678
  var root_2$1 = /* @__PURE__ */ from_html(`<li><label> <input type="radio" name="timeslot"/></label></li>`);
31285
- var root_1$1 = /* @__PURE__ */ from_html(`<ul data-testid="timeslots"></ul>`);
31679
+ var root_1$2 = /* @__PURE__ */ from_html(`<ul data-testid="timeslots"></ul>`);
31286
31680
  function Timeslots($$anchor, $$props) {
31287
31681
  push($$props, true);
31288
31682
  const binding_group = [];
31289
31683
  const _tsd = getTicketSelectionDetails($$props.$$host);
31290
- const details = new Details$1(_tsd);
31684
+ const details = new Details$2(_tsd);
31291
31685
  const change = (e) => {
31292
31686
  e.target.dispatchEvent(new CustomEvent("go-timeslot-select", {
31293
31687
  detail: { selected: details.tsd.selectedTimeslot },
@@ -31300,7 +31694,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31300
31694
  var node = first_child(fragment);
31301
31695
  {
31302
31696
  var consequent = ($$anchor2) => {
31303
- var ul = root_1$1();
31697
+ var ul = root_1$2();
31304
31698
  each(ul, 20, () => details.timeslots, (timeslot) => timeslot, ($$anchor3, timeslot) => {
31305
31699
  const selected = /* @__PURE__ */ user_derived(() => details.tsd?.selectedTimeslot === timeslot.startAt);
31306
31700
  var li = root_2$1();
@@ -31374,7 +31768,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31374
31768
  }
31375
31769
  get dates() {
31376
31770
  if (!this.details) {
31377
- console.warn("(Calendar) details is undefined");
31378
31771
  return void 0;
31379
31772
  }
31380
31773
  switch (this.details.mode) {
@@ -31412,6 +31805,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31412
31805
  timeslot: "time_slot",
31413
31806
  annual: "annual",
31414
31807
  "event:scaled-price": "scaled_price",
31808
+ "events:scaled-price": "not implemented",
31415
31809
  "event:ticket": "not implemented"
31416
31810
  })[f]);
31417
31811
  }
@@ -31459,7 +31853,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31459
31853
  var root_11 = /* @__PURE__ */ from_html(`<div> </div>`);
31460
31854
  var root_7 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
31461
31855
  var root_2 = /* @__PURE__ */ from_html(`<!> <!>`, 1);
31462
- var root_1 = /* @__PURE__ */ from_html(`<div data-calendar-wrapper=""><!></div>`);
31856
+ var root_1$1 = /* @__PURE__ */ from_html(`<div data-calendar-wrapper=""><!></div>`);
31463
31857
  function CalendarUI($$anchor, $$props) {
31464
31858
  push($$props, true);
31465
31859
  let calendarClass = prop($$props, "calendarClass", 7);
@@ -31481,7 +31875,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31481
31875
  flushSync();
31482
31876
  }
31483
31877
  };
31484
- var div = root_1();
31878
+ var div = root_1$1();
31485
31879
  var node = child(div);
31486
31880
  {
31487
31881
  const children = ($$anchor2, $$arg0) => {
@@ -31731,7 +32125,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31731
32125
  return pop($$exports);
31732
32126
  }
31733
32127
  customElements.define("go-calendar", create_custom_element(Calendar_1, {}, [], ["details"], false));
31734
- class Details {
32128
+ let Details$1 = class Details {
31735
32129
  #ticketSelectionDetails;
31736
32130
  get ticketSelectionDetails() {
31737
32131
  return get$2(this.#ticketSelectionDetails);
@@ -31767,14 +32161,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31767
32161
  const ret = this.ticketSelectionDetails.preCarts.some((cart) => cart.items.some((item) => item.quantity > 0));
31768
32162
  return ret;
31769
32163
  }
31770
- }
31771
- var root = /* @__PURE__ */ from_html(`<button data-add-to-cart-button="" data-testid="go-add-to-cart-button__button"> </button>`);
32164
+ };
32165
+ var root$2 = /* @__PURE__ */ from_html(`<button data-add-to-cart-button="" data-testid="go-add-to-cart-button__button"> </button>`);
31772
32166
  function AddToCartButton($$anchor, $$props) {
31773
32167
  push($$props, true);
31774
32168
  const _tsd = getTicketSelectionDetails($$props.$$host);
31775
- const details = new Details(_tsd);
32169
+ const details = new Details$1(_tsd);
31776
32170
  var $$exports = { details };
31777
- var button = root();
32171
+ var button = root$2();
31778
32172
  button.__click = () => details.addToCart();
31779
32173
  var text2 = child(button, true);
31780
32174
  reset(button);
@@ -31795,37 +32189,105 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
31795
32189
  }
31796
32190
  delegate(["click"]);
31797
32191
  customElements.define("go-add-to-cart-button", create_custom_element(AddToCartButton, {}, [], ["details"], false));
31798
- function Link($$anchor, $$props) {
31799
- push($$props, true);
31800
- const to = prop($$props, "to", 7);
31801
- const href = /* @__PURE__ */ user_derived(() => go.config.urls[to()]);
31802
- const a2 = wrapInElement($$props.$$host, "a");
31803
- user_effect(() => {
31804
- if (!get$2(href)) {
31805
- console.warn(`[go-link] No URL found for route "${to()}".`);
31806
- a2.removeAttribute("href");
31807
- return;
31808
- }
31809
- a2.setAttribute("href", get$2(href)());
32192
+ var root$1 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
32193
+ function Password($$anchor, $$props) {
32194
+ push($$props, false);
32195
+ Forms.defineForm({
32196
+ id: "passwordResetForm",
32197
+ fields: [
32198
+ { key: "currentPassword", required: true },
32199
+ { key: "password", required: true },
32200
+ { key: "confirmPassword", required: true }
32201
+ ]
31810
32202
  });
31811
- a2.addEventListener("click", (e) => {
31812
- e.preventDefault();
31813
- if (!go.config.urls[to()]) {
31814
- console.warn(`[go-link] No URL found for route "${to()}". You can define it with go.config.urls.${to()} = () => 'https://example.com/my-route'`);
31815
- return;
32203
+ async function submit(event2) {
32204
+ const form = event2.target;
32205
+ const details = form.details;
32206
+ const result = await shop.updatePassword(details.formData);
32207
+ if (result.data) {
32208
+ details.successMessage = shop.t("user.passwordSuccess.desc.title");
32209
+ details.apiErrors = [];
32210
+ } else {
32211
+ details.apiErrors = result.error?.errors || result.error || result.errors;
31816
32212
  }
31817
- go.config.navigateTo(go.config.urls[to()]());
32213
+ }
32214
+ init();
32215
+ var go_form = root$1();
32216
+ set_custom_element_data(go_form, "formId", "passwordResetForm");
32217
+ event("submit", go_form, submit);
32218
+ append($$anchor, go_form);
32219
+ pop();
32220
+ }
32221
+ customElements.define("go-profile-password", create_custom_element(Password, {}, [], [], false));
32222
+ var root = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
32223
+ function Details($$anchor, $$props) {
32224
+ push($$props, true);
32225
+ Forms.defineForm({
32226
+ id: "accountDetailsForm",
32227
+ fields: [
32228
+ { key: "salutation", required: false },
32229
+ { key: "firstName", required: true },
32230
+ { key: "lastName", required: true },
32231
+ { key: "email", required: true },
32232
+ { key: "confirmEmail", required: true },
32233
+ // { key: 'addressee', required: true },
32234
+ // { key: 'street', required: true },
32235
+ // { key: 'postcode', required: true },
32236
+ // { key: 'city', required: true },
32237
+ // { key: 'country', required: true },
32238
+ { key: "language", required: true }
32239
+ ]
31818
32240
  });
31819
- var $$exports = {
31820
- get to() {
31821
- return to();
31822
- },
31823
- set to($$value) {
31824
- to($$value);
31825
- flushSync();
31826
- }
31827
- };
31828
- return pop($$exports);
32241
+ let form = /* @__PURE__ */ state(void 0);
32242
+ const user = /* @__PURE__ */ user_derived(() => shop.validateToken());
32243
+ onMount(async () => {
32244
+ await shop.waitForAllFetches();
32245
+ await pollUntilTruthy(() => get$2(form).details);
32246
+ await pollUntilTruthy(() => get$2(user).data);
32247
+ get$2(form).details.fill(get$2(user).data);
32248
+ });
32249
+ var go_form = root();
32250
+ set_custom_element_data(go_form, "formId", "accountDetailsForm");
32251
+ bind_this(go_form, ($$value) => set(form, $$value), () => get$2(form));
32252
+ append($$anchor, go_form);
32253
+ pop();
31829
32254
  }
31830
- customElements.define("go-link", create_custom_element(Link, { to: { attribute: "to", reflect: true, type: "String" } }, [], [], false));
32255
+ customElements.define("go-profile-details", create_custom_element(Details, {}, [], [], false));
32256
+ var root_1 = /* @__PURE__ */ from_html(`<div class="go-profile-fullname"> </div> <div class="go-profile-email"> </div>`, 1);
32257
+ function Overview($$anchor, $$props) {
32258
+ push($$props, true);
32259
+ const user = /* @__PURE__ */ user_derived(() => shop.validateToken());
32260
+ const data = /* @__PURE__ */ user_derived(() => get$2(user)?.data);
32261
+ var fragment = comment();
32262
+ var node = first_child(fragment);
32263
+ {
32264
+ var consequent = ($$anchor2) => {
32265
+ var fragment_1 = root_1();
32266
+ var div = first_child(fragment_1);
32267
+ var text2 = child(div);
32268
+ reset(div);
32269
+ var div_1 = sibling(div, 2);
32270
+ var text_1 = child(div_1, true);
32271
+ reset(div_1);
32272
+ template_effect(() => {
32273
+ set_text(text2, `${get$2(data).name ?? ""}
32274
+ ${get$2(data).surname ?? ""}`);
32275
+ set_text(text_1, get$2(data).email);
32276
+ });
32277
+ append($$anchor2, fragment_1);
32278
+ };
32279
+ var alternate = ($$anchor2) => {
32280
+ var text_2 = text();
32281
+ template_effect(($0) => set_text(text_2, $0), [() => shop.t("user.login.desc.text")]);
32282
+ append($$anchor2, text_2);
32283
+ };
32284
+ if_block(node, ($$render) => {
32285
+ if (get$2(data)) $$render(consequent);
32286
+ else $$render(alternate, false);
32287
+ });
32288
+ }
32289
+ append($$anchor, fragment);
32290
+ pop();
32291
+ }
32292
+ customElements.define("go-profile-overview", create_custom_element(Overview, {}, [], [], false));
31831
32293
  })();