@frigade/react 2.9.6 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -66,7 +66,7 @@ var It=Object.defineProperty,En=Object.defineProperties;var In=Object.getOwnProp
66
66
  to {
67
67
  opacity: 1;
68
68
  }
69
- `;function Oo(S){var B=S,{align:e,alignOffset:o,autoScroll:t,defaultOpen:r,dismissible:n,flow:a,handleDismiss:s,lockScroll:l,modal:d,onPrimary:u,onSecondary:c,part:f,side:y,sideOffset:C,spotlight:v,step:h}=B,b=g(B,["align","alignOffset","autoScroll","defaultOpen","dismissible","flow","handleDismiss","lockScroll","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var N,G,ee,ne,Z;let{handlePrimary:O,handleSecondary:T}=ae(h,{onPrimary:u,onSecondary:c}),{videoProps:k,otherProps:w}=re(b),E=(G=(N=h.primaryButton)==null?void 0:N.title)!=null?G:h.primaryButtonTitle,H=(ne=(ee=h.secondaryButton)==null?void 0:ee.title)!=null?ne:h.secondaryButtonTitle,z=!!h.$state.blocked;return jsx(ft,p(i({align:e,alignOffset:o,anchor:h.selector,autoScroll:t,"data-step-id":h.id,defaultOpen:r,lockScroll:l,modal:d,part:f,side:y,sideOffset:C,spotlight:v,onMount:()=>{r&&!z&&(h==null||h.start());}},w),{children:jsxs(P,{animation:`${Cs} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsx(P.Media,i({aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(Z=h.videoUri)!=null?Z:h.imageUri,transform:"translate3d(0, 0, 1px)",type:h.videoUri?"video":"image"},k)),jsx(P.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:s,subtitle:h.subtitle,title:h.title}),jsxs(P.Footer,{children:[a.getNumberOfAvailableSteps()>1&&jsx(De,{current:a.getCurrentStepOrder()+1,marginRight:"auto",total:a.getNumberOfAvailableSteps()}),jsx(P.Secondary,{disabled:z,onClick:T,title:H}),jsx(P.Primary,{disabled:z,onClick:O,title:E})]})]})}))}function an(n){var a=n,{children:e,container:o,flowId:t}=a,r=g(a,["children","container","flowId"]);return jsx(ct,{container:o,children:jsx(x,p(i({"data-flow-id":t,part:"tour"},r),{children:e}))})}function Eo(r){var n=r,{as:e,flowId:o}=n,t=g(n,["as","flowId"]);let{onDismiss:a,onPrimary:s,onSecondary:l}=t;return jsx(W,p(i({as:null,flowId:o,autoStart:!1},t),{children:({flow:d,handleDismiss:u,parentProps:c,step:f})=>{var de;let oe=c.containerProps,{align:y="after",alignOffset:C=0,autoScroll:v=!1,container:h="body",defaultOpen:b,lockScroll:S=!0,modal:B,onOpenChange:O,open:T,part:k,sequential:w=!0,side:E="bottom",sideOffset:H=0,spotlight:z,zIndex:N=9999}=oe,G=g(oe,["align","alignOffset","autoScroll","container","defaultOpen","lockScroll","modal","onOpenChange","open","part","sequential","side","sideOffset","spotlight","zIndex"]),{dismissible:ee}=c,ne=i({align:y,alignOffset:C,autoScroll:v,dismissible:ee,flow:d,handleDismiss:u,modal:B,onPrimary:s,onSecondary:l,onOpenChange:O,open:T,part:k,side:E,sideOffset:H,spotlight:z,step:f,zIndex:N},(de=f.props)!=null?de:{});if(w)return jsx(an,p(i({as:e,container:h,flowId:o,part:"tour",zIndex:N},G),{children:jsx(Oo,i({defaultOpen:b!=null?b:!0,lockScroll:S},ne),f.id)}));let Z=Array.from(d.steps.values()).filter(M=>{let{blocked:K,completed:j,skipped:te,visible:ie}=M.$state;return !K&&!j&&!te&&ie}).map(M=>{var xe,ce,kt,Bt;function K(Ot){return V(this,null,function*(){return (yield a==null?void 0:a(d,Ot))===!1?(Ot.preventDefault(),!1):(M.skip(),!0)})}let j=z&&M.id===f.id,te=(ce=(xe=M.props)==null?void 0:xe.zIndex)!=null?ce:N,ie=i({align:y,alignOffset:C,dismissible:ee,flow:d,handleDismiss:K,onPrimary:s,onSecondary:l,onOpenChange:O,open:T,part:k,side:E,sideOffset:H,spotlight:z,zIndex:te},(kt=M.props)!=null?kt:{});return jsx(Oo,i({css:{"&:has([aria-expanded=true])":{zIndex:Number(te)+2},".fr-overlay":{zIndex:Number(te)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(Bt=b||j)!=null?Bt:!1,lockScroll:S,step:M},ie),`${M.id}-${j}`)});return jsx(an,p(i({as:e,container:h,flowId:o,part:"tour",zIndex:N},G),{children:Z}))}}))}var Io="useSyncExternalStore"in jo?jo.useSyncExternalStore:sn.useSyncExternalStore;function Do(){let{frigade:e}=useContext(A),[,o]=useState(!1),t=useRef(),r=useCallback(s=>{e==null||e.getCollections().then(()=>{s();});let l=()=>{clearTimeout(t.current),t.current=setTimeout(()=>{o(d=>!d),s();},0);};return e==null||e.on("flow.any",l),()=>{e==null||e.off("flow.any",l);}},[e]),n=()=>{let s;try{s=e==null?void 0:e.getCollectionsSync();}catch(l){}return s};return {collections:Io(r,n,n)}}function Ho(e){var l,d,u,c;let{frigade:o}=useContext(A),{collections:t}=Do(),r=t==null?void 0:t.get(e),a=(c=((u=(d=(l=t==null?void 0:t.get(e))==null?void 0:l.flows)==null?void 0:d.filter(f=>f.visible).map(f=>p(i({},f),{flow:o==null?void 0:o.getFlowSync(f.flowId)})))!=null?u:[]).find(({flow:f})=>f==null?void 0:f.isVisible))==null?void 0:c.flowId,{flow:s}=Oe(a);return useEffect(()=>{o==null||o.registerCollection(e);},[e,o]),{collection:r,currentFlow:s}}function yt(n){var a=n,{collectionId:e,part:o,variables:t={}}=a,r=g(a,["collectionId","part","variables"]);var u,c,f;let s={ANNOUNCEMENT:xt,BANNER:Xo,CARD:P,CHECKLIST:xo,EMBEDDED_TIP:P,FORM:ze,NPS_SURVEY:to,SURVEY:to,TOUR:Eo},{currentFlow:l}=Ho(e),d=(c=s[(u=l==null?void 0:l.rawData)==null?void 0:u.flowType])!=null?c:null;return l==null||d==null?null:((f=l==null?void 0:l.rawData)==null?void 0:f.flowType)===FlowType.FORM?jsx(x,p(i({part:["collection",o],"data-collection-id":e},r),{children:jsx(ze,{flowId:l.id,as:$,variables:t},l.id)})):jsx(x,p(i({part:["collection",o],"data-collection-id":e},r),{children:jsx(d,{flowId:l.id,variables:t},l.id)}))}function ln(){var t,r;let{collections:e}=Do(),o=(r=Array.from((t=e==null?void 0:e.entries())!=null?t:[]).find(n=>n[1].collectionType==="DEFAULT"))==null?void 0:r[0];return Ho(o),o==null?null:jsx(yt,{as:null,collectionId:o})}var A=createContext({apiKey:"",currentModal:null,setCurrentModal:()=>{},navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});var Se=(e,o="log")=>{let t=`__frigade_logged_${e}`;globalThis[t]||(globalThis[t]=!0,console[o](e));};function ht(){let e=useContext(A);(!e||!e.frigade)&&Se("useFrigade() must be used in a child of the Frigade Provider","warn");let{frigade:o}=e;return {frigade:o,isLoading:!(o!=null&&o.isReady())}}function pn(){let{frigade:e}=ht();return useEffect(()=>{V(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(r=>{if(r.imageUri){let n=new Image;n.src=r.imageUri;}});});});},[e]),null}var dn="2.9.6";function gn(l){var d=l,{children:e,css:o={},defaultCollection:t=!0,navigate:r,theme:n,themeSelector:a=":root"}=d,s=g(d,["children","css","defaultCollection","navigate","theme","themeSelector"]);let u=n?_o(n):{},c=useRef(new Map),f=useRef(),[y,C]=useState(!1),[v,h]=useState(null),b=useMemo(()=>(C(!1),f.current=void 0,new Frigade(s.apiKey,{apiKey:s.apiKey,apiUrl:s.apiUrl,userId:s.userId,groupId:s.groupId,userProperties:s.userProperties,groupProperties:s.groupProperties,generateGuestId:s.generateGuestId,syncOnWindowUpdates:s.syncOnWindowUpdates,__readOnly:s.__readOnly,__flowStateOverrides:s.__flowStateOverrides,__platformVersion:dn,__platformName:"React"})),[s.userId,s.groupId,s.apiKey]);useEffect(()=>{if(s.__flowStateOverrides){let k=b.getConfig();k.__flowStateOverrides=s.__flowStateOverrides,b.reload(k);}},[b,s.__flowStateOverrides]);function S(){let k=[...c.current.entries()].map(([w,E])=>[w,E.callback]);b.batchRegister(k),C(!0);}function B(k,w){if(f.current&&clearTimeout(f.current),y){c.current.has(k)?b.getFlow(k).then(E=>w(E.isVisible)):(b.getFlow(k).then(E=>E.register(w)),c.current.set(k,{callback:w}));return}c.current.has(k)||c.current.set(k,{callback:w}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>S(),0);}function O(k){c.current.has(k)&&b.getFlow(k).then(w=>{c.current.delete(k),w==null||w.unregister();});}let T=r!=null?r:(k,w="_self")=>{window.open(k,w);};return useEffect(()=>()=>{b.destroy();},[b]),jsxs(A.Provider,{value:p(i({currentModal:v,setCurrentModal:h,navigate:T},s),{frigade:b,registerComponent:B,unregisterComponent:O,hasInitialized:y,variables:s.variables||{}}),children:[jsx(Global,{styles:{[a]:i(i(i({},Uo),u),o)}}),jsxs(ThemeProvider,{theme:I,children:[t&&jsx(ln,{}),e]}),s.preloadImages!==!1&&jsx(pn,{})]})}function Oe(e,o){let t=useContext(A);(!t||!t.frigade)&&Se(`useFlow('${e}') must be used in a child of the Frigade Provider`,"warn");let{frigade:r,variables:n}=t!=null?t:{},[,a]=useState(!1),s=useCallback(d=>{r==null||r.getFlow(e).then(()=>{d();});let u=(c,f)=>{f.id===e&&setTimeout(()=>{a(y=>!y),d();},0);};return r==null||r.on("flow.any",u),()=>{r==null||r.off("flow.any",u);}},[e,r]),l=Io(s,()=>r==null?void 0:r.getFlowSync(e),()=>r==null?void 0:r.getFlowSync(e));return useEffect(()=>{l==null||l.applyVariables(i(i({},n),o==null?void 0:o.variables));},[o==null?void 0:o.variables,l,e,n]),{flow:l,isLoading:r!=null&&r.hasFailedToLoad()?!1:!l}}function Pt(e,{onComplete:o,onDismiss:t}={}){let r=useRef(null);return useEffect(()=>{if(e==null)return;function n(){return V(this,null,function*(){e.isCompleted&&r.current===!1&&(r.current=!0,yield o==null?void 0:o(e));})}return n(),r.current=e==null?void 0:e.isCompleted,()=>{n();}},[e,e==null?void 0:e.isCompleted,o]),{handleDismiss:useCallback(n=>V(this,null,function*(){if((yield t==null?void 0:t(e,n))===!1)return n.preventDefault(),!1;e.skip();}),[e,t])}}function hn(e,o=!0){let{currentModal:t,setCurrentModal:r}=useContext(A),n=useCallback(s=>{o&&(e!=null&&e.isVisible)&&r(s);},[o,e==null?void 0:e.isVisible,r]),a=useCallback(()=>{e!=null&&t===(e==null?void 0:e.id)&&r(null);},[t,e,r]);return useEffect(()=>(e!=null&&t===null&&e.isVisible&&n(e.id),a),[n,t,e,a]),useEffect(()=>{e!=null&&(!o||!e.isVisible)&&a();},[e,o,a]),e==null?{hasModalCollision:!1}:!o||!e.isVisible?{hasModalCollision:!1}:t===e.id?{hasModalCollision:!1}:t===null?{hasModalCollision:!1}:{hasModalCollision:!0}}function St(e){return typeof e=="function"&&e.displayName==="Dialog"}function W(c){var f=c,{as:e,autoStart:o=!0,children:t,flowId:r,onComplete:n,onDismiss:a,onPrimary:s,onSecondary:l,variables:d}=f,u=g(f,["as","autoStart","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var ee,ne,Z,de;let{flow:y}=Oe(r,{variables:d}),C=y==null?void 0:y.getCurrentStep(),v=(ee=C==null?void 0:C.props)!=null?ee:{},{otherProps:h}=re(v),oe=i(i(i({},u),(ne=y==null?void 0:y.props)!=null?ne:{}),((Z=y==null?void 0:y.rawData)==null?void 0:Z.flowType)===FlowType.CHECKLIST?{}:h),{dismissible:b=!!St(e),forceMount:S=!1}=oe,B=g(oe,["dismissible","forceMount"]),{handleDismiss:O}=Pt(y,{onComplete:n,onDismiss:a}),{handlePrimary:T,handleSecondary:k}=ae(C,{onPrimary:s,onSecondary:l}),w=(B==null?void 0:B.modal)||St(e)||[FlowType.ANNOUNCEMENT,FlowType.TOUR].includes((de=y==null?void 0:y.rawData)==null?void 0:de.flowType),{hasModalCollision:E}=hn(y,w);function H(M){if(b===!1){M.preventDefault();return}typeof u.onEscapeKeyDown=="function"&&u.onEscapeKeyDown(M),M.defaultPrevented||O(M);}let z=S&&((y==null?void 0:y.isCompleted)||(y==null?void 0:y.isSkipped));if(!y||(!y.isVisible||E)&&!z)return null;(z||!y.isCompleted&&!y.isSkipped&&o)&&(C==null||C.start());let N=e===null?Fragment$1:e!=null?e:x,G=p(i({},B),{"data-flow-id":y.id});return St(e)&&(G.onEscapeKeyDown=H),jsx(N,p(i({},e===null?{}:G),{children:t({flow:y,handleDismiss:O,handlePrimary:T,handleSecondary:k,parentProps:{as:e,dismissible:b,flowId:r,variables:d,containerProps:G},step:C})}))}function Pn(t){var r=t,{part:e}=r,o=g(r,["part"]);return jsx(W,p(i({as:P,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:n,handlePrimary:a,handleSecondary:s,parentProps:{dismissible:l},step:d})=>{var y,C,v,h,b,S;let u=(C=(y=d.primaryButton)==null?void 0:y.title)!=null?C:d.primaryButtonTitle,c=(h=(v=d.secondaryButton)==null?void 0:v.title)!=null?h:d.secondaryButtonTitle,{videoProps:f}=re((b=d.props)!=null?b:{});return jsxs(Fragment,{children:[jsx(P.Header,{dismissible:l,handleDismiss:n,subtitle:d.subtitle,title:d.title}),jsx(P.Media,i({src:(S=d.videoUri)!=null?S:d.imageUri,type:d.videoUri?"video":"image",css:{objectFit:"contain",width:"100%"}},f)),jsxs(R.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsx(P.Secondary,{title:c,onClick:s}),jsx(P.Primary,{title:u,onClick:a})]})]})}}))}function $o(r){var n=r,{part:e,src:o}=n,t=g(n,["part","src"]);return jsx(x,i({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function Js(e){var o,t,r,n,a;return e.includes("youtube")?`https://www.youtube.com/embed/${(o=e.split("v=")[1])==null?void 0:o.split("&")[0]}`:e.includes("youtu.be")?`https://www.youtube.com/embed/${(t=e.split("youtu.be/")[1])==null?void 0:t.split("&")[0]}`:e.includes("vimeo")?`https://player.vimeo.com/video/${(r=e.split("vimeo.com/")[1])==null?void 0:r.split("&")[0]}`:e.includes("wistia")?`https://fast.wistia.net/embed/iframe/${(n=e.split("wistia.com/medias/")[1])==null?void 0:n.split("&")[0]}`:e.includes("loom")?`https://loom.com/embed/${(a=e.split("loom.com/share/")[1])==null?void 0:a.split("&")[0]}?hideEmbedTopBar=true&hide_title=true&hide_share=true&hide_owner=true`:null}function Ao(v){var h=v,{autoPlay:e,controls:o,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:a,loop:s,muted:l,playsInline:d,poster:u,preload:c,part:f,src:y}=h,C=g(h,["autoPlay","controls","controlsList","crossOrigin","disablePictureInPicture","disableRemotePlayback","loop","muted","playsInline","poster","preload","part","src"]);let b=Js(y);return b?jsx(x,i({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"neutral.100",borderWidth:"0",part:["video",f],src:b},C)):y!=null&&y.endsWith(".mp4")?jsx(x,i({as:"video",part:["video",f],src:y,autoPlay:e,controls:o!=null?o:!0,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:a,loop:s,muted:l!=null?l:e,playsInline:d,poster:u,preload:c},C)):(console.error(`Could not map videoUri ${y} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function ve(r){var n=r,{src:e,type:o}=n,t=g(n,["src","type"]);return jsx(o==="video"?Ao:$o,i({src:e},t))}var P=jo.forwardRef((a,n)=>{var s=a,{children:e,flowId:o,part:t}=s,r=g(s,["children","flowId","part"]);var d;if(o!=null)return jsx(Pn,i({flowId:o},r));let l=(d=r.as)!=null?d:R.Column;return jsx(l,p(i({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5,part:["card",t]},r),{ref:n,children:e}))});P.Dismiss=e=>jsx(D.Plain,p(i({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsx(Ie,{height:"20",fill:"currentColor"})}));P.Footer=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return jsx(R.Row,p(i({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",o]},t),{children:e}))};P.Header=s=>{var l=s,{dismissible:e,handleDismiss:o,part:t,subtitle:r,title:n}=l,a=g(l,["dismissible","handleDismiss","part","subtitle","title"]);return !e&&(n==null||(n==null?void 0:n.length)===0)&&(r==null||(r==null?void 0:r.length)===0)?null:jsxs(R.Row,p(i({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",t]},a),{children:[jsx(P.Title,{maxWidth:"calc(100% - 32px)",children:n}),e&&jsx(P.Dismiss,{onClick:o,marginLeft:"auto"}),jsx(P.Subtitle,{color:"neutral.400",flexBasis:"100%",children:r})]}))};P.Media=t=>{var r=t,{src:e}=r,o=g(r,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsx(ve,i({borderRadius:"md",src:e},o))};P.Primary=r=>{var n=r,{onClick:e,title:o}=n,t=g(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(D.Primary,i({title:o,onClick:e},t))};P.Secondary=r=>{var n=r,{onClick:e,title:o}=n,t=g(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(D.Secondary,i({title:o,onClick:e},t))};P.Subtitle=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsx(F.Body2,p(i({display:"block",color:"neutral.400",part:["subtitle",o]},t),{children:e}))};P.Title=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsx(F.H4,p(i({display:"block",part:["title",o]},t),{children:e}))};var Mo={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function vn(e){let o=Object.fromEntries(Mo.content.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),t=Object.fromEntries(Mo.root.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),r={};for(let n of Object.keys(e))!Mo.content.some(a=>a===n)&&!Mo.root.some(a=>a===n)&&(r[n]=e[n]);return {contentProps:o,otherProps:r,rootProps:t}}var Qs=keyframes`
69
+ `;function Oo(S){var B=S,{align:e,alignOffset:o,autoScroll:t,defaultOpen:r,dismissible:n,flow:a,handleDismiss:s,lockScroll:l,modal:d,onPrimary:u,onSecondary:c,part:f,side:y,sideOffset:C,spotlight:v,step:h}=B,b=g(B,["align","alignOffset","autoScroll","defaultOpen","dismissible","flow","handleDismiss","lockScroll","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var N,G,ee,ne,Z;let{handlePrimary:O,handleSecondary:T}=ae(h,{onPrimary:u,onSecondary:c}),{videoProps:k,otherProps:w}=re(b),E=(G=(N=h.primaryButton)==null?void 0:N.title)!=null?G:h.primaryButtonTitle,H=(ne=(ee=h.secondaryButton)==null?void 0:ee.title)!=null?ne:h.secondaryButtonTitle,z=!!h.$state.blocked;return jsx(ft,p(i({align:e,alignOffset:o,anchor:h.selector,autoScroll:t,"data-step-id":h.id,defaultOpen:r,lockScroll:l,modal:d,part:f,side:y,sideOffset:C,spotlight:v,onMount:()=>{r&&!z&&(h==null||h.start());}},w),{children:jsxs(P,{animation:`${Cs} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsx(P.Media,i({aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(Z=h.videoUri)!=null?Z:h.imageUri,transform:"translate3d(0, 0, 1px)",type:h.videoUri?"video":"image"},k)),jsx(P.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:s,subtitle:h.subtitle,title:h.title}),jsxs(P.Footer,{children:[a.getNumberOfAvailableSteps()>1&&jsx(De,{current:a.getCurrentStepOrder()+1,marginRight:"auto",total:a.getNumberOfAvailableSteps()}),jsx(P.Secondary,{disabled:z,onClick:T,title:H}),jsx(P.Primary,{disabled:z,onClick:O,title:E})]})]})}))}function an(n){var a=n,{children:e,container:o,flowId:t}=a,r=g(a,["children","container","flowId"]);return jsx(ct,{container:o,children:jsx(x,p(i({"data-flow-id":t,part:"tour"},r),{children:e}))})}function Eo(r){var n=r,{as:e,flowId:o}=n,t=g(n,["as","flowId"]);let{onDismiss:a,onPrimary:s,onSecondary:l}=t;return jsx(W,p(i({as:null,flowId:o,autoStart:!1},t),{children:({flow:d,handleDismiss:u,parentProps:c,step:f})=>{var de;let oe=c.containerProps,{align:y="after",alignOffset:C=0,autoScroll:v=!1,container:h="body",defaultOpen:b,lockScroll:S=!0,modal:B,onOpenChange:O,open:T,part:k,sequential:w=!0,side:E="bottom",sideOffset:H=0,spotlight:z,zIndex:N=9999}=oe,G=g(oe,["align","alignOffset","autoScroll","container","defaultOpen","lockScroll","modal","onOpenChange","open","part","sequential","side","sideOffset","spotlight","zIndex"]),{dismissible:ee}=c,ne=i({align:y,alignOffset:C,autoScroll:v,dismissible:ee,flow:d,handleDismiss:u,modal:B,onPrimary:s,onSecondary:l,onOpenChange:O,open:T,part:k,side:E,sideOffset:H,spotlight:z,step:f,zIndex:N},(de=f.props)!=null?de:{});if(w)return jsx(an,p(i({as:e,container:h,flowId:o,part:"tour",zIndex:N},G),{children:jsx(Oo,i({defaultOpen:b!=null?b:!0,lockScroll:S},ne),f.id)}));let Z=Array.from(d.steps.values()).filter(M=>{let{blocked:K,completed:j,skipped:te,visible:ie}=M.$state;return !K&&!j&&!te&&ie}).map(M=>{var xe,ce,kt,Bt;function K(Ot){return V(this,null,function*(){return (yield a==null?void 0:a(d,Ot))===!1?(Ot.preventDefault(),!1):(M.skip(),!0)})}let j=z&&M.id===f.id,te=(ce=(xe=M.props)==null?void 0:xe.zIndex)!=null?ce:N,ie=i({align:y,alignOffset:C,dismissible:ee,flow:d,handleDismiss:K,onPrimary:s,onSecondary:l,onOpenChange:O,open:T,part:k,side:E,sideOffset:H,spotlight:z,zIndex:te},(kt=M.props)!=null?kt:{});return jsx(Oo,i({css:{"&:has([aria-expanded=true])":{zIndex:Number(te)+2},".fr-overlay":{zIndex:Number(te)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(Bt=b||j)!=null?Bt:!1,lockScroll:S,step:M},ie),`${M.id}-${j}`)});return jsx(an,p(i({as:e,container:h,flowId:o,part:"tour",zIndex:N},G),{children:Z}))}}))}var Io="useSyncExternalStore"in jo?jo.useSyncExternalStore:sn.useSyncExternalStore;function Do(){let{frigade:e}=useContext(A),[,o]=useState(!1),t=useRef(),r=useCallback(s=>{e==null||e.getCollections().then(()=>{s();});let l=()=>{clearTimeout(t.current),t.current=setTimeout(()=>{o(d=>!d),s();},0);};return e==null||e.on("flow.any",l),()=>{e==null||e.off("flow.any",l);}},[e]),n=()=>{let s;try{s=e==null?void 0:e.getCollectionsSync();}catch(l){}return s};return {collections:Io(r,n,n)}}function Ho(e){var l,d,u,c;let{frigade:o}=useContext(A),{collections:t}=Do(),r=t==null?void 0:t.get(e),a=(c=((u=(d=(l=t==null?void 0:t.get(e))==null?void 0:l.flows)==null?void 0:d.filter(f=>f.visible).map(f=>p(i({},f),{flow:o==null?void 0:o.getFlowSync(f.flowId)})))!=null?u:[]).find(({flow:f})=>f==null?void 0:f.isVisible))==null?void 0:c.flowId,{flow:s}=Oe(a);return useEffect(()=>{o==null||o.registerCollection(e);},[e,o]),{collection:r,currentFlow:s}}function yt(n){var a=n,{collectionId:e,part:o,variables:t={}}=a,r=g(a,["collectionId","part","variables"]);var u,c,f;let s={ANNOUNCEMENT:xt,BANNER:Xo,CARD:P,CHECKLIST:xo,EMBEDDED_TIP:P,FORM:ze,NPS_SURVEY:to,SURVEY:to,TOUR:Eo},{currentFlow:l}=Ho(e),d=(c=s[(u=l==null?void 0:l.rawData)==null?void 0:u.flowType])!=null?c:null;return l==null||d==null?null:((f=l==null?void 0:l.rawData)==null?void 0:f.flowType)===FlowType.FORM?jsx(x,p(i({part:["collection",o],"data-collection-id":e},r),{children:jsx(ze,{flowId:l.id,as:$,variables:t},l.id)})):jsx(x,p(i({part:["collection",o],"data-collection-id":e},r),{children:jsx(d,{flowId:l.id,variables:t},l.id)}))}function ln(){var t,r;let{collections:e}=Do(),o=(r=Array.from((t=e==null?void 0:e.entries())!=null?t:[]).find(n=>n[1].collectionType==="DEFAULT"))==null?void 0:r[0];return Ho(o),o==null?null:jsx(yt,{as:null,collectionId:o})}var A=createContext({apiKey:"",currentModal:null,setCurrentModal:()=>{},navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});var Se=(e,o="log")=>{let t=`__frigade_logged_${e}`;globalThis[t]||(globalThis[t]=!0,console[o](e));};function ht(){let e=useContext(A);(!e||!e.frigade)&&Se("useFrigade() must be used in a child of the Frigade Provider","warn");let{frigade:o}=e;return {frigade:o,isLoading:!(o!=null&&o.isReady())}}function pn(){let{frigade:e}=ht();return useEffect(()=>{V(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(r=>{if(r.imageUri){let n=new Image;n.src=r.imageUri;}});});});},[e]),null}var dn="2.10.0";function gn(l){var d=l,{children:e,css:o={},defaultCollection:t=!0,navigate:r,theme:n,themeSelector:a=":root"}=d,s=g(d,["children","css","defaultCollection","navigate","theme","themeSelector"]);let u=n?_o(n):{},c=useRef(new Map),f=useRef(),[y,C]=useState(!1),[v,h]=useState(null),b=useMemo(()=>(C(!1),f.current=void 0,new Frigade(s.apiKey,{apiKey:s.apiKey,apiUrl:s.apiUrl,userId:s.userId,groupId:s.groupId,userProperties:s.userProperties,groupProperties:s.groupProperties,generateGuestId:s.generateGuestId,syncOnWindowUpdates:s.syncOnWindowUpdates,__readOnly:s.__readOnly,__flowStateOverrides:s.__flowStateOverrides,__platformVersion:dn,__platformName:"React"})),[s.userId,s.groupId,s.apiKey]);useEffect(()=>{if(s.__flowStateOverrides){let k=b.getConfig();k.__flowStateOverrides=s.__flowStateOverrides,b.reload(k);}},[b,s.__flowStateOverrides]);function S(){let k=[...c.current.entries()].map(([w,E])=>[w,E.callback]);b.batchRegister(k),C(!0);}function B(k,w){if(f.current&&clearTimeout(f.current),y){c.current.has(k)?b.getFlow(k).then(E=>w(E.isVisible)):(b.getFlow(k).then(E=>E.register(w)),c.current.set(k,{callback:w}));return}c.current.has(k)||c.current.set(k,{callback:w}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>S(),0);}function O(k){c.current.has(k)&&b.getFlow(k).then(w=>{c.current.delete(k),w==null||w.unregister();});}let T=r!=null?r:(k,w="_self")=>{window.open(k,w);};return useEffect(()=>()=>{b.destroy();},[b]),jsxs(A.Provider,{value:p(i({currentModal:v,setCurrentModal:h,navigate:T},s),{frigade:b,registerComponent:B,unregisterComponent:O,hasInitialized:y,variables:s.variables||{}}),children:[jsx(Global,{styles:{[a]:i(i(i({},Uo),u),o)}}),jsxs(ThemeProvider,{theme:I,children:[t&&jsx(ln,{}),e]}),s.preloadImages!==!1&&jsx(pn,{})]})}function Oe(e,o){let t=useContext(A);(!t||!t.frigade)&&Se(`useFlow('${e}') must be used in a child of the Frigade Provider`,"warn");let{frigade:r,variables:n}=t!=null?t:{},[,a]=useState(!1),s=useCallback(d=>{r==null||r.getFlow(e).then(()=>{d();});let u=(c,f)=>{f.id===e&&setTimeout(()=>{a(y=>!y),d();},0);};return r==null||r.on("flow.any",u),()=>{r==null||r.off("flow.any",u);}},[e,r]),l=Io(s,()=>r==null?void 0:r.getFlowSync(e),()=>r==null?void 0:r.getFlowSync(e));return useEffect(()=>{l==null||l.applyVariables(i(i({},n),o==null?void 0:o.variables));},[o==null?void 0:o.variables,l,e,n]),{flow:l,isLoading:r!=null&&r.hasFailedToLoad()?!1:!l}}function Pt(e,{onComplete:o,onDismiss:t}={}){let r=useRef(null);return useEffect(()=>{if(e==null)return;function n(){return V(this,null,function*(){e.isCompleted&&r.current===!1&&(r.current=!0,yield o==null?void 0:o(e));})}return n(),r.current=e==null?void 0:e.isCompleted,()=>{n();}},[e,e==null?void 0:e.isCompleted,o]),{handleDismiss:useCallback(n=>V(this,null,function*(){if((yield t==null?void 0:t(e,n))===!1)return n.preventDefault(),!1;e.skip();}),[e,t])}}function hn(e,o=!0){let{currentModal:t,setCurrentModal:r}=useContext(A),n=useCallback(s=>{o&&(e!=null&&e.isVisible)&&r(s);},[o,e==null?void 0:e.isVisible,r]),a=useCallback(()=>{e!=null&&t===(e==null?void 0:e.id)&&r(null);},[t,e,r]);return useEffect(()=>(e!=null&&t===null&&e.isVisible&&n(e.id),a),[n,t,e,a]),useEffect(()=>{e!=null&&(!o||!e.isVisible)&&a();},[e,o,a]),e==null?{hasModalCollision:!1}:!o||!e.isVisible?{hasModalCollision:!1}:t===e.id?{hasModalCollision:!1}:t===null?{hasModalCollision:!1}:{hasModalCollision:!0}}function St(e){return typeof e=="function"&&e.displayName==="Dialog"}function W(c){var f=c,{as:e,autoStart:o=!0,children:t,flowId:r,onComplete:n,onDismiss:a,onPrimary:s,onSecondary:l,variables:d}=f,u=g(f,["as","autoStart","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var ee,ne,Z,de;let{flow:y}=Oe(r,{variables:d}),C=y==null?void 0:y.getCurrentStep(),v=(ee=C==null?void 0:C.props)!=null?ee:{},{otherProps:h}=re(v),oe=i(i(i({},u),(ne=y==null?void 0:y.props)!=null?ne:{}),((Z=y==null?void 0:y.rawData)==null?void 0:Z.flowType)===FlowType.CHECKLIST?{}:h),{dismissible:b=!!St(e),forceMount:S=!1}=oe,B=g(oe,["dismissible","forceMount"]),{handleDismiss:O}=Pt(y,{onComplete:n,onDismiss:a}),{handlePrimary:T,handleSecondary:k}=ae(C,{onPrimary:s,onSecondary:l}),w=(B==null?void 0:B.modal)||St(e)||[FlowType.ANNOUNCEMENT,FlowType.TOUR].includes((de=y==null?void 0:y.rawData)==null?void 0:de.flowType),{hasModalCollision:E}=hn(y,w);function H(M){if(b===!1){M.preventDefault();return}typeof u.onEscapeKeyDown=="function"&&u.onEscapeKeyDown(M),M.defaultPrevented||O(M);}let z=S&&((y==null?void 0:y.isCompleted)||(y==null?void 0:y.isSkipped));if(!y||(!y.isVisible||E)&&!z)return null;(z||!y.isCompleted&&!y.isSkipped&&o)&&(C==null||C.start());let N=e===null?Fragment$1:e!=null?e:x,G=p(i({},B),{"data-flow-id":y.id});return St(e)&&(G.onEscapeKeyDown=H),jsx(N,p(i({},e===null?{}:G),{children:t({flow:y,handleDismiss:O,handlePrimary:T,handleSecondary:k,parentProps:{as:e,dismissible:b,flowId:r,variables:d,containerProps:G},step:C})}))}function Pn(t){var r=t,{part:e}=r,o=g(r,["part"]);return jsx(W,p(i({as:P,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:n,handlePrimary:a,handleSecondary:s,parentProps:{dismissible:l},step:d})=>{var y,C,v,h,b,S;let u=(C=(y=d.primaryButton)==null?void 0:y.title)!=null?C:d.primaryButtonTitle,c=(h=(v=d.secondaryButton)==null?void 0:v.title)!=null?h:d.secondaryButtonTitle,{videoProps:f}=re((b=d.props)!=null?b:{});return jsxs(Fragment,{children:[jsx(P.Header,{dismissible:l,handleDismiss:n,subtitle:d.subtitle,title:d.title}),jsx(P.Media,i({src:(S=d.videoUri)!=null?S:d.imageUri,type:d.videoUri?"video":"image",css:{objectFit:"contain",width:"100%"}},f)),jsxs(R.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsx(P.Secondary,{title:c,onClick:s}),jsx(P.Primary,{title:u,onClick:a})]})]})}}))}function $o(r){var n=r,{part:e,src:o}=n,t=g(n,["part","src"]);return jsx(x,i({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function Js(e){var o,t,r,n,a;return e.includes("youtube")?`https://www.youtube.com/embed/${(o=e.split("v=")[1])==null?void 0:o.split("&")[0]}`:e.includes("youtu.be")?`https://www.youtube.com/embed/${(t=e.split("youtu.be/")[1])==null?void 0:t.split("&")[0]}`:e.includes("vimeo")?`https://player.vimeo.com/video/${(r=e.split("vimeo.com/")[1])==null?void 0:r.split("&")[0]}`:e.includes("wistia")?`https://fast.wistia.net/embed/iframe/${(n=e.split("wistia.com/medias/")[1])==null?void 0:n.split("&")[0]}`:e.includes("loom")?`https://loom.com/embed/${(a=e.split("loom.com/share/")[1])==null?void 0:a.split("&")[0]}?hideEmbedTopBar=true&hide_title=true&hide_share=true&hide_owner=true`:null}function Ao(v){var h=v,{autoPlay:e,controls:o,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:a,loop:s,muted:l,playsInline:d,poster:u,preload:c,part:f,src:y}=h,C=g(h,["autoPlay","controls","controlsList","crossOrigin","disablePictureInPicture","disableRemotePlayback","loop","muted","playsInline","poster","preload","part","src"]);let b=Js(y);return b?jsx(x,i({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"neutral.100",borderWidth:"0",part:["video",f],src:b},C)):y!=null&&y.endsWith(".mp4")?jsx(x,i({as:"video",part:["video",f],src:y,autoPlay:e,controls:o!=null?o:!0,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:a,loop:s,muted:l!=null?l:e,playsInline:d,poster:u,preload:c},C)):(console.error(`Could not map videoUri ${y} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function ve(r){var n=r,{src:e,type:o}=n,t=g(n,["src","type"]);return jsx(o==="video"?Ao:$o,i({src:e},t))}var P=jo.forwardRef((a,n)=>{var s=a,{children:e,flowId:o,part:t}=s,r=g(s,["children","flowId","part"]);var d;if(o!=null)return jsx(Pn,i({flowId:o},r));let l=(d=r.as)!=null?d:R.Column;return jsx(l,p(i({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5,part:["card",t]},r),{ref:n,children:e}))});P.Dismiss=e=>jsx(D.Plain,p(i({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsx(Ie,{height:"20",fill:"currentColor"})}));P.Footer=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return jsx(R.Row,p(i({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",o]},t),{children:e}))};P.Header=s=>{var l=s,{dismissible:e,handleDismiss:o,part:t,subtitle:r,title:n}=l,a=g(l,["dismissible","handleDismiss","part","subtitle","title"]);return !e&&(n==null||(n==null?void 0:n.length)===0)&&(r==null||(r==null?void 0:r.length)===0)?null:jsxs(R.Row,p(i({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",t]},a),{children:[jsx(P.Title,{maxWidth:"calc(100% - 32px)",children:n}),e&&jsx(P.Dismiss,{onClick:o,marginLeft:"auto"}),jsx(P.Subtitle,{color:"neutral.400",flexBasis:"100%",children:r})]}))};P.Media=t=>{var r=t,{src:e}=r,o=g(r,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsx(ve,i({borderRadius:"md",src:e},o))};P.Primary=r=>{var n=r,{onClick:e,title:o}=n,t=g(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(D.Primary,i({title:o,onClick:e},t))};P.Secondary=r=>{var n=r,{onClick:e,title:o}=n,t=g(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(D.Secondary,i({title:o,onClick:e},t))};P.Subtitle=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsx(F.Body2,p(i({display:"block",color:"neutral.400",part:["subtitle",o]},t),{children:e}))};P.Title=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsx(F.H4,p(i({display:"block",part:["title",o]},t),{children:e}))};var Mo={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function vn(e){let o=Object.fromEntries(Mo.content.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),t=Object.fromEntries(Mo.root.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),r={};for(let n of Object.keys(e))!Mo.content.some(a=>a===n)&&!Mo.root.some(a=>a===n)&&(r[n]=e[n]);return {contentProps:o,otherProps:r,rootProps:t}}var Qs=keyframes`
70
70
  from {
71
71
  opacity: 0;
72
72
  }