@frigade/react 2.6.4 → 2.6.5

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.cjs CHANGED
@@ -17,7 +17,7 @@ var lo = require('@radix-ui/react-checkbox');
17
17
  var reactDom = require('react-dom');
18
18
  var reactRemoveScroll = require('react-remove-scroll');
19
19
  var react$1 = require('@floating-ui/react');
20
- var Lr = require('use-sync-external-store/shim');
20
+ var Lr = require('use-sync-external-store/shim/index.js');
21
21
  var de = require('@radix-ui/react-popover');
22
22
 
23
23
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -95,7 +95,7 @@ var dt=Object.defineProperty,cn=Object.defineProperties;var un=Object.getOwnProp
95
95
  to {
96
96
  opacity: 1;
97
97
  }
98
- `;function go(T){var S=T,{align:e,alignOffset:o,autoScroll:t,defaultOpen:r,dismissible:n,flow:i,handleDismiss:l,modal:s,onPrimary:d,onSecondary:u,part:f,side:m,sideOffset:x,spotlight:v,step:C}=S,P=g(S,["align","alignOffset","autoScroll","defaultOpen","dismissible","flow","handleDismiss","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var re,J,U,Q,ee;let{handlePrimary:B,handleSecondary:O}=ge(C,{onPrimary:d,onSecondary:u}),{videoProps:b,otherProps:k}=pe(P),w=(J=(re=C.primaryButton)==null?void 0:re.title)!=null?J:C.primaryButtonTitle,D=(Q=(U=C.secondaryButton)==null?void 0:U.title)!=null?Q:C.secondaryButtonTitle,H=!!C.$state.blocked;return jsxRuntime.jsx(Jo,p(a({align:e,alignOffset:o,anchor:C.selector,autoScroll:t,"data-step-id":C.id,defaultOpen:r,modal:s,part:f,side:m,sideOffset:x,spotlight:v},k),{children:jsxRuntime.jsxs(h,{animation:`${Aa} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsxRuntime.jsx(h.Media,a({aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(ee=C.videoUri)!=null?ee:C.imageUri,transform:"translate3d(0, 0, 1px)",type:C.videoUri?"video":"image"},b)),jsxRuntime.jsx(h.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:l,subtitle:C.subtitle,title:C.title}),jsxRuntime.jsxs(h.Footer,{children:[i.getNumberOfAvailableSteps()>1&&jsxRuntime.jsx(Oe,{current:i.getCurrentStepOrder()+1,marginRight:"auto",total:i.getNumberOfAvailableSteps()}),jsxRuntime.jsx(h.Secondary,{disabled:H,onClick:O,title:D}),jsxRuntime.jsx(h.Primary,{disabled:H,onClick:B,title:w})]})]})}))}function Wr(n){var i=n,{children:e,container:o,flowId:t}=i,r=g(i,["children","container","flowId"]);return jsxRuntime.jsx(Sr,{container:o,children:jsxRuntime.jsx(y,p(a({"data-flow-id":t,part:"tour"},r),{children:e}))})}function yo(r){var n=r,{as:e,flowId:o}=n,t=g(n,["as","flowId"]);let{onDismiss:i,onPrimary:l,onSecondary:s}=t;return jsxRuntime.jsx(z,p(a({as:null,flowId:o},t),{children:({flow:d,handleDismiss:u,parentProps:f,step:m})=>{var ee;let Q=f.containerProps,{align:x="after",alignOffset:v=0,autoScroll:C=!1,container:P="body",defaultOpen:T,modal:S,part:B,sequential:O=!0,side:b="bottom",sideOffset:k=0,spotlight:w,zIndex:D=9999}=Q,H=g(Q,["align","alignOffset","autoScroll","container","defaultOpen","modal","part","sequential","side","sideOffset","spotlight","zIndex"]),{dismissible:re}=f,J=a({align:x,alignOffset:v,autoScroll:C,dismissible:re,flow:d,handleDismiss:u,modal:S,onPrimary:l,onSecondary:s,part:B,side:b,sideOffset:k,spotlight:w,step:m,zIndex:D},(ee=m.props)!=null?ee:{});if(O)return jsxRuntime.jsx(Wr,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:D},H),{children:jsxRuntime.jsx(go,a({defaultOpen:T!=null?T:!0},J),m.id)}));let U=Array.from(d.steps.values()).filter(_=>{let{blocked:q,completed:j,skipped:oe,visible:W}=_.$state;return !q&&!j&&!oe&&W}).map(_=>{var te,ce,se,xe;function q(le){return M(this,null,function*(){return (yield i==null?void 0:i(d,le))===!1?(le.preventDefault(),!1):(_.skip(),!0)})}let j=w&&_.id===m.id,oe=(ce=(te=_.props)==null?void 0:te.zIndex)!=null?ce:D,W=a({align:x,alignOffset:v,dismissible:re,flow:d,handleDismiss:q,onPrimary:l,onSecondary:s,part:B,side:b,sideOffset:k,spotlight:w,zIndex:oe},(se=_.props)!=null?se:{});return jsxRuntime.jsx(go,a({css:{"&:has([aria-expanded=true])":{zIndex:Number(oe)+2},".fr-overlay":{zIndex:Number(oe)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(xe=T||j)!=null?xe:!1,step:_},W),`${_.id}-${j}`)});return jsxRuntime.jsx(Wr,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:D},H),{children:U}))}}))}var xo="useSyncExternalStore"in Do__namespace?Do__namespace.useSyncExternalStore:Lr__namespace.useSyncExternalStore;function ho(){let{frigade:e}=Do.useContext(A),[,o]=Do.useState(!1),t,r=Do.useCallback(l=>{e==null||e.getCollections().then(()=>{l();});let s=()=>{clearTimeout(t),t=setTimeout(()=>{o(d=>!d),l();},0);};return e==null||e.onStateChange(s),()=>{e==null||e.removeStateChangeHandler(s);}},[]),n=()=>{let l;try{l=e==null?void 0:e.getCollectionsSync();}catch(s){}return l};return {collections:xo(r,n,n)}}function bo(e){var s,d,u,f;let{frigade:o}=Do.useContext(A),{collections:t}=ho(),r=t==null?void 0:t.get(e),i=(f=((u=(d=(s=t==null?void 0:t.get(e))==null?void 0:s.flows)==null?void 0:d.filter(m=>m.visible).map(m=>p(a({},m),{flow:o==null?void 0:o.getFlowSync(m.flowId)})))!=null?u:[]).find(({flow:m})=>m.isVisible))==null?void 0:f.flowId,{flow:l}=Te(i);return Do.useEffect(()=>{o==null||o.registerCollection(e);},[e]),{collection:r,currentFlow:l}}function Zo(n){var i=n,{collectionId:e,part:o,variables:t={}}=i,r=g(i,["collectionId","part","variables"]);var u,f,m;let l={ANNOUNCEMENT:Yo,BANNER:Io,CARD:h,CHECKLIST:no,EMBEDDED_TIP:h,FORM:$e,NPS_SURVEY:Ke,SURVEY:Ke,TOUR:yo},{currentFlow:s}=bo(e),d=(f=l[(u=s==null?void 0:s.rawData)==null?void 0:u.flowType])!=null?f:null;return s==null||d==null?null:((m=s==null?void 0:s.rawData)==null?void 0:m.flowType)===js.FlowType.FORM?jsxRuntime.jsx(y,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx($e,{flowId:s.id,as:V,variables:t},s.id)})):jsxRuntime.jsx(y,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx(d,{flowId:s.id,variables:t},s.id)}))}function Nr(){var t,r;let{collections:e}=ho(),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 bo(o),o==null?null:jsxRuntime.jsx(Zo,{as:null,collectionId:o})}var A=Do.createContext({apiKey:"",currentModal:null,setCurrentModal:()=>{},navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});var be=(e,o="log")=>{let t=`__frigade_logged_${e}`;globalThis[t]||(globalThis[t]=!0,console[o](e));};function Qo(){let e=Do.useContext(A);(!e||!e.frigade)&&be("useFrigade() must be used in a child of the Frigade Provider","error");let{frigade:o}=e;return {frigade:o,isLoading:!(o!=null&&o.isReady())}}function _r(){let{frigade:e}=Qo();return Do.useEffect(()=>{M(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(r=>{if(r.imageUri){let n=new Image;n.src=r.imageUri;}});});});},[]),null}var zr="2.6.4";function Xr(l){var s=l,{children:e,css:o={},defaultCollection:t=!0,navigate:r,theme:n}=s,i=g(s,["children","css","defaultCollection","navigate","theme"]);let d=n?To(n):{},u=Do.useRef(new Map),f=Do.useRef(),[m,x]=Do.useState(!1),[v,C]=Do.useState(null),P=Do.useMemo(()=>(x(!1),f.current=void 0,new js.Frigade(i.apiKey,{apiKey:i.apiKey,apiUrl:i.apiUrl,userId:i.userId,groupId:i.groupId,userProperties:i.userProperties,groupProperties:i.groupProperties,generateGuestId:i.generateGuestId,syncOnWindowUpdates:i.syncOnWindowUpdates,__readOnly:i.__readOnly,__flowStateOverrides:i.__flowStateOverrides,__platformVersion:zr,__platformName:"React"})),[i.userId,i.groupId,i.apiKey]);Do.useEffect(()=>{if(i.__flowStateOverrides){let b=P.getConfig();b.__flowStateOverrides=i.__flowStateOverrides,P.reload(b);}},[i.__flowStateOverrides]);function T(){let b=[...u.current.entries()].map(([k,w])=>[k,w.callback]);P.batchRegister(b),x(!0);}function S(b,k){if(f.current&&clearTimeout(f.current),m){u.current.has(b)?P.getFlow(b).then(w=>k(w.isVisible)):(P.getFlow(b).then(w=>w.register(k)),u.current.set(b,{callback:k}));return}u.current.has(b)||u.current.set(b,{callback:k}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>T(),0);}function B(b){u.current.has(b)&&P.getFlow(b).then(k=>{u.current.delete(b),k==null||k.unregister();});}let O=r!=null?r:(b,k="_self")=>{window.open(b,k);};return Do.useEffect(()=>()=>{P.destroy();},[]),jsxRuntime.jsxs(A.Provider,{value:p(a({currentModal:v,setCurrentModal:C,navigate:O},i),{frigade:P,registerComponent:S,unregisterComponent:B,hasInitialized:m,variables:i.variables||{}}),children:[jsxRuntime.jsx(react.Global,{styles:{":root":a(a(a({},ko),d),o)}}),jsxRuntime.jsxs(react.ThemeProvider,{theme:E,children:[t&&jsxRuntime.jsx(Nr,{}),e]}),i.preloadImages!==!1&&jsxRuntime.jsx(_r,{})]})}function Te(e,o){let t=Do.useContext(A);(!t||!t.frigade)&&be(`useFlow('${e}') must be used in a child of the Frigade Provider`,"error");let{frigade:r,variables:n}=t!=null?t:{},[,i]=Do.useState(!1),l=Do.useCallback(d=>{r==null||r.getFlow(e).then(()=>{d();});let u=f=>{f.id===e&&setTimeout(()=>{i(m=>!m),d();},0);};return r==null||r.onStateChange(u),()=>{r==null||r.removeStateChangeHandler(u);}},[e,r]),s=xo(l,()=>r==null?void 0:r.getFlowSync(e),()=>r==null?void 0:r.getFlowSync(e));return Do.useEffect(()=>{s==null||s.applyVariables(a(a({},n),o==null?void 0:o.variables));},[o==null?void 0:o.variables,e,n]),{flow:s,isLoading:r!=null&&r.hasFailedToLoad()?!1:!s}}function ot(e,{onComplete:o,onDismiss:t}={}){let r=Do.useRef(null);return Do.useEffect(()=>{if(e==null)return;function n(){return M(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==null?void 0:e.isCompleted]),{handleDismiss:Do.useCallback(n=>M(this,null,function*(){if((yield t==null?void 0:t(e,n))===!1)return n.preventDefault(),!1;e.skip();}),[e])}}function Zr(e,o=!0){let{currentModal:t,setCurrentModal:r}=Do.useContext(A),n=Do.useCallback(l=>{o&&(e!=null&&e.isVisible)&&r(l);},[o,e==null?void 0:e.isVisible]),i=Do.useCallback(()=>{e!=null&&t===(e==null?void 0:e.id)&&r(null);},[t,e==null?void 0:e.id]);return Do.useEffect(()=>(e!=null&&t===null&&e.isVisible&&n(e.id),i),[t,e==null?void 0:e.id,e==null?void 0:e.isVisible]),Do.useEffect(()=>{e!=null&&(!o||!e.isVisible)&&i();},[e==null?void 0:e.isVisible,o]),e==null?{hasModalCollision:!1}:!o||!e.isVisible?{hasModalCollision:!1}:t===e.id?{hasModalCollision:!1}:t===null?{hasModalCollision:!1}:{hasModalCollision:!0}}function rt(e){return typeof e=="function"&&e.displayName==="Dialog"}function z(u){var f=u,{as:e,children:o,flowId:t,onComplete:r,onDismiss:n,onPrimary:i,onSecondary:l,variables:s}=f,d=g(f,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var U,Q,ee,q;let{flow:m}=Te(t,{variables:s}),x=m==null?void 0:m.getCurrentStep(),v=(U=x==null?void 0:x.props)!=null?U:{},{otherProps:C}=pe(v),_=a(a(a({},d),(Q=m==null?void 0:m.props)!=null?Q:{}),((ee=m==null?void 0:m.rawData)==null?void 0:ee.flowType)===js.FlowType.CHECKLIST?{}:C),{dismissible:P=!!rt(e),forceMount:T=!1}=_,S=g(_,["dismissible","forceMount"]),{handleDismiss:B}=ot(m,{onComplete:r,onDismiss:n}),{handlePrimary:O,handleSecondary:b}=ge(x,{onPrimary:i,onSecondary:l}),k=(S==null?void 0:S.modal)||rt(e)||[js.FlowType.ANNOUNCEMENT,js.FlowType.TOUR].includes((q=m==null?void 0:m.rawData)==null?void 0:q.flowType),{hasModalCollision:w}=Zr(m,k);function D(j){if(P===!1){j.preventDefault();return}typeof d.onEscapeKeyDown=="function"&&d.onEscapeKeyDown(j),j.defaultPrevented||B(j);}let H=T&&((m==null?void 0:m.isCompleted)||(m==null?void 0:m.isSkipped));if(!m||(!m.isVisible||w)&&!H)return null;(H||!m.isCompleted&&!m.isSkipped)&&(x==null||x.start());let re=e===null?Do.Fragment:e!=null?e:y,J=p(a({},S),{"data-flow-id":m.id});return rt(e)&&(J.onEscapeKeyDown=D),jsxRuntime.jsx(re,p(a({},e===null?{}:J),{children:o({flow:m,handleDismiss:B,handlePrimary:O,handleSecondary:b,parentProps:{dismissible:P,flowId:t,variables:s,containerProps:J},step:x})}))}function Qr(t){var r=t,{part:e}=r,o=g(r,["part"]);return jsxRuntime.jsx(z,p(a({as:h,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:n,handlePrimary:i,handleSecondary:l,parentProps:{dismissible:s},step:d})=>{var x,v,C,P,T,S;let u=(v=(x=d.primaryButton)==null?void 0:x.title)!=null?v:d.primaryButtonTitle,f=(P=(C=d.secondaryButton)==null?void 0:C.title)!=null?P:d.secondaryButtonTitle,{videoProps:m}=pe((T=d.props)!=null?T:{});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(h.Header,{dismissible:s,handleDismiss:n,subtitle:d.subtitle,title:d.title}),jsxRuntime.jsx(h.Media,a({src:(S=d.videoUri)!=null?S:d.imageUri,type:d.videoUri?"video":"image",css:{objectFit:"contain",width:"100%"}},m)),jsxRuntime.jsxs(F.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsxRuntime.jsx(h.Secondary,{title:f,onClick:l}),jsxRuntime.jsx(h.Primary,{title:u,onClick:i})]})]})}}))}function Co(r){var n=r,{part:e,src:o}=n,t=g(n,["part","src"]);return jsxRuntime.jsx(y,a({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function ps(e){var o,t,r,n,i;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/${(i=e.split("loom.com/share/")[1])==null?void 0:i.split("&")[0]}?hideEmbedTopBar=true&hide_title=true&hide_share=true&hide_owner=true`:null}function So(C){var P=C,{autoPlay:e,controls:o,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:i,loop:l,muted:s,playsInline:d,poster:u,preload:f,part:m,src:x}=P,v=g(P,["autoPlay","controls","controlsList","crossOrigin","disablePictureInPicture","disableRemotePlayback","loop","muted","playsInline","poster","preload","part","src"]);let T=ps(x);return T?jsxRuntime.jsx(y,a({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"neutral.100",borderWidth:"0",part:["video",m],src:T},v)):x!=null&&x.endsWith(".mp4")?jsxRuntime.jsx(y,a({as:"video",part:["video",m],src:x,autoPlay:e,controls:o!=null?o:!0,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:i,loop:l,muted:s!=null?s:e,playsInline:d,poster:u,preload:f},v)):(console.error(`Could not map videoUri ${x} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function Pe(r){var n=r,{src:e,type:o}=n,t=g(n,["src","type"]);return jsxRuntime.jsx(o==="video"?So:Co,a({src:e},t))}var h=Do__namespace.forwardRef((i,n)=>{var l=i,{children:e,flowId:o,part:t}=l,r=g(l,["children","flowId","part"]);var d;if(o!=null)return jsxRuntime.jsx(Qr,a({flowId:o},r));let s=(d=r.as)!=null?d:F.Column;return jsxRuntime.jsx(s,p(a({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5,part:["card",t]},r),{ref:n,children:e}))});h.Dismiss=e=>jsxRuntime.jsx(I.Plain,p(a({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsxRuntime.jsx(Be,{height:"20",fill:"currentColor"})}));h.Footer=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return jsxRuntime.jsx(F.Row,p(a({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",o]},t),{children:e}))};h.Header=l=>{var s=l,{dismissible:e,handleDismiss:o,part:t,subtitle:r,title:n}=s,i=g(s,["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:jsxRuntime.jsxs(F.Row,p(a({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",t]},i),{children:[jsxRuntime.jsx(h.Title,{maxWidth:"calc(100% - 32px)",children:n}),e&&jsxRuntime.jsx(h.Dismiss,{onClick:o,marginLeft:"auto"}),jsxRuntime.jsx(h.Subtitle,{color:"neutral.400",flexBasis:"100%",children:r})]}))};h.Media=t=>{var r=t,{src:e}=r,o=g(r,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsxRuntime.jsx(Pe,a({borderRadius:"md",src:e},o))};h.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:jsxRuntime.jsx(I.Primary,a({title:o,onClick:e},t))};h.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:jsxRuntime.jsx(I.Secondary,a({title:o,onClick:e},t))};h.Subtitle=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsxRuntime.jsx(R.Body2,p(a({display:"block",color:"neutral.400",part:["subtitle",o]},t),{children:e}))};h.Title=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsxRuntime.jsx(R.H4,p(a({display:"block",part:["title",o]},t),{children:e}))};var wo={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function tn(e){let o=Object.fromEntries(wo.content.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),t=Object.fromEntries(wo.root.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),r={};for(let n of Object.keys(e))!wo.content.some(i=>i===n)&&!wo.root.some(i=>i===n)&&(r[n]=e[n]);return {contentProps:o,otherProps:r,rootProps:t}}var ms=react.keyframes`
98
+ `;function go(T){var S=T,{align:e,alignOffset:o,autoScroll:t,defaultOpen:r,dismissible:n,flow:i,handleDismiss:l,modal:s,onPrimary:d,onSecondary:u,part:f,side:m,sideOffset:x,spotlight:v,step:C}=S,P=g(S,["align","alignOffset","autoScroll","defaultOpen","dismissible","flow","handleDismiss","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var re,J,U,Q,ee;let{handlePrimary:B,handleSecondary:O}=ge(C,{onPrimary:d,onSecondary:u}),{videoProps:b,otherProps:k}=pe(P),w=(J=(re=C.primaryButton)==null?void 0:re.title)!=null?J:C.primaryButtonTitle,D=(Q=(U=C.secondaryButton)==null?void 0:U.title)!=null?Q:C.secondaryButtonTitle,H=!!C.$state.blocked;return jsxRuntime.jsx(Jo,p(a({align:e,alignOffset:o,anchor:C.selector,autoScroll:t,"data-step-id":C.id,defaultOpen:r,modal:s,part:f,side:m,sideOffset:x,spotlight:v},k),{children:jsxRuntime.jsxs(h,{animation:`${Aa} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsxRuntime.jsx(h.Media,a({aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(ee=C.videoUri)!=null?ee:C.imageUri,transform:"translate3d(0, 0, 1px)",type:C.videoUri?"video":"image"},b)),jsxRuntime.jsx(h.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:l,subtitle:C.subtitle,title:C.title}),jsxRuntime.jsxs(h.Footer,{children:[i.getNumberOfAvailableSteps()>1&&jsxRuntime.jsx(Oe,{current:i.getCurrentStepOrder()+1,marginRight:"auto",total:i.getNumberOfAvailableSteps()}),jsxRuntime.jsx(h.Secondary,{disabled:H,onClick:O,title:D}),jsxRuntime.jsx(h.Primary,{disabled:H,onClick:B,title:w})]})]})}))}function Wr(n){var i=n,{children:e,container:o,flowId:t}=i,r=g(i,["children","container","flowId"]);return jsxRuntime.jsx(Sr,{container:o,children:jsxRuntime.jsx(y,p(a({"data-flow-id":t,part:"tour"},r),{children:e}))})}function yo(r){var n=r,{as:e,flowId:o}=n,t=g(n,["as","flowId"]);let{onDismiss:i,onPrimary:l,onSecondary:s}=t;return jsxRuntime.jsx(z,p(a({as:null,flowId:o},t),{children:({flow:d,handleDismiss:u,parentProps:f,step:m})=>{var ee;let Q=f.containerProps,{align:x="after",alignOffset:v=0,autoScroll:C=!1,container:P="body",defaultOpen:T,modal:S,part:B,sequential:O=!0,side:b="bottom",sideOffset:k=0,spotlight:w,zIndex:D=9999}=Q,H=g(Q,["align","alignOffset","autoScroll","container","defaultOpen","modal","part","sequential","side","sideOffset","spotlight","zIndex"]),{dismissible:re}=f,J=a({align:x,alignOffset:v,autoScroll:C,dismissible:re,flow:d,handleDismiss:u,modal:S,onPrimary:l,onSecondary:s,part:B,side:b,sideOffset:k,spotlight:w,step:m,zIndex:D},(ee=m.props)!=null?ee:{});if(O)return jsxRuntime.jsx(Wr,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:D},H),{children:jsxRuntime.jsx(go,a({defaultOpen:T!=null?T:!0},J),m.id)}));let U=Array.from(d.steps.values()).filter(_=>{let{blocked:q,completed:j,skipped:oe,visible:W}=_.$state;return !q&&!j&&!oe&&W}).map(_=>{var te,ce,se,xe;function q(le){return M(this,null,function*(){return (yield i==null?void 0:i(d,le))===!1?(le.preventDefault(),!1):(_.skip(),!0)})}let j=w&&_.id===m.id,oe=(ce=(te=_.props)==null?void 0:te.zIndex)!=null?ce:D,W=a({align:x,alignOffset:v,dismissible:re,flow:d,handleDismiss:q,onPrimary:l,onSecondary:s,part:B,side:b,sideOffset:k,spotlight:w,zIndex:oe},(se=_.props)!=null?se:{});return jsxRuntime.jsx(go,a({css:{"&:has([aria-expanded=true])":{zIndex:Number(oe)+2},".fr-overlay":{zIndex:Number(oe)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(xe=T||j)!=null?xe:!1,step:_},W),`${_.id}-${j}`)});return jsxRuntime.jsx(Wr,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:D},H),{children:U}))}}))}var xo="useSyncExternalStore"in Do__namespace?Do__namespace.useSyncExternalStore:Lr__namespace.useSyncExternalStore;function ho(){let{frigade:e}=Do.useContext(A),[,o]=Do.useState(!1),t,r=Do.useCallback(l=>{e==null||e.getCollections().then(()=>{l();});let s=()=>{clearTimeout(t),t=setTimeout(()=>{o(d=>!d),l();},0);};return e==null||e.onStateChange(s),()=>{e==null||e.removeStateChangeHandler(s);}},[]),n=()=>{let l;try{l=e==null?void 0:e.getCollectionsSync();}catch(s){}return l};return {collections:xo(r,n,n)}}function bo(e){var s,d,u,f;let{frigade:o}=Do.useContext(A),{collections:t}=ho(),r=t==null?void 0:t.get(e),i=(f=((u=(d=(s=t==null?void 0:t.get(e))==null?void 0:s.flows)==null?void 0:d.filter(m=>m.visible).map(m=>p(a({},m),{flow:o==null?void 0:o.getFlowSync(m.flowId)})))!=null?u:[]).find(({flow:m})=>m.isVisible))==null?void 0:f.flowId,{flow:l}=Te(i);return Do.useEffect(()=>{o==null||o.registerCollection(e);},[e]),{collection:r,currentFlow:l}}function Zo(n){var i=n,{collectionId:e,part:o,variables:t={}}=i,r=g(i,["collectionId","part","variables"]);var u,f,m;let l={ANNOUNCEMENT:Yo,BANNER:Io,CARD:h,CHECKLIST:no,EMBEDDED_TIP:h,FORM:$e,NPS_SURVEY:Ke,SURVEY:Ke,TOUR:yo},{currentFlow:s}=bo(e),d=(f=l[(u=s==null?void 0:s.rawData)==null?void 0:u.flowType])!=null?f:null;return s==null||d==null?null:((m=s==null?void 0:s.rawData)==null?void 0:m.flowType)===js.FlowType.FORM?jsxRuntime.jsx(y,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx($e,{flowId:s.id,as:V,variables:t},s.id)})):jsxRuntime.jsx(y,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx(d,{flowId:s.id,variables:t},s.id)}))}function Nr(){var t,r;let{collections:e}=ho(),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 bo(o),o==null?null:jsxRuntime.jsx(Zo,{as:null,collectionId:o})}var A=Do.createContext({apiKey:"",currentModal:null,setCurrentModal:()=>{},navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});var be=(e,o="log")=>{let t=`__frigade_logged_${e}`;globalThis[t]||(globalThis[t]=!0,console[o](e));};function Qo(){let e=Do.useContext(A);(!e||!e.frigade)&&be("useFrigade() must be used in a child of the Frigade Provider","error");let{frigade:o}=e;return {frigade:o,isLoading:!(o!=null&&o.isReady())}}function _r(){let{frigade:e}=Qo();return Do.useEffect(()=>{M(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(r=>{if(r.imageUri){let n=new Image;n.src=r.imageUri;}});});});},[]),null}var zr="2.6.5";function Xr(l){var s=l,{children:e,css:o={},defaultCollection:t=!0,navigate:r,theme:n}=s,i=g(s,["children","css","defaultCollection","navigate","theme"]);let d=n?To(n):{},u=Do.useRef(new Map),f=Do.useRef(),[m,x]=Do.useState(!1),[v,C]=Do.useState(null),P=Do.useMemo(()=>(x(!1),f.current=void 0,new js.Frigade(i.apiKey,{apiKey:i.apiKey,apiUrl:i.apiUrl,userId:i.userId,groupId:i.groupId,userProperties:i.userProperties,groupProperties:i.groupProperties,generateGuestId:i.generateGuestId,syncOnWindowUpdates:i.syncOnWindowUpdates,__readOnly:i.__readOnly,__flowStateOverrides:i.__flowStateOverrides,__platformVersion:zr,__platformName:"React"})),[i.userId,i.groupId,i.apiKey]);Do.useEffect(()=>{if(i.__flowStateOverrides){let b=P.getConfig();b.__flowStateOverrides=i.__flowStateOverrides,P.reload(b);}},[i.__flowStateOverrides]);function T(){let b=[...u.current.entries()].map(([k,w])=>[k,w.callback]);P.batchRegister(b),x(!0);}function S(b,k){if(f.current&&clearTimeout(f.current),m){u.current.has(b)?P.getFlow(b).then(w=>k(w.isVisible)):(P.getFlow(b).then(w=>w.register(k)),u.current.set(b,{callback:k}));return}u.current.has(b)||u.current.set(b,{callback:k}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>T(),0);}function B(b){u.current.has(b)&&P.getFlow(b).then(k=>{u.current.delete(b),k==null||k.unregister();});}let O=r!=null?r:(b,k="_self")=>{window.open(b,k);};return Do.useEffect(()=>()=>{P.destroy();},[]),jsxRuntime.jsxs(A.Provider,{value:p(a({currentModal:v,setCurrentModal:C,navigate:O},i),{frigade:P,registerComponent:S,unregisterComponent:B,hasInitialized:m,variables:i.variables||{}}),children:[jsxRuntime.jsx(react.Global,{styles:{":root":a(a(a({},ko),d),o)}}),jsxRuntime.jsxs(react.ThemeProvider,{theme:E,children:[t&&jsxRuntime.jsx(Nr,{}),e]}),i.preloadImages!==!1&&jsxRuntime.jsx(_r,{})]})}function Te(e,o){let t=Do.useContext(A);(!t||!t.frigade)&&be(`useFlow('${e}') must be used in a child of the Frigade Provider`,"error");let{frigade:r,variables:n}=t!=null?t:{},[,i]=Do.useState(!1),l=Do.useCallback(d=>{r==null||r.getFlow(e).then(()=>{d();});let u=f=>{f.id===e&&setTimeout(()=>{i(m=>!m),d();},0);};return r==null||r.onStateChange(u),()=>{r==null||r.removeStateChangeHandler(u);}},[e,r]),s=xo(l,()=>r==null?void 0:r.getFlowSync(e),()=>r==null?void 0:r.getFlowSync(e));return Do.useEffect(()=>{s==null||s.applyVariables(a(a({},n),o==null?void 0:o.variables));},[o==null?void 0:o.variables,e,n]),{flow:s,isLoading:r!=null&&r.hasFailedToLoad()?!1:!s}}function ot(e,{onComplete:o,onDismiss:t}={}){let r=Do.useRef(null);return Do.useEffect(()=>{if(e==null)return;function n(){return M(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==null?void 0:e.isCompleted]),{handleDismiss:Do.useCallback(n=>M(this,null,function*(){if((yield t==null?void 0:t(e,n))===!1)return n.preventDefault(),!1;e.skip();}),[e])}}function Zr(e,o=!0){let{currentModal:t,setCurrentModal:r}=Do.useContext(A),n=Do.useCallback(l=>{o&&(e!=null&&e.isVisible)&&r(l);},[o,e==null?void 0:e.isVisible]),i=Do.useCallback(()=>{e!=null&&t===(e==null?void 0:e.id)&&r(null);},[t,e==null?void 0:e.id]);return Do.useEffect(()=>(e!=null&&t===null&&e.isVisible&&n(e.id),i),[t,e==null?void 0:e.id,e==null?void 0:e.isVisible]),Do.useEffect(()=>{e!=null&&(!o||!e.isVisible)&&i();},[e==null?void 0:e.isVisible,o]),e==null?{hasModalCollision:!1}:!o||!e.isVisible?{hasModalCollision:!1}:t===e.id?{hasModalCollision:!1}:t===null?{hasModalCollision:!1}:{hasModalCollision:!0}}function rt(e){return typeof e=="function"&&e.displayName==="Dialog"}function z(u){var f=u,{as:e,children:o,flowId:t,onComplete:r,onDismiss:n,onPrimary:i,onSecondary:l,variables:s}=f,d=g(f,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var U,Q,ee,q;let{flow:m}=Te(t,{variables:s}),x=m==null?void 0:m.getCurrentStep(),v=(U=x==null?void 0:x.props)!=null?U:{},{otherProps:C}=pe(v),_=a(a(a({},d),(Q=m==null?void 0:m.props)!=null?Q:{}),((ee=m==null?void 0:m.rawData)==null?void 0:ee.flowType)===js.FlowType.CHECKLIST?{}:C),{dismissible:P=!!rt(e),forceMount:T=!1}=_,S=g(_,["dismissible","forceMount"]),{handleDismiss:B}=ot(m,{onComplete:r,onDismiss:n}),{handlePrimary:O,handleSecondary:b}=ge(x,{onPrimary:i,onSecondary:l}),k=(S==null?void 0:S.modal)||rt(e)||[js.FlowType.ANNOUNCEMENT,js.FlowType.TOUR].includes((q=m==null?void 0:m.rawData)==null?void 0:q.flowType),{hasModalCollision:w}=Zr(m,k);function D(j){if(P===!1){j.preventDefault();return}typeof d.onEscapeKeyDown=="function"&&d.onEscapeKeyDown(j),j.defaultPrevented||B(j);}let H=T&&((m==null?void 0:m.isCompleted)||(m==null?void 0:m.isSkipped));if(!m||(!m.isVisible||w)&&!H)return null;(H||!m.isCompleted&&!m.isSkipped)&&(x==null||x.start());let re=e===null?Do.Fragment:e!=null?e:y,J=p(a({},S),{"data-flow-id":m.id});return rt(e)&&(J.onEscapeKeyDown=D),jsxRuntime.jsx(re,p(a({},e===null?{}:J),{children:o({flow:m,handleDismiss:B,handlePrimary:O,handleSecondary:b,parentProps:{dismissible:P,flowId:t,variables:s,containerProps:J},step:x})}))}function Qr(t){var r=t,{part:e}=r,o=g(r,["part"]);return jsxRuntime.jsx(z,p(a({as:h,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:n,handlePrimary:i,handleSecondary:l,parentProps:{dismissible:s},step:d})=>{var x,v,C,P,T,S;let u=(v=(x=d.primaryButton)==null?void 0:x.title)!=null?v:d.primaryButtonTitle,f=(P=(C=d.secondaryButton)==null?void 0:C.title)!=null?P:d.secondaryButtonTitle,{videoProps:m}=pe((T=d.props)!=null?T:{});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(h.Header,{dismissible:s,handleDismiss:n,subtitle:d.subtitle,title:d.title}),jsxRuntime.jsx(h.Media,a({src:(S=d.videoUri)!=null?S:d.imageUri,type:d.videoUri?"video":"image",css:{objectFit:"contain",width:"100%"}},m)),jsxRuntime.jsxs(F.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsxRuntime.jsx(h.Secondary,{title:f,onClick:l}),jsxRuntime.jsx(h.Primary,{title:u,onClick:i})]})]})}}))}function Co(r){var n=r,{part:e,src:o}=n,t=g(n,["part","src"]);return jsxRuntime.jsx(y,a({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function ps(e){var o,t,r,n,i;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/${(i=e.split("loom.com/share/")[1])==null?void 0:i.split("&")[0]}?hideEmbedTopBar=true&hide_title=true&hide_share=true&hide_owner=true`:null}function So(C){var P=C,{autoPlay:e,controls:o,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:i,loop:l,muted:s,playsInline:d,poster:u,preload:f,part:m,src:x}=P,v=g(P,["autoPlay","controls","controlsList","crossOrigin","disablePictureInPicture","disableRemotePlayback","loop","muted","playsInline","poster","preload","part","src"]);let T=ps(x);return T?jsxRuntime.jsx(y,a({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"neutral.100",borderWidth:"0",part:["video",m],src:T},v)):x!=null&&x.endsWith(".mp4")?jsxRuntime.jsx(y,a({as:"video",part:["video",m],src:x,autoPlay:e,controls:o!=null?o:!0,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:i,loop:l,muted:s!=null?s:e,playsInline:d,poster:u,preload:f},v)):(console.error(`Could not map videoUri ${x} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function Pe(r){var n=r,{src:e,type:o}=n,t=g(n,["src","type"]);return jsxRuntime.jsx(o==="video"?So:Co,a({src:e},t))}var h=Do__namespace.forwardRef((i,n)=>{var l=i,{children:e,flowId:o,part:t}=l,r=g(l,["children","flowId","part"]);var d;if(o!=null)return jsxRuntime.jsx(Qr,a({flowId:o},r));let s=(d=r.as)!=null?d:F.Column;return jsxRuntime.jsx(s,p(a({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5,part:["card",t]},r),{ref:n,children:e}))});h.Dismiss=e=>jsxRuntime.jsx(I.Plain,p(a({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsxRuntime.jsx(Be,{height:"20",fill:"currentColor"})}));h.Footer=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return jsxRuntime.jsx(F.Row,p(a({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",o]},t),{children:e}))};h.Header=l=>{var s=l,{dismissible:e,handleDismiss:o,part:t,subtitle:r,title:n}=s,i=g(s,["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:jsxRuntime.jsxs(F.Row,p(a({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",t]},i),{children:[jsxRuntime.jsx(h.Title,{maxWidth:"calc(100% - 32px)",children:n}),e&&jsxRuntime.jsx(h.Dismiss,{onClick:o,marginLeft:"auto"}),jsxRuntime.jsx(h.Subtitle,{color:"neutral.400",flexBasis:"100%",children:r})]}))};h.Media=t=>{var r=t,{src:e}=r,o=g(r,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsxRuntime.jsx(Pe,a({borderRadius:"md",src:e},o))};h.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:jsxRuntime.jsx(I.Primary,a({title:o,onClick:e},t))};h.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:jsxRuntime.jsx(I.Secondary,a({title:o,onClick:e},t))};h.Subtitle=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsxRuntime.jsx(R.Body2,p(a({display:"block",color:"neutral.400",part:["subtitle",o]},t),{children:e}))};h.Title=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsxRuntime.jsx(R.H4,p(a({display:"block",part:["title",o]},t),{children:e}))};var wo={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function tn(e){let o=Object.fromEntries(wo.content.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),t=Object.fromEntries(wo.root.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),r={};for(let n of Object.keys(e))!wo.content.some(i=>i===n)&&!wo.root.some(i=>i===n)&&(r[n]=e[n]);return {contentProps:o,otherProps:r,rootProps:t}}var ms=react.keyframes`
99
99
  from {
100
100
  opacity: 0;
101
101
  }