userflow.js-self-hosted 0.1.1010263 → 0.1.1010334
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/EmbedApp.js +2 -0
- package/FlowChrome.js +1 -1
- package/LauncherApp.js +1 -1
- package/ResourceCenterAssistantChat.js +2 -2
- package/TrackerTestingApp.js +1 -1
- package/bubble-frame.css +38 -3
- package/flow-condition-types.js +1 -1
- package/flow-host.css +45 -0
- package/flow-host.styl.js +1 -1
- package/hash.txt +1 -1
- package/package.json +1 -1
- package/roots.js +1 -1
- package/stylesheets.js +1 -1
- package/ui.js +2 -2
- package/use-selector-element-monitoring.js +3 -3
- package/userflow.js +7 -7
- package/vendor.core-js.js +1 -1
package/EmbedApp.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as n,R as s}from"./vendor.react.js";import{s as f,E as W}from"./userflow.js";import{u as P,i as M}from"./client-context.js";import{o as x}from"./vendor.obj-str.js";import{u as z,a as H,g as Y,D as K}from"./stylesheets.js";import{a as q}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{u as Z,S as G,b as J}from"./use-selector-element-monitoring.js";import{w as Q,f as V}from"./flow-host.styl.js";import{r as X}from"./vendor.react-dom.js";import{F as ee}from"./use-window-resize.js";import{e as l}from"./roots.js";import{u as te}from"./use-element-rect.js";import{C as re}from"./ChecklistUI.js";import"./vendor.core-js.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.react-i18next.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./flow-condition-types.js";import"./vendor.date-fns.js";import"./vendor.scheduler.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},m=new Error().stack;m&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[m]="0a1e3d3f-8292-4ad8-abfa-14819884d42e",t._sentryDebugIdIdentifier="sentry-dbid-0a1e3d3f-8292-4ad8-abfa-14819884d42e")}catch{}})();const Re=({session:t,checklistSession:m})=>{const b=P(),{version:i}=t,r=i.embed,E=z(i.theme),L=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;n.useEffect(()=>{M.changeLanguage(L)},[L]);const e=n.useRef(null);n.useLayoutEffect(()=>{e.current=document.createElement("div")},[]);const[F,S]=n.useState(!1),{loaded:N}=H(window,V,E),[j,T]=n.useState(!1),p=N&&j,[k,_]=n.useState(0),v=n.useCallback(()=>{T(!1),_(o=>o+1)},[]),g=![f.BODY_FIRST,f.BODY_LAST,f.ELEMENT_FIRST,f.ELEMENT_LAST,f.ELEMENT_BEFORE,f.ELEMENT_AFTER].includes(r.embedMode),[h,C]=n.useState(null),D=n.useCallback(({targetEl:o})=>{C(o)},[]),A=n.useCallback(()=>{g&&console.warn(`Userflow.js: Could not find embed element for banner "${t.flow.name||t.flow.id}"`),C(null)},[g,t.flow.name,t.flow.id]);Z({selector:r.embedSelector,targetMoved:D,targetLost:A});const[I,B]=n.useState(!1),c=n.useCallback(()=>{const o=e.current;o&&o.parentElement&&(o.parentElement.removeChild(o),S(!1))},[e]),O=n.useCallback(()=>{t.kind==="embed"&&(B(!0),b.endFlow(t,{endReason:W.USER_CLOSED}),c())},[c,t,b]);n.useLayoutEffect(()=>{try{const o={BODY_FIRST:"afterbegin",BODY_LAST:"beforeend",ELEMENT_FIRST:"afterbegin",ELEMENT_LAST:"beforeend",ELEMENT_BEFORE:"beforebegin",ELEMENT_AFTER:"afterend",DEFAULT:"afterbegin"},a=r.embedMode||"BODY_FIRST",u=o[a]||o.DEFAULT;h?h.insertAdjacentElement(u,e.current):document.body.insertAdjacentElement(u,e.current),S(!0),v()}catch(o){console.error("Error during element insertion:",o)}return()=>{c()}},[c,e,g,h,i.embed?.overlay,i.embed?.sticky,r.embedMode,v]);const y=o=>x({"userflowjs-embed":!0,[`userflowjs-embed--embed-mode-${r.embedMode}`]:!0,[`userflowjs-embed--animate-${String(r.animate)}`]:o&&r.animate});n.useLayoutEffect(()=>{e.current&&(e.current.className=y(!1))},[e,r.embedMode,r.animate]);const w=r.zIndex||Q(0);n.useLayoutEffect(()=>{e.current&&(e.current.style.zIndex=w==null?"":String(w),e.current.style.position=p?"":"absolute",e.current.style.visibility=p?"":"hidden")},[e,w,p]);const{height:d,setEl:$}=te();n.useLayoutEffect(()=>{e.current&&e.current.style.setProperty("--userflowjs-embed-height",d&&l(d+(r.marginTop||0)+(r.marginBottom||0))||"0px")},[e,d,r.marginTop,r.marginBottom]);const U=()=>{if(!t.version.embed?.blocks?.length)return null;const o=(a,u)=>s.createElement("div",{className:"userflowjs-embed-wrapper",key:u},s.createElement("div",{className:"userflowjs-bubble-toolbar"},t.draftMode&&s.createElement("div",{className:"userflowjs-bubble-draft"},"Preview"),!i.closeDisabled&&s.createElement("button",{"data-testid":"userflow-embed-dismiss",className:"userflowjs-bubble-toolbar-button",onClick:O,"aria-label":"Close embed"},s.createElement(K,{icon:q}))),a);return t.version.embed?.blocks?t.version.embed.blocks.map(a=>{switch(a.type){case"CHECKLIST":return m?o(s.createElement("div",{style:{...Y(E),paddingTop:i.closeDisabled?"0px":"32px"},className:"userflowjs-embedded-checklist"},s.createElement(re,{session:m})),a.id):null;default:return console.warn(`Unknown embed block type: ${a.type}`),null}}):null};return n.useLayoutEffect(()=>{const o=`userflow-${t.id}`;return e.current.id=o,()=>{I||document.getElementById(o)===e.current&&c()}},[e,t.id,c,I]),n.useLayoutEffect(()=>{const o=t.version.embed?.blocks?.length&&t.version.embed.blocks.some(a=>a.type==="CHECKLIST"?m:!1);d&&d>0&&o?(e.current.style.height=`${d}px`,e.current.className=y(r.animate)):(e.current.style.height="0px",e.current.className=y(!1))},[e,d,m,r.animate]),n.useEffect(()=>{if(!e.current)return;const o=new ResizeObserver(u=>{for(const R of u)R.contentRect&&!r.embedMode&&(e.current.style.height=`${R.contentRect.height}px`)}),a=e.current.querySelector("iframe");return a&&o.observe(a),()=>{o.disconnect()}},[e,r.embedMode]),!F||!t.version.embed?.blocks?.length?null:X.createPortal(s.createElement(G.Provider,{value:t},s.createElement(ee,{key:k,className:"userflowjs-embed-frame",style:{maxWidth:r.maxWidth?l(r.maxWidth):"100%",width:"100%",height:t.version.embed?.blocks?.length?"100%":"auto",minHeight:0,marginTop:l(r.marginTop),marginRight:l(r.marginRight),marginBottom:l(r.marginBottom),marginLeft:l(r.marginLeft),borderRadius:l(r.borderRadius)},stylesheet:J,theme:E,onStylesheetsLoad:T,title:"Embedded Content"},s.createElement("div",{ref:$,className:x({"userflowjs-embed-root":!0,[`userflowjs-embed-root--content-layout-${r.contentLayout}`]:!0,"userflowjs-theme-root":!0,"userflowjs-embed-root-blocks":t.version.embed?.blocks?.length>0}),dir:M.dir(),style:{width:"100%",maxWidth:r.maxContentWidth?l(r.maxContentWidth):"100%",margin:"0 auto"}},U()))),e.current)};export{Re as EmbedApp,Re as default};
|
|
2
|
+
//# sourceMappingURL=EmbedApp.js.map
|
package/FlowChrome.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{m as pe,n as he,d as ge,a as we}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{R as p,r as u}from"./vendor.react.js";import{D as Ht,a as Te,g as Ee}from"./stylesheets.js";import"./vendor.core-js.js";import{u as ie}from"./vendor.react-i18next.js";import{u as ye,F as le}from"./use-window-resize.js";import{c as $,f as v,q as it,F as ve,r as O,
|
|
1
|
+
import{m as pe,n as he,d as ge,a as we}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{R as p,r as u}from"./vendor.react.js";import{D as Ht,a as Te,g as Ee}from"./stylesheets.js";import"./vendor.core-js.js";import{u as ie}from"./vendor.react-i18next.js";import{u as ye,F as le}from"./use-window-resize.js";import{c as $,f as v,q as it,F as ve,r as O,D as Be,z as c}from"./userflow.js";import{a as Le,f as Me}from"./flow-host.styl.js";import{u as ke,b as Re}from"./use-selector-element-monitoring.js";import{S as je}from"./logomark.js";import{o as At}from"./vendor.obj-str.js";import{d as zt,c as Ct,h as nt,q as Pe,k as se,M as re,p as Dt,s as Oe,m as Ne}from"./roots.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]="b19df9a8-42b2-4312-ac75-94e5bbb01f14",t._sentryDebugIdIdentifier="sentry-dbid-b19df9a8-42b2-4312-ac75-94e5bbb01f14")}catch{}})();const Qe=({draftMode:t,muted:e,toggleMuted:o,close:w,minimize:E})=>{const{t:f}=ie();return p.createElement("div",{className:"userflowjs-bubble-toolbar"},t&&p.createElement("div",{className:"userflowjs-bubble-draft"},typeof t=="string"?t:"Preview"),o&&p.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:o,"aria-label":e?"Unmute":"Mute"},e?p.createElement(Ht,{icon:pe}):p.createElement(Ht,{icon:he})),E&&p.createElement("button",{"data-testid":"minimize-button",className:"userflowjs-bubble-toolbar-button",onClick:E,"aria-label":"Minimize checklist"},p.createElement(Ht,{icon:ge})),w&&p.createElement("button",{"data-testid":"close-button",className:"userflowjs-bubble-toolbar-button",onClick:w,"aria-label":f("menu.close")},p.createElement(Ht,{icon:we})))},Ie=new URL("avatar-frame.css",import.meta.url).href;function xe(t,e){const o=window.Intercom;u.useEffect(()=>{if(!(!e||!t.autoHideIntercom||typeof o!="function"||$.autoHide3pDisabled)){try{o("update",{hide_default_launcher:!0})}catch(a){console.warn("Userflow.js: Error when hiding Intercom launcher",a)}return()=>{if(!$.autoHide3pDisabled)try{o("update",{hide_default_launcher:!1})}catch(a){console.warn("Userflow.js: Error when unhiding Intercom launcher",a)}}}},[o,t.autoHideIntercom,e]);const w=window.$crisp;u.useEffect(()=>{if(!(!e||!t.autoHideCrisp||!w||$.autoHide3pDisabled)){try{w.push(["do","chat:hide"])}catch(a){console.warn("Userflow.js: Error when hiding Crisp Chat",a)}return()=>{if(!$.autoHide3pDisabled)try{w.push(["do","chat:show"])}catch(a){console.warn("Userflow.js: Error when unhiding Crisp Chat",a)}}}},[w,t.autoHideCrisp,e]);const E=window.HubSpotConversations;u.useEffect(()=>{if(!(!e||!t.autoHideHubspot||!E||$.autoHide3pDisabled)){try{E.widget.remove()}catch(a){console.warn("Userflow.js: Error when hiding HubSpot Chat",a)}return()=>{if(!$.autoHide3pDisabled)try{E.widget.load()}catch(a){console.warn("Userflow.js: Error when unhiding HubSpot Chat",a)}}}},[E,t.autoHideHubspot,e]);const f=window.drift;u.useEffect(()=>{if(!(!e||!t.autoHideDrift||!f||$.autoHide3pDisabled)){try{f.api.widget.hide()}catch(a){console.warn("Userflow.js: Error when hiding Drift Chat",a)}return()=>{if(!$.autoHide3pDisabled)try{f.api.widget.show()}catch(a){console.warn("Userflow.js: Error when unhiding Drift Chat",a)}}}},[f,t.autoHideDrift,e])}const Gt=16,kt=20,to=({company:t,theme:e,position:o,absoluteWidth:w,absoluteHeight:E,stepKey:f,stepAppearance:a,width:m,backgroundImageUrl:T,tooltipSelector:d,allowMissingTooltipTarget:y,tooltipPlacement:k,backdrop:_,tooltipTargetBlocked:A,backdropPadding:Q,zIndex:N,onTooltipTargetClick:B,onTooltipTargetMissingChange:H,onModalBackdropClick:q,onVisibleChange:tt,speaking:C,noIframe:R,MadeWithUserflow:n,minimizeOnAvatarClick:F,autoHide3pEnabled:M,bubbleFrameRootRef:L,frameWrapperHtmlAttributes:j,rootChildren:I,children:l,isModalAnnouncement:i})=>{const U=o||"absolute",X=k||null,V=Q||"0",et=n||He,ot=Le(),at=U==="fixed"?N??ot+1:1,J=at-1,{i18n:Rt}=ie(),st=Rt.dir(),ut=u.useRef(null),mt=u.useRef(null),ct=u.useRef(null),[Y,jt]=u.useState(null),pt=u.useRef(null),ht=u.useRef(null),gt=u.useRef(null),wt=u.useRef(null),Tt=u.useRef(null),Et=u.useRef(null),yt=u.useRef(null),vt=u.useRef(null),Bt=u.useRef(null);u.useLayoutEffect(()=>{const s=ut.current.style;s.animation="none",s.visibility="hidden",s.position="absolute",s.top="-99999px",s.left="-99999px"},[]);const{loaded:Pt}=Te(window,Me,e),[Ot,Nt]=u.useState(!1),[It,Ft]=u.useState(!1),Lt=Pt&&Ot&&It;let[g,r]=u.useState(!1);a!==v.BUBBLE&&(F=!1,g=!1),u.useEffect(()=>{r(!1)},[f]);const P=u.useRef({appearance:null,width:null,theme:e,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}),[lt,D]=u.useState(null),z=lt!=null&≪u.useEffect(()=>{tt&&tt(z)},[tt,z]);const x=u.useCallback(s=>{P.current.lastReportedTooltipTargetMissing!==s&&(P.current.lastReportedTooltipTargetMissing=s,H&&H(s))},[H]),G=u.useCallback(({forceAppearanceLayout:s,forceUpdatePosition:S}={})=>{const bt=ut.current,_t=mt.current,Mt=ct.current,$t=ht.current,Xt=pt.current,Yt=gt.current,Zt=wt.current,qt=Tt.current,Jt=Et.current,Kt=yt.current,Qt=vt.current,te=Bt.current;if(!bt||!_t||!Mt||!Y||!$t||!Xt||!Yt||!Zt||!qt||!Jt||!Kt||!Qt||!te||!Lt)return;const h=P.current,{tooltipTargetParams:St}=h;Ne();let W=a,ee=!1;W===v.TOOLTIP&&!y&&!St&&(h.tooltipTargetMissing?(W=v.BUBBLE,ee=!0):W=null);const oe=W!==h.appearance,de=m!==h.width;if((s||oe||de||e!==h.theme||_!=h.backdrop||V!=h.backdropPadding||X!==h.desiredTooltipPlacement)&&(h.appearance=W,h.width=m,h.theme=e,h.backdrop=_,h.backdropPadding=V,h.desiredTooltipPlacement=X,S=!0,De({layoutState:h,width:m,position:U,absoluteWidth:w,root:bt,bubble:_t,bubbleFrameRoot:Y,avatar:$t,avatarNotch:Xt,modalBackdrop:te,dir:st})),!R){const Z=Y.offsetHeight,Ut=zt(),Vt=Ct()<800?0:Gt,be=e.avatarType===it.NONE?0:W===v.BUBBLE?kt+e.avatarSize:W===v.MODAL?e.avatarSize/2:0,ae=Ut-2*Vt-be,Wt=Math.min(Z,ae);if(W&&Wt!==h.bubbleFrameHeight){if(h.bubbleFrameHeight=Wt,b(Mt,"height",nt(Wt)),Pe(Mt)&&Mt.contentDocument){const me=Mt.contentDocument.documentElement;me.style.overflowY=Z<=ae?"hidden":"scroll"}S=!0}}if(S&&W){let Z=oe;if(W===v.TOOLTIP){const Ut=h.tooltipTargetParams&&h.tooltipTargetParams.targetEl,Vt=h.prevTooltipTargetParams&&h.prevTooltipTargetParams.targetEl;Ut!==Vt&&(Z=!0)}h.prevTooltipTargetParams=h.tooltipTargetParams,Ce({layoutState:h,animateIn:Z,position:U,absoluteWidth:w,absoluteHeight:E,desiredTooltipPlacement:X,root:bt,bubble:_t,tooltipNotch:Yt,tooltipBackdrop:Zt,tooltipBlockTop:qt,tooltipBlockRight:Jt,tooltipBlockBottom:Kt,tooltipBlockLeft:Qt,dir:st})}if(W===v.TOOLTIP){const Z=St&&St.targetEl;Z&&h.stepKeyScrolledIntoView!==f&&h.targetScrolledIntoView!==Z&&(h.stepKeyScrolledIntoView=f,h.targetScrolledIntoView=Z,Se(Z))}else h.stepKeyScrolledIntoView=void 0,h.targetScrolledIntoView=null;x(ee),D(W)},[Lt,Y,f,a,m,e,U,w,E,y,X,_,V,R,x,st]),K=u.useRef(G);K.current=G;const ft=u.useRef(!1);u.useEffect(()=>{const s=()=>{ft.current=!0};return window.addEventListener("pagehide",s),()=>window.removeEventListener("pagehide",s)},[]);const xt=()=>{window.clearTimeout(P.current.tooltipTargetMissingTimeout),P.current.tooltipTargetMissingTimeout=void 0};u.useEffect(()=>xt,[]);const ue=u.useCallback(()=>{const s=P.current;if(s.tooltipTargetParams=null,y||(s.tooltipPlacement=null),a!==v.TOOLTIP){xt(),s.tooltipTargetMissing=!1;return}if(!y&&!s.tooltipTargetMissingTimeout){s.tooltipTargetMissing=!1;const S=d&&!se(d)&&d.type===ve.AUTO&&!d.autoData?1:parseFloat(e.tooltipMissingToleranceSeconds)*1e3;s.tooltipTargetMissingTimeout=window.setTimeout(()=>{if(!ft.current){if(d&&!se(d)){let bt=d.autoData;if(d.autoData)try{bt=JSON.parse(d.autoData)}catch{}console.warn(`Userflow.js: Tooltip target not found on page.
|
|
2
2
|
`,{type:d.type,autoData:bt,excludeText:d.excludeText,precision:d.precision,text:d.text,css:d.css})}xt(),s.tooltipTargetMissing=!0,K.current()}},S)}K.current()},[a,y,d,e.tooltipMissingToleranceSeconds]),ce=u.useCallback(s=>{const S=P.current;xt(),S.tooltipTargetParams&&S.tooltipTargetParams.targetEl!==s.targetEl&&(S.tooltipPlacement=null),S.tooltipTargetParams=s,G({forceUpdatePosition:!0})},[G]);ke({selector:a===v.TOOLTIP&&d||null,targetMoved:ce,targetLost:ue,onTargetClick:B});const fe=u.useCallback(()=>G({forceAppearanceLayout:!0}),[G]);ye(fe),u.useEffect(()=>{if(!Y||R||typeof re!="function")return;let s;const S=new re(()=>{s||(s=window.requestAnimationFrame(()=>{s=void 0,K.current()}))});return S.observe(Y,{childList:!0,attributes:!0,subtree:!0}),()=>{S.disconnect(),s&&window.cancelAnimationFrame(s)}},[Y,R]),u.useLayoutEffect(()=>{K.current()}),u.useLayoutEffect(()=>{U==="absolute"&&G({forceAppearanceLayout:!0})},[U,w,E]);const dt=s=>{s.preventDefault(),s.stopPropagation()};return xe(e,!!M&<===v.BUBBLE),p.createElement("div",{ref:ut,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:Ee(e),dir:st},p.createElement("div",{className:"userflowjs-bubble",ref:mt,style:{zIndex:at}},p.createElement("div",{className:At({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(e.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!F,"userflowjs-bubble-outline--minimized":g})},p.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...j},p.createElement(le,{className:"userflowjs-bubble__frame",elRef:ct,stylesheet:Re,theme:e,onStylesheetsLoad:Nt,noIframe:R,title:a.toLowerCase()},p.createElement("div",{className:"userflowjs-bubble-frame-root",ref:s=>{L&&L(s),jt(s)},style:T?{backgroundImage:`url("${encodeURI(T)}")`}:void 0},l,t.flowBranding&&!i&&p.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},p.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},p.createElement(et,{company:t},p.createElement(je,null),p.createElement("div",null,"Made with Userflow"))))))),p.createElement("div",{ref:pt,className:"userflowjs-bubble__avatar-notch"})),p.createElement(le,{className:At({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!F,"userflowjs-bubble__avatar--speaking":!!C}),elRef:ht,stylesheet:Ie,theme:e,onStylesheetsLoad:Ft,noIframe:R,ariaHidden:!0,title:a.toLowerCase()},p.createElement("div",{className:At({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!F}),onClick:F?()=>r(s=>!s):void 0},p.createElement(_e,{theme:e}))),p.createElement("div",{ref:gt,className:"userflowjs-bubble__tooltip-notch"})),p.createElement("div",{ref:wt,className:"userflowjs-tooltip-backdrop",onMouseDown:dt,style:{zIndex:J,pointerEvents:A?void 0:"none"}}),p.createElement("div",{ref:Tt,className:"userflowjs-tooltip-block",onMouseDown:dt,style:{zIndex:J}}),p.createElement("div",{ref:Et,className:"userflowjs-tooltip-block",onMouseDown:dt,style:{zIndex:J}}),p.createElement("div",{ref:yt,className:"userflowjs-tooltip-block",onMouseDown:dt,style:{zIndex:J}}),p.createElement("div",{ref:vt,className:"userflowjs-tooltip-block",onMouseDown:dt,style:{zIndex:J}}),p.createElement("div",{ref:Bt,className:"userflowjs-modal-backdrop",onMouseDown:dt,onClick:q,style:{zIndex:J}}),I&&I({visible:z,bubbleFrame:ct.current}))},_e=({theme:t})=>{const e="https://js.userflow.com/cartoon-avatars-no-bg/";let o;return t.avatarType===it.ASSET&&t.avatarAsset?o=t.avatarAsset.assetUrl:t.avatarType===it.CARTOON&&t.avatarName?o=e+t.avatarName+".svg?3":t.avatarType===it.URL&&t.avatarUrl?o=t.avatarUrl:o=e+"none.svg",p.createElement("img",{src:o,alt:""})},He=({company:t,children:e})=>p.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+t.slug,target:"_blank",rel:"noopener noreferrer"},e);function De({layoutState:{appearance:t,theme:e,backdrop:o,tooltipTargetMissing:w},width:E,position:f,absoluteWidth:a,root:m,bubble:T,bubbleFrameRoot:d,avatar:y,avatarNotch:k,modalBackdrop:_,dir:A}){const Q=f==="absolute"?a||1024:nt(Ct()),{avatarSize:N,bubblePlacement:B}=e;let H=e.bubbleWidth,q=null,tt=null,C=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${t?.toLowerCase()}`,R="hidden",n=null,F=null,M=null,L=null,j="userflowjs-bubble__avatar-notch",I="hidden",l=null,i=null,U=null,X=null,V="userflowjs-modal-backdrop";switch((t===v.MODAL||!w&&t===v.BUBBLE&&o)&&(V+=" userflowjs-modal-backdrop--visible"),t){case v.BUBBLE:if(e.avatarType!==it.NONE){R="",I="",B===O.TOP_LEFT||B===O.TOP_CENTER||B===O.TOP_RIGHT?(q=N+kt,n=0,l=-2*kt,j+=" userflowjs-bubble__avatar-notch--top"):(tt=N+kt,M=0,U=-2*kt,j+=" userflowjs-bubble__avatar-notch--bottom");const ot=B===O.TOP_LEFT||B===O.TOP_CENTER||B===O.BOTTOM_LEFT||B===O.BOTTOM_CENTER||B===O.CENTER;A==="ltr"&&ot||A==="rtl"&&!ot?(L=0,X=N,j+=" userflowjs-bubble__avatar-notch--left"):(F=0,i=N,j+=" userflowjs-bubble__avatar-notch--right")}break;case v.MODAL:H=e.modalWidth,e.avatarType!==it.NONE&&(R="",L=`calc(50% - ${N/2}px)`,n=-N/2);break;case v.TOOLTIP:H=e.tooltipWidth;break}E!=null&&(H=E),H=Math.min(H,Q-2*Gt),m.classList.toggle("userflowjs-flow-chrome--position-absolute",f==="absolute"),m.classList.toggle("userflowjs-flow-chrome--position-relative",f==="relative"),m.classList.toggle("userflowjs-flow-chrome--position-fixed",f==="fixed"),m.classList.toggle("userflowjs-flow-chrome--appearance-modal",t===v.MODAL);const et=t!=null&&t!==v.HIDDEN;m.style.position="",m.style.top="",m.style.left="",m.style.visibility=et?"":"hidden",m.style.animation=et?"":"none",b(T,"width",nt(H)),b(T,"padding-top",q),b(T,"padding-bottom",tt),d.className=C,b(y,"width",nt(e.avatarSize)),b(y,"height",nt(e.avatarSize)),y.style.visibility=R,b(y,"top",n),b(y,"right",F),b(y,"bottom",M),b(y,"left",L),k.className=j,k.style.visibility=I,b(k,"top",l),b(k,"right",i),b(k,"bottom",U),b(k,"left",X),_.className=V}function Ce({layoutState:t,animateIn:e,position:o,absoluteWidth:w,absoluteHeight:E,desiredTooltipPlacement:f,root:a,bubble:m,tooltipNotch:T,tooltipBackdrop:d,tooltipBlockTop:y,tooltipBlockRight:k,tooltipBlockBottom:_,tooltipBlockLeft:A,dir:Q}){const{appearance:N,theme:B,tooltipTargetParams:H,backdrop:q,backdropPadding:tt}=t,{bubblePlacement:C}=B,R=Gt,n=B.tooltipNotchSize,F=10,{width:M,height:L}=m.getBoundingClientRect(),j=o==="absolute"?w||1024:nt(Ct()),I=o==="absolute"?E||768:nt(zt());let l=0,i=0,U="userflowjs-bubble__tooltip-notch",X="hidden",V=null,et=null,ot=null,at=null,J="userflowjs-tooltip-backdrop",Rt=null,st=null,ut=null,mt=null,ct=null,Y=null,jt=null,pt=null,ht="userflowjs-tooltip-block userflowjs-tooltip-block--top",gt=null,wt=null,Tt="userflowjs-tooltip-block userflowjs-tooltip-block--right",Et=null,yt=null,vt="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",Bt=null,Pt=null,Ot="userflowjs-tooltip-block userflowjs-tooltip-block--left",Nt=null,It=null;switch(N){case v.BUBBLE:{C===O.TOP_LEFT||C===O.BOTTOM_LEFT?l=B.bubbleX:C===O.TOP_CENTER||C===O.CENTER||C===O.BOTTOM_CENTER?l=(j-M)/2:l=j-M-B.bubbleX,C===O.TOP_LEFT||C===O.TOP_CENTER||C===O.TOP_RIGHT?i=B.bubbleY:C===O.CENTER?i=(I-L)/2:i=I-L-B.bubbleY,Q==="rtl"&&(l=j-l-M),l=Math.max(0,Math.min(j-M,l)),i=Math.max(0,Math.min(I-L,i));break}case v.MODAL:{let g=R;B.avatarType!==it.NONE&&(g+=B.avatarSize/2),l=R+(j-R*2-M)/2,i=g+(I-g-R-L)/2;break}case v.TOOLTIP:{let g;if(H){let{targetRect:r,viewportClipRect:P}=H;if(o==="absolute"){const x=a.offsetParent.getBoundingClientRect();P={top:0,right:j,bottom:I,left:0},r={top:r.top-x.top,right:r.right-x.left,bottom:r.bottom-x.top,left:r.left-x.left,width:r.width,height:r.height}}let lt=0;if(q){const{paddingTop:x,paddingRight:G,paddingBottom:K,paddingLeft:ft}=Ue(tt);r={top:r.top-x,right:r.right+G,bottom:r.bottom+K,left:r.left-ft,width:r.width+ft+G,height:r.height+x+K},lt=Math.min(x,G,K,ft)}const D=r,z=B.backdropHighlightType==Be.OUTSIDE?B.backdropHighlightSpread:0;if(q&&z&&(r={top:r.top-z,right:r.right+z,bottom:r.bottom+z,left:r.left-z,width:r.width+2*z,height:r.height+2*z}),g=Fe({targetRect:r,bubbleWidth:M,bubbleHeight:L,containerWidth:j,containerHeight:I,viewportClipRect:P,tooltipNotchSize:n,currentTooltipPlacement:t.tooltipPlacement,desiredTooltipPlacement:f}),g===c.BELOW||g===c.ABOVE?(l=r.left+r.width/2-M/2,l=Math.max(R,Math.min(j-M-R,l)),at=Math.max(F,Math.min(M-F-n*2,r.left+r.width/2-n-l)),g===c.BELOW?V=-n*2:ot=-n*2):g===c.RIGHT?(l=r.right+n,l=Math.max(l,P.left+n),l=Math.min(l,P.right+n),l=Math.max(l,n),l=Math.min(l,j-M)):(l=r.left-n-M,l=Math.max(l,P.left-M-n),l=Math.min(l,P.right-M-n),l=Math.max(l,0),l=Math.min(l,j-M-n)),g===c.LEFT||g===c.RIGHT?(i=r.top+r.height/2-L/2,i=Math.max(R,Math.min(I-L-R,i)),V=Math.max(F,Math.min(L-F-n*2,r.top+r.height/2-n-i)),g===c.LEFT?et=-n*2:at=-n*2):g===c.BELOW?(i=r.bottom+n,i=Math.max(i,P.top+n),i=Math.min(i,P.bottom+n),i=Math.max(i,n),i=Math.min(i,I-L)):(i=r.top-n-L,i=Math.max(i,P.top-L-n),i=Math.min(i,P.bottom-L-n),i=Math.max(i,0),i=Math.min(i,I-L-n)),q){const x=window.getComputedStyle(H.targetEl);Rt=Math.max(0,D.top),st=Math.max(0,j-D.right),ut=Math.max(0,I-D.bottom),mt=Math.max(0,D.left),ct=Math.max(0,Dt(x.borderTopLeftRadius)+lt),Y=Math.max(0,Dt(x.borderTopRightRadius)+lt),jt=Math.max(0,Dt(x.borderBottomRightRadius)+lt),pt=Math.max(0,Dt(x.borderBottomLeftRadius)+lt),gt=Math.max(0,D.right),wt=Math.max(0,D.top),Et=Math.max(0,D.right),yt=Math.max(0,D.bottom),Bt=Math.max(0,D.left),Pt=Math.max(0,D.bottom),Nt=Math.max(0,D.left),It=Math.max(0,D.top)}}else g=f||c.BELOW,(g===c.BELOW||g===c.ABOVE)&&(at=M/2-n,g===c.BELOW?V=-n*2:ot=-n*2),(g===c.LEFT||g===c.RIGHT)&&(V=L/2-n,g===c.LEFT?et=-n*2:at=-n*2);t.tooltipPlacement=g,U+=` userflowjs-bubble__tooltip-notch--${g.toLowerCase()}`,X="",q&&(J+=" userflowjs-tooltip-backdrop--visible",ht+=" userflowjs-tooltip-block--visible",Tt+=" userflowjs-tooltip-block--visible",vt+=" userflowjs-tooltip-block--visible",Ot+=" userflowjs-tooltip-block--visible");break}}m.style.transition="";let Ft=l,Lt=i;if(e&&(m.style.opacity="0",N===v.TOOLTIP))switch(t.tooltipPlacement){case c.BELOW:i+=24;break;case c.ABOVE:i-=24;break;case c.RIGHT:l+=24;break;case c.LEFT:l-=24;break}if(o!=="relative"&&ne(m,l,i),T.className=U,T.style.visibility=X,b(T,"top",V),b(T,"right",et),b(T,"bottom",ot),b(T,"left",at),d.className=J,b(d,"top",Rt),b(d,"right",st),b(d,"bottom",ut),b(d,"left",mt),b(d,"border-top-left-radius",ct),b(d,"border-top-right-radius",Y),b(d,"border-bottom-right-radius",jt),b(d,"border-bottom-left-radius",pt),y.className=ht,b(y,"width",gt),b(y,"height",wt),k.className=Tt,b(k,"left",Et),b(k,"height",yt),_.className=vt,b(_,"left",Bt),b(_,"top",Pt),A.className=Ot,b(A,"width",Nt),b(A,"top",It),e){m.offsetWidth;const g="opacity 250ms linear";N===v.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"&&ne(m,Ft,Lt)}}function Fe({targetRect:t,bubbleWidth:e,bubbleHeight:o,containerWidth:w,containerHeight:E,viewportClipRect:f,tooltipNotchSize:a,currentTooltipPlacement:m,desiredTooltipPlacement:T}){if(t.bottom<=f.top)return o+a<=E-f.top?c.BELOW:c.ABOVE;if(t.top>=f.bottom)return o+a<=f.bottom?c.ABOVE:c.BELOW;if(t.right<=f.left)return e+a<=w-f.left?c.RIGHT:c.LEFT;if(t.left>=f.right)return e+a<=f.right?c.LEFT:c.RIGHT;const d=k=>{const _=t.left+t.width/2,A=_>=f.left&&_<=f.right,Q=t.top+t.height/2,N=Q>=f.top&&Q<=f.bottom;switch(k){case c.BELOW:return E-t.bottom>o+a&&A;case c.ABOVE:return t.top>o+a&&A;case c.RIGHT:return w-t.right>e+a&&N;case c.LEFT:return t.left>e+a&&N}};if(T&&d(T))return T;if(m&&d(m))return m;const y=[{placement:c.BELOW,dist:t.top},{placement:c.ABOVE,dist:E-t.bottom},{placement:c.RIGHT,dist:t.left},{placement:c.LEFT,dist:w-t.right}];y.sort((k,_)=>k.dist-_.dist);for(const{placement:k}of y)if(d(k))return k;return c.BELOW}function b(t,e,o){o==null?t.style.removeProperty(e):t.style.setProperty(e,typeof o=="number"?o+"px":o,"important")}function ne(t,e,o){e=Math.round(e),o=Math.round(o),t.style.transform=`translate3d(${e}px, ${o}px, 0px)`}function Se(t){if($.customScrollIntoView){$.customScrollIntoView(t);return}const{scrollPadding:e}=$;if(e&&Oe(t)===document.scrollingElement){const o=e.top||0,w=e.right||0,E=e.bottom||0,f=e.left||0;let a=0,m=0;const T=t.getBoundingClientRect(),d=Ct(),y=zt();if(T.top<o?a=T.top-o:T.bottom>y-E&&(a=T.bottom-y+E),T.left<f?m=T.left-f:T.right>d-w&&(m=T.right-d+w),a!=0||m!=0){window.scrollBy({top:a,left:m,behavior:"smooth"});return}}try{t.scrollIntoView({behavior:"smooth",block:"nearest"})}catch(o){console.warn("Userflow.js: scrollIntoView error (falling back to no options).",o),t.scrollIntoView()}}function Ue(t){if(!t||t==="0")return{paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0};const e=t.trim().split(" ");if(e.length===1){const o=rt(e[0]);return{paddingTop:o,paddingRight:o,paddingBottom:o,paddingLeft:o}}else if(e.length===2){const o=rt(e[0]),w=rt(e[1]);return{paddingTop:o,paddingRight:w,paddingBottom:o,paddingLeft:w}}else return{paddingTop:rt(e[0]),paddingRight:rt(e[1]),paddingBottom:rt(e[2]),paddingLeft:rt(e[3])}}function rt(t){const e=parseInt(t,10);return isNaN(e)?0:e}export{Qe as B,to as F};
|
|
3
3
|
//# sourceMappingURL=FlowChrome.js.map
|
package/LauncherApp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{R as i,r as u}from"./vendor.react.js";import{L as R,
|
|
1
|
+
import{R as i,r as u}from"./vendor.react.js";import{L as R,t as l,v as a,f as te,w as re,x as b,y as K,z as N}from"./userflow.js";import{u as ne,m as oe,d as ae,S as ce,R as se,h as le,r as ie}from"./use-selector-element-monitoring.js";import{u as ue,i as fe}from"./client-context.js";import{o as U}from"./vendor.obj-str.js";import{a as de,b as he,g as Ee,D as Te,u as me}from"./stylesheets.js";import{w as be,f as pe,L as ge,S as Ce}from"./flow-host.styl.js";import"./vendor.core-js.js";import{F as Le,B as Re}from"./FlowChrome.js";import{g as we}from"./flow-condition-types.js";import{T as Ae}from"./Trigger.js";import{r as V}from"./roots.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.react-i18next.js";import"./vendor.babel.runtime.js";import"./vendor.i18next.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.js";import"./vendor.date-fns.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},c=new Error().stack;c&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[c]="496bbafe-6945-4d71-82b7-ab408bb16fe0",t._sentryDebugIdIdentifier="sentry-dbid-496bbafe-6945-4d71-82b7-ab408bb16fe0")}catch{}})();const ve=i.forwardRef(({appearance:t,icon:c,buttonText:f,theme:T,noAnimation:E,noFixed:w,onClick:e,onMouseEnter:s,onMouseLeave:o,noPointerEvents:n,zIndex:m},r)=>{const{loaded:C}=de(window,pe,T),k=T&&t===R.BUTTON?T:null,{loaded:H}=he(window,k),I={"userflowjs-launcher":!0,"userflowjs-launcher--activate-on-click":!!e,"userflowjs-fixed-widget":!w},d={ref:r,style:{...Ee(T),zIndex:m||be(ge),pointerEvents:n?"none":void 0},onClick:e,onMouseEnter:s,onMouseLeave:o};if(!C||!H)return null;switch(t){case R.BEACON:return i.createElement("div",{className:U({...I,"userflowjs-beacon":!0,"userflowjs-beacon--pulse":!E,"userflowjs-beacon--pulse-still":!!E}),...d},i.createElement("div",{className:"userflowjs-beacon__ring"}),i.createElement("div",{className:"userflowjs-beacon__ring"}));case R.BUTTON:return i.createElement("div",{className:U({...I,"userflowjs-launcher--button":!0}),...d},f);case R.HIDDEN:return null;case R.ICON:return i.createElement("div",{className:U({...I,"userflowjs-launcher--icon":!0}),...d},i.createElement(Te,{icon:c||"solid/info-circle",size:T.launcherIconSize}))}}),Ie="userflowjs-fixed-widget--visible",tt=({session:t,active:c})=>{const f=ue(),{version:T}=t,E=t.id,w=t.flow.id,e=t.version.launcher,[s,o]=u.useState(null),n=me(T.theme),m=t.locale?t.locale.standardLocaleId:n.languageId;u.useEffect(()=>{fe.changeLanguage(m)},[m]);const{activateOn:r}=e,C=e.activeWhileTooltipHover||e.buttons.length>0,k=e.hiddenWhileActive&&r!==l.LAUNCHER_HOVER,H=!c||!k,I=r===l.LAUNCHER_CLICK||r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK||C,d=u.useRef({}),A=u.useCallback(()=>{let h=null;const{targetEl:p,clipEl:g,viewportClipRect:F}=d.current,S=s;S&&(p&&g&&F&&(h=ke({targetEl:p,subjectEl:S,clipEl:g,viewportClipRect:F,position:e.targetPosition,subjectAnchor:e.appearance===R.BEACON?"center":"side"})),ie(()=>{Oe(S,h)}));let M;e.appearance===R.HIDDEN?M=!!p:M=!!h,M&&!d.current.seenTriggered&&!E&&(d.current.seenTriggered=!0,f.launcherSeen(w))},[s,e,f,E,w]);u.useLayoutEffect(()=>{A()},[A]);const _=u.useRef(!1),y=u.useRef(!1),P=u.useRef(!1),x=u.useRef(),z=()=>{_.current=!0,v()},W=()=>{_.current=!1,v()},Z=()=>{y.current=!0,v()},$=()=>{y.current=!1,v()},X=()=>{P.current=!0,v()},q=()=>{P.current=!1,v()},v=()=>{O();const h=250;x.current=window.setTimeout(()=>B.current(),h)},O=u.useCallback(()=>{window.clearTimeout(x.current)},[]),G=()=>{if(r===l.LAUNCHER_CLICK||r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK)return;const h=r===l.LAUNCHER_HOVER||r===l.LAUNCHER_TARGET_HOVER,p=r===l.TARGET_HOVER||r===l.LAUNCHER_TARGET_HOVER;_.current&&(!k||!c)&&h||y.current&&p||P.current&&C?D():L()},B=u.useRef(G);B.current=G;const D=()=>{c||(O(),e.tooltipEnabled?f.activateLauncher(t):(f.activateLauncher(t),f.deactivateLauncher(t)),le(f,t,e.actions))},L=u.useCallback(()=>{c&&(O(),f.deactivateLauncher(t))},[c,f,t,O]),j=()=>{c?L():D()},J=u.useCallback(({targetEl:h,clipEl:p,viewportClipRect:g})=>{d.current.targetEl=h,d.current.clipEl=p,d.current.viewportClipRect=g,A()},[A]),Q=u.useCallback(()=>{d.current.targetEl=void 0,d.current.clipEl=void 0,A(),L()},[A,L]);ne({selector:e.targetSelector,targetMoved:J,targetLost:Q,onTargetMouseEnter:Z,onTargetMouseLeave:$,onTargetClick:r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK?j:void 0}),u.useEffect(()=>{if(!c)return;const h=p=>{const g=p.target;s&&s.contains(g)||(r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK)&&d.current.targetEl&&d.current.targetEl.contains(g)||L()};return window.addEventListener("click",h,{capture:!0}),()=>window.removeEventListener("click",h,{capture:!0})},[c,r,s,L]);const Y=Ne(e.tooltipPosition.side===a.AUTO?e.targetPosition:e.tooltipPosition),ee=u.useMemo(()=>e.content&&oe(ae(e.content),{buttons:e.buttons}),[e.content,e.buttons]);return i.createElement(ce.Provider,{value:t},H&&i.createElement(ve,{ref:o,appearance:e.appearance,icon:e.icon,buttonText:e.buttonText,theme:n,onClick:r===l.LAUNCHER_CLICK||r===l.LAUNCHER_TARGET_CLICK?j:void 0,onMouseEnter:z,onMouseLeave:W,noPointerEvents:r===l.TARGET_HOVER,zIndex:e.zIndex}),c&&i.createElement(Ce,null,i.createElement(Le,{company:t.flow.company,theme:n,position:"fixed",stepAppearance:te.TOOLTIP,width:e.tooltipWidth,tooltipSelector:e.tooltipAnchor===re.TARGET?d.current.targetEl:s,tooltipPlacement:Y,frameWrapperHtmlAttributes:{onMouseEnter:X,onMouseLeave:q},rootChildren:()=>i.createElement(i.Fragment,null,e.triggers.map(h=>i.createElement(Ae,{key:h.id,trigger:h})))},i.createElement(Re,{draftMode:t.draftMode,close:I?L:void 0}),i.createElement("div",{className:"userflowjs-bubble-content"},i.createElement(se,{doc:ee,lookupAttribute:we(t.data),buttons:e.buttons})))))};function ke({targetEl:t,subjectEl:c,clipEl:f,viewportClipRect:T,position:E,subjectAnchor:w}){const e=V(t);if(e.width===0||e.height===0)return null;const s=c.getBoundingClientRect();let o=0,n=0,{side:m,align:r}=E;switch(m===a.AUTO&&(m=a.TOP,r=b.END),m){case a.TOP:n=e.top;break;case a.BOTTOM:n=e.bottom;break;case a.LEFT:o=e.left;break;case a.RIGHT:o=e.right;break}switch(m){case a.TOP:case a.BOTTOM:switch(r){case b.START:o=e.left;break;case b.CENTER:o=e.left+e.width/2;break;case b.END:o=e.right;break}break;case a.LEFT:case a.RIGHT:switch(r){case b.START:n=e.top;break;case b.CENTER:n=e.top+e.height/2;break;case b.END:n=e.bottom;break}break}switch(E.xUnit===K.PERCENT?o+=E.xOffset/100*e.width:o+=E.xOffset,E.yUnit===K.PERCENT?n+=E.yOffset/100*e.height:n+=E.yOffset,w){case"center":o-=s.width/2,n-=s.height/2;break;case"side":switch(m){case a.TOP:n-=s.height;break;case a.LEFT:o-=s.width;break}switch(m){case a.TOP:case a.BOTTOM:switch(r){case b.CENTER:o-=s.width/2;break;case b.END:o-=s.width;break}break;case a.LEFT:case a.RIGHT:switch(r){case b.CENTER:n-=s.height/2;break;case b.END:n-=s.height;break}break}}if(o+s.width<T.left||o>T.right||n+s.height<T.top||n>T.bottom)return null;const C=V(f);return o=Math.max(o,C.left-f.scrollLeft),n=Math.max(n,C.top-f.scrollTop),o=Math.round(o),n=Math.round(n),{left:o,top:n}}function Oe(t,c){t.classList.toggle(Ie,c!=null),c&&(t.style.transform=`translate3d(${c.left}px, ${c.top}px, 0)`)}function Ne(t){switch(t.side){case a.AUTO:return null;case a.TOP:return N.ABOVE;case a.BOTTOM:return N.BELOW;case a.LEFT:return N.LEFT;case a.RIGHT:return N.RIGHT}}export{tt as LauncherApp,tt as default};
|
|
2
2
|
//# sourceMappingURL=LauncherApp.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{r as u,R as n}from"./vendor.react.js";import{a0 as b,a1 as y,u as Y}from"./userflow.js";import{u as Ee}from"./client-context.js";import{D as q,E as Q,F as _e,G as P,H as $,I as V,J as X,K as Z}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{p as be}from"./vendor.dompurify.js";import{m as ke}from"./vendor.marked.js";import{o as F}from"./vendor.obj-str.js";import{A as we,d as Ie,G as Se}from"./ResourceCenterApp.js";import{f as je,R as Ce}from"./use-selector-element-monitoring.js";import{D as W}from"./stylesheets.js";import{U as ae}from"./roots.js";import{r as ee}from"./vendor.react-dom.js";import"./vendor.core-js.js";import{g as Me}from"./flow-condition-types.js";import{u as ve}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./flow-host.styl.js";import"./use-window-resize.js";import"./logomark.js";import"./ChecklistUI.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./FlowChrome.js";import"./use-element-rect.js";import"./vendor.bignumber.js.js";import"./index.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";import"./vendor.babel.runtime.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]="366de984-fdc1-4a2d-a749-c7181c92afb2",t._sentryDebugIdIdentifier="sentry-dbid-366de984-fdc1-4a2d-a749-c7181c92afb2")}catch{}})();function Re(t){const e=Intl.Segmenter;return e?/(\p{Emoji_Presentation}|\p{Extended_Pictographic})(\p{Emoji_Modifier_Base}?\p{Emoji_Modifier}?|\uFE0F\u200D(\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?\uFE0F\u200D)*\p{Emoji_Presentation}|\uFE0F\u200D\p{Extended_Pictographic})/u.test(t)&&[...new e().segment(t)].length===1:!1}const te=[];function Ne({assistant:t,lookupAttribute:e,initialConversationId:a,initialHistory:c,initialUserContent:m,onConversationIdChange:f,submitMessage:h,submitRating:l,submitFeedback:g,InsideMessage:r,onContactClick:p,contactButtonText:i}){const[o,d]=u.useState(null),[S,w]=u.useState(()=>c?c.map(s=>({...s,assistantHtml:x(B(s.assistantContent),!1)})):te),[D,M]=u.useState(""),j=u.useRef(null),k=u.useRef(null),_=u.useRef(!0),I=u.useRef(a||null),[ce,le]=u.useState(I.current),H=u.useCallback(s=>{I.current=s,le(s),f&&f(s)},[f]),T=u.useCallback(()=>{o?.focus({preventScroll:!0})},[o]);u.useEffect(()=>{T()},[T]),u.useLayoutEffect(()=>{const s=k.current;s&&(s.scrollTop=Math.ceil(s.scrollHeight-s.clientHeight))},[]);const K=u.useCallback(()=>{const s=k.current;s&&(_.current=!0,typeof s.scrollTo=="function"&&s.scrollTo({top:Math.ceil(s.scrollHeight-s.clientHeight),behavior:"smooth"}))},[]),G=u.useRef(0);u.useLayoutEffect(()=>{const s=k.current;s&&s.scrollHeight!==G.current&&(G.current=s.scrollHeight,_.current&&K())},[S,K]);const N=u.useCallback(()=>{j.current&&j.current()},[]);u.useEffect(()=>()=>{N()},[N]);const O=(s,R)=>{w(C=>C.map(v=>{if(s===v.id){const E=R(v);return{...v,...E}}else return v}))},L=s=>{w(R=>R.map((C,v)=>{if(v===R.length-1){const E=s(C);return{...C,...E}}else return C}))},U=u.useCallback(async s=>{if(s=s.trim(),s==="")return;N(),w(E=>[...E,{id:null,userContent:s,assistantContent:"",assistantHtml:x("","enter"),enterAnimation:!0,sources:[],completed:!1,rating:null,scaleRating:null,scaleMax:null,feedbackSubmitted:!1}]),M(""),K();let R=!1;const C=()=>{R=!0,j.current=null},v=h({conversationId:I.current,userContent:s,callback:E=>{if(R){console.log("Userflow.js AssistantChat got message after being done",E);return}switch(E.kind){case"conversation_created":H(E.conversationId);break;case"message_created":L(()=>({id:E.messageId,warning:E.warning}));break;case"assistant_content_delta":L(A=>{const he=E.delta,z=A.assistantContent+he,ge=B(z),pe=x(ge);return{assistantContent:z,assistantHtml:pe}});break;case"done":C(),L(A=>({assistantHtml:x(A.assistantContent,"exit"),completed:!0,sources:E.sources}));break;case"error":C(),L(A=>({failed:!0,error:E.message,assistantHtml:x(B(A.assistantContent),!1)}));break;default:console.log("Userflow.js AssistantChat got unknown message",E)}}});j.current=()=>{C(),v.abort(),L(E=>({assistantHtml:x(B(E.assistantContent),!1)}))}},[N,K,h,H]),J=u.useRef(!1);u.useEffect(()=>{J.current||(J.current=!0,m&&U(m))},[U,m]);const ie=u.useCallback(()=>{N(),H(null),w(te),T()},[N,T,H]),[ue,fe]=u.useState(!0),de=u.useCallback(()=>{const s=k.current;s&&fe(s.scrollTop===0)},[]),me=u.useCallback(()=>{const s=k.current;s&&(_.current=Math.ceil(s.scrollHeight-s.clientHeight)==Math.ceil(s.scrollTop))},[]);return{assistant:t,lookupAttribute:e,history:S,setInput:d,contentElRef:k,scrolledToTop:ue,userContent:D,setUserContent:M,onSubmitMessage:U,supportsFeedback:!!l&&!!g,onSubmitRating:s=>{if(l){switch(s.ratingMode){case b.LIKE:O(s.messageId,()=>({rating:s.rating}));break;case b.SCALE:O(s.messageId,()=>({scaleRating:s.scaleRating,scaleMax:s.scaleMax}));break;default:throw new ae(s)}l(s)}},onSubmitFeedback:s=>{g&&(O(s.messageId,()=>({feedbackSubmitted:!0})),g(s))},InsideMessage:r,onContactClick:p,contactButtonText:i,reset:ie,onContentScroll:de,onContentWheel:me,conversationId:ce}}const xe=({assistant:t,lookupAttribute:e,history:a,setInput:c,contentElRef:m,scrolledToTop:f,userContent:h,setUserContent:l,onSubmitMessage:g,supportsFeedback:r,onSubmitRating:p,onSubmitFeedback:i,InsideMessage:o,onContactClick:d,contactButtonText:S,reset:w,onContentScroll:D,onContentWheel:M,conversationId:j})=>{const k=a.some(_=>_.completed||_.failed);return n.createElement("div",{className:"userflowjs-assistant-chat"},n.createElement("div",{className:F({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})}),n.createElement("div",{className:F({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})},n.createElement(n.Fragment,null,n.createElement("h2",{className:"userflowjs-assistant-chat__title"},t.title),n.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:w},t.resetText))),n.createElement("div",{ref:m,className:"userflowjs-assistant-chat__content",onScroll:D,onWheel:M},!je(t.intro)&&n.createElement("div",{className:"userflowjs-assistant-chat__intro"},n.createElement(Ce,{doc:t.intro,lookupAttribute:e})),a.map((_,I)=>n.createElement(Le,{key:I,assistant:t,message:_,supportsFeedback:r,onSubmitRating:p,onSubmitFeedback:i,InsideMessage:o,conversationId:j,isLast:I===a.length-1}))),n.createElement("div",{className:"userflowjs-assistant-chat__prompt"},n.createElement(we,{textareaRef:c,placeholder:(a.length===0?t.promptEmptyPlaceholder:t.promptNonemptyPlaceholder)||"",value:h,onChange:l,onSubmit:()=>g(h)})),k&&d&&n.createElement("div",{className:"userflowjs-assistant-chat__contact"},n.createElement("button",{className:"userflowjs-tertiary-button",onClick:()=>d()},S)))},Le=({assistant:t,message:e,supportsFeedback:a,onSubmitRating:c,onSubmitFeedback:m,InsideMessage:f,conversationId:h,isLast:l})=>n.createElement("div",{className:"userflowjs-assistant-chat__message"},f&&n.createElement(f,{message:e}),n.createElement("div",{className:F({"userflowjs-assistant-chat__user-content":!0,"userflowjs-assistant-chat__user-content--enter":!!e.enterAnimation}),"data-assistant-conversation-id":h,"data-assistant-message-id":e.id},n.createElement("div",{style:{whiteSpace:"pre-wrap"}},e.userContent)),e.warning&&n.createElement("div",{className:"userflowjs-assistant-chat__error"},"Warning: ",e.warning),n.createElement("div",{className:"userflowjs-assistant-chat__assistant-content"},n.createElement("div",null,n.createElement(ye,{html:e.assistantHtml})),e.error&&n.createElement("div",{className:"userflowjs-assistant-chat__error"},e.error)),e.sources&&e.sources.length>0&&n.createElement("div",{className:"userflowjs-assistant-chat__sources"},n.createElement("div",{className:"userflowjs-assistant-chat__sources-title"},t.sourcesText),e.sources.map((g,r)=>n.createElement("a",{key:r,className:"userflowjs-assistant-chat__source",href:Ie(g.url),target:"_blank",rel:"noreferrer noopener"},g.title))),a&&e.completed&&e.id&&(t.ratingMode===b.LIKE||t.ratingMode===b.SCALE&&l)&&n.createElement(Ae,{assistant:t,message:e,onSubmitRating:c,onSubmitFeedback:m})),Ae=({assistant:t,message:e,onSubmitRating:a,onSubmitFeedback:c})=>{const m=u.useRef(null),[f,h]=u.useState(""),l=i=>{const o=e.id;o&&(ee.flushSync(()=>{a({ratingMode:b.LIKE,messageId:o,rating:i})}),m.current?.focus({preventScroll:!0}))},g=i=>{const o=e.id;o&&(ee.flushSync(()=>{a({ratingMode:b.SCALE,messageId:o,scaleRating:i,scaleMax:t.scaleMax})}),m.current?.focus({preventScroll:!0}))},r=()=>{e.id&&(c({messageId:e.id,feedback:f.trim()}),h(""))},p=t.ratingMode===b.LIKE?n.createElement("button",{className:"userflowjs-assistant-chat__rating-option",disabled:!0},n.createElement(W,{icon:e.rating==y.DISLIKE?q:Q})):e.scaleRating&&e.scaleMax&&n.createElement("button",{className:F({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--scale":!0}),disabled:!0},oe(t,e.scaleRating,e.scaleMax));return n.createElement("div",{className:`userflowjs-assistant-chat__rating userflowjs-assistant-chat__rating--${t.ratingMode}`},t.ratingMode===b.SCALE&&n.createElement("div",{className:"userflowjs-assistant-chat__rating-question"},t.scaleQuestion),e.feedbackSubmitted?n.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks"},p,n.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks-message"},t.feedbackThanksText)):(t.ratingMode===b.LIKE?e.rating:e.scaleRating)?n.createElement(Se,{textareaRef:m,className:"userflowjs-growing-textarea userflowjs-assistant-chat__feedback-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea",placeholder:(t.ratingMode===b.LIKE?e.rating===y.LIKE?t.feedbackLikePlaceholder:t.feedbackDislikePlaceholder:t.scaleFeedbackPlaceholder)||"",value:f,onChange:h,onKeyDown:i=>{!i.shiftKey&&i.key==="Enter"&&(i.preventDefault(),r())}},p,n.createElement("button",{className:"userflowjs-assistant-chat__feedback-submit",onClick:()=>r()},n.createElement(W,{icon:_e}))):n.createElement("div",{className:"userflowjs-assistant-chat__rating-options"},t.ratingMode===b.LIKE?[y.LIKE,y.DISLIKE].map(i=>(!e.rating||e.rating===i)&&n.createElement("button",{key:i,className:"userflowjs-assistant-chat__rating-option",onClick:e.rating?void 0:()=>l(i),disabled:!!e.rating,"data-testid":`assistant-chat-rating-${i}`},n.createElement(W,{icon:i==y.DISLIKE?q:Q}))):Fe(t).map(({value:i,label:o})=>n.createElement("button",{key:i,className:F({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--large-scale":Re(o||"")}),onClick:e.scaleRating?void 0:()=>g(i),disabled:!!e.scaleRating,"data-testid":`assistant-chat-rating-${i}`},o))))};function B(t){let e=t;const a=f=>(f=f.replace(/\s*[*_`]*$/,""),f=f.replace(/(^|\n)\s*(\d+\.?|-|=)$/,""),f);e=a(e),e=e.replace(/\[([^\]\n]*)(\](\([^)\n]*)?)?$/,"$1"),e=a(e);const c=Array.from(e.matchAll(/\n( *)```/g));if(c.length%2===1){const f=c[c.length-1][1];e+=`
|
|
1
|
+
import{r as u,R as n}from"./vendor.react.js";import{a1 as _,a2 as y,u as Y}from"./userflow.js";import{u as Ee}from"./client-context.js";import{D as q,E as Q,F as be,G as P,H as $,I as V,J as X,K as Z}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{p as _e}from"./vendor.dompurify.js";import{m as ke}from"./vendor.marked.js";import{o as F}from"./vendor.obj-str.js";import{A as we,d as Ie,G as Se}from"./ResourceCenterApp.js";import{f as je,R as Ce}from"./use-selector-element-monitoring.js";import{D as W}from"./stylesheets.js";import{U as ae}from"./roots.js";import{r as ee}from"./vendor.react-dom.js";import"./vendor.core-js.js";import{g as Me}from"./flow-condition-types.js";import{u as ve}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./flow-host.styl.js";import"./use-window-resize.js";import"./logomark.js";import"./ChecklistUI.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./FlowChrome.js";import"./use-element-rect.js";import"./vendor.bignumber.js.js";import"./index.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";import"./vendor.babel.runtime.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]="7a8edcec-ef9f-4197-b720-6d995039ef2b",t._sentryDebugIdIdentifier="sentry-dbid-7a8edcec-ef9f-4197-b720-6d995039ef2b")}catch{}})();function Re(t){const e=Intl.Segmenter;return e?/(\p{Emoji_Presentation}|\p{Extended_Pictographic})(\p{Emoji_Modifier_Base}?\p{Emoji_Modifier}?|\uFE0F\u200D(\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?\uFE0F\u200D)*\p{Emoji_Presentation}|\uFE0F\u200D\p{Extended_Pictographic})/u.test(t)&&[...new e().segment(t)].length===1:!1}const te=[];function Ne({assistant:t,lookupAttribute:e,initialConversationId:a,initialHistory:c,initialUserContent:m,onConversationIdChange:f,submitMessage:h,submitRating:l,submitFeedback:g,InsideMessage:r,onContactClick:p,contactButtonText:i}){const[o,d]=u.useState(null),[S,w]=u.useState(()=>c?c.map(s=>({...s,assistantHtml:x(B(s.assistantContent),!1)})):te),[D,M]=u.useState(""),j=u.useRef(null),k=u.useRef(null),b=u.useRef(!0),I=u.useRef(a||null),[ce,le]=u.useState(I.current),H=u.useCallback(s=>{I.current=s,le(s),f&&f(s)},[f]),T=u.useCallback(()=>{o?.focus({preventScroll:!0})},[o]);u.useEffect(()=>{T()},[T]),u.useLayoutEffect(()=>{const s=k.current;s&&(s.scrollTop=Math.ceil(s.scrollHeight-s.clientHeight))},[]);const K=u.useCallback(()=>{const s=k.current;s&&(b.current=!0,typeof s.scrollTo=="function"&&s.scrollTo({top:Math.ceil(s.scrollHeight-s.clientHeight),behavior:"smooth"}))},[]),G=u.useRef(0);u.useLayoutEffect(()=>{const s=k.current;s&&s.scrollHeight!==G.current&&(G.current=s.scrollHeight,b.current&&K())},[S,K]);const N=u.useCallback(()=>{j.current&&j.current()},[]);u.useEffect(()=>()=>{N()},[N]);const O=(s,R)=>{w(C=>C.map(v=>{if(s===v.id){const E=R(v);return{...v,...E}}else return v}))},L=s=>{w(R=>R.map((C,v)=>{if(v===R.length-1){const E=s(C);return{...C,...E}}else return C}))},U=u.useCallback(async s=>{if(s=s.trim(),s==="")return;N(),w(E=>[...E,{id:null,userContent:s,assistantContent:"",assistantHtml:x("","enter"),enterAnimation:!0,sources:[],completed:!1,rating:null,scaleRating:null,scaleMax:null,feedbackSubmitted:!1}]),M(""),K();let R=!1;const C=()=>{R=!0,j.current=null},v=h({conversationId:I.current,userContent:s,callback:E=>{if(R){console.log("Userflow.js AssistantChat got message after being done",E);return}switch(E.kind){case"conversation_created":H(E.conversationId);break;case"message_created":L(()=>({id:E.messageId,warning:E.warning}));break;case"assistant_content_delta":L(A=>{const he=E.delta,z=A.assistantContent+he,ge=B(z),pe=x(ge);return{assistantContent:z,assistantHtml:pe}});break;case"done":C(),L(A=>({assistantHtml:x(A.assistantContent,"exit"),completed:!0,sources:E.sources}));break;case"error":C(),L(A=>({failed:!0,error:E.message,assistantHtml:x(B(A.assistantContent),!1)}));break;default:console.log("Userflow.js AssistantChat got unknown message",E)}}});j.current=()=>{C(),v.abort(),L(E=>({assistantHtml:x(B(E.assistantContent),!1)}))}},[N,K,h,H]),J=u.useRef(!1);u.useEffect(()=>{J.current||(J.current=!0,m&&U(m))},[U,m]);const ie=u.useCallback(()=>{N(),H(null),w(te),T()},[N,T,H]),[ue,fe]=u.useState(!0),de=u.useCallback(()=>{const s=k.current;s&&fe(s.scrollTop===0)},[]),me=u.useCallback(()=>{const s=k.current;s&&(b.current=Math.ceil(s.scrollHeight-s.clientHeight)==Math.ceil(s.scrollTop))},[]);return{assistant:t,lookupAttribute:e,history:S,setInput:d,contentElRef:k,scrolledToTop:ue,userContent:D,setUserContent:M,onSubmitMessage:U,supportsFeedback:!!l&&!!g,onSubmitRating:s=>{if(l){switch(s.ratingMode){case _.LIKE:O(s.messageId,()=>({rating:s.rating}));break;case _.SCALE:O(s.messageId,()=>({scaleRating:s.scaleRating,scaleMax:s.scaleMax}));break;default:throw new ae(s)}l(s)}},onSubmitFeedback:s=>{g&&(O(s.messageId,()=>({feedbackSubmitted:!0})),g(s))},InsideMessage:r,onContactClick:p,contactButtonText:i,reset:ie,onContentScroll:de,onContentWheel:me,conversationId:ce}}const xe=({assistant:t,lookupAttribute:e,history:a,setInput:c,contentElRef:m,scrolledToTop:f,userContent:h,setUserContent:l,onSubmitMessage:g,supportsFeedback:r,onSubmitRating:p,onSubmitFeedback:i,InsideMessage:o,onContactClick:d,contactButtonText:S,reset:w,onContentScroll:D,onContentWheel:M,conversationId:j})=>{const k=a.some(b=>b.completed||b.failed);return n.createElement("div",{className:"userflowjs-assistant-chat"},n.createElement("div",{className:F({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})}),n.createElement("div",{className:F({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})},n.createElement(n.Fragment,null,n.createElement("h2",{className:"userflowjs-assistant-chat__title"},t.title),n.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:w},t.resetText))),n.createElement("div",{ref:m,className:"userflowjs-assistant-chat__content",onScroll:D,onWheel:M},!je(t.intro)&&n.createElement("div",{className:"userflowjs-assistant-chat__intro"},n.createElement(Ce,{doc:t.intro,lookupAttribute:e})),a.map((b,I)=>n.createElement(Le,{key:I,assistant:t,message:b,supportsFeedback:r,onSubmitRating:p,onSubmitFeedback:i,InsideMessage:o,conversationId:j,isLast:I===a.length-1}))),n.createElement("div",{className:"userflowjs-assistant-chat__prompt"},n.createElement(we,{textareaRef:c,placeholder:(a.length===0?t.promptEmptyPlaceholder:t.promptNonemptyPlaceholder)||"",value:h,onChange:l,onSubmit:()=>g(h)})),k&&d&&n.createElement("div",{className:"userflowjs-assistant-chat__contact"},n.createElement("button",{className:"userflowjs-tertiary-button",onClick:()=>d()},S)))},Le=({assistant:t,message:e,supportsFeedback:a,onSubmitRating:c,onSubmitFeedback:m,InsideMessage:f,conversationId:h,isLast:l})=>n.createElement("div",{className:"userflowjs-assistant-chat__message"},f&&n.createElement(f,{message:e}),n.createElement("div",{className:F({"userflowjs-assistant-chat__user-content":!0,"userflowjs-assistant-chat__user-content--enter":!!e.enterAnimation}),"data-assistant-conversation-id":h,"data-assistant-message-id":e.id},n.createElement("div",{style:{whiteSpace:"pre-wrap"}},e.userContent)),e.warning&&n.createElement("div",{className:"userflowjs-assistant-chat__error"},"Warning: ",e.warning),n.createElement("div",{className:"userflowjs-assistant-chat__assistant-content"},n.createElement("div",null,n.createElement(ye,{html:e.assistantHtml})),e.error&&n.createElement("div",{className:"userflowjs-assistant-chat__error"},e.error)),e.sources&&e.sources.length>0&&n.createElement("div",{className:"userflowjs-assistant-chat__sources"},n.createElement("div",{className:"userflowjs-assistant-chat__sources-title"},t.sourcesText),e.sources.map((g,r)=>n.createElement("a",{key:r,className:"userflowjs-assistant-chat__source",href:Ie(g.url),target:"_blank",rel:"noreferrer noopener"},g.title))),a&&e.completed&&e.id&&(t.ratingMode===_.LIKE||t.ratingMode===_.SCALE&&l)&&n.createElement(Ae,{assistant:t,message:e,onSubmitRating:c,onSubmitFeedback:m})),Ae=({assistant:t,message:e,onSubmitRating:a,onSubmitFeedback:c})=>{const m=u.useRef(null),[f,h]=u.useState(""),l=i=>{const o=e.id;o&&(ee.flushSync(()=>{a({ratingMode:_.LIKE,messageId:o,rating:i})}),m.current?.focus({preventScroll:!0}))},g=i=>{const o=e.id;o&&(ee.flushSync(()=>{a({ratingMode:_.SCALE,messageId:o,scaleRating:i,scaleMax:t.scaleMax})}),m.current?.focus({preventScroll:!0}))},r=()=>{e.id&&(c({messageId:e.id,feedback:f.trim()}),h(""))},p=t.ratingMode===_.LIKE?n.createElement("button",{className:"userflowjs-assistant-chat__rating-option",disabled:!0},n.createElement(W,{icon:e.rating==y.DISLIKE?q:Q})):e.scaleRating&&e.scaleMax&&n.createElement("button",{className:F({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--scale":!0}),disabled:!0},oe(t,e.scaleRating,e.scaleMax));return n.createElement("div",{className:`userflowjs-assistant-chat__rating userflowjs-assistant-chat__rating--${t.ratingMode}`},t.ratingMode===_.SCALE&&n.createElement("div",{className:"userflowjs-assistant-chat__rating-question"},t.scaleQuestion),e.feedbackSubmitted?n.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks"},p,n.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks-message"},t.feedbackThanksText)):(t.ratingMode===_.LIKE?e.rating:e.scaleRating)?n.createElement(Se,{textareaRef:m,className:"userflowjs-growing-textarea userflowjs-assistant-chat__feedback-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea",placeholder:(t.ratingMode===_.LIKE?e.rating===y.LIKE?t.feedbackLikePlaceholder:t.feedbackDislikePlaceholder:t.scaleFeedbackPlaceholder)||"",value:f,onChange:h,onKeyDown:i=>{!i.shiftKey&&i.key==="Enter"&&(i.preventDefault(),r())}},p,n.createElement("button",{className:"userflowjs-assistant-chat__feedback-submit",onClick:()=>r()},n.createElement(W,{icon:be}))):n.createElement("div",{className:"userflowjs-assistant-chat__rating-options"},t.ratingMode===_.LIKE?[y.LIKE,y.DISLIKE].map(i=>(!e.rating||e.rating===i)&&n.createElement("button",{key:i,className:"userflowjs-assistant-chat__rating-option",onClick:e.rating?void 0:()=>l(i),disabled:!!e.rating,"data-testid":`assistant-chat-rating-${i}`},n.createElement(W,{icon:i==y.DISLIKE?q:Q}))):Fe(t).map(({value:i,label:o})=>n.createElement("button",{key:i,className:F({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--large-scale":Re(o||"")}),onClick:e.scaleRating?void 0:()=>g(i),disabled:!!e.scaleRating,"data-testid":`assistant-chat-rating-${i}`},o))))};function B(t){let e=t;const a=f=>(f=f.replace(/\s*[*_`]*$/,""),f=f.replace(/(^|\n)\s*(\d+\.?|-|=)$/,""),f);e=a(e),e=e.replace(/\[([^\]\n]*)(\](\([^)\n]*)?)?$/,"$1"),e=a(e);const c=Array.from(e.matchAll(/\n( *)```/g));if(c.length%2===1){const f=c[c.length-1][1];e+=`
|
|
2
2
|
`+f+"```"}else{let f=0;for(let r=e.length-1;r>=0;r--)if(e[r]===`
|
|
3
3
|
`&&e[r-1]===`
|
|
4
|
-
`){f=r;break}const h=[];let l=!1;const g=r=>r==null||r.match(/\W/);for(let r=f;r<e.length;r++){const p=e[r],i=p+e[r+1],o=i+e[r+2];let d=null;!l&&o==="***"||!l&&o==="___"&&(g(e[r-1])||g(e[r+3]))?d=o:!l&&i==="**"||!l&&i==="__"&&(g(e[r-1])||g(e[r+2]))?d=i:(!l&&p==="*"||!l&&p==="_"&&(g(e[r-1])||g(e[r+1]))||p==="`")&&(d=p),d!=null&&(e.slice(f,r+d.length).match(/\[[^\]\n]*\]\([^)\n]*$/)||(h[h.length-1]===d?(d==="`"&&(l=!1),h.pop()):(d==="`"&&(l=!0),h.push(d))),r+=d.length-1)}e+=h.reverse().join("")}return e}function x(t,e){t=t.trim(),e!==!1&&(t=t.replace(/(\n *```)?$/," {{USERFLOWCHATBRAIN}}$1"));let a=
|
|
4
|
+
`){f=r;break}const h=[];let l=!1;const g=r=>r==null||r.match(/\W/);for(let r=f;r<e.length;r++){const p=e[r],i=p+e[r+1],o=i+e[r+2];let d=null;!l&&o==="***"||!l&&o==="___"&&(g(e[r-1])||g(e[r+3]))?d=o:!l&&i==="**"||!l&&i==="__"&&(g(e[r-1])||g(e[r+2]))?d=i:(!l&&p==="*"||!l&&p==="_"&&(g(e[r-1])||g(e[r+1]))||p==="`")&&(d=p),d!=null&&(e.slice(f,r+d.length).match(/\[[^\]\n]*\]\([^)\n]*$/)||(h[h.length-1]===d?(d==="`"&&(l=!1),h.pop()):(d==="`"&&(l=!0),h.push(d))),r+=d.length-1)}e+=h.reverse().join("")}return e}function x(t,e){t=t.trim(),e!==!1&&(t=t.replace(/(\n *```)?$/," {{USERFLOWCHATBRAIN}}$1"));let a=_e.sanitize(ke.parse(t));if(e!==!1){let c="userflowjs-assistant-brain";e&&(c+=` userflowjs-assistant-brain--${e}`),a=a.replace("{{USERFLOWCHATBRAIN}}",`<span class="${c}"><span></span><span></span><span></span><span></span></span>`)}return a=a.replace(/<a href=/g,'<a target="_blank" rel="noopener noreferrer" href='),a}const ye=({html:t})=>u.useMemo(()=>{if(!t)return null;const a=new DOMParser().parseFromString(t,"text/html");return re(a.body)},[t]);function re(t,e){if(t instanceof Element){if(t.tagName==="BODY")return n.createElement(n.Fragment,{key:e},se(t));{if(["script","style"].includes(t.tagName))return null;const a={key:e};for(const c of t.attributes){let m=c.name;m.startsWith("on")||(m==="class"&&(m="className"),a[m]=c.value)}return n.createElement(t.tagName.toLowerCase(),a,se(t))}}else return t instanceof Text?t.textContent:null}function se(t){const e=[];let a=0;for(const c of t.childNodes)e.push(re(c,a)),a++;return e}function Fe(t){let e=[];const a=t.scaleMax||5;for(let c=1;c<=a;c++)e.push({value:c,label:oe(t,c,a)});return e}function oe(t,e,a){if(t.scaleLabels)return t.scaleLabels[e-1]||e;{const c=ne[a]&&ne[a][e];return c?n.createElement(W,{icon:c,size:24}):e}}const ne={2:{1:P,2:$},3:{1:P,2:V,3:$},4:{1:X,2:P,3:$,4:Z},5:{1:X,2:P,3:V,4:$,5:Z}},ht=({block:t,session:e,assistantReply:a,initialUserContent:c,onContactClick:m,contactButtonText:f})=>{const h=t.assistantFlowId,l=Ee(),{t:g}=ve(),r=g("assistant.generic_error"),p=g("assistant.disconnected_error"),i=Ne(u.useMemo(()=>({assistant:a.assistant,lookupAttribute:Me(e.data),initialConversationId:a.conversationId,initialHistory:a.history,initialUserContent:c,onConversationIdChange:o=>{const d="assistantConversationId:"+h;o?Y.setItem(d,o):Y.removeItem(d)},submitMessage:({conversationId:o,userContent:d,callback:S})=>{l.assistantMessageInProgress=!0;const w=l.nextRef();l.send({kind:"SubmitAssistantMessage",ref:w,assistantFlowId:h,conversationId:o,userContent:d},{handlesRejection:!0}).catch(b=>{S({kind:"error",message:b.humanMessage||r})});const M=()=>{l.assistantMessageInProgress=void 0,l.off("private:assistantMessageEvent",j),l.off("private:disconnect",k)},j=b=>{if(b.ref!==w)return;const{event:I}=b;S(I),(I.kind=="done"||I.kind=="error")&&M()},k=()=>{S({kind:"error",message:p}),M()};return l.on("private:assistantMessageEvent",j),l.on("private:disconnect",k),{abort:()=>{l.send({kind:"AbortAssistantMessage"}),M()}}},submitRating:o=>{switch(o.ratingMode){case _.LIKE:l.send({kind:"SubmitAssistantRating",messageId:o.messageId,rating:o.rating});break;case _.SCALE:l.send({kind:"SubmitAssistantScaleRating",messageId:o.messageId,scaleRating:o.scaleRating,scaleMax:o.scaleMax});break;default:throw new ae(o)}},submitFeedback:o=>{l.send({kind:"SubmitAssistantFeedback",messageId:o.messageId,feedback:o.feedback})},onContactClick:m,contactButtonText:f}),[a,h,l,c,e.data,m,f,r,p]));return n.createElement(n.Fragment,null,n.createElement(xe,{...i}))};export{ht as ResourceCenterAssistantChat};
|
|
5
5
|
//# sourceMappingURL=ResourceCenterAssistantChat.js.map
|
package/TrackerTestingApp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as c,R as r}from"./vendor.react.js";import{u as y}from"./client-context.js";import{B as T}from"./BuilderBar.js";import{c as E}from"./flow-condition-types.js";import{
|
|
1
|
+
import{r as c,R as r}from"./vendor.react.js";import{u as y}from"./client-context.js";import{B as T}from"./BuilderBar.js";import{c as E}from"./flow-condition-types.js";import{K as I}from"./userflow.js";import"./vendor.core-js.js";import"./vendor.object-assign.js";import"./vendor.i18next.js";import"./vendor.react-i18next.js";import"./vendor.babel.runtime.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./stylesheets.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./logomark.js";import"./vendor.obj-str.js";import"./vendor.fortawesome.pro-light-svg-icons.js";import"./vendor.date-fns.js";import"./roots.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="78dad523-0394-4b3b-a034-6e0fb1c9fb6b",t._sentryDebugIdIdentifier="sentry-dbid-78dad523-0394-4b3b-a034-6e0fb1c9fb6b")}catch{}})();const J=({state:t})=>{const e=y(),[o,d]=c.useState("notIdentified");c.useEffect(()=>{let n=!1,i,a;function k(){i=()=>{e.off("private:identified",i),b()},e.isIdentified()?i():e.on("private:identified",i)}const b=async()=>{d("trackerLoading");const{tracker:l}=await e.send({kind:"GetTrackerForTesting",token:t.token});if(n)return;const{condition:f}=l,g=E[f.type];let m=!1;a=g.track({sessionData:new I(l.data),condition:f,flipBackEvents:!0,callback:p=>{const v=m;m=p,!v&&p&&e.setSessionStorageState(s=>({...s,trackerTesting:{...s.trackerTesting,events:s.trackerTesting.events+1}}))}}),d("trackerLoaded")};return k(),()=>{n=!0,i&&e.off("private:identified",i),a&&a()}},[e,t.token]);const u=c.useCallback(async()=>{e.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null})),e.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerClosed"})},[e]);return r.createElement(T,{buttons:r.createElement("button",{className:"btn btn--default",onClick:()=>u()},"Back to Builder")},r.createElement("div",null,r.createElement("div",{className:"label"},"Testing tracker: ",t.trackerName),o==="notIdentified"?r.createElement("div",null,"Waiting for your app to identify user..."):o==="trackerLoading"?r.createElement("div",null,"Loading tracker..."):t.events===0?r.createElement("div",{className:"error"},"Not tracked yet"):r.createElement("div",{className:"success"},"Tracked ",t.events," time",t.events===1?"":"s")))};export{J as TrackerTestingApp,J as default};
|
|
2
2
|
//# sourceMappingURL=TrackerTestingApp.js.map
|
package/bubble-frame.css
CHANGED
|
@@ -170,6 +170,29 @@
|
|
|
170
170
|
background-position: top center;
|
|
171
171
|
padding: 24px;
|
|
172
172
|
}
|
|
173
|
+
.userflowjs-embedded-checklist {
|
|
174
|
+
position: relative;
|
|
175
|
+
overflow: hidden;
|
|
176
|
+
background-color: var(--userflow-main-background-color, #fff);
|
|
177
|
+
background-repeat: no-repeat;
|
|
178
|
+
background-size: 100%;
|
|
179
|
+
background-position: top center;
|
|
180
|
+
}
|
|
181
|
+
.userflowjs-embed-wrapper {
|
|
182
|
+
position: relative;
|
|
183
|
+
width: 100%;
|
|
184
|
+
}
|
|
185
|
+
.userflowjs-embed-root-blocks {
|
|
186
|
+
padding: 20px;
|
|
187
|
+
}
|
|
188
|
+
.userflowjs-embed-root {
|
|
189
|
+
position: relative;
|
|
190
|
+
overflow: hidden;
|
|
191
|
+
background-color: var(--userflow-main-background-color, #fff);
|
|
192
|
+
background-repeat: no-repeat;
|
|
193
|
+
background-size: 100%;
|
|
194
|
+
background-position: top center;
|
|
195
|
+
}
|
|
173
196
|
.userflowjs-bubble-frame-root--appearance-modal {
|
|
174
197
|
padding: var(--userflow-modal-padding);
|
|
175
198
|
padding-top: var(--userflow-modal-padding-top);
|
|
@@ -1338,14 +1361,17 @@
|
|
|
1338
1361
|
.userflowjs-bubble-task--just-completed .userflowjs-bubble-task__checkmark {
|
|
1339
1362
|
animation: userflowjs-bubble-task-just-completed 500ms ease-out;
|
|
1340
1363
|
}
|
|
1341
|
-
.userflowjs-bubble-frame-root .userflowjs-bubble-task
|
|
1364
|
+
.userflowjs-bubble-frame-root .userflowjs-bubble-task,
|
|
1365
|
+
.userflowjs-embedded-checklist .userflowjs-bubble-task {
|
|
1342
1366
|
padding: 0.5rem 24px;
|
|
1343
1367
|
transition: background 200ms cubic-bezier(0.25, 0.8, 0.5, 1), box-shadow 200ms cubic-bezier(0.25, 0.8, 0.5, 1);
|
|
1344
1368
|
}
|
|
1345
|
-
.userflowjs-bubble-frame-root .userflowjs-bubble-task:hover
|
|
1369
|
+
.userflowjs-bubble-frame-root .userflowjs-bubble-task:hover,
|
|
1370
|
+
.userflowjs-embedded-checklist .userflowjs-bubble-task:hover {
|
|
1346
1371
|
background-color: rgba(var(--userflow-main-foreground-color-rgb), 0.05);
|
|
1347
1372
|
}
|
|
1348
|
-
.userflowjs-bubble-frame-root .userflowjs-bubble-task:hover .userflowjs-bubble-task__arrow
|
|
1373
|
+
.userflowjs-bubble-frame-root .userflowjs-bubble-task:hover .userflowjs-bubble-task__arrow,
|
|
1374
|
+
.userflowjs-embedded-checklist .userflowjs-bubble-task:hover .userflowjs-bubble-task__arrow {
|
|
1349
1375
|
opacity: 1;
|
|
1350
1376
|
transform: translateX(0px);
|
|
1351
1377
|
transition: transform 200ms cubic-bezier(0.25, 0.8, 0.5, 1), opacity 200ms linear;
|
|
@@ -1463,6 +1489,15 @@
|
|
|
1463
1489
|
.userflowjs-banner-root--content-layout-SPACE_BETWEEN .userflowjs-banner-inner {
|
|
1464
1490
|
justify-content: space-between;
|
|
1465
1491
|
}
|
|
1492
|
+
.userflowjs-embed-root--content-layout-START .userflowjs-banner-inner {
|
|
1493
|
+
justify-content: start;
|
|
1494
|
+
}
|
|
1495
|
+
.userflowjs-embed-root--content-layout-CENTER .userflowjs-banner-inner {
|
|
1496
|
+
justify-content: center;
|
|
1497
|
+
}
|
|
1498
|
+
.userflowjs-embed-root--content-layout-SPACE_BETWEEN .userflowjs-banner-inner {
|
|
1499
|
+
justify-content: space-between;
|
|
1500
|
+
}
|
|
1466
1501
|
.userflowjs-banner-inner {
|
|
1467
1502
|
min-width: 0;
|
|
1468
1503
|
flex: 1000000 1 0%;
|
package/flow-condition-types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{N as c,O as T,Q as y,W as X,X as Y,Y as L}from"./userflow.js";import"./vendor.core-js.js";import{i as S,a as I,b as z,p as P,c as j,s as Z}from"./vendor.date-fns.js";import{M as q,o as G,f as x,u as F,v as Q}from"./roots.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]="c1f9d0fa-4048-4205-a632-cadb3ebf2661",e._sentryDebugIdIdentifier="sentry-dbid-c1f9d0fa-4048-4205-a632-cadb3ebf2661")}catch{}})();const K=/(\\*)\{\{([a-zA-Z0-9_.\\/]+)\}\}/g;function J(e,t){return(e||"").replace(K,(r,n,s)=>{const a=n.length;return a%2===0?"\\".repeat(a/2)+(t(s)||""):"\\".repeat((a-1)/2)+"{{"+s+"}}"})}function ee(e){let t=null;return r=>(t||(t=new Map,e.forEach(({name:n,value:s})=>t.set(n,Array.isArray(s)?s[0]:s))),t.get(r)||null)}function g(e,t){const r=ee(t);return J(e,n=>r(n))}function U(e,t){const r=M(e,t),n=e.nearSelector&&M(e.nearSelector,t);return e===r&&e.nearSelector===n?e:e.nearSelector===n?r:{...r,nearSelector:n}}function M(e,t){if(!e.text)return e;const r=g(e.text,t);return r===e.text?e:{...e,text:r}}function te(e,t){return e.includes.length===0&&e.excludes.length===0?!1:(e.includes.length===0||e.includes.some(r=>{const n=W(r);return n&&t.match(n)}))&&!e.excludes.some(r=>{const n=W(r);return n&&t.match(n)})}function re(e){const t=e.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);if(!t)return null;const[,,r,n,s,,a,i]=t;return{scheme:r||"",domain:n||"",path:s||"",query:a||"",fragment:i||""}}function W(e){const t=re(e);if(!t)return console.error("Userflow: Invalid URL pattern:",e),null;const{scheme:r,domain:n,path:s,query:a,fragment:i}=t;let l;r?l=O(r):l="[a-z\\d]+";let f;n?f=A(n,"[^/]","."):f="[^/]*";const o="(:\\d+)?";let p;s?p=A(s,"[^?#]","/"):p="/[^?#]*";let E;a?(E="",new URLSearchParams(a).forEach((d,w)=>{let b;d===""?b="=?":d==="*"?b="(=[^&#]*)?":(d=d.split(/\*/g).map($=>encodeURI($)).join("*"),b="="+A(d,"[^#]")),E+="(?=.*[?&]"+O(w)+b+"([&#]|$))"}),E+="\\?[^#]*"):E="(\\?[^#]*)?";let m;return i?m=A(i,".","/"):m="(#.*)?",new RegExp("^"+l+"://"+f+o+p+E+m+"$")}function A(e,t,r){return e=O(e),e=e.replace(/\\\*/g,t+"*"),r&&(e=e.replace(/:[a-zA-Z0-9_]+/g,"[^"+r+"]+")),e}function O(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}const _={[c.ABSOLUTE_EQ]:{compare:({condition:e,value:t})=>{const r=h(t),n=N(e.value,"00:00:00.000"),s=N(e.value,"23:59:59.999");return r!=null&&n!=null&&s!=null&&!S(r,n)&&!I(r,s)}},[c.ABSOLUTE_GT]:{compare:({condition:e,value:t})=>{const r=h(t),n=N(e.value,"23:59:59.999");return r!=null&&n!=null&&I(r,n)}},[c.ABSOLUTE_LT]:{compare:({condition:e,value:t})=>{const r=h(t),n=N(e.value,"00:00:00.000");return r!=null&&n!=null&&S(r,n)}},[c.AND]:{compare:()=>V("AND.compare")},[c.BETWEEN]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&!!e.value2&&parseFloat(v(t))>=parseFloat(e.value)&&parseFloat(v(t))<=parseFloat(e.value2)},[c.CONTAINS]:{compare:({sessionData:e,condition:t,value:r})=>!!r&&v(r).toLowerCase().includes(g(t.value||"",e).toLowerCase())},[c.EMPTY]:{compare:({value:e})=>e==null||e===""||Array.isArray(e)&&e.length===0},[c.ENDS_WITH]:{compare:({sessionData:e,condition:t,value:r})=>!!r&&v(r).toLowerCase().endsWith(g(t.value||"",e).toLowerCase())},[c.EQ]:{compare:({sessionData:e,condition:t,value:r})=>g(t.value||"",e)===v(r)},[c.EXCLUDES_ALL]:{compare:({condition:e,value:t})=>{const r=new Set(D(t));return!(e.values||[]).some(n=>r.has(n))}},[c.EXCLUDES_ANY]:{compare:({condition:e,value:t})=>{const r=new Set(D(t));return!(e.values||[]).every(n=>r.has(n))}},[c.FALSE]:{compare:({value:e})=>v(e).toLowerCase()==="false"},[c.GT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(v(t))>parseFloat(e.value)},[c.GTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(v(t))>=parseFloat(e.value)},[c.INCLUDES_ALL]:{compare:({condition:e,value:t})=>{const r=new Set(D(t));return(e.values||[]).every(n=>r.has(n))}},[c.INCLUDES_ANY]:{compare:({condition:e,value:t})=>{const r=new Set(D(t));return(e.values||[]).some(n=>r.has(n))}},[c.LT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(v(t))<parseFloat(e.value)},[c.LTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(v(t))<=parseFloat(e.value)},[c.NE]:{compare:({sessionData:e,condition:t,value:r})=>g(t.value||"",e)!==v(r)},[c.NOT_CONTAINS]:{compare:({sessionData:e,condition:t,value:r})=>!r||!v(r).toLowerCase().includes(g(t.value||"",e).toLowerCase())},[c.NOT_EMPTY]:{compare:({value:e})=>e!=null&&e!==""&&(!Array.isArray(e)||e.length>0)},[c.NOT_REGEX]:{compare:({condition:e,value:t})=>!B(e,t)},[c.OR]:{compare:()=>V("OR.compare")},[c.REGEX]:{compare:({condition:e,value:t})=>B(e,t)},[c.RELATIVE_EQ]:{compare:({condition:e,value:t})=>{const r=h(t),n=k(e.value);return r==null||n==null?!1:!S(r,n)&&S(r,z(n,1))}},[c.RELATIVE_GT]:{compare:({condition:e,value:t})=>{const r=h(t),n=k(e.value);return r==null||n==null?!1:I(r,n)}},[c.RELATIVE_LT]:{compare:({condition:e,value:t})=>{const r=h(t),n=k(e.value);return r==null||n==null?!1:S(r,n)}},[c.STARTS_WITH]:{compare:({sessionData:e,condition:t,value:r})=>!!r&&v(r).toLowerCase().startsWith(g(t.value||"",e).toLowerCase())},[c.TRUE]:{compare:({value:e})=>v(e).toLowerCase()==="true"},[c.URL]:{compare:({condition:e,value:t})=>e.urlPattern&&t!=null?te(e.urlPattern,v(t)):!1}};function V(e){throw new Error(`conditionOperators.${e} is not supported`)}function h(e){if(Array.isArray(e)&&(e=e[0]),!e)return null;e.match(/(Z|((\+|-)\d\d:\d\d))$/i)||(e+="Z");const t=P(e);return j(t)?t:null}function N(e,t){if(!e)return null;e+="T"+t+"Z";const r=P(e);return j(r)?r:null}function k(e){if(!e)return null;const t=parseInt(e,10);return isNaN(t)?null:Z(Date.now(),t)}function B(e,t){return e.value?new RegExp(e.value).test(v(t)):!1}function v(e){return Array.isArray(e)?e[0]:e??""}function D(e){return Array.isArray(e)?e:e===""||e==null?[]:[e]}const ne=50,se=1e3;function R(e,t={}){let r,n;const s=()=>{n=void 0,e()},a=()=>{if(window.clearTimeout(r),n==null)n=Date.now();else if(Date.now()-n>se){s();return}r=window.setTimeout(s,ne)},i=o=>{const p=o.target;if(!p||!H(p))return;const E=document.getElementById("userflow-ui");E&&E.contains(p)||a()},l=new q(o=>{ae(o)||a()}),f=G(o=>{l.observe(o,{attributes:!0,subtree:!0,childList:!0,characterData:!0}),o.addEventListener("animationend",i),o.addEventListener("transitionend",i),t.observeInput&&(o.addEventListener("input",a),o.addEventListener("keypress",a),o.addEventListener("change",a))},o=>{o.removeEventListener("animationend",i),o.removeEventListener("transitionend",i),t.observeInput&&(o.removeEventListener("input",a),o.removeEventListener("keypress",a),o.removeEventListener("change",a))});return{disconnect:()=>{window.clearTimeout(r),l.disconnect(),f()}}}function ae(e){const t=document.getElementById("userflow-ui");for(const r of e){const{target:n}=r;if(H(n)&&t&&t.contains(n))return!0}return!1}function H(e){return e.nodeType===Node.ELEMENT_NODE}const C={[T.ALWAYS_TRUE]:{track:({callback:e})=>(e(!0),()=>{})},[T.ATTRIBUTE]:{track:({sessionData:e,condition:t,callback:r})=>{const n=()=>{let a=!1;if(e&&t.operator){const i=e.value.find(o=>o.name===t.attributeName),l=i?i.value:null;a=_[t.operator].compare({sessionData:e.value,condition:t,value:l})}r(a)};n();const s=e.observe(n);return()=>{s()}}},[T.CLAUSE]:{isExpensive:e=>{for(const t of e.conditions){const r=C[t.type];if(r.isExpensive&&r.isExpensive(t))return!0}return!1},track:({sessionData:e,condition:t,flipBackEvents:r,callback:n,description:s})=>{let a,i,l=null;const f=t.conditions.map(m=>{const u=C[m.type];return{condition:m,typeDef:u,expensive:!!u.isExpensive&&u.isExpensive(m),active:!1,isTrue:null}}),o=m=>{for(const u of f){const d=!r||!u.expensive||m;d&&!u.active?(u.active=!0,u.isTrue=!1,u.untrack=u.typeDef.track({sessionData:e,condition:u.condition,flipBackEvents:r,callback:(w,b={})=>{u.isTrue=w,window.clearTimeout(a),b.immediate?p({immediate:!0}):a=window.setTimeout(p,0)},description:s})):!d&&u.active&&(u.untrack&&u.untrack(),u.active=!1,u.isTrue=null,u.untrack=void 0)}},p=(m={})=>{if(f.length===0){E(!1,m);return}let u,d;if(t.operator===c.AND){u=!0,d=!0;for(const w of f)w.isTrue===!1?(u=!1,w.expensive||(d=!1)):u!==!1&&w.isTrue===null&&(u=null)}else{u=!1,d=!0;for(const w of f)w.isTrue===!0?(u=!0,w.expensive||(d=!1)):u!==!0&&w.isTrue===null&&(u=null)}u!==null&&u!==l&&(l=u,E(u,m)),o(d)},E=(m,u)=>{if(!m||t.waitTime==null||t.waitTime=="0")window.clearTimeout(i),i=void 0,n(m,u);else if(!i){const d=parseFloat(t.waitTime)*1e3;i=window.setTimeout(()=>{n(!0,{})},d)}};return o(!1),p(),()=>{window.clearTimeout(a),window.clearTimeout(i);for(const m of f)m.untrack&&m.untrack()}}},[T.ELEMENT]:{isExpensive:()=>!0,track:e=>{const{elementState:t}=e.condition;if(!t)return()=>{};const r=oe(t);switch(r.kind){case"observer":return le(e,r.checkElement);case"event":return ue(e,r.eventName,r.valueWhenOccurred)}}},[T.FILLED_IN_INPUT]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:r})=>{let n=null,s;const a=()=>{if(!t.selector){console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);return}const f=x(U(t.selector,e.value));let o=null;for(const p of f){const E=F(p);if(E){o=E;break}}o?o!=n&&(window.clearTimeout(s),s=window.setTimeout(()=>{r(!0)},1e3)):(r(!1),window.clearTimeout(s)),n=o};a();const i=e.observe(a),{disconnect:l}=R(a,{observeInput:!0});return()=>{i(),l(),window.clearTimeout(s)}}},[T.FLOW]:{track:()=>(console.warn("Userflow.js: Flow conditions do not work client-side"),()=>{})},[T.INPUT_VALUE]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:r})=>{const n=()=>{if(!t.operator){console.warn("Userflow.js: INPUT_VALUE condition missing operator",t);return}if(!t.selector){console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);return}let i=!1;const l=_[t.operator],f=x(U(t.selector,e.value));if(f.length>0)for(const o of f){const p=F(o);if(l.compare({sessionData:e.value,condition:t,value:p})){i=!0;break}}else l.compare({sessionData:e.value,condition:t,value:""})&&(i=!0);r(i)};n();const s=e.observe(n),{disconnect:a}=R(n,{observeInput:!0});return()=>{s(),a()}}},[T.PAGE]:{track:({sessionData:e,condition:t,callback:r})=>{const n=()=>{let l=!1;if(t.operator){const f=y();l=_[t.operator].compare({sessionData:e.value,condition:t,value:f})}r(l)};let s=y();const a=()=>{const l=y();l!==s&&(s=l,n())};X(a),n();const i=e.observe(n);return()=>{i(),Y(a)}}},[T.SEGMENT]:{track:({description:e,callback:t})=>(console.error("Userflow.js: Segment conditions are not supported in "+(e||"unknown content item")+"."),t(!1),()=>{})},[T.TIME]:{track:({condition:e,callback:t})=>{let r=null;const n=e.value?new Date(e.value):null,s=e.value2?new Date(e.value2):null,a=()=>{let l=!0;(n&&!isNaN(n.valueOf())&&Date.now()<n.valueOf()||s&&!isNaN(s.valueOf())&&Date.now()>=s.valueOf())&&(l=!1),l!==r&&(r=l,t(l))};a();const i=window.setInterval(a,10*1e3);return()=>{window.clearInterval(i)}}}};function oe(e){switch(e){case L.CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!0};case L.DISABLED:return{kind:"observer",checkElement:t=>!!t&&t.disabled};case L.MOUSEDOWN:return{kind:"event",eventName:"mousedown",valueWhenOccurred:!0};case L.NOT_CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!1};case L.NOT_DISABLED:return{kind:"observer",checkElement:t=>!!t&&!t.disabled};case L.NOT_PRESENT:return{kind:"observer",checkElement:t=>!t};case L.PRESENT:return{kind:"observer",checkElement:t=>!!t}}}function le({sessionData:e,condition:t,callback:r},n){const s=()=>{if(!t.elementState){console.warn("Userflow.js: ELEMENT_STATE condition missing elementState",t);return}if(!t.selector){console.warn("Userflow.js: ELEMENT_STATE condition missing selector",t);return}let l=!1;const f=x(U(t.selector,e.value));if(f.length>0){for(const o of f)if(n(o)){l=!0;break}}else n(null)&&(l=!0);r(l)};s();const a=e.observe(s),{disconnect:i}=R(s);return()=>{a(),i()}}function ue({condition:e,flipBackEvents:t,callback:r},n,s){const{selector:a}=e;if(!a)return()=>{};r(!s);const i=o=>{const p=o.target;p&&Q(p,a)&&(t?(r(s,{immediate:!0}),r(!s,{immediate:!0})):r(s))},l={capture:!0},f=G(o=>o.addEventListener(n,i,l),o=>o.removeEventListener(n,i,l));return()=>{f()}}const me=Object.freeze(Object.defineProperty({__proto__:null,conditionTypes:C},Symbol.toStringTag,{value:"Module"}));export{g as a,J as b,C as c,me as f,ee as g,U as i,R as o};
|
|
1
|
+
import{O as c,Q as T,W as y,X,Y,Z as L}from"./userflow.js";import"./vendor.core-js.js";import{i as S,a as I,b as Z,p as P,c as j,s as z}from"./vendor.date-fns.js";import{M as q,o as G,f as x,u as F,v as Q}from"./roots.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]="27417aa6-0375-4b42-b130-1a09d4740f96",e._sentryDebugIdIdentifier="sentry-dbid-27417aa6-0375-4b42-b130-1a09d4740f96")}catch{}})();const K=/(\\*)\{\{([a-zA-Z0-9_.\\/]+)\}\}/g;function J(e,t){return(e||"").replace(K,(r,n,s)=>{const a=n.length;return a%2===0?"\\".repeat(a/2)+(t(s)||""):"\\".repeat((a-1)/2)+"{{"+s+"}}"})}function ee(e){let t=null;return r=>(t||(t=new Map,e.forEach(({name:n,value:s})=>t.set(n,Array.isArray(s)?s[0]:s))),t.get(r)||null)}function g(e,t){const r=ee(t);return J(e,n=>r(n))}function U(e,t){const r=M(e,t),n=e.nearSelector&&M(e.nearSelector,t);return e===r&&e.nearSelector===n?e:e.nearSelector===n?r:{...r,nearSelector:n}}function M(e,t){if(!e.text)return e;const r=g(e.text,t);return r===e.text?e:{...e,text:r}}function te(e,t){return e.includes.length===0&&e.excludes.length===0?!1:(e.includes.length===0||e.includes.some(r=>{const n=W(r);return n&&t.match(n)}))&&!e.excludes.some(r=>{const n=W(r);return n&&t.match(n)})}function re(e){const t=e.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);if(!t)return null;const[,,r,n,s,,a,i]=t;return{scheme:r||"",domain:n||"",path:s||"",query:a||"",fragment:i||""}}function W(e){const t=re(e);if(!t)return console.error("Userflow: Invalid URL pattern:",e),null;const{scheme:r,domain:n,path:s,query:a,fragment:i}=t;let l;r?l=O(r):l="[a-z\\d]+";let f;n?f=A(n,"[^/]","."):f="[^/]*";const o="(:\\d+)?";let p;s?p=A(s,"[^?#]","/"):p="/[^?#]*";let E;a?(E="",new URLSearchParams(a).forEach((d,w)=>{let b;d===""?b="=?":d==="*"?b="(=[^&#]*)?":(d=d.split(/\*/g).map($=>encodeURI($)).join("*"),b="="+A(d,"[^#]")),E+="(?=.*[?&]"+O(w)+b+"([&#]|$))"}),E+="\\?[^#]*"):E="(\\?[^#]*)?";let m;return i?m=A(i,".","/"):m="(#.*)?",new RegExp("^"+l+"://"+f+o+p+E+m+"$")}function A(e,t,r){return e=O(e),e=e.replace(/\\\*/g,t+"*"),r&&(e=e.replace(/:[a-zA-Z0-9_]+/g,"[^"+r+"]+")),e}function O(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}const _={[c.ABSOLUTE_EQ]:{compare:({condition:e,value:t})=>{const r=h(t),n=D(e.value,"00:00:00.000"),s=D(e.value,"23:59:59.999");return r!=null&&n!=null&&s!=null&&!S(r,n)&&!I(r,s)}},[c.ABSOLUTE_GT]:{compare:({condition:e,value:t})=>{const r=h(t),n=D(e.value,"23:59:59.999");return r!=null&&n!=null&&I(r,n)}},[c.ABSOLUTE_LT]:{compare:({condition:e,value:t})=>{const r=h(t),n=D(e.value,"00:00:00.000");return r!=null&&n!=null&&S(r,n)}},[c.AND]:{compare:()=>V("AND.compare")},[c.BETWEEN]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&!!e.value2&&parseFloat(v(t))>=parseFloat(e.value)&&parseFloat(v(t))<=parseFloat(e.value2)},[c.CONTAINS]:{compare:({sessionData:e,condition:t,value:r})=>!!r&&v(r).toLowerCase().includes(g(t.value||"",e).toLowerCase())},[c.EMPTY]:{compare:({value:e})=>e==null||e===""||Array.isArray(e)&&e.length===0},[c.ENDS_WITH]:{compare:({sessionData:e,condition:t,value:r})=>!!r&&v(r).toLowerCase().endsWith(g(t.value||"",e).toLowerCase())},[c.EQ]:{compare:({sessionData:e,condition:t,value:r})=>g(t.value||"",e)===v(r)},[c.EXCLUDES_ALL]:{compare:({condition:e,value:t})=>{const r=new Set(N(t));return!(e.values||[]).some(n=>r.has(n))}},[c.EXCLUDES_ANY]:{compare:({condition:e,value:t})=>{const r=new Set(N(t));return!(e.values||[]).every(n=>r.has(n))}},[c.FALSE]:{compare:({value:e})=>v(e).toLowerCase()==="false"},[c.GT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(v(t))>parseFloat(e.value)},[c.GTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(v(t))>=parseFloat(e.value)},[c.INCLUDES_ALL]:{compare:({condition:e,value:t})=>{const r=new Set(N(t));return(e.values||[]).every(n=>r.has(n))}},[c.INCLUDES_ANY]:{compare:({condition:e,value:t})=>{const r=new Set(N(t));return(e.values||[]).some(n=>r.has(n))}},[c.LT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(v(t))<parseFloat(e.value)},[c.LTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(v(t))<=parseFloat(e.value)},[c.NE]:{compare:({sessionData:e,condition:t,value:r})=>g(t.value||"",e)!==v(r)},[c.NOT_CONTAINS]:{compare:({sessionData:e,condition:t,value:r})=>!r||!v(r).toLowerCase().includes(g(t.value||"",e).toLowerCase())},[c.NOT_EMPTY]:{compare:({value:e})=>e!=null&&e!==""&&(!Array.isArray(e)||e.length>0)},[c.NOT_REGEX]:{compare:({condition:e,value:t})=>!B(e,t)},[c.OR]:{compare:()=>V("OR.compare")},[c.REGEX]:{compare:({condition:e,value:t})=>B(e,t)},[c.RELATIVE_EQ]:{compare:({condition:e,value:t})=>{const r=h(t),n=k(e.value);return r==null||n==null?!1:!S(r,n)&&S(r,Z(n,1))}},[c.RELATIVE_GT]:{compare:({condition:e,value:t})=>{const r=h(t),n=k(e.value);return r==null||n==null?!1:I(r,n)}},[c.RELATIVE_LT]:{compare:({condition:e,value:t})=>{const r=h(t),n=k(e.value);return r==null||n==null?!1:S(r,n)}},[c.STARTS_WITH]:{compare:({sessionData:e,condition:t,value:r})=>!!r&&v(r).toLowerCase().startsWith(g(t.value||"",e).toLowerCase())},[c.TRUE]:{compare:({value:e})=>v(e).toLowerCase()==="true"},[c.URL]:{compare:({condition:e,value:t})=>e.urlPattern&&t!=null?te(e.urlPattern,v(t)):!1}};function V(e){throw new Error(`conditionOperators.${e} is not supported`)}function h(e){if(Array.isArray(e)&&(e=e[0]),!e)return null;e.match(/(Z|((\+|-)\d\d:\d\d))$/i)||(e+="Z");const t=P(e);return j(t)?t:null}function D(e,t){if(!e)return null;e+="T"+t+"Z";const r=P(e);return j(r)?r:null}function k(e){if(!e)return null;const t=parseInt(e,10);return isNaN(t)?null:z(Date.now(),t)}function B(e,t){return e.value?new RegExp(e.value).test(v(t)):!1}function v(e){return Array.isArray(e)?e[0]:e??""}function N(e){return Array.isArray(e)?e:e===""||e==null?[]:[e]}const ne=50,se=1e3;function R(e,t={}){let r,n;const s=()=>{n=void 0,e()},a=()=>{if(window.clearTimeout(r),n==null)n=Date.now();else if(Date.now()-n>se){s();return}r=window.setTimeout(s,ne)},i=o=>{const p=o.target;if(!p||!H(p))return;const E=document.getElementById("userflow-ui");E&&E.contains(p)||a()},l=new q(o=>{ae(o)||a()}),f=G(o=>{l.observe(o,{attributes:!0,subtree:!0,childList:!0,characterData:!0}),o.addEventListener("animationend",i),o.addEventListener("transitionend",i),t.observeInput&&(o.addEventListener("input",a),o.addEventListener("keypress",a),o.addEventListener("change",a))},o=>{o.removeEventListener("animationend",i),o.removeEventListener("transitionend",i),t.observeInput&&(o.removeEventListener("input",a),o.removeEventListener("keypress",a),o.removeEventListener("change",a))});return{disconnect:()=>{window.clearTimeout(r),l.disconnect(),f()}}}function ae(e){const t=document.getElementById("userflow-ui");for(const r of e){const{target:n}=r;if(H(n)&&t&&t.contains(n))return!0}return!1}function H(e){return e.nodeType===Node.ELEMENT_NODE}const C={[T.ALWAYS_TRUE]:{track:({callback:e})=>(e(!0),()=>{})},[T.ATTRIBUTE]:{track:({sessionData:e,condition:t,callback:r})=>{const n=()=>{let a=!1;if(e&&t.operator){const i=e.value.find(o=>o.name===t.attributeName),l=i?i.value:null;a=_[t.operator].compare({sessionData:e.value,condition:t,value:l})}r(a)};n();const s=e.observe(n);return()=>{s()}}},[T.CLAUSE]:{isExpensive:e=>{for(const t of e.conditions){const r=C[t.type];if(r.isExpensive&&r.isExpensive(t))return!0}return!1},track:({sessionData:e,condition:t,flipBackEvents:r,callback:n,description:s})=>{let a,i,l=null;const f=t.conditions.map(m=>{const u=C[m.type];return{condition:m,typeDef:u,expensive:!!u.isExpensive&&u.isExpensive(m),active:!1,isTrue:null}}),o=m=>{for(const u of f){const d=!r||!u.expensive||m;d&&!u.active?(u.active=!0,u.isTrue=!1,u.untrack=u.typeDef.track({sessionData:e,condition:u.condition,flipBackEvents:r,callback:(w,b={})=>{u.isTrue=w,window.clearTimeout(a),b.immediate?p({immediate:!0}):a=window.setTimeout(p,0)},description:s})):!d&&u.active&&(u.untrack&&u.untrack(),u.active=!1,u.isTrue=null,u.untrack=void 0)}},p=(m={})=>{if(f.length===0){E(!1,m);return}let u,d;if(t.operator===c.AND){u=!0,d=!0;for(const w of f)w.isTrue===!1?(u=!1,w.expensive||(d=!1)):u!==!1&&w.isTrue===null&&(u=null)}else{u=!1,d=!0;for(const w of f)w.isTrue===!0?(u=!0,w.expensive||(d=!1)):u!==!0&&w.isTrue===null&&(u=null)}u!==null&&u!==l&&(l=u,E(u,m)),o(d)},E=(m,u)=>{if(!m||t.waitTime==null||t.waitTime=="0")window.clearTimeout(i),i=void 0,n(m,u);else if(!i){const d=parseFloat(t.waitTime)*1e3;i=window.setTimeout(()=>{n(!0,{})},d)}};return o(!1),p(),()=>{window.clearTimeout(a),window.clearTimeout(i);for(const m of f)m.untrack&&m.untrack()}}},[T.ELEMENT]:{isExpensive:()=>!0,track:e=>{const{elementState:t}=e.condition;if(!t)return()=>{};const r=oe(t);switch(r.kind){case"observer":return le(e,r.checkElement);case"event":return ue(e,r.eventName,r.valueWhenOccurred)}}},[T.FILLED_IN_INPUT]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:r})=>{let n=null,s;const a=()=>{if(!t.selector){console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);return}const f=x(U(t.selector,e.value));let o=null;for(const p of f){const E=F(p);if(E){o=E;break}}o?o!=n&&(window.clearTimeout(s),s=window.setTimeout(()=>{r(!0)},1e3)):(r(!1),window.clearTimeout(s)),n=o};a();const i=e.observe(a),{disconnect:l}=R(a,{observeInput:!0});return()=>{i(),l(),window.clearTimeout(s)}}},[T.FLOW]:{track:()=>(console.warn("Userflow.js: Flow conditions do not work client-side"),()=>{})},[T.INPUT_VALUE]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:r})=>{const n=()=>{if(!t.operator){console.warn("Userflow.js: INPUT_VALUE condition missing operator",t);return}if(!t.selector){console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);return}let i=!1;const l=_[t.operator],f=x(U(t.selector,e.value));if(f.length>0)for(const o of f){const p=F(o);if(l.compare({sessionData:e.value,condition:t,value:p})){i=!0;break}}else l.compare({sessionData:e.value,condition:t,value:""})&&(i=!0);r(i)};n();const s=e.observe(n),{disconnect:a}=R(n,{observeInput:!0});return()=>{s(),a()}}},[T.PAGE]:{track:({sessionData:e,condition:t,callback:r})=>{const n=()=>{let l=!1;if(t.operator){const f=y();l=_[t.operator].compare({sessionData:e.value,condition:t,value:f})}r(l)};let s=y();const a=()=>{const l=y();l!==s&&(s=l,n())};X(a),n();const i=e.observe(n);return()=>{i(),Y(a)}}},[T.SEGMENT]:{track:({description:e,callback:t})=>(console.error("Userflow.js: Segment conditions are not supported in "+(e||"unknown content item")+"."),t(!1),()=>{})},[T.TIME]:{track:({condition:e,callback:t})=>{let r=null;const n=e.value?new Date(e.value):null,s=e.value2?new Date(e.value2):null,a=()=>{let l=!0;(n&&!isNaN(n.valueOf())&&Date.now()<n.valueOf()||s&&!isNaN(s.valueOf())&&Date.now()>=s.valueOf())&&(l=!1),l!==r&&(r=l,t(l))};a();const i=window.setInterval(a,10*1e3);return()=>{window.clearInterval(i)}}}};function oe(e){switch(e){case L.CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!0};case L.DISABLED:return{kind:"observer",checkElement:t=>!!t&&t.disabled};case L.MOUSEDOWN:return{kind:"event",eventName:"mousedown",valueWhenOccurred:!0};case L.NOT_CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!1};case L.NOT_DISABLED:return{kind:"observer",checkElement:t=>!!t&&!t.disabled};case L.NOT_PRESENT:return{kind:"observer",checkElement:t=>!t};case L.PRESENT:return{kind:"observer",checkElement:t=>!!t}}}function le({sessionData:e,condition:t,callback:r},n){const s=()=>{if(!t.elementState){console.warn("Userflow.js: ELEMENT_STATE condition missing elementState",t);return}if(!t.selector){console.warn("Userflow.js: ELEMENT_STATE condition missing selector",t);return}let l=!1;const f=x(U(t.selector,e.value));if(f.length>0){for(const o of f)if(n(o)){l=!0;break}}else n(null)&&(l=!0);r(l)};s();const a=e.observe(s),{disconnect:i}=R(s);return()=>{a(),i()}}function ue({condition:e,flipBackEvents:t,callback:r},n,s){const{selector:a}=e;if(!a)return()=>{};r(!s);const i=o=>{const p=o.target;p&&Q(p,a)&&(t?(r(s,{immediate:!0}),r(!s,{immediate:!0})):r(s))},l={capture:!0},f=G(o=>o.addEventListener(n,i,l),o=>o.removeEventListener(n,i,l));return()=>{f()}}const me=Object.freeze(Object.defineProperty({__proto__:null,conditionTypes:C},Symbol.toStringTag,{value:"Module"}));export{g as a,J as b,C as c,me as f,ee as g,U as i,R as o};
|
|
2
2
|
//# sourceMappingURL=flow-condition-types.js.map
|
package/flow-host.css
CHANGED
|
@@ -600,6 +600,11 @@ _:future,
|
|
|
600
600
|
box-shadow: 0 3px 21px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1);
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
|
+
.userflowjs-embed--animate-true {
|
|
604
|
+
animation-name: userflowjs-embed-animate-in;
|
|
605
|
+
animation-duration: 800ms;
|
|
606
|
+
animation-timing-function: ease-in-out;
|
|
607
|
+
}
|
|
603
608
|
@-moz-keyframes userflowjs-flow-chrome-visible {
|
|
604
609
|
0% {
|
|
605
610
|
opacity: 0;
|
|
@@ -1004,3 +1009,43 @@ _:future,
|
|
|
1004
1009
|
opacity: 1;
|
|
1005
1010
|
}
|
|
1006
1011
|
}
|
|
1012
|
+
@-moz-keyframes userflowjs-embed-animate-in {
|
|
1013
|
+
0% {
|
|
1014
|
+
height: 0;
|
|
1015
|
+
opacity: 0;
|
|
1016
|
+
}
|
|
1017
|
+
100% {
|
|
1018
|
+
height: var(--userflowjs-banner-height);
|
|
1019
|
+
opacity: 1;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
@-webkit-keyframes userflowjs-embed-animate-in {
|
|
1023
|
+
0% {
|
|
1024
|
+
height: 0;
|
|
1025
|
+
opacity: 0;
|
|
1026
|
+
}
|
|
1027
|
+
100% {
|
|
1028
|
+
height: var(--userflowjs-banner-height);
|
|
1029
|
+
opacity: 1;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
@-o-keyframes userflowjs-embed-animate-in {
|
|
1033
|
+
0% {
|
|
1034
|
+
height: 0;
|
|
1035
|
+
opacity: 0;
|
|
1036
|
+
}
|
|
1037
|
+
100% {
|
|
1038
|
+
height: var(--userflowjs-banner-height);
|
|
1039
|
+
opacity: 1;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
@keyframes userflowjs-embed-animate-in {
|
|
1043
|
+
0% {
|
|
1044
|
+
height: 0;
|
|
1045
|
+
opacity: 0;
|
|
1046
|
+
}
|
|
1047
|
+
100% {
|
|
1048
|
+
height: var(--userflowjs-banner-height);
|
|
1049
|
+
opacity: 1;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
package/flow-host.styl.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{R as
|
|
1
|
+
import{R as d,r as s}from"./vendor.react.js";import{c as i}from"./userflow.js";import"./vendor.core-js.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]="7c73c89d-dc4d-43b1-a085-b9fd8b6b0559",e._sentryDebugIdIdentifier="sentry-dbid-7c73c89d-dc4d-43b1-a085-b9fd8b6b0559")}catch{}})();const _=0,E=10,a=100,g=2e3;function u(e){return i.baseZIndex+e}const n=[],I=10;function o(){const e={zIndex:n.length===0?u(a):n[n.length-1].zIndex+I};return n.push(e),e}function c(e){const t=n.indexOf(e);t!==-1&&n.splice(t,1)}function l(){const[e,t]=s.useState(o);s.useEffect(()=>()=>c(e),[e]);const r=s.useCallback(()=>{c(e),t(o())},[e]);return{zIndex:e.zIndex,bringToFront:r}}const p=({children:e})=>{const{zIndex:t}=l();return d.createElement(f.Provider,{value:t},e)},f=d.createContext(void 0);function C(){return s.useContext(f)||u(a)}const w=new URL("flow-host.css",import.meta.url).href;export{E as C,_ as L,g as N,p as S,C as a,w as f,l as u,u as w};
|
|
2
2
|
//# sourceMappingURL=flow-host.styl.js.map
|
package/hash.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
0d96176163d73cb3deda1aa6007de5408dc01fa3
|
package/package.json
CHANGED
package/roots.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as l,c as L,Z as ne,m as ae,F as z,$ as Me}from"./userflow.js";import"./vendor.core-js.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]="960fd930-a13b-4972-a6fc-b1f7c4e83035",e._sentryDebugIdIdentifier="sentry-dbid-960fd930-a13b-4972-a6fc-b1f7c4e83035")}catch{}})();class Ne extends Error{constructor(t,o){const n=`Unreachable case: ${t}`;o?o=`${o} (${n})`:o=n,super(o)}}let ue=window.MutationObserver;const v=window;if(v.Zone&&typeof v.Zone.__symbol__=="function"){const e=v.Zone.__symbol__("MutationObserver");e&&typeof e=="string"&&v.hasOwnProperty(e)&&typeof v[e]=="function"&&(ue=v[e])}function fe(e,t){const o=e.left,n=e.top,r=o+e.width,i=n+e.height,c=t.left,s=t.top,f=c+t.width,u=s+t.height;return ve(o,n,r,i,c,s,f,u)}function ve(e,t,o,n,r,i,c,s){const f=c<e,u=o<r,d=s<t,a=n<i;return a&&f?$(e,n,c,i):f&&d?$(e,t,c,s):d&&u?$(o,t,r,s):u&&a?$(o,n,r,i):f?e-c:u?r-o:d?t-s:a?i-n:0}function $(e,t,o,n){return Math.sqrt(Math.pow(o-e,2)+Math.pow(n-t,2))}function _(e){window.performance.mark&&window.performance.mark(e)}function X(e,t,o){window.performance.measure&&window.performance.measure(e,t,o)}function Le(){const e=window.getComputedStyle(window.document.body);if(e.zoom&&e.zoom!=="1"){const t=parseFloat(e.zoom);if(!isNaN(t))return t}return 1}function ht(e){return _e(),Re(e)}let V;function Re(e){return V==null&&(V=Le()),V==1?e:e/V}function _e(){V=null}function mt(){return(document.compatMode=="BackCompat"?document.body:document.documentElement).clientWidth||window.innerWidth}function De(){return(document.compatMode=="BackCompat"?document.body:document.documentElement).clientHeight||window.innerHeight}function pt(e){return e?parseFloat(e.replace(/px$/,"")):0}function wt(e){return e==null?void 0:e+"px"}function gt(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}const Fe=50,ke=100,oe=25,Ve=new Set(["left","start","justify","justify-all"]);class Oe{constructor(t){this.ctx=t,this.rectCache=new Map,this.isLabelLikeCache=new Map,this.hasPlaceholderCache=new Map}calcScore(t,o){const n=this.getRect(t),r=this.getRect(o),i=this.distBetween(t,o),c=K(o)?ke:Fe;if(i>c)return 0;const s=this.isLabelLike(t),f=this.isCloserToOtherInput(t,o),u=window.getComputedStyle(t).textAlign||"",d=n.top+n.height<=r.top,a=Math.abs(n.left-r.left)<oe&&(!u||Ve.has(u)),h=n.left+n.width<=r.left,T=Math.abs(n.top-r.top)<oe,S=d&&a||h&&T,y=n.height>=De()/2,b=be(o);if(b&&n.top>=r.top+r.height)return 0;let m=1;const E=t.htmlFor;return E&&E===o.id&&(m+=Math.pow(1e3,4)),b&&!y&&!f&&(s&&S?m+=Math.pow(1e3,3):o===t&&this.hasPlaceholder(o)?m+=Math.pow(1e3,2):!s&&S&&(m+=Math.pow(1e3,1))),m+=c-i,m}getRect(t){let o=this.rectCache.get(t);return o||(o=A(t),this.rectCache.set(t,o)),o}isLabelLike(t){let o=this.isLabelLikeCache.get(t);if(o===void 0){const n="a, button, h1, h2, h3, h4, h5, h6, input";o=!t.closest(n)&&!t.querySelector(n),this.isLabelLikeCache.set(t,o)}return o}hasPlaceholder(t){let o=this.hasPlaceholderCache.get(t);return o===void 0&&(o=!!O(t),this.hasPlaceholderCache.set(t,o)),o}getAllInputs(){return this.allInputs||(this.allInputs=Array.from(document.querySelectorAll(we())).filter(t=>ee(t,this.ctx))),this.allInputs}distBetween(t,o){return Math.round(fe(this.getRect(t),this.getRect(o)))}isCloserToOtherInput(t,o){let n=this.distBetween(t,o);for(let r of this.getAllInputs()){if(r===o)continue;if(this.distBetween(t,r)<n)return!0}return!1}}function Be(e,t={}){const o=performance.now();_("userflow:inferSelector:start"),l.groupCollapsed("inferSelector for",e,t);let n;try{n=$e(e,t)}catch(r){console.error("Userflow findElement error:",r),n=null}return l("time",performance.now()-o),l.groupEnd(),_("userflow:inferSelector:end"),X("userflow:inferSelector","userflow:inferSelector:start","userflow:inferSelector:end"),n}function de(e){const t=[],o=e.tagName.toLowerCase();return L.inferenceAttributeNames.forEach(n=>{const r=e.getAttribute(n);if(!r)return;const i=L.inferenceAttributeFilters[n];if(!(i&&!ne(i,r)))if(n==="id")t.push(`#${r}`);else{const c=n==="name"||n==="placeholder"?o:"";t.push(`${c}[${n}="${r}"]`)}}),e.classList.forEach(n=>{ne(L.inferenceClassNameFilters,n)&&(n=n.replace(/:/g,"\\:").trim(),t.push(`.${n}`))}),t}const Ue=window.userflow||{};Ue.__inferSelector=Be;function $e(e,{elementType:t}={}){const o={minorVersion:Ge};let n=be(e);const r=nt(e);if(t===ae.INPUT&&!n)if(r)e=r,n=!0,l("use custom input parent",r);else return l("not an input"),null;else r&&(e=r,n=!0);const i=Pe(e);let c=null;n||(c=pe(e),c&&c.length>250&&(c=null)),l("text is:"+c);let s=new Map,f=new Map;const u=new Map,d=new j(i,null,o),a=new j(i,c,o),h=(y,b,m,E,g)=>{if(E<0)return;let p=y.get(b);p||(p=[],y.set(b,p)),p.push({css:m,offset:E,complexity:g}),l(`use css=${m}, cardinality=${b}, offset=${E}`)},T=qe(e),S=[e.tagName.toLowerCase(),...de(e)];l("shadowRootSelectors:",i),l("ancestorCssSelectors:",T),l("ownCssSelectors:",S);for(const y of S)for(const b of T){const m=b?`${b} ${y}`:y,E=b?2:1,g=d.query(m),p=Array.from(g),w=p.length;if(w>100){l(`cardinality too high css=${m}, cardinality=${w}`);continue}u.set(m,w);const x=p.indexOf(e);if(h(s,w,m,x,E),c){const k=a.query(m),N=Array.from(k),Ce=N.indexOf(e),Ie=N.length;h(f,Ie,m,Ce,E)}}if(s.size>0||f.size>0){const y=E=>Array.from(E.entries()).map(([g,p])=>({cardinality:g,cssSelectors:p.sort((w,x)=>{const k=u.get(w.css),N=u.get(x.css);return k!==N?k?N?k-N:-1:1:w.complexity!==x.complexity?x.complexity-w.complexity:w.css.localeCompare(x.css)}).map(({css:w,offset:x})=>({css:w,offset:x}))})).sort((g,p)=>g.cardinality-p.cardinality),b={version:"v1",minorVersion:o.minorVersion,shadowRootSelectors:i,notextGroups:y(s),textGroups:y(f)},m={el:e,selector:{type:z.AUTO,autoData:JSON.stringify(b),text:c,elementType:t}};return l("inference result",m),m}return l("no selector inferred "),null}function Pe(e){let t=[],o=e;for(;o;){let n=o.getRootNode();if(F(n)){const{host:i}=n;t.unshift(i.tagName.toLowerCase()),o=i;continue}const r=q(o);if(r){let i=r.tagName.toLowerCase();const c=r.getAttribute("name");c?i+=`[name="${c}"]`:r.id&&!r.id.match(/\d$/)&&(i+="#"+r.id),t.unshift(i),o=r;continue}break}if(t.length!==0)return t}function qe(e){const t=new Map;t.set(null,0);let o=e.parentNode;for(;o&&!(o.tagName==="BODY"||F(o));){for(const r of de(o)){if(t.has(r))continue;const i=P(document.body,r);if(i){const c=i.length;t.set(r,c)}}o=o.parentNode}return Array.from(t.entries()).sort(([,r],[,i])=>r-i).slice(0,20).map(([r])=>r)}function Ye(e,t){const{text:o,excludeText:n,precision:r}=e,i={minorVersion:t.minorVersion||0},c=o!=null&&!n,s=c?t.textGroups:t.notextGroups,f=Math.max(1,Math.min(s.length,Math.ceil((1-parseFloat(r||"1"))*s.length))),u=new j(t.shadowRootSelectors,c&&o||null,i);l("findElementAutoV1",{text:o,excludeText:n,precision:r,groups:s,groupCount:f});for(let d=0;d<f;d++){const a=s[d];let h=new Map,T=0,S=null;l.group(`group cardinality=${a.cardinality}`,a);try{for(let y=0;y<a.cssSelectors.length;y++){const{css:b,offset:m}=a.cssSelectors[y];l(`css=${b}, offset=${m}`);let E=u.query(b),g=null;for(let w=0;w<=m;w++){const x=E.next();if(x.done)break;g=x.value}if(!g)continue;const p=(h.get(g)||0)+1;if(h.set(g,p),l(`el with frequency=${p}`+(p>T&&g!==S?" NEW BEST":""),g),p>T&&(T=p,S=g,p>=Math.ceil(a.cssSelectors.length/2)))return l("early winner",S),S}}finally{l.groupEnd()}if(S)return l("winner",S),S}return l("element not found"),null}class j{constructor(t,o,n){this.shadowRootSelectors=t,this.text=o,this.ctx=n,this.isVisibleCache=new Map,this.textCache=new Map}*query(t){const o=P(document.body,t,this.shadowRootSelectors);if(l("found",o),!o)return;const{text:n}=this;for(let r=0;r<o.length;r++){const i=o[r];if(n){let s=this.textCache.get(i);if(s==null&&(s=G(i,n),this.textCache.set(i,s)),!s){l("skip, text mismatch",i);continue}}let c=this.isVisibleCache.get(i);if(c==null&&(c=ee(i,this.ctx),this.isVisibleCache.set(i,c)),!c){l("skip, not visible",i);continue}l("yield",i),yield i}}}const Ge=5,B=window.userflow||{};function Z(e){const t=performance.now();_("userflow:findAllElements:start"),l.groupCollapsed("findAllElements",e);let o;try{if(e.type===z.MANUAL)o=je(e);else if(e.autoData){const n=JSON.parse(e.autoData);let r;if(n.version==="v1")r=Ye(e,n);else throw new Ne(n.version,"Unknown autoData version: "+n.version);o=r?[r]:[]}else o=[]}catch(n){console.error("Userflow findElement error:",n),o=[]}return l("time",performance.now()-t),l.groupEnd(),_("userflow:findAllElements:end"),X("userflow:findAllElements","userflow:findAllElements:start","userflow:findAllElements:end"),o}function je(e){const t={minorVersion:e.minorVersion==null?1:e.minorVersion};let{css:o,text:n,elementType:r,offset:i}=e;n=n&&R(n);const c="nearSelector"in e?e.nearSelector:null;l("findAllElementsManual",e),i!=null&&c!=null&&console.warn("Userflow.js: Both selector.offset and selector.nearSelector was set; ignoring nearSelector.");let s;if(n&&!o){if(s=[],t.minorVersion>=2)for(const f of se())W(f,n,s);else W(document.body,n,s);l("els after traverseElementForText",s)}else if(o){if(t.minorVersion>=2){s=[];for(const f of se()){const u=P(f,o);u&&u.length>0&&s.push(...u)}}else s=Array.from(P(document.body,o)||[]);l("els after safeQueryAll",s),n&&(s=ze(s,n),l("els after filterElementsByText",s))}else console.warn("Userflow.js: findAllElements() requires least one of `css` and `text` to be set."),s=[];if(s.length>0&&(s=s.filter(f=>ee(f,t)),l("els after isVisible",s)),s.length>0&&r===ae.INPUT&&(s=et(s,t),l("els after mapElementsToInputs",s)),s.length>0&&(s.sort((f,u)=>{const d=A(f),a=A(u);return d.top<a.top?-1:d.top>a.top?1:d.left-a.left}),l("els after sort",s)),s.length>0){if(i!=null)s=s[i]?[s[i]]:[],l("els after offset",s);else if(c!=null){const f=Z(c);let u=null,d=0;for(const a of s)for(const h of f){const T=fe(A(a),A(h));(!u||T<d)&&(u=a,d=T)}s=u?[u]:[],l("els after nearSelector",s)}}return s}function he(e){return Z(e)[0]||null}function We(e,t){const o=performance.now();_("userflow:elementMatchesSelector:start"),l.groupCollapsed("elementMatchesSelector",e,t);let n;try{if(t.type===z.MANUAL)n=He(e,t);else{const r=he(t);n=r!=null&&r.contains(e)}}catch(r){console.error("Userflow findElement error:",r),n=!1}return l(n?"match":"not match"),l("time",performance.now()-o),l.groupEnd(),_("userflow:elementMatchesSelector:end"),X("userflow:elementMatchesSelector","userflow:elementMatchesSelector:start","userflow:elementMatchesSelector:end"),n}function He(e,t){t.offset!=null&&console.warn("Userflow.js: selector.offset is not supported for elementMatchesSelector yet"),"nearSelector"in t&&t.nearSelector!=null&&console.warn("Userflow.js: selector.nearSelector is not supported for elementMatchesSelector yet");let{css:o,text:n}=t;n=n&&R(n);let r=!1,i=e;for(;i&&i.tagName!=="BODY";){if((!o||i.matches(o))&&(!n||G(i,n))){r=!0;break}i=i.parentElement}return r}function W(e,t,o){if(D(e)){const{tagName:r}=e;if(r==="SCRIPT"||r==="STYLE")return!1}let n=!1;for(let r=0;r<e.children.length;r++)W(e.children[r],t,o)&&(n=!0);return!n&&D(e)&&G(e,t)&&(o.push(e),n=!0),n}function P(e,t,o){try{return o==null?e.querySelectorAll(t):me(t,o,0,e)}catch{return console.info("Userflow.js: Invalid CSS selector: ",t),null}}function me(e,t,o,n){if(o>=t.length)return Array.from(n.querySelectorAll(e));const r=t[o],i=n.querySelectorAll(r),c=[];return i.forEach(s=>{let f;if(s.shadowRoot)f=s.shadowRoot;else{if(!Ee(s))return;let u=null;try{u=s.contentDocument}catch{}if(!u)return;f=u.body}c.push(...me(e,t,o+1,f))}),c}function ze(e,t){const o=[];for(let n=e.length-1;n>=0;n--){const r=e[n];o.some(i=>i.contains(r))||G(r,t)&&o.push(r)}return o.reverse()}const Xe={email:!0,number:!0,password:!0,search:!0,tel:!0,text:!0,url:!0},Ze={date:!0,"datetime-local":!0,month:!0,time:!0,week:!0},Qe={button:!0,email:!0,reset:!0,search:!0,submit:!0,tel:!0,text:!0,url:!0};function pe(e){let t=e.innerText;return t===void 0&&e.tagName!=="SELECT"&&(t=e.textContent),t=R(t),t||null}function O(e){if(ge(e)||Q(e)){const t=R(e.getAttribute("placeholder")),o=e.value||"";if(t&&!o)return t;const n=R(o);if(n&&ot(e))return n}if(J(e)&&e.selectedIndex>=0){const t=R(e.options[e.selectedIndex].text);if(t)return t}return pe(e)}function G(e,t){const o=O(e);return o?Je(t,o):!1}function Je(e,t){const o=e.toLowerCase();return t.toLowerCase()===o}function R(e){return!e||e.length>250?null:e.replace(/^[\s\uFEFF\xA0\u200B*]+|[\s\uFEFF\xA0\u200B*]+$/g,"").replace(/\s+/g," ")}function Ke(e){for(const{cssSelector:t,getValue:o}of L.customInputs)if(e.matches(t))if(o)try{return(o(e)||"").trim()}catch(n){return console.error(`Userflow.js: getValue function for custom input '${t}' failed:`,n),""}else return O(e)||"";return J(e)?e.selectedIndex==-1?"":e.options[e.selectedIndex].text:K(e)?O(e)||"":e.value}function we(){return"input, select, textarea, [contenteditable]"+L.customInputs.map(({cssSelector:e})=>`, ${e}`).join("")}function et(e,t){const o=new Set,n=new Oe(t),r=we();for(const i of e){if(i.matches(r)){o.add(i);continue}let c=null,s=null;n.getAllInputs().forEach(f=>{const u=n.calcScore(i,f);l("input",u,f),u!==0&&(c&&s&&u<=s||(l("input is best so far"),c=f,s=u))}),c&&(l("best input was",c),o.add(c))}return Array.from(o)}function ge(e){if(e.tagName!=="INPUT")return!1;const t=e.getAttribute("type");return t==null?!0:Xe[(t||"").toLowerCase()]===!0}function Q(e){return e.tagName==="TEXTAREA"}function tt(e){if(e.tagName!=="INPUT")return!1;const t=(e.getAttribute("type")||"").toLowerCase();return Ze[t]===!0}function J(e){return e.tagName==="SELECT"}function K(e){return"hasAttribute"in e&&e.hasAttribute("contenteditable")}function ye(e){return!!(K(e)||L.customInputs.some(({cssSelector:t})=>e.matches(t)))}function nt(e){let t=e.parentNode;for(;t&&!(t.tagName==="BODY"||F(t));){if(ye(t))return t;t=t.parentNode}return null}function be(e){return ge(e)||tt(e)||Q(e)||J(e)||ye(e)}function ot(e){if(Q(e))return!0;const t=(e.getAttribute("type")||"").toLowerCase();return Qe[t]}function ee(e,t){const o=A(e);let n=e,r=!0,i=!1,c=!1,s=!1,f=!1;for(;n;){const u=n===document.body,d=n.tagName==="BODY",a=window.getComputedStyle(n);let h=null;if(r){if(a.visibility&&a.visibility!=="visible")return l("not visible because visibility is",a.visibility,e,{cur:n}),!1;r=!1}if(a.display==="none")return l("not visible because display is",a.display,e,{cur:n}),!1;if(a.opacity!=null&&parseFloat(a.opacity)<.01)return l("not visible because opacity is",a.opacity,e,{cur:n}),!1;if(a.position==="absolute"?s=!0:(a.position==="relative"||a.position==="fixed"||a.position==="sticky")&&(s=!1),t.minorVersion>=4&&!i&&!d&&!(f&&a.position==="static")&&(I(a.overflowX)||I(a.overflowY))&&(h=h||A(n),h.width===0||h.height===0))return l("not visible because width/height (v1.4 check) is",h.width,h.height,e,{cur:n}),!1;if(!c&&Se(a.display)&&(t.minorVersion<1||d||a.position!=="static")){const T=d||I(a.overflow),S=T||I(a.overflowX),y=T||I(a.overflowY),{scrollLeft:b,scrollTop:m}=d?n.ownerDocument.documentElement:n,E=!d&&!s;if(S){if(h=h||A(n),E&&h.width===0)return l("not visible because width is",h.width,e,{cur:n}),!1;const g=t.minorVersion>=5?o.width/2:0,p=Math.round(o.left+g),w=Math.round(h.left-b);if(p<w)return l("not visible because it's clipped left",e,{elX:p,curLeft:w,cur:n}),!1}if(y){if(h=h||A(n),E&&h.height===0)return l("not visible because height is",h.height,e,{cur:n}),!1;const g=t.minorVersion>=5?o.height/2:0,p=Math.round(o.top+g),w=Math.round(h.top-m);if(p<w)return l("not visible because it's clipped top",e,{elY:p,curTop:w,cur:n}),!1}(S||y)&&(c=!0)}if(a.position==="fixed"&&(i=!0,c=!0),t.minorVersion>=3&&(n.scrollTop>0||n.scrollLeft>0)&&(c=!0),u)break;d?(n=q(n),r=!0):n=n.parentElement,f=s}return!0}function I(e){return e==="hidden"||e==="clip"||e==="scroll"||e==="auto"}function Se(e){return!e||!e.includes("inline")&&e!=="contents"}function yt(e){let t=e.parentNode,o=!1;for(;t&&t.tagName!=="BODY";){F(t)&&(t=t.host);const n=window.getComputedStyle(t);if(n.position==="absolute"?o=!0:(n.position==="relative"||n.position==="fixed"||n.position==="sticky")&&(o=!1),!o&&Se(n.display)&&(I(n.overflow)||I(n.overflowY)))return t;if(n.position==="fixed")return e.ownerDocument.documentElement;t=t.parentNode}return e.ownerDocument.documentElement}function A(e){if(e.tagName==="HTML"){const n=q(e);if(n)return A(n)}let t=e.getBoundingClientRect(),o=e;for(;o&&(o=q(o),!!o);){const n=o.getBoundingClientRect();t={width:t.width,height:t.height,left:t.left+n.left,right:t.right+n.left,top:t.top+n.top,bottom:t.bottom+n.top}}return t}const re=new WeakSet;function q(e){const t=e.ownerDocument?.defaultView;if(!t||re.has(t))return null;{const o=t.frameElement;return o||re.add(t),o}}function F(e){return typeof e=="object"&&e!=null&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e&&"mode"in e}function D(e){return typeof e=="object"&&e!=null&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Ee(e){return D(e)&&e.tagName==="IFRAME"}B.__findElement=he;B.__findAllElements=Z;B.__elementMatchesSelector=We;B.__getElementText=O;B.__getInputValue=Ke;const C=new Set,H=new Map,Y=new Set;function se(){return Te(),C}function bt(e,t){Te();for(const n of C)e(n);const o={setup:e,teardown:t};return Y.add(o),()=>{Y.delete(o);for(const n of C)t(n)}}let ie=!1,M=null;function Te(){if(le(),!ie){l("roots started"),ie=!0,M=document.body,U(M);for(const e of Me)document.addEventListener(e,rt);window.setInterval(le,10*1e3)}}function rt(){M&&!document.contains(M)&&(l("roots detected new Turbo body"),te(M),M=document.body,U(M))}function le(){for(const e of C)F(e)&&(st(e)||(l("roots clean before removeRoot",e),te(e)));l("roots clean finished, remaining=",C.size)}function st(e){if(!e.ownerDocument.defaultView)return!1;let t=e.host;for(;t;){if(F(t)&&(t=t.host),D(t)&&t.tagName==="BODY")return!0;t=t.parentNode}return!1}function U(e){if(!C.has(e)){l("roots addRoot",e),C.add(e),it(e),xe(e),at(e),ut(e);for(const{setup:t}of Y)t(e)}}function te(e){if(C.has(e)){l("roots removeRoot",e),H.get(e)?.disconnect(),H.delete(e),C.delete(e);for(const{teardown:t}of Y)t(e)}}function it(e){let t;const o=()=>{xe(e)},n=new ue(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(o)});n.observe(e,{childList:!0,subtree:!0}),H.set(e,n)}function xe(e){const t=D(e)?e.ownerDocument.getElementsByTagName("iframe"):e.querySelectorAll("iframe");for(const o of t)Ae(o)}const ce=new WeakSet;function Ae(e){if(ce.has(e)||e.closest("#userflow-ui"))return;e.addEventListener("load",lt);const t=e.contentWindow,o=e.contentDocument;if(!t||!o){ce.add(e);return}const n=o.body;n&&(t.addEventListener("pagehide",ct),l("roots setupFrame before addRoot",e,o,n),U(n))}function lt(e){const t=e.target;t&&Ee(t)&&Ae(t)}function ct(e){const t=e.currentTarget.document.body;l("roots onFrameUnload before removeRoot",t),te(t)}function at(e){const t=e.ownerDocument.defaultView;if(t.__userflowAttachShadowInstalled)return;t.__userflowAttachShadowInstalled=!0;const o=t.Element.prototype.attachShadow;o!=null&&(t.Element.prototype.attachShadow=function(n){const r=o.call(this,n);return this.shadowRoot&&(l("roots monitorShadowDom before addRoot",this,this.shadowRoot),U(this.shadowRoot)),r})}function ut(e){const t=o=>{o.childNodes.forEach(n=>{D(n)&&n.shadowRoot&&(l("roots queryShadowDom before addRoot",n,n.shadowRoot),U(n.shadowRoot)),t(n)})};t(e)}export{ue as M,Ne as U,Be as a,be as b,mt as c,De as d,wt as e,Z as f,pe as g,Re as h,gt as i,F as j,D as k,q as l,_e as m,R as n,bt as o,pt as p,Ee as q,A as r,yt as s,he as t,Ke as u,We as v,ht as z};
|
|
1
|
+
import{d as l,c as L,$ as ne,m as ae,F as z,a0 as Me}from"./userflow.js";import"./vendor.core-js.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]="4ba07e0d-7f11-4d95-90e8-f76ad2e13330",e._sentryDebugIdIdentifier="sentry-dbid-4ba07e0d-7f11-4d95-90e8-f76ad2e13330")}catch{}})();class Ne extends Error{constructor(t,o){const n=`Unreachable case: ${t}`;o?o=`${o} (${n})`:o=n,super(o)}}let ue=window.MutationObserver;const v=window;if(v.Zone&&typeof v.Zone.__symbol__=="function"){const e=v.Zone.__symbol__("MutationObserver");e&&typeof e=="string"&&v.hasOwnProperty(e)&&typeof v[e]=="function"&&(ue=v[e])}function fe(e,t){const o=e.left,n=e.top,r=o+e.width,i=n+e.height,c=t.left,s=t.top,f=c+t.width,u=s+t.height;return ve(o,n,r,i,c,s,f,u)}function ve(e,t,o,n,r,i,c,s){const f=c<e,u=o<r,d=s<t,a=n<i;return a&&f?$(e,n,c,i):f&&d?$(e,t,c,s):d&&u?$(o,t,r,s):u&&a?$(o,n,r,i):f?e-c:u?r-o:d?t-s:a?i-n:0}function $(e,t,o,n){return Math.sqrt(Math.pow(o-e,2)+Math.pow(n-t,2))}function _(e){window.performance.mark&&window.performance.mark(e)}function X(e,t,o){window.performance.measure&&window.performance.measure(e,t,o)}function Le(){const e=window.getComputedStyle(window.document.body);if(e.zoom&&e.zoom!=="1"){const t=parseFloat(e.zoom);if(!isNaN(t))return t}return 1}function ht(e){return _e(),Re(e)}let V;function Re(e){return V==null&&(V=Le()),V==1?e:e/V}function _e(){V=null}function mt(){return(document.compatMode=="BackCompat"?document.body:document.documentElement).clientWidth||window.innerWidth}function De(){return(document.compatMode=="BackCompat"?document.body:document.documentElement).clientHeight||window.innerHeight}function pt(e){return e?parseFloat(e.replace(/px$/,"")):0}function wt(e){return e==null?void 0:e+"px"}function gt(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}const Fe=50,ke=100,oe=25,Ve=new Set(["left","start","justify","justify-all"]);class Oe{constructor(t){this.ctx=t,this.rectCache=new Map,this.isLabelLikeCache=new Map,this.hasPlaceholderCache=new Map}calcScore(t,o){const n=this.getRect(t),r=this.getRect(o),i=this.distBetween(t,o),c=K(o)?ke:Fe;if(i>c)return 0;const s=this.isLabelLike(t),f=this.isCloserToOtherInput(t,o),u=window.getComputedStyle(t).textAlign||"",d=n.top+n.height<=r.top,a=Math.abs(n.left-r.left)<oe&&(!u||Ve.has(u)),h=n.left+n.width<=r.left,T=Math.abs(n.top-r.top)<oe,S=d&&a||h&&T,y=n.height>=De()/2,b=be(o);if(b&&n.top>=r.top+r.height)return 0;let m=1;const E=t.htmlFor;return E&&E===o.id&&(m+=Math.pow(1e3,4)),b&&!y&&!f&&(s&&S?m+=Math.pow(1e3,3):o===t&&this.hasPlaceholder(o)?m+=Math.pow(1e3,2):!s&&S&&(m+=Math.pow(1e3,1))),m+=c-i,m}getRect(t){let o=this.rectCache.get(t);return o||(o=A(t),this.rectCache.set(t,o)),o}isLabelLike(t){let o=this.isLabelLikeCache.get(t);if(o===void 0){const n="a, button, h1, h2, h3, h4, h5, h6, input";o=!t.closest(n)&&!t.querySelector(n),this.isLabelLikeCache.set(t,o)}return o}hasPlaceholder(t){let o=this.hasPlaceholderCache.get(t);return o===void 0&&(o=!!O(t),this.hasPlaceholderCache.set(t,o)),o}getAllInputs(){return this.allInputs||(this.allInputs=Array.from(document.querySelectorAll(we())).filter(t=>ee(t,this.ctx))),this.allInputs}distBetween(t,o){return Math.round(fe(this.getRect(t),this.getRect(o)))}isCloserToOtherInput(t,o){let n=this.distBetween(t,o);for(let r of this.getAllInputs()){if(r===o)continue;if(this.distBetween(t,r)<n)return!0}return!1}}function Be(e,t={}){const o=performance.now();_("userflow:inferSelector:start"),l.groupCollapsed("inferSelector for",e,t);let n;try{n=$e(e,t)}catch(r){console.error("Userflow findElement error:",r),n=null}return l("time",performance.now()-o),l.groupEnd(),_("userflow:inferSelector:end"),X("userflow:inferSelector","userflow:inferSelector:start","userflow:inferSelector:end"),n}function de(e){const t=[],o=e.tagName.toLowerCase();return L.inferenceAttributeNames.forEach(n=>{const r=e.getAttribute(n);if(!r)return;const i=L.inferenceAttributeFilters[n];if(!(i&&!ne(i,r)))if(n==="id")t.push(`#${r}`);else{const c=n==="name"||n==="placeholder"?o:"";t.push(`${c}[${n}="${r}"]`)}}),e.classList.forEach(n=>{ne(L.inferenceClassNameFilters,n)&&(n=n.replace(/:/g,"\\:").trim(),t.push(`.${n}`))}),t}const Ue=window.userflow||{};Ue.__inferSelector=Be;function $e(e,{elementType:t}={}){const o={minorVersion:Ge};let n=be(e);const r=nt(e);if(t===ae.INPUT&&!n)if(r)e=r,n=!0,l("use custom input parent",r);else return l("not an input"),null;else r&&(e=r,n=!0);const i=Pe(e);let c=null;n||(c=pe(e),c&&c.length>250&&(c=null)),l("text is:"+c);let s=new Map,f=new Map;const u=new Map,d=new j(i,null,o),a=new j(i,c,o),h=(y,b,m,E,g)=>{if(E<0)return;let p=y.get(b);p||(p=[],y.set(b,p)),p.push({css:m,offset:E,complexity:g}),l(`use css=${m}, cardinality=${b}, offset=${E}`)},T=qe(e),S=[e.tagName.toLowerCase(),...de(e)];l("shadowRootSelectors:",i),l("ancestorCssSelectors:",T),l("ownCssSelectors:",S);for(const y of S)for(const b of T){const m=b?`${b} ${y}`:y,E=b?2:1,g=d.query(m),p=Array.from(g),w=p.length;if(w>100){l(`cardinality too high css=${m}, cardinality=${w}`);continue}u.set(m,w);const x=p.indexOf(e);if(h(s,w,m,x,E),c){const k=a.query(m),N=Array.from(k),Ce=N.indexOf(e),Ie=N.length;h(f,Ie,m,Ce,E)}}if(s.size>0||f.size>0){const y=E=>Array.from(E.entries()).map(([g,p])=>({cardinality:g,cssSelectors:p.sort((w,x)=>{const k=u.get(w.css),N=u.get(x.css);return k!==N?k?N?k-N:-1:1:w.complexity!==x.complexity?x.complexity-w.complexity:w.css.localeCompare(x.css)}).map(({css:w,offset:x})=>({css:w,offset:x}))})).sort((g,p)=>g.cardinality-p.cardinality),b={version:"v1",minorVersion:o.minorVersion,shadowRootSelectors:i,notextGroups:y(s),textGroups:y(f)},m={el:e,selector:{type:z.AUTO,autoData:JSON.stringify(b),text:c,elementType:t}};return l("inference result",m),m}return l("no selector inferred "),null}function Pe(e){let t=[],o=e;for(;o;){let n=o.getRootNode();if(F(n)){const{host:i}=n;t.unshift(i.tagName.toLowerCase()),o=i;continue}const r=q(o);if(r){let i=r.tagName.toLowerCase();const c=r.getAttribute("name");c?i+=`[name="${c}"]`:r.id&&!r.id.match(/\d$/)&&(i+="#"+r.id),t.unshift(i),o=r;continue}break}if(t.length!==0)return t}function qe(e){const t=new Map;t.set(null,0);let o=e.parentNode;for(;o&&!(o.tagName==="BODY"||F(o));){for(const r of de(o)){if(t.has(r))continue;const i=P(document.body,r);if(i){const c=i.length;t.set(r,c)}}o=o.parentNode}return Array.from(t.entries()).sort(([,r],[,i])=>r-i).slice(0,20).map(([r])=>r)}function Ye(e,t){const{text:o,excludeText:n,precision:r}=e,i={minorVersion:t.minorVersion||0},c=o!=null&&!n,s=c?t.textGroups:t.notextGroups,f=Math.max(1,Math.min(s.length,Math.ceil((1-parseFloat(r||"1"))*s.length))),u=new j(t.shadowRootSelectors,c&&o||null,i);l("findElementAutoV1",{text:o,excludeText:n,precision:r,groups:s,groupCount:f});for(let d=0;d<f;d++){const a=s[d];let h=new Map,T=0,S=null;l.group(`group cardinality=${a.cardinality}`,a);try{for(let y=0;y<a.cssSelectors.length;y++){const{css:b,offset:m}=a.cssSelectors[y];l(`css=${b}, offset=${m}`);let E=u.query(b),g=null;for(let w=0;w<=m;w++){const x=E.next();if(x.done)break;g=x.value}if(!g)continue;const p=(h.get(g)||0)+1;if(h.set(g,p),l(`el with frequency=${p}`+(p>T&&g!==S?" NEW BEST":""),g),p>T&&(T=p,S=g,p>=Math.ceil(a.cssSelectors.length/2)))return l("early winner",S),S}}finally{l.groupEnd()}if(S)return l("winner",S),S}return l("element not found"),null}class j{constructor(t,o,n){this.shadowRootSelectors=t,this.text=o,this.ctx=n,this.isVisibleCache=new Map,this.textCache=new Map}*query(t){const o=P(document.body,t,this.shadowRootSelectors);if(l("found",o),!o)return;const{text:n}=this;for(let r=0;r<o.length;r++){const i=o[r];if(n){let s=this.textCache.get(i);if(s==null&&(s=G(i,n),this.textCache.set(i,s)),!s){l("skip, text mismatch",i);continue}}let c=this.isVisibleCache.get(i);if(c==null&&(c=ee(i,this.ctx),this.isVisibleCache.set(i,c)),!c){l("skip, not visible",i);continue}l("yield",i),yield i}}}const Ge=5,B=window.userflow||{};function Z(e){const t=performance.now();_("userflow:findAllElements:start"),l.groupCollapsed("findAllElements",e);let o;try{if(e.type===z.MANUAL)o=je(e);else if(e.autoData){const n=JSON.parse(e.autoData);let r;if(n.version==="v1")r=Ye(e,n);else throw new Ne(n.version,"Unknown autoData version: "+n.version);o=r?[r]:[]}else o=[]}catch(n){console.error("Userflow findElement error:",n),o=[]}return l("time",performance.now()-t),l.groupEnd(),_("userflow:findAllElements:end"),X("userflow:findAllElements","userflow:findAllElements:start","userflow:findAllElements:end"),o}function je(e){const t={minorVersion:e.minorVersion==null?1:e.minorVersion};let{css:o,text:n,elementType:r,offset:i}=e;n=n&&R(n);const c="nearSelector"in e?e.nearSelector:null;l("findAllElementsManual",e),i!=null&&c!=null&&console.warn("Userflow.js: Both selector.offset and selector.nearSelector was set; ignoring nearSelector.");let s;if(n&&!o){if(s=[],t.minorVersion>=2)for(const f of se())W(f,n,s);else W(document.body,n,s);l("els after traverseElementForText",s)}else if(o){if(t.minorVersion>=2){s=[];for(const f of se()){const u=P(f,o);u&&u.length>0&&s.push(...u)}}else s=Array.from(P(document.body,o)||[]);l("els after safeQueryAll",s),n&&(s=ze(s,n),l("els after filterElementsByText",s))}else console.warn("Userflow.js: findAllElements() requires least one of `css` and `text` to be set."),s=[];if(s.length>0&&(s=s.filter(f=>ee(f,t)),l("els after isVisible",s)),s.length>0&&r===ae.INPUT&&(s=et(s,t),l("els after mapElementsToInputs",s)),s.length>0&&(s.sort((f,u)=>{const d=A(f),a=A(u);return d.top<a.top?-1:d.top>a.top?1:d.left-a.left}),l("els after sort",s)),s.length>0){if(i!=null)s=s[i]?[s[i]]:[],l("els after offset",s);else if(c!=null){const f=Z(c);let u=null,d=0;for(const a of s)for(const h of f){const T=fe(A(a),A(h));(!u||T<d)&&(u=a,d=T)}s=u?[u]:[],l("els after nearSelector",s)}}return s}function he(e){return Z(e)[0]||null}function We(e,t){const o=performance.now();_("userflow:elementMatchesSelector:start"),l.groupCollapsed("elementMatchesSelector",e,t);let n;try{if(t.type===z.MANUAL)n=He(e,t);else{const r=he(t);n=r!=null&&r.contains(e)}}catch(r){console.error("Userflow findElement error:",r),n=!1}return l(n?"match":"not match"),l("time",performance.now()-o),l.groupEnd(),_("userflow:elementMatchesSelector:end"),X("userflow:elementMatchesSelector","userflow:elementMatchesSelector:start","userflow:elementMatchesSelector:end"),n}function He(e,t){t.offset!=null&&console.warn("Userflow.js: selector.offset is not supported for elementMatchesSelector yet"),"nearSelector"in t&&t.nearSelector!=null&&console.warn("Userflow.js: selector.nearSelector is not supported for elementMatchesSelector yet");let{css:o,text:n}=t;n=n&&R(n);let r=!1,i=e;for(;i&&i.tagName!=="BODY";){if((!o||i.matches(o))&&(!n||G(i,n))){r=!0;break}i=i.parentElement}return r}function W(e,t,o){if(D(e)){const{tagName:r}=e;if(r==="SCRIPT"||r==="STYLE")return!1}let n=!1;for(let r=0;r<e.children.length;r++)W(e.children[r],t,o)&&(n=!0);return!n&&D(e)&&G(e,t)&&(o.push(e),n=!0),n}function P(e,t,o){try{return o==null?e.querySelectorAll(t):me(t,o,0,e)}catch{return console.info("Userflow.js: Invalid CSS selector: ",t),null}}function me(e,t,o,n){if(o>=t.length)return Array.from(n.querySelectorAll(e));const r=t[o],i=n.querySelectorAll(r),c=[];return i.forEach(s=>{let f;if(s.shadowRoot)f=s.shadowRoot;else{if(!Ee(s))return;let u=null;try{u=s.contentDocument}catch{}if(!u)return;f=u.body}c.push(...me(e,t,o+1,f))}),c}function ze(e,t){const o=[];for(let n=e.length-1;n>=0;n--){const r=e[n];o.some(i=>i.contains(r))||G(r,t)&&o.push(r)}return o.reverse()}const Xe={email:!0,number:!0,password:!0,search:!0,tel:!0,text:!0,url:!0},Ze={date:!0,"datetime-local":!0,month:!0,time:!0,week:!0},Qe={button:!0,email:!0,reset:!0,search:!0,submit:!0,tel:!0,text:!0,url:!0};function pe(e){let t=e.innerText;return t===void 0&&e.tagName!=="SELECT"&&(t=e.textContent),t=R(t),t||null}function O(e){if(ge(e)||Q(e)){const t=R(e.getAttribute("placeholder")),o=e.value||"";if(t&&!o)return t;const n=R(o);if(n&&ot(e))return n}if(J(e)&&e.selectedIndex>=0){const t=R(e.options[e.selectedIndex].text);if(t)return t}return pe(e)}function G(e,t){const o=O(e);return o?Je(t,o):!1}function Je(e,t){const o=e.toLowerCase();return t.toLowerCase()===o}function R(e){return!e||e.length>250?null:e.replace(/^[\s\uFEFF\xA0\u200B*]+|[\s\uFEFF\xA0\u200B*]+$/g,"").replace(/\s+/g," ")}function Ke(e){for(const{cssSelector:t,getValue:o}of L.customInputs)if(e.matches(t))if(o)try{return(o(e)||"").trim()}catch(n){return console.error(`Userflow.js: getValue function for custom input '${t}' failed:`,n),""}else return O(e)||"";return J(e)?e.selectedIndex==-1?"":e.options[e.selectedIndex].text:K(e)?O(e)||"":e.value}function we(){return"input, select, textarea, [contenteditable]"+L.customInputs.map(({cssSelector:e})=>`, ${e}`).join("")}function et(e,t){const o=new Set,n=new Oe(t),r=we();for(const i of e){if(i.matches(r)){o.add(i);continue}let c=null,s=null;n.getAllInputs().forEach(f=>{const u=n.calcScore(i,f);l("input",u,f),u!==0&&(c&&s&&u<=s||(l("input is best so far"),c=f,s=u))}),c&&(l("best input was",c),o.add(c))}return Array.from(o)}function ge(e){if(e.tagName!=="INPUT")return!1;const t=e.getAttribute("type");return t==null?!0:Xe[(t||"").toLowerCase()]===!0}function Q(e){return e.tagName==="TEXTAREA"}function tt(e){if(e.tagName!=="INPUT")return!1;const t=(e.getAttribute("type")||"").toLowerCase();return Ze[t]===!0}function J(e){return e.tagName==="SELECT"}function K(e){return"hasAttribute"in e&&e.hasAttribute("contenteditable")}function ye(e){return!!(K(e)||L.customInputs.some(({cssSelector:t})=>e.matches(t)))}function nt(e){let t=e.parentNode;for(;t&&!(t.tagName==="BODY"||F(t));){if(ye(t))return t;t=t.parentNode}return null}function be(e){return ge(e)||tt(e)||Q(e)||J(e)||ye(e)}function ot(e){if(Q(e))return!0;const t=(e.getAttribute("type")||"").toLowerCase();return Qe[t]}function ee(e,t){const o=A(e);let n=e,r=!0,i=!1,c=!1,s=!1,f=!1;for(;n;){const u=n===document.body,d=n.tagName==="BODY",a=window.getComputedStyle(n);let h=null;if(r){if(a.visibility&&a.visibility!=="visible")return l("not visible because visibility is",a.visibility,e,{cur:n}),!1;r=!1}if(a.display==="none")return l("not visible because display is",a.display,e,{cur:n}),!1;if(a.opacity!=null&&parseFloat(a.opacity)<.01)return l("not visible because opacity is",a.opacity,e,{cur:n}),!1;if(a.position==="absolute"?s=!0:(a.position==="relative"||a.position==="fixed"||a.position==="sticky")&&(s=!1),t.minorVersion>=4&&!i&&!d&&!(f&&a.position==="static")&&(I(a.overflowX)||I(a.overflowY))&&(h=h||A(n),h.width===0||h.height===0))return l("not visible because width/height (v1.4 check) is",h.width,h.height,e,{cur:n}),!1;if(!c&&Se(a.display)&&(t.minorVersion<1||d||a.position!=="static")){const T=d||I(a.overflow),S=T||I(a.overflowX),y=T||I(a.overflowY),{scrollLeft:b,scrollTop:m}=d?n.ownerDocument.documentElement:n,E=!d&&!s;if(S){if(h=h||A(n),E&&h.width===0)return l("not visible because width is",h.width,e,{cur:n}),!1;const g=t.minorVersion>=5?o.width/2:0,p=Math.round(o.left+g),w=Math.round(h.left-b);if(p<w)return l("not visible because it's clipped left",e,{elX:p,curLeft:w,cur:n}),!1}if(y){if(h=h||A(n),E&&h.height===0)return l("not visible because height is",h.height,e,{cur:n}),!1;const g=t.minorVersion>=5?o.height/2:0,p=Math.round(o.top+g),w=Math.round(h.top-m);if(p<w)return l("not visible because it's clipped top",e,{elY:p,curTop:w,cur:n}),!1}(S||y)&&(c=!0)}if(a.position==="fixed"&&(i=!0,c=!0),t.minorVersion>=3&&(n.scrollTop>0||n.scrollLeft>0)&&(c=!0),u)break;d?(n=q(n),r=!0):n=n.parentElement,f=s}return!0}function I(e){return e==="hidden"||e==="clip"||e==="scroll"||e==="auto"}function Se(e){return!e||!e.includes("inline")&&e!=="contents"}function yt(e){let t=e.parentNode,o=!1;for(;t&&t.tagName!=="BODY";){F(t)&&(t=t.host);const n=window.getComputedStyle(t);if(n.position==="absolute"?o=!0:(n.position==="relative"||n.position==="fixed"||n.position==="sticky")&&(o=!1),!o&&Se(n.display)&&(I(n.overflow)||I(n.overflowY)))return t;if(n.position==="fixed")return e.ownerDocument.documentElement;t=t.parentNode}return e.ownerDocument.documentElement}function A(e){if(e.tagName==="HTML"){const n=q(e);if(n)return A(n)}let t=e.getBoundingClientRect(),o=e;for(;o&&(o=q(o),!!o);){const n=o.getBoundingClientRect();t={width:t.width,height:t.height,left:t.left+n.left,right:t.right+n.left,top:t.top+n.top,bottom:t.bottom+n.top}}return t}const re=new WeakSet;function q(e){const t=e.ownerDocument?.defaultView;if(!t||re.has(t))return null;{const o=t.frameElement;return o||re.add(t),o}}function F(e){return typeof e=="object"&&e!=null&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e&&"mode"in e}function D(e){return typeof e=="object"&&e!=null&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Ee(e){return D(e)&&e.tagName==="IFRAME"}B.__findElement=he;B.__findAllElements=Z;B.__elementMatchesSelector=We;B.__getElementText=O;B.__getInputValue=Ke;const C=new Set,H=new Map,Y=new Set;function se(){return Te(),C}function bt(e,t){Te();for(const n of C)e(n);const o={setup:e,teardown:t};return Y.add(o),()=>{Y.delete(o);for(const n of C)t(n)}}let ie=!1,M=null;function Te(){if(le(),!ie){l("roots started"),ie=!0,M=document.body,U(M);for(const e of Me)document.addEventListener(e,rt);window.setInterval(le,10*1e3)}}function rt(){M&&!document.contains(M)&&(l("roots detected new Turbo body"),te(M),M=document.body,U(M))}function le(){for(const e of C)F(e)&&(st(e)||(l("roots clean before removeRoot",e),te(e)));l("roots clean finished, remaining=",C.size)}function st(e){if(!e.ownerDocument.defaultView)return!1;let t=e.host;for(;t;){if(F(t)&&(t=t.host),D(t)&&t.tagName==="BODY")return!0;t=t.parentNode}return!1}function U(e){if(!C.has(e)){l("roots addRoot",e),C.add(e),it(e),xe(e),at(e),ut(e);for(const{setup:t}of Y)t(e)}}function te(e){if(C.has(e)){l("roots removeRoot",e),H.get(e)?.disconnect(),H.delete(e),C.delete(e);for(const{teardown:t}of Y)t(e)}}function it(e){let t;const o=()=>{xe(e)},n=new ue(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(o)});n.observe(e,{childList:!0,subtree:!0}),H.set(e,n)}function xe(e){const t=D(e)?e.ownerDocument.getElementsByTagName("iframe"):e.querySelectorAll("iframe");for(const o of t)Ae(o)}const ce=new WeakSet;function Ae(e){if(ce.has(e)||e.closest("#userflow-ui"))return;e.addEventListener("load",lt);const t=e.contentWindow,o=e.contentDocument;if(!t||!o){ce.add(e);return}const n=o.body;n&&(t.addEventListener("pagehide",ct),l("roots setupFrame before addRoot",e,o,n),U(n))}function lt(e){const t=e.target;t&&Ee(t)&&Ae(t)}function ct(e){const t=e.currentTarget.document.body;l("roots onFrameUnload before removeRoot",t),te(t)}function at(e){const t=e.ownerDocument.defaultView;if(t.__userflowAttachShadowInstalled)return;t.__userflowAttachShadowInstalled=!0;const o=t.Element.prototype.attachShadow;o!=null&&(t.Element.prototype.attachShadow=function(n){const r=o.call(this,n);return this.shadowRoot&&(l("roots monitorShadowDom before addRoot",this,this.shadowRoot),U(this.shadowRoot)),r})}function ut(e){const t=o=>{o.childNodes.forEach(n=>{D(n)&&n.shadowRoot&&(l("roots queryShadowDom before addRoot",n,n.shadowRoot),U(n.shadowRoot)),t(n)})};t(e)}export{ue as M,Ne as U,Be as a,be as b,mt as c,De as d,wt as e,Z as f,pe as g,Re as h,gt as i,F as j,D as k,q as l,_e as m,R as n,bt as o,pt as p,Ee as q,A as r,yt as s,he as t,Ke as u,We as v,ht as z};
|
|
2
2
|
//# sourceMappingURL=roots.js.map
|