@frigade/react 2.0.0-alpha.8 → 2.0.0

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 CHANGED
@@ -1,15 +1,23 @@
1
1
  'use client';
2
- import * as _ from 'react';
3
- import { createContext, useState, useRef, useEffect, useCallback, useLayoutEffect, useContext } from 'react';
2
+ import * as w from '@radix-ui/react-dialog';
3
+ import { XMarkIcon } from '@heroicons/react/24/solid';
4
+ import * as xe from 'react';
5
+ import { createContext, useState, useMemo, useEffect, useContext, useRef, useCallback, useLayoutEffect } from 'react';
4
6
  import { clsx } from 'clsx';
5
- import { jsx, jsxs } from '@emotion/react/jsx-runtime';
7
+ import Do from 'known-css-properties';
8
+ import Wo from 'dompurify';
9
+ import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
6
10
  import { keyframes, Global, ThemeProvider } from '@emotion/react';
7
- import { XMarkIcon } from '@heroicons/react/24/solid';
8
- import * as v from '@radix-ui/react-popover';
9
11
  import { Frigade } from '@frigade/js';
12
+ export { Flow, Frigade } from '@frigade/js';
13
+ import { useForm, useController } from 'react-hook-form';
14
+ import * as N from '@radix-ui/react-radio-group';
15
+ import * as S from '@radix-ui/react-select';
16
+ import { ChevronDownIcon } from '@heroicons/react/24/outline';
17
+ import * as D from '@radix-ui/react-popover';
10
18
 
