@gomusdev/web-components 1.57.1 → 1.57.3
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.
|
@@ -11292,6 +11292,38 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
11292
11292
|
}
|
|
11293
11293
|
};
|
|
11294
11294
|
}
|
|
11295
|
+
const STORAGE_TTL_MS = 15 * 6e4;
|
|
11296
|
+
function isLocalStorageAvailable() {
|
|
11297
|
+
return typeof window !== "undefined" && typeof localStorage !== "undefined";
|
|
11298
|
+
}
|
|
11299
|
+
function saveToLocalStorage(key, data) {
|
|
11300
|
+
if (!isLocalStorageAvailable()) return;
|
|
11301
|
+
try {
|
|
11302
|
+
localStorage.setItem(key, JSON.stringify(data));
|
|
11303
|
+
} catch (e) {
|
|
11304
|
+
console.warn(`Failed to save to localStorage (${key}):`, e);
|
|
11305
|
+
}
|
|
11306
|
+
}
|
|
11307
|
+
function loadFromLocalStorage$1(key) {
|
|
11308
|
+
if (!isLocalStorageAvailable()) return null;
|
|
11309
|
+
try {
|
|
11310
|
+
const item = localStorage.getItem(key);
|
|
11311
|
+
return item ? JSON.parse(item) : null;
|
|
11312
|
+
} catch (e) {
|
|
11313
|
+
console.warn(`Failed to load from localStorage (${key}):`, e);
|
|
11314
|
+
return null;
|
|
11315
|
+
}
|
|
11316
|
+
}
|
|
11317
|
+
function removeFromLocalStorage(key) {
|
|
11318
|
+
if (!isLocalStorageAvailable()) return;
|
|
11319
|
+
try {
|
|
11320
|
+
localStorage.removeItem(key);
|
|
11321
|
+
} catch (e) {
|
|
11322
|
+
console.warn(`Failed to remove from localStorage (${key}):`, e);
|
|
11323
|
+
}
|
|
11324
|
+
}
|
|
11325
|
+
const KEY$6 = "go-cart";
|
|
11326
|
+
const persistCart = (items, coupons) => localStorage.setItem(KEY$6, JSON.stringify({ items, coupons, savedAt: Date.now() }));
|
|
11295
11327
|
function generateCartItem(cartItem) {
|
|
11296
11328
|
const type = cartItem.product.type;
|
|
11297
11329
|
switch (type) {
|
|
@@ -11308,11 +11340,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
11308
11340
|
throw new Error(`Unhandled case: ${_exhaustiveCheck}`);
|
|
11309
11341
|
}
|
|
11310
11342
|
}
|
|
11311
|
-
function loadFromLocalStorage
|
|
11343
|
+
function loadFromLocalStorage(cart) {
|
|
11312
11344
|
let lsItems = [];
|
|
11313
11345
|
let lsCoupons = [];
|
|
11346
|
+
let savedAt;
|
|
11314
11347
|
try {
|
|
11315
|
-
const content = localStorage.getItem(
|
|
11348
|
+
const content = localStorage.getItem(KEY$6);
|
|
11316
11349
|
if (!content) return [];
|
|
11317
11350
|
const parsed = JSON.parse(content);
|
|
11318
11351
|
if (Array.isArray(parsed)) {
|
|
@@ -11321,10 +11354,18 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
11321
11354
|
} else if (typeof parsed === "object" && parsed !== null) {
|
|
11322
11355
|
lsItems = parsed.items || [];
|
|
11323
11356
|
lsCoupons = parsed.coupons || [];
|
|
11357
|
+
savedAt = parsed.savedAt;
|
|
11324
11358
|
} else {
|
|
11325
11359
|
console.dir({ parsed, content });
|
|
11326
11360
|
throw new Error("go-cart has invalid format");
|
|
11327
11361
|
}
|
|
11362
|
+
const expired = !!savedAt && Date.now() - savedAt > STORAGE_TTL_MS;
|
|
11363
|
+
if (expired) {
|
|
11364
|
+
cart.clearItems();
|
|
11365
|
+
cart.clearCoupons();
|
|
11366
|
+
persistCart([], []);
|
|
11367
|
+
return [];
|
|
11368
|
+
}
|
|
11328
11369
|
if (lsItems.length === 0) {
|
|
11329
11370
|
cart.clearItems();
|
|
11330
11371
|
} else {
|
|
@@ -11335,20 +11376,20 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
11335
11376
|
return cart.items;
|
|
11336
11377
|
} catch (e) {
|
|
11337
11378
|
console.error(e);
|
|
11338
|
-
|
|
11379
|
+
persistCart([], []);
|
|
11339
11380
|
return [];
|
|
11340
11381
|
}
|
|
11341
11382
|
}
|
|
11342
11383
|
function syncCartToLocalStorage(cart) {
|
|
11343
|
-
loadFromLocalStorage
|
|
11384
|
+
loadFromLocalStorage(cart);
|
|
11344
11385
|
let lastWritten = JSON.stringify({ items: cart.items || [], coupons: cart.coupons || [] });
|
|
11345
|
-
|
|
11386
|
+
persistCart(cart.items || [], cart.coupons || []);
|
|
11346
11387
|
effect_root(() => {
|
|
11347
11388
|
user_effect(() => {
|
|
11348
11389
|
const content = JSON.stringify({ items: cart.items || [], coupons: cart.coupons || [] });
|
|
11349
11390
|
if (content === lastWritten) return;
|
|
11350
11391
|
lastWritten = content;
|
|
11351
|
-
|
|
11392
|
+
persistCart(cart.items || [], cart.coupons || []);
|
|
11352
11393
|
});
|
|
11353
11394
|
});
|
|
11354
11395
|
}
|
|
@@ -11443,47 +11484,24 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
11443
11484
|
dispatchCartEvents(cart);
|
|
11444
11485
|
return cart;
|
|
11445
11486
|
}
|
|
11446
|
-
function isLocalStorageAvailable() {
|
|
11447
|
-
return typeof window !== "undefined" && typeof localStorage !== "undefined";
|
|
11448
|
-
}
|
|
11449
|
-
function saveToLocalStorage(key, data) {
|
|
11450
|
-
if (!isLocalStorageAvailable()) return;
|
|
11451
|
-
try {
|
|
11452
|
-
localStorage.setItem(key, JSON.stringify(data));
|
|
11453
|
-
} catch (e) {
|
|
11454
|
-
console.warn(`Failed to save to localStorage (${key}):`, e);
|
|
11455
|
-
}
|
|
11456
|
-
}
|
|
11457
|
-
function loadFromLocalStorage(key) {
|
|
11458
|
-
if (!isLocalStorageAvailable()) return null;
|
|
11459
|
-
try {
|
|
11460
|
-
const item = localStorage.getItem(key);
|
|
11461
|
-
return item ? JSON.parse(item) : null;
|
|
11462
|
-
} catch (e) {
|
|
11463
|
-
console.warn(`Failed to load from localStorage (${key}):`, e);
|
|
11464
|
-
return null;
|
|
11465
|
-
}
|
|
11466
|
-
}
|
|
11467
|
-
function removeFromLocalStorage(key) {
|
|
11468
|
-
if (!isLocalStorageAvailable()) return;
|
|
11469
|
-
try {
|
|
11470
|
-
localStorage.removeItem(key);
|
|
11471
|
-
} catch (e) {
|
|
11472
|
-
console.warn(`Failed to remove from localStorage (${key}):`, e);
|
|
11473
|
-
}
|
|
11474
|
-
}
|
|
11475
11487
|
const KEY$5 = "go-capacity";
|
|
11476
11488
|
function saveCapacityToLocalStorage(allSeats, allQuotas) {
|
|
11477
|
-
const existing = loadFromLocalStorage(KEY$5);
|
|
11489
|
+
const existing = loadFromLocalStorage$1(KEY$5);
|
|
11478
11490
|
const merged = {
|
|
11479
11491
|
allSeats: { ...existing?.allSeats || {}, ...allSeats },
|
|
11480
|
-
allQuotas: { ...existing?.allQuotas || {}, ...allQuotas }
|
|
11492
|
+
allQuotas: { ...existing?.allQuotas || {}, ...allQuotas },
|
|
11493
|
+
savedAt: Date.now()
|
|
11481
11494
|
};
|
|
11482
11495
|
saveToLocalStorage(KEY$5, merged);
|
|
11483
11496
|
}
|
|
11484
11497
|
function loadCapacityFromLocalStorage(manager) {
|
|
11485
|
-
const data = loadFromLocalStorage(KEY$5);
|
|
11498
|
+
const data = loadFromLocalStorage$1(KEY$5);
|
|
11486
11499
|
if (!data) return;
|
|
11500
|
+
const expired = !data.savedAt || Date.now() - data.savedAt > STORAGE_TTL_MS;
|
|
11501
|
+
if (expired) {
|
|
11502
|
+
removeFromLocalStorage(KEY$5);
|
|
11503
|
+
return;
|
|
11504
|
+
}
|
|
11487
11505
|
if (data.allSeats) {
|
|
11488
11506
|
for (const dateId in data.allSeats) {
|
|
11489
11507
|
const did = parseInt(dateId);
|
|
@@ -11501,7 +11519,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
11501
11519
|
loadCapacityFromLocalStorage(manager);
|
|
11502
11520
|
}
|
|
11503
11521
|
if (event2.key === "go-cart") {
|
|
11504
|
-
const cart = loadFromLocalStorage("go-cart");
|
|
11522
|
+
const cart = loadFromLocalStorage$1("go-cart");
|
|
11505
11523
|
const cartEmpty = !cart || !cart.items || cart.items.length === 0;
|
|
11506
11524
|
if (cartEmpty) removeFromLocalStorage(KEY$5);
|
|
11507
11525
|
}
|
|
@@ -35895,8 +35913,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
35895
35913
|
var consequent = ($$anchor2) => {
|
|
35896
35914
|
var ul = root_1$1();
|
|
35897
35915
|
each(ul, 20, () => details.timeslots, (timeslot) => timeslot, ($$anchor3, timeslot) => {
|
|
35898
|
-
const
|
|
35899
|
-
const
|
|
35916
|
+
const unavailable = /* @__PURE__ */ user_derived(() => timeslot.totalCapacity === 0);
|
|
35917
|
+
const soldOut = /* @__PURE__ */ user_derived(() => !get$2(unavailable) && timeslot.capacity === 0);
|
|
35918
|
+
const disabled = /* @__PURE__ */ user_derived(() => get$2(unavailable) || get$2(soldOut) || !timeslot.available);
|
|
35900
35919
|
const selected = /* @__PURE__ */ user_derived(() => details.tsd?.selectedTimeslot === timeslot.startAt);
|
|
35901
35920
|
var li = root_2$1();
|
|
35902
35921
|
var label = child(li);
|
|
@@ -35910,6 +35929,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
35910
35929
|
template_effect(() => {
|
|
35911
35930
|
set_class(li, 1, clsx({
|
|
35912
35931
|
"go-timeslot": true,
|
|
35932
|
+
"is-unavailable": get$2(unavailable),
|
|
35913
35933
|
"is-sold-out": get$2(soldOut),
|
|
35914
35934
|
"is-disabled": get$2(disabled),
|
|
35915
35935
|
"is-selected": get$2(selected)
|
|
@@ -11292,6 +11292,38 @@ function createCartItem(product, options) {
|
|
|
11292
11292
|
}
|
|
11293
11293
|
};
|
|
11294
11294
|
}
|
|
11295
|
+
const STORAGE_TTL_MS = 15 * 6e4;
|
|
11296
|
+
function isLocalStorageAvailable() {
|
|
11297
|
+
return typeof window !== "undefined" && typeof localStorage !== "undefined";
|
|
11298
|
+
}
|
|
11299
|
+
function saveToLocalStorage(key, data) {
|
|
11300
|
+
if (!isLocalStorageAvailable()) return;
|
|
11301
|
+
try {
|
|
11302
|
+
localStorage.setItem(key, JSON.stringify(data));
|
|
11303
|
+
} catch (e) {
|
|
11304
|
+
console.warn(`Failed to save to localStorage (${key}):`, e);
|
|
11305
|
+
}
|
|
11306
|
+
}
|
|
11307
|
+
function loadFromLocalStorage$1(key) {
|
|
11308
|
+
if (!isLocalStorageAvailable()) return null;
|
|
11309
|
+
try {
|
|
11310
|
+
const item = localStorage.getItem(key);
|
|
11311
|
+
return item ? JSON.parse(item) : null;
|
|
11312
|
+
} catch (e) {
|
|
11313
|
+
console.warn(`Failed to load from localStorage (${key}):`, e);
|
|
11314
|
+
return null;
|
|
11315
|
+
}
|
|
11316
|
+
}
|
|
11317
|
+
function removeFromLocalStorage(key) {
|
|
11318
|
+
if (!isLocalStorageAvailable()) return;
|
|
11319
|
+
try {
|
|
11320
|
+
localStorage.removeItem(key);
|
|
11321
|
+
} catch (e) {
|
|
11322
|
+
console.warn(`Failed to remove from localStorage (${key}):`, e);
|
|
11323
|
+
}
|
|
11324
|
+
}
|
|
11325
|
+
const KEY$6 = "go-cart";
|
|
11326
|
+
const persistCart = (items, coupons) => localStorage.setItem(KEY$6, JSON.stringify({ items, coupons, savedAt: Date.now() }));
|
|
11295
11327
|
function generateCartItem(cartItem) {
|
|
11296
11328
|
const type = cartItem.product.type;
|
|
11297
11329
|
switch (type) {
|
|
@@ -11308,11 +11340,12 @@ function generateCartItem(cartItem) {
|
|
|
11308
11340
|
throw new Error(`Unhandled case: ${_exhaustiveCheck}`);
|
|
11309
11341
|
}
|
|
11310
11342
|
}
|
|
11311
|
-
function loadFromLocalStorage
|
|
11343
|
+
function loadFromLocalStorage(cart) {
|
|
11312
11344
|
let lsItems = [];
|
|
11313
11345
|
let lsCoupons = [];
|
|
11346
|
+
let savedAt;
|
|
11314
11347
|
try {
|
|
11315
|
-
const content = localStorage.getItem(
|
|
11348
|
+
const content = localStorage.getItem(KEY$6);
|
|
11316
11349
|
if (!content) return [];
|
|
11317
11350
|
const parsed = JSON.parse(content);
|
|
11318
11351
|
if (Array.isArray(parsed)) {
|
|
@@ -11321,10 +11354,18 @@ function loadFromLocalStorage$1(cart) {
|
|
|
11321
11354
|
} else if (typeof parsed === "object" && parsed !== null) {
|
|
11322
11355
|
lsItems = parsed.items || [];
|
|
11323
11356
|
lsCoupons = parsed.coupons || [];
|
|
11357
|
+
savedAt = parsed.savedAt;
|
|
11324
11358
|
} else {
|
|
11325
11359
|
console.dir({ parsed, content });
|
|
11326
11360
|
throw new Error("go-cart has invalid format");
|
|
11327
11361
|
}
|
|
11362
|
+
const expired = !!savedAt && Date.now() - savedAt > STORAGE_TTL_MS;
|
|
11363
|
+
if (expired) {
|
|
11364
|
+
cart.clearItems();
|
|
11365
|
+
cart.clearCoupons();
|
|
11366
|
+
persistCart([], []);
|
|
11367
|
+
return [];
|
|
11368
|
+
}
|
|
11328
11369
|
if (lsItems.length === 0) {
|
|
11329
11370
|
cart.clearItems();
|
|
11330
11371
|
} else {
|
|
@@ -11335,20 +11376,20 @@ function loadFromLocalStorage$1(cart) {
|
|
|
11335
11376
|
return cart.items;
|
|
11336
11377
|
} catch (e) {
|
|
11337
11378
|
console.error(e);
|
|
11338
|
-
|
|
11379
|
+
persistCart([], []);
|
|
11339
11380
|
return [];
|
|
11340
11381
|
}
|
|
11341
11382
|
}
|
|
11342
11383
|
function syncCartToLocalStorage(cart) {
|
|
11343
|
-
loadFromLocalStorage
|
|
11384
|
+
loadFromLocalStorage(cart);
|
|
11344
11385
|
let lastWritten = JSON.stringify({ items: cart.items || [], coupons: cart.coupons || [] });
|
|
11345
|
-
|
|
11386
|
+
persistCart(cart.items || [], cart.coupons || []);
|
|
11346
11387
|
effect_root(() => {
|
|
11347
11388
|
user_effect(() => {
|
|
11348
11389
|
const content = JSON.stringify({ items: cart.items || [], coupons: cart.coupons || [] });
|
|
11349
11390
|
if (content === lastWritten) return;
|
|
11350
11391
|
lastWritten = content;
|
|
11351
|
-
|
|
11392
|
+
persistCart(cart.items || [], cart.coupons || []);
|
|
11352
11393
|
});
|
|
11353
11394
|
});
|
|
11354
11395
|
}
|
|
@@ -11443,47 +11484,24 @@ function createMainCart() {
|
|
|
11443
11484
|
dispatchCartEvents(cart);
|
|
11444
11485
|
return cart;
|
|
11445
11486
|
}
|
|
11446
|
-
function isLocalStorageAvailable() {
|
|
11447
|
-
return typeof window !== "undefined" && typeof localStorage !== "undefined";
|
|
11448
|
-
}
|
|
11449
|
-
function saveToLocalStorage(key, data) {
|
|
11450
|
-
if (!isLocalStorageAvailable()) return;
|
|
11451
|
-
try {
|
|
11452
|
-
localStorage.setItem(key, JSON.stringify(data));
|
|
11453
|
-
} catch (e) {
|
|
11454
|
-
console.warn(`Failed to save to localStorage (${key}):`, e);
|
|
11455
|
-
}
|
|
11456
|
-
}
|
|
11457
|
-
function loadFromLocalStorage(key) {
|
|
11458
|
-
if (!isLocalStorageAvailable()) return null;
|
|
11459
|
-
try {
|
|
11460
|
-
const item = localStorage.getItem(key);
|
|
11461
|
-
return item ? JSON.parse(item) : null;
|
|
11462
|
-
} catch (e) {
|
|
11463
|
-
console.warn(`Failed to load from localStorage (${key}):`, e);
|
|
11464
|
-
return null;
|
|
11465
|
-
}
|
|
11466
|
-
}
|
|
11467
|
-
function removeFromLocalStorage(key) {
|
|
11468
|
-
if (!isLocalStorageAvailable()) return;
|
|
11469
|
-
try {
|
|
11470
|
-
localStorage.removeItem(key);
|
|
11471
|
-
} catch (e) {
|
|
11472
|
-
console.warn(`Failed to remove from localStorage (${key}):`, e);
|
|
11473
|
-
}
|
|
11474
|
-
}
|
|
11475
11487
|
const KEY$5 = "go-capacity";
|
|
11476
11488
|
function saveCapacityToLocalStorage(allSeats, allQuotas) {
|
|
11477
|
-
const existing = loadFromLocalStorage(KEY$5);
|
|
11489
|
+
const existing = loadFromLocalStorage$1(KEY$5);
|
|
11478
11490
|
const merged = {
|
|
11479
11491
|
allSeats: { ...existing?.allSeats || {}, ...allSeats },
|
|
11480
|
-
allQuotas: { ...existing?.allQuotas || {}, ...allQuotas }
|
|
11492
|
+
allQuotas: { ...existing?.allQuotas || {}, ...allQuotas },
|
|
11493
|
+
savedAt: Date.now()
|
|
11481
11494
|
};
|
|
11482
11495
|
saveToLocalStorage(KEY$5, merged);
|
|
11483
11496
|
}
|
|
11484
11497
|
function loadCapacityFromLocalStorage(manager) {
|
|
11485
|
-
const data = loadFromLocalStorage(KEY$5);
|
|
11498
|
+
const data = loadFromLocalStorage$1(KEY$5);
|
|
11486
11499
|
if (!data) return;
|
|
11500
|
+
const expired = !data.savedAt || Date.now() - data.savedAt > STORAGE_TTL_MS;
|
|
11501
|
+
if (expired) {
|
|
11502
|
+
removeFromLocalStorage(KEY$5);
|
|
11503
|
+
return;
|
|
11504
|
+
}
|
|
11487
11505
|
if (data.allSeats) {
|
|
11488
11506
|
for (const dateId in data.allSeats) {
|
|
11489
11507
|
const did = parseInt(dateId);
|
|
@@ -11501,7 +11519,7 @@ function syncCapacityAcrossTabs(manager) {
|
|
|
11501
11519
|
loadCapacityFromLocalStorage(manager);
|
|
11502
11520
|
}
|
|
11503
11521
|
if (event2.key === "go-cart") {
|
|
11504
|
-
const cart = loadFromLocalStorage("go-cart");
|
|
11522
|
+
const cart = loadFromLocalStorage$1("go-cart");
|
|
11505
11523
|
const cartEmpty = !cart || !cart.items || cart.items.length === 0;
|
|
11506
11524
|
if (cartEmpty) removeFromLocalStorage(KEY$5);
|
|
11507
11525
|
}
|
|
@@ -35895,8 +35913,9 @@ function Timeslots($$anchor, $$props) {
|
|
|
35895
35913
|
var consequent = ($$anchor2) => {
|
|
35896
35914
|
var ul = root_1$1();
|
|
35897
35915
|
each(ul, 20, () => details.timeslots, (timeslot) => timeslot, ($$anchor3, timeslot) => {
|
|
35898
|
-
const
|
|
35899
|
-
const
|
|
35916
|
+
const unavailable = /* @__PURE__ */ user_derived(() => timeslot.totalCapacity === 0);
|
|
35917
|
+
const soldOut = /* @__PURE__ */ user_derived(() => !get$2(unavailable) && timeslot.capacity === 0);
|
|
35918
|
+
const disabled = /* @__PURE__ */ user_derived(() => get$2(unavailable) || get$2(soldOut) || !timeslot.available);
|
|
35900
35919
|
const selected = /* @__PURE__ */ user_derived(() => details.tsd?.selectedTimeslot === timeslot.startAt);
|
|
35901
35920
|
var li = root_2$1();
|
|
35902
35921
|
var label = child(li);
|
|
@@ -35910,6 +35929,7 @@ function Timeslots($$anchor, $$props) {
|
|
|
35910
35929
|
template_effect(() => {
|
|
35911
35930
|
set_class(li, 1, clsx({
|
|
35912
35931
|
"go-timeslot": true,
|
|
35932
|
+
"is-unavailable": get$2(unavailable),
|
|
35913
35933
|
"is-sold-out": get$2(soldOut),
|
|
35914
35934
|
"is-disabled": get$2(disabled),
|
|
35915
35935
|
"is-selected": get$2(selected)
|