userflow.js-self-hosted 0.1.1024673 → 0.1.1024807

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.
@@ -1,5 +1,5 @@
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"])))=>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 Jr}from"./use-element-rect.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]="9b419714-5826-4de7-8e81-b5b1d602cb58",t._sentryDebugIdIdentifier="sentry-dbid-9b419714-5826-4de7-8e81-b5b1d602cb58")}catch{}})();function Yr(t,r,n){return!t.resourceCenterAutoDividers||r===S.DIVIDER||n===S.DIVIDER?!1:Lt(r)||Lt(n)}function Lt(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})=>{en();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
- `+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");tn();let n=!1,s=!1;const o=()=>{n||s?(Mt(),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:()=>{Mt(),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),rn();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 nn(),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");sn();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 Je.add(n),Ye.add(s),on(),()=>{Je.delete(n),Ye.delete(s)}},show:()=>{f.zE("messenger","open")},hide:()=>{f.zE("messenger","close")}}};let xt=!1;function en(){xt||(xt=!0,f.$crisp||(f.$crisp=[]),f.$crisp.push(["do","chat:hide"]))}let Bt=!1;function tn(){Bt||(Bt=!0,$e())}function Mt(){f.Beacon("config",{display:{style:"icon"}})}function $e(){f.Beacon("config",{display:{style:"manual"}})}let Dt=!1,st=!1;function rn(){Dt||(Dt=!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 Pt=!1,Ke=new Set,Qe=new Set;function nn(){if(Pt)return;Pt=!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 Ft=!1,Ze=new Set,Ge=new Set,Xe=new Set;function sn(){Ft||(Ft=!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 Ut=!1,Je=new Set,Ye=new Set;function on(){Ut||(Ut=!0,f.zE("messenger:on","open",function(){for(const t of Je)t()}),f.zE("messenger:on","close",function(){for(const t of Ye)t()}))}const cn=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"})),an=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)},an)},[r]);return a.useEffect(()=>()=>{window.clearTimeout(o.current)},[]),[n,l,c]}const ln={xs:[16,3],sm:[24,4],md32:[32,4],md:[40,4],lg:[56,4]};class un 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]=ln[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 dn=({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(un,{indeterminate:!0,size:"xs",color:"purple"})),C)},mn=({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(dn,{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 fn(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function Gt(t){return Ae.linkUrlDecorator?Ae.linkUrlDecorator(t):t}function hn(t){if(!t)return null;let r;"block"in t&&t.block!=null&&(r=t.block.cvid);const n={kind:t.kind,blockCvid:r};return t.kind==="announcementShow"&&(n.announcementId=t.announcementId),JSON.stringify(n)}function Ot(t,r){if(!r)return null;const n=JSON.parse(r);let s;if(n.blockCvid&&(s=t.version.resourceCenter?.blocks.find(c=>c.cvid===n.blockCvid)),!s&&n.kind!=="search")return null;const o={kind:n.kind,block:s};return o.kind==="announcementShow"&&(o.announcementId=n.announcementId),o}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]))).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(!fn())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(()=>Ot(t,ae.getItem(`resourceCenterRoute:v1:${t.id}`))),D=a.useCallback((d,v)=>{pe(d);const I=hn(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(Ot(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]),J=Q.length===1,Me=a.useMemo(()=>tr(Q),[Q]);a.useEffect(()=>{if(!r||!J)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,J]);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,Y,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(Yt,{session:I,open:Ee,navigate:D,block:v,announcement:d,onDismiss:gt,isStandalonePopout:Ne?.isStandalonePopout,rcPlacement:Y.resourceCenterPlacement}))},[c,Ee,D]),pr=(d,v,I)=>{const Y={...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:Y,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&&(!J||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=!J&&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(cn,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],Y=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}),Y&&Yr(u,d.type,Y.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":!!(J&&q?.icon)})},J&&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(Jt,{count:r,onClick:n}))},Jt=({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)},Yt=({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}=Jr();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(Jt,{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(mn,{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 qn=Object.freeze(Object.defineProperty({__proto__:null,FloatingAnnouncements:Yt,LauncherUnreadBadge:Xt,ModalAnnouncement:er,ResourceCenterApp:Wt,default:Wt,formatAnnouncementTime:Re,getAnnouncementsBlock:ar,markAnnouncementSeen:O,syncAnnouncementSeen:ct},Symbol.toStringTag,{value:"Module"}));export{mn as A,dn as G,Xt as L,qn as R,ye as c,Gt as d,Re as f,O as m,hn as s};
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";
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};
5
5
  //# sourceMappingURL=ResourceCenterApp.js.map
@@ -1,5 +1,5 @@
1
- import{r as c,R as t}from"./vendor.react.js";import{ai as pe,aj as C,ak as ye,al as se,am as B,L as ne,h as ae,M as re,E as Ae}from"./userflow.js";import{A as Le,d as Te,G as xe,c as oe}from"./ResourceCenterApp.js";import{u as De}from"./client-context.js";import{a7 as be,h as He,a0 as Pe,a8 as le,a9 as ce,aa as ie,ab as J,ac as ue,ad as Y,ae as fe}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{p as We}from"./vendor.dompurify.js";import{m as Ke}from"./vendor.marked.js";import{o as z}from"./vendor.obj-str.js";import{r as Ee,R as X,s as $e,n as Oe}from"./TreeDoc.js";import{D as L}from"./stylesheets.js";import{U as _e}from"./roots.js";import{r as de}from"./vendor.react-dom.js";import{S as ke}from"./AnnouncementEngagement.js";import"./vendor.object-assign.js";import{u as Z}from"./vendor.react-i18next.js";import{g as me}from"./flow-condition-types.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./flow-host.styl.js";import"./use-selector-element-monitoring.js";import"./Frame.js";import"./iframe-reset.styl.js";import"./use-window-resize.js";import"./logomark.js";import"./ChecklistUI.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./FlowChrome.js";import"./use-confetti.js";import"./vendor.canvas-confetti.js";import"./vendor.memoize-one.js";import"./vendor.bignumber.js.js";import"./use-element-rect.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="d0b0923e-ab5f-4e17-9092-bd220d978f05",s._sentryDebugIdIdentifier="sentry-dbid-d0b0923e-ab5f-4e17-9092-bd220d978f05")}catch{}})();function Ue(s){const e=Intl.Segmenter;return e?/(\p{Emoji_Presentation}|\p{Extended_Pictographic})(\p{Emoji_Modifier_Base}?\p{Emoji_Modifier}?|\uFE0F\u200D(\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?\uFE0F\u200D)*\p{Emoji_Presentation}|\uFE0F\u200D\p{Extended_Pictographic})/u.test(s)&&[...new e().segment(s)].length===1:!1}const he=[];function Be({assistant:s,lookupAttribute:e,initialConversationId:r,initialHistory:u,initialUserContent:w,onConversationIdChange:f,submitMessage:b,submitRating:h,submitFeedback:g,InsideMessage:n,onContactClick:p,contactButtonText:i,onHandoverClick:m,onFlowSuggestionClick:o}){const[k,M]=c.useState(null),[l,d]=c.useState(()=>u?u.map(a=>({...a,assistantHtml:K(Q(a.assistantContent),!1)})):he),[_,N]=c.useState(""),I=c.useRef(null),y=c.useRef(null),S=c.useRef(!0),T=c.useRef(r||null),[F,x]=c.useState(T.current),j=c.useCallback(a=>{T.current=a,x(a),f&&f(a)},[f]),D=c.useCallback(()=>{k?.focus({preventScroll:!0})},[k]);c.useEffect(()=>{D()},[D]),c.useLayoutEffect(()=>{const a=y.current;a&&(a.scrollTop=Math.ceil(a.scrollHeight-a.clientHeight))},[]);const v=c.useCallback(()=>{const a=y.current;a&&(S.current=!0,typeof a.scrollTo=="function"&&a.scrollTo({top:Math.ceil(a.scrollHeight-a.clientHeight),behavior:"smooth"}))},[]),$=c.useRef(0);c.useLayoutEffect(()=>{const a=y.current;a&&a.scrollHeight!==$.current&&($.current=a.scrollHeight,S.current&&v())},[l,v]);const W=c.useCallback(()=>{I.current&&I.current()},[]);c.useEffect(()=>()=>{W()},[W]);const q=(a,R)=>{d(H=>H.map(A=>{if(a===A.id){const P=R(A);return{...A,...P}}else return A}))},O=a=>{d(R=>R.map((H,A)=>{if(A===R.length-1){const P=a(H);return{...H,...P}}else return H}))},G=c.useCallback(a=>{const{userContent:R,workflow:H}=a;W(),d(E=>[...E,{id:null,userContent:R??"",assistantContent:"",assistantFallbackContent:null,assistantHtml:K("","enter"),enterAnimation:!0,sources:[],flowSuggestions:[],completed:!1,rating:null,scaleRating:null,scaleMax:null,feedbackSubmitted:!1,handover:null,workflowMessageType:H?pe.INITIAL:null}]),v();let A=!1;const P=()=>{A=!0,I.current=null},Re=b({conversationId:T.current,userContent:R??"",workflow:H,callback:E=>{if(A){console.log("Userflow.js AssistantChat got message after being done",E);return}switch(E.kind){case"conversation_created":j(E.conversationId);break;case"message_created":O(()=>({id:E.messageId,warning:E.warning,workflowMessageType:E.workflowMessageType}));break;case"assistant_content_delta":O(U=>{const te=U.assistantContent+E.delta;return{assistantContent:te,assistantHtml:K(Q(te))}});break;case"done":P(),O(U=>({assistantHtml:K(U.assistantContent,"exit"),assistantFallbackContent:E.fallbackContent,flowSuggestions:E.flowSuggestions,completed:!0,sources:E.sources,handover:E.handover}));break;case"error":P(),O(U=>({failed:!0,error:E.message,assistantHtml:K(Q(U.assistantContent),!1)}));break;default:console.log("Userflow.js AssistantChat got unknown message",E)}}});I.current=()=>{P(),Re.abort(),O(E=>({assistantHtml:K(Q(E.assistantContent),!1)}))}},[W,v,j,b]),V=c.useCallback(a=>{a=a.trim(),a!==""&&(N(""),G({userContent:a}))},[G]),ee=c.useRef(!1);c.useEffect(()=>{ee.current||(ee.current=!0,w&&V(w))},[V,w]);const ve=c.useCallback(a=>{G({userContent:"Hey, can you please fill in the field",workflow:a})},[G]),Ie=c.useCallback(()=>{W(),j(null),d(he),D()},[W,D,j]),[je,Me]=c.useState(!0),Ne=c.useCallback(()=>{const a=y.current;a&&Me(a.scrollTop===0)},[]),Fe=c.useCallback(()=>{const a=y.current;a&&(S.current=Math.ceil(a.scrollHeight-a.clientHeight)==Math.ceil(a.scrollTop))},[]);return{assistant:s,lookupAttribute:e,history:l,setInput:M,contentElRef:y,scrolledToTop:je,userContent:_,setUserContent:N,onSubmitMessage:V,supportsFeedback:!!h&&!!g,onSubmitRating:async a=>{if(!h)return;switch(a.ratingMode){case C.LIKE:q(a.messageId,()=>({rating:a.rating}));break;case C.SCALE:q(a.messageId,()=>({scaleRating:a.scaleRating,scaleMax:a.scaleMax}));break;default:throw new _e(a)}const R=await h(a);R?.handover&&q(a.messageId,()=>({handover:R.handover}))},onSubmitFeedback:a=>{g&&(q(a.messageId,()=>({feedbackSubmitted:!0})),g(a))},onFlowSuggestionClick:o,InsideMessage:n,onContactClick:p,contactButtonText:i,onHandoverClick:m,reset:Ie,scrollToBottom:v,onContentScroll:Ne,onContentWheel:Fe,conversationId:F,startWorkflowFill:ve}}const ze=({assistant:s,lookupAttribute:e,history:r,setInput:u,contentElRef:w,scrolledToTop:f,userContent:b,setUserContent:h,onSubmitMessage:g,supportsFeedback:n,onSubmitRating:p,onSubmitFeedback:i,onFlowSuggestionClick:m,InsideMessage:o,onContactClick:k,contactButtonText:M,onHandoverClick:l,reset:d,scrollToBottom:_,onContentScroll:N,onContentWheel:I,conversationId:y,workflowSession:S,onCancelWorkflow:T})=>{const{t:F}=Z();c.useEffect(()=>{_()},[S,_]);const x=r.some(v=>v.completed||v.failed),[j,D]=c.useState(null);return t.createElement("div",{className:"userflowjs-assistant-chat"},t.createElement("div",{className:z({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})}),t.createElement("div",{className:z({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})},t.createElement(t.Fragment,null,t.createElement("h2",{className:"userflowjs-assistant-chat__title"},s.title),t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:d},s.resetText))),t.createElement("div",{ref:w,className:"userflowjs-assistant-chat__content",onScroll:N,onWheel:I},!Ee(s.intro)&&t.createElement("div",{className:"userflowjs-assistant-chat__intro"},t.createElement(X,{doc:s.intro,lookupAttribute:e})),r.map((v,$)=>t.createElement(qe,{key:$,assistant:s,message:v,supportsFeedback:n,onSubmitRating:p,onSubmitFeedback:i,InsideMessage:o,conversationId:y,isLast:$===r.length-1,onFlowSuggestionClick:m,onRequestConfirm:D,onHandoverClick:l}))),j?t.createElement("div",{className:"userflowjs-bubble-buttons userflowjs-assistant-chat__confirm"},t.createElement("p",{className:"userflowjs-assistant-chat__confirm-text"},F("resource_center.confirm_action")),t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:()=>D(null)},F("resource_center.deny")),t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",disabled:!!S,onClick:async()=>{if(S)return;const v=j;D(null),await m(v)}},F("resource_center.allow"))):t.createElement(t.Fragment,null,S&&t.createElement("div",{className:"userflowjs-assistant-workflow__status"},t.createElement("div",{className:"userflowjs-assistant-workflow__status-message"},t.createElement(ke,null),F("resource_center.workflow_in_progress")),t.createElement("button",{className:"userflowjs-workflow-cancel-button",onClick:T},F("resource_center.cancel_workflow"))),t.createElement("div",{className:"userflowjs-assistant-chat__prompt"},t.createElement(Le,{textareaRef:u,placeholder:(r.length===0?s.promptEmptyPlaceholder:s.promptNonemptyPlaceholder)||"",value:b,onChange:h,onSubmit:()=>g(b)}))),x&&k&&t.createElement("div",{className:"userflowjs-assistant-chat__contact"},t.createElement("button",{className:"userflowjs-tertiary-button",onClick:()=>k()},M)))},qe=({assistant:s,message:e,supportsFeedback:r,onSubmitRating:u,onSubmitFeedback:w,onFlowSuggestionClick:f,onRequestConfirm:b,onHandoverClick:h,InsideMessage:g,conversationId:n,isLast:p})=>{const i=!Ee(e.assistantFallbackContent),m=e.workflowMessageType===pe.INITIAL,o=e.flowSuggestions[0],[k,M]=c.useState(!1),{t:l}=Z(),d=async()=>{if(o.flowType===se.WORKFLOW){b({messageId:e.id,flowSuggestion:o});return}try{M(!0),await f({messageId:e.id,flowSuggestion:o})}finally{M(!1)}};return t.createElement("div",{className:"userflowjs-assistant-chat__message"},g&&t.createElement(g,{message:e}),!m&&t.createElement("div",{className:z({"userflowjs-assistant-chat__user-content":!0,"userflowjs-assistant-chat__user-content--enter":!!e.enterAnimation}),"data-assistant-conversation-id":n,"data-assistant-message-id":e.id},t.createElement("div",{style:{whiteSpace:"pre-wrap"}},e.userContent)),e.warning&&t.createElement("div",{className:"userflowjs-assistant-chat__error"},"Warning: ",e.warning),t.createElement("div",{className:"userflowjs-assistant-chat__assistant-content"},i&&t.createElement("div",null,t.createElement(X,{doc:e.assistantFallbackContent})),!i&&t.createElement("div",null,t.createElement(Je,{html:e.assistantHtml})),e.error&&t.createElement("div",{className:"userflowjs-assistant-chat__error"},e.error)),e.handover&&t.createElement("div",{className:"userflowjs-assistant-chat__handover"},e.handover.message&&t.createElement("div",{className:"userflowjs-assistant-chat__handover-message"},t.createElement(X,{doc:e.handover.message})),t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-assistant-chat__handover-button",onClick:e.id&&h?()=>h({messageId:e.id}):void 0},t.createElement("span",{className:"userflowjs-assistant-chat__handover-button-content "},e.handover.buttonIcon&&t.createElement(L,{icon:e.handover.buttonIcon,size:16}),t.createElement("span",null,e.handover.buttonText)),t.createElement(L,{icon:be,size:16}))),e.id&&o&&t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-assistant-chat__flow-suggestion",onClick:d},t.createElement("span",{className:"userflowjs-assistant-chat__flow-suggestion-content"},!k&&o.iconSetting!==ye.HIDE&&(o.icon?t.createElement(L,{icon:o.icon,size:20}):t.createElement(L,{icon:He,size:20})),k&&t.createElement(ke,null),t.createElement("div",{className:"userflowjs-assistant-chat__flow-suggestion-title"},t.createElement("span",null,o.name),o.flowType===se.FLOW?t.createElement("span",{className:"userflowjs-assistant-chat__flow-suggestion-info"},l("resource_center.flow_suggestion_hint")):t.createElement("span",{className:"userflowjs-assistant-chat__flow-suggestion-info"},l("resource_center.workflow_suggestion_hint")))),t.createElement(L,{size:32,icon:Pe})),e.sources&&e.sources.length>0&&t.createElement("div",{className:"userflowjs-assistant-chat__sources"},t.createElement("div",{className:"userflowjs-assistant-chat__sources-title"},s.sourcesText),e.sources.map((_,N)=>t.createElement("a",{key:N,className:"userflowjs-assistant-chat__source",href:Te(_.url),target:"_blank",rel:"noreferrer noopener"},_.title))),r&&e.completed&&e.id&&(s.ratingMode===C.LIKE||s.ratingMode===C.SCALE&&p)&&t.createElement(Ge,{assistant:s,message:e,onSubmitRating:u,onSubmitFeedback:w}))},Ge=({assistant:s,message:e,onSubmitRating:r,onSubmitFeedback:u})=>{const w=c.useRef(null),[f,b]=c.useState(""),h=i=>{const m=e.id;m&&(de.flushSync(()=>{r({ratingMode:C.LIKE,messageId:m,rating:i})}),w.current?.focus({preventScroll:!0}))},g=i=>{const m=e.id;m&&(de.flushSync(()=>{r({ratingMode:C.SCALE,messageId:m,scaleRating:i,scaleMax:s.scaleMax})}),w.current?.focus({preventScroll:!0}))},n=()=>{e.id&&(u({messageId:e.id,feedback:f.trim()}),b(""))},p=s.ratingMode===C.LIKE?t.createElement("button",{className:"userflowjs-assistant-chat__rating-option",disabled:!0},t.createElement(L,{icon:e.rating==B.DISLIKE?le:ce})):e.scaleRating&&e.scaleMax&&t.createElement("button",{className:z({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--scale":!0}),disabled:!0},Se(s,e.scaleRating,e.scaleMax));return t.createElement("div",{className:`userflowjs-assistant-chat__rating userflowjs-assistant-chat__rating--${s.ratingMode}`},s.ratingMode===C.SCALE&&t.createElement("div",{className:"userflowjs-assistant-chat__rating-question"},s.scaleQuestion),e.feedbackSubmitted?t.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks"},p,t.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks-message"},s.feedbackThanksText)):(s.ratingMode===C.LIKE?e.rating:e.scaleRating)?t.createElement(xe,{textareaRef:w,className:"userflowjs-growing-textarea userflowjs-assistant-chat__feedback-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea",placeholder:(s.ratingMode===C.LIKE?e.rating===B.LIKE?s.feedbackLikePlaceholder:s.feedbackDislikePlaceholder:s.scaleFeedbackPlaceholder)||"",value:f,onChange:b,onKeyDown:i=>{!i.shiftKey&&i.key==="Enter"&&(i.preventDefault(),n())}},p,t.createElement("button",{className:"userflowjs-assistant-chat__feedback-submit",onClick:()=>n()},t.createElement(L,{icon:be}))):t.createElement("div",{className:"userflowjs-assistant-chat__rating-options"},s.ratingMode===C.LIKE?[B.LIKE,B.DISLIKE].map(i=>(!e.rating||e.rating===i)&&t.createElement("button",{key:i,className:"userflowjs-assistant-chat__rating-option",onClick:e.rating?void 0:()=>h(i),disabled:!!e.rating,"data-testid":`assistant-chat-rating-${i}`},t.createElement(L,{icon:i==B.DISLIKE?le:ce}))):Ye(s).map(({value:i,label:m})=>t.createElement("button",{key:i,className:z({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--large-scale":Ue(m||"")}),onClick:e.scaleRating?void 0:()=>g(i),disabled:!!e.scaleRating,"data-testid":`assistant-chat-rating-${i}`},m))))};function Q(s){let e=s;const r=f=>(f=f.replace(/\s*[*_`]*$/,""),f=f.replace(/(^|\n)\s*(\d+\.?|-|=)$/,""),f);e=r(e),e=e.replace(/\[([^\]\n]*)(\](\([^)\n]*)?)?$/,"$1"),e=r(e);const u=Array.from(e.matchAll(/\n( *)```/g));if(u.length%2===1){const f=u[u.length-1][1];e+=`
1
+ import{r as c,R as t}from"./vendor.react.js";import{ai as pe,aj as C,ak as ye,al as se,am as B,L as ne,h as ae,M as re,E as Ae}from"./userflow.js";import{A as Le,d as Te,G as xe,c as oe}from"./ResourceCenterApp.js";import{u as De}from"./client-context.js";import{a7 as be,h as He,a0 as Pe,a8 as le,a9 as ce,aa as ie,ab as J,ac as ue,ad as Y,ae as fe}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{p as We}from"./vendor.dompurify.js";import{m as Ke}from"./vendor.marked.js";import{o as z}from"./vendor.obj-str.js";import{r as Ee,R as X,s as $e,n as Oe}from"./TreeDoc.js";import{D as L}from"./stylesheets.js";import{U as _e}from"./roots.js";import{r as de}from"./vendor.react-dom.js";import{S as ke}from"./AnnouncementEngagement.js";import"./vendor.object-assign.js";import{u as Z}from"./vendor.react-i18next.js";import{g as me}from"./flow-condition-types.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./flow-host.styl.js";import"./use-selector-element-monitoring.js";import"./Frame.js";import"./iframe-reset.styl.js";import"./use-window-resize.js";import"./logomark.js";import"./ChecklistUI.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./FlowChrome.js";import"./use-confetti.js";import"./vendor.canvas-confetti.js";import"./vendor.memoize-one.js";import"./vendor.bignumber.js.js";import"./use-element-rect.js";import"./resource-center-route.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="9686fbd4-b5c4-413b-aeb0-7fb00b5e2dfa",s._sentryDebugIdIdentifier="sentry-dbid-9686fbd4-b5c4-413b-aeb0-7fb00b5e2dfa")}catch{}})();function Ue(s){const e=Intl.Segmenter;return e?/(\p{Emoji_Presentation}|\p{Extended_Pictographic})(\p{Emoji_Modifier_Base}?\p{Emoji_Modifier}?|\uFE0F\u200D(\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?\uFE0F\u200D)*\p{Emoji_Presentation}|\uFE0F\u200D\p{Extended_Pictographic})/u.test(s)&&[...new e().segment(s)].length===1:!1}const he=[];function Be({assistant:s,lookupAttribute:e,initialConversationId:r,initialHistory:u,initialUserContent:w,onConversationIdChange:f,submitMessage:b,submitRating:h,submitFeedback:g,InsideMessage:n,onContactClick:p,contactButtonText:i,onHandoverClick:m,onFlowSuggestionClick:o}){const[k,M]=c.useState(null),[l,d]=c.useState(()=>u?u.map(a=>({...a,assistantHtml:K(Q(a.assistantContent),!1)})):he),[_,N]=c.useState(""),I=c.useRef(null),y=c.useRef(null),S=c.useRef(!0),T=c.useRef(r||null),[F,x]=c.useState(T.current),j=c.useCallback(a=>{T.current=a,x(a),f&&f(a)},[f]),D=c.useCallback(()=>{k?.focus({preventScroll:!0})},[k]);c.useEffect(()=>{D()},[D]),c.useLayoutEffect(()=>{const a=y.current;a&&(a.scrollTop=Math.ceil(a.scrollHeight-a.clientHeight))},[]);const v=c.useCallback(()=>{const a=y.current;a&&(S.current=!0,typeof a.scrollTo=="function"&&a.scrollTo({top:Math.ceil(a.scrollHeight-a.clientHeight),behavior:"smooth"}))},[]),$=c.useRef(0);c.useLayoutEffect(()=>{const a=y.current;a&&a.scrollHeight!==$.current&&($.current=a.scrollHeight,S.current&&v())},[l,v]);const W=c.useCallback(()=>{I.current&&I.current()},[]);c.useEffect(()=>()=>{W()},[W]);const q=(a,R)=>{d(H=>H.map(A=>{if(a===A.id){const P=R(A);return{...A,...P}}else return A}))},O=a=>{d(R=>R.map((H,A)=>{if(A===R.length-1){const P=a(H);return{...H,...P}}else return H}))},G=c.useCallback(a=>{const{userContent:R,workflow:H}=a;W(),d(E=>[...E,{id:null,userContent:R??"",assistantContent:"",assistantFallbackContent:null,assistantHtml:K("","enter"),enterAnimation:!0,sources:[],flowSuggestions:[],completed:!1,rating:null,scaleRating:null,scaleMax:null,feedbackSubmitted:!1,handover:null,workflowMessageType:H?pe.INITIAL:null}]),v();let A=!1;const P=()=>{A=!0,I.current=null},Re=b({conversationId:T.current,userContent:R??"",workflow:H,callback:E=>{if(A){console.log("Userflow.js AssistantChat got message after being done",E);return}switch(E.kind){case"conversation_created":j(E.conversationId);break;case"message_created":O(()=>({id:E.messageId,warning:E.warning,workflowMessageType:E.workflowMessageType}));break;case"assistant_content_delta":O(U=>{const te=U.assistantContent+E.delta;return{assistantContent:te,assistantHtml:K(Q(te))}});break;case"done":P(),O(U=>({assistantHtml:K(U.assistantContent,"exit"),assistantFallbackContent:E.fallbackContent,flowSuggestions:E.flowSuggestions,completed:!0,sources:E.sources,handover:E.handover}));break;case"error":P(),O(U=>({failed:!0,error:E.message,assistantHtml:K(Q(U.assistantContent),!1)}));break;default:console.log("Userflow.js AssistantChat got unknown message",E)}}});I.current=()=>{P(),Re.abort(),O(E=>({assistantHtml:K(Q(E.assistantContent),!1)}))}},[W,v,j,b]),V=c.useCallback(a=>{a=a.trim(),a!==""&&(N(""),G({userContent:a}))},[G]),ee=c.useRef(!1);c.useEffect(()=>{ee.current||(ee.current=!0,w&&V(w))},[V,w]);const ve=c.useCallback(a=>{G({userContent:"Hey, can you please fill in the field",workflow:a})},[G]),Ie=c.useCallback(()=>{W(),j(null),d(he),D()},[W,D,j]),[je,Me]=c.useState(!0),Ne=c.useCallback(()=>{const a=y.current;a&&Me(a.scrollTop===0)},[]),Fe=c.useCallback(()=>{const a=y.current;a&&(S.current=Math.ceil(a.scrollHeight-a.clientHeight)==Math.ceil(a.scrollTop))},[]);return{assistant:s,lookupAttribute:e,history:l,setInput:M,contentElRef:y,scrolledToTop:je,userContent:_,setUserContent:N,onSubmitMessage:V,supportsFeedback:!!h&&!!g,onSubmitRating:async a=>{if(!h)return;switch(a.ratingMode){case C.LIKE:q(a.messageId,()=>({rating:a.rating}));break;case C.SCALE:q(a.messageId,()=>({scaleRating:a.scaleRating,scaleMax:a.scaleMax}));break;default:throw new _e(a)}const R=await h(a);R?.handover&&q(a.messageId,()=>({handover:R.handover}))},onSubmitFeedback:a=>{g&&(q(a.messageId,()=>({feedbackSubmitted:!0})),g(a))},onFlowSuggestionClick:o,InsideMessage:n,onContactClick:p,contactButtonText:i,onHandoverClick:m,reset:Ie,scrollToBottom:v,onContentScroll:Ne,onContentWheel:Fe,conversationId:F,startWorkflowFill:ve}}const ze=({assistant:s,lookupAttribute:e,history:r,setInput:u,contentElRef:w,scrolledToTop:f,userContent:b,setUserContent:h,onSubmitMessage:g,supportsFeedback:n,onSubmitRating:p,onSubmitFeedback:i,onFlowSuggestionClick:m,InsideMessage:o,onContactClick:k,contactButtonText:M,onHandoverClick:l,reset:d,scrollToBottom:_,onContentScroll:N,onContentWheel:I,conversationId:y,workflowSession:S,onCancelWorkflow:T})=>{const{t:F}=Z();c.useEffect(()=>{_()},[S,_]);const x=r.some(v=>v.completed||v.failed),[j,D]=c.useState(null);return t.createElement("div",{className:"userflowjs-assistant-chat"},t.createElement("div",{className:z({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})}),t.createElement("div",{className:z({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})},t.createElement(t.Fragment,null,t.createElement("h2",{className:"userflowjs-assistant-chat__title"},s.title),t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:d},s.resetText))),t.createElement("div",{ref:w,className:"userflowjs-assistant-chat__content",onScroll:N,onWheel:I},!Ee(s.intro)&&t.createElement("div",{className:"userflowjs-assistant-chat__intro"},t.createElement(X,{doc:s.intro,lookupAttribute:e})),r.map((v,$)=>t.createElement(qe,{key:$,assistant:s,message:v,supportsFeedback:n,onSubmitRating:p,onSubmitFeedback:i,InsideMessage:o,conversationId:y,isLast:$===r.length-1,onFlowSuggestionClick:m,onRequestConfirm:D,onHandoverClick:l}))),j?t.createElement("div",{className:"userflowjs-bubble-buttons userflowjs-assistant-chat__confirm"},t.createElement("p",{className:"userflowjs-assistant-chat__confirm-text"},F("resource_center.confirm_action")),t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:()=>D(null)},F("resource_center.deny")),t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",disabled:!!S,onClick:async()=>{if(S)return;const v=j;D(null),await m(v)}},F("resource_center.allow"))):t.createElement(t.Fragment,null,S&&t.createElement("div",{className:"userflowjs-assistant-workflow__status"},t.createElement("div",{className:"userflowjs-assistant-workflow__status-message"},t.createElement(ke,null),F("resource_center.workflow_in_progress")),t.createElement("button",{className:"userflowjs-workflow-cancel-button",onClick:T},F("resource_center.cancel_workflow"))),t.createElement("div",{className:"userflowjs-assistant-chat__prompt"},t.createElement(Le,{textareaRef:u,placeholder:(r.length===0?s.promptEmptyPlaceholder:s.promptNonemptyPlaceholder)||"",value:b,onChange:h,onSubmit:()=>g(b)}))),x&&k&&t.createElement("div",{className:"userflowjs-assistant-chat__contact"},t.createElement("button",{className:"userflowjs-tertiary-button",onClick:()=>k()},M)))},qe=({assistant:s,message:e,supportsFeedback:r,onSubmitRating:u,onSubmitFeedback:w,onFlowSuggestionClick:f,onRequestConfirm:b,onHandoverClick:h,InsideMessage:g,conversationId:n,isLast:p})=>{const i=!Ee(e.assistantFallbackContent),m=e.workflowMessageType===pe.INITIAL,o=e.flowSuggestions[0],[k,M]=c.useState(!1),{t:l}=Z(),d=async()=>{if(o.flowType===se.WORKFLOW){b({messageId:e.id,flowSuggestion:o});return}try{M(!0),await f({messageId:e.id,flowSuggestion:o})}finally{M(!1)}};return t.createElement("div",{className:"userflowjs-assistant-chat__message"},g&&t.createElement(g,{message:e}),!m&&t.createElement("div",{className:z({"userflowjs-assistant-chat__user-content":!0,"userflowjs-assistant-chat__user-content--enter":!!e.enterAnimation}),"data-assistant-conversation-id":n,"data-assistant-message-id":e.id},t.createElement("div",{style:{whiteSpace:"pre-wrap"}},e.userContent)),e.warning&&t.createElement("div",{className:"userflowjs-assistant-chat__error"},"Warning: ",e.warning),t.createElement("div",{className:"userflowjs-assistant-chat__assistant-content"},i&&t.createElement("div",null,t.createElement(X,{doc:e.assistantFallbackContent})),!i&&t.createElement("div",null,t.createElement(Je,{html:e.assistantHtml})),e.error&&t.createElement("div",{className:"userflowjs-assistant-chat__error"},e.error)),e.handover&&t.createElement("div",{className:"userflowjs-assistant-chat__handover"},e.handover.message&&t.createElement("div",{className:"userflowjs-assistant-chat__handover-message"},t.createElement(X,{doc:e.handover.message})),t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-assistant-chat__handover-button",onClick:e.id&&h?()=>h({messageId:e.id}):void 0},t.createElement("span",{className:"userflowjs-assistant-chat__handover-button-content "},e.handover.buttonIcon&&t.createElement(L,{icon:e.handover.buttonIcon,size:16}),t.createElement("span",null,e.handover.buttonText)),t.createElement(L,{icon:be,size:16}))),e.id&&o&&t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-assistant-chat__flow-suggestion",onClick:d},t.createElement("span",{className:"userflowjs-assistant-chat__flow-suggestion-content"},!k&&o.iconSetting!==ye.HIDE&&(o.icon?t.createElement(L,{icon:o.icon,size:20}):t.createElement(L,{icon:He,size:20})),k&&t.createElement(ke,null),t.createElement("div",{className:"userflowjs-assistant-chat__flow-suggestion-title"},t.createElement("span",null,o.name),o.flowType===se.FLOW?t.createElement("span",{className:"userflowjs-assistant-chat__flow-suggestion-info"},l("resource_center.flow_suggestion_hint")):t.createElement("span",{className:"userflowjs-assistant-chat__flow-suggestion-info"},l("resource_center.workflow_suggestion_hint")))),t.createElement(L,{size:32,icon:Pe})),e.sources&&e.sources.length>0&&t.createElement("div",{className:"userflowjs-assistant-chat__sources"},t.createElement("div",{className:"userflowjs-assistant-chat__sources-title"},s.sourcesText),e.sources.map((_,N)=>t.createElement("a",{key:N,className:"userflowjs-assistant-chat__source",href:Te(_.url),target:"_blank",rel:"noreferrer noopener"},_.title))),r&&e.completed&&e.id&&(s.ratingMode===C.LIKE||s.ratingMode===C.SCALE&&p)&&t.createElement(Ge,{assistant:s,message:e,onSubmitRating:u,onSubmitFeedback:w}))},Ge=({assistant:s,message:e,onSubmitRating:r,onSubmitFeedback:u})=>{const w=c.useRef(null),[f,b]=c.useState(""),h=i=>{const m=e.id;m&&(de.flushSync(()=>{r({ratingMode:C.LIKE,messageId:m,rating:i})}),w.current?.focus({preventScroll:!0}))},g=i=>{const m=e.id;m&&(de.flushSync(()=>{r({ratingMode:C.SCALE,messageId:m,scaleRating:i,scaleMax:s.scaleMax})}),w.current?.focus({preventScroll:!0}))},n=()=>{e.id&&(u({messageId:e.id,feedback:f.trim()}),b(""))},p=s.ratingMode===C.LIKE?t.createElement("button",{className:"userflowjs-assistant-chat__rating-option",disabled:!0},t.createElement(L,{icon:e.rating==B.DISLIKE?le:ce})):e.scaleRating&&e.scaleMax&&t.createElement("button",{className:z({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--scale":!0}),disabled:!0},Se(s,e.scaleRating,e.scaleMax));return t.createElement("div",{className:`userflowjs-assistant-chat__rating userflowjs-assistant-chat__rating--${s.ratingMode}`},s.ratingMode===C.SCALE&&t.createElement("div",{className:"userflowjs-assistant-chat__rating-question"},s.scaleQuestion),e.feedbackSubmitted?t.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks"},p,t.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks-message"},s.feedbackThanksText)):(s.ratingMode===C.LIKE?e.rating:e.scaleRating)?t.createElement(xe,{textareaRef:w,className:"userflowjs-growing-textarea userflowjs-assistant-chat__feedback-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea",placeholder:(s.ratingMode===C.LIKE?e.rating===B.LIKE?s.feedbackLikePlaceholder:s.feedbackDislikePlaceholder:s.scaleFeedbackPlaceholder)||"",value:f,onChange:b,onKeyDown:i=>{!i.shiftKey&&i.key==="Enter"&&(i.preventDefault(),n())}},p,t.createElement("button",{className:"userflowjs-assistant-chat__feedback-submit",onClick:()=>n()},t.createElement(L,{icon:be}))):t.createElement("div",{className:"userflowjs-assistant-chat__rating-options"},s.ratingMode===C.LIKE?[B.LIKE,B.DISLIKE].map(i=>(!e.rating||e.rating===i)&&t.createElement("button",{key:i,className:"userflowjs-assistant-chat__rating-option",onClick:e.rating?void 0:()=>h(i),disabled:!!e.rating,"data-testid":`assistant-chat-rating-${i}`},t.createElement(L,{icon:i==B.DISLIKE?le:ce}))):Ye(s).map(({value:i,label:m})=>t.createElement("button",{key:i,className:z({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--large-scale":Ue(m||"")}),onClick:e.scaleRating?void 0:()=>g(i),disabled:!!e.scaleRating,"data-testid":`assistant-chat-rating-${i}`},m))))};function Q(s){let e=s;const r=f=>(f=f.replace(/\s*[*_`]*$/,""),f=f.replace(/(^|\n)\s*(\d+\.?|-|=)$/,""),f);e=r(e),e=e.replace(/\[([^\]\n]*)(\](\([^)\n]*)?)?$/,"$1"),e=r(e);const u=Array.from(e.matchAll(/\n( *)```/g));if(u.length%2===1){const f=u[u.length-1][1];e+=`
2
2
  `+f+"```"}else{let f=0;for(let n=e.length-1;n>=0;n--)if(e[n]===`
3
3
  `&&e[n-1]===`
4
- `){f=n;break}const b=[];let h=!1;const g=n=>n==null||n.match(/\W/);for(let n=f;n<e.length;n++){const p=e[n],i=p+e[n+1],m=i+e[n+2];let o=null;!h&&m==="***"||!h&&m==="___"&&(g(e[n-1])||g(e[n+3]))?o=m:!h&&i==="**"||!h&&i==="__"&&(g(e[n-1])||g(e[n+2]))?o=i:(!h&&p==="*"||!h&&p==="_"&&(g(e[n-1])||g(e[n+1]))||p==="`")&&(o=p),o!=null&&(e.slice(f,n+o.length).match(/\[[^\]\n]*\]\([^)\n]*$/)||(b[b.length-1]===o?(o==="`"&&(h=!1),b.pop()):(o==="`"&&(h=!0),b.push(o))),n+=o.length-1)}e+=b.reverse().join("")}return e}function K(s,e){s=s.trim(),e!==!1&&(s=s.replace(/(\n *```)?$/," {{USERFLOWCHATBRAIN}}$1"));let r=We.sanitize(Ke.parse(s));if(e!==!1){let u="userflowjs-assistant-brain";e&&(u+=` userflowjs-assistant-brain--${e}`),r=r.replace("{{USERFLOWCHATBRAIN}}",`<span class="${u}"><span></span><span></span><span></span><span></span></span>`)}return r=r.replace(/<a href=/g,'<a target="_blank" rel="noopener noreferrer" href='),r}const Je=({html:s})=>c.useMemo(()=>{if(!s)return null;const r=new DOMParser().parseFromString(s,"text/html");return Ce(r.body)},[s]);function Ce(s,e){if(s instanceof Element){if(s.tagName==="BODY")return t.createElement(t.Fragment,{key:e},ge(s));{if(["script","style"].includes(s.tagName))return null;const r={key:e};for(const u of s.attributes){let w=u.name;w.startsWith("on")||(w==="class"&&(w="className"),r[w]=u.value)}return t.createElement(s.tagName.toLowerCase(),r,ge(s))}}else return s instanceof Text?s.textContent:null}function ge(s){const e=[];let r=0;for(const u of s.childNodes)e.push(Ce(u,r)),r++;return e}function Ye(s){let e=[];const r=s.scaleMax||5;for(let u=1;u<=r;u++)e.push({value:u,label:Se(s,u,r)});return e}function Se(s,e,r){if(s.scaleLabels)return s.scaleLabels[e-1]||e;{const u=we[r]&&we[r][e];return u?t.createElement(L,{icon:u,size:24}):e}}const we={2:{1:Y,2:J},3:{1:Y,2:ue,3:J},4:{1:fe,2:Y,3:J,4:ie},5:{1:fe,2:Y,3:ue,4:J,5:ie}},Tt=({block:s,session:e,assistantReply:r,initialUserContent:u,onContactClick:w,contactButtonText:f,onHandoverChatShow:b,chatBlock:h})=>{const g=s.assistantFlowId,n=De(),{t:p}=Z(),i=p("assistant.generic_error"),m=p("assistant.disconnected_error"),o=c.useMemo(()=>{const l=r.assistant.handoverChatProvider;return l?{...s,chatProvider:l,chatCode:l===ne.CUSTOM?r.assistant.handoverChatCode:""}:null},[r.assistant.handoverChatProvider,r.assistant.handoverChatCode,s]);c.useEffect(()=>{if(!o||h)return;const l=oe[o.chatProvider];try{const d=l.configure({block:o,onShow:()=>{},onHide:()=>{}});return()=>{d()}}catch(d){console.error(`Userflow.js: Error when configuring ${o.chatProvider}:`,d);return}},[o,h]);const k=Be(c.useMemo(()=>({assistant:r.assistant,lookupAttribute:me(e.data),initialConversationId:r.conversationId,initialHistory:r.history,initialUserContent:u,onConversationIdChange:l=>{const d="assistantConversationId:"+g;l?re.setItem(d,l):re.removeItem(d)},submitMessage:({conversationId:l,userContent:d,workflow:_,callback:N})=>{n.assistantMessageInProgress=!0;const I=n.nextRef();n.send(_?{kind:"WorkflowRequestFillValue",ref:I,assistantFlowId:g,sessionId:_.workflowSessionId,stepId:_.stepId,conversationId:l,userContent:d}:{kind:"SubmitAssistantMessage",ref:I,assistantFlowId:g,conversationId:l,userContent:d},{handlesRejection:!0}).catch(x=>{N({kind:"error",message:x.humanMessage||i})});const S=()=>{n.assistantMessageInProgress=void 0,n.off("private:assistantMessageEvent",T),n.off("private:disconnect",F)},T=x=>{if(x.ref!==I){console.error(`The ${I} for the messages didn't match`);return}const{event:j}=x;N(j),(j.kind=="done"||j.kind=="error")&&S()},F=()=>{N({kind:"error",message:m}),S()};return n.on("private:assistantMessageEvent",T),n.on("private:disconnect",F),{abort:()=>{n.send({kind:"AbortAssistantMessage"}),S()}}},submitRating:l=>{switch(l.ratingMode){case C.LIKE:return n.send({kind:"SubmitAssistantRating",messageId:l.messageId,rating:l.rating});case C.SCALE:return n.send({kind:"SubmitAssistantScaleRating",messageId:l.messageId,scaleRating:l.scaleRating,scaleMax:l.scaleMax});default:throw new _e(l)}},submitFeedback:l=>{n.send({kind:"SubmitAssistantFeedback",messageId:l.messageId,feedback:l.feedback})},onContactClick:w,contactButtonText:f,onHandoverClick:async({messageId:l})=>{if(o){await n.send({kind:"ClickAssistantHandoverButton",messageId:l});try{oe[o.chatProvider].show({block:o}),n.closeResourceCenter(),o.chatProvider!==ne.CUSTOM&&b(o)}catch(d){console.error(`Userflow.js: Error when showing ${o.chatProvider}:`,d)}}},onFlowSuggestionClick:async l=>{await n.send({kind:"ClickAssistantFlowSuggestion",messageId:l.messageId,flowSuggestionId:l.flowSuggestion.id}),await n.startFlow({flowId:l.flowSuggestion.flowId,startReason:e.draftMode?ae.DRAFT:ae.ASSISTANT,replaceCurrent:!0});const d=$e(l.flowSuggestion.url,{lookupAttribute:me(e.data)});d&&Oe(d)}}),[r,g,n,u,e.data,w,f,o,i,m,e.draftMode])),M=c.useRef(k.startWorkflowFill);return M.current=k.startWorkflowFill,c.useEffect(()=>{const l=_=>{M.current(_)},d=_=>{_?.kind==="assistant"&&n.emit("private:assistantChatReady")};return n.on("private:workflowFillStep",l),n.on("private:resourceCenterNavigate",d),n.emit("private:assistantChatReady"),()=>{n.off("private:workflowFillStep",l),n.off("private:resourceCenterNavigate",d)}},[n]),t.createElement(t.Fragment,null,t.createElement(ze,{...k,workflowSession:n.workflowSession,onCancelWorkflow:()=>{n.workflowSession&&n.endFlow(n.workflowSession,{endReason:Ae.USER_CLOSED})}}))};export{Tt as ResourceCenterAssistantChat};
4
+ `){f=n;break}const b=[];let h=!1;const g=n=>n==null||n.match(/\W/);for(let n=f;n<e.length;n++){const p=e[n],i=p+e[n+1],m=i+e[n+2];let o=null;!h&&m==="***"||!h&&m==="___"&&(g(e[n-1])||g(e[n+3]))?o=m:!h&&i==="**"||!h&&i==="__"&&(g(e[n-1])||g(e[n+2]))?o=i:(!h&&p==="*"||!h&&p==="_"&&(g(e[n-1])||g(e[n+1]))||p==="`")&&(o=p),o!=null&&(e.slice(f,n+o.length).match(/\[[^\]\n]*\]\([^)\n]*$/)||(b[b.length-1]===o?(o==="`"&&(h=!1),b.pop()):(o==="`"&&(h=!0),b.push(o))),n+=o.length-1)}e+=b.reverse().join("")}return e}function K(s,e){s=s.trim(),e!==!1&&(s=s.replace(/(\n *```)?$/," {{USERFLOWCHATBRAIN}}$1"));let r=We.sanitize(Ke.parse(s));if(e!==!1){let u="userflowjs-assistant-brain";e&&(u+=` userflowjs-assistant-brain--${e}`),r=r.replace("{{USERFLOWCHATBRAIN}}",`<span class="${u}"><span></span><span></span><span></span><span></span></span>`)}return r=r.replace(/<a href=/g,'<a target="_blank" rel="noopener noreferrer" href='),r}const Je=({html:s})=>c.useMemo(()=>{if(!s)return null;const r=new DOMParser().parseFromString(s,"text/html");return Ce(r.body)},[s]);function Ce(s,e){if(s instanceof Element){if(s.tagName==="BODY")return t.createElement(t.Fragment,{key:e},ge(s));{if(["script","style"].includes(s.tagName))return null;const r={key:e};for(const u of s.attributes){let w=u.name;w.startsWith("on")||(w==="class"&&(w="className"),r[w]=u.value)}return t.createElement(s.tagName.toLowerCase(),r,ge(s))}}else return s instanceof Text?s.textContent:null}function ge(s){const e=[];let r=0;for(const u of s.childNodes)e.push(Ce(u,r)),r++;return e}function Ye(s){let e=[];const r=s.scaleMax||5;for(let u=1;u<=r;u++)e.push({value:u,label:Se(s,u,r)});return e}function Se(s,e,r){if(s.scaleLabels)return s.scaleLabels[e-1]||e;{const u=we[r]&&we[r][e];return u?t.createElement(L,{icon:u,size:24}):e}}const we={2:{1:Y,2:J},3:{1:Y,2:ue,3:J},4:{1:fe,2:Y,3:J,4:ie},5:{1:fe,2:Y,3:ue,4:J,5:ie}},xt=({block:s,session:e,assistantReply:r,initialUserContent:u,onContactClick:w,contactButtonText:f,onHandoverChatShow:b,chatBlock:h})=>{const g=s.assistantFlowId,n=De(),{t:p}=Z(),i=p("assistant.generic_error"),m=p("assistant.disconnected_error"),o=c.useMemo(()=>{const l=r.assistant.handoverChatProvider;return l?{...s,chatProvider:l,chatCode:l===ne.CUSTOM?r.assistant.handoverChatCode:""}:null},[r.assistant.handoverChatProvider,r.assistant.handoverChatCode,s]);c.useEffect(()=>{if(!o||h)return;const l=oe[o.chatProvider];try{const d=l.configure({block:o,onShow:()=>{},onHide:()=>{}});return()=>{d()}}catch(d){console.error(`Userflow.js: Error when configuring ${o.chatProvider}:`,d);return}},[o,h]);const k=Be(c.useMemo(()=>({assistant:r.assistant,lookupAttribute:me(e.data),initialConversationId:r.conversationId,initialHistory:r.history,initialUserContent:u,onConversationIdChange:l=>{const d="assistantConversationId:"+g;l?re.setItem(d,l):re.removeItem(d)},submitMessage:({conversationId:l,userContent:d,workflow:_,callback:N})=>{n.assistantMessageInProgress=!0;const I=n.nextRef();n.send(_?{kind:"WorkflowRequestFillValue",ref:I,assistantFlowId:g,sessionId:_.workflowSessionId,stepId:_.stepId,conversationId:l,userContent:d}:{kind:"SubmitAssistantMessage",ref:I,assistantFlowId:g,conversationId:l,userContent:d},{handlesRejection:!0}).catch(x=>{N({kind:"error",message:x.humanMessage||i})});const S=()=>{n.assistantMessageInProgress=void 0,n.off("private:assistantMessageEvent",T),n.off("private:disconnect",F)},T=x=>{if(x.ref!==I){console.error(`The ${I} for the messages didn't match`);return}const{event:j}=x;N(j),(j.kind=="done"||j.kind=="error")&&S()},F=()=>{N({kind:"error",message:m}),S()};return n.on("private:assistantMessageEvent",T),n.on("private:disconnect",F),{abort:()=>{n.send({kind:"AbortAssistantMessage"}),S()}}},submitRating:l=>{switch(l.ratingMode){case C.LIKE:return n.send({kind:"SubmitAssistantRating",messageId:l.messageId,rating:l.rating});case C.SCALE:return n.send({kind:"SubmitAssistantScaleRating",messageId:l.messageId,scaleRating:l.scaleRating,scaleMax:l.scaleMax});default:throw new _e(l)}},submitFeedback:l=>{n.send({kind:"SubmitAssistantFeedback",messageId:l.messageId,feedback:l.feedback})},onContactClick:w,contactButtonText:f,onHandoverClick:async({messageId:l})=>{if(o){await n.send({kind:"ClickAssistantHandoverButton",messageId:l});try{oe[o.chatProvider].show({block:o}),n.closeResourceCenter(),o.chatProvider!==ne.CUSTOM&&b(o)}catch(d){console.error(`Userflow.js: Error when showing ${o.chatProvider}:`,d)}}},onFlowSuggestionClick:async l=>{await n.send({kind:"ClickAssistantFlowSuggestion",messageId:l.messageId,flowSuggestionId:l.flowSuggestion.id}),await n.startFlow({flowId:l.flowSuggestion.flowId,startReason:e.draftMode?ae.DRAFT:ae.ASSISTANT,replaceCurrent:!0});const d=$e(l.flowSuggestion.url,{lookupAttribute:me(e.data)});d&&Oe(d)}}),[r,g,n,u,e.data,w,f,o,i,m,e.draftMode])),M=c.useRef(k.startWorkflowFill);return M.current=k.startWorkflowFill,c.useEffect(()=>{const l=_=>{M.current(_)},d=_=>{_?.kind==="assistant"&&n.emit("private:assistantChatReady")};return n.on("private:workflowFillStep",l),n.on("private:resourceCenterNavigate",d),n.emit("private:assistantChatReady"),()=>{n.off("private:workflowFillStep",l),n.off("private:resourceCenterNavigate",d)}},[n]),t.createElement(t.Fragment,null,t.createElement(ze,{...k,workflowSession:n.workflowSession,onCancelWorkflow:()=>{n.workflowSession&&n.endFlow(n.workflowSession,{endReason:Ae.USER_CLOSED})}}))};export{xt as ResourceCenterAssistantChat};
5
5
  //# sourceMappingURL=ResourceCenterAssistantChat.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 b}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,f as M,s as L}from"./ResourceCenterApp.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"./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]="ad9c9470-af64-46fe-abe5-39b9a72e9a43",o._sentryDebugIdIdentifier="sentry-dbid-ad9c9470-af64-46fe-abe5-39b9a72e9a43")}catch{}})();const ve=({session:o,isOpen:t,flowSession:s,resourceCenterLauncherHidden:u})=>{const l=b(),n=o.version.resourceCenter,i=h(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:()=>{w(l,d)},onOpen:c}))},_=320,$=({session:o,announcement:t,targetParams:s,onOpen:u})=>{const l=b(),n=h(t.theme),i=()=>{w(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{ve as ResourceCenterLauncherHandler,ve as default};
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 b}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,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"./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]="f8ad60d9-9b99-4d30-9504-3f5b338019df",o._sentryDebugIdIdentifier="sentry-dbid-f8ad60d9-9b99-4d30-9504-3f5b338019df")}catch{}})();const Te=({session:o,isOpen:t,flowSession:s,resourceCenterLauncherHidden:u})=>{const l=b(),n=o.version.resourceCenter,i=h(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:()=>{w(l,d)},onOpen:c}))},_=320,$=({session:o,announcement:t,targetParams:s,onOpen:u})=>{const l=b(),n=h(t.theme),i=()=>{w(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};
2
2
  //# sourceMappingURL=ResourceCenterLauncherHandler.js.map
package/WorkflowApp.js CHANGED
@@ -1,4 +1,4 @@
1
- import{R as l,r as E}from"./vendor.react.js";import{d as T,a9 as I,E as S,aa as y,g as b,f as _,K as H,U as D,S as P,r as W,p as B}from"./userflow.js";import{f as k}from"./steps.js";import{u as A}from"./client-context.js";import{g as M,m as v}from"./roots.js";import{s as L,n as V,h as j,c as $}from"./TreeDoc.js";import{g as R,o as G,c as J}from"./flow-condition-types.js";import"./vendor.object-assign.js";import{u as K,a as q}from"./stylesheets.js";import{S as X}from"./flow-host.styl.js";import{B as Y,F as Z}from"./FlowChrome.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./vendor.obj-str.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.date-fns.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-selector-element-monitoring.js";import"./use-window-resize.js";import"./logomark.js";import"./use-confetti.js";import"./vendor.canvas-confetti.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]="1c4d576e-cc90-4468-9e48-919f60f637a3",e._sentryDebugIdIdentifier="sentry-dbid-1c4d576e-cc90-4468-9e48-919f60f637a3")}catch{}})();const z=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set,Q=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set,ee=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;function te(e){return e instanceof HTMLTextAreaElement?Q:e instanceof HTMLSelectElement?ee:z}function ne(e,t){return e.style.setProperty("--userflow-workflow-glow-color",t),e.classList.add("userflow-workflow-input-glow"),()=>N(e)}function N(e){e.classList.remove("userflow-workflow-input-glow"),e.style.removeProperty("--userflow-workflow-glow-color")}function oe(e,t){const n=te(e);n?n.call(e,t):e.value=t,e.dispatchEvent(new Event("input",{bubbles:!0})),e instanceof HTMLSelectElement&&e.dispatchEvent(new Event("change",{bubbles:!0}))}const O=3e4,re=100;function se(e,t){return new Promise(n=>{let o=!1;const r=()=>{o||(o=!0,e.off("private:assistantChatReady",r),window.clearTimeout(s),n())};e.on("private:assistantChatReady",r);const s=window.setTimeout(r,t)})}function g(e){const t=Number(e.stepTimeoutSeconds);return t>0?t*1e3:O}async function x(e,t,n=()=>!1){const o=Date.now()+t;for(;!n();){if(await e())return!0;if(Date.now()>=o)return!1;await new Promise(r=>window.setTimeout(r,re))}return!1}async function C(e,t,n=O,o){let r=null;return await x(async()=>{const s=v(e);for(const i of t)if(s instanceof i)return r=s,!0;return!1},n,o),r}class h extends Error{}class F extends Error{}class U extends Error{}const le={[y.CLICK]:{execute:async(e,t,n,o)=>{if(!e.selector)return;const r=await C(e.selector,[HTMLElement],g(t),o.isCanceled);if(!r)throw new h;r.click()},verify:async()=>!0},[y.FILL]:{execute:async(e,t,n,o)=>{if(!e.selector)return;const r=await C(e.selector,[HTMLInputElement,HTMLTextAreaElement,HTMLSelectElement],g(t),o.isCanceled);if(!r)throw new h;if(o.isCanceled())return;const s=ne(r,t.version.theme.brandBackgroundColor);if(await n.openResourceCenter(),o.isCanceled()){s();return}if(t.draftMode){let i;const c=n.resourceCenterSession?.version.resourceCenter?.blocks.filter(f=>f.type===H.ASSISTANT);if(!c||c.length===0){console.error("Userflow.js: No assistant block configured in the resource center."),s();return}i=c[0],c.length>1&&console.warn(`Userflow.js: Multiple assistant blocks found in the resource center.
1
+ import{R as i,r as E}from"./vendor.react.js";import{d as S,a9 as A,E as y,aa as I,g as T,f as j,K as D,M as $,U as z,S as G,r as J,p as K}from"./userflow.js";import{f as M}from"./steps.js";import{u as _}from"./client-context.js";import{g as N,m as R}from"./roots.js";import{s as O,n as q,h as X,c as Y}from"./TreeDoc.js";import{g as x,o as Z,c as Q}from"./flow-condition-types.js";import{s as ee}from"./resource-center-route.js";import"./vendor.object-assign.js";import{u as te,a as ne}from"./stylesheets.js";import{S as oe}from"./flow-host.styl.js";import{B as re,F as se}from"./FlowChrome.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./vendor.obj-str.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.date-fns.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-selector-element-monitoring.js";import"./use-window-resize.js";import"./logomark.js";import"./use-confetti.js";import"./vendor.canvas-confetti.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]="67a20979-b3d7-4766-84b9-20de6837627d",e._sentryDebugIdIdentifier="sentry-dbid-67a20979-b3d7-4766-84b9-20de6837627d")}catch{}})();const ie=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set,le=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set,ae=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;function ce(e){return e instanceof HTMLTextAreaElement?le:e instanceof HTMLSelectElement?ae:ie}function ue(e,t){return e.style.setProperty("--userflow-workflow-glow-color",t),e.classList.add("userflow-workflow-input-glow"),()=>H(e)}function H(e){e.classList.remove("userflow-workflow-input-glow"),e.style.removeProperty("--userflow-workflow-glow-color")}function fe(e,t){const n=ce(e);n?n.call(e,t):e.value=t,e.dispatchEvent(new Event("input",{bubbles:!0})),e instanceof HTMLSelectElement&&e.dispatchEvent(new Event("change",{bubbles:!0}))}const P=3e4,de=100;function pe(e,t){return new Promise(n=>{let o=!1;const r=()=>{o||(o=!0,e.off("private:assistantChatReady",r),window.clearTimeout(s),n())};e.on("private:assistantChatReady",r);const s=window.setTimeout(r,t)})}function me(e,t,n){return new Promise(o=>{if(e.resourceCenterSession){o(e.resourceCenterSession);return}const r=l=>{e.off("private:resourceCenterSession",r),window.clearTimeout(s),o(l)};e.on("private:resourceCenterSession",r);const s=window.setTimeout(()=>r(null),n)})}function g(e){const t=Number(e.stepTimeoutSeconds);return t>0?t*1e3:P}async function W(e,t,n=()=>!1){const o=Date.now()+t;for(;!n();){if(await e())return!0;if(Date.now()>=o)return!1;await new Promise(r=>window.setTimeout(r,de))}return!1}async function U(e,t,n=P,o){let r=null;return await W(async()=>{const s=R(e);for(const l of t)if(s instanceof l)return r=s,!0;return!1},n,o),r}class C extends Error{}class v extends Error{}class B extends Error{}const we={[I.CLICK]:{execute:async(e,t,n,o)=>{if(!e.selector)return;const r=await U(e.selector,[HTMLElement],g(t),o.isCanceled);if(!r)throw new C;r.click()},verify:async()=>!0},[I.FILL]:{execute:async(e,t,n,o)=>{if(!e.selector)return;const r=await U(e.selector,[HTMLInputElement,HTMLTextAreaElement,HTMLSelectElement],g(t),o.isCanceled);if(!r)throw new C;if(o.isCanceled())return;const s=ue(r,t.version.theme.brandBackgroundColor);if(o.isCanceled()){s();return}const l=await me(n,t.draftMode,g(t));if(o.isCanceled()){s();return}if(!l)throw s(),new v;const c=l.version.resourceCenter?.blocks.filter(a=>a.type===D.ASSISTANT),u=c?.[0];if(!u)throw console.error("Userflow.js: No assistant block configured in the resource center."),s(),new v;c&&c.length>1&&console.warn(`Userflow.js: Multiple assistant blocks found in the resource center.
2
2
 
3
- Using ${i.name} for communication`);const u=se(n,g(t));if(n.emit("private:resourceCenterNavigate",{kind:"assistant",block:i}),await u,o.isCanceled()){s();return}}n.emit("private:workflowFillStep",{stepId:e.id,workflowSessionId:t.id});try{await new Promise((i,c)=>{let u=M(r),f,m;const d=()=>{window.clearTimeout(m),window.clearTimeout(f),w()},a=()=>{const p=M(r);p?p!==u&&(window.clearTimeout(f),f=window.setTimeout(()=>{d(),i()},1e3)):window.clearTimeout(f),u=p},{disconnect:w}=G(a,{observeInput:!0});m=window.setTimeout(()=>{d(),c(new U)},g(t)),a(),o.onCancel(()=>{d(),c(new D("Userflow.js: Fill step canceled."))})})}finally{s()}},verify:async()=>!0},[y.NAVIGATE]:{execute:async(e,t)=>{if(!e.url)return;const n=L(e.url,{lookupAttribute:R(t.data)}),o=new URL(n,b()).toString();if(b()!==o){if(e.navigateTarget===_.NEW_TAB){window.open(n);return}V(n)}},verify:async(e,t)=>{if(!e.url)return!1;const n=L(e.url,{lookupAttribute:R(t.data)});return b()===new URL(n,b()).toString()}}};function ie(e){const{step:t,workflowSessionData:n,client:o,onSuccess:r,onElementMissing:s}=e;let i=!1,c;const u={isCanceled:()=>i,onCancel:d=>{i?d():c=d}},f=()=>{i||(i=!0,c?.())};async function m(){const d=le[t.type];try{if(T("executing workflow-step",t),await d.execute(t,n,o,u),i)return;T("verifying workflow-step",t);const a=await x(()=>d.verify(t,n),g(n),u.isCanceled);if(T(`workflow-step verified ${a}`,t),i)return;if(!a)throw new F;r()}catch(a){if(i)return;a instanceof h?(o.send({kind:"ReportWorkflowElementMissing",sessionId:n.id,stepId:t.id}),s()):a instanceof U?(o.send({kind:"ReportWorkflowTimedOut",sessionId:n.id,stepId:t.id,errorReason:I.USER_INPUT_TIMEOUT}),o.endFlow(n,{endReason:S.USERFLOWJS})):a instanceof F?(o.send({kind:"ReportWorkflowTimedOut",sessionId:n.id,stepId:t.id,errorReason:I.STEP_TIMEOUT}),o.endFlow(n,{endReason:S.USERFLOWJS})):console.warn(a)}}return{cancel:f,start:m}}function ae(e,t,n){const o=new P(t.data),r=[];for(const s of e){const{condition:i}=s;if(!i)continue;let c=!1;const f=J[i.type].track({condition:s.condition,sessionData:o,callback:m=>{m&&!c&&(c=!0,j(n,t,s.actions))}});r.push(f)}return()=>r.forEach(s=>s())}const ce=new URL("workflow.css",import.meta.url).href,ue=({session:e,step:t})=>{const n=A(),o=t.selector,r=!o||o.type===W.AUTO&&!o.autoData,s=u=>{u.stopPropagation(),n.endFlow(e,{endReason:S.USER_CLOSED})},i=Number(e.stepTimeoutSeconds),c=t.name||`Step ${t.idx+1}`;return l.createElement(l.Fragment,null,l.createElement(Y,{draftMode:e.draftMode,close:s}),e.draftMode&&r?l.createElement("div",{className:"userflowjs-bubble-content"},l.createElement("div",{className:"userflowjs-bubble-alert p-like"},l.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"No element target selected yet. Please go back to the Builder and select a target element in ",l.createElement("b",null,c)," of"," ",l.createElement("b",null,e.flow.name),".")):e.draftMode?l.createElement("div",{className:"userflowjs-bubble-content"},l.createElement("div",{className:"userflowjs-bubble-alert p-like"},l.createElement("p",null,l.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The target element for ",l.createElement("b",null,c)," of"," ",l.createElement("b",null,e.flow.name)," was not found within ",i," ",i===1?"second":"seconds","."),l.createElement("p",null,"For regular users, the action flow will auto-dismiss when this happens."),l.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),l.createElement("p",null,"Read more in our"," ",l.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):l.createElement(l.Fragment,null,l.createElement("div",{className:"userflowjs-bubble-content"},l.createElement("p",null,l.createElement("b",null,"A required element could not be found.")),l.createElement("p",null,"Please try again or close this action flow.")),l.createElement("div",{className:"userflowjs-bubble-buttons"},l.createElement($,{appearance:"default",onClick:s,text:"Close"}))))},Be=({session:e})=>{const t=A();K(window,ce);const[n,o]=E.useReducer(fe,void 0,()=>({session:e,step:k(e)})),{session:r,step:s}=n,i=q(r.version.theme),[c,u]=E.useState(!1),f=E.useRef(c);f.current=c;const m=E.useCallback(()=>{if(s.selector){const a=v(s.selector);a instanceof HTMLElement&&N(a)}},[s]);E.useEffect(()=>{r!==e&&o({kind:"updateSession",session:e});const a=w=>{w.session.id===r.id&&!f.current&&(o({kind:"goToStep",stepId:w.step.id}),T("workflow-step moving to",w.step))};return t.on("gotostep",a),()=>{t.off("gotostep",a)}},[t,r,e]),E.useEffect(()=>{const a=w=>{if(!s.selector)return;const p=v(s.selector);(p instanceof HTMLInputElement||p instanceof HTMLTextAreaElement||p instanceof HTMLSelectElement)&&oe(p,w.value)};return t.on("private:workflowFillStepValue",a),()=>{t.off("private:workflowFillStepValue",a)}},[t,s]);const d=s.id;return E.useEffect(()=>{u(!1);let a;const{cancel:w,start:p}=ie({step:s,workflowSessionData:r,client:t,onSuccess:()=>{a=ae(s.triggers,r,t)},onElementMissing:()=>{if(!r.draftMode){t.endFlow(r,{endReason:S.ELEMENT_MISSING});return}u(!0)}});return p(),()=>{w(),a?.(),m()}},[t,d,r.draftMode]),c?l.createElement(X,null,l.createElement(Z,{company:r.flow.company,theme:i,position:"fixed",stepAppearance:B.BUBBLE},l.createElement(ue,{session:r,step:s}))):null};function fe(e,t){switch(t.kind){case"updateSession":{let n;return t.session.id===e.session.id?n=t.session.version.workflowSteps.find(({crossVersionId:o})=>o===e.step.crossVersionId)||k(t.session):n=k(t.session),{...e,session:t.session,step:n}}case"goToStep":{const n=e.session.version.workflowSteps.find(o=>o.id===t.stepId);return n?{...e,step:n}:e}}}export{Be as WorkflowApp,Be as default};
3
+ Using ${u.name} for communication`);const p={kind:"assistant",block:u},w=pe(n,g(t)),f=ee(p);if(f&&$.setItem(`resourceCenterRoute:v1:${l.id}`,f),await n.openResourceCenter(),o.isCanceled()){s();return}if(n.emit("private:resourceCenterNavigate",p),await w,o.isCanceled()){s();return}n.emit("private:workflowFillStep",{stepId:e.id,workflowSessionId:t.id});try{await new Promise((a,d)=>{let m=N(r),b,L;const k=()=>{window.clearTimeout(L),window.clearTimeout(b),V()},F=()=>{const h=N(r);h?h!==m&&(window.clearTimeout(b),b=window.setTimeout(()=>{k(),a()},1e3)):window.clearTimeout(b),m=h},{disconnect:V}=Z(F,{observeInput:!0});L=window.setTimeout(()=>{k(),d(new B)},g(t)),F(),o.onCancel(()=>{k(),d(new z("Userflow.js: Fill step canceled."))})})}finally{s()}},verify:async()=>!0},[I.NAVIGATE]:{execute:async(e,t)=>{if(!e.url)return;const n=O(e.url,{lookupAttribute:x(t.data)}),o=new URL(n,T()).toString();if(T()!==o){if(e.navigateTarget===j.NEW_TAB){window.open(n);return}q(n)}},verify:async(e,t)=>{if(!e.url)return!1;const n=O(e.url,{lookupAttribute:x(t.data)});return T()===new URL(n,T()).toString()}}};function Ee(e){const{step:t,workflowSessionData:n,client:o,onSuccess:r,onElementMissing:s}=e;let l=!1,c;const u={isCanceled:()=>l,onCancel:f=>{l?f():c=f}},p=()=>{l||(l=!0,c?.())};async function w(){const f=we[t.type];try{if(S("executing workflow-step",t),await f.execute(t,n,o,u),l)return;S("verifying workflow-step",t);const a=await W(()=>f.verify(t,n),g(n),u.isCanceled);if(S(`workflow-step verified ${a}`,t),l)return;if(!a)throw new v;r()}catch(a){if(l)return;a instanceof C?(o.send({kind:"ReportWorkflowElementMissing",sessionId:n.id,stepId:t.id}),s()):a instanceof B?(o.send({kind:"ReportWorkflowTimedOut",sessionId:n.id,stepId:t.id,errorReason:A.USER_INPUT_TIMEOUT}),o.endFlow(n,{endReason:y.USERFLOWJS})):a instanceof v?(o.send({kind:"ReportWorkflowTimedOut",sessionId:n.id,stepId:t.id,errorReason:A.STEP_TIMEOUT}),o.endFlow(n,{endReason:y.USERFLOWJS})):console.warn(a)}}return{cancel:p,start:w}}function ge(e,t,n){const o=new G(t.data),r=[];for(const s of e){const{condition:l}=s;if(!l)continue;let c=!1;const p=Q[l.type].track({condition:s.condition,sessionData:o,callback:w=>{w&&!c&&(c=!0,X(n,t,s.actions))}});r.push(p)}return()=>r.forEach(s=>s())}const be=new URL("workflow.css",import.meta.url).href,Te=({session:e,step:t})=>{const n=_(),o=t.selector,r=!o||o.type===J.AUTO&&!o.autoData,s=u=>{u.stopPropagation(),n.endFlow(e,{endReason:y.USER_CLOSED})},l=Number(e.stepTimeoutSeconds),c=t.name||`Step ${t.idx+1}`;return i.createElement(i.Fragment,null,i.createElement(re,{draftMode:e.draftMode,close:s}),e.draftMode&&r?i.createElement("div",{className:"userflowjs-bubble-content"},i.createElement("div",{className:"userflowjs-bubble-alert p-like"},i.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"No element target selected yet. Please go back to the Builder and select a target element in ",i.createElement("b",null,c)," of"," ",i.createElement("b",null,e.flow.name),".")):e.draftMode?i.createElement("div",{className:"userflowjs-bubble-content"},i.createElement("div",{className:"userflowjs-bubble-alert p-like"},i.createElement("p",null,i.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The target element for ",i.createElement("b",null,c)," of"," ",i.createElement("b",null,e.flow.name)," was not found within ",l," ",l===1?"second":"seconds","."),i.createElement("p",null,"For regular users, the action flow will auto-dismiss when this happens."),i.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),i.createElement("p",null,"Read more in our"," ",i.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):i.createElement(i.Fragment,null,i.createElement("div",{className:"userflowjs-bubble-content"},i.createElement("p",null,i.createElement("b",null,"A required element could not be found.")),i.createElement("p",null,"Please try again or close this action flow.")),i.createElement("div",{className:"userflowjs-bubble-buttons"},i.createElement(Y,{appearance:"default",onClick:s,text:"Close"}))))},Ye=({session:e})=>{const t=_();te(window,be);const[n,o]=E.useReducer(Se,void 0,()=>({session:e,step:M(e)})),{session:r,step:s}=n,l=ne(r.version.theme),[c,u]=E.useState(!1),p=E.useRef(c);p.current=c;const w=E.useCallback(()=>{if(s.selector){const a=R(s.selector);a instanceof HTMLElement&&H(a)}},[s]);E.useEffect(()=>{r!==e&&o({kind:"updateSession",session:e});const a=d=>{d.session.id===r.id&&!p.current&&(o({kind:"goToStep",stepId:d.step.id}),S("workflow-step moving to",d.step))};return t.on("gotostep",a),()=>{t.off("gotostep",a)}},[t,r,e]),E.useEffect(()=>{const a=d=>{if(!s.selector)return;const m=R(s.selector);(m instanceof HTMLInputElement||m instanceof HTMLTextAreaElement||m instanceof HTMLSelectElement)&&fe(m,d.value)};return t.on("private:workflowFillStepValue",a),()=>{t.off("private:workflowFillStepValue",a)}},[t,s]);const f=s.id;return E.useEffect(()=>{u(!1);let a;const{cancel:d,start:m}=Ee({step:s,workflowSessionData:r,client:t,onSuccess:()=>{a=ge(s.triggers,r,t)},onElementMissing:()=>{if(!r.draftMode){t.endFlow(r,{endReason:y.ELEMENT_MISSING});return}u(!0)}});return m(),()=>{d(),a?.(),w()}},[t,f,r.draftMode]),c?i.createElement(oe,null,i.createElement(se,{company:r.flow.company,theme:l,position:"fixed",stepAppearance:K.BUBBLE},i.createElement(Te,{session:r,step:s}))):null};function Se(e,t){switch(t.kind){case"updateSession":{let n;return t.session.id===e.session.id?n=t.session.version.workflowSteps.find(({crossVersionId:o})=>o===e.step.crossVersionId)||M(t.session):n=M(t.session),{...e,session:t.session,step:n}}case"goToStep":{const n=e.session.version.workflowSteps.find(o=>o.id===t.stepId);return n?{...e,step:n}:e}}}export{Ye as WorkflowApp,Ye as default};
4
4
  //# sourceMappingURL=WorkflowApp.js.map
package/hash.txt CHANGED
@@ -1 +1 @@
1
- fa6cada33f3ecff19120a2e7135ce4e3c63b30e6
1
+ 63e124d788a395a477ad9765ffa680e892c10fcb
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1024673",
3
+ "version": "0.1.1024807",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
@@ -0,0 +1,2 @@
1
+ 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]="b5122eb4-bda5-44bd-af6e-d57ef1d2a112",n._sentryDebugIdIdentifier="sentry-dbid-b5122eb4-bda5-44bd-af6e-d57ef1d2a112")}catch{}})();function c(n){if(!n)return null;let d;"block"in n&&n.block!=null&&(d=n.block.cvid);const e={kind:n.kind,blockCvid:d};return n.kind==="announcementShow"&&(e.announcementId=n.announcementId),JSON.stringify(e)}function r(n,d){if(!d)return null;const e=JSON.parse(d);let i;if(e.blockCvid&&(i=n.version.resourceCenter?.blocks.find(o=>o.cvid===e.blockCvid)),!i&&e.kind!=="search")return null;const t={kind:e.kind,block:i};return t.kind==="announcementShow"&&(t.announcementId=e.announcementId),t}export{r as d,c as s};
2
+ //# sourceMappingURL=resource-center-route.js.map
package/ui.js CHANGED
@@ -1,3 +1,3 @@
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","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,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,30,29,15,16,17,23,31,13,24,32,33]))),Z=e.lazy(()=>o(()=>import("./ChecklistApp.js"),__vite__mapDeps([38,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,39,34]))),ee=e.lazy(j),te=e.lazy(()=>o(()=>import("./EmbedApp.js"),__vite__mapDeps([40,1,2,6,7,8,9,10,11,12,4,18,19,20,21,22,5,34,30,31,16,17,15,23,41,13,39]))),ne=e.lazy(q),se=e.lazy(()=>o(()=>import("./ResourceCenterLauncherHandler.js"),__vite__mapDeps([42,1,2,6,7,8,9,10,11,12,31,21,22,5,18,19,20,43,30,34,4,15,16,17,23,13,24,39,29,32,33,44,45,46,41]))),oe=e.lazy(()=>o(()=>import("./LauncherApp.js"),__vite__mapDeps([47,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([48,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([49,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([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,51]))),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};
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,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,9 +1,9 @@
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","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
- 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]="f7476079-5daf-4179-972e-1757453369a6",e._sentryDebugIdIdentifier="sentry-dbid-f7476079-5daf-4179-972e-1757453369a6")}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.
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
+ 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]));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([31,1,2,3,4,5,6,15,12,13,14,9,10,11,8,7,16,18,19,17,20,30,21,32,33])),N="1024673",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([34,1,2,3,4,5,6,18,19,35,36,37,38,39,40,41,42,43,44,27,15,12,13,14,9,10,11,25,26,20,8,45,28,46,47,32,33]));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="1024807",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
- `+i.details.map(r=>(r.path?`${r.path}: `:"")+r.message):""))})}async startImplicitTracking(){await I(()=>import("./implicit-tracking.js"),__vite__mapDeps([48,11,2,33,32])).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,`
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,`
8
8
  Client message:`,t,`
9
9
  Error:`,u),i&&n(new h(c))});this.channel.push("client_message",t).receive("ok",u=>{a(),s(u)}).receive("error",u=>{a();const c=`Userflow.js error reply (${u.code}): ${u.message}`;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.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([49,1,2,18,19,3,4,5,6,17,12,13,14,9,10,11,20,22,15,47,46,45,28,32,33]));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([50,1,2,18,19,3,4,5,6,32,33]));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]="330f26af-ad3a-486a-8543-ce8770057cf4",e._sentryDebugIdIdentifier="sentry-dbid-330f26af-ad3a-486a-8543-ce8770057cf4")}catch{}})();var p=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};p.SENTRY_RELEASE={id:"4fe2a6c320cfad5d44060cb4af6a9deeaa1e7da0"};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 l={},r=0;r<10;r++)l["_"+String.fromCharCode(r)]=r;var o=Object.getOwnPropertyNames(l).map(function(n){return l[n]});if(o.join("")!=="0123456789")return!1;var a={};return"abcdefghijklmnopqrst".split("").forEach(function(n){a[n]=n}),Object.keys(Object.assign({},a)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return i=g()?Object.assign:function(t,l){for(var r,o=b(t),a,n=1;n<arguments.length;n++){r=Object(arguments[n]);for(var d in r)s.call(r,d)&&(o[d]=r[d]);if(e){a=e(r);for(var f=0;f<a.length;f++)u.call(r,a[f])&&(o[a[f]]=r[a[f]])}}return o},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]="a1c4463e-9566-477a-8dc6-fec2a35d055a",e._sentryDebugIdIdentifier="sentry-dbid-a1c4463e-9566-477a-8dc6-fec2a35d055a")}catch{}})();var p=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};p.SENTRY_RELEASE={id:"f1a7ee4c52358da0be3096f9fc0c4895a1caa2a5"};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,u;function j(){if(u)return i;u=1;var e=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,c=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 l={},r=0;r<10;r++)l["_"+String.fromCharCode(r)]=r;var o=Object.getOwnPropertyNames(l).map(function(n){return l[n]});if(o.join("")!=="0123456789")return!1;var a={};return"abcdefghijklmnopqrst".split("").forEach(function(n){a[n]=n}),Object.keys(Object.assign({},a)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return i=g()?Object.assign:function(t,l){for(var r,o=b(t),a,n=1;n<arguments.length;n++){r=Object(arguments[n]);for(var d in r)s.call(r,d)&&(o[d]=r[d]);if(e){a=e(r);for(var f=0;f<a.length;f++)c.call(r,a[f])&&(o[a[f]]=r[a[f]])}}return o},i}export{y as c,w as g,j as r};
2
2
  //# sourceMappingURL=vendor.object-assign.js.map