@momentco-ai/moment-sdk 0.4.0-dev.28 → 0.5.0-dev.30

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.
@@ -1,4 +1,4 @@
1
- (function(v){"use strict";class x{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-500)/2),o=Math.round(window.screenY+(window.outerHeight-700)/2);if(this.popup=window.open(t,"moment-oauth-popup",`width=500,height=700,left=${i},top=${o},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 r=s.data;!r||typeof r!="object"||r.source!=="moment-live-embed"||r.type!=="moment.embed.result"||(this.resultReceived=!0,this.sendStatusToIframe("completed"),this.opts.iframeWindow&&this.opts.iframeWindow.postMessage(r,this.opts.liveOrigin),this.opts.onResult(r),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=window.location.origin,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())},500)}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)}}function S(n,e,t=typeof window<"u"?window.location.origin:""){if(e.triggerType==="schedule"){const o=new URLSearchParams;return o.set("teamSlug",e.teamSlug),o.set("returnOrigin",t),o.set("embed","1"),`${n}/en/embed/schedule?${o.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"),`${n}/en/embed/sync?${i.toString()}`}const b="moment-sdk-trigger-styles",T=`
1
+ (function(b){"use strict";class P{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-500)/2),o=Math.round(window.screenY+(window.outerHeight-700)/2);if(this.popup=window.open(t,"moment-oauth-popup",`width=500,height=700,left=${i},top=${o},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=n=>{if(n.origin!==this.opts.liveOrigin||n.source!==this.popup)return;const r=n.data;!r||typeof r!="object"||r.source!=="moment-live-embed"||r.type!=="moment.embed.result"||(this.resultReceived=!0,this.sendStatusToIframe("completed"),this.opts.iframeWindow&&this.opts.iframeWindow.postMessage(r,this.opts.liveOrigin),this.opts.onResult(r),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=window.location.origin,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())},500)}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)}}function k(s,e,t=typeof window<"u"?window.location.origin:""){if(e.triggerType==="schedule"){const o=new URLSearchParams;return o.set("teamSlug",e.teamSlug),o.set("returnOrigin",t),o.set("embed","1"),`${s}/en/embed/schedule?${o.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"),`${s}/en/embed/sync?${i.toString()}`}const y="moment-sdk-trigger-styles",A=`
2
2
  :where(.moment-sync-trigger) {
3
3
  background-color: #1c1917;
4
4
  color: #ffffff;
@@ -22,4 +22,4 @@
22
22
  outline: 2px solid #1c1917;
23
23
  outline-offset: 2px;
24
24
  }
25
- `;function E(){if(typeof document>"u"||document.getElementById(b))return;const n=document.createElement("style");n.id=b,n.textContent=T,document.head.appendChild(n)}const I=".moment-sync-trigger",P="https://live.dev.momentco.ai";class y{opts;liveBaseUrl;liveOrigin;overlay=null;iframe=null;wrapper=null;container=null;popupBridge=null;messageHandler=null;boundClickHandlers=new Map;activePayload=null;previousFocusedElement=null;previousBodyOverflow="";didManageBodyOverflow=!1;closeTimer=null;constructor(e){this.opts={triggerSelector:I,...e},this.liveBaseUrl=P;try{this.liveOrigin=new URL(this.liveBaseUrl).origin}catch{throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`)}E(),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)},o=this.boundClickHandlers.get(t);o&&t.removeEventListener("click",o),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,o=e.getAttribute("data-moment-list-slug")??void 0,s=e.getAttribute("data-moment-trigger-type");let r="moment";s!=null&&s!==""&&(s==="moment"||s==="list"||s==="team"||s==="brand-playlist"||s==="playlist"||s==="schedule"?r=s:console.warn("[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",s));const h=e.getAttribute("data-moment-ids")??e.getAttribute("data-moment-game-id")??"",d=h?h.split(",").filter(Boolean):[],c=e.getAttribute("data-moment-playlist-slugs")??"",m=c?c.split(",").map(k=>k.trim()).filter(Boolean):[],a=e.getAttribute("data-moment-calendar");let l;a!=null&&a!==""&&(a==="google"||a==="outlook"?l=a:console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:",a));const p=e.getAttribute("data-api-source-id")??void 0,u=e.getAttribute("data-external-event-id")??void 0,g=e.getAttribute("data-external-event-id-prefix")??void 0;if(u&&g&&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 f=r==="team"||r==="brand-playlist"||r==="playlist"||r==="schedule";this.emitAnalytics("embed.trigger.click",{teamSlug:t,triggerType:r,momentIds:f?[]:d}),this.open({teamSlug:t,momentSlug:i,listSlug:o,triggerType:r,ids:d,playlistSlugs:m,calendar:l??void 0,apiSourceId:p,externalEventId:g&&!u?void 0:u,externalEventIdPrefix:u?void 0:g})}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",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(2px)",padding:"16px"}),this.overlay.addEventListener("click",l=>{l.target===this.overlay&&this.handleCancel()});const i=l=>{l.key==="Escape"&&this.handleCancel()};document.addEventListener("keydown",i);const o=document.createElement("div");Object.assign(o.style,{position:"relative",width:"100%",maxWidth:"380px",borderRadius:"16px",transition:"border-radius 0.3s ease",overflow:"hidden",backgroundColor:"#000000",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%",maxHeight:"80vh",borderRadius:"12px",transition:"border-radius 0.3s ease",overflow:"auto",backgroundColor:"#ffffff"});const r=document.createElement("button");r.type="button",r.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>',r.setAttribute("aria-label","Close"),Object.assign(r.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"}),r.addEventListener("mouseenter",()=>{r.style.color="#666"}),r.addEventListener("mouseleave",()=>{r.style.color="#999"}),r.addEventListener("click",()=>this.handleCancel());const h=e.triggerType!=="schedule";this.iframe=document.createElement("iframe"),this.iframe.src=t,this.iframe.setAttribute("allow",""),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",height:"420px",overflow:"hidden",transition:"height 0.15s ease"}),h&&s.appendChild(r),s.appendChild(this.iframe);const d=document.createElement("div");Object.assign(d.style,{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px 0"});const c=document.createElement("span");c.textContent="Powered by",Object.assign(c.style,{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:"12px",lineHeight:"16px",color:"#ffffff"});const m=document.createElement("img");m.alt="Moment",m.src=`${this.liveBaseUrl}/brand/moment-text-white.png`,Object.assign(m.style,{height:"auto",width:"67px",paddingTop:"2px"}),d.appendChild(c),d.appendChild(m),this.wrapper=o,this.container=s,o.appendChild(s),o.appendChild(d),this.overlay.appendChild(o),document.body.appendChild(this.overlay);const a=l=>{if(l.key!=="Tab")return;const p=s.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(p.length===0){l.preventDefault(),s.focus();return}const u=p[0],g=p[p.length-1],f=document.activeElement;l.shiftKey&&f===u?(l.preventDefault(),g.focus()):!l.shiftKey&&f===g&&(l.preventDefault(),u.focus())};s.addEventListener("keydown",a),h?r.focus():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=a}buildIframeUrl(e){return S(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 o=Math.round(window.innerHeight*.8);this.iframe.style.height=`${Math.min(i,o)}px`}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.theme"){const{borderRadius:i}=t;if(typeof i=="number"&&Number.isFinite(i)){const o=Math.max(0,Math.min(i,32));this.container&&(this.container.style.borderRadius=`${o}px`),this.wrapper&&(this.wrapper.style.borderRadius=o===0?"0px":`${o+4}px`)}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.open.url"){const{url:i}=t;i&&typeof i=="string"&&i.startsWith("webcal://")&&window.open(i,"_blank");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 x({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)}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"),e.triggerType!=="schedule"&&(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.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.activePayload=null,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 w(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=y,n.createMomentButton=w}v.MomentSdk=y,v.createMomentButton=w,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})})(this.MomentSdk=this.MomentSdk||{});
25
+ `;function H(){if(typeof document>"u"||document.getElementById(y))return;const s=document.createElement("style");s.id=y,s.textContent=A,document.head.appendChild(s)}const M=".moment-sync-trigger",w=1024,x=380,T=600,S=400,f=80,L="https://live.dev.momentco.ai";class E{opts;liveBaseUrl;liveOrigin;overlay=null;iframe=null;wrapper=null;container=null;popupBridge=null;messageHandler=null;boundClickHandlers=new Map;activePayload=null;previousFocusedElement=null;previousBodyOverflow="";didManageBodyOverflow=!1;closeTimer=null;isDesktopViewport=!1;viewportResizeHandler=null;constructor(e){this.opts={triggerSelector:M,...e},this.liveBaseUrl=L;try{this.liveOrigin=new URL(this.liveBaseUrl).origin}catch{throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`)}H(),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=n=>{n.preventDefault(),this.handleTriggerClick(t)},o=this.boundClickHandlers.get(t);o&&t.removeEventListener("click",o),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,o=e.getAttribute("data-moment-list-slug")??void 0,n=e.getAttribute("data-moment-trigger-type");let r="moment";n!=null&&n!==""&&(n==="moment"||n==="list"||n==="team"||n==="brand-playlist"||n==="playlist"||n==="schedule"?r=n:console.warn("[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",n));const g=e.getAttribute("data-moment-ids")??e.getAttribute("data-moment-game-id")??"",u=g?g.split(",").filter(Boolean):[],m=e.getAttribute("data-moment-playlist-slugs")??"",p=m?m.split(",").map(O=>O.trim()).filter(Boolean):[],a=e.getAttribute("data-moment-calendar");let l;a!=null&&a!==""&&(a==="google"||a==="outlook"?l=a:console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:",a));const d=e.getAttribute("data-api-source-id")??void 0,c=e.getAttribute("data-external-event-id")??void 0,h=e.getAttribute("data-external-event-id-prefix")??void 0;if(c&&h&&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 v=r==="team"||r==="brand-playlist"||r==="playlist"||r==="schedule";this.emitAnalytics("embed.trigger.click",{teamSlug:t,triggerType:r,momentIds:v?[]:u}),this.open({teamSlug:t,momentSlug:i,listSlug:o,triggerType:r,ids:u,playlistSlugs:p,calendar:l??void 0,apiSourceId:d,externalEventId:h&&!c?void 0:c,externalEventIdPrefix:c?void 0:h})}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,this.isDesktopViewport=window.innerWidth>=w;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",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(2px)",padding:"16px"}),this.overlay.addEventListener("click",l=>{l.target===this.overlay&&this.handleCancel()});const i=l=>{l.key==="Escape"&&this.handleCancel()};document.addEventListener("keydown",i);const o=document.createElement("div");Object.assign(o.style,{position:"relative",width:"100%",maxWidth:`${this.isDesktopViewport?T:x}px`,minWidth:this.isDesktopViewport?`${S}px`:"0",borderRadius:"16px",transition:"border-radius 0.3s ease",overflow:"hidden",backgroundColor:"#000000",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"});const n=document.createElement("div");n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label","Calendar sync modal"),n.tabIndex=-1,Object.assign(n.style,{position:"relative",width:"100%",maxHeight:this.isDesktopViewport?`calc(100vh - ${f}px)`:"80vh",borderRadius:"12px",transition:"border-radius 0.3s ease",overflow:"auto",backgroundColor:"#ffffff"});const r=document.createElement("button");r.type="button",r.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>',r.setAttribute("aria-label","Close"),Object.assign(r.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"}),r.addEventListener("mouseenter",()=>{r.style.color="#666"}),r.addEventListener("mouseleave",()=>{r.style.color="#999"}),r.addEventListener("click",()=>this.handleCancel());const g=e.triggerType!=="schedule";this.iframe=document.createElement("iframe"),this.iframe.src=t,this.iframe.setAttribute("allow",""),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",height:this.isDesktopViewport?"520px":"420px",overflow:"hidden",transition:"height 0.15s ease"}),g&&n.appendChild(r),n.appendChild(this.iframe);const u=document.createElement("div");Object.assign(u.style,{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px 0"});const m=document.createElement("span");m.textContent="Powered by",Object.assign(m.style,{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:"12px",lineHeight:"16px",color:"#ffffff"});const p=document.createElement("img");p.alt="Moment",p.src=`${this.liveBaseUrl}/brand/moment-text-white.png`,Object.assign(p.style,{height:"auto",width:"67px",paddingTop:"2px"}),u.appendChild(m),u.appendChild(p),this.wrapper=o,this.container=n,o.appendChild(n),o.appendChild(u),this.overlay.appendChild(o),document.body.appendChild(this.overlay),this.viewportResizeHandler=()=>{const l=window.innerWidth>=w;if(this.isDesktopViewport=l,this.wrapper&&(this.wrapper.style.maxWidth=`${l?T:x}px`,this.wrapper.style.minWidth=l?`${S}px`:"0"),this.container&&(this.container.style.maxHeight=l?`calc(100vh - ${f}px)`:"80vh"),this.iframe){const d=l?window.innerHeight-f:Math.round(window.innerHeight*.8);(Number.parseFloat(this.iframe.style.height)||0)>d&&(this.iframe.style.height=`${d}px`)}},window.addEventListener("resize",this.viewportResizeHandler);const a=l=>{if(l.key!=="Tab")return;const d=n.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(d.length===0){l.preventDefault(),n.focus();return}const c=d[0],h=d[d.length-1],v=document.activeElement;l.shiftKey&&v===c?(l.preventDefault(),h.focus()):!l.shiftKey&&v===h&&(l.preventDefault(),c.focus())};n.addEventListener("keydown",a),g?r.focus():n.focus(),this.previousBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.didManageBodyOverflow=!0,this.setupMessageListener(),this.overlay._escHandler=i,this.overlay._focusTrapHandler=a}buildIframeUrl(e){return k(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 o=this.isDesktopViewport?window.innerHeight-f:Math.round(window.innerHeight*.8);this.iframe.style.height=`${Math.min(i,o)}px`}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.theme"){const{borderRadius:i}=t;if(typeof i=="number"&&Number.isFinite(i)){const o=Math.max(0,Math.min(i,32));this.container&&(this.container.style.borderRadius=`${o}px`),this.wrapper&&(this.wrapper.style.borderRadius=o===0?"0px":`${o+4}px`)}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.open.url"){const{url:i}=t;i&&typeof i=="string"&&i.startsWith("webcal://")&&window.open(i,"_blank");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 P({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)}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"),e.triggerType!=="schedule"&&(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.activePayload=null,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 I(s){const e=document.createElement("button");return e.type="button",e.classList.add("moment-sync-trigger"),s.className&&s.className.split(" ").forEach(t=>{t&&e.classList.add(t)}),e.setAttribute("data-moment-team-slug",s.teamSlug),s.momentSlug&&e.setAttribute("data-moment-slug",s.momentSlug),s.listSlug&&e.setAttribute("data-moment-list-slug",s.listSlug),s.triggerType&&e.setAttribute("data-moment-trigger-type",s.triggerType),s.ids?.length&&e.setAttribute("data-moment-ids",s.ids.join(",")),s.playlistSlugs?.length&&e.setAttribute("data-moment-playlist-slugs",s.playlistSlugs.join(",")),s.calendar&&e.setAttribute("data-moment-calendar",s.calendar),s.apiSourceId&&e.setAttribute("data-api-source-id",s.apiSourceId),s.externalEventId&&e.setAttribute("data-external-event-id",s.externalEventId),s.externalEventIdPrefix&&e.setAttribute("data-external-event-id-prefix",s.externalEventIdPrefix),e.textContent=s.label??"Add to Calendar",e}if(typeof window<"u"){const s=window;s.MomentSdk=E,s.createMomentButton=I}b.MomentSdk=E,b.createMomentButton=I,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})})(this.MomentSdk=this.MomentSdk||{});
@@ -1,4 +1,4 @@
1
- class y {
1
+ class S {
2
2
  popup = null;
3
3
  pollTimer = null;
4
4
  messageHandler = null;
@@ -63,7 +63,7 @@ class y {
63
63
  this.opts.iframeWindow.postMessage(t, this.opts.liveOrigin);
64
64
  }
65
65
  }
66
- function w(s, e, t = typeof window < "u" ? window.location.origin : "") {
66
+ function I(s, e, t = typeof window < "u" ? window.location.origin : "") {
67
67
  if (e.triggerType === "schedule") {
68
68
  const o = new URLSearchParams();
69
69
  return o.set("teamSlug", e.teamSlug), o.set("returnOrigin", t), o.set("embed", "1"), `${s}/en/embed/schedule?${o.toString()}`;
@@ -71,7 +71,7 @@ function w(s, e, t = typeof window < "u" ? window.location.origin : "") {
71
71
  const i = new URLSearchParams();
72
72
  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"), `${s}/en/embed/sync?${i.toString()}`;
73
73
  }
74
- const v = "moment-sdk-trigger-styles", x = `
74
+ const b = "moment-sdk-trigger-styles", P = `
75
75
  :where(.moment-sync-trigger) {
76
76
  background-color: #1c1917;
77
77
  color: #ffffff;
@@ -96,13 +96,13 @@ const v = "moment-sdk-trigger-styles", x = `
96
96
  outline-offset: 2px;
97
97
  }
98
98
  `;
99
- function T() {
100
- if (typeof document > "u" || document.getElementById(v)) return;
99
+ function A() {
100
+ if (typeof document > "u" || document.getElementById(b)) return;
101
101
  const s = document.createElement("style");
102
- s.id = v, s.textContent = x, document.head.appendChild(s);
102
+ s.id = b, s.textContent = P, document.head.appendChild(s);
103
103
  }
104
- const S = ".moment-sync-trigger", E = "https://live.dev.momentco.ai";
105
- class I {
104
+ const k = ".moment-sync-trigger", y = 1024, w = 380, x = 600, T = 400, v = 80, H = "https://live.dev.momentco.ai";
105
+ class L {
106
106
  opts;
107
107
  liveBaseUrl;
108
108
  liveOrigin;
@@ -120,17 +120,21 @@ class I {
120
120
  previousBodyOverflow = "";
121
121
  didManageBodyOverflow = !1;
122
122
  closeTimer = null;
123
+ // Whether the host viewport is wide enough for the desktop modal layout.
124
+ // Set on open and kept in sync via a window resize listener.
125
+ isDesktopViewport = !1;
126
+ viewportResizeHandler = null;
123
127
  constructor(e) {
124
128
  this.opts = {
125
- triggerSelector: S,
129
+ triggerSelector: k,
126
130
  ...e
127
- }, this.liveBaseUrl = E;
131
+ }, this.liveBaseUrl = H;
128
132
  try {
129
133
  this.liveOrigin = new URL(this.liveBaseUrl).origin;
130
134
  } catch {
131
135
  throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`);
132
136
  }
133
- T(), this.bindTriggers(), this.emitAnalytics("embed.init");
137
+ A(), this.bindTriggers(), this.emitAnalytics("embed.init");
134
138
  }
135
139
  /**
136
140
  * Programmatically open the sync modal.
@@ -184,11 +188,11 @@ class I {
184
188
  "[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",
185
189
  n
186
190
  ));
187
- const h = e.getAttribute("data-moment-ids") ?? e.getAttribute("data-moment-game-id") ?? "", d = h ? h.split(",").filter(Boolean) : [], c = e.getAttribute("data-moment-playlist-slugs") ?? "", m = c ? c.split(",").map((b) => b.trim()).filter(Boolean) : [], a = e.getAttribute("data-moment-calendar");
191
+ const g = e.getAttribute("data-moment-ids") ?? e.getAttribute("data-moment-game-id") ?? "", u = g ? g.split(",").filter(Boolean) : [], m = e.getAttribute("data-moment-playlist-slugs") ?? "", p = m ? m.split(",").map((E) => E.trim()).filter(Boolean) : [], a = e.getAttribute("data-moment-calendar");
188
192
  let l;
189
193
  a != null && a !== "" && (a === "google" || a === "outlook" ? l = a : console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:", a));
190
- const p = e.getAttribute("data-api-source-id") ?? void 0, u = e.getAttribute("data-external-event-id") ?? void 0, g = e.getAttribute("data-external-event-id-prefix") ?? void 0;
191
- if (u && g && console.warn(
194
+ const d = e.getAttribute("data-api-source-id") ?? void 0, c = e.getAttribute("data-external-event-id") ?? void 0, h = e.getAttribute("data-external-event-id-prefix") ?? void 0;
195
+ if (c && h && console.warn(
192
196
  "[MomentSdk] Both data-external-event-id and data-external-event-id-prefix are set; using data-external-event-id only."
193
197
  ), !t) {
194
198
  console.warn("[MomentSdk] Missing data-moment-team-slug on trigger element");
@@ -198,18 +202,18 @@ class I {
198
202
  this.emitAnalytics("embed.trigger.click", {
199
203
  teamSlug: t,
200
204
  triggerType: r,
201
- momentIds: f ? [] : d
205
+ momentIds: f ? [] : u
202
206
  }), this.open({
203
207
  teamSlug: t,
204
208
  momentSlug: i,
205
209
  listSlug: o,
206
210
  triggerType: r,
207
- ids: d,
208
- playlistSlugs: m,
211
+ ids: u,
212
+ playlistSlugs: p,
209
213
  calendar: l ?? void 0,
210
- apiSourceId: p,
211
- externalEventId: g && !u ? void 0 : u,
212
- externalEventIdPrefix: u ? void 0 : g
214
+ apiSourceId: d,
215
+ externalEventId: h && !c ? void 0 : c,
216
+ externalEventIdPrefix: c ? void 0 : h
213
217
  });
214
218
  }
215
219
  /** Drop moment/list/source scoping for brand-level subscription triggers. */
@@ -230,7 +234,7 @@ class I {
230
234
  }
231
235
  // ── Private: modal creation ───────────────────────────────────────
232
236
  createModal(e) {
233
- this.cleanup(), this.previousFocusedElement = document.activeElement || null, this.activePayload = e;
237
+ this.cleanup(), this.previousFocusedElement = document.activeElement || null, this.activePayload = e, this.isDesktopViewport = window.innerWidth >= y;
234
238
  const t = this.buildIframeUrl(e);
235
239
  this.overlay = document.createElement("div"), this.overlay.setAttribute("role", "presentation"), Object.assign(this.overlay.style, {
236
240
  position: "fixed",
@@ -253,7 +257,8 @@ class I {
253
257
  Object.assign(o.style, {
254
258
  position: "relative",
255
259
  width: "100%",
256
- maxWidth: "380px",
260
+ maxWidth: `${this.isDesktopViewport ? x : w}px`,
261
+ minWidth: this.isDesktopViewport ? `${T}px` : "0",
257
262
  borderRadius: "16px",
258
263
  // Ease radius changes so a brand's configured radius (arriving via
259
264
  // `moment.embed.theme` after the iframe resolves its config) settles
@@ -269,7 +274,7 @@ class I {
269
274
  n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), n.setAttribute("aria-label", "Calendar sync modal"), n.tabIndex = -1, Object.assign(n.style, {
270
275
  position: "relative",
271
276
  width: "100%",
272
- maxHeight: "80vh",
277
+ maxHeight: this.isDesktopViewport ? `calc(100vh - ${v}px)` : "80vh",
273
278
  borderRadius: "12px",
274
279
  transition: "border-radius 0.3s ease",
275
280
  overflow: "auto",
@@ -296,51 +301,57 @@ class I {
296
301
  }), r.addEventListener("mouseleave", () => {
297
302
  r.style.color = "#999";
298
303
  }), r.addEventListener("click", () => this.handleCancel());
299
- const h = e.triggerType !== "schedule";
304
+ const g = e.triggerType !== "schedule";
300
305
  this.iframe = document.createElement("iframe"), this.iframe.src = t, this.iframe.setAttribute("allow", ""), this.iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-popups allow-forms"), this.iframe.setAttribute("scrolling", "no"), Object.assign(this.iframe.style, {
301
306
  width: "100%",
302
307
  border: "none",
303
308
  display: "block",
304
- height: "420px",
309
+ height: this.isDesktopViewport ? "520px" : "420px",
305
310
  overflow: "hidden",
306
311
  transition: "height 0.15s ease"
307
- }), h && n.appendChild(r), n.appendChild(this.iframe);
308
- const d = document.createElement("div");
309
- Object.assign(d.style, {
312
+ }), g && n.appendChild(r), n.appendChild(this.iframe);
313
+ const u = document.createElement("div");
314
+ Object.assign(u.style, {
310
315
  display: "flex",
311
316
  alignItems: "center",
312
317
  justifyContent: "center",
313
318
  padding: "12px 0"
314
319
  });
315
- const c = document.createElement("span");
316
- c.textContent = "Powered by", Object.assign(c.style, {
320
+ const m = document.createElement("span");
321
+ m.textContent = "Powered by", Object.assign(m.style, {
317
322
  fontFamily: "Inter, system-ui, -apple-system, sans-serif",
318
323
  fontSize: "12px",
319
324
  lineHeight: "16px",
320
325
  color: "#ffffff"
321
326
  });
322
- const m = document.createElement("img");
323
- m.alt = "Moment", m.src = `${this.liveBaseUrl}/brand/moment-text-white.png`, Object.assign(m.style, {
327
+ const p = document.createElement("img");
328
+ p.alt = "Moment", p.src = `${this.liveBaseUrl}/brand/moment-text-white.png`, Object.assign(p.style, {
324
329
  height: "auto",
325
330
  width: "67px",
326
331
  paddingTop: "2px"
327
- }), d.appendChild(c), d.appendChild(m), this.wrapper = o, this.container = n, o.appendChild(n), o.appendChild(d), this.overlay.appendChild(o), document.body.appendChild(this.overlay);
332
+ }), u.appendChild(m), u.appendChild(p), this.wrapper = o, this.container = n, o.appendChild(n), o.appendChild(u), this.overlay.appendChild(o), document.body.appendChild(this.overlay), this.viewportResizeHandler = () => {
333
+ const l = window.innerWidth >= y;
334
+ if (this.isDesktopViewport = l, this.wrapper && (this.wrapper.style.maxWidth = `${l ? x : w}px`, this.wrapper.style.minWidth = l ? `${T}px` : "0"), this.container && (this.container.style.maxHeight = l ? `calc(100vh - ${v}px)` : "80vh"), this.iframe) {
335
+ const d = l ? window.innerHeight - v : Math.round(window.innerHeight * 0.8);
336
+ (Number.parseFloat(this.iframe.style.height) || 0) > d && (this.iframe.style.height = `${d}px`);
337
+ }
338
+ }, window.addEventListener("resize", this.viewportResizeHandler);
328
339
  const a = (l) => {
329
340
  if (l.key !== "Tab") return;
330
- const p = n.querySelectorAll(
341
+ const d = n.querySelectorAll(
331
342
  'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
332
343
  );
333
- if (p.length === 0) {
344
+ if (d.length === 0) {
334
345
  l.preventDefault(), n.focus();
335
346
  return;
336
347
  }
337
- const u = p[0], g = p[p.length - 1], f = document.activeElement;
338
- l.shiftKey && f === u ? (l.preventDefault(), g.focus()) : !l.shiftKey && f === g && (l.preventDefault(), u.focus());
348
+ const c = d[0], h = d[d.length - 1], f = document.activeElement;
349
+ l.shiftKey && f === c ? (l.preventDefault(), h.focus()) : !l.shiftKey && f === h && (l.preventDefault(), c.focus());
339
350
  };
340
- n.addEventListener("keydown", a), h ? r.focus() : n.focus(), this.previousBodyOverflow = document.body.style.overflow, document.body.style.overflow = "hidden", this.didManageBodyOverflow = !0, this.setupMessageListener(), this.overlay._escHandler = i, this.overlay._focusTrapHandler = a;
351
+ n.addEventListener("keydown", a), g ? r.focus() : n.focus(), this.previousBodyOverflow = document.body.style.overflow, document.body.style.overflow = "hidden", this.didManageBodyOverflow = !0, this.setupMessageListener(), this.overlay._escHandler = i, this.overlay._focusTrapHandler = a;
341
352
  }
342
353
  buildIframeUrl(e) {
343
- return w(this.liveBaseUrl, e);
354
+ return I(this.liveBaseUrl, e);
344
355
  }
345
356
  // ── Private: message handling ─────────────────────────────────────
346
357
  setupMessageListener() {
@@ -359,7 +370,7 @@ class I {
359
370
  if (t.source === "moment-live-embed" && t.type === "moment.embed.resize") {
360
371
  const i = typeof t.height == "number" ? t.height : 0;
361
372
  if (i > 0 && this.iframe) {
362
- const o = Math.round(window.innerHeight * 0.8);
373
+ const o = this.isDesktopViewport ? window.innerHeight - v : Math.round(window.innerHeight * 0.8);
363
374
  this.iframe.style.height = `${Math.min(i, o)}px`;
364
375
  }
365
376
  return;
@@ -389,7 +400,7 @@ class I {
389
400
  }, window.addEventListener("message", this.messageHandler);
390
401
  }
391
402
  handleOAuthStart(e) {
392
- this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.popupBridge = new y({
403
+ this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.popupBridge = new S({
393
404
  liveBaseUrl: this.liveBaseUrl,
394
405
  liveOrigin: this.liveOrigin,
395
406
  iframeWindow: this.iframe?.contentWindow ?? null,
@@ -438,7 +449,7 @@ class I {
438
449
  }
439
450
  // ── Private: cleanup ──────────────────────────────────────────────
440
451
  cleanup() {
441
- 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.overlay) {
452
+ 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) {
442
453
  const { _escHandler: e, _focusTrapHandler: t } = this.overlay;
443
454
  e && document.removeEventListener("keydown", e);
444
455
  const i = this.overlay.firstElementChild;
@@ -455,7 +466,7 @@ class I {
455
466
  });
456
467
  }
457
468
  }
458
- function P(s) {
469
+ function O(s) {
459
470
  const e = document.createElement("button");
460
471
  return e.type = "button", e.classList.add("moment-sync-trigger"), s.className && s.className.split(" ").forEach((t) => {
461
472
  t && e.classList.add(t);
@@ -463,9 +474,9 @@ function P(s) {
463
474
  }
464
475
  if (typeof window < "u") {
465
476
  const s = window;
466
- s.MomentSdk = I, s.createMomentButton = P;
477
+ s.MomentSdk = L, s.createMomentButton = O;
467
478
  }
468
479
  export {
469
- I as MomentSdk,
470
- P as createMomentButton
480
+ L as MomentSdk,
481
+ O as createMomentButton
471
482
  };
@@ -21,6 +21,8 @@ export declare class MomentSdk {
21
21
  private previousBodyOverflow;
22
22
  private didManageBodyOverflow;
23
23
  private closeTimer;
24
+ private isDesktopViewport;
25
+ private viewportResizeHandler;
24
26
  constructor(options: MomentSdkInitOptions);
25
27
  /**
26
28
  * Programmatically open the sync modal.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momentco-ai/moment-sdk",
3
- "version": "0.4.0-dev.28",
3
+ "version": "0.5.0-dev.30",
4
4
  "type": "module",
5
5
  "description": "Embeddable calendar sync widget for external team websites",
6
6
  "author": "Moment Co. <support@momentco.ai> (https://momentco.ai)",