@gomusdev/web-components 4.4.0 → 4.6.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 (24) hide show
  1. package/README.md +16 -0
  2. package/dist-js/components/checkoutForm/CheckoutGuest.svelte.d.ts +1 -0
  3. package/dist-js/components/checkoutForm/CheckoutUser.svelte.d.ts +1 -0
  4. package/dist-js/gomus-webcomponents.iife.js +172 -60
  5. package/dist-js/gomus-webcomponents.js +172 -60
  6. package/dist-js/gomus-webcomponents.min.iife.js +20 -20
  7. package/dist-js/gomus-webcomponents.min.js +4494 -4408
  8. package/dist-js/src/components/annualTicketPersonalization/lib/PersonalizationDetails.svelte.d.ts +2 -0
  9. package/dist-js/src/components/cart/mocks/gomusTicketMocks.d.ts +3 -0
  10. package/dist-js/src/components/checkoutForm/CheckoutGuest.spec.d.ts +1 -0
  11. package/dist-js/src/components/checkoutForm/CheckoutUser.spec.d.ts +1 -0
  12. package/dist-js/src/components/checkoutForm/lib.d.ts +2 -1
  13. package/dist-js/src/components/graveyard/event/lib.svelte.d.ts +1 -0
  14. package/dist-js/src/components/order/lib/OrderDetails.svelte.d.ts +3 -2
  15. package/dist-js/src/components/ticketSelection/subcomponents/tickets/subcomponents/segment/SegmentDetails.svelte.d.ts +6 -0
  16. package/dist-js/src/factories/CartItemFactories.d.ts +18 -0
  17. package/dist-js/src/go/go.d.ts +3 -2
  18. package/dist-js/src/lib/models/cart/CartItem.d.ts +23 -0
  19. package/dist-js/src/lib/models/cart/cart.svelte.d.ts +12 -0
  20. package/dist-js/src/lib/models/cart/localStorage.svelte.d.ts +3 -0
  21. package/dist-js/src/lib/models/ticket/UITicket.svelte.d.ts +3 -0
  22. package/dist-js/src/lib/stores/shop.svelte.d.ts +13 -1
  23. package/dist-js/src/mocks/ShopMocks.d.ts +2 -0
  24. package/package.json +1 -1
