userflow.js-self-hosted 0.1.1003773 → 0.1.1003813

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{F as e,d as t,c as n,t as o,a as r,b as s,T as i,e as l,g as a,o as c,u,f}from"./userflow.js";import{i as d,a as m,b as p,p as h,c as w,s as v}from"./vendor.date-fns.js";class E extends Error{constructor(e,t){const n=`Unreachable case: ${e}`;super(t=t?`${t} (${n})`:n)}}const g=/(\\*)\{\{([a-zA-Z0-9_.]+)\}\}/g;function y(e,t){return(e||"").replace(g,((e,n,o)=>{const r=n.length;return r%2==0?"\\".repeat(r/2)+(t(o)||""):"\\".repeat((r-1)/2)+"{{"+o+"}}"}))}function b(e){let t=null;return n=>(t||(t=new Map,e.forEach((({name:e,value:n})=>t.set(e,Array.isArray(n)?n[0]:n)))),t.get(n)||null)}function T(e,t){const n=b(t);return y(e,(e=>n(e)))}function S(e,t){const n=L(e,t),o=e.nearSelector&&L(e.nearSelector,t);return e===n&&e.nearSelector===o?e:e.nearSelector===o?n:{...n,nearSelector:o}}function L(e,t){if(!e.text)return e;const n=T(e.text,t);return n===e.text?e:{...e,text:n}}function N(e){const t=function(e){const t=e.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);if(!t)return null;const[,,n,o,r,,s,i]=t;return{scheme:n||"",domain:o||"",path:r||"",query:s||"",fragment:i||""}}(e);if(!t)return console.error("Userflow: Invalid URL pattern:",e),null;const{scheme:n,domain:o,path:r,query:s,fragment:i}=t;let l,a;l=n?x(n):"[a-z\\d]+",a=o?A(o,"[^/]","."):"[^/]*";let c,u,f;c=r?A(r,"[^?#]","/"):"/[^?#]*",s?(u="",new URLSearchParams(s).forEach(((e,t)=>{let n;n=""===e?"=?":"*"===e?"(=[^&#]*)?":"="+A(e=e.split(/\*/g).map((e=>encodeURI(e))).join("*"),"[^#]"),u+="(?=.*[?&]"+x(t)+n+"([&#]|$))"})),u+="\\?[^#]*"):u="(\\?[^#]*)?",f=i?A(i,".","/"):"(#.*)?";return new RegExp("^"+l+"://"+a+"(:\\d+)?"+c+u+f+"$")}function A(e,t,n){return e=(e=x(e)).replace(/\\\*/g,t+"*"),n&&(e=e.replace(/:[a-zA-Z0-9_]+/g,"[^"+n+"]+")),e}function x(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}const k={[e.ABSOLUTE_EQ]:{compare:({condition:e,value:t})=>{const n=D(t),o=M(e.value,"00:00:00.000"),r=M(e.value,"23:59:59.999");return null!=n&&null!=o&&null!=r&&!d(n,o)&&!m(n,r)}},[e.ABSOLUTE_GT]:{compare:({condition:e,value:t})=>{const n=D(t),o=M(e.value,"23:59:59.999");return null!=n&&null!=o&&m(n,o)}},[e.ABSOLUTE_LT]:{compare:({condition:e,value:t})=>{const n=D(t),o=M(e.value,"00:00:00.000");return null!=n&&null!=o&&d(n,o)}},[e.AND]:{compare:()=>C("AND.compare")},[e.BETWEEN]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&!!e.value2&&parseFloat(U(t))>=parseFloat(e.value)&&parseFloat(U(t))<=parseFloat(e.value2)},[e.CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&U(n).toLowerCase().includes(T(t.value||"",e).toLowerCase())},[e.EMPTY]:{compare:({value:e})=>null==e||""===e},[e.ENDS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&U(n).toLowerCase().endsWith(T(t.value||"",e).toLowerCase())},[e.EQ]:{compare:({sessionData:e,condition:t,value:n})=>T(t.value||"",e)===U(n)},[e.EXCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(R(t));return!(e.values||[]).some((e=>n.has(e)))}},[e.EXCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(R(t));return!(e.values||[]).every((e=>n.has(e)))}},[e.FALSE]:{compare:({value:e})=>"false"===U(e).toLowerCase()},[e.GT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(U(t))>parseFloat(e.value)},[e.GTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(U(t))>=parseFloat(e.value)},[e.INCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(R(t));return(e.values||[]).every((e=>n.has(e)))}},[e.INCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(R(t));return(e.values||[]).some((e=>n.has(e)))}},[e.LT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(U(t))<parseFloat(e.value)},[e.LTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(U(t))<=parseFloat(e.value)},[e.NE]:{compare:({sessionData:e,condition:t,value:n})=>T(t.value||"",e)!==U(n)},[e.NOT_CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!n||!U(n).toLowerCase().includes(T(t.value||"",e).toLowerCase())},[e.NOT_EMPTY]:{compare:({value:e})=>null!=e&&""!==e},[e.NOT_REGEX]:{compare:({condition:e,value:t})=>!I(e,t)},[e.OR]:{compare:()=>C("OR.compare")},[e.REGEX]:{compare:({condition:e,value:t})=>I(e,t)},[e.RELATIVE_EQ]:{compare:({condition:e,value:t})=>{const n=D(t),o=_(e.value);return null!=n&&null!=o&&(!d(n,o)&&d(n,p(o,1)))}},[e.RELATIVE_GT]:{compare:({condition:e,value:t})=>{const n=D(t),o=_(e.value);return null!=n&&null!=o&&m(n,o)}},[e.RELATIVE_LT]:{compare:({condition:e,value:t})=>{const n=D(t),o=_(e.value);return null!=n&&null!=o&&d(n,o)}},[e.STARTS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&U(n).toLowerCase().startsWith(T(t.value||"",e).toLowerCase())},[e.TRUE]:{compare:({value:e})=>"true"===U(e).toLowerCase()},[e.URL]:{compare:({condition:e,value:t})=>{return!(!e.urlPattern||null==t)&&(n=e.urlPattern,o=U(t),(0!==n.includes.length||0!==n.excludes.length)&&(0===n.includes.length||n.includes.some((e=>{const t=N(e);return t&&o.match(t)})))&&!n.excludes.some((e=>{const t=N(e);return t&&o.match(t)})));var n,o}}};function C(e){throw new Error(`conditionOperators.${e} is not supported`)}function D(e){if(Array.isArray(e)&&(e=e[0]),!e)return null;e.match(/(Z|((\+|-)\d\d:\d\d))$/i)||(e+="Z");const t=h(e);return w(t)?t:null}function M(e,t){if(!e)return null;const n=h(e+="T"+t+"Z");return w(n)?n:null}function _(e){if(!e)return null;const t=parseInt(e,10);return isNaN(t)?null:v(Date.now(),t)}function I(e,t){if(!e.value)return!1;return new RegExp(e.value).test(U(t))}function U(e){return Array.isArray(e)?e[0]:null==e?"":e}function R(e){return Array.isArray(e)?e:""===e||null==e?[]:[e]}let O=window.MutationObserver;const F=window;if(F.Zone&&"function"==typeof F.Zone.__symbol__){const e=F.Zone.__symbol__("MutationObserver");e&&"string"==typeof e&&F.hasOwnProperty(e)&&"function"==typeof F[e]&&(O=F[e])}function B(e,t){const n=e.left,o=e.top,r=n+e.width,s=o+e.height,i=t.left,l=t.top;return function(e,t,n,o,r,s,i,l){const a=i<e,c=n<r,u=l<t,f=o<s;return f&&a?$(e,o,i,s):a&&u?$(e,t,i,l):u&&c?$(n,t,r,l):c&&f?$(n,o,r,s):a?e-i:c?r-n:u?t-l:f?s-o:0}(n,o,r,s,i,l,i+t.width,l+t.height)}function $(e,t,n,o){return Math.sqrt(Math.pow(n-e,2)+Math.pow(o-t,2))}function V(e){window.performance.mark&&window.performance.mark(e)}function P(e,t,n){window.performance.measure&&window.performance.measure(e,t,n)}function j(e){return Y(),W(e)}let q;function W(e){return null==q&&(q=function(){const e=window.getComputedStyle(window.document.body);if(e.zoom&&"1"!==e.zoom){const t=parseFloat(e.zoom);if(!isNaN(t))return t}return 1}()),1==q?e:e/q}function Y(){q=null}function z(){return("BackCompat"==document.compatMode?document.body:document.documentElement).clientWidth||window.innerWidth}function G(){return("BackCompat"==document.compatMode?document.body:document.documentElement).clientHeight||window.innerHeight}function Z(e){return e?parseFloat(e.replace(/px$/,"")):0}const X=new Set(["left","start","justify","justify-all"]);class H{constructor(e){this.ctx=e,this.rectCache=new Map,this.isLabelLikeCache=new Map,this.hasPlaceholderCache=new Map}calcScore(e,t){const n=this.getRect(e),o=this.getRect(t),r=this.distBetween(e,t),s=ye(t)?100:50;if(r>s)return 0;const i=this.isLabelLike(e),l=this.isCloserToOtherInput(e,t),a=window.getComputedStyle(e).textAlign||"",c=n.top+n.height<=o.top,u=Math.abs(n.left-o.left)<25&&(!a||X.has(a)),f=n.left+n.width<=o.left,d=Math.abs(n.top-o.top)<25,m=c&&u||f&&d,p=n.height>=G()/2,h=Te(t);if(h&&n.top>=o.top+o.height)return 0;let w=1;const v=e.htmlFor;return v&&v===t.id&&(w+=Math.pow(1e3,4)),!h||p||l||(i&&m?w+=Math.pow(1e3,3):t===e&&this.hasPlaceholder(t)?w+=Math.pow(1e3,2):!i&&m&&(w+=Math.pow(1e3,1))),w+=s-r,w}getRect(e){let t=this.rectCache.get(e);return t||(t=xe(e),this.rectCache.set(e,t)),t}isLabelLike(e){let t=this.isLabelLikeCache.get(e);if(void 0===t){const n="a, button, h1, h2, h3, h4, h5, h6, input";t=!e.closest(n)&&!e.querySelector(n),this.isLabelLikeCache.set(e,t)}return t}hasPlaceholder(e){let t=this.hasPlaceholderCache.get(e);return void 0===t&&(t=!!de(e),this.hasPlaceholderCache.set(e,t)),t}getAllInputs(){return this.allInputs||(this.allInputs=Array.from(document.querySelectorAll(we())).filter((e=>Se(e,this.ctx)))),this.allInputs}distBetween(e,t){return Math.round(B(this.getRect(e),this.getRect(t)))}isCloserToOtherInput(e,t){let n=this.distBetween(e,t);for(let o of this.getAllInputs()){if(o===t)continue;if(this.distBetween(e,o)<n)return!0}return!1}}function Q(e,n={}){const o=performance.now();let i;V("userflow:inferSelector:start"),t.groupCollapsed("inferSelector for",e,n);try{i=function(e,{elementType:n}={}){const o={minorVersion:ee};let i=Te(e);const l=function(e){let t=e.parentNode;for(;t&&"BODY"!==t.tagName&&!De(t);){if(be(t))return t;t=t.parentNode}return null}(e);if(n!==r.INPUT||i)l&&(e=l,i=!0);else{if(!l)return t("not an input"),null;e=l,i=!0,t("use custom input parent",l)}const a=function(e){let t=[],n=e;for(;n;){let e=n.getRootNode();if(De(e)){const{host:o}=e;t.unshift(o.tagName.toLowerCase()),n=o;continue}const o=Ce(n);if(!o)break;{let e=o.tagName.toLowerCase();const r=o.getAttribute("name");r?e+=`[name="${r}"]`:o.id&&!o.id.match(/\d$/)&&(e+="#"+o.id),t.unshift(e),n=o}}if(0===t.length)return;return t}(e);let c=null;i||(c=fe(e),c&&c.length>250&&(c=null));t("text is:"+c);let u=new Map,f=new Map;const d=new Map,m=new K(a,null,o),p=new K(a,c,o),h=(e,n,o,r,s)=>{if(r<0)return;let i=e.get(n);i||(i=[],e.set(n,i)),i.push({css:o,offset:r,complexity:s}),t(`use css=${o}, cardinality=${n}, offset=${r}`)},w=function(e){const t=new Map;t.set(null,0);let n=e.parentNode;for(;n&&"BODY"!==n.tagName&&!De(n);){for(const e of J(n)){if(t.has(e))continue;const n=ie(document.body,e);if(n){const o=n.length;t.set(e,o)}}n=n.parentNode}const o=20;return Array.from(t.entries()).sort((([,e],[,t])=>e-t)).slice(0,o).map((([e])=>e))}(e),v=[e.tagName.toLowerCase(),...J(e)];t("shadowRootSelectors:",a),t("ancestorCssSelectors:",w),t("ownCssSelectors:",v);for(const r of v)for(const n of w){const o=n?`${n} ${r}`:r,s=n?2:1,i=m.query(o),l=Array.from(i),a=l.length;if(a>100){t(`cardinality too high css=${o}, cardinality=${a}`);continue}d.set(o,a);if(h(u,a,o,l.indexOf(e),s),c){const t=p.query(o),n=Array.from(t),r=n.indexOf(e);h(f,n.length,o,r,s)}}if(u.size>0||f.size>0){const r=e=>Array.from(e.entries()).map((([e,t])=>({cardinality:e,cssSelectors:t.sort(((e,t)=>{const n=d.get(e.css),o=d.get(t.css);return n!==o?n?o?n-o:-1:1:e.complexity!==t.complexity?t.complexity-e.complexity:e.css.localeCompare(t.css)})).map((({css:e,offset:t})=>({css:e,offset:t})))}))).sort(((e,t)=>e.cardinality-t.cardinality)),i={version:"v1",minorVersion:o.minorVersion,shadowRootSelectors:a,notextGroups:r(u),textGroups:r(f)},l={el:e,selector:{type:s.AUTO,autoData:JSON.stringify(i),text:c,elementType:n}};return t("inference result",l),l}return t("no selector inferred "),null}(e,n)}catch(l){console.error("Userflow findElement error:",l),i=null}return t("time",performance.now()-o),t.groupEnd(),V("userflow:inferSelector:end"),P("userflow:inferSelector","userflow:inferSelector:start","userflow:inferSelector:end"),i}function J(e){const t=[],r=e.tagName.toLowerCase();return n.inferenceAttributeNames.forEach((s=>{const i=e.getAttribute(s);if(!i)return;const l=n.inferenceAttributeFilters[s];if(!l||o(l,i))if("id"===s)t.push(`#${i}`);else{const e="name"===s||"placeholder"===s?r:"";t.push(`${e}[${s}="${i}"]`)}})),e.classList.forEach((e=>{o(n.inferenceClassNameFilters,e)&&t.push(`.${e.trim()}`)})),t}(window.userflow||{}).__inferSelector=Q;class K{constructor(e,t,n){this.shadowRootSelectors=e,this.text=t,this.ctx=n,this.isVisibleCache=new Map,this.textCache=new Map}*query(e){const n=ie(document.body,e,this.shadowRootSelectors);if(t("found",n),!n)return;const{text:o}=this;for(let r=0;r<n.length;r++){const e=n[r];if(o){let n=this.textCache.get(e);if(null==n&&(n=me(e,o),this.textCache.set(e,n)),!n){t("skip, text mismatch",e);continue}}let s=this.isVisibleCache.get(e);null==s&&(s=Se(e,this.ctx),this.isVisibleCache.set(e,s)),s?(t("yield",e),yield e):t("skip, not visible",e)}}}const ee=4,te=window.userflow||{};function ne(e){const n=performance.now();let o;V("userflow:findAllElements:start"),t.groupCollapsed("findAllElements",e);try{if(e.type===s.MANUAL)o=function(e){const n={minorVersion:null==e.minorVersion?1:e.minorVersion};let{css:o,text:s,elementType:i,offset:l}=e;s=s&&pe(s);const a="nearSelector"in e?e.nearSelector:null;t("findAllElementsManual",e),null!=l&&null!=a&&console.warn("Userflow.js: Both selector.offset and selector.nearSelector was set; ignoring nearSelector.");let c;if(s&&!o){if(c=[],n.minorVersion>=2)for(const e of Oe())se(e,s,c);else se(document.body,s,c);t("els after traverseElementForText",c)}else if(o){if(n.minorVersion>=2){c=[];for(const e of Oe()){const t=ie(e,o);t&&t.length>0&&c.push(...t)}}else c=Array.from(ie(document.body,o)||[]);t("els after safeQueryAll",c),s&&(c=function(e,t){const n=[];for(let o=e.length-1;o>=0;o--){const r=e[o];n.some((e=>e.contains(r)))||me(r,t)&&n.push(r)}return n.reverse()}(c,s),t("els after filterElementsByText",c))}else console.warn("Userflow.js: findAllElements() requires least one of `css` and `text` to be set."),c=[];c.length>0&&(c=c.filter((e=>Se(e,n))),t("els after isVisible",c));c.length>0&&i===r.INPUT&&(c=function(e,n){const o=new Set,r=new H(n),s=we();for(const i of e){if(i.matches(s)){o.add(i);continue}let e=null,n=null;r.getAllInputs().forEach((o=>{const s=r.calcScore(i,o);t("input",s,o),0!==s&&(e&&n&&s<=n||(t("input is best so far"),e=o,n=s))})),e&&(t("best input was",e),o.add(e))}return Array.from(o)}(c,n),t("els after mapElementsToInputs",c));c.length>0&&(c.sort(((e,t)=>{const n=xe(e),o=xe(t);return n.top<o.top?-1:n.top>o.top?1:n.left-o.left})),t("els after sort",c));if(c.length>0)if(null!=l)c=c[l]?[c[l]]:[],t("els after offset",c);else if(null!=a){const e=ne(a);let n=null,o=0;for(const t of c)for(const r of e){const e=B(xe(t),xe(r));(!n||e<o)&&(n=t,o=e)}c=n?[n]:[],t("els after nearSelector",c)}return c}(e);else if(e.autoData){const n=JSON.parse(e.autoData);let r;if("v1"!==n.version)throw new E(n.version,"Unknown autoData version: "+n.version);r=function(e,n){const{text:o,excludeText:r,precision:s}=e,i={minorVersion:n.minorVersion||0},l=null!=o&&!r,a=l?n.textGroups:n.notextGroups,c=Math.max(1,Math.min(a.length,Math.ceil((1-parseFloat(s||"1"))*a.length))),u=new K(n.shadowRootSelectors,l&&o||null,i);t("findElementAutoV1",{text:o,excludeText:r,precision:s,groups:a,groupCount:c});for(let f=0;f<c;f++){const e=a[f];let n=new Map,o=0,r=null;t.group(`group cardinality=${e.cardinality}`,e);try{for(let s=0;s<e.cssSelectors.length;s++){const{css:i,offset:l}=e.cssSelectors[s];t(`css=${i}, offset=${l}`);let a=u.query(i),c=null;for(let e=0;e<=l;e++){const e=a.next();if(e.done)break;c=e.value}if(!c)continue;const f=(n.get(c)||0)+1;if(n.set(c,f),t(`el with frequency=${f}`+(f>o&&c!==r?" NEW BEST":""),c),f>o&&(o=f,r=c,f>=Math.ceil(e.cssSelectors.length/2)))return t("early winner",r),r}}finally{t.groupEnd()}if(r)return t("winner",r),r}return t("element not found"),null}(e,n),o=r?[r]:[]}else o=[]}catch(i){console.error("Userflow findElement error:",i),o=[]}return t("time",performance.now()-n),t.groupEnd(),V("userflow:findAllElements:end"),P("userflow:findAllElements","userflow:findAllElements:start","userflow:findAllElements:end"),o}function oe(e){return ne(e)[0]||null}function re(e,n){const o=performance.now();let r;V("userflow:elementMatchesSelector:start"),t.groupCollapsed("elementMatchesSelector",e,n);try{if(n.type===s.MANUAL)r=function(e,t){null!=t.offset&&console.warn("Userflow.js: selector.offset is not supported for elementMatchesSelector yet");"nearSelector"in t&&null!=t.nearSelector&&console.warn("Userflow.js: selector.nearSelector is not supported for elementMatchesSelector yet");let{css:n,text:o}=t;o=o&&pe(o);let r=!1,s=e;for(;s&&"BODY"!==s.tagName;){if((!n||s.matches(n))&&(!o||me(s,o))){r=!0;break}s=s.parentElement}return r}(e,n);else{const t=oe(n);r=null!=t&&t.contains(e)}}catch(i){console.error("Userflow findElement error:",i),r=!1}return t(r?"match":"not match"),t("time",performance.now()-o),t.groupEnd(),V("userflow:elementMatchesSelector:end"),P("userflow:elementMatchesSelector","userflow:elementMatchesSelector:start","userflow:elementMatchesSelector:end"),r}function se(e,t,n){if(Me(e)){const{tagName:t}=e;if("SCRIPT"===t||"STYLE"===t)return!1}let o=!1;for(let r=0;r<e.children.length;r++)se(e.children[r],t,n)&&(o=!0);return!o&&Me(e)&&me(e,t)&&(n.push(e),o=!0),o}function ie(e,t,n){try{if(null==n)return e.querySelectorAll(t);return le(t,n,0,e)}catch(o){return console.warn("Userflow.js: Invalid CSS selector: ",t),null}}function le(e,t,n,o){if(n>=t.length)return Array.from(o.querySelectorAll(e));const r=t[n],s=o.querySelectorAll(r),i=[];return s.forEach((o=>{let r;if(o.shadowRoot)r=o.shadowRoot;else{if(!_e(o))return;let e=null;try{e=o.contentDocument}catch(s){}if(!e)return;r=e.body}i.push(...le(e,t,n+1,r))})),i}const ae={email:!0,number:!0,password:!0,search:!0,tel:!0,text:!0,url:!0},ce={date:!0,"datetime-local":!0,month:!0,time:!0,week:!0},ue={button:!0,email:!0,reset:!0,search:!0,submit:!0,tel:!0,text:!0,url:!0};function fe(e){let t=e.innerText;return void 0===t&&"SELECT"!==e.tagName&&(t=e.textContent),t=pe(t),t||null}function de(e){if(ve(e)||Ee(e)){const t=pe(e.getAttribute("placeholder")),n=e.value||"";if(t&&!n)return t;const o=pe(n);if(o&&function(e){if(Ee(e))return!0;const t=(e.getAttribute("type")||"").toLowerCase();return ue[t]}(e))return o}if(ge(e)&&e.selectedIndex>=0){const t=pe(e.options[e.selectedIndex].text);if(t)return t}return fe(e)}function me(e,t){const n=de(e);return!!n&&function(e,t){const n=e.toLowerCase();if(t.toLowerCase()===n)return!0;return!1}(t,n)}function pe(e){return e?e.length>250?null:e.replace(/^[\s\uFEFF\xA0\u200B*]+|[\s\uFEFF\xA0\u200B*]+$/g,"").replace(/\s+/g," "):null}function he(e){for(const{cssSelector:o,getValue:r}of n.customInputs)if(e.matches(o)){if(!r)return de(e)||"";try{return(r(e)||"").trim()}catch(t){return console.error(`Userflow.js: getValue function for custom input '${o}' failed:`,t),""}}return ge(e)?-1==e.selectedIndex?"":e.options[e.selectedIndex].text:ye(e)?de(e)||"":e.value}function we(){return"input, select, textarea, [contenteditable]"+n.customInputs.map((({cssSelector:e})=>`, ${e}`)).join("")}function ve(e){if("INPUT"!==e.tagName)return!1;const t=e.getAttribute("type");return null==t||!0===ae[(t||"").toLowerCase()]}function Ee(e){return"TEXTAREA"===e.tagName}function ge(e){return"SELECT"===e.tagName}function ye(e){return"hasAttribute"in e&&e.hasAttribute("contenteditable")}function be(e){return!!ye(e)||!!n.customInputs.some((({cssSelector:t})=>e.matches(t)))}function Te(e){return ve(e)||function(e){if("INPUT"!==e.tagName)return!1;const t=(e.getAttribute("type")||"").toLowerCase();return!0===ce[t]}(e)||Ee(e)||ge(e)||be(e)}function Se(e,n){const o=xe(e);let r=e,s=!0,i=!1,l=!1,a=!1,c=!1;for(;r;){const u=r===document.body,f="BODY"===r.tagName,d=window.getComputedStyle(r);let m=null;if(s){if(d.visibility&&"visible"!==d.visibility)return t("not visible because visibility is",d.visibility,e,{cur:r}),!1;s=!1}if("none"===d.display)return t("not visible because display is",d.display,e,{cur:r}),!1;if(null!=d.opacity&&parseFloat(d.opacity)<.01)return t("not visible because opacity is",d.opacity,e,{cur:r}),!1;if("absolute"===d.position?a=!0:"relative"!==d.position&&"fixed"!==d.position&&"sticky"!==d.position||(a=!1),n.minorVersion>=4&&!i&&!f&&(!c||"static"!==d.position)&&(Le(d.overflowX)||Le(d.overflowY))&&(m=m||xe(r),0===m.width||0===m.height))return t("not visible because width/height (v1.4 check) is",m.width,m.height,e,{cur:r}),!1;if(!l&&Ne(d.display)&&(n.minorVersion<1||f||"static"!==d.position)){const n=f||Le(d.overflow),s=n||Le(d.overflowX),i=n||Le(d.overflowY),{scrollLeft:c,scrollTop:u}=f?r.ownerDocument.documentElement:r,p=!f&&!a;if(s){if(m=m||xe(r),p&&0===m.width)return t("not visible because width is",m.width,e,{cur:r}),!1;const n=Math.round(m.left-c);if(Math.round(o.left)<n)return t("not visible because it's clipped left",e,{left:n,cur:r}),!1}if(i){if(m=m||xe(r),p&&0===m.height)return t("not visible because height is",m.height,e,{cur:r}),!1;const n=Math.round(m.top-u);if(Math.round(o.top)<n)return t("not visible because it's clipped top",e,{top:n,cur:r}),!1}(s||i)&&(l=!0)}if("fixed"===d.position&&(i=!0,l=!0),n.minorVersion>=3&&(r.scrollTop>0||r.scrollLeft>0)&&(l=!0),u)break;f?(r=Ce(r),s=!0):r=r.parentElement,c=a}return!0}function Le(e){return"hidden"===e||"clip"===e||"scroll"===e||"auto"===e}function Ne(e){return!e||!e.includes("inline")&&"contents"!==e}function Ae(e){let t=e.parentNode,n=!1;for(;t&&"BODY"!==t.tagName;){De(t)&&(t=t.host);const o=window.getComputedStyle(t);if("absolute"===o.position?n=!0:"relative"!==o.position&&"fixed"!==o.position&&"sticky"!==o.position||(n=!1),!n&&Ne(o.display)&&(Le(o.overflow)||Le(o.overflowY)))return t;if("fixed"===o.position)return e.ownerDocument.documentElement;t=t.parentNode}return e.ownerDocument.documentElement}function xe(e){if("HTML"===e.tagName){const t=Ce(e);if(t)return xe(t)}let t=e.getBoundingClientRect(),n=e;for(;n&&(n=Ce(n),n);){const e=n.getBoundingClientRect();t={width:t.width,height:t.height,left:t.left+e.left,right:t.right+e.left,top:t.top+e.top,bottom:t.bottom+e.top}}return t}const ke=new WeakSet;function Ce(e){const t=e.ownerDocument?.defaultView;if(!t)return null;if(ke.has(t))return null;{const e=t.frameElement;return e||ke.add(t),e}}function De(e){return"object"==typeof e&&null!=e&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e&&"mode"in e}function Me(e){return"object"==typeof e&&null!=e&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function _e(e){return Me(e)&&"IFRAME"===e.tagName}te.__findElement=oe,te.__findAllElements=ne,te.__elementMatchesSelector=re,te.__getElementText=de,te.__getInputValue=he;const Ie=new Set,Ue=new Map,Re=new Set;function Oe(){return Ve(),Ie}function Fe(e,t){Ve();for(const o of Ie)e(o);const n={setup:e,teardown:t};return Re.add(n),()=>{Re.delete(n);for(const e of Ie)t(e)}}let Be=!1,$e=null;function Ve(){if(je(),!Be){t("roots started"),Be=!0,$e=document.body,We($e);for(const e of i)document.addEventListener(e,Pe);window.setInterval(je,1e4)}}function Pe(){$e&&!document.contains($e)&&(t("roots detected new Turbo body"),Ye($e),$e=document.body,We($e))}function je(){for(const e of Ie)De(e)&&(qe(e)||(t("roots clean before removeRoot",e),Ye(e)));t("roots clean finished, remaining=",Ie.size)}function qe(e){if(!e.ownerDocument.defaultView)return!1;let t=e.host;for(;t;){if(De(t)&&(t=t.host),Me(t)&&"BODY"===t.tagName)return!0;t=t.parentNode}return!1}function We(e){if(!Ie.has(e)){t("roots addRoot",e),Ie.add(e),function(e){let t;const n=()=>{ze(e)},o=new O((()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(n)}));o.observe(e,{childList:!0,subtree:!0}),Ue.set(e,o)}(e),ze(e),function(e){const n=e.ownerDocument.defaultView;if(n.__userflowAttachShadowInstalled)return;n.__userflowAttachShadowInstalled=!0;const o=n.Element.prototype.attachShadow;null!=o&&(n.Element.prototype.attachShadow=function(e){const n=o.call(this,e);return this.shadowRoot&&(t("roots monitorShadowDom before addRoot",this,this.shadowRoot),We(this.shadowRoot)),n})}(e),function(e){const n=e=>{e.childNodes.forEach((e=>{Me(e)&&e.shadowRoot&&(t("roots queryShadowDom before addRoot",e,e.shadowRoot),We(e.shadowRoot)),n(e)}))};n(e)}(e);for(const{setup:t}of Re)t(e)}}function Ye(e){if(Ie.has(e)){t("roots removeRoot",e),Ue.get(e)?.disconnect(),Ue.delete(e),Ie.delete(e);for(const{teardown:t}of Re)t(e)}}function ze(e){const t=Me(e)?e.ownerDocument.getElementsByTagName("iframe"):e.querySelectorAll("iframe");for(const n of t)Ze(n)}const Ge=new WeakSet;function Ze(e){if(Ge.has(e))return;if(e.closest("#userflow-ui"))return;e.addEventListener("load",Xe);const n=e.contentWindow,o=e.contentDocument;if(!n||!o)return void Ge.add(e);const r=o.body;r&&(n.addEventListener("pagehide",He),t("roots setupFrame before addRoot",e,o,r),We(r))}function Xe(e){const t=e.target;t&&_e(t)&&Ze(t)}function He(e){const n=e.currentTarget.document.body;t("roots onFrameUnload before removeRoot",n),Ye(n)}function Qe(e,t={}){let n,o;const r=()=>{o=void 0,e()},s=()=>{if(window.clearTimeout(n),null==o)o=Date.now();else if(Date.now()-o>1e3)return void r();n=window.setTimeout(r,50)},i=e=>{const t=e.target;if(!t||!Je(t))return;const n=document.getElementById("userflow-ui");n&&n.contains(t)||s()},l=new O((e=>{(function(e){const t=document.getElementById("userflow-ui");for(const n of e){const{target:e}=n;if(Je(e)&&(t&&t.contains(e)))return!0}return!1})(e)||s()})),a=Fe((e=>{l.observe(e,{attributes:!0,subtree:!0,childList:!0,characterData:!0}),e.addEventListener("animationend",i),e.addEventListener("transitionend",i),t.observeInput&&(e.addEventListener("input",s),e.addEventListener("keypress",s),e.addEventListener("change",s))}),(e=>{e.removeEventListener("animationend",i),e.removeEventListener("transitionend",i),t.observeInput&&(e.removeEventListener("input",s),e.removeEventListener("keypress",s),e.removeEventListener("change",s))}));return{disconnect:()=>{window.clearTimeout(n),l.disconnect(),a()}}}function Je(e){return e.nodeType===Node.ELEMENT_NODE}const Ke={[l.ALWAYS_TRUE]:{track:({callback:e})=>(e(!0),()=>{})},[l.ATTRIBUTE]:{track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{let o=!1;if(e&&t.operator){const n=e.value.find((e=>e.name===t.attributeName)),r=n?n.value:null;o=k[t.operator].compare({sessionData:e.value,condition:t,value:r})}n(o)};o();const r=e.observe(o);return()=>{r()}}},[l.CLAUSE]:{isExpensive:e=>{for(const t of e.conditions){const e=Ke[t.type];if(e.isExpensive&&e.isExpensive(t))return!0}return!1},track:({sessionData:t,condition:n,flipBackEvents:o,callback:r})=>{let s,i,l=null;const a=n.conditions.map((e=>{const t=Ke[e.type];return{condition:e,typeDef:t,expensive:!!t.isExpensive&&t.isExpensive(e),active:!1,isTrue:null}})),c=e=>{for(const n of a){const r=!o||!n.expensive||e;r&&!n.active?(n.active=!0,n.isTrue=!1,n.untrack=n.typeDef.track({sessionData:t,condition:n.condition,flipBackEvents:o,callback:(e,t={})=>{n.isTrue=e,window.clearTimeout(s),t.immediate?u({immediate:!0}):s=window.setTimeout(u,0)}})):!r&&n.active&&(n.untrack&&n.untrack(),n.active=!1,n.isTrue=null,n.untrack=void 0)}},u=(t={})=>{if(0===a.length)return void f(!1,t);let o,r;if(n.operator===e.AND){o=!0,r=!0;for(const e of a)!1===e.isTrue?(o=!1,e.expensive||(r=!1)):!1!==o&&null===e.isTrue&&(o=null)}else{o=!1,r=!0;for(const e of a)!0===e.isTrue?(o=!0,e.expensive||(r=!1)):!0!==o&&null===e.isTrue&&(o=null)}null!==o&&o!==l&&(l=o,f(o,t)),c(r)},f=(e,t)=>{if(e&&null!=n.waitTime&&"0"!=n.waitTime){if(!i){const e=1e3*parseFloat(n.waitTime);i=window.setTimeout((()=>{r(!0,{})}),e)}}else window.clearTimeout(i),i=void 0,r(e,t)};return c(!1),u(),()=>{window.clearTimeout(s),window.clearTimeout(i);for(const e of a)e.untrack&&e.untrack()}}},[l.ELEMENT]:{isExpensive:()=>!0,track:e=>{const{elementState:t}=e.condition;if(!t)return()=>{};const n=function(e){switch(e){case f.CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!0};case f.DISABLED:return{kind:"observer",checkElement:e=>!!e&&e.disabled};case f.MOUSEDOWN:return{kind:"event",eventName:"mousedown",valueWhenOccurred:!0};case f.NOT_CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!1};case f.NOT_DISABLED:return{kind:"observer",checkElement:e=>!!e&&!e.disabled};case f.NOT_PRESENT:return{kind:"observer",checkElement:e=>!e};case f.PRESENT:return{kind:"observer",checkElement:e=>!!e}}}(t);switch(n.kind){case"observer":return function({sessionData:e,condition:t,callback:n},o){const r=()=>{if(!t.elementState)return void console.warn("Userflow.js: ELEMENT_STATE condition missing elementState",t);if(!t.selector)return void console.warn("Userflow.js: ELEMENT_STATE condition missing selector",t);let r=!1;const s=ne(S(t.selector,e.value));if(s.length>0){for(const e of s)if(o(e)){r=!0;break}}else o(null)&&(r=!0);n(r)};r();const s=e.observe(r),{disconnect:i}=Qe(r);return()=>{s(),i()}}(e,n.checkElement);case"event":return function({condition:e,flipBackEvents:t,callback:n},o,r){const{selector:s}=e;if(!s)return()=>{};let i;n(!r);const l=e=>{const o=e.target;o&&re(o,s)&&(t?(n(r,{immediate:!0}),n(!r,{immediate:!0})):n(r))},a={capture:!0},c=Fe((e=>e.addEventListener(o,l,a)),(e=>e.removeEventListener(o,l,a)));return()=>{c(),window.clearTimeout(i)}}(e,n.eventName,n.valueWhenOccurred)}}},[l.FILLED_IN_INPUT]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{let o,r=null;const s=()=>{if(!t.selector)return void console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);const s=ne(S(t.selector,e.value));let i=null;for(const e of s){const t=he(e);if(t){i=t;break}}i?i!=r&&(window.clearTimeout(o),o=window.setTimeout((()=>{n(!0)}),1e3)):(n(!1),window.clearTimeout(o)),r=i};s();const i=e.observe(s),{disconnect:l}=Qe(s,{observeInput:!0});return()=>{i(),l(),window.clearTimeout(o)}}},[l.FLOW]:{track:()=>(console.warn("Userflow.js: Flow conditions do not work client-side"),()=>{})},[l.INPUT_VALUE]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{if(!t.operator)return void console.warn("Userflow.js: INPUT_VALUE condition missing operator",t);if(!t.selector)return void console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);let o=!1;const r=k[t.operator],s=ne(S(t.selector,e.value));if(s.length>0)for(const n of s){const s=he(n);if(r.compare({sessionData:e.value,condition:t,value:s})){o=!0;break}}else r.compare({sessionData:e.value,condition:t,value:""})&&(o=!0);n(o)};o();const r=e.observe(o),{disconnect:s}=Qe(o,{observeInput:!0});return()=>{r(),s()}}},[l.PAGE]:{track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{let o=!1;if(t.operator){const n=a();o=k[t.operator].compare({sessionData:e.value,condition:t,value:n})}n(o)};let r=a();const s=()=>{const e=a();e!==r&&(r=e,o())};c(s),o();const i=e.observe(o);return()=>{i(),u(s)}}},[l.TIME]:{track:({condition:e,callback:t})=>{let n=null;const o=e.value?new Date(e.value):null,r=e.value2?new Date(e.value2):null,s=()=>{let e=!0;(o&&!isNaN(o.valueOf())&&Date.now()<o.valueOf()||r&&!isNaN(r.valueOf())&&Date.now()>=r.valueOf())&&(e=!1),e!==n&&(n=e,t(e))};s();const i=window.setInterval(s,1e4);return()=>{window.clearInterval(i)}}}};var et=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",conditionTypes:Ke});export{O as M,G as a,b,Ke as c,y as d,W as e,De as f,z as g,Y as h,T as i,Me as j,Ce as k,Q as l,Z as m,S as n,Fe as o,Qe as p,oe as q,xe as r,Ae as s,_e as t,et as u,j as z};
1
+ import{F as e,d as t,c as n,t as o,a as r,b as s,T as i,e as l,g as a,o as c,u,f}from"./userflow.js";import{i as d,a as m,b as p,p as h,c as w,s as v}from"./vendor.date-fns.js";class E extends Error{constructor(e,t){const n=`Unreachable case: ${e}`;super(t=t?`${t} (${n})`:n)}}const g=/(\\*)\{\{([a-zA-Z0-9_.]+)\}\}/g;function y(e,t){return(e||"").replace(g,((e,n,o)=>{const r=n.length;return r%2==0?"\\".repeat(r/2)+(t(o)||""):"\\".repeat((r-1)/2)+"{{"+o+"}}"}))}function b(e){let t=null;return n=>(t||(t=new Map,e.forEach((({name:e,value:n})=>t.set(e,Array.isArray(n)?n[0]:n)))),t.get(n)||null)}function T(e,t){const n=b(t);return y(e,(e=>n(e)))}function S(e,t){const n=L(e,t),o=e.nearSelector&&L(e.nearSelector,t);return e===n&&e.nearSelector===o?e:e.nearSelector===o?n:{...n,nearSelector:o}}function L(e,t){if(!e.text)return e;const n=T(e.text,t);return n===e.text?e:{...e,text:n}}function N(e){const t=function(e){const t=e.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);if(!t)return null;const[,,n,o,r,,s,i]=t;return{scheme:n||"",domain:o||"",path:r||"",query:s||"",fragment:i||""}}(e);if(!t)return console.error("Userflow: Invalid URL pattern:",e),null;const{scheme:n,domain:o,path:r,query:s,fragment:i}=t;let l,a;l=n?x(n):"[a-z\\d]+",a=o?A(o,"[^/]","."):"[^/]*";let c,u,f;c=r?A(r,"[^?#]","/"):"/[^?#]*",s?(u="",new URLSearchParams(s).forEach(((e,t)=>{let n;n=""===e?"=?":"*"===e?"(=[^&#]*)?":"="+A(e=e.split(/\*/g).map((e=>encodeURI(e))).join("*"),"[^#]"),u+="(?=.*[?&]"+x(t)+n+"([&#]|$))"})),u+="\\?[^#]*"):u="(\\?[^#]*)?",f=i?A(i,".","/"):"(#.*)?";return new RegExp("^"+l+"://"+a+"(:\\d+)?"+c+u+f+"$")}function A(e,t,n){return e=(e=x(e)).replace(/\\\*/g,t+"*"),n&&(e=e.replace(/:[a-zA-Z0-9_]+/g,"[^"+n+"]+")),e}function x(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}const k={[e.ABSOLUTE_EQ]:{compare:({condition:e,value:t})=>{const n=D(t),o=M(e.value,"00:00:00.000"),r=M(e.value,"23:59:59.999");return null!=n&&null!=o&&null!=r&&!d(n,o)&&!m(n,r)}},[e.ABSOLUTE_GT]:{compare:({condition:e,value:t})=>{const n=D(t),o=M(e.value,"23:59:59.999");return null!=n&&null!=o&&m(n,o)}},[e.ABSOLUTE_LT]:{compare:({condition:e,value:t})=>{const n=D(t),o=M(e.value,"00:00:00.000");return null!=n&&null!=o&&d(n,o)}},[e.AND]:{compare:()=>C("AND.compare")},[e.BETWEEN]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&!!e.value2&&parseFloat(U(t))>=parseFloat(e.value)&&parseFloat(U(t))<=parseFloat(e.value2)},[e.CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&U(n).toLowerCase().includes(T(t.value||"",e).toLowerCase())},[e.EMPTY]:{compare:({value:e})=>null==e||""===e},[e.ENDS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&U(n).toLowerCase().endsWith(T(t.value||"",e).toLowerCase())},[e.EQ]:{compare:({sessionData:e,condition:t,value:n})=>T(t.value||"",e)===U(n)},[e.EXCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(R(t));return!(e.values||[]).some((e=>n.has(e)))}},[e.EXCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(R(t));return!(e.values||[]).every((e=>n.has(e)))}},[e.FALSE]:{compare:({value:e})=>"false"===U(e).toLowerCase()},[e.GT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(U(t))>parseFloat(e.value)},[e.GTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(U(t))>=parseFloat(e.value)},[e.INCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(R(t));return(e.values||[]).every((e=>n.has(e)))}},[e.INCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(R(t));return(e.values||[]).some((e=>n.has(e)))}},[e.LT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(U(t))<parseFloat(e.value)},[e.LTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(U(t))<=parseFloat(e.value)},[e.NE]:{compare:({sessionData:e,condition:t,value:n})=>T(t.value||"",e)!==U(n)},[e.NOT_CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!n||!U(n).toLowerCase().includes(T(t.value||"",e).toLowerCase())},[e.NOT_EMPTY]:{compare:({value:e})=>null!=e&&""!==e},[e.NOT_REGEX]:{compare:({condition:e,value:t})=>!I(e,t)},[e.OR]:{compare:()=>C("OR.compare")},[e.REGEX]:{compare:({condition:e,value:t})=>I(e,t)},[e.RELATIVE_EQ]:{compare:({condition:e,value:t})=>{const n=D(t),o=_(e.value);return null!=n&&null!=o&&(!d(n,o)&&d(n,p(o,1)))}},[e.RELATIVE_GT]:{compare:({condition:e,value:t})=>{const n=D(t),o=_(e.value);return null!=n&&null!=o&&m(n,o)}},[e.RELATIVE_LT]:{compare:({condition:e,value:t})=>{const n=D(t),o=_(e.value);return null!=n&&null!=o&&d(n,o)}},[e.STARTS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&U(n).toLowerCase().startsWith(T(t.value||"",e).toLowerCase())},[e.TRUE]:{compare:({value:e})=>"true"===U(e).toLowerCase()},[e.URL]:{compare:({condition:e,value:t})=>{return!(!e.urlPattern||null==t)&&(n=e.urlPattern,o=U(t),(0!==n.includes.length||0!==n.excludes.length)&&(0===n.includes.length||n.includes.some((e=>{const t=N(e);return t&&o.match(t)})))&&!n.excludes.some((e=>{const t=N(e);return t&&o.match(t)})));var n,o}}};function C(e){throw new Error(`conditionOperators.${e} is not supported`)}function D(e){if(Array.isArray(e)&&(e=e[0]),!e)return null;e.match(/(Z|((\+|-)\d\d:\d\d))$/i)||(e+="Z");const t=h(e);return w(t)?t:null}function M(e,t){if(!e)return null;const n=h(e+="T"+t+"Z");return w(n)?n:null}function _(e){if(!e)return null;const t=parseInt(e,10);return isNaN(t)?null:v(Date.now(),t)}function I(e,t){if(!e.value)return!1;return new RegExp(e.value).test(U(t))}function U(e){return Array.isArray(e)?e[0]:null==e?"":e}function R(e){return Array.isArray(e)?e:""===e||null==e?[]:[e]}let O=window.MutationObserver;const F=window;if(F.Zone&&"function"==typeof F.Zone.__symbol__){const e=F.Zone.__symbol__("MutationObserver");e&&"string"==typeof e&&F.hasOwnProperty(e)&&"function"==typeof F[e]&&(O=F[e])}function B(e,t){const n=e.left,o=e.top,r=n+e.width,s=o+e.height,i=t.left,l=t.top;return function(e,t,n,o,r,s,i,l){const a=i<e,c=n<r,u=l<t,f=o<s;return f&&a?$(e,o,i,s):a&&u?$(e,t,i,l):u&&c?$(n,t,r,l):c&&f?$(n,o,r,s):a?e-i:c?r-n:u?t-l:f?s-o:0}(n,o,r,s,i,l,i+t.width,l+t.height)}function $(e,t,n,o){return Math.sqrt(Math.pow(n-e,2)+Math.pow(o-t,2))}function V(e){window.performance.mark&&window.performance.mark(e)}function P(e,t,n){window.performance.measure&&window.performance.measure(e,t,n)}function j(e){return Y(),W(e)}let q;function W(e){return null==q&&(q=function(){const e=window.getComputedStyle(window.document.body);if(e.zoom&&"1"!==e.zoom){const t=parseFloat(e.zoom);if(!isNaN(t))return t}return 1}()),1==q?e:e/q}function Y(){q=null}function z(){return("BackCompat"==document.compatMode?document.body:document.documentElement).clientWidth||window.innerWidth}function G(){return("BackCompat"==document.compatMode?document.body:document.documentElement).clientHeight||window.innerHeight}function Z(e){return e?parseFloat(e.replace(/px$/,"")):0}function X(e){return null==e?void 0:e+"px"}const H=new Set(["left","start","justify","justify-all"]);class Q{constructor(e){this.ctx=e,this.rectCache=new Map,this.isLabelLikeCache=new Map,this.hasPlaceholderCache=new Map}calcScore(e,t){const n=this.getRect(e),o=this.getRect(t),r=this.distBetween(e,t),s=be(t)?100:50;if(r>s)return 0;const i=this.isLabelLike(e),l=this.isCloserToOtherInput(e,t),a=window.getComputedStyle(e).textAlign||"",c=n.top+n.height<=o.top,u=Math.abs(n.left-o.left)<25&&(!a||H.has(a)),f=n.left+n.width<=o.left,d=Math.abs(n.top-o.top)<25,m=c&&u||f&&d,p=n.height>=G()/2,h=Se(t);if(h&&n.top>=o.top+o.height)return 0;let w=1;const v=e.htmlFor;return v&&v===t.id&&(w+=Math.pow(1e3,4)),!h||p||l||(i&&m?w+=Math.pow(1e3,3):t===e&&this.hasPlaceholder(t)?w+=Math.pow(1e3,2):!i&&m&&(w+=Math.pow(1e3,1))),w+=s-r,w}getRect(e){let t=this.rectCache.get(e);return t||(t=ke(e),this.rectCache.set(e,t)),t}isLabelLike(e){let t=this.isLabelLikeCache.get(e);if(void 0===t){const n="a, button, h1, h2, h3, h4, h5, h6, input";t=!e.closest(n)&&!e.querySelector(n),this.isLabelLikeCache.set(e,t)}return t}hasPlaceholder(e){let t=this.hasPlaceholderCache.get(e);return void 0===t&&(t=!!me(e),this.hasPlaceholderCache.set(e,t)),t}getAllInputs(){return this.allInputs||(this.allInputs=Array.from(document.querySelectorAll(ve())).filter((e=>Le(e,this.ctx)))),this.allInputs}distBetween(e,t){return Math.round(B(this.getRect(e),this.getRect(t)))}isCloserToOtherInput(e,t){let n=this.distBetween(e,t);for(let o of this.getAllInputs()){if(o===t)continue;if(this.distBetween(e,o)<n)return!0}return!1}}function J(e,n={}){const o=performance.now();let i;V("userflow:inferSelector:start"),t.groupCollapsed("inferSelector for",e,n);try{i=function(e,{elementType:n}={}){const o={minorVersion:te};let i=Se(e);const l=function(e){let t=e.parentNode;for(;t&&"BODY"!==t.tagName&&!Me(t);){if(Te(t))return t;t=t.parentNode}return null}(e);if(n!==r.INPUT||i)l&&(e=l,i=!0);else{if(!l)return t("not an input"),null;e=l,i=!0,t("use custom input parent",l)}const a=function(e){let t=[],n=e;for(;n;){let e=n.getRootNode();if(Me(e)){const{host:o}=e;t.unshift(o.tagName.toLowerCase()),n=o;continue}const o=De(n);if(!o)break;{let e=o.tagName.toLowerCase();const r=o.getAttribute("name");r?e+=`[name="${r}"]`:o.id&&!o.id.match(/\d$/)&&(e+="#"+o.id),t.unshift(e),n=o}}if(0===t.length)return;return t}(e);let c=null;i||(c=de(e),c&&c.length>250&&(c=null));t("text is:"+c);let u=new Map,f=new Map;const d=new Map,m=new ee(a,null,o),p=new ee(a,c,o),h=(e,n,o,r,s)=>{if(r<0)return;let i=e.get(n);i||(i=[],e.set(n,i)),i.push({css:o,offset:r,complexity:s}),t(`use css=${o}, cardinality=${n}, offset=${r}`)},w=function(e){const t=new Map;t.set(null,0);let n=e.parentNode;for(;n&&"BODY"!==n.tagName&&!Me(n);){for(const e of K(n)){if(t.has(e))continue;const n=le(document.body,e);if(n){const o=n.length;t.set(e,o)}}n=n.parentNode}const o=20;return Array.from(t.entries()).sort((([,e],[,t])=>e-t)).slice(0,o).map((([e])=>e))}(e),v=[e.tagName.toLowerCase(),...K(e)];t("shadowRootSelectors:",a),t("ancestorCssSelectors:",w),t("ownCssSelectors:",v);for(const r of v)for(const n of w){const o=n?`${n} ${r}`:r,s=n?2:1,i=m.query(o),l=Array.from(i),a=l.length;if(a>100){t(`cardinality too high css=${o}, cardinality=${a}`);continue}d.set(o,a);if(h(u,a,o,l.indexOf(e),s),c){const t=p.query(o),n=Array.from(t),r=n.indexOf(e);h(f,n.length,o,r,s)}}if(u.size>0||f.size>0){const r=e=>Array.from(e.entries()).map((([e,t])=>({cardinality:e,cssSelectors:t.sort(((e,t)=>{const n=d.get(e.css),o=d.get(t.css);return n!==o?n?o?n-o:-1:1:e.complexity!==t.complexity?t.complexity-e.complexity:e.css.localeCompare(t.css)})).map((({css:e,offset:t})=>({css:e,offset:t})))}))).sort(((e,t)=>e.cardinality-t.cardinality)),i={version:"v1",minorVersion:o.minorVersion,shadowRootSelectors:a,notextGroups:r(u),textGroups:r(f)},l={el:e,selector:{type:s.AUTO,autoData:JSON.stringify(i),text:c,elementType:n}};return t("inference result",l),l}return t("no selector inferred "),null}(e,n)}catch(l){console.error("Userflow findElement error:",l),i=null}return t("time",performance.now()-o),t.groupEnd(),V("userflow:inferSelector:end"),P("userflow:inferSelector","userflow:inferSelector:start","userflow:inferSelector:end"),i}function K(e){const t=[],r=e.tagName.toLowerCase();return n.inferenceAttributeNames.forEach((s=>{const i=e.getAttribute(s);if(!i)return;const l=n.inferenceAttributeFilters[s];if(!l||o(l,i))if("id"===s)t.push(`#${i}`);else{const e="name"===s||"placeholder"===s?r:"";t.push(`${e}[${s}="${i}"]`)}})),e.classList.forEach((e=>{o(n.inferenceClassNameFilters,e)&&t.push(`.${e.trim()}`)})),t}(window.userflow||{}).__inferSelector=J;class ee{constructor(e,t,n){this.shadowRootSelectors=e,this.text=t,this.ctx=n,this.isVisibleCache=new Map,this.textCache=new Map}*query(e){const n=le(document.body,e,this.shadowRootSelectors);if(t("found",n),!n)return;const{text:o}=this;for(let r=0;r<n.length;r++){const e=n[r];if(o){let n=this.textCache.get(e);if(null==n&&(n=pe(e,o),this.textCache.set(e,n)),!n){t("skip, text mismatch",e);continue}}let s=this.isVisibleCache.get(e);null==s&&(s=Le(e,this.ctx),this.isVisibleCache.set(e,s)),s?(t("yield",e),yield e):t("skip, not visible",e)}}}const te=4,ne=window.userflow||{};function oe(e){const n=performance.now();let o;V("userflow:findAllElements:start"),t.groupCollapsed("findAllElements",e);try{if(e.type===s.MANUAL)o=function(e){const n={minorVersion:null==e.minorVersion?1:e.minorVersion};let{css:o,text:s,elementType:i,offset:l}=e;s=s&&he(s);const a="nearSelector"in e?e.nearSelector:null;t("findAllElementsManual",e),null!=l&&null!=a&&console.warn("Userflow.js: Both selector.offset and selector.nearSelector was set; ignoring nearSelector.");let c;if(s&&!o){if(c=[],n.minorVersion>=2)for(const e of Fe())ie(e,s,c);else ie(document.body,s,c);t("els after traverseElementForText",c)}else if(o){if(n.minorVersion>=2){c=[];for(const e of Fe()){const t=le(e,o);t&&t.length>0&&c.push(...t)}}else c=Array.from(le(document.body,o)||[]);t("els after safeQueryAll",c),s&&(c=function(e,t){const n=[];for(let o=e.length-1;o>=0;o--){const r=e[o];n.some((e=>e.contains(r)))||pe(r,t)&&n.push(r)}return n.reverse()}(c,s),t("els after filterElementsByText",c))}else console.warn("Userflow.js: findAllElements() requires least one of `css` and `text` to be set."),c=[];c.length>0&&(c=c.filter((e=>Le(e,n))),t("els after isVisible",c));c.length>0&&i===r.INPUT&&(c=function(e,n){const o=new Set,r=new Q(n),s=ve();for(const i of e){if(i.matches(s)){o.add(i);continue}let e=null,n=null;r.getAllInputs().forEach((o=>{const s=r.calcScore(i,o);t("input",s,o),0!==s&&(e&&n&&s<=n||(t("input is best so far"),e=o,n=s))})),e&&(t("best input was",e),o.add(e))}return Array.from(o)}(c,n),t("els after mapElementsToInputs",c));c.length>0&&(c.sort(((e,t)=>{const n=ke(e),o=ke(t);return n.top<o.top?-1:n.top>o.top?1:n.left-o.left})),t("els after sort",c));if(c.length>0)if(null!=l)c=c[l]?[c[l]]:[],t("els after offset",c);else if(null!=a){const e=oe(a);let n=null,o=0;for(const t of c)for(const r of e){const e=B(ke(t),ke(r));(!n||e<o)&&(n=t,o=e)}c=n?[n]:[],t("els after nearSelector",c)}return c}(e);else if(e.autoData){const n=JSON.parse(e.autoData);let r;if("v1"!==n.version)throw new E(n.version,"Unknown autoData version: "+n.version);r=function(e,n){const{text:o,excludeText:r,precision:s}=e,i={minorVersion:n.minorVersion||0},l=null!=o&&!r,a=l?n.textGroups:n.notextGroups,c=Math.max(1,Math.min(a.length,Math.ceil((1-parseFloat(s||"1"))*a.length))),u=new ee(n.shadowRootSelectors,l&&o||null,i);t("findElementAutoV1",{text:o,excludeText:r,precision:s,groups:a,groupCount:c});for(let f=0;f<c;f++){const e=a[f];let n=new Map,o=0,r=null;t.group(`group cardinality=${e.cardinality}`,e);try{for(let s=0;s<e.cssSelectors.length;s++){const{css:i,offset:l}=e.cssSelectors[s];t(`css=${i}, offset=${l}`);let a=u.query(i),c=null;for(let e=0;e<=l;e++){const e=a.next();if(e.done)break;c=e.value}if(!c)continue;const f=(n.get(c)||0)+1;if(n.set(c,f),t(`el with frequency=${f}`+(f>o&&c!==r?" NEW BEST":""),c),f>o&&(o=f,r=c,f>=Math.ceil(e.cssSelectors.length/2)))return t("early winner",r),r}}finally{t.groupEnd()}if(r)return t("winner",r),r}return t("element not found"),null}(e,n),o=r?[r]:[]}else o=[]}catch(i){console.error("Userflow findElement error:",i),o=[]}return t("time",performance.now()-n),t.groupEnd(),V("userflow:findAllElements:end"),P("userflow:findAllElements","userflow:findAllElements:start","userflow:findAllElements:end"),o}function re(e){return oe(e)[0]||null}function se(e,n){const o=performance.now();let r;V("userflow:elementMatchesSelector:start"),t.groupCollapsed("elementMatchesSelector",e,n);try{if(n.type===s.MANUAL)r=function(e,t){null!=t.offset&&console.warn("Userflow.js: selector.offset is not supported for elementMatchesSelector yet");"nearSelector"in t&&null!=t.nearSelector&&console.warn("Userflow.js: selector.nearSelector is not supported for elementMatchesSelector yet");let{css:n,text:o}=t;o=o&&he(o);let r=!1,s=e;for(;s&&"BODY"!==s.tagName;){if((!n||s.matches(n))&&(!o||pe(s,o))){r=!0;break}s=s.parentElement}return r}(e,n);else{const t=re(n);r=null!=t&&t.contains(e)}}catch(i){console.error("Userflow findElement error:",i),r=!1}return t(r?"match":"not match"),t("time",performance.now()-o),t.groupEnd(),V("userflow:elementMatchesSelector:end"),P("userflow:elementMatchesSelector","userflow:elementMatchesSelector:start","userflow:elementMatchesSelector:end"),r}function ie(e,t,n){if(_e(e)){const{tagName:t}=e;if("SCRIPT"===t||"STYLE"===t)return!1}let o=!1;for(let r=0;r<e.children.length;r++)ie(e.children[r],t,n)&&(o=!0);return!o&&_e(e)&&pe(e,t)&&(n.push(e),o=!0),o}function le(e,t,n){try{if(null==n)return e.querySelectorAll(t);return ae(t,n,0,e)}catch(o){return console.warn("Userflow.js: Invalid CSS selector: ",t),null}}function ae(e,t,n,o){if(n>=t.length)return Array.from(o.querySelectorAll(e));const r=t[n],s=o.querySelectorAll(r),i=[];return s.forEach((o=>{let r;if(o.shadowRoot)r=o.shadowRoot;else{if(!Ie(o))return;let e=null;try{e=o.contentDocument}catch(s){}if(!e)return;r=e.body}i.push(...ae(e,t,n+1,r))})),i}const ce={email:!0,number:!0,password:!0,search:!0,tel:!0,text:!0,url:!0},ue={date:!0,"datetime-local":!0,month:!0,time:!0,week:!0},fe={button:!0,email:!0,reset:!0,search:!0,submit:!0,tel:!0,text:!0,url:!0};function de(e){let t=e.innerText;return void 0===t&&"SELECT"!==e.tagName&&(t=e.textContent),t=he(t),t||null}function me(e){if(Ee(e)||ge(e)){const t=he(e.getAttribute("placeholder")),n=e.value||"";if(t&&!n)return t;const o=he(n);if(o&&function(e){if(ge(e))return!0;const t=(e.getAttribute("type")||"").toLowerCase();return fe[t]}(e))return o}if(ye(e)&&e.selectedIndex>=0){const t=he(e.options[e.selectedIndex].text);if(t)return t}return de(e)}function pe(e,t){const n=me(e);return!!n&&function(e,t){const n=e.toLowerCase();if(t.toLowerCase()===n)return!0;return!1}(t,n)}function he(e){return e?e.length>250?null:e.replace(/^[\s\uFEFF\xA0\u200B*]+|[\s\uFEFF\xA0\u200B*]+$/g,"").replace(/\s+/g," "):null}function we(e){for(const{cssSelector:o,getValue:r}of n.customInputs)if(e.matches(o)){if(!r)return me(e)||"";try{return(r(e)||"").trim()}catch(t){return console.error(`Userflow.js: getValue function for custom input '${o}' failed:`,t),""}}return ye(e)?-1==e.selectedIndex?"":e.options[e.selectedIndex].text:be(e)?me(e)||"":e.value}function ve(){return"input, select, textarea, [contenteditable]"+n.customInputs.map((({cssSelector:e})=>`, ${e}`)).join("")}function Ee(e){if("INPUT"!==e.tagName)return!1;const t=e.getAttribute("type");return null==t||!0===ce[(t||"").toLowerCase()]}function ge(e){return"TEXTAREA"===e.tagName}function ye(e){return"SELECT"===e.tagName}function be(e){return"hasAttribute"in e&&e.hasAttribute("contenteditable")}function Te(e){return!!be(e)||!!n.customInputs.some((({cssSelector:t})=>e.matches(t)))}function Se(e){return Ee(e)||function(e){if("INPUT"!==e.tagName)return!1;const t=(e.getAttribute("type")||"").toLowerCase();return!0===ue[t]}(e)||ge(e)||ye(e)||Te(e)}function Le(e,n){const o=ke(e);let r=e,s=!0,i=!1,l=!1,a=!1,c=!1;for(;r;){const u=r===document.body,f="BODY"===r.tagName,d=window.getComputedStyle(r);let m=null;if(s){if(d.visibility&&"visible"!==d.visibility)return t("not visible because visibility is",d.visibility,e,{cur:r}),!1;s=!1}if("none"===d.display)return t("not visible because display is",d.display,e,{cur:r}),!1;if(null!=d.opacity&&parseFloat(d.opacity)<.01)return t("not visible because opacity is",d.opacity,e,{cur:r}),!1;if("absolute"===d.position?a=!0:"relative"!==d.position&&"fixed"!==d.position&&"sticky"!==d.position||(a=!1),n.minorVersion>=4&&!i&&!f&&(!c||"static"!==d.position)&&(Ne(d.overflowX)||Ne(d.overflowY))&&(m=m||ke(r),0===m.width||0===m.height))return t("not visible because width/height (v1.4 check) is",m.width,m.height,e,{cur:r}),!1;if(!l&&Ae(d.display)&&(n.minorVersion<1||f||"static"!==d.position)){const n=f||Ne(d.overflow),s=n||Ne(d.overflowX),i=n||Ne(d.overflowY),{scrollLeft:c,scrollTop:u}=f?r.ownerDocument.documentElement:r,p=!f&&!a;if(s){if(m=m||ke(r),p&&0===m.width)return t("not visible because width is",m.width,e,{cur:r}),!1;const n=Math.round(m.left-c);if(Math.round(o.left)<n)return t("not visible because it's clipped left",e,{left:n,cur:r}),!1}if(i){if(m=m||ke(r),p&&0===m.height)return t("not visible because height is",m.height,e,{cur:r}),!1;const n=Math.round(m.top-u);if(Math.round(o.top)<n)return t("not visible because it's clipped top",e,{top:n,cur:r}),!1}(s||i)&&(l=!0)}if("fixed"===d.position&&(i=!0,l=!0),n.minorVersion>=3&&(r.scrollTop>0||r.scrollLeft>0)&&(l=!0),u)break;f?(r=De(r),s=!0):r=r.parentElement,c=a}return!0}function Ne(e){return"hidden"===e||"clip"===e||"scroll"===e||"auto"===e}function Ae(e){return!e||!e.includes("inline")&&"contents"!==e}function xe(e){let t=e.parentNode,n=!1;for(;t&&"BODY"!==t.tagName;){Me(t)&&(t=t.host);const o=window.getComputedStyle(t);if("absolute"===o.position?n=!0:"relative"!==o.position&&"fixed"!==o.position&&"sticky"!==o.position||(n=!1),!n&&Ae(o.display)&&(Ne(o.overflow)||Ne(o.overflowY)))return t;if("fixed"===o.position)return e.ownerDocument.documentElement;t=t.parentNode}return e.ownerDocument.documentElement}function ke(e){if("HTML"===e.tagName){const t=De(e);if(t)return ke(t)}let t=e.getBoundingClientRect(),n=e;for(;n&&(n=De(n),n);){const e=n.getBoundingClientRect();t={width:t.width,height:t.height,left:t.left+e.left,right:t.right+e.left,top:t.top+e.top,bottom:t.bottom+e.top}}return t}const Ce=new WeakSet;function De(e){const t=e.ownerDocument?.defaultView;if(!t)return null;if(Ce.has(t))return null;{const e=t.frameElement;return e||Ce.add(t),e}}function Me(e){return"object"==typeof e&&null!=e&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e&&"mode"in e}function _e(e){return"object"==typeof e&&null!=e&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Ie(e){return _e(e)&&"IFRAME"===e.tagName}ne.__findElement=re,ne.__findAllElements=oe,ne.__elementMatchesSelector=se,ne.__getElementText=me,ne.__getInputValue=we;const Ue=new Set,Re=new Map,Oe=new Set;function Fe(){return Pe(),Ue}function Be(e,t){Pe();for(const o of Ue)e(o);const n={setup:e,teardown:t};return Oe.add(n),()=>{Oe.delete(n);for(const e of Ue)t(e)}}let $e=!1,Ve=null;function Pe(){if(qe(),!$e){t("roots started"),$e=!0,Ve=document.body,Ye(Ve);for(const e of i)document.addEventListener(e,je);window.setInterval(qe,1e4)}}function je(){Ve&&!document.contains(Ve)&&(t("roots detected new Turbo body"),ze(Ve),Ve=document.body,Ye(Ve))}function qe(){for(const e of Ue)Me(e)&&(We(e)||(t("roots clean before removeRoot",e),ze(e)));t("roots clean finished, remaining=",Ue.size)}function We(e){if(!e.ownerDocument.defaultView)return!1;let t=e.host;for(;t;){if(Me(t)&&(t=t.host),_e(t)&&"BODY"===t.tagName)return!0;t=t.parentNode}return!1}function Ye(e){if(!Ue.has(e)){t("roots addRoot",e),Ue.add(e),function(e){let t;const n=()=>{Ge(e)},o=new O((()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(n)}));o.observe(e,{childList:!0,subtree:!0}),Re.set(e,o)}(e),Ge(e),function(e){const n=e.ownerDocument.defaultView;if(n.__userflowAttachShadowInstalled)return;n.__userflowAttachShadowInstalled=!0;const o=n.Element.prototype.attachShadow;null!=o&&(n.Element.prototype.attachShadow=function(e){const n=o.call(this,e);return this.shadowRoot&&(t("roots monitorShadowDom before addRoot",this,this.shadowRoot),Ye(this.shadowRoot)),n})}(e),function(e){const n=e=>{e.childNodes.forEach((e=>{_e(e)&&e.shadowRoot&&(t("roots queryShadowDom before addRoot",e,e.shadowRoot),Ye(e.shadowRoot)),n(e)}))};n(e)}(e);for(const{setup:t}of Oe)t(e)}}function ze(e){if(Ue.has(e)){t("roots removeRoot",e),Re.get(e)?.disconnect(),Re.delete(e),Ue.delete(e);for(const{teardown:t}of Oe)t(e)}}function Ge(e){const t=_e(e)?e.ownerDocument.getElementsByTagName("iframe"):e.querySelectorAll("iframe");for(const n of t)Xe(n)}const Ze=new WeakSet;function Xe(e){if(Ze.has(e))return;if(e.closest("#userflow-ui"))return;e.addEventListener("load",He);const n=e.contentWindow,o=e.contentDocument;if(!n||!o)return void Ze.add(e);const r=o.body;r&&(n.addEventListener("pagehide",Qe),t("roots setupFrame before addRoot",e,o,r),Ye(r))}function He(e){const t=e.target;t&&Ie(t)&&Xe(t)}function Qe(e){const n=e.currentTarget.document.body;t("roots onFrameUnload before removeRoot",n),ze(n)}function Je(e,t={}){let n,o;const r=()=>{o=void 0,e()},s=()=>{if(window.clearTimeout(n),null==o)o=Date.now();else if(Date.now()-o>1e3)return void r();n=window.setTimeout(r,50)},i=e=>{const t=e.target;if(!t||!Ke(t))return;const n=document.getElementById("userflow-ui");n&&n.contains(t)||s()},l=new O((e=>{(function(e){const t=document.getElementById("userflow-ui");for(const n of e){const{target:e}=n;if(Ke(e)&&(t&&t.contains(e)))return!0}return!1})(e)||s()})),a=Be((e=>{l.observe(e,{attributes:!0,subtree:!0,childList:!0,characterData:!0}),e.addEventListener("animationend",i),e.addEventListener("transitionend",i),t.observeInput&&(e.addEventListener("input",s),e.addEventListener("keypress",s),e.addEventListener("change",s))}),(e=>{e.removeEventListener("animationend",i),e.removeEventListener("transitionend",i),t.observeInput&&(e.removeEventListener("input",s),e.removeEventListener("keypress",s),e.removeEventListener("change",s))}));return{disconnect:()=>{window.clearTimeout(n),l.disconnect(),a()}}}function Ke(e){return e.nodeType===Node.ELEMENT_NODE}const et={[l.ALWAYS_TRUE]:{track:({callback:e})=>(e(!0),()=>{})},[l.ATTRIBUTE]:{track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{let o=!1;if(e&&t.operator){const n=e.value.find((e=>e.name===t.attributeName)),r=n?n.value:null;o=k[t.operator].compare({sessionData:e.value,condition:t,value:r})}n(o)};o();const r=e.observe(o);return()=>{r()}}},[l.CLAUSE]:{isExpensive:e=>{for(const t of e.conditions){const e=et[t.type];if(e.isExpensive&&e.isExpensive(t))return!0}return!1},track:({sessionData:t,condition:n,flipBackEvents:o,callback:r})=>{let s,i,l=null;const a=n.conditions.map((e=>{const t=et[e.type];return{condition:e,typeDef:t,expensive:!!t.isExpensive&&t.isExpensive(e),active:!1,isTrue:null}})),c=e=>{for(const n of a){const r=!o||!n.expensive||e;r&&!n.active?(n.active=!0,n.isTrue=!1,n.untrack=n.typeDef.track({sessionData:t,condition:n.condition,flipBackEvents:o,callback:(e,t={})=>{n.isTrue=e,window.clearTimeout(s),t.immediate?u({immediate:!0}):s=window.setTimeout(u,0)}})):!r&&n.active&&(n.untrack&&n.untrack(),n.active=!1,n.isTrue=null,n.untrack=void 0)}},u=(t={})=>{if(0===a.length)return void f(!1,t);let o,r;if(n.operator===e.AND){o=!0,r=!0;for(const e of a)!1===e.isTrue?(o=!1,e.expensive||(r=!1)):!1!==o&&null===e.isTrue&&(o=null)}else{o=!1,r=!0;for(const e of a)!0===e.isTrue?(o=!0,e.expensive||(r=!1)):!0!==o&&null===e.isTrue&&(o=null)}null!==o&&o!==l&&(l=o,f(o,t)),c(r)},f=(e,t)=>{if(e&&null!=n.waitTime&&"0"!=n.waitTime){if(!i){const e=1e3*parseFloat(n.waitTime);i=window.setTimeout((()=>{r(!0,{})}),e)}}else window.clearTimeout(i),i=void 0,r(e,t)};return c(!1),u(),()=>{window.clearTimeout(s),window.clearTimeout(i);for(const e of a)e.untrack&&e.untrack()}}},[l.ELEMENT]:{isExpensive:()=>!0,track:e=>{const{elementState:t}=e.condition;if(!t)return()=>{};const n=function(e){switch(e){case f.CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!0};case f.DISABLED:return{kind:"observer",checkElement:e=>!!e&&e.disabled};case f.MOUSEDOWN:return{kind:"event",eventName:"mousedown",valueWhenOccurred:!0};case f.NOT_CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!1};case f.NOT_DISABLED:return{kind:"observer",checkElement:e=>!!e&&!e.disabled};case f.NOT_PRESENT:return{kind:"observer",checkElement:e=>!e};case f.PRESENT:return{kind:"observer",checkElement:e=>!!e}}}(t);switch(n.kind){case"observer":return function({sessionData:e,condition:t,callback:n},o){const r=()=>{if(!t.elementState)return void console.warn("Userflow.js: ELEMENT_STATE condition missing elementState",t);if(!t.selector)return void console.warn("Userflow.js: ELEMENT_STATE condition missing selector",t);let r=!1;const s=oe(S(t.selector,e.value));if(s.length>0){for(const e of s)if(o(e)){r=!0;break}}else o(null)&&(r=!0);n(r)};r();const s=e.observe(r),{disconnect:i}=Je(r);return()=>{s(),i()}}(e,n.checkElement);case"event":return function({condition:e,flipBackEvents:t,callback:n},o,r){const{selector:s}=e;if(!s)return()=>{};let i;n(!r);const l=e=>{const o=e.target;o&&se(o,s)&&(t?(n(r,{immediate:!0}),n(!r,{immediate:!0})):n(r))},a={capture:!0},c=Be((e=>e.addEventListener(o,l,a)),(e=>e.removeEventListener(o,l,a)));return()=>{c(),window.clearTimeout(i)}}(e,n.eventName,n.valueWhenOccurred)}}},[l.FILLED_IN_INPUT]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{let o,r=null;const s=()=>{if(!t.selector)return void console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);const s=oe(S(t.selector,e.value));let i=null;for(const e of s){const t=we(e);if(t){i=t;break}}i?i!=r&&(window.clearTimeout(o),o=window.setTimeout((()=>{n(!0)}),1e3)):(n(!1),window.clearTimeout(o)),r=i};s();const i=e.observe(s),{disconnect:l}=Je(s,{observeInput:!0});return()=>{i(),l(),window.clearTimeout(o)}}},[l.FLOW]:{track:()=>(console.warn("Userflow.js: Flow conditions do not work client-side"),()=>{})},[l.INPUT_VALUE]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{if(!t.operator)return void console.warn("Userflow.js: INPUT_VALUE condition missing operator",t);if(!t.selector)return void console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);let o=!1;const r=k[t.operator],s=oe(S(t.selector,e.value));if(s.length>0)for(const n of s){const s=we(n);if(r.compare({sessionData:e.value,condition:t,value:s})){o=!0;break}}else r.compare({sessionData:e.value,condition:t,value:""})&&(o=!0);n(o)};o();const r=e.observe(o),{disconnect:s}=Je(o,{observeInput:!0});return()=>{r(),s()}}},[l.PAGE]:{track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{let o=!1;if(t.operator){const n=a();o=k[t.operator].compare({sessionData:e.value,condition:t,value:n})}n(o)};let r=a();const s=()=>{const e=a();e!==r&&(r=e,o())};c(s),o();const i=e.observe(o);return()=>{i(),u(s)}}},[l.TIME]:{track:({condition:e,callback:t})=>{let n=null;const o=e.value?new Date(e.value):null,r=e.value2?new Date(e.value2):null,s=()=>{let e=!0;(o&&!isNaN(o.valueOf())&&Date.now()<o.valueOf()||r&&!isNaN(r.valueOf())&&Date.now()>=r.valueOf())&&(e=!1),e!==n&&(n=e,t(e))};s();const i=window.setInterval(s,1e4);return()=>{window.clearInterval(i)}}}};var tt=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",conditionTypes:et});export{O as M,G as a,b,et as c,y as d,_e as e,X as f,z as g,re as h,T as i,xe as j,Y as k,W as l,Be as m,Me as n,Je as o,De as p,J as q,ke as r,Z as s,S as t,Ie as u,tt as v,j as z};
package/flow-host.css CHANGED
@@ -332,6 +332,54 @@ _:future,
332
332
  .userflowjs-checklist-launcher--position-fixed {
333
333
  position: fixed;
334
334
  }
