@frigade/react 2.6.1 → 2.6.2
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -93,7 +93,7 @@ var st=Object.defineProperty,sn=Object.defineProperties;var ln=Object.getOwnProp
|
|
|
93
93
|
to {
|
|
94
94
|
opacity: 1;
|
|
95
95
|
}
|
|
96
|
-
`;function fo(T){var S=T,{align:e,alignOffset:o,autoScroll:t,defaultOpen:n,dismissible:r,flow:i,handleDismiss:s,modal:l,onPrimary:d,onSecondary:u,part:m,side:f,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:n,modal:l,part:m,side:f,sideOffset:x,spotlight:v},k),{children:jsxRuntime.jsxs(h,{animation:`${Da} 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:r,handleDismiss:s,subtitle:C.subtitle,title:C.title}),jsxRuntime.jsxs(h.Footer,{children:[i.getNumberOfAvailableSteps()>1&&jsxRuntime.jsx(Ee,{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 Ar(r){var i=r,{children:e,container:o,flowId:t}=i,n=g(i,["children","container","flowId"]);return jsxRuntime.jsx(br,{container:o,children:jsxRuntime.jsx(y,p(a({"data-flow-id":t,part:"tour"},n),{children:e}))})}function go(n){var r=n,{as:e,flowId:o}=r,t=g(r,["as","flowId"]);let{onDismiss:i,onPrimary:s,onSecondary:l}=t;return jsxRuntime.jsx(z,p(a({as:null,flowId:o},t),{children:({flow:d,handleDismiss:u,parentProps:m,step:f})=>{var ee;let Q=m.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}=m,J=a({align:x,alignOffset:v,autoScroll:C,dismissible:re,flow:d,handleDismiss:u,modal:S,onPrimary:s,onSecondary:l,part:B,side:b,sideOffset:k,spotlight:w,step:f,zIndex:D},(ee=f.props)!=null?ee:{});if(O)return jsxRuntime.jsx(Ar,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:D},H),{children:jsxRuntime.jsx(fo,a({defaultOpen:T!=null?T:!0},J),f.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===f.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:s,onSecondary:l,part:B,side:b,sideOffset:k,spotlight:w,zIndex:oe},(se=_.props)!=null?se:{});return jsxRuntime.jsx(fo,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(Ar,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:D},H),{children:U}))}}))}function yo(){let{frigade:e}=Eo.useContext(A),[,o]=Eo.useState(!1),t,n=Eo.useCallback(s=>{e==null||e.getCollections().then(()=>{s();});let l=()=>{clearTimeout(t),t=setTimeout(()=>{o(d=>!d),s();},0);};return e==null||e.onStateChange(l),()=>{e==null||e.removeStateChangeHandler(l);}},[]),r=()=>{let s;try{s=e==null?void 0:e.getCollectionsSync();}catch(l){}return s};return {collections:Eo.useSyncExternalStore(n,r,r)}}function xo(e){var l,d,u,m;let{frigade:o}=Eo.useContext(A),{collections:t}=yo(),n=t==null?void 0:t.get(e),i=(m=((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(a({},f),{flow:o==null?void 0:o.getFlowSync(f.flowId)})))!=null?u:[]).find(({flow:f})=>f.isVisible))==null?void 0:m.flowId,{flow:s}=Re(i);return Eo.useEffect(()=>{o==null||o.registerCollection(e);},[e]),{collection:n,currentFlow:s}}function Xo(r){var i=r,{collectionId:e,part:o,variables:t={}}=i,n=g(i,["collectionId","part","variables"]);var u,m,f;let s={ANNOUNCEMENT:Jo,BANNER:Oo,CARD:h,CHECKLIST:ro,EMBEDDED_TIP:h,FORM:Me,NPS_SURVEY:Ge,SURVEY:Ge,TOUR:go},{currentFlow:l}=xo(e),d=(m=s[(u=l==null?void 0:l.rawData)==null?void 0:u.flowType])!=null?m:null;return l==null||d==null?null:((f=l==null?void 0:l.rawData)==null?void 0:f.flowType)===js.FlowType.FORM?jsxRuntime.jsx(y,p(a({part:["collection",o],"data-collection-id":e},n),{children:jsxRuntime.jsx(Me,{flowId:l.id,as:V,variables:t},l.id)})):jsxRuntime.jsx(y,p(a({part:["collection",o],"data-collection-id":e},n),{children:jsxRuntime.jsx(d,{flowId:l.id,variables:t},l.id)}))}function Mr(){var t,n;let{collections:e}=yo(),o=(n=Array.from((t=e==null?void 0:e.entries())!=null?t:[]).find(r=>r[1].collectionType==="DEFAULT"))==null?void 0:n[0];return xo(o),o==null?null:jsxRuntime.jsx(Xo,{as:null,collectionId:o})}var A=Eo.createContext({apiKey:"",currentModal:null,setCurrentModal:()=>{},navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});function qo(){let{frigade:e}=Eo.useContext(A);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function $r(){let{frigade:e}=qo();return Eo.useEffect(()=>{M(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(n=>{if(n.imageUri){let r=new Image;r.src=n.imageUri;}});});});},[]),null}var Wr="2.6.1";function Ur(s){var l=s,{children:e,css:o={},defaultCollection:t=!0,navigate:n,theme:r}=l,i=g(l,["children","css","defaultCollection","navigate","theme"]);let d=r?vo(r):{},u=Eo.useRef(new Map),m=Eo.useRef(),[f,x]=Eo.useState(!1),[v,C]=Eo.useState(null),P=Eo.useMemo(()=>(x(!1),m.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:Wr,__platformName:"React"})),[i.userId,i.groupId,i.apiKey]);Eo.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(m.current&&clearTimeout(m.current),f){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}),m.current&&clearTimeout(m.current),m.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=n!=null?n:(b,k="_self")=>{window.open(b,k);};return Eo.useEffect(()=>()=>{P.destroy();},[]),jsxRuntime.jsxs(A.Provider,{value:p(a({currentModal:v,setCurrentModal:C,navigate:O},i),{frigade:P,registerComponent:S,unregisterComponent:B,hasInitialized:f,variables:i.variables||{}}),children:[jsxRuntime.jsx(react.Global,{styles:{":root":a(a(a({},Ro),d),o)}}),jsxRuntime.jsxs(react.ThemeProvider,{theme:E,children:[t&&jsxRuntime.jsx(Mr,{}),e]}),i.preloadImages!==!1&&jsxRuntime.jsx($r,{})]})}function Re(e,o){let{frigade:t,variables:n}=Eo.useContext(A),[,r]=Eo.useState(!1),i=Eo.useCallback(l=>{t==null||t.getFlow(e).then(()=>{l();});let d=u=>{u.id===e&&setTimeout(()=>{r(m=>!m),l();},0);};return t==null||t.onStateChange(d),()=>{t==null||t.removeStateChangeHandler(d);}},[e,t]),s=Eo.useSyncExternalStore(i,()=>t==null?void 0:t.getFlowSync(e),()=>t==null?void 0:t.getFlowSync(e));return Eo.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:t!=null&&t.hasFailedToLoad()?!1:!s}}function Yo(e,{onComplete:o,onDismiss:t}={}){let n=Eo.useRef(null);return Eo.useEffect(()=>{if(e==null)return;function r(){return M(this,null,function*(){e.isCompleted&&n.current===!1&&(n.current=!0,yield o==null?void 0:o(e));})}return r(),n.current=e==null?void 0:e.isCompleted,()=>{r();}},[e==null?void 0:e.isCompleted]),{handleDismiss:Eo.useCallback(r=>M(this,null,function*(){if((yield t==null?void 0:t(e,r))===!1)return r.preventDefault(),!1;e.skip();}),[e])}}function jr(e,o=!0){let{currentModal:t,setCurrentModal:n}=Eo.useContext(A),r=Eo.useCallback(s=>{o&&e.isVisible&&n(s);},[o,e==null?void 0:e.isVisible]),i=Eo.useCallback(()=>{e!=null&&t===(e==null?void 0:e.id)&&n(null);},[t,e==null?void 0:e.id]);return Eo.useEffect(()=>(e!=null&&t===null&&e.isVisible&&r(e.id),i),[t,e==null?void 0:e.id,e==null?void 0:e.isVisible]),Eo.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}:{hasModalCollision:!0}}function et(e){return typeof e=="function"&&e.displayName==="Dialog"}function z(u){var m=u,{as:e,children:o,flowId:t,onComplete:n,onDismiss:r,onPrimary:i,onSecondary:s,variables:l}=m,d=g(m,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var U,Q,ee,q;let{flow:f}=Re(t,{variables:l}),x=f==null?void 0:f.getCurrentStep(),v=(U=x==null?void 0:x.props)!=null?U:{},{otherProps:C}=pe(v),_=a(a(a({},d),(Q=f==null?void 0:f.props)!=null?Q:{}),((ee=f==null?void 0:f.rawData)==null?void 0:ee.flowType)===js.FlowType.CHECKLIST?{}:C),{dismissible:P=!!et(e),forceMount:T=!1}=_,S=g(_,["dismissible","forceMount"]),{handleDismiss:B}=Yo(f,{onComplete:n,onDismiss:r}),{handlePrimary:O,handleSecondary:b}=ge(x,{onPrimary:i,onSecondary:s}),k=(S==null?void 0:S.modal)||et(e)||[js.FlowType.ANNOUNCEMENT,js.FlowType.TOUR].includes((q=f==null?void 0:f.rawData)==null?void 0:q.flowType),{hasModalCollision:w}=jr(f,k);function D(j){if(P===!1){j.preventDefault();return}typeof d.onEscapeKeyDown=="function"&&d.onEscapeKeyDown(j),j.defaultPrevented||B(j);}let H=T&&((f==null?void 0:f.isCompleted)||(f==null?void 0:f.isSkipped));if(!f||(!f.isVisible||w)&&!H)return null;(H||!f.isCompleted&&!f.isSkipped)&&(x==null||x.start());let re=e===null?Eo.Fragment:e!=null?e:y,J=p(a({},S),{"data-flow-id":f.id});return et(e)&&(J.onEscapeKeyDown=D),jsxRuntime.jsx(re,p(a({},e===null?{}:J),{children:o({flow:f,handleDismiss:B,handlePrimary:O,handleSecondary:b,parentProps:{dismissible:P,flowId:t,variables:l,containerProps:J},step:x})}))}function Jr(t){var n=t,{part:e}=n,o=g(n,["part"]);return jsxRuntime.jsx(z,p(a({as:h,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:r,handlePrimary:i,handleSecondary:s,parentProps:{dismissible:l},step:d})=>{var x,v,C,P,T,S;let u=(v=(x=d.primaryButton)==null?void 0:x.title)!=null?v:d.primaryButtonTitle,m=(P=(C=d.secondaryButton)==null?void 0:C.title)!=null?P:d.secondaryButtonTitle,{videoProps:f}=pe((T=d.props)!=null?T:{});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(h.Header,{dismissible:l,handleDismiss:r,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%"}},f)),jsxRuntime.jsxs(F.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsxRuntime.jsx(h.Secondary,{title:m,onClick:s}),jsxRuntime.jsx(h.Primary,{title:u,onClick:i})]})]})}}))}function bo(n){var r=n,{part:e,src:o}=r,t=g(r,["part","src"]);return jsxRuntime.jsx(y,a({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function ss(e){var o,t,n,r,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/${(n=e.split("vimeo.com/")[1])==null?void 0:n.split("&")[0]}`:e.includes("wistia")?`https://fast.wistia.net/embed/iframe/${(r=e.split("wistia.com/medias/")[1])==null?void 0:r.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 Po(C){var P=C,{autoPlay:e,controls:o,controlsList:t,crossOrigin:n,disablePictureInPicture:r,disableRemotePlayback:i,loop:s,muted:l,playsInline:d,poster:u,preload:m,part:f,src:x}=P,v=g(P,["autoPlay","controls","controlsList","crossOrigin","disablePictureInPicture","disableRemotePlayback","loop","muted","playsInline","poster","preload","part","src"]);let T=ss(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",f],src:T},v)):x!=null&&x.endsWith(".mp4")?jsxRuntime.jsx(y,a({as:"video",part:["video",f],src:x,autoPlay:e,controls:o!=null?o:!0,controlsList:t,crossOrigin:n,disablePictureInPicture:r,disableRemotePlayback:i,loop:s,muted:l!=null?l:e,playsInline:d,poster:u,preload:m},v)):(console.error(`Could not map videoUri ${x} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function be(n){var r=n,{src:e,type:o}=r,t=g(r,["src","type"]);return jsxRuntime.jsx(o==="video"?Po:bo,a({src:e},t))}var h=Eo__namespace.forwardRef((i,r)=>{var s=i,{children:e,flowId:o,part:t}=s,n=g(s,["children","flowId","part"]);var d;if(o!=null)return jsxRuntime.jsx(Jr,a({flowId:o},n));let l=(d=n.as)!=null?d:F.Column;return jsxRuntime.jsx(l,p(a({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5,part:["card",t]},n),{ref:r,children:e}))});h.Dismiss=e=>jsxRuntime.jsx(I.Plain,p(a({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsxRuntime.jsx(ke,{height:"20",fill:"currentColor"})}));h.Footer=n=>{var r=n,{children:e,part:o}=r,t=g(r,["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=s=>{var l=s,{dismissible:e,handleDismiss:o,part:t,subtitle:n,title:r}=l,i=g(l,["dismissible","handleDismiss","part","subtitle","title"]);return !e&&(r==null||(r==null?void 0:r.length)===0)&&(n==null||(n==null?void 0:n.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:r}),e&&jsxRuntime.jsx(h.Dismiss,{onClick:o,marginLeft:"auto"}),jsxRuntime.jsx(h.Subtitle,{color:"neutral.400",flexBasis:"100%",children:n})]}))};h.Media=t=>{var n=t,{src:e}=n,o=g(n,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsxRuntime.jsx(be,a({borderRadius:"md",src:e},o))};h.Primary=n=>{var r=n,{onClick:e,title:o}=r,t=g(r,["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=n=>{var r=n,{onClick:e,title:o}=r,t=g(r,["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=n=>{var r=n,{children:e,part:o}=r,t=g(r,["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=n=>{var r=n,{children:e,part:o}=r,t=g(r,["children","part"]);return e==null?null:jsxRuntime.jsx(R.H4,p(a({display:"block",part:["title",o]},t),{children:e}))};var Co={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function Yr(e){let o=Object.fromEntries(Co.content.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),t=Object.fromEntries(Co.root.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),n={};for(let r of Object.keys(e))!Co.content.some(i=>i===r)&&!Co.root.some(i=>i===r)&&(n[r]=e[r]);return {contentProps:o,otherProps:n,rootProps:t}}var cs=react.keyframes`
|
|
96
|
+
`;function fo(T){var S=T,{align:e,alignOffset:o,autoScroll:t,defaultOpen:n,dismissible:r,flow:i,handleDismiss:s,modal:l,onPrimary:d,onSecondary:u,part:m,side:f,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:n,modal:l,part:m,side:f,sideOffset:x,spotlight:v},k),{children:jsxRuntime.jsxs(h,{animation:`${Da} 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:r,handleDismiss:s,subtitle:C.subtitle,title:C.title}),jsxRuntime.jsxs(h.Footer,{children:[i.getNumberOfAvailableSteps()>1&&jsxRuntime.jsx(Ee,{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 Ar(r){var i=r,{children:e,container:o,flowId:t}=i,n=g(i,["children","container","flowId"]);return jsxRuntime.jsx(br,{container:o,children:jsxRuntime.jsx(y,p(a({"data-flow-id":t,part:"tour"},n),{children:e}))})}function go(n){var r=n,{as:e,flowId:o}=r,t=g(r,["as","flowId"]);let{onDismiss:i,onPrimary:s,onSecondary:l}=t;return jsxRuntime.jsx(z,p(a({as:null,flowId:o},t),{children:({flow:d,handleDismiss:u,parentProps:m,step:f})=>{var ee;let Q=m.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}=m,J=a({align:x,alignOffset:v,autoScroll:C,dismissible:re,flow:d,handleDismiss:u,modal:S,onPrimary:s,onSecondary:l,part:B,side:b,sideOffset:k,spotlight:w,step:f,zIndex:D},(ee=f.props)!=null?ee:{});if(O)return jsxRuntime.jsx(Ar,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:D},H),{children:jsxRuntime.jsx(fo,a({defaultOpen:T!=null?T:!0},J),f.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===f.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:s,onSecondary:l,part:B,side:b,sideOffset:k,spotlight:w,zIndex:oe},(se=_.props)!=null?se:{});return jsxRuntime.jsx(fo,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(Ar,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:D},H),{children:U}))}}))}function yo(){let{frigade:e}=Eo.useContext(A),[,o]=Eo.useState(!1),t,n=Eo.useCallback(s=>{e==null||e.getCollections().then(()=>{s();});let l=()=>{clearTimeout(t),t=setTimeout(()=>{o(d=>!d),s();},0);};return e==null||e.onStateChange(l),()=>{e==null||e.removeStateChangeHandler(l);}},[]),r=()=>{let s;try{s=e==null?void 0:e.getCollectionsSync();}catch(l){}return s};return {collections:Eo.useSyncExternalStore(n,r,r)}}function xo(e){var l,d,u,m;let{frigade:o}=Eo.useContext(A),{collections:t}=yo(),n=t==null?void 0:t.get(e),i=(m=((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(a({},f),{flow:o==null?void 0:o.getFlowSync(f.flowId)})))!=null?u:[]).find(({flow:f})=>f.isVisible))==null?void 0:m.flowId,{flow:s}=Re(i);return Eo.useEffect(()=>{o==null||o.registerCollection(e);},[e]),{collection:n,currentFlow:s}}function Xo(r){var i=r,{collectionId:e,part:o,variables:t={}}=i,n=g(i,["collectionId","part","variables"]);var u,m,f;let s={ANNOUNCEMENT:Jo,BANNER:Oo,CARD:h,CHECKLIST:ro,EMBEDDED_TIP:h,FORM:Me,NPS_SURVEY:Ge,SURVEY:Ge,TOUR:go},{currentFlow:l}=xo(e),d=(m=s[(u=l==null?void 0:l.rawData)==null?void 0:u.flowType])!=null?m:null;return l==null||d==null?null:((f=l==null?void 0:l.rawData)==null?void 0:f.flowType)===js.FlowType.FORM?jsxRuntime.jsx(y,p(a({part:["collection",o],"data-collection-id":e},n),{children:jsxRuntime.jsx(Me,{flowId:l.id,as:V,variables:t},l.id)})):jsxRuntime.jsx(y,p(a({part:["collection",o],"data-collection-id":e},n),{children:jsxRuntime.jsx(d,{flowId:l.id,variables:t},l.id)}))}function Mr(){var t,n;let{collections:e}=yo(),o=(n=Array.from((t=e==null?void 0:e.entries())!=null?t:[]).find(r=>r[1].collectionType==="DEFAULT"))==null?void 0:n[0];return xo(o),o==null?null:jsxRuntime.jsx(Xo,{as:null,collectionId:o})}var A=Eo.createContext({apiKey:"",currentModal:null,setCurrentModal:()=>{},navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});function qo(){let{frigade:e}=Eo.useContext(A);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function $r(){let{frigade:e}=qo();return Eo.useEffect(()=>{M(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(n=>{if(n.imageUri){let r=new Image;r.src=n.imageUri;}});});});},[]),null}var Wr="2.6.2";function Ur(s){var l=s,{children:e,css:o={},defaultCollection:t=!0,navigate:n,theme:r}=l,i=g(l,["children","css","defaultCollection","navigate","theme"]);let d=r?vo(r):{},u=Eo.useRef(new Map),m=Eo.useRef(),[f,x]=Eo.useState(!1),[v,C]=Eo.useState(null),P=Eo.useMemo(()=>(x(!1),m.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:Wr,__platformName:"React"})),[i.userId,i.groupId,i.apiKey]);Eo.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(m.current&&clearTimeout(m.current),f){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}),m.current&&clearTimeout(m.current),m.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=n!=null?n:(b,k="_self")=>{window.open(b,k);};return Eo.useEffect(()=>()=>{P.destroy();},[]),jsxRuntime.jsxs(A.Provider,{value:p(a({currentModal:v,setCurrentModal:C,navigate:O},i),{frigade:P,registerComponent:S,unregisterComponent:B,hasInitialized:f,variables:i.variables||{}}),children:[jsxRuntime.jsx(react.Global,{styles:{":root":a(a(a({},Ro),d),o)}}),jsxRuntime.jsxs(react.ThemeProvider,{theme:E,children:[t&&jsxRuntime.jsx(Mr,{}),e]}),i.preloadImages!==!1&&jsxRuntime.jsx($r,{})]})}function Re(e,o){let{frigade:t,variables:n}=Eo.useContext(A),[,r]=Eo.useState(!1),i=Eo.useCallback(l=>{t==null||t.getFlow(e).then(()=>{l();});let d=u=>{u.id===e&&setTimeout(()=>{r(m=>!m),l();},0);};return t==null||t.onStateChange(d),()=>{t==null||t.removeStateChangeHandler(d);}},[e,t]),s=Eo.useSyncExternalStore(i,()=>t==null?void 0:t.getFlowSync(e),()=>t==null?void 0:t.getFlowSync(e));return Eo.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:t!=null&&t.hasFailedToLoad()?!1:!s}}function Yo(e,{onComplete:o,onDismiss:t}={}){let n=Eo.useRef(null);return Eo.useEffect(()=>{if(e==null)return;function r(){return M(this,null,function*(){e.isCompleted&&n.current===!1&&(n.current=!0,yield o==null?void 0:o(e));})}return r(),n.current=e==null?void 0:e.isCompleted,()=>{r();}},[e==null?void 0:e.isCompleted]),{handleDismiss:Eo.useCallback(r=>M(this,null,function*(){if((yield t==null?void 0:t(e,r))===!1)return r.preventDefault(),!1;e.skip();}),[e])}}function jr(e,o=!0){let{currentModal:t,setCurrentModal:n}=Eo.useContext(A),r=Eo.useCallback(s=>{o&&(e!=null&&e.isVisible)&&n(s);},[o,e==null?void 0:e.isVisible]),i=Eo.useCallback(()=>{e!=null&&t===(e==null?void 0:e.id)&&n(null);},[t,e==null?void 0:e.id]);return Eo.useEffect(()=>(e!=null&&t===null&&e.isVisible&&r(e.id),i),[t,e==null?void 0:e.id,e==null?void 0:e.isVisible]),Eo.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 et(e){return typeof e=="function"&&e.displayName==="Dialog"}function z(u){var m=u,{as:e,children:o,flowId:t,onComplete:n,onDismiss:r,onPrimary:i,onSecondary:s,variables:l}=m,d=g(m,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var U,Q,ee,q;let{flow:f}=Re(t,{variables:l}),x=f==null?void 0:f.getCurrentStep(),v=(U=x==null?void 0:x.props)!=null?U:{},{otherProps:C}=pe(v),_=a(a(a({},d),(Q=f==null?void 0:f.props)!=null?Q:{}),((ee=f==null?void 0:f.rawData)==null?void 0:ee.flowType)===js.FlowType.CHECKLIST?{}:C),{dismissible:P=!!et(e),forceMount:T=!1}=_,S=g(_,["dismissible","forceMount"]),{handleDismiss:B}=Yo(f,{onComplete:n,onDismiss:r}),{handlePrimary:O,handleSecondary:b}=ge(x,{onPrimary:i,onSecondary:s}),k=(S==null?void 0:S.modal)||et(e)||[js.FlowType.ANNOUNCEMENT,js.FlowType.TOUR].includes((q=f==null?void 0:f.rawData)==null?void 0:q.flowType),{hasModalCollision:w}=jr(f,k);function D(j){if(P===!1){j.preventDefault();return}typeof d.onEscapeKeyDown=="function"&&d.onEscapeKeyDown(j),j.defaultPrevented||B(j);}let H=T&&((f==null?void 0:f.isCompleted)||(f==null?void 0:f.isSkipped));if(!f||(!f.isVisible||w)&&!H)return null;(H||!f.isCompleted&&!f.isSkipped)&&(x==null||x.start());let re=e===null?Eo.Fragment:e!=null?e:y,J=p(a({},S),{"data-flow-id":f.id});return et(e)&&(J.onEscapeKeyDown=D),jsxRuntime.jsx(re,p(a({},e===null?{}:J),{children:o({flow:f,handleDismiss:B,handlePrimary:O,handleSecondary:b,parentProps:{dismissible:P,flowId:t,variables:l,containerProps:J},step:x})}))}function Jr(t){var n=t,{part:e}=n,o=g(n,["part"]);return jsxRuntime.jsx(z,p(a({as:h,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:r,handlePrimary:i,handleSecondary:s,parentProps:{dismissible:l},step:d})=>{var x,v,C,P,T,S;let u=(v=(x=d.primaryButton)==null?void 0:x.title)!=null?v:d.primaryButtonTitle,m=(P=(C=d.secondaryButton)==null?void 0:C.title)!=null?P:d.secondaryButtonTitle,{videoProps:f}=pe((T=d.props)!=null?T:{});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(h.Header,{dismissible:l,handleDismiss:r,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%"}},f)),jsxRuntime.jsxs(F.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsxRuntime.jsx(h.Secondary,{title:m,onClick:s}),jsxRuntime.jsx(h.Primary,{title:u,onClick:i})]})]})}}))}function bo(n){var r=n,{part:e,src:o}=r,t=g(r,["part","src"]);return jsxRuntime.jsx(y,a({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function ss(e){var o,t,n,r,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/${(n=e.split("vimeo.com/")[1])==null?void 0:n.split("&")[0]}`:e.includes("wistia")?`https://fast.wistia.net/embed/iframe/${(r=e.split("wistia.com/medias/")[1])==null?void 0:r.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 Po(C){var P=C,{autoPlay:e,controls:o,controlsList:t,crossOrigin:n,disablePictureInPicture:r,disableRemotePlayback:i,loop:s,muted:l,playsInline:d,poster:u,preload:m,part:f,src:x}=P,v=g(P,["autoPlay","controls","controlsList","crossOrigin","disablePictureInPicture","disableRemotePlayback","loop","muted","playsInline","poster","preload","part","src"]);let T=ss(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",f],src:T},v)):x!=null&&x.endsWith(".mp4")?jsxRuntime.jsx(y,a({as:"video",part:["video",f],src:x,autoPlay:e,controls:o!=null?o:!0,controlsList:t,crossOrigin:n,disablePictureInPicture:r,disableRemotePlayback:i,loop:s,muted:l!=null?l:e,playsInline:d,poster:u,preload:m},v)):(console.error(`Could not map videoUri ${x} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function be(n){var r=n,{src:e,type:o}=r,t=g(r,["src","type"]);return jsxRuntime.jsx(o==="video"?Po:bo,a({src:e},t))}var h=Eo__namespace.forwardRef((i,r)=>{var s=i,{children:e,flowId:o,part:t}=s,n=g(s,["children","flowId","part"]);var d;if(o!=null)return jsxRuntime.jsx(Jr,a({flowId:o},n));let l=(d=n.as)!=null?d:F.Column;return jsxRuntime.jsx(l,p(a({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5,part:["card",t]},n),{ref:r,children:e}))});h.Dismiss=e=>jsxRuntime.jsx(I.Plain,p(a({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsxRuntime.jsx(ke,{height:"20",fill:"currentColor"})}));h.Footer=n=>{var r=n,{children:e,part:o}=r,t=g(r,["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=s=>{var l=s,{dismissible:e,handleDismiss:o,part:t,subtitle:n,title:r}=l,i=g(l,["dismissible","handleDismiss","part","subtitle","title"]);return !e&&(r==null||(r==null?void 0:r.length)===0)&&(n==null||(n==null?void 0:n.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:r}),e&&jsxRuntime.jsx(h.Dismiss,{onClick:o,marginLeft:"auto"}),jsxRuntime.jsx(h.Subtitle,{color:"neutral.400",flexBasis:"100%",children:n})]}))};h.Media=t=>{var n=t,{src:e}=n,o=g(n,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsxRuntime.jsx(be,a({borderRadius:"md",src:e},o))};h.Primary=n=>{var r=n,{onClick:e,title:o}=r,t=g(r,["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=n=>{var r=n,{onClick:e,title:o}=r,t=g(r,["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=n=>{var r=n,{children:e,part:o}=r,t=g(r,["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=n=>{var r=n,{children:e,part:o}=r,t=g(r,["children","part"]);return e==null?null:jsxRuntime.jsx(R.H4,p(a({display:"block",part:["title",o]},t),{children:e}))};var Co={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function Yr(e){let o=Object.fromEntries(Co.content.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),t=Object.fromEntries(Co.root.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),n={};for(let r of Object.keys(e))!Co.content.some(i=>i===r)&&!Co.root.some(i=>i===r)&&(n[r]=e[r]);return {contentProps:o,otherProps:n,rootProps:t}}var cs=react.keyframes`
|
|
97
97
|
from {
|
|
98
98
|
opacity: 0;
|
|
99
99
|
}
|