@flows/react
Advanced tools
Comparing version
"use client" | ||
"use strict";var le=Object.defineProperty,Uo=Object.defineProperties,Ko=Object.getOwnPropertyDescriptor,Vo=Object.getOwnPropertyDescriptors,Oo=Object.getOwnPropertyNames,ie=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var Ye=(e,t,o)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,m=(e,t)=>{for(var o in t||(t={}))he.call(t,o)&&Ye(e,o,t[o]);if(ie)for(var o of ie(t))je.call(t,o)&&Ye(e,o,t[o]);return e},w=(e,t)=>Uo(e,Vo(t));var Qe=(e,t)=>{var o={};for(var r in e)he.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&ie)for(var r of ie(e))t.indexOf(r)<0&&je.call(e,r)&&(o[r]=e[r]);return o};var g=(e,t)=>()=>(e&&(t=e(e=0)),t);var et=(e,t)=>{for(var o in t)le(e,o,{get:t[o],enumerable:!0})},zo=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Oo(t))!he.call(e,n)&&n!==o&&le(e,n,{get:()=>t[n],enumerable:!(r=Ko(t,n))||r.enumerable});return e};var Ho=e=>zo(le({},"__esModule",{value:!0}),e);var tt,ue,ot=g(()=>{"use strict";tt=(e,{body:t,method:o,version:r})=>fetch(e,{method:o,headers:{"Content-Type":"application/json","x-flows-version":r},body:t?JSON.stringify(t):void 0}).then(async n=>{var c;let u=await n.text(),i=u?JSON.parse(u):void 0;if(!n.ok){let p=i;throw new Error((c=p==null?void 0:p.message)!=null?c:n.statusText)}return i}),ue=(e,t)=>({getBlocks:o=>tt(`${e}/v2/sdk/blocks`,{method:"POST",body:o,version:t}),sendEvent:o=>tt(`${e}/v2/sdk/events`,{method:"POST",body:o,version:t})})});var xe,rt=g(()=>{"use strict";xe=(e,t)=>{let o=new Set([...t.exitedBlockIds,...t.updatedBlocks.map(r=>r.id)]);return[...e.filter(r=>!o.has(r.id)),...t.updatedBlocks]}});var ne,Pe,nt,st=g(()=>{"use strict";ne=require("es-toolkit/compat"),Pe=e=>{var p,a;let{block:t,exitNodeCb:o,removeBlock:r,setStateMemory:n}=e,u=({properties:s,parentKey:l})=>{var v;let f=m({},s);return Object.entries(s).forEach(([d,y])=>{Array.isArray(y)&&(f[d]=y.map((h,A)=>typeof h=="object"?u({properties:h,parentKey:[l,d,A].filter(F=>F!==void 0).join(".")}):h))}),delete f.f__exit_nodes,(v=s.f__exit_nodes)==null||v.forEach(d=>{let y=()=>o({key:[l,d].filter(h=>h!==void 0).join("."),blockId:t.id});f[d]=y}),f},i=u({properties:t.data});for(let s of(p=t.propertyMeta)!=null?p:[]){if(s.type==="state-memory"){let l={value:s.value,setValue:f=>{n({key:s.key,value:f,blockId:t.id})},triggers:(a=s.triggers)!=null?a:[]};(0,ne.set)(i,s.key,l)}if(s.type==="block-state"){let l=Pe(w(m({},e),{block:s.value}));(0,ne.set)(i,s.key,l)}if(s.type==="action"){let l=s.value,f={label:l.label,url:l.url,openInNew:l.openInNew},v=l.exitNode;v&&(f.callAction=()=>o({key:v,blockId:t.id})),(0,ne.set)(i,s.key,f)}}let c=t.exitNodes.reduce((s,l)=>{let f=()=>(r(t.id),o({key:l,blockId:t.id}));return s[l]=f,s},{});return m(m({__flows:{id:t.id,key:t.key,workflowId:t.workflowId}},i),c)},nt=({tourStep:e,currentIndex:t,handleCancel:o,handleContinue:r,handlePrevious:n})=>{var c;let u=t===0,i=m({},e.data);for(let p of(c=e.propertyMeta)!=null?c:[])if(p.type==="action"){let a=p.value,s={label:a.label,url:a.url,openInNew:a.openInNew};a.exitNode&&(s.callAction=async()=>{a.exitNode==="continue"&&r(),a.exitNode==="previous"&&n(),a.exitNode==="cancel"&&o()}),(0,ne.set)(i,p.key,s)}return w(m({__flows:{id:e.id,key:e.key,workflowId:e.workflowId}},i),{continue:r,previous:u?void 0:n,cancel:o})}});var Wo,at,it,Ce,Se,Be,lt,Te,ut,pt,ct,pe,dt,ft=g(()=>{"use strict";Wo=/^https?:\/\/localhost/,at=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,it=e=>(!!e).toString(),Ce="flows-debug-enabled",Se="flows-debug-position",Be=[{value:"top-left",label:"Top Left"},{value:"top-right",label:"Top Right"},{value:"bottom-left",label:"Bottom Left"},{value:"bottom-right",label:"Bottom Right"}],lt=()=>{let e=localStorage.getItem(Se);return Be.some(t=>t.value===e)?e:"bottom-right"},Te={organizationId:{true:"Organization ID is valid.",false:"Organization ID is not valid."},userId:{true:"User ID is set.",false:"User ID is not set."},environment:{true:"Environment is set.",false:"Environment is not set."},apiError:{true:"API responded successfully.",false:"API returned an error. Check the browser console for details."},title:{user:"User Information","sdk-setup":"SDK Setup",blocks:"Blocks",pathname:"Pathname",settings:"Settings"}},ut=e=>{if(typeof e!="undefined")return e;let t=sessionStorage.getItem(Ce);return t?t==="true":Wo.test(window.location.origin)},pt=e=>`https://app.flows.sh/org/${e}`,ct="https://flows.sh/docs/sdk-overview#debug-mode",pe=()=>{if(typeof window=="undefined")return!1;let e=navigator.userAgent.includes("Mac"),t=/(?:iphone|ipad|ipod)/i.test(navigator.userAgent);return e||t},dt=e=>(pe()?e.metaKey:e.ctrlKey)&&e.shiftKey&&e.altKey&&e.key.toLowerCase()==="f"});var gt,mt=g(()=>{"use strict";gt=e=>{var t;if(!(!e||e==="disabled"))return e==="automatic"?(t=navigator.languages.at(0))!=null?t:navigator.language:e}});var _o,$o,bt,vt,L,Ne=g(()=>{"use strict";_o="#22262d",$o="#fff",bt="%cFlows%c",vt=`color:${$o};background:${_o};padding:2px 4px;border-radius:4px`,L={error:(e,...t)=>{console.error(`${bt} ${e}`,vt,"",...t)},warn:(e,...t)=>{console.warn(`${bt} ${e}`,vt,"",...t)}}});var Ee,Me,Ie,Re,Ae,Le,De,Fe,Ge,kt=g(()=>{"use strict";Ee=(e,t)=>t?Array.isArray(t)?t.some(o=>Ee(e,o)):typeof e!="string"?!1:new RegExp(t).test(e):!0,Me=(e,t)=>t===void 0?!0:Array.isArray(t)?t.some(o=>Me(e,o)):e===t,Ie=(e,t)=>t===void 0?!0:Array.isArray(t)?t.every(o=>Ie(e,o)):e!==t,Re=(e,t)=>t?Array.isArray(t)?t.some(o=>Re(e,o)):typeof e!="string"?!1:e.includes(t):!0,Ae=(e,t)=>t?Array.isArray(t)?t.every(o=>Ae(e,o)):typeof e!="string"?!1:!e.includes(t):!0,Le=(e,t)=>t?Array.isArray(t)?t.some(o=>Le(e,o)):typeof e!="string"?!1:e.startsWith(t):!0,De=(e,t)=>t?Array.isArray(t)?t.some(o=>De(e,o)):typeof e!="string"?!1:e.endsWith(t):!0,Fe=(e,t)=>t?Array.isArray(t)?t.every(o=>Fe(e,o)):typeof e!="string"?!1:!e.startsWith(t):!0,Ge=(e,t)=>t?Array.isArray(t)?t.every(o=>Ge(e,o)):typeof e!="string"?!1:!e.endsWith(t):!0});var yt=g(()=>{"use strict";kt()});var O,ce,wt,ht,xt=g(()=>{"use strict";yt();O=({operator:e,pathname:t,value:o})=>e==="eq"?Me(t,o):e==="ne"?Ie(t,o):e==="contains"?Re(t,o):e==="notContains"?Ae(t,o):e==="startsWith"?Le(t,o):e==="endsWith"?De(t,o):e==="notStartsWith"?Fe(t,o):e==="notEndsWith"?Ge(t,o):e==="regex"?Ee(t,o):!0,ce=({eventTarget:e,value:t})=>t?Array.from(document.querySelectorAll(t)).some(o=>o.contains(e)):!1,wt=e=>typeof e!="string"?!1:e.trim()?!!document.querySelector(e):!0,ht=e=>typeof e!="string"?!1:e.trim()?!document.querySelector(e):!0});var Ue=g(()=>{"use strict";xt()});var z,Pt=g(()=>{"use strict";z=()=>window.location.pathname+window.location.search});var Ct,St=g(()=>{"use strict";Ne();Ue();Ct=(e,t)=>e?e.$and?e.$and.every(o=>{let r=o.type;if(r==="navigation"){if(!o.operator)return!0;let n=o.values;return n!=null&&n.every(u=>!u)?!0:O({operator:o.operator,pathname:t.pathname,value:n})}if(r==="dom-element"){let n=o.value;return typeof n!="string"?!1:n?!!document.querySelector(n):!0}if(r==="not-dom-element"){let n=o.value;return typeof n!="string"?!1:n?!document.querySelector(n):!0}if(r==="click"){let n=o.value;if(typeof n!="string")return!1;if(!n)return!0;if(!t.event||!(t.event instanceof MouseEvent))return!1;let u=t.event.target;return!u||!(u instanceof Element)?!1:ce({eventTarget:u,value:n})}return L.error(`Aborting tour start due to an unrecognized tour trigger type: ${r}. Try updating the SDK or changing the tour trigger configuration.`),!1}):(L.error("Aborting tour start due to an unsupported tour trigger format. Try updating the SDK or changing the tour trigger configuration."),!1):!0});var Ke,Bt=g(()=>{"use strict";Ke=(e,t)=>new Proxy(e,{get(o,r,n){return r==="props"&&t(e.id),Reflect.get(o,r,n)}})});var Tt=g(()=>{"use strict"});var Nt=g(()=>{"use strict"});var Et=g(()=>{"use strict"});var Mt=g(()=>{"use strict"});var It=g(()=>{"use strict"});var Rt=g(()=>{"use strict";Bt();Tt();Nt();Et();Mt();It()});var T=g(()=>{"use strict";ot();rt();st();ft();mt();Ne();Ue();Pt();St();Rt()});var de,At,Ve,I,X=g(()=>{"use strict";de=require("react"),At=()=>{},Ve=(0,de.createContext)({blocks:[],components:{},tourComponents:{},runningTours:[],removeBlock:At,updateBlock:At}),I=()=>(0,de.useContext)(Ve)});var U,Ft,Zo,qo,Lt,H,Dt,Q=g(()=>{"use strict";"use client";T();U=require("react"),Ft=require("react/jsx-runtime"),Zo=200,qo=()=>{let[e,t]=(0,U.useState)(),o=(0,U.useRef)(e);return(0,U.useEffect)(()=>{o.current=e},[e]),(0,U.useEffect)(()=>{let r=window.setInterval(()=>{let n=z();o.current!==n&&t(n)},Zo);return()=>{clearInterval(r)}}),e},Lt=(0,U.createContext)(void 0),H=()=>{if((0,U.useContext)(Lt)!==void 0)return z()},Dt=({children:e})=>{let t=qo();return(0,Ft.jsx)(Lt.Provider,{value:t,children:e})}});var Kt,Vt,Ut=g(()=>{Kt="@flows/react",Vt="1.17.0"});var _,se=g(()=>{"use strict";Ut();_=`${Kt}@${Vt}`});var io,ao=g(()=>{io=`:root { | ||
"use strict";var ue=Object.defineProperty,Uo=Object.defineProperties,Ko=Object.getOwnPropertyDescriptor,Vo=Object.getOwnPropertyDescriptors,Oo=Object.getOwnPropertyNames,le=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var Ye=(e,t,o)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,m=(e,t)=>{for(var o in t||(t={}))xe.call(t,o)&&Ye(e,o,t[o]);if(le)for(var o of le(t))je.call(t,o)&&Ye(e,o,t[o]);return e},w=(e,t)=>Uo(e,Vo(t));var Qe=(e,t)=>{var o={};for(var r in e)xe.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&le)for(var r of le(e))t.indexOf(r)<0&&je.call(e,r)&&(o[r]=e[r]);return o};var g=(e,t)=>()=>(e&&(t=e(e=0)),t);var et=(e,t)=>{for(var o in t)ue(e,o,{get:t[o],enumerable:!0})},zo=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Oo(t))!xe.call(e,n)&&n!==o&&ue(e,n,{get:()=>t[n],enumerable:!(r=Ko(t,n))||r.enumerable});return e};var Ho=e=>zo(ue({},"__esModule",{value:!0}),e);var tt,pe,ot=g(()=>{"use strict";tt=(e,{body:t,method:o,version:r})=>fetch(e,{method:o,headers:{"Content-Type":"application/json","x-flows-version":r},body:t?JSON.stringify(t):void 0}).then(async n=>{var c;let u=await n.text(),i=u?JSON.parse(u):void 0;if(!n.ok){let p=i;throw new Error((c=p==null?void 0:p.message)!=null?c:n.statusText)}return i}),pe=(e,t)=>({getBlocks:o=>tt(`${e}/v2/sdk/blocks`,{method:"POST",body:o,version:t}),sendEvent:o=>tt(`${e}/v2/sdk/events`,{method:"POST",body:o,version:t})})});var ce,rt=g(()=>{"use strict";ce=(e,t)=>{let o=new Set([...t.exitedBlockIds,...t.updatedBlocks.map(r=>r.id)]);return[...e.filter(r=>!o.has(r.id)),...t.updatedBlocks]}});var se,Ce,nt,st=g(()=>{"use strict";se=require("es-toolkit/compat"),Ce=e=>{var p,a;let{block:t,exitNodeCb:o,removeBlock:r,setStateMemory:n}=e,u=({properties:s,parentKey:l})=>{var b;let f=m({},s);return Object.entries(s).forEach(([d,y])=>{Array.isArray(y)&&(f[d]=y.map((h,A)=>typeof h=="object"?u({properties:h,parentKey:[l,d,A].filter(F=>F!==void 0).join(".")}):h))}),delete f.f__exit_nodes,(b=s.f__exit_nodes)==null||b.forEach(d=>{let y=()=>o({key:[l,d].filter(h=>h!==void 0).join("."),blockId:t.id});f[d]=y}),f},i=u({properties:t.data});for(let s of(p=t.propertyMeta)!=null?p:[]){if(s.type==="state-memory"){let l={value:s.value,setValue:f=>{n({key:s.key,value:f,blockId:t.id})},triggers:(a=s.triggers)!=null?a:[]};(0,se.set)(i,s.key,l)}if(s.type==="block-state"){let l=Ce(w(m({},e),{block:s.value}));(0,se.set)(i,s.key,l)}if(s.type==="action"){let l=s.value,f={label:l.label,url:l.url,openInNew:l.openInNew},b=l.exitNode;b&&(f.callAction=()=>o({key:b,blockId:t.id})),(0,se.set)(i,s.key,f)}}let c=t.exitNodes.reduce((s,l)=>{let f=()=>(r(t.id),o({key:l,blockId:t.id}));return s[l]=f,s},{});return m(m({__flows:{id:t.id,key:t.key,workflowId:t.workflowId}},i),c)},nt=({tourStep:e,currentIndex:t,handleCancel:o,handleContinue:r,handlePrevious:n})=>{var c;let u=t===0,i=m({},e.data);for(let p of(c=e.propertyMeta)!=null?c:[])if(p.type==="action"){let a=p.value,s={label:a.label,url:a.url,openInNew:a.openInNew};a.exitNode&&(s.callAction=async()=>{a.exitNode==="continue"&&r(),a.exitNode==="previous"&&n(),a.exitNode==="cancel"&&o()}),(0,se.set)(i,p.key,s)}return w(m({__flows:{id:e.id,key:e.key,workflowId:e.workflowId}},i),{continue:r,previous:u?void 0:n,cancel:o})}});var _o,at,it,Pe,Se,Be,lt,Te,ut,pt,ct,de,dt,ft=g(()=>{"use strict";_o=/^https?:\/\/localhost/,at=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,it=e=>(!!e).toString(),Pe="flows-debug-enabled",Se="flows-debug-position",Be=[{value:"top-left",label:"Top Left"},{value:"top-right",label:"Top Right"},{value:"bottom-left",label:"Bottom Left"},{value:"bottom-right",label:"Bottom Right"}],lt=()=>{let e=localStorage.getItem(Se);return Be.some(t=>t.value===e)?e:"bottom-right"},Te={organizationId:{true:"Organization ID is valid.",false:"Organization ID is not valid."},userId:{true:"User ID is set.",false:"User ID is not set."},environment:{true:"Environment is set.",false:"Environment is not set."},apiError:{true:"API responded successfully.",false:"API returned an error. Check the browser console for details."},title:{user:"User Information","sdk-setup":"SDK Setup",blocks:"Blocks",pathname:"Pathname",settings:"Settings"}},ut=e=>{if(typeof e!="undefined")return e;let t=sessionStorage.getItem(Pe);return t?t==="true":_o.test(window.location.origin)},pt=e=>`https://app.flows.sh/org/${e}`,ct="https://flows.sh/docs/sdk-overview#debug-mode",de=()=>{if(typeof window=="undefined")return!1;let e=navigator.userAgent.includes("Mac"),t=/(?:iphone|ipad|ipod)/i.test(navigator.userAgent);return e||t},dt=e=>(de()?e.metaKey:e.ctrlKey)&&e.shiftKey&&e.altKey&&e.key.toLowerCase()==="f"});var gt,mt=g(()=>{"use strict";gt=e=>{var t;if(!(!e||e==="disabled"))return e==="automatic"?(t=navigator.languages.at(0))!=null?t:navigator.language:e}});var Wo,$o,bt,vt,L,Ne=g(()=>{"use strict";Wo="#22262d",$o="#fff",bt="%cFlows%c",vt=`color:${$o};background:${Wo};padding:2px 4px;border-radius:4px`,L={error:(e,...t)=>{console.error(`${bt} ${e}`,vt,"",...t)},warn:(e,...t)=>{console.warn(`${bt} ${e}`,vt,"",...t)}}});var Ee,Me,Ie,Re,Ae,Le,De,Fe,Ge,kt=g(()=>{"use strict";Ee=(e,t)=>t?Array.isArray(t)?t.some(o=>Ee(e,o)):typeof e!="string"?!1:new RegExp(t).test(e):!0,Me=(e,t)=>t===void 0?!0:Array.isArray(t)?t.some(o=>Me(e,o)):e===t,Ie=(e,t)=>t===void 0?!0:Array.isArray(t)?t.every(o=>Ie(e,o)):e!==t,Re=(e,t)=>t?Array.isArray(t)?t.some(o=>Re(e,o)):typeof e!="string"?!1:e.includes(t):!0,Ae=(e,t)=>t?Array.isArray(t)?t.every(o=>Ae(e,o)):typeof e!="string"?!1:!e.includes(t):!0,Le=(e,t)=>t?Array.isArray(t)?t.some(o=>Le(e,o)):typeof e!="string"?!1:e.startsWith(t):!0,De=(e,t)=>t?Array.isArray(t)?t.some(o=>De(e,o)):typeof e!="string"?!1:e.endsWith(t):!0,Fe=(e,t)=>t?Array.isArray(t)?t.every(o=>Fe(e,o)):typeof e!="string"?!1:!e.startsWith(t):!0,Ge=(e,t)=>t?Array.isArray(t)?t.every(o=>Ge(e,o)):typeof e!="string"?!1:!e.endsWith(t):!0});var yt=g(()=>{"use strict";kt()});var O,fe,wt,ht,xt=g(()=>{"use strict";yt();O=({operator:e,pathname:t,value:o})=>e==="eq"?Me(t,o):e==="ne"?Ie(t,o):e==="contains"?Re(t,o):e==="notContains"?Ae(t,o):e==="startsWith"?Le(t,o):e==="endsWith"?De(t,o):e==="notStartsWith"?Fe(t,o):e==="notEndsWith"?Ge(t,o):e==="regex"?Ee(t,o):!0,fe=({eventTarget:e,value:t})=>t?Array.from(document.querySelectorAll(t)).some(o=>o.contains(e)):!1,wt=e=>typeof e!="string"?!1:e.trim()?!!document.querySelector(e):!0,ht=e=>typeof e!="string"?!1:e.trim()?!document.querySelector(e):!0});var Ue=g(()=>{"use strict";xt()});var z,Ct=g(()=>{"use strict";z=()=>window.location.pathname+window.location.search});var Pt,St=g(()=>{"use strict";Ne();Ue();Pt=(e,t)=>e?e.$and?e.$and.every(o=>{let r=o.type;if(r==="navigation"){if(!o.operator)return!0;let n=o.values;return n!=null&&n.every(u=>!u)?!0:O({operator:o.operator,pathname:t.pathname,value:n})}if(r==="dom-element"){let n=o.value;return typeof n!="string"?!1:n?!!document.querySelector(n):!0}if(r==="not-dom-element"){let n=o.value;return typeof n!="string"?!1:n?!document.querySelector(n):!0}if(r==="click"){let n=o.value;if(typeof n!="string")return!1;if(!n)return!0;if(!t.event||!(t.event instanceof MouseEvent))return!1;let u=t.event.target;return!u||!(u instanceof Element)?!1:fe({eventTarget:u,value:n})}return L.error(`Aborting tour start due to an unrecognized tour trigger type: ${r}. Try updating the SDK or changing the tour trigger configuration.`),!1}):(L.error("Aborting tour start due to an unsupported tour trigger format. Try updating the SDK or changing the tour trigger configuration."),!1):!0});var Ke,Bt=g(()=>{"use strict";Ke=(e,t)=>new Proxy(e,{get(o,r,n){return r==="props"&&t(e.id),Reflect.get(o,r,n)}})});var Tt=g(()=>{"use strict"});var Nt=g(()=>{"use strict"});var Et=g(()=>{"use strict"});var Mt=g(()=>{"use strict"});var It=g(()=>{"use strict"});var Rt=g(()=>{"use strict";Bt();Tt();Nt();Et();Mt();It()});var T=g(()=>{"use strict";ot();rt();st();ft();mt();Ne();Ue();Ct();St();Rt()});var ge,At,Ve,I,Y=g(()=>{"use strict";ge=require("react"),At=()=>{},Ve=(0,ge.createContext)({blocks:[],components:{},tourComponents:{},runningTours:[],removeBlock:At,updateBlock:At}),I=()=>(0,ge.useContext)(Ve)});var U,Ft,Zo,qo,Lt,H,Dt,ee=g(()=>{"use strict";"use client";T();U=require("react"),Ft=require("react/jsx-runtime"),Zo=200,qo=()=>{let[e,t]=(0,U.useState)(),o=(0,U.useRef)(e);return(0,U.useEffect)(()=>{o.current=e},[e]),(0,U.useEffect)(()=>{let r=window.setInterval(()=>{let n=z();o.current!==n&&t(n)},Zo);return()=>{clearInterval(r)}}),e},Lt=(0,U.createContext)(void 0),H=()=>{if((0,U.useContext)(Lt)!==void 0)return z()},Dt=({children:e})=>{let t=qo();return(0,Ft.jsx)(Lt.Provider,{value:t,children:e})}});var Kt,Vt,Ut=g(()=>{Kt="@flows/react",Vt="1.17.1"});var W,ae=g(()=>{"use strict";Ut();W=`${Kt}@${Vt}`});var io,ao=g(()=>{io=`:root { | ||
--flows-debug-bg-default: #ffffff; | ||
@@ -339,2 +339,2 @@ --flows-debug-bg-subtle: #f9fafc; | ||
} | ||
`});var $e,lo,uo=g(()=>{"use strict";$e=require("react/jsx-runtime"),lo=e=>(0,$e.jsx)("svg",w(m({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 40 40"},e),{children:(0,$e.jsx)("path",{d:"M38.02 12.24C36.7 10 34.87 8.22 32.56 6.94C30.38 5.74 27.83 5.08 25 5H16C12.97 5 9.76 5.66 7.45 6.94C5.14 8.22 3.3 10 1.99 12.23C0.67 14.46 0 17.08 0 20.02C0 22.96 0.67 25.53 1.99 27.76C3.3 29.99 5.15 31.78 7.47 33.05C9.8 34.33 12.94 35 16 35H25C27.81 34.94 30.4 34.26 32.6 33.05C34.91 31.77 36.74 29.99 38.04 27.76C39.34 25.52 40 22.92 40 20.01C40 17.1 39.33 14.48 38.02 12.24ZM30.3 19.89L27.37 22.82C26.63 23.56 25.62 24 24.58 24H19.95C18.9 24 17.9 24.39 17.16 25.13L16.12 26C13.19 28.46 8.72 26.37 8.72 22.55C8.72 21.65 9.08 20.79 9.71 20.16L12.64 17.23C13.38 16.49 14.4 16 15.45 16H20.08C21.13 16 22.12 15.66 22.86 14.92L23.79 14.09C26.65 11.53 31.2 13.5 31.29 17.34V17.5C31.29 18.4 30.94 19.26 30.3 19.89Z"})}))});var K,po,co=g(()=>{"use strict";K=require("react/jsx-runtime"),po=({userProperties:e,userId:t})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)("p",{className:"flows-debug-info-line",children:[(0,K.jsx)("strong",{children:"User ID:"})," ",(0,K.jsx)("code",{className:"flows-debug-inline-code",children:t})]}),(0,K.jsx)("p",{className:"flows-debug-info-line",children:(0,K.jsx)("strong",{children:"User properties:"})}),(0,K.jsx)("pre",{className:"flows-debug-code-block",children:JSON.stringify(e!=null?e:{},null,2)})]})});var N,fo,go=g(()=>{"use strict";N=require("react/jsx-runtime"),fo=({organizationId:e,environment:t,statusItems:o})=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)("p",{className:"flows-debug-info-line",children:[(0,N.jsx)("strong",{children:"Organization ID:"})," ",(0,N.jsx)("code",{className:"flows-debug-inline-code",children:e||(0,N.jsx)("span",{className:"flows-debug-validation-invalid",children:"Not set"})})]}),(0,N.jsxs)("p",{className:"flows-debug-info-line",children:[(0,N.jsx)("strong",{children:"Environment:"})," ",(0,N.jsx)("code",{className:"flows-debug-inline-code",children:t||(0,N.jsx)("span",{className:"flows-debug-validation-invalid",children:"Not set"})})]}),(0,N.jsx)("p",{className:"flows-debug-info-line",children:(0,N.jsx)("strong",{children:"Validation:"})}),o]})});var V,mo,bo=g(()=>{"use strict";V=require("react/jsx-runtime"),mo=({blocks:e})=>(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)("p",{className:"flows-debug-info-line",children:[(0,V.jsx)("strong",{children:"Loaded blocks:"})," ",e.length]}),(0,V.jsx)("p",{className:"flows-debug-info-line",children:(0,V.jsx)("strong",{children:"Blocks JSON:"})}),(0,V.jsx)("pre",{className:"flows-debug-code-block",children:JSON.stringify(e,null,2)}),(0,V.jsx)("button",{className:"flows-debug-btn flows-debug-button-secondary flows-debug-print-button",onClick:()=>{console.log(e)},type:"button",children:"Print to console"})]})});var ae,oe,vo=g(()=>{"use strict";ae=require("react/jsx-runtime"),oe=({label:e,secondary:t,onClick:o})=>(0,ae.jsxs)("button",{className:"flows-debug-btn flows-debug-item flows-debug-item-interactive",onClick:o,type:"button",children:[(0,ae.jsx)("span",{className:"flows-debug-item-label",children:e}),t?(0,ae.jsx)("span",{className:"flows-debug-item-secondary",children:t}):null]})});var E,ko,yo=g(()=>{"use strict";T();vo();se();E=require("react/jsx-runtime"),ko=({userId:e,setPanelPage:t,sdkSetupValid:o,blocks:r,pathname:n,organizationId:u})=>(0,E.jsxs)("div",{className:"flows-debug-popover-narrow",children:[(0,E.jsxs)("div",{className:"flows-debug-item-list",children:[(0,E.jsx)(oe,{label:"User",secondary:e?(0,E.jsx)("code",{className:"flows-debug-inline-code",children:e}):"Not set",onClick:()=>{t("user")}}),(0,E.jsx)(oe,{label:"SDK setup",secondary:o?"Valid":(0,E.jsx)("span",{className:"flows-debug-validation-invalid",children:"Error"}),onClick:()=>{t("sdk-setup")}}),(0,E.jsx)(oe,{label:"Blocks",secondary:`${r.length} loaded`,onClick:()=>{t("blocks")}}),(0,E.jsx)(oe,{label:"Pathname",secondary:n,onClick:()=>{t("pathname")}})]}),(0,E.jsx)("hr",{}),(0,E.jsxs)("div",{className:"flows-debug-item-list",children:[(0,E.jsx)(oe,{label:"Settings",secondary:_,onClick:()=>{t("settings")}}),(0,E.jsx)("a",{href:pt(u),target:"_blank",rel:"noopener noreferrer",className:"flows-debug-item flows-debug-item-interactive flows-debug-item-label",children:"Open Flows dashboard"})]})]})});function wo(e){return(0,Ze.jsx)("svg",w(m({fill:"currentColor",height:16,width:16,xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,Ze.jsx)("path",{d:"M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"})}))}var Ze,ho=g(()=>{"use strict";Ze=require("react/jsx-runtime")});var b,xo,Po=g(()=>{"use strict";T();ho();se();b=require("react/jsx-runtime"),xo=({position:e,onPositionChange:t})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"flows-debug-item",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"flows-debug-item-label",htmlFor:"debug-panel-position",children:"Position"}),(0,b.jsx)("p",{className:"flows-debug-item-info",children:"Sets the position of the debug panel on the screen."})]}),(0,b.jsxs)("div",{className:"flows-debug-select-wrap",children:[(0,b.jsx)("select",{className:"flows-debug-select",value:e,id:"debug-panel-position",onChange:r=>{let n=r.target.value;t(n)},children:Be.map(r=>(0,b.jsx)("option",{value:r.value,children:r.label},r.value))}),(0,b.jsx)(wo,{})]})]}),(0,b.jsxs)("div",{className:"flows-debug-item",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"flows-debug-item-label",children:"Debug panel shortcut"}),(0,b.jsx)("p",{className:"flows-debug-item-info",children:"Used to toggle the panel visibility even when debug mode is not active."})]}),(0,b.jsxs)("div",{className:"flows-debug-shortcut-list",children:[(0,b.jsx)("p",{className:"flows-debug-shortcut",children:pe()?"Cmd":"Ctrl"}),(0,b.jsx)("p",{className:"flows-debug-shortcut",children:pe()?"Option":"Alt"}),(0,b.jsx)("p",{className:"flows-debug-shortcut",children:"Shift"}),(0,b.jsx)("p",{className:"flows-debug-shortcut",children:"F"})]})]}),(0,b.jsxs)("div",{className:"flows-debug-item",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"flows-debug-item-label",children:"Docs"}),(0,b.jsx)("p",{className:"flows-debug-item-info",children:"Learn more about the debug panel and its features."})]}),(0,b.jsx)("a",{className:"flows-debug-button-secondary",href:ct,target:"_blank",rel:"noopener noreferrer",children:"Open docs"})]}),(0,b.jsxs)("div",{className:"flows-debug-item",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"flows-debug-item-label",children:"SDK version"}),(0,b.jsx)("p",{className:"flows-debug-item-info",children:"Make sure to keep your SDK up to date for the best experience."})]}),(0,b.jsx)("p",{children:_})]})]})});var qe,Co,So=g(()=>{"use strict";qe=require("react/jsx-runtime"),Co=e=>(0,qe.jsx)("svg",w(m({fill:"currentColor",height:16,viewBox:"0 0 16 16",width:16,xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,qe.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.03 5.22032C12.1705 5.36094 12.2494 5.55157 12.2494 5.75032C12.2494 5.94907 12.1705 6.13969 12.03 6.28032L7.53003 10.7803C7.38941 10.9208 7.19878 10.9997 7.00003 10.9997C6.80128 10.9997 6.61066 10.9208 6.47003 10.7803L4.22003 8.53032C4.14634 8.46165 4.08724 8.37885 4.04625 8.28685C4.00526 8.19486 3.98322 8.09554 3.98144 7.99484C3.97966 7.89414 3.99819 7.79411 4.03591 7.70072C4.07363 7.60733 4.12977 7.5225 4.20099 7.45128C4.27221 7.38006 4.35705 7.32391 4.45043 7.28619C4.54382 7.24847 4.64385 7.22995 4.74455 7.23172C4.84526 7.2335 4.94457 7.25554 5.03657 7.29654C5.12857 7.33753 5.21137 7.39663 5.28003 7.47032L7.00003 9.19032L10.97 5.22032C11.1107 5.07987 11.3013 5.00098 11.5 5.00098C11.6988 5.00098 11.8894 5.07987 12.03 5.22032Z"})}))});function Bo(e){return(0,Je.jsx)("svg",w(m({height:16,viewBox:"0 0 16 16",width:16,xmlns:"http://www.w3.org/2000/svg",fill:"currentColor"},e),{children:(0,Je.jsx)("path",{d:"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"})}))}var Je,To=g(()=>{"use strict";Je=require("react/jsx-runtime")});function No(e){return(0,Xe.jsx)("svg",w(m({height:16,viewBox:"0 0 16 16",width:16,xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,Xe.jsx)("path",{d:"M7.78 12.53a.75.75 0 0 1-1.06 0L2.47 8.28a.75.75 0 0 1 0-1.06l4.25-4.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L4.81 7h7.44a.75.75 0 0 1 0 1.5H4.81l2.97 2.97a.75.75 0 0 1 0 1.06Z",fill:"currentColor"})}))}var Xe,Eo=g(()=>{"use strict";Xe=require("react/jsx-runtime")});var Z,Mo,Io=g(()=>{"use strict";Eo();Z=require("react/jsx-runtime"),Mo=({label:e,children:t,onClose:o})=>(0,Z.jsxs)("div",{className:"flows-debug-popover-wide",children:[(0,Z.jsxs)("div",{className:"flows-debug-section-header",children:[(0,Z.jsx)("button",{className:"flows-debug-btn flows-debug-section-close",onClick:o,type:"button",children:(0,Z.jsx)(No,{})}),(0,Z.jsx)("p",{className:"flows-debug-section-label",children:e})]}),(0,Z.jsx)("div",{className:"flows-debug-section-content",children:t})]})});var W,Ro,Ao=g(()=>{"use strict";W=require("react/jsx-runtime"),Ro=({pathname:e})=>(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("p",{className:"flows-debug-info-line",children:(0,W.jsx)("strong",{children:"Pathname:"})}),(0,W.jsx)("p",{className:"flows-debug-code-block flows-debug-info-line",children:e}),(0,W.jsx)("p",{className:"flows-debug-info-line",children:"This pathname is used when evaluating page targeting conditions."})]})});var Lo={};et(Lo,{default:()=>Qo});var re,ke,x,Yo,jo,Qo,Do=g(()=>{"use strict";re=require("react");T();ao();ke=require("clsx");X();Q();uo();co();go();bo();yo();Po();So();To();Io();Ao();x=require("react/jsx-runtime"),Yo=({blocksError:e,wsError:t,environment:o,organizationId:r,userId:n,userProperties:u})=>{let[i,c]=(0,re.useState)(!1),p=()=>{c(B=>!B)},[a,s]=(0,re.useState)(),l=()=>{s(void 0)},[f,v]=(0,re.useState)(lt()),d=(0,re.useCallback)(B=>{v(B),localStorage.setItem(Se,B)},[]),y=H(),{blocks:h}=I(),A=[{key:"organizationId",valid:r&&at.test(r)},{key:"userId",valid:!!n},{key:"environment",valid:!!o},{key:"apiError",valid:!e&&!t}],F=A.every(B=>B.valid),G=a==="user"?(0,x.jsx)(po,{userProperties:u,userId:n}):a==="sdk-setup"?(0,x.jsx)(fo,{organizationId:r,environment:o,statusItems:A.map(B=>{let j=B.valid?(0,x.jsx)(Co,{className:"flows-debug-validation-valid"}):(0,x.jsx)(Bo,{className:"flows-debug-validation-invalid"}),k=Te[B.key][it(B.valid)];return(0,x.jsxs)("div",{className:"flows-debug-validation-item",children:[j," ",(0,x.jsx)("p",{children:k})]},B.key)})}):a==="blocks"?(0,x.jsx)(mo,{blocks:h}):a==="pathname"?(0,x.jsx)(Ro,{pathname:y}):a==="settings"?(0,x.jsx)(xo,{position:f,onPositionChange:d}):(0,x.jsx)(ko,{pathname:y,userId:n,setPanelPage:s,sdkSetupValid:F,blocks:h,organizationId:r});return(0,x.jsxs)("div",{className:(0,ke.clsx)("flows-debug",`flows-debug-${f}`),children:[(0,x.jsx)("button",{className:(0,ke.clsx)("flows-debug-btn","flows-debug-menu",!F&&"flows-debug-menu-error"),type:"button",onClick:p,children:(0,x.jsx)("div",{className:(0,ke.clsx)("flows-debug-menu-inset",!F&&"flows-debug-menu-inset-error"),children:(0,x.jsx)(lo,{})})}),i?(0,x.jsx)("div",{className:"flows-debug-popover",children:(0,x.jsx)(jo,{page:a,onClose:l,children:G})}):null,(0,x.jsx)("style",{children:io})]})},jo=({children:e,page:t,onClose:o})=>t?(0,x.jsx)(Mo,{label:Te.title[t],onClose:o,children:e}):e,Qo=Yo});var ir={};et(ir,{FlowsProvider:()=>Go,FlowsSlot:()=>Jo,resetAllWorkflowsProgress:()=>nr,resetWorkflowProgress:()=>sr,startWorkflow:()=>ar,useCurrentFloatingBlocks:()=>fe,useCurrentSlotBlocks:()=>ge});module.exports=Ho(ir);T();var ee=require("react");X();Q();T();T();var Y={};se();var D=async e=>{let{apiUrl:t,environment:o,organizationId:r,userId:n}=Y;!t||!o||!r||!n||await ue(t,_).sendEvent(w(m({},e),{environment:o,organizationId:r,userId:n}))},Ot=new Set,Oe=async e=>{Ot.has(e)||(Ot.add(e),await D({name:"block-activated",blockId:e}))};var ze=({block:e,removeBlock:t,updateBlock:o})=>{if(!e.componentType)return[];let n=Pe({block:e,removeBlock:t,exitNodeCb:({key:i,blockId:c})=>D({name:"transition",blockId:c,propertyKey:i}),setStateMemory:async({blockId:i,key:c,value:p})=>{o(i,a=>{var s;return w(m({},a),{propertyMeta:(s=a.propertyMeta)==null?void 0:s.map(l=>l.type==="state-memory"&&l.key===c?w(m({},l),{value:p}):l)})}),await D({name:"set-state-memory",blockId:i,propertyKey:c,properties:{value:p}})}}),u={id:e.id,type:"component",component:e.componentType,props:n};return Ke(u,Oe)},He=e=>{let t=e.activeStep;if(!(t!=null&&t.componentType))return[];let o=nt({tourStep:t,currentIndex:e.currentBlockIndex,handleCancel:e.cancel,handleContinue:e.continue,handlePrevious:e.previous}),r={id:t.id,tourBlockId:e.block.id,type:"tour-component",component:t.componentType,props:o};return Ke(r,Oe)};var We=e=>e==null?void 0:e.slotId;var Ht=()=>{let{blocks:e}=I(),t=H();return(0,ee.useMemo)(()=>e.filter(o=>O({pathname:t,operator:o.page_targeting_operator,value:o.page_targeting_values})),[e,t])},Wt=()=>{let{runningTours:e}=I(),t=H();return(0,ee.useMemo)(()=>e.filter(o=>{let r=o.activeStep;return r&&O({pathname:t,operator:r.page_targeting_operator,value:r.page_targeting_values})}),[t,e])},fe=()=>{let e=Ht(),t=Wt(),{removeBlock:o,updateBlock:r}=I(),n=(0,ee.useMemo)(()=>e.filter(i=>!i.slottable).flatMap(i=>ze({block:i,removeBlock:o,updateBlock:r})),[o,r,e]),u=(0,ee.useMemo)(()=>t.filter(i=>{let c=i.activeStep;return c&&!c.slottable}).flatMap(He),[t]);return[...n,...u]},_t=e=>"type"in e,zt=e=>{var t,o,r;return _t(e)?(t=e.slotIndex)!=null?t:0:(r=(o=e.activeStep)==null?void 0:o.slotIndex)!=null?r:0},ge=e=>{let t=Ht(),o=Wt(),{removeBlock:r,updateBlock:n}=I();return(0,ee.useMemo)(()=>{let i=t.filter(p=>p.slottable&&We(p)===e),c=o.filter(p=>{var a;return((a=p.activeStep)==null?void 0:a.slottable)&&We(p.activeStep)===e});return[...i,...c].sort((p,a)=>zt(p)-zt(a)).flatMap(p=>_t(p)?ze({block:p,removeBlock:r,updateBlock:n}):He(p))},[r,e,n,t,o])};var $t=require("react");T();X();var Zt=require("react/jsx-runtime"),me=({block:e})=>{let{components:t}=I(),o=t[e.component];return(0,$t.useEffect)(()=>{o||L.error(`Component not found for workflow block "${e.component}"`)},[o,e.component]),o?(0,Zt.jsx)(o,m({},e.props)):null};var qt=require("react");T();X();var Jt=require("react/jsx-runtime"),be=({block:e})=>{let{tourComponents:t}=I(),o=t[e.component];return(0,qt.useEffect)(()=>{o||L.error(`Tour Component not found for tour block "${e.component}"`)},[o,e.component]),o?(0,Jt.jsx)(o,m({},e.props)):null};var _e=require("react/jsx-runtime"),Jo=({id:e,placeholder:t})=>{let o=ge(e);return o.length?o.map(r=>r.type==="component"?(0,_e.jsx)(me,{block:r},r.id):r.type==="tour-component"?(0,_e.jsx)(be,{block:r},r.id):null):t!=null?t:null};X();var R=require("react");T();var Xt=require("es-toolkit");Q();var Yt=({blocks:e,removeBlock:t})=>{let[o,r]=(0,R.useState)([]),n=(0,R.useRef)(o);n.current=o;let u=H();(0,R.useEffect)(()=>{r(p=>{let a=new Set(e.filter(s=>s.type==="tour").map(s=>s.id));return p.filter(s=>a.has(s.blockId))})},[e]);let i=(0,R.useCallback)(p=>{let a=e.filter(l=>l.type==="tour"),s=new Set(n.current.map(l=>l.blockId));a.forEach(l=>{s.has(l.id)||!Ct(l.tour_trigger,p)||r(v=>{var y;let d={blockId:l.id,currentBlockIndex:(y=l.currentTourIndex)!=null?y:0};return[...v,d]})})},[e]);return(0,R.useEffect)(()=>{u&&i({pathname:u})},[u,i]),(0,R.useEffect)(()=>{let p=(0,Xt.debounce)(()=>{i({pathname:z()})},32),a=new MutationObserver(p);return a.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),p(),()=>{a.disconnect()}},[i]),(0,R.useEffect)(()=>{let p=a=>{i({pathname:z(),event:a})};return document.addEventListener("click",p),()=>{document.removeEventListener("click",p)}},[i]),(0,R.useMemo)(()=>{let p=(s,l)=>{r(f=>f.map(v=>v.blockId===s?l(v):v))},a=(s,l)=>{p(s,f=>w(m({},f),{currentBlockIndex:l}))};return o.map(({blockId:s,currentBlockIndex:l})=>{var G,B,j;let f=e.find(k=>k.id===s);if(!f)return;let v=(G=f.tourBlocks)==null?void 0:G[l],d=l===((j=(B=f.tourBlocks)==null?void 0:B.length)!=null?j:0)-1,y=k=>{D({name:"tour-update",blockId:s,properties:{currentTourIndex:k}})};return{block:f,currentBlockIndex:l,activeStep:v,continue:()=>{if(d)t(s),D({name:"transition",propertyKey:"complete",blockId:s});else{let k=l+1;a(s,k),y(k)}},previous:()=>{var C;let k=l===0?l:l-1;for(;k>0&&f.tourBlocks&&!((C=f.tourBlocks.at(k))!=null&&C.componentType);)k-=1;a(s,k),y(k)},cancel:()=>{t(s),D({name:"transition",blockId:s,propertyKey:"cancel"})}}}).filter(s=>!!s)},[e,t,o])};var P=require("react");T();se();var S=require("react"),jt=({url:e,onMessage:t,onOpen:o})=>{let[r,n]=(0,S.useState)(),[u,i]=(0,S.useState)(!1),c=(0,S.useRef)(void 0),[p,a]=(0,S.useState)(0),s=(0,S.useRef)(o);(0,S.useEffect)(()=>{s.current=o},[o]);let l=(0,S.useRef)(t);(0,S.useEffect)(()=>{l.current=t},[t]);let f=(0,S.useCallback)(d=>{l.current(d)},[]),v=(0,S.useCallback)(()=>{if(c.current&&(c.current(),c.current=void 0),!e)return;let d=new WebSocket(e);i(!1),n(d);let y=()=>{var G;(G=s.current)==null||G.call(s),a(0)},h=()=>{n(void 0),a(G=>G+1)},A=()=>{i(!0)};d.addEventListener("open",y),d.addEventListener("close",h),d.addEventListener("error",A),d.addEventListener("message",f);let F=()=>{d.removeEventListener("open",y),d.removeEventListener("close",h),d.removeEventListener("error",A),d.removeEventListener("message",f),d.readyState===WebSocket.CONNECTING?d.addEventListener("open",()=>{d.close()}):d.close(),n(void 0)};return c.current=F,F},[f,e]);return(0,S.useEffect)(()=>{let d=v();return()=>{d==null||d()}},[v]),(0,S.useEffect)(()=>{if(r)return;let d=setTimeout(()=>{v()},Math.min(1e3*4**p,12e4));return()=>{clearTimeout(d)}},[p,r,v]),(0,S.useEffect)(()=>()=>{c.current&&c.current()},[]),{error:u}};var eo=({apiUrl:e,environment:t,organizationId:o,userId:r,userProperties:n,language:u})=>{let[i,c]=(0,P.useState)(null),[p,a]=(0,P.useState)(!1),s=(0,P.useMemo)(()=>i!=null?i:[],[i]),[l,f]=(0,P.useState)(!1),v=(0,P.useRef)([]),d=(0,P.useMemo)(()=>({environment:t,organizationId:o,userId:r}),[t,o,r]),y=(0,P.useRef)(n);(0,P.useEffect)(()=>{y.current=n},[n]);let h=(0,P.useCallback)(()=>{a(!1),ue(e,_).getBlocks(w(m({},d),{language:gt(u),userProperties:y.current})).then(k=>{var C;c(()=>{let M=v.current.reduce(xe,k.blocks);return v.current=[],M}),(C=k.meta)!=null&&C.usage_limited&&f(!0)}).catch(k=>{a(!0),L.error("Failed to load blocks",k)})},[e,u,d]),A=(0,P.useMemo)(()=>l?void 0:`${e.replace("https://","wss://").replace("http://","ws://")}/ws/sdk/block-updates?${new URLSearchParams(d).toString()}`,[e,d,l]),F=(0,P.useCallback)(k=>{let C=JSON.parse(k.data);c(M=>M?xe(M,C):(v.current.push(C),M))},[]),{error:G}=jt({url:A,onMessage:F,onOpen:h});(0,P.useEffect)(()=>{s.forEach(k=>{var C;Qt(k),(C=k.tourBlocks)==null||C.forEach(M=>{Qt(M)})})},[s]);let B=(0,P.useCallback)(k=>{c(C=>C&&C.filter(M=>M.id!==k))},[]),j=(0,P.useCallback)((k,C)=>{c(M=>M&&M.map(we=>we.id===k?C(we):we))},[]);return{blocks:s,error:p,wsError:G,removeBlock:B,updateBlock:j}},Qt=e=>{e.slottable&&!e.slotId&&L.error(`Encountered workflow block "${e.componentType}" that is slottable but has no slotId`)};Q();var $=require("react");T();var to=require("react"),oo=require("es-toolkit");X();Q();var ro=()=>{let{runningTours:e}=I(),t=H(),[o]=(0,to.useState)(new Map),r=(0,$.useMemo)(()=>e.filter(n=>{var u;return!!((u=n.activeStep)!=null&&u.tourWait)}),[e]);return(0,$.useEffect)(()=>{r.forEach(n=>{var i,c,p;let u=(i=n.activeStep)==null?void 0:i.tourWait;(u==null?void 0:u.interaction)==="navigation"&&O({pathname:t,operator:(c=u.page)==null?void 0:c.operator,value:(p=u.page)==null?void 0:p.value})&&n.continue()})},[t,r]),(0,$.useEffect)(()=>{let n=u=>{let i=u.target;if(!i||!(i instanceof Element))return;let c=z();r.forEach(p=>{var s,l,f;let a=(s=p.activeStep)==null?void 0:s.tourWait;if((a==null?void 0:a.interaction)==="click"){let v=O({pathname:c,operator:(l=a.page)==null?void 0:l.operator,value:(f=a.page)==null?void 0:f.value});ce({eventTarget:i,value:a.element})&&v&&p.continue()}})};return addEventListener("click",n),()=>{removeEventListener("click",n)}},[t,r]),(0,$.useEffect)(()=>{let u=(0,oo.debounce)(()=>{let c=z();r.forEach(p=>{var l,f,v,d,y;let a=(l=p.activeStep)==null?void 0:l.tourWait,s=a==null?void 0:a.element;if((a==null?void 0:a.interaction)==="dom-element"){let h=O({pathname:c,operator:(f=a.page)==null?void 0:f.operator,value:(v=a.page)==null?void 0:v.value});wt(s)&&h&&p.continue()}if((a==null?void 0:a.interaction)==="not-dom-element"){let h=O({pathname:c,operator:(d=a.page)==null?void 0:d.operator,value:(y=a.page)==null?void 0:y.value});ht(s)&&h&&p.continue()}})},32),i=new MutationObserver(u);return i.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),u(),()=>{i.disconnect()}},[t,r]),(0,$.useEffect)(()=>{e.forEach(n=>{let u=n.activeStep,i=o.get(n.block.id);i&&i.stepId!==(u==null?void 0:u.id)&&(clearTimeout(i.timeoutId),o.delete(n.block.id))})},[e,o]),(0,$.useEffect)(()=>{r.forEach(n=>{let u=n.activeStep,i=u==null?void 0:u.tourWait;if(u&&(i==null?void 0:i.interaction)==="delay"&&i.ms!==void 0&&!o.has(n.block.id)){let c=window.setTimeout(()=>{n.continue(),o.delete(n.block.id)},i.ms);o.set(n.block.id,{timeoutId:c,stepId:u.id})}})},[r,o]),null};var te=require("react/jsx-runtime"),no=()=>{let e=fe();return(0,te.jsx)(te.Fragment,{children:e.map(t=>t.type==="component"?(0,te.jsx)(me,{block:t},t.id):t.type==="tour-component"?(0,te.jsx)(be,{block:t},t.tourBlockId):null)})};var q=require("react");T();T();var so=require("react"),ve=class extends so.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,o){L.error("ErrorBoundary caught an error:",t,o)}render(){return this.state.hasError?this.props.fallback:this.props.children}};var ye=require("react/jsx-runtime"),er=(0,q.lazy)(()=>Promise.resolve().then(()=>(Do(),Lo))),Fo=e=>{let[t,o]=(0,q.useState)(!0);return(0,q.useEffect)(()=>{o(!1)},[]),t?null:(0,ye.jsx)(tr,m({},e))},tr=r=>{var n=r,{enabled:e,onDebugKeydown:t}=n,o=Qe(n,["enabled","onDebugKeydown"]);let[u,i]=(0,q.useState)(ut(e));return(0,q.useEffect)(()=>{let c=p=>{(t!=null?t:dt)(p)&&i(s=>{let l=!s;return sessionStorage.setItem(Ce,String(l)),l})};return addEventListener("keydown",c),()=>{removeEventListener("keydown",c)}},[t]),u?(0,ye.jsx)(ve,{children:(0,ye.jsx)(er,m({},o))}):null};var J=require("react/jsx-runtime"),Go=e=>or(e)?(0,J.jsx)(Dt,{children:(0,J.jsx)(rr,m({},e))}):e.children,or=e=>typeof e.userId=="string",rr=({children:e,apiUrl:t="https://api.flows-cloud.com",environment:o,organizationId:r,userId:n,components:u,tourComponents:i,userProperties:c,language:p,debug:a,onDebugShortcut:s})=>{Y.apiUrl=t,Y.environment=o,Y.organizationId=r,Y.userId=n;let{blocks:l,error:f,wsError:v,removeBlock:d,updateBlock:y}=eo({apiUrl:t,environment:o,organizationId:r,userId:n,userProperties:c,language:p}),h=Yt({blocks:l,removeBlock:d});return(0,J.jsxs)(Ve.Provider,{value:{blocks:l,components:u,runningTours:h,tourComponents:i,removeBlock:d,updateBlock:y},children:[e,(0,J.jsx)(no,{}),(0,J.jsx)(ro,{}),(0,J.jsx)(Fo,{enabled:a,blocksError:f,wsError:v,environment:o,organizationId:r,userId:n,userProperties:c,onDebugKeydown:s})]})};var nr=()=>D({name:"reset-progress"}),sr=e=>D({name:"reset-progress",workflowId:e}),ar=e=>D({name:"workflow-start",blockKey:e}); | ||
`});var $e,lo,uo=g(()=>{"use strict";$e=require("react/jsx-runtime"),lo=e=>(0,$e.jsx)("svg",w(m({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 40 40"},e),{children:(0,$e.jsx)("path",{d:"M38.02 12.24C36.7 10 34.87 8.22 32.56 6.94C30.38 5.74 27.83 5.08 25 5H16C12.97 5 9.76 5.66 7.45 6.94C5.14 8.22 3.3 10 1.99 12.23C0.67 14.46 0 17.08 0 20.02C0 22.96 0.67 25.53 1.99 27.76C3.3 29.99 5.15 31.78 7.47 33.05C9.8 34.33 12.94 35 16 35H25C27.81 34.94 30.4 34.26 32.6 33.05C34.91 31.77 36.74 29.99 38.04 27.76C39.34 25.52 40 22.92 40 20.01C40 17.1 39.33 14.48 38.02 12.24ZM30.3 19.89L27.37 22.82C26.63 23.56 25.62 24 24.58 24H19.95C18.9 24 17.9 24.39 17.16 25.13L16.12 26C13.19 28.46 8.72 26.37 8.72 22.55C8.72 21.65 9.08 20.79 9.71 20.16L12.64 17.23C13.38 16.49 14.4 16 15.45 16H20.08C21.13 16 22.12 15.66 22.86 14.92L23.79 14.09C26.65 11.53 31.2 13.5 31.29 17.34V17.5C31.29 18.4 30.94 19.26 30.3 19.89Z"})}))});var K,po,co=g(()=>{"use strict";K=require("react/jsx-runtime"),po=({userProperties:e,userId:t})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)("p",{className:"flows-debug-info-line",children:[(0,K.jsx)("strong",{children:"User ID:"})," ",(0,K.jsx)("code",{className:"flows-debug-inline-code",children:t})]}),(0,K.jsx)("p",{className:"flows-debug-info-line",children:(0,K.jsx)("strong",{children:"User properties:"})}),(0,K.jsx)("pre",{className:"flows-debug-code-block",children:JSON.stringify(e!=null?e:{},null,2)})]})});var N,fo,go=g(()=>{"use strict";N=require("react/jsx-runtime"),fo=({organizationId:e,environment:t,statusItems:o})=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)("p",{className:"flows-debug-info-line",children:[(0,N.jsx)("strong",{children:"Organization ID:"})," ",(0,N.jsx)("code",{className:"flows-debug-inline-code",children:e||(0,N.jsx)("span",{className:"flows-debug-validation-invalid",children:"Not set"})})]}),(0,N.jsxs)("p",{className:"flows-debug-info-line",children:[(0,N.jsx)("strong",{children:"Environment:"})," ",(0,N.jsx)("code",{className:"flows-debug-inline-code",children:t||(0,N.jsx)("span",{className:"flows-debug-validation-invalid",children:"Not set"})})]}),(0,N.jsx)("p",{className:"flows-debug-info-line",children:(0,N.jsx)("strong",{children:"Validation:"})}),o]})});var V,mo,bo=g(()=>{"use strict";V=require("react/jsx-runtime"),mo=({blocks:e})=>(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)("p",{className:"flows-debug-info-line",children:[(0,V.jsx)("strong",{children:"Loaded blocks:"})," ",e.length]}),(0,V.jsx)("p",{className:"flows-debug-info-line",children:(0,V.jsx)("strong",{children:"Blocks JSON:"})}),(0,V.jsx)("pre",{className:"flows-debug-code-block",children:JSON.stringify(e,null,2)}),(0,V.jsx)("button",{className:"flows-debug-btn flows-debug-button-secondary flows-debug-print-button",onClick:()=>{console.log(e)},type:"button",children:"Print to console"})]})});var ie,re,vo=g(()=>{"use strict";ie=require("react/jsx-runtime"),re=({label:e,secondary:t,onClick:o})=>(0,ie.jsxs)("button",{className:"flows-debug-btn flows-debug-item flows-debug-item-interactive",onClick:o,type:"button",children:[(0,ie.jsx)("span",{className:"flows-debug-item-label",children:e}),t?(0,ie.jsx)("span",{className:"flows-debug-item-secondary",children:t}):null]})});var E,ko,yo=g(()=>{"use strict";T();vo();ae();E=require("react/jsx-runtime"),ko=({userId:e,setPanelPage:t,sdkSetupValid:o,blocks:r,pathname:n,organizationId:u})=>(0,E.jsxs)("div",{className:"flows-debug-popover-narrow",children:[(0,E.jsxs)("div",{className:"flows-debug-item-list",children:[(0,E.jsx)(re,{label:"User",secondary:e?(0,E.jsx)("code",{className:"flows-debug-inline-code",children:e}):"Not set",onClick:()=>{t("user")}}),(0,E.jsx)(re,{label:"SDK setup",secondary:o?"Valid":(0,E.jsx)("span",{className:"flows-debug-validation-invalid",children:"Error"}),onClick:()=>{t("sdk-setup")}}),(0,E.jsx)(re,{label:"Blocks",secondary:`${r.length} loaded`,onClick:()=>{t("blocks")}}),(0,E.jsx)(re,{label:"Pathname",secondary:n,onClick:()=>{t("pathname")}})]}),(0,E.jsx)("hr",{}),(0,E.jsxs)("div",{className:"flows-debug-item-list",children:[(0,E.jsx)(re,{label:"Settings",secondary:W,onClick:()=>{t("settings")}}),(0,E.jsx)("a",{href:pt(u),target:"_blank",rel:"noopener noreferrer",className:"flows-debug-item flows-debug-item-interactive flows-debug-item-label",children:"Open Flows dashboard"})]})]})});function wo(e){return(0,Ze.jsx)("svg",w(m({fill:"currentColor",height:16,width:16,xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,Ze.jsx)("path",{d:"M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"})}))}var Ze,ho=g(()=>{"use strict";Ze=require("react/jsx-runtime")});var v,xo,Co=g(()=>{"use strict";T();ho();ae();v=require("react/jsx-runtime"),xo=({position:e,onPositionChange:t})=>(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{className:"flows-debug-item",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"flows-debug-item-label",htmlFor:"debug-panel-position",children:"Position"}),(0,v.jsx)("p",{className:"flows-debug-item-info",children:"Sets the position of the debug panel on the screen."})]}),(0,v.jsxs)("div",{className:"flows-debug-select-wrap",children:[(0,v.jsx)("select",{className:"flows-debug-select",value:e,id:"debug-panel-position",onChange:r=>{let n=r.target.value;t(n)},children:Be.map(r=>(0,v.jsx)("option",{value:r.value,children:r.label},r.value))}),(0,v.jsx)(wo,{})]})]}),(0,v.jsxs)("div",{className:"flows-debug-item",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{className:"flows-debug-item-label",children:"Debug panel shortcut"}),(0,v.jsx)("p",{className:"flows-debug-item-info",children:"Used to toggle the panel visibility even when debug mode is not active."})]}),(0,v.jsxs)("div",{className:"flows-debug-shortcut-list",children:[(0,v.jsx)("p",{className:"flows-debug-shortcut",children:de()?"Cmd":"Ctrl"}),(0,v.jsx)("p",{className:"flows-debug-shortcut",children:de()?"Option":"Alt"}),(0,v.jsx)("p",{className:"flows-debug-shortcut",children:"Shift"}),(0,v.jsx)("p",{className:"flows-debug-shortcut",children:"F"})]})]}),(0,v.jsxs)("div",{className:"flows-debug-item",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{className:"flows-debug-item-label",children:"Docs"}),(0,v.jsx)("p",{className:"flows-debug-item-info",children:"Learn more about the debug panel and its features."})]}),(0,v.jsx)("a",{className:"flows-debug-button-secondary",href:ct,target:"_blank",rel:"noopener noreferrer",children:"Open docs"})]}),(0,v.jsxs)("div",{className:"flows-debug-item",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{className:"flows-debug-item-label",children:"SDK version"}),(0,v.jsx)("p",{className:"flows-debug-item-info",children:"Make sure to keep your SDK up to date for the best experience."})]}),(0,v.jsx)("p",{children:W})]})]})});var qe,Po,So=g(()=>{"use strict";qe=require("react/jsx-runtime"),Po=e=>(0,qe.jsx)("svg",w(m({fill:"currentColor",height:16,viewBox:"0 0 16 16",width:16,xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,qe.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.03 5.22032C12.1705 5.36094 12.2494 5.55157 12.2494 5.75032C12.2494 5.94907 12.1705 6.13969 12.03 6.28032L7.53003 10.7803C7.38941 10.9208 7.19878 10.9997 7.00003 10.9997C6.80128 10.9997 6.61066 10.9208 6.47003 10.7803L4.22003 8.53032C4.14634 8.46165 4.08724 8.37885 4.04625 8.28685C4.00526 8.19486 3.98322 8.09554 3.98144 7.99484C3.97966 7.89414 3.99819 7.79411 4.03591 7.70072C4.07363 7.60733 4.12977 7.5225 4.20099 7.45128C4.27221 7.38006 4.35705 7.32391 4.45043 7.28619C4.54382 7.24847 4.64385 7.22995 4.74455 7.23172C4.84526 7.2335 4.94457 7.25554 5.03657 7.29654C5.12857 7.33753 5.21137 7.39663 5.28003 7.47032L7.00003 9.19032L10.97 5.22032C11.1107 5.07987 11.3013 5.00098 11.5 5.00098C11.6988 5.00098 11.8894 5.07987 12.03 5.22032Z"})}))});function Bo(e){return(0,Je.jsx)("svg",w(m({height:16,viewBox:"0 0 16 16",width:16,xmlns:"http://www.w3.org/2000/svg",fill:"currentColor"},e),{children:(0,Je.jsx)("path",{d:"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"})}))}var Je,To=g(()=>{"use strict";Je=require("react/jsx-runtime")});function No(e){return(0,Xe.jsx)("svg",w(m({height:16,viewBox:"0 0 16 16",width:16,xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,Xe.jsx)("path",{d:"M7.78 12.53a.75.75 0 0 1-1.06 0L2.47 8.28a.75.75 0 0 1 0-1.06l4.25-4.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L4.81 7h7.44a.75.75 0 0 1 0 1.5H4.81l2.97 2.97a.75.75 0 0 1 0 1.06Z",fill:"currentColor"})}))}var Xe,Eo=g(()=>{"use strict";Xe=require("react/jsx-runtime")});var Z,Mo,Io=g(()=>{"use strict";Eo();Z=require("react/jsx-runtime"),Mo=({label:e,children:t,onClose:o})=>(0,Z.jsxs)("div",{className:"flows-debug-popover-wide",children:[(0,Z.jsxs)("div",{className:"flows-debug-section-header",children:[(0,Z.jsx)("button",{className:"flows-debug-btn flows-debug-section-close",onClick:o,type:"button",children:(0,Z.jsx)(No,{})}),(0,Z.jsx)("p",{className:"flows-debug-section-label",children:e})]}),(0,Z.jsx)("div",{className:"flows-debug-section-content",children:t})]})});var _,Ro,Ao=g(()=>{"use strict";_=require("react/jsx-runtime"),Ro=({pathname:e})=>(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{className:"flows-debug-info-line",children:(0,_.jsx)("strong",{children:"Pathname:"})}),(0,_.jsx)("p",{className:"flows-debug-code-block flows-debug-info-line",children:e}),(0,_.jsx)("p",{className:"flows-debug-info-line",children:"This pathname is used when evaluating page targeting conditions."})]})});var Lo={};et(Lo,{default:()=>Qo});var ne,we,x,Yo,jo,Qo,Do=g(()=>{"use strict";ne=require("react");T();ao();we=require("clsx");Y();ee();uo();co();go();bo();yo();Co();So();To();Io();Ao();x=require("react/jsx-runtime"),Yo=({blocksError:e,wsError:t,environment:o,organizationId:r,userId:n,userProperties:u})=>{let[i,c]=(0,ne.useState)(!1),p=()=>{c(B=>!B)},[a,s]=(0,ne.useState)(),l=()=>{s(void 0)},[f,b]=(0,ne.useState)(lt()),d=(0,ne.useCallback)(B=>{b(B),localStorage.setItem(Se,B)},[]),y=H(),{blocks:h}=I(),A=[{key:"organizationId",valid:r&&at.test(r)},{key:"userId",valid:!!n},{key:"environment",valid:!!o},{key:"apiError",valid:!e&&!t}],F=A.every(B=>B.valid),G=a==="user"?(0,x.jsx)(po,{userProperties:u,userId:n}):a==="sdk-setup"?(0,x.jsx)(fo,{organizationId:r,environment:o,statusItems:A.map(B=>{let Q=B.valid?(0,x.jsx)(Po,{className:"flows-debug-validation-valid"}):(0,x.jsx)(Bo,{className:"flows-debug-validation-invalid"}),k=Te[B.key][it(B.valid)];return(0,x.jsxs)("div",{className:"flows-debug-validation-item",children:[Q," ",(0,x.jsx)("p",{children:k})]},B.key)})}):a==="blocks"?(0,x.jsx)(mo,{blocks:h}):a==="pathname"?(0,x.jsx)(Ro,{pathname:y}):a==="settings"?(0,x.jsx)(xo,{position:f,onPositionChange:d}):(0,x.jsx)(ko,{pathname:y,userId:n,setPanelPage:s,sdkSetupValid:F,blocks:h,organizationId:r});return(0,x.jsxs)("div",{className:(0,we.clsx)("flows-debug",`flows-debug-${f}`),children:[(0,x.jsx)("button",{className:(0,we.clsx)("flows-debug-btn","flows-debug-menu",!F&&"flows-debug-menu-error"),type:"button",onClick:p,children:(0,x.jsx)("div",{className:(0,we.clsx)("flows-debug-menu-inset",!F&&"flows-debug-menu-inset-error"),children:(0,x.jsx)(lo,{})})}),i?(0,x.jsx)("div",{className:"flows-debug-popover",children:(0,x.jsx)(jo,{page:a,onClose:l,children:G})}):null,(0,x.jsx)("style",{children:io})]})},jo=({children:e,page:t,onClose:o})=>t?(0,x.jsx)(Mo,{label:Te.title[t],onClose:o,children:e}):e,Qo=Yo});var ir={};et(ir,{FlowsProvider:()=>Go,FlowsSlot:()=>Jo,resetAllWorkflowsProgress:()=>nr,resetWorkflowProgress:()=>sr,startWorkflow:()=>ar,useCurrentFloatingBlocks:()=>me,useCurrentSlotBlocks:()=>be});module.exports=Ho(ir);T();var te=require("react");Y();ee();T();T();var j={};ae();var D=async e=>{let{apiUrl:t,environment:o,organizationId:r,userId:n}=j;!t||!o||!r||!n||await pe(t,W).sendEvent(w(m({},e),{environment:o,organizationId:r,userId:n}))},Ot=new Set,Oe=async e=>{Ot.has(e)||(Ot.add(e),await D({name:"block-activated",blockId:e}))};var ze=({block:e,removeBlock:t,updateBlock:o})=>{if(!e.componentType)return[];let n=Ce({block:e,removeBlock:t,exitNodeCb:({key:i,blockId:c})=>D({name:"transition",blockId:c,propertyKey:i}),setStateMemory:async({blockId:i,key:c,value:p})=>{o(i,a=>{var s;return w(m({},a),{propertyMeta:(s=a.propertyMeta)==null?void 0:s.map(l=>l.type==="state-memory"&&l.key===c?w(m({},l),{value:p}):l)})}),await D({name:"set-state-memory",blockId:i,propertyKey:c,properties:{value:p}})}}),u={id:e.id,type:"component",component:e.componentType,props:n};return Ke(u,Oe)},He=e=>{let t=e.activeStep;if(!(t!=null&&t.componentType))return[];let o=nt({tourStep:t,currentIndex:e.currentBlockIndex,handleCancel:e.cancel,handleContinue:e.continue,handlePrevious:e.previous}),r={id:t.id,tourBlockId:e.block.id,type:"tour-component",component:t.componentType,props:o};return Ke(r,Oe)};var _e=e=>e==null?void 0:e.slotId;var Ht=()=>{let{blocks:e}=I(),t=H();return(0,te.useMemo)(()=>e.filter(o=>O({pathname:t,operator:o.page_targeting_operator,value:o.page_targeting_values})),[e,t])},_t=()=>{let{runningTours:e}=I(),t=H();return(0,te.useMemo)(()=>e.filter(o=>{let r=o.activeStep;return r&&O({pathname:t,operator:r.page_targeting_operator,value:r.page_targeting_values})}),[t,e])},me=()=>{let e=Ht(),t=_t(),{removeBlock:o,updateBlock:r}=I(),n=(0,te.useMemo)(()=>e.filter(i=>!i.slottable).flatMap(i=>ze({block:i,removeBlock:o,updateBlock:r})),[o,r,e]),u=(0,te.useMemo)(()=>t.filter(i=>{let c=i.activeStep;return c&&!c.slottable}).flatMap(He),[t]);return[...n,...u]},Wt=e=>"type"in e,zt=e=>{var t,o,r;return Wt(e)?(t=e.slotIndex)!=null?t:0:(r=(o=e.activeStep)==null?void 0:o.slotIndex)!=null?r:0},be=e=>{let t=Ht(),o=_t(),{removeBlock:r,updateBlock:n}=I();return(0,te.useMemo)(()=>{let i=t.filter(p=>p.slottable&&_e(p)===e),c=o.filter(p=>{var a;return((a=p.activeStep)==null?void 0:a.slottable)&&_e(p.activeStep)===e});return[...i,...c].sort((p,a)=>zt(p)-zt(a)).flatMap(p=>Wt(p)?ze({block:p,removeBlock:r,updateBlock:n}):He(p))},[r,e,n,t,o])};var $t=require("react");T();Y();var Zt=require("react/jsx-runtime"),ve=({block:e})=>{let{components:t}=I(),o=t[e.component];return(0,$t.useEffect)(()=>{o||L.error(`Component not found for workflow block "${e.component}"`)},[o,e.component]),o?(0,Zt.jsx)(o,m({},e.props)):null};var qt=require("react");T();Y();var Jt=require("react/jsx-runtime"),ke=({block:e})=>{let{tourComponents:t}=I(),o=t[e.component];return(0,qt.useEffect)(()=>{o||L.error(`Tour Component not found for tour block "${e.component}"`)},[o,e.component]),o?(0,Jt.jsx)(o,m({},e.props)):null};var We=require("react/jsx-runtime"),Jo=({id:e,placeholder:t})=>{let o=be(e);return o.length?o.map(r=>r.type==="component"?(0,We.jsx)(ve,{block:r},r.id):r.type==="tour-component"?(0,We.jsx)(ke,{block:r},r.id):null):t!=null?t:null};Y();var R=require("react");T();var Xt=require("es-toolkit");ee();var Yt=({blocks:e,removeBlock:t})=>{let[o,r]=(0,R.useState)([]),n=(0,R.useRef)(o);n.current=o;let u=H();(0,R.useEffect)(()=>{r(p=>{let a=new Set(e.filter(s=>s.type==="tour").map(s=>s.id));return p.filter(s=>a.has(s.blockId))})},[e]);let i=(0,R.useCallback)(p=>{let a=e.filter(l=>l.type==="tour"),s=new Set(n.current.map(l=>l.blockId));a.forEach(l=>{s.has(l.id)||!Pt(l.tour_trigger,p)||r(b=>{var y;let d={blockId:l.id,currentBlockIndex:(y=l.currentTourIndex)!=null?y:0};return[...b,d]})})},[e]);return(0,R.useEffect)(()=>{u&&i({pathname:u})},[u,i]),(0,R.useEffect)(()=>{let p=(0,Xt.debounce)(()=>{i({pathname:z()})},32),a=new MutationObserver(p);return a.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),p(),()=>{a.disconnect()}},[i]),(0,R.useEffect)(()=>{let p=a=>{i({pathname:z(),event:a})};return document.addEventListener("click",p),()=>{document.removeEventListener("click",p)}},[i]),(0,R.useMemo)(()=>{let p=(s,l)=>{r(f=>f.map(b=>b.blockId===s?l(b):b))},a=(s,l)=>{p(s,f=>w(m({},f),{currentBlockIndex:l}))};return o.map(({blockId:s,currentBlockIndex:l})=>{var G,B,Q;let f=e.find(k=>k.id===s);if(!f)return;let b=(G=f.tourBlocks)==null?void 0:G[l],d=l===((Q=(B=f.tourBlocks)==null?void 0:B.length)!=null?Q:0)-1,y=k=>{D({name:"tour-update",blockId:s,properties:{currentTourIndex:k}})};return{block:f,currentBlockIndex:l,activeStep:b,continue:()=>{if(d)t(s),D({name:"transition",propertyKey:"complete",blockId:s});else{let k=l+1;a(s,k),y(k)}},previous:()=>{var P;let k=l===0?l:l-1;for(;k>0&&f.tourBlocks&&!((P=f.tourBlocks.at(k))!=null&&P.componentType);)k-=1;a(s,k),y(k)},cancel:()=>{t(s),D({name:"transition",blockId:s,propertyKey:"cancel"})}}}).filter(s=>!!s)},[e,t,o])};var C=require("react");T();ae();var S=require("react"),jt=({url:e,onMessage:t,onOpen:o})=>{let[r,n]=(0,S.useState)(),[u,i]=(0,S.useState)(!1),c=(0,S.useRef)(void 0),[p,a]=(0,S.useState)(0),s=(0,S.useRef)(o);(0,S.useEffect)(()=>{s.current=o},[o]);let l=(0,S.useRef)(t);(0,S.useEffect)(()=>{l.current=t},[t]);let f=(0,S.useCallback)(d=>{l.current(d)},[]),b=(0,S.useCallback)(()=>{if(c.current&&(c.current(),c.current=void 0),!e)return;let d=new WebSocket(e);i(!1),n(d);let y=()=>{var G;(G=s.current)==null||G.call(s),a(0)},h=()=>{n(void 0),a(G=>G+1)},A=()=>{i(!0)};d.addEventListener("open",y),d.addEventListener("close",h),d.addEventListener("error",A),d.addEventListener("message",f);let F=()=>{d.removeEventListener("open",y),d.removeEventListener("close",h),d.removeEventListener("error",A),d.removeEventListener("message",f),d.readyState===WebSocket.CONNECTING?d.addEventListener("open",()=>{d.close()}):d.close(),n(void 0)};return c.current=F,F},[f,e]);return(0,S.useEffect)(()=>{let d=b();return()=>{d==null||d()}},[b]),(0,S.useEffect)(()=>{if(r)return;let d=setTimeout(()=>{b()},Math.min(1e3*4**p,12e4));return()=>{clearTimeout(d)}},[p,r,b]),(0,S.useEffect)(()=>()=>{c.current&&c.current()},[]),{error:u}};var eo=({apiUrl:e,environment:t,organizationId:o,userId:r,userProperties:n,language:u})=>{let[i,c]=(0,C.useState)(null),[p,a]=(0,C.useState)(!1),s=(0,C.useMemo)(()=>i!=null?i:[],[i]),[l,f]=(0,C.useState)(!1),b=(0,C.useRef)([]),d=(0,C.useMemo)(()=>({environment:t,organizationId:o,userId:r}),[t,o,r]),y=(0,C.useRef)(n);(0,C.useEffect)(()=>{y.current=n},[n]);let h=(0,C.useCallback)(()=>{a(!1),pe(e,W).getBlocks(w(m({},d),{language:gt(u),userProperties:y.current})).then(k=>{var P;c(b.current.reduce(ce,k.blocks)),b.current.length=0,setTimeout(()=>{if(b.current.length){let M=[...b.current];b.current.length=0,c(X=>M.reduce(ce,X!=null?X:[]))}},0),(P=k.meta)!=null&&P.usage_limited&&f(!0)}).catch(k=>{a(!0),L.error("Failed to load blocks",k)})},[e,u,d]),A=(0,C.useMemo)(()=>l?void 0:`${e.replace("https://","wss://").replace("http://","ws://")}/ws/sdk/block-updates?${new URLSearchParams(d).toString()}`,[e,d,l]),F=(0,C.useCallback)(k=>{let P=JSON.parse(k.data);c(M=>M?ce(M,P):(b.current.push(P),M))},[]),{error:G}=jt({url:A,onMessage:F,onOpen:h});(0,C.useEffect)(()=>{s.forEach(k=>{var P;Qt(k),(P=k.tourBlocks)==null||P.forEach(M=>{Qt(M)})})},[s]);let B=(0,C.useCallback)(k=>{c(P=>P&&P.filter(M=>M.id!==k))},[]),Q=(0,C.useCallback)((k,P)=>{c(M=>M&&M.map(X=>X.id===k?P(X):X))},[]);return{blocks:s,error:p,wsError:G,removeBlock:B,updateBlock:Q}},Qt=e=>{e.slottable&&!e.slotId&&L.error(`Encountered workflow block "${e.componentType}" that is slottable but has no slotId`)};ee();var $=require("react");T();var to=require("react"),oo=require("es-toolkit");Y();ee();var ro=()=>{let{runningTours:e}=I(),t=H(),[o]=(0,to.useState)(new Map),r=(0,$.useMemo)(()=>e.filter(n=>{var u;return!!((u=n.activeStep)!=null&&u.tourWait)}),[e]);return(0,$.useEffect)(()=>{r.forEach(n=>{var i,c,p;let u=(i=n.activeStep)==null?void 0:i.tourWait;(u==null?void 0:u.interaction)==="navigation"&&O({pathname:t,operator:(c=u.page)==null?void 0:c.operator,value:(p=u.page)==null?void 0:p.value})&&n.continue()})},[t,r]),(0,$.useEffect)(()=>{let n=u=>{let i=u.target;if(!i||!(i instanceof Element))return;let c=z();r.forEach(p=>{var s,l,f;let a=(s=p.activeStep)==null?void 0:s.tourWait;if((a==null?void 0:a.interaction)==="click"){let b=O({pathname:c,operator:(l=a.page)==null?void 0:l.operator,value:(f=a.page)==null?void 0:f.value});fe({eventTarget:i,value:a.element})&&b&&p.continue()}})};return addEventListener("click",n),()=>{removeEventListener("click",n)}},[t,r]),(0,$.useEffect)(()=>{let u=(0,oo.debounce)(()=>{let c=z();r.forEach(p=>{var l,f,b,d,y;let a=(l=p.activeStep)==null?void 0:l.tourWait,s=a==null?void 0:a.element;if((a==null?void 0:a.interaction)==="dom-element"){let h=O({pathname:c,operator:(f=a.page)==null?void 0:f.operator,value:(b=a.page)==null?void 0:b.value});wt(s)&&h&&p.continue()}if((a==null?void 0:a.interaction)==="not-dom-element"){let h=O({pathname:c,operator:(d=a.page)==null?void 0:d.operator,value:(y=a.page)==null?void 0:y.value});ht(s)&&h&&p.continue()}})},32),i=new MutationObserver(u);return i.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),u(),()=>{i.disconnect()}},[t,r]),(0,$.useEffect)(()=>{e.forEach(n=>{let u=n.activeStep,i=o.get(n.block.id);i&&i.stepId!==(u==null?void 0:u.id)&&(clearTimeout(i.timeoutId),o.delete(n.block.id))})},[e,o]),(0,$.useEffect)(()=>{r.forEach(n=>{let u=n.activeStep,i=u==null?void 0:u.tourWait;if(u&&(i==null?void 0:i.interaction)==="delay"&&i.ms!==void 0&&!o.has(n.block.id)){let c=window.setTimeout(()=>{n.continue(),o.delete(n.block.id)},i.ms);o.set(n.block.id,{timeoutId:c,stepId:u.id})}})},[r,o]),null};var oe=require("react/jsx-runtime"),no=()=>{let e=me();return(0,oe.jsx)(oe.Fragment,{children:e.map(t=>t.type==="component"?(0,oe.jsx)(ve,{block:t},t.id):t.type==="tour-component"?(0,oe.jsx)(ke,{block:t},t.tourBlockId):null)})};var q=require("react");T();T();var so=require("react"),ye=class extends so.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,o){L.error("ErrorBoundary caught an error:",t,o)}render(){return this.state.hasError?this.props.fallback:this.props.children}};var he=require("react/jsx-runtime"),er=(0,q.lazy)(()=>Promise.resolve().then(()=>(Do(),Lo))),Fo=e=>{let[t,o]=(0,q.useState)(!0);return(0,q.useEffect)(()=>{o(!1)},[]),t?null:(0,he.jsx)(tr,m({},e))},tr=r=>{var n=r,{enabled:e,onDebugKeydown:t}=n,o=Qe(n,["enabled","onDebugKeydown"]);let[u,i]=(0,q.useState)(ut(e));return(0,q.useEffect)(()=>{let c=p=>{(t!=null?t:dt)(p)&&i(s=>{let l=!s;return sessionStorage.setItem(Pe,String(l)),l})};return addEventListener("keydown",c),()=>{removeEventListener("keydown",c)}},[t]),u?(0,he.jsx)(ye,{children:(0,he.jsx)(er,m({},o))}):null};var J=require("react/jsx-runtime"),Go=e=>or(e)?(0,J.jsx)(Dt,{children:(0,J.jsx)(rr,m({},e))}):e.children,or=e=>typeof e.userId=="string",rr=({children:e,apiUrl:t="https://api.flows-cloud.com",environment:o,organizationId:r,userId:n,components:u,tourComponents:i,userProperties:c,language:p,debug:a,onDebugShortcut:s})=>{j.apiUrl=t,j.environment=o,j.organizationId=r,j.userId=n;let{blocks:l,error:f,wsError:b,removeBlock:d,updateBlock:y}=eo({apiUrl:t,environment:o,organizationId:r,userId:n,userProperties:c,language:p}),h=Yt({blocks:l,removeBlock:d});return(0,J.jsxs)(Ve.Provider,{value:{blocks:l,components:u,runningTours:h,tourComponents:i,removeBlock:d,updateBlock:y},children:[e,(0,J.jsx)(no,{}),(0,J.jsx)(ro,{}),(0,J.jsx)(Fo,{enabled:a,blocksError:f,wsError:b,environment:o,organizationId:r,userId:n,userProperties:c,onDebugKeydown:s})]})};var nr=()=>D({name:"reset-progress"}),sr=e=>D({name:"reset-progress",workflowId:e}),ar=e=>D({name:"workflow-start",blockKey:e}); |
{ | ||
"name": "@flows/react", | ||
"version": "1.17.0", | ||
"version": "1.17.1", | ||
"description": "Flows React SDK – Build native product growth experiences, your way", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
111436
0.18%1105
0.18%