userflow.js-self-hosted 0.1.1004474 → 0.1.1004513

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/FlowApp.js CHANGED
@@ -1 +1 @@
1
- import{r as e}from"./vendor.react.js";import{E as t,V as o,J as n,b as s,K as r,H as l,L as a,x as i,D as c,M as u,U as d}from"./userflow.js";import{B as p}from"./BubbleToolbar.js";import{m,d as f,R as b,i as w,g as h,u as g,c as E,h as v,S as y}from"./bubble-frame.styl.js";import{b as k,z as j,a as T,t as R,r as S}from"./flow-condition-types.js";import{u as L,i as M}from"./client-context.js";import{F as x}from"./FlowChrome.js";import{u as F,r as C}from"./use-selector-element-monitoring.js";import{a as I,S as N}from"./flow-host.styl.js";import{m as D}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as P,u as B}from"./stylesheets.js";import{T as q}from"./Trigger.js";import{u as _}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.obj-str.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.js";import"./vendor.babel.runtime.js";const A=()=>{const{t:o}=_(),n=L(),{dispatch:s,restart:r}=le(),{session:l,step:a}=ae(),i="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return e.createElement("div",{role:"dialog","aria-modal":ne(a)?"true":void 0,"aria-label":"Guide menu"},e.createElement("div",{className:"userflowjs-bubble-menu__title"},o("menu.title")),e.createElement("button",{className:i,onClick:()=>n.endFlow(l,{endReason:t.USER_CLOSED})},o("menu.close")),l.version.restartEnabled&&e.createElement("button",{className:i,onClick:r},o("menu.restart")),e.createElement("button",{className:i,onClick:()=>s({kind:"showFlow"})},o("menu.back")))},O=({progress:t})=>{const o={width:100*parseFloat(t||"0")+"%"};return e.createElement("div",{className:"userflowjs-bubble-progress"},e.createElement("div",{className:"userflowjs-bubble-progress__fill",style:o}))},V=({theme:s})=>{const r=L(),{session:l,step:a,muted:i,shouldLabelDialog:c}=ae(),{version:u}=l,{dispatch:d}=le(),w=u.steps[0],h=w&&w.id===a.id,g=h&&"1"===a.progress,E=e.useMemo((()=>a.content&&m(f(a.content),{buttons:a.buttons,questions:a.questions})),[a.content,a.buttons,a.questions]);return e.createElement("div",{key:a.id,role:"alertdialog","aria-modal":ne(a)?"true":void 0,"aria-label":c?"Guide":void 0},!g&&e.createElement(O,{progress:a.progress}),e.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},e.createElement(b,{doc:E,lookupAttribute:k(l.data),buttons:a.buttons,questions:a.questions})),e.createElement(p,{draftMode:l.draftMode,muted:i,toggleMuted:s.voiceType!==o.NONE?()=>d({kind:"toggleMuted"}):void 0,close:u.closeDisabled?void 0:()=>s.flowXButtonBehavior===n.DISMISS||h?r.endFlow(l,{endReason:t.USER_CLOSED}):d({kind:"showMenu"})}))};function U(e,t){if(!e)return"";"string"==typeof e&&(e=f(e));const o=[],n=/[.!?;,]$/;function s(){const e=(o[o.length-1]||"").trim();e&&!e.match(n)&&o.push(".")}function r(e){e.forEach((e=>function(e){if(w(e)){if(e.text&&!e.silent){const t=e.text.split("\n");t.forEach(((e,n)=>{o.push(e),n<t.length-1&&(s(),o.push("\n"))}))}}else switch(e.type){case"attribute":{const n=h(e,t);n&&o.push(n);break}default:r(e.children),["link"].includes(e.type)||(s(),o.push("\n\n"))}}(e)))}return r(e.children),o.join("").trim().replace(new RegExp(String.fromCharCode(160),"g")," ").replace(new RegExp(String.fromCharCode(8),"g"),"")}const Y=({bubbleFrame:t,theme:n})=>{const s=L(),{dispatch:r}=le(),{muted:l,session:a,step:i}=ae(),c=s.getAudio();e.useEffect((()=>{const e=()=>{r({kind:"speechPlaying"})},t=()=>{r({kind:"speechStopped"})};return c.addEventListener("playing",e),c.addEventListener("ended",t),c.addEventListener("pause",t),()=>{c.removeEventListener("playing",e),c.removeEventListener("ended",t),c.removeEventListener("pause",t),c.pause(),c.src="",r({kind:"speechStopped"})}}),[r,c]),e.useEffect((()=>{if(s.audioReady)return;const e=t&&"IFRAME"===t.tagName?t.contentWindow:null;const o=()=>{window.removeEventListener("mousedown",n),e&&e.removeEventListener("mousedown",n)},n=()=>{o(),s.playAudio(null)};return window.addEventListener("mousedown",n),e&&e.addEventListener("mousedown",n),o}),[t,s]);const u=e.useRef(a),d=e.useRef(n),p=e.useRef(i);return e.useEffect((()=>{u.current=a,d.current=n,p.current=i}),[a,n,i]),e.useEffect((()=>{if(!s.audioReady||l)return void s.pauseAudio();let e=!1;return(async()=>{if(await new Promise((e=>setTimeout(e,1))),e)return;const t=await async function(e,t,n,s){if(n.voiceType===o.SYNTHETIC&&"string"==typeof n.syntheticVoice&&s.content){e.ensureIdentified();const o=k(t.data),r=U(s.content,o);return e.getStepSpeech(n.syntheticVoice,r)}if(n.voiceType===o.MANUAL&&s.speechAsset)return s.speechAsset.assetUrl;return null}(s,u.current,d.current,p.current);e||t&&s.playAudio(t)})(),()=>{e=!0}}),[l,s,i.id,n.voiceType,n.syntheticVoice]),null};const z=e.forwardRef(((t,o)=>{const n=I();return e.createElement("div",{ref:o,className:"userflowjs-out-of-viewport-pointer",style:{zIndex:n+2}},e.createElement(P,{icon:D}))}));function G(e,t){const o=e.current;o&&(o.classList.toggle("userflowjs-out-of-viewport-pointer--visible",null!=t),t&&(o.style.left=t.left+"px",o.style.top=t.top+"px",o.classList.toggle("userflowjs-out-of-viewport-pointer--visible-up","up"===t.direction),o.classList.toggle("userflowjs-out-of-viewport-pointer--visible-down","down"===t.direction)))}const H=()=>{const{step:t}=ae();return e.createElement(e.Fragment,null,t.beacons.map((t=>e.createElement(X,{key:t.id,beacon:t}))))},X=({beacon:t})=>{const{session:o}=ae(),n=I(),s=e.useRef(null),r=e.useRef(null),l=g(t.hiddenCondition),a=e.useMemo((()=>R(t.selector,o.data)),[t.selector,o.data]),i=e.useCallback((({targetRect:e,clipEl:o,viewportClipRect:n})=>{const l=function({beacon:e,beaconRef:t,clipEl:o,viewportClipRect:n,targetRect:s}){if(!t.current)return null;if(0===s.width||0===s.height)return null;const r=16,l=16,a=S(o);let i=0,c=0;switch(e.placement){case"top-left":case"left":case"bottom-left":i=s.left;break;case"top":case"center":case"bottom":i=s.left+s.width/2;break;default:i=s.left+s.width}switch(e.placement){case"left":case"center":case"right":c=s.top+s.height/2;break;case"bottom-left":case"bottom":case"bottom-right":c=s.top+s.height;break;default:c=s.top}i-=r/2,c-=l/2,i+=e.offsetX,c+=e.offsetY,i=Math.max(i,a.left-(o===document.documentElement?0:o.scrollLeft)),c=Math.max(c,a.top-(o===document.documentElement?0:o.scrollTop));const u=i+r,d=c+l,p=Math.min(32,.5*l);let m;m=d<n.top+p?"up":c>n.bottom-p?"down":null;return{top:c,right:u,bottom:d,left:i,width:r,height:l,pointerSubjectPosition:{direction:m,left:i,width:r},visible:null==m}}({beacon:t,beaconRef:s,clipEl:o,viewportClipRect:n,targetRect:e}),a=l&&function({subjectPosition:e,pointerRef:t,viewportClipRect:o}){const n=t.current;if(!n)return null;const s=n.getBoundingClientRect(),r=j(T());let l,a,i=e.direction;return null==i?null:("down"===i&&o.bottom<s.height/2?i="up":"up"===i&&o.top>r&&(i="down"),l=e.left+e.width/2-s.width/2,a="down"===i?o.bottom-s.height:o.top,{direction:i,left:l,top:a})}({subjectPosition:l.pointerSubjectPosition,pointerRef:r,viewportClipRect:n});C((()=>{K(s,l),G(r,a)}))}),[t]),c=e.useCallback((()=>{K(s,null),G(r,null)}),[]);return F({selector:l?null:a,targetMoved:i,targetLost:c}),e.createElement(e.Fragment,null,e.createElement("div",{ref:s,className:"userflowjs-beacon userflowjs-beacon--pulse userflowjs-beacon--for-flow userflowjs-fixed-widget",style:{zIndex:n+2}},e.createElement("div",{className:"userflowjs-beacon__ring"}),e.createElement("div",{className:"userflowjs-beacon__ring"})),e.createElement(z,{ref:r}))};function K(e,t){const o=e.current;o&&(o.classList.toggle("userflowjs-fixed-widget--visible",null!=t),t&&(o.style.transform=`translate3d(${t.left}px, ${t.top}px, 0)`,o.style.visibility=t.visible?"visible":"hidden"))}const W=()=>{const{t:o}=_(),n=L(),{restart:l}=le(),{session:a,step:i}=ae(),c=i.theme||a.version.theme,u=i.selector,d=!u||u.type===s.AUTO&&!u.autoData,m=()=>n.endFlow(a,{endReason:t.USER_CLOSED});return e.createElement(e.Fragment,null,e.createElement(p,{draftMode:a.draftMode,close:m}),a.draftMode&&d?e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"No tooltip target selected yet. Please go back to the Builder and select a tooltip target in ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name),".")):a.draftMode&&c.tooltipMissingBehavior===r.END?e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.createElement("p",null,e.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name)," was not found within"," ",c.tooltipMissingToleranceSeconds," ",1===parseFloat(c.tooltipMissingToleranceSeconds)?"second":"seconds","."),e.createElement("p",null,"For regular users, the flow will auto-dismiss when this happens."),e.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),e.createElement("p",null,"Read more in our"," ",e.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-bubble-content"},a.draftMode&&e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name)," was not found on the page. If you are on the right page, then try reselecting the element in the Builder."),e.createElement("p",null,e.createElement("b",null,o("tooltipTargetMissing.line1"))),e.createElement("p",null,o("tooltipTargetMissing.line2"))),e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement(E,{appearance:"primary",onClick:l,text:o("menu.restart")}),e.createElement(E,{appearance:"default",onClick:m,text:o("menu.close")}))))},$=({session:o,checklistSession:n,resourceCenterEmbedsChecklist:s})=>{const d=L(),[p,m]=e.useState(!1),[f,b]=e.useState(null),[w,h]=e.useReducer(Z,void 0,(()=>{const e=o,t=ee(e);return{...Q,session:e,step:t,muted:!!l.getItem("flowsMuted"),autoFocusRequested:oe(t)}})),{session:g,step:E,speechPlaying:k,contentType:j}=w,{version:T}=g,S=ne(E);let F=0;E.questions.some((e=>e.type===i.NPS))&&(F=420);const C=B(E.theme||T.theme),I=e.useMemo((()=>{let e=C.bubbleY;const t=n?.version.theme;return!s&&n&&t&&n.version.checklist?.launcherEnabled&&E.appearance===a.BUBBLE&&t.checklistLauncherPlacement===C.bubblePlacement&&(C.avatarType===c.NONE||t.checklistLauncherX<C.bubbleX+C.avatarSize)&&(e=Math.max(C.bubbleY,t.checklistLauncherY+t.checklistLauncherHeight+C.bubbleY)),{...C,bubbleWidth:Math.max(C.bubbleWidth,F),bubbleY:e}}),[s,n,E.appearance,C,F]);e.useEffect((()=>{g!==o&&h({kind:"updateSession",session:o});const e=e=>{e.session.id===g.id&&h({kind:"goToStep",stepId:e.step.id})};return d.on("gotostep",e),()=>{d.off("gotostep",e)}}),[d,g,o]);const D=e.useMemo((()=>({dispatch:h,restart:()=>{d.goToStep(g,te(g)),h({kind:"showFlow"})}})),[d,h,g]),P=e.useMemo((()=>E.selector&&R(E.selector,g.data)),[E.selector,g.data]),q=e.useCallback((()=>{v(d,g,E.actions)}),[d,g,E.actions]);e.useEffect((()=>{w.muted?l.setItem("flowsMuted","true"):l.removeItem("flowsMuted")}),[w.muted]);const _=g.locale?g.locale.standardLocaleId:I.languageId;e.useEffect((()=>{M.changeLanguage(_)}),[_]);const[O,U]=e.useState(!1),Y=e.useCallback((e=>{U(e),e&&d.send({kind:"ReportTooltipTargetMissing",sessionId:g.id,stepId:E.id}),e&&I.tooltipMissingBehavior===r.END&&!g.draftMode&&d.endFlow(g,{endReason:t.TOOLTIP_TARGET_MISSING})}),[d,g,E.id,I.tooltipMissingBehavior]);return e.useEffect((()=>{if(!p||!w.autoFocusRequested)return;d.originalActiveElement||d.originalActiveElement===f?.ownerDocument.defaultView?.frameElement||(d.originalActiveElement=document.activeElement);let e=f?.querySelector('button:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), [tabindex]:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), input, textarea');if(e&&e.matches(".userflowjs-bubble-buttons button:not(.userflowjs-bubble-button--primary)")){const t=f?.querySelector(".userflowjs-bubble-buttons .userflowjs-bubble-button--primary");t&&(e=t)}e&&"function"==typeof e.focus&&e.focus({preventScroll:!0}),h({kind:"autoFocused"})}),[d,f,p,w.autoFocusRequested]),e.useEffect((()=>{const e=f?.ownerDocument.defaultView;if(!e)return;const t=()=>{h({kind:"focusOut"}),delete d.originalActiveElement},o=()=>{h({kind:"focusIn"})};return window.addEventListener("focusin",t),e.addEventListener("focusin",o),()=>{window.removeEventListener("focusin",t),e.removeEventListener("focusin",o)}}),[f,d]),e.useEffect((()=>{if(!S||!f)return;const e=f.ownerDocument.defaultView,o=e?e.document:document,n=e=>{if("Escape"!==e.key||T.closeDisabled){if("Tab"===e.key){const t=f.querySelectorAll('button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea'),n=t[0],s=t[t.length-1],r=o.activeElement;e.shiftKey?r===n&&(e.preventDefault(),s.focus()):r===s&&(e.preventDefault(),n.focus())}}else d.endFlow(g,{endReason:t.USER_CLOSED})};return window.addEventListener("keydown",n),e?.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n),e?.removeEventListener("keydown",n)}}),[S,d,g,f,T.closeDisabled]),e.useEffect((()=>{if(w.scrollToTopRequested){if(f?.ownerDocument.defaultView?.frameElement){const e=f?.ownerDocument.body;e&&(e.scrollTop=0)}h({kind:"scrolledToTop"})}}),[w.scrollToTopRequested,f]),e.createElement(se.Provider,{value:D},e.createElement(re.Provider,{value:w},e.createElement(y.Provider,{value:g},e.createElement(N,null,e.createElement(x,{company:g.flow.company,theme:I,position:"fixed",stepKey:E.crossVersionId,stepAppearance:E.appearance,width:E.width,backgroundImageUrl:"flow"===j&&!O&&E.backgroundAsset?E.backgroundAsset.assetUrl:null,tooltipSelector:P,tooltipPlacement:E.tooltipPlacement,backdrop:E.backdrop,tooltipTargetBlocked:E.tooltipTargetBlocked,backdropPadding:E.backdropPadding,onTooltipTargetClick:q,onTooltipTargetMissingChange:Y,onModalBackdropClick:E.appearance!==a.MODAL||I.modalBackdropOnclick!==u.DISMISS||T.closeDisabled?void 0:()=>d.endFlow(g,{endReason:t.USER_CLOSED}),speaking:k,minimizeOnAvatarClick:!0,autoHide3pEnabled:!0,onVisibleChange:m,bubbleFrameRootRef:b,rootChildren:t=>e.createElement(J,{...t,theme:I})},"menu"===j?e.createElement(A,null):O&&I.tooltipMissingBehavior!==r.BUBBLE?e.createElement(W,null):e.createElement(V,{theme:I}))))))},J=({visible:t,bubbleFrame:o,theme:n})=>{const s=ae(),{step:r}=s,l=s.session.currentStep&&s.session.currentStep.id,[a,i]=e.useState(!1),c=e.useRef(l);return e.useEffect((()=>{t?i(!0):c.current!==l&&i(!1),c.current=l}),[l,t]),e.createElement(e.Fragment,null,(t||a)&&"flow"===s.contentType&&e.createElement(e.Fragment,null,e.createElement(Y,{bubbleFrame:o,theme:n}),e.createElement(H,null)),r.triggers.map((t=>e.createElement(q,{key:t.id,trigger:t}))))},Q={muted:!1,speechPlaying:!1,contentType:"flow",autoFocusRequested:!1,hasFocus:!1,scrollToTopRequested:!1,shouldLabelDialog:!0};function Z(e,t){switch(t.kind){case"updateSession":{let o;return o=t.session.id===e.session.id&&t.session.version.steps.find((({crossVersionId:t})=>t===e.step.crossVersionId))||ee(t.session),{...e,session:t.session,step:o}}case"goToStep":{const o=e.session.version.steps.find((e=>e.id===t.stepId));return o?{...e,step:o,contentType:"flow",autoFocusRequested:e.hasFocus||oe(o),scrollToTopRequested:!0,shouldLabelDialog:!e.hasFocus}:e}case"toggleMuted":return{...e,muted:!e.muted};case"speechPlaying":return{...e,speechPlaying:!0};case"speechStopped":return{...e,speechPlaying:!1};case"showFlow":return{...e,contentType:"flow",autoFocusRequested:!0,scrollToTopRequested:!0};case"showMenu":return{...e,contentType:"menu",autoFocusRequested:!0,scrollToTopRequested:!0};case"autoFocused":return{...e,autoFocusRequested:!1};case"focusIn":return{...e,hasFocus:!0};case"focusOut":return{...e,hasFocus:!1};case"scrolledToTop":return{...e,scrollToTopRequested:!1}}}function ee(e){const{currentStep:t}=e,{steps:o}=e.version;if(t){const e=o.find((({crossVersionId:e})=>e===t.crossVersionId));if(!e)throw new d("Session points to an unknown step: "+t.crossVersionId);return e}return te(e)}function te(e){const t=e.version.steps[0];if(!t)throw new d("Session has no current step and its version has no start step");return t}function oe(e){return ne(e)}function ne(e){return e.appearance===a.MODAL||e.appearance===a.BUBBLE&&e.backdrop||e.appearance===a.TOOLTIP&&e.tooltipTargetBlocked}const se=e.createContext(null),re=e.createContext(null);function le(){return e.useContext(se)}function ae(){return e.useContext(re)}export default $;export{$ as FlowApp,re as FlowStateContext,Q as initialFlowState,ne as isStepModal,le as useFlowDispatch,ae as useFlowState};
1
+ import{r as e}from"./vendor.react.js";import{E as t,V as o,J as n,b as s,K as r,H as l,L as a,x as i,D as c,M as u,U as d}from"./userflow.js";import{B as p}from"./BubbleToolbar.js";import{m,d as f,R as b,i as h,g as w,u as g,c as E,h as v,S as y}from"./bubble-frame.styl.js";import{b as k,z as j,a as T,t as S,r as R}from"./flow-condition-types.js";import{u as L,i as M}from"./client-context.js";import{F as x}from"./FlowChrome.js";import{u as F,r as C}from"./use-selector-element-monitoring.js";import{a as I,S as N}from"./flow-host.styl.js";import{m as D}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as P,u as B}from"./stylesheets.js";import{T as q}from"./Trigger.js";import{u as _}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.obj-str.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.js";import"./vendor.babel.runtime.js";const A=()=>{const{t:o}=_(),n=L(),{dispatch:s,restart:r}=le(),{session:l,step:a}=ae(),i="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return e.createElement("div",{role:"dialog","aria-modal":ne(a)?"true":void 0,"aria-label":"Guide menu"},e.createElement("div",{className:"userflowjs-bubble-menu__title"},o("menu.title")),e.createElement("button",{className:i,onClick:()=>n.endFlow(l,{endReason:t.USER_CLOSED})},o("menu.close")),l.version.restartEnabled&&e.createElement("button",{className:i,onClick:r},o("menu.restart")),e.createElement("button",{className:i,onClick:()=>s({kind:"showFlow"})},o("menu.back")))},O=({progress:t})=>{const o={width:100*parseFloat(t||"0")+"%"};return e.createElement("div",{className:"userflowjs-bubble-progress"},e.createElement("div",{className:"userflowjs-bubble-progress__fill",style:o}))},V=({theme:s})=>{const r=L(),{session:l,step:a,muted:i,shouldLabelDialog:c}=ae(),{version:u}=l,{dispatch:d}=le(),h=u.steps[0],w=h&&h.id===a.id,g=w&&"1"===a.progress,E=e.useMemo((()=>a.content&&m(f(a.content),{buttons:a.buttons,questions:a.questions})),[a.content,a.buttons,a.questions]);return e.createElement("div",{key:a.id,role:"alertdialog","aria-modal":ne(a)?"true":void 0,"aria-label":c?"Guide":void 0},!g&&e.createElement(O,{progress:a.progress}),e.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},e.createElement(b,{doc:E,lookupAttribute:k(l.data),buttons:a.buttons,questions:a.questions})),e.createElement(p,{draftMode:l.draftMode,muted:i,toggleMuted:s.voiceType!==o.NONE?()=>d({kind:"toggleMuted"}):void 0,close:u.closeDisabled?void 0:()=>s.flowXButtonBehavior===n.DISMISS||w?r.endFlow(l,{endReason:t.USER_CLOSED}):d({kind:"showMenu"})}))};function U(e,t){if(!e)return"";"string"==typeof e&&(e=f(e));const o=[],n=/[.!?;,]$/;function s(){const e=(o[o.length-1]||"").trim();e&&!e.match(n)&&o.push(".")}function r(e){e.forEach((e=>function(e){if(h(e)){if(e.text&&!e.silent){const t=e.text.split("\n");t.forEach(((e,n)=>{o.push(e),n<t.length-1&&(s(),o.push("\n"))}))}}else switch(e.type){case"attribute":{const n=w(e,t);n&&o.push(n);break}default:r(e.children),["link"].includes(e.type)||(s(),o.push("\n\n"))}}(e)))}return r(e.children),o.join("").trim().replace(new RegExp(String.fromCharCode(160),"g")," ").replace(new RegExp(String.fromCharCode(8),"g"),"")}const z=({bubbleFrame:t,theme:n})=>{const s=L(),{dispatch:r}=le(),{muted:l,session:a,step:i}=ae(),c=s.getAudio();e.useEffect((()=>{const e=()=>{r({kind:"speechPlaying"})},t=()=>{r({kind:"speechStopped"})};return c.addEventListener("playing",e),c.addEventListener("ended",t),c.addEventListener("pause",t),()=>{c.removeEventListener("playing",e),c.removeEventListener("ended",t),c.removeEventListener("pause",t),c.pause(),c.src="",r({kind:"speechStopped"})}}),[r,c]),e.useEffect((()=>{if(s.audioReady)return;const e=t&&"IFRAME"===t.tagName?t.contentWindow:null;const o=()=>{window.removeEventListener("mousedown",n),e&&e.removeEventListener("mousedown",n)},n=()=>{o(),s.playAudio(null)};return window.addEventListener("mousedown",n),e&&e.addEventListener("mousedown",n),o}),[t,s]);const u=e.useRef(a),d=e.useRef(n),p=e.useRef(i);return e.useEffect((()=>{u.current=a,d.current=n,p.current=i}),[a,n,i]),e.useEffect((()=>{if(!s.audioReady||l)return void s.pauseAudio();let e=!1;return(async()=>{if(await new Promise((e=>setTimeout(e,1))),e)return;const t=await async function(e,t,n,s){if(n.voiceType===o.SYNTHETIC&&"string"==typeof n.syntheticVoice&&s.content){e.ensureIdentified();const o=k(t.data),r=U(s.content,o);return e.getStepSpeech(n.syntheticVoice,r)}if(n.voiceType===o.MANUAL&&s.speechAsset)return s.speechAsset.assetUrl;return null}(s,u.current,d.current,p.current);e||t&&s.playAudio(t)})(),()=>{e=!0}}),[l,s,i.id,n.voiceType,n.syntheticVoice]),null};const Y=e.forwardRef(((t,o)=>{const n=I();return e.createElement("div",{ref:o,className:"userflowjs-out-of-viewport-pointer",style:{zIndex:n+2}},e.createElement(P,{icon:D}))}));function G(e,t){const o=e.current;o&&(o.classList.toggle("userflowjs-out-of-viewport-pointer--visible",null!=t),t&&(o.style.left=t.left+"px",o.style.top=t.top+"px",o.classList.toggle("userflowjs-out-of-viewport-pointer--visible-up","up"===t.direction),o.classList.toggle("userflowjs-out-of-viewport-pointer--visible-down","down"===t.direction)))}const H=({theme:t})=>{const{step:o}=ae();return e.createElement(e.Fragment,null,o.beacons.map((o=>e.createElement(X,{key:o.id,beacon:o,theme:t}))))},X=({beacon:t,theme:o})=>{const{session:n}=ae(),s=I(),r=e.useRef(null),l=e.useRef(null),a=g(t.hiddenCondition),i=e.useMemo((()=>S(t.selector,n.data)),[t.selector,n.data]),c=e.useCallback((({targetRect:e,clipEl:n,viewportClipRect:s})=>{const a=function({beacon:e,beaconRef:t,clipEl:o,viewportClipRect:n,targetRect:s,theme:r}){if(!t.current)return null;if(0===s.width||0===s.height)return null;const l=r.beaconSize,a=r.beaconSize,i=R(o);let c=0,u=0;switch(e.placement){case"top-left":case"left":case"bottom-left":c=s.left;break;case"top":case"center":case"bottom":c=s.left+s.width/2;break;default:c=s.left+s.width}switch(e.placement){case"left":case"center":case"right":u=s.top+s.height/2;break;case"bottom-left":case"bottom":case"bottom-right":u=s.top+s.height;break;default:u=s.top}c-=l/2,u-=a/2,c+=e.offsetX,u+=e.offsetY,c=Math.max(c,i.left-(o===document.documentElement?0:o.scrollLeft)),u=Math.max(u,i.top-(o===document.documentElement?0:o.scrollTop));const d=c+l,p=u+a,m=Math.min(32,.5*a);let f;f=p<n.top+m?"up":u>n.bottom-m?"down":null;return{top:u,right:d,bottom:p,left:c,width:l,height:a,pointerSubjectPosition:{direction:f,left:c,width:l},visible:null==f}}({beacon:t,beaconRef:r,clipEl:n,viewportClipRect:s,targetRect:e,theme:o}),i=a&&function({subjectPosition:e,pointerRef:t,viewportClipRect:o}){const n=t.current;if(!n)return null;const s=n.getBoundingClientRect(),r=j(T());let l,a,i=e.direction;return null==i?null:("down"===i&&o.bottom<s.height/2?i="up":"up"===i&&o.top>r&&(i="down"),l=e.left+e.width/2-s.width/2,a="down"===i?o.bottom-s.height:o.top,{direction:i,left:l,top:a})}({subjectPosition:a.pointerSubjectPosition,pointerRef:l,viewportClipRect:s});C((()=>{K(r,a),G(l,i)}))}),[t]),u=e.useCallback((()=>{K(r,null),G(l,null)}),[]);return F({selector:a?null:i,targetMoved:c,targetLost:u}),e.createElement(e.Fragment,null,e.createElement("div",{ref:r,className:"userflowjs-beacon userflowjs-beacon--pulse userflowjs-beacon--for-flow userflowjs-fixed-widget",style:{zIndex:s+2}},e.createElement("div",{className:"userflowjs-beacon__ring"}),e.createElement("div",{className:"userflowjs-beacon__ring"})),e.createElement(Y,{ref:l}))};function K(e,t){const o=e.current;o&&(o.classList.toggle("userflowjs-fixed-widget--visible",null!=t),t&&(o.style.transform=`translate3d(${t.left}px, ${t.top}px, 0)`,o.style.visibility=t.visible?"visible":"hidden"))}const W=()=>{const{t:o}=_(),n=L(),{restart:l}=le(),{session:a,step:i}=ae(),c=i.theme||a.version.theme,u=i.selector,d=!u||u.type===s.AUTO&&!u.autoData,m=()=>n.endFlow(a,{endReason:t.USER_CLOSED});return e.createElement(e.Fragment,null,e.createElement(p,{draftMode:a.draftMode,close:m}),a.draftMode&&d?e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"No tooltip target selected yet. Please go back to the Builder and select a tooltip target in ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name),".")):a.draftMode&&c.tooltipMissingBehavior===r.END?e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.createElement("p",null,e.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name)," was not found within"," ",c.tooltipMissingToleranceSeconds," ",1===parseFloat(c.tooltipMissingToleranceSeconds)?"second":"seconds","."),e.createElement("p",null,"For regular users, the flow will auto-dismiss when this happens."),e.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),e.createElement("p",null,"Read more in our"," ",e.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-bubble-content"},a.draftMode&&e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name)," was not found on the page. If you are on the right page, then try reselecting the element in the Builder."),e.createElement("p",null,e.createElement("b",null,o("tooltipTargetMissing.line1"))),e.createElement("p",null,o("tooltipTargetMissing.line2"))),e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement(E,{appearance:"primary",onClick:l,text:o("menu.restart")}),e.createElement(E,{appearance:"default",onClick:m,text:o("menu.close")}))))},$=({session:o,checklistSession:n,resourceCenterEmbedsChecklist:s})=>{const d=L(),[p,m]=e.useState(!1),[f,b]=e.useState(null),[h,w]=e.useReducer(Z,void 0,(()=>{const e=o,t=ee(e);return{...Q,session:e,step:t,muted:!!l.getItem("flowsMuted"),autoFocusRequested:oe(t)}})),{session:g,step:E,speechPlaying:k,contentType:j}=h,{version:T}=g,R=ne(E);let F=0;E.questions.some((e=>e.type===i.NPS))&&(F=420);const C=B(E.theme||T.theme),I=e.useMemo((()=>{let e=C.bubbleY;const t=n?.version.theme;return!s&&n&&t&&n.version.checklist?.launcherEnabled&&E.appearance===a.BUBBLE&&t.checklistLauncherPlacement===C.bubblePlacement&&(C.avatarType===c.NONE||t.checklistLauncherX<C.bubbleX+C.avatarSize)&&(e=Math.max(C.bubbleY,t.checklistLauncherY+t.checklistLauncherHeight+C.bubbleY)),{...C,bubbleWidth:Math.max(C.bubbleWidth,F),bubbleY:e}}),[s,n,E.appearance,C,F]);e.useEffect((()=>{g!==o&&w({kind:"updateSession",session:o});const e=e=>{e.session.id===g.id&&w({kind:"goToStep",stepId:e.step.id})};return d.on("gotostep",e),()=>{d.off("gotostep",e)}}),[d,g,o]);const D=e.useMemo((()=>({dispatch:w,restart:()=>{d.goToStep(g,te(g)),w({kind:"showFlow"})}})),[d,w,g]),P=e.useMemo((()=>E.selector&&S(E.selector,g.data)),[E.selector,g.data]),q=e.useCallback((()=>{v(d,g,E.actions)}),[d,g,E.actions]);e.useEffect((()=>{h.muted?l.setItem("flowsMuted","true"):l.removeItem("flowsMuted")}),[h.muted]);const _=g.locale?g.locale.standardLocaleId:I.languageId;e.useEffect((()=>{M.changeLanguage(_)}),[_]);const[O,U]=e.useState(!1),z=e.useCallback((e=>{U(e),e&&d.send({kind:"ReportTooltipTargetMissing",sessionId:g.id,stepId:E.id}),e&&I.tooltipMissingBehavior===r.END&&!g.draftMode&&d.endFlow(g,{endReason:t.TOOLTIP_TARGET_MISSING})}),[d,g,E.id,I.tooltipMissingBehavior]);return e.useEffect((()=>{if(!p||!h.autoFocusRequested)return;d.originalActiveElement||d.originalActiveElement===f?.ownerDocument.defaultView?.frameElement||(d.originalActiveElement=document.activeElement);let e=f?.querySelector('button:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), [tabindex]:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), input, textarea');if(e&&e.matches(".userflowjs-bubble-buttons button:not(.userflowjs-bubble-button--primary)")){const t=f?.querySelector(".userflowjs-bubble-buttons .userflowjs-bubble-button--primary");t&&(e=t)}e&&"function"==typeof e.focus&&e.focus({preventScroll:!0}),w({kind:"autoFocused"})}),[d,f,p,h.autoFocusRequested]),e.useEffect((()=>{const e=f?.ownerDocument.defaultView;if(!e)return;const t=()=>{w({kind:"focusOut"}),delete d.originalActiveElement},o=()=>{w({kind:"focusIn"})};return window.addEventListener("focusin",t),e.addEventListener("focusin",o),()=>{window.removeEventListener("focusin",t),e.removeEventListener("focusin",o)}}),[f,d]),e.useEffect((()=>{if(!R||!f)return;const e=f.ownerDocument.defaultView,o=e?e.document:document,n=e=>{if("Escape"!==e.key||T.closeDisabled){if("Tab"===e.key){const t=f.querySelectorAll('button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea'),n=t[0],s=t[t.length-1],r=o.activeElement;e.shiftKey?r===n&&(e.preventDefault(),s.focus()):r===s&&(e.preventDefault(),n.focus())}}else d.endFlow(g,{endReason:t.USER_CLOSED})};return window.addEventListener("keydown",n),e?.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n),e?.removeEventListener("keydown",n)}}),[R,d,g,f,T.closeDisabled]),e.useEffect((()=>{if(h.scrollToTopRequested){if(f?.ownerDocument.defaultView?.frameElement){const e=f?.ownerDocument.body;e&&(e.scrollTop=0)}w({kind:"scrolledToTop"})}}),[h.scrollToTopRequested,f]),e.createElement(se.Provider,{value:D},e.createElement(re.Provider,{value:h},e.createElement(y.Provider,{value:g},e.createElement(N,null,e.createElement(x,{company:g.flow.company,theme:I,position:"fixed",stepKey:E.crossVersionId,stepAppearance:E.appearance,width:E.width,backgroundImageUrl:"flow"===j&&!O&&E.backgroundAsset?E.backgroundAsset.assetUrl:null,tooltipSelector:P,tooltipPlacement:E.tooltipPlacement,backdrop:E.backdrop,tooltipTargetBlocked:E.tooltipTargetBlocked,backdropPadding:E.backdropPadding,onTooltipTargetClick:q,onTooltipTargetMissingChange:z,onModalBackdropClick:E.appearance!==a.MODAL||I.modalBackdropOnclick!==u.DISMISS||T.closeDisabled?void 0:()=>d.endFlow(g,{endReason:t.USER_CLOSED}),speaking:k,minimizeOnAvatarClick:!0,autoHide3pEnabled:!0,onVisibleChange:m,bubbleFrameRootRef:b,rootChildren:t=>e.createElement(J,{...t,theme:I})},"menu"===j?e.createElement(A,null):O&&I.tooltipMissingBehavior!==r.BUBBLE?e.createElement(W,null):e.createElement(V,{theme:I}))))))},J=({visible:t,bubbleFrame:o,theme:n})=>{const s=ae(),{step:r}=s,l=s.session.currentStep&&s.session.currentStep.id,[a,i]=e.useState(!1),c=e.useRef(l);return e.useEffect((()=>{t?i(!0):c.current!==l&&i(!1),c.current=l}),[l,t]),e.createElement(e.Fragment,null,(t||a)&&"flow"===s.contentType&&e.createElement(e.Fragment,null,e.createElement(z,{bubbleFrame:o,theme:n}),e.createElement(H,{theme:n})),r.triggers.map((t=>e.createElement(q,{key:t.id,trigger:t}))))},Q={muted:!1,speechPlaying:!1,contentType:"flow",autoFocusRequested:!1,hasFocus:!1,scrollToTopRequested:!1,shouldLabelDialog:!0};function Z(e,t){switch(t.kind){case"updateSession":{let o;return o=t.session.id===e.session.id&&t.session.version.steps.find((({crossVersionId:t})=>t===e.step.crossVersionId))||ee(t.session),{...e,session:t.session,step:o}}case"goToStep":{const o=e.session.version.steps.find((e=>e.id===t.stepId));return o?{...e,step:o,contentType:"flow",autoFocusRequested:e.hasFocus||oe(o),scrollToTopRequested:!0,shouldLabelDialog:!e.hasFocus}:e}case"toggleMuted":return{...e,muted:!e.muted};case"speechPlaying":return{...e,speechPlaying:!0};case"speechStopped":return{...e,speechPlaying:!1};case"showFlow":return{...e,contentType:"flow",autoFocusRequested:!0,scrollToTopRequested:!0};case"showMenu":return{...e,contentType:"menu",autoFocusRequested:!0,scrollToTopRequested:!0};case"autoFocused":return{...e,autoFocusRequested:!1};case"focusIn":return{...e,hasFocus:!0};case"focusOut":return{...e,hasFocus:!1};case"scrolledToTop":return{...e,scrollToTopRequested:!1}}}function ee(e){const{currentStep:t}=e,{steps:o}=e.version;if(t){const e=o.find((({crossVersionId:e})=>e===t.crossVersionId));if(!e)throw new d("Session points to an unknown step: "+t.crossVersionId);return e}return te(e)}function te(e){const t=e.version.steps[0];if(!t)throw new d("Session has no current step and its version has no start step");return t}function oe(e){return ne(e)}function ne(e){return e.appearance===a.MODAL||e.appearance===a.BUBBLE&&e.backdrop||e.appearance===a.TOOLTIP&&e.tooltipTargetBlocked}const se=e.createContext(null),re=e.createContext(null);function le(){return e.useContext(se)}function ae(){return e.useContext(re)}export default $;export{$ as FlowApp,re as FlowStateContext,Q as initialFlowState,ne as isStepModal,le as useFlowDispatch,ae as useFlowState};
package/flow-host.css CHANGED
@@ -194,8 +194,8 @@ _:future,
194
194
  }
