@momentco-ai/moment-sdk 0.9.0-dev.49 → 0.9.0-dev.51
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/CHANGELOG.md +9 -0
- package/README.md +11 -9
- package/dist/moment-sdk.js +31 -4
- package/dist/moment-sdk.mjs +325 -224
- package/dist/types/sdk/__tests__/fake-dom.d.ts +107 -0
- package/dist/types/sdk/__tests__/moment-sdk-frame.test.d.ts +1 -0
- package/dist/types/sdk/modal-frame.d.ts +22 -0
- package/dist/types/sdk/moment-sdk.d.ts +22 -0
- package/dist/types/sdk/popup-bridge.d.ts +3 -2
- package/dist/types/sdk/sdk-styles.d.ts +8 -3
- package/dist/types/sdk/types.d.ts +44 -6
- package/package.json +1 -1
package/dist/moment-sdk.mjs
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
const M = "moment_sync", O = "moment_campaign";
|
|
2
|
+
const X = /^(?:schedule|(moment|list):([a-z0-9-]+)|playlist:([a-z0-9-]+(?:,[a-z0-9-]+)*))$/, J = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
3
|
+
function Q(i, e) {
|
|
4
4
|
if (!e) return null;
|
|
5
|
-
const t = new URL(i),
|
|
6
|
-
if (
|
|
7
|
-
const r =
|
|
5
|
+
const t = new URL(i), s = t.searchParams.get(M);
|
|
6
|
+
if (s === null || s.length > 200) return null;
|
|
7
|
+
const r = X.exec(s);
|
|
8
8
|
if (!r) return null;
|
|
9
|
-
const [, o,
|
|
10
|
-
let
|
|
11
|
-
o === "moment" ?
|
|
12
|
-
const u = t.searchParams.get(
|
|
13
|
-
return t.search = t.search.slice(1).split("&").filter((
|
|
14
|
-
const l =
|
|
15
|
-
return l !==
|
|
9
|
+
const [, o, n, a] = r;
|
|
10
|
+
let h;
|
|
11
|
+
o === "moment" ? h = { teamSlug: e, triggerType: "moment", momentSlug: n } : o === "list" ? h = { teamSlug: e, triggerType: "list", listSlug: n } : a ? h = { teamSlug: e, triggerType: "playlist", playlistSlugs: a.split(",") } : h = { teamSlug: e, triggerType: "schedule" };
|
|
12
|
+
const u = t.searchParams.get(O);
|
|
13
|
+
return t.search = t.search.slice(1).split("&").filter((g) => {
|
|
14
|
+
const l = g.split("=", 1)[0];
|
|
15
|
+
return l !== M && l !== O;
|
|
16
16
|
}).join("&"), {
|
|
17
|
-
payload:
|
|
18
|
-
...u &&
|
|
17
|
+
payload: h,
|
|
18
|
+
...u && J.test(u) ? { campaignId: u } : {},
|
|
19
19
|
cleanUrl: t.href
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
let
|
|
23
|
-
function
|
|
24
|
-
return
|
|
22
|
+
let k = !1;
|
|
23
|
+
function ee() {
|
|
24
|
+
return k ? !1 : (k = !0, !0);
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function te(i, e) {
|
|
27
27
|
i.body ? e() : i.addEventListener("DOMContentLoaded", e, { once: !0 });
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
success: { fill: "#1c1d22", glyph: "#fafafc", path:
|
|
31
|
-
info: { fill: "#146eaa", glyph: "#ffffff", path:
|
|
32
|
-
warning: { fill: "#aa4e19", glyph: "#ffffff", path:
|
|
33
|
-
error: { fill: "#c62734", glyph: "#ffffff", path:
|
|
34
|
-
},
|
|
29
|
+
const ie = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='15.55 11.94 120.52 21.28'%3E%3Cpath d='M16.59 33.04L17.42 29.54C18.62 24.54 19.22 21.32 19.22 19.89C19.22 19.68 19.19 19.54 19.12 19.47C19.05 19.4 18.91 19.38 18.7 19.4C18.4 19.47 17.97 19.65 17.42 19.94C16.86 20.23 16.32 20.62 15.79 21.1C15.63 20.9 15.55 20.69 15.55 20.48C15.55 20.27 15.65 20.03 15.86 19.75C16.16 19.38 16.65 18.95 17.33 18.45C18.02 17.95 18.74 17.53 19.5 17.2C20.27 16.86 20.92 16.7 21.48 16.7C21.78 16.7 22 16.79 22.14 16.99C22.28 17.19 22.35 17.5 22.35 17.94C22.35 18.55 22.24 19.42 22.04 20.56C21.83 21.71 21.55 22.88 21.2 24.09C22.34 21.96 23.59 20.19 24.95 18.79C26.32 17.4 27.7 16.7 29.12 16.7C29.79 16.7 30.27 16.87 30.57 17.23C30.87 17.59 31.02 18.14 31.02 18.88C31.02 19.97 30.69 21.7 30.02 24.09C31.13 22.01 32.44 20.25 33.94 18.83C35.44 17.41 36.94 16.7 38.42 16.7C39.11 16.7 39.63 16.88 39.98 17.25C40.33 17.62 40.5 18.16 40.5 18.88C40.5 19.18 40.45 19.62 40.34 20.18C40.24 20.75 40.1 21.37 39.91 22.04L38.42 27.7C38.09 28.92 37.93 29.77 37.93 30.23C37.93 30.48 37.97 30.67 38.05 30.8C38.13 30.93 38.27 30.99 38.45 30.99C38.89 30.99 39.47 30.69 40.17 30.09C40.88 29.49 41.46 28.85 41.92 28.18C42.25 28.44 42.41 28.72 42.41 29.05C42.41 29.26 42.34 29.48 42.2 29.71C41.74 30.5 40.98 31.28 39.93 32.05C38.87 32.82 37.82 33.21 36.75 33.21C36.08 33.21 35.56 33.02 35.17 32.62C34.79 32.23 34.6 31.66 34.6 30.92C34.6 30.3 34.8 29.22 35.19 27.7L36.79 21.55C37 20.74 37.1 20.13 37.1 19.71C37.1 19.2 36.89 18.95 36.48 18.95C35.97 18.95 35.3 19.33 34.46 20.08C33.63 20.83 32.79 21.94 31.93 23.41C31.07 24.88 30.33 26.62 29.71 28.63L28.91 31.27C28.77 31.73 28.59 32.09 28.37 32.33C28.15 32.57 27.82 32.73 27.38 32.8L25.54 33.22L25.37 33.04L26.13 29.67C26.73 27.11 27.19 25.03 27.49 23.44C27.79 21.86 27.94 20.72 27.94 20.03C27.94 19.33 27.72 19.02 27.28 19.02C26.79 19.02 26.17 19.4 25.42 20.15C24.67 20.9 23.89 22 23.1 23.46C22.3 24.92 21.6 26.65 21 28.67L20.2 31.27C20.06 31.71 19.87 32.05 19.63 32.29C19.38 32.54 19.02 32.71 18.53 32.8L16.76 33.22L16.59 33.04L16.59 33.04Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M57.66 17.94C57 17.13 55.99 16.73 54.62 16.73C52.93 16.73 51.31 17.3 49.75 18.43C49.51 18.6 49.28 18.78 49.06 18.97C49.24 19.85 49.39 20.78 49.48 21.74C49.86 21.01 50.3 20.37 50.79 19.82C51.63 18.87 52.5 18.39 53.41 18.39C54.08 18.39 54.55 18.68 54.81 19.24C55.08 19.81 55.21 20.58 55.21 21.55C55.21 23.08 54.97 24.63 54.48 26.19C54 27.75 53.35 29.03 52.54 30.04C51.73 31.04 50.86 31.55 49.94 31.55C49.53 31.55 49.19 31.44 48.9 31.22C48.74 31.9 48.54 32.55 48.31 33.19C48.5 33.2 48.7 33.21 48.9 33.21C50.54 33.21 52.11 32.63 53.61 31.48C55.12 30.32 56.33 28.82 57.26 26.98C58.18 25.14 58.65 23.28 58.65 21.38C58.65 19.9 58.32 18.75 57.66 17.94L57.66 17.94Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M61.84 33.04L62.67 29.54C63.88 24.54 64.48 21.32 64.48 19.89C64.48 19.68 64.44 19.54 64.37 19.47C64.3 19.4 64.17 19.38 63.96 19.4C63.66 19.47 63.23 19.65 62.67 19.94C62.12 20.23 61.57 20.62 61.04 21.1C60.88 20.9 60.8 20.69 60.8 20.48C60.8 20.27 60.9 20.03 61.11 19.75C61.41 19.38 61.9 18.95 62.59 18.45C63.27 17.95 63.99 17.53 64.76 17.2C65.52 16.86 66.18 16.7 66.73 16.7C67.04 16.7 67.26 16.79 67.39 16.99C67.53 17.19 67.6 17.5 67.6 17.94C67.6 18.55 67.5 19.42 67.29 20.56C67.08 21.71 66.8 22.88 66.46 24.09C67.59 21.96 68.84 20.19 70.2 18.79C71.57 17.4 72.96 16.7 74.37 16.7C75.04 16.7 75.53 16.87 75.83 17.23C76.13 17.59 76.28 18.14 76.28 18.88C76.28 19.97 75.94 21.7 75.27 24.09C76.38 22.01 77.69 20.25 79.19 18.83C80.7 17.41 82.19 16.7 83.67 16.7C84.36 16.7 84.89 16.88 85.23 17.25C85.58 17.62 85.75 18.16 85.75 18.88C85.75 19.18 85.7 19.62 85.6 20.18C85.49 20.75 85.35 21.37 85.16 22.04L83.67 27.7C83.35 28.92 83.19 29.77 83.19 30.23C83.19 30.48 83.23 30.67 83.31 30.8C83.39 30.93 83.52 30.99 83.71 30.99C84.15 30.99 84.72 30.69 85.42 30.09C86.13 29.49 86.71 28.85 87.18 28.18C87.5 28.44 87.66 28.72 87.66 29.05C87.66 29.26 87.59 29.48 87.46 29.71C86.99 30.5 86.24 31.28 85.18 32.05C84.13 32.82 83.07 33.21 82.01 33.21C81.34 33.21 80.81 33.02 80.43 32.62C80.05 32.23 79.86 31.66 79.86 30.92C79.86 30.3 80.05 29.22 80.44 27.7L82.04 21.55C82.25 20.74 82.35 20.13 82.35 19.71C82.35 19.2 82.15 18.95 81.73 18.95C81.22 18.95 80.55 19.33 79.72 20.08C78.88 20.83 78.04 21.94 77.18 23.41C76.33 24.88 75.59 26.62 74.96 28.63L74.16 31.27C74.02 31.73 73.85 32.09 73.63 32.33C73.41 32.57 73.08 32.73 72.64 32.8L70.8 33.22L70.62 33.04L71.39 29.67C71.99 27.11 72.44 25.03 72.74 23.44C73.04 21.86 73.19 20.72 73.19 20.03C73.19 19.33 72.97 19.02 72.53 19.02C72.05 19.02 71.43 19.4 70.68 20.15C69.92 20.9 69.15 22 68.35 23.46C67.55 24.92 66.85 26.65 66.25 28.67L65.45 31.27C65.31 31.71 65.12 32.05 64.88 32.29C64.64 32.54 64.27 32.71 63.79 32.8L62.02 33.22L61.84 33.04L61.84 33.04Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M91.01 31.91C90.19 31.04 89.78 29.85 89.78 28.32C89.78 26.47 90.32 24.64 91.41 22.84C92.49 21.03 93.87 19.56 95.54 18.41C97.2 17.27 98.82 16.69 100.4 16.69C101.23 16.69 101.87 16.9 102.31 17.3C102.75 17.71 102.97 18.25 102.97 18.95C102.97 20.08 102.55 21.13 101.72 22.09C100.88 23.05 99.77 23.81 98.37 24.38C96.97 24.95 95.47 25.23 93.87 25.23H93.52C93.25 26.16 93.11 27.05 93.11 27.9C93.11 28.97 93.32 29.79 93.75 30.37C94.18 30.95 94.8 31.24 95.61 31.24C96.51 31.24 97.4 30.91 98.28 30.26C99.16 29.62 99.99 28.69 100.78 27.49C100.96 27.72 101.1 27.91 101.18 28.06C101.26 28.21 101.3 28.39 101.3 28.6C101.3 28.81 101.22 29.06 101.06 29.36C100.78 29.89 100.32 30.46 99.67 31.05C99.02 31.63 98.24 32.14 97.33 32.57C96.41 33 95.43 33.21 94.39 33.21C92.96 33.21 91.83 32.78 91.01 31.91V31.91ZM94.32 23.81C95.43 23.81 96.43 23.58 97.33 23.12C98.22 22.65 98.92 22.08 99.42 21.4C99.93 20.71 100.19 20.05 100.19 19.4C100.19 18.69 99.85 18.33 99.18 18.33C98.3 18.33 97.37 18.85 96.39 19.91C95.41 20.96 94.61 22.25 94.01 23.78C94.08 23.8 94.19 23.81 94.32 23.81L94.32 23.81Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M105.91 33.04L106.78 29.12C107.96 24.08 108.55 21.04 108.55 20.03C108.55 19.82 108.5 19.66 108.4 19.56C108.29 19.45 108.15 19.4 107.96 19.4C107.68 19.4 107.3 19.54 106.82 19.82C106.33 20.1 105.75 20.51 105.08 21.07C105.01 21 104.95 20.89 104.91 20.75C104.86 20.62 104.84 20.5 104.84 20.41C104.84 20.27 104.86 20.13 104.89 19.99C104.93 19.85 105.01 19.7 105.15 19.54C105.43 19.17 105.88 18.76 106.52 18.31C107.16 17.86 107.83 17.47 108.55 17.16C109.27 16.85 109.89 16.69 110.43 16.69C110.79 16.69 111.06 16.79 111.21 16.97C111.36 17.16 111.43 17.47 111.43 17.91C111.43 19.09 111.05 21.2 110.29 24.26C111.42 22.08 112.72 20.28 114.19 18.84C115.66 17.41 117.14 16.69 118.65 16.69C119.37 16.69 119.92 16.88 120.3 17.25C120.68 17.62 120.87 18.14 120.87 18.81C120.87 19.48 120.67 20.57 120.28 22.07L118.72 27.97C118.44 28.99 118.3 29.74 118.3 30.23C118.3 30.71 118.48 30.99 118.82 30.99C119.26 30.99 119.84 30.69 120.54 30.09C121.25 29.49 121.83 28.85 122.29 28.18C122.62 28.43 122.78 28.72 122.78 29.05C122.78 29.26 122.71 29.48 122.57 29.71C122.32 30.17 121.91 30.67 121.34 31.22C120.77 31.76 120.12 32.23 119.39 32.62C118.67 33.02 117.92 33.21 117.16 33.21C116.46 33.21 115.92 33.02 115.54 32.62C115.16 32.23 114.97 31.63 114.97 30.82C114.97 30.15 115.18 29.04 115.59 27.49L117.09 22.14C117.36 21.05 117.5 20.24 117.5 19.71C117.5 19.18 117.32 18.95 116.95 18.95C116.37 18.95 115.65 19.35 114.8 20.15C113.94 20.95 113.08 22.09 112.21 23.58C111.34 25.07 110.63 26.84 110.08 28.87L109.45 31.06C109.31 31.59 109.13 31.98 108.9 32.22C108.67 32.47 108.33 32.65 107.89 32.76L106.09 33.21L105.91 33.04L105.91 33.04Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M126.29 32.28C125.82 31.65 125.59 30.84 125.59 29.85C125.59 29.27 125.7 28.37 125.9 27.16C126.11 25.94 126.47 24.18 126.98 21.87L127.6 18.88H124.52L124.76 17.49L127.99 17.15L130.03 13.12C130.24 12.75 130.43 12.48 130.59 12.32C130.75 12.16 130.95 12.06 131.18 12.01C131.41 11.96 131.76 11.94 132.22 11.94L132.36 12.11L131.28 17.15H136.07L135.9 18.01C135.85 18.36 135.75 18.59 135.6 18.71C135.45 18.82 135.18 18.88 134.79 18.88H130.9L130.24 21.94C129.73 24.34 129.37 26.11 129.17 27.23C128.96 28.35 128.85 29.14 128.85 29.61C128.85 30 128.93 30.29 129.08 30.47C129.23 30.66 129.48 30.75 129.82 30.75C130.42 30.75 131.14 30.5 131.98 30.01C132.81 29.51 133.55 28.89 134.2 28.15C134.57 28.43 134.75 28.69 134.75 28.95C134.75 29.39 134.42 29.95 133.75 30.63C133.07 31.31 132.25 31.91 131.26 32.43C130.28 32.96 129.34 33.22 128.44 33.22C127.47 33.22 126.75 32.9 126.28 32.28L126.29 32.28Z' fill='%23FAFAF9'%3E%3C/path%3E%3C/svg%3E", se = 120.52 / 21.28, ne = 4e3, re = 80, R = ["#f04a34", "#041abe", "#041139", "#1cd4ed", "#b8e070"], oe = 10, ae = 260, le = "M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z", de = "M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z", ce = "M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z", ue = "M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z", H = {
|
|
30
|
+
success: { fill: "#1c1d22", glyph: "#fafafc", path: le },
|
|
31
|
+
info: { fill: "#146eaa", glyph: "#ffffff", path: de },
|
|
32
|
+
warning: { fill: "#aa4e19", glyph: "#ffffff", path: ce },
|
|
33
|
+
error: { fill: "#c62734", glyph: "#ffffff", path: ue }
|
|
34
|
+
}, me = {
|
|
35
35
|
position: "absolute",
|
|
36
36
|
top: "calc(56px + env(safe-area-inset-top, 0px))",
|
|
37
37
|
left: "0",
|
|
@@ -54,7 +54,7 @@ const J = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox=
|
|
|
54
54
|
lineHeight: "20px",
|
|
55
55
|
fontWeight: "400",
|
|
56
56
|
overflowWrap: "anywhere"
|
|
57
|
-
},
|
|
57
|
+
}, he = {
|
|
58
58
|
display: "flex",
|
|
59
59
|
alignItems: "center",
|
|
60
60
|
justifyContent: "center",
|
|
@@ -63,7 +63,7 @@ const J = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox=
|
|
|
63
63
|
height: "28px",
|
|
64
64
|
margin: "2px",
|
|
65
65
|
borderRadius: "50%"
|
|
66
|
-
},
|
|
66
|
+
}, pe = {
|
|
67
67
|
position: "absolute",
|
|
68
68
|
width: "1px",
|
|
69
69
|
height: "1px",
|
|
@@ -78,7 +78,7 @@ function y(i, e) {
|
|
|
78
78
|
const t = document.createElement(i);
|
|
79
79
|
return Object.assign(t.style, e), t;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function fe(i, e) {
|
|
82
82
|
const t = y("div", {
|
|
83
83
|
position: "absolute",
|
|
84
84
|
inset: "0",
|
|
@@ -87,14 +87,14 @@ function ue(i, e) {
|
|
|
87
87
|
zIndex: "1"
|
|
88
88
|
});
|
|
89
89
|
t.setAttribute("aria-hidden", "true"), i.appendChild(t);
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
let r = null, o = null,
|
|
93
|
-
const
|
|
94
|
-
o && clearTimeout(o), o = null, a?.(), a = null, r?.remove(), r = null,
|
|
90
|
+
const s = y("span", pe);
|
|
91
|
+
s.setAttribute("role", "status"), (e.querySelector('[role="dialog"]') ?? e).appendChild(s);
|
|
92
|
+
let r = null, o = null, n = null, a = null;
|
|
93
|
+
const h = () => {
|
|
94
|
+
o && clearTimeout(o), o = null, a?.(), a = null, r?.remove(), r = null, s.textContent = "";
|
|
95
95
|
}, u = (l) => {
|
|
96
96
|
const d = () => {
|
|
97
|
-
a = null,
|
|
97
|
+
a = null, s.textContent = l;
|
|
98
98
|
};
|
|
99
99
|
if (typeof requestAnimationFrame == "function") {
|
|
100
100
|
const c = requestAnimationFrame(d);
|
|
@@ -103,26 +103,26 @@ function ue(i, e) {
|
|
|
103
103
|
const c = setTimeout(d, 0);
|
|
104
104
|
a = () => clearTimeout(c);
|
|
105
105
|
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
const l = e.getBoundingClientRect(), d = Math.max(0, l.top -
|
|
109
|
-
for (let c = 0; c <
|
|
110
|
-
const
|
|
106
|
+
}, g = () => {
|
|
107
|
+
n = null;
|
|
108
|
+
const l = e.getBoundingClientRect(), d = Math.max(0, l.top - oe);
|
|
109
|
+
for (let c = 0; c < re; c++) {
|
|
110
|
+
const m = 4 + Math.random() * 6, f = y("span", {
|
|
111
111
|
position: "absolute",
|
|
112
112
|
left: `${l.left + Math.random() * l.width}px`,
|
|
113
113
|
top: `${d}px`,
|
|
114
|
-
width: `${
|
|
115
|
-
height: `${
|
|
114
|
+
width: `${m}px`,
|
|
115
|
+
height: `${m * (0.5 + Math.random())}px`,
|
|
116
116
|
borderRadius: c % 3 === 0 ? "50%" : "1px",
|
|
117
|
-
backgroundColor:
|
|
117
|
+
backgroundColor: R[c % R.length]
|
|
118
118
|
});
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
119
|
+
f.setAttribute("data-moment-confetti", ""), t.appendChild(f);
|
|
120
|
+
const v = d * (0.35 + Math.random() * 0.55), b = (Math.random() - 0.5) * 120, p = (Math.random() - 0.5) * 1080;
|
|
121
|
+
f.animate(
|
|
122
122
|
[
|
|
123
123
|
{ transform: "translate(0px, 0px) rotate(0deg)", opacity: 1 },
|
|
124
124
|
{ opacity: 1, offset: 0.6 },
|
|
125
|
-
{ transform: `translate(${
|
|
125
|
+
{ transform: `translate(${b}px, ${-v}px) rotate(${p}deg)`, opacity: 0 }
|
|
126
126
|
],
|
|
127
127
|
{
|
|
128
128
|
duration: 1200 + Math.random() * 800,
|
|
@@ -130,42 +130,42 @@ function ue(i, e) {
|
|
|
130
130
|
easing: "cubic-bezier(0.2, 0.6, 0.35, 1)",
|
|
131
131
|
fill: "both"
|
|
132
132
|
}
|
|
133
|
-
).onfinish = () =>
|
|
133
|
+
).onfinish = () => f.remove();
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
return {
|
|
137
137
|
celebrate() {
|
|
138
|
-
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches || typeof t.animate != "function" ||
|
|
138
|
+
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches || typeof t.animate != "function" || n || (n = setTimeout(g, ae));
|
|
139
139
|
},
|
|
140
140
|
toast(l, d = "success") {
|
|
141
|
-
|
|
142
|
-
const c =
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
141
|
+
h();
|
|
142
|
+
const c = H[Object.hasOwn(H, d) ? d : "success"], m = y("span", { ...he, backgroundColor: c.fill, color: c.glyph });
|
|
143
|
+
m.innerHTML = `<svg width="16" height="16" viewBox="0 0 256 256" fill="currentColor" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="${c.path}"/></svg>`;
|
|
144
|
+
const f = y("span", { minWidth: "0" });
|
|
145
|
+
f.textContent = l, r = y("div", me), r.setAttribute("data-moment-toast", ""), r.appendChild(m), r.appendChild(f), t.appendChild(r), u(l), o = setTimeout(h, ne);
|
|
146
146
|
},
|
|
147
147
|
destroy() {
|
|
148
|
-
|
|
148
|
+
n && clearTimeout(n), n = null, h(), t.remove(), s.remove();
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function G() {
|
|
153
153
|
if (typeof window > "u") return "";
|
|
154
154
|
const i = window.location.origin, e = i === "null" ? self.origin : i;
|
|
155
155
|
return e === "null" && console.error(
|
|
156
156
|
'[MomentSdk] This page has an opaque origin ("null"), so Moment Live cannot message it and calendar sync will not work. Serve the page over http(s), and give a sandboxed iframe allow-same-origin.'
|
|
157
157
|
), e;
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function ge(i, e, t = G(), s) {
|
|
160
160
|
if (e.triggerType === "schedule") {
|
|
161
161
|
const o = new URLSearchParams();
|
|
162
|
-
return o.set("teamSlug", e.teamSlug), o.set("returnOrigin", t), o.set("embed", "1"), o.set("sdkVersion", "0.9.0-dev.
|
|
162
|
+
return o.set("teamSlug", e.teamSlug), o.set("returnOrigin", t), o.set("embed", "1"), o.set("sdkVersion", "0.9.0-dev.51"), s && (o.set("entry", "link"), s.campaignId && o.set("campaignId", s.campaignId)), `${i}/en/embed/schedule?${o.toString()}`;
|
|
163
163
|
}
|
|
164
164
|
const r = new URLSearchParams();
|
|
165
|
-
return r.set("teamSlug", e.teamSlug), e.momentSlug && r.set("momentSlug", e.momentSlug), e.listSlug && r.set("listSlug", e.listSlug), r.set("triggerType", e.triggerType), e.ids?.length && r.set("ids", e.ids.join(",")), e.playlistSlugs?.length && r.set("playlistSlugs", e.playlistSlugs.join(",")), e.calendar && r.set("calendar", e.calendar), e.apiSourceId && r.set("subscriptionId", e.apiSourceId), e.externalEventId && r.set("externalId", e.externalEventId), e.externalEventIdPrefix && !e.externalEventId && r.set("externalIdPrefix", e.externalEventIdPrefix), r.set("returnOrigin", t), r.set("embed", "1"), r.set("sdkVersion", "0.9.0-dev.
|
|
165
|
+
return r.set("teamSlug", e.teamSlug), e.momentSlug && r.set("momentSlug", e.momentSlug), e.listSlug && r.set("listSlug", e.listSlug), r.set("triggerType", e.triggerType), e.ids?.length && r.set("ids", e.ids.join(",")), e.playlistSlugs?.length && r.set("playlistSlugs", e.playlistSlugs.join(",")), e.calendar && r.set("calendar", e.calendar), e.apiSourceId && r.set("subscriptionId", e.apiSourceId), e.externalEventId && r.set("externalId", e.externalEventId), e.externalEventIdPrefix && !e.externalEventId && r.set("externalIdPrefix", e.externalEventIdPrefix), r.set("returnOrigin", t), r.set("embed", "1"), r.set("sdkVersion", "0.9.0-dev.51"), s && (r.set("entry", "link"), s.campaignId && r.set("campaignId", s.campaignId)), `${i}/en/embed/sync?${r.toString()}`;
|
|
166
166
|
}
|
|
167
|
-
const
|
|
168
|
-
class
|
|
167
|
+
const B = 500, P = 700, Ce = 500;
|
|
168
|
+
class be {
|
|
169
169
|
popup = null;
|
|
170
170
|
pollTimer = null;
|
|
171
171
|
messageHandler = null;
|
|
@@ -179,19 +179,19 @@ class he {
|
|
|
179
179
|
*/
|
|
180
180
|
open(e) {
|
|
181
181
|
this.cleanup(), this.resultReceived = !1;
|
|
182
|
-
const t = this.buildPopupUrl(e),
|
|
182
|
+
const t = this.buildPopupUrl(e), s = Math.round(window.screenX + (window.outerWidth - B) / 2), r = Math.round(window.screenY + (window.outerHeight - P) / 2);
|
|
183
183
|
if (this.popup = window.open(
|
|
184
184
|
t,
|
|
185
185
|
"moment-oauth-popup",
|
|
186
|
-
`width=${
|
|
186
|
+
`width=${B},height=${P},left=${s},top=${r},menubar=no,toolbar=no,location=yes,status=no`
|
|
187
187
|
), !this.popup || this.popup.closed) {
|
|
188
188
|
this.sendStatusToIframe("popup-blocked"), this.opts.onPopupBlocked();
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
191
|
this.sendStatusToIframe("popup-opened"), this.startPolling(), this.messageHandler = (o) => {
|
|
192
192
|
if (o.origin !== this.opts.liveOrigin || o.source !== this.popup) return;
|
|
193
|
-
const
|
|
194
|
-
!
|
|
193
|
+
const n = o.data;
|
|
194
|
+
!n || typeof n != "object" || n.source !== "moment-live-embed" || n.type !== "moment.embed.result" || (this.resultReceived = !0, this.sendStatusToIframe("completed"), this.opts.iframeWindow && this.opts.iframeWindow.postMessage(n, this.opts.liveOrigin), e.intent !== "connect" && this.opts.onResult(n), this.cleanup());
|
|
195
195
|
}, window.addEventListener("message", this.messageHandler);
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
@@ -206,13 +206,13 @@ class he {
|
|
|
206
206
|
this.popup = null;
|
|
207
207
|
}
|
|
208
208
|
buildPopupUrl(e) {
|
|
209
|
-
const t =
|
|
209
|
+
const t = ye(e, G());
|
|
210
210
|
return this.opts.campaignId && t.set("campaignId", this.opts.campaignId), `${this.opts.liveBaseUrl}/en/embed/oauth-popup?${t.toString()}`;
|
|
211
211
|
}
|
|
212
212
|
startPolling() {
|
|
213
213
|
this.pollTimer = setInterval(() => {
|
|
214
214
|
(!this.popup || this.popup.closed) && (this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null), this.resultReceived || (this.sendStatusToIframe("popup-closed"), this.opts.onPopupClosed()), this.cleanup());
|
|
215
|
-
},
|
|
215
|
+
}, Ce);
|
|
216
216
|
}
|
|
217
217
|
sendStatusToIframe(e) {
|
|
218
218
|
if (!this.opts.iframeWindow) return;
|
|
@@ -224,7 +224,7 @@ class he {
|
|
|
224
224
|
this.opts.iframeWindow.postMessage(t, this.opts.liveOrigin);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function ye(i, e) {
|
|
228
228
|
const t = new URLSearchParams({
|
|
229
229
|
provider: i.provider,
|
|
230
230
|
teamSlug: i.teamSlug,
|
|
@@ -233,16 +233,16 @@ function ge(i, e) {
|
|
|
233
233
|
returnOrigin: e
|
|
234
234
|
});
|
|
235
235
|
i.subscriptionType && t.set("subscriptionType", i.subscriptionType);
|
|
236
|
-
const
|
|
236
|
+
const s = {
|
|
237
237
|
scheduleMomentIds: i.scheduleMomentIds,
|
|
238
238
|
schedulePlaylistIds: i.schedulePlaylistIds,
|
|
239
239
|
scheduleListIds: i.scheduleListIds
|
|
240
240
|
};
|
|
241
|
-
for (const [r, o] of Object.entries(
|
|
241
|
+
for (const [r, o] of Object.entries(s))
|
|
242
242
|
o?.length && t.set(r, o.join(","));
|
|
243
|
-
return i.addons?.length && t.set("addons", i.addons.join(",")), t;
|
|
243
|
+
return i.addons?.length && t.set("addons", i.addons.join(",")), i.intent === "connect" && t.set("intent", "connect"), t;
|
|
244
244
|
}
|
|
245
|
-
const
|
|
245
|
+
const F = "moment-sdk-styles", z = "moment-sdk-close", I = "moment-sdk-tray", A = "moment-sdk-closing", ve = `
|
|
246
246
|
:where(.moment-sync-trigger) {
|
|
247
247
|
background-color: #1c1917;
|
|
248
248
|
color: #ffffff;
|
|
@@ -267,7 +267,7 @@ const k = "moment-sdk-styles", U = "moment-sdk-close", $ = "moment-sdk-tray", fe
|
|
|
267
267
|
outline-offset: 2px;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
.${
|
|
270
|
+
.${z}:focus-visible {
|
|
271
271
|
outline: 2px solid #ffffff;
|
|
272
272
|
outline-offset: 0;
|
|
273
273
|
box-shadow: 0 0 0 4px #121316;
|
|
@@ -278,41 +278,68 @@ const k = "moment-sdk-styles", U = "moment-sdk-close", $ = "moment-sdk-tray", fe
|
|
|
278
278
|
to { transform: translateY(0); }
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
@keyframes moment-sdk-tray-out {
|
|
282
|
+
from { transform: translateY(0); }
|
|
283
|
+
to { transform: translateY(100%); }
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
@keyframes moment-sdk-fade-out {
|
|
287
|
+
to { opacity: 0; }
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/* The dim fades by its colour: an overlay below opacity 1 would cut the glass off from the page
|
|
291
|
+
behind it, and the sheet would turn sharp and see-through as it left. */
|
|
292
|
+
@keyframes moment-sdk-dim-out {
|
|
293
|
+
to { background-color: transparent; }
|
|
294
|
+
}
|
|
295
|
+
|
|
281
296
|
@media (prefers-reduced-motion: no-preference) {
|
|
282
|
-
.${
|
|
297
|
+
.${I} {
|
|
283
298
|
animation: moment-sdk-tray-in 0.35s cubic-bezier(0.32, 0.72, 0, 1);
|
|
284
299
|
}
|
|
300
|
+
|
|
301
|
+
.${A} {
|
|
302
|
+
animation: moment-sdk-dim-out 0.25s ease-in forwards;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.${A} > * {
|
|
306
|
+
animation: moment-sdk-fade-out 0.25s ease-in forwards;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.${A} .${I} {
|
|
310
|
+
animation: moment-sdk-tray-out 0.25s cubic-bezier(0.32, 0.72, 0, 1) forwards;
|
|
311
|
+
}
|
|
285
312
|
}
|
|
286
313
|
`;
|
|
287
|
-
function
|
|
288
|
-
if (typeof document > "u" || document.getElementById(
|
|
314
|
+
function Te() {
|
|
315
|
+
if (typeof document > "u" || document.getElementById(F)) return;
|
|
289
316
|
const i = document.createElement("style");
|
|
290
|
-
i.id =
|
|
317
|
+
i.id = F, i.textContent = ve, document.head.appendChild(i);
|
|
291
318
|
}
|
|
292
|
-
function
|
|
319
|
+
function xe(i) {
|
|
293
320
|
return typeof i == "string" && i.startsWith("webcal://");
|
|
294
321
|
}
|
|
295
|
-
function
|
|
322
|
+
function Ae(i) {
|
|
296
323
|
return !i || i.closed ? "blocked" : "opened";
|
|
297
324
|
}
|
|
298
|
-
const
|
|
299
|
-
backgroundColor:
|
|
325
|
+
const we = 1024, L = 600, Ee = 400, Se = 40, D = 80, N = 90, Le = 420, Ie = 520, U = 48, K = "#0d0d0d", w = "#121316", _e = {
|
|
326
|
+
backgroundColor: K,
|
|
300
327
|
boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
|
301
328
|
backdropFilter: "none",
|
|
302
329
|
webkitBackdropFilter: "none"
|
|
303
|
-
},
|
|
330
|
+
}, Y = "inset 0 0.5px 0.75px rgb(255 255 255 / 0.6)", Me = "inset 0 -0.5px 0.75px rgb(255 255 255 / 0.3)", V = [
|
|
304
331
|
"0 0 0 0.5px #9c9c9c",
|
|
305
332
|
"0 4px 8px 0 #0000001f",
|
|
306
333
|
"0 12px 32px 0 #00000047"
|
|
307
|
-
],
|
|
334
|
+
], Z = {
|
|
308
335
|
backgroundColor: "rgb(19 19 19 / 0.812)",
|
|
309
336
|
backdropFilter: "blur(14px)",
|
|
310
337
|
webkitBackdropFilter: "blur(14px)",
|
|
311
|
-
boxShadow: [
|
|
312
|
-
},
|
|
313
|
-
...
|
|
314
|
-
boxShadow: [
|
|
315
|
-
},
|
|
338
|
+
boxShadow: [Y, Me, ...V].join(", ")
|
|
339
|
+
}, Oe = {
|
|
340
|
+
...Z,
|
|
341
|
+
boxShadow: [Y, ...V].join(", ")
|
|
342
|
+
}, x = 32, $ = "height 0.25s cubic-bezier(0.32, 0.72, 0, 1)", ke = 2e3, Re = 500, He = 400, E = 12, Be = "2147483647", Pe = 'button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex="-1"])', q = "#38393B", Fe = "#4B4B4E", De = {
|
|
316
343
|
position: "absolute",
|
|
317
344
|
top: "16px",
|
|
318
345
|
right: "16px",
|
|
@@ -322,23 +349,23 @@ const ve = 1024, w = 600, xe = 400, Ae = 40, H = 80, P = 90, we = 420, Te = 520,
|
|
|
322
349
|
padding: "0",
|
|
323
350
|
border: "none",
|
|
324
351
|
borderRadius: "50%",
|
|
325
|
-
backgroundColor:
|
|
352
|
+
backgroundColor: q,
|
|
326
353
|
color: "#F5F5F5",
|
|
327
354
|
cursor: "pointer",
|
|
328
355
|
display: "flex",
|
|
329
356
|
alignItems: "center",
|
|
330
357
|
justifyContent: "center"
|
|
331
358
|
};
|
|
332
|
-
function
|
|
333
|
-
const
|
|
334
|
-
showFooter: !
|
|
335
|
-
material:
|
|
336
|
-
wrapperMaterial:
|
|
337
|
-
card: { backgroundColor:
|
|
338
|
-
iframe:
|
|
339
|
-
},
|
|
359
|
+
function Ne(i, e, t = E, s = "v1", r = 0, o = w) {
|
|
360
|
+
const n = s === "v2", a = i < we, u = {
|
|
361
|
+
showFooter: !n,
|
|
362
|
+
material: n ? "glass" : "solid",
|
|
363
|
+
wrapperMaterial: n ? a ? Oe : Z : _e,
|
|
364
|
+
card: { backgroundColor: n ? "transparent" : o },
|
|
365
|
+
iframe: n ? { background: "transparent", colorScheme: "dark" } : { background: "", colorScheme: "" }
|
|
366
|
+
}, g = n ? "rgba(0, 0, 0, 0.4)" : "rgba(0, 0, 0, 0.5)", l = n ? E : t, d = `${l}px ${l}px 0px 0px`;
|
|
340
367
|
if (a) {
|
|
341
|
-
const
|
|
368
|
+
const m = n ? e - U - r : Math.floor(e * N / 100) - x;
|
|
342
369
|
return {
|
|
343
370
|
isTray: !0,
|
|
344
371
|
// No blur: iPhone Safari tints its status bar and toolbar from the page, and over a blurred
|
|
@@ -347,12 +374,12 @@ function Re(i, e, t = x, n = "v1", r = 0, o = v) {
|
|
|
347
374
|
alignItems: "flex-end",
|
|
348
375
|
padding: "0",
|
|
349
376
|
backdropFilter: "none",
|
|
350
|
-
backgroundColor:
|
|
377
|
+
backgroundColor: g
|
|
351
378
|
},
|
|
352
379
|
wrapper: {
|
|
353
380
|
// The modal's width: at full width on a tablet the embed's pills and rows stretched. Only
|
|
354
381
|
// once that leaves 40px each side: at 600–679px it left a sliver of the page down each side.
|
|
355
|
-
maxWidth: i <
|
|
382
|
+
maxWidth: i < L + 2 * Se ? "none" : `${L}px`,
|
|
356
383
|
minWidth: "0",
|
|
357
384
|
borderRadius: d,
|
|
358
385
|
paddingBottom: "env(safe-area-inset-bottom, 0px)"
|
|
@@ -360,52 +387,55 @@ function Re(i, e, t = x, n = "v1", r = 0, o = v) {
|
|
|
360
387
|
container: {
|
|
361
388
|
// ponytail: no vh fallback for browsers without dvh (Safari < 15.4); the iframe cap still
|
|
362
389
|
// holds there.
|
|
363
|
-
maxHeight:
|
|
390
|
+
maxHeight: n ? `calc(100dvh - ${U}px - env(safe-area-inset-bottom, 0px))` : `calc(${N}dvh - ${x}px)`,
|
|
364
391
|
borderRadius: d
|
|
365
392
|
},
|
|
366
|
-
iframeMaxHeight:
|
|
367
|
-
iframeOpeningHeight: Math.min(
|
|
393
|
+
iframeMaxHeight: m,
|
|
394
|
+
iframeOpeningHeight: Math.min(Le, m),
|
|
368
395
|
...u
|
|
369
396
|
};
|
|
370
397
|
}
|
|
371
|
-
const c = e -
|
|
398
|
+
const c = e - D;
|
|
372
399
|
return {
|
|
373
400
|
isTray: !1,
|
|
374
401
|
overlay: {
|
|
375
402
|
alignItems: "center",
|
|
376
403
|
padding: "16px",
|
|
377
404
|
// Roman (Q1): under v2 the page behind stays sharp; only the dim layer covers it.
|
|
378
|
-
backdropFilter:
|
|
379
|
-
backgroundColor:
|
|
405
|
+
backdropFilter: n ? "none" : "blur(2px)",
|
|
406
|
+
backgroundColor: g
|
|
380
407
|
},
|
|
381
408
|
wrapper: {
|
|
382
|
-
maxWidth: `${
|
|
383
|
-
minWidth: `${
|
|
409
|
+
maxWidth: `${L}px`,
|
|
410
|
+
minWidth: `${Ee}px`,
|
|
384
411
|
borderRadius: `${l}px`,
|
|
385
412
|
paddingBottom: "0"
|
|
386
413
|
},
|
|
387
414
|
container: {
|
|
388
|
-
maxHeight: `calc(100vh - ${
|
|
415
|
+
maxHeight: `calc(100vh - ${D}px)`,
|
|
389
416
|
borderRadius: d
|
|
390
417
|
},
|
|
391
418
|
iframeMaxHeight: c,
|
|
392
|
-
iframeOpeningHeight: Math.min(
|
|
419
|
+
iframeOpeningHeight: Math.min(Ie, c),
|
|
393
420
|
...u
|
|
394
421
|
};
|
|
395
422
|
}
|
|
396
|
-
function
|
|
423
|
+
function W(i, e) {
|
|
397
424
|
return Math.min(i, e);
|
|
398
425
|
}
|
|
399
|
-
function
|
|
426
|
+
function Ue(i) {
|
|
400
427
|
return i.triggerType !== "schedule" && i.keepOpen !== !0;
|
|
401
428
|
}
|
|
402
|
-
const
|
|
403
|
-
function
|
|
404
|
-
const e = {
|
|
405
|
-
|
|
429
|
+
const $e = 32;
|
|
430
|
+
function We(i) {
|
|
431
|
+
const e = {
|
|
432
|
+
hideCloseButton: i.closeControl === "embed",
|
|
433
|
+
dismissByEmbed: i.dismiss === "embed"
|
|
434
|
+
};
|
|
435
|
+
return typeof i.borderRadius == "number" && Number.isFinite(i.borderRadius) && (e.cardRadius = Math.max(0, Math.min(i.borderRadius, $e))), typeof i.surface == "string" && i.surface !== "" && (e.surface = i.surface), (i.design === "v1" || i.design === "v2") && (e.design = i.design), e;
|
|
406
436
|
}
|
|
407
|
-
const
|
|
408
|
-
class
|
|
437
|
+
const je = ".moment-sync-trigger", Ge = 6, j = 60, ze = "rgba(255, 255, 255, 0.216)", Ke = "https://live.dev.momentco.ai";
|
|
438
|
+
class Ye {
|
|
409
439
|
opts;
|
|
410
440
|
liveBaseUrl;
|
|
411
441
|
liveOrigin;
|
|
@@ -426,13 +456,22 @@ class Ue {
|
|
|
426
456
|
previousFocusedElement = null;
|
|
427
457
|
previousBodyOverflow = "";
|
|
428
458
|
didManageBodyOverflow = !1;
|
|
459
|
+
previousBodyPaddingRight = "";
|
|
460
|
+
didManageBodyPadding = !1;
|
|
429
461
|
closeTimer = null;
|
|
462
|
+
/** Whether the frame is showing: from the embed's first theme, or the reveal cap. */
|
|
463
|
+
revealed = !1;
|
|
464
|
+
revealTimer = null;
|
|
465
|
+
/** A dismissal posted to the embed and not yet acknowledged: it closes the sheet when it fires. */
|
|
466
|
+
dismissAckTimer = null;
|
|
430
467
|
// The card radius the frame is laid out with: the default until a theme hint sends the brand's.
|
|
431
|
-
cardRadius =
|
|
468
|
+
cardRadius = E;
|
|
432
469
|
/** The frame the embed last asked for: `v2` (glass) or `v1` (the 0.8.0 look). */
|
|
433
470
|
design = "v1";
|
|
434
471
|
/** The card colour the embed last sent, kept through a v2 sheet so v1 gets it back. */
|
|
435
|
-
surface =
|
|
472
|
+
surface = w;
|
|
473
|
+
/** The embed sent `dismiss: 'embed'` this open; it counts only while the frame is v2. */
|
|
474
|
+
dismissByEmbed = !1;
|
|
436
475
|
/** The height the embed last asked for, so a re-cap after a resize can grow back to it. */
|
|
437
476
|
lastRequestedHeight = null;
|
|
438
477
|
footer = null;
|
|
@@ -444,15 +483,15 @@ class Ue {
|
|
|
444
483
|
closeReported = !1;
|
|
445
484
|
constructor(e) {
|
|
446
485
|
this.opts = {
|
|
447
|
-
triggerSelector:
|
|
486
|
+
triggerSelector: je,
|
|
448
487
|
...e
|
|
449
|
-
}, this.liveBaseUrl =
|
|
488
|
+
}, this.liveBaseUrl = Ke;
|
|
450
489
|
try {
|
|
451
490
|
this.liveOrigin = new URL(this.liveBaseUrl).origin;
|
|
452
491
|
} catch {
|
|
453
492
|
throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`);
|
|
454
493
|
}
|
|
455
|
-
|
|
494
|
+
Te(), this.bindTriggers(), this.emitAnalytics("embed.init"), this.opts.autoOpen && this.autoOpenFromUrl(this.opts.autoOpen.teamSlug);
|
|
456
495
|
}
|
|
457
496
|
/**
|
|
458
497
|
* Programmatically open the sync modal.
|
|
@@ -481,34 +520,35 @@ class Ue {
|
|
|
481
520
|
// ── Private: opening ──────────────────────────────────────────────
|
|
482
521
|
/** `open()`, plus the link when the sheet opens from the page URL. */
|
|
483
522
|
openWith(e, t) {
|
|
523
|
+
if (this.overlay && !this.revealed) return;
|
|
484
524
|
e.externalEventId && e.externalEventIdPrefix && console.warn(
|
|
485
525
|
"[MomentSdk] Both externalEventId and externalEventIdPrefix provided; using externalEventId only."
|
|
486
526
|
);
|
|
487
|
-
const
|
|
527
|
+
const s = this.scopeOpenPayload(e);
|
|
488
528
|
this.emitAnalytics("embed.open", {
|
|
489
|
-
teamSlug:
|
|
490
|
-
triggerType:
|
|
529
|
+
teamSlug: s.teamSlug,
|
|
530
|
+
triggerType: s.triggerType,
|
|
491
531
|
...t ? { triggerSource: "url" } : {}
|
|
492
|
-
}), this.createModal(
|
|
532
|
+
}), this.createModal(s, t);
|
|
493
533
|
}
|
|
494
534
|
/**
|
|
495
535
|
* Open the sheet from the page URL's `moment_sync`, once per page load, then drop the link's
|
|
496
536
|
* params from the address bar so a reload doesn't reopen it.
|
|
497
537
|
*/
|
|
498
538
|
autoOpenFromUrl(e) {
|
|
499
|
-
if (!
|
|
500
|
-
const t =
|
|
501
|
-
t &&
|
|
539
|
+
if (!ee()) return;
|
|
540
|
+
const t = Q(window.location.href, e);
|
|
541
|
+
t && te(document, () => {
|
|
502
542
|
this.openWith(t.payload, t), history.replaceState(history.state, "", t.cleanUrl);
|
|
503
543
|
});
|
|
504
544
|
}
|
|
505
545
|
// ── Private: trigger binding ──────────────────────────────────────
|
|
506
546
|
bindTriggers() {
|
|
507
547
|
document.querySelectorAll(this.opts.triggerSelector).forEach((t) => {
|
|
508
|
-
const
|
|
548
|
+
const s = (o) => {
|
|
509
549
|
o.preventDefault(), this.handleTriggerClick(t);
|
|
510
550
|
}, r = this.boundClickHandlers.get(t);
|
|
511
|
-
r && t.removeEventListener("click", r), t.addEventListener("click",
|
|
551
|
+
r && t.removeEventListener("click", r), t.addEventListener("click", s), this.boundClickHandlers.set(t, s);
|
|
512
552
|
});
|
|
513
553
|
}
|
|
514
554
|
unbindTriggers() {
|
|
@@ -517,38 +557,38 @@ class Ue {
|
|
|
517
557
|
}), this.boundClickHandlers.clear();
|
|
518
558
|
}
|
|
519
559
|
handleTriggerClick(e) {
|
|
520
|
-
const t = e.getAttribute("data-moment-team-slug") ?? "",
|
|
521
|
-
let
|
|
522
|
-
o != null && o !== "" && (o === "moment" || o === "list" || o === "team" || o === "brand-playlist" || o === "playlist" || o === "schedule" ?
|
|
560
|
+
const t = e.getAttribute("data-moment-team-slug") ?? "", s = e.getAttribute("data-moment-slug") ?? void 0, r = e.getAttribute("data-moment-list-slug") ?? void 0, o = e.getAttribute("data-moment-trigger-type");
|
|
561
|
+
let n = "moment";
|
|
562
|
+
o != null && o !== "" && (o === "moment" || o === "list" || o === "team" || o === "brand-playlist" || o === "playlist" || o === "schedule" ? n = o : console.warn(
|
|
523
563
|
"[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",
|
|
524
564
|
o
|
|
525
565
|
));
|
|
526
|
-
const a = e.getAttribute("data-moment-ids") ?? e.getAttribute("data-moment-game-id") ?? "",
|
|
566
|
+
const a = e.getAttribute("data-moment-ids") ?? e.getAttribute("data-moment-game-id") ?? "", h = a ? a.split(",").filter(Boolean) : [], u = e.getAttribute("data-moment-playlist-slugs") ?? "", g = u ? u.split(",").map((b) => b.trim()).filter(Boolean) : [], l = e.getAttribute("data-moment-calendar");
|
|
527
567
|
let d;
|
|
528
568
|
l != null && l !== "" && (l === "google" || l === "outlook" ? d = l : console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:", l));
|
|
529
|
-
const c = e.getAttribute("data-api-source-id") ?? void 0,
|
|
530
|
-
if (
|
|
569
|
+
const c = e.getAttribute("data-api-source-id") ?? void 0, m = e.getAttribute("data-external-event-id") ?? void 0, f = e.getAttribute("data-external-event-id-prefix") ?? void 0;
|
|
570
|
+
if (m && f && console.warn(
|
|
531
571
|
"[MomentSdk] Both data-external-event-id and data-external-event-id-prefix are set; using data-external-event-id only."
|
|
532
572
|
), !t) {
|
|
533
573
|
console.warn("[MomentSdk] Missing data-moment-team-slug on trigger element");
|
|
534
574
|
return;
|
|
535
575
|
}
|
|
536
|
-
const
|
|
576
|
+
const v = n === "team" || n === "brand-playlist" || n === "playlist" || n === "schedule";
|
|
537
577
|
this.emitAnalytics("embed.trigger.click", {
|
|
538
578
|
teamSlug: t,
|
|
539
|
-
triggerType:
|
|
540
|
-
momentIds:
|
|
579
|
+
triggerType: n,
|
|
580
|
+
momentIds: v ? [] : h
|
|
541
581
|
}), this.open({
|
|
542
582
|
teamSlug: t,
|
|
543
|
-
momentSlug:
|
|
583
|
+
momentSlug: s,
|
|
544
584
|
listSlug: r,
|
|
545
|
-
triggerType:
|
|
546
|
-
ids:
|
|
547
|
-
playlistSlugs:
|
|
585
|
+
triggerType: n,
|
|
586
|
+
ids: h,
|
|
587
|
+
playlistSlugs: g,
|
|
548
588
|
calendar: d ?? void 0,
|
|
549
589
|
apiSourceId: c,
|
|
550
|
-
externalEventId:
|
|
551
|
-
externalEventIdPrefix:
|
|
590
|
+
externalEventId: f && !m ? void 0 : m,
|
|
591
|
+
externalEventIdPrefix: m ? void 0 : f
|
|
552
592
|
});
|
|
553
593
|
}
|
|
554
594
|
/** Drop moment/list/source scoping for brand-level subscription triggers. */
|
|
@@ -570,19 +610,22 @@ class Ue {
|
|
|
570
610
|
// ── Private: modal creation ───────────────────────────────────────
|
|
571
611
|
createModal(e, t) {
|
|
572
612
|
this.cleanup(), this.previousFocusedElement = document.activeElement || null, this.activePayload = e, this.activeCampaignId = t?.campaignId;
|
|
573
|
-
const
|
|
613
|
+
const s = this.buildIframeUrl(e, t);
|
|
574
614
|
this.overlay = document.createElement("div"), this.overlay.setAttribute("role", "presentation"), Object.assign(this.overlay.style, {
|
|
575
615
|
position: "fixed",
|
|
576
616
|
inset: "0",
|
|
577
|
-
zIndex:
|
|
617
|
+
zIndex: Be,
|
|
578
618
|
display: "flex",
|
|
579
|
-
justifyContent: "center"
|
|
619
|
+
justifyContent: "center",
|
|
580
620
|
// backgroundColor comes from the layout: 50%, or 40% for a v2 sheet.
|
|
581
|
-
|
|
582
|
-
|
|
621
|
+
// Hidden until the embed's first theme (or the cap), so the sheet shows once, in the look
|
|
622
|
+
// the embed asked for. `visibility`, not `opacity`: a hidden sheet takes no taps or focus.
|
|
623
|
+
visibility: "hidden"
|
|
624
|
+
}), this.overlay.addEventListener("click", (p) => {
|
|
625
|
+
p.target === this.overlay && this.requestDismiss();
|
|
583
626
|
});
|
|
584
|
-
const r = (
|
|
585
|
-
|
|
627
|
+
const r = (p) => {
|
|
628
|
+
p.key === "Escape" && this.requestDismiss();
|
|
586
629
|
};
|
|
587
630
|
document.addEventListener("keydown", r);
|
|
588
631
|
const o = document.createElement("div");
|
|
@@ -594,20 +637,20 @@ class Ue {
|
|
|
594
637
|
// smoothly instead of snapping.
|
|
595
638
|
transition: "border-radius 0.3s ease",
|
|
596
639
|
overflow: "hidden",
|
|
597
|
-
backgroundColor:
|
|
640
|
+
backgroundColor: K,
|
|
598
641
|
boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
|
599
642
|
display: "flex",
|
|
600
643
|
flexDirection: "column"
|
|
601
644
|
});
|
|
602
|
-
const
|
|
603
|
-
|
|
645
|
+
const n = document.createElement("div");
|
|
646
|
+
n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), n.setAttribute("aria-label", "Calendar sync modal"), n.tabIndex = -1, Object.assign(n.style, {
|
|
604
647
|
position: "relative",
|
|
605
648
|
width: "100%",
|
|
606
649
|
transition: "border-radius 0.3s ease",
|
|
607
650
|
overflow: "auto",
|
|
608
651
|
// The sheet colour Live's embeds paint, so the card never flashes white before the
|
|
609
652
|
// embed's theme (and its own `surface`) arrives.
|
|
610
|
-
backgroundColor:
|
|
653
|
+
backgroundColor: w,
|
|
611
654
|
// `tabIndex = -1` above makes this a programmatic focus target for the
|
|
612
655
|
// focus trap, never a Tab stop — but browsers still draw their platform
|
|
613
656
|
// focus ring (blue on stock macOS/Windows) around the whole card when we
|
|
@@ -616,13 +659,13 @@ class Ue {
|
|
|
616
659
|
outline: "none"
|
|
617
660
|
});
|
|
618
661
|
const a = document.createElement("button");
|
|
619
|
-
a.type = "button", a.className =
|
|
620
|
-
a.style.backgroundColor =
|
|
662
|
+
a.type = "button", a.className = z, a.innerHTML = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.75 5.25 5.25 18.75M5.25 5.25l13.5 13.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>', a.setAttribute("aria-label", "Close"), Object.assign(a.style, De), a.addEventListener("mouseenter", () => {
|
|
663
|
+
a.style.backgroundColor = Fe;
|
|
621
664
|
}), a.addEventListener("mouseleave", () => {
|
|
622
|
-
a.style.backgroundColor =
|
|
665
|
+
a.style.backgroundColor = q;
|
|
623
666
|
}), a.addEventListener("click", () => this.handleCancel());
|
|
624
|
-
const
|
|
625
|
-
this.iframe = document.createElement("iframe"), this.iframe.src =
|
|
667
|
+
const h = e.triggerType !== "schedule";
|
|
668
|
+
this.iframe = document.createElement("iframe"), this.iframe.src = s, this.iframe.setAttribute("allow", "web-share; clipboard-write"), this.iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-popups allow-forms"), this.iframe.setAttribute("scrolling", "no"), Object.assign(this.iframe.style, {
|
|
626
669
|
width: "100%",
|
|
627
670
|
border: "none",
|
|
628
671
|
display: "block",
|
|
@@ -630,15 +673,15 @@ class Ue {
|
|
|
630
673
|
// The first resize is the big one — the frame grows from its opening
|
|
631
674
|
// guess to the embed's real content height. Eased and a little slower so
|
|
632
675
|
// that reads as the sheet settling rather than a snap.
|
|
633
|
-
transition:
|
|
634
|
-
}),
|
|
676
|
+
transition: $
|
|
677
|
+
}), h && (n.appendChild(a), this.closeButton = a), n.appendChild(this.iframe);
|
|
635
678
|
const u = document.createElement("div");
|
|
636
679
|
this.footer = u, Object.assign(u.style, {
|
|
637
680
|
display: "flex",
|
|
638
681
|
alignItems: "center",
|
|
639
682
|
justifyContent: "center",
|
|
640
|
-
gap: `${
|
|
641
|
-
height: `${
|
|
683
|
+
gap: `${Ge}px`,
|
|
684
|
+
height: `${x}px`,
|
|
642
685
|
// The wrapper is a flex column, so without this the tray would be the
|
|
643
686
|
// first thing squeezed when the card hits its max height.
|
|
644
687
|
flexShrink: "0",
|
|
@@ -646,44 +689,57 @@ class Ue {
|
|
|
646
689
|
boxSizing: "border-box",
|
|
647
690
|
padding: "0"
|
|
648
691
|
});
|
|
649
|
-
const
|
|
650
|
-
|
|
692
|
+
const g = document.createElement("span");
|
|
693
|
+
g.textContent = "Powered by", Object.assign(g.style, {
|
|
651
694
|
fontFamily: "Inter, system-ui, -apple-system, sans-serif",
|
|
652
695
|
fontSize: "12px",
|
|
653
696
|
lineHeight: "16px",
|
|
654
697
|
color: "#ffffff"
|
|
655
698
|
});
|
|
656
699
|
const l = document.createElement("img");
|
|
657
|
-
l.alt = "Moment", l.src =
|
|
700
|
+
l.alt = "Moment", l.src = ie, Object.assign(l.style, {
|
|
658
701
|
display: "block",
|
|
659
702
|
// Both dimensions are explicit so the tray has no reflow to do, even if
|
|
660
703
|
// the image is ever swapped for one that has to decode.
|
|
661
|
-
width: `${
|
|
662
|
-
height: `${(
|
|
663
|
-
}), u.appendChild(
|
|
704
|
+
width: `${j}px`,
|
|
705
|
+
height: `${(j / se).toFixed(2)}px`
|
|
706
|
+
}), u.appendChild(g), u.appendChild(l), this.wrapper = o, this.container = n, this.applyFrameLayout();
|
|
664
707
|
const d = document.createElement("div");
|
|
665
708
|
this.hairline = d, d.setAttribute("aria-hidden", "true"), Object.assign(d.style, {
|
|
666
709
|
position: "absolute",
|
|
667
710
|
inset: "0",
|
|
668
711
|
borderRadius: "inherit",
|
|
669
|
-
boxShadow: `inset 0 0 0 1px ${
|
|
712
|
+
boxShadow: `inset 0 0 0 1px ${ze}`,
|
|
670
713
|
pointerEvents: "none",
|
|
671
714
|
zIndex: "2"
|
|
672
|
-
}), o.appendChild(
|
|
673
|
-
const c = () =>
|
|
674
|
-
if (
|
|
675
|
-
const C = c(),
|
|
676
|
-
|
|
715
|
+
}), o.appendChild(n), o.appendChild(u), o.appendChild(d), this.overlay.appendChild(o), this.feedback = fe(this.overlay, o), document.body.appendChild(this.overlay), this.revealTimer = setTimeout(() => this.reveal(), ke), this.viewportResizeHandler = () => this.applyFrameLayout(), window.addEventListener("resize", this.viewportResizeHandler);
|
|
716
|
+
const c = () => n.querySelectorAll(Pe), m = (p) => {
|
|
717
|
+
if (p.key !== "Tab") return;
|
|
718
|
+
const C = c(), T = C[0], _ = C[C.length - 1], S = document.activeElement;
|
|
719
|
+
p.shiftKey && (S === T || S === n) ? (p.preventDefault(), _.focus()) : !p.shiftKey && S === _ && (p.preventDefault(), T.focus());
|
|
677
720
|
};
|
|
678
|
-
|
|
679
|
-
const
|
|
721
|
+
n.addEventListener("keydown", m);
|
|
722
|
+
const f = (p) => {
|
|
680
723
|
const C = document.createElement("span");
|
|
681
724
|
return C.tabIndex = 0, Object.assign(C.style, { position: "fixed", opacity: "0" }), C.addEventListener("focus", () => {
|
|
682
|
-
const
|
|
683
|
-
|
|
725
|
+
const T = c();
|
|
726
|
+
T[p === "first" ? 0 : T.length - 1].focus();
|
|
684
727
|
}), C;
|
|
685
728
|
};
|
|
686
|
-
|
|
729
|
+
n.before(f("last")), n.after(f("first"));
|
|
730
|
+
const v = document.documentElement.clientWidth;
|
|
731
|
+
this.previousBodyOverflow = document.body.style.overflow, document.body.style.overflow = "hidden", this.didManageBodyOverflow = !0;
|
|
732
|
+
const b = document.documentElement.clientWidth - v;
|
|
733
|
+
if (b > 0) {
|
|
734
|
+
this.previousBodyPaddingRight = document.body.style.paddingRight;
|
|
735
|
+
const p = Number.parseFloat(getComputedStyle(document.body).paddingRight) || 0;
|
|
736
|
+
document.body.style.paddingRight = `${p + b}px`, this.didManageBodyPadding = !0;
|
|
737
|
+
}
|
|
738
|
+
this.setupMessageListener(), this.overlay._escHandler = r, this.overlay._focusTrapHandler = m;
|
|
739
|
+
}
|
|
740
|
+
/** Show the hidden frame, in the look the embed has asked for so far. Runs once per open. */
|
|
741
|
+
reveal() {
|
|
742
|
+
this.revealed || !this.overlay || (this.revealTimer && clearTimeout(this.revealTimer), this.revealTimer = null, this.revealed = !0, this.overlay.style.visibility = "", this.applyFrameLayout(), this.container?.focus());
|
|
687
743
|
}
|
|
688
744
|
/**
|
|
689
745
|
* Size the frame for the current viewport: the one routine for open, window resize and a theme
|
|
@@ -693,9 +749,15 @@ class Ue {
|
|
|
693
749
|
if (!this.overlay || !this.wrapper || !this.container || !this.iframe) return;
|
|
694
750
|
Object.assign(this.wrapper.style, this.currentLayout().wrapper);
|
|
695
751
|
const e = this.currentLayout();
|
|
696
|
-
Object.assign(this.overlay.style, e.overlay), Object.assign(this.wrapper.style, e.wrapperMaterial), Object.assign(this.container.style, e.container), Object.assign(this.container.style, e.card), Object.assign(this.iframe.style, e.iframe)
|
|
697
|
-
const t =
|
|
698
|
-
this.
|
|
752
|
+
Object.assign(this.overlay.style, e.overlay), Object.assign(this.wrapper.style, e.wrapperMaterial), Object.assign(this.container.style, e.container), Object.assign(this.container.style, e.card), Object.assign(this.iframe.style, e.iframe);
|
|
753
|
+
const t = this.footer?.style.display !== "none";
|
|
754
|
+
if (this.footer && this.revealed && t !== e.showFooter) {
|
|
755
|
+
const o = this.iframe.offsetHeight;
|
|
756
|
+
this.iframe.style.transition = "none", this.iframe.style.height = `${o + (t ? x : -x)}px`, this.iframe.offsetHeight, this.iframe.style.transition = $;
|
|
757
|
+
}
|
|
758
|
+
this.footer && (this.footer.style.display = e.showFooter ? "flex" : "none"), this.hairline && (this.hairline.style.display = e.material === "glass" ? "none" : ""), this.wrapper.classList.toggle(I, e.isTray && this.revealed);
|
|
759
|
+
const s = Number.parseFloat(this.iframe.style.height), r = this.lastRequestedHeight !== null ? W(this.lastRequestedHeight, e.iframeMaxHeight) : Number.isNaN(s) ? e.iframeOpeningHeight : Math.min(s, e.iframeMaxHeight);
|
|
760
|
+
this.iframe.style.height = `${r}px`;
|
|
699
761
|
}
|
|
700
762
|
/**
|
|
701
763
|
* The frame for the current viewport, design, radius and card colour. The bottom inset is the
|
|
@@ -703,7 +765,7 @@ class Ue {
|
|
|
703
765
|
*/
|
|
704
766
|
currentLayout() {
|
|
705
767
|
const e = this.wrapper && Number.parseFloat(getComputedStyle(this.wrapper).paddingBottom) || 0;
|
|
706
|
-
return
|
|
768
|
+
return Ne(
|
|
707
769
|
window.innerWidth,
|
|
708
770
|
window.innerHeight,
|
|
709
771
|
this.cardRadius,
|
|
@@ -713,7 +775,7 @@ class Ue {
|
|
|
713
775
|
);
|
|
714
776
|
}
|
|
715
777
|
buildIframeUrl(e, t) {
|
|
716
|
-
return
|
|
778
|
+
return ge(this.liveBaseUrl, e, void 0, t);
|
|
717
779
|
}
|
|
718
780
|
// ── Private: message handling ─────────────────────────────────────
|
|
719
781
|
setupMessageListener() {
|
|
@@ -722,34 +784,38 @@ class Ue {
|
|
|
722
784
|
const t = e.data;
|
|
723
785
|
if (!(!t || typeof t != "object")) {
|
|
724
786
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.oauth.start") {
|
|
725
|
-
const
|
|
787
|
+
const s = t;
|
|
726
788
|
this.emitAnalytics("oauth.start", {
|
|
727
|
-
provider:
|
|
728
|
-
teamSlug:
|
|
729
|
-
}), this.handleOAuthStart(
|
|
789
|
+
provider: s.provider,
|
|
790
|
+
teamSlug: s.teamSlug
|
|
791
|
+
}), this.handleOAuthStart(s);
|
|
730
792
|
return;
|
|
731
793
|
}
|
|
732
794
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.resize") {
|
|
733
|
-
const
|
|
734
|
-
if (
|
|
735
|
-
this.lastRequestedHeight =
|
|
795
|
+
const s = typeof t.height == "number" ? t.height : 0;
|
|
796
|
+
if (s > 0 && this.iframe) {
|
|
797
|
+
this.lastRequestedHeight = s;
|
|
736
798
|
const { iframeMaxHeight: r } = this.currentLayout();
|
|
737
|
-
this.iframe.style.height = `${
|
|
799
|
+
this.iframe.style.height = `${W(s, r)}px`;
|
|
738
800
|
}
|
|
739
801
|
return;
|
|
740
802
|
}
|
|
741
803
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.theme") {
|
|
742
|
-
const
|
|
743
|
-
|
|
804
|
+
const s = We(t);
|
|
805
|
+
s.design && s.design !== this.design && (this.design = s.design, this.applyFrameLayout()), s.cardRadius !== void 0 && (this.cardRadius = s.cardRadius, this.applyFrameLayout()), s.hideCloseButton && this.closeButton && (document.activeElement === this.closeButton && this.container?.focus(), this.closeButton.remove()), s.surface !== void 0 && (this.surface = s.surface, this.applyFrameLayout()), s.dismissByEmbed && (this.dismissByEmbed = !0), this.reveal();
|
|
744
806
|
return;
|
|
745
807
|
}
|
|
746
808
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.open.url") {
|
|
747
|
-
const { url:
|
|
748
|
-
if (
|
|
749
|
-
const r =
|
|
750
|
-
r === "blocked" && this.emitAnalytics("open.url.blocked", {}), this.sendOpenUrlStatus(r,
|
|
809
|
+
const { url: s } = t;
|
|
810
|
+
if (xe(s)) {
|
|
811
|
+
const r = Ae(window.open(s, "_blank"));
|
|
812
|
+
r === "blocked" && this.emitAnalytics("open.url.blocked", {}), this.sendOpenUrlStatus(r, s);
|
|
751
813
|
} else
|
|
752
|
-
this.sendOpenUrlStatus("blocked", typeof
|
|
814
|
+
this.sendOpenUrlStatus("blocked", typeof s == "string" ? s : "");
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
if (t.source === "moment-live-embed" && t.type === "moment.embed.dismiss.ack") {
|
|
818
|
+
this.clearDismissAckTimer();
|
|
753
819
|
return;
|
|
754
820
|
}
|
|
755
821
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.close") {
|
|
@@ -761,19 +827,19 @@ class Ue {
|
|
|
761
827
|
return;
|
|
762
828
|
}
|
|
763
829
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.toast") {
|
|
764
|
-
const { text:
|
|
765
|
-
typeof
|
|
830
|
+
const { text: s, variant: r } = t;
|
|
831
|
+
typeof s == "string" && s.trim() !== "" && this.feedback?.toast(s, r);
|
|
766
832
|
return;
|
|
767
833
|
}
|
|
768
834
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.result") {
|
|
769
|
-
const
|
|
770
|
-
this.handleResult(
|
|
835
|
+
const s = t;
|
|
836
|
+
this.handleResult(s);
|
|
771
837
|
}
|
|
772
838
|
}
|
|
773
839
|
}, window.addEventListener("message", this.messageHandler);
|
|
774
840
|
}
|
|
775
841
|
handleOAuthStart(e) {
|
|
776
|
-
this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.popupBridge = new
|
|
842
|
+
this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.popupBridge = new be({
|
|
777
843
|
liveBaseUrl: this.liveBaseUrl,
|
|
778
844
|
liveOrigin: this.liveOrigin,
|
|
779
845
|
iframeWindow: this.iframe?.contentWindow ?? null,
|
|
@@ -798,15 +864,15 @@ class Ue {
|
|
|
798
864
|
* real open from a blocked one instead of assuming success.
|
|
799
865
|
*/
|
|
800
866
|
sendOpenUrlStatus(e, t) {
|
|
801
|
-
const
|
|
802
|
-
if (!
|
|
867
|
+
const s = this.iframe?.contentWindow;
|
|
868
|
+
if (!s) return;
|
|
803
869
|
const r = {
|
|
804
870
|
source: "moment-sdk",
|
|
805
871
|
type: "moment.embed.open.url.status",
|
|
806
872
|
status: e,
|
|
807
873
|
url: t
|
|
808
874
|
};
|
|
809
|
-
|
|
875
|
+
s.postMessage(r, this.liveOrigin);
|
|
810
876
|
}
|
|
811
877
|
handleResult(e) {
|
|
812
878
|
e.result !== "cancelled" && (e.keepOpen === !0 && e.triggerType !== "schedule" && (this.closeReported = !0), e.result === "success" || e.result === "partial" ? (this.emitAnalytics("subscribe.success", {
|
|
@@ -817,7 +883,24 @@ class Ue {
|
|
|
817
883
|
provider: e.provider,
|
|
818
884
|
triggerType: e.triggerType,
|
|
819
885
|
momentIds: e.momentIds
|
|
820
|
-
}), this.opts.onError?.(e)), this.opts.onClose?.(e), this.emitAnalytics("embed.close"),
|
|
886
|
+
}), this.opts.onError?.(e)), this.opts.onClose?.(e), this.emitAnalytics("embed.close"), Ue(e) && (this.closeTimer = setTimeout(() => this.cleanup(), 1500)));
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* A tap outside the sheet or Escape on the page. A v2 sheet that claimed it hears it, answers
|
|
890
|
+
* with `moment.embed.dismiss.ack` and does what its own ✕ does, closing through
|
|
891
|
+
* `moment.embed.close`; anything else, or no answer in time, closes here.
|
|
892
|
+
*/
|
|
893
|
+
requestDismiss() {
|
|
894
|
+
const e = this.iframe?.contentWindow;
|
|
895
|
+
if (!this.dismissByEmbed || this.design !== "v2" || !e) {
|
|
896
|
+
this.handleCancel();
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
const t = { source: "moment-sdk", type: "moment.sdk.dismiss" };
|
|
900
|
+
e.postMessage(t, this.liveOrigin), this.dismissAckTimer || (this.dismissAckTimer = setTimeout(() => this.handleCancel(), Re));
|
|
901
|
+
}
|
|
902
|
+
clearDismissAckTimer() {
|
|
903
|
+
this.dismissAckTimer && clearTimeout(this.dismissAckTimer), this.dismissAckTimer = null;
|
|
821
904
|
}
|
|
822
905
|
handleCancel() {
|
|
823
906
|
if (!this.closeReported) {
|
|
@@ -831,17 +914,35 @@ class Ue {
|
|
|
831
914
|
};
|
|
832
915
|
this.opts.onClose?.(t);
|
|
833
916
|
}
|
|
834
|
-
this.cleanup();
|
|
917
|
+
this.cleanup(!0);
|
|
835
918
|
}
|
|
836
919
|
// ── Private: cleanup ──────────────────────────────────────────────
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
920
|
+
/**
|
|
921
|
+
* Tear the open sheet down. With `exit` (a close the fan or partner asked for), a shown v2 sheet
|
|
922
|
+
* leaves with its slide-down, or its fade on desktop; everything else here still runs at once.
|
|
923
|
+
*/
|
|
924
|
+
cleanup(e = !1) {
|
|
925
|
+
const t = e && this.design === "v2" && this.revealed && !window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
926
|
+
if (this.closeTimer && (clearTimeout(this.closeTimer), this.closeTimer = null), this.revealTimer && (clearTimeout(this.revealTimer), this.revealTimer = null), this.clearDismissAckTimer(), this.revealed = !1, this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.messageHandler && (window.removeEventListener("message", this.messageHandler), this.messageHandler = null), this.feedback?.destroy(), this.feedback = null, this.closeReported = !1, this.design = "v1", this.surface = w, this.dismissByEmbed = !1, this.lastRequestedHeight = null, this.footer = null, this.hairline = null, this.viewportResizeHandler && (window.removeEventListener("resize", this.viewportResizeHandler), this.viewportResizeHandler = null), this.overlay) {
|
|
927
|
+
const { _escHandler: s, _focusTrapHandler: r } = this.overlay;
|
|
928
|
+
s && document.removeEventListener("keydown", s);
|
|
929
|
+
const o = this.overlay.firstElementChild;
|
|
930
|
+
if (o && r && o.removeEventListener("keydown", r), t) {
|
|
931
|
+
const n = this.overlay;
|
|
932
|
+
n.style.pointerEvents = "none", n.style.width = `${document.documentElement.clientWidth}px`, n.classList.add(A);
|
|
933
|
+
const a = setTimeout(() => n.remove(), He);
|
|
934
|
+
n.addEventListener(
|
|
935
|
+
"animationend",
|
|
936
|
+
() => {
|
|
937
|
+
clearTimeout(a), n.remove();
|
|
938
|
+
},
|
|
939
|
+
{ once: !0 }
|
|
940
|
+
);
|
|
941
|
+
} else
|
|
942
|
+
this.overlay.remove();
|
|
943
|
+
this.overlay = null;
|
|
843
944
|
}
|
|
844
|
-
this.iframe = null, this.wrapper = null, this.container = null, this.closeButton = null, this.activePayload = null, this.activeCampaignId = void 0, this.cardRadius =
|
|
945
|
+
this.iframe = null, this.wrapper = null, this.container = null, this.closeButton = null, this.activePayload = null, this.activeCampaignId = void 0, this.cardRadius = E, this.didManageBodyOverflow && (document.body.style.overflow = this.previousBodyOverflow, this.didManageBodyOverflow = !1), this.didManageBodyPadding && (document.body.style.paddingRight = this.previousBodyPaddingRight, this.didManageBodyPadding = !1), this.previousFocusedElement && typeof this.previousFocusedElement.focus == "function" && this.previousFocusedElement.focus(), this.previousFocusedElement = null;
|
|
845
946
|
}
|
|
846
947
|
// ── Private: analytics ────────────────────────────────────────────
|
|
847
948
|
emitAnalytics(e, t) {
|
|
@@ -852,7 +953,7 @@ class Ue {
|
|
|
852
953
|
});
|
|
853
954
|
}
|
|
854
955
|
}
|
|
855
|
-
function
|
|
956
|
+
function Ve(i) {
|
|
856
957
|
const e = document.createElement("button");
|
|
857
958
|
return e.type = "button", e.classList.add("moment-sync-trigger"), i.className && i.className.split(" ").forEach((t) => {
|
|
858
959
|
t && e.classList.add(t);
|
|
@@ -860,9 +961,9 @@ function $e(i) {
|
|
|
860
961
|
}
|
|
861
962
|
if (typeof window < "u") {
|
|
862
963
|
const i = window;
|
|
863
|
-
i.MomentSdk =
|
|
964
|
+
i.MomentSdk = Ye, i.createMomentButton = Ve;
|
|
864
965
|
}
|
|
865
966
|
export {
|
|
866
|
-
|
|
867
|
-
|
|
967
|
+
Ye as MomentSdk,
|
|
968
|
+
Ve as createMomentButton
|
|
868
969
|
};
|