@momentco-ai/moment-sdk 0.8.0-dev.42 → 0.8.0-dev.44
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 +5 -2
- package/README.md +1 -1
- package/dist/moment-sdk.js +7 -7
- package/dist/moment-sdk.mjs +93 -89
- package/dist/types/sdk/modal-frame.d.ts +26 -3
- package/dist/types/sdk/sdk-styles.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
- **Bottom tray on smaller screens.** Below 1024px: full width, top corners rounded, slide-up (instant when the visitor prefers reduced motion), at most 90% of the visible height in `dvh` so mobile toolbars can't push it off screen. Footer padded by `env(safe-area-inset-bottom)`. The desktop modal is unchanged, and ✕, Escape and tapping outside work as before.
|
|
12
|
+
- **Bottom tray on smaller screens.** Below 1024px: full width, or the desktop modal's 600px, centred, once that leaves at least 40px each side (so no sliver of the page shows beside it), top corners rounded, slide-up (instant when the visitor prefers reduced motion), at most 90% of the visible height in `dvh` so mobile toolbars can't push it off screen. Footer padded by `env(safe-area-inset-bottom)`. The desktop modal is unchanged, and ✕, Escape and tapping outside work as before.
|
|
13
13
|
- **`keepOpen` on `moment.embed.result`.** The callbacks fire as before and the sheet stays open until `moment.embed.close` or a dismiss. `onClose` (with `cancelled`) and `embed.close` then fire again, as they do for `schedule`.
|
|
14
14
|
- **`closeControl` and `surface` on `moment.embed.theme`.** `"embed"` removes the SDK ✕; `surface` colours the card behind the iframe; each theme field applies on its own.
|
|
15
15
|
- **The embed can share a link.** The iframe now carries `allow="web-share; clipboard-write"`, so the embed's Share button can open the share sheet or copy the link. A host page's own `Permissions-Policy` still decides.
|
|
@@ -17,13 +17,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
17
17
|
### Fixed
|
|
18
18
|
|
|
19
19
|
- **Frame edges.** The frame and the card share one radius, and the card rounds only its top corners, so no dark sliver shows outside a top corner and no notch where the card meets the "Powered by" tray. The hairline now outlines the whole sheet instead of only the tray. The card starts in the sheet colour (`#121316`) instead of white, so it no longer flashes white before the embed's theme arrives.
|
|
20
|
+
- **The ✕ matches the embed's.** It is a 40px round button 16px from the card's top and right, drawn as the embed draws its own, so nothing moves or changes when the embed's ✕ takes over (`closeControl: "embed"`). Its focus ring is white inside a dark band, so it shows on the dark card and on a light embed.
|
|
21
|
+
- **iPhone Safari dims its bars with the page.** The page behind the tray is dimmed but no longer blurred: over a blurred backdrop, Safari kept its status bar and toolbar in the host page's colours. The desktop modal keeps its blur.
|
|
22
|
+
- **The sheet sits above cookie-consent banners.** The overlay's z-index is now 2147483647, the highest there is. At 999999, a consent banner docked to the bottom of the page covered the tray's lower buttons.
|
|
20
23
|
- **Tab reaches the embed's controls.** The focus trap never counted the iframe, so Tab only ever reached the ✕, and a sheet without one (`schedule`, or an embed that sends `closeControl: "embed"`) had no Tab stop at all. Tab now moves into the embed, and focus that leaves its first or last control stays in the sheet instead of reaching the host page.
|
|
21
24
|
- **Calendar sync works when the page is a `srcdoc` iframe.** There `location.origin` is `"null"`, so `returnOrigin` falls back to `self.origin`, the origin the frame inherits. Normal pages send the same value as before. A `srcdoc` iframe sandboxed without `allow-same-origin`, whose origin is really opaque, logs a console error instead.
|
|
22
25
|
|
|
23
26
|
### Compatibility
|
|
24
27
|
|
|
25
28
|
- Older SDKs ignore the new fields: they close after 1.5 s and keep their ✕ and white card.
|
|
26
|
-
- Embeds that don't send the
|
|
29
|
+
- Embeds that don't send `closeControl` keep the SDK's ✕, now drawn for the dark sheet, so 0.8.0 needs a Live that serves the 0.8.0 embed.
|
|
27
30
|
- Types: `MomentResultPayload` gains `keepOpen?: boolean`, and `MomentThemePayload.borderRadius` is now optional, so code that reads it off `MomentPostMessage` must allow `undefined`.
|
|
28
31
|
|
|
29
32
|
## [0.7.0] - 2026-10-12
|
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ Copy this into any page. Replace `your-team-slug` and `your-event-slug` with val
|
|
|
85
85
|
|
|
86
86
|
Clicking the button opens a modal where the fan selects Google Calendar or Outlook and completes OAuth in a popup. Your callbacks fire when sync succeeds, fails, or the modal closes.
|
|
87
87
|
|
|
88
|
-
On screens narrower than 1024px the sheet opens as a bottom tray: full width, sliding up from the bottom edge (without animation when the visitor prefers reduced motion) and at most 90% of the visible height. At 1024px and wider it opens as a centred modal. On pages with `viewport-fit=cover`, the tray keeps its footer clear of the iPhone home indicator.
|
|
88
|
+
On screens narrower than 1024px the sheet opens as a bottom tray: full width, or 600px and centred once that leaves at least 40px each side, sliding up from the bottom edge (without animation when the visitor prefers reduced motion) and at most 90% of the visible height. At 1024px and wider it opens as a centred modal. On pages with `viewport-fit=cover`, the tray keeps its footer clear of the iPhone home indicator.
|
|
89
89
|
|
|
90
90
|
---
|
|
91
91
|
|
package/dist/moment-sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(v){"use strict";const B="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",P=5.663533834586466;function E(){if(typeof window>"u")return"";const n=window.location.origin,e=n==="null"?self.origin:n;return e==="null"&&console.error('[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.'),e}function F(n,e,t=E()){if(e.triggerType==="schedule"){const r=new URLSearchParams;return r.set("teamSlug",e.teamSlug),r.set("returnOrigin",t),r.set("embed","1"),r.set("sdkVersion","0.8.0-dev.42"),`${n}/en/embed/schedule?${r.toString()}`}const i=new URLSearchParams;return i.set("teamSlug",e.teamSlug),e.momentSlug&&i.set("momentSlug",e.momentSlug),e.listSlug&&i.set("listSlug",e.listSlug),i.set("triggerType",e.triggerType),e.ids?.length&&i.set("ids",e.ids.join(",")),e.playlistSlugs?.length&&i.set("playlistSlugs",e.playlistSlugs.join(",")),e.calendar&&i.set("calendar",e.calendar),e.apiSourceId&&i.set("subscriptionId",e.apiSourceId),e.externalEventId&&i.set("externalId",e.externalEventId),e.externalEventIdPrefix&&!e.externalEventId&&i.set("externalIdPrefix",e.externalEventIdPrefix),i.set("returnOrigin",t),i.set("embed","1"),i.set("sdkVersion","0.8.0-dev.42"),`${n}/en/embed/sync?${i.toString()}`}const x=500,S=700,D=500;class U{popup=null;pollTimer=null;messageHandler=null;resultReceived=!1;opts;constructor(e){this.opts=e}open(e){this.cleanup(),this.resultReceived=!1;const t=this.buildPopupUrl(e),i=Math.round(window.screenX+(window.outerWidth-x)/2),r=Math.round(window.screenY+(window.outerHeight-S)/2);if(this.popup=window.open(t,"moment-oauth-popup",`width=${x},height=${S},left=${i},top=${r},menubar=no,toolbar=no,location=yes,status=no`),!this.popup||this.popup.closed){this.sendStatusToIframe("popup-blocked"),this.opts.onPopupBlocked();return}this.sendStatusToIframe("popup-opened"),this.startPolling(),this.messageHandler=s=>{if(s.origin!==this.opts.liveOrigin||s.source!==this.popup)return;const o=s.data;!o||typeof o!="object"||o.source!=="moment-live-embed"||o.type!=="moment.embed.result"||(this.resultReceived=!0,this.sendStatusToIframe("completed"),this.opts.iframeWindow&&this.opts.iframeWindow.postMessage(o,this.opts.liveOrigin),this.opts.onResult(o),this.cleanup())},window.addEventListener("message",this.messageHandler)}cleanup(){if(this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.popup&&!this.popup.closed)try{this.popup.close()}catch{}this.popup=null}buildPopupUrl(e){const t=E(),i=new URLSearchParams({provider:e.provider,teamSlug:e.teamSlug,ids:e.ids.join(","),triggerType:e.triggerType,returnOrigin:t});return e.subscriptionType&&i.set("subscriptionType",e.subscriptionType),e.scheduleMomentIds?.length&&i.set("scheduleMomentIds",e.scheduleMomentIds.join(",")),e.schedulePlaylistIds?.length&&i.set("schedulePlaylistIds",e.schedulePlaylistIds.join(",")),`${this.opts.liveBaseUrl}/en/embed/oauth-popup?${i.toString()}`}startPolling(){this.pollTimer=setInterval(()=>{(!this.popup||this.popup.closed)&&(this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.resultReceived||(this.sendStatusToIframe("popup-closed"),this.opts.onPopupClosed()),this.cleanup())},D)}sendStatusToIframe(e){if(!this.opts.iframeWindow)return;const t={source:"moment-sdk",type:"moment.embed.oauth.status",status:e};this.opts.iframeWindow.postMessage(t,this.opts.liveOrigin)}}const T="moment-sdk-styles",L="moment-sdk-close",A="moment-sdk-tray",$=`
|
|
1
|
+
(function(v){"use strict";const F="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",D=5.663533834586466;function S(){if(typeof window>"u")return"";const n=window.location.origin,e=n==="null"?self.origin:n;return e==="null"&&console.error('[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.'),e}function U(n,e,t=S()){if(e.triggerType==="schedule"){const r=new URLSearchParams;return r.set("teamSlug",e.teamSlug),r.set("returnOrigin",t),r.set("embed","1"),r.set("sdkVersion","0.8.0-dev.44"),`${n}/en/embed/schedule?${r.toString()}`}const i=new URLSearchParams;return i.set("teamSlug",e.teamSlug),e.momentSlug&&i.set("momentSlug",e.momentSlug),e.listSlug&&i.set("listSlug",e.listSlug),i.set("triggerType",e.triggerType),e.ids?.length&&i.set("ids",e.ids.join(",")),e.playlistSlugs?.length&&i.set("playlistSlugs",e.playlistSlugs.join(",")),e.calendar&&i.set("calendar",e.calendar),e.apiSourceId&&i.set("subscriptionId",e.apiSourceId),e.externalEventId&&i.set("externalId",e.externalEventId),e.externalEventIdPrefix&&!e.externalEventId&&i.set("externalIdPrefix",e.externalEventIdPrefix),i.set("returnOrigin",t),i.set("embed","1"),i.set("sdkVersion","0.8.0-dev.44"),`${n}/en/embed/sync?${i.toString()}`}const x=500,T=700,$=500;class N{popup=null;pollTimer=null;messageHandler=null;resultReceived=!1;opts;constructor(e){this.opts=e}open(e){this.cleanup(),this.resultReceived=!1;const t=this.buildPopupUrl(e),i=Math.round(window.screenX+(window.outerWidth-x)/2),r=Math.round(window.screenY+(window.outerHeight-T)/2);if(this.popup=window.open(t,"moment-oauth-popup",`width=${x},height=${T},left=${i},top=${r},menubar=no,toolbar=no,location=yes,status=no`),!this.popup||this.popup.closed){this.sendStatusToIframe("popup-blocked"),this.opts.onPopupBlocked();return}this.sendStatusToIframe("popup-opened"),this.startPolling(),this.messageHandler=s=>{if(s.origin!==this.opts.liveOrigin||s.source!==this.popup)return;const o=s.data;!o||typeof o!="object"||o.source!=="moment-live-embed"||o.type!=="moment.embed.result"||(this.resultReceived=!0,this.sendStatusToIframe("completed"),this.opts.iframeWindow&&this.opts.iframeWindow.postMessage(o,this.opts.liveOrigin),this.opts.onResult(o),this.cleanup())},window.addEventListener("message",this.messageHandler)}cleanup(){if(this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.popup&&!this.popup.closed)try{this.popup.close()}catch{}this.popup=null}buildPopupUrl(e){const t=S(),i=new URLSearchParams({provider:e.provider,teamSlug:e.teamSlug,ids:e.ids.join(","),triggerType:e.triggerType,returnOrigin:t});return e.subscriptionType&&i.set("subscriptionType",e.subscriptionType),e.scheduleMomentIds?.length&&i.set("scheduleMomentIds",e.scheduleMomentIds.join(",")),e.schedulePlaylistIds?.length&&i.set("schedulePlaylistIds",e.schedulePlaylistIds.join(",")),`${this.opts.liveBaseUrl}/en/embed/oauth-popup?${i.toString()}`}startPolling(){this.pollTimer=setInterval(()=>{(!this.popup||this.popup.closed)&&(this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.resultReceived||(this.sendStatusToIframe("popup-closed"),this.opts.onPopupClosed()),this.cleanup())},$)}sendStatusToIframe(e){if(!this.opts.iframeWindow)return;const t={source:"moment-sdk",type:"moment.embed.oauth.status",status:e};this.opts.iframeWindow.postMessage(t,this.opts.liveOrigin)}}const L="moment-sdk-styles",A="moment-sdk-close",I="moment-sdk-tray",j=`
|
|
2
2
|
:where(.moment-sync-trigger) {
|
|
3
3
|
background-color: #1c1917;
|
|
4
4
|
color: #ffffff;
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
outline-offset: 2px;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.${
|
|
27
|
-
outline: 2px solid #
|
|
28
|
-
outline-offset:
|
|
29
|
-
|
|
26
|
+
.${A}:focus-visible {
|
|
27
|
+
outline: 2px solid #ffffff;
|
|
28
|
+
outline-offset: 0;
|
|
29
|
+
box-shadow: 0 0 0 4px #121316;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
@keyframes moment-sdk-tray-in {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
@media (prefers-reduced-motion: no-preference) {
|
|
38
|
-
.${
|
|
38
|
+
.${I} {
|
|
39
39
|
animation: moment-sdk-tray-in 0.35s cubic-bezier(0.32, 0.72, 0, 1);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
`;function j(){if(typeof document>"u"||document.getElementById(T))return;const n=document.createElement("style");n.id=T,n.textContent=$,document.head.appendChild(n)}function W(n){return typeof n=="string"&&n.startsWith("webcal://")}function N(n){return!n||n.closed?"blocked":"opened"}const z=1024,K=600,G=400,I=80,M=90,V=420,Y=520,b=32,y=12,Z='button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex="-1"])';function O(n,e,t=y){const i=`${t}px ${t}px 0px 0px`;if(n<z){const s=Math.floor(e*M/100)-b;return{isTray:!0,overlay:{alignItems:"flex-end",padding:"0"},wrapper:{maxWidth:"none",minWidth:"0",borderRadius:i,paddingBottom:"env(safe-area-inset-bottom, 0px)"},container:{maxHeight:`calc(${M}dvh - ${b}px)`,borderRadius:i},iframeMaxHeight:s,iframeOpeningHeight:Math.min(V,s)}}const r=e-I;return{isTray:!1,overlay:{alignItems:"center",padding:"16px"},wrapper:{maxWidth:`${K}px`,minWidth:`${G}px`,borderRadius:`${t}px`,paddingBottom:"0"},container:{maxHeight:`calc(100vh - ${I}px)`,borderRadius:i},iframeMaxHeight:r,iframeOpeningHeight:Math.min(Y,r)}}function X(n){return n.triggerType!=="schedule"&&n.keepOpen!==!0}const q=32;function J(n){const e={hideCloseButton:n.closeControl==="embed"};return typeof n.borderRadius=="number"&&Number.isFinite(n.borderRadius)&&(e.cardRadius=Math.max(0,Math.min(n.borderRadius,q))),typeof n.surface=="string"&&n.surface!==""&&(e.surface=n.surface),e}const Q=".moment-sync-trigger",ee=6,k=60,te="#0d0d0d",ie="rgba(255, 255, 255, 0.216)",ne="#121316",se="https://live.dev.momentco.ai";class H{opts;liveBaseUrl;liveOrigin;overlay=null;iframe=null;wrapper=null;container=null;closeButton=null;popupBridge=null;messageHandler=null;boundClickHandlers=new Map;activePayload=null;previousFocusedElement=null;previousBodyOverflow="";didManageBodyOverflow=!1;closeTimer=null;cardRadius=y;viewportResizeHandler=null;constructor(e){this.opts={triggerSelector:Q,...e},this.liveBaseUrl=se;try{this.liveOrigin=new URL(this.liveBaseUrl).origin}catch{throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`)}j(),this.bindTriggers(),this.emitAnalytics("embed.init")}open(e){e.externalEventId&&e.externalEventIdPrefix&&console.warn("[MomentSdk] Both externalEventId and externalEventIdPrefix provided; using externalEventId only.");const t=this.scopeOpenPayload(e);this.emitAnalytics("embed.open",{teamSlug:t.teamSlug,triggerType:t.triggerType}),this.createModal(t)}close(){this.handleCancel()}rebind(){this.unbindTriggers(),this.bindTriggers()}destroy(){this.cleanup(),this.unbindTriggers()}bindTriggers(){document.querySelectorAll(this.opts.triggerSelector).forEach(t=>{const i=s=>{s.preventDefault(),this.handleTriggerClick(t)},r=this.boundClickHandlers.get(t);r&&t.removeEventListener("click",r),t.addEventListener("click",i),this.boundClickHandlers.set(t,i)})}unbindTriggers(){this.boundClickHandlers.forEach((e,t)=>{t.removeEventListener("click",e)}),this.boundClickHandlers.clear()}handleTriggerClick(e){const t=e.getAttribute("data-moment-team-slug")??"",i=e.getAttribute("data-moment-slug")??void 0,r=e.getAttribute("data-moment-list-slug")??void 0,s=e.getAttribute("data-moment-trigger-type");let o="moment";s!=null&&s!==""&&(s==="moment"||s==="list"||s==="team"||s==="brand-playlist"||s==="playlist"||s==="schedule"?o=s:console.warn("[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",s));const f=e.getAttribute("data-moment-ids")??e.getAttribute("data-moment-game-id")??"",c=f?f.split(",").filter(Boolean):[],p=e.getAttribute("data-moment-playlist-slugs")??"",h=p?p.split(",").map(m=>m.trim()).filter(Boolean):[],a=e.getAttribute("data-moment-calendar");let g;a!=null&&a!==""&&(a==="google"||a==="outlook"?g=a:console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:",a));const C=e.getAttribute("data-api-source-id")??void 0,u=e.getAttribute("data-external-event-id")??void 0,l=e.getAttribute("data-external-event-id-prefix")??void 0;if(u&&l&&console.warn("[MomentSdk] Both data-external-event-id and data-external-event-id-prefix are set; using data-external-event-id only."),!t){console.warn("[MomentSdk] Missing data-moment-team-slug on trigger element");return}const d=o==="team"||o==="brand-playlist"||o==="playlist"||o==="schedule";this.emitAnalytics("embed.trigger.click",{teamSlug:t,triggerType:o,momentIds:d?[]:c}),this.open({teamSlug:t,momentSlug:i,listSlug:r,triggerType:o,ids:c,playlistSlugs:h,calendar:g??void 0,apiSourceId:C,externalEventId:l&&!u?void 0:u,externalEventIdPrefix:u?void 0:l})}scopeOpenPayload(e){return e.triggerType==="schedule"?{teamSlug:e.teamSlug,triggerType:e.triggerType}:e.triggerType==="playlist"?{teamSlug:e.teamSlug,triggerType:e.triggerType,playlistSlugs:e.playlistSlugs,calendar:e.calendar}:e.triggerType==="team"||e.triggerType==="brand-playlist"?{teamSlug:e.teamSlug,triggerType:e.triggerType,calendar:e.calendar}:e}createModal(e){this.cleanup(),this.previousFocusedElement=document.activeElement||null,this.activePayload=e;const t=this.buildIframeUrl(e);this.overlay=document.createElement("div"),this.overlay.setAttribute("role","presentation"),Object.assign(this.overlay.style,{position:"fixed",inset:"0",zIndex:"999999",display:"flex",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(2px)"}),this.overlay.addEventListener("click",l=>{l.target===this.overlay&&this.handleCancel()});const i=l=>{l.key==="Escape"&&this.handleCancel()};document.addEventListener("keydown",i);const r=document.createElement("div");Object.assign(r.style,{position:"relative",width:"100%",transition:"border-radius 0.3s ease",overflow:"hidden",backgroundColor:te,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"});const s=document.createElement("div");s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("aria-label","Calendar sync modal"),s.tabIndex=-1,Object.assign(s.style,{position:"relative",width:"100%",transition:"border-radius 0.3s ease",overflow:"auto",backgroundColor:ne,outline:"none"});const o=document.createElement("button");o.type="button",o.className=L,o.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1l12 12M13 1L1 13" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',o.setAttribute("aria-label","Close"),Object.assign(o.style,{position:"absolute",top:"10px",right:"10px",zIndex:"10",border:"none",backgroundColor:"transparent",color:"#999",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:"0"}),o.addEventListener("mouseenter",()=>{o.style.color="#666"}),o.addEventListener("mouseleave",()=>{o.style.color="#999"}),o.addEventListener("click",()=>this.handleCancel());const f=e.triggerType!=="schedule";this.iframe=document.createElement("iframe"),this.iframe.src=t,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,{width:"100%",border:"none",display:"block",overflow:"hidden",transition:"height 0.25s cubic-bezier(0.32, 0.72, 0, 1)"}),f&&(s.appendChild(o),this.closeButton=o),s.appendChild(this.iframe);const c=document.createElement("div");Object.assign(c.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:`${ee}px`,height:`${b}px`,flexShrink:"0",boxSizing:"border-box",padding:"0"});const p=document.createElement("span");p.textContent="Powered by",Object.assign(p.style,{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:"12px",lineHeight:"16px",color:"#ffffff"});const h=document.createElement("img");h.alt="Moment",h.src=B,Object.assign(h.style,{display:"block",width:`${k}px`,height:`${(k/P).toFixed(2)}px`}),c.appendChild(p),c.appendChild(h),this.wrapper=r,this.container=s,this.applyFrameLayout();const a=document.createElement("div");a.setAttribute("aria-hidden","true"),Object.assign(a.style,{position:"absolute",inset:"0",borderRadius:"inherit",boxShadow:`inset 0 0 0 1px ${ie}`,pointerEvents:"none",zIndex:"2"}),r.appendChild(s),r.appendChild(c),r.appendChild(a),this.overlay.appendChild(r),document.body.appendChild(this.overlay),this.viewportResizeHandler=()=>this.applyFrameLayout(),window.addEventListener("resize",this.viewportResizeHandler);const g=()=>s.querySelectorAll(Z),C=l=>{if(l.key!=="Tab")return;const d=g(),m=d[0],_=d[d.length-1],w=document.activeElement;l.shiftKey&&(w===m||w===s)?(l.preventDefault(),_.focus()):!l.shiftKey&&w===_&&(l.preventDefault(),m.focus())};s.addEventListener("keydown",C);const u=l=>{const d=document.createElement("span");return d.tabIndex=0,Object.assign(d.style,{position:"fixed",opacity:"0"}),d.addEventListener("focus",()=>{const m=g();m[l==="first"?0:m.length-1].focus()}),d};s.before(u("last")),s.after(u("first")),s.focus(),this.previousBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.didManageBodyOverflow=!0,this.setupMessageListener(),this.overlay._escHandler=i,this.overlay._focusTrapHandler=C}applyFrameLayout(){if(!this.overlay||!this.wrapper||!this.container||!this.iframe)return;const e=O(window.innerWidth,window.innerHeight,this.cardRadius);Object.assign(this.overlay.style,e.overlay),Object.assign(this.wrapper.style,e.wrapper),Object.assign(this.container.style,e.container),this.wrapper.classList.toggle(A,e.isTray);const t=Number.parseFloat(this.iframe.style.height),i=Number.isNaN(t)?e.iframeOpeningHeight:Math.min(t,e.iframeMaxHeight);this.iframe.style.height=`${i}px`}buildIframeUrl(e){return F(this.liveBaseUrl,e)}setupMessageListener(){this.messageHandler=e=>{if(e.origin!==this.liveOrigin||e.source!==this.iframe?.contentWindow)return;const t=e.data;if(!(!t||typeof t!="object")){if(t.source==="moment-live-embed"&&t.type==="moment.embed.oauth.start"){const i=t;this.emitAnalytics("oauth.start",{provider:i.provider,teamSlug:i.teamSlug}),this.handleOAuthStart(i);return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.resize"){const i=typeof t.height=="number"?t.height:0;if(i>0&&this.iframe){const{iframeMaxHeight:r}=O(window.innerWidth,window.innerHeight);this.iframe.style.height=`${Math.min(i,r)}px`}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.theme"){const i=J(t);i.cardRadius!==void 0&&(this.cardRadius=i.cardRadius,this.applyFrameLayout()),i.hideCloseButton&&this.closeButton&&(document.activeElement===this.closeButton&&this.container?.focus(),this.closeButton.remove()),i.surface!==void 0&&this.container&&(this.container.style.backgroundColor=i.surface);return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.open.url"){const{url:i}=t;if(W(i)){const r=N(window.open(i,"_blank"));r==="blocked"&&this.emitAnalytics("open.url.blocked",{}),this.sendOpenUrlStatus(r,i)}else this.sendOpenUrlStatus("blocked",typeof i=="string"?i:"");return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.close"){this.handleCancel();return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.result"){const i=t;this.handleResult(i)}}},window.addEventListener("message",this.messageHandler)}handleOAuthStart(e){this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.popupBridge=new U({liveBaseUrl:this.liveBaseUrl,liveOrigin:this.liveOrigin,iframeWindow:this.iframe?.contentWindow??null,onResult:t=>{this.handleResult(t)},onPopupBlocked:()=>{this.emitAnalytics("oauth.popup.blocked",{provider:e.provider})},onPopupClosed:()=>{this.emitAnalytics("oauth.popup.closed",{provider:e.provider})}}),this.popupBridge.open(e)}sendOpenUrlStatus(e,t){const i=this.iframe?.contentWindow;if(!i)return;const r={source:"moment-sdk",type:"moment.embed.open.url.status",status:e,url:t};i.postMessage(r,this.liveOrigin)}handleResult(e){if(e.result==="success"||e.result==="partial")this.emitAnalytics("subscribe.success",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onSuccess?.(e);else if(e.result==="error")this.emitAnalytics("subscribe.error",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onError?.(e);else if(e.result==="cancelled")return;this.opts.onClose?.(e),this.emitAnalytics("embed.close"),X(e)&&(this.closeTimer=setTimeout(()=>this.cleanup(),1500))}handleCancel(){this.emitAnalytics("embed.close");const t={source:"moment-live-embed",type:"moment.embed.result",result:"cancelled",triggerType:this.activePayload?.triggerType??"moment",momentIds:this.activePayload?.ids??[]};this.opts.onClose?.(t),this.cleanup()}cleanup(){if(this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=null),this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.viewportResizeHandler&&(window.removeEventListener("resize",this.viewportResizeHandler),this.viewportResizeHandler=null),this.overlay){const{_escHandler:e,_focusTrapHandler:t}=this.overlay;e&&document.removeEventListener("keydown",e);const i=this.overlay.firstElementChild;i&&t&&i.removeEventListener("keydown",t),this.overlay.remove(),this.overlay=null}this.iframe=null,this.wrapper=null,this.container=null,this.closeButton=null,this.activePayload=null,this.cardRadius=y,this.didManageBodyOverflow&&(document.body.style.overflow=this.previousBodyOverflow,this.didManageBodyOverflow=!1),this.previousFocusedElement&&typeof this.previousFocusedElement.focus=="function"&&this.previousFocusedElement.focus(),this.previousFocusedElement=null}emitAnalytics(e,t){this.opts.onAnalytics?.({event:e,timestamp:Date.now(),...t})}}function R(n){const e=document.createElement("button");return e.type="button",e.classList.add("moment-sync-trigger"),n.className&&n.className.split(" ").forEach(t=>{t&&e.classList.add(t)}),e.setAttribute("data-moment-team-slug",n.teamSlug),n.momentSlug&&e.setAttribute("data-moment-slug",n.momentSlug),n.listSlug&&e.setAttribute("data-moment-list-slug",n.listSlug),n.triggerType&&e.setAttribute("data-moment-trigger-type",n.triggerType),n.ids?.length&&e.setAttribute("data-moment-ids",n.ids.join(",")),n.playlistSlugs?.length&&e.setAttribute("data-moment-playlist-slugs",n.playlistSlugs.join(",")),n.calendar&&e.setAttribute("data-moment-calendar",n.calendar),n.apiSourceId&&e.setAttribute("data-api-source-id",n.apiSourceId),n.externalEventId&&e.setAttribute("data-external-event-id",n.externalEventId),n.externalEventIdPrefix&&e.setAttribute("data-external-event-id-prefix",n.externalEventIdPrefix),e.textContent=n.label??"Add to Calendar",e}if(typeof window<"u"){const n=window;n.MomentSdk=H,n.createMomentButton=R}v.MomentSdk=H,v.createMomentButton=R,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})})(this.MomentSdk=this.MomentSdk||{});
|
|
42
|
+
`;function W(){if(typeof document>"u"||document.getElementById(L))return;const n=document.createElement("style");n.id=L,n.textContent=j,document.head.appendChild(n)}function z(n){return typeof n=="string"&&n.startsWith("webcal://")}function K(n){return!n||n.closed?"blocked":"opened"}const G=1024,b=600,V=400,Y=40,O=80,M=90,Z=420,X=520,y=32,w=12,q="2147483647",J='button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex="-1"])',k="#38393B",Q="#4B4B4E",ee={position:"absolute",top:"16px",right:"16px",zIndex:"10",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:k,color:"#F5F5F5",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"};function _(n,e,t=w){const i=`${t}px ${t}px 0px 0px`;if(n<G){const s=Math.floor(e*M/100)-y;return{isTray:!0,overlay:{alignItems:"flex-end",padding:"0",backdropFilter:"none"},wrapper:{maxWidth:n<b+2*Y?"none":`${b}px`,minWidth:"0",borderRadius:i,paddingBottom:"env(safe-area-inset-bottom, 0px)"},container:{maxHeight:`calc(${M}dvh - ${y}px)`,borderRadius:i},iframeMaxHeight:s,iframeOpeningHeight:Math.min(Z,s)}}const r=e-O;return{isTray:!1,overlay:{alignItems:"center",padding:"16px",backdropFilter:"blur(2px)"},wrapper:{maxWidth:`${b}px`,minWidth:`${V}px`,borderRadius:`${t}px`,paddingBottom:"0"},container:{maxHeight:`calc(100vh - ${O}px)`,borderRadius:i},iframeMaxHeight:r,iframeOpeningHeight:Math.min(X,r)}}function te(n){return n.triggerType!=="schedule"&&n.keepOpen!==!0}const ie=32;function ne(n){const e={hideCloseButton:n.closeControl==="embed"};return typeof n.borderRadius=="number"&&Number.isFinite(n.borderRadius)&&(e.cardRadius=Math.max(0,Math.min(n.borderRadius,ie))),typeof n.surface=="string"&&n.surface!==""&&(e.surface=n.surface),e}const se=".moment-sync-trigger",re=6,R=60,oe="#0d0d0d",le="rgba(255, 255, 255, 0.216)",ae="#121316",de="https://live.dev.momentco.ai";class H{opts;liveBaseUrl;liveOrigin;overlay=null;iframe=null;wrapper=null;container=null;closeButton=null;popupBridge=null;messageHandler=null;boundClickHandlers=new Map;activePayload=null;previousFocusedElement=null;previousBodyOverflow="";didManageBodyOverflow=!1;closeTimer=null;cardRadius=w;viewportResizeHandler=null;constructor(e){this.opts={triggerSelector:se,...e},this.liveBaseUrl=de;try{this.liveOrigin=new URL(this.liveBaseUrl).origin}catch{throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`)}W(),this.bindTriggers(),this.emitAnalytics("embed.init")}open(e){e.externalEventId&&e.externalEventIdPrefix&&console.warn("[MomentSdk] Both externalEventId and externalEventIdPrefix provided; using externalEventId only.");const t=this.scopeOpenPayload(e);this.emitAnalytics("embed.open",{teamSlug:t.teamSlug,triggerType:t.triggerType}),this.createModal(t)}close(){this.handleCancel()}rebind(){this.unbindTriggers(),this.bindTriggers()}destroy(){this.cleanup(),this.unbindTriggers()}bindTriggers(){document.querySelectorAll(this.opts.triggerSelector).forEach(t=>{const i=s=>{s.preventDefault(),this.handleTriggerClick(t)},r=this.boundClickHandlers.get(t);r&&t.removeEventListener("click",r),t.addEventListener("click",i),this.boundClickHandlers.set(t,i)})}unbindTriggers(){this.boundClickHandlers.forEach((e,t)=>{t.removeEventListener("click",e)}),this.boundClickHandlers.clear()}handleTriggerClick(e){const t=e.getAttribute("data-moment-team-slug")??"",i=e.getAttribute("data-moment-slug")??void 0,r=e.getAttribute("data-moment-list-slug")??void 0,s=e.getAttribute("data-moment-trigger-type");let o="moment";s!=null&&s!==""&&(s==="moment"||s==="list"||s==="team"||s==="brand-playlist"||s==="playlist"||s==="schedule"?o=s:console.warn("[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",s));const f=e.getAttribute("data-moment-ids")??e.getAttribute("data-moment-game-id")??"",c=f?f.split(",").filter(Boolean):[],p=e.getAttribute("data-moment-playlist-slugs")??"",h=p?p.split(",").map(m=>m.trim()).filter(Boolean):[],a=e.getAttribute("data-moment-calendar");let g;a!=null&&a!==""&&(a==="google"||a==="outlook"?g=a:console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:",a));const C=e.getAttribute("data-api-source-id")??void 0,u=e.getAttribute("data-external-event-id")??void 0,l=e.getAttribute("data-external-event-id-prefix")??void 0;if(u&&l&&console.warn("[MomentSdk] Both data-external-event-id and data-external-event-id-prefix are set; using data-external-event-id only."),!t){console.warn("[MomentSdk] Missing data-moment-team-slug on trigger element");return}const d=o==="team"||o==="brand-playlist"||o==="playlist"||o==="schedule";this.emitAnalytics("embed.trigger.click",{teamSlug:t,triggerType:o,momentIds:d?[]:c}),this.open({teamSlug:t,momentSlug:i,listSlug:r,triggerType:o,ids:c,playlistSlugs:h,calendar:g??void 0,apiSourceId:C,externalEventId:l&&!u?void 0:u,externalEventIdPrefix:u?void 0:l})}scopeOpenPayload(e){return e.triggerType==="schedule"?{teamSlug:e.teamSlug,triggerType:e.triggerType}:e.triggerType==="playlist"?{teamSlug:e.teamSlug,triggerType:e.triggerType,playlistSlugs:e.playlistSlugs,calendar:e.calendar}:e.triggerType==="team"||e.triggerType==="brand-playlist"?{teamSlug:e.teamSlug,triggerType:e.triggerType,calendar:e.calendar}:e}createModal(e){this.cleanup(),this.previousFocusedElement=document.activeElement||null,this.activePayload=e;const t=this.buildIframeUrl(e);this.overlay=document.createElement("div"),this.overlay.setAttribute("role","presentation"),Object.assign(this.overlay.style,{position:"fixed",inset:"0",zIndex:q,display:"flex",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)"}),this.overlay.addEventListener("click",l=>{l.target===this.overlay&&this.handleCancel()});const i=l=>{l.key==="Escape"&&this.handleCancel()};document.addEventListener("keydown",i);const r=document.createElement("div");Object.assign(r.style,{position:"relative",width:"100%",transition:"border-radius 0.3s ease",overflow:"hidden",backgroundColor:oe,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"});const s=document.createElement("div");s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("aria-label","Calendar sync modal"),s.tabIndex=-1,Object.assign(s.style,{position:"relative",width:"100%",transition:"border-radius 0.3s ease",overflow:"auto",backgroundColor:ae,outline:"none"});const o=document.createElement("button");o.type="button",o.className=A,o.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>',o.setAttribute("aria-label","Close"),Object.assign(o.style,ee),o.addEventListener("mouseenter",()=>{o.style.backgroundColor=Q}),o.addEventListener("mouseleave",()=>{o.style.backgroundColor=k}),o.addEventListener("click",()=>this.handleCancel());const f=e.triggerType!=="schedule";this.iframe=document.createElement("iframe"),this.iframe.src=t,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,{width:"100%",border:"none",display:"block",overflow:"hidden",transition:"height 0.25s cubic-bezier(0.32, 0.72, 0, 1)"}),f&&(s.appendChild(o),this.closeButton=o),s.appendChild(this.iframe);const c=document.createElement("div");Object.assign(c.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:`${re}px`,height:`${y}px`,flexShrink:"0",boxSizing:"border-box",padding:"0"});const p=document.createElement("span");p.textContent="Powered by",Object.assign(p.style,{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:"12px",lineHeight:"16px",color:"#ffffff"});const h=document.createElement("img");h.alt="Moment",h.src=F,Object.assign(h.style,{display:"block",width:`${R}px`,height:`${(R/D).toFixed(2)}px`}),c.appendChild(p),c.appendChild(h),this.wrapper=r,this.container=s,this.applyFrameLayout();const a=document.createElement("div");a.setAttribute("aria-hidden","true"),Object.assign(a.style,{position:"absolute",inset:"0",borderRadius:"inherit",boxShadow:`inset 0 0 0 1px ${le}`,pointerEvents:"none",zIndex:"2"}),r.appendChild(s),r.appendChild(c),r.appendChild(a),this.overlay.appendChild(r),document.body.appendChild(this.overlay),this.viewportResizeHandler=()=>this.applyFrameLayout(),window.addEventListener("resize",this.viewportResizeHandler);const g=()=>s.querySelectorAll(J),C=l=>{if(l.key!=="Tab")return;const d=g(),m=d[0],P=d[d.length-1],E=document.activeElement;l.shiftKey&&(E===m||E===s)?(l.preventDefault(),P.focus()):!l.shiftKey&&E===P&&(l.preventDefault(),m.focus())};s.addEventListener("keydown",C);const u=l=>{const d=document.createElement("span");return d.tabIndex=0,Object.assign(d.style,{position:"fixed",opacity:"0"}),d.addEventListener("focus",()=>{const m=g();m[l==="first"?0:m.length-1].focus()}),d};s.before(u("last")),s.after(u("first")),s.focus(),this.previousBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.didManageBodyOverflow=!0,this.setupMessageListener(),this.overlay._escHandler=i,this.overlay._focusTrapHandler=C}applyFrameLayout(){if(!this.overlay||!this.wrapper||!this.container||!this.iframe)return;const e=_(window.innerWidth,window.innerHeight,this.cardRadius);Object.assign(this.overlay.style,e.overlay),Object.assign(this.wrapper.style,e.wrapper),Object.assign(this.container.style,e.container),this.wrapper.classList.toggle(I,e.isTray);const t=Number.parseFloat(this.iframe.style.height),i=Number.isNaN(t)?e.iframeOpeningHeight:Math.min(t,e.iframeMaxHeight);this.iframe.style.height=`${i}px`}buildIframeUrl(e){return U(this.liveBaseUrl,e)}setupMessageListener(){this.messageHandler=e=>{if(e.origin!==this.liveOrigin||e.source!==this.iframe?.contentWindow)return;const t=e.data;if(!(!t||typeof t!="object")){if(t.source==="moment-live-embed"&&t.type==="moment.embed.oauth.start"){const i=t;this.emitAnalytics("oauth.start",{provider:i.provider,teamSlug:i.teamSlug}),this.handleOAuthStart(i);return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.resize"){const i=typeof t.height=="number"?t.height:0;if(i>0&&this.iframe){const{iframeMaxHeight:r}=_(window.innerWidth,window.innerHeight);this.iframe.style.height=`${Math.min(i,r)}px`}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.theme"){const i=ne(t);i.cardRadius!==void 0&&(this.cardRadius=i.cardRadius,this.applyFrameLayout()),i.hideCloseButton&&this.closeButton&&(document.activeElement===this.closeButton&&this.container?.focus(),this.closeButton.remove()),i.surface!==void 0&&this.container&&(this.container.style.backgroundColor=i.surface);return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.open.url"){const{url:i}=t;if(z(i)){const r=K(window.open(i,"_blank"));r==="blocked"&&this.emitAnalytics("open.url.blocked",{}),this.sendOpenUrlStatus(r,i)}else this.sendOpenUrlStatus("blocked",typeof i=="string"?i:"");return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.close"){this.handleCancel();return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.result"){const i=t;this.handleResult(i)}}},window.addEventListener("message",this.messageHandler)}handleOAuthStart(e){this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.popupBridge=new N({liveBaseUrl:this.liveBaseUrl,liveOrigin:this.liveOrigin,iframeWindow:this.iframe?.contentWindow??null,onResult:t=>{this.handleResult(t)},onPopupBlocked:()=>{this.emitAnalytics("oauth.popup.blocked",{provider:e.provider})},onPopupClosed:()=>{this.emitAnalytics("oauth.popup.closed",{provider:e.provider})}}),this.popupBridge.open(e)}sendOpenUrlStatus(e,t){const i=this.iframe?.contentWindow;if(!i)return;const r={source:"moment-sdk",type:"moment.embed.open.url.status",status:e,url:t};i.postMessage(r,this.liveOrigin)}handleResult(e){if(e.result==="success"||e.result==="partial")this.emitAnalytics("subscribe.success",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onSuccess?.(e);else if(e.result==="error")this.emitAnalytics("subscribe.error",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onError?.(e);else if(e.result==="cancelled")return;this.opts.onClose?.(e),this.emitAnalytics("embed.close"),te(e)&&(this.closeTimer=setTimeout(()=>this.cleanup(),1500))}handleCancel(){this.emitAnalytics("embed.close");const t={source:"moment-live-embed",type:"moment.embed.result",result:"cancelled",triggerType:this.activePayload?.triggerType??"moment",momentIds:this.activePayload?.ids??[]};this.opts.onClose?.(t),this.cleanup()}cleanup(){if(this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=null),this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.viewportResizeHandler&&(window.removeEventListener("resize",this.viewportResizeHandler),this.viewportResizeHandler=null),this.overlay){const{_escHandler:e,_focusTrapHandler:t}=this.overlay;e&&document.removeEventListener("keydown",e);const i=this.overlay.firstElementChild;i&&t&&i.removeEventListener("keydown",t),this.overlay.remove(),this.overlay=null}this.iframe=null,this.wrapper=null,this.container=null,this.closeButton=null,this.activePayload=null,this.cardRadius=w,this.didManageBodyOverflow&&(document.body.style.overflow=this.previousBodyOverflow,this.didManageBodyOverflow=!1),this.previousFocusedElement&&typeof this.previousFocusedElement.focus=="function"&&this.previousFocusedElement.focus(),this.previousFocusedElement=null}emitAnalytics(e,t){this.opts.onAnalytics?.({event:e,timestamp:Date.now(),...t})}}function B(n){const e=document.createElement("button");return e.type="button",e.classList.add("moment-sync-trigger"),n.className&&n.className.split(" ").forEach(t=>{t&&e.classList.add(t)}),e.setAttribute("data-moment-team-slug",n.teamSlug),n.momentSlug&&e.setAttribute("data-moment-slug",n.momentSlug),n.listSlug&&e.setAttribute("data-moment-list-slug",n.listSlug),n.triggerType&&e.setAttribute("data-moment-trigger-type",n.triggerType),n.ids?.length&&e.setAttribute("data-moment-ids",n.ids.join(",")),n.playlistSlugs?.length&&e.setAttribute("data-moment-playlist-slugs",n.playlistSlugs.join(",")),n.calendar&&e.setAttribute("data-moment-calendar",n.calendar),n.apiSourceId&&e.setAttribute("data-api-source-id",n.apiSourceId),n.externalEventId&&e.setAttribute("data-external-event-id",n.externalEventId),n.externalEventIdPrefix&&e.setAttribute("data-external-event-id-prefix",n.externalEventIdPrefix),e.textContent=n.label??"Add to Calendar",e}if(typeof window<"u"){const n=window;n.MomentSdk=H,n.createMomentButton=B}v.MomentSdk=H,v.createMomentButton=B,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})})(this.MomentSdk=this.MomentSdk||{});
|
package/dist/moment-sdk.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
const H = "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",
|
|
2
|
-
function
|
|
1
|
+
const H = "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", B = 5.663533834586466;
|
|
2
|
+
function M() {
|
|
3
3
|
if (typeof window > "u") return "";
|
|
4
4
|
const n = window.location.origin, e = n === "null" ? self.origin : n;
|
|
5
5
|
return e === "null" && console.error(
|
|
6
6
|
'[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.'
|
|
7
7
|
), e;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function P(n, e, t = M()) {
|
|
10
10
|
if (e.triggerType === "schedule") {
|
|
11
11
|
const r = new URLSearchParams();
|
|
12
|
-
return r.set("teamSlug", e.teamSlug), r.set("returnOrigin", t), r.set("embed", "1"), r.set("sdkVersion", "0.8.0-dev.
|
|
12
|
+
return r.set("teamSlug", e.teamSlug), r.set("returnOrigin", t), r.set("embed", "1"), r.set("sdkVersion", "0.8.0-dev.44"), `${n}/en/embed/schedule?${r.toString()}`;
|
|
13
13
|
}
|
|
14
14
|
const i = new URLSearchParams();
|
|
15
|
-
return i.set("teamSlug", e.teamSlug), e.momentSlug && i.set("momentSlug", e.momentSlug), e.listSlug && i.set("listSlug", e.listSlug), i.set("triggerType", e.triggerType), e.ids?.length && i.set("ids", e.ids.join(",")), e.playlistSlugs?.length && i.set("playlistSlugs", e.playlistSlugs.join(",")), e.calendar && i.set("calendar", e.calendar), e.apiSourceId && i.set("subscriptionId", e.apiSourceId), e.externalEventId && i.set("externalId", e.externalEventId), e.externalEventIdPrefix && !e.externalEventId && i.set("externalIdPrefix", e.externalEventIdPrefix), i.set("returnOrigin", t), i.set("embed", "1"), i.set("sdkVersion", "0.8.0-dev.
|
|
15
|
+
return i.set("teamSlug", e.teamSlug), e.momentSlug && i.set("momentSlug", e.momentSlug), e.listSlug && i.set("listSlug", e.listSlug), i.set("triggerType", e.triggerType), e.ids?.length && i.set("ids", e.ids.join(",")), e.playlistSlugs?.length && i.set("playlistSlugs", e.playlistSlugs.join(",")), e.calendar && i.set("calendar", e.calendar), e.apiSourceId && i.set("subscriptionId", e.apiSourceId), e.externalEventId && i.set("externalId", e.externalEventId), e.externalEventIdPrefix && !e.externalEventId && i.set("externalIdPrefix", e.externalEventIdPrefix), i.set("returnOrigin", t), i.set("embed", "1"), i.set("sdkVersion", "0.8.0-dev.44"), `${n}/en/embed/sync?${i.toString()}`;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
class
|
|
17
|
+
const x = 500, S = 700, F = 500;
|
|
18
|
+
class D {
|
|
19
19
|
popup = null;
|
|
20
20
|
pollTimer = null;
|
|
21
21
|
messageHandler = null;
|
|
@@ -29,11 +29,11 @@ class P {
|
|
|
29
29
|
*/
|
|
30
30
|
open(e) {
|
|
31
31
|
this.cleanup(), this.resultReceived = !1;
|
|
32
|
-
const t = this.buildPopupUrl(e), i = Math.round(window.screenX + (window.outerWidth -
|
|
32
|
+
const t = this.buildPopupUrl(e), i = Math.round(window.screenX + (window.outerWidth - x) / 2), r = Math.round(window.screenY + (window.outerHeight - S) / 2);
|
|
33
33
|
if (this.popup = window.open(
|
|
34
34
|
t,
|
|
35
35
|
"moment-oauth-popup",
|
|
36
|
-
`width=${
|
|
36
|
+
`width=${x},height=${S},left=${i},top=${r},menubar=no,toolbar=no,location=yes,status=no`
|
|
37
37
|
), !this.popup || this.popup.closed) {
|
|
38
38
|
this.sendStatusToIframe("popup-blocked"), this.opts.onPopupBlocked();
|
|
39
39
|
return;
|
|
@@ -56,7 +56,7 @@ class P {
|
|
|
56
56
|
this.popup = null;
|
|
57
57
|
}
|
|
58
58
|
buildPopupUrl(e) {
|
|
59
|
-
const t =
|
|
59
|
+
const t = M(), i = new URLSearchParams({
|
|
60
60
|
provider: e.provider,
|
|
61
61
|
teamSlug: e.teamSlug,
|
|
62
62
|
ids: e.ids.join(","),
|
|
@@ -68,7 +68,7 @@ class P {
|
|
|
68
68
|
startPolling() {
|
|
69
69
|
this.pollTimer = setInterval(() => {
|
|
70
70
|
(!this.popup || this.popup.closed) && (this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null), this.resultReceived || (this.sendStatusToIframe("popup-closed"), this.opts.onPopupClosed()), this.cleanup());
|
|
71
|
-
},
|
|
71
|
+
}, F);
|
|
72
72
|
}
|
|
73
73
|
sendStatusToIframe(e) {
|
|
74
74
|
if (!this.opts.iframeWindow) return;
|
|
@@ -80,7 +80,7 @@ class P {
|
|
|
80
80
|
this.opts.iframeWindow.postMessage(t, this.opts.liveOrigin);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
const
|
|
83
|
+
const T = "moment-sdk-styles", _ = "moment-sdk-close", k = "moment-sdk-tray", U = `
|
|
84
84
|
:where(.moment-sync-trigger) {
|
|
85
85
|
background-color: #1c1917;
|
|
86
86
|
color: #ffffff;
|
|
@@ -105,10 +105,10 @@ const S = "moment-sdk-styles", M = "moment-sdk-close", k = "moment-sdk-tray", F
|
|
|
105
105
|
outline-offset: 2px;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
.${
|
|
109
|
-
outline: 2px solid #
|
|
110
|
-
outline-offset:
|
|
111
|
-
|
|
108
|
+
.${_}:focus-visible {
|
|
109
|
+
outline: 2px solid #ffffff;
|
|
110
|
+
outline-offset: 0;
|
|
111
|
+
box-shadow: 0 0 0 4px #121316;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
@keyframes moment-sdk-tray-in {
|
|
@@ -122,27 +122,47 @@ const S = "moment-sdk-styles", M = "moment-sdk-close", k = "moment-sdk-tray", F
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
`;
|
|
125
|
-
function
|
|
126
|
-
if (typeof document > "u" || document.getElementById(
|
|
125
|
+
function $() {
|
|
126
|
+
if (typeof document > "u" || document.getElementById(T)) return;
|
|
127
127
|
const n = document.createElement("style");
|
|
128
|
-
n.id =
|
|
128
|
+
n.id = T, n.textContent = U, document.head.appendChild(n);
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function N(n) {
|
|
131
131
|
return typeof n == "string" && n.startsWith("webcal://");
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function j(n) {
|
|
134
134
|
return !n || n.closed ? "blocked" : "opened";
|
|
135
135
|
}
|
|
136
|
-
const
|
|
137
|
-
|
|
136
|
+
const W = 1024, b = 600, z = 400, K = 40, L = 80, A = 90, G = 420, V = 520, y = 32, w = 12, Y = "2147483647", Z = 'button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex="-1"])', R = "#38393B", X = "#4B4B4E", q = {
|
|
137
|
+
position: "absolute",
|
|
138
|
+
top: "16px",
|
|
139
|
+
right: "16px",
|
|
140
|
+
zIndex: "10",
|
|
141
|
+
width: "40px",
|
|
142
|
+
height: "40px",
|
|
143
|
+
padding: "0",
|
|
144
|
+
border: "none",
|
|
145
|
+
borderRadius: "50%",
|
|
146
|
+
backgroundColor: R,
|
|
147
|
+
color: "#F5F5F5",
|
|
148
|
+
cursor: "pointer",
|
|
149
|
+
display: "flex",
|
|
150
|
+
alignItems: "center",
|
|
151
|
+
justifyContent: "center"
|
|
152
|
+
};
|
|
153
|
+
function I(n, e, t = w) {
|
|
138
154
|
const i = `${t}px ${t}px 0px 0px`;
|
|
139
|
-
if (n <
|
|
140
|
-
const s = Math.floor(e *
|
|
155
|
+
if (n < W) {
|
|
156
|
+
const s = Math.floor(e * A / 100) - y;
|
|
141
157
|
return {
|
|
142
158
|
isTray: !0,
|
|
143
|
-
|
|
159
|
+
// No blur: iPhone Safari tints its status bar and toolbar from the page, and over a blurred
|
|
160
|
+
// backdrop it keeps the host page's colours instead of dimming them with the page.
|
|
161
|
+
overlay: { alignItems: "flex-end", padding: "0", backdropFilter: "none" },
|
|
144
162
|
wrapper: {
|
|
145
|
-
|
|
163
|
+
// The modal's width: at full width on a tablet the embed's pills and rows stretched. Only
|
|
164
|
+
// once that leaves 40px each side: at 600–679px it left a sliver of the page down each side.
|
|
165
|
+
maxWidth: n < b + 2 * K ? "none" : `${b}px`,
|
|
146
166
|
minWidth: "0",
|
|
147
167
|
borderRadius: i,
|
|
148
168
|
paddingBottom: "env(safe-area-inset-bottom, 0px)"
|
|
@@ -150,41 +170,41 @@ function A(n, e, t = y) {
|
|
|
150
170
|
container: {
|
|
151
171
|
// ponytail: no vh fallback for browsers without dvh (Safari < 15.4); the iframe cap still
|
|
152
172
|
// holds there.
|
|
153
|
-
maxHeight: `calc(${
|
|
173
|
+
maxHeight: `calc(${A}dvh - ${y}px)`,
|
|
154
174
|
borderRadius: i
|
|
155
175
|
},
|
|
156
176
|
iframeMaxHeight: s,
|
|
157
|
-
iframeOpeningHeight: Math.min(
|
|
177
|
+
iframeOpeningHeight: Math.min(G, s)
|
|
158
178
|
};
|
|
159
179
|
}
|
|
160
|
-
const r = e -
|
|
180
|
+
const r = e - L;
|
|
161
181
|
return {
|
|
162
182
|
isTray: !1,
|
|
163
|
-
overlay: { alignItems: "center", padding: "16px" },
|
|
183
|
+
overlay: { alignItems: "center", padding: "16px", backdropFilter: "blur(2px)" },
|
|
164
184
|
wrapper: {
|
|
165
|
-
maxWidth: `${
|
|
166
|
-
minWidth: `${
|
|
185
|
+
maxWidth: `${b}px`,
|
|
186
|
+
minWidth: `${z}px`,
|
|
167
187
|
borderRadius: `${t}px`,
|
|
168
188
|
paddingBottom: "0"
|
|
169
189
|
},
|
|
170
190
|
container: {
|
|
171
|
-
maxHeight: `calc(100vh - ${
|
|
191
|
+
maxHeight: `calc(100vh - ${L}px)`,
|
|
172
192
|
borderRadius: i
|
|
173
193
|
},
|
|
174
194
|
iframeMaxHeight: r,
|
|
175
|
-
iframeOpeningHeight: Math.min(
|
|
195
|
+
iframeOpeningHeight: Math.min(V, r)
|
|
176
196
|
};
|
|
177
197
|
}
|
|
178
|
-
function
|
|
198
|
+
function J(n) {
|
|
179
199
|
return n.triggerType !== "schedule" && n.keepOpen !== !0;
|
|
180
200
|
}
|
|
181
|
-
const
|
|
182
|
-
function
|
|
201
|
+
const Q = 32;
|
|
202
|
+
function ee(n) {
|
|
183
203
|
const e = { hideCloseButton: n.closeControl === "embed" };
|
|
184
|
-
return typeof n.borderRadius == "number" && Number.isFinite(n.borderRadius) && (e.cardRadius = Math.max(0, Math.min(n.borderRadius,
|
|
204
|
+
return typeof n.borderRadius == "number" && Number.isFinite(n.borderRadius) && (e.cardRadius = Math.max(0, Math.min(n.borderRadius, Q))), typeof n.surface == "string" && n.surface !== "" && (e.surface = n.surface), e;
|
|
185
205
|
}
|
|
186
|
-
const
|
|
187
|
-
class
|
|
206
|
+
const te = ".moment-sync-trigger", ie = 6, O = 60, ne = "#0d0d0d", se = "rgba(255, 255, 255, 0.216)", re = "#121316", oe = "https://live.dev.momentco.ai";
|
|
207
|
+
class le {
|
|
188
208
|
opts;
|
|
189
209
|
liveBaseUrl;
|
|
190
210
|
liveOrigin;
|
|
@@ -205,19 +225,19 @@ class ie {
|
|
|
205
225
|
didManageBodyOverflow = !1;
|
|
206
226
|
closeTimer = null;
|
|
207
227
|
// The card radius the frame is laid out with: the default until a theme hint sends the brand's.
|
|
208
|
-
cardRadius =
|
|
228
|
+
cardRadius = w;
|
|
209
229
|
viewportResizeHandler = null;
|
|
210
230
|
constructor(e) {
|
|
211
231
|
this.opts = {
|
|
212
|
-
triggerSelector:
|
|
232
|
+
triggerSelector: te,
|
|
213
233
|
...e
|
|
214
|
-
}, this.liveBaseUrl =
|
|
234
|
+
}, this.liveBaseUrl = oe;
|
|
215
235
|
try {
|
|
216
236
|
this.liveOrigin = new URL(this.liveBaseUrl).origin;
|
|
217
237
|
} catch {
|
|
218
238
|
throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`);
|
|
219
239
|
}
|
|
220
|
-
|
|
240
|
+
$(), this.bindTriggers(), this.emitAnalytics("embed.init");
|
|
221
241
|
}
|
|
222
242
|
/**
|
|
223
243
|
* Programmatically open the sync modal.
|
|
@@ -322,11 +342,10 @@ class ie {
|
|
|
322
342
|
this.overlay = document.createElement("div"), this.overlay.setAttribute("role", "presentation"), Object.assign(this.overlay.style, {
|
|
323
343
|
position: "fixed",
|
|
324
344
|
inset: "0",
|
|
325
|
-
zIndex:
|
|
345
|
+
zIndex: Y,
|
|
326
346
|
display: "flex",
|
|
327
347
|
justifyContent: "center",
|
|
328
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
329
|
-
backdropFilter: "blur(2px)"
|
|
348
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
330
349
|
}), this.overlay.addEventListener("click", (l) => {
|
|
331
350
|
l.target === this.overlay && this.handleCancel();
|
|
332
351
|
});
|
|
@@ -343,7 +362,7 @@ class ie {
|
|
|
343
362
|
// smoothly instead of snapping.
|
|
344
363
|
transition: "border-radius 0.3s ease",
|
|
345
364
|
overflow: "hidden",
|
|
346
|
-
backgroundColor:
|
|
365
|
+
backgroundColor: ne,
|
|
347
366
|
boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
|
348
367
|
display: "flex",
|
|
349
368
|
flexDirection: "column"
|
|
@@ -356,7 +375,7 @@ class ie {
|
|
|
356
375
|
overflow: "auto",
|
|
357
376
|
// The sheet colour Live's embeds paint, so the card never flashes white before the
|
|
358
377
|
// embed's theme (and its own `surface`) arrives.
|
|
359
|
-
backgroundColor:
|
|
378
|
+
backgroundColor: re,
|
|
360
379
|
// `tabIndex = -1` above makes this a programmatic focus target for the
|
|
361
380
|
// focus trap, never a Tab stop — but browsers still draw their platform
|
|
362
381
|
// focus ring (blue on stock macOS/Windows) around the whole card when we
|
|
@@ -365,25 +384,10 @@ class ie {
|
|
|
365
384
|
outline: "none"
|
|
366
385
|
});
|
|
367
386
|
const o = document.createElement("button");
|
|
368
|
-
o.type = "button", o.className =
|
|
369
|
-
|
|
370
|
-
top: "10px",
|
|
371
|
-
right: "10px",
|
|
372
|
-
zIndex: "10",
|
|
373
|
-
border: "none",
|
|
374
|
-
backgroundColor: "transparent",
|
|
375
|
-
color: "#999",
|
|
376
|
-
cursor: "pointer",
|
|
377
|
-
display: "flex",
|
|
378
|
-
alignItems: "center",
|
|
379
|
-
justifyContent: "center",
|
|
380
|
-
width: "24px",
|
|
381
|
-
height: "24px",
|
|
382
|
-
padding: "0"
|
|
383
|
-
}), o.addEventListener("mouseenter", () => {
|
|
384
|
-
o.style.color = "#666";
|
|
387
|
+
o.type = "button", o.className = _, o.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>', o.setAttribute("aria-label", "Close"), Object.assign(o.style, q), o.addEventListener("mouseenter", () => {
|
|
388
|
+
o.style.backgroundColor = X;
|
|
385
389
|
}), o.addEventListener("mouseleave", () => {
|
|
386
|
-
o.style.
|
|
390
|
+
o.style.backgroundColor = R;
|
|
387
391
|
}), o.addEventListener("click", () => this.handleCancel());
|
|
388
392
|
const f = e.triggerType !== "schedule";
|
|
389
393
|
this.iframe = document.createElement("iframe"), this.iframe.src = t, 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, {
|
|
@@ -401,8 +405,8 @@ class ie {
|
|
|
401
405
|
display: "flex",
|
|
402
406
|
alignItems: "center",
|
|
403
407
|
justifyContent: "center",
|
|
404
|
-
gap: `${
|
|
405
|
-
height: `${
|
|
408
|
+
gap: `${ie}px`,
|
|
409
|
+
height: `${y}px`,
|
|
406
410
|
// The wrapper is a flex column, so without this the tray would be the
|
|
407
411
|
// first thing squeezed when the card hits its max height.
|
|
408
412
|
flexShrink: "0",
|
|
@@ -422,22 +426,22 @@ class ie {
|
|
|
422
426
|
display: "block",
|
|
423
427
|
// Both dimensions are explicit so the tray has no reflow to do, even if
|
|
424
428
|
// the image is ever swapped for one that has to decode.
|
|
425
|
-
width: `${
|
|
426
|
-
height: `${(
|
|
429
|
+
width: `${O}px`,
|
|
430
|
+
height: `${(O / B).toFixed(2)}px`
|
|
427
431
|
}), c.appendChild(p), c.appendChild(h), this.wrapper = r, this.container = s, this.applyFrameLayout();
|
|
428
432
|
const a = document.createElement("div");
|
|
429
433
|
a.setAttribute("aria-hidden", "true"), Object.assign(a.style, {
|
|
430
434
|
position: "absolute",
|
|
431
435
|
inset: "0",
|
|
432
436
|
borderRadius: "inherit",
|
|
433
|
-
boxShadow: `inset 0 0 0 1px ${
|
|
437
|
+
boxShadow: `inset 0 0 0 1px ${se}`,
|
|
434
438
|
pointerEvents: "none",
|
|
435
439
|
zIndex: "2"
|
|
436
440
|
}), r.appendChild(s), r.appendChild(c), r.appendChild(a), this.overlay.appendChild(r), document.body.appendChild(this.overlay), this.viewportResizeHandler = () => this.applyFrameLayout(), window.addEventListener("resize", this.viewportResizeHandler);
|
|
437
|
-
const g = () => s.querySelectorAll(
|
|
441
|
+
const g = () => s.querySelectorAll(Z), C = (l) => {
|
|
438
442
|
if (l.key !== "Tab") return;
|
|
439
|
-
const d = g(), m = d[0],
|
|
440
|
-
l.shiftKey && (v === m || v === s) ? (l.preventDefault(),
|
|
443
|
+
const d = g(), m = d[0], E = d[d.length - 1], v = document.activeElement;
|
|
444
|
+
l.shiftKey && (v === m || v === s) ? (l.preventDefault(), E.focus()) : !l.shiftKey && v === E && (l.preventDefault(), m.focus());
|
|
441
445
|
};
|
|
442
446
|
s.addEventListener("keydown", C);
|
|
443
447
|
const u = (l) => {
|
|
@@ -455,13 +459,13 @@ class ie {
|
|
|
455
459
|
*/
|
|
456
460
|
applyFrameLayout() {
|
|
457
461
|
if (!this.overlay || !this.wrapper || !this.container || !this.iframe) return;
|
|
458
|
-
const e =
|
|
462
|
+
const e = I(window.innerWidth, window.innerHeight, this.cardRadius);
|
|
459
463
|
Object.assign(this.overlay.style, e.overlay), Object.assign(this.wrapper.style, e.wrapper), Object.assign(this.container.style, e.container), this.wrapper.classList.toggle(k, e.isTray);
|
|
460
464
|
const t = Number.parseFloat(this.iframe.style.height), i = Number.isNaN(t) ? e.iframeOpeningHeight : Math.min(t, e.iframeMaxHeight);
|
|
461
465
|
this.iframe.style.height = `${i}px`;
|
|
462
466
|
}
|
|
463
467
|
buildIframeUrl(e) {
|
|
464
|
-
return
|
|
468
|
+
return P(this.liveBaseUrl, e);
|
|
465
469
|
}
|
|
466
470
|
// ── Private: message handling ─────────────────────────────────────
|
|
467
471
|
setupMessageListener() {
|
|
@@ -480,20 +484,20 @@ class ie {
|
|
|
480
484
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.resize") {
|
|
481
485
|
const i = typeof t.height == "number" ? t.height : 0;
|
|
482
486
|
if (i > 0 && this.iframe) {
|
|
483
|
-
const { iframeMaxHeight: r } =
|
|
487
|
+
const { iframeMaxHeight: r } = I(window.innerWidth, window.innerHeight);
|
|
484
488
|
this.iframe.style.height = `${Math.min(i, r)}px`;
|
|
485
489
|
}
|
|
486
490
|
return;
|
|
487
491
|
}
|
|
488
492
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.theme") {
|
|
489
|
-
const i =
|
|
493
|
+
const i = ee(t);
|
|
490
494
|
i.cardRadius !== void 0 && (this.cardRadius = i.cardRadius, this.applyFrameLayout()), i.hideCloseButton && this.closeButton && (document.activeElement === this.closeButton && this.container?.focus(), this.closeButton.remove()), i.surface !== void 0 && this.container && (this.container.style.backgroundColor = i.surface);
|
|
491
495
|
return;
|
|
492
496
|
}
|
|
493
497
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.open.url") {
|
|
494
498
|
const { url: i } = t;
|
|
495
|
-
if (
|
|
496
|
-
const r =
|
|
499
|
+
if (N(i)) {
|
|
500
|
+
const r = j(window.open(i, "_blank"));
|
|
497
501
|
r === "blocked" && this.emitAnalytics("open.url.blocked", {}), this.sendOpenUrlStatus(r, i);
|
|
498
502
|
} else
|
|
499
503
|
this.sendOpenUrlStatus("blocked", typeof i == "string" ? i : "");
|
|
@@ -511,7 +515,7 @@ class ie {
|
|
|
511
515
|
}, window.addEventListener("message", this.messageHandler);
|
|
512
516
|
}
|
|
513
517
|
handleOAuthStart(e) {
|
|
514
|
-
this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.popupBridge = new
|
|
518
|
+
this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.popupBridge = new D({
|
|
515
519
|
liveBaseUrl: this.liveBaseUrl,
|
|
516
520
|
liveOrigin: this.liveOrigin,
|
|
517
521
|
iframeWindow: this.iframe?.contentWindow ?? null,
|
|
@@ -560,7 +564,7 @@ class ie {
|
|
|
560
564
|
}), this.opts.onError?.(e);
|
|
561
565
|
else if (e.result === "cancelled")
|
|
562
566
|
return;
|
|
563
|
-
this.opts.onClose?.(e), this.emitAnalytics("embed.close"),
|
|
567
|
+
this.opts.onClose?.(e), this.emitAnalytics("embed.close"), J(e) && (this.closeTimer = setTimeout(() => this.cleanup(), 1500));
|
|
564
568
|
}
|
|
565
569
|
handleCancel() {
|
|
566
570
|
this.emitAnalytics("embed.close");
|
|
@@ -581,7 +585,7 @@ class ie {
|
|
|
581
585
|
const i = this.overlay.firstElementChild;
|
|
582
586
|
i && t && i.removeEventListener("keydown", t), this.overlay.remove(), this.overlay = null;
|
|
583
587
|
}
|
|
584
|
-
this.iframe = null, this.wrapper = null, this.container = null, this.closeButton = null, this.activePayload = null, this.cardRadius =
|
|
588
|
+
this.iframe = null, this.wrapper = null, this.container = null, this.closeButton = null, this.activePayload = null, this.cardRadius = w, this.didManageBodyOverflow && (document.body.style.overflow = this.previousBodyOverflow, this.didManageBodyOverflow = !1), this.previousFocusedElement && typeof this.previousFocusedElement.focus == "function" && this.previousFocusedElement.focus(), this.previousFocusedElement = null;
|
|
585
589
|
}
|
|
586
590
|
// ── Private: analytics ────────────────────────────────────────────
|
|
587
591
|
emitAnalytics(e, t) {
|
|
@@ -592,7 +596,7 @@ class ie {
|
|
|
592
596
|
});
|
|
593
597
|
}
|
|
594
598
|
}
|
|
595
|
-
function
|
|
599
|
+
function ae(n) {
|
|
596
600
|
const e = document.createElement("button");
|
|
597
601
|
return e.type = "button", e.classList.add("moment-sync-trigger"), n.className && n.className.split(" ").forEach((t) => {
|
|
598
602
|
t && e.classList.add(t);
|
|
@@ -600,9 +604,9 @@ function ne(n) {
|
|
|
600
604
|
}
|
|
601
605
|
if (typeof window < "u") {
|
|
602
606
|
const n = window;
|
|
603
|
-
n.MomentSdk =
|
|
607
|
+
n.MomentSdk = le, n.createMomentButton = ae;
|
|
604
608
|
}
|
|
605
609
|
export {
|
|
606
|
-
|
|
607
|
-
|
|
610
|
+
le as MomentSdk,
|
|
611
|
+
ae as createMomentButton
|
|
608
612
|
};
|
|
@@ -10,17 +10,40 @@ import type { MomentResultPayload } from './types';
|
|
|
10
10
|
export declare const FOOTER_HEIGHT = 32;
|
|
11
11
|
/** The card's corner radius in px until the embed sends a brand radius. */
|
|
12
12
|
export declare const DEFAULT_CARD_RADIUS = 12;
|
|
13
|
+
/**
|
|
14
|
+
* The overlay's z-index, the highest a browser allows. Cookie-consent banners sit as high as
|
|
15
|
+
* 2147483645 and dock to the bottom edge, where the tray opens. The overlay goes at the end of
|
|
16
|
+
* `body` when the sheet opens, so it also wins a tie with anything already on the page. The sheet
|
|
17
|
+
* opens on a tap or when the host page calls `open()`, so a page that calls `open()` before its
|
|
18
|
+
* consent wall is answered puts the sheet over that wall. A banner that doesn't block the page
|
|
19
|
+
* shows again once the sheet closes.
|
|
20
|
+
*/
|
|
21
|
+
export declare const OVERLAY_Z_INDEX = "2147483647";
|
|
13
22
|
/**
|
|
14
23
|
* What the modal's focus trap counts as a Tab stop inside the card. The iframe is one, so Tab
|
|
15
24
|
* moves into the embed, where the calendar buttons are.
|
|
16
25
|
*/
|
|
17
26
|
export declare const MODAL_FOCUSABLE_SELECTOR = "button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex=\"-1\"])";
|
|
27
|
+
/**
|
|
28
|
+
* The ✕'s fill: the colour the embed's own ✕ (white at 16%) makes over the #121316 card. Opaque,
|
|
29
|
+
* because for a frame during the hand-over the embed's ✕ already shows under this one, and two
|
|
30
|
+
* translucent discs would stack into a brighter one.
|
|
31
|
+
*/
|
|
32
|
+
export declare const CLOSE_BUTTON_BACKGROUND = "#38393B";
|
|
33
|
+
/** The ✕'s fill on hover: the embed's white at 24% over the card, made opaque the same way. */
|
|
34
|
+
export declare const CLOSE_BUTTON_BACKGROUND_HOVER = "#4B4B4E";
|
|
35
|
+
/**
|
|
36
|
+
* The ✕'s inline styles: a 40px disc 16px from the card's top and right, with a #F5F5F5 glyph.
|
|
37
|
+
* The embed draws its own ✕ the same way in the same place, so when `closeControl: 'embed'` hands
|
|
38
|
+
* over, the ✕ neither moves nor changes. Inline, so a host page's `button` rules don't outrank them.
|
|
39
|
+
*/
|
|
40
|
+
export declare const CLOSE_BUTTON_STYLE: Partial<CSSStyleDeclaration>;
|
|
18
41
|
/** Inline styles and iframe heights for the frame at one viewport size. */
|
|
19
42
|
export interface FrameLayout {
|
|
20
|
-
/** True below 1024px: a
|
|
43
|
+
/** True below 1024px: a sheet docked to the bottom edge, full width or 600px with 40px+ sides. */
|
|
21
44
|
isTray: boolean;
|
|
22
|
-
/** The dimmed backdrop that places the frame. */
|
|
23
|
-
overlay: Pick<CSSStyleDeclaration, 'alignItems' | 'padding'>;
|
|
45
|
+
/** The dimmed backdrop that places the frame, blurred only behind the desktop modal. */
|
|
46
|
+
overlay: Pick<CSSStyleDeclaration, 'alignItems' | 'padding' | 'backdropFilter'>;
|
|
24
47
|
/** The dark frame around the card and the footer. */
|
|
25
48
|
wrapper: Pick<CSSStyleDeclaration, 'maxWidth' | 'minWidth' | 'borderRadius' | 'paddingBottom'>;
|
|
26
49
|
/** The card that holds the iframe. */
|
|
@@ -20,6 +20,6 @@ export declare const MODAL_TRAY_CLASS = "moment-sdk-tray";
|
|
|
20
20
|
* OS accent colour — blue on stock macOS and Windows), and a host page's global
|
|
21
21
|
* `button:focus` must not be able to put that back.
|
|
22
22
|
*/
|
|
23
|
-
export declare const SDK_STYLES = "\n:where(.moment-sync-trigger) {\n background-color: #1c1917;\n color: #ffffff;\n border: 1px solid #292524;\n border-radius: 4px;\n padding: 8px 16px;\n font-size: 14px;\n font-weight: 500;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n line-height: 1.4;\n cursor: pointer;\n appearance: none;\n -webkit-appearance: none;\n}\n\n:where(.moment-sync-trigger:hover) {\n background-color: #292524;\n}\n\n:where(.moment-sync-trigger:focus-visible) {\n outline: 2px solid #1c1917;\n outline-offset: 2px;\n}\n\n.moment-sdk-close:focus-visible {\n outline: 2px solid #
|
|
23
|
+
export declare const SDK_STYLES = "\n:where(.moment-sync-trigger) {\n background-color: #1c1917;\n color: #ffffff;\n border: 1px solid #292524;\n border-radius: 4px;\n padding: 8px 16px;\n font-size: 14px;\n font-weight: 500;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n line-height: 1.4;\n cursor: pointer;\n appearance: none;\n -webkit-appearance: none;\n}\n\n:where(.moment-sync-trigger:hover) {\n background-color: #292524;\n}\n\n:where(.moment-sync-trigger:focus-visible) {\n outline: 2px solid #1c1917;\n outline-offset: 2px;\n}\n\n.moment-sdk-close:focus-visible {\n outline: 2px solid #ffffff;\n outline-offset: 0;\n box-shadow: 0 0 0 4px #121316;\n}\n\n@keyframes moment-sdk-tray-in {\n from { transform: translateY(100%); }\n to { transform: translateY(0); }\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .moment-sdk-tray {\n animation: moment-sdk-tray-in 0.35s cubic-bezier(0.32, 0.72, 0, 1);\n }\n}\n";
|
|
24
24
|
/** Inject the SDK's styles once per page. */
|
|
25
25
|
export declare function injectSdkStyles(): void;
|
package/package.json
CHANGED