userflow.js-self-hosted 0.1.1025218 → 0.1.1025288

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/FlowChrome.js CHANGED
@@ -1,3 +1,3 @@
1
- import{a4 as ye,a5 as Le,a2 as ve,U as Be}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{R as p,r as s}from"./vendor.react.js";import{D as Dt,u as Me,g as ke}from"./stylesheets.js";import"./vendor.object-assign.js";import{u as de}from"./vendor.react-i18next.js";import{F as ie}from"./Frame.js";import{c as G,p as L,b as ft,r as Re,Y as O,B as je,Z as f}from"./userflow.js";import{a as Pe,f as Oe}from"./flow-host.styl.js";import{u as Ne,b as xe}from"./use-selector-element-monitoring.js";import{u as Ie}from"./use-window-resize.js";import{S as _e}from"./logomark.js";import{o as $t}from"./vendor.obj-str.js";import{k as Yt,j as Ft,s as ct,t as He,u as De,l as ue,v as Ce,M as ce,w as Ct,p as Fe,q as Se,x as Ue,y as Ve}from"./roots.js";import{u as We}from"./use-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]="7823609d-fe73-4786-8630-4051cc646337",e._sentryDebugIdIdentifier="sentry-dbid-7823609d-fe73-4786-8630-4051cc646337")}catch{}})();const bo=({draftMode:e,muted:t,toggleMuted:o,close:w,minimize:E})=>{const{t:c}=de();return p.createElement("div",{className:"userflowjs-bubble-toolbar"},e&&p.createElement("div",{className:"userflowjs-bubble-draft"},typeof e=="string"?e:"Preview"),o&&p.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:o,"aria-label":t?"Unmute":"Mute"},t?p.createElement(Dt,{icon:ye}):p.createElement(Dt,{icon:Le})),E&&p.createElement("button",{"data-testid":"minimize-button",className:"userflowjs-bubble-toolbar-button",onClick:E,"aria-label":"Minimize checklist"},p.createElement(Dt,{icon:ve})),w&&p.createElement("button",{"data-testid":"close-button",className:"userflowjs-bubble-toolbar-button",onClick:w,"aria-label":c("menu.close")},p.createElement(Dt,{icon:Be})))},Ae=new URL("avatar-frame.css",import.meta.url).href;function ze(e,t){const o=window.Intercom;s.useEffect(()=>{if(!(!t||!e.autoHideIntercom||typeof o!="function"||G.autoHide3pDisabled)){try{o("update",{hide_default_launcher:!0})}catch(l){console.warn("Userflow.js: Error when hiding Intercom launcher",l)}return()=>{if(!G.autoHide3pDisabled)try{o("update",{hide_default_launcher:!1})}catch(l){console.warn("Userflow.js: Error when unhiding Intercom launcher",l)}}}},[o,e.autoHideIntercom,t]);const w=window.$crisp;s.useEffect(()=>{if(!(!t||!e.autoHideCrisp||!w||G.autoHide3pDisabled)){try{w.push(["do","chat:hide"])}catch(l){console.warn("Userflow.js: Error when hiding Crisp Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{w.push(["do","chat:show"])}catch(l){console.warn("Userflow.js: Error when unhiding Crisp Chat",l)}}}},[w,e.autoHideCrisp,t]);const E=window.HubSpotConversations;s.useEffect(()=>{if(!(!t||!e.autoHideHubspot||!E||G.autoHide3pDisabled)){try{E.widget.remove()}catch(l){console.warn("Userflow.js: Error when hiding HubSpot Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{E.widget.load()}catch(l){console.warn("Userflow.js: Error when unhiding HubSpot Chat",l)}}}},[E,e.autoHideHubspot,t]);const c=window.drift;s.useEffect(()=>{if(!(!t||!e.autoHideDrift||!c||G.autoHide3pDisabled)){try{c.api.widget.hide()}catch(l){console.warn("Userflow.js: Error when hiding Drift Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{c.api.widget.show()}catch(l){console.warn("Userflow.js: Error when unhiding Drift Chat",l)}}}},[c,e.autoHideDrift,t])}const Xt=16,Rt=20,mo=({company:e,theme:t,position:o,absoluteWidth:w,absoluteHeight:E,stepKey:c,stepAppearance:l,width:m,backgroundImageUrl:T,tooltipSelector:d,allowMissingTooltipTarget:y,tooltipPlacement:R,backdrop:H,tooltipTargetBlocked:A,backdropPadding:Q,zIndex:N,onTooltipTargetClick:v,onTooltipTargetMissingChange:D,onModalBackdropClick:J,onVisibleChange:tt,speaking:F,noIframe:j,MadeWithUserflow:i,minimizeOnAvatarClick:S,autoHide3pEnabled:M,bubbleFrameRootRef:B,frameWrapperHtmlAttributes:P,rootChildren:x,children:r,isModalAnnouncement:u,confettiEnabled:et})=>{const C=o||"absolute",U=R||null,$=Q||"0",ot=i||$e,nt=Pe(),dt=C==="fixed"?N??nt+1:1,K=dt-1,jt=dt-2,{i18n:Pt}=de(),it=Pt.dir(),bt=s.useRef(null),at=s.useRef(null),lt=s.useRef(null),[Y,Ot]=s.useState(null),gt=s.useRef(null),wt=s.useRef(null),Tt=s.useRef(null),Et=s.useRef(null),yt=s.useRef(null),Lt=s.useRef(null),vt=s.useRef(null),Bt=s.useRef(null),mt=s.useRef(null);s.useLayoutEffect(()=>{const a=bt.current.style;a.animation="none",a.visibility="hidden",a.position="absolute",a.top="-99999px",a.left="-99999px"},[]);const{loaded:Nt}=Me(window,Oe,t),[xt,St]=s.useState(!1),[Ut,g]=s.useState(!1),n=Nt&&xt&&Ut;let[V,st]=s.useState(!1);l!==L.BUBBLE&&(S=!1,V=!1),s.useEffect(()=>{st(!1)},[c]);const k=s.useRef({appearance:null,width:null,theme:t,bubbleFrameHeight:0,backdrop:!1,backdropPadding:"0",prevTooltipTargetParams:null,tooltipTargetParams:null,desiredTooltipPlacement:null,tooltipPlacement:null,lastReportedTooltipTargetMissing:!1,tooltipTargetMissing:!1,tooltipTargetMissingTimeout:void 0,stepKeyScrolledIntoView:void 0,targetScrolledIntoView:null}),[X,_]=s.useState(null),Z=X!=null&&n;s.useEffect(()=>{tt&&tt(Z)},[tt,Z]);const pt=s.useCallback(a=>{k.current.lastReportedTooltipTargetMissing!==a&&(k.current.lastReportedTooltipTargetMissing=a,D&&D(a))},[D]),z=s.useCallback(({forceAppearanceLayout:a,forceUpdatePosition:I}={})=>{const rt=bt.current,Ht=at.current,kt=lt.current,qt=wt.current,Jt=gt.current,Kt=Tt.current,Qt=Et.current,te=yt.current,ee=Lt.current,oe=vt.current,ae=Bt.current,le=mt.current;if(!rt||!Ht||!kt||!Y||!qt||!Jt||!Kt||!Qt||!te||!ee||!oe||!ae||!le||!n)return;const h=k.current,{tooltipTargetParams:Wt}=h;Se();let W=l,se=!1;W===L.TOOLTIP&&!y&&!Wt&&(h.tooltipTargetMissing?(W=L.BUBBLE,se=!0):W=null);const re=W!==h.appearance,we=m!==h.width;if((a||re||we||t!==h.theme||H!=h.backdrop||$!=h.backdropPadding||U!==h.desiredTooltipPlacement)&&(h.appearance=W,h.width=m,h.theme=t,h.backdrop=H,h.backdropPadding=$,h.desiredTooltipPlacement=U,I=!0,Ye({layoutState:h,width:m,position:C,absoluteWidth:w,root:rt,bubble:Ht,bubbleFrameRoot:Y,avatar:qt,avatarNotch:Jt,modalBackdrop:le,dir:it})),!j){const q=Y.offsetHeight,At=Yt(),zt=Ft()<800?0:Xt,Te=t.avatarType===ft.NONE?0:W===L.BUBBLE?Rt+t.avatarSize:W===L.MODAL?t.avatarSize/2:0,ne=At-2*zt-Te,Gt=Math.min(q,ne);if(W&&Gt!==h.bubbleFrameHeight){if(h.bubbleFrameHeight=Gt,b(kt,"height",ct(Gt)),He(kt)&&kt.contentDocument){const Ee=kt.contentDocument.documentElement;Ee.style.overflowY=q<=ne?"hidden":"scroll"}I=!0}}if(I&&W){let q=re;if(W===L.TOOLTIP){const At=h.tooltipTargetParams&&h.tooltipTargetParams.targetEl,zt=h.prevTooltipTargetParams&&h.prevTooltipTargetParams.targetEl;At!==zt&&(q=!0)}h.prevTooltipTargetParams=h.tooltipTargetParams,Xe({layoutState:h,animateIn:q,position:C,absoluteWidth:w,absoluteHeight:E,desiredTooltipPlacement:U,root:rt,bubble:Ht,tooltipNotch:Kt,tooltipBackdrop:Qt,tooltipBlockTop:te,tooltipBlockRight:ee,tooltipBlockBottom:oe,tooltipBlockLeft:ae,dir:it})}if(W===L.TOOLTIP){const q=Wt&&Wt.targetEl;q&&h.stepKeyScrolledIntoView!==c&&h.targetScrolledIntoView!==q&&(h.stepKeyScrolledIntoView=c,h.targetScrolledIntoView=q,qe(q))}else h.stepKeyScrolledIntoView=void 0,h.targetScrolledIntoView=null;pt(se),_(W)},[n,Y,c,l,m,t,C,w,E,y,U,H,$,j,pt,it]),Mt=s.useRef(z);Mt.current=z;const Zt=s.useRef(!1);s.useEffect(()=>{const a=()=>{Zt.current=!0};return window.addEventListener("pagehide",a),()=>window.removeEventListener("pagehide",a)},[]);const It=()=>{window.clearTimeout(k.current.tooltipTargetMissingTimeout),k.current.tooltipTargetMissingTimeout=void 0};s.useLayoutEffect(()=>It,[]);const _t=s.useRef(!1),be=()=>{const a=at.current;_t.current||!a||(Ve(a),_t.current=!0)},Vt=()=>{const a=at.current;!_t.current||!a||(Ue(a),_t.current=!1)};s.useLayoutEffect(()=>Vt,[]),s.useLayoutEffect(()=>{if(l!==L.MODAL||C!=="fixed")return;const a=mt.current,I=at.current;if(!a||!I)return;const rt=De(a,I);return()=>rt()},[l,C]);const me=s.useCallback(()=>{Vt();const a=k.current;if(a.tooltipTargetParams=null,y||(a.tooltipPlacement=null),l!==L.TOOLTIP){It(),a.tooltipTargetMissing=!1;return}if(!y&&!a.tooltipTargetMissingTimeout){a.tooltipTargetMissing=!1;const I=d&&!ue(d)&&d.type===Re.AUTO&&!d.autoData?1:parseFloat(t.tooltipMissingToleranceSeconds)*1e3;a.tooltipTargetMissingTimeout=window.setTimeout(()=>{if(!Zt.current){if(d&&!ue(d)){let rt=d.autoData;if(d.autoData)try{rt=JSON.parse(d.autoData)}catch{}console.warn(`Userflow.js: Tooltip target not found on page.
2
- `,{type:d.type,autoData:rt,excludeText:d.excludeText,precision:d.precision,text:d.text,css:d.css})}It(),a.tooltipTargetMissing=!0,Mt.current()}},I)}Mt.current()},[l,y,d,t.tooltipMissingToleranceSeconds]),pe=s.useCallback(a=>{const I=k.current;It(),Ce(a.targetEl)?be():Vt(),I.tooltipTargetParams&&I.tooltipTargetParams.targetEl!==a.targetEl&&(I.tooltipPlacement=null),I.tooltipTargetParams=a,z({forceUpdatePosition:!0})},[z]);Ne({selector:l===L.TOOLTIP&&d||null,targetMoved:pe,targetLost:me,onTargetClick:v});const he=s.useCallback(()=>z({forceAppearanceLayout:!0}),[z]);Ie(he),s.useEffect(()=>{if(!Y||j||typeof ce!="function")return;let a;const I=new ce(()=>{a||(a=window.requestAnimationFrame(()=>{a=void 0,Mt.current()}))});return I.observe(Y,{childList:!0,attributes:!0,subtree:!0}),()=>{I.disconnect(),a&&window.cancelAnimationFrame(a)}},[Y,j]);const{startConfetti:ge}=We({stepType:l,theme:t,bubbleFrame:lt.current,isBubbleVisible:Z,confettiDelay:400,zIndex:jt});s.useEffect(()=>{Z&&et&&lt.current&&ge(!0)},[et,c,Z]),s.useLayoutEffect(()=>{Mt.current()}),s.useLayoutEffect(()=>{C==="absolute"&&z({forceAppearanceLayout:!0})},[C,w,E]);const ht=a=>{a.preventDefault(),a.stopPropagation()};return ze(t,!!M&&X===L.BUBBLE),p.createElement("div",{ref:bt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:ke(t),dir:it},p.createElement("div",{className:"userflowjs-bubble",ref:at,style:{zIndex:dt}},p.createElement("div",{className:$t({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(t.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!S,"userflowjs-bubble-outline--minimized":V})},p.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...P},p.createElement(ie,{className:"userflowjs-bubble__frame",elRef:lt,stylesheet:xe,theme:t,onStylesheetsLoad:St,noIframe:j,title:l.toLowerCase()},p.createElement("div",{className:"userflowjs-bubble-frame-root",ref:a=>{B&&B(a),Ot(a)},style:T?{backgroundImage:`url("${encodeURI(T)}")`}:void 0},r,e.flowBranding&&!u&&p.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},p.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},p.createElement(ot,{company:e},p.createElement(_e,null),p.createElement("div",null,"Made with Userflow"))))))),p.createElement("div",{ref:gt,className:"userflowjs-bubble__avatar-notch"})),p.createElement(ie,{className:$t({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!S,"userflowjs-bubble__avatar--speaking":!!F}),elRef:wt,stylesheet:Ae,theme:t,onStylesheetsLoad:g,noIframe:j,ariaHidden:!0,title:l.toLowerCase()},p.createElement("div",{className:$t({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!S}),onClick:S?()=>st(a=>!a):void 0},p.createElement(Ge,{theme:t}))),p.createElement("div",{ref:Tt,className:"userflowjs-bubble__tooltip-notch"})),p.createElement("div",{ref:Et,className:"userflowjs-tooltip-backdrop",onMouseDown:ht,style:{zIndex:K,pointerEvents:A?void 0:"none"}}),p.createElement("div",{ref:yt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:Lt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:vt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:Bt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:mt,className:"userflowjs-modal-backdrop",onMouseDown:ht,onClick:J,style:{zIndex:K}}),x&&x({visible:Z,bubbleFrame:lt.current}))},Ge=({theme:e})=>{const t="https://js.userflow.com/cartoon-avatars-no-bg/";let o;return e.avatarType===ft.ASSET&&e.avatarAsset?o=e.avatarAsset.assetUrl:e.avatarType===ft.CARTOON&&e.avatarName?o=t+e.avatarName+".svg?3":e.avatarType===ft.URL&&e.avatarUrl?o=e.avatarUrl:o=t+"none.svg",p.createElement("img",{src:o,alt:""})},$e=({company:e,children:t})=>p.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+e.slug,target:"_blank",rel:"noopener noreferrer"},t);function Ye({layoutState:{appearance:e,theme:t,backdrop:o,tooltipTargetMissing:w},width:E,position:c,absoluteWidth:l,root:m,bubble:T,bubbleFrameRoot:d,avatar:y,avatarNotch:R,modalBackdrop:H,dir:A}){const Q=c==="absolute"?l||1024:ct(Ft()),{avatarSize:N,bubblePlacement:v}=t;let D=t.bubbleWidth,J=null,tt=null,F=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${e?.toLowerCase()}`,j="hidden",i=null,S=null,M=null,B=null,P="userflowjs-bubble__avatar-notch",x="hidden",r=null,u=null,et=null,C=null,U="userflowjs-modal-backdrop";switch((e===L.MODAL||!w&&e===L.BUBBLE&&o)&&(U+=" userflowjs-modal-backdrop--visible"),e){case L.BUBBLE:if(t.avatarType!==ft.NONE){j="",x="",v===O.TOP_LEFT||v===O.TOP_CENTER||v===O.TOP_RIGHT?(J=N+Rt,i=0,r=-2*Rt,P+=" userflowjs-bubble__avatar-notch--top"):(tt=N+Rt,M=0,et=-2*Rt,P+=" userflowjs-bubble__avatar-notch--bottom");const ot=v===O.TOP_LEFT||v===O.TOP_CENTER||v===O.BOTTOM_LEFT||v===O.BOTTOM_CENTER||v===O.CENTER;A==="ltr"&&ot||A==="rtl"&&!ot?(B=0,C=N,P+=" userflowjs-bubble__avatar-notch--left"):(S=0,u=N,P+=" userflowjs-bubble__avatar-notch--right")}break;case L.MODAL:D=t.modalWidth,t.avatarType!==ft.NONE&&(j="",B=`calc(50% - ${N/2}px)`,i=-N/2);break;case L.TOOLTIP:D=t.tooltipWidth;break}E!=null&&(D=E),D=Math.min(D,Q-2*Xt),m.classList.toggle("userflowjs-flow-chrome--position-absolute",c==="absolute"),m.classList.toggle("userflowjs-flow-chrome--position-relative",c==="relative"),m.classList.toggle("userflowjs-flow-chrome--position-fixed",c==="fixed"),m.classList.toggle("userflowjs-flow-chrome--appearance-modal",e===L.MODAL);const $=e!=null&&e!==L.HIDDEN;m.style.position="",m.style.top="",m.style.left="",m.style.visibility=$?"":"hidden",m.style.animation=$?"":"none",b(T,"width",ct(D)),b(T,"padding-top",J),b(T,"padding-bottom",tt),d.className=F,b(y,"width",ct(t.avatarSize)),b(y,"height",ct(t.avatarSize)),y.style.visibility=j,b(y,"top",i),b(y,"right",S),b(y,"bottom",M),b(y,"left",B),R.className=P,R.style.visibility=x,b(R,"top",r),b(R,"right",u),b(R,"bottom",et),b(R,"left",C),H.className=U}function Xe({layoutState:e,animateIn:t,position:o,absoluteWidth:w,absoluteHeight:E,desiredTooltipPlacement:c,root:l,bubble:m,tooltipNotch:T,tooltipBackdrop:d,tooltipBlockTop:y,tooltipBlockRight:R,tooltipBlockBottom:H,tooltipBlockLeft:A,dir:Q}){const{appearance:N,theme:v,tooltipTargetParams:D,backdrop:J,backdropPadding:tt}=e,{bubblePlacement:F}=v,j=Xt,i=v.tooltipNotchSize,S=10,{width:M,height:B}=m.getBoundingClientRect(),P=o==="absolute"?w||1024:ct(Ft()),x=o==="absolute"?E||768:ct(Yt());let r=0,u=0,et="userflowjs-bubble__tooltip-notch",C="hidden",U=null,$=null,ot=null,nt=null,dt="userflowjs-tooltip-backdrop",K=null,jt=null,Pt=null,it=null,bt=null,at=null,lt=null,Y=null,Ot="userflowjs-tooltip-block userflowjs-tooltip-block--top",gt=null,wt=null,Tt="userflowjs-tooltip-block userflowjs-tooltip-block--right",Et=null,yt=null,Lt="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",vt=null,Bt=null,mt="userflowjs-tooltip-block userflowjs-tooltip-block--left",Nt=null,xt=null;switch(N){case L.BUBBLE:{F===O.TOP_LEFT||F===O.BOTTOM_LEFT?r=v.bubbleX:F===O.TOP_CENTER||F===O.CENTER||F===O.BOTTOM_CENTER?r=(P-M)/2:r=P-M-v.bubbleX,F===O.TOP_LEFT||F===O.TOP_CENTER||F===O.TOP_RIGHT?u=v.bubbleY:F===O.CENTER?u=(x-B)/2:u=x-B-v.bubbleY,Q==="rtl"&&(r=P-r-M),r=Math.max(0,Math.min(P-M,r)),u=Math.max(0,Math.min(x-B,u));break}case L.MODAL:{let g=j;v.avatarType!==ft.NONE&&(g+=v.avatarSize/2),r=j+(P-j*2-M)/2,u=g+(x-g-j-B)/2;break}case L.TOOLTIP:{let g;if(D){let{targetRect:n,viewportClipRect:V}=D;if(o==="absolute"){const _=l.offsetParent.getBoundingClientRect();V={top:0,right:P,bottom:x,left:0},n={top:n.top-_.top,right:n.right-_.left,bottom:n.bottom-_.top,left:n.left-_.left,width:n.width,height:n.height}}let st=0;if(J){const{paddingTop:_,paddingRight:Z,paddingBottom:pt,paddingLeft:z}=Je(tt);n={top:n.top-_,right:n.right+Z,bottom:n.bottom+pt,left:n.left-z,width:n.width+z+Z,height:n.height+_+pt},st=Math.min(_,Z,pt,z)}const k=n,X=v.backdropHighlightType==je.OUTSIDE?v.backdropHighlightSpread:0;if(J&&X&&(n={top:n.top-X,right:n.right+X,bottom:n.bottom+X,left:n.left-X,width:n.width+2*X,height:n.height+2*X}),g=Ze({targetRect:n,bubbleWidth:M,bubbleHeight:B,containerWidth:P,containerHeight:x,viewportClipRect:V,tooltipNotchSize:i,currentTooltipPlacement:e.tooltipPlacement,desiredTooltipPlacement:c}),g===f.BELOW||g===f.ABOVE?(r=n.left+n.width/2-M/2,r=Math.max(j,Math.min(P-M-j,r)),nt=Math.max(S,Math.min(M-S-i*2,n.left+n.width/2-i-r)),g===f.BELOW?U=-i*2:ot=-i*2):g===f.RIGHT?(r=n.right+i,r=Math.max(r,V.left+i),r=Math.min(r,V.right+i),r=Math.max(r,i),r=Math.min(r,P-M)):(r=n.left-i-M,r=Math.max(r,V.left-M-i),r=Math.min(r,V.right-M-i),r=Math.max(r,0),r=Math.min(r,P-M-i)),g===f.LEFT||g===f.RIGHT?(u=n.top+n.height/2-B/2,u=Math.max(j,Math.min(x-B-j,u)),U=Math.max(S,Math.min(B-S-i*2,n.top+n.height/2-i-u)),g===f.LEFT?$=-i*2:nt=-i*2):g===f.BELOW?(u=n.bottom+i,u=Math.max(u,V.top+i),u=Math.min(u,V.bottom+i),u=Math.max(u,i),u=Math.min(u,x-B)):(u=n.top-i-B,u=Math.max(u,V.top-B-i),u=Math.min(u,V.bottom-B-i),u=Math.max(u,0),u=Math.min(u,x-B-i)),J){const _=window.getComputedStyle(D.targetEl);K=Math.max(0,k.top),jt=Math.max(0,P-k.right),Pt=Math.max(0,x-k.bottom),it=Math.max(0,k.left),bt=Math.max(0,Ct(_.borderTopLeftRadius)+st),at=Math.max(0,Ct(_.borderTopRightRadius)+st),lt=Math.max(0,Ct(_.borderBottomRightRadius)+st),Y=Math.max(0,Ct(_.borderBottomLeftRadius)+st),gt=Math.max(0,k.right),wt=Math.max(0,k.top),Et=Math.max(0,k.right),yt=Math.max(0,k.bottom),vt=Math.max(0,k.left),Bt=Math.max(0,k.bottom),Nt=Math.max(0,k.left),xt=Math.max(0,k.top)}}else g=c||f.BELOW,(g===f.BELOW||g===f.ABOVE)&&(nt=M/2-i,g===f.BELOW?U=-i*2:ot=-i*2),(g===f.LEFT||g===f.RIGHT)&&(U=B/2-i,g===f.LEFT?$=-i*2:nt=-i*2);e.tooltipPlacement=g,et+=` userflowjs-bubble__tooltip-notch--${g.toLowerCase()}`,C="",J&&(dt+=" userflowjs-tooltip-backdrop--visible",Ot+=" userflowjs-tooltip-block--visible",Tt+=" userflowjs-tooltip-block--visible",Lt+=" userflowjs-tooltip-block--visible",mt+=" userflowjs-tooltip-block--visible");break}}m.style.transition="";let St=r,Ut=u;if(t&&(m.style.opacity="0",N===L.TOOLTIP))switch(e.tooltipPlacement){case f.BELOW:u+=24;break;case f.ABOVE:u-=24;break;case f.RIGHT:r+=24;break;case f.LEFT:r-=24;break}if(o!=="relative"&&fe(m,r,u),T.className=et,T.style.visibility=C,b(T,"top",U),b(T,"right",$),b(T,"bottom",ot),b(T,"left",nt),d.className=dt,b(d,"top",K),b(d,"right",jt),b(d,"bottom",Pt),b(d,"left",it),b(d,"border-top-left-radius",bt),b(d,"border-top-right-radius",at),b(d,"border-bottom-right-radius",lt),b(d,"border-bottom-left-radius",Y),y.className=Ot,b(y,"width",gt),b(y,"height",wt),R.className=Tt,b(R,"left",Et),b(R,"height",yt),H.className=Lt,b(H,"left",vt),b(H,"top",Bt),A.className=mt,b(A,"width",Nt),b(A,"top",xt),t){m.offsetWidth;const g="opacity 250ms linear";N===L.TOOLTIP?m.style.transition=`${g}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:m.style.transition=g,m.style.opacity="1",o!=="relative"&&fe(m,St,Ut)}}function Ze({targetRect:e,bubbleWidth:t,bubbleHeight:o,containerWidth:w,containerHeight:E,viewportClipRect:c,tooltipNotchSize:l,currentTooltipPlacement:m,desiredTooltipPlacement:T}){if(e.bottom<=c.top)return o+l<=E-c.top?f.BELOW:f.ABOVE;if(e.top>=c.bottom)return o+l<=c.bottom?f.ABOVE:f.BELOW;if(e.right<=c.left)return t+l<=w-c.left?f.RIGHT:f.LEFT;if(e.left>=c.right)return t+l<=c.right?f.LEFT:f.RIGHT;const d=R=>{const H=e.left+e.width/2,A=H>=c.left&&H<=c.right,Q=e.top+e.height/2,N=Q>=c.top&&Q<=c.bottom;switch(R){case f.BELOW:return E-e.bottom>o+l&&A;case f.ABOVE:return e.top>o+l&&A;case f.RIGHT:return w-e.right>t+l&&N;case f.LEFT:return e.left>t+l&&N}};if(T&&d(T))return T;if(m&&d(m))return m;const y=[{placement:f.BELOW,dist:e.top},{placement:f.ABOVE,dist:E-e.bottom},{placement:f.RIGHT,dist:e.left},{placement:f.LEFT,dist:w-e.right}];y.sort((R,H)=>R.dist-H.dist);for(const{placement:R}of y)if(d(R))return R;return f.BELOW}function b(e,t,o){o==null?e.style.removeProperty(t):e.style.setProperty(t,typeof o=="number"?o+"px":o,"important")}function fe(e,t,o){t=Math.round(t),o=Math.round(o),e.style.transform=`translate3d(${t}px, ${o}px, 0px)`}function qe(e){if(G.customScrollIntoView){G.customScrollIntoView(e);return}const{scrollPadding:t}=G;if(t&&Fe(e)===document.scrollingElement){const o=t.top||0,w=t.right||0,E=t.bottom||0,c=t.left||0;let l=0,m=0;const T=e.getBoundingClientRect(),d=Ft(),y=Yt();if(T.top<o?l=T.top-o:T.bottom>y-E&&(l=T.bottom-y+E),T.left<c?m=T.left-c:T.right>d-w&&(m=T.right-d+w),l!=0||m!=0){window.scrollBy({top:l,left:m,behavior:"smooth"});return}}try{e.scrollIntoView({behavior:"smooth",block:"nearest"})}catch(o){console.warn("Userflow.js: scrollIntoView error (falling back to no options).",o),e.scrollIntoView()}}function Je(e){if(!e||e==="0")return{paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0};const t=e.trim().split(" ");if(t.length===1){const o=ut(t[0]);return{paddingTop:o,paddingRight:o,paddingBottom:o,paddingLeft:o}}else if(t.length===2){const o=ut(t[0]),w=ut(t[1]);return{paddingTop:o,paddingRight:w,paddingBottom:o,paddingLeft:w}}else return{paddingTop:ut(t[0]),paddingRight:ut(t[1]),paddingBottom:ut(t[2]),paddingLeft:ut(t[3])}}function ut(e){const t=parseInt(e,10);return isNaN(t)?0:t}export{bo as B,mo as F};
1
+ import{a4 as ye,a5 as Le,a2 as ve,U as Be}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{R as p,r as s}from"./vendor.react.js";import{D as Dt,u as Me,g as ke}from"./stylesheets.js";import"./vendor.object-assign.js";import{u as de}from"./vendor.react-i18next.js";import{F as ie}from"./Frame.js";import{c as G,p as L,b as ft,r as Re,Y as O,B as je,Z as f}from"./userflow.js";import{a as Pe,f as Oe}from"./flow-host.styl.js";import{u as Ne,b as xe}from"./use-selector-element-monitoring.js";import{u as Ie}from"./use-window-resize.js";import{S as _e}from"./logomark.js";import{o as $t}from"./vendor.obj-str.js";import{k as Yt,j as Ft,s as ct,t as He,u as De,l as ue,v as Ce,M as ce,w as Ct,p as Fe,q as Se,x as Ue,y as Ve}from"./roots.js";import{u as We}from"./use-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]="c7d154a8-2603-4da6-8af9-e6372e76c041",e._sentryDebugIdIdentifier="sentry-dbid-c7d154a8-2603-4da6-8af9-e6372e76c041")}catch{}})();const bo=({draftMode:e,muted:t,toggleMuted:o,close:w,minimize:E})=>{const{t:c}=de();return p.createElement("div",{className:"userflowjs-bubble-toolbar"},e&&p.createElement("div",{className:"userflowjs-bubble-draft"},typeof e=="string"?e:"Preview"),o&&p.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:o,"aria-label":t?"Unmute":"Mute"},t?p.createElement(Dt,{icon:ye}):p.createElement(Dt,{icon:Le})),E&&p.createElement("button",{"data-testid":"minimize-button",className:"userflowjs-bubble-toolbar-button",onClick:E,"aria-label":"Minimize checklist"},p.createElement(Dt,{icon:ve})),w&&p.createElement("button",{"data-testid":"close-button",className:"userflowjs-bubble-toolbar-button",onClick:w,"aria-label":c("menu.close")},p.createElement(Dt,{icon:Be})))},Ae=new URL("avatar-frame.css",import.meta.url).href;function ze(e,t){const o=window.Intercom;s.useEffect(()=>{if(!(!t||!e.autoHideIntercom||typeof o!="function"||G.autoHide3pDisabled)){try{o("update",{hide_default_launcher:!0})}catch(l){console.warn("Userflow.js: Error when hiding Intercom launcher",l)}return()=>{if(!G.autoHide3pDisabled)try{o("update",{hide_default_launcher:!1})}catch(l){console.warn("Userflow.js: Error when unhiding Intercom launcher",l)}}}},[o,e.autoHideIntercom,t]);const w=window.$crisp;s.useEffect(()=>{if(!(!t||!e.autoHideCrisp||!w||G.autoHide3pDisabled)){try{w.push(["do","chat:hide"])}catch(l){console.warn("Userflow.js: Error when hiding Crisp Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{w.push(["do","chat:show"])}catch(l){console.warn("Userflow.js: Error when unhiding Crisp Chat",l)}}}},[w,e.autoHideCrisp,t]);const E=window.HubSpotConversations;s.useEffect(()=>{if(!(!t||!e.autoHideHubspot||!E||G.autoHide3pDisabled)){try{E.widget.remove()}catch(l){console.warn("Userflow.js: Error when hiding HubSpot Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{E.widget.load()}catch(l){console.warn("Userflow.js: Error when unhiding HubSpot Chat",l)}}}},[E,e.autoHideHubspot,t]);const c=window.drift;s.useEffect(()=>{if(!(!t||!e.autoHideDrift||!c||G.autoHide3pDisabled)){try{c.api.widget.hide()}catch(l){console.warn("Userflow.js: Error when hiding Drift Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{c.api.widget.show()}catch(l){console.warn("Userflow.js: Error when unhiding Drift Chat",l)}}}},[c,e.autoHideDrift,t])}const Xt=16,Rt=20,mo=({company:e,theme:t,position:o,absoluteWidth:w,absoluteHeight:E,stepKey:c,stepAppearance:l,width:m,backgroundImageUrl:T,tooltipSelector:d,allowMissingTooltipTarget:y,tooltipPlacement:R,backdrop:H,tooltipTargetBlocked:A,backdropPadding:Q,zIndex:N,onTooltipTargetClick:v,onTooltipTargetMissingChange:D,onModalBackdropClick:J,onVisibleChange:tt,speaking:F,noIframe:j,MadeWithUserflow:i,minimizeOnAvatarClick:S,autoHide3pEnabled:M,bubbleFrameRootRef:B,frameWrapperHtmlAttributes:P,rootChildren:x,children:r,isModalAnnouncement:u,confettiEnabled:et})=>{const C=o||"absolute",U=R||null,$=Q||"0",ot=i||$e,nt=Pe(),dt=C==="fixed"?N??nt+1:1,K=dt-1,jt=dt-2,{i18n:Pt}=de(),it=Pt.dir(),bt=s.useRef(null),at=s.useRef(null),lt=s.useRef(null),[Y,Ot]=s.useState(null),gt=s.useRef(null),wt=s.useRef(null),Tt=s.useRef(null),Et=s.useRef(null),yt=s.useRef(null),Lt=s.useRef(null),vt=s.useRef(null),Bt=s.useRef(null),mt=s.useRef(null);s.useLayoutEffect(()=>{const a=bt.current.style;a.animation="none",a.visibility="hidden",a.position="absolute",a.top="-99999px",a.left="-99999px"},[]);const{loaded:Nt}=Me(window,Oe,t),[xt,St]=s.useState(!1),[Ut,g]=s.useState(!1),n=Nt&&xt&&Ut;let[V,st]=s.useState(!1);l!==L.BUBBLE&&(S=!1,V=!1),s.useEffect(()=>{st(!1)},[c]);const k=s.useRef({appearance:null,width:null,theme:t,bubbleFrameHeight:0,backdrop:!1,backdropPadding:"0",prevTooltipTargetParams:null,tooltipTargetParams:null,desiredTooltipPlacement:null,tooltipPlacement:null,lastReportedTooltipTargetMissing:!1,tooltipTargetMissing:!1,tooltipTargetMissingTimeout:void 0,stepKeyScrolledIntoView:void 0,targetScrolledIntoView:null}),[X,_]=s.useState(null),Z=X!=null&&n;s.useEffect(()=>{tt&&tt(Z)},[tt,Z]);const pt=s.useCallback(a=>{k.current.lastReportedTooltipTargetMissing!==a&&(k.current.lastReportedTooltipTargetMissing=a,D&&D(a))},[D]),z=s.useCallback(({forceAppearanceLayout:a,forceUpdatePosition:I}={})=>{const rt=bt.current,Ht=at.current,kt=lt.current,qt=wt.current,Jt=gt.current,Kt=Tt.current,Qt=Et.current,te=yt.current,ee=Lt.current,oe=vt.current,ae=Bt.current,le=mt.current;if(!rt||!Ht||!kt||!Y||!qt||!Jt||!Kt||!Qt||!te||!ee||!oe||!ae||!le||!n)return;const h=k.current,{tooltipTargetParams:Wt}=h;Se();let W=l,se=!1;W===L.TOOLTIP&&!y&&!Wt&&(h.tooltipTargetMissing?(W=L.BUBBLE,se=!0):W=null);const re=W!==h.appearance,we=m!==h.width;if((a||re||we||t!==h.theme||H!=h.backdrop||$!=h.backdropPadding||U!==h.desiredTooltipPlacement)&&(h.appearance=W,h.width=m,h.theme=t,h.backdrop=H,h.backdropPadding=$,h.desiredTooltipPlacement=U,I=!0,Ye({layoutState:h,width:m,position:C,absoluteWidth:w,root:rt,bubble:Ht,bubbleFrameRoot:Y,avatar:qt,avatarNotch:Jt,modalBackdrop:le,dir:it})),!j){const q=Y.offsetHeight,At=Yt(),zt=Ft()<800?0:Xt,Te=t.avatarType===ft.NONE?0:W===L.BUBBLE?Rt+t.avatarSize:W===L.MODAL?t.avatarSize/2:0,ne=At-2*zt-Te,Gt=Math.min(q,ne);if(W&&Gt!==h.bubbleFrameHeight){if(h.bubbleFrameHeight=Gt,b(kt,"height",ct(Gt)),He(kt)&&kt.contentDocument){const Ee=kt.contentDocument.documentElement;Ee.style.overflowY=q<=ne?"hidden":"scroll"}I=!0}}if(I&&W){let q=re;if(W===L.TOOLTIP){const At=h.tooltipTargetParams&&h.tooltipTargetParams.targetEl,zt=h.prevTooltipTargetParams&&h.prevTooltipTargetParams.targetEl;At!==zt&&(q=!0)}h.prevTooltipTargetParams=h.tooltipTargetParams,Xe({layoutState:h,animateIn:q,position:C,absoluteWidth:w,absoluteHeight:E,desiredTooltipPlacement:U,root:rt,bubble:Ht,tooltipNotch:Kt,tooltipBackdrop:Qt,tooltipBlockTop:te,tooltipBlockRight:ee,tooltipBlockBottom:oe,tooltipBlockLeft:ae,dir:it})}if(W===L.TOOLTIP){const q=Wt&&Wt.targetEl;q&&h.stepKeyScrolledIntoView!==c&&h.targetScrolledIntoView!==q&&(h.stepKeyScrolledIntoView=c,h.targetScrolledIntoView=q,qe(q))}else h.stepKeyScrolledIntoView=void 0,h.targetScrolledIntoView=null;pt(se),_(W)},[n,Y,c,l,m,t,C,w,E,y,U,H,$,j,pt,it]),Mt=s.useRef(z);Mt.current=z;const Zt=s.useRef(!1);s.useEffect(()=>{const a=()=>{Zt.current=!0};return window.addEventListener("pagehide",a),()=>window.removeEventListener("pagehide",a)},[]);const It=()=>{window.clearTimeout(k.current.tooltipTargetMissingTimeout),k.current.tooltipTargetMissingTimeout=void 0};s.useLayoutEffect(()=>It,[]);const _t=s.useRef(!1),be=()=>{const a=at.current;_t.current||!a||(Ve(a),_t.current=!0)},Vt=()=>{const a=at.current;!_t.current||!a||(Ue(a),_t.current=!1)};s.useLayoutEffect(()=>Vt,[]),s.useLayoutEffect(()=>{if(l!==L.MODAL||C!=="fixed")return;const a=mt.current,I=at.current;if(!a||!I)return;const rt=De(a,I);return()=>rt()},[l,C]);const me=s.useCallback(()=>{Vt();const a=k.current;if(a.tooltipTargetParams=null,y||(a.tooltipPlacement=null),l!==L.TOOLTIP){It(),a.tooltipTargetMissing=!1;return}if(!y&&!a.tooltipTargetMissingTimeout){a.tooltipTargetMissing=!1;const I=d&&!ue(d)&&d.type===Re.AUTO&&!d.autoData?1:parseFloat(t.tooltipMissingToleranceSeconds)*1e3;a.tooltipTargetMissingTimeout=window.setTimeout(()=>{if(!Zt.current){if(d&&!ue(d)){let rt=d.autoData;if(d.autoData)try{rt=JSON.parse(d.autoData)}catch{}console.warn(`Userflow.js: Tooltip target not found on page.
2
+ `,{type:d.type,autoData:rt,excludeText:d.excludeText,precision:d.precision,text:d.text,css:d.css})}It(),a.tooltipTargetMissing=!0,Mt.current()}},I)}Mt.current()},[l,y,d,t.tooltipMissingToleranceSeconds]),pe=s.useCallback(a=>{const I=k.current;It(),Ce(a.targetEl)?be():Vt(),I.tooltipTargetParams&&I.tooltipTargetParams.targetEl!==a.targetEl&&(I.tooltipPlacement=null),I.tooltipTargetParams=a,z({forceUpdatePosition:!0})},[z]);Ne({selector:l===L.TOOLTIP&&d||null,targetMoved:pe,targetLost:me,onTargetClick:v});const he=s.useCallback(()=>z({forceAppearanceLayout:!0}),[z]);Ie(he),s.useEffect(()=>{if(!Y||j||typeof ce!="function")return;let a;const I=new ce(()=>{a||(a=window.requestAnimationFrame(()=>{a=void 0,Mt.current()}))});return I.observe(Y,{childList:!0,attributes:!0,subtree:!0}),()=>{I.disconnect(),a&&window.cancelAnimationFrame(a)}},[Y,j]);const{startConfetti:ge}=We({stepType:l,theme:t,bubbleFrame:lt.current,isBubbleVisible:Z,confettiDelay:400,zIndex:jt});s.useEffect(()=>{Z&&et&&lt.current&&ge(!0)},[et,c,Z]),s.useLayoutEffect(()=>{Mt.current()}),s.useLayoutEffect(()=>{C==="absolute"&&z({forceAppearanceLayout:!0})},[C,w,E]);const ht=a=>{a.preventDefault(),a.stopPropagation()};return ze(t,!!M&&X===L.BUBBLE),p.createElement("div",{ref:bt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:ke(t),dir:it},p.createElement("div",{className:"userflowjs-bubble",ref:at,style:{zIndex:dt}},p.createElement("div",{className:$t({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(t.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!S,"userflowjs-bubble-outline--minimized":V})},p.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...P},p.createElement(ie,{className:"userflowjs-bubble__frame",elRef:lt,stylesheet:xe,theme:t,onStylesheetsLoad:St,noIframe:j,title:l.toLowerCase()},p.createElement("div",{className:"userflowjs-bubble-frame-root",ref:a=>{B&&B(a),Ot(a)},style:T?{backgroundSize:"cover",backgroundImage:`url("${encodeURI(T)}")`}:void 0},r,e.flowBranding&&!u&&p.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},p.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},p.createElement(ot,{company:e},p.createElement(_e,null),p.createElement("div",null,"Made with Userflow"))))))),p.createElement("div",{ref:gt,className:"userflowjs-bubble__avatar-notch"})),p.createElement(ie,{className:$t({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!S,"userflowjs-bubble__avatar--speaking":!!F}),elRef:wt,stylesheet:Ae,theme:t,onStylesheetsLoad:g,noIframe:j,ariaHidden:!0,title:l.toLowerCase()},p.createElement("div",{className:$t({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!S}),onClick:S?()=>st(a=>!a):void 0},p.createElement(Ge,{theme:t}))),p.createElement("div",{ref:Tt,className:"userflowjs-bubble__tooltip-notch"})),p.createElement("div",{ref:Et,className:"userflowjs-tooltip-backdrop",onMouseDown:ht,style:{zIndex:K,pointerEvents:A?void 0:"none"}}),p.createElement("div",{ref:yt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:Lt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:vt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:Bt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:mt,className:"userflowjs-modal-backdrop",onMouseDown:ht,onClick:J,style:{zIndex:K}}),x&&x({visible:Z,bubbleFrame:lt.current}))},Ge=({theme:e})=>{const t="https://js.userflow.com/cartoon-avatars-no-bg/";let o;return e.avatarType===ft.ASSET&&e.avatarAsset?o=e.avatarAsset.assetUrl:e.avatarType===ft.CARTOON&&e.avatarName?o=t+e.avatarName+".svg?3":e.avatarType===ft.URL&&e.avatarUrl?o=e.avatarUrl:o=t+"none.svg",p.createElement("img",{src:o,alt:""})},$e=({company:e,children:t})=>p.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+e.slug,target:"_blank",rel:"noopener noreferrer"},t);function Ye({layoutState:{appearance:e,theme:t,backdrop:o,tooltipTargetMissing:w},width:E,position:c,absoluteWidth:l,root:m,bubble:T,bubbleFrameRoot:d,avatar:y,avatarNotch:R,modalBackdrop:H,dir:A}){const Q=c==="absolute"?l||1024:ct(Ft()),{avatarSize:N,bubblePlacement:v}=t;let D=t.bubbleWidth,J=null,tt=null,F=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${e?.toLowerCase()}`,j="hidden",i=null,S=null,M=null,B=null,P="userflowjs-bubble__avatar-notch",x="hidden",r=null,u=null,et=null,C=null,U="userflowjs-modal-backdrop";switch((e===L.MODAL||!w&&e===L.BUBBLE&&o)&&(U+=" userflowjs-modal-backdrop--visible"),e){case L.BUBBLE:if(t.avatarType!==ft.NONE){j="",x="",v===O.TOP_LEFT||v===O.TOP_CENTER||v===O.TOP_RIGHT?(J=N+Rt,i=0,r=-2*Rt,P+=" userflowjs-bubble__avatar-notch--top"):(tt=N+Rt,M=0,et=-2*Rt,P+=" userflowjs-bubble__avatar-notch--bottom");const ot=v===O.TOP_LEFT||v===O.TOP_CENTER||v===O.BOTTOM_LEFT||v===O.BOTTOM_CENTER||v===O.CENTER;A==="ltr"&&ot||A==="rtl"&&!ot?(B=0,C=N,P+=" userflowjs-bubble__avatar-notch--left"):(S=0,u=N,P+=" userflowjs-bubble__avatar-notch--right")}break;case L.MODAL:D=t.modalWidth,t.avatarType!==ft.NONE&&(j="",B=`calc(50% - ${N/2}px)`,i=-N/2);break;case L.TOOLTIP:D=t.tooltipWidth;break}E!=null&&(D=E),D=Math.min(D,Q-2*Xt),m.classList.toggle("userflowjs-flow-chrome--position-absolute",c==="absolute"),m.classList.toggle("userflowjs-flow-chrome--position-relative",c==="relative"),m.classList.toggle("userflowjs-flow-chrome--position-fixed",c==="fixed"),m.classList.toggle("userflowjs-flow-chrome--appearance-modal",e===L.MODAL);const $=e!=null&&e!==L.HIDDEN;m.style.position="",m.style.top="",m.style.left="",m.style.visibility=$?"":"hidden",m.style.animation=$?"":"none",b(T,"width",ct(D)),b(T,"padding-top",J),b(T,"padding-bottom",tt),d.className=F,b(y,"width",ct(t.avatarSize)),b(y,"height",ct(t.avatarSize)),y.style.visibility=j,b(y,"top",i),b(y,"right",S),b(y,"bottom",M),b(y,"left",B),R.className=P,R.style.visibility=x,b(R,"top",r),b(R,"right",u),b(R,"bottom",et),b(R,"left",C),H.className=U}function Xe({layoutState:e,animateIn:t,position:o,absoluteWidth:w,absoluteHeight:E,desiredTooltipPlacement:c,root:l,bubble:m,tooltipNotch:T,tooltipBackdrop:d,tooltipBlockTop:y,tooltipBlockRight:R,tooltipBlockBottom:H,tooltipBlockLeft:A,dir:Q}){const{appearance:N,theme:v,tooltipTargetParams:D,backdrop:J,backdropPadding:tt}=e,{bubblePlacement:F}=v,j=Xt,i=v.tooltipNotchSize,S=10,{width:M,height:B}=m.getBoundingClientRect(),P=o==="absolute"?w||1024:ct(Ft()),x=o==="absolute"?E||768:ct(Yt());let r=0,u=0,et="userflowjs-bubble__tooltip-notch",C="hidden",U=null,$=null,ot=null,nt=null,dt="userflowjs-tooltip-backdrop",K=null,jt=null,Pt=null,it=null,bt=null,at=null,lt=null,Y=null,Ot="userflowjs-tooltip-block userflowjs-tooltip-block--top",gt=null,wt=null,Tt="userflowjs-tooltip-block userflowjs-tooltip-block--right",Et=null,yt=null,Lt="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",vt=null,Bt=null,mt="userflowjs-tooltip-block userflowjs-tooltip-block--left",Nt=null,xt=null;switch(N){case L.BUBBLE:{F===O.TOP_LEFT||F===O.BOTTOM_LEFT?r=v.bubbleX:F===O.TOP_CENTER||F===O.CENTER||F===O.BOTTOM_CENTER?r=(P-M)/2:r=P-M-v.bubbleX,F===O.TOP_LEFT||F===O.TOP_CENTER||F===O.TOP_RIGHT?u=v.bubbleY:F===O.CENTER?u=(x-B)/2:u=x-B-v.bubbleY,Q==="rtl"&&(r=P-r-M),r=Math.max(0,Math.min(P-M,r)),u=Math.max(0,Math.min(x-B,u));break}case L.MODAL:{let g=j;v.avatarType!==ft.NONE&&(g+=v.avatarSize/2),r=j+(P-j*2-M)/2,u=g+(x-g-j-B)/2;break}case L.TOOLTIP:{let g;if(D){let{targetRect:n,viewportClipRect:V}=D;if(o==="absolute"){const _=l.offsetParent.getBoundingClientRect();V={top:0,right:P,bottom:x,left:0},n={top:n.top-_.top,right:n.right-_.left,bottom:n.bottom-_.top,left:n.left-_.left,width:n.width,height:n.height}}let st=0;if(J){const{paddingTop:_,paddingRight:Z,paddingBottom:pt,paddingLeft:z}=Je(tt);n={top:n.top-_,right:n.right+Z,bottom:n.bottom+pt,left:n.left-z,width:n.width+z+Z,height:n.height+_+pt},st=Math.min(_,Z,pt,z)}const k=n,X=v.backdropHighlightType==je.OUTSIDE?v.backdropHighlightSpread:0;if(J&&X&&(n={top:n.top-X,right:n.right+X,bottom:n.bottom+X,left:n.left-X,width:n.width+2*X,height:n.height+2*X}),g=Ze({targetRect:n,bubbleWidth:M,bubbleHeight:B,containerWidth:P,containerHeight:x,viewportClipRect:V,tooltipNotchSize:i,currentTooltipPlacement:e.tooltipPlacement,desiredTooltipPlacement:c}),g===f.BELOW||g===f.ABOVE?(r=n.left+n.width/2-M/2,r=Math.max(j,Math.min(P-M-j,r)),nt=Math.max(S,Math.min(M-S-i*2,n.left+n.width/2-i-r)),g===f.BELOW?U=-i*2:ot=-i*2):g===f.RIGHT?(r=n.right+i,r=Math.max(r,V.left+i),r=Math.min(r,V.right+i),r=Math.max(r,i),r=Math.min(r,P-M)):(r=n.left-i-M,r=Math.max(r,V.left-M-i),r=Math.min(r,V.right-M-i),r=Math.max(r,0),r=Math.min(r,P-M-i)),g===f.LEFT||g===f.RIGHT?(u=n.top+n.height/2-B/2,u=Math.max(j,Math.min(x-B-j,u)),U=Math.max(S,Math.min(B-S-i*2,n.top+n.height/2-i-u)),g===f.LEFT?$=-i*2:nt=-i*2):g===f.BELOW?(u=n.bottom+i,u=Math.max(u,V.top+i),u=Math.min(u,V.bottom+i),u=Math.max(u,i),u=Math.min(u,x-B)):(u=n.top-i-B,u=Math.max(u,V.top-B-i),u=Math.min(u,V.bottom-B-i),u=Math.max(u,0),u=Math.min(u,x-B-i)),J){const _=window.getComputedStyle(D.targetEl);K=Math.max(0,k.top),jt=Math.max(0,P-k.right),Pt=Math.max(0,x-k.bottom),it=Math.max(0,k.left),bt=Math.max(0,Ct(_.borderTopLeftRadius)+st),at=Math.max(0,Ct(_.borderTopRightRadius)+st),lt=Math.max(0,Ct(_.borderBottomRightRadius)+st),Y=Math.max(0,Ct(_.borderBottomLeftRadius)+st),gt=Math.max(0,k.right),wt=Math.max(0,k.top),Et=Math.max(0,k.right),yt=Math.max(0,k.bottom),vt=Math.max(0,k.left),Bt=Math.max(0,k.bottom),Nt=Math.max(0,k.left),xt=Math.max(0,k.top)}}else g=c||f.BELOW,(g===f.BELOW||g===f.ABOVE)&&(nt=M/2-i,g===f.BELOW?U=-i*2:ot=-i*2),(g===f.LEFT||g===f.RIGHT)&&(U=B/2-i,g===f.LEFT?$=-i*2:nt=-i*2);e.tooltipPlacement=g,et+=` userflowjs-bubble__tooltip-notch--${g.toLowerCase()}`,C="",J&&(dt+=" userflowjs-tooltip-backdrop--visible",Ot+=" userflowjs-tooltip-block--visible",Tt+=" userflowjs-tooltip-block--visible",Lt+=" userflowjs-tooltip-block--visible",mt+=" userflowjs-tooltip-block--visible");break}}m.style.transition="";let St=r,Ut=u;if(t&&(m.style.opacity="0",N===L.TOOLTIP))switch(e.tooltipPlacement){case f.BELOW:u+=24;break;case f.ABOVE:u-=24;break;case f.RIGHT:r+=24;break;case f.LEFT:r-=24;break}if(o!=="relative"&&fe(m,r,u),T.className=et,T.style.visibility=C,b(T,"top",U),b(T,"right",$),b(T,"bottom",ot),b(T,"left",nt),d.className=dt,b(d,"top",K),b(d,"right",jt),b(d,"bottom",Pt),b(d,"left",it),b(d,"border-top-left-radius",bt),b(d,"border-top-right-radius",at),b(d,"border-bottom-right-radius",lt),b(d,"border-bottom-left-radius",Y),y.className=Ot,b(y,"width",gt),b(y,"height",wt),R.className=Tt,b(R,"left",Et),b(R,"height",yt),H.className=Lt,b(H,"left",vt),b(H,"top",Bt),A.className=mt,b(A,"width",Nt),b(A,"top",xt),t){m.offsetWidth;const g="opacity 250ms linear";N===L.TOOLTIP?m.style.transition=`${g}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:m.style.transition=g,m.style.opacity="1",o!=="relative"&&fe(m,St,Ut)}}function Ze({targetRect:e,bubbleWidth:t,bubbleHeight:o,containerWidth:w,containerHeight:E,viewportClipRect:c,tooltipNotchSize:l,currentTooltipPlacement:m,desiredTooltipPlacement:T}){if(e.bottom<=c.top)return o+l<=E-c.top?f.BELOW:f.ABOVE;if(e.top>=c.bottom)return o+l<=c.bottom?f.ABOVE:f.BELOW;if(e.right<=c.left)return t+l<=w-c.left?f.RIGHT:f.LEFT;if(e.left>=c.right)return t+l<=c.right?f.LEFT:f.RIGHT;const d=R=>{const H=e.left+e.width/2,A=H>=c.left&&H<=c.right,Q=e.top+e.height/2,N=Q>=c.top&&Q<=c.bottom;switch(R){case f.BELOW:return E-e.bottom>o+l&&A;case f.ABOVE:return e.top>o+l&&A;case f.RIGHT:return w-e.right>t+l&&N;case f.LEFT:return e.left>t+l&&N}};if(T&&d(T))return T;if(m&&d(m))return m;const y=[{placement:f.BELOW,dist:e.top},{placement:f.ABOVE,dist:E-e.bottom},{placement:f.RIGHT,dist:e.left},{placement:f.LEFT,dist:w-e.right}];y.sort((R,H)=>R.dist-H.dist);for(const{placement:R}of y)if(d(R))return R;return f.BELOW}function b(e,t,o){o==null?e.style.removeProperty(t):e.style.setProperty(t,typeof o=="number"?o+"px":o,"important")}function fe(e,t,o){t=Math.round(t),o=Math.round(o),e.style.transform=`translate3d(${t}px, ${o}px, 0px)`}function qe(e){if(G.customScrollIntoView){G.customScrollIntoView(e);return}const{scrollPadding:t}=G;if(t&&Fe(e)===document.scrollingElement){const o=t.top||0,w=t.right||0,E=t.bottom||0,c=t.left||0;let l=0,m=0;const T=e.getBoundingClientRect(),d=Ft(),y=Yt();if(T.top<o?l=T.top-o:T.bottom>y-E&&(l=T.bottom-y+E),T.left<c?m=T.left-c:T.right>d-w&&(m=T.right-d+w),l!=0||m!=0){window.scrollBy({top:l,left:m,behavior:"smooth"});return}}try{e.scrollIntoView({behavior:"smooth",block:"nearest"})}catch(o){console.warn("Userflow.js: scrollIntoView error (falling back to no options).",o),e.scrollIntoView()}}function Je(e){if(!e||e==="0")return{paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0};const t=e.trim().split(" ");if(t.length===1){const o=ut(t[0]);return{paddingTop:o,paddingRight:o,paddingBottom:o,paddingLeft:o}}else if(t.length===2){const o=ut(t[0]),w=ut(t[1]);return{paddingTop:o,paddingRight:w,paddingBottom:o,paddingLeft:w}}else return{paddingTop:ut(t[0]),paddingRight:ut(t[1]),paddingBottom:ut(t[2]),paddingLeft:ut(t[3])}}function ut(e){const t=parseInt(e,10);return isNaN(t)?0:t}export{bo as B,mo as F};
3
3
  //# sourceMappingURL=FlowChrome.js.map