335
+ .userflowjs-banner {
336
+ display: block;
337
+ left: 0;
338
+ right: 0;
339
+ height: var(--userflowjs-banner-height);
340
+ }
341
+ .userflowjs-banner--animate-true {
342
+ animation-name: userflowjs-banner-animate-in;
343
+ animation-duration: 400ms;
344
+ animation-timing-function: ease-in-out;
345
+ }
346
+ .userflowjs-banner--embed-mode-BODY_FIRST,
347
+ .userflowjs-banner--embed-mode-ELEMENT_FIRST,
348
+ .userflowjs-banner--embed-mode-ELEMENT_BEFORE,
349
+ .userflowjs-banner--embed-mode-ELEMENT_AFTER {
350
+ top: 0;
351
+ }
352
+ .userflowjs-banner--embed-mode-BODY_LAST,
353
+ .userflowjs-banner--embed-mode-ELEMENT_LAST {
354
+ bottom: 0;
355
+ }
356
+ .userflowjs-banner--embed-mode-BODY_FIRST.userflowjs-banner--overlay-false.userflowjs-banner--sticky-true,
357
+ .userflowjs-banner--embed-mode-BODY_LAST.userflowjs-banner--overlay-false.userflowjs-banner--sticky-true {
358
+ position: sticky;
359
+ }
360
+ .userflowjs-banner--embed-mode-BODY_FIRST.userflowjs-banner--overlay-true.userflowjs-banner--sticky-false,
361
+ .userflowjs-banner--embed-mode-BODY_LAST.userflowjs-banner--overlay-true.userflowjs-banner--sticky-false {
362
+ position: absolute;
363
+ }
364
+ .userflowjs-banner--embed-mode-BODY_FIRST.userflowjs-banner--overlay-true.userflowjs-banner--sticky-true,
365
+ .userflowjs-banner--embed-mode-BODY_LAST.userflowjs-banner--overlay-true.userflowjs-banner--sticky-true {
366
+ position: fixed;
367
+ }
368
+ .userflowjs-banner--embed-mode-ELEMENT_FIRST.userflowjs-banner--overlay-true.userflowjs-banner--sticky-false,
369
+ .userflowjs-banner--embed-mode-ELEMENT_LAST.userflowjs-banner--overlay-true.userflowjs-banner--sticky-false {
370
+ position: absolute;
371
+ }
372
+ .userflowjs-banner--embed-mode-ELEMENT_FIRST.userflowjs-banner--sticky-true,
373
+ .userflowjs-banner--embed-mode-ELEMENT_LAST.userflowjs-banner--sticky-true,
374
+ .userflowjs-banner--embed-mode-ELEMENT_BEFORE.userflowjs-banner--sticky-true,
375
+ .userflowjs-banner--embed-mode-ELEMENT_AFTER.userflowjs-banner--sticky-true {
376
+ position: sticky;
377
+ }
378
+ .userflowjs-frame {
379
+ display: block;
380
+ width: 100%;
381
+ height: 100%;
382
+ }
335
383
  .userflowjs-resource-center-frame {
336
384
  overflow: hidden;
337
385
  display: block;
@@ -392,6 +440,48 @@ _:future,
392
440
  width: var(--userflow-resource-center-width);
393
441
  border-radius: var(--userflow-bubble-border-radius);
394
442
  }
