@ticketlayer/live 0.2.0 → 0.4.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.
- package/README.md +13 -14
- package/dist/auto.d.ts +5 -0
- package/dist/auto.d.ts.map +1 -1
- package/dist/auto.js +7 -0
- package/dist/auto.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/core/cartTotals.d.ts +72 -0
- package/dist/core/cartTotals.d.ts.map +1 -0
- package/dist/core/cartTotals.js +110 -0
- package/dist/core/cartTotals.js.map +1 -0
- package/dist/createLiveClient.d.ts.map +1 -1
- package/dist/createLiveClient.js +7 -0
- package/dist/createLiveClient.js.map +1 -1
- package/dist/elements.d.ts.map +1 -1
- package/dist/elements.js +15 -6
- package/dist/elements.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/state/checkoutModal.d.ts +0 -18
- package/dist/state/checkoutModal.d.ts.map +1 -1
- package/dist/state/checkoutModal.js +33 -22
- package/dist/state/checkoutModal.js.map +1 -1
- package/dist/state/loadElements.d.ts +13 -1
- package/dist/state/loadElements.d.ts.map +1 -1
- package/dist/state/loadElements.js +90 -1
- package/dist/state/loadElements.js.map +1 -1
- package/dist/state/theme.d.ts +13 -13
- package/dist/state/theme.d.ts.map +1 -1
- package/dist/state/theme.js +18 -34
- package/dist/state/theme.js.map +1 -1
- package/dist/ticketlayer.js +3 -3
- package/dist/ticketlayer.js.map +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +22 -21
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
export interface LoadElementsOptions {
|
|
2
2
|
/** Enable runtime injection (default false - most hosts import Elements directly). */
|
|
3
3
|
elements?: boolean;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Override the Elements ESM bundle URL: a pinned CDN build, or a local dist
|
|
6
|
+
* in dev. An exact-version URL must come with `elementsIntegrity`.
|
|
7
|
+
*/
|
|
5
8
|
elementsUrl?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Subresource integrity for `elementsUrl`, as `/versions.json` publishes it
|
|
11
|
+
* (`sha384-...`). Required for an exact-version URL, refused without one.
|
|
12
|
+
*/
|
|
13
|
+
elementsIntegrity?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Thrown when the options ask for something that cannot be verified. */
|
|
16
|
+
export declare class ElementsIntegrityError extends Error {
|
|
17
|
+
constructor(message: string);
|
|
6
18
|
}
|
|
7
19
|
export declare function loadElements(opts?: LoadElementsOptions): Promise<void>;
|
|
8
20
|
//# sourceMappingURL=loadElements.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadElements.d.ts","sourceRoot":"","sources":["../../src/state/loadElements.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadElements.d.ts","sourceRoot":"","sources":["../../src/state/loadElements.ts"],"names":[],"mappings":"AAkEA,MAAM,WAAW,mBAAmB;IAClC,sFAAsF;IACtF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,yEAAyE;AACzE,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAID,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsE1E"}
|
|
@@ -5,14 +5,90 @@
|
|
|
5
5
|
* No-op when: not in a browser, the custom elements are already defined (a
|
|
6
6
|
* bundler-based host like HBO imports them directly), or an injection for this
|
|
7
7
|
* URL is already in flight. The default URL points at the Elements ESM entry on
|
|
8
|
-
* the Ticketlayer CDN; pass `elementsUrl` to target a
|
|
8
|
+
* the Ticketlayer CDN; pass `elementsUrl` to target a pinned build or a local
|
|
9
|
+
* one in dev.
|
|
10
|
+
*
|
|
11
|
+
* ## Subresource integrity, and when it is required (TKT-160)
|
|
12
|
+
*
|
|
13
|
+
* The page's own `<script>` tag is integrity-checked by the browser, but the
|
|
14
|
+
* Elements bundle this module then injects is a second, much larger download -
|
|
15
|
+
* the one that actually renders the checkout. Injecting it with no `integrity`
|
|
16
|
+
* left it unverified, which made the pinning the Webflow Integration Service
|
|
17
|
+
* writes into every installed site (`data-elements-url` +
|
|
18
|
+
* `data-elements-integrity`) worth nothing past the first script tag.
|
|
19
|
+
*
|
|
20
|
+
* The rule this module enforces, in full:
|
|
21
|
+
*
|
|
22
|
+
* 1. **A hash with no URL is refused.** `elementsIntegrity` without
|
|
23
|
+
* `elementsUrl` could only be pinning the floating default, whose bytes are
|
|
24
|
+
* rewritten by every release, so the hash is wrong the moment one lands.
|
|
25
|
+
* 2. **A malformed hash is refused.** It has to look like
|
|
26
|
+
* `sha256-`/`sha384-`/`sha512-` followed by base64, optionally several
|
|
27
|
+
* space-separated, as the HTML spec defines the attribute. A typo that the
|
|
28
|
+
* browser ignores is worse than no hash at all, because it reads as
|
|
29
|
+
* protection.
|
|
30
|
+
* 3. **An exact-version URL with no hash is refused.** A path carrying a full
|
|
31
|
+
* `v<major>.<minor>.<patch>` segment is the CDN's pinned tier: those bytes
|
|
32
|
+
* are written once and never rewritten, `/versions.json` publishes their
|
|
33
|
+
* `sha384`, and pinning without verifying is the degradation this exists to
|
|
34
|
+
* stop. This is exactly the shape the Webflow Integration Service writes.
|
|
35
|
+
* 4. **Everything else loads unverified, deliberately.** The floating tiers
|
|
36
|
+
* (`/v1/`, `/v0.3/`) and a local dev server change under the URL by design;
|
|
37
|
+
* an integrity hash on one of them fails the moment a release lands
|
|
38
|
+
* (`cdn/README.md`, "Pinning, and subresource integrity"). They cannot be
|
|
39
|
+
* verified, so requiring it would only stop them working.
|
|
40
|
+
*
|
|
41
|
+
* `DEFAULT_ELEMENTS_URL` is a floating path and therefore falls into case 4.
|
|
42
|
+
* The default is kept, because removing it would break the documented one-line
|
|
43
|
+
* embed and every site that already omits `data-elements-url`, but it is no
|
|
44
|
+
* longer silent: taking it logs once, naming the pinned alternative. A site
|
|
45
|
+
* that wants the bundle verified pins it.
|
|
46
|
+
*
|
|
47
|
+
* `crossOrigin` is set alongside `integrity` and is not optional: a
|
|
48
|
+
* cross-origin script without CORS is opaque to the page, and the browser
|
|
49
|
+
* refuses to check an `integrity` it cannot read the bytes for.
|
|
9
50
|
*/
|
|
10
51
|
const DEFAULT_ELEMENTS_URL = 'https://cdn.ticketlayer.com/elements/v1/ticketlayer-elements/ticketlayer-elements.esm.js';
|
|
11
52
|
const SENTINEL_TAG = 'tl-event-list';
|
|
12
53
|
const inFlight = new Map();
|
|
54
|
+
/**
|
|
55
|
+
* A path segment naming a full major.minor.patch - the CDN's pinned tier
|
|
56
|
+
* (`cdn/build-tree.mjs` is where the scheme is decided). `/v1/` and `/v0.3/`
|
|
57
|
+
* are the floating tiers and deliberately do not match.
|
|
58
|
+
*/
|
|
59
|
+
const PINNED_PATH = /\/v\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?\//;
|
|
60
|
+
/** The `integrity` attribute as HTML defines it: one or more hash expressions. */
|
|
61
|
+
const INTEGRITY = /^(?:sha(?:256|384|512)-[A-Za-z0-9+/]+={0,2})(?:\s+sha(?:256|384|512)-[A-Za-z0-9+/]+={0,2})*$/;
|
|
62
|
+
/** Thrown when the options ask for something that cannot be verified. */
|
|
63
|
+
export class ElementsIntegrityError extends Error {
|
|
64
|
+
constructor(message) {
|
|
65
|
+
super(`[live] ${message}`);
|
|
66
|
+
this.name = 'ElementsIntegrityError';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
let warnedAboutDefault = false;
|
|
13
70
|
export function loadElements(opts = {}) {
|
|
14
71
|
if (!opts.elements)
|
|
15
72
|
return Promise.resolve();
|
|
73
|
+
const integrity = opts.elementsIntegrity?.trim() || undefined;
|
|
74
|
+
// The refusals come before the browser and already-registered checks, so a
|
|
75
|
+
// misconfigured host hears about it in Node, in SSR and in a test - not only
|
|
76
|
+
// on the one page where the elements had not already been defined.
|
|
77
|
+
if (integrity && !opts.elementsUrl) {
|
|
78
|
+
throw new ElementsIntegrityError('elementsIntegrity was given without elementsUrl. The default Elements URL is a floating ' +
|
|
79
|
+
'path that every release rewrites, so a hash pinned to it cannot keep matching. Pass the ' +
|
|
80
|
+
'pinned elementsUrl that the hash is for (see /versions.json on the CDN).');
|
|
81
|
+
}
|
|
82
|
+
if (integrity && !INTEGRITY.test(integrity)) {
|
|
83
|
+
throw new ElementsIntegrityError(`elementsIntegrity is not a subresource integrity value: ${JSON.stringify(opts.elementsIntegrity)}. ` +
|
|
84
|
+
'Expected one or more of sha256-, sha384- or sha512- followed by base64, as /versions.json publishes it.');
|
|
85
|
+
}
|
|
86
|
+
if (opts.elementsUrl && !integrity && PINNED_PATH.test(opts.elementsUrl)) {
|
|
87
|
+
throw new ElementsIntegrityError(`elementsUrl ${opts.elementsUrl} names an exact version, which is the CDN's pinned tier, but no ` +
|
|
88
|
+
'elementsIntegrity came with it. A pinned URL exists to be verified; loading it unchecked would ' +
|
|
89
|
+
'be weaker than the floating path. Pass the sha384 from /versions.json as elementsIntegrity ' +
|
|
90
|
+
'(data-elements-integrity on the embed script), or use a floating /v1/ URL.');
|
|
91
|
+
}
|
|
16
92
|
if (typeof window === 'undefined' || typeof document === 'undefined')
|
|
17
93
|
return Promise.resolve();
|
|
18
94
|
// Already registered (bundler import or a prior load) - nothing to do.
|
|
@@ -20,6 +96,13 @@ export function loadElements(opts = {}) {
|
|
|
20
96
|
if (ce?.get(SENTINEL_TAG))
|
|
21
97
|
return Promise.resolve();
|
|
22
98
|
const url = opts.elementsUrl ?? DEFAULT_ELEMENTS_URL;
|
|
99
|
+
if (!opts.elementsUrl && !warnedAboutDefault) {
|
|
100
|
+
warnedAboutDefault = true;
|
|
101
|
+
console.warn(`[live] Loading Elements unverified from the floating default ${DEFAULT_ELEMENTS_URL}. ` +
|
|
102
|
+
'Floating paths are rewritten by every release and cannot carry a subresource integrity hash. ' +
|
|
103
|
+
'To verify the bundle, pin it: set elementsUrl (data-elements-url) to the pinned path from ' +
|
|
104
|
+
'/versions.json and elementsIntegrity (data-elements-integrity) to the sha384 beside it.');
|
|
105
|
+
}
|
|
23
106
|
const existing = inFlight.get(url);
|
|
24
107
|
if (existing)
|
|
25
108
|
return existing;
|
|
@@ -28,6 +111,12 @@ export function loadElements(opts = {}) {
|
|
|
28
111
|
script.type = 'module';
|
|
29
112
|
script.src = url;
|
|
30
113
|
script.async = true;
|
|
114
|
+
if (integrity) {
|
|
115
|
+
script.integrity = integrity;
|
|
116
|
+
// Without CORS the response is opaque and the browser cannot check the
|
|
117
|
+
// hash at all, so these two are set together or not at all.
|
|
118
|
+
script.crossOrigin = 'anonymous';
|
|
119
|
+
}
|
|
31
120
|
script.dataset.ticketlayerElements = 'auto';
|
|
32
121
|
script.onload = () => resolve();
|
|
33
122
|
script.onerror = () => reject(new Error(`[live] Failed to load Elements from ${url}`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadElements.js","sourceRoot":"","sources":["../../src/state/loadElements.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"loadElements.js","sourceRoot":"","sources":["../../src/state/loadElements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,oBAAoB,GACxB,0FAA0F,CAAC;AAE7F,MAAM,YAAY,GAAG,eAAe,CAAC;AACrC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,GAAG,2CAA2C,CAAC;AAEhE,kFAAkF;AAClF,MAAM,SAAS,GAAG,8FAA8F,CAAC;AAiBjH,yEAAyE;AACzE,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAE/B,MAAM,UAAU,YAAY,CAAC,OAA4B,EAAE;IACzD,IAAI,CAAC,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAE7C,MAAM,SAAS,GAAG,IAAI,CAAC,iBAAiB,EAAE,IAAI,EAAE,IAAI,SAAS,CAAC;IAE9D,2EAA2E;IAC3E,6EAA6E;IAC7E,mEAAmE;IACnE,IAAI,SAAS,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,IAAI,sBAAsB,CAC9B,0FAA0F;YACxF,0FAA0F;YAC1F,0EAA0E,CAC7E,CAAC;IACJ,CAAC;IACD,IAAI,SAAS,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,sBAAsB,CAC9B,2DAA2D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI;YACnG,yGAAyG,CAC5G,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,WAAW,IAAI,CAAC,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,sBAAsB,CAC9B,eAAe,IAAI,CAAC,WAAW,kEAAkE;YAC/F,iGAAiG;YACjG,6FAA6F;YAC7F,4EAA4E,CAC/E,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAE/F,uEAAuE;IACvE,MAAM,EAAE,GAAI,MAAgE,CAAC,cAAc,CAAC;IAC5F,IAAI,EAAE,EAAE,GAAG,CAAC,YAAY,CAAC;QAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAEpD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,IAAI,oBAAoB,CAAC;IAErD,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC7C,kBAAkB,GAAG,IAAI,CAAC;QAC1B,OAAO,CAAC,IAAI,CACV,gEAAgE,oBAAoB,IAAI;YACtF,+FAA+F;YAC/F,4FAA4F;YAC5F,yFAAyF,CAC5F,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAE9B,MAAM,CAAC,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;QACvB,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;QACjB,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;YAC7B,uEAAuE;YACvE,4DAA4D;YAC5D,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;QACnC,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,mBAAmB,GAAG,MAAM,CAAC;QAC5C,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;QAChC,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,uCAAuC,GAAG,EAAE,CAAC,CAAC,CAAC;QACvF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrB,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/state/theme.d.ts
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* Apply a resolved channel theme to the document as CSS custom properties
|
|
3
3
|
* (browser only; SSR-safe no-op).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* This is the web harness's half of the token contract, and the only place in
|
|
6
|
+
* this client that writes a `--tl-*` name. What each name is, what it defaults
|
|
7
|
+
* to and which key of the theme document feeds it are not decided here: they
|
|
8
|
+
* come from `@ticketlayer/theme`, which is also where the Elements' defaults
|
|
9
|
+
* come from. `themeToCssVars` returns the declarations, including every alias a
|
|
10
|
+
* token answers to, so a host reading `--tl-color-primary` or the Backstage
|
|
11
|
+
* theme designer's `--tl-base-size` gets the channel's value too.
|
|
12
|
+
*
|
|
13
|
+
* Only the defaults are overridden. A key the theme carries that is not a
|
|
14
|
+
* declared token is ignored; a new one is added in packages/theme/tokens.json,
|
|
15
|
+
* where the Elements and a native harness see it as well.
|
|
11
16
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
typography?: Record<string, string | number>;
|
|
15
|
-
shape?: Record<string, string>;
|
|
16
|
-
brand?: Record<string, string>;
|
|
17
|
-
}
|
|
17
|
+
import { type ThemeDocument } from '@ticketlayer/theme';
|
|
18
|
+
export type ResolvedTheme = ThemeDocument;
|
|
18
19
|
export declare function applyTheme(theme: ResolvedTheme | null | undefined): void;
|
|
19
|
-
export {};
|
|
20
20
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/state/theme.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/state/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxE,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC;AAE1C,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAYxE"}
|
package/dist/state/theme.js
CHANGED
|
@@ -1,41 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply a resolved channel theme to the document as CSS custom properties
|
|
3
|
+
* (browser only; SSR-safe no-op).
|
|
4
|
+
*
|
|
5
|
+
* This is the web harness's half of the token contract, and the only place in
|
|
6
|
+
* this client that writes a `--tl-*` name. What each name is, what it defaults
|
|
7
|
+
* to and which key of the theme document feeds it are not decided here: they
|
|
8
|
+
* come from `@ticketlayer/theme`, which is also where the Elements' defaults
|
|
9
|
+
* come from. `themeToCssVars` returns the declarations, including every alias a
|
|
10
|
+
* token answers to, so a host reading `--tl-color-primary` or the Backstage
|
|
11
|
+
* theme designer's `--tl-base-size` gets the channel's value too.
|
|
12
|
+
*
|
|
13
|
+
* Only the defaults are overridden. A key the theme carries that is not a
|
|
14
|
+
* declared token is ignored; a new one is added in packages/theme/tokens.json,
|
|
15
|
+
* where the Elements and a native harness see it as well.
|
|
16
|
+
*/
|
|
17
|
+
import { themeToCssVars } from '@ticketlayer/theme';
|
|
1
18
|
const STYLE_ID = 'tl-theme-vars';
|
|
2
|
-
const kebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
3
|
-
// camelCase typography key → the CSS var suffix HBO's @theme / fallbacks expect.
|
|
4
|
-
const TYPOGRAPHY_VARS = {
|
|
5
|
-
fontFamily: 'font-family',
|
|
6
|
-
fontFamilyMono: 'font-family-mono',
|
|
7
|
-
baseSize: 'font-size-base',
|
|
8
|
-
scaleRatio: 'font-scale',
|
|
9
|
-
};
|
|
10
19
|
export function applyTheme(theme) {
|
|
11
20
|
if (!theme || typeof document === 'undefined')
|
|
12
21
|
return;
|
|
13
|
-
const vars = [];
|
|
14
|
-
const push = (name, value) => {
|
|
15
|
-
if (value === undefined || value === null)
|
|
16
|
-
return;
|
|
17
|
-
vars.push(`--tl-${name}: ${String(value)};`);
|
|
18
|
-
};
|
|
19
|
-
// Colors: emit both --tl-<name> and --tl-color-<name>; alias destructive→error.
|
|
20
|
-
for (const [key, value] of Object.entries(theme.colors ?? {})) {
|
|
21
|
-
const name = kebab(key);
|
|
22
|
-
push(name, value);
|
|
23
|
-
push(`color-${name}`, value);
|
|
24
|
-
if (key === 'destructive') {
|
|
25
|
-
push('error', value);
|
|
26
|
-
push('color-error', value);
|
|
27
|
-
}
|
|
28
|
-
if (key === 'destructiveForeground') {
|
|
29
|
-
push('error-foreground', value);
|
|
30
|
-
push('color-error-foreground', value);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
for (const [key, value] of Object.entries(theme.typography ?? {})) {
|
|
34
|
-
push(TYPOGRAPHY_VARS[key] ?? kebab(key), value);
|
|
35
|
-
}
|
|
36
|
-
for (const [key, value] of Object.entries(theme.shape ?? {})) {
|
|
37
|
-
push(kebab(key), value); // radiusMd → radius-md
|
|
38
|
-
}
|
|
22
|
+
const vars = Object.entries(themeToCssVars(theme)).map(([name, value]) => `${name}: ${value};`);
|
|
39
23
|
let style = document.getElementById(STYLE_ID);
|
|
40
24
|
if (!style) {
|
|
41
25
|
style = document.createElement('style');
|
package/dist/state/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/state/theme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/state/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,cAAc,EAAsB,MAAM,oBAAoB,CAAC;AAExE,MAAM,QAAQ,GAAG,eAAe,CAAC;AAIjC,MAAM,UAAU,UAAU,CAAC,KAAuC;IAChE,IAAI,CAAC,KAAK,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IAEtD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC;IAEhG,IAAI,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAA4B,CAAC;IACzE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACxC,KAAK,CAAC,EAAE,GAAG,QAAQ,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,WAAW,GAAG,cAAc,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;AAC3D,CAAC"}
|
package/dist/ticketlayer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var TicketlayerLive=(()=>{var C=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var X=(s,t)=>{for(var a in t)C(s,a,{get:t[a],enumerable:!0})},Z=(s,t,a,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of z(t))!H.call(s,o)&&o!==a&&C(s,o,{get:()=>t[o],enumerable:!(e=Y(t,o))||e.enumerable});return s};var Q=s=>Z(C({},"__esModule",{value:!0}),s);var me={};X(me,{TicketlayerLive:()=>S,boot:()=>j,createLiveClient:()=>O});var A="@ticketlayer/live",R="0.2.0";var I="2026-06-13";function W(){var t,a,e;let s=globalThis;return((t=s.navigator)==null?void 0:t.product)==="ReactNative"?"react-native":typeof s.window!="undefined"&&typeof s.document!="undefined"?"browser":(e=(a=s.process)==null?void 0:a.versions)!=null&&e.node?`node/${s.process.versions.node}`:s.EdgeRuntime?"edge":"unknown"}var ee=`${A.replace(/^@/,"").replace("/","-")}/${R} (${W()})`;function te(){let s=null;return{get:()=>s,set:t=>{s=t},clear:()=>{s=null}}}var b=class extends Error{constructor(t,a,e){super(t),this.code=a,this.status=e,this.name="LiveAPIError"}},v=class{constructor(t){var a,e,o,l;this.salesListings={list:async()=>await this.request("/sales/listings",{method:"GET"})},this.salesCustomerAuth={magicLink:async r=>(await this.request("/sales/customer-auth/magic-link",{method:"POST",body:JSON.stringify(r)})).sent},this.salesCustomerTokens={create:async r=>await this.request("/sales/customer-tokens",{method:"POST",body:JSON.stringify(r)}),refresh:async()=>await this.request("/sales/customer-tokens/refresh",{method:"POST"})},this.salesCarts={create:async r=>(await this.request("/sales/carts",{method:"POST",body:JSON.stringify(r)})).cart,get:async r=>(await this.request(`/sales/carts/${r}`,{method:"GET"})).cart,addItem:async(r,i)=>(await this.request(`/sales/carts/${r}/items`,{method:"POST",body:JSON.stringify(i)})).cart,removeItem:async(r,i)=>(await this.request(`/sales/carts/${r}/items/${i}`,{method:"DELETE"})).cart,checkout:async(r,i)=>await this.request(`/sales/carts/${r}/checkout`,{method:"POST",body:JSON.stringify(i)})},this.salesMyOrders={list:async()=>(await this.request("/sales/my-orders",{method:"GET"})).orders},this.salesOrders={get:async r=>(await this.request(`/sales/orders/${r}`,{method:"GET"})).order,ticketPdf:async(r,i)=>await this.request(`/sales/orders/${r}/passes/${i}/ticket.pdf`,{method:"GET"})},this.salesOrderPayments={create:async(r,i)=>(await this.request(`/sales/orders/${r}/payments`,{method:"POST",body:JSON.stringify(i)})).payment},this.salesRefundRequests={create:async(r,i)=>(await this.request(`/sales/orders/${r}/refund-requests`,{method:"POST",body:JSON.stringify(i)})).request},this.salesCustomers={create:async r=>(await this.request("/sales/customers",{method:"POST",body:JSON.stringify(r)})).customer,get:async r=>(await this.request(`/sales/customers/${r}`,{method:"GET"})).customer,update:async(r,i)=>(await this.request(`/sales/customers/${r}`,{method:"PATCH",body:JSON.stringify(i)})).customer},this.salesPresaleCodes={redeem:async r=>await this.request("/sales/presale-codes/redeem",{method:"POST",body:JSON.stringify(r)})},this.sales={resolveChannel:async r=>{let i=new URLSearchParams;(r==null?void 0:r.domain)!==void 0&&i.append("domain",String(r.domain));let n=i.toString(),c=n?`/sales/channel?${n}`:"/sales/channel";return await this.request(c,{method:"GET"})},get:async r=>(await this.request(`/sales/events/${r}`,{method:"GET"})).event,getTheme:async()=>(await this.request("/sales/theme",{method:"GET"})).theme},this.session={start:async r=>await this.request("/session",{method:"POST",body:JSON.stringify(r)}),current:async()=>await this.request("/session",{method:"GET"}),end:async()=>await this.request("/session",{method:"DELETE"}),attachOrderAccess:async r=>await this.request("/session/order-access",{method:"POST",body:JSON.stringify(r)})},this.queue={status:async()=>await this.request("/queue/status",{method:"GET"}),join:async()=>await this.request("/queue/join",{method:"POST"})},this.baseUrl=t.baseUrl.replace(/\/$/,""),this.sessionMode=(a=t.sessionMode)!=null?a:"cookie",this.publishableKey=t.publishableKey,this.tokenStorage=(e=t.tokenStorage)!=null?e:te(),this.apiVersion=(o=t.apiVersion)!=null?o:I,this.headers=(l=t.headers)!=null?l:{}}async setSessionToken(t){await this.tokenStorage.set(t)}async getSessionToken(){return this.tokenStorage.get()}async clearSession(){await this.tokenStorage.clear()}async request(t,a={}){var n,c,d;let e=`${this.baseUrl}${t}`,o={"Content-Type":"application/json","TL-Version":this.apiVersion,"TL-Client":ee,...this.headers,...a.headers};if(this.publishableKey&&(o.Authorization=`Bearer ${this.publishableKey}`),this.sessionMode==="token"){let u=await this.tokenStorage.get();u&&(o["X-Live-Session"]=u)}let l=await fetch(e,{...a,headers:o,credentials:this.sessionMode==="cookie"?"include":"same-origin"}),r=await l.text(),i=r?JSON.parse(r):null;if(!l.ok){let u=(n=i==null?void 0:i.error)!=null?n:{};throw new b((c=u.message)!=null?c:`Request failed (${l.status})`,(d=u.code)!=null?d:"REQUEST_FAILED",l.status)}return i&&i.status==="success"&&i.data!==void 0?i.data:i}};var x="Ticketlayer",se="ticketlayer:ready";function re(s){let t=window;if(t[x])return t[x];let a={client:null,sdk:null,version:s,_resolvers:[],getClient(){return this.client},getSDK(){return this.sdk},ready(){return this.client?Promise.resolve(this.client):new Promise(e=>this._resolvers.push(e))}};return t[x]=a,a}function U(s,t,a){if(typeof window=="undefined")return;let e=re(a);e.client&&e.client!==s&&console.warn("[live] A Ticketlayer client is already on window.Ticketlayer; replacing it. Create a single client per page."),e.client=s,e.sdk=t;let o=e._resolvers;e._resolvers=[],o.forEach(l=>l(s)),window.dispatchEvent(new CustomEvent(se,{detail:s}))}var ne="https://cdn.ticketlayer.com/elements/v1/ticketlayer-elements/ticketlayer-elements.esm.js",oe="tl-event-list",N=new Map;function K(s={}){var l;if(!s.elements||typeof window=="undefined"||typeof document=="undefined")return Promise.resolve();let t=window.customElements;if(t!=null&&t.get(oe))return Promise.resolve();let a=(l=s.elementsUrl)!=null?l:ne,e=N.get(a);if(e)return e;let o=new Promise((r,i)=>{let n=document.createElement("script");n.type="module",n.src=a,n.async=!0,n.dataset.ticketlayerElements="auto",n.onload=()=>r(),n.onerror=()=>i(new Error(`[live] Failed to load Elements from ${a}`)),document.head.appendChild(n)});return N.set(a,o),o}var D="tl-checkout-overlay",ae="https://ticketlayer.com/privacy",ie="https://ticketlayer.com/report-abuse",ce="https://ticketlayer.com";function le(){let s='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true" style="display:block;"><path d="M4 7.5A1.5 1.5 0 0 1 5.5 6h13A1.5 1.5 0 0 1 20 7.5v2a2 2 0 0 0 0 5v2a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 4 16.5v-2a2 2 0 0 0 0-5v-2Z" fill="currentColor"/><path d="M13 7v10" stroke="rgba(255,255,255,0.5)" stroke-width="1.2" stroke-dasharray="1.5 1.8" stroke-linecap="round"/></svg>',t=(a,e)=>`<a href="${a}" target="_blank" rel="noopener noreferrer" style="color:inherit;text-decoration:none;opacity:0.85;">${e}</a>`;return`<div style="display:flex;gap:16px;align-items:center;">${t(ae,"Privacy Policy")}${t(ie,"Report Abuse")}</div><a href="${ce}" target="_blank" rel="noopener noreferrer" style="color:inherit;text-decoration:none;display:inline-flex;align-items:center;gap:6px;opacity:0.92;"><span style="opacity:0.7;">Powered by</span>${s}<span style="font-weight:700;letter-spacing:0.01em;">Ticketlayer</span></a>`}function G(s,t={}){if(typeof window=="undefined"||typeof document=="undefined")return()=>{};let a=null,e=()=>{var i;(i=document.getElementById(D))==null||i.remove(),a&&(window.removeEventListener("message",a),a=null)},o=async i=>{let n=await s.getSessionToken().catch(()=>null),c=(t.embedBaseUrl||window.location.origin).replace(/\/$/,""),d=new URLSearchParams;n&&d.set("session",n),d.set("parent_origin",window.location.origin);let u=`${c}/embed/checkout?${d.toString()}`,h=new URL(u).origin;e();let f=document.createElement("div");f.id=D,f.style.cssText="position:fixed;inset:0;z-index:2147483647;background:rgba(15,23,42,0.55);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:16px;";let p=document.createElement("div");p.style.cssText="width:100%;max-width:960px;display:flex;flex-direction:column;gap:10px;";let w=document.createElement("iframe");w.src=u,w.allow="payment",w.style.cssText="width:100%;height:88vh;max-height:760px;border:1px solid var(--tl-border,#e5e7eb);border-radius:16px;background:#fff;box-shadow:0 24px 64px rgba(0,0,0,0.45);";let k=document.createElement("div");k.style.cssText='display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 8px;font:500 12px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:rgba(255,255,255,0.78);',k.innerHTML=le(),p.appendChild(w),p.appendChild(k),f.appendChild(p),f.addEventListener("click",y=>{var m;(y.target===f||y.target===p)&&(e(),(m=i.onClose)==null||m.call(i))}),document.body.appendChild(f),a=y=>{var P,M,$;if(y.origin!==h)return;let m=y.data;if(!(!m||typeof m!="object"))switch(m.type){case"tl:complete":{let E=m.order&&typeof m.order=="object"?m.order:{},L=m.orderId?{...E,id:m.orderId,orderNumber:m.orderReference,...m.accessToken?{accessToken:m.accessToken}:{}}:m.order;(P=i.onComplete)==null||P.call(i,L),s.emit("checkout:completed",L),e();break}case"tl:close":case"tl:cancel":(M=i.onClose)==null||M.call(i),e();break;case"tl:error":{let E=new Error(m.message||m.code||"Checkout failed");m.code&&(E.code=m.code),($=i.onError)==null||$.call(i,E);break}}},window.addEventListener("message",a)},l=s.on("ui:checkout-requested",i=>void o(i!=null?i:{})),r=s.on("ui:modal-close-requested",()=>e());return()=>{l(),r(),e()}}function B(s,t={}){if(typeof window=="undefined"||typeof document=="undefined")return()=>{};let a=t.tag||"tl-buy-modal",e=null,o=null,l=()=>{e&&(e.remove(),e=null),o=null},r=c=>{if(!(c!=null&&c.eventId))return;l(),o=c;let d=document.createElement(a);d.setAttribute("event-id",c.eventId),c.occurrenceId&&d.setAttribute("occurrence-id",c.occurrenceId),d.addEventListener("tlClose",()=>{var h;let u=o;l(),(h=u==null?void 0:u.onClose)==null||h.call(u)}),d.addEventListener("tlError",u=>{var f,p;let h=((f=u.detail)==null?void 0:f.message)||"Could not load this event";(p=o==null?void 0:o.onError)==null||p.call(o,new Error(h))}),d.addEventListener("tlCheckout",()=>{let u=o;l(),s.emit("ui:checkout-requested",{onComplete:u==null?void 0:u.onComplete,onError:u==null?void 0:u.onError,onClose:u==null?void 0:u.onClose})}),document.body.appendChild(d),e=d},i=s.on("ui:event-modal-requested",c=>r(c!=null?c:{})),n=s.on("ui:modal-close-requested",()=>l());return()=>{i(),n(),l()}}var _=s=>{var l,r,i,n,c;if(!s||typeof s!="object")return s;let t=s,a=((l=t.items)!=null?l:[]).map(d=>{var p,w,k;let u=d,h=(p=u.quantity)!=null?p:0,f=(w=u.subtotal)!=null?w:u.unitPrice*h;return{...u,totalPrice:(k=u.totalPrice)!=null?k:f}}),e=a.reduce((d,u)=>{var h;return d+((h=u.quantity)!=null?h:0)},0),o=(i=(r=t.itemsSubtotal)!=null?r:t.subtotal)!=null?i:0;return{...t,items:a,itemCount:e,subtotal:o,fees:(n=t.fees)!=null?n:0,total:(c=t.total)!=null?c:o}};function J(s){let t=new Map,a=(n,c)=>{let d=t.get(n);if(!(d!=null&&d.categoryId))throw new Error(`[live] No category known for ticket type ${n}. Load the occurrence's ticket types (getTicketTypes) before adding it to the cart.`);return{categoryId:d.categoryId,occurrenceId:c||d.occurrenceId}},e={async list(n){var u;let c=await s.events.list(),d=((u=c==null?void 0:c.listings)!=null?u:[]).map(h=>{var f,p,w;return{id:(f=h.eventId)!=null?f:h.id,name:(p=h.name)!=null?p:"",...h.shortDescription?{shortDescription:h.shortDescription}:{},...h.imageUrl?{imageUrl:h.imageUrl}:{},...h.venueName?{venue:{id:"",name:h.venueName,city:(w=h.venueCity)!=null?w:""}}:{},...h.nextOccurrenceAt?{nextOccurrence:{startsAt:h.nextOccurrenceAt}}:{},availabilityStatus:"available"}});return n!=null&&n.limit&&(d=d.slice(0,n.limit)),{items:d}},get:n=>s.events.get(n),async getTicketTypes(n,c){var f,p,w,k;let d=await s.events.get(n),u=(w=(f=d==null?void 0:d.occurrences)==null?void 0:f.find(y=>y.id===c))!=null?w:(p=d==null?void 0:d.occurrences)==null?void 0:p[0];return((k=u==null?void 0:u.ticketTypes)!=null?k:[]).map(y=>(u&&t.set(y.ticketTypeId,{categoryId:y.categoryId,occurrenceId:u.id}),{id:y.ticketTypeId,name:y.ticketTypeName,description:y.description,price:y.unitPrice,currency:y.currency,categoryId:y.categoryId,categoryName:y.categoryName,maxPerOrder:10,available:999}))}},o={get:async()=>{var n;return _((n=s.cart.current)!=null?n:await s.cart.refresh())},on:(n,c)=>s.on(n,d=>c(n==="cart:updated"?_(d):d)),off:(n,c)=>s.off(n,c),addItem:async(n,c,d)=>{let{categoryId:u,occurrenceId:h}=a(n,d);return _(await s.cart.add({eventOccurrenceId:h,categoryId:u,ticketTypeId:n,quantity:c}))},addItems:async n=>{let c=s.cart.current;for(let d of n)c=await o.addItem(d.ticketTypeId,d.quantity,d.occurrenceId);return c},removeItem:async n=>_(await s.cart.remove(n)),addSeat:async(n,c,d)=>{let{categoryId:u,occurrenceId:h}=a(c,d);return _(await s.cart.add({eventOccurrenceId:h,categoryId:u,ticketTypeId:c,eventLayoutSeatIds:[n]}))},removeSeat:async(n,c)=>{var d;return console.warn("[live] removeSeat is a no-op until cart items expose seat ids; use removeItem(itemId)."),_((d=await s.cart.refresh())!=null?d:s.cart.current)}},l={mine:()=>s.orders.mine(),get:n=>s.orders.get(n),ticketPdf:(n,c)=>s.orders.ticketPdf(n,c)},r={get customer(){return s.auth.customer},get authenticated(){return s.auth.authenticated},requestMagicLink:n=>s.auth.requestMagicLink(n),exchange:n=>s.auth.exchange(n),logout:()=>s.auth.logout()},i={redeem:n=>s.presale.redeem(n)};return{getEventsManager:()=>e,getCartManager:()=>o,getOrdersManager:()=>l,getAuthManager:()=>r,getPresaleManager:()=>i,on:(n,c)=>s.on(n,c),off:(n,c)=>s.off(n,c),event:n=>({openModal:(c={})=>s.emit("ui:event-modal-requested",{eventId:n,...c})}),checkout:{openModal:(n={})=>s.emit("ui:checkout-requested",n),closeModal:()=>s.emit("ui:modal-close-requested")},closeModal:()=>s.emit("ui:modal-close-requested")}}var T=class{constructor(){this.handlers=new Map}on(t,a){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(a),()=>this.off(t,a)}off(t,a){var e;(e=this.handlers.get(t))==null||e.delete(a)}emit(t,a){var e;(e=this.handlers.get(t))==null||e.forEach(o=>{try{o(a)}catch(l){console.error(`[live] handler for ${t} threw`,l)}})}};var V="tl-theme-vars",q=s=>s.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),de={fontFamily:"font-family",fontFamilyMono:"font-family-mono",baseSize:"font-size-base",scaleRatio:"font-scale"};function F(s){var o,l,r,i;if(!s||typeof document=="undefined")return;let t=[],a=(n,c)=>{c!=null&&t.push(`--tl-${n}: ${String(c)};`)};for(let[n,c]of Object.entries((o=s.colors)!=null?o:{})){let d=q(n);a(d,c),a(`color-${d}`,c),n==="destructive"&&(a("error",c),a("color-error",c)),n==="destructiveForeground"&&(a("error-foreground",c),a("color-error-foreground",c))}for(let[n,c]of Object.entries((l=s.typography)!=null?l:{}))a((r=de[n])!=null?r:q(n),c);for(let[n,c]of Object.entries((i=s.shape)!=null?i:{}))a(q(n),c);let e=document.getElementById(V);e||(e=document.createElement("style"),e.id=V,document.head.appendChild(e)),e.textContent=`:root {
|
|
2
|
-
${
|
|
1
|
+
"use strict";var TicketlayerLive=(()=>{var q=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var de=(t,e)=>{for(var a in e)q(t,a,{get:e[a],enumerable:!0})},le=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ce(e))!ue.call(t,o)&&o!==a&&q(t,o,{get:()=>e[o],enumerable:!(r=ie(e,o))||r.enumerable});return t};var fe=t=>le(q({},"__esModule",{value:!0}),t);var ve={};de(ve,{TicketlayerLive:()=>v,boot:()=>ae,createLiveClient:()=>B});var z="@ticketlayer/live",j="0.4.0";var K="2026-06-13";function me(){var e,a,r;let t=globalThis;return((e=t.navigator)==null?void 0:e.product)==="ReactNative"?"react-native":typeof t.window!="undefined"&&typeof t.document!="undefined"?"browser":(r=(a=t.process)==null?void 0:a.versions)!=null&&r.node?`node/${t.process.versions.node}`:t.EdgeRuntime?"edge":"unknown"}var he=`${z.replace(/^@/,"").replace("/","-")}/${j} (${me()})`;function ge(){let t=null;return{get:()=>t,set:e=>{t=e},clear:()=>{t=null}}}var _=class extends Error{constructor(e,a,r){super(e),this.code=a,this.status=r,this.name="LiveAPIError"}},N=class{constructor(e){var a,r,o,c;this.salesListings={list:async()=>await this.request("/sales/listings",{method:"GET"})},this.salesCustomerAuth={magicLink:async s=>(await this.request("/sales/customer-auth/magic-link",{method:"POST",body:JSON.stringify(s)})).sent},this.salesCustomerTokens={create:async s=>await this.request("/sales/customer-tokens",{method:"POST",body:JSON.stringify(s)}),refresh:async()=>await this.request("/sales/customer-tokens/refresh",{method:"POST"})},this.salesCarts={create:async s=>(await this.request("/sales/carts",{method:"POST",body:JSON.stringify(s)})).cart,get:async s=>(await this.request(`/sales/carts/${s}`,{method:"GET"})).cart,addItem:async(s,n)=>(await this.request(`/sales/carts/${s}/items`,{method:"POST",body:JSON.stringify(n)})).cart,removeItem:async(s,n)=>(await this.request(`/sales/carts/${s}/items/${n}`,{method:"DELETE"})).cart,checkout:async(s,n)=>await this.request(`/sales/carts/${s}/checkout`,{method:"POST",body:JSON.stringify(n)})},this.salesMyOrders={list:async()=>(await this.request("/sales/my-orders",{method:"GET"})).orders},this.salesOrders={get:async s=>(await this.request(`/sales/orders/${s}`,{method:"GET"})).order,ticketPdf:async(s,n)=>await this.request(`/sales/orders/${s}/passes/${n}/ticket.pdf`,{method:"GET"})},this.salesOrderPayments={create:async(s,n)=>(await this.request(`/sales/orders/${s}/payments`,{method:"POST",body:JSON.stringify(n)})).payment},this.salesRefundRequests={create:async(s,n)=>(await this.request(`/sales/orders/${s}/refund-requests`,{method:"POST",body:JSON.stringify(n)})).request},this.salesCustomers={create:async s=>(await this.request("/sales/customers",{method:"POST",body:JSON.stringify(s)})).customer,get:async s=>(await this.request(`/sales/customers/${s}`,{method:"GET"})).customer,update:async(s,n)=>(await this.request(`/sales/customers/${s}`,{method:"PATCH",body:JSON.stringify(n)})).customer},this.salesPresaleCodes={redeem:async s=>await this.request("/sales/presale-codes/redeem",{method:"POST",body:JSON.stringify(s)})},this.sales={resolveChannel:async s=>{let n=new URLSearchParams;(s==null?void 0:s.domain)!==void 0&&n.append("domain",String(s.domain));let i=n.toString(),d=i?`/sales/channel?${i}`:"/sales/channel";return await this.request(d,{method:"GET"})},get:async s=>(await this.request(`/sales/events/${s}`,{method:"GET"})).event,getTheme:async()=>(await this.request("/sales/theme",{method:"GET"})).theme},this.session={start:async s=>await this.request("/session",{method:"POST",body:JSON.stringify(s)}),current:async()=>await this.request("/session",{method:"GET"}),end:async()=>await this.request("/session",{method:"DELETE"}),attachOrderAccess:async s=>await this.request("/session/order-access",{method:"POST",body:JSON.stringify(s)})},this.queue={status:async()=>await this.request("/queue/status",{method:"GET"}),join:async()=>await this.request("/queue/join",{method:"POST"})},this.baseUrl=e.baseUrl.replace(/\/$/,""),this.sessionMode=(a=e.sessionMode)!=null?a:"cookie",this.publishableKey=e.publishableKey,this.tokenStorage=(r=e.tokenStorage)!=null?r:ge(),this.apiVersion=(o=e.apiVersion)!=null?o:K,this.headers=(c=e.headers)!=null?c:{}}async setSessionToken(e){await this.tokenStorage.set(e)}async getSessionToken(){return this.tokenStorage.get()}async clearSession(){await this.tokenStorage.clear()}async request(e,a={}){var i,d,u;let r=`${this.baseUrl}${e}`,o={"Content-Type":"application/json","TL-Version":this.apiVersion,"TL-Client":he,...this.headers,...a.headers};if(this.publishableKey&&(o.Authorization=`Bearer ${this.publishableKey}`),this.sessionMode==="token"){let l=await this.tokenStorage.get();l&&(o["X-Live-Session"]=l)}let c=await fetch(r,{...a,headers:o,credentials:this.sessionMode==="cookie"?"include":"same-origin"}),s=await c.text(),n=s?JSON.parse(s):null;if(!c.ok){let l=(i=n==null?void 0:n.error)!=null?i:{};throw new _((d=l.message)!=null?d:`Request failed (${c.status})`,(u=l.code)!=null?u:"REQUEST_FAILED",c.status)}return n&&n.status==="success"&&n.data!==void 0?n.data:n}};var P="Ticketlayer",pe="ticketlayer:ready";function ye(t){let e=window;if(e[P])return e[P];let a={client:null,sdk:null,version:t,_resolvers:[],getClient(){return this.client},getSDK(){return this.sdk},ready(){return this.client?Promise.resolve(this.client):new Promise(r=>this._resolvers.push(r))}};return e[P]=a,a}function J(t,e,a){if(typeof window=="undefined")return;let r=ye(a);r.client&&r.client!==t&&console.warn("[live] A Ticketlayer client is already on window.Ticketlayer; replacing it. Create a single client per page."),r.client=t,r.sdk=e;let o=r._resolvers;r._resolvers=[],o.forEach(c=>c(t)),window.dispatchEvent(new CustomEvent(pe,{detail:t}))}var V="https://cdn.ticketlayer.com/elements/v1/ticketlayer-elements/ticketlayer-elements.esm.js",be="tl-event-list",Y=new Map,we=/\/v\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?\//,ke=/^(?:sha(?:256|384|512)-[A-Za-z0-9+/]+={0,2})(?:\s+sha(?:256|384|512)-[A-Za-z0-9+/]+={0,2})*$/,M=class extends Error{constructor(e){super(`[live] ${e}`),this.name="ElementsIntegrityError"}},H=!1;function X(t={}){var s,n;if(!t.elements)return Promise.resolve();let e=((s=t.elementsIntegrity)==null?void 0:s.trim())||void 0;if(e&&!t.elementsUrl)throw new M("elementsIntegrity was given without elementsUrl. The default Elements URL is a floating path that every release rewrites, so a hash pinned to it cannot keep matching. Pass the pinned elementsUrl that the hash is for (see /versions.json on the CDN).");if(e&&!ke.test(e))throw new M(`elementsIntegrity is not a subresource integrity value: ${JSON.stringify(t.elementsIntegrity)}. Expected one or more of sha256-, sha384- or sha512- followed by base64, as /versions.json publishes it.`);if(t.elementsUrl&&!e&&we.test(t.elementsUrl))throw new M(`elementsUrl ${t.elementsUrl} names an exact version, which is the CDN's pinned tier, but no elementsIntegrity came with it. A pinned URL exists to be verified; loading it unchecked would be weaker than the floating path. Pass the sha384 from /versions.json as elementsIntegrity (data-elements-integrity on the embed script), or use a floating /v1/ URL.`);if(typeof window=="undefined"||typeof document=="undefined")return Promise.resolve();let a=window.customElements;if(a!=null&&a.get(be))return Promise.resolve();let r=(n=t.elementsUrl)!=null?n:V;!t.elementsUrl&&!H&&(H=!0,console.warn(`[live] Loading Elements unverified from the floating default ${V}. Floating paths are rewritten by every release and cannot carry a subresource integrity hash. To verify the bundle, pin it: set elementsUrl (data-elements-url) to the pinned path from /versions.json and elementsIntegrity (data-elements-integrity) to the sha384 beside it.`));let o=Y.get(r);if(o)return o;let c=new Promise((i,d)=>{let u=document.createElement("script");u.type="module",u.src=r,u.async=!0,e&&(u.integrity=e,u.crossOrigin="anonymous"),u.dataset.ticketlayerElements="auto",u.onload=()=>i(),u.onerror=()=>d(new Error(`[live] Failed to load Elements from ${r}`)),document.head.appendChild(u)});return Y.set(r,c),c}var U={"color-primary":"primary","color-primary-foreground":"primary-foreground","color-secondary":"secondary","color-secondary-foreground":"secondary-foreground","color-accent":"accent","color-accent-foreground":"accent-foreground","color-background":"background","color-foreground":"foreground","color-card":"card","color-muted":"muted","color-muted-foreground":"muted-foreground","color-border":"border","color-border-hover":"border-hover","color-input":"input","color-ring":"ring","color-success":"success","color-success-foreground":"success-foreground","color-warning":"warning","color-warning-foreground":"warning-foreground","color-warning-bg":"warning-bg","color-error":"error",destructive:"error","color-destructive":"error","color-error-foreground":"error-foreground","destructive-foreground":"error-foreground","color-destructive-foreground":"error-foreground","color-error-bg":"error-bg","destructive-bg":"error-bg","color-destructive-bg":"error-bg","base-size":"font-size-base",radius:"radius-md"},A={primary:"#6366f1","primary-foreground":"#ffffff",secondary:"#f3f4f6","secondary-foreground":"#111827",accent:"#ec4899","accent-foreground":"#ffffff",background:"#ffffff",foreground:"#111827",card:"#ffffff",muted:"#f9fafb","muted-foreground":"#6b7280",border:"#e5e7eb","border-hover":"#9ca3af",input:"#e5e7eb",ring:"#6366f1",success:"#10b981","success-foreground":"#ffffff",warning:"#f59e0b","warning-foreground":"#ffffff","warning-bg":"#fef3c7",error:"#ef4444","error-foreground":"#ffffff","error-bg":"#fee2e2","font-family":"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif","font-family-mono":"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace","font-size-base":"16px","font-scale":"1.25","radius-none":"0px","radius-sm":"0.25rem","radius-md":"0.5rem","radius-lg":"0.75rem","radius-full":"9999px","spacing-1":"0.25rem","spacing-2":"0.5rem","spacing-3":"0.75rem","spacing-4":"1rem","spacing-5":"1.25rem","spacing-6":"1.5rem","spacing-8":"2rem","duration-fast":"120ms","duration-normal":"200ms","duration-slow":"320ms","easing-standard":"cubic-bezier(0.2, 0, 0, 1)","easing-emphasised":"cubic-bezier(0.3, 0, 0, 1)"};var $={primary:"colors.primary","primary-foreground":"colors.primaryForeground",secondary:"colors.secondary","secondary-foreground":"colors.secondaryForeground",accent:"colors.accent","accent-foreground":"colors.accentForeground",background:"colors.background",foreground:"colors.foreground",muted:"colors.muted","muted-foreground":"colors.mutedForeground",border:"colors.border",input:"colors.input",ring:"colors.ring",success:"colors.success","success-foreground":"colors.successForeground",warning:"colors.warning","warning-foreground":"colors.warningForeground",error:"colors.destructive","error-foreground":"colors.destructiveForeground","font-family":"typography.fontFamily","font-family-mono":"typography.fontFamilyMono","font-size-base":"typography.baseSize","font-scale":"typography.scaleRatio","radius-none":"shape.radiusNone","radius-sm":"shape.radiusSm","radius-md":"shape.radiusMd","radius-lg":"shape.radiusLg","radius-full":"shape.radiusFull"};function R(t){return`--tl-${t}`}function Z(t){var a;let e={};if(!t)return e;for(let[r,o]of Object.entries($)){let[c,s]=o.split("."),n=(a=t[c])==null?void 0:a[s];n==null||n===""||(e[R(r)]=String(n))}for(let[r,o]of Object.entries(U)){let c=e[R(o)];c!==void 0&&(e[R(r)]=c)}return e}var Q="tl-checkout-overlay";function W(t,e={}){if(typeof window=="undefined"||typeof document=="undefined")return()=>{};let a=null,r=()=>{var n;(n=document.getElementById(Q))==null||n.remove(),a&&(window.removeEventListener("message",a),a=null)},o=async n=>{let i=await t.getSessionToken().catch(()=>null),d=(e.embedBaseUrl||window.location.origin).replace(/\/$/,""),u=new URLSearchParams;i&&u.set("session",i),u.set("parent_origin",window.location.origin);let l=`${d}/embed/checkout?${u.toString()}`,f=new URL(l).origin;r();let g=document.createElement("div");g.id=Q,g.style.cssText="position:fixed;inset:0;z-index:2147483647;background:rgba(15,23,42,0.55);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:16px;";let h=document.createElement("div");h.style.cssText="width:100%;max-width:960px;display:flex;flex-direction:column;gap:10px;";let b=document.createElement("iframe");b.src=l,b.allow="payment",b.style.cssText=`width:100%;height:88vh;max-height:760px;border:1px solid var(--tl-border, ${A.border});border-radius:16px;background:#fff;box-shadow:0 24px 64px rgba(0,0,0,0.45);`,h.appendChild(b),g.appendChild(h),g.addEventListener("click",w=>{var m;(w.target===g||w.target===h)&&(r(),(m=n.onClose)==null||m.call(n))}),document.body.appendChild(g),a=w=>{var I,x,C;if(w.origin!==f)return;let m=w.data;if(!(!m||typeof m!="object"))switch(m.type){case"tl:complete":{let S=m.order&&typeof m.order=="object"?m.order:{},O=m.orderId?{...S,id:m.orderId,orderNumber:m.orderReference,...m.accessToken?{accessToken:m.accessToken}:{}}:m.order;(I=n.onComplete)==null||I.call(n,O),t.emit("checkout:completed",O),r();break}case"tl:close":case"tl:cancel":(x=n.onClose)==null||x.call(n),r();break;case"tl:error":{let S=new Error(m.message||m.code||"Checkout failed");m.code&&(S.code=m.code),(C=n.onError)==null||C.call(n,S);break}}},window.addEventListener("message",a)},c=t.on("ui:checkout-requested",n=>void o(n!=null?n:{})),s=t.on("ui:modal-close-requested",()=>r());return()=>{c(),s(),r()}}function ee(t,e={}){if(typeof window=="undefined"||typeof document=="undefined")return()=>{};let a=e.tag||"tl-buy-modal",r=null,o=null,c=()=>{r&&(r.remove(),r=null),o=null},s=d=>{if(!(d!=null&&d.eventId))return;c(),o=d;let u=document.createElement(a);u.setAttribute("event-id",d.eventId),d.occurrenceId&&u.setAttribute("occurrence-id",d.occurrenceId),u.addEventListener("tlClose",()=>{var f;let l=o;c(),(f=l==null?void 0:l.onClose)==null||f.call(l)}),u.addEventListener("tlError",l=>{var g,h;let f=((g=l.detail)==null?void 0:g.message)||"Could not load this event";(h=o==null?void 0:o.onError)==null||h.call(o,new Error(f))}),u.addEventListener("tlCheckout",()=>{let l=o;c(),t.emit("ui:checkout-requested",{onComplete:l==null?void 0:l.onComplete,onError:l==null?void 0:l.onError,onClose:l==null?void 0:l.onClose})}),document.body.appendChild(u),r=u},n=t.on("ui:event-modal-requested",d=>s(d!=null?d:{})),i=t.on("ui:modal-close-requested",()=>c());return()=>{n(),i(),c()}}var re=t=>t&&typeof t=="object"?t:{};function k(t){return typeof t=="number"?Number.isInteger(t)?t:null:typeof t=="string"&&/^-?\d+$/.test(t)?Number(t):null}var D=t=>typeof t.type=="string"?t.type:"ticket",Ee=t=>!["fee","tax","discount"].includes(D(t));function Se(t,e){return t===null?e:t>0||e}function te(t){var w,m,I,x,C,S,O,G;let e=re(t),a=Array.isArray(e.items)?e.items.map(re):[],r=(m=(w=k(e.itemsSubtotal))!=null?w:k(e.subtotal))!=null?m:a.filter(Ee).reduce((y,L)=>{var E;return y+((E=k(L.subtotal))!=null?E:0)},0),o=a.filter(y=>D(y)==="fee"),c=o.length?o.reduce((y,L)=>{var E;return y+((E=k(L.subtotal))!=null?E:0)},0):null,s=(x=(I=k(e.totalFees))!=null?I:k(e.fees))!=null?x:c,n=typeof e.feeLabel=="string"&&e.feeLabel?e.feeLabel:null,i=o.map(y=>y.name).find(y=>typeof y=="string"&&y),d=(C=n!=null?n:i)!=null?C:null,u=a.filter(y=>D(y)==="discount"),l=u.length?u.reduce((y,L)=>{var E;return y+Math.abs((E=k(L.subtotal))!=null?E:0)},0):null,f=(O=(S=k(e.totalDiscounts))!=null?S:k(e.discount))!=null?O:l,g=(G=k(e.totalTax))!=null?G:0,h=k(e.total),b=h!=null?h:r+(s!=null?s:0)+g-(f!=null?f:0);return{currency:typeof e.currency=="string"?e.currency:null,subtotal:r,fees:s!=null?s:0,discount:f!=null?f:0,total:b,hasFees:Se(s,d!==null||o.length>0),feeLabel:d,totalFromServer:h!==null}}var T=t=>{var c;if(!t||typeof t!="object")return t;let e=t,a=((c=e.items)!=null?c:[]).map(s=>{var u,l,f;let n=s,i=(u=n.quantity)!=null?u:0,d=(l=n.subtotal)!=null?l:n.unitPrice*i;return{...n,totalPrice:(f=n.totalPrice)!=null?f:d}}),r=a.reduce((s,n)=>{var i;return s+((i=n.quantity)!=null?i:0)},0),o=te(e);return{...e,items:a,itemCount:r,subtotal:o.subtotal,fees:o.fees,discount:o.discount,total:o.total,hasFees:o.hasFees,feeLabel:o.feeLabel}};function se(t){let e=new Map,a=(i,d)=>{let u=e.get(i);if(!(u!=null&&u.categoryId))throw new Error(`[live] No category known for ticket type ${i}. Load the occurrence's ticket types (getTicketTypes) before adding it to the cart.`);return{categoryId:u.categoryId,occurrenceId:d||u.occurrenceId}},r={async list(i){var l;let d=await t.events.list(),u=((l=d==null?void 0:d.listings)!=null?l:[]).map(f=>{var g,h,b;return{id:(g=f.eventId)!=null?g:f.id,name:(h=f.name)!=null?h:"",...f.shortDescription?{shortDescription:f.shortDescription}:{},...f.imageUrl?{imageUrl:f.imageUrl}:{},...f.venueName?{venue:{id:"",name:f.venueName,city:(b=f.venueCity)!=null?b:""}}:{},...f.nextOccurrenceAt?{nextOccurrence:{startsAt:f.nextOccurrenceAt}}:{},availabilityStatus:"available"}});return i!=null&&i.limit&&(u=u.slice(0,i.limit)),{items:u}},get:i=>t.events.get(i),async getTicketTypes(i,d){var g,h,b,w;let u=await t.events.get(i),l=(b=(g=u==null?void 0:u.occurrences)==null?void 0:g.find(m=>m.id===d))!=null?b:(h=u==null?void 0:u.occurrences)==null?void 0:h[0];return((w=l==null?void 0:l.ticketTypes)!=null?w:[]).map(m=>(l&&e.set(m.ticketTypeId,{categoryId:m.categoryId,occurrenceId:l.id}),{id:m.ticketTypeId,name:m.ticketTypeName,description:m.description,price:m.unitPrice,currency:m.currency,categoryId:m.categoryId,categoryName:m.categoryName,maxPerOrder:10,available:999}))}},o={get:async()=>{var i;return T((i=t.cart.current)!=null?i:await t.cart.refresh())},on:(i,d)=>t.on(i,u=>d(i==="cart:updated"?T(u):u)),off:(i,d)=>t.off(i,d),addItem:async(i,d,u)=>{let{categoryId:l,occurrenceId:f}=a(i,u);return T(await t.cart.add({eventOccurrenceId:f,categoryId:l,ticketTypeId:i,quantity:d}))},addItems:async i=>{let d=t.cart.current;for(let u of i)d=await o.addItem(u.ticketTypeId,u.quantity,u.occurrenceId);return d},removeItem:async i=>T(await t.cart.remove(i)),addSeat:async(i,d,u)=>{let{categoryId:l,occurrenceId:f}=a(d,u);return T(await t.cart.add({eventOccurrenceId:f,categoryId:l,ticketTypeId:d,eventLayoutSeatIds:[i]}))},removeSeat:async(i,d)=>{var u;return console.warn("[live] removeSeat is a no-op until cart items expose seat ids; use removeItem(itemId)."),T((u=await t.cart.refresh())!=null?u:t.cart.current)}},c={mine:()=>t.orders.mine(),get:i=>t.orders.get(i),ticketPdf:(i,d)=>t.orders.ticketPdf(i,d)},s={get customer(){return t.auth.customer},get authenticated(){return t.auth.authenticated},requestMagicLink:i=>t.auth.requestMagicLink(i),exchange:i=>t.auth.exchange(i),logout:()=>t.auth.logout()},n={redeem:i=>t.presale.redeem(i)};return{getEventsManager:()=>r,getCartManager:()=>o,getOrdersManager:()=>c,getAuthManager:()=>s,getPresaleManager:()=>n,on:(i,d)=>t.on(i,d),off:(i,d)=>t.off(i,d),event:i=>({openModal:(d={})=>t.emit("ui:event-modal-requested",{eventId:i,...d})}),checkout:{openModal:(i={})=>t.emit("ui:checkout-requested",i),closeModal:()=>t.emit("ui:modal-close-requested")},closeModal:()=>t.emit("ui:modal-close-requested")}}var F=class{constructor(){this.handlers=new Map}on(e,a){return this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(a),()=>this.off(e,a)}off(e,a){var r;(r=this.handlers.get(e))==null||r.delete(a)}emit(e,a){var r;(r=this.handlers.get(e))==null||r.forEach(o=>{try{o(a)}catch(c){console.error(`[live] handler for ${e} threw`,c)}})}};var oe="tl-theme-vars";function ne(t){if(!t||typeof document=="undefined")return;let e=Object.entries(Z(t)).map(([r,o])=>`${r}: ${o};`),a=document.getElementById(oe);a||(a=document.createElement("style"),a.id=oe,document.head.appendChild(a)),a.textContent=`:root {
|
|
2
|
+
${e.join(`
|
|
3
3
|
`)}
|
|
4
|
-
}`}var
|
|
4
|
+
}`}var p=(t,e)=>t&&typeof t=="object"&&!Array.isArray(t)&&e in t?t[e]:t,v=class{constructor(e,a){this.emitter=new F,this._sessionStarted=!1,this._sessionStarting=null,this._session={channelId:null,customer:null,authenticated:!1},this._cart=null,this._cartId=null,this.client=e,this.sessionMode=a.sessionMode,this.publishableKey=a.publishableKey,this.domain=a.domain,this.baseUrl=a.baseUrl.replace(/\/$/,"");let r=this;this.events={list:()=>r.client.salesListings.list(),get:o=>r.client.sales.get(o).then(c=>p(c,"event"))},this.theme={get:()=>r.client.sales.getTheme().then(o=>p(o,"theme")),apply:async()=>{let o=await r.theme.get();return ne(o),o}},this.cart={get current(){return r._cart},get id(){return r._cartId},ensure:async()=>{var o;if(!r._cartId){await r.ensureSession();let c=await r.client.salesCarts.create({}),s=p(c,"cart");r._cartId=(o=s==null?void 0:s.id)!=null?o:null,r._setCart(s)}return r._cartId},add:async o=>{let c=await r.cart.ensure();try{let s=await r.client.salesCarts.addItem(c,o);return r._setCart(p(s,"cart")),r._cart}catch(s){if(!r._isCartGone(s))throw s;r._resetCart();let n=await r.cart.ensure(),i=await r.client.salesCarts.addItem(n,o);return r._setCart(p(i,"cart")),r._cart}},remove:async o=>{if(!r._cartId)return r._cart;try{let c=await r.client.salesCarts.removeItem(r._cartId,o);return r._setCart(p(c,"cart")),r._cart}catch(c){if(!r._isCartGone(c))throw c;return r._resetCart(),r._cart}},refresh:async()=>{if(!r._cartId)return r._cart;try{let o=await r.client.salesCarts.get(r._cartId);return r._setCart(p(o,"cart")),r._cart}catch(o){if(!r._isCartGone(o))throw o;return r._resetCart(),r._cart}},checkout:async(o={})=>{if(!r._cartId)throw new Error("No cart to check out");try{let c=await r.client.salesCarts.checkout(r._cartId,o);return r._cartId=null,r._setCart(null),r.emitter.emit("checkout:completed",p(c,"order")),c}catch(c){throw r._isCartGone(c)?(r._resetCart(),new _("Your cart has expired. Please add your tickets again.","CART_EXPIRED",409)):c}}},this.auth={get customer(){return r._session.customer},get authenticated(){return r._session.authenticated},requestMagicLink:o=>r.client.salesCustomerAuth.magicLink(o),exchange:async o=>{var n;await r.ensureSession();let c=typeof o=="string"?{type:"magic_link",code:o}:o,s=await r.client.salesCustomerTokens.create({proof:c});return r._session={...r._session,customer:(n=p(s,"customer"))!=null?n:null,authenticated:!0},r.emitter.emit("auth:changed",r._session),s},logout:async()=>{await r.client.session.end().catch(()=>{}),r._session={channelId:r._session.channelId,customer:null,authenticated:!1},r._cart=null,r._cartId=null,r.emitter.emit("auth:changed",r._session)}},this.orders={mine:()=>r.client.salesMyOrders.list().then(o=>p(o,"orders")),get:o=>r.client.salesOrders.get(o).then(c=>p(c,"order")),ticketPdf:async(o,c)=>{let s={};if(r.publishableKey&&(s.Authorization=`Bearer ${r.publishableKey}`),r.sessionMode==="token"){let i=await r.client.getSessionToken();i&&(s["X-Live-Session"]=i)}let n=await fetch(`${r.baseUrl}/sales/orders/${o}/passes/${c}/ticket.pdf`,{headers:s,credentials:r.sessionMode==="cookie"?"include":"same-origin"});if(!n.ok)throw new _(`Failed to download ticket (${n.status})`,"TICKET_PDF_FAILED",n.status);return n.blob()}},this.payments={begin:(o,c={})=>r.client.salesOrderPayments.create(o,c).then(s=>p(s,"payment"))},this.presale={redeem:async o=>{let c=await r.client.salesPresaleCodes.redeem({code:o.trim()});return r._cartId&&await r.cart.refresh().catch(()=>{}),c}},this.queue={status:()=>r.client.queue.status(),join:()=>r.client.queue.join()}}on(e,a){return this.emitter.on(e,a)}off(e,a){this.emitter.off(e,a)}emit(e,a){this.emitter.emit(e,a)}get session(){return this._session}get hasSession(){return this._sessionStarted}async ensureSession(){if(!this._sessionStarted){if(this._sessionStarting)return this._sessionStarting;this._sessionStarting=(async()=>{let e={};this.sessionMode==="token"&&this.publishableKey?e.channelKey=this.publishableKey:this.domain?e.domain=this.domain:this.publishableKey&&(e.channelKey=this.publishableKey);let a=await this.client.session.start(e);if(this.sessionMode==="token"){let r=p(a,"sessionToken");r&&await this.client.setSessionToken(r)}this._sessionStarted=!0,await this.refreshSession()})();try{await this._sessionStarting}finally{this._sessionStarting=null}}}async start(e={}){return e.domain&&(this.domain=e.domain),this.ensureSession()}async resumeIfExists(){if(this._sessionStarted)return!0;try{return await this.refreshSession(),this._sessionStarted=!0,!0}catch{return!1}}async resume(e){await this.client.setSessionToken(e),this._sessionStarted=!0,await this.refreshSession()}getSessionToken(){return this.client.getSessionToken()}async refreshSession(){var r,o,c,s;let e=await this.client.session.current();this._session={channelId:(o=(r=p(e,"channel"))==null?void 0:r.id)!=null?o:null,customer:(c=p(e,"customer"))!=null?c:null,authenticated:!!p(e,"authenticated")};let a=(s=p(e,"cartId"))!=null?s:null;a&&(this._cartId=a,await this.cart.refresh()),this.emitter.emit("session:changed",this._session)}_resetSessionStarted(){this._sessionStarted=!1,this._sessionStarting=null}_setCart(e){this._cart=e!=null?e:null,this.emitter.emit("cart:updated",this._cart)}_isCartGone(e){return e instanceof _?e.code==="CART_EXPIRED"||e.code==="CART_NOT_ACTIVE"||e.code==="CART_NOT_FOUND"||e.status===404:!1}_resetCart(){this._cartId=null,this._setCart(null)}};async function _e(t,e){var a;try{let r=await fetch(`${t.replace(/\/$/,"")}/channel?domain=${encodeURIComponent(e)}`,{headers:{accept:"application/json"}});if(!r.ok)return;let o=await r.json();return(a=o==null?void 0:o.data)==null?void 0:a.publishableKey}catch{return}}async function B(t){var i,d,u;let e=(i=t.domain)!=null?i:typeof window!="undefined"?window.location.host:void 0,a=t.publishableKey;!a&&!t.sessionToken&&e&&(a=await _e(t.baseUrl,e));let r=!!t.publishableKey||!!t.sessionToken,o=(d=t.sessionMode)!=null?d:r?"token":"cookie",c=new N({...t,sessionMode:o,...a?{publishableKey:a}:{}}),s=new v(c,{sessionMode:o,baseUrl:t.baseUrl,...a?{publishableKey:a}:{},...e?{domain:e}:{}});t.publish!==!1&&typeof window!="undefined"&&J(s,se(s),K),((u=t.checkout)==null?void 0:u.mode)==="modal"&&typeof window!="undefined"&&W(s,t.checkout),t.buyModal!==!1&&t.publish!==!1&&typeof window!="undefined"&&ee(s);let n=X(t).catch(l=>{console.error("[live] Elements auto-load failed",l)});return t.autoStart!==!1&&(t.sessionToken?await s.resume(t.sessionToken):o==="cookie"&&typeof window!="undefined"&&await s.resumeIfExists().catch(()=>{}),t.applyTheme!==!1&&typeof window!="undefined"&&await s.theme.apply().catch(()=>{})),await n,s}function Te(){var a;if(typeof document=="undefined")return null;let t=(a=document.currentScript)!=null?a:document.querySelector("script[data-publishable-key]");if(!t)return null;let e=t.dataset;return{publishableKey:e.publishableKey,apiUrl:e.apiUrl,elementsUrl:e.elementsUrl,elementsIntegrity:e.elementsIntegrity,checkoutBase:e.checkoutBase,autoElements:e.elements!=="false"}}function ae(){var r,o;if(typeof window=="undefined")return Promise.resolve(null);let t=window;if(t.__tlBooted)return(o=(r=t.ticketlayer)==null?void 0:r.ready)!=null?o:Promise.resolve(null);let e=Te();if(!(e!=null&&e.publishableKey))return Promise.resolve(null);if(!e.apiUrl)return console.error("[ticketlayer] Missing data-api-url on the embed script; cannot auto-init."),Promise.resolve(null);t.__tlBooted=!0;let a=B({baseUrl:e.apiUrl,publishableKey:e.publishableKey,elements:e.autoElements,...e.elementsUrl?{elementsUrl:e.elementsUrl}:{},...e.elementsIntegrity?{elementsIntegrity:e.elementsIntegrity}:{},checkout:{mode:"modal",...e.checkoutBase?{embedBaseUrl:e.checkoutBase}:{}}}).catch(c=>(console.error("[ticketlayer] Failed to initialise:",c),null));return t.ticketlayer={ready:a},a}ae();return fe(ve);})();
|
|
5
5
|
//# sourceMappingURL=ticketlayer.js.map
|