@frigade/react 1.37.13 → 1.37.15
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.js +301 -301
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var sa=Object.defineProperty,la=Object.defineProperties;var aa=Object.getOwnPropertyDescriptors;var $o=Object.getOwnPropertySymbols;var li=Object.prototype.hasOwnProperty,ai=Object.prototype.propertyIsEnumerable;var si=(e,t,o)=>t in e?sa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,T=(e,t)=>{for(var o in t||(t={}))li.call(t,o)&&si(e,o,t[o]);if($o)for(var o of $o(t))ai.call(t,o)&&si(e,o,t[o]);return e},j=(e,t)=>la(e,aa(t));var pi=e=>typeof e=="symbol"?e:e+"",Ie=(e,t)=>{var o={};for(var i in e)li.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&$o)for(var i of $o(e))t.indexOf(i)<0&&ai.call(e,i)&&(o[i]=e[i]);return o};var M=(e,t,o)=>new Promise((i,n)=>{var r=d=>{try{p(o.next(d))}catch(s){n(s)}},l=d=>{try{p(o.throw(d))}catch(s){n(s)}},p=d=>d.done?i(d.value):Promise.resolve(d.value).then(r,l);p((o=o.apply(e,t)).next())});import Eo,{createContext as Fd,useEffect as or,useState as Ve}from"react";import{ThemeProvider as An}from"styled-components";import Nt,{useContext as Rp,useEffect as Rt,useState as ko}from"react";import{useCallback as Bt,useContext as ba,useEffect as wa}from"react";import gr,{useMemo as ci}from"react";var di="1.37.13";var nt="NOT_STARTED_STEP",re="COMPLETED_FLOW",Mo="ABORTED_FLOW",vt="STARTED_FLOW",Me="NOT_STARTED_FLOW",Le="COMPLETED_STEP",go="STARTED_STEP";function Ze(){let{publicApiKey:e,userId:t,apiUrl:o}=gr.useContext(Q);return{config:ci(()=>({headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-Frigade-SDK-Version":di,"X-Frigade-SDK-Platform":"React"}}),[e,t]),apiUrl:ci(()=>`${o}/v1/public/`,[o])}}var pa="frigade-last-call-at-",da="frigade-last-call-data-";function jt(){let{shouldGracefullyDegrade:e,readonly:t}=gr.useContext(Q);return(o,i)=>M(this,null,function*(){if(t&&(i.method==="POST"||i.method==="PUT"||i.method==="DELETE"))return Vt();if(e)return console.log(`Skipping ${o} call to Frigade due to error`),Vt();let n=pa+o,r=da+o;if(typeof window!="undefined"&&window.localStorage&&i&&i.body&&i.method==="POST"){let p=window.localStorage.getItem(n),d=window.localStorage.getItem(r);if(p&&d&&d==i.body){let s=new Date(p);if(new Date().getTime()-s.getTime()<1e3)return Vt()}typeof window!="undefined"&&(window.localStorage.setItem(n,new Date().toISOString()),window.localStorage.setItem(r,i.body))}let l;try{l=yield fetch(o,i)}catch(p){return Vt(p)}return l?l.ok?l:Vt(l.statusText):Vt()})}function Vt(e){return e&&console.log("Call to Frigade failed",e),{json:()=>({})}}function Gt(){let{publicApiKey:e,shouldGracefullyDegrade:t}=gr.useContext(Q);function o(){return t?!1:e?!0:(console.error("Frigade hooks cannot be used outside the scope of FrigadeProvider"),!1)}return{verifySDKInitiated:o}}import{useContext as Ca,useState as mi}from"react";import{useContext as ma,useEffect as ua,useState as fa}from"react";import ga from"swr";import{useContext as ca}from"react";function Be(){let{openFlowStates:e,setOpenFlowStates:t,hasActiveFullPageFlow:o,setCompletedFlowsToKeepOpenDuringSession:i,completedFlowsToKeepOpenDuringSession:n}=ca(Q);function r(c,g=!1){var y;return(y=e[c])!=null?y:g}function l(c,g){t(y=>j(T({},y),{[c]:g}))}function p(c){t(g=>{let C=g,{[c]:y}=C,b=Ie(C,[pi(c)]);return T({},b)})}function d(c){n.includes(c)||i(g=>[...g,c])}function s(c){return n.includes(c)}function m(c){return Object.entries(e).some(([g,y])=>y&&g!=c)||o}return{getOpenFlowState:r,setOpenFlowState:l,resetOpenFlowState:p,hasOpenModals:m,setKeepCompletedFlowOpenDuringSession:d,shouldKeepCompletedFlowOpenDuringSession:s}}import ha from"swr/immutable";import ho from"core-js-pure/actual/structured-clone";function hr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ce(...e){let t=e.shift(),o=e.length===1?e[0]:Ce(...e);if(!hr(t)||!hr(o))throw new Error("deepmerge can only merge Objects");let i=ho(t);return Object.entries(o).forEach(([n,r])=>{hr(r)?i[n]!==void 0?Object.assign(i,{[n]:Ce(i[n],ho(r))}):Object.assign(i,{[n]:ho(r)}):Array.isArray(r)?i[n]!==void 0?Object.assign(i,{[n]:[...i[n],...ho(r)]}):Object.assign(i,{[n]:ho(r)}):Object.assign(i,{[n]:r})}),i}var xa="unknown";function De(){let{config:e,apiUrl:t}=Ze(),{publicApiKey:o,userId:i,organizationId:n,flows:r,setShouldGracefullyDegrade:l,readonly:p}=ma(Q),{resetOpenFlowState:d}=Be(),[s,m]=fa(!1),c={data:r.map(w=>({flowId:w.id,flowState:re,lastStepId:null,userId:i,foreignUserId:i,stepStates:{},shouldTrigger:!1}))},g=w=>fetch(w,e).then(k=>{if(k.ok)return k.json();throw new Error("Failed to fetch user flow states")}).catch(k=>(console.log(`Error fetching ${w}: ${k}. Will gracefully degrade and hide Frigade`),l(!0),c)),y=o&&r&&i?`${t}userFlowStates?foreignUserId=${encodeURIComponent(i)}${n?`&foreignUserGroupId=${encodeURIComponent(n)}`:""}`:null,{data:b,isLoading:C,mutate:x,error:P}=p?ha(y,g):ga(y,g,{revalidateOnFocus:!0,revalidateIfStale:!0,keepPreviousData:!0,revalidateOnMount:!1,errorRetryInterval:1e4,errorRetryCount:3,onError:()=>c,onLoadingSlow:()=>c}),S=b==null?void 0:b.data;ua(()=>{!s&&!C&&S&&m(!0)},[S,s,C]);function v(w){return M(this,null,function*(){if(S&&!p){let k=S.find(I=>I.flowId===w);k&&k.flowState!==re&&(k.flowState=re),yield x(Promise.resolve(Ce(b,{data:S})),{optimisticData:Ce(b,{data:S}),revalidate:!1,rollbackOnError:!1})}})}function $(w,k,I){return M(this,null,function*(){if(S){let N=S.find(A=>A.flowId===w);N&&(N.stepStates[k]=I,N.flowState=vt),yield x(Promise.resolve(Ce(b,{data:S})),{optimisticData:Ce(b,{data:S}),revalidate:!1,rollbackOnError:!1})}})}function B(w,k,I){return M(this,null,function*(){if(S){let N=S.find(A=>A.flowId===w);N&&(N.lastStepId=k,N.stepStates[k]=I,N.flowState=vt),yield x(Ce(b,{data:S}),{optimisticData:Ce(b,{data:S}),revalidate:!1,rollbackOnError:!1})}})}function u(w){return M(this,null,function*(){if(S){let k=S.find(I=>I.flowId===w);k&&k.flowState!==Me&&(k.flowState=Me,k.lastStepId=xa,Object.keys(k.stepStates).forEach(I=>{k.stepStates[I].actionType=nt,k.stepStates[I].createdAt=new Date().toISOString()}),yield x(Ce(b,{data:S}),{optimisticData:Ce(b,{data:S}),revalidate:!1,rollbackOnError:!1}),d(w))}})}function O(w,k,I){return M(this,null,function*(){if(S){let N=S.find(A=>A.flowId===w);N&&(N.stepStates[k]=I),yield x(Promise.resolve(Ce(b,{data:S})),{optimisticData:Ce(b,{data:S}),revalidate:!1,rollbackOnError:!1})}})}return{userFlowStatesData:S,isLoadingUserFlowStateData:!s,mutateUserFlowState:x,optimisticallyMarkFlowCompleted:v,optimisticallyMarkFlowNotStarted:u,optimisticallyMarkStepCompleted:$,optimisticallyMarkStepNotStarted:O,optimisticallyMarkStepStarted:B,error:P}}function xo(){let{config:e,apiUrl:t}=Ze(),{userFlowStatesData:o,mutateUserFlowState:i}=De(),{failedFlowResponses:n,setFailedFlowResponses:r,flowResponses:l,setFlowResponses:p}=Ca(Q),[d,s]=mi(new Set),[m,c]=mi(new Set),g=jt();function y(x){let P=JSON.stringify(x);if(d.has(P))return null;d.add(P),s(d),m.add(x),c(m);let S=l==null?void 0:l.find(v=>v.flowSlug===x.flowSlug&&v.stepId===x.stepId&&v.actionType===x.actionType&&v.createdAt===x.createdAt);return g(`${t}flowResponses`,j(T({},e),{method:"POST",body:P})).then(v=>{v.status!==200&&v.status!==201?(console.log("Failed to send flow response for step "+x.stepId+". Will retry again later."),r([...n,x])):S||p($=>[...$!=null?$:[],x])})}function b(x){return M(this,null,function*(){x.foreignUserId&&(x.actionType===vt||x.actionType===Me?yield y(x):x.actionType===re?yield y(x):x.actionType===go?yield y(x):x.actionType===Le?yield y(x):x.actionType===Mo?yield y(x):x.actionType===nt&&(yield y(x)))})}function C(){let x=[];return o==null||o.forEach(P=>{if(P&&P.stepStates&&Object.keys(P.stepStates).length!==0)for(let S in P.stepStates){let v=P.stepStates[S];x.push({foreignUserId:P.foreignUserId,flowSlug:P.flowId,stepId:v.stepId,actionType:v.actionType,data:{},createdAt:new Date(v.createdAt),blocked:v.blocked,hidden:v.hidden})}}),[...x,...l]}return{addResponse:b,setFlowResponses:p,getFlowResponses:C}}import Ta from"swr";var ya=/user.flow\(([^\)]+)\) == '?COMPLETED_FLOW'?/gm,ui=e=>{let t=ya.exec(e);if(t===null)return null;let o=null;return t.forEach((i,n)=>{let r=Sa(i,"'","");r.startsWith("flow_")&&(o=r)}),o},Sa=function(e,t,o){return e.replace(new RegExp(t,"g"),o)};function Do(e){try{return JSON.parse(e)}catch(t){return console.error("Failed to parse Frigade config.yml to JSON",t),null}}var xr=(s=>(s.CHECKLIST="CHECKLIST",s.FORM="FORM",s.TOUR="TOUR",s.SUPPORT="SUPPORT",s.CUSTOM="CUSTOM",s.BANNER="BANNER",s.EMBEDDED_TIP="EMBEDDED_TIP",s.NPS_SURVEY="NPS_SURVEY",s.ANNOUNCEMENT="ANNOUNCEMENT",s))(xr||{});function R(){let{config:e,apiUrl:t}=Ze(),{flows:o,setFlows:i,userId:n,organizationId:r,publicApiKey:l,customVariables:p,setCustomVariables:d,hasActiveFullPageFlow:s,setHasActiveFullPageFlow:m,setFlowResponses:c,setShouldGracefullyDegrade:g,shouldGracefullyDegrade:y,readonly:b,flowDataOverrides:C}=ba(Q),x={data:[]},{verifySDKInitiated:P}=Gt(),{addResponse:S,getFlowResponses:v}=xo(),$=h=>fetch(h,e).then(f=>f.ok?f.json():(console.log(`Error fetching ${h} (${f.status}): ${f.statusText}. Will gracefully degrade and hide Frigade`),g(!0),x)).catch(f=>(console.log(`Error fetching ${h}: ${f}. Will gracefully degrade and hide Frigade`),g(!0),x)),{mutateUserFlowState:B,userFlowStatesData:u,isLoadingUserFlowStateData:O,optimisticallyMarkFlowCompleted:w,optimisticallyMarkFlowNotStarted:k,optimisticallyMarkStepCompleted:I,optimisticallyMarkStepNotStarted:N,optimisticallyMarkStepStarted:A}=De(),{data:H,error:_,isLoading:ee}=Ta(l?`${t}flows${b?"?readonly=true":""}`:null,$,{keepPreviousData:!0});wa(()=>{if(_){console.error(_);return}H&&H.data&&i(H.data)},[H,_]);function X(h){if(ee)return null;let f=o.find(F=>F.slug===h);return!f&&o.length>0&&!O&&!ee?(console.log(`Flow with id ${h} not found`),null):(f&&C&&C[h]&&(f.data=C[h]),(f==null?void 0:f.active)===!1&&!b?null:f)}function q(h){var U,fe,ht,kt,Pt;if(!X(h))return[];let f=(U=X(h))==null?void 0:U.data;return f?(f=Y(f),((Pt=(kt=(fe=Do(f))==null?void 0:fe.data)!=null?kt:(ht=Do(f))==null?void 0:ht.steps)!=null?Pt:[]).map(ge=>{let uo=je(ge);return j(T({handleSecondaryButtonClick:()=>{ge.skippable===!0&&Z(h,ge.id,{skipped:!0})}},ge),{complete:ce(h,ge.id)===Le||uo>=1,started:ce(h,ge.id)===go||ce(h,ge.id)===Le,currentlyActive:u==null?void 0:u.some(fo=>fo.flowId==h&&fo.lastStepId===ge.id),blocked:V(h,ge.id),hidden:W(h,ge.id),handlePrimaryButtonClick:()=>{(!ge.completionCriteria&&(ge.autoMarkCompleted||ge.autoMarkCompleted===void 0)||ge.completionCriteria&&ge.autoMarkCompleted===!0)&&Z(h,ge.id)},progress:uo})}).filter(ge=>ge.hidden!==!0)):[]}function Y(h){return h.replaceAll(/\${(.*?)}/g,(f,F)=>p[F]===void 0?"":String(p[F]).replace(/[\u00A0-\u9999<>\&]/g,function(U){return"&#"+U.charCodeAt(0)+";"}).replaceAll(/[\\]/g,"\\\\").replaceAll(/[\"]/g,'\\"').replaceAll(/[\/]/g,"\\/").replaceAll(/[\b]/g,"\\b").replaceAll(/[\f]/g,"\\f").replaceAll(/[\n]/g,"\\n").replaceAll(/[\r]/g,"\\r").replaceAll(/[\t]/g,"\\t"))}function J(h){var F;if(!X(h))return[];let f=X(h).data;return f?(f=Y(f),(F=JSON.parse(f))!=null?F:{}):[]}function pe(h,f){d(F=>j(T({},F),{[h]:f}))}function we(h){!O&&!ee&&h&&JSON.stringify(p)!=JSON.stringify(T(T({},p),h))&&Object.keys(h).forEach(f=>{pe(f,h[f])})}let Oe=Bt((h,f,F)=>M(this,null,function*(){if(!P())return;let U={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:f,actionType:go,data:F!=null?F:{},createdAt:new Date,blocked:!1,hidden:!1};xe(U)&&(yield A(h,f,U),S(U))}),[n,r,u]),de=Bt((h,f,F)=>M(this,null,function*(){if(!P())return;let U={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:f,actionType:nt,data:F!=null?F:{},createdAt:new Date,blocked:!1,hidden:!1};xe(U)&&(yield N(h,f,U),S(U))}),[n,r,u]),Z=Bt((h,f,F)=>M(this,null,function*(){if(!P())return;let U={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:f,actionType:Le,data:F!=null?F:{},createdAt:new Date,blocked:!1,hidden:!1};xe(U)&&(yield I(h,f,U),S(U))}),[n,r,u]),D=Bt((h,f)=>M(this,null,function*(){if(!P()||Xe(h)===Me)return;let F={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:"unknown",actionType:Me,data:f!=null?f:{},createdAt:new Date,blocked:!1,hidden:!1};yield k(h),xe(F)&&S(F)}),[n,r,u]),oe=Bt((h,f)=>M(this,null,function*(){if(!P())return;let F={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:"unknown",actionType:vt,data:f!=null?f:{},createdAt:new Date,blocked:!1,hidden:!1};xe(F)&&S(F)}),[n,r,u]),Ne=Bt((h,f)=>M(this,null,function*(){if(!P())return;let F={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:"unknown",actionType:re,data:f!=null?f:{},createdAt:new Date,blocked:!1,hidden:!1};xe(F)&&(yield w(h),S(F))}),[n,r,u]),Je=Bt((h,f)=>M(this,null,function*(){if(!P())return;let F={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:"unknown",actionType:Mo,data:f!=null?f:{},createdAt:new Date,blocked:!1,hidden:!1};xe(F)&&(yield w(h),S(F))}),[n,r,u]);function xe(h){var f;if(u===void 0)return!1;if(u){let F=u.find(U=>U.flowId===h.flowSlug);if(h.actionType===nt&&(!(F!=null&&F.stepStates[h.stepId])||F.stepStates[h.stepId].actionType===nt))return!1;if(F&&((f=F.stepStates[h.stepId])==null?void 0:f.actionType)===h.actionType){if(h.actionType===Le&&(!h.data||JSON.stringify(h.data)===JSON.stringify({})))return!1;let U=Object.keys(F.stepStates).sort((fe,ht)=>{let kt=new Date(F.stepStates[fe].createdAt),Pt=new Date(F.stepStates[ht].createdAt);return kt.getTime()-Pt.getTime()});if(F.stepStates[U[U.length-1]].actionType===h.actionType&&h.stepId===U[U.length-1])return!1}if(F&&F.flowState===re&&h.actionType===re)return!1}return!0}function ce(h,f){let F=L(h,f);return O?null:F?F.actionType:nt}function V(h,f){let F=L(h,f);return F?F.blocked:!1}function W(h,f){let F=L(h,f);return F?F.hidden:!1}function L(h,f){var U;if(O)return null;let F=u==null?void 0:u.find(fe=>fe.flowId===h);return!F||!F.stepStates[f]?null:(U=F.stepStates[f])!=null?U:null}function z(h){var F,U;if(O||!u)return null;if(Xe(h)===Me)return(F=q(h)[0])!=null?F:null;let f=(U=u.find(fe=>fe.flowId===h))==null?void 0:U.lastStepId;return f?q(h).find(fe=>fe.id===f):null}function me(h){var U;let f=z(h);if(!f)return 0;let F=(U=q(h).findIndex(fe=>fe.id===f.id))!=null?U:0;return ce(h,f.id)===Le&&F<q(h).length-1?F+1:F}function je(h){if(!h.completionCriteria)return;let f=ui(h.completionCriteria);if(f===null)return;let F=Ft(f),U=Ge(f);return U===0?void 0:F/U}function Xe(h){let f=u==null?void 0:u.find(F=>F.flowId===h);return f?f.flowState:null}function Ft(h){let f=q(h);return f.length===0?0:f.filter(U=>ce(h,U.id)===Le).length}function Ge(h){return q(h).length}function gt(h){let f=o.find(F=>F.slug===h);return f?(C&&C[h]&&(f.data=C[h]),Do(f.data)):null}function Ke(h){if(b)return!1;if(O||y)return!0;if(h!=null&&h.targetingLogic&&u){let f=u.find(F=>F.flowId===h.slug);if(f)return f.shouldTrigger===!1}return!!(h!=null&&h.targetingLogic&&n&&n.startsWith("guest_"))}function Wt(h){return!Ke(X(h))}function zt(){n&&B()}function Ht(){return o}return{getAllFlows:Ht,getFlow:X,getFlowData:gt,isLoading:O||ee,getStepStatus:ce,getFlowSteps:q,getCurrentStepIndex:me,markStepStarted:Oe,markStepCompleted:Z,markFlowNotStarted:D,markFlowStarted:oe,markFlowCompleted:Ne,markFlowAborted:Je,markStepNotStarted:de,getFlowStatus:Xe,getNumberOfStepsCompleted:Ft,getNumberOfSteps:Ge,targetingLogicShouldHideFlow:Ke,setCustomVariable:pe,updateCustomVariables:we,customVariables:p,getStepOptionalProgress:je,getFlowMetadata:J,isStepBlocked:V,isStepHidden:W,hasActiveFullPageFlow:s,setHasActiveFullPageFlow:m,isFlowAvailableToUser:Wt,refresh:zt}}import{useCallback as Cr,useContext as Fa,useEffect as ka}from"react";var Kt="guest_";function Co(){let{userId:e,organizationId:t,setUserId:o,setUserProperties:i,shouldGracefullyDegrade:n}=Fa(Q),{config:r,apiUrl:l}=Ze(),{mutateUserFlowState:p}=De(),d=jt(),{verifySDKInitiated:s}=Gt();function m(b){return`frigade-user-registered-${b}`}ka(()=>{if(e&&!t){if(e.startsWith(Kt))return;let b=m(e);localStorage.getItem(b)||(d(`${l}users`,j(T({},r),{method:"POST",body:JSON.stringify({foreignId:e})})),localStorage.setItem(b,"true"))}},[e,n,t]);let c=Cr(b=>M(this,null,function*(){if(!s())return;let C={foreignId:e,properties:b};yield d(`${l}users`,j(T({},r),{method:"POST",body:JSON.stringify(C)})),i(x=>T(T({},x),b)),p()}),[e,r,n,p]),g=Cr((b,C)=>M(this,null,function*(){if(!s())return;let P={foreignId:e,events:[{event:b,properties:C}]};yield d(`${l}users`,j(T({},r),{method:"POST",body:JSON.stringify(P)})),p()}),[e,r,p]),y=Cr((b,C)=>M(this,null,function*(){if(s())if(C){let x=m(b);localStorage.setItem(x,"true"),o(b);let P={foreignId:b,properties:C};yield d(`${l}users`,j(T({},r),{method:"POST",body:JSON.stringify(P)})),i(S=>T(T({},S),C)),p()}else o(b)}),[r,n,p]);return{userId:e,setUserId:o,setUserIdWithProperties:y,addPropertiesToUser:c,trackEventForUser:g}}import{v4 as ed}from"uuid";import ot,{useEffect as xn,useState as Xp}from"react";import qe,{useEffect as wr,useState as La}from"react";import zo from"styled-components";import Pa from"react";import va from"styled-components";var fi="fr-",yo="cfr-";function a(e,t){let o=`${fi}${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+" "+yo+e}return o}function E(e){if(!e.className||e.className.indexOf(yo)!==-1)return"";let o=e.className.replace(/\s+/g," ").split(" ");return o.length==1&&o[0].startsWith(fi)?"":`:not(${o.map(i=>`.${i}`).join(", ")})`}function Uo(e){return e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}function ke(e){return e!=null&&e.styleOverrides?Object.keys(e.styleOverrides).map(t=>`${Uo(t)}: ${e.styleOverrides[t]};`).join(" "):""}function Te(...e){return e.filter(Boolean).join(" ")}function So(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ba=va.div`
|
|
2
|
+
var sa=Object.defineProperty,la=Object.defineProperties;var aa=Object.getOwnPropertyDescriptors;var $o=Object.getOwnPropertySymbols;var li=Object.prototype.hasOwnProperty,ai=Object.prototype.propertyIsEnumerable;var si=(e,t,o)=>t in e?sa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,T=(e,t)=>{for(var o in t||(t={}))li.call(t,o)&&si(e,o,t[o]);if($o)for(var o of $o(t))ai.call(t,o)&&si(e,o,t[o]);return e},j=(e,t)=>la(e,aa(t));var pi=e=>typeof e=="symbol"?e:e+"",Ie=(e,t)=>{var o={};for(var i in e)li.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&$o)for(var i of $o(e))t.indexOf(i)<0&&ai.call(e,i)&&(o[i]=e[i]);return o};var M=(e,t,o)=>new Promise((i,n)=>{var r=d=>{try{p(o.next(d))}catch(s){n(s)}},l=d=>{try{p(o.throw(d))}catch(s){n(s)}},p=d=>d.done?i(d.value):Promise.resolve(d.value).then(r,l);p((o=o.apply(e,t)).next())});import Eo,{createContext as Fd,useEffect as or,useState as Ve}from"react";import{ThemeProvider as An}from"styled-components";import Nt,{useContext as Rp,useEffect as Rt,useState as ko}from"react";import{useCallback as Bt,useContext as ba,useEffect as wa}from"react";import gr,{useMemo as ci}from"react";var di="1.37.15";var nt="NOT_STARTED_STEP",re="COMPLETED_FLOW",Mo="ABORTED_FLOW",vt="STARTED_FLOW",Me="NOT_STARTED_FLOW",Le="COMPLETED_STEP",go="STARTED_STEP";function Ze(){let{publicApiKey:e,userId:t,apiUrl:o}=gr.useContext(Q);return{config:ci(()=>({headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-Frigade-SDK-Version":di,"X-Frigade-SDK-Platform":"React"}}),[e,t]),apiUrl:ci(()=>`${o}/v1/public/`,[o])}}var pa="frigade-last-call-at-",da="frigade-last-call-data-";function jt(){let{shouldGracefullyDegrade:e,readonly:t}=gr.useContext(Q);return(o,i)=>M(this,null,function*(){if(t&&(i.method==="POST"||i.method==="PUT"||i.method==="DELETE"))return Vt();if(e)return console.log(`Skipping ${o} call to Frigade due to error`),Vt();let n=pa+o,r=da+o;if(typeof window!="undefined"&&window.localStorage&&i&&i.body&&i.method==="POST"){let p=window.localStorage.getItem(n),d=window.localStorage.getItem(r);if(p&&d&&d==i.body){let s=new Date(p);if(new Date().getTime()-s.getTime()<1e3)return Vt()}typeof window!="undefined"&&(window.localStorage.setItem(n,new Date().toISOString()),window.localStorage.setItem(r,i.body))}let l;try{l=yield fetch(o,i)}catch(p){return Vt(p)}return l?l.ok?l:Vt(l.statusText):Vt()})}function Vt(e){return e&&console.log("Call to Frigade failed",e),{json:()=>({})}}function Gt(){let{publicApiKey:e,shouldGracefullyDegrade:t}=gr.useContext(Q);function o(){return t?!1:e?!0:(console.error("Frigade hooks cannot be used outside the scope of FrigadeProvider"),!1)}return{verifySDKInitiated:o}}import{useContext as Ca,useState as mi}from"react";import{useContext as ma,useEffect as ua,useState as fa}from"react";import ga from"swr";import{useContext as ca}from"react";function Be(){let{openFlowStates:e,setOpenFlowStates:t,hasActiveFullPageFlow:o,setCompletedFlowsToKeepOpenDuringSession:i,completedFlowsToKeepOpenDuringSession:n}=ca(Q);function r(c,g=!1){var y;return(y=e[c])!=null?y:g}function l(c,g){t(y=>j(T({},y),{[c]:g}))}function p(c){t(g=>{let C=g,{[c]:y}=C,b=Ie(C,[pi(c)]);return T({},b)})}function d(c){n.includes(c)||i(g=>[...g,c])}function s(c){return n.includes(c)}function m(c){return Object.entries(e).some(([g,y])=>y&&g!=c)||o}return{getOpenFlowState:r,setOpenFlowState:l,resetOpenFlowState:p,hasOpenModals:m,setKeepCompletedFlowOpenDuringSession:d,shouldKeepCompletedFlowOpenDuringSession:s}}import ha from"swr/immutable";import ho from"core-js-pure/actual/structured-clone";function hr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ce(...e){let t=e.shift(),o=e.length===1?e[0]:Ce(...e);if(!hr(t)||!hr(o))throw new Error("deepmerge can only merge Objects");let i=ho(t);return Object.entries(o).forEach(([n,r])=>{hr(r)?i[n]!==void 0?Object.assign(i,{[n]:Ce(i[n],ho(r))}):Object.assign(i,{[n]:ho(r)}):Array.isArray(r)?i[n]!==void 0?Object.assign(i,{[n]:[...i[n],...ho(r)]}):Object.assign(i,{[n]:ho(r)}):Object.assign(i,{[n]:r})}),i}var xa="unknown";function De(){let{config:e,apiUrl:t}=Ze(),{publicApiKey:o,userId:i,organizationId:n,flows:r,setShouldGracefullyDegrade:l,readonly:p}=ma(Q),{resetOpenFlowState:d}=Be(),[s,m]=fa(!1),c={data:r.map(w=>({flowId:w.id,flowState:re,lastStepId:null,userId:i,foreignUserId:i,stepStates:{},shouldTrigger:!1}))},g=w=>fetch(w,e).then(k=>{if(k.ok)return k.json();throw new Error("Failed to fetch user flow states")}).catch(k=>(console.log(`Error fetching ${w}: ${k}. Will gracefully degrade and hide Frigade`),l(!0),c)),y=o&&r&&i?`${t}userFlowStates?foreignUserId=${encodeURIComponent(i)}${n?`&foreignUserGroupId=${encodeURIComponent(n)}`:""}`:null,{data:b,isLoading:C,mutate:x,error:P}=p?ha(y,g):ga(y,g,{revalidateOnFocus:!0,revalidateIfStale:!0,keepPreviousData:!0,revalidateOnMount:!1,errorRetryInterval:1e4,errorRetryCount:3,onError:()=>c,onLoadingSlow:()=>c}),S=b==null?void 0:b.data;ua(()=>{!s&&!C&&S&&m(!0)},[S,s,C]);function v(w){return M(this,null,function*(){if(S&&!p){let k=S.find(I=>I.flowId===w);k&&k.flowState!==re&&(k.flowState=re),yield x(Promise.resolve(Ce(b,{data:S})),{optimisticData:Ce(b,{data:S}),revalidate:!1,rollbackOnError:!1})}})}function $(w,k,I){return M(this,null,function*(){if(S){let N=S.find(A=>A.flowId===w);N&&(N.stepStates[k]=I,N.flowState=vt),yield x(Promise.resolve(Ce(b,{data:S})),{optimisticData:Ce(b,{data:S}),revalidate:!1,rollbackOnError:!1})}})}function B(w,k,I){return M(this,null,function*(){if(S){let N=S.find(A=>A.flowId===w);N&&(N.lastStepId=k,N.stepStates[k]=I,N.flowState=vt),yield x(Ce(b,{data:S}),{optimisticData:Ce(b,{data:S}),revalidate:!1,rollbackOnError:!1})}})}function u(w){return M(this,null,function*(){if(S){let k=S.find(I=>I.flowId===w);k&&k.flowState!==Me&&(k.flowState=Me,k.lastStepId=xa,Object.keys(k.stepStates).forEach(I=>{k.stepStates[I].actionType=nt,k.stepStates[I].createdAt=new Date().toISOString()}),yield x(Ce(b,{data:S}),{optimisticData:Ce(b,{data:S}),revalidate:!1,rollbackOnError:!1}),d(w))}})}function O(w,k,I){return M(this,null,function*(){if(S){let N=S.find(A=>A.flowId===w);N&&(N.stepStates[k]=I),yield x(Promise.resolve(Ce(b,{data:S})),{optimisticData:Ce(b,{data:S}),revalidate:!1,rollbackOnError:!1})}})}return{userFlowStatesData:S,isLoadingUserFlowStateData:!s,mutateUserFlowState:x,optimisticallyMarkFlowCompleted:v,optimisticallyMarkFlowNotStarted:u,optimisticallyMarkStepCompleted:$,optimisticallyMarkStepNotStarted:O,optimisticallyMarkStepStarted:B,error:P}}function xo(){let{config:e,apiUrl:t}=Ze(),{userFlowStatesData:o,mutateUserFlowState:i}=De(),{failedFlowResponses:n,setFailedFlowResponses:r,flowResponses:l,setFlowResponses:p}=Ca(Q),[d,s]=mi(new Set),[m,c]=mi(new Set),g=jt();function y(x){let P=JSON.stringify(x);if(d.has(P))return null;d.add(P),s(d),m.add(x),c(m);let S=l==null?void 0:l.find(v=>v.flowSlug===x.flowSlug&&v.stepId===x.stepId&&v.actionType===x.actionType&&v.createdAt===x.createdAt);return g(`${t}flowResponses`,j(T({},e),{method:"POST",body:P})).then(v=>{v.status!==200&&v.status!==201?(console.log("Failed to send flow response for step "+x.stepId+". Will retry again later."),r([...n,x])):S||p($=>[...$!=null?$:[],x])})}function b(x){return M(this,null,function*(){x.foreignUserId&&(x.actionType===vt||x.actionType===Me?yield y(x):x.actionType===re?yield y(x):x.actionType===go?yield y(x):x.actionType===Le?yield y(x):x.actionType===Mo?yield y(x):x.actionType===nt&&(yield y(x)))})}function C(){let x=[];return o==null||o.forEach(P=>{if(P&&P.stepStates&&Object.keys(P.stepStates).length!==0)for(let S in P.stepStates){let v=P.stepStates[S];x.push({foreignUserId:P.foreignUserId,flowSlug:P.flowId,stepId:v.stepId,actionType:v.actionType,data:{},createdAt:new Date(v.createdAt),blocked:v.blocked,hidden:v.hidden})}}),[...x,...l]}return{addResponse:b,setFlowResponses:p,getFlowResponses:C}}import Ta from"swr";var ya=/user.flow\(([^\)]+)\) == '?COMPLETED_FLOW'?/gm,ui=e=>{let t=ya.exec(e);if(t===null)return null;let o=null;return t.forEach((i,n)=>{let r=Sa(i,"'","");r.startsWith("flow_")&&(o=r)}),o},Sa=function(e,t,o){return e.replace(new RegExp(t,"g"),o)};function Do(e){try{return JSON.parse(e)}catch(t){return console.error("Failed to parse Frigade config.yml to JSON",t),null}}var xr=(s=>(s.CHECKLIST="CHECKLIST",s.FORM="FORM",s.TOUR="TOUR",s.SUPPORT="SUPPORT",s.CUSTOM="CUSTOM",s.BANNER="BANNER",s.EMBEDDED_TIP="EMBEDDED_TIP",s.NPS_SURVEY="NPS_SURVEY",s.ANNOUNCEMENT="ANNOUNCEMENT",s))(xr||{});function R(){let{config:e,apiUrl:t}=Ze(),{flows:o,setFlows:i,userId:n,organizationId:r,publicApiKey:l,customVariables:p,setCustomVariables:d,hasActiveFullPageFlow:s,setHasActiveFullPageFlow:m,setFlowResponses:c,setShouldGracefullyDegrade:g,shouldGracefullyDegrade:y,readonly:b,flowDataOverrides:C}=ba(Q),x={data:[]},{verifySDKInitiated:P}=Gt(),{addResponse:S,getFlowResponses:v}=xo(),$=h=>fetch(h,e).then(f=>f.ok?f.json():(console.log(`Error fetching ${h} (${f.status}): ${f.statusText}. Will gracefully degrade and hide Frigade`),g(!0),x)).catch(f=>(console.log(`Error fetching ${h}: ${f}. Will gracefully degrade and hide Frigade`),g(!0),x)),{mutateUserFlowState:B,userFlowStatesData:u,isLoadingUserFlowStateData:O,optimisticallyMarkFlowCompleted:w,optimisticallyMarkFlowNotStarted:k,optimisticallyMarkStepCompleted:I,optimisticallyMarkStepNotStarted:N,optimisticallyMarkStepStarted:A}=De(),{data:H,error:_,isLoading:ee}=Ta(l?`${t}flows${b?"?readonly=true":""}`:null,$,{keepPreviousData:!0});wa(()=>{if(_){console.error(_);return}H&&H.data&&i(H.data)},[H,_]);function X(h){if(ee)return null;let f=o.find(F=>F.slug===h);return!f&&o.length>0&&!O&&!ee?(console.log(`Flow with id ${h} not found`),null):(f&&C&&C[h]&&(f.data=C[h]),(f==null?void 0:f.active)===!1&&!b?null:f)}function q(h){var U,fe,ht,kt,Pt;if(!X(h))return[];let f=(U=X(h))==null?void 0:U.data;return f?(f=J(f),((Pt=(kt=(fe=Do(f))==null?void 0:fe.data)!=null?kt:(ht=Do(f))==null?void 0:ht.steps)!=null?Pt:[]).map(ge=>{let uo=je(ge);return j(T({handleSecondaryButtonClick:()=>{ge.skippable===!0&&Z(h,ge.id,{skipped:!0})}},ge),{complete:ce(h,ge.id)===Le||uo>=1,started:ce(h,ge.id)===go||ce(h,ge.id)===Le,currentlyActive:u==null?void 0:u.some(fo=>fo.flowId==h&&fo.lastStepId===ge.id),blocked:V(h,ge.id),hidden:W(h,ge.id),handlePrimaryButtonClick:()=>{(!ge.completionCriteria&&(ge.autoMarkCompleted||ge.autoMarkCompleted===void 0)||ge.completionCriteria&&ge.autoMarkCompleted===!0)&&Z(h,ge.id)},progress:uo})}).filter(ge=>ge.hidden!==!0)):[]}function J(h){return h.replaceAll(/\${(.*?)}/g,(f,F)=>p[F]===void 0?"":String(p[F]).replace(/[\u00A0-\u9999<>\&]/g,function(U){return"&#"+U.charCodeAt(0)+";"}).replaceAll(/[\\]/g,"\\\\").replaceAll(/[\"]/g,'\\"').replaceAll(/[\/]/g,"\\/").replaceAll(/[\b]/g,"\\b").replaceAll(/[\f]/g,"\\f").replaceAll(/[\n]/g,"\\n").replaceAll(/[\r]/g,"\\r").replaceAll(/[\t]/g,"\\t"))}function Y(h){var F;if(!X(h))return[];let f=X(h).data;return f?(f=J(f),(F=JSON.parse(f))!=null?F:{}):[]}function pe(h,f){d(F=>j(T({},F),{[h]:f}))}function we(h){!O&&!ee&&h&&JSON.stringify(p)!=JSON.stringify(T(T({},p),h))&&Object.keys(h).forEach(f=>{pe(f,h[f])})}let Oe=Bt((h,f,F)=>M(this,null,function*(){if(!P())return;let U={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:f,actionType:go,data:F!=null?F:{},createdAt:new Date,blocked:!1,hidden:!1};xe(U)&&(yield A(h,f,U),S(U))}),[n,r,u]),de=Bt((h,f,F)=>M(this,null,function*(){if(!P())return;let U={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:f,actionType:nt,data:F!=null?F:{},createdAt:new Date,blocked:!1,hidden:!1};xe(U)&&(yield N(h,f,U),S(U))}),[n,r,u]),Z=Bt((h,f,F)=>M(this,null,function*(){if(!P())return;let U={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:f,actionType:Le,data:F!=null?F:{},createdAt:new Date,blocked:!1,hidden:!1};xe(U)&&(yield I(h,f,U),S(U))}),[n,r,u]),D=Bt((h,f)=>M(this,null,function*(){if(!P()||Xe(h)===Me)return;let F={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:"unknown",actionType:Me,data:f!=null?f:{},createdAt:new Date,blocked:!1,hidden:!1};yield k(h),xe(F)&&S(F)}),[n,r,u]),oe=Bt((h,f)=>M(this,null,function*(){if(!P())return;let F={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:"unknown",actionType:vt,data:f!=null?f:{},createdAt:new Date,blocked:!1,hidden:!1};xe(F)&&S(F)}),[n,r,u]),Ne=Bt((h,f)=>M(this,null,function*(){if(!P())return;let F={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:"unknown",actionType:re,data:f!=null?f:{},createdAt:new Date,blocked:!1,hidden:!1};xe(F)&&(yield w(h),S(F))}),[n,r,u]),Je=Bt((h,f)=>M(this,null,function*(){if(!P())return;let F={foreignUserId:n,foreignUserGroupId:r!=null?r:null,flowSlug:h,stepId:"unknown",actionType:Mo,data:f!=null?f:{},createdAt:new Date,blocked:!1,hidden:!1};xe(F)&&(yield w(h),S(F))}),[n,r,u]);function xe(h){var f;if(u===void 0)return!1;if(u){let F=u.find(U=>U.flowId===h.flowSlug);if(h.actionType===nt&&(!(F!=null&&F.stepStates[h.stepId])||F.stepStates[h.stepId].actionType===nt))return!1;if(F&&((f=F.stepStates[h.stepId])==null?void 0:f.actionType)===h.actionType){if(h.actionType===Le&&(!h.data||JSON.stringify(h.data)===JSON.stringify({})))return!1;let U=Object.keys(F.stepStates).sort((fe,ht)=>{let kt=new Date(F.stepStates[fe].createdAt),Pt=new Date(F.stepStates[ht].createdAt);return kt.getTime()-Pt.getTime()});if(F.stepStates[U[U.length-1]].actionType===h.actionType&&h.stepId===U[U.length-1])return!1}if(F&&F.flowState===re&&h.actionType===re)return!1}return!0}function ce(h,f){let F=L(h,f);return O?null:F?F.actionType:nt}function V(h,f){let F=L(h,f);return F?F.blocked:!1}function W(h,f){let F=L(h,f);return F?F.hidden:!1}function L(h,f){var U;if(O)return null;let F=u==null?void 0:u.find(fe=>fe.flowId===h);return!F||!F.stepStates[f]?null:(U=F.stepStates[f])!=null?U:null}function z(h){var F,U;if(O||!u)return null;if(Xe(h)===Me)return(F=q(h)[0])!=null?F:null;let f=(U=u.find(fe=>fe.flowId===h))==null?void 0:U.lastStepId;return f?q(h).find(fe=>fe.id===f):null}function me(h){var U;let f=z(h);if(!f)return 0;let F=(U=q(h).findIndex(fe=>fe.id===f.id))!=null?U:0;return ce(h,f.id)===Le&&F<q(h).length-1?F+1:F}function je(h){if(!h.completionCriteria)return;let f=ui(h.completionCriteria);if(f===null)return;let F=Ft(f),U=Ge(f);return U===0?void 0:F/U}function Xe(h){let f=u==null?void 0:u.find(F=>F.flowId===h);return f?f.flowState:null}function Ft(h){let f=q(h);return f.length===0?0:f.filter(U=>ce(h,U.id)===Le).length}function Ge(h){return q(h).length}function gt(h){let f=o.find(F=>F.slug===h);return f?(C&&C[h]&&(f.data=C[h]),Do(f.data)):null}function Ke(h){if(b)return!1;if(O||y)return!0;if(h!=null&&h.targetingLogic&&u){let f=u.find(F=>F.flowId===h.slug);if(f)return f.shouldTrigger===!1}return!!(h!=null&&h.targetingLogic&&n&&n.startsWith("guest_"))}function Wt(h){return!Ke(X(h))}function zt(){n&&B()}function Ht(){return o}return{getAllFlows:Ht,getFlow:X,getFlowData:gt,isLoading:O||ee,getStepStatus:ce,getFlowSteps:q,getCurrentStepIndex:me,markStepStarted:Oe,markStepCompleted:Z,markFlowNotStarted:D,markFlowStarted:oe,markFlowCompleted:Ne,markFlowAborted:Je,markStepNotStarted:de,getFlowStatus:Xe,getNumberOfStepsCompleted:Ft,getNumberOfSteps:Ge,targetingLogicShouldHideFlow:Ke,setCustomVariable:pe,updateCustomVariables:we,customVariables:p,getStepOptionalProgress:je,getFlowMetadata:Y,isStepBlocked:V,isStepHidden:W,hasActiveFullPageFlow:s,setHasActiveFullPageFlow:m,isFlowAvailableToUser:Wt,refresh:zt}}import{useCallback as Cr,useContext as Fa,useEffect as ka}from"react";var Kt="guest_";function Co(){let{userId:e,organizationId:t,setUserId:o,setUserProperties:i,shouldGracefullyDegrade:n}=Fa(Q),{config:r,apiUrl:l}=Ze(),{mutateUserFlowState:p}=De(),d=jt(),{verifySDKInitiated:s}=Gt();function m(b){return`frigade-user-registered-${b}`}ka(()=>{if(e&&!t){if(e.startsWith(Kt))return;let b=m(e);localStorage.getItem(b)||(d(`${l}users`,j(T({},r),{method:"POST",body:JSON.stringify({foreignId:e})})),localStorage.setItem(b,"true"))}},[e,n,t]);let c=Cr(b=>M(this,null,function*(){if(!s())return;let C={foreignId:e,properties:b};yield d(`${l}users`,j(T({},r),{method:"POST",body:JSON.stringify(C)})),i(x=>T(T({},x),b)),p()}),[e,r,n,p]),g=Cr((b,C)=>M(this,null,function*(){if(!s())return;let P={foreignId:e,events:[{event:b,properties:C}]};yield d(`${l}users`,j(T({},r),{method:"POST",body:JSON.stringify(P)})),p()}),[e,r,p]),y=Cr((b,C)=>M(this,null,function*(){if(s())if(C){let x=m(b);localStorage.setItem(x,"true"),o(b);let P={foreignId:b,properties:C};yield d(`${l}users`,j(T({},r),{method:"POST",body:JSON.stringify(P)})),i(S=>T(T({},S),C)),p()}else o(b)}),[r,n,p]);return{userId:e,setUserId:o,setUserIdWithProperties:y,addPropertiesToUser:c,trackEventForUser:g}}import{v4 as ed}from"uuid";import ot,{useEffect as xn,useState as Xp}from"react";import qe,{useEffect as wr,useState as La}from"react";import zo from"styled-components";import Pa from"react";import va from"styled-components";var fi="fr-",yo="cfr-";function a(e,t){let o=`${fi}${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+" "+yo+e}return o}function E(e){if(!e.className||e.className.indexOf(yo)!==-1)return"";let o=e.className.replace(/\s+/g," ").split(" ");return o.length==1&&o[0].startsWith(fi)?"":`:not(${o.map(i=>`.${i}`).join(", ")})`}function Uo(e){return e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}function ke(e){return e!=null&&e.styleOverrides?Object.keys(e.styleOverrides).map(t=>`${Uo(t)}: ${e.styleOverrides[t]};`).join(" "):""}function Te(...e){return e.filter(Boolean).join(" ")}function So(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ba=va.div`
|
|
3
3
|
display: flex;
|
|
4
4
|
justify-content: center;
|
|
5
5
|
position: fixed;
|
|
@@ -690,8 +690,8 @@ var sa=Object.defineProperty,la=Object.defineProperties;var aa=Object.getOwnProp
|
|
|
690
690
|
color: ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorText}};
|
|
691
691
|
display: flex;
|
|
692
692
|
align-self: center;
|
|
693
|
-
`;var gn=({stepData:e,setCanContinue:t,onSaveData:o,appearance:i})=>{let n=e.props,[r,l]=Ur([]),[p,d]=Ur(!1),[s,m]=Ur(e.id);return Dr(()=>{r.length==0&&!p&&(d(!0),o({choice:[]}))},[p]),Dr(()=>{s!==e.id&&(m(e.id),l([]))},[e]),Dr(()=>{o({choice:r}),r.length>=n.minChoices?t(!0):t(!1)},[r]),pt.createElement(ln,{className:a("selectListContainer",i)},pt.createElement(an,null,pt.createElement(pn,{className:a("selectListTitle",i)},e.title),pt.createElement(dn,{appearance:i,className:a("selectListSubtitle",i)},e.subtitle)),n.options.map((c,g)=>{let y=r.includes(c.id);return pt.createElement(cn,{key:`select-item-${g}`,onClick:()=>{if(r.includes(c.id)){l(r.filter(b=>b!==c.id));return}r.length<n.maxChoices?l([...r,c.id]):r.length==1&&n.maxChoices==1&&l([c.id])},hideBottomBorder:g===n.options.length-1,className:a("selectListSelectItem",i)},pt.createElement(mn,{className:a("selectListItemImage",i)},c.imageUri&&pt.createElement(un,{src:c.imageUri,alt:`select-icon-${g}`}),pt.createElement(fn,{appearance:i,className:a("selectListSelectItemText",i)},c.title)),pt.createElement(at,{appearance:i,value:y,primaryColor:i.theme.colorPrimary}))}))};import Ue,{useEffect as hn,useState as Zo}from"react";var Gp=({children:e,id:t,shouldWrap:o=!1})=>Ue.createElement(Ue.Fragment,null,o?Ue.createElement("div",{key:t,style:{width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:1,overflowY:"auto"}},e):e),Ro=({appearance:e,steps:t,selectedStep:o,customStepTypes:i,customVariables:n,onButtonClick:r,onStepCompletion:l,flowId:p,type:d,hideOnFlowCompletion:s,onComplete:m,setVisible:c,setShowModal:g,onDismiss:y,showPagination:b=!1,customFormElements:C,allowBackNavigation:x,validationHandler:P,onFormDataChange:S,showFooter:v,prefillData:$,updateUrlOnPageChange:B,repeatable:u})=>{var ce;let w=T(T({},{linkCollection:nn,multiInput:Ki,callToAction:sn,selectList:gn}),i),{primaryCTAClickSideEffects:k,secondaryCTAClickSideEffects:I}=ue(),[N,A]=Zo(!1),[H,_]=Zo({}),[ee,X]=Zo(!1),[q,
|
|
694
|
-
${e=>e.inlineStyles.map(([t,o])=>`.${yo}${t}.${yo}${t} { ${Object.entries(o).map(([i,n])=>typeof n=="object"?`${i} { ${Object.entries(n).map(([l,p])=>`${Uo(l)}: ${p};`).join(" ")} }`:`${Uo(i)}: ${n};`).join(" ")} }`).join(" ")}`;function ae({appearance:e}){if(!e||!e.styleOverrides)return Fo.createElement(Fo.Fragment,null);let t=Object.entries(e.styleOverrides).filter(([o,i])=>typeof i=="object");return t.length===0?Fo.createElement(Fo.Fragment,null):Fo.createElement(qp,{inlineStyles:t})}import{useEffect as Yp,useState as Jp}from"react";function He(e,t=!0){let[o,i]=Jp(!1),{markStepStarted:n,isLoading:r,getFlowStatus:l,getFlowSteps:p,getCurrentStepIndex:d,targetingLogicShouldHideFlow:s,getFlow:m}=R(),c=p(e);function g(){return M(this,null,function*(){!o&&!r&&l(e)===Me&&s(m(e))===!1&&t&&(i(!0),yield n(e,c[d(e)].id))})}return Yp(()=>{g()},[r,e,t]),{}}var Cn=({flowId:e,customStepTypes:t={},type:o="inline",visible:i,setVisible:n,customVariables:r,customFormElements:l,onComplete:p,appearance:d,hideOnFlowCompletion:s=!0,onStepCompletion:m,onButtonClick:c,dismissible:g=!0,endFlowOnDismiss:y=!1,modalPosition:b="center",repeatable:C=!1,onDismiss:x,showPagination:P=!1,allowBackNavigation:S=!1,validationHandler:v,showFrigadeBranding:$=!1,onFormDataChange:B,showFooter:u=!0,prefillData:O={},updateUrlOnPageChange:w=!1})=>{let{getFlow:k,getFlowSteps:I,isLoading:N,targetingLogicShouldHideFlow:A,getFlowStatus:H,getCurrentStepIndex:_,markFlowCompleted:ee,markFlowNotStarted:X,markStepStarted:q}=R(),Y=_(e),{mergeAppearanceWithDefault:J}=ie(),[pe,we]=Xp(null),{setOpenFlowState:Oe,getOpenFlowState:de,hasOpenModals:Z}=Be();He(e,i);let D=I(e);d=J(d);let[oe,Ne]=i!==void 0&&n!==void 0?[i,n]:[de(e,!0),V=>Oe(e,V)],Je=typeof window!="undefined"?window.location.hash:null;if(xn(()=>{var V;if(D&&D.length>0&&S){let W=typeof window!="undefined"&&((V=window==null?void 0:window.location)!=null&&V.hash)?window.location.hash.replace("#",""):"";if(D&&(D==null?void 0:D.length)>0){let L=-1;if(W){let z=W;L=D.findIndex(me=>me.id===z),pe===W&&(L=-1)}L!==-1&&(we(W),q(e,D[L].id))}}},[Je]),xn(()=>{!N&&D&&D.length&&typeof window!="undefined"&&S&&(we(D[Y].id),window.location.hash=D[Y].id)},[N,Y,D]),N)return null;let xe=k(e);if(!xe||A(xe)||!D||i!==void 0&&i===!1||H(e)===re&&s&&!C||(o=="modal"||o=="corner-modal")&&Z(e))return null;let ce=()=>{Ne(!1),x&&x(),y===!0&&ee(e)};if(b=="center"&&o==="modal"||o==="large-modal"){let V={padding:"24px"};return o==="large-modal"?(V.width="85%",V.height="90%",V.maxHeight="800px",V.minHeight="500px",V.padding="0"):V.width="400px",ot.createElement(Re,{appearance:d,onClose:ce,visible:oe,style:V,dismissible:g,showFrigadeBranding:$},ot.createElement(ae,{appearance:d}),ot.createElement(Ro,{appearance:d,steps:D,selectedStep:Y,customStepTypes:t,customVariables:r,onButtonClick:c,onStepCompletion:m,flowId:e,type:o,hideOnFlowCompletion:s,onComplete:p,setVisible:n,setShowModal:Ne,onDismiss:x,showPagination:P,customFormElements:l,allowBackNavigation:S,validationHandler:v,onFormDataChange:B,showFooter:u,prefillData:O,updateUrlOnPageChange:w,repeatable:C}))}return o==="modal"&&b!=="center"?ot.createElement(Vo,{appearance:d,onClose:ce,visible:oe,modalPosition:b},ot.createElement(ae,{appearance:d}),ot.createElement(Ro,{appearance:d,steps:D,selectedStep:Y,customStepTypes:t,customVariables:r,onButtonClick:c,onStepCompletion:m,flowId:e,type:o,hideOnFlowCompletion:s,onComplete:p,setVisible:n,setShowModal:Ne,onDismiss:x,showPagination:P,customFormElements:l,allowBackNavigation:S,validationHandler:v,onFormDataChange:B,showFooter:u,prefillData:O,updateUrlOnPageChange:w,repeatable:C})):ot.createElement(ot.Fragment,null,ot.createElement(ae,{appearance:d}),ot.createElement(Ro,{appearance:d,steps:D,selectedStep:Y,customStepTypes:t,customVariables:r,onButtonClick:c,onStepCompletion:m,flowId:e,type:o,hideOnFlowCompletion:s,onComplete:p,setVisible:n,setShowModal:Ne,onDismiss:x,showPagination:P,customFormElements:l,allowBackNavigation:S,validationHandler:v,onFormDataChange:B,showFooter:u,prefillData:O,updateUrlOnPageChange:w,repeatable:C}))},yn=Cn;import{useCallback as _r,useContext as Qp,useEffect as Zp}from"react";function Wr(){let{organizationId:e,userId:t,setOrganizationId:o}=Qp(Q),{mutateUserFlowState:i}=De(),{config:n,apiUrl:r}=Ze(),l=jt(),{verifySDKInitiated:p}=Gt();function d(g,y){return`frigade-user-group-registered-${g}-${y}`}Zp(()=>{if(t&&e){if(t.startsWith(Kt))return;let g=d(t,e);localStorage.getItem(g)||(l(`${r}userGroups`,j(T({},n),{method:"POST",body:JSON.stringify({foreignUserId:t,foreignUserGroupId:e})})),localStorage.setItem(g,"true"))}},[t,e]);let s=_r(g=>M(this,null,function*(){if(!p())return;if(!e||!t){console.error("Cannot add properties to organization: Organization ID and User ID must both be set.",{organizationIdInternal:e,userId:t});return}let y={foreignUserId:t,foreignUserGroupId:e,properties:g};yield l(`${r}userGroups`,j(T({},n),{method:"POST",body:JSON.stringify(y)})),i()}),[e,t,n,i]),m=_r((g,y)=>M(this,null,function*(){if(!p())return;if(!e||!t){console.error("Cannot track event for organization: Organization ID and User ID must both be set.",{organizationIdInternal:e,userId:t});return}let C={foreignUserId:t,foreignUserGroupId:e,events:[{event:g,properties:y}]};yield l(`${r}userGroups`,j(T({},n),{method:"POST",body:JSON.stringify(C)})),i()}),[e,t,n,i]),c=_r((g,y)=>M(this,null,function*(){if(p())if(y){let b=d(t,g);localStorage.setItem(b,"true"),o(g);let C={foreignUserId:t,foreignUserGroupId:g,properties:y};yield l(`${r}userGroups`,j(T({},n),{method:"POST",body:JSON.stringify(C)})),i()}else o(g)}),[t,n,i]);return{organizationId:e,setOrganizationId:o,setOrganizationIdWithProperties:c,addPropertiesToOrganization:s,trackEventForOrganization:m}}var Sn="frigade-xFrigade_guestUserId",Po="frigade-xFrigade_userId",bn=({})=>{let{setFlowResponses:e}=xo(),{userFlowStatesData:t,isLoadingUserFlowStateData:o,mutateUserFlowState:i}=De(),{userId:n,setUserId:r}=Co(),[l,p]=ko(n),{getFlowStatus:d}=R(),{flows:s,userProperties:m,setIsNewGuestUser:c,flowResponses:g}=Rp(Q),[y,b]=ko([]),[C,x]=ko([]),{organizationId:P}=Wr(),[S,v]=ko(P),[$,B]=ko(!1);Rt(()=>{if(!o&&t)for(let k=0;k<t.length;k++){let I=t[k],N=s.find(A=>A.slug===(I==null?void 0:I.flowId));if(N&&I&&I.shouldTrigger===!0&&N.type=="FORM"&&N.triggerType==="AUTOMATIC"&&!C.includes(N.slug)){setTimeout(()=>{u(I.flowId)},500);break}}},[o,t]),Rt(()=>{g.length>0&&i()},[g]),Rt(()=>{$||(B(!0),i())},[o,B]);function u(k){let I=s.find(N=>N.slug===k);I&&I.triggerType==="AUTOMATIC"&&!C.includes(I.slug)&&(x([...C,I.slug]),b([I]))}function O(){if(!n){let k=localStorage.getItem(Po);if(k){r(k);return}let I=localStorage.getItem(Sn);if(I){r(I);return}c(!0);let N=Kt+ed();try{localStorage.setItem(Sn,N)}catch(A){console.log("Failed to save guest user id locally: Local storage unavailable",A)}r(A=>A||N)}}Rt(()=>{try{if(s){let k=[];s.forEach(I=>{if(I.data){let N=I.data.match(/"imageUri":"(.*?)"/g);N&&N.forEach(A=>{let H=A.replace('"imageUri":"',"").replace('"',"");if(k.includes(H))return;let _=new Image;_.src=H,k.push(H)})}})}}catch(k){}},[s]),Rt(()=>{if(n!==l&&(e([]),i()),p(n),n&&!n.startsWith(Kt))try{localStorage.setItem(Po,n)}catch(k){console.log("Failed to save user id locally: Local storage available",k)}n===null&&setTimeout(()=>{n===null&&O()},50)},[n,s,m]),Rt(()=>{P!=S&&(v(P),e([]),i())},[P,S,v]);function w(){return Nt.createElement(Nt.Fragment,null,y.map(k=>d(k.slug)!==Me?null:Nt.createElement("span",{key:k.slug},Nt.createElement(yn,{flowId:k.slug,type:"modal",modalPosition:"center",endFlowOnDismiss:!0}))))}return Nt.createElement(Nt.Fragment,null,Nt.createElement(w,null))};var wn={colorPrimary:"colors.primary.background",colorText:"colors.neutral.foreground",colorBackground:"colors.neutral.background",colorBackgroundSecondary:"colors.secondary.background",colorTextOnPrimaryBackground:"colors.primary.foreground",colorTextSecondary:"colors.secondary.foreground",colorTextDisabled:"colors.gray700",colorBorder:"colors.gray800",colorTextError:"colors.negative.foreground",borderRadius:"radii.lg"};function td(e){if(!e)return;let t={};return Object.entries(e).forEach(([o,i])=>{if(wn[o]){let n=wn[o].split("."),r=t;n.forEach((l,p)=>{r[l]||(r[l]=p===n.length-1?i:{}),r=r[l]})}}),t}function od(e){if(!e)return;let t=Ce({},e),o={};return Object.keys(t).forEach(i=>{let n=`.fr-${i}`;o[n]=t[i]}),o}function Tn(e){let{theme:t,styleOverrides:o}=e,i=td(t),n=od(o);return{overrides:i,css:n}}import hd from"styled-components";import{compose as xd,variant as kn}from"styled-system";import Fn from"react";import rd,{ThemeProvider as id,useTheme as nd}from"styled-components";import{border as sd,color as ld,compose as ad,get as pd,shadow as dd,space as cd,system as md,typography as ud}from"styled-system";var fd={width:{property:"width",scale:"sizes",transform:(e,t)=>pd(t,e,!(typeof e=="number"&&!isNaN(e))||e>1?e:e*100+"%")},height:{property:"height",scale:"sizes"},minWidth:{property:"minWidth",scale:"sizes"},minHeight:{property:"minHeight",scale:"sizes"},maxWidth:{property:"maxWidth",scale:"sizes"},maxHeight:{property:"maxHeight",scale:"sizes"},overflow:!0,overflowX:!0,overflowY:!0,display:!0,verticalAlign:!0},gd=rd("div")(({css:e})=>e,ad(sd,ld,dd,cd,ud,md(fd))),vo=n=>{var r=n,{as:e,children:t,overrides:o}=r,i=Ie(r,["as","children","overrides"]);let l=nd(),p={border:"none",boxSizing:"border-box",m:0,p:0},d=()=>Fn.createElement(gd,T(T({as:e},p),i),t);if(o!==void 0){let s=Ce(l,o);return Fn.createElement(id,{theme:s},d())}return d()};var Bo={Primary:{backgroundColor:"primary.background",color:"primary.foreground","&:hover":{backgroundColor:"blue400"}},Secondary:{backgroundColor:"white",border:"1px solid",borderColor:"gray800",color:"neutral.foreground","&:hover":{backgroundColor:"blue900"}},Link:{backgroundColor:"transparent",color:"primary.inverted"},Plain:{backgroundColor:"transparent",color:"neutral.foreground"}},Cd={sm:{paddingX:4,paddingY:1},md:{paddingX:6,paddingY:2}},Pn=hd(vo)(()=>({whiteSpace:"nowrap"}),xd(kn({scale:"components.Button",variants:"components.Button"}),kn({prop:"size",variants:Cd})));import yd from"styled-components";import{variant as Sd,system as bd}from"styled-system";var er={Display1:{fontSize:"5xl",fontWeight:"bold",letterSpacing:"md",lineHeight:"4xl"},Display2:{fontSize:"4xl",fontWeight:"bold",letterSpacing:"md",lineHeight:"3xl"},H1:{fontSize:"3xl",fontWeight:"bold",letterSpacing:"md",lineHeight:"2xl"},H2:{fontSize:"2xl",fontWeight:"bold",letterSpacing:"md",lineHeight:"xl"},H3:{fontSize:"xl",fontWeight:"bold",letterSpacing:"md",lineHeight:"lg"},H4:{fontSize:"lg",fontWeight:"bold",letterSpacing:"md",lineHeight:"md"},Body1:{fontSize:"md",fontWeight:"regular",letterSpacing:"md",lineHeight:"md"},Body2:{fontSize:"sm",fontWeight:"regular",letterSpacing:"md",lineHeight:"md"},Caption:{fontSize:"xs",fontWeight:"regular",letterSpacing:"md",lineHeight:"sm"}};var vn=yd(vo)(Sd({scale:"components.Text",variants:"components.Text"}),bd({fontWeight:{property:"fontWeight",scale:"fontWeights"}}));var Bn=4,En="px",wd=20,Td=Object.fromEntries(Array.from(Array(wd+1),(e,t)=>t===0?[.5,`${.5*Bn}${En}`]:[t,`${t*Bn}${En}`])),eo={black:"#000000",gray100:"#14161A",gray200:"#181B20",gray300:"#1F2329",gray400:"#2E343D",gray500:"#4C5766",gray600:"#5A6472",gray700:"#C5CBD3",gray800:"#E2E5E9",gray900:"#F1F2F4",white:"#ffffff",blue400:"#015AC6",blue500:"#0171F8",blue800:"#DBECFF",blue900:"#F5F9FF",green400:"#009E37",green500:"#00D149",green800:"#DBFFE8",transparent:"#FFFFFF00",red500:"#c00000"},tr={colors:j(T({},eo),{neutral:{foreground:eo.gray300},primary:{background:eo.blue500,foreground:eo.white,inverted:eo.blue500},negative:{foreground:eo.red500}}),fonts:{default:"TT Interphases Pro, sans-serif"},fontSizes:{xs:"12px",sm:"14px",md:"16px",lg:"18px",xl:"20px","2xl":"24px","3xl":"30px","4xl":"36px","5xl":"48px"},fontWeights:{regular:400,semibold:500,bold:700},letterSpacings:{md:"0.02em"},lineHeights:{xs:"18px",sm:"22px",md:"24px",lg:"26px",xl:"30px","2xl":"38px","3xl":"46px","4xl":"60px"},radii:{md:"8px",lg:"20px",round:"50%"},shadows:{md:"0px 4px 20px rgba(0, 0, 0, 0.06)"},space:Td,components:{Button:Bo,Text:er}};var On="https://api.frigade.com",Q=Fd({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:lt,shouldGracefullyDegrade:!1,setShouldGracefullyDegrade:()=>{},apiUrl:On,readonly:!1,debug:!1});function kd(){Object.keys(localStorage).forEach(e=>{e.startsWith("frigade-")&&localStorage.removeItem(e)})}var Pd=({publicApiKey:e,userId:t,organizationId:o,config:i,children:n})=>{var Y,J,pe,we,Oe,de;let[r,l]=Ve(t||null),[p,d]=Ve(o||null),[s,m]=Ve([]),[c,g]=Ve([]),[y,b]=Ve([]),[C,x]=Ve({}),[P,S]=Ve({}),[v,$]=Ve([]),[B,u]=Ve({}),[O,w]=Ve(!1),[k,I]=Ve(!1),[N,A]=Ve(!ee(e)),H=(Z,D)=>{if(D==="_blank"){window.open(Z,"_blank");return}setTimeout(()=>{window.location.href=Z},50)},_={theme:T(T({},lt.theme),(J=(Y=i==null?void 0:i.defaultAppearance)==null?void 0:Y.theme)!=null?J:{}),styleOverrides:T(T({},lt.styleOverrides),(we=(pe=i==null?void 0:i.defaultAppearance)==null?void 0:pe.styleOverrides)!=null?we:{})};function ee(Z){return!!(Z&&Z.length>10&&Z.substring(0,10)==="api_public")}or(()=>{t&&l(t)},[t]),or(()=>{r&&typeof window!="undefined"&&window.localStorage&&window.localStorage.getItem(Po)&&window.localStorage.getItem(Po)!==r&&kd()},[r]),or(()=>{o&&d(o)},[o]),or(()=>{if(ee(e))A(!1);else{console.error("Frigade SDK failed to initialize. API key provided is either missing or valid."),A(!0);return}},[e,A]);let X={publicApiKey:e,userId:r,setUserId:l,setFlows:m,flows:s,failedFlowResponses:c,setFailedFlowResponses:g,flowResponses:y,setFlowResponses:b,userProperties:C,setUserProperties:x,openFlowStates:P,setOpenFlowStates:S,completedFlowsToKeepOpenDuringSession:v,setCompletedFlowsToKeepOpenDuringSession:$,customVariables:B,setCustomVariables:u,isNewGuestUser:O,setIsNewGuestUser:w,hasActiveFullPageFlow:k,setHasActiveFullPageFlow:I,organizationId:p,setOrganizationId:d,navigate:i&&i.navigate?i.navigate:H,defaultAppearance:_,shouldGracefullyDegrade:N,setShouldGracefullyDegrade:A,apiUrl:i&&i.apiUrl?i.apiUrl:On,readonly:i&&i.readonly?i.readonly:!1,debug:i&&i.debug?i.debug:!1,flowDataOverrides:i&&i.__internal__?i.__internal__:void 0},{overrides:q}=Tn(_);return N?Eo.createElement(Q.Provider,{value:X},Eo.createElement(An,{theme:Ce(_.theme,tr,q!=null?q:{},(Oe=i==null?void 0:i.theme)!=null?Oe:{})},n)):Eo.createElement(Q.Provider,{value:X},Eo.createElement(An,{theme:Ce(_.theme,tr,q!=null?q:{},(de=i==null?void 0:i.theme)!=null?de:{})},n,Eo.createElement(bn,null)))};import gc from"react";import Se,{useEffect as cr,useState as nl}from"react";import Ye,{useState as jd}from"react";import $t from"styled-components";import nr from"react";import It from"react";import In from"styled-components";var Nn=In.span`
|
|
693
|
+
`;var gn=({stepData:e,setCanContinue:t,onSaveData:o,appearance:i})=>{let n=e.props,[r,l]=Ur([]),[p,d]=Ur(!1),[s,m]=Ur(e.id);return Dr(()=>{r.length==0&&!p&&(d(!0),o({choice:[]}))},[p]),Dr(()=>{s!==e.id&&(m(e.id),l([]))},[e]),Dr(()=>{o({choice:r}),r.length>=n.minChoices?t(!0):t(!1)},[r]),pt.createElement(ln,{className:a("selectListContainer",i)},pt.createElement(an,null,pt.createElement(pn,{className:a("selectListTitle",i)},e.title),pt.createElement(dn,{appearance:i,className:a("selectListSubtitle",i)},e.subtitle)),n.options.map((c,g)=>{let y=r.includes(c.id);return pt.createElement(cn,{key:`select-item-${g}`,onClick:()=>{if(r.includes(c.id)){l(r.filter(b=>b!==c.id));return}r.length<n.maxChoices?l([...r,c.id]):r.length==1&&n.maxChoices==1&&l([c.id])},hideBottomBorder:g===n.options.length-1,className:a("selectListSelectItem",i)},pt.createElement(mn,{className:a("selectListItemImage",i)},c.imageUri&&pt.createElement(un,{src:c.imageUri,alt:`select-icon-${g}`}),pt.createElement(fn,{appearance:i,className:a("selectListSelectItemText",i)},c.title)),pt.createElement(at,{appearance:i,value:y,primaryColor:i.theme.colorPrimary}))}))};import Ue,{useEffect as hn,useState as Zo}from"react";var Gp=({children:e,id:t,shouldWrap:o=!1})=>Ue.createElement(Ue.Fragment,null,o?Ue.createElement("div",{key:t,style:{width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:1,overflowY:"auto"}},e):e),Ro=({appearance:e,steps:t,selectedStep:o,customStepTypes:i,customVariables:n,onButtonClick:r,onStepCompletion:l,flowId:p,type:d,hideOnFlowCompletion:s,onComplete:m,setVisible:c,setShowModal:g,onDismiss:y,showPagination:b=!1,customFormElements:C,allowBackNavigation:x,validationHandler:P,onFormDataChange:S,showFooter:v,prefillData:$,updateUrlOnPageChange:B,repeatable:u})=>{var ce;let w=T(T({},{linkCollection:nn,multiInput:Ki,callToAction:sn,selectList:gn}),i),{primaryCTAClickSideEffects:k,secondaryCTAClickSideEffects:I}=ue(),[N,A]=Zo(!1),[H,_]=Zo({}),[ee,X]=Zo(!1),[q,J]=Zo(null),Y=(ce=t[o])!=null?ce:null,{markStepCompleted:pe,markStepStarted:we,isLoading:Oe,updateCustomVariables:de,markFlowCompleted:Z}=R();hn(()=>{de(n)},[n,Oe]),hn(()=>{S&&S(H,D(),t[o],o)},[H]);function D(){var W;return{data:(W=H[t[o].id])!=null?W:{},stepId:t[o].id,customVariables:n}}function oe(V,W,L){let z=o+1<t.length?t[o+1]:null;return l&&l(V,L,z,H,D()),r?r(V,o,W,z):!0}function Ne(V,W){_(L=>{let z={};return z[V.id]=W,T(T({},L),z)})}function Je(V){return V.selectedStep.imageUri?Ue.createElement(Zi,{image:V.selectedStep.imageUri,appearance:e,className:a("formContainerSidebarImage",e)}):null}let xe=v&&Ue.createElement(on,{step:t[o],canContinue:N&&!ee,formType:d,selectedStep:o,appearance:e,onPrimaryClick:()=>M(void 0,null,function*(){if(X(!0),P){let L=yield P(t[o],o,t[o+1],H,D());if(L!==!0){J(typeof L=="string"?L:null),X(!1);return}else J(null)}let V=T({},D());yield pe(p,t[o].id,V),o+1<t.length&&!x&&(yield we(p,t[o+1].id));let W=oe(t[o],"primary",o);if(o+1>=t.length&&(m&&m(),y&&y(),s&&W&&(c&&c(!1),g(!1)),yield Z(p),u&&(yield we(p,t[0].id),typeof window!="undefined"&&window.localStorage&&Object.keys(window.localStorage).forEach(z=>{z.startsWith(Lr)&&window.localStorage.removeItem(z)}))),k(t[o]),X(!1),typeof window!="undefined"&&!x&&B&&o+1<t.length){let L=new URL(window.location.href);L.searchParams.set("p",t[o+1].id),window.history.pushState({},"",L.toString())}}),onSecondaryClick:()=>{oe(t[o],"secondary",o),I(t[o])},onBack:()=>M(void 0,null,function*(){o-1>=0&&(X(!0),yield we(p,t[o-1].id),X(!1))}),steps:t,allowBackNavigation:x,errorMessage:q,isSaving:ee});return Ue.createElement(Ue.Fragment,null,Ue.createElement(Xi,{className:a("formContainer",e)},Ue.createElement(Gp,{id:o,shouldWrap:d==="large-modal"},Ue.createElement(Qi,{key:Y.id,type:d,className:a("formContent",e)},t.map(V=>{var L;let W=w[(L=V.type)!=null?L:"multiInput"];return Y.id!==V.id?null:typeof W!="function"?W:Ue.createElement(W,{key:V.id,stepData:V,canContinue:N,setCanContinue:A,onSaveData:z=>{Ne(V,z)},appearance:e,customFormElements:C,flowId:p,prefillData:$})}),b&&Ue.createElement(rn,{className:a("formPagination",e),appearance:e,stepCount:t.length,currentStep:o}),xe)),d=="large-modal"&&Ue.createElement(Je,{selectedStep:t[o]})))};import Fo from"react";import{createGlobalStyle as Kp}from"styled-components";var qp=Kp`
|
|
694
|
+
${e=>e.inlineStyles.map(([t,o])=>`.${yo}${t}.${yo}${t} { ${Object.entries(o).map(([i,n])=>typeof n=="object"?`${i} { ${Object.entries(n).map(([l,p])=>`${Uo(l)}: ${p};`).join(" ")} }`:`${Uo(i)}: ${n};`).join(" ")} }`).join(" ")}`;function ae({appearance:e}){if(!e||!e.styleOverrides)return Fo.createElement(Fo.Fragment,null);let t=Object.entries(e.styleOverrides).filter(([o,i])=>typeof i=="object");return t.length===0?Fo.createElement(Fo.Fragment,null):Fo.createElement(qp,{inlineStyles:t})}import{useEffect as Yp,useState as Jp}from"react";function He(e,t=!0){let[o,i]=Jp(!1),{markStepStarted:n,isLoading:r,getFlowStatus:l,getFlowSteps:p,getCurrentStepIndex:d,targetingLogicShouldHideFlow:s,getFlow:m}=R(),c=p(e);function g(){return M(this,null,function*(){!o&&!r&&l(e)===Me&&s(m(e))===!1&&t&&(i(!0),yield n(e,c[d(e)].id))})}return Yp(()=>{g()},[r,e,t]),{}}var Cn=({flowId:e,customStepTypes:t={},type:o="inline",visible:i,setVisible:n,customVariables:r,customFormElements:l,onComplete:p,appearance:d,hideOnFlowCompletion:s=!0,onStepCompletion:m,onButtonClick:c,dismissible:g=!0,endFlowOnDismiss:y=!1,modalPosition:b="center",repeatable:C=!1,onDismiss:x,showPagination:P=!1,allowBackNavigation:S=!1,validationHandler:v,showFrigadeBranding:$=!1,onFormDataChange:B,showFooter:u=!0,prefillData:O={},updateUrlOnPageChange:w=!1})=>{let{getFlow:k,getFlowSteps:I,isLoading:N,targetingLogicShouldHideFlow:A,getFlowStatus:H,getCurrentStepIndex:_,markFlowCompleted:ee,markFlowNotStarted:X,markStepStarted:q}=R(),J=_(e),{mergeAppearanceWithDefault:Y}=ie(),[pe,we]=Xp(null),{setOpenFlowState:Oe,getOpenFlowState:de,hasOpenModals:Z}=Be();He(e,i);let D=I(e);d=Y(d);let[oe,Ne]=i!==void 0&&n!==void 0?[i,n]:[de(e,!0),V=>Oe(e,V)],Je=typeof window!="undefined"?window.location.hash:null;if(xn(()=>{var V;if(D&&D.length>0&&S){let W=typeof window!="undefined"&&((V=window==null?void 0:window.location)!=null&&V.hash)?window.location.hash.replace("#",""):"";if(D&&(D==null?void 0:D.length)>0){let L=-1;if(W){let z=W;L=D.findIndex(me=>me.id===z),pe===W&&(L=-1)}L!==-1&&(we(W),q(e,D[L].id))}}},[Je]),xn(()=>{!N&&D&&D.length&&typeof window!="undefined"&&S&&(we(D[J].id),window.location.hash=D[J].id)},[N,J,D]),N)return null;let xe=k(e);if(!xe||A(xe)||!D||i!==void 0&&i===!1||H(e)===re&&s&&!C||(o=="modal"||o=="corner-modal")&&Z(e))return null;let ce=()=>{Ne(!1),x&&x(),y===!0&&ee(e)};if(b=="center"&&o==="modal"||o==="large-modal"){let V={padding:"24px"};return o==="large-modal"?(V.width="85%",V.height="90%",V.maxHeight="800px",V.minHeight="500px",V.padding="0"):V.width="400px",ot.createElement(Re,{appearance:d,onClose:ce,visible:oe,style:V,dismissible:g,showFrigadeBranding:$},ot.createElement(ae,{appearance:d}),ot.createElement(Ro,{appearance:d,steps:D,selectedStep:J,customStepTypes:t,customVariables:r,onButtonClick:c,onStepCompletion:m,flowId:e,type:o,hideOnFlowCompletion:s,onComplete:p,setVisible:n,setShowModal:Ne,onDismiss:x,showPagination:P,customFormElements:l,allowBackNavigation:S,validationHandler:v,onFormDataChange:B,showFooter:u,prefillData:O,updateUrlOnPageChange:w,repeatable:C}))}return o==="modal"&&b!=="center"?ot.createElement(Vo,{appearance:d,onClose:ce,visible:oe,modalPosition:b},ot.createElement(ae,{appearance:d}),ot.createElement(Ro,{appearance:d,steps:D,selectedStep:J,customStepTypes:t,customVariables:r,onButtonClick:c,onStepCompletion:m,flowId:e,type:o,hideOnFlowCompletion:s,onComplete:p,setVisible:n,setShowModal:Ne,onDismiss:x,showPagination:P,customFormElements:l,allowBackNavigation:S,validationHandler:v,onFormDataChange:B,showFooter:u,prefillData:O,updateUrlOnPageChange:w,repeatable:C})):ot.createElement(ot.Fragment,null,ot.createElement(ae,{appearance:d}),ot.createElement(Ro,{appearance:d,steps:D,selectedStep:J,customStepTypes:t,customVariables:r,onButtonClick:c,onStepCompletion:m,flowId:e,type:o,hideOnFlowCompletion:s,onComplete:p,setVisible:n,setShowModal:Ne,onDismiss:x,showPagination:P,customFormElements:l,allowBackNavigation:S,validationHandler:v,onFormDataChange:B,showFooter:u,prefillData:O,updateUrlOnPageChange:w,repeatable:C}))},yn=Cn;import{useCallback as _r,useContext as Qp,useEffect as Zp}from"react";function Wr(){let{organizationId:e,userId:t,setOrganizationId:o}=Qp(Q),{mutateUserFlowState:i}=De(),{config:n,apiUrl:r}=Ze(),l=jt(),{verifySDKInitiated:p}=Gt();function d(g,y){return`frigade-user-group-registered-${g}-${y}`}Zp(()=>{if(t&&e){if(t.startsWith(Kt))return;let g=d(t,e);localStorage.getItem(g)||(l(`${r}userGroups`,j(T({},n),{method:"POST",body:JSON.stringify({foreignUserId:t,foreignUserGroupId:e})})),localStorage.setItem(g,"true"))}},[t,e]);let s=_r(g=>M(this,null,function*(){if(!p())return;if(!e||!t){console.error("Cannot add properties to organization: Organization ID and User ID must both be set.",{organizationIdInternal:e,userId:t});return}let y={foreignUserId:t,foreignUserGroupId:e,properties:g};yield l(`${r}userGroups`,j(T({},n),{method:"POST",body:JSON.stringify(y)})),i()}),[e,t,n,i]),m=_r((g,y)=>M(this,null,function*(){if(!p())return;if(!e||!t){console.error("Cannot track event for organization: Organization ID and User ID must both be set.",{organizationIdInternal:e,userId:t});return}let C={foreignUserId:t,foreignUserGroupId:e,events:[{event:g,properties:y}]};yield l(`${r}userGroups`,j(T({},n),{method:"POST",body:JSON.stringify(C)})),i()}),[e,t,n,i]),c=_r((g,y)=>M(this,null,function*(){if(p())if(y){let b=d(t,g);localStorage.setItem(b,"true"),o(g);let C={foreignUserId:t,foreignUserGroupId:g,properties:y};yield l(`${r}userGroups`,j(T({},n),{method:"POST",body:JSON.stringify(C)})),i()}else o(g)}),[t,n,i]);return{organizationId:e,setOrganizationId:o,setOrganizationIdWithProperties:c,addPropertiesToOrganization:s,trackEventForOrganization:m}}var Sn="frigade-xFrigade_guestUserId",Po="frigade-xFrigade_userId",bn=({})=>{let{setFlowResponses:e}=xo(),{userFlowStatesData:t,isLoadingUserFlowStateData:o,mutateUserFlowState:i}=De(),{userId:n,setUserId:r}=Co(),[l,p]=ko(n),{getFlowStatus:d}=R(),{flows:s,userProperties:m,setIsNewGuestUser:c,flowResponses:g}=Rp(Q),[y,b]=ko([]),[C,x]=ko([]),{organizationId:P}=Wr(),[S,v]=ko(P),[$,B]=ko(!1);Rt(()=>{if(!o&&t)for(let k=0;k<t.length;k++){let I=t[k],N=s.find(A=>A.slug===(I==null?void 0:I.flowId));if(N&&I&&I.shouldTrigger===!0&&N.type=="FORM"&&N.triggerType==="AUTOMATIC"&&!C.includes(N.slug)){setTimeout(()=>{u(I.flowId)},500);break}}},[o,t]),Rt(()=>{g.length>0&&i()},[g]),Rt(()=>{$||(B(!0),i())},[o,B]);function u(k){let I=s.find(N=>N.slug===k);I&&I.triggerType==="AUTOMATIC"&&!C.includes(I.slug)&&(x([...C,I.slug]),b([I]))}function O(){if(!n){let k=localStorage.getItem(Po);if(k){r(k);return}let I=localStorage.getItem(Sn);if(I){r(I);return}c(!0);let N=Kt+ed();try{localStorage.setItem(Sn,N)}catch(A){console.log("Failed to save guest user id locally: Local storage unavailable",A)}r(A=>A||N)}}Rt(()=>{try{if(s){let k=[];s.forEach(I=>{if(I.data){let N=I.data.match(/"imageUri":"(.*?)"/g);N&&N.forEach(A=>{let H=A.replace('"imageUri":"',"").replace('"',"");if(k.includes(H))return;let _=new Image;_.src=H,k.push(H)})}})}}catch(k){}},[s]),Rt(()=>{if(n!==l&&(e([]),i()),p(n),n&&!n.startsWith(Kt))try{localStorage.setItem(Po,n)}catch(k){console.log("Failed to save user id locally: Local storage available",k)}n===null&&setTimeout(()=>{n===null&&O()},50)},[n,s,m]),Rt(()=>{P!=S&&(v(P),e([]),i())},[P,S,v]);function w(){return Nt.createElement(Nt.Fragment,null,y.map(k=>d(k.slug)!==Me?null:Nt.createElement("span",{key:k.slug},Nt.createElement(yn,{flowId:k.slug,type:"modal",modalPosition:"center",endFlowOnDismiss:!0}))))}return Nt.createElement(Nt.Fragment,null,Nt.createElement(w,null))};var wn={colorPrimary:"colors.primary.background",colorText:"colors.neutral.foreground",colorBackground:"colors.neutral.background",colorBackgroundSecondary:"colors.secondary.background",colorTextOnPrimaryBackground:"colors.primary.foreground",colorTextSecondary:"colors.secondary.foreground",colorTextDisabled:"colors.gray700",colorBorder:"colors.gray800",colorTextError:"colors.negative.foreground",borderRadius:"radii.lg"};function td(e){if(!e)return;let t={};return Object.entries(e).forEach(([o,i])=>{if(wn[o]){let n=wn[o].split("."),r=t;n.forEach((l,p)=>{r[l]||(r[l]=p===n.length-1?i:{}),r=r[l]})}}),t}function od(e){if(!e)return;let t=Ce({},e),o={};return Object.keys(t).forEach(i=>{let n=`.fr-${i}`;o[n]=t[i]}),o}function Tn(e){let{theme:t,styleOverrides:o}=e,i=td(t),n=od(o);return{overrides:i,css:n}}import hd from"styled-components";import{compose as xd,variant as kn}from"styled-system";import Fn from"react";import rd,{ThemeProvider as id,useTheme as nd}from"styled-components";import{border as sd,color as ld,compose as ad,get as pd,shadow as dd,space as cd,system as md,typography as ud}from"styled-system";var fd={width:{property:"width",scale:"sizes",transform:(e,t)=>pd(t,e,!(typeof e=="number"&&!isNaN(e))||e>1?e:e*100+"%")},height:{property:"height",scale:"sizes"},minWidth:{property:"minWidth",scale:"sizes"},minHeight:{property:"minHeight",scale:"sizes"},maxWidth:{property:"maxWidth",scale:"sizes"},maxHeight:{property:"maxHeight",scale:"sizes"},overflow:!0,overflowX:!0,overflowY:!0,display:!0,verticalAlign:!0},gd=rd("div")(({css:e})=>e,ad(sd,ld,dd,cd,ud,md(fd))),vo=n=>{var r=n,{as:e,children:t,overrides:o}=r,i=Ie(r,["as","children","overrides"]);let l=nd(),p={border:"none",boxSizing:"border-box",m:0,p:0},d=()=>Fn.createElement(gd,T(T({as:e},p),i),t);if(o!==void 0){let s=Ce(l,o);return Fn.createElement(id,{theme:s},d())}return d()};var Bo={Primary:{backgroundColor:"primary.background",color:"primary.foreground","&:hover":{backgroundColor:"blue400"}},Secondary:{backgroundColor:"white",border:"1px solid",borderColor:"gray800",color:"neutral.foreground","&:hover":{backgroundColor:"blue900"}},Link:{backgroundColor:"transparent",color:"primary.inverted"},Plain:{backgroundColor:"transparent",color:"neutral.foreground"}},Cd={sm:{paddingX:4,paddingY:1},md:{paddingX:6,paddingY:2}},Pn=hd(vo)(()=>({whiteSpace:"nowrap"}),xd(kn({scale:"components.Button",variants:"components.Button"}),kn({prop:"size",variants:Cd})));import yd from"styled-components";import{variant as Sd,system as bd}from"styled-system";var er={Display1:{fontSize:"5xl",fontWeight:"bold",letterSpacing:"md",lineHeight:"4xl"},Display2:{fontSize:"4xl",fontWeight:"bold",letterSpacing:"md",lineHeight:"3xl"},H1:{fontSize:"3xl",fontWeight:"bold",letterSpacing:"md",lineHeight:"2xl"},H2:{fontSize:"2xl",fontWeight:"bold",letterSpacing:"md",lineHeight:"xl"},H3:{fontSize:"xl",fontWeight:"bold",letterSpacing:"md",lineHeight:"lg"},H4:{fontSize:"lg",fontWeight:"bold",letterSpacing:"md",lineHeight:"md"},Body1:{fontSize:"md",fontWeight:"regular",letterSpacing:"md",lineHeight:"md"},Body2:{fontSize:"sm",fontWeight:"regular",letterSpacing:"md",lineHeight:"md"},Caption:{fontSize:"xs",fontWeight:"regular",letterSpacing:"md",lineHeight:"sm"}};var vn=yd(vo)(Sd({scale:"components.Text",variants:"components.Text"}),bd({fontWeight:{property:"fontWeight",scale:"fontWeights"}}));var Bn=4,En="px",wd=20,Td=Object.fromEntries(Array.from(Array(wd+1),(e,t)=>t===0?[.5,`${.5*Bn}${En}`]:[t,`${t*Bn}${En}`])),eo={black:"#000000",gray100:"#14161A",gray200:"#181B20",gray300:"#1F2329",gray400:"#2E343D",gray500:"#4C5766",gray600:"#5A6472",gray700:"#C5CBD3",gray800:"#E2E5E9",gray900:"#F1F2F4",white:"#ffffff",blue400:"#015AC6",blue500:"#0171F8",blue800:"#DBECFF",blue900:"#F5F9FF",green400:"#009E37",green500:"#00D149",green800:"#DBFFE8",transparent:"#FFFFFF00",red500:"#c00000"},tr={colors:j(T({},eo),{neutral:{foreground:eo.gray300},primary:{background:eo.blue500,foreground:eo.white,inverted:eo.blue500},negative:{foreground:eo.red500}}),fonts:{default:"TT Interphases Pro, sans-serif"},fontSizes:{xs:"12px",sm:"14px",md:"16px",lg:"18px",xl:"20px","2xl":"24px","3xl":"30px","4xl":"36px","5xl":"48px"},fontWeights:{regular:400,semibold:500,bold:700},letterSpacings:{md:"0.02em"},lineHeights:{xs:"18px",sm:"22px",md:"24px",lg:"26px",xl:"30px","2xl":"38px","3xl":"46px","4xl":"60px"},radii:{md:"8px",lg:"20px",round:"50%"},shadows:{md:"0px 4px 20px rgba(0, 0, 0, 0.06)"},space:Td,components:{Button:Bo,Text:er}};var On="https://api.frigade.com",Q=Fd({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:lt,shouldGracefullyDegrade:!1,setShouldGracefullyDegrade:()=>{},apiUrl:On,readonly:!1,debug:!1});function kd(){Object.keys(localStorage).forEach(e=>{e.startsWith("frigade-")&&localStorage.removeItem(e)})}var Pd=({publicApiKey:e,userId:t,organizationId:o,config:i,children:n})=>{var J,Y,pe,we,Oe,de;let[r,l]=Ve(t||null),[p,d]=Ve(o||null),[s,m]=Ve([]),[c,g]=Ve([]),[y,b]=Ve([]),[C,x]=Ve({}),[P,S]=Ve({}),[v,$]=Ve([]),[B,u]=Ve({}),[O,w]=Ve(!1),[k,I]=Ve(!1),[N,A]=Ve(!ee(e)),H=(Z,D)=>{if(D==="_blank"){window.open(Z,"_blank");return}setTimeout(()=>{window.location.href=Z},50)},_={theme:T(T({},lt.theme),(Y=(J=i==null?void 0:i.defaultAppearance)==null?void 0:J.theme)!=null?Y:{}),styleOverrides:T(T({},lt.styleOverrides),(we=(pe=i==null?void 0:i.defaultAppearance)==null?void 0:pe.styleOverrides)!=null?we:{})};function ee(Z){return!!(Z&&Z.length>10&&Z.substring(0,10)==="api_public")}or(()=>{t&&l(t)},[t]),or(()=>{r&&typeof window!="undefined"&&window.localStorage&&window.localStorage.getItem(Po)&&window.localStorage.getItem(Po)!==r&&kd()},[r]),or(()=>{o&&d(o)},[o]),or(()=>{if(ee(e))A(!1);else{console.error("Frigade SDK failed to initialize. API key provided is either missing or valid."),A(!0);return}},[e,A]);let X={publicApiKey:e,userId:r,setUserId:l,setFlows:m,flows:s,failedFlowResponses:c,setFailedFlowResponses:g,flowResponses:y,setFlowResponses:b,userProperties:C,setUserProperties:x,openFlowStates:P,setOpenFlowStates:S,completedFlowsToKeepOpenDuringSession:v,setCompletedFlowsToKeepOpenDuringSession:$,customVariables:B,setCustomVariables:u,isNewGuestUser:O,setIsNewGuestUser:w,hasActiveFullPageFlow:k,setHasActiveFullPageFlow:I,organizationId:p,setOrganizationId:d,navigate:i&&i.navigate?i.navigate:H,defaultAppearance:_,shouldGracefullyDegrade:N,setShouldGracefullyDegrade:A,apiUrl:i&&i.apiUrl?i.apiUrl:On,readonly:i&&i.readonly?i.readonly:!1,debug:i&&i.debug?i.debug:!1,flowDataOverrides:i&&i.__internal__?i.__internal__:void 0},{overrides:q}=Tn(_);return N?Eo.createElement(Q.Provider,{value:X},Eo.createElement(An,{theme:Ce(_.theme,tr,q!=null?q:{},(Oe=i==null?void 0:i.theme)!=null?Oe:{})},n)):Eo.createElement(Q.Provider,{value:X},Eo.createElement(An,{theme:Ce(_.theme,tr,q!=null?q:{},(de=i==null?void 0:i.theme)!=null?de:{})},n,Eo.createElement(bn,null)))};import gc from"react";import Se,{useEffect as cr,useState as nl}from"react";import Ye,{useState as jd}from"react";import $t from"styled-components";import nr from"react";import It from"react";import In from"styled-components";var Nn=In.span`
|
|
695
695
|
font-weight: 600;
|
|
696
696
|
font-size: 14px;
|
|
697
697
|
font-style: normal;
|
|
@@ -1354,7 +1354,7 @@ ${e=>e.inlineStyles.map(([t,o])=>`.${yo}${t}.${yo}${t} { ${Object.entries(o).map
|
|
|
1354
1354
|
color: ${({theme:e})=>e.colorTextSecondary};
|
|
1355
1355
|
${e=>e.blocked||e.complete?"opacity: 0.4;":`
|
|
1356
1356
|
`}
|
|
1357
|
-
`;var ol=({stepData:e,style:t={},appearance:o})=>{let{mergeAppearanceWithDefault:i}=ie(),{primaryCTAClickSideEffects:n}=ue();o=i(o);let{imageUri:r=null,subtitle:l=null,title:p=null,complete:d=!1,blocked:s=!1}=e,m=e.primaryButtonTitle||e.secondaryButtonTitle,c=()=>{n(e)};return lo.createElement(Ys,{className:a("carouselCard",o),onClick:s?null:c,style:t,blocked:s,complete:d},r&&lo.createElement(Js,{className:a("carouselCardImage",o),src:r,alt:p,style:{opacity:d||s?.4:1}}),d&&lo.createElement(Qs,{className:a("carouselCompletedPill",o)},lo.createElement(tl,{style:{color:"#108E0B"}},"Complete")),p&&lo.createElement(el,{blocked:s,complete:d,className:a("carouselCardTitle",o)},p),l&&lo.createElement(bt.Quiet,{blocked:s,complete:d,className:a("carouselCardSubtitle",o)},l))};var fc=()=>he.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},he.createElement("path",{d:"M14 6L20 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),he.createElement("path",{d:"M14 18L20 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),he.createElement("path",{d:"M4 12H20",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})),rl=({side:e="left",show:t=!1,onClick:o=()=>{}})=>{let[i,n]=Mt(!1),[r,l]=Mt(!1);Yr(()=>{t===!0&&i===!1?n(!0):t===!1&&i===!0&&l(!0)},[t]);let p=()=>{n(!1),l(!1)},d=e=="left"?{top:0,bottom:0,left:-20,transform:"rotate(180deg)"}:{top:0,bottom:0,right:-20};return i?he.createElement(Gs,{style:d,reversed:r,onAnimationEnd:r?p:null},he.createElement(Ks,{onClick:()=>o(),style:{right:16,top:"calc(50% - 24px)"}},he.createElement(fc,null))):null},il=({flowId:e,appearance:t,customVariables:o,className:i})=>{let n=uc(null),[r,l]=Mt(!1),[p,d]=Mt(!1),[s,m]=Mt(null),[c,g]=Mt([]),[y,b]=Mt(0),{isSmall:C}=_s(),x=C?1:3,{getFlowMetadata:P,getFlowSteps:S,getNumberOfStepsCompleted:v,updateCustomVariables:$,isLoading:B}=R();Yr(()=>{$(o)},[o,B]),Yr(()=>{if(B)return;let N=P(e),A=v(e),H=S(e);m(N),(N.data!==null||N.steps!==null)&&(g(H.sort((_,ee)=>Number(_.complete)-Number(ee.complete))),d(H.length>x),b(A))},[B]);let u=[];for(let N=0;N<c.length;N+=x)u.push(c.slice(N,N+x));let O=N=>{let A=N.target,H=A.scrollWidth-A.clientWidth,_=Math.ceil(A.scrollLeft);_>0&&r===!1&&l(!0),_===0&&r===!0&&l(!1),_<H&&p===!1&&d(!0),_===H&&p===!0&&d(!1)},w=(N=!0)=>{let A=N?1:-1;n.current!==null&&n.current.scrollBy({left:n.current.clientWidth*A,behavior:"smooth"})},k=null,I=N=>{k!==null?clearTimeout(k):O(N),k=setTimeout(()=>{O(N)},16)};return B?null:he.createElement(Xs,{className:Te(a("carouselContainer",t),i)},he.createElement("div",{style:{display:"flex",justifyContent:C?"center":"space-between",marginBottom:20,flexWrap:C?"wrap":"nowrap",gap:C?16:20}},he.createElement("div",null,he.createElement(Zs,{className:a("carouselTitle",t)},s==null?void 0:s.title),he.createElement(bt.Quiet,{className:a("carouselSubtitle",t)},s==null?void 0:s.subtitle)),he.createElement(Rs,{className:a("progressWrapper",t)},he.createElement(_e,{count:y,total:c.length,appearance:t}))),he.createElement("div",{style:{position:"relative"}},he.createElement(rl,{show:r,onClick:()=>w(!1)}),he.createElement(rl,{side:"right",show:p,onClick:w}),he.createElement(Vs,{ref:n,onScroll:I},u.map((N,A)=>he.createElement(js,{key:A,style:{flex:`0 0 calc(100% - ${c.length>x?36:0}px)`}},N.map((H,_)=>he.createElement(ol,{key:_,stepData:H,style:{flex:c.length>x?`0 1 calc(100% / ${x} - 16px * 2 / ${x})`:1},appearance:t})))))),he.createElement(ae,{appearance:t}))};var Jr=$=>{var B=$,{flowId:e,title:t,subtitle:o,style:i,initialSelectedStep:n,className:r,type:l="inline",onDismiss:p,visible:d,customVariables:s,onStepCompletion:m,onButtonClick:c,appearance:g,hideOnFlowCompletion:y,setVisible:b,customStepTypes:C,checklistStyle:x="default",autoExpandFirstIncompleteStep:P,autoExpandNextStep:S}=B,v=Ie(B,["flowId","title","subtitle","style","initialSelectedStep","className","type","onDismiss","visible","customVariables","onStepCompletion","onButtonClick","appearance","hideOnFlowCompletion","setVisible","customStepTypes","checklistStyle","autoExpandFirstIncompleteStep","autoExpandNextStep"]);let{getFlow:u,getFlowSteps:O,markStepCompleted:w,getStepStatus:k,getNumberOfStepsCompleted:I,isLoading:N,targetingLogicShouldHideFlow:A,updateCustomVariables:H,getFlowMetadata:_,isStepBlocked:ee,getFlowStatus:X,hasActiveFullPageFlow:q,setHasActiveFullPageFlow:
|
|
1357
|
+
`;var ol=({stepData:e,style:t={},appearance:o})=>{let{mergeAppearanceWithDefault:i}=ie(),{primaryCTAClickSideEffects:n}=ue();o=i(o);let{imageUri:r=null,subtitle:l=null,title:p=null,complete:d=!1,blocked:s=!1}=e,m=e.primaryButtonTitle||e.secondaryButtonTitle,c=()=>{n(e)};return lo.createElement(Ys,{className:a("carouselCard",o),onClick:s?null:c,style:t,blocked:s,complete:d},r&&lo.createElement(Js,{className:a("carouselCardImage",o),src:r,alt:p,style:{opacity:d||s?.4:1}}),d&&lo.createElement(Qs,{className:a("carouselCompletedPill",o)},lo.createElement(tl,{style:{color:"#108E0B"}},"Complete")),p&&lo.createElement(el,{blocked:s,complete:d,className:a("carouselCardTitle",o)},p),l&&lo.createElement(bt.Quiet,{blocked:s,complete:d,className:a("carouselCardSubtitle",o)},l))};var fc=()=>he.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},he.createElement("path",{d:"M14 6L20 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),he.createElement("path",{d:"M14 18L20 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),he.createElement("path",{d:"M4 12H20",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})),rl=({side:e="left",show:t=!1,onClick:o=()=>{}})=>{let[i,n]=Mt(!1),[r,l]=Mt(!1);Yr(()=>{t===!0&&i===!1?n(!0):t===!1&&i===!0&&l(!0)},[t]);let p=()=>{n(!1),l(!1)},d=e=="left"?{top:0,bottom:0,left:-20,transform:"rotate(180deg)"}:{top:0,bottom:0,right:-20};return i?he.createElement(Gs,{style:d,reversed:r,onAnimationEnd:r?p:null},he.createElement(Ks,{onClick:()=>o(),style:{right:16,top:"calc(50% - 24px)"}},he.createElement(fc,null))):null},il=({flowId:e,appearance:t,customVariables:o,className:i})=>{let n=uc(null),[r,l]=Mt(!1),[p,d]=Mt(!1),[s,m]=Mt(null),[c,g]=Mt([]),[y,b]=Mt(0),{isSmall:C}=_s(),x=C?1:3,{getFlowMetadata:P,getFlowSteps:S,getNumberOfStepsCompleted:v,updateCustomVariables:$,isLoading:B}=R();Yr(()=>{$(o)},[o,B]),Yr(()=>{if(B)return;let N=P(e),A=v(e),H=S(e);m(N),(N.data!==null||N.steps!==null)&&(g(H.sort((_,ee)=>Number(_.complete)-Number(ee.complete))),d(H.length>x),b(A))},[B]);let u=[];for(let N=0;N<c.length;N+=x)u.push(c.slice(N,N+x));let O=N=>{let A=N.target,H=A.scrollWidth-A.clientWidth,_=Math.ceil(A.scrollLeft);_>0&&r===!1&&l(!0),_===0&&r===!0&&l(!1),_<H&&p===!1&&d(!0),_===H&&p===!0&&d(!1)},w=(N=!0)=>{let A=N?1:-1;n.current!==null&&n.current.scrollBy({left:n.current.clientWidth*A,behavior:"smooth"})},k=null,I=N=>{k!==null?clearTimeout(k):O(N),k=setTimeout(()=>{O(N)},16)};return B?null:he.createElement(Xs,{className:Te(a("carouselContainer",t),i)},he.createElement("div",{style:{display:"flex",justifyContent:C?"center":"space-between",marginBottom:20,flexWrap:C?"wrap":"nowrap",gap:C?16:20}},he.createElement("div",null,he.createElement(Zs,{className:a("carouselTitle",t)},s==null?void 0:s.title),he.createElement(bt.Quiet,{className:a("carouselSubtitle",t)},s==null?void 0:s.subtitle)),he.createElement(Rs,{className:a("progressWrapper",t)},he.createElement(_e,{count:y,total:c.length,appearance:t}))),he.createElement("div",{style:{position:"relative"}},he.createElement(rl,{show:r,onClick:()=>w(!1)}),he.createElement(rl,{side:"right",show:p,onClick:w}),he.createElement(Vs,{ref:n,onScroll:I},u.map((N,A)=>he.createElement(js,{key:A,style:{flex:`0 0 calc(100% - ${c.length>x?36:0}px)`}},N.map((H,_)=>he.createElement(ol,{key:_,stepData:H,style:{flex:c.length>x?`0 1 calc(100% / ${x} - 16px * 2 / ${x})`:1},appearance:t})))))),he.createElement(ae,{appearance:t}))};var Jr=$=>{var B=$,{flowId:e,title:t,subtitle:o,style:i,initialSelectedStep:n,className:r,type:l="inline",onDismiss:p,visible:d,customVariables:s,onStepCompletion:m,onButtonClick:c,appearance:g,hideOnFlowCompletion:y,setVisible:b,customStepTypes:C,checklistStyle:x="default",autoExpandFirstIncompleteStep:P,autoExpandNextStep:S}=B,v=Ie(B,["flowId","title","subtitle","style","initialSelectedStep","className","type","onDismiss","visible","customVariables","onStepCompletion","onButtonClick","appearance","hideOnFlowCompletion","setVisible","customStepTypes","checklistStyle","autoExpandFirstIncompleteStep","autoExpandNextStep"]);let{getFlow:u,getFlowSteps:O,markStepCompleted:w,getStepStatus:k,getNumberOfStepsCompleted:I,isLoading:N,targetingLogicShouldHideFlow:A,updateCustomVariables:H,getFlowMetadata:_,isStepBlocked:ee,getFlowStatus:X,hasActiveFullPageFlow:q,setHasActiveFullPageFlow:J,markStepStarted:Y,getCurrentStepIndex:pe}=R(),{primaryCTAClickSideEffects:we,secondaryCTAClickSideEffects:Oe}=ue(),{getOpenFlowState:de,setOpenFlowState:Z}=Be(),[D,oe]=nl(n||0),[Ne,Je]=nl(!1),xe=d===void 0?de(e):d,ce=l==="modal",{mergeAppearanceWithDefault:V}=ie();He(e,d);let W=O(e),L=pe(e);if(g=V(g),cr(()=>{H(s)},[s,N]),cr(()=>{d!==void 0&&(ce&&d===!0?J(!0):ce&&d===!1&&J(!1))},[d,b,q]),cr(()=>{!N&&W&&W[D]&&k(e,W[D].id)&&k(e,W[D].id)!==Le&&Y(e,W[D].id)},[D]),cr(()=>{D!==L&&oe(L)},[L]),N)return null;let z=u(e);if(!z||A(z)||!W||y===!0&&X(e)===re)return null;let me=_(e);if(me!=null&&me.title&&(t=me.title),me!=null&&me.subtitle&&(o=me.subtitle),!Ne&&n===void 0&&I(e)>0){let f=W.findIndex(F=>F.complete===!1);oe(f>-1?f:W.length-1),Je(!0)}function je(){if(D+1>=W.length){ce&&Z(e,!1);return}ee(e,W[D+1].id)||oe(D+1)}function Xe(f,F,U){let fe=D+1<W.length?W[D+1]:null;c&&c(f,D,F,fe)===!0&&ce&&Ke(),m&&m(f,U,fe),!m&&!c&&(f.primaryButtonUri||f.secondaryButtonUri)&&ce&&Ke()}function Ft(){return W.map((f,F)=>j(T({},f),{handleSecondaryButtonClick:()=>{je(),Oe(f),f.skippable===!0&&w(e,f.id,{skipped:!0}),Xe(f,"secondary",F)},handlePrimaryButtonClick:()=>{(!f.completionCriteria&&(f.autoMarkCompleted||f.autoMarkCompleted===void 0)||f.completionCriteria&&f.autoMarkCompleted===!0)&&(w(e,f.id),je()),Xe(f,"primary",F),we(f),k(e,f.id)===Le&&je()}}))}function Ge(){return Se.createElement(ae,{appearance:g})}let gt={steps:Ft(),title:t,subtitle:o,primaryColor:g.theme.colorPrimary,appearance:g,customStepTypes:C,type:l,className:r,autoExpandFirstIncompleteStep:P,autoExpandNextStep:S};function Ke(){Z(e,!1),p&&p(),b&&b(!1)}function Wt(){return Se.createElement(Se.Fragment,null,Se.createElement(Ge,null),Se.createElement(il,{flowId:e,appearance:g,customVariables:s,className:r}))}function zt(){return Se.createElement(Se.Fragment,null,Se.createElement(Ge,null),Se.createElement(qr,T({visible:xe,onClose:()=>{Ke()},selectedStep:D,setSelectedStep:oe,autoExpandNextStep:!0,appearance:g},gt)))}function Ht(){var U;let f=v.guideFlowId,F;return f&&u(f)&&(F=O(f)),Se.createElement(Se.Fragment,null,Se.createElement(Ge,null),Se.createElement(Kr,T({visible:xe,stepsTitle:me.stepsTitle?me.stepsTitle:"Your quick start guide",onClose:()=>{Ke()},selectedStep:D,setSelectedStep:oe,guideData:F,guideTitle:(U=v.guideTitle)!=null?U:"Guide",appearance:g,title:t,subtitle:o,onGuideButtonClick:fe=>{Xe(fe,"link",0)},customStepTypes:C},gt)))}function h(){let f=Se.createElement(jr,T({flowId:e,style:i,selectedStep:D,setSelectedStep:oe,appearance:g,type:l},gt));return ce?Se.createElement(Re,{onClose:()=>{Ke()},visible:xe,appearance:g,style:{paddingTop:"0px",padding:"12px",paddingLeft:0}},Se.createElement(Ge,null),f):Se.createElement(Se.Fragment,null,Se.createElement(Ge,null),f)}switch(x){case"condensed":return zt();case"with-guide":return Ht();case"default":return h();case"carousel":return Wt();default:return h()}};var hc=e=>gc.createElement(Jr,T({type:"inline"},e));import Tt,{useEffect as xc}from"react";import rt from"react";import mr from"styled-components";var sl=mr.div`
|
|
1358
1358
|
border: 1px solid ${e=>e.appearance.theme.colorBorder};
|
|
1359
1359
|
border-radius: ${e=>e.appearance.theme.borderRadius}px;
|
|
1360
1360
|
padding: 10px 12px 10px 12px;
|
|
@@ -1464,7 +1464,7 @@ ${e=>e.inlineStyles.map(([t,o])=>`.${yo}${t}.${yo}${t} { ${Object.entries(o).map
|
|
|
1464
1464
|
`,Oc=Lo(bl)`
|
|
1465
1465
|
width: ${co+12}px;
|
|
1466
1466
|
height: ${co+12}px;
|
|
1467
|
-
`,Nc=({steps:e=[],onDismiss:t,onComplete:o=()=>{},tooltipPosition:i="auto",showHighlight:n=!0,primaryColor:r="#000000",offset:l={x:0,y:0},visible:p=!0,containerStyle:d={},selectedStep:s=0,customStepTypes:m,appearance:c,dismissible:g=!1,showHighlightOnly:y,showStepCount:b=!0,completedStepsCount:C=0,showFrigadeBranding:x=!1,cssPosition:P="absolute",onViewTooltip:S,className:v})=>{var Ft,Ge,gt,Ke,Wt,zt,Ht,h,f,F,U,fe,ht,kt,Pt,ge,uo,fo,ni;let{logErrorIfDebugMode:$}=xl(),[B,u]=po(),[O,w]=po(new Date),k=Pc(null),[I,N]=po(document.querySelector(e[s].selector)),A=hl(I,O),[H,_]=po(),[ee,X]=po(!y),q=(Ge=(Ft=e[s])==null?void 0:Ft.props)!=null&&Ge.position?e[s].props.position:P,
|
|
1467
|
+
`,Nc=({steps:e=[],onDismiss:t,onComplete:o=()=>{},tooltipPosition:i="auto",showHighlight:n=!0,primaryColor:r="#000000",offset:l={x:0,y:0},visible:p=!0,containerStyle:d={},selectedStep:s=0,customStepTypes:m,appearance:c,dismissible:g=!1,showHighlightOnly:y,showStepCount:b=!0,completedStepsCount:C=0,showFrigadeBranding:x=!1,cssPosition:P="absolute",onViewTooltip:S,className:v})=>{var Ft,Ge,gt,Ke,Wt,zt,Ht,h,f,F,U,fe,ht,kt,Pt,ge,uo,fo,ni;let{logErrorIfDebugMode:$}=xl(),[B,u]=po(),[O,w]=po(new Date),k=Pc(null),[I,N]=po(document.querySelector(e[s].selector)),A=hl(I,O),[H,_]=po(),[ee,X]=po(!y),q=(Ge=(Ft=e[s])==null?void 0:Ft.props)!=null&&Ge.position?e[s].props.position:P,J=(Wt=(Ke=(gt=e[s])==null?void 0:gt.props)==null?void 0:Ke.zIndex)!=null?Wt:90,Y=(zt=B==null?void 0:B.width)!=null?zt:yl,pe=(Ht=B==null?void 0:B.height)!=null?Ht:Sl,[we,Oe]=po(new Date().getTime());l=(F=(f=(h=e[s])==null?void 0:h.props)==null?void 0:f.offset)!=null?F:l;let de=window.location.pathname.split("/").pop();Cl(()=>{k.current&&u({width:k.current.clientWidth,height:k.current.clientHeight})},[s,O,q]),ao(()=>{y||X(!0)},[s]),ao(()=>{p&&ee&&S(s)},[ee]);let Z=()=>{if(q==="static")return;let te=document.querySelector(e[s].selector);if(!te){_(void 0),N(null),$(`FrigadeTour: Could not find element with selector "${e[s].selector}" for step ${e[s].id}`);return}H&&H===JSON.stringify(te==null?void 0:te.getBoundingClientRect())||(N(te),w(new Date),te&&_(JSON.stringify(te.getBoundingClientRect())))};if(ao(()=>{let te=new MutationObserver(Z);return te.observe(document.body,{subtree:!0,childList:!0}),()=>te.disconnect()},[Z]),ao(()=>{let te=new MutationObserver(Z);return te.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","class"]}),()=>te.disconnect()},[Z]),ao(()=>{let te=setInterval(()=>{Z()},10);return()=>clearInterval(te)},[Z]),Cl(()=>{setTimeout(()=>{Z()},vc),Z()},[s,de]),ao(()=>{if(!p)return;let te=Qe=>{Qe.key==="Escape"&&t()};return document.addEventListener("keydown",te),()=>{document.removeEventListener("keydown",te)}},[]),I===null||!p)return null;let D=i==="auto"?"right":i,oe=Xr(A,D,Y,l,q),Ne=A.right+Y>(window.innerWidth||document.documentElement.clientWidth),Je=A.bottom+Sl>(window.innerHeight||document.documentElement.clientHeight);Ne&&i==="auto"&&(oe=Xr(A,"left",Y,l,q),D="left"),(fe=(U=e[s])==null?void 0:U.props)!=null&&fe.tooltipPosition&&((kt=(ht=e[s])==null?void 0:ht.props)==null?void 0:kt.tooltipPosition)!=="auto"&&(((ge=(Pt=e[s])==null?void 0:Pt.props)==null?void 0:ge.tooltipPosition)==="left"||((fo=(uo=e[s])==null?void 0:uo.props)==null?void 0:fo.tooltipPosition)==="right")&&(D=e[s].props.tooltipPosition);let xe=()=>{let te=()=>{if(e[s].handlePrimaryButtonClick&&(e[s].handlePrimaryButtonClick(),X(!1),setTimeout(()=>{Z()},30)),C===e.length-1)return o()},Qe=()=>{e[s].handleSecondaryButtonClick&&(e[s].handleSecondaryButtonClick(),y&&!e[s].secondaryButtonUri&&X(!1))};return K.createElement(K.Fragment,null,b&&e.length>1&&K.createElement(wi,null,K.createElement(Fi,{role:"status",className:a("tooltipStepCounter",c)},s+1," of ",e.length)),(e[s].primaryButtonTitle||e[s].secondaryButtonTitle)&&K.createElement(Ti,{showStepCount:b,className:a("tooltipCTAContainer",c)},e[s].secondaryButtonTitle&&K.createElement(se,{title:e[s].secondaryButtonTitle,appearance:c,onClick:Qe,size:"small",withMargin:!1,secondary:!0}),e[s].primaryButtonTitle&&K.createElement(se,{title:e[s].primaryButtonTitle,appearance:c,onClick:te,autoFocus:!0,withMargin:!1,size:"small"})))},ce=()=>K.createElement(K.Fragment,null,g&&K.createElement(xi,{"data-testid":"tooltip-dismiss",onClick:()=>{t&&t()},className:a("tooltipClose",c),hasImage:!!e[s].imageUri||!!e[s].videoUri,"aria-label":"Close Tooltip",role:"button",tabIndex:0},K.createElement(Ee,null)),e[s].imageUri&&K.createElement(Ci,{dismissible:g,appearance:c,role:"img","aria-label":e[s].title,src:e[s].imageUri,className:a("tooltipImageContainer",c)}),e[s].videoUri&&!e[s].imageUri&&K.createElement(yi,{dismissible:g,appearance:c,role:"video","aria-label":e[s].title,className:a("tooltipVideoContainer",c)},K.createElement(tt,{appearance:c,videoUri:e[s].videoUri})),K.createElement(bi,{className:a("tooltipContentContainer",c)},K.createElement(Ae,{appearance:c,title:e[s].title,subtitle:e[s].subtitle,size:"small",ariaPrefix:`Tooltip${e[s].id}`}),K.createElement(Si,{className:a("tooltipFooter",c)},K.createElement(xe,null)))),W=T(T({},{default:te=>{var Qe;if((Qe=e[s])!=null&&Qe.StepContent){let na=e[s].StepContent;return K.createElement("div",null,na)}return K.createElement(ce,null)}}),m),L=()=>{var te;return e?!((te=e[s])!=null&&te.type)||!W[e[s].type]?W.default(e[s]):W[e[s].type]({stepData:e[s],primaryColor:r}):K.createElement(K.Fragment,null)};if(e[s].complete===!0||oe.x==0&&oe.y==0&&new Date().getTime()-we<100)return null;let z={top:(oe==null?void 0:oe.y)-co,left:(ni=D=="left"?A.x+l.x:(oe==null?void 0:oe.x)-co)!=null?ni:0,cursor:y?"pointer":"default",position:q},me=()=>{let Qe=z.left+(D=="left"?-Y:24);return Math.min(Math.max(Qe,20),window.innerWidth-Y-20)},je=()=>{if(q==="fixed")return z.top;let te=z.top+pe,Qe=20;return te>window.innerHeight-Qe?z.top+-pe:z.top},Xe=()=>{y&&(w(new Date),X(!ee))};return K.createElement(Ac,{className:v},K.createElement(Oc,{style:z,zIndex:J,className:a("tourHighlightContainer",c)},n&&e[s].showHighlight!==!1&&P!=="static"&&K.createElement(K.Fragment,null,K.createElement(Ec,{style:{position:q},onClick:Xe,primaryColor:c.theme.colorPrimary,className:a("tourHighlightInnerCircle",c)}),K.createElement(Bc,{style:{position:"absolute"},onClick:Xe,primaryColor:c.theme.colorPrimary,className:a("tourHighlightOuterCircle",c)}))),K.createElement(bl,{style:j(T({},z),{left:me(),top:je()}),zIndex:J+1,className:a("tooltipContainerWrapper",c)},ee&&K.createElement(K.Fragment,null,K.createElement(_o,{ref:k,role:"dialog","aria-labelledby":`frigadeTooltip${e[s].id}Title`,"aria-describedby":`frigadeTooltip${e[s].id}Subtitle`,layoutId:"tooltip-container",tabIndex:0,"aria-label":"Tooltip",style:T({position:"relative",width:"max-content",right:0,top:P!=="static"?12:0},d),appearance:c,className:a("tooltipContainer",c),maxWidth:yl,zIndex:J+10},K.createElement(L,null)),x&&K.createElement(Pi,{className:a("poweredByFrigadeTooltipRibbon",c),appearance:c,zIndex:J+10},K.createElement(Wo,{appearance:c})))))},Qr=Nc;import{Portal as $c}from"react-portal";var Mc=x=>{var P=x,{flowId:e,customVariables:t,appearance:o,onStepCompletion:i,onButtonClick:n,showTooltipsSimultaneously:r=!1,onDismiss:l,dismissible:p,tooltipPosition:d="auto",showHighlightOnly:s=!1,dismissBehavior:m="complete-flow",onComplete:c,skipIfNotFound:g=!1,cssPosition:y="absolute",className:b}=P,C=Ie(P,["flowId","customVariables","appearance","onStepCompletion","onButtonClick","showTooltipsSimultaneously","onDismiss","dismissible","tooltipPosition","showHighlightOnly","dismissBehavior","onComplete","skipIfNotFound","cssPosition","className"]);let{getFlow:S,getFlowSteps:v,isLoading:$,targetingLogicShouldHideFlow:B,markStepCompleted:u,markStepStarted:O,markFlowCompleted:w,updateCustomVariables:k,getCurrentStepIndex:I,getStepStatus:N,isStepBlocked:A,getFlowStatus:H,getNumberOfStepsCompleted:_}=R(),{isLoadingUserFlowStateData:ee}=De(),{primaryCTAClickSideEffects:X,secondaryCTAClickSideEffects:q}=ue(),{hasOpenModals:J}=Be(),Y=I(e),{openFlowStates:pe}=Ic(Q),{mergeAppearanceWithDefault:we}=ie();if(o=we(o),Lc(()=>{k(t)},[t,$]),ee)return null;let Oe=S(e);if(!Oe||B(Oe)||H(e)==re||J())return null;let de=v(e);if(Object.keys(pe).length>0){let L=Object.keys(pe).find(z=>pe[z]===!0);if(L!==void 0&&L!==e)return Dt.createElement(Dt.Fragment,null)}function Z(L){return M(this,null,function*(){if(yield u(e,L.id),de.map(z=>N(e,z.id)).every(z=>z===Le)){yield w(e);return}!s&&Y+1<de.length&&!r&&A(e,de[Y+1].id)})}function D(L,z,me){let je=Y+1<de.length?de[Y+1]:null;n&&n(L,Y,z,je),i&&i(L,me,je)}function oe(){return de.map(L=>j(T({},L),{handleSecondaryButtonClick:()=>M(this,null,function*(){q(L),L.skippable===!0&&(yield u(e,L.id,{skipped:!0})),D(L,"secondary",Y)}),handlePrimaryButtonClick:()=>M(this,null,function*(){(!L.completionCriteria&&(L.autoMarkCompleted||L.autoMarkCompleted===void 0)||L.completionCriteria&&L.autoMarkCompleted===!0)&&(yield Z(L)),D(L,"primary",Y),X(L)})}))}function Ne(L){return M(this,null,function*(){l&&l(),m==="complete-flow"?yield w(e):yield u(e,L.id)})}function Je(){c&&c()}function xe(L){return M(this,null,function*(){yield O(e,de[L].id)})}let ce=!document.querySelector(de[Y].selector);function V(){let L=de.findIndex(z=>!!document.querySelector(z.selector));return de.map((z,me)=>!r&&me!==Y&&!g||me<L&&!g||g&&!ce&&me!==Y?null:Dt.createElement(Qr,T({key:z.id,appearance:o,steps:oe(),selectedStep:me,showTooltipsSimultaneously:r,dismissible:p,onDismiss:()=>Ne(z),tooltipPosition:d,showHighlightOnly:s,completedStepsCount:_(e),onComplete:Je,cssPosition:y,onViewTooltip:xe,className:b},C)))}function W(){return Dt.createElement(Dt.Fragment,null,Dt.createElement(ae,{appearance:o}),V())}return y==="static"?W():Dt.createElement($c,null,W())};import ze,{useEffect as Dc,useRef as Uc,useState as _c}from"react";import{Portal as Wc}from"react-portal";import Ut from"styled-components";var wl=Ut.button`
|
|
1468
1468
|
${e=>E(e)} {
|
|
1469
1469
|
// Anything inside this block will be ignored if the user provides a custom class
|
|
1470
1470
|
|
|
@@ -1723,7 +1723,7 @@ ${e=>e.inlineStyles.map(([t,o])=>`.${yo}${t}.${yo}${t} { ${Object.entries(o).map
|
|
|
1723
1723
|
opacity: 0.8;
|
|
1724
1724
|
}
|
|
1725
1725
|
}
|
|
1726
|
-
`;var Yc=({flowId:e,onDismiss:t,customVariables:o,onButtonClick:i,appearance:n,className:r,style:l,type:p="modal"})=>{let{getFlow:d,markFlowCompleted:s,markStepCompleted:m,getNumberOfStepsCompleted:c,isLoading:g,targetingLogicShouldHideFlow:y,updateCustomVariables:b,getFlowSteps:C,getFlowStatus:x,getFlowMetadata:P}=R(),{primaryCTAClickSideEffects:S}=ue(),{mergeAppearanceWithDefault:v}=ie(),[$,B]=le.useState(null),[u,O]=le.useState(""),w=P(e),{hasOpenModals:k,setKeepCompletedFlowOpenDuringSession:I,shouldKeepCompletedFlowOpenDuringSession:N}=Be();if(He(e),n=v(n),Kc(()=>{b(o)},[o,g]),g)return null;let A=d(e);if(!A||y(A)||x(e)===re||c(e)===1&&!N(e)||k())return null;let _=C(e)[c(e)];function ee(){var Y
|
|
1726
|
+
`;var Yc=({flowId:e,onDismiss:t,customVariables:o,onButtonClick:i,appearance:n,className:r,style:l,type:p="modal"})=>{let{getFlow:d,markFlowCompleted:s,markStepCompleted:m,getNumberOfStepsCompleted:c,isLoading:g,targetingLogicShouldHideFlow:y,updateCustomVariables:b,getFlowSteps:C,getFlowStatus:x,getFlowMetadata:P}=R(),{primaryCTAClickSideEffects:S}=ue(),{mergeAppearanceWithDefault:v}=ie(),[$,B]=le.useState(null),[u,O]=le.useState(""),w=P(e),{hasOpenModals:k,setKeepCompletedFlowOpenDuringSession:I,shouldKeepCompletedFlowOpenDuringSession:N}=Be();if(He(e),n=v(n),Kc(()=>{b(o)},[o,g]),g)return null;let A=d(e);if(!A||y(A)||x(e)===re||c(e)===1&&!N(e)||k())return null;let _=C(e)[c(e)];function ee(){var J,Y;return le.createElement(le.Fragment,null,le.createElement(ri,null,le.createElement(Ae,{size:"large",appearance:n,title:_.title,subtitle:_.subtitle})),le.createElement(ti,{className:a("npsNumberButtonContainer",n),appearance:n},Array.from(Array(10).keys()).map(pe=>le.createElement(Vl,{className:a("npsNumberButton",n),selected:$===pe+1,key:pe,onClick:()=>M(this,null,function*(){I(e),B(pe+1),yield m(e,_.id,{score:pe+1})}),appearance:n},pe+1))),le.createElement(jl,{appearance:n},le.createElement(oi,{appearance:n},(J=w==null?void 0:w.negativeLabel)!=null?J:"Not likely at all"),le.createElement(oi,{appearance:n},(Y=w==null?void 0:w.positiveLabel)!=null?Y:"Extremely likely")))}function X(){var J;return le.createElement(le.Fragment,null,le.createElement(ri,null,le.createElement(Ae,{appearance:n,title:(J=_.title)!=null?J:"Why did you choose this score?",size:"large"})),le.createElement(Gl,{appearance:n,value:u,onChange:Y=>{O(Y.target.value)},placeholder:"Add your optional feedback here..."}),le.createElement(ti,{appearance:n,className:a("npsNumberButtonContainer",n)},le.createElement(se,{size:"large",withMargin:!1,onClick:()=>M(this,null,function*(){yield s(e),i&&i(_,1,"primary")}),appearance:n,title:_.secondaryButtonTitle||"Skip",secondary:!0}),le.createElement(se,{size:"large",withMargin:!1,onClick:()=>M(this,null,function*(){yield m(e,_.id,{feedbackText:u}),yield s(e),i&&i(_,1,"primary")}),appearance:n,title:_.primaryButtonTitle||"Submit"})))}function q(){return c(e)>=2?null:le.createElement(le.Fragment,null,le.createElement(ae,{appearance:n}),le.createElement(Hl,{appearance:n,className:Te(a("npsSurveyContainer",n),r),style:l,type:p},le.createElement(Kl,{onClick:()=>M(this,null,function*(){yield s(e),t&&t()}),className:a("npsSurveyDismissButton",n)},le.createElement(Ee,null)),c(e)==0&&ee(),c(e)==1&&X()))}return p==="inline"?q():le.createElement(qc,null,q())};import ve,{useEffect as Qc}from"react";import _t from"styled-components";var ql=_t.div`
|
|
1727
1727
|
${e=>E(e)} {
|
|
1728
1728
|
display: flex;
|
|
1729
1729
|
flex-direction: column;
|