443
+ .userflowjs-notifications {
444
+ position: fixed;
445
+ left: 1rem;
446
+ bottom: 1rem;
447
+ width: 400px;
448
+ }
449
+ .userflowjs-notifications__toast {
450
+ display: flex;
451
+ margin-top: 1rem;
452
+ padding: 1rem;
453
+ border-radius: 0.25rem;
454
+ background-color: #eb1e47;
455
+ color: #fff;
456
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
457
+ font-size: 14px;
458
+ }
459
+ .userflowjs-notifications__toast-content {
460
+ min-width: 0;
461
+ flex: 1 1 0%;
462
+ margin-right: 1rem;
463
+ }
464
+ .userflowjs-notifications__toast-label {
465
+ font-weight: 600;
466
+ margin-right: 0.5rem;
467
+ }
468
+ .userflowjs-notifications__toast-dismiss {
469
+ cursor: pointer;
470
+ width: 24px;
471
+ height: 24px;
472
+ color: #700013;
473
+ display: flex;
474
+ align-items: center;
475
+ justify-content: center;
476
+ }
477
+ .userflowjs-notifications__toast-dismiss:hover {
478
+ color: #fdc9d5;
479
+ }
480
+ .userflowjs-notifications__toast-dismiss svg {
481
+ display: block;
482
+ width: 16px;
483
+ height: 16px;
484
+ }
395
485
  @supports (-ms-ime-align: auto) {
396
486
  .userflowjs-bubble,
397
487
  .userflowjs-bubble__avatar,
@@ -680,3 +770,35 @@ _:future,
680
770
  transform: rotate(180deg) translateY(0);
681
771
  }