@@ -6553,12 +6553,12 @@ var assign = (initial, override) => {
6553
6553
  //#endregion
6554
6554
  //#region src/lib/stores/auth.svelte.ts
6555
6555
  var Auth = class {
6556
- #data = {
6556
+ #data = /* @__PURE__ */ state(proxy({
6557
6557
  uid: "",
6558
6558
  client: "",
6559
6559
  accessToken: "",
6560
6560
  expiry: 0
6561
- };
6561
+ }));
6562
6562
  constructor() {
6563
6563
  this.load();
6564
6564
  if (typeof window !== "undefined") window.addEventListener("storage", (e) => {
@@ -6570,34 +6570,39 @@ var Auth = class {
6570
6570
  if (this.isLoggedIn()) return 20;
6571
6571
  }
6572
6572
  isAuthenticated() {
6573
- return this.#data.uid !== "";
6573
+ return this.data.uid !== "";
6574
6574
  }
6575
6575
  isLoggedIn() {
6576
- return Boolean(this.#data.uid && isEmail(this.#data.uid));
6576
+ return Boolean(this.data.uid && isEmail(this.data.uid));
6577
6577
  }
6578
6578
  isGuest() {
6579
- return Boolean(this.#data.uid && !isEmail(this.#data.uid));
6579
+ return Boolean(this.data.uid && !isEmail(this.data.uid));
6580
6580
  }
6581
6581
  signOut() {
6582
- this.#data.uid = "";
6583
- this.#data.client = "";
6584
- this.#data.accessToken = "";
6585
- this.#data.expiry = 0;
6582
+ get$2(this.#data).uid = "";
6583
+ get$2(this.#data).client = "";
6584
+ get$2(this.#data).accessToken = "";
6585
+ get$2(this.#data).expiry = 0;
6586
6586
  this.save();
6587
6587
  }
6588
6588
  signIn(options) {
6589
- this.#data.uid = options.uid;
6590
- this.#data.client = options.client;
6591
- this.#data.accessToken = options.accessToken;
6592
- this.#data.expiry = options.expiry;
6589
+ get$2(this.#data).uid = options.uid;
6590
+ get$2(this.#data).client = options.client;
6591
+ get$2(this.#data).accessToken = options.accessToken;
6592
+ get$2(this.#data).expiry = options.expiry;
6593
6593
  this.save();
6594
6594
  }
6595
6595
  get data() {
6596
- if (this.#data.expiry < Math.floor(Date.now() / 1e3)) this.signOut();
6597
- return this.#data;
6596
+ if (get$2(this.#data).uid !== "" && get$2(this.#data).expiry < Math.floor(Date.now() / 1e3)) return {
6597
+ uid: "",
6598
+ client: "",
6599
+ accessToken: "",
6600
+ expiry: 0
6601
+ };
6602
+ return get$2(this.#data);
6598
6603
  }
6599
6604
  toString() {
6600
- return JSON.stringify(this.#data);
6605
+ return JSON.stringify(get$2(this.#data));
6601
6606
  }
6602
6607
  save() {
6603
6608
  if (typeof localStorage === "undefined") return;
@@ -6612,6 +6617,10 @@ var Auth = class {
6612
6617
  }
6613
6618
  const d = JSON.parse(str);
6614
6619
  if (!(isObject$2(d) && "uid" in d && "client" in d && "accessToken" in d && "expiry" in d)) throw new Error(`(Auth.loadFromString) invalid auth json ${str}`);
6620
+ if (d.uid !== "" && d.expiry < Math.floor(Date.now() / 1e3)) {
6621
+ this.signOut();
6622
+ return;
6623
+ }
6615
6624
  this.signIn(d);
6616
6625
  }
6617
6626
  };
@@ -12269,6 +12278,7 @@ function createCartItem(product, options) {
12269
12278
  if (isUITour(this.product)) segments.push(`tour: ${this.product.instanceKey}`);
12270
12279
  if (this.display?.discounted) segments.push("discounted");
12271
12280
  if (isMantleTicket(this.product) && this.mantle?.key) segments.push(`mantle_key: ${this.mantle.key}`);
12281
+ if (this.voucher?.code) segments.push(`voucher_code: ${this.voucher.code}`);
12272
12282
  return segments.length > 0 ? ` (${segments.join(", ")})` : "";
12273
12283
  },
12274
12284
  toString() {
@@ -12359,7 +12369,8 @@ function generateCartItem(cartItem) {
12359
12369
  return createCartItem(createUITicket(cartItem.product, { selectedTime: cartItem.product.selectedTime }), {
12360
12370
  time: cartItem.time,
12361
12371
  quantity: cartItem.quantity,
12362
- mantle: cartItem.mantle
12372
+ mantle: cartItem.mantle,
12373
+ voucher: cartItem.voucher
12363
12374
  });
12364
12375
  case "Event":
12365
12376
  if (!isStillValid(cartItem)) return;
@@ -12507,6 +12518,7 @@ function createCart(products, contingent = 20) {
12507
12518
  },
12508
12519
  deleteItem(item) {
12509
12520
  for (let i = this.items.length - 1; i >= 0; i--) if (this.items[i].uuid === item.uuid) this.items.splice(i, 1);
12521
+ if (item?.voucher?.code && !this.items.some((i) => i.voucher?.code === item.voucher.code)) this.removeCoupon(item.voucher.code);
12510
12522
  },
12511
12523
  addItem(item) {
12512
12524
  const existingItem = this.items.find((i) => i.uuid === item.uuid);
@@ -12525,7 +12537,12 @@ function createCart(products, contingent = 20) {
12525
12537
  removeCoupon(code) {
12526
12538
  const upper = code.toUpperCase();
12527
12539
  const index = this.coupons.findIndex((c) => c.code === upper);
12528
- if (index > -1) this.coupons.splice(index, 1);
12540
+ if (index > -1) {
12541
+ const [removed] = this.coupons.splice(index, 1);
12542
+ if (removed.kind === "serviceVoucher") {
12543
+ for (let i = this.items.length - 1; i >= 0; i--) if (this.items[i].voucher?.code === upper) this.items.splice(i, 1);
12544
+ }
12545
+ }
12529
12546
  },
12530
12547
  clearCoupons() {
12531
12548
  while (this.coupons.length > 0) this.coupons.pop();
@@ -13623,6 +13640,7 @@ var WITHDRAWAL_ENDPOINT = "/api/v4/orders/withdrawals";
13623
13640
  var MEMBERSHIP_ACTIVATION_ENDPOINT = "/api/v4/customer/memberships/activate";
13624
13641
  var ORDERS_ENDPOINT = "/api/v4/orders";
13625
13642
  var CUSTOMER_ADDRESSES_ENDPOINT = "/api/v4/customer/customer_addresses";
13643
+ var CUSTOMER_MEMBERSHIPS_ENDPOINT = "/api/v4/customer/memberships";
13626
13644
  //#endregion
13627
13645
  //#region ../../packages/gomus-api/lib/customerLevels.ts
13628
13646
  var CustomerLevels = {
@@ -13748,6 +13766,10 @@ var Shop = class {
13748
13766
  if (!this.auth.data.accessToken) return NOT_SIGNED_IN;
13749
13767
  return this.fetchAndCache(CUSTOMER_ADDRESSES_ENDPOINT, "customerAddresses", "", { cache: 5 });
13750
13768
  }
13769
+ getCustomerMemberships() {
13770
+ if (!this.auth.data.accessToken) return NOT_SIGNED_IN;
13771
+ return this.fetchAndCache(CUSTOMER_MEMBERSHIPS_ENDPOINT, "customerMemberships", "", { cache: 5 });
13772
+ }
13751
13773
  ticketsCalendar(params) {
13752
13774
  return this.fetchAndCache(TICKETS_CALENDAR_ENDPOINT, `ticketsCalendar-${JSON.stringify(params)}`, "data", {
13753
13775
  cache: 60,
@@ -13945,7 +13967,7 @@ var Shop = class {
13945
13967
  });
13946
13968
  }
13947
13969
  getCouponSaleByBarcode(token) {
13948
- return this.fetchAndCache(`/api/v4/coupon_sales/barcode/${token}`, `coupon_sale_barcode_${token}`, "coupon_sale");
13970
+ return this.fetchAndCache(`/api/v4/coupon_sales/barcode/${token}`, `coupon_sale_barcode_${token}`, "coupon_sale", { cache: 0 });
13949
13971
  }
13950
13972
  getCoupons() {
13951
13973
  return this.fetchAndCache("/api/v4/coupons", "coupons", "coupons", { query: {
@@ -15204,8 +15226,8 @@ function createDisplayCart(baseCart, apiItems) {
15204
15226
  }
15205
15227
  function createDisplayCartItem(cartItem, attrs) {
15206
15228
  const quantity = isUITour(cartItem.product) ? 1 : resolveApiQuantity(attrs);
15207
- const displayPrice = attrs.price_cents ?? cartItem.product.price_cents;
15208
15229
  const originalPrice = cartItem.product.price_cents;
15230
+ const displayPrice = originalPrice === 0 ? 0 : attrs.price_cents ?? originalPrice;
15209
15231
  const discounted = displayPrice < originalPrice;
15210
15232
  return createCartItem({
15211
15233
  ...cartItem.product,
@@ -15213,6 +15235,7 @@ function createDisplayCartItem(cartItem, attrs) {
15213
15235
  }, {
15214
15236
  quantity,
15215
15237
  time: cartItem.time,
15238
+ voucher: cartItem.voucher,
15216
15239
  mantle: cartItem.mantle,
15217
15240
  display: {
15218
15241
  discounted,
@@ -17826,10 +17849,11 @@ create_custom_element(SubRow, {
17826
17849
  var root$47 = /* @__PURE__ */ from_html(`<s class="go-cart-item-price-original"> </s> <span class="go-cart-item-price-discounted"> </span>`, 1);
17827
17850
  var root_1$15 = /* @__PURE__ */ from_html(`<span class="go-cart-item-price-discounted"> </span>`);
17828
17851
  var root_2$11 = /* @__PURE__ */ from_html(`<span data-testid="cart-item-participant-count"> </span>`);
17829
- var root_3$8 = /* @__PURE__ */ from_html(`<span> </span>`);
17830
- var root_4$4 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button class="go-cart-remove">⨉</button></li>`);
17831
- var root_5$2 = /* @__PURE__ */ from_html(`<ul class="go-sub-tickets" role="list"></ul>`);
17832
- var root_6$2 = /* @__PURE__ */ from_html(`<article class="go-cart-item-content"><ul><li class="go-cart-item-title-container"><!></li> <li class="go-cart-item-price"><!></li> <li class="go-cart-item-count"><!></li> <!> <li class="go-cart-item-sum"> </li></ul></article> <!>`, 1);
17852
+ var root_3$8 = /* @__PURE__ */ from_html(`<span data-testid="cart-item-voucher-quantity"> </span>`);
17853
+ var root_4$4 = /* @__PURE__ */ from_html(`<span> </span>`);
17854
+ var root_5$2 = /* @__PURE__ */ from_html(`<li class="go-cart-item-remove"><button class="go-cart-remove">⨉</button></li>`);
17855
+ var root_6$2 = /* @__PURE__ */ from_html(`<ul class="go-sub-tickets" role="list"></ul>`);
17856
+ var root_7$2 = /* @__PURE__ */ from_html(`<article class="go-cart-item-content"><ul><li class="go-cart-item-title-container"><!></li> <li class="go-cart-item-price"><!></li> <li class="go-cart-item-count"><!></li> <!> <li class="go-cart-item-sum"> </li></ul></article> <!>`, 1);
17833
17857
  function Item$1($$anchor, $$props) {
17834
17858
  push($$props, true);
17835
17859
  let displayItem = prop($$props, "displayItem", 7), displayCart = prop($$props, "displayCart", 7), preview = prop($$props, "preview", 7);
@@ -17894,8 +17918,8 @@ function Item$1($$anchor, $$props) {
17894
17918
  };
17895
17919
  var fragment = comment();
17896
17920
  var node = first_child(fragment);
17897
- var consequent_9 = ($$anchor) => {
17898
- var fragment_1 = root_6$2();
17921
+ var consequent_10 = ($$anchor) => {
17922
+ var fragment_1 = root_7$2();
17899
17923
  var article = first_child(fragment_1);
17900
17924
  var ul = child(article);
17901
17925
  var li = child(ul);
@@ -17971,6 +17995,13 @@ function Item$1($$anchor, $$props) {
17971
17995
  template_effect(() => set_text(text_4, displayItem().quantity));
17972
17996
  append($$anchor, span_3);
17973
17997
  };
17998
+ var consequent_7 = ($$anchor) => {
17999
+ var span_4 = root_4$4();
18000
+ var text_5 = child(span_4, true);
18001
+ reset(span_4);
18002
+ template_effect(() => set_text(text_5, displayItem().quantity));
18003
+ append($$anchor, span_4);
18004
+ };
17974
18005
  var alternate_1 = ($$anchor) => {
17975
18006
  {
17976
18007
  let $0 = /* @__PURE__ */ user_derived(() => displayItem().quantity ?? 0);
@@ -17994,13 +18025,14 @@ function Item$1($$anchor, $$props) {
17994
18025
  };
17995
18026
  if_block(node_3, ($$render) => {
17996
18027
  if (displayItem().product.type === "Tour") $$render(consequent_5);
17997
- else if (preview()) $$render(consequent_6, 1);
18028
+ else if (displayItem().voucher?.code) $$render(consequent_6, 1);
18029
+ else if (preview()) $$render(consequent_7, 2);
17998
18030
  else $$render(alternate_1, -1);
17999
18031
  });
18000
18032
  reset(li_2);
18001
18033
  var node_4 = sibling(li_2, 2);
18002
- var consequent_7 = ($$anchor) => {
18003
- var li_3 = root_4$4();
18034
+ var consequent_8 = ($$anchor) => {
18035
+ var li_3 = root_5$2();
18004
18036
  var button = child(li_3);
18005
18037
  reset(li_3);
18006
18038
  template_effect(($0) => set_attribute(button, "aria-label", $0), [() => shop.t("cart.item.remove")]);
@@ -18008,16 +18040,16 @@ function Item$1($$anchor, $$props) {
18008
18040
  append($$anchor, li_3);
18009
18041
  };
18010
18042
  if_block(node_4, ($$render) => {
18011
- if (!preview()) $$render(consequent_7);
18043
+ if (!preview()) $$render(consequent_8);
18012
18044
  });
18013
18045
  var li_4 = sibling(node_4, 2);
18014
- var text_5 = child(li_4, true);
18046
+ var text_6 = child(li_4, true);
18015
18047
  reset(li_4);
18016
18048
  reset(ul);
18017
18049
  reset(article);
18018
18050
  var node_5 = sibling(article, 2);
18019
- var consequent_8 = ($$anchor) => {
18020
- var ul_1 = root_5$2();
18051
+ var consequent_9 = ($$anchor) => {
18052
+ var ul_1 = root_6$2();
18021
18053
  each(ul_1, 21, () => subTicketDefs(get$2(mantleProduct)), (sub) => sub.id, ($$anchor, sub) => {
18022
18054
  {
18023
18055
  let $0 = /* @__PURE__ */ user_derived(() => displayItem().mantle?.composition?.[get$2(sub).id] ?? 0);
@@ -18043,13 +18075,13 @@ function Item$1($$anchor, $$props) {
18043
18075
  append($$anchor, ul_1);
18044
18076
  };
18045
18077
  if_block(node_5, ($$render) => {
18046
- if (get$2(mantleProduct)) $$render(consequent_8);
18078
+ if (get$2(mantleProduct)) $$render(consequent_9);
18047
18079
  });
18048
- template_effect(($0) => set_text(text_5, $0), [() => formatCurrency(displayItem().total_price_cents)]);
18080
+ template_effect(($0) => set_text(text_6, $0), [() => formatCurrency(displayItem().total_price_cents)]);
18049
18081
  append($$anchor, fragment_1);
18050
18082
  };
18051
18083
  if_block(node, ($$render) => {
18052
- if (get$2(capacity)) $$render(consequent_9);
18084
+ if (get$2(capacity)) $$render(consequent_10);
18053
18085
  });
18054
18086
  append($$anchor, fragment);
18055
18087
  return pop($$exports);
@@ -18330,11 +18362,23 @@ function CartCounter($$anchor, $$props) {
18330
18362
  }
18331
18363
  customElements.define("go-cart-counter", create_custom_element(CartCounter, {}, [], []));
18332
18364
  //#endregion
18333
- //#region src/components/checkoutForm/CheckoutForm.svelte
18334
- function CheckoutForm($$anchor, $$props) {
18335
- push($$props, true);
18336
- let custom = prop($$props, "custom", 7, false);
18337
- let cart = /* @__PURE__ */ user_derived(() => shop.cart);
18365
+ //#region src/components/checkoutForm/lib.ts
18366
+ async function finalizeCheckout(form, formId) {
18367
+ const cart = shop.cart;
18368
+ if (!cart) return;
18369
+ const paymentMode = form.details.fieldValue("paymentMode");
18370
+ cart.paymentModeId = paymentMode == null ? void 0 : String(paymentMode);
18371
+ const checkout = await shop.checkout(cart.orderData());
18372
+ if (checkout.error) {
18373
+ form.details.apiErrors = checkout.error;
18374
+ return;
18375
+ }
18376
+ const beforeSubmit = configStore.config.forms[formId]?.beforeSubmit;
18377
+ if (beforeSubmit) await beforeSubmit(form.details.formData);
18378
+ const paymentUrl = checkout.data.meta.payment_url;
18379
+ configStore.config.navigateTo?.(paymentUrl);
18380
+ }
18381
+ function setupGuestCheckout(host, custom) {
18338
18382
  Forms.defineForm({
18339
18383
  id: "checkoutGuest",
18340
18384
  submitLabel: "cart.detail.actions.checkout",
@@ -18365,30 +18409,48 @@ function CheckoutForm($$anchor, $$props) {
18365
18409
  }
18366
18410
  ]
18367
18411
  });
18368
- wrapInElement($$props.$$host, "go-form", {
18412
+ wrapInElement(host, "go-form", {
18369
18413
  "form-id": "checkoutGuest",
18370
- custom: custom()
18414
+ custom
18371
18415
  });
18372
- $$props.$$host.addEventListener("submit", async (e) => {
18416
+ host.addEventListener("submit", async (e) => {
18373
18417
  const form = e.target;
18374
- if (!get$2(cart)) return;
18418
+ if (!shop.cart) return;
18375
18419
  const auth = await shop.signUp(form.details.formData, true);
18376
18420
  if (auth.error) {
18377
18421
  form.details.apiErrors = auth.error.errors;
18378
18422
  return;
18379
18423
  }
18380
- const paymentMode = form.details.fieldValue("paymentMode");
18381
- get$2(cart).paymentModeId = paymentMode == null ? void 0 : String(paymentMode);
18382
- const checkout = await shop.checkout(get$2(cart).orderData());
18383
- if (checkout.error) {
18384
- form.details.apiErrors = checkout.error;
18385
- return;
18386
- }
18387
- const beforeSubmit = configStore.config.forms.checkoutGuest?.beforeSubmit;
18388
- if (beforeSubmit) await beforeSubmit(form.details.formData);
18389
- const paymentUrl = checkout.data.meta.payment_url;
18390
- configStore.config.navigateTo?.(paymentUrl);
18424
+ await finalizeCheckout(form, "checkoutGuest");
18425
+ });
18426
+ }
18427
+ function setupUserCheckout(host, custom) {
18428
+ Forms.defineForm({
18429
+ id: "checkoutUser",
18430
+ submitLabel: "cart.detail.actions.checkout",
18431
+ fields: [{
18432
+ key: "acceptTerms",
18433
+ required: true
18434
+ }, {
18435
+ key: "paymentMode",
18436
+ required: true
18437
+ }]
18438
+ });
18439
+ wrapInElement(host, "go-form", {
18440
+ "form-id": "checkoutUser",
18441
+ custom
18391
18442
  });
18443
+ host.addEventListener("submit", async (e) => {
18444
+ const form = e.target;
18445
+ await finalizeCheckout(form, "checkoutUser");
18446
+ });
18447
+ }
18448
+ //#endregion
18449
+ //#region src/components/checkoutForm/CheckoutForm.svelte
18450
+ function CheckoutForm($$anchor, $$props) {
18451
+ push($$props, true);
18452
+ let custom = prop($$props, "custom", 7, false);
18453
+ setupGuestCheckout($$props.$$host, custom());
18392
18454
  return pop({
18393
18455
  get custom() {
18394
18456
  return custom();
@@ -18401,6 +18463,40 @@ function CheckoutForm($$anchor, $$props) {
18401
18463
  }
18402
18464
  customElements.define("go-checkout-form", create_custom_element(CheckoutForm, { custom: {} }, [], []));
18403
18465
  //#endregion
18466
+ //#region src/components/checkoutForm/CheckoutGuest.svelte
18467
+ function CheckoutGuest($$anchor, $$props) {
18468
+ push($$props, true);
18469
+ let custom = prop($$props, "custom", 7, false);
18470
+ setupGuestCheckout($$props.$$host, custom());
18471
+ return pop({
18472
+ get custom() {
18473
+ return custom();
18474
+ },
18475
+ set custom($$value = false) {
18476
+ custom($$value);
18477
+ flushSync();
18478
+ }
18479
+ });
18480
+ }
18481
+ customElements.define("go-checkout-guest", create_custom_element(CheckoutGuest, { custom: {} }, [], []));
18482
+ //#endregion
18483
+ //#region src/components/checkoutForm/CheckoutUser.svelte
18484
+ function CheckoutUser($$anchor, $$props) {
18485
+ push($$props, true);
18486
+ let custom = prop($$props, "custom", 7, false);
18487
+ setupUserCheckout($$props.$$host, custom());
18488
+ return pop({
18489
+ get custom() {
18490
+ return custom();
18491
+ },
18492
+ set custom($$value = false) {
18493
+ custom($$value);
18494
+ flushSync();
18495
+ }
18496
+ });
18497
+ }
18498
+ customElements.define("go-checkout-user", create_custom_element(CheckoutUser, { custom: {} }, [], []));
18499
+ //#endregion
18404
18500
  //#region src/components/couponRedemption/lib.ts
18405
18501
  var APPLY_ORDER_DISCOUNT = "TokenActions::ApplyOrderDiscount";
18406
18502
  async function redeem(token) {
@@ -18428,15 +18524,21 @@ function applyValueCoupon(token, valueCents) {
18428
18524
  return { success: true };
18429
18525
  }
18430
18526
  async function applyVoucher(token, couponSale) {
18431
- const ticket = (await shop.asyncFetch(() => shop.tickets({ "by_ticket_ids[]": [couponSale.is_voucher_for] }))).find((t) => t.id === couponSale.is_voucher_for);
18527
+ const code = token.toUpperCase();
18528
+ if (shop.cart.coupons.some((c) => c.code === code)) return { success: true };
18529
+ const tickets = await shop.asyncFetch(() => shop.tickets({ "by_ticket_ids[]": [couponSale.is_voucher_for] }));
18530
+ const ticket = Array.isArray(tickets) ? tickets.find((t) => t.id === couponSale.is_voucher_for) : void 0;
18432
18531
  if (!ticket) return fail([shop.t("cart.coupon.form.errors.error")]);
18433
18532
  const voucherTicket = {
18434
18533
  ...ticket,
18435
18534
  price_cents: 0
18436
18535
  };
18437
- shop.cart.addItem(createCartItem(createUITicket(voucherTicket), { quantity: 1 }));
18536
+ shop.cart.addItem(createCartItem(createUITicket(voucherTicket), {
18537
+ quantity: 1,
18538
+ voucher: { code }
18539
+ }));
18438
18540
  shop.cart.addCoupon({
18439
- code: token,
18541
+ code,
18440
18542
  kind: "serviceVoucher"
18441
18543
  });
18442
18544
  return { success: true };
@@ -35759,12 +35861,18 @@ function If($$anchor, $$props) {
35759
35861
  const formDetails = /* @__PURE__ */ user_derived(() => _formDetails.value);
35760
35862
  const _cartView = getCartDetails($$props.$$host);
35761
35863
  const cartView = /* @__PURE__ */ user_derived(() => _cartView.value);
35864
+ const auth = shop.auth;
35762
35865
  let data = /* @__PURE__ */ user_derived(() => ({
35763
35866
  ticketSelection: get$2(ticketSelectionDetails),
35764
35867
  personalizationDetails: get$2(personalizationDetails),
35765
35868
  formData: get$2(formDetails)?.formData,
35766
35869
  cart: shop.cart,
35767
- cartView: get$2(cartView)
35870
+ cartView: get$2(cartView),
35871
+ auth: {
35872
+ isAuthenticated: auth.isAuthenticated(),
35873
+ isLoggedIn: auth.isLoggedIn(),
35874
+ isGuest: auth.isGuest()
35875
+ }
35768
35876
  }));
35769
35877
  const _setData = (_data) => {
35770
35878
  set(data, _data);
@@ -38132,6 +38240,10 @@ var go = {
38132
38240
  getCustomerAddresses: async () => {
38133
38241
  await ensureShopReady();
38134
38242
  return shop.asyncFetch(() => shop.getCustomerAddresses());
38243
+ },
38244
+ getCustomerMemberships: async () => {
38245
+ await ensureShopReady();
38246
+ return shop.asyncFetch(() => shop.getCustomerMemberships());
38135
38247
  }
38136
38248
  },
38137
38249
  cart: { addTour: async (options) => {