package/TreeDoc.js CHANGED
@@ -1,11 +1,11 @@
1
- import{R as t,r as v}from"./vendor.react.js";import{c as De,g as Le,i as ye,a as ke}from"./flow-condition-types.js";import{b as Ue,D as J}from"./stylesheets.js";import"./vendor.object-assign.js";import{o as D}from"./vendor.obj-str.js";import{c as ie,s as Oe,g as Pe,e as I,f as _e,h as he,E as re,i as C,U as ge,j as _,d as Me}from"./userflow.js";import{b as G}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{u as Be}from"./vendor.react-i18next.js";import{u as xe}from"./client-context.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="8e1b40cb-ec4c-41cf-a1eb-0ffdd1343a3c",e._sentryDebugIdIdentifier="sentry-dbid-8e1b40cb-ec4c-41cf-a1eb-0ffdd1343a3c")}catch{}})();const We=t.createContext(null);function oe(){const e=v.useContext(We);if(!e)throw new Error("useSession: Session was not set");return e}function ze(){const e=oe();if(e.kind!=="flow")throw new Error("useFlowSession: Wrong session kind");return e}function Ve(e){const r=v.useRef(e),n=v.useRef(e);return e!==n.current&&JSON.stringify(e)!==JSON.stringify(n.current)&&(r.current=e),n.current=e,r.current}function ve(e){const r=oe(),[n,i]=v.useState(!1),s=Ue(r.data),a=Ve(e);return v.useLayoutEffect(()=>{if(a)return De[a.type].track({sessionData:s,condition:a,callback:p=>{i(p)}})},[s,a]),a==null?!1:n}const Ke=({appearance:e,hidden:r,disabled:n,onMouseDown:i,onClick:s,text:a,active:l,children:u})=>t.createElement("button",{className:D({[wt(e)]:!0,"userflowjs-bubble-button--hidden":!!r,"userflowjs-bubble-button--active":!!l}),onMouseDown:i,onClick:s,disabled:n},u||t.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},a));function Je(e){const r=Pe(),n=new URL(e,r).toString();r!==n&&(ie.customNavigate?ie.customNavigate(e):window.setTimeout(()=>{Oe(e)},0))}async function ne(e,r,n){const{steps:i}=r.version;switch(n.type){case I.CLOSE_FLOW:switch(r.kind){case"launcher":await e.dismissLauncher(r,{endReason:re.ACTION});break;case"banner":case"flow":case"workflow":case"checklist":await e.endFlow(r,{endReason:re.ACTION});break}return;case I.EVAL_JS:if(ie.evalJsDisabled){console.error('Userflow.js: Blocked "Evaluate JavaScript" action from running, since userflow.disableEvalJs() has been called.');return}try{const s=ye(n.code||"",r.data);new Function(`"use strict";
1
+ import{R as t,r as v}from"./vendor.react.js";import{c as Le,g as De,i as ke,a as _e}from"./flow-condition-types.js";import{b as Ue,D as Q}from"./stylesheets.js";import"./vendor.object-assign.js";import{o as D}from"./vendor.obj-str.js";import{c as ce,s as Oe,g as Pe,e as I,f as xe,h as ge,E as ae,i as C,U as ve,j as N,d as Me}from"./userflow.js";import{b as X}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{u as Be}from"./vendor.react-i18next.js";import{u as Ne}from"./client-context.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b3e26cd5-46c1-4559-8df1-1588d5099c16",e._sentryDebugIdIdentifier="sentry-dbid-b3e26cd5-46c1-4559-8df1-1588d5099c16")}catch{}})();const We=t.createContext(null);function me(){const e=v.useContext(We);if(!e)throw new Error("useSession: Session was not set");return e}function ze(){const e=me();if(e.kind!=="flow")throw new Error("useFlowSession: Wrong session kind");return e}function Ve(e){const n=v.useRef(e),r=v.useRef(e);return e!==r.current&&JSON.stringify(e)!==JSON.stringify(r.current)&&(n.current=e),r.current=e,n.current}function Ee(e){const n=me(),[r,i]=v.useState(!1),s=Ue(n.data),l=Ve(e);return v.useLayoutEffect(()=>{if(l)return Le[l.type].track({sessionData:s,condition:l,callback:b=>{i(b)}})},[s,l]),l==null?!1:r}const Ke=({appearance:e,hidden:n,disabled:r,onMouseDown:i,onClick:s,text:l,active:a,children:m})=>t.createElement("button",{className:D({[pt(e)]:!0,"userflowjs-bubble-button--hidden":!!n,"userflowjs-bubble-button--active":!!a}),onMouseDown:i,onClick:s,disabled:r},m||t.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},l));function Je(e){const n=Pe(),r=new URL(e,n).toString();n!==r&&(ce.customNavigate?ce.customNavigate(e):window.setTimeout(()=>{Oe(e)},0))}async function le(e,n,r){const{steps:i}=n.version;switch(r.type){case I.CLOSE_FLOW:switch(n.kind){case"launcher":await e.dismissLauncher(n,{endReason:ae.ACTION});break;case"banner":case"flow":case"workflow":case"checklist":await e.endFlow(n,{endReason:ae.ACTION});break}return;case I.EVAL_JS:if(ce.evalJsDisabled){console.error('Userflow.js: Blocked "Evaluate JavaScript" action from running, since userflow.disableEvalJs() has been called.');return}try{const s=ke(r.code||"",n.data);new Function(`"use strict";
2
2
  `+s)()}catch(s){console.error(`Userflow.js: Evaluate JavaScript action failed.
3
3
 
4
4
  Error:
5
5
  ${s.stack||s.message||s}
6
6
 
7
7
  Code:
8
- ${n.code}`)}return;case I.GO_TO_STEP:{if(r.kind==="flow"){const s=i.find(({crossVersionId:a})=>a===n.stepCvid);if(!s)throw new ge("Action points to unknown step: "+n.stepCvid);await e.goToStep(r,s)}else if(r.kind==="workflow"){const s=r.version.workflowSteps.find(({crossVersionId:a})=>a===n.stepCvid);if(!s)throw new ge("Action points to unknown step: "+n.stepCvid);await e.goToStep(r,s)}return}case I.NAVIGATE:{if(!n.url){console.warn("Userflow.js: NAVIGATE action is missing url property");return}const s=W(n.url,{lookupAttribute:Le(r.data)});n.navigateTarget===_e.NEW_TAB?window.open(s):Je(s);return}case I.SET_ATTRIBUTE:{let s;const a=n.attributeValue||"";switch(n.attributeOperation){case C.SET:s={set:a};break;case C.SET_DATETIME:s={set:new Date().toISOString()};break;case C.SET_DATETIME_ONCE:s={set_once:new Date().toISOString()};break;case C.SET_ONCE:s={set_once:a};break;case C.ADD:s={add:a};break;case C.SUBTRACT:s={subtract:a};break;case C.APPEND:s={append:a};break;case C.PREPEND:s={prepend:a};break;case C.REMOVE:s={remove:a};break;case C.UNSET:s={set:null};break;default:return}const l=n.attributeFqn||"",u=l.split("/");u.length===1?e.updateUser({[l]:s}):u[0]==="group"?e.updateGroup({[u[1]]:s}):u[0]==="group_membership"&&e.updateGroup({},{membership:{[u[1]]:s}});return}case I.SNOOZE:r.kind==="flow"&&n.timeValue&&n.timeUnit&&(e.endFlow(r,{endReason:re.SNOOZED,batch:!0}),r.draftMode?window.alert(`In preview mode, flows can't be snoozed.
8
+ ${r.code}`)}return;case I.GO_TO_STEP:{if(n.kind==="flow"){const s=i.find(({crossVersionId:l})=>l===r.stepCvid);if(!s)throw new ve("Action points to unknown step: "+r.stepCvid);await e.goToStep(n,s)}else if(n.kind==="workflow"){const s=n.version.workflowSteps.find(({crossVersionId:l})=>l===r.stepCvid);if(!s)throw new ve("Action points to unknown step: "+r.stepCvid);await e.goToStep(n,s)}return}case I.NAVIGATE:{if(!r.url){console.warn("Userflow.js: NAVIGATE action is missing url property");return}const s=z(r.url,{lookupAttribute:De(n.data)});r.navigateTarget===xe.NEW_TAB?window.open(s):Je(s);return}case I.SET_ATTRIBUTE:{let s;const l=r.attributeValue||"";switch(r.attributeOperation){case C.SET:s={set:l};break;case C.SET_DATETIME:s={set:new Date().toISOString()};break;case C.SET_DATETIME_ONCE:s={set_once:new Date().toISOString()};break;case C.SET_ONCE:s={set_once:l};break;case C.ADD:s={add:l};break;case C.SUBTRACT:s={subtract:l};break;case C.APPEND:s={append:l};break;case C.PREPEND:s={prepend:l};break;case C.REMOVE:s={remove:l};break;case C.UNSET:s={set:null};break;default:return}const a=r.attributeFqn||"",m=a.split("/");m.length===1?e.updateUser({[a]:s}):m[0]==="group"?e.updateGroup({[m[1]]:s}):m[0]==="group_membership"&&e.updateGroup({},{membership:{[m[1]]:s}});return}case I.SNOOZE:n.kind==="flow"&&r.timeValue&&r.timeUnit&&(e.endFlow(n,{endReason:ae.SNOOZED,batch:!0}),n.draftMode?window.alert(`In preview mode, flows can't be snoozed.
9
9
 
10
- But if this flow was running in published mode, the flow would now be snoozed for ${n.timeValue} ${n.timeUnit.toLowerCase()+(n.timeValue===1?"":"s")}.`):e.send({kind:"Snooze",flowId:r.flow.id,timeValue:n.timeValue,timeUnit:n.timeUnit},{batch:!0}));return;case I.START_FLOW:r.kind==="launcher"&&e.deactivateLauncher(r),n.otherFlow?await e.startFlow({flowId:n.otherFlow.id,stepCvid:n.otherFlowStepCvid,startReason:r.draftMode?he.DRAFT:he.ACTION,replaceCurrent:!0}):console.warn("Userflow.js: START_FLOW action is missing other flow");return;case I.TRACK_BUTTON_EVENT:{let s=null,a=r?r.id:null;if(r.kind==="flow"){const{currentStep:l}=r;s=l?l?.crossVersionId:null}if(n.buttonEvent){const{eventName:l,token:u}=n.buttonEvent;await e.trackButtonEvent(l,u,s,a)}return}}}async function Ne(e,r,n){const i=[],s=[],a=[];for(const l of n)l.type===I.NAVIGATE?l.navigateTarget===_e.NEW_TAB?i.push(l):a.push(l):s.push(l);for(const l of i)ne(e,r,l);await Promise.all(s.map(l=>ne(e,r,l)));for(const l of a)ne(e,r,l)}const Ge=({button:e})=>{const r=xe(),n=oe(),i=ve(e.disabledCondition),s=ve(e.hiddenCondition);return t.createElement(Ke,{appearance:e.appearance,hidden:s,disabled:i,onClick:()=>Ne(r,n,e.actions),text:ye(e.text,n.data)})},He=()=>t.createElement("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},t.createElement("polygon",{className:"userflowjs-star-shape",fill:"#fff",points:"16 22.7785728 7.18322122 29.1352549 10.5042507 18.7856772 1.73415226 12.3647451 12.6034401 12.3250364 16 2 19.3965599 12.3250364 30.2658477 12.3647451 21.4957493 18.7856772 24.8167788 29.1352549"})),Qe=({type:e,required:r,placeholder:n,buttonText:i,options:s,otherOption:a,multipleSelection:l,shuffleOptions:u,labelLeft:p,labelCenter:d,labelRight:h,minValue:w,maxValue:E,onSubmit:x,inert:f})=>{const{t:m}=Be(),y=v.useRef(null),[c,N]=v.useState(""),[L,$e]=v.useState(new Set),[$,ce]=v.useState(),[me,fe]=v.useState(),[U,z]=v.useState(!1),[g,Q]=v.useState(!1),[F,T]=v.useState(null),O=v.useMemo(()=>s&&(u?[...s].sort(()=>Math.random()-.5):s),[s,u]),q=o=>{if(!(f||!x)){if(r&&c===""&&[_.MULTILINE_TEXT,_.TEXT].includes(e)){T(m("question.requiredError")),X();return}Q(!0),T(null),x({...o,onCancel:()=>{Q(!1)},onError:j=>{Q(!1),T(j||"Sorry, something went wrong saving your answer. Please try again.")}})}},X=v.useCallback(()=>{f||!y.current||y.current.focus()},[f]),[de,be]=v.useState(!1);v.useEffect(()=>{de&&(X(),be(!1))},[X,de]);const we=t.createElement("div",{className:"userflowjs-bubble-buttons"},t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>q({answer:{kind:"text",value:c}}),tabIndex:f?-1:void 0,disabled:g},t.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},i||m("question.submit"))));let S=null,K=0;if(e===_.NPS)p=p||m("question.npsLabelLeft"),h=h||m("question.npsLabelRight"),S=[0,1,2,3,4,5,6,7,8,9,10],K=S.length;else if([_.SCALE,_.STARS].includes(e)){w=w??1,E=E??5,S=[];for(let o=w;o<=E;o++)S.push(o);K=S.length}else e===_.MULTIPLE_CHOICE&&(K=(O?O.length:0)+(a&&!U?1:0));const[pe,Fe]=v.useState(-1),A=pe===-1?-1:Math.min(pe,K-1),Y=o=>{if(!o.target.closest('[role="radio"], [role="checkbox"], [role="radiogroup"], [role="group"]'))return;let k=null;if(o.key==="ArrowRight"||o.key==="ArrowDown"?k=1:(o.key==="ArrowLeft"||o.key==="ArrowUp")&&(k=-1),k!=null){o.preventDefault();const B=o.currentTarget.querySelectorAll('[role="radio"], [role="checkbox"]');let b=A+k;b<0?b=B.length-1:b>B.length-1&&(b=0),Fe(b),B[b].focus()}};let Z=null,ee=null;if(S&&(p||d||h)){const o=[];p&&o.push(S[0],p),h&&o.push(S[S.length-1],h),Z=t.createElement("div",{id:"a11y-scale-labels",className:"userflowjs-a11y-only"},o.join(", ")),ee=t.createElement("div",{id:"userflowjs-bubble-question-labels",className:"userflowjs-bubble-question__scale-labels","aria-hidden":"true"},t.createElement("div",{className:"userflowjs-bubble-question__scale-label"},p),d&&t.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--center"},d),t.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--right"},h))}let P;switch(e){case _.MULTILINE_TEXT:P=t.createElement(t.Fragment,null,t.createElement("textarea",{ref:y,className:"userflowjs-textarea userflowjs-bubble-question__textarea",value:c,onChange:o=>N(o.target.value),onKeyDown:o=>{(o.ctrlKey||o.metaKey)&&o.key==="Enter"&&q({answer:{kind:"text",value:c}})},placeholder:n||m("question.placeholder"),readOnly:f||g,tabIndex:f?-1:void 0,rows:3,"aria-required":r?"true":void 0,"aria-invalid":F!=null?"true":void 0}),we);break;case _.MULTIPLE_CHOICE:{const o=()=>{c&&q({answer:{kind:"text",value:c},animationPromise:H()})},j=(O?.length||0)+(a?1:0),k=Math.max(0,Math.min(j,w??1)),M=Math.max(0,Math.min(j,E??j)),B=()=>{const b=(O||[]).filter((V,R)=>L.has(R)).map(V=>V.value);if(a&&U&&c!==""&&b.push(c),k===M&&b.length!==k){T(m("question.multiple_selection_wrong",{count:k}));return}else if(b.length<k){T(m("question.multiple_selection_too_few",{count:k}));return}else if(b.length>M){T(m("question.multiple_selection_too_many",{count:M}));return}q({answer:{kind:"list",values:b}})};P=t.createElement(t.Fragment,null,l&&t.createElement("div",{className:D({"userflowjs-bubble-question__multiple-choice-hint":!0,"userflowjs-bubble-question__multiple-choice-hint--error":!!F})},m("question.multiple_selection_hint",{replace:{selected:L.size+(a&&U&&c!==""?1:0),range:k===M?k:`${k}-${M}`}}),F&&t.createElement(t.Fragment,null,". ",t.createElement("span",{role:"alert"},F))),t.createElement("div",{className:D({"userflowjs-bubble-question__multiple-choice":!0,"userflowjs-bubble-question__multiple-choice--single-selection":!l,"userflowjs-bubble-question__multiple-choice--multiple-selection":!!l}),role:l?"group":"radiogroup",tabIndex:!f&&A===-1?0:-1,onKeyDown:Y},O?.map(({value:b,label:V},R)=>t.createElement("button",{key:R,className:D({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--selected":l?L.has(R):g&&!U&&c==b}),onClick:g?void 0:()=>{if(l){T(null);const te=new Set(L);L.has(R)?te.delete(R):te.add(R),$e(te)}else z(!1),N(b),q({answer:{kind:"text",value:b},animationPromise:H()})},disabled:g,tabIndex:!f&&R===A?0:-1,role:l?"checkbox":"radio","aria-label":V||b,"aria-checked":!U&&c==b},l?t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},t.createElement(J,{icon:G}))):t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},V||b))),a&&(U?t.createElement("div",{className:D({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--other":!0,"userflowjs-bubble-question__multiple-choice-option--selected":l?c!="":g})},l?t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox",onClick:()=>{N(""),z(!1)}},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},t.createElement(J,{icon:G}))):t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),t.createElement("input",{ref:y,className:"userflowjs-bubble-question__multiple-choice-option-input",value:c,onChange:b=>N(b.target.value),onKeyDown:b=>{!b.shiftKey&&b.key==="Enter"?l?B():o():b.key==="Escape"&&(b.stopPropagation(),N(""),z(!1))},onBlur:()=>{c===""&&z(!1)},placeholder:n||m("question.placeholder"),readOnly:f||g,tabIndex:f?-1:void 0}),!l&&t.createElement("button",{"data-testid":"multiple-choice-other-submit",className:"userflowjs-bubble-question__multiple-choice-option-submit",onClick:()=>o(),disabled:g,"aria-label":m("question.submit")},t.createElement(J,{icon:G}))):t.createElement("button",{className:"userflowjs-bubble-question__multiple-choice-option",onClick:g?void 0:()=>{T(null),z(!0),be(!0)},disabled:g,tabIndex:!f&&O?.length===A?0:-1,role:"radio","aria-label":m("question.other"),"aria-checked":"false"},l?t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},t.createElement(J,{icon:G}))):t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},m("question.other"))))),l&&t.createElement("div",{className:"userflowjs-bubble-buttons"},t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:B,tabIndex:f?-1:void 0,disabled:g},t.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},i||m("question.submit")))));break}case _.NPS:case _.SCALE:{P=t.createElement(t.Fragment,null,Z,t.createElement("div",{className:"userflowjs-bubble-question__scale-options",role:"radiogroup",tabIndex:!f&&A===-1?0:-1,onKeyDown:Y},S?.map((o,j)=>t.createElement("button",{className:D({"userflowjs-bubble-question__scale-option":!0,"userflowjs-bubble-question__scale-option--selected":g&&$==o}),key:o,tabIndex:!f&&j===A?0:-1,onClick:()=>{ce(o),q({answer:{kind:"number",value:o},animationPromise:H()})},disabled:g,role:"radio","aria-checked":$==o},o))),ee);break}case _.STARS:{P=t.createElement("div",{className:"userflowjs-bubble-question__stars-wrapper"},Z,t.createElement("div",{className:"userflowjs-bubble-question__stars",role:"radiogroup",tabIndex:!f&&A===-1?0:-1,onKeyDown:Y},S?.map((o,j)=>t.createElement("button",{className:D({"userflowjs-bubble-question__star":!0,"userflowjs-bubble-question__star--hovered":!g&&me!=null&&me>=o,"userflowjs-bubble-question__star--selected":g&&$!=null&&$>=o,"userflowjs-bubble-question__star--not-selected":g&&$!=null&&$<o}),key:o,tabIndex:!f&&j===A?0:-1,onClick:()=>{ce(o),q({answer:{kind:"number",value:o},animationPromise:H()})},onMouseOver:()=>fe(o),onMouseLeave:()=>fe(null),disabled:g,role:"radio","aria-checked":$==o,"aria-label":String(o)},t.createElement("div",{className:"userflowjs-bubble-question__star-icon","aria-hidden":"true"},t.createElement(He,null)),t.createElement("div",{className:"userflowjs-bubble-question__star-value","aria-hidden":"true"},o)))),ee);break}case _.TEXT:P=t.createElement(t.Fragment,null,t.createElement("input",{ref:y,className:"userflowjs-text-input userflowjs-bubble-question__text-input",value:c,onChange:o=>N(o.target.value),onKeyDown:o=>{!o.shiftKey&&o.key==="Enter"&&q({answer:{kind:"text",value:c}})},placeholder:n||m("question.placeholder"),readOnly:f||g,tabIndex:f?-1:void 0,"aria-required":r?"true":void 0,"aria-invalid":F!=null?"true":void 0}),we);break}return t.createElement("div",{className:"userflowjs-bubble-question",style:{pointerEvents:f?"none":void 0}},F&&!(e===_.MULTIPLE_CHOICE&&l)&&t.createElement("div",{className:"userflowjs-bubble-question__error",role:"alert"},F),P)};function H(){return new Promise(e=>window.setTimeout(e,250))}const Xe=({question:e})=>{const r=xe(),n=ze();return t.createElement(Qe,{type:e.type,required:!!e.required,placeholder:e.placeholder||"",buttonText:e.buttonText||"",options:e.options,otherOption:e.otherOption,multipleSelection:e.multipleSelection,shuffleOptions:e.shuffleOptions,labelLeft:e.labelLeft||"",labelCenter:e.labelCenter||"",labelRight:e.labelRight||"",minValue:e.minValue,maxValue:e.maxValue,onSubmit:async i=>{Me("answerQuestion",n.id,e.cvid,i);const{answer:s}=i;try{await Promise.all([await r.send({kind:"AnswerQuestion",sessionId:n.id,questionName:e.name,questionCvid:e.cvid,textAnswer:s.kind=="text"?s.value:null,numberAnswer:s.kind=="number"?String(s.value):null,listAnswer:s.kind=="list"?s.values:null}),i.animationPromise])}catch(l){console.log("Userflow.js: Error when answering question:",l),i.onError();return}const{bindAttributeFqn:a}=e;if(a&&r.flowSession?.id===n.id){let l;switch(s.kind){case"text":l={name:a,value:s.value};break;case"number":l={name:a,value:String(s.value)};break;case"list":l={name:a,value:s.values};break}r.optimisticClockUIUpdate(()=>{r.setFlowSession({...n,data:[...n.data.filter(u=>u.name!==a),l]})})}Ne(r,n,e.actions)}})},Ye=({text:e})=>{if(!e)return null;const r=e.split(/\n/);return r.length===1?t.createElement(t.Fragment,null,r[0]):t.createElement(t.Fragment,null,r.map((n,i)=>t.createElement(t.Fragment,{key:i},i>0&&t.createElement("br",null),n)))};function Ze(e=""){return{type:"rich2",children:[et(e)]}}function et(e=""){return{type:"paragraph",children:[{text:e}]}}function Se(e){if(e){let r;try{r=JSON.parse(e)}catch{throw new Error("Could not JSON.parse rich content doc: "+e)}if(r.type==="rich2")return r;throw new Error("Could not recognize rich content doc: "+e)}else return Ze()}function tt(e=""){return{type:"plaintext2",children:[{type:"plaintext",children:[{text:e}]}]}}function rt(e){if(e){let r;try{r=JSON.parse(e)}catch{throw new Error("Could not JSON.parse plaintext doc: "+e)}if(r.type==="plaintext2")return r;throw new Error("Could not recognize plaintext doc: "+e)}else return tt()}function W(e,{lookupAttribute:r}){if(!e)return"";typeof e=="string"&&(e=rt(e));const n=[];function i(a){if(ue(a)){a.text&&n.push(a.text);return}if(a.type==="attribute"){const l=qe(a,r);l&&n.push(l)}else s(a.children)}function s(a){a&&a.forEach(l=>l&&i(l))}return s(e.children),n.join("")}function Nt(e){let r=!0;if(!e)return!0;typeof e=="string"&&(e=Se(e));const n=new Set(["attribute","button","image","question","video"]);return Re(e,i=>{if(ue(i)){i.text!==""&&(r=!1);return}"type"in i&&n.has(i.type)&&(r=!1)}),r}const St=t.memo(({doc:e,...r})=>e?(typeof e=="string"&&(e=Se(e)),t.createElement(je,{parent:e,...r})):null),je=({parent:e,...r})=>t.createElement(t.Fragment,null,e.children.map((n,i)=>ue(n)?t.createElement(nt,{key:i,node:n}):t.createElement(st,{key:i,node:n,parent:e,...r}))),nt=({node:e})=>e.text?t.createElement(Ce,{node:e},t.createElement(Ye,{text:e.text})):null,Ce=({node:e,children:r})=>(e.color&&typeof e.color=="string"&&(r=t.createElement("span",{style:{color:e.color}},r)),e.bold&&(r=t.createElement("b",null,r)),e.italic&&(r=t.createElement("i",null,r)),e.underline&&(r=t.createElement("u",null,r)),e.strikeThrough&&(r=t.createElement("s",null,r)),e.code&&(r=t.createElement("code",null,r)),e.small&&(r=t.createElement("small",null,r)),e.sup&&(r=t.createElement("sup",null,r)),r),st=({node:e,parent:r,...n})=>{const{lookupAttribute:i}=n,s=t.createElement(je,{parent:e,...n});switch(e.type){case"attribute":return t.createElement(lt,{node:e,...n});case"button":return t.createElement(at,{node:e,...n});case"button-group":return t.createElement("div",{className:"userflowjs-bubble-buttons",style:{justifyContent:e.align}},s);case"column":return t.createElement("div",{style:dt(e,r)},s);case"column-group":return t.createElement("div",{className:"p-like",style:ft(e)},s);case"container":return t.createElement("div",{className:"p-like"+(e.className?` ${e.className}`:""),style:bt(e)},s);case"image":return t.createElement(ot,{node:e,...n});case"link":return t.createElement("a",{href:W(e.href,{lookupAttribute:i}),target:e.target==="same"?"_top":"_blank",rel:"noopener noreferrer"},s);case"paragraph":return t.createElement("p",{className:ae(e)},s);case"heading1":return t.createElement("h1",{className:ae(e)},s);case"heading2":return t.createElement("h2",{className:ae(e)},s);case"question":return t.createElement(it,{node:e,...n});case"quote":return t.createElement("blockquote",null,s);case"code-block":return t.createElement("pre",null,t.createElement("code",null,s));case"ordered-list":return t.createElement("ol",null,s);case"unordered-list":return t.createElement("ul",null,s);case"list-item":return t.createElement("li",null,s);case"video":return t.createElement(ut,{node:e,...n});default:return t.createElement("div",null,s)}},lt=({node:e,lookupAttribute:r})=>{let n=qe(e,r);return t.createElement(Ce,{node:e},n)},at=({node:e,buttons:r})=>{const n=r?.find(i=>i.cvid===e.cvid);return n?t.createElement(Ge,{key:n.id,button:n}):null},it=({node:e,questions:r})=>{const n=r?.find(i=>i.cvid===e.cvid);return n?t.createElement(Xe,{key:n.id,question:n}):null},ot=({node:e,lookupAttribute:r})=>{const{src:n,widthMode:i,displayWidth:s,width:a,height:l,marginTop:u,marginRight:p,marginBottom:d,marginLeft:h,align:w,hasLink:E,href:x}=e;if(!n)return null;const{wrapperStyle:f,blockStyle:m}=Ie({widthMode:i,displayWidth:s,width:a,height:l,marginTop:u,marginRight:p,marginBottom:d,marginLeft:h,align:w}),y=typeof n=="string"?n:W(n,{lookupAttribute:r});let c=t.createElement("img",{src:ke(y,N=>encodeURIComponent((r?r(N):"")||"")),style:{...m,objectFit:"contain"},alt:""});return E&&x&&(c=t.createElement("a",{href:W(x,{lookupAttribute:r}),target:e.target==="same"?"_top":"_blank",rel:"noopener noreferrer",style:m},c)),t.createElement("div",{className:"p-like"},t.createElement("div",{style:f},c))},ut=({node:e,lookupAttribute:r})=>{const{url:n,widthMode:i,displayWidth:s,width:a,height:l,marginTop:u,marginRight:p,marginBottom:d,marginLeft:h,align:w}=e;if(!n)return null;const{wrapperStyle:E,blockStyle:x}=Ie({widthMode:i,displayWidth:s,width:a,height:l,marginTop:u,marginRight:p,marginBottom:d,marginLeft:h,align:w});return t.createElement("div",{className:"p-like"},t.createElement("div",{style:E},t.createElement("div",{style:x},t.createElement(ct,{element:e,noFocus:!0,lookupAttribute:r}))))},ct=({element:{embedType:e,url:r,src:n,autoPlay:i,controls:s,loop:a,muted:l},noFocus:u,forceMuted:p,lookupAttribute:d})=>{if(!r)return null;const h=typeof r=="string"?r:W(r,{lookupAttribute:d}),w={width:"100%",height:"100%",allow:"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,allowtransparency:"true",mozallowfullscreen:"true",webkitallowfullscreen:"true",oallowfullscreen:"true",msallowfullscreen:"true",style:{display:"block",border:"none"},tabIndex:u?-1:void 0};if(e==="video")return t.createElement("video",{key:h+";"+String(i)+";"+String(s)+";"+String(a)+";"+String(l),src:h,style:{width:"100%",height:"100%",display:"block"},autoPlay:!!i,controls:s!==!1,loop:a,muted:p||l});let E=mt(h,{iframeFallback:!0});if(E.kind==="invalid")return null;if(n){let c;try{c=new URL(n)}catch{return null}p&&(c.searchParams.has("autoplay")||c.searchParams.has("autoPlay"))&&(c.searchParams.set("mute","1"),c.searchParams.set("muted","1"),c.searchParams.set("volume","0"));let N=c.toString();return le(c)&&(N=se(c.toString())),t.createElement("iframe",{src:N,...w})}const{videoProvider:x,videoId:f,searchParams:m}=E;i=i||m.has("autoplay")||m.has("autoPlay");let y;try{y=new URL(h)}catch{console.error("Invalid video URL:",h)}switch(x){case"iframe":return y&&le(y)?t.createElement("iframe",{src:se(h),...w}):t.createElement("iframe",{src:ke(f,c=>encodeURIComponent((d?d(c):"")||"")),scrolling:m.get("scrolling")||void 0,...w});case"loom":return t.createElement("iframe",{src:`https://www.loom.com/embed/${f}?${m.toString()}`,...w});case"raw":return t.createElement("video",{src:f,controls:!0,style:{width:"100%",height:"100%",display:"block"},autoPlay:m.has("autoplay"),muted:p||m.has("muted")});case"youtube":{p&&i&&m.set("mute","1");let c=`https://www.youtube.com/embed/${f}?${m.toString()}`;return y&&le(y)&&(c=se(c)),t.createElement("iframe",{src:c,...w})}case"vimeo":return p&&i&&m.set("muted","1"),t.createElement("iframe",{src:`https://player.vimeo.com/video/${f}?${m.toString()}`,...w});case"wistia":return m.set("videoFoam","true"),p&&i&&m.set("volume","0"),t.createElement(t.Fragment,null,t.createElement("iframe",{src:`https://fast.wistia.net/embed/iframe/${f}?${m.toString()}`,...w}))}};function se(e){return`https://cdn.userflow.com/iframe/youtube?src=${encodeURIComponent(e)}`}function le(e){return["youtube.com","www.youtube.com","youtu.be"].includes(e.hostname)}function mt(e,{iframeFallback:r}={}){let n;try{n=new URL(e)}catch{return{kind:"invalid"}}const{hostname:i,pathname:s,searchParams:a}=n;if(i.match(/^(www\.)?(use)?loom\.com$/)){const l=s.match(/^\/share\/([a-z0-9]+)$/i);if(l){const[,u]=l;return{kind:"ok",videoProvider:"loom",videoId:u,searchParams:a}}}if(e.startsWith("raw:"))return{kind:"ok",videoProvider:"raw",videoId:e.replace(/^raw:/,""),searchParams:a};if(e.startsWith("iframe:"))return{kind:"ok",videoProvider:"iframe",videoId:e.replace(/^iframe:/,""),searchParams:a};if(["youtube.com","www.youtube.com"].includes(i)){const l=a.get("v");if(l)return a.delete("v"),{kind:"ok",videoProvider:"youtube",videoId:l,searchParams:a}}if(i==="youtu.be"){const l=s.match(/^\/([^/]+)$/);if(l){const[,u]=l;return{kind:"ok",videoProvider:"youtube",videoId:u,searchParams:a}}}if(i==="vimeo.com"){const l=s.match(/^\/(\d+)$/);if(l){const[,u]=l;return{kind:"ok",videoProvider:"vimeo",videoId:u,searchParams:a}}}if(i==="player.vimeo.com"){const l=s.match(/^\/video\/([^/]+)$/);if(l){const[,u]=l;return{kind:"ok",videoProvider:"vimeo",videoId:u,searchParams:a}}}if(i.match(/^[^.]+\.wistia.com$/)){const l=s.match(/^\/medias\/([^/]+)$/);if(l){const[,u]=l;return{kind:"ok",videoProvider:"wistia",videoId:u,searchParams:a}}}return r?{kind:"ok",videoProvider:"iframe",videoId:e,searchParams:a}:{kind:"invalid"}}function ae(e){return e.align==="right"?"userflowjs-text-align-end":e.align==="center"?"userflowjs-text-align-center":e.align==="justify"?"userflowjs-text-align-justify":""}function Ie({widthMode:e,displayWidth:r,width:n,height:i,marginTop:s,marginRight:a,marginBottom:l,marginLeft:u,align:p}){const d={position:"relative"},h={position:"absolute",top:"0",left:"0",display:"block",width:"100%",height:"100%"};typeof r!="number"&&(r=100,e="percent"),p==="center"?(d.marginLeft="auto",d.marginRight="auto"):p==="right"&&(d.marginLeft="auto");let w=0;if(s!=null&&typeof s=="number"&&(d.marginTop=`${s}px`),a!=null&&typeof a=="number"&&(d.marginRight=`${a}px`,w+=a),l!=null&&typeof l=="number"&&(d.marginBottom=`${l}px`),u!=null&&typeof u=="number"&&(d.marginLeft=`${u}px`,w+=u),typeof r!="number"||typeof n!="number"||typeof i!="number")d.width="100px",d.height="100px";else if(e==="px"){const x=Math.max(10,r);d.width=`${x}px`,d.height=`${x/(n/i)}px`}else{const E=Math.max(0,Math.min(100,r));d.width=`calc(${E}% - ${w}px)`,d.height="0",d.paddingBottom=`calc((${E}% - ${w}px) / (${n} / ${i})`}return{wrapperStyle:d,blockStyle:h}}const Te=16;function ft(e){return{display:"flex",alignItems:"stretch",marginRight:`-${e.spacing==null?Te:e.spacing}px`}}function dt(e,r){const n=e.widthMode==="fill"||e.displayWidth==null;return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:n?void 0:e.widthMode==="px"?`${e.displayWidth||50}px`:e.widthMode==="percent"?`${e.displayWidth||50}%`:void 0,flex:n?"1 0 0":void 0,marginRight:`${r.spacing==null?Te:r.spacing}px`,marginBottom:"0"}}function bt(e){return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:e.widthMode==="px"&&e.displayWidth!=null?`${e.displayWidth}px`:e.widthMode==="percent"&&e.displayWidth!=null?`${e.displayWidth}%`:void 0,minHeight:e.heightMode==="px"?`${e.displayHeight||50}px`:void 0,flex:e.heightMode==="fill"?"1 0 0":void 0,marginTop:e.marginTop!=null?`${e.marginTop}px`:void 0,marginRight:e.marginRight!=null?`${e.marginRight}px`:e.widthMode!=="fill"&&e.align==="center"?"auto":void 0,marginBottom:e.marginBottom!=null?`${e.marginBottom}px`:void 0,marginLeft:e.marginLeft!=null?`${e.marginLeft}px`:e.widthMode!=="fill"&&(e.align==="center"||e.align==="right")?"auto":void 0}}function qe(e,r){if(!r)return null;const n=e.attributeName;if(typeof n=="string"){const i=r(n)||e.fallback;if(typeof i=="string")return i}return null}function Ae(e){return Array.isArray(e.children)&&typeof e.addMark>"u"}function Ee(e,r,n="type"){return Ae(e)&&typeof e=="object"&&e[n]===r}function ue(e){return typeof e.text=="string"}function Re(e,r){function n(s,a){r(s,a),Ae(s)&&i(s.children)}function i(s){s&&s.forEach((a,l)=>a&&n(a,l))}i(Array.isArray(e)?e:e.children)}const jt=t.memo(({doc:e,lookupAttribute:r})=>e?t.createElement(t.Fragment,null,W(e,{lookupAttribute:r})):null);function Ct(e,{buttons:r,questions:n}){const i=new Set,s=new Set;if(Re(e,a=>{Ee(a,"button")&&i.add(a.cvid),Ee(a,"question")&&s.add(a.cvid)}),n){const a=n.filter(l=>!s.has(l.cvid));a.length>0&&(e={...e,children:[...e.children,...a.map(l=>({type:"question",cvid:l.cvid,children:[{text:""}]}))]})}if(r){const a=r.filter(l=>!i.has(l.cvid));a.length>0&&(e={...e,children:[...e.children,{type:"button-group",children:a.map(l=>({type:"button",cvid:l.cvid,children:[{text:""}]}))}]})}return e}function wt(e){return e=e||"default","userflowjs-bubble-button "+(e==="primary"||e==="PRIMARY"||e==="default"||e==="DEFAULT"||e==="banner-primary"||e==="banner-secondary"?`userflowjs-bubble-button--${e.toLowerCase()}`:e)}export{Ge as B,St as R,We as S,jt as a,ve as b,Ke as c,Se as d,qe as g,Ne as h,ue as i,Ct as m,Je as n,Nt as r,W as s,oe as u};
10
+ But if this flow was running in published mode, the flow would now be snoozed for ${r.timeValue} ${r.timeUnit.toLowerCase()+(r.timeValue===1?"":"s")}.`):e.send({kind:"Snooze",flowId:n.flow.id,timeValue:r.timeValue,timeUnit:r.timeUnit},{batch:!0}));return;case I.START_FLOW:n.kind==="launcher"&&e.deactivateLauncher(n),r.otherFlow?await e.startFlow({flowId:r.otherFlow.id,stepCvid:r.otherFlowStepCvid,startReason:n.draftMode?ge.DRAFT:ge.ACTION,replaceCurrent:!0}):console.warn("Userflow.js: START_FLOW action is missing other flow");return;case I.TRACK_BUTTON_EVENT:{let s=null,l=n?n.id:null;if(n.kind==="flow"){const{currentStep:a}=n;s=a?a?.crossVersionId:null}if(r.buttonEvent){const{eventName:a,token:m}=r.buttonEvent;await e.trackButtonEvent(a,m,s,l)}return}}}async function Se(e,n,r){const i=[],s=[],l=[];for(const a of r)a.type===I.NAVIGATE?a.navigateTarget===xe.NEW_TAB?i.push(a):l.push(a):s.push(a);for(const a of i)le(e,n,a);await Promise.all(s.map(a=>le(e,n,a)));for(const a of l)le(e,n,a)}const Ge=({button:e})=>{const n=Ne(),r=me(),i=Ee(e.disabledCondition),s=Ee(e.hiddenCondition);return t.createElement(Ke,{appearance:e.appearance,hidden:s,disabled:i,onClick:()=>Se(n,r,e.actions),text:ke(e.text,r.data)})},He=()=>t.createElement("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},t.createElement("polygon",{className:"userflowjs-star-shape",fill:"#fff",points:"16 22.7785728 7.18322122 29.1352549 10.5042507 18.7856772 1.73415226 12.3647451 12.6034401 12.3250364 16 2 19.3965599 12.3250364 30.2658477 12.3647451 21.4957493 18.7856772 24.8167788 29.1352549"})),Qe=({type:e,required:n,placeholder:r,buttonText:i,options:s,otherOption:l,multipleSelection:a,shuffleOptions:m,labelLeft:b,labelCenter:y,labelRight:w,minValue:p,maxValue:E,onSubmit:k,inert:u})=>{const{t:d}=Be(),h=v.useRef(null),[c,_]=v.useState(""),[q,J]=v.useState(new Set),[T,U]=v.useState(),[G,fe]=v.useState(),[O,V]=v.useState(!1),[g,Z]=v.useState(!1),[L,A]=v.useState(null),P=v.useMemo(()=>s&&(m?[...s].sort(()=>Math.random()-.5):s),[s,m]),R=o=>{if(!(u||!k)){if(n&&c===""&&[N.MULTILINE_TEXT,N.TEXT].includes(e)){A(d("question.requiredError")),ee();return}Z(!0),A(null),k({...o,onCancel:()=>{Z(!1)},onError:j=>{Z(!1),A(j||"Sorry, something went wrong saving your answer. Please try again.")}})}},ee=v.useCallback(()=>{u||!h.current||h.current.focus()},[u]),[be,pe]=v.useState(!1);v.useEffect(()=>{be&&(ee(),pe(!1))},[ee,be]);const we=t.createElement("div",{className:"userflowjs-bubble-buttons"},t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>R({answer:{kind:"text",value:c}}),tabIndex:u?-1:void 0,disabled:g},t.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},i||d("question.submit"))));let S=null,H=0;if(e===N.NPS)b=b||d("question.npsLabelLeft"),w=w||d("question.npsLabelRight"),S=[0,1,2,3,4,5,6,7,8,9,10],H=S.length;else if([N.SCALE,N.STARS].includes(e)){p=p??1,E=E??5,S=[];for(let o=p;o<=E;o++)S.push(o);H=S.length}else e===N.MULTIPLE_CHOICE&&(H=(P?P.length:0)+(l&&!O?1:0));const[he,Fe]=v.useState(-1),$=he===-1?-1:Math.min(he,H-1),te=o=>{if(!o.target.closest('[role="radio"], [role="checkbox"], [role="radiogroup"], [role="group"]'))return;let x=null;if(o.key==="ArrowRight"||o.key==="ArrowDown"?x=1:(o.key==="ArrowLeft"||o.key==="ArrowUp")&&(x=-1),x!=null){o.preventDefault();const W=o.currentTarget.querySelectorAll('[role="radio"], [role="checkbox"]');let f=$+x;f<0?f=W.length-1:f>W.length-1&&(f=0),Fe(f),W[f].focus()}};let ne=null,re=null;if(S&&(b||y||w)){const o=[];b&&o.push(S[0],b),w&&o.push(S[S.length-1],w),ne=t.createElement("div",{id:"a11y-scale-labels",className:"userflowjs-a11y-only"},o.join(", ")),re=t.createElement("div",{id:"userflowjs-bubble-question-labels",className:"userflowjs-bubble-question__scale-labels","aria-hidden":"true"},t.createElement("div",{className:"userflowjs-bubble-question__scale-label"},b),y&&t.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--center"},y),t.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--right"},w))}let M;switch(e){case N.MULTILINE_TEXT:M=t.createElement(t.Fragment,null,t.createElement("textarea",{ref:h,className:"userflowjs-textarea userflowjs-bubble-question__textarea",value:c,onChange:o=>_(o.target.value),onKeyDown:o=>{(o.ctrlKey||o.metaKey)&&o.key==="Enter"&&R({answer:{kind:"text",value:c}})},placeholder:r||d("question.placeholder"),readOnly:u||g,tabIndex:u?-1:void 0,rows:3,"aria-required":n?"true":void 0,"aria-invalid":L!=null?"true":void 0}),we);break;case N.MULTIPLE_CHOICE:{const o=()=>{c&&R({answer:{kind:"text",value:c},animationPromise:Y()})},j=(P?.length||0)+(l?1:0),x=Math.max(0,Math.min(j,p??1)),B=Math.max(0,Math.min(j,E??j)),W=()=>{const f=(P||[]).filter((K,F)=>q.has(F)).map(K=>K.value);if(l&&O&&c!==""&&f.push(c),x===B&&f.length!==x){A(d("question.multiple_selection_wrong",{count:x}));return}else if(f.length<x){A(d("question.multiple_selection_too_few",{count:x}));return}else if(f.length>B){A(d("question.multiple_selection_too_many",{count:B}));return}R({answer:{kind:"list",values:f}})};M=t.createElement(t.Fragment,null,a&&t.createElement("div",{className:D({"userflowjs-bubble-question__multiple-choice-hint":!0,"userflowjs-bubble-question__multiple-choice-hint--error":!!L})},d("question.multiple_selection_hint",{replace:{selected:q.size+(l&&O&&c!==""?1:0),range:x===B?x:`${x}-${B}`}}),L&&t.createElement(t.Fragment,null,". ",t.createElement("span",{role:"alert"},L))),t.createElement("div",{className:D({"userflowjs-bubble-question__multiple-choice":!0,"userflowjs-bubble-question__multiple-choice--single-selection":!a,"userflowjs-bubble-question__multiple-choice--multiple-selection":!!a}),role:a?"group":"radiogroup",tabIndex:!u&&$===-1?0:-1,onKeyDown:te},P?.map(({value:f,label:K},F)=>t.createElement("button",{key:F,className:D({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--selected":a?q.has(F):g&&!O&&c==f}),onClick:g?void 0:()=>{if(a){A(null);const se=new Set(q);q.has(F)?se.delete(F):se.add(F),J(se)}else V(!1),_(f),R({answer:{kind:"text",value:f},animationPromise:Y()})},disabled:g,tabIndex:!u&&F===$?0:-1,role:a?"checkbox":"radio","aria-label":K||f,"aria-checked":!O&&c==f},a?t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},t.createElement(Q,{icon:X}))):t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},K||f))),l&&(O?t.createElement("div",{className:D({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--other":!0,"userflowjs-bubble-question__multiple-choice-option--selected":a?c!="":g})},a?t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox",onClick:()=>{_(""),V(!1)}},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},t.createElement(Q,{icon:X}))):t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),t.createElement("input",{ref:h,className:"userflowjs-bubble-question__multiple-choice-option-input",value:c,onChange:f=>_(f.target.value),onKeyDown:f=>{!f.shiftKey&&f.key==="Enter"?a?W():o():f.key==="Escape"&&(f.stopPropagation(),_(""),V(!1))},onBlur:()=>{c===""&&V(!1)},placeholder:r||d("question.placeholder"),readOnly:u||g,tabIndex:u?-1:void 0}),!a&&t.createElement("button",{"data-testid":"multiple-choice-other-submit",className:"userflowjs-bubble-question__multiple-choice-option-submit",onClick:()=>o(),disabled:g,"aria-label":d("question.submit")},t.createElement(Q,{icon:X}))):t.createElement("button",{className:"userflowjs-bubble-question__multiple-choice-option",onClick:g?void 0:()=>{A(null),V(!0),pe(!0)},disabled:g,tabIndex:!u&&P?.length===$?0:-1,role:"radio","aria-label":d("question.other"),"aria-checked":"false"},a?t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},t.createElement(Q,{icon:X}))):t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),t.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},d("question.other"))))),a&&t.createElement("div",{className:"userflowjs-bubble-buttons"},t.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:W,tabIndex:u?-1:void 0,disabled:g},t.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},i||d("question.submit")))));break}case N.NPS:case N.SCALE:{M=t.createElement(t.Fragment,null,ne,t.createElement("div",{className:"userflowjs-bubble-question__scale-options",role:"radiogroup",tabIndex:!u&&$===-1?0:-1,onKeyDown:te},S?.map((o,j)=>t.createElement("button",{className:D({"userflowjs-bubble-question__scale-option":!0,"userflowjs-bubble-question__scale-option--selected":g&&T==o}),key:o,tabIndex:!u&&j===$?0:-1,onClick:()=>{U(o),R({answer:{kind:"number",value:o},animationPromise:Y()})},disabled:g,role:"radio","aria-checked":T==o},o))),re);break}case N.STARS:{M=t.createElement("div",{className:"userflowjs-bubble-question__stars-wrapper"},ne,t.createElement("div",{className:"userflowjs-bubble-question__stars",role:"radiogroup",tabIndex:!u&&$===-1?0:-1,onKeyDown:te},S?.map((o,j)=>t.createElement("button",{className:D({"userflowjs-bubble-question__star":!0,"userflowjs-bubble-question__star--hovered":!g&&G!=null&&G>=o,"userflowjs-bubble-question__star--selected":g&&T!=null&&T>=o,"userflowjs-bubble-question__star--not-selected":g&&T!=null&&T<o}),key:o,tabIndex:!u&&j===$?0:-1,onClick:()=>{U(o),R({answer:{kind:"number",value:o},animationPromise:Y()})},onMouseOver:()=>fe(o),onMouseLeave:()=>fe(null),disabled:g,role:"radio","aria-checked":T==o,"aria-label":String(o)},t.createElement("div",{className:"userflowjs-bubble-question__star-icon","aria-hidden":"true"},t.createElement(He,null)),t.createElement("div",{className:"userflowjs-bubble-question__star-value","aria-hidden":"true"},o)))),re);break}case N.TEXT:M=t.createElement(t.Fragment,null,t.createElement("input",{ref:h,className:"userflowjs-text-input userflowjs-bubble-question__text-input",value:c,onChange:o=>_(o.target.value),onKeyDown:o=>{!o.shiftKey&&o.key==="Enter"&&R({answer:{kind:"text",value:c}})},placeholder:r||d("question.placeholder"),readOnly:u||g,tabIndex:u?-1:void 0,"aria-required":n?"true":void 0,"aria-invalid":L!=null?"true":void 0}),we);break}return t.createElement("div",{className:"userflowjs-bubble-question",style:{pointerEvents:u?"none":void 0}},L&&!(e===N.MULTIPLE_CHOICE&&a)&&t.createElement("div",{className:"userflowjs-bubble-question__error",role:"alert"},L),M)};function Y(){return new Promise(e=>window.setTimeout(e,250))}const Xe=({question:e})=>{const n=Ne(),r=ze();return t.createElement(Qe,{type:e.type,required:!!e.required,placeholder:e.placeholder||"",buttonText:e.buttonText||"",options:e.options,otherOption:e.otherOption,multipleSelection:e.multipleSelection,shuffleOptions:e.shuffleOptions,labelLeft:e.labelLeft||"",labelCenter:e.labelCenter||"",labelRight:e.labelRight||"",minValue:e.minValue,maxValue:e.maxValue,onSubmit:async i=>{Me("answerQuestion",r.id,e.cvid,i);const{answer:s}=i;try{await Promise.all([await n.send({kind:"AnswerQuestion",sessionId:r.id,questionName:e.name,questionCvid:e.cvid,textAnswer:s.kind=="text"?s.value:null,numberAnswer:s.kind=="number"?String(s.value):null,listAnswer:s.kind=="list"?s.values:null}),i.animationPromise])}catch(a){console.log("Userflow.js: Error when answering question:",a),i.onError();return}const{bindAttributeFqn:l}=e;if(l&&n.flowSession?.id===r.id){let a;switch(s.kind){case"text":a={name:l,value:s.value};break;case"number":a={name:l,value:String(s.value)};break;case"list":a={name:l,value:s.values};break}n.optimisticClockUIUpdate(()=>{n.setFlowSession({...r,data:[...r.data.filter(m=>m.name!==l),a]})})}Se(n,r,e.actions)}})},Ye=({text:e})=>{if(!e)return null;const n=e.split(/\n/);return n.length===1?t.createElement(t.Fragment,null,n[0]):t.createElement(t.Fragment,null,n.map((r,i)=>t.createElement(t.Fragment,{key:i},i>0&&t.createElement("br",null),r)))};function Ze(e=""){return{type:"rich2",children:[et(e)]}}function et(e=""){return{type:"paragraph",children:[{text:e}]}}function je(e){if(e){let n;try{n=JSON.parse(e)}catch{throw new Error("Could not JSON.parse rich content doc: "+e)}if(n.type==="rich2")return n;throw new Error("Could not recognize rich content doc: "+e)}else return Ze()}function tt(e=""){return{type:"plaintext2",children:[{type:"plaintext",children:[{text:e}]}]}}function nt(e){if(e){let n;try{n=JSON.parse(e)}catch{throw new Error("Could not JSON.parse plaintext doc: "+e)}if(n.type==="plaintext2")return n;throw new Error("Could not recognize plaintext doc: "+e)}else return tt()}function z(e,{lookupAttribute:n}){if(!e)return"";typeof e=="string"&&(e=nt(e));const r=[];function i(l){if(de(l)){l.text&&r.push(l.text);return}if(l.type==="attribute"){const a=Ae(l,n);a&&r.push(a)}else s(l.children)}function s(l){l&&l.forEach(a=>a&&i(a))}return s(e.children),r.join("")}function Nt(e){let n=!0;if(!e)return!0;typeof e=="string"&&(e=je(e));const r=new Set(["attribute","button","image","question","video"]);return $e(e,i=>{if(de(i)){i.text!==""&&(n=!1);return}"type"in i&&r.has(i.type)&&(n=!1)}),n}const St=t.memo(({doc:e,...n})=>e?(typeof e=="string"&&(e=je(e)),t.createElement(Ce,{parent:e,...n})):null),Ce=({parent:e,...n})=>t.createElement(t.Fragment,null,e.children.map((r,i)=>de(r)?t.createElement(rt,{key:i,node:r}):t.createElement(st,{key:i,node:r,parent:e,...n}))),rt=({node:e})=>e.text?t.createElement(Te,{node:e},t.createElement(Ye,{text:e.text})):null,Te=({node:e,children:n})=>(e.color&&typeof e.color=="string"&&(n=t.createElement("span",{style:{color:e.color}},n)),e.bold&&(n=t.createElement("b",null,n)),e.italic&&(n=t.createElement("i",null,n)),e.underline&&(n=t.createElement("u",null,n)),e.strikeThrough&&(n=t.createElement("s",null,n)),e.code&&(n=t.createElement("code",null,n)),e.small&&(n=t.createElement("small",null,n)),e.sup&&(n=t.createElement("sup",null,n)),n),st=({node:e,parent:n,...r})=>{const{lookupAttribute:i}=r,s=t.createElement(Ce,{parent:e,...r});switch(e.type){case"attribute":return t.createElement(at,{node:e,...r});case"button":return t.createElement(lt,{node:e,...r});case"button-group":return t.createElement("div",{className:"userflowjs-bubble-buttons",style:{justifyContent:e.align}},s);case"column":return t.createElement("div",{style:ft(e,n)},s);case"column-group":return t.createElement("div",{className:"p-like",style:dt(e)},s);case"container":return t.createElement("div",{className:"p-like"+(e.className?` ${e.className}`:""),style:bt(e)},s);case"image":return t.createElement(ot,{node:e,...r});case"link":return t.createElement("a",{href:z(e.href,{lookupAttribute:i}),target:e.target==="same"?"_top":"_blank",rel:"noopener noreferrer"},s);case"paragraph":return t.createElement("p",{className:ue(e)},s);case"heading1":return t.createElement("h1",{className:ue(e)},s);case"heading2":return t.createElement("h2",{className:ue(e)},s);case"question":return t.createElement(it,{node:e,...r});case"quote":return t.createElement("blockquote",null,s);case"code-block":return t.createElement("pre",null,t.createElement("code",null,s));case"ordered-list":return t.createElement("ol",null,s);case"unordered-list":return t.createElement("ul",null,s);case"list-item":return t.createElement("li",null,s);case"video":return t.createElement(ut,{node:e,...r});default:return t.createElement("div",null,s)}},at=({node:e,lookupAttribute:n})=>{let r=Ae(e,n);return t.createElement(Te,{node:e},r)},lt=({node:e,buttons:n})=>{const r=n?.find(i=>i.cvid===e.cvid);return r?t.createElement(Ge,{key:r.id,button:r}):null},it=({node:e,questions:n})=>{const r=n?.find(i=>i.cvid===e.cvid);return r?t.createElement(Xe,{key:r.id,question:r}):null},ot=({node:e,lookupAttribute:n})=>{const{src:r,widthMode:i,displayWidth:s,width:l,height:a,marginTop:m,marginRight:b,marginBottom:y,marginLeft:w,paddingTop:p,paddingRight:E,paddingBottom:k,paddingLeft:u,align:d,hasLink:h,href:c}=e;if(!r)return null;const{paddingStyle:_,wrapperStyle:q,blockStyle:J}=Ie({widthMode:i,displayWidth:s,width:l,height:a,marginTop:m,marginRight:b,marginBottom:y,marginLeft:w,paddingTop:p,paddingRight:E,paddingBottom:k,paddingLeft:u,align:d}),T=typeof r=="string"?r:z(r,{lookupAttribute:n});let U=t.createElement("img",{src:_e(T,G=>encodeURIComponent((n?n(G):"")||"")),style:{...J,objectFit:"contain"},alt:""});return h&&c&&(U=t.createElement("a",{href:z(c,{lookupAttribute:n}),target:e.target==="same"?"_top":"_blank",rel:"noopener noreferrer",style:J},U)),t.createElement("div",{className:"p-like",style:_},t.createElement("div",{style:q},U))},ut=({node:e,lookupAttribute:n})=>{const{url:r,widthMode:i,displayWidth:s,width:l,height:a,marginTop:m,marginRight:b,marginBottom:y,marginLeft:w,align:p}=e;if(!r)return null;const{wrapperStyle:E,blockStyle:k}=Ie({widthMode:i,displayWidth:s,width:l,height:a,marginTop:m,marginRight:b,marginBottom:y,marginLeft:w,align:p});return t.createElement("div",{className:"p-like"},t.createElement("div",{style:E},t.createElement("div",{style:k},t.createElement(ct,{element:e,noFocus:!0,lookupAttribute:n}))))},ct=({element:{embedType:e,url:n,src:r,autoPlay:i,controls:s,loop:l,muted:a},noFocus:m,forceMuted:b,lookupAttribute:y})=>{if(!n)return null;const w=typeof n=="string"?n:z(n,{lookupAttribute:y}),p={width:"100%",height:"100%",allow:"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,allowtransparency:"true",mozallowfullscreen:"true",webkitallowfullscreen:"true",oallowfullscreen:"true",msallowfullscreen:"true",style:{display:"block",border:"none"},tabIndex:m?-1:void 0};if(e==="video")return t.createElement("video",{key:w+";"+String(i)+";"+String(s)+";"+String(l)+";"+String(a),src:w,style:{width:"100%",height:"100%",display:"block"},autoPlay:!!i,controls:s!==!1,loop:l,muted:b||a});let E=mt(w,{iframeFallback:!0});if(E.kind==="invalid")return null;if(r){let c;try{c=new URL(r)}catch{return null}b&&(c.searchParams.has("autoplay")||c.searchParams.has("autoPlay"))&&(c.searchParams.set("mute","1"),c.searchParams.set("muted","1"),c.searchParams.set("volume","0"));let _=c.toString();return oe(c)&&(_=ie(c.toString())),t.createElement("iframe",{src:_,...p})}const{videoProvider:k,videoId:u,searchParams:d}=E;i=i||d.has("autoplay")||d.has("autoPlay");let h;try{h=new URL(w)}catch{console.error("Invalid video URL:",w)}switch(k){case"iframe":return h&&oe(h)?t.createElement("iframe",{src:ie(w),...p}):t.createElement("iframe",{src:_e(u,c=>encodeURIComponent((y?y(c):"")||"")),scrolling:d.get("scrolling")||void 0,...p});case"loom":return t.createElement("iframe",{src:`https://www.loom.com/embed/${u}?${d.toString()}`,...p});case"raw":return t.createElement("video",{src:u,controls:!0,style:{width:"100%",height:"100%",display:"block"},autoPlay:d.has("autoplay"),muted:b||d.has("muted")});case"youtube":{b&&i&&d.set("mute","1");let c=`https://www.youtube.com/embed/${u}?${d.toString()}`;return h&&oe(h)&&(c=ie(c)),t.createElement("iframe",{src:c,...p})}case"vimeo":return b&&i&&d.set("muted","1"),t.createElement("iframe",{src:`https://player.vimeo.com/video/${u}?${d.toString()}`,...p});case"wistia":return d.set("videoFoam","true"),b&&i&&d.set("volume","0"),t.createElement(t.Fragment,null,t.createElement("iframe",{src:`https://fast.wistia.net/embed/iframe/${u}?${d.toString()}`,...p}))}};function ie(e){return`https://cdn.userflow.com/iframe/youtube?src=${encodeURIComponent(e)}`}function oe(e){return["youtube.com","www.youtube.com","youtu.be"].includes(e.hostname)}function mt(e,{iframeFallback:n}={}){let r;try{r=new URL(e)}catch{return{kind:"invalid"}}const{hostname:i,pathname:s,searchParams:l}=r;if(i.match(/^(www\.)?(use)?loom\.com$/)){const a=s.match(/^\/share\/([a-z0-9]+)$/i);if(a){const[,m]=a;return{kind:"ok",videoProvider:"loom",videoId:m,searchParams:l}}}if(e.startsWith("raw:"))return{kind:"ok",videoProvider:"raw",videoId:e.replace(/^raw:/,""),searchParams:l};if(e.startsWith("iframe:"))return{kind:"ok",videoProvider:"iframe",videoId:e.replace(/^iframe:/,""),searchParams:l};if(["youtube.com","www.youtube.com"].includes(i)){const a=l.get("v");if(a)return l.delete("v"),{kind:"ok",videoProvider:"youtube",videoId:a,searchParams:l}}if(i==="youtu.be"){const a=s.match(/^\/([^/]+)$/);if(a){const[,m]=a;return{kind:"ok",videoProvider:"youtube",videoId:m,searchParams:l}}}if(i==="vimeo.com"){const a=s.match(/^\/(\d+)$/);if(a){const[,m]=a;return{kind:"ok",videoProvider:"vimeo",videoId:m,searchParams:l}}}if(i==="player.vimeo.com"){const a=s.match(/^\/video\/([^/]+)$/);if(a){const[,m]=a;return{kind:"ok",videoProvider:"vimeo",videoId:m,searchParams:l}}}if(i.match(/^[^.]+\.wistia.com$/)){const a=s.match(/^\/medias\/([^/]+)$/);if(a){const[,m]=a;return{kind:"ok",videoProvider:"wistia",videoId:m,searchParams:l}}}return n?{kind:"ok",videoProvider:"iframe",videoId:e,searchParams:l}:{kind:"invalid"}}function ue(e){return e.align==="right"?"userflowjs-text-align-end":e.align==="center"?"userflowjs-text-align-center":e.align==="justify"?"userflowjs-text-align-justify":""}function Ie({widthMode:e,displayWidth:n,width:r,height:i,marginTop:s,marginRight:l,marginBottom:a,marginLeft:m,paddingTop:b,paddingRight:y,paddingBottom:w,paddingLeft:p,align:E}){const k={},u={position:"relative"},d={position:"absolute",top:"0",left:"0",display:"block",width:"100%",height:"100%"};typeof n!="number"&&(n=100,e="percent"),E==="center"?(u.marginLeft="auto",u.marginRight="auto"):E==="right"&&(u.marginLeft="auto"),Number.isFinite(b)&&(k.paddingTop=`${b}px`),Number.isFinite(y)&&(k.paddingRight=`${y}px`),Number.isFinite(w)&&(k.paddingBottom=`${w}px`),Number.isFinite(p)&&(k.paddingLeft=`${p}px`);let h=0;if(s!=null&&typeof s=="number"&&(u.marginTop=`${s}px`),l!=null&&typeof l=="number"&&(u.marginRight=`${l}px`,h+=l),a!=null&&typeof a=="number"&&(u.marginBottom=`${a}px`),m!=null&&typeof m=="number"&&(u.marginLeft=`${m}px`,h+=m),typeof n!="number"||typeof r!="number"||typeof i!="number")u.width="100px",u.height="100px";else if(e==="px"){const _=Math.max(10,n);u.width=`${_}px`,u.height=`${_/(r/i)}px`}else{const c=Math.max(0,Math.min(100,n));u.width=`calc(${c}% - ${h}px)`,u.height="0",u.paddingBottom=`calc((${c}% - ${h}px) / (${r} / ${i})`}return{paddingStyle:k,wrapperStyle:u,blockStyle:d}}const qe=16;function dt(e){return{display:"flex",alignItems:"stretch",marginRight:`-${e.spacing==null?qe:e.spacing}px`}}function ft(e,n){const r=e.widthMode==="fill"||e.displayWidth==null;return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:r?void 0:e.widthMode==="px"?`${e.displayWidth||50}px`:e.widthMode==="percent"?`${e.displayWidth||50}%`:void 0,flex:r?"1 0 0":void 0,marginRight:`${n.spacing==null?qe:n.spacing}px`,marginBottom:"0"}}function bt(e){return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:e.widthMode==="px"&&e.displayWidth!=null?`${e.displayWidth}px`:e.widthMode==="percent"&&e.displayWidth!=null?`${e.displayWidth}%`:void 0,minHeight:e.heightMode==="px"?`${e.displayHeight||50}px`:void 0,flex:e.heightMode==="fill"?"1 0 0":void 0,marginTop:e.marginTop!=null?`${e.marginTop}px`:void 0,marginRight:e.marginRight!=null?`${e.marginRight}px`:e.widthMode!=="fill"&&e.align==="center"?"auto":void 0,marginBottom:e.marginBottom!=null?`${e.marginBottom}px`:void 0,marginLeft:e.marginLeft!=null?`${e.marginLeft}px`:e.widthMode!=="fill"&&(e.align==="center"||e.align==="right")?"auto":void 0,paddingTop:e.paddingTop!=null?`${e.paddingTop}px`:void 0,paddingRight:e.paddingRight!=null?`${e.paddingRight}px`:void 0,paddingBottom:e.paddingBottom!=null?`${e.paddingBottom}px`:void 0,paddingLeft:e.paddingLeft!=null?`${e.paddingLeft}px`:void 0}}function Ae(e,n){if(!n)return null;const r=e.attributeName;if(typeof r=="string"){const i=n(r)||e.fallback;if(typeof i=="string")return i}return null}function Re(e){return Array.isArray(e.children)&&typeof e.addMark>"u"}function ye(e,n,r="type"){return Re(e)&&typeof e=="object"&&e[r]===n}function de(e){return typeof e.text=="string"}function $e(e,n){function r(s,l){n(s,l),Re(s)&&i(s.children)}function i(s){s&&s.forEach((l,a)=>l&&r(l,a))}i(Array.isArray(e)?e:e.children)}const jt=t.memo(({doc:e,lookupAttribute:n})=>e?t.createElement(t.Fragment,null,z(e,{lookupAttribute:n})):null);function Ct(e,{buttons:n,questions:r}){const i=new Set,s=new Set;if($e(e,l=>{ye(l,"button")&&i.add(l.cvid),ye(l,"question")&&s.add(l.cvid)}),r){const l=r.filter(a=>!s.has(a.cvid));l.length>0&&(e={...e,children:[...e.children,...l.map(a=>({type:"question",cvid:a.cvid,children:[{text:""}]}))]})}if(n){const l=n.filter(a=>!i.has(a.cvid));l.length>0&&(e={...e,children:[...e.children,{type:"button-group",children:l.map(a=>({type:"button",cvid:a.cvid,children:[{text:""}]}))}]})}return e}function pt(e){return e=e||"default","userflowjs-bubble-button "+(e==="primary"||e==="PRIMARY"||e==="default"||e==="DEFAULT"||e==="banner-primary"||e==="banner-secondary"?`userflowjs-bubble-button--${e.toLowerCase()}`:e)}export{Ge as B,St as R,We as S,jt as a,Ee as b,Ke as c,je as d,Ae as g,Se as h,de as i,Ct as m,Je as n,Nt as r,z as s,me as u};
11
11
  //# sourceMappingURL=TreeDoc.js.map
package/hash.txt CHANGED
@@ -1 +1 @@
1
- 90d29dae9639c6268333e5ce1e33e08722922b01
1
+ 62b94c56da6f1c7e90a1463a8a246319d016dac1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1025218",
3
+ "version": "0.1.1025288",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
package/userflow.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ResourceCenterApp.js","vendor.react.js","vendor.object-assign.js","client-context.js","vendor.i18next.js","vendor.babel.runtime.js","vendor.react-i18next.js","flow-host.styl.js","TreeDoc.js","flow-condition-types.js","vendor.date-fns.js","roots.js","stylesheets.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.fortawesome.pro-solid-svg-icons.js","vendor.obj-str.js","use-selector-element-monitoring.js","Frame.js","vendor.react-dom.js","vendor.scheduler.js","iframe-reset.styl.js","use-window-resize.js","logomark.js","ChecklistUI.js","FlowChrome.js","use-confetti.js","vendor.canvas-confetti.js","AnnouncementEngagement.js","vendor.memoize-one.js","vendor.bignumber.js.js","use-element-rect.js","resource-center-route.js","BannerApp.js","vendor.phoenix.js","vendor.uuid.js","SitePage.js","vendor.react-router-dom.js","vendor.react-router.js","vendor.prop-types.js","vendor.history.js","vendor.resolve-pathname.js","vendor.value-equal.js","vendor.tiny-invariant.js","vendor.mini-create-react-context.js","vendor.path-to-regexp.js","vendor.react-is.js","Popover.js","react-hooks.js","vendor.lodash.js","implicit-tracking.js","DebuggerUI.js","ui.js"])))=>i.map(i=>d[i]);
2
2
  import"./vendor.object-assign.js";import{S as J}from"./vendor.phoenix.js";import{v as b}from"./vendor.uuid.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="36fa7c4f-8d7f-48bc-8bfa-a0f5d0770ceb",e._sentryDebugIdIdentifier="sentry-dbid-36fa7c4f-8d7f-48bc-8bfa-a0f5d0770ceb")}catch{}})();const Q="modulepreload",X=function(e){return new URL("./",import.meta.url).toString()+e},D={},I=function(t,s,n){let i=Promise.resolve();if(s&&s.length>0){let u=function(c){return Promise.all(c.map(E=>Promise.resolve(E).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");i=u(s.map(c=>{if(c=X(c),c in D)return;D[c]=!0;const E=c.endsWith(".css"),g=E?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${g}`))return;const T=document.createElement("link");if(T.rel=E?"stylesheet":Q,E||(T.as="script"),T.crossOrigin="",T.href=c,l&&T.setAttribute("nonce",l),document.head.appendChild(T),E)return new Promise((Y,z)=>{T.addEventListener("load",Y),T.addEventListener("error",()=>z(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&r(l.reason);return t().catch(r)})};class h extends Error{constructor(t,s,n){super(t),Object.setPrototypeOf(this,h.prototype),this.name="UserflowError",this.code=s,this.humanMessage=n}}class G{constructor(t){this.type=t,this.testState={}}formatKey(t){return`userflow:${t}`}isSupported(){if(typeof window>"u")return!1;try{return window[this.type]!=null}catch{return!1}}getItem(t){return t=this.formatKey(t),this.isSupported()?window[this.type].getItem(t):null}setItem(t,s){t=this.formatKey(t);{if(!this.isSupported())return;window[this.type].setItem(t,s)}}removeItem(t){return t=this.formatKey(t),this.isSupported()?window[this.type].removeItem(t):void 0}clear(){return this.isSupported()?window[this.type].clear():void 0}}const C=new G("localStorage"),d=new G("sessionStorage");function ft(e){window.location.href=e}function m(){return window.location.href}function A(e){window.postMessage(e,window.origin)}function x(e){const t=n=>{if(n.source!==window||n.origin!==window.origin)return;const i=n.data;!i||typeof i!="object"||typeof i.kind!="string"||!i.kind.startsWith("userflow:")||e(i)===!0&&s()};window.addEventListener("message",t);const s=()=>window.removeEventListener("message",t);return s}function Z(e){return new Promise(t=>{x(s=>{const n=e(s);return n?(t(n),!0):!1})})}const v=new Set;let y=!1;function q(e){return ee(),v.add(e),()=>{F(e)}}function F(e){v.delete(e)}function k(){v.forEach(e=>e())}function ee(){if(y)return;y=!0;const{history:e}=window,t=s=>{const n=e[s];e[s]=(...i)=>{const r=n.apply(e,i);return k(),r}};window.__userflowStatePatched?(window.addEventListener("userflow:pushstate",()=>{k()}),window.addEventListener("userflow:replacestate",()=>{k()})):(t("pushState"),t("replaceState")),window.addEventListener("popstate",()=>{k()})}class te{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(t){A({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:t})}onBuilderMessage(t){return this.unregisterOnMessage=x(t),!1}async captureScreenshot(t,s,n,i){return A({kind:"userflow:crxScreenshot",x:t,y:s,width:n,height:i,devicePixelRatio:window.devicePixelRatio}),(await Z(a=>a.kind==="userflow:crxScreenshotResult"?a:null)).imageDataUrl}}var U=(e=>(e.ACTION="ACTION",e.ELEMENT_MISSING="ELEMENT_MISSING",e.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",e.WORKFLOW_TIMED_OUT="WORKFLOW_TIMED_OUT",e.REPLACED="REPLACED",e.SNOOZED="SNOOZED",e.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",e.USERFLOWJS="USERFLOWJS",e.USER_CLOSED="USER_CLOSED",e))(U||{}),se=(e=>(e.POSITIVE="POSITIVE",e.NEUTRAL="NEUTRAL",e.NEGATIVE="NEGATIVE",e))(se||{}),ie=(e=>(e.USER_INPUT_TIMEOUT="USER_INPUT_TIMEOUT",e.STEP_TIMEOUT="STEP_TIMEOUT",e))(ie||{}),ne=(e=>(e.SECOND="SECOND",e.MINUTE="MINUTE",e.HOUR="HOUR",e.DAY="DAY",e))(ne||{}),p=(e=>(e.ACTION="ACTION",e.DRAFT="DRAFT",e.LINK="LINK",e.LAUNCHER_SEEN="LAUNCHER_SEEN",e.RESOURCE_CENTER="RESOURCE_CENTER",e.USERFLOWJS="USERFLOWJS",e.ASSISTANT="ASSISTANT",e))(p||{}),re=(e=>(e.LIKE="LIKE",e.DISLIKE="DISLIKE",e))(re||{}),S=(e=>(e.STRING="STRING",e.BOOLEAN="BOOLEAN",e.NUMBER="NUMBER",e.DATETIME="DATETIME",e.LIST="LIST",e.RANDOM_AB="RANDOM_AB",e.RANDOM_NUMBER="RANDOM_NUMBER",e.CHECKLIST_TASK="CHECKLIST_TASK",e.FLOW="FLOW",e.FLOW_SESSION="FLOW_SESSION",e.FLOW_STEP="FLOW_STEP",e.FLOW_VERSION="FLOW_VERSION",e))(S||{}),L=(e=>(e.FLOW="FLOW",e.BANNER="BANNER",e.EMBED="EMBED",e.CHECKLIST="CHECKLIST",e.LAUNCHER="LAUNCHER",e.RESOURCE_CENTER="RESOURCE_CENTER",e.SITE="SITE",e.WORKFLOW="WORKFLOW",e))(L||{}),oe=(e=>(e.ALWAYS_TRUE="ALWAYS_TRUE",e.ATTRIBUTE="ATTRIBUTE",e.CHECKLIST_TASK_CLICKED="CHECKLIST_TASK_CLICKED",e.CLAUSE="CLAUSE",e.ELEMENT="ELEMENT",e.EVENT="EVENT",e.FILLED_IN_INPUT="FILLED_IN_INPUT",e.FLOW="FLOW",e.INPUT_VALUE="INPUT_VALUE",e.PAGE="PAGE",e.SEGMENT="SEGMENT",e.TIME="TIME",e))(oe||{}),ae=(e=>(e.AUTO="AUTO",e.MANUAL="MANUAL",e))(ae||{}),ce=(e=>(e.INPUT="INPUT",e))(ce||{}),le=(e=>(e.ABSOLUTE_EQ="ABSOLUTE_EQ",e.ABSOLUTE_GT="ABSOLUTE_GT",e.ABSOLUTE_LT="ABSOLUTE_LT",e.AND="AND",e.BETWEEN="BETWEEN",e.CONTAINS="CONTAINS",e.EMPTY="EMPTY",e.ENDS_WITH="ENDS_WITH",e.EQ="EQ",e.EXCLUDES_ALL="EXCLUDES_ALL",e.EXCLUDES_ANY="EXCLUDES_ANY",e.FALSE="FALSE",e.GT="GT",e.GTE="GTE",e.INCLUDES_ALL="INCLUDES_ALL",e.INCLUDES_ANY="INCLUDES_ANY",e.LT="LT",e.LTE="LTE",e.NE="NE",e.NOT_CONTAINS="NOT_CONTAINS",e.NOT_EMPTY="NOT_EMPTY",e.NOT_REGEX="NOT_REGEX",e.OR="OR",e.REGEX="REGEX",e.RELATIVE_EQ="RELATIVE_EQ",e.RELATIVE_GT="RELATIVE_GT",e.RELATIVE_LT="RELATIVE_LT",e.STARTS_WITH="STARTS_WITH",e.TRUE="TRUE",e.URL="URL",e))(le||{}),ue=(e=>(e.CLICK="CLICK",e.DISABLED="DISABLED",e.MOUSEDOWN="MOUSEDOWN",e.NOT_CLICK="NOT_CLICK",e.NOT_DISABLED="NOT_DISABLED",e.NOT_PRESENT="NOT_PRESENT",e.PRESENT="PRESENT",e))(ue||{}),he=(e=>(e.END_USER="END_USER",e.GROUP="GROUP",e))(he||{}),de=(e=>(e.BETWEEN="BETWEEN",e.EQ="EQ",e.GTE="GTE",e.LTE="LTE",e))(de||{}),fe=(e=>(e.ANY="ANY",e.RELATIVE_BETWEEN="RELATIVE_BETWEEN",e.RELATIVE_GT="RELATIVE_GT",e.RELATIVE_LT="RELATIVE_LT",e))(fe||{}),Ee=(e=>(e.CURRENT_USER="CURRENT_USER",e.CURRENT_USER_CURRENT_GROUP="CURRENT_USER_CURRENT_GROUP",e.CURRENT_GROUP="CURRENT_GROUP",e))(Ee||{}),Se=(e=>(e.ASSET="ASSET",e.CARTOON="CARTOON",e.NONE="NONE",e.URL="URL",e))(Se||{}),Te=(e=>(e.INSIDE="INSIDE",e.OUTSIDE="OUTSIDE",e))(Te||{}),Ie=(e=>(e.TOP_LEFT="TOP_LEFT",e.TOP_CENTER="TOP_CENTER",e.TOP_RIGHT="TOP_RIGHT",e.BOTTOM_RIGHT="BOTTOM_RIGHT",e.BOTTOM_CENTER="BOTTOM_CENTER",e.BOTTOM_LEFT="BOTTOM_LEFT",e.CENTER="CENTER",e))(Ie||{}),ge=(e=>(e.GOOGLE="GOOGLE",e.STANDARD="STANDARD",e))(ge||{}),we=(e=>(e.DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",e.DISMISS="DISMISS",e))(we||{}),Ce=(e=>(e.DISMISS="DISMISS",e.NONE="NONE",e))(Ce||{}),ke=(e=>(e.DEFAULT="DEFAULT",e.NARROW="NARROW",e.CHAINED_SQUARED="CHAINED_SQUARED",e.CHAINED_ROUNDED="CHAINED_ROUNDED",e.DOTTED="DOTTED",e.NUMBERED="NUMBERED",e))(ke||{}),me=(e=>(e.TOP="TOP",e.BOTTOM="BOTTOM",e))(me||{}),Ue=(e=>(e.DEFAULT="DEFAULT",e.PLAINTEXT="PLAINTEXT",e.CUSTOM="CUSTOM",e))(Ue||{}),Le=(e=>(e.CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",e.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",e.NONE="NONE",e))(Le||{}),pe=(e=>(e.BUBBLE="BUBBLE",e.END="END",e.ERROR="ERROR",e.FLAG="FLAG",e))(pe||{}),_e=(e=>(e.MANUAL="MANUAL",e.NONE="NONE",e.SYNTHETIC="SYNTHETIC",e))(_e||{}),Ne=(e=>(e.BUBBLE="BUBBLE",e.HIDDEN="HIDDEN",e.MODAL="MODAL",e.TOOLTIP="TOOLTIP",e))(Ne||{}),Ae=(e=>(e.ABOVE="ABOVE",e.BELOW="BELOW",e.LEFT="LEFT",e.RIGHT="RIGHT",e))(Ae||{}),Re=(e=>(e.CLOSE_FLOW="CLOSE_FLOW",e.EVAL_JS="EVAL_JS",e.GO_TO_STEP="GO_TO_STEP",e.NAVIGATE="NAVIGATE",e.SET_ATTRIBUTE="SET_ATTRIBUTE",e.SNOOZE="SNOOZE",e.START_FLOW="START_FLOW",e.TRACK_BUTTON_EVENT="TRACK_BUTTON_EVENT",e))(Re||{}),ve=(e=>(e.NEW_TAB="NEW_TAB",e.SAME_TAB="SAME_TAB",e))(ve||{}),Oe=(e=>(e.SET="SET",e.SET_DATETIME="SET_DATETIME",e.SET_DATETIME_ONCE="SET_DATETIME_ONCE",e.SET_ONCE="SET_ONCE",e.ADD="ADD",e.SUBTRACT="SUBTRACT",e.APPEND="APPEND",e.PREPEND="PREPEND",e.REMOVE="REMOVE",e.UNSET="UNSET",e))(Oe||{}),be=(e=>(e.MULTILINE_TEXT="MULTILINE_TEXT",e.MULTIPLE_CHOICE="MULTIPLE_CHOICE",e.NPS="NPS",e.SCALE="SCALE",e.STARS="STARS",e.TEXT="TEXT",e))(be||{}),De=(e=>(e.CLICK="CLICK",e.FILL="FILL",e.NAVIGATE="NAVIGATE",e))(De||{}),R=(e=>(e.ACTION="ACTION",e.ANNOUNCEMENTS="ANNOUNCEMENTS",e.ASSISTANT="ASSISTANT",e.CHECKLIST="CHECKLIST",e.CONTACT="CONTACT",e.DIVIDER="DIVIDER",e.FLOWS="FLOWS",e.KNOWLEDGE_BASE="KNOWLEDGE_BASE",e.MESSAGE="MESSAGE",e.SUBPAGE="SUBPAGE",e))(R||{}),ye=(e=>(e.CRISP="CRISP",e.CUSTOM="CUSTOM",e.FRESHCHAT="FRESHCHAT",e.HELPSCOUT="HELPSCOUT",e.HUBSPOT="HUBSPOT",e.INTERCOM="INTERCOM",e.ZENDESK="ZENDESK",e.ZENDESK_MESSENGER="ZENDESK_MESSENGER",e))(ye||{}),Me=(e=>(e.BUTTON="BUTTON",e.INPUT="INPUT",e))(Me||{}),Pe=(e=>(e.EMAIL="EMAIL",e.PHONE="PHONE",e.CHAT="CHAT",e))(Pe||{}),Be=(e=>(e.SILENT="SILENT",e.BADGE="BADGE",e.POPOUT="POPOUT",e.MODAL="MODAL",e.TOAST="TOAST",e))(Be||{}),He=(e=>(e.DEFAULT="DEFAULT",e.CUSTOM="CUSTOM",e.NONE="NONE",e))(He||{}),We=(e=>(e.LAUNCHER_CLICK="LAUNCHER_CLICK",e.LAUNCHER_HOVER="LAUNCHER_HOVER",e.TARGET_CLICK="TARGET_CLICK",e.TARGET_HOVER="TARGET_HOVER",e.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",e.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",e))(We||{}),V=(e=>(e.ACTIVATE="ACTIVATE",e.DEACTIVATE="DEACTIVATE",e.NEVER="NEVER",e))(V||{}),Ge=(e=>(e.AUTO="AUTO",e.TOP="TOP",e.RIGHT="RIGHT",e.BOTTOM="BOTTOM",e.LEFT="LEFT",e))(Ge||{}),xe=(e=>(e.START="START",e.CENTER="CENTER",e.END="END",e))(xe||{}),Fe=(e=>(e.PERCENT="PERCENT",e.PX="PX",e))(Fe||{}),Ve=(e=>(e.BEACON="BEACON",e.BUTTON="BUTTON",e.HIDDEN="HIDDEN",e.ICON="ICON",e))(Ve||{}),Ke=(e=>(e.LAUNCHER="LAUNCHER",e.TARGET="TARGET",e))(Ke||{}),$e=(e=>(e.BODY_FIRST="BODY_FIRST",e.BODY_LAST="BODY_LAST",e.ELEMENT_FIRST="ELEMENT_FIRST",e.ELEMENT_LAST="ELEMENT_LAST",e.ELEMENT_BEFORE="ELEMENT_BEFORE",e.ELEMENT_AFTER="ELEMENT_AFTER",e))($e||{}),je=(e=>(e.BODY_FIRST="BODY_FIRST",e.BODY_LAST="BODY_LAST",e.ELEMENT_FIRST="ELEMENT_FIRST",e.ELEMENT_LAST="ELEMENT_LAST",e.ELEMENT_BEFORE="ELEMENT_BEFORE",e.ELEMENT_AFTER="ELEMENT_AFTER",e))(je||{}),K=(e=>(e.CHECKLIST="CHECKLIST",e))(K||{}),Ye=(e=>(e.INITIAL="INITIAL",e.FOLLOWUP="FOLLOWUP",e))(Ye||{}),ze=(e=>(e.FLOW="FLOW",e.WORKFLOW="WORKFLOW",e))(ze||{}),Je=(e=>(e.HIDE="HIDE",e.OTHERS="OTHERS",e))(Je||{}),Qe=(e=>(e.ALWAYS="ALWAYS",e.MULTIPLE="MULTIPLE",e.NEVER="NEVER",e.ONCE="ONCE",e.ONCE_PER_GROUP="ONCE_PER_GROUP",e))(Qe||{}),Xe=(e=>(e.NONE="NONE",e.PENDING_SCHEDULE="PENDING_SCHEDULE",e.SCHEDULED="SCHEDULED",e.FIRED="FIRED",e))(Xe||{}),Ze=(e=>(e.NONE="NONE",e.LIKE="LIKE",e.SCALE="SCALE",e))(Ze||{}),qe=(e=>(e.HIDE="HIDE",e.BLOCK="BLOCK",e.OTHERS="OTHERS",e))(qe||{});function et(){return{customInputs:[],customNavigate:null,urlFilter:null,linkUrlDecorator:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[e=>!e.match(/\d$/)],"data-id":[e=>!e.match(/\d$/)]},inferenceClassNameFilters:[e=>!e.startsWith("css-")],baseZIndex:1234500,evalJsDisabled:!1}}const f=et();function M(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map(t=>typeof t=="string"?new RegExp(t):t),e}function Et(e,t){return e.every(s=>typeof s=="function"?s(t):s instanceof RegExp?s.test(t):!0)}function tt(){let e=m();if(f.urlFilter){if(e=f.urlFilter(e),typeof e!="string")throw new h("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(e)}catch(t){throw new h(`Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.
3
3
  Returned URL: `+e+`
4
- Error message: `+t.message)}}return e}let $="";try{$=localStorage.getItem("debug")||""}catch{}const j=$.split(",").some(e=>e==="*"||e.startsWith("userflow:*")),o=O("log");o.group=O("group");o.groupCollapsed=O("groupCollapsed");o.groupEnd=function(){j&&console.groupEnd()};let _;function O(e){return function(t,...s){if(j){const n=performance.now(),i=_?Math.round(n-_):0;_=n,console[e](`%cuserflow %c${t} %c+${i}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const st=()=>I(()=>import("./ResourceCenterApp.js").then(e=>e.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]));function it(e){const s=e.version.checklist.tasks.length;return Math.max(0,s-e.taskCompletions.length)}class P{constructor(t){this.observers=new Set,this._value=t}get value(){return this._value}update(t){if(t!==this._value){this._value=t;for(const s of this.observers)s()}}observe(t){return this.observers.add(t),()=>this.observers.delete(t)}}const B=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit","livewire:navigated","livewire:navigating","livewire:update"],nt=()=>I(()=>import("./BannerApp.js"),__vite__mapDeps([32,1,2,3,4,5,6,15,12,13,14,9,10,11,8,7,16,18,19,17,20,30,21,33,34])),N="1025218",rt=import.meta.url,H=50,ot=300*1e3,W="userflowClientState",w="userflowClientSiteId";class at{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=null,this.siteSession=null,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.embedSessions=[],this.workflowSession=null,this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.debuggerUI=null,this.debuggerMountInProgress=!1,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.implicitTracking=null,this.initialMessagesQueue=[],this.onBuilderMessage=t=>(this.handleBuilderMessage(t),!1),this.handleBuilderMessage=async t=>{o(`builder ${t.kind} message received`,t);const s="idempotencyKey"in t&&typeof t.idempotencyKey=="string"?t.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const n=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(t.kind){case"userflow:selectElement":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:t.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),d.setItem("previewFlowId",t.flowId),t.testUser?this.identifyTestUser(t.testUser):this.resetTestUser(),t.testStartCondition?this.setSessionStorageState(i=>({...i,activeApp:"startConditionTesting",testStartConditionToken:t.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(t.token),t.isResourceCenter){const i=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===t.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",i))};this.on("resourceCenterChanged",i),i()}});return}case"userflow:testTracker":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0})),t.testUser?this.identifyTestUser(t.testUser):this.resetTestUser(),this.setSessionStorageState(i=>({...i,activeApp:"trackerTesting",trackerTesting:{trackerName:t.trackerName,token:t.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,trackerTesting:null}));return}case"userflow:startSmartFlow":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startSmartFlowAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:"smartFlowRecording",smartFlowRecording:{sessionId:t.sessionId,isRecording:!0,startUrl:t.startUrl||null}}));return}case"userflow:smartFlowCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,smartFlowRecording:null}));return}case"userflow:smartFlowStartOverAck":return;case"userflow:smartFlowComplete":{this.setSessionStorageState(i=>({...i,activeApp:null,smartFlowRecording:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),H))},this.onUserActivity=()=>this.ensureConnected(),this.mountSitePage=async(t,s)=>{d.setItem(w,s),o("mounting site page"),this.setResourceCenterLauncherHidden(!0);try{const{SitePage:n}=await I(async()=>{const{SitePage:r}=await import("./SitePage.js");return{SitePage:r}},__vite__mapDeps([35,1,2,3,4,5,6,18,19,36,37,38,39,40,41,42,43,44,45,27,15,12,13,14,9,10,11,25,26,20,8,46,28,47,48,33,34]));new n(this,t).mount(),o("site page mounted")}catch(n){console.error("Userflow: Failed to mount site page",n)}},this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+N),q(this.onUrlChange),this.setTargetEnv(new te),this.checkTestUserAtBoot(),this.toggleUI(),this.checkDebuggerSession();for(const t of B)document.addEventListener(t,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),F(this.onUrlChange),this.destroyTargetEnv();for(const t of B)document.removeEventListener(t,this.remountIfNecessary)}setTargetEnv(t){this.destroyTargetEnv(),this.targetEnv=t,t.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new h("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(t){const s=t(this.getSessionStorageState());d.setItem(W,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let t=this.sessionStorageState;if(!t){const s=d.getItem(W);if(s)try{t=JSON.parse(s)}catch(n){console.error("Userflow.js: Parse ElementSelectionState error:",n)}t||(t={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=t}return t}checkTestUserAtBoot(){const t=this.getSessionStorageState().testUser;t&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(t))}async identifyTestUser(t){this.setSessionStorageState(i=>({...i,testUser:t})),this.reset(),this.init(t.clientToken),this.testUserIdentified=!0,this.externalId=t.id;const s=[this.identify(t.id,{name:t.name,email:t.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:t.signature})],{group:n}=t;n&&(this.groupId=n.id,s.push(this.group(n.id,{name:n.name},{signature:n.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(t=>({...t,testUser:null}))}init(t){if(o("init",t),!t)throw new h("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==t){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=t,this.emit("private:initialised")}}ensureInit(){if(!this.clientToken)throw new h("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new h("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new h("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");const t=/^ct_eu\d+_.+$/.test(this.clientToken)?"e.eu.":"e.";let s=f.serverEndpoint||t+"userflow.com";new URL(rt).hostname==="js.getuserflow.com"&&s==="e.userflow.com"&&(s="e.getuserflow.com");const n="wss://"+s+"/end-users/"+this.clientToken+"/socket";this.socket=new J(n,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{typeof this.featureFlags>"u"&&this.clearInitialMessagesQueue(i.featureFlags),this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected"),this.featureFlagEnabled("cff_implicit_events")===!0&&!this.implicitTracking&&this.startImplicitTracking(),!this.featureFlagEnabled("cff_implicit_events")&&this.implicitTracking&&(this.implicitTracking.stop(),this.implicitTracking=null)}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
4
+ Error message: `+t.message)}}return e}let $="";try{$=localStorage.getItem("debug")||""}catch{}const j=$.split(",").some(e=>e==="*"||e.startsWith("userflow:*")),o=O("log");o.group=O("group");o.groupCollapsed=O("groupCollapsed");o.groupEnd=function(){j&&console.groupEnd()};let _;function O(e){return function(t,...s){if(j){const n=performance.now(),i=_?Math.round(n-_):0;_=n,console[e](`%cuserflow %c${t} %c+${i}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const st=()=>I(()=>import("./ResourceCenterApp.js").then(e=>e.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]));function it(e){const s=e.version.checklist.tasks.length;return Math.max(0,s-e.taskCompletions.length)}class P{constructor(t){this.observers=new Set,this._value=t}get value(){return this._value}update(t){if(t!==this._value){this._value=t;for(const s of this.observers)s()}}observe(t){return this.observers.add(t),()=>this.observers.delete(t)}}const B=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit","livewire:navigated","livewire:navigating","livewire:update"],nt=()=>I(()=>import("./BannerApp.js"),__vite__mapDeps([32,1,2,3,4,5,6,15,12,13,14,9,10,11,8,7,16,18,19,17,20,30,21,33,34])),N="1025288",rt=import.meta.url,H=50,ot=300*1e3,W="userflowClientState",w="userflowClientSiteId";class at{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=null,this.siteSession=null,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.embedSessions=[],this.workflowSession=null,this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.debuggerUI=null,this.debuggerMountInProgress=!1,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.implicitTracking=null,this.initialMessagesQueue=[],this.onBuilderMessage=t=>(this.handleBuilderMessage(t),!1),this.handleBuilderMessage=async t=>{o(`builder ${t.kind} message received`,t);const s="idempotencyKey"in t&&typeof t.idempotencyKey=="string"?t.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const n=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(t.kind){case"userflow:selectElement":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:t.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),d.setItem("previewFlowId",t.flowId),t.testUser?this.identifyTestUser(t.testUser):this.resetTestUser(),t.testStartCondition?this.setSessionStorageState(i=>({...i,activeApp:"startConditionTesting",testStartConditionToken:t.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(t.token),t.isResourceCenter){const i=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===t.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",i))};this.on("resourceCenterChanged",i),i()}});return}case"userflow:testTracker":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0})),t.testUser?this.identifyTestUser(t.testUser):this.resetTestUser(),this.setSessionStorageState(i=>({...i,activeApp:"trackerTesting",trackerTesting:{trackerName:t.trackerName,token:t.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,trackerTesting:null}));return}case"userflow:startSmartFlow":{n(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startSmartFlowAck",idempotencyKey:t.idempotencyKey}),this.setSessionStorageState(i=>({...i,isTargetTab:!0,activeApp:"smartFlowRecording",smartFlowRecording:{sessionId:t.sessionId,isRecording:!0,startUrl:t.startUrl||null}}));return}case"userflow:smartFlowCancel":{this.setSessionStorageState(i=>({...i,activeApp:null,smartFlowRecording:null}));return}case"userflow:smartFlowStartOverAck":return;case"userflow:smartFlowComplete":{this.setSessionStorageState(i=>({...i,activeApp:null,smartFlowRecording:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),H))},this.onUserActivity=()=>this.ensureConnected(),this.mountSitePage=async(t,s)=>{d.setItem(w,s),o("mounting site page"),this.setResourceCenterLauncherHidden(!0);try{const{SitePage:n}=await I(async()=>{const{SitePage:r}=await import("./SitePage.js");return{SitePage:r}},__vite__mapDeps([35,1,2,3,4,5,6,18,19,36,37,38,39,40,41,42,43,44,45,27,15,12,13,14,9,10,11,25,26,20,8,46,28,47,48,33,34]));new n(this,t).mount(),o("site page mounted")}catch(n){console.error("Userflow: Failed to mount site page",n)}},this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+N),q(this.onUrlChange),this.setTargetEnv(new te),this.checkTestUserAtBoot(),this.toggleUI(),this.checkDebuggerSession();for(const t of B)document.addEventListener(t,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),F(this.onUrlChange),this.destroyTargetEnv();for(const t of B)document.removeEventListener(t,this.remountIfNecessary)}setTargetEnv(t){this.destroyTargetEnv(),this.targetEnv=t,t.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new h("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(t){const s=t(this.getSessionStorageState());d.setItem(W,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let t=this.sessionStorageState;if(!t){const s=d.getItem(W);if(s)try{t=JSON.parse(s)}catch(n){console.error("Userflow.js: Parse ElementSelectionState error:",n)}t||(t={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=t}return t}checkTestUserAtBoot(){const t=this.getSessionStorageState().testUser;t&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(t))}async identifyTestUser(t){this.setSessionStorageState(i=>({...i,testUser:t})),this.reset(),this.init(t.clientToken),this.testUserIdentified=!0,this.externalId=t.id;const s=[this.identify(t.id,{name:t.name,email:t.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:t.signature})],{group:n}=t;n&&(this.groupId=n.id,s.push(this.group(n.id,{name:n.name},{signature:n.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(t=>({...t,testUser:null}))}init(t){if(o("init",t),!t)throw new h("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==t){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=t,this.emit("private:initialised")}}ensureInit(){if(!this.clientToken)throw new h("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new h("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new h("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");const t=/^ct_eu\d+_.+$/.test(this.clientToken)?"e.eu.":"e.";let s=f.serverEndpoint||t+"userflow.com";new URL(rt).hostname==="js.getuserflow.com"&&s==="e.userflow.com"&&(s="e.getuserflow.com");const n="wss://"+s+"/end-users/"+this.clientToken+"/socket";this.socket=new J(n,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{typeof this.featureFlags>"u"&&this.clearInitialMessagesQueue(i.featureFlags),this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected"),this.featureFlagEnabled("cff_implicit_events")===!0&&!this.implicitTracking&&this.startImplicitTracking(),!this.featureFlagEnabled("cff_implicit_events")&&this.implicitTracking&&(this.implicitTracking.stop(),this.implicitTracking=null)}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
5
5
  Details:
6
6
  `+i.details.map(r=>(r.path?`${r.path}: `:"")+r.message):""))})}async startImplicitTracking(){await I(()=>import("./implicit-tracking.js"),__vite__mapDeps([49,11,2,34,33])).then(t=>{this.implicitTracking=new t.ImplicitTracking(this),this.implicitTracking.start()}).catch(t=>o(`Implicit tracking failed to load ${t}`))}makeChannelJoinPayload(){let t;d.getItem(w)&&(t=new URL(m()).searchParams.get("announcement_id")||void 0);const n=this.buildClientContext();this.clientContext=n;const i={protocolVersion:2,userflowClientBuild:N,signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,bannerSessionId:this.bannerSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,siteSessionId:this.siteSession?.id||null,launchers:this.launcherSessions.map(r=>({flowId:r.flow.id})),trackers:Array.from(this.trackers.values()).map(r=>({flowId:r.tracker.flowId})),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map(r=>({conditionId:r.condition.id,isTrue:r.isTrue})),previewFlowId:d.getItem("previewFlowId"),announcementPreviewId:t,clientContext:n};return o("channel join payload",i),i}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout(()=>{if(this.hasDraftSession()||this.assistantMessageInProgress){this.debounceInactiveDisconnect();return}o("disconnecting from socket due to inactivity"),this.disconnect()},ot)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some(t=>t.draftMode)}async send(t,{batch:s,endBatch:n,handlesRejection:i}={}){return(!this.inBatch||!["ToggleClientCondition","UpdateClientContext"].includes(t.kind))&&this.checkPushRateLimit(),this.ensureConnected(),s&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),n?this.endBatch():this.endBatchTimeout=window.setTimeout(()=>{this.endBatch()},H)),this.sendRaw(t,{handlesRejection:i})}clearInitialMessagesQueue(t){if(this.initialMessagesQueue.length===0)return;const s=t.includes("cff_disable_page_views")===!0,n=t.includes("cff_implicit_events")===!1;for(const i of this.initialMessagesQueue){const{message:r,handlesRejection:a,resolve:l,reject:u}=i;if(n&&r.kind==="TrackRawEvent"){l("skipped due to disabled implicit events");continue}if(s&&(r.kind==="TrackEvent"&&r.name==="page_viewed"||r.kind==="TrackRawEvent"&&r.name==="page_viewed")){l("skipped due to disabled page views tracking");continue}this._sendToChannel(r,l,u,{handlesRejection:a})}this.initialMessagesQueue=[]}async sendRaw(t,{handlesRejection:s}={}){return typeof this.featureFlags>"u"?new Promise((n,i)=>{this.initialMessagesQueue.push({message:t,resolve:n,reject:i,handlesRejection:s})}):new Promise((n,i)=>{this._sendToChannel(t,n,i,{handlesRejection:s})})}_sendToChannel(t,s,n,{handlesRejection:i}={}){if(!this.channel){const u=`Userflow.js: send() should not be called if channel is not set. Message kind=${t.kind}`;if(i)throw Error(u);console.log(u,`
7
7
  Client message:`,t);return}o(`push ${t.kind} message`,t);const r=this.clientClock,a=()=>{this.serverClock=r,this.channel?.off("phx_error",l)},l=this.channel.on("phx_error",u=>{a();const c=`Userflow.js send ${t.kind} got phx_error`;this._socketStatus==="connected"&&console.log(c,`
@@ -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]="f48a3301-4a9b-41e7-9597-54106f451764",e._sentryDebugIdIdentifier="sentry-dbid-f48a3301-4a9b-41e7-9597-54106f451764")}catch{}})();var p=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};p.SENTRY_RELEASE={id:"a1ea0c65a00f734246b368bc2d4fc5b897a0bd4a"};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 u,b;function j(){if(b)return u;b=1;var e=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable;function c(t){if(t==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function g(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de",Object.getOwnPropertyNames(t)[0]==="5")return!1;for(var l={},r=0;r<10;r++)l["_"+String.fromCharCode(r)]=r;var a=Object.getOwnPropertyNames(l).map(function(n){return l[n]});if(a.join("")!=="0123456789")return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(n){o[n]=n}),Object.keys(Object.assign({},o)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return u=g()?Object.assign:function(t,l){for(var r,a=c(t),o,n=1;n<arguments.length;n++){r=Object(arguments[n]);for(var i in r)s.call(r,i)&&(a[i]=r[i]);if(e){o=e(r);for(var f=0;f<o.length;f++)d.call(r,o[f])&&(a[o[f]]=r[o[f]])}}return a},u}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]="6015ba3e-c36b-4022-b048-a87b5191a534",e._sentryDebugIdIdentifier="sentry-dbid-6015ba3e-c36b-4022-b048-a87b5191a534")}catch{}})();var p=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};p.SENTRY_RELEASE={id:"eb88b78a5932a7515c98f28fb41cb5adb3d102a4"};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,d;function j(){if(d)return i;d=1;var e=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;function c(t){if(t==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function g(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de",Object.getOwnPropertyNames(t)[0]==="5")return!1;for(var l={},r=0;r<10;r++)l["_"+String.fromCharCode(r)]=r;var a=Object.getOwnPropertyNames(l).map(function(n){return l[n]});if(a.join("")!=="0123456789")return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(n){o[n]=n}),Object.keys(Object.assign({},o)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return i=g()?Object.assign:function(t,l){for(var r,a=c(t),o,n=1;n<arguments.length;n++){r=Object(arguments[n]);for(var b in r)s.call(r,b)&&(a[b]=r[b]);if(e){o=e(r);for(var f=0;f<o.length;f++)u.call(r,o[f])&&(a[o[f]]=r[o[f]])}}return a},i}export{y as c,w as g,j as r};
2
2
  //# sourceMappingURL=vendor.object-assign.js.map