11
- var Z=Object.defineProperty,Le=Object.defineProperties;var ze=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var Y=(e,t,o)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,s=(e,t)=>{for(var o in t||(t={}))ee.call(t,o)&&Y(e,o,t[o]);if($)for(var o of $(t))te.call(t,o)&&Y(e,o,t[o]);return e},p=(e,t)=>Le(e,ze(t));var f=(e,t)=>{var o={};for(var r in e)ee.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&$)for(var r of $(e))t.indexOf(r)<0&&te.call(e,r)&&(o[r]=e[r]);return o};var oe=(e,t)=>{for(var o in t)Z(e,o,{get:t[o],enumerable:!0});};var C=(e,t,o)=>new Promise((r,n)=>{var i=u=>{try{c(o.next(u));}catch(d){n(d);}},l=u=>{try{c(o.throw(u));}catch(d){n(d);}},c=u=>u.done?r(u.value):Promise.resolve(u.value).then(i,l);c((o=o.apply(e,t)).next());});var re={borders:{md:"1px solid"},borderWidths:{0:"0",md:"1px"}};var ne={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",inherit:"inherit",red500:"#c00000"};var ie={md:"10px",lg:"20px",round:"50%"};var a=e=>`var(--fr-colors-${e})`,se={neutral:{background:a("white"),border:a("gray500"),foreground:a("black"),surface:a("gray700"),active:{background:a("white"),border:a("gray900"),foreground:a("black"),surface:a("gray700")},focus:{background:a("white"),border:a("gray900"),foreground:a("black"),surface:a("gray700")},hover:{background:a("white"),border:a("gray900"),foreground:a("black"),surface:a("gray700")}},primary:{background:a("blue500"),border:a("blue500"),foreground:a("white"),surface:a("blue500"),active:{background:a("blue400"),border:a("blue400"),foreground:a("white"),surface:a("blue400")},focus:{background:a("blue500"),border:a("blue500"),foreground:a("white"),surface:a("blue500")},hover:{background:a("blue400"),border:a("blue400"),foreground:a("white"),surface:a("blue400")}},secondary:{background:a("gray900"),border:a("gray900"),foreground:a("black"),surface:a("gray900"),active:{background:a("gray800"),border:a("gray800"),foreground:a("black"),surface:a("gray800")},focus:{background:a("gray900"),border:a("gray900"),foreground:a("black"),surface:a("gray900")},hover:{background:a("gray800"),border:a("gray800"),foreground:a("black"),surface:a("gray800")}}};var ae={md:"0px 4px 20px rgba(0, 0, 0, 0.1)"};var Ke="px",Ue=e=>typeof e=="number"?`${4*e}${Ke}`:e,Ne=[-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,-.5,0,.5,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,"auto"],le=Object.fromEntries(Ne.map(e=>[e,Ue(e)]));var pe={fontFamilies:{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:{thin:"100",extralight:"200",light:"300",regular:"400",medium:"500",demibold:"600",bold:"700",extrabold:"800",black:"900"},letterSpacings:{md:"0.02em"},lineHeights:{xs:"18px",sm:"22px",md:"24px",lg:"26px",xl:"30px","2xl":"38px","3xl":"46px","4xl":"60px"}};var L=p(s(p(s({},re),{colors:s(s({},ne),se)}),pe),{radii:ie,shadows:ae,space:le});function F(e,t="",o="."){return Object.keys(e).reduce((r,n)=>{let l=`${t.length?`${t}${o}`:""}${n}`,c=e[n];return typeof c=="object"&&c!==null&&!Array.isArray(c)?Object.assign(r,F(c,l,o)):r[l]=c,r},{})}function z(e){return F(e,"--fr","-")}function ce(e,t="--fr"){let o={};return Object.keys(e).forEach(r=>{let n=e[r];typeof n=="object"&&n!==null&&!Array.isArray(n)?o[r]=ce(n,`${t}-${r}`):o[r]=`var(${t}-${r})`;}),o}var de=z(L),m=ce(L);var K=F(m.colors),fe={color:K,backgroundColor:K,borderColor:K,border:m.borders,borderRadius:m.radii,borderWidth:m.borderWidths,fontFamily:m.fontFamilies,fontSize:m.fontSizes,fontWeight:m.fontWeights,gap:m.space,lineHeight:m.lineHeights,margin:m.space,marginTop:m.space,marginRight:m.space,marginBottom:m.space,marginLeft:m.space,padding:m.space,paddingTop:m.space,paddingRight:m.space,paddingBottom:m.space,paddingLeft:m.space,alignContent:["center","start","end","flex-start","flex-end","normal","baseline","first baseline","last baseline","space-between","space-around","space-evenly","stretch","safe center","unsafe center","inherit","initial","revert","revert-layer","unset"],alignItems:["normal","stretch","center","start","end","flex-start","flex-end","self-start","self-end","baseline","first baseline","last baseline","safe center","unsafe center","inherit","initial","revert","revert-layer","unset"],alignSelf:["auto","normal","center","start","end","self-start","self-end","flex-start","flex-end","baseline","first baseline","last baseline","stretch","safe center","unsafe center","inherit","initial","revert","revert-layer","unset"],flexDirection:["row","row-reverse","column","column-reverse","inherit","initial","revert","revert-layer","unset"],flexWrap:["nowrap","wrap","wrap-reverse","inherit","initial","revert","revert-layer","unset"],justifyContent:["center","start","end","flex-start","flex-end","left","right","normal","space-between","space-around","space-evenly","stretch","safe center","unsafe center","inherit","initial","revert","revert-layer","unset"],justifyItems:["normal","stretch","center","start","end","flex-start","flex-end","self-start","self-end","left","right","baseline","first baseline","last baseline","safe center","unsafe center","legacy right","legacy left","legacy center","inherit","initial","revert","revert-layer","unset"],boxSizing:["border-box","content-box","inherit","initial","revert","revert-layer","unset"],position:["static","relative","absolute","fixed","sticky","inherit","initial","revert","revert-layer","unset"],display:["block","block flex","block flow","block flow-root","block grid","contents","flex","flow-root","grid","inherit","initial","inline","inline flex","inline flow","inline flow-root","inline grid","inline-block","inline-flex","inline-grid","list-item","none","revert","revert-layer","table","table-row-group","table-header-group","table-footer-group","table-row","table-cell","table-column-group","table-column","table-caption","unset"]},ue={m:["margin"],mt:["marginTop"],mr:["marginRight"],mb:["marginBottom"],ml:["marginLeft"],mx:["marginLeft","marginRight"],my:["marginTop","marginBottom"],p:["padding"],pt:["paddingTop"],pr:["paddingRight"],pb:["paddingBottom"],pl:["paddingLeft"],px:["paddingLeft","paddingRight"],py:["paddingTop","paddingBottom"]};function _e(e){if(Array.isArray(e))return new Map(e.map(t=>[t,t]));if(typeof e=="object"&&e!==null)return new Map(Object.entries(e));if(["string","number"].includes(typeof e))return new Map([e,e]);throw new Error("Invalid entry in styleProps")}var Xe=new Map(Object.entries(fe).map(([e,t])=>[e,_e(t)])),qe=new Map(Object.entries(ue).map(([e,t])=>[e,new Set(t)]));function me(e){let t=Object.assign({},e),o={};return Object.entries(t).forEach(([r,n])=>{let i=qe.get(r);i!=null&&(i.forEach(l=>{t[l]=n;}),delete t[r]);}),Object.entries(t).forEach(([r,n])=>{let i=Xe.get(r);if(i!=null)if(typeof n=="string"&&n.indexOf(" ")>-1){let l=n.split(" ");o[r]=l.map(c=>{var u;return (u=i.get(c.toString()))!=null?u:c}).join(" "),delete t[r];}else i.has(n.toString())&&(o[r]=i.get(n.toString()),delete t[r]);}),{cssFromProps:o,unmatchedProps:t}}function ge(e){return e&&`fr-${e}`}function Je(e){return e&&(Array.isArray(e)?e.map(t=>ge(t)).join(" "):ge(e))}function Qe(l,i){var c=l,{as:e,children:t,className:o,part:r}=c,n=f(c,["as","children","className","part"]);let u=e!=null?e:"div",{cssFromProps:d,unmatchedProps:h}=me(n),y=Je(r),w=o||y?clsx(o,y):void 0;return jsx(u,p(s({className:w,css:[{boxSizing:"border-box"},d]},h),{ref:i,children:t}))}var g=_.forwardRef(Qe);var U={};oe(U,{Body1:()=>it,Body2:()=>st,Caption:()=>at,Display1:()=>Ze,Display2:()=>et,H1:()=>tt,H2:()=>ot,H3:()=>rt,H4:()=>nt});var T={color:"neutral.foreground",fontFamily:"default",margin:0},Ze=p(s({},T),{fontSize:"5xl",fontWeight:"bold",lineHeight:"4xl"}),et=p(s({},T),{fontSize:"4xl",fontWeight:"bold",lineHeight:"3xl"}),tt=p(s({},T),{fontSize:"3xl",fontWeight:"bold",lineHeight:"2xl"}),ot=p(s({},T),{fontSize:"2xl",fontWeight:"bold",lineHeight:"xl"}),rt=p(s({},T),{fontSize:"xl",fontWeight:"bold",lineHeight:"lg"}),nt=p(s({},T),{fontSize:"lg",fontWeight:"bold",lineHeight:"md"}),it=p(s({},T),{fontSize:"md",fontWeight:"regular",lineHeight:"md"}),st=p(s({},T),{fontSize:"sm",fontWeight:"regular",lineHeight:"md"}),at=p(s({},T),{fontSize:"xs",fontWeight:"regular",lineHeight:"sm"});function be(n){var i=n,{as:e="span",children:t,variant:o="Body1"}=i,r=f(i,["as","children","variant"]);return jsx(g,p(s(s({as:e},U[o]),r),{children:t}))}var lt=["Display1","Display2","H1","H2","H3","H4","Body1","Body2","Caption"],pt=Object.fromEntries(lt.map(e=>{let t=["H1","H2","H3","H4"].includes(e)?e.toLowerCase():void 0,o=r=>jsx(be,p(s({as:t},r),{variant:e,children:r.children}));return o.displayName=`Text.${e}`,[e,o]})),B=Object.assign(be,pt);var N={};oe(N,{Link:()=>ft,Plain:()=>ut,Primary:()=>ct,Secondary:()=>dt,base:()=>O});var O=({radii:e,space:t})=>({borderWidth:0,borderRadius:e.md,padding:`${t[2]} ${t[4]}`}),ct=({colors:e})=>[O,{backgroundColor:e.primary.surface,color:e.primary.foreground,"&:hover":{backgroundColor:e.primary.hover.surface}}],dt=({colors:e})=>[O,{backgroundColor:e.secondary.surface,color:e.secondary.foreground,"&:hover":{backgroundColor:e.secondary.hover.surface}}],ft=({colors:e})=>[O,{backgroundColor:e.transparent,color:e.primary.surface,"&:hover":{color:e.primary.hover.surface}}],ut=({colors:e})=>[O,{backgroundColor:e.transparent,color:e.neutral.foreground}];function he(i){var l=i,{as:e,children:t,title:o,variant:r="Primary"}=l,n=f(l,["as","children","title","variant"]);return jsxs(g,p(s({as:e!=null?e:"button",css:N[r]},n),{children:[t,o&&jsx(B.Body2,{fontWeight:"demibold",color:"inherit",children:o})]}))}var mt=["Primary","Secondary","Link","Plain"],gt=Object.fromEntries(mt.map(e=>{let t=e.toLocaleLowerCase(),o=i=>{var l=i,{part:r}=l,n=f(l,["part"]);return jsx(he,p(s({part:[`button-${t}`,r]},n),{variant:e,children:n.children}))};return o.displayName=`Text.${e}`,[e,o]})),H=Object.assign(he,gt);var bt=_.forwardRef((n,r)=>{var i=n,{children:e,css:t}=i,o=f(i,["children","css"]);return jsx(g,p(s({css:[{display:"flex",flexDirection:"row"},t]},o),{ref:r,children:e}))}),yt=_.forwardRef((n,r)=>{var i=n,{children:e,css:t}=i,o=f(i,["children","css"]);return jsx(g,p(s({css:[{display:"flex",flexDirection:"column"},t]},o),{ref:r,children:e}))}),E={Column:yt,Row:bt};var S=createContext({apiKey:"",modals:[],setModals:()=>{},navigate:()=>{}});function wt(n){var i=n,{children:e,navigate:t,theme:o}=i,r=f(i,["children","navigate","theme"]);let l=o?z(o):{},[c,u]=useState([]),d=t!=null?t:(h,y="_self")=>{window.open(h,y);};return jsxs(S.Provider,{value:s({modals:c,setModals:u,navigate:d},r),children:[jsx(Global,{styles:{":root":s(s({},de),l)}}),jsx(ThemeProvider,{theme:m,children:e})]})}function Ce(){let e="DOMRect"in globalThis?new DOMRect:{height:0,width:0,x:0,y:0,bottom:0,top:0,right:0,left:0,toJSON:()=>{}},[t,o]=useState(e),[r,n]=useState(null),i=useCallback(l=>{n(l);},[]);return useLayoutEffect(()=>{r&&o(r.getBoundingClientRect());},[r]),{node:r,rect:t,ref:i}}var kt=keyframes({"0%":{opacity:.5,transform:"scale(0.5)"},"50%":{opacity:0,transform:"scale(1)"},"100%":{opacity:0,transform:"scale(1)"}});function Se(r){var n=r,{style:e={},part:t=""}=n,o=f(n,["style","part"]);return jsxs(g,p(s({part:`dot-wrapper ${t}`,style:s({height:"48px",position:"absolute",width:"48px"},e)},o),{children:[jsx(g,{backgroundColor:"primary.surface",part:"dot-pulse",css:{animation:`2s ease-out infinite ${kt}`,borderRadius:"24px",height:"48px",left:0,position:"absolute",top:0,transformOrigin:"center center",width:"48px"}}),jsx(g,{backgroundColor:"primary.surface",part:"dot",style:{borderRadius:"12px",height:"24px",left:"12px",position:"absolute",top:"12px",width:"24px"}})]}))}function Re(r){var n=r,{part:e,src:t}=n,o=f(n,["part","src"]);return jsx(g,s({as:"img",part:["image",e],src:t},o))}function Ht(e){var t,o,r;if(e.includes("youtube"))return `https://www.youtube.com/embed/${(t=e.split("v=")[1])==null?void 0:t.split("&")[0]}`;if(e.includes("vimeo"))return `https://player.vimeo.com/video/${(o=e.split("vimeo.com/")[1])==null?void 0:o.split("&")[0]}`;if(e.includes("wistia"))return `https://fast.wistia.net/embed/iframe/${(r=e.split("wistia.com/medias/")[1])==null?void 0:r.split("&")[0]}`;throw new Error("Could not map videoUri to a known provider (Youtube, Vimeo, Wistia).")}function ke(r){var n=r,{part:e,src:t}=n,o=f(n,["part","src"]);let i=Ht(t);return jsx(g,s({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"gray100",borderWidth:0,part:["video",e],src:i},o))}function X(r){var n=r,{src:e,type:t}=n,o=f(n,["src","type"]);return jsx(t==="video"?ke:Re,s({src:e},o))}function Fe({props:e,alignAttr:t,sideAttr:o}){let r=o!=null?o:"bottom",n={},i=()=>{var d;if(["after","before"].includes(e.align)){if(t=="start")return "before";if(t=="end")return "after"}return (d=e.align)!=null?d:"after"},l="-24px",c={top:"bottom",right:"left",bottom:"top",left:"right"};n[c[r]]=l;let u=i();return ["before","end"].includes(u)?["top","bottom"].includes(r)?n.right=l:n.bottom=l:["after","start"].includes(u)?["top","bottom"].includes(r)?n.left=l:n.top=l:["top","bottom"].includes(r)?n.left=`calc(50% + ${l})`:n.top=`calc(50% + ${l})`,n}var Oe={content:["align","alignOffset","arrowPadding","avoidCollisions","collisionBoundary","collisionPadding","forceMount","hideWhenDetached","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onInteractOutside","onOpenAutoFocus","onPointerDownOutside","side","sideOffset","sticky"],root:["defaultOpen","modal","onOpenChange","open"]};function He(e,t){var n,i,l,c,u;let o=Object.fromEntries(Oe.content.map(d=>[d,e[d]]).filter(d=>d[1]!==void 0)),r=Object.fromEntries(Oe.root.map(d=>[d,e[d]]).filter(d=>d[1]!==void 0));if(o.align=(n=o.align)!=null?n:"after",o.side=(i=o.side)!=null?i:"bottom",["before","after"].includes(o.align)){let d={after:"end",before:"start"},h=(A,I)=>["top","bottom"].includes(I)?A=="after"?"marginLeft":"marginRight":A=="after"?"marginTop":"marginBottom",y=(l=o.alignOffset)!=null?l:0,w=(c=o.style)!=null?c:{},P=(u=o.side)!=null?u:"bottom",M=o.align;o.style=p(s({},w),{[h(M,P)]:y});let D=["top","bottom"].includes(P)?t.width:t.height;o.alignOffset=(D+y)*-1,o.align=d[M];}return {contentProps:o,rootProps:r}}function x(l){var c=l,{anchor:e,children:t,className:o,spotlight:r=!1,style:n}=c,i=f(c,["anchor","children","className","spotlight","style"]);let{node:u,rect:d,ref:h}=Ce(),{contentProps:y,rootProps:w}=He(i,d),[P,M]=useState(y.align),[D,A]=useState(y.side);if(u!==null){let k=u.getAttribute("data-align"),Q=u.getAttribute("data-side");P!==k&&M(k),D!==Q&&A(Q);}let I=useRef(null),[V,$e]=useState(null);if(useEffect(()=>{let k=document.querySelector(e);k!=null&&(I.current=k,$e(I));},[e]),V==null)return null;let W=V.current.getBoundingClientRect(),J="0";typeof window!="undefined"&&(J=window.getComputedStyle(V.current).borderRadius);let je=Fe({props:i,alignAttr:P,sideAttr:D});return jsxs(v.Root,p(s({defaultOpen:!0},w),{children:[jsx(v.Anchor,{virtualRef:V}),jsx(v.Portal,{children:jsxs("div",{className:o,css:{position:"absolute",zIndex:9999},children:[r&&jsx(g,{borderRadius:J,part:"tooltip-spotlight",position:"absolute",css:{boxShadow:"0 0 0 2000px rgb(0 0 0 / 0.5)",height:W.height,left:W.left,top:W.top,width:W.width}}),jsx(v.Content,p(s({asChild:!0},y),{ref:h,children:jsxs(E.Column,{backgroundColor:"neutral.background",borderRadius:"md",p:5,part:"tooltip-content",position:"relative",css:s({boxShadow:"0px 4px 20px rgba(0, 0, 0, 0.1)",maxWidth:"360px"},n),children:[jsx(Se,{style:je}),t]})}))]})})]}))}x.Close=e=>jsx(v.Close,{"aria-label":"Close",asChild:!0,children:jsx(H.Plain,p(s({css:{top:"12px",right:"4px"},part:"tooltip-close",position:"absolute"},e),{children:jsx(XMarkIcon,{height:"24",fill:"currentColor"})}))});x.Media=o=>{var r=o,{src:e}=r,t=f(r,["src"]);return e==null?null:jsx(X,s({borderRadius:"md md 0 0",borderWidth:"0",css:{aspectRatio:"2"},margin:"-5 -5 5",src:e},t))};x.Primary=r=>{var n=r,{onClick:e,title:t}=n,o=f(n,["onClick","title"]);return t==null?null:jsx(H.Primary,s({title:t,onClick:e},o))};x.Progress=o=>{var r=o,{children:e}=r,t=f(r,["children"]);return e==null?null:jsx(B.Body2,p(s({fontWeight:"demibold",part:"progress"},t),{children:e}))};x.Secondary=r=>{var n=r,{onClick:e,title:t}=n,o=f(n,["onClick","title"]);return t==null?null:jsx(H.Secondary,s({title:t,onClick:e},o))};x.Subtitle=o=>{var r=o,{children:e}=r,t=f(r,["children"]);return e==null?null:jsx(B.Body2,p(s({part:"subtitle"},t),{children:e}))};x.Title=o=>{var r=o,{children:e}=r,t=f(r,["children"]);return e==null?null:jsx(B.Body1,p(s({fontWeight:"bold",mb:1,part:"title"},t),{children:e}))};function Ee(e){let[t,o]=useState(),{apiKey:r,apiUrl:n,userId:i}=useContext(S),c=useRef(new Frigade(r,{apiUrl:n,userId:i})).current,u=d=>{if(d.id!==e)return;let h=Object.assign(Object.create(Object.getPrototypeOf(d)),d);o(h);};return useEffect(()=>(C(this,null,function*(){let d=yield c.getFlow(e);o(d);}),c.onStateChange(u),()=>{c.removeStateChangeHandler(u);}),[]),{flow:t}}function De(e){let{modals:t,setModals:o}=useContext(S),[r,n]=useState(!1);return useEffect(()=>(o([...t,e]),()=>o(t.filter(i=>i!==e))),[]),useEffect(()=>{let i=t[0]===e;i!==r&&n(i);},[t]),{isCurrentModal:r}}function j(e,{onComplete:t,onDismiss:o}={}){let r=useRef(null);return useEffect(()=>{e!=null&&(e.isCompleted&&r.current===!1&&t(e),r.current=e==null?void 0:e.isCompleted);},[e==null?void 0:e.isCompleted]),{handleDismiss:useCallback(n=>C(this,null,function*(){if((o==null?void 0:o(e,n))===!1)return n.preventDefault(),!1;yield e.skip();}),[e])}}function Ie(e,{onPrimary:t,onSecondary:o}={}){let{navigate:r}=useContext(S);return {handlePrimary:useCallback(n=>C(this,null,function*(){if((t==null?void 0:t(e,n))===!1)return n.preventDefault(),!1;yield e.complete(),e.primaryButtonUri!=null&&r(e.primaryButtonUri,e.primaryButtonUriTarget);}),[e]),handleSecondary:useCallback(n=>C(this,null,function*(){if((o==null?void 0:o(e,n))===!1)return n.preventDefault(),!1;yield e.complete(),e.secondaryButtonUri!=null&&r(e.secondaryButtonUri,e.secondaryButtonUriTarget);}),[e])}}function We(l){var c=l,{step:e,flow:t,onDismiss:o,onPrimary:r,onSecondary:n}=c,i=f(c,["step","flow","onDismiss","onPrimary","onSecondary"]);var w;let{isCurrentModal:u}=De(`${t.id}-${e.id}`),{handleDismiss:d}=j(t,{onDismiss:o}),{handlePrimary:h,handleSecondary:y}=Ie(e,{onPrimary:r,onSecondary:n});return u?jsxs(x,p(s({anchor:e.selector,onOpenAutoFocus:P=>P.preventDefault(),onPointerDownOutside:P=>P.preventDefault()},i),{children:[jsx(x.Close,{onClick:d}),jsx(x.Media,{src:(w=e.videoUri)!=null?w:e.imageUri,type:e.videoUri?"video":"image"}),jsx(x.Title,{children:e.title}),jsx(x.Subtitle,{children:e.subtitle}),jsxs(E.Row,{alignItems:"center",gap:3,justifyContent:"flex-end",part:"tooltip-footer",pt:4,children:[jsx(x.Progress,{children:`${(e==null?void 0:e.order)+1}/${t.steps.size}`}),jsx(x.Secondary,{marginLeft:"auto",title:e.secondaryButtonTitle,onClick:y}),jsx(x.Primary,{title:e.primaryButtonTitle,onClick:h})]})]}),e.id):null}function qt(r){var n=r,{flowId:e,onComplete:t}=n,o=f(n,["flowId","onComplete"]);let{flow:i}=Ee(e);if(j(i,{onComplete:t}),i==null||i.isVisible===!1)return null;i.start();let l=i.getCurrentStep();return l==null||l.start(),jsx(We,s({step:l,flow:i},o))}
19
+ var wo=Object.defineProperty;var Ro=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,t)=>(typeof require<"u"?require:o)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var te=(e,o)=>{for(var t in o)wo(e,t,{get:o[t],enumerable:!0});};var Fe={borders:{md:"1px solid"},borderWidths:{0:"0",md:"1px"}};var Te={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",inherit:"inherit",red500:"#c00000"};var we={md:"10px",lg:"20px",round:"50%"};var l=e=>`var(--fr-colors-${e})`,Re={neutral:{background:l("white"),border:l("gray800"),foreground:l("black"),surface:l("gray700"),active:{background:l("white"),border:l("gray900"),foreground:l("black"),surface:l("gray700")},focus:{background:l("white"),border:l("gray900"),foreground:l("black"),surface:l("gray700")},hover:{background:l("white"),border:l("gray900"),foreground:l("black"),surface:l("gray700")}},primary:{background:l("blue500"),border:l("blue500"),foreground:l("white"),surface:l("blue500"),active:{background:l("blue400"),border:l("blue400"),foreground:l("white"),surface:l("blue400")},focus:{background:l("blue500"),border:l("blue500"),foreground:l("white"),surface:l("blue500")},hover:{background:l("blue400"),border:l("blue400"),foreground:l("white"),surface:l("blue400")}},secondary:{background:l("white"),border:l("gray800"),foreground:l("black"),surface:l("gray900"),active:{background:l("gray900"),border:l("gray800"),foreground:l("black"),surface:l("gray800")},focus:{background:l("gray900"),border:l("gray800"),foreground:l("black"),surface:l("gray900")},hover:{background:l("gray900"),border:l("gray800"),foreground:l("black"),surface:l("gray800")}}};var Be={md:"0px 4px 20px rgba(0, 0, 0, 0.1)"};var Bo="px",vo=e=>typeof e=="number"?`${4*e}${Bo}`:e,ko=[-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,-.5,0,.5,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,"auto"],ve=Object.fromEntries(ko.map(e=>[e,vo(e)]));var ke={fontFamilies:{default:"inherit"},fontSizes:{xs:"12px",sm:"14px",md:"16px",lg:"18px",xl:"20px","2xl":"24px","3xl":"30px","4xl":"36px","5xl":"48px"},fontWeights:{thin:"100",extralight:"200",light:"300",regular:"400",medium:"500",demibold:"600",bold:"700",extrabold:"800",black:"900"},letterSpacings:{md:"0.02em"},lineHeights:{xs:"18px",sm:"22px",md:"24px",lg:"26px",xl:"30px","2xl":"38px","3xl":"46px","4xl":"60px"}};var me={...Fe,colors:{...Te,...Re},...ke,radii:we,shadows:Be,space:ve};function X(e,o="",t="."){return Object.keys(e).reduce((n,r)=>{let a=`${o.length?`${o}${t}`:""}${r}`,s=e[r];return typeof s=="object"&&s!==null&&!Array.isArray(s)?Object.assign(n,X(s,a,t)):n[a]=s,n},{})}function ce(e){return X(e,"--fr","-")}function De(e,o="--fr"){let t={};return Object.keys(e).forEach(n=>{let r=e[n];typeof r=="object"&&r!==null&&!Array.isArray(r)?t[n]=De(r,`${o}-${n}`):t[n]=`var(${o}-${n})`;}),t}var Ee=ce(me),c=De(me);var Eo=new Set(["alt","size","src"]),Oo=Do.all.filter(e=>e.indexOf("-")!=0&&!Eo.has(e)).map(e=>[e.replace(/-([a-z])/g,(o,t)=>t.toUpperCase()),null]),Ho=Object.fromEntries(Oo),ue=X(c.colors),Mo={color:ue,backgroundColor:ue,borderColor:ue,border:c.borders,borderRadius:c.radii,borderWidth:c.borderWidths,boxShadow:c.shadows,fontFamily:c.fontFamilies,fontSize:c.fontSizes,fontWeight:c.fontWeights,gap:c.space,lineHeight:c.lineHeights,margin:c.space,marginBottom:c.space,marginLeft:c.space,marginRight:c.space,marginTop:c.space,padding:c.space,paddingBottom:c.space,paddingLeft:c.space,paddingRight:c.space,paddingTop:c.space},Oe={...Ho,...Mo},He={bg:["backgroundColor"],m:["margin"],mt:["marginTop"],mr:["marginRight"],mb:["marginBottom"],ml:["marginLeft"],mx:["marginLeft","marginRight"],my:["marginTop","marginBottom"],p:["padding"],pt:["paddingTop"],pr:["paddingRight"],pb:["paddingBottom"],pl:["paddingLeft"],px:["paddingLeft","paddingRight"],py:["paddingTop","paddingBottom"]},Me=new Set(["active","focus","focusVisible","focusWithin","hover"]);function Io(e){return Array.isArray(e)?new Map(e.map(o=>[o,o])):typeof e=="object"&&e!==null?new Map(Object.entries(e)):typeof e=="string"||typeof e=="number"?new Map([[e,e]]):new Map}var Ie=new Map(Object.entries(Oe).map(([e,o])=>[e,Io(o)])),Ao=new Map(Object.entries(He).map(([e,o])=>[e,new Set(o)])),Vo=new Set(["height","width"]),Lo=new Set(["canvas","embed","iframe","img","input","object","video"]);function Ae(e){let[o,t]=e.split(":");return [o,Me.has(t)?t:null]}function Ve(e,o="div"){let t=Object.assign({},e),n={};function r(i){if(i==null)return n;let s=`&:${i.replace(/[A-Z]/g,d=>`-${d.toLocaleLowerCase()}`)}`;return n[s]==null&&(n[s]={}),n[s]}return Object.entries(t).forEach(([i,a])=>{let[s,d]=Ae(i),f=Ao.get(s);f!=null&&(f.forEach(g=>{let y=`${g}${d?":"+d:""}`;t[y]=a;}),delete t[i]);}),Object.entries(t).forEach(([i,a])=>{let[s,d]=Ae(i),f=Ie.get(s);if(f!=null){if(typeof a=="string"&&a.indexOf(" ")>-1){let g=a.split(" ");r(d)[s]=g.map(y=>f.get(y.toString())??y).join(" ");}else f.has(a.toString())?r(d)[s]=f.get(a.toString()):r(d)[s]=a;(typeof o!="string"||!Lo.has(o)||!Vo.has(s))&&delete t[i];}}),Object.keys(t).forEach(i=>{let a=i.substring(1);i.indexOf("_")===0&&Ie.has(a)&&(t[a]=t[i],delete t[i]);}),{cssFromProps:n,unmatchedProps:t}}function $o(){if(typeof window>"u"){let{JSDOM:e}=Ro("jsdom");return new e("<!DOCTYPE html>").window}return window}function Le(e){return e?{__html:Wo($o()).sanitize(e,{ALLOWED_TAGS:["b","i","a","span","div","p","pre","u","br","img","code","li","ul","table","tbody","thead","tr","td","th","h1","h2","h3","h4","video"],ALLOWED_ATTR:["style","class","target","id","href","alt","src","controls","autoplay","loop","muted"]})}:{__html:""}}function _o(e){return e&&`fr-${e}`}function ze(e){return e&&(Array.isArray(e)?e.map(o=>ze(o)).join(" "):_o(e))}function jo({as:e,children:o,className:t,css:n={},part:r,...i},a){let s=e??"div",{cssFromProps:d,unmatchedProps:f}=Ve(i,s),g=ze(r),y=t||g?clsx(t,g):void 0,b=[{boxSizing:"border-box"},d,n];return typeof o=="string"?jsx(s,{className:y,css:b,...f,ref:a,dangerouslySetInnerHTML:Le(o)}):jsx(s,{className:y,css:b,...f,ref:a,children:o})}var p=xe.forwardRef(jo);var m={};te(m,{Body1:()=>at,Body2:()=>st,Caption:()=>lt,Display1:()=>et,Display2:()=>ot,H1:()=>tt,H2:()=>rt,H3:()=>nt,H4:()=>it});var fe={};te(fe,{Body1:()=>qo,Body2:()=>Yo,Caption:()=>Qo,Display1:()=>Ko,Display2:()=>No,H1:()=>Uo,H2:()=>Go,H3:()=>Xo,H4:()=>Jo});var E={color:"neutral.foreground",fontFamily:"default",margin:"0"},Ko={...E,fontSize:"5xl",fontWeight:"bold",lineHeight:"4xl"},No={...E,fontSize:"4xl",fontWeight:"bold",lineHeight:"3xl"},Uo={...E,fontSize:"3xl",fontWeight:"demibold",lineHeight:"2xl"},Go={...E,fontSize:"2xl",fontWeight:"demibold",lineHeight:"xl"},Xo={...E,fontSize:"xl",fontWeight:"demibold",lineHeight:"lg"},Jo={...E,fontSize:"md",fontWeight:"demibold",lineHeight:"md"},qo={...E,fontSize:"md",fontWeight:"regular",lineHeight:"md"},Yo={...E,fontSize:"sm",fontWeight:"regular",lineHeight:"sm"},Qo={...E,fontSize:"xs",fontWeight:"regular",lineHeight:"xs"};var Zo=["Display1","Display2","H1","H2","H3","H4","Body1","Body2","Caption"],O=Object.fromEntries(Zo.map(e=>{let o=["H1","H2","H3","H4"].includes(e)?e.toLowerCase():"span",t=xe.forwardRef(({as:n=o,children:r,...i},a)=>jsx(p,{as:n,...fe[e],...i,ref:a,children:r}));return t.displayName=`Text.${e}`,[e,t]})),et=O.Display1,ot=O.Display2,tt=O.H1,rt=O.H2,nt=O.H3,it=O.H4,at=O.Body1,st=O.Body2,lt=O.Caption;var ge={};te(ge,{Link:()=>ct,Plain:()=>ut,Primary:()=>dt,Secondary:()=>mt});var re={borderWidth:"0",borderRadius:"md",display:"flex",gap:"2",padding:"2 4"},dt={...re,backgroundColor:"primary.surface",color:"primary.foreground","backgroundColor:hover":"primary.hover.surface"},mt={...re,backgroundColor:"secondary.background",borderColor:"secondary.border",borderStyle:"solid",borderWidth:"1px",color:"secondary.foreground","backgroundColor:hover":"secondary.hover.background"},ct={...re,backgroundColor:"transparent",color:"primary.surface","color:hover":"primary.hover.surface"},ut={...re,backgroundColor:"transparent",color:"neutral.foreground"};function je({as:e,children:o,part:t,title:n,variant:r="Primary",...i}){let a=r.toLocaleLowerCase();return jsxs(p,{as:e??"button",part:[`button-${a}`,t],...ge[r],...i,children:[o,n&&jsx(m.Body2,{color:"inherit",flexGrow:"1",fontWeight:"demibold",transform:"translateY(1px)",css:{"-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale"},children:n})]})}var ft=["Primary","Secondary","Link","Plain"],gt=Object.fromEntries(ft.map(e=>{let o=t=>jsx(je,{...t,variant:e,children:t.children});return o.displayName=`Button.${e}`,[e,o]})),h=Object.assign(je,gt);var x={};te(x,{Column:()=>ht,Row:()=>yt});var yt=xe.forwardRef(({children:e,css:o,...t},n)=>jsx(p,{css:[{display:"flex",flexDirection:"row"},o],...t,ref:n,children:e})),ht=xe.forwardRef(({children:e,css:o,...t},n)=>jsx(p,{css:[{display:"flex",flexDirection:"column"},o],...t,ref:n,children:e}));var v=createContext({apiKey:"",modals:new Set,setModals:()=>{},currentModal:null,navigate:()=>{}});function Rt({children:e,navigate:o,theme:t,...n}){let r=t?ce(t):{},[i,a]=useState(new Set),s=useMemo(()=>new Frigade(n.apiKey,{apiKey:n.apiKey,apiUrl:n.apiUrl,userId:n.userId,groupId:n.groupId,__readOnly:n.__readOnly,__flowConfigOverrides:n.__flowConfigOverrides}),[n.userId,n.groupId,n.apiKey]),d=o??((g,y="_self")=>{window.open(g,y);});useEffect(()=>()=>{s.destroy();},[]);let f=i.size>0?i.values().next().value:null;return jsxs(v.Provider,{value:{modals:i,setModals:a,currentModal:f,navigate:d,...n,frigade:s},children:[jsx(Global,{styles:{":root":{...Ee,...r}}}),jsx(ThemeProvider,{theme:c,children:e})]})}function J(e,o){let[t,n]=useState(),[,r]=useState(""),{frigade:i}=useContext(v),a=s=>{s.id===e&&(o!=null&&o.variables&&s.applyVariables(o.variables),n(s),r(Math.random().toString()));};return useEffect(()=>((async()=>{let s=await i.getFlow(e);if(!s||i.hasFailedToLoad()){n(void 0);return}o!=null&&o.variables&&s.applyVariables(o.variables),n(s);})(),i.onStateChange(a),()=>{i.removeStateChangeHandler(a);}),[]),{flow:t}}function L(e,{onComplete:o,onDismiss:t}={}){let n=useRef(null);return useEffect(()=>{e!=null&&(e.isCompleted&&n.current===!1&&(async()=>await(o==null?void 0:o(e)))(),n.current=e==null?void 0:e.isCompleted);},[e==null?void 0:e.isCompleted]),{handleDismiss:useCallback(async r=>{if(await(t==null?void 0:t(e,r))===!1)return r.preventDefault(),!1;await e.skip();},[e])}}function q(e,{onPrimary:o,onSecondary:t}={}){let{navigate:n}=useContext(v);return {handlePrimary:useCallback(async(r,i)=>await(o==null?void 0:o(e,r))===!1?(r.preventDefault(),!1):(await e.complete(i),e.primaryButtonUri!=null&&n(e.primaryButtonUri,e.primaryButtonUriTarget),!0),[e]),handleSecondary:useCallback(async(r,i)=>await(t==null?void 0:t(e,r))===!1?(r.preventDefault(),!1):(await e.complete(i),e.secondaryButtonUri!=null&&n(e.secondaryButtonUri,e.secondaryButtonUriTarget),!0),[e])}}function Y(e){let{currentModal:o,modals:t,setModals:n}=useContext(v),[r,i]=useState(!1);useEffect(()=>{e!=null&&e.isVisible&&e&&!t.has(e.id)&&n(s=>new Set(s).add(e.id));},[e==null?void 0:e.id,e==null?void 0:e.isVisible]),useEffect(()=>{let s=o===(e==null?void 0:e.id);(e==null?void 0:e.id)!=null&&s!==r&&i(s);},[e==null?void 0:e.id,o]);function a(){t.has(e==null?void 0:e.id)&&n(s=>{let d=new Set(s);return d.delete(e==null?void 0:e.id),d});}return {isCurrentModal:r,removeModal:a}}function I({as:e,container:o,dismissible:t=o==="dialog",flowId:n,onComplete:r,onDismiss:i,onPrimary:a,onSecondary:s,variables:d,...f}){let g=o==="dialog"?F:e??p,y=function({children:Z,...se}){let{flow:P}=J(n,{variables:d}),U=P==null?void 0:P.getCurrentStep(),{handleDismiss:le}=L(P,{onComplete:r,onDismiss:i}),{handlePrimary:pe,handleSecondary:de}=q(U,{onPrimary:a,onSecondary:s}),{isCurrentModal:G,removeModal:ee}=Y(P);return useEffect(()=>{!(P!=null&&P.isVisible)&&G&&ee();},[P==null?void 0:P.isVisible,G]),P==null||!P.isVisible||!G?null:(P.start(),U.start(),jsx(g,{position:"relative",...se,...f,children:Z({flow:P,handleDismiss:le,handlePrimary:pe,handleSecondary:de,parentProps:{container:o,dismissible:t,flowId:n,variables:d,...f},step:U})}))};return {FlowComponent:useMemo(()=>y,[])}}function qe(e){let{FlowComponent:o}=I(e);return jsx(o,{as:u,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",children:({handleDismiss:t,handlePrimary:n,handleSecondary:r,parentProps:{dismissible:i},step:a})=>jsxs(Fragment,{children:[jsxs(x.Row,{alignItems:"center",flexWrap:"wrap",gap:1,justifyContent:"space-between",part:"card-header",children:[jsx(u.Title,{children:a.title}),i&&jsx(u.Dismiss,{onClick:t}),jsx(u.Subtitle,{flexBasis:"100%",children:a.subtitle})]}),jsx(u.Media,{src:a.imageUri,css:{objectFit:"contain",width:"100%"}}),jsxs(x.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsx(u.Secondary,{title:a.secondaryButtonTitle,onClick:r}),jsx(u.Primary,{title:a.primaryButtonTitle??"Continue",onClick:n})]})]})})}function Ye({part:e,src:o,...t}){return jsx(p,{as:"img",part:["image",e],src:o,...t})}function zt(e){var o,t,n,r;if(e.includes("youtube"))return `https://www.youtube.com/embed/${(o=e.split("v=")[1])==null?void 0:o.split("&")[0]}`;if(e.includes("vimeo"))return `https://player.vimeo.com/video/${(t=e.split("vimeo.com/")[1])==null?void 0:t.split("&")[0]}`;if(e.includes("wistia"))return `https://fast.wistia.net/embed/iframe/${(n=e.split("wistia.com/medias/")[1])==null?void 0:n.split("&")[0]}`;if(e.includes("loom"))return `https://loom.com/embed/${(r=e.split("loom.com/share/")[1])==null?void 0:r.split("&")[0]}?hideEmbedTopBar=true&hide_title=true&hide_share=true&hide_owner=true`;throw new Error("Could not map videoUri to a known provider (Youtube, Vimeo, Wistia, Loom).")}function Qe({part:e,src:o,...t}){let n=zt(o);return jsx(p,{allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"gray100",borderWidth:0,part:["video",e],src:n,...t})}function $({src:e,type:o,...t}){return jsx(o==="video"?Qe:Ye,{src:e,...t})}var u=xe.forwardRef(({as:e,children:o,...t},n)=>{if(t.flowId!=null)return jsx(qe,{as:e,...t});let r=e??x.Column;return jsx(r,{backgroundColor:"neutral.background",borderRadius:"md",gap:5,p:5,...t,ref:n,children:o})});u.Dismiss=e=>jsx(h.Plain,{part:"dismiss",padding:0,...e,children:jsx(XMarkIcon,{height:"24",fill:"currentColor"})});u.Media=({src:e,...o})=>e==null?null:jsx($,{borderRadius:"md",src:e,...o});u.Primary=({onClick:e,title:o,...t})=>o==null?null:jsx(h.Primary,{title:o,onClick:e,...t});u.Secondary=({onClick:e,title:o,...t})=>o==null?null:jsx(h.Secondary,{title:o,onClick:e,...t});u.Subtitle=({children:e,...o})=>e==null?null:jsx(m.Body2,{display:"block",part:"subtitle",...o,children:e});u.Title=({children:e,...o})=>e==null?null:jsx(m.Body1,{display:"block",fontWeight:"bold",part:"title",...o,children:e});function F({children:e,...o}){return jsx(w.Root,{defaultOpen:!0,modal:!0,children:jsx(w.Portal,{children:jsxs(p,{inset:"0",position:"fixed",zIndex:"9999",children:[jsx(w.Overlay,{asChild:!0,children:jsx(p,{background:"rgb(0 0 0 / 0.5)",part:"dialog-overlay",position:"fixed",inset:"0"})}),jsx(w.Content,{asChild:!0,onOpenAutoFocus:t=>t.preventDefault(),onPointerDownOutside:t=>t.preventDefault(),children:jsx(u,{boxShadow:"md",left:"50%",maxWidth:"430px",p:8,part:"dialog-content",position:"fixed",textAlign:"center",top:"50%",transform:"translate(-50%, -50%)",...o,children:e})})]})})})}F.Dismiss=e=>jsx(w.Close,{"aria-label":"Close",asChild:!0,children:jsx(h.Plain,{part:"close",position:"absolute",right:"-4px",top:"4px",...e,children:jsx(XMarkIcon,{height:"24",fill:"currentColor"})})});F.Subtitle=({children:e,...o})=>jsx(w.Description,{asChild:!0,children:jsx(m.Body2,{part:"subtitle",...o,children:e})});F.Media=({src:e,...o})=>e==null?null:jsx($,{borderRadius:"md",src:e,...o});F.Primary=({onClick:e,title:o,...t})=>o==null?null:jsx(h.Primary,{title:o,onClick:e,...t});F.ProgressDots=({current:e,total:o})=>{if(o==1)return null;let t=[...Array(o)].map((n,r)=>jsx("circle",{r:4,cx:4+16*r,cy:"4px",fill:e===r?c.colors.blue500:c.colors.blue800},r));return jsx(p,{as:"svg",height:"8px",marginInline:"auto",part:"progress",viewBox:`0 0 ${16*o-8} 8`,width:16*o-8,children:t})};F.Secondary=({onClick:e,title:o,...t})=>o==null?null:jsx(h.Secondary,{title:o,onClick:e,...t});F.Title=({children:e,...o})=>jsx(w.Title,{asChild:!0,children:jsx(m.H3,{part:"title",...o,children:e})});function Gt(e){let{FlowComponent:o}=I({...e,container:"dialog"});return jsx(o,{children:({flow:t,handleDismiss:n,handlePrimary:r,handleSecondary:i,parentProps:{dismissible:a},step:s})=>jsxs(Fragment,{children:[a&&jsx(F.Dismiss,{onClick:n}),jsxs(x.Column,{gap:1,part:"announcement-header",children:[jsx(F.Title,{children:s.title}),jsx(F.Subtitle,{children:s.subtitle})]}),jsx(F.Media,{src:s.videoUri??s.imageUri,type:s.videoUri?"video":"image",css:{aspectRatio:"1.5",objectFit:"cover",width:"100%"}}),jsx(F.ProgressDots,{current:t.getNumberOfCompletedSteps(),total:t.getNumberOfAvailableSteps()}),jsxs(x.Row,{css:{"& > button":{flexGrow:1}},gap:3,part:"announcement-footer",children:[s.secondaryButtonTitle&&jsx(F.Secondary,{title:s.secondaryButtonTitle,onClick:i}),jsx(F.Primary,{title:s.primaryButtonTitle??"Continue",onClick:r})]})]})})}function Jt(e){let{FlowComponent:o}=I(e);return jsx(o,{as:u,border:"md",borderColor:"neutral.border",display:"flex",flexDirection:"row",gap:3,justifyContent:"space-between",children:({handleDismiss:t,handlePrimary:n,handleSecondary:r,step:i})=>jsxs(Fragment,{children:[jsxs(x.Row,{gap:3,children:[i.imageUri&&jsx("img",{src:i.imageUri,style:{height:40,width:40,alignSelf:"center"}}),jsxs(x.Column,{children:[jsx(m.H4,{mb:1,children:i.title}),jsx(m.Body2,{color:"gray500",children:i.subtitle})]})]}),jsxs(x.Row,{alignItems:"center",gap:3,justifyContent:"center",children:[i.secondaryButtonTitle&&jsx(h.Secondary,{title:i.secondaryButtonTitle,onClick:r}),jsx(h.Primary,{title:i.primaryButtonTitle,onClick:n}),e.dismissible&&jsx(u.Dismiss,{onClick:t})]})]})})}var Zt=new Set(["required","min","max","minLength","maxLength","pattern"]);function er({fieldComponent:e,control:o,fieldData:t}){t.pattern!=null&&(typeof t.pattern=="string"?t.pattern=new RegExp(t.pattern.replace(/^\/|\/$/g,"")):typeof t.pattern=="object"&&typeof t.pattern.value=="string"&&(t.pattern.value=new RegExp(t.pattern.value.replace(/^\/|\/$/g,""))));let n=Object.fromEntries(Object.entries(t).filter(([i])=>Zt.has(i))),r=useController({name:t.id,control:o,rules:n});return jsx(e,{...r,fieldData:t})}function eo({fieldTypes:e,handleDismiss:o,handlePrimary:t,handleSecondary:n,parentProps:{dismissible:r},step:i}){var y;let{control:a,handleSubmit:s}=useForm({delayError:2e3,mode:"onChange"}),d=[];function f(b,K){t(K,b);}function g(b,K){n(K,b);}return (y=i.fields)==null||y.forEach(b=>{e[b.type]!=null&&d.push(jsx(er,{control:a,fieldComponent:e[b.type],fieldData:b},b.id));}),jsxs(x.Column,{gap:5,children:[jsxs(x.Row,{alignItems:"center",flexWrap:"wrap",gap:1,justifyContent:"space-between",part:"form-header",children:[jsx(u.Title,{children:i.title}),r&&jsx(u.Dismiss,{onClick:o}),jsx(u.Subtitle,{flexBasis:"100%",children:i.subtitle})]}),d,jsxs(x.Row,{part:"form-footer",justifyContent:"flex-end",gap:3,children:[i.secondaryButtonTitle&&jsx(h.Secondary,{title:i.secondaryButtonTitle,onClick:s(g)}),jsx(h.Primary,{title:i.primaryButtonTitle??"Submit",onClick:s(f)})]},"form-footer")]})}function oo({error:e}){var o;return (o=e==null?void 0:e.message)!=null&&o.length?jsx(m.Caption,{color:"red500",display:"block",part:"field-error",textAlign:"end",children:e==null?void 0:e.message}):null}function to({children:e,id:o,required:t=!1}){return jsxs(m.H4,{as:"label",htmlFor:o,part:"field-label",children:[e,t&&" *"]})}var Q={px:"4",py:"2",backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",borderRadius:"md",display:"block",outline:"none",width:"100%"};function V({children:e,field:o,fieldData:t,fieldState:n}){let{id:r,label:i,placeholder:a}=t,{error:s}=n,d={id:r,...o,...a?{placeholder:a}:{},...Q,"aria-invalid":!!s,value:o.value??""};return jsxs(p,{part:"field",children:[jsx(to,{id:r,required:!!t.required,children:i}),e(d),jsx(oo,{error:s})]})}var nr=()=>jsx(p,{as:"svg",color:"primary.foreground",width:"10px",height:"8px",viewBox:"0 0 10 8",fill:"none",children:jsx("path",{d:"M1 4.34664L3.4618 6.99729L3.4459 6.98017L9 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),ir=xe.forwardRef(({label:e,value:o},t)=>jsxs(p,{as:"label",backgroundColor:"neutral.background",borderColor:"neutral.border",borderRadius:"md",borderStyle:"solid",borderWidth:"md",display:"flex",htmlFor:o,justifyContent:"space-between",part:"field-radio",px:4,py:2,children:[jsx(m.Body2,{part:"field-radio-label",children:e}),jsx(N.Item,{id:o,value:o,ref:t,asChild:!0,children:jsx(p,{as:"button",backgroundColor:"inherit",borderWidth:"md",borderStyle:"solid",borderColor:"neutral.border",borderRadius:"100%",padding:"0",part:"field-radio-value",position:"relative",height:"24px",width:"24px",children:jsx(p,{as:N.Indicator,alignItems:"center",bg:"primary.surface",borderWidth:"md",borderStyle:"solid",borderColor:"primary.border",borderRadius:"100%",display:"flex",height:"calc(100% + 2px)",justifyContent:"center",left:"-1px",part:"field-radio-indicator",position:"absolute",top:"-1px",width:"calc(100% + 2px)",children:jsx(nr,{})})})})]}));function ao(e){let{field:{onChange:o,value:t},fieldData:{options:n=[]}}=e,r=n.map(({label:i,value:a})=>jsx(ir,{value:a,label:i},a));return jsx(V,{...e,children:()=>jsx(N.Root,{value:t,onValueChange:o,asChild:!0,children:jsx(x.Column,{gap:2,part:"field-radio-group",children:r})})})}var lr=xe.forwardRef(({label:e,value:o},t)=>jsx(S.Item,{value:o,ref:t,asChild:!0,children:jsx(p,{"backgroundColor:hover":"blue900",borderRadius:"md",outline:"none",part:"field-select-option",px:"3",py:"2",children:jsx(S.ItemText,{asChild:!0,children:jsx(m.Body2,{part:"field-select-option-label",children:e})})})}));function po(e){let{field:{onChange:o,value:t},fieldData:{options:n=[],placeholder:r}}=e,i=n.map(({label:a,value:s})=>jsx(lr,{value:s,label:a},s));return jsx(V,{...e,children:()=>jsxs(S.Root,{value:t,onValueChange:o,children:[jsx(S.Trigger,{asChild:!0,children:jsxs(m.Body2,{...Q,alignItems:"center",display:"flex",justifyContent:"space-between",part:"field-select",children:[jsx(S.Value,{placeholder:r??"Select one"}),jsx(S.Icon,{children:jsx(p,{as:ChevronDownIcon,color:"gray100",display:"block",height:"24px",part:"field-select-icon",width:"24px"})})]})}),jsx(S.Portal,{children:jsx(S.Content,{position:"popper",sideOffset:4,asChild:!0,children:jsx(p,{...Q,p:"1",part:"field-select-options",width:"var(--radix-popper-anchor-width)",children:jsx(S.Viewport,{children:i})})})})]})})}function co(e){return jsx(V,{...e,children:o=>jsx(m.Body2,{as:"input",part:"field-text",type:"text",...o})})}function fo(e){return jsx(V,{...e,children:o=>jsx(m.Body2,{as:"textarea",part:"field-textarea",...o})})}var pr={radio:ao,select:po,text:co,textarea:fo};function dr({fieldTypes:e={},...o}){let{FlowComponent:t}=I(o),n=Object.assign({},pr,e);return jsx(t,{children:r=>jsx(eo,{fieldTypes:n,...r})})}function ie(){let e="DOMRect"in globalThis?new DOMRect:{height:0,width:0,x:0,y:0,bottom:0,top:0,right:0,left:0,toJSON:()=>{}},[o,t]=useState(e),[n,r]=useState(null),i=useCallback(a=>{r(a);},[]);return useLayoutEffect(()=>{if(!n)return;let a=()=>{let s=n.getBoundingClientRect();t(s);};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[n]),{node:n,rect:o,ref:i}}var fr=keyframes({"0%":{opacity:.5,transform:"scale(0.5)"},"50%":{opacity:0,transform:"scale(1)"},"100%":{opacity:0,transform:"scale(1)"}});function ho({style:e={},part:o="",...t}){return jsxs(p,{part:`dot-wrapper ${o}`,style:{height:"48px",position:"absolute",width:"48px",...e},...t,children:[jsx(p,{backgroundColor:"primary.surface",part:"dot-pulse",css:{animation:`2s ease-out infinite ${fr}`,borderRadius:"24px",height:"48px",left:0,position:"absolute",top:0,transformOrigin:"center center",width:"48px"}}),jsx(p,{backgroundColor:"primary.surface",part:"dot",style:{borderRadius:"12px",height:"24px",left:"12px",position:"absolute",top:"12px",width:"24px"}})]})}function bo({props:e,alignAttr:o,sideAttr:t}){let n=t??"bottom",r={},i=()=>{if(["after","before"].includes(e.align)){if(o=="start")return "before";if(o=="end")return "after"}return e.align??"after"},a="-24px",s={top:"bottom",right:"left",bottom:"top",left:"right"};r[s[n]]=a;let d=i();return ["before","end"].includes(d)?["top","bottom"].includes(n)?r.right=a:r.bottom=a:["after","start"].includes(d)?["top","bottom"].includes(n)?r.left=a:r.top=a:["top","bottom"].includes(n)?r.left=`calc(50% + ${a})`:r.top=`calc(50% + ${a})`,r}var Po={content:["align","alignOffset","arrowPadding","avoidCollisions","collisionBoundary","collisionPadding","forceMount","hideWhenDetached","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onInteractOutside","onOpenAutoFocus","onPointerDownOutside","side","sideOffset","sticky"],root:["defaultOpen","modal","onOpenChange","open"]};function Co(e,o){let t=Object.fromEntries(Po.content.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),n=Object.fromEntries(Po.root.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0));if(t.align=t.align??"after",t.side=t.side??"bottom",["before","after"].includes(t.align)){let r={after:"end",before:"start"},i=(y,b)=>["top","bottom"].includes(b)?y=="after"?"marginLeft":"marginRight":y=="after"?"marginTop":"marginBottom",a=t.alignOffset??0,s=t.style??{},d=t.side??"bottom",f=t.align;t.style={...s,[i(f,d)]:a};let g=["top","bottom"].includes(d)?o.width:o.height;t.alignOffset=(g+a)*-1,t.align=r[f];}return {contentProps:t,rootProps:n}}function T({anchor:e,children:o,className:t,spotlight:n=!1,style:r,...i}){let{node:a,rect:s,ref:d}=ie(),{node:f,rect:g,ref:y}=ie(),{contentProps:b,rootProps:K}=Co(i,s),[Z,se]=useState(b.align),[P,U]=useState(b.side),[le,pe]=useState(0),[de,G]=useState(0);if(a!==null){let M=a.getAttribute("data-align"),oe=a.getAttribute("data-side");Z!==M&&se(M),P!==oe&&U(oe);}let ee=useRef(null);if(useEffect(()=>{let M=document.querySelector(e);M!=null&&(y(M),ee.current=M);},[e]),useEffect(()=>{let{scrollX:M,scrollY:oe}=window;pe(g.left+M),G(g.top+oe);},[g.left,g.top]),f==null)return null;let Se="0";typeof window<"u"&&(Se=window.getComputedStyle(f).borderRadius);let To=bo({props:i,alignAttr:Z,sideAttr:P});return jsxs(D.Root,{defaultOpen:!0,...K,children:[jsx(D.Anchor,{virtualRef:ee}),jsx(D.Portal,{children:jsxs("div",{className:t,css:{bottom:0,left:0,position:"absolute",right:0,top:0,zIndex:9999},children:[n&&jsx(p,{part:"tooltip-spotlight",position:"absolute",style:{borderRadius:Se,boxShadow:"0 0 0 20000px rgb(0 0 0 / 0.5)",height:g.height,left:le,top:de,width:g.width}}),jsx(D.Content,{asChild:!0,...b,ref:d,children:jsxs(u,{boxShadow:"md",part:"tooltip-content",position:"relative",css:{maxWidth:"360px",...r},children:[jsx(ho,{style:To}),o]})})]})})]})}T.Close=e=>jsx(D.Close,{"aria-label":"Close",asChild:!0,children:jsx(h.Plain,{css:{top:"12px",right:"4px"},part:"close",position:"absolute",...e,children:jsx(XMarkIcon,{height:"24",fill:"currentColor"})})});T.Media=({src:e,...o})=>e==null?null:jsx($,{borderRadius:"md md 0 0",borderWidth:"0",css:{aspectRatio:"2",objectFit:"cover"},margin:"-5 -5 0",src:e,...o});T.Primary=({onClick:e,title:o,...t})=>o==null?null:jsx(h.Primary,{title:o,onClick:e,...t});T.Progress=({children:e,...o})=>e==null?null:jsx(m.H4,{part:"progress",...o,children:e});T.Secondary=({onClick:e,title:o,...t})=>o==null?null:jsx(h.Secondary,{title:o,onClick:e,...t});T.Subtitle=({children:e,...o})=>e==null?null:jsx(m.Body2,{part:"subtitle",...o,children:e});T.Title=({children:e,...o})=>e==null?null:jsx(m.H4,{part:"title",...o,children:e});function Fo({dismissible:e=!0,flow:o,onDismiss:t,onPrimary:n,onSecondary:r,step:i,...a}){let{handleDismiss:s}=L(o,{onDismiss:t}),{handlePrimary:d,handleSecondary:f}=q(i,{onPrimary:n,onSecondary:r});return jsxs(T,{anchor:i.selector,onOpenAutoFocus:g=>g.preventDefault(),onPointerDownOutside:g=>g.preventDefault(),...a,children:[e&&jsx(T.Close,{onClick:s}),jsx(T.Media,{src:i.videoUri??i.imageUri,type:i.videoUri?"video":"image"}),jsxs(x.Column,{gap:1,part:"tooltip-header",children:[jsx(T.Title,{children:i.title}),jsx(T.Subtitle,{color:"gray500",children:i.subtitle})]}),jsxs(x.Row,{alignItems:"center",gap:3,justifyContent:"flex-end",part:"tooltip-footer",children:[jsx(T.Progress,{marginRight:"auto",transform:"translateY(1px)",children:`${o.getNumberOfCompletedSteps()+1}/${o.getNumberOfAvailableSteps()}`}),jsx(T.Secondary,{title:i.secondaryButtonTitle,onClick:f}),jsx(T.Primary,{title:i.primaryButtonTitle,onClick:d})]})]},i.id)}function br({flowId:e,onComplete:o,variables:t,...n}){let{flow:r}=J(e,{variables:t});L(r,{onComplete:o});let{isCurrentModal:i,removeModal:a}=Y(r);if(useEffect(()=>{!(r!=null&&r.isVisible)&&i&&a();},[r==null?void 0:r.isVisible,i]),r==null||r.isVisible===!1||!i)return null;r.start();let s=r.getCurrentStep();return s==null||s.start(),jsx(Fo,{step:s,flow:r,...n})}function Sr(){let{frigade:e}=useContext(v);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function Tr(){let{userId:e,frigade:o}=useContext(v);async function t(r){await o.identify(e,r);}async function n(r,i){await o.track(r,i);}return {userId:e,addProperties:t,track:n}}function Rr(){let{groupId:e,frigade:o}=useContext(v);async function t(r){if(!e){console.error("No Group ID is set. Cannot set properties without a Group ID.");return}await o.group(e,r);}async function n(r,i){await o.track(r,i);}return {groupId:e,addProperties:t,track:n}}
12
20
 
13
- export { g as Box, H as Button, E as Flex, wt as Provider, B as Text, x as Tooltip, qt as Tour };
21
+ export { Gt as Announcement, Jt as Banner, p as Box, h as Button, u as Card, x as Flex, dr as Form, Rt as Provider, m as Text, T as Tooltip, br as Tour, ie as useBoundingClientRect, J as useFlow, L as useFlowHandlers, Sr as useFrigade, Rr as useGroup, Y as useModal, q as useStepHandlers, Tr as useUser };
14
22
  //# sourceMappingURL=out.js.map
15
23
  //# sourceMappingURL=index.js.map