@frigade/react 1.32.50 → 1.32.51
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/lib/index.js +17 -16
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +11 -10
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import gt,{createContext as Da,useEffect as Ro,useState as Ne}from"react";import{ThemeProvider as $a}from"styled-components";import ft,{useContext as La,useEffect as Fo,useState as Zo}from"react";import{useCallback as pt,useContext as nl,useEffect as sl}from"react";import Do,{useMemo as Ks}from"react";var gr="1.32.50 ";var Te="https://api.frigade.com/v1/public/",Ae="NOT_STARTED_STEP",Y="COMPLETED_FLOW",no="ABORTED_FLOW",at="STARTED_FLOW",Le="NOT_STARTED_FLOW",Oe="COMPLETED_STEP",so="STARTED_STEP";function Me(){let{publicApiKey:e,userId:t}=Do.useContext(q);return{config:Ks(()=>({headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-Frigade-SDK-Version":gr,"X-Frigade-SDK-Platform":"React"}}),[e,t])}}var Ys="frigade-last-call-at-",Xs="frigade-last-call-data-";function Tt(){let{shouldGracefullyDegrade:e}=Do.useContext(q);return async(t,o)=>{if(e)return console.log(`Skipping ${t} call to Frigade due to error`),zt();let i=Ys+t,n=Xs+t;if(window&&window.localStorage&&o&&o.body&&o.method==="POST"){let s=window.localStorage.getItem(i),p=window.localStorage.getItem(n);if(s&&p&&p==o.body){let d=new Date(s);if(new Date().getTime()-d.getTime()<1e3)return zt()}window.localStorage.setItem(i,new Date().toISOString()),window.localStorage.setItem(n,o.body)}let r;try{r=await fetch(t,o)}catch(s){return zt(s)}return r?r.ok?r:zt(r.statusText):zt()}}function zt(e){return e&&console.log("Call to Frigade failed",e),{json:()=>({})}}function Ft(){let{publicApiKey:e,shouldGracefullyDegrade:t}=Do.useContext(q);function o(){if(t){console.error("Frigade hooks cannot be used when Frigade SDK has failed to initialize");return}e||console.error("Frigade hooks cannot be used outside the scope of FrigadeProvider")}return{verifySDKInitiated:o}}import{useContext as ol,useState as hr}from"react";import{useContext as Qs,useEffect as Zs,useState as Rs}from"react";import el from"swr";import{useContext as Js}from"react";function Pe(){let{openFlowStates:e,setOpenFlowStates:t,hasActiveFullPageFlow:o,setCompletedFlowsToKeepOpenDuringSession:i,completedFlowsToKeepOpenDuringSession:n}=Js(q);function r(c,u=!1){return e[c]??u}function s(c,u){t(w=>({...w,[c]:u}))}function p(c){t(u=>{let{[c]:w,...T}=u;return{...T}})}function d(c){n.includes(c)||i(u=>[...u,c])}function a(c){return n.includes(c)}function f(){return Object.values(e).some(c=>c)||o}return{getOpenFlowState:r,setOpenFlowState:s,resetOpenFlowState:p,hasOpenModals:f,setKeepCompletedFlowOpenDuringSession:d,shouldKeepCompletedFlowOpenDuringSession:a}}var tl="unknown";function Ie(){let{config:e}=Me(),{publicApiKey:t,userId:o,flows:i,setShouldGracefullyDegrade:n}=Qs(q),{resetOpenFlowState:r}=Pe(),[s,p]=Rs(!1),d={data:i.map(y=>({flowId:y.id,flowState:Y,lastStepId:null,userId:o,foreignUserId:o,stepStates:{},shouldTrigger:!1}))},a=y=>fetch(y,e).then(h=>{if(h.ok)return h.json();throw new Error("Failed to fetch user flow states")}).catch(h=>(console.log(`Error fetching ${y}: ${h}. Will gracefully degrade and hide Frigade`),n(!0),d)),{data:f,isLoading:c,mutate:u,error:w}=el(t&&i&&o?`${Te}userFlowStates?foreignUserId=${encodeURIComponent(o)}`:null,a,{revalidateIfStale:!0,keepPreviousData:!0,revalidateOnMount:!0,errorRetryInterval:1e4,errorRetryCount:3,onError:()=>d,onLoadingSlow:()=>d}),T=f==null?void 0:f.data;Zs(()=>{!s&&!c&&T&&p(!0)},[T,s,c]);async function S(y){if(T){let h=T.find(m=>m.flowId===y);h&&h.flowState!==Y&&(h.flowState=Y),await u(Promise.resolve({...f,data:T}),{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function C(y,h,m){if(T){let x=T.find(F=>F.flowId===y);x&&(x.stepStates[h]=m,x.flowState=at),await u(Promise.resolve({...f,data:T}),{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function P(y,h,m){if(T){let x=T.find(F=>F.flowId===y);x&&(x.lastStepId=h,x.stepStates[h]=m,x.flowState=at),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function v(y){if(T){let h=T.find(m=>m.flowId===y);h&&h.flowState!==Le&&(h.flowState=Le,h.lastStepId=tl,Object.keys(h.stepStates).forEach(m=>{h.stepStates[m].actionType=Ae,h.stepStates[m].createdAt=new Date().toISOString()}),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1}),r(y))}}async function B(y,h){if(T){let m=T.find(x=>x.flowId===y);m&&m.stepStates[h]!==Ae&&(m.stepStates[h]=Ae),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}return{userFlowStatesData:T,isLoadingUserFlowStateData:!s,mutateUserFlowState:u,optimisticallyMarkFlowCompleted:S,optimisticallyMarkFlowNotStarted:v,optimisticallyMarkStepCompleted:C,optimisticallyMarkStepNotStarted:B,optimisticallyMarkStepStarted:P,error:w}}function Wt(){let{config:e}=Me(),{userFlowStatesData:t,mutateUserFlowState:o}=Ie(),{failedFlowResponses:i,setFailedFlowResponses:n,flowResponses:r,setFlowResponses:s}=ol(q),[p,d]=hr(new Set),[a,f]=hr(new Set),c=Tt();function u(S){let C=JSON.stringify(S);if(p.has(C))return null;p.add(C),d(p),a.add(S),f(a);let P=r==null?void 0:r.find(v=>v.flowSlug===S.flowSlug&&v.stepId===S.stepId&&v.actionType===S.actionType&&v.createdAt===S.createdAt);return c(`${Te}flowResponses`,{...e,method:"POST",body:C}).then(v=>{v.status!==200&&v.status!==201?(console.log("Failed to send flow response for step "+S.stepId+". Will retry again later."),n([...i,S])):P||s(B=>[...B??[],S])})}async function w(S){S.foreignUserId&&(S.actionType===at||S.actionType===Le?await u(S):S.actionType===Y?await u(S):S.actionType===so?await u(S):S.actionType===Oe?await u(S):S.actionType===no?await u(S):S.actionType===Ae&&await u(S))}function T(){let S=[];return t==null||t.forEach(C=>{if(C&&C.stepStates&&Object.keys(C.stepStates).length!==0)for(let P in C.stepStates){let v=C.stepStates[P];S.push({foreignUserId:C.foreignUserId,flowSlug:C.flowId,stepId:v.stepId,actionType:v.actionType,data:{},createdAt:new Date(v.createdAt),blocked:v.blocked,hidden:v.hidden})}}),[...S,...r]}return{addResponse:w,setFlowResponses:s,getFlowResponses:T}}import ll from"swr";var rl=/user.flow\(([^\)]+)\) == '?COMPLETED_FLOW'?/gm,xr=e=>{let t=rl.exec(e);if(t===null)return null;let o=null;return t.forEach((i,n)=>{let r=il(i,"'","");r.startsWith("flow_")&&(o=r)}),o},il=function(e,t,o){return e.replace(new RegExp(t,"g"),o)};function X(){let{config:e}=Me(),{flows:t,setFlows:o,userId:i,publicApiKey:n,customVariables:r,setCustomVariables:s,hasActiveFullPageFlow:p,setHasActiveFullPageFlow:d,setFlowResponses:a,setShouldGracefullyDegrade:f}=nl(q),c={data:[]},{verifySDKInitiated:u}=Ft(),{addResponse:w,getFlowResponses:T}=Wt(),S=g=>fetch(g,e).then(b=>b.ok?b.json():(console.log(`Error fetching ${g} (${b.status}): ${b.statusText}. .Will gracefully degrade and hide Frigade`),f(!0),c)).catch(b=>(console.log(`Error fetching ${g}: ${b}. Will gracefully degrade and hide Frigade`),f(!0),c)),{userFlowStatesData:C,isLoadingUserFlowStateData:P,optimisticallyMarkFlowCompleted:v,optimisticallyMarkFlowNotStarted:B,optimisticallyMarkStepCompleted:y,optimisticallyMarkStepNotStarted:h,optimisticallyMarkStepStarted:m}=Ie(),{data:x,error:F,isLoading:O}=ll(n?`${Te}flows`:null,S,{keepPreviousData:!0});sl(()=>{if(F){console.error(F);return}x&&x.data&&(x.data=o(x.data))},[x,F]);function _(g){if(O)return null;let b=t.find(E=>E.slug===g);return!b&&t.length>0&&!P&&!O?(console.log(`Flow with slug ${g} not found`),null):(b==null?void 0:b.active)===!1?null:b}function z(g){var V;if(!_(g))return[];let b=_(g).data;return b?(b=A(b),(((V=JSON.parse(b))==null?void 0:V.data)??[]).map(de=>{let W=R(de);return{handleSecondaryButtonClick:()=>{de.skippable===!0&&L(g,de.id,{skipped:!0})},...de,complete:I(g,de.id)===Oe||W>=1,blocked:ne(g,de.id),hidden:fe(g,de.id),handlePrimaryButtonClick:()=>{(!de.completionCriteria&&(de.autoMarkCompleted||de.autoMarkCompleted===void 0)||de.completionCriteria&&de.autoMarkCompleted===!0)&&L(g,de.id)},progress:W}}).filter(de=>de.hidden!==!0)):[]}function A(g){return g.replace(/\${(.*?)}/g,(b,E)=>r[E]!==void 0?String(r[E]):"")}function U(g){if(!_(g))return[];let b=_(g).data;return b?(b=A(b),JSON.parse(b)??{}):[]}function $(g,b){s(E=>({...E,[g]:b}))}function N(g){!P&&!O&&g&&JSON.stringify(r)!=JSON.stringify({...r,...g})&&Object.keys(g).forEach(b=>{$(b,g[b])})}let ie=pt(async(g,b,E)=>{u();let V={foreignUserId:i,flowSlug:g,stepId:b,actionType:so,data:E??{},createdAt:new Date,blocked:!1,hidden:!1};oe(V)&&(await m(g,b,V),w(V))},[i,C]),pe=pt(async(g,b,E)=>{u();let V={foreignUserId:i,flowSlug:g,stepId:b,actionType:Ae,data:E??{},createdAt:new Date,blocked:!1,hidden:!1};oe(V)&&(await h(g,b),w(V))},[i,C]),L=pt(async(g,b,E)=>{u();let V={foreignUserId:i,flowSlug:g,stepId:b,actionType:Oe,data:E??{},createdAt:new Date,blocked:!1,hidden:!1};oe(V)&&(await y(g,b,V),w(V))},[i,C]),we=pt(async(g,b)=>{if(u(),K(g)===Le)return;let E={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:Le,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};await B(g),oe(E)&&w(E)},[i,C]),xe=pt(async(g,b)=>{u();let E={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:at,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};oe(E)&&w(E)},[i,C]),ee=pt(async(g,b)=>{u();let E={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:Y,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};oe(E)&&(await v(g),w(E))},[i,C]),j=pt(async(g,b)=>{u();let E={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:no,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};oe(E)&&(await v(g),w(E))},[i,C]);function oe(g){var b;if(!C&&g.actionType===Ae)return!1;if(C){let E=C.find(V=>V.flowId===g.flowSlug);if(g.actionType===Ae&&(!(E!=null&&E.stepStates[g.stepId])||E.stepStates[g.stepId].actionType===Ae)||E&&((b=E.stepStates[g.stepId])==null?void 0:b.actionType)===g.actionType||E&&E.flowState===Y&&g.actionType===Y)return!1}return!0}function I(g,b){let E=ke(g,b);return P?null:E?E.actionType:Ae}function ne(g,b){let E=ke(g,b);return E?E.blocked:!1}function fe(g,b){let E=ke(g,b);return E?E.hidden:!1}function ke(g,b){if(P)return null;let E=C==null?void 0:C.find(V=>V.flowId===g);return!E||!E.stepStates[b]?null:E.stepStates[b]??null}function G(g){var E;if(P||!C)return null;if(K(g)===Le)return z(g)[0]??null;let b=(E=C.find(V=>V.flowId===g))==null?void 0:E.lastStepId;return b?z(g).find(V=>V.id===b):null}function ge(g){let b=G(g);if(!b)return 0;let E=z(g).findIndex(V=>V.id===b.id)??0;return I(g,b.id)===Oe&&E<z(g).length-1?E+1:E}function R(g){if(!g.completionCriteria)return;let b=xr(g.completionCriteria);if(b===null)return;let E=je(b),V=Ge(b);return V===0?void 0:E/V}function K(g){let b=C==null?void 0:C.find(E=>E.flowId===g);return b?b.flowState:null}function je(g){let b=z(g);return b.length===0?0:b.filter(V=>I(g,V.id)===Oe).length}function Ge(g){return z(g).length}function wt(g){return JSON.parse(t.find(b=>b.slug===g).data)}function H(g){if(P)return!0;if(g!=null&&g.targetingLogic&&C){let b=C.find(E=>E.flowId===g.slug);if(b)return b.shouldTrigger===!1}return!!(g!=null&&g.targetingLogic&&i&&i.startsWith("guest_"))}function Be(g){return!H(_(g))}return{getFlow:_,getFlowData:wt,isLoading:P||O,getStepStatus:I,getFlowSteps:z,getCurrentStepIndex:ge,markStepStarted:ie,markStepCompleted:L,markFlowNotStarted:we,markFlowStarted:xe,markFlowCompleted:ee,markFlowAborted:j,markStepNotStarted:pe,getFlowStatus:K,getNumberOfStepsCompleted:je,getNumberOfSteps:Ge,targetingLogicShouldHideFlow:H,setCustomVariable:$,updateCustomVariables:N,customVariables:r,getStepOptionalProgress:R,getFlowMetadata:U,isStepBlocked:ne,isStepHidden:fe,hasActiveFullPageFlow:p,setHasActiveFullPageFlow:d,isFlowAvailableToUser:Be}}import{useCallback as Cr,useContext as al,useEffect as pl}from"react";var kt="guest_";function Ht(){let{userId:e,organizationId:t,setUserId:o,setUserProperties:i,shouldGracefullyDegrade:n}=al(q),{config:r}=Me(),{mutateUserFlowState:s}=Ie(),p=Tt(),{verifySDKInitiated:d}=Ft();pl(()=>{if(e&&!t){if(e.startsWith(kt))return;let c=`frigade-user-registered-${e}`;localStorage.getItem(c)||(p(`${Te}users`,{...r,method:"POST",body:JSON.stringify({foreignId:e})}),localStorage.setItem(c,"true"))}},[e,n,t]);let a=Cr(async c=>{d();let u={foreignId:e,properties:c};await p(`${Te}users`,{...r,method:"POST",body:JSON.stringify(u)}),i(w=>({...w,...c})),s()},[e,r,n,s]),f=Cr(async(c,u)=>{d();let T={foreignId:e,events:[{event:c,properties:u}]};await p(`${Te}users`,{...r,method:"POST",body:JSON.stringify(T)}),s()},[e,r,s]);return{userId:e,setUserId:o,addPropertiesToUser:a,trackEventForUser:f}}import{v4 as Oa}from"uuid";import _e,{useEffect as Ba,useState as Aa}from"react";import De,{useEffect as hl}from"react";import co from"styled-components";import dl from"react";import cl from"styled-components";var Sr="fr-",Vt="cfr-";function l(e,t){let o=`${Sr}${e}`;if(!t)return o;if(t.styleOverrides&&t.styleOverrides[e]){if(typeof t.styleOverrides[e]=="string")return o+" "+t.styleOverrides[e];if(typeof t.styleOverrides[e]=="object")return o+" "+Vt+e}return o}function k(e){if(!e.className||e.className.indexOf(Vt)!==-1)return"";let o=e.className.replace(/\s+/g," ").split(" ");return o.length==1&&o[0].startsWith(Sr)?"":`:not(${o.map(i=>`.${i}`).join(", ")})`}function $o(e){return e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}function dt(e){return e!=null&&e.styleOverrides?Object.keys(e.styleOverrides).map(t=>`${$o(t)}: ${e.styleOverrides[t]};`).join(" "):""}function Ce(...e){return e.filter(Boolean).join(" ")}function yr(e){return e.charAt(0).toUpperCase()+e.slice(1)}var ml=cl.div`
|
|
2
|
+
import gt,{createContext as Da,useEffect as Ro,useState as Ne}from"react";import{ThemeProvider as $a}from"styled-components";import ft,{useContext as La,useEffect as Fo,useState as Zo}from"react";import{useCallback as pt,useContext as nl,useEffect as sl}from"react";import Do,{useMemo as Ks}from"react";var gr="1.32.51 ";var Te="https://api.frigade.com/v1/public/",Ae="NOT_STARTED_STEP",Y="COMPLETED_FLOW",no="ABORTED_FLOW",at="STARTED_FLOW",Le="NOT_STARTED_FLOW",Oe="COMPLETED_STEP",so="STARTED_STEP";function Me(){let{publicApiKey:e,userId:t}=Do.useContext(q);return{config:Ks(()=>({headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-Frigade-SDK-Version":gr,"X-Frigade-SDK-Platform":"React"}}),[e,t])}}var Ys="frigade-last-call-at-",Xs="frigade-last-call-data-";function Tt(){let{shouldGracefullyDegrade:e}=Do.useContext(q);return async(t,o)=>{if(e)return console.log(`Skipping ${t} call to Frigade due to error`),zt();let i=Ys+t,n=Xs+t;if(window&&window.localStorage&&o&&o.body&&o.method==="POST"){let s=window.localStorage.getItem(i),p=window.localStorage.getItem(n);if(s&&p&&p==o.body){let d=new Date(s);if(new Date().getTime()-d.getTime()<1e3)return zt()}window.localStorage.setItem(i,new Date().toISOString()),window.localStorage.setItem(n,o.body)}let r;try{r=await fetch(t,o)}catch(s){return zt(s)}return r?r.ok?r:zt(r.statusText):zt()}}function zt(e){return e&&console.log("Call to Frigade failed",e),{json:()=>({})}}function Ft(){let{publicApiKey:e,shouldGracefullyDegrade:t}=Do.useContext(q);function o(){if(t){console.error("Frigade hooks cannot be used when Frigade SDK has failed to initialize");return}e||console.error("Frigade hooks cannot be used outside the scope of FrigadeProvider")}return{verifySDKInitiated:o}}import{useContext as ol,useState as hr}from"react";import{useContext as Qs,useEffect as Zs,useState as Rs}from"react";import el from"swr";import{useContext as Js}from"react";function Pe(){let{openFlowStates:e,setOpenFlowStates:t,hasActiveFullPageFlow:o,setCompletedFlowsToKeepOpenDuringSession:i,completedFlowsToKeepOpenDuringSession:n}=Js(q);function r(c,u=!1){return e[c]??u}function s(c,u){t(w=>({...w,[c]:u}))}function p(c){t(u=>{let{[c]:w,...T}=u;return{...T}})}function d(c){n.includes(c)||i(u=>[...u,c])}function a(c){return n.includes(c)}function f(){return Object.values(e).some(c=>c)||o}return{getOpenFlowState:r,setOpenFlowState:s,resetOpenFlowState:p,hasOpenModals:f,setKeepCompletedFlowOpenDuringSession:d,shouldKeepCompletedFlowOpenDuringSession:a}}var tl="unknown";function Ie(){let{config:e}=Me(),{publicApiKey:t,userId:o,flows:i,setShouldGracefullyDegrade:n}=Qs(q),{resetOpenFlowState:r}=Pe(),[s,p]=Rs(!1),d={data:i.map(y=>({flowId:y.id,flowState:Y,lastStepId:null,userId:o,foreignUserId:o,stepStates:{},shouldTrigger:!1}))},a=y=>fetch(y,e).then(h=>{if(h.ok)return h.json();throw new Error("Failed to fetch user flow states")}).catch(h=>(console.log(`Error fetching ${y}: ${h}. Will gracefully degrade and hide Frigade`),n(!0),d)),{data:f,isLoading:c,mutate:u,error:w}=el(t&&i&&o?`${Te}userFlowStates?foreignUserId=${encodeURIComponent(o)}`:null,a,{revalidateIfStale:!0,keepPreviousData:!0,revalidateOnMount:!0,errorRetryInterval:1e4,errorRetryCount:3,onError:()=>d,onLoadingSlow:()=>d}),T=f==null?void 0:f.data;Zs(()=>{!s&&!c&&T&&p(!0)},[T,s,c]);async function S(y){if(T){let h=T.find(m=>m.flowId===y);h&&h.flowState!==Y&&(h.flowState=Y),await u(Promise.resolve({...f,data:T}),{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function C(y,h,m){if(T){let x=T.find(F=>F.flowId===y);x&&(x.stepStates[h]=m,x.flowState=at),await u(Promise.resolve({...f,data:T}),{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function P(y,h,m){if(T){let x=T.find(F=>F.flowId===y);x&&(x.lastStepId=h,x.stepStates[h]=m,x.flowState=at),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function v(y){if(T){let h=T.find(m=>m.flowId===y);h&&h.flowState!==Le&&(h.flowState=Le,h.lastStepId=tl,Object.keys(h.stepStates).forEach(m=>{h.stepStates[m].actionType=Ae,h.stepStates[m].createdAt=new Date().toISOString()}),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1}),r(y))}}async function B(y,h){if(T){let m=T.find(x=>x.flowId===y);m&&m.stepStates[h]!==Ae&&(m.stepStates[h]=Ae),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}return{userFlowStatesData:T,isLoadingUserFlowStateData:!s,mutateUserFlowState:u,optimisticallyMarkFlowCompleted:S,optimisticallyMarkFlowNotStarted:v,optimisticallyMarkStepCompleted:C,optimisticallyMarkStepNotStarted:B,optimisticallyMarkStepStarted:P,error:w}}function Wt(){let{config:e}=Me(),{userFlowStatesData:t,mutateUserFlowState:o}=Ie(),{failedFlowResponses:i,setFailedFlowResponses:n,flowResponses:r,setFlowResponses:s}=ol(q),[p,d]=hr(new Set),[a,f]=hr(new Set),c=Tt();function u(S){let C=JSON.stringify(S);if(p.has(C))return null;p.add(C),d(p),a.add(S),f(a);let P=r==null?void 0:r.find(v=>v.flowSlug===S.flowSlug&&v.stepId===S.stepId&&v.actionType===S.actionType&&v.createdAt===S.createdAt);return c(`${Te}flowResponses`,{...e,method:"POST",body:C}).then(v=>{v.status!==200&&v.status!==201?(console.log("Failed to send flow response for step "+S.stepId+". Will retry again later."),n([...i,S])):P||s(B=>[...B??[],S])})}async function w(S){S.foreignUserId&&(S.actionType===at||S.actionType===Le?await u(S):S.actionType===Y?await u(S):S.actionType===so?await u(S):S.actionType===Oe?await u(S):S.actionType===no?await u(S):S.actionType===Ae&&await u(S))}function T(){let S=[];return t==null||t.forEach(C=>{if(C&&C.stepStates&&Object.keys(C.stepStates).length!==0)for(let P in C.stepStates){let v=C.stepStates[P];S.push({foreignUserId:C.foreignUserId,flowSlug:C.flowId,stepId:v.stepId,actionType:v.actionType,data:{},createdAt:new Date(v.createdAt),blocked:v.blocked,hidden:v.hidden})}}),[...S,...r]}return{addResponse:w,setFlowResponses:s,getFlowResponses:T}}import ll from"swr";var rl=/user.flow\(([^\)]+)\) == '?COMPLETED_FLOW'?/gm,xr=e=>{let t=rl.exec(e);if(t===null)return null;let o=null;return t.forEach((i,n)=>{let r=il(i,"'","");r.startsWith("flow_")&&(o=r)}),o},il=function(e,t,o){return e.replace(new RegExp(t,"g"),o)};function X(){let{config:e}=Me(),{flows:t,setFlows:o,userId:i,publicApiKey:n,customVariables:r,setCustomVariables:s,hasActiveFullPageFlow:p,setHasActiveFullPageFlow:d,setFlowResponses:a,setShouldGracefullyDegrade:f}=nl(q),c={data:[]},{verifySDKInitiated:u}=Ft(),{addResponse:w,getFlowResponses:T}=Wt(),S=g=>fetch(g,e).then(b=>b.ok?b.json():(console.log(`Error fetching ${g} (${b.status}): ${b.statusText}. .Will gracefully degrade and hide Frigade`),f(!0),c)).catch(b=>(console.log(`Error fetching ${g}: ${b}. Will gracefully degrade and hide Frigade`),f(!0),c)),{userFlowStatesData:C,isLoadingUserFlowStateData:P,optimisticallyMarkFlowCompleted:v,optimisticallyMarkFlowNotStarted:B,optimisticallyMarkStepCompleted:y,optimisticallyMarkStepNotStarted:h,optimisticallyMarkStepStarted:m}=Ie(),{data:x,error:F,isLoading:D}=ll(n?`${Te}flows`:null,S,{keepPreviousData:!0});sl(()=>{if(F){console.error(F);return}x&&x.data&&(x.data=o(x.data))},[x,F]);function _(g){if(D)return null;let b=t.find(E=>E.slug===g);return!b&&t.length>0&&!P&&!D?(console.log(`Flow with slug ${g} not found`),null):(b==null?void 0:b.active)===!1?null:b}function z(g){var V;if(!_(g))return[];let b=_(g).data;return b?(b=A(b),(((V=JSON.parse(b))==null?void 0:V.data)??[]).map(de=>{let W=R(de);return{handleSecondaryButtonClick:()=>{de.skippable===!0&&O(g,de.id,{skipped:!0})},...de,complete:I(g,de.id)===Oe||W>=1,blocked:ne(g,de.id),hidden:fe(g,de.id),handlePrimaryButtonClick:()=>{(!de.completionCriteria&&(de.autoMarkCompleted||de.autoMarkCompleted===void 0)||de.completionCriteria&&de.autoMarkCompleted===!0)&&O(g,de.id)},progress:W}}).filter(de=>de.hidden!==!0)):[]}function A(g){return g.replace(/\${(.*?)}/g,(b,E)=>r[E]!==void 0?String(r[E]):"")}function U(g){if(!_(g))return[];let b=_(g).data;return b?(b=A(b),JSON.parse(b)??{}):[]}function $(g,b){s(E=>({...E,[g]:b}))}function L(g){!P&&!D&&g&&JSON.stringify(r)!=JSON.stringify({...r,...g})&&Object.keys(g).forEach(b=>{$(b,g[b])})}let ie=pt(async(g,b,E)=>{u();let V={foreignUserId:i,flowSlug:g,stepId:b,actionType:so,data:E??{},createdAt:new Date,blocked:!1,hidden:!1};oe(V)&&(await m(g,b,V),w(V))},[i,C]),pe=pt(async(g,b,E)=>{u();let V={foreignUserId:i,flowSlug:g,stepId:b,actionType:Ae,data:E??{},createdAt:new Date,blocked:!1,hidden:!1};oe(V)&&(await h(g,b),w(V))},[i,C]),O=pt(async(g,b,E)=>{u();let V={foreignUserId:i,flowSlug:g,stepId:b,actionType:Oe,data:E??{},createdAt:new Date,blocked:!1,hidden:!1};oe(V)&&(await y(g,b,V),w(V))},[i,C]),we=pt(async(g,b)=>{if(u(),K(g)===Le)return;let E={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:Le,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};await B(g),oe(E)&&w(E)},[i,C]),xe=pt(async(g,b)=>{u();let E={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:at,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};oe(E)&&w(E)},[i,C]),ee=pt(async(g,b)=>{u();let E={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:Y,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};oe(E)&&(await v(g),w(E))},[i,C]),j=pt(async(g,b)=>{u();let E={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:no,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};oe(E)&&(await v(g),w(E))},[i,C]);function oe(g){var b;if(!C&&g.actionType===Ae)return!1;if(C){let E=C.find(V=>V.flowId===g.flowSlug);if(g.actionType===Ae&&(!(E!=null&&E.stepStates[g.stepId])||E.stepStates[g.stepId].actionType===Ae)||E&&((b=E.stepStates[g.stepId])==null?void 0:b.actionType)===g.actionType||E&&E.flowState===Y&&g.actionType===Y)return!1}return!0}function I(g,b){let E=ke(g,b);return P?null:E?E.actionType:Ae}function ne(g,b){let E=ke(g,b);return E?E.blocked:!1}function fe(g,b){let E=ke(g,b);return E?E.hidden:!1}function ke(g,b){if(P)return null;let E=C==null?void 0:C.find(V=>V.flowId===g);return!E||!E.stepStates[b]?null:E.stepStates[b]??null}function G(g){var E;if(P||!C)return null;if(K(g)===Le)return z(g)[0]??null;let b=(E=C.find(V=>V.flowId===g))==null?void 0:E.lastStepId;return b?z(g).find(V=>V.id===b):null}function ge(g){let b=G(g);if(!b)return 0;let E=z(g).findIndex(V=>V.id===b.id)??0;return I(g,b.id)===Oe&&E<z(g).length-1?E+1:E}function R(g){if(!g.completionCriteria)return;let b=xr(g.completionCriteria);if(b===null)return;let E=je(b),V=Ge(b);return V===0?void 0:E/V}function K(g){let b=C==null?void 0:C.find(E=>E.flowId===g);return b?b.flowState:null}function je(g){let b=z(g);return b.length===0?0:b.filter(V=>I(g,V.id)===Oe).length}function Ge(g){return z(g).length}function wt(g){return JSON.parse(t.find(b=>b.slug===g).data)}function H(g){if(P)return!0;if(g!=null&&g.targetingLogic&&C){let b=C.find(E=>E.flowId===g.slug);if(b)return b.shouldTrigger===!1}return!!(g!=null&&g.targetingLogic&&i&&i.startsWith("guest_"))}function Be(g){return!H(_(g))}return{getFlow:_,getFlowData:wt,isLoading:P||D,getStepStatus:I,getFlowSteps:z,getCurrentStepIndex:ge,markStepStarted:ie,markStepCompleted:O,markFlowNotStarted:we,markFlowStarted:xe,markFlowCompleted:ee,markFlowAborted:j,markStepNotStarted:pe,getFlowStatus:K,getNumberOfStepsCompleted:je,getNumberOfSteps:Ge,targetingLogicShouldHideFlow:H,setCustomVariable:$,updateCustomVariables:L,customVariables:r,getStepOptionalProgress:R,getFlowMetadata:U,isStepBlocked:ne,isStepHidden:fe,hasActiveFullPageFlow:p,setHasActiveFullPageFlow:d,isFlowAvailableToUser:Be}}import{useCallback as Cr,useContext as al,useEffect as pl}from"react";var kt="guest_";function Ht(){let{userId:e,organizationId:t,setUserId:o,setUserProperties:i,shouldGracefullyDegrade:n}=al(q),{config:r}=Me(),{mutateUserFlowState:s}=Ie(),p=Tt(),{verifySDKInitiated:d}=Ft();pl(()=>{if(e&&!t){if(e.startsWith(kt))return;let c=`frigade-user-registered-${e}`;localStorage.getItem(c)||(p(`${Te}users`,{...r,method:"POST",body:JSON.stringify({foreignId:e})}),localStorage.setItem(c,"true"))}},[e,n,t]);let a=Cr(async c=>{d();let u={foreignId:e,properties:c};await p(`${Te}users`,{...r,method:"POST",body:JSON.stringify(u)}),i(w=>({...w,...c})),s()},[e,r,n,s]),f=Cr(async(c,u)=>{d();let T={foreignId:e,events:[{event:c,properties:u}]};await p(`${Te}users`,{...r,method:"POST",body:JSON.stringify(T)}),s()},[e,r,s]);return{userId:e,setUserId:o,addPropertiesToUser:a,trackEventForUser:f}}import{v4 as Oa}from"uuid";import _e,{useEffect as Ba,useState as Aa}from"react";import De,{useEffect as hl}from"react";import co from"styled-components";import dl from"react";import cl from"styled-components";var Sr="fr-",Vt="cfr-";function l(e,t){let o=`${Sr}${e}`;if(!t)return o;if(t.styleOverrides&&t.styleOverrides[e]){if(typeof t.styleOverrides[e]=="string")return o+" "+t.styleOverrides[e];if(typeof t.styleOverrides[e]=="object")return o+" "+Vt+e}return o}function k(e){if(!e.className||e.className.indexOf(Vt)!==-1)return"";let o=e.className.replace(/\s+/g," ").split(" ");return o.length==1&&o[0].startsWith(Sr)?"":`:not(${o.map(i=>`.${i}`).join(", ")})`}function $o(e){return e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}function dt(e){return e!=null&&e.styleOverrides?Object.keys(e.styleOverrides).map(t=>`${$o(t)}: ${e.styleOverrides[t]};`).join(" "):""}function Ce(...e){return e.filter(Boolean).join(" ")}function yr(e){return e.charAt(0).toUpperCase()+e.slice(1)}var ml=cl.div`
|
|
3
3
|
display: flex;
|
|
4
4
|
justify-content: center;
|
|
5
5
|
position: fixed;
|
|
@@ -107,7 +107,7 @@ import gt,{createContext as Da,useEffect as Ro,useState as Ne}from"react";import
|
|
|
107
107
|
`,Ir=Uo(ao)`
|
|
108
108
|
background-color: ${e=>{var t;return(t=e.appearance)==null?void 0:t.theme.colorBackground}};
|
|
109
109
|
position: absolute;
|
|
110
|
-
bottom: -
|
|
110
|
+
bottom: -60px;
|
|
111
111
|
left: 0;
|
|
112
112
|
width: 100%;
|
|
113
113
|
height: 40px;
|
|
@@ -116,6 +116,7 @@ import gt,{createContext as Da,useEffect as Ro,useState as Ne}from"react";import
|
|
|
116
116
|
justify-content: center;
|
|
117
117
|
border-radius: ${e=>{var t;return(t=e.appearance)==null?void 0:t.theme.borderRadius}}px;
|
|
118
118
|
padding: 0;
|
|
119
|
+
z-index: ${e=>e.zIndex};
|
|
119
120
|
`,Nr=Uo.div`
|
|
120
121
|
display: flex;
|
|
121
122
|
justify-content: center;
|
|
@@ -378,7 +379,7 @@ import gt,{createContext as Da,useEffect as Ro,useState as Ne}from"react";import
|
|
|
378
379
|
`,Hl=Go.div`
|
|
379
380
|
padding-left: 1px;
|
|
380
381
|
padding-right: 1px;
|
|
381
|
-
`,Vl={text:Vo,multipleChoice:jr,multipleChoiceList:Yr};function Jr({flowId:e,stepData:t,canContinue:o,setCanContinue:i,onSaveData:n,appearance:r,customFormElements:s}){var B;let p=t.props,[d,a]=jo([]),[f,c]=jo([]),{userId:u}=Ht(),[w,T]=jo(P()||{}),S={...Vl,...s};_l(()=>{i(d.length===0)},[d,i]);function C(y,h){let m={...w,[y.id]:h};T(m),n(m),window&&window.localStorage&&window.localStorage.setItem(v(),JSON.stringify(m))}function P(){if(window&&window.localStorage){let y=window.localStorage.getItem(v());if(y)return JSON.parse(y)}return{}}function v(){return`frigade-multiInputStepTypeData-${e}-${t.id}-${u}`}return jt.createElement(Hl,{className:l("multiInput",r)},jt.createElement(Se,{appearance:r,title:t.title,subtitle:t.subtitle}),jt.createElement(zl,{className:l("multiInputContainer",r)},(B=p.data)==null?void 0:B.map(y=>{var m;let h=(m=d.reverse().find(x=>x.id===y.id))==null?void 0:m.message;return S[y.type]?jt.createElement("span",{key:y.id},S[y.type]({formInput:y,customFormTypeProps:{flowId:e,stepData:t,canContinue:o,setCanContinue:i,onSaveData:n,appearance:r},onSaveInputData:x=>{!f.includes(y.id)&&x&&(x==null?void 0:x.text)!==""&&c(F=>[...F,y.id]),C(y,x)},inputData:w[y.id],setFormValidationErrors:x=>{a(F=>x.length===0?F.filter(
|
|
382
|
+
`,Vl={text:Vo,multipleChoice:jr,multipleChoiceList:Yr};function Jr({flowId:e,stepData:t,canContinue:o,setCanContinue:i,onSaveData:n,appearance:r,customFormElements:s}){var B;let p=t.props,[d,a]=jo([]),[f,c]=jo([]),{userId:u}=Ht(),[w,T]=jo(P()||{}),S={...Vl,...s};_l(()=>{i(d.length===0)},[d,i]);function C(y,h){let m={...w,[y.id]:h};T(m),n(m),window&&window.localStorage&&window.localStorage.setItem(v(),JSON.stringify(m))}function P(){if(window&&window.localStorage){let y=window.localStorage.getItem(v());if(y)return JSON.parse(y)}return{}}function v(){return`frigade-multiInputStepTypeData-${e}-${t.id}-${u}`}return jt.createElement(Hl,{className:l("multiInput",r)},jt.createElement(Se,{appearance:r,title:t.title,subtitle:t.subtitle}),jt.createElement(zl,{className:l("multiInputContainer",r)},(B=p.data)==null?void 0:B.map(y=>{var m;let h=(m=d.reverse().find(x=>x.id===y.id))==null?void 0:m.message;return S[y.type]?jt.createElement("span",{key:y.id},S[y.type]({formInput:y,customFormTypeProps:{flowId:e,stepData:t,canContinue:o,setCanContinue:i,onSaveData:n,appearance:r},onSaveInputData:x=>{!f.includes(y.id)&&x&&(x==null?void 0:x.text)!==""&&c(F=>[...F,y.id]),C(y,x)},inputData:w[y.id],setFormValidationErrors:x=>{a(F=>x.length===0?F.filter(D=>D.id!==y.id):[...F,...x])}}),h&&f.includes(y.id)&&jt.createElement(Wl,{appearance:r,className:l("multiInputValidationError",r)},h)):null})))}import ct from"styled-components";var Qr=ct.div`
|
|
382
383
|
align-items: center;
|
|
383
384
|
display: flex;
|
|
384
385
|
justify-content: ${e=>e.showBackButton?"space-between":"flex-end"};
|
|
@@ -623,8 +624,8 @@ import gt,{createContext as Da,useEffect as Ro,useState as Ne}from"react";import
|
|
|
623
624
|
color: ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorText}};
|
|
624
625
|
display: flex;
|
|
625
626
|
align-self: center;
|
|
626
|
-
`;var Ci=({stepData:e,setCanContinue:t,onSaveData:o,appearance:i})=>{let n=e.props,[r,s]=Xo([]),[p,d]=Xo(!1),[a,f]=Xo(e.id);return Yo(()=>{r.length==0&&!p&&(d(!0),o({choice:[]}))},[p]),Yo(()=>{a!==e.id&&(f(e.id),s([]))},[e]),Yo(()=>{o({choice:r}),r.length>=n.minChoices?t(!0):t(!1)},[r]),Ke.createElement(di,{className:l("selectListContainer",i)},Ke.createElement(ci,null,Ke.createElement(mi,{className:l("selectListTitle",i)},e.title),Ke.createElement(ui,{appearance:i,className:l("selectListSubtitle",i)},e.subtitle)),n.options.map((c,u)=>{let w=r.includes(c.id);return Ke.createElement(fi,{key:`select-item-${u}`,onClick:()=>{if(r.includes(c.id)){s(r.filter(T=>T!==c.id));return}r.length<n.maxChoices?s([...r,c.id]):r.length==1&&n.maxChoices==1&&s([c.id])},hideBottomBorder:u===n.options.length-1,className:l("selectListSelectItem",i)},Ke.createElement(gi,{className:l("selectListItemImage",i)},c.imageUri&&Ke.createElement(hi,{src:c.imageUri,alt:`select-icon-${u}`}),Ke.createElement(xi,{appearance:i,className:l("selectListSelectItemText",i)},c.title)),Ke.createElement(ut,{appearance:i,value:w,primaryColor:i.theme.colorPrimary}))}))};import ye,{useEffect as Jo,useState as Yt}from"react";import{AnimatePresence as ka,motion as Pa}from"framer-motion";var va=({children:e,id:t,shouldWrap:o=!1})=>ye.createElement(ye.Fragment,null,o?ye.createElement(ka,{initial:!1},ye.createElement(Pa.div,{key:t,initial:{opacity:1,y:"100%"},animate:{opacity:1,y:0},exit:{opacity:0,y:"-100%"},transition:{duration:.5,ease:"easeInOut"},style:{width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:1,overflowY:"auto"}},e)):e),To=({appearance:e,steps:t,selectedStep:o,customStepTypes:i,customVariables:n,onButtonClick:r,onStepCompletion:s,flowId:p,type:d,hideOnFlowCompletion:a,onComplete:f,setVisible:c,setShowModal:u,onDismiss:w,showPagination:T=!1,customFormElements:S,allowBackNavigation:C,validationHandler:P})=>{var ke;let B={...{linkCollection:li,multiInput:Jr,callToAction:ai,selectList:Ci},...i},{primaryCTAClickSideEffects:y,secondaryCTAClickSideEffects:h}=re(),[m,x]=Yt(!1),[F,
|
|
627
|
-
${i=>i.inlineStyles.map(([n,r])=>`.${Vt}${n}.${Vt}${n} { ${Object.entries(r).map(([s,p])=>`${$o(s)}: ${p};`).join(" ")} }`).join(" ")}`;return Xt.createElement(o,{inlineStyles:t})}var Si=({flowId:e,customStepTypes:t={},type:o="inline",visible:i,setVisible:n,customVariables:r,customFormElements:s,onComplete:p,appearance:d,hideOnFlowCompletion:a=!0,onStepCompletion:f,onButtonClick:c,dismissible:u=!0,endFlowOnDismiss:w=!1,modalPosition:T="center",repeatable:S=!1,onDismiss:C,showPagination:P=!1,allowBackNavigation:v=!1,validationHandler:B,showFrigadeBranding:y=!1})=>{let{getFlow:h,getFlowSteps:m,isLoading:x,targetingLogicShouldHideFlow:F,getFlowStatus:
|
|
627
|
+
`;var Ci=({stepData:e,setCanContinue:t,onSaveData:o,appearance:i})=>{let n=e.props,[r,s]=Xo([]),[p,d]=Xo(!1),[a,f]=Xo(e.id);return Yo(()=>{r.length==0&&!p&&(d(!0),o({choice:[]}))},[p]),Yo(()=>{a!==e.id&&(f(e.id),s([]))},[e]),Yo(()=>{o({choice:r}),r.length>=n.minChoices?t(!0):t(!1)},[r]),Ke.createElement(di,{className:l("selectListContainer",i)},Ke.createElement(ci,null,Ke.createElement(mi,{className:l("selectListTitle",i)},e.title),Ke.createElement(ui,{appearance:i,className:l("selectListSubtitle",i)},e.subtitle)),n.options.map((c,u)=>{let w=r.includes(c.id);return Ke.createElement(fi,{key:`select-item-${u}`,onClick:()=>{if(r.includes(c.id)){s(r.filter(T=>T!==c.id));return}r.length<n.maxChoices?s([...r,c.id]):r.length==1&&n.maxChoices==1&&s([c.id])},hideBottomBorder:u===n.options.length-1,className:l("selectListSelectItem",i)},Ke.createElement(gi,{className:l("selectListItemImage",i)},c.imageUri&&Ke.createElement(hi,{src:c.imageUri,alt:`select-icon-${u}`}),Ke.createElement(xi,{appearance:i,className:l("selectListSelectItemText",i)},c.title)),Ke.createElement(ut,{appearance:i,value:w,primaryColor:i.theme.colorPrimary}))}))};import ye,{useEffect as Jo,useState as Yt}from"react";import{AnimatePresence as ka,motion as Pa}from"framer-motion";var va=({children:e,id:t,shouldWrap:o=!1})=>ye.createElement(ye.Fragment,null,o?ye.createElement(ka,{initial:!1},ye.createElement(Pa.div,{key:t,initial:{opacity:1,y:"100%"},animate:{opacity:1,y:0},exit:{opacity:0,y:"-100%"},transition:{duration:.5,ease:"easeInOut"},style:{width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:1,overflowY:"auto"}},e)):e),To=({appearance:e,steps:t,selectedStep:o,customStepTypes:i,customVariables:n,onButtonClick:r,onStepCompletion:s,flowId:p,type:d,hideOnFlowCompletion:a,onComplete:f,setVisible:c,setShowModal:u,onDismiss:w,showPagination:T=!1,customFormElements:S,allowBackNavigation:C,validationHandler:P})=>{var ke;let B={...{linkCollection:li,multiInput:Jr,callToAction:ai,selectList:Ci},...i},{primaryCTAClickSideEffects:y,secondaryCTAClickSideEffects:h}=re(),[m,x]=Yt(!1),[F,D]=Yt({}),[_,z]=Yt(!1),[A,U]=Yt(!1),[$,L]=Yt(null),ie=t[o]??null,{markStepCompleted:pe,markStepStarted:O,isLoading:we,updateCustomVariables:xe,markFlowCompleted:ee}=X();Jo(()=>{xe(n)},[n,we]),Jo(()=>{window&&C&&!A&&(window.location.hash=t[o].id,U(!0))},[C,A,U]),Jo(()=>{var G;if(window&&((G=window==null?void 0:window.location)!=null&&G.hash)&&window.location.hash.replace("#","")!==t[o].id){let ge=window.location.hash.replace("#",""),R=t.findIndex(K=>K.id===ge);R!==-1&&O(p,t[R].id)}},[(ke=window==null?void 0:window.location)==null?void 0:ke.hash,O,o,t]);function j(){return{data:F[t[o].id]??{},stepId:t[o].id,customVariables:n}}function oe(G,ge,R){let K=o+1<t.length?t[o+1]:null;r&&r(G,o,ge,K),s&&s(G,R,K,F,j())}function I(G,ge){D(R=>{let K={};return K[G.id]=ge,{...R,...K}})}function ne(G){return G.selectedStep.imageUri?ye.createElement(ri,{image:G.selectedStep.imageUri,appearance:e,className:l("formContainerSidebarImage",e)}):null}let fe=ye.createElement(ni,{step:t[o],canContinue:m&&!_,formType:d,selectedStep:o,appearance:e,onPrimaryClick:async()=>{if(z(!0),P){let ge=await P(t[o],o,t[o+1],F,j());if(ge){L(ge),z(!1);return}else L(null)}let G={...j()};await pe(p,t[o].id,G),o+1<t.length&&await O(p,t[o+1].id),oe(t[o],"primary",o),o+1>=t.length&&(f&&f(),w&&w(),a&&(c&&c(!1),u(!1)),await ee(p)),y(t[o]),z(!1),window&&C&&o+1<t.length&&(window.location.hash=t[o+1].id)},onSecondaryClick:()=>{oe(t[o],"secondary",o),h(t[o])},onBack:async()=>{o-1>=0&&(z(!0),await O(p,t[o-1].id),z(!1))},steps:t,allowBackNavigation:C,errorMessage:$});return ye.createElement(ye.Fragment,null,ye.createElement(ei,{className:l("formContainer",e)},ye.createElement(ti,null,ye.createElement(va,{id:o,shouldWrap:d==="large-modal"},ye.createElement(oi,{key:ie.id,type:d,className:l("formContent",e)},t.map(G=>{let ge=B[G.type];return ie.id!==G.id?null:ye.createElement(ge,{key:G.id,stepData:G,canContinue:m,setCanContinue:x,onSaveData:R=>{I(G,R)},appearance:e,customFormElements:S,flowId:p})}),T&&ye.createElement(si,{className:l("formPagination",e),appearance:e,stepCount:t.length,currentStep:o}),fe))),d=="large-modal"&&ye.createElement(ne,{selectedStep:t[o]})))};import Xt from"react";import{createGlobalStyle as Ea}from"styled-components";function te({appearance:e}){if(!e||!e.styleOverrides)return Xt.createElement(Xt.Fragment,null);let t=Object.entries(e.styleOverrides).filter(([i,n])=>typeof n=="object");if(t.length===0)return Xt.createElement(Xt.Fragment,null);let o=Ea`
|
|
628
|
+
${i=>i.inlineStyles.map(([n,r])=>`.${Vt}${n}.${Vt}${n} { ${Object.entries(r).map(([s,p])=>`${$o(s)}: ${p};`).join(" ")} }`).join(" ")}`;return Xt.createElement(o,{inlineStyles:t})}var Si=({flowId:e,customStepTypes:t={},type:o="inline",visible:i,setVisible:n,customVariables:r,customFormElements:s,onComplete:p,appearance:d,hideOnFlowCompletion:a=!0,onStepCompletion:f,onButtonClick:c,dismissible:u=!0,endFlowOnDismiss:w=!1,modalPosition:T="center",repeatable:S=!1,onDismiss:C,showPagination:P=!1,allowBackNavigation:v=!1,validationHandler:B,showFrigadeBranding:y=!1})=>{let{getFlow:h,getFlowSteps:m,isLoading:x,targetingLogicShouldHideFlow:F,getFlowStatus:D,getCurrentStepIndex:_,markFlowCompleted:z,markFlowNotStarted:A}=X(),U=_(e),{mergeAppearanceWithDefault:$}=J(),[L,ie]=Aa(!1),{setOpenFlowState:pe,getOpenFlowState:O}=Pe();d=$(d);let[we,xe]=i!==void 0&&n!==void 0?[i,n]:[O(e,!0),I=>pe(e,I)];if(Ba(()=>{!L&&!x&&(ie(!0),D(e)===Y&&S&&A(e),ie(!0))},[L,ie,x]),x)return null;let ee=h(e);if(!ee||F(ee))return null;let j=m(e);if(!j||i!==void 0&&i===!1||D(e)===Y&&a)return null;let oe=()=>{xe(!1),C&&C(),w===!0&&z(e)};if(T=="center"&&o==="modal"||o==="large-modal"){let I={padding:"24px"};return o==="large-modal"?(I.width="85%",I.height="90%",I.maxHeight="800px",I.minHeight="500px",I.padding="0"):I.width="400px",_e.createElement(et,{appearance:d,onClose:oe,visible:we,style:I,dismissible:u,showFrigadeBranding:y},_e.createElement(te,{appearance:d}),_e.createElement(To,{appearance:d,steps:j,selectedStep:U,customStepTypes:t,customVariables:r,onButtonClick:c,onStepCompletion:f,flowId:e,type:o,hideOnFlowCompletion:a,onComplete:p,setVisible:n,setShowModal:xe,onDismiss:C,showPagination:P,customFormElements:s,allowBackNavigation:v,validationHandler:B}))}return o==="modal"&&T!=="center"?_e.createElement(Or,{appearance:d,onClose:oe,visible:we},_e.createElement(te,{appearance:d}),_e.createElement(To,{appearance:d,steps:j,selectedStep:U,customStepTypes:t,customVariables:r,onButtonClick:c,onStepCompletion:f,flowId:e,type:o,hideOnFlowCompletion:a,onComplete:p,setVisible:n,setShowModal:xe,onDismiss:C,showPagination:P,customFormElements:s,allowBackNavigation:v,validationHandler:B})):_e.createElement(_e.Fragment,null,_e.createElement(te,{appearance:d}),_e.createElement(To,{appearance:d,steps:j,selectedStep:U,customStepTypes:t,customVariables:r,onButtonClick:c,onStepCompletion:f,flowId:e,type:o,hideOnFlowCompletion:a,onComplete:p,setVisible:n,setShowModal:xe,onDismiss:C,showPagination:P,customFormElements:s,allowBackNavigation:v,validationHandler:B}))},yi=Si;import{useCallback as bi,useContext as Ia,useEffect as Na}from"react";function Qo(){let{organizationId:e,userId:t,setOrganizationId:o}=Ia(q),{mutateUserFlowState:i}=Ie(),{config:n}=Me(),r=Tt(),{verifySDKInitiated:s}=Ft();Na(()=>{if(t&&e){if(t.startsWith(kt))return;let a=`frigade-user-group-registered-${t}-${e}`;localStorage.getItem(a)||(r(`${Te}userGroups`,{...n,method:"POST",body:JSON.stringify({foreignUserId:t,foreignUserGroupId:e})}),localStorage.setItem(a,"true"))}},[t,e]);let p=bi(async a=>{if(s(),!e||!t){console.error("Cannot add properties to organization: Organization ID and User ID must both be set.",{organizationId:e,userId:t});return}let f={foreignUserId:t,foreignUserGroupId:e,properties:a};await r(`${Te}userGroups`,{...n,method:"POST",body:JSON.stringify(f)}),i()},[e,t,n,i]),d=bi(async(a,f)=>{if(s(),!e||!t){console.error("Cannot track event for organization: Organization ID and User ID must both be set.",{organizationId:e,userId:t});return}let u={foreignUserId:t,foreignUserGroupId:e,events:[{event:a,properties:f}]};await r(`${Te}userGroups`,{...n,method:"POST",body:JSON.stringify(u)}),i()},[e,t,n,i]);return{organizationId:e,setOrganizationId:o,addPropertiesToOrganization:p,trackEventForOrganization:d}}var wi="xFrigade_guestUserId",Ti="xFrigade_userId",Fi=({})=>{let{setFlowResponses:e}=Wt(),{userFlowStatesData:t,isLoadingUserFlowStateData:o,mutateUserFlowState:i}=Ie(),{userId:n,setUserId:r}=Ht(),[s,p]=Zo(null),{getFlowStatus:d}=X(),{flows:a,userProperties:f,setIsNewGuestUser:c,flowResponses:u}=La(q),[w,T]=Zo([]),[S,C]=Zo([]),{organizationId:P}=Qo();Fo(()=>{if(!o&&t)for(let h=0;h<t.length;h++){let m=t[h],x=a.find(F=>F.slug===(m==null?void 0:m.flowId));if(x&&m&&m.shouldTrigger===!0&&x.type=="FORM"&&x.triggerType==="AUTOMATIC"&&!S.includes(x.slug)){setTimeout(()=>{v(m.flowId)},500);break}}},[o,t]),Fo(()=>{u.length>0&&i()},[u]);function v(h){let m=a.find(x=>x.slug===h);m&&m.triggerType==="AUTOMATIC"&&!S.includes(m.slug)&&(C([...S,m.slug]),T([m]))}function B(){if(!n){let h=localStorage.getItem(Ti);if(h){r(h);return}let m=localStorage.getItem(wi);if(m){r(m);return}c(!0);let x=kt+Oa();try{localStorage.setItem(wi,x)}catch(F){console.log("Failed to save guest user id locally: Local storage unavailable",F)}r(F=>F||x)}}Fo(()=>{try{if(a){let h=[];a.forEach(m=>{if(m.data){let x=m.data.match(/"imageUri":"(.*?)"/g);x&&x.forEach(F=>{let D=F.replace('"imageUri":"',"").replace('"',"");if(h.includes(D))return;let _=new Image;_.src=D,h.push(D)})}})}}catch{}},[a]),Fo(()=>{if(n!==s&&e([]),p(n),n&&!n.startsWith(kt))try{localStorage.setItem(Ti,n)}catch(h){console.log("Failed to save user id locally: Local storage available",h)}n===null&&setTimeout(()=>{n===null&&B()},50)},[n,a,f]);function y(){return ft.createElement(ft.Fragment,null,w.map(h=>d(h.slug)!==Le?null:ft.createElement("span",{key:h.slug},ft.createElement(yi,{flowId:h.slug,type:"modal",modalPosition:"center",endFlowOnDismiss:!0}))))}return ft.createElement(ft.Fragment,null,ft.createElement(y,null))};import{ErrorBoundary as Ma}from"react-error-boundary";var q=Da({publicApiKey:"",setUserId:()=>{},flows:[],setFlows:()=>{},failedFlowResponses:[],setFailedFlowResponses:()=>{},flowResponses:[],setFlowResponses:()=>{},userProperties:{},setUserProperties:()=>{},openFlowStates:{},setOpenFlowStates:()=>{},completedFlowsToKeepOpenDuringSession:[],setCompletedFlowsToKeepOpenDuringSession:()=>{},customVariables:{},setCustomVariables:()=>{},isNewGuestUser:!1,setIsNewGuestUser:()=>{},hasActiveFullPageFlow:!1,setHasActiveFullPageFlow:()=>{},organizationId:"",setOrganizationId:()=>{},navigate:()=>{},defaultAppearance:qe,shouldGracefullyDegrade:!1,setShouldGracefullyDegrade:()=>{}}),Ua=({publicApiKey:e,userId:t,organizationId:o,config:i,children:n})=>{var ie,pe;let[r,s]=Ne(t||null),[p,d]=Ne(o||null),[a,f]=Ne([]),[c,u]=Ne([]),[w,T]=Ne([]),[S,C]=Ne({}),[P,v]=Ne({}),[B,y]=Ne([]),[h,m]=Ne({}),[x,F]=Ne(!1),[D,_]=Ne(!1),[z,A]=Ne(!L(e)),U=(O,we)=>{if(we==="_blank"){window.open(O,"_blank");return}setTimeout(()=>{window.location.href=O},50)},$={theme:{...qe.theme,...((ie=i==null?void 0:i.defaultAppearance)==null?void 0:ie.theme)??{}},styleOverrides:{...qe.styleOverrides,...((pe=i==null?void 0:i.defaultAppearance)==null?void 0:pe.styleOverrides)??{}}};function L(O){return!!(O&&O.length>10&&O.substring(0,10)==="api_public")}return Ro(()=>{t&&s(t)},[t]),Ro(()=>{o&&d(o)},[o]),Ro(()=>{if(L(e))A(!1);else{console.error("Frigade SDK failed to initialize. API key provided is either missing or valid."),A(!0);return}},[e,A]),z?gt.createElement(q.Provider,{value:{publicApiKey:e,userId:r,setUserId:s,setFlows:f,flows:a,failedFlowResponses:c,setFailedFlowResponses:u,flowResponses:w,setFlowResponses:T,userProperties:S,setUserProperties:C,openFlowStates:P,setOpenFlowStates:v,completedFlowsToKeepOpenDuringSession:B,setCompletedFlowsToKeepOpenDuringSession:y,customVariables:h,setCustomVariables:m,isNewGuestUser:x,setIsNewGuestUser:F,hasActiveFullPageFlow:D,setHasActiveFullPageFlow:_,organizationId:p,setOrganizationId:d,navigate:i&&i.navigate?i.navigate:U,defaultAppearance:$,shouldGracefullyDegrade:z,setShouldGracefullyDegrade:A}},n):gt.createElement(Ma,{fallback:gt.createElement(gt.Fragment,null,n)},gt.createElement(q.Provider,{value:{publicApiKey:e,userId:r,setUserId:s,setFlows:f,flows:a,failedFlowResponses:c,setFailedFlowResponses:u,flowResponses:w,setFlowResponses:T,userProperties:S,setUserProperties:C,openFlowStates:P,setOpenFlowStates:v,completedFlowsToKeepOpenDuringSession:B,setCompletedFlowsToKeepOpenDuringSession:y,customVariables:h,setCustomVariables:m,isNewGuestUser:x,setIsNewGuestUser:F,hasActiveFullPageFlow:D,setHasActiveFullPageFlow:_,organizationId:p,setOrganizationId:d,navigate:i&&i.navigate?i.navigate:U,defaultAppearance:$,shouldGracefullyDegrade:z,setShouldGracefullyDegrade:A}},gt.createElement($a,{theme:$.theme},n,gt.createElement(Fi,null))))};import Dp from"react";import ae,{useEffect as ts,useState as os}from"react";import $e,{useState as sp}from"react";import Ct from"styled-components";import vo from"react";import ht from"react";import Pi from"styled-components";var ki=Pi.span`
|
|
628
629
|
font-weight: 400;
|
|
629
630
|
font-size: 15px;
|
|
630
631
|
line-height: 20px;
|
|
@@ -1230,7 +1231,7 @@ ${i=>i.inlineStyles.map(([n,r])=>`.${Vt}${n}.${Vt}${n} { ${Object.entries(r).map
|
|
|
1230
1231
|
color: ${({theme:e})=>e.colorTextSecondary};
|
|
1231
1232
|
${e=>e.blocked||e.complete?"opacity: 0.4;":`
|
|
1232
1233
|
`}
|
|
1233
|
-
`;var Qn=({stepData:e,style:t={},appearance:o})=>{let{mergeAppearanceWithDefault:i}=J(),{primaryCTAClickSideEffects:n}=re(),{theme:r,styleOverrides:s}=i(o),{imageUri:p=null,subtitle:d=null,title:a=null,complete:f=!1,blocked:c=!1}=e,u=()=>{n(e)};return St.createElement(Hn,{className:l("carouselCard",o),onClick:c?null:u,style:t,blocked:c,complete:f},St.createElement("div",{style:{alignItems:"flex-start",display:"flex",justifyContent:"space-between"}},p&&St.createElement(Vn,{className:l("carouselCardImage",o),src:p,alt:a,style:{opacity:f||c?.4:1}}),f&&St.createElement(Kn,{className:l("carouselCompletedPill",o)},St.createElement(Jn,{style:{color:"#108E0B"}},"Complete"))),a&&St.createElement(Xn,{blocked:c,complete:f,className:l("carouselCardTitle",o)},a),d&&St.createElement(We.Quiet,{blocked:c,complete:f,className:l("carouselCardSubtitle",o)},d))};import eo from"react";var Zn=({numberOfStepsCompleted:e,numberOfSteps:t,appearance:o})=>{let i=t>0?e/t:0,n=200,r=Math.min(n,Math.max(10,Math.round(n*i)));return eo.createElement(Gn,{className:l("carouselProgressBar",o)},eo.createElement(qn,{as:We.Loud,style:{marginRight:8}},e," of ",t),eo.createElement("svg",{height:10,width:n},eo.createElement("rect",{x:0,y:0,rx:5,width:n,height:10,fill:"#E6E6E6"}),eo.createElement("rect",{x:0,y:0,rx:5,width:r,height:10,fill:"currentColor"})))};var Op=()=>le.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},le.createElement("path",{d:"M14 6L20 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),le.createElement("path",{d:"M14 18L20 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),le.createElement("path",{d:"M4 12H20",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})),Rn=({side:e="left",show:t=!1,onClick:o=()=>{}})=>{let[i,n]=yt(!1),[r,s]=yt(!1);sr(()=>{t===!0&&i===!1?n(!0):t===!1&&i===!0&&s(!0)},[t]);let p=()=>{n(!1),s(!1)},d=e=="left"?{top:0,bottom:0,left:-20,transform:"rotate(180deg)"}:{top:0,bottom:0,right:-20};return i?le.createElement(_n,{style:d,reversed:r,onAnimationEnd:r?p:null},le.createElement(zn,{onClick:()=>o(),style:{right:16,top:"calc(50% - 24px)"}},le.createElement(Op,null))):null},es=({flowId:e,appearance:t,customVariables:o,className:i})=>{let n=Lp(null),[r,s]=yt(!1),[p,d]=yt(!1),[a,f]=yt(null),[c,u]=yt([]),[w,T]=yt(0),{getFlowMetadata:S,getFlowSteps:C,getNumberOfStepsCompleted:P,updateCustomVariables:v,getFlowStatus:B,isLoading:y,targetingLogicShouldHideFlow:h,getFlow:m}=X();sr(()=>{v(o)},[o,y]),sr(()=>{if(y)return;let A=S(e),U=P(e),$=C(e);f(A),A.data!==null&&(u($.sort((
|
|
1234
|
+
`;var Qn=({stepData:e,style:t={},appearance:o})=>{let{mergeAppearanceWithDefault:i}=J(),{primaryCTAClickSideEffects:n}=re(),{theme:r,styleOverrides:s}=i(o),{imageUri:p=null,subtitle:d=null,title:a=null,complete:f=!1,blocked:c=!1}=e,u=()=>{n(e)};return St.createElement(Hn,{className:l("carouselCard",o),onClick:c?null:u,style:t,blocked:c,complete:f},St.createElement("div",{style:{alignItems:"flex-start",display:"flex",justifyContent:"space-between"}},p&&St.createElement(Vn,{className:l("carouselCardImage",o),src:p,alt:a,style:{opacity:f||c?.4:1}}),f&&St.createElement(Kn,{className:l("carouselCompletedPill",o)},St.createElement(Jn,{style:{color:"#108E0B"}},"Complete"))),a&&St.createElement(Xn,{blocked:c,complete:f,className:l("carouselCardTitle",o)},a),d&&St.createElement(We.Quiet,{blocked:c,complete:f,className:l("carouselCardSubtitle",o)},d))};import eo from"react";var Zn=({numberOfStepsCompleted:e,numberOfSteps:t,appearance:o})=>{let i=t>0?e/t:0,n=200,r=Math.min(n,Math.max(10,Math.round(n*i)));return eo.createElement(Gn,{className:l("carouselProgressBar",o)},eo.createElement(qn,{as:We.Loud,style:{marginRight:8}},e," of ",t),eo.createElement("svg",{height:10,width:n},eo.createElement("rect",{x:0,y:0,rx:5,width:n,height:10,fill:"#E6E6E6"}),eo.createElement("rect",{x:0,y:0,rx:5,width:r,height:10,fill:"currentColor"})))};var Op=()=>le.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},le.createElement("path",{d:"M14 6L20 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),le.createElement("path",{d:"M14 18L20 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),le.createElement("path",{d:"M4 12H20",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})),Rn=({side:e="left",show:t=!1,onClick:o=()=>{}})=>{let[i,n]=yt(!1),[r,s]=yt(!1);sr(()=>{t===!0&&i===!1?n(!0):t===!1&&i===!0&&s(!0)},[t]);let p=()=>{n(!1),s(!1)},d=e=="left"?{top:0,bottom:0,left:-20,transform:"rotate(180deg)"}:{top:0,bottom:0,right:-20};return i?le.createElement(_n,{style:d,reversed:r,onAnimationEnd:r?p:null},le.createElement(zn,{onClick:()=>o(),style:{right:16,top:"calc(50% - 24px)"}},le.createElement(Op,null))):null},es=({flowId:e,appearance:t,customVariables:o,className:i})=>{let n=Lp(null),[r,s]=yt(!1),[p,d]=yt(!1),[a,f]=yt(null),[c,u]=yt([]),[w,T]=yt(0),{getFlowMetadata:S,getFlowSteps:C,getNumberOfStepsCompleted:P,updateCustomVariables:v,getFlowStatus:B,isLoading:y,targetingLogicShouldHideFlow:h,getFlow:m}=X();sr(()=>{v(o)},[o,y]),sr(()=>{if(y)return;let A=S(e),U=P(e),$=C(e);f(A),A.data!==null&&(u($.sort((L,ie)=>Number(L.complete)-Number(ie.complete))),d($.length>3),T(U))},[y]);let x=[];for(let A=0;A<c.length;A+=3)x.push(c.slice(A,A+3));let F=A=>{let U=A.target,$=U.scrollWidth-U.clientWidth,L=Math.ceil(U.scrollLeft);L>0&&r===!1&&s(!0),L===0&&r===!0&&s(!1),L<$&&p===!1&&d(!0),L===$&&p===!0&&d(!1)},D=(A=!0)=>{let U=A?1:-1;n.current!==null&&n.current.scrollBy({left:n.current.clientWidth*U,behavior:"smooth"})},_=null,z=A=>{_!==null?clearTimeout(_):F(A),_=setTimeout(()=>{F(A)},16)};return y?null:le.createElement(jn,{className:Ce(l("carouselContainer",t),i)},le.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:20}},le.createElement("div",null,le.createElement(Yn,{className:l("carouselTitle",t)},a==null?void 0:a.title),le.createElement(We.Quiet,{className:l("carouselSubtitle",t)},a==null?void 0:a.subtitle)),le.createElement(Zn,{numberOfStepsCompleted:w,numberOfSteps:c.length})),le.createElement("div",{style:{position:"relative"}},le.createElement(Rn,{show:r,onClick:()=>D(!1)}),le.createElement(Rn,{side:"right",show:p,onClick:D}),le.createElement(Mn,{ref:n,onScroll:z},x.map((A,U)=>le.createElement(Un,{key:U,style:{flex:`0 0 calc(100% - ${c.length>3?36:0}px)`}},A.map(($,L)=>le.createElement(Qn,{key:L,stepData:$,style:{flex:c.length>3?"0 1 calc(33% - 16px * 2 / 3)":1},appearance:t})))))))};var lr=({flowId:e,title:t,subtitle:o,style:i,initialSelectedStep:n,className:r,type:s="inline",onDismiss:p,visible:d,customVariables:a,onStepCompletion:f,onButtonClick:c,appearance:u,hideOnFlowCompletion:w,setVisible:T,customStepTypes:S,checklistStyle:C="default",autoExpandFirstIncompleteStep:P,autoExpandNextStep:v,...B})=>{let{getFlow:y,getFlowSteps:h,markStepCompleted:m,getStepStatus:x,getNumberOfStepsCompleted:F,isLoading:D,targetingLogicShouldHideFlow:_,updateCustomVariables:z,getFlowMetadata:A,isStepBlocked:U,getFlowStatus:$,hasActiveFullPageFlow:L,setHasActiveFullPageFlow:ie}=X(),{primaryCTAClickSideEffects:pe,secondaryCTAClickSideEffects:O}=re(),{getOpenFlowState:we,setOpenFlowState:xe}=Pe(),[ee,j]=os(n||0),[oe,I]=os(!1),ne=d===void 0?we(e):d,fe=s==="modal",{mergeAppearanceWithDefault:ke}=J(),{isLarge:G}=Cn();if(u=ke(u),ts(()=>{z(a)},[a,D]),ts(()=>{d!==void 0&&(fe&&d===!0?ie(!0):fe&&d===!1&&ie(!1))},[d,T,L]),D)return null;let ge=y(e);if(!ge||_(ge))return null;let R=h(e);if(!R||w===!0&&$(e)===Y)return null;let K=A(e);if(K!=null&&K.title&&(t=K.title),K!=null&&K.subtitle&&(o=K.subtitle),!oe&&n===void 0&&F(e)>0){let W=Math.min(F(e),R.length-1);j(W),I(!0)}function je(){if(ee+1>=R.length){fe&&xe(e,!1);return}U(e,R[ee+1].id)||j(ee+1)}function Ge(W,lt,io){let fr=ee+1<R.length?R[ee+1]:null;c&&c(W,ee,lt,fr)===!0&&fe&&g(),f&&f(W,io,fr),!f&&!c&&(W.primaryButtonUri||W.secondaryButtonUri)&&fe&&g()}function wt(){return R.map((W,lt)=>({...W,handleSecondaryButtonClick:()=>{je(),O(W),W.skippable===!0&&m(e,W.id,{skipped:!0}),Ge(W,"secondary",lt)},handlePrimaryButtonClick:()=>{(!W.completionCriteria&&(W.autoMarkCompleted||W.autoMarkCompleted===void 0)||W.completionCriteria&&W.autoMarkCompleted===!0)&&(m(e,W.id),je()),Ge(W,"primary",lt),pe(W),x(e,W.id)===Oe&&je()}}))}function H(){return ae.createElement(te,{appearance:u})}let Be={steps:wt(),title:t,subtitle:o,primaryColor:u.theme.colorPrimary,appearance:u,customStepTypes:S,type:s,className:r,autoExpandFirstIncompleteStep:P,autoExpandNextStep:v};function g(){xe(e,!1),p&&p(),T&&T(!1)}function b(){return ae.createElement(ae.Fragment,null,ae.createElement(H,null),ae.createElement(es,{flowId:e,appearance:u,customVariables:a,className:r}))}function E(){return ae.createElement(ae.Fragment,null,ae.createElement(H,null),ae.createElement(nr,{visible:ne,onClose:()=>{g()},selectedStep:ee,setSelectedStep:j,autoExpandNextStep:!0,appearance:u,...Be}))}function V(){if(!G)return E();let W=B.guideFlowId,lt;return W&&y(W)&&(lt=h(W)),ae.createElement(ae.Fragment,null,ae.createElement(H,null),ae.createElement(ir,{visible:ne,stepsTitle:K.stepsTitle?K.stepsTitle:"Your quick start guide",onClose:()=>{g()},selectedStep:ee,setSelectedStep:j,guideData:lt,guideTitle:B.guideTitle??"Guide",appearance:u,title:t,subtitle:o,onGuideButtonClick:io=>{Ge(io,"link",0)},customStepTypes:S,...Be}))}function de(){if(!G)return E();let W=ae.createElement(or,{flowId:e,style:i,selectedStep:ee,setSelectedStep:j,appearance:u,type:s,...Be});return fe?ae.createElement(et,{onClose:()=>{g()},visible:ne,appearance:u,style:{paddingTop:"0px",padding:"12px",paddingLeft:0}},ae.createElement(H,null),W):ae.createElement(ae.Fragment,null,ae.createElement(H,null),W)}switch(C){case"condensed":return E();case"with-guide":return V();case"default":return de();case"carousel":return b();default:return de()}};var $p=e=>Dp.createElement(lr,{type:"inline",...e});import st,{useEffect as Up}from"react";import He from"react";import Io from"styled-components";var rs=Io.div`
|
|
1234
1235
|
border: 1px solid ${e=>e.appearance.theme.colorBorder};
|
|
1235
1236
|
border-radius: 8px;
|
|
1236
1237
|
padding: 6px 10px 6px 10px;
|
|
@@ -1295,7 +1296,7 @@ ${i=>i.inlineStyles.map(([n,r])=>`.${Vt}${n}.${Vt}${n} { ${Object.entries(r).map
|
|
|
1295
1296
|
:hover {
|
|
1296
1297
|
opacity: 0.8;
|
|
1297
1298
|
}
|
|
1298
|
-
`;var ms=({title:e,subtitle:t,icon:o,appearance:i,count:n,total:r,className:s,style:p})=>nt.createElement(nt.Fragment,null,nt.createElement(as,{appearance:i,className:Ce(l("fullWidthProgressBadgeContainer",i),s??""),style:p},o&&nt.createElement(ps,{className:l("fullWidthProgressBadgeIcon",i)},o),nt.createElement(ds,null,nt.createElement(Se,{size:"small",appearance:i,title:e,subtitle:t})),nt.createElement(cs,{className:l("fullWidthProgressBadgeProgressContainer",i)},nt.createElement(ze,{count:n,total:r,display:"percent",textLocation:"top",fillColor:i.theme.colorPrimary}))));var _p=({flowId:e,title:t,subtitle:o,icon:i,style:n,onClick:r,className:s,customVariables:p,hideOnFlowCompletion:d,appearance:a,type:f="default"})=>{let{getFlow:c,getFlowSteps:u,getFlowStatus:w,getNumberOfStepsCompleted:T,isLoading:S,targetingLogicShouldHideFlow:C,updateCustomVariables:P}=X(),{mergeAppearanceWithDefault:v}=J();a=v(a);let{setOpenFlowState:B,getOpenFlowState:y}=Pe();if(Up(()=>{P(p)},[p,S]),S)return null;let h=c(e);if(!h||C(h)||d===!0&&w(e)===Y)return null;let m=u(e),x=T(e);return f==="full-width"?st.createElement(st.Fragment,null,st.createElement(te,{appearance:a}),st.createElement(ms,{title:t,subtitle:o,count:x,total:m.length,style:n,className:s,appearance:a,icon:i,onClick:()=>{}})):st.createElement(st.Fragment,null,st.createElement(te,{appearance:a}),st.createElement(ls,{count:x,total:m.length,title:t,style:n,onClick:()=>{B(e,!0),r&&r()},type:f,className:s,appearance:a}))};import zp from"react";var Wp=({flowId:e,style:t,appearance:o,...i})=>{let{getFlow:n,targetingLogicShouldHideFlow:r,getFlowSteps:s}=X(),{mergeAppearanceWithDefault:p}=J();o=p(o);let d=n(e);if(!d||r(d))return null;let a=s(e);return zp.createElement(Rt,{steps:a,style:t,appearance:o,...i})};import Ut,{useContext as Rp,useEffect as ed}from"react";import
|
|
1299
|
+
`;var ms=({title:e,subtitle:t,icon:o,appearance:i,count:n,total:r,className:s,style:p})=>nt.createElement(nt.Fragment,null,nt.createElement(as,{appearance:i,className:Ce(l("fullWidthProgressBadgeContainer",i),s??""),style:p},o&&nt.createElement(ps,{className:l("fullWidthProgressBadgeIcon",i)},o),nt.createElement(ds,null,nt.createElement(Se,{size:"small",appearance:i,title:e,subtitle:t})),nt.createElement(cs,{className:l("fullWidthProgressBadgeProgressContainer",i)},nt.createElement(ze,{count:n,total:r,display:"percent",textLocation:"top",fillColor:i.theme.colorPrimary}))));var _p=({flowId:e,title:t,subtitle:o,icon:i,style:n,onClick:r,className:s,customVariables:p,hideOnFlowCompletion:d,appearance:a,type:f="default"})=>{let{getFlow:c,getFlowSteps:u,getFlowStatus:w,getNumberOfStepsCompleted:T,isLoading:S,targetingLogicShouldHideFlow:C,updateCustomVariables:P}=X(),{mergeAppearanceWithDefault:v}=J();a=v(a);let{setOpenFlowState:B,getOpenFlowState:y}=Pe();if(Up(()=>{P(p)},[p,S]),S)return null;let h=c(e);if(!h||C(h)||d===!0&&w(e)===Y)return null;let m=u(e),x=T(e);return f==="full-width"?st.createElement(st.Fragment,null,st.createElement(te,{appearance:a}),st.createElement(ms,{title:t,subtitle:o,count:x,total:m.length,style:n,className:s,appearance:a,icon:i,onClick:()=>{}})):st.createElement(st.Fragment,null,st.createElement(te,{appearance:a}),st.createElement(ls,{count:x,total:m.length,title:t,style:n,onClick:()=>{B(e,!0),r&&r()},type:f,className:s,appearance:a}))};import zp from"react";var Wp=({flowId:e,style:t,appearance:o,...i})=>{let{getFlow:n,targetingLogicShouldHideFlow:r,getFlowSteps:s}=X(),{mergeAppearanceWithDefault:p}=J();o=p(o);let d=n(e);if(!d||r(d))return null;let a=s(e);return zp.createElement(Rt,{steps:a,style:t,appearance:o,...i})};import Ut,{useContext as Rp,useEffect as ed}from"react";import N,{useEffect as No,useLayoutEffect as gs,useRef as qp,useState as oo}from"react";import ro from"styled-components";import{useCallback as Hp,useEffect as Vp,useState as jp}from"react";var ar=(e,t,o,i={x:20,y:20},n)=>{let r=n=="fixed"?0:window.scrollY,s=n=="fixed"?0:window.scrollX;return!e||!e.left||!e.top?{x:0,y:0}:t==="left"?{x:e.left-o+i.x+s,y:e.top-i.y+r}:t==="right"?{x:e.left+e.width+i.x+s,y:e.top-i.y+r}:{x:0,y:0}},us={bottom:0,height:0,left:0,right:0,top:0,width:0,x:0,y:0};function Gp(e){let t=us;return e&&(t=e.getBoundingClientRect()),t}function fs(e,t){let[o,i]=jp(us),n=Hp(()=>{e&&i(Gp(e))},[e]);return Vp(()=>(n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)),[e,t]),o}var hs=300,xs=100,Kp=500,Mt=12,Yp=ro.div`
|
|
1299
1300
|
width: 100%;
|
|
1300
1301
|
height: 100%;
|
|
1301
1302
|
border-radius: 9999px;
|
|
@@ -1336,7 +1337,7 @@ ${i=>i.inlineStyles.map(([n,r])=>`.${Vt}${n}.${Vt}${n} { ${Object.entries(r).map
|
|
|
1336
1337
|
`,Qp=ro(Cs)`
|
|
1337
1338
|
width: ${Mt+12}px;
|
|
1338
1339
|
height: ${Mt+12}px;
|
|
1339
|
-
`,Zp=({steps:e=[],onDismiss:t,onComplete:o=()=>{},tooltipPosition:i="auto",showHighlight:n=!0,primaryColor:r="#000000",offset:s={x:0,y:0},visible:p=!0,containerStyle:d={},selectedStep:a=0,customStepTypes:f,appearance:c,dismissible:u=!1,showHighlightOnly:w,showStepCount:T=!0,completedStepsCount:S=0,showFrigadeBranding:C=!1})=>{var K,je,Ge,wt;let[P,v]=oo(),[B,y]=oo(new Date),h=qp(null),[m,x]=oo(document.querySelector(e[a].selector)),F=fs(m,B),[
|
|
1340
|
+
`,Zp=({steps:e=[],onDismiss:t,onComplete:o=()=>{},tooltipPosition:i="auto",showHighlight:n=!0,primaryColor:r="#000000",offset:s={x:0,y:0},visible:p=!0,containerStyle:d={},selectedStep:a=0,customStepTypes:f,appearance:c,dismissible:u=!1,showHighlightOnly:w,showStepCount:T=!0,completedStepsCount:S=0,showFrigadeBranding:C=!1})=>{var K,je,Ge,wt;let[P,v]=oo(),[B,y]=oo(new Date),h=qp(null),[m,x]=oo(document.querySelector(e[a].selector)),F=fs(m,B),[D,_]=oo(),[z,A]=oo(!w),U=(je=(K=e[a])==null?void 0:K.props)!=null&&je.position?e[a].props.position:"absolute",$=((wt=(Ge=e[a])==null?void 0:Ge.props)==null?void 0:wt.zIndex)??90,L=(P==null?void 0:P.width)??hs,ie=(P==null?void 0:P.height)??xs;gs(()=>{h.current&&v({width:h.current.clientWidth,height:h.current.clientHeight})},[a,B,U]),No(()=>{w||A(!0)},[a]);let pe=i==="auto"?"right":i,O=ar(F,pe,L,s,U),we=F.right+L>(window.innerWidth||document.documentElement.clientWidth),xe=F.bottom+xs>(window.innerHeight||document.documentElement.clientHeight);we&&i==="auto"&&(O=ar(F,"left",L,s,U),pe="left");let ee=window.location.pathname.split("/").pop(),j=()=>{let H=document.querySelector(e[a].selector);D&&D===JSON.stringify(H==null?void 0:H.getBoundingClientRect())||(x(H),y(new Date),H&&_(JSON.stringify(H.getBoundingClientRect())))};if(No(()=>{let H=new MutationObserver(j);return H.observe(document.body,{subtree:!0,childList:!0}),()=>H.disconnect()},[j]),No(()=>{let H=new MutationObserver(j);return H.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","class"]}),()=>H.disconnect()},[j]),No(()=>{let H=setInterval(()=>{j()},10);return()=>clearInterval(H)},[j]),gs(()=>{setTimeout(()=>{j()},Kp),j()},[a,ee]),m===null)return N.createElement(N.Fragment,null);if(O.x==0&&O.y==0)return N.createElement(N.Fragment,null);if(!p)return N.createElement(N.Fragment,null);let oe=()=>{let H=()=>{if(e[a].handlePrimaryButtonClick&&(e[a].handlePrimaryButtonClick(),A(!1),setTimeout(()=>{j()},30)),S===e.length-1)return o()},Be=()=>{e[a].handleSecondaryButtonClick&&(e[a].handleSecondaryButtonClick(),w&&A(!1))};return N.createElement(N.Fragment,null,T&&N.createElement(vr,null,N.createElement(Br,{className:l("tooltipStepCounter",c)},a+1," of ",e.length)),N.createElement(Er,{showStepCount:T,className:l("tooltipCTAContainer",c)},e[a].secondaryButtonTitle&&N.createElement(Z,{title:e[a].secondaryButtonTitle,appearance:c,onClick:Be,size:"small",withMargin:!1,secondary:!0}),e[a].primaryButtonTitle&&N.createElement(Z,{title:e[a].primaryButtonTitle,appearance:c,onClick:H,withMargin:!1,size:"small"})))},I=()=>N.createElement(N.Fragment,null,u&&N.createElement(Tr,{"data-testid":"tooltip-dismiss",onClick:()=>{t&&t()},className:l("tooltipClose",c)},N.createElement(ve,null)),e[a].imageUri&&N.createElement(Fr,{dismissible:u,appearance:c,src:e[a].imageUri,className:l("tooltipImageContainer",c)}),e[a].videoUri&&!e[a].imageUri&&N.createElement(kr,{dismissible:u,appearance:c,className:l("tooltipVideoContainer",c)},N.createElement(Et,{appearance:c,videoUri:e[a].videoUri})),N.createElement(Se,{appearance:c,title:e[a].title,subtitle:e[a].subtitle,size:"small"}),N.createElement(Pr,{className:l("tooltipFooter",c)},N.createElement(oe,null))),fe={...{default:H=>{var Be;if((Be=e[a])!=null&&Be.StepContent){let g=e[a].StepContent;return N.createElement("div",null,g)}return N.createElement(I,null)}},...f},ke=()=>{var H;return e?!((H=e[a])!=null&&H.type)||!fe[e[a].type]?fe.default(e[a]):fe[e[a].type]({stepData:e[a],primaryColor:r}):N.createElement(N.Fragment,null)};if(w&&e[a].complete===!0)return null;let G={top:(O==null?void 0:O.y)-Mt,left:(pe=="left"?F.x+s.x:(O==null?void 0:O.x)-Mt)??0,cursor:w?"pointer":"default",position:U},ge=()=>{let Be=G.left+(pe=="left"?-L:24);return Math.min(Math.max(Be,20),window.innerWidth-L-20)},R=()=>{w&&(y(new Date),A(!z))};return N.createElement(Jp,null,N.createElement(Qp,{style:G,zIndex:$,className:l("tourHighlightContainer",c)},n&&e[a].showHighlight!==!1&&N.createElement(N.Fragment,null,N.createElement(Xp,{style:{position:U},onClick:R,primaryColor:c.theme.colorPrimary}),N.createElement(Yp,{style:{position:"absolute"},onClick:R,primaryColor:c.theme.colorPrimary}))),N.createElement(Cs,{style:{...G,left:ge()},zIndex:$+1,className:l("tooltipContainerWrapper",c)},z&&N.createElement(N.Fragment,null,N.createElement(ao,{ref:h,layoutId:"tooltip-container",style:{position:"relative",width:"max-content",right:0,top:12,...d},appearance:c,className:l("tooltipContainer",c),maxWidth:hs,zIndex:$+10},N.createElement(ke,null)),C&&N.createElement(Ir,{className:l("poweredByFrigadeTooltipRibbon",c),appearance:c,zIndex:$+10},N.createElement(po,{appearance:c})))))},Lo=Zp;import{Portal as td}from"react-portal";var od=({flowId:e,customVariables:t,appearance:o,onStepCompletion:i,onButtonClick:n,showTooltipsSimultaneously:r=!1,onDismiss:s,dismissible:p,tooltipPosition:d="auto",showHighlightOnly:a=!1,dismissBehavior:f="complete-flow",onComplete:c,...u})=>{let{getFlow:w,getFlowSteps:T,isLoading:S,targetingLogicShouldHideFlow:C,markStepCompleted:P,markStepStarted:v,markFlowCompleted:B,updateCustomVariables:y,getCurrentStepIndex:h,getStepStatus:m,isStepBlocked:x,getFlowStatus:F,getNumberOfStepsCompleted:D}=X(),{isLoadingUserFlowStateData:_}=Ie(),{primaryCTAClickSideEffects:z,secondaryCTAClickSideEffects:A}=re(),{hasOpenModals:U}=Pe(),$=h(e),{openFlowStates:L}=Rp(q),{mergeAppearanceWithDefault:ie}=J();if(o=ie(o),ed(()=>{y(t)},[t,S]),_)return null;let pe=w(e);if(!pe||C(pe)||F(e)==Y||U())return null;let O=T(e);if(Object.keys(L).length>0){let I=Object.keys(L).find(ne=>L[ne]===!0);if(I!==void 0&&I!==e)return Ut.createElement(Ut.Fragment,null)}async function we(I){if(await P(e,I.id),O.map(ne=>m(e,ne.id)).every(ne=>ne===Oe)){await B(e);return}if(!a&&$+1<O.length){if(x(e,O[$+1].id))return;await v(e,O[$+1].id)}}function xe(I,ne,fe){let ke=$+1<O.length?O[$+1]:null;n&&n(I,$,ne,ke),i&&i(I,fe,ke)}function ee(){return O.map(I=>({...I,handleSecondaryButtonClick:async()=>{A(I),I.skippable===!0&&await P(e,I.id,{skipped:!0}),xe(I,"secondary",$)},handlePrimaryButtonClick:async()=>{(!I.completionCriteria&&(I.autoMarkCompleted||I.autoMarkCompleted===void 0)||I.completionCriteria&&I.autoMarkCompleted===!0)&&await we(I),xe(I,"primary",$),z(I)}}))}async function j(I){s&&s(),f==="complete-flow"?await B(e):await P(e,I.id)}function oe(){c&&c()}return Ut.createElement(td,null,Ut.createElement(te,{appearance:o}),r?O.map((I,ne)=>Ut.createElement(Lo,{key:I.id,appearance:o,steps:ee(),selectedStep:ne,showTooltipsSimultaneously:r,dismissible:p,onDismiss:()=>j(I),tooltipPosition:d,showHighlightOnly:a,completedStepsCount:D(e),onComplete:oe,...u})):Ut.createElement(Lo,{appearance:o,steps:ee(),selectedStep:$,showTooltipsSimultaneously:r,dismissible:p,onDismiss:()=>j(O[$]),tooltipPosition:d,completedStepsCount:D(e),showHighlightOnly:a,onComplete:oe,...u}))};import be,{useEffect as rd,useRef as id,useState as nd}from"react";import{Portal as sd}from"react-portal";import bt from"styled-components";var Ss=bt.button`
|
|
1340
1341
|
${e=>k(e)} {
|
|
1341
1342
|
// Anything inside this block will be ignored if the user provides a custom class
|
|
1342
1343
|
|
|
@@ -1424,7 +1425,7 @@ ${i=>i.inlineStyles.map(([n,r])=>`.${Vt}${n}.${Vt}${n} { ${Object.entries(r).map
|
|
|
1424
1425
|
font-size: 14px;
|
|
1425
1426
|
|
|
1426
1427
|
padding: 8px 12px;
|
|
1427
|
-
`;import{AnimatePresence as As,motion as Is}from"framer-motion";import Ps from"react";var vs=({style:e,className:t})=>Ps.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",fill:"none",viewBox:"0 0 18 18",style:e,className:t},Ps.createElement("path",{fill:"currentColor",d:"M13.43 4.938a4.494 4.494 0 00-1.043-1.435A4.955 4.955 0 009 2.197c-1.276 0-2.48.464-3.387 1.305A4.502 4.502 0 004.57 4.938a4.242 4.242 0 00-.386 1.773v.475c0 .109.087.197.196.197h.95a.197.197 0 00.197-.197V6.71c0-1.749 1.557-3.17 3.473-3.17s3.473 1.421 3.473 3.17c0 .718-.254 1.393-.738 1.955a3.537 3.537 0 01-1.9 1.125 1.928 1.928 0 00-1.085.682c-.271.343-.42.768-.42 1.206v.552c0 .109.088.197.197.197h.95a.197.197 0 00.196-.197v-.552c0-.276.192-.519.457-.578a4.904 4.904 0 002.625-1.56c.335-.392.597-.828.778-1.3a4.256 4.256 0 00-.103-3.303zM9 13.834a.985.985 0 10.001 1.97.985.985 0 00-.001-1.97z"}));import Es from"react";var Bs=({style:e,className:t})=>Es.createElement("svg",{style:e,className:t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},Es.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"}));var ld=({flowId:e,style:t,onStepCompletion:o,visible:i=!0,type:n="inline",title:r="Help",appearance:s})=>{let{getFlow:p,getFlowSteps:d,markStepCompleted:a,getStepStatus:f,getNumberOfStepsCompleted:c,isLoading:u,targetingLogicShouldHideFlow:w}=X(),{primaryCTAClickSideEffects:T}=re(),S=id(null),[C,P]=nd(!1),{mergeAppearanceWithDefault:v}=J();s=v(s),rd(()=>(document.addEventListener("click",B,!1),()=>{document.removeEventListener("click",B,!1)}),[]);let B=F=>{S.current&&!S.current.contains(F.target)&&P(!1)};if(u)return null;let y=p(e);if(!y||w(y))return null;let h=d(e);if(!h||!i)return null;function m(F,
|
|
1428
|
+
`;import{AnimatePresence as As,motion as Is}from"framer-motion";import Ps from"react";var vs=({style:e,className:t})=>Ps.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",fill:"none",viewBox:"0 0 18 18",style:e,className:t},Ps.createElement("path",{fill:"currentColor",d:"M13.43 4.938a4.494 4.494 0 00-1.043-1.435A4.955 4.955 0 009 2.197c-1.276 0-2.48.464-3.387 1.305A4.502 4.502 0 004.57 4.938a4.242 4.242 0 00-.386 1.773v.475c0 .109.087.197.196.197h.95a.197.197 0 00.197-.197V6.71c0-1.749 1.557-3.17 3.473-3.17s3.473 1.421 3.473 3.17c0 .718-.254 1.393-.738 1.955a3.537 3.537 0 01-1.9 1.125 1.928 1.928 0 00-1.085.682c-.271.343-.42.768-.42 1.206v.552c0 .109.088.197.197.197h.95a.197.197 0 00.196-.197v-.552c0-.276.192-.519.457-.578a4.904 4.904 0 002.625-1.56c.335-.392.597-.828.778-1.3a4.256 4.256 0 00-.103-3.303zM9 13.834a.985.985 0 10.001 1.97.985.985 0 00-.001-1.97z"}));import Es from"react";var Bs=({style:e,className:t})=>Es.createElement("svg",{style:e,className:t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},Es.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"}));var ld=({flowId:e,style:t,onStepCompletion:o,visible:i=!0,type:n="inline",title:r="Help",appearance:s})=>{let{getFlow:p,getFlowSteps:d,markStepCompleted:a,getStepStatus:f,getNumberOfStepsCompleted:c,isLoading:u,targetingLogicShouldHideFlow:w}=X(),{primaryCTAClickSideEffects:T}=re(),S=id(null),[C,P]=nd(!1),{mergeAppearanceWithDefault:v}=J();s=v(s),rd(()=>(document.addEventListener("click",B,!1),()=>{document.removeEventListener("click",B,!1)}),[]);let B=F=>{S.current&&!S.current.contains(F.target)&&P(!1)};if(u)return null;let y=p(e);if(!y||w(y))return null;let h=d(e);if(!h||!i)return null;function m(F,D){!F.completionCriteria&&(F.autoMarkCompleted||F.autoMarkCompleted===void 0)&&a(e,F.id),T(F),o&&o(F,D),P(!1)}function x(){return C&&be.createElement(Fs,{className:l("floatingWidgetMenu",s),as:Is.div,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},type:n},h.map((F,D)=>be.createElement(ks,{className:l("floatingWidgetMenuItem",s),key:D,onClick:()=>m(F,D)},F.title)))}return n=="inline"?be.createElement("span",{ref:S},be.createElement(Ss,{style:t,onClick:()=>{P(!C)},className:l("supportButton",s)},be.createElement(bs,{className:l("supportIconContainer",s)},be.createElement(Bs,{className:l("supportIcon",s),style:{width:"18px",height:"18px"}})),be.createElement(ys,{className:l("supportButtonTitle",s)},r)),be.createElement(As,null,be.createElement(x,null))):be.createElement(sd,null,be.createElement(ws,{style:t,ref:S},be.createElement(As,null,be.createElement(x,null)),be.createElement(Ts,{onClick:()=>{P(!C)},as:Is.button,whileHover:{scale:1.1},className:l("floatingWidgetButton",s)},be.createElement(vs,{className:l("floatingWidgetButtonIcon",s),style:{display:"flex",width:"20px",height:"20px"}}))))};import Ve,{useEffect as ad}from"react";import Oo from"styled-components";var Ns=Oo.div`
|
|
1428
1429
|
${e=>k(e)} {
|
|
1429
1430
|
display: flex;
|
|
1430
1431
|
flex-direction: column;
|
|
@@ -1592,5 +1593,5 @@ ${i=>i.inlineStyles.map(([n,r])=>`.${Vt}${n}.${Vt}${n} { ${Object.entries(r).map
|
|
|
1592
1593
|
opacity: 0.8;
|
|
1593
1594
|
}
|
|
1594
1595
|
}
|
|
1595
|
-
`;var fd=({flowId:e,onDismiss:t,customVariables:o,onButtonClick:i,appearance:n,className:r,style:s})=>{let{getFlow:p,markFlowCompleted:d,markStepCompleted:a,getNumberOfStepsCompleted:f,isLoading:c,targetingLogicShouldHideFlow:u,updateCustomVariables:w,getFlowSteps:T,getFlowStatus:S,getCurrentStepIndex:C}=X(),{primaryCTAClickSideEffects:P}=re(),{mergeAppearanceWithDefault:v}=J(),[B,y]=Q.useState(null),[h,m]=Q.useState(""),{hasOpenModals:x,setKeepCompletedFlowOpenDuringSession:F,shouldKeepCompletedFlowOpenDuringSession:
|
|
1596
|
+
`;var fd=({flowId:e,onDismiss:t,customVariables:o,onButtonClick:i,appearance:n,className:r,style:s})=>{let{getFlow:p,markFlowCompleted:d,markStepCompleted:a,getNumberOfStepsCompleted:f,isLoading:c,targetingLogicShouldHideFlow:u,updateCustomVariables:w,getFlowSteps:T,getFlowStatus:S,getCurrentStepIndex:C}=X(),{primaryCTAClickSideEffects:P}=re(),{mergeAppearanceWithDefault:v}=J(),[B,y]=Q.useState(null),[h,m]=Q.useState(""),{hasOpenModals:x,setKeepCompletedFlowOpenDuringSession:F,shouldKeepCompletedFlowOpenDuringSession:D}=Pe();if(n=v(n),md(()=>{w(o)},[o,c]),c)return null;let _=p(e);if(!_||u(_)||S(e)===Y||f(e)===1&&!D(e)||x())return null;let A=T(e)[C(e)];function U(){return Q.createElement(Q.Fragment,null,Q.createElement(ur,null,Q.createElement(Se,{size:"large",appearance:n,title:A.title,subtitle:A.subtitle})),Q.createElement(cr,{className:l("npsNumberButtonContainer",n),appearance:n},Array.from(Array(10).keys()).map(L=>Q.createElement(Vs,{className:l("npsNumberButton",n),selected:B===L+1,key:L,onClick:async()=>{F(e),y(L+1),await a(e,A.id,{score:L+1})},appearance:n},L+1))),Q.createElement(js,{appearance:n},Q.createElement(mr,{appearance:n},"Not likely at all"),Q.createElement(mr,{appearance:n},"Extremely likely")))}function $(){return Q.createElement(Q.Fragment,null,Q.createElement(ur,null,Q.createElement(Se,{appearance:n,title:"Why did you choose this score?",size:"large"})),Q.createElement(Gs,{appearance:n,value:h,onChange:L=>{m(L.target.value)},placeHolder:"Add your optional fedback here..."}),Q.createElement(cr,{appearance:n,className:l("npsNumberButtonContainer",n)},Q.createElement(Z,{size:"large",withMargin:!1,onClick:async()=>{await d(e),i&&i(A,1,"primary")},appearance:n,title:A.secondaryButtonTitle||"Skip",secondary:!0}),Q.createElement(Z,{size:"large",withMargin:!1,onClick:async()=>{await a(e,A.id,{feedbackText:h}),await d(e),i&&i(A,1,"primary")},appearance:n,title:A.primaryButtonTitle||"Submit"})))}return Q.createElement(ud,null,Q.createElement(te,{appearance:n}),Q.createElement(Hs,{appearance:n,className:Ce(l("npsSurveyContainer",n),r),style:s},Q.createElement(qs,{onClick:async()=>{await d(e),t&&t()},className:l("npsSurveyDismissButton",n)},Q.createElement(ve,null)),f(e)==0&&U(),f(e)==1&&$()))};export{ut as CheckBox,ot as FormLabel,Vo as FormTextField,cd as FrigadeBanner,lr as FrigadeChecklist,qe as FrigadeDefaultAppearance,pd as FrigadeEmbeddedTip,Si as FrigadeForm,Wp as FrigadeGuide,$p as FrigadeHeroChecklist,fd as FrigadeNPSSurvey,_p as FrigadeProgressBadge,Ua as FrigadeProvider,ld as FrigadeSupportWidget,od as FrigadeTour,At as ProgressRing,Pe as useFlowOpens,Wt as useFlowResponses,X as useFlows,Qo as useOrganization,Ht as useUser};
|
|
1596
1597
|
//# sourceMappingURL=index.mjs.map
|