195
195
  .userflowjs-beacon {
196
196
  position: relative;
197
- width: 16px;
198
- height: 16px;
197
+ width: var(--userflow-beacon-size);
198
+ height: var(--userflow-beacon-size);
199
199
  background-color: var(--userflow-beacon-color);
200
200
  border-radius: 100%;
201
201
  }
package/hash.txt CHANGED
@@ -1 +1 @@
1
- 7b0054a7545fbf9900d17181149d751b1e9f1977
1
+ 4c4a3c33120fa9332dc069ce449e0a1c6a2fa5ab
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1004474",
3
+ "version": "0.1.1004513",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
package/stylesheets.js CHANGED
@@ -1 +1 @@
1
- import{r as o}from"./vendor.react.js";import{l as r,m as e,k as t,i as n,n as l,h as u,o as a,p as c,q as i,r as d,s,t as g,j as f,u as h,v as B,w as C,x as b,y as k,z as w}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{a as p,b as m,c as v,d as y,e as F,g as H,h as A,i as x,j as M,k as L}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{y as S,z as W,D as I,c as z,G as $}from"./userflow.js";import{c as E}from"./flow-condition-types.js";import{a as j}from"./client-context.js";function T(r){const[e]=o.useState((()=>new S(r)));return e.update(r),e}const q=({icon:r,size:e})=>{e=e||16;const t="string"==typeof r&&P[r]?P[r]:r;if("string"==typeof t)return o.createElement("img",{"aria-hidden":"true",src:t,width:e,height:e,style:{objectFit:"contain"}});{const r=t.icon[0],n=t.icon[1],l=t.icon[4];return o.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:`0 0 ${r} ${n}`},o.createElement("path",{fill:"currentColor",d:String(l)}))}},P={"regular/calendar-day":r,"regular/comment-alt":e,"regular/comments-alt":t,"regular/envelope":n,"regular/exclamation-triangle":l,"regular/external-link":u,"regular/file-alt":a,"regular/graduation-cap":c,"regular/info-circle":i,"regular/lightbulb":d,"regular/megaphone":s,"regular/pencil":g,"regular/phone":f,"regular/play-circle":h,"regular/question-circle":B,"regular/shoe-prints":C,"solid/shoe-prints":p,"solid/file-invoice":m,"solid/receipt":v,"solid/university":y,"solid/users":F,"solid/stars":H,"regular/tasks":b,"regular/user":k,"regular/users":w,"solid/exclamation-triangle":A,"solid/info-circle":x,"solid/play-circle":M,"solid/question-circle":L};function R(o){return o?o.match(/^#[0-9a-f]{6}$/i)?[parseInt(o.substring(1,3),16),parseInt(o.substring(3,5),16),parseInt(o.substring(5,7),16)]:o.match(/^#[0-9a-f]{3}$/i)?[parseInt(o.substring(1,2).repeat(2),16),parseInt(o.substring(2,3).repeat(2),16),parseInt(o.substring(3,4).repeat(2),16)]:[0,0,0]:[0,0,0]}function U([o,r,e]){return"#"+o.toString(16).padStart(2,"0")+r.toString(16).padStart(2,"0")+e.toString(16).padStart(2,"0")}function D(o){const r=R(o);return r?r.join(", "):"0, 0, 0"}function O(o){return U(R(o))}function N(o,r,e){return[Math.max(0,Math.min(255,Math.round(o[0]+(r[0]-o[0])*e))),Math.max(0,Math.min(255,Math.round(o[1]+(r[1]-o[1])*e))),Math.max(0,Math.min(255,Math.round(o[2]+(r[2]-o[2])*e)))]}function G(o,r,e){const t=R(o),n=R(r);return t&&n?U(N(t,n,e)):o}function K([o,r,e]){o/=255,r/=255,e/=255;const t=Math.max(o,r,e),n=Math.min(o,r,e);let l,u,a=(t+n)/2;if(t==n)l=u=0;else{const c=t-n;switch(u=a>.5?c/(2-t-n):c/(t+n),t){case o:l=(r-e)/c+(r<e?6:0);break;case r:l=(e-o)/c+2;break;default:l=(o-r)/c+4}l/=6}return[l,u,a]}function V([o,r,e]){let t=r/255,n=e/255;function l(o){let r=0;return r=o<=.04045?o/12.92:Math.pow((o+.055)/1.055,2.4),r}let u=.2126*l(o/255)+.7152*l(t)+.0722*l(n);return Math.round(10*function(o){let r=0;return r=o<=216/24389?o*(24389/27):116*Math.pow(o,1/3)-16,r}(u))/1e3}function X(o,r){const e=V(o),t=V(r);let n=.13*((1-(t-e))/2)+.05,l=1-Math.abs(t-e),u=n+Math.pow((1-n)*l,4);return Math.round(1e3*u)/1e3}function Y(o,r){const e=R(o),t=K(e);let n=null,l=null;for(const d of r){const o=R(d),r=K(o);let e=!1;if(n&&l){const o=.3;Math.abs(r[2]-t[2])>o?r[1]>l[1]&&(e=!0):Math.abs(t[2]-r[2])>Math.abs(t[2]-l[2])&&(e=!0)}else e=!0;e&&(n=o,l=r)}let u=n,a=n,c=X(u,e),i=2*c;return t[2]>.2&&t[2]<.8&&(a=function([o,r,e]){return[Math.round(255-o),Math.round(255-r),Math.round(255-e)]}(a),i=X(a,e)),[U(N(e,u,c)),U(N(e,a,i))]}function J(o){const[r,e,t,n,l,u,a,c]=function(o,r,e,t){const[n,l]=Y(o,[r]);let u,a;if(o===e)u=n,a=l;else{const n=Y(e,[o,r,t]);u=n[0],a=n[1]}const c=R(o),i=R(e);let d,s,g,f;if(Math.abs(c[0]-i[0])<20&&Math.abs(c[1]-i[1])<20&&Math.abs(c[2]-i[2])<20){d=r,s=o;const e=Y(d,[s]);g=e[0],f=e[1]}else d=o,s=r,g=n,f=l;return[n,l,u,a,d,s,g,f]}(o.brandBackgroundColor,o.brandForegroundColor,o.mainBackgroundColor,o.mainForegroundColor),i={...o,widgetBackgroundColor:l,widgetForegroundColor:u,widgetHoverBackgroundColor:a,widgetActiveBackgroundColor:c,sameBackground:O(o.mainBackgroundColor)==O(o.brandBackgroundColor)};i.brandHoverBackgroundColor&&(i.widgetHoverBackgroundColor=i.brandHoverBackgroundColor),i.brandActiveBackgroundColor&&(i.widgetActiveBackgroundColor=i.brandActiveBackgroundColor),i.brandHoverBackgroundColor||(i.brandHoverBackgroundColor=r),i.brandActiveBackgroundColor||(i.brandActiveBackgroundColor=e),i.mainHoverBackgroundColor||(i.mainHoverBackgroundColor=t),i.mainActiveBackgroundColor||(i.mainActiveBackgroundColor=n),i.bannerBackgroundColor||(i.bannerBackgroundColor=i.brandBackgroundColor),i.bannerForegroundColor||(i.bannerForegroundColor=i.brandForegroundColor);const[d,s]=Y(i.bannerBackgroundColor,[i.bannerForegroundColor]);i.bannerHoverBackgroundColor=d,i.bannerActiveBackgroundColor=s;const[g,f]=Y(i.bannerForegroundColor,[i.bannerBackgroundColor]);if(i.bannerHoverForegroundColor=g,i.bannerActiveForegroundColor=f,i.bubbleBorderColor||(i.bubbleBorderColor=i.mainForegroundColor),i.checklistLauncherActiveBackgroundColor||(i.checklistLauncherActiveBackgroundColor=i.brandActiveBackgroundColor),i.checklistLauncherBackgroundColor||(i.checklistLauncherBackgroundColor=i.brandBackgroundColor),i.checklistLauncherCounterBackgroundColor||(i.checklistLauncherCounterBackgroundColor=i.brandForegroundColor),i.checklistLauncherCounterFontColor||(i.checklistLauncherCounterFontColor=i.brandBackgroundColor),i.checklistLauncherFontColor||(i.checklistLauncherFontColor=i.brandForegroundColor),i.checklistLauncherHoverBackgroundColor||(i.checklistLauncherHoverBackgroundColor=i.brandHoverBackgroundColor),i.focusColor||(i.focusColor=i.mainActiveBackgroundColor),i.launcherIconActiveColor||(i.launcherIconActiveColor=i.brandActiveBackgroundColor),i.launcherIconColor||(i.launcherIconColor=i.brandBackgroundColor),i.launcherIconHoverColor||(i.launcherIconHoverColor=i.brandHoverBackgroundColor),i.linkColor||(i.linkColor=i.widgetBackgroundColor),i.progressBarColor||(i.progressBarColor=i.widgetBackgroundColor),i.questionColor||(i.questionColor=i.widgetBackgroundColor),i.toolbarForegroundColor||(i.toolbarForegroundColor=i.mainForegroundColor),i.primaryButtonBackgroundColor||(i.primaryButtonBackgroundColor=i.widgetBackgroundColor),i.primaryButtonFontColor||(i.primaryButtonFontColor=i.widgetForegroundColor),i.primaryButtonHoverFontColor||(i.primaryButtonHoverFontColor=i.primaryButtonFontColor),i.primaryButtonActiveFontColor||(i.primaryButtonActiveFontColor=i.primaryButtonFontColor),!i.primaryButtonHoverBackgroundColor||!i.primaryButtonActiveBackgroundColor){const[o,r]=Y(i.primaryButtonBackgroundColor,[i.primaryButtonFontColor]);i.primaryButtonHoverBackgroundColor||(i.primaryButtonHoverBackgroundColor=o),i.primaryButtonActiveBackgroundColor||(i.primaryButtonActiveBackgroundColor=r)}if(i.primaryButtonBorderColor||(i.primaryButtonBorderColor=i.widgetBackgroundColor),i.primaryButtonHoverBorderColor||(i.primaryButtonHoverBorderColor=i.primaryButtonHoverBackgroundColor),i.primaryButtonActiveBorderColor||(i.primaryButtonActiveBorderColor=i.primaryButtonActiveBackgroundColor),i.defaultButtonBackgroundColor||(i.defaultButtonBackgroundColor=i.mainBackgroundColor),i.defaultButtonFontColor||(i.defaultButtonFontColor=l),i.defaultButtonHoverFontColor||(i.defaultButtonHoverFontColor=i.defaultButtonFontColor),i.defaultButtonActiveFontColor||(i.defaultButtonActiveFontColor=i.defaultButtonFontColor),!i.defaultButtonHoverBackgroundColor||!i.defaultButtonActiveBackgroundColor){const[o,r]=Y(i.defaultButtonBackgroundColor,[i.defaultButtonFontColor]);i.defaultButtonHoverBackgroundColor||(i.defaultButtonHoverBackgroundColor=o),i.defaultButtonActiveBackgroundColor||(i.defaultButtonActiveBackgroundColor=r)}return i.defaultButtonBorderColor||(i.defaultButtonBorderColor=i.defaultButtonFontColor),i.defaultButtonHoverBorderColor||(i.defaultButtonHoverBorderColor=i.defaultButtonBorderColor),i.defaultButtonActiveBorderColor||(i.defaultButtonActiveBorderColor=i.defaultButtonBorderColor),i.launcherButtonBackgroundColor||(i.launcherButtonBackgroundColor=i.brandBackgroundColor),i.launcherButtonBorderColor||(i.launcherButtonBorderColor=i.brandBackgroundColor),i.launcherButtonFontColor||(i.launcherButtonFontColor=i.brandForegroundColor),i.launcherButtonHoverBackgroundColor||(i.launcherButtonHoverBackgroundColor=i.brandHoverBackgroundColor),i.launcherButtonHoverBorderColor||(i.launcherButtonHoverBorderColor=i.launcherButtonHoverBackgroundColor),i.launcherButtonHoverFontColor||(i.launcherButtonHoverFontColor=i.launcherButtonFontColor),i.launcherButtonActiveBackgroundColor||(i.launcherButtonActiveBackgroundColor=i.brandActiveBackgroundColor),i.launcherButtonActiveBorderColor||(i.launcherButtonActiveBorderColor=i.launcherButtonActiveBackgroundColor),i.launcherButtonActiveFontColor||(i.launcherButtonActiveFontColor=i.launcherButtonFontColor),i}function Q(o){const{questionColor:r}=o;return{"--userflow-backdrop-highlight-color-rgb":D(o.backdropHighlightColor),"--userflow-backdrop-highlight-inset":o.backdropHighlightType===W.INSIDE?"inset":"","--userflow-backdrop-highlight-opacity":o.backdropHighlightOpacity,"--userflow-backdrop-highlight-radius":o.backdropHighlightRadius+"px","--userflow-backdrop-highlight-spread":o.backdropHighlightSpread+"px","--userflow-backdrop-opacity":o.backdropOpacity,"--userflow-banner-background-color":o.bannerBackgroundColor,"--userflow-banner-hover-background-color":o.bannerHoverBackgroundColor,"--userflow-banner-active-background-color":o.bannerActiveBackgroundColor,"--userflow-banner-foreground-color":o.bannerForegroundColor,"--userflow-banner-hover-foreground-color":o.bannerHoverForegroundColor,"--userflow-banner-active-foreground-color":o.bannerActiveForegroundColor,"--userflow-beacon-color":o.beaconColor,"--userflow-brand-active-background-color":o.brandActiveBackgroundColor,"--userflow-brand-background-color":o.brandBackgroundColor,"--userflow-brand-foreground-color":o.brandForegroundColor,"--userflow-brand-foreground-color-rgb":D(o.brandForegroundColor),"--userflow-brand-hover-background-color":o.brandHoverBackgroundColor,"--userflow-bubble-border-color":o.bubbleBorderColor,"--userflow-bubble-border-radius":o.bubbleBorderRadius+"px","--userflow-bubble-border-width":o.bubbleBorderWidth+"px","--userflow-button-border-radius":o.buttonBorderRadius+"px","--userflow-button-height":o.buttonHeight+"px","--userflow-button-min-width":o.buttonMinWidth+"px","--userflow-button-text-align":0===o.buttonMinWidth?"start":"center","--userflow-buttons-justify-content":"left"===o.buttonHorizontalAlign?"start":"right"===o.buttonHorizontalAlign?"end":"center","--userflow-buttons-bubble-justify-content":"left"===o.buttonHorizontalAlign?"start":"center"===o.buttonHorizontalAlign?"center":"end","--userflow-checklist-launcher-active-background-color":o.checklistLauncherActiveBackgroundColor,"--userflow-checklist-launcher-background-color":o.checklistLauncherBackgroundColor,"--userflow-checklist-launcher-border-radius":o.checklistLauncherBorderRadius+"px","--userflow-checklist-launcher-counter-background-color":o.checklistLauncherCounterBackgroundColor,"--userflow-checklist-launcher-counter-font-color":o.checklistLauncherCounterFontColor,"--userflow-checklist-launcher-font-color-rgb":D(o.checklistLauncherFontColor),"--userflow-checklist-launcher-font-color":o.checklistLauncherFontColor,"--userflow-checklist-launcher-font-weight":String(o.checklistLauncherFontWeight),"--userflow-checklist-launcher-height":o.checklistLauncherHeight+"px","--userflow-checklist-launcher-hover-background-color":o.checklistLauncherHoverBackgroundColor,"--userflow-checkmark-background-color":o.checkmarkBackgroundColor,"--userflow-completed-task-text-decoration":o.completedTaskTextDecoration,"--userflow-default-button-active-background-color":o.defaultButtonActiveBackgroundColor,"--userflow-default-button-active-border-color":o.defaultButtonActiveBorderColor,"--userflow-default-button-active-font-color":o.defaultButtonActiveFontColor,"--userflow-default-button-background-color":o.defaultButtonBackgroundColor,"--userflow-default-button-border-color":o.defaultButtonBorderColor,"--userflow-default-button-border-width":o.defaultButtonBorderWidth+"px","--userflow-default-button-font-color":o.defaultButtonFontColor,"--userflow-default-button-font-weight":String(o.defaultButtonFontWeight),"--userflow-default-button-hover-background-color":o.defaultButtonHoverBackgroundColor,"--userflow-default-button-hover-border-color":o.defaultButtonHoverBorderColor,"--userflow-default-button-hover-font-color":o.defaultButtonHoverFontColor,"--userflow-focus-color":`rgba(${D(o.focusColor)}, ${o.focusOpacity})`,"--userflow-font-family":o.builtinFontFamily?o.builtinFontFamily.name+(o.builtinFontFamily.fallback?", "+o.builtinFontFamily.fallback:""):o.fontFamily?o.fontFamily:"sans-serif","--userflow-font-size":o.fontSize+"px","--userflow-font-weight-bold":String(o.fontWeightBold),"--userflow-font-weight-normal":String(o.fontWeightNormal),"--userflow-h1-font-size":o.h1FontSize+"px","--userflow-h2-font-size":o.h2FontSize+"px","--userflow-launcher-button-active-background-color":o.launcherButtonActiveBackgroundColor,"--userflow-launcher-button-active-border-color":o.launcherButtonActiveBorderColor,"--userflow-launcher-button-active-font-color":o.launcherButtonActiveFontColor,"--userflow-launcher-button-background-color":o.launcherButtonBackgroundColor,"--userflow-launcher-button-border-color":o.launcherButtonBorderColor,"--userflow-launcher-button-border-radius":o.launcherButtonBorderRadius+"px","--userflow-launcher-button-border-width":o.launcherButtonBorderWidth+"px","--userflow-launcher-button-font-color":o.launcherButtonFontColor,"--userflow-launcher-button-font-weight":String(o.launcherButtonFontWeight),"--userflow-launcher-button-height":o.launcherButtonHeight+"px","--userflow-launcher-button-horizontal-padding":o.launcherButtonHorizontalPadding+"px","--userflow-launcher-button-hover-background-color":o.launcherButtonHoverBackgroundColor,"--userflow-launcher-button-hover-border-color":o.launcherButtonHoverBorderColor,"--userflow-launcher-button-hover-font-color":o.launcherButtonHoverFontColor,"--userflow-launcher-button-width":o.launcherButtonWidth?o.launcherButtonWidth+"px":"auto","--userflow-launcher-icon-active-color":o.launcherIconActiveColor,"--userflow-launcher-icon-color":o.launcherIconColor,"--userflow-launcher-icon-hover-color":o.launcherIconHoverColor,"--userflow-launcher-icon-opacity":o.launcherIconOpacity,"--userflow-launcher-icon-size":o.launcherIconSize+"px","--userflow-line-height":o.lineHeight+"px","--userflow-link-color":o.linkColor,"--userflow-main-active-background-color":o.mainActiveBackgroundColor,"--userflow-main-background-color":o.mainBackgroundColor,"--userflow-main-background-color-rgb":D(o.mainBackgroundColor),"--userflow-main-foreground-color":o.mainForegroundColor,"--userflow-main-foreground-color-rgb":D(o.mainForegroundColor),"--userflow-main-hover-background-color":o.mainHoverBackgroundColor,"--userflow-modal-padding":o.modalPadding+"px","--userflow-modal-padding-top":(o.avatarType===I.NONE?o.modalPadding:o.modalPadding+Math.max((o.avatarSize-o.modalPadding)/2,0))+"px","--userflow-backdrop-color-rgb":D(o.backdropColor),"--userflow-notch-color":o.bubbleBorderWidth>0&&o.bubbleBorderColor||o.mainBackgroundColor,"--userflow-primary-button-active-background-color":o.primaryButtonActiveBackgroundColor,"--userflow-primary-button-active-border-color":o.primaryButtonActiveBorderColor,"--userflow-primary-button-active-font-color":o.primaryButtonActiveFontColor,"--userflow-primary-button-background-color":o.primaryButtonBackgroundColor,"--userflow-primary-button-border-color":o.primaryButtonBorderColor,"--userflow-primary-button-border-width":o.primaryButtonBorderWidth+"px","--userflow-primary-button-font-color":o.primaryButtonFontColor,"--userflow-primary-button-font-weight":String(o.primaryButtonFontWeight),"--userflow-primary-button-hover-background-color":o.primaryButtonHoverBackgroundColor,"--userflow-primary-button-hover-border-color":o.primaryButtonHoverBorderColor,"--userflow-primary-button-hover-font-color":o.primaryButtonHoverFontColor,"--userflow-progress-bar-color":o.progressBarColor,"--userflow-progress-bar-height":o.progressBarHeight+"px","--userflow-resource-center-collapsed-height":o.resourceCenterCollapsedHeight+"px","--userflow-resource-center-full-width":o.resourceCenterFullWidth+"px","--userflow-resource-center-launcher-border-radius":(null!=o.resourceCenterLauncherBorderRadius?Math.min(o.resourceCenterLauncherBorderRadius,o.resourceCenterCollapsedHeight/2):o.resourceCenterCollapsedHeight/2)+"px","--userflow-resource-center-padding-x":o.resourceCenterPaddingX+"px","--userflow-resource-center-padding-y":o.resourceCenterPaddingY+"px","--userflow-resource-center-transition-duration":o.resourceCenterTransitionDuration+"ms","--userflow-resource-center-width":o.resourceCenterWidth+"px","--userflow-question-color-light":G(r,o.mainBackgroundColor,.5),"--userflow-question-color-lighter":G(r,o.mainBackgroundColor,.75),"--userflow-question-color-lightest":G(r,o.mainBackgroundColor,.9),"--userflow-question-color-medium-light":G(r,o.mainBackgroundColor,.15),"--userflow-question-color":r,"--userflow-toolbar-foreground-color":o.toolbarForegroundColor,"--userflow-toolbar-foreground-color-rgb":D(o.toolbarForegroundColor),"--userflow-tooltip-notch-size":o.tooltipNotchSize+"px","--userflow-unread-badge-background-color":o.unreadBadgeBackgroundColor,"--userflow-unread-badge-foreground-color":o.unreadBadgeForegroundColor,"--userflow-widget-active-background-color":o.widgetActiveBackgroundColor,"--userflow-widget-background-color":o.widgetBackgroundColor,"--userflow-widget-foreground-color":o.widgetForegroundColor,"--userflow-widget-hover-background-color":o.widgetHoverBackgroundColor}}const Z=[];function _(r){let[e,t]=o.useState(r);const n=T(r.sessionData||Z);return o.useLayoutEffect((()=>{const{variations:o}=r;if(!o)return;const e=[],l=[],u=()=>{let n=r,l=!1;for(const[r,t]of o.entries())if(e[r]){l||(l=!0,n={...n});for(const o of t.overriddenKeys)n[o]=t[o]}t(n)};for(const[r,t]of o.entries()){e[r]=!1;const{condition:o}=t;if(o&&t.overriddenKeys&&t.overriddenKeys.length>0){const t=E[o.type].track({sessionData:n,condition:o,callback:o=>{e[r]=o,u()}});l[r]=t}else l[r]=()=>{}}return u(),()=>{for(const o of l)o()}}),[r,n]),o.useMemo((()=>J(e)),[e])}function oo(o){const r=z.serverEndpoint||"cdn.userflow.com";return o?.cssVersion?`https://${r}/themes/${o.id}/stylesheets/${o.cssVersion}/custom.css`:null}const ro=new Map;function eo(o){let r=ro.get(o);return r||(r={stylesheets:new Map},ro.set(o,r)),r}function to(r,e,t,{uninstallOnUnmount:n}={}){const l=j(),[u,a]=o.useState(!e);return o.useLayoutEffect((()=>{if(!r||!e)return;let o,u=!1;const c=async e=>{await uo(l,r,e),o&&ao(r,o),o=e};(async()=>{let o="string"==typeof e?e:e.get();if(window.MSInputMethodContext&&document.documentMode&&t){let r=await function(o){return new Promise(((r,e)=>{let t=no.get(o);if(t)return void r(t);const n=new XMLHttpRequest;n.addEventListener("load",(()=>{if(200!==n.status)return void e(new Error("Userflow.js could not fetch stylesheet: "+o));const t=n.responseText;no.set(o,t),r(t)})),n.addEventListener("error",(()=>{e(new Error("Userflow.js could not fetch stylesheet: "+o))})),n.open("GET",o),n.send()}))}(o);if(u)return;r=function(o,r){for(const e in r)if(r.hasOwnProperty(e)){const t=r[e];t&&(o=o.replace(new RegExp(`var\\(${e}.*?\\)`,"g"),t))}return o=o.replace(/var\(--[a-z0-9-]+(,\s*(.*?))?\)/g,"$2")}(r,Q(t)),o="data:text/css;base64,"+btoa(r)}await c(o),u||a(!0)})();let i=null;return"string"!=typeof e&&(i=e.onUpdate((async()=>{c(e.get())}))),()=>{u=!0,i&&i(),n&&o&&ao(r,o)}}),[l,r,e,t,n]),{loaded:u}}const no=new Map;function lo(r,e){const t=e&&function(o){if(!o.builtinFontFamily)return o.fontCssUrl?{url:o.fontCssUrl,fontFamily:o.fontFamily}:null;switch(o.builtinFontFamily.provider){case $.GOOGLE:{const r=Array.from(new Set(["0,400","1,400",`0,${o.fontWeightBold}`,`0,${o.defaultButtonFontWeight}`,`0,${o.primaryButtonFontWeight}`,`0,${o.checklistLauncherFontWeight}`,`0,${o.launcherButtonFontWeight}`])).sort().join(";");return{url:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(o.builtinFontFamily.name)}:ital,wght@${r}`,fontFamily:o.builtinFontFamily.name}}case $.STANDARD:return null}}(e),n=t?.url,l=t?.fontFamily,[u,a]=o.useState(!n||!l);return o.useLayoutEffect((()=>{if(!r||!n||!l)return;let o=!1;return uo(null,r,n),function(o,r,e){if(!o.document.fonts)return e(),()=>{};let t=!1;const n=()=>{const l=o.document.fonts.load(`100px ${r}`,"BESbswy");if(!l)return u(),void e();l.then((o=>{t||(o.length>=1?(u(),e()):window.setTimeout(n,25))}),(o=>{console.log("Userflow.js: observeFont error:"),console.log(o),e()}))};n();const l=window.setTimeout((()=>{console.warn(`Userflow.js: Timed out waiting for font family ${r} to load. Will continue anyway.`),e()}),2e3),u=()=>{t=!0,window.clearTimeout(void 0),window.clearTimeout(l)}}(r,l,(()=>{o||a(!0)})),()=>{o=!0}}),[r,n,l]),{loaded:u}}function uo(o,r,e){const t=eo(r),n=t.stylesheets.get(e);if(n)return n.loadPromise;const l=r.document.createElement("link"),u=new Promise(((t,n)=>{l.dataset.userflowStylesheet="true",l.rel="stylesheet",l.href=e,l.onload=()=>{t()},l.onerror=r=>{console.log(`Userflow.js: Error installing Stylesheet ${e}:`,r),o&&o.reportCspIssue(),n()},r.document.head.appendChild(l)}));return t.stylesheets.set(e,{link:l,loadPromise:u}),u}function ao(o,r){const e=eo(o),t=e.stylesheets.get(r);t&&(o.document.head.removeChild(t.link),e.stylesheets.delete(r))}export{q as D,to as a,T as b,lo as c,oo as d,Q as g,_ as u};
1
+ import{r as o}from"./vendor.react.js";import{l as r,m as e,k as t,i as n,n as l,h as u,o as a,p as c,q as i,r as d,s,t as g,j as f,u as h,v as B,w as C,x as b,y as k,z as w}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{a as p,b as m,c as v,d as y,e as F,g as H,h as A,i as x,j as M,k as L}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{y as S,z,D as W,c as I,G as $}from"./userflow.js";import{c as E}from"./flow-condition-types.js";import{a as j}from"./client-context.js";function T(r){const[e]=o.useState((()=>new S(r)));return e.update(r),e}const q=({icon:r,size:e})=>{e=e||16;const t="string"==typeof r&&P[r]?P[r]:r;if("string"==typeof t)return o.createElement("img",{"aria-hidden":"true",src:t,width:e,height:e,style:{objectFit:"contain"}});{const r=t.icon[0],n=t.icon[1],l=t.icon[4];return o.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:`0 0 ${r} ${n}`},o.createElement("path",{fill:"currentColor",d:String(l)}))}},P={"regular/calendar-day":r,"regular/comment-alt":e,"regular/comments-alt":t,"regular/envelope":n,"regular/exclamation-triangle":l,"regular/external-link":u,"regular/file-alt":a,"regular/graduation-cap":c,"regular/info-circle":i,"regular/lightbulb":d,"regular/megaphone":s,"regular/pencil":g,"regular/phone":f,"regular/play-circle":h,"regular/question-circle":B,"regular/shoe-prints":C,"solid/shoe-prints":p,"solid/file-invoice":m,"solid/receipt":v,"solid/university":y,"solid/users":F,"solid/stars":H,"regular/tasks":b,"regular/user":k,"regular/users":w,"solid/exclamation-triangle":A,"solid/info-circle":x,"solid/play-circle":M,"solid/question-circle":L};function R(o){return o?o.match(/^#[0-9a-f]{6}$/i)?[parseInt(o.substring(1,3),16),parseInt(o.substring(3,5),16),parseInt(o.substring(5,7),16)]:o.match(/^#[0-9a-f]{3}$/i)?[parseInt(o.substring(1,2).repeat(2),16),parseInt(o.substring(2,3).repeat(2),16),parseInt(o.substring(3,4).repeat(2),16)]:[0,0,0]:[0,0,0]}function U([o,r,e]){return"#"+o.toString(16).padStart(2,"0")+r.toString(16).padStart(2,"0")+e.toString(16).padStart(2,"0")}function D(o){const r=R(o);return r?r.join(", "):"0, 0, 0"}function O(o){return U(R(o))}function N(o,r,e){return[Math.max(0,Math.min(255,Math.round(o[0]+(r[0]-o[0])*e))),Math.max(0,Math.min(255,Math.round(o[1]+(r[1]-o[1])*e))),Math.max(0,Math.min(255,Math.round(o[2]+(r[2]-o[2])*e)))]}function G(o,r,e){const t=R(o),n=R(r);return t&&n?U(N(t,n,e)):o}function K([o,r,e]){o/=255,r/=255,e/=255;const t=Math.max(o,r,e),n=Math.min(o,r,e);let l,u,a=(t+n)/2;if(t==n)l=u=0;else{const c=t-n;switch(u=a>.5?c/(2-t-n):c/(t+n),t){case o:l=(r-e)/c+(r<e?6:0);break;case r:l=(e-o)/c+2;break;default:l=(o-r)/c+4}l/=6}return[l,u,a]}function V([o,r,e]){let t=r/255,n=e/255;function l(o){let r=0;return r=o<=.04045?o/12.92:Math.pow((o+.055)/1.055,2.4),r}let u=.2126*l(o/255)+.7152*l(t)+.0722*l(n);return Math.round(10*function(o){let r=0;return r=o<=216/24389?o*(24389/27):116*Math.pow(o,1/3)-16,r}(u))/1e3}function X(o,r){const e=V(o),t=V(r);let n=.13*((1-(t-e))/2)+.05,l=1-Math.abs(t-e),u=n+Math.pow((1-n)*l,4);return Math.round(1e3*u)/1e3}function Y(o,r){const e=R(o),t=K(e);let n=null,l=null;for(const d of r){const o=R(d),r=K(o);let e=!1;if(n&&l){const o=.3;Math.abs(r[2]-t[2])>o?r[1]>l[1]&&(e=!0):Math.abs(t[2]-r[2])>Math.abs(t[2]-l[2])&&(e=!0)}else e=!0;e&&(n=o,l=r)}let u=n,a=n,c=X(u,e),i=2*c;return t[2]>.2&&t[2]<.8&&(a=function([o,r,e]){return[Math.round(255-o),Math.round(255-r),Math.round(255-e)]}(a),i=X(a,e)),[U(N(e,u,c)),U(N(e,a,i))]}function J(o){const[r,e,t,n,l,u,a,c]=function(o,r,e,t){const[n,l]=Y(o,[r]);let u,a;if(o===e)u=n,a=l;else{const n=Y(e,[o,r,t]);u=n[0],a=n[1]}const c=R(o),i=R(e);let d,s,g,f;if(Math.abs(c[0]-i[0])<20&&Math.abs(c[1]-i[1])<20&&Math.abs(c[2]-i[2])<20){d=r,s=o;const e=Y(d,[s]);g=e[0],f=e[1]}else d=o,s=r,g=n,f=l;return[n,l,u,a,d,s,g,f]}(o.brandBackgroundColor,o.brandForegroundColor,o.mainBackgroundColor,o.mainForegroundColor),i={...o,widgetBackgroundColor:l,widgetForegroundColor:u,widgetHoverBackgroundColor:a,widgetActiveBackgroundColor:c,sameBackground:O(o.mainBackgroundColor)==O(o.brandBackgroundColor)};i.brandHoverBackgroundColor&&(i.widgetHoverBackgroundColor=i.brandHoverBackgroundColor),i.brandActiveBackgroundColor&&(i.widgetActiveBackgroundColor=i.brandActiveBackgroundColor),i.brandHoverBackgroundColor||(i.brandHoverBackgroundColor=r),i.brandActiveBackgroundColor||(i.brandActiveBackgroundColor=e),i.mainHoverBackgroundColor||(i.mainHoverBackgroundColor=t),i.mainActiveBackgroundColor||(i.mainActiveBackgroundColor=n),i.bannerBackgroundColor||(i.bannerBackgroundColor=i.brandBackgroundColor),i.bannerForegroundColor||(i.bannerForegroundColor=i.brandForegroundColor);const[d,s]=Y(i.bannerBackgroundColor,[i.bannerForegroundColor]);i.bannerHoverBackgroundColor=d,i.bannerActiveBackgroundColor=s;const[g,f]=Y(i.bannerForegroundColor,[i.bannerBackgroundColor]);if(i.bannerHoverForegroundColor=g,i.bannerActiveForegroundColor=f,i.bubbleBorderColor||(i.bubbleBorderColor=i.mainForegroundColor),i.checklistLauncherActiveBackgroundColor||(i.checklistLauncherActiveBackgroundColor=i.brandActiveBackgroundColor),i.checklistLauncherBackgroundColor||(i.checklistLauncherBackgroundColor=i.brandBackgroundColor),i.checklistLauncherCounterBackgroundColor||(i.checklistLauncherCounterBackgroundColor=i.brandForegroundColor),i.checklistLauncherCounterFontColor||(i.checklistLauncherCounterFontColor=i.brandBackgroundColor),i.checklistLauncherFontColor||(i.checklistLauncherFontColor=i.brandForegroundColor),i.checklistLauncherHoverBackgroundColor||(i.checklistLauncherHoverBackgroundColor=i.brandHoverBackgroundColor),i.focusColor||(i.focusColor=i.mainActiveBackgroundColor),i.launcherIconActiveColor||(i.launcherIconActiveColor=i.brandActiveBackgroundColor),i.launcherIconColor||(i.launcherIconColor=i.brandBackgroundColor),i.launcherIconHoverColor||(i.launcherIconHoverColor=i.brandHoverBackgroundColor),i.linkColor||(i.linkColor=i.widgetBackgroundColor),i.progressBarColor||(i.progressBarColor=i.widgetBackgroundColor),i.questionColor||(i.questionColor=i.widgetBackgroundColor),i.toolbarForegroundColor||(i.toolbarForegroundColor=i.mainForegroundColor),i.primaryButtonBackgroundColor||(i.primaryButtonBackgroundColor=i.widgetBackgroundColor),i.primaryButtonFontColor||(i.primaryButtonFontColor=i.widgetForegroundColor),i.primaryButtonHoverFontColor||(i.primaryButtonHoverFontColor=i.primaryButtonFontColor),i.primaryButtonActiveFontColor||(i.primaryButtonActiveFontColor=i.primaryButtonFontColor),!i.primaryButtonHoverBackgroundColor||!i.primaryButtonActiveBackgroundColor){const[o,r]=Y(i.primaryButtonBackgroundColor,[i.primaryButtonFontColor]);i.primaryButtonHoverBackgroundColor||(i.primaryButtonHoverBackgroundColor=o),i.primaryButtonActiveBackgroundColor||(i.primaryButtonActiveBackgroundColor=r)}if(i.primaryButtonBorderColor||(i.primaryButtonBorderColor=i.widgetBackgroundColor),i.primaryButtonHoverBorderColor||(i.primaryButtonHoverBorderColor=i.primaryButtonHoverBackgroundColor),i.primaryButtonActiveBorderColor||(i.primaryButtonActiveBorderColor=i.primaryButtonActiveBackgroundColor),i.defaultButtonBackgroundColor||(i.defaultButtonBackgroundColor=i.mainBackgroundColor),i.defaultButtonFontColor||(i.defaultButtonFontColor=l),i.defaultButtonHoverFontColor||(i.defaultButtonHoverFontColor=i.defaultButtonFontColor),i.defaultButtonActiveFontColor||(i.defaultButtonActiveFontColor=i.defaultButtonFontColor),!i.defaultButtonHoverBackgroundColor||!i.defaultButtonActiveBackgroundColor){const[o,r]=Y(i.defaultButtonBackgroundColor,[i.defaultButtonFontColor]);i.defaultButtonHoverBackgroundColor||(i.defaultButtonHoverBackgroundColor=o),i.defaultButtonActiveBackgroundColor||(i.defaultButtonActiveBackgroundColor=r)}return i.defaultButtonBorderColor||(i.defaultButtonBorderColor=i.defaultButtonFontColor),i.defaultButtonHoverBorderColor||(i.defaultButtonHoverBorderColor=i.defaultButtonBorderColor),i.defaultButtonActiveBorderColor||(i.defaultButtonActiveBorderColor=i.defaultButtonBorderColor),i.launcherButtonBackgroundColor||(i.launcherButtonBackgroundColor=i.brandBackgroundColor),i.launcherButtonBorderColor||(i.launcherButtonBorderColor=i.brandBackgroundColor),i.launcherButtonFontColor||(i.launcherButtonFontColor=i.brandForegroundColor),i.launcherButtonHoverBackgroundColor||(i.launcherButtonHoverBackgroundColor=i.brandHoverBackgroundColor),i.launcherButtonHoverBorderColor||(i.launcherButtonHoverBorderColor=i.launcherButtonHoverBackgroundColor),i.launcherButtonHoverFontColor||(i.launcherButtonHoverFontColor=i.launcherButtonFontColor),i.launcherButtonActiveBackgroundColor||(i.launcherButtonActiveBackgroundColor=i.brandActiveBackgroundColor),i.launcherButtonActiveBorderColor||(i.launcherButtonActiveBorderColor=i.launcherButtonActiveBackgroundColor),i.launcherButtonActiveFontColor||(i.launcherButtonActiveFontColor=i.launcherButtonFontColor),i}function Q(o){const{questionColor:r}=o;return{"--userflow-backdrop-highlight-color-rgb":D(o.backdropHighlightColor),"--userflow-backdrop-highlight-inset":o.backdropHighlightType===z.INSIDE?"inset":"","--userflow-backdrop-highlight-opacity":o.backdropHighlightOpacity,"--userflow-backdrop-highlight-radius":o.backdropHighlightRadius+"px","--userflow-backdrop-highlight-spread":o.backdropHighlightSpread+"px","--userflow-backdrop-opacity":o.backdropOpacity,"--userflow-banner-background-color":o.bannerBackgroundColor,"--userflow-banner-hover-background-color":o.bannerHoverBackgroundColor,"--userflow-banner-active-background-color":o.bannerActiveBackgroundColor,"--userflow-banner-foreground-color":o.bannerForegroundColor,"--userflow-banner-hover-foreground-color":o.bannerHoverForegroundColor,"--userflow-banner-active-foreground-color":o.bannerActiveForegroundColor,"--userflow-beacon-color":o.beaconColor,"--userflow-beacon-size":o.beaconSize+"px","--userflow-brand-active-background-color":o.brandActiveBackgroundColor,"--userflow-brand-background-color":o.brandBackgroundColor,"--userflow-brand-foreground-color":o.brandForegroundColor,"--userflow-brand-foreground-color-rgb":D(o.brandForegroundColor),"--userflow-brand-hover-background-color":o.brandHoverBackgroundColor,"--userflow-bubble-border-color":o.bubbleBorderColor,"--userflow-bubble-border-radius":o.bubbleBorderRadius+"px","--userflow-bubble-border-width":o.bubbleBorderWidth+"px","--userflow-button-border-radius":o.buttonBorderRadius+"px","--userflow-button-height":o.buttonHeight+"px","--userflow-button-min-width":o.buttonMinWidth+"px","--userflow-button-text-align":0===o.buttonMinWidth?"start":"center","--userflow-buttons-justify-content":"left"===o.buttonHorizontalAlign?"start":"right"===o.buttonHorizontalAlign?"end":"center","--userflow-buttons-bubble-justify-content":"left"===o.buttonHorizontalAlign?"start":"center"===o.buttonHorizontalAlign?"center":"end","--userflow-checklist-launcher-active-background-color":o.checklistLauncherActiveBackgroundColor,"--userflow-checklist-launcher-background-color":o.checklistLauncherBackgroundColor,"--userflow-checklist-launcher-border-radius":o.checklistLauncherBorderRadius+"px","--userflow-checklist-launcher-counter-background-color":o.checklistLauncherCounterBackgroundColor,"--userflow-checklist-launcher-counter-font-color":o.checklistLauncherCounterFontColor,"--userflow-checklist-launcher-font-color-rgb":D(o.checklistLauncherFontColor),"--userflow-checklist-launcher-font-color":o.checklistLauncherFontColor,"--userflow-checklist-launcher-font-weight":String(o.checklistLauncherFontWeight),"--userflow-checklist-launcher-height":o.checklistLauncherHeight+"px","--userflow-checklist-launcher-hover-background-color":o.checklistLauncherHoverBackgroundColor,"--userflow-checkmark-background-color":o.checkmarkBackgroundColor,"--userflow-completed-task-text-decoration":o.completedTaskTextDecoration,"--userflow-default-button-active-background-color":o.defaultButtonActiveBackgroundColor,"--userflow-default-button-active-border-color":o.defaultButtonActiveBorderColor,"--userflow-default-button-active-font-color":o.defaultButtonActiveFontColor,"--userflow-default-button-background-color":o.defaultButtonBackgroundColor,"--userflow-default-button-border-color":o.defaultButtonBorderColor,"--userflow-default-button-border-width":o.defaultButtonBorderWidth+"px","--userflow-default-button-font-color":o.defaultButtonFontColor,"--userflow-default-button-font-weight":String(o.defaultButtonFontWeight),"--userflow-default-button-hover-background-color":o.defaultButtonHoverBackgroundColor,"--userflow-default-button-hover-border-color":o.defaultButtonHoverBorderColor,"--userflow-default-button-hover-font-color":o.defaultButtonHoverFontColor,"--userflow-focus-color":`rgba(${D(o.focusColor)}, ${o.focusOpacity})`,"--userflow-font-family":o.builtinFontFamily?o.builtinFontFamily.name+(o.builtinFontFamily.fallback?", "+o.builtinFontFamily.fallback:""):o.fontFamily?o.fontFamily:"sans-serif","--userflow-font-size":o.fontSize+"px","--userflow-font-weight-bold":String(o.fontWeightBold),"--userflow-font-weight-normal":String(o.fontWeightNormal),"--userflow-h1-font-size":o.h1FontSize+"px","--userflow-h2-font-size":o.h2FontSize+"px","--userflow-launcher-button-active-background-color":o.launcherButtonActiveBackgroundColor,"--userflow-launcher-button-active-border-color":o.launcherButtonActiveBorderColor,"--userflow-launcher-button-active-font-color":o.launcherButtonActiveFontColor,"--userflow-launcher-button-background-color":o.launcherButtonBackgroundColor,"--userflow-launcher-button-border-color":o.launcherButtonBorderColor,"--userflow-launcher-button-border-radius":o.launcherButtonBorderRadius+"px","--userflow-launcher-button-border-width":o.launcherButtonBorderWidth+"px","--userflow-launcher-button-font-color":o.launcherButtonFontColor,"--userflow-launcher-button-font-weight":String(o.launcherButtonFontWeight),"--userflow-launcher-button-height":o.launcherButtonHeight+"px","--userflow-launcher-button-horizontal-padding":o.launcherButtonHorizontalPadding+"px","--userflow-launcher-button-hover-background-color":o.launcherButtonHoverBackgroundColor,"--userflow-launcher-button-hover-border-color":o.launcherButtonHoverBorderColor,"--userflow-launcher-button-hover-font-color":o.launcherButtonHoverFontColor,"--userflow-launcher-button-width":o.launcherButtonWidth?o.launcherButtonWidth+"px":"auto","--userflow-launcher-icon-active-color":o.launcherIconActiveColor,"--userflow-launcher-icon-color":o.launcherIconColor,"--userflow-launcher-icon-hover-color":o.launcherIconHoverColor,"--userflow-launcher-icon-opacity":o.launcherIconOpacity,"--userflow-launcher-icon-size":o.launcherIconSize+"px","--userflow-line-height":o.lineHeight+"px","--userflow-link-color":o.linkColor,"--userflow-main-active-background-color":o.mainActiveBackgroundColor,"--userflow-main-background-color":o.mainBackgroundColor,"--userflow-main-background-color-rgb":D(o.mainBackgroundColor),"--userflow-main-foreground-color":o.mainForegroundColor,"--userflow-main-foreground-color-rgb":D(o.mainForegroundColor),"--userflow-main-hover-background-color":o.mainHoverBackgroundColor,"--userflow-modal-padding":o.modalPadding+"px","--userflow-modal-padding-top":(o.avatarType===W.NONE?o.modalPadding:o.modalPadding+Math.max((o.avatarSize-o.modalPadding)/2,0))+"px","--userflow-backdrop-color-rgb":D(o.backdropColor),"--userflow-notch-color":o.bubbleBorderWidth>0&&o.bubbleBorderColor||o.mainBackgroundColor,"--userflow-primary-button-active-background-color":o.primaryButtonActiveBackgroundColor,"--userflow-primary-button-active-border-color":o.primaryButtonActiveBorderColor,"--userflow-primary-button-active-font-color":o.primaryButtonActiveFontColor,"--userflow-primary-button-background-color":o.primaryButtonBackgroundColor,"--userflow-primary-button-border-color":o.primaryButtonBorderColor,"--userflow-primary-button-border-width":o.primaryButtonBorderWidth+"px","--userflow-primary-button-font-color":o.primaryButtonFontColor,"--userflow-primary-button-font-weight":String(o.primaryButtonFontWeight),"--userflow-primary-button-hover-background-color":o.primaryButtonHoverBackgroundColor,"--userflow-primary-button-hover-border-color":o.primaryButtonHoverBorderColor,"--userflow-primary-button-hover-font-color":o.primaryButtonHoverFontColor,"--userflow-progress-bar-color":o.progressBarColor,"--userflow-progress-bar-height":o.progressBarHeight+"px","--userflow-resource-center-collapsed-height":o.resourceCenterCollapsedHeight+"px","--userflow-resource-center-full-width":o.resourceCenterFullWidth+"px","--userflow-resource-center-launcher-border-radius":(null!=o.resourceCenterLauncherBorderRadius?Math.min(o.resourceCenterLauncherBorderRadius,o.resourceCenterCollapsedHeight/2):o.resourceCenterCollapsedHeight/2)+"px","--userflow-resource-center-padding-x":o.resourceCenterPaddingX+"px","--userflow-resource-center-padding-y":o.resourceCenterPaddingY+"px","--userflow-resource-center-transition-duration":o.resourceCenterTransitionDuration+"ms","--userflow-resource-center-width":o.resourceCenterWidth+"px","--userflow-question-color-light":G(r,o.mainBackgroundColor,.5),"--userflow-question-color-lighter":G(r,o.mainBackgroundColor,.75),"--userflow-question-color-lightest":G(r,o.mainBackgroundColor,.9),"--userflow-question-color-medium-light":G(r,o.mainBackgroundColor,.15),"--userflow-question-color":r,"--userflow-toolbar-foreground-color":o.toolbarForegroundColor,"--userflow-toolbar-foreground-color-rgb":D(o.toolbarForegroundColor),"--userflow-tooltip-notch-size":o.tooltipNotchSize+"px","--userflow-unread-badge-background-color":o.unreadBadgeBackgroundColor,"--userflow-unread-badge-foreground-color":o.unreadBadgeForegroundColor,"--userflow-widget-active-background-color":o.widgetActiveBackgroundColor,"--userflow-widget-background-color":o.widgetBackgroundColor,"--userflow-widget-foreground-color":o.widgetForegroundColor,"--userflow-widget-hover-background-color":o.widgetHoverBackgroundColor}}const Z=[];function _(r){let[e,t]=o.useState(r);const n=T(r.sessionData||Z);return o.useLayoutEffect((()=>{const{variations:o}=r;if(!o)return;const e=[],l=[],u=()=>{let n=r,l=!1;for(const[r,t]of o.entries())if(e[r]){l||(l=!0,n={...n});for(const o of t.overriddenKeys)n[o]=t[o]}t(n)};for(const[r,t]of o.entries()){e[r]=!1;const{condition:o}=t;if(o&&t.overriddenKeys&&t.overriddenKeys.length>0){const t=E[o.type].track({sessionData:n,condition:o,callback:o=>{e[r]=o,u()}});l[r]=t}else l[r]=()=>{}}return u(),()=>{for(const o of l)o()}}),[r,n]),o.useMemo((()=>J(e)),[e])}function oo(o){const r=I.serverEndpoint||"cdn.userflow.com";return o?.cssVersion?`https://${r}/themes/${o.id}/stylesheets/${o.cssVersion}/custom.css`:null}const ro=new Map;function eo(o){let r=ro.get(o);return r||(r={stylesheets:new Map},ro.set(o,r)),r}function to(r,e,t,{uninstallOnUnmount:n}={}){const l=j(),[u,a]=o.useState(!e);return o.useLayoutEffect((()=>{if(!r||!e)return;let o,u=!1;const c=async e=>{await uo(l,r,e),o&&ao(r,o),o=e};(async()=>{let o="string"==typeof e?e:e.get();if(window.MSInputMethodContext&&document.documentMode&&t){let r=await function(o){return new Promise(((r,e)=>{let t=no.get(o);if(t)return void r(t);const n=new XMLHttpRequest;n.addEventListener("load",(()=>{if(200!==n.status)return void e(new Error("Userflow.js could not fetch stylesheet: "+o));const t=n.responseText;no.set(o,t),r(t)})),n.addEventListener("error",(()=>{e(new Error("Userflow.js could not fetch stylesheet: "+o))})),n.open("GET",o),n.send()}))}(o);if(u)return;r=function(o,r){for(const e in r)if(r.hasOwnProperty(e)){const t=r[e];t&&(o=o.replace(new RegExp(`var\\(${e}.*?\\)`,"g"),t))}return o=o.replace(/var\(--[a-z0-9-]+(,\s*(.*?))?\)/g,"$2")}(r,Q(t)),o="data:text/css;base64,"+btoa(r)}await c(o),u||a(!0)})();let i=null;return"string"!=typeof e&&(i=e.onUpdate((async()=>{c(e.get())}))),()=>{u=!0,i&&i(),n&&o&&ao(r,o)}}),[l,r,e,t,n]),{loaded:u}}const no=new Map;function lo(r,e){const t=e&&function(o){if(!o.builtinFontFamily)return o.fontCssUrl?{url:o.fontCssUrl,fontFamily:o.fontFamily}:null;switch(o.builtinFontFamily.provider){case $.GOOGLE:{const r=Array.from(new Set(["0,400","1,400",`0,${o.fontWeightBold}`,`0,${o.defaultButtonFontWeight}`,`0,${o.primaryButtonFontWeight}`,`0,${o.checklistLauncherFontWeight}`,`0,${o.launcherButtonFontWeight}`])).sort().join(";");return{url:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(o.builtinFontFamily.name)}:ital,wght@${r}`,fontFamily:o.builtinFontFamily.name}}case $.STANDARD:return null}}(e),n=t?.url,l=t?.fontFamily,[u,a]=o.useState(!n||!l);return o.useLayoutEffect((()=>{if(!r||!n||!l)return;let o=!1;return uo(null,r,n),function(o,r,e){if(!o.document.fonts)return e(),()=>{};let t=!1;const n=()=>{const l=o.document.fonts.load(`100px ${r}`,"BESbswy");if(!l)return u(),void e();l.then((o=>{t||(o.length>=1?(u(),e()):window.setTimeout(n,25))}),(o=>{console.log("Userflow.js: observeFont error:"),console.log(o),e()}))};n();const l=window.setTimeout((()=>{console.warn(`Userflow.js: Timed out waiting for font family ${r} to load. Will continue anyway.`),e()}),2e3),u=()=>{t=!0,window.clearTimeout(void 0),window.clearTimeout(l)}}(r,l,(()=>{o||a(!0)})),()=>{o=!0}}),[r,n,l]),{loaded:u}}function uo(o,r,e){const t=eo(r),n=t.stylesheets.get(e);if(n)return n.loadPromise;const l=r.document.createElement("link"),u=new Promise(((t,n)=>{l.dataset.userflowStylesheet="true",l.rel="stylesheet",l.href=e,l.onload=()=>{t()},l.onerror=r=>{console.log(`Userflow.js: Error installing Stylesheet ${e}:`,r),o&&o.reportCspIssue(),n()},r.document.head.appendChild(l)}));return t.stylesheets.set(e,{link:l,loadPromise:u}),u}function ao(o,r){const e=eo(o),t=e.stylesheets.get(r);t&&(o.document.head.removeChild(t.link),e.stylesheets.delete(r))}export{q as D,to as a,T as b,lo as c,oo as d,Q as g,_ as u};
package/userflow.js CHANGED
@@ -1 +1 @@
1
- import{S as e}from"./vendor.phoenix.js";import{v as t}from"./vendor.uuid.js";let s;const i={},n=function(e,t){if(!t)return e();if(void 0===s){const e=document.createElement("link").relList;s=e&&e.supports&&e.supports("modulepreload")?"modulepreload":"preload"}return Promise.all(t.map((e=>{if(e in i)return;i[e]=!0;const t=e.endsWith(".css"),n=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${n}`))return;const o=document.createElement("link");return o.rel=t?"stylesheet":s,t||(o.as="script",o.crossOrigin=""),o.href=e,document.head.appendChild(o),t?new Promise(((e,t)=>{o.addEventListener("load",e),o.addEventListener("error",t)})):void 0}))).then((()=>e()))};class o extends Error{constructor(e,t,s){super(e),Object.setPrototypeOf(this,o.prototype),this.name="UserflowError",this.code=t,this.humanMessage=s}}class r{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}isSupported(){if("undefined"==typeof window)return!1;try{return null!=window[this.type]}catch{return!1}}getItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].getItem(e):null}setItem(e,t){e=this.formatKey(e),this.isSupported()&&window[this.type].setItem(e,t)}removeItem(e){if(e=this.formatKey(e),this.isSupported())return window[this.type].removeItem(e)}clear(){if(this.isSupported())return window[this.type].clear()}}const a=new r("localStorage"),c=new r("sessionStorage");function l(e){window.location.href=e}function d(){return window.location.href}var h,u,E;function T(e){window.postMessage(e,window.origin)}function S(e){const t=t=>{if(t.source!==window||t.origin!==window.origin)return;const i=t.data;i&&"object"==typeof i&&"string"==typeof i.kind&&i.kind.startsWith("userflow:")&&!0===e(i)&&s()};window.addEventListener("message",t);const s=()=>window.removeEventListener("message",t);return s}(h||(h={})).INPUT="INPUT",(E=u||(u={})).AUTO="AUTO",E.MANUAL="MANUAL";const f=new Set;let w=!1;function p(e){return function(){if(w)return;w=!0;const{history:e}=window,t=t=>{const s=e[t];e[t]=(...t)=>{s.apply(e,t),I()}};t("pushState"),t("replaceState"),window.addEventListener("popstate",(()=>{I()}))}(),f.add(e),()=>{g(e)}}function g(e){f.delete(e)}function I(){f.forEach((e=>e()))}class C{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){T({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=S(e),!1}async captureScreenshot(e,t,s,i){T({kind:"userflow:crxScreenshot",x:e,y:t,width:s,height:i,devicePixelRatio:window.devicePixelRatio});var n;return(await(n=e=>"userflow:crxScreenshotResult"===e.kind?e:null,new Promise((e=>{S((t=>{const s=n(t);return!!s&&(e(s),!0)}))})))).imageDataUrl}}var m,k,A,U,L,R,N,v,O,y,_,b,D,M,F,B,P,x,H,G,W,$,V,K,j,z,Y,J,X,Z,Q,q,ee,te,se,ie,ne,oe,re,ae,ce,le,de,he,ue,Ee,Te,Se,fe,we,pe,ge,Ie,Ce,me,ke,Ae,Ue,Le,Re,Ne,ve,Oe,ye,_e,be,De,Me,Fe,Be,Pe,xe,He,Ge,We,$e,Ve,Ke,je,ze,Ye,Je,Xe,Ze,Qe,qe;(k=m||(m={})).ACTION="ACTION",k.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",k.REPLACED="REPLACED",k.SNOOZED="SNOOZED",k.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",k.USERFLOWJS="USERFLOWJS",k.USER_CLOSED="USER_CLOSED",(U=A||(A={})).SECOND="SECOND",U.MINUTE="MINUTE",U.HOUR="HOUR",U.DAY="DAY",(R=L||(L={})).ACTION="ACTION",R.DRAFT="DRAFT",R.LINK="LINK",R.LAUNCHER_SEEN="LAUNCHER_SEEN",R.RESOURCE_CENTER="RESOURCE_CENTER",R.USERFLOWJS="USERFLOWJS",(v=N||(N={})).LIKE="LIKE",v.DISLIKE="DISLIKE",(y=O||(O={})).STRING="STRING",y.BOOLEAN="BOOLEAN",y.NUMBER="NUMBER",y.DATETIME="DATETIME",y.LIST="LIST",y.RANDOM_AB="RANDOM_AB",y.RANDOM_NUMBER="RANDOM_NUMBER",(b=_||(_={})).FLOW="FLOW",b.BANNER="BANNER",b.CHECKLIST="CHECKLIST",b.LAUNCHER="LAUNCHER",b.RESOURCE_CENTER="RESOURCE_CENTER",(M=D||(D={})).ALWAYS_TRUE="ALWAYS_TRUE",M.ATTRIBUTE="ATTRIBUTE",M.CLAUSE="CLAUSE",M.ELEMENT="ELEMENT",M.FILLED_IN_INPUT="FILLED_IN_INPUT",M.FLOW="FLOW",M.INPUT_VALUE="INPUT_VALUE",M.PAGE="PAGE",M.SEGMENT="SEGMENT",M.TIME="TIME",function(e){e.AUTO="AUTO",e.MANUAL="MANUAL"}(F||(F={})),(B||(B={})).INPUT="INPUT",(x=P||(P={})).ABSOLUTE_EQ="ABSOLUTE_EQ",x.ABSOLUTE_GT="ABSOLUTE_GT",x.ABSOLUTE_LT="ABSOLUTE_LT",x.AND="AND",x.BETWEEN="BETWEEN",x.CONTAINS="CONTAINS",x.EMPTY="EMPTY",x.ENDS_WITH="ENDS_WITH",x.EQ="EQ",x.EXCLUDES_ALL="EXCLUDES_ALL",x.EXCLUDES_ANY="EXCLUDES_ANY",x.FALSE="FALSE",x.GT="GT",x.GTE="GTE",x.INCLUDES_ALL="INCLUDES_ALL",x.INCLUDES_ANY="INCLUDES_ANY",x.LT="LT",x.LTE="LTE",x.NE="NE",x.NOT_CONTAINS="NOT_CONTAINS",x.NOT_EMPTY="NOT_EMPTY",x.NOT_REGEX="NOT_REGEX",x.OR="OR",x.REGEX="REGEX",x.RELATIVE_EQ="RELATIVE_EQ",x.RELATIVE_GT="RELATIVE_GT",x.RELATIVE_LT="RELATIVE_LT",x.STARTS_WITH="STARTS_WITH",x.TRUE="TRUE",x.URL="URL",(G=H||(H={})).CLICK="CLICK",G.DISABLED="DISABLED",G.MOUSEDOWN="MOUSEDOWN",G.NOT_CLICK="NOT_CLICK",G.NOT_DISABLED="NOT_DISABLED",G.NOT_PRESENT="NOT_PRESENT",G.PRESENT="PRESENT",($=W||(W={})).ASSET="ASSET",$.CARTOON="CARTOON",$.NONE="NONE",$.URL="URL",(K=V||(V={})).INSIDE="INSIDE",K.OUTSIDE="OUTSIDE",(z=j||(j={})).TOP_LEFT="TOP_LEFT",z.TOP_CENTER="TOP_CENTER",z.TOP_RIGHT="TOP_RIGHT",z.BOTTOM_RIGHT="BOTTOM_RIGHT",z.BOTTOM_CENTER="BOTTOM_CENTER",z.BOTTOM_LEFT="BOTTOM_LEFT",z.CENTER="CENTER",(J=Y||(Y={})).GOOGLE="GOOGLE",J.STANDARD="STANDARD",(Z=X||(X={})).DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",Z.DISMISS="DISMISS",(q=Q||(Q={})).DISMISS="DISMISS",q.NONE="NONE",(te=ee||(ee={})).DEFAULT="DEFAULT",te.PLAINTEXT="PLAINTEXT",(ie=se||(se={})).CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",ie.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",ie.NONE="NONE",(oe=ne||(ne={})).BUBBLE="BUBBLE",oe.END="END",oe.ERROR="ERROR",oe.FLAG="FLAG",(ae=re||(re={})).MANUAL="MANUAL",ae.NONE="NONE",ae.SYNTHETIC="SYNTHETIC",(le=ce||(ce={})).BUBBLE="BUBBLE",le.HIDDEN="HIDDEN",le.MODAL="MODAL",le.TOOLTIP="TOOLTIP",(he=de||(de={})).ABOVE="ABOVE",he.BELOW="BELOW",he.LEFT="LEFT",he.RIGHT="RIGHT",(Ee=ue||(ue={})).CLOSE_FLOW="CLOSE_FLOW",Ee.EVAL_JS="EVAL_JS",Ee.GO_TO_STEP="GO_TO_STEP",Ee.NAVIGATE="NAVIGATE",Ee.SET_ATTRIBUTE="SET_ATTRIBUTE",Ee.SNOOZE="SNOOZE",Ee.START_FLOW="START_FLOW",(Se=Te||(Te={})).NEW_TAB="NEW_TAB",Se.SAME_TAB="SAME_TAB",(we=fe||(fe={})).SET="SET",we.SET_DATETIME="SET_DATETIME",we.SET_DATETIME_ONCE="SET_DATETIME_ONCE",we.SET_ONCE="SET_ONCE",we.ADD="ADD",we.SUBTRACT="SUBTRACT",we.APPEND="APPEND",we.PREPEND="PREPEND",we.REMOVE="REMOVE",we.UNSET="UNSET",(ge=pe||(pe={})).MULTILINE_TEXT="MULTILINE_TEXT",ge.MULTIPLE_CHOICE="MULTIPLE_CHOICE",ge.NPS="NPS",ge.SCALE="SCALE",ge.STARS="STARS",ge.TEXT="TEXT",(Ce=Ie||(Ie={})).ACTION="ACTION",Ce.ANNOUNCEMENTS="ANNOUNCEMENTS",Ce.ASSISTANT="ASSISTANT",Ce.CHECKLIST="CHECKLIST",Ce.CONTACT="CONTACT",Ce.DIVIDER="DIVIDER",Ce.FLOWS="FLOWS",Ce.KNOWLEDGE_BASE="KNOWLEDGE_BASE",Ce.MESSAGE="MESSAGE",Ce.SUBPAGE="SUBPAGE",(ke=me||(me={})).CRISP="CRISP",ke.CUSTOM="CUSTOM",ke.FRESHCHAT="FRESHCHAT",ke.HELPSCOUT="HELPSCOUT",ke.HUBSPOT="HUBSPOT",ke.INTERCOM="INTERCOM",ke.ZENDESK="ZENDESK",ke.ZENDESK_MESSENGER="ZENDESK_MESSENGER",(Ue=Ae||(Ae={})).BUTTON="BUTTON",Ue.INPUT="INPUT",(Re=Le||(Le={})).EMAIL="EMAIL",Re.PHONE="PHONE",Re.CHAT="CHAT",(ve=Ne||(Ne={})).SILENT="SILENT",ve.BADGE="BADGE",ve.POPOUT="POPOUT",(ye=Oe||(Oe={})).LAUNCHER_CLICK="LAUNCHER_CLICK",ye.LAUNCHER_HOVER="LAUNCHER_HOVER",ye.TARGET_CLICK="TARGET_CLICK",ye.TARGET_HOVER="TARGET_HOVER",ye.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",ye.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",(be=_e||(_e={})).ACTIVATE="ACTIVATE",be.DEACTIVATE="DEACTIVATE",be.NEVER="NEVER",(Me=De||(De={})).AUTO="AUTO",Me.TOP="TOP",Me.RIGHT="RIGHT",Me.BOTTOM="BOTTOM",Me.LEFT="LEFT",(Be=Fe||(Fe={})).START="START",Be.CENTER="CENTER",Be.END="END",(xe=Pe||(Pe={})).PERCENT="PERCENT",xe.PX="PX",(Ge=He||(He={})).BEACON="BEACON",Ge.BUTTON="BUTTON",Ge.HIDDEN="HIDDEN",Ge.ICON="ICON",($e=We||(We={})).LAUNCHER="LAUNCHER",$e.TARGET="TARGET",(Ke=Ve||(Ve={})).BODY_FIRST="BODY_FIRST",Ke.BODY_LAST="BODY_LAST",Ke.ELEMENT_FIRST="ELEMENT_FIRST",Ke.ELEMENT_LAST="ELEMENT_LAST",Ke.ELEMENT_BEFORE="ELEMENT_BEFORE",Ke.ELEMENT_AFTER="ELEMENT_AFTER",(ze=je||(je={})).START="START",ze.CENTER="CENTER",ze.SPACE_BETWEEN="SPACE_BETWEEN",(Je=Ye||(Ye={})).NONE="NONE",Je.LIKE="LIKE",Je.SCALE="SCALE",(Ze=Xe||(Xe={})).ACTIVE="ACTIVE",Ze.COMPLETED="COMPLETED",Ze.ENDED="ENDED",Ze.NOT_SEEN="NOT_SEEN",(qe=Qe||(Qe={})).HIGHLIGHT="HIGHLIGHT",qe.MODAL="MODAL",qe.HIGHLIGHT_MODAL="HIGHLIGHT_MODAL";const et={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:[e=>!e.match(/\d$/)],"data-id":[e=>!e.match(/\d$/)]},inferenceClassNameFilters:[e=>!e.startsWith("css-")],baseZIndex:1234500,evalJsDisabled:!1};function tt(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map((e=>"string"==typeof e?new RegExp(e):e))}function st(e,t){return e.every((e=>"function"==typeof e?e(t):!(e instanceof RegExp)||e.test(t)))}function it(){let e=d();if(et.urlFilter){if(e=et.urlFilter(e),"string"!=typeof e)throw new o("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(e)}catch(t){throw new o("Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.\nReturned URL: "+e+"\nError message: "+t.message)}}return e}let nt="";try{nt=localStorage.getItem("debug")||""}catch(ft){}const ot=nt.split(",").some((e=>"*"===e||e.startsWith("userflow:*"))),rt=ct("log");let at;function ct(e){return function(t,...s){if(ot){const i=performance.now(),n=at?Math.round(i-at):0;at=i,console[e](`%cuserflow %c${t} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}rt.group=ct("group"),rt.groupCollapsed=ct("groupCollapsed"),rt.groupEnd=function(){ot&&console.groupEnd()};const lt=()=>n((()=>import("./ResourceCenterApp.js").then((function(e){return e.R}))),[new URL("ResourceCenterApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("flow-host.styl.js",import.meta.url).toString(),new URL("bubble-frame.styl.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("use-element-rect.js",import.meta.url).toString()]);function dt(e){const t=e.version.checklist.tasks.length;return Math.max(0,t-e.taskCompletions.length)}class ht{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 e of this.observers)e()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const ut=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],Et=()=>n((()=>import("./BannerApp.js")),[new URL("BannerApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("bubble-frame.styl.js",import.meta.url).toString(),new URL("flow-host.styl.js",import.meta.url).toString(),new URL("use-selector-element-monitoring.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("use-element-rect.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]),Tt=import.meta.url;class St{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.featureFlags=new Set,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.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.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.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{rt(`builder ${e.kind} message received`,e);const t="idempotencyKey"in e&&"string"==typeof e.idempotencyKey?e.idempotencyKey:null;if(t&&this.idempotencyKeysSeen.has(t))return;const s=()=>{t&&this.idempotencyKeysSeen.add(t)};switch(e.kind){case"userflow:selectElement":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),void this.setSessionStorageState((t=>({...t,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}})));case"userflow:selectElementCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,elementSelection:null})));case"userflow:startFlowWithToken":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState((e=>({...e,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0}))),c.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void(e.testStartCondition?this.setSessionStorageState((t=>({...t,activeApp:"startConditionTesting",testStartConditionToken:e.token}))):this.onceIdentified((()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const t=()=>{const s=this.resourceCenterSession;s&&s.draftMode&&s.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",t))};this.on("resourceCenterChanged",t),t()}})));case"userflow:testTracker":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState((e=>({...e,isTargetTab:!0}))),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.setSessionStorageState((t=>({...t,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}})));case"userflow:testTrackerCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,trackerTesting:null})))}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout((()=>this.flushUrlChange()),50))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{this.ui?.container&&!document.contains(this.ui.container)&&(rt("remounting UI because container was missing"),this.remount())},rt("constructor, build=1004474"),p(this.onUrlChange),this.setTargetEnv(new C),this.checkTestUserAtBoot(),this.toggleUI();for(const e of ut)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){rt("destroy"),this.reset(),g(this.onUrlChange),this.destroyTargetEnv();for(const e of ut)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 o("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const t=e(this.getSessionStorageState());c.setItem("userflowClientState",JSON.stringify(t)),this.sessionStorageState=t,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const t=c.getItem("userflowClientState");if(t)try{e=JSON.parse(t)}catch(ft){console.error("Userflow.js: Parse ElementSelectionState error:",ft)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(rt("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState((t=>({...t,testUser:e}))),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const t=[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:s}=e;s&&(this.groupId=s.id,t.push(this.group(s.id,{name:s.name},{signature:s.signature}))),await Promise.all(t)}resetTestUser(){this.setSessionStorageState((e=>({...e,testUser:null})))}init(e){if(rt("init",e),!e)throw new o("userflow.init() was called but missing Userflow.js Token");this.clientToken!==e&&(this.testUserIdentified?rt("init() ignoring new token since a test user has been identified"):(this.clientToken&&(rt("init() resetting due to new client token"),this.reset()),this.clientToken=e))}ensureInit(){if(!this.clientToken)throw new o("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new o("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new o("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId)return;if(this.debounceInactiveDisconnect(),this.socket)return;this._socketStatus="connecting",rt("connecting to socket");let t=et.serverEndpoint||"e.userflow.com";"js.getuserflow.com"===new URL(Tt).hostname&&"e.userflow.com"===t&&(t="e.getuserflow.com");const s="wss://"+t+"/end-users/"+this.clientToken+"/socket";this.socket=new e(s,{reconnectAfterMs:e=>[100,500,1e3,5e3][e-1]||1e4,timeout:2e4}),this.socket.connect(),this.socket.onOpen((()=>{rt("socket opened")})),this.socket.onClose((()=>{this.emit("private:disconnect")})),this.socket.onError((e=>{console.log("Userflow.js socket error",e),this.reportCspIssue()})),this.channel=this.socket.channel(`end_users:${this.externalId}`,(()=>this.makeChannelJoinPayload())),this.channel.join().receive("ok",(e=>{this.logrocketAppId=e.logrocketAppId,this.featureFlags=new Set(e.featureFlags),rt("channel joined"),"connected"!==this._socketStatus&&(this._socketStatus="connected")})).receive("error",(e=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(e.code)?(console.error(`Userflow.js resetting due to: [${e.code}] ${e.message}`),this.reset(),this.clientToken=null):"invalid_protocol_version"===e.code?(console.error(`Userflow.js destroying due to: [${e.code}] ${e.message}`),this.destroy()):console.log("Userflow.js channel join error",e)})),this.channel.on("server_message",(e=>this.handleServerMessage(e))),this.channel.on("server_error",(e=>{console.log(`Userflow.js server error (${e.code}): ${e.message}`+(e.details&&e.details.length>0?"\nDetails:\n"+e.details.map((e=>(e.path?`${e.path}: `:"")+e.message)):""))}))}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const t={protocolVersion:2,userflowClientBuild:"1004474",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((e=>({flowId:e.flow.id}))),trackers:Array.from(this.trackers.values()).map((e=>({flowId:e.tracker.flowId}))),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map((e=>({conditionId:e.condition.id,isTrue:e.isTrue}))),previewFlowId:c.getItem("previewFlowId"),clientContext:e};return rt("channel join payload",t),t}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((()=>{this.hasDraftSession()||this.assistantMessageInProgress?this.debounceInactiveDisconnect():(rt("disconnecting from socket due to inactivity"),this.disconnect())}),3e5)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some((e=>e.draftMode))}async send(e,{batch:t,endBatch:s,handlesRejection:i}={}){return this.inBatch&&["ToggleClientCondition","UpdateClientContext"].includes(e.kind)||this.checkPushRateLimit(),this.ensureConnected(),t&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),s?this.endBatch():this.endBatchTimeout=window.setTimeout((()=>{this.endBatch()}),50)),this.sendRaw(e,{handlesRejection:i})}async sendRaw(e,{handlesRejection:t}={}){return new Promise(((s,i)=>{if(!this.channel){const s=`Userflow.js: send() should not be called if channel is not set. Message kind=${e.kind}`;if(t)throw Error(s);return void console.log(s,"\nClient message:",e)}rt(`push ${e.kind} message`,e);const n=this.clientClock,r=()=>{this.serverClock=n,this.channel?.off("phx_error",a)},a=this.channel.on("phx_error",(s=>{r();const n=`Userflow.js send ${e.kind} got phx_error`;"connected"===this._socketStatus&&console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n))}));this.channel.push("client_message",e).receive("ok",(e=>{r(),s(e)})).receive("error",(s=>{r();const n=`Userflow.js error reply (${s.code}): ${s.message}`;console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n,s.code,s.message))}))}))}endBatch(){this.inBatch=!1,this.sendRaw({kind:"EndBatch"})}checkPushRateLimit(){const e=Date.now();if(this.pushRateLimitMinuteExpires<e&&(this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=e+6e4),this.pushRateLimitMinute>=100)throw new o("This Userflow.js client has reached a maximum of 100 operations in the last 1 minute. This is usually due to one of the following:\n\n - Excessive calls to Userflow.js. Check if any of userflow.track(), userflow.identify(), userflow.updateUser() or similar are called repeatedly.\n - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.\n - The user legitimately being very active, in which case you can just ignore this error.\n \n If in doubt, reach out to us at support@userflow.com.");this.pushRateLimitMinute++}handleServerMessage(e){rt(`received ${e.kind} message`,e);const{serverClock:t,flowSession:s,flowSessionClock:i,checklistSession:n,checklistSessionClock:o,bannerSession:r,resourceCenterSession:a}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:t}=e,s=this.launcherSessions.findIndex((e=>e.flow.id===t.flow.id));return this.launcherSessions=-1===s?[...this.launcherSessions,t]:[...this.launcherSessions.slice(0,s),t,...this.launcherSessions.slice(s+1)],void this.toggleUI()}case"AddTracker":return void this.addTracker(e.tracker);case"AssistantMessageEventWrapper":return void this.emit("private:assistantMessageEvent",e);case"CancelConditionWaitTimer":return window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),void this.conditionWaitTimers.delete(e.conditionId);case"ChecklistTaskCompleted":return void this.unackedTasks.add(e.taskCvid);case"ForceGoToStep":return i>t?void rt(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&this.emit("gotostep",{session:s,step:{id:e.stepId}}));case"RemoveLauncher":return void(this.removeLauncher(e.flowId)&&this.toggleUI());case"RemoveTracker":return void this.removeTracker(e.flowId);case"SetBannerSession":return this.setBannerSession(e.session),void this.toggleUI();case"SetChecklistSession":return void(o<=t||n?.id===e.session.id?(this.setChecklistSession(e.session,t),this.toggleUI()):rt(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`));case"SetFlowSession":return void(i<=t||s?.id===e.session.id?(this.setFlowSession(e.session,t),this.toggleUI()):rt(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`));case"SetResourceCenterSession":return this.setResourceCenterSession(e.session),void this.toggleUI();case"StartConditionWaitTimer":if(!this.conditionWaitTimers.has(e.conditionId)){const t=window.setTimeout((()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})}),1e3*parseFloat(e.waitTime));this.conditionWaitTimers.set(e.conditionId,t)}return;case"TestStartConditionSuccess":return void this.emit("private:testStartConditionSuccess");case"TrackClientCondition":return void this.trackClientCondition(e.condition);case"UnsetBannerSession":return void(r?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI()));case"UnsetChecklistSession":return o>t?void rt(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`):void(n?.id===e.sessionId&&(this.setChecklistSession(null,t),this.toggleUI()));case"UnsetFlowSession":return i>t?void rt(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&(this.setFlowSession(null,t),this.toggleUI()));case"UnsetResourceCenterSession":return void(a?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI()));case"UntrackClientCondition":return void this.untrackClientCondition(e.conditionId);default:return void console.warn("Userflow.js: Received unknown message",e)}}async identify(e,t={},{signature:s}={}){if(rt("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId)rt("identify() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`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&&(rt("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=s||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(t)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}}async identifyAnonymous(e={},s={}){if(!a.isSupported())throw new o("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const i="anonymousId";let n=a.getItem(i);n||(n="anon-"+t(),a.setItem(i,n)),await this.identify(n,e,s)}async updateUser(e={},t={}){rt("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,t={},{signature:s,membership:i}={}){if(rt("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId)rt("group() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`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=s||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(t),membershipAttributes:this.normalizeAttributes(i)},{batch:!0})}}async updateGroup(e={},t={}){rt("updateGroup");const s=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:s,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(t.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(null==e)return{};if("object"!=typeof e)throw new o("Userflow: 'attributes' must be an object.");const t={};for(const s in e){if(!e.hasOwnProperty(s))continue;if("traits"===s){const i=e[s];Object.assign(t,this.extractLegacyTraits(i));continue}let i=e[s];if("string"==typeof i||"number"==typeof i||"boolean"==typeof i||null==i||Array.isArray(i))t[s]=this.normalizeAttributeLiteralOrList(s,i);else{if("object"!=typeof i||null==i)throw new o(`Userflow: Invalid value for '${s}' attribute.`);if("set"in i)t[s]={set:this.normalizeAttributeLiteralOrList(s,i.set),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("set_once"in i||"setOnce"in i)t[s]={setOnce:this.normalizeAttributeLiteralOrList(s,i.set_once??i.setOnce),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("add"in i){const e=i.add;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'add' value for '${s}' attribute. Must be a number or string.`);t[s]={add:e}}else if("subtract"in i){const e=i.subtract;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'subtract' value for '${s}' attribute. Must be a number or string.`);t[s]={subtract:e}}else if("append"in i)t[s]={append:this.normalizeAttributeLiteralOrList(s,i.append)};else if("prepend"in i)t[s]={prepend:this.normalizeAttributeLiteralOrList(s,i.prepend)};else{if(!("remove"in i))throw new o(`Userflow: Invalid value for '${s}' attribute.`);t[s]={remove:this.normalizeAttributeLiteralOrList(s,i.remove)}}}}return t}normalizeAttributeLiteralOrList(e,t){return Array.isArray(t)?t.map((t=>this.normalizeAttributeLiteral(e,t))):this.normalizeAttributeLiteral(e,t)}normalizeAttributeLiteral(e,t){if(null==t)return null;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return t;throw new o(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,t){if(!t)return null;switch(t){case"string":return O.STRING;case"number":return O.NUMBER;case"boolean":return O.BOOLEAN;case"datetime":return O.DATETIME}throw new o(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push({name:s,value:e[s]});e=t}return e.reduce(((e,{name:t,value:s,dataType:i})=>{if("string"!=typeof t||t.length>100||!t.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:",t),e;if("string"==typeof s);else if("boolean"==typeof s)i||(i="boolean"),s=s?"true":"false";else{if("number"!=typeof s)return this.warn(`userflow.identify: The value of trait '${t}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,s),e;i||(i=Number.isInteger(s)?"integer":"decimal"),s=String(s)}let n=null;if(i)switch(i){case"string":n=O.STRING;break;case"boolean":n=O.BOOLEAN;break;case"integer":case"decimal":n=O.NUMBER;break;case"datetime":n=O.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${t}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,i),e}return e[t]={set:s,dataType:n},e}),{})}async track(e,t={},{userOnly:s}={}){rt(`track '${e}'`,t),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!s,name:e,attributes:this.normalizeEventAttributes(t)},{batch:!0})}normalizeEventAttributes(e){const t=this.normalizeAttributes(e);for(const s in t){if(!t.hasOwnProperty(s))continue;const e=t[s];if(null!=e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Array.isArray(e)&&!("set"in e))throw new o(`Userflow: Invalid value for '${s}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return t}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(d()),t=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");t&&(rt(`url contained flow ${t}`),this.startFlow({flowId:t,startReason:L.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",{})}buildClientContext(){return{pageUrl:it(),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 null!=this.externalId}on(e,t){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s)),s.add(t)}off(e,t){const s=this.listeners.get(e);s&&s.delete(t)}emit(e,...t){const s=this.listeners.get(e);if(s){Array.from(s).forEach((e=>e(...t)))}}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(){rt("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,t)=>{this.untrackClientCondition(t)})),this.firstIdentifyCallback=null,this.testUserIdentified=!1,a.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)}async startFlow({flowId:e,stepCvid:t,startReason:s,once:i,batch:n,replaceCurrent:o}){if(this.ensureIdentified(),o&&this.flowSession&&this.endFlow(this.flowSession,{endReason:m.REPLACED,batch:!0}),rt(`startFlow ${e}`,{startReason:s}),this.checklistSession?.flow.id===e)return rt("startFlow matches current checklist, so showing it instead"),void this.showChecklist();const r={kind:"StartFlow",flowId:e,stepCvid:t,startReason:s,once:!!i};await this.send(r,{batch:n})}async startFlowWithToken(e){this.ensureIdentified(),rt("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){this.resourceCenterEmbedsChecklist()?this.openResourceCenter():(this.unmarkExpandPending(),this.checklistSession&&!this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),c.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0})))}async hideChecklist(){this.resourceCenterEmbedsChecklist()?this.closeResourceCenter():this.checklistSession&&this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),c.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"),c.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"),c.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:t}=this,s=this.resourceCenterSession.version.resourceCenter?.blocks.find((e=>e.type===Ie.ANNOUNCEMENTS));return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&t?dt(t):0,unreadAnnouncementCount:s?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some((e=>e.type===Ie.CHECKLIST))}async endFlow(e,{endReason:t,batch:s}){this.ensureIdentified(),this.optimisticClockUIUpdate((()=>{const{clientClock:t}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,t),this.checklistSession?.id===e.id&&this.setChecklistSession(null,t),this.bannerSession?.id===e.id&&this.setBannerSession(null),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)}));const{flow:i}=e,n={id:i.id,type:i.type.toLowerCase()};i.type===_.CHECKLIST?this.emit("checklistEnded",{checklist:n,endReason:t}):i.type===_.FLOW&&this.emit("flowEnded",{flow:n,endReason:t});const o={kind:"EndFlow",sessionId:e.id,endReason:t};await this.send(o,{batch:s})}async goToStep(e,t){rt("goToStep",e.id,t.name||t.id),this.ensureIdentified();const s=this.send({kind:"GoToStep",sessionId:e.id,stepId:t.id});e.currentStep=t,this.emit("gotostep",{session:e,step:t}),await s}async endAllFlows(){rt("endAllFlows"),this.optimisticClockUIUpdate((()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)})),await this.send({kind:"EndAllFlows"})}async endChecklist(){rt("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===_.CHECKLIST&&this.endFlow(e,{endReason:m.USERFLOWJS})}setFlowSession(e,t=this.clientClock){const s=this.flowSession;this.flowSession=e,this.flowSessionClock=t,e&&!s&&(this.hideChecklist(),this.closeResourceCenter()),null==e&&this.originalActiveElement&&("function"==typeof this.originalActiveElement.focus&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,t=this.clientClock){const s=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=t,null===e&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==s?.id&&(this.checklistExpanded=!!c.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setBannerSession(e){this.bannerSession=e}setResourceCenterSession(e){const t=this.resourceCenterSession;e="function"==typeof e?e(this.resourceCenterSession):e,this.resourceCenterSession=e,null===e&&(this.resourceCenterOpen=!1),t&&t.id!==e?.id&&c.removeItem(`resourceCenterOpen:${t.id}`),e&&e.id!==t?.id&&(this.resourceCenterOpen=!!c.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:L.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const t=this.activeLauncherFlowId&&this.launcherSessions.find((e=>e.flow.id===this.activeLauncherFlowId));t&&this.deactivateLauncher(t),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:t}=e.version;e.flow.id===this.activeLauncherFlowId&&(t?.dismissOn===_e.DEACTIVATE?this.dismissLauncher(e,{endReason:m.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:t}){const s=e.flow.id;this.removeLauncher(s),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:s,endReason:t})}removeLauncher(e){const t=this.launcherSessions.findIndex((t=>t.flow.id===e));return-1!==t&&(this.launcherSessions=[...this.launcherSessions.slice(0,t),...this.launcherSessions.slice(t+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const e=this.getSessionStorageState();this.flowSession||!this.checklistExpandPending&&!this.checklistSession?.version.checklist?.tasks.some((e=>this.taskIsUnacked(e.cvid)))||this.showChecklist(),e.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){if(this.uiDisabled)return!1;return!!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&&(rt("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(rt("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=n((()=>import("./ui.js")),[new URL("ui.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);this.bannerSession&&Et(),this.resourceCenterSession&&lt();const{RealUI:t}=await e;return new t(this)}catch(ft){throw this.reportCspIssue(),ft}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;rt("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:t}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.v}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),s=t[e.type],i=this.clientConditions.get(e.id);i&&(i.untrack=s.track({sessionData:new ht([]),condition:e,callback:t=>{i.isTrue!==t&&(rt("client condition truthiness changed",t,i.condition),i.isTrue=t,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:t},{batch:!0}))}}))}untrackClientCondition(e){const t=this.clientConditions.get(e);t&&(rt("untrack client condition",t.condition),t.untrack&&t.untrack(),this.clientConditions.delete(e))}async addTracker(e){let t=this.trackers.get(e.flowId);t?t.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:s}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.v}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),i=this.trackers.get(e.flowId);if(!i)return;const{tracker:o}=i,{condition:r}=o,a=s[r.type];i.untrack&&i.untrack(),i.untrack=a.track({sessionData:new ht(o.data),condition:r,flipBackEvents:!0,callback:e=>{const t=i.isTrue;i.isTrue=e,!t&&e&&this.send({kind:"TrackTrackerEvent",token:o.token},{batch:!0})},description:`event tracker ${o.flowId}`}),this.emit("private:trackerStarted")}removeTracker(e){const t=this.trackers.get(e);t&&(t.untrack&&t.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 t=new MutationObserver((()=>{this.fixTitle()}));t.observe(e,{childList:!0}),this.titleObserver=t}}fixTitle(){const e=document.title,t="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==t&&(document.title=t)}reportCspIssue(){const e=this.getSessionStorageState();!this.testUserIdentified&&!e.activeApp||this.cspIssueReported||(this.cspIssueReported=!0,rt("csp issue detected"),T({kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const t=this.getAudio();e&&(t.src=e);const s=t.play();this.audioReady=!0,s&&s.catch((e=>{e.name}))}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,t){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:t})).url}featureFlagEnabled(e){return this.featureFlags.has(e)}showNotification(e,t,s){const i={id:++this.notificationIdCounter,label:e,message:t,type:s};this.notifications=[...this.notifications,i],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter((t=>t.id!==e)),this.toggleUI()}warn(...e){console.warn(...e)}nextRef(){return this.refCounter++}}if(void 0===window.userflow||window.userflow._stubbed){const e=Object.assign(window.userflow||{},function(){const e=new St;return{_stubbed:!1,init(t){e.init(t)},identify:(t,s={},i={})=>e.identify(t,s,i),identifyAnonymous:(t={},s={})=>e.identifyAnonymous(t,s),isIdentified:()=>e.isIdentified(),updateUser:(t,s={})=>e.updateUser(t,s),group:(t,s={},i={})=>e.group(t,s,i),updateGroup:(t,s={})=>e.updateGroup(t,s),track:(t,s={},i={})=>e.track(t,s,i),start:(t,{once:s}={})=>e.startFlow({flowId:t,startReason:L.USERFLOWJS,once:s}),startFlow:e=>(console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),startWalk:e=>(console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),endAll:()=>e.endAllFlows(),endChecklist:()=>e.endChecklist(),endAllFlows:()=>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(){e.openResourceCenter()},closeResourceCenter(){e.closeResourceCenter()},toggleResourceCenter(){e.toggleResourceCenter()},setResourceCenterLauncherHidden(t){e.setResourceCenterLauncherHidden(t)},getResourceCenterState:()=>e.getResourceCenterState(),setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){e.reset()},remount(){e.remount()},on(t,s){e.on(t,s)},off(t,s){e.off(t,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&&et.customInputs.push({cssSelector:e})},registerCustomInput(e,t){et.customInputs.push({cssSelector:e,getValue:t})},setCustomNavigate(e){et.customNavigate=e},setUrlFilter(e){et.urlFilter=e},setLinkUrlDecorator(t){et.linkUrlDecorator=t,e.emit("uistatechange")},setInferenceAttributeNames(e){et.inferenceAttributeNames=e},setInferenceAttributeFilter(e,t){et.inferenceAttributeFilters[e]=tt(t)},setInferenceClassNameFilter(e){et.inferenceClassNameFilters=tt(e)},setScrollPadding(e){et.scrollPadding=e},setCustomScrollIntoView(e){et.customScrollIntoView=e},prepareAudio(){e.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(t){e.pageTrackingDisabled=t},setBaseZIndex(e){et.baseZIndex=e},setServerEndpoint(e){et.serverEndpoint=e},disableEvalJs(){et.evalJsDisabled=!0},_setTargetEnv(t){e.setTargetEnv(t)}}}());window.userflow=e,window.studio1=e,function(){const e=window.userflow,t=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!t||0===t.length)return;rt(`processing ${t.length} items in the queue`);for(const[s,i,n]of t){if("function"!=typeof e[s]){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const t=e[s](...n);i&&t&&"function"==typeof t.then&&t.then(i.resolve,i.reject)}rt("queue processed")}()}export{Ye as $,Ne as A,Et as B,me as C,W as D,m as E,P as F,Y as G,a as H,Ve as I,X as J,ne as K,ce as L,Q as M,j as N,de as O,He as P,Oe as Q,lt as R,L as S,ut as T,o as U,re as V,De as W,We as X,Fe as Y,Pe as Z,n as _,B as a,N as a0,F as b,et as c,rt as d,D as e,H as f,it as g,Ie as h,c as i,dt as j,se as k,ee as l,ue as m,Ae as n,p as o,_ as p,Le as q,d as r,l as s,st as t,g as u,Te as v,fe as w,pe as x,ht as y,V as z};export default window.userflow;
1
+ import{S as e}from"./vendor.phoenix.js";import{v as t}from"./vendor.uuid.js";let s;const i={},n=function(e,t){if(!t)return e();if(void 0===s){const e=document.createElement("link").relList;s=e&&e.supports&&e.supports("modulepreload")?"modulepreload":"preload"}return Promise.all(t.map((e=>{if(e in i)return;i[e]=!0;const t=e.endsWith(".css"),n=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${n}`))return;const o=document.createElement("link");return o.rel=t?"stylesheet":s,t||(o.as="script",o.crossOrigin=""),o.href=e,document.head.appendChild(o),t?new Promise(((e,t)=>{o.addEventListener("load",e),o.addEventListener("error",t)})):void 0}))).then((()=>e()))};class o extends Error{constructor(e,t,s){super(e),Object.setPrototypeOf(this,o.prototype),this.name="UserflowError",this.code=t,this.humanMessage=s}}class r{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}isSupported(){if("undefined"==typeof window)return!1;try{return null!=window[this.type]}catch{return!1}}getItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].getItem(e):null}setItem(e,t){e=this.formatKey(e),this.isSupported()&&window[this.type].setItem(e,t)}removeItem(e){if(e=this.formatKey(e),this.isSupported())return window[this.type].removeItem(e)}clear(){if(this.isSupported())return window[this.type].clear()}}const a=new r("localStorage"),c=new r("sessionStorage");function l(e){window.location.href=e}function d(){return window.location.href}var h,u,E;function T(e){window.postMessage(e,window.origin)}function S(e){const t=t=>{if(t.source!==window||t.origin!==window.origin)return;const i=t.data;i&&"object"==typeof i&&"string"==typeof i.kind&&i.kind.startsWith("userflow:")&&!0===e(i)&&s()};window.addEventListener("message",t);const s=()=>window.removeEventListener("message",t);return s}(h||(h={})).INPUT="INPUT",(E=u||(u={})).AUTO="AUTO",E.MANUAL="MANUAL";const f=new Set;let w=!1;function p(e){return function(){if(w)return;w=!0;const{history:e}=window,t=t=>{const s=e[t];e[t]=(...t)=>{s.apply(e,t),I()}};t("pushState"),t("replaceState"),window.addEventListener("popstate",(()=>{I()}))}(),f.add(e),()=>{g(e)}}function g(e){f.delete(e)}function I(){f.forEach((e=>e()))}class C{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){T({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=S(e),!1}async captureScreenshot(e,t,s,i){T({kind:"userflow:crxScreenshot",x:e,y:t,width:s,height:i,devicePixelRatio:window.devicePixelRatio});var n;return(await(n=e=>"userflow:crxScreenshotResult"===e.kind?e:null,new Promise((e=>{S((t=>{const s=n(t);return!!s&&(e(s),!0)}))})))).imageDataUrl}}var m,k,A,U,L,R,N,v,O,y,_,b,D,M,F,B,P,x,H,G,W,$,V,K,j,z,Y,J,X,Z,Q,q,ee,te,se,ie,ne,oe,re,ae,ce,le,de,he,ue,Ee,Te,Se,fe,we,pe,ge,Ie,Ce,me,ke,Ae,Ue,Le,Re,Ne,ve,Oe,ye,_e,be,De,Me,Fe,Be,Pe,xe,He,Ge,We,$e,Ve,Ke,je,ze,Ye,Je,Xe,Ze,Qe,qe;(k=m||(m={})).ACTION="ACTION",k.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",k.REPLACED="REPLACED",k.SNOOZED="SNOOZED",k.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",k.USERFLOWJS="USERFLOWJS",k.USER_CLOSED="USER_CLOSED",(U=A||(A={})).SECOND="SECOND",U.MINUTE="MINUTE",U.HOUR="HOUR",U.DAY="DAY",(R=L||(L={})).ACTION="ACTION",R.DRAFT="DRAFT",R.LINK="LINK",R.LAUNCHER_SEEN="LAUNCHER_SEEN",R.RESOURCE_CENTER="RESOURCE_CENTER",R.USERFLOWJS="USERFLOWJS",(v=N||(N={})).LIKE="LIKE",v.DISLIKE="DISLIKE",(y=O||(O={})).STRING="STRING",y.BOOLEAN="BOOLEAN",y.NUMBER="NUMBER",y.DATETIME="DATETIME",y.LIST="LIST",y.RANDOM_AB="RANDOM_AB",y.RANDOM_NUMBER="RANDOM_NUMBER",(b=_||(_={})).FLOW="FLOW",b.BANNER="BANNER",b.CHECKLIST="CHECKLIST",b.LAUNCHER="LAUNCHER",b.RESOURCE_CENTER="RESOURCE_CENTER",(M=D||(D={})).ALWAYS_TRUE="ALWAYS_TRUE",M.ATTRIBUTE="ATTRIBUTE",M.CLAUSE="CLAUSE",M.ELEMENT="ELEMENT",M.FILLED_IN_INPUT="FILLED_IN_INPUT",M.FLOW="FLOW",M.INPUT_VALUE="INPUT_VALUE",M.PAGE="PAGE",M.SEGMENT="SEGMENT",M.TIME="TIME",function(e){e.AUTO="AUTO",e.MANUAL="MANUAL"}(F||(F={})),(B||(B={})).INPUT="INPUT",(x=P||(P={})).ABSOLUTE_EQ="ABSOLUTE_EQ",x.ABSOLUTE_GT="ABSOLUTE_GT",x.ABSOLUTE_LT="ABSOLUTE_LT",x.AND="AND",x.BETWEEN="BETWEEN",x.CONTAINS="CONTAINS",x.EMPTY="EMPTY",x.ENDS_WITH="ENDS_WITH",x.EQ="EQ",x.EXCLUDES_ALL="EXCLUDES_ALL",x.EXCLUDES_ANY="EXCLUDES_ANY",x.FALSE="FALSE",x.GT="GT",x.GTE="GTE",x.INCLUDES_ALL="INCLUDES_ALL",x.INCLUDES_ANY="INCLUDES_ANY",x.LT="LT",x.LTE="LTE",x.NE="NE",x.NOT_CONTAINS="NOT_CONTAINS",x.NOT_EMPTY="NOT_EMPTY",x.NOT_REGEX="NOT_REGEX",x.OR="OR",x.REGEX="REGEX",x.RELATIVE_EQ="RELATIVE_EQ",x.RELATIVE_GT="RELATIVE_GT",x.RELATIVE_LT="RELATIVE_LT",x.STARTS_WITH="STARTS_WITH",x.TRUE="TRUE",x.URL="URL",(G=H||(H={})).CLICK="CLICK",G.DISABLED="DISABLED",G.MOUSEDOWN="MOUSEDOWN",G.NOT_CLICK="NOT_CLICK",G.NOT_DISABLED="NOT_DISABLED",G.NOT_PRESENT="NOT_PRESENT",G.PRESENT="PRESENT",($=W||(W={})).ASSET="ASSET",$.CARTOON="CARTOON",$.NONE="NONE",$.URL="URL",(K=V||(V={})).INSIDE="INSIDE",K.OUTSIDE="OUTSIDE",(z=j||(j={})).TOP_LEFT="TOP_LEFT",z.TOP_CENTER="TOP_CENTER",z.TOP_RIGHT="TOP_RIGHT",z.BOTTOM_RIGHT="BOTTOM_RIGHT",z.BOTTOM_CENTER="BOTTOM_CENTER",z.BOTTOM_LEFT="BOTTOM_LEFT",z.CENTER="CENTER",(J=Y||(Y={})).GOOGLE="GOOGLE",J.STANDARD="STANDARD",(Z=X||(X={})).DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",Z.DISMISS="DISMISS",(q=Q||(Q={})).DISMISS="DISMISS",q.NONE="NONE",(te=ee||(ee={})).DEFAULT="DEFAULT",te.PLAINTEXT="PLAINTEXT",(ie=se||(se={})).CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",ie.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",ie.NONE="NONE",(oe=ne||(ne={})).BUBBLE="BUBBLE",oe.END="END",oe.ERROR="ERROR",oe.FLAG="FLAG",(ae=re||(re={})).MANUAL="MANUAL",ae.NONE="NONE",ae.SYNTHETIC="SYNTHETIC",(le=ce||(ce={})).BUBBLE="BUBBLE",le.HIDDEN="HIDDEN",le.MODAL="MODAL",le.TOOLTIP="TOOLTIP",(he=de||(de={})).ABOVE="ABOVE",he.BELOW="BELOW",he.LEFT="LEFT",he.RIGHT="RIGHT",(Ee=ue||(ue={})).CLOSE_FLOW="CLOSE_FLOW",Ee.EVAL_JS="EVAL_JS",Ee.GO_TO_STEP="GO_TO_STEP",Ee.NAVIGATE="NAVIGATE",Ee.SET_ATTRIBUTE="SET_ATTRIBUTE",Ee.SNOOZE="SNOOZE",Ee.START_FLOW="START_FLOW",(Se=Te||(Te={})).NEW_TAB="NEW_TAB",Se.SAME_TAB="SAME_TAB",(we=fe||(fe={})).SET="SET",we.SET_DATETIME="SET_DATETIME",we.SET_DATETIME_ONCE="SET_DATETIME_ONCE",we.SET_ONCE="SET_ONCE",we.ADD="ADD",we.SUBTRACT="SUBTRACT",we.APPEND="APPEND",we.PREPEND="PREPEND",we.REMOVE="REMOVE",we.UNSET="UNSET",(ge=pe||(pe={})).MULTILINE_TEXT="MULTILINE_TEXT",ge.MULTIPLE_CHOICE="MULTIPLE_CHOICE",ge.NPS="NPS",ge.SCALE="SCALE",ge.STARS="STARS",ge.TEXT="TEXT",(Ce=Ie||(Ie={})).ACTION="ACTION",Ce.ANNOUNCEMENTS="ANNOUNCEMENTS",Ce.ASSISTANT="ASSISTANT",Ce.CHECKLIST="CHECKLIST",Ce.CONTACT="CONTACT",Ce.DIVIDER="DIVIDER",Ce.FLOWS="FLOWS",Ce.KNOWLEDGE_BASE="KNOWLEDGE_BASE",Ce.MESSAGE="MESSAGE",Ce.SUBPAGE="SUBPAGE",(ke=me||(me={})).CRISP="CRISP",ke.CUSTOM="CUSTOM",ke.FRESHCHAT="FRESHCHAT",ke.HELPSCOUT="HELPSCOUT",ke.HUBSPOT="HUBSPOT",ke.INTERCOM="INTERCOM",ke.ZENDESK="ZENDESK",ke.ZENDESK_MESSENGER="ZENDESK_MESSENGER",(Ue=Ae||(Ae={})).BUTTON="BUTTON",Ue.INPUT="INPUT",(Re=Le||(Le={})).EMAIL="EMAIL",Re.PHONE="PHONE",Re.CHAT="CHAT",(ve=Ne||(Ne={})).SILENT="SILENT",ve.BADGE="BADGE",ve.POPOUT="POPOUT",(ye=Oe||(Oe={})).LAUNCHER_CLICK="LAUNCHER_CLICK",ye.LAUNCHER_HOVER="LAUNCHER_HOVER",ye.TARGET_CLICK="TARGET_CLICK",ye.TARGET_HOVER="TARGET_HOVER",ye.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",ye.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",(be=_e||(_e={})).ACTIVATE="ACTIVATE",be.DEACTIVATE="DEACTIVATE",be.NEVER="NEVER",(Me=De||(De={})).AUTO="AUTO",Me.TOP="TOP",Me.RIGHT="RIGHT",Me.BOTTOM="BOTTOM",Me.LEFT="LEFT",(Be=Fe||(Fe={})).START="START",Be.CENTER="CENTER",Be.END="END",(xe=Pe||(Pe={})).PERCENT="PERCENT",xe.PX="PX",(Ge=He||(He={})).BEACON="BEACON",Ge.BUTTON="BUTTON",Ge.HIDDEN="HIDDEN",Ge.ICON="ICON",($e=We||(We={})).LAUNCHER="LAUNCHER",$e.TARGET="TARGET",(Ke=Ve||(Ve={})).BODY_FIRST="BODY_FIRST",Ke.BODY_LAST="BODY_LAST",Ke.ELEMENT_FIRST="ELEMENT_FIRST",Ke.ELEMENT_LAST="ELEMENT_LAST",Ke.ELEMENT_BEFORE="ELEMENT_BEFORE",Ke.ELEMENT_AFTER="ELEMENT_AFTER",(ze=je||(je={})).START="START",ze.CENTER="CENTER",ze.SPACE_BETWEEN="SPACE_BETWEEN",(Je=Ye||(Ye={})).NONE="NONE",Je.LIKE="LIKE",Je.SCALE="SCALE",(Ze=Xe||(Xe={})).ACTIVE="ACTIVE",Ze.COMPLETED="COMPLETED",Ze.ENDED="ENDED",Ze.NOT_SEEN="NOT_SEEN",(qe=Qe||(Qe={})).HIGHLIGHT="HIGHLIGHT",qe.MODAL="MODAL",qe.HIGHLIGHT_MODAL="HIGHLIGHT_MODAL";const et={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:[e=>!e.match(/\d$/)],"data-id":[e=>!e.match(/\d$/)]},inferenceClassNameFilters:[e=>!e.startsWith("css-")],baseZIndex:1234500,evalJsDisabled:!1};function tt(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map((e=>"string"==typeof e?new RegExp(e):e))}function st(e,t){return e.every((e=>"function"==typeof e?e(t):!(e instanceof RegExp)||e.test(t)))}function it(){let e=d();if(et.urlFilter){if(e=et.urlFilter(e),"string"!=typeof e)throw new o("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(e)}catch(t){throw new o("Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.\nReturned URL: "+e+"\nError message: "+t.message)}}return e}let nt="";try{nt=localStorage.getItem("debug")||""}catch(ft){}const ot=nt.split(",").some((e=>"*"===e||e.startsWith("userflow:*"))),rt=ct("log");let at;function ct(e){return function(t,...s){if(ot){const i=performance.now(),n=at?Math.round(i-at):0;at=i,console[e](`%cuserflow %c${t} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}rt.group=ct("group"),rt.groupCollapsed=ct("groupCollapsed"),rt.groupEnd=function(){ot&&console.groupEnd()};const lt=()=>n((()=>import("./ResourceCenterApp.js").then((function(e){return e.R}))),[new URL("ResourceCenterApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("flow-host.styl.js",import.meta.url).toString(),new URL("bubble-frame.styl.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("use-element-rect.js",import.meta.url).toString()]);function dt(e){const t=e.version.checklist.tasks.length;return Math.max(0,t-e.taskCompletions.length)}class ht{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 e of this.observers)e()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const ut=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],Et=()=>n((()=>import("./BannerApp.js")),[new URL("BannerApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("bubble-frame.styl.js",import.meta.url).toString(),new URL("flow-host.styl.js",import.meta.url).toString(),new URL("use-selector-element-monitoring.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("use-element-rect.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]),Tt=import.meta.url;class St{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.featureFlags=new Set,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.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.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.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{rt(`builder ${e.kind} message received`,e);const t="idempotencyKey"in e&&"string"==typeof e.idempotencyKey?e.idempotencyKey:null;if(t&&this.idempotencyKeysSeen.has(t))return;const s=()=>{t&&this.idempotencyKeysSeen.add(t)};switch(e.kind){case"userflow:selectElement":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),void this.setSessionStorageState((t=>({...t,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}})));case"userflow:selectElementCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,elementSelection:null})));case"userflow:startFlowWithToken":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState((e=>({...e,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0}))),c.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void(e.testStartCondition?this.setSessionStorageState((t=>({...t,activeApp:"startConditionTesting",testStartConditionToken:e.token}))):this.onceIdentified((()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const t=()=>{const s=this.resourceCenterSession;s&&s.draftMode&&s.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",t))};this.on("resourceCenterChanged",t),t()}})));case"userflow:testTracker":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState((e=>({...e,isTargetTab:!0}))),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.setSessionStorageState((t=>({...t,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}})));case"userflow:testTrackerCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,trackerTesting:null})))}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout((()=>this.flushUrlChange()),50))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{this.ui?.container&&!document.contains(this.ui.container)&&(rt("remounting UI because container was missing"),this.remount())},rt("constructor, build=1004513"),p(this.onUrlChange),this.setTargetEnv(new C),this.checkTestUserAtBoot(),this.toggleUI();for(const e of ut)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){rt("destroy"),this.reset(),g(this.onUrlChange),this.destroyTargetEnv();for(const e of ut)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 o("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const t=e(this.getSessionStorageState());c.setItem("userflowClientState",JSON.stringify(t)),this.sessionStorageState=t,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const t=c.getItem("userflowClientState");if(t)try{e=JSON.parse(t)}catch(ft){console.error("Userflow.js: Parse ElementSelectionState error:",ft)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(rt("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState((t=>({...t,testUser:e}))),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const t=[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:s}=e;s&&(this.groupId=s.id,t.push(this.group(s.id,{name:s.name},{signature:s.signature}))),await Promise.all(t)}resetTestUser(){this.setSessionStorageState((e=>({...e,testUser:null})))}init(e){if(rt("init",e),!e)throw new o("userflow.init() was called but missing Userflow.js Token");this.clientToken!==e&&(this.testUserIdentified?rt("init() ignoring new token since a test user has been identified"):(this.clientToken&&(rt("init() resetting due to new client token"),this.reset()),this.clientToken=e))}ensureInit(){if(!this.clientToken)throw new o("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new o("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new o("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId)return;if(this.debounceInactiveDisconnect(),this.socket)return;this._socketStatus="connecting",rt("connecting to socket");let t=et.serverEndpoint||"e.userflow.com";"js.getuserflow.com"===new URL(Tt).hostname&&"e.userflow.com"===t&&(t="e.getuserflow.com");const s="wss://"+t+"/end-users/"+this.clientToken+"/socket";this.socket=new e(s,{reconnectAfterMs:e=>[100,500,1e3,5e3][e-1]||1e4,timeout:2e4}),this.socket.connect(),this.socket.onOpen((()=>{rt("socket opened")})),this.socket.onClose((()=>{this.emit("private:disconnect")})),this.socket.onError((e=>{console.log("Userflow.js socket error",e),this.reportCspIssue()})),this.channel=this.socket.channel(`end_users:${this.externalId}`,(()=>this.makeChannelJoinPayload())),this.channel.join().receive("ok",(e=>{this.logrocketAppId=e.logrocketAppId,this.featureFlags=new Set(e.featureFlags),rt("channel joined"),"connected"!==this._socketStatus&&(this._socketStatus="connected")})).receive("error",(e=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(e.code)?(console.error(`Userflow.js resetting due to: [${e.code}] ${e.message}`),this.reset(),this.clientToken=null):"invalid_protocol_version"===e.code?(console.error(`Userflow.js destroying due to: [${e.code}] ${e.message}`),this.destroy()):console.log("Userflow.js channel join error",e)})),this.channel.on("server_message",(e=>this.handleServerMessage(e))),this.channel.on("server_error",(e=>{console.log(`Userflow.js server error (${e.code}): ${e.message}`+(e.details&&e.details.length>0?"\nDetails:\n"+e.details.map((e=>(e.path?`${e.path}: `:"")+e.message)):""))}))}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const t={protocolVersion:2,userflowClientBuild:"1004513",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((e=>({flowId:e.flow.id}))),trackers:Array.from(this.trackers.values()).map((e=>({flowId:e.tracker.flowId}))),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map((e=>({conditionId:e.condition.id,isTrue:e.isTrue}))),previewFlowId:c.getItem("previewFlowId"),clientContext:e};return rt("channel join payload",t),t}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((()=>{this.hasDraftSession()||this.assistantMessageInProgress?this.debounceInactiveDisconnect():(rt("disconnecting from socket due to inactivity"),this.disconnect())}),3e5)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some((e=>e.draftMode))}async send(e,{batch:t,endBatch:s,handlesRejection:i}={}){return this.inBatch&&["ToggleClientCondition","UpdateClientContext"].includes(e.kind)||this.checkPushRateLimit(),this.ensureConnected(),t&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),s?this.endBatch():this.endBatchTimeout=window.setTimeout((()=>{this.endBatch()}),50)),this.sendRaw(e,{handlesRejection:i})}async sendRaw(e,{handlesRejection:t}={}){return new Promise(((s,i)=>{if(!this.channel){const s=`Userflow.js: send() should not be called if channel is not set. Message kind=${e.kind}`;if(t)throw Error(s);return void console.log(s,"\nClient message:",e)}rt(`push ${e.kind} message`,e);const n=this.clientClock,r=()=>{this.serverClock=n,this.channel?.off("phx_error",a)},a=this.channel.on("phx_error",(s=>{r();const n=`Userflow.js send ${e.kind} got phx_error`;"connected"===this._socketStatus&&console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n))}));this.channel.push("client_message",e).receive("ok",(e=>{r(),s(e)})).receive("error",(s=>{r();const n=`Userflow.js error reply (${s.code}): ${s.message}`;console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n,s.code,s.message))}))}))}endBatch(){this.inBatch=!1,this.sendRaw({kind:"EndBatch"})}checkPushRateLimit(){const e=Date.now();if(this.pushRateLimitMinuteExpires<e&&(this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=e+6e4),this.pushRateLimitMinute>=100)throw new o("This Userflow.js client has reached a maximum of 100 operations in the last 1 minute. This is usually due to one of the following:\n\n - Excessive calls to Userflow.js. Check if any of userflow.track(), userflow.identify(), userflow.updateUser() or similar are called repeatedly.\n - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.\n - The user legitimately being very active, in which case you can just ignore this error.\n \n If in doubt, reach out to us at support@userflow.com.");this.pushRateLimitMinute++}handleServerMessage(e){rt(`received ${e.kind} message`,e);const{serverClock:t,flowSession:s,flowSessionClock:i,checklistSession:n,checklistSessionClock:o,bannerSession:r,resourceCenterSession:a}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:t}=e,s=this.launcherSessions.findIndex((e=>e.flow.id===t.flow.id));return this.launcherSessions=-1===s?[...this.launcherSessions,t]:[...this.launcherSessions.slice(0,s),t,...this.launcherSessions.slice(s+1)],void this.toggleUI()}case"AddTracker":return void this.addTracker(e.tracker);case"AssistantMessageEventWrapper":return void this.emit("private:assistantMessageEvent",e);case"CancelConditionWaitTimer":return window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),void this.conditionWaitTimers.delete(e.conditionId);case"ChecklistTaskCompleted":return void this.unackedTasks.add(e.taskCvid);case"ForceGoToStep":return i>t?void rt(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&this.emit("gotostep",{session:s,step:{id:e.stepId}}));case"RemoveLauncher":return void(this.removeLauncher(e.flowId)&&this.toggleUI());case"RemoveTracker":return void this.removeTracker(e.flowId);case"SetBannerSession":return this.setBannerSession(e.session),void this.toggleUI();case"SetChecklistSession":return void(o<=t||n?.id===e.session.id?(this.setChecklistSession(e.session,t),this.toggleUI()):rt(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`));case"SetFlowSession":return void(i<=t||s?.id===e.session.id?(this.setFlowSession(e.session,t),this.toggleUI()):rt(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`));case"SetResourceCenterSession":return this.setResourceCenterSession(e.session),void this.toggleUI();case"StartConditionWaitTimer":if(!this.conditionWaitTimers.has(e.conditionId)){const t=window.setTimeout((()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})}),1e3*parseFloat(e.waitTime));this.conditionWaitTimers.set(e.conditionId,t)}return;case"TestStartConditionSuccess":return void this.emit("private:testStartConditionSuccess");case"TrackClientCondition":return void this.trackClientCondition(e.condition);case"UnsetBannerSession":return void(r?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI()));case"UnsetChecklistSession":return o>t?void rt(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`):void(n?.id===e.sessionId&&(this.setChecklistSession(null,t),this.toggleUI()));case"UnsetFlowSession":return i>t?void rt(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&(this.setFlowSession(null,t),this.toggleUI()));case"UnsetResourceCenterSession":return void(a?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI()));case"UntrackClientCondition":return void this.untrackClientCondition(e.conditionId);default:return void console.warn("Userflow.js: Received unknown message",e)}}async identify(e,t={},{signature:s}={}){if(rt("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId)rt("identify() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`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&&(rt("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=s||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(t)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}}async identifyAnonymous(e={},s={}){if(!a.isSupported())throw new o("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const i="anonymousId";let n=a.getItem(i);n||(n="anon-"+t(),a.setItem(i,n)),await this.identify(n,e,s)}async updateUser(e={},t={}){rt("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,t={},{signature:s,membership:i}={}){if(rt("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId)rt("group() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`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=s||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(t),membershipAttributes:this.normalizeAttributes(i)},{batch:!0})}}async updateGroup(e={},t={}){rt("updateGroup");const s=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:s,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(t.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(null==e)return{};if("object"!=typeof e)throw new o("Userflow: 'attributes' must be an object.");const t={};for(const s in e){if(!e.hasOwnProperty(s))continue;if("traits"===s){const i=e[s];Object.assign(t,this.extractLegacyTraits(i));continue}let i=e[s];if("string"==typeof i||"number"==typeof i||"boolean"==typeof i||null==i||Array.isArray(i))t[s]=this.normalizeAttributeLiteralOrList(s,i);else{if("object"!=typeof i||null==i)throw new o(`Userflow: Invalid value for '${s}' attribute.`);if("set"in i)t[s]={set:this.normalizeAttributeLiteralOrList(s,i.set),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("set_once"in i||"setOnce"in i)t[s]={setOnce:this.normalizeAttributeLiteralOrList(s,i.set_once??i.setOnce),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("add"in i){const e=i.add;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'add' value for '${s}' attribute. Must be a number or string.`);t[s]={add:e}}else if("subtract"in i){const e=i.subtract;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'subtract' value for '${s}' attribute. Must be a number or string.`);t[s]={subtract:e}}else if("append"in i)t[s]={append:this.normalizeAttributeLiteralOrList(s,i.append)};else if("prepend"in i)t[s]={prepend:this.normalizeAttributeLiteralOrList(s,i.prepend)};else{if(!("remove"in i))throw new o(`Userflow: Invalid value for '${s}' attribute.`);t[s]={remove:this.normalizeAttributeLiteralOrList(s,i.remove)}}}}return t}normalizeAttributeLiteralOrList(e,t){return Array.isArray(t)?t.map((t=>this.normalizeAttributeLiteral(e,t))):this.normalizeAttributeLiteral(e,t)}normalizeAttributeLiteral(e,t){if(null==t)return null;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return t;throw new o(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,t){if(!t)return null;switch(t){case"string":return O.STRING;case"number":return O.NUMBER;case"boolean":return O.BOOLEAN;case"datetime":return O.DATETIME}throw new o(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push({name:s,value:e[s]});e=t}return e.reduce(((e,{name:t,value:s,dataType:i})=>{if("string"!=typeof t||t.length>100||!t.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:",t),e;if("string"==typeof s);else if("boolean"==typeof s)i||(i="boolean"),s=s?"true":"false";else{if("number"!=typeof s)return this.warn(`userflow.identify: The value of trait '${t}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,s),e;i||(i=Number.isInteger(s)?"integer":"decimal"),s=String(s)}let n=null;if(i)switch(i){case"string":n=O.STRING;break;case"boolean":n=O.BOOLEAN;break;case"integer":case"decimal":n=O.NUMBER;break;case"datetime":n=O.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${t}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,i),e}return e[t]={set:s,dataType:n},e}),{})}async track(e,t={},{userOnly:s}={}){rt(`track '${e}'`,t),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!s,name:e,attributes:this.normalizeEventAttributes(t)},{batch:!0})}normalizeEventAttributes(e){const t=this.normalizeAttributes(e);for(const s in t){if(!t.hasOwnProperty(s))continue;const e=t[s];if(null!=e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Array.isArray(e)&&!("set"in e))throw new o(`Userflow: Invalid value for '${s}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return t}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(d()),t=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");t&&(rt(`url contained flow ${t}`),this.startFlow({flowId:t,startReason:L.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",{})}buildClientContext(){return{pageUrl:it(),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 null!=this.externalId}on(e,t){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s)),s.add(t)}off(e,t){const s=this.listeners.get(e);s&&s.delete(t)}emit(e,...t){const s=this.listeners.get(e);if(s){Array.from(s).forEach((e=>e(...t)))}}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(){rt("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,t)=>{this.untrackClientCondition(t)})),this.firstIdentifyCallback=null,this.testUserIdentified=!1,a.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)}async startFlow({flowId:e,stepCvid:t,startReason:s,once:i,batch:n,replaceCurrent:o}){if(this.ensureIdentified(),o&&this.flowSession&&this.endFlow(this.flowSession,{endReason:m.REPLACED,batch:!0}),rt(`startFlow ${e}`,{startReason:s}),this.checklistSession?.flow.id===e)return rt("startFlow matches current checklist, so showing it instead"),void this.showChecklist();const r={kind:"StartFlow",flowId:e,stepCvid:t,startReason:s,once:!!i};await this.send(r,{batch:n})}async startFlowWithToken(e){this.ensureIdentified(),rt("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){this.resourceCenterEmbedsChecklist()?this.openResourceCenter():(this.unmarkExpandPending(),this.checklistSession&&!this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),c.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0})))}async hideChecklist(){this.resourceCenterEmbedsChecklist()?this.closeResourceCenter():this.checklistSession&&this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),c.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"),c.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"),c.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:t}=this,s=this.resourceCenterSession.version.resourceCenter?.blocks.find((e=>e.type===Ie.ANNOUNCEMENTS));return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&t?dt(t):0,unreadAnnouncementCount:s?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some((e=>e.type===Ie.CHECKLIST))}async endFlow(e,{endReason:t,batch:s}){this.ensureIdentified(),this.optimisticClockUIUpdate((()=>{const{clientClock:t}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,t),this.checklistSession?.id===e.id&&this.setChecklistSession(null,t),this.bannerSession?.id===e.id&&this.setBannerSession(null),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)}));const{flow:i}=e,n={id:i.id,type:i.type.toLowerCase()};i.type===_.CHECKLIST?this.emit("checklistEnded",{checklist:n,endReason:t}):i.type===_.FLOW&&this.emit("flowEnded",{flow:n,endReason:t});const o={kind:"EndFlow",sessionId:e.id,endReason:t};await this.send(o,{batch:s})}async goToStep(e,t){rt("goToStep",e.id,t.name||t.id),this.ensureIdentified();const s=this.send({kind:"GoToStep",sessionId:e.id,stepId:t.id});e.currentStep=t,this.emit("gotostep",{session:e,step:t}),await s}async endAllFlows(){rt("endAllFlows"),this.optimisticClockUIUpdate((()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)})),await this.send({kind:"EndAllFlows"})}async endChecklist(){rt("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===_.CHECKLIST&&this.endFlow(e,{endReason:m.USERFLOWJS})}setFlowSession(e,t=this.clientClock){const s=this.flowSession;this.flowSession=e,this.flowSessionClock=t,e&&!s&&(this.hideChecklist(),this.closeResourceCenter()),null==e&&this.originalActiveElement&&("function"==typeof this.originalActiveElement.focus&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,t=this.clientClock){const s=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=t,null===e&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==s?.id&&(this.checklistExpanded=!!c.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setBannerSession(e){this.bannerSession=e}setResourceCenterSession(e){const t=this.resourceCenterSession;e="function"==typeof e?e(this.resourceCenterSession):e,this.resourceCenterSession=e,null===e&&(this.resourceCenterOpen=!1),t&&t.id!==e?.id&&c.removeItem(`resourceCenterOpen:${t.id}`),e&&e.id!==t?.id&&(this.resourceCenterOpen=!!c.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:L.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const t=this.activeLauncherFlowId&&this.launcherSessions.find((e=>e.flow.id===this.activeLauncherFlowId));t&&this.deactivateLauncher(t),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:t}=e.version;e.flow.id===this.activeLauncherFlowId&&(t?.dismissOn===_e.DEACTIVATE?this.dismissLauncher(e,{endReason:m.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:t}){const s=e.flow.id;this.removeLauncher(s),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:s,endReason:t})}removeLauncher(e){const t=this.launcherSessions.findIndex((t=>t.flow.id===e));return-1!==t&&(this.launcherSessions=[...this.launcherSessions.slice(0,t),...this.launcherSessions.slice(t+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const e=this.getSessionStorageState();this.flowSession||!this.checklistExpandPending&&!this.checklistSession?.version.checklist?.tasks.some((e=>this.taskIsUnacked(e.cvid)))||this.showChecklist(),e.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){if(this.uiDisabled)return!1;return!!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&&(rt("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(rt("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=n((()=>import("./ui.js")),[new URL("ui.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);this.bannerSession&&Et(),this.resourceCenterSession&&lt();const{RealUI:t}=await e;return new t(this)}catch(ft){throw this.reportCspIssue(),ft}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;rt("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:t}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.v}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),s=t[e.type],i=this.clientConditions.get(e.id);i&&(i.untrack=s.track({sessionData:new ht([]),condition:e,callback:t=>{i.isTrue!==t&&(rt("client condition truthiness changed",t,i.condition),i.isTrue=t,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:t},{batch:!0}))}}))}untrackClientCondition(e){const t=this.clientConditions.get(e);t&&(rt("untrack client condition",t.condition),t.untrack&&t.untrack(),this.clientConditions.delete(e))}async addTracker(e){let t=this.trackers.get(e.flowId);t?t.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:s}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.v}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),i=this.trackers.get(e.flowId);if(!i)return;const{tracker:o}=i,{condition:r}=o,a=s[r.type];i.untrack&&i.untrack(),i.untrack=a.track({sessionData:new ht(o.data),condition:r,flipBackEvents:!0,callback:e=>{const t=i.isTrue;i.isTrue=e,!t&&e&&this.send({kind:"TrackTrackerEvent",token:o.token},{batch:!0})},description:`event tracker ${o.flowId}`}),this.emit("private:trackerStarted")}removeTracker(e){const t=this.trackers.get(e);t&&(t.untrack&&t.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 t=new MutationObserver((()=>{this.fixTitle()}));t.observe(e,{childList:!0}),this.titleObserver=t}}fixTitle(){const e=document.title,t="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==t&&(document.title=t)}reportCspIssue(){const e=this.getSessionStorageState();!this.testUserIdentified&&!e.activeApp||this.cspIssueReported||(this.cspIssueReported=!0,rt("csp issue detected"),T({kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const t=this.getAudio();e&&(t.src=e);const s=t.play();this.audioReady=!0,s&&s.catch((e=>{e.name}))}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,t){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:t})).url}featureFlagEnabled(e){return this.featureFlags.has(e)}showNotification(e,t,s){const i={id:++this.notificationIdCounter,label:e,message:t,type:s};this.notifications=[...this.notifications,i],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter((t=>t.id!==e)),this.toggleUI()}warn(...e){console.warn(...e)}nextRef(){return this.refCounter++}}if(void 0===window.userflow||window.userflow._stubbed){const e=Object.assign(window.userflow||{},function(){const e=new St;return{_stubbed:!1,init(t){e.init(t)},identify:(t,s={},i={})=>e.identify(t,s,i),identifyAnonymous:(t={},s={})=>e.identifyAnonymous(t,s),isIdentified:()=>e.isIdentified(),updateUser:(t,s={})=>e.updateUser(t,s),group:(t,s={},i={})=>e.group(t,s,i),updateGroup:(t,s={})=>e.updateGroup(t,s),track:(t,s={},i={})=>e.track(t,s,i),start:(t,{once:s}={})=>e.startFlow({flowId:t,startReason:L.USERFLOWJS,once:s}),startFlow:e=>(console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),startWalk:e=>(console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),endAll:()=>e.endAllFlows(),endChecklist:()=>e.endChecklist(),endAllFlows:()=>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(){e.openResourceCenter()},closeResourceCenter(){e.closeResourceCenter()},toggleResourceCenter(){e.toggleResourceCenter()},setResourceCenterLauncherHidden(t){e.setResourceCenterLauncherHidden(t)},getResourceCenterState:()=>e.getResourceCenterState(),setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){e.reset()},remount(){e.remount()},on(t,s){e.on(t,s)},off(t,s){e.off(t,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&&et.customInputs.push({cssSelector:e})},registerCustomInput(e,t){et.customInputs.push({cssSelector:e,getValue:t})},setCustomNavigate(e){et.customNavigate=e},setUrlFilter(e){et.urlFilter=e},setLinkUrlDecorator(t){et.linkUrlDecorator=t,e.emit("uistatechange")},setInferenceAttributeNames(e){et.inferenceAttributeNames=e},setInferenceAttributeFilter(e,t){et.inferenceAttributeFilters[e]=tt(t)},setInferenceClassNameFilter(e){et.inferenceClassNameFilters=tt(e)},setScrollPadding(e){et.scrollPadding=e},setCustomScrollIntoView(e){et.customScrollIntoView=e},prepareAudio(){e.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(t){e.pageTrackingDisabled=t},setBaseZIndex(e){et.baseZIndex=e},setServerEndpoint(e){et.serverEndpoint=e},disableEvalJs(){et.evalJsDisabled=!0},_setTargetEnv(t){e.setTargetEnv(t)}}}());window.userflow=e,window.studio1=e,function(){const e=window.userflow,t=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!t||0===t.length)return;rt(`processing ${t.length} items in the queue`);for(const[s,i,n]of t){if("function"!=typeof e[s]){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const t=e[s](...n);i&&t&&"function"==typeof t.then&&t.then(i.resolve,i.reject)}rt("queue processed")}()}export{Ye as $,Ne as A,Et as B,me as C,W as D,m as E,P as F,Y as G,a as H,Ve as I,X as J,ne as K,ce as L,Q as M,j as N,de as O,He as P,Oe as Q,lt as R,L as S,ut as T,o as U,re as V,De as W,We as X,Fe as Y,Pe as Z,n as _,B as a,N as a0,F as b,et as c,rt as d,D as e,H as f,it as g,Ie as h,c as i,dt as j,se as k,ee as l,ue as m,Ae as n,p as o,_ as p,Le as q,d as r,l as s,st as t,g as u,Te as v,fe as w,pe as x,ht as y,V as z};export default window.userflow;