userflow.js-self-hosted 0.1.1012092 → 0.1.1012167

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/DebuggerUI.js CHANGED
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["flow-condition-types.js","userflow.js","vendor.core-js.js","vendor.phoenix.js","vendor.uuid.js","vendor.date-fns.js","vendor.babel.runtime.js","roots.js"])))=>i.map(i=>d[i]);
2
- import{r as i,R as e}from"./vendor.react.js";import{r as he}from"./vendor.react-dom.js";import{u as q,U as ct}from"./client-context.js";import{d as _e,a as G,b as M,c as Y,e as se,f as d,A as Fe,W as R,g as z,h as O,S as ut,i as dt,_ as mt,j as pt}from"./userflow.js";import{F as ft}from"./Frame.js";import{S as gt}from"./logomark.js";import{f as X,a as ht,b as Ce,c as qe,d as U,e as Et,g as Ge,h as ye,i as vt,j as bt,k as ze,l as wt,m as _t,n as W,o as A,p as Ct,q as Ye,r as yt,s as xt,t as Nt,u as Tt,v as St,w as Ot,x as Z,y as Dt,z as je,A as Pt,B as It,C as Ft,D as Rt,E as Lt,F as Mt,G as me,H as At}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{f as Ut,a as kt}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as m}from"./stylesheets.js";import{o as E}from"./vendor.obj-str.js";import"./vendor.core-js.js";import{_ as Ee,l as Xe}from"./vendor.lodash.js";import{F as ve}from"./vendor.fortawesome.react-fontawesome.js";import"./vendor.react-day-picker.js";import{f as xe,p as Vt,a as Ht}from"./vendor.date-fns.js";import{m as Bt}from"./vendor.memoize-one.js";import{c as Wt}from"./roots.js";import"./vendor.object-assign.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./flow-condition-types.js";import"./vendor.fortawesome.fontawesome-svg-core.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="988f785e-ac1a-4ae7-8e72-30d1360b0719",t._sentryDebugIdIdentifier="sentry-dbid-988f785e-ac1a-4ae7-8e72-30d1360b0719")}catch{}})();const qt=new URL("debugger.css",import.meta.url).href,$e=i.createContext(void 0),F=()=>i.useContext($e),Ke=i.createContext(null),Ne=()=>i.useContext(Ke),Ze=i.createContext({debuggerClientConditions:new Map,meta:void 0,buildId:void 0}),J=()=>i.useContext(Ze),oe={verifySetup:{name:"Verify setup",icon:X},checkAutoStart:{name:"Check auto-start",icon:ht},currentUser:{name:"Current user",icon:Ce}},Qe=i.createContext(void 0),Gt=({children:t})=>{const n=q(),[r,s]=i.useState(n.getSessionStorageState().debuggerApp?.selectedTab??"verifySetup");return i.useEffect(()=>{n.setSessionStorageState(o=>!o.debuggerApp||!o.debuggerApp.x?o:{...o,debuggerApp:{...o.debuggerApp,selectedTab:r}}),_e("Debugger Route changed to",r)},[r]),e.createElement(Qe.Provider,{value:{debuggerRoute:r,setDebuggerRoute:s}},t)},Te=()=>{const t=i.useContext(Qe);if(t===void 0)throw new Error("useDebuggerRouteHandler must be used within a DebuggerRouteProvider");return{debuggerRoute:t.debuggerRoute,setDebuggerRoute:t.setDebuggerRoute}},zt=t=>{const n=i.useRef(null),r=Ne();return i.useEffect(()=>{const s=r?.current,o=a=>{n.current&&!n.current.contains(a.target)&&t(a)};return document.addEventListener("mousedown",o),s?.contentDocument?.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o),s?.contentDocument?.removeEventListener("mousedown",o)}},[t,r,n]),n},Yt=()=>e.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M18.4393 5.56066C18.158 5.27936 18 4.89782 18 4.5C18 4.10218 18.158 3.72064 18.4393 3.43934C18.7206 3.15804 19.1022 3 19.5 3C19.8978 3 20.2794 3.15804 20.5607 3.43934C20.842 3.72064 21 4.10218 21 4.5C21 4.89782 20.842 5.27936 20.5607 5.56066C20.2794 5.84196 19.8978 6 19.5 6C19.1022 6 18.7206 5.84196 18.4393 5.56066Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 5.56066C3.15804 5.27936 3 4.89782 3 4.5C3 4.10218 3.15804 3.72064 3.43934 3.43934C3.72064 3.15804 4.10218 3 4.5 3C4.89782 3 5.27936 3.15804 5.56066 3.43934C5.84196 3.72064 6 4.10218 6 4.5C6 4.89782 5.84196 5.27936 5.56066 5.56066C5.27936 5.84196 4.89782 6 4.5 6C4.10218 6 3.72064 5.84196 3.43934 5.56066Z",fill:"#537388"}),e.createElement("path",{d:"M10.9393 13.0607C10.658 12.7794 10.5 12.3978 10.5 12C10.5 11.6022 10.658 11.2206 10.9393 10.9393C11.2206 10.658 11.6022 10.5 12 10.5C12.3978 10.5 12.7794 10.658 13.0607 10.9393C13.342 11.2206 13.5 11.6022 13.5 12C13.5 12.3978 13.342 12.7794 13.0607 13.0607C12.7794 13.342 12.3978 13.5 12 13.5C11.6022 13.5 11.2206 13.342 10.9393 13.0607Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 20.5607C3.15804 20.2794 3 19.8978 3 19.5C3 19.1022 3.15804 18.7206 3.43934 18.4393C3.72064 18.158 4.10218 18 4.5 18C4.89782 18 5.27936 18.158 5.56066 18.4393C5.84196 18.7206 6 19.1022 6 19.5C6 19.8978 5.84196 20.2794 5.56066 20.5607C5.27936 20.842 4.89782 21 4.5 21C4.10218 21 3.72064 20.842 3.43934 20.5607Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 13.0607C3.15804 12.7794 3 12.3978 3 12C3 11.6022 3.15804 11.2206 3.43934 10.9393C3.72064 10.658 4.10218 10.5 4.5 10.5C4.89782 10.5 5.27936 10.658 5.56066 10.9393C5.84196 11.2206 6 11.6022 6 12C6 12.3978 5.84196 12.7794 5.56066 13.0607C5.27936 13.342 4.89782 13.5 4.5 13.5C4.10218 13.5 3.72064 13.342 3.43934 13.0607Z",fill:"#537388"}),e.createElement("path",{d:"M10.9393 5.56066C10.658 5.27936 10.5 4.89782 10.5 4.5C10.5 4.10218 10.658 3.72064 10.9393 3.43934C11.2206 3.15804 11.6022 3 12 3C12.3978 3 12.7794 3.15804 13.0607 3.43934C13.342 3.72064 13.5 4.10218 13.5 4.5C13.5 4.89782 13.342 5.27936 13.0607 5.56066C12.7794 5.84196 12.3978 6 12 6C11.6022 6 11.2206 5.84196 10.9393 5.56066Z",fill:"#537388"})),jt={prefix:"far",iconName:"custom-hand-pointer-slash",icon:[641,512,[],"???","M185.554191,59.5126699 C189.248662,26.0794907 217.382589,0 251.429,0 C287.979,0 317.715,30.056 317.715,67 L317.715,140.634 C338.128,137.776 359.183,144.576 374.31,160.263 C401.503,147.416 434.689,154.593 454.182,179.361 C497.375,162.727 544,195.156 544,242 L544,326 C544,330.296189 543.590626,334.580726 542.780274,338.796073 L495.999,302.221942 L495.999,242 C495.999,216.84 459.428,216.879 459.428,242 C459.428,250.836 452.265,258 443.428,258 L439.435556,258 L420.622383,243.291649 C420.588346,242.865584 420.571,242.434817 420.571,242 L420.571,221 C420.571,197.943344 389.858993,196.049429 384.724023,215.225903 L269.713,125.308981 L269.713,67 C269.713,41.84 233.142,41.88 233.142,67 L233.142,96.717359 L185.554191,59.5126699 Z M162.172457,223.995642 L233.142,279.479508 L233.142,308.493 C233.142,324.063 213.106,330.402 204.111,317.776 L176.985,279.697 C162.585,259.485 133.185,282.08 147.591,302.303 L257.303,456.303 C260.737,461.122 266.231,464 272,464 L450.285,464 C455.041109,464 459.427079,462.119816 462.713129,458.957818 L500.616335,488.590478 C488.331086,503.061811 470.146238,512 450.286,512 L272,512 C250.741,512 230.632,501.59 218.209,484.154 L108.51,330.153 C87.267,300.334 93.705,258.796 123.06,237.001 C134.952446,228.171597 148.664261,223.998532 162.172457,223.995642 Z M272.143,309.970422 L306.143,336.551563 L306.143,400 C306.143,408.837 299.875,416 292.143,416 L286.143,416 C278.41,416 272.143,408.837 272.143,400 L272.143,309.970422 Z M347.571,368.939901 L381.571,395.521042 L381.571,400 C381.571,408.837 375.303,416 367.571,416 L361.571,416 C353.839,416 347.571,408.837 347.571,400 L347.571,368.939901 Z M633.994211,471.020009 C640.904211,476.540009 642.014211,486.610009 636.494211,493.510009 L626.494211,506 C620.964211,512.890009 610.904211,514.010009 604.004211,508.490009 L6.00421069,40.9800088 C-0.895789309,35.4600088 -2.01578931,25.3900088 3.51421069,18.4900088 L13.5142107,6 C19.0342107,-0.899991212 29.1042107,-2.00999121 36.0042107,3.51000879 L633.994211,471.020009 Z"]},Xt={CLICK:qe,DISABLED:U,MOUSEDOWN:Et,NOT_CLICK:jt,NOT_DISABLED:X,NOT_PRESENT:Ge,PRESENT:ye},$t={COMPLETED:X,NOT_COMPLETED:U,NOT_SEEN:Ge,ACTIVE:vt,NOT_ACTIVE:bt,SEEN:ye},Kt={CLICK:"is clicked",DISABLED:"is disabled",MOUSEDOWN:"has mouse down on it",NOT_CLICK:"is not clicked",NOT_DISABLED:"is not disabled",NOT_PRESENT:"is not present",PRESENT:"is present"};function Zt(t){return Kt[t]}const Qt={COMPLETED:"completed",NOT_COMPLETED:"not completed",NOT_SEEN:"not seen",ACTIVE:"is currently active",NOT_ACTIVE:"is not currently active",SEEN:"seen"};function Jt(t){return Qt[t]}function en(t,n){let r=(n||"").toLowerCase();return(t.eventTimeOperator===M.RELATIVE_BETWEEN?t.eventRelativeValue2:t.eventRelativeValue)!==1&&(r+="s"),t.eventTimeOperator!==M.RELATIVE_GT&&(r+=" ago"),r}function tn(t){return(t.eventFrequencyOperator===Y.BETWEEN?t.eventFrequencyValue2:t.eventFrequencyValue)===1?"time":"times"}const nn={CURRENT_USER:"by current user in any company",CURRENT_USER_CURRENT_GROUP:"by current user in current company",CURRENT_GROUP:"by any user in current company"};function rn(t){return nn[t]}function sn(t){if(!t)return"";switch(t){case Y.BETWEEN:return"between";case Y.EQ:return"exactly";case Y.GTE:return"at least";case Y.LTE:return"at most"}}function on(t){if(!t)return"";switch(t){case M.ANY:return"at any point in time";case M.RELATIVE_BETWEEN:return"between";case M.RELATIVE_GT:return"in the last";case M.RELATIVE_LT:return"more than"}}const an={1:"Lowest",2:"Low",3:"Medium",4:"High",5:"Highest"};function ln(t){return`${an[t]||String(t)} priority`}function be(t,n){switch(t){case se.DAY:return n===1?"day":"days";case se.HOUR:return n===1?"hour":"hours";case se.MINUTE:return n===1?"minute":"minutes";case se.SECOND:return n===1?"second":"seconds"}}function Re(t){switch(t){case"USER":return Ce;case"GROUP":return _t;case"GROUP_MEMBERSHIP":return wt;case"EVENT":return ze}}function cn(t){const n=t.split("/");if(n.length===1)return["USER",t];switch(n[0]){case"group":return["GROUP",n[1]];case"group_membership":return["GROUP_MEMBERSHIP",n[1]];case"event":return["EVENT",n[1]]}return console.warn("parseAttributeDefinitionFqn: Invalid attribute definition FQN",t),["USER",t]}const un={[G.BANNER]:"banner",[G.CHECKLIST]:"checklist",[G.FLOW]:"flow",[G.EMBED]:"embed",[G.LAUNCHER]:"launcher",[G.RESOURCE_CENTER]:"resource center"};function dn(t,{title:n,plural:r}={}){let s=un[t];return n&&(s=Ee.upperFirst(s)),r&&(s+="s"),s}let Le=!1;const Q=[];function Me(t){Q.push(t),Le||(Le=!0,window.addEventListener("keydown",n=>{if(n.key==="Escape"){const r=Q[Q.length-1];r&&(r(),n.stopImmediatePropagation())}}))}function Ae(t){const n=Q.indexOf(t);n>=0&&Q.splice(n,1)}const I=[];let Se=0;typeof window<"u"&&window.document.documentElement.addEventListener("mousedown",()=>Se++,{capture:!0});function mn(t){const n={cmp:t,zIndex:Je(),mountMouseDownCounter:Se};I.push(n),I.length===1&&document.documentElement.addEventListener("click",et,{capture:!0})}function pn(t){const n=I.findIndex(r=>r.cmp===t);I.splice(n,1),I.length===0&&document.documentElement.removeEventListener("click",et,{capture:!0})}function fn(t){const n=I.find(r=>r.cmp===t);return n?n.zIndex:Je()}function Je(){const t=I[I.length-1];return t?t.zIndex+100:1e3}function gn(t,n){const r=t.rootRef.current;return!!r&&r.contains(n)}function et(t){const n=t.target;if(n.closest("#userflow-ui, #notifications"))return;const r=I.findIndex(s=>gn(s.cmp,n));for(let s=I.length-1;s>r;s--){const o=I[s];o&&o.mountMouseDownCounter<Se&&o.cmp.closeLayer(t)}}const we=8,hn=we*2,En=8,Ue=50,j=8,ke=24,vn=8;class tt extends e.PureComponent{constructor(){super(...arguments),this.rootRef=e.createRef(),this.notchRef=e.createRef(),this.bodyRef=e.createRef(),this.state={},this.onAnimationFrame=()=>{this.reposition(),this.requestAnimationFrame()},this.onClick=n=>{n.stopPropagation(),this.props.onClick&&this.props.onClick(n)},this.closeLayer=n=>{if(this.props.ignoreTargetClick){const r=this.props.target,s=n.target;if(r&&s&&r.contains(s))return}this.fireOnDismiss({reason:"outside-click",event:n})},this.onEscape=()=>this.fireOnDismiss({reason:"escape"})}get el(){return this.rootRef.current}componentDidMount(){mn(this),this.props.onDismiss&&Me(this.onEscape),window.addEventListener("userflow:hideAllPopovers",this.closeLayer),this.requestAnimationFrame(),this.reposition()}componentWillUnmount(){pn(this),Ae(this.onEscape),window.removeEventListener("userflow:hideAllPopovers",this.closeLayer),window.cancelAnimationFrame(this.raf)}componentDidUpdate(n){const{props:r}=this;this.reposition(),!n.onDismiss&&r.onDismiss?Me(this.onEscape):n.onDismiss&&!r.onDismiss&&Ae(this.onEscape)}render(){const{props:n}=this,r=this.state,s=["popover"];n.className&&s.push(n.className),s.push(`popover--placement-${r.actualPlacement}`);const o=e.createElement("div",{className:s.join(" "),ref:this.rootRef,onMouseDown:n.onMouseDown,onMouseEnter:n.onMouseEnter,onClick:this.onClick,style:{zIndex:fn(this)}},e.createElement("div",{className:"popover__body",ref:this.bodyRef},n.children),!n.noNotch&&this.renderNotch());return he.createPortal(o,(n.document||document).body)}renderNotch(){const n=we,r=n*2;return e.createElement("div",{ref:this.notchRef,className:"popover__notch"},e.createElement("svg",{viewBox:`0 0 ${r} ${n}`},e.createElement("polygon",{className:"popover__notch-border",points:`${r/2},0 ${r},${n} 0,${n}`}),e.createElement("polygon",{className:"popover__notch-fill",points:`${r/2},1 ${r},${n+1} 0,${n+1}`})))}requestAnimationFrame(){this.raf=window.requestAnimationFrame(this.onAnimationFrame)}reposition(){const{props:n}=this,r=n.target,s=this.rootRef.current,o=this.notchRef.current,a=n.placement||"bottom",l=ae(a),c=!!n.forceDimension,g=n.horizontalAlign,_=n.verticalAlign,h=!!n.noNotch,v=document.documentElement.clientWidth,y=document.documentElement.clientHeight,p=r?.getBoundingClientRect(),b=p?.left,f=p?.top,w=p?.width,u=p?.height;let C=n.width;n.matchWidth&&(C=w);let x=n.minWidth;n.matchMinWidth&&w!=null&&(x=Math.max(w,x||0)),(this.lastPopoverCssWidth!==C||this.lastPopoverMinWidth!==x)&&(s.style.width=C==null?"":Math.round(C)+"px",s.style.minWidth=x==null?"":Math.round(x)+"px");const k=s.getBoundingClientRect(),D=k?.width,P=k?.height,V=parseInt((window.getComputedStyle(s).borderTopLeftRadius||"").replace(/px/,""),10),ee=window.scrollX,te=window.scrollY;if(this.lastPlacement===a&&this.lastForceDimension===c&&this.lastHorizontalAlign===g&&this.lastVerticalAlign===_&&this.lastNoNotch===h&&this.lastViewportWidth===v&&this.lastViewportHeight===y&&this.lastTargetX===b&&this.lastTargetY===f&&this.lastTargetWidth===w&&this.lastTargetHeight===u&&this.lastPopoverCssWidth===C&&this.lastPopoverMinWidth===x&&this.lastPopoverWidth===D&&this.lastPopoverHeight===P&&this.lastPopoverBorderRadius===V&&this.lastScrollX===ee&&this.lastScrollY===te)return;let ne,H=null;if(b!=null&&f!=null&&w!=null&&u!=null){ne=!0;const L=h?0:En,Pe=Ve(b,w,D,v,g||"left"),Ie=Ve(f,u,P,y,_||"top");let re=[{placement:"top",x:Pe,y:f-P-L,fits:P<f-L-j},{placement:"bottom",x:Pe,y:f+u+L,fits:P<y-(f+u)-L-j},{placement:"left",x:b-D-L,y:Ie,fits:D<=b-L-j},{placement:"right",x:b+w+L,y:Ie,fits:D<=v-(b+w)-L-j}];c&&(re=re.filter(T=>ae(T.placement)===l)),re.sort((T,N)=>{const S=ae(T.placement),B=ae(N.placement);return T.fits!==N.fits?T.fits?-1:1:T.placement===a?-1:N.placement===a?1:S!==B?S===l?-1:1:T.placement==="bottom"||T.placement==="right"?-1:1});const de=re[0];let $=de.x,K=de.y;if(H=de.placement,$+=ee,K+=te,$=Math.round($),K=Math.round(K),s.style.transform=`translate3d(${$}px, ${K}px, 0px)`,!h&&o){const T=Math.max(vn,V);let N,S;if(H==="left"||H==="right"){const B=f+u/2-we/2;u<=Ue||_==="center"?S=B:S=Math.min(f,B),S+=-K+te,S=Math.max(T,Math.min(P-T,S))}else{const B=b+w/2-hn/2;w<=Ue||g==="center"?N=B:N=Math.min(b,B),N+=-$+ee,N=Math.max(T,Math.min(D-T,N))}N=N&&Math.round(N),S=S&&Math.round(S),o.style.left=N==null?"":N+"px",o.style.top=S==null?"":S+"px"}}else ne=!1,s.style.transform="translate3d(-999999px, -999999px, 0px)";ne&&!this.lastVisible&&n.onShow&&n.onShow(),H!==this.lastActualPlacement&&(this.setState({actualPlacement:H}),n.onPlacementChange&&n.onPlacementChange(H)),this.lastVisible=ne,this.lastPlacement=a,this.lastActualPlacement=H,this.lastForceDimension=c,this.lastHorizontalAlign=g,this.lastVerticalAlign=_,this.lastNoNotch=h,this.lastViewportWidth=v,this.lastViewportHeight=y,this.lastTargetX=b,this.lastTargetY=f,this.lastTargetWidth=w,this.lastTargetHeight=u,this.lastPopoverCssWidth=C,this.lastPopoverMinWidth=x,this.lastPopoverWidth=D,this.lastPopoverHeight=P,this.lastPopoverBorderRadius=V,this.lastScrollX=ee,this.lastScrollY=te}fireOnDismiss(n){const{onDismiss:r}=this.props;r&&r(n),!this.props.noTargetRefocus&&n.reason==="escape"&&this.props.target&&this.props.target.focus()}}function ae(t){return t==="left"||t==="right"?"x":"y"}function Ve(t,n,r,s,o){let a;return o==="center"?a=t+n/2-r/2:a=t,a=Math.max(a,j),a=Math.min(a,s-r-j),a=Math.max(a,t+ke-r),a=Math.min(a,t+n-ke),a}const bn=["yyyy-MM-dd","yyyy/MM/dd","MM-dd yyyy","MM/dd yyyy","MM-dd-yyyy","MM/dd/yyyy","MM-dd","MM/dd","dd MMM yyyy","dd MMMM yyyy","MMM dd yyyy","MMMM dd yyyy","dd MMM","dd MMMM","MMM dd","MMMM dd"],wn=["hh:mmaaa","hh.mmaaa","hh:mm aaa","hh.mm aaa","HH:mm","HH.mm","hhaaa","hh aaa","HH"];for(const t of bn)for(const n of wn);const _n="d MMM yyyy";function He(t){if(t==null)return"";const n=yn?t.getMinutes()===0?"h aaa":"h:mm aaa":"HH:mm";return xe(t,_n+", "+n)}function Cn(t){if(!t)return null;const n=Vt(t,"yyyy-MM-dd",new Date);return isNaN(n.valueOf())?null:n}function Be(t){if(!t)return null;const n=Ht(t);return isNaN(n.valueOf())?null:n}const yn=Intl.DateTimeFormat(Intl.DateTimeFormat().resolvedOptions().locale,{hour:"numeric"}).resolvedOptions().hourCycle==="h12";var nt=(t=>(t.EVENT="EVENT",t.GROUP="GROUP",t.GROUP_MEMBERSHIP="GROUP_MEMBERSHIP",t.USER="USER",t))(nt||{});function ce(){const[t,n]=i.useState(!1),r=i.useRef(null),s=i.useCallback(()=>n(!0),[]),o=i.useCallback(()=>n(!1),[]),a=i.useCallback(()=>n(!0),[]),l=i.useCallback(()=>n(!1),[]);return{ref:r,hovered:t,eventHandlers:{onPointerEnter:s,onPointerLeave:o,onFocus:a,onBlur:l}}}function We(t){return({condition:n})=>{throw new Error(`conditionOperators.${n.operator}.${t} is not supported`)}}const pe={[d.ABSOLUTE_EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"on")," ",e.createElement("span",{className:"nowrap text-bold"},ge(t.value)))},[d.ABSOLUTE_GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"after")," ",e.createElement("span",{className:"nowrap text-bold"},ge(t.value)))},[d.ABSOLUTE_LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"before")," ",e.createElement("span",{className:"nowrap text-bold"},ge(t.value)))},[d.AND]:{Preview:We("Preview")},[d.BETWEEN]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is between")," ",e.createElement("b",null,t.value)," ",e.createElement("span",{className:"text-secondary"},"and")," ",e.createElement("b",null,t.value2))},[d.CONTAINS]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"contains")," ",e.createElement("b",null,t.value))},[d.EMPTY]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is empty")},[d.ENDS_WITH]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"ends with")," ",e.createElement("b",null,t.value))},[d.EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is")," ",e.createElement("b",null,t.dataType===Fe.FLOW&&t.value?e.createElement("span",null,t?.eventDisplayName??t.eventName):t.value))},[d.EXCLUDES_ALL]:{Preview:({condition:t})=>le(t,"does not include","all of")},[d.EXCLUDES_ANY]:{Preview:({condition:t})=>le(t,"does not include","at least one of")},[d.FALSE]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is false")},[d.GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is greater than")," ",e.createElement("b",null,t.value))},[d.GTE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is greater than or equal to")," ",e.createElement("b",null,t.value))},[d.INCLUDES_ALL]:{Preview:({condition:t})=>le(t,"includes","all of")},[d.INCLUDES_ANY]:{Preview:({condition:t})=>le(t,"includes","at least one of")},[d.LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is less than")," ",e.createElement("b",null,t.value))},[d.LTE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is less than or equal to")," ",e.createElement("b",null,t.value))},[d.NE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is not")," ",e.createElement("b",null,t.dataType===Fe.FLOW&&t.value?e.createElement("span",null," ",t?.eventDisplayName??t.eventName):t.value))},[d.NOT_CONTAINS]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not contain")," ",e.createElement("b",null,t.value))},[d.NOT_EMPTY]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"has any value")},[d.NOT_REGEX]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not match")," ",e.createElement("b",null,t.value))},[d.OR]:{Preview:We("Preview")},[d.REGEX]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"matches")," ",e.createElement("b",null,t.value))},[d.RELATIVE_EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"exactly")," ",e.createElement("span",{className:"nowrap text-bold"},fe(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[d.RELATIVE_GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"less than")," ",e.createElement("span",{className:"nowrap text-bold"},fe(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[d.RELATIVE_LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"more than")," ",e.createElement("span",{className:"nowrap text-bold"},fe(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[d.STARTS_WITH]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"starts with")," ",e.createElement("b",null,t.value))},[d.TRUE]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is true")},[d.URL]:{Preview:({condition:t})=>{const{urlPattern:n}=t;if(!n)return e.createElement("span",{className:"text-secondary"},"matches ...");const{includes:r,excludes:s}=n;return e.createElement(e.Fragment,null,r.length>0&&e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"matches")," ",r.map((o,a)=>e.createElement(e.Fragment,{key:a},a>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",null,o)))),r.length>0&&s.length>0&&e.createElement("span",{className:"text-secondary"}," and "),s.length>0&&e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not match")," ",s.map((o,a)=>e.createElement(e.Fragment,{key:a},a>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",null,o)))))}}};function xn(t){return parseInt(t,10)}function fe(t){if(!t)return"days";const n=xn(t);return isNaN(n)?"days":n+" "+(n===1?"day":"days")}function ge(t){if(!t)return"";const n=Cn(t);return n?xe(n,"PP"):""}function le(t,n,r){const s=t.values||[];return e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},n+(s.length>1?" "+r:""))," ",s.map((o,a)=>e.createElement(e.Fragment,{key:a},a>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",{key:a},o))))}const Oe=t=>({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":t===!0,"userflow-debugger-condition__item__danger":t===!1,"userflow-debugger-condition__item__intermediate":t===null}),De=t=>t===!0?A:t===!1?U:W,rt=(t,n)=>{const r=F();return i.useMemo(()=>{const a=(n?r?.hiddenCondition?.breakdown:r?.startCondition?.breakdown)?.find(l=>l.conditionId===t.id);return{classes:Oe(a?.match),icon:De(a?.match)}},[t,r,n])},ie=t=>{const{condition:n,isHideCond:r}=t,{classes:s,icon:o}=rt(n,r),a=n.type;if(a===O.CLAUSE)return e.createElement(Tn,{...t});const l=ot[a];return e.createElement("div",{className:E(s)},e.createElement("span",{className:"d-flex gap-8 align-center userflow-debugger-condition__item__icon"},l.icon?e.createElement(m,{icon:l.icon({condition:n})}):null,e.createElement(l.Preview,{...t})),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:o}))},Nn=()=>{const t=F(),[n,r]=i.useState(!1),s=i.useMemo(()=>t?.hiddenCondition?.breakdown.find(a=>a.conditionId===t?.hiddenCondition?.condition.id),[t?.hiddenCondition]);return t?.hiddenCondition?.condition?e.createElement("div",{role:"button",className:E({"d-flex gap-8 flex-column margin-8":!0,"userflow-debugger-condition__clause":!0,"userflow-debugger-hide-condition__clause__success":s?.match===!0,"userflow-debugger-hide-condition__clause__danger":s?.match===!1,"userflow-debugger-hide-condition__clause__expanded":n}),onClick:o=>{r(!n),o.stopPropagation()}},e.createElement("div",{className:"d-flex gap-8 justify-space-between align-center"},e.createElement("span",null,"Termporarily hide flow"," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to ",n?"collapse":"expand")),e.createElement(m,{icon:Z})),n&&e.createElement(ie,{isRoot:!0,isHideCond:!0,condition:t?.hiddenCondition?.condition})):null},Tn=({condition:t,isRoot:n=!1,isHideCond:r=!1})=>{const[s,o]=i.useState(!1),{classes:a,icon:l}=rt(t,r);return n?e.createElement(e.Fragment,null,t.conditions.map((c,g)=>e.createElement(ie,{isHideCond:r,key:g,condition:c}))):e.createElement("div",{role:"button",className:E({"d-flex flex-column gap-8":!0,"userflow-debugger-condition__clause":s,...s?{"userflow-debugger-condition__item__success__expanded":a["userflow-debugger-condition__item__success"],"userflow-debugger-condition__item__danger__expanded":a["userflow-debugger-condition__item__danger"],"userflow-debugger-condition__item__intermediate__expanded":a["userflow-debugger-condition__item__intermediate"]}:a}),onClick:c=>{o(!s),c.stopPropagation()}},e.createElement("div",{className:"d-flex justify-space-between align-center w-full"},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:Dt})," ",e.createElement("strong",null,"Logic Group")," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to ",s?"collapse":"expand")),!s&&e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:l})),s&&e.createElement(e.Fragment,null,t.conditions.map((c,g)=>e.createElement("div",{key:g,className:E({"userflow-debugger-condition__clause__operator__wrapper":!0})},g>0&&e.createElement("div",{className:E({"userflow-debugger-condition__clause__operator":!0})},e.createElement(st,{condition:t})),e.createElement(ie,{isHideCond:r,condition:c})))))},st=({condition:t})=>{const n=t.operator;return n?e.createElement("span",{className:E({"userflow-debugger-condition__item__operator":!0,"userflow-debugger-condition__item__operator__and":n===d.AND,"userflow-debugger-condition__item__operator__or":n===d.OR})},n===d.AND&&"AND",n===d.OR&&"OR"):null},Sn={[R.NONE]:U,[R.PENDING_SCHEDULE]:U,[R.SCHEDULED]:W,[R.FIRED]:A},On=e.memo(()=>{const t=F(),{waitTimer:n}=t||{},r=t?.startCondition?.condition.waitTime,{ref:s,hovered:o,eventHandlers:a}=ce();return!r||!n||n===R.NONE?null:e.createElement("div",{ref:s,...a,className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__danger":n===R.PENDING_SCHEDULE,"userflow-debugger-condition__item__intermediate":n===R.SCHEDULED,"userflow-debugger-condition__item__success":n===R.FIRED})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:Ct}),e.createElement("span",null,"Wait ",e.createElement("strong",null,r)," seconds")),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:Sn[n]}),e.createElement(ue,{target:s,hovered:o&&n===R.PENDING_SCHEDULE},"Timer activates once all conditions are satisfied"))}),Dn=e.memo(()=>{const t=F(),[n,r]=i.useState(!1),{startFrequency:s,listFlowLatestVersion:o}=t||{startFrequency:{}};if(!s||!o?.startFrequency||o?.startFrequency===z.NEVER)return null;const{currentFlowIntervalThrottle:a,frequency:l,frequencyUsage:c}=s,g=De(l),_=Oe(l);if(o.startFrequency===z.ONCE||o.startFrequency===z.ONCE_PER_GROUP)return e.createElement("div",{className:E(_)},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:Ye}),e.createElement("strong",null,"Once per user"," ",o.startFrequency===z.ONCE_PER_GROUP&&"per company")),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:g}));if(o.startFrequency===z.ALWAYS&&o.startIntervalValue&&o.startIntervalUnit)return e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":a===!0,"userflow-debugger-condition__item__intermediate":a===!1})},e.createElement("span",null,"Every ",e.createElement("strong",null,o.startIntervalValue)," ",e.createElement("span",{className:"userflow-debugger-info-text"},be(o.startIntervalUnit,o.startIntervalValue)," ","apart")),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:a===!1?W:A}));if(o.startFrequency===z.MULTIPLE){const h=l===!0&&a===!0,v=l===!0&&a===!1,y=l===!1;return e.createElement("div",{className:E({"d-flex flex-column gap-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__clause":n,...n?{"userflow-debugger-condition-frequency__success__expanded":h,"userflow-debugger-condition-frequency__intermediate__expanded":v,"userflow-debugger-condition-frequency__danger__expanded":y}:{"userflow-debugger-condition-frequency__success":h,"userflow-debugger-condition-frequency__intermediate":v,"userflow-debugger-condition-frequency__danger":y}}),onClick:p=>{r(!n),p.stopPropagation()}},e.createElement("div",{className:"d-flex gap-8 justify-space-between"},e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement("strong",null,"Start multiple times")," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to expand")),!n&&e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:h?A:v?W:U})),n&&e.createElement(e.Fragment,null,e.createElement("div",{className:E(_)},e.createElement("span",null,e.createElement("strong",null,o.startLimit)," ",e.createElement("span",{className:"userflow-debugger-info-text"},"(started ",c," times)")),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:g})),o.startIntervalUnit&&o.startIntervalValue&&e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":a===!0,"userflow-debugger-condition__item__intermediate":a===!1})},e.createElement("span",null,e.createElement("strong",null,o.startIntervalValue)," ",e.createElement("span",{className:"userflow-debugger-info-text"},be(o.startIntervalUnit,o.startIntervalValue)," ","apart")),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:a===!1?W:A}))))}return null}),Pn=()=>{const t=F(),{priority:n}=t||{};return n?.priority?e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__priority":!0})},e.createElement("span",null,e.createElement("strong",null,ln(n?.priority))," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to learn more")),e.createElement("a",{href:"https://docs.userflow.com/docs/trouble/using-the-debugger#flow-trigger-precedence",target:"_blank",rel:"noreferrer noopener"},e.createElement(m,{icon:je}))):null},In=()=>{const t=F(),{startFrequency:n}=t||{},{onlyIfNotCompleted:r}=n||{};return r==null?null:e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":r===!0,"userflow-debugger-condition__item__danger":r===!1})},"Only if not completed",e.createElement(m,{icon:r===!0?A:U}))},Fn=()=>{const t=F(),{startFrequency:n}=t||{},{hovered:r,eventHandlers:s,ref:o}=ce();return!n||n?.scopeByGroup===null||n.scopeByGroup===void 0||n.scopeByGroup===!0?null:e.createElement("div",{ref:o,...s,className:E({"d-flex align-center margin-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__danger":!0})},"Constrain to current company",e.createElement(m,{icon:De(n.scopeByGroup)}),e.createElement(ue,{target:o,hovered:r},"User is not associated with a company"))},Rn=()=>{const t=F(),{startFrequency:n,listFlowLatestVersion:r}=t||{},{anyFlowIntervalThrottle:s}=n||{},{throttleUnit:o,throttleValue:a}=r||{};return s===null||o===null||a===null||o===void 0||a===void 0?null:e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":s===!0,"userflow-debugger-condition__item__intermediate":s===!1})},e.createElement("span",null,"Atleast ",e.createElement("strong",null,r?.throttleValue)," ",be(o,a)," after any flow"),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:s===!0?A:W}))},Ln=e.memo(()=>{const{hovered:t,eventHandlers:n,ref:r}=ce(),s=F(),{snoozed:o}=s||{},a=i.useMemo(()=>{if(o?.until)return xe(new Date(o.until),"MMM do, h:mm a")},[o?.until]);return o?e.createElement("div",{ref:r,...n,className:E({"d-flex align-center margin-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__intermediate":!0})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:yt}),e.createElement("span",null,"This flow is currently ",e.createElement("strong",null,"snoozed"))),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:W}),e.createElement(ue,{target:r,hovered:t},"Snoozed until ",a)):null}),ot={[O.PAGE]:{icon:()=>xt,Preview:({condition:t})=>{const n=t.operator&&pe[t.operator];return e.createElement("span",null,"URL"," ",e.createElement("strong",null,n&&e.createElement(n.Preview,{condition:t})))}},[O.ATTRIBUTE]:{icon:({condition:t})=>{if(!t||!t.attributeName)return Re(nt.EVENT);const[n]=cn(t.attributeName);return Re(n)},Preview:({condition:t})=>{const n=t.operator&&pe[t.operator];return e.createElement("span",null,e.createElement("strong",null,t.attributeDisplayName?t.attributeDisplayName:"Attribute")," ",e.createElement("span",{className:"userflow-debugger-info-text"},n&&e.createElement(n.Preview,{condition:t})))}},[O.SEGMENT]:{icon:()=>Nt,Preview:({condition:t})=>{const{segment:n}=t;return e.createElement("span",null,e.createElement("strong",null,n?.subjectType===ut.GROUP?"Company":"User")," ",e.createElement("span",{className:"text-secondary"},t.operator===d.FALSE?"is not in":"is in")," ",e.createElement("strong",null,n?.name||"Segment"))}},[O.ELEMENT]:{icon:({condition:t})=>t.elementState?Xt[t.elementState]:Tt,Preview:({condition:t})=>e.createElement("span",null,"Element"," ",t.elementState&&e.createElement("strong",null,Zt(t.elementState)))},[O.INPUT_VALUE]:{icon:()=>St,Preview:({condition:t})=>{const n=t.operator&&pe[t.operator];return e.createElement("span",null,"The value of input"," ",e.createElement("strong",null,n&&e.createElement(n.Preview,{condition:t})))}},[O.FILLED_IN_INPUT]:{icon:()=>Ot,Preview:()=>e.createElement("span",null,"User fills an input")},[O.FLOW]:{icon:({condition:t})=>t.flowState?$t[t.flowState]:ye,Preview:({condition:t})=>e.createElement("span",null,t.flow?e.createElement(e.Fragment,null,dn(t.flow.type,{title:!0})," ",e.createElement("strong",null,t.flow.name)):"Flow/checklist"," ",t.flowState&&Jt(t.flowState))},[O.TIME]:{icon:()=>Ye,Preview:({condition:t})=>{const n=t.value?Be(t.value):null,r=n&&e.createElement("strong",{style:{whiteSpace:"nowrap"}},He(n)),s=t.value2?Be(t.value2):null,o=s&&e.createElement("strong",{style:{whiteSpace:"nowrap"}},He(s));return r&&o?e.createElement("span",null,"Current time is between ",r," and ",o):r?e.createElement(e.Fragment,null,"Current time is after ",r):o?e.createElement(e.Fragment,null,"Current time is before ",o):e.createElement(e.Fragment,null,"Current time is ...")}},[O.EVENT]:{icon:()=>ze,Preview:({condition:t})=>{const{ref:n,hovered:r,eventHandlers:s}=ce();return e.createElement("div",{ref:n,...s},e.createElement("strong",null,t.eventDisplayName?t.eventDisplayName:"Event")," ",e.createElement("span",{className:"userflow-debugger-info-text"},sn(t.eventFrequencyOperator))," ",e.createElement("strong",null,t.eventFrequencyValue),t.eventFrequencyOperator===Y.BETWEEN&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"userflow-debugger-info-text"},"and")," ",e.createElement("strong",null,t.eventFrequencyValue2))," ",e.createElement("span",{className:"userflow-debugger-info-text"},tn(t),","," ",on(t.eventTimeOperator)),t.eventTimeOperator!==M.ANY&&e.createElement(e.Fragment,null," ",e.createElement("strong",null,t.eventRelativeValue),t.eventTimeOperator===M.RELATIVE_BETWEEN&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"userflow-debugger-info-text"},"and")," ",e.createElement("strong",null,t.eventRelativeValue2))," ",e.createElement("span",{className:"userflow-debugger-info-text"},en(t,t.eventRelativeUnit))),t.eventActor&&t.eventActor!==dt.CURRENT_USER?e.createElement(e.Fragment,null," ",e.createElement("strong",null,rn(t.eventActor))):"",t.whereCondition&&r&&e.createElement(ue,{hovered:!0,target:n},"Where ",e.createElement("br",null),e.createElement(at,{condition:t.whereCondition})))}},[O.ALWAYS_TRUE]:{icon:()=>A,Preview:()=>e.createElement("span",null,"Water is wet")},[O.CHECKLIST_TASK_CLICKED]:{icon:()=>qe,Preview:()=>e.createElement("span",null,"Task is clicked")}},at=t=>e.createElement("div",null,t.condition.conditions.map((n,r)=>e.createElement("div",{key:n.id}," ",r===0?null:e.createElement("span",{className:"userflow-debugger-info-text"},t.condition.operator?.toLowerCase())," ",n.type==="ATTRIBUTE"&&ot.ATTRIBUTE.Preview({condition:n,isRoot:!0,isHideCond:!1}),n.type==="CLAUSE"&&e.createElement(e.Fragment,null,"(",e.createElement(at,{condition:n}),")")))),ue=({hovered:t,children:n,target:r})=>{const s=Ne();return t?e.createElement(tt,{className:"userflow-debugger-popover",target:r.current,placement:"top",horizontalAlign:"center",verticalAlign:"center",document:s?.current?.contentDocument||void 0},n):null};class Mn extends e.PureComponent{constructor(n){super(n),this.rootRef=e.createRef(),this.optionsElRef=e.createRef(),this.input=null,this.popoverRef=e.createRef(),this.isMouseDown=!1,this.isCreateOpen=!1,this.setInput=r=>{this.input=r;const{inputRef:s}=this.props;s&&(typeof s=="function"?s(r):s.current=r)},this.onInputChange=r=>{r.stopPropagation();const{value:s}=r.target;s!==""&&this.openPopover();const o=this.memoizedFilterOptions(this.props.options,s);this.setState({inputValue:s,q:s,highlightedIndex:o.length>0?0:-1,createHighlighted:o.length===0}),s===""&&!this.props.noEmpty&&this.triggerOnChange(null),this.props.onSearchChange&&this.props.onSearchChange(s)},this.onPopoverPlacementChange=r=>this.setState({popoverPlacement:r}),this.onMouseDown=r=>{r.preventDefault(),this.isMouseDown=!0;const s=()=>{this.isMouseDown=!1,this.props.document?.removeEventListener("mouseup",s),document.body.removeEventListener("mouseup",s)};this.props.document?.addEventListener("mouseup",s),document.body.addEventListener("mouseup",s)},this.onFocus=r=>{this.input&&!this.props.noSearch&&this.input.select(),this.props.onFocus&&this.props.onFocus(r)},this.onBlur=r=>{this.isMouseDown||this.closePopover(),this.props.onBlur&&!this.isCreateOpen&&this.props.onBlur(r)},this.onTriggerClick=()=>{this.props.readOnly||this.props.disabled||(this.state.popoverOpen?this.closePopover():(this.input&&this.input.focus(),this.openPopover()))},this.onKeyDown=r=>{const{popoverOpen:s,highlightedIndex:o,createHighlighted:a}=this.state,l=this.getFilteredOptions(),c=l.length-1;switch(r.key){case"ArrowUp":r.preventDefault(),s&&(a?this.setState({highlightedIndex:c,createHighlighted:!1}):o>0&&this.setState({highlightedIndex:o-1}));break;case"ArrowDown":r.preventDefault(),s?this.props.onCreate&&(o===c||a)?this.setState({highlightedIndex:-1,createHighlighted:!0}):o<c&&this.setState({highlightedIndex:o+1}):this.props.noOpenOnDown||this.openPopover();break;case"Enter":if(s)if(r.preventDefault(),a)this.fireOnCreate();else{const g=l[o];(g||!this.props.noEmpty)&&this.selectOption(g)}else this.props.onEnter?this.props.onEnter():this.openPopover();break;case"Tab":s&&this.selectOption(l[o]);break;case"Escape":s&&(r.preventDefault(),r.stopPropagation(),this.setState({popoverOpen:!1}));break}},this.selectOption=r=>{r===this.props.value?this.setState({popoverOpen:!1,inputValue:this.renderOptionText(r),q:""}):(this.setState({popoverOpen:!1,inputValue:"",q:""}),this.triggerOnChange(r))},this.highlightOption=r=>{this.setState({highlightedIndex:r,createHighlighted:!1})},this.highlightCreate=()=>{this.setState({highlightedIndex:-1,createHighlighted:!0})},this.fireOnCreate=()=>{const{onCreate:r}=this.props;if(r){this.isCreateOpen=!0;const s={q:Ee.upperFirst(this.state.q),callback:o=>{this.isCreateOpen=!1,o!=null&&this.selectOption(o),this.input&&this.input.focus()}};r(s),this.closePopover()}},this.openPopover=()=>{if(!this.state.popoverOpen){const r=this.getFilteredOptions();let s=0,o=!1;if(r.length===0)s=-1,o=!0;else{const{value:a}=this.props,l=r.findIndex(c=>c===a);l!==-1&&(s=l)}this.setState({popoverOpen:!0,highlightedIndex:s,createHighlighted:o})}},this.memoizedFilterOptions=Bt((r,s)=>(r=r||[],s?r.filter(o=>this.filter(o,s)):r)),this.state={inputValue:this.renderOptionText(n.value==null?null:n.value),q:"",popoverOpen:!1,popoverPlacement:null,highlightedIndex:-1,createHighlighted:!1}}componentDidUpdate(n,r){const{value:s}=this.props;if(s!==n.value){const o=this.renderOptionText(s??null);o!==this.state.inputValue&&this.setState({inputValue:o})}r.highlightedIndex!==this.state.highlightedIndex&&this.scrollHighlightedOptionIntoView()}render(){let n;const{props:r}=this,s=this.state,o=s.popoverPlacement==="top"?"above":"below";if(s.popoverOpen&&this.rootRef.current){const l=this.getFilteredOptions();let c;if(l.length>0){let g=null;c=l.reduce((_,h,v)=>{const y=this.getOptionGroup(h);y&&y!==g&&_.push(e.createElement("div",{key:"group:"+y,className:"combo-box__group-header"},y)),g=y;const p=["combo-box__option"];return v===s.highlightedIndex&&p.push("combo-box__option--highlighted"),_.push(e.createElement(An,{key:this.getOptionKey(h,v),className:p.join(" "),option:h,idx:v,renderOptionText:r.renderOptionText,renderOptionItem:r.renderOptionItem,getOptionIcon:r.getOptionIcon,onClick:this.selectOption,onHover:this.highlightOption})),r.hasSeparatorAfter&&r.hasSeparatorAfter(h)&&_.push(e.createElement("div",{key:"sep-"+v,className:"combo-box__option-sep"})),_},[])}else r.loading?c=e.createElement("div",{className:"combo-box__no-results"},"Loading..."):c=e.createElement("div",{className:"combo-box__no-results"},"No matching ",r.nounPlural||"items");n=e.createElement(tt,{ref:this.popoverRef,className:"combo-box-popover"+(r.popoverNotch?"":` combo-box-popover--${o}`),noNotch:!r.popoverNotch,target:this.rootRef.current,forceDimension:!0,matchWidth:!0,minWidth:r.popoverMinWidth,onMouseDown:this.onMouseDown,onPlacementChange:this.onPopoverPlacementChange,document:r.document},e.createElement("div",{ref:this.optionsElRef,className:E({"combo-box__options":!0,"combo-box__options--with-create":!!r.onCreate})},c),r.onCreate&&e.createElement("div",{key:"create",className:E({"combo-box__option":!0,"combo-box__option--create":!0,"combo-box__option--highlighted":s.createHighlighted}),onClick:this.fireOnCreate,onMouseMove:this.highlightCreate},e.createElement("div",{className:"combo-box__create-icon"},e.createElement(ve,{icon:Pt})),e.createElement("div",{className:"combo-box__create-text"},"Create"," ",s.q===""?"new"+(r.noun?` ${r.noun}`:""):e.createElement("b",null,Ee.upperFirst(s.inputValue)))))}const a=["input-group","combo-box"];return s.popoverOpen&&(a.push("combo-box--open"),r.popoverNotch||a.push(`combo-box--with-popover-${o}`)),r.disabled&&a.push("input-group--disabled"),r.noSearch&&a.push("combo-box--no-search"),r.className&&a.push(r.className),e.createElement(e.Fragment,null,e.createElement("div",{className:a.join(" "),style:{width:r.width?r.width+"px":void 0},ref:this.rootRef,onClick:r.readOnly||r.disabled?void 0:()=>{this.input?.focus(),this.openPopover()}},r.childrenBefore,r.value&&r.getOptionIcon&&e.createElement("div",{className:"combobox__input-icon"},it(r.value,r.getOptionIcon)),e.createElement("input",{type:"text",className:r.inputClassName,name:r.name,value:s.inputValue,onChange:this.onInputChange,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onMouseDown:this.openPopover,placeholder:r.placeholder,readOnly:r.readOnly||r.noSearch,disabled:r.disabled,autoComplete:"off",ref:this.setInput,...r.inputHtmlAttributes}),!r.noTrigger&&e.createElement("div",{"data-testid":r.triggerTestId||"combo-box-trigger",className:"input-group__append input-group__trigger",onClick:this.onTriggerClick,onMouseDown:this.onMouseDown},e.createElement(ve,{icon:It})),r.childrenAfter),n)}scrollHighlightedOptionIntoView(){const n=this.optionsElRef.current;if(this.state.popoverOpen&&n){const r=n.querySelector(".combo-box__option--highlighted");if(r){const s=n.getBoundingClientRect(),o=r.getBoundingClientRect();o.top<s.top?n.scrollTop+=o.top-s.top:o.bottom>s.bottom&&(n.scrollTop+=o.bottom-s.bottom)}}}triggerOnChange(n){const{onChange:r}=this.props;r&&r(n)}closePopover(){this.setState({popoverOpen:!1,inputValue:this.renderOptionText(this.props.value==null?null:this.props.value),q:""})}renderOptionText(n){return n==null?"":lt(n,this.props.renderOptionText)}getFilteredOptions(){return this.memoizedFilterOptions(this.props.options,this.state.q)}filter(n,r){return this.props.filter?this.props.filter(n,r):this.renderOptionText(n).toLowerCase().includes(r.toLowerCase())}getOptionKey(n,r){return n&&n.id||r}getOptionGroup(n){return this.props.getOptionGroup?this.props.getOptionGroup(n):n&&n.group||null}}class An extends e.PureComponent{constructor(){super(...arguments),this.state={isOptionDisabled:!1},this.onClick=()=>{this.state.isOptionDisabled||this.props.onClick(this.props.option)},this.onHover=()=>{this.state.isOptionDisabled||this.props.onHover(this.props.idx)}}componentDidMount(){const n=this.props.option!==void 0&&typeof this.props.option=="object"&&this.props.option!==null&&"disabled"in this.props.option&&this.props.option.disabled===!0;this.setState({isOptionDisabled:n})}componentDidUpdate(){const n=this.props.option!==void 0&&typeof this.props.option=="object"&&this.props.option!==null&&"disabled"in this.props.option&&this.props.option.disabled===!0;this.setState({isOptionDisabled:n})}render(){const{isOptionDisabled:n}=this.state,{props:r}=this;return e.createElement("div",{className:E({[r.className]:!0,"combo-box__option--disabled":n}),onClick:this.onClick,onMouseMove:this.onHover},Un(r.option,r.renderOptionText,r.renderOptionItem,r.getOptionIcon))}}function lt(t,n){return n?n(t):typeof t=="string"||typeof t=="number"?t:t?t.name:"?"}function Un(t,n,r,s){if(r)return r(t);{let o=lt(t,n);return s?e.createElement("div",{className:"d-flex align-flex-start"},e.createElement("div",{className:"combobox__option-icon"},it(t,s)),e.createElement("div",{className:"flex-1"},o)):o}}function it(t,n){const r=n(t);return kn(r)?e.createElement(ve,{icon:r}):r}function kn(t){return Wt(t)&&"iconName"in t}const Vn=({selectedFlow:t,setSelectedFlow:n,flows:r,debugAutoStartCondition:s})=>{const o=q(),a=Ne();i.useEffect(()=>{if(!t)return;s(t.latestVersion);const c=()=>{s(t.latestVersion)};return o.on("private:checkSessionsAck",c),document.addEventListener("visibilitychange",c),()=>{o.off("private:checkSessionsAck",c),document.removeEventListener("visibilitychange",c)}},[t]);const l=i.useCallback(c=>{!c||t?.latestVersion?.id===c.latestVersion.id||n(c)},[t]);return e.createElement(e.Fragment,null,e.createElement("div",{className:"d-flex align-center justify-space-between"},e.createElement("div",{className:"d-flex justify-space-between align-center"},"Select Flow"),e.createElement(Mn,{className:"userflow-debugger__flow__selector",value:t,options:r,placeholder:"Select flow",document:a?.current?.contentDocument||void 0,onChange:l,renderOptionItem:c=>c.name})),e.createElement(Hn,{selectedFlow:t,selectedFlowVersionsId:t?.latestVersion?.id}))},Hn=({selectedFlowVersionsId:t,selectedFlow:n})=>{const r=q(),[s,o]=i.useState(!1),a=F(),l=a&&a?.activeFlow?.id===n?.id;return i.useEffect(()=>(o(!1),r.on("private:setFlowSession",c=>{o(c===t)}),()=>{r.off("private:setFlowSession",()=>o(!1))}),[t]),i.useEffect(()=>{l||o(!1)},[l]),a?.activeFlow===null?null:e.createElement(e.Fragment,null,a?.locale?.match===!1&&e.createElement("div",{className:E(Oe(!1))},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:U}),e.createElement("span",null,"The flow will not auto start ",e.createElement("br",null)," ",e.createElement("b",null,"User locale (",a?.locale?.code,") is not enabled.")))),s?e.createElement("div",{className:E({"d-flex align-center fade-in":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex align-center gap-8"},e.createElement(m,{icon:Z}),e.createElement("span",null,"This flow ",e.createElement("strong",null,"just")," started"))):null,l&&!s&&e.createElement("div",{className:E({"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex align-center gap-8"},e.createElement(m,{icon:Z}),e.createElement("span",null,"This flow is currently active"))),!l&&a&&e.createElement("div",{className:E({"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:Z,size:16}),e.createElement("span",null,"Another flow is currently active"))))},Bn=({close:t})=>{const n=q(),r=i.useRef(null),[s,o]=i.useState(!!n.clientToken),[a,l]=i.useState(()=>{const u=n.getSessionStorageState(),C=u?.debuggerApp?.x,x=u?.debuggerApp?.y||50;return{x:C??(document.body.clientWidth?Number(document.body.clientWidth)-450:50),y:x}}),[c,g]=i.useState(!1),_=i.useRef(null),{meta:h}=J(),{debuggerRoute:v}=Te(),[y,p]=i.useState(!1),b=i.useRef(null),f=i.useRef({mouseX:0,mouseY:0,elementX:0,elementY:0});i.useEffect(()=>{a&&n.setSessionStorageState(u=>({...u,debuggerApp:{...u.debuggerApp,x:a.x,y:a.y}}))},[a]),i.useEffect(()=>{if(!c)return;const u=x=>{const k=x.clientX-f.current.mouseX,D=x.clientY-f.current.mouseY,P=Math.min(f.current.elementX+k,window.document.body.clientWidth-200),V=Math.max(f.current.elementY+D,0);b.current||(b.current=requestAnimationFrame(()=>{l({x:P,y:V}),b.current=null}))},C=()=>{g(!1)};return document.addEventListener("mousemove",u),document.addEventListener("mouseup",C),()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",C),b.current&&(cancelAnimationFrame(b.current),b.current=null)}},[c,a]),i.useEffect(()=>{const u=()=>{l(x=>{const k=document.body.clientWidth-500,D=document.body.clientHeight-100,P=Math.max(Math.min(x.x,k),0),V=Math.max(Math.min(x.y,D),0);return{x:P,y:V}})},C=()=>{o(!!n.clientToken)};return window.addEventListener("resize",u),n.on("private:initialised",C),()=>{window.removeEventListener("resize",u),n.off("private:initialised",C)}},[]);const w=u=>{r.current&&(g(!0),u.preventDefault())};return e.createElement("div",{ref:r,style:{left:"0",top:"0",position:"absolute",willChange:"transform",transform:`translate3d(${a.x}px, ${a.y}px, 0)`,zIndex:1234620}},e.createElement("div",{onMouseDown:w,style:{height:"50px",cursor:"move",userSelect:"none",position:"absolute",width:"50px"}}),e.createElement(ft,{title:"Debugger",stylesheet:qt,style:{borderRadius:"8px",width:"400px",height:v==="checkAutoStart"?"600px":s?"500px":"400px"},elRef:_,onStylesheetsLoad:p},e.createElement(Ke.Provider,{value:_},e.createElement("div",{className:"d-flex flex-column userflow-debugger-app",style:{visibility:y?"visible":"hidden"}},e.createElement("div",{className:"d-flex justify-space-between userflow-debugger-app__header"},e.createElement(Yt,null),e.createElement("div",{className:"d-flex align-center userflow-debugger-app__title"},e.createElement(gt,null),e.createElement("span",null,"Userflow debugger")),e.createElement("button",{role:"button",className:"userflow-debugger-app__close",onClick:()=>{n.getSessionStorageState().debuggerApp&&n.setSessionStorageState(u=>({...u,debuggerApp:null})),t()}},e.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M12.1836 4.49609L8.90234 7.77734L12.1562 11.0312C12.4297 11.2773 12.4297 11.6875 12.1562 11.9336C11.9102 12.207 11.5 12.207 11.2539 11.9336L7.97266 8.67969L4.71875 11.9336C4.47266 12.207 4.0625 12.207 3.81641 11.9336C3.54297 11.6875 3.54297 11.2773 3.81641 11.0039L7.07031 7.75L3.81641 4.49609C3.54297 4.25 3.54297 3.83984 3.81641 3.56641C4.0625 3.32031 4.47266 3.32031 4.74609 3.56641L8 6.84766L11.2539 3.59375C11.5 3.32031 11.9102 3.32031 12.1836 3.59375C12.4297 3.83984 12.4297 4.25 12.1836 4.49609Z",fill:"white"})))),e.createElement(Wn,null),v==="verifySetup"&&e.createElement(qn,null),h?.endUser?.debuggerEnabled&&v==="checkAutoStart"&&e.createElement(Gn,null),v==="currentUser"&&e.createElement(zn,null)))))},Wn=()=>{const t=q(),{meta:n}=J(),[r,s]=i.useState(!1),{debuggerRoute:o,setDebuggerRoute:a}=Te(),l=t.isIdentified(),c=zt(()=>s(!1));return i.useEffect(()=>{n&&n?.endUser.debuggerEnabled===!1&&o==="checkAutoStart"&&a("verifySetup")},[n]),l?e.createElement("div",{ref:c},e.createElement("div",{className:"d-flex align-center justify-space-between userflow-debugger-menu",onClick:()=>s(!r)},e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-menu__title":!0,"userflow-debugger-menu__title--open":r})},e.createElement(m,{icon:oe[o].icon}),e.createElement("span",null,oe[o].name)),e.createElement("button",{className:"userflow-debugger-menu__toggle"},e.createElement(m,{icon:Ft}))),r&&e.createElement("ul",{className:"userflow-debugger-menu__list"},Object.keys(oe).map(g=>{if(!n?.endUser?.debuggerEnabled&&g==="checkAutoStart")return null;const _=oe[g];return e.createElement("li",{key:g,className:"d-flex align-center userflow-debugger-app__item",onClick:()=>{a&&a(g),s(!1)}},e.createElement(m,{icon:_.icon}),_.name)}))):null},qn=()=>{const{meta:t,buildId:n}=J(),r=q(),[s,o]=i.useState(!!r.clientToken),a=i.useMemo(()=>r.isIdentified(),[r,t]),{setDebuggerRoute:l}=Te();i.useEffect(()=>{const h=()=>{o(!!r.clientToken)};return r.on("private:initialised",h),()=>{r.off("private:initialised",h)}},[]);const c=i.useMemo(()=>{let h=me;const v={"d-flex flex-column gap-8":!0,"userflow-debugger-installation__step":!0};return s?(h=X,v["userflow-debugger-installation__step__success"]=!0):(h=At,v["userflow-debugger-installation__step__danger"]=!0),{icon:h,classes:v}},[s]),g=i.useMemo(()=>{let h=me;const v={"d-flex flex-column gap-8":!0,"userflow-debugger-installation__step":!0};return!s&&!a&&(h=me,v["userflow-debugger-installation__step__failed"]=!0),s&&!a&&(h=Z,v["userflow-debugger-installation__step__warning"]=!0),s&&a&&(h=X,v["userflow-debugger-installation__step__success"]=!0),{icon:h,classes:v}},[s,a]),_=()=>a?t?.endUser.debuggerEnabled?e.createElement(e.Fragment,null,e.createElement("span",{className:"userflow-debugger-details"},t?.env.company.name),e.createElement("span",{className:"userflow-debugger-details"},t?.env.name)):e.createElement("div",{className:"userflow-debugger-details__access__denied"},"The"," ",e.createElement("button",{onClick:()=>l("currentUser")},"currently signed-in user")," ","does not have debugger access"):e.createElement(e.Fragment,null,e.createElement("span",{className:"userflow-debugger-details"},"Unknown company"),e.createElement("span",{className:"userflow-debugger-details"},"Unknown environment"));return e.createElement("div",{className:"space-evenly userflow-debugger-app__content"},e.createElement("div",{className:"userflow-debugger-installation__steps"},e.createElement("div",{className:E({"d-flex gap-8 flex-column":!0,"userflow-debugger-installation__step":!0,"userflow-debugger-installation__step__success":!0})},e.createElement(m,{icon:X,size:32}),"Userflow ",e.createElement("br",null),"installed"),e.createElement("div",{className:E(c.classes)},e.createElement(m,{icon:c.icon,size:32}),"Userflow ",e.createElement("br",null)," ",s?"":"not"," initialized"),e.createElement("div",{className:E(g.classes)},e.createElement(m,{icon:g.icon,size:32}),"User ",e.createElement("br",null)," ",a&&s?"":"not"," ","identified")),!s&&!a&&e.createElement("div",{className:E({"d-flex gap-8 flex-column":!0,"userflow-debugger-installation__not__initialized":!0})},"Remember to initialize Userflow by calling",e.createElement("div",null,"userflow.init('YOUR_USERFLOW_TOKEN')")),s&&e.createElement("div",{className:"d-flex gap-8 flex-column userflow-debugger-details__wrapper"},e.createElement("div",{className:"userflow-debugger-details__env__details"},e.createElement("div",{className:"d-flex gap-8 flex-column justify-space-around"},e.createElement(m,{size:20,icon:Rt}),e.createElement(m,{size:20,icon:Lt})),e.createElement("div",{className:"d-flex flex-column align-flex-start gap-8"},_())),e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement(m,{size:20,icon:Mt}),e.createElement("span",{className:"userflow-debugger-details"},r.getInitToken())),e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement(m,{size:20,icon:Ce}),e.createElement("span",{className:"userflow-debugger-details"},a?r.getIdentifiedUser()?.externalId:"User not identified"))),e.createElement("div",{className:"userflow-debugger-installation__version"},e.createElement("a",{href:"https://docs.userflow.com/docs/dev/userflow-js-installation",target:"_blank",rel:"noreferrer"},"Visit the Userflow Developer Docs for help")," ",e.createElement("br",null),"Userflow.js version 0.1.",n))},Gn=()=>{const t=q(),{debuggerClientConditions:n}=J(),[r,s]=i.useState(void 0),[o,a]=i.useState([]),[l,c]=i.useState(),g=i.useMemo(()=>{if(l?.startCondition?.match===!1||l?.hiddenCondition?.match===!1||l?.locale?.match===!1)return!1;const p=l?.startFrequency;return!(p&&(p.onlyIfNotCompleted===!1||p.scopeByGroup===!1||p.frequency===!1))},[l]);i.useEffect(()=>(y().then(p=>{if(p?.length&&(a(p),!r)){const b=t.getSessionStorageState()?.debuggerApp?.selectedFlowVersionId,f=p.find(w=>w.latestVersion.id===b);h(f??p[0])}}),document.addEventListener("visibilitychange",y),()=>{document.removeEventListener("visibilitychange",y)}),[]),i.useEffect(()=>{r&&v(r.latestVersion)},[r]);const _=Xe.debounce(async p=>{const b=[];for(const[u,C]of n.entries())b.push({conditionId:u,isTrue:C.isTrue});const f={kind:"DebugFlowAutostartCondition",flowVersionId:p.id,clientConditions:b},w=await t.send(f);c({...w,listFlowLatestVersion:p}),w.latestVersion?.id&&p.id!==w.latestVersion?.id&&(y().then(u=>{if(!u)return;a(u);const C=u?.find(x=>x.latestVersion.id===w.latestVersion?.id);C&&h(C)}),_(w.latestVersion))},300),h=p=>{s(p);const b=t.getSessionStorageState().debuggerApp;b&&b?.x&&t.setSessionStorageState(f=>({...f,debuggerApp:{...b,selectedFlowVersionId:p.latestVersion.id}}))},v=async p=>{n.forEach(f=>{f.untrack?.()}),n.clear();const{conditionTypes:b}=await mt(async()=>{const{conditionTypes:f}=await import("./flow-condition-types.js").then(w=>w.f);return{conditionTypes:f}},__vite__mapDeps([0,1,2,3,4,5,6,7]));for(const f of p.clientConditions){n.set(f.id,{condition:f,isTrue:null});const w=b[f.type];if(!w){console.error(`Unknown condition type ${f.type}`);continue}const u=n.get(f.id);u&&(u.untrack=w.track({sessionData:new pt([]),condition:f,callback:C=>{u.isTrue!==C&&(u.isTrue=C,_(p))}}))}},y=async()=>{try{return(await t.send({kind:"ListFlows",hasAutostartCondition:!0},{handlesRejection:!0})).flows?.filter(f=>f.type==="FLOW")}catch(p){p.code==="debugger_access_denied"&&_e("Access defined for List Flows");return}};return e.createElement("div",{className:"userflow-debugger-app__content"},e.createElement($e.Provider,{value:l},e.createElement(Vn,{flows:o,selectedFlow:r,setSelectedFlow:h,debugAutoStartCondition:_}),e.createElement("div",{className:"d-flex flex-column gap-8 userflow-debugger-app__wrapper"},l?.startCondition?.condition&&e.createElement("div",null,e.createElement("div",{className:E({"d-flex gap-8 align-center":!0,"userflow-debugger-app__wrapper__passing":g,"userflow-debugger-app__wrapper__failed":!g})},e.createElement(m,{icon:g?Ut:kt}),e.createElement("strong",null,"Auto-start conditions")),e.createElement("span",null,"These are"," ",e.createElement(st,{condition:l.startCondition.condition}),e.createElement("b",null,"-conditions"),", meaning"," ",l.startCondition.condition.type==="CLAUSE"&&l.startCondition.condition.operator==="AND"&&e.createElement(e.Fragment,null,"all conditions must pass for the flow to start."),l.startCondition?.condition.type==="CLAUSE"&&l.startCondition.condition.operator==="OR"&&e.createElement(e.Fragment,null,"only one condition must pass for the flow to start."))),l?.startCondition?.condition&&e.createElement(ie,{isRoot:!0,isHideCond:!1,condition:l.startCondition.condition}),e.createElement(On,null),e.createElement(Dn,null),e.createElement(In,null),e.createElement(Rn,null),e.createElement(Pn,null),e.createElement(Nn,null),e.createElement(Fn,null),e.createElement(Ln,null))))},zn=e.memo(()=>{const{meta:t,buildId:n}=J();if(!t)return null;const r="https://app.userflow.com/app/"+t.env.company.slug+"/settings/debugger?external_id="+t.endUser.externalId;return e.createElement("div",{className:"d-flex flex-column space-evenly flex-1"},e.createElement("div",{className:"d-flex flex-column gap-8"},e.createElement("div",{className:"d-flex flex-column"},t.endUser.avatarUrl?e.createElement("img",{src:t.endUser.avatarUrl,className:"userflow-debugger-user__image"}):e.createElement("div",{className:"userflow-debugger-user__image"}),e.createElement("span",{className:"userflow-debugger-user__name"},t.endUser?.name||"Unknown name"),e.createElement("span",{className:"userflow-debugger-user__email"},t?.endUser?.email||"Unknown email address"),(!t.endUser.email||!t.endUser.name)&&e.createElement("span",{className:"userflow-debugger__external__id"},t.endUser.externalId)),!t.endUser.debuggerEnabled&&e.createElement(e.Fragment,null,e.createElement("div",{className:"userflow-debugger-user__info"},"This user doesn't have access to the Userflow debugger. You can grant access through the debugger settings in Userflow."),e.createElement("a",{className:"userflow-debugger-user__button",href:r,target:"_blank",rel:"noreferrer"},"Grant access in Userflow ",e.createElement(m,{icon:je})))),e.createElement("div",{className:"userflow-debugger-installation__version"},e.createElement("a",{href:"https://docs.userflow.com/docs/dev/userflow-js-installation",target:"_blank",rel:"noreferrer"},"Visit the Userflow Developer Docs for help")," ",e.createElement("br",null),"Userflow.js version 0.1.",n))});class br{constructor(n,r){this.client=n,this.buildId=r,this.debuggerClientConditions=new Map}mount(){if(this.container)throw new Error("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-debugger-ui",document.body.appendChild(this.container),he.render(e.createElement(Yn,{client:this.client,debuggerClientConditions:this.debuggerClientConditions,buildId:this.buildId,unmount:()=>this.unmount()}),this.container)}unmount(){this.container&&(he.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),this.client.unMountDebugger(),delete this.container)}}const Yn=({client:t,debuggerClientConditions:n,buildId:r,unmount:s})=>{const[o,a]=i.useState(void 0),l=Xe.debounce(async()=>{try{const c=await t.send({kind:"GetCurrentEndUser"},{handlesRejection:!0});a(c)}catch(c){c.code==="debugger_access_denied"&&_e("debugger access denied"),a(void 0)}},300);return i.useEffect(()=>(l(),document.addEventListener("visibilitychange",l),t.on("private:identified",l),()=>{document.removeEventListener("visibilitychange",l),t.off("private:identified",l)}),[]),e.createElement(ct.Provider,{value:t},e.createElement(Ze.Provider,{value:{meta:o,debuggerClientConditions:n,buildId:r}},e.createElement(Gt,null,e.createElement(Bn,{close:s}))))};export{br as DebuggerUI};
2
+ import{r as i,R as e}from"./vendor.react.js";import{r as he}from"./vendor.react-dom.js";import{u as q,U as ct}from"./client-context.js";import{d as _e,a as G,b as M,c as Y,e as se,f as d,A as Fe,W as R,g as z,h as O,S as ut,i as dt,_ as mt,j as pt}from"./userflow.js";import{F as ft}from"./Frame.js";import{S as gt}from"./logomark.js";import{f as X,a as ht,b as Ce,c as qe,d as U,e as Et,g as Ge,h as ye,i as vt,j as bt,k as ze,l as wt,m as _t,n as W,o as A,p as Ct,q as Ye,r as yt,s as xt,t as Nt,u as Tt,v as St,w as Ot,x as Z,y as Dt,z as je,A as Pt,B as It,C as Ft,D as Rt,E as Lt,F as Mt,G as me,H as At}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{f as Ut,a as kt}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as m}from"./stylesheets.js";import{o as E}from"./vendor.obj-str.js";import"./vendor.core-js.js";import{_ as Ee,l as Xe}from"./vendor.lodash.js";import{F as ve}from"./vendor.fortawesome.react-fontawesome.js";import"./vendor.react-day-picker.js";import{f as xe,p as Vt,a as Ht}from"./vendor.date-fns.js";import{m as Bt}from"./vendor.memoize-one.js";import{c as Wt}from"./roots.js";import"./vendor.object-assign.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./flow-condition-types.js";import"./vendor.fortawesome.fontawesome-svg-core.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="7a3460b8-eec6-424d-8349-aa7175beed06",t._sentryDebugIdIdentifier="sentry-dbid-7a3460b8-eec6-424d-8349-aa7175beed06")}catch{}})();const qt=new URL("debugger.css",import.meta.url).href,$e=i.createContext(void 0),F=()=>i.useContext($e),Ke=i.createContext(null),Ne=()=>i.useContext(Ke),Ze=i.createContext({debuggerClientConditions:new Map,meta:void 0,buildId:void 0}),J=()=>i.useContext(Ze),oe={verifySetup:{name:"Verify setup",icon:X},checkAutoStart:{name:"Check auto-start",icon:ht},currentUser:{name:"Current user",icon:Ce}},Qe=i.createContext(void 0),Gt=({children:t})=>{const n=q(),[r,s]=i.useState(n.getSessionStorageState().debuggerApp?.selectedTab??"verifySetup");return i.useEffect(()=>{n.setSessionStorageState(o=>!o.debuggerApp||!o.debuggerApp.x?o:{...o,debuggerApp:{...o.debuggerApp,selectedTab:r}}),_e("Debugger Route changed to",r)},[r]),e.createElement(Qe.Provider,{value:{debuggerRoute:r,setDebuggerRoute:s}},t)},Te=()=>{const t=i.useContext(Qe);if(t===void 0)throw new Error("useDebuggerRouteHandler must be used within a DebuggerRouteProvider");return{debuggerRoute:t.debuggerRoute,setDebuggerRoute:t.setDebuggerRoute}},zt=t=>{const n=i.useRef(null),r=Ne();return i.useEffect(()=>{const s=r?.current,o=a=>{n.current&&!n.current.contains(a.target)&&t(a)};return document.addEventListener("mousedown",o),s?.contentDocument?.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o),s?.contentDocument?.removeEventListener("mousedown",o)}},[t,r,n]),n},Yt=()=>e.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M18.4393 5.56066C18.158 5.27936 18 4.89782 18 4.5C18 4.10218 18.158 3.72064 18.4393 3.43934C18.7206 3.15804 19.1022 3 19.5 3C19.8978 3 20.2794 3.15804 20.5607 3.43934C20.842 3.72064 21 4.10218 21 4.5C21 4.89782 20.842 5.27936 20.5607 5.56066C20.2794 5.84196 19.8978 6 19.5 6C19.1022 6 18.7206 5.84196 18.4393 5.56066Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 5.56066C3.15804 5.27936 3 4.89782 3 4.5C3 4.10218 3.15804 3.72064 3.43934 3.43934C3.72064 3.15804 4.10218 3 4.5 3C4.89782 3 5.27936 3.15804 5.56066 3.43934C5.84196 3.72064 6 4.10218 6 4.5C6 4.89782 5.84196 5.27936 5.56066 5.56066C5.27936 5.84196 4.89782 6 4.5 6C4.10218 6 3.72064 5.84196 3.43934 5.56066Z",fill:"#537388"}),e.createElement("path",{d:"M10.9393 13.0607C10.658 12.7794 10.5 12.3978 10.5 12C10.5 11.6022 10.658 11.2206 10.9393 10.9393C11.2206 10.658 11.6022 10.5 12 10.5C12.3978 10.5 12.7794 10.658 13.0607 10.9393C13.342 11.2206 13.5 11.6022 13.5 12C13.5 12.3978 13.342 12.7794 13.0607 13.0607C12.7794 13.342 12.3978 13.5 12 13.5C11.6022 13.5 11.2206 13.342 10.9393 13.0607Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 20.5607C3.15804 20.2794 3 19.8978 3 19.5C3 19.1022 3.15804 18.7206 3.43934 18.4393C3.72064 18.158 4.10218 18 4.5 18C4.89782 18 5.27936 18.158 5.56066 18.4393C5.84196 18.7206 6 19.1022 6 19.5C6 19.8978 5.84196 20.2794 5.56066 20.5607C5.27936 20.842 4.89782 21 4.5 21C4.10218 21 3.72064 20.842 3.43934 20.5607Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 13.0607C3.15804 12.7794 3 12.3978 3 12C3 11.6022 3.15804 11.2206 3.43934 10.9393C3.72064 10.658 4.10218 10.5 4.5 10.5C4.89782 10.5 5.27936 10.658 5.56066 10.9393C5.84196 11.2206 6 11.6022 6 12C6 12.3978 5.84196 12.7794 5.56066 13.0607C5.27936 13.342 4.89782 13.5 4.5 13.5C4.10218 13.5 3.72064 13.342 3.43934 13.0607Z",fill:"#537388"}),e.createElement("path",{d:"M10.9393 5.56066C10.658 5.27936 10.5 4.89782 10.5 4.5C10.5 4.10218 10.658 3.72064 10.9393 3.43934C11.2206 3.15804 11.6022 3 12 3C12.3978 3 12.7794 3.15804 13.0607 3.43934C13.342 3.72064 13.5 4.10218 13.5 4.5C13.5 4.89782 13.342 5.27936 13.0607 5.56066C12.7794 5.84196 12.3978 6 12 6C11.6022 6 11.2206 5.84196 10.9393 5.56066Z",fill:"#537388"})),jt={prefix:"far",iconName:"custom-hand-pointer-slash",icon:[641,512,[],"???","M185.554191,59.5126699 C189.248662,26.0794907 217.382589,0 251.429,0 C287.979,0 317.715,30.056 317.715,67 L317.715,140.634 C338.128,137.776 359.183,144.576 374.31,160.263 C401.503,147.416 434.689,154.593 454.182,179.361 C497.375,162.727 544,195.156 544,242 L544,326 C544,330.296189 543.590626,334.580726 542.780274,338.796073 L495.999,302.221942 L495.999,242 C495.999,216.84 459.428,216.879 459.428,242 C459.428,250.836 452.265,258 443.428,258 L439.435556,258 L420.622383,243.291649 C420.588346,242.865584 420.571,242.434817 420.571,242 L420.571,221 C420.571,197.943344 389.858993,196.049429 384.724023,215.225903 L269.713,125.308981 L269.713,67 C269.713,41.84 233.142,41.88 233.142,67 L233.142,96.717359 L185.554191,59.5126699 Z M162.172457,223.995642 L233.142,279.479508 L233.142,308.493 C233.142,324.063 213.106,330.402 204.111,317.776 L176.985,279.697 C162.585,259.485 133.185,282.08 147.591,302.303 L257.303,456.303 C260.737,461.122 266.231,464 272,464 L450.285,464 C455.041109,464 459.427079,462.119816 462.713129,458.957818 L500.616335,488.590478 C488.331086,503.061811 470.146238,512 450.286,512 L272,512 C250.741,512 230.632,501.59 218.209,484.154 L108.51,330.153 C87.267,300.334 93.705,258.796 123.06,237.001 C134.952446,228.171597 148.664261,223.998532 162.172457,223.995642 Z M272.143,309.970422 L306.143,336.551563 L306.143,400 C306.143,408.837 299.875,416 292.143,416 L286.143,416 C278.41,416 272.143,408.837 272.143,400 L272.143,309.970422 Z M347.571,368.939901 L381.571,395.521042 L381.571,400 C381.571,408.837 375.303,416 367.571,416 L361.571,416 C353.839,416 347.571,408.837 347.571,400 L347.571,368.939901 Z M633.994211,471.020009 C640.904211,476.540009 642.014211,486.610009 636.494211,493.510009 L626.494211,506 C620.964211,512.890009 610.904211,514.010009 604.004211,508.490009 L6.00421069,40.9800088 C-0.895789309,35.4600088 -2.01578931,25.3900088 3.51421069,18.4900088 L13.5142107,6 C19.0342107,-0.899991212 29.1042107,-2.00999121 36.0042107,3.51000879 L633.994211,471.020009 Z"]},Xt={CLICK:qe,DISABLED:U,MOUSEDOWN:Et,NOT_CLICK:jt,NOT_DISABLED:X,NOT_PRESENT:Ge,PRESENT:ye},$t={COMPLETED:X,NOT_COMPLETED:U,NOT_SEEN:Ge,ACTIVE:vt,NOT_ACTIVE:bt,SEEN:ye},Kt={CLICK:"is clicked",DISABLED:"is disabled",MOUSEDOWN:"has mouse down on it",NOT_CLICK:"is not clicked",NOT_DISABLED:"is not disabled",NOT_PRESENT:"is not present",PRESENT:"is present"};function Zt(t){return Kt[t]}const Qt={COMPLETED:"completed",NOT_COMPLETED:"not completed",NOT_SEEN:"not seen",ACTIVE:"is currently active",NOT_ACTIVE:"is not currently active",SEEN:"seen"};function Jt(t){return Qt[t]}function en(t,n){let r=(n||"").toLowerCase();return(t.eventTimeOperator===M.RELATIVE_BETWEEN?t.eventRelativeValue2:t.eventRelativeValue)!==1&&(r+="s"),t.eventTimeOperator!==M.RELATIVE_GT&&(r+=" ago"),r}function tn(t){return(t.eventFrequencyOperator===Y.BETWEEN?t.eventFrequencyValue2:t.eventFrequencyValue)===1?"time":"times"}const nn={CURRENT_USER:"by current user in any company",CURRENT_USER_CURRENT_GROUP:"by current user in current company",CURRENT_GROUP:"by any user in current company"};function rn(t){return nn[t]}function sn(t){if(!t)return"";switch(t){case Y.BETWEEN:return"between";case Y.EQ:return"exactly";case Y.GTE:return"at least";case Y.LTE:return"at most"}}function on(t){if(!t)return"";switch(t){case M.ANY:return"at any point in time";case M.RELATIVE_BETWEEN:return"between";case M.RELATIVE_GT:return"in the last";case M.RELATIVE_LT:return"more than"}}const an={1:"Lowest",2:"Low",3:"Medium",4:"High",5:"Highest"};function ln(t){return`${an[t]||String(t)} priority`}function be(t,n){switch(t){case se.DAY:return n===1?"day":"days";case se.HOUR:return n===1?"hour":"hours";case se.MINUTE:return n===1?"minute":"minutes";case se.SECOND:return n===1?"second":"seconds"}}function Re(t){switch(t){case"USER":return Ce;case"GROUP":return _t;case"GROUP_MEMBERSHIP":return wt;case"EVENT":return ze}}function cn(t){const n=t.split("/");if(n.length===1)return["USER",t];switch(n[0]){case"group":return["GROUP",n[1]];case"group_membership":return["GROUP_MEMBERSHIP",n[1]];case"event":return["EVENT",n[1]]}return console.warn("parseAttributeDefinitionFqn: Invalid attribute definition FQN",t),["USER",t]}const un={[G.BANNER]:"banner",[G.CHECKLIST]:"checklist",[G.FLOW]:"flow",[G.EMBED]:"embed",[G.LAUNCHER]:"launcher",[G.RESOURCE_CENTER]:"resource center"};function dn(t,{title:n,plural:r}={}){let s=un[t];return n&&(s=Ee.upperFirst(s)),r&&(s+="s"),s}let Le=!1;const Q=[];function Me(t){Q.push(t),Le||(Le=!0,window.addEventListener("keydown",n=>{if(n.key==="Escape"){const r=Q[Q.length-1];r&&(r(),n.stopImmediatePropagation())}}))}function Ae(t){const n=Q.indexOf(t);n>=0&&Q.splice(n,1)}const I=[];let Se=0;typeof window<"u"&&window.document.documentElement.addEventListener("mousedown",()=>Se++,{capture:!0});function mn(t){const n={cmp:t,zIndex:Je(),mountMouseDownCounter:Se};I.push(n),I.length===1&&document.documentElement.addEventListener("click",et,{capture:!0})}function pn(t){const n=I.findIndex(r=>r.cmp===t);I.splice(n,1),I.length===0&&document.documentElement.removeEventListener("click",et,{capture:!0})}function fn(t){const n=I.find(r=>r.cmp===t);return n?n.zIndex:Je()}function Je(){const t=I[I.length-1];return t?t.zIndex+100:1e3}function gn(t,n){const r=t.rootRef.current;return!!r&&r.contains(n)}function et(t){const n=t.target;if(n.closest("#userflow-ui, #notifications"))return;const r=I.findIndex(s=>gn(s.cmp,n));for(let s=I.length-1;s>r;s--){const o=I[s];o&&o.mountMouseDownCounter<Se&&o.cmp.closeLayer(t)}}const we=8,hn=we*2,En=8,Ue=50,j=8,ke=24,vn=8;class tt extends e.PureComponent{constructor(){super(...arguments),this.rootRef=e.createRef(),this.notchRef=e.createRef(),this.bodyRef=e.createRef(),this.state={},this.onAnimationFrame=()=>{this.reposition(),this.requestAnimationFrame()},this.onClick=n=>{n.stopPropagation(),this.props.onClick&&this.props.onClick(n)},this.closeLayer=n=>{if(this.props.ignoreTargetClick){const r=this.props.target,s=n.target;if(r&&s&&r.contains(s))return}this.fireOnDismiss({reason:"outside-click",event:n})},this.onEscape=()=>this.fireOnDismiss({reason:"escape"})}get el(){return this.rootRef.current}componentDidMount(){mn(this),this.props.onDismiss&&Me(this.onEscape),window.addEventListener("userflow:hideAllPopovers",this.closeLayer),this.requestAnimationFrame(),this.reposition()}componentWillUnmount(){pn(this),Ae(this.onEscape),window.removeEventListener("userflow:hideAllPopovers",this.closeLayer),window.cancelAnimationFrame(this.raf)}componentDidUpdate(n){const{props:r}=this;this.reposition(),!n.onDismiss&&r.onDismiss?Me(this.onEscape):n.onDismiss&&!r.onDismiss&&Ae(this.onEscape)}render(){const{props:n}=this,r=this.state,s=["popover"];n.className&&s.push(n.className),s.push(`popover--placement-${r.actualPlacement}`);const o=e.createElement("div",{className:s.join(" "),ref:this.rootRef,onMouseDown:n.onMouseDown,onMouseEnter:n.onMouseEnter,onClick:this.onClick,style:{zIndex:fn(this)}},e.createElement("div",{className:"popover__body",ref:this.bodyRef},n.children),!n.noNotch&&this.renderNotch());return he.createPortal(o,(n.document||document).body)}renderNotch(){const n=we,r=n*2;return e.createElement("div",{ref:this.notchRef,className:"popover__notch"},e.createElement("svg",{viewBox:`0 0 ${r} ${n}`},e.createElement("polygon",{className:"popover__notch-border",points:`${r/2},0 ${r},${n} 0,${n}`}),e.createElement("polygon",{className:"popover__notch-fill",points:`${r/2},1 ${r},${n+1} 0,${n+1}`})))}requestAnimationFrame(){this.raf=window.requestAnimationFrame(this.onAnimationFrame)}reposition(){const{props:n}=this,r=n.target,s=this.rootRef.current,o=this.notchRef.current,a=n.placement||"bottom",l=ae(a),c=!!n.forceDimension,g=n.horizontalAlign,_=n.verticalAlign,h=!!n.noNotch,v=document.documentElement.clientWidth,y=document.documentElement.clientHeight,p=r?.getBoundingClientRect(),b=p?.left,f=p?.top,w=p?.width,u=p?.height;let C=n.width;n.matchWidth&&(C=w);let x=n.minWidth;n.matchMinWidth&&w!=null&&(x=Math.max(w,x||0)),(this.lastPopoverCssWidth!==C||this.lastPopoverMinWidth!==x)&&(s.style.width=C==null?"":Math.round(C)+"px",s.style.minWidth=x==null?"":Math.round(x)+"px");const k=s.getBoundingClientRect(),D=k?.width,P=k?.height,V=parseInt((window.getComputedStyle(s).borderTopLeftRadius||"").replace(/px/,""),10),ee=window.scrollX,te=window.scrollY;if(this.lastPlacement===a&&this.lastForceDimension===c&&this.lastHorizontalAlign===g&&this.lastVerticalAlign===_&&this.lastNoNotch===h&&this.lastViewportWidth===v&&this.lastViewportHeight===y&&this.lastTargetX===b&&this.lastTargetY===f&&this.lastTargetWidth===w&&this.lastTargetHeight===u&&this.lastPopoverCssWidth===C&&this.lastPopoverMinWidth===x&&this.lastPopoverWidth===D&&this.lastPopoverHeight===P&&this.lastPopoverBorderRadius===V&&this.lastScrollX===ee&&this.lastScrollY===te)return;let ne,H=null;if(b!=null&&f!=null&&w!=null&&u!=null){ne=!0;const L=h?0:En,Pe=Ve(b,w,D,v,g||"left"),Ie=Ve(f,u,P,y,_||"top");let re=[{placement:"top",x:Pe,y:f-P-L,fits:P<f-L-j},{placement:"bottom",x:Pe,y:f+u+L,fits:P<y-(f+u)-L-j},{placement:"left",x:b-D-L,y:Ie,fits:D<=b-L-j},{placement:"right",x:b+w+L,y:Ie,fits:D<=v-(b+w)-L-j}];c&&(re=re.filter(T=>ae(T.placement)===l)),re.sort((T,N)=>{const S=ae(T.placement),B=ae(N.placement);return T.fits!==N.fits?T.fits?-1:1:T.placement===a?-1:N.placement===a?1:S!==B?S===l?-1:1:T.placement==="bottom"||T.placement==="right"?-1:1});const de=re[0];let $=de.x,K=de.y;if(H=de.placement,$+=ee,K+=te,$=Math.round($),K=Math.round(K),s.style.transform=`translate3d(${$}px, ${K}px, 0px)`,!h&&o){const T=Math.max(vn,V);let N,S;if(H==="left"||H==="right"){const B=f+u/2-we/2;u<=Ue||_==="center"?S=B:S=Math.min(f,B),S+=-K+te,S=Math.max(T,Math.min(P-T,S))}else{const B=b+w/2-hn/2;w<=Ue||g==="center"?N=B:N=Math.min(b,B),N+=-$+ee,N=Math.max(T,Math.min(D-T,N))}N=N&&Math.round(N),S=S&&Math.round(S),o.style.left=N==null?"":N+"px",o.style.top=S==null?"":S+"px"}}else ne=!1,s.style.transform="translate3d(-999999px, -999999px, 0px)";ne&&!this.lastVisible&&n.onShow&&n.onShow(),H!==this.lastActualPlacement&&(this.setState({actualPlacement:H}),n.onPlacementChange&&n.onPlacementChange(H)),this.lastVisible=ne,this.lastPlacement=a,this.lastActualPlacement=H,this.lastForceDimension=c,this.lastHorizontalAlign=g,this.lastVerticalAlign=_,this.lastNoNotch=h,this.lastViewportWidth=v,this.lastViewportHeight=y,this.lastTargetX=b,this.lastTargetY=f,this.lastTargetWidth=w,this.lastTargetHeight=u,this.lastPopoverCssWidth=C,this.lastPopoverMinWidth=x,this.lastPopoverWidth=D,this.lastPopoverHeight=P,this.lastPopoverBorderRadius=V,this.lastScrollX=ee,this.lastScrollY=te}fireOnDismiss(n){const{onDismiss:r}=this.props;r&&r(n),!this.props.noTargetRefocus&&n.reason==="escape"&&this.props.target&&this.props.target.focus()}}function ae(t){return t==="left"||t==="right"?"x":"y"}function Ve(t,n,r,s,o){let a;return o==="center"?a=t+n/2-r/2:a=t,a=Math.max(a,j),a=Math.min(a,s-r-j),a=Math.max(a,t+ke-r),a=Math.min(a,t+n-ke),a}const bn=["yyyy-MM-dd","yyyy/MM/dd","MM-dd yyyy","MM/dd yyyy","MM-dd-yyyy","MM/dd/yyyy","MM-dd","MM/dd","dd MMM yyyy","dd MMMM yyyy","MMM dd yyyy","MMMM dd yyyy","dd MMM","dd MMMM","MMM dd","MMMM dd"],wn=["hh:mmaaa","hh.mmaaa","hh:mm aaa","hh.mm aaa","HH:mm","HH.mm","hhaaa","hh aaa","HH"];for(const t of bn)for(const n of wn);const _n="d MMM yyyy";function He(t){if(t==null)return"";const n=yn?t.getMinutes()===0?"h aaa":"h:mm aaa":"HH:mm";return xe(t,_n+", "+n)}function Cn(t){if(!t)return null;const n=Vt(t,"yyyy-MM-dd",new Date);return isNaN(n.valueOf())?null:n}function Be(t){if(!t)return null;const n=Ht(t);return isNaN(n.valueOf())?null:n}const yn=Intl.DateTimeFormat(Intl.DateTimeFormat().resolvedOptions().locale,{hour:"numeric"}).resolvedOptions().hourCycle==="h12";var nt=(t=>(t.EVENT="EVENT",t.GROUP="GROUP",t.GROUP_MEMBERSHIP="GROUP_MEMBERSHIP",t.USER="USER",t))(nt||{});function ce(){const[t,n]=i.useState(!1),r=i.useRef(null),s=i.useCallback(()=>n(!0),[]),o=i.useCallback(()=>n(!1),[]),a=i.useCallback(()=>n(!0),[]),l=i.useCallback(()=>n(!1),[]);return{ref:r,hovered:t,eventHandlers:{onPointerEnter:s,onPointerLeave:o,onFocus:a,onBlur:l}}}function We(t){return({condition:n})=>{throw new Error(`conditionOperators.${n.operator}.${t} is not supported`)}}const pe={[d.ABSOLUTE_EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"on")," ",e.createElement("span",{className:"nowrap text-bold"},ge(t.value)))},[d.ABSOLUTE_GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"after")," ",e.createElement("span",{className:"nowrap text-bold"},ge(t.value)))},[d.ABSOLUTE_LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"before")," ",e.createElement("span",{className:"nowrap text-bold"},ge(t.value)))},[d.AND]:{Preview:We("Preview")},[d.BETWEEN]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is between")," ",e.createElement("b",null,t.value)," ",e.createElement("span",{className:"text-secondary"},"and")," ",e.createElement("b",null,t.value2))},[d.CONTAINS]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"contains")," ",e.createElement("b",null,t.value))},[d.EMPTY]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is empty")},[d.ENDS_WITH]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"ends with")," ",e.createElement("b",null,t.value))},[d.EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is")," ",e.createElement("b",null,t.dataType===Fe.FLOW&&t.value?e.createElement("span",null,t?.eventDisplayName??t.eventName):t.value))},[d.EXCLUDES_ALL]:{Preview:({condition:t})=>le(t,"does not include","all of")},[d.EXCLUDES_ANY]:{Preview:({condition:t})=>le(t,"does not include","at least one of")},[d.FALSE]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is false")},[d.GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is greater than")," ",e.createElement("b",null,t.value))},[d.GTE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is greater than or equal to")," ",e.createElement("b",null,t.value))},[d.INCLUDES_ALL]:{Preview:({condition:t})=>le(t,"includes","all of")},[d.INCLUDES_ANY]:{Preview:({condition:t})=>le(t,"includes","at least one of")},[d.LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is less than")," ",e.createElement("b",null,t.value))},[d.LTE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is less than or equal to")," ",e.createElement("b",null,t.value))},[d.NE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is not")," ",e.createElement("b",null,t.dataType===Fe.FLOW&&t.value?e.createElement("span",null," ",t?.eventDisplayName??t.eventName):t.value))},[d.NOT_CONTAINS]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not contain")," ",e.createElement("b",null,t.value))},[d.NOT_EMPTY]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"has any value")},[d.NOT_REGEX]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not match")," ",e.createElement("b",null,t.value))},[d.OR]:{Preview:We("Preview")},[d.REGEX]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"matches")," ",e.createElement("b",null,t.value))},[d.RELATIVE_EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"exactly")," ",e.createElement("span",{className:"nowrap text-bold"},fe(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[d.RELATIVE_GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"less than")," ",e.createElement("span",{className:"nowrap text-bold"},fe(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[d.RELATIVE_LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"more than")," ",e.createElement("span",{className:"nowrap text-bold"},fe(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[d.STARTS_WITH]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"starts with")," ",e.createElement("b",null,t.value))},[d.TRUE]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is true")},[d.URL]:{Preview:({condition:t})=>{const{urlPattern:n}=t;if(!n)return e.createElement("span",{className:"text-secondary"},"matches ...");const{includes:r,excludes:s}=n;return e.createElement(e.Fragment,null,r.length>0&&e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"matches")," ",r.map((o,a)=>e.createElement(e.Fragment,{key:a},a>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",null,o)))),r.length>0&&s.length>0&&e.createElement("span",{className:"text-secondary"}," and "),s.length>0&&e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not match")," ",s.map((o,a)=>e.createElement(e.Fragment,{key:a},a>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",null,o)))))}}};function xn(t){return parseInt(t,10)}function fe(t){if(!t)return"days";const n=xn(t);return isNaN(n)?"days":n+" "+(n===1?"day":"days")}function ge(t){if(!t)return"";const n=Cn(t);return n?xe(n,"PP"):""}function le(t,n,r){const s=t.values||[];return e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},n+(s.length>1?" "+r:""))," ",s.map((o,a)=>e.createElement(e.Fragment,{key:a},a>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",{key:a},o))))}const Oe=t=>({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":t===!0,"userflow-debugger-condition__item__danger":t===!1,"userflow-debugger-condition__item__intermediate":t===null}),De=t=>t===!0?A:t===!1?U:W,rt=(t,n)=>{const r=F();return i.useMemo(()=>{const a=(n?r?.hiddenCondition?.breakdown:r?.startCondition?.breakdown)?.find(l=>l.conditionId===t.id);return{classes:Oe(a?.match),icon:De(a?.match)}},[t,r,n])},ie=t=>{const{condition:n,isHideCond:r}=t,{classes:s,icon:o}=rt(n,r),a=n.type;if(a===O.CLAUSE)return e.createElement(Tn,{...t});const l=ot[a];return e.createElement("div",{className:E(s)},e.createElement("span",{className:"d-flex gap-8 align-center userflow-debugger-condition__item__icon"},l.icon?e.createElement(m,{icon:l.icon({condition:n})}):null,e.createElement(l.Preview,{...t})),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:o}))},Nn=()=>{const t=F(),[n,r]=i.useState(!1),s=i.useMemo(()=>t?.hiddenCondition?.breakdown.find(a=>a.conditionId===t?.hiddenCondition?.condition.id),[t?.hiddenCondition]);return t?.hiddenCondition?.condition?e.createElement("div",{role:"button",className:E({"d-flex gap-8 flex-column margin-8":!0,"userflow-debugger-condition__clause":!0,"userflow-debugger-hide-condition__clause__success":s?.match===!0,"userflow-debugger-hide-condition__clause__danger":s?.match===!1,"userflow-debugger-hide-condition__clause__expanded":n}),onClick:o=>{r(!n),o.stopPropagation()}},e.createElement("div",{className:"d-flex gap-8 justify-space-between align-center"},e.createElement("span",null,"Termporarily hide flow"," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to ",n?"collapse":"expand")),e.createElement(m,{icon:Z})),n&&e.createElement(ie,{isRoot:!0,isHideCond:!0,condition:t?.hiddenCondition?.condition})):null},Tn=({condition:t,isRoot:n=!1,isHideCond:r=!1})=>{const[s,o]=i.useState(!1),{classes:a,icon:l}=rt(t,r);return n?e.createElement(e.Fragment,null,t.conditions.map((c,g)=>e.createElement(ie,{isHideCond:r,key:g,condition:c}))):e.createElement("div",{role:"button",className:E({"d-flex flex-column gap-8":!0,"userflow-debugger-condition__clause":s,...s?{"userflow-debugger-condition__item__success__expanded":a["userflow-debugger-condition__item__success"],"userflow-debugger-condition__item__danger__expanded":a["userflow-debugger-condition__item__danger"],"userflow-debugger-condition__item__intermediate__expanded":a["userflow-debugger-condition__item__intermediate"]}:a}),onClick:c=>{o(!s),c.stopPropagation()}},e.createElement("div",{className:"d-flex justify-space-between align-center w-full"},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:Dt})," ",e.createElement("strong",null,"Logic Group")," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to ",s?"collapse":"expand")),!s&&e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:l})),s&&e.createElement(e.Fragment,null,t.conditions.map((c,g)=>e.createElement("div",{key:g,className:E({"userflow-debugger-condition__clause__operator__wrapper":!0})},g>0&&e.createElement("div",{className:E({"userflow-debugger-condition__clause__operator":!0})},e.createElement(st,{condition:t})),e.createElement(ie,{isHideCond:r,condition:c})))))},st=({condition:t})=>{const n=t.operator;return n?e.createElement("span",{className:E({"userflow-debugger-condition__item__operator":!0,"userflow-debugger-condition__item__operator__and":n===d.AND,"userflow-debugger-condition__item__operator__or":n===d.OR})},n===d.AND&&"AND",n===d.OR&&"OR"):null},Sn={[R.NONE]:U,[R.PENDING_SCHEDULE]:U,[R.SCHEDULED]:W,[R.FIRED]:A},On=e.memo(()=>{const t=F(),{waitTimer:n}=t||{},r=t?.startCondition?.condition.waitTime,{ref:s,hovered:o,eventHandlers:a}=ce();return!r||!n||n===R.NONE?null:e.createElement("div",{ref:s,...a,className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__danger":n===R.PENDING_SCHEDULE,"userflow-debugger-condition__item__intermediate":n===R.SCHEDULED,"userflow-debugger-condition__item__success":n===R.FIRED})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:Ct}),e.createElement("span",null,"Wait ",e.createElement("strong",null,r)," seconds")),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:Sn[n]}),e.createElement(ue,{target:s,hovered:o&&n===R.PENDING_SCHEDULE},"Timer activates once all conditions are satisfied"))}),Dn=e.memo(()=>{const t=F(),[n,r]=i.useState(!1),{startFrequency:s,listFlowLatestVersion:o}=t||{startFrequency:{}};if(!s||!o?.startFrequency||o?.startFrequency===z.NEVER)return null;const{currentFlowIntervalThrottle:a,frequency:l,frequencyUsage:c}=s,g=De(l),_=Oe(l);if(o.startFrequency===z.ONCE||o.startFrequency===z.ONCE_PER_GROUP)return e.createElement("div",{className:E(_)},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:Ye}),e.createElement("strong",null,"Once per user"," ",o.startFrequency===z.ONCE_PER_GROUP&&"per company")),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:g}));if(o.startFrequency===z.ALWAYS&&o.startIntervalValue&&o.startIntervalUnit)return e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":a===!0,"userflow-debugger-condition__item__intermediate":a===!1})},e.createElement("span",null,"Every ",e.createElement("strong",null,o.startIntervalValue)," ",e.createElement("span",{className:"userflow-debugger-info-text"},be(o.startIntervalUnit,o.startIntervalValue)," ","apart")),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:a===!1?W:A}));if(o.startFrequency===z.MULTIPLE){const h=l===!0&&a===!0,v=l===!0&&a===!1,y=l===!1;return e.createElement("div",{className:E({"d-flex flex-column gap-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__clause":n,...n?{"userflow-debugger-condition-frequency__success__expanded":h,"userflow-debugger-condition-frequency__intermediate__expanded":v,"userflow-debugger-condition-frequency__danger__expanded":y}:{"userflow-debugger-condition-frequency__success":h,"userflow-debugger-condition-frequency__intermediate":v,"userflow-debugger-condition-frequency__danger":y}}),onClick:p=>{r(!n),p.stopPropagation()}},e.createElement("div",{className:"d-flex gap-8 justify-space-between"},e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement("strong",null,"Start multiple times")," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to expand")),!n&&e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:h?A:v?W:U})),n&&e.createElement(e.Fragment,null,e.createElement("div",{className:E(_)},e.createElement("span",null,e.createElement("strong",null,o.startLimit)," ",e.createElement("span",{className:"userflow-debugger-info-text"},"(started ",c," times)")),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:g})),o.startIntervalUnit&&o.startIntervalValue&&e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":a===!0,"userflow-debugger-condition__item__intermediate":a===!1})},e.createElement("span",null,e.createElement("strong",null,o.startIntervalValue)," ",e.createElement("span",{className:"userflow-debugger-info-text"},be(o.startIntervalUnit,o.startIntervalValue)," ","apart")),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:a===!1?W:A}))))}return null}),Pn=()=>{const t=F(),{priority:n}=t||{};return n?.priority?e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__priority":!0})},e.createElement("span",null,e.createElement("strong",null,ln(n?.priority))," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to learn more")),e.createElement("a",{href:"https://docs.userflow.com/docs/trouble/using-the-debugger#flow-trigger-precedence",target:"_blank",rel:"noreferrer noopener"},e.createElement(m,{icon:je}))):null},In=()=>{const t=F(),{startFrequency:n}=t||{},{onlyIfNotCompleted:r}=n||{};return r==null?null:e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":r===!0,"userflow-debugger-condition__item__danger":r===!1})},"Only if not completed",e.createElement(m,{icon:r===!0?A:U}))},Fn=()=>{const t=F(),{startFrequency:n}=t||{},{hovered:r,eventHandlers:s,ref:o}=ce();return!n||n?.scopeByGroup===null||n.scopeByGroup===void 0||n.scopeByGroup===!0?null:e.createElement("div",{ref:o,...s,className:E({"d-flex align-center margin-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__danger":!0})},"Constrain to current company",e.createElement(m,{icon:De(n.scopeByGroup)}),e.createElement(ue,{target:o,hovered:r},"User is not associated with a company"))},Rn=()=>{const t=F(),{startFrequency:n,listFlowLatestVersion:r}=t||{},{anyFlowIntervalThrottle:s}=n||{},{throttleUnit:o,throttleValue:a}=r||{};return s===null||o===null||a===null||o===void 0||a===void 0?null:e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":s===!0,"userflow-debugger-condition__item__intermediate":s===!1})},e.createElement("span",null,"Atleast ",e.createElement("strong",null,r?.throttleValue)," ",be(o,a)," after any flow"),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:s===!0?A:W}))},Ln=e.memo(()=>{const{hovered:t,eventHandlers:n,ref:r}=ce(),s=F(),{snoozed:o}=s||{},a=i.useMemo(()=>{if(o?.until)return xe(new Date(o.until),"MMM do, h:mm a")},[o?.until]);return o?e.createElement("div",{ref:r,...n,className:E({"d-flex align-center margin-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__intermediate":!0})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:yt}),e.createElement("span",null,"This flow is currently ",e.createElement("strong",null,"snoozed"))),e.createElement(m,{dataAttrs:{"data-condition-status":"true"},icon:W}),e.createElement(ue,{target:r,hovered:t},"Snoozed until ",a)):null}),ot={[O.PAGE]:{icon:()=>xt,Preview:({condition:t})=>{const n=t.operator&&pe[t.operator];return e.createElement("span",null,"URL"," ",e.createElement("strong",null,n&&e.createElement(n.Preview,{condition:t})))}},[O.ATTRIBUTE]:{icon:({condition:t})=>{if(!t||!t.attributeName)return Re(nt.EVENT);const[n]=cn(t.attributeName);return Re(n)},Preview:({condition:t})=>{const n=t.operator&&pe[t.operator];return e.createElement("span",null,e.createElement("strong",null,t.attributeDisplayName?t.attributeDisplayName:"Attribute")," ",e.createElement("span",{className:"userflow-debugger-info-text"},n&&e.createElement(n.Preview,{condition:t})))}},[O.SEGMENT]:{icon:()=>Nt,Preview:({condition:t})=>{const{segment:n}=t;return e.createElement("span",null,e.createElement("strong",null,n?.subjectType===ut.GROUP?"Company":"User")," ",e.createElement("span",{className:"text-secondary"},t.operator===d.FALSE?"is not in":"is in")," ",e.createElement("strong",null,n?.name||"Segment"))}},[O.ELEMENT]:{icon:({condition:t})=>t.elementState?Xt[t.elementState]:Tt,Preview:({condition:t})=>e.createElement("span",null,"Element"," ",t.elementState&&e.createElement("strong",null,Zt(t.elementState)))},[O.INPUT_VALUE]:{icon:()=>St,Preview:({condition:t})=>{const n=t.operator&&pe[t.operator];return e.createElement("span",null,"The value of input"," ",e.createElement("strong",null,n&&e.createElement(n.Preview,{condition:t})))}},[O.FILLED_IN_INPUT]:{icon:()=>Ot,Preview:()=>e.createElement("span",null,"User fills an input")},[O.FLOW]:{icon:({condition:t})=>t.flowState?$t[t.flowState]:ye,Preview:({condition:t})=>e.createElement("span",null,t.flow?e.createElement(e.Fragment,null,dn(t.flow.type,{title:!0})," ",e.createElement("strong",null,t.flow.name)):"Flow/checklist"," ",t.flowState&&Jt(t.flowState))},[O.TIME]:{icon:()=>Ye,Preview:({condition:t})=>{const n=t.value?Be(t.value):null,r=n&&e.createElement("strong",{style:{whiteSpace:"nowrap"}},He(n)),s=t.value2?Be(t.value2):null,o=s&&e.createElement("strong",{style:{whiteSpace:"nowrap"}},He(s));return r&&o?e.createElement("span",null,"Current time is between ",r," and ",o):r?e.createElement(e.Fragment,null,"Current time is after ",r):o?e.createElement(e.Fragment,null,"Current time is before ",o):e.createElement(e.Fragment,null,"Current time is ...")}},[O.EVENT]:{icon:()=>ze,Preview:({condition:t})=>{const{ref:n,hovered:r,eventHandlers:s}=ce();return e.createElement("div",{ref:n,...s},e.createElement("strong",null,t.eventDisplayName?t.eventDisplayName:"Event")," ",e.createElement("span",{className:"userflow-debugger-info-text"},sn(t.eventFrequencyOperator))," ",e.createElement("strong",null,t.eventFrequencyValue),t.eventFrequencyOperator===Y.BETWEEN&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"userflow-debugger-info-text"},"and")," ",e.createElement("strong",null,t.eventFrequencyValue2))," ",e.createElement("span",{className:"userflow-debugger-info-text"},tn(t),","," ",on(t.eventTimeOperator)),t.eventTimeOperator!==M.ANY&&e.createElement(e.Fragment,null," ",e.createElement("strong",null,t.eventRelativeValue),t.eventTimeOperator===M.RELATIVE_BETWEEN&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"userflow-debugger-info-text"},"and")," ",e.createElement("strong",null,t.eventRelativeValue2))," ",e.createElement("span",{className:"userflow-debugger-info-text"},en(t,t.eventRelativeUnit))),t.eventActor&&t.eventActor!==dt.CURRENT_USER?e.createElement(e.Fragment,null," ",e.createElement("strong",null,rn(t.eventActor))):"",t.whereCondition&&r&&e.createElement(ue,{hovered:!0,target:n},"Where ",e.createElement("br",null),e.createElement(at,{condition:t.whereCondition})))}},[O.ALWAYS_TRUE]:{icon:()=>A,Preview:()=>e.createElement("span",null,"Water is wet")},[O.CHECKLIST_TASK_CLICKED]:{icon:()=>qe,Preview:()=>e.createElement("span",null,"Task is clicked")}},at=t=>e.createElement("div",null,t.condition.conditions.map((n,r)=>e.createElement("div",{key:n.id}," ",r===0?null:e.createElement("span",{className:"userflow-debugger-info-text"},t.condition.operator?.toLowerCase())," ",n.type==="ATTRIBUTE"&&ot.ATTRIBUTE.Preview({condition:n,isRoot:!0,isHideCond:!1}),n.type==="CLAUSE"&&e.createElement(e.Fragment,null,"(",e.createElement(at,{condition:n}),")")))),ue=({hovered:t,children:n,target:r})=>{const s=Ne();return t?e.createElement(tt,{className:"userflow-debugger-popover",target:r.current,placement:"top",horizontalAlign:"center",verticalAlign:"center",document:s?.current?.contentDocument||void 0},n):null};class Mn extends e.PureComponent{constructor(n){super(n),this.rootRef=e.createRef(),this.optionsElRef=e.createRef(),this.input=null,this.popoverRef=e.createRef(),this.isMouseDown=!1,this.isCreateOpen=!1,this.setInput=r=>{this.input=r;const{inputRef:s}=this.props;s&&(typeof s=="function"?s(r):s.current=r)},this.onInputChange=r=>{r.stopPropagation();const{value:s}=r.target;s!==""&&this.openPopover();const o=this.memoizedFilterOptions(this.props.options,s);this.setState({inputValue:s,q:s,highlightedIndex:o.length>0?0:-1,createHighlighted:o.length===0}),s===""&&!this.props.noEmpty&&this.triggerOnChange(null),this.props.onSearchChange&&this.props.onSearchChange(s)},this.onPopoverPlacementChange=r=>this.setState({popoverPlacement:r}),this.onMouseDown=r=>{r.preventDefault(),this.isMouseDown=!0;const s=()=>{this.isMouseDown=!1,this.props.document?.removeEventListener("mouseup",s),document.body.removeEventListener("mouseup",s)};this.props.document?.addEventListener("mouseup",s),document.body.addEventListener("mouseup",s)},this.onFocus=r=>{this.input&&!this.props.noSearch&&this.input.select(),this.props.onFocus&&this.props.onFocus(r)},this.onBlur=r=>{this.isMouseDown||this.closePopover(),this.props.onBlur&&!this.isCreateOpen&&this.props.onBlur(r)},this.onTriggerClick=()=>{this.props.readOnly||this.props.disabled||(this.state.popoverOpen?this.closePopover():(this.input&&this.input.focus(),this.openPopover()))},this.onKeyDown=r=>{const{popoverOpen:s,highlightedIndex:o,createHighlighted:a}=this.state,l=this.getFilteredOptions(),c=l.length-1;switch(r.key){case"ArrowUp":r.preventDefault(),s&&(a?this.setState({highlightedIndex:c,createHighlighted:!1}):o>0&&this.setState({highlightedIndex:o-1}));break;case"ArrowDown":r.preventDefault(),s?this.props.onCreate&&(o===c||a)?this.setState({highlightedIndex:-1,createHighlighted:!0}):o<c&&this.setState({highlightedIndex:o+1}):this.props.noOpenOnDown||this.openPopover();break;case"Enter":if(s)if(r.preventDefault(),a)this.fireOnCreate();else{const g=l[o];(g||!this.props.noEmpty)&&this.selectOption(g)}else this.props.onEnter?this.props.onEnter():this.openPopover();break;case"Tab":s&&this.selectOption(l[o]);break;case"Escape":s&&(r.preventDefault(),r.stopPropagation(),this.setState({popoverOpen:!1}));break}},this.selectOption=r=>{r===this.props.value?this.setState({popoverOpen:!1,inputValue:this.renderOptionText(r),q:""}):(this.setState({popoverOpen:!1,inputValue:"",q:""}),this.triggerOnChange(r))},this.highlightOption=r=>{this.setState({highlightedIndex:r,createHighlighted:!1})},this.highlightCreate=()=>{this.setState({highlightedIndex:-1,createHighlighted:!0})},this.fireOnCreate=()=>{const{onCreate:r}=this.props;if(r){this.isCreateOpen=!0;const s={q:Ee.upperFirst(this.state.q),callback:o=>{this.isCreateOpen=!1,o!=null&&this.selectOption(o),this.input&&this.input.focus()}};r(s),this.closePopover()}},this.openPopover=()=>{if(!this.state.popoverOpen){const r=this.getFilteredOptions();let s=0,o=!1;if(r.length===0)s=-1,o=!0;else{const{value:a}=this.props,l=r.findIndex(c=>c===a);l!==-1&&(s=l)}this.setState({popoverOpen:!0,highlightedIndex:s,createHighlighted:o})}},this.memoizedFilterOptions=Bt((r,s)=>(r=r||[],s?r.filter(o=>this.filter(o,s)):r)),this.state={inputValue:this.renderOptionText(n.value==null?null:n.value),q:"",popoverOpen:!1,popoverPlacement:null,highlightedIndex:-1,createHighlighted:!1}}componentDidUpdate(n,r){const{value:s}=this.props;if(s!==n.value){const o=this.renderOptionText(s??null);o!==this.state.inputValue&&this.setState({inputValue:o})}r.highlightedIndex!==this.state.highlightedIndex&&this.scrollHighlightedOptionIntoView()}render(){let n;const{props:r}=this,s=this.state,o=s.popoverPlacement==="top"?"above":"below";if(s.popoverOpen&&this.rootRef.current){const l=this.getFilteredOptions();let c;if(l.length>0){let g=null;c=l.reduce((_,h,v)=>{const y=this.getOptionGroup(h);y&&y!==g&&_.push(e.createElement("div",{key:"group:"+y,className:"combo-box__group-header"},y)),g=y;const p=["combo-box__option"];return v===s.highlightedIndex&&p.push("combo-box__option--highlighted"),_.push(e.createElement(An,{key:this.getOptionKey(h,v),className:p.join(" "),option:h,idx:v,renderOptionText:r.renderOptionText,renderOptionItem:r.renderOptionItem,getOptionIcon:r.getOptionIcon,onClick:this.selectOption,onHover:this.highlightOption})),r.hasSeparatorAfter&&r.hasSeparatorAfter(h)&&_.push(e.createElement("div",{key:"sep-"+v,className:"combo-box__option-sep"})),_},[])}else r.loading?c=e.createElement("div",{className:"combo-box__no-results"},"Loading..."):c=e.createElement("div",{className:"combo-box__no-results"},"No matching ",r.nounPlural||"items");n=e.createElement(tt,{ref:this.popoverRef,className:"combo-box-popover"+(r.popoverNotch?"":` combo-box-popover--${o}`),noNotch:!r.popoverNotch,target:this.rootRef.current,forceDimension:!0,matchWidth:!0,minWidth:r.popoverMinWidth,onMouseDown:this.onMouseDown,onPlacementChange:this.onPopoverPlacementChange,document:r.document},e.createElement("div",{ref:this.optionsElRef,className:E({"combo-box__options":!0,"combo-box__options--with-create":!!r.onCreate})},c),r.onCreate&&e.createElement("div",{key:"create",className:E({"combo-box__option":!0,"combo-box__option--create":!0,"combo-box__option--highlighted":s.createHighlighted}),onClick:this.fireOnCreate,onMouseMove:this.highlightCreate},e.createElement("div",{className:"combo-box__create-icon"},e.createElement(ve,{icon:Pt})),e.createElement("div",{className:"combo-box__create-text"},"Create"," ",s.q===""?"new"+(r.noun?` ${r.noun}`:""):e.createElement("b",null,Ee.upperFirst(s.inputValue)))))}const a=["input-group","combo-box"];return s.popoverOpen&&(a.push("combo-box--open"),r.popoverNotch||a.push(`combo-box--with-popover-${o}`)),r.disabled&&a.push("input-group--disabled"),r.noSearch&&a.push("combo-box--no-search"),r.className&&a.push(r.className),e.createElement(e.Fragment,null,e.createElement("div",{className:a.join(" "),style:{width:r.width?r.width+"px":void 0},ref:this.rootRef,onClick:r.readOnly||r.disabled?void 0:()=>{this.input?.focus(),this.openPopover()}},r.childrenBefore,r.value&&r.getOptionIcon&&e.createElement("div",{className:"combobox__input-icon"},it(r.value,r.getOptionIcon)),e.createElement("input",{type:"text",className:r.inputClassName,name:r.name,value:s.inputValue,onChange:this.onInputChange,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onMouseDown:this.openPopover,placeholder:r.placeholder,readOnly:r.readOnly||r.noSearch,disabled:r.disabled,autoComplete:"off",ref:this.setInput,...r.inputHtmlAttributes}),!r.noTrigger&&e.createElement("div",{"data-testid":r.triggerTestId||"combo-box-trigger",className:"input-group__append input-group__trigger",onClick:this.onTriggerClick,onMouseDown:this.onMouseDown},e.createElement(ve,{icon:It})),r.childrenAfter),n)}scrollHighlightedOptionIntoView(){const n=this.optionsElRef.current;if(this.state.popoverOpen&&n){const r=n.querySelector(".combo-box__option--highlighted");if(r){const s=n.getBoundingClientRect(),o=r.getBoundingClientRect();o.top<s.top?n.scrollTop+=o.top-s.top:o.bottom>s.bottom&&(n.scrollTop+=o.bottom-s.bottom)}}}triggerOnChange(n){const{onChange:r}=this.props;r&&r(n)}closePopover(){this.setState({popoverOpen:!1,inputValue:this.renderOptionText(this.props.value==null?null:this.props.value),q:""})}renderOptionText(n){return n==null?"":lt(n,this.props.renderOptionText)}getFilteredOptions(){return this.memoizedFilterOptions(this.props.options,this.state.q)}filter(n,r){return this.props.filter?this.props.filter(n,r):this.renderOptionText(n).toLowerCase().includes(r.toLowerCase())}getOptionKey(n,r){return n&&n.id||r}getOptionGroup(n){return this.props.getOptionGroup?this.props.getOptionGroup(n):n&&n.group||null}}class An extends e.PureComponent{constructor(){super(...arguments),this.state={isOptionDisabled:!1},this.onClick=()=>{this.state.isOptionDisabled||this.props.onClick(this.props.option)},this.onHover=()=>{this.state.isOptionDisabled||this.props.onHover(this.props.idx)}}componentDidMount(){const n=this.props.option!==void 0&&typeof this.props.option=="object"&&this.props.option!==null&&"disabled"in this.props.option&&this.props.option.disabled===!0;this.setState({isOptionDisabled:n})}componentDidUpdate(){const n=this.props.option!==void 0&&typeof this.props.option=="object"&&this.props.option!==null&&"disabled"in this.props.option&&this.props.option.disabled===!0;this.setState({isOptionDisabled:n})}render(){const{isOptionDisabled:n}=this.state,{props:r}=this;return e.createElement("div",{className:E({[r.className]:!0,"combo-box__option--disabled":n}),onClick:this.onClick,onMouseMove:this.onHover},Un(r.option,r.renderOptionText,r.renderOptionItem,r.getOptionIcon))}}function lt(t,n){return n?n(t):typeof t=="string"||typeof t=="number"?t:t?t.name:"?"}function Un(t,n,r,s){if(r)return r(t);{let o=lt(t,n);return s?e.createElement("div",{className:"d-flex align-flex-start"},e.createElement("div",{className:"combobox__option-icon"},it(t,s)),e.createElement("div",{className:"flex-1"},o)):o}}function it(t,n){const r=n(t);return kn(r)?e.createElement(ve,{icon:r}):r}function kn(t){return Wt(t)&&"iconName"in t}const Vn=({selectedFlow:t,setSelectedFlow:n,flows:r,debugAutoStartCondition:s})=>{const o=q(),a=Ne();i.useEffect(()=>{if(!t)return;s(t.latestVersion);const c=()=>{s(t.latestVersion)};return o.on("private:checkSessionsAck",c),document.addEventListener("visibilitychange",c),()=>{o.off("private:checkSessionsAck",c),document.removeEventListener("visibilitychange",c)}},[t]);const l=i.useCallback(c=>{!c||t?.latestVersion?.id===c.latestVersion.id||n(c)},[t]);return e.createElement(e.Fragment,null,e.createElement("div",{className:"d-flex align-center justify-space-between"},e.createElement("div",{className:"d-flex justify-space-between align-center"},"Select Flow"),e.createElement(Mn,{className:"userflow-debugger__flow__selector",value:t,options:r,placeholder:"Select flow",document:a?.current?.contentDocument||void 0,onChange:l,renderOptionItem:c=>c.name})),e.createElement(Hn,{selectedFlow:t,selectedFlowVersionsId:t?.latestVersion?.id}))},Hn=({selectedFlowVersionsId:t,selectedFlow:n})=>{const r=q(),[s,o]=i.useState(!1),a=F(),l=a&&a?.activeFlow?.id===n?.id;return i.useEffect(()=>(o(!1),r.on("private:setFlowSession",c=>{o(c===t)}),()=>{r.off("private:setFlowSession",()=>o(!1))}),[t]),i.useEffect(()=>{l||o(!1)},[l]),a?.activeFlow===null?null:e.createElement(e.Fragment,null,a?.locale?.match===!1&&e.createElement("div",{className:E(Oe(!1))},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:U}),e.createElement("span",null,"The flow will not auto start ",e.createElement("br",null)," ",e.createElement("b",null,"User locale (",a?.locale?.code,") is not enabled.")))),s?e.createElement("div",{className:E({"d-flex align-center fade-in":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex align-center gap-8"},e.createElement(m,{icon:Z}),e.createElement("span",null,"This flow ",e.createElement("strong",null,"just")," started"))):null,l&&!s&&e.createElement("div",{className:E({"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex align-center gap-8"},e.createElement(m,{icon:Z}),e.createElement("span",null,"This flow is currently active"))),!l&&a&&e.createElement("div",{className:E({"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(m,{icon:Z,size:16}),e.createElement("span",null,"Another flow is currently active"))))},Bn=({close:t})=>{const n=q(),r=i.useRef(null),[s,o]=i.useState(!!n.clientToken),[a,l]=i.useState(()=>{const u=n.getSessionStorageState(),C=u?.debuggerApp?.x,x=u?.debuggerApp?.y||50;return{x:C??(document.body.clientWidth?Number(document.body.clientWidth)-450:50),y:x}}),[c,g]=i.useState(!1),_=i.useRef(null),{meta:h}=J(),{debuggerRoute:v}=Te(),[y,p]=i.useState(!1),b=i.useRef(null),f=i.useRef({mouseX:0,mouseY:0,elementX:0,elementY:0});i.useEffect(()=>{a&&n.setSessionStorageState(u=>({...u,debuggerApp:{...u.debuggerApp,x:a.x,y:a.y}}))},[a]),i.useEffect(()=>{if(!c)return;const u=x=>{const k=x.clientX-f.current.mouseX,D=x.clientY-f.current.mouseY,P=Math.min(f.current.elementX+k,window.document.body.clientWidth-200),V=Math.max(f.current.elementY+D,0);b.current||(b.current=requestAnimationFrame(()=>{l({x:P,y:V}),b.current=null}))},C=()=>{g(!1)};return document.addEventListener("mousemove",u),document.addEventListener("mouseup",C),()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",C),b.current&&(cancelAnimationFrame(b.current),b.current=null)}},[c,a]),i.useEffect(()=>{const u=()=>{l(x=>{const k=document.body.clientWidth-500,D=document.body.clientHeight-100,P=Math.max(Math.min(x.x,k),0),V=Math.max(Math.min(x.y,D),0);return{x:P,y:V}})},C=()=>{o(!!n.clientToken)};return window.addEventListener("resize",u),n.on("private:initialised",C),()=>{window.removeEventListener("resize",u),n.off("private:initialised",C)}},[]);const w=u=>{r.current&&(g(!0),u.preventDefault())};return e.createElement("div",{ref:r,style:{left:"0",top:"0",position:"absolute",willChange:"transform",transform:`translate3d(${a.x}px, ${a.y}px, 0)`,zIndex:1234620}},e.createElement("div",{onMouseDown:w,style:{height:"50px",cursor:"move",userSelect:"none",position:"absolute",width:"50px"}}),e.createElement(ft,{title:"Debugger",stylesheet:qt,style:{borderRadius:"8px",width:"400px",height:v==="checkAutoStart"?"600px":s?"500px":"400px"},elRef:_,onStylesheetsLoad:p},e.createElement(Ke.Provider,{value:_},e.createElement("div",{className:"d-flex flex-column userflow-debugger-app",style:{visibility:y?"visible":"hidden"}},e.createElement("div",{className:"d-flex justify-space-between userflow-debugger-app__header"},e.createElement(Yt,null),e.createElement("div",{className:"d-flex align-center userflow-debugger-app__title"},e.createElement(gt,null),e.createElement("span",null,"Userflow debugger")),e.createElement("button",{role:"button",className:"userflow-debugger-app__close",onClick:()=>{n.getSessionStorageState().debuggerApp&&n.setSessionStorageState(u=>({...u,debuggerApp:null})),t()}},e.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M12.1836 4.49609L8.90234 7.77734L12.1562 11.0312C12.4297 11.2773 12.4297 11.6875 12.1562 11.9336C11.9102 12.207 11.5 12.207 11.2539 11.9336L7.97266 8.67969L4.71875 11.9336C4.47266 12.207 4.0625 12.207 3.81641 11.9336C3.54297 11.6875 3.54297 11.2773 3.81641 11.0039L7.07031 7.75L3.81641 4.49609C3.54297 4.25 3.54297 3.83984 3.81641 3.56641C4.0625 3.32031 4.47266 3.32031 4.74609 3.56641L8 6.84766L11.2539 3.59375C11.5 3.32031 11.9102 3.32031 12.1836 3.59375C12.4297 3.83984 12.4297 4.25 12.1836 4.49609Z",fill:"white"})))),e.createElement(Wn,null),v==="verifySetup"&&e.createElement(qn,null),h?.endUser?.debuggerEnabled&&v==="checkAutoStart"&&e.createElement(Gn,null),v==="currentUser"&&e.createElement(zn,null)))))},Wn=()=>{const t=q(),{meta:n}=J(),[r,s]=i.useState(!1),{debuggerRoute:o,setDebuggerRoute:a}=Te(),l=t.isIdentified(),c=zt(()=>s(!1));return i.useEffect(()=>{n&&n?.endUser.debuggerEnabled===!1&&o==="checkAutoStart"&&a("verifySetup")},[n]),l?e.createElement("div",{ref:c},e.createElement("div",{className:"d-flex align-center justify-space-between userflow-debugger-menu",onClick:()=>s(!r)},e.createElement("div",{className:E({"d-flex align-center":!0,"userflow-debugger-menu__title":!0,"userflow-debugger-menu__title--open":r})},e.createElement(m,{icon:oe[o].icon}),e.createElement("span",null,oe[o].name)),e.createElement("button",{className:"userflow-debugger-menu__toggle"},e.createElement(m,{icon:Ft}))),r&&e.createElement("ul",{className:"userflow-debugger-menu__list"},Object.keys(oe).map(g=>{if(!n?.endUser?.debuggerEnabled&&g==="checkAutoStart")return null;const _=oe[g];return e.createElement("li",{key:g,className:"d-flex align-center userflow-debugger-app__item",onClick:()=>{a&&a(g),s(!1)}},e.createElement(m,{icon:_.icon}),_.name)}))):null},qn=()=>{const{meta:t,buildId:n}=J(),r=q(),[s,o]=i.useState(!!r.clientToken),a=i.useMemo(()=>r.isIdentified(),[r,t]),{setDebuggerRoute:l}=Te();i.useEffect(()=>{const h=()=>{o(!!r.clientToken)};return r.on("private:initialised",h),()=>{r.off("private:initialised",h)}},[]);const c=i.useMemo(()=>{let h=me;const v={"d-flex flex-column gap-8":!0,"userflow-debugger-installation__step":!0};return s?(h=X,v["userflow-debugger-installation__step__success"]=!0):(h=At,v["userflow-debugger-installation__step__danger"]=!0),{icon:h,classes:v}},[s]),g=i.useMemo(()=>{let h=me;const v={"d-flex flex-column gap-8":!0,"userflow-debugger-installation__step":!0};return!s&&!a&&(h=me,v["userflow-debugger-installation__step__failed"]=!0),s&&!a&&(h=Z,v["userflow-debugger-installation__step__warning"]=!0),s&&a&&(h=X,v["userflow-debugger-installation__step__success"]=!0),{icon:h,classes:v}},[s,a]),_=()=>a?t?.endUser.debuggerEnabled?e.createElement(e.Fragment,null,e.createElement("span",{className:"userflow-debugger-details"},t?.env.company.name),e.createElement("span",{className:"userflow-debugger-details"},t?.env.name)):e.createElement("div",{className:"userflow-debugger-details__access__denied"},"The"," ",e.createElement("button",{onClick:()=>l("currentUser")},"currently signed-in user")," ","does not have debugger access"):e.createElement(e.Fragment,null,e.createElement("span",{className:"userflow-debugger-details"},"Unknown company"),e.createElement("span",{className:"userflow-debugger-details"},"Unknown environment"));return e.createElement("div",{className:"space-evenly userflow-debugger-app__content"},e.createElement("div",{className:"userflow-debugger-installation__steps"},e.createElement("div",{className:E({"d-flex gap-8 flex-column":!0,"userflow-debugger-installation__step":!0,"userflow-debugger-installation__step__success":!0})},e.createElement(m,{icon:X,size:32}),"Userflow ",e.createElement("br",null),"installed"),e.createElement("div",{className:E(c.classes)},e.createElement(m,{icon:c.icon,size:32}),"Userflow ",e.createElement("br",null)," ",s?"":"not"," initialized"),e.createElement("div",{className:E(g.classes)},e.createElement(m,{icon:g.icon,size:32}),"User ",e.createElement("br",null)," ",a&&s?"":"not"," ","identified")),!s&&!a&&e.createElement("div",{className:E({"d-flex gap-8 flex-column":!0,"userflow-debugger-installation__not__initialized":!0})},"Remember to initialize Userflow by calling",e.createElement("div",null,"userflow.init('YOUR_USERFLOW_TOKEN')")),s&&e.createElement("div",{className:"d-flex gap-8 flex-column userflow-debugger-details__wrapper"},e.createElement("div",{className:"userflow-debugger-details__env__details"},e.createElement("div",{className:"d-flex gap-8 flex-column justify-space-around"},e.createElement(m,{size:20,icon:Rt}),e.createElement(m,{size:20,icon:Lt})),e.createElement("div",{className:"d-flex flex-column align-flex-start gap-8"},_())),e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement(m,{size:20,icon:Mt}),e.createElement("span",{className:"userflow-debugger-details"},r.getInitToken())),e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement(m,{size:20,icon:Ce}),e.createElement("span",{className:"userflow-debugger-details"},a?r.getIdentifiedUser()?.externalId:"User not identified"))),e.createElement("div",{className:"userflow-debugger-installation__version"},e.createElement("a",{href:"https://docs.userflow.com/docs/dev/userflow-js-installation",target:"_blank",rel:"noreferrer"},"Visit the Userflow Developer Docs for help")," ",e.createElement("br",null),"Userflow.js version 0.1.",n))},Gn=()=>{const t=q(),{debuggerClientConditions:n}=J(),[r,s]=i.useState(void 0),[o,a]=i.useState([]),[l,c]=i.useState(),g=i.useMemo(()=>{if(l?.startCondition?.match===!1||l?.hiddenCondition?.match===!1||l?.locale?.match===!1)return!1;const p=l?.startFrequency;return!(p&&(p.onlyIfNotCompleted===!1||p.scopeByGroup===!1||p.frequency===!1))},[l]);i.useEffect(()=>(y().then(p=>{if(p?.length&&(a(p),!r)){const b=t.getSessionStorageState()?.debuggerApp?.selectedFlowVersionId,f=p.find(w=>w.latestVersion.id===b);h(f??p[0])}}),document.addEventListener("visibilitychange",y),()=>{document.removeEventListener("visibilitychange",y)}),[]),i.useEffect(()=>{r&&v(r.latestVersion)},[r]);const _=Xe.debounce(async p=>{const b=[];for(const[u,C]of n.entries())b.push({conditionId:u,isTrue:C.isTrue});const f={kind:"DebugFlowAutostartCondition",flowVersionId:p.id,clientConditions:b},w=await t.send(f);c({...w,listFlowLatestVersion:p}),w.latestVersion?.id&&p.id!==w.latestVersion?.id&&(y().then(u=>{if(!u)return;a(u);const C=u?.find(x=>x.latestVersion.id===w.latestVersion?.id);C&&h(C)}),_(w.latestVersion))},300),h=p=>{s(p);const b=t.getSessionStorageState().debuggerApp;b&&b?.x&&t.setSessionStorageState(f=>({...f,debuggerApp:{...b,selectedFlowVersionId:p.latestVersion.id}}))},v=async p=>{n.forEach(f=>{f.untrack?.()}),n.clear();const{conditionTypes:b}=await mt(async()=>{const{conditionTypes:f}=await import("./flow-condition-types.js").then(w=>w.f);return{conditionTypes:f}},__vite__mapDeps([0,1,2,3,4,5,6,7]));for(const f of p.clientConditions){n.set(f.id,{condition:f,isTrue:null});const w=b[f.type];if(!w){console.error(`Unknown condition type ${f.type}`);continue}const u=n.get(f.id);u&&(u.untrack=w.track({sessionData:new pt([]),condition:f,callback:C=>{u.isTrue!==C&&(u.isTrue=C,_(p))}}))}},y=async()=>{try{return(await t.send({kind:"ListFlows",hasAutostartCondition:!0},{handlesRejection:!0})).flows?.filter(f=>f.type==="FLOW")}catch(p){p.code==="debugger_access_denied"&&_e("Access defined for List Flows");return}};return e.createElement("div",{className:"userflow-debugger-app__content"},e.createElement($e.Provider,{value:l},e.createElement(Vn,{flows:o,selectedFlow:r,setSelectedFlow:h,debugAutoStartCondition:_}),e.createElement("div",{className:"d-flex flex-column gap-8 userflow-debugger-app__wrapper"},l?.startCondition?.condition&&e.createElement("div",null,e.createElement("div",{className:E({"d-flex gap-8 align-center":!0,"userflow-debugger-app__wrapper__passing":g,"userflow-debugger-app__wrapper__failed":!g})},e.createElement(m,{icon:g?Ut:kt}),e.createElement("strong",null,"Auto-start conditions")),e.createElement("span",null,"These are"," ",e.createElement(st,{condition:l.startCondition.condition}),e.createElement("b",null,"-conditions"),", meaning"," ",l.startCondition.condition.type==="CLAUSE"&&l.startCondition.condition.operator==="AND"&&e.createElement(e.Fragment,null,"all conditions must pass for the flow to start."),l.startCondition?.condition.type==="CLAUSE"&&l.startCondition.condition.operator==="OR"&&e.createElement(e.Fragment,null,"only one condition must pass for the flow to start."))),l?.startCondition?.condition&&e.createElement(ie,{isRoot:!0,isHideCond:!1,condition:l.startCondition.condition}),e.createElement(On,null),e.createElement(Dn,null),e.createElement(In,null),e.createElement(Rn,null),e.createElement(Pn,null),e.createElement(Nn,null),e.createElement(Fn,null),e.createElement(Ln,null))))},zn=e.memo(()=>{const{meta:t,buildId:n}=J();if(!t)return null;const r="https://app.userflow.com/app/"+t.env.company.slug+"/settings/debugger?external_id="+t.endUser.externalId;return e.createElement("div",{className:"d-flex flex-column space-evenly flex-1"},e.createElement("div",{className:"d-flex flex-column gap-8"},e.createElement("div",{className:"d-flex flex-column"},t.endUser.avatarUrl?e.createElement("img",{src:t.endUser.avatarUrl,className:"userflow-debugger-user__image"}):e.createElement("div",{className:"userflow-debugger-user__image"}),e.createElement("span",{className:"userflow-debugger-user__name"},t.endUser?.name||"Unknown name"),e.createElement("span",{className:"userflow-debugger-user__email"},t?.endUser?.email||"Unknown email address"),(!t.endUser.email||!t.endUser.name)&&e.createElement("span",{className:"userflow-debugger__external__id"},t.endUser.externalId)),!t.endUser.debuggerEnabled&&e.createElement(e.Fragment,null,e.createElement("div",{className:"userflow-debugger-user__info"},"This user doesn't have access to the Userflow debugger. You can grant access through the debugger settings in Userflow."),e.createElement("a",{className:"userflow-debugger-user__button",href:r,target:"_blank",rel:"noreferrer"},"Grant access in Userflow ",e.createElement(m,{icon:je})))),e.createElement("div",{className:"userflow-debugger-installation__version"},e.createElement("a",{href:"https://docs.userflow.com/docs/dev/userflow-js-installation",target:"_blank",rel:"noreferrer"},"Visit the Userflow Developer Docs for help")," ",e.createElement("br",null),"Userflow.js version 0.1.",n))});class br{constructor(n,r){this.client=n,this.buildId=r,this.debuggerClientConditions=new Map}mount(){if(this.container)throw new Error("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-debugger-ui",document.body.appendChild(this.container),he.render(e.createElement(Yn,{client:this.client,debuggerClientConditions:this.debuggerClientConditions,buildId:this.buildId,unmount:()=>this.unmount()}),this.container)}unmount(){this.container&&(he.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),this.client.unMountDebugger(),delete this.container)}}const Yn=({client:t,debuggerClientConditions:n,buildId:r,unmount:s})=>{const[o,a]=i.useState(void 0),l=Xe.debounce(async()=>{try{const c=await t.send({kind:"GetCurrentEndUser"},{handlesRejection:!0});a(c)}catch(c){c.code==="debugger_access_denied"&&_e("debugger access denied"),a(void 0)}},300);return i.useEffect(()=>(l(),document.addEventListener("visibilitychange",l),t.on("private:identified",l),()=>{document.removeEventListener("visibilitychange",l),t.off("private:identified",l)}),[]),e.createElement(ct.Provider,{value:t},e.createElement(Ze.Provider,{value:{meta:o,debuggerClientConditions:n,buildId:r}},e.createElement(Gt,null,e.createElement(Bn,{close:s}))))};export{br as DebuggerUI};
3
3
  //# sourceMappingURL=DebuggerUI.js.map
package/debugger.css CHANGED
@@ -114,6 +114,9 @@ body {
114
114
  top: 0;
115
115
  right: 0;
116
116
  }
117
+ .overflow-hidden {
118
+ overflow: hidden;
119
+ }
117
120
  .width-xs {
118
121
  width: 1rem;
119
122
  }
package/hash.txt CHANGED
@@ -1 +1 @@
1
- 71351a2ebf2ea7705de636839b2e2d58a2210b21
1
+ 85b0260d12adeb9787dafd6047131ec18a039580
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1012092",
3
+ "version": "0.1.1012167",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
@@ -1,11 +1,11 @@
1
- import{R as n,r as p}from"./vendor.react.js";import{c as Ue,g as Be,a as _e,b as xe,o as We}from"./flow-condition-types.js";import{c as ze,D as Z}from"./stylesheets.js";import"./vendor.core-js.js";import{o as O}from"./vendor.obj-str.js";import{l as me,a0 as He,a1 as Ve,r as $,a2 as Ne,t as ve,E as oe,a3 as I,U as Ge,H as N,d as Je}from"./userflow.js";import{c as Y}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{u as Ke}from"./vendor.react-i18next.js";import{u as Se}from"./client-context.js";import{l as Qe,u as Xe,t as Ze,r as Ce,p as Ye,j as Ee,e as et,d as tt}from"./roots.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="62c28ab8-64a2-4105-965b-c9cdf0c2f0dc",e._sentryDebugIdIdentifier="sentry-dbid-62c28ab8-64a2-4105-965b-c9cdf0c2f0dc")}catch{}})();const nt=n.createContext(null);function fe(){const e=p.useContext(nt);if(!e)throw new Error("useSession: Session was not set");return e}function rt(){const e=fe();if(e.kind!=="flow")throw new Error("useFlowSession: Wrong session kind");return e}function st(e){const t=p.useRef(e),r=p.useRef(e);return e!==r.current&&JSON.stringify(e)!==JSON.stringify(r.current)&&(t.current=e),r.current=e,t.current}function ye(e){const t=fe(),[r,i]=p.useState(!1),s=ze(t.data),l=st(e);return p.useLayoutEffect(()=>{if(l)return Ue[l.type].track({sessionData:s,condition:l,callback:b=>{i(b)}})},[s,l]),l==null?!1:r}const at=({appearance:e,hidden:t,disabled:r,onMouseDown:i,onClick:s,text:l,active:a,children:c})=>n.createElement("button",{className:O({[jt(e)]:!0,"userflowjs-bubble-button--hidden":!!t,"userflowjs-bubble-button--active":!!a}),onMouseDown:i,onClick:s,disabled:r},c||n.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},l));function lt(e){const t=Ve(),r=new URL(e,t).toString();t!==r&&(me.customNavigate?me.customNavigate(e):window.setTimeout(()=>{He(e)},0))}async function ue(e,t,r){const{steps:i}=t.version;switch(r.type){case $.CLOSE_FLOW:switch(t.kind){case"launcher":await e.dismissLauncher(t,{endReason:oe.ACTION});break;case"banner":case"flow":case"checklist":await e.endFlow(t,{endReason:oe.ACTION});break}return;case $.EVAL_JS:if(me.evalJsDisabled){console.error('Userflow.js: Blocked "Evaluate JavaScript" action from running, since userflow.disableEvalJs() has been called.');return}try{const s=_e(r.code||"",t.data);new Function(`"use strict";
1
+ import{R as n,r as p}from"./vendor.react.js";import{c as Ue,g as Be,a as _e,b as xe,o as We}from"./flow-condition-types.js";import{c as Ve,D as Z}from"./stylesheets.js";import"./vendor.core-js.js";import{o as O}from"./vendor.obj-str.js";import{l as me,a0 as ze,a1 as He,r as R,a2 as Ne,t as ve,E as oe,a3 as I,U as Ke,H as N,d as Ge}from"./userflow.js";import{c as Y}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{u as Je}from"./vendor.react-i18next.js";import{u as Se}from"./client-context.js";import{l as Qe,u as Xe,t as Ze,r as Ce,p as Ye,j as Ee,e as et,d as tt}from"./roots.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="60612127-b304-4d54-8dae-cda8cb79afce",e._sentryDebugIdIdentifier="sentry-dbid-60612127-b304-4d54-8dae-cda8cb79afce")}catch{}})();const nt=n.createContext(null);function fe(){const e=p.useContext(nt);if(!e)throw new Error("useSession: Session was not set");return e}function rt(){const e=fe();if(e.kind!=="flow")throw new Error("useFlowSession: Wrong session kind");return e}function st(e){const t=p.useRef(e),r=p.useRef(e);return e!==r.current&&JSON.stringify(e)!==JSON.stringify(r.current)&&(t.current=e),r.current=e,t.current}function ye(e){const t=fe(),[r,i]=p.useState(!1),s=Ve(t.data),l=st(e);return p.useLayoutEffect(()=>{if(l)return Ue[l.type].track({sessionData:s,condition:l,callback:b=>{i(b)}})},[s,l]),l==null?!1:r}const at=({appearance:e,hidden:t,disabled:r,onMouseDown:i,onClick:s,text:l,active:a,children:u})=>n.createElement("button",{className:O({[jt(e)]:!0,"userflowjs-bubble-button--hidden":!!t,"userflowjs-bubble-button--active":!!a}),onMouseDown:i,onClick:s,disabled:r},u||n.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},l));function lt(e){const t=He(),r=new URL(e,t).toString();t!==r&&(me.customNavigate?me.customNavigate(e):window.setTimeout(()=>{ze(e)},0))}async function ue(e,t,r){const{steps:i}=t.version;switch(r.type){case R.CLOSE_FLOW:switch(t.kind){case"launcher":await e.dismissLauncher(t,{endReason:oe.ACTION});break;case"banner":case"flow":case"checklist":await e.endFlow(t,{endReason:oe.ACTION});break}return;case R.EVAL_JS:if(me.evalJsDisabled){console.error('Userflow.js: Blocked "Evaluate JavaScript" action from running, since userflow.disableEvalJs() has been called.');return}try{const s=_e(r.code||"",t.data);new Function(`"use strict";
2
2
  `+s)()}catch(s){console.error(`Userflow.js: Evaluate JavaScript action failed.
3
3
 
4
4
  Error:
5
5
  ${s.stack||s.message||s}
6
6
 
7
7
  Code:
8
- ${r.code}`)}return;case $.GO_TO_STEP:{if(t.kind!=="flow")return;const s=i.find(({crossVersionId:l})=>l===r.stepCvid);if(!s)throw new Ge("Action points to unknown step: "+r.stepCvid);await e.goToStep(t,s);return}case $.NAVIGATE:{if(!r.url){console.warn("Userflow.js: NAVIGATE action is missing url property");return}const s=H(r.url,{lookupAttribute:Be(t.data)});r.navigateTarget===Ne.NEW_TAB?window.open(s):lt(s);return}case $.SET_ATTRIBUTE:{let s;const l=r.attributeValue||"";switch(r.attributeOperation){case I.SET:s={set:l};break;case I.SET_DATETIME:s={set:new Date().toISOString()};break;case I.SET_DATETIME_ONCE:s={set_once:new Date().toISOString()};break;case I.SET_ONCE:s={set_once:l};break;case I.ADD:s={add:l};break;case I.SUBTRACT:s={subtract:l};break;case I.APPEND:s={append:l};break;case I.PREPEND:s={prepend:l};break;case I.REMOVE:s={remove:l};break;case I.UNSET:s={set:null};break;default:return}const a=r.attributeFqn||"",c=a.split("/");c.length===1?e.updateUser({[a]:s}):c[0]==="group"?e.updateGroup({[c[1]]:s}):c[0]==="group_membership"&&e.updateGroup({},{membership:{[c[1]]:s}});return}case $.SNOOZE:t.kind==="flow"&&r.timeValue&&r.timeUnit&&(e.endFlow(t,{endReason:oe.SNOOZED,batch:!0}),t.draftMode?window.alert(`In preview mode, flows can't be snoozed.
8
+ ${r.code}`)}return;case R.GO_TO_STEP:{if(t.kind!=="flow")return;const s=i.find(({crossVersionId:l})=>l===r.stepCvid);if(!s)throw new Ke("Action points to unknown step: "+r.stepCvid);await e.goToStep(t,s);return}case R.NAVIGATE:{if(!r.url){console.warn("Userflow.js: NAVIGATE action is missing url property");return}const s=z(r.url,{lookupAttribute:Be(t.data)});r.navigateTarget===Ne.NEW_TAB?window.open(s):lt(s);return}case R.SET_ATTRIBUTE:{let s;const l=r.attributeValue||"";switch(r.attributeOperation){case I.SET:s={set:l};break;case I.SET_DATETIME:s={set:new Date().toISOString()};break;case I.SET_DATETIME_ONCE:s={set_once:new Date().toISOString()};break;case I.SET_ONCE:s={set_once:l};break;case I.ADD:s={add:l};break;case I.SUBTRACT:s={subtract:l};break;case I.APPEND:s={append:l};break;case I.PREPEND:s={prepend:l};break;case I.REMOVE:s={remove:l};break;case I.UNSET:s={set:null};break;default:return}const a=r.attributeFqn||"",u=a.split("/");u.length===1?e.updateUser({[a]:s}):u[0]==="group"?e.updateGroup({[u[1]]:s}):u[0]==="group_membership"&&e.updateGroup({},{membership:{[u[1]]:s}});return}case R.SNOOZE:t.kind==="flow"&&r.timeValue&&r.timeUnit&&(e.endFlow(t,{endReason:oe.SNOOZED,batch:!0}),t.draftMode?window.alert(`In preview mode, flows can't be snoozed.
9
9
 
10
- But if this flow was running in published mode, the flow would now be snoozed for ${r.timeValue} ${r.timeUnit.toLowerCase()+(r.timeValue===1?"":"s")}.`):e.send({kind:"Snooze",flowId:t.flow.id,timeValue:r.timeValue,timeUnit:r.timeUnit},{batch:!0}));return;case $.START_FLOW:t.kind==="launcher"&&e.deactivateLauncher(t),r.otherFlow?await e.startFlow({flowId:r.otherFlow.id,stepCvid:r.otherFlowStepCvid,startReason:t.draftMode?ve.DRAFT:ve.ACTION,replaceCurrent:!0}):console.warn("Userflow.js: START_FLOW action is missing other flow");return}}async function je(e,t,r){const i=[],s=[],l=[];for(const a of r)a.type===$.NAVIGATE?a.navigateTarget===Ne.NEW_TAB?i.push(a):l.push(a):s.push(a);for(const a of i)ue(e,t,a);await Promise.all(s.map(a=>ue(e,t,a)));for(const a of l)ue(e,t,a)}const it=({button:e})=>{const t=Se(),r=fe(),i=ye(e.disabledCondition),s=ye(e.hiddenCondition);return n.createElement(at,{appearance:e.appearance,hidden:s,disabled:i,onClick:()=>je(t,r,e.actions),text:_e(e.text,r.data)})},ot=()=>n.createElement("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},n.createElement("polygon",{className:"userflowjs-star-shape",fill:"#fff",points:"16 22.7785728 7.18322122 29.1352549 10.5042507 18.7856772 1.73415226 12.3647451 12.6034401 12.3250364 16 2 19.3965599 12.3250364 30.2658477 12.3647451 21.4957493 18.7856772 24.8167788 29.1352549"})),ut=({type:e,required:t,placeholder:r,buttonText:i,options:s,otherOption:l,multipleSelection:a,shuffleOptions:c,labelLeft:b,labelCenter:f,labelRight:v,minValue:u,maxValue:g,onSubmit:y,inert:d})=>{const{t:m}=Ke(),E=p.useRef(null),[h,j]=p.useState(""),[R,V]=p.useState(new Set),[S,M]=p.useState(),[G,Q]=p.useState(),[_,J]=p.useState(!1),[k,ne]=p.useState(!1),[D,A]=p.useState(null),P=p.useMemo(()=>s&&(c?[...s].sort(()=>Math.random()-.5):s),[s,c]),q=o=>{if(!(d||!y)){if(t&&h===""&&[N.MULTILINE_TEXT,N.TEXT].includes(e)){A(m("question.requiredError")),re();return}ne(!0),A(null),y({...o,onCancel:()=>{ne(!1)},onError:T=>{ne(!1),A(T||"Sorry, something went wrong saving your answer. Please try again.")}})}},re=p.useCallback(()=>{d||!E.current||E.current.focus()},[d]),[he,we]=p.useState(!1);p.useEffect(()=>{he&&(re(),we(!1))},[re,he]);const pe=n.createElement("div",{className:"userflowjs-bubble-buttons"},n.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>q({answer:{kind:"text",value:h}}),tabIndex:d?-1:void 0,disabled:k},n.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},i||m("question.submit"))));let C=null,X=0;if(e===N.NPS)b=b||m("question.npsLabelLeft"),v=v||m("question.npsLabelRight"),C=[0,1,2,3,4,5,6,7,8,9,10],X=C.length;else if([N.SCALE,N.STARS].includes(e)){u=u??1,g=g??5,C=[];for(let o=u;o<=g;o++)C.push(o);X=C.length}else e===N.MULTIPLE_CHOICE&&(X=(P?P.length:0)+(l&&!_?1:0));const[ge,Pe]=p.useState(-1),L=ge===-1?-1:Math.min(ge,X-1),se=o=>{if(!o.target.closest('[role="radio"], [role="checkbox"], [role="radiogroup"], [role="group"]'))return;let x=null;if(o.key==="ArrowRight"||o.key==="ArrowDown"?x=1:(o.key==="ArrowLeft"||o.key==="ArrowUp")&&(x=-1),x!=null){o.preventDefault();const W=o.currentTarget.querySelectorAll('[role="radio"], [role="checkbox"]');let w=L+x;w<0?w=W.length-1:w>W.length-1&&(w=0),Pe(w),W[w].focus()}};let ae=null,le=null;if(C&&(b||f||v)){const o=[];b&&o.push(C[0],b),v&&o.push(C[C.length-1],v),ae=n.createElement("div",{id:"a11y-scale-labels",className:"userflowjs-a11y-only"},o.join(", ")),le=n.createElement("div",{id:"userflowjs-bubble-question-labels",className:"userflowjs-bubble-question__scale-labels","aria-hidden":"true"},n.createElement("div",{className:"userflowjs-bubble-question__scale-label"},b),f&&n.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--center"},f),n.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--right"},v))}let U;switch(e){case N.MULTILINE_TEXT:U=n.createElement(n.Fragment,null,n.createElement("textarea",{ref:E,className:"userflowjs-textarea userflowjs-bubble-question__textarea",value:h,onChange:o=>j(o.target.value),onKeyDown:o=>{(o.ctrlKey||o.metaKey)&&o.key==="Enter"&&q({answer:{kind:"text",value:h}})},placeholder:r||m("question.placeholder"),readOnly:d||k,tabIndex:d?-1:void 0,rows:3,"aria-required":t?"true":void 0,"aria-invalid":D!=null?"true":void 0}),pe);break;case N.MULTIPLE_CHOICE:{const o=()=>{h&&q({answer:{kind:"text",value:h},animationPromise:ee()})},T=(P?.length||0)+(l?1:0),x=Math.max(0,Math.min(T,u??1)),B=Math.max(0,Math.min(T,g??T)),W=()=>{const w=(P||[]).filter((K,F)=>R.has(F)).map(K=>K.value);if(l&&_&&h!==""&&w.push(h),x===B&&w.length!==x){A(m("question.multiple_selection_wrong",{count:x}));return}else if(w.length<x){A(m("question.multiple_selection_too_few",{count:x}));return}else if(w.length>B){A(m("question.multiple_selection_too_many",{count:B}));return}q({answer:{kind:"list",values:w}})};U=n.createElement(n.Fragment,null,a&&n.createElement("div",{className:O({"userflowjs-bubble-question__multiple-choice-hint":!0,"userflowjs-bubble-question__multiple-choice-hint--error":!!D})},m("question.multiple_selection_hint",{replace:{selected:R.size+(l&&_&&h!==""?1:0),range:x===B?x:`${x}-${B}`}}),D&&n.createElement(n.Fragment,null,". ",n.createElement("span",{role:"alert"},D))),n.createElement("div",{className:O({"userflowjs-bubble-question__multiple-choice":!0,"userflowjs-bubble-question__multiple-choice--single-selection":!a,"userflowjs-bubble-question__multiple-choice--multiple-selection":!!a}),role:a?"group":"radiogroup",tabIndex:!d&&L===-1?0:-1,onKeyDown:se},P?.map(({value:w,label:K},F)=>n.createElement("button",{key:F,className:O({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--selected":a?R.has(F):k&&!_&&h==w}),onClick:k?void 0:()=>{if(a){A(null);const ie=new Set(R);R.has(F)?ie.delete(F):ie.add(F),V(ie)}else J(!1),j(w),q({answer:{kind:"text",value:w},animationPromise:ee()})},disabled:k,tabIndex:!d&&F===L?0:-1,role:a?"checkbox":"radio","aria-label":K||w,"aria-checked":!_&&h==w},a?n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},n.createElement(Z,{icon:Y}))):n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},K||w))),l&&(_?n.createElement("div",{className:O({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--other":!0,"userflowjs-bubble-question__multiple-choice-option--selected":a?h!="":k})},a?n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox",onClick:()=>{j(""),J(!1)}},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},n.createElement(Z,{icon:Y}))):n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),n.createElement("input",{ref:E,className:"userflowjs-bubble-question__multiple-choice-option-input",value:h,onChange:w=>j(w.target.value),onKeyDown:w=>{!w.shiftKey&&w.key==="Enter"?a?W():o():w.key==="Escape"&&(w.stopPropagation(),j(""),J(!1))},onBlur:()=>{h===""&&J(!1)},placeholder:r||m("question.placeholder"),readOnly:d||k,tabIndex:d?-1:void 0}),!a&&n.createElement("button",{"data-testid":"multiple-choice-other-submit",className:"userflowjs-bubble-question__multiple-choice-option-submit",onClick:()=>o(),disabled:k,"aria-label":m("question.submit")},n.createElement(Z,{icon:Y}))):n.createElement("button",{className:"userflowjs-bubble-question__multiple-choice-option",onClick:k?void 0:()=>{A(null),J(!0),we(!0)},disabled:k,tabIndex:!d&&P?.length===L?0:-1,role:"radio","aria-label":m("question.other"),"aria-checked":"false"},a?n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},n.createElement(Z,{icon:Y}))):n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},m("question.other"))))),a&&n.createElement("div",{className:"userflowjs-bubble-buttons"},n.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:W,tabIndex:d?-1:void 0,disabled:k},n.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},i||m("question.submit")))));break}case N.NPS:case N.SCALE:{U=n.createElement(n.Fragment,null,ae,n.createElement("div",{className:"userflowjs-bubble-question__scale-options",role:"radiogroup",tabIndex:!d&&L===-1?0:-1,onKeyDown:se},C?.map((o,T)=>n.createElement("button",{className:O({"userflowjs-bubble-question__scale-option":!0,"userflowjs-bubble-question__scale-option--selected":k&&S==o}),key:o,tabIndex:!d&&T===L?0:-1,onClick:()=>{M(o),q({answer:{kind:"number",value:o},animationPromise:ee()})},disabled:k,role:"radio","aria-checked":S==o},o))),le);break}case N.STARS:{U=n.createElement("div",{className:"userflowjs-bubble-question__stars-wrapper"},ae,n.createElement("div",{className:"userflowjs-bubble-question__stars",role:"radiogroup",tabIndex:!d&&L===-1?0:-1,onKeyDown:se},C?.map((o,T)=>n.createElement("button",{className:O({"userflowjs-bubble-question__star":!0,"userflowjs-bubble-question__star--hovered":!k&&G!=null&&G>=o,"userflowjs-bubble-question__star--selected":k&&S!=null&&S>=o,"userflowjs-bubble-question__star--not-selected":k&&S!=null&&S<o}),key:o,tabIndex:!d&&T===L?0:-1,onClick:()=>{M(o),q({answer:{kind:"number",value:o},animationPromise:ee()})},onMouseOver:()=>Q(o),onMouseLeave:()=>Q(null),disabled:k,role:"radio","aria-checked":S==o,"aria-label":String(o)},n.createElement("div",{className:"userflowjs-bubble-question__star-icon","aria-hidden":"true"},n.createElement(ot,null)),n.createElement("div",{className:"userflowjs-bubble-question__star-value","aria-hidden":"true"},o)))),le);break}case N.TEXT:U=n.createElement(n.Fragment,null,n.createElement("input",{ref:E,className:"userflowjs-text-input userflowjs-bubble-question__text-input",value:h,onChange:o=>j(o.target.value),onKeyDown:o=>{!o.shiftKey&&o.key==="Enter"&&q({answer:{kind:"text",value:h}})},placeholder:r||m("question.placeholder"),readOnly:d||k,tabIndex:d?-1:void 0,"aria-required":t?"true":void 0,"aria-invalid":D!=null?"true":void 0}),pe);break}return n.createElement("div",{className:"userflowjs-bubble-question",style:{pointerEvents:d?"none":void 0}},D&&!(e===N.MULTIPLE_CHOICE&&a)&&n.createElement("div",{className:"userflowjs-bubble-question__error",role:"alert"},D),U)};function ee(){return new Promise(e=>window.setTimeout(e,250))}const ct=({question:e})=>{const t=Se(),r=rt();return n.createElement(ut,{type:e.type,required:!!e.required,placeholder:e.placeholder||"",buttonText:e.buttonText||"",options:e.options,otherOption:e.otherOption,multipleSelection:e.multipleSelection,shuffleOptions:e.shuffleOptions,labelLeft:e.labelLeft||"",labelCenter:e.labelCenter||"",labelRight:e.labelRight||"",minValue:e.minValue,maxValue:e.maxValue,onSubmit:async i=>{Je("answerQuestion",r.id,e.cvid,i);const{answer:s}=i;try{await Promise.all([await t.send({kind:"AnswerQuestion",sessionId:r.id,questionName:e.name,questionCvid:e.cvid,textAnswer:s.kind=="text"?s.value:null,numberAnswer:s.kind=="number"?String(s.value):null,listAnswer:s.kind=="list"?s.values:null}),i.animationPromise])}catch(a){console.log("Userflow.js: Error when answering question:",a),i.onError();return}const{bindAttributeFqn:l}=e;if(l&&t.flowSession?.id===r.id){let a;switch(s.kind){case"text":a={name:l,value:s.value};break;case"number":a={name:l,value:String(s.value)};break;case"list":a={name:l,value:s.values};break}t.optimisticClockUIUpdate(()=>{t.setFlowSession({...r,data:[...r.data.filter(c=>c.name!==l),a]})})}je(t,r,e.actions)}})},mt=({text:e})=>{if(!e)return null;const t=e.split(/\n/);return t.length===1?n.createElement(n.Fragment,null,t[0]):n.createElement(n.Fragment,null,t.map((r,i)=>n.createElement(n.Fragment,{key:i},i>0&&n.createElement("br",null),r)))};function ft(e=""){return{type:"rich2",children:[dt(e)]}}function dt(e=""){return{type:"paragraph",children:[{text:e}]}}function Te(e){if(e){let t;try{t=JSON.parse(e)}catch{throw new Error("Could not JSON.parse rich content doc: "+e)}if(t.type==="rich2")return t;throw new Error("Could not recognize rich content doc: "+e)}else return ft()}function bt(e=""){return{type:"plaintext2",children:[{type:"plaintext",children:[{text:e}]}]}}function ht(e){if(e){let t;try{t=JSON.parse(e)}catch{throw new Error("Could not JSON.parse plaintext doc: "+e)}if(t.type==="plaintext2")return t;throw new Error("Could not recognize plaintext doc: "+e)}else return bt()}function H(e,{lookupAttribute:t}){if(!e)return"";typeof e=="string"&&(e=ht(e));const r=[];function i(l){if(de(l)){l.text&&r.push(l.text);return}switch(l.type){case"attribute":{const a=Le(l,t);a&&r.push(a);break}default:s(l.children);break}}function s(l){l&&l.forEach(a=>a&&i(a))}return s(e.children),r.join("")}function zt(e){let t=!0;if(!e)return!0;typeof e=="string"&&(e=Te(e));const r=new Set(["attribute","button","image","question","video"]);return $e(e,i=>{if(de(i)){i.text!==""&&(t=!1);return}"type"in i&&r.has(i.type)&&(t=!1)}),t}const Ht=n.memo(({doc:e,...t})=>e?(typeof e=="string"&&(e=Te(e)),n.createElement(Ie,{parent:e,...t})):null),Ie=({parent:e,...t})=>n.createElement(n.Fragment,null,e.children.map((r,i)=>de(r)?n.createElement(wt,{key:i,node:r}):n.createElement(pt,{key:i,node:r,parent:e,...t}))),wt=({node:e})=>e.text?n.createElement(Re,{node:e},n.createElement(mt,{text:e.text})):null,Re=({node:e,children:t})=>(e.color&&typeof e.color=="string"&&(t=n.createElement("span",{style:{color:e.color}},t)),e.bold&&(t=n.createElement("b",null,t)),e.italic&&(t=n.createElement("i",null,t)),e.underline&&(t=n.createElement("u",null,t)),e.strikeThrough&&(t=n.createElement("s",null,t)),e.code&&(t=n.createElement("code",null,t)),e.small&&(t=n.createElement("small",null,t)),e.sup&&(t=n.createElement("sup",null,t)),t),pt=({node:e,parent:t,...r})=>{const{lookupAttribute:i}=r,s=n.createElement(Ie,{parent:e,...r});switch(e.type){case"attribute":return n.createElement(gt,{node:e,...r});case"button":return n.createElement(vt,{node:e,...r});case"button-group":return n.createElement("div",{className:"userflowjs-bubble-buttons",style:{justifyContent:e.align}},s);case"column":return n.createElement("div",{style:St(e,t)},s);case"column-group":return n.createElement("div",{className:"p-like",style:Nt(e)},s);case"container":return n.createElement("div",{className:"p-like"+(e.className?` ${e.className}`:""),style:Ct(e)},s);case"image":return n.createElement(yt,{node:e,...r});case"link":return n.createElement("a",{href:H(e.href,{lookupAttribute:i}),target:e.target==="same"?"_top":"_blank",rel:"noopener noreferrer"},s);case"paragraph":return n.createElement("p",{className:ce(e)},s);case"heading1":return n.createElement("h1",{className:ce(e)},s);case"heading2":return n.createElement("h2",{className:ce(e)},s);case"question":return n.createElement(Et,{node:e,...r});case"quote":return n.createElement("blockquote",null,s);case"code-block":return n.createElement("pre",null,n.createElement("code",null,s));case"ordered-list":return n.createElement("ol",null,s);case"unordered-list":return n.createElement("ul",null,s);case"list-item":return n.createElement("li",null,s);case"video":return n.createElement(kt,{node:e,...r});default:return n.createElement("div",null,s)}},gt=({node:e,lookupAttribute:t})=>{let r=Le(e,t);return n.createElement(Re,{node:e},r)},vt=({node:e,buttons:t})=>{const r=t?.find(i=>i.cvid===e.cvid);return r?n.createElement(it,{key:r.id,button:r}):null},Et=({node:e,questions:t})=>{const r=t?.find(i=>i.cvid===e.cvid);return r?n.createElement(ct,{key:r.id,question:r}):null},yt=({node:e,lookupAttribute:t})=>{const{src:r,widthMode:i,displayWidth:s,width:l,height:a,marginTop:c,marginRight:b,marginBottom:f,marginLeft:v,align:u,hasLink:g,href:y}=e;if(!r)return null;const{wrapperStyle:d,blockStyle:m}=Ae({widthMode:i,displayWidth:s,width:l,height:a,marginTop:c,marginRight:b,marginBottom:f,marginLeft:v,align:u}),E=typeof r=="string"?r:H(r,{lookupAttribute:t});let h=n.createElement("img",{src:xe(E,j=>encodeURIComponent((t?t(j):"")||"")),style:{...m,objectFit:"contain"},alt:""});return g&&y&&(h=n.createElement("a",{href:H(y,{lookupAttribute:t}),target:e.target==="same"?"_top":"_blank",rel:"noopener noreferrer",style:m},h)),n.createElement("div",{className:"p-like"},n.createElement("div",{style:d},h))},kt=({node:e,lookupAttribute:t})=>{const{url:r,widthMode:i,displayWidth:s,width:l,height:a,marginTop:c,marginRight:b,marginBottom:f,marginLeft:v,align:u}=e;if(!r)return null;const{wrapperStyle:g,blockStyle:y}=Ae({widthMode:i,displayWidth:s,width:l,height:a,marginTop:c,marginRight:b,marginBottom:f,marginLeft:v,align:u});return n.createElement("div",{className:"p-like"},n.createElement("div",{style:g},n.createElement("div",{style:y},n.createElement(_t,{element:e,noFocus:!0,lookupAttribute:t}))))},_t=({element:{embedType:e,url:t,src:r,autoPlay:i,controls:s,loop:l,muted:a},noFocus:c,forceMuted:b,lookupAttribute:f})=>{if(!t)return null;const v=typeof t=="string"?t:H(t,{lookupAttribute:f}),u={width:"100%",height:"100%",allow:"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,allowtransparency:"true",mozallowfullscreen:"true",webkitallowfullscreen:"true",oallowfullscreen:"true",msallowfullscreen:"true",style:{display:"block",border:"none"},tabIndex:c?-1:void 0};if(e==="video")return n.createElement("video",{key:v+";"+String(i)+";"+String(s)+";"+String(l)+";"+String(a),src:v,style:{width:"100%",height:"100%",display:"block"},autoPlay:!!i,controls:s!==!1,loop:l,muted:b||a});if(r){let E;try{E=new URL(r)}catch{return null}return b&&(E.searchParams.has("autoplay")||E.searchParams.has("autoPlay"))&&(E.searchParams.set("mute","1"),E.searchParams.set("muted","1"),E.searchParams.set("volume","0")),n.createElement("iframe",{src:E.toString(),...u})}let g=xt(v,{iframeFallback:!0});if(g.kind==="invalid")return null;const{videoProvider:y,videoId:d,searchParams:m}=g;switch(i=i||m.has("autoplay")||m.has("autoPlay"),y){case"iframe":return n.createElement("iframe",{src:xe(d,E=>encodeURIComponent((f?f(E):"")||"")),scrolling:m.get("scrolling")||void 0,...u});case"loom":return n.createElement("iframe",{src:`https://www.loom.com/embed/${d}?${m.toString()}`,...u});case"raw":return n.createElement("video",{src:d,controls:!0,style:{width:"100%",height:"100%",display:"block"},autoPlay:m.has("autoplay"),muted:b||m.has("muted")});case"youtube":return b&&i&&m.set("mute","1"),n.createElement("iframe",{src:`https://www.youtube.com/embed/${d}?${m.toString()}`,...u});case"vimeo":return b&&i&&m.set("muted","1"),n.createElement("iframe",{src:`https://player.vimeo.com/video/${d}?${m.toString()}`,...u});case"wistia":return m.set("videoFoam","true"),b&&i&&m.set("volume","0"),n.createElement(n.Fragment,null,n.createElement("iframe",{src:`https://fast.wistia.net/embed/iframe/${d}?${m.toString()}`,...u}))}};function xt(e,{iframeFallback:t}={}){let r;try{r=new URL(e)}catch{return{kind:"invalid"}}const{hostname:i,pathname:s,searchParams:l}=r;if(i.match(/^(www\.)?(use)?loom\.com$/)){const a=s.match(/^\/share\/([a-z0-9]+)$/i);if(a){const[,c]=a;return{kind:"ok",videoProvider:"loom",videoId:c,searchParams:l}}}if(e.startsWith("raw:"))return{kind:"ok",videoProvider:"raw",videoId:e.replace(/^raw:/,""),searchParams:l};if(e.startsWith("iframe:"))return{kind:"ok",videoProvider:"iframe",videoId:e.replace(/^iframe:/,""),searchParams:l};if(["youtube.com","www.youtube.com"].includes(i)){const a=l.get("v");if(a)return l.delete("v"),{kind:"ok",videoProvider:"youtube",videoId:a,searchParams:l}}if(i==="youtu.be"){const a=s.match(/^\/([^/]+)$/);if(a){const[,c]=a;return{kind:"ok",videoProvider:"youtube",videoId:c,searchParams:l}}}if(i==="vimeo.com"){const a=s.match(/^\/(\d+)$/);if(a){const[,c]=a;return{kind:"ok",videoProvider:"vimeo",videoId:c,searchParams:l}}}if(i==="player.vimeo.com"){const a=s.match(/^\/video\/([^/]+)$/);if(a){const[,c]=a;return{kind:"ok",videoProvider:"vimeo",videoId:c,searchParams:l}}}if(i.match(/^[^.]+\.wistia.com$/)){const a=s.match(/^\/medias\/([^/]+)$/);if(a){const[,c]=a;return{kind:"ok",videoProvider:"wistia",videoId:c,searchParams:l}}}return t?{kind:"ok",videoProvider:"iframe",videoId:e,searchParams:l}:{kind:"invalid"}}function ce(e){return e.align==="right"?"userflowjs-text-align-end":e.align==="center"?"userflowjs-text-align-center":e.align==="justify"?"userflowjs-text-align-justify":""}function Ae({widthMode:e,displayWidth:t,width:r,height:i,marginTop:s,marginRight:l,marginBottom:a,marginLeft:c,align:b}){const f={position:"relative"},v={position:"absolute",top:"0",left:"0",display:"block",width:"100%",height:"100%"};typeof t!="number"&&(t=100,e="percent"),b==="center"?(f.marginLeft="auto",f.marginRight="auto"):b==="right"&&(f.marginLeft="auto");let u=0;if(s!=null&&typeof s=="number"&&(f.marginTop=`${s}px`),l!=null&&typeof l=="number"&&(f.marginRight=`${l}px`,u+=l),a!=null&&typeof a=="number"&&(f.marginBottom=`${a}px`),c!=null&&typeof c=="number"&&(f.marginLeft=`${c}px`,u+=c),typeof t!="number"||typeof r!="number"||typeof i!="number")f.width="100px",f.height="100px";else if(e==="px"){const y=Math.max(10,t);f.width=`${y}px`,f.height=`${y/(r/i)}px`}else{const g=Math.max(0,Math.min(100,t));f.width=`calc(${g}% - ${u}px)`,f.height="0",f.paddingBottom=`calc((${g}% - ${u}px) / (${r} / ${i})`}return{wrapperStyle:f,blockStyle:v}}const qe=16;function Nt(e){return{display:"flex",alignItems:"stretch",marginRight:`-${e.spacing==null?qe:e.spacing}px`}}function St(e,t){const r=e.widthMode==="fill"||e.displayWidth==null;return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:r?void 0:e.widthMode==="px"?`${e.displayWidth||50}px`:e.widthMode==="percent"?`${e.displayWidth||50}%`:void 0,flex:r?"1 0 0":void 0,marginRight:`${t.spacing==null?qe:t.spacing}px`,marginBottom:"0"}}function Ct(e){return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:e.widthMode==="px"&&e.displayWidth!=null?`${e.displayWidth}px`:e.widthMode==="percent"&&e.displayWidth!=null?`${e.displayWidth}%`:void 0,minHeight:e.heightMode==="px"?`${e.displayHeight||50}px`:void 0,flex:e.heightMode==="fill"?"1 0 0":void 0,marginTop:e.marginTop!=null?`${e.marginTop}px`:void 0,marginRight:e.marginRight!=null?`${e.marginRight}px`:e.widthMode!=="fill"&&e.align==="center"?"auto":void 0,marginBottom:e.marginBottom!=null?`${e.marginBottom}px`:void 0,marginLeft:e.marginLeft!=null?`${e.marginLeft}px`:e.widthMode!=="fill"&&(e.align==="center"||e.align==="right")?"auto":void 0}}function Le(e,t){if(!t)return null;const r=e.attributeName;if(typeof r=="string"){const i=t(r)||e.fallback;if(typeof i=="string")return i}return null}function Fe(e){return Array.isArray(e.children)&&typeof e.addMark>"u"}function ke(e,t,r="type"){return Fe(e)&&typeof e=="object"&&e[r]===t}function de(e){return typeof e.text=="string"}function $e(e,t){function r(s,l){t(s,l),Fe(s)&&i(s.children)}function i(s){s&&s.forEach((l,a)=>l&&r(l,a))}i(Array.isArray(e)?e:e.children)}const Vt=n.memo(({doc:e,lookupAttribute:t})=>e?n.createElement(n.Fragment,null,H(e,{lookupAttribute:t})):null);function Gt(e,{buttons:t,questions:r}){const i=new Set,s=new Set;if($e(e,l=>{ke(l,"button")&&i.add(l.cvid),ke(l,"question")&&s.add(l.cvid)}),r){const l=r.filter(a=>!s.has(a.cvid));l.length>0&&(e={...e,children:[...e.children,...l.map(a=>({type:"question",cvid:a.cvid,children:[{text:""}]}))]})}if(t){const l=t.filter(a=>!i.has(a.cvid));l.length>0&&(e={...e,children:[...e.children,{type:"button-group",children:l.map(a=>({type:"button",cvid:a.cvid,children:[{text:""}]}))}]})}return e}function jt(e){return e=e||"default","userflowjs-bubble-button "+(e==="primary"||e==="PRIMARY"||e==="default"||e==="DEFAULT"||e==="banner-primary"||e==="banner-secondary"?`userflowjs-bubble-button--${e.toLowerCase()}`:e)}const Jt=new URL("bubble-frame.css",import.meta.url).href;let be=!1;const z=[];let te=[],De;function Tt(e){z.push(e),z.length===1&&(be=!0,Oe(),window.addEventListener("scroll",Me))}function It(e){const t=z.indexOf(e);t>=0&&(z.splice(t,1),z.length===0&&(be=!1,window.cancelAnimationFrame(De),window.removeEventListener("scroll",Me)))}function Kt(e){te.push(e)}function Rt(){z.forEach(e=>e()),te.length>0&&(te.forEach(e=>e()),te=[]),Oe()}function Oe(){be&&(De=window.requestAnimationFrame(Rt))}function Me(){}function Qt({selector:e,targetMoved:t,targetLost:r,onTargetClick:i,onTargetMouseEnter:s,onTargetMouseLeave:l}){const a=p.useRef(t),c=p.useRef(r),b=p.useRef(i),f=p.useRef(s),v=p.useRef(l);p.useLayoutEffect(()=>{a.current=t,c.current=r,b.current=i,f.current=s,v.current=l}),p.useLayoutEffect(()=>{let u=null,g=null,y=null,d=!1;const m=()=>{u=null,g=null,y=null,c.current()};if(!e){m();return}const E=()=>{if(!y||!u)return;const _=Ce(u);(!g||!At(g,_))&&(g=_,_.width===0&&_.height===0?m():a.current({targetEl:u,targetRect:g,clipEl:y,viewportClipRect:qt(y)}))};let h=!1;const j=()=>{h||(h=!0,Tt(E))},R=()=>{h&&(h=!1,It(E))},V=()=>{b.current&&b.current()},S=()=>{f.current&&f.current()},M=()=>{v.current&&v.current()},G=()=>{const _=u;u=Qe(e)?e:Xe(e),(!d||u!==_)&&(_&&(_.removeEventListener("click",V),_.removeEventListener("mouseenter",S),_.removeEventListener("mouseleave",M)),u?(j(),u.addEventListener("click",V),u.addEventListener("mouseenter",S),u.addEventListener("mouseleave",M),y=Ze(u)):(R(),m())),d=!0};G();const Q=We(G);return()=>{Q.disconnect(),R(),u&&(u.removeEventListener("click",V),u.removeEventListener("mouseenter",S),u.removeEventListener("mouseleave",M))}},[e])}function At(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function qt(e){Ye();const t=Ee(et()),r=Ee(tt());if(!e||e===document.documentElement)return{top:0,right:r,bottom:t,left:0};{const i=Ce(e);return{top:Math.max(0,i.top),right:Math.min(r,i.right),bottom:Math.min(t,i.bottom),left:Math.max(0,i.left)}}}export{it as B,Ht as R,nt as S,Vt as a,Jt as b,ye as c,Te as d,at as e,zt as f,Le as g,je as h,de as i,fe as j,Gt as m,lt as n,Kt as r,H as s,Qt as u};
10
+ But if this flow was running in published mode, the flow would now be snoozed for ${r.timeValue} ${r.timeUnit.toLowerCase()+(r.timeValue===1?"":"s")}.`):e.send({kind:"Snooze",flowId:t.flow.id,timeValue:r.timeValue,timeUnit:r.timeUnit},{batch:!0}));return;case R.START_FLOW:t.kind==="launcher"&&e.deactivateLauncher(t),r.otherFlow?await e.startFlow({flowId:r.otherFlow.id,stepCvid:r.otherFlowStepCvid,startReason:t.draftMode?ve.DRAFT:ve.ACTION,replaceCurrent:!0}):console.warn("Userflow.js: START_FLOW action is missing other flow");return;case R.TRACK_BUTTON_EVENT:{let s=null,l=t?t.id:null;if(t.kind==="flow"){const{currentStep:a}=t;s=a?a?.crossVersionId:null}if(r.buttonEvent){const{eventName:a,token:u}=r.buttonEvent;await e.trackButtonEvent(a,u,s,l)}return}}}async function je(e,t,r){const i=[],s=[],l=[];for(const a of r)a.type===R.NAVIGATE?a.navigateTarget===Ne.NEW_TAB?i.push(a):l.push(a):s.push(a);for(const a of i)ue(e,t,a);await Promise.all(s.map(a=>ue(e,t,a)));for(const a of l)ue(e,t,a)}const it=({button:e})=>{const t=Se(),r=fe(),i=ye(e.disabledCondition),s=ye(e.hiddenCondition);return n.createElement(at,{appearance:e.appearance,hidden:s,disabled:i,onClick:()=>je(t,r,e.actions),text:_e(e.text,r.data)})},ot=()=>n.createElement("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},n.createElement("polygon",{className:"userflowjs-star-shape",fill:"#fff",points:"16 22.7785728 7.18322122 29.1352549 10.5042507 18.7856772 1.73415226 12.3647451 12.6034401 12.3250364 16 2 19.3965599 12.3250364 30.2658477 12.3647451 21.4957493 18.7856772 24.8167788 29.1352549"})),ut=({type:e,required:t,placeholder:r,buttonText:i,options:s,otherOption:l,multipleSelection:a,shuffleOptions:u,labelLeft:b,labelCenter:f,labelRight:v,minValue:c,maxValue:g,onSubmit:y,inert:d})=>{const{t:m}=Je(),E=p.useRef(null),[h,j]=p.useState(""),[A,H]=p.useState(new Set),[S,M]=p.useState(),[K,Q]=p.useState(),[_,G]=p.useState(!1),[k,ne]=p.useState(!1),[D,q]=p.useState(null),P=p.useMemo(()=>s&&(u?[...s].sort(()=>Math.random()-.5):s),[s,u]),L=o=>{if(!(d||!y)){if(t&&h===""&&[N.MULTILINE_TEXT,N.TEXT].includes(e)){q(m("question.requiredError")),re();return}ne(!0),q(null),y({...o,onCancel:()=>{ne(!1)},onError:T=>{ne(!1),q(T||"Sorry, something went wrong saving your answer. Please try again.")}})}},re=p.useCallback(()=>{d||!E.current||E.current.focus()},[d]),[he,we]=p.useState(!1);p.useEffect(()=>{he&&(re(),we(!1))},[re,he]);const pe=n.createElement("div",{className:"userflowjs-bubble-buttons"},n.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>L({answer:{kind:"text",value:h}}),tabIndex:d?-1:void 0,disabled:k},n.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},i||m("question.submit"))));let C=null,X=0;if(e===N.NPS)b=b||m("question.npsLabelLeft"),v=v||m("question.npsLabelRight"),C=[0,1,2,3,4,5,6,7,8,9,10],X=C.length;else if([N.SCALE,N.STARS].includes(e)){c=c??1,g=g??5,C=[];for(let o=c;o<=g;o++)C.push(o);X=C.length}else e===N.MULTIPLE_CHOICE&&(X=(P?P.length:0)+(l&&!_?1:0));const[ge,Pe]=p.useState(-1),F=ge===-1?-1:Math.min(ge,X-1),se=o=>{if(!o.target.closest('[role="radio"], [role="checkbox"], [role="radiogroup"], [role="group"]'))return;let x=null;if(o.key==="ArrowRight"||o.key==="ArrowDown"?x=1:(o.key==="ArrowLeft"||o.key==="ArrowUp")&&(x=-1),x!=null){o.preventDefault();const W=o.currentTarget.querySelectorAll('[role="radio"], [role="checkbox"]');let w=F+x;w<0?w=W.length-1:w>W.length-1&&(w=0),Pe(w),W[w].focus()}};let ae=null,le=null;if(C&&(b||f||v)){const o=[];b&&o.push(C[0],b),v&&o.push(C[C.length-1],v),ae=n.createElement("div",{id:"a11y-scale-labels",className:"userflowjs-a11y-only"},o.join(", ")),le=n.createElement("div",{id:"userflowjs-bubble-question-labels",className:"userflowjs-bubble-question__scale-labels","aria-hidden":"true"},n.createElement("div",{className:"userflowjs-bubble-question__scale-label"},b),f&&n.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--center"},f),n.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--right"},v))}let U;switch(e){case N.MULTILINE_TEXT:U=n.createElement(n.Fragment,null,n.createElement("textarea",{ref:E,className:"userflowjs-textarea userflowjs-bubble-question__textarea",value:h,onChange:o=>j(o.target.value),onKeyDown:o=>{(o.ctrlKey||o.metaKey)&&o.key==="Enter"&&L({answer:{kind:"text",value:h}})},placeholder:r||m("question.placeholder"),readOnly:d||k,tabIndex:d?-1:void 0,rows:3,"aria-required":t?"true":void 0,"aria-invalid":D!=null?"true":void 0}),pe);break;case N.MULTIPLE_CHOICE:{const o=()=>{h&&L({answer:{kind:"text",value:h},animationPromise:ee()})},T=(P?.length||0)+(l?1:0),x=Math.max(0,Math.min(T,c??1)),B=Math.max(0,Math.min(T,g??T)),W=()=>{const w=(P||[]).filter((J,$)=>A.has($)).map(J=>J.value);if(l&&_&&h!==""&&w.push(h),x===B&&w.length!==x){q(m("question.multiple_selection_wrong",{count:x}));return}else if(w.length<x){q(m("question.multiple_selection_too_few",{count:x}));return}else if(w.length>B){q(m("question.multiple_selection_too_many",{count:B}));return}L({answer:{kind:"list",values:w}})};U=n.createElement(n.Fragment,null,a&&n.createElement("div",{className:O({"userflowjs-bubble-question__multiple-choice-hint":!0,"userflowjs-bubble-question__multiple-choice-hint--error":!!D})},m("question.multiple_selection_hint",{replace:{selected:A.size+(l&&_&&h!==""?1:0),range:x===B?x:`${x}-${B}`}}),D&&n.createElement(n.Fragment,null,". ",n.createElement("span",{role:"alert"},D))),n.createElement("div",{className:O({"userflowjs-bubble-question__multiple-choice":!0,"userflowjs-bubble-question__multiple-choice--single-selection":!a,"userflowjs-bubble-question__multiple-choice--multiple-selection":!!a}),role:a?"group":"radiogroup",tabIndex:!d&&F===-1?0:-1,onKeyDown:se},P?.map(({value:w,label:J},$)=>n.createElement("button",{key:$,className:O({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--selected":a?A.has($):k&&!_&&h==w}),onClick:k?void 0:()=>{if(a){q(null);const ie=new Set(A);A.has($)?ie.delete($):ie.add($),H(ie)}else G(!1),j(w),L({answer:{kind:"text",value:w},animationPromise:ee()})},disabled:k,tabIndex:!d&&$===F?0:-1,role:a?"checkbox":"radio","aria-label":J||w,"aria-checked":!_&&h==w},a?n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},n.createElement(Z,{icon:Y}))):n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},J||w))),l&&(_?n.createElement("div",{className:O({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--other":!0,"userflowjs-bubble-question__multiple-choice-option--selected":a?h!="":k})},a?n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox",onClick:()=>{j(""),G(!1)}},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},n.createElement(Z,{icon:Y}))):n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),n.createElement("input",{ref:E,className:"userflowjs-bubble-question__multiple-choice-option-input",value:h,onChange:w=>j(w.target.value),onKeyDown:w=>{!w.shiftKey&&w.key==="Enter"?a?W():o():w.key==="Escape"&&(w.stopPropagation(),j(""),G(!1))},onBlur:()=>{h===""&&G(!1)},placeholder:r||m("question.placeholder"),readOnly:d||k,tabIndex:d?-1:void 0}),!a&&n.createElement("button",{"data-testid":"multiple-choice-other-submit",className:"userflowjs-bubble-question__multiple-choice-option-submit",onClick:()=>o(),disabled:k,"aria-label":m("question.submit")},n.createElement(Z,{icon:Y}))):n.createElement("button",{className:"userflowjs-bubble-question__multiple-choice-option",onClick:k?void 0:()=>{q(null),G(!0),we(!0)},disabled:k,tabIndex:!d&&P?.length===F?0:-1,role:"radio","aria-label":m("question.other"),"aria-checked":"false"},a?n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},n.createElement(Z,{icon:Y}))):n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),n.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},m("question.other"))))),a&&n.createElement("div",{className:"userflowjs-bubble-buttons"},n.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:W,tabIndex:d?-1:void 0,disabled:k},n.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},i||m("question.submit")))));break}case N.NPS:case N.SCALE:{U=n.createElement(n.Fragment,null,ae,n.createElement("div",{className:"userflowjs-bubble-question__scale-options",role:"radiogroup",tabIndex:!d&&F===-1?0:-1,onKeyDown:se},C?.map((o,T)=>n.createElement("button",{className:O({"userflowjs-bubble-question__scale-option":!0,"userflowjs-bubble-question__scale-option--selected":k&&S==o}),key:o,tabIndex:!d&&T===F?0:-1,onClick:()=>{M(o),L({answer:{kind:"number",value:o},animationPromise:ee()})},disabled:k,role:"radio","aria-checked":S==o},o))),le);break}case N.STARS:{U=n.createElement("div",{className:"userflowjs-bubble-question__stars-wrapper"},ae,n.createElement("div",{className:"userflowjs-bubble-question__stars",role:"radiogroup",tabIndex:!d&&F===-1?0:-1,onKeyDown:se},C?.map((o,T)=>n.createElement("button",{className:O({"userflowjs-bubble-question__star":!0,"userflowjs-bubble-question__star--hovered":!k&&K!=null&&K>=o,"userflowjs-bubble-question__star--selected":k&&S!=null&&S>=o,"userflowjs-bubble-question__star--not-selected":k&&S!=null&&S<o}),key:o,tabIndex:!d&&T===F?0:-1,onClick:()=>{M(o),L({answer:{kind:"number",value:o},animationPromise:ee()})},onMouseOver:()=>Q(o),onMouseLeave:()=>Q(null),disabled:k,role:"radio","aria-checked":S==o,"aria-label":String(o)},n.createElement("div",{className:"userflowjs-bubble-question__star-icon","aria-hidden":"true"},n.createElement(ot,null)),n.createElement("div",{className:"userflowjs-bubble-question__star-value","aria-hidden":"true"},o)))),le);break}case N.TEXT:U=n.createElement(n.Fragment,null,n.createElement("input",{ref:E,className:"userflowjs-text-input userflowjs-bubble-question__text-input",value:h,onChange:o=>j(o.target.value),onKeyDown:o=>{!o.shiftKey&&o.key==="Enter"&&L({answer:{kind:"text",value:h}})},placeholder:r||m("question.placeholder"),readOnly:d||k,tabIndex:d?-1:void 0,"aria-required":t?"true":void 0,"aria-invalid":D!=null?"true":void 0}),pe);break}return n.createElement("div",{className:"userflowjs-bubble-question",style:{pointerEvents:d?"none":void 0}},D&&!(e===N.MULTIPLE_CHOICE&&a)&&n.createElement("div",{className:"userflowjs-bubble-question__error",role:"alert"},D),U)};function ee(){return new Promise(e=>window.setTimeout(e,250))}const ct=({question:e})=>{const t=Se(),r=rt();return n.createElement(ut,{type:e.type,required:!!e.required,placeholder:e.placeholder||"",buttonText:e.buttonText||"",options:e.options,otherOption:e.otherOption,multipleSelection:e.multipleSelection,shuffleOptions:e.shuffleOptions,labelLeft:e.labelLeft||"",labelCenter:e.labelCenter||"",labelRight:e.labelRight||"",minValue:e.minValue,maxValue:e.maxValue,onSubmit:async i=>{Ge("answerQuestion",r.id,e.cvid,i);const{answer:s}=i;try{await Promise.all([await t.send({kind:"AnswerQuestion",sessionId:r.id,questionName:e.name,questionCvid:e.cvid,textAnswer:s.kind=="text"?s.value:null,numberAnswer:s.kind=="number"?String(s.value):null,listAnswer:s.kind=="list"?s.values:null}),i.animationPromise])}catch(a){console.log("Userflow.js: Error when answering question:",a),i.onError();return}const{bindAttributeFqn:l}=e;if(l&&t.flowSession?.id===r.id){let a;switch(s.kind){case"text":a={name:l,value:s.value};break;case"number":a={name:l,value:String(s.value)};break;case"list":a={name:l,value:s.values};break}t.optimisticClockUIUpdate(()=>{t.setFlowSession({...r,data:[...r.data.filter(u=>u.name!==l),a]})})}je(t,r,e.actions)}})},mt=({text:e})=>{if(!e)return null;const t=e.split(/\n/);return t.length===1?n.createElement(n.Fragment,null,t[0]):n.createElement(n.Fragment,null,t.map((r,i)=>n.createElement(n.Fragment,{key:i},i>0&&n.createElement("br",null),r)))};function ft(e=""){return{type:"rich2",children:[dt(e)]}}function dt(e=""){return{type:"paragraph",children:[{text:e}]}}function Te(e){if(e){let t;try{t=JSON.parse(e)}catch{throw new Error("Could not JSON.parse rich content doc: "+e)}if(t.type==="rich2")return t;throw new Error("Could not recognize rich content doc: "+e)}else return ft()}function bt(e=""){return{type:"plaintext2",children:[{type:"plaintext",children:[{text:e}]}]}}function ht(e){if(e){let t;try{t=JSON.parse(e)}catch{throw new Error("Could not JSON.parse plaintext doc: "+e)}if(t.type==="plaintext2")return t;throw new Error("Could not recognize plaintext doc: "+e)}else return bt()}function z(e,{lookupAttribute:t}){if(!e)return"";typeof e=="string"&&(e=ht(e));const r=[];function i(l){if(de(l)){l.text&&r.push(l.text);return}switch(l.type){case"attribute":{const a=Le(l,t);a&&r.push(a);break}default:s(l.children);break}}function s(l){l&&l.forEach(a=>a&&i(a))}return s(e.children),r.join("")}function Vt(e){let t=!0;if(!e)return!0;typeof e=="string"&&(e=Te(e));const r=new Set(["attribute","button","image","question","video"]);return $e(e,i=>{if(de(i)){i.text!==""&&(t=!1);return}"type"in i&&r.has(i.type)&&(t=!1)}),t}const zt=n.memo(({doc:e,...t})=>e?(typeof e=="string"&&(e=Te(e)),n.createElement(Ie,{parent:e,...t})):null),Ie=({parent:e,...t})=>n.createElement(n.Fragment,null,e.children.map((r,i)=>de(r)?n.createElement(wt,{key:i,node:r}):n.createElement(pt,{key:i,node:r,parent:e,...t}))),wt=({node:e})=>e.text?n.createElement(Re,{node:e},n.createElement(mt,{text:e.text})):null,Re=({node:e,children:t})=>(e.color&&typeof e.color=="string"&&(t=n.createElement("span",{style:{color:e.color}},t)),e.bold&&(t=n.createElement("b",null,t)),e.italic&&(t=n.createElement("i",null,t)),e.underline&&(t=n.createElement("u",null,t)),e.strikeThrough&&(t=n.createElement("s",null,t)),e.code&&(t=n.createElement("code",null,t)),e.small&&(t=n.createElement("small",null,t)),e.sup&&(t=n.createElement("sup",null,t)),t),pt=({node:e,parent:t,...r})=>{const{lookupAttribute:i}=r,s=n.createElement(Ie,{parent:e,...r});switch(e.type){case"attribute":return n.createElement(gt,{node:e,...r});case"button":return n.createElement(vt,{node:e,...r});case"button-group":return n.createElement("div",{className:"userflowjs-bubble-buttons",style:{justifyContent:e.align}},s);case"column":return n.createElement("div",{style:St(e,t)},s);case"column-group":return n.createElement("div",{className:"p-like",style:Nt(e)},s);case"container":return n.createElement("div",{className:"p-like"+(e.className?` ${e.className}`:""),style:Ct(e)},s);case"image":return n.createElement(yt,{node:e,...r});case"link":return n.createElement("a",{href:z(e.href,{lookupAttribute:i}),target:e.target==="same"?"_top":"_blank",rel:"noopener noreferrer"},s);case"paragraph":return n.createElement("p",{className:ce(e)},s);case"heading1":return n.createElement("h1",{className:ce(e)},s);case"heading2":return n.createElement("h2",{className:ce(e)},s);case"question":return n.createElement(Et,{node:e,...r});case"quote":return n.createElement("blockquote",null,s);case"code-block":return n.createElement("pre",null,n.createElement("code",null,s));case"ordered-list":return n.createElement("ol",null,s);case"unordered-list":return n.createElement("ul",null,s);case"list-item":return n.createElement("li",null,s);case"video":return n.createElement(kt,{node:e,...r});default:return n.createElement("div",null,s)}},gt=({node:e,lookupAttribute:t})=>{let r=Le(e,t);return n.createElement(Re,{node:e},r)},vt=({node:e,buttons:t})=>{const r=t?.find(i=>i.cvid===e.cvid);return r?n.createElement(it,{key:r.id,button:r}):null},Et=({node:e,questions:t})=>{const r=t?.find(i=>i.cvid===e.cvid);return r?n.createElement(ct,{key:r.id,question:r}):null},yt=({node:e,lookupAttribute:t})=>{const{src:r,widthMode:i,displayWidth:s,width:l,height:a,marginTop:u,marginRight:b,marginBottom:f,marginLeft:v,align:c,hasLink:g,href:y}=e;if(!r)return null;const{wrapperStyle:d,blockStyle:m}=Ae({widthMode:i,displayWidth:s,width:l,height:a,marginTop:u,marginRight:b,marginBottom:f,marginLeft:v,align:c}),E=typeof r=="string"?r:z(r,{lookupAttribute:t});let h=n.createElement("img",{src:xe(E,j=>encodeURIComponent((t?t(j):"")||"")),style:{...m,objectFit:"contain"},alt:""});return g&&y&&(h=n.createElement("a",{href:z(y,{lookupAttribute:t}),target:e.target==="same"?"_top":"_blank",rel:"noopener noreferrer",style:m},h)),n.createElement("div",{className:"p-like"},n.createElement("div",{style:d},h))},kt=({node:e,lookupAttribute:t})=>{const{url:r,widthMode:i,displayWidth:s,width:l,height:a,marginTop:u,marginRight:b,marginBottom:f,marginLeft:v,align:c}=e;if(!r)return null;const{wrapperStyle:g,blockStyle:y}=Ae({widthMode:i,displayWidth:s,width:l,height:a,marginTop:u,marginRight:b,marginBottom:f,marginLeft:v,align:c});return n.createElement("div",{className:"p-like"},n.createElement("div",{style:g},n.createElement("div",{style:y},n.createElement(_t,{element:e,noFocus:!0,lookupAttribute:t}))))},_t=({element:{embedType:e,url:t,src:r,autoPlay:i,controls:s,loop:l,muted:a},noFocus:u,forceMuted:b,lookupAttribute:f})=>{if(!t)return null;const v=typeof t=="string"?t:z(t,{lookupAttribute:f}),c={width:"100%",height:"100%",allow:"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,allowtransparency:"true",mozallowfullscreen:"true",webkitallowfullscreen:"true",oallowfullscreen:"true",msallowfullscreen:"true",style:{display:"block",border:"none"},tabIndex:u?-1:void 0};if(e==="video")return n.createElement("video",{key:v+";"+String(i)+";"+String(s)+";"+String(l)+";"+String(a),src:v,style:{width:"100%",height:"100%",display:"block"},autoPlay:!!i,controls:s!==!1,loop:l,muted:b||a});if(r){let E;try{E=new URL(r)}catch{return null}return b&&(E.searchParams.has("autoplay")||E.searchParams.has("autoPlay"))&&(E.searchParams.set("mute","1"),E.searchParams.set("muted","1"),E.searchParams.set("volume","0")),n.createElement("iframe",{src:E.toString(),...c})}let g=xt(v,{iframeFallback:!0});if(g.kind==="invalid")return null;const{videoProvider:y,videoId:d,searchParams:m}=g;switch(i=i||m.has("autoplay")||m.has("autoPlay"),y){case"iframe":return n.createElement("iframe",{src:xe(d,E=>encodeURIComponent((f?f(E):"")||"")),scrolling:m.get("scrolling")||void 0,...c});case"loom":return n.createElement("iframe",{src:`https://www.loom.com/embed/${d}?${m.toString()}`,...c});case"raw":return n.createElement("video",{src:d,controls:!0,style:{width:"100%",height:"100%",display:"block"},autoPlay:m.has("autoplay"),muted:b||m.has("muted")});case"youtube":return b&&i&&m.set("mute","1"),n.createElement("iframe",{src:`https://www.youtube.com/embed/${d}?${m.toString()}`,...c});case"vimeo":return b&&i&&m.set("muted","1"),n.createElement("iframe",{src:`https://player.vimeo.com/video/${d}?${m.toString()}`,...c});case"wistia":return m.set("videoFoam","true"),b&&i&&m.set("volume","0"),n.createElement(n.Fragment,null,n.createElement("iframe",{src:`https://fast.wistia.net/embed/iframe/${d}?${m.toString()}`,...c}))}};function xt(e,{iframeFallback:t}={}){let r;try{r=new URL(e)}catch{return{kind:"invalid"}}const{hostname:i,pathname:s,searchParams:l}=r;if(i.match(/^(www\.)?(use)?loom\.com$/)){const a=s.match(/^\/share\/([a-z0-9]+)$/i);if(a){const[,u]=a;return{kind:"ok",videoProvider:"loom",videoId:u,searchParams:l}}}if(e.startsWith("raw:"))return{kind:"ok",videoProvider:"raw",videoId:e.replace(/^raw:/,""),searchParams:l};if(e.startsWith("iframe:"))return{kind:"ok",videoProvider:"iframe",videoId:e.replace(/^iframe:/,""),searchParams:l};if(["youtube.com","www.youtube.com"].includes(i)){const a=l.get("v");if(a)return l.delete("v"),{kind:"ok",videoProvider:"youtube",videoId:a,searchParams:l}}if(i==="youtu.be"){const a=s.match(/^\/([^/]+)$/);if(a){const[,u]=a;return{kind:"ok",videoProvider:"youtube",videoId:u,searchParams:l}}}if(i==="vimeo.com"){const a=s.match(/^\/(\d+)$/);if(a){const[,u]=a;return{kind:"ok",videoProvider:"vimeo",videoId:u,searchParams:l}}}if(i==="player.vimeo.com"){const a=s.match(/^\/video\/([^/]+)$/);if(a){const[,u]=a;return{kind:"ok",videoProvider:"vimeo",videoId:u,searchParams:l}}}if(i.match(/^[^.]+\.wistia.com$/)){const a=s.match(/^\/medias\/([^/]+)$/);if(a){const[,u]=a;return{kind:"ok",videoProvider:"wistia",videoId:u,searchParams:l}}}return t?{kind:"ok",videoProvider:"iframe",videoId:e,searchParams:l}:{kind:"invalid"}}function ce(e){return e.align==="right"?"userflowjs-text-align-end":e.align==="center"?"userflowjs-text-align-center":e.align==="justify"?"userflowjs-text-align-justify":""}function Ae({widthMode:e,displayWidth:t,width:r,height:i,marginTop:s,marginRight:l,marginBottom:a,marginLeft:u,align:b}){const f={position:"relative"},v={position:"absolute",top:"0",left:"0",display:"block",width:"100%",height:"100%"};typeof t!="number"&&(t=100,e="percent"),b==="center"?(f.marginLeft="auto",f.marginRight="auto"):b==="right"&&(f.marginLeft="auto");let c=0;if(s!=null&&typeof s=="number"&&(f.marginTop=`${s}px`),l!=null&&typeof l=="number"&&(f.marginRight=`${l}px`,c+=l),a!=null&&typeof a=="number"&&(f.marginBottom=`${a}px`),u!=null&&typeof u=="number"&&(f.marginLeft=`${u}px`,c+=u),typeof t!="number"||typeof r!="number"||typeof i!="number")f.width="100px",f.height="100px";else if(e==="px"){const y=Math.max(10,t);f.width=`${y}px`,f.height=`${y/(r/i)}px`}else{const g=Math.max(0,Math.min(100,t));f.width=`calc(${g}% - ${c}px)`,f.height="0",f.paddingBottom=`calc((${g}% - ${c}px) / (${r} / ${i})`}return{wrapperStyle:f,blockStyle:v}}const qe=16;function Nt(e){return{display:"flex",alignItems:"stretch",marginRight:`-${e.spacing==null?qe:e.spacing}px`}}function St(e,t){const r=e.widthMode==="fill"||e.displayWidth==null;return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:r?void 0:e.widthMode==="px"?`${e.displayWidth||50}px`:e.widthMode==="percent"?`${e.displayWidth||50}%`:void 0,flex:r?"1 0 0":void 0,marginRight:`${t.spacing==null?qe:t.spacing}px`,marginBottom:"0"}}function Ct(e){return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:e.widthMode==="px"&&e.displayWidth!=null?`${e.displayWidth}px`:e.widthMode==="percent"&&e.displayWidth!=null?`${e.displayWidth}%`:void 0,minHeight:e.heightMode==="px"?`${e.displayHeight||50}px`:void 0,flex:e.heightMode==="fill"?"1 0 0":void 0,marginTop:e.marginTop!=null?`${e.marginTop}px`:void 0,marginRight:e.marginRight!=null?`${e.marginRight}px`:e.widthMode!=="fill"&&e.align==="center"?"auto":void 0,marginBottom:e.marginBottom!=null?`${e.marginBottom}px`:void 0,marginLeft:e.marginLeft!=null?`${e.marginLeft}px`:e.widthMode!=="fill"&&(e.align==="center"||e.align==="right")?"auto":void 0}}function Le(e,t){if(!t)return null;const r=e.attributeName;if(typeof r=="string"){const i=t(r)||e.fallback;if(typeof i=="string")return i}return null}function Fe(e){return Array.isArray(e.children)&&typeof e.addMark>"u"}function ke(e,t,r="type"){return Fe(e)&&typeof e=="object"&&e[r]===t}function de(e){return typeof e.text=="string"}function $e(e,t){function r(s,l){t(s,l),Fe(s)&&i(s.children)}function i(s){s&&s.forEach((l,a)=>l&&r(l,a))}i(Array.isArray(e)?e:e.children)}const Ht=n.memo(({doc:e,lookupAttribute:t})=>e?n.createElement(n.Fragment,null,z(e,{lookupAttribute:t})):null);function Kt(e,{buttons:t,questions:r}){const i=new Set,s=new Set;if($e(e,l=>{ke(l,"button")&&i.add(l.cvid),ke(l,"question")&&s.add(l.cvid)}),r){const l=r.filter(a=>!s.has(a.cvid));l.length>0&&(e={...e,children:[...e.children,...l.map(a=>({type:"question",cvid:a.cvid,children:[{text:""}]}))]})}if(t){const l=t.filter(a=>!i.has(a.cvid));l.length>0&&(e={...e,children:[...e.children,{type:"button-group",children:l.map(a=>({type:"button",cvid:a.cvid,children:[{text:""}]}))}]})}return e}function jt(e){return e=e||"default","userflowjs-bubble-button "+(e==="primary"||e==="PRIMARY"||e==="default"||e==="DEFAULT"||e==="banner-primary"||e==="banner-secondary"?`userflowjs-bubble-button--${e.toLowerCase()}`:e)}const Gt=new URL("bubble-frame.css",import.meta.url).href;let be=!1;const V=[];let te=[],De;function Tt(e){V.push(e),V.length===1&&(be=!0,Oe(),window.addEventListener("scroll",Me))}function It(e){const t=V.indexOf(e);t>=0&&(V.splice(t,1),V.length===0&&(be=!1,window.cancelAnimationFrame(De),window.removeEventListener("scroll",Me)))}function Jt(e){te.push(e)}function Rt(){V.forEach(e=>e()),te.length>0&&(te.forEach(e=>e()),te=[]),Oe()}function Oe(){be&&(De=window.requestAnimationFrame(Rt))}function Me(){}function Qt({selector:e,targetMoved:t,targetLost:r,onTargetClick:i,onTargetMouseEnter:s,onTargetMouseLeave:l}){const a=p.useRef(t),u=p.useRef(r),b=p.useRef(i),f=p.useRef(s),v=p.useRef(l);p.useLayoutEffect(()=>{a.current=t,u.current=r,b.current=i,f.current=s,v.current=l}),p.useLayoutEffect(()=>{let c=null,g=null,y=null,d=!1;const m=()=>{c=null,g=null,y=null,u.current()};if(!e){m();return}const E=()=>{if(!y||!c)return;const _=Ce(c);(!g||!At(g,_))&&(g=_,_.width===0&&_.height===0?m():a.current({targetEl:c,targetRect:g,clipEl:y,viewportClipRect:qt(y)}))};let h=!1;const j=()=>{h||(h=!0,Tt(E))},A=()=>{h&&(h=!1,It(E))},H=()=>{b.current&&b.current()},S=()=>{f.current&&f.current()},M=()=>{v.current&&v.current()},K=()=>{const _=c;c=Qe(e)?e:Xe(e),(!d||c!==_)&&(_&&(_.removeEventListener("click",H),_.removeEventListener("mouseenter",S),_.removeEventListener("mouseleave",M)),c?(j(),c.addEventListener("click",H),c.addEventListener("mouseenter",S),c.addEventListener("mouseleave",M),y=Ze(c)):(A(),m())),d=!0};K();const Q=We(K);return()=>{Q.disconnect(),A(),c&&(c.removeEventListener("click",H),c.removeEventListener("mouseenter",S),c.removeEventListener("mouseleave",M))}},[e])}function At(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function qt(e){Ye();const t=Ee(et()),r=Ee(tt());if(!e||e===document.documentElement)return{top:0,right:r,bottom:t,left:0};{const i=Ce(e);return{top:Math.max(0,i.top),right:Math.min(r,i.right),bottom:Math.min(t,i.bottom),left:Math.max(0,i.left)}}}export{it as B,zt as R,nt as S,Ht as a,Gt as b,ye as c,Te as d,at as e,Vt as f,Le as g,je as h,de as i,fe as j,Kt as m,lt as n,Jt as r,z as s,Qt as u};
11
11
  //# sourceMappingURL=use-selector-element-monitoring.js.map
package/userflow.js CHANGED
@@ -1,18 +1,18 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ResourceCenterApp.js","vendor.react.js","vendor.core-js.js","vendor.object-assign.js","client-context.js","vendor.i18next.js","vendor.babel.runtime.js","vendor.react-i18next.js","flow-host.styl.js","use-selector-element-monitoring.js","flow-condition-types.js","vendor.date-fns.js","roots.js","stylesheets.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.fortawesome.pro-solid-svg-icons.js","vendor.obj-str.js","Frame.js","vendor.react-dom.js","vendor.scheduler.js","use-window-resize.js","logomark.js","ChecklistUI.js","FlowChrome.js","use-element-rect.js","vendor.bignumber.js.js","BannerApp.js","vendor.phoenix.js","vendor.uuid.js","implicit-tracking.js","DebuggerUI.js","vendor.lodash.js","vendor.fortawesome.react-fontawesome.js","vendor.fortawesome.fontawesome-svg-core.js","vendor.react-day-picker.js","vendor.memoize-one.js","ui.js"])))=>i.map(i=>d[i]);
2
- import"./vendor.core-js.js";import{S as j}from"./vendor.phoenix.js";import{v as U}from"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="6fbef5aa-5e60-48d0-9bf7-557f4180b68c",t._sentryDebugIdIdentifier="sentry-dbid-6fbef5aa-5e60-48d0-9bf7-557f4180b68c")}catch{}})();const Y="modulepreload",z=function(t){return new URL("./",import.meta.url).toString()+t},v={},g=function(e,s,i){let n=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),h=a?.nonce||a?.getAttribute("nonce");n=Promise.allSettled(s.map(c=>{if(c=z(c),c in v)return;v[c]=!0;const l=c.endsWith(".css"),T=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${T}`))return;const E=document.createElement("link");if(E.rel=l?"stylesheet":Y,l||(E.as="script"),E.crossOrigin="",E.href=c,h&&E.setAttribute("nonce",h),document.head.appendChild(E),l)return new Promise((K,F)=>{E.addEventListener("load",K),E.addEventListener("error",()=>F(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=a,window.dispatchEvent(h),!h.defaultPrevented)throw a}return n.then(a=>{for(const h of a||[])h.status==="rejected"&&r(h.reason);return e().catch(r)})};class u extends Error{constructor(e,s,i){super(e),Object.setPrototypeOf(this,u.prototype),this.name="UserflowError",this.code=s,this.humanMessage=i}}class B{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}isSupported(){if(typeof window>"u")return!1;try{return window[this.type]!=null}catch{return!1}}getItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].getItem(e):null}setItem(e,s){e=this.formatKey(e);{if(!this.isSupported())return;window[this.type].setItem(e,s)}}removeItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].removeItem(e):void 0}clear(){return this.isSupported()?window[this.type].clear():void 0}}const I=new B("localStorage"),f=new B("sessionStorage");function it(t){window.location.href=t}function x(){return window.location.href}function N(t){window.postMessage(t,window.origin)}function H(t){const e=i=>{if(i.source!==window||i.origin!==window.origin)return;const n=i.data;!n||typeof n!="object"||typeof n.kind!="string"||!n.kind.startsWith("userflow:")||t(n)===!0&&s()};window.addEventListener("message",e);const s=()=>window.removeEventListener("message",e);return s}function J(t){return new Promise(e=>{H(s=>{const i=t(s);return i?(e(i),!0):!1})})}const A=new Set;let O=!1;function Q(t){return X(),A.add(t),()=>{G(t)}}function G(t){A.delete(t)}function w(){A.forEach(t=>t())}function X(){if(O)return;O=!0;const{history:t}=window,e=s=>{const i=t[s];t[s]=(...n)=>{const r=i.apply(t,n);return w(),r}};window.__userflowStatePatched?(window.addEventListener("userflow:pushstate",()=>{w()}),window.addEventListener("userflow:replacestate",()=>{w()})):(e("pushState"),e("replaceState")),window.addEventListener("popstate",()=>{w()})}class Z{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){N({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=H(e),!1}async captureScreenshot(e,s,i,n){return N({kind:"userflow:crxScreenshot",x:e,y:s,width:i,height:n,devicePixelRatio:window.devicePixelRatio}),(await J(a=>a.kind==="userflow:crxScreenshotResult"?a:null)).imageDataUrl}}var C=(t=>(t.ACTION="ACTION",t.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",t.REPLACED="REPLACED",t.SNOOZED="SNOOZED",t.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",t.USERFLOWJS="USERFLOWJS",t.USER_CLOSED="USER_CLOSED",t))(C||{}),q=(t=>(t.SECOND="SECOND",t.MINUTE="MINUTE",t.HOUR="HOUR",t.DAY="DAY",t))(q||{}),m=(t=>(t.ACTION="ACTION",t.DRAFT="DRAFT",t.LINK="LINK",t.LAUNCHER_SEEN="LAUNCHER_SEEN",t.RESOURCE_CENTER="RESOURCE_CENTER",t.USERFLOWJS="USERFLOWJS",t))(m||{}),ee=(t=>(t.LIKE="LIKE",t.DISLIKE="DISLIKE",t))(ee||{}),S=(t=>(t.STRING="STRING",t.BOOLEAN="BOOLEAN",t.NUMBER="NUMBER",t.DATETIME="DATETIME",t.LIST="LIST",t.RANDOM_AB="RANDOM_AB",t.RANDOM_NUMBER="RANDOM_NUMBER",t.CHECKLIST_TASK="CHECKLIST_TASK",t.FLOW="FLOW",t.FLOW_SESSION="FLOW_SESSION",t.FLOW_STEP="FLOW_STEP",t.FLOW_VERSION="FLOW_VERSION",t))(S||{}),k=(t=>(t.FLOW="FLOW",t.BANNER="BANNER",t.EMBED="EMBED",t.CHECKLIST="CHECKLIST",t.LAUNCHER="LAUNCHER",t.RESOURCE_CENTER="RESOURCE_CENTER",t))(k||{}),te=(t=>(t.ALWAYS_TRUE="ALWAYS_TRUE",t.ATTRIBUTE="ATTRIBUTE",t.CHECKLIST_TASK_CLICKED="CHECKLIST_TASK_CLICKED",t.CLAUSE="CLAUSE",t.ELEMENT="ELEMENT",t.EVENT="EVENT",t.FILLED_IN_INPUT="FILLED_IN_INPUT",t.FLOW="FLOW",t.INPUT_VALUE="INPUT_VALUE",t.PAGE="PAGE",t.SEGMENT="SEGMENT",t.TIME="TIME",t))(te||{}),se=(t=>(t.AUTO="AUTO",t.MANUAL="MANUAL",t))(se||{}),ie=(t=>(t.INPUT="INPUT",t))(ie||{}),ne=(t=>(t.ABSOLUTE_EQ="ABSOLUTE_EQ",t.ABSOLUTE_GT="ABSOLUTE_GT",t.ABSOLUTE_LT="ABSOLUTE_LT",t.AND="AND",t.BETWEEN="BETWEEN",t.CONTAINS="CONTAINS",t.EMPTY="EMPTY",t.ENDS_WITH="ENDS_WITH",t.EQ="EQ",t.EXCLUDES_ALL="EXCLUDES_ALL",t.EXCLUDES_ANY="EXCLUDES_ANY",t.FALSE="FALSE",t.GT="GT",t.GTE="GTE",t.INCLUDES_ALL="INCLUDES_ALL",t.INCLUDES_ANY="INCLUDES_ANY",t.LT="LT",t.LTE="LTE",t.NE="NE",t.NOT_CONTAINS="NOT_CONTAINS",t.NOT_EMPTY="NOT_EMPTY",t.NOT_REGEX="NOT_REGEX",t.OR="OR",t.REGEX="REGEX",t.RELATIVE_EQ="RELATIVE_EQ",t.RELATIVE_GT="RELATIVE_GT",t.RELATIVE_LT="RELATIVE_LT",t.STARTS_WITH="STARTS_WITH",t.TRUE="TRUE",t.URL="URL",t))(ne||{}),re=(t=>(t.CLICK="CLICK",t.DISABLED="DISABLED",t.MOUSEDOWN="MOUSEDOWN",t.NOT_CLICK="NOT_CLICK",t.NOT_DISABLED="NOT_DISABLED",t.NOT_PRESENT="NOT_PRESENT",t.PRESENT="PRESENT",t))(re||{}),oe=(t=>(t.END_USER="END_USER",t.GROUP="GROUP",t))(oe||{}),ae=(t=>(t.BETWEEN="BETWEEN",t.EQ="EQ",t.GTE="GTE",t.LTE="LTE",t))(ae||{}),ce=(t=>(t.ANY="ANY",t.RELATIVE_BETWEEN="RELATIVE_BETWEEN",t.RELATIVE_GT="RELATIVE_GT",t.RELATIVE_LT="RELATIVE_LT",t))(ce||{}),le=(t=>(t.CURRENT_USER="CURRENT_USER",t.CURRENT_USER_CURRENT_GROUP="CURRENT_USER_CURRENT_GROUP",t.CURRENT_GROUP="CURRENT_GROUP",t))(le||{}),ue=(t=>(t.ASSET="ASSET",t.CARTOON="CARTOON",t.NONE="NONE",t.URL="URL",t))(ue||{}),he=(t=>(t.INSIDE="INSIDE",t.OUTSIDE="OUTSIDE",t))(he||{}),de=(t=>(t.TOP_LEFT="TOP_LEFT",t.TOP_CENTER="TOP_CENTER",t.TOP_RIGHT="TOP_RIGHT",t.BOTTOM_RIGHT="BOTTOM_RIGHT",t.BOTTOM_CENTER="BOTTOM_CENTER",t.BOTTOM_LEFT="BOTTOM_LEFT",t.CENTER="CENTER",t))(de||{}),fe=(t=>(t.GOOGLE="GOOGLE",t.STANDARD="STANDARD",t))(fe||{}),Ee=(t=>(t.DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",t.DISMISS="DISMISS",t))(Ee||{}),Se=(t=>(t.DISMISS="DISMISS",t.NONE="NONE",t))(Se||{}),Te=(t=>(t.DEFAULT="DEFAULT",t.NARROW="NARROW",t.CHAINED_SQUARED="CHAINED_SQUARED",t.CHAINED_ROUNDED="CHAINED_ROUNDED",t.DOTTED="DOTTED",t.NUMBERED="NUMBERED",t))(Te||{}),ge=(t=>(t.TOP="TOP",t.BOTTOM="BOTTOM",t))(ge||{}),Ie=(t=>(t.DEFAULT="DEFAULT",t.PLAINTEXT="PLAINTEXT",t.CUSTOM="CUSTOM",t))(Ie||{}),we=(t=>(t.CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",t.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",t.NONE="NONE",t))(we||{}),Ce=(t=>(t.BUBBLE="BUBBLE",t.END="END",t.ERROR="ERROR",t.FLAG="FLAG",t))(Ce||{}),ke=(t=>(t.MANUAL="MANUAL",t.NONE="NONE",t.SYNTHETIC="SYNTHETIC",t))(ke||{}),me=(t=>(t.BUBBLE="BUBBLE",t.HIDDEN="HIDDEN",t.MODAL="MODAL",t.TOOLTIP="TOOLTIP",t))(me||{}),Ue=(t=>(t.ABOVE="ABOVE",t.BELOW="BELOW",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(Ue||{}),pe=(t=>(t.CLOSE_FLOW="CLOSE_FLOW",t.EVAL_JS="EVAL_JS",t.GO_TO_STEP="GO_TO_STEP",t.NAVIGATE="NAVIGATE",t.SET_ATTRIBUTE="SET_ATTRIBUTE",t.SNOOZE="SNOOZE",t.START_FLOW="START_FLOW",t))(pe||{}),Le=(t=>(t.NEW_TAB="NEW_TAB",t.SAME_TAB="SAME_TAB",t))(Le||{}),Ne=(t=>(t.SET="SET",t.SET_DATETIME="SET_DATETIME",t.SET_DATETIME_ONCE="SET_DATETIME_ONCE",t.SET_ONCE="SET_ONCE",t.ADD="ADD",t.SUBTRACT="SUBTRACT",t.APPEND="APPEND",t.PREPEND="PREPEND",t.REMOVE="REMOVE",t.UNSET="UNSET",t))(Ne||{}),_e=(t=>(t.MULTILINE_TEXT="MULTILINE_TEXT",t.MULTIPLE_CHOICE="MULTIPLE_CHOICE",t.NPS="NPS",t.SCALE="SCALE",t.STARS="STARS",t.TEXT="TEXT",t))(_e||{}),_=(t=>(t.ACTION="ACTION",t.ANNOUNCEMENTS="ANNOUNCEMENTS",t.ASSISTANT="ASSISTANT",t.CHECKLIST="CHECKLIST",t.CONTACT="CONTACT",t.DIVIDER="DIVIDER",t.FLOWS="FLOWS",t.KNOWLEDGE_BASE="KNOWLEDGE_BASE",t.MESSAGE="MESSAGE",t.SUBPAGE="SUBPAGE",t))(_||{}),Ae=(t=>(t.CRISP="CRISP",t.CUSTOM="CUSTOM",t.FRESHCHAT="FRESHCHAT",t.HELPSCOUT="HELPSCOUT",t.HUBSPOT="HUBSPOT",t.INTERCOM="INTERCOM",t.ZENDESK="ZENDESK",t.ZENDESK_MESSENGER="ZENDESK_MESSENGER",t))(Ae||{}),Re=(t=>(t.BUTTON="BUTTON",t.INPUT="INPUT",t))(Re||{}),ve=(t=>(t.EMAIL="EMAIL",t.PHONE="PHONE",t.CHAT="CHAT",t))(ve||{}),Oe=(t=>(t.SILENT="SILENT",t.BADGE="BADGE",t.POPOUT="POPOUT",t.MODAL="MODAL",t.TOAST="TOAST",t))(Oe||{}),be=(t=>(t.LAUNCHER_CLICK="LAUNCHER_CLICK",t.LAUNCHER_HOVER="LAUNCHER_HOVER",t.TARGET_CLICK="TARGET_CLICK",t.TARGET_HOVER="TARGET_HOVER",t.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",t.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",t))(be||{}),W=(t=>(t.ACTIVATE="ACTIVATE",t.DEACTIVATE="DEACTIVATE",t.NEVER="NEVER",t))(W||{}),De=(t=>(t.AUTO="AUTO",t.TOP="TOP",t.RIGHT="RIGHT",t.BOTTOM="BOTTOM",t.LEFT="LEFT",t))(De||{}),ye=(t=>(t.START="START",t.CENTER="CENTER",t.END="END",t))(ye||{}),Me=(t=>(t.PERCENT="PERCENT",t.PX="PX",t))(Me||{}),Pe=(t=>(t.BEACON="BEACON",t.BUTTON="BUTTON",t.HIDDEN="HIDDEN",t.ICON="ICON",t))(Pe||{}),Be=(t=>(t.LAUNCHER="LAUNCHER",t.TARGET="TARGET",t))(Be||{}),xe=(t=>(t.BODY_FIRST="BODY_FIRST",t.BODY_LAST="BODY_LAST",t.ELEMENT_FIRST="ELEMENT_FIRST",t.ELEMENT_LAST="ELEMENT_LAST",t.ELEMENT_BEFORE="ELEMENT_BEFORE",t.ELEMENT_AFTER="ELEMENT_AFTER",t))(xe||{}),He=(t=>(t.BODY_FIRST="BODY_FIRST",t.BODY_LAST="BODY_LAST",t.ELEMENT_FIRST="ELEMENT_FIRST",t.ELEMENT_LAST="ELEMENT_LAST",t.ELEMENT_BEFORE="ELEMENT_BEFORE",t.ELEMENT_AFTER="ELEMENT_AFTER",t))(He||{}),Ge=(t=>(t.ALWAYS="ALWAYS",t.MULTIPLE="MULTIPLE",t.NEVER="NEVER",t.ONCE="ONCE",t.ONCE_PER_GROUP="ONCE_PER_GROUP",t))(Ge||{}),We=(t=>(t.NONE="NONE",t.PENDING_SCHEDULE="PENDING_SCHEDULE",t.SCHEDULED="SCHEDULED",t.FIRED="FIRED",t))(We||{}),Ve=(t=>(t.NONE="NONE",t.LIKE="LIKE",t.SCALE="SCALE",t))(Ve||{}),$e=(t=>(t.HIDE="HIDE",t.BLOCK="BLOCK",t.OTHERS="OTHERS",t))($e||{});function Ke(){return{customInputs:[],customNavigate:null,urlFilter:null,linkUrlDecorator:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[t=>!t.match(/\d$/)],"data-id":[t=>!t.match(/\d$/)]},inferenceClassNameFilters:[t=>!t.startsWith("css-")],baseZIndex:1234500,evalJsDisabled:!1}}const d=Ke();function b(t){return Array.isArray(t)||(t=t?[t]:[]),t=t.map(e=>typeof e=="string"?new RegExp(e):e),t}function nt(t,e){return t.every(s=>typeof s=="function"?s(e):s instanceof RegExp?s.test(e):!0)}function Fe(){let t=x();if(d.urlFilter){if(t=d.urlFilter(t),typeof t!="string")throw new u("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(t)}catch(e){throw new u(`Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.
2
+ import"./vendor.core-js.js";import{S as j}from"./vendor.phoenix.js";import{v as U}from"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="e0faa25b-2abc-4d44-af22-1bddaaf4d6c8",t._sentryDebugIdIdentifier="sentry-dbid-e0faa25b-2abc-4d44-af22-1bddaaf4d6c8")}catch{}})();const Y="modulepreload",z=function(t){return new URL("./",import.meta.url).toString()+t},v={},g=function(e,s,i){let n=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),h=a?.nonce||a?.getAttribute("nonce");n=Promise.allSettled(s.map(c=>{if(c=z(c),c in v)return;v[c]=!0;const u=c.endsWith(".css"),T=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${T}`))return;const E=document.createElement("link");if(E.rel=u?"stylesheet":Y,u||(E.as="script"),E.crossOrigin="",E.href=c,h&&E.setAttribute("nonce",h),document.head.appendChild(E),u)return new Promise(($,F)=>{E.addEventListener("load",$),E.addEventListener("error",()=>F(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=a,window.dispatchEvent(h),!h.defaultPrevented)throw a}return n.then(a=>{for(const h of a||[])h.status==="rejected"&&r(h.reason);return e().catch(r)})};class l extends Error{constructor(e,s,i){super(e),Object.setPrototypeOf(this,l.prototype),this.name="UserflowError",this.code=s,this.humanMessage=i}}class B{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}isSupported(){if(typeof window>"u")return!1;try{return window[this.type]!=null}catch{return!1}}getItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].getItem(e):null}setItem(e,s){e=this.formatKey(e);{if(!this.isSupported())return;window[this.type].setItem(e,s)}}removeItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].removeItem(e):void 0}clear(){return this.isSupported()?window[this.type].clear():void 0}}const I=new B("localStorage"),f=new B("sessionStorage");function it(t){window.location.href=t}function x(){return window.location.href}function N(t){window.postMessage(t,window.origin)}function H(t){const e=i=>{if(i.source!==window||i.origin!==window.origin)return;const n=i.data;!n||typeof n!="object"||typeof n.kind!="string"||!n.kind.startsWith("userflow:")||t(n)===!0&&s()};window.addEventListener("message",e);const s=()=>window.removeEventListener("message",e);return s}function J(t){return new Promise(e=>{H(s=>{const i=t(s);return i?(e(i),!0):!1})})}const A=new Set;let O=!1;function Q(t){return X(),A.add(t),()=>{G(t)}}function G(t){A.delete(t)}function w(){A.forEach(t=>t())}function X(){if(O)return;O=!0;const{history:t}=window,e=s=>{const i=t[s];t[s]=(...n)=>{const r=i.apply(t,n);return w(),r}};window.__userflowStatePatched?(window.addEventListener("userflow:pushstate",()=>{w()}),window.addEventListener("userflow:replacestate",()=>{w()})):(e("pushState"),e("replaceState")),window.addEventListener("popstate",()=>{w()})}class Z{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){N({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=H(e),!1}async captureScreenshot(e,s,i,n){return N({kind:"userflow:crxScreenshot",x:e,y:s,width:i,height:n,devicePixelRatio:window.devicePixelRatio}),(await J(a=>a.kind==="userflow:crxScreenshotResult"?a:null)).imageDataUrl}}var C=(t=>(t.ACTION="ACTION",t.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",t.REPLACED="REPLACED",t.SNOOZED="SNOOZED",t.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",t.USERFLOWJS="USERFLOWJS",t.USER_CLOSED="USER_CLOSED",t))(C||{}),q=(t=>(t.SECOND="SECOND",t.MINUTE="MINUTE",t.HOUR="HOUR",t.DAY="DAY",t))(q||{}),m=(t=>(t.ACTION="ACTION",t.DRAFT="DRAFT",t.LINK="LINK",t.LAUNCHER_SEEN="LAUNCHER_SEEN",t.RESOURCE_CENTER="RESOURCE_CENTER",t.USERFLOWJS="USERFLOWJS",t))(m||{}),ee=(t=>(t.LIKE="LIKE",t.DISLIKE="DISLIKE",t))(ee||{}),S=(t=>(t.STRING="STRING",t.BOOLEAN="BOOLEAN",t.NUMBER="NUMBER",t.DATETIME="DATETIME",t.LIST="LIST",t.RANDOM_AB="RANDOM_AB",t.RANDOM_NUMBER="RANDOM_NUMBER",t.CHECKLIST_TASK="CHECKLIST_TASK",t.FLOW="FLOW",t.FLOW_SESSION="FLOW_SESSION",t.FLOW_STEP="FLOW_STEP",t.FLOW_VERSION="FLOW_VERSION",t))(S||{}),k=(t=>(t.FLOW="FLOW",t.BANNER="BANNER",t.EMBED="EMBED",t.CHECKLIST="CHECKLIST",t.LAUNCHER="LAUNCHER",t.RESOURCE_CENTER="RESOURCE_CENTER",t))(k||{}),te=(t=>(t.ALWAYS_TRUE="ALWAYS_TRUE",t.ATTRIBUTE="ATTRIBUTE",t.CHECKLIST_TASK_CLICKED="CHECKLIST_TASK_CLICKED",t.CLAUSE="CLAUSE",t.ELEMENT="ELEMENT",t.EVENT="EVENT",t.FILLED_IN_INPUT="FILLED_IN_INPUT",t.FLOW="FLOW",t.INPUT_VALUE="INPUT_VALUE",t.PAGE="PAGE",t.SEGMENT="SEGMENT",t.TIME="TIME",t))(te||{}),se=(t=>(t.AUTO="AUTO",t.MANUAL="MANUAL",t))(se||{}),ie=(t=>(t.INPUT="INPUT",t))(ie||{}),ne=(t=>(t.ABSOLUTE_EQ="ABSOLUTE_EQ",t.ABSOLUTE_GT="ABSOLUTE_GT",t.ABSOLUTE_LT="ABSOLUTE_LT",t.AND="AND",t.BETWEEN="BETWEEN",t.CONTAINS="CONTAINS",t.EMPTY="EMPTY",t.ENDS_WITH="ENDS_WITH",t.EQ="EQ",t.EXCLUDES_ALL="EXCLUDES_ALL",t.EXCLUDES_ANY="EXCLUDES_ANY",t.FALSE="FALSE",t.GT="GT",t.GTE="GTE",t.INCLUDES_ALL="INCLUDES_ALL",t.INCLUDES_ANY="INCLUDES_ANY",t.LT="LT",t.LTE="LTE",t.NE="NE",t.NOT_CONTAINS="NOT_CONTAINS",t.NOT_EMPTY="NOT_EMPTY",t.NOT_REGEX="NOT_REGEX",t.OR="OR",t.REGEX="REGEX",t.RELATIVE_EQ="RELATIVE_EQ",t.RELATIVE_GT="RELATIVE_GT",t.RELATIVE_LT="RELATIVE_LT",t.STARTS_WITH="STARTS_WITH",t.TRUE="TRUE",t.URL="URL",t))(ne||{}),re=(t=>(t.CLICK="CLICK",t.DISABLED="DISABLED",t.MOUSEDOWN="MOUSEDOWN",t.NOT_CLICK="NOT_CLICK",t.NOT_DISABLED="NOT_DISABLED",t.NOT_PRESENT="NOT_PRESENT",t.PRESENT="PRESENT",t))(re||{}),oe=(t=>(t.END_USER="END_USER",t.GROUP="GROUP",t))(oe||{}),ae=(t=>(t.BETWEEN="BETWEEN",t.EQ="EQ",t.GTE="GTE",t.LTE="LTE",t))(ae||{}),ce=(t=>(t.ANY="ANY",t.RELATIVE_BETWEEN="RELATIVE_BETWEEN",t.RELATIVE_GT="RELATIVE_GT",t.RELATIVE_LT="RELATIVE_LT",t))(ce||{}),ue=(t=>(t.CURRENT_USER="CURRENT_USER",t.CURRENT_USER_CURRENT_GROUP="CURRENT_USER_CURRENT_GROUP",t.CURRENT_GROUP="CURRENT_GROUP",t))(ue||{}),le=(t=>(t.ASSET="ASSET",t.CARTOON="CARTOON",t.NONE="NONE",t.URL="URL",t))(le||{}),he=(t=>(t.INSIDE="INSIDE",t.OUTSIDE="OUTSIDE",t))(he||{}),de=(t=>(t.TOP_LEFT="TOP_LEFT",t.TOP_CENTER="TOP_CENTER",t.TOP_RIGHT="TOP_RIGHT",t.BOTTOM_RIGHT="BOTTOM_RIGHT",t.BOTTOM_CENTER="BOTTOM_CENTER",t.BOTTOM_LEFT="BOTTOM_LEFT",t.CENTER="CENTER",t))(de||{}),fe=(t=>(t.GOOGLE="GOOGLE",t.STANDARD="STANDARD",t))(fe||{}),Ee=(t=>(t.DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",t.DISMISS="DISMISS",t))(Ee||{}),Se=(t=>(t.DISMISS="DISMISS",t.NONE="NONE",t))(Se||{}),Te=(t=>(t.DEFAULT="DEFAULT",t.NARROW="NARROW",t.CHAINED_SQUARED="CHAINED_SQUARED",t.CHAINED_ROUNDED="CHAINED_ROUNDED",t.DOTTED="DOTTED",t.NUMBERED="NUMBERED",t))(Te||{}),ge=(t=>(t.TOP="TOP",t.BOTTOM="BOTTOM",t))(ge||{}),Ie=(t=>(t.DEFAULT="DEFAULT",t.PLAINTEXT="PLAINTEXT",t.CUSTOM="CUSTOM",t))(Ie||{}),we=(t=>(t.CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",t.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",t.NONE="NONE",t))(we||{}),Ce=(t=>(t.BUBBLE="BUBBLE",t.END="END",t.ERROR="ERROR",t.FLAG="FLAG",t))(Ce||{}),ke=(t=>(t.MANUAL="MANUAL",t.NONE="NONE",t.SYNTHETIC="SYNTHETIC",t))(ke||{}),me=(t=>(t.BUBBLE="BUBBLE",t.HIDDEN="HIDDEN",t.MODAL="MODAL",t.TOOLTIP="TOOLTIP",t))(me||{}),Ue=(t=>(t.ABOVE="ABOVE",t.BELOW="BELOW",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(Ue||{}),pe=(t=>(t.CLOSE_FLOW="CLOSE_FLOW",t.EVAL_JS="EVAL_JS",t.GO_TO_STEP="GO_TO_STEP",t.NAVIGATE="NAVIGATE",t.SET_ATTRIBUTE="SET_ATTRIBUTE",t.SNOOZE="SNOOZE",t.START_FLOW="START_FLOW",t.TRACK_BUTTON_EVENT="TRACK_BUTTON_EVENT",t))(pe||{}),Le=(t=>(t.NEW_TAB="NEW_TAB",t.SAME_TAB="SAME_TAB",t))(Le||{}),Ne=(t=>(t.SET="SET",t.SET_DATETIME="SET_DATETIME",t.SET_DATETIME_ONCE="SET_DATETIME_ONCE",t.SET_ONCE="SET_ONCE",t.ADD="ADD",t.SUBTRACT="SUBTRACT",t.APPEND="APPEND",t.PREPEND="PREPEND",t.REMOVE="REMOVE",t.UNSET="UNSET",t))(Ne||{}),_e=(t=>(t.MULTILINE_TEXT="MULTILINE_TEXT",t.MULTIPLE_CHOICE="MULTIPLE_CHOICE",t.NPS="NPS",t.SCALE="SCALE",t.STARS="STARS",t.TEXT="TEXT",t))(_e||{}),_=(t=>(t.ACTION="ACTION",t.ANNOUNCEMENTS="ANNOUNCEMENTS",t.ASSISTANT="ASSISTANT",t.CHECKLIST="CHECKLIST",t.CONTACT="CONTACT",t.DIVIDER="DIVIDER",t.FLOWS="FLOWS",t.KNOWLEDGE_BASE="KNOWLEDGE_BASE",t.MESSAGE="MESSAGE",t.SUBPAGE="SUBPAGE",t))(_||{}),Ae=(t=>(t.CRISP="CRISP",t.CUSTOM="CUSTOM",t.FRESHCHAT="FRESHCHAT",t.HELPSCOUT="HELPSCOUT",t.HUBSPOT="HUBSPOT",t.INTERCOM="INTERCOM",t.ZENDESK="ZENDESK",t.ZENDESK_MESSENGER="ZENDESK_MESSENGER",t))(Ae||{}),Re=(t=>(t.BUTTON="BUTTON",t.INPUT="INPUT",t))(Re||{}),ve=(t=>(t.EMAIL="EMAIL",t.PHONE="PHONE",t.CHAT="CHAT",t))(ve||{}),Oe=(t=>(t.SILENT="SILENT",t.BADGE="BADGE",t.POPOUT="POPOUT",t.MODAL="MODAL",t.TOAST="TOAST",t))(Oe||{}),be=(t=>(t.LAUNCHER_CLICK="LAUNCHER_CLICK",t.LAUNCHER_HOVER="LAUNCHER_HOVER",t.TARGET_CLICK="TARGET_CLICK",t.TARGET_HOVER="TARGET_HOVER",t.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",t.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",t))(be||{}),W=(t=>(t.ACTIVATE="ACTIVATE",t.DEACTIVATE="DEACTIVATE",t.NEVER="NEVER",t))(W||{}),De=(t=>(t.AUTO="AUTO",t.TOP="TOP",t.RIGHT="RIGHT",t.BOTTOM="BOTTOM",t.LEFT="LEFT",t))(De||{}),ye=(t=>(t.START="START",t.CENTER="CENTER",t.END="END",t))(ye||{}),Me=(t=>(t.PERCENT="PERCENT",t.PX="PX",t))(Me||{}),Pe=(t=>(t.BEACON="BEACON",t.BUTTON="BUTTON",t.HIDDEN="HIDDEN",t.ICON="ICON",t))(Pe||{}),Be=(t=>(t.LAUNCHER="LAUNCHER",t.TARGET="TARGET",t))(Be||{}),xe=(t=>(t.BODY_FIRST="BODY_FIRST",t.BODY_LAST="BODY_LAST",t.ELEMENT_FIRST="ELEMENT_FIRST",t.ELEMENT_LAST="ELEMENT_LAST",t.ELEMENT_BEFORE="ELEMENT_BEFORE",t.ELEMENT_AFTER="ELEMENT_AFTER",t))(xe||{}),He=(t=>(t.BODY_FIRST="BODY_FIRST",t.BODY_LAST="BODY_LAST",t.ELEMENT_FIRST="ELEMENT_FIRST",t.ELEMENT_LAST="ELEMENT_LAST",t.ELEMENT_BEFORE="ELEMENT_BEFORE",t.ELEMENT_AFTER="ELEMENT_AFTER",t))(He||{}),Ge=(t=>(t.ALWAYS="ALWAYS",t.MULTIPLE="MULTIPLE",t.NEVER="NEVER",t.ONCE="ONCE",t.ONCE_PER_GROUP="ONCE_PER_GROUP",t))(Ge||{}),We=(t=>(t.NONE="NONE",t.PENDING_SCHEDULE="PENDING_SCHEDULE",t.SCHEDULED="SCHEDULED",t.FIRED="FIRED",t))(We||{}),Ve=(t=>(t.NONE="NONE",t.LIKE="LIKE",t.SCALE="SCALE",t))(Ve||{}),Ke=(t=>(t.HIDE="HIDE",t.BLOCK="BLOCK",t.OTHERS="OTHERS",t))(Ke||{});function $e(){return{customInputs:[],customNavigate:null,urlFilter:null,linkUrlDecorator:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[t=>!t.match(/\d$/)],"data-id":[t=>!t.match(/\d$/)]},inferenceClassNameFilters:[t=>!t.startsWith("css-")],baseZIndex:1234500,evalJsDisabled:!1}}const d=$e();function b(t){return Array.isArray(t)||(t=t?[t]:[]),t=t.map(e=>typeof e=="string"?new RegExp(e):e),t}function nt(t,e){return t.every(s=>typeof s=="function"?s(e):s instanceof RegExp?s.test(e):!0)}function Fe(){let t=x();if(d.urlFilter){if(t=d.urlFilter(t),typeof t!="string")throw new l("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(t)}catch(e){throw new l(`Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.
3
3
  Returned URL: `+t+`
4
- Error message: `+e.message)}}return t}let V="";try{V=localStorage.getItem("debug")||""}catch{}const $=V.split(",").some(t=>t==="*"||t.startsWith("userflow:*")),o=R("log");o.group=R("group");o.groupCollapsed=R("groupCollapsed");o.groupEnd=function(){$&&console.groupEnd()};let p;function R(t){return function(e,...s){if($){const i=performance.now(),n=p?Math.round(i-p):0;p=i,console[t](`%cuserflow %c${e} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const je=()=>g(()=>import("./ResourceCenterApp.js").then(t=>t.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]));function Ye(t){const s=t.version.checklist.tasks.length;return Math.max(0,s-t.taskCompletions.length)}class D{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const s of this.observers)s()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const y=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],ze=()=>g(()=>import("./BannerApp.js"),__vite__mapDeps([26,1,2,3,4,5,6,7,16,13,14,15,10,11,12,9,8,18,19,17,24,20,27,28])),L="1012092",Je=import.meta.url,M=50,Qe=5*60*1e3,P="userflowClientState";class Xe{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.embedSessions=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.debuggerUI=null,this.debuggerMountInProgress=!1,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.implicitTrackingQueue=[],this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{o(`builder ${e.kind} message received`,e);const s="idempotencyKey"in e&&typeof e.idempotencyKey=="string"?e.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const i=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(e.kind){case"userflow:selectElement":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),f.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),e.testStartCondition?this.setSessionStorageState(n=>({...n,activeApp:"startConditionTesting",testStartConditionToken:e.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const n=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",n))};this.on("resourceCenterChanged",n),n()}});return}case"userflow:testTracker":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0})),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),this.setSessionStorageState(n=>({...n,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),M))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+L),Q(this.onUrlChange),this.setTargetEnv(new Z),this.checkTestUserAtBoot(),this.toggleUI(),this.checkDebuggerSession();for(const e of y)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),G(this.onUrlChange),this.destroyTargetEnv();for(const e of y)document.removeEventListener(e,this.remountIfNecessary)}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new u("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const s=e(this.getSessionStorageState());f.setItem(P,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=f.getItem(P);if(s)try{e=JSON.parse(s)}catch(i){console.error("Userflow.js: Parse ElementSelectionState error:",i)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState(n=>({...n,testUser:e})),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const s=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:i}=e;i&&(this.groupId=i.id,s.push(this.group(i.id,{name:i.name},{signature:i.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(e=>({...e,testUser:null}))}init(e){if(o("init",e),!e)throw new u("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==e){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=e,this.emit("private:initialised")}}ensureInit(){if(!this.clientToken)throw new u("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new u("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new u("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");let e=d.serverEndpoint||"e.userflow.com";new URL(Je).hostname==="js.getuserflow.com"&&e==="e.userflow.com"&&(e="e.getuserflow.com");const s="wss://"+e+"/end-users/"+this.clientToken+"/socket";this.socket=new j(s,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected"),this.flushImplicitTrackingQueue(),this.featureFlagEnabled("cff_implicit_events")===!0&&this.startImplicitTracking()}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
4
+ Error message: `+e.message)}}return t}let V="";try{V=localStorage.getItem("debug")||""}catch{}const K=V.split(",").some(t=>t==="*"||t.startsWith("userflow:*")),o=R("log");o.group=R("group");o.groupCollapsed=R("groupCollapsed");o.groupEnd=function(){K&&console.groupEnd()};let p;function R(t){return function(e,...s){if(K){const i=performance.now(),n=p?Math.round(i-p):0;p=i,console[t](`%cuserflow %c${e} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const je=()=>g(()=>import("./ResourceCenterApp.js").then(t=>t.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]));function Ye(t){const s=t.version.checklist.tasks.length;return Math.max(0,s-t.taskCompletions.length)}class D{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const s of this.observers)s()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const y=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],ze=()=>g(()=>import("./BannerApp.js"),__vite__mapDeps([26,1,2,3,4,5,6,7,16,13,14,15,10,11,12,9,8,18,19,17,24,20,27,28])),L="1012167",Je=import.meta.url,M=50,Qe=5*60*1e3,P="userflowClientState";class Xe{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.embedSessions=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.debuggerUI=null,this.debuggerMountInProgress=!1,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.implicitTrackingQueue=[],this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{o(`builder ${e.kind} message received`,e);const s="idempotencyKey"in e&&typeof e.idempotencyKey=="string"?e.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const i=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(e.kind){case"userflow:selectElement":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),f.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),e.testStartCondition?this.setSessionStorageState(n=>({...n,activeApp:"startConditionTesting",testStartConditionToken:e.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const n=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",n))};this.on("resourceCenterChanged",n),n()}});return}case"userflow:testTracker":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0})),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),this.setSessionStorageState(n=>({...n,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),M))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+L),Q(this.onUrlChange),this.setTargetEnv(new Z),this.checkTestUserAtBoot(),this.toggleUI(),this.checkDebuggerSession();for(const e of y)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),G(this.onUrlChange),this.destroyTargetEnv();for(const e of y)document.removeEventListener(e,this.remountIfNecessary)}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new l("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const s=e(this.getSessionStorageState());f.setItem(P,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=f.getItem(P);if(s)try{e=JSON.parse(s)}catch(i){console.error("Userflow.js: Parse ElementSelectionState error:",i)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState(n=>({...n,testUser:e})),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const s=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:i}=e;i&&(this.groupId=i.id,s.push(this.group(i.id,{name:i.name},{signature:i.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(e=>({...e,testUser:null}))}init(e){if(o("init",e),!e)throw new l("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==e){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=e,this.emit("private:initialised")}}ensureInit(){if(!this.clientToken)throw new l("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new l("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new l("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");let e=d.serverEndpoint||"e.userflow.com";new URL(Je).hostname==="js.getuserflow.com"&&e==="e.userflow.com"&&(e="e.getuserflow.com");const s="wss://"+e+"/end-users/"+this.clientToken+"/socket";this.socket=new j(s,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected"),this.flushImplicitTrackingQueue(),this.featureFlagEnabled("cff_implicit_events")===!0&&this.startImplicitTracking()}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
5
5
  Details:
6
6
  `+i.details.map(n=>(n.path?`${n.path}: `:"")+n.message):""))}),this.channel.onClose(()=>{this.flushImplicitTrackingQueue(),this.implicitTracking?.stop()})}async startImplicitTracking(){await g(()=>import("./implicit-tracking.js"),__vite__mapDeps([29,12,2,28,27])).then(e=>this.implicitTracking=new e.ImplicitTracking(this)).catch(e=>o(`Implicit tracking failed to load ${e}`)),this.implicitTracking.start()}flushImplicitTrackingQueue(){this.featureFlagEnabled("cff_implicit_events")===!0&&this.implicitTrackingQueue.forEach(e=>{this.trackRawEvent({name:"page_viewed",attributes:e})}),this.implicitTrackingQueue=[]}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const s={protocolVersion:2,userflowClientBuild:L,signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,bannerSessionId:this.bannerSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map(i=>({flowId:i.flow.id})),trackers:Array.from(this.trackers.values()).map(i=>({flowId:i.tracker.flowId})),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map(i=>({conditionId:i.condition.id,isTrue:i.isTrue})),previewFlowId:f.getItem("previewFlowId"),clientContext:e};return o("channel join payload",s),s}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout(()=>{if(this.hasDraftSession()||this.assistantMessageInProgress){this.debounceInactiveDisconnect();return}o("disconnecting from socket due to inactivity"),this.disconnect()},Qe)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some(e=>e.draftMode)}async send(e,{batch:s,endBatch:i,handlesRejection:n}={}){return(!this.inBatch||!["ToggleClientCondition","UpdateClientContext"].includes(e.kind))&&this.checkPushRateLimit(),this.ensureConnected(),s&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),i?this.endBatch():this.endBatchTimeout=window.setTimeout(()=>{this.endBatch()},M)),this.sendRaw(e,{handlesRejection:n})}async sendRaw(e,{handlesRejection:s}={}){return new Promise((i,n)=>{if(!this.channel){const c=`Userflow.js: send() should not be called if channel is not set. Message kind=${e.kind}`;if(s)throw Error(c);console.log(c,`
7
- Client message:`,e);return}o(`push ${e.kind} message`,e);const r=this.clientClock,a=()=>{this.serverClock=r,this.channel?.off("phx_error",h)},h=this.channel.on("phx_error",c=>{a();const l=`Userflow.js send ${e.kind} got phx_error`;this._socketStatus==="connected"&&console.log(l,`
7
+ Client message:`,e);return}o(`push ${e.kind} message`,e);const r=this.clientClock,a=()=>{this.serverClock=r,this.channel?.off("phx_error",h)},h=this.channel.on("phx_error",c=>{a();const u=`Userflow.js send ${e.kind} got phx_error`;this._socketStatus==="connected"&&console.log(u,`
8
8
  Client message:`,e,`
9
- Error:`,c),s&&n(new u(l))});this.channel.push("client_message",e).receive("ok",c=>{a(),i(c)}).receive("error",c=>{a();const l=`Userflow.js error reply (${c.code}): ${c.message}`;console.log(l,`
9
+ Error:`,c),s&&n(new l(u))});this.channel.push("client_message",e).receive("ok",c=>{a(),i(c)}).receive("error",c=>{a();const u=`Userflow.js error reply (${c.code}): ${c.message}`;console.log(u,`
10
10
  Client message:`,e,`
11
- Error:`,c),s&&n(new u(l,c.code,c.message))})})}endBatch(){this.inBatch=!1,this.sendRaw({kind:"EndBatch"})}checkPushRateLimit(){const e=this.featureFlagEnabled("cff_implicit_events")===!0?200:100,s=Date.now();if(this.pushRateLimitMinuteExpires<s&&(this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=s+60*1e3),this.pushRateLimitMinute>=e)throw new u(`This Userflow.js client has reached a maximum of ${e} operations in the last 1 minute. This is usually due to one of the following:
11
+ Error:`,c),s&&n(new l(u,c.code,c.message))})})}endBatch(){this.inBatch=!1,this.sendRaw({kind:"EndBatch"})}checkPushRateLimit(){const e=this.featureFlagEnabled("cff_implicit_events")===!0?200:100,s=Date.now();if(this.pushRateLimitMinuteExpires<s&&(this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=s+60*1e3),this.pushRateLimitMinute>=e)throw new l(`This Userflow.js client has reached a maximum of ${e} operations in the last 1 minute. This is usually due to one of the following:
12
12
 
13
13
  - Excessive calls to Userflow.js. Check if any of userflow.track(), userflow.identify(), userflow.updateUser() or similar are called repeatedly.
14
14
  - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.
15
15
  - The user legitimately being very active, in which case you can just ignore this error.
16
16
 
17
- If in doubt, reach out to us at support@userflow.com.`);this.pushRateLimitMinute++}handleServerMessage(e){o(`received ${e.kind} message`,e);const{serverClock:s,flowSession:i,flowSessionClock:n,checklistSession:r,checklistSessionClock:a,bannerSession:h,resourceCenterSession:c}=this;switch(e.kind){case"CheckSessionsAck":this.emit("private:checkSessionsAck");return;case"ServerDebug":return;case"AddLauncher":{const{session:l}=e,T=this.launcherSessions.findIndex(E=>E.flow.id===l.flow.id);T===-1?this.launcherSessions=[...this.launcherSessions,l]:this.launcherSessions=[...this.launcherSessions.slice(0,T),l,...this.launcherSessions.slice(T+1)],this.toggleUI();return}case"AddTracker":{this.addTracker(e.tracker);return}case"AssistantMessageEventWrapper":{this.emit("private:assistantMessageEvent",e);return}case"CancelConditionWaitTimer":window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),this.conditionWaitTimers.delete(e.conditionId);return;case"ChecklistTaskCompleted":this.unackedTasks.add(e.taskCvid);return;case"ForceGoToStep":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&this.emit("gotostep",{session:i,step:{id:e.stepId}});return;case"RemoveLauncher":this.removeLauncher(e.flowId)&&this.toggleUI();return;case"RemoveTracker":{this.removeTracker(e.flowId);return}case"SetBannerSession":this.setBannerSession(e.session),this.toggleUI();return;case"SetChecklistSession":a<=s||r?.id===e.session.id?(this.setChecklistSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return;case"SetFlowSession":n<=s||i?.id===e.session.id?(this.setFlowSession(e.session,s),this.emit("private:setFlowSession",e.session.version.id),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return;case"SetResourceCenterSession":this.setResourceCenterSession(e.session),this.toggleUI();return;case"StartConditionWaitTimer":{if(!this.conditionWaitTimers.has(e.conditionId)){const l=window.setTimeout(()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})},parseFloat(e.waitTime)*1e3);this.conditionWaitTimers.set(e.conditionId,l)}return}case"TestStartConditionSuccess":this.emit("private:testStartConditionSuccess");return;case"TrackClientCondition":this.trackClientCondition(e.condition);return;case"UnsetBannerSession":h?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI());return;case"UnsetChecklistSession":if(a>s){o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return}r?.id===e.sessionId&&(this.setChecklistSession(null,s),this.toggleUI());return;case"UnsetFlowSession":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&(this.setFlowSession(null,s),this.toggleUI());return;case"UnsetResourceCenterSession":c?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI());return;case"UntrackClientCondition":this.untrackClientCondition(e.conditionId);return;case"AddEmbed":{const l=this.embedSessions?.findIndex(T=>T.flow.id===e.session.flow.id);l!==void 0&&l>=0?this.embedSessions=[...this.embedSessions?.slice(0,l)||[],e.session,...this.embedSessions?.slice(l+1)||[]]:this.embedSessions=[...this.embedSessions||[],e.session],this.emit("uistatechange");break}case"RemoveEmbed":{this.embedSessions=(this.embedSessions||[]).filter(l=>l.flow.id!==e.flowId),this.emit("uistatechange");break}default:console.warn("Userflow.js: Received unknown message",e);return}}async identify(e,s={},{signature:i}={}){if(o("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId){o("identify() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new u(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(o("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=i||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(s)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}async identifyAnonymous(e={},s={}){if(!I.isSupported())throw new u("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const i="anonymousId";let n=I.getItem(i);n||(n="anon-"+U(),I.setItem(i,n)),await this.identify(n,e,s)}getInitToken(){return this.clientToken}getIdentifiedUser(){return{externalId:this.externalId}}async updateUser(e={},s={}){o("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,s={},{signature:i,membership:n}={}){if(o("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId){o("group() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new u(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=i||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(s),membershipAttributes:this.normalizeAttributes(n)},{batch:!0})}async updateGroup(e={},s={}){o("updateGroup");const i=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:i,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(s.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(e==null)return{};if(typeof e!="object")throw new u("Userflow: 'attributes' must be an object.");const s={};for(const i in e){if(!e.hasOwnProperty(i))continue;if(i==="traits"){const r=e[i];Object.assign(s,this.extractLegacyTraits(r));continue}let n=e[i];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n==null||Array.isArray(n))s[i]=this.normalizeAttributeLiteralOrList(i,n);else{if(typeof n!="object"||n==null)throw new u(`Userflow: Invalid value for '${i}' attribute.`);if("set"in n)s[i]={set:this.normalizeAttributeLiteralOrList(i,n.set),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("set_once"in n||"setOnce"in n)s[i]={setOnce:this.normalizeAttributeLiteralOrList(i,n.set_once??n.setOnce),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("add"in n){const r=n.add;if(typeof r!="string"&&typeof r!="number")throw new u(`Userflow: Invalid 'add' value for '${i}' attribute. Must be a number or string.`);s[i]={add:r}}else if("subtract"in n){const r=n.subtract;if(typeof r!="string"&&typeof r!="number")throw new u(`Userflow: Invalid 'subtract' value for '${i}' attribute. Must be a number or string.`);s[i]={subtract:r}}else if("append"in n)s[i]={append:this.normalizeAttributeLiteralOrList(i,n.append)};else if("prepend"in n)s[i]={prepend:this.normalizeAttributeLiteralOrList(i,n.prepend)};else if("remove"in n)s[i]={remove:this.normalizeAttributeLiteralOrList(i,n.remove)};else throw new u(`Userflow: Invalid value for '${i}' attribute.`)}}return s}normalizeAttributeLiteralOrList(e,s){return Array.isArray(s)?s.map(i=>this.normalizeAttributeLiteral(e,i)):this.normalizeAttributeLiteral(e,s)}normalizeAttributeLiteral(e,s){if(s==null)return null;if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;throw new u(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,s){if(!s)return null;switch(s){case"string":return S.STRING;case"number":return S.NUMBER;case"boolean":return S.BOOLEAN;case"datetime":return S.DATETIME}throw new u(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const s=[];for(const i in e)e.hasOwnProperty(i)&&s.push({name:i,value:e[i]});e=s}return e.reduce((s,{name:i,value:n,dataType:r})=>{if(typeof i!="string"||i.length>100||!i.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",i),s;if(typeof n!="string")if(typeof n=="boolean")r||(r="boolean"),n=n?"true":"false";else if(typeof n=="number")r||(r=Number.isInteger(n)?"integer":"decimal"),n=String(n);else return this.warn(`userflow.identify: The value of trait '${i}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,n),s;let a=null;if(r)switch(r){case"string":a=S.STRING;break;case"boolean":a=S.BOOLEAN;break;case"integer":a=S.NUMBER;break;case"decimal":a=S.NUMBER;break;case"datetime":a=S.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${i}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,r),s}return s[i]={set:n,dataType:a},s},{})}async track(e,s={},{userOnly:i}={}){o(`track '${e}'`,s),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!i,name:e,attributes:this.normalizeEventAttributes(s)},{batch:!0})}async trackRawEvent(e){const{name:s,attributes:i}=e;o(`track raw event '${s}'`,i),this.ensureIdentified(),await this.send({kind:"TrackRawEvent",name:s,attributes:this.normalizeEventAttributes(i)},{batch:!0})}normalizeEventAttributes(e){const s=this.normalizeAttributes(e);for(const i in s){if(!s.hasOwnProperty(i))continue;const n=s[i];if(!(n==null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||Array.isArray(n)||"set"in n))throw new u(`Userflow: Invalid value for '${i}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return s}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout(()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()},0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(x()),s=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");s&&(o(`url contained flow ${s}`),this.startFlow({flowId:s,startReason:m.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();(!this.clientContext||e.pageUrl!==this.clientContext.pageUrl)&&(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{}),typeof this.featureFlags>"u"&&this.implicitTrackingQueue.push({id:U(),page_title:document.title,...this.buildClientContext()}),this.featureFlagEnabled("cff_implicit_events")===!0&&this.trackRawEvent({name:"page_viewed",attributes:{id:U(),page_title:document.title}})}buildClientContext(){return{pageUrl:Fe(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return this.externalId!=null}on(e,s){let i=this.listeners.get(e);i||(i=new Set,this.listeners.set(e,i)),i.add(s)}off(e,s){const i=this.listeners.get(e);i&&i.delete(s)}emit(e,...s){const i=this.listeners.get(e);i&&Array.from(i).forEach(r=>r(...s))}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){o("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setBannerSession(null),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach((e,s)=>{this.untrackClientCondition(s)}),this.firstIdentifyCallback=null,this.testUserIdentified=!1,I.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1,this.titleMonitored=void 0,this.titleObserver&&(this.titleObserver.disconnect(),this.titleObserver=void 0),this.flushImplicitTrackingQueue()}async startFlow({flowId:e,stepCvid:s,startReason:i,once:n,batch:r,replaceCurrent:a}){if(this.ensureIdentified(),a&&this.flowSession&&this.endFlow(this.flowSession,{endReason:C.REPLACED,batch:!0}),o(`startFlow ${e}`,{startReason:i}),this.checklistSession?.flow.id===e){o("startFlow matches current checklist, so showing it instead"),this.showChecklist();return}const h={kind:"StartFlow",flowId:e,stepCvid:s,startReason:i,once:!!n};await this.send(h,{batch:r})}async startFlowWithToken(e){this.ensureIdentified(),o("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){if(this.resourceCenterEmbedsChecklist()){this.openResourceCenter();return}this.unmarkExpandPending(),!(!this.checklistSession||this.checklistExpanded)&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),f.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async hideChecklist(){if(this.resourceCenterEmbedsChecklist()){this.closeResourceCenter();return}!this.checklistSession||!this.checklistExpanded||(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),f.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){!this.checklistSession||!this.checklistExpandPending||(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),!(!this.resourceCenterSession||this.resourceCenterOpen)&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),f.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){!this.resourceCenterSession||!this.resourceCenterOpen||(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),f.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:s}=this,i=this.resourceCenterSession.version.resourceCenter?.blocks.find(n=>n.type===_.ANNOUNCEMENTS);return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&s?Ye(s):0,unreadAnnouncementCount:i?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some(s=>s.type===_.CHECKLIST)}async endFlow(e,{endReason:s,batch:i}){this.ensureIdentified(),this.optimisticClockUIUpdate(()=>{const{clientClock:h}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,h),this.checklistSession?.id===e.id&&this.setChecklistSession(null,h),this.bannerSession?.id===e.id&&this.setBannerSession(null),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)});const{flow:n}=e,r={id:n.id,type:n.type.toLowerCase()};n.type===k.CHECKLIST?this.emit("checklistEnded",{checklist:r,endReason:s}):n.type===k.FLOW&&this.emit("flowEnded",{flow:r,endReason:s});const a={kind:"EndFlow",sessionId:e.id,endReason:s};await this.send(a,{batch:i})}async goToStep(e,s){o("goToStep",e.id,s.name||s.id),this.ensureIdentified();const i=this.send({kind:"GoToStep",sessionId:e.id,stepId:s.id});e.currentStep=s,this.emit("gotostep",{session:e,step:s}),await i}async endAllFlows(){o("endAllFlows"),this.optimisticClockUIUpdate(()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)}),await this.send({kind:"EndAllFlows"})}async endChecklist(){o("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===k.CHECKLIST&&this.endFlow(e,{endReason:C.USERFLOWJS})}setFlowSession(e,s=this.clientClock){const i=this.flowSession;this.flowSession=e,this.flowSessionClock=s,e&&!i&&(this.hideChecklist(),this.closeResourceCenter()),e==null&&this.originalActiveElement&&(typeof this.originalActiveElement.focus=="function"&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,s=this.clientClock){const i=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=s,e===null&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==i?.id&&(this.checklistExpanded=!!f.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setBannerSession(e){this.bannerSession=e}setResourceCenterSession(e){const s=this.resourceCenterSession;e=typeof e=="function"?e(this.resourceCenterSession):e,this.resourceCenterSession=e,e===null&&(this.resourceCenterOpen=!1),s&&s.id!==e?.id&&f.removeItem(`resourceCenterOpen:${s.id}`),e&&e.id!==s?.id&&(this.resourceCenterOpen=!!f.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:m.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const s=this.activeLauncherFlowId&&this.launcherSessions.find(i=>i.flow.id===this.activeLauncherFlowId);s&&this.deactivateLauncher(s),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:s}=e.version;e.flow.id===this.activeLauncherFlowId&&(s?.dismissOn===W.DEACTIVATE?this.dismissLauncher(e,{endReason:C.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:s}){const i=e.flow.id;this.removeLauncher(i),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:i,endReason:s})}removeLauncher(e){const s=this.launcherSessions.findIndex(i=>i.flow.id===e);return s===-1?!1:(this.launcherSessions=[...this.launcherSessions.slice(0,s),...this.launcherSessions.slice(s+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const e=this.getSessionStorageState();!this.flowSession&&(this.checklistExpandPending||this.checklistSession?.version.checklist?.tasks.some(s=>this.taskIsUnacked(s.cvid)))&&this.showChecklist(),e.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){return this.uiDisabled?!1:!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.bannerSession||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(o("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(o("unmount UI"),this.ui.unmount(),this.ui=null)}checkDebuggerSession(){if(this.debuggerUI)return;const e=this.sessionStorageState?.debuggerApp;e&&e?.x&&e?.y&&this.mountDebugger()}async mountDebugger(){if(!this.debuggerMountInProgress){if(this.debuggerUI){this.debuggerUI.unmount();return}this.debuggerMountInProgress=!0;try{const{DebuggerUI:e}=await g(async()=>{const{DebuggerUI:s}=await import("./DebuggerUI.js");return{DebuggerUI:s}},__vite__mapDeps([30,1,2,3,18,19,4,5,6,7,17,13,14,15,10,11,12,21,16,31,32,33,34,35,27,28]));this.debuggerUI=new e(this,L),this.debuggerUI.mount()}catch(e){console.error("Userflow: Failed to mount debugger UI",e)}finally{this.debuggerMountInProgress=!1}}}unMountDebugger(){this.debuggerUI=null}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=g(()=>import("./ui.js"),__vite__mapDeps([36,1,2,3,18,19,4,5,6,7,27,28]));this.bannerSession&&ze(),this.resourceCenterSession&&je();const{RealUI:s}=await e;return new s(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;o("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:s}=await g(async()=>{const{conditionTypes:r}=await import("./flow-condition-types.js").then(a=>a.f);return{conditionTypes:r}},__vite__mapDeps([10,2,11,6,12])),i=s[e.type],n=this.clientConditions.get(e.id);n&&(n.untrack=i.track({sessionData:new D([]),condition:e,callback:r=>{n.isTrue!==r&&(o("client condition truthiness changed",r,n.condition),n.isTrue=r,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:r},{batch:!0}))}}))}untrackClientCondition(e){const s=this.clientConditions.get(e);s&&(o("untrack client condition",s.condition),s.untrack&&s.untrack(),this.clientConditions.delete(e))}async addTracker(e){let s=this.trackers.get(e.flowId);s?s.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:i}=await g(async()=>{const{conditionTypes:c}=await import("./flow-condition-types.js").then(l=>l.f);return{conditionTypes:c}},__vite__mapDeps([10,2,11,6,12])),n=this.trackers.get(e.flowId);if(!n)return;const{tracker:r}=n,{condition:a}=r,h=i[a.type];n.untrack&&n.untrack(),n.untrack=h.track({sessionData:new D(r.data),condition:a,flipBackEvents:!0,callback:c=>{const l=n.isTrue;n.isTrue=c,!l&&c&&this.send({kind:"TrackTrackerEvent",token:r.token},{batch:!0})},description:`event tracker ${r.flowId}`}),this.emit("private:trackerStarted")}removeTracker(e){const s=this.trackers.get(e);s&&(s.untrack&&s.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const e=document.querySelector("title");if(e){const s=new MutationObserver(()=>{this.fixTitle()});s.observe(e,{childList:!0}),this.titleObserver=s}}fixTitle(){const e=document.title,i="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==i&&(document.title=i)}reportCspIssue(){const e=this.getSessionStorageState();(this.testUserIdentified||e.activeApp)&&!this.cspIssueReported&&(this.cspIssueReported=!0,o("csp issue detected"),N({kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const s=this.getAudio();e&&(s.src=e);const i=s.play();this.audioReady=!0,i&&i.catch(n=>{n.name})}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,s){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:s})).url}featureFlagEnabled(e){return this.featureFlags?this.featureFlags.has(e):!1}showNotification(e,s,i){const r={id:++this.notificationIdCounter,label:e,message:s,type:i};this.notifications=[...this.notifications,r],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter(s=>s.id!==e),this.toggleUI()}warn(...e){console.warn(...e)}nextRef(){return this.refCounter++}}if(typeof window.userflow>"u"||window.userflow._stubbed){const t=Object.assign(window.userflow||{},Ze());window.userflow=t,window.studio1=t,qe()}function Ze(){const t=new Xe;return{_stubbed:!1,init(e){t.init(e)},identify(e,s={},i={}){return t.identify(e,s,i)},identifyAnonymous(e={},s={}){return t.identifyAnonymous(e,s)},isIdentified(){return t.isIdentified()},updateUser(e,s={}){return t.updateUser(e,s)},group(e,s={},i={}){return t.group(e,s,i)},updateGroup(e,s={}){return t.updateGroup(e,s)},track(e,s={},i={}){return t.track(e,s,i)},start(e,{once:s}={}){return t.startFlow({flowId:e,startReason:m.USERFLOWJS,once:s})},startFlow(e){return console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},startWalk(e){return console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},endAll(){return t.endAllFlows()},endChecklist(){return t.endChecklist()},endAllFlows(){"Userflow.js: userflow.endAllFlows() has been deprecated. Use userflow.endAll() instead.";return window.userflow.endAll()},async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){t.openResourceCenter()},closeResourceCenter(){t.closeResourceCenter()},toggleResourceCenter(){t.toggleResourceCenter()},setResourceCenterLauncherHidden(e){t.setResourceCenterLauncherHidden(e)},getResourceCenterState(){return t.getResourceCenterState()},setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){t.reset()},remount(){t.remount()},on(e,s){t.on(e,s)},off(e,s){t.off(e,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&d.customInputs.push({cssSelector:e})},registerCustomInput(e,s){d.customInputs.push({cssSelector:e,getValue:s})},setCustomNavigate(e){d.customNavigate=e},setUrlFilter(e){d.urlFilter=e},setLinkUrlDecorator(e){d.linkUrlDecorator=e,t.emit("uistatechange")},setInferenceAttributeNames(e){d.inferenceAttributeNames=e},setInferenceAttributeFilter(e,s){d.inferenceAttributeFilters[e]=b(s)},setInferenceClassNameFilter(e){d.inferenceClassNameFilters=b(e)},setScrollPadding(e){d.scrollPadding=e},setCustomScrollIntoView(e){d.customScrollIntoView=e},prepareAudio(){t.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(e){t.pageTrackingDisabled=e},setBaseZIndex(e){d.baseZIndex=e},setServerEndpoint(e){d.serverEndpoint=e},disableEvalJs(){d.evalJsDisabled=!0},_setTargetEnv(e){t.setTargetEnv(e)},debugger(){return t.mountDebugger()}}}function qe(){const t=window.userflow,e=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!(!e||e.length===0)){o(`processing ${e.length} items in the queue`);for(const[s,i,n]of e){if(typeof t[s]!="function"){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const r=t[s](...n);i&&r&&typeof r.then=="function"&&r.then(i.resolve,i.reject)}o("queue processed")}}var rt=window.userflow;export{he as $,S as A,ze as B,Ae as C,Ee as D,C as E,se as F,I as G,_e as H,ue as I,de as J,He as K,Pe as L,Se as M,be as N,De as O,Te as P,Be as Q,je as R,oe as S,Ce as T,u as U,ke as V,We as W,ye as X,Me as Y,Ue as Z,g as _,k as a,it as a0,x as a1,Le as a2,Ne as a3,fe as a4,Fe as a5,Q as a6,G as a7,re as a8,nt as a9,y as aa,Ve as ab,ee as ac,ce as b,ae as c,o as d,rt as default,q as e,ne as f,Ge as g,te as h,le as i,D as j,_ as k,d as l,Ye as m,we as n,Ie as o,Oe as p,me as q,pe as r,Re as s,m as t,f as u,$e as v,ve as w,xe as x,ie as y,ge as z};
17
+ If in doubt, reach out to us at support@userflow.com.`);this.pushRateLimitMinute++}handleServerMessage(e){o(`received ${e.kind} message`,e);const{serverClock:s,flowSession:i,flowSessionClock:n,checklistSession:r,checklistSessionClock:a,bannerSession:h,resourceCenterSession:c}=this;switch(e.kind){case"CheckSessionsAck":this.emit("private:checkSessionsAck");return;case"ServerDebug":return;case"AddLauncher":{const{session:u}=e,T=this.launcherSessions.findIndex(E=>E.flow.id===u.flow.id);T===-1?this.launcherSessions=[...this.launcherSessions,u]:this.launcherSessions=[...this.launcherSessions.slice(0,T),u,...this.launcherSessions.slice(T+1)],this.toggleUI();return}case"AddTracker":{this.addTracker(e.tracker);return}case"AssistantMessageEventWrapper":{this.emit("private:assistantMessageEvent",e);return}case"CancelConditionWaitTimer":window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),this.conditionWaitTimers.delete(e.conditionId);return;case"ChecklistTaskCompleted":this.unackedTasks.add(e.taskCvid);return;case"ForceGoToStep":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&this.emit("gotostep",{session:i,step:{id:e.stepId}});return;case"RemoveLauncher":this.removeLauncher(e.flowId)&&this.toggleUI();return;case"RemoveTracker":{this.removeTracker(e.flowId);return}case"SetBannerSession":this.setBannerSession(e.session),this.toggleUI();return;case"SetChecklistSession":a<=s||r?.id===e.session.id?(this.setChecklistSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return;case"SetFlowSession":n<=s||i?.id===e.session.id?(this.setFlowSession(e.session,s),this.emit("private:setFlowSession",e.session.version.id),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return;case"SetResourceCenterSession":this.setResourceCenterSession(e.session),this.toggleUI();return;case"StartConditionWaitTimer":{if(!this.conditionWaitTimers.has(e.conditionId)){const u=window.setTimeout(()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})},parseFloat(e.waitTime)*1e3);this.conditionWaitTimers.set(e.conditionId,u)}return}case"TestStartConditionSuccess":this.emit("private:testStartConditionSuccess");return;case"TrackClientCondition":this.trackClientCondition(e.condition);return;case"UnsetBannerSession":h?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI());return;case"UnsetChecklistSession":if(a>s){o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return}r?.id===e.sessionId&&(this.setChecklistSession(null,s),this.toggleUI());return;case"UnsetFlowSession":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&(this.setFlowSession(null,s),this.toggleUI());return;case"UnsetResourceCenterSession":c?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI());return;case"UntrackClientCondition":this.untrackClientCondition(e.conditionId);return;case"AddEmbed":{const u=this.embedSessions?.findIndex(T=>T.flow.id===e.session.flow.id);u!==void 0&&u>=0?this.embedSessions=[...this.embedSessions?.slice(0,u)||[],e.session,...this.embedSessions?.slice(u+1)||[]]:this.embedSessions=[...this.embedSessions||[],e.session],this.emit("uistatechange");break}case"RemoveEmbed":{this.embedSessions=(this.embedSessions||[]).filter(u=>u.flow.id!==e.flowId),this.emit("uistatechange");break}default:console.warn("Userflow.js: Received unknown message",e);return}}async identify(e,s={},{signature:i}={}){if(o("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId){o("identify() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(o("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=i||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(s)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}async identifyAnonymous(e={},s={}){if(!I.isSupported())throw new l("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const i="anonymousId";let n=I.getItem(i);n||(n="anon-"+U(),I.setItem(i,n)),await this.identify(n,e,s)}getInitToken(){return this.clientToken}getIdentifiedUser(){return{externalId:this.externalId}}async updateUser(e={},s={}){o("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,s={},{signature:i,membership:n}={}){if(o("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId){o("group() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=i||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(s),membershipAttributes:this.normalizeAttributes(n)},{batch:!0})}async updateGroup(e={},s={}){o("updateGroup");const i=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:i,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(s.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(e==null)return{};if(typeof e!="object")throw new l("Userflow: 'attributes' must be an object.");const s={};for(const i in e){if(!e.hasOwnProperty(i))continue;if(i==="traits"){const r=e[i];Object.assign(s,this.extractLegacyTraits(r));continue}let n=e[i];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n==null||Array.isArray(n))s[i]=this.normalizeAttributeLiteralOrList(i,n);else{if(typeof n!="object"||n==null)throw new l(`Userflow: Invalid value for '${i}' attribute.`);if("set"in n)s[i]={set:this.normalizeAttributeLiteralOrList(i,n.set),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("set_once"in n||"setOnce"in n)s[i]={setOnce:this.normalizeAttributeLiteralOrList(i,n.set_once??n.setOnce),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("add"in n){const r=n.add;if(typeof r!="string"&&typeof r!="number")throw new l(`Userflow: Invalid 'add' value for '${i}' attribute. Must be a number or string.`);s[i]={add:r}}else if("subtract"in n){const r=n.subtract;if(typeof r!="string"&&typeof r!="number")throw new l(`Userflow: Invalid 'subtract' value for '${i}' attribute. Must be a number or string.`);s[i]={subtract:r}}else if("append"in n)s[i]={append:this.normalizeAttributeLiteralOrList(i,n.append)};else if("prepend"in n)s[i]={prepend:this.normalizeAttributeLiteralOrList(i,n.prepend)};else if("remove"in n)s[i]={remove:this.normalizeAttributeLiteralOrList(i,n.remove)};else throw new l(`Userflow: Invalid value for '${i}' attribute.`)}}return s}normalizeAttributeLiteralOrList(e,s){return Array.isArray(s)?s.map(i=>this.normalizeAttributeLiteral(e,i)):this.normalizeAttributeLiteral(e,s)}normalizeAttributeLiteral(e,s){if(s==null)return null;if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;throw new l(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,s){if(!s)return null;switch(s){case"string":return S.STRING;case"number":return S.NUMBER;case"boolean":return S.BOOLEAN;case"datetime":return S.DATETIME}throw new l(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const s=[];for(const i in e)e.hasOwnProperty(i)&&s.push({name:i,value:e[i]});e=s}return e.reduce((s,{name:i,value:n,dataType:r})=>{if(typeof i!="string"||i.length>100||!i.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",i),s;if(typeof n!="string")if(typeof n=="boolean")r||(r="boolean"),n=n?"true":"false";else if(typeof n=="number")r||(r=Number.isInteger(n)?"integer":"decimal"),n=String(n);else return this.warn(`userflow.identify: The value of trait '${i}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,n),s;let a=null;if(r)switch(r){case"string":a=S.STRING;break;case"boolean":a=S.BOOLEAN;break;case"integer":a=S.NUMBER;break;case"decimal":a=S.NUMBER;break;case"datetime":a=S.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${i}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,r),s}return s[i]={set:n,dataType:a},s},{})}async track(e,s={},{userOnly:i}={}){o(`track '${e}'`,s),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!i,name:e,attributes:this.normalizeEventAttributes(s)},{batch:!0})}async trackRawEvent(e){const{name:s,attributes:i}=e;o(`track raw event '${s}'`,i),this.ensureIdentified(),await this.send({kind:"TrackRawEvent",name:s,attributes:this.normalizeEventAttributes(i)},{batch:!0})}normalizeEventAttributes(e){const s=this.normalizeAttributes(e);for(const i in s){if(!s.hasOwnProperty(i))continue;const n=s[i];if(!(n==null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||Array.isArray(n)||"set"in n))throw new l(`Userflow: Invalid value for '${i}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return s}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout(()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()},0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(x()),s=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");s&&(o(`url contained flow ${s}`),this.startFlow({flowId:s,startReason:m.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();(!this.clientContext||e.pageUrl!==this.clientContext.pageUrl)&&(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{}),typeof this.featureFlags>"u"&&this.implicitTrackingQueue.push({id:U(),page_title:document.title,...this.buildClientContext()}),this.featureFlagEnabled("cff_implicit_events")===!0&&this.trackRawEvent({name:"page_viewed",attributes:{id:U(),page_title:document.title}})}buildClientContext(){return{pageUrl:Fe(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return this.externalId!=null}on(e,s){let i=this.listeners.get(e);i||(i=new Set,this.listeners.set(e,i)),i.add(s)}off(e,s){const i=this.listeners.get(e);i&&i.delete(s)}emit(e,...s){const i=this.listeners.get(e);i&&Array.from(i).forEach(r=>r(...s))}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){o("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setBannerSession(null),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach((e,s)=>{this.untrackClientCondition(s)}),this.firstIdentifyCallback=null,this.testUserIdentified=!1,I.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1,this.titleMonitored=void 0,this.titleObserver&&(this.titleObserver.disconnect(),this.titleObserver=void 0),this.flushImplicitTrackingQueue()}async startFlow({flowId:e,stepCvid:s,startReason:i,once:n,batch:r,replaceCurrent:a}){if(this.ensureIdentified(),a&&this.flowSession&&this.endFlow(this.flowSession,{endReason:C.REPLACED,batch:!0}),o(`startFlow ${e}`,{startReason:i}),this.checklistSession?.flow.id===e){o("startFlow matches current checklist, so showing it instead"),this.showChecklist();return}const h={kind:"StartFlow",flowId:e,stepCvid:s,startReason:i,once:!!n};await this.send(h,{batch:r})}async trackButtonEvent(e,s,i,n){const r={kind:"TrackButtonEvent",eventName:e,stepCvid:i,sessionId:n,token:s};await this.send(r,{batch:!0})}async startFlowWithToken(e){this.ensureIdentified(),o("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){if(this.resourceCenterEmbedsChecklist()){this.openResourceCenter();return}this.unmarkExpandPending(),!(!this.checklistSession||this.checklistExpanded)&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),f.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async hideChecklist(){if(this.resourceCenterEmbedsChecklist()){this.closeResourceCenter();return}!this.checklistSession||!this.checklistExpanded||(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),f.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){!this.checklistSession||!this.checklistExpandPending||(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),!(!this.resourceCenterSession||this.resourceCenterOpen)&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),f.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){!this.resourceCenterSession||!this.resourceCenterOpen||(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),f.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:s}=this,i=this.resourceCenterSession.version.resourceCenter?.blocks.find(n=>n.type===_.ANNOUNCEMENTS);return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&s?Ye(s):0,unreadAnnouncementCount:i?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some(s=>s.type===_.CHECKLIST)}async endFlow(e,{endReason:s,batch:i}){this.ensureIdentified(),this.optimisticClockUIUpdate(()=>{const{clientClock:h}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,h),this.checklistSession?.id===e.id&&this.setChecklistSession(null,h),this.bannerSession?.id===e.id&&this.setBannerSession(null),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)});const{flow:n}=e,r={id:n.id,type:n.type.toLowerCase()};n.type===k.CHECKLIST?this.emit("checklistEnded",{checklist:r,endReason:s}):n.type===k.FLOW&&this.emit("flowEnded",{flow:r,endReason:s});const a={kind:"EndFlow",sessionId:e.id,endReason:s};await this.send(a,{batch:i})}async goToStep(e,s){o("goToStep",e.id,s.name||s.id),this.ensureIdentified();const i=this.send({kind:"GoToStep",sessionId:e.id,stepId:s.id});e.currentStep=s,this.emit("gotostep",{session:e,step:s}),await i}async endAllFlows(){o("endAllFlows"),this.optimisticClockUIUpdate(()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)}),await this.send({kind:"EndAllFlows"})}async endChecklist(){o("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===k.CHECKLIST&&this.endFlow(e,{endReason:C.USERFLOWJS})}setFlowSession(e,s=this.clientClock){const i=this.flowSession;this.flowSession=e,this.flowSessionClock=s,e&&!i&&(this.hideChecklist(),this.closeResourceCenter()),e==null&&this.originalActiveElement&&(typeof this.originalActiveElement.focus=="function"&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,s=this.clientClock){const i=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=s,e===null&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==i?.id&&(this.checklistExpanded=!!f.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setBannerSession(e){this.bannerSession=e}setResourceCenterSession(e){const s=this.resourceCenterSession;e=typeof e=="function"?e(this.resourceCenterSession):e,this.resourceCenterSession=e,e===null&&(this.resourceCenterOpen=!1),s&&s.id!==e?.id&&f.removeItem(`resourceCenterOpen:${s.id}`),e&&e.id!==s?.id&&(this.resourceCenterOpen=!!f.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:m.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const s=this.activeLauncherFlowId&&this.launcherSessions.find(i=>i.flow.id===this.activeLauncherFlowId);s&&this.deactivateLauncher(s),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:s}=e.version;e.flow.id===this.activeLauncherFlowId&&(s?.dismissOn===W.DEACTIVATE?this.dismissLauncher(e,{endReason:C.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:s}){const i=e.flow.id;this.removeLauncher(i),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:i,endReason:s})}removeLauncher(e){const s=this.launcherSessions.findIndex(i=>i.flow.id===e);return s===-1?!1:(this.launcherSessions=[...this.launcherSessions.slice(0,s),...this.launcherSessions.slice(s+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const e=this.getSessionStorageState();!this.flowSession&&(this.checklistExpandPending||this.checklistSession?.version.checklist?.tasks.some(s=>this.taskIsUnacked(s.cvid)))&&this.showChecklist(),e.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){return this.uiDisabled?!1:!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.bannerSession||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(o("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(o("unmount UI"),this.ui.unmount(),this.ui=null)}checkDebuggerSession(){if(this.debuggerUI)return;const e=this.sessionStorageState?.debuggerApp;e&&e?.x&&e?.y&&this.mountDebugger()}async mountDebugger(){if(!this.debuggerMountInProgress){if(this.debuggerUI){this.debuggerUI.unmount();return}this.debuggerMountInProgress=!0;try{const{DebuggerUI:e}=await g(async()=>{const{DebuggerUI:s}=await import("./DebuggerUI.js");return{DebuggerUI:s}},__vite__mapDeps([30,1,2,3,18,19,4,5,6,7,17,13,14,15,10,11,12,21,16,31,32,33,34,35,27,28]));this.debuggerUI=new e(this,L),this.debuggerUI.mount()}catch(e){console.error("Userflow: Failed to mount debugger UI",e)}finally{this.debuggerMountInProgress=!1}}}unMountDebugger(){this.debuggerUI=null}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=g(()=>import("./ui.js"),__vite__mapDeps([36,1,2,3,18,19,4,5,6,7,27,28]));this.bannerSession&&ze(),this.resourceCenterSession&&je();const{RealUI:s}=await e;return new s(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;o("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:s}=await g(async()=>{const{conditionTypes:r}=await import("./flow-condition-types.js").then(a=>a.f);return{conditionTypes:r}},__vite__mapDeps([10,2,11,6,12])),i=s[e.type],n=this.clientConditions.get(e.id);n&&(n.untrack=i.track({sessionData:new D([]),condition:e,callback:r=>{n.isTrue!==r&&(o("client condition truthiness changed",r,n.condition),n.isTrue=r,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:r},{batch:!0}))}}))}untrackClientCondition(e){const s=this.clientConditions.get(e);s&&(o("untrack client condition",s.condition),s.untrack&&s.untrack(),this.clientConditions.delete(e))}async addTracker(e){let s=this.trackers.get(e.flowId);s?s.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:i}=await g(async()=>{const{conditionTypes:c}=await import("./flow-condition-types.js").then(u=>u.f);return{conditionTypes:c}},__vite__mapDeps([10,2,11,6,12])),n=this.trackers.get(e.flowId);if(!n)return;const{tracker:r}=n,{condition:a}=r,h=i[a.type];n.untrack&&n.untrack(),n.untrack=h.track({sessionData:new D(r.data),condition:a,flipBackEvents:!0,callback:c=>{const u=n.isTrue;n.isTrue=c,!u&&c&&this.send({kind:"TrackTrackerEvent",token:r.token},{batch:!0})},description:`event tracker ${r.flowId}`}),this.emit("private:trackerStarted")}removeTracker(e){const s=this.trackers.get(e);s&&(s.untrack&&s.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const e=document.querySelector("title");if(e){const s=new MutationObserver(()=>{this.fixTitle()});s.observe(e,{childList:!0}),this.titleObserver=s}}fixTitle(){const e=document.title,i="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==i&&(document.title=i)}reportCspIssue(){const e=this.getSessionStorageState();(this.testUserIdentified||e.activeApp)&&!this.cspIssueReported&&(this.cspIssueReported=!0,o("csp issue detected"),N({kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const s=this.getAudio();e&&(s.src=e);const i=s.play();this.audioReady=!0,i&&i.catch(n=>{n.name})}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,s){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:s})).url}featureFlagEnabled(e){return this.featureFlags?this.featureFlags.has(e):!1}showNotification(e,s,i){const r={id:++this.notificationIdCounter,label:e,message:s,type:i};this.notifications=[...this.notifications,r],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter(s=>s.id!==e),this.toggleUI()}warn(...e){console.warn(...e)}nextRef(){return this.refCounter++}}if(typeof window.userflow>"u"||window.userflow._stubbed){const t=Object.assign(window.userflow||{},Ze());window.userflow=t,window.studio1=t,qe()}function Ze(){const t=new Xe;return{_stubbed:!1,init(e){t.init(e)},identify(e,s={},i={}){return t.identify(e,s,i)},identifyAnonymous(e={},s={}){return t.identifyAnonymous(e,s)},isIdentified(){return t.isIdentified()},updateUser(e,s={}){return t.updateUser(e,s)},group(e,s={},i={}){return t.group(e,s,i)},updateGroup(e,s={}){return t.updateGroup(e,s)},track(e,s={},i={}){return t.track(e,s,i)},start(e,{once:s}={}){return t.startFlow({flowId:e,startReason:m.USERFLOWJS,once:s})},startFlow(e){return console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},startWalk(e){return console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},endAll(){return t.endAllFlows()},endChecklist(){return t.endChecklist()},endAllFlows(){"Userflow.js: userflow.endAllFlows() has been deprecated. Use userflow.endAll() instead.";return window.userflow.endAll()},async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){t.openResourceCenter()},closeResourceCenter(){t.closeResourceCenter()},toggleResourceCenter(){t.toggleResourceCenter()},setResourceCenterLauncherHidden(e){t.setResourceCenterLauncherHidden(e)},getResourceCenterState(){return t.getResourceCenterState()},setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){t.reset()},remount(){t.remount()},on(e,s){t.on(e,s)},off(e,s){t.off(e,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&d.customInputs.push({cssSelector:e})},registerCustomInput(e,s){d.customInputs.push({cssSelector:e,getValue:s})},setCustomNavigate(e){d.customNavigate=e},setUrlFilter(e){d.urlFilter=e},setLinkUrlDecorator(e){d.linkUrlDecorator=e,t.emit("uistatechange")},setInferenceAttributeNames(e){d.inferenceAttributeNames=e},setInferenceAttributeFilter(e,s){d.inferenceAttributeFilters[e]=b(s)},setInferenceClassNameFilter(e){d.inferenceClassNameFilters=b(e)},setScrollPadding(e){d.scrollPadding=e},setCustomScrollIntoView(e){d.customScrollIntoView=e},prepareAudio(){t.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(e){t.pageTrackingDisabled=e},setBaseZIndex(e){d.baseZIndex=e},setServerEndpoint(e){d.serverEndpoint=e},disableEvalJs(){d.evalJsDisabled=!0},_setTargetEnv(e){t.setTargetEnv(e)},debugger(){return t.mountDebugger()}}}function qe(){const t=window.userflow,e=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!(!e||e.length===0)){o(`processing ${e.length} items in the queue`);for(const[s,i,n]of e){if(typeof t[s]!="function"){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const r=t[s](...n);i&&r&&typeof r.then=="function"&&r.then(i.resolve,i.reject)}o("queue processed")}}var rt=window.userflow;export{he as $,S as A,ze as B,Ae as C,Ee as D,C as E,se as F,I as G,_e as H,le as I,de as J,He as K,Pe as L,Se as M,be as N,De as O,Te as P,Be as Q,je as R,oe as S,Ce as T,l as U,ke as V,We as W,ye as X,Me as Y,Ue as Z,g as _,k as a,it as a0,x as a1,Le as a2,Ne as a3,fe as a4,Fe as a5,Q as a6,G as a7,re as a8,nt as a9,y as aa,Ve as ab,ee as ac,ce as b,ae as c,o as d,rt as default,q as e,ne as f,Ge as g,te as h,ue as i,D as j,_ as k,d as l,Ye as m,we as n,Ie as o,Oe as p,me as q,pe as r,Re as s,m as t,f as u,Ke as v,ve as w,xe as x,ie as y,ge as z};
18
18
  //# sourceMappingURL=userflow.js.map
package/vendor.core-js.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="624a0e87-f760-4975-8930-5368f480b9dd",r._sentryDebugIdIdentifier="sentry-dbid-624a0e87-f760-4975-8930-5368f480b9dd")}catch{}})();var Ze=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};Ze.SENTRY_RELEASE={id:"03800ef197465127b9330b32e05eae0f71f94c17"};var F=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yi(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var P=function(r){return r&&r.Math===Math&&r},f=P(typeof globalThis=="object"&&globalThis)||P(typeof window=="object"&&window)||P(typeof self=="object"&&self)||P(typeof F=="object"&&F)||P(typeof F=="object"&&F)||function(){return this}()||Function("return this")(),gr={},h=function(r){try{return!!r()}catch{return!0}},Qe=h,g=!Qe(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),rt=h,Or=!rt(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")}),et=Or,B=Function.prototype.call,O=et?B.bind(B):function(){return B.apply(B,arguments)},fe={},se={}.propertyIsEnumerable,ye=Object.getOwnPropertyDescriptor,tt=ye&&!se.call({1:2},1);fe.f=tt?function(e){var t=ye(this,e);return!!t&&t.enumerable}:se;var de=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}},$e=Or,pe=Function.prototype,sr=pe.call,nt=$e&&pe.bind.bind(sr,sr),b=$e?nt:function(r){return function(){return sr.apply(r,arguments)}},be=b,at=be({}.toString),ot=be("".slice),q=function(r){return ot(at(r),8,-1)},it=b,vt=h,ut=q,H=Object,ct=it("".split),lt=vt(function(){return!H("z").propertyIsEnumerable(0)})?function(r){return ut(r)==="String"?ct(r,""):H(r)}:H,Sr=function(r){return r==null},ft=Sr,st=TypeError,he=function(r){if(ft(r))throw new st("Can't call method on "+r);return r},yt=lt,dt=he,Er=function(r){return yt(dt(r))},X=typeof document=="object"&&document.all,d=typeof X>"u"&&X!==void 0?function(r){return typeof r=="function"||r===X}:function(r){return typeof r=="function"},$t=d,_=function(r){return typeof r=="object"?r!==null:$t(r)},Z=f,pt=d,bt=function(r){return pt(r)?r:void 0},ge=function(r,e){return arguments.length<2?bt(Z[r]):Z[r]&&Z[r][e]},ht=b,Oe=ht({}.isPrototypeOf),gt=f,_r=gt.navigator,Dr=_r&&_r.userAgent,Se=Dr?String(Dr):"",Ee=f,Q=Se,Mr=Ee.process,Ar=Ee.Deno,Fr=Mr&&Mr.versions||Ar&&Ar.version,Br=Fr&&Fr.v8,$,W;Br&&($=Br.split("."),W=$[0]>0&&$[0]<4?1:+($[0]+$[1]));!W&&Q&&($=Q.match(/Edge\/(\d+)/),(!$||$[1]>=74)&&($=Q.match(/Chrome\/(\d+)/),$&&(W=+$[1])));var Te=W,Lr=Te,Ot=h,St=f,Et=St.String,we=!!Object.getOwnPropertySymbols&&!Ot(function(){var r=Symbol("symbol detection");return!Et(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Lr&&Lr<41}),Tt=we,Ie=Tt&&!Symbol.sham&&typeof Symbol.iterator=="symbol",wt=ge,It=d,mt=Oe,Rt=Ie,Pt=Object,me=Rt?function(r){return typeof r=="symbol"}:function(r){var e=wt("Symbol");return It(e)&&mt(e.prototype,Pt(r))},Ct=String,Tr=function(r){try{return Ct(r)}catch{return"Object"}},jt=d,Nt=Tr,_t=TypeError,D=function(r){if(jt(r))return r;throw new _t(Nt(r)+" is not a function")},Dt=D,Mt=Sr,wr=function(r,e){var t=r[e];return Mt(t)?void 0:Dt(t)},rr=O,er=d,tr=_,At=TypeError,Ft=function(r,e){var t,n;if(e==="string"&&er(t=r.toString)&&!tr(n=rr(t,r))||er(t=r.valueOf)&&!tr(n=rr(t,r))||e!=="string"&&er(t=r.toString)&&!tr(n=rr(t,r)))return n;throw new At("Can't convert object to primitive value")},Re={exports:{}},Ur=f,Bt=Object.defineProperty,Ir=function(r,e){try{Bt(Ur,r,{value:e,configurable:!0,writable:!0})}catch{Ur[r]=e}return e},Lt=f,Ut=Ir,Gr="__core-js_shared__",xr=Re.exports=Lt[Gr]||Ut(Gr,{});(xr.versions||(xr.versions=[])).push({version:"3.39.0",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"});var mr=Re.exports,Kr=mr,Pe=function(r,e){return Kr[r]||(Kr[r]=e||{})},Gt=he,xt=Object,Kt=function(r){return xt(Gt(r))},Vt=b,kt=Kt,Wt=Vt({}.hasOwnProperty),S=Object.hasOwn||function(e,t){return Wt(kt(e),t)},zt=b,Yt=0,qt=Math.random(),Jt=zt(1 .toString),Ce=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Jt(++Yt+qt,36)},Ht=f,Xt=Pe,Vr=S,Zt=Ce,Qt=we,rn=Ie,m=Ht.Symbol,nr=Xt("wks"),en=rn?m.for||m:m&&m.withoutSetter||Zt,E=function(r){return Vr(nr,r)||(nr[r]=Qt&&Vr(m,r)?m[r]:en("Symbol."+r)),nr[r]},tn=O,kr=_,Wr=me,nn=wr,an=Ft,on=E,vn=TypeError,un=on("toPrimitive"),cn=function(r,e){if(!kr(r)||Wr(r))return r;var t=nn(r,un),n;if(t){if(e===void 0&&(e="default"),n=tn(t,r,e),!kr(n)||Wr(n))return n;throw new vn("Can't convert object to primitive value")}return e===void 0&&(e="number"),an(r,e)},ln=cn,fn=me,je=function(r){var e=ln(r,"string");return fn(e)?e:e+""},sn=f,zr=_,yr=sn.document,yn=zr(yr)&&zr(yr.createElement),dn=function(r){return yn?yr.createElement(r):{}},$n=g,pn=h,bn=dn,Ne=!$n&&!pn(function(){return Object.defineProperty(bn("div"),"a",{get:function(){return 7}}).a!==7}),hn=g,gn=O,On=fe,Sn=de,En=Er,Tn=je,wn=S,In=Ne,Yr=Object.getOwnPropertyDescriptor;gr.f=hn?Yr:function(e,t){if(e=En(e),t=Tn(t),In)try{return Yr(e,t)}catch{}if(wn(e,t))return Sn(!gn(On.f,e,t),e[t])};var J={},mn=g,Rn=h,Pn=mn&&Rn(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),Cn=_,jn=String,Nn=TypeError,M=function(r){if(Cn(r))return r;throw new Nn(jn(r)+" is not an object")},_n=g,Dn=Ne,Mn=Pn,L=M,qr=je,An=TypeError,ar=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,or="enumerable",ir="configurable",vr="writable";J.f=_n?Mn?function(e,t,n){if(L(e),t=qr(t),L(n),typeof e=="function"&&t==="prototype"&&"value"in n&&vr in n&&!n[vr]){var a=Fn(e,t);a&&a[vr]&&(e[t]=n.value,n={configurable:ir in n?n[ir]:a[ir],enumerable:or in n?n[or]:a[or],writable:!1})}return ar(e,t,n)}:ar:function(e,t,n){if(L(e),t=qr(t),L(n),Dn)try{return ar(e,t,n)}catch{}if("get"in n||"set"in n)throw new An("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Bn=g,Ln=J,Un=de,_e=Bn?function(r,e,t){return Ln.f(r,e,Un(1,t))}:function(r,e,t){return r[e]=t,r},De={exports:{}},dr=g,Gn=S,Me=Function.prototype,xn=dr&&Object.getOwnPropertyDescriptor,Rr=Gn(Me,"name"),Kn=Rr&&function(){}.name==="something",Vn=Rr&&(!dr||dr&&xn(Me,"name").configurable),kn={EXISTS:Rr,PROPER:Kn,CONFIGURABLE:Vn},Wn=b,zn=d,$r=mr,Yn=Wn(Function.toString);zn($r.inspectSource)||($r.inspectSource=function(r){return Yn(r)});var Ae=$r.inspectSource,qn=f,Jn=d,Jr=qn.WeakMap,Hn=Jn(Jr)&&/native code/.test(String(Jr)),Xn=Pe,Zn=Ce,Hr=Xn("keys"),Qn=function(r){return Hr[r]||(Hr[r]=Zn(r))},Fe={},ra=Hn,Be=f,ea=_,ta=_e,ur=S,cr=mr,na=Qn,aa=Fe,Xr="Object already initialized",pr=Be.TypeError,oa=Be.WeakMap,z,N,Y,ia=function(r){return Y(r)?N(r):z(r,{})},va=function(r){return function(e){var t;if(!ea(e)||(t=N(e)).type!==r)throw new pr("Incompatible receiver, "+r+" required");return t}};if(ra||cr.state){var p=cr.state||(cr.state=new oa);p.get=p.get,p.has=p.has,p.set=p.set,z=function(r,e){if(p.has(r))throw new pr(Xr);return e.facade=r,p.set(r,e),e},N=function(r){return p.get(r)||{}},Y=function(r){return p.has(r)}}else{var I=na("state");aa[I]=!0,z=function(r,e){if(ur(r,I))throw new pr(Xr);return e.facade=r,ta(r,I,e),e},N=function(r){return ur(r,I)?r[I]:{}},Y=function(r){return ur(r,I)}}var ua={set:z,get:N,has:Y,enforce:ia,getterFor:va},Pr=b,ca=h,la=d,U=S,br=g,fa=kn.CONFIGURABLE,sa=Ae,Le=ua,ya=Le.enforce,da=Le.get,Zr=String,K=Object.defineProperty,$a=Pr("".slice),pa=Pr("".replace),ba=Pr([].join),ha=br&&!ca(function(){return K(function(){},"length",{value:8}).length!==8}),ga=String(String).split("String"),Oa=De.exports=function(r,e,t){$a(Zr(e),0,7)==="Symbol("&&(e="["+pa(Zr(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!U(r,"name")||fa&&r.name!==e)&&(br?K(r,"name",{value:e,configurable:!0}):r.name=e),ha&&t&&U(t,"arity")&&r.length!==t.arity&&K(r,"length",{value:t.arity});try{t&&U(t,"constructor")&&t.constructor?br&&K(r,"prototype",{writable:!1}):r.prototype&&(r.prototype=void 0)}catch{}var n=ya(r);return U(n,"source")||(n.source=ba(ga,typeof e=="string"?e:"")),r};Function.prototype.toString=Oa(function(){return la(this)&&da(this).source||sa(this)},"toString");var Sa=De.exports,Ea=d,Ta=J,wa=Sa,Ia=Ir,ma=function(r,e,t,n){n||(n={});var a=n.enumerable,o=n.name!==void 0?n.name:e;if(Ea(t)&&wa(t,o,n),n.global)a?r[e]=t:Ia(e,t);else{try{n.unsafe?r[e]&&(a=!0):delete r[e]}catch{}a?r[e]=t:Ta.f(r,e,{value:t,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return r},Ue={},Ra=Math.ceil,Pa=Math.floor,Ca=Math.trunc||function(e){var t=+e;return(t>0?Pa:Ra)(t)},ja=Ca,Ge=function(r){var e=+r;return e!==e||e===0?0:ja(e)},Na=Ge,_a=Math.max,Da=Math.min,Ma=function(r,e){var t=Na(r);return t<0?_a(t+e,0):Da(t,e)},Aa=Ge,Fa=Math.min,Ba=function(r){var e=Aa(r);return e>0?Fa(e,9007199254740991):0},La=Ba,xe=function(r){return La(r.length)},Ua=Er,Ga=Ma,xa=xe,Qr=function(r){return function(e,t,n){var a=Ua(e),o=xa(a);if(o===0)return!r&&-1;var i=Ga(n,o),v;if(r&&t!==t){for(;o>i;)if(v=a[i++],v!==v)return!0}else for(;o>i;i++)if((r||i in a)&&a[i]===t)return r||i||0;return!r&&-1}},Ka={includes:Qr(!0),indexOf:Qr(!1)},Va=b,lr=S,ka=Er,Wa=Ka.indexOf,za=Fe,re=Va([].push),Ya=function(r,e){var t=ka(r),n=0,a=[],o;for(o in t)!lr(za,o)&&lr(t,o)&&re(a,o);for(;e.length>n;)lr(t,o=e[n++])&&(~Wa(a,o)||re(a,o));return a},qa=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ja=Ya,Ha=qa,Xa=Ha.concat("length","prototype");Ue.f=Object.getOwnPropertyNames||function(e){return Ja(e,Xa)};var Ke={};Ke.f=Object.getOwnPropertySymbols;var Za=ge,Qa=b,ro=Ue,eo=Ke,to=M,no=Qa([].concat),ao=Za("Reflect","ownKeys")||function(e){var t=ro.f(to(e)),n=eo.f;return n?no(t,n(e)):t},ee=S,oo=ao,io=gr,vo=J,uo=function(r,e,t){for(var n=oo(e),a=vo.f,o=io.f,i=0;i<n.length;i++){var v=n[i];!ee(r,v)&&!(t&&ee(t,v))&&a(r,v,o(e,v))}},co=h,lo=d,fo=/#|\.prototype\./,A=function(r,e){var t=yo[so(r)];return t===po?!0:t===$o?!1:lo(e)?co(e):!!e},so=A.normalize=function(r){return String(r).replace(fo,".").toLowerCase()},yo=A.data={},$o=A.NATIVE="N",po=A.POLYFILL="P",Ve=A,G=f,bo=gr.f,ho=_e,go=ma,Oo=Ir,So=uo,Eo=Ve,To=function(r,e){var t=r.target,n=r.global,a=r.stat,o,i,v,u,c,s;if(n?i=G:a?i=G[t]||Oo(t,{}):i=G[t]&&G[t].prototype,i)for(v in e){if(c=e[v],r.dontCallGetSet?(s=bo(i,v),u=s&&s.value):u=i[v],o=Eo(n?v:t+(a?".":"#")+v,r.forced),!o&&u!==void 0){if(typeof c==typeof u)continue;So(c,u)}(r.sham||u&&u.sham)&&ho(c,"sham",!0),go(i,v,c,r)}},ke={},te=D,wo=TypeError,Io=function(r){var e,t;this.promise=new r(function(n,a){if(e!==void 0||t!==void 0)throw new wo("Bad Promise constructor");e=n,t=a}),this.resolve=te(e),this.reject=te(t)};ke.f=function(r){return new Io(r)};var mo=function(r){try{return{error:!1,value:r()}}catch(e){return{error:!0,value:e}}},Ro=q,Po=b,Co=function(r){if(Ro(r)==="Function")return Po(r)},ne=Co,jo=D,No=Or,_o=ne(ne.bind),Do=function(r,e){return jo(r),e===void 0?r:No?_o(r,e):function(){return r.apply(e,arguments)}},We={},Mo=E,Ao=We,Fo=Mo("iterator"),Bo=Array.prototype,Lo=function(r){return r!==void 0&&(Ao.Array===r||Bo[Fo]===r)},Uo=E,Go=Uo("toStringTag"),ze={};ze[Go]="z";var xo=String(ze)==="[object z]",Ko=xo,Vo=d,V=q,ko=E,Wo=ko("toStringTag"),zo=Object,Yo=V(function(){return arguments}())==="Arguments",qo=function(r,e){try{return r[e]}catch{}},Jo=Ko?V:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=qo(e=zo(r),Wo))=="string"?t:Yo?V(e):(n=V(e))==="Object"&&Vo(e.callee)?"Arguments":n},Ho=Jo,ae=wr,Xo=Sr,Zo=We,Qo=E,ri=Qo("iterator"),Ye=function(r){if(!Xo(r))return ae(r,ri)||ae(r,"@@iterator")||Zo[Ho(r)]},ei=O,ti=D,ni=M,ai=Tr,oi=Ye,ii=TypeError,vi=function(r,e){var t=arguments.length<2?oi(r):e;if(ti(t))return ni(ei(t,r));throw new ii(ai(r)+" is not iterable")},ui=O,oe=M,ci=wr,li=function(r,e,t){var n,a;oe(r);try{if(n=ci(r,"return"),!n){if(e==="throw")throw t;return t}n=ui(n,r)}catch(o){a=!0,n=o}if(e==="throw")throw t;if(a)throw n;return oe(n),t},fi=Do,si=O,yi=M,di=Tr,$i=Lo,pi=xe,ie=Oe,bi=vi,hi=Ye,ve=li,gi=TypeError,k=function(r,e){this.stopped=r,this.result=e},ue=k.prototype,Oi=function(r,e,t){var n=t&&t.that,a=!!(t&&t.AS_ENTRIES),o=!!(t&&t.IS_RECORD),i=!!(t&&t.IS_ITERATOR),v=!!(t&&t.INTERRUPTED),u=fi(e,n),c,s,T,R,l,w,Cr,jr=function(y){return c&&ve(c,"normal",y),new k(!0,y)},Nr=function(y){return a?(yi(y),v?u(y[0],y[1],jr):u(y[0],y[1])):v?u(y,jr):u(y)};if(o)c=r.iterator;else if(i)c=r;else{if(s=hi(r),!s)throw new gi(di(r)+" is not iterable");if($i(s)){for(T=0,R=pi(r);R>T;T++)if(l=Nr(r[T]),l&&ie(ue,l))return l;return new k(!1)}c=bi(r,s)}for(w=o?r.next:c.next;!(Cr=si(w,c)).done;){try{l=Nr(Cr.value)}catch(y){ve(c,"throw",y)}if(typeof l=="object"&&l&&ie(ue,l))return l}return new k(!1)},Si=f,qe=Si.Promise,Ei=E,Je=Ei("iterator"),He=!1;try{var Ti=0,ce={next:function(){return{done:!!Ti++}},return:function(){He=!0}};ce[Je]=function(){return this},Array.from(ce,function(){throw 2})}catch{}var wi=function(r,e){try{if(!e&&!He)return!1}catch{return!1}var t=!1;try{var n={};n[Je]=function(){return{next:function(){return{done:t=!0}}}},r(n)}catch{}return t},C=f,Ii=Se,mi=q,x=function(r){return Ii.slice(0,r.length)===r},Ri=function(){return x("Bun/")?"BUN":x("Cloudflare-Workers")?"CLOUDFLARE":x("Deno/")?"DENO":x("Node.js/")?"NODE":C.Bun&&typeof Bun.version=="string"?"BUN":C.Deno&&typeof Deno.version=="object"?"DENO":mi(C.process)==="process"?"NODE":C.window&&C.document?"BROWSER":"REST"}(),Pi=f,j=qe,Ci=d,ji=Ve,Ni=Ae,_i=E,le=Ri,fr=Te;j&&j.prototype;var Di=_i("species"),hr=!1,Xe=Ci(Pi.PromiseRejectionEvent),Mi=ji("Promise",function(){var r=Ni(j),e=r!==String(j);if(!e&&fr===66)return!0;if(!fr||fr<51||!/native code/.test(r)){var t=new j(function(o){o(1)}),n=function(o){o(function(){},function(){})},a=t.constructor={};if(a[Di]=n,hr=t.then(function(){})instanceof n,!hr)return!0}return!e&&(le==="BROWSER"||le==="DENO")&&!Xe}),Ai={CONSTRUCTOR:Mi,REJECTION_EVENT:Xe,SUBCLASSING:hr},Fi=qe,Bi=wi,Li=Ai.CONSTRUCTOR,Ui=Li||!Bi(function(r){Fi.all(r).then(void 0,function(){})}),Gi=To,xi=O,Ki=D,Vi=ke,ki=mo,Wi=Oi,zi=Ui;Gi({target:"Promise",stat:!0,forced:zi},{allSettled:function(e){var t=this,n=Vi.f(t),a=n.resolve,o=n.reject,i=ki(function(){var v=Ki(t.resolve),u=[],c=0,s=1;Wi(e,function(T){var R=c++,l=!1;s++,xi(v,t,T).then(function(w){l||(l=!0,u[R]={status:"fulfilled",value:w},--s||a(u))},function(w){l||(l=!0,u[R]={status:"rejected",reason:w},--s||a(u))})}),--s||a(u)});return i.error&&o(i.value),n.promise}});export{F as c,Yi as g};
1
+ (function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="ffe109c4-cd2f-4aea-ac36-6e829ed61b2f",r._sentryDebugIdIdentifier="sentry-dbid-ffe109c4-cd2f-4aea-ac36-6e829ed61b2f")}catch{}})();var Ze=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};Ze.SENTRY_RELEASE={id:"d2af06f07598ad795de7d7fd7c328cf5deddbbcc"};var F=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yi(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var P=function(r){return r&&r.Math===Math&&r},f=P(typeof globalThis=="object"&&globalThis)||P(typeof window=="object"&&window)||P(typeof self=="object"&&self)||P(typeof F=="object"&&F)||P(typeof F=="object"&&F)||function(){return this}()||Function("return this")(),gr={},h=function(r){try{return!!r()}catch{return!0}},Qe=h,g=!Qe(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),rt=h,Or=!rt(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")}),et=Or,B=Function.prototype.call,O=et?B.bind(B):function(){return B.apply(B,arguments)},fe={},se={}.propertyIsEnumerable,ye=Object.getOwnPropertyDescriptor,tt=ye&&!se.call({1:2},1);fe.f=tt?function(e){var t=ye(this,e);return!!t&&t.enumerable}:se;var de=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}},$e=Or,pe=Function.prototype,sr=pe.call,nt=$e&&pe.bind.bind(sr,sr),b=$e?nt:function(r){return function(){return sr.apply(r,arguments)}},be=b,at=be({}.toString),ot=be("".slice),q=function(r){return ot(at(r),8,-1)},it=b,vt=h,ut=q,H=Object,ct=it("".split),lt=vt(function(){return!H("z").propertyIsEnumerable(0)})?function(r){return ut(r)==="String"?ct(r,""):H(r)}:H,Sr=function(r){return r==null},ft=Sr,st=TypeError,he=function(r){if(ft(r))throw new st("Can't call method on "+r);return r},yt=lt,dt=he,Er=function(r){return yt(dt(r))},X=typeof document=="object"&&document.all,d=typeof X>"u"&&X!==void 0?function(r){return typeof r=="function"||r===X}:function(r){return typeof r=="function"},$t=d,_=function(r){return typeof r=="object"?r!==null:$t(r)},Z=f,pt=d,bt=function(r){return pt(r)?r:void 0},ge=function(r,e){return arguments.length<2?bt(Z[r]):Z[r]&&Z[r][e]},ht=b,Oe=ht({}.isPrototypeOf),gt=f,_r=gt.navigator,Dr=_r&&_r.userAgent,Se=Dr?String(Dr):"",Ee=f,Q=Se,Mr=Ee.process,Ar=Ee.Deno,Fr=Mr&&Mr.versions||Ar&&Ar.version,Br=Fr&&Fr.v8,$,W;Br&&($=Br.split("."),W=$[0]>0&&$[0]<4?1:+($[0]+$[1]));!W&&Q&&($=Q.match(/Edge\/(\d+)/),(!$||$[1]>=74)&&($=Q.match(/Chrome\/(\d+)/),$&&(W=+$[1])));var Te=W,Lr=Te,Ot=h,St=f,Et=St.String,we=!!Object.getOwnPropertySymbols&&!Ot(function(){var r=Symbol("symbol detection");return!Et(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Lr&&Lr<41}),Tt=we,Ie=Tt&&!Symbol.sham&&typeof Symbol.iterator=="symbol",wt=ge,It=d,mt=Oe,Rt=Ie,Pt=Object,me=Rt?function(r){return typeof r=="symbol"}:function(r){var e=wt("Symbol");return It(e)&&mt(e.prototype,Pt(r))},Ct=String,Tr=function(r){try{return Ct(r)}catch{return"Object"}},jt=d,Nt=Tr,_t=TypeError,D=function(r){if(jt(r))return r;throw new _t(Nt(r)+" is not a function")},Dt=D,Mt=Sr,wr=function(r,e){var t=r[e];return Mt(t)?void 0:Dt(t)},rr=O,er=d,tr=_,At=TypeError,Ft=function(r,e){var t,n;if(e==="string"&&er(t=r.toString)&&!tr(n=rr(t,r))||er(t=r.valueOf)&&!tr(n=rr(t,r))||e!=="string"&&er(t=r.toString)&&!tr(n=rr(t,r)))return n;throw new At("Can't convert object to primitive value")},Re={exports:{}},Ur=f,Bt=Object.defineProperty,Ir=function(r,e){try{Bt(Ur,r,{value:e,configurable:!0,writable:!0})}catch{Ur[r]=e}return e},Lt=f,Ut=Ir,Gr="__core-js_shared__",xr=Re.exports=Lt[Gr]||Ut(Gr,{});(xr.versions||(xr.versions=[])).push({version:"3.39.0",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"});var mr=Re.exports,Kr=mr,Pe=function(r,e){return Kr[r]||(Kr[r]=e||{})},Gt=he,xt=Object,Kt=function(r){return xt(Gt(r))},Vt=b,kt=Kt,Wt=Vt({}.hasOwnProperty),S=Object.hasOwn||function(e,t){return Wt(kt(e),t)},zt=b,Yt=0,qt=Math.random(),Jt=zt(1 .toString),Ce=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Jt(++Yt+qt,36)},Ht=f,Xt=Pe,Vr=S,Zt=Ce,Qt=we,rn=Ie,m=Ht.Symbol,nr=Xt("wks"),en=rn?m.for||m:m&&m.withoutSetter||Zt,E=function(r){return Vr(nr,r)||(nr[r]=Qt&&Vr(m,r)?m[r]:en("Symbol."+r)),nr[r]},tn=O,kr=_,Wr=me,nn=wr,an=Ft,on=E,vn=TypeError,un=on("toPrimitive"),cn=function(r,e){if(!kr(r)||Wr(r))return r;var t=nn(r,un),n;if(t){if(e===void 0&&(e="default"),n=tn(t,r,e),!kr(n)||Wr(n))return n;throw new vn("Can't convert object to primitive value")}return e===void 0&&(e="number"),an(r,e)},ln=cn,fn=me,je=function(r){var e=ln(r,"string");return fn(e)?e:e+""},sn=f,zr=_,yr=sn.document,yn=zr(yr)&&zr(yr.createElement),dn=function(r){return yn?yr.createElement(r):{}},$n=g,pn=h,bn=dn,Ne=!$n&&!pn(function(){return Object.defineProperty(bn("div"),"a",{get:function(){return 7}}).a!==7}),hn=g,gn=O,On=fe,Sn=de,En=Er,Tn=je,wn=S,In=Ne,Yr=Object.getOwnPropertyDescriptor;gr.f=hn?Yr:function(e,t){if(e=En(e),t=Tn(t),In)try{return Yr(e,t)}catch{}if(wn(e,t))return Sn(!gn(On.f,e,t),e[t])};var J={},mn=g,Rn=h,Pn=mn&&Rn(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),Cn=_,jn=String,Nn=TypeError,M=function(r){if(Cn(r))return r;throw new Nn(jn(r)+" is not an object")},_n=g,Dn=Ne,Mn=Pn,L=M,qr=je,An=TypeError,ar=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,or="enumerable",ir="configurable",vr="writable";J.f=_n?Mn?function(e,t,n){if(L(e),t=qr(t),L(n),typeof e=="function"&&t==="prototype"&&"value"in n&&vr in n&&!n[vr]){var a=Fn(e,t);a&&a[vr]&&(e[t]=n.value,n={configurable:ir in n?n[ir]:a[ir],enumerable:or in n?n[or]:a[or],writable:!1})}return ar(e,t,n)}:ar:function(e,t,n){if(L(e),t=qr(t),L(n),Dn)try{return ar(e,t,n)}catch{}if("get"in n||"set"in n)throw new An("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Bn=g,Ln=J,Un=de,_e=Bn?function(r,e,t){return Ln.f(r,e,Un(1,t))}:function(r,e,t){return r[e]=t,r},De={exports:{}},dr=g,Gn=S,Me=Function.prototype,xn=dr&&Object.getOwnPropertyDescriptor,Rr=Gn(Me,"name"),Kn=Rr&&function(){}.name==="something",Vn=Rr&&(!dr||dr&&xn(Me,"name").configurable),kn={EXISTS:Rr,PROPER:Kn,CONFIGURABLE:Vn},Wn=b,zn=d,$r=mr,Yn=Wn(Function.toString);zn($r.inspectSource)||($r.inspectSource=function(r){return Yn(r)});var Ae=$r.inspectSource,qn=f,Jn=d,Jr=qn.WeakMap,Hn=Jn(Jr)&&/native code/.test(String(Jr)),Xn=Pe,Zn=Ce,Hr=Xn("keys"),Qn=function(r){return Hr[r]||(Hr[r]=Zn(r))},Fe={},ra=Hn,Be=f,ea=_,ta=_e,ur=S,cr=mr,na=Qn,aa=Fe,Xr="Object already initialized",pr=Be.TypeError,oa=Be.WeakMap,z,N,Y,ia=function(r){return Y(r)?N(r):z(r,{})},va=function(r){return function(e){var t;if(!ea(e)||(t=N(e)).type!==r)throw new pr("Incompatible receiver, "+r+" required");return t}};if(ra||cr.state){var p=cr.state||(cr.state=new oa);p.get=p.get,p.has=p.has,p.set=p.set,z=function(r,e){if(p.has(r))throw new pr(Xr);return e.facade=r,p.set(r,e),e},N=function(r){return p.get(r)||{}},Y=function(r){return p.has(r)}}else{var I=na("state");aa[I]=!0,z=function(r,e){if(ur(r,I))throw new pr(Xr);return e.facade=r,ta(r,I,e),e},N=function(r){return ur(r,I)?r[I]:{}},Y=function(r){return ur(r,I)}}var ua={set:z,get:N,has:Y,enforce:ia,getterFor:va},Pr=b,ca=h,la=d,U=S,br=g,fa=kn.CONFIGURABLE,sa=Ae,Le=ua,ya=Le.enforce,da=Le.get,Zr=String,K=Object.defineProperty,$a=Pr("".slice),pa=Pr("".replace),ba=Pr([].join),ha=br&&!ca(function(){return K(function(){},"length",{value:8}).length!==8}),ga=String(String).split("String"),Oa=De.exports=function(r,e,t){$a(Zr(e),0,7)==="Symbol("&&(e="["+pa(Zr(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!U(r,"name")||fa&&r.name!==e)&&(br?K(r,"name",{value:e,configurable:!0}):r.name=e),ha&&t&&U(t,"arity")&&r.length!==t.arity&&K(r,"length",{value:t.arity});try{t&&U(t,"constructor")&&t.constructor?br&&K(r,"prototype",{writable:!1}):r.prototype&&(r.prototype=void 0)}catch{}var n=ya(r);return U(n,"source")||(n.source=ba(ga,typeof e=="string"?e:"")),r};Function.prototype.toString=Oa(function(){return la(this)&&da(this).source||sa(this)},"toString");var Sa=De.exports,Ea=d,Ta=J,wa=Sa,Ia=Ir,ma=function(r,e,t,n){n||(n={});var a=n.enumerable,o=n.name!==void 0?n.name:e;if(Ea(t)&&wa(t,o,n),n.global)a?r[e]=t:Ia(e,t);else{try{n.unsafe?r[e]&&(a=!0):delete r[e]}catch{}a?r[e]=t:Ta.f(r,e,{value:t,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return r},Ue={},Ra=Math.ceil,Pa=Math.floor,Ca=Math.trunc||function(e){var t=+e;return(t>0?Pa:Ra)(t)},ja=Ca,Ge=function(r){var e=+r;return e!==e||e===0?0:ja(e)},Na=Ge,_a=Math.max,Da=Math.min,Ma=function(r,e){var t=Na(r);return t<0?_a(t+e,0):Da(t,e)},Aa=Ge,Fa=Math.min,Ba=function(r){var e=Aa(r);return e>0?Fa(e,9007199254740991):0},La=Ba,xe=function(r){return La(r.length)},Ua=Er,Ga=Ma,xa=xe,Qr=function(r){return function(e,t,n){var a=Ua(e),o=xa(a);if(o===0)return!r&&-1;var i=Ga(n,o),v;if(r&&t!==t){for(;o>i;)if(v=a[i++],v!==v)return!0}else for(;o>i;i++)if((r||i in a)&&a[i]===t)return r||i||0;return!r&&-1}},Ka={includes:Qr(!0),indexOf:Qr(!1)},Va=b,lr=S,ka=Er,Wa=Ka.indexOf,za=Fe,re=Va([].push),Ya=function(r,e){var t=ka(r),n=0,a=[],o;for(o in t)!lr(za,o)&&lr(t,o)&&re(a,o);for(;e.length>n;)lr(t,o=e[n++])&&(~Wa(a,o)||re(a,o));return a},qa=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ja=Ya,Ha=qa,Xa=Ha.concat("length","prototype");Ue.f=Object.getOwnPropertyNames||function(e){return Ja(e,Xa)};var Ke={};Ke.f=Object.getOwnPropertySymbols;var Za=ge,Qa=b,ro=Ue,eo=Ke,to=M,no=Qa([].concat),ao=Za("Reflect","ownKeys")||function(e){var t=ro.f(to(e)),n=eo.f;return n?no(t,n(e)):t},ee=S,oo=ao,io=gr,vo=J,uo=function(r,e,t){for(var n=oo(e),a=vo.f,o=io.f,i=0;i<n.length;i++){var v=n[i];!ee(r,v)&&!(t&&ee(t,v))&&a(r,v,o(e,v))}},co=h,lo=d,fo=/#|\.prototype\./,A=function(r,e){var t=yo[so(r)];return t===po?!0:t===$o?!1:lo(e)?co(e):!!e},so=A.normalize=function(r){return String(r).replace(fo,".").toLowerCase()},yo=A.data={},$o=A.NATIVE="N",po=A.POLYFILL="P",Ve=A,G=f,bo=gr.f,ho=_e,go=ma,Oo=Ir,So=uo,Eo=Ve,To=function(r,e){var t=r.target,n=r.global,a=r.stat,o,i,v,u,c,s;if(n?i=G:a?i=G[t]||Oo(t,{}):i=G[t]&&G[t].prototype,i)for(v in e){if(c=e[v],r.dontCallGetSet?(s=bo(i,v),u=s&&s.value):u=i[v],o=Eo(n?v:t+(a?".":"#")+v,r.forced),!o&&u!==void 0){if(typeof c==typeof u)continue;So(c,u)}(r.sham||u&&u.sham)&&ho(c,"sham",!0),go(i,v,c,r)}},ke={},te=D,wo=TypeError,Io=function(r){var e,t;this.promise=new r(function(n,a){if(e!==void 0||t!==void 0)throw new wo("Bad Promise constructor");e=n,t=a}),this.resolve=te(e),this.reject=te(t)};ke.f=function(r){return new Io(r)};var mo=function(r){try{return{error:!1,value:r()}}catch(e){return{error:!0,value:e}}},Ro=q,Po=b,Co=function(r){if(Ro(r)==="Function")return Po(r)},ne=Co,jo=D,No=Or,_o=ne(ne.bind),Do=function(r,e){return jo(r),e===void 0?r:No?_o(r,e):function(){return r.apply(e,arguments)}},We={},Mo=E,Ao=We,Fo=Mo("iterator"),Bo=Array.prototype,Lo=function(r){return r!==void 0&&(Ao.Array===r||Bo[Fo]===r)},Uo=E,Go=Uo("toStringTag"),ze={};ze[Go]="z";var xo=String(ze)==="[object z]",Ko=xo,Vo=d,V=q,ko=E,Wo=ko("toStringTag"),zo=Object,Yo=V(function(){return arguments}())==="Arguments",qo=function(r,e){try{return r[e]}catch{}},Jo=Ko?V:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=qo(e=zo(r),Wo))=="string"?t:Yo?V(e):(n=V(e))==="Object"&&Vo(e.callee)?"Arguments":n},Ho=Jo,ae=wr,Xo=Sr,Zo=We,Qo=E,ri=Qo("iterator"),Ye=function(r){if(!Xo(r))return ae(r,ri)||ae(r,"@@iterator")||Zo[Ho(r)]},ei=O,ti=D,ni=M,ai=Tr,oi=Ye,ii=TypeError,vi=function(r,e){var t=arguments.length<2?oi(r):e;if(ti(t))return ni(ei(t,r));throw new ii(ai(r)+" is not iterable")},ui=O,oe=M,ci=wr,li=function(r,e,t){var n,a;oe(r);try{if(n=ci(r,"return"),!n){if(e==="throw")throw t;return t}n=ui(n,r)}catch(o){a=!0,n=o}if(e==="throw")throw t;if(a)throw n;return oe(n),t},fi=Do,si=O,yi=M,di=Tr,$i=Lo,pi=xe,ie=Oe,bi=vi,hi=Ye,ve=li,gi=TypeError,k=function(r,e){this.stopped=r,this.result=e},ue=k.prototype,Oi=function(r,e,t){var n=t&&t.that,a=!!(t&&t.AS_ENTRIES),o=!!(t&&t.IS_RECORD),i=!!(t&&t.IS_ITERATOR),v=!!(t&&t.INTERRUPTED),u=fi(e,n),c,s,T,R,l,w,Cr,jr=function(y){return c&&ve(c,"normal",y),new k(!0,y)},Nr=function(y){return a?(yi(y),v?u(y[0],y[1],jr):u(y[0],y[1])):v?u(y,jr):u(y)};if(o)c=r.iterator;else if(i)c=r;else{if(s=hi(r),!s)throw new gi(di(r)+" is not iterable");if($i(s)){for(T=0,R=pi(r);R>T;T++)if(l=Nr(r[T]),l&&ie(ue,l))return l;return new k(!1)}c=bi(r,s)}for(w=o?r.next:c.next;!(Cr=si(w,c)).done;){try{l=Nr(Cr.value)}catch(y){ve(c,"throw",y)}if(typeof l=="object"&&l&&ie(ue,l))return l}return new k(!1)},Si=f,qe=Si.Promise,Ei=E,Je=Ei("iterator"),He=!1;try{var Ti=0,ce={next:function(){return{done:!!Ti++}},return:function(){He=!0}};ce[Je]=function(){return this},Array.from(ce,function(){throw 2})}catch{}var wi=function(r,e){try{if(!e&&!He)return!1}catch{return!1}var t=!1;try{var n={};n[Je]=function(){return{next:function(){return{done:t=!0}}}},r(n)}catch{}return t},C=f,Ii=Se,mi=q,x=function(r){return Ii.slice(0,r.length)===r},Ri=function(){return x("Bun/")?"BUN":x("Cloudflare-Workers")?"CLOUDFLARE":x("Deno/")?"DENO":x("Node.js/")?"NODE":C.Bun&&typeof Bun.version=="string"?"BUN":C.Deno&&typeof Deno.version=="object"?"DENO":mi(C.process)==="process"?"NODE":C.window&&C.document?"BROWSER":"REST"}(),Pi=f,j=qe,Ci=d,ji=Ve,Ni=Ae,_i=E,le=Ri,fr=Te;j&&j.prototype;var Di=_i("species"),hr=!1,Xe=Ci(Pi.PromiseRejectionEvent),Mi=ji("Promise",function(){var r=Ni(j),e=r!==String(j);if(!e&&fr===66)return!0;if(!fr||fr<51||!/native code/.test(r)){var t=new j(function(o){o(1)}),n=function(o){o(function(){},function(){})},a=t.constructor={};if(a[Di]=n,hr=t.then(function(){})instanceof n,!hr)return!0}return!e&&(le==="BROWSER"||le==="DENO")&&!Xe}),Ai={CONSTRUCTOR:Mi,REJECTION_EVENT:Xe,SUBCLASSING:hr},Fi=qe,Bi=wi,Li=Ai.CONSTRUCTOR,Ui=Li||!Bi(function(r){Fi.all(r).then(void 0,function(){})}),Gi=To,xi=O,Ki=D,Vi=ke,ki=mo,Wi=Oi,zi=Ui;Gi({target:"Promise",stat:!0,forced:zi},{allSettled:function(e){var t=this,n=Vi.f(t),a=n.resolve,o=n.reject,i=ki(function(){var v=Ki(t.resolve),u=[],c=0,s=1;Wi(e,function(T){var R=c++,l=!1;s++,xi(v,t,T).then(function(w){l||(l=!0,u[R]={status:"fulfilled",value:w},--s||a(u))},function(w){l||(l=!0,u[R]={status:"rejected",reason:w},--s||a(u))})}),--s||a(u)});return i.error&&o(i.value),n.promise}});export{F as c,Yi as g};
2
2
  //# sourceMappingURL=vendor.core-js.js.map