@frigade/react 2.2.8 → 2.2.9
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 +2 -2
package/dist/index.js
CHANGED
|
@@ -54,7 +54,7 @@ var vo=Object.defineProperty,er=Object.defineProperties;var or=Object.getOwnProp
|
|
|
54
54
|
to {
|
|
55
55
|
opacity: 1;
|
|
56
56
|
}
|
|
57
|
-
`;function N(s){var p=s,{anchor:e,children:o,className:t,spotlight:r=!1,style:n}=p,i=m(p,["anchor","children","className","spotlight","style"]);let{node:c,rect:u,ref:f}=Ge(),{node:P,rect:x,ref:h}=Ge(),$i=Et(i,u),{contentProps:F,otherProps:Zt}=$i,To=Zt,{part:y}=To,B=m(To,["part"]),{rootProps:E}=$i,[v,I]=useState(F.align),[L,w]=useState(F.side),[R,k]=useState(0),[$,Ce]=useState(0);if(c!==null){let X=c.getAttribute("data-align"),ae=c.getAttribute("data-side");v!==X&&I(X),L!==ae&&w(ae);}let ie=useRef(null);if(useEffect(()=>{let X=document.querySelector(e);X!=null?(h(X),ie.current=X):console.debug(`[frigade] Tooltip: No anchor found for query: ${e}`);},[e]),useEffect(()=>{function X(Se){if(Se.matches(e))return Se;let ge=Se.querySelectorAll(e);return ge.length>0?ge[0]:null}let ae=new MutationObserver(Se=>{for(let ge of Se)if(ge.type==="childList"){for(let Fe of ge.addedNodes){if(Fe.nodeType!==Node.ELEMENT_NODE)continue;let se=X(Fe);if(se!=null){h(se),ie.current=se,console.debug("[frigade] Tooltip: MutationObserver added anchor: ",se);break}}for(let Fe of ge.removedNodes){if(Fe.nodeType!==Node.ELEMENT_NODE)continue;let se=X(Fe);if(se!=null){h(null),ie.current=null,console.debug("[frigade] Tooltip: MutationObserver removed anchor: ",se);break}}}});return ae.observe(document.querySelector("body"),{childList:!0,subtree:!0}),()=>ae.disconnect()},[]),useEffect(()=>{let{scrollX:X,scrollY:ae}=window;k(x.left+X),Ce(x.top+ae);},[x.left,x.top]),P==null)return null;let He="0";typeof window!="undefined"&&(He=window.getComputedStyle(P).borderRadius);let Me=Dt({props:i,alignAttr:v,sideAttr:L});return jsxs(Q.Root,d(a({defaultOpen:!0},E),{children:[jsx(Q.Anchor,{virtualRef:ie}),jsx(Q.Portal,{children:jsxs(Fragment,{children:[r&&jsx(g,a({animation:`${Ot} 300ms ease-out`,boxShadow:"0 0 0 20000px rgb(0 0 0 / 0.5)",part:"tooltip-spotlight",pointerEvents:"none",position:"absolute",style:{borderRadius:He,height:x.height,left:R,top:$,width:x.width}},i.zIndex!=null?{zIndex:i.zIndex}:{})),jsx(Q.Content,d(a({asChild:!0},F),{ref:f,children:jsxs(b,d(a({animation:`${Ot} 300ms ease-out`,boxShadow:"md",position:"relative",className:t,css:{maxWidth:"360px",pointerEvents:"auto"},part:["tooltip",y],style:n},B),{children:[jsx(Rt,{style:Me}),o]}))}))]})})]}))}N.Close=e=>jsx(Q.Close,{"aria-label":"Close",asChild:!0,children:jsx(D.Plain,d(a({css:{top:"0px",right:"-6px"},part:"close",position:"absolute"},e),{children:jsx(XMarkIcon,{height:"20",fill:"currentColor"})}))});N.Media=t=>{var r=t,{src:e}=r,o=m(r,["src"]);return e==null?null:jsx(me,a({borderRadius:"md md 0 0",borderWidth:"0",css:{aspectRatio:"2",objectFit:"cover"},margin:"-5 -5 0",src:e},o))};N.Primary=r=>{var n=r,{onClick:e,title:o}=n,t=m(n,["onClick","title"]);return o==null?null:jsx(D.Primary,a({title:o,onClick:e},t))};N.Progress=t=>{var r=t,{children:e}=r,o=m(r,["children"]);return e==null?null:jsx(S.Body2,d(a({part:"progress"},o),{children:e}))};N.Secondary=r=>{var n=r,{onClick:e,title:o}=n,t=m(n,["onClick","title"]);return o==null?null:jsx(D.Secondary,a({title:o,onClick:e},t))};N.Subtitle=t=>{var r=t,{children:e}=r,o=m(r,["children"]);return e==null?null:jsx(S.Body2,d(a({part:"subtitle"},o),{children:e}))};N.Title=t=>{var r=t,{children:e}=r,o=m(r,["children"]);return e==null?null:jsx(S.H4,d(a({part:"title"},o),{children:e}))};function It(c){var u=c,{dismissible:e=!0,flow:o,onDismiss:t,onEscapeKeyDown:r,onPrimary:n,onSecondary:i,step:s}=u,p=m(u,["dismissible","flow","onDismiss","onEscapeKeyDown","onPrimary","onSecondary","step"]);var E,v,I,L,w,R;let{handleDismiss:f}=ue(o,{onDismiss:t}),{handlePrimary:P,handleSecondary:x}=te(s,{onPrimary:n,onSecondary:i}),h=(E=s.props)!=null?E:{},F=(I=(v=s.primaryButton)==null?void 0:v.title)!=null?I:s.primaryButtonTitle,y=(w=(L=s.secondaryButton)==null?void 0:L.title)!=null?w:s.secondaryButtonTitle,B=!!s.$state.blocked;return jsxs(N,d(a(a({anchor:s.selector,onOpenAutoFocus:k=>k.preventDefault(),onPointerDownOutside:k=>k.preventDefault(),onInteractOutside:k=>k.preventDefault()},p),h),{onEscapeKeyDown:k=>{typeof r=="function"&&r(k),k.defaultPrevented||f(k);},children:[e&&jsx(N.Close,{onClick:f}),jsx(N.Media,{src:(R=s.videoUri)!=null?R:s.imageUri,type:s.videoUri?"video":"image"}),jsxs(C.Column,{gap:1,part:"tooltip-header",children:[jsx(N.Title,{children:s.title}),jsx(N.Subtitle,{color:"neutral.400",children:s.subtitle})]}),jsxs(C.Row,{alignItems:"center",gap:3,justifyContent:"flex-end",part:"tooltip-footer",children:[o.getNumberOfAvailableSteps()>1&&jsx(N.Progress,{marginRight:"auto",transform:"translateY(1px)",children:`${o.getCurrentStepIndex()+1}/${o.getNumberOfAvailableSteps()}`}),jsx(N.Secondary,{disabled:B,onClick:x,title:y}),jsx(N.Primary,{disabled:B,onClick:P,title:F})]})]}),s.id)}function Ee(e,o=!0){let{currentModal:t,modals:r,setModals:n}=useContext(O),[i,s]=useState(!1);useEffect(()=>{o&&(e!=null&&e.isVisible)&&e&&!r.has(e.id)&&n(c=>new Set(c).add(e.id));},[e==null?void 0:e.id,e==null?void 0:e.isVisible]),useEffect(()=>{let c=t===(e==null?void 0:e.id);o&&(e==null?void 0:e.id)!=null&&c!==i&&s(c);},[e==null?void 0:e.id,t]);function p(){o&&r.has(e==null?void 0:e.id)&&n(c=>{let u=new Set(c);return u.delete(e==null?void 0:e.id),u});}return {isCurrentModal:i||!o,removeModal:p}}function Po(i){var s=i,{flowId:e,onComplete:o,variables:t,part:r}=s,n=m(s,["flowId","onComplete","variables","part"]);let[p,c]=useState(!1),{flow:u}=ce(e,{variables:t}),{hasInitialized:f,registerComponent:P,unregisterComponent:x}=useContext(O);ue(u,{onComplete:o});let{isCurrentModal:h,removeModal:F}=Ee(u);if(useEffect(()=>{!(u!=null&&u.isVisible)&&h&&F();},[u==null?void 0:u.isVisible,h]),useEffect(()=>()=>{x(e);},[]),u==null||u.isVisible===!1||!h||(P(e,()=>{p||c(!0);}),!f||!p))return null;let y=u.getCurrentStep();return y==null||y.start(),jsx(It,a({"data-flow-id":u.id,flow:u,part:["tour",r],step:y},n))}function Wt(e){let[o,t]=useState(),{frigade:r}=useContext(O);return useEffect(()=>{H(this,null,function*(){let n=yield r.getCollection(e);if(!n||r.hasFailedToLoad()){t(void 0);return}t(n);});},[e]),{collection:o}}function Co(r){var n=r,{collectionId:e,part:o}=n,t=m(n,["collectionId","part"]);var f,P;let i={ANNOUNCEMENT:So,BANNER:no,CARD:b,CHECKLIST:_e,EMBEDDED_TIP:b,FORM:De,NPS_SURVEY:Ue,TOUR:Po},[s,p]=useState(),{collection:c}=Wt(e);useEffect(()=>{var h;if(c==null)return;let x=(h=c.flows.find(({flow:F})=>F.isVisible))==null?void 0:h.flow;x!=null&&p(x);},[c]);let u=(P=i[(f=s==null?void 0:s.rawData)==null?void 0:f.flowType])!=null?P:()=>null;return s==null||u==null?null:jsx(g,d(a({part:["collection",o],"data-collection-id":e},t),{children:jsx(u,{flowId:s.id})}))}function Oe(){let{frigade:e}=useContext(O);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function At(){let[e,o]=useState(),{frigade:t}=Oe();return useEffect(()=>{t.getCollections().then(r=>{r==null||r.forEach((n,i)=>{n.collectionType==="DEFAULT"&&o(i);});});},[]),e==null?null:jsx(Co,{as:null,collectionId:e})}var O=createContext({apiKey:"",modals:new Set,setModals:()=>{},currentModal:null,navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{}});function $t(){let{frigade:e}=Oe();return useEffect(()=>{H(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(r=>{if(r.imageUri){let n=new Image;n.src=r.imageUri;}});});});},[]),null}function Kt(s){var p=s,{children:e,css:o={},defaultCollection:t=!0,navigate:r,theme:n}=p,i=m(p,["children","css","defaultCollection","navigate","theme"]);let c=n?Qe(n):{},[u,f]=useState(new Set),P=useRef(new Map),x=useRef(),[h,F]=useState(!1),y=useMemo(()=>(F(!1),x.current=void 0,f(new Set),new 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})),[i.userId,i.groupId,i.apiKey]);useEffect(()=>{if(i.__flowStateOverrides){let w=y.getConfig();w.__flowStateOverrides=i.__flowStateOverrides,y.reload(w);}},[i.__flowStateOverrides]);function B(){let w=[...P.current.entries()].map(([R,k])=>[R,k.callback]);y.batchRegister(w),F(!0);}function E(w,R){if(x.current&&clearTimeout(x.current),h){P.current.has(w)?y.getFlow(w).then(k=>R(k.isVisible)):(y.getFlow(w).then(k=>k.register(R)),P.current.set(w,{callback:R}));return}P.current.has(w)||P.current.set(w,{callback:R}),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>B(),0);}function v(w){P.current.has(w)&&y.getFlow(w).then(R=>{P.current.delete(w),R==null||R.unregister();});}let I=r!=null?r:(w,R="_self")=>{window.open(w,R);};useEffect(()=>()=>{y.destroy();},[]);let L=u.size>0?u.values().next().value:null;return jsxs(O.Provider,{value:d(a({modals:u,setModals:f,currentModal:L,navigate:I},i),{frigade:y,registerComponent:E,unregisterComponent:v,hasInitialized:h}),children:[jsx(Global,{styles:{":root":a(a(a({},Ze),c),o)}}),jsxs(ThemeProvider,{theme:T,children:[t&&jsx(At,{}),e]}),i.preloadImages!==!1&&jsx($t,{})]})}function ce(e,o){let[t,r]=useState(),[,n]=useState(""),{frigade:i}=useContext(O),s=useCallback(p=>{p.id===e&&(o!=null&&o.variables&&p.applyVariables(o.variables),setTimeout(()=>{r(p),n(Math.random().toString());},0));},[o==null?void 0:o.variables,i]);return useEffect(()=>{if(i!=null&&i.isReady())return H(this,null,function*(){let p=yield i.getFlow(e);if(!p||i.hasFailedToLoad()){r(void 0);return}o!=null&&o.variables&&p.applyVariables(o.variables),r(p);}),i.onStateChange(s),()=>{i.removeStateChangeHandler(s);}},[s,i]),useEffect(()=>{!(o!=null&&o.variables)||!t||s(t);},[o==null?void 0:o.variables]),{flow:t}}function K(P){var x=P,{as:e,children:o,dismissible:t=!1,flowId:r,onComplete:n,onDismiss:i,onPrimary:s,onSecondary:p,variables:c,forceMount:u}=x,f=m(x,["as","children","dismissible","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables","forceMount"]);let[h,F]=useState(!1),{flow:y}=ce(r,{variables:c}),{hasInitialized:B,registerComponent:E,unregisterComponent:v}=useContext(O),I=y==null?void 0:y.getCurrentStep(),{handleDismiss:L}=ue(y,{onComplete:n,onDismiss:i}),{handlePrimary:w,handleSecondary:R}=te(I,{onPrimary:s,onSecondary:p}),k=e&&typeof e=="function"&&e.displayName==="Dialog",{isCurrentModal:$,removeModal:Ce}=Ee(y,k);useEffect(()=>{!(y!=null&&y.isVisible)&&$&&Ce();},[y==null?void 0:y.isVisible,$]),useEffect(()=>()=>{v(r);},[]);let ie=u&&((y==null?void 0:y.isCompleted)||(y==null?void 0:y.isSkipped));if(!y||!ie&&!$||(E(r,()=>{h||F(!0);}),!y.isVisible&&!ie)||!B||!h)return null;(ie||!y.isCompleted&&!y.isSkipped)&&I.start();let He=e===null?Fragment$1:e!=null?e:g,Me=d(a({},f),{"data-flow-id":y.id});return jsx(He,d(a({},e===null?{}:Me),{children:o({flow:y,handleDismiss:L,handlePrimary:w,handleSecondary:R,parentProps:{dismissible:t,flowId:r,variables:c,containerProps:Me},step:I})}))}function Xt(t){var r=t,{part:e}=r,o=m(r,["part"]);return jsx(K,d(a({as:b,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:n,handlePrimary:i,handleSecondary:s,parentProps:{dismissible:p},step:c})=>{var P,x,h,F;let u=(x=(P=c.primaryButton)==null?void 0:P.title)!=null?x:c.primaryButtonTitle,f=(F=(h=c.secondaryButton)==null?void 0:h.title)!=null?F:c.secondaryButtonTitle;return jsxs(Fragment,{children:[jsx(b.Header,{dismissible:p,handleDismiss:n,subtitle:c.subtitle,title:c.title}),jsx(b.Media,{src:c.imageUri,css:{objectFit:"contain",width:"100%"}}),jsxs(C.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsx(b.Secondary,{title:f,onClick:s}),jsx(b.Primary,{title:u,onClick:i})]})]})}}))}var b=ro.forwardRef((n,r)=>{var i=n,{children:e,flowId:o}=i,t=m(i,["children","flowId"]);var p;if(o!=null)return jsx(Xt,a({flowId:o},t));let s=(p=t.as)!=null?p:C.Column;return jsx(s,d(a({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5},t),{ref:r,children:e}))});b.Dismiss=e=>jsx(D.Plain,d(a({part:"dismiss",padding:0},e),{children:jsx(XMarkIcon,{height:"20",fill:"currentColor"})}));b.Header=i=>{var s=i,{dismissible:e,handleDismiss:o,subtitle:t,title:r}=s,n=m(s,["dismissible","handleDismiss","subtitle","title"]);return jsxs(C.Row,d(a({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:"card-header"},n),{children:[jsx(b.Title,{maxWidth:"calc(100% - 32px)",children:r}),e&&jsx(b.Dismiss,{onClick:o,marginLeft:"auto"}),jsx(b.Subtitle,{color:"neutral.400",flexBasis:"100%",children:t})]}))};b.Media=t=>{var r=t,{src:e}=r,o=m(r,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsx(me,a({borderRadius:"md",src:e},o))};b.Primary=r=>{var n=r,{onClick:e,title:o}=n,t=m(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(D.Primary,a({title:o,onClick:e},t))};b.Secondary=r=>{var n=r,{onClick:e,title:o}=n,t=m(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(D.Secondary,a({title:o,onClick:e},t))};b.Subtitle=t=>{var r=t,{children:e}=r,o=m(r,["children"]);return e==null?null:jsx(S.Body2,d(a({display:"block",color:"neutral.400",part:"subtitle"},o),{children:e}))};b.Title=t=>{var r=t,{children:e}=r,o=m(r,["children"]);return e==null?null:jsx(S.H4,d(a({display:"block",part:"title"},o),{children:e}))};var qe={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function Yt(e){let o=Object.fromEntries(qe.content.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),t=Object.fromEntries(qe.root.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),r={};for(let n of Object.keys(e))!qe.content.some(i=>i===n)&&!qe.root.some(i=>i===n)&&(r[n]=e[n]);return {contentProps:o,otherProps:r,rootProps:t}}var Oi=keyframes`
|
|
57
|
+
`;function N(s){var p=s,{anchor:e,children:o,className:t,spotlight:r=!1,style:n}=p,i=m(p,["anchor","children","className","spotlight","style"]);let{node:c,rect:u,ref:f}=Ge(),{node:P,rect:x,ref:h}=Ge(),$i=Et(i,u),{contentProps:F,otherProps:Zt}=$i,To=Zt,{part:y}=To,B=m(To,["part"]),{rootProps:E}=$i,[v,I]=useState(F.align),[L,w]=useState(F.side),[R,k]=useState(0),[$,Ce]=useState(0);if(c!==null){let X=c.getAttribute("data-align"),ae=c.getAttribute("data-side");v!==X&&I(X),L!==ae&&w(ae);}let ie=useRef(null);if(useEffect(()=>{let X=document.querySelector(e);X!=null?(h(X),ie.current=X):console.debug(`[frigade] Tooltip: No anchor found for query: ${e}`);},[e]),useEffect(()=>{function X(Se){if(Se.matches(e))return Se;let ge=Se.querySelectorAll(e);return ge.length>0?ge[0]:null}let ae=new MutationObserver(Se=>{for(let ge of Se)if(ge.type==="childList"){for(let Fe of ge.addedNodes){if(Fe.nodeType!==Node.ELEMENT_NODE)continue;let se=X(Fe);if(se!=null){h(se),ie.current=se,console.debug("[frigade] Tooltip: MutationObserver added anchor: ",se);break}}for(let Fe of ge.removedNodes){if(Fe.nodeType!==Node.ELEMENT_NODE)continue;let se=X(Fe);if(se!=null){h(null),ie.current=null,console.debug("[frigade] Tooltip: MutationObserver removed anchor: ",se);break}}}});return ae.observe(document.querySelector("body"),{childList:!0,subtree:!0}),()=>ae.disconnect()},[]),useEffect(()=>{let{scrollX:X,scrollY:ae}=window;k(x.left+X),Ce(x.top+ae);},[x.left,x.top]),P==null)return null;let He="0";typeof window!="undefined"&&(He=window.getComputedStyle(P).borderRadius);let Me=Dt({props:i,alignAttr:v,sideAttr:L});return jsxs(Q.Root,d(a({defaultOpen:!0},E),{children:[jsx(Q.Anchor,{virtualRef:ie}),jsx(Q.Portal,{children:jsxs(Fragment,{children:[r&&jsx(g,a({animation:`${Ot} 300ms ease-out`,boxShadow:"0 0 0 20000px rgb(0 0 0 / 0.5)",part:"tooltip-spotlight",pointerEvents:"none",position:"absolute",style:{borderRadius:He,height:x.height,left:R,top:$,width:x.width}},i.zIndex!=null?{zIndex:i.zIndex}:{})),jsx(Q.Content,d(a({asChild:!0},F),{ref:f,children:jsxs(b,d(a({animation:`${Ot} 300ms ease-out`,boxShadow:"md",position:"relative",className:t,maxWidth:"min(360px, calc(100vw - 25px))",part:["tooltip",y],pointerEvents:"auto",style:n},B),{children:[jsx(Rt,{style:Me}),o]}))}))]})})]}))}N.Close=e=>jsx(Q.Close,{"aria-label":"Close",asChild:!0,children:jsx(D.Plain,d(a({css:{top:"0px",right:"-6px"},part:"close",position:"absolute"},e),{children:jsx(XMarkIcon,{height:"20",fill:"currentColor"})}))});N.Media=t=>{var r=t,{src:e}=r,o=m(r,["src"]);return e==null?null:jsx(me,a({borderRadius:"md md 0 0",borderWidth:"0",css:{aspectRatio:"2",objectFit:"cover"},margin:"-5 -5 0",src:e},o))};N.Primary=r=>{var n=r,{onClick:e,title:o}=n,t=m(n,["onClick","title"]);return o==null?null:jsx(D.Primary,a({title:o,onClick:e},t))};N.Progress=t=>{var r=t,{children:e}=r,o=m(r,["children"]);return e==null?null:jsx(S.Body2,d(a({part:"progress"},o),{children:e}))};N.Secondary=r=>{var n=r,{onClick:e,title:o}=n,t=m(n,["onClick","title"]);return o==null?null:jsx(D.Secondary,a({title:o,onClick:e},t))};N.Subtitle=t=>{var r=t,{children:e}=r,o=m(r,["children"]);return e==null?null:jsx(S.Body2,d(a({part:"subtitle"},o),{children:e}))};N.Title=t=>{var r=t,{children:e}=r,o=m(r,["children"]);return e==null?null:jsx(S.H4,d(a({part:"title"},o),{children:e}))};function It(c){var u=c,{dismissible:e=!0,flow:o,onDismiss:t,onEscapeKeyDown:r,onPrimary:n,onSecondary:i,step:s}=u,p=m(u,["dismissible","flow","onDismiss","onEscapeKeyDown","onPrimary","onSecondary","step"]);var E,v,I,L,w,R;let{handleDismiss:f}=ue(o,{onDismiss:t}),{handlePrimary:P,handleSecondary:x}=te(s,{onPrimary:n,onSecondary:i}),h=(E=s.props)!=null?E:{},F=(I=(v=s.primaryButton)==null?void 0:v.title)!=null?I:s.primaryButtonTitle,y=(w=(L=s.secondaryButton)==null?void 0:L.title)!=null?w:s.secondaryButtonTitle,B=!!s.$state.blocked;return jsxs(N,d(a(a({anchor:s.selector,collisionPadding:12,onOpenAutoFocus:k=>k.preventDefault(),onPointerDownOutside:k=>k.preventDefault(),onInteractOutside:k=>k.preventDefault()},p),h),{onEscapeKeyDown:k=>{typeof r=="function"&&r(k),k.defaultPrevented||f(k);},children:[e&&jsx(N.Close,{onClick:f}),jsx(N.Media,{src:(R=s.videoUri)!=null?R:s.imageUri,type:s.videoUri?"video":"image"}),jsxs(C.Column,{gap:1,part:"tooltip-header",children:[jsx(N.Title,{children:s.title}),jsx(N.Subtitle,{color:"neutral.400",children:s.subtitle})]}),jsxs(C.Row,{alignItems:"center",gap:3,justifyContent:"flex-end",part:"tooltip-footer",children:[o.getNumberOfAvailableSteps()>1&&jsx(N.Progress,{marginRight:"auto",transform:"translateY(1px)",children:`${o.getCurrentStepIndex()+1}/${o.getNumberOfAvailableSteps()}`}),jsx(N.Secondary,{disabled:B,onClick:x,title:y}),jsx(N.Primary,{disabled:B,onClick:P,title:F})]})]}),s.id)}function Ee(e,o=!0){let{currentModal:t,modals:r,setModals:n}=useContext(O),[i,s]=useState(!1);useEffect(()=>{o&&(e!=null&&e.isVisible)&&e&&!r.has(e.id)&&n(c=>new Set(c).add(e.id));},[e==null?void 0:e.id,e==null?void 0:e.isVisible]),useEffect(()=>{let c=t===(e==null?void 0:e.id);o&&(e==null?void 0:e.id)!=null&&c!==i&&s(c);},[e==null?void 0:e.id,t]);function p(){o&&r.has(e==null?void 0:e.id)&&n(c=>{let u=new Set(c);return u.delete(e==null?void 0:e.id),u});}return {isCurrentModal:i||!o,removeModal:p}}function Po(i){var s=i,{flowId:e,onComplete:o,variables:t,part:r}=s,n=m(s,["flowId","onComplete","variables","part"]);let[p,c]=useState(!1),{flow:u}=ce(e,{variables:t}),{hasInitialized:f,registerComponent:P,unregisterComponent:x}=useContext(O);ue(u,{onComplete:o});let{isCurrentModal:h,removeModal:F}=Ee(u);if(useEffect(()=>{!(u!=null&&u.isVisible)&&h&&F();},[u==null?void 0:u.isVisible,h]),useEffect(()=>()=>{x(e);},[]),u==null||u.isVisible===!1||!h||(P(e,()=>{p||c(!0);}),!f||!p))return null;let y=u.getCurrentStep();return y==null||y.start(),jsx(It,a({"data-flow-id":u.id,flow:u,part:["tour",r],step:y},n))}function Wt(e){let[o,t]=useState(),{frigade:r}=useContext(O);return useEffect(()=>{H(this,null,function*(){let n=yield r.getCollection(e);if(!n||r.hasFailedToLoad()){t(void 0);return}t(n);});},[e]),{collection:o}}function Co(r){var n=r,{collectionId:e,part:o}=n,t=m(n,["collectionId","part"]);var f,P;let i={ANNOUNCEMENT:So,BANNER:no,CARD:b,CHECKLIST:_e,EMBEDDED_TIP:b,FORM:De,NPS_SURVEY:Ue,TOUR:Po},[s,p]=useState(),{collection:c}=Wt(e);useEffect(()=>{var h;if(c==null)return;let x=(h=c.flows.find(({flow:F})=>F.isVisible))==null?void 0:h.flow;x!=null&&p(x);},[c]);let u=(P=i[(f=s==null?void 0:s.rawData)==null?void 0:f.flowType])!=null?P:()=>null;return s==null||u==null?null:jsx(g,d(a({part:["collection",o],"data-collection-id":e},t),{children:jsx(u,{flowId:s.id})}))}function Oe(){let{frigade:e}=useContext(O);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function At(){let[e,o]=useState(),{frigade:t}=Oe();return useEffect(()=>{t.getCollections().then(r=>{r==null||r.forEach((n,i)=>{n.collectionType==="DEFAULT"&&o(i);});});},[]),e==null?null:jsx(Co,{as:null,collectionId:e})}var O=createContext({apiKey:"",modals:new Set,setModals:()=>{},currentModal:null,navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{}});function $t(){let{frigade:e}=Oe();return useEffect(()=>{H(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(r=>{if(r.imageUri){let n=new Image;n.src=r.imageUri;}});});});},[]),null}function Kt(s){var p=s,{children:e,css:o={},defaultCollection:t=!0,navigate:r,theme:n}=p,i=m(p,["children","css","defaultCollection","navigate","theme"]);let c=n?Qe(n):{},[u,f]=useState(new Set),P=useRef(new Map),x=useRef(),[h,F]=useState(!1),y=useMemo(()=>(F(!1),x.current=void 0,f(new Set),new 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})),[i.userId,i.groupId,i.apiKey]);useEffect(()=>{if(i.__flowStateOverrides){let w=y.getConfig();w.__flowStateOverrides=i.__flowStateOverrides,y.reload(w);}},[i.__flowStateOverrides]);function B(){let w=[...P.current.entries()].map(([R,k])=>[R,k.callback]);y.batchRegister(w),F(!0);}function E(w,R){if(x.current&&clearTimeout(x.current),h){P.current.has(w)?y.getFlow(w).then(k=>R(k.isVisible)):(y.getFlow(w).then(k=>k.register(R)),P.current.set(w,{callback:R}));return}P.current.has(w)||P.current.set(w,{callback:R}),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>B(),0);}function v(w){P.current.has(w)&&y.getFlow(w).then(R=>{P.current.delete(w),R==null||R.unregister();});}let I=r!=null?r:(w,R="_self")=>{window.open(w,R);};useEffect(()=>()=>{y.destroy();},[]);let L=u.size>0?u.values().next().value:null;return jsxs(O.Provider,{value:d(a({modals:u,setModals:f,currentModal:L,navigate:I},i),{frigade:y,registerComponent:E,unregisterComponent:v,hasInitialized:h}),children:[jsx(Global,{styles:{":root":a(a(a({},Ze),c),o)}}),jsxs(ThemeProvider,{theme:T,children:[t&&jsx(At,{}),e]}),i.preloadImages!==!1&&jsx($t,{})]})}function ce(e,o){let[t,r]=useState(),[,n]=useState(""),{frigade:i}=useContext(O),s=useCallback(p=>{p.id===e&&(o!=null&&o.variables&&p.applyVariables(o.variables),setTimeout(()=>{r(p),n(Math.random().toString());},0));},[o==null?void 0:o.variables,i]);return useEffect(()=>{if(i!=null&&i.isReady())return H(this,null,function*(){let p=yield i.getFlow(e);if(!p||i.hasFailedToLoad()){r(void 0);return}o!=null&&o.variables&&p.applyVariables(o.variables),r(p);}),i.onStateChange(s),()=>{i.removeStateChangeHandler(s);}},[s,i]),useEffect(()=>{!(o!=null&&o.variables)||!t||s(t);},[o==null?void 0:o.variables]),{flow:t}}function K(P){var x=P,{as:e,children:o,dismissible:t=!1,flowId:r,onComplete:n,onDismiss:i,onPrimary:s,onSecondary:p,variables:c,forceMount:u}=x,f=m(x,["as","children","dismissible","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables","forceMount"]);let[h,F]=useState(!1),{flow:y}=ce(r,{variables:c}),{hasInitialized:B,registerComponent:E,unregisterComponent:v}=useContext(O),I=y==null?void 0:y.getCurrentStep(),{handleDismiss:L}=ue(y,{onComplete:n,onDismiss:i}),{handlePrimary:w,handleSecondary:R}=te(I,{onPrimary:s,onSecondary:p}),k=e&&typeof e=="function"&&e.displayName==="Dialog",{isCurrentModal:$,removeModal:Ce}=Ee(y,k);useEffect(()=>{!(y!=null&&y.isVisible)&&$&&Ce();},[y==null?void 0:y.isVisible,$]),useEffect(()=>()=>{v(r);},[]);let ie=u&&((y==null?void 0:y.isCompleted)||(y==null?void 0:y.isSkipped));if(!y||!ie&&!$||(E(r,()=>{h||F(!0);}),!y.isVisible&&!ie)||!B||!h)return null;(ie||!y.isCompleted&&!y.isSkipped)&&I.start();let He=e===null?Fragment$1:e!=null?e:g,Me=d(a({},f),{"data-flow-id":y.id});return jsx(He,d(a({},e===null?{}:Me),{children:o({flow:y,handleDismiss:L,handlePrimary:w,handleSecondary:R,parentProps:{dismissible:t,flowId:r,variables:c,containerProps:Me},step:I})}))}function Xt(t){var r=t,{part:e}=r,o=m(r,["part"]);return jsx(K,d(a({as:b,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:n,handlePrimary:i,handleSecondary:s,parentProps:{dismissible:p},step:c})=>{var P,x,h,F;let u=(x=(P=c.primaryButton)==null?void 0:P.title)!=null?x:c.primaryButtonTitle,f=(F=(h=c.secondaryButton)==null?void 0:h.title)!=null?F:c.secondaryButtonTitle;return jsxs(Fragment,{children:[jsx(b.Header,{dismissible:p,handleDismiss:n,subtitle:c.subtitle,title:c.title}),jsx(b.Media,{src:c.imageUri,css:{objectFit:"contain",width:"100%"}}),jsxs(C.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsx(b.Secondary,{title:f,onClick:s}),jsx(b.Primary,{title:u,onClick:i})]})]})}}))}var b=ro.forwardRef((n,r)=>{var i=n,{children:e,flowId:o}=i,t=m(i,["children","flowId"]);var p;if(o!=null)return jsx(Xt,a({flowId:o},t));let s=(p=t.as)!=null?p:C.Column;return jsx(s,d(a({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5},t),{ref:r,children:e}))});b.Dismiss=e=>jsx(D.Plain,d(a({part:"dismiss",padding:0},e),{children:jsx(XMarkIcon,{height:"20",fill:"currentColor"})}));b.Header=i=>{var s=i,{dismissible:e,handleDismiss:o,subtitle:t,title:r}=s,n=m(s,["dismissible","handleDismiss","subtitle","title"]);return jsxs(C.Row,d(a({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:"card-header"},n),{children:[jsx(b.Title,{maxWidth:"calc(100% - 32px)",children:r}),e&&jsx(b.Dismiss,{onClick:o,marginLeft:"auto"}),jsx(b.Subtitle,{color:"neutral.400",flexBasis:"100%",children:t})]}))};b.Media=t=>{var r=t,{src:e}=r,o=m(r,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsx(me,a({borderRadius:"md",src:e},o))};b.Primary=r=>{var n=r,{onClick:e,title:o}=n,t=m(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(D.Primary,a({title:o,onClick:e},t))};b.Secondary=r=>{var n=r,{onClick:e,title:o}=n,t=m(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(D.Secondary,a({title:o,onClick:e},t))};b.Subtitle=t=>{var r=t,{children:e}=r,o=m(r,["children"]);return e==null?null:jsx(S.Body2,d(a({display:"block",color:"neutral.400",part:"subtitle"},o),{children:e}))};b.Title=t=>{var r=t,{children:e}=r,o=m(r,["children"]);return e==null?null:jsx(S.H4,d(a({display:"block",part:"title"},o),{children:e}))};var qe={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function Yt(e){let o=Object.fromEntries(qe.content.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),t=Object.fromEntries(qe.root.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),r={};for(let n of Object.keys(e))!qe.content.some(i=>i===n)&&!qe.root.some(i=>i===n)&&(r[n]=e[n]);return {contentProps:o,otherProps:r,rootProps:t}}var Oi=keyframes`
|
|
58
58
|
from {
|
|
59
59
|
opacity: 0;
|
|
60
60
|
}
|