userflow.js-self-hosted 0.1.1008453 → 0.1.1008499

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/FlowApp.js CHANGED
@@ -1,6 +1,6 @@
1
- import{R as o,r as f}from"./vendor.react.js";import{E as D,k as N,V as L,l as ce,m as ue,T as O,n as F,o as de,p as pe,M as fe,U as Y}from"./userflow.js";import"./vendor.html-parse-stringify2.js";import{u as x}from"./vendor.react-i18next.js";import{B as G}from"./BubbleToolbar.js";import{m as me,d as Q,R as be,i as Ee,g as ge,u as we,c as V,h as he,S as Te}from"./bubble-frame.styl.js";import{b as X,z as ve,a as Se,l as K,r as ye}from"./flow-condition-types.js";import{u as I,i as ke}from"./client-context.js";import{F as De}from"./FlowChrome.js";import{u as Ne,r as Re}from"./use-selector-element-monitoring.js";import{a as Z,S as Ie}from"./flow-host.styl.js";import{f as Me}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as Ae,u as Be}from"./stylesheets.js";import{T as Fe}from"./Trigger.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.obj-str.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.js";(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]="f9c13b73-3b25-4739-9fa8-63a4e79040ae",e._sentryDebugIdIdentifier="sentry-dbid-f9c13b73-3b25-4739-9fa8-63a4e79040ae")}catch{}})();const Ce=()=>{const{t:e}=x(),s=I(),{dispatch:t,restart:n}=A(),{session:l,step:d}=k(),a="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return o.createElement("div",{role:"dialog","aria-modal":M(d)?"true":void 0,"aria-label":"Guide menu"},o.createElement("div",{className:"userflowjs-bubble-menu__title"},e("menu.title")),o.createElement("button",{className:a,onClick:()=>s.endFlow(l,{endReason:D.USER_CLOSED})},e("menu.close")),l.version.restartEnabled&&o.createElement("button",{className:a,onClick:n},e("menu.restart")),o.createElement("button",{className:a,onClick:()=>t({kind:"showFlow"})},e("menu.back")))},W=({progress:e,type:s,position:t,totalSteps:n})=>{const{t:l}=x(),d=parseFloat(e||"0"),a={width:`${d*100}%`},c=s==="DEFAULT"?"TOP":t,u=`userflowjs-bubble-progress-${s||"DEFAULT"}`,m=c==="BOTTOM"?" userflowjs-bubble-progress-bottom":"",i=["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW"].includes(s)?`userflowjs-bubble-progress-CHAINED ${s==="CHAINED_SQUARED"?"userflowjs-bubble-progress-CHAINED_SQUARED":s==="CHAINED_ROUNDED"?"userflowjs-bubble-progress-CHAINED_ROUNDED":s==="DOTTED"?"userflowjs-bubble-progress-DOTTED":"userflowjs-bubble-progress-NARROW"}${m}`:`${u}${m}`,r=s==="NUMBERED"?3:n||0,b=Math.min(Math.floor(d*r),r);return o.createElement("div",null,["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED"].includes(s)&&o.createElement("div",{className:i},Array.from({length:3}).map((E,g)=>o.createElement("div",{key:g,className:`rounded ${g<Math.floor(d*3)?"completed":""}`}))),s==="NARROW"&&o.createElement("div",{className:i},o.createElement("div",{className:"linear-progress-bar"},o.createElement("div",{className:"linear-progress-fill",style:a}))),s==="NUMBERED"&&o.createElement("div",{className:i},o.createElement("span",{className:"numbered-progress"},l("of",{replace:{range:r,selected:b}}))),!["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW","NUMBERED"].includes(s)&&o.createElement("div",{className:`${i} ${c==="BOTTOM"?"bottom":""}`},o.createElement("div",{className:"userflowjs-bubble-progress__fill",style:a})))};var J=(e=>(e.BOTTOM="BOTTOM",e.TOP="TOP",e))(J||{});const Le=({theme:e})=>{const s=I(),{session:t,step:n,muted:l,shouldLabelDialog:d}=k(),{version:a}=t,{dispatch:c}=A(),u=a.steps[0],m=u&&u.id===n.id,i=m&&n.progress==="1",r=f.useMemo(()=>n.content&&me(Q(n.content),{buttons:n.buttons,questions:n.questions}),[n.content,n.buttons,n.questions]),b=a.steps.filter(v=>v.appearance!==N.HIDDEN),E=b.findIndex(v=>v.id===n.id),g=b.length,h=g>0?((E+1)/g).toString():"0";return o.createElement("div",{key:n.id,role:"alertdialog","aria-modal":M(n)?"true":void 0,"aria-label":d?"Guide":void 0},!i&&e.progressBarPosition==="TOP"&&e.progressBarEnabled&&o.createElement(W,{progress:h,type:e.progressBarType,totalSteps:g}),o.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},o.createElement(be,{doc:r,lookupAttribute:X(t.data),buttons:n.buttons,questions:n.questions})),o.createElement(G,{draftMode:t.draftMode,muted:l,toggleMuted:e.voiceType!==L.NONE?()=>c({kind:"toggleMuted"}):void 0,close:a.closeDisabled?void 0:()=>e.flowXButtonBehavior===ce.DISMISS||m?s.endFlow(t,{endReason:D.USER_CLOSED}):c({kind:"showMenu"})}),!i&&e.progressBarPosition==="BOTTOM"&&e.progressBarEnabled&&o.createElement(W,{progress:h,type:e.progressBarType,position:J.BOTTOM,totalSteps:g}))};function Oe(e,s){if(!e)return"";typeof e=="string"&&(e=Q(e));const t=[],n=/[.!?;,]$/;function l(){const c=(t[t.length-1]||"").trim();c&&!c.match(n)&&t.push(".")}function d(c){if(Ee(c)){if(c.text&&!c.silent){const u=c.text.split(`
1
+ import{R as o,r as f}from"./vendor.react.js";import{E as D,k as N,V as L,l as ce,m as ue,T as O,n as F,o as de,p as pe,M as fe,U as Y}from"./userflow.js";import"./vendor.html-parse-stringify2.js";import{u as x}from"./vendor.react-i18next.js";import{B as G}from"./BubbleToolbar.js";import{m as me,d as Q,R as be,i as Ee,g as ge,u as we,c as V,h as he,S as Te}from"./bubble-frame.styl.js";import{b as X,z as ve,a as Se,l as K,r as ye}from"./flow-condition-types.js";import{u as R,i as ke}from"./client-context.js";import{F as De}from"./FlowChrome.js";import{u as Ne,r as Ie}from"./use-selector-element-monitoring.js";import{a as Z,S as Re}from"./flow-host.styl.js";import{f as Me}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as Ae,u as Be}from"./stylesheets.js";import{T as Fe}from"./Trigger.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.obj-str.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.js";(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]="c11334ca-820d-4b5c-88b9-7391e5684a74",e._sentryDebugIdIdentifier="sentry-dbid-c11334ca-820d-4b5c-88b9-7391e5684a74")}catch{}})();const Ce=()=>{const{t:e}=x(),s=R(),{dispatch:t,restart:n}=A(),{session:l,step:d}=k(),a="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return o.createElement("div",{role:"dialog","aria-modal":M(d)?"true":void 0,"aria-label":"Guide menu"},o.createElement("div",{className:"userflowjs-bubble-menu__title"},e("menu.title")),o.createElement("button",{className:a,onClick:()=>s.endFlow(l,{endReason:D.USER_CLOSED})},e("menu.close")),l.version.restartEnabled&&o.createElement("button",{className:a,onClick:n},e("menu.restart")),o.createElement("button",{className:a,onClick:()=>t({kind:"showFlow"})},e("menu.back")))},W=({progress:e,type:s,position:t,totalSteps:n})=>{const{t:l}=x(),d=parseFloat(e||"0"),a={width:`${d*100}%`},c=s==="DEFAULT"?"TOP":t,u=`userflowjs-bubble-progress-${s||"DEFAULT"}`,m=c==="BOTTOM"?" userflowjs-bubble-progress-bottom":"",i=["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW"].includes(s)?`userflowjs-bubble-progress-CHAINED ${s==="CHAINED_SQUARED"?"userflowjs-bubble-progress-CHAINED_SQUARED":s==="CHAINED_ROUNDED"?"userflowjs-bubble-progress-CHAINED_ROUNDED":s==="DOTTED"?"userflowjs-bubble-progress-DOTTED":"userflowjs-bubble-progress-NARROW"}${m}`:`${u}${m}`,r=n||0,b=Math.min(r,Math.max(1,Math.floor(d*r)));return o.createElement("div",null,["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED"].includes(s)&&o.createElement("div",{className:i},Array.from({length:3}).map((E,g)=>o.createElement("div",{key:g,className:`rounded ${g<Math.floor(d*3)?"completed":""}`}))),s==="NARROW"&&o.createElement("div",{className:i},o.createElement("div",{className:"linear-progress-bar"},o.createElement("div",{className:"linear-progress-fill",style:a}))),s==="NUMBERED"&&o.createElement("div",{className:i},o.createElement("span",{className:"numbered-progress"},l("of",{replace:{range:r,selected:b}}))),!["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW","NUMBERED"].includes(s)&&o.createElement("div",{className:`${i} ${c==="BOTTOM"?"bottom":""}`},o.createElement("div",{className:"userflowjs-bubble-progress__fill",style:a})))};var J=(e=>(e.BOTTOM="BOTTOM",e.TOP="TOP",e))(J||{});const Le=({theme:e})=>{const s=R(),{session:t,step:n,muted:l,shouldLabelDialog:d}=k(),{version:a}=t,{dispatch:c}=A(),u=a.steps[0],m=u&&u.id===n.id,i=m&&n.progress==="1",r=f.useMemo(()=>n.content&&me(Q(n.content),{buttons:n.buttons,questions:n.questions}),[n.content,n.buttons,n.questions]),b=a.steps.filter(v=>v.appearance!==N.HIDDEN),E=b.findIndex(v=>v.id===n.id),g=b.length,h=g>0?((E+1)/g).toString():"0";return o.createElement("div",{key:n.id,role:"alertdialog","aria-modal":M(n)?"true":void 0,"aria-label":d?"Guide":void 0},!i&&e.progressBarPosition==="TOP"&&e.progressBarEnabled&&o.createElement(W,{progress:h,type:e.progressBarType,totalSteps:g}),o.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},o.createElement(be,{doc:r,lookupAttribute:X(t.data),buttons:n.buttons,questions:n.questions})),o.createElement(G,{draftMode:t.draftMode,muted:l,toggleMuted:e.voiceType!==L.NONE?()=>c({kind:"toggleMuted"}):void 0,close:a.closeDisabled?void 0:()=>e.flowXButtonBehavior===ce.DISMISS||m?s.endFlow(t,{endReason:D.USER_CLOSED}):c({kind:"showMenu"})}),!i&&e.progressBarPosition==="BOTTOM"&&e.progressBarEnabled&&o.createElement(W,{progress:h,type:e.progressBarType,position:J.BOTTOM,totalSteps:g}))};function Oe(e,s){if(!e)return"";typeof e=="string"&&(e=Q(e));const t=[],n=/[.!?;,]$/;function l(){const c=(t[t.length-1]||"").trim();c&&!c.match(n)&&t.push(".")}function d(c){if(Ee(c)){if(c.text&&!c.silent){const u=c.text.split(`
2
2
  `);u.forEach((m,i)=>{t.push(m),i<u.length-1&&(l(),t.push(`
3
3
  `))})}return}switch(c.type){case"attribute":{const u=ge(c,s);u&&t.push(u);break}default:a(c.children),["link"].includes(c.type)||(l(),t.push(`
4
4
 
5
- `));break}}function a(c){c.forEach(u=>d(u))}return a(e.children),t.join("").trim().replace(new RegExp(" ","g")," ").replace(new RegExp("\b","g"),"")}const _e=({bubbleFrame:e,theme:s})=>{const t=I(),{dispatch:n}=A(),{muted:l,session:d,step:a}=k(),c=t.getAudio();f.useEffect(()=>{const r=()=>{n({kind:"speechPlaying"})},b=()=>{n({kind:"speechStopped"})};return c.addEventListener("playing",r),c.addEventListener("ended",b),c.addEventListener("pause",b),()=>{c.removeEventListener("playing",r),c.removeEventListener("ended",b),c.removeEventListener("pause",b),c.pause(),c.src="",n({kind:"speechStopped"})}},[n,c]),f.useEffect(()=>{if(t.audioReady)return;const r=e&&Pe(e)?e.contentWindow:null,b=()=>{window.removeEventListener("mousedown",E),r&&r.removeEventListener("mousedown",E)},E=()=>{b(),t.playAudio(null)};return window.addEventListener("mousedown",E),r&&r.addEventListener("mousedown",E),b},[e,t]);const u=f.useRef(d),m=f.useRef(s),i=f.useRef(a);return f.useEffect(()=>{u.current=d,m.current=s,i.current=a},[d,s,a]),f.useEffect(()=>{if(!t.audioReady||l){t.pauseAudio();return}let r=!1;return(async()=>{if(await new Promise(g=>setTimeout(g,1)),r)return;const E=await xe(t,u.current,m.current,i.current);r||E&&t.playAudio(E)})(),()=>{r=!0}},[l,t,a.id,s.voiceType,s.syntheticVoice]),null};async function xe(e,s,t,n){if(t.voiceType===L.SYNTHETIC&&typeof t.syntheticVoice=="string"&&n.content){e.ensureIdentified();const l=X(s.data),d=Oe(n.content,l);return e.getStepSpeech(t.syntheticVoice,d)}else if(t.voiceType===L.MANUAL&&n.speechAsset)return n.speechAsset.assetUrl;return null}function Pe(e){return e.tagName==="IFRAME"}const je="userflowjs-out-of-viewport-pointer--visible",Ue="userflowjs-out-of-viewport-pointer--visible-up",qe="userflowjs-out-of-viewport-pointer--visible-down",He=o.forwardRef((e,s)=>{const t=Z();return o.createElement("div",{ref:s,className:"userflowjs-out-of-viewport-pointer",style:{zIndex:t+2}},o.createElement(Ae,{icon:Me}))});function Ve({subjectPosition:e,pointerRef:s,viewportClipRect:t}){const n=s.current;if(!n)return null;const l=n.getBoundingClientRect(),d=ve(Se());let a=e.direction,c,u;return a==null?null:(a==="down"&&t.bottom<l.height/2?a="up":a==="up"&&t.top>d&&(a="down"),c=e.left+e.width/2-l.width/2,u=a==="down"?t.bottom-l.height:t.top,{direction:a,left:c,top:u})}function $(e,s){const t=e.current;t&&(t.classList.toggle(je,s!=null),s&&(t.style.left=s.left+"px",t.style.top=s.top+"px",t.classList.toggle(Ue,s.direction==="up"),t.classList.toggle(qe,s.direction==="down")))}const We="userflowjs-fixed-widget--visible",$e=({theme:e})=>{const{step:s}=k();return o.createElement(o.Fragment,null,s.beacons.map(t=>o.createElement(ze,{key:t.id,beacon:t,theme:e})))},ze=({beacon:e,theme:s})=>{const{session:t}=k(),n=Z(),l=f.useRef(null),d=f.useRef(null),a=we(e.hiddenCondition),c=f.useMemo(()=>K(e.selector,t.data),[e.selector,t.data]),u=f.useCallback(({targetRect:i,clipEl:r,viewportClipRect:b})=>{const E=Ye({beacon:e,beaconRef:l,clipEl:r,viewportClipRect:b,targetRect:i,theme:s}),g=E&&Ve({subjectPosition:E.pointerSubjectPosition,pointerRef:d,viewportClipRect:b});Re(()=>{z(l,E),$(d,g)})},[e]),m=f.useCallback(()=>{z(l,null),$(d,null)},[]);return Ne({selector:a?null:c,targetMoved:u,targetLost:m}),o.createElement(o.Fragment,null,o.createElement("div",{ref:l,className:"userflowjs-beacon userflowjs-beacon--pulse userflowjs-beacon--for-flow userflowjs-fixed-widget",style:{zIndex:n+2}},o.createElement("div",{className:"userflowjs-beacon__ring"}),o.createElement("div",{className:"userflowjs-beacon__ring"})),o.createElement(He,{ref:d}))};function Ye({beacon:e,beaconRef:s,clipEl:t,viewportClipRect:n,targetRect:l,theme:d}){if(!s.current||l.width===0||l.height===0)return null;const c=d.beaconSize,u=d.beaconSize,m=ye(t);let i=0,r=0;switch(e.placement){case"top-left":case"left":case"bottom-left":i=l.left;break;case"top":case"center":case"bottom":i=l.left+l.width/2;break;default:i=l.left+l.width;break}switch(e.placement){case"left":case"center":case"right":r=l.top+l.height/2;break;case"bottom-left":case"bottom":case"bottom-right":r=l.top+l.height;break;default:r=l.top;break}i-=c/2,r-=u/2,i+=e.offsetX,r+=e.offsetY,i=Math.max(i,m.left-(t===document.documentElement?0:t.scrollLeft)),r=Math.max(r,m.top-(t===document.documentElement?0:t.scrollTop));const b=i+c,E=r+u,g=Math.min(32,.5*u);let h;E<n.top+g?h="up":r>n.bottom-g?h="down":h=null;const v=h==null;return{top:r,right:b,bottom:E,left:i,width:c,height:u,pointerSubjectPosition:{direction:h,left:i,width:c},visible:v}}function z(e,s){const t=e.current;t&&(t.classList.toggle(We,s!=null),s&&(t.style.transform=`translate3d(${s.left}px, ${s.top}px, 0)`,t.style.visibility=s.visible?"visible":"hidden"))}const Ge=()=>{const{t:e}=x(),s=I(),{restart:t}=A(),{session:n,step:l}=k(),d=l.theme||n.version.theme,a=l.selector,c=!a||a.type===ue.AUTO&&!a.autoData,u=()=>s.endFlow(n,{endReason:D.USER_CLOSED});return o.createElement(o.Fragment,null,o.createElement(G,{draftMode:n.draftMode,close:u}),n.draftMode&&c?o.createElement("div",{className:"userflowjs-bubble-content"},o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"No tooltip target selected yet. Please go back to the Builder and select a tooltip target in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name),".")):n.draftMode&&d.tooltipMissingBehavior===O.END?o.createElement("div",{className:"userflowjs-bubble-content"},o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("p",null,o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name)," was not found within"," ",d.tooltipMissingToleranceSeconds," ",parseFloat(d.tooltipMissingToleranceSeconds)===1?"second":"seconds","."),o.createElement("p",null,"For regular users, the flow will auto-dismiss when this happens."),o.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),o.createElement("p",null,"Read more in our"," ",o.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):o.createElement(o.Fragment,null,o.createElement("div",{className:"userflowjs-bubble-content"},n.draftMode&&o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name)," was not found on the page. If you are on the right page, then try reselecting the element in the Builder."),o.createElement("p",null,o.createElement("b",null,e("tooltipTargetMissing.line1"))),o.createElement("p",null,e("tooltipTargetMissing.line2"))),o.createElement("div",{className:"userflowjs-bubble-buttons"},o.createElement(V,{appearance:"primary",onClick:t,text:e("menu.restart")}),o.createElement(V,{appearance:"default",onClick:u,text:e("menu.close")}))))},C="flowsMuted",Dt=({session:e,checklistSession:s,resourceCenterEmbedsChecklist:t})=>{const n=I(),[l,d]=f.useState(!1),[a,c]=f.useState(null),[u,m]=f.useReducer(Ke,void 0,()=>{const p=e,w=_(p);return{...Xe,session:p,step:w,muted:!!F.getItem(C),autoFocusRequested:te(w)}}),{session:i,step:r,speechPlaying:b,contentType:E}=u,{version:g}=i,h=M(r);let v=0;r.questions.some(p=>p.type===de.NPS)&&(v=420);const T=Be(r.theme||g.theme),S=f.useMemo(()=>{let p=T.bubbleY;const w=s?.version.theme;return!t&&s&&w&&s.version.checklist?.launcherEnabled&&r.appearance===N.BUBBLE&&w.checklistLauncherPlacement===T.bubblePlacement&&(T.avatarType===pe.NONE||w.checklistLauncherX<T.bubbleX+T.avatarSize)&&(p=Math.max(T.bubbleY,w.checklistLauncherY+w.checklistLauncherHeight+T.bubbleY)),{...T,bubbleWidth:Math.max(T.bubbleWidth,v),bubbleY:p}},[t,s,r.appearance,T,v]);f.useEffect(()=>{i!==e&&m({kind:"updateSession",session:e});const p=w=>{w.session.id===i.id&&m({kind:"goToStep",stepId:w.step.id})};return n.on("gotostep",p),()=>{n.off("gotostep",p)}},[n,i,e]);const se=f.useMemo(()=>({dispatch:m,restart:()=>{n.goToStep(i,ee(i)),m({kind:"showFlow"})}}),[n,m,i]),re=f.useMemo(()=>r.selector&&K(r.selector,i.data),[r.selector,i.data]),le=f.useCallback(()=>{he(n,i,r.actions)},[n,i,r.actions]);f.useEffect(()=>{u.muted?F.setItem(C,"true"):F.removeItem(C)},[u.muted]);const P=i.locale?i.locale.standardLocaleId:S.languageId;f.useEffect(()=>{ke.changeLanguage(P)},[P]);const[j,ae]=f.useState(!1),ie=f.useCallback(p=>{ae(p),p&&n.send({kind:"ReportTooltipTargetMissing",sessionId:i.id,stepId:r.id}),p&&S.tooltipMissingBehavior===O.END&&!i.draftMode&&n.endFlow(i,{endReason:D.TOOLTIP_TARGET_MISSING})},[n,i,r.id,S.tooltipMissingBehavior]);return f.useEffect(()=>{if(!l||!u.autoFocusRequested)return;!n.originalActiveElement&&n.originalActiveElement!==a?.ownerDocument.defaultView?.frameElement&&(n.originalActiveElement=document.activeElement);let p=a?.querySelector('button:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), [tabindex]:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), input, textarea');if(p&&p.matches(".userflowjs-bubble-buttons button:not(.userflowjs-bubble-button--primary)")){const w=a?.querySelector(".userflowjs-bubble-buttons .userflowjs-bubble-button--primary");w&&(p=w)}p&&typeof p.focus=="function"&&p.focus({preventScroll:!0}),m({kind:"autoFocused"})},[n,a,l,u.autoFocusRequested]),f.useEffect(()=>{const p=a?.ownerDocument.defaultView;if(!p)return;const w=()=>{m({kind:"focusOut"}),delete n.originalActiveElement},y=()=>{m({kind:"focusIn"})};return window.addEventListener("focusin",w),p.addEventListener("focusin",y),()=>{window.removeEventListener("focusin",w),p.removeEventListener("focusin",y)}},[a,n]),f.useEffect(()=>{if(!h||!a)return;const p=a.ownerDocument.defaultView,w=p?p.document:document,y=R=>{if(R.key==="Escape"&&!g.closeDisabled)n.endFlow(i,{endReason:D.USER_CLOSED});else if(R.key==="Tab"){const B=a.querySelectorAll('button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea'),U=B[0],q=B[B.length-1],H=w.activeElement;R.shiftKey?H===U&&(R.preventDefault(),q.focus()):H===q&&(R.preventDefault(),U.focus())}};return window.addEventListener("keydown",y),p?.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y),p?.removeEventListener("keydown",y)}},[h,n,i,a,g.closeDisabled]),f.useEffect(()=>{if(u.scrollToTopRequested){if(a?.ownerDocument.defaultView?.frameElement){const p=a?.ownerDocument.body;p&&(p.scrollTop=0)}m({kind:"scrolledToTop"})}},[u.scrollToTopRequested,a]),o.createElement(ne.Provider,{value:se},o.createElement(oe.Provider,{value:u},o.createElement(Te.Provider,{value:i},o.createElement(Ie,null,o.createElement(De,{company:i.flow.company,theme:S,position:"fixed",stepKey:r.crossVersionId,stepAppearance:r.appearance,width:r.width,backgroundImageUrl:E==="flow"&&!j&&r.backgroundAsset?r.backgroundAsset.assetUrl:null,tooltipSelector:re,tooltipPlacement:r.tooltipPlacement,backdrop:r.backdrop,tooltipTargetBlocked:r.tooltipTargetBlocked,backdropPadding:r.backdropPadding,onTooltipTargetClick:le,onTooltipTargetMissingChange:ie,onModalBackdropClick:r.appearance===N.MODAL&&S.modalBackdropOnclick===fe.DISMISS&&!g.closeDisabled?()=>n.endFlow(i,{endReason:D.USER_CLOSED}):void 0,speaking:b,minimizeOnAvatarClick:!0,autoHide3pEnabled:!0,onVisibleChange:d,bubbleFrameRootRef:c,rootChildren:p=>o.createElement(Qe,{...p,theme:S})},E==="menu"?o.createElement(Ce,null):j&&S.tooltipMissingBehavior!==O.BUBBLE?o.createElement(Ge,null):o.createElement(Le,{theme:S}))))))},Qe=({visible:e,bubbleFrame:s,theme:t})=>{const n=k(),{step:l}=n,d=n.session.currentStep&&n.session.currentStep.id,[a,c]=f.useState(!1),u=f.useRef(d);return f.useEffect(()=>{e?c(!0):u.current!==d&&c(!1),u.current=d},[d,e]),o.createElement(o.Fragment,null,(e||a)&&n.contentType==="flow"&&o.createElement(o.Fragment,null,o.createElement(_e,{bubbleFrame:s,theme:t}),o.createElement($e,{theme:t})),l.triggers.map(m=>o.createElement(Fe,{key:m.id,trigger:m})))},Xe={muted:!1,speechPlaying:!1,contentType:"flow",autoFocusRequested:!1,hasFocus:!1,scrollToTopRequested:!1,shouldLabelDialog:!0};function Ke(e,s){switch(s.kind){case"updateSession":{let t;return s.session.id===e.session.id?t=s.session.version.steps.find(({crossVersionId:n})=>n===e.step.crossVersionId)||_(s.session):t=_(s.session),{...e,session:s.session,step:t}}case"goToStep":{const t=e.session.version.steps.find(n=>n.id===s.stepId);return t?{...e,step:t,contentType:"flow",autoFocusRequested:e.hasFocus||te(t),scrollToTopRequested:!0,shouldLabelDialog:!e.hasFocus}:e}case"toggleMuted":return{...e,muted:!e.muted};case"speechPlaying":return{...e,speechPlaying:!0};case"speechStopped":return{...e,speechPlaying:!1};case"showFlow":return{...e,contentType:"flow",autoFocusRequested:!0,scrollToTopRequested:!0};case"showMenu":return{...e,contentType:"menu",autoFocusRequested:!0,scrollToTopRequested:!0};case"autoFocused":return{...e,autoFocusRequested:!1};case"focusIn":return{...e,hasFocus:!0};case"focusOut":return{...e,hasFocus:!1};case"scrolledToTop":return{...e,scrollToTopRequested:!1}}}function _(e){const{currentStep:s}=e,{steps:t}=e.version;if(s){const n=t.find(({crossVersionId:l})=>l===s.crossVersionId);if(!n)throw new Y("Session points to an unknown step: "+s.crossVersionId);return n}else return ee(e)}function ee(e){const s=e.version.steps[0];if(!s)throw new Y("Session has no current step and its version has no start step");return s}function te(e){return M(e)}function M(e){return e.appearance===N.MODAL||e.appearance===N.BUBBLE&&e.backdrop||e.appearance===N.TOOLTIP&&e.tooltipTargetBlocked}const ne=f.createContext(null),oe=f.createContext(null);function A(){return f.useContext(ne)}function k(){return f.useContext(oe)}export{Dt as FlowApp,oe as FlowStateContext,Dt as default,Xe as initialFlowState,M as isStepModal,A as useFlowDispatch,k as useFlowState};
5
+ `));break}}function a(c){c.forEach(u=>d(u))}return a(e.children),t.join("").trim().replace(new RegExp(" ","g")," ").replace(new RegExp("\b","g"),"")}const _e=({bubbleFrame:e,theme:s})=>{const t=R(),{dispatch:n}=A(),{muted:l,session:d,step:a}=k(),c=t.getAudio();f.useEffect(()=>{const r=()=>{n({kind:"speechPlaying"})},b=()=>{n({kind:"speechStopped"})};return c.addEventListener("playing",r),c.addEventListener("ended",b),c.addEventListener("pause",b),()=>{c.removeEventListener("playing",r),c.removeEventListener("ended",b),c.removeEventListener("pause",b),c.pause(),c.src="",n({kind:"speechStopped"})}},[n,c]),f.useEffect(()=>{if(t.audioReady)return;const r=e&&Pe(e)?e.contentWindow:null,b=()=>{window.removeEventListener("mousedown",E),r&&r.removeEventListener("mousedown",E)},E=()=>{b(),t.playAudio(null)};return window.addEventListener("mousedown",E),r&&r.addEventListener("mousedown",E),b},[e,t]);const u=f.useRef(d),m=f.useRef(s),i=f.useRef(a);return f.useEffect(()=>{u.current=d,m.current=s,i.current=a},[d,s,a]),f.useEffect(()=>{if(!t.audioReady||l){t.pauseAudio();return}let r=!1;return(async()=>{if(await new Promise(g=>setTimeout(g,1)),r)return;const E=await xe(t,u.current,m.current,i.current);r||E&&t.playAudio(E)})(),()=>{r=!0}},[l,t,a.id,s.voiceType,s.syntheticVoice]),null};async function xe(e,s,t,n){if(t.voiceType===L.SYNTHETIC&&typeof t.syntheticVoice=="string"&&n.content){e.ensureIdentified();const l=X(s.data),d=Oe(n.content,l);return e.getStepSpeech(t.syntheticVoice,d)}else if(t.voiceType===L.MANUAL&&n.speechAsset)return n.speechAsset.assetUrl;return null}function Pe(e){return e.tagName==="IFRAME"}const je="userflowjs-out-of-viewport-pointer--visible",Ue="userflowjs-out-of-viewport-pointer--visible-up",qe="userflowjs-out-of-viewport-pointer--visible-down",He=o.forwardRef((e,s)=>{const t=Z();return o.createElement("div",{ref:s,className:"userflowjs-out-of-viewport-pointer",style:{zIndex:t+2}},o.createElement(Ae,{icon:Me}))});function Ve({subjectPosition:e,pointerRef:s,viewportClipRect:t}){const n=s.current;if(!n)return null;const l=n.getBoundingClientRect(),d=ve(Se());let a=e.direction,c,u;return a==null?null:(a==="down"&&t.bottom<l.height/2?a="up":a==="up"&&t.top>d&&(a="down"),c=e.left+e.width/2-l.width/2,u=a==="down"?t.bottom-l.height:t.top,{direction:a,left:c,top:u})}function $(e,s){const t=e.current;t&&(t.classList.toggle(je,s!=null),s&&(t.style.left=s.left+"px",t.style.top=s.top+"px",t.classList.toggle(Ue,s.direction==="up"),t.classList.toggle(qe,s.direction==="down")))}const We="userflowjs-fixed-widget--visible",$e=({theme:e})=>{const{step:s}=k();return o.createElement(o.Fragment,null,s.beacons.map(t=>o.createElement(ze,{key:t.id,beacon:t,theme:e})))},ze=({beacon:e,theme:s})=>{const{session:t}=k(),n=Z(),l=f.useRef(null),d=f.useRef(null),a=we(e.hiddenCondition),c=f.useMemo(()=>K(e.selector,t.data),[e.selector,t.data]),u=f.useCallback(({targetRect:i,clipEl:r,viewportClipRect:b})=>{const E=Ye({beacon:e,beaconRef:l,clipEl:r,viewportClipRect:b,targetRect:i,theme:s}),g=E&&Ve({subjectPosition:E.pointerSubjectPosition,pointerRef:d,viewportClipRect:b});Ie(()=>{z(l,E),$(d,g)})},[e]),m=f.useCallback(()=>{z(l,null),$(d,null)},[]);return Ne({selector:a?null:c,targetMoved:u,targetLost:m}),o.createElement(o.Fragment,null,o.createElement("div",{ref:l,className:"userflowjs-beacon userflowjs-beacon--pulse userflowjs-beacon--for-flow userflowjs-fixed-widget",style:{zIndex:n+2}},o.createElement("div",{className:"userflowjs-beacon__ring"}),o.createElement("div",{className:"userflowjs-beacon__ring"})),o.createElement(He,{ref:d}))};function Ye({beacon:e,beaconRef:s,clipEl:t,viewportClipRect:n,targetRect:l,theme:d}){if(!s.current||l.width===0||l.height===0)return null;const c=d.beaconSize,u=d.beaconSize,m=ye(t);let i=0,r=0;switch(e.placement){case"top-left":case"left":case"bottom-left":i=l.left;break;case"top":case"center":case"bottom":i=l.left+l.width/2;break;default:i=l.left+l.width;break}switch(e.placement){case"left":case"center":case"right":r=l.top+l.height/2;break;case"bottom-left":case"bottom":case"bottom-right":r=l.top+l.height;break;default:r=l.top;break}i-=c/2,r-=u/2,i+=e.offsetX,r+=e.offsetY,i=Math.max(i,m.left-(t===document.documentElement?0:t.scrollLeft)),r=Math.max(r,m.top-(t===document.documentElement?0:t.scrollTop));const b=i+c,E=r+u,g=Math.min(32,.5*u);let h;E<n.top+g?h="up":r>n.bottom-g?h="down":h=null;const v=h==null;return{top:r,right:b,bottom:E,left:i,width:c,height:u,pointerSubjectPosition:{direction:h,left:i,width:c},visible:v}}function z(e,s){const t=e.current;t&&(t.classList.toggle(We,s!=null),s&&(t.style.transform=`translate3d(${s.left}px, ${s.top}px, 0)`,t.style.visibility=s.visible?"visible":"hidden"))}const Ge=()=>{const{t:e}=x(),s=R(),{restart:t}=A(),{session:n,step:l}=k(),d=l.theme||n.version.theme,a=l.selector,c=!a||a.type===ue.AUTO&&!a.autoData,u=()=>s.endFlow(n,{endReason:D.USER_CLOSED});return o.createElement(o.Fragment,null,o.createElement(G,{draftMode:n.draftMode,close:u}),n.draftMode&&c?o.createElement("div",{className:"userflowjs-bubble-content"},o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"No tooltip target selected yet. Please go back to the Builder and select a tooltip target in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name),".")):n.draftMode&&d.tooltipMissingBehavior===O.END?o.createElement("div",{className:"userflowjs-bubble-content"},o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("p",null,o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name)," was not found within"," ",d.tooltipMissingToleranceSeconds," ",parseFloat(d.tooltipMissingToleranceSeconds)===1?"second":"seconds","."),o.createElement("p",null,"For regular users, the flow will auto-dismiss when this happens."),o.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),o.createElement("p",null,"Read more in our"," ",o.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):o.createElement(o.Fragment,null,o.createElement("div",{className:"userflowjs-bubble-content"},n.draftMode&&o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name)," was not found on the page. If you are on the right page, then try reselecting the element in the Builder."),o.createElement("p",null,o.createElement("b",null,e("tooltipTargetMissing.line1"))),o.createElement("p",null,e("tooltipTargetMissing.line2"))),o.createElement("div",{className:"userflowjs-bubble-buttons"},o.createElement(V,{appearance:"primary",onClick:t,text:e("menu.restart")}),o.createElement(V,{appearance:"default",onClick:u,text:e("menu.close")}))))},C="flowsMuted",Dt=({session:e,checklistSession:s,resourceCenterEmbedsChecklist:t})=>{const n=R(),[l,d]=f.useState(!1),[a,c]=f.useState(null),[u,m]=f.useReducer(Ke,void 0,()=>{const p=e,w=_(p);return{...Xe,session:p,step:w,muted:!!F.getItem(C),autoFocusRequested:te(w)}}),{session:i,step:r,speechPlaying:b,contentType:E}=u,{version:g}=i,h=M(r);let v=0;r.questions.some(p=>p.type===de.NPS)&&(v=420);const T=Be(r.theme||g.theme),S=f.useMemo(()=>{let p=T.bubbleY;const w=s?.version.theme;return!t&&s&&w&&s.version.checklist?.launcherEnabled&&r.appearance===N.BUBBLE&&w.checklistLauncherPlacement===T.bubblePlacement&&(T.avatarType===pe.NONE||w.checklistLauncherX<T.bubbleX+T.avatarSize)&&(p=Math.max(T.bubbleY,w.checklistLauncherY+w.checklistLauncherHeight+T.bubbleY)),{...T,bubbleWidth:Math.max(T.bubbleWidth,v),bubbleY:p}},[t,s,r.appearance,T,v]);f.useEffect(()=>{i!==e&&m({kind:"updateSession",session:e});const p=w=>{w.session.id===i.id&&m({kind:"goToStep",stepId:w.step.id})};return n.on("gotostep",p),()=>{n.off("gotostep",p)}},[n,i,e]);const se=f.useMemo(()=>({dispatch:m,restart:()=>{n.goToStep(i,ee(i)),m({kind:"showFlow"})}}),[n,m,i]),re=f.useMemo(()=>r.selector&&K(r.selector,i.data),[r.selector,i.data]),le=f.useCallback(()=>{he(n,i,r.actions)},[n,i,r.actions]);f.useEffect(()=>{u.muted?F.setItem(C,"true"):F.removeItem(C)},[u.muted]);const P=i.locale?i.locale.standardLocaleId:S.languageId;f.useEffect(()=>{ke.changeLanguage(P)},[P]);const[j,ae]=f.useState(!1),ie=f.useCallback(p=>{ae(p),p&&n.send({kind:"ReportTooltipTargetMissing",sessionId:i.id,stepId:r.id}),p&&S.tooltipMissingBehavior===O.END&&!i.draftMode&&n.endFlow(i,{endReason:D.TOOLTIP_TARGET_MISSING})},[n,i,r.id,S.tooltipMissingBehavior]);return f.useEffect(()=>{if(!l||!u.autoFocusRequested)return;!n.originalActiveElement&&n.originalActiveElement!==a?.ownerDocument.defaultView?.frameElement&&(n.originalActiveElement=document.activeElement);let p=a?.querySelector('button:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), [tabindex]:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), input, textarea');if(p&&p.matches(".userflowjs-bubble-buttons button:not(.userflowjs-bubble-button--primary)")){const w=a?.querySelector(".userflowjs-bubble-buttons .userflowjs-bubble-button--primary");w&&(p=w)}p&&typeof p.focus=="function"&&p.focus({preventScroll:!0}),m({kind:"autoFocused"})},[n,a,l,u.autoFocusRequested]),f.useEffect(()=>{const p=a?.ownerDocument.defaultView;if(!p)return;const w=()=>{m({kind:"focusOut"}),delete n.originalActiveElement},y=()=>{m({kind:"focusIn"})};return window.addEventListener("focusin",w),p.addEventListener("focusin",y),()=>{window.removeEventListener("focusin",w),p.removeEventListener("focusin",y)}},[a,n]),f.useEffect(()=>{if(!h||!a)return;const p=a.ownerDocument.defaultView,w=p?p.document:document,y=I=>{if(I.key==="Escape"&&!g.closeDisabled)n.endFlow(i,{endReason:D.USER_CLOSED});else if(I.key==="Tab"){const B=a.querySelectorAll('button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea'),U=B[0],q=B[B.length-1],H=w.activeElement;I.shiftKey?H===U&&(I.preventDefault(),q.focus()):H===q&&(I.preventDefault(),U.focus())}};return window.addEventListener("keydown",y),p?.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y),p?.removeEventListener("keydown",y)}},[h,n,i,a,g.closeDisabled]),f.useEffect(()=>{if(u.scrollToTopRequested){if(a?.ownerDocument.defaultView?.frameElement){const p=a?.ownerDocument.body;p&&(p.scrollTop=0)}m({kind:"scrolledToTop"})}},[u.scrollToTopRequested,a]),o.createElement(ne.Provider,{value:se},o.createElement(oe.Provider,{value:u},o.createElement(Te.Provider,{value:i},o.createElement(Re,null,o.createElement(De,{company:i.flow.company,theme:S,position:"fixed",stepKey:r.crossVersionId,stepAppearance:r.appearance,width:r.width,backgroundImageUrl:E==="flow"&&!j&&r.backgroundAsset?r.backgroundAsset.assetUrl:null,tooltipSelector:re,tooltipPlacement:r.tooltipPlacement,backdrop:r.backdrop,tooltipTargetBlocked:r.tooltipTargetBlocked,backdropPadding:r.backdropPadding,onTooltipTargetClick:le,onTooltipTargetMissingChange:ie,onModalBackdropClick:r.appearance===N.MODAL&&S.modalBackdropOnclick===fe.DISMISS&&!g.closeDisabled?()=>n.endFlow(i,{endReason:D.USER_CLOSED}):void 0,speaking:b,minimizeOnAvatarClick:!0,autoHide3pEnabled:!0,onVisibleChange:d,bubbleFrameRootRef:c,rootChildren:p=>o.createElement(Qe,{...p,theme:S})},E==="menu"?o.createElement(Ce,null):j&&S.tooltipMissingBehavior!==O.BUBBLE?o.createElement(Ge,null):o.createElement(Le,{theme:S}))))))},Qe=({visible:e,bubbleFrame:s,theme:t})=>{const n=k(),{step:l}=n,d=n.session.currentStep&&n.session.currentStep.id,[a,c]=f.useState(!1),u=f.useRef(d);return f.useEffect(()=>{e?c(!0):u.current!==d&&c(!1),u.current=d},[d,e]),o.createElement(o.Fragment,null,(e||a)&&n.contentType==="flow"&&o.createElement(o.Fragment,null,o.createElement(_e,{bubbleFrame:s,theme:t}),o.createElement($e,{theme:t})),l.triggers.map(m=>o.createElement(Fe,{key:m.id,trigger:m})))},Xe={muted:!1,speechPlaying:!1,contentType:"flow",autoFocusRequested:!1,hasFocus:!1,scrollToTopRequested:!1,shouldLabelDialog:!0};function Ke(e,s){switch(s.kind){case"updateSession":{let t;return s.session.id===e.session.id?t=s.session.version.steps.find(({crossVersionId:n})=>n===e.step.crossVersionId)||_(s.session):t=_(s.session),{...e,session:s.session,step:t}}case"goToStep":{const t=e.session.version.steps.find(n=>n.id===s.stepId);return t?{...e,step:t,contentType:"flow",autoFocusRequested:e.hasFocus||te(t),scrollToTopRequested:!0,shouldLabelDialog:!e.hasFocus}:e}case"toggleMuted":return{...e,muted:!e.muted};case"speechPlaying":return{...e,speechPlaying:!0};case"speechStopped":return{...e,speechPlaying:!1};case"showFlow":return{...e,contentType:"flow",autoFocusRequested:!0,scrollToTopRequested:!0};case"showMenu":return{...e,contentType:"menu",autoFocusRequested:!0,scrollToTopRequested:!0};case"autoFocused":return{...e,autoFocusRequested:!1};case"focusIn":return{...e,hasFocus:!0};case"focusOut":return{...e,hasFocus:!1};case"scrolledToTop":return{...e,scrollToTopRequested:!1}}}function _(e){const{currentStep:s}=e,{steps:t}=e.version;if(s){const n=t.find(({crossVersionId:l})=>l===s.crossVersionId);if(!n)throw new Y("Session points to an unknown step: "+s.crossVersionId);return n}else return ee(e)}function ee(e){const s=e.version.steps[0];if(!s)throw new Y("Session has no current step and its version has no start step");return s}function te(e){return M(e)}function M(e){return e.appearance===N.MODAL||e.appearance===N.BUBBLE&&e.backdrop||e.appearance===N.TOOLTIP&&e.tooltipTargetBlocked}const ne=f.createContext(null),oe=f.createContext(null);function A(){return f.useContext(ne)}function k(){return f.useContext(oe)}export{Dt as FlowApp,oe as FlowStateContext,Dt as default,Xe as initialFlowState,M as isStepModal,A as useFlowDispatch,k as useFlowState};
6
6
  //# sourceMappingURL=FlowApp.js.map
package/hash.txt CHANGED
@@ -1 +1 @@
1
- 7a06dcb5dfd59a5ab1ca2e0618ad686571e4519f
1
+ a96fb2e889e725c84fc3098d3125c173e9a2f987
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1008453",
3
+ "version": "0.1.1008499",
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.html-parse-stringify2.js","vendor.object-assign.js","client-context.js","vendor.i18next.js","vendor.react-i18next.js","vendor.babel.runtime.js","flow-host.styl.js","bubble-frame.styl.js","flow-condition-types.js","vendor.date-fns.js","stylesheets.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.fortawesome.pro-solid-svg-icons.js","vendor.obj-str.js","use-window-resize.js","vendor.react-dom.js","vendor.scheduler.js","logomark.js","ChecklistUI.js","BubbleToolbar.js","use-element-rect.js","BannerApp.js","use-selector-element-monitoring.js","vendor.phoenix.js","vendor.uuid.js","ui.js"])))=>i.map(i=>d[i]);
2
2
  import"./vendor.html-parse-stringify2.js";import{S as K}from"./vendor.phoenix.js";import{v as j}from"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="4b9ab4f1-fdd7-4380-aeb6-f2720eaf2113",t._sentryDebugIdIdentifier="sentry-dbid-4b9ab4f1-fdd7-4380-aeb6-f2720eaf2113")}catch{}})();const z="modulepreload",Y=function(t){return"https://js.userflow.com/es2020/"+t},v={},w=function(e,s,i){let n=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),u=a?.nonce||a?.getAttribute("nonce");n=Promise.allSettled(s.map(c=>{if(c=Y(c),c in v)return;v[c]=!0;const h=c.endsWith(".css"),T=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${T}`))return;const E=document.createElement("link");if(E.rel=h?"stylesheet":z,h||(E.as="script"),E.crossOrigin="",E.href=c,u&&E.setAttribute("nonce",u),document.head.appendChild(E),h)return new Promise((F,V)=>{E.addEventListener("load",F),E.addEventListener("error",()=>V(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=a,window.dispatchEvent(u),!u.defaultPrevented)throw a}return n.then(a=>{for(const u of a||[])u.status==="rejected"&&r(u.reason);return e().catch(r)})};class l extends Error{constructor(e,s,i){super(e),Object.setPrototypeOf(this,l.prototype),this.name="UserflowError",this.code=s,this.humanMessage=i}}class B{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}isSupported(){if(typeof window>"u")return!1;try{return window[this.type]!=null}catch{return!1}}getItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].getItem(e):null}setItem(e,s){e=this.formatKey(e);{if(!this.isSupported())return;window[this.type].setItem(e,s)}}removeItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].removeItem(e):void 0}clear(){return this.isSupported()?window[this.type].clear():void 0}}const g=new B("localStorage"),f=new B("sessionStorage");function je(t){window.location.href=t}function P(){return window.location.href}function U(t){window.postMessage(t,window.origin)}function x(t){const e=i=>{if(i.source!==window||i.origin!==window.origin)return;const n=i.data;!n||typeof n!="object"||typeof n.kind!="string"||!n.kind.startsWith("userflow:")||t(n)===!0&&s()};window.addEventListener("message",e);const s=()=>window.removeEventListener("message",e);return s}function J(t){return new Promise(e=>{x(s=>{const i=t(s);return i?(e(i),!0):!1})})}const A=new Set;let _=!1;function X(t){return Z(),A.add(t),()=>{H(t)}}function H(t){A.delete(t)}function I(){A.forEach(t=>t())}function Z(){if(_)return;_=!0;const{history:t}=window,e=s=>{const i=t[s];t[s]=(...n)=>{const r=i.apply(t,n);return I(),r}};window.__userflowStatePatched?(window.addEventListener("userflow:pushstate",()=>{I()}),window.addEventListener("userflow:replacestate",()=>{I()})):(e("pushState"),e("replaceState")),window.addEventListener("popstate",()=>{I()})}class q{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){U({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=x(e),!1}async captureScreenshot(e,s,i,n){return U({kind:"userflow:crxScreenshot",x:e,y:s,width:i,height:n,devicePixelRatio:window.devicePixelRatio}),(await J(a=>a.kind==="userflow:crxScreenshotResult"?a:null)).imageDataUrl}}var C=(t=>(t.ACTION="ACTION",t.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",t.REPLACED="REPLACED",t.SNOOZED="SNOOZED",t.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",t.USERFLOWJS="USERFLOWJS",t.USER_CLOSED="USER_CLOSED",t))(C||{}),m=(t=>(t.ACTION="ACTION",t.DRAFT="DRAFT",t.LINK="LINK",t.LAUNCHER_SEEN="LAUNCHER_SEEN",t.RESOURCE_CENTER="RESOURCE_CENTER",t.USERFLOWJS="USERFLOWJS",t))(m||{}),Q=(t=>(t.LIKE="LIKE",t.DISLIKE="DISLIKE",t))(Q||{}),S=(t=>(t.STRING="STRING",t.BOOLEAN="BOOLEAN",t.NUMBER="NUMBER",t.DATETIME="DATETIME",t.LIST="LIST",t.RANDOM_AB="RANDOM_AB",t.RANDOM_NUMBER="RANDOM_NUMBER",t))(S||{}),k=(t=>(t.FLOW="FLOW",t.BANNER="BANNER",t.CHECKLIST="CHECKLIST",t.LAUNCHER="LAUNCHER",t.RESOURCE_CENTER="RESOURCE_CENTER",t))(k||{}),ee=(t=>(t.ALWAYS_TRUE="ALWAYS_TRUE",t.ATTRIBUTE="ATTRIBUTE",t.CLAUSE="CLAUSE",t.ELEMENT="ELEMENT",t.FILLED_IN_INPUT="FILLED_IN_INPUT",t.FLOW="FLOW",t.INPUT_VALUE="INPUT_VALUE",t.PAGE="PAGE",t.SEGMENT="SEGMENT",t.TIME="TIME",t))(ee||{}),te=(t=>(t.AUTO="AUTO",t.MANUAL="MANUAL",t))(te||{}),se=(t=>(t.INPUT="INPUT",t))(se||{}),ie=(t=>(t.ABSOLUTE_EQ="ABSOLUTE_EQ",t.ABSOLUTE_GT="ABSOLUTE_GT",t.ABSOLUTE_LT="ABSOLUTE_LT",t.AND="AND",t.BETWEEN="BETWEEN",t.CONTAINS="CONTAINS",t.EMPTY="EMPTY",t.ENDS_WITH="ENDS_WITH",t.EQ="EQ",t.EXCLUDES_ALL="EXCLUDES_ALL",t.EXCLUDES_ANY="EXCLUDES_ANY",t.FALSE="FALSE",t.GT="GT",t.GTE="GTE",t.INCLUDES_ALL="INCLUDES_ALL",t.INCLUDES_ANY="INCLUDES_ANY",t.LT="LT",t.LTE="LTE",t.NE="NE",t.NOT_CONTAINS="NOT_CONTAINS",t.NOT_EMPTY="NOT_EMPTY",t.NOT_REGEX="NOT_REGEX",t.OR="OR",t.REGEX="REGEX",t.RELATIVE_EQ="RELATIVE_EQ",t.RELATIVE_GT="RELATIVE_GT",t.RELATIVE_LT="RELATIVE_LT",t.STARTS_WITH="STARTS_WITH",t.TRUE="TRUE",t.URL="URL",t))(ie||{}),ne=(t=>(t.CLICK="CLICK",t.DISABLED="DISABLED",t.MOUSEDOWN="MOUSEDOWN",t.NOT_CLICK="NOT_CLICK",t.NOT_DISABLED="NOT_DISABLED",t.NOT_PRESENT="NOT_PRESENT",t.PRESENT="PRESENT",t))(ne||{}),re=(t=>(t.ASSET="ASSET",t.CARTOON="CARTOON",t.NONE="NONE",t.URL="URL",t))(re||{}),oe=(t=>(t.INSIDE="INSIDE",t.OUTSIDE="OUTSIDE",t))(oe||{}),ae=(t=>(t.TOP_LEFT="TOP_LEFT",t.TOP_CENTER="TOP_CENTER",t.TOP_RIGHT="TOP_RIGHT",t.BOTTOM_RIGHT="BOTTOM_RIGHT",t.BOTTOM_CENTER="BOTTOM_CENTER",t.BOTTOM_LEFT="BOTTOM_LEFT",t.CENTER="CENTER",t))(ae||{}),ce=(t=>(t.GOOGLE="GOOGLE",t.STANDARD="STANDARD",t))(ce||{}),le=(t=>(t.DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",t.DISMISS="DISMISS",t))(le||{}),ue=(t=>(t.DISMISS="DISMISS",t.NONE="NONE",t))(ue||{}),he=(t=>(t.DEFAULT="DEFAULT",t.PLAINTEXT="PLAINTEXT",t.CUSTOM="CUSTOM",t))(he||{}),de=(t=>(t.CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",t.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",t.NONE="NONE",t))(de||{}),fe=(t=>(t.BUBBLE="BUBBLE",t.END="END",t.ERROR="ERROR",t.FLAG="FLAG",t))(fe||{}),Ee=(t=>(t.MANUAL="MANUAL",t.NONE="NONE",t.SYNTHETIC="SYNTHETIC",t))(Ee||{}),Se=(t=>(t.BUBBLE="BUBBLE",t.HIDDEN="HIDDEN",t.MODAL="MODAL",t.TOOLTIP="TOOLTIP",t))(Se||{}),Te=(t=>(t.ABOVE="ABOVE",t.BELOW="BELOW",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(Te||{}),we=(t=>(t.CLOSE_FLOW="CLOSE_FLOW",t.EVAL_JS="EVAL_JS",t.GO_TO_STEP="GO_TO_STEP",t.NAVIGATE="NAVIGATE",t.SET_ATTRIBUTE="SET_ATTRIBUTE",t.SNOOZE="SNOOZE",t.START_FLOW="START_FLOW",t))(we||{}),ge=(t=>(t.NEW_TAB="NEW_TAB",t.SAME_TAB="SAME_TAB",t))(ge||{}),Ie=(t=>(t.SET="SET",t.SET_DATETIME="SET_DATETIME",t.SET_DATETIME_ONCE="SET_DATETIME_ONCE",t.SET_ONCE="SET_ONCE",t.ADD="ADD",t.SUBTRACT="SUBTRACT",t.APPEND="APPEND",t.PREPEND="PREPEND",t.REMOVE="REMOVE",t.UNSET="UNSET",t))(Ie||{}),Ce=(t=>(t.MULTILINE_TEXT="MULTILINE_TEXT",t.MULTIPLE_CHOICE="MULTIPLE_CHOICE",t.NPS="NPS",t.SCALE="SCALE",t.STARS="STARS",t.TEXT="TEXT",t))(Ce||{}),L=(t=>(t.ACTION="ACTION",t.ANNOUNCEMENTS="ANNOUNCEMENTS",t.ASSISTANT="ASSISTANT",t.CHECKLIST="CHECKLIST",t.CONTACT="CONTACT",t.DIVIDER="DIVIDER",t.FLOWS="FLOWS",t.KNOWLEDGE_BASE="KNOWLEDGE_BASE",t.MESSAGE="MESSAGE",t.SUBPAGE="SUBPAGE",t))(L||{}),ke=(t=>(t.CRISP="CRISP",t.CUSTOM="CUSTOM",t.FRESHCHAT="FRESHCHAT",t.HELPSCOUT="HELPSCOUT",t.HUBSPOT="HUBSPOT",t.INTERCOM="INTERCOM",t.ZENDESK="ZENDESK",t.ZENDESK_MESSENGER="ZENDESK_MESSENGER",t))(ke||{}),me=(t=>(t.BUTTON="BUTTON",t.INPUT="INPUT",t))(me||{}),pe=(t=>(t.EMAIL="EMAIL",t.PHONE="PHONE",t.CHAT="CHAT",t))(pe||{}),Ue=(t=>(t.SILENT="SILENT",t.BADGE="BADGE",t.POPOUT="POPOUT",t))(Ue||{}),Le=(t=>(t.LAUNCHER_CLICK="LAUNCHER_CLICK",t.LAUNCHER_HOVER="LAUNCHER_HOVER",t.TARGET_CLICK="TARGET_CLICK",t.TARGET_HOVER="TARGET_HOVER",t.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",t.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",t))(Le||{}),G=(t=>(t.ACTIVATE="ACTIVATE",t.DEACTIVATE="DEACTIVATE",t.NEVER="NEVER",t))(G||{}),Ae=(t=>(t.AUTO="AUTO",t.TOP="TOP",t.RIGHT="RIGHT",t.BOTTOM="BOTTOM",t.LEFT="LEFT",t))(Ae||{}),Ne=(t=>(t.START="START",t.CENTER="CENTER",t.END="END",t))(Ne||{}),ve=(t=>(t.PERCENT="PERCENT",t.PX="PX",t))(ve||{}),_e=(t=>(t.BEACON="BEACON",t.BUTTON="BUTTON",t.HIDDEN="HIDDEN",t.ICON="ICON",t))(_e||{}),Re=(t=>(t.LAUNCHER="LAUNCHER",t.TARGET="TARGET",t))(Re||{}),ye=(t=>(t.BODY_FIRST="BODY_FIRST",t.BODY_LAST="BODY_LAST",t.ELEMENT_FIRST="ELEMENT_FIRST",t.ELEMENT_LAST="ELEMENT_LAST",t.ELEMENT_BEFORE="ELEMENT_BEFORE",t.ELEMENT_AFTER="ELEMENT_AFTER",t))(ye||{}),Oe=(t=>(t.NONE="NONE",t.LIKE="LIKE",t.SCALE="SCALE",t))(Oe||{});function be(){return{customInputs:[],customNavigate:null,urlFilter:null,linkUrlDecorator:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[t=>!t.match(/\d$/)],"data-id":[t=>!t.match(/\d$/)]},inferenceClassNameFilters:[t=>!t.startsWith("css-")],baseZIndex:1234500,evalJsDisabled:!1}}const d=be();function R(t){return Array.isArray(t)||(t=t?[t]:[]),t=t.map(e=>typeof e=="string"?new RegExp(e):e),t}function ze(t,e){return t.every(s=>typeof s=="function"?s(e):s instanceof RegExp?s.test(e):!0)}function De(){let t=P();if(d.urlFilter){if(t=d.urlFilter(t),typeof t!="string")throw new l("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(t)}catch(e){throw new l(`Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.
3
3
  Returned URL: `+t+`
4
- Error message: `+e.message)}}return t}let W="";try{W=localStorage.getItem("debug")||""}catch{}const $=W.split(",").some(t=>t==="*"||t.startsWith("userflow:*")),o=N("log");o.group=N("group");o.groupCollapsed=N("groupCollapsed");o.groupEnd=function(){$&&console.groupEnd()};let p;function N(t){return function(e,...s){if($){const i=performance.now(),n=p?Math.round(i-p):0;p=i,console[t](`%cuserflow %c${e} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const Me=()=>w(()=>import("./ResourceCenterApp.js").then(t=>t.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));function Be(t){const s=t.version.checklist.tasks.length;return Math.max(0,s-t.taskCompletions.length)}class y{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const s of this.observers)s()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const O=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],Pe=()=>w(()=>import("./BannerApp.js"),__vite__mapDeps([23,1,2,3,4,5,6,7,15,12,13,14,10,11,9,8,24,17,18,16,22,25,26])),b="1008453",xe=import.meta.url,D=50,He=5*60*1e3,M="userflowClientState";class Ge{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.featureFlags=new Set,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{o(`builder ${e.kind} message received`,e);const s="idempotencyKey"in e&&typeof e.idempotencyKey=="string"?e.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const i=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(e.kind){case"userflow:selectElement":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),f.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),e.testStartCondition?this.setSessionStorageState(n=>({...n,activeApp:"startConditionTesting",testStartConditionToken:e.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const n=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",n))};this.on("resourceCenterChanged",n),n()}});return}case"userflow:testTracker":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0})),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),this.setSessionStorageState(n=>({...n,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),D))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+b),X(this.onUrlChange),this.setTargetEnv(new q),this.checkTestUserAtBoot(),this.toggleUI();for(const e of O)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),H(this.onUrlChange),this.destroyTargetEnv();for(const e of O)document.removeEventListener(e,this.remountIfNecessary)}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new l("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const s=e(this.getSessionStorageState());f.setItem(M,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=f.getItem(M);if(s)try{e=JSON.parse(s)}catch(i){console.error("Userflow.js: Parse ElementSelectionState error:",i)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState(n=>({...n,testUser:e})),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const s=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:i}=e;i&&(this.groupId=i.id,s.push(this.group(i.id,{name:i.name},{signature:i.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(e=>({...e,testUser:null}))}init(e){if(o("init",e),!e)throw new l("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==e){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=e}}ensureInit(){if(!this.clientToken)throw new l("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new l("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new l("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");let e=d.serverEndpoint||"e.userflow.com";new URL(xe).hostname==="js.getuserflow.com"&&e==="e.userflow.com"&&(e="e.getuserflow.com");const s="wss://"+e+"/end-users/"+this.clientToken+"/socket";this.socket=new K(s,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected")}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
4
+ Error message: `+e.message)}}return t}let W="";try{W=localStorage.getItem("debug")||""}catch{}const $=W.split(",").some(t=>t==="*"||t.startsWith("userflow:*")),o=N("log");o.group=N("group");o.groupCollapsed=N("groupCollapsed");o.groupEnd=function(){$&&console.groupEnd()};let p;function N(t){return function(e,...s){if($){const i=performance.now(),n=p?Math.round(i-p):0;p=i,console[t](`%cuserflow %c${e} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const Me=()=>w(()=>import("./ResourceCenterApp.js").then(t=>t.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));function Be(t){const s=t.version.checklist.tasks.length;return Math.max(0,s-t.taskCompletions.length)}class y{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const s of this.observers)s()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const O=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],Pe=()=>w(()=>import("./BannerApp.js"),__vite__mapDeps([23,1,2,3,4,5,6,7,15,12,13,14,10,11,9,8,24,17,18,16,22,25,26])),b="1008499",xe=import.meta.url,D=50,He=5*60*1e3,M="userflowClientState";class Ge{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.featureFlags=new Set,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{o(`builder ${e.kind} message received`,e);const s="idempotencyKey"in e&&typeof e.idempotencyKey=="string"?e.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const i=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(e.kind){case"userflow:selectElement":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),f.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),e.testStartCondition?this.setSessionStorageState(n=>({...n,activeApp:"startConditionTesting",testStartConditionToken:e.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const n=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",n))};this.on("resourceCenterChanged",n),n()}});return}case"userflow:testTracker":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0})),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),this.setSessionStorageState(n=>({...n,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),D))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+b),X(this.onUrlChange),this.setTargetEnv(new q),this.checkTestUserAtBoot(),this.toggleUI();for(const e of O)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),H(this.onUrlChange),this.destroyTargetEnv();for(const e of O)document.removeEventListener(e,this.remountIfNecessary)}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new l("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const s=e(this.getSessionStorageState());f.setItem(M,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=f.getItem(M);if(s)try{e=JSON.parse(s)}catch(i){console.error("Userflow.js: Parse ElementSelectionState error:",i)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState(n=>({...n,testUser:e})),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const s=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:i}=e;i&&(this.groupId=i.id,s.push(this.group(i.id,{name:i.name},{signature:i.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(e=>({...e,testUser:null}))}init(e){if(o("init",e),!e)throw new l("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==e){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=e}}ensureInit(){if(!this.clientToken)throw new l("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new l("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new l("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");let e=d.serverEndpoint||"e.userflow.com";new URL(xe).hostname==="js.getuserflow.com"&&e==="e.userflow.com"&&(e="e.getuserflow.com");const s="wss://"+e+"/end-users/"+this.clientToken+"/socket";this.socket=new K(s,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected")}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
5
5
  Details:
6
6
  `+i.details.map(n=>(n.path?`${n.path}: `:"")+n.message):""))})}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const s={protocolVersion:2,userflowClientBuild:b,signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,bannerSessionId:this.bannerSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map(i=>({flowId:i.flow.id})),trackers:Array.from(this.trackers.values()).map(i=>({flowId:i.tracker.flowId})),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map(i=>({conditionId:i.condition.id,isTrue:i.isTrue})),previewFlowId:f.getItem("previewFlowId"),clientContext:e};return o("channel join payload",s),s}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout(()=>{if(this.hasDraftSession()||this.assistantMessageInProgress){this.debounceInactiveDisconnect();return}o("disconnecting from socket due to inactivity"),this.disconnect()},He)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some(e=>e.draftMode)}async send(e,{batch:s,endBatch:i,handlesRejection:n}={}){return(!this.inBatch||!["ToggleClientCondition","UpdateClientContext"].includes(e.kind))&&this.checkPushRateLimit(),this.ensureConnected(),s&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),i?this.endBatch():this.endBatchTimeout=window.setTimeout(()=>{this.endBatch()},D)),this.sendRaw(e,{handlesRejection:n})}async sendRaw(e,{handlesRejection:s}={}){return new Promise((i,n)=>{if(!this.channel){const c=`Userflow.js: send() should not be called if channel is not set. Message kind=${e.kind}`;if(s)throw Error(c);console.log(c,`
7
7
  Client message:`,e);return}o(`push ${e.kind} message`,e);const r=this.clientClock,a=()=>{this.serverClock=r,this.channel?.off("phx_error",u)},u=this.channel.on("phx_error",c=>{a();const h=`Userflow.js send ${e.kind} got phx_error`;this._socketStatus==="connected"&&console.log(h,`
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d=new Error().stack;d&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[d]="c12b5c03-5bf7-471d-a152-d7cf32c1ba36",e._sentryDebugIdIdentifier="sentry-dbid-c12b5c03-5bf7-471d-a152-d7cf32c1ba36")}catch{}})();var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"5e17a12b365969e9a5ae25340d395a6c9e67989f"};function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}export{f as g};
1
+ (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},f=new Error().stack;f&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[f]="7bf4ef81-f7d7-4372-9571-c5c59de61bfa",e._sentryDebugIdIdentifier="sentry-dbid-7bf4ef81-f7d7-4372-9571-c5c59de61bfa")}catch{}})();var d=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};d.SENTRY_RELEASE={id:"8e34896f7be8ea6f54530000fe284a878faab537"};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}export{t as g};
2
2
  //# sourceMappingURL=vendor.html-parse-stringify2.js.map