@frigade/react 2.5.15 → 2.5.16
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.d.ts +0 -10
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -86,7 +86,7 @@ var nt=Object.defineProperty,Qr=Object.defineProperties;var en=Object.getOwnProp
|
|
|
86
86
|
to {
|
|
87
87
|
opacity: 1;
|
|
88
88
|
}
|
|
89
|
-
`;function uo(v){var B=v,{align:e,alignOffset:o,defaultOpen:t,dismissible:n,flow:r,handleDismiss:a,modal:p,onPrimary:s,onSecondary:d,part:u,side:m,sideOffset:g,spotlight:b,step:x}=B,T=f(B,["align","alignOffset","defaultOpen","dismissible","flow","handleDismiss","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var $,L,E,I,A;let{handlePrimary:w,handleSecondary:P}=le(x,{onPrimary:s,onSecondary:d}),C=(L=($=x.primaryButton)==null?void 0:$.title)!=null?L:x.primaryButtonTitle,R=(I=(E=x.secondaryButton)==null?void 0:E.title)!=null?I:x.secondaryButtonTitle,k=!!x.$state.blocked;return jsxRuntime.jsx(Uo,l(i({align:e,alignOffset:o,anchor:x.selector,"data-step-id":x.id,defaultOpen:t,modal:p,part:u,side:m,sideOffset:g,spotlight:b},T),{children:jsxRuntime.jsxs(h,{animation:`${ca} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsxRuntime.jsx(h.Media,{aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(A=x.videoUri)!=null?A:x.imageUri,transform:"translate3d(0, 0, 1px)",type:x.videoUri?"video":"image"}),jsxRuntime.jsx(h.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:a,subtitle:x.subtitle,title:x.title}),jsxRuntime.jsxs(h.Footer,{children:[r.getNumberOfAvailableSteps()>1&&jsxRuntime.jsx(Be,{current:r.getCurrentStepOrder()+1,marginRight:"auto",total:r.getNumberOfAvailableSteps()}),jsxRuntime.jsx(h.Secondary,{disabled:k,onClick:P,title:R}),jsxRuntime.jsx(h.Primary,{disabled:k,onClick:w,title:C})]})]})}))}function Tr(e,o,t){let[n,r]=ko.useState(!1),a=ko.useRef();return ko.useEffect(()=>{a.current=typeof o=="string"?document.querySelector(o):o,r(!0);},[]),n?reactDom.createPortal(e,a.current,t):null}function mo(T){var v=T,{align:e="after",alignOffset:o=0,as:t,defaultOpen:n,dismissible:r=!1,flowId:a,modal:p,part:s,sequential:d=!0,side:u="bottom",sideOffset:m=0,spotlight:g,zIndex:b=9999}=v,x=f(v,["align","alignOffset","as","defaultOpen","dismissible","flowId","modal","part","sequential","side","sideOffset","spotlight","zIndex"]);let{onDismiss:B,onPrimary:w,onSecondary:P}=x;return Tr(jsxRuntime.jsx(_,l(i({as:t,flowId:a,part:"tour"},x),{children:({flow:C,handleDismiss:R,parentProps:{containerProps:k},step:$})=>{var E,I,A,he;let L=i({align:e,alignOffset:o,dismissible:r,flow:C,handleDismiss:R,modal:p,onPrimary:w,onSecondary:P,part:s,side:u,sideOffset:m,spotlight:g,step:$,zIndex:(A=(I=(E=$.props)==null?void 0:E.zIndex)!=null?I:k==null?void 0:k.zIndex)!=null?A:b},(he=$.props)!=null?he:{});return d?jsxRuntime.jsx(uo,i({defaultOpen:n!=null?n:!0},L),$.id):Array.from(C.steps.values()).filter(Q=>{let{blocked:Ae,completed:ue,skipped:ee,visible:Fe}=Q.$state;return !Ae&&!ue&&!ee&&Fe}).map(Q=>{var je,K,oe,ne,te;function Ae(me){return M(this,null,function*(){return (yield B==null?void 0:B(C,me))===!1?(me.preventDefault(),!1):(Q.skip(),!0)})}let ue=g&&Q.id===$.id,ee=(oe=(K=(je=Q.props)==null?void 0:je.zIndex)!=null?K:k==null?void 0:k.zIndex)!=null?oe:b,Fe=i({align:e,alignOffset:o,dismissible:r,flow:C,handleDismiss:Ae,onPrimary:w,onSecondary:P,part:s,side:u,sideOffset:m,spotlight:g,zIndex:ee},(ne=Q.props)!=null?ne:{});return jsxRuntime.jsx(uo,i({css:{"&:has([aria-expanded=true])":{zIndex:Number(ee)+2},".fr-overlay":{zIndex:Number(ee)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(te=n||ue)!=null?te:!1,step:Q},Fe),`${Q.id}-${ue}`)})}})),"body")}function fo(){let{frigade:e}=ko.useContext(V),[,o]=ko.useState(!1),t,n=ko.useCallback(p=>{e==null||e.getCollections().then(()=>{p();});let s=()=>{clearTimeout(t),t=setTimeout(()=>{o(d=>!d),p();},0);};return e==null||e.onStateChange(s),()=>{e==null||e.removeStateChangeHandler(s);}},[]),r=()=>{let p;try{p=e==null?void 0:e.getCollectionsSync();}catch(s){}return p};return {collections:ko.useSyncExternalStore(n,r,r)}}function go(e){var s,d,u,m;let{frigade:o}=ko.useContext(V),{collections:t}=fo(),n=t==null?void 0:t.get(e),a=(m=((u=(d=(s=t==null?void 0:t.get(e))==null?void 0:s.flows)==null?void 0:d.filter(g=>g.visible).map(g=>l(i({},g),{flow:o==null?void 0:o.getFlowSync(g.flowId)})))!=null?u:[]).find(({flow:g})=>g.isVisible))==null?void 0:m.flowId,{flow:p}=we(a);return ko.useEffect(()=>{o==null||o.registerCollection(e);},[e]),{collection:n,currentFlow:p}}function Ko(r){var a=r,{collectionId:e,part:o,variables:t={}}=a,n=f(a,["collectionId","part","variables"]);var u,m,g;let p={ANNOUNCEMENT:jo,BANNER:Eo,CARD:h,CHECKLIST:to,EMBEDDED_TIP:h,FORM:He,NPS_SURVEY:_e,SURVEY:_e,TOUR:mo},{currentFlow:s}=go(e),d=(m=p[(u=s==null?void 0:s.rawData)==null?void 0:u.flowType])!=null?m:null;return s==null||d==null?null:((g=s==null?void 0:s.rawData)==null?void 0:g.flowType)===js.FlowType.FORM?jsxRuntime.jsx(y,l(i({part:["collection",o],"data-collection-id":e},n),{children:jsxRuntime.jsx(He,{flowId:s.id,as:H,variables:t},s.id)})):jsxRuntime.jsx(y,l(i({part:["collection",o],"data-collection-id":e},n),{children:jsxRuntime.jsx(d,{flowId:s.id,variables:t},s.id)}))}function kr(){var t,n;let{collections:e}=fo(),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 go(o),o==null?null:jsxRuntime.jsx(Ko,{as:null,collectionId:o})}var V=ko.createContext({apiKey:"",navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});function Xo(){let{frigade:e}=ko.useContext(V);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function Er(){let{frigade:e}=Xo();return ko.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 Or="2.5.15";function $r(p){var s=p,{children:e,css:o={},defaultCollection:t=!0,navigate:n,theme:r}=s,a=f(s,["children","css","defaultCollection","navigate","theme"]);let d=r?Fo(r):{},u=ko.useRef(new Map),m=ko.useRef(),[g,b]=ko.useState(!1),x=ko.useMemo(()=>(b(!1),m.current=void 0,new js.Frigade(a.apiKey,{apiKey:a.apiKey,apiUrl:a.apiUrl,userId:a.userId,groupId:a.groupId,userProperties:a.userProperties,groupProperties:a.groupProperties,generateGuestId:a.generateGuestId,syncOnWindowUpdates:a.syncOnWindowUpdates,__readOnly:a.__readOnly,__flowStateOverrides:a.__flowStateOverrides,__platformVersion:Or,__platformName:"React"})),[a.userId,a.groupId,a.apiKey]);ko.useEffect(()=>{if(a.__flowStateOverrides){let P=x.getConfig();P.__flowStateOverrides=a.__flowStateOverrides,x.reload(P);}},[a.__flowStateOverrides]);function T(){let P=[...u.current.entries()].map(([C,R])=>[C,R.callback]);x.batchRegister(P),b(!0);}function v(P,C){if(m.current&&clearTimeout(m.current),g){u.current.has(P)?x.getFlow(P).then(R=>C(R.isVisible)):(x.getFlow(P).then(R=>R.register(C)),u.current.set(P,{callback:C}));return}u.current.has(P)||u.current.set(P,{callback:C}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>T(),0);}function B(P){u.current.has(P)&&x.getFlow(P).then(C=>{u.current.delete(P),C==null||C.unregister();});}let w=n!=null?n:(P,C="_self")=>{window.open(P,C);};return ko.useEffect(()=>()=>{x.destroy();},[]),jsxRuntime.jsxs(V.Provider,{value:l(i({navigate:w},a),{frigade:x,registerComponent:v,unregisterComponent:B,hasInitialized:g,variables:a.variables||{}}),children:[jsxRuntime.jsx(react.Global,{styles:{":root":i(i(i({},vo),d),o)}}),jsxRuntime.jsxs(react.ThemeProvider,{theme:O,children:[t&&jsxRuntime.jsx(kr,{}),e]}),a.preloadImages!==!1&&jsxRuntime.jsx(Er,{})]})}function we(e,o){let{frigade:t,variables:n}=ko.useContext(V),[,r]=ko.useState(!1),a=ko.useCallback(s=>{t==null||t.getFlow(e).then(()=>{s();});let d=u=>{u.id===e&&setTimeout(()=>{r(m=>!m),s();},0);};return t==null||t.onStateChange(d),()=>{t==null||t.removeStateChangeHandler(d);}},[e,t]),p=ko.useSyncExternalStore(a,()=>t==null?void 0:t.getFlowSync(e),()=>t==null?void 0:t.getFlowSync(e));return p==null||p.applyVariables(i(i({},n),o==null?void 0:o.variables)),{flow:p,isLoading:t!=null&&t.hasFailedToLoad()?!1:!p}}function qo(e,{onComplete:o,onDismiss:t}={}){let n=ko.useRef(null);return ko.useEffect(()=>{if(e==null)return;function r(){return M(this,null,function*(){e.isCompleted&&n.current===!1&&(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:ko.useCallback(r=>M(this,null,function*(){if((yield t==null?void 0:t(e,r))===!1)return r.preventDefault(),!1;e.skip();}),[e])}}var de=new Set;function Zo(e,o=!0){let t=ko.useCallback(()=>{de.has(e==null?void 0:e.id)&&de.delete(e==null?void 0:e.id);},[de,o]),n=ko.useCallback(()=>{o&&(e!=null&&e.isVisible)&&!de.has(e.id)&&de.add(e.id);},[de,o]);ko.useEffect(()=>()=>{t();},[]),ko.useEffect(()=>{n();let a=()=>{t();};return window.addEventListener("popstate",a),window.addEventListener("beforeunload",a),()=>{t(),window.removeEventListener("popstate",a),window.removeEventListener("beforeunload",a);}},[n,t]),e!=null&&e.isVisible?n():t();let r=de.size>0?de.values().next().value:null;return {isCurrentModal:o?r===(e==null?void 0:e.id)||de.size==0:!0}}function _(u){var m=u,{as:e,children:o,flowId:t,onComplete:n,onDismiss:r,onPrimary:a,onSecondary:p,variables:s}=m,d=f(m,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var E,A;let{flow:g}=we(t,{variables:s}),I=i(i({},d),(E=g==null?void 0:g.props)!=null?E:{}),{dismissible:b=!1,forceMount:x=!1}=I,T=f(I,["dismissible","forceMount"]),v=g==null?void 0:g.getCurrentStep(),{handleDismiss:B}=qo(g,{onComplete:n,onDismiss:r}),{handlePrimary:w,handleSecondary:P}=le(v,{onPrimary:a,onSecondary:p}),C=(T==null?void 0:T.modal)||typeof e=="function"&&(e==null?void 0:e.displayName)==="Dialog"||[js.FlowType.ANNOUNCEMENT,js.FlowType.TOUR].includes((A=g==null?void 0:g.rawData)==null?void 0:A.flowType),{isCurrentModal:R}=Zo(g,C),k=x&&((g==null?void 0:g.isCompleted)||(g==null?void 0:g.isSkipped));if(!g||!g.isVisible&&!k||!k&&!R)return null;(k||!g.isCompleted&&!g.isSkipped)&&(v==null||v.start());let $=e===null?ko.Fragment:e!=null?e:y,L=l(i({},T),{"data-flow-id":g.id});return jsxRuntime.jsx($,l(i({},e===null?{}:L),{children:o({flow:g,handleDismiss:B,handlePrimary:w,handleSecondary:P,parentProps:{dismissible:b,flowId:t,variables:s,containerProps:L},step:v})}))}function Lr(t){var n=t,{part:e}=n,o=f(n,["part"]);return jsxRuntime.jsx(_,l(i({as:h,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:r,handlePrimary:a,handleSecondary:p,parentProps:{dismissible:s},step:d})=>{var g,b,x,T;let u=(b=(g=d.primaryButton)==null?void 0:g.title)!=null?b:d.primaryButtonTitle,m=(T=(x=d.secondaryButton)==null?void 0:x.title)!=null?T:d.secondaryButtonTitle;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(h.Header,{dismissible:s,handleDismiss:r,subtitle:d.subtitle,title:d.title}),jsxRuntime.jsx(h.Media,{src:d.imageUri,css:{objectFit:"contain",width:"100%"}}),jsxRuntime.jsxs(S.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsxRuntime.jsx(h.Secondary,{title:m,onClick:p}),jsxRuntime.jsx(h.Primary,{title:u,onClick:a})]})]})}}))}function xo(n){var r=n,{part:e,src:o}=r,t=f(r,["part","src"]);return jsxRuntime.jsx(y,i({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function _a(e){var o,t,n,r,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/${(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/${(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 ho(n){var r=n,{part:e,src:o}=r,t=f(r,["part","src"]);let a=_a(o);return a?jsxRuntime.jsx(y,i({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"neutral.100",borderWidth:"0",part:["video",e],src:a},t)):o!=null&&o.endsWith(".mp4")?jsxRuntime.jsx(y,i({as:"video",controls:!0,part:["video",e],src:o},t)):(console.error(`Could not map videoUri ${o} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function ye(n){var r=n,{src:e,type:o}=r,t=f(r,["src","type"]);return jsxRuntime.jsx(o==="video"?ho:xo,i({src:e},t))}var h=ko__namespace.forwardRef((a,r)=>{var p=a,{children:e,flowId:o,part:t}=p,n=f(p,["children","flowId","part"]);var d;if(o!=null)return jsxRuntime.jsx(Lr,i({flowId:o},n));let s=(d=n.as)!=null?d:S.Column;return jsxRuntime.jsx(s,l(i({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(D.Plain,l(i({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsxRuntime.jsx(ve,{height:"20",fill:"currentColor"})}));h.Footer=n=>{var r=n,{children:e,part:o}=r,t=f(r,["children","part"]);return jsxRuntime.jsx(S.Row,l(i({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",o]},t),{children:e}))};h.Header=p=>{var s=p,{dismissible:e,handleDismiss:o,part:t,subtitle:n,title:r}=s,a=f(s,["dismissible","handleDismiss","part","subtitle","title"]);return jsxRuntime.jsxs(S.Row,l(i({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",t]},a),{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=f(n,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsxRuntime.jsx(ye,i({borderRadius:"md",src:e},o))};h.Primary=n=>{var r=n,{onClick:e,title:o}=r,t=f(r,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Primary,i({title:o,onClick:e},t))};h.Secondary=n=>{var r=n,{onClick:e,title:o}=r,t=f(r,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Secondary,i({title:o,onClick:e},t))};h.Subtitle=n=>{var r=n,{children:e,part:o}=r,t=f(r,["children","part"]);return e==null?null:jsxRuntime.jsx(F.Body2,l(i({display:"block",color:"neutral.400",part:["subtitle",o]},t),{children:e}))};h.Title=n=>{var r=n,{children:e,part:o}=r,t=f(r,["children","part"]);return e==null?null:jsxRuntime.jsx(F.H4,l(i({display:"block",part:["title",o]},t),{children:e}))};var bo={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function _r(e){let o=Object.fromEntries(bo.content.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),t=Object.fromEntries(bo.root.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),n={};for(let r of Object.keys(e))!bo.content.some(a=>a===r)&&!bo.root.some(a=>a===r)&&(n[r]=e[r]);return {contentProps:o,otherProps:n,rootProps:t}}var ja=react.keyframes`
|
|
89
|
+
`;function uo(v){var B=v,{align:e,alignOffset:o,defaultOpen:t,dismissible:n,flow:r,handleDismiss:a,modal:p,onPrimary:s,onSecondary:d,part:u,side:m,sideOffset:g,spotlight:b,step:x}=B,T=f(B,["align","alignOffset","defaultOpen","dismissible","flow","handleDismiss","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var $,L,E,I,A;let{handlePrimary:w,handleSecondary:P}=le(x,{onPrimary:s,onSecondary:d}),C=(L=($=x.primaryButton)==null?void 0:$.title)!=null?L:x.primaryButtonTitle,R=(I=(E=x.secondaryButton)==null?void 0:E.title)!=null?I:x.secondaryButtonTitle,k=!!x.$state.blocked;return jsxRuntime.jsx(Uo,l(i({align:e,alignOffset:o,anchor:x.selector,"data-step-id":x.id,defaultOpen:t,modal:p,part:u,side:m,sideOffset:g,spotlight:b},T),{children:jsxRuntime.jsxs(h,{animation:`${ca} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsxRuntime.jsx(h.Media,{aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(A=x.videoUri)!=null?A:x.imageUri,transform:"translate3d(0, 0, 1px)",type:x.videoUri?"video":"image"}),jsxRuntime.jsx(h.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:a,subtitle:x.subtitle,title:x.title}),jsxRuntime.jsxs(h.Footer,{children:[r.getNumberOfAvailableSteps()>1&&jsxRuntime.jsx(Be,{current:r.getCurrentStepOrder()+1,marginRight:"auto",total:r.getNumberOfAvailableSteps()}),jsxRuntime.jsx(h.Secondary,{disabled:k,onClick:P,title:R}),jsxRuntime.jsx(h.Primary,{disabled:k,onClick:w,title:C})]})]})}))}function Tr(e,o,t){let[n,r]=ko.useState(!1),a=ko.useRef();return ko.useEffect(()=>{a.current=typeof o=="string"?document.querySelector(o):o,r(!0);},[]),n?reactDom.createPortal(e,a.current,t):null}function mo(T){var v=T,{align:e="after",alignOffset:o=0,as:t,defaultOpen:n,dismissible:r=!1,flowId:a,modal:p,part:s,sequential:d=!0,side:u="bottom",sideOffset:m=0,spotlight:g,zIndex:b=9999}=v,x=f(v,["align","alignOffset","as","defaultOpen","dismissible","flowId","modal","part","sequential","side","sideOffset","spotlight","zIndex"]);let{onDismiss:B,onPrimary:w,onSecondary:P}=x;return Tr(jsxRuntime.jsx(_,l(i({as:t,flowId:a,part:"tour"},x),{children:({flow:C,handleDismiss:R,parentProps:{containerProps:k},step:$})=>{var E,I,A,he;let L=i({align:e,alignOffset:o,dismissible:r,flow:C,handleDismiss:R,modal:p,onPrimary:w,onSecondary:P,part:s,side:u,sideOffset:m,spotlight:g,step:$,zIndex:(A=(I=(E=$.props)==null?void 0:E.zIndex)!=null?I:k==null?void 0:k.zIndex)!=null?A:b},(he=$.props)!=null?he:{});return d?jsxRuntime.jsx(uo,i({defaultOpen:n!=null?n:!0},L),$.id):Array.from(C.steps.values()).filter(Q=>{let{blocked:Ae,completed:ue,skipped:ee,visible:Fe}=Q.$state;return !Ae&&!ue&&!ee&&Fe}).map(Q=>{var je,K,oe,ne,te;function Ae(me){return M(this,null,function*(){return (yield B==null?void 0:B(C,me))===!1?(me.preventDefault(),!1):(Q.skip(),!0)})}let ue=g&&Q.id===$.id,ee=(oe=(K=(je=Q.props)==null?void 0:je.zIndex)!=null?K:k==null?void 0:k.zIndex)!=null?oe:b,Fe=i({align:e,alignOffset:o,dismissible:r,flow:C,handleDismiss:Ae,onPrimary:w,onSecondary:P,part:s,side:u,sideOffset:m,spotlight:g,zIndex:ee},(ne=Q.props)!=null?ne:{});return jsxRuntime.jsx(uo,i({css:{"&:has([aria-expanded=true])":{zIndex:Number(ee)+2},".fr-overlay":{zIndex:Number(ee)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(te=n||ue)!=null?te:!1,step:Q},Fe),`${Q.id}-${ue}`)})}})),"body")}function fo(){let{frigade:e}=ko.useContext(V),[,o]=ko.useState(!1),t,n=ko.useCallback(p=>{e==null||e.getCollections().then(()=>{p();});let s=()=>{clearTimeout(t),t=setTimeout(()=>{o(d=>!d),p();},0);};return e==null||e.onStateChange(s),()=>{e==null||e.removeStateChangeHandler(s);}},[]),r=()=>{let p;try{p=e==null?void 0:e.getCollectionsSync();}catch(s){}return p};return {collections:ko.useSyncExternalStore(n,r,r)}}function go(e){var s,d,u,m;let{frigade:o}=ko.useContext(V),{collections:t}=fo(),n=t==null?void 0:t.get(e),a=(m=((u=(d=(s=t==null?void 0:t.get(e))==null?void 0:s.flows)==null?void 0:d.filter(g=>g.visible).map(g=>l(i({},g),{flow:o==null?void 0:o.getFlowSync(g.flowId)})))!=null?u:[]).find(({flow:g})=>g.isVisible))==null?void 0:m.flowId,{flow:p}=we(a);return ko.useEffect(()=>{o==null||o.registerCollection(e);},[e]),{collection:n,currentFlow:p}}function Ko(r){var a=r,{collectionId:e,part:o,variables:t={}}=a,n=f(a,["collectionId","part","variables"]);var u,m,g;let p={ANNOUNCEMENT:jo,BANNER:Eo,CARD:h,CHECKLIST:to,EMBEDDED_TIP:h,FORM:He,NPS_SURVEY:_e,SURVEY:_e,TOUR:mo},{currentFlow:s}=go(e),d=(m=p[(u=s==null?void 0:s.rawData)==null?void 0:u.flowType])!=null?m:null;return s==null||d==null?null:((g=s==null?void 0:s.rawData)==null?void 0:g.flowType)===js.FlowType.FORM?jsxRuntime.jsx(y,l(i({part:["collection",o],"data-collection-id":e},n),{children:jsxRuntime.jsx(He,{flowId:s.id,as:H,variables:t},s.id)})):jsxRuntime.jsx(y,l(i({part:["collection",o],"data-collection-id":e},n),{children:jsxRuntime.jsx(d,{flowId:s.id,variables:t},s.id)}))}function kr(){var t,n;let{collections:e}=fo(),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 go(o),o==null?null:jsxRuntime.jsx(Ko,{as:null,collectionId:o})}var V=ko.createContext({apiKey:"",navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});function Xo(){let{frigade:e}=ko.useContext(V);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function Er(){let{frigade:e}=Xo();return ko.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 Or="2.5.16";function $r(p){var s=p,{children:e,css:o={},defaultCollection:t=!0,navigate:n,theme:r}=s,a=f(s,["children","css","defaultCollection","navigate","theme"]);let d=r?Fo(r):{},u=ko.useRef(new Map),m=ko.useRef(),[g,b]=ko.useState(!1),x=ko.useMemo(()=>(b(!1),m.current=void 0,new js.Frigade(a.apiKey,{apiKey:a.apiKey,apiUrl:a.apiUrl,userId:a.userId,groupId:a.groupId,userProperties:a.userProperties,groupProperties:a.groupProperties,generateGuestId:a.generateGuestId,syncOnWindowUpdates:a.syncOnWindowUpdates,__readOnly:a.__readOnly,__flowStateOverrides:a.__flowStateOverrides,__platformVersion:Or,__platformName:"React"})),[a.userId,a.groupId,a.apiKey]);ko.useEffect(()=>{if(a.__flowStateOverrides){let P=x.getConfig();P.__flowStateOverrides=a.__flowStateOverrides,x.reload(P);}},[a.__flowStateOverrides]);function T(){let P=[...u.current.entries()].map(([C,R])=>[C,R.callback]);x.batchRegister(P),b(!0);}function v(P,C){if(m.current&&clearTimeout(m.current),g){u.current.has(P)?x.getFlow(P).then(R=>C(R.isVisible)):(x.getFlow(P).then(R=>R.register(C)),u.current.set(P,{callback:C}));return}u.current.has(P)||u.current.set(P,{callback:C}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>T(),0);}function B(P){u.current.has(P)&&x.getFlow(P).then(C=>{u.current.delete(P),C==null||C.unregister();});}let w=n!=null?n:(P,C="_self")=>{window.open(P,C);};return ko.useEffect(()=>()=>{x.destroy();},[]),jsxRuntime.jsxs(V.Provider,{value:l(i({navigate:w},a),{frigade:x,registerComponent:v,unregisterComponent:B,hasInitialized:g,variables:a.variables||{}}),children:[jsxRuntime.jsx(react.Global,{styles:{":root":i(i(i({},vo),d),o)}}),jsxRuntime.jsxs(react.ThemeProvider,{theme:O,children:[t&&jsxRuntime.jsx(kr,{}),e]}),a.preloadImages!==!1&&jsxRuntime.jsx(Er,{})]})}function we(e,o){let{frigade:t,variables:n}=ko.useContext(V),[,r]=ko.useState(!1),a=ko.useCallback(s=>{t==null||t.getFlow(e).then(()=>{s();});let d=u=>{u.id===e&&setTimeout(()=>{r(m=>!m),s();},0);};return t==null||t.onStateChange(d),()=>{t==null||t.removeStateChangeHandler(d);}},[e,t]),p=ko.useSyncExternalStore(a,()=>t==null?void 0:t.getFlowSync(e),()=>t==null?void 0:t.getFlowSync(e));return p==null||p.applyVariables(i(i({},n),o==null?void 0:o.variables)),{flow:p,isLoading:t!=null&&t.hasFailedToLoad()?!1:!p}}function qo(e,{onComplete:o,onDismiss:t}={}){let n=ko.useRef(null);return ko.useEffect(()=>{if(e==null)return;function r(){return M(this,null,function*(){e.isCompleted&&n.current===!1&&(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:ko.useCallback(r=>M(this,null,function*(){if((yield t==null?void 0:t(e,r))===!1)return r.preventDefault(),!1;e.skip();}),[e])}}var de=new Set;function Zo(e,o=!0){let t=ko.useCallback(()=>{de.has(e==null?void 0:e.id)&&de.delete(e==null?void 0:e.id);},[de,o]),n=ko.useCallback(()=>{o&&(e!=null&&e.isVisible)&&!de.has(e.id)&&de.add(e.id);},[de,o]);ko.useEffect(()=>()=>{t();},[]),ko.useEffect(()=>{n();let a=()=>{t();};return window.addEventListener("popstate",a),window.addEventListener("beforeunload",a),()=>{t(),window.removeEventListener("popstate",a),window.removeEventListener("beforeunload",a);}},[n,t]),e!=null&&e.isVisible?n():t();let r=de.size>0?de.values().next().value:null;return {isCurrentModal:o?r===(e==null?void 0:e.id)||de.size==0:!0}}function _(u){var m=u,{as:e,children:o,flowId:t,onComplete:n,onDismiss:r,onPrimary:a,onSecondary:p,variables:s}=m,d=f(m,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var E,A;let{flow:g}=we(t,{variables:s}),I=i(i({},d),(E=g==null?void 0:g.props)!=null?E:{}),{dismissible:b=!1,forceMount:x=!1}=I,T=f(I,["dismissible","forceMount"]),v=g==null?void 0:g.getCurrentStep(),{handleDismiss:B}=qo(g,{onComplete:n,onDismiss:r}),{handlePrimary:w,handleSecondary:P}=le(v,{onPrimary:a,onSecondary:p}),C=(T==null?void 0:T.modal)||typeof e=="function"&&(e==null?void 0:e.displayName)==="Dialog"||[js.FlowType.ANNOUNCEMENT,js.FlowType.TOUR].includes((A=g==null?void 0:g.rawData)==null?void 0:A.flowType),{isCurrentModal:R}=Zo(g,C),k=x&&((g==null?void 0:g.isCompleted)||(g==null?void 0:g.isSkipped));if(!g||!g.isVisible&&!k||!k&&!R)return null;(k||!g.isCompleted&&!g.isSkipped)&&(v==null||v.start());let $=e===null?ko.Fragment:e!=null?e:y,L=l(i({},T),{"data-flow-id":g.id});return jsxRuntime.jsx($,l(i({},e===null?{}:L),{children:o({flow:g,handleDismiss:B,handlePrimary:w,handleSecondary:P,parentProps:{dismissible:b,flowId:t,variables:s,containerProps:L},step:v})}))}function Lr(t){var n=t,{part:e}=n,o=f(n,["part"]);return jsxRuntime.jsx(_,l(i({as:h,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:r,handlePrimary:a,handleSecondary:p,parentProps:{dismissible:s},step:d})=>{var g,b,x,T;let u=(b=(g=d.primaryButton)==null?void 0:g.title)!=null?b:d.primaryButtonTitle,m=(T=(x=d.secondaryButton)==null?void 0:x.title)!=null?T:d.secondaryButtonTitle;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(h.Header,{dismissible:s,handleDismiss:r,subtitle:d.subtitle,title:d.title}),jsxRuntime.jsx(h.Media,{src:d.imageUri,css:{objectFit:"contain",width:"100%"}}),jsxRuntime.jsxs(S.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsxRuntime.jsx(h.Secondary,{title:m,onClick:p}),jsxRuntime.jsx(h.Primary,{title:u,onClick:a})]})]})}}))}function xo(n){var r=n,{part:e,src:o}=r,t=f(r,["part","src"]);return jsxRuntime.jsx(y,i({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function _a(e){var o,t,n,r,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/${(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/${(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 ho(n){var r=n,{part:e,src:o}=r,t=f(r,["part","src"]);let a=_a(o);return a?jsxRuntime.jsx(y,i({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"neutral.100",borderWidth:"0",part:["video",e],src:a},t)):o!=null&&o.endsWith(".mp4")?jsxRuntime.jsx(y,i({as:"video",controls:!0,part:["video",e],src:o},t)):(console.error(`Could not map videoUri ${o} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function ye(n){var r=n,{src:e,type:o}=r,t=f(r,["src","type"]);return jsxRuntime.jsx(o==="video"?ho:xo,i({src:e},t))}var h=ko__namespace.forwardRef((a,r)=>{var p=a,{children:e,flowId:o,part:t}=p,n=f(p,["children","flowId","part"]);var d;if(o!=null)return jsxRuntime.jsx(Lr,i({flowId:o},n));let s=(d=n.as)!=null?d:S.Column;return jsxRuntime.jsx(s,l(i({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(D.Plain,l(i({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsxRuntime.jsx(ve,{height:"20",fill:"currentColor"})}));h.Footer=n=>{var r=n,{children:e,part:o}=r,t=f(r,["children","part"]);return jsxRuntime.jsx(S.Row,l(i({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",o]},t),{children:e}))};h.Header=p=>{var s=p,{dismissible:e,handleDismiss:o,part:t,subtitle:n,title:r}=s,a=f(s,["dismissible","handleDismiss","part","subtitle","title"]);return jsxRuntime.jsxs(S.Row,l(i({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",t]},a),{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=f(n,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsxRuntime.jsx(ye,i({borderRadius:"md",src:e},o))};h.Primary=n=>{var r=n,{onClick:e,title:o}=r,t=f(r,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Primary,i({title:o,onClick:e},t))};h.Secondary=n=>{var r=n,{onClick:e,title:o}=r,t=f(r,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Secondary,i({title:o,onClick:e},t))};h.Subtitle=n=>{var r=n,{children:e,part:o}=r,t=f(r,["children","part"]);return e==null?null:jsxRuntime.jsx(F.Body2,l(i({display:"block",color:"neutral.400",part:["subtitle",o]},t),{children:e}))};h.Title=n=>{var r=n,{children:e,part:o}=r,t=f(r,["children","part"]);return e==null?null:jsxRuntime.jsx(F.H4,l(i({display:"block",part:["title",o]},t),{children:e}))};var bo={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function _r(e){let o=Object.fromEntries(bo.content.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),t=Object.fromEntries(bo.root.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),n={};for(let r of Object.keys(e))!bo.content.some(a=>a===r)&&!bo.root.some(a=>a===r)&&(n[r]=e[r]);return {contentProps:o,otherProps:n,rootProps:t}}var ja=react.keyframes`
|
|
90
90
|
from {
|
|
91
91
|
opacity: 0;
|
|
92
92
|
}
|