682
772
  }
773
+ @-moz-keyframes userflowjs-banner-animate-in {
774
+ 0% {
775
+ height: 0;
776
+ }
777
+ 100% {
778
+ height: var(--userflowjs-banner-height);
779
+ }
780
+ }
781
+ @-webkit-keyframes userflowjs-banner-animate-in {
782
+ 0% {
783
+ height: 0;
784
+ }
785
+ 100% {
786
+ height: var(--userflowjs-banner-height);
787
+ }
788
+ }
789
+ @-o-keyframes userflowjs-banner-animate-in {
790
+ 0% {
791
+ height: 0;
792
+ }
793
+ 100% {
794
+ height: var(--userflowjs-banner-height);
795
+ }
796
+ }
797
+ @keyframes userflowjs-banner-animate-in {
798
+ 0% {
799
+ height: 0;
800
+ }
801
+ 100% {
802
+ height: var(--userflowjs-banner-height);
803
+ }
804
+ }
@@ -0,0 +1 @@
1
+ import{r as e}from"./vendor.react.js";import{c as n}from"./userflow.js";const t=0,s=10,r=2e3;function o(e){return n.baseZIndex+e}const c=[];function a(){const e={zIndex:0===c.length?o(100):c[c.length-1].zIndex+10};return c.push(e),e}function u(e){const n=c.indexOf(e);-1!==n&&c.splice(n,1)}function f(){const[n,t]=e.useState(a);e.useEffect((()=>()=>u(n)),[n]);const s=e.useCallback((()=>{u(n),t(a())}),[n]);return{zIndex:n.zIndex,bringToFront:s}}const i=({children:n})=>{const{zIndex:t}=f();return e.createElement(d.Provider,{value:t},n)},d=e.createContext(void 0);function l(){return e.useContext(d)||o(100)}var x=new URL("flow-host.css",import.meta.url).href;export{s as C,t as L,r as N,i as S,l as a,x as f,f as u,o as w};
package/hash.txt CHANGED
@@ -1 +1 @@
1
- 53e7a638e9705c2972ea921bdf76597964322592
1
+ 33a3d42edba46ad2749df8ae9e83ee4ef675f234
package/logomark.js CHANGED
@@ -1 +1 @@
1
- import{r as e}from"./vendor.react.js";import{r as t}from"./vendor.react-dom.js";import{g as s,a as r,c as o}from"./stylesheets.js";import{a,i as n}from"./client-context.js";import{c as l}from"./userflow.js";var i=new URL("iframe-reset.css",import.meta.url).href;const d=({testId:t,className:a,style:n,elRef:d,stylesheet:f,theme:u,onStylesheetsLoad:h,noIframe:y,ariaHidden:w,children:p})=>{y=y||!1;const[E,v]=e.useState(null),R=u&&"userflowjs-theme-root",L=u&&s(u),{loaded:N}=r(E,y?null:i),{loaded:g}=r(E,f,u),{loaded:I}=o(E,u),C=l.serverEndpoint||"cdn.userflow.com",S=u?.cssVersion?`https://${C}/themes/${u.id}/stylesheets/${u.cssVersion}/custom.css`:null,{loaded:j}=r(E,S,u);return e.useEffect((()=>{h&&N&&g&&I&&j&&h(!0)}),[h,N,g,I,j]),y?e.createElement(m,{testId:t,className:a,style:n,rootClassName:R,rootStyle:L,elRef:d,onWinReady:v,ariaHidden:w},p):e.createElement(c,{testId:t,className:a,style:n,rootClassName:R,rootStyle:L,elRef:d,onWinReady:v,ariaHidden:w},p)},c=({testId:s,className:r,style:o,rootClassName:l,rootStyle:i,elRef:d,onWinReady:c,ariaHidden:m,children:f})=>{const u=a(),[h,y]=e.useState(null);e.useLayoutEffect((()=>{if(!h)return;const{documentElement:e,body:t}=h.document;e.dir=n.dir();const s=l&&l.split(" ");if(s&&t.classList.add(...s),i)for(const r in i)t.style.setProperty(r,i[r]);return()=>{s&&t.classList.remove(...s)}}),[h,l,i]);const w=u?.logrocketAppId,p=e.useRef(!1);e.useEffect((()=>{if(!h||!w||p.current)return;if(!window.LogRocket?.tabID)return;p.current=!0;const e=h.document.createElement("script");e.crossOrigin="anonymous",e.src="https://cdn.lr-in-prod.com/LogRocket.min.js",e.onload=()=>{h.LogRocket.init(w,{mergeIframes:!0})},h.document.head.appendChild(e)}),[h,w]);return e.createElement("iframe",{ref:e=>{if(!e)return;d&&(d.current=e);const t=e.contentWindow;if(!t||t===h)return;const s=e=>{y(e),c(e)};"complete"===t.document.readyState?s(t):t.addEventListener("load",(()=>{s(t)}))},"data-testid":s,role:"presentation","aria-hidden":m?"true":void 0,tabIndex:m?-1:void 0,className:r,style:o,frameBorder:0,bis_size:"{}"},h&&t.createPortal(f,h.document.body))},m=({testId:t,className:s,style:r,rootClassName:o,rootStyle:a,elRef:l,onWinReady:i,ariaHidden:d,children:c})=>(e.useEffect((()=>{i(window)}),[i]),e.createElement("div",{ref:l,"data-testid":t,"aria-hidden":d?"true":void 0,tabIndex:d?-1:void 0,dir:n.dir(),className:s,style:r},e.createElement("div",{className:o,style:a},c)));function f(t){e.useLayoutEffect((()=>{let e;const s=()=>{window.cancelAnimationFrame(e),e=window.requestAnimationFrame(t)};return window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s),window.cancelAnimationFrame(e)}}),[t])}const u=t=>e.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 100 100"},t),e.createElement("path",{fill:"#23d777",d:"m61.539 30.37-1.652 9.37c-1.762 10-11.293 18-21.244 18h-8.159c-10.011 0-16.628-8.09-14.877-18l3.314-18.77h9.42l-3.313 18.77a6.992 6.992 0 0 0 1.405 6.088 7.006 7.006 0 0 0 5.713 2.542h8.16a10.77 10.77 0 0 0 6.58-2.553 10.748 10.748 0 0 0 3.58-6.077l2.483-14.07a5.849 5.849 0 0 1 5.537-4.7h17.43l1.08-6.15C78.448 6.63 72.992 0 64.783 0H24.738C16.548 0 8.72 6.63 7.288 14.82l-7.008 40C-1.16 63 4.285 69.63 12.494 69.63h40.045c8.199 0 16.018-6.63 17.45-14.81l4.314-24.45H61.54Z"}),e.createElement("path",{fill:"#1a57e6",d:"M87.668 30.37h-4.004l-6.097 34.57c-1.442 8.18-9.26 14.82-17.45 14.82h-36.09l-.951 5.43C21.624 93.37 27.08 100 35.289 100h40.045c8.19 0 16.018-6.63 17.45-14.81l7.008-40c1.531-8.18-3.935-14.82-12.124-14.82Z"}));export{d as F,u as S,f as u};
1
+ import{r as e}from"./vendor.react.js";const l=l=>e.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 100 100"},l),e.createElement("path",{fill:"#23d777",d:"m61.539 30.37-1.652 9.37c-1.762 10-11.293 18-21.244 18h-8.159c-10.011 0-16.628-8.09-14.877-18l3.314-18.77h9.42l-3.313 18.77a6.992 6.992 0 0 0 1.405 6.088 7.006 7.006 0 0 0 5.713 2.542h8.16a10.77 10.77 0 0 0 6.58-2.553 10.748 10.748 0 0 0 3.58-6.077l2.483-14.07a5.849 5.849 0 0 1 5.537-4.7h17.43l1.08-6.15C78.448 6.63 72.992 0 64.783 0H24.738C16.548 0 8.72 6.63 7.288 14.82l-7.008 40C-1.16 63 4.285 69.63 12.494 69.63h40.045c8.199 0 16.018-6.63 17.45-14.81l4.314-24.45H61.54Z"}),e.createElement("path",{fill:"#1a57e6",d:"M87.668 30.37h-4.004l-6.097 34.57c-1.442 8.18-9.26 14.82-17.45 14.82h-36.09l-.951 5.43C21.624 93.37 27.08 100 35.289 100h40.045c8.19 0 16.018-6.63 17.45-14.81l7.008-40c1.531-8.18-3.935-14.82-12.124-14.82Z"}));export{l as S};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1003773",
3
+ "version": "0.1.1003813",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
package/stylesheets.js CHANGED
@@ -1 +1 @@
1
- import{r as o}from"./vendor.react.js";import{m as r,n as t,j as e,h as n,o as l,g as u,p as a,q as c,r as i,s as d,t as s,i as g,u as f,v as h,w as B,x as C,y as b,z as w}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{a as k,b as p,c as m,d as v,e as y,g as F,h as H,i as A,j as x,k as M}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{x as L,B as S,A as I,y as W}from"./userflow.js";import{c as z}from"./flow-condition-types.js";import{a as j}from"./client-context.js";function E(r){const[t]=o.useState((()=>new L(r)));return t.update(r),t}const $=({icon:r,size:t})=>{t=t||16;const e="string"==typeof r&&T[r]?T[r]:r;if("string"==typeof e)return o.createElement("img",{"aria-hidden":"true",src:e,width:t,height:t,style:{objectFit:"contain"}});{const r=e.icon[0],n=e.icon[1],l=e.icon[4];return o.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:`0 0 ${r} ${n}`},o.createElement("path",{fill:"currentColor",d:String(l)}))}},T={"regular/calendar-day":r,"regular/comment-alt":t,"regular/comments-alt":e,"regular/envelope":n,"regular/exclamation-triangle":l,"regular/external-link":u,"regular/file-alt":a,"regular/graduation-cap":c,"regular/info-circle":i,"regular/lightbulb":d,"regular/pencil":s,"regular/phone":g,"regular/play-circle":f,"regular/question-circle":h,"regular/shoe-prints":B,"solid/shoe-prints":k,"solid/file-invoice":p,"solid/receipt":m,"solid/university":v,"solid/users":y,"solid/stars":F,"regular/tasks":C,"regular/user":b,"regular/users":w,"solid/exclamation-triangle":H,"solid/info-circle":A,"solid/play-circle":x,"solid/question-circle":M};function q(o){return o?o.match(/^#[0-9a-f]{6}$/i)?[parseInt(o.substring(1,3),16),parseInt(o.substring(3,5),16),parseInt(o.substring(5,7),16)]:o.match(/^#[0-9a-f]{3}$/i)?[parseInt(o.substring(1,2).repeat(2),16),parseInt(o.substring(2,3).repeat(2),16),parseInt(o.substring(3,4).repeat(2),16)]:[0,0,0]:[0,0,0]}function P([o,r,t]){return"#"+o.toString(16).padStart(2,"0")+r.toString(16).padStart(2,"0")+t.toString(16).padStart(2,"0")}function R(o){const r=q(o);return r?r.join(", "):"0, 0, 0"}function U(o){return P(q(o))}function D(o,r,t){return[Math.max(0,Math.min(255,Math.round(o[0]+(r[0]-o[0])*t))),Math.max(0,Math.min(255,Math.round(o[1]+(r[1]-o[1])*t))),Math.max(0,Math.min(255,Math.round(o[2]+(r[2]-o[2])*t)))]}function O(o,r,t){const e=q(o),n=q(r);return e&&n?P(D(e,n,t)):o}function N([o,r,t]){o/=255,r/=255,t/=255;const e=Math.max(o,r,t),n=Math.min(o,r,t);let l,u,a=(e+n)/2;if(e==n)l=u=0;else{const c=e-n;switch(u=a>.5?c/(2-e-n):c/(e+n),e){case o:l=(r-t)/c+(r<t?6:0);break;case r:l=(t-o)/c+2;break;default:l=(o-r)/c+4}l/=6}return[l,u,a]}function G([o,r,t]){let e=r/255,n=t/255;function l(o){let r=0;return r=o<=.04045?o/12.92:Math.pow((o+.055)/1.055,2.4),r}let u=.2126*l(o/255)+.7152*l(e)+.0722*l(n);return Math.round(10*function(o){let r=0;return r=o<=216/24389?o*(24389/27):116*Math.pow(o,1/3)-16,r}(u))/1e3}function K(o,r){const t=G(o),e=G(r);let n=.13*((1-(e-t))/2)+.05,l=1-Math.abs(e-t),u=n+Math.pow((1-n)*l,4);return Math.round(1e3*u)/1e3}function X(o,r){const t=q(o),e=N(t);let n=null,l=null;for(const d of r){const o=q(d),r=N(o);let t=!1;if(n&&l){const o=.3;Math.abs(r[2]-e[2])>o?r[1]>l[1]&&(t=!0):Math.abs(e[2]-r[2])>Math.abs(e[2]-l[2])&&(t=!0)}else t=!0;t&&(n=o,l=r)}let u=n,a=n,c=K(u,t),i=2*c;return e[2]>.2&&e[2]<.8&&(a=function([o,r,t]){return[Math.round(255-o),Math.round(255-r),Math.round(255-t)]}(a),i=K(a,t)),[P(D(t,u,c)),P(D(t,a,i))]}function Y(o){const[r,t,e,n,l,u,a,c]=function(o,r,t,e){const[n,l]=X(o,[r]);let u,a;if(o===t)u=n,a=l;else{const n=X(t,[o,r,e]);u=n[0],a=n[1]}const c=q(o),i=q(t);let d,s,g,f;if(Math.abs(c[0]-i[0])<20&&Math.abs(c[1]-i[1])<20&&Math.abs(c[2]-i[2])<20){d=r,s=o;const t=X(d,[s]);g=t[0],f=t[1]}else d=o,s=r,g=n,f=l;return[n,l,u,a,d,s,g,f]}(o.brandBackgroundColor,o.brandForegroundColor,o.mainBackgroundColor,o.mainForegroundColor),i={...o,widgetBackgroundColor:l,widgetForegroundColor:u,widgetHoverBackgroundColor:a,widgetActiveBackgroundColor:c,sameBackground:U(o.mainBackgroundColor)==U(o.brandBackgroundColor)};if(i.brandHoverBackgroundColor&&(i.widgetHoverBackgroundColor=i.brandHoverBackgroundColor),i.brandActiveBackgroundColor&&(i.widgetActiveBackgroundColor=i.brandActiveBackgroundColor),i.brandHoverBackgroundColor||(i.brandHoverBackgroundColor=r),i.brandActiveBackgroundColor||(i.brandActiveBackgroundColor=t),i.mainHoverBackgroundColor||(i.mainHoverBackgroundColor=e),i.mainActiveBackgroundColor||(i.mainActiveBackgroundColor=n),i.bubbleBorderColor||(i.bubbleBorderColor=i.mainForegroundColor),i.checklistLauncherActiveBackgroundColor||(i.checklistLauncherActiveBackgroundColor=i.brandActiveBackgroundColor),i.checklistLauncherBackgroundColor||(i.checklistLauncherBackgroundColor=i.brandBackgroundColor),i.checklistLauncherCounterBackgroundColor||(i.checklistLauncherCounterBackgroundColor=i.brandForegroundColor),i.checklistLauncherCounterFontColor||(i.checklistLauncherCounterFontColor=i.brandBackgroundColor),i.checklistLauncherFontColor||(i.checklistLauncherFontColor=i.brandForegroundColor),i.checklistLauncherHoverBackgroundColor||(i.checklistLauncherHoverBackgroundColor=i.brandHoverBackgroundColor),i.focusColor||(i.focusColor=i.mainActiveBackgroundColor),i.launcherIconActiveColor||(i.launcherIconActiveColor=i.brandActiveBackgroundColor),i.launcherIconColor||(i.launcherIconColor=i.brandBackgroundColor),i.launcherIconHoverColor||(i.launcherIconHoverColor=i.brandHoverBackgroundColor),i.linkColor||(i.linkColor=i.widgetBackgroundColor),i.progressBarColor||(i.progressBarColor=i.widgetBackgroundColor),i.questionColor||(i.questionColor=i.widgetBackgroundColor),i.toolbarForegroundColor||(i.toolbarForegroundColor=i.mainForegroundColor),i.primaryButtonBackgroundColor||(i.primaryButtonBackgroundColor=i.widgetBackgroundColor),i.primaryButtonFontColor||(i.primaryButtonFontColor=i.widgetForegroundColor),i.primaryButtonHoverFontColor||(i.primaryButtonHoverFontColor=i.primaryButtonFontColor),i.primaryButtonActiveFontColor||(i.primaryButtonActiveFontColor=i.primaryButtonFontColor),!i.primaryButtonHoverBackgroundColor||!i.primaryButtonActiveBackgroundColor){const[o,r]=X(i.primaryButtonBackgroundColor,[i.primaryButtonFontColor]);i.primaryButtonHoverBackgroundColor||(i.primaryButtonHoverBackgroundColor=o),i.primaryButtonActiveBackgroundColor||(i.primaryButtonActiveBackgroundColor=r)}if(i.primaryButtonBorderColor||(i.primaryButtonBorderColor=i.widgetBackgroundColor),i.primaryButtonHoverBorderColor||(i.primaryButtonHoverBorderColor=i.primaryButtonHoverBackgroundColor),i.primaryButtonActiveBorderColor||(i.primaryButtonActiveBorderColor=i.primaryButtonActiveBackgroundColor),i.defaultButtonBackgroundColor||(i.defaultButtonBackgroundColor=i.mainBackgroundColor),i.defaultButtonFontColor||(i.defaultButtonFontColor=l),i.defaultButtonHoverFontColor||(i.defaultButtonHoverFontColor=i.defaultButtonFontColor),i.defaultButtonActiveFontColor||(i.defaultButtonActiveFontColor=i.defaultButtonFontColor),!i.defaultButtonHoverBackgroundColor||!i.defaultButtonActiveBackgroundColor){const[o,r]=X(i.defaultButtonBackgroundColor,[i.defaultButtonFontColor]);i.defaultButtonHoverBackgroundColor||(i.defaultButtonHoverBackgroundColor=o),i.defaultButtonActiveBackgroundColor||(i.defaultButtonActiveBackgroundColor=r)}return i.defaultButtonBorderColor||(i.defaultButtonBorderColor=i.defaultButtonFontColor),i.defaultButtonHoverBorderColor||(i.defaultButtonHoverBorderColor=i.defaultButtonBorderColor),i.defaultButtonActiveBorderColor||(i.defaultButtonActiveBorderColor=i.defaultButtonBorderColor),i.launcherButtonBackgroundColor||(i.launcherButtonBackgroundColor=i.brandBackgroundColor),i.launcherButtonBorderColor||(i.launcherButtonBorderColor=i.brandBackgroundColor),i.launcherButtonFontColor||(i.launcherButtonFontColor=i.brandForegroundColor),i.launcherButtonHoverBackgroundColor||(i.launcherButtonHoverBackgroundColor=i.brandHoverBackgroundColor),i.launcherButtonHoverBorderColor||(i.launcherButtonHoverBorderColor=i.launcherButtonHoverBackgroundColor),i.launcherButtonHoverFontColor||(i.launcherButtonHoverFontColor=i.launcherButtonFontColor),i.launcherButtonActiveBackgroundColor||(i.launcherButtonActiveBackgroundColor=i.brandActiveBackgroundColor),i.launcherButtonActiveBorderColor||(i.launcherButtonActiveBorderColor=i.launcherButtonActiveBackgroundColor),i.launcherButtonActiveFontColor||(i.launcherButtonActiveFontColor=i.launcherButtonFontColor),i}function J(o){const{questionColor:r}=o;return{"--userflow-backdrop-highlight-color-rgb":R(o.backdropHighlightColor),"--userflow-backdrop-highlight-inset":o.backdropHighlightType===S.INSIDE?"inset":"","--userflow-backdrop-highlight-opacity":o.backdropHighlightOpacity,"--userflow-backdrop-highlight-radius":o.backdropHighlightRadius+"px","--userflow-backdrop-highlight-spread":o.backdropHighlightSpread+"px","--userflow-backdrop-opacity":o.backdropOpacity,"--userflow-beacon-color":o.beaconColor,"--userflow-brand-active-background-color":o.brandActiveBackgroundColor,"--userflow-brand-background-color":o.brandBackgroundColor,"--userflow-brand-foreground-color":o.brandForegroundColor,"--userflow-brand-foreground-color-rgb":R(o.brandForegroundColor),"--userflow-brand-hover-background-color":o.brandHoverBackgroundColor,"--userflow-bubble-border-color":o.bubbleBorderColor,"--userflow-bubble-border-radius":o.bubbleBorderRadius+"px","--userflow-bubble-border-width":o.bubbleBorderWidth+"px","--userflow-button-border-radius":o.buttonBorderRadius+"px","--userflow-button-height":o.buttonHeight+"px","--userflow-button-min-width":o.buttonMinWidth+"px","--userflow-button-text-align":0===o.buttonMinWidth?"start":"center","--userflow-buttons-justify-content":"left"===o.buttonHorizontalAlign?"flex-start":"center"===o.buttonHorizontalAlign?"center":"flex-end","--userflow-buttons-modal-justify-content":"left"===o.buttonHorizontalAlign?"flex-start":"right"===o.buttonHorizontalAlign?"flex-end":"center","--userflow-checklist-launcher-active-background-color":o.checklistLauncherActiveBackgroundColor,"--userflow-checklist-launcher-background-color":o.checklistLauncherBackgroundColor,"--userflow-checklist-launcher-border-radius":o.checklistLauncherBorderRadius+"px","--userflow-checklist-launcher-counter-background-color":o.checklistLauncherCounterBackgroundColor,"--userflow-checklist-launcher-counter-font-color":o.checklistLauncherCounterFontColor,"--userflow-checklist-launcher-font-color-rgb":R(o.checklistLauncherFontColor),"--userflow-checklist-launcher-font-color":o.checklistLauncherFontColor,"--userflow-checklist-launcher-font-weight":String(o.checklistLauncherFontWeight),"--userflow-checklist-launcher-height":o.checklistLauncherHeight+"px","--userflow-checklist-launcher-hover-background-color":o.checklistLauncherHoverBackgroundColor,"--userflow-checkmark-background-color":o.checkmarkBackgroundColor,"--userflow-completed-task-text-decoration":o.completedTaskTextDecoration,"--userflow-default-button-active-background-color":o.defaultButtonActiveBackgroundColor,"--userflow-default-button-active-border-color":o.defaultButtonActiveBorderColor,"--userflow-default-button-active-font-color":o.defaultButtonActiveFontColor,"--userflow-default-button-background-color":o.defaultButtonBackgroundColor,"--userflow-default-button-border-color":o.defaultButtonBorderColor,"--userflow-default-button-border-width":o.defaultButtonBorderWidth+"px","--userflow-default-button-font-color":o.defaultButtonFontColor,"--userflow-default-button-font-weight":String(o.defaultButtonFontWeight),"--userflow-default-button-hover-background-color":o.defaultButtonHoverBackgroundColor,"--userflow-default-button-hover-border-color":o.defaultButtonHoverBorderColor,"--userflow-default-button-hover-font-color":o.defaultButtonHoverFontColor,"--userflow-focus-color":`rgba(${R(o.focusColor)}, ${o.focusOpacity})`,"--userflow-font-family":o.builtinFontFamily?o.builtinFontFamily.name+(o.builtinFontFamily.fallback?", "+o.builtinFontFamily.fallback:""):o.fontFamily?o.fontFamily:"sans-serif","--userflow-font-size":o.fontSize+"px","--userflow-font-weight-bold":String(o.fontWeightBold),"--userflow-font-weight-normal":String(o.fontWeightNormal),"--userflow-h1-font-size":o.h1FontSize+"px","--userflow-h2-font-size":o.h2FontSize+"px","--userflow-launcher-button-active-background-color":o.launcherButtonActiveBackgroundColor,"--userflow-launcher-button-active-border-color":o.launcherButtonActiveBorderColor,"--userflow-launcher-button-active-font-color":o.launcherButtonActiveFontColor,"--userflow-launcher-button-background-color":o.launcherButtonBackgroundColor,"--userflow-launcher-button-border-color":o.launcherButtonBorderColor,"--userflow-launcher-button-border-radius":o.launcherButtonBorderRadius+"px","--userflow-launcher-button-border-width":o.launcherButtonBorderWidth+"px","--userflow-launcher-button-font-color":o.launcherButtonFontColor,"--userflow-launcher-button-font-weight":String(o.launcherButtonFontWeight),"--userflow-launcher-button-height":o.launcherButtonHeight+"px","--userflow-launcher-button-horizontal-padding":o.launcherButtonHorizontalPadding+"px","--userflow-launcher-button-hover-background-color":o.launcherButtonHoverBackgroundColor,"--userflow-launcher-button-hover-border-color":o.launcherButtonHoverBorderColor,"--userflow-launcher-button-hover-font-color":o.launcherButtonHoverFontColor,"--userflow-launcher-button-width":o.launcherButtonWidth?o.launcherButtonWidth+"px":"auto","--userflow-launcher-icon-active-color":o.launcherIconActiveColor,"--userflow-launcher-icon-color":o.launcherIconColor,"--userflow-launcher-icon-hover-color":o.launcherIconHoverColor,"--userflow-launcher-icon-opacity":o.launcherIconOpacity,"--userflow-launcher-icon-size":o.launcherIconSize+"px","--userflow-line-height":o.lineHeight+"px","--userflow-link-color":o.linkColor,"--userflow-main-active-background-color":o.mainActiveBackgroundColor,"--userflow-main-background-color":o.mainBackgroundColor,"--userflow-main-background-color-rgb":R(o.mainBackgroundColor),"--userflow-main-foreground-color":o.mainForegroundColor,"--userflow-main-foreground-color-rgb":R(o.mainForegroundColor),"--userflow-main-hover-background-color":o.mainHoverBackgroundColor,"--userflow-modal-padding":o.modalPadding+"px","--userflow-modal-padding-top":(o.avatarType===I.NONE?o.modalPadding:o.modalPadding+Math.max((o.avatarSize-o.modalPadding)/2,0))+"px","--userflow-backdrop-color-rgb":R(o.backdropColor),"--userflow-notch-color":o.bubbleBorderWidth>0&&o.bubbleBorderColor||o.mainBackgroundColor,"--userflow-primary-button-active-background-color":o.primaryButtonActiveBackgroundColor,"--userflow-primary-button-active-border-color":o.primaryButtonActiveBorderColor,"--userflow-primary-button-active-font-color":o.primaryButtonActiveFontColor,"--userflow-primary-button-background-color":o.primaryButtonBackgroundColor,"--userflow-primary-button-border-color":o.primaryButtonBorderColor,"--userflow-primary-button-border-width":o.primaryButtonBorderWidth+"px","--userflow-primary-button-font-color":o.primaryButtonFontColor,"--userflow-primary-button-font-weight":String(o.primaryButtonFontWeight),"--userflow-primary-button-hover-background-color":o.primaryButtonHoverBackgroundColor,"--userflow-primary-button-hover-border-color":o.primaryButtonHoverBorderColor,"--userflow-primary-button-hover-font-color":o.primaryButtonHoverFontColor,"--userflow-progress-bar-color":o.progressBarColor,"--userflow-progress-bar-height":o.progressBarHeight+"px","--userflow-resource-center-collapsed-height":o.resourceCenterCollapsedHeight+"px","--userflow-resource-center-launcher-border-radius":(null!=o.resourceCenterLauncherBorderRadius?o.resourceCenterLauncherBorderRadius:o.resourceCenterCollapsedHeight/2)+"px","--userflow-resource-center-padding-x":o.resourceCenterPaddingX+"px","--userflow-resource-center-padding-y":o.resourceCenterPaddingY+"px","--userflow-resource-center-transition-duration":o.resourceCenterTransitionDuration+"ms","--userflow-resource-center-width":o.resourceCenterWidth+"px","--userflow-question-color-light":O(r,o.mainBackgroundColor,.5),"--userflow-question-color-lighter":O(r,o.mainBackgroundColor,.75),"--userflow-question-color-lightest":O(r,o.mainBackgroundColor,.9),"--userflow-question-color-medium-light":O(r,o.mainBackgroundColor,.15),"--userflow-question-color":r,"--userflow-toolbar-foreground-color":o.toolbarForegroundColor,"--userflow-toolbar-foreground-color-rgb":R(o.toolbarForegroundColor),"--userflow-tooltip-notch-size":o.tooltipNotchSize+"px","--userflow-widget-active-background-color":o.widgetActiveBackgroundColor,"--userflow-widget-background-color":o.widgetBackgroundColor,"--userflow-widget-foreground-color":o.widgetForegroundColor,"--userflow-widget-hover-background-color":o.widgetHoverBackgroundColor}}const Q=[];function V(r){let[t,e]=o.useState(r);const n=E(r.sessionData||Q);return o.useLayoutEffect((()=>{const{variations:o}=r;if(!o)return;const t=[],l=[],u=()=>{let n=r,l=!1;for(const[r,e]of o.entries())if(t[r]){l||(l=!0,n={...n});for(const o of e.overriddenKeys)n[o]=e[o]}e(n)};for(const[r,e]of o.entries()){t[r]=!1;const{condition:o}=e;if(o&&e.overriddenKeys&&e.overriddenKeys.length>0){const e=z[o.type].track({sessionData:n,condition:o,callback:o=>{t[r]=o,u()}});l[r]=e}else l[r]=()=>{}}return u(),()=>{for(const o of l)o()}}),[r,n]),o.useMemo((()=>Y(t)),[t])}const Z=new Map;function _(o){let r=Z.get(o);return r||(r={stylesheets:new Map},Z.set(o,r)),r}function oo(r,t,e){const n=j(),[l,u]=o.useState(!t);return o.useLayoutEffect((()=>{if(!r||!t)return;let o,l=!1;const a=async t=>{await eo(n,r,t),o&&function(o,r){const t=_(o),e=t.stylesheets.get(r);if(!e)return;o.document.head.removeChild(e.link),t.stylesheets.delete(r)}(r,o),o=t};(async()=>{let o="string"==typeof t?t:t.get();if(window.MSInputMethodContext&&document.documentMode&&e){let r=await function(o){return new Promise(((r,t)=>{let e=ro.get(o);if(e)return void r(e);const n=new XMLHttpRequest;n.addEventListener("load",(()=>{if(200!==n.status)return void t(new Error("Userflow.js could not fetch stylesheet: "+o));const e=n.responseText;ro.set(o,e),r(e)})),n.addEventListener("error",(()=>{t(new Error("Userflow.js could not fetch stylesheet: "+o))})),n.open("GET",o),n.send()}))}(o);if(l)return;r=function(o,r){for(const t in r)if(r.hasOwnProperty(t)){const e=r[t];e&&(o=o.replace(new RegExp(`var\\(${t}.*?\\)`,"g"),e))}return o=o.replace(/var\(--[a-z0-9-]+(,\s*(.*?))?\)/g,"$2")}(r,J(e)),o="data:text/css;base64,"+btoa(r)}await a(o),l||u(!0)})();let c=null;return"string"!=typeof t&&(c=t.onUpdate((async()=>{a(t.get())}))),()=>{l=!0,c&&c()}}),[n,r,t,e]),{loaded:l}}const ro=new Map;function to(r,t){const e=t&&function(o){if(!o.builtinFontFamily)return o.fontCssUrl?{url:o.fontCssUrl,fontFamily:o.fontFamily}:null;switch(o.builtinFontFamily.provider){case W.GOOGLE:{const r=Array.from(new Set(["0,400","1,400",`0,${o.fontWeightBold}`,`0,${o.defaultButtonFontWeight}`,`0,${o.primaryButtonFontWeight}`,`0,${o.checklistLauncherFontWeight}`,`0,${o.launcherButtonFontWeight}`])).sort().join(";");return{url:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(o.builtinFontFamily.name)}:ital,wght@${r}`,fontFamily:o.builtinFontFamily.name}}case W.STANDARD:return null}}(t),n=e?.url,l=e?.fontFamily,[u,a]=o.useState(!n||!l);return o.useLayoutEffect((()=>{if(!r||!n||!l)return;let o=!1;return eo(null,r,n),function(o,r,t){if(!o.document.fonts)return t(),()=>{};let e=!1;const n=()=>{const l=o.document.fonts.load(`100px ${r}`,"BESbswy");if(!l)return u(),void t();l.then((o=>{e||(o.length>=1?(u(),t()):window.setTimeout(n,25))}),(o=>{console.log("Userflow.js: observeFont error:"),console.log(o),t()}))};n();const l=window.setTimeout((()=>{console.warn(`Userflow.js: Timed out waiting for font family ${r} to load. Will continue anyway.`),t()}),2e3),u=()=>{e=!0,window.clearTimeout(void 0),window.clearTimeout(l)}}(r,l,(()=>{o||a(!0)})),()=>{o=!0}}),[r,n,l]),{loaded:u}}function eo(o,r,t){const e=_(r),n=e.stylesheets.get(t);if(n)return n.loadPromise;const l=r.document.createElement("link"),u=new Promise(((e,n)=>{l.dataset.userflowStylesheet="true",l.rel="stylesheet",l.href=t,l.onload=()=>{e()},l.onerror=r=>{console.log(`Userflow.js: Error installing Stylesheet ${t}:`,r),o&&o.reportCspIssue(),n()},r.document.head.appendChild(l)}));return e.stylesheets.set(t,{link:l,loadPromise:u}),u}export{$ as D,oo as a,E as b,to as c,J as g,V as u};
1
+ import{r as o}from"./vendor.react.js";import{k as r,l as t,j as e,h as n,m as l,g as u,n as a,o as c,p as i,q as d,r as s,i as g,s as f,t as h,u as B,v as C,w as b,x as k}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{a as w,b as p,c as m,d as v,e as y,g as F,h as H,i as A,j as x,k as M}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{x as L,y as S,A as I,c as W,z as $}from"./userflow.js";import{c as z}from"./flow-condition-types.js";import{a as E}from"./client-context.js";function j(r){const[t]=o.useState((()=>new L(r)));return t.update(r),t}const T=({icon:r,size:t})=>{t=t||16;const e="string"==typeof r&&q[r]?q[r]:r;if("string"==typeof e)return o.createElement("img",{"aria-hidden":"true",src:e,width:t,height:t,style:{objectFit:"contain"}});{const r=e.icon[0],n=e.icon[1],l=e.icon[4];return o.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:`0 0 ${r} ${n}`},o.createElement("path",{fill:"currentColor",d:String(l)}))}},q={"regular/calendar-day":r,"regular/comment-alt":t,"regular/comments-alt":e,"regular/envelope":n,"regular/exclamation-triangle":l,"regular/external-link":u,"regular/file-alt":a,"regular/graduation-cap":c,"regular/info-circle":i,"regular/lightbulb":d,"regular/pencil":s,"regular/phone":g,"regular/play-circle":f,"regular/question-circle":h,"regular/shoe-prints":B,"solid/shoe-prints":w,"solid/file-invoice":p,"solid/receipt":m,"solid/university":v,"solid/users":y,"solid/stars":F,"regular/tasks":C,"regular/user":b,"regular/users":k,"solid/exclamation-triangle":H,"solid/info-circle":A,"solid/play-circle":x,"solid/question-circle":M};function P(o){return o?o.match(/^#[0-9a-f]{6}$/i)?[parseInt(o.substring(1,3),16),parseInt(o.substring(3,5),16),parseInt(o.substring(5,7),16)]:o.match(/^#[0-9a-f]{3}$/i)?[parseInt(o.substring(1,2).repeat(2),16),parseInt(o.substring(2,3).repeat(2),16),parseInt(o.substring(3,4).repeat(2),16)]:[0,0,0]:[0,0,0]}function R([o,r,t]){return"#"+o.toString(16).padStart(2,"0")+r.toString(16).padStart(2,"0")+t.toString(16).padStart(2,"0")}function U(o){const r=P(o);return r?r.join(", "):"0, 0, 0"}function D(o){return R(P(o))}function O(o,r,t){return[Math.max(0,Math.min(255,Math.round(o[0]+(r[0]-o[0])*t))),Math.max(0,Math.min(255,Math.round(o[1]+(r[1]-o[1])*t))),Math.max(0,Math.min(255,Math.round(o[2]+(r[2]-o[2])*t)))]}function N(o,r,t){const e=P(o),n=P(r);return e&&n?R(O(e,n,t)):o}function G([o,r,t]){o/=255,r/=255,t/=255;const e=Math.max(o,r,t),n=Math.min(o,r,t);let l,u,a=(e+n)/2;if(e==n)l=u=0;else{const c=e-n;switch(u=a>.5?c/(2-e-n):c/(e+n),e){case o:l=(r-t)/c+(r<t?6:0);break;case r:l=(t-o)/c+2;break;default:l=(o-r)/c+4}l/=6}return[l,u,a]}function K([o,r,t]){let e=r/255,n=t/255;function l(o){let r=0;return r=o<=.04045?o/12.92:Math.pow((o+.055)/1.055,2.4),r}let u=.2126*l(o/255)+.7152*l(e)+.0722*l(n);return Math.round(10*function(o){let r=0;return r=o<=216/24389?o*(24389/27):116*Math.pow(o,1/3)-16,r}(u))/1e3}function V(o,r){const t=K(o),e=K(r);let n=.13*((1-(e-t))/2)+.05,l=1-Math.abs(e-t),u=n+Math.pow((1-n)*l,4);return Math.round(1e3*u)/1e3}function X(o,r){const t=P(o),e=G(t);let n=null,l=null;for(const d of r){const o=P(d),r=G(o);let t=!1;if(n&&l){const o=.3;Math.abs(r[2]-e[2])>o?r[1]>l[1]&&(t=!0):Math.abs(e[2]-r[2])>Math.abs(e[2]-l[2])&&(t=!0)}else t=!0;t&&(n=o,l=r)}let u=n,a=n,c=V(u,t),i=2*c;return e[2]>.2&&e[2]<.8&&(a=function([o,r,t]){return[Math.round(255-o),Math.round(255-r),Math.round(255-t)]}(a),i=V(a,t)),[R(O(t,u,c)),R(O(t,a,i))]}function Y(o){const[r,t,e,n,l,u,a,c]=function(o,r,t,e){const[n,l]=X(o,[r]);let u,a;if(o===t)u=n,a=l;else{const n=X(t,[o,r,e]);u=n[0],a=n[1]}const c=P(o),i=P(t);let d,s,g,f;if(Math.abs(c[0]-i[0])<20&&Math.abs(c[1]-i[1])<20&&Math.abs(c[2]-i[2])<20){d=r,s=o;const t=X(d,[s]);g=t[0],f=t[1]}else d=o,s=r,g=n,f=l;return[n,l,u,a,d,s,g,f]}(o.brandBackgroundColor,o.brandForegroundColor,o.mainBackgroundColor,o.mainForegroundColor),i={...o,widgetBackgroundColor:l,widgetForegroundColor:u,widgetHoverBackgroundColor:a,widgetActiveBackgroundColor:c,sameBackground:D(o.mainBackgroundColor)==D(o.brandBackgroundColor)};i.brandHoverBackgroundColor&&(i.widgetHoverBackgroundColor=i.brandHoverBackgroundColor),i.brandActiveBackgroundColor&&(i.widgetActiveBackgroundColor=i.brandActiveBackgroundColor),i.brandHoverBackgroundColor||(i.brandHoverBackgroundColor=r),i.brandActiveBackgroundColor||(i.brandActiveBackgroundColor=t),i.mainHoverBackgroundColor||(i.mainHoverBackgroundColor=e),i.mainActiveBackgroundColor||(i.mainActiveBackgroundColor=n),i.bannerBackgroundColor||(i.bannerBackgroundColor=i.brandBackgroundColor),i.bannerForegroundColor||(i.bannerForegroundColor=i.brandForegroundColor);const[d,s]=X(i.bannerBackgroundColor,[i.bannerForegroundColor]);i.bannerHoverBackgroundColor=d,i.bannerActiveBackgroundColor=s;const[g,f]=X(i.bannerForegroundColor,[i.bannerBackgroundColor]);if(i.bannerHoverForegroundColor=g,i.bannerActiveForegroundColor=f,i.bubbleBorderColor||(i.bubbleBorderColor=i.mainForegroundColor),i.checklistLauncherActiveBackgroundColor||(i.checklistLauncherActiveBackgroundColor=i.brandActiveBackgroundColor),i.checklistLauncherBackgroundColor||(i.checklistLauncherBackgroundColor=i.brandBackgroundColor),i.checklistLauncherCounterBackgroundColor||(i.checklistLauncherCounterBackgroundColor=i.brandForegroundColor),i.checklistLauncherCounterFontColor||(i.checklistLauncherCounterFontColor=i.brandBackgroundColor),i.checklistLauncherFontColor||(i.checklistLauncherFontColor=i.brandForegroundColor),i.checklistLauncherHoverBackgroundColor||(i.checklistLauncherHoverBackgroundColor=i.brandHoverBackgroundColor),i.focusColor||(i.focusColor=i.mainActiveBackgroundColor),i.launcherIconActiveColor||(i.launcherIconActiveColor=i.brandActiveBackgroundColor),i.launcherIconColor||(i.launcherIconColor=i.brandBackgroundColor),i.launcherIconHoverColor||(i.launcherIconHoverColor=i.brandHoverBackgroundColor),i.linkColor||(i.linkColor=i.widgetBackgroundColor),i.progressBarColor||(i.progressBarColor=i.widgetBackgroundColor),i.questionColor||(i.questionColor=i.widgetBackgroundColor),i.toolbarForegroundColor||(i.toolbarForegroundColor=i.mainForegroundColor),i.primaryButtonBackgroundColor||(i.primaryButtonBackgroundColor=i.widgetBackgroundColor),i.primaryButtonFontColor||(i.primaryButtonFontColor=i.widgetForegroundColor),i.primaryButtonHoverFontColor||(i.primaryButtonHoverFontColor=i.primaryButtonFontColor),i.primaryButtonActiveFontColor||(i.primaryButtonActiveFontColor=i.primaryButtonFontColor),!i.primaryButtonHoverBackgroundColor||!i.primaryButtonActiveBackgroundColor){const[o,r]=X(i.primaryButtonBackgroundColor,[i.primaryButtonFontColor]);i.primaryButtonHoverBackgroundColor||(i.primaryButtonHoverBackgroundColor=o),i.primaryButtonActiveBackgroundColor||(i.primaryButtonActiveBackgroundColor=r)}if(i.primaryButtonBorderColor||(i.primaryButtonBorderColor=i.widgetBackgroundColor),i.primaryButtonHoverBorderColor||(i.primaryButtonHoverBorderColor=i.primaryButtonHoverBackgroundColor),i.primaryButtonActiveBorderColor||(i.primaryButtonActiveBorderColor=i.primaryButtonActiveBackgroundColor),i.defaultButtonBackgroundColor||(i.defaultButtonBackgroundColor=i.mainBackgroundColor),i.defaultButtonFontColor||(i.defaultButtonFontColor=l),i.defaultButtonHoverFontColor||(i.defaultButtonHoverFontColor=i.defaultButtonFontColor),i.defaultButtonActiveFontColor||(i.defaultButtonActiveFontColor=i.defaultButtonFontColor),!i.defaultButtonHoverBackgroundColor||!i.defaultButtonActiveBackgroundColor){const[o,r]=X(i.defaultButtonBackgroundColor,[i.defaultButtonFontColor]);i.defaultButtonHoverBackgroundColor||(i.defaultButtonHoverBackgroundColor=o),i.defaultButtonActiveBackgroundColor||(i.defaultButtonActiveBackgroundColor=r)}return i.defaultButtonBorderColor||(i.defaultButtonBorderColor=i.defaultButtonFontColor),i.defaultButtonHoverBorderColor||(i.defaultButtonHoverBorderColor=i.defaultButtonBorderColor),i.defaultButtonActiveBorderColor||(i.defaultButtonActiveBorderColor=i.defaultButtonBorderColor),i.launcherButtonBackgroundColor||(i.launcherButtonBackgroundColor=i.brandBackgroundColor),i.launcherButtonBorderColor||(i.launcherButtonBorderColor=i.brandBackgroundColor),i.launcherButtonFontColor||(i.launcherButtonFontColor=i.brandForegroundColor),i.launcherButtonHoverBackgroundColor||(i.launcherButtonHoverBackgroundColor=i.brandHoverBackgroundColor),i.launcherButtonHoverBorderColor||(i.launcherButtonHoverBorderColor=i.launcherButtonHoverBackgroundColor),i.launcherButtonHoverFontColor||(i.launcherButtonHoverFontColor=i.launcherButtonFontColor),i.launcherButtonActiveBackgroundColor||(i.launcherButtonActiveBackgroundColor=i.brandActiveBackgroundColor),i.launcherButtonActiveBorderColor||(i.launcherButtonActiveBorderColor=i.launcherButtonActiveBackgroundColor),i.launcherButtonActiveFontColor||(i.launcherButtonActiveFontColor=i.launcherButtonFontColor),i}function J(o){const{questionColor:r}=o;return{"--userflow-backdrop-highlight-color-rgb":U(o.backdropHighlightColor),"--userflow-backdrop-highlight-inset":o.backdropHighlightType===S.INSIDE?"inset":"","--userflow-backdrop-highlight-opacity":o.backdropHighlightOpacity,"--userflow-backdrop-highlight-radius":o.backdropHighlightRadius+"px","--userflow-backdrop-highlight-spread":o.backdropHighlightSpread+"px","--userflow-backdrop-opacity":o.backdropOpacity,"--userflow-banner-background-color":o.bannerBackgroundColor,"--userflow-banner-hover-background-color":o.bannerHoverBackgroundColor,"--userflow-banner-active-background-color":o.bannerActiveBackgroundColor,"--userflow-banner-foreground-color":o.bannerForegroundColor,"--userflow-banner-hover-foreground-color":o.bannerHoverForegroundColor,"--userflow-banner-active-foreground-color":o.bannerActiveForegroundColor,"--userflow-beacon-color":o.beaconColor,"--userflow-brand-active-background-color":o.brandActiveBackgroundColor,"--userflow-brand-background-color":o.brandBackgroundColor,"--userflow-brand-foreground-color":o.brandForegroundColor,"--userflow-brand-foreground-color-rgb":U(o.brandForegroundColor),"--userflow-brand-hover-background-color":o.brandHoverBackgroundColor,"--userflow-bubble-border-color":o.bubbleBorderColor,"--userflow-bubble-border-radius":o.bubbleBorderRadius+"px","--userflow-bubble-border-width":o.bubbleBorderWidth+"px","--userflow-button-border-radius":o.buttonBorderRadius+"px","--userflow-button-height":o.buttonHeight+"px","--userflow-button-min-width":o.buttonMinWidth+"px","--userflow-button-text-align":0===o.buttonMinWidth?"start":"center","--userflow-buttons-justify-content":"left"===o.buttonHorizontalAlign?"flex-start":"center"===o.buttonHorizontalAlign?"center":"flex-end","--userflow-buttons-modal-justify-content":"left"===o.buttonHorizontalAlign?"flex-start":"right"===o.buttonHorizontalAlign?"flex-end":"center","--userflow-checklist-launcher-active-background-color":o.checklistLauncherActiveBackgroundColor,"--userflow-checklist-launcher-background-color":o.checklistLauncherBackgroundColor,"--userflow-checklist-launcher-border-radius":o.checklistLauncherBorderRadius+"px","--userflow-checklist-launcher-counter-background-color":o.checklistLauncherCounterBackgroundColor,"--userflow-checklist-launcher-counter-font-color":o.checklistLauncherCounterFontColor,"--userflow-checklist-launcher-font-color-rgb":U(o.checklistLauncherFontColor),"--userflow-checklist-launcher-font-color":o.checklistLauncherFontColor,"--userflow-checklist-launcher-font-weight":String(o.checklistLauncherFontWeight),"--userflow-checklist-launcher-height":o.checklistLauncherHeight+"px","--userflow-checklist-launcher-hover-background-color":o.checklistLauncherHoverBackgroundColor,"--userflow-checkmark-background-color":o.checkmarkBackgroundColor,"--userflow-completed-task-text-decoration":o.completedTaskTextDecoration,"--userflow-default-button-active-background-color":o.defaultButtonActiveBackgroundColor,"--userflow-default-button-active-border-color":o.defaultButtonActiveBorderColor,"--userflow-default-button-active-font-color":o.defaultButtonActiveFontColor,"--userflow-default-button-background-color":o.defaultButtonBackgroundColor,"--userflow-default-button-border-color":o.defaultButtonBorderColor,"--userflow-default-button-border-width":o.defaultButtonBorderWidth+"px","--userflow-default-button-font-color":o.defaultButtonFontColor,"--userflow-default-button-font-weight":String(o.defaultButtonFontWeight),"--userflow-default-button-hover-background-color":o.defaultButtonHoverBackgroundColor,"--userflow-default-button-hover-border-color":o.defaultButtonHoverBorderColor,"--userflow-default-button-hover-font-color":o.defaultButtonHoverFontColor,"--userflow-focus-color":`rgba(${U(o.focusColor)}, ${o.focusOpacity})`,"--userflow-font-family":o.builtinFontFamily?o.builtinFontFamily.name+(o.builtinFontFamily.fallback?", "+o.builtinFontFamily.fallback:""):o.fontFamily?o.fontFamily:"sans-serif","--userflow-font-size":o.fontSize+"px","--userflow-font-weight-bold":String(o.fontWeightBold),"--userflow-font-weight-normal":String(o.fontWeightNormal),"--userflow-h1-font-size":o.h1FontSize+"px","--userflow-h2-font-size":o.h2FontSize+"px","--userflow-launcher-button-active-background-color":o.launcherButtonActiveBackgroundColor,"--userflow-launcher-button-active-border-color":o.launcherButtonActiveBorderColor,"--userflow-launcher-button-active-font-color":o.launcherButtonActiveFontColor,"--userflow-launcher-button-background-color":o.launcherButtonBackgroundColor,"--userflow-launcher-button-border-color":o.launcherButtonBorderColor,"--userflow-launcher-button-border-radius":o.launcherButtonBorderRadius+"px","--userflow-launcher-button-border-width":o.launcherButtonBorderWidth+"px","--userflow-launcher-button-font-color":o.launcherButtonFontColor,"--userflow-launcher-button-font-weight":String(o.launcherButtonFontWeight),"--userflow-launcher-button-height":o.launcherButtonHeight+"px","--userflow-launcher-button-horizontal-padding":o.launcherButtonHorizontalPadding+"px","--userflow-launcher-button-hover-background-color":o.launcherButtonHoverBackgroundColor,"--userflow-launcher-button-hover-border-color":o.launcherButtonHoverBorderColor,"--userflow-launcher-button-hover-font-color":o.launcherButtonHoverFontColor,"--userflow-launcher-button-width":o.launcherButtonWidth?o.launcherButtonWidth+"px":"auto","--userflow-launcher-icon-active-color":o.launcherIconActiveColor,"--userflow-launcher-icon-color":o.launcherIconColor,"--userflow-launcher-icon-hover-color":o.launcherIconHoverColor,"--userflow-launcher-icon-opacity":o.launcherIconOpacity,"--userflow-launcher-icon-size":o.launcherIconSize+"px","--userflow-line-height":o.lineHeight+"px","--userflow-link-color":o.linkColor,"--userflow-main-active-background-color":o.mainActiveBackgroundColor,"--userflow-main-background-color":o.mainBackgroundColor,"--userflow-main-background-color-rgb":U(o.mainBackgroundColor),"--userflow-main-foreground-color":o.mainForegroundColor,"--userflow-main-foreground-color-rgb":U(o.mainForegroundColor),"--userflow-main-hover-background-color":o.mainHoverBackgroundColor,"--userflow-modal-padding":o.modalPadding+"px","--userflow-modal-padding-top":(o.avatarType===I.NONE?o.modalPadding:o.modalPadding+Math.max((o.avatarSize-o.modalPadding)/2,0))+"px","--userflow-backdrop-color-rgb":U(o.backdropColor),"--userflow-notch-color":o.bubbleBorderWidth>0&&o.bubbleBorderColor||o.mainBackgroundColor,"--userflow-primary-button-active-background-color":o.primaryButtonActiveBackgroundColor,"--userflow-primary-button-active-border-color":o.primaryButtonActiveBorderColor,"--userflow-primary-button-active-font-color":o.primaryButtonActiveFontColor,"--userflow-primary-button-background-color":o.primaryButtonBackgroundColor,"--userflow-primary-button-border-color":o.primaryButtonBorderColor,"--userflow-primary-button-border-width":o.primaryButtonBorderWidth+"px","--userflow-primary-button-font-color":o.primaryButtonFontColor,"--userflow-primary-button-font-weight":String(o.primaryButtonFontWeight),"--userflow-primary-button-hover-background-color":o.primaryButtonHoverBackgroundColor,"--userflow-primary-button-hover-border-color":o.primaryButtonHoverBorderColor,"--userflow-primary-button-hover-font-color":o.primaryButtonHoverFontColor,"--userflow-progress-bar-color":o.progressBarColor,"--userflow-progress-bar-height":o.progressBarHeight+"px","--userflow-resource-center-collapsed-height":o.resourceCenterCollapsedHeight+"px","--userflow-resource-center-launcher-border-radius":(null!=o.resourceCenterLauncherBorderRadius?o.resourceCenterLauncherBorderRadius:o.resourceCenterCollapsedHeight/2)+"px","--userflow-resource-center-padding-x":o.resourceCenterPaddingX+"px","--userflow-resource-center-padding-y":o.resourceCenterPaddingY+"px","--userflow-resource-center-transition-duration":o.resourceCenterTransitionDuration+"ms","--userflow-resource-center-width":o.resourceCenterWidth+"px","--userflow-question-color-light":N(r,o.mainBackgroundColor,.5),"--userflow-question-color-lighter":N(r,o.mainBackgroundColor,.75),"--userflow-question-color-lightest":N(r,o.mainBackgroundColor,.9),"--userflow-question-color-medium-light":N(r,o.mainBackgroundColor,.15),"--userflow-question-color":r,"--userflow-toolbar-foreground-color":o.toolbarForegroundColor,"--userflow-toolbar-foreground-color-rgb":U(o.toolbarForegroundColor),"--userflow-tooltip-notch-size":o.tooltipNotchSize+"px","--userflow-widget-active-background-color":o.widgetActiveBackgroundColor,"--userflow-widget-background-color":o.widgetBackgroundColor,"--userflow-widget-foreground-color":o.widgetForegroundColor,"--userflow-widget-hover-background-color":o.widgetHoverBackgroundColor}}const Q=[];function Z(r){let[t,e]=o.useState(r);const n=j(r.sessionData||Q);return o.useLayoutEffect((()=>{const{variations:o}=r;if(!o)return;const t=[],l=[],u=()=>{let n=r,l=!1;for(const[r,e]of o.entries())if(t[r]){l||(l=!0,n={...n});for(const o of e.overriddenKeys)n[o]=e[o]}e(n)};for(const[r,e]of o.entries()){t[r]=!1;const{condition:o}=e;if(o&&e.overriddenKeys&&e.overriddenKeys.length>0){const e=z[o.type].track({sessionData:n,condition:o,callback:o=>{t[r]=o,u()}});l[r]=e}else l[r]=()=>{}}return u(),()=>{for(const o of l)o()}}),[r,n]),o.useMemo((()=>Y(t)),[t])}function _(o){const r=W.serverEndpoint||"cdn.userflow.com";return o?.cssVersion?`https://${r}/themes/${o.id}/stylesheets/${o.cssVersion}/custom.css`:null}const oo=new Map;function ro(o){let r=oo.get(o);return r||(r={stylesheets:new Map},oo.set(o,r)),r}function to(r,t,e){const n=E(),[l,u]=o.useState(!t);return o.useLayoutEffect((()=>{if(!r||!t)return;let o,l=!1;const a=async t=>{await lo(n,r,t),o&&function(o,r){const t=ro(o),e=t.stylesheets.get(r);if(!e)return;o.document.head.removeChild(e.link),t.stylesheets.delete(r)}(r,o),o=t};(async()=>{let o="string"==typeof t?t:t.get();if(window.MSInputMethodContext&&document.documentMode&&e){let r=await function(o){return new Promise(((r,t)=>{let e=eo.get(o);if(e)return void r(e);const n=new XMLHttpRequest;n.addEventListener("load",(()=>{if(200!==n.status)return void t(new Error("Userflow.js could not fetch stylesheet: "+o));const e=n.responseText;eo.set(o,e),r(e)})),n.addEventListener("error",(()=>{t(new Error("Userflow.js could not fetch stylesheet: "+o))})),n.open("GET",o),n.send()}))}(o);if(l)return;r=function(o,r){for(const t in r)if(r.hasOwnProperty(t)){const e=r[t];e&&(o=o.replace(new RegExp(`var\\(${t}.*?\\)`,"g"),e))}return o=o.replace(/var\(--[a-z0-9-]+(,\s*(.*?))?\)/g,"$2")}(r,J(e)),o="data:text/css;base64,"+btoa(r)}await a(o),l||u(!0)})();let c=null;return"string"!=typeof t&&(c=t.onUpdate((async()=>{a(t.get())}))),()=>{l=!0,c&&c()}}),[n,r,t,e]),{loaded:l}}const eo=new Map;function no(r,t){const e=t&&function(o){if(!o.builtinFontFamily)return o.fontCssUrl?{url:o.fontCssUrl,fontFamily:o.fontFamily}:null;switch(o.builtinFontFamily.provider){case $.GOOGLE:{const r=Array.from(new Set(["0,400","1,400",`0,${o.fontWeightBold}`,`0,${o.defaultButtonFontWeight}`,`0,${o.primaryButtonFontWeight}`,`0,${o.checklistLauncherFontWeight}`,`0,${o.launcherButtonFontWeight}`])).sort().join(";");return{url:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(o.builtinFontFamily.name)}:ital,wght@${r}`,fontFamily:o.builtinFontFamily.name}}case $.STANDARD:return null}}(t),n=e?.url,l=e?.fontFamily,[u,a]=o.useState(!n||!l);return o.useLayoutEffect((()=>{if(!r||!n||!l)return;let o=!1;return lo(null,r,n),function(o,r,t){if(!o.document.fonts)return t(),()=>{};let e=!1;const n=()=>{const l=o.document.fonts.load(`100px ${r}`,"BESbswy");if(!l)return u(),void t();l.then((o=>{e||(o.length>=1?(u(),t()):window.setTimeout(n,25))}),(o=>{console.log("Userflow.js: observeFont error:"),console.log(o),t()}))};n();const l=window.setTimeout((()=>{console.warn(`Userflow.js: Timed out waiting for font family ${r} to load. Will continue anyway.`),t()}),2e3),u=()=>{e=!0,window.clearTimeout(void 0),window.clearTimeout(l)}}(r,l,(()=>{o||a(!0)})),()=>{o=!0}}),[r,n,l]),{loaded:u}}function lo(o,r,t){const e=ro(r),n=e.stylesheets.get(t);if(n)return n.loadPromise;const l=r.document.createElement("link"),u=new Promise(((e,n)=>{l.dataset.userflowStylesheet="true",l.rel="stylesheet",l.href=t,l.onload=()=>{e()},l.onerror=r=>{console.log(`Userflow.js: Error installing Stylesheet ${t}:`,r),o&&o.reportCspIssue(),n()},r.document.head.appendChild(l)}));return e.stylesheets.set(t,{link:l,loadPromise:u}),u}export{T as D,to as a,j as b,no as c,_ as d,J as g,Z as u};
package/ui.js CHANGED
@@ -1 +1 @@
1
- import{r as e}from"./vendor.react.js";import{r as t}from"./vendor.react-dom.js";import{u as n,i as s,U as i}from"./client-context.js";import{_ as r,R as o,U as c}from"./userflow.js";import{I as a}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";const l=e.lazy((()=>r((()=>import("./ElementSelectionApp.js")),[new URL("ElementSelectionApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.is-hotkey.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString()]))),u=e.lazy((()=>r((()=>import("./FlowApp.js")),[new URL("FlowApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("z-index.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),m=e.lazy((()=>r((()=>import("./ChecklistApp.js")),[new URL("ChecklistApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("z-index.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString()]))),d=e.lazy(o),p=e.lazy((()=>r((()=>import("./LauncherApp.js")),[new URL("LauncherApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("z-index.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),h=e.lazy((()=>r((()=>import("./NotificationsApp.js")),[new URL("NotificationsApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("z-index.js",import.meta.url).toString()]))),E=e.lazy((()=>r((()=>import("./TrackerTestingApp.js")),[new URL("TrackerTestingApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString()]))),S=()=>{const t=n(),[s,i]=e.useState(t.getSessionStorageState()),[r,o]=e.useState((()=>f()?null:t.flowSession)),[c,a]=e.useState(t.checklistSession),[S,_]=e.useState(t.checklistExpanded),[v,k]=e.useState(t.resourceCenterSession),[b,y]=e.useState(t.resourceCenterOpen),[j,g]=e.useState(t.resourceCenterLauncherHidden),[w,A]=e.useState(t.resourceCenterEmbedsChecklist()),[C,L]=e.useState(t.launcherSessions),[T,I]=e.useState(t.activeLauncherFlowId),[O,x]=e.useState(t.notifications);e.useEffect((()=>{const e=()=>{i(t.getSessionStorageState()),o((e=>f()&&t.flowSession?.id!==e?.id?null:t.flowSession)),a(t.checklistSession),_(t.checklistExpanded),k(t.resourceCenterSession),y(t.resourceCenterOpen),g(t.resourceCenterLauncherHidden),A(t.resourceCenterEmbedsChecklist()),L(t.launcherSessions),I(t.activeLauncherFlowId),x(t.notifications)};t.on("uistatechange",e);const n=()=>{f()||o(t.flowSession)};return document.addEventListener("visibilitychange",n),()=>{t.off("uistatechange",e),document.removeEventListener("visibilitychange",n)}}),[t]);const z=!s.activeApp&&!!r;return e.useLayoutEffect((()=>{if(z)return t.emit("flowvisibilitychange",!0),()=>{t.emit("flowvisibilitychange",!1)}}),[t,z]),"elementSelection"===s.activeApp&&s.elementSelection?e.createElement(e.Suspense,{fallback:null},e.createElement(l,{state:s.elementSelection})):"trackerTesting"===s.activeApp&&s.trackerTesting?e.createElement(e.Suspense,{fallback:null},e.createElement(E,{state:s.trackerTesting})):e.createElement(e.Fragment,null,r&&e.createElement(e.Suspense,{fallback:null},e.createElement(u,{key:r.id,session:r,checklistSession:c,resourceCenterEmbedsChecklist:w})),c&&!w&&(S||c.version.checklist?.launcherEnabled)&&e.createElement(e.Suspense,{fallback:null},e.createElement(m,{key:c.id,session:c,checklistExpanded:S})),v&&(b||!j)&&e.createElement(e.Suspense,{fallback:null},e.createElement(d,{key:v.id,session:v,isOpen:b,flowSession:r,checklistSession:c})),!r&&e.createElement(e.Suspense,{fallback:null},C.map((t=>e.createElement(p,{key:t.flow.id,session:t,active:t.flow.id===T})))),O.length>0&&e.createElement(e.Suspense,{fallback:null},e.createElement(h,{notifications:O})))};function f(){return"hidden"===document.visibilityState}const _=({client:t})=>e.createElement(a,{i18n:s},e.createElement(i.Provider,{value:t},e.createElement(S,null)));class v{constructor(e){this.client=e}mount(){if(this.container)throw new c("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-ui",document.body.appendChild(this.container),t.render(e.createElement(_,{client:this.client}),this.container)}unmount(){this.container&&(t.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),delete this.container)}}export{v as RealUI};
1
+ import{r as e}from"./vendor.react.js";import{r as t}from"./vendor.react-dom.js";import{u as n,i as s,U as i}from"./client-context.js";import{_ as r,B as o,R as a,U as c}from"./userflow.js";import{I as l}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";const u=e.lazy((()=>r((()=>import("./ElementSelectionApp.js")),[new URL("ElementSelectionApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.is-hotkey.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString()]))),m=e.lazy((()=>r((()=>import("./FlowApp.js")),[new URL("FlowApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("bubble-frame.styl.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("flow-host.styl.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("use-selector-element-monitoring.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),d=e.lazy((()=>r((()=>import("./ChecklistApp.js")),[new URL("ChecklistApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("flow-host.styl.js",import.meta.url).toString(),new URL("bubble-frame.styl.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("use-selector-element-monitoring.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString()]))),p=e.lazy(o),h=e.lazy(a),E=e.lazy((()=>r((()=>import("./LauncherApp.js")),[new URL("LauncherApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("use-selector-element-monitoring.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("bubble-frame.styl.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("flow-host.styl.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),S=e.lazy((()=>r((()=>import("./NotificationsApp.js")),[new URL("NotificationsApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("flow-host.styl.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]))),f=e.lazy((()=>r((()=>import("./TrackerTestingApp.js")),[new URL("TrackerTestingApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString()]))),_=()=>{const t=n(),[s,i]=e.useState(t.getSessionStorageState()),[r,o]=e.useState((()=>k()?null:t.flowSession)),[a,c]=e.useState(t.checklistSession),[l,_]=e.useState(t.checklistExpanded),[v,b]=e.useState(t.bannerSession),[y,j]=e.useState(t.resourceCenterSession),[g,w]=e.useState(t.resourceCenterOpen),[A,C]=e.useState(t.resourceCenterLauncherHidden),[L,T]=e.useState(t.resourceCenterEmbedsChecklist()),[I,O]=e.useState(t.launcherSessions),[x,z]=e.useState(t.activeLauncherFlowId),[P,R]=e.useState(t.notifications);e.useEffect((()=>{const e=()=>{i(t.getSessionStorageState()),o((e=>k()&&t.flowSession?.id!==e?.id?null:t.flowSession)),c(t.checklistSession),_(t.checklistExpanded),b(t.bannerSession),j(t.resourceCenterSession),w(t.resourceCenterOpen),C(t.resourceCenterLauncherHidden),T(t.resourceCenterEmbedsChecklist()),O(t.launcherSessions),z(t.activeLauncherFlowId),R(t.notifications)};t.on("uistatechange",e);const n=()=>{k()||o(t.flowSession)};return document.addEventListener("visibilitychange",n),()=>{t.off("uistatechange",e),document.removeEventListener("visibilitychange",n)}}),[t]);const D=!s.activeApp&&!!r;return e.useLayoutEffect((()=>{if(D)return t.emit("flowvisibilitychange",!0),()=>{t.emit("flowvisibilitychange",!1)}}),[t,D]),"elementSelection"===s.activeApp&&s.elementSelection?e.createElement(e.Suspense,{fallback:null},e.createElement(u,{state:s.elementSelection})):"trackerTesting"===s.activeApp&&s.trackerTesting?e.createElement(e.Suspense,{fallback:null},e.createElement(f,{state:s.trackerTesting})):e.createElement(e.Fragment,null,r&&e.createElement(e.Suspense,{fallback:null},e.createElement(m,{key:r.id,session:r,checklistSession:a,resourceCenterEmbedsChecklist:L})),a&&!L&&(l||a.version.checklist?.launcherEnabled)&&e.createElement(e.Suspense,{fallback:null},e.createElement(d,{key:a.id,session:a,checklistExpanded:l})),v&&e.createElement(e.Suspense,{fallback:null},e.createElement(p,{key:v.id,session:v})),y&&(g||!A)&&e.createElement(e.Suspense,{fallback:null},e.createElement(h,{key:y.id,session:y,isOpen:g,flowSession:r,checklistSession:a})),!r&&e.createElement(e.Suspense,{fallback:null},I.map((t=>e.createElement(E,{key:t.flow.id,session:t,active:t.flow.id===x})))),P.length>0&&e.createElement(e.Suspense,{fallback:null},e.createElement(S,{notifications:P})))};function k(){return"hidden"===document.visibilityState}const v=({client:t})=>e.createElement(l,{i18n:s},e.createElement(i.Provider,{value:t},e.createElement(_,null)));class b{constructor(e){this.client=e}mount(){if(this.container)throw new c("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-ui",document.body.appendChild(this.container),t.render(e.createElement(v,{client:this.client}),this.container)}unmount(){this.container&&(t.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),delete this.container)}}export{b as RealUI};
@@ -0,0 +1 @@
1
+ import{r as e}from"./vendor.react.js";import{o as t,e as n,h as r,j as o,r as s,k as c,l as i,a as u,g as a}from"./flow-condition-types.js";let l=!1;const m=[];let f,v=[];function h(e){v.push(e)}function d(){m.forEach((e=>e())),v.length>0&&(v.forEach((e=>e())),v=[]),E()}function E(){l&&(f=window.requestAnimationFrame(d))}function g(){}function p({selector:c,targetMoved:i,targetLost:u,onTargetClick:a,onTargetMouseEnter:v,onTargetMouseLeave:h}){const d=e.useRef(i),p=e.useRef(u),w=e.useRef(a),M=e.useRef(v),R=e.useRef(h);e.useLayoutEffect((()=>{d.current=i,p.current=u,w.current=a,M.current=v,R.current=h})),e.useLayoutEffect((()=>{let e=null,i=null,u=null,a=!1;const v=()=>{e=null,i=null,u=null,p.current()};if(!c)return void v();const h=()=>{if(!u||!e)return;const t=s(e);var n,r;i&&(r=t,(n=i).left===r.left&&n.top===r.top&&n.width===r.width&&n.height===r.height)||(i=t,0===t.width&&0===t.height?v():d.current({targetEl:e,targetRect:i,clipEl:u,viewportClipRect:L(u)}))};let k=!1;const x=()=>{var e;k||(k=!0,e=h,m.push(e),1===m.length&&(l=!0,E(),window.addEventListener("scroll",g)))},b=()=>{k&&(k=!1,function(e){const t=m.indexOf(e);t>=0&&(m.splice(t,1),0===m.length&&(l=!1,window.cancelAnimationFrame(f),window.removeEventListener("scroll",g)))}(h))},j=()=>{w.current&&w.current()},y=()=>{M.current&&M.current()},T=()=>{R.current&&R.current()},A=()=>{const t=e;e=n(c)?c:r(c),a&&e===t||(t&&(t.removeEventListener("click",j),t.removeEventListener("mouseenter",y),t.removeEventListener("mouseleave",T)),e?(x(),e.addEventListener("click",j),e.addEventListener("mouseenter",y),e.addEventListener("mouseleave",T),u=o(e)):(b(),v())),a=!0};A();const C=t(A);return()=>{C.disconnect(),b(),e&&(e.removeEventListener("click",j),e.removeEventListener("mouseenter",y),e.removeEventListener("mouseleave",T))}}),[c])}function L(e){c();const t=i(u()),n=i(a());if(e&&e!==document.documentElement){const r=s(e);return{top:Math.max(0,r.top),right:Math.min(n,r.right),bottom:Math.min(t,r.bottom),left:Math.max(0,r.left)}}return{top:0,right:n,bottom:t,left:0}}export{h as r,p as u};
@@ -0,0 +1 @@
1
+ import{r as e}from"./vendor.react.js";import{r as t}from"./vendor.react-dom.js";import{g as r,a as s,c as a,d as o}from"./stylesheets.js";import{a as n,i as d}from"./client-context.js";var i=new URL("iframe-reset.css",import.meta.url).href;const l=({testId:t,className:n,style:d,elRef:l,stylesheet:u,theme:f,onStylesheetsLoad:y,noIframe:p,ariaHidden:w,children:E})=>{p=p||!1;const[h,v]=e.useState(null),R=f&&"userflowjs-theme-root",L=f&&r(f),{loaded:N}=s(h,p?null:i),{loaded:I}=s(h,u,f),{loaded:S}=a(h,f),g=f&&o(f),{loaded:b}=s(h,g,f);return e.useEffect((()=>{y&&N&&I&&S&&b&&y(!0)}),[y,N,I,S,b]),p?e.createElement(m,{testId:t,className:n,style:d,rootClassName:R,rootStyle:L,elRef:l,onWinReady:v,ariaHidden:w},E):e.createElement(c,{testId:t,className:n,style:d,rootClassName:R,rootStyle:L,elRef:l,onWinReady:v,ariaHidden:w},E)},c=({testId:r,className:s,style:a,rootClassName:o,rootStyle:i,elRef:l,onWinReady:c,ariaHidden:m,children:u})=>{const f=n(),[y,p]=e.useState(null);e.useLayoutEffect((()=>{if(!y)return;const{documentElement:e,body:t}=y.document;e.dir=d.dir();const r=o&&o.split(" ");if(r&&t.classList.add(...r),i)for(const s in i)t.style.setProperty(s,i[s]);return()=>{r&&t.classList.remove(...r)}}),[y,o,i]);const w=f?.logrocketAppId,E=e.useRef(!1);e.useEffect((()=>{if(!y||!w||E.current)return;if(!window.LogRocket?.tabID)return;E.current=!0;const e=y.document.createElement("script");e.crossOrigin="anonymous",e.src="https://cdn.lr-in-prod.com/LogRocket.min.js",e.onload=()=>{y.LogRocket.init(w,{mergeIframes:!0})},y.document.head.appendChild(e)}),[y,w]);return e.createElement("iframe",{ref:e=>{if(!e)return;l&&(l.current=e);const t=e.contentWindow;if(!t||t===y)return;const r=e=>{p(e),c(e)};"complete"===t.document.readyState?r(t):t.addEventListener("load",(()=>{r(t)}))},"data-testid":r,role:"presentation","aria-hidden":m?"true":void 0,tabIndex:m?-1:void 0,className:s,style:a,frameBorder:0,bis_size:"{}"},y&&t.createPortal(u,y.document.body))},m=({testId:t,className:r,style:s,rootClassName:a,rootStyle:o,elRef:n,onWinReady:i,ariaHidden:l,children:c})=>(e.useEffect((()=>{i(window)}),[i]),e.createElement("div",{ref:n,"data-testid":t,"aria-hidden":l?"true":void 0,tabIndex:l?-1:void 0,dir:d.dir(),className:r,style:s},e.createElement("div",{className:a,style:o},c)));function u(t){e.useLayoutEffect((()=>{let e;const r=()=>{window.cancelAnimationFrame(e),e=window.requestAnimationFrame(t)};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r),window.cancelAnimationFrame(e)}}),[t])}export{l as F,u};