userflow.js-self-hosted 0.1.1025143 → 0.1.1025283

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,4 +1,4 @@
1
- import{R as o,r as u}from"./vendor.react.js";import{E as M,a3 as D,a4 as ie,p as T,a5 as ce,a6 as x,r as ue,a7 as O,X as A,j as de,b as pe,a8 as fe}from"./userflow.js";import{k as me}from"./vendor.lodash.js";import"./vendor.object-assign.js";import{u as j}from"./vendor.react-i18next.js";import{B as X,F as be}from"./FlowChrome.js";import{m as Ee,d as K,R as ge,i as we,g as he,b as ve,c as z,h as Te,S as Se}from"./TreeDoc.js";import{g as Q,b as Z}from"./flow-condition-types.js";import{u as F,i as ye}from"./client-context.js";import{u as ke,r as Be}from"./use-selector-element-monitoring.js";import{D as Me,k as De,r as Fe}from"./roots.js";import{a as J,S as Le}from"./flow-host.styl.js";import{r as Ie}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as Re,a as Ne}from"./stylesheets.js";import{T as Ce}from"./Trigger.js";import{f as _,a as Ae}from"./steps.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./Frame.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.obj-str.js";import"./iframe-reset.styl.js";import"./use-window-resize.js";import"./logomark.js";import"./use-confetti.js";import"./vendor.canvas-confetti.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="e79abca6-65df-4bef-a110-733b7c8c88ad",e._sentryDebugIdIdentifier="sentry-dbid-e79abca6-65df-4bef-a110-733b7c8c88ad")}catch{}})();const Pe=()=>{const{t:e}=j(),s=F(),{dispatch:t,restart:n}=R(),{session:i,step:f}=B(),l="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return o.createElement("div",{role:"dialog","aria-modal":I(f)?"true":void 0,"aria-label":"Guide menu"},o.createElement("div",{className:"userflowjs-bubble-menu__title"},e("menu.title")),o.createElement("button",{className:l,onClick:()=>s.endFlow(i,{endReason:M.USER_CLOSED})},e("menu.close")),i.version.restartEnabled&&o.createElement("button",{className:l,onClick:n},e("menu.restart")),o.createElement("button",{className:l,onClick:()=>t({kind:"showFlow"})},e("menu.back")))},Y=({progress:e,type:s,position:t,totalSteps:n})=>{const{t:i}=j(),f=u.useMemo(()=>parseFloat(e||"0"),[e]),l=u.useMemo(()=>({width:`${f*100}%`}),[f]),c=u.useMemo(()=>s===ie.DEFAULT?D.TOP:t,[s,t]),d=c===D.BOTTOM?"userflowjs-bubble-progress--bottom":"",m=u.useMemo(()=>`userflowjs-bubble-progress--${me(s||"DEFAULT").toLowerCase()} ${d}`,[s,d]),a=n||0,r=u.useMemo(()=>Math.min(Math.floor(f*a),a),[f,a]);return o.createElement(o.Fragment,null,(s==="CHAINED_ROUNDED"||s==="CHAINED_SQUARED"||s==="DOTTED")&&o.createElement("div",{className:m},Array.from({length:3}).map((g,E)=>o.createElement("div",{key:E,className:`userflowjs-bubble-progress-step ${E<Math.floor(f*3)?"userflowjs-bubble-progress-step_completed":""}`}))),s==="NARROW"&&o.createElement("div",{className:m},o.createElement("div",{className:"linear-progress-bar"},o.createElement("div",{className:"userflowjs-bubble-progress--narrow-fill",style:l}))),s==="NUMBERED"&&o.createElement("div",{className:m},o.createElement("span",{className:"numbered-progress"},i("of",{replace:{range:a,selected:r}}))),!["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW","NUMBERED"].includes(s)&&o.createElement("div",{className:`${m} ${c===D.BOTTOM?"userflowjs-bubble-progress--bottom":""}`},o.createElement("div",{className:"userflowjs-bubble-progress__fill",style:l})))},xe=({theme:e})=>{const s=F(),{session:t,step:n,muted:i,shouldLabelDialog:f}=B(),{version:l}=t,{dispatch:c}=R(),d=l.steps[0],m=d&&d.id===n.id,a=m&&n.progress==="1",r=u.useMemo(()=>n.content&&Ee(K(n.content),{buttons:n.buttons,questions:n.questions}),[n.content,n.buttons,n.questions]),g=l.steps.filter(S=>S.appearance!==T.HIDDEN),E=g.findIndex(S=>S.id===n.id),w=g.length,h=w>0?((E+1)/w).toString():"0";return o.createElement("div",{key:n.id,role:"alertdialog","aria-modal":I(n)?"true":void 0,"aria-label":f?"Guide":void 0},!a&&e.progressBarPosition==="TOP"&&e.progressBarEnabled&&o.createElement(Y,{progress:h,type:e.progressBarType,position:n.appearance===T.MODAL?void 0:D.TOP,totalSteps:w}),o.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content","data-progress-position":e.progressBarPosition,"data-progress-type":e.progressBarType},o.createElement(ge,{doc:r,lookupAttribute:Q(t.data),buttons:n.buttons,questions:n.questions})),o.createElement(X,{draftMode:t.draftMode,muted:i,toggleMuted:e.voiceType!==x.NONE?()=>c({kind:"toggleMuted"}):void 0,close:l.closeDisabled?void 0:()=>e.flowXButtonBehavior===ce.DISMISS||m?s.endFlow(t,{endReason:M.USER_CLOSED}):c({kind:"showMenu"})}),!a&&e.progressBarPosition==="BOTTOM"&&e.progressBarEnabled&&o.createElement(Y,{progress:h,type:e.progressBarType,position:D.BOTTOM,totalSteps:w}))};function Oe(e,s){if(!e)return"";typeof e=="string"&&(e=K(e));const t=[],n=/[.!?;,]$/;function i(){const c=(t[t.length-1]||"").trim();c&&!c.match(n)&&t.push(".")}function f(c){if(we(c)){if(c.text&&!c.silent){const d=c.text.split(`
1
+ import{R as o,r as u}from"./vendor.react.js";import{E as M,a3 as D,a4 as ie,p as T,a5 as ce,a6 as x,r as ue,a7 as O,X as A,j as de,b as pe,a8 as fe}from"./userflow.js";import{k as me}from"./vendor.lodash.js";import"./vendor.object-assign.js";import{u as j}from"./vendor.react-i18next.js";import{B as X,F as be}from"./FlowChrome.js";import{m as Ee,d as K,R as ge,i as we,g as he,b as ve,c as z,h as Te,S as Se}from"./TreeDoc.js";import{g as Q,b as Z}from"./flow-condition-types.js";import{u as F,i as ye}from"./client-context.js";import{u as ke,r as Be}from"./use-selector-element-monitoring.js";import{D as Me,k as De,r as Fe}from"./roots.js";import{a as J,S as Le}from"./flow-host.styl.js";import{r as Ie}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as Re,a as Ne}from"./stylesheets.js";import{T as Ce}from"./Trigger.js";import{f as _,a as Ae}from"./steps.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./Frame.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./iframe-reset.styl.js";import"./use-window-resize.js";import"./logomark.js";import"./vendor.obj-str.js";import"./use-confetti.js";import"./vendor.canvas-confetti.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="b0c9b10e-0bdb-43d0-a33d-c5abb249dd5b",e._sentryDebugIdIdentifier="sentry-dbid-b0c9b10e-0bdb-43d0-a33d-c5abb249dd5b")}catch{}})();const Pe=()=>{const{t:e}=j(),s=F(),{dispatch:t,restart:n}=R(),{session:i,step:f}=B(),l="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return o.createElement("div",{role:"dialog","aria-modal":I(f)?"true":void 0,"aria-label":"Guide menu"},o.createElement("div",{className:"userflowjs-bubble-menu__title"},e("menu.title")),o.createElement("button",{className:l,onClick:()=>s.endFlow(i,{endReason:M.USER_CLOSED})},e("menu.close")),i.version.restartEnabled&&o.createElement("button",{className:l,onClick:n},e("menu.restart")),o.createElement("button",{className:l,onClick:()=>t({kind:"showFlow"})},e("menu.back")))},Y=({progress:e,type:s,position:t,totalSteps:n})=>{const{t:i}=j(),f=u.useMemo(()=>parseFloat(e||"0"),[e]),l=u.useMemo(()=>({width:`${f*100}%`}),[f]),c=u.useMemo(()=>s===ie.DEFAULT?D.TOP:t,[s,t]),d=c===D.BOTTOM?"userflowjs-bubble-progress--bottom":"",m=u.useMemo(()=>`userflowjs-bubble-progress--${me(s||"DEFAULT").toLowerCase()} ${d}`,[s,d]),a=n||0,r=u.useMemo(()=>Math.min(Math.floor(f*a),a),[f,a]);return o.createElement(o.Fragment,null,(s==="CHAINED_ROUNDED"||s==="CHAINED_SQUARED"||s==="DOTTED")&&o.createElement("div",{className:m},Array.from({length:3}).map((g,E)=>o.createElement("div",{key:E,className:`userflowjs-bubble-progress-step ${E<Math.floor(f*3)?"userflowjs-bubble-progress-step_completed":""}`}))),s==="NARROW"&&o.createElement("div",{className:m},o.createElement("div",{className:"linear-progress-bar"},o.createElement("div",{className:"userflowjs-bubble-progress--narrow-fill",style:l}))),s==="NUMBERED"&&o.createElement("div",{className:m},o.createElement("span",{className:"numbered-progress"},i("of",{replace:{range:a,selected:r}}))),!["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW","NUMBERED"].includes(s)&&o.createElement("div",{className:`${m} ${c===D.BOTTOM?"userflowjs-bubble-progress--bottom":""}`},o.createElement("div",{className:"userflowjs-bubble-progress__fill",style:l})))},xe=({theme:e})=>{const s=F(),{session:t,step:n,muted:i,shouldLabelDialog:f}=B(),{version:l}=t,{dispatch:c}=R(),d=l.steps[0],m=d&&d.id===n.id,a=m&&n.progress==="1",r=u.useMemo(()=>n.content&&Ee(K(n.content),{buttons:n.buttons,questions:n.questions}),[n.content,n.buttons,n.questions]),g=l.steps.filter(S=>S.appearance!==T.HIDDEN),E=g.findIndex(S=>S.id===n.id),w=g.length,h=w>0?((E+1)/w).toString():"0";return o.createElement("div",{key:n.id,role:"alertdialog","aria-modal":I(n)?"true":void 0,"aria-label":f?"Guide":void 0},!a&&e.progressBarPosition==="TOP"&&e.progressBarEnabled&&o.createElement(Y,{progress:h,type:e.progressBarType,position:n.appearance===T.MODAL?void 0:D.TOP,totalSteps:w}),o.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content","data-progress-position":e.progressBarPosition,"data-progress-type":e.progressBarType},o.createElement(ge,{doc:r,lookupAttribute:Q(t.data),buttons:n.buttons,questions:n.questions})),o.createElement(X,{draftMode:t.draftMode,muted:i,toggleMuted:e.voiceType!==x.NONE?()=>c({kind:"toggleMuted"}):void 0,close:l.closeDisabled?void 0:()=>e.flowXButtonBehavior===ce.DISMISS||m?s.endFlow(t,{endReason:M.USER_CLOSED}):c({kind:"showMenu"})}),!a&&e.progressBarPosition==="BOTTOM"&&e.progressBarEnabled&&o.createElement(Y,{progress:h,type:e.progressBarType,position:D.BOTTOM,totalSteps:w}))};function Oe(e,s){if(!e)return"";typeof e=="string"&&(e=K(e));const t=[],n=/[.!?;,]$/;function i(){const c=(t[t.length-1]||"").trim();c&&!c.match(n)&&t.push(".")}function f(c){if(we(c)){if(c.text&&!c.silent){const d=c.text.split(`
2
2
  `);d.forEach((m,a)=>{t.push(m),a<d.length-1&&(i(),t.push(`
3
3
  `))})}return}if(c.type==="attribute"){const d=he(c,s);d&&t.push(d)}else l(c.children),["link"].includes(c.type)||(i(),t.push(`
4
4
 
package/Frame.js CHANGED
@@ -1,2 +1,2 @@
1
- import{r as y,R as p}from"./vendor.react.js";import{r as L}from"./vendor.react-dom.js";import{o as R}from"./vendor.obj-str.js";import{g as x,u as S,c as F,d as W}from"./stylesheets.js";import{i as _}from"./iframe-reset.styl.js";import{i as D,a as h}from"./client-context.js";import"./vendor.object-assign.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new Error().stack;o&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[o]="2d101374-7ead-44e1-ae91-cd97006acd02",r._sentryDebugIdIdentifier="sentry-dbid-2d101374-7ead-44e1-ae91-cd97006acd02")}catch{}})();const q=({testId:r,className:o,style:l,elRef:a,stylesheet:i,theme:t,onStylesheetsLoad:c,noIframe:n,noScroll:f,ariaHidden:b,title:I,children:w})=>{n=n||!1;const[s,E]=y.useState(null),v=t&&"userflowjs-theme-root",g=t&&x(t),{loaded:u}=S(s,n?null:_),{loaded:e}=S(s,i,t),{loaded:d}=F(s,t),m=t&&W(t),{loaded:k}=S(s,m,t,{uninstallOnUnmount:!0});return y.useEffect(()=>{c&&u&&e&&d&&k&&c(!0)},[c,u,e,d,k]),n?p.createElement(j,{testId:r,className:o,style:l,rootClassName:v,rootStyle:g,elRef:a,onWinReady:E,noScroll:f,ariaHidden:b},w):p.createElement(U,{testId:r,className:o,style:l,rootClassName:v,rootStyle:g,elRef:a,onWinReady:E,noScroll:f,ariaHidden:b,title:I},w)},U=({testId:r,className:o,style:l,rootClassName:a,rootStyle:i,elRef:t,onWinReady:c,noScroll:n,ariaHidden:f,title:b,children:I})=>{const w=h(),[s,E]=y.useState(null);y.useLayoutEffect(()=>{if(!s)return;const{documentElement:u,body:e}=s.document;u.dir=D.dir();const d=a&&a.split(" ");if(d&&e.classList.add(...d),i)for(const m in i)e.style.setProperty(m,i[m]);return e.style.overflow=n?"hidden":"",()=>{d&&e.classList.remove(...d)}},[s,a,i,n]);const v=w?.logrocketAppId;y.useRef(!1),y.useEffect(()=>{},[s,v]);const g={bis_size:"{}"};return p.createElement("iframe",{ref:u=>{if(!u)return;t&&(t.current=u);const e=u.contentWindow;if(!e||e===s)return;const d=m=>{E(m),c(m)};e.document.readyState==="complete"?d(e):e.addEventListener("load",()=>{d(e)})},"data-testid":r,"aria-hidden":f?"true":void 0,title:b,tabIndex:f?-1:void 0,className:o,style:{...l,border:"none"},...g},s&&L.createPortal(I,s.document.body))},j=({testId:r,className:o,style:l,rootClassName:a,rootStyle:i,elRef:t,onWinReady:c,ariaHidden:n,children:f})=>(y.useEffect(()=>{c(window)},[c]),p.createElement("div",{ref:t,"data-testid":r,"aria-hidden":n?"true":void 0,tabIndex:n?-1:void 0,dir:D.dir(),className:R({"userflowjs-div-frame":!0,[o||""]:!!o}),style:l},p.createElement("div",{className:a,style:i},f)));export{q as F};
1
+ import{r as y,R as p}from"./vendor.react.js";import{r as R}from"./vendor.react-dom.js";import{g as S,u as k,c as x,d as F}from"./stylesheets.js";import{i as W}from"./iframe-reset.styl.js";import{i as L,a as _}from"./client-context.js";import"./vendor.object-assign.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d=new Error().stack;d&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[d]="0207aec0-77bd-4ec7-8aff-f32b403569e6",n._sentryDebugIdIdentifier="sentry-dbid-0207aec0-77bd-4ec7-8aff-f32b403569e6")}catch{}})();const B=({testId:n,className:d,style:u,elRef:a,stylesheet:i,theme:t,onStylesheetsLoad:c,noIframe:o,noScroll:l,ariaHidden:b,title:I,children:E})=>{o=o||!1;const[s,w]=y.useState(null),g=t&&"userflowjs-theme-root",v=t&&S(t),{loaded:f}=k(s,o?null:W),{loaded:e}=k(s,i,t),{loaded:r}=x(s,t),m=t&&F(t),{loaded:D}=k(s,m,t,{uninstallOnUnmount:!0});return y.useEffect(()=>{c&&f&&e&&r&&D&&c(!0)},[c,f,e,r,D]),o?p.createElement(U,{testId:n,className:d,style:u,rootClassName:g,rootStyle:v,elRef:a,onWinReady:w,noScroll:l,ariaHidden:b},E):p.createElement(h,{testId:n,className:d,style:u,rootClassName:g,rootStyle:v,elRef:a,onWinReady:w,noScroll:l,ariaHidden:b,title:I},E)},h=({testId:n,className:d,style:u,rootClassName:a,rootStyle:i,elRef:t,onWinReady:c,noScroll:o,ariaHidden:l,title:b,children:I})=>{const E=_(),[s,w]=y.useState(null);y.useLayoutEffect(()=>{if(!s)return;const{documentElement:f,body:e}=s.document;f.dir=L.dir();const r=a&&a.split(" ");if(r&&e.classList.add(...r),i)for(const m in i)e.style.setProperty(m,i[m]);return e.style.overflow=o?"hidden":"",()=>{r&&e.classList.remove(...r)}},[s,a,i,o]);const g=E?.logrocketAppId;y.useRef(!1),y.useEffect(()=>{},[s,g]);const v={bis_size:"{}"};return p.createElement("iframe",{ref:f=>{if(!f)return;t&&(t.current=f);const e=f.contentWindow;if(!e||e===s)return;const r=m=>{w(m),c(m)};e.document.readyState==="complete"?r(e):e.addEventListener("load",()=>{r(e)})},"data-testid":n,"aria-hidden":l?"true":void 0,title:b,tabIndex:l?-1:void 0,className:d,style:{...u,border:"none"},...v},s&&R.createPortal(I,s.document.body))},U=({testId:n,className:d,style:u,rootClassName:a,rootStyle:i,elRef:t,onWinReady:c,ariaHidden:o,children:l})=>(y.useEffect(()=>{c(window)},[c]),p.createElement("div",{ref:t,"data-testid":n,"aria-hidden":o?"true":void 0,tabIndex:o?-1:void 0,dir:L.dir(),className:d,style:u},p.createElement("div",{className:a,style:i},l)));export{B as F};
2
2
  //# sourceMappingURL=Frame.js.map
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ResourceCenterAssistantChat.js","vendor.react.js","vendor.object-assign.js","userflow.js","vendor.phoenix.js","vendor.uuid.js","client-context.js","vendor.i18next.js","vendor.babel.runtime.js","vendor.react-i18next.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.dompurify.js","vendor.marked.js","vendor.obj-str.js","TreeDoc.js","flow-condition-types.js","vendor.date-fns.js","roots.js","stylesheets.js","vendor.fortawesome.pro-solid-svg-icons.js","vendor.react-dom.js","vendor.scheduler.js","AnnouncementEngagement.js","use-confetti.js","vendor.canvas-confetti.js","flow-host.styl.js","use-selector-element-monitoring.js","Frame.js","iframe-reset.styl.js","use-window-resize.js","logomark.js","ChecklistUI.js","FlowChrome.js","vendor.memoize-one.js","vendor.bignumber.js.js","use-element-rect.js","resource-center-route.js"])))=>i.map(i=>d[i]);
2
- import{K as S,L as H,c as Ae,A as M,p as jr,R as je,M as ae,N as yr,O as Ct,P as kt,E as Ar,Q as Ir,e as Tr,T as St,z as Nt,h as jt,V as Rr,_ as _r}from"./userflow.js";import{r as a,R as e}from"./vendor.react.js";import{u as B,i as Ie}from"./client-context.js";import{f as yt,u as Lr,w as At,N as xr,C as Br}from"./flow-host.styl.js";import{R as W,S as le,s as Te,a as ie,h as Mr,n as Dr,u as Vt}from"./TreeDoc.js";import{g as L}from"./flow-condition-types.js";import{D as y,a as re,g as He,u as It}from"./stylesheets.js";import{b as et}from"./use-selector-element-monitoring.js";import{F as tt}from"./Frame.js";import{o as P}from"./vendor.obj-str.js";import{M as We,j as Tt,k as Rt}from"./roots.js";import{u as Pr}from"./use-window-resize.js";import{S as Fr}from"./logomark.js";import"./vendor.object-assign.js";import{f as Ur,C as Or}from"./ChecklistUI.js";import{$ as Hr,a0 as Kt,U as rt,b as Wr,a1 as $r,a2 as zr,a3 as te,s as Vr,u as Kr,l as Qr,v as qr}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{F as Zr,B as Gr}from"./FlowChrome.js";import{a as ue,S as U,b as Qt,A as Xr,u as nt}from"./AnnouncementEngagement.js";import{m as _t}from"./vendor.memoize-one.js";import{B as qt}from"./vendor.bignumber.js.js";import{u as Yr}from"./use-element-rect.js";import{d as Lt,s as Jr}from"./resource-center-route.js";import{u as ne}from"./vendor.react-i18next.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="806e9477-e12d-471e-85ca-78dcf701278c",t._sentryDebugIdIdentifier="sentry-dbid-806e9477-e12d-471e-85ca-78dcf701278c")}catch{}})();function en(t,r,n){return!t.resourceCenterAutoDividers||r===S.DIVIDER||n===S.DIVIDER?!1:xt(r)||xt(n)}function xt(t){return t!==S.ACTION&&t!==S.ANNOUNCEMENTS&&t!==S.ASSISTANT&&t!==S.CONTACT&&t!==S.FLOWS&&t!==S.KNOWLEDGE_BASE&&t!==S.SUBPAGE}const f=window,ye={[H.CRISP]:{configure:({onShow:t,onHide:r})=>{tn();let n=!1,s=!1;const o=()=>{n||s?(f.$crisp.push(["do","chat:show"]),t()):(f.$crisp.push(["do","chat:hide"]),r())},c=()=>{n=!0,o()};f.$crisp.push(["on","chat:opened",c]);const l=()=>{n=!1,o()};f.$crisp.push(["on","chat:closed",l]);const i=()=>{s=!0,o()};f.$crisp.push(["on","message:received",i]);const w=()=>{const h=document.getElementById("crisp-chatbox");if(!h||window.getComputedStyle(h).display!=="block")return!1;const p=h.querySelector('[data-id="new_messages"]');return!(!p||window.getComputedStyle(p).display!=="block")},m=()=>{const h=w();h!==s&&(s=h,o())},u=window.setInterval(m,200);return()=>{f.$crisp.push(["off","chat:opened",c]),f.$crisp.push(["off","chat:closed",l]),f.$crisp.push(["off","message:received",i]),window.clearInterval(u)}},show:()=>{f.$crisp.push(["do","chat:show"]),f.$crisp.push(["do","chat:open"])},hide:()=>{f.$crisp.push(["do","chat:hide"]),f.$crisp.push(["do","chat:close"])}},[H.CUSTOM]:{configure:()=>()=>{},show:({block:t})=>{try{new Function(`"use strict";
2
+ import{K as S,L as H,c as Ae,A as M,p as jr,R as je,M as ae,N as yr,O as Ct,P as kt,E as Ar,Q as Ir,e as Tr,T as St,z as Nt,h as jt,V as Rr,_ as _r}from"./userflow.js";import{r as a,R as e}from"./vendor.react.js";import{u as B,i as Ie}from"./client-context.js";import{f as yt,u as Lr,w as At,N as xr,C as Br}from"./flow-host.styl.js";import{R as W,S as le,s as Te,a as ie,h as Mr,n as Dr,u as Vt}from"./TreeDoc.js";import{g as L}from"./flow-condition-types.js";import{D as y,a as re,g as He,u as It}from"./stylesheets.js";import{b as et}from"./use-selector-element-monitoring.js";import{F as tt}from"./Frame.js";import{o as P}from"./vendor.obj-str.js";import{M as We,j as Tt,k as Rt}from"./roots.js";import{u as Pr}from"./use-window-resize.js";import{S as Fr}from"./logomark.js";import"./vendor.object-assign.js";import{f as Ur,C as Or}from"./ChecklistUI.js";import{$ as Hr,a0 as Kt,U as rt,b as Wr,a1 as $r,a2 as zr,a3 as te,s as Vr,u as Kr,l as Qr,v as qr}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{F as Zr,B as Gr}from"./FlowChrome.js";import{a as ue,S as U,b as Qt,A as Xr,u as nt}from"./AnnouncementEngagement.js";import{m as _t}from"./vendor.memoize-one.js";import{B as qt}from"./vendor.bignumber.js.js";import{u as Yr}from"./use-element-rect.js";import{d as Lt,s as Jr}from"./resource-center-route.js";import{u as ne}from"./vendor.react-i18next.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="6548883c-092b-4046-abac-869a7889322b",t._sentryDebugIdIdentifier="sentry-dbid-6548883c-092b-4046-abac-869a7889322b")}catch{}})();function en(t,r,n){return!t.resourceCenterAutoDividers||r===S.DIVIDER||n===S.DIVIDER?!1:xt(r)||xt(n)}function xt(t){return t!==S.ACTION&&t!==S.ANNOUNCEMENTS&&t!==S.ASSISTANT&&t!==S.CONTACT&&t!==S.FLOWS&&t!==S.KNOWLEDGE_BASE&&t!==S.SUBPAGE}const f=window,ye={[H.CRISP]:{configure:({onShow:t,onHide:r})=>{tn();let n=!1,s=!1;const o=()=>{n||s?(f.$crisp.push(["do","chat:show"]),t()):(f.$crisp.push(["do","chat:hide"]),r())},c=()=>{n=!0,o()};f.$crisp.push(["on","chat:opened",c]);const l=()=>{n=!1,o()};f.$crisp.push(["on","chat:closed",l]);const i=()=>{s=!0,o()};f.$crisp.push(["on","message:received",i]);const w=()=>{const h=document.getElementById("crisp-chatbox");if(!h||window.getComputedStyle(h).display!=="block")return!1;const p=h.querySelector('[data-id="new_messages"]');return!(!p||window.getComputedStyle(p).display!=="block")},m=()=>{const h=w();h!==s&&(s=h,o())},u=window.setInterval(m,200);return()=>{f.$crisp.push(["off","chat:opened",c]),f.$crisp.push(["off","chat:closed",l]),f.$crisp.push(["off","message:received",i]),window.clearInterval(u)}},show:()=>{f.$crisp.push(["do","chat:show"]),f.$crisp.push(["do","chat:open"])},hide:()=>{f.$crisp.push(["do","chat:hide"]),f.$crisp.push(["do","chat:close"])}},[H.CUSTOM]:{configure:()=>()=>{},show:({block:t})=>{try{new Function(`"use strict";
3
3
  `+t.chatCode)()}catch(r){console.error(`Userflow.js: Showing custom chat provider failed. Code: ${t.chatCode}`,r)}},hide:()=>{}},[H.FRESHCHAT]:{configure:({onShow:t,onHide:r})=>{if(!f.fcWidget)throw new Error("Freshchat is not installed");let n=!1,s=!1;const o=()=>{n||s?t():r()},c=()=>{n=!0,o()};f.fcWidget.on("widget:opened",c);const l=()=>{n=!1,o()};f.fcWidget.on("widget:closed",l);const i=()=>{const m=!!document.querySelector("#fc_frame.h-open-notify");m!==s&&(s=m,o())},w=window.setInterval(i,200);return f.fcWidget.on("unreadCount:notify",i),()=>{f.fcWidget.off("widget:opened",c),f.fcWidget.off("widget:closed",l),f.fcWidget.off("unreadCount:notify",i),window.clearInterval(w)}},show:()=>{f.fcWidget.open()},hide:()=>{f.fcWidget.close()}},[H.HELPSCOUT]:{configure:({onShow:t,onHide:r})=>{if(!f.Beacon)throw new Error("Help Scout is not installed");rn();let n=!1,s=!1;const o=()=>{n||s?(Dt(),t()):($e(),r())},c=()=>{n=!0,o()};f.Beacon("on","open",c),f.Beacon("info")?.status.isOpened&&c();const l=()=>{n=!1,o()};f.Beacon("on","close",l);const i=()=>{const m=!!document.querySelector(".BeaconNotificationsFrame");m!==s&&(s=m,o())},w=window.setInterval(i,200);return()=>{f.Beacon("off","open",c),f.Beacon("off","close",l),window.clearInterval(w)}},show:()=>{Dt(),f.Beacon("open")},hide:()=>{$e(),f.Beacon("close")}},[H.HUBSPOT]:{configure:({onShow:t,onHide:r})=>{const n=()=>{const c=document.getElementById("hubspot-messages-iframe-container");if(!f.HubSpotConversations||!c)return;window.clearInterval(o),nn();let l=!1,i=!1;const w=()=>{l||i?(ze(),t()):(Ve(),r())},m=()=>{const p=!!document.querySelector("#hubspot-messages-iframe-container .hs-shadow-container.active");p!==l&&(l=p,w())},u=new We(m);u.observe(c,{attributes:!0,subtree:!0,attributeFilter:["class"]}),m();const h=({unreadCount:p})=>{const E=p>0;E!==i&&(i=E,w())};f.HubSpotConversations.on("unreadConversationCountChanged",h),s=()=>{u.disconnect(),f.HubSpotConversations.off("unreadConversationCountChanged",h)}};let s=()=>{window.clearInterval(o)};const o=window.setInterval(n,100);return n(),()=>{s()}},show:()=>{ze(),f.HubSpotConversations.widget.open()},hide:()=>{Ve(),f.HubSpotConversations.widget.close()}},[H.INTERCOM]:{configure:({onShow:t,onHide:r})=>{if(!f.Intercom)throw new Error("Intercom is not installed");return sn(),Ke.add(t),Qe.add(r),()=>{Ke.delete(t),Qe.delete(r)}},show:()=>{Zt(),f.Intercom("show")},hide:()=>{qe(),f.Intercom("hide")}},[H.ZENDESK]:{configure:({onShow:t,onHide:r})=>{if(!f.zE)throw new Error("Zendesk is not installed");on();let n=!1,s=!1;const o=()=>{n||s?(f.zE("webWidget","show"),t()):(f.zE("webWidget","hide"),r())},c=()=>{n=!0,s=!1,o()};Ze.add(c);const l=()=>{n=!1,s=!1,o()};Ge.add(l);const i=w=>{const m=w>0;m!==s&&(s=m,o())};return Xe.add(i),()=>{Ze.delete(c),Ge.delete(l),Xe.delete(i)}},show:()=>{f.zE("webWidget","show"),f.zE("webWidget","open")},hide:()=>{f.zE("webWidget","hide"),f.zE("webWidget","close")}},[H.ZENDESK_MESSENGER]:{configure:({onShow:t,onHide:r})=>{if(!f.zE)throw new Error("Zendesk is not installed");const n=()=>{t()},s=()=>{r()};return Ye.add(n),Je.add(s),cn(),()=>{Ye.delete(n),Je.delete(s)}},show:()=>{f.zE("messenger","open")},hide:()=>{f.zE("messenger","close")}}};let Bt=!1;function tn(){Bt||(Bt=!0,f.$crisp||(f.$crisp=[]),f.$crisp.push(["do","chat:hide"]))}let Mt=!1;function rn(){Mt||(Mt=!0,$e())}function Dt(){f.Beacon("config",{display:{style:"icon"}})}function $e(){f.Beacon("config",{display:{style:"manual"}})}let Pt=!1,st=!1;function nn(){Pt||(Pt=!0,st?ze():Ve())}function ze(){st=!0,document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","visible","important")}function Ve(){st=!1,document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","hidden","important")}let Ft=!1,Ke=new Set,Qe=new Set;function sn(){if(Ft)return;Ft=!0,qe();let t=!1,r=!1;const n=()=>{Zt();for(const l of Ke)l()},s=()=>{qe();for(const l of Qe)l()},o=()=>{t||r?n():s()};f.Intercom("onShow",()=>{t=!0,o()}),f.Intercom("onHide",()=>{t=!1,o()});const c=()=>{const l=!!document.querySelector('iframe[name="intercom-borderless-frame"], iframe[name="intercom-notifications-frame"]');r!==l&&(r=l,o())};f.Intercom("onUnreadCountChange",()=>{c()}),window.setInterval(c,200)}function Zt(){f.Intercom("update",{hide_default_launcher:!1,vertical_padding:20})}function qe(){f.Intercom("update",{hide_default_launcher:!0,vertical_padding:100})}let Ut=!1,Ze=new Set,Ge=new Set,Xe=new Set;function on(){Ut||(Ut=!0,f.zE("webWidget","hide"),f.zE("webWidget","close"),f.zE("webWidget:on","open",()=>{for(const t of Ze)t()}),f.zE("webWidget:on","close",()=>{for(const t of Ge)t()}),f.zE("webWidget:on","chat:unreadMessages",t=>{for(const r of Xe)r(t)}))}let Ot=!1,Ye=new Set,Je=new Set;function cn(){Ot||(Ot=!0,f.zE("messenger:on","open",function(){for(const t of Ye)t()}),f.zE("messenger:on","close",function(){for(const t of Je)t()}))}const an=t=>a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},t),a.createElement("path",{fill:"currentColor",d:"M24.049 79.74h36.003c8.185 0 15.985-6.621 17.43-14.814l6.091-34.556h3.997c8.149 0 13.645 6.63 12.2 14.815l-7.051 40C91.274 93.363 83.474 100 75.288 100h-40c-8.185 0-13.645-6.667-12.2-14.815l.96-5.444Z"}),a.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12.437 69.63h40c8.148 0 15.978-6.637 17.422-14.815l7.052-40C78.355 6.63 72.896 0 64.711 0h-40C16.533 0 8.726 6.63 7.281 14.815l-7.052 40C-1.215 62.963 4.252 69.63 12.437 69.63Zm33.628-33.798c3.756-2.064 8.725-4.795 9.907-11.844C57.385 15.458 50.065 8.983 42.168 9c-7.452 0-12.771 3.195-17.508 8.892-.858 1.034-.884 2.45-.053 3.212l3.472 3.196c.847.767 2.25.589 3.176-.406 2.842-3.068 4.869-4.83 8.51-4.83 2.864 0 6.077 1.934 5.59 4.847-.37 2.223-2.292 3.334-5.4 5.001l-.28.151c-3.582 1.92-8.134 4.362-9.124 10.247l-.16.956c-.055.28-.05.571.014.85.065.278.188.538.362.76.173.222.391.4.639.522.247.121.518.183.79.18h6.744a2.709 2.709 0 0 0 1.712-.688c.481-.426.81-1.01.934-1.657l.095-.556c.266-1.582 2.101-2.59 4.384-3.845ZM32.837 59c3.552 0 6.955-3.034 7.58-6.769.63-3.729-1.742-6.763-5.293-6.763-3.552 0-6.934 3.028-7.58 6.763C26.9 55.966 29.286 59 32.837 59Z"})),ln=200;function ot(t,r){const[n,s]=a.useState(t),o=a.useRef(void 0),c=a.useCallback(i=>{window.clearTimeout(o.current),s(i),r(i)},[r]),l=a.useCallback(i=>{window.clearTimeout(o.current),s(i),o.current=window.setTimeout(()=>{r(i)},ln)},[r]);return a.useEffect(()=>()=>{window.clearTimeout(o.current)},[]),[n,l,c]}const un={xs:[16,3],sm:[24,4],md32:[32,4],md:[40,4],lg:[56,4]};class dn extends e.PureComponent{constructor(){super(...arguments),this.memoizedBgStyle=_t(r=>({strokeWidth:`${r}px`})),this.memoizedFillStyle=_t((r,n,s)=>({strokeWidth:`${r}px`,strokeDasharray:n*2*Math.PI*new qt(s).toNumber()+"px, 1000"}))}render(){const{props:r}=this,{size:n,indeterminate:s,className:o,center:c,right:l,color:i}=this.props,w=["progress-spinner"];n&&w.push(`progress-spinner--${n}`),s&&w.push("progress-spinner--indeterminate"),o&&w.push(o);const m=s?.25:r.progress||0,[u,h]=un[n||"md"],p=u/2,E=(u-h)/2;let N=e.createElement("div",{className:w.join(" ")},e.createElement("svg",{viewBox:`0 0 ${u} ${u}`,version:"1.1",xmlns:"http://www.w3.org/2000/svg"},e.createElement("circle",{className:"progress-spinner__bg",fill:"none",cx:p,cy:p,r:E,style:this.memoizedBgStyle(h)}),e.createElement("circle",{className:i==="purple"?"progress-spinner__fill-purple":"progress-spinner__fill",fill:"none",cx:p,cy:p,r:E,transform:`translate(${p}, ${p}) rotate(-90) translate(-${p}, -${p})`,style:this.memoizedFillStyle(h,E,m)})));return c?N=e.createElement("div",{className:"progress-spinner-center-aligner"},N):l&&(N=e.createElement("div",{className:"progress-spinner-right-aligner"},N)),N}}const mn=({textareaRef:t,value:r,onChange:n,onBlur:s,onKeyDown:o,onMouseDown:c,placeholder:l,maxLength:i,disabled:w,readOnly:m,className:u,mirrorClassName:h,textareaClassName:p,icon:E,onIconClick:N,loading:g=!1,children:C})=>{let j=r||l||"";(j===""||j.endsWith(`
4
- `))&&(j+=" "),u=u||"growing-textarea",h=h||u+"__mirror";const[_,k]=a.useState(!1);return e.createElement("div",{className:P({[u]:!0,[`${u}__loading`]:g})},e.createElement("div",{className:h+" "+(p||"")},j),e.createElement("textarea",{ref:t,value:r,onChange:T=>n&&n(T.target.value),onBlur:s,onKeyDown:T=>{if(T.key==="Enter"&&_){T.preventDefault();return}o&&o(T)},onMouseDown:c,placeholder:l,maxLength:i,disabled:w||g,readOnly:m,className:P({"growing-textarea__input":!0,[p||""]:!0,[`${u}__with-icon`]:!!E,[`${u}__loading-input`]:g}),onCompositionStart:()=>k(!0),onCompositionEnd:()=>k(!1)}),E&&!g&&e.createElement("div",{className:`${u}__icon`},e.createElement("button",{className:"btn btn--plain-blue btn--square btn--md32",onClick:N},e.createElement(y,{icon:E}))),g&&e.createElement("div",{className:`${u}__loader`},e.createElement(dn,{indeterminate:!0,size:"xs",color:"purple"})),C)},fn=({textareaRef:t,value:r,onChange:n,onSubmit:s,placeholder:o,readOnly:c})=>{const l=()=>{s&&s()};return e.createElement("div",{className:"userflowjs-assistant-chat-input"},e.createElement(mn,{textareaRef:t,className:"userflowjs-growing-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea userflowjs-assistant-chat-input__textarea",placeholder:o,readOnly:c,value:r||"",onChange:n,onKeyDown:i=>{!i.shiftKey&&i.key==="Enter"&&(i.preventDefault(),l())}}),e.createElement("button",{"data-testid":"assistant-chat-input-submit",className:"userflowjs-assistant-chat-input__submit",onClick:()=>l()},e.createElement(y,{icon:Hr})))};function hn(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function Gt(t){return Ae.linkUrlDecorator?Ae.linkUrlDecorator(t):t}const Ht=5,wn=async()=>(await _r(async()=>{const{ResourceCenterAssistantChat:t}=await import("./ResourceCenterAssistantChat.js");return{ResourceCenterAssistantChat:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]))).ResourceCenterAssistantChat,Wt=({session:t,isOpen:r,flowSession:n,checklistSession:s,resourceCenterLauncherHidden:o})=>{const c=B(),{t:l}=ne(),{company:i}=t.flow,{version:w}=t,m=w.resourceCenter,u=re(w.theme),h=m.launcherType??je.DEFAULT,p=a.useMemo(()=>h===je.CUSTOM?!1:o===!1?!0:o===!0?!1:h===je.DEFAULT,[h,o]),E=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;a.useEffect(()=>{Ie.changeLanguage(E)},[E]);const{loaded:N}=It(window,yt,u),[g,C]=a.useState(!1),j=N&&g,[_,k]=a.useState(Tt()),[T,F]=a.useState(Rt()),_e=a.useCallback(()=>{k(Tt()),F(Rt())},[]);Pr(_e);const{zIndex:se,bringToFront:oe}=Lr(),[$,Le]=a.useState(null),[V,K]=a.useState(null),[G,me]=a.useState(null),fe=a.useRef(null),[z,lr]=a.useState(null),[at,ir]=a.useState(null),[lt,ur]=a.useState(null),[dr,mr]=a.useState(0),[fr,hr]=a.useState(0),he=a.useCallback(()=>{V&&mr(Math.round(V?.offsetWidth||0)),hr(Math.round((G?.offsetHeight||0)+(z?.offsetHeight||0)+(at?.offsetHeight||0)+(lt?.offsetHeight||0)))},[V,G,z,at,lt]);a.useLayoutEffect(()=>{if(!$||typeof We!="function")return;const d=new We(()=>{he()});return d.observe($,{childList:!0,attributes:!0,subtree:!0}),()=>{d.disconnect()}},[$,he]),a.useLayoutEffect(()=>{he()},[he]);const[it,ut]=a.useState(!1),xe=a.useRef(),we=a.useCallback(()=>{ut(!0),window.clearTimeout(xe.current),xe.current=window.setTimeout(()=>{ut(!1)},u.resourceCenterTransitionDuration)},[u.resourceCenterTransitionDuration]);a.useEffect(()=>()=>{window.clearTimeout(xe.current)},[]);const Ee=a.useCallback(()=>{oe(),we(),c.openResourceCenter()},[oe,c,we]),Be=a.useCallback(()=>{we(),c.closeResourceCenter()},[c,we]),[dt,X]=a.useState(!1);a.useEffect(()=>{if(dt){if(!hn())if(r){const d='button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea';let v=z?.querySelector(".userflowjs-assistant-chat-input textarea")||z?.querySelector(d)||G?.querySelector(d);if(v){const I=v.closest&&v.closest(".userflowjs-resource-center-checklist")||null;I?Ur(I):v.focus({preventScroll:!0})}}else V?.focus({preventScroll:!0});X(!1)}},[dt,r,z,G,V]),a.useEffect(()=>{const d=$?.ownerDocument.defaultView;if(!r||!d)return;const v=I=>{I.key==="Escape"&&(Be(),X(!0))};return d.addEventListener("keydown",v),()=>d.removeEventListener("keydown",v)},[r,$,X,Be]);const[b,pe]=a.useState(()=>Lt(t,ae.getItem(`resourceCenterRoute:v1:${t.id}`))),D=a.useCallback((d,v)=>{pe(d);const I=Jr(d);I?ae.setItem(`resourceCenterRoute:v1:${t.id}`,I):ae.removeItem(`resourceCenterRoute:v1:${t.id}`),v?.detail===0&&X(!0)},[t.id]);a.useEffect(()=>{const d=v=>{D(v)};return c.on("private:resourceCenterNavigate",d),()=>c.off("private:resourceCenterNavigate",d)},[c,t,D]),a.useEffect(()=>{const d=ae.getItem(`resourceCenterRoute:v1:${t.id}`);pe(Lt(t,d))},[t]),a.useEffect(()=>{if(!t.draftMode||!b||!("block"in b)||!b.block)return;const d=m.blocks.find(v=>v.cvid===b.block.cvid);d?JSON.stringify(d)!==JSON.stringify(b.block)&&pe({...b,block:d}):pe(null),b.block},[t.draftMode,m,b]);const Q=a.useMemo(()=>m.blocks.filter(d=>!(d.type===S.CHECKLIST&&!s||d.type===S.DIVIDER&&u.resourceCenterAutoDividers||d.hiddenWhenFlowsActive&&d.hiddenWhenFlowsActive.some(v=>v===n?.flow.id||v===s?.flow.id))),[m,n,s,u.resourceCenterAutoDividers]),Y=Q.length===1,Me=a.useMemo(()=>tr(Q),[Q]);a.useEffect(()=>{if(!r||!Y)return;const d=Q[0];let v=null;switch(d.type){case S.ANNOUNCEMENTS:v={kind:"announcementList",block:d};break;case S.FLOWS:v={kind:"flows",block:d};break;case S.KNOWLEDGE_BASE:v={kind:"knowledgeBase",block:d};break;case S.SUBPAGE:v={kind:"subpage",block:d};break;case S.ASSISTANT:v={kind:"assistant",block:d,initialUserContent:""};break}v&&D(v)},[r,Q,D,Y]);const De=a.useMemo(()=>!s||!m.blocks.some(d=>d.type===S.CHECKLIST)?0:yr(s),[m,s]),x=a.useMemo(()=>m.blocks.find(d=>d.type===S.CONTACT&&d.chatEnabled&&d.chatProvider),[m]),[wr,be]=a.useState(!1),ce=a.useRef(null),ve=a.useCallback(()=>{c.closeResourceCenter(),x&&x.chatProvider!==H.CUSTOM&&be(!0)},[c,x]),ge=a.useCallback(()=>{be(!1)},[]),Er=a.useCallback(d=>{if(ce.current?.(),ce.current=null,Ae.autoHide3pDisabled=!0,be(!0),x&&d.chatProvider===x.chatProvider)return;const v=ye[d.chatProvider];try{ce.current=v.configure({block:d,onShow:()=>{},onHide:()=>{be(!1)}})}catch(I){console.error(`Userflow.js: Error when configuring ${d.chatProvider}:`,I)}},[x]),mt=a.useCallback(()=>{if(x)try{ye[x.chatProvider].hide({block:x}),ge()}catch(d){console.error(`Userflow.js: Error when hiding ${x.chatProvider}:`,d)}},[x,ge]);a.useEffect(()=>{if(!x)return;Ae.autoHide3pDisabled=!0;const d=ye[x.chatProvider];try{const v=d.configure({block:x,onShow:ve,onHide:ge});return()=>{v()}}catch(v){console.error(`Userflow.js: Error when configuring ${x.chatProvider}:`,v);return}},[x,ve,ge]),a.useEffect(()=>{r&&(mt(),ce.current?.(),ce.current=null)},[mt,r]);const A=ar(t),Ce=a.useMemo(()=>{if(!A)return null;if(A.boosterAnnouncement){const d=A.boosterAnnouncement;if(!d.seen&&(d.level===M.TOAST||d.level===M.MODAL))return d}return A.popoutAnnouncement&&!A.popoutAnnouncement.seen?A.popoutAnnouncement:null},[A]),ft=re(Ce?.theme||w.theme);It(window,yt,p?void 0:ft);const ke=a.useCallback((d,v,I,J,Ne)=>{const gt=()=>{ct(c,d)};return e.createElement(le.Provider,{value:{...I,data:d.data}},d.level===M.MODAL&&e.createElement(er,{session:I,open:Ee,navigate:D,block:v,announcement:d,onDismiss:gt}),(d.level===M.TOAST||d.level===M.POPOUT)&&e.createElement(Jt,{session:I,open:Ee,navigate:D,block:v,announcement:d,onDismiss:gt,isStandalonePopout:Ne?.isStandalonePopout,rcPlacement:J.resourceCenterPlacement}))},[c,Ee,D]),pr=(d,v,I)=>{const J={...He(I),zIndex:At(xr),position:"fixed",top:0,left:0,width:"100vw",height:"100vh",pointerEvents:d.level===M.MODAL?"auto":"none"},Ne={...t,data:{...t.data,...d.data||{}}};return e.createElement(le.Provider,{value:Ne},e.createElement("div",{className:"userflowjs-theme-root",style:J,id:"userflowjs-announcement-app"},ke(d,v,Ne,I,{isStandalonePopout:d.level===M.POPOUT})))},br=!!b&&(b.kind==="search"||b.kind==="flows"||b.kind==="knowledgeBase"),ht=b?.kind==="assistant"||b?.kind==="announcementList"||b?.kind==="announcementShow",Pe=Math.min(ht?u.resourceCenterFullWidth:u.resourceCenterWidth,_-2*u.resourceCenterPaddingX),vr=540,gr=720,Cr={zIndex:u.resourceCenterZIndex!=null?u.resourceCenterZIndex:r?se:At(Br),position:j?void 0:"absolute",visibility:j&&!wr?void 0:"hidden"},kr={width:(r?Pe:dr)+"px",height:r?Math.min(br?vr:ht?gr:fr,T-2*u.resourceCenterPaddingY,u.resourceCenterMaxHeight==null?Number.MAX_VALUE:u.resourceCenterMaxHeight)+"px":void 0,display:!p&&!r?"none":void 0},[Sr,wt]=a.useState(!1),Et=()=>{Ee(),X(!0)},pt=b!=null&&(!Y||b.kind==="announcementShow"),q=b&&"block"in b?b.block:null;let bt=m.headerText;b!=null&&!pt&&q&&(bt=Te(q.name,{lookupAttribute:L(t.data)}));const Fe=!Y&&q?e.createElement("div",{className:"userflowjs-resource-center-list-route-title"},e.createElement(ie,{doc:q.name,lookupAttribute:L(t.data)})):null,vt=u.resourceCenterDisplayChecklistProgress&&s&&De>0?e.createElement("div",{"data-testid":"resource-center-launcher-badge",className:"userflowjs-resource-center-launcher-badge"},De,e.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")):null;let Se="",Ue="";u.resourceCenterLauncherTextMode===Ct.CHECKLIST_OVERRIDE&&s&&De>0?Se=s.version.checklist?.launcherText||"Get Started":u.resourceCenterLauncherTextMode!==Ct.NONE&&(Ue=m.buttonText);const Oe=Ce?.level,Nr=Oe===M.MODAL||Oe===M.TOAST||Oe===M.POPOUT&&(h!==je.CUSTOM||o===!0);return!p&&!r&&Ce&&A&&Nr?pr(Ce,A,ft):e.createElement(le.Provider,{value:t},e.createElement("div",{"data-testid":"resource-center-app",className:"userflowjs-resource-center-app userflowjs-theme-root",style:He(u),dir:Ie.dir()},e.createElement("div",{className:P({"userflowjs-resource-center":!0,"userflowjs-resource-center--fixed":!0,[`userflowjs-resource-center--placement-${u.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0}),style:Cr},e.createElement("div",{className:"userflowjs-resource-center-frame-wrapper",onMouseEnter:()=>wt(!0),onMouseLeave:()=>wt(!1)},e.createElement(tt,{className:P({"userflowjs-resource-center-frame":!0,"userflowjs-resource-center-frame--animating":it,"userflowjs-resource-center-frame--open":r,"userflowjs-resource-center-frame--closed":!r}),style:kr,stylesheet:et,theme:u,onStylesheetsLoad:C,title:"Resource center"},j&&e.createElement(e.Fragment,null,e.createElement("div",{ref:Le,className:P({"userflowjs-resource-center-frame-root":!0,[`userflowjs-resource-center-frame-root--placement-${u.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0,"userflowjs-resource-center-frame-root--animating":it,"userflowjs-resource-center-frame-root--open":r,"userflowjs-resource-center-frame-root--closed":!r}),role:r?"dialog":void 0,"aria-label":r?m.headerText:void 0},p&&e.createElement("div",{className:"userflowjs-resource-center-launcher-container"},e.createElement("button",{ref:K,className:P({"userflowjs-resource-center-launcher-button":!0,"userflowjs-resource-center-launcher-button--hover":Sr}),onClick:Et,"aria-label":`Open ${m.headerText}`},vt,Se&&e.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},Se),(vt||Se)&&e.createElement("div",{className:"userflowjs-resource-center-launcher-divider"}),Ue&&e.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},Ue),e.createElement("div",{className:"userflowjs-resource-center-launcher-icon"},u.resourceCenterLauncherIconType===kt.PLAINTEXT?"?":u.resourceCenterLauncherIconType===kt.DEFAULT?e.createElement(an,null):u.rcIconAsset&&u.rcIconAsset.assetUrl?e.createElement("img",{src:u.rcIconAsset.assetUrl,className:"company-icon",style:{height:`${u.rcIconSize}px`,width:`${u.rcIconSize}px`}}):e.createElement("span",null)))),e.createElement("div",{ref:fe,className:"userflowjs-resource-center-body",style:{width:Pe+"px"}},e.createElement("div",{ref:lr,className:P({"userflowjs-resource-center-body-content":!0,"userflowjs-resource-center-body-content--padding":b?.kind!=="assistant","userflowjs-resource-center-body-content--same-background":u.sameBackground,"userflowjs-resource-center-body-content--with-made-with-userflow":i.resourceCenterBranding})},r&&e.createElement(e.Fragment,null,b?b.kind==="search"?e.createElement(En,{session:t,navigate:D}):b.kind==="email"?e.createElement(pn,{block:b.block,session:t}):b.kind==="phone"?e.createElement(bn,{block:b.block,session:t}):b.kind==="flows"?e.createElement(vn,{block:b.block,initialQ:b.initialQ,session:t,navigate:D,title:Fe}):b.kind==="knowledgeBase"?e.createElement(gn,{block:b.block,initialQ:b.initialQ,session:t,bodyRef:fe,title:Fe}):b.kind==="subpage"?e.createElement(Cn,{block:b.block,session:t}):b.kind==="announcementList"||b.kind==="announcementShow"?e.createElement(kn,{bodyRef:fe,session:t,route:b,navigate:D,title:Fe}):b.kind==="assistant"?e.createElement(jn,{block:b.block,initialUserContent:b.initialUserContent,session:t,navigate:D,chatBlock:x,onChatShow:ve,onHandoverChatShow:Er}):null:e.createElement(e.Fragment,null,Q.map((d,v)=>{const I=de[d.type],J=Q[v+1];return I?e.createElement(e.Fragment,{key:d.id},e.createElement(I.View,{session:t,flowSession:n,checklistSession:s,block:d,navigate:D,onChatShow:ve}),J&&en(u,d.type,J.type)&&e.createElement("div",{className:"userflowjs-resource-center-divider"})):null}))))),i.resourceCenterBranding&&e.createElement("div",{className:"userflowjs-resource-center-made-with-userflow"},e.createElement("div",{className:"userflowjs-resource-center-made-with-userflow-content",ref:ir},e.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+i.slug+"&utm_content=resource-center",target:"_blank",rel:"noopener noreferrer"},e.createElement(Fr,null),e.createElement("div",null,"Made with Userflow")))),t.draftMode&&e.createElement("div",{className:"userflowjs-resource-center-preview"},e.createElement("div",{ref:ur,className:"userflowjs-resource-center-preview-content"},e.createElement("div",{className:"userflowjs-resource-center-preview-text"},"Preview"),e.createElement("button",{className:"userflowjs-resource-center-preview-button",onClick:()=>{c.endFlow(t,{endReason:Ar.USER_CLOSED})}},e.createElement(y,{icon:rt})))),e.createElement("div",{className:"userflowjs-resource-center-header",style:{width:Pe+"px"}},e.createElement("div",{ref:me,className:"userflowjs-resource-center-header-content"},pt?e.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:d=>D(b?.kind==="announcementShow"?{kind:"announcementList",block:b.block}:null,d)},e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(y,{icon:Wr})),e.createElement("div",{className:"userflowjs-resource-center-icon-button__text"},l("resource_center.back"))):e.createElement("div",{className:P({"userflowjs-resource-center-header-text":!0,"userflowjs-resource-center-header-text--with-icon":!!(Y&&q?.icon)})},Y&&q?.icon&&e.createElement(y,{icon:q.icon,size:16}),bt),e.createElement("div",{className:"flex-1"}),Me.length>0&&e.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:()=>{let d={kind:"search"};if(Me.length===1){const v=Me[0],I=de[v.type];I.routeTo&&(d=I.routeTo({block:v}))}b?.kind==="search"?D(null):(R(c,t,null,"Search icon"),D(d))},"aria-label":"Search"},e.createElement(y,{icon:$r})),e.createElement("button",{className:"userflowjs-resource-center-icon-button userflowjs-resource-center-close-button",onClick:d=>{Be(),d.detail===0&&X(!0)},"aria-label":`Close ${m.headerText}`},e.createElement(y,{icon:zr}))))))),!r&&!n&&p&&A&&A.unreadAnnouncementCount>0&&e.createElement(Xt,{theme:u,count:A.unreadAnnouncementCount,onClick:Et})),!r&&!n&&p&&A?.popoutAnnouncement&&ke(A.popoutAnnouncement,A,t,u),!r&&!n&&p&&A?.boosterAnnouncement&&A.boosterAnnouncement.level===M.MODAL&&ke(A.boosterAnnouncement,A,t,u),!r&&!n&&p&&A?.boosterAnnouncement&&A.boosterAnnouncement.level===M.TOAST&&ke(A.boosterAnnouncement,A,t,u))))},Xt=({theme:t,count:r,onClick:n,style:s})=>{const[o,c]=a.useState(!1);return e.createElement(tt,{className:P({"userflowjs-resource-center-launcher-unread-badge":!0}),noScroll:!0,style:{position:o?void 0:"absolute",visibility:o?void 0:"hidden",...s},stylesheet:et,theme:t,onStylesheetsLoad:c,title:"Resource center unread badge"},e.createElement(Yt,{count:r,onClick:n}))},Yt=({count:t,onClick:r})=>{let n=null;return t>9&&(t=9,n=e.createElement("span",{className:"userflowjs-unread-badge-plus"},"+")),e.createElement("div",{className:P({"userflowjs-unread-badge":!0,"userflowjs-unread-badge--clickable":!!r}),onClick:r},e.createElement("span",null,t),n)},Jt=({session:t,open:r,navigate:n,announcement:s,block:o,rcPlacement:c,onDismiss:l,isStandalonePopout:i})=>{const w=a.useRef(null),m=re(s.theme),u=m.toastPlacement,h=!!o.boosterAnnouncement||i!==void 0&&s?.level===M.TOAST,p=u===c;let E=null,N=null;s&&(E=s.toastAutoDismiss??m.toastAutoDismiss,N=s.toastWidth?s.toastWidth:m.toastWidth);const g=B(),[C,j]=a.useState(!1),{height:_,setEl:k}=Yr();a.useEffect(()=>{const K=w.current;if(!K||E===null)return;const G=Date.now(),me=()=>{const z=1-(Date.now()-G)/(new qt(E||0).toNumber()*1e3);z<=0?(K.style.width="0%",s&&O(g,s)):(K.style.width=`${z*100}%`,requestAnimationFrame(me))};return requestAnimationFrame(me),()=>{K&&(K.style.width="0%")}},[w.current,E,g,s,O]);const T=l||(()=>{s&&O(g,s)}),F=20,_e=a.useMemo(()=>CSS.supports("height: 100dvh")?"dvh":"vh",[]),se=()=>{h&&s&&(O(g,s),R(g,t,o,s.title),n({kind:"announcementShow",block:o,announcementId:s.id}),r())},oe=()=>{s&&(O(g,s),R(g,t,o,s.title),n({kind:"announcementShow",block:o,announcementId:s.id}),r())},$=()=>{n({kind:"announcementShow",block:o,announcementId:s.id}),r()};if(!s)return null;const Le=!!i&&!!c,V=(i!==void 0||!p)&&!!u&&h;return e.createElement("div",{className:P({"userflowjs-resource-center-popout":!h,"userflowjs-resource-center-toast":h,[`userflowjs-resource-center-popout-standalone--${c?.toLowerCase()?.replace(/_/g,"-")}`]:Le,[`userflowjs-resource-center-toast--${u?.toLowerCase()?.replace(/_/g,"-")}`]:V}),style:He(m)},e.createElement(tt,{className:P({"userflowjs-resource-center-popout-frame":!0}),style:{height:`calc(min(${_}px, 100${_e} - 2 * var(--userflow-resource-center-padding-y) - var(--userflow-resource-center-collapsed-height) - ${F}px)`,position:C?void 0:"absolute",visibility:C?void 0:"hidden",...N&&h?{width:N}:{}},stylesheet:et,theme:m,onStylesheetsLoad:j,title:"Resource center popout"},h&&e.createElement("div",{className:"userflowjs-bubble-progress--default"},e.createElement("div",{className:"userflowjs-bubble-progress__fill",ref:w})),e.createElement("div",{ref:k,className:"userflowjs-resource-center-popout-frame-root",style:{cursor:h?"pointer":"auto",padding:h&&m.toastPadding||void 0}},e.createElement("div",{onClick:se},e.createElement("h2",{className:"userflowjs-announcement-title"},e.createElement("span",{className:"userflowjs-unread-dot"}),e.createElement("span",null,s.title)),e.createElement("div",{className:"userflowjs-announcement-time"},e.createElement("div",{className:"userflowjs-announcement-time-text"},Re(s.time))),e.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},e.createElement(W,{doc:s.content,buttons:s.buttons,lookupAttribute:L(s.data)})),!h&&e.createElement(ue,{announcement:s,onMoreClick:oe,confettiColors:m.confettiColors,onSubmitSuccess:$},e.createElement("div",{className:"userflowjs-announcement-more"},e.createElement("button",{className:"userflowjs-tertiary-button",onClick:oe},e.createElement("div",null,s.moreButtonText||"Read more"),e.createElement("span",{className:"userflowjs-rtl-mirrored userflowjs-tertiary-button__icon"},e.createElement(y,{icon:Kt})))))),h&&e.createElement(e.Fragment,null,!s.reactionEnabled&&s.moreEnabled&&e.createElement("div",{onClick:se,className:"userflowjs-announcement-more--toast"},s.moreButtonText||"Read more"),e.createElement(ue,{announcement:s,onMoreClick:se,confettiColors:m.confettiColors,onSubmitSuccess:$})),e.createElement("div",{className:"userflowjs-bubble-toolbar"},e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:T,"aria-label":"Dismiss announcement"},e.createElement(y,{icon:rt}))))),!h&&!i&&e.createElement("div",{className:"userflowjs-resource-center-popout-notch"}))},er=({session:t,open:r,navigate:n,announcement:s,block:o,onDismiss:c})=>{const l=B(),i=re(s.theme),m=c||(()=>{O(l,s)}),u=()=>{O(l,s),R(l,t,o,s.title),n({kind:"announcementShow",block:o,announcementId:s.id}),r()},h=()=>{n({kind:"announcementShow",block:o,announcementId:s.id}),r()};return e.createElement(Zr,{company:t.flow.company,theme:i,position:"fixed",width:s.modalWidth,stepAppearance:jr.MODAL,zIndex:i.checklistZIndex,autoHide3pEnabled:!0,onModalBackdropClick:m,noIframe:!0,isModalAnnouncement:!0},e.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},e.createElement("h1",null,s.title),e.createElement(W,{doc:s.content,buttons:s.buttons,lookupAttribute:L(s.data)}),e.createElement(ue,{announcement:s,onMoreClick:u,confettiColors:i.confettiColors,onSubmitSuccess:h},e.createElement("div",{className:"userflowjs-announcement-more--modal"},e.createElement("button",{className:"userflowjs-bubble-button--primary",onClick:u},s.moreButtonText||"Read more")))),e.createElement("div",{className:"userflowjs-bubble-toolbar"},e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:m,"aria-label":"Dismiss announcement"},e.createElement(y,{icon:rt}))))};function tr(t){return t.filter(r=>{const n=de[r.type];return n.isSearchable?n.isSearchable(r):!!n.search})}const de={[S.ACTION]:{View:t=>{const{block:r,session:n,flowSession:s,checklistSession:o}=t,c=B(),[l,i]=a.useState(!1),w=s?.id,m=o?.id;return a.useEffect(()=>{i(!1)},[w,m]),e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:l?void 0:()=>{R(c,n,r);const u=r.actions.find(h=>h.type===Tr.START_FLOW);u?u.otherFlow?.id!==o?.flow.id&&i(!0):c.closeResourceCenter(),Mr(c,n,r.actions)},disabled:l},e.createElement(ee,{...t}),e.createElement(Z,{...t}),l&&e.createElement(U,null))}},[S.ANNOUNCEMENTS]:{View:t=>{const{block:r,session:n,navigate:s}=t,o=B();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c=>{R(o,n,r),s({kind:"announcementList",block:r},c)}},r.unreadAnnouncementCount>0?e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(Yt,{count:r.unreadAnnouncementCount})):e.createElement(ee,{...t}),e.createElement(Z,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te})))}},[S.ASSISTANT]:{View:t=>{const{block:r,session:n,navigate:s}=t,o=B(),[c,l]=a.useState("");return r.assistantAppearance===Ir.INPUT?e.createElement("div",{className:"userflowjs-resource-center-assistant-block"},e.createElement(fn,{value:c,onChange:l,placeholder:Te(r.name,{lookupAttribute:L(n.data)}),onSubmit:()=>{R(o,n,r),s({kind:"assistant",block:r,initialUserContent:c})}})):e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{R(o,n,r),s({kind:"assistant",block:r,initialUserContent:""})}},e.createElement(ee,{...t}),e.createElement(Z,{...t}))}},[S.CHECKLIST]:{View:({checklistSession:t})=>e.createElement("div",{"data-testid":"resource-center-checklist",className:"userflowjs-resource-center-checklist"},e.createElement(Or,{session:t}),e.createElement(Gr,{draftMode:t.draftMode?"CHECKLIST PREVIEW":!1}))},[S.CONTACT]:{View:t=>{const{block:r,session:n,navigate:s,onChatShow:o}=t,c=B(),l=[];return r.emailEnabled&&l.push({icon:Kr,label:"Email",isRoute:!0,onClick:i=>{R(c,n,r,"Email"),s({kind:"email",block:r},i)}}),r.phoneEnabled&&l.push({icon:Qr,label:"Phone",isRoute:!0,onClick:i=>{R(c,n,r,"Phone"),s({kind:"phone",block:r},i)}}),r.chatEnabled&&l.push({icon:qr,label:"Live-chat",isRoute:!1,onClick:()=>{R(c,n,r,"Chat"),cr(n,r,o)}}),e.createElement("div",{className:P({"userflowjs-resource-center-block":!0,"userflowjs-resource-center-block--clickable":l.length===1}),onClick:l.length===1?l[0].onClick:void 0},l.length===1&&e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(y,{icon:l[0].icon})),e.createElement(Z,{...t}),l.length>1&&l.map(({icon:i,label:w,onClick:m},u)=>e.createElement("button",{key:u,className:"userflowjs-resource-center-icon-button",onClick:m,"aria-label":w},e.createElement(y,{icon:i}))),l.length===1&&l[0].isRoute&&e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te})))}},[S.DIVIDER]:{View:()=>e.createElement("div",{className:"userflowjs-resource-center-divider"})},[S.FLOWS]:{View:t=>{const{block:r,session:n,navigate:s}=t,o=B();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c=>{R(o,n,r),s({kind:"flows",block:r},c)}},e.createElement(ee,{...t}),e.createElement(Z,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te})))},routeTo:({block:t,initialQ:r})=>({kind:"flows",block:t,initialQ:r}),isSearchable:t=>!!t.searchEnabled,search:async({client:t,session:r,block:n,q:s})=>{const{flows:o}=await t.send({kind:"ListResourceCenterBlockFlows",sessionId:r.id,blockCvid:n.cvid},{handlesRejection:!0}),c=rr(o,s),l=c.slice(0,Ht);return{block:n,truncated:l.length===c.length,results:l.map(i=>({kind:"flow",flow:i}))}}},[S.KNOWLEDGE_BASE]:{View:t=>{const{block:r,session:n,navigate:s}=t,o=B();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c=>{R(o,n,r),s({kind:"knowledgeBase",block:r},c)}},e.createElement(ee,{...t}),e.createElement(Z,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te})))},routeTo:({block:t,initialQ:r})=>({kind:"knowledgeBase",block:t,initialQ:r}),search:async({client:t,session:r,block:n,q:s})=>{const{truncated:o,articles:c}=await t.send({kind:"SearchKnowledgeBase",sessionId:r.id,blockCvid:n.cvid,q:s,offset:0,limit:Ht},{handlesRejection:!0});return{block:n,truncated:o,results:c.map(l=>({kind:"article",article:l}))}}},[S.MESSAGE]:{View:({block:t,session:r})=>e.createElement("div",{className:"userflowjs-resource-center-block"},e.createElement("div",{className:"userflowjs-resource-center-block-text userflowjs-bubble-content"},e.createElement(W,{doc:t.content,lookupAttribute:L(r.data)})))},[S.SUBPAGE]:{View:t=>{const{block:r,session:n,navigate:s}=t,o=B();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c=>{R(o,n,r),s({kind:"subpage",block:r},c)}},e.createElement(ee,{...t}),e.createElement(Z,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te})))}}},ee=({block:t})=>t.icon?e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(y,{icon:t.icon,size:16})):null,Z=({block:t,session:r})=>e.createElement("div",{className:"userflowjs-resource-center-block-text"},e.createElement(ie,{doc:t.name,lookupAttribute:L(r.data)})),En=({session:t,navigate:r})=>{const n=B(),s=t.version.resourceCenter.blocks,o=tr(s),{t:c}=ne(),l=a.useRef(null),[i,w]=a.useState(""),[m,u]=ot(i,w),[h,p]=a.useState(null);return a.useEffect(()=>{if(i.trim()===""){p(null);return}let E=!1;return(async()=>{p(null);const g=await Promise.all(s.map(async C=>{const{search:j}=de[C.type];if(!j)return null;try{return await j({client:n,session:t,block:C,q:i})}catch(_){return console.error(`Userflow.js: Global search failed for ${C.type} block=`,C,"error=",_),null}}));E||p(g.filter(C=>C!=null&&C.results.length>0))})(),()=>{E=!0}},[n,t,s,i]),a.useEffect(()=>{l.current?.focus({preventScroll:!0})},[]),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:l,className:"userflowjs-text-input",type:"text",value:m,onChange:E=>u(E.target.value),placeholder:c("resource_center.search_placeholder")})),i.trim()===""?e.createElement("div",{"data-testid":"resource-center-empty-query",className:"userflowjs-resource-center-list-route-error"},c("resource_center.search_in")," ",o.map((E,N)=>e.createElement(e.Fragment,{key:E.cvid},N>0&&(N===o.length-1?` ${c("and")} `:", "),e.createElement("b",null,e.createElement(ie,{doc:E.name,lookupAttribute:L(t.data)})))),"."):h?h.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.no_results_found")):h.map(({block:E,truncated:N,results:g},C)=>{const j=de[E.type],_=j.routeTo&&j.routeTo({block:E,initialQ:i});return e.createElement(e.Fragment,{key:E.cvid},C>0&&e.createElement("div",{className:"userflowjs-resource-center-divider"}),e.createElement("div",{className:"userflowjs-resource-center-label"},e.createElement(ie,{doc:E.name,lookupAttribute:L(t.data)})),g.map((k,T)=>k.kind==="flow"?e.createElement(nr,{key:k.flow.id,block:E,session:t,flow:k.flow,navigate:r}):k.kind==="article"?e.createElement(sr,{key:T,block:E,session:t,article:k.article}):null),!N&&_&&e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:k=>{R(n,t,E),r(_,k)}},e.createElement("div",{className:"userflowjs-resource-center-block-text"},c("more"),":"," ",e.createElement(ie,{doc:E.name,lookupAttribute:L(t.data)})),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te}))))}):e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null)))},pn=({block:t,session:r})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement(W,{doc:t.emailContent,lookupAttribute:L(r.data)})),bn=({block:t,session:r})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement(W,{doc:t.phoneContent,lookupAttribute:L(r.data)})),vn=({block:t,initialQ:r,session:n,navigate:s,title:o})=>{const{t:c}=ne(),l=a.useRef(null),[i,w]=a.useState(r||""),[m,u]=ot(i,w),{data:h,error:p}=Qt({message:{kind:"ListResourceCenterBlockFlows",sessionId:n.id,blockCvid:t.cvid}}),E=h?.flows,N=a.useMemo(()=>E?rr(E,i):null,[E,i]);return a.useEffect(()=>{l.current?.focus({preventScroll:!0})},[]),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},o),t.searchEnabled&&e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:l,className:"userflowjs-text-input",type:"text",value:m,onChange:g=>u(g.target.value),placeholder:c("resource_center.search_placeholder")})),p?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.generic_error")):N?N.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.no_results_found")):N.map(g=>e.createElement(nr,{key:g.id,block:t,session:n,flow:g,navigate:s})):e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,{fadeIn:!0})))};function rr(t,r){const n=r.toLowerCase().trim();return n===""?t:t.filter(s=>s.name.toLowerCase().includes(n))}const nr=({block:t,session:r,flow:n,navigate:s})=>{const o=B(),[c,l]=a.useState(!1);return a.useEffect(()=>{if(!c||n.type!==Nt.CHECKLIST)return;const i=()=>{o.checklistSession?.flow.id===n.id&&(w(),s(null))},w=()=>{o.off("checklistChanged",i)};return o.on("checklistChanged",i),w},[o,c,n.type,n.id,s]),e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{if(R(o,r,t,n.name),o.checklistSession?.flow.id===n.id){s(null);return}o.startFlow({flowId:n.id,startReason:r.draftMode?jt.DRAFT:jt.RESOURCE_CENTER,replaceCurrent:!0}),l(!0);const i=Te(n.url,{lookupAttribute:L(r.data)});i&&Dr(i)},disabled:c},n.iconSetting!==Rr.HIDE&&e.createElement("div",{className:"userflowjs-resource-center-block-icon"},n.icon?e.createElement(y,{icon:n.icon,size:16}):e.createElement(y,{icon:n.type===Nt.CHECKLIST?"regular/tasks":"regular/shoe-prints",size:16})),r.draftMode&&!n.published&&e.createElement("div",{className:"userflowjs-resource-center-code-block"},e.createElement("div",{title:"Unpublished. Preview only"},e.createElement("code",null,"P"))),e.createElement("div",{className:"userflowjs-resource-center-block-text"},n.name),c&&e.createElement(U,null))},gn=({block:t,initialQ:r,session:n,bodyRef:s,title:o})=>{const{t:c}=ne(),l=a.useRef(null),[i,w]=a.useState(r||""),[m,u]=ot(i,w),{loading:h,loadingMore:p,data:E,messageForData:N,error:g,loadMore:C}=Qt({message:{kind:"SearchKnowledgeBase",sessionId:n.id,blockCvid:t.cvid,q:i,offset:0}}),j=E?.truncated,_=a.useCallback(()=>{C((T,F)=>({...F,offset:T.articles.length}),(T,F)=>({...F,articles:[...T.articles,...F.articles]}))},[C]);or({bodyRef:s,loading:h,loadingMore:p,truncated:j,loadMoreHelper:_}),a.useEffect(()=>{l.current?.focus({preventScroll:!0})},[]);let k=t.knowledgeBaseUrl||"";return k.match(/^https?:\/\//)||(k=`http://${k}`),k=Gt(k),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},o,e.createElement("a",{className:"userflowjs-resource-center-icon-button",href:k,target:"_blank",rel:"noopener noreferrer"},e.createElement(y,{icon:Vr}))),e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:l,className:"userflowjs-text-input",type:"text",value:m,onChange:T=>u(T.target.value),placeholder:c("resource_center.search_placeholder")})),g?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},g.code==="quota_exceeded"?"Sorry, this company has reached its max number of searches. Consider asking Userflow to be moved to a dedicated search engine for a higher quota.":g.humanMessage||c("resource_center.generic_error")):h||!E?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null)):E.articles.length===0?N?.q===""?null:e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.no_results_found")):e.createElement(e.Fragment,null,N?.q===""&&e.createElement("div",{className:"userflowjs-resource-center-label"},c("resource_center.suggested_articles")),E.articles.map((T,F)=>e.createElement(sr,{key:F,block:t,session:n,article:T})),p&&e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null))))},sr=({block:t,article:r,session:n})=>{const s=B();return e.createElement("a",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{R(s,n,t,r.title)},href:Gt(r.url),target:"_blank",rel:"noopener noreferrer"},e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(y,{icon:"regular/file-alt",size:16})),e.createElement("div",{className:"userflowjs-resource-center-block-text"},e.createElement("span",{dangerouslySetInnerHTML:{__html:r.htmlTitle}}),e.createElement("div",{className:"userflowjs-resource-center-block-subtext",dangerouslySetInnerHTML:{__html:r.htmlSnippet}})))},Cn=({block:t,session:r})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement(W,{doc:t.content,lookupAttribute:L(r.data)})),kn=({bodyRef:t,session:r,route:n,navigate:s,title:o})=>{const c=B(),[l,i]=a.useState(void 0);return a.useLayoutEffect(()=>{t.current&&l!=null&&n?.kind==="announcementList"&&(t.current.scrollTop=l)},[t,l,n?.kind]),!n||n?.kind!=="announcementList"&&n?.kind!=="announcementShow"?null:e.createElement(Xr,null,n.kind==="announcementList"&&e.createElement(Sn,{bodyRef:t,session:r,block:n.block,onMoreClick:w=>{i(t.current?.scrollTop),R(c,r,n.block,w.title),s({kind:"announcementShow",block:n.block,announcementId:w.id})},title:o}),n.kind==="announcementShow"&&e.createElement(Nn,{announcementId:n.announcementId}))},Sn=({bodyRef:t,block:r,session:n,onMoreClick:s,title:o})=>{const{t:c}=ne(),{announcements:l,error:i,loading:w,loadingMore:m,truncated:u,pageSize:h,loadMore:p}=nt(),[E,N]=a.useMemo(()=>{const C=[],j=[];if(l){let _=-1;for(const k of l)_++,_<h&&!k.seen&&k.level!==M.SILENT?C.push(k):j.push(k)}return[C,j]},[l,h]),g=E.length;return or({bodyRef:t,loading:w,loadingMore:m,truncated:u,loadMoreHelper:p}),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},o),i?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.generic_error")):w?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null)):l.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},Ie.exists("resource_center.no_announcements",{fallbackLng:[]})?c("resource_center.no_announcements"):c("resource_center.no_results_found")):e.createElement(e.Fragment,null,g>0&&e.createElement("div",{className:"userflowjs-announcement-unread-header"},c("resource_center.unread",{count:g})),E.map(C=>e.createElement(zt,{key:C.id,bodyRef:t,announcement:C,onMoreClick:()=>s(C)})),N.map(C=>e.createElement(zt,{key:C.id,bodyRef:t,announcement:C,onMoreClick:()=>s(C)})),m&&e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null))))},$t=new Set;function O(t,r){r.seen||$t.has(r.id)||($t.add(r.id),ct(t,r))}const zt=({bodyRef:t,onMoreClick:r,announcement:n})=>{const s=B(),o=Vt(),c=re(o.version.theme),l=a.useRef(null),{submitReaction:i,submitComment:w}=nt(),m=a.useRef(!1);return a.useEffect(()=>{if(m.current||n.seen)return;const u=new IntersectionObserver(p=>{const E=p[0];E&&E.isIntersecting&&(O(s,n),m.current=!0,h())},{root:t.current,threshold:1}),h=()=>{u.disconnect()};return u.observe(l.current),h},[t,s,n]),e.createElement("div",{className:"userflowjs-announcement-list-item"},e.createElement("div",{className:"userflowjs-announcement-time-divider"},e.createElement("div",{className:"userflowjs-announcement-time-divider-line"}),e.createElement("div",{className:"userflowjs-announcement-time-text"},Re(n.time)),e.createElement("div",{className:"userflowjs-announcement-time-divider-line"})),e.createElement("h2",{ref:l,className:"userflowjs-announcement-title"},!n.seen&&n.level!==M.SILENT&&e.createElement("span",{className:"userflowjs-unread-dot"}),e.createElement("span",null,n.title)),e.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},e.createElement(le.Provider,{value:{...o,data:n.data}},e.createElement(W,{doc:n.content,buttons:n.buttons,lookupAttribute:L(n.data)}))),e.createElement(ue,{announcement:n,onMoreClick:r,confettiColors:c.confettiColors,onReactionChange:i,onCommentSubmit:w},e.createElement("div",{className:"userflowjs-announcement-more"},e.createElement("button",{className:"userflowjs-tertiary-button",onClick:r},e.createElement("div",null,n.moreButtonText||"Read more"),e.createElement("span",{className:"userflowjs-rtl-mirrored"},e.createElement(y,{icon:Kt}))))))},Nn=({announcementId:t})=>{const r=B(),n=Vt(),s=re(n.version.theme),[o,c]=a.useState(null),{fetchAnnouncement:l,loading:i,error:w,submitComment:m,submitReaction:u}=nt(),{t:h}=ne();return a.useEffect(()=>{l(t).then(c)},[t]),a.useEffect(()=>{!o||o.seen||O(r,o)},[r,o]),i?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null)):e.createElement(e.Fragment,null,w?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},w.humanMessage||h("resource_center.generic_error")):i||!o?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null)):e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-announcement-show"},e.createElement("h2",{className:"userflowjs-announcement-title"},o.title),e.createElement("div",{className:"userflowjs-announcement-time"},e.createElement("div",{className:"userflowjs-announcement-time-text"},Re(o.time))),e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement(le.Provider,{value:{...n,data:o.data}},e.createElement(W,{doc:o.content,buttons:o.buttons,lookupAttribute:L(o.data)}),o.moreEnabled&&e.createElement(W,{doc:o.moreContent,buttons:o.moreButtons,lookupAttribute:L(o.data)}))),e.createElement(ue,{announcement:o,confettiColors:s.confettiColors,showMoreButton:!1,onCommentSubmit:m,onReactionChange:u}))))},jn=({block:t,initialUserContent:r,session:n,navigate:s,onChatShow:o,onHandoverChatShow:c,chatBlock:l})=>{const i=t.assistantFlowId,w=B(),[m,u]=a.useState(null),[h,p]=a.useState(null),[E,N]=a.useState(null),[g]=a.useState(r);a.useEffect(()=>{r&&s({kind:"assistant",block:t,initialUserContent:""})},[r,t,s]),a.useEffect(()=>{let j=!1;return(async()=>{try{const k=ae.getItem("assistantConversationId:"+i),[T,F]=await Promise.all([wn(),w.send({kind:"GetAssistant",assistantFlowId:i,conversationId:k},{handlesRejection:!0,endBatch:!0})]);if(j)return;u(()=>T),p(F)}catch(k){console.error("Resource center assistant route failed to load:",k),N(k.humanMessage||"Sorry, something went wrong. Please try again or contact my human friends.")}})(),()=>{j=!0}},[w,i]);const C=a.useMemo(()=>{if(!t.assistantContactEnabled)return;const j=n.version.resourceCenter?.blocks.find(_=>_.type===S.CONTACT);if(j)return()=>{switch(R(w,n,t,t.assistantContactButtonText||void 0),t.assistantContactMethod){case St.EMAIL:s({kind:"email",block:j});break;case St.PHONE:s({kind:"phone",block:j});break;default:s(null),cr(n,j,o);break}}},[w,n,t,o,s]);return E?e.createElement("div",{className:"userflowjs-assistant-chat"},e.createElement("div",{className:"userflowjs-assistant-chat__content"},e.createElement("div",{className:"userflowjs-assistant-chat__error"},E))):!m||!h?e.createElement(U,{center:!0,fadeIn:!0}):e.createElement(m,{block:t,session:n,assistantReply:h,initialUserContent:g,onContactClick:C,contactButtonText:t.assistantContactButtonText||void 0,onHandoverChatShow:c,chatBlock:l})};function R(t,r,n,s){t.send({kind:"ClickResourceCenter",sessionId:r.id,description:n?Te(n.name,{lookupAttribute:L(r.data)})+(s?` - ${s}`:""):s},{batch:!0})}function or({bodyRef:t,loading:r,loadingMore:n,truncated:s,loadMoreHelper:o}){a.useEffect(()=>{const c=t.current;if(!c||r||n||s)return;const l=()=>{c.scrollHeight-c.clientHeight-c.scrollTop>400||o()};return c.addEventListener("scroll",l),()=>{c.removeEventListener("scroll",l)}},[t,r,n,s,o])}function cr(t,r,n){if(r.chatProvider){const s=ye[r.chatProvider];try{s.show({block:r})}catch(o){console.error(`Userflow.js: Error when showing ${r.chatProvider}:`,o)}n()}else t.draftMode&&window.alert("You have not selected a chat provider. Go to the resource center builder in Userflow. Click the Contact block. Pick a chat provider in the side panel.")}function ct(t,r){t.setResourceCenterSession(n=>n?{...n,version:{...n.version,resourceCenter:{...n.version.resourceCenter,blocks:n.version.resourceCenter.blocks.map(s=>s.type===S.ANNOUNCEMENTS?{...s,unreadAnnouncementCount:r.level===M.SILENT?s.unreadAnnouncementCount:s.unreadAnnouncementCount-1,popoutAnnouncement:s.popoutAnnouncement?.id===r.id?null:s.popoutAnnouncement,boosterAnnouncement:s.boosterAnnouncement?.id===r.id?null:s.boosterAnnouncement}:s)}}}:null),t.send({kind:"MarkAnnouncementSeen",announcementId:r.id,versionId:r.versionId}),t.toggleUI()}function ar(t){return t?.version.resourceCenter?.blocks.find(r=>r.type===S.ANNOUNCEMENTS)||null}function Re(t){const r=t?new Date(t):new Date;let n=new Intl.DateTimeFormat(Ie.language,{weekday:"long",day:"numeric",month:"short",year:r.getFullYear()===new Date().getFullYear()?void 0:"numeric"}).format(r);return n.substring(0,1).toUpperCase()+n.substring(1)}const Zn=Object.freeze(Object.defineProperty({__proto__:null,FloatingAnnouncements:Jt,LauncherUnreadBadge:Xt,ModalAnnouncement:er,ResourceCenterApp:Wt,default:Wt,formatAnnouncementTime:Re,getAnnouncementsBlock:ar,markAnnouncementSeen:O,syncAnnouncementSeen:ct},Symbol.toStringTag,{value:"Module"}));export{fn as A,mn as G,Xt as L,Zn as R,ye as c,Gt as d,Re as f,O as m};
4
+ `))&&(j+=" "),u=u||"growing-textarea",h=h||u+"__mirror";const[_,k]=a.useState(!1);return e.createElement("div",{className:P({[u]:!0,[`${u}__loading`]:g})},e.createElement("div",{className:h+" "+(p||"")},j),e.createElement("textarea",{ref:t,value:r,onChange:T=>n&&n(T.target.value),onBlur:s,onKeyDown:T=>{if(T.key==="Enter"&&_){T.preventDefault();return}o&&o(T)},onMouseDown:c,placeholder:l,maxLength:i,disabled:w||g,readOnly:m,className:P({"growing-textarea__input":!0,[p||""]:!0,[`${u}__with-icon`]:!!E,[`${u}__loading-input`]:g}),onCompositionStart:()=>k(!0),onCompositionEnd:()=>k(!1)}),E&&!g&&e.createElement("div",{className:`${u}__icon`},e.createElement("button",{className:"btn btn--plain-blue btn--square btn--md32",onClick:N},e.createElement(y,{icon:E}))),g&&e.createElement("div",{className:`${u}__loader`},e.createElement(dn,{indeterminate:!0,size:"xs",color:"purple"})),C)},fn=({textareaRef:t,value:r,onChange:n,onSubmit:s,placeholder:o,readOnly:c})=>{const l=()=>{s&&s()};return e.createElement("div",{className:"userflowjs-assistant-chat-input"},e.createElement(mn,{textareaRef:t,className:"userflowjs-growing-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea userflowjs-assistant-chat-input__textarea",placeholder:o,readOnly:c,value:r||"",onChange:n,onKeyDown:i=>{!i.shiftKey&&i.key==="Enter"&&(i.preventDefault(),l())}}),e.createElement("button",{"data-testid":"assistant-chat-input-submit",className:"userflowjs-assistant-chat-input__submit",onClick:()=>l()},e.createElement(y,{icon:Hr})))};function hn(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function Gt(t){return Ae.linkUrlDecorator?Ae.linkUrlDecorator(t):t}const Ht=5,wn=async()=>(await _r(async()=>{const{ResourceCenterAssistantChat:t}=await import("./ResourceCenterAssistantChat.js");return{ResourceCenterAssistantChat:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]))).ResourceCenterAssistantChat,Wt=({session:t,isOpen:r,flowSession:n,checklistSession:s,resourceCenterLauncherHidden:o})=>{const c=B(),{t:l}=ne(),{company:i}=t.flow,{version:w}=t,m=w.resourceCenter,u=re(w.theme),h=m.launcherType??je.DEFAULT,p=a.useMemo(()=>h===je.CUSTOM?!1:o===!1?!0:o===!0?!1:h===je.DEFAULT,[h,o]),E=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;a.useEffect(()=>{Ie.changeLanguage(E)},[E]);const{loaded:N}=It(window,yt,u),[g,C]=a.useState(!1),j=N&&g,[_,k]=a.useState(Tt()),[T,F]=a.useState(Rt()),_e=a.useCallback(()=>{k(Tt()),F(Rt())},[]);Pr(_e);const{zIndex:se,bringToFront:oe}=Lr(),[$,Le]=a.useState(null),[V,K]=a.useState(null),[G,me]=a.useState(null),fe=a.useRef(null),[z,lr]=a.useState(null),[at,ir]=a.useState(null),[lt,ur]=a.useState(null),[dr,mr]=a.useState(0),[fr,hr]=a.useState(0),he=a.useCallback(()=>{V&&mr(Math.round(V?.offsetWidth||0)),hr(Math.round((G?.offsetHeight||0)+(z?.offsetHeight||0)+(at?.offsetHeight||0)+(lt?.offsetHeight||0)))},[V,G,z,at,lt]);a.useLayoutEffect(()=>{if(!$||typeof We!="function")return;const d=new We(()=>{he()});return d.observe($,{childList:!0,attributes:!0,subtree:!0}),()=>{d.disconnect()}},[$,he]),a.useLayoutEffect(()=>{he()},[he]);const[it,ut]=a.useState(!1),xe=a.useRef(),we=a.useCallback(()=>{ut(!0),window.clearTimeout(xe.current),xe.current=window.setTimeout(()=>{ut(!1)},u.resourceCenterTransitionDuration)},[u.resourceCenterTransitionDuration]);a.useEffect(()=>()=>{window.clearTimeout(xe.current)},[]);const Ee=a.useCallback(()=>{oe(),we(),c.openResourceCenter()},[oe,c,we]),Be=a.useCallback(()=>{we(),c.closeResourceCenter()},[c,we]),[dt,X]=a.useState(!1);a.useEffect(()=>{if(dt){if(!hn())if(r){const d='button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea';let v=z?.querySelector(".userflowjs-assistant-chat-input textarea")||z?.querySelector(d)||G?.querySelector(d);if(v){const I=v.closest&&v.closest(".userflowjs-resource-center-checklist")||null;I?Ur(I):v.focus({preventScroll:!0})}}else V?.focus({preventScroll:!0});X(!1)}},[dt,r,z,G,V]),a.useEffect(()=>{const d=$?.ownerDocument.defaultView;if(!r||!d)return;const v=I=>{I.key==="Escape"&&(Be(),X(!0))};return d.addEventListener("keydown",v),()=>d.removeEventListener("keydown",v)},[r,$,X,Be]);const[b,pe]=a.useState(()=>Lt(t,ae.getItem(`resourceCenterRoute:v1:${t.id}`))),D=a.useCallback((d,v)=>{pe(d);const I=Jr(d);I?ae.setItem(`resourceCenterRoute:v1:${t.id}`,I):ae.removeItem(`resourceCenterRoute:v1:${t.id}`),v?.detail===0&&X(!0)},[t.id]);a.useEffect(()=>{const d=v=>{D(v)};return c.on("private:resourceCenterNavigate",d),()=>c.off("private:resourceCenterNavigate",d)},[c,t,D]),a.useEffect(()=>{const d=ae.getItem(`resourceCenterRoute:v1:${t.id}`);pe(Lt(t,d))},[t]),a.useEffect(()=>{if(!t.draftMode||!b||!("block"in b)||!b.block)return;const d=m.blocks.find(v=>v.cvid===b.block.cvid);d?JSON.stringify(d)!==JSON.stringify(b.block)&&pe({...b,block:d}):pe(null),b.block},[t.draftMode,m,b]);const Q=a.useMemo(()=>m.blocks.filter(d=>!(d.type===S.CHECKLIST&&!s||d.type===S.DIVIDER&&u.resourceCenterAutoDividers||d.hiddenWhenFlowsActive&&d.hiddenWhenFlowsActive.some(v=>v===n?.flow.id||v===s?.flow.id))),[m,n,s,u.resourceCenterAutoDividers]),Y=Q.length===1,Me=a.useMemo(()=>tr(Q),[Q]);a.useEffect(()=>{if(!r||!Y)return;const d=Q[0];let v=null;switch(d.type){case S.ANNOUNCEMENTS:v={kind:"announcementList",block:d};break;case S.FLOWS:v={kind:"flows",block:d};break;case S.KNOWLEDGE_BASE:v={kind:"knowledgeBase",block:d};break;case S.SUBPAGE:v={kind:"subpage",block:d};break;case S.ASSISTANT:v={kind:"assistant",block:d,initialUserContent:""};break}v&&D(v)},[r,Q,D,Y]);const De=a.useMemo(()=>!s||!m.blocks.some(d=>d.type===S.CHECKLIST)?0:yr(s),[m,s]),x=a.useMemo(()=>m.blocks.find(d=>d.type===S.CONTACT&&d.chatEnabled&&d.chatProvider),[m]),[wr,be]=a.useState(!1),ce=a.useRef(null),ve=a.useCallback(()=>{c.closeResourceCenter(),x&&x.chatProvider!==H.CUSTOM&&be(!0)},[c,x]),ge=a.useCallback(()=>{be(!1)},[]),Er=a.useCallback(d=>{if(ce.current?.(),ce.current=null,Ae.autoHide3pDisabled=!0,be(!0),x&&d.chatProvider===x.chatProvider)return;const v=ye[d.chatProvider];try{ce.current=v.configure({block:d,onShow:()=>{},onHide:()=>{be(!1)}})}catch(I){console.error(`Userflow.js: Error when configuring ${d.chatProvider}:`,I)}},[x]),mt=a.useCallback(()=>{if(x)try{ye[x.chatProvider].hide({block:x}),ge()}catch(d){console.error(`Userflow.js: Error when hiding ${x.chatProvider}:`,d)}},[x,ge]);a.useEffect(()=>{if(!x)return;Ae.autoHide3pDisabled=!0;const d=ye[x.chatProvider];try{const v=d.configure({block:x,onShow:ve,onHide:ge});return()=>{v()}}catch(v){console.error(`Userflow.js: Error when configuring ${x.chatProvider}:`,v);return}},[x,ve,ge]),a.useEffect(()=>{r&&(mt(),ce.current?.(),ce.current=null)},[mt,r]);const A=ar(t),Ce=a.useMemo(()=>{if(!A)return null;if(A.boosterAnnouncement){const d=A.boosterAnnouncement;if(!d.seen&&(d.level===M.TOAST||d.level===M.MODAL))return d}return A.popoutAnnouncement&&!A.popoutAnnouncement.seen?A.popoutAnnouncement:null},[A]),ft=re(Ce?.theme||w.theme);It(window,yt,p?void 0:ft);const ke=a.useCallback((d,v,I,J,Ne)=>{const gt=()=>{ct(c,d)};return e.createElement(le.Provider,{value:{...I,data:d.data}},d.level===M.MODAL&&e.createElement(er,{session:I,open:Ee,navigate:D,block:v,announcement:d,onDismiss:gt}),(d.level===M.TOAST||d.level===M.POPOUT)&&e.createElement(Jt,{session:I,open:Ee,navigate:D,block:v,announcement:d,onDismiss:gt,isStandalonePopout:Ne?.isStandalonePopout,rcPlacement:J.resourceCenterPlacement}))},[c,Ee,D]),pr=(d,v,I)=>{const J={...He(I),zIndex:At(xr),position:"fixed",top:0,left:0,width:"100vw",height:"100vh",pointerEvents:d.level===M.MODAL?"auto":"none"},Ne={...t,data:{...t.data,...d.data||{}}};return e.createElement(le.Provider,{value:Ne},e.createElement("div",{className:"userflowjs-theme-root",style:J,id:"userflowjs-announcement-app"},ke(d,v,Ne,I,{isStandalonePopout:d.level===M.POPOUT})))},br=!!b&&(b.kind==="search"||b.kind==="flows"||b.kind==="knowledgeBase"),ht=b?.kind==="assistant"||b?.kind==="announcementList"||b?.kind==="announcementShow",Pe=Math.min(ht?u.resourceCenterFullWidth:u.resourceCenterWidth,_-2*u.resourceCenterPaddingX),vr=540,gr=720,Cr={zIndex:u.resourceCenterZIndex!=null?u.resourceCenterZIndex:r?se:At(Br),position:j?void 0:"absolute",visibility:j&&!wr?void 0:"hidden"},kr={width:(r?Pe:dr)+"px",height:r?Math.min(br?vr:ht?gr:fr,T-2*u.resourceCenterPaddingY,u.resourceCenterMaxHeight==null?Number.MAX_VALUE:u.resourceCenterMaxHeight)+"px":void 0,display:!p&&!r?"none":void 0},[Sr,wt]=a.useState(!1),Et=()=>{Ee(),X(!0)},pt=b!=null&&(!Y||b.kind==="announcementShow"),q=b&&"block"in b?b.block:null;let bt=m.headerText;b!=null&&!pt&&q&&(bt=Te(q.name,{lookupAttribute:L(t.data)}));const Fe=!Y&&q?e.createElement("div",{className:"userflowjs-resource-center-list-route-title"},e.createElement(ie,{doc:q.name,lookupAttribute:L(t.data)})):null,vt=u.resourceCenterDisplayChecklistProgress&&s&&De>0?e.createElement("div",{"data-testid":"resource-center-launcher-badge",className:"userflowjs-resource-center-launcher-badge"},De,e.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")):null;let Se="",Ue="";u.resourceCenterLauncherTextMode===Ct.CHECKLIST_OVERRIDE&&s&&De>0?Se=s.version.checklist?.launcherText||"Get Started":u.resourceCenterLauncherTextMode!==Ct.NONE&&(Ue=m.buttonText);const Oe=Ce?.level,Nr=Oe===M.MODAL||Oe===M.TOAST||Oe===M.POPOUT&&(h!==je.CUSTOM||o===!0);return!p&&!r&&Ce&&A&&Nr?pr(Ce,A,ft):e.createElement(le.Provider,{value:t},e.createElement("div",{"data-testid":"resource-center-app",className:"userflowjs-resource-center-app userflowjs-theme-root",style:He(u),dir:Ie.dir()},e.createElement("div",{className:P({"userflowjs-resource-center":!0,"userflowjs-resource-center--fixed":!0,[`userflowjs-resource-center--placement-${u.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0}),style:Cr},e.createElement("div",{className:"userflowjs-resource-center-frame-wrapper",onMouseEnter:()=>wt(!0),onMouseLeave:()=>wt(!1)},e.createElement(tt,{className:P({"userflowjs-resource-center-frame":!0,"userflowjs-resource-center-frame--animating":it,"userflowjs-resource-center-frame--open":r,"userflowjs-resource-center-frame--closed":!r}),style:kr,stylesheet:et,theme:u,onStylesheetsLoad:C,title:"Resource center"},j&&e.createElement(e.Fragment,null,e.createElement("div",{ref:Le,className:P({"userflowjs-resource-center-frame-root":!0,[`userflowjs-resource-center-frame-root--placement-${u.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0,"userflowjs-resource-center-frame-root--animating":it,"userflowjs-resource-center-frame-root--open":r,"userflowjs-resource-center-frame-root--closed":!r}),role:r?"dialog":void 0,"aria-label":r?m.headerText:void 0},p&&e.createElement("div",{className:"userflowjs-resource-center-launcher-container"},e.createElement("button",{ref:K,className:P({"userflowjs-resource-center-launcher-button":!0,"userflowjs-resource-center-launcher-button--hover":Sr}),onClick:Et,"aria-label":`Open ${m.headerText}`},vt,Se&&e.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},Se),(vt||Se)&&e.createElement("div",{className:"userflowjs-resource-center-launcher-divider"}),Ue&&e.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},Ue),e.createElement("div",{className:"userflowjs-resource-center-launcher-icon"},u.resourceCenterLauncherIconType===kt.PLAINTEXT?"?":u.resourceCenterLauncherIconType===kt.DEFAULT?e.createElement(an,null):u.rcIconAsset&&u.rcIconAsset.assetUrl?e.createElement("img",{src:u.rcIconAsset.assetUrl,className:"company-icon",style:{height:`${u.rcIconSize}px`,width:`${u.rcIconSize}px`}}):e.createElement("span",null)))),e.createElement("div",{ref:fe,className:"userflowjs-resource-center-body",style:{width:Pe+"px"}},e.createElement("div",{ref:lr,className:P({"userflowjs-resource-center-body-content":!0,"userflowjs-resource-center-body-content--padding":b?.kind!=="assistant","userflowjs-resource-center-body-content--same-background":u.sameBackground,"userflowjs-resource-center-body-content--with-made-with-userflow":i.resourceCenterBranding})},r&&e.createElement(e.Fragment,null,b?b.kind==="search"?e.createElement(En,{session:t,navigate:D}):b.kind==="email"?e.createElement(pn,{block:b.block,session:t}):b.kind==="phone"?e.createElement(bn,{block:b.block,session:t}):b.kind==="flows"?e.createElement(vn,{block:b.block,initialQ:b.initialQ,session:t,navigate:D,title:Fe}):b.kind==="knowledgeBase"?e.createElement(gn,{block:b.block,initialQ:b.initialQ,session:t,bodyRef:fe,title:Fe}):b.kind==="subpage"?e.createElement(Cn,{block:b.block,session:t}):b.kind==="announcementList"||b.kind==="announcementShow"?e.createElement(kn,{bodyRef:fe,session:t,route:b,navigate:D,title:Fe}):b.kind==="assistant"?e.createElement(jn,{block:b.block,initialUserContent:b.initialUserContent,session:t,navigate:D,chatBlock:x,onChatShow:ve,onHandoverChatShow:Er}):null:e.createElement(e.Fragment,null,Q.map((d,v)=>{const I=de[d.type],J=Q[v+1];return I?e.createElement(e.Fragment,{key:d.id},e.createElement(I.View,{session:t,flowSession:n,checklistSession:s,block:d,navigate:D,onChatShow:ve}),J&&en(u,d.type,J.type)&&e.createElement("div",{className:"userflowjs-resource-center-divider"})):null}))))),i.resourceCenterBranding&&e.createElement("div",{className:"userflowjs-resource-center-made-with-userflow"},e.createElement("div",{className:"userflowjs-resource-center-made-with-userflow-content",ref:ir},e.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+i.slug+"&utm_content=resource-center",target:"_blank",rel:"noopener noreferrer"},e.createElement(Fr,null),e.createElement("div",null,"Made with Userflow")))),t.draftMode&&e.createElement("div",{className:"userflowjs-resource-center-preview"},e.createElement("div",{ref:ur,className:"userflowjs-resource-center-preview-content"},e.createElement("div",{className:"userflowjs-resource-center-preview-text"},"Preview"),e.createElement("button",{className:"userflowjs-resource-center-preview-button",onClick:()=>{c.endFlow(t,{endReason:Ar.USER_CLOSED})}},e.createElement(y,{icon:rt})))),e.createElement("div",{className:"userflowjs-resource-center-header",style:{width:Pe+"px"}},e.createElement("div",{ref:me,className:"userflowjs-resource-center-header-content"},pt?e.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:d=>D(b?.kind==="announcementShow"?{kind:"announcementList",block:b.block}:null,d)},e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(y,{icon:Wr})),e.createElement("div",{className:"userflowjs-resource-center-icon-button__text"},l("resource_center.back"))):e.createElement("div",{className:P({"userflowjs-resource-center-header-text":!0,"userflowjs-resource-center-header-text--with-icon":!!(Y&&q?.icon)})},Y&&q?.icon&&e.createElement(y,{icon:q.icon,size:16}),bt),e.createElement("div",{className:"flex-1"}),Me.length>0&&e.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:()=>{let d={kind:"search"};if(Me.length===1){const v=Me[0],I=de[v.type];I.routeTo&&(d=I.routeTo({block:v}))}b?.kind==="search"?D(null):(R(c,t,null,"Search icon"),D(d))},"aria-label":"Search"},e.createElement(y,{icon:$r})),e.createElement("button",{className:"userflowjs-resource-center-icon-button userflowjs-resource-center-close-button",onClick:d=>{Be(),d.detail===0&&X(!0)},"aria-label":`Close ${m.headerText}`},e.createElement(y,{icon:zr}))))))),!r&&!n&&p&&A&&A.unreadAnnouncementCount>0&&e.createElement(Xt,{theme:u,count:A.unreadAnnouncementCount,onClick:Et})),!r&&!n&&p&&A?.popoutAnnouncement&&ke(A.popoutAnnouncement,A,t,u),!r&&!n&&p&&A?.boosterAnnouncement&&A.boosterAnnouncement.level===M.MODAL&&ke(A.boosterAnnouncement,A,t,u),!r&&!n&&p&&A?.boosterAnnouncement&&A.boosterAnnouncement.level===M.TOAST&&ke(A.boosterAnnouncement,A,t,u))))},Xt=({theme:t,count:r,onClick:n,style:s})=>{const[o,c]=a.useState(!1);return e.createElement(tt,{className:P({"userflowjs-resource-center-launcher-unread-badge":!0}),noScroll:!0,style:{position:o?void 0:"absolute",visibility:o?void 0:"hidden",...s},stylesheet:et,theme:t,onStylesheetsLoad:c,title:"Resource center unread badge"},e.createElement(Yt,{count:r,onClick:n}))},Yt=({count:t,onClick:r})=>{let n=null;return t>9&&(t=9,n=e.createElement("span",{className:"userflowjs-unread-badge-plus"},"+")),e.createElement("div",{className:P({"userflowjs-unread-badge":!0,"userflowjs-unread-badge--clickable":!!r}),onClick:r},e.createElement("span",null,t),n)},Jt=({session:t,open:r,navigate:n,announcement:s,block:o,rcPlacement:c,onDismiss:l,isStandalonePopout:i})=>{const w=a.useRef(null),m=re(s.theme),u=m.toastPlacement,h=!!o.boosterAnnouncement||i!==void 0&&s?.level===M.TOAST,p=u===c;let E=null,N=null;s&&(E=s.toastAutoDismiss??m.toastAutoDismiss,N=s.toastWidth?s.toastWidth:m.toastWidth);const g=B(),[C,j]=a.useState(!1),{height:_,setEl:k}=Yr();a.useEffect(()=>{const K=w.current;if(!K||E===null)return;const G=Date.now(),me=()=>{const z=1-(Date.now()-G)/(new qt(E||0).toNumber()*1e3);z<=0?(K.style.width="0%",s&&O(g,s)):(K.style.width=`${z*100}%`,requestAnimationFrame(me))};return requestAnimationFrame(me),()=>{K&&(K.style.width="0%")}},[w.current,E,g,s,O]);const T=l||(()=>{s&&O(g,s)}),F=20,_e=a.useMemo(()=>CSS.supports("height: 100dvh")?"dvh":"vh",[]),se=()=>{h&&s&&(O(g,s),R(g,t,o,s.title),n({kind:"announcementShow",block:o,announcementId:s.id}),r())},oe=()=>{s&&(O(g,s),R(g,t,o,s.title),n({kind:"announcementShow",block:o,announcementId:s.id}),r())},$=()=>{n({kind:"announcementShow",block:o,announcementId:s.id}),r()};if(!s)return null;const Le=!!i&&!!c,V=(i!==void 0||!p)&&!!u&&h;return e.createElement("div",{className:P({"userflowjs-resource-center-popout":!h,"userflowjs-resource-center-toast":h,[`userflowjs-resource-center-popout-standalone--${c?.toLowerCase()?.replace(/_/g,"-")}`]:Le,[`userflowjs-resource-center-toast--${u?.toLowerCase()?.replace(/_/g,"-")}`]:V}),style:He(m)},e.createElement(tt,{className:P({"userflowjs-resource-center-popout-frame":!0}),style:{height:`calc(min(${_}px, 100${_e} - 2 * var(--userflow-resource-center-padding-y) - var(--userflow-resource-center-collapsed-height) - ${F}px)`,position:C?void 0:"absolute",visibility:C?void 0:"hidden",...N&&h?{width:N}:{}},stylesheet:et,theme:m,onStylesheetsLoad:j,title:"Resource center popout"},h&&e.createElement("div",{className:"userflowjs-bubble-progress--default"},e.createElement("div",{className:"userflowjs-bubble-progress__fill",ref:w})),e.createElement("div",{ref:k,className:"userflowjs-resource-center-popout-frame-root",style:{cursor:h?"pointer":"auto",padding:h&&m.toastPadding||void 0}},e.createElement("div",{onClick:se},e.createElement("h2",{className:"userflowjs-announcement-title"},e.createElement("span",{className:"userflowjs-unread-dot"}),e.createElement("span",null,s.title)),e.createElement("div",{className:"userflowjs-announcement-time"},e.createElement("div",{className:"userflowjs-announcement-time-text"},Re(s.time))),e.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},e.createElement(W,{doc:s.content,buttons:s.buttons,lookupAttribute:L(s.data)})),!h&&e.createElement(ue,{announcement:s,onMoreClick:oe,confettiColors:m.confettiColors,onSubmitSuccess:$},e.createElement("div",{className:"userflowjs-announcement-more"},e.createElement("button",{className:"userflowjs-tertiary-button",onClick:oe},e.createElement("div",null,s.moreButtonText||"Read more"),e.createElement("span",{className:"userflowjs-rtl-mirrored userflowjs-tertiary-button__icon"},e.createElement(y,{icon:Kt})))))),h&&e.createElement(e.Fragment,null,!s.reactionEnabled&&s.moreEnabled&&e.createElement("div",{onClick:se,className:"userflowjs-announcement-more--toast"},s.moreButtonText||"Read more"),e.createElement(ue,{announcement:s,onMoreClick:se,confettiColors:m.confettiColors,onSubmitSuccess:$})),e.createElement("div",{className:"userflowjs-bubble-toolbar"},e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:T,"aria-label":"Dismiss announcement"},e.createElement(y,{icon:rt}))))),!h&&!i&&e.createElement("div",{className:"userflowjs-resource-center-popout-notch"}))},er=({session:t,open:r,navigate:n,announcement:s,block:o,onDismiss:c})=>{const l=B(),i=re(s.theme),m=c||(()=>{O(l,s)}),u=()=>{O(l,s),R(l,t,o,s.title),n({kind:"announcementShow",block:o,announcementId:s.id}),r()},h=()=>{n({kind:"announcementShow",block:o,announcementId:s.id}),r()};return e.createElement(Zr,{company:t.flow.company,theme:i,position:"fixed",width:s.modalWidth,stepAppearance:jr.MODAL,zIndex:i.checklistZIndex,autoHide3pEnabled:!0,onModalBackdropClick:m,noIframe:!0,isModalAnnouncement:!0},e.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},e.createElement("h1",null,s.title),e.createElement(W,{doc:s.content,buttons:s.buttons,lookupAttribute:L(s.data)}),e.createElement(ue,{announcement:s,onMoreClick:u,confettiColors:i.confettiColors,onSubmitSuccess:h},e.createElement("div",{className:"userflowjs-announcement-more--modal"},e.createElement("button",{className:"userflowjs-bubble-button--primary",onClick:u},s.moreButtonText||"Read more")))),e.createElement("div",{className:"userflowjs-bubble-toolbar"},e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:m,"aria-label":"Dismiss announcement"},e.createElement(y,{icon:rt}))))};function tr(t){return t.filter(r=>{const n=de[r.type];return n.isSearchable?n.isSearchable(r):!!n.search})}const de={[S.ACTION]:{View:t=>{const{block:r,session:n,flowSession:s,checklistSession:o}=t,c=B(),[l,i]=a.useState(!1),w=s?.id,m=o?.id;return a.useEffect(()=>{i(!1)},[w,m]),e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:l?void 0:()=>{R(c,n,r);const u=r.actions.find(h=>h.type===Tr.START_FLOW);u?u.otherFlow?.id!==o?.flow.id&&i(!0):c.closeResourceCenter(),Mr(c,n,r.actions)},disabled:l},e.createElement(ee,{...t}),e.createElement(Z,{...t}),l&&e.createElement(U,null))}},[S.ANNOUNCEMENTS]:{View:t=>{const{block:r,session:n,navigate:s}=t,o=B();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c=>{R(o,n,r),s({kind:"announcementList",block:r},c)}},r.unreadAnnouncementCount>0?e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(Yt,{count:r.unreadAnnouncementCount})):e.createElement(ee,{...t}),e.createElement(Z,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te})))}},[S.ASSISTANT]:{View:t=>{const{block:r,session:n,navigate:s}=t,o=B(),[c,l]=a.useState("");return r.assistantAppearance===Ir.INPUT?e.createElement("div",{className:"userflowjs-resource-center-assistant-block"},e.createElement(fn,{value:c,onChange:l,placeholder:Te(r.name,{lookupAttribute:L(n.data)}),onSubmit:()=>{R(o,n,r),s({kind:"assistant",block:r,initialUserContent:c})}})):e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{R(o,n,r),s({kind:"assistant",block:r,initialUserContent:""})}},e.createElement(ee,{...t}),e.createElement(Z,{...t}))}},[S.CHECKLIST]:{View:({checklistSession:t})=>e.createElement("div",{"data-testid":"resource-center-checklist",className:"userflowjs-resource-center-checklist"},e.createElement(Or,{session:t}),e.createElement(Gr,{draftMode:t.draftMode?"CHECKLIST PREVIEW":!1}))},[S.CONTACT]:{View:t=>{const{block:r,session:n,navigate:s,onChatShow:o}=t,c=B(),l=[];return r.emailEnabled&&l.push({icon:Kr,label:"Email",isRoute:!0,onClick:i=>{R(c,n,r,"Email"),s({kind:"email",block:r},i)}}),r.phoneEnabled&&l.push({icon:Qr,label:"Phone",isRoute:!0,onClick:i=>{R(c,n,r,"Phone"),s({kind:"phone",block:r},i)}}),r.chatEnabled&&l.push({icon:qr,label:"Live-chat",isRoute:!1,onClick:()=>{R(c,n,r,"Chat"),cr(n,r,o)}}),e.createElement("div",{className:P({"userflowjs-resource-center-block":!0,"userflowjs-resource-center-block--clickable":l.length===1}),onClick:l.length===1?l[0].onClick:void 0},l.length===1&&e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(y,{icon:l[0].icon})),e.createElement(Z,{...t}),l.length>1&&l.map(({icon:i,label:w,onClick:m},u)=>e.createElement("button",{key:u,className:"userflowjs-resource-center-icon-button",onClick:m,"aria-label":w},e.createElement(y,{icon:i}))),l.length===1&&l[0].isRoute&&e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te})))}},[S.DIVIDER]:{View:()=>e.createElement("div",{className:"userflowjs-resource-center-divider"})},[S.FLOWS]:{View:t=>{const{block:r,session:n,navigate:s}=t,o=B();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c=>{R(o,n,r),s({kind:"flows",block:r},c)}},e.createElement(ee,{...t}),e.createElement(Z,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te})))},routeTo:({block:t,initialQ:r})=>({kind:"flows",block:t,initialQ:r}),isSearchable:t=>!!t.searchEnabled,search:async({client:t,session:r,block:n,q:s})=>{const{flows:o}=await t.send({kind:"ListResourceCenterBlockFlows",sessionId:r.id,blockCvid:n.cvid},{handlesRejection:!0}),c=rr(o,s),l=c.slice(0,Ht);return{block:n,truncated:l.length===c.length,results:l.map(i=>({kind:"flow",flow:i}))}}},[S.KNOWLEDGE_BASE]:{View:t=>{const{block:r,session:n,navigate:s}=t,o=B();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c=>{R(o,n,r),s({kind:"knowledgeBase",block:r},c)}},e.createElement(ee,{...t}),e.createElement(Z,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te})))},routeTo:({block:t,initialQ:r})=>({kind:"knowledgeBase",block:t,initialQ:r}),search:async({client:t,session:r,block:n,q:s})=>{const{truncated:o,articles:c}=await t.send({kind:"SearchKnowledgeBase",sessionId:r.id,blockCvid:n.cvid,q:s,offset:0,limit:Ht},{handlesRejection:!0});return{block:n,truncated:o,results:c.map(l=>({kind:"article",article:l}))}}},[S.MESSAGE]:{View:({block:t,session:r})=>e.createElement("div",{className:"userflowjs-resource-center-block"},e.createElement("div",{className:"userflowjs-resource-center-block-text userflowjs-bubble-content"},e.createElement(W,{doc:t.content,lookupAttribute:L(r.data)})))},[S.SUBPAGE]:{View:t=>{const{block:r,session:n,navigate:s}=t,o=B();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c=>{R(o,n,r),s({kind:"subpage",block:r},c)}},e.createElement(ee,{...t}),e.createElement(Z,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te})))}}},ee=({block:t})=>t.icon?e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(y,{icon:t.icon,size:16})):null,Z=({block:t,session:r})=>e.createElement("div",{className:"userflowjs-resource-center-block-text"},e.createElement(ie,{doc:t.name,lookupAttribute:L(r.data)})),En=({session:t,navigate:r})=>{const n=B(),s=t.version.resourceCenter.blocks,o=tr(s),{t:c}=ne(),l=a.useRef(null),[i,w]=a.useState(""),[m,u]=ot(i,w),[h,p]=a.useState(null);return a.useEffect(()=>{if(i.trim()===""){p(null);return}let E=!1;return(async()=>{p(null);const g=await Promise.all(s.map(async C=>{const{search:j}=de[C.type];if(!j)return null;try{return await j({client:n,session:t,block:C,q:i})}catch(_){return console.error(`Userflow.js: Global search failed for ${C.type} block=`,C,"error=",_),null}}));E||p(g.filter(C=>C!=null&&C.results.length>0))})(),()=>{E=!0}},[n,t,s,i]),a.useEffect(()=>{l.current?.focus({preventScroll:!0})},[]),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:l,className:"userflowjs-text-input",type:"text",value:m,onChange:E=>u(E.target.value),placeholder:c("resource_center.search_placeholder")})),i.trim()===""?e.createElement("div",{"data-testid":"resource-center-empty-query",className:"userflowjs-resource-center-list-route-error"},c("resource_center.search_in")," ",o.map((E,N)=>e.createElement(e.Fragment,{key:E.cvid},N>0&&(N===o.length-1?` ${c("and")} `:", "),e.createElement("b",null,e.createElement(ie,{doc:E.name,lookupAttribute:L(t.data)})))),"."):h?h.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.no_results_found")):h.map(({block:E,truncated:N,results:g},C)=>{const j=de[E.type],_=j.routeTo&&j.routeTo({block:E,initialQ:i});return e.createElement(e.Fragment,{key:E.cvid},C>0&&e.createElement("div",{className:"userflowjs-resource-center-divider"}),e.createElement("div",{className:"userflowjs-resource-center-label"},e.createElement(ie,{doc:E.name,lookupAttribute:L(t.data)})),g.map((k,T)=>k.kind==="flow"?e.createElement(nr,{key:k.flow.id,block:E,session:t,flow:k.flow,navigate:r}):k.kind==="article"?e.createElement(sr,{key:T,block:E,session:t,article:k.article}):null),!N&&_&&e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:k=>{R(n,t,E),r(_,k)}},e.createElement("div",{className:"userflowjs-resource-center-block-text"},c("more"),":"," ",e.createElement(ie,{doc:E.name,lookupAttribute:L(t.data)})),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(y,{icon:te}))))}):e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null)))},pn=({block:t,session:r})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement(W,{doc:t.emailContent,lookupAttribute:L(r.data)})),bn=({block:t,session:r})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement(W,{doc:t.phoneContent,lookupAttribute:L(r.data)})),vn=({block:t,initialQ:r,session:n,navigate:s,title:o})=>{const{t:c}=ne(),l=a.useRef(null),[i,w]=a.useState(r||""),[m,u]=ot(i,w),{data:h,error:p}=Qt({message:{kind:"ListResourceCenterBlockFlows",sessionId:n.id,blockCvid:t.cvid}}),E=h?.flows,N=a.useMemo(()=>E?rr(E,i):null,[E,i]);return a.useEffect(()=>{l.current?.focus({preventScroll:!0})},[]),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},o),t.searchEnabled&&e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:l,className:"userflowjs-text-input",type:"text",value:m,onChange:g=>u(g.target.value),placeholder:c("resource_center.search_placeholder")})),p?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.generic_error")):N?N.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.no_results_found")):N.map(g=>e.createElement(nr,{key:g.id,block:t,session:n,flow:g,navigate:s})):e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,{fadeIn:!0})))};function rr(t,r){const n=r.toLowerCase().trim();return n===""?t:t.filter(s=>s.name.toLowerCase().includes(n))}const nr=({block:t,session:r,flow:n,navigate:s})=>{const o=B(),[c,l]=a.useState(!1);return a.useEffect(()=>{if(!c||n.type!==Nt.CHECKLIST)return;const i=()=>{o.checklistSession?.flow.id===n.id&&(w(),s(null))},w=()=>{o.off("checklistChanged",i)};return o.on("checklistChanged",i),w},[o,c,n.type,n.id,s]),e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{if(R(o,r,t,n.name),o.checklistSession?.flow.id===n.id){s(null);return}o.startFlow({flowId:n.id,startReason:r.draftMode?jt.DRAFT:jt.RESOURCE_CENTER,replaceCurrent:!0}),l(!0);const i=Te(n.url,{lookupAttribute:L(r.data)});i&&Dr(i)},disabled:c},n.iconSetting!==Rr.HIDE&&e.createElement("div",{className:"userflowjs-resource-center-block-icon"},n.icon?e.createElement(y,{icon:n.icon,size:16}):e.createElement(y,{icon:n.type===Nt.CHECKLIST?"regular/tasks":"regular/shoe-prints",size:16})),r.draftMode&&!n.published&&e.createElement("div",{className:"userflowjs-resource-center-code-block"},e.createElement("div",{title:"Unpublished. Preview only"},e.createElement("code",null,"P"))),e.createElement("div",{className:"userflowjs-resource-center-block-text"},n.name),c&&e.createElement(U,null))},gn=({block:t,initialQ:r,session:n,bodyRef:s,title:o})=>{const{t:c}=ne(),l=a.useRef(null),[i,w]=a.useState(r||""),[m,u]=ot(i,w),{loading:h,loadingMore:p,data:E,messageForData:N,error:g,loadMore:C}=Qt({message:{kind:"SearchKnowledgeBase",sessionId:n.id,blockCvid:t.cvid,q:i,offset:0}}),j=E?.truncated,_=a.useCallback(()=>{C((T,F)=>({...F,offset:T.articles.length}),(T,F)=>({...F,articles:[...T.articles,...F.articles]}))},[C]);or({bodyRef:s,loading:h,loadingMore:p,truncated:j,loadMoreHelper:_}),a.useEffect(()=>{l.current?.focus({preventScroll:!0})},[]);let k=t.knowledgeBaseUrl||"";return k.match(/^https?:\/\//)||(k=`http://${k}`),k=Gt(k),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},o,e.createElement("a",{className:"userflowjs-resource-center-icon-button",href:k,target:"_blank",rel:"noopener noreferrer"},e.createElement(y,{icon:Vr}))),e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:l,className:"userflowjs-text-input",type:"text",value:m,onChange:T=>u(T.target.value),placeholder:c("resource_center.search_placeholder")})),g?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},g.code==="quota_exceeded"?"Sorry, this company has reached its max number of searches. Consider asking Userflow to be moved to a dedicated search engine for a higher quota.":g.humanMessage||c("resource_center.generic_error")):h||!E?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null)):E.articles.length===0?N?.q===""?null:e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.no_results_found")):e.createElement(e.Fragment,null,N?.q===""&&e.createElement("div",{className:"userflowjs-resource-center-label"},c("resource_center.suggested_articles")),E.articles.map((T,F)=>e.createElement(sr,{key:F,block:t,session:n,article:T})),p&&e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null))))},sr=({block:t,article:r,session:n})=>{const s=B();return e.createElement("a",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{R(s,n,t,r.title)},href:Gt(r.url),target:"_blank",rel:"noopener noreferrer"},e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(y,{icon:"regular/file-alt",size:16})),e.createElement("div",{className:"userflowjs-resource-center-block-text"},e.createElement("span",{dangerouslySetInnerHTML:{__html:r.htmlTitle}}),e.createElement("div",{className:"userflowjs-resource-center-block-subtext",dangerouslySetInnerHTML:{__html:r.htmlSnippet}})))},Cn=({block:t,session:r})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement(W,{doc:t.content,lookupAttribute:L(r.data)})),kn=({bodyRef:t,session:r,route:n,navigate:s,title:o})=>{const c=B(),[l,i]=a.useState(void 0);return a.useLayoutEffect(()=>{t.current&&l!=null&&n?.kind==="announcementList"&&(t.current.scrollTop=l)},[t,l,n?.kind]),!n||n?.kind!=="announcementList"&&n?.kind!=="announcementShow"?null:e.createElement(Xr,null,n.kind==="announcementList"&&e.createElement(Sn,{bodyRef:t,session:r,block:n.block,onMoreClick:w=>{i(t.current?.scrollTop),R(c,r,n.block,w.title),s({kind:"announcementShow",block:n.block,announcementId:w.id})},title:o}),n.kind==="announcementShow"&&e.createElement(Nn,{announcementId:n.announcementId}))},Sn=({bodyRef:t,block:r,session:n,onMoreClick:s,title:o})=>{const{t:c}=ne(),{announcements:l,error:i,loading:w,loadingMore:m,truncated:u,pageSize:h,loadMore:p}=nt(),[E,N]=a.useMemo(()=>{const C=[],j=[];if(l){let _=-1;for(const k of l)_++,_<h&&!k.seen&&k.level!==M.SILENT?C.push(k):j.push(k)}return[C,j]},[l,h]),g=E.length;return or({bodyRef:t,loading:w,loadingMore:m,truncated:u,loadMoreHelper:p}),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},o),i?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.generic_error")):w?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null)):l.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},Ie.exists("resource_center.no_announcements",{fallbackLng:[]})?c("resource_center.no_announcements"):c("resource_center.no_results_found")):e.createElement(e.Fragment,null,g>0&&e.createElement("div",{className:"userflowjs-announcement-unread-header"},c("resource_center.unread",{count:g})),E.map(C=>e.createElement(zt,{key:C.id,bodyRef:t,announcement:C,onMoreClick:()=>s(C)})),N.map(C=>e.createElement(zt,{key:C.id,bodyRef:t,announcement:C,onMoreClick:()=>s(C)})),m&&e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null))))},$t=new Set;function O(t,r){r.seen||$t.has(r.id)||($t.add(r.id),ct(t,r))}const zt=({bodyRef:t,onMoreClick:r,announcement:n})=>{const s=B(),o=Vt(),c=re(o.version.theme),l=a.useRef(null),{submitReaction:i,submitComment:w}=nt(),m=a.useRef(!1);return a.useEffect(()=>{if(m.current||n.seen)return;const u=new IntersectionObserver(p=>{const E=p[0];E&&E.isIntersecting&&(O(s,n),m.current=!0,h())},{root:t.current,threshold:1}),h=()=>{u.disconnect()};return u.observe(l.current),h},[t,s,n]),e.createElement("div",{className:"userflowjs-announcement-list-item"},e.createElement("div",{className:"userflowjs-announcement-time-divider"},e.createElement("div",{className:"userflowjs-announcement-time-divider-line"}),e.createElement("div",{className:"userflowjs-announcement-time-text"},Re(n.time)),e.createElement("div",{className:"userflowjs-announcement-time-divider-line"})),e.createElement("h2",{ref:l,className:"userflowjs-announcement-title"},!n.seen&&n.level!==M.SILENT&&e.createElement("span",{className:"userflowjs-unread-dot"}),e.createElement("span",null,n.title)),e.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},e.createElement(le.Provider,{value:{...o,data:n.data}},e.createElement(W,{doc:n.content,buttons:n.buttons,lookupAttribute:L(n.data)}))),e.createElement(ue,{announcement:n,onMoreClick:r,confettiColors:c.confettiColors,onReactionChange:i,onCommentSubmit:w},e.createElement("div",{className:"userflowjs-announcement-more"},e.createElement("button",{className:"userflowjs-tertiary-button",onClick:r},e.createElement("div",null,n.moreButtonText||"Read more"),e.createElement("span",{className:"userflowjs-rtl-mirrored"},e.createElement(y,{icon:Kt}))))))},Nn=({announcementId:t})=>{const r=B(),n=Vt(),s=re(n.version.theme),[o,c]=a.useState(null),{fetchAnnouncement:l,loading:i,error:w,submitComment:m,submitReaction:u}=nt(),{t:h}=ne();return a.useEffect(()=>{l(t).then(c)},[t]),a.useEffect(()=>{!o||o.seen||O(r,o)},[r,o]),i?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null)):e.createElement(e.Fragment,null,w?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},w.humanMessage||h("resource_center.generic_error")):i||!o?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(U,null)):e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-announcement-show"},e.createElement("h2",{className:"userflowjs-announcement-title"},o.title),e.createElement("div",{className:"userflowjs-announcement-time"},e.createElement("div",{className:"userflowjs-announcement-time-text"},Re(o.time))),e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement(le.Provider,{value:{...n,data:o.data}},e.createElement(W,{doc:o.content,buttons:o.buttons,lookupAttribute:L(o.data)}),o.moreEnabled&&e.createElement(W,{doc:o.moreContent,buttons:o.moreButtons,lookupAttribute:L(o.data)}))),e.createElement(ue,{announcement:o,confettiColors:s.confettiColors,showMoreButton:!1,onCommentSubmit:m,onReactionChange:u}))))},jn=({block:t,initialUserContent:r,session:n,navigate:s,onChatShow:o,onHandoverChatShow:c,chatBlock:l})=>{const i=t.assistantFlowId,w=B(),[m,u]=a.useState(null),[h,p]=a.useState(null),[E,N]=a.useState(null),[g]=a.useState(r);a.useEffect(()=>{r&&s({kind:"assistant",block:t,initialUserContent:""})},[r,t,s]),a.useEffect(()=>{let j=!1;return(async()=>{try{const k=ae.getItem("assistantConversationId:"+i),[T,F]=await Promise.all([wn(),w.send({kind:"GetAssistant",assistantFlowId:i,conversationId:k},{handlesRejection:!0,endBatch:!0})]);if(j)return;u(()=>T),p(F)}catch(k){console.error("Resource center assistant route failed to load:",k),N(k.humanMessage||"Sorry, something went wrong. Please try again or contact my human friends.")}})(),()=>{j=!0}},[w,i]);const C=a.useMemo(()=>{if(!t.assistantContactEnabled)return;const j=n.version.resourceCenter?.blocks.find(_=>_.type===S.CONTACT);if(j)return()=>{switch(R(w,n,t,t.assistantContactButtonText||void 0),t.assistantContactMethod){case St.EMAIL:s({kind:"email",block:j});break;case St.PHONE:s({kind:"phone",block:j});break;default:s(null),cr(n,j,o);break}}},[w,n,t,o,s]);return E?e.createElement("div",{className:"userflowjs-assistant-chat"},e.createElement("div",{className:"userflowjs-assistant-chat__content"},e.createElement("div",{className:"userflowjs-assistant-chat__error"},E))):!m||!h?e.createElement(U,{center:!0,fadeIn:!0}):e.createElement(m,{block:t,session:n,assistantReply:h,initialUserContent:g,onContactClick:C,contactButtonText:t.assistantContactButtonText||void 0,onHandoverChatShow:c,chatBlock:l})};function R(t,r,n,s){t.send({kind:"ClickResourceCenter",sessionId:r.id,description:n?Te(n.name,{lookupAttribute:L(r.data)})+(s?` - ${s}`:""):s},{batch:!0})}function or({bodyRef:t,loading:r,loadingMore:n,truncated:s,loadMoreHelper:o}){a.useEffect(()=>{const c=t.current;if(!c||r||n||s)return;const l=()=>{c.scrollHeight-c.clientHeight-c.scrollTop>400||o()};return c.addEventListener("scroll",l),()=>{c.removeEventListener("scroll",l)}},[t,r,n,s,o])}function cr(t,r,n){if(r.chatProvider){const s=ye[r.chatProvider];try{s.show({block:r})}catch(o){console.error(`Userflow.js: Error when showing ${r.chatProvider}:`,o)}n()}else t.draftMode&&window.alert("You have not selected a chat provider. Go to the resource center builder in Userflow. Click the Contact block. Pick a chat provider in the side panel.")}function ct(t,r){t.setResourceCenterSession(n=>n?{...n,version:{...n.version,resourceCenter:{...n.version.resourceCenter,blocks:n.version.resourceCenter.blocks.map(s=>s.type===S.ANNOUNCEMENTS?{...s,unreadAnnouncementCount:r.level===M.SILENT?s.unreadAnnouncementCount:s.unreadAnnouncementCount-1,popoutAnnouncement:s.popoutAnnouncement?.id===r.id?null:s.popoutAnnouncement,boosterAnnouncement:s.boosterAnnouncement?.id===r.id?null:s.boosterAnnouncement}:s)}}}:null),t.send({kind:"MarkAnnouncementSeen",announcementId:r.id,versionId:r.versionId}),t.toggleUI()}function ar(t){return t?.version.resourceCenter?.blocks.find(r=>r.type===S.ANNOUNCEMENTS)||null}function Re(t){const r=t?new Date(t):new Date;let n=new Intl.DateTimeFormat(Ie.language,{weekday:"long",day:"numeric",month:"short",year:r.getFullYear()===new Date().getFullYear()?void 0:"numeric"}).format(r);return n.substring(0,1).toUpperCase()+n.substring(1)}const Zn=Object.freeze(Object.defineProperty({__proto__:null,FloatingAnnouncements:Jt,LauncherUnreadBadge:Xt,ModalAnnouncement:er,ResourceCenterApp:Wt,default:Wt,formatAnnouncementTime:Re,getAnnouncementsBlock:ar,markAnnouncementSeen:O,syncAnnouncementSeen:ct},Symbol.toStringTag,{value:"Module"}));export{fn as A,mn as G,Xt as L,Zn as R,ye as c,Gt as d,Re as f,O as m,ct as s};
5
5
  //# sourceMappingURL=ResourceCenterApp.js.map
@@ -1,2 +1,2 @@
1
- import{r as E,R as e}from"./vendor.react.js";import{R,K as C,p as N,M as g}from"./userflow.js";import{u as h}from"./client-context.js";import{u as S}from"./use-selector-element-monitoring.js";import{a as w,D as k}from"./stylesheets.js";import{L as I,m as b,f as M}from"./ResourceCenterApp.js";import{s as L}from"./resource-center-route.js";import{S as x,R as j}from"./TreeDoc.js";import{g as D}from"./flow-condition-types.js";import{a0 as P}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{F as O,B as U}from"./FlowChrome.js";import{a as B}from"./AnnouncementEngagement.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./roots.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./flow-host.styl.js";import"./Frame.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.obj-str.js";import"./iframe-reset.styl.js";import"./use-window-resize.js";import"./logomark.js";import"./ChecklistUI.js";import"./vendor.memoize-one.js";import"./vendor.bignumber.js.js";import"./use-element-rect.js";import"./vendor.date-fns.js";import"./use-confetti.js";import"./vendor.canvas-confetti.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[t]="08a713fd-79c7-4180-a03e-06d306009341",o._sentryDebugIdIdentifier="sentry-dbid-08a713fd-79c7-4180-a03e-06d306009341")}catch{}})();const Te=({session:o,isOpen:t,flowSession:s,resourceCenterLauncherHidden:u})=>{const l=h(),n=o.version.resourceCenter,i=w(o.version.theme),[r,m]=E.useState(null),c=()=>{l.toggleResourceCenter()},v=f=>{m(f)},T=()=>{m(null)},p=n.launcherType===R.CUSTOM&&u!==!0;S({selector:p?n.launcherTargetSelector:null,targetMoved:v,targetLost:T,onTargetClick:c});const a=E.useMemo(()=>n.blocks.find(f=>f.type===C.ANNOUNCEMENTS),[n]),y=p&&!t&&!s&&a&&a.unreadAnnouncementCount>0&&r,d=E.useMemo(()=>a?.popoutAnnouncement,[a]),A=p&&!t&&!s&&d&&r;return e.createElement(x.Provider,{value:o},y&&e.createElement(I,{theme:i,count:a.unreadAnnouncementCount,onClick:c,style:{position:"fixed",top:`${r.targetRect.top}px`,left:`${r.targetRect.left}px`,transform:"translate(-50%, -50%)",zIndex:999999}}),A&&a&&e.createElement($,{session:o,announcement:d,targetParams:r,onDismiss:()=>{b(l,d)},onOpen:c}))},_=320,$=({session:o,announcement:t,targetParams:s,onOpen:u})=>{const l=h(),n=w(t.theme),i=()=>{b(l,t)},r=()=>{i(),u();const m=L({kind:"announcementShow",block:o.version.resourceCenter.blocks.find(c=>c.type===C.ANNOUNCEMENTS),announcementId:t.id});m?g.setItem(`resourceCenterRoute:v1:${o.id}`,m):g.removeItem(`resourceCenterRoute:v1:${o.id}`)};return e.createElement(O,{company:o.flow.company,theme:n,position:"fixed",stepAppearance:N.TOOLTIP,width:_,tooltipSelector:s.targetEl,tooltipPlacement:null,isModalAnnouncement:!0},e.createElement(U,{close:i}),e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("div",null,e.createElement("h2",{className:"userflowjs-announcement-title"},e.createElement("span",{className:"userflowjs-unread-dot"}),e.createElement("span",null,t.title)),e.createElement("div",{className:"userflowjs-announcement-time"},e.createElement("div",{className:"userflowjs-announcement-time-text"},M(t.time))),e.createElement("div",{className:"userflowjs-announcement-content"},e.createElement(j,{doc:t.content,buttons:t.buttons,lookupAttribute:D(t.data)})),e.createElement(B,{announcement:t,onMoreClick:r},e.createElement("div",{className:"userflowjs-announcement-more"},e.createElement("button",{className:"userflowjs-tertiary-button",onClick:r},e.createElement("div",null,t.moreButtonText||"Read more"),e.createElement("span",{className:"userflowjs-rtl-mirrored"},e.createElement(k,{icon:P}))))))))};export{Te as ResourceCenterLauncherHandler,Te as default};
1
+ import{r as E,R as e}from"./vendor.react.js";import{R,K as b,p as N,M as g}from"./userflow.js";import{u as C}from"./client-context.js";import{u as S}from"./use-selector-element-monitoring.js";import{a as h,D as k}from"./stylesheets.js";import{L as I,m as w,s as M,f as L}from"./ResourceCenterApp.js";import{s as x}from"./resource-center-route.js";import{S as j,R as D}from"./TreeDoc.js";import{g as P}from"./flow-condition-types.js";import{a0 as O}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{F as U,B}from"./FlowChrome.js";import{a as _}from"./AnnouncementEngagement.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./roots.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./flow-host.styl.js";import"./Frame.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./iframe-reset.styl.js";import"./vendor.obj-str.js";import"./use-window-resize.js";import"./logomark.js";import"./ChecklistUI.js";import"./vendor.memoize-one.js";import"./vendor.bignumber.js.js";import"./use-element-rect.js";import"./vendor.date-fns.js";import"./use-confetti.js";import"./vendor.canvas-confetti.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[t]="b758182c-b997-4470-8eac-20a9b9617d62",o._sentryDebugIdIdentifier="sentry-dbid-b758182c-b997-4470-8eac-20a9b9617d62")}catch{}})();const Te=({session:o,isOpen:t,flowSession:s,resourceCenterLauncherHidden:i})=>{const m=C(),n=o.version.resourceCenter,c=h(o.version.theme),[r,l]=E.useState(null),u=()=>{m.toggleResourceCenter()},v=f=>{l(f)},y=()=>{l(null)},p=n.launcherType===R.CUSTOM&&i!==!0;S({selector:p?n.launcherTargetSelector:null,targetMoved:v,targetLost:y,onTargetClick:u});const a=E.useMemo(()=>n.blocks.find(f=>f.type===b.ANNOUNCEMENTS),[n]),T=p&&!t&&!s&&a&&a.unreadAnnouncementCount>0&&r,d=E.useMemo(()=>a?.popoutAnnouncement,[a]),A=p&&!t&&!s&&d&&r;return e.createElement(j.Provider,{value:o},T&&e.createElement(I,{theme:c,count:a.unreadAnnouncementCount,onClick:u,style:{position:"fixed",top:`${r.targetRect.top}px`,left:`${r.targetRect.left}px`,transform:"translate(-50%, -50%)",zIndex:999999}}),A&&a&&e.createElement(z,{session:o,announcement:d,targetParams:r,onDismiss:()=>{w(m,d)},onOpen:u}))},$=320,z=({session:o,announcement:t,targetParams:s,onOpen:i})=>{const m=C(),n=h(t.theme),c=()=>{w(m,t),i();const r=x({kind:"announcementShow",block:o.version.resourceCenter.blocks.find(l=>l.type===b.ANNOUNCEMENTS),announcementId:t.id});r?g.setItem(`resourceCenterRoute:v1:${o.id}`,r):g.removeItem(`resourceCenterRoute:v1:${o.id}`)};return e.createElement(U,{company:o.flow.company,theme:n,position:"fixed",stepAppearance:N.TOOLTIP,width:$,tooltipSelector:s.targetEl,tooltipPlacement:null,isModalAnnouncement:!0},e.createElement(B,{close:()=>M(m,t)}),e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("div",null,e.createElement("h2",{className:"userflowjs-announcement-title"},e.createElement("span",{className:"userflowjs-unread-dot"}),e.createElement("span",null,t.title)),e.createElement("div",{className:"userflowjs-announcement-time"},e.createElement("div",{className:"userflowjs-announcement-time-text"},L(t.time))),e.createElement("div",{className:"userflowjs-announcement-content"},e.createElement(D,{doc:t.content,buttons:t.buttons,lookupAttribute:P(t.data)})),e.createElement(_,{announcement:t,onMoreClick:c},e.createElement("div",{className:"userflowjs-announcement-more"},e.createElement("button",{className:"userflowjs-tertiary-button",onClick:c},e.createElement("div",null,t.moreButtonText||"Read more"),e.createElement("span",{className:"userflowjs-rtl-mirrored"},e.createElement(k,{icon:O}))))))))};export{Te as ResourceCenterLauncherHandler,Te as default};
2
2
  //# sourceMappingURL=ResourceCenterLauncherHandler.js.map
@@ -1,2 +1,2 @@
1
- import{r,R as t}from"./vendor.react.js";import{u as g}from"./client-context.js";import{B as b}from"./BuilderBar.js";import{a6 as w}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{D as E}from"./stylesheets.js";import{P as y}from"./Popover.js";import"./vendor.object-assign.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./Frame.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.obj-str.js";import"./iframe-reset.styl.js";import"./logomark.js";import"./vendor.fortawesome.pro-light-svg-icons.js";import"./userflow.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./use-window-resize.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./flow-condition-types.js";import"./vendor.date-fns.js";import"./roots.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="52bfd343-b41c-48a0-a602-74891fe3e57d",i._sentryDebugIdIdentifier="sentry-dbid-52bfd343-b41c-48a0-a602-74891fe3e57d")}catch{}})();const v=250,C=250;let I=0;class T{constructor(){this.currentId=null,this.subscribers=new Set}showDelayed(e){window.clearTimeout(this.changeTimeout),this.currentId?this.updateCurrentId(e):this.changeTimeout=window.setTimeout(()=>{this.updateCurrentId(e)},v)}hideDelayed(e){window.clearTimeout(this.changeTimeout),e===this.currentId&&(this.changeTimeout=window.setTimeout(()=>{this.updateCurrentId(null)},C))}hide(e){window.clearTimeout(this.changeTimeout),e===this.currentId&&this.updateCurrentId(null)}updateCurrentId(e){this.currentId=e,this.subscribers.forEach(n=>n(e))}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}}const S=r.createContext(new T),D=i=>{const e=r.useRef(null),[n]=r.useState(()=>++I),o=r.useContext(S),[m,p]=r.useState(o.currentId);r.useEffect(()=>o.subscribe(p),[o]);const{tip:s,maxWidth:f,children:l,Tag:a,placement:h="top",...c}=i,u=a||"div";let d=null;return m===n&&e.current&&(d=t.createElement(y,{className:"tooltipped__popover",target:e.current,placement:h,horizontalAlign:"center",verticalAlign:"center",onMouseEnter:()=>o.hide(n),document:e.current.ownerDocument||void 0},t.createElement("div",{style:{maxWidth:f||300}},typeof s=="function"?s():s))),t.createElement(t.Fragment,null,t.createElement(u,{ref:e,...c,onMouseEnter:s?()=>o.showDelayed(n):void 0,onMouseLeave:s?()=>o.hideDelayed(n):void 0,onMouseDown:s?()=>o.hide(n):void 0},l),d)},Z=({token:i})=>{const e=g(),[n,o]=r.useState("notIdentified"),[m,p]=r.useState(null),[s,f]=r.useState(null);let l=r.useRef(!1);r.useEffect(()=>()=>{l.current&&(l.current=!1,e.send({kind:"TestStartConditionCancel"}))},[e]);const a=r.useCallback(()=>{e.setSessionStorageState(c=>({...c,activeApp:null,testStartConditionToken:void 0}))},[e]);r.useEffect(()=>{let c=!1;return e.onceIdentified(async()=>{o("loading"),l.current=!0;let u;try{u=await e.send({kind:"TestStartCondition",token:i},{handlesRejection:!0})}catch(d){if(c)return;o("error"),f(d.humanMessage||"Sorry, something went wrong. Please try again or contact Userflow.");return}c||(p(u),o("loaded"),e.on("private:testStartConditionSuccess",a))}),()=>{c=!0,e.off("private:testStartConditionSuccess",a)}},[e,i,a]);const h=r.useCallback(async()=>{a(),e.getTargetEnv().postBuilderMessage({kind:"userflow:activateBuilder"})},[e,a]);return t.createElement(b,{buttons:t.createElement("button",{className:"btn btn--default",onClick:()=>h()},"Back to Builder")},t.createElement("div",null,t.createElement("div",{className:"label"},"Testing: ",m?.flowName||"..."),n==="notIdentified"?t.createElement("div",null,"Waiting for your app to identify user..."):n==="loading"?t.createElement("div",null,"Loading..."):n==="error"?t.createElement("div",{className:"error"},s):t.createElement("div",{className:"error"},t.createElement("span",{className:"error-text-with-icon"},"Auto-start condition not triggered yet...","",t.createElement(D,{tip:"Auto-start conditions debugging guide",placement:"right"},t.createElement("a",{href:"https://docs.userflow.com/docs/trouble/using-the-debugger",target:"_blank",rel:"noopener noreferrer",className:"error-icon-link"},t.createElement(E,{icon:w,size:12})))))))};export{Z as StartConditionTestingApp,Z as default};
1
+ import{r,R as t}from"./vendor.react.js";import{u as g}from"./client-context.js";import{B as b}from"./BuilderBar.js";import{a6 as w}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{D as E}from"./stylesheets.js";import{P as y}from"./Popover.js";import"./vendor.object-assign.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./Frame.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./iframe-reset.styl.js";import"./logomark.js";import"./vendor.obj-str.js";import"./vendor.fortawesome.pro-light-svg-icons.js";import"./userflow.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./use-window-resize.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./flow-condition-types.js";import"./vendor.date-fns.js";import"./roots.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="245b9ad3-2ed2-48da-8151-3797829b2ad1",i._sentryDebugIdIdentifier="sentry-dbid-245b9ad3-2ed2-48da-8151-3797829b2ad1")}catch{}})();const v=250,C=250;let I=0;class T{constructor(){this.currentId=null,this.subscribers=new Set}showDelayed(e){window.clearTimeout(this.changeTimeout),this.currentId?this.updateCurrentId(e):this.changeTimeout=window.setTimeout(()=>{this.updateCurrentId(e)},v)}hideDelayed(e){window.clearTimeout(this.changeTimeout),e===this.currentId&&(this.changeTimeout=window.setTimeout(()=>{this.updateCurrentId(null)},C))}hide(e){window.clearTimeout(this.changeTimeout),e===this.currentId&&this.updateCurrentId(null)}updateCurrentId(e){this.currentId=e,this.subscribers.forEach(n=>n(e))}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}}const S=r.createContext(new T),D=i=>{const e=r.useRef(null),[n]=r.useState(()=>++I),o=r.useContext(S),[m,p]=r.useState(o.currentId);r.useEffect(()=>o.subscribe(p),[o]);const{tip:s,maxWidth:f,children:d,Tag:a,placement:h="top",...c}=i,l=a||"div";let u=null;return m===n&&e.current&&(u=t.createElement(y,{className:"tooltipped__popover",target:e.current,placement:h,horizontalAlign:"center",verticalAlign:"center",onMouseEnter:()=>o.hide(n),document:e.current.ownerDocument||void 0},t.createElement("div",{style:{maxWidth:f||300}},typeof s=="function"?s():s))),t.createElement(t.Fragment,null,t.createElement(l,{ref:e,...c,onMouseEnter:s?()=>o.showDelayed(n):void 0,onMouseLeave:s?()=>o.hideDelayed(n):void 0,onMouseDown:s?()=>o.hide(n):void 0},d),u)},Z=({token:i})=>{const e=g(),[n,o]=r.useState("notIdentified"),[m,p]=r.useState(null),[s,f]=r.useState(null);let d=r.useRef(!1);r.useEffect(()=>()=>{d.current&&(d.current=!1,e.send({kind:"TestStartConditionCancel"}))},[e]);const a=r.useCallback(()=>{e.setSessionStorageState(c=>({...c,activeApp:null,testStartConditionToken:void 0}))},[e]);r.useEffect(()=>{let c=!1;return e.onceIdentified(async()=>{o("loading"),d.current=!0;let l;try{l=await e.send({kind:"TestStartCondition",token:i},{handlesRejection:!0})}catch(u){if(c)return;o("error"),f(u.humanMessage||"Sorry, something went wrong. Please try again or contact Userflow.");return}c||(p(l),o("loaded"),e.on("private:testStartConditionSuccess",a))}),()=>{c=!0,e.off("private:testStartConditionSuccess",a)}},[e,i,a]);const h=r.useCallback(async()=>{a(),e.getTargetEnv().postBuilderMessage({kind:"userflow:activateBuilder"})},[e,a]);return t.createElement(b,{buttons:t.createElement("button",{className:"btn btn--default",onClick:()=>h()},"Back to Builder")},t.createElement("div",null,t.createElement("div",{className:"label"},"Testing: ",m?.flowName||"..."),n==="notIdentified"?t.createElement("div",null,"Waiting for your app to identify user..."):n==="loading"?t.createElement("div",null,"Loading..."):n==="error"?t.createElement("div",{className:"error"},s):t.createElement("div",{className:"error"},t.createElement("span",{className:"error-text-with-icon"},"Auto-start condition not triggered yet...","",t.createElement(D,{tip:"Auto-start conditions debugging guide",placement:"right"},t.createElement("a",{href:"https://docs.userflow.com/docs/trouble/using-the-debugger",target:"_blank",rel:"noopener noreferrer",className:"error-icon-link"},t.createElement(E,{icon:w,size:12})))))))};export{Z as StartConditionTestingApp,Z as default};
2
2
  //# sourceMappingURL=StartConditionTestingApp.js.map
@@ -1,2 +1,2 @@
1
- import{r as c,R as r}from"./vendor.react.js";import{u as y}from"./client-context.js";import{B as T}from"./BuilderBar.js";import{c as E}from"./flow-condition-types.js";import{S as I}from"./userflow.js";import"./vendor.object-assign.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./Frame.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.obj-str.js";import"./stylesheets.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./iframe-reset.styl.js";import"./logomark.js";import"./vendor.fortawesome.pro-light-svg-icons.js";import"./use-window-resize.js";import"./vendor.date-fns.js";import"./roots.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="1aca3a9e-7116-45c4-a889-3cac3bed41f1",t._sentryDebugIdIdentifier="sentry-dbid-1aca3a9e-7116-45c4-a889-3cac3bed41f1")}catch{}})();const P=({state:t})=>{const e=y(),[a,d]=c.useState("notIdentified");c.useEffect(()=>{let n=!1,i,o;function k(){i=()=>{e.off("private:identified",i),g()},e.isIdentified()?i():e.on("private:identified",i)}const g=async()=>{d("trackerLoading");const{tracker:l}=await e.send({kind:"GetTrackerForTesting",token:t.token});if(n)return;const{condition:f}=l,v=E[f.type];let m=!1;o=v.track({sessionData:new I(l.data),condition:f,flipBackEvents:!0,callback:p=>{const b=m;m=p,!b&&p&&e.setSessionStorageState(s=>({...s,trackerTesting:{...s.trackerTesting,events:s.trackerTesting.events+1}}))}}),d("trackerLoaded")};return k(),()=>{n=!0,i&&e.off("private:identified",i),o&&o()}},[e,t.token]);const u=c.useCallback(async()=>{e.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null})),e.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerClosed"})},[e]);return r.createElement(T,{buttons:r.createElement("button",{className:"btn btn--default",onClick:()=>u()},"Back to Builder")},r.createElement("div",null,r.createElement("div",{className:"label"},"Testing tracker: ",t.trackerName),a==="notIdentified"?r.createElement("div",null,"Waiting for your app to identify user..."):a==="trackerLoading"?r.createElement("div",null,"Loading tracker..."):t.events===0?r.createElement("div",{className:"error"},"Not tracked yet"):r.createElement("div",{className:"success"},"Tracked ",t.events," time",t.events===1?"":"s")))};export{P as TrackerTestingApp,P as default};
1
+ import{r as c,R as r}from"./vendor.react.js";import{u as y}from"./client-context.js";import{B as T}from"./BuilderBar.js";import{c as E}from"./flow-condition-types.js";import{S as I}from"./userflow.js";import"./vendor.object-assign.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./Frame.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./stylesheets.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./iframe-reset.styl.js";import"./logomark.js";import"./vendor.obj-str.js";import"./vendor.fortawesome.pro-light-svg-icons.js";import"./use-window-resize.js";import"./vendor.date-fns.js";import"./roots.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="d1c02668-18c9-4740-a65c-b8d5d8a0e0bd",t._sentryDebugIdIdentifier="sentry-dbid-d1c02668-18c9-4740-a65c-b8d5d8a0e0bd")}catch{}})();const P=({state:t})=>{const e=y(),[o,d]=c.useState("notIdentified");c.useEffect(()=>{let n=!1,i,a;function k(){i=()=>{e.off("private:identified",i),g()},e.isIdentified()?i():e.on("private:identified",i)}const g=async()=>{d("trackerLoading");const{tracker:l}=await e.send({kind:"GetTrackerForTesting",token:t.token});if(n)return;const{condition:f}=l,b=E[f.type];let m=!1;a=b.track({sessionData:new I(l.data),condition:f,flipBackEvents:!0,callback:p=>{const v=m;m=p,!v&&p&&e.setSessionStorageState(s=>({...s,trackerTesting:{...s.trackerTesting,events:s.trackerTesting.events+1}}))}}),d("trackerLoaded")};return k(),()=>{n=!0,i&&e.off("private:identified",i),a&&a()}},[e,t.token]);const u=c.useCallback(async()=>{e.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null})),e.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerClosed"})},[e]);return r.createElement(T,{buttons:r.createElement("button",{className:"btn btn--default",onClick:()=>u()},"Back to Builder")},r.createElement("div",null,r.createElement("div",{className:"label"},"Testing tracker: ",t.trackerName),o==="notIdentified"?r.createElement("div",null,"Waiting for your app to identify user..."):o==="trackerLoading"?r.createElement("div",null,"Loading tracker..."):t.events===0?r.createElement("div",{className:"error"},"Not tracked yet"):r.createElement("div",{className:"success"},"Tracked ",t.events," time",t.events===1?"":"s")))};export{P as TrackerTestingApp,P as default};
2
2
  //# sourceMappingURL=TrackerTestingApp.js.map
package/hash.txt CHANGED
@@ -1 +1 @@
1
- c4486979bb1a37bc8fb77be27685b068d947dfb3
1
+ 8bdac2be23d24021b06f61aa544324288f984740
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1025143",
3
+ "version": "0.1.1025283",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
package/ui.js CHANGED
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ElementSelectionApp.js","vendor.react.js","vendor.object-assign.js","vendor.is-hotkey.js","vendor.obj-str.js","roots.js","userflow.js","vendor.phoenix.js","vendor.uuid.js","client-context.js","vendor.i18next.js","vendor.babel.runtime.js","vendor.react-i18next.js","use-window-resize.js","BuilderBar.js","Frame.js","vendor.react-dom.js","vendor.scheduler.js","stylesheets.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.fortawesome.pro-solid-svg-icons.js","flow-condition-types.js","vendor.date-fns.js","iframe-reset.styl.js","logomark.js","vendor.fortawesome.pro-light-svg-icons.js","SmartFlowRecordingApp.js","FlowApp.js","vendor.lodash.js","FlowChrome.js","flow-host.styl.js","use-selector-element-monitoring.js","use-confetti.js","vendor.canvas-confetti.js","TreeDoc.js","Trigger.js","steps.js","WorkflowApp.js","resource-center-route.js","ChecklistApp.js","ChecklistUI.js","EmbedApp.js","use-element-rect.js","ResourceCenterLauncherHandler.js","ResourceCenterApp.js","AnnouncementEngagement.js","vendor.memoize-one.js","vendor.bignumber.js.js","LauncherApp.js","NotificationsApp.js","TrackerTestingApp.js","StartConditionTestingApp.js","Popover.js"])))=>i.map(i=>d[i]);
2
- import{r as s,R as e}from"./vendor.react.js";import{r as C}from"./vendor.react-dom.js";import{u as N,i as $,U as W}from"./client-context.js";import{R as J,_ as o,I as j,J as q,U as G}from"./userflow.js";import"./vendor.object-assign.js";import{I as K}from"./vendor.react-i18next.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="35de5746-3a44-48ae-a5a8-d7c68fabdc7a",t._sentryDebugIdIdentifier="sentry-dbid-35de5746-3a44-48ae-a5a8-d7c68fabdc7a")}catch{}})();const M=e.lazy(()=>o(()=>import("./ElementSelectionApp.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),Q=e.lazy(()=>o(()=>import("./SmartFlowRecordingApp.js"),__vite__mapDeps([26,1,2,4,9,10,11,12,14,15,16,17,18,19,20,6,7,8,21,22,5,23,24,25,13]))),X=e.lazy(()=>o(()=>import("./FlowApp.js"),__vite__mapDeps([27,1,2,6,7,8,28,12,11,29,19,18,20,21,22,5,9,10,15,16,17,4,23,30,31,13,24,32,33,34,35,36]))),Y=e.lazy(()=>o(()=>import("./WorkflowApp.js"),__vite__mapDeps([37,1,2,6,7,8,36,9,10,11,12,5,34,21,22,18,19,20,4,38,30,29,15,16,17,23,31,13,24,32,33]))),Z=e.lazy(()=>o(()=>import("./ChecklistApp.js"),__vite__mapDeps([39,1,2,6,7,8,29,19,18,20,21,22,11,5,9,10,12,15,16,17,4,23,30,31,13,24,32,33,40,34]))),ee=e.lazy(j),te=e.lazy(()=>o(()=>import("./EmbedApp.js"),__vite__mapDeps([41,1,2,6,7,8,9,10,11,12,4,18,19,20,21,22,5,34,30,31,16,17,15,23,42,13,40]))),ne=e.lazy(q),se=e.lazy(()=>o(()=>import("./ResourceCenterLauncherHandler.js"),__vite__mapDeps([43,1,2,6,7,8,9,10,11,12,31,21,22,5,18,19,20,44,30,34,4,15,16,17,23,13,24,40,29,32,33,45,46,47,42,38]))),oe=e.lazy(()=>o(()=>import("./LauncherApp.js"),__vite__mapDeps([48,1,2,6,7,8,31,21,22,11,5,34,18,19,20,9,10,12,4,30,29,15,16,17,23,13,24,32,33,35]))),re=e.lazy(()=>o(()=>import("./NotificationsApp.js"),__vite__mapDeps([49,1,2,9,10,11,12,30,6,7,8,18,19,20,21,22,5]))),ie=e.lazy(()=>o(()=>import("./TrackerTestingApp.js"),__vite__mapDeps([50,1,2,9,10,11,12,14,15,16,17,4,18,19,20,6,7,8,21,22,5,23,24,25,13]))),ae=e.lazy(()=>o(()=>import("./StartConditionTestingApp.js"),__vite__mapDeps([51,1,2,9,10,11,12,14,15,16,17,4,18,19,20,6,7,8,21,22,5,23,24,25,13,52]))),ce=()=>{const t=N(),[n,p]=s.useState(t.getSessionStorageState()),[a,S]=s.useState(()=>m()?null:t.flowSession),[l,w]=s.useState(t.workflowSession),[i,v]=s.useState(t.checklistSession),[E,A]=s.useState(t.checklistExpanded),[u,g]=s.useState(t.bannerSession),[c,L]=s.useState(t.resourceCenterSession),[f,R]=s.useState(t.resourceCenterOpen),[d,I]=s.useState(t.resourceCenterLauncherHidden),[h,T]=s.useState(t.resourceCenterEmbedsChecklist()),[D,O]=s.useState(t.embedChecklistSessions()),[P,z]=s.useState(t.launcherSessions),[F,V]=s.useState(t.activeLauncherFlowId),[_,x]=s.useState(t.notifications),[U,H]=s.useState(t.embedSessions);s.useEffect(()=>{const r=()=>{p(t.getSessionStorageState()),S(B=>m()&&t.flowSession?.id!==B?.id?null:t.flowSession),v(t.checklistSession),A(t.checklistExpanded),g(t.bannerSession),L(t.resourceCenterSession),R(t.resourceCenterOpen),I(t.resourceCenterLauncherHidden),T(t.resourceCenterEmbedsChecklist()),O(t.embedChecklistSessions()),z(t.launcherSessions),V(t.activeLauncherFlowId),x(t.notifications),H(t.embedSessions),w(t.workflowSession)};t.on("uistatechange",r);const y=()=>{m()||S(t.flowSession)};return document.addEventListener("visibilitychange",y),()=>{t.off("uistatechange",r),document.removeEventListener("visibilitychange",y)}},[t]);const b=!n.activeApp&&!!a,k=c?.version.resourceCenter?.launcherType;return s.useLayoutEffect(()=>{if(b)return t.emit("flowvisibilitychange",!0),()=>{t.emit("flowvisibilitychange",!1)}},[t,b]),n.activeApp==="elementSelection"&&n.elementSelection?e.createElement(e.Suspense,{fallback:null},e.createElement(M,{state:n.elementSelection})):n.activeApp==="trackerTesting"&&n.trackerTesting?e.createElement(e.Suspense,{fallback:null},e.createElement(ie,{state:n.trackerTesting})):n.activeApp==="smartFlowRecording"&&n.smartFlowRecording?e.createElement(e.Suspense,{fallback:null},e.createElement(Q,{state:n.smartFlowRecording})):e.createElement(e.Fragment,null,l&&e.createElement(e.Suspense,{fallback:null},e.createElement(Y,{key:l.id,session:l})),a&&e.createElement(e.Suspense,{fallback:null},e.createElement(X,{key:a.id,session:a,checklistSession:i,resourceCenterEmbedsChecklist:h})),i&&!h&&!D&&(E||i.version.checklist?.launcherEnabled)&&e.createElement(e.Suspense,{fallback:null},e.createElement(Z,{key:i.id,session:i,checklistExpanded:E})),u&&e.createElement(e.Suspense,{fallback:null},e.createElement(ee,{key:u.id,session:u})),c&&e.createElement(e.Fragment,null,e.createElement(e.Suspense,{fallback:null},e.createElement(ne,{key:`${c.id}-${d}-${k}`,session:c,isOpen:f,flowSession:a,checklistSession:i,resourceCenterLauncherHidden:d})),k!==J.DEFAULT&&e.createElement(e.Suspense,{fallback:null},e.createElement(se,{session:c,isOpen:f,flowSession:a,resourceCenterLauncherHidden:d}))),e.createElement(e.Suspense,{fallback:null},P.map(r=>e.createElement(oe,{key:r.flow.id,session:r,active:r.flow.id===F}))),_.length>0&&e.createElement(e.Suspense,{fallback:null},e.createElement(re,{notifications:_})),n.activeApp==="startConditionTesting"&&n.testStartConditionToken&&e.createElement(e.Suspense,{fallback:null},e.createElement(ae,{token:n.testStartConditionToken})),U.map(r=>e.createElement(e.Suspense,{key:r.id,fallback:null},e.createElement(te,{session:r,checklistSession:i,type:"embed"}))))};function m(){return document.visibilityState==="hidden"}const le=({client:t})=>e.createElement(K,{i18n:$},e.createElement(W.Provider,{value:t},e.createElement(ce,null)));class ye{constructor(n){this.client=n}mount(){if(this.container)throw new G("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-ui",document.body.appendChild(this.container),C.render(e.createElement(le,{client:this.client}),this.container)}unmount(){this.container&&(C.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),delete this.container)}}export{ye as RealUI};
2
+ import{r as s,R as e}from"./vendor.react.js";import{r as C}from"./vendor.react-dom.js";import{u as N,i as $,U as W}from"./client-context.js";import{R as J,_ as o,I as j,J as q,U as G}from"./userflow.js";import"./vendor.object-assign.js";import{I as K}from"./vendor.react-i18next.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="35de5746-3a44-48ae-a5a8-d7c68fabdc7a",t._sentryDebugIdIdentifier="sentry-dbid-35de5746-3a44-48ae-a5a8-d7c68fabdc7a")}catch{}})();const M=e.lazy(()=>o(()=>import("./ElementSelectionApp.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),Q=e.lazy(()=>o(()=>import("./SmartFlowRecordingApp.js"),__vite__mapDeps([26,1,2,4,9,10,11,12,14,15,16,17,18,19,20,6,7,8,21,22,5,23,24,25,13]))),X=e.lazy(()=>o(()=>import("./FlowApp.js"),__vite__mapDeps([27,1,2,6,7,8,28,12,11,29,19,18,20,21,22,5,9,10,15,16,17,23,30,31,13,24,4,32,33,34,35,36]))),Y=e.lazy(()=>o(()=>import("./WorkflowApp.js"),__vite__mapDeps([37,1,2,6,7,8,36,9,10,11,12,5,34,21,22,18,19,20,4,38,30,29,15,16,17,23,31,13,24,32,33]))),Z=e.lazy(()=>o(()=>import("./ChecklistApp.js"),__vite__mapDeps([39,1,2,6,7,8,29,19,18,20,21,22,11,5,9,10,12,15,16,17,23,30,31,13,24,4,32,33,40,34]))),ee=e.lazy(j),te=e.lazy(()=>o(()=>import("./EmbedApp.js"),__vite__mapDeps([41,1,2,6,7,8,9,10,11,12,4,18,19,20,21,22,5,34,30,31,16,17,15,23,42,13,40]))),ne=e.lazy(q),se=e.lazy(()=>o(()=>import("./ResourceCenterLauncherHandler.js"),__vite__mapDeps([43,1,2,6,7,8,9,10,11,12,31,21,22,5,18,19,20,44,30,34,4,15,16,17,23,13,24,40,29,32,33,45,46,47,42,38]))),oe=e.lazy(()=>o(()=>import("./LauncherApp.js"),__vite__mapDeps([48,1,2,6,7,8,31,21,22,11,5,34,18,19,20,9,10,12,4,30,29,15,16,17,23,13,24,32,33,35]))),re=e.lazy(()=>o(()=>import("./NotificationsApp.js"),__vite__mapDeps([49,1,2,9,10,11,12,30,6,7,8,18,19,20,21,22,5]))),ie=e.lazy(()=>o(()=>import("./TrackerTestingApp.js"),__vite__mapDeps([50,1,2,9,10,11,12,14,15,16,17,18,19,20,6,7,8,21,22,5,23,24,4,25,13]))),ae=e.lazy(()=>o(()=>import("./StartConditionTestingApp.js"),__vite__mapDeps([51,1,2,9,10,11,12,14,15,16,17,18,19,20,6,7,8,21,22,5,23,24,4,25,13,52]))),ce=()=>{const t=N(),[n,p]=s.useState(t.getSessionStorageState()),[a,S]=s.useState(()=>m()?null:t.flowSession),[l,w]=s.useState(t.workflowSession),[i,v]=s.useState(t.checklistSession),[E,A]=s.useState(t.checklistExpanded),[u,g]=s.useState(t.bannerSession),[c,L]=s.useState(t.resourceCenterSession),[f,R]=s.useState(t.resourceCenterOpen),[d,I]=s.useState(t.resourceCenterLauncherHidden),[h,T]=s.useState(t.resourceCenterEmbedsChecklist()),[D,O]=s.useState(t.embedChecklistSessions()),[P,z]=s.useState(t.launcherSessions),[F,V]=s.useState(t.activeLauncherFlowId),[_,x]=s.useState(t.notifications),[U,H]=s.useState(t.embedSessions);s.useEffect(()=>{const r=()=>{p(t.getSessionStorageState()),S(B=>m()&&t.flowSession?.id!==B?.id?null:t.flowSession),v(t.checklistSession),A(t.checklistExpanded),g(t.bannerSession),L(t.resourceCenterSession),R(t.resourceCenterOpen),I(t.resourceCenterLauncherHidden),T(t.resourceCenterEmbedsChecklist()),O(t.embedChecklistSessions()),z(t.launcherSessions),V(t.activeLauncherFlowId),x(t.notifications),H(t.embedSessions),w(t.workflowSession)};t.on("uistatechange",r);const y=()=>{m()||S(t.flowSession)};return document.addEventListener("visibilitychange",y),()=>{t.off("uistatechange",r),document.removeEventListener("visibilitychange",y)}},[t]);const b=!n.activeApp&&!!a,k=c?.version.resourceCenter?.launcherType;return s.useLayoutEffect(()=>{if(b)return t.emit("flowvisibilitychange",!0),()=>{t.emit("flowvisibilitychange",!1)}},[t,b]),n.activeApp==="elementSelection"&&n.elementSelection?e.createElement(e.Suspense,{fallback:null},e.createElement(M,{state:n.elementSelection})):n.activeApp==="trackerTesting"&&n.trackerTesting?e.createElement(e.Suspense,{fallback:null},e.createElement(ie,{state:n.trackerTesting})):n.activeApp==="smartFlowRecording"&&n.smartFlowRecording?e.createElement(e.Suspense,{fallback:null},e.createElement(Q,{state:n.smartFlowRecording})):e.createElement(e.Fragment,null,l&&e.createElement(e.Suspense,{fallback:null},e.createElement(Y,{key:l.id,session:l})),a&&e.createElement(e.Suspense,{fallback:null},e.createElement(X,{key:a.id,session:a,checklistSession:i,resourceCenterEmbedsChecklist:h})),i&&!h&&!D&&(E||i.version.checklist?.launcherEnabled)&&e.createElement(e.Suspense,{fallback:null},e.createElement(Z,{key:i.id,session:i,checklistExpanded:E})),u&&e.createElement(e.Suspense,{fallback:null},e.createElement(ee,{key:u.id,session:u})),c&&e.createElement(e.Fragment,null,e.createElement(e.Suspense,{fallback:null},e.createElement(ne,{key:`${c.id}-${d}-${k}`,session:c,isOpen:f,flowSession:a,checklistSession:i,resourceCenterLauncherHidden:d})),k!==J.DEFAULT&&e.createElement(e.Suspense,{fallback:null},e.createElement(se,{session:c,isOpen:f,flowSession:a,resourceCenterLauncherHidden:d}))),e.createElement(e.Suspense,{fallback:null},P.map(r=>e.createElement(oe,{key:r.flow.id,session:r,active:r.flow.id===F}))),_.length>0&&e.createElement(e.Suspense,{fallback:null},e.createElement(re,{notifications:_})),n.activeApp==="startConditionTesting"&&n.testStartConditionToken&&e.createElement(e.Suspense,{fallback:null},e.createElement(ae,{token:n.testStartConditionToken})),U.map(r=>e.createElement(e.Suspense,{key:r.id,fallback:null},e.createElement(te,{session:r,checklistSession:i,type:"embed"}))))};function m(){return document.visibilityState==="hidden"}const le=({client:t})=>e.createElement(K,{i18n:$},e.createElement(W.Provider,{value:t},e.createElement(ce,null)));class ye{constructor(n){this.client=n}mount(){if(this.container)throw new G("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-ui",document.body.appendChild(this.container),C.render(e.createElement(le,{client:this.client}),this.container)}unmount(){this.container&&(C.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),delete this.container)}}export{ye as RealUI};
3
3
  //# sourceMappingURL=ui.js.map
package/userflow.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ResourceCenterApp.js","vendor.react.js","vendor.object-assign.js","client-context.js","vendor.i18next.js","vendor.babel.runtime.js","vendor.react-i18next.js","flow-host.styl.js","TreeDoc.js","flow-condition-types.js","vendor.date-fns.js","roots.js","stylesheets.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.fortawesome.pro-solid-svg-icons.js","vendor.obj-str.js","use-selector-element-monitoring.js","Frame.js","vendor.react-dom.js","vendor.scheduler.js","iframe-reset.styl.js","use-window-resize.js","logomark.js","ChecklistUI.js","FlowChrome.js","use-confetti.js","vendor.canvas-confetti.js","AnnouncementEngagement.js","vendor.memoize-one.js","vendor.bignumber.js.js","use-element-rect.js","resource-center-route.js","BannerApp.js","vendor.phoenix.js","vendor.uuid.js","SitePage.js","vendor.react-router-dom.js","vendor.react-router.js","vendor.prop-types.js","vendor.history.js","vendor.resolve-pathname.js","vendor.value-equal.js","vendor.tiny-invariant.js","vendor.mini-create-react-context.js","vendor.path-to-regexp.js","vendor.react-is.js","Popover.js","react-hooks.js","vendor.lodash.js","implicit-tracking.js","DebuggerUI.js","ui.js"])))=>i.map(i=>d[i]);
2
2
  import"./vendor.object-assign.js";import{S as J}from"./vendor.phoenix.js";import{v as b}from"./vendor.uuid.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="36fa7c4f-8d7f-48bc-8bfa-a0f5d0770ceb",e._sentryDebugIdIdentifier="sentry-dbid-36fa7c4f-8d7f-48bc-8bfa-a0f5d0770ceb")}catch{}})();const Q="modulepreload",X=function(e){return new URL("./",import.meta.url).toString()+e},D={},I=function(t,s,n){let i=Promise.resolve();if(s&&s.length>0){let u=function(c){return Promise.all(c.map(E=>Promise.resolve(E).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");i=u(s.map(c=>{if(c=X(c),c in D)return;D[c]=!0;const E=c.endsWith(".css"),g=E?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${g}`))return;const T=document.createElement("link");if(T.rel=E?"stylesheet":Q,E||(T.as="script"),T.crossOrigin="",T.href=c,l&&T.setAttribute("nonce",l),document.head.appendChild(T),E)return new Promise((Y,z)=>{T.addEventListener("load",Y),T.addEventListener("error",()=>z(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&r(l.reason);return t().catch(r)})};class h extends Error{constructor(t,s,n){super(t),Object.setPrototypeOf(this,h.prototype),this.name="UserflowError",this.code=s,this.humanMessage=n}}class G{constructor(t){this.type=t,this.testState={}}formatKey(t){return`userflow:${t}`}isSupported(){if(typeof window>"u")return!1;try{return window[this.type]!=null}catch{return!1}}getItem(t){return t=this.formatKey(t),this.isSupported()?window[this.type].getItem(t):null}setItem(t,s){t=this.formatKey(t);{if(!this.isSupported())return;window[this.type].setItem(t,s)}}removeItem(t){return t=this.formatKey(t),this.isSupported()?window[this.type].removeItem(t):void 0}clear(){return this.isSupported()?window[this.type].clear():void 0}}const C=new G("localStorage"),d=new G("sessionStorage");function ft(e){window.location.href=e}function m(){return window.location.href}function A(e){window.postMessage(e,window.origin)}function x(e){const t=n=>{if(n.source!==window||n.origin!==window.origin)return;const i=n.data;!i||typeof i!="object"||typeof i.kind!="string"||!i.kind.startsWith("userflow:")||e(i)===!0&&s()};window.addEventListener("message",t);const s=()=>window.removeEventListener("message",t);return s}function Z(e){return new Promise(t=>{x(s=>{const n=e(s);return n?(t(n),!0):!1})})}const v=new Set;let y=!1;function q(e){return ee(),v.add(e),()=>{F(e)}}function F(e){v.delete(e)}function k(){v.forEach(e=>e())}function ee(){if(y)return;y=!0;const{history:e}=window,t=s=>{const n=e[s];e[s]=(...i)=>{const r=n.apply(e,i);return k(),r}};window.__userflowStatePatched?(window.addEventListener("userflow:pushstate",()=>{k()}),window.addEventListener("userflow:replacestate",()=>{k()})):(t("pushState"),t("replaceState")),window.addEventListener("popstate",()=>{k()})}class te{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(t){A({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:t})}onBuilderMessage(t){return this.unregisterOnMessage=x(t),!1}async captureScreenshot(t,s,n,i){return A({kind:"userflow:crxScreenshot",x:t,y:s,width:n,height:i,devicePixelRatio:window.devicePixelRatio}),(await Z(a=>a.kind==="userflow:crxScreenshotResult"?a:null)).imageDataUrl}}var U=(e=>(e.ACTION="ACTION",e.ELEMENT_MISSING="ELEMENT_MISSING",e.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",e.WORKFLOW_TIMED_OUT="WORKFLOW_TIMED_OUT",e.REPLACED="REPLACED",e.SNOOZED="SNOOZED",e.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",e.USERFLOWJS="USERFLOWJS",e.USER_CLOSED="USER_CLOSED",e))(U||{}),se=(e=>(e.POSITIVE="POSITIVE",e.NEUTRAL="NEUTRAL",e.NEGATIVE="NEGATIVE",e))(se||{}),ie=(e=>(e.USER_INPUT_TIMEOUT="USER_INPUT_TIMEOUT",e.STEP_TIMEOUT="STEP_TIMEOUT",e))(ie||{}),ne=(e=>(e.SECOND="SECOND",e.MINUTE="MINUTE",e.HOUR="HOUR",e.DAY="DAY",e))(ne||{}),p=(e=>(e.ACTION="ACTION",e.DRAFT="DRAFT",e.LINK="LINK",e.LAUNCHER_SEEN="LAUNCHER_SEEN",e.RESOURCE_CENTER="RESOURCE_CENTER",e.USERFLOWJS="USERFLOWJS",e.ASSISTANT="ASSISTANT",e))(p||{}),re=(e=>(e.LIKE="LIKE",e.DISLIKE="DISLIKE",e))(re||{}),S=(e=>(e.STRING="STRING",e.BOOLEAN="BOOLEAN",e.NUMBER="NUMBER",e.DATETIME="DATETIME",e.LIST="LIST",e.RANDOM_AB="RANDOM_AB",e.RANDOM_NUMBER="RANDOM_NUMBER",e.CHECKLIST_TASK="CHECKLIST_TASK",e.FLOW="FLOW",e.FLOW_SESSION="FLOW_SESSION",e.FLOW_STEP="FLOW_STEP",e.FLOW_VERSION="FLOW_VERSION",e))(S||{}),L=(e=>(e.FLOW="FLOW",e.BANNER="BANNER",e.EMBED="EMBED",e.CHECKLIST="CHECKLIST",e.LAUNCHER="LAUNCHER",e.RESOURCE_CENTER="RESOURCE_CENTER",e.SITE="SITE",e.WORKFLOW="WORKFLOW",e))(L||{}),oe=(e=>(e.ALWAYS_TRUE="ALWAYS_TRUE",e.ATTRIBUTE="ATTRIBUTE",e.CHECKLIST_TASK_CLICKED="CHECKLIST_TASK_CLICKED",e.CLAUSE="CLAUSE",e.ELEMENT="ELEMENT",e.EVENT="EVENT",e.FILLED_IN_INPUT="FILLED_IN_INPUT",e.FLOW="FLOW",e.INPUT_VALUE="INPUT_VALUE",e.PAGE="PAGE",e.SEGMENT="SEGMENT",e.TIME="TIME",e))(oe||{}),ae=(e=>(e.AUTO="AUTO",e.MANUAL="MANUAL",e))(ae||{}),ce=(e=>(e.INPUT="INPUT",e))(ce||{}),le=(e=>(e.ABSOLUTE_EQ="ABSOLUTE_EQ",e.ABSOLUTE_GT="ABSOLUTE_GT",e.ABSOLUTE_LT="ABSOLUTE_LT",e.AND="AND",e.BETWEEN="BETWEEN",e.CONTAINS="CONTAINS",e.EMPTY="EMPTY",e.ENDS_WITH="ENDS_WITH",e.EQ="EQ",e.EXCLUDES_ALL="EXCLUDES_ALL",e.EXCLUDES_ANY="EXCLUDES_ANY",e.FALSE="FALSE",e.GT="GT",e.GTE="GTE",e.INCLUDES_ALL="INCLUDES_ALL",e.INCLUDES_ANY="INCLUDES_ANY",e.LT="LT",e.LTE="LTE",e.NE="NE",e.NOT_CONTAINS="NOT_CONTAINS",e.NOT_EMPTY="NOT_EMPTY",e.NOT_REGEX="NOT_REGEX",e.OR="OR",e.REGEX="REGEX",e.RELATIVE_EQ="RELATIVE_EQ",e.RELATIVE_GT="RELATIVE_GT",e.RELATIVE_LT="RELATIVE_LT",e.STARTS_WITH="STARTS_WITH",e.TRUE="TRUE",e.URL="URL",e))(le||{}),ue=(e=>(e.CLICK="CLICK",e.DISABLED="DISABLED",e.MOUSEDOWN="MOUSEDOWN",e.NOT_CLICK="NOT_CLICK",e.NOT_DISABLED="NOT_DISABLED",e.NOT_PRESENT="NOT_PRESENT",e.PRESENT="PRESENT",e))(ue||{}),he=(e=>(e.END_USER="END_USER",e.GROUP="GROUP",e))(he||{}),de=(e=>(e.BETWEEN="BETWEEN",e.EQ="EQ",e.GTE="GTE",e.LTE="LTE",e))(de||{}),fe=(e=>(e.ANY="ANY",e.RELATIVE_BETWEEN="RELATIVE_BETWEEN",e.RELATIVE_GT="RELATIVE_GT",e.RELATIVE_LT="RELATIVE_LT",e))(fe||{}),Ee=(e=>(e.CURRENT_USER="CURRENT_USER",e.CURRENT_USER_CURRENT_GROUP="CURRENT_USER_CURRENT_GROUP",e.CURRENT_GROUP="CURRENT_GROUP",e))(Ee||{}),Se=(e=>(e.ASSET="ASSET",e.CARTOON="CARTOON",e.NONE="NONE",e.URL="URL",e))(Se||{}),Te=(e=>(e.INSIDE="INSIDE",e.OUTSIDE="OUTSIDE",e))(Te||{}),Ie=(e=>(e.TOP_LEFT="TOP_LEFT",e.TOP_CENTER="TOP_CENTER",e.TOP_RIGHT="TOP_RIGHT",e.BOTTOM_RIGHT="BOTTOM_RIGHT",e.BOTTOM_CENTER="BOTTOM_CENTER",e.BOTTOM_LEFT="BOTTOM_LEFT",e.CENTER="CENTER",e))(Ie||{}),ge=(e=>(e.GOOGLE="GOOGLE",e.STANDARD="STANDARD",e))(ge||{}),we=(e=>(e.DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",e.DISMISS="DISMISS",e))(we||{}),Ce=(e=>(e.DISMISS="DISMISS",e.NONE="NONE",e))(Ce||{}),ke=(e=>(e.DEFAULT="DEFAULT",e.NARROW="NARROW",e.CHAINED_SQUARED="CHAINED_SQUARED",e.CHAINED_ROUNDED="CHAINED_ROUNDED",e.DOTTED="DOTTED",e.NUMBERED="NUMBERED",e))(ke||{}),me=(e=>(e.TOP="TOP",e.BOTTOM="BOTTOM",e))(me||{}),Ue=(e=>(e.DEFAULT="DEFAULT",e.PLAINTEXT="PLAINTEXT",e.CUSTOM="CUSTOM",e))(Ue||{}),Le=(e=>(e.CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",e.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",e.NONE="NONE",e))(Le||{}),pe=(e=>(e.BUBBLE="BUBBLE",e.END="END",e.ERROR="ERROR",e.FLAG="FLAG",e))(pe||{}),_e=(e=>(e.MANUAL="MANUAL",e.NONE="NONE",e.SYNTHETIC="SYNTHETIC",e))(_e||{}),Ne=(e=>(e.BUBBLE="BUBBLE",e.HIDDEN="HIDDEN",e.MODAL="MODAL",e.TOOLTIP="TOOLTIP",e))(Ne||{}),Ae=(e=>(e.ABOVE="ABOVE",e.BELOW="BELOW",e.LEFT="LEFT",e.RIGHT="RIGHT",e))(Ae||{}),Re=(e=>(e.CLOSE_FLOW="CLOSE_FLOW",e.EVAL_JS="EVAL_JS",e.GO_TO_STEP="GO_TO_STEP",e.NAVIGATE="NAVIGATE",e.SET_ATTRIBUTE="SET_ATTRIBUTE",e.SNOOZE="SNOOZE",e.START_FLOW="START_FLOW",e.TRACK_BUTTON_EVENT="TRACK_BUTTON_EVENT",e))(Re||{}),ve=(e=>(e.NEW_TAB="NEW_TAB",e.SAME_TAB="SAME_TAB",e))(ve||{}),Oe=(e=>(e.SET="SET",e.SET_DATETIME="SET_DATETIME",e.SET_DATETIME_ONCE="SET_DATETIME_ONCE",e.SET_ONCE="SET_ONCE",e.ADD="ADD",e.SUBTRACT="SUBTRACT",e.APPEND="APPEND",e.PREPEND="PREPEND",e.REMOVE="REMOVE",e.UNSET="UNSET",e))(Oe||{}),be=(e=>(e.MULTILINE_TEXT="MULTILINE_TEXT",e.MULTIPLE_CHOICE="MULTIPLE_CHOICE",e.NPS="NPS",e.SCALE="SCALE",e.STARS="STARS",e.TEXT="TEXT",e))(be||{}),De=(e=>(e.CLICK="CLICK",e.FILL="FILL",e.NAVIGATE="NAVIGATE",e))(De||{}),R=(e=>(e.ACTION="ACTION",e.ANNOUNCEMENTS="ANNOUNCEMENTS",e.ASSISTANT="ASSISTANT",e.CHECKLIST="CHECKLIST",e.CONTACT="CONTACT",e.DIVIDER="DIVIDER",e.FLOWS="FLOWS",e.KNOWLEDGE_BASE="KNOWLEDGE_BASE",e.MESSAGE="MESSAGE",e.SUBPAGE="SUBPAGE",e))(R||{}),ye=(e=>(e.CRISP="CRISP",e.CUSTOM="CUSTOM",e.FRESHCHAT="FRESHCHAT",e.HELPSCOUT="HELPSCOUT",e.HUBSPOT="HUBSPOT",e.INTERCOM="INTERCOM",e.ZENDESK="ZENDESK",e.ZENDESK_MESSENGER="ZENDESK_MESSENGER",e))(ye||{}),Me=(e=>(e.BUTTON="BUTTON",e.INPUT="INPUT",e))(Me||{}),Pe=(e=>(e.EMAIL="EMAIL",e.PHONE="PHONE",e.CHAT="CHAT",e))(Pe||{}),Be=(e=>(e.SILENT="SILENT",e.BADGE="BADGE",e.POPOUT="POPOUT",e.MODAL="MODAL",e.TOAST="TOAST",e))(Be||{}),He=(e=>(e.DEFAULT="DEFAULT",e.CUSTOM="CUSTOM",e.NONE="NONE",e))(He||{}),We=(e=>(e.LAUNCHER_CLICK="LAUNCHER_CLICK",e.LAUNCHER_HOVER="LAUNCHER_HOVER",e.TARGET_CLICK="TARGET_CLICK",e.TARGET_HOVER="TARGET_HOVER",e.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",e.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",e))(We||{}),V=(e=>(e.ACTIVATE="ACTIVATE",e.DEACTIVATE="DEACTIVATE",e.NEVER="NEVER",e))(V||{}),Ge=(e=>(e.AUTO="AUTO",e.TOP="TOP",e.RIGHT="RIGHT",e.BOTTOM="BOTTOM",e.LEFT="LEFT",e))(Ge||{}),xe=(e=>(e.START="START",e.CENTER="CENTER",e.END="END",e))(xe||{}),Fe=(e=>(e.PERCENT="PERCENT",e.PX="PX",e))(Fe||{}),Ve=(e=>(e.BEACON="BEACON",e.BUTTON="BUTTON",e.HIDDEN="HIDDEN",e.ICON="ICON",e))(Ve||{}),Ke=(e=>(e.LAUNCHER="LAUNCHER",e.TARGET="TARGET",e))(Ke||{}),$e=(e=>(e.BODY_FIRST="BODY_FIRST",e.BODY_LAST="BODY_LAST",e.ELEMENT_FIRST="ELEMENT_FIRST",e.ELEMENT_LAST="ELEMENT_LAST",e.ELEMENT_BEFORE="ELEMENT_BEFORE",e.ELEMENT_AFTER="ELEMENT_AFTER",e))($e||{}),je=(e=>(e.BODY_FIRST="BODY_FIRST",e.BODY_LAST="BODY_LAST",e.ELEMENT_FIRST="ELEMENT_FIRST",e.ELEMENT_LAST="ELEMENT_LAST",e.ELEMENT_BEFORE="ELEMENT_BEFORE",e.ELEMENT_AFTER="ELEMENT_AFTER",e))(je||{}),K=(e=>(e.CHECKLIST="CHECKLIST",e))(K||{}),Ye=(e=>(e.INITIAL="INITIAL",e.FOLLOWUP="FOLLOWUP",e))(Ye||{}),ze=(e=>(e.FLOW="FLOW",e.WORKFLOW="WORKFLOW",e))(ze||{}),Je=(e=>(e.HIDE="HIDE",e.OTHERS="OTHERS",e))(Je||{}),Qe=(e=>(e.ALWAYS="ALWAYS",e.MULTIPLE="MULTIPLE",e.NEVER="NEVER",e.ONCE="ONCE",e.ONCE_PER_GROUP="ONCE_PER_GROUP",e))(Qe||{}),Xe=(e=>(e.NONE="NONE",e.PENDING_SCHEDULE="PENDING_SCHEDULE",e.SCHEDULED="SCHEDULED",e.FIRED="FIRED",e))(Xe||{}),Ze=(e=>(e.NONE="NONE",e.LIKE="LIKE",e.SCALE="SCALE",e))(Ze||{}),qe=(e=>(e.HIDE="HIDE",e.BLOCK="BLOCK",e.OTHERS="OTHERS",e))(qe||{});function et(){return{customInputs:[],customNavigate:null,urlFilter:null,linkUrlDecorator:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[e=>!e.match(/\d$/)],"data-id":[e=>!e.match(/\d$/)]},inferenceClassNameFilters:[e=>!e.startsWith("css-")],baseZIndex:1234500,evalJsDisabled:!1}}const f=et();function M(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map(t=>typeof t=="string"?new RegExp(t):t),e}function Et(e,t){return e.every(s=>typeof s=="function"?s(t):s instanceof RegExp?s.test(t):!0)}function tt(){let e=m();if(f.urlFilter){if(e=f.urlFilter(e),typeof e!="string")throw new h("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(e)}catch(t){throw new h(`Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.
3
3
  Returned URL: `+e+`
4
- Error message: `+t.message)}}return e}let $="";try{$=localStorage.getItem("debug")||""}catch{}const j=$.split(",").some(e=>e==="*"||e.startsWith("userflow:*")),o=O("log");o.group=O("group");o.groupCollapsed=O("groupCollapsed");o.groupEnd=function(){j&&console.groupEnd()};let _;function O(e){return function(t,...s){if(j){const n=performance.now(),i=_?Math.round(n-_):0;_=n,console[e](`%cuserflow %c${t} %c+${i}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const st=()=>I(()=>import("./ResourceCenterApp.js").then(e=>e.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]));function it(e){const s=e.version.checklist.tasks.length;return Math.max(0,s-e.taskCompletions.length)}class P{constructor(t){this.observers=new Set,this._value=t}get value(){return this._value}update(t){if(t!==this._value){this._value=t;for(const s of this.observers)s()}}observe(t){return this.observers.add(t),()=>this.observers.delete(t)}}const B=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit","livewire:navigated","livewire:navigating","livewire:update"],nt=()=>I(()=>import("./BannerApp.js"),__vite__mapDeps([32,1,2,3,4,5,6,15,12,13,14,9,10,11,8,7,16,18,19,17,20,30,21,33,34])),N="1025143",rt=import.meta.url,H=50,ot=300*1e3,W="userflowClientState",w="userflowClientSiteId";class at{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=null,this.siteSession=null,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.embedSessions=[],this.workflowSession=null,this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.debuggerUI=null,this.debuggerMountInProgress=!1,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.implicitTracking=null,this.initialMessagesQueue=[],this.onBuilderMessage=t=>(this.handleBuilderMessage(t),!1),this.handleBuilderMessage=async t=>{o(`builder ${t.kind} message received`,t);const s="idempotencyKey"in t&&typeof t.idempotencyKey=="string"?t.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const n=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(t.kind){case"userflow:selectElement":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:t.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),d.setItem("previewFlowId",t.flowId),t.testUser?this.identifyTestUser(t.testUser):this.resetTestUser(),t.testStartCondition?this.setSessionStorageState(i=>({...i,activeApp:"startConditionTesting",testStartConditionToken:t.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(t.token),t.isResourceCenter){const i=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===t.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",i))};this.on("resourceCenterChanged",i),i()}});return}case"userflow:testTracker":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0})),t.testUser?this.identifyTestUser(t.testUser):this.resetTestUser(),this.setSessionStorageState(i=>({...i,activeApp:"trackerTesting",trackerTesting:{trackerName:t.trackerName,token:t.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,trackerTesting:null}));return}case"userflow:startSmartFlow":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startSmartFlowAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:"smartFlowRecording",smartFlowRecording:{sessionId:t.sessionId,isRecording:!0,startUrl:t.startUrl||null}}));return}case"userflow:smartFlowCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,smartFlowRecording:null}));return}case"userflow:smartFlowStartOverAck":return;case"userflow:smartFlowComplete":{this.setSessionStorageState(i=>({...i,activeApp:null,smartFlowRecording:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),H))},this.onUserActivity=()=>this.ensureConnected(),this.mountSitePage=async(t,s)=>{d.setItem(w,s),o("mounting site page"),this.setResourceCenterLauncherHidden(!0);try{const{SitePage:n}=await I(async()=>{const{SitePage:r}=await import("./SitePage.js");return{SitePage:r}},__vite__mapDeps([35,1,2,3,4,5,6,18,19,36,37,38,39,40,41,42,43,44,45,27,15,12,13,14,9,10,11,25,26,20,8,46,28,47,48,33,34]));new n(this,t).mount(),o("site page mounted")}catch(n){console.error("Userflow: Failed to mount site page",n)}},this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+N),q(this.onUrlChange),this.setTargetEnv(new te),this.checkTestUserAtBoot(),this.toggleUI(),this.checkDebuggerSession();for(const t of B)document.addEventListener(t,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),F(this.onUrlChange),this.destroyTargetEnv();for(const t of B)document.removeEventListener(t,this.remountIfNecessary)}setTargetEnv(t){this.destroyTargetEnv(),this.targetEnv=t,t.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new h("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(t){const s=t(this.getSessionStorageState());d.setItem(W,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let t=this.sessionStorageState;if(!t){const s=d.getItem(W);if(s)try{t=JSON.parse(s)}catch(n){console.error("Userflow.js: Parse ElementSelectionState error:",n)}t||(t={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=t}return t}checkTestUserAtBoot(){const t=this.getSessionStorageState().testUser;t&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(t))}async identifyTestUser(t){this.setSessionStorageState(i=>({...i,testUser:t})),this.reset(),this.init(t.clientToken),this.testUserIdentified=!0,this.externalId=t.id;const s=[this.identify(t.id,{name:t.name,email:t.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:t.signature})],{group:n}=t;n&&(this.groupId=n.id,s.push(this.group(n.id,{name:n.name},{signature:n.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(t=>({...t,testUser:null}))}init(t){if(o("init",t),!t)throw new h("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==t){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=t,this.emit("private:initialised")}}ensureInit(){if(!this.clientToken)throw new h("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new h("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new h("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");const t=/^ct_eu\d+_.+$/.test(this.clientToken)?"e.eu.":"e.";let s=f.serverEndpoint||t+"userflow.com";new URL(rt).hostname==="js.getuserflow.com"&&s==="e.userflow.com"&&(s="e.getuserflow.com");const n="wss://"+s+"/end-users/"+this.clientToken+"/socket";this.socket=new J(n,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{typeof this.featureFlags>"u"&&this.clearInitialMessagesQueue(i.featureFlags),this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected"),this.featureFlagEnabled("cff_implicit_events")===!0&&!this.implicitTracking&&this.startImplicitTracking(),!this.featureFlagEnabled("cff_implicit_events")&&this.implicitTracking&&(this.implicitTracking.stop(),this.implicitTracking=null)}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
4
+ Error message: `+t.message)}}return e}let $="";try{$=localStorage.getItem("debug")||""}catch{}const j=$.split(",").some(e=>e==="*"||e.startsWith("userflow:*")),o=O("log");o.group=O("group");o.groupCollapsed=O("groupCollapsed");o.groupEnd=function(){j&&console.groupEnd()};let _;function O(e){return function(t,...s){if(j){const n=performance.now(),i=_?Math.round(n-_):0;_=n,console[e](`%cuserflow %c${t} %c+${i}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const st=()=>I(()=>import("./ResourceCenterApp.js").then(e=>e.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]));function it(e){const s=e.version.checklist.tasks.length;return Math.max(0,s-e.taskCompletions.length)}class P{constructor(t){this.observers=new Set,this._value=t}get value(){return this._value}update(t){if(t!==this._value){this._value=t;for(const s of this.observers)s()}}observe(t){return this.observers.add(t),()=>this.observers.delete(t)}}const B=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit","livewire:navigated","livewire:navigating","livewire:update"],nt=()=>I(()=>import("./BannerApp.js"),__vite__mapDeps([32,1,2,3,4,5,6,15,12,13,14,9,10,11,8,7,16,18,19,17,20,30,21,33,34])),N="1025283",rt=import.meta.url,H=50,ot=300*1e3,W="userflowClientState",w="userflowClientSiteId";class at{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=null,this.siteSession=null,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.embedSessions=[],this.workflowSession=null,this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.debuggerUI=null,this.debuggerMountInProgress=!1,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.implicitTracking=null,this.initialMessagesQueue=[],this.onBuilderMessage=t=>(this.handleBuilderMessage(t),!1),this.handleBuilderMessage=async t=>{o(`builder ${t.kind} message received`,t);const s="idempotencyKey"in t&&typeof t.idempotencyKey=="string"?t.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const n=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(t.kind){case"userflow:selectElement":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:t.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),d.setItem("previewFlowId",t.flowId),t.testUser?this.identifyTestUser(t.testUser):this.resetTestUser(),t.testStartCondition?this.setSessionStorageState(i=>({...i,activeApp:"startConditionTesting",testStartConditionToken:t.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(t.token),t.isResourceCenter){const i=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===t.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",i))};this.on("resourceCenterChanged",i),i()}});return}case"userflow:testTracker":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0})),t.testUser?this.identifyTestUser(t.testUser):this.resetTestUser(),this.setSessionStorageState(i=>({...i,activeApp:"trackerTesting",trackerTesting:{trackerName:t.trackerName,token:t.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,trackerTesting:null}));return}case"userflow:startSmartFlow":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startSmartFlowAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:"smartFlowRecording",smartFlowRecording:{sessionId:t.sessionId,isRecording:!0,startUrl:t.startUrl||null}}));return}case"userflow:smartFlowCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,smartFlowRecording:null}));return}case"userflow:smartFlowStartOverAck":return;case"userflow:smartFlowComplete":{this.setSessionStorageState(i=>({...i,activeApp:null,smartFlowRecording:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),H))},this.onUserActivity=()=>this.ensureConnected(),this.mountSitePage=async(t,s)=>{d.setItem(w,s),o("mounting site page"),this.setResourceCenterLauncherHidden(!0);try{const{SitePage:n}=await I(async()=>{const{SitePage:r}=await import("./SitePage.js");return{SitePage:r}},__vite__mapDeps([35,1,2,3,4,5,6,18,19,36,37,38,39,40,41,42,43,44,45,27,15,12,13,14,9,10,11,25,26,20,8,46,28,47,48,33,34]));new n(this,t).mount(),o("site page mounted")}catch(n){console.error("Userflow: Failed to mount site page",n)}},this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+N),q(this.onUrlChange),this.setTargetEnv(new te),this.checkTestUserAtBoot(),this.toggleUI(),this.checkDebuggerSession();for(const t of B)document.addEventListener(t,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),F(this.onUrlChange),this.destroyTargetEnv();for(const t of B)document.removeEventListener(t,this.remountIfNecessary)}setTargetEnv(t){this.destroyTargetEnv(),this.targetEnv=t,t.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new h("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(t){const s=t(this.getSessionStorageState());d.setItem(W,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let t=this.sessionStorageState;if(!t){const s=d.getItem(W);if(s)try{t=JSON.parse(s)}catch(n){console.error("Userflow.js: Parse ElementSelectionState error:",n)}t||(t={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=t}return t}checkTestUserAtBoot(){const t=this.getSessionStorageState().testUser;t&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(t))}async identifyTestUser(t){this.setSessionStorageState(i=>({...i,testUser:t})),this.reset(),this.init(t.clientToken),this.testUserIdentified=!0,this.externalId=t.id;const s=[this.identify(t.id,{name:t.name,email:t.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:t.signature})],{group:n}=t;n&&(this.groupId=n.id,s.push(this.group(n.id,{name:n.name},{signature:n.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(t=>({...t,testUser:null}))}init(t){if(o("init",t),!t)throw new h("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==t){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=t,this.emit("private:initialised")}}ensureInit(){if(!this.clientToken)throw new h("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new h("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new h("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");const t=/^ct_eu\d+_.+$/.test(this.clientToken)?"e.eu.":"e.";let s=f.serverEndpoint||t+"userflow.com";new URL(rt).hostname==="js.getuserflow.com"&&s==="e.userflow.com"&&(s="e.getuserflow.com");const n="wss://"+s+"/end-users/"+this.clientToken+"/socket";this.socket=new J(n,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{typeof this.featureFlags>"u"&&this.clearInitialMessagesQueue(i.featureFlags),this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected"),this.featureFlagEnabled("cff_implicit_events")===!0&&!this.implicitTracking&&this.startImplicitTracking(),!this.featureFlagEnabled("cff_implicit_events")&&this.implicitTracking&&(this.implicitTracking.stop(),this.implicitTracking=null)}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
5
5
  Details:
6
6
  `+i.details.map(r=>(r.path?`${r.path}: `:"")+r.message):""))})}async startImplicitTracking(){await I(()=>import("./implicit-tracking.js"),__vite__mapDeps([49,11,2,34,33])).then(t=>{this.implicitTracking=new t.ImplicitTracking(this),this.implicitTracking.start()}).catch(t=>o(`Implicit tracking failed to load ${t}`))}makeChannelJoinPayload(){let t;d.getItem(w)&&(t=new URL(m()).searchParams.get("announcement_id")||void 0);const n=this.buildClientContext();this.clientContext=n;const i={protocolVersion:2,userflowClientBuild:N,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,siteSessionId:this.siteSession?.id||null,launchers:this.launcherSessions.map(r=>({flowId:r.flow.id})),trackers:Array.from(this.trackers.values()).map(r=>({flowId:r.tracker.flowId})),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map(r=>({conditionId:r.condition.id,isTrue:r.isTrue})),previewFlowId:d.getItem("previewFlowId"),announcementPreviewId:t,clientContext:n};return o("channel join payload",i),i}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout(()=>{if(this.hasDraftSession()||this.assistantMessageInProgress){this.debounceInactiveDisconnect();return}o("disconnecting from socket due to inactivity"),this.disconnect()},ot)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some(t=>t.draftMode)}async send(t,{batch:s,endBatch:n,handlesRejection:i}={}){return(!this.inBatch||!["ToggleClientCondition","UpdateClientContext"].includes(t.kind))&&this.checkPushRateLimit(),this.ensureConnected(),s&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),n?this.endBatch():this.endBatchTimeout=window.setTimeout(()=>{this.endBatch()},H)),this.sendRaw(t,{handlesRejection:i})}clearInitialMessagesQueue(t){if(this.initialMessagesQueue.length===0)return;const s=t.includes("cff_disable_page_views")===!0,n=t.includes("cff_implicit_events")===!1;for(const i of this.initialMessagesQueue){const{message:r,handlesRejection:a,resolve:l,reject:u}=i;if(n&&r.kind==="TrackRawEvent"){l("skipped due to disabled implicit events");continue}if(s&&(r.kind==="TrackEvent"&&r.name==="page_viewed"||r.kind==="TrackRawEvent"&&r.name==="page_viewed")){l("skipped due to disabled page views tracking");continue}this._sendToChannel(r,l,u,{handlesRejection:a})}this.initialMessagesQueue=[]}async sendRaw(t,{handlesRejection:s}={}){return typeof this.featureFlags>"u"?new Promise((n,i)=>{this.initialMessagesQueue.push({message:t,resolve:n,reject:i,handlesRejection:s})}):new Promise((n,i)=>{this._sendToChannel(t,n,i,{handlesRejection:s})})}_sendToChannel(t,s,n,{handlesRejection:i}={}){if(!this.channel){const u=`Userflow.js: send() should not be called if channel is not set. Message kind=${t.kind}`;if(i)throw Error(u);console.log(u,`
7
7
  Client message:`,t);return}o(`push ${t.kind} message`,t);const r=this.clientClock,a=()=>{this.serverClock=r,this.channel?.off("phx_error",l)},l=this.channel.on("phx_error",u=>{a();const c=`Userflow.js send ${t.kind} got phx_error`;this._socketStatus==="connected"&&console.log(c,`
@@ -14,5 +14,5 @@ Error:`,u),i&&n(new h(c,u.code,u.message))})}endBatch(){this.inBatch=!1,this.sen
14
14
  - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.
15
15
  - The user legitimately being very active, in which case you can just ignore this error.
16
16
 
17
- If in doubt, reach out to us at support@userflow.com.`);this.pushRateLimitMinute++}handleServerMessage(t){o(`received ${t.kind} message`,t);const{serverClock:s,flowSession:n,flowSessionClock:i,checklistSession:r,checklistSessionClock:a,bannerSession:l,resourceCenterSession:u}=this;switch(t.kind){case"CheckSessionsAck":this.emit("private:checkSessionsAck");return;case"ServerDebug":return;case"AddLauncher":{const{session:c}=t,E=this.launcherSessions.findIndex(g=>g.flow.id===c.flow.id);E===-1?this.launcherSessions=[...this.launcherSessions,c]:this.launcherSessions=[...this.launcherSessions.slice(0,E),c,...this.launcherSessions.slice(E+1)],this.toggleUI();return}case"AddTracker":{this.addTracker(t.tracker);return}case"AssistantMessageEventWrapper":{this.emit("private:assistantMessageEvent",t);return}case"CancelConditionWaitTimer":window.clearTimeout(this.conditionWaitTimers.get(t.conditionId)),this.conditionWaitTimers.delete(t.conditionId);return;case"ChecklistTaskCompleted":this.unackedTasks.add(t.taskCvid);return;case"ForceGoToStep":if(i>s){o(`ignoring ${t.kind} message due to stale clock flowSessionClock=${i} > serverClock=${s}`);return}n?.id===t.sessionId&&this.emit("gotostep",{session:n,step:{id:t.stepId}});return;case"RemoveLauncher":this.removeLauncher(t.flowId)&&this.toggleUI();return;case"RemoveTracker":{this.removeTracker(t.flowId);return}case"SetBannerSession":this.setBannerSession(t.session),this.toggleUI();return;case"SetChecklistSession":a<=s||r?.id===t.session.id?(this.setChecklistSession(t.session,s),this.toggleUI()):o(`ignoring ${t.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return;case"SetFlowSession":i<=s||n?.id===t.session.id?(this.setFlowSession(t.session,s),this.emit("private:setFlowSession",t.session.version.id),this.toggleUI()):o(`ignoring ${t.kind} message due to stale clock flowSessionClock=${i} > serverClock=${s}`);return;case"SetResourceCenterSession":this.emit("private:resourceCenterSession",t.session),this.setResourceCenterSession(t.session),this.toggleUI();return;case"StartConditionWaitTimer":{if(!this.conditionWaitTimers.has(t.conditionId)){const c=window.setTimeout(()=>{this.conditionWaitTimers.delete(t.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:t.conditionId},{batch:!0})},parseFloat(t.waitTime)*1e3);this.conditionWaitTimers.set(t.conditionId,c)}return}case"TestStartConditionSuccess":this.emit("private:testStartConditionSuccess");return;case"TrackClientCondition":this.trackClientCondition(t.condition);return;case"UnsetBannerSession":l?.id===t.sessionId&&(this.setBannerSession(null),this.toggleUI());return;case"UnsetChecklistSession":if(a>s){o(`ignoring ${t.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return}r?.id===t.sessionId&&(this.setChecklistSession(null,s),this.toggleUI());return;case"UnsetFlowSession":if(i>s){o(`ignoring ${t.kind} message due to stale clock flowSessionClock=${i} > serverClock=${s}`);return}n?.id===t.sessionId&&(this.setFlowSession(null,s),this.toggleUI());return;case"UnsetResourceCenterSession":u?.id===t.sessionId&&(this.setResourceCenterSession(null),this.toggleUI());return;case"UntrackClientCondition":this.untrackClientCondition(t.conditionId);return;case"AddEmbed":{const c=this.embedSessions?.findIndex(E=>E.flow.id===t.session.flow.id);c!==void 0&&c>=0?this.embedSessions=[...this.embedSessions?.slice(0,c)||[],t.session,...this.embedSessions?.slice(c+1)||[]]:this.embedSessions=[...this.embedSessions||[],t.session],this.emit("uistatechange");break}case"RemoveEmbed":{this.embedSessions=(this.embedSessions||[]).filter(c=>c.flow.id!==t.flowId),this.emit("uistatechange");break}case"SetSiteSession":{this.siteSession=t.session,this.emit("private:siteSession",t.session);break}case"UnsetSiteSession":{this.siteSession=null,d.removeItem(w),this.emit("private:unsetSiteSession");break}case"SetWorkflowSession":{this.setWorkFlowSession(t.session),this.toggleUI();break}case"UnsetWorkflowSession":{this.setWorkFlowSession(null),this.toggleUI();break}case"WorkflowFillStepValue":{this.emit("private:workflowFillStepValue",t);break}default:console.warn("Userflow.js: Received unknown message",t);return}}async identify(t,s={},{signature:n}={}){if(o("identify",t),this.ensureInit(),this.testUserIdentified&&t!==this.externalId){o("identify() ignored since a test user has been identified");return}if(typeof t=="number")t=String(t);else if(!t||typeof t!="string")throw new h(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(t)}`);this.externalId&&t!==this.externalId&&(o("identify resetting due to new externalId"),this.reset()),this.externalId=t,this.signature=n||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(s)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}async identifyAnonymous(t={},s={}){if(!C.isSupported())throw new h("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const n="anonymousId";let i=C.getItem(n);i||(i="anon-"+b(),C.setItem(n,i)),await this.identify(i,t,s)}getInitToken(){return this.clientToken}getIdentifiedUser(){return{externalId:this.externalId}}async updateUser(t={},s={}){o("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(t)},{batch:!0})}async group(t,s={},{signature:n,membership:i}={}){if(o("group",t),this.ensureIdentified(),this.testUserIdentified&&t!==this.groupId){o("group() ignored since a test user has been identified");return}if(typeof t=="number")t=String(t);else if(!t||typeof t!="string")throw new h(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(t)}`);this.groupId=t,this.groupSignature=n||null,await this.send({kind:"UpsertGroup",groupExternalId:t,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(s),membershipAttributes:this.normalizeAttributes(i)},{batch:!0})}async updateGroup(t={},s={}){o("updateGroup");const n=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:n,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(s.membership),groupAttributes:this.normalizeAttributes(t)},{batch:!0})}normalizeAttributes(t){if(t==null)return{};if(typeof t!="object")throw new h("Userflow: 'attributes' must be an object.");const s={};for(const n in t){if(!t.hasOwnProperty(n))continue;if(n==="traits"){const r=t[n];Object.assign(s,this.extractLegacyTraits(r));continue}let i=t[n];if(typeof i=="string"||typeof i=="number"||typeof i=="boolean"||i==null||Array.isArray(i))s[n]=this.normalizeAttributeLiteralOrList(n,i);else{if(typeof i!="object"||i==null)throw new h(`Userflow: Invalid value for '${n}' attribute.`);if("set"in i)s[n]={set:this.normalizeAttributeLiteralOrList(n,i.set),dataType:this.normalizeDataType(n,i.data_type||i.dataType)};else if("set_once"in i||"setOnce"in i)s[n]={setOnce:this.normalizeAttributeLiteralOrList(n,i.set_once??i.setOnce),dataType:this.normalizeDataType(n,i.data_type||i.dataType)};else if("add"in i){const r=i.add;if(typeof r!="string"&&typeof r!="number")throw new h(`Userflow: Invalid 'add' value for '${n}' attribute. Must be a number or string.`);s[n]={add:r}}else if("subtract"in i){const r=i.subtract;if(typeof r!="string"&&typeof r!="number")throw new h(`Userflow: Invalid 'subtract' value for '${n}' attribute. Must be a number or string.`);s[n]={subtract:r}}else if("append"in i)s[n]={append:this.normalizeAttributeLiteralOrList(n,i.append)};else if("prepend"in i)s[n]={prepend:this.normalizeAttributeLiteralOrList(n,i.prepend)};else if("remove"in i)s[n]={remove:this.normalizeAttributeLiteralOrList(n,i.remove)};else throw new h(`Userflow: Invalid value for '${n}' attribute.`)}}return s}normalizeAttributeLiteralOrList(t,s){return Array.isArray(s)?s.map(n=>this.normalizeAttributeLiteral(t,n)):this.normalizeAttributeLiteral(t,s)}normalizeAttributeLiteral(t,s){if(s==null)return null;if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;throw new h(`Userflow: Invalid value for '${t}' attribute.`)}normalizeDataType(t,s){if(!s)return null;switch(s){case"string":return S.STRING;case"number":return S.NUMBER;case"boolean":return S.BOOLEAN;case"datetime":return S.DATETIME}throw new h(`Userflow: Invalid data_type for '${t}' attribute.`)}extractLegacyTraits(t){if(!t)return{};if(!Array.isArray(t)){const s=[];for(const n in t)t.hasOwnProperty(n)&&s.push({name:n,value:t[n]});t=s}return t.reduce((s,{name:n,value:i,dataType:r})=>{if(typeof n!="string"||n.length>100||!n.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:",n),s;if(typeof i!="string")if(typeof i=="boolean")r||(r="boolean"),i=i?"true":"false";else if(typeof i=="number")r||(r=Number.isInteger(i)?"integer":"decimal"),i=String(i);else return this.warn(`userflow.identify: The value of trait '${n}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,i),s;let a=null;if(r)switch(r){case"string":a=S.STRING;break;case"boolean":a=S.BOOLEAN;break;case"integer":a=S.NUMBER;break;case"decimal":a=S.NUMBER;break;case"datetime":a=S.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${n}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,r),s}return s[n]={set:i,dataType:a},s},{})}async track(t,s={},{userOnly:n}={}){o(`track '${t}'`,s),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!n,name:t,attributes:this.normalizeEventAttributes(s)},{batch:!0})}async trackRawEvent(t){const{name:s,attributes:n}=t;o(`track raw event '${s}'`,n),this.ensureIdentified(),await this.send({kind:"TrackRawEvent",name:s,attributes:this.normalizeEventAttributes(n)})}normalizeEventAttributes(t){const s=this.normalizeAttributes(t);for(const n in s){if(!s.hasOwnProperty(n))continue;const i=s[n];if(!(i==null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||Array.isArray(i)||"set"in i))throw new h(`Userflow: Invalid value for '${n}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return s}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout(()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()},0))}onceIdentified(t){this.isIdentified()?t():this.firstIdentifyCallback=t}checkUrlForStartFlow(){const t=new URL(m()),s=t.searchParams.get("userflow")||t.searchParams.get("studio1_flow")||t.searchParams.get("studio1_walkthrough");s&&(o(`url contained flow ${s}`),this.startFlow({flowId:s,startReason:p.LINK,batch:!0}),t.searchParams.delete("userflow"),t.searchParams.delete("studio1_flow"),t.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",t.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const t=this.buildClientContext();(!this.clientContext||t.pageUrl!==this.clientContext.pageUrl)&&(this.clientContext=t,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.featureFlags&&this.featureFlagEnabled("cff_disable_page_views")===!0||(this.pageTrackingDisabled||this.track("page_viewed",{}),this.trackRawPageViewed())}async trackRawPageViewed(){this.featureFlags&&(this.featureFlagEnabled("cff_implicit_events")===!1||this.featureFlagEnabled("cff_disable_page_views")===!0)||this.trackRawEvent({name:"page_viewed",attributes:{id:b(),page_title:document.title,...this.buildClientContext()}})}buildClientContext(){let t=null;const s=d.getItem(w);if(s){const i=new URL(m()).pathname.match(/^\/([^/]+)\/?(?:\/([^/]+)\/?)?$/);i&&(t=i[1])}return{pageUrl:tt(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,...s&&{siteId:s},...t&&{localeCode:t}}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(t){this.unackedTasks.delete(t)}taskIsUnacked(t){return this.unackedTasks.has(t)}isIdentified(){return this.externalId!=null}on(t,s){let n=this.listeners.get(t);n||(n=new Set,this.listeners.set(t,n)),n.add(s)}off(t,s){const n=this.listeners.get(t);n&&n.delete(s)}emit(t,...s){const n=this.listeners.get(t);n&&Array.from(n).forEach(r=>r(...s))}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){o("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setBannerSession(null),this.setResourceCenterSession(null),this.resourceCenterLauncherHidden=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((t,s)=>{this.untrackClientCondition(s)}),this.firstIdentifyCallback=null,this.testUserIdentified=!1,C.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:t,stepCvid:s,startReason:n,once:i,batch:r,replaceCurrent:a}){if(this.ensureIdentified(),a&&this.flowSession&&this.endFlow(this.flowSession,{endReason:U.REPLACED,batch:!0}),o(`startFlow ${t}`,{startReason:n}),this.checklistSession?.flow.id===t){o("startFlow matches current checklist, so showing it instead"),this.showChecklist();return}const l={kind:"StartFlow",flowId:t,stepCvid:s,startReason:n,once:!!i};await this.send(l,{batch:r})}async trackButtonEvent(t,s,n,i){const r={kind:"TrackButtonEvent",eventName:t,stepCvid:n,sessionId:i,token:s};await this.send(r,{batch:!0})}async startFlowWithToken(t){this.ensureIdentified(),o("startFlowWithToken",{token:t}),await this.send({kind:"StartFlowWithToken",token:t},{batch:!0})}optimisticClockUIUpdate(t){this.clientClock++,t(),this.toggleUI()}async showChecklist(){if(this.resourceCenterEmbedsChecklist()&&!this.embedChecklistSessions()){this.openResourceCenter();return}this.embedChecklistSessions()||(this.unmarkExpandPending(),!(!this.checklistSession||this.checklistExpanded)&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),d.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0})))}async hideChecklist(){if(this.resourceCenterEmbedsChecklist()){this.closeResourceCenter();return}!this.checklistSession||!this.checklistExpanded||(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),d.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"),d.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"),d.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(t){this.resourceCenterLauncherHidden=t,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const t=this.resourceCenterEmbedsChecklist(),{checklistSession:s}=this,n=this.resourceCenterSession.version.resourceCenter?.blocks.find(i=>i.type===R.ANNOUNCEMENTS);return{isOpen:this.resourceCenterOpen,hasChecklist:t,uncompletedChecklistTaskCount:t&&s?it(s):0,unreadAnnouncementCount:n?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const t=this.resourceCenterSession;return!!t&&!!t.version.resourceCenter?.blocks.some(s=>s.type===R.CHECKLIST)}embedChecklistSessions(){return this.embedSessions.some(t=>!!t.version.embed?.blocks?.some(s=>s.type===K.CHECKLIST))}async endFlow(t,{endReason:s,batch:n}){this.ensureIdentified(),this.optimisticClockUIUpdate(()=>{const{clientClock:l}=this;this.flowSession?.id===t.id&&this.setFlowSession(null,l),this.checklistSession?.id===t.id&&this.setChecklistSession(null,l),this.bannerSession?.id===t.id&&this.setBannerSession(null),this.resourceCenterSession?.id===t.id&&this.setResourceCenterSession(null),this.workflowSession?.id===t.id&&this.setWorkFlowSession(null)});const{flow:i}=t,r={id:i.id,type:i.type.toLowerCase()};i.type===L.CHECKLIST?this.emit("checklistEnded",{checklist:r,endReason:s}):i.type===L.FLOW&&this.emit("flowEnded",{flow:r,endReason:s});const a={kind:"EndFlow",sessionId:t.id,endReason:s};await this.send(a,{batch:n})}async goToStep(t,s){o("goToStep",t.id,s.name||s.id),this.ensureIdentified();const n=this.send({kind:"GoToStep",sessionId:t.id,stepId:s.id});t.currentStep=s,this.emit("gotostep",{session:t,step:s}),await n}async endAllFlows(){o("endAllFlows"),this.optimisticClockUIUpdate(()=>{const{clientClock:t}=this;this.setFlowSession(null,t),this.setChecklistSession(null,t)}),await this.send({kind:"EndAllFlows"})}async endChecklist(){o("endChecklist");const t=this.checklistSession||this.flowSession;t?.flow.type===L.CHECKLIST&&this.endFlow(t,{endReason:U.USERFLOWJS})}setFlowSession(t,s=this.clientClock){const n=this.flowSession;this.flowSession=t,this.flowSessionClock=s,t&&!n&&(this.hideChecklist(),this.closeResourceCenter()),t==null&&this.originalActiveElement&&(typeof this.originalActiveElement.focus=="function"&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setWorkFlowSession(t){this.workflowSession=t}setChecklistSession(t,s=this.clientClock){const n=this.checklistSession;this.checklistSession=t,this.checklistSessionClock=s,t===null&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),t&&t.id!==n?.id&&(this.checklistExpanded=!!d.getItem(`checklistExpanded:${t.id}`),t.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setBannerSession(t){this.bannerSession=t}setResourceCenterSession(t){const s=this.resourceCenterSession;t=typeof t=="function"?t(this.resourceCenterSession):t,this.resourceCenterSession=t,t===null&&(this.resourceCenterOpen=!1),s&&s.id!==t?.id&&d.removeItem(`resourceCenterOpen:${s.id}`),t&&t.id!==s?.id&&(this.resourceCenterOpen=!!d.getItem(`resourceCenterOpen:${t.id}`)),this.emit("resourceCenterChanged")}launcherSeen(t){this.send({kind:"StartFlow",flowId:t,startReason:p.LAUNCHER_SEEN,once:!1})}activateLauncher(t){const s=this.activeLauncherFlowId&&this.launcherSessions.find(n=>n.flow.id===this.activeLauncherFlowId);s&&this.deactivateLauncher(s),this.activeLauncherFlowId=t.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:t.flow.id})}deactivateLauncher(t){const{launcher:s}=t.version;t.flow.id===this.activeLauncherFlowId&&(s?.dismissOn===V.DEACTIVATE?this.dismissLauncher(t,{endReason:U.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(t,{endReason:s}){const n=t.flow.id;this.removeLauncher(n),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:n,endReason:s})}removeLauncher(t){const s=this.launcherSessions.findIndex(n=>n.flow.id===t);return s===-1?!1:(this.launcherSessions=[...this.launcherSessions.slice(0,s),...this.launcherSessions.slice(s+1)],t===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const t=this.getSessionStorageState();!this.flowSession&&!this.workflowSession&&(this.checklistExpandPending||this.checklistSession?.version.checklist?.tasks.some(s=>this.taskIsUnacked(s.cvid)))&&this.showChecklist(),t.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){return this.uiDisabled||this.siteSession?.id||d.getItem(w)?!1:!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.workflowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.bannerSession||!!this.resourceCenterSession||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const t=await this.createUI();this.shouldBeMounted()&&!this.ui&&(o("mount UI"),this.ui=t,this.ui.mount())}}unmountUI(){this.ui&&(o("unmount UI"),this.ui.unmount(),this.ui=null)}checkDebuggerSession(){if(this.debuggerUI)return;const t=this.sessionStorageState?.debuggerApp;t&&t?.x&&t?.y&&this.mountDebugger()}async mountDebugger(){if(!this.debuggerMountInProgress){if(this.debuggerUI){this.debuggerUI.unmount();return}this.debuggerMountInProgress=!0;try{const{DebuggerUI:t}=await I(async()=>{const{DebuggerUI:s}=await import("./DebuggerUI.js");return{DebuggerUI:s}},__vite__mapDeps([50,1,2,18,19,3,4,5,6,17,15,12,13,14,9,10,11,20,22,48,47,46,28,33,34]));this.debuggerUI=new t(this,N),this.debuggerUI.mount()}catch(t){console.error("Userflow: Failed to mount debugger UI",t)}finally{this.debuggerMountInProgress=!1}}}unMountDebugger(){this.debuggerUI=null}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const t=I(()=>import("./ui.js"),__vite__mapDeps([51,1,2,18,19,3,4,5,6,33,34]));this.bannerSession&&nt(),this.resourceCenterSession&&st();const{RealUI:s}=await t;return new s(this)}catch(t){throw this.reportCspIssue(),t}}async trackClientCondition(t){if(this.clientConditions.has(t.id))return;o("track client condition",t),this.clientConditions.set(t.id,{condition:t,isTrue:null});const{conditionTypes:s}=await I(async()=>{const{conditionTypes:r}=await import("./flow-condition-types.js").then(a=>a.f);return{conditionTypes:r}},__vite__mapDeps([9,2,10,5,11])),n=s[t.type],i=this.clientConditions.get(t.id);i&&(i.untrack=n.track({sessionData:new P([]),condition:t,callback:r=>{i.isTrue!==r&&(o("client condition truthiness changed",r,i.condition),i.isTrue=r,this.send({kind:"ToggleClientCondition",conditionId:t.id,isTrue:r},{batch:!0}))}}))}untrackClientCondition(t){const s=this.clientConditions.get(t);s&&(o("untrack client condition",s.condition),s.untrack&&s.untrack(),this.clientConditions.delete(t))}async addTracker(t){let s=this.trackers.get(t.flowId);s?s.tracker=t:this.trackers.set(t.flowId,{tracker:t,isTrue:!1});const{conditionTypes:n}=await I(async()=>{const{conditionTypes:u}=await import("./flow-condition-types.js").then(c=>c.f);return{conditionTypes:u}},__vite__mapDeps([9,2,10,5,11])),i=this.trackers.get(t.flowId);if(!i)return;const{tracker:r}=i,{condition:a}=r,l=n[a.type];i.untrack&&i.untrack(),i.untrack=l.track({sessionData:new P(r.data),condition:a,flipBackEvents:!0,callback:u=>{const c=i.isTrue;i.isTrue=u,!c&&u&&this.send({kind:"TrackTrackerEvent",token:r.token},{batch:!0})},description:`event tracker ${r.flowId}`}),this.emit("private:trackerStarted")}removeTracker(t){const s=this.trackers.get(t);s&&(s.untrack&&s.untrack(),this.trackers.delete(t),this.emit("private:trackerStopped"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const t=document.querySelector("title");if(t){const s=new MutationObserver(()=>{this.fixTitle()});s.observe(t,{childList:!0}),this.titleObserver=s}}fixTitle(){const t=document.title,n="[Userflow Preview] "+t.replace(/\[Userflow Preview\]\s*/g,"");t!==n&&(document.title=n)}reportCspIssue(){const t=this.getSessionStorageState();(this.testUserIdentified||t.activeApp)&&!this.cspIssueReported&&(this.cspIssueReported=!0,o("csp issue detected"),A({kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(t){if(document.hidden)return;const s=this.getAudio();t&&(s.src=t);const n=s.play();this.audioReady=!0,n&&n.catch(i=>{i.name})}pauseAudio(){const t=this.audio;t&&!t.paused&&t.pause()}async getStepSpeech(t,s){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:t,text:s})).url}featureFlagEnabled(t){return this.featureFlags?this.featureFlags.has(t):!1}showNotification(t,s,n){const r={id:++this.notificationIdCounter,label:t,message:s,type:n};this.notifications=[...this.notifications,r],this.toggleUI()}dismissNotification(t){this.notifications=this.notifications.filter(s=>s.id!==t),this.toggleUI()}warn(...t){console.warn(...t)}nextRef(){return this.refCounter++}}if(typeof window.userflow>"u"||window.userflow._stubbed){const e=Object.assign(window.userflow||{},ct());window.userflow=e,window.studio1=e,lt()}function ct(){const e=new at;return{_stubbed:!1,init(t){e.init(t)},identify(t,s={},n={}){return e.identify(t,s,n)},identifyAnonymous(t={},s={}){return e.identifyAnonymous(t,s)},isIdentified(){return e.isIdentified()},updateUser(t,s={}){return e.updateUser(t,s)},group(t,s={},n={}){return e.group(t,s,n)},updateGroup(t,s={}){return e.updateGroup(t,s)},track(t,s={},n={}){return e.track(t,s,n)},start(t,{once:s}={}){return e.startFlow({flowId:t,startReason:p.USERFLOWJS,once:s})},startFlow(t){return console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(t)},startWalk(t){return console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(t)},endAll(){return e.endAllFlows()},endChecklist(){return e.endChecklist()},endAllFlows(){"Userflow.js: userflow.endAllFlows() has been deprecated. Use userflow.endAll() instead.";return window.userflow.endAll()},async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){e.openResourceCenter()},closeResourceCenter(){e.closeResourceCenter()},toggleResourceCenter(){e.toggleResourceCenter()},setResourceCenterLauncherHidden(t){e.setResourceCenterLauncherHidden(t)},getResourceCenterState(){return 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(t){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),t&&f.customInputs.push({cssSelector:t})},registerCustomInput(t,s){f.customInputs.push({cssSelector:t,getValue:s})},setCustomNavigate(t){f.customNavigate=t},setUrlFilter(t){f.urlFilter=t},setLinkUrlDecorator(t){f.linkUrlDecorator=t,e.emit("uistatechange")},setInferenceAttributeNames(t){f.inferenceAttributeNames=t},setInferenceAttributeFilter(t,s){f.inferenceAttributeFilters[t]=M(s)},setInferenceClassNameFilter(t){f.inferenceClassNameFilters=M(t)},setScrollPadding(t){f.scrollPadding=t},setCustomScrollIntoView(t){f.customScrollIntoView=t},prepareAudio(){e.playAudio(null)},setShadowDomEnabled(t){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(t){f.baseZIndex=t},setServerEndpoint(t){f.serverEndpoint=t},disableEvalJs(){f.evalJsDisabled=!0},_setTargetEnv(t){e.setTargetEnv(t)},debugger(){return e.mountDebugger()},mountSitePage(t,s){return e.mountSitePage(t,s)}}}function lt(){const e=window.userflow,t=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!(!t||t.length===0)){o(`processing ${t.length} items in the queue`);for(const[s,n,i]of t){if(typeof e[s]!="function"){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const r=e[s](...i);n&&r&&typeof r.then=="function"&&r.then(n.resolve,n.reject)}o("queue processed")}}var St=window.userflow;export{$e as $,Be as A,Te as B,S as C,Qe as D,U as E,ge as F,Ee as G,he as H,nt as I,st as J,R as K,ye as L,d as M,it as N,Le as O,Ue as P,Me as Q,He as R,P as S,Pe as T,h as U,qe as V,Xe as W,C as X,Ie as Y,Ae as Z,I as _,se as a,A as a0,x as a1,Z as a2,me as a3,ke as a4,we as a5,_e as a6,pe as a7,Ce as a8,ie as a9,De as aa,je as ab,Ve as ac,We as ad,Ge as ae,Ke as af,xe as ag,Fe as ah,Ye as ai,Ze as aj,Je as ak,ze as al,re as am,Se as b,f as c,o as d,St as default,Re as e,ve as f,m as g,p as h,Oe as i,be as j,le as k,oe as l,tt as m,ue as n,q as o,Ne as p,ce as q,ae as r,ft as s,Et as t,F as u,B as v,ne as w,de as x,fe as y,L as z};
17
+ If in doubt, reach out to us at support@userflow.com.`);this.pushRateLimitMinute++}handleServerMessage(t){o(`received ${t.kind} message`,t);const{serverClock:s,flowSession:n,flowSessionClock:i,checklistSession:r,checklistSessionClock:a,bannerSession:l,resourceCenterSession:u}=this;switch(t.kind){case"CheckSessionsAck":this.emit("private:checkSessionsAck");return;case"ServerDebug":return;case"AddLauncher":{const{session:c}=t,E=this.launcherSessions.findIndex(g=>g.flow.id===c.flow.id);E===-1?this.launcherSessions=[...this.launcherSessions,c]:this.launcherSessions=[...this.launcherSessions.slice(0,E),c,...this.launcherSessions.slice(E+1)],this.toggleUI();return}case"AddTracker":{this.addTracker(t.tracker);return}case"AssistantMessageEventWrapper":{this.emit("private:assistantMessageEvent",t);return}case"CancelConditionWaitTimer":window.clearTimeout(this.conditionWaitTimers.get(t.conditionId)),this.conditionWaitTimers.delete(t.conditionId);return;case"ChecklistTaskCompleted":this.unackedTasks.add(t.taskCvid);return;case"ForceGoToStep":if(i>s){o(`ignoring ${t.kind} message due to stale clock flowSessionClock=${i} > serverClock=${s}`);return}n?.id===t.sessionId&&this.emit("gotostep",{session:n,step:{id:t.stepId}});return;case"RemoveLauncher":this.removeLauncher(t.flowId)&&this.toggleUI();return;case"RemoveTracker":{this.removeTracker(t.flowId);return}case"SetBannerSession":this.setBannerSession(t.session),this.toggleUI();return;case"SetChecklistSession":a<=s||r?.id===t.session.id?(this.setChecklistSession(t.session,s),this.toggleUI()):o(`ignoring ${t.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return;case"SetFlowSession":i<=s||n?.id===t.session.id?(this.setFlowSession(t.session,s),this.emit("private:setFlowSession",t.session.version.id),this.toggleUI()):o(`ignoring ${t.kind} message due to stale clock flowSessionClock=${i} > serverClock=${s}`);return;case"SetResourceCenterSession":this.emit("private:resourceCenterSession",t.session),this.setResourceCenterSession(t.session),this.toggleUI();return;case"StartConditionWaitTimer":{if(!this.conditionWaitTimers.has(t.conditionId)){const c=window.setTimeout(()=>{this.conditionWaitTimers.delete(t.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:t.conditionId},{batch:!0})},parseFloat(t.waitTime)*1e3);this.conditionWaitTimers.set(t.conditionId,c)}return}case"TestStartConditionSuccess":this.emit("private:testStartConditionSuccess");return;case"TrackClientCondition":this.trackClientCondition(t.condition);return;case"UnsetBannerSession":l?.id===t.sessionId&&(this.setBannerSession(null),this.toggleUI());return;case"UnsetChecklistSession":if(a>s){o(`ignoring ${t.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return}r?.id===t.sessionId&&(this.setChecklistSession(null,s),this.toggleUI());return;case"UnsetFlowSession":if(i>s){o(`ignoring ${t.kind} message due to stale clock flowSessionClock=${i} > serverClock=${s}`);return}n?.id===t.sessionId&&(this.setFlowSession(null,s),this.toggleUI());return;case"UnsetResourceCenterSession":u?.id===t.sessionId&&(this.setResourceCenterSession(null),this.toggleUI());return;case"UntrackClientCondition":this.untrackClientCondition(t.conditionId);return;case"AddEmbed":{const c=this.embedSessions?.findIndex(E=>E.flow.id===t.session.flow.id);c!==void 0&&c>=0?this.embedSessions=[...this.embedSessions?.slice(0,c)||[],t.session,...this.embedSessions?.slice(c+1)||[]]:this.embedSessions=[...this.embedSessions||[],t.session],this.emit("uistatechange");break}case"RemoveEmbed":{this.embedSessions=(this.embedSessions||[]).filter(c=>c.flow.id!==t.flowId),this.emit("uistatechange");break}case"SetSiteSession":{this.siteSession=t.session,this.emit("private:siteSession",t.session);break}case"UnsetSiteSession":{this.siteSession=null,d.removeItem(w),this.emit("private:unsetSiteSession");break}case"SetWorkflowSession":{this.setWorkFlowSession(t.session),this.toggleUI();break}case"UnsetWorkflowSession":{this.setWorkFlowSession(null),this.toggleUI();break}case"WorkflowFillStepValue":{this.emit("private:workflowFillStepValue",t);break}default:console.warn("Userflow.js: Received unknown message",t);return}}async identify(t,s={},{signature:n}={}){if(o("identify",t),this.ensureInit(),this.testUserIdentified&&t!==this.externalId){o("identify() ignored since a test user has been identified");return}if(typeof t=="number")t=String(t);else if(!t||typeof t!="string")throw new h(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(t)}`);this.externalId&&t!==this.externalId&&(o("identify resetting due to new externalId"),this.reset()),this.externalId=t,this.signature=n||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(s)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}async identifyAnonymous(t={},s={}){if(!C.isSupported())throw new h("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const n="anonymousId";let i=C.getItem(n);i||(i="anon-"+b(),C.setItem(n,i)),await this.identify(i,t,s)}getInitToken(){return this.clientToken}getIdentifiedUser(){return{externalId:this.externalId}}async updateUser(t={},s={}){o("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(t)},{batch:!0})}async group(t,s={},{signature:n,membership:i}={}){if(o("group",t),this.ensureIdentified(),this.testUserIdentified&&t!==this.groupId){o("group() ignored since a test user has been identified");return}if(typeof t=="number")t=String(t);else if(!t||typeof t!="string")throw new h(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(t)}`);this.groupId=t,this.groupSignature=n||null,await this.send({kind:"UpsertGroup",groupExternalId:t,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(s),membershipAttributes:this.normalizeAttributes(i)},{batch:!0})}async updateGroup(t={},s={}){o("updateGroup");const n=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:n,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(s.membership),groupAttributes:this.normalizeAttributes(t)},{batch:!0})}normalizeAttributes(t){if(t==null)return{};if(typeof t!="object")throw new h("Userflow: 'attributes' must be an object.");const s={};for(const n in t){if(!t.hasOwnProperty(n))continue;if(n==="traits"){const r=t[n];Object.assign(s,this.extractLegacyTraits(r));continue}let i=t[n];if(typeof i=="string"||typeof i=="number"||typeof i=="boolean"||i==null||Array.isArray(i))s[n]=this.normalizeAttributeLiteralOrList(n,i);else{if(typeof i!="object"||i==null)throw new h(`Userflow: Invalid value for '${n}' attribute.`);if("set"in i)s[n]={set:this.normalizeAttributeLiteralOrList(n,i.set),dataType:this.normalizeDataType(n,i.data_type||i.dataType)};else if("set_once"in i||"setOnce"in i)s[n]={setOnce:this.normalizeAttributeLiteralOrList(n,i.set_once??i.setOnce),dataType:this.normalizeDataType(n,i.data_type||i.dataType)};else if("add"in i){const r=i.add;if(typeof r!="string"&&typeof r!="number")throw new h(`Userflow: Invalid 'add' value for '${n}' attribute. Must be a number or string.`);s[n]={add:r}}else if("subtract"in i){const r=i.subtract;if(typeof r!="string"&&typeof r!="number")throw new h(`Userflow: Invalid 'subtract' value for '${n}' attribute. Must be a number or string.`);s[n]={subtract:r}}else if("append"in i)s[n]={append:this.normalizeAttributeLiteralOrList(n,i.append)};else if("prepend"in i)s[n]={prepend:this.normalizeAttributeLiteralOrList(n,i.prepend)};else if("remove"in i)s[n]={remove:this.normalizeAttributeLiteralOrList(n,i.remove)};else throw new h(`Userflow: Invalid value for '${n}' attribute.`)}}return s}normalizeAttributeLiteralOrList(t,s){return Array.isArray(s)?s.map(n=>this.normalizeAttributeLiteral(t,n)):this.normalizeAttributeLiteral(t,s)}normalizeAttributeLiteral(t,s){if(s==null)return null;if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;throw new h(`Userflow: Invalid value for '${t}' attribute.`)}normalizeDataType(t,s){if(!s)return null;switch(s){case"string":return S.STRING;case"number":return S.NUMBER;case"boolean":return S.BOOLEAN;case"datetime":return S.DATETIME}throw new h(`Userflow: Invalid data_type for '${t}' attribute.`)}extractLegacyTraits(t){if(!t)return{};if(!Array.isArray(t)){const s=[];for(const n in t)t.hasOwnProperty(n)&&s.push({name:n,value:t[n]});t=s}return t.reduce((s,{name:n,value:i,dataType:r})=>{if(typeof n!="string"||n.length>100||!n.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:",n),s;if(typeof i!="string")if(typeof i=="boolean")r||(r="boolean"),i=i?"true":"false";else if(typeof i=="number")r||(r=Number.isInteger(i)?"integer":"decimal"),i=String(i);else return this.warn(`userflow.identify: The value of trait '${n}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,i),s;let a=null;if(r)switch(r){case"string":a=S.STRING;break;case"boolean":a=S.BOOLEAN;break;case"integer":a=S.NUMBER;break;case"decimal":a=S.NUMBER;break;case"datetime":a=S.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${n}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,r),s}return s[n]={set:i,dataType:a},s},{})}async track(t,s={},{userOnly:n}={}){o(`track '${t}'`,s),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!n,name:t,attributes:this.normalizeEventAttributes(s)},{batch:!0})}async trackRawEvent(t){const{name:s,attributes:n}=t;o(`track raw event '${s}'`,n),this.ensureIdentified(),await this.send({kind:"TrackRawEvent",name:s,attributes:this.normalizeEventAttributes(n)})}normalizeEventAttributes(t){const s=this.normalizeAttributes(t);for(const n in s){if(!s.hasOwnProperty(n))continue;const i=s[n];if(!(i==null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||Array.isArray(i)||"set"in i))throw new h(`Userflow: Invalid value for '${n}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return s}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout(()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()},0))}onceIdentified(t){this.isIdentified()?t():this.firstIdentifyCallback=t}checkUrlForStartFlow(){const t=new URL(m()),s=t.searchParams.get("userflow")||t.searchParams.get("studio1_flow")||t.searchParams.get("studio1_walkthrough");s&&(o(`url contained flow ${s}`),this.startFlow({flowId:s,startReason:p.LINK,batch:!0}),t.searchParams.delete("userflow"),t.searchParams.delete("studio1_flow"),t.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",t.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const t=this.buildClientContext();(!this.clientContext||t.pageUrl!==this.clientContext.pageUrl)&&(this.clientContext=t,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.featureFlags&&this.featureFlagEnabled("cff_disable_page_views")===!0||(this.pageTrackingDisabled||this.track("page_viewed",{}),this.trackRawPageViewed())}async trackRawPageViewed(){this.featureFlags&&(this.featureFlagEnabled("cff_implicit_events")===!1||this.featureFlagEnabled("cff_disable_page_views")===!0)||this.trackRawEvent({name:"page_viewed",attributes:{id:b(),page_title:document.title,...this.buildClientContext()}})}buildClientContext(){let t=null;const s=d.getItem(w);if(s){const i=new URL(m()).pathname.match(/^\/([^/]+)\/?(?:\/([^/]+)\/?)?$/);i&&(t=i[1])}return{pageUrl:tt(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,...s&&{siteId:s},...t&&{localeCode:t}}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(t){this.unackedTasks.delete(t)}taskIsUnacked(t){return this.unackedTasks.has(t)}isIdentified(){return this.externalId!=null}on(t,s){let n=this.listeners.get(t);n||(n=new Set,this.listeners.set(t,n)),n.add(s)}off(t,s){const n=this.listeners.get(t);n&&n.delete(s)}emit(t,...s){const n=this.listeners.get(t);n&&Array.from(n).forEach(r=>r(...s))}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){o("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setBannerSession(null),this.setResourceCenterSession(null),this.resourceCenterLauncherHidden=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((t,s)=>{this.untrackClientCondition(s)}),this.firstIdentifyCallback=null,this.testUserIdentified=!1,C.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:t,stepCvid:s,startReason:n,once:i,batch:r,replaceCurrent:a}){if(this.ensureIdentified(),a&&this.flowSession&&this.endFlow(this.flowSession,{endReason:U.REPLACED,batch:!0}),o(`startFlow ${t}`,{startReason:n}),this.checklistSession?.flow.id===t){o("startFlow matches current checklist, so showing it instead"),this.showChecklist();return}const l={kind:"StartFlow",flowId:t,stepCvid:s,startReason:n,once:!!i};await this.send(l,{batch:r})}async trackButtonEvent(t,s,n,i){const r={kind:"TrackButtonEvent",eventName:t,stepCvid:n,sessionId:i,token:s};await this.send(r,{batch:!0})}async startFlowWithToken(t){this.ensureIdentified(),o("startFlowWithToken",{token:t}),await this.send({kind:"StartFlowWithToken",token:t},{batch:!0})}optimisticClockUIUpdate(t){this.clientClock++,t(),this.toggleUI()}async showChecklist(){if(this.resourceCenterEmbedsChecklist()&&!this.embedChecklistSessions()){this.openResourceCenter();return}this.embedChecklistSessions()||(this.unmarkExpandPending(),!(!this.checklistSession||this.checklistExpanded)&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),d.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0})))}async hideChecklist(){if(this.resourceCenterEmbedsChecklist()){this.closeResourceCenter();return}!this.checklistSession||!this.checklistExpanded||(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),d.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"),d.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"),d.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(t){this.resourceCenterLauncherHidden=t,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const t=this.resourceCenterEmbedsChecklist(),{checklistSession:s}=this,n=this.resourceCenterSession.version.resourceCenter?.blocks.find(i=>i.type===R.ANNOUNCEMENTS);return{isOpen:this.resourceCenterOpen,hasChecklist:t,uncompletedChecklistTaskCount:t&&s?it(s):0,unreadAnnouncementCount:n?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const t=this.resourceCenterSession;return!!t&&!!t.version.resourceCenter?.blocks.some(s=>s.type===R.CHECKLIST)}embedChecklistSessions(){return this.embedSessions.some(t=>!!t.version.embed?.blocks?.some(s=>s.type===K.CHECKLIST))}async endFlow(t,{endReason:s,batch:n}){this.ensureIdentified(),this.optimisticClockUIUpdate(()=>{const{clientClock:l}=this;this.flowSession?.id===t.id&&this.setFlowSession(null,l),this.checklistSession?.id===t.id&&this.setChecklistSession(null,l),this.bannerSession?.id===t.id&&this.setBannerSession(null),this.resourceCenterSession?.id===t.id&&this.setResourceCenterSession(null),this.workflowSession?.id===t.id&&this.setWorkFlowSession(null)});const{flow:i}=t,r={id:i.id,type:i.type.toLowerCase()};i.type===L.CHECKLIST?this.emit("checklistEnded",{checklist:r,endReason:s}):i.type===L.FLOW&&this.emit("flowEnded",{flow:r,endReason:s});const a={kind:"EndFlow",sessionId:t.id,endReason:s};await this.send(a,{batch:n})}async goToStep(t,s){o("goToStep",t.id,s.name||s.id),this.ensureIdentified();const n=this.send({kind:"GoToStep",sessionId:t.id,stepId:s.id});t.currentStep=s,this.emit("gotostep",{session:t,step:s}),await n}async endAllFlows(){o("endAllFlows"),this.optimisticClockUIUpdate(()=>{const{clientClock:t}=this;this.setFlowSession(null,t),this.setChecklistSession(null,t)}),await this.send({kind:"EndAllFlows"})}async endChecklist(){o("endChecklist");const t=this.checklistSession||this.flowSession;t?.flow.type===L.CHECKLIST&&this.endFlow(t,{endReason:U.USERFLOWJS})}setFlowSession(t,s=this.clientClock){const n=this.flowSession;this.flowSession=t,this.flowSessionClock=s,t&&!n&&(this.hideChecklist(),this.closeResourceCenter()),t==null&&this.originalActiveElement&&(typeof this.originalActiveElement.focus=="function"&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setWorkFlowSession(t){this.workflowSession=t}setChecklistSession(t,s=this.clientClock){const n=this.checklistSession;this.checklistSession=t,this.checklistSessionClock=s,t===null&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),t&&t.id!==n?.id&&(this.checklistExpanded=!!d.getItem(`checklistExpanded:${t.id}`),t.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setBannerSession(t){this.bannerSession=t}setResourceCenterSession(t){const s=this.resourceCenterSession;t=typeof t=="function"?t(this.resourceCenterSession):t,this.resourceCenterSession=t,t===null&&(this.resourceCenterOpen=!1),s&&s.id!==t?.id&&d.removeItem(`resourceCenterOpen:${s.id}`),t&&t.id!==s?.id&&(this.resourceCenterOpen=!!d.getItem(`resourceCenterOpen:${t.id}`)),this.emit("resourceCenterChanged")}launcherSeen(t){this.send({kind:"StartFlow",flowId:t,startReason:p.LAUNCHER_SEEN,once:!1})}activateLauncher(t){const s=this.activeLauncherFlowId&&this.launcherSessions.find(n=>n.flow.id===this.activeLauncherFlowId);s&&this.deactivateLauncher(s),this.activeLauncherFlowId=t.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:t.flow.id})}deactivateLauncher(t){const{launcher:s}=t.version;t.flow.id===this.activeLauncherFlowId&&(s?.dismissOn===V.DEACTIVATE?this.dismissLauncher(t,{endReason:U.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(t,{endReason:s}){const n=t.flow.id;this.removeLauncher(n),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:n,endReason:s})}removeLauncher(t){const s=this.launcherSessions.findIndex(n=>n.flow.id===t);return s===-1?!1:(this.launcherSessions=[...this.launcherSessions.slice(0,s),...this.launcherSessions.slice(s+1)],t===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const t=this.getSessionStorageState();!this.flowSession&&!this.workflowSession&&(this.checklistExpandPending||this.checklistSession?.version.checklist?.tasks.some(s=>this.taskIsUnacked(s.cvid)))&&this.showChecklist(),t.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){return this.uiDisabled||this.siteSession?.id||d.getItem(w)?!1:!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.workflowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.bannerSession||!!this.resourceCenterSession||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const t=await this.createUI();this.shouldBeMounted()&&!this.ui&&(o("mount UI"),this.ui=t,this.ui.mount())}}unmountUI(){this.ui&&(o("unmount UI"),this.ui.unmount(),this.ui=null)}checkDebuggerSession(){if(this.debuggerUI)return;const t=this.sessionStorageState?.debuggerApp;t&&t?.x&&t?.y&&this.mountDebugger()}async mountDebugger(){if(!this.debuggerMountInProgress){if(this.debuggerUI){this.debuggerUI.unmount();return}this.debuggerMountInProgress=!0;try{const{DebuggerUI:t}=await I(async()=>{const{DebuggerUI:s}=await import("./DebuggerUI.js");return{DebuggerUI:s}},__vite__mapDeps([50,1,2,18,19,3,4,5,6,17,12,13,14,9,10,11,20,22,15,48,47,46,28,33,34]));this.debuggerUI=new t(this,N),this.debuggerUI.mount()}catch(t){console.error("Userflow: Failed to mount debugger UI",t)}finally{this.debuggerMountInProgress=!1}}}unMountDebugger(){this.debuggerUI=null}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const t=I(()=>import("./ui.js"),__vite__mapDeps([51,1,2,18,19,3,4,5,6,33,34]));this.bannerSession&&nt(),this.resourceCenterSession&&st();const{RealUI:s}=await t;return new s(this)}catch(t){throw this.reportCspIssue(),t}}async trackClientCondition(t){if(this.clientConditions.has(t.id))return;o("track client condition",t),this.clientConditions.set(t.id,{condition:t,isTrue:null});const{conditionTypes:s}=await I(async()=>{const{conditionTypes:r}=await import("./flow-condition-types.js").then(a=>a.f);return{conditionTypes:r}},__vite__mapDeps([9,2,10,5,11])),n=s[t.type],i=this.clientConditions.get(t.id);i&&(i.untrack=n.track({sessionData:new P([]),condition:t,callback:r=>{i.isTrue!==r&&(o("client condition truthiness changed",r,i.condition),i.isTrue=r,this.send({kind:"ToggleClientCondition",conditionId:t.id,isTrue:r},{batch:!0}))}}))}untrackClientCondition(t){const s=this.clientConditions.get(t);s&&(o("untrack client condition",s.condition),s.untrack&&s.untrack(),this.clientConditions.delete(t))}async addTracker(t){let s=this.trackers.get(t.flowId);s?s.tracker=t:this.trackers.set(t.flowId,{tracker:t,isTrue:!1});const{conditionTypes:n}=await I(async()=>{const{conditionTypes:u}=await import("./flow-condition-types.js").then(c=>c.f);return{conditionTypes:u}},__vite__mapDeps([9,2,10,5,11])),i=this.trackers.get(t.flowId);if(!i)return;const{tracker:r}=i,{condition:a}=r,l=n[a.type];i.untrack&&i.untrack(),i.untrack=l.track({sessionData:new P(r.data),condition:a,flipBackEvents:!0,callback:u=>{const c=i.isTrue;i.isTrue=u,!c&&u&&this.send({kind:"TrackTrackerEvent",token:r.token},{batch:!0})},description:`event tracker ${r.flowId}`}),this.emit("private:trackerStarted")}removeTracker(t){const s=this.trackers.get(t);s&&(s.untrack&&s.untrack(),this.trackers.delete(t),this.emit("private:trackerStopped"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const t=document.querySelector("title");if(t){const s=new MutationObserver(()=>{this.fixTitle()});s.observe(t,{childList:!0}),this.titleObserver=s}}fixTitle(){const t=document.title,n="[Userflow Preview] "+t.replace(/\[Userflow Preview\]\s*/g,"");t!==n&&(document.title=n)}reportCspIssue(){const t=this.getSessionStorageState();(this.testUserIdentified||t.activeApp)&&!this.cspIssueReported&&(this.cspIssueReported=!0,o("csp issue detected"),A({kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(t){if(document.hidden)return;const s=this.getAudio();t&&(s.src=t);const n=s.play();this.audioReady=!0,n&&n.catch(i=>{i.name})}pauseAudio(){const t=this.audio;t&&!t.paused&&t.pause()}async getStepSpeech(t,s){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:t,text:s})).url}featureFlagEnabled(t){return this.featureFlags?this.featureFlags.has(t):!1}showNotification(t,s,n){const r={id:++this.notificationIdCounter,label:t,message:s,type:n};this.notifications=[...this.notifications,r],this.toggleUI()}dismissNotification(t){this.notifications=this.notifications.filter(s=>s.id!==t),this.toggleUI()}warn(...t){console.warn(...t)}nextRef(){return this.refCounter++}}if(typeof window.userflow>"u"||window.userflow._stubbed){const e=Object.assign(window.userflow||{},ct());window.userflow=e,window.studio1=e,lt()}function ct(){const e=new at;return{_stubbed:!1,init(t){e.init(t)},identify(t,s={},n={}){return e.identify(t,s,n)},identifyAnonymous(t={},s={}){return e.identifyAnonymous(t,s)},isIdentified(){return e.isIdentified()},updateUser(t,s={}){return e.updateUser(t,s)},group(t,s={},n={}){return e.group(t,s,n)},updateGroup(t,s={}){return e.updateGroup(t,s)},track(t,s={},n={}){return e.track(t,s,n)},start(t,{once:s}={}){return e.startFlow({flowId:t,startReason:p.USERFLOWJS,once:s})},startFlow(t){return console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(t)},startWalk(t){return console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(t)},endAll(){return e.endAllFlows()},endChecklist(){return e.endChecklist()},endAllFlows(){"Userflow.js: userflow.endAllFlows() has been deprecated. Use userflow.endAll() instead.";return window.userflow.endAll()},async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){e.openResourceCenter()},closeResourceCenter(){e.closeResourceCenter()},toggleResourceCenter(){e.toggleResourceCenter()},setResourceCenterLauncherHidden(t){e.setResourceCenterLauncherHidden(t)},getResourceCenterState(){return 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(t){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),t&&f.customInputs.push({cssSelector:t})},registerCustomInput(t,s){f.customInputs.push({cssSelector:t,getValue:s})},setCustomNavigate(t){f.customNavigate=t},setUrlFilter(t){f.urlFilter=t},setLinkUrlDecorator(t){f.linkUrlDecorator=t,e.emit("uistatechange")},setInferenceAttributeNames(t){f.inferenceAttributeNames=t},setInferenceAttributeFilter(t,s){f.inferenceAttributeFilters[t]=M(s)},setInferenceClassNameFilter(t){f.inferenceClassNameFilters=M(t)},setScrollPadding(t){f.scrollPadding=t},setCustomScrollIntoView(t){f.customScrollIntoView=t},prepareAudio(){e.playAudio(null)},setShadowDomEnabled(t){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(t){f.baseZIndex=t},setServerEndpoint(t){f.serverEndpoint=t},disableEvalJs(){f.evalJsDisabled=!0},_setTargetEnv(t){e.setTargetEnv(t)},debugger(){return e.mountDebugger()},mountSitePage(t,s){return e.mountSitePage(t,s)}}}function lt(){const e=window.userflow,t=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!(!t||t.length===0)){o(`processing ${t.length} items in the queue`);for(const[s,n,i]of t){if(typeof e[s]!="function"){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const r=e[s](...i);n&&r&&typeof r.then=="function"&&r.then(n.resolve,n.reject)}o("queue processed")}}var St=window.userflow;export{$e as $,Be as A,Te as B,S as C,Qe as D,U as E,ge as F,Ee as G,he as H,nt as I,st as J,R as K,ye as L,d as M,it as N,Le as O,Ue as P,Me as Q,He as R,P as S,Pe as T,h as U,qe as V,Xe as W,C as X,Ie as Y,Ae as Z,I as _,se as a,A as a0,x as a1,Z as a2,me as a3,ke as a4,we as a5,_e as a6,pe as a7,Ce as a8,ie as a9,De as aa,je as ab,Ve as ac,We as ad,Ge as ae,Ke as af,xe as ag,Fe as ah,Ye as ai,Ze as aj,Je as ak,ze as al,re as am,Se as b,f as c,o as d,St as default,Re as e,ve as f,m as g,p as h,Oe as i,be as j,le as k,oe as l,tt as m,ue as n,q as o,Ne as p,ce as q,ae as r,ft as s,Et as t,F as u,B as v,ne as w,de as x,fe as y,L as z};
18
18
  //# sourceMappingURL=userflow.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="2f35dc0a-d9cd-4fce-9fe8-183467b8f50e",e._sentryDebugIdIdentifier="sentry-dbid-2f35dc0a-d9cd-4fce-9fe8-183467b8f50e")}catch{}})();var p=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};p.SENTRY_RELEASE={id:"b6c0394157e958e4e2db076529693a5e99b56c32"};var y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function w(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var i,c;function j(){if(c)return i;c=1;var e=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;function b(t){if(t==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function g(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de",Object.getOwnPropertyNames(t)[0]==="5")return!1;for(var d={},r=0;r<10;r++)d["_"+String.fromCharCode(r)]=r;var f=Object.getOwnPropertyNames(d).map(function(n){return d[n]});if(f.join("")!=="0123456789")return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(n){o[n]=n}),Object.keys(Object.assign({},o)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return i=g()?Object.assign:function(t,d){for(var r,f=b(t),o,n=1;n<arguments.length;n++){r=Object(arguments[n]);for(var l in r)s.call(r,l)&&(f[l]=r[l]);if(e){o=e(r);for(var a=0;a<o.length;a++)u.call(r,o[a])&&(f[o[a]]=r[o[a]])}}return f},i}export{y as c,w as g,j as r};
1
+ (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="7b5cfb5a-bc86-43b3-885b-228d4164c4d2",e._sentryDebugIdIdentifier="sentry-dbid-7b5cfb5a-bc86-43b3-885b-228d4164c4d2")}catch{}})();var p=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};p.SENTRY_RELEASE={id:"d31ee62740661529ba54853368d683ac9c3728b4"};var y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function w(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var b,u;function j(){if(u)return b;u=1;var e=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function c(t){if(t==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function g(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de",Object.getOwnPropertyNames(t)[0]==="5")return!1;for(var l={},r=0;r<10;r++)l["_"+String.fromCharCode(r)]=r;var a=Object.getOwnPropertyNames(l).map(function(n){return l[n]});if(a.join("")!=="0123456789")return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(n){o[n]=n}),Object.keys(Object.assign({},o)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return b=g()?Object.assign:function(t,l){for(var r,a=c(t),o,n=1;n<arguments.length;n++){r=Object(arguments[n]);for(var d in r)s.call(r,d)&&(a[d]=r[d]);if(e){o=e(r);for(var f=0;f<o.length;f++)i.call(r,o[f])&&(a[o[f]]=r[o[f]])}}return a},b}export{y as c,w as g,j as r};
2
2
  //# sourceMappingURL=vendor.object-assign.js.map