@leadbot/components 2.24.1 → 2.25.0

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.
@@ -77,6 +77,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
77
77
  c-0.3,0-0.6,0.3-0.6,0.6v4.9c0,0.3,0.3,0.6,0.6,0.6h5.2l-0.1,26c0,9.6,5.5,13,12,13c2.1,0,4.3-0.6,6.1-1.1c0.3-0.1,0.6-0.4,0.6-0.8
78
78
  V90.9z"/>
79
79
  </g>
80
- </svg>`;function Pt(e,t){return e?`${t?`https://leadbot.nl/welkom-ai`:`https://leadbot.nl/welkom`}?r=${encodeURIComponent(e)}`:`https://leadbot.com?ref=widget`}function Ft({leadbot:n,align:r=`right`,className:i,asLink:a=!1,language:o=`en`,isChatbot:s=!1}){if(n?.is_white_label)return null;let c=n?.partner,l=c?.custom_branding??!1,u=c?.partner_logo_url&&/^https?:\/\//i.test(D(c.partner_logo_url))?D(c.partner_logo_url):null,d=c?.partner_website,f=n?.domain?.display_name,p=d&&/^https?:\/\//i.test(D(d))?D(d):null,m=p?`${p}${p.includes(`?`)?`&`:`?`}ref=widget`:null,h=r===`center`?`leadbot-powered-by--center`:`leadbot-powered-by--right`,g=i?` ${i}`:``,_=(0,t.getVariableValue)(`powered_by`,o);if(a){let t=l&&u,n=`leadbot-powered-by ${h}${g}`,r=t?e.t(`img`,{src:u,alt:`Partner`}):e.t(`span`,{className:`leadbot-powered-by__logo`,"aria-label":`LeadBot`,dangerouslySetInnerHTML:{__html:Nt}});if(t&&!m)return e.t(`div`,{className:n,children:[e.t(`span`,{children:_}),r]});let i=t&&m?m:Pt(f,s);return e.t(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:n,children:[e.t(`span`,{children:_}),r]})}return e.t(`div`,{className:`leadbot-powered-by ${h}${g}`,children:[e.t(`span`,{children:_}),l&&u?It(m,u):Lt(f,s)]})}function It(t,n){return t?e.t(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:e.t(`img`,{src:n,alt:`Partner`})}):e.t(`img`,{src:n,alt:`Partner`})}function Lt(t,n){return e.t(`a`,{href:Pt(t,n),target:`_blank`,rel:`noopener noreferrer`,children:e.t(`span`,{className:`leadbot-powered-by__logo`,"aria-label":`LeadBot`,dangerouslySetInnerHTML:{__html:Nt}})})}function Z({senderName:t=``,companyName:n,contentHtml:r,isFirstStep:i=!1,className:a,poweredByAlign:o=`right`,leadbot:s,language:c=`en`}){let l=i&&!s?.is_white_label,u=[`leadbot-card`,a,l?`leadbot-card--has-pwrdby`:``].filter(Boolean).join(` `);return e.t(`div`,{className:u,children:[t&&e.t(`div`,{className:`leadbot-title-row`,children:[e.t(`span`,{className:`leadbot-title-row__name`,children:t}),e.t(`span`,{className:`leadbot-title-row__arrow`,dangerouslySetInnerHTML:{__html:w.chevronRight}}),e.t(`span`,{className:`leadbot-title-row__company`,children:n})]}),e.t(`div`,{className:`leadbot-card__content`,dangerouslySetInnerHTML:{__html:X(r)}}),l&&e.t(Ft,{align:o,leadbot:s,language:c})]})}function Rt(n){let{step:r,config:i,isFirstStep:a}=n,{attributes:o}=r,s=o.message||``,c=o.sender_name||``,l=o.sender_image?.url||null,u=(0,t.processVariables)(s,i.leadbot.language,{name:i.leadbot.default_contact_information?.label,website_name:i.leadbot.domain.display_name,email:i.leadbot.default_contact_information?.email,phonenumber:i.leadbot.default_contact_information?.phone});return e.t(e.E,{children:e.t(`div`,{className:`leadbot-message-row leadbot-message-has-avatar`,children:[e.t(Mt,{imageUrl:l,variant:`message`,showOnlineDot:!0}),e.t(Z,{senderName:c,companyName:i.leadbot.domain.display_name,contentHtml:u,isFirstStep:a,poweredByAlign:`right`,leadbot:i.leadbot,language:i.leadbot?.language})]})})}function zt(t){let{step:n,config:r,isCurrent:i}=t;if(!i)return null;let a=u(n.options);if(a.length===0)return null;let o=a[0],s=r.steps.find(e=>e.uuid===o.next_step_uuid);if(!s)return null;if(s.step_type===`button`){let n=ca(`button`).component;return e.t(n,{...t,step:s})}let c=ca(s.step_type).component;return e.t(c,{...t,step:s})}function Bt(n){let{step:r,config:i,isFirstStep:a}=n,{attributes:o}=r,s=o.message||``,c=o.sender_name||``,l=(0,t.processVariables)(s,i.leadbot.language,{name:i.leadbot.default_contact_information?.label,website_name:i.leadbot.domain.display_name,email:i.leadbot.default_contact_information?.email,phonenumber:i.leadbot.default_contact_information?.phone});return e.t(e.E,{children:e.t(`div`,{className:`leadbot-message-row`,children:e.t(Z,{senderName:c,companyName:i.leadbot.domain.display_name,contentHtml:l,className:`leadbot-bubble-notification`,isFirstStep:a,poweredByAlign:`right`,leadbot:i.leadbot,language:i.leadbot?.language})})})}var Vt=class{constructor(e){this.domainKey=d(e),this.leadbotId=_(e),this.apiUrl=h(`/client/submit`),this.client=(0,t.createClient)({domainKey:this.domainKey,apiBase:h(``)}),this.previewToken=y()??void 0,this.preview=this.previewToken?!0:void 0,this.visitorId=(0,t.getOrCreateVisitorId)(),(0,t.getAttributionParams)()}submitChatFeedback(e){(0,t.sendChatFeedback)(this.client,{visitorId:this.visitorId,preview:this.preview,previewToken:this.previewToken,...e})}submitChatExchange(e){(0,t.sendChatExchange)(this.client,{leadbotId:this.leadbotId,visitorId:this.visitorId,analytics:(0,t.buildAnalytics)(),preview:this.preview,previewToken:this.previewToken,stepUuid:e.step_uuid,chatSessionId:e.chat_session_id,messages:e.messages,answer:e.answer})}trackClick(e){(0,t.trackClick)(this.client,{stepUuid:e,visitorId:this.visitorId,preview:this.preview,previewToken:this.previewToken})}async submitUserData(e,n,r,i){try{let a=await fetch(this.apiUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify((0,t.buildSubmitPayload)({domainKey:this.domainKey,leadbotId:this.leadbotId,stepUuid:n,stepType:e,visitorId:this.visitorId,userData:r,analytics:(0,t.buildAnalytics)(),preview:this.preview,previewToken:this.previewToken,extraFields:i}))});if(a.status===400){let e=await a.json().catch(()=>null),t=Error(e?.message||`Server error: ${a.status}`);throw t.errors=Array.isArray(e?.errors)?e.errors:[],t}if(!a.ok)return{success:!1,error:`Server error: ${a.status}`};let o=await a.json();if(o.success)return{success:!0,data:o};{console.error(`Submission failed:`,o);let e=Error(o.message||`Form submission failed`);throw e.errors=o.errors||[],e.message=o.message,e}}catch(e){if(console.error(`Submission error:`,e),e&&typeof e==`object`&&`errors`in e)throw e;return{success:!1,error:e instanceof Error?e.message:`An unknown error occurred`}}}};function Ht(t){let n=e.o(null);return n.current===null&&(n.current=new Vt(t)),n.current}function Ut(e){return e?e.startsWith(`tel:`)?w.phone:e.startsWith(`mailto:`)?w.envelope:null:null}function Wt(t){let n=Ht(t.config),{step:r,isCurrent:i,onOptionSelect:a}=t,o=r.attributes?.text||r.label||`Click here`,s=r.attributes?.url,c=r.attributes?.target||`_self`,l=r.attributes?.continue_after_cta===!0,d=()=>{if(!i)return;if(n.trackClick(r.uuid),t.analyticsTracker?.trackButtonClick(r),s){let e=O(s);if(e!==`#`&&window.open(e,c,`noopener,noreferrer`),!l)return}let e=u(r.options).map(e=>e.next_step_uuid).filter(e=>!!e);e.length>0&&a(e)},f=t=>t.split(/(\*\*.+?\*\*)/g).map((t,n)=>t.startsWith(`**`)&&t.endsWith(`**`)?e.t(`strong`,{children:t.slice(2,-2)},n):t),p=r.background_color?.trim(),m=p?.toLowerCase(),h=!p||m===`#fff`||m===`#ffffff`||m===`white`||m===`rgb(255, 255, 255)`||m===`rgba(255, 255, 255, 1)`,g=!p,_=Ut(s);return e.t(`button`,{className:`leadbot-option-btn${g?` leadbot-option-btn-secondary`:``}${i?``:` leadbot-option-disabled`}`,style:{"--btn-bg":p||`var(--leadbot-primary)`,"--btn-color":r.text_color||`#ffffff`},disabled:!i,onClick:d,children:[_&&e.t(`span`,{"aria-hidden":`true`,className:`leadbot-option-btn-icon${h?` leadbot-option-btn-icon-badge`:``}`,dangerouslySetInnerHTML:{__html:_}}),f(o)]})}function Gt(t){let{step:n}=t,r=e.o(null),[i,a]=e.l(!1),o=n.attributes?.html_content||n.attributes?.html||``,s=n.attributes?.title||``,c=n.background_color?.trim()||void 0;return e.d(()=>{a(!1);let e=r.current;if(!e)return;let t=e.querySelector(`iframe`);if(!t){a(!0);return}if(t.contentDocument?.readyState===`complete`){a(!0);return}let n=()=>a(!0);return t.addEventListener(`load`,n),()=>t.removeEventListener(`load`,n)},[o]),e.t(`div`,{className:`leadbot-html-embed ${i?`leadbot-embed-loaded`:``}`,style:c?{backgroundColor:c}:void 0,children:[s&&e.t(`div`,{className:`leadbot-embed-title`,dangerouslySetInnerHTML:{__html:X(s)}}),e.t(`div`,{ref:r,className:`leadbot-embed-content`,dangerouslySetInnerHTML:{__html:jt(o)}})]})}var Kt=e.D(null);function qt(e){let n=(0,t.resolveLanguage)(e);return{language:n,t:(e,r)=>{let i=(0,t.getVariableValue)(e,n);return i===`[${e}]`?r??e:i}}}var Jt=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(Jt||{}),Q=[0,1],Yt=[1,0],Xt=[2,3],Zt=[3,2],Qt={L:Q,M:Yt,Q:Xt,H:Zt},$t=/^\d*$/,en=/^[A-Z0-9 $%*+./:-]*$/,tn=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,nn=1,rn=40,an=3,on=3,sn=40,cn=10,ln=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],un=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],dn=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<nn||e>rn)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,Jt.Timing),this.setFunctionModule(e,6,e%2==0,Jt.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,fn(r,e));this.setFunctionModule(8,7,fn(r,6)),this.setFunctionModule(8,8,fn(r,7)),this.setFunctionModule(7,8,fn(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,fn(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,fn(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,fn(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=fn(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,Jt.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,Jt.Alignment)}setFunctionModule(e,t,n,r=Jt.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==Dn(t,n))throw RangeError(`Invalid argument`);let r=un[n[0]][t],i=ln[n[0]][t],a=Math.floor(En(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=On(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=kn(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(En(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=fn(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=an:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*sn),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*sn}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=an:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*sn),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*sn}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=on)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*cn,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function $(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function fn(e,t){return!!(e>>>t&1)}var pn=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},mn=[1,10,12,14],hn=[2,9,11,13],gn=[4,8,16,16];function _n(e,t){return e[Math.floor((t+7)/17)+1]}function vn(e){let t=[];for(let n of e)$(n,8,t);return new pn(gn,e.length,t)}function yn(e){if(!Sn(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);$(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new pn(mn,e.length,t)}function bn(e){if(!Cn(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n;for(n=0;n+2<=e.length;n+=2){let r=tn.indexOf(e.charAt(n))*45;r+=tn.indexOf(e.charAt(n+1)),$(r,11,t)}return n<e.length&&$(tn.indexOf(e.charAt(n)),6,t),new pn(hn,e.length,t)}function xn(e){return e===``?[]:Sn(e)?[yn(e)]:Cn(e)?[bn(e)]:[vn(Tn(e))]}function Sn(e){return $t.test(e)}function Cn(e){return en.test(e)}function wn(e,t){let n=0;for(let r of e){let e=_n(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function Tn(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function En(e){if(e<nn||e>rn)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function Dn(e,t){return Math.floor(En(e)/8)-ln[t[0]][e]*un[t[0]][e]}function On(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=An(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=An(n,2)}return t}function kn(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=An(t,e))}return n}function An(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function jn(e,t,n=1,r=40,i=-1,a=!0){if(!(nn<=n&&n<=r&&r<=rn)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=Dn(o,t)*8,i=wn(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Yt,Xt,Zt])a&&s<=Dn(o,e)*8&&(t=e);let c=[];for(let t of e){$(t.mode[0],4,c),$(t.numChars,_n(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=Dn(o,t)*8;$(0,Math.min(4,l-c.length),c),$(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)$(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new dn(o,t,u,i)}function Mn(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?xn(e):Array.isArray(e)?[vn(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=jn(c,Qt[n],i,a,o,r),u=Nn({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function Nn(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=Jt.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function Pn(e,t){let n=Object.entries(e).find(([,e])=>e.name===t);return n?{uuid:n[0],...n[1]}:null}function Fn(e){let t=Pn(e,`message`);if(t)return t;let n=Pn(e,`phone`)?.uuid,r=Object.entries(e).find(([e])=>e!==n);return r?{uuid:r[0],...r[1]}:null}function In(e,t,n){let r=e.trim(),i=n?.trim();return[t.trim(),r&&`*bericht:*\n\n${r}`,i&&`*telefoonnummer:*\n\n${i}`].filter(Boolean).join(`
80
+ </svg>`;function Pt(e,t){return e?`${t?`https://leadbot.nl/welkom-ai`:`https://leadbot.nl/welkom`}?r=${encodeURIComponent(e)}`:`https://leadbot.com?ref=widget`}function Ft({leadbot:n,align:r,className:i,asLink:a=!1,language:o=`en`,isChatbot:s=!1}){if(n?.is_white_label)return null;let c=n?.partner,l=c?.custom_branding??!1,u=c?.partner_logo_url&&/^https?:\/\//i.test(D(c.partner_logo_url))?D(c.partner_logo_url):null,d=c?.partner_website,f=n?.domain?.display_name,p=d&&/^https?:\/\//i.test(D(d))?D(d):null,m=p?`${p}${p.includes(`?`)?`&`:`?`}ref=widget`:null,h=r?` leadbot-powered-by--${r}`:``,g=i?` ${i}`:``,_=(0,t.getVariableValue)(`powered_by`,o);if(a){let t=l&&u,n=`leadbot-powered-by${h}${g}`,r=t?e.t(`img`,{src:u,alt:`Partner`}):e.t(`span`,{className:`leadbot-powered-by__logo`,"aria-label":`LeadBot`,dangerouslySetInnerHTML:{__html:Nt}});if(t&&!m)return e.t(`div`,{className:n,children:[e.t(`span`,{children:_}),r]});let i=t&&m?m:Pt(f,s);return e.t(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:n,children:[e.t(`span`,{children:_}),r]})}return e.t(`div`,{className:`leadbot-powered-by${h}${g}`,children:[e.t(`span`,{children:_}),l&&u?It(m,u):Lt(f,s)]})}function It(t,n){return t?e.t(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:e.t(`img`,{src:n,alt:`Partner`})}):e.t(`img`,{src:n,alt:`Partner`})}function Lt(t,n){return e.t(`a`,{href:Pt(t,n),target:`_blank`,rel:`noopener noreferrer`,children:e.t(`span`,{className:`leadbot-powered-by__logo`,"aria-label":`LeadBot`,dangerouslySetInnerHTML:{__html:Nt}})})}function Z({senderName:t=``,companyName:n,contentHtml:r,isFirstStep:i=!1,className:a,poweredByAlign:o,leadbot:s,language:c=`en`}){let l=i&&!s?.is_white_label,u=[`leadbot-card`,a,l?`leadbot-card--has-pwrdby`:``].filter(Boolean).join(` `);return e.t(`div`,{className:u,children:[t&&e.t(`div`,{className:`leadbot-title-row`,children:[e.t(`span`,{className:`leadbot-title-row__name`,children:t}),e.t(`span`,{className:`leadbot-title-row__arrow`,dangerouslySetInnerHTML:{__html:w.chevronRight}}),e.t(`span`,{className:`leadbot-title-row__company`,children:n})]}),e.t(`div`,{className:`leadbot-card__content`,dangerouslySetInnerHTML:{__html:X(r)}}),l&&e.t(Ft,{align:o,leadbot:s,language:c})]})}function Rt(n){let{step:r,config:i,isFirstStep:a}=n,{attributes:o}=r,s=o.message||``,c=o.sender_name||``,l=o.sender_image?.url||null,u=(0,t.processVariables)(s,i.leadbot.language,{name:i.leadbot.default_contact_information?.label,website_name:i.leadbot.domain.display_name,email:i.leadbot.default_contact_information?.email,phonenumber:i.leadbot.default_contact_information?.phone});return e.t(e.E,{children:e.t(`div`,{className:`leadbot-message-row leadbot-message-has-avatar`,children:[e.t(Mt,{imageUrl:l,variant:`message`,showOnlineDot:!0}),e.t(Z,{senderName:c,companyName:i.leadbot.domain.display_name,contentHtml:u,isFirstStep:a,leadbot:i.leadbot,language:i.leadbot?.language})]})})}function zt(t){let{step:n,config:r,isCurrent:i}=t;if(!i)return null;let a=u(n.options);if(a.length===0)return null;let o=a[0],s=r.steps.find(e=>e.uuid===o.next_step_uuid);if(!s)return null;if(s.step_type===`button`){let n=ca(`button`).component;return e.t(n,{...t,step:s})}let c=ca(s.step_type).component;return e.t(c,{...t,step:s})}function Bt(n){let{step:r,config:i,isFirstStep:a}=n,{attributes:o}=r,s=o.message||``,c=o.sender_name||``,l=(0,t.processVariables)(s,i.leadbot.language,{name:i.leadbot.default_contact_information?.label,website_name:i.leadbot.domain.display_name,email:i.leadbot.default_contact_information?.email,phonenumber:i.leadbot.default_contact_information?.phone});return e.t(e.E,{children:e.t(`div`,{className:`leadbot-message-row`,children:e.t(Z,{senderName:c,companyName:i.leadbot.domain.display_name,contentHtml:l,className:`leadbot-bubble-notification`,isFirstStep:a,leadbot:i.leadbot,language:i.leadbot?.language})})})}var Vt=class{constructor(e){this.domainKey=d(e),this.leadbotId=_(e),this.apiUrl=h(`/client/submit`),this.client=(0,t.createClient)({domainKey:this.domainKey,apiBase:h(``)}),this.previewToken=y()??void 0,this.preview=this.previewToken?!0:void 0,this.visitorId=(0,t.getOrCreateVisitorId)(),(0,t.getAttributionParams)()}submitChatFeedback(e){(0,t.sendChatFeedback)(this.client,{visitorId:this.visitorId,preview:this.preview,previewToken:this.previewToken,...e})}submitChatExchange(e){(0,t.sendChatExchange)(this.client,{leadbotId:this.leadbotId,visitorId:this.visitorId,analytics:(0,t.buildAnalytics)(),preview:this.preview,previewToken:this.previewToken,stepUuid:e.step_uuid,chatSessionId:e.chat_session_id,messages:e.messages,answer:e.answer})}trackClick(e){(0,t.trackClick)(this.client,{stepUuid:e,visitorId:this.visitorId,preview:this.preview,previewToken:this.previewToken})}async submitUserData(e,n,r,i){try{let a=await fetch(this.apiUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify((0,t.buildSubmitPayload)({domainKey:this.domainKey,leadbotId:this.leadbotId,stepUuid:n,stepType:e,visitorId:this.visitorId,userData:r,analytics:(0,t.buildAnalytics)(),preview:this.preview,previewToken:this.previewToken,extraFields:i}))});if(a.status===400){let e=await a.json().catch(()=>null),t=Error(e?.message||`Server error: ${a.status}`);throw t.errors=Array.isArray(e?.errors)?e.errors:[],t}if(!a.ok)return{success:!1,error:`Server error: ${a.status}`};let o=await a.json();if(o.success)return{success:!0,data:o};{console.error(`Submission failed:`,o);let e=Error(o.message||`Form submission failed`);throw e.errors=o.errors||[],e.message=o.message,e}}catch(e){if(console.error(`Submission error:`,e),e&&typeof e==`object`&&`errors`in e)throw e;return{success:!1,error:e instanceof Error?e.message:`An unknown error occurred`}}}};function Ht(t){let n=e.o(null);return n.current===null&&(n.current=new Vt(t)),n.current}function Ut(e){return e?e.startsWith(`tel:`)?w.phone:e.startsWith(`mailto:`)?w.envelope:null:null}function Wt(t){let n=Ht(t.config),{step:r,isCurrent:i,onOptionSelect:a}=t,o=r.attributes?.text||r.label||`Click here`,s=r.attributes?.url,c=r.attributes?.target||`_self`,l=r.attributes?.continue_after_cta===!0,d=()=>{if(!i)return;if(n.trackClick(r.uuid),t.analyticsTracker?.trackButtonClick(r),s){let e=O(s);if(e!==`#`&&window.open(e,c,`noopener,noreferrer`),!l)return}let e=u(r.options).map(e=>e.next_step_uuid).filter(e=>!!e);e.length>0&&a(e)},f=t=>t.split(/(\*\*.+?\*\*)/g).map((t,n)=>t.startsWith(`**`)&&t.endsWith(`**`)?e.t(`strong`,{children:t.slice(2,-2)},n):t),p=r.background_color?.trim(),m=p?.toLowerCase(),h=!p||m===`#fff`||m===`#ffffff`||m===`white`||m===`rgb(255, 255, 255)`||m===`rgba(255, 255, 255, 1)`,g=!p,_=Ut(s);return e.t(`button`,{className:`leadbot-option-btn${g?` leadbot-option-btn-secondary`:``}${i?``:` leadbot-option-disabled`}`,style:{"--btn-bg":p||`var(--leadbot-primary)`,"--btn-color":r.text_color||`#ffffff`},disabled:!i,onClick:d,children:[_&&e.t(`span`,{"aria-hidden":`true`,className:`leadbot-option-btn-icon${h?` leadbot-option-btn-icon-badge`:``}`,dangerouslySetInnerHTML:{__html:_}}),f(o)]})}function Gt(t){let{step:n}=t,r=e.o(null),[i,a]=e.l(!1),o=n.attributes?.html_content||n.attributes?.html||``,s=n.attributes?.title||``,c=n.background_color?.trim()||void 0;return e.d(()=>{a(!1);let e=r.current;if(!e)return;let t=e.querySelector(`iframe`);if(!t){a(!0);return}if(t.contentDocument?.readyState===`complete`){a(!0);return}let n=()=>a(!0);return t.addEventListener(`load`,n),()=>t.removeEventListener(`load`,n)},[o]),e.t(`div`,{className:`leadbot-html-embed ${i?`leadbot-embed-loaded`:``}`,style:c?{backgroundColor:c}:void 0,children:[s&&e.t(`div`,{className:`leadbot-embed-title`,dangerouslySetInnerHTML:{__html:X(s)}}),e.t(`div`,{ref:r,className:`leadbot-embed-content`,dangerouslySetInnerHTML:{__html:jt(o)}})]})}var Kt=e.D(null);function qt(e){let n=(0,t.resolveLanguage)(e);return{language:n,t:(e,r)=>{let i=(0,t.getVariableValue)(e,n);return i===`[${e}]`?r??e:i}}}var Jt=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(Jt||{}),Q=[0,1],Yt=[1,0],Xt=[2,3],Zt=[3,2],Qt={L:Q,M:Yt,Q:Xt,H:Zt},$t=/^\d*$/,en=/^[A-Z0-9 $%*+./:-]*$/,tn=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,nn=1,rn=40,an=3,on=3,sn=40,cn=10,ln=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],un=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],dn=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<nn||e>rn)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,Jt.Timing),this.setFunctionModule(e,6,e%2==0,Jt.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,fn(r,e));this.setFunctionModule(8,7,fn(r,6)),this.setFunctionModule(8,8,fn(r,7)),this.setFunctionModule(7,8,fn(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,fn(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,fn(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,fn(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=fn(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,Jt.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,Jt.Alignment)}setFunctionModule(e,t,n,r=Jt.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==Dn(t,n))throw RangeError(`Invalid argument`);let r=un[n[0]][t],i=ln[n[0]][t],a=Math.floor(En(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=On(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=kn(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(En(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=fn(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=an:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*sn),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*sn}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=an:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*sn),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*sn}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=on)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*cn,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function $(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function fn(e,t){return!!(e>>>t&1)}var pn=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},mn=[1,10,12,14],hn=[2,9,11,13],gn=[4,8,16,16];function _n(e,t){return e[Math.floor((t+7)/17)+1]}function vn(e){let t=[];for(let n of e)$(n,8,t);return new pn(gn,e.length,t)}function yn(e){if(!Sn(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);$(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new pn(mn,e.length,t)}function bn(e){if(!Cn(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n;for(n=0;n+2<=e.length;n+=2){let r=tn.indexOf(e.charAt(n))*45;r+=tn.indexOf(e.charAt(n+1)),$(r,11,t)}return n<e.length&&$(tn.indexOf(e.charAt(n)),6,t),new pn(hn,e.length,t)}function xn(e){return e===``?[]:Sn(e)?[yn(e)]:Cn(e)?[bn(e)]:[vn(Tn(e))]}function Sn(e){return $t.test(e)}function Cn(e){return en.test(e)}function wn(e,t){let n=0;for(let r of e){let e=_n(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function Tn(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function En(e){if(e<nn||e>rn)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function Dn(e,t){return Math.floor(En(e)/8)-ln[t[0]][e]*un[t[0]][e]}function On(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=An(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=An(n,2)}return t}function kn(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=An(t,e))}return n}function An(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function jn(e,t,n=1,r=40,i=-1,a=!0){if(!(nn<=n&&n<=r&&r<=rn)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=Dn(o,t)*8,i=wn(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Yt,Xt,Zt])a&&s<=Dn(o,e)*8&&(t=e);let c=[];for(let t of e){$(t.mode[0],4,c),$(t.numChars,_n(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=Dn(o,t)*8;$(0,Math.min(4,l-c.length),c),$(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)$(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new dn(o,t,u,i)}function Mn(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?xn(e):Array.isArray(e)?[vn(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=jn(c,Qt[n],i,a,o,r),u=Nn({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function Nn(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=Jt.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function Pn(e,t){let n=Object.entries(e).find(([,e])=>e.name===t);return n?{uuid:n[0],...n[1]}:null}function Fn(e){let t=Pn(e,`message`);if(t)return t;let n=Pn(e,`phone`)?.uuid,r=Object.entries(e).find(([e])=>e!==n);return r?{uuid:r[0],...r[1]}:null}function In(e,t,n){let r=e.trim(),i=n?.trim();return[t.trim(),r&&`*bericht:*\n\n${r}`,i&&`*telefoonnummer:*\n\n${i}`].filter(Boolean).join(`
81
81
 
82
- `)}function Ln(e){try{let{data:t,size:n}=Mn(e),r=n+4,i=``;for(let e=0;e<n;e++)for(let r=0;r<n;r++)t[e][r]&&(i+=`M${r+2},${e+2}h1v1h-1z`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${r} ${r}"><rect width="${r}" height="${r}" fill="#fff"/><path d="${i}" fill="#111b21"/></svg>`}catch(e){return console.error(`QR code generation failed:`,e),null}}var Rn=`whatsapp`;function zn(n){let{step:r,config:a,isCurrent:o,onOptionSelect:s}=n,c=Ht(a),l=e.p(Kt),[u,d]=e.l(!1),[f,p]=e.l(null),[m,h]=e.l(null),[g,_]=e.l(null),[v,y]=e.l(null),[b,x]=e.l(!1),S=e.o(null),C=e.o(null),T=e.o(void 0);e.d(()=>()=>clearTimeout(T.current),[]);let E=r.attributes?.show_qr_code===!0,{isDesktop:D}=i(),O=E&&D,k=(0,t.resolveLanguage)(a.leadbot?.language),{t:A}=qt(k),j=r.attributes?.sender_name||A(`whatsapp_default_contact`,`Support`),ee=r.attributes?.sender_image?.url||null,M=r.attributes?.text||``,N=(0,t.processVariables)(M,k,{name:a.leadbot.default_contact_information?.label,website_name:a.leadbot.domain.display_name,email:a.leadbot.default_contact_information?.email,phonenumber:a.leadbot.default_contact_information?.phone}),P=r.attributes?.form_schema?.fields||{},F=Fn(P),I=Pn(P,`phone`),te=r.attributes?.ask_phone_number===!0&&!!I,L=g!==null;e.d(()=>{if(!o)return;let e=C.current?.closest(`.leadbot-steps-container`);e&&(e.scrollTop=e.scrollHeight)},[o,L,b,m,f]);let ne=A(`whatsapp_placeholder`,`Type a message`),re=A(`whatsapp_phone_placeholder`,`Your phone number`),ie=A(`whatsapp_phone_prompt`,`What is your phone number? Then we will continue in WhatsApp.`),R=A(`whatsapp_phone_invalid`,`Please enter a valid phone number.`),ae=A(`whatsapp_status_online`,`Online`),oe=()=>{let e=new Date;return e.getHours().toString().padStart(2,`0`)+`:`+e.getMinutes().toString().padStart(2,`0`)},se=r.attributes?.sender_number||r.attributes?.phone_number||``,ce=A(`whatsapp_error_submission`,`We could not save your message. You can still continue in WhatsApp.`),le=A(`whatsapp_error_phone_missing`,`WhatsApp is not configured for this step.`),ue=(0,t.sanitizeTrackedUrl)(window.location.href),z=async(e,t)=>{if(!F)return null;let i={[F.uuid]:e};t&&I&&(i[I.uuid]=t);let a=await c.submitUserData(Rn,r.uuid,i,l?{chat_session_id:l}:void 0);if(a?.success===!1)throw Error(a.error||`Submission failed`);return n.onSubmitted?.(i),null},de=A(`whatsapp_error_redirect`,`WhatsApp could not be opened. Please check your pop-up settings.`),B=(e,n)=>{let r=In(e,ue,n),i=(0,t.createWhatsAppUrl)(se,r);return i?(window.open(i,`_blank`,`noopener,noreferrer`),!0):!1},fe=()=>{let e=r.options?.[0];e?.next_step_uuid&&s(e.next_step_uuid)},V=(e,t)=>{let n=Ln(e);return n?(h(n),y(t),!0):!1},H=async e=>{if(e.preventDefault(),!o||u||b)return;let i=S.current?.value?.trim();if(!i)return;if(p(null),te&&!L){_(i),x(!0),T.current=setTimeout(()=>x(!1),t.TYPING_INDICATOR_MS),S.current&&(S.current.value=``);return}let a=L?g:i,s=L?(0,t.normalizePhoneInput)(i):void 0;if(s!==void 0&&!(0,t.isPlausiblePhone)(s)){p(R);return}d(!0);try{try{await z(a,s)}catch(e){console.error(`WhatsApp data submission failed:`,e),p(ce)}if(!se||!se.trim()){p(le);return}if(O){let e=In(a,ue,s),i=(0,t.createWhatsAppUrl)(se,e),o=(0,t.createWhatsAppWebUrl)(se,e);if(!i||!o||!V(i,o)){p(de);return}n.analyticsTracker?.trackWhatsAppRedirect(r),S.current&&(S.current.value=``),_(null);return}if(!B(a,s)){p(de);return}n.analyticsTracker?.trackWhatsAppRedirect(r),S.current&&(S.current.value=``),_(null),fe()}catch(e){console.error(`WhatsApp submission failed:`,e),p(ce)}finally{d(!1)}},pe=e.t(Ft,{align:`right`,className:`leadbot-whatsapp-branding`,leadbot:a.leadbot,language:k,asLink:!0}),U=A(`whatsapp_qr_title`,`Open in WhatsApp`),me=A(`whatsapp_qr_scan_label`,`Scan this QR code with your phone to continue on WhatsApp`),he=A(`whatsapp_qr_open_web`,`Open WhatsApp Web`);return e.t(`div`,{className:`leadbot-whatsapp-interface`,ref:C,children:[e.t(`div`,{className:`leadbot-whatsapp-header`,children:e.t(`div`,{className:`leadbot-whatsapp-contact-info`,children:[e.t(Mt,{imageUrl:ee,alt:j,variant:`whatsapp`}),e.t(`div`,{className:`leadbot-whatsapp-contact-details`,children:[e.t(`div`,{className:`leadbot-whatsapp-name`,children:j}),e.t(`div`,{className:`leadbot-whatsapp-status`,children:ae})]})]})}),e.t(`div`,{className:`leadbot-whatsapp-chat`,children:[N&&e.t(`div`,{className:`leadbot-whatsapp-message`,children:[e.t(`div`,{className:`leadbot-whatsapp-message-content`,dangerouslySetInnerHTML:{__html:X(N)}}),e.t(`div`,{className:`leadbot-whatsapp-message-time`,children:[oe(),e.t(`span`,{className:`leadbot-whatsapp-checkmarks`,dangerouslySetInnerHTML:{__html:w.checkDouble}})]})]}),L&&e.t(e.E,{children:[e.t(`div`,{className:`leadbot-whatsapp-message leadbot-whatsapp-message-outgoing`,children:[e.t(`div`,{className:`leadbot-whatsapp-message-content`,children:g}),e.t(`div`,{className:`leadbot-whatsapp-message-time`,children:oe()})]}),b?e.t(`div`,{className:`leadbot-whatsapp-message leadbot-whatsapp-typing`,"aria-hidden":`true`,children:e.t(`span`,{className:`leadbot-whatsapp-typing-dots`,children:[e.t(`span`,{}),e.t(`span`,{}),e.t(`span`,{})]})}):e.t(`div`,{className:`leadbot-whatsapp-message`,children:e.t(`div`,{className:`leadbot-whatsapp-message-content`,children:ie})})]})]}),m&&v?e.t(`div`,{className:`leadbot-whatsapp-qr-card`,children:[e.t(`div`,{className:`leadbot-whatsapp-qr-content`,children:[e.t(`div`,{className:`leadbot-whatsapp-qr-title`,children:U}),e.t(`div`,{className:`leadbot-whatsapp-qr-image`,dangerouslySetInnerHTML:{__html:m}}),e.t(`div`,{className:`leadbot-whatsapp-qr-label`,children:me})]}),e.t(`div`,{className:`leadbot-whatsapp-qr-actions`,children:e.t(`a`,{href:v,target:`_blank`,rel:`noopener noreferrer`,className:`leadbot-whatsapp-qr-btn leadbot-whatsapp-qr-btn-web`,children:[e.t(`span`,{className:`leadbot-whatsapp-qr-btn-icon`,dangerouslySetInnerHTML:{__html:w.whatsapp}}),he]})}),pe]}):e.t(`div`,{className:`leadbot-whatsapp-input-container`,children:[f&&e.t(`div`,{className:`leadbot-form-error`,children:f}),e.t(`form`,{onSubmit:H,children:e.t(`div`,{className:`leadbot-whatsapp-input-bar`,children:[e.t(`input`,{ref:S,type:L?`tel`:`text`,className:`leadbot-whatsapp-message-field`,placeholder:L?re:ne,"aria-label":L?re:ne,autoComplete:L?`tel`:`off`,required:!0,disabled:!o||u||b}),e.t(`button`,{type:`submit`,className:`leadbot-whatsapp-send-btn${u?` leadbot-whatsapp-send-disabled`:``}`,"aria-label":A(`whatsapp_send_label`,`Send message`),disabled:!o||u,children:e.t(`span`,{dangerouslySetInnerHTML:{__html:w.send}})})]})}),pe]})]})}function Bn(e,t){for(var n in t)e[n]=t[n];return e}function Vn(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function Hn(e,t){this.props=e,this.context=t}(Hn.prototype=new e.C).isPureReactComponent=!0,Hn.prototype.shouldComponentUpdate=function(e,t){return Vn(this.props,e)||Vn(this.state,t)};var Un=e.k.__b;e.k.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Un&&Un(e)},typeof Symbol<`u`&&Symbol.for;var Wn=e.k.__e;e.k.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k||[]),i.__c(e,t)}Wn(e,t,n,r)};var Gn=e.k.unmount;function Kn(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=Bn({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Kn(e,t,n)})),e}function qn(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return qn(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Jn(){this.__u=0,this.o=null,this.__b=null}function Yn(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function Xn(){this.i=null,this.l=null}e.k.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Gn&&Gn(e)},(Jn.prototype=new e.C).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=Yn(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=qn(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},Jn.prototype.componentWillUnmount=function(){this.o=[]},Jn.prototype.render=function(t,n){if(this.__b){if(this.__v.__k){var r=document.createElement(`div`),i=this.__v.__k[0].__c;this.__v.__k[0]=Kn(this.__b,r,i.__O=i.__P)}this.__b=null}var a=n.__a&&e.O(e.E,null,t.fallback);return a&&(a.__u&=-33),[e.O(e.E,null,n.__a?null:t.children),a]};var Zn=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function Qn(e){return this.getChildContext=function(){return e.context},e.children}function $n(t){var n=this,r=t.h;if(n.componentWillUnmount=function(){e.T(null,n.v),n.v=null,n.h=null},n.h&&n.h!==r&&n.componentWillUnmount(),!n.v){for(var i=n.__v;i!==null&&!i.__m&&i.__!==null;)i=i.__;n.h=r,n.v={nodeType:1,parentNode:r,childNodes:[],__k:{__m:i.__m},contains:function(){return!0},namespaceURI:r.namespaceURI,insertBefore:function(e,t){this.childNodes.push(e),n.h.insertBefore(e,t)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),n.h.removeChild(e)}}}e.T(e.O(Qn,{context:n.context},t.__v),n.v)}function er(t,n){var r=e.O($n,{__v:t,h:n});return r.containerInfo=n,r}(Xn.prototype=new e.C).__a=function(e){var t=this,n=Yn(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Zn(t,e,r)):i()};n?n(a):a()}},Xn.prototype.render=function(t){this.i=null,this.l=new Map;var n=e.w(t.children);t.revealOrder&&t.revealOrder[0]===`b`&&n.reverse();for(var r=n.length;r--;)this.l.set(n[r],this.i=[1,0,this.i]);return t.children},Xn.prototype.componentDidUpdate=Xn.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Zn(e,n,t)})};var tr=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,nr=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,rr=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ir=/[A-Z0-9]/g,ar=typeof document<`u`,or=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};e.C.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(t){Object.defineProperty(e.C.prototype,t,{configurable:!0,get:function(){return this[`UNSAFE_`+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var sr=e.k.event;e.k.event=function(e){return sr&&(e=sr(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var cr={configurable:!0,get:function(){return this.class}},lr=e.k.vnode;e.k.vnode=function(t){typeof t.type==`string`&&function(t){var n=t.props,r=t.type,i={},a=r.indexOf(`-`)==-1;for(var o in n){var s=n[o];if(!(o===`value`&&`defaultValue`in n&&s==null||ar&&o===`children`&&r===`noscript`||o===`class`||o===`className`)){var c=o.toLowerCase();o===`defaultValue`&&`value`in n&&n.value==null?o=`value`:o===`download`&&!0===s?s=``:c===`translate`&&s===`no`?s=!1:c[0]===`o`&&c[1]===`n`?c===`ondoubleclick`?o=`ondblclick`:c!==`onchange`||r!==`input`&&r!==`textarea`||or(n.type)?c===`onfocus`?o=`onfocusin`:c===`onblur`?o=`onfocusout`:rr.test(o)&&(o=c):c=o=`oninput`:a&&nr.test(o)?o=o.replace(ir,`-$&`).toLowerCase():s===null&&(s=void 0),c===`oninput`&&i[o=c]&&(o=`oninputCapture`),i[o]=s}}r==`select`&&(i.multiple&&Array.isArray(i.value)&&(i.value=e.w(n.children).forEach(function(e){e.props.selected=i.value.indexOf(e.props.value)!=-1})),i.defaultValue!=null&&(i.value=e.w(n.children).forEach(function(e){e.props.selected=i.multiple?i.defaultValue.indexOf(e.props.value)!=-1:i.defaultValue==e.props.value}))),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,"className",cr)):n.className&&(i.class=i.className=n.className),t.props=i}(t),t.$$typeof=tr,lr&&lr(t)};var ur=e.k.__r;e.k.__r=function(e){ur&&ur(e),e.__c};var dr=e.k.diffed;e.k.diffed=function(e){dr&&dr(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};var fr=`.leadbot-widget`,pr=6,mr=8,hr=32;function gr(t){let{isOpen:n,onRequestClose:r,remeasureKey:i,minWidth:a=0}=t,o=e.o(null),s=e.o(null),c=e.o(null),l=e.o(null),[u,d]=e.l(null),[f,p]=e.l(null),m=()=>{let e=s.current,t=c.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,o=Math.min(Math.max(n.width,a),r-16),u=Math.min(Math.max(n.left,mr),Math.max(mr,r-o-mr)),f=`${o}px`;t.style.width!==f&&(t.style.width=f);let p=t.offsetHeight,m=i-n.bottom-pr-mr,h=n.top-pr-mr,g=p<=m,_=p<=h,v=l.current;v?v===`below`&&p>m+hr&&_&&h>m+hr?v=`above`:v===`above`&&!_&&p<=m+hr&&(v=`below`):v=!g&&_&&h>m?`above`:`below`,l.current=v;let y=v===`above`,b=y?Math.max(mr,n.top-pr-p):Math.min(n.bottom+pr,Math.max(mr,i-p-mr));d(e=>e&&e.top===b&&e.left===u&&e.width===o&&e.above===y?e:{top:b,left:u,width:o,above:y})};return e.c(()=>{if(!n){l.current=null,d(null),p(null);return}p(s.current?.closest(fr)??o.current??null)},[n]),e.c(()=>{!n||!f||m()},[n,f,i]),e.d(()=>{if(!n)return;let e=s.current?.getRootNode(),t=e=>{let t=e.composedPath();o.current&&t.includes(o.current)||c.current&&t.includes(c.current)||r()},i=()=>m();document.addEventListener(`pointerdown`,t,!0),window.addEventListener(`resize`,i),window.addEventListener(`scroll`,i,!0);let a=e instanceof ShadowRoot?e:null;a?.addEventListener(`scroll`,i,!0);let l=requestAnimationFrame(function e(){m(),l=requestAnimationFrame(e)});return()=>{cancelAnimationFrame(l),document.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`resize`,i),window.removeEventListener(`scroll`,i,!0),a?.removeEventListener(`scroll`,i,!0)}},[n]),{wrapperRef:o,anchorRef:s,panelRef:c,panelPos:u,portalTarget:f}}var _r=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}))?$/,vr=e=>String(e).padStart(2,`0`),yr=e=>`${e.getFullYear()}-${vr(e.getMonth()+1)}-${vr(e.getDate())}`;function br(e){let t=e?.match(_r);if(!t)return null;let[,n,r,i,a,o]=t,s=new Date(Number(n),Number(r)-1,Number(i),Number(a??12),Number(o??0));return isNaN(s.getTime())?null:s}function xr(e){try{let t=new Intl.Locale(e),n=t.weekInfo??t.getWeekInfo?.();if(n?.firstDay)return n.firstDay%7}catch{}return 1}function Sr(e,t){let n=new Intl.DateTimeFormat(e,{weekday:`short`});return Array.from({length:7},(e,r)=>n.format(new Date(2024,0,7+(t+r)%7)))}var Cr=260,wr=20,Tr=e.t(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[e.t(`rect`,{x:`4`,y:`5.5`,width:`16`,height:`15`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`}),e.t(`path`,{d:`M8 3.5v3M16 3.5v3M4 10.5h16`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`})]}),Er=t=>e.t(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,style:t?void 0:{transform:`scaleX(-1)`},"aria-hidden":`true`,children:e.t(`path`,{d:`M6 3l5 5-5 5`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})});function Dr(t){let{field:n,locale:r,t:i,prefillValue:a,error:o,onEdit:s}=t,c=e.s(()=>br(a),[a]),[l,u]=e.l(c),[d,f]=e.l(!1),[p,m]=e.l(`days`),[h,g]=e.l(()=>{let e=c??new Date;return{year:e.getFullYear(),month:e.getMonth()}}),[_,v]=e.l(0),y=()=>{m(`days`),f(!0)},{wrapperRef:b,anchorRef:x,panelRef:S,panelPos:C,portalTarget:w}=gr({isOpen:d,onRequestClose:()=>f(!1),remeasureKey:`${h.year}-${h.month}-${p}-${_}`,minWidth:Cr}),T=e.s(()=>xr(r),[r]),E=e.s(()=>Sr(r,T),[r,T]),D=e.s(()=>new Intl.DateTimeFormat(r,{month:`long`,year:`numeric`}),[r]),O=e.s(()=>new Intl.DateTimeFormat(r,{dateStyle:`medium`}),[r]),k=l?yr(l):``,A=l?O.format(l):``,j=new Date(h.year,h.month+1,0).getDate(),ee=(new Date(h.year,h.month,1).getDay()-T+7)%7,M=42-ee-j,N=new Date,P=e=>{g(({year:t,month:n})=>{let r=new Date(t,n+e,1);return{year:r.getFullYear(),month:r.getMonth()}})},F=()=>{if(p===`years`){m(`days`);return}v(h.year-wr+1),m(`years`)},I=e=>{g(({month:t})=>({year:e,month:t})),m(`days`)},te=e=>{u(new Date(h.year,h.month,e)),f(!1),s?.()},L=()=>{n.required||(u(null),f(!1),s?.(),x.current?.focus())},ne=e=>{if(!n.required&&l&&(e.key===`Backspace`||e.key===`Delete`)){e.preventDefault(),L();return}e.key===`Enter`||e.key===` `||e.key===`ArrowDown`?(e.preventDefault(),y()):e.key===`Escape`&&d&&(e.stopPropagation(),f(!1))},re=n.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null;return e.t(`div`,{className:`leadbot-field leadbot-field-date`,children:[e.t(`label`,{htmlFor:n.uuid,children:[n.label,re]}),e.t(`div`,{className:`leadbot-datepicker${!n.required&&l?` has-clear`:``}`,ref:b,children:[e.t(`span`,{className:`leadbot-datepicker-icon`,"aria-hidden":`true`,children:Tr}),e.t(`input`,{ref:x,type:`text`,className:`leadbot-datepicker-input`,id:n.uuid,"data-field-focus-uuid":n.uuid,inputMode:`none`,autocomplete:`off`,placeholder:n.placeholder||i(`datepicker_placeholder`,`Select a date`),required:n.required,value:A,"aria-haspopup":`dialog`,"aria-expanded":d,"aria-invalid":o?`true`:void 0,"aria-describedby":o?`${n.uuid}-error`:void 0,onBeforeInput:e=>e.preventDefault(),onClick:()=>d?f(!1):y(),onKeyDown:ne}),!n.required&&l&&e.t(`button`,{type:`button`,className:`leadbot-datepicker-clear`,"aria-label":i(`datepicker_clear`,`Clear date`),onClick:L,children:`×`}),e.t(`input`,{type:`hidden`,name:n.name,"data-field-uuid":n.uuid,value:k}),d&&w&&er(e.t(`div`,{ref:S,className:`leadbot-datepicker-panel${C?.above?` is-above`:``}`,role:`dialog`,"aria-label":n.label,style:C?{top:`${C.top}px`,left:`${C.left}px`,width:`${C.width}px`}:{visibility:`hidden`},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),f(!1),x.current?.focus())},children:[e.t(`div`,{className:`leadbot-datepicker-header`,children:[e.t(`button`,{type:`button`,className:`leadbot-datepicker-nav`,"aria-label":p===`years`?i(`datepicker_prev_years`,`Previous years`):i(`datepicker_prev_month`,`Previous month`),onClick:()=>p===`years`?v(e=>e-wr):P(-1),children:Er(!1)}),e.t(`button`,{type:`button`,className:`leadbot-datepicker-month`,"aria-label":i(`datepicker_select_year`,`Select a year`),"aria-expanded":p===`years`,onClick:F,children:p===`years`?`${_} \u{2013} ${_+wr-1}`:D.format(new Date(h.year,h.month))}),e.t(`button`,{type:`button`,className:`leadbot-datepicker-nav`,"aria-label":p===`years`?i(`datepicker_next_years`,`Next years`):i(`datepicker_next_month`,`Next month`),onClick:()=>p===`years`?v(e=>e+wr):P(1),children:Er(!0)})]}),p===`years`?e.t(`div`,{className:`leadbot-datepicker-years`,children:Array.from({length:wr},(t,n)=>{let r=_+n;return e.t(`button`,{type:`button`,className:`leadbot-datepicker-year${r===h.year?` is-selected`:``}`,"aria-pressed":r===h.year,onClick:()=>I(r),children:r},r)})}):e.t(e.E,{children:[e.t(`div`,{className:`leadbot-datepicker-weekdays`,children:E.map(t=>e.t(`span`,{children:t},t))}),e.t(`div`,{className:`leadbot-datepicker-grid`,children:[Array.from({length:ee},(t,n)=>e.t(`span`,{className:`leadbot-datepicker-blank`,"aria-hidden":`true`},`leading-blank-${n}`)),Array.from({length:j},(t,n)=>{let r=n+1,i=!!l&&l.getFullYear()===h.year&&l.getMonth()===h.month&&l.getDate()===r,a=N.getFullYear()===h.year&&N.getMonth()===h.month&&N.getDate()===r;return e.t(`button`,{type:`button`,className:`leadbot-datepicker-day${i?` is-selected`:``}${a?` is-today`:``}`,"aria-pressed":i,"aria-current":a?`date`:void 0,onClick:()=>te(r),children:r},r)}),Array.from({length:M},(t,n)=>e.t(`span`,{className:`leadbot-datepicker-blank`,"aria-hidden":`true`},`trailing-blank-${n}`))]})]})]}),w)]}),o&&e.t(`p`,{className:`leadbot-field-error`,id:`${n.uuid}-error`,role:`alert`,children:o})]},n.uuid)}var Or=/^(\d{2}):(\d{2})/,kr=5,Ar=220,jr=e=>String(e).padStart(2,`0`),Mr=Array.from({length:24},(e,t)=>jr(t)),Nr=Array.from({length:60/kr},(e,t)=>jr(t*kr)),Pr=e.t(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[e.t(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`currentColor`,"stroke-width":`2`}),e.t(`path`,{d:`M12 7.5V12l3 2`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]});function Fr(e){let t=e?.match(Or);if(!t)return{hour:``,minute:``};let n=Number(t[1]),r=Number(t[2]);return n>23||r>59?{hour:``,minute:``}:{hour:jr(n),minute:jr(r-r%kr)}}function Ir(t){let{field:n,t:r,prefillValue:i,error:a,onEdit:o}=t,s=Fr(i),[c,l]=e.l(s.hour),[u,d]=e.l(s.minute),[f,p]=e.l(!1),m=e.o(null),h=e.o(null),{wrapperRef:g,anchorRef:_,panelRef:v,panelPos:y,portalTarget:b}=gr({isOpen:f,onRequestClose:()=>p(!1),minWidth:Ar});e.c(()=>{if(!f)return;let e=(e,t)=>{let n=e?.querySelector(t);n&&e&&(e.scrollTop=n.offsetTop-e.clientHeight/2+n.offsetHeight/2)};e(m.current,`.is-selected`),e(h.current,`.is-selected`)},[f,y?.above]);let x=c!==``&&u!==``?`${c}:${u}`:``,S=x,C=e=>{l(e),u===``&&d(`00`),o?.()},w=e=>{d(e),c===``&&l(`00`),p(!1),o?.(),_.current?.focus()},T=()=>{n.required||(l(``),d(``),p(!1),o?.(),_.current?.focus())},E=e=>{if(!n.required&&x&&(e.key===`Backspace`||e.key===`Delete`)){e.preventDefault(),T();return}e.key===`Enter`||e.key===` `||e.key===`ArrowDown`?(e.preventDefault(),p(!0)):e.key===`Escape`&&f&&(e.stopPropagation(),p(!1))},D=n.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null;return e.t(`div`,{className:`leadbot-field leadbot-field-time`,children:[e.t(`label`,{htmlFor:n.uuid,children:[n.label,D]}),e.t(`div`,{className:`leadbot-timepicker${!n.required&&x?` has-clear`:``}`,ref:g,children:[e.t(`span`,{className:`leadbot-timepicker-icon`,"aria-hidden":`true`,children:Pr}),e.t(`input`,{ref:_,type:`text`,className:`leadbot-timepicker-input`,id:n.uuid,"data-field-focus-uuid":n.uuid,inputMode:`none`,autocomplete:`off`,placeholder:n.placeholder||r(`timepicker_placeholder`,`Select a time`),required:n.required,value:S,"aria-haspopup":`dialog`,"aria-expanded":f,"aria-invalid":a?`true`:void 0,"aria-describedby":a?`${n.uuid}-error`:void 0,onBeforeInput:e=>e.preventDefault(),onClick:()=>p(!f),onKeyDown:E}),!n.required&&x&&e.t(`button`,{type:`button`,className:`leadbot-timepicker-clear`,"aria-label":r(`timepicker_clear`,`Clear time`),onClick:T,children:`×`}),e.t(`input`,{type:`hidden`,name:n.name,"data-field-uuid":n.uuid,value:x}),f&&b&&er(e.t(`div`,{ref:v,className:`leadbot-timepicker-panel${y?.above?` is-above`:``}`,role:`dialog`,"aria-label":n.label,style:y?{top:`${y.top}px`,left:`${y.left}px`,width:`${y.width}px`}:{visibility:`hidden`},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),p(!1),_.current?.focus())},children:e.t(`div`,{className:`leadbot-timepicker-columns`,children:[e.t(`div`,{className:`leadbot-timepicker-column`,role:`listbox`,"aria-label":r(`timepicker_hours_label`,`Hours`),ref:m,children:Mr.map(t=>e.t(`button`,{type:`button`,className:`leadbot-timepicker-option${c===t?` is-selected`:``}`,role:`option`,"aria-selected":c===t,onClick:()=>C(t),children:t},t))}),e.t(`span`,{className:`leadbot-timepicker-columns-separator`,"aria-hidden":`true`,children:`:`}),e.t(`div`,{className:`leadbot-timepicker-column`,role:`listbox`,"aria-label":r(`timepicker_minutes_label`,`Minutes`),ref:h,children:Nr.map(t=>e.t(`button`,{type:`button`,className:`leadbot-timepicker-option${u===t?` is-selected`:``}`,role:`option`,"aria-selected":u===t,onClick:()=>w(t),children:t},t))})]})}),b)]}),a&&e.t(`p`,{className:`leadbot-field-error`,id:`${n.uuid}-error`,role:`alert`,children:a})]},n.uuid)}var Lr={"submit-form":`form_submit`,"submit-callback":`callback_request`,"submit-email":`email_request`,"submit-whatsapp":`whatsapp`};function Rr(e,t){return t?{"aria-invalid":`true`,"aria-describedby":`${e.uuid}-error`}:{}}function zr(t,n){return n?e.t(`p`,{className:`leadbot-field-error`,id:`${t.uuid}-error`,role:`alert`,children:n}):null}function Br(e){e.key===`Enter`&&e.stopPropagation()}function Vr(t,n,r){let i=t.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null,a=t.validation?.min_length,o=t.validation?.max_length,s=a===void 0?void 0:Number(a),c=o===void 0?void 0:Number(o),l=n===`number`;return e.t(`div`,{className:`leadbot-field`,children:[e.t(`label`,{htmlFor:t.uuid,children:[t.label,i]}),e.t(`input`,{type:n,id:t.uuid,name:t.name,"data-field-uuid":t.uuid,placeholder:t.placeholder,required:t.required,defaultValue:r.prefillValue,minLength:l?void 0:a,maxLength:l?void 0:o,min:l?s:void 0,max:l?c:void 0,inputMode:n===`number`?`decimal`:void 0,onInput:r.onEdit,...Rr(t,r.error)}),zr(t,r.error)]},t.uuid)}function Hr(t,n){let r=t.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null;return e.t(`div`,{className:`leadbot-field`,children:[e.t(`label`,{htmlFor:t.uuid,children:[t.label,r]}),e.t(`textarea`,{id:t.uuid,name:t.name,"data-field-uuid":t.uuid,placeholder:t.placeholder,required:t.required,minLength:t.validation?.min_length,maxLength:t.validation?.max_length,onKeyDown:Br,onInput:n.onEdit,...Rr(t,n.error)}),zr(t,n.error)]},t.uuid)}function Ur(t,n){let r=t.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null;return e.t(`div`,{className:`leadbot-field leadbot-field-checkbox`,children:[e.t(`label`,{children:[e.t(`input`,{type:`checkbox`,id:t.uuid,name:t.name,"data-field-uuid":t.uuid,required:t.required,onChange:n.onEdit,...Rr(t,n.error)}),t.label,r]}),zr(t,n.error)]},t.uuid)}function Wr(n,r){let i=n.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null,a=`${n.uuid}-legend`,o=[],s=()=>{if(r.onEdit(),!n.required)return;let e=o.some(e=>e?.checked)?``:r.t(`form_checklist_required`,`Please select at least one option`);o.forEach(t=>{t&&t.setCustomValidity(e)})};return e.t(`fieldset`,{className:`leadbot-field leadbot-field-list`,children:[e.t(`legend`,{className:`leadbot-field-list-label`,id:a,children:[n.label,i]}),e.t(`div`,{className:`leadbot-field-options`,children:(0,t.getFieldOptions)(n).map((t,i)=>e.t(`label`,{className:`leadbot-field-option`,children:[e.t(`input`,{type:`checkbox`,name:`${n.uuid}-checklist`,"data-field-uuid":n.uuid,value:t.value,ref:e=>{e&&!o.includes(e)&&(o.push(e),n.required&&e.setCustomValidity(r.t(`form_checklist_required`,`Please select at least one option`)))},onChange:s,...Rr(n,r.error)}),e.t(`span`,{children:t.label})]},`${n.uuid}-${t.value}-${i}`))}),zr(n,r.error)]},n.uuid)}function Gr(n,r){let i=n.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null,a=`${n.uuid}-legend`;return e.t(`fieldset`,{className:`leadbot-field leadbot-field-list`,children:[e.t(`legend`,{className:`leadbot-field-list-label`,id:a,children:[n.label,i]}),e.t(`div`,{className:`leadbot-field-options`,role:`radiogroup`,"aria-labelledby":a,children:(0,t.getFieldOptions)(n).map((t,i)=>e.t(`label`,{className:`leadbot-field-option`,children:[e.t(`input`,{type:`radio`,name:`${n.uuid}-radiolist`,"data-field-uuid":n.uuid,value:t.value,required:n.required,onChange:r.onEdit,...Rr(n,r.error)}),e.t(`span`,{children:t.label})]},`${n.uuid}-${t.value}-${i}`))}),zr(n,r.error)]},n.uuid)}function Kr(n,r){let i=n.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null,a=r.t(`form_select_placeholder`,`Choose an option`);return e.t(`div`,{className:`leadbot-field`,children:[e.t(`label`,{htmlFor:n.uuid,children:[n.label,i]}),e.t(`select`,{id:n.uuid,name:n.name,"data-field-uuid":n.uuid,required:n.required,onChange:r.onEdit,...Rr(n,r.error),children:[e.t(`option`,{value:``,children:a}),(0,t.getFieldOptions)(n).map(t=>e.t(`option`,{value:t.value,children:t.label},t.value))]}),zr(n,r.error)]},n.uuid)}function qr(e,n){let r=(0,t.resolveFieldType)(n);if(r===`checklist`)return Array.from(e.querySelectorAll(`[data-field-uuid="${n.uuid}"]`)).filter(e=>e.checked).map(e=>e.value);if(r===`radiolist`)return e.querySelector(`[data-field-uuid="${n.uuid}"]:checked`)?.value||``;let i=e.querySelector(`[data-field-uuid="${n.uuid}"]`);return i?r===`checkbox`||i.type===`checkbox`?i.checked?`true`:`false`:i.value:``}var Jr={text:(e,t)=>Vr(e,`text`,t),email:(e,t)=>Vr(e,`email`,t),tel:(e,t)=>Vr(e,`tel`,t),number:(e,t)=>Vr(e,`number`,t),date:(t,n)=>e.t(Dr,{field:t,locale:n.locale||`en`,t:n.t,prefillValue:n.prefillValue,error:n.error,onEdit:n.onEdit},t.uuid),time:(t,n)=>e.t(Ir,{field:t,t:n.t,prefillValue:n.prefillValue,error:n.error,onEdit:n.onEdit},t.uuid),textarea:(e,t)=>Hr(e,t),checkbox:(e,t)=>Ur(e,t),checklist:(e,t)=>Wr(e,t),radiolist:(e,t)=>Gr(e,t),select:(e,t)=>Kr(e,t)};function Yr(e,n){let r=(0,t.resolveFieldType)(e),i=r?Jr[r]:null;return!i||!r?(console.warn(`Unsupported field type: ${e.type}`),null):i(e,n)}function Xr(n){let{step:r,config:i,isCurrent:a,onOptionSelect:o,formConfig:s}=n,c=Ht(i),l=e.p(Kt),[u,d]=e.l(!1),[f,p]=e.l(!1),[m,h]=e.l(null),[g,_]=e.l({}),v=e.o(null),y=(0,t.resolveLanguage)(i.leadbot?.language),b=r.attributes?.form_schema,x=b?.fields||{},{t:S}=qt(y),C=Object.keys(x).map(e=>({uuid:e,...x[e]})).sort((e,t)=>(e.order||0)-(t.order||0)),w=b?.title||``,T=b?.show_title!==!1&&!!w,E=r.attributes?.button_text||s.defaultButtonText||S(`form_submit_button`,`Submit`),D=r.attributes?.success_message||S(`submit-${s.action}`,`Thank you for your submission!`),O=e=>{_(t=>{if(!(e in t))return t;let n={...t};return delete n[e],Object.keys(n).length===0&&h(null),n})},k=e=>{let t=v.current,n=CSS.escape(e);(t?.querySelector(`[data-field-focus-uuid="${n}"]`)||t?.querySelector(`[data-field-uuid="${n}"]:not([type="hidden"])`))?.focus()};return f?e.t(`div`,{className:`${s.containerClass} leadbot-form-complete`,children:e.t(`div`,{className:`leadbot-success-message`,role:`status`,dangerouslySetInnerHTML:{__html:X(D)}})}):e.t(`div`,{className:s.containerClass,children:e.t(`form`,{className:`leadbot-form-shell`,ref:v,onSubmit:async e=>{if(e.preventDefault(),!a||u||f)return;let i=v.current;if(!i)return;let m={};for(let e of C){let n=qr(i,e);m[e.uuid]=(0,t.resolveFieldType)(e)===`tel`&&typeof n==`string`?(0,t.normalizePhoneInput)(n):n}let g={};for(let e of C){let n=m[e.uuid];(0,t.resolveFieldType)(e)===`tel`&&typeof n==`string`&&n&&!(0,t.isPlausiblePhone)(n)&&(g[e.uuid]=S(`form_invalid_phone`,`Enter a valid phone number (e.g. 0614526333)`))}let y=C.find(e=>g[e.uuid]);if(y){_(g),h(S(`form_fix_fields`,`Please check the highlighted fields`)),k(y.uuid);return}h(null),_({}),d(!0);try{let e=Lr[s.action]||`form_submit`,i=await c.submitUserData(e,r.uuid,m,l?{chat_session_id:l}:void 0);if(i?.success===!1)throw Error(i.error||`Submission failed`);n.analyticsTracker?.trackFormSubmit(r,e,(0,t.buildGaUserData)(C,t.resolveFieldType,e=>m[e.uuid])),p(!0),n.onSubmitted?.(m);let a=r.options?.[0];a?.next_step_uuid&&o(a.next_step_uuid)}catch(e){let t={invalid_phone:[`form_invalid_phone`,`Enter a valid phone number (e.g. 0614526333)`],invalid_email:[`form_invalid_email`,`Enter a valid email address`],required:[`form_field_required`,`This field is required`]},n={};if(Array.isArray(e?.errors))for(let r of e.errors){let e=r?.field_uuid,i=r?.message;if(typeof e==`string`&&typeof i==`string`){let a=t[r?.code];n[e]=a?S(a[0],a[1]):i}}let r=C.find(e=>n[e.uuid]);r?(_(n),h(S(`form_fix_fields`,`Please check the highlighted fields`)),k(r.uuid)):h(S(`form_submit_failed`,`Something went wrong while sending. Please try again.`))}finally{d(!1)}},children:[e.t(`div`,{className:`leadbot-form-scroll`,children:[T&&e.t(`div`,{className:`leadbot-form-title`,dangerouslySetInnerHTML:{__html:X(w)}}),m&&e.t(`div`,{className:`leadbot-form-error`,role:`alert`,children:m}),e.t(`fieldset`,{className:`leadbot-form-fields`,disabled:u,children:C.map(e=>Yr(e,{t:S,prefillValue:n.prefillValues?.[e.uuid],locale:y,error:g[e.uuid],onEdit:()=>O(e.uuid)}))})]}),e.t(`div`,{className:`leadbot-form-actions`,children:e.t(`button`,{type:`submit`,className:`leadbot-submit-btn${u?` leadbot-loading`:``}`,disabled:!a||u,children:E})})]})})}function Zr(t){return e.t(Xr,{...t,formConfig:{action:`submit-callback`,containerClass:`leadbot-callback-form`,defaultButtonText:`Request Callback`}})}function Qr(t){return e.t(Xr,{...t,formConfig:{action:`submit-email`,containerClass:`leadbot-email-request-form`,defaultButtonText:`Submit`}})}function $r(t){return e.t(Xr,{...t,formConfig:{action:`submit-form`,containerClass:`leadbot-form`,defaultButtonText:`Submit`}})}function ei(){return null}var ti=`whatsapp`;function ni(n){let{step:r,config:a,isPending:o,prefillMessage:s,onCompleted:c,onDismissed:l}=n,u=Ht(a),d=e.p(Kt),[f,p]=e.l(null),[m,h]=e.l(null),[g,_]=e.l(null),v=(0,t.resolveLanguage)(a.leadbot?.language),{t:y}=qt(v),b=r.attributes?.sender_name||y(`whatsapp_default_contact`,`Support`),x=r.attributes?.sender_image?.url||null,S=r.attributes?.text||``,C=(0,t.processVariables)(S,v,{name:a.leadbot.default_contact_information?.label,website_name:a.leadbot.domain.display_name,email:a.leadbot.default_contact_information?.email,phonenumber:a.leadbot.default_contact_information?.phone}),T=r.attributes?.sender_number||r.attributes?.phone_number||``,E=Fn(r.attributes?.form_schema?.fields||{}),D=r.attributes?.show_qr_code===!0,{isDesktop:O}=i(),k=D&&O,A=y(`whatsapp_error_submission`,`We could not save your message. You can still continue in WhatsApp.`),j=y(`whatsapp_error_phone_missing`,`WhatsApp is not configured for this step.`),ee=y(`whatsapp_error_redirect`,`WhatsApp could not be opened. Please check your pop-up settings.`),M=async e=>{if(!(!E||!e))try{let t=await u.submitUserData(ti,r.uuid,{[E.uuid]:e},d?{chat_session_id:d}:void 0);if(t?.success===!1)throw Error(t.error||`Submission failed`)}catch(e){console.error(`WhatsApp data submission failed:`,e),p(A)}},N=async()=>{if(!o)return;p(null);let e=(s||``).trim();if(!T.trim()){p(j);return}let i=In(e,(0,t.sanitizeTrackedUrl)(window.location.href)),a=(0,t.createWhatsAppUrl)(T,i);if(!a){p(j);return}if(k){let e=(0,t.createWhatsAppWebUrl)(T,i),n=Ln(a);if(!n||!e){p(ee);return}h({svg:n,webUrl:e})}else window.open(a,`_blank`,`noopener,noreferrer`),_(a);n.analyticsTracker?.trackWhatsAppRedirect(r),await M(e),c(E&&e?{[E.uuid]:e}:{})},P=!m&&!g,F=y(`chatbot_whatsapp_open`,`Open WhatsApp`),I=y(`chatbot_whatsapp_dismiss`,`No thanks, continue chatting here`);return e.t(`div`,{className:`leadbot-chatbot-wa`,children:[P&&e.t(`div`,{className:`leadbot-chatbot-wa-contact`,children:[e.t(Mt,{imageUrl:x,alt:b,variant:`whatsapp`}),e.t(`div`,{className:`leadbot-chatbot-wa-contact-info`,children:[e.t(`span`,{className:`leadbot-chatbot-wa-name`,children:b}),e.t(`span`,{className:`leadbot-chatbot-wa-via`,children:[e.t(`span`,{dangerouslySetInnerHTML:{__html:w.whatsapp}}),`WhatsApp`]})]})]}),P&&C&&e.t(`div`,{className:`leadbot-chatbot-wa-text`,dangerouslySetInnerHTML:{__html:X(C)}}),f&&e.t(`div`,{className:`leadbot-form-error`,children:f}),P&&o&&e.t(`button`,{type:`button`,className:`leadbot-chatbot-wa-open-btn`,onClick:N,children:[e.t(`span`,{dangerouslySetInnerHTML:{__html:w.whatsapp}}),F]}),m&&e.t(`div`,{className:`leadbot-chatbot-wa-qr`,children:[e.t(`div`,{className:`leadbot-chatbot-wa-qr-title`,children:y(`whatsapp_qr_title`,`Open in WhatsApp`)}),e.t(`div`,{className:`leadbot-chatbot-wa-qr-image`,dangerouslySetInnerHTML:{__html:m.svg}}),e.t(`div`,{className:`leadbot-chatbot-wa-qr-label`,children:y(`whatsapp_qr_scan_label`,`Scan the code to continue on your phone, or use WhatsApp Web.`)}),e.t(`a`,{href:m.webUrl,target:`_blank`,rel:`noopener noreferrer`,className:`leadbot-chatbot-wa-link`,children:[e.t(`span`,{dangerouslySetInnerHTML:{__html:w.whatsapp}}),y(`whatsapp_qr_open_web`,`Open WhatsApp Web`)]})]}),g&&e.t(`div`,{className:`leadbot-chatbot-wa-opened`,children:[e.t(`span`,{children:y(`chatbot_whatsapp_opened`,`WhatsApp opened — your message is ready to send.`)}),e.t(`a`,{href:g,target:`_blank`,rel:`noopener noreferrer`,className:`leadbot-chatbot-wa-link`,children:y(`chatbot_whatsapp_reopen`,`Open again`)})]}),P&&o&&e.t(`button`,{type:`button`,className:`leadbot-chatbot-wa-dismiss`,onClick:l,children:I})]})}var ri=8,ii=new Set([`text`,`email`,`tel`,`phone`,`name`]),ai=[`email`,`phone`,`name`],oi=/^[\d\s\-+()]{7,}$/;function si(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={},n=0;for(let[r,i]of Object.entries(e)){if(n>=ri)break;if(typeof i!=`string`)continue;let e=i.trim();!e||e.length>254||(t[r]=e,n++)}return t}function ci(e,t){return e===`email`?t.includes(`@`)&&!/\s/.test(t):e!==`phone`||oi.test(t)}function li(e,t){let n=String(t.type||``).toLowerCase();if(!ii.has(n))return!1;let r=String(t.name||``).toLowerCase();return e===`email`?n===`email`||r.includes(`email`):e===`phone`?n===`tel`||n===`phone`||r.includes(`phone`)||r.includes(`tel`):n===`name`||r.includes(`name`)}function ui(e,t){let n={},r=new Set;for(let i of ai){let a=e[i];if(!a||!ci(i,a))continue;let o=Object.keys(t).find(e=>!r.has(e)&&li(i,t[e]));o&&(r.add(o),n[o]=a)}return n}function di(e){let t=e.attributes?.form_schema?.title;return e.label||t||e.step_type}function fi(t){let{message:n,config:r,onCompleted:i,analyticsTracker:a}=t,o=r.steps?.find(e=>e.uuid===n.step_uuid);if(!o)return console.warn(`ChatToolCard: no step found for tool_call step_uuid "${n.step_uuid}"`),null;let{component:s}=ca(o.step_type),c=o.step_type===`whatsapp`,l=n.status===`pending`,u=n.status===`completed`,d=n.status===`dismissed`;return e.t(`div`,{className:`leadbot-chatbot-message leadbot-chatbot-message-bot leadbot-chatbot-tool-card${u?` leadbot-chatbot-tool-card--completed`:d?` leadbot-chatbot-tool-card--dismissed`:``}${c?` leadbot-chatbot-tool-card--whatsapp`:``}`,children:[e.t(`div`,{className:`leadbot-chatbot-tool-card-header`,children:[e.t(`span`,{className:`leadbot-chatbot-tool-card-icon`,"aria-hidden":`true`,children:e.t(mi,{stepType:o.step_type})}),e.t(`span`,{className:`leadbot-chatbot-tool-card-title`,children:di(o)}),u&&e.t(`span`,{className:`leadbot-chatbot-tool-card-check`,"aria-hidden":`true`,children:e.t(pi,{})})]}),!d&&e.t(`div`,{className:`leadbot-chatbot-tool-card-body`,children:c?e.t(ni,{step:o,config:r,isPending:l,prefillMessage:t.prefillMessage,onCompleted:i,onDismissed:t.onDismissed??(()=>{}),analyticsTracker:a}):e.t(s,{step:o,config:r,isCurrent:l,isFirstStep:!1,onOptionSelect:()=>{},onSubmitted:i,prefillValues:ui(n.args||{},o.attributes?.form_schema?.fields||{}),analyticsTracker:a})})]})}function pi(){return e.t(`svg`,{width:`10`,height:`10`,viewBox:`0 0 16 16`,fill:`none`,children:e.t(`path`,{d:`M3 8.5l3.2 3.2L13 5`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function mi(t){let n={callback_request:`M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z`,email_request:`M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zm18 3-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,whatsapp:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,form_submit:`M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2M9 12h6M9 16h6`},r=n[t.stepType]||n.form_submit;return e.t(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,children:e.t(`path`,{d:r,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}var hi=`__leadbot_`,gi=100,_i=64;function vi(e){return`${hi}session_${e||`default`}`}function yi(e){return`${hi}closed_${e||`default`}`}function bi(e){return`${hi}chat_${e||`default`}_`}function xi(e,t){return`${bi(e)}${t}`}function Si(e,n){(0,t.writeEntry)(vi(e),n.slice(-100))}function Ci(e){let n=(0,t.readEntry)(vi(e));return!Array.isArray(n)||n.length===0||n.length>gi||!n.every(e=>typeof e==`string`&&e.length>0&&e.length<=_i)?null:n}function wi(e,n=e,r){try{let i=vi(n),a=yi(n),o=(0,t.sessionStore)();if(r){o.removeItem(i),o.removeItem(a);for(let t of r)o.removeItem(xi(e,t));return}let s=bi(e);for(let e=o.length-1;e>=0;e--){let t=o.key(e);(t===i||t===a||t?.startsWith(s))&&o.removeItem(t)}}catch{}}var Ti=2e4,Ei=1e3,Di=25,Oi=2e3,ki=50,Ai=5e3,ji=50,Mi=64,Ni=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Pi=new Set([`pending`,`completed`,`dismissed`]);function Fi(e){if(!Array.isArray(e))return;let t=e.filter(e=>!!e&&typeof e==`object`&&typeof e.chunk_id==`number`&&typeof e.filename==`string`&&e.filename.length<=Oi).slice(0,Di).map(e=>({chunk_id:e.chunk_id,filename:e.filename}));return t.length>0?t:void 0}function Ii(e){if(!e||typeof e!=`object`)return;let t=e;if(t.rating!==`positive`&&t.rating!==`negative`)return;let n={rating:t.rating};return typeof t.comment==`string`&&t.comment!==``&&t.comment.length<=1e3&&(n.comment=t.comment),n}function Li(e){if(e.role!==`user`&&e.role!==`assistant`||typeof e.content!=`string`||e.content===``||e.content.length>Ti)return null;let t={role:e.role,content:e.content},n=Fi(e.citations);if(n&&(t.citations=n),e.role===`assistant`&&e.ai===!0){t.ai=!0;let n=Ii(e.feedback);n&&(t.feedback=n)}return t}function Ri(e,t,n){return Array.isArray(e)?e.some(e=>!e||typeof e!=`object`?!1:(e.tool_type||`step`)===`step`&&e.name===t&&e.step_uuid===n):!1}function zi(e){if(typeof e==`string`)return e.length<=Ai?e:void 0;if(!(!Array.isArray(e)||e.length>ji)&&!e.some(e=>typeof e!=`string`||e.length>Ai))return[...e]}function Bi(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={},n=0;for(let[r,i]of Object.entries(e)){if(n>=ki)break;let e=zi(i);e!==void 0&&(t[r]=e,n++)}return t}function Vi(e,t){if(e.role!==`tool`||typeof e.tool!=`string`||!e.tool||typeof e.step_uuid!=`string`||!e.step_uuid||e.step_uuid.length>Mi||typeof e.status!=`string`||!Pi.has(e.status)||!Ri(t,e.tool,e.step_uuid))return null;let n={role:`tool`,tool:e.tool,step_uuid:e.step_uuid,status:e.status,args:si(e.args)};return n.status===`completed`&&(n.result=Bi(e.result)),n}function Hi(e,t){if(!Array.isArray(e))return null;let n=[];for(let r of e.slice(-50)){if(!r||typeof r!=`object`)return null;let e=r,i=e.role===`tool`?Vi(e,t):Li(e);if(!i)return null;n.push(i)}return n}function Ui(e,n,r){let i=(0,t.readEntry)(xi(e,n));if(!i||typeof i!=`object`)return null;let a=i,o=Hi(a.messages,r);return!o||o.length===0?null:{sessionId:typeof a.sessionId==`string`&&Ni.test(a.sessionId)?a.sessionId:null,messages:o}}function Wi(e,n,r,i){if(!r)return;let a=i.filter(e=>e.role===`tool`||e.content!==``).slice(-50);(0,t.writeEntry)(xi(e,n),{sessionId:r,messages:a})}function Gi(e,n){(0,t.removeEntry)(xi(e,n))}function Ki(e,n){let r=e[n];if(!r||r.role===`tool`)return null;let i=-1,a=0;for(let t=0;t<e.length;t++){let r=e[t];(r.role!==`tool`||r.status!==`pending`)&&(a++,t<=n&&i++)}let o=Math.max(0,a-(t.MAX_WIRE_HISTORY+1));return i<o?null:i-o}var qi=2500;function Ji({feedback:n,language:r,onRate:i,onLayoutChange:a}){let[o,s]=e.l(!1),[c,l]=e.l(``),[u,d]=e.l(!1),f=e.o(null);e.d(()=>()=>{f.current&&clearTimeout(f.current)},[]);let p=()=>{d(!0),f.current=setTimeout(()=>{f.current=null,d(!1),a()},qi)},m=e=>{n?.rating!==e&&(i(e),l(``),s(!0),d(!1),a())};return e.t(`div`,{className:`leadbot-chatbot-feedback`,children:[e.t(`div`,{className:`leadbot-chatbot-feedback-buttons`,children:[e.t(`button`,{type:`button`,className:`leadbot-chatbot-feedback-btn${n?.rating===`positive`?` leadbot-chatbot-feedback-btn--selected`:``}`,"aria-label":(0,t.getVariableValue)(`chatbot_feedback_positive`,r),"aria-pressed":n?.rating===`positive`,onClick:()=>m(`positive`),dangerouslySetInnerHTML:{__html:C(`fal fa-thumbs-up`)}}),e.t(`button`,{type:`button`,className:`leadbot-chatbot-feedback-btn${n?.rating===`negative`?` leadbot-chatbot-feedback-btn--selected`:``}`,"aria-label":(0,t.getVariableValue)(`chatbot_feedback_negative`,r),"aria-pressed":n?.rating===`negative`,onClick:()=>m(`negative`),dangerouslySetInnerHTML:{__html:C(`fal fa-thumbs-down`)}})]}),o&&n&&e.t(`form`,{className:`leadbot-chatbot-feedback-comment`,onSubmit:e=>{if(e.preventDefault(),!n)return;let t=c.trim().slice(0,Ei);t&&i(n.rating,t),s(!1),l(``),p(),a()},children:[e.t(`textarea`,{className:`leadbot-chatbot-feedback-textarea`,rows:2,maxLength:1e3,placeholder:(0,t.getVariableValue)(`chatbot_feedback_comment_placeholder`,r),value:c,onInput:e=>l(e.target.value)}),e.t(`div`,{className:`leadbot-chatbot-feedback-comment-actions`,children:[e.t(`button`,{type:`submit`,className:`leadbot-chatbot-feedback-send`,children:(0,t.getVariableValue)(`chatbot_feedback_comment_submit`,r)}),e.t(`button`,{type:`button`,className:`leadbot-chatbot-feedback-skip`,onClick:()=>{s(!1),l(``),a()},children:(0,t.getVariableValue)(`chatbot_feedback_comment_skip`,r)})]})]}),u&&e.t(`div`,{className:`leadbot-chatbot-feedback-thanks`,children:(0,t.getVariableValue)(`chatbot_feedback_thanks`,r)})]})}var Yi=5e3;function Xi(e,t,n){return Array.isArray(e)&&e.find(e=>!e||typeof e!=`object`?!1:(e.tool_type||`step`)===`step`&&e.name===t&&e.step_uuid===n)||null}function Zi(e,t){if(e.status===`dismissed`)return`The visitor dismissed this step without completing it.`;let n=(t.steps?.find(t=>t.uuid===e.step_uuid))?.attributes?.form_schema?.fields||{},r=Object.entries(e.result||{}).map(([e,t])=>{let r=n[e];return`${r?.label||r?.name||e}: ${t}`}).join(`; `);return(r?`The visitor submitted the form. ${r}`:`The visitor submitted the form.`).slice(0,Yi)}function Qi(e,t){let n=[];for(let r of e){if(r.role!==`tool`){n.push({role:r.role,content:r.content});continue}r.status!==`pending`&&n.push({role:`tool_result`,tool:r.tool,status:r.status,content:Zi(r,t)})}return n}function $i(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(t.role===`user`)return t.content}}function ea(e,t){let n=-1;for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`){n=t;break}let r=n===-1?null:e[n],i=r&&r.content!==``&&t.length>0?e.map((e,i)=>i===n?{...r,citations:t}:e):e;return i.filter((e,t)=>e.role!==`assistant`||e.content!==``||!i.slice(t+1).some(e=>e.role===`tool`))}function ta(e,t){let n=e[e.length-1];return n?.role===`assistant`&&n.content===``?[...e.slice(0,-1),{role:`assistant`,content:t}]:[...e,{role:`assistant`,content:t}]}function na(e,t){let n=e[e.length-1];return n?.role===`assistant`?[...e.slice(0,-1),{...n,content:n.content+t,ai:!0}]:[...e,{role:`assistant`,content:t,ai:!0}]}function ra(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.role===`user`)break;if(r.role===`assistant`)return[...e.slice(0,n),{...r,content:t,ai:!0},...e.slice(n+1)]}return[...e,{role:`assistant`,content:t,ai:!0}]}function ia(n){let{step:r,config:i,isCurrent:a}=n,o=Ht(i),s=r.attributes?.sender_name||`AI Assistant`,c=r.attributes?.sender_image?.url||null,l=r.attributes?.initial_message||``,u=(0,t.sanitizeConversationStarters)(r.attributes?.conversation_starters),f=(0,t.resolveLanguage)(i.leadbot?.language),p=(0,t.getVariableValue)(`chatbot_placeholder`,f),m=d(i),[g]=e.l(()=>Ui(m,r.uuid,r.attributes?.tools)),[v,b]=e.l(()=>g?g.messages:l?[{role:`assistant`,content:l}]:[]),[x,S]=e.l(!1),[w,T]=e.l(null),[E,D]=e.l(!1),[O,k]=e.l(!1),A=e.o(null),j=e.o(null),ee=e.o(null),M=e.o(null),N=e.o(g?.sessionId??null),P=e.o(v),F=e.o(!1),I=e.o(!1),te=e.o(null),re=e.o(null);e.d(()=>{E&&M.current?.focus({preventScroll:!0})},[E]);let R=e=>{b(t=>{let n=typeof e==`function`?e(t):e;return P.current=n,n})},ae=e=>{F.current=e,S(e)},oe=()=>(N.current||=(0,t.generateUUID)(),(0,t.setActiveChatSession)(N.current),N.current),se=()=>{setTimeout(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},100)};e.d(()=>{P.current=v},[v]),e.d(()=>{Wi(m,r.uuid,N.current,v)},[m,r.uuid,v]),e.d(()=>{F.current=x},[x]),e.d(()=>()=>{if(!te.current)return;clearTimeout(te.current);let e=re.current;e&&Ui(m,r.uuid,r.attributes?.tools)&&Wi(m,r.uuid,N.current,ta(P.current,e))},[]),e.d(()=>{se()},[v,x,w]);let ce=e.o(null),le=e=>{if(typeof e.tool!=`string`||!e.tool)return;if(typeof e.step_uuid!=`string`||!e.step_uuid){T(`tool`);return}let t=e.step_uuid,n=i.steps?.find(e=>e.uuid===t);if(!n){console.warn(`Chatbot tool_call references unknown step: ${t}`);return}let a=Xi(r.attributes?.tools,e.tool,t);if(!a){console.warn(`Chatbot tool_call references unconfigured step tool: ${e.tool}`);return}if(a.step_type&&a.step_type!==n.step_type){console.warn(`Chatbot tool_call step_type mismatch for step: ${t}`);return}let o={role:`tool`,tool:e.tool,step_uuid:t,status:`pending`,args:si(e.args)};R(e=>[...e.map(e=>e.role===`tool`&&e.step_uuid===t&&e.status===`pending`?{...e,status:`dismissed`}:e),o])},ue=async e=>{let n=o.visitorId;if(!m||!r.uuid)throw Error(`chatbot_error_default`);let a=Qi(e,i),s=new AbortController;ce.current=s;let c=[],l=!1,u=(0,t.streamChat)({url:h(`/client/chat/stream`),domainKey:m,leadbotId:_(i),stepUuid:r.uuid,visitorId:n,chatSessionId:oe(),messages:a,previewToken:y()??void 0,analytics:(0,t.buildAnalytics)(),signal:s.signal});for await(let e of u){if(e.type===`reasoning`){l||(l=!0,T(`thinking`));continue}if(l&&(l=!1,T(`searching`),await new Promise(e=>setTimeout(e,0))),e.type===`token`&&typeof e.content==`string`)T(null),R(t=>na(t,e.content)),await new Promise(e=>setTimeout(e,0));else if(e.type===`correction`&&typeof e.content==`string`)R(t=>ra(t,e.content)),await new Promise(e=>setTimeout(e,0));else if(e.type===`citations`&&Array.isArray(e.citations))c=e.citations;else if(e.type===`tool_call`)le(e),await new Promise(e=>setTimeout(e,0));else if(e.type===`done`){R(e=>ea(e,c));break}else if(e.type===`error`){let n=t.CHAT_ERROR_CODE_MAP[e.error_code]||`chatbot_error_default`;R(e=>{let r=ea(e,[]),i=r[r.length-1];return i?.role===`assistant`&&i.content===``?[...r.slice(0,-1),{...i,content:(0,t.getVariableValue)(n,f)}]:[...r,{role:`assistant`,content:(0,t.getVariableValue)(n,f)}]});break}}},z=async e=>{R([...e,{role:`assistant`,content:``}]),ae(!0),T(`thinking`);try{await ue(e)}catch(e){console.error(`Failed to send chatbot message:`,e);let n=e instanceof Error&&e.message.startsWith(`chatbot_error_`)?e.message:`chatbot_error_default`;R(e=>{let r=ea(e,[]),i=r[r.length-1];return i?.role===`assistant`&&i.content===``?[...r.slice(0,-1),{role:`assistant`,content:(0,t.getVariableValue)(n,f)}]:i?.role===`assistant`?[...r.slice(0,-1),{...i,content:`${i.content}\n\n${(0,t.getVariableValue)(n,f)}`}]:i?.role===`tool`?[...r,{role:`assistant`,content:(0,t.getVariableValue)(n,f)}]:r})}finally{ae(!1),T(null),ce.current=null,I.current&&(I.current=!1,setTimeout(()=>{F.current||z(P.current)},0))}},de=async e=>{await z([...P.current,{role:`user`,content:e}])};e.d(()=>{let e=n.pendingMessage;if(!(e===void 0||!a||F.current)){if(n.onPendingMessageConsumed?.(),e){let t=e.trim().toLowerCase(),n=u.find(e=>e.question.trim().toLowerCase()===t);n?B(n):de(e)}else j.current?.focus({preventScroll:!0})}},[n.pendingMessage,a,x]);let B=e=>{if(!(!a||F.current)){if(e.answer){fe(e.question,e.answer);return}de(e.question)}},fe=(e,n)=>{let a=oe();o.submitChatExchange({step_uuid:r.uuid,chat_session_id:a,messages:Qi([...P.current,{role:`user`,content:e}],i),answer:n}),R(t=>[...t,{role:`user`,content:e},{role:`assistant`,content:``}]),ae(!0),T(`thinking`),re.current=n,te.current=setTimeout(()=>{te.current=null,re.current=null,R(e=>ta(e,n)),ae(!1),T(null)},t.FIXED_ANSWER_TYPING_MS)},V=(e,t)=>{let n=P.current,r=n[e];if(r?.role!==`tool`||r.status!==`pending`)return;let i=n.map((n,r)=>r===e&&n.role===`tool`?{...n,status:`completed`,result:t}:n);if(R(i),F.current){I.current=!0;return}z(i)},H=e=>{R(t=>t.map((t,n)=>n===e&&t.role===`tool`&&t.status===`pending`?{...t,status:`dismissed`}:t))},pe=(e,t,n)=>{let i=N.current;if(!i)return;let a=P.current,s=a[e];if(s?.role!==`assistant`)return;let c=Ki(a,e);c!==null&&(R(r=>r.map((r,i)=>i===e&&r.role===`assistant`?{...r,feedback:{rating:t,...n?{comment:n}:{}}}:r)),o.submitChatFeedback({step_uuid:r.uuid,chat_session_id:i,message_index:c,rating:t,comment:n,message_content:s.content.slice(0,5e3)}))},U=e=>{e.preventDefault();let t=j.current?.value?.trim();!t||!a||x||(j.current.value=``,k(!1),de(t))},me=()=>{k(!!j.current?.value?.trim())},he=e=>{e.key===`Enter`&&!e.shiftKey&&U(e)},ge=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),D(!1),ee.current?.focus({preventScroll:!0}))},_e=()=>{ce.current?.abort(),ce.current=null,N.current=null,I.current=!1,Gi(m,r.uuid),te.current&&=(clearTimeout(te.current),null),ae(!1),T(null),R(l?[{role:`assistant`,content:l}]:[]),D(!1)},ve=v.some(e=>e.role!==`assistant`),ye=u.length>0&&!ve&&!x,be=v[v.length-1],xe=x&&w!==null&&be?.role===`assistant`&&be.content!==``;return e.t(`div`,{className:`leadbot-chatbot-interface`,children:[e.t(`div`,{className:`leadbot-chatbot-header`,children:[e.t(Mt,{imageUrl:c,alt:s,variant:`chatbot`}),e.t(`div`,{className:`leadbot-chatbot-header-info`,children:[e.t(`div`,{className:`leadbot-chatbot-title`,children:s}),e.t(`div`,{className:`leadbot-chatbot-status`,children:[e.t(`span`,{className:`leadbot-chatbot-online-dot`}),e.t(`span`,{children:`Online`})]})]}),e.t(`button`,{ref:ee,type:`button`,className:`leadbot-chatbot-menu-btn`,"aria-label":(0,t.getVariableValue)(`chatbot_menu_label`,f),"aria-expanded":E,"aria-haspopup":`menu`,onClick:()=>D(!E),children:e.t(`svg`,{width:`18`,height:`18`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[e.t(`circle`,{cx:`10`,cy:`4`,r:`1.5`,fill:`currentColor`}),e.t(`circle`,{cx:`10`,cy:`10`,r:`1.5`,fill:`currentColor`}),e.t(`circle`,{cx:`10`,cy:`16`,r:`1.5`,fill:`currentColor`})]})}),E&&e.t(`div`,{className:`leadbot-chatbot-menu`,role:`menu`,onKeyDown:ge,children:e.t(`button`,{ref:M,type:`button`,className:`leadbot-chatbot-menu-item`,role:`menuitem`,onClick:_e,children:[e.t(`span`,{className:`leadbot-chatbot-menu-item-icon`,dangerouslySetInnerHTML:{__html:C(`fal fa-rotate-left`)}}),e.t(`span`,{children:`Reset chat`})]})})]}),e.t(`div`,{className:`leadbot-chatbot-messages`,ref:A,role:`log`,"aria-label":(0,t.getVariableValue)(`chatbot_messages_label`,f),tabIndex:0,children:[v.map((t,r)=>{if(t.role===`user`)return e.t(`div`,{className:`leadbot-chatbot-message leadbot-chatbot-message-user`,children:e.t(`div`,{className:`leadbot-chatbot-message-content`,dangerouslySetInnerHTML:{__html:ne(t.content)}})},r);if(t.role===`tool`)return e.t(Kt.Provider,{value:N.current,children:e.t(fi,{message:t,config:i,analyticsTracker:n.analyticsTracker,onCompleted:e=>V(r,e),onDismissed:()=>H(r),prefillMessage:$i(v,r)})},r);if(x&&t.content===``&&r===v.length-1)return e.t(`div`,{className:`leadbot-chatbot-message leadbot-chatbot-message-bot leadbot-chatbot-message-typing`,children:e.t(oa,{language:f,phase:w||`thinking`})},r);let{html:a,sources:o}=ie(L(t.content),t.citations||[]),s=t.ai===!0&&t.content!==``&&!(x&&r===v.length-1)&&Ki(v,r)!==null;return e.t(`div`,{className:`leadbot-chatbot-message leadbot-chatbot-message-bot`,children:[e.t(`div`,{className:`leadbot-chatbot-message-content`,dangerouslySetInnerHTML:{__html:X(a)}}),o.length>0&&e.t(`div`,{className:`leadbot-chatbot-citations`,children:o.map(t=>{let n=t.url.replace(/^https?:\/\//,``);return e.t(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`leadbot-chatbot-citation-item`,children:[e.t(`span`,{className:`leadbot-chatbot-citation-number`,children:t.index}),e.t(`span`,{className:`leadbot-chatbot-citation-url`,children:n})]},t.index)})}),s&&e.t(Ji,{feedback:t.feedback,language:f,onRate:(e,t)=>pe(r,e,t),onLayoutChange:se})]},r)}),xe&&e.t(`div`,{className:`leadbot-chatbot-message leadbot-chatbot-message-bot leadbot-chatbot-message-typing`,children:e.t(oa,{language:f,phase:w||`thinking`})})]}),ye&&e.t(aa,{starters:u,disabled:!a,onSelect:B}),e.t(Ft,{align:`center`,className:`leadbot-chatbot-branding`,leadbot:i.leadbot,language:f,isChatbot:!0,asLink:!0}),e.t(`div`,{className:`leadbot-chatbot-input`,children:e.t(`div`,{className:`leadbot-chatbot-input-field`,children:[e.t(`input`,{ref:j,type:`text`,placeholder:p,className:`leadbot-chatbot-message-input`,onKeyDown:he,onInput:me,disabled:!a||x}),e.t(`button`,{className:`leadbot-chatbot-send-btn${O&&!x?` leadbot-chatbot-send-btn--active`:``}`,"aria-label":(0,t.getVariableValue)(`chatbot_send_label`,f),onClick:U,disabled:!a||x||!O,children:e.t(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,children:e.t(`path`,{d:`M10 4L10 16M10 4L5 9M10 4L15 9`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]})})]})}function aa({starters:t,disabled:n,onSelect:r}){return e.t(`div`,{className:`leadbot-chatbot-starters`,children:t.map(t=>e.t(`button`,{type:`button`,className:`leadbot-chatbot-starter-btn`,disabled:n,onClick:()=>r(t),children:t.question},t.question))})}function oa({language:n,phase:r}){let i=r===`searching`?(0,t.getVariableValue)(`chatbot_searching`,n):r===`tool`?(0,t.getVariableValue)(`chatbot_using_tool`,n):(0,t.getVariableValue)(`chatbot_thinking`,n);return e.t(`div`,{className:`leadbot-chatbot-thinking`,children:[e.t(`span`,{className:`leadbot-chatbot-typing-dots`,children:[e.t(`span`,{}),e.t(`span`,{}),e.t(`span`,{})]}),e.t(`span`,{className:`leadbot-chatbot-thinking-text`,children:[i,`...`]})]})}var sa={start:{component:zt,autoAdvance:!0},message:{component:Rt,autoAdvance:!0},notification:{component:Bt,autoAdvance:!0},button:{component:Wt,autoAdvance:!1},html_embed:{component:Gt,autoAdvance:!0},whatsapp:{component:zn,autoAdvance:!1},callback_request:{component:Zr,autoAdvance:!1},email_request:{component:Qr,autoAdvance:!1},form_submit:{component:$r,autoAdvance:!1},chatbot:{component:ia,autoAdvance:!1}},ca=e=>sa[e]||(console.warn(`No component found for step type: ${e}`),{component:ei,autoAdvance:!1});function la(t){let{step:n}=t,r=ca(n.step_type).component;return e.t(r,{...t})}function ua(e){let t=e?.attributes?.tools;return Array.isArray(t)?t.map(e=>typeof e?.step_uuid==`string`?e.step_uuid:null).filter(e=>!!e):[]}function da(e){let t=new Set(e.flatMap(e=>[...e.options.map(e=>e.next_step_uuid),...ua(e)])),n=e.filter(e=>!t.has(e.uuid));if(n.length===0&&e.length>0){let t=0;for(let n=1;n<e.length;n++)(e[n].order??1/0)<(e[t].order??1/0)&&(t=n);return[t]}return n.map(t=>e.indexOf(t))}function fa(e,t,n){let r=e[t[n]]?.uuid;if(!r)return null;for(let i=n-1;i>=0;i--){let n=e[t[i]];if(u(n?.options??[]).some(e=>e.next_step_uuid===r))return i}return null}function pa(e,t,n){if(n===void 0||n<0||n>=t.length)return t;let r=n;if(e[t[n]]?.step_type===`button`){let i=fa(e,t,n);for(;r+1<t.length&&e[t[r+1]]?.step_type===`button`&&fa(e,t,r+1)===i;)r++}return t.slice(0,r+1)}function ma(e,t){return(e?.options??[]).some(e=>e.next_step_uuid===t)||ua(e).includes(t)}function ha(e,t,n=[]){let r=new Set(n),i=[t],a=new Set([t]),o=e[t]?.uuid;for(;o;){let t=o,n=e.flatMap((e,n)=>ma(e,t)?[n]:[]),s=n.find(e=>r.has(e))??n[0];if(s===void 0||a.has(s))break;i.unshift(s),a.add(s),o=e[s].uuid}return i}function*ga(e,t){let n=0;for(;n<t.length;){if(e[t[n]]?.step_type!==`button`){n++;continue}let r=n,i=fa(e,t,n);for(n++;n<t.length&&e[t[n]]?.step_type===`button`&&fa(e,t,n)===i;)n++;yield{start:r,end:n,parent:i}}}function _a(e,t){let n=new Set,r=t.map((n,r)=>{let i=e[n],a=new Set([...(i?.options??[]).map(e=>e.next_step_uuid),...ua(i)]);return t.slice(r+1).some(t=>a.has(e[t]?.uuid))}),i=new Set;for(let{start:a,end:o,parent:s}of ga(e,t)){let e=!1;for(let t=a;t<o;t++)e||=r[t];if(e)for(let e=a;e<o;e++)n.add(e);else s!==null&&i.add(s)}return t.forEach((t,a)=>{e[t]?.step_type!==`button`&&r[a]&&!i.has(a)&&n.add(a)}),n}var va=new Set;function ya(e,t){if(e.leadbot?.keep_open_on_navigation!==!0)return null;let n=Ci(t);if(!n)return null;let r=n.map(t=>e.steps.findIndex(e=>e.uuid===t));return r.every(e=>e!==-1)?r:null}function ba({config:n,active:r,sessionScope:i,restoredStepHistory:a,typingIndicator:o=!0,resetRef:s,openIntent:c,clearOpenIntent:l}){let f=d(n),p=n.leadbot?.keep_open_on_navigation===!0,m=n.leadbot?.hide_historical_steps===!0,[h,g]=e.l(a??[]),[_,v]=e.l(!1),y=e.o(null),b=e.o([]),x=e.o(!1),S=(0,t.getTracker)(),{t:C}=qt(n.leadbot?.language),w=e.s(()=>n.steps.map(e=>e.uuid),[n.steps]),T=()=>{for(let e of b.current)window.clearTimeout(e);b.current=[],v(!1)},E=e.f(()=>{T(),g([]),wi(f,i,w)},[f,i,w]);e.d(()=>{if(s)return s.current=E,()=>{s.current=void 0}},[s,E]);let[D,O]=e.l(null);e.d(()=>{p||wi(f,i,w)},[p,f,i,w]),e.d(()=>{p&&(!r||h.length===0||Si(i,h.map(e=>n.steps[e]?.uuid).filter(e=>!!e)))},[n.steps,i,r,p,h]),e.d(()=>{r||T()},[r]),e.d(()=>T,[]);let k=e=>{if(!e)return;let t=ca(e.step_type),n=u(e.options);if(!t?.autoAdvance||n.length===0)return;let r=e.attributes?.timer_next_action_enabled?e.attributes.timer_next_action??0:0,i=()=>{let e=n.map(e=>e.next_step_uuid).filter(e=>!!e);e.length>0&&j(e)};if(r>0){o&&v(!0);let e=window.setTimeout(()=>{v(!1),i()},r);b.current.push(e)}else i()},A=(e,t)=>{let r=!x.current;x.current=!0;try{g(r=>[...pa(n.steps,r,t),...e]),r&&T();for(let t of e)k(n.steps[t])}finally{r&&(x.current=!1)}},j=(e,r)=>{if(!e||Array.isArray(e)&&e.length===0)return;let i=(Array.isArray(e)?e:[e]).map(e=>n.steps.findIndex(t=>t.uuid===e)).filter(e=>e!==-1);if(i.length!==0){if(r!==void 0&&o){v(!0);let e=window.setTimeout(()=>{v(!1),A(i,r)},t.TYPING_INDICATOR_MS);b.current.push(e);return}A(i,r)}};e.d(()=>{if(!r||h.length>0)return;let e=da(n.steps);e.length!==0&&(g(e),k(n.steps[e[0]]))},[n.steps,r,h.length]),e.d(()=>{if(!c||!r||h.length===0)return;l?.();let e=n.steps.findIndex(e=>e.uuid===c.stepUuid);if(e===-1)return;let t=h.lastIndexOf(e),i=t!==-1;n.steps[e].step_type===`chatbot`&&(!i||M(e,t))&&O(c),i||(T(),g(t=>[...t,...ha(n.steps,e,t).filter(e=>!t.includes(e))]),k(n.steps[e]))},[l,n.steps,r,c,h]);let ee=e.o(!1);e.d(()=>{if(!r||ee.current||(ee.current=!0,!a||a.length===0))return;let e=n.steps[a[a.length-1]];if(!e)return;let t=new Set(a.map(e=>n.steps[e]?.uuid));u(e.options).some(e=>e.next_step_uuid&&t.has(e.next_step_uuid))||k(e)},[r]),e.d(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[h,_]);let M=(e,t)=>{let r=n.steps[e],i=new Set(r?.options?.map(e=>e.next_step_uuid)??[]);return!h.slice(t+1).some(e=>i.has(n.steps[e]?.uuid))},N=e.s(()=>m?_a(n.steps,h):va,[m,n.steps,h]),P=e.s(()=>{let e=new Map;for(let{start:t,end:r}of ga(n.steps,h))e.set(t,r);return e},[n.steps,h]),F=(t,r)=>e.t(`div`,{className:`leadbot-step-wrapper leadbot-step-buttons leadbot-step-current`,children:e.t(`div`,{className:`leadbot-options`,children:h.slice(t,r).map((r,i)=>{let a=n.steps[r],o=t+i;return e.t(la,{step:a,config:n,isCurrent:M(r,o),isFirstStep:!1,onOptionSelect:e=>j(e,o),analyticsTracker:S},`${a.uuid}-${o}`)})})},`btn-group-${h[t]}`);return e.t(`div`,{className:`leadbot-steps-container`,ref:y,role:`region`,"aria-label":C(`steps_container_label`,`Conversation`),children:[(()=>{let t=[],r=h.findIndex(e=>n.steps[e]?.step_type!==`start`),i=0;for(;i<h.length;){let a=P.get(i);if(a!==void 0){N.has(i)||t.push(F(i,a)),i=a;continue}let o=n.steps[h[i]];if(!o||N.has(i)){i++;continue}let s=M(h[i],i);t.push(e.t(`div`,{className:`leadbot-step-wrapper ${s?`leadbot-step-current`:``}`,children:e.t(la,{step:o,config:n,isCurrent:s,isFirstStep:i===r,onOptionSelect:e=>j(e,i),analyticsTracker:S,pendingMessage:D?.stepUuid===o.uuid?D.message:void 0,onPendingMessageConsumed:()=>O(null)})},`${o.uuid}-${i}`)),i++}return t})(),_&&e.t(`div`,{className:`leadbot-step-wrapper leadbot-step-current`,children:e.t(`div`,{className:`leadbot-step-typing`,children:e.t(`div`,{className:`leadbot-step-typing-dots`,children:[e.t(`span`,{}),e.t(`span`,{}),e.t(`span`,{})]})})})]})}function xa(e,t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${e}" aria-hidden="true" focusable="false" fill="currentColor">${t}</svg>`}function Sa(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">${e}</svg>`}function Ca(e=``,t=!1){return Sa(`${t?`<path d="M20 3.5H10a2 2 0 0 0-2 2v3" opacity="0.5"/>`:``}<path d="M4 6.5h14a2 2 0 0 1 2 2V15a2 2 0 0 1-2 2H10l-4.5 3.5V17H4a2 2 0 0 1-2-2V8.5a2 2 0 0 1 2-2Z"/>${e}`)}var wa=`<path d="M6.5 10.5h9M6.5 13.5h6"/>`,Ta=`<path d="M8.5 12s.9 1.5 2.5 1.5 2.5-1.5 2.5-1.5"/><circle cx="8.3" cy="10" r="0.6" fill="currentColor" stroke="none"/><circle cx="12.7" cy="10" r="0.6" fill="currentColor" stroke="none"/>`,Ea=`<path d="M9.5 9.5v3"/><circle cx="9.5" cy="14.5" r="0.75" fill="currentColor" stroke="none"/>`;S({"fal fa-paperclip":Sa(`<path d="M16.5 6.5 8.7 14.3a3 3 0 1 0 4.2 4.2l7.4-7.4a5 5 0 1 0-7.1-7.1L5.8 11.4a7 7 0 0 0 9.9 9.9"/>`),"fal fa-paper-plane":Sa(`<path d="M21 3 3 10.5l7.5 3L13.5 21 21 3Z"/><path d="M10.5 13.5 21 3"/>`),"fal fa-phone":Sa(`<path d="M6.6 10.8c1.4 2.8 3.8 5.2 6.6 6.6l2.2-2.2c.3-.3.7-.4 1.1-.3 1.2.4 2.5.6 3.8.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1C10.9 21 3 13.1 3 3.7c0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.6.6 3.8.1.4 0 .8-.3 1.1L6.6 10.8Z"/>`),"fal fa-envelope":Sa(`<rect x="3" y="5.5" width="18" height="13" rx="2"/><path d="m3.5 6.5 8.5 7 8.5-7"/>`),"fab fa-whatsapp":xa(`0 0 448 512`,`<path d="M380.9 97.1c-41.9-42-97.7-65.1-157-65.1-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480 117.7 449.1c32.4 17.7 68.9 27 106.1 27l.1 0c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3 18.6-68.1-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1s56.2 81.2 56.1 130.5c0 101.8-84.9 184.6-186.6 184.6zM325.1 300.5c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8s-14.3 18-17.6 21.8c-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7 .9-6.9-.5-9.7s-12.5-30.1-17.1-41.2c-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2s-9.7 1.4-14.8 6.9c-5.1 5.6-19.4 19-19.4 46.3s19.9 53.7 22.6 57.4c2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4s4.6-24.1 3.2-26.4c-1.3-2.5-5-3.9-10.5-6.6z"/>`),"fal fa-comment":Ca(),"fal fa-comment-lines":Ca(wa),"fal fa-comment-smile":Ca(Ta),"fal fa-comments":Ca(``,!0),"fal fa-comment-exclamation":Ca(Ea),"fal fa-comment-alt":Ca(),"fal fa-comment-alt-lines":Ca(wa),"fal fa-comment-alt-smile":Ca(Ta),"fal fa-comments-alt":Ca(``,!0),"fal fa-comment-alt-exclamation":Ca(Ea),"fal fa-rotate-left":Sa(`<path d="M4 9.5A8 8 0 1 1 5 15"/><path d="M4 4v5.5h5.5"/>`),"fal fa-thumbs-up":Sa(`<path d="M7 21H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h3m0 11V10m0 11 5.4-.1c1.9 0 3.6-1.1 4.3-2.9l2.1-5.4a1.6 1.6 0 0 0-1.5-2.2h-4.7l.7-4.2a2.1 2.1 0 0 0-3.8-1.6L7 10"/>`),"fal fa-thumbs-down":Sa(`<path d="M17 3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-3M17 3v11m0-11-5.4.1c-1.9 0-3.6 1.1-4.3 2.9l-2.1 5.4a1.6 1.6 0 0 0 1.5 2.2h4.7l-.7 4.2a2.1 2.1 0 0 0 3.8 1.6L17 14"/>`),"fa-kit fa-leadbot":xa(`0 0 448 512`,`<path d="M4 452.4c31.6 31.2 74.2 60.3 120.6 59.5 33-.5 63.7-20.2 69.8-54 8.2-45.2-20.9-89-49.7-121-19-21.1-40.6-40.6-63.7-57.2-13.3-9.5-28.9-19.6-45.4-22.6-13.8-2.5-28.7 1.1-33.7 15.7-4.5 13.2 1.5 28 7.4 39.7 10.1 20.3 25.1 38.5 40.3 55.2 19.5 21.7 40.9 41.7 64.8 58.7 34 24.1 75.4 43 117.9 42.3 32.3-.5 63.9-13.7 82-41.3 19.5-29.8 17.1-68.6 5.6-100.8-18.7-52.4-57.2-94.5-97.1-132.1-19.3-18.2-39.3-35.5-60.5-51.4-14.4-10.8-29.5-21.2-45.8-29.1-17.8-8.6-49.2-20-61.3 3.5-5.2 10.2-3.3 22.6 .1 33 5 14.9 12.9 28.7 21.5 41.7 29.3 44.4 67.1 85.1 106.5 120.6 36.2 32.6 77.8 62 124.8 76.8 30.9 9.8 66.3 12.7 96.1-2.3 26.8-13.5 40.9-40.7 43.3-69.7 3.2-38.7-13.4-77.8-32.8-110.3-29.8-49.9-71.5-92.7-115.4-130.4-33.1-28.3-69.7-56-111.4-70.5-12.2-4.3-25.7-7.3-38.7-6.3-7.3 .5-13.5 5.8-13.5 13.5 0 6.9 6.2 14 13.5 13.5 2.3-.2 4.6-.2 6.9-.1 1.2 .1 2.5 .2 3.7 .3 3.9 .3-1.7-.5 2.3 .3 6.3 1.2 12.5 2.8 18.6 4.9 13.5 4.7 28.2 12.4 42.1 21 42.8 26.4 81 61.2 115.2 97.8 30.3 32.5 59 70.1 73.9 112 2.8 7.8 5.1 15.8 6.7 23.9 1.5 7.6 2.1 11.4 2.2 20.2 .1 3.2 0 6.5-.3 9.7-.1 1.6-.3 3.1-.5 4.6 .4-3.2-.4 2.2-.6 3.1-.6 2.8-1.3 5.7-2.2 8.4-.4 1.3-.9 2.7-1.4 4-.2 .6-1 2.4 .2-.3-.3 .8-.7 1.6-1.1 2.3-1.2 2.4-2.5 4.8-3.9 7.1-.8 1.3-1.7 2.5-2.5 3.7 1.9-2.6-.6 .7-1.3 1.5-1.8 2-3.7 3.7-5.6 5.5-.5 .4-1 .8-1.5 1.3-1.4 1.2 1.9-1.4 .4-.3-1.2 .9-2.4 1.7-3.7 2.6-2.3 1.5-4.6 2.8-7.1 4-.9 .4-4.3 1.8-1.5 .7-1.6 .6-3.3 1.3-5 1.8-2.8 .9-5.6 1.6-8.5 2.2-1.5 .3-3 .6-4.5 .8-2.6 .4-.3 .1 .2 0-1.2 .1-2.3 .3-3.5 .4-15.7 1.3-26.9-.2-41.2-3.9-18.2-4.6-34.7-11.7-51.1-20.7-44.9-24.6-82.4-59.8-117.2-97-26.6-28.5-53.8-59.1-71.2-94.3-.7-1.4-1.3-2.7-2-4.1-1.6-3.4 0 .3-.7-1.7-1-2.7-2-5.3-2.8-8-.6-2.1-.9-4.2-1.5-6.3-.6-2.1 0 3.4 0 0 0-1-.1-2-.1-2.9 0-.6 .3-3.8-.1-.9-.3 2.8 .1 0 .2-.6 .2-.9 1.4-2.7 .1-.5-2.1 3.5 2.2-2.8-.3 .5-1.6 2.2-.2 .3 .3-.1 .3-.3-3.3 2.2-.9 .8 2.3-1.4-.9 .4-1 .3 .3 .1 1.8-.6 2.3-.6 1.5-.2-3.8-.1-.8 .1 .8 .1 1.7-.1 2.5 0 .9 0 1.8 .2 2.7 .2-4.5-.1-.5 0 .8 .3 2.2 .5 4.4 1.1 6.6 1.8 1.2 .4 2.4 .8 3.6 1.3 .6 .2 1.2 .5 1.9 .7 2.7 1-2.3-1.1 .6 .3 13.8 6.1 26.6 14.1 39 22.8 18 12.6 34.9 26.7 51.2 41.3 20.9 18.7 41.4 38.2 59.7 59.6 15.2 17.8 28.7 37.1 39 58.1 4.1 8.3 7.4 16.8 10.1 25.7 2.2 7.6 4.1 16.4 4.6 22.2 1.5 15.4 .7 25.3-4.9 39.4 1-2.6-.6 1.3-1 2-1.3 2.7-2.8 5.3-4.5 7.8-.5 .8-3.7 5-1.8 2.7-1.9 2.3-3.8 4.5-6 6.6-1.1 1-2.2 2-3.3 3-.6 .5-1.1 1-1.7 1.4 1.5-1.2 .6-.4-.4 .3-2.5 1.7-5 3.4-7.7 4.8-1.3 .7-2.7 1.4-4.1 2.1-.7 .3-1.4 .7-2.1 1-1.4 .6 1.8-.7-.6 .2-6.6 2.4-13.3 4.2-20.2 5.2 2.5-.4-2 .2-2.8 .3-1.8 .2-3.5 .3-5.3 .3-4.1 .2-8.3 .1-12.4-.2-8.1-.5-13.4-1.4-22.1-3.5-41.9-10.2-78.7-36.2-109.2-65.8-17.1-16.6-33.7-34.5-47.2-54.2-4.8-7-9.1-14.3-12.8-21.9-.4-.7-.7-1.5-1-2.3 1 2.3 .2 .5 0 0-.5-1.4-1-2.7-1.4-4.1-.4-1.2-.7-2.5-1-3.8-.1-.6-.2-1.2-.4-1.8-.7-2.5-.2 2.7 0 .3 .1-.8 .1-2.2-.1-3-.4-1.8-1 3.2 0 .3 1-2.9-1.1 1.8-.3 .5 1.5-2.6-2.1 2-.3 .3 1.8-1.7-3.1 1.9-.3 .3 1.8-1-3.5 1.3-.5 .3 2.7-.9-1.8-.3-.3 0 .9 .2 2.5 .1 3.4 .1-.8 0-2.3-.6 .6 .2 1.2 .3 2.5 .6 3.7 .9 1.4 .4 2.7 .9 4 1.3 .7 .3 1.4 .5 2.1 .8 1.4 .5-1.6-.8 .7 .3 7.6 3.7 14.9 7.9 21.9 12.7 20.2 13.7 38.5 30.6 55.5 48.1 16.7 17.3 31.7 36.4 42 58.2 7 15 10.3 28.7 8.8 44.3-.2 2.2 .4-2.1 0 0-.1 .8-.3 1.6-.4 2.4-.4 1.7-.8 3.4-1.3 5.1-.4 1.5-.9 2.9-1.5 4.3 1.1-2.8-.8 1.6-1.2 2.3-.7 1.3-1.5 2.5-2.3 3.7-.4 .6-.8 1.2-1.2 1.8-1.1 1.6 1.4-1.7 .1-.2-2 2.3-4.1 4.5-6.5 6.4 2.3-1.9-.9 .6-1.7 1.1-1.2 .8-2.5 1.6-3.8 2.3-1.3 .7-2.7 1.4-4 2 2.7-1.2-2.4 .8-3.3 1.1-3.1 .9-6.2 1.7-9.4 2.2 2.6-.4-1.8 .2-2.7 .2-2.2 .2-4.4 .2-6.6 .2-8.7-.1-13-.8-21.3-2.9-8.4-2.2-16.4-5.2-24.1-9-20.3-10-38-23.9-54-39.8-12.4-12.2-31.6 6.8-19.2 19.1l0 0z"/>`),"fa-kit fa-default-avatar":xa(`0 0 448 512`,`<path d="M113.2 84.6c44.7 1.1 83-22.9 123.1-39.1 10.5-4.5 21.5-7.8 32.8-9.9 5.2-.8 10.4-1.1 15.6-1 4.5 0 9 .4 13.5 1.1 8.6 1.3 16.7 4.7 23.6 10.1S334 58.2 337.3 66.3c-.7-1.6 0 .4 .2 .6 .5 1.7 1.2 3.4 1.7 5s1.2 4.3 1.6 6.5c1 4.7 1.5 9.5 1.6 14.3 .1 5.1-.1 10.2-.6 15.3-.2 2.1-.5 4.1-.9 6.2-.5 2.7-1.1 5.4-1.7 8-.6 2.2-.5 4.4 0 6.6s1.7 4.1 3.3 5.7 3.5 2.7 5.7 3.3 4.4 .6 6.6 0c1.1-.4 2.3-.6 3.5-.9l3.6-.7 2.3-.4c-3.1 .3 3-.5 0 0 4.3-.5 8.7-.6 13-.4l3 .2c3.6 .3-2.2-.5 .9 0 2.5 .4 5 1 7.4 1.7 1.2 .4 2.3 .9 3.5 1.2s-2.8-1.4-.4 0c.5 .3 1.1 .5 1.5 .7 1.2 .6 2.3 1.2 3.4 1.9 .8 .5 4.7 3.5 2.1 1.3 2 1.7 3.9 3.6 5.6 5.5 .5 .5 1.8 2.3 0 0 .4 .5 .8 1.1 1.2 1.6 1 1.4 1.9 3 2.7 4.5 .3 .6 .7 1.3 1 2 0 0 1.4 3.2 .7 1.6s.7 2 .7 1.8c.3 .8 .5 1.6 .7 2.4 1.3 4 2.2 8.1 2.8 12.2 .6 4.7 .7 9.4 .5 14 0 2.2-.2 4.3-.4 6.5s0 1.3 0 .7c0 1.3-.4 2.5-.7 3.9-.8 4-1.8 7.9-3.1 11.7-.5 1.6-1.3 3.1-1.7 4.7s1.3-2.7 0-.2c-.4 .7-.7 1.4-1 2.2-1.2 2.5-2.5 5-4.1 7.3-1.7 3-2.2 6.5-1.3 9.8s3 6.1 6 7.9 6.5 2.2 9.8 1.3 6.1-3 7.9-6c5.6-8.6 9.6-18.1 11.7-28.1 5-19.9 3.8-40.9-3.4-60.1-5.4-14.6-16.2-26.6-30.3-33.3-11.1-4.9-23.1-7-35.2-6.1-7 .3-13.9 1.4-20.6 3.3l15.6 15.6c10.1-41.3 2.3-92.2-40.4-111.7-22.9-10.4-49.8-9.9-73.6-3.3-22.1 6.1-42.7 16.8-63.5 26.2-22.6 10.2-47.6 19.6-73.1 18.9-16.4-.4-16.4 25 0 25.4l0 0zM213.3 329.4c-2 1.1-3.9 2-6.1 3l-1.4 .6 .5-.2-2.7 1c-2.1 .8-4.3 1.4-6.6 1.8 3.1-.5 0 0-.5-.2 2.3 .7-.5-1 0 .2l2.5 3.2c0 .6 .2 .4 0-.4 .3-1.8 .3-3.7 0-5.6 0-7 .2-14 .3-20.9 .4-26.6 .8-53.1 1.1-79.7 0-16.4-25.2-16.4-25.4 0-.4 31.3-.8 62.6-1.3 93.8 0 8.3-1.5 17.8 3.2 25.1 2.6 3.4 6 6.2 9.9 7.8s8.3 2.3 12.5 1.7c9.5-1.3 18.6-4.5 26.8-9.4 14.4-7.8 1.5-29.9-12.8-21.9l0 .1zm-77-53.7c16.4 0 16.4-25.4 0-25.4s-16.4 25.4 0 25.4zm111.9-1.1l1.5 0c3.4-.2 6.6-1.6 9-3.9 2.3-2.4 3.7-5.6 3.9-9l-.4-3.4c-.6-2.1-1.7-4-3.3-5.6l-2.6-2c-1.9-1.1-4.2-1.8-6.4-1.8l-1.5 0c-1.7-.1-3.4 .3-4.9 1.1-1.6 .5-3 1.4-4.1 2.7-2.3 2.5-3.6 5.6-3.7 9l.5 3.4c.6 2.1 1.7 4 3.2 5.6l2.6 2c1.9 1.2 4.2 1.7 6.4 1.7l-.2 .2zM72.9 6.9c-32.5 35.6-63.1 79.6-65.6 129.4-1.1 21.8 4.3 45.5 17.5 63.2 11.2 14.2 27.3 23.7 45.2 26.6 3.2 .8 6.7 .3 9.6-1.3s5.1-4.4 6.1-7.5c.9-3.3 .4-6.7-1.3-9.6s-4.4-5.1-7.6-6c-12-1.6-23.1-7.4-31.3-16.4-1.4-1.6 2.3 3.2 .8 1.1-.4-.5-.7-1.1-1.1-1.6-.9-1.3-1.7-2.5-2.5-3.9s-1.8-3.2-2.7-4.8c-.5-.9-.9-1.9-1.4-2.9s-.4-.9-.6-1.4c-.8-1.6 1.2 3.1 .4 .8-1.8-4.8-3.3-9.6-4.4-14.6-.3-1.4-.5-2.9-.8-4.4s-.5-.8 0 .5c-.2-.8-.3-1.7-.3-2.5-.3-3.2-.5-6.5-.5-9.8s0-7.1 .5-10.7c0-1 .2-2.1 .4-3.1-.2 2.2-.2 1.1 0-.3 .3-2.1 .7-4.1 1.1-6.2 .9-4.3 2-8.4 3.3-12.6 .7-2.2 1.4-4.3 2.2-6.4 .4-1.1 .8-2.2 1.2-3.2l1.1-2.9c.4-1.1 2.3-5.3 3.5-7.6s2.7-5.6 4.2-8.3c3.2-5.9 6.7-11.7 10.4-17.4 9.1-13.5 19.2-26.3 30.3-38.2 2.3-2.4 3.6-5.6 3.6-9s-1.3-6.6-3.6-9c-2.4-2.4-5.6-3.7-9-3.7s-6.6 1.3-9 3.7l.3 .1zm-14.3 255c1.4 50.6 5.4 103.2 22.2 151.4 10.2 29.1 25.7 56.7 51.1 75.1 18.8 13.6 41.8 19.2 64.7 20.4 42.7 2.2 84.7-12 112.8-45.1 28.9-34 41.1-78.2 46.2-121.8 .6-5.4 1.1-10.8 1.5-16.2l-9.4 12.2c24.8-8.6 49-28.4 48.3-57.1-.1-6.8-1.7-13.5-4.8-19.5s-7.6-11.3-13-15.3c-5.7-3.8-12.2-6.2-18.9-7.2s-13.7-.4-20.2 1.6l16.1 12.3c-1.5-15.2-4.6-30.2-9.1-44.8-4.3-12.5-10.8-24.1-19.2-34.4-12.9-16.5-31.2-27.9-51.7-32.1-36.6-6.8-71.3 9.8-102.2 27.6-28.9 16.6-61.3 38.4-96.4 32.6-3.2-.8-6.7-.3-9.6 1.3s-5.1 4.3-6.1 7.5c-1.7 6.1 2.1 14.5 8.9 15.6 33.5 5.5 64.2-6 93.1-22 13.6-7.5 26.8-15.6 40.6-22.9 11.5-5.9 23.6-10.5 36.2-13.8 2.4-.6 4.8-1.3 7.2-1.7l1.7-.3c2-.4-3.3 .4-1.2 0 1.4 0 2.8-.3 4.2-.4 3-.2 6.1-.2 9.1 0 1.5 0 3.1 .2 4.6 .4l1.6 0s-2.7-.5-1.3-.2l2.9 .5c3.8 .7 7.6 1.7 11.3 3.1 .4 0 3.6 1.4 2.1 .7s1.2 .5 1.6 .7c2.2 1 4.3 2.2 6.3 3.4 1.9 1.1 3.6 2.3 5.4 3.6-1.4-1.2 1.8 1.2 0 0l1.3 1.1c1.1 .9 2.1 1.8 3.1 2.7 4.3 3.9 8.2 8.3 11.5 13.2 1.9 2.9 3.7 5.8 5.4 8.8 1 1.8 1.9 3.5 2.8 5.3 .4 .8 1.4 3.4 .6 1.1 5 13.9 8.3 28.3 9.9 43 1 7.8 7.3 14.7 16.1 12.2 3-1 6.1-1.4 9.3-1s6.1 1.4 8.8 3.1c5.5 4.1 6.8 9.9 6.6 16.8-.3 2.7-1 5.3-2.1 7.8-1.5 3.4-3.7 6.4-6.3 9.1-6 5.9-13.2 10.3-21.2 12.9-2.6 .8-4.9 2.4-6.6 4.6s-2.6 4.8-2.7 7.6c-.4 5.2-.8 10.4-1.4 15.6 0 1.2-.3 2.4-.4 3.6s-.5 3.6 0 1.4c-.4 2.6-.8 5.2-1.2 7.8-1.6 10.2-3.8 20.2-6.6 30.1-4.7 18.7-12.6 36.4-23.5 52.3-1.3 1.9-2.6 3.7-3.9 5.6s.7-.8-.8 1c-1 1.2-1.9 2.3-2.9 3.5-3.1 3.6-6.3 6.9-9.8 10.1-1.6 1.5-3.4 3-5.1 4.4l-1.3 1.1c.4-.3 1.8-1.4 0 0l-3.2 2.3c-3.9 2.7-8 5.2-12.3 7.4-2.1 1.1-4.2 2.1-6.3 3 2-.9-1.3 .5-1.9 .8l-3.9 1.4c-4.9 1.7-9.9 3.1-15 4.1-1.3 .2-2.5 .5-3.9 .7l-2.9 .5c-1.3 0-5.9 .6-8.4 .8-4.5 .3-9 .4-13.5 .4s-9.9-.3-14.8-.9c-.8 0-4.6-.5-2-.2s-1.7-.3-2.6-.4c-2.4-.4-4.8-.9-7.2-1.4-4.9-1.1-9.7-2.6-14.3-4.4l-1.6-.7c-.4 0 2.9 1.3 .5 .2l-3.5-1.7c-2.3-1.1-4.5-2.4-6.7-3.7s-4.6-3-6.8-4.6-.6 0 .5 .4c-.6-.3-1.1-.8-1.5-1.2l-3.2-2.8c-4.4-4-8.5-8.3-12.2-13-1.1-1.4-.8-1.2 0 .2l-1.6-2.1c-1-1.4-1.9-2.7-2.9-4.1-1.9-2.9-3.7-5.7-5.4-8.7s-3.6-6.6-5.2-10.1c-.8-1.6-1.6-3.3-2.3-5-.2-.4-1.3-3.1-.7-1.5s-.6-1.5-.8-2.1c-7-18-12.2-36.6-15.6-55.6-2.3-12-3.9-22.2-5-33.6-1.6-13.8-2.6-27.6-3.4-41.4-.4-7.8-.7-15.6-.9-23.5-.1-3.3-1.4-6.5-3.8-8.9s-5.6-3.7-8.9-3.8c-3.4 0-6.6 1.4-9 3.8s-3.7 5.6-3.8 9l.1 .2z"/>`),"__internal-chevron-right":Sa(`<path d="m9 6 6 6-6 6"/>`)});function Da(e){return!!e?.styling&&Array.isArray(e?.steps)}function Oa({config:t,sessionScope:r,baseColor:i,typingIndicator:a}){let[o]=e.l(()=>Da(t)?ya(t,r):null);return Da(t)?e.t(n,{children:e.t(`div`,{className:`leadbot-flow-conversation`,lang:t.leadbot?.language||void 0,style:{"--leadbot-primary":i||t.styling.base_color||`#2563eb`},children:e.t(ba,{config:t,active:!0,sessionScope:r,restoredStepHistory:o,typingIndicator:a})})}):(console.error(`LeadBot: Invalid config`),null)}function ka(e,t){Aa(e,`--leadbot-flow-max-width`,t?.maxWidth),Aa(e,`--leadbot-flow-align`,t?.align)}function Aa(e,t,n){n?e.style.setProperty(t,n):e.style.removeProperty(t)}function ja(e){try{return(0,t.resolveApiBase)(e)}catch{return null}}var Ma=`leadbot-flow`;function Na(n){let[r,i]=e.l(null),[a,o]=e.l(0);e.d(()=>{if(!n.path)return(0,t.onUrlChange)(()=>o(e=>e+1))},[n.path]);let{domainKey:s,apiHost:c,leadbotId:l,path:u,language:d,previewToken:f,preview:p}=n,h=JSON.stringify([s,c,l,u,d,f,p,a]);e.d(()=>{let t=!0;return e.v({domainKey:s,apiHost:c,leadbotId:l,path:u,language:d,previewToken:f,preview:p}).then(e=>{t&&i({key:h,flow:e??null})}),()=>{t=!1}},[h]);let g=ja(e.S(n));e.d(()=>{m(g)},[g]);let _=r?.key===h?r.flow:null;if(!_)return null;let v=e.S(n),y=`${v.domainKey??`default`}#flow-${v.leadbotId??``}`;return e.O(Oa,{key:`${a}:${v.leadbotId??``}:${n.path??``}`,config:_,sessionScope:y,baseColor:v.baseColor,typingIndicator:n.typingIndicator})}function Pa(t,n={}){t.classList.add(Ma),ka(t,n.layout);let r=e.h(Na,t,n);return{update(e){`layout`in e&&ka(t,e.layout),r.update(e)},destroy(){ka(t,void 0),t.classList.remove(Ma),r.destroy()}}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Pa}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ma}});
82
+ `)}function Ln(e){try{let{data:t,size:n}=Mn(e),r=n+4,i=``;for(let e=0;e<n;e++)for(let r=0;r<n;r++)t[e][r]&&(i+=`M${r+2},${e+2}h1v1h-1z`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${r} ${r}"><rect width="${r}" height="${r}" fill="#fff"/><path d="${i}" fill="#111b21"/></svg>`}catch(e){return console.error(`QR code generation failed:`,e),null}}var Rn=`whatsapp`;function zn(n){let{step:r,config:a,isCurrent:o,onOptionSelect:s}=n,c=Ht(a),l=e.p(Kt),[u,d]=e.l(!1),[f,p]=e.l(null),[m,h]=e.l(null),[g,_]=e.l(null),[v,y]=e.l(null),[b,x]=e.l(!1),S=e.o(null),C=e.o(null),T=e.o(void 0);e.d(()=>()=>clearTimeout(T.current),[]);let E=r.attributes?.show_qr_code===!0,{isDesktop:D}=i(),O=E&&D,k=(0,t.resolveLanguage)(a.leadbot?.language),{t:A}=qt(k),j=r.attributes?.sender_name||A(`whatsapp_default_contact`,`Support`),ee=r.attributes?.sender_image?.url||null,M=r.attributes?.text||``,N=(0,t.processVariables)(M,k,{name:a.leadbot.default_contact_information?.label,website_name:a.leadbot.domain.display_name,email:a.leadbot.default_contact_information?.email,phonenumber:a.leadbot.default_contact_information?.phone}),P=r.attributes?.form_schema?.fields||{},F=Fn(P),I=Pn(P,`phone`),te=r.attributes?.ask_phone_number===!0&&!!I,L=g!==null;e.d(()=>{if(!o)return;let e=C.current?.closest(`.leadbot-steps-container`);e&&(e.scrollTop=e.scrollHeight)},[o,L,b,m,f]);let ne=A(`whatsapp_placeholder`,`Type a message`),re=A(`whatsapp_phone_placeholder`,`Your phone number`),ie=A(`whatsapp_phone_prompt`,`What is your phone number? Then we will continue in WhatsApp.`),R=A(`whatsapp_phone_invalid`,`Please enter a valid phone number.`),ae=A(`whatsapp_status_online`,`Online`),oe=()=>{let e=new Date;return e.getHours().toString().padStart(2,`0`)+`:`+e.getMinutes().toString().padStart(2,`0`)},se=r.attributes?.sender_number||r.attributes?.phone_number||``,ce=A(`whatsapp_error_submission`,`We could not save your message. You can still continue in WhatsApp.`),le=A(`whatsapp_error_phone_missing`,`WhatsApp is not configured for this step.`),ue=(0,t.sanitizeTrackedUrl)(window.location.href),z=async(e,t)=>{if(!F)return null;let i={[F.uuid]:e};t&&I&&(i[I.uuid]=t);let a=await c.submitUserData(Rn,r.uuid,i,l?{chat_session_id:l}:void 0);if(a?.success===!1)throw Error(a.error||`Submission failed`);return n.onSubmitted?.(i),null},de=A(`whatsapp_error_redirect`,`WhatsApp could not be opened. Please check your pop-up settings.`),B=(e,n)=>{let r=In(e,ue,n),i=(0,t.createWhatsAppUrl)(se,r);return i?(window.open(i,`_blank`,`noopener,noreferrer`),!0):!1},fe=()=>{let e=r.options?.[0];e?.next_step_uuid&&s(e.next_step_uuid)},V=(e,t)=>{let n=Ln(e);return n?(h(n),y(t),!0):!1},H=async e=>{if(e.preventDefault(),!o||u||b)return;let i=S.current?.value?.trim();if(!i)return;if(p(null),te&&!L){_(i),x(!0),T.current=setTimeout(()=>x(!1),t.TYPING_INDICATOR_MS),S.current&&(S.current.value=``);return}let a=L?g:i,s=L?(0,t.normalizePhoneInput)(i):void 0;if(s!==void 0&&!(0,t.isPlausiblePhone)(s)){p(R);return}d(!0);try{try{await z(a,s)}catch(e){console.error(`WhatsApp data submission failed:`,e),p(ce)}if(!se||!se.trim()){p(le);return}if(O){let e=In(a,ue,s),i=(0,t.createWhatsAppUrl)(se,e),o=(0,t.createWhatsAppWebUrl)(se,e);if(!i||!o||!V(i,o)){p(de);return}n.analyticsTracker?.trackWhatsAppRedirect(r),S.current&&(S.current.value=``),_(null);return}if(!B(a,s)){p(de);return}n.analyticsTracker?.trackWhatsAppRedirect(r),S.current&&(S.current.value=``),_(null),fe()}catch(e){console.error(`WhatsApp submission failed:`,e),p(ce)}finally{d(!1)}},pe=e.t(Ft,{align:`right`,className:`leadbot-whatsapp-branding`,leadbot:a.leadbot,language:k,asLink:!0}),U=A(`whatsapp_qr_title`,`Open in WhatsApp`),me=A(`whatsapp_qr_scan_label`,`Scan this QR code with your phone to continue on WhatsApp`),he=A(`whatsapp_qr_open_web`,`Open WhatsApp Web`);return e.t(`div`,{className:`leadbot-whatsapp-interface`,ref:C,children:[e.t(`div`,{className:`leadbot-whatsapp-header`,children:e.t(`div`,{className:`leadbot-whatsapp-contact-info`,children:[e.t(Mt,{imageUrl:ee,alt:j,variant:`whatsapp`}),e.t(`div`,{className:`leadbot-whatsapp-contact-details`,children:[e.t(`div`,{className:`leadbot-whatsapp-name`,children:j}),e.t(`div`,{className:`leadbot-whatsapp-status`,children:ae})]})]})}),e.t(`div`,{className:`leadbot-whatsapp-chat`,children:[N&&e.t(`div`,{className:`leadbot-whatsapp-message`,children:[e.t(`div`,{className:`leadbot-whatsapp-message-content`,dangerouslySetInnerHTML:{__html:X(N)}}),e.t(`div`,{className:`leadbot-whatsapp-message-time`,children:[oe(),e.t(`span`,{className:`leadbot-whatsapp-checkmarks`,dangerouslySetInnerHTML:{__html:w.checkDouble}})]})]}),L&&e.t(e.E,{children:[e.t(`div`,{className:`leadbot-whatsapp-message leadbot-whatsapp-message-outgoing`,children:[e.t(`div`,{className:`leadbot-whatsapp-message-content`,children:g}),e.t(`div`,{className:`leadbot-whatsapp-message-time`,children:oe()})]}),b?e.t(`div`,{className:`leadbot-whatsapp-message leadbot-whatsapp-typing`,"aria-hidden":`true`,children:e.t(`span`,{className:`leadbot-whatsapp-typing-dots`,children:[e.t(`span`,{}),e.t(`span`,{}),e.t(`span`,{})]})}):e.t(`div`,{className:`leadbot-whatsapp-message`,children:e.t(`div`,{className:`leadbot-whatsapp-message-content`,children:ie})})]})]}),m&&v?e.t(`div`,{className:`leadbot-whatsapp-qr-card`,children:[e.t(`div`,{className:`leadbot-whatsapp-qr-content`,children:[e.t(`div`,{className:`leadbot-whatsapp-qr-title`,children:U}),e.t(`div`,{className:`leadbot-whatsapp-qr-image`,dangerouslySetInnerHTML:{__html:m}}),e.t(`div`,{className:`leadbot-whatsapp-qr-label`,children:me})]}),e.t(`div`,{className:`leadbot-whatsapp-qr-actions`,children:e.t(`a`,{href:v,target:`_blank`,rel:`noopener noreferrer`,className:`leadbot-whatsapp-qr-btn leadbot-whatsapp-qr-btn-web`,children:[e.t(`span`,{className:`leadbot-whatsapp-qr-btn-icon`,dangerouslySetInnerHTML:{__html:w.whatsapp}}),he]})}),pe]}):e.t(`div`,{className:`leadbot-whatsapp-input-container`,children:[f&&e.t(`div`,{className:`leadbot-form-error`,children:f}),e.t(`form`,{onSubmit:H,children:e.t(`div`,{className:`leadbot-whatsapp-input-bar`,children:[e.t(`input`,{ref:S,type:L?`tel`:`text`,className:`leadbot-whatsapp-message-field`,placeholder:L?re:ne,"aria-label":L?re:ne,autoComplete:L?`tel`:`off`,required:!0,disabled:!o||u||b}),e.t(`button`,{type:`submit`,className:`leadbot-whatsapp-send-btn${u?` leadbot-whatsapp-send-disabled`:``}`,"aria-label":A(`whatsapp_send_label`,`Send message`),disabled:!o||u,children:e.t(`span`,{dangerouslySetInnerHTML:{__html:w.send}})})]})}),pe]})]})}function Bn(e,t){for(var n in t)e[n]=t[n];return e}function Vn(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function Hn(e,t){this.props=e,this.context=t}(Hn.prototype=new e.C).isPureReactComponent=!0,Hn.prototype.shouldComponentUpdate=function(e,t){return Vn(this.props,e)||Vn(this.state,t)};var Un=e.k.__b;e.k.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Un&&Un(e)},typeof Symbol<`u`&&Symbol.for;var Wn=e.k.__e;e.k.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k||[]),i.__c(e,t)}Wn(e,t,n,r)};var Gn=e.k.unmount;function Kn(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=Bn({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Kn(e,t,n)})),e}function qn(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return qn(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Jn(){this.__u=0,this.o=null,this.__b=null}function Yn(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function Xn(){this.i=null,this.l=null}e.k.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Gn&&Gn(e)},(Jn.prototype=new e.C).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=Yn(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=qn(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},Jn.prototype.componentWillUnmount=function(){this.o=[]},Jn.prototype.render=function(t,n){if(this.__b){if(this.__v.__k){var r=document.createElement(`div`),i=this.__v.__k[0].__c;this.__v.__k[0]=Kn(this.__b,r,i.__O=i.__P)}this.__b=null}var a=n.__a&&e.O(e.E,null,t.fallback);return a&&(a.__u&=-33),[e.O(e.E,null,n.__a?null:t.children),a]};var Zn=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function Qn(e){return this.getChildContext=function(){return e.context},e.children}function $n(t){var n=this,r=t.h;if(n.componentWillUnmount=function(){e.T(null,n.v),n.v=null,n.h=null},n.h&&n.h!==r&&n.componentWillUnmount(),!n.v){for(var i=n.__v;i!==null&&!i.__m&&i.__!==null;)i=i.__;n.h=r,n.v={nodeType:1,parentNode:r,childNodes:[],__k:{__m:i.__m},contains:function(){return!0},namespaceURI:r.namespaceURI,insertBefore:function(e,t){this.childNodes.push(e),n.h.insertBefore(e,t)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),n.h.removeChild(e)}}}e.T(e.O(Qn,{context:n.context},t.__v),n.v)}function er(t,n){var r=e.O($n,{__v:t,h:n});return r.containerInfo=n,r}(Xn.prototype=new e.C).__a=function(e){var t=this,n=Yn(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Zn(t,e,r)):i()};n?n(a):a()}},Xn.prototype.render=function(t){this.i=null,this.l=new Map;var n=e.w(t.children);t.revealOrder&&t.revealOrder[0]===`b`&&n.reverse();for(var r=n.length;r--;)this.l.set(n[r],this.i=[1,0,this.i]);return t.children},Xn.prototype.componentDidUpdate=Xn.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Zn(e,n,t)})};var tr=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,nr=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,rr=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ir=/[A-Z0-9]/g,ar=typeof document<`u`,or=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};e.C.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(t){Object.defineProperty(e.C.prototype,t,{configurable:!0,get:function(){return this[`UNSAFE_`+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var sr=e.k.event;e.k.event=function(e){return sr&&(e=sr(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var cr={configurable:!0,get:function(){return this.class}},lr=e.k.vnode;e.k.vnode=function(t){typeof t.type==`string`&&function(t){var n=t.props,r=t.type,i={},a=r.indexOf(`-`)==-1;for(var o in n){var s=n[o];if(!(o===`value`&&`defaultValue`in n&&s==null||ar&&o===`children`&&r===`noscript`||o===`class`||o===`className`)){var c=o.toLowerCase();o===`defaultValue`&&`value`in n&&n.value==null?o=`value`:o===`download`&&!0===s?s=``:c===`translate`&&s===`no`?s=!1:c[0]===`o`&&c[1]===`n`?c===`ondoubleclick`?o=`ondblclick`:c!==`onchange`||r!==`input`&&r!==`textarea`||or(n.type)?c===`onfocus`?o=`onfocusin`:c===`onblur`?o=`onfocusout`:rr.test(o)&&(o=c):c=o=`oninput`:a&&nr.test(o)?o=o.replace(ir,`-$&`).toLowerCase():s===null&&(s=void 0),c===`oninput`&&i[o=c]&&(o=`oninputCapture`),i[o]=s}}r==`select`&&(i.multiple&&Array.isArray(i.value)&&(i.value=e.w(n.children).forEach(function(e){e.props.selected=i.value.indexOf(e.props.value)!=-1})),i.defaultValue!=null&&(i.value=e.w(n.children).forEach(function(e){e.props.selected=i.multiple?i.defaultValue.indexOf(e.props.value)!=-1:i.defaultValue==e.props.value}))),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,"className",cr)):n.className&&(i.class=i.className=n.className),t.props=i}(t),t.$$typeof=tr,lr&&lr(t)};var ur=e.k.__r;e.k.__r=function(e){ur&&ur(e),e.__c};var dr=e.k.diffed;e.k.diffed=function(e){dr&&dr(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};var fr=`.leadbot-widget`,pr=6,mr=8,hr=32;function gr(t){let{isOpen:n,onRequestClose:r,remeasureKey:i,minWidth:a=0}=t,o=e.o(null),s=e.o(null),c=e.o(null),l=e.o(null),[u,d]=e.l(null),[f,p]=e.l(null),m=()=>{let e=s.current,t=c.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,o=Math.min(Math.max(n.width,a),r-16),u=Math.min(Math.max(n.left,mr),Math.max(mr,r-o-mr)),f=`${o}px`;t.style.width!==f&&(t.style.width=f);let p=t.offsetHeight,m=i-n.bottom-pr-mr,h=n.top-pr-mr,g=p<=m,_=p<=h,v=l.current;v?v===`below`&&p>m+hr&&_&&h>m+hr?v=`above`:v===`above`&&!_&&p<=m+hr&&(v=`below`):v=!g&&_&&h>m?`above`:`below`,l.current=v;let y=v===`above`,b=y?Math.max(mr,n.top-pr-p):Math.min(n.bottom+pr,Math.max(mr,i-p-mr));d(e=>e&&e.top===b&&e.left===u&&e.width===o&&e.above===y?e:{top:b,left:u,width:o,above:y})};return e.c(()=>{if(!n){l.current=null,d(null),p(null);return}p(s.current?.closest(fr)??o.current??null)},[n]),e.c(()=>{!n||!f||m()},[n,f,i]),e.d(()=>{if(!n)return;let e=s.current?.getRootNode(),t=e=>{let t=e.composedPath();o.current&&t.includes(o.current)||c.current&&t.includes(c.current)||r()},i=()=>m();document.addEventListener(`pointerdown`,t,!0),window.addEventListener(`resize`,i),window.addEventListener(`scroll`,i,!0);let a=e instanceof ShadowRoot?e:null;a?.addEventListener(`scroll`,i,!0);let l=requestAnimationFrame(function e(){m(),l=requestAnimationFrame(e)});return()=>{cancelAnimationFrame(l),document.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`resize`,i),window.removeEventListener(`scroll`,i,!0),a?.removeEventListener(`scroll`,i,!0)}},[n]),{wrapperRef:o,anchorRef:s,panelRef:c,panelPos:u,portalTarget:f}}var _r=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}))?$/,vr=e=>String(e).padStart(2,`0`),yr=e=>`${e.getFullYear()}-${vr(e.getMonth()+1)}-${vr(e.getDate())}`;function br(e){let t=e?.match(_r);if(!t)return null;let[,n,r,i,a,o]=t,s=new Date(Number(n),Number(r)-1,Number(i),Number(a??12),Number(o??0));return isNaN(s.getTime())?null:s}function xr(e){try{let t=new Intl.Locale(e),n=t.weekInfo??t.getWeekInfo?.();if(n?.firstDay)return n.firstDay%7}catch{}return 1}function Sr(e,t){let n=new Intl.DateTimeFormat(e,{weekday:`short`});return Array.from({length:7},(e,r)=>n.format(new Date(2024,0,7+(t+r)%7)))}var Cr=260,wr=20,Tr=e.t(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[e.t(`rect`,{x:`4`,y:`5.5`,width:`16`,height:`15`,rx:`2`,stroke:`currentColor`,"stroke-width":`2`}),e.t(`path`,{d:`M8 3.5v3M16 3.5v3M4 10.5h16`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`})]}),Er=t=>e.t(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,style:t?void 0:{transform:`scaleX(-1)`},"aria-hidden":`true`,children:e.t(`path`,{d:`M6 3l5 5-5 5`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})});function Dr(t){let{field:n,locale:r,t:i,prefillValue:a,error:o,onEdit:s}=t,c=e.s(()=>br(a),[a]),[l,u]=e.l(c),[d,f]=e.l(!1),[p,m]=e.l(`days`),[h,g]=e.l(()=>{let e=c??new Date;return{year:e.getFullYear(),month:e.getMonth()}}),[_,v]=e.l(0),y=()=>{m(`days`),f(!0)},{wrapperRef:b,anchorRef:x,panelRef:S,panelPos:C,portalTarget:w}=gr({isOpen:d,onRequestClose:()=>f(!1),remeasureKey:`${h.year}-${h.month}-${p}-${_}`,minWidth:Cr}),T=e.s(()=>xr(r),[r]),E=e.s(()=>Sr(r,T),[r,T]),D=e.s(()=>new Intl.DateTimeFormat(r,{month:`long`,year:`numeric`}),[r]),O=e.s(()=>new Intl.DateTimeFormat(r,{dateStyle:`medium`}),[r]),k=l?yr(l):``,A=l?O.format(l):``,j=new Date(h.year,h.month+1,0).getDate(),ee=(new Date(h.year,h.month,1).getDay()-T+7)%7,M=42-ee-j,N=new Date,P=e=>{g(({year:t,month:n})=>{let r=new Date(t,n+e,1);return{year:r.getFullYear(),month:r.getMonth()}})},F=()=>{if(p===`years`){m(`days`);return}v(h.year-wr+1),m(`years`)},I=e=>{g(({month:t})=>({year:e,month:t})),m(`days`)},te=e=>{u(new Date(h.year,h.month,e)),f(!1),s?.()},L=()=>{n.required||(u(null),f(!1),s?.(),x.current?.focus())},ne=e=>{if(!n.required&&l&&(e.key===`Backspace`||e.key===`Delete`)){e.preventDefault(),L();return}e.key===`Enter`||e.key===` `||e.key===`ArrowDown`?(e.preventDefault(),y()):e.key===`Escape`&&d&&(e.stopPropagation(),f(!1))},re=n.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null;return e.t(`div`,{className:`leadbot-field leadbot-field-date`,children:[e.t(`label`,{htmlFor:n.uuid,children:[n.label,re]}),e.t(`div`,{className:`leadbot-datepicker${!n.required&&l?` has-clear`:``}`,ref:b,children:[e.t(`span`,{className:`leadbot-datepicker-icon`,"aria-hidden":`true`,children:Tr}),e.t(`input`,{ref:x,type:`text`,className:`leadbot-datepicker-input`,id:n.uuid,"data-field-focus-uuid":n.uuid,inputMode:`none`,autocomplete:`off`,placeholder:n.placeholder||i(`datepicker_placeholder`,`Select a date`),required:n.required,value:A,"aria-haspopup":`dialog`,"aria-expanded":d,"aria-invalid":o?`true`:void 0,"aria-describedby":o?`${n.uuid}-error`:void 0,onBeforeInput:e=>e.preventDefault(),onClick:()=>d?f(!1):y(),onKeyDown:ne}),!n.required&&l&&e.t(`button`,{type:`button`,className:`leadbot-datepicker-clear`,"aria-label":i(`datepicker_clear`,`Clear date`),onClick:L,children:`×`}),e.t(`input`,{type:`hidden`,name:n.name,"data-field-uuid":n.uuid,value:k}),d&&w&&er(e.t(`div`,{ref:S,className:`leadbot-datepicker-panel${C?.above?` is-above`:``}`,role:`dialog`,"aria-label":n.label,style:C?{top:`${C.top}px`,left:`${C.left}px`,width:`${C.width}px`}:{visibility:`hidden`},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),f(!1),x.current?.focus())},children:[e.t(`div`,{className:`leadbot-datepicker-header`,children:[e.t(`button`,{type:`button`,className:`leadbot-datepicker-nav`,"aria-label":p===`years`?i(`datepicker_prev_years`,`Previous years`):i(`datepicker_prev_month`,`Previous month`),onClick:()=>p===`years`?v(e=>e-wr):P(-1),children:Er(!1)}),e.t(`button`,{type:`button`,className:`leadbot-datepicker-month`,"aria-label":i(`datepicker_select_year`,`Select a year`),"aria-expanded":p===`years`,onClick:F,children:p===`years`?`${_} \u{2013} ${_+wr-1}`:D.format(new Date(h.year,h.month))}),e.t(`button`,{type:`button`,className:`leadbot-datepicker-nav`,"aria-label":p===`years`?i(`datepicker_next_years`,`Next years`):i(`datepicker_next_month`,`Next month`),onClick:()=>p===`years`?v(e=>e+wr):P(1),children:Er(!0)})]}),p===`years`?e.t(`div`,{className:`leadbot-datepicker-years`,children:Array.from({length:wr},(t,n)=>{let r=_+n;return e.t(`button`,{type:`button`,className:`leadbot-datepicker-year${r===h.year?` is-selected`:``}`,"aria-pressed":r===h.year,onClick:()=>I(r),children:r},r)})}):e.t(e.E,{children:[e.t(`div`,{className:`leadbot-datepicker-weekdays`,children:E.map(t=>e.t(`span`,{children:t},t))}),e.t(`div`,{className:`leadbot-datepicker-grid`,children:[Array.from({length:ee},(t,n)=>e.t(`span`,{className:`leadbot-datepicker-blank`,"aria-hidden":`true`},`leading-blank-${n}`)),Array.from({length:j},(t,n)=>{let r=n+1,i=!!l&&l.getFullYear()===h.year&&l.getMonth()===h.month&&l.getDate()===r,a=N.getFullYear()===h.year&&N.getMonth()===h.month&&N.getDate()===r;return e.t(`button`,{type:`button`,className:`leadbot-datepicker-day${i?` is-selected`:``}${a?` is-today`:``}`,"aria-pressed":i,"aria-current":a?`date`:void 0,onClick:()=>te(r),children:r},r)}),Array.from({length:M},(t,n)=>e.t(`span`,{className:`leadbot-datepicker-blank`,"aria-hidden":`true`},`trailing-blank-${n}`))]})]})]}),w)]}),o&&e.t(`p`,{className:`leadbot-field-error`,id:`${n.uuid}-error`,role:`alert`,children:o})]},n.uuid)}var Or=/^(\d{2}):(\d{2})/,kr=5,Ar=220,jr=e=>String(e).padStart(2,`0`),Mr=Array.from({length:24},(e,t)=>jr(t)),Nr=Array.from({length:60/kr},(e,t)=>jr(t*kr)),Pr=e.t(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[e.t(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`currentColor`,"stroke-width":`2`}),e.t(`path`,{d:`M12 7.5V12l3 2`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]});function Fr(e){let t=e?.match(Or);if(!t)return{hour:``,minute:``};let n=Number(t[1]),r=Number(t[2]);return n>23||r>59?{hour:``,minute:``}:{hour:jr(n),minute:jr(r-r%kr)}}function Ir(t){let{field:n,t:r,prefillValue:i,error:a,onEdit:o}=t,s=Fr(i),[c,l]=e.l(s.hour),[u,d]=e.l(s.minute),[f,p]=e.l(!1),m=e.o(null),h=e.o(null),{wrapperRef:g,anchorRef:_,panelRef:v,panelPos:y,portalTarget:b}=gr({isOpen:f,onRequestClose:()=>p(!1),minWidth:Ar});e.c(()=>{if(!f)return;let e=(e,t)=>{let n=e?.querySelector(t);n&&e&&(e.scrollTop=n.offsetTop-e.clientHeight/2+n.offsetHeight/2)};e(m.current,`.is-selected`),e(h.current,`.is-selected`)},[f,y?.above]);let x=c!==``&&u!==``?`${c}:${u}`:``,S=x,C=e=>{l(e),u===``&&d(`00`),o?.()},w=e=>{d(e),c===``&&l(`00`),p(!1),o?.(),_.current?.focus()},T=()=>{n.required||(l(``),d(``),p(!1),o?.(),_.current?.focus())},E=e=>{if(!n.required&&x&&(e.key===`Backspace`||e.key===`Delete`)){e.preventDefault(),T();return}e.key===`Enter`||e.key===` `||e.key===`ArrowDown`?(e.preventDefault(),p(!0)):e.key===`Escape`&&f&&(e.stopPropagation(),p(!1))},D=n.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null;return e.t(`div`,{className:`leadbot-field leadbot-field-time`,children:[e.t(`label`,{htmlFor:n.uuid,children:[n.label,D]}),e.t(`div`,{className:`leadbot-timepicker${!n.required&&x?` has-clear`:``}`,ref:g,children:[e.t(`span`,{className:`leadbot-timepicker-icon`,"aria-hidden":`true`,children:Pr}),e.t(`input`,{ref:_,type:`text`,className:`leadbot-timepicker-input`,id:n.uuid,"data-field-focus-uuid":n.uuid,inputMode:`none`,autocomplete:`off`,placeholder:n.placeholder||r(`timepicker_placeholder`,`Select a time`),required:n.required,value:S,"aria-haspopup":`dialog`,"aria-expanded":f,"aria-invalid":a?`true`:void 0,"aria-describedby":a?`${n.uuid}-error`:void 0,onBeforeInput:e=>e.preventDefault(),onClick:()=>p(!f),onKeyDown:E}),!n.required&&x&&e.t(`button`,{type:`button`,className:`leadbot-timepicker-clear`,"aria-label":r(`timepicker_clear`,`Clear time`),onClick:T,children:`×`}),e.t(`input`,{type:`hidden`,name:n.name,"data-field-uuid":n.uuid,value:x}),f&&b&&er(e.t(`div`,{ref:v,className:`leadbot-timepicker-panel${y?.above?` is-above`:``}`,role:`dialog`,"aria-label":n.label,style:y?{top:`${y.top}px`,left:`${y.left}px`,width:`${y.width}px`}:{visibility:`hidden`},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),p(!1),_.current?.focus())},children:e.t(`div`,{className:`leadbot-timepicker-columns`,children:[e.t(`div`,{className:`leadbot-timepicker-column`,role:`listbox`,"aria-label":r(`timepicker_hours_label`,`Hours`),ref:m,children:Mr.map(t=>e.t(`button`,{type:`button`,className:`leadbot-timepicker-option${c===t?` is-selected`:``}`,role:`option`,"aria-selected":c===t,onClick:()=>C(t),children:t},t))}),e.t(`span`,{className:`leadbot-timepicker-columns-separator`,"aria-hidden":`true`,children:`:`}),e.t(`div`,{className:`leadbot-timepicker-column`,role:`listbox`,"aria-label":r(`timepicker_minutes_label`,`Minutes`),ref:h,children:Nr.map(t=>e.t(`button`,{type:`button`,className:`leadbot-timepicker-option${u===t?` is-selected`:``}`,role:`option`,"aria-selected":u===t,onClick:()=>w(t),children:t},t))})]})}),b)]}),a&&e.t(`p`,{className:`leadbot-field-error`,id:`${n.uuid}-error`,role:`alert`,children:a})]},n.uuid)}var Lr={"submit-form":`form_submit`,"submit-callback":`callback_request`,"submit-email":`email_request`,"submit-whatsapp":`whatsapp`};function Rr(e,t){return t?{"aria-invalid":`true`,"aria-describedby":`${e.uuid}-error`}:{}}function zr(t,n){return n?e.t(`p`,{className:`leadbot-field-error`,id:`${t.uuid}-error`,role:`alert`,children:n}):null}function Br(e){e.key===`Enter`&&e.stopPropagation()}function Vr(t,n,r){let i=t.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null,a=t.validation?.min_length,o=t.validation?.max_length,s=a===void 0?void 0:Number(a),c=o===void 0?void 0:Number(o),l=n===`number`;return e.t(`div`,{className:`leadbot-field`,children:[e.t(`label`,{htmlFor:t.uuid,children:[t.label,i]}),e.t(`input`,{type:n,id:t.uuid,name:t.name,"data-field-uuid":t.uuid,placeholder:t.placeholder,required:t.required,defaultValue:r.prefillValue,minLength:l?void 0:a,maxLength:l?void 0:o,min:l?s:void 0,max:l?c:void 0,inputMode:n===`number`?`decimal`:void 0,onInput:r.onEdit,...Rr(t,r.error)}),zr(t,r.error)]},t.uuid)}function Hr(t,n){let r=t.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null;return e.t(`div`,{className:`leadbot-field`,children:[e.t(`label`,{htmlFor:t.uuid,children:[t.label,r]}),e.t(`textarea`,{id:t.uuid,name:t.name,"data-field-uuid":t.uuid,placeholder:t.placeholder,required:t.required,minLength:t.validation?.min_length,maxLength:t.validation?.max_length,onKeyDown:Br,onInput:n.onEdit,...Rr(t,n.error)}),zr(t,n.error)]},t.uuid)}function Ur(t,n){let r=t.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null;return e.t(`div`,{className:`leadbot-field leadbot-field-checkbox`,children:[e.t(`label`,{children:[e.t(`input`,{type:`checkbox`,id:t.uuid,name:t.name,"data-field-uuid":t.uuid,required:t.required,onChange:n.onEdit,...Rr(t,n.error)}),t.label,r]}),zr(t,n.error)]},t.uuid)}function Wr(n,r){let i=n.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null,a=`${n.uuid}-legend`,o=[],s=()=>{if(r.onEdit(),!n.required)return;let e=o.some(e=>e?.checked)?``:r.t(`form_checklist_required`,`Please select at least one option`);o.forEach(t=>{t&&t.setCustomValidity(e)})};return e.t(`fieldset`,{className:`leadbot-field leadbot-field-list`,children:[e.t(`legend`,{className:`leadbot-field-list-label`,id:a,children:[n.label,i]}),e.t(`div`,{className:`leadbot-field-options`,children:(0,t.getFieldOptions)(n).map((t,i)=>e.t(`label`,{className:`leadbot-field-option`,children:[e.t(`input`,{type:`checkbox`,name:`${n.uuid}-checklist`,"data-field-uuid":n.uuid,value:t.value,ref:e=>{e&&!o.includes(e)&&(o.push(e),n.required&&e.setCustomValidity(r.t(`form_checklist_required`,`Please select at least one option`)))},onChange:s,...Rr(n,r.error)}),e.t(`span`,{children:t.label})]},`${n.uuid}-${t.value}-${i}`))}),zr(n,r.error)]},n.uuid)}function Gr(n,r){let i=n.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null,a=`${n.uuid}-legend`;return e.t(`fieldset`,{className:`leadbot-field leadbot-field-list`,children:[e.t(`legend`,{className:`leadbot-field-list-label`,id:a,children:[n.label,i]}),e.t(`div`,{className:`leadbot-field-options`,role:`radiogroup`,"aria-labelledby":a,children:(0,t.getFieldOptions)(n).map((t,i)=>e.t(`label`,{className:`leadbot-field-option`,children:[e.t(`input`,{type:`radio`,name:`${n.uuid}-radiolist`,"data-field-uuid":n.uuid,value:t.value,required:n.required,onChange:r.onEdit,...Rr(n,r.error)}),e.t(`span`,{children:t.label})]},`${n.uuid}-${t.value}-${i}`))}),zr(n,r.error)]},n.uuid)}function Kr(n,r){let i=n.required?e.t(`span`,{className:`leadbot-required-asterisk`,children:`*`}):null,a=r.t(`form_select_placeholder`,`Choose an option`);return e.t(`div`,{className:`leadbot-field`,children:[e.t(`label`,{htmlFor:n.uuid,children:[n.label,i]}),e.t(`select`,{id:n.uuid,name:n.name,"data-field-uuid":n.uuid,required:n.required,onChange:r.onEdit,...Rr(n,r.error),children:[e.t(`option`,{value:``,children:a}),(0,t.getFieldOptions)(n).map(t=>e.t(`option`,{value:t.value,children:t.label},t.value))]}),zr(n,r.error)]},n.uuid)}function qr(e,n){let r=(0,t.resolveFieldType)(n);if(r===`checklist`)return Array.from(e.querySelectorAll(`[data-field-uuid="${n.uuid}"]`)).filter(e=>e.checked).map(e=>e.value);if(r===`radiolist`)return e.querySelector(`[data-field-uuid="${n.uuid}"]:checked`)?.value||``;let i=e.querySelector(`[data-field-uuid="${n.uuid}"]`);return i?r===`checkbox`||i.type===`checkbox`?i.checked?`true`:`false`:i.value:``}var Jr={text:(e,t)=>Vr(e,`text`,t),email:(e,t)=>Vr(e,`email`,t),tel:(e,t)=>Vr(e,`tel`,t),number:(e,t)=>Vr(e,`number`,t),date:(t,n)=>e.t(Dr,{field:t,locale:n.locale||`en`,t:n.t,prefillValue:n.prefillValue,error:n.error,onEdit:n.onEdit},t.uuid),time:(t,n)=>e.t(Ir,{field:t,t:n.t,prefillValue:n.prefillValue,error:n.error,onEdit:n.onEdit},t.uuid),textarea:(e,t)=>Hr(e,t),checkbox:(e,t)=>Ur(e,t),checklist:(e,t)=>Wr(e,t),radiolist:(e,t)=>Gr(e,t),select:(e,t)=>Kr(e,t)};function Yr(e,n){let r=(0,t.resolveFieldType)(e),i=r?Jr[r]:null;return!i||!r?(console.warn(`Unsupported field type: ${e.type}`),null):i(e,n)}function Xr(n){let{step:r,config:i,isCurrent:a,onOptionSelect:o,formConfig:s}=n,c=Ht(i),l=e.p(Kt),[u,d]=e.l(!1),[f,p]=e.l(!1),[m,h]=e.l(null),[g,_]=e.l({}),v=e.o(null),y=(0,t.resolveLanguage)(i.leadbot?.language),b=r.attributes?.form_schema,x=b?.fields||{},{t:S}=qt(y),C=Object.keys(x).map(e=>({uuid:e,...x[e]})).sort((e,t)=>(e.order||0)-(t.order||0)),w=b?.title||``,T=b?.show_title!==!1&&!!w,E=r.attributes?.button_text||s.defaultButtonText||S(`form_submit_button`,`Submit`),D=r.attributes?.success_message||S(`submit-${s.action}`,`Thank you for your submission!`),O=e=>{_(t=>{if(!(e in t))return t;let n={...t};return delete n[e],Object.keys(n).length===0&&h(null),n})},k=e=>{let t=v.current,n=CSS.escape(e);(t?.querySelector(`[data-field-focus-uuid="${n}"]`)||t?.querySelector(`[data-field-uuid="${n}"]:not([type="hidden"])`))?.focus()};return f?e.t(`div`,{className:`${s.containerClass} leadbot-form-complete`,children:e.t(`div`,{className:`leadbot-success-message`,role:`status`,dangerouslySetInnerHTML:{__html:X(D)}})}):e.t(`div`,{className:s.containerClass,children:e.t(`form`,{className:`leadbot-form-shell`,ref:v,onSubmit:async e=>{if(e.preventDefault(),!a||u||f)return;let i=v.current;if(!i)return;let m={};for(let e of C){let n=qr(i,e);m[e.uuid]=(0,t.resolveFieldType)(e)===`tel`&&typeof n==`string`?(0,t.normalizePhoneInput)(n):n}let g={};for(let e of C){let n=m[e.uuid];(0,t.resolveFieldType)(e)===`tel`&&typeof n==`string`&&n&&!(0,t.isPlausiblePhone)(n)&&(g[e.uuid]=S(`form_invalid_phone`,`Enter a valid phone number (e.g. 0614526333)`))}let y=C.find(e=>g[e.uuid]);if(y){_(g),h(S(`form_fix_fields`,`Please check the highlighted fields`)),k(y.uuid);return}h(null),_({}),d(!0);try{let e=Lr[s.action]||`form_submit`,i=await c.submitUserData(e,r.uuid,m,l?{chat_session_id:l}:void 0);if(i?.success===!1)throw Error(i.error||`Submission failed`);n.analyticsTracker?.trackFormSubmit(r,e,(0,t.buildGaUserData)(C,t.resolveFieldType,e=>m[e.uuid])),p(!0),n.onSubmitted?.(m);let a=r.options?.[0];a?.next_step_uuid&&o(a.next_step_uuid)}catch(e){let t={invalid_phone:[`form_invalid_phone`,`Enter a valid phone number (e.g. 0614526333)`],invalid_email:[`form_invalid_email`,`Enter a valid email address`],required:[`form_field_required`,`This field is required`]},n={};if(Array.isArray(e?.errors))for(let r of e.errors){let e=r?.field_uuid,i=r?.message;if(typeof e==`string`&&typeof i==`string`){let a=t[r?.code];n[e]=a?S(a[0],a[1]):i}}let r=C.find(e=>n[e.uuid]);r?(_(n),h(S(`form_fix_fields`,`Please check the highlighted fields`)),k(r.uuid)):h(S(`form_submit_failed`,`Something went wrong while sending. Please try again.`))}finally{d(!1)}},children:[e.t(`div`,{className:`leadbot-form-scroll`,children:[T&&e.t(`div`,{className:`leadbot-form-title`,dangerouslySetInnerHTML:{__html:X(w)}}),m&&e.t(`div`,{className:`leadbot-form-error`,role:`alert`,children:m}),e.t(`fieldset`,{className:`leadbot-form-fields`,disabled:u,children:C.map(e=>Yr(e,{t:S,prefillValue:n.prefillValues?.[e.uuid],locale:y,error:g[e.uuid],onEdit:()=>O(e.uuid)}))})]}),e.t(`div`,{className:`leadbot-form-actions`,children:e.t(`button`,{type:`submit`,className:`leadbot-submit-btn${u?` leadbot-loading`:``}`,disabled:!a||u,children:E})})]})})}function Zr(t){return e.t(Xr,{...t,formConfig:{action:`submit-callback`,containerClass:`leadbot-callback-form`,defaultButtonText:`Request Callback`}})}function Qr(t){return e.t(Xr,{...t,formConfig:{action:`submit-email`,containerClass:`leadbot-email-request-form`,defaultButtonText:`Submit`}})}function $r(t){return e.t(Xr,{...t,formConfig:{action:`submit-form`,containerClass:`leadbot-form`,defaultButtonText:`Submit`}})}function ei(){return null}var ti=`whatsapp`;function ni(n){let{step:r,config:a,isPending:o,prefillMessage:s,onCompleted:c,onDismissed:l}=n,u=Ht(a),d=e.p(Kt),[f,p]=e.l(null),[m,h]=e.l(null),[g,_]=e.l(null),v=(0,t.resolveLanguage)(a.leadbot?.language),{t:y}=qt(v),b=r.attributes?.sender_name||y(`whatsapp_default_contact`,`Support`),x=r.attributes?.sender_image?.url||null,S=r.attributes?.text||``,C=(0,t.processVariables)(S,v,{name:a.leadbot.default_contact_information?.label,website_name:a.leadbot.domain.display_name,email:a.leadbot.default_contact_information?.email,phonenumber:a.leadbot.default_contact_information?.phone}),T=r.attributes?.sender_number||r.attributes?.phone_number||``,E=Fn(r.attributes?.form_schema?.fields||{}),D=r.attributes?.show_qr_code===!0,{isDesktop:O}=i(),k=D&&O,A=y(`whatsapp_error_submission`,`We could not save your message. You can still continue in WhatsApp.`),j=y(`whatsapp_error_phone_missing`,`WhatsApp is not configured for this step.`),ee=y(`whatsapp_error_redirect`,`WhatsApp could not be opened. Please check your pop-up settings.`),M=async e=>{if(!(!E||!e))try{let t=await u.submitUserData(ti,r.uuid,{[E.uuid]:e},d?{chat_session_id:d}:void 0);if(t?.success===!1)throw Error(t.error||`Submission failed`)}catch(e){console.error(`WhatsApp data submission failed:`,e),p(A)}},N=async()=>{if(!o)return;p(null);let e=(s||``).trim();if(!T.trim()){p(j);return}let i=In(e,(0,t.sanitizeTrackedUrl)(window.location.href)),a=(0,t.createWhatsAppUrl)(T,i);if(!a){p(j);return}if(k){let e=(0,t.createWhatsAppWebUrl)(T,i),n=Ln(a);if(!n||!e){p(ee);return}h({svg:n,webUrl:e})}else window.open(a,`_blank`,`noopener,noreferrer`),_(a);n.analyticsTracker?.trackWhatsAppRedirect(r),await M(e),c(E&&e?{[E.uuid]:e}:{})},P=!m&&!g,F=y(`chatbot_whatsapp_open`,`Open WhatsApp`),I=y(`chatbot_whatsapp_dismiss`,`No thanks, continue chatting here`);return e.t(`div`,{className:`leadbot-chatbot-wa`,children:[P&&e.t(`div`,{className:`leadbot-chatbot-wa-contact`,children:[e.t(Mt,{imageUrl:x,alt:b,variant:`whatsapp`}),e.t(`div`,{className:`leadbot-chatbot-wa-contact-info`,children:[e.t(`span`,{className:`leadbot-chatbot-wa-name`,children:b}),e.t(`span`,{className:`leadbot-chatbot-wa-via`,children:[e.t(`span`,{dangerouslySetInnerHTML:{__html:w.whatsapp}}),`WhatsApp`]})]})]}),P&&C&&e.t(`div`,{className:`leadbot-chatbot-wa-text`,dangerouslySetInnerHTML:{__html:X(C)}}),f&&e.t(`div`,{className:`leadbot-form-error`,children:f}),P&&o&&e.t(`button`,{type:`button`,className:`leadbot-chatbot-wa-open-btn`,onClick:N,children:[e.t(`span`,{dangerouslySetInnerHTML:{__html:w.whatsapp}}),F]}),m&&e.t(`div`,{className:`leadbot-chatbot-wa-qr`,children:[e.t(`div`,{className:`leadbot-chatbot-wa-qr-title`,children:y(`whatsapp_qr_title`,`Open in WhatsApp`)}),e.t(`div`,{className:`leadbot-chatbot-wa-qr-image`,dangerouslySetInnerHTML:{__html:m.svg}}),e.t(`div`,{className:`leadbot-chatbot-wa-qr-label`,children:y(`whatsapp_qr_scan_label`,`Scan the code to continue on your phone, or use WhatsApp Web.`)}),e.t(`a`,{href:m.webUrl,target:`_blank`,rel:`noopener noreferrer`,className:`leadbot-chatbot-wa-link`,children:[e.t(`span`,{dangerouslySetInnerHTML:{__html:w.whatsapp}}),y(`whatsapp_qr_open_web`,`Open WhatsApp Web`)]})]}),g&&e.t(`div`,{className:`leadbot-chatbot-wa-opened`,children:[e.t(`span`,{children:y(`chatbot_whatsapp_opened`,`WhatsApp opened — your message is ready to send.`)}),e.t(`a`,{href:g,target:`_blank`,rel:`noopener noreferrer`,className:`leadbot-chatbot-wa-link`,children:y(`chatbot_whatsapp_reopen`,`Open again`)})]}),P&&o&&e.t(`button`,{type:`button`,className:`leadbot-chatbot-wa-dismiss`,onClick:l,children:I})]})}var ri=8,ii=new Set([`text`,`email`,`tel`,`phone`,`name`]),ai=[`email`,`phone`,`name`],oi=/^[\d\s\-+()]{7,}$/;function si(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={},n=0;for(let[r,i]of Object.entries(e)){if(n>=ri)break;if(typeof i!=`string`)continue;let e=i.trim();!e||e.length>254||(t[r]=e,n++)}return t}function ci(e,t){return e===`email`?t.includes(`@`)&&!/\s/.test(t):e!==`phone`||oi.test(t)}function li(e,t){let n=String(t.type||``).toLowerCase();if(!ii.has(n))return!1;let r=String(t.name||``).toLowerCase();return e===`email`?n===`email`||r.includes(`email`):e===`phone`?n===`tel`||n===`phone`||r.includes(`phone`)||r.includes(`tel`):n===`name`||r.includes(`name`)}function ui(e,t){let n={},r=new Set;for(let i of ai){let a=e[i];if(!a||!ci(i,a))continue;let o=Object.keys(t).find(e=>!r.has(e)&&li(i,t[e]));o&&(r.add(o),n[o]=a)}return n}function di(e){let t=e.attributes?.form_schema?.title;return e.label||t||e.step_type}function fi(t){let{message:n,config:r,onCompleted:i,analyticsTracker:a}=t,o=r.steps?.find(e=>e.uuid===n.step_uuid);if(!o)return console.warn(`ChatToolCard: no step found for tool_call step_uuid "${n.step_uuid}"`),null;let{component:s}=ca(o.step_type),c=o.step_type===`whatsapp`,l=n.status===`pending`,u=n.status===`completed`,d=n.status===`dismissed`;return e.t(`div`,{className:`leadbot-chatbot-message leadbot-chatbot-message-bot leadbot-chatbot-tool-card${u?` leadbot-chatbot-tool-card--completed`:d?` leadbot-chatbot-tool-card--dismissed`:``}${c?` leadbot-chatbot-tool-card--whatsapp`:``}`,children:[e.t(`div`,{className:`leadbot-chatbot-tool-card-header`,children:[e.t(`span`,{className:`leadbot-chatbot-tool-card-icon`,"aria-hidden":`true`,children:e.t(mi,{stepType:o.step_type})}),e.t(`span`,{className:`leadbot-chatbot-tool-card-title`,children:di(o)}),u&&e.t(`span`,{className:`leadbot-chatbot-tool-card-check`,"aria-hidden":`true`,children:e.t(pi,{})})]}),!d&&e.t(`div`,{className:`leadbot-chatbot-tool-card-body`,children:c?e.t(ni,{step:o,config:r,isPending:l,prefillMessage:t.prefillMessage,onCompleted:i,onDismissed:t.onDismissed??(()=>{}),analyticsTracker:a}):e.t(s,{step:o,config:r,isCurrent:l,isFirstStep:!1,onOptionSelect:()=>{},onSubmitted:i,prefillValues:ui(n.args||{},o.attributes?.form_schema?.fields||{}),analyticsTracker:a})})]})}function pi(){return e.t(`svg`,{width:`10`,height:`10`,viewBox:`0 0 16 16`,fill:`none`,children:e.t(`path`,{d:`M3 8.5l3.2 3.2L13 5`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function mi(t){let n={callback_request:`M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z`,email_request:`M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zm18 3-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,whatsapp:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,form_submit:`M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2M9 12h6M9 16h6`},r=n[t.stepType]||n.form_submit;return e.t(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,children:e.t(`path`,{d:r,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}var hi=`__leadbot_`,gi=100,_i=64;function vi(e){return`${hi}session_${e||`default`}`}function yi(e){return`${hi}closed_${e||`default`}`}function bi(e){return`${hi}chat_${e||`default`}_`}function xi(e,t){return`${bi(e)}${t}`}function Si(e,n){(0,t.writeEntry)(vi(e),n.slice(-100))}function Ci(e){let n=(0,t.readEntry)(vi(e));return!Array.isArray(n)||n.length===0||n.length>gi||!n.every(e=>typeof e==`string`&&e.length>0&&e.length<=_i)?null:n}function wi(e,n=e,r){try{let i=vi(n),a=yi(n),o=(0,t.sessionStore)();if(r){o.removeItem(i),o.removeItem(a);for(let t of r)o.removeItem(xi(e,t));return}let s=bi(e);for(let e=o.length-1;e>=0;e--){let t=o.key(e);(t===i||t===a||t?.startsWith(s))&&o.removeItem(t)}}catch{}}var Ti=2e4,Ei=1e3,Di=25,Oi=2e3,ki=50,Ai=5e3,ji=50,Mi=64,Ni=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Pi=new Set([`pending`,`completed`,`dismissed`]);function Fi(e){if(!Array.isArray(e))return;let t=e.filter(e=>!!e&&typeof e==`object`&&typeof e.chunk_id==`number`&&typeof e.filename==`string`&&e.filename.length<=Oi).slice(0,Di).map(e=>({chunk_id:e.chunk_id,filename:e.filename}));return t.length>0?t:void 0}function Ii(e){if(!e||typeof e!=`object`)return;let t=e;if(t.rating!==`positive`&&t.rating!==`negative`)return;let n={rating:t.rating};return typeof t.comment==`string`&&t.comment!==``&&t.comment.length<=1e3&&(n.comment=t.comment),n}function Li(e){if(e.role!==`user`&&e.role!==`assistant`||typeof e.content!=`string`||e.content===``||e.content.length>Ti)return null;let t={role:e.role,content:e.content},n=Fi(e.citations);if(n&&(t.citations=n),e.role===`assistant`&&e.ai===!0){t.ai=!0;let n=Ii(e.feedback);n&&(t.feedback=n)}return t}function Ri(e,t,n){return Array.isArray(e)?e.some(e=>!e||typeof e!=`object`?!1:(e.tool_type||`step`)===`step`&&e.name===t&&e.step_uuid===n):!1}function zi(e){if(typeof e==`string`)return e.length<=Ai?e:void 0;if(!(!Array.isArray(e)||e.length>ji)&&!e.some(e=>typeof e!=`string`||e.length>Ai))return[...e]}function Bi(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={},n=0;for(let[r,i]of Object.entries(e)){if(n>=ki)break;let e=zi(i);e!==void 0&&(t[r]=e,n++)}return t}function Vi(e,t){if(e.role!==`tool`||typeof e.tool!=`string`||!e.tool||typeof e.step_uuid!=`string`||!e.step_uuid||e.step_uuid.length>Mi||typeof e.status!=`string`||!Pi.has(e.status)||!Ri(t,e.tool,e.step_uuid))return null;let n={role:`tool`,tool:e.tool,step_uuid:e.step_uuid,status:e.status,args:si(e.args)};return n.status===`completed`&&(n.result=Bi(e.result)),n}function Hi(e,t){if(!Array.isArray(e))return null;let n=[];for(let r of e.slice(-50)){if(!r||typeof r!=`object`)return null;let e=r,i=e.role===`tool`?Vi(e,t):Li(e);if(!i)return null;n.push(i)}return n}function Ui(e,n,r){let i=(0,t.readEntry)(xi(e,n));if(!i||typeof i!=`object`)return null;let a=i,o=Hi(a.messages,r);return!o||o.length===0?null:{sessionId:typeof a.sessionId==`string`&&Ni.test(a.sessionId)?a.sessionId:null,messages:o}}function Wi(e,n,r,i){if(!r)return;let a=i.filter(e=>e.role===`tool`||e.content!==``).slice(-50);(0,t.writeEntry)(xi(e,n),{sessionId:r,messages:a})}function Gi(e,n){(0,t.removeEntry)(xi(e,n))}function Ki(e,n){let r=e[n];if(!r||r.role===`tool`)return null;let i=-1,a=0;for(let t=0;t<e.length;t++){let r=e[t];(r.role!==`tool`||r.status!==`pending`)&&(a++,t<=n&&i++)}let o=Math.max(0,a-(t.MAX_WIRE_HISTORY+1));return i<o?null:i-o}var qi=2500;function Ji({feedback:n,language:r,onRate:i,onLayoutChange:a}){let[o,s]=e.l(!1),[c,l]=e.l(``),[u,d]=e.l(!1),f=e.o(null);e.d(()=>()=>{f.current&&clearTimeout(f.current)},[]);let p=()=>{d(!0),f.current=setTimeout(()=>{f.current=null,d(!1),a()},qi)},m=e=>{n?.rating!==e&&(i(e),l(``),s(!0),d(!1),a())};return e.t(`div`,{className:`leadbot-chatbot-feedback`,children:[e.t(`div`,{className:`leadbot-chatbot-feedback-buttons`,children:[e.t(`button`,{type:`button`,className:`leadbot-chatbot-feedback-btn${n?.rating===`positive`?` leadbot-chatbot-feedback-btn--selected`:``}`,"aria-label":(0,t.getVariableValue)(`chatbot_feedback_positive`,r),"aria-pressed":n?.rating===`positive`,onClick:()=>m(`positive`),dangerouslySetInnerHTML:{__html:C(`fal fa-thumbs-up`)}}),e.t(`button`,{type:`button`,className:`leadbot-chatbot-feedback-btn${n?.rating===`negative`?` leadbot-chatbot-feedback-btn--selected`:``}`,"aria-label":(0,t.getVariableValue)(`chatbot_feedback_negative`,r),"aria-pressed":n?.rating===`negative`,onClick:()=>m(`negative`),dangerouslySetInnerHTML:{__html:C(`fal fa-thumbs-down`)}})]}),o&&n&&e.t(`form`,{className:`leadbot-chatbot-feedback-comment`,onSubmit:e=>{if(e.preventDefault(),!n)return;let t=c.trim().slice(0,Ei);t&&i(n.rating,t),s(!1),l(``),p(),a()},children:[e.t(`textarea`,{className:`leadbot-chatbot-feedback-textarea`,rows:2,maxLength:1e3,placeholder:(0,t.getVariableValue)(`chatbot_feedback_comment_placeholder`,r),value:c,onInput:e=>l(e.target.value)}),e.t(`div`,{className:`leadbot-chatbot-feedback-comment-actions`,children:[e.t(`button`,{type:`submit`,className:`leadbot-chatbot-feedback-send`,children:(0,t.getVariableValue)(`chatbot_feedback_comment_submit`,r)}),e.t(`button`,{type:`button`,className:`leadbot-chatbot-feedback-skip`,onClick:()=>{s(!1),l(``),a()},children:(0,t.getVariableValue)(`chatbot_feedback_comment_skip`,r)})]})]}),u&&e.t(`div`,{className:`leadbot-chatbot-feedback-thanks`,children:(0,t.getVariableValue)(`chatbot_feedback_thanks`,r)})]})}var Yi=5e3;function Xi(e,t,n){return Array.isArray(e)&&e.find(e=>!e||typeof e!=`object`?!1:(e.tool_type||`step`)===`step`&&e.name===t&&e.step_uuid===n)||null}function Zi(e,t){if(e.status===`dismissed`)return`The visitor dismissed this step without completing it.`;let n=(t.steps?.find(t=>t.uuid===e.step_uuid))?.attributes?.form_schema?.fields||{},r=Object.entries(e.result||{}).map(([e,t])=>{let r=n[e];return`${r?.label||r?.name||e}: ${t}`}).join(`; `);return(r?`The visitor submitted the form. ${r}`:`The visitor submitted the form.`).slice(0,Yi)}function Qi(e,t){let n=[];for(let r of e){if(r.role!==`tool`){n.push({role:r.role,content:r.content});continue}r.status!==`pending`&&n.push({role:`tool_result`,tool:r.tool,status:r.status,content:Zi(r,t)})}return n}function $i(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(t.role===`user`)return t.content}}function ea(e,t){let n=-1;for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`){n=t;break}let r=n===-1?null:e[n],i=r&&r.content!==``&&t.length>0?e.map((e,i)=>i===n?{...r,citations:t}:e):e;return i.filter((e,t)=>e.role!==`assistant`||e.content!==``||!i.slice(t+1).some(e=>e.role===`tool`))}function ta(e,t){let n=e[e.length-1];return n?.role===`assistant`&&n.content===``?[...e.slice(0,-1),{role:`assistant`,content:t}]:[...e,{role:`assistant`,content:t}]}function na(e,t){let n=e[e.length-1];return n?.role===`assistant`?[...e.slice(0,-1),{...n,content:n.content+t,ai:!0}]:[...e,{role:`assistant`,content:t,ai:!0}]}function ra(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.role===`user`)break;if(r.role===`assistant`)return[...e.slice(0,n),{...r,content:t,ai:!0},...e.slice(n+1)]}return[...e,{role:`assistant`,content:t,ai:!0}]}function ia(n){let{step:r,config:i,isCurrent:a}=n,o=Ht(i),s=r.attributes?.sender_name||`AI Assistant`,c=r.attributes?.sender_image?.url||null,l=r.attributes?.initial_message||``,u=(0,t.sanitizeConversationStarters)(r.attributes?.conversation_starters),f=(0,t.resolveLanguage)(i.leadbot?.language),p=(0,t.getVariableValue)(`chatbot_placeholder`,f),m=d(i),[g]=e.l(()=>Ui(m,r.uuid,r.attributes?.tools)),[v,b]=e.l(()=>g?g.messages:l?[{role:`assistant`,content:l}]:[]),[x,S]=e.l(!1),[w,T]=e.l(null),[E,D]=e.l(!1),[O,k]=e.l(!1),A=e.o(null),j=e.o(null),ee=e.o(null),M=e.o(null),N=e.o(g?.sessionId??null),P=e.o(v),F=e.o(!1),I=e.o(!1),te=e.o(null),re=e.o(null);e.d(()=>{E&&M.current?.focus({preventScroll:!0})},[E]);let R=e=>{b(t=>{let n=typeof e==`function`?e(t):e;return P.current=n,n})},ae=e=>{F.current=e,S(e)},oe=()=>(N.current||=(0,t.generateUUID)(),(0,t.setActiveChatSession)(N.current),N.current),se=()=>{setTimeout(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},100)};e.d(()=>{P.current=v},[v]),e.d(()=>{Wi(m,r.uuid,N.current,v)},[m,r.uuid,v]),e.d(()=>{F.current=x},[x]),e.d(()=>()=>{if(!te.current)return;clearTimeout(te.current);let e=re.current;e&&Ui(m,r.uuid,r.attributes?.tools)&&Wi(m,r.uuid,N.current,ta(P.current,e))},[]),e.d(()=>{se()},[v,x,w]);let ce=e.o(null),le=e=>{if(typeof e.tool!=`string`||!e.tool)return;if(typeof e.step_uuid!=`string`||!e.step_uuid){T(`tool`);return}let t=e.step_uuid,n=i.steps?.find(e=>e.uuid===t);if(!n){console.warn(`Chatbot tool_call references unknown step: ${t}`);return}let a=Xi(r.attributes?.tools,e.tool,t);if(!a){console.warn(`Chatbot tool_call references unconfigured step tool: ${e.tool}`);return}if(a.step_type&&a.step_type!==n.step_type){console.warn(`Chatbot tool_call step_type mismatch for step: ${t}`);return}let o={role:`tool`,tool:e.tool,step_uuid:t,status:`pending`,args:si(e.args)};R(e=>[...e.map(e=>e.role===`tool`&&e.step_uuid===t&&e.status===`pending`?{...e,status:`dismissed`}:e),o])},ue=async e=>{let n=o.visitorId;if(!m||!r.uuid)throw Error(`chatbot_error_default`);let a=Qi(e,i),s=new AbortController;ce.current=s;let c=[],l=!1,u=(0,t.streamChat)({url:h(`/client/chat/stream`),domainKey:m,leadbotId:_(i),stepUuid:r.uuid,visitorId:n,chatSessionId:oe(),messages:a,previewToken:y()??void 0,analytics:(0,t.buildAnalytics)(),signal:s.signal});for await(let e of u){if(e.type===`reasoning`){l||(l=!0,T(`thinking`));continue}if(l&&(l=!1,T(`searching`),await new Promise(e=>setTimeout(e,0))),e.type===`token`&&typeof e.content==`string`)T(null),R(t=>na(t,e.content)),await new Promise(e=>setTimeout(e,0));else if(e.type===`correction`&&typeof e.content==`string`)R(t=>ra(t,e.content)),await new Promise(e=>setTimeout(e,0));else if(e.type===`citations`&&Array.isArray(e.citations))c=e.citations;else if(e.type===`tool_call`)le(e),await new Promise(e=>setTimeout(e,0));else if(e.type===`done`){R(e=>ea(e,c));break}else if(e.type===`error`){let n=t.CHAT_ERROR_CODE_MAP[e.error_code]||`chatbot_error_default`;R(e=>{let r=ea(e,[]),i=r[r.length-1];return i?.role===`assistant`&&i.content===``?[...r.slice(0,-1),{...i,content:(0,t.getVariableValue)(n,f)}]:[...r,{role:`assistant`,content:(0,t.getVariableValue)(n,f)}]});break}}},z=async e=>{R([...e,{role:`assistant`,content:``}]),ae(!0),T(`thinking`);try{await ue(e)}catch(e){console.error(`Failed to send chatbot message:`,e);let n=e instanceof Error&&e.message.startsWith(`chatbot_error_`)?e.message:`chatbot_error_default`;R(e=>{let r=ea(e,[]),i=r[r.length-1];return i?.role===`assistant`&&i.content===``?[...r.slice(0,-1),{role:`assistant`,content:(0,t.getVariableValue)(n,f)}]:i?.role===`assistant`?[...r.slice(0,-1),{...i,content:`${i.content}\n\n${(0,t.getVariableValue)(n,f)}`}]:i?.role===`tool`?[...r,{role:`assistant`,content:(0,t.getVariableValue)(n,f)}]:r})}finally{ae(!1),T(null),ce.current=null,I.current&&(I.current=!1,setTimeout(()=>{F.current||z(P.current)},0))}},de=async e=>{await z([...P.current,{role:`user`,content:e}])};e.d(()=>{let e=n.pendingMessage;if(!(e===void 0||!a||F.current)){if(n.onPendingMessageConsumed?.(),e){let t=e.trim().toLowerCase(),n=u.find(e=>e.question.trim().toLowerCase()===t);n?B(n):de(e)}else j.current?.focus({preventScroll:!0})}},[n.pendingMessage,a,x]);let B=e=>{if(!(!a||F.current)){if(e.answer){fe(e.question,e.answer);return}de(e.question)}},fe=(e,n)=>{let a=oe();o.submitChatExchange({step_uuid:r.uuid,chat_session_id:a,messages:Qi([...P.current,{role:`user`,content:e}],i),answer:n}),R(t=>[...t,{role:`user`,content:e},{role:`assistant`,content:``}]),ae(!0),T(`thinking`),re.current=n,te.current=setTimeout(()=>{te.current=null,re.current=null,R(e=>ta(e,n)),ae(!1),T(null)},t.FIXED_ANSWER_TYPING_MS)},V=(e,t)=>{let n=P.current,r=n[e];if(r?.role!==`tool`||r.status!==`pending`)return;let i=n.map((n,r)=>r===e&&n.role===`tool`?{...n,status:`completed`,result:t}:n);if(R(i),F.current){I.current=!0;return}z(i)},H=e=>{R(t=>t.map((t,n)=>n===e&&t.role===`tool`&&t.status===`pending`?{...t,status:`dismissed`}:t))},pe=(e,t,n)=>{let i=N.current;if(!i)return;let a=P.current,s=a[e];if(s?.role!==`assistant`)return;let c=Ki(a,e);c!==null&&(R(r=>r.map((r,i)=>i===e&&r.role===`assistant`?{...r,feedback:{rating:t,...n?{comment:n}:{}}}:r)),o.submitChatFeedback({step_uuid:r.uuid,chat_session_id:i,message_index:c,rating:t,comment:n,message_content:s.content.slice(0,5e3)}))},U=e=>{e.preventDefault();let t=j.current?.value?.trim();!t||!a||x||(j.current.value=``,k(!1),de(t))},me=()=>{k(!!j.current?.value?.trim())},he=e=>{e.key===`Enter`&&!e.shiftKey&&U(e)},ge=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),D(!1),ee.current?.focus({preventScroll:!0}))},_e=()=>{ce.current?.abort(),ce.current=null,N.current=null,I.current=!1,Gi(m,r.uuid),te.current&&=(clearTimeout(te.current),null),ae(!1),T(null),R(l?[{role:`assistant`,content:l}]:[]),D(!1)},ve=v.some(e=>e.role!==`assistant`),ye=u.length>0&&!ve&&!x,be=v[v.length-1],xe=x&&w!==null&&be?.role===`assistant`&&be.content!==``;return e.t(`div`,{className:`leadbot-chatbot-interface`,children:[e.t(`div`,{className:`leadbot-chatbot-header`,children:[e.t(Mt,{imageUrl:c,alt:s,variant:`chatbot`}),e.t(`div`,{className:`leadbot-chatbot-header-info`,children:[e.t(`div`,{className:`leadbot-chatbot-title`,children:s}),e.t(`div`,{className:`leadbot-chatbot-status`,children:[e.t(`span`,{className:`leadbot-chatbot-online-dot`}),e.t(`span`,{children:`Online`})]})]}),e.t(`button`,{ref:ee,type:`button`,className:`leadbot-chatbot-menu-btn`,"aria-label":(0,t.getVariableValue)(`chatbot_menu_label`,f),"aria-expanded":E,"aria-haspopup":`menu`,onClick:()=>D(!E),children:e.t(`svg`,{width:`18`,height:`18`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[e.t(`circle`,{cx:`10`,cy:`4`,r:`1.5`,fill:`currentColor`}),e.t(`circle`,{cx:`10`,cy:`10`,r:`1.5`,fill:`currentColor`}),e.t(`circle`,{cx:`10`,cy:`16`,r:`1.5`,fill:`currentColor`})]})}),E&&e.t(`div`,{className:`leadbot-chatbot-menu`,role:`menu`,onKeyDown:ge,children:e.t(`button`,{ref:M,type:`button`,className:`leadbot-chatbot-menu-item`,role:`menuitem`,onClick:_e,children:[e.t(`span`,{className:`leadbot-chatbot-menu-item-icon`,dangerouslySetInnerHTML:{__html:C(`fal fa-rotate-left`)}}),e.t(`span`,{children:`Reset chat`})]})})]}),e.t(`div`,{className:`leadbot-chatbot-messages`,ref:A,role:`log`,"aria-label":(0,t.getVariableValue)(`chatbot_messages_label`,f),tabIndex:0,children:[v.map((t,r)=>{if(t.role===`user`)return e.t(`div`,{className:`leadbot-chatbot-message leadbot-chatbot-message-user`,children:e.t(`div`,{className:`leadbot-chatbot-message-content`,dangerouslySetInnerHTML:{__html:ne(t.content)}})},r);if(t.role===`tool`)return e.t(Kt.Provider,{value:N.current,children:e.t(fi,{message:t,config:i,analyticsTracker:n.analyticsTracker,onCompleted:e=>V(r,e),onDismissed:()=>H(r),prefillMessage:$i(v,r)})},r);if(x&&t.content===``&&r===v.length-1)return e.t(`div`,{className:`leadbot-chatbot-message leadbot-chatbot-message-bot leadbot-chatbot-message-typing`,children:e.t(oa,{language:f,phase:w||`thinking`})},r);let{html:a,sources:o}=ie(L(t.content),t.citations||[]),s=t.ai===!0&&t.content!==``&&!(x&&r===v.length-1)&&Ki(v,r)!==null;return e.t(`div`,{className:`leadbot-chatbot-message leadbot-chatbot-message-bot`,children:[e.t(`div`,{className:`leadbot-chatbot-message-content`,dangerouslySetInnerHTML:{__html:X(a)}}),o.length>0&&e.t(`div`,{className:`leadbot-chatbot-citations`,children:o.map(t=>{let n=t.url.replace(/^https?:\/\//,``);return e.t(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`leadbot-chatbot-citation-item`,children:[e.t(`span`,{className:`leadbot-chatbot-citation-number`,children:t.index}),e.t(`span`,{className:`leadbot-chatbot-citation-url`,children:n})]},t.index)})}),s&&e.t(Ji,{feedback:t.feedback,language:f,onRate:(e,t)=>pe(r,e,t),onLayoutChange:se})]},r)}),xe&&e.t(`div`,{className:`leadbot-chatbot-message leadbot-chatbot-message-bot leadbot-chatbot-message-typing`,children:e.t(oa,{language:f,phase:w||`thinking`})})]}),ye&&e.t(aa,{starters:u,disabled:!a,onSelect:B}),e.t(Ft,{align:`center`,className:`leadbot-chatbot-branding`,leadbot:i.leadbot,language:f,isChatbot:!0,asLink:!0}),e.t(`div`,{className:`leadbot-chatbot-input`,children:e.t(`div`,{className:`leadbot-chatbot-input-field`,children:[e.t(`input`,{ref:j,type:`text`,placeholder:p,className:`leadbot-chatbot-message-input`,onKeyDown:he,onInput:me,disabled:!a||x}),e.t(`button`,{className:`leadbot-chatbot-send-btn${O&&!x?` leadbot-chatbot-send-btn--active`:``}`,"aria-label":(0,t.getVariableValue)(`chatbot_send_label`,f),onClick:U,disabled:!a||x||!O,children:e.t(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,children:e.t(`path`,{d:`M10 4L10 16M10 4L5 9M10 4L15 9`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]})})]})}function aa({starters:t,disabled:n,onSelect:r}){return e.t(`div`,{className:`leadbot-chatbot-starters`,children:t.map(t=>e.t(`button`,{type:`button`,className:`leadbot-chatbot-starter-btn`,disabled:n,onClick:()=>r(t),children:t.question},t.question))})}function oa({language:n,phase:r}){let i=r===`searching`?(0,t.getVariableValue)(`chatbot_searching`,n):r===`tool`?(0,t.getVariableValue)(`chatbot_using_tool`,n):(0,t.getVariableValue)(`chatbot_thinking`,n);return e.t(`div`,{className:`leadbot-chatbot-thinking`,children:[e.t(`span`,{className:`leadbot-chatbot-typing-dots`,children:[e.t(`span`,{}),e.t(`span`,{}),e.t(`span`,{})]}),e.t(`span`,{className:`leadbot-chatbot-thinking-text`,children:[i,`...`]})]})}var sa={start:{component:zt,autoAdvance:!0},message:{component:Rt,autoAdvance:!0},notification:{component:Bt,autoAdvance:!0},button:{component:Wt,autoAdvance:!1},html_embed:{component:Gt,autoAdvance:!0},whatsapp:{component:zn,autoAdvance:!1},callback_request:{component:Zr,autoAdvance:!1},email_request:{component:Qr,autoAdvance:!1},form_submit:{component:$r,autoAdvance:!1},chatbot:{component:ia,autoAdvance:!1}},ca=e=>sa[e]||(console.warn(`No component found for step type: ${e}`),{component:ei,autoAdvance:!1});function la(t){let{step:n}=t,r=ca(n.step_type).component;return e.t(r,{...t})}function ua(e){let t=e?.attributes?.tools;return Array.isArray(t)?t.map(e=>typeof e?.step_uuid==`string`?e.step_uuid:null).filter(e=>!!e):[]}function da(e){let t=new Set(e.flatMap(e=>[...e.options.map(e=>e.next_step_uuid),...ua(e)])),n=e.filter(e=>!t.has(e.uuid));if(n.length===0&&e.length>0){let t=0;for(let n=1;n<e.length;n++)(e[n].order??1/0)<(e[t].order??1/0)&&(t=n);return[t]}return n.map(t=>e.indexOf(t))}function fa(e,t,n){let r=e[t[n]]?.uuid;if(!r)return null;for(let i=n-1;i>=0;i--){let n=e[t[i]];if(u(n?.options??[]).some(e=>e.next_step_uuid===r))return i}return null}function pa(e,t,n){if(n===void 0||n<0||n>=t.length)return t;let r=n;if(e[t[n]]?.step_type===`button`){let i=fa(e,t,n);for(;r+1<t.length&&e[t[r+1]]?.step_type===`button`&&fa(e,t,r+1)===i;)r++}return t.slice(0,r+1)}function ma(e,t){return(e?.options??[]).some(e=>e.next_step_uuid===t)||ua(e).includes(t)}function ha(e,t,n=[]){let r=new Set(n),i=[t],a=new Set([t]),o=e[t]?.uuid;for(;o;){let t=o,n=e.flatMap((e,n)=>ma(e,t)?[n]:[]),s=n.find(e=>r.has(e))??n[0];if(s===void 0||a.has(s))break;i.unshift(s),a.add(s),o=e[s].uuid}return i}function*ga(e,t){let n=0;for(;n<t.length;){if(e[t[n]]?.step_type!==`button`){n++;continue}let r=n,i=fa(e,t,n);for(n++;n<t.length&&e[t[n]]?.step_type===`button`&&fa(e,t,n)===i;)n++;yield{start:r,end:n,parent:i}}}function _a(e,t){let n=new Set,r=t.map((n,r)=>{let i=e[n],a=new Set([...(i?.options??[]).map(e=>e.next_step_uuid),...ua(i)]);return t.slice(r+1).some(t=>a.has(e[t]?.uuid))}),i=new Set;for(let{start:a,end:o,parent:s}of ga(e,t)){let e=!1;for(let t=a;t<o;t++)e||=r[t];if(e)for(let e=a;e<o;e++)n.add(e);else s!==null&&i.add(s)}return t.forEach((t,a)=>{e[t]?.step_type!==`button`&&r[a]&&!i.has(a)&&n.add(a)}),n}var va=new Set;function ya(e,t){if(e.leadbot?.keep_open_on_navigation!==!0)return null;let n=Ci(t);if(!n)return null;let r=n.map(t=>e.steps.findIndex(e=>e.uuid===t));return r.every(e=>e!==-1)?r:null}function ba({config:n,active:r,sessionScope:i,restoredStepHistory:a,typingIndicator:o=!0,resetRef:s,openIntent:c,clearOpenIntent:l}){let f=d(n),p=n.leadbot?.keep_open_on_navigation===!0,m=n.leadbot?.hide_historical_steps===!0,[h,g]=e.l(a??[]),[_,v]=e.l(!1),y=e.o(null),b=e.o([]),x=e.o(!1),S=(0,t.getTracker)(),{t:C}=qt(n.leadbot?.language),w=e.s(()=>n.steps.map(e=>e.uuid),[n.steps]),T=()=>{for(let e of b.current)window.clearTimeout(e);b.current=[],v(!1)},E=e.f(()=>{T(),g([]),wi(f,i,w)},[f,i,w]);e.d(()=>{if(s)return s.current=E,()=>{s.current=void 0}},[s,E]);let[D,O]=e.l(null);e.d(()=>{p||wi(f,i,w)},[p,f,i,w]),e.d(()=>{p&&(!r||h.length===0||Si(i,h.map(e=>n.steps[e]?.uuid).filter(e=>!!e)))},[n.steps,i,r,p,h]),e.d(()=>{r||T()},[r]),e.d(()=>T,[]);let k=e=>{if(!e)return;let t=ca(e.step_type),n=u(e.options);if(!t?.autoAdvance||n.length===0)return;let r=e.attributes?.timer_next_action_enabled?e.attributes.timer_next_action??0:0,i=()=>{let e=n.map(e=>e.next_step_uuid).filter(e=>!!e);e.length>0&&j(e)};if(r>0){o&&v(!0);let e=window.setTimeout(()=>{v(!1),i()},r);b.current.push(e)}else i()},A=(e,t)=>{let r=!x.current;x.current=!0;try{g(r=>[...pa(n.steps,r,t),...e]),r&&T();for(let t of e)k(n.steps[t])}finally{r&&(x.current=!1)}},j=(e,r)=>{if(!e||Array.isArray(e)&&e.length===0)return;let i=(Array.isArray(e)?e:[e]).map(e=>n.steps.findIndex(t=>t.uuid===e)).filter(e=>e!==-1);if(i.length!==0){if(r!==void 0&&o){v(!0);let e=window.setTimeout(()=>{v(!1),A(i,r)},t.TYPING_INDICATOR_MS);b.current.push(e);return}A(i,r)}};e.d(()=>{if(!r||h.length>0)return;let e=da(n.steps);e.length!==0&&(g(e),k(n.steps[e[0]]))},[n.steps,r,h.length]),e.d(()=>{if(!c||!r||h.length===0)return;l?.();let e=n.steps.findIndex(e=>e.uuid===c.stepUuid);if(e===-1)return;let t=h.lastIndexOf(e),i=t!==-1;n.steps[e].step_type===`chatbot`&&(!i||M(e,t))&&O(c),i||(T(),g(t=>[...t,...ha(n.steps,e,t).filter(e=>!t.includes(e))]),k(n.steps[e]))},[l,n.steps,r,c,h]);let ee=e.o(!1);e.d(()=>{if(!r||ee.current||(ee.current=!0,!a||a.length===0))return;let e=n.steps[a[a.length-1]];if(!e)return;let t=new Set(a.map(e=>n.steps[e]?.uuid));u(e.options).some(e=>e.next_step_uuid&&t.has(e.next_step_uuid))||k(e)},[r]),e.d(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[h,_]);let M=(e,t)=>{let r=n.steps[e],i=new Set(r?.options?.map(e=>e.next_step_uuid)??[]);return!h.slice(t+1).some(e=>i.has(n.steps[e]?.uuid))},N=e.s(()=>m?_a(n.steps,h):va,[m,n.steps,h]),P=e.s(()=>{let e=new Map;for(let{start:t,end:r}of ga(n.steps,h))e.set(t,r);return e},[n.steps,h]),F=(t,r)=>e.t(`div`,{className:`leadbot-step-wrapper leadbot-step-buttons leadbot-step-current`,children:e.t(`div`,{className:`leadbot-options`,children:h.slice(t,r).map((r,i)=>{let a=n.steps[r],o=t+i;return e.t(la,{step:a,config:n,isCurrent:M(r,o),isFirstStep:!1,onOptionSelect:e=>j(e,o),analyticsTracker:S},`${a.uuid}-${o}`)})})},`btn-group-${h[t]}`);return e.t(`div`,{className:`leadbot-steps-container`,ref:y,role:`region`,"aria-label":C(`steps_container_label`,`Conversation`),children:[(()=>{let t=[],r=h.findIndex(e=>n.steps[e]?.step_type!==`start`),i=0;for(;i<h.length;){let a=P.get(i);if(a!==void 0){N.has(i)||t.push(F(i,a)),i=a;continue}let o=n.steps[h[i]];if(!o||N.has(i)){i++;continue}let s=M(h[i],i);t.push(e.t(`div`,{className:`leadbot-step-wrapper ${o.step_type===`chatbot`?`leadbot-step-wrapper--chat`:``} ${s?`leadbot-step-current`:``}`,children:e.t(la,{step:o,config:n,isCurrent:s,isFirstStep:i===r,onOptionSelect:e=>j(e,i),analyticsTracker:S,pendingMessage:D?.stepUuid===o.uuid?D.message:void 0,onPendingMessageConsumed:()=>O(null)})},`${o.uuid}-${i}`)),i++}return t})(),_&&e.t(`div`,{className:`leadbot-step-wrapper leadbot-step-current`,children:e.t(`div`,{className:`leadbot-step-typing`,children:e.t(`div`,{className:`leadbot-step-typing-dots`,children:[e.t(`span`,{}),e.t(`span`,{}),e.t(`span`,{})]})})})]})}function xa(e,t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${e}" aria-hidden="true" focusable="false" fill="currentColor">${t}</svg>`}function Sa(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">${e}</svg>`}function Ca(e=``,t=!1){return Sa(`${t?`<path d="M20 3.5H10a2 2 0 0 0-2 2v3" opacity="0.5"/>`:``}<path d="M4 6.5h14a2 2 0 0 1 2 2V15a2 2 0 0 1-2 2H10l-4.5 3.5V17H4a2 2 0 0 1-2-2V8.5a2 2 0 0 1 2-2Z"/>${e}`)}var wa=`<path d="M6.5 10.5h9M6.5 13.5h6"/>`,Ta=`<path d="M8.5 12s.9 1.5 2.5 1.5 2.5-1.5 2.5-1.5"/><circle cx="8.3" cy="10" r="0.6" fill="currentColor" stroke="none"/><circle cx="12.7" cy="10" r="0.6" fill="currentColor" stroke="none"/>`,Ea=`<path d="M9.5 9.5v3"/><circle cx="9.5" cy="14.5" r="0.75" fill="currentColor" stroke="none"/>`;S({"fal fa-paperclip":Sa(`<path d="M16.5 6.5 8.7 14.3a3 3 0 1 0 4.2 4.2l7.4-7.4a5 5 0 1 0-7.1-7.1L5.8 11.4a7 7 0 0 0 9.9 9.9"/>`),"fal fa-paper-plane":Sa(`<path d="M21 3 3 10.5l7.5 3L13.5 21 21 3Z"/><path d="M10.5 13.5 21 3"/>`),"fal fa-phone":Sa(`<path d="M6.6 10.8c1.4 2.8 3.8 5.2 6.6 6.6l2.2-2.2c.3-.3.7-.4 1.1-.3 1.2.4 2.5.6 3.8.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1C10.9 21 3 13.1 3 3.7c0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.6.6 3.8.1.4 0 .8-.3 1.1L6.6 10.8Z"/>`),"fal fa-envelope":Sa(`<rect x="3" y="5.5" width="18" height="13" rx="2"/><path d="m3.5 6.5 8.5 7 8.5-7"/>`),"fab fa-whatsapp":xa(`0 0 448 512`,`<path d="M380.9 97.1c-41.9-42-97.7-65.1-157-65.1-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480 117.7 449.1c32.4 17.7 68.9 27 106.1 27l.1 0c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3 18.6-68.1-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1s56.2 81.2 56.1 130.5c0 101.8-84.9 184.6-186.6 184.6zM325.1 300.5c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8s-14.3 18-17.6 21.8c-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7 .9-6.9-.5-9.7s-12.5-30.1-17.1-41.2c-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2s-9.7 1.4-14.8 6.9c-5.1 5.6-19.4 19-19.4 46.3s19.9 53.7 22.6 57.4c2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4s4.6-24.1 3.2-26.4c-1.3-2.5-5-3.9-10.5-6.6z"/>`),"fal fa-comment":Ca(),"fal fa-comment-lines":Ca(wa),"fal fa-comment-smile":Ca(Ta),"fal fa-comments":Ca(``,!0),"fal fa-comment-exclamation":Ca(Ea),"fal fa-comment-alt":Ca(),"fal fa-comment-alt-lines":Ca(wa),"fal fa-comment-alt-smile":Ca(Ta),"fal fa-comments-alt":Ca(``,!0),"fal fa-comment-alt-exclamation":Ca(Ea),"fal fa-rotate-left":Sa(`<path d="M4 9.5A8 8 0 1 1 5 15"/><path d="M4 4v5.5h5.5"/>`),"fal fa-thumbs-up":Sa(`<path d="M7 21H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h3m0 11V10m0 11 5.4-.1c1.9 0 3.6-1.1 4.3-2.9l2.1-5.4a1.6 1.6 0 0 0-1.5-2.2h-4.7l.7-4.2a2.1 2.1 0 0 0-3.8-1.6L7 10"/>`),"fal fa-thumbs-down":Sa(`<path d="M17 3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-3M17 3v11m0-11-5.4.1c-1.9 0-3.6 1.1-4.3 2.9l-2.1 5.4a1.6 1.6 0 0 0 1.5 2.2h4.7l-.7 4.2a2.1 2.1 0 0 0 3.8 1.6L17 14"/>`),"fa-kit fa-leadbot":xa(`0 0 448 512`,`<path d="M4 452.4c31.6 31.2 74.2 60.3 120.6 59.5 33-.5 63.7-20.2 69.8-54 8.2-45.2-20.9-89-49.7-121-19-21.1-40.6-40.6-63.7-57.2-13.3-9.5-28.9-19.6-45.4-22.6-13.8-2.5-28.7 1.1-33.7 15.7-4.5 13.2 1.5 28 7.4 39.7 10.1 20.3 25.1 38.5 40.3 55.2 19.5 21.7 40.9 41.7 64.8 58.7 34 24.1 75.4 43 117.9 42.3 32.3-.5 63.9-13.7 82-41.3 19.5-29.8 17.1-68.6 5.6-100.8-18.7-52.4-57.2-94.5-97.1-132.1-19.3-18.2-39.3-35.5-60.5-51.4-14.4-10.8-29.5-21.2-45.8-29.1-17.8-8.6-49.2-20-61.3 3.5-5.2 10.2-3.3 22.6 .1 33 5 14.9 12.9 28.7 21.5 41.7 29.3 44.4 67.1 85.1 106.5 120.6 36.2 32.6 77.8 62 124.8 76.8 30.9 9.8 66.3 12.7 96.1-2.3 26.8-13.5 40.9-40.7 43.3-69.7 3.2-38.7-13.4-77.8-32.8-110.3-29.8-49.9-71.5-92.7-115.4-130.4-33.1-28.3-69.7-56-111.4-70.5-12.2-4.3-25.7-7.3-38.7-6.3-7.3 .5-13.5 5.8-13.5 13.5 0 6.9 6.2 14 13.5 13.5 2.3-.2 4.6-.2 6.9-.1 1.2 .1 2.5 .2 3.7 .3 3.9 .3-1.7-.5 2.3 .3 6.3 1.2 12.5 2.8 18.6 4.9 13.5 4.7 28.2 12.4 42.1 21 42.8 26.4 81 61.2 115.2 97.8 30.3 32.5 59 70.1 73.9 112 2.8 7.8 5.1 15.8 6.7 23.9 1.5 7.6 2.1 11.4 2.2 20.2 .1 3.2 0 6.5-.3 9.7-.1 1.6-.3 3.1-.5 4.6 .4-3.2-.4 2.2-.6 3.1-.6 2.8-1.3 5.7-2.2 8.4-.4 1.3-.9 2.7-1.4 4-.2 .6-1 2.4 .2-.3-.3 .8-.7 1.6-1.1 2.3-1.2 2.4-2.5 4.8-3.9 7.1-.8 1.3-1.7 2.5-2.5 3.7 1.9-2.6-.6 .7-1.3 1.5-1.8 2-3.7 3.7-5.6 5.5-.5 .4-1 .8-1.5 1.3-1.4 1.2 1.9-1.4 .4-.3-1.2 .9-2.4 1.7-3.7 2.6-2.3 1.5-4.6 2.8-7.1 4-.9 .4-4.3 1.8-1.5 .7-1.6 .6-3.3 1.3-5 1.8-2.8 .9-5.6 1.6-8.5 2.2-1.5 .3-3 .6-4.5 .8-2.6 .4-.3 .1 .2 0-1.2 .1-2.3 .3-3.5 .4-15.7 1.3-26.9-.2-41.2-3.9-18.2-4.6-34.7-11.7-51.1-20.7-44.9-24.6-82.4-59.8-117.2-97-26.6-28.5-53.8-59.1-71.2-94.3-.7-1.4-1.3-2.7-2-4.1-1.6-3.4 0 .3-.7-1.7-1-2.7-2-5.3-2.8-8-.6-2.1-.9-4.2-1.5-6.3-.6-2.1 0 3.4 0 0 0-1-.1-2-.1-2.9 0-.6 .3-3.8-.1-.9-.3 2.8 .1 0 .2-.6 .2-.9 1.4-2.7 .1-.5-2.1 3.5 2.2-2.8-.3 .5-1.6 2.2-.2 .3 .3-.1 .3-.3-3.3 2.2-.9 .8 2.3-1.4-.9 .4-1 .3 .3 .1 1.8-.6 2.3-.6 1.5-.2-3.8-.1-.8 .1 .8 .1 1.7-.1 2.5 0 .9 0 1.8 .2 2.7 .2-4.5-.1-.5 0 .8 .3 2.2 .5 4.4 1.1 6.6 1.8 1.2 .4 2.4 .8 3.6 1.3 .6 .2 1.2 .5 1.9 .7 2.7 1-2.3-1.1 .6 .3 13.8 6.1 26.6 14.1 39 22.8 18 12.6 34.9 26.7 51.2 41.3 20.9 18.7 41.4 38.2 59.7 59.6 15.2 17.8 28.7 37.1 39 58.1 4.1 8.3 7.4 16.8 10.1 25.7 2.2 7.6 4.1 16.4 4.6 22.2 1.5 15.4 .7 25.3-4.9 39.4 1-2.6-.6 1.3-1 2-1.3 2.7-2.8 5.3-4.5 7.8-.5 .8-3.7 5-1.8 2.7-1.9 2.3-3.8 4.5-6 6.6-1.1 1-2.2 2-3.3 3-.6 .5-1.1 1-1.7 1.4 1.5-1.2 .6-.4-.4 .3-2.5 1.7-5 3.4-7.7 4.8-1.3 .7-2.7 1.4-4.1 2.1-.7 .3-1.4 .7-2.1 1-1.4 .6 1.8-.7-.6 .2-6.6 2.4-13.3 4.2-20.2 5.2 2.5-.4-2 .2-2.8 .3-1.8 .2-3.5 .3-5.3 .3-4.1 .2-8.3 .1-12.4-.2-8.1-.5-13.4-1.4-22.1-3.5-41.9-10.2-78.7-36.2-109.2-65.8-17.1-16.6-33.7-34.5-47.2-54.2-4.8-7-9.1-14.3-12.8-21.9-.4-.7-.7-1.5-1-2.3 1 2.3 .2 .5 0 0-.5-1.4-1-2.7-1.4-4.1-.4-1.2-.7-2.5-1-3.8-.1-.6-.2-1.2-.4-1.8-.7-2.5-.2 2.7 0 .3 .1-.8 .1-2.2-.1-3-.4-1.8-1 3.2 0 .3 1-2.9-1.1 1.8-.3 .5 1.5-2.6-2.1 2-.3 .3 1.8-1.7-3.1 1.9-.3 .3 1.8-1-3.5 1.3-.5 .3 2.7-.9-1.8-.3-.3 0 .9 .2 2.5 .1 3.4 .1-.8 0-2.3-.6 .6 .2 1.2 .3 2.5 .6 3.7 .9 1.4 .4 2.7 .9 4 1.3 .7 .3 1.4 .5 2.1 .8 1.4 .5-1.6-.8 .7 .3 7.6 3.7 14.9 7.9 21.9 12.7 20.2 13.7 38.5 30.6 55.5 48.1 16.7 17.3 31.7 36.4 42 58.2 7 15 10.3 28.7 8.8 44.3-.2 2.2 .4-2.1 0 0-.1 .8-.3 1.6-.4 2.4-.4 1.7-.8 3.4-1.3 5.1-.4 1.5-.9 2.9-1.5 4.3 1.1-2.8-.8 1.6-1.2 2.3-.7 1.3-1.5 2.5-2.3 3.7-.4 .6-.8 1.2-1.2 1.8-1.1 1.6 1.4-1.7 .1-.2-2 2.3-4.1 4.5-6.5 6.4 2.3-1.9-.9 .6-1.7 1.1-1.2 .8-2.5 1.6-3.8 2.3-1.3 .7-2.7 1.4-4 2 2.7-1.2-2.4 .8-3.3 1.1-3.1 .9-6.2 1.7-9.4 2.2 2.6-.4-1.8 .2-2.7 .2-2.2 .2-4.4 .2-6.6 .2-8.7-.1-13-.8-21.3-2.9-8.4-2.2-16.4-5.2-24.1-9-20.3-10-38-23.9-54-39.8-12.4-12.2-31.6 6.8-19.2 19.1l0 0z"/>`),"fa-kit fa-default-avatar":xa(`0 0 448 512`,`<path d="M113.2 84.6c44.7 1.1 83-22.9 123.1-39.1 10.5-4.5 21.5-7.8 32.8-9.9 5.2-.8 10.4-1.1 15.6-1 4.5 0 9 .4 13.5 1.1 8.6 1.3 16.7 4.7 23.6 10.1S334 58.2 337.3 66.3c-.7-1.6 0 .4 .2 .6 .5 1.7 1.2 3.4 1.7 5s1.2 4.3 1.6 6.5c1 4.7 1.5 9.5 1.6 14.3 .1 5.1-.1 10.2-.6 15.3-.2 2.1-.5 4.1-.9 6.2-.5 2.7-1.1 5.4-1.7 8-.6 2.2-.5 4.4 0 6.6s1.7 4.1 3.3 5.7 3.5 2.7 5.7 3.3 4.4 .6 6.6 0c1.1-.4 2.3-.6 3.5-.9l3.6-.7 2.3-.4c-3.1 .3 3-.5 0 0 4.3-.5 8.7-.6 13-.4l3 .2c3.6 .3-2.2-.5 .9 0 2.5 .4 5 1 7.4 1.7 1.2 .4 2.3 .9 3.5 1.2s-2.8-1.4-.4 0c.5 .3 1.1 .5 1.5 .7 1.2 .6 2.3 1.2 3.4 1.9 .8 .5 4.7 3.5 2.1 1.3 2 1.7 3.9 3.6 5.6 5.5 .5 .5 1.8 2.3 0 0 .4 .5 .8 1.1 1.2 1.6 1 1.4 1.9 3 2.7 4.5 .3 .6 .7 1.3 1 2 0 0 1.4 3.2 .7 1.6s.7 2 .7 1.8c.3 .8 .5 1.6 .7 2.4 1.3 4 2.2 8.1 2.8 12.2 .6 4.7 .7 9.4 .5 14 0 2.2-.2 4.3-.4 6.5s0 1.3 0 .7c0 1.3-.4 2.5-.7 3.9-.8 4-1.8 7.9-3.1 11.7-.5 1.6-1.3 3.1-1.7 4.7s1.3-2.7 0-.2c-.4 .7-.7 1.4-1 2.2-1.2 2.5-2.5 5-4.1 7.3-1.7 3-2.2 6.5-1.3 9.8s3 6.1 6 7.9 6.5 2.2 9.8 1.3 6.1-3 7.9-6c5.6-8.6 9.6-18.1 11.7-28.1 5-19.9 3.8-40.9-3.4-60.1-5.4-14.6-16.2-26.6-30.3-33.3-11.1-4.9-23.1-7-35.2-6.1-7 .3-13.9 1.4-20.6 3.3l15.6 15.6c10.1-41.3 2.3-92.2-40.4-111.7-22.9-10.4-49.8-9.9-73.6-3.3-22.1 6.1-42.7 16.8-63.5 26.2-22.6 10.2-47.6 19.6-73.1 18.9-16.4-.4-16.4 25 0 25.4l0 0zM213.3 329.4c-2 1.1-3.9 2-6.1 3l-1.4 .6 .5-.2-2.7 1c-2.1 .8-4.3 1.4-6.6 1.8 3.1-.5 0 0-.5-.2 2.3 .7-.5-1 0 .2l2.5 3.2c0 .6 .2 .4 0-.4 .3-1.8 .3-3.7 0-5.6 0-7 .2-14 .3-20.9 .4-26.6 .8-53.1 1.1-79.7 0-16.4-25.2-16.4-25.4 0-.4 31.3-.8 62.6-1.3 93.8 0 8.3-1.5 17.8 3.2 25.1 2.6 3.4 6 6.2 9.9 7.8s8.3 2.3 12.5 1.7c9.5-1.3 18.6-4.5 26.8-9.4 14.4-7.8 1.5-29.9-12.8-21.9l0 .1zm-77-53.7c16.4 0 16.4-25.4 0-25.4s-16.4 25.4 0 25.4zm111.9-1.1l1.5 0c3.4-.2 6.6-1.6 9-3.9 2.3-2.4 3.7-5.6 3.9-9l-.4-3.4c-.6-2.1-1.7-4-3.3-5.6l-2.6-2c-1.9-1.1-4.2-1.8-6.4-1.8l-1.5 0c-1.7-.1-3.4 .3-4.9 1.1-1.6 .5-3 1.4-4.1 2.7-2.3 2.5-3.6 5.6-3.7 9l.5 3.4c.6 2.1 1.7 4 3.2 5.6l2.6 2c1.9 1.2 4.2 1.7 6.4 1.7l-.2 .2zM72.9 6.9c-32.5 35.6-63.1 79.6-65.6 129.4-1.1 21.8 4.3 45.5 17.5 63.2 11.2 14.2 27.3 23.7 45.2 26.6 3.2 .8 6.7 .3 9.6-1.3s5.1-4.4 6.1-7.5c.9-3.3 .4-6.7-1.3-9.6s-4.4-5.1-7.6-6c-12-1.6-23.1-7.4-31.3-16.4-1.4-1.6 2.3 3.2 .8 1.1-.4-.5-.7-1.1-1.1-1.6-.9-1.3-1.7-2.5-2.5-3.9s-1.8-3.2-2.7-4.8c-.5-.9-.9-1.9-1.4-2.9s-.4-.9-.6-1.4c-.8-1.6 1.2 3.1 .4 .8-1.8-4.8-3.3-9.6-4.4-14.6-.3-1.4-.5-2.9-.8-4.4s-.5-.8 0 .5c-.2-.8-.3-1.7-.3-2.5-.3-3.2-.5-6.5-.5-9.8s0-7.1 .5-10.7c0-1 .2-2.1 .4-3.1-.2 2.2-.2 1.1 0-.3 .3-2.1 .7-4.1 1.1-6.2 .9-4.3 2-8.4 3.3-12.6 .7-2.2 1.4-4.3 2.2-6.4 .4-1.1 .8-2.2 1.2-3.2l1.1-2.9c.4-1.1 2.3-5.3 3.5-7.6s2.7-5.6 4.2-8.3c3.2-5.9 6.7-11.7 10.4-17.4 9.1-13.5 19.2-26.3 30.3-38.2 2.3-2.4 3.6-5.6 3.6-9s-1.3-6.6-3.6-9c-2.4-2.4-5.6-3.7-9-3.7s-6.6 1.3-9 3.7l.3 .1zm-14.3 255c1.4 50.6 5.4 103.2 22.2 151.4 10.2 29.1 25.7 56.7 51.1 75.1 18.8 13.6 41.8 19.2 64.7 20.4 42.7 2.2 84.7-12 112.8-45.1 28.9-34 41.1-78.2 46.2-121.8 .6-5.4 1.1-10.8 1.5-16.2l-9.4 12.2c24.8-8.6 49-28.4 48.3-57.1-.1-6.8-1.7-13.5-4.8-19.5s-7.6-11.3-13-15.3c-5.7-3.8-12.2-6.2-18.9-7.2s-13.7-.4-20.2 1.6l16.1 12.3c-1.5-15.2-4.6-30.2-9.1-44.8-4.3-12.5-10.8-24.1-19.2-34.4-12.9-16.5-31.2-27.9-51.7-32.1-36.6-6.8-71.3 9.8-102.2 27.6-28.9 16.6-61.3 38.4-96.4 32.6-3.2-.8-6.7-.3-9.6 1.3s-5.1 4.3-6.1 7.5c-1.7 6.1 2.1 14.5 8.9 15.6 33.5 5.5 64.2-6 93.1-22 13.6-7.5 26.8-15.6 40.6-22.9 11.5-5.9 23.6-10.5 36.2-13.8 2.4-.6 4.8-1.3 7.2-1.7l1.7-.3c2-.4-3.3 .4-1.2 0 1.4 0 2.8-.3 4.2-.4 3-.2 6.1-.2 9.1 0 1.5 0 3.1 .2 4.6 .4l1.6 0s-2.7-.5-1.3-.2l2.9 .5c3.8 .7 7.6 1.7 11.3 3.1 .4 0 3.6 1.4 2.1 .7s1.2 .5 1.6 .7c2.2 1 4.3 2.2 6.3 3.4 1.9 1.1 3.6 2.3 5.4 3.6-1.4-1.2 1.8 1.2 0 0l1.3 1.1c1.1 .9 2.1 1.8 3.1 2.7 4.3 3.9 8.2 8.3 11.5 13.2 1.9 2.9 3.7 5.8 5.4 8.8 1 1.8 1.9 3.5 2.8 5.3 .4 .8 1.4 3.4 .6 1.1 5 13.9 8.3 28.3 9.9 43 1 7.8 7.3 14.7 16.1 12.2 3-1 6.1-1.4 9.3-1s6.1 1.4 8.8 3.1c5.5 4.1 6.8 9.9 6.6 16.8-.3 2.7-1 5.3-2.1 7.8-1.5 3.4-3.7 6.4-6.3 9.1-6 5.9-13.2 10.3-21.2 12.9-2.6 .8-4.9 2.4-6.6 4.6s-2.6 4.8-2.7 7.6c-.4 5.2-.8 10.4-1.4 15.6 0 1.2-.3 2.4-.4 3.6s-.5 3.6 0 1.4c-.4 2.6-.8 5.2-1.2 7.8-1.6 10.2-3.8 20.2-6.6 30.1-4.7 18.7-12.6 36.4-23.5 52.3-1.3 1.9-2.6 3.7-3.9 5.6s.7-.8-.8 1c-1 1.2-1.9 2.3-2.9 3.5-3.1 3.6-6.3 6.9-9.8 10.1-1.6 1.5-3.4 3-5.1 4.4l-1.3 1.1c.4-.3 1.8-1.4 0 0l-3.2 2.3c-3.9 2.7-8 5.2-12.3 7.4-2.1 1.1-4.2 2.1-6.3 3 2-.9-1.3 .5-1.9 .8l-3.9 1.4c-4.9 1.7-9.9 3.1-15 4.1-1.3 .2-2.5 .5-3.9 .7l-2.9 .5c-1.3 0-5.9 .6-8.4 .8-4.5 .3-9 .4-13.5 .4s-9.9-.3-14.8-.9c-.8 0-4.6-.5-2-.2s-1.7-.3-2.6-.4c-2.4-.4-4.8-.9-7.2-1.4-4.9-1.1-9.7-2.6-14.3-4.4l-1.6-.7c-.4 0 2.9 1.3 .5 .2l-3.5-1.7c-2.3-1.1-4.5-2.4-6.7-3.7s-4.6-3-6.8-4.6-.6 0 .5 .4c-.6-.3-1.1-.8-1.5-1.2l-3.2-2.8c-4.4-4-8.5-8.3-12.2-13-1.1-1.4-.8-1.2 0 .2l-1.6-2.1c-1-1.4-1.9-2.7-2.9-4.1-1.9-2.9-3.7-5.7-5.4-8.7s-3.6-6.6-5.2-10.1c-.8-1.6-1.6-3.3-2.3-5-.2-.4-1.3-3.1-.7-1.5s-.6-1.5-.8-2.1c-7-18-12.2-36.6-15.6-55.6-2.3-12-3.9-22.2-5-33.6-1.6-13.8-2.6-27.6-3.4-41.4-.4-7.8-.7-15.6-.9-23.5-.1-3.3-1.4-6.5-3.8-8.9s-5.6-3.7-8.9-3.8c-3.4 0-6.6 1.4-9 3.8s-3.7 5.6-3.8 9l.1 .2z"/>`),"__internal-chevron-right":Sa(`<path d="m9 6 6 6-6 6"/>`)});function Da(e){return!!e?.styling&&Array.isArray(e?.steps)}function Oa({config:t,sessionScope:r,baseColor:i,typingIndicator:a}){let[o]=e.l(()=>Da(t)?ya(t,r):null);return Da(t)?e.t(n,{children:e.t(`div`,{className:`leadbot-flow-conversation`,lang:t.leadbot?.language||void 0,style:{"--leadbot-primary":i||t.styling.base_color||`#2563eb`},children:e.t(ba,{config:t,active:!0,sessionScope:r,restoredStepHistory:o,typingIndicator:a})})}):(console.error(`LeadBot: Invalid config`),null)}function ka(e,t){Aa(e,`--leadbot-flow-max-width`,t?.maxWidth),Aa(e,`--leadbot-flow-align`,t?.align),Aa(e,`--leadbot-powered-by-justify`,t?.poweredByAlign)}function Aa(e,t,n){n?e.style.setProperty(t,n):e.style.removeProperty(t)}function ja(e){try{return(0,t.resolveApiBase)(e)}catch{return null}}var Ma=`leadbot-flow`;function Na(n){let[r,i]=e.l(null),[a,o]=e.l(0);e.d(()=>{if(!n.path)return(0,t.onUrlChange)(()=>o(e=>e+1))},[n.path]);let{domainKey:s,apiHost:c,leadbotId:l,path:u,language:d,previewToken:f,preview:p}=n,h=JSON.stringify([s,c,l,u,d,f,p,a]);e.d(()=>{let t=!0;return e.v({domainKey:s,apiHost:c,leadbotId:l,path:u,language:d,previewToken:f,preview:p}).then(e=>{t&&i({key:h,flow:e??null})}),()=>{t=!1}},[h]);let g=ja(e.S(n));e.d(()=>{m(g)},[g]);let _=r?.key===h?r.flow:null;if(!_)return null;let v=e.S(n),y=`${v.domainKey??`default`}#flow-${v.leadbotId??``}`;return e.O(Oa,{key:`${a}:${v.leadbotId??``}:${n.path??``}`,config:_,sessionScope:y,baseColor:v.baseColor,typingIndicator:n.typingIndicator})}function Pa(t,n={}){t.classList.add(Ma),ka(t,n.layout);let r=e.h(Na,t,n);return{update(e){`layout`in e&&ka(t,e.layout),r.update(e)},destroy(){ka(t,void 0),t.classList.remove(Ma),r.destroy()}}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Pa}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ma}});
@@ -59,7 +59,7 @@ function me(e) {
59
59
  }
60
60
  //#endregion
61
61
  //#region ../../src/conditions/time.ts
62
- function he(e) {
62
+ function V(e) {
63
63
  if (!e || e.length === 0) return !1;
64
64
  let t = /* @__PURE__ */ new Date(), n = t.getHours() * 60 + t.getMinutes();
65
65
  return e.some((e) => {
@@ -76,45 +76,45 @@ function he(e) {
76
76
  }
77
77
  //#endregion
78
78
  //#region ../../src/conditions/index.ts
79
- var ge = {
79
+ var he = {
80
80
  device: me,
81
81
  day: B,
82
- time: he
82
+ time: V
83
83
  };
84
- function _e(e) {
85
- let { condition_type: t, eval: n, evaluates: r } = e, i = ge[t];
84
+ function ge(e) {
85
+ let { condition_type: t, eval: n, evaluates: r } = e, i = he[t];
86
86
  if (!i) return console.warn(`Unknown condition type: ${t}`), !0;
87
87
  let a = i(n);
88
88
  return r ? a : !a;
89
89
  }
90
- function ve(e) {
91
- return !e.conditions || e.conditions.length === 0 || e.conditions.every((e) => _e(e));
90
+ function _e(e) {
91
+ return !e.conditions || e.conditions.length === 0 || e.conditions.every((e) => ge(e));
92
92
  }
93
- function ye(e) {
94
- return e.filter((e) => ve(e));
93
+ function ve(e) {
94
+ return e.filter((e) => _e(e));
95
95
  }
96
96
  //#endregion
97
97
  //#region ../../src/utils/domainKey.ts
98
- function be(e) {
98
+ function ye(e) {
99
99
  return e?.leadbot?.domain?.domain_key || null;
100
100
  }
101
101
  //#endregion
102
102
  //#region ../../src/config.ts
103
- var xe = {
103
+ var be = {
104
104
  API_BASE: "https://collector.leadbot.com/api",
105
105
  CSS_CLASSES: {
106
106
  CONTAINER: "leadbot-widget",
107
107
  HIDDEN: "leadbot-hidden",
108
108
  LOADING: "leadbot-loading"
109
109
  }
110
- }, V = null;
110
+ }, xe = null;
111
111
  function Se(e) {
112
- V = e ? e.replace(/\/+$/, "") : null;
112
+ xe = e ? e.replace(/\/+$/, "") : null;
113
113
  }
114
114
  function Ce(e) {
115
- if (V) return V + e;
115
+ if (xe) return xe + e;
116
116
  let t = we();
117
- return re(t ? { apiHost: t } : { apiBase: xe.API_BASE }) + e;
117
+ return re(t ? { apiHost: t } : { apiBase: be.API_BASE }) + e;
118
118
  }
119
119
  function we() {
120
120
  let e = document.getElementsByTagName("script");
@@ -577,7 +577,7 @@ function dn() {
577
577
  enumerable: !0,
578
578
  value: !1
579
579
  }
580
- })), pe = null, me = null, he = Object.seal(it(null, {
580
+ })), pe = null, me = null, V = Object.seal(it(null, {
581
581
  tagCheck: {
582
582
  writable: !0,
583
583
  configurable: !1,
@@ -590,7 +590,7 @@ function dn() {
590
590
  enumerable: !0,
591
591
  value: null
592
592
  }
593
- })), ge = !0, _e = !0, ve = !1, ye = !0, be = !1, xe = !0, V = !1, Se = !1, Ce = null, we = null, Te = !1, Ee = !1, De = !1, Oe = !1, ke = !0, Ae = !1, je = "user-content-", H = !0, Me = !1, Ne = {}, U = null, Pe = Z({}, /* @__PURE__ */ "annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp".split(".")), Fe = null, Ie = Z({}, [
593
+ })), he = !0, ge = !0, _e = !1, ve = !0, ye = !1, be = !0, xe = !1, Se = !1, Ce = null, we = null, Te = !1, Ee = !1, De = !1, Oe = !1, ke = !0, Ae = !1, je = "user-content-", H = !0, Me = !1, Ne = {}, U = null, Pe = Z({}, /* @__PURE__ */ "annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp".split(".")), Fe = null, Ie = Z({}, [
594
594
  "audio",
595
595
  "video",
596
596
  "img",
@@ -639,9 +639,9 @@ function dn() {
639
639
  }), Fe = ln(e, "ADD_DATA_URI_TAGS", Ie, {
640
640
  transform: G,
641
641
  base: Ie
642
- }), U = ln(e, "FORBID_CONTENTS", Pe, { transform: G }), pe = ln(e, "FORBID_TAGS", Q({}), { transform: G }), me = ln(e, "FORBID_ATTR", Q({}), { transform: G }), Ne = J(e, "USE_PROFILES") ? e.USE_PROFILES && typeof e.USE_PROFILES == "object" ? Q(e.USE_PROFILES) : e.USE_PROFILES : !1, ge = e.ALLOW_ARIA_ATTR !== !1, _e = e.ALLOW_DATA_ATTR !== !1, ve = e.ALLOW_UNKNOWN_PROTOCOLS || !1, ye = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, be = e.SAFE_FOR_TEMPLATES || !1, xe = e.SAFE_FOR_XML !== !1, V = e.WHOLE_DOCUMENT || !1, Ee = e.RETURN_DOM || !1, De = e.RETURN_DOM_FRAGMENT || !1, Oe = e.RETURN_TRUSTED_TYPE || !1, Te = e.FORCE_BODY || !1, ke = e.SANITIZE_DOM !== !1, Ae = e.SANITIZE_NAMED_PROPS || !1, H = e.KEEP_CONTENT !== !1, Me = e.IN_PLACE || !1, ue = At(e.ALLOWED_URI_REGEXP) ? e.ALLOWED_URI_REGEXP : qt, Ve = typeof e.NAMESPACE == "string" ? e.NAMESPACE : W, Ke = un(e, "MATHML_TEXT_INTEGRATION_POINTS", () => Z({}, Ge)), Je = un(e, "HTML_INTEGRATION_POINTS", () => Z({}, qe));
642
+ }), U = ln(e, "FORBID_CONTENTS", Pe, { transform: G }), pe = ln(e, "FORBID_TAGS", Q({}), { transform: G }), me = ln(e, "FORBID_ATTR", Q({}), { transform: G }), Ne = J(e, "USE_PROFILES") ? e.USE_PROFILES && typeof e.USE_PROFILES == "object" ? Q(e.USE_PROFILES) : e.USE_PROFILES : !1, he = e.ALLOW_ARIA_ATTR !== !1, ge = e.ALLOW_DATA_ATTR !== !1, _e = e.ALLOW_UNKNOWN_PROTOCOLS || !1, ve = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, ye = e.SAFE_FOR_TEMPLATES || !1, be = e.SAFE_FOR_XML !== !1, xe = e.WHOLE_DOCUMENT || !1, Ee = e.RETURN_DOM || !1, De = e.RETURN_DOM_FRAGMENT || !1, Oe = e.RETURN_TRUSTED_TYPE || !1, Te = e.FORCE_BODY || !1, ke = e.SANITIZE_DOM !== !1, Ae = e.SANITIZE_NAMED_PROPS || !1, H = e.KEEP_CONTENT !== !1, Me = e.IN_PLACE || !1, ue = At(e.ALLOWED_URI_REGEXP) ? e.ALLOWED_URI_REGEXP : qt, Ve = typeof e.NAMESPACE == "string" ? e.NAMESPACE : W, Ke = un(e, "MATHML_TEXT_INTEGRATION_POINTS", () => Z({}, Ge)), Je = un(e, "HTML_INTEGRATION_POINTS", () => Z({}, qe));
643
643
  let t = un(e, "CUSTOM_ELEMENT_HANDLING", () => it(null));
644
- if (B = it(null), J(t, "tagNameCheck") && tt(t.tagNameCheck) && (B.tagNameCheck = t.tagNameCheck), J(t, "attributeNameCheck") && tt(t.attributeNameCheck) && (B.attributeNameCheck = t.attributeNameCheck), J(t, "allowCustomizedBuiltInElements") && typeof t.allowCustomizedBuiltInElements == "boolean" && (B.allowCustomizedBuiltInElements = t.allowCustomizedBuiltInElements), q(B), be && (_e = !1), De && (Ee = !0), Ne && (R = Z({}, Lt), z = it(null), Ne.html === !0 && (Z(R, jt), Z(z, Rt)), Ne.svg === !0 && (Z(R, Mt), Z(z, zt), Z(z, Vt)), Ne.svgFilters === !0 && (Z(R, Nt), Z(z, zt), Z(z, Vt)), Ne.mathMl === !0 && (Z(R, Ft), Z(z, Bt), Z(z, Vt))), he.tagCheck = null, he.attributeCheck = null, J(e, "ADD_TAGS") && (typeof e.ADD_TAGS == "function" ? he.tagCheck = e.ADD_TAGS : pt(e.ADD_TAGS) && (R === de && (R = Q(R)), Z(R, e.ADD_TAGS, G))), J(e, "ADD_ATTR") && (typeof e.ADD_ATTR == "function" ? he.attributeCheck = e.ADD_ATTR : pt(e.ADD_ATTR) && (z === fe && (z = Q(z)), Z(z, e.ADD_ATTR, G))), J(e, "ADD_FORBID_CONTENTS") && pt(e.ADD_FORBID_CONTENTS) && (U === Pe && (U = Q(U)), Z(U, e.ADD_FORBID_CONTENTS, G)), H && (R["#text"] = !0), V && Z(R, [
644
+ if (B = it(null), J(t, "tagNameCheck") && tt(t.tagNameCheck) && (B.tagNameCheck = t.tagNameCheck), J(t, "attributeNameCheck") && tt(t.attributeNameCheck) && (B.attributeNameCheck = t.attributeNameCheck), J(t, "allowCustomizedBuiltInElements") && typeof t.allowCustomizedBuiltInElements == "boolean" && (B.allowCustomizedBuiltInElements = t.allowCustomizedBuiltInElements), q(B), ye && (ge = !1), De && (Ee = !0), Ne && (R = Z({}, Lt), z = it(null), Ne.html === !0 && (Z(R, jt), Z(z, Rt)), Ne.svg === !0 && (Z(R, Mt), Z(z, zt), Z(z, Vt)), Ne.svgFilters === !0 && (Z(R, Nt), Z(z, zt), Z(z, Vt)), Ne.mathMl === !0 && (Z(R, Ft), Z(z, Bt), Z(z, Vt))), V.tagCheck = null, V.attributeCheck = null, J(e, "ADD_TAGS") && (typeof e.ADD_TAGS == "function" ? V.tagCheck = e.ADD_TAGS : pt(e.ADD_TAGS) && (R === de && (R = Q(R)), Z(R, e.ADD_TAGS, G))), J(e, "ADD_ATTR") && (typeof e.ADD_ATTR == "function" ? V.attributeCheck = e.ADD_ATTR : pt(e.ADD_ATTR) && (z === fe && (z = Q(z)), Z(z, e.ADD_ATTR, G))), J(e, "ADD_FORBID_CONTENTS") && pt(e.ADD_FORBID_CONTENTS) && (U === Pe && (U = Q(U)), Z(U, e.ADD_FORBID_CONTENTS, G)), H && (R["#text"] = !0), xe && Z(R, [
645
645
  "html",
646
646
  "head",
647
647
  "body"
@@ -748,9 +748,9 @@ function dn() {
748
748
  if (n) for (let e = n.length - 1; e >= 0; --e) t.push(n[e]);
749
749
  }
750
750
  }, nn = function(e, t) {
751
- return xe ? e === "patchsrc" || e === "for" && t !== "label" && t !== "output" : !1;
751
+ return be ? e === "patchsrc" || e === "for" && t !== "label" && t !== "output" : !1;
752
752
  }, fn = function(e) {
753
- if (!xe) return;
753
+ if (!be) return;
754
754
  let t = [e];
755
755
  for (; t.length > 0;) {
756
756
  let e = t.pop(), n = S(e);
@@ -788,7 +788,7 @@ function dn() {
788
788
  } catch {}
789
789
  }
790
790
  let a = t.body || t.documentElement;
791
- return e && r && a.insertBefore(n.createTextNode(r), a.childNodes[0] || null), Ve === W ? P.call(t, V ? "html" : "body")[0] : V ? t.documentElement : a;
791
+ return e && r && a.insertBefore(n.createTextNode(r), a.childNodes[0] || null), Ve === W ? P.call(t, xe ? "html" : "body")[0] : xe ? t.documentElement : a;
792
792
  }, mn = function(e) {
793
793
  let t = x ? x(e) : e.ownerDocument;
794
794
  return ne.call(t || e, e, c.SHOW_ELEMENT | c.SHOW_COMMENT | c.SHOW_TEXT | c.SHOW_PROCESSING_INSTRUCTION | c.SHOW_CDATA_SECTION, null);
@@ -826,7 +826,7 @@ function dn() {
826
826
  });
827
827
  }
828
828
  let xn = function(e, t) {
829
- return !!(xe && e.hasChildNodes() && !yn(e.firstElementChild) && Y(Qt, e.textContent) && Y(Qt, e.innerHTML) || xe && e.namespaceURI === W && rn[t] && (yn(e.firstElementChild) || typeof e.textContent == "string" && Y(an[t], e.textContent)) || e.nodeType === $.processingInstruction || xe && e.nodeType === $.comment && Y($t, e.data));
829
+ return !!(be && e.hasChildNodes() && !yn(e.firstElementChild) && Y(Qt, e.textContent) && Y(Qt, e.innerHTML) || be && e.namespaceURI === W && rn[t] && (yn(e.firstElementChild) || typeof e.textContent == "string" && Y(an[t], e.textContent)) || e.nodeType === $.processingInstruction || be && e.nodeType === $.comment && Y($t, e.data));
830
830
  }, Sn = function(e, t) {
831
831
  return e instanceof RegExp ? Y(e, t) : e instanceof Function && !!e(t, ...[...arguments].slice(2));
832
832
  }, Cn = function(e, t, n) {
@@ -855,20 +855,20 @@ function dn() {
855
855
  allowedTags: R
856
856
  }), Tn(e, n)) return !0;
857
857
  if (xn(e, r)) return St(e), !0;
858
- if (pe[r] || !(he.tagCheck instanceof Function && he.tagCheck(r)) && !R[r]) {
858
+ if (pe[r] || !(V.tagCheck instanceof Function && V.tagCheck(r)) && !R[r]) {
859
859
  let t = Cn(e, r, n);
860
860
  return t === !1 && bn(I.afterSanitizeElements, e, null), t;
861
861
  }
862
862
  if (S(e) === $.element && !xt(e) || (r === "noscript" || r === "noembed" || r === "noframes") && Y(en, e.innerHTML)) return St(e), !0;
863
- if (be && e.nodeType === $.text) {
863
+ if (ye && e.nodeType === $.text) {
864
864
  let n = hn(e.textContent);
865
865
  e.textContent !== n && (dt(t.removed, { element: e.cloneNode() }), e.textContent = n);
866
866
  }
867
867
  return bn(I.afterSanitizeElements, e, null), !1;
868
868
  }, Dn = function(e, t, r) {
869
869
  if (me[t] || nn(t, e) || ke && (t === "id" || t === "name") && (r in n || r in et)) return !1;
870
- let i = z[t] || he.attributeCheck instanceof Function && he.attributeCheck(t, e);
871
- return _e && Y(oe, t) || ge && Y(L, t) ? !0 : i ? Le[t] || Y(ue, _t(r, ce, "")) || (t === "src" || t === "xlink:href" || t === "href") && e !== "script" && vt(r, "data:") === 0 && Fe[e] || ve && !Y(se, _t(r, ce, "")) ? !0 : !r : kn(e) && Sn(B.tagNameCheck, e) && Sn(B.attributeNameCheck, t, e) || t === "is" && B.allowCustomizedBuiltInElements && Sn(B.tagNameCheck, r);
870
+ let i = z[t] || V.attributeCheck instanceof Function && V.attributeCheck(t, e);
871
+ return ge && Y(oe, t) || he && Y(L, t) ? !0 : i ? Le[t] || Y(ue, _t(r, ce, "")) || (t === "src" || t === "xlink:href" || t === "href") && e !== "script" && vt(r, "data:") === 0 && Fe[e] || _e && !Y(se, _t(r, ce, "")) ? !0 : !r : kn(e) && Sn(B.tagNameCheck, e) && Sn(B.attributeNameCheck, t, e) || t === "is" && B.allowCustomizedBuiltInElements && Sn(B.tagNameCheck, r);
872
872
  }, On = Z({}, [
873
873
  "annotation-xml",
874
874
  "color-profile",
@@ -906,7 +906,7 @@ function dn() {
906
906
  }, r = t.length, i = G(e.nodeName);
907
907
  for (; r--;) {
908
908
  let a = t[r], o = a.name, s = a.namespaceURI, c = a.value, l = G(o), u = c, d = o === "value" ? u : yt(u);
909
- if (n.attrName = l, n.attrValue = d, n.keepAttr = !0, n.forceKeepAttr = void 0, bn(I.uponSanitizeAttribute, e, n), d = n.attrValue, Ae && (l === "id" || l === "name") && vt(d, je) !== 0 && (X(o, e, a), d = je + d), xe && Y(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, d)) {
909
+ if (n.attrName = l, n.attrValue = d, n.keepAttr = !0, n.forceKeepAttr = void 0, bn(I.uponSanitizeAttribute, e, n), d = n.attrValue, Ae && (l === "id" || l === "name") && vt(d, je) !== 0 && (X(o, e, a), d = je + d), be && Y(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, d)) {
910
910
  X(o, e, a);
911
911
  continue;
912
912
  }
@@ -919,11 +919,11 @@ function dn() {
919
919
  X(o, e, a);
920
920
  continue;
921
921
  }
922
- if (!ye && Y(tn, d)) {
922
+ if (!ve && Y(tn, d)) {
923
923
  X(o, e, a);
924
924
  continue;
925
925
  }
926
- if (be && (d = hn(d)), !Dn(i, l, d)) {
926
+ if (ye && (d = hn(d)), !Dn(i, l, d)) {
927
927
  X(o, e, a);
928
928
  continue;
929
929
  }
@@ -997,7 +997,7 @@ function dn() {
997
997
  }
998
998
  } else if (yn(e)) i = pn("<!---->"), a = i.ownerDocument.importNode(e, !0), a.nodeType === $.element && a.nodeName === "BODY" || a.nodeName === "HTML" ? i = a : i.appendChild(a), Pn(a);
999
999
  else {
1000
- if (!Ee && !be && !V && e.indexOf("<") === -1) return w && Oe ? A(e) : e;
1000
+ if (!Ee && !ye && !xe && e.indexOf("<") === -1) return w && Oe ? A(e) : e;
1001
1001
  if (i = pn(e), !i) return Ee ? null : Oe ? T : "";
1002
1002
  }
1003
1003
  i && Te && St(i.firstChild);
@@ -1012,14 +1012,14 @@ function dn() {
1012
1012
  }
1013
1013
  if (c) return ct(t.removed, (e) => {
1014
1014
  e.element && Dt(e.element);
1015
- }), be && gn(e), e;
1015
+ }), ye && gn(e), e;
1016
1016
  if (Ee) {
1017
- if (be && gn(i), De) for (s = N.call(i.ownerDocument); i.firstChild;) s.appendChild(i.firstChild);
1017
+ if (ye && gn(i), De) for (s = N.call(i.ownerDocument); i.firstChild;) s.appendChild(i.firstChild);
1018
1018
  else s = i;
1019
1019
  return (z.shadowroot || z.shadowrootmode) && (s = F.call(r, s, !0)), s;
1020
1020
  }
1021
- let u = V ? i.outerHTML : i.innerHTML;
1022
- return V && R["!doctype"] && i.ownerDocument && i.ownerDocument.doctype && i.ownerDocument.doctype.name && Y(Xt, i.ownerDocument.doctype.name) && (u = "<!DOCTYPE " + i.ownerDocument.doctype.name + ">\n" + u), be && (u = hn(u)), w && Oe ? A(u) : u;
1021
+ let u = xe ? i.outerHTML : i.innerHTML;
1022
+ return xe && R["!doctype"] && i.ownerDocument && i.ownerDocument.doctype && i.ownerDocument.doctype.name && Y(Xt, i.ownerDocument.doctype.name) && (u = "<!DOCTYPE " + i.ownerDocument.doctype.name + ">\n" + u), ye && (u = hn(u)), w && Oe ? A(u) : u;
1023
1023
  }, t.setConfig = function() {
1024
1024
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1025
1025
  nt(e), Se = !0, Ce = R, we = z;
@@ -1158,11 +1158,11 @@ var Dn = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 7 420 120\">\n<s
1158
1158
  function On(e, t) {
1159
1159
  return e ? `${t ? "https://leadbot.nl/welkom-ai" : "https://leadbot.nl/welkom"}?r=${encodeURIComponent(e)}` : "https://leadbot.com?ref=widget";
1160
1160
  }
1161
- function kn({ leadbot: e, align: t = "right", className: n, asLink: r = !1, language: i = "en", isChatbot: a = !1 }) {
1161
+ function kn({ leadbot: e, align: t, className: n, asLink: r = !1, language: i = "en", isChatbot: a = !1 }) {
1162
1162
  if (e?.is_white_label) return null;
1163
- let o = e?.partner, s = o?.custom_branding ?? !1, c = o?.partner_logo_url && /^https?:\/\//i.test(U(o.partner_logo_url)) ? U(o.partner_logo_url) : null, l = o?.partner_website, u = e?.domain?.display_name, d = l && /^https?:\/\//i.test(U(l)) ? U(l) : null, f = d ? `${d}${d.includes("?") ? "&" : "?"}ref=widget` : null, p = t === "center" ? "leadbot-powered-by--center" : "leadbot-powered-by--right", m = n ? ` ${n}` : "", g = M("powered_by", i);
1163
+ let o = e?.partner, s = o?.custom_branding ?? !1, c = o?.partner_logo_url && /^https?:\/\//i.test(U(o.partner_logo_url)) ? U(o.partner_logo_url) : null, l = o?.partner_website, u = e?.domain?.display_name, d = l && /^https?:\/\//i.test(U(l)) ? U(l) : null, f = d ? `${d}${d.includes("?") ? "&" : "?"}ref=widget` : null, p = t ? ` leadbot-powered-by--${t}` : "", m = n ? ` ${n}` : "", g = M("powered_by", i);
1164
1164
  if (r) {
1165
- let e = s && c, t = `leadbot-powered-by ${p}${m}`, n = e ? /* @__PURE__ */ h("img", {
1165
+ let e = s && c, t = `leadbot-powered-by${p}${m}`, n = e ? /* @__PURE__ */ h("img", {
1166
1166
  src: c,
1167
1167
  alt: "Partner"
1168
1168
  }) : /* @__PURE__ */ h("span", {
@@ -1184,7 +1184,7 @@ function kn({ leadbot: e, align: t = "right", className: n, asLink: r = !1, lang
1184
1184
  });
1185
1185
  }
1186
1186
  return /* @__PURE__ */ h("div", {
1187
- className: `leadbot-powered-by ${p}${m}`,
1187
+ className: `leadbot-powered-by${p}${m}`,
1188
1188
  children: [/* @__PURE__ */ h("span", { children: g }), s && c ? An(f, c) : jn(u, a)]
1189
1189
  });
1190
1190
  }
@@ -1216,7 +1216,7 @@ function jn(e, t) {
1216
1216
  }
1217
1217
  //#endregion
1218
1218
  //#region ../../src/components/messageCard.tsx
1219
- function Mn({ senderName: e = "", companyName: t, contentHtml: n, isFirstStep: r = !1, className: i, poweredByAlign: a = "right", leadbot: o, language: s = "en" }) {
1219
+ function Mn({ senderName: e = "", companyName: t, contentHtml: n, isFirstStep: r = !1, className: i, poweredByAlign: a, leadbot: o, language: s = "en" }) {
1220
1220
  let c = r && !o?.is_white_label, l = [
1221
1221
  "leadbot-card",
1222
1222
  i,
@@ -1274,7 +1274,6 @@ function Nn(e) {
1274
1274
  companyName: r.leadbot.domain.display_name,
1275
1275
  contentHtml: l,
1276
1276
  isFirstStep: i,
1277
- poweredByAlign: "right",
1278
1277
  leadbot: r.leadbot,
1279
1278
  language: r.leadbot?.language
1280
1279
  })]
@@ -1285,7 +1284,7 @@ function Nn(e) {
1285
1284
  function Pn(e) {
1286
1285
  let { step: t, config: n, isCurrent: r } = e;
1287
1286
  if (!r) return null;
1288
- let i = ye(t.options);
1287
+ let i = ve(t.options);
1289
1288
  if (i.length === 0) return null;
1290
1289
  let a = i[0], o = n.steps.find((e) => e.uuid === a.next_step_uuid);
1291
1290
  if (!o) return null;
@@ -1319,7 +1318,6 @@ function Fn(e) {
1319
1318
  contentHtml: c,
1320
1319
  className: "leadbot-bubble-notification",
1321
1320
  isFirstStep: i,
1322
- poweredByAlign: "right",
1323
1321
  leadbot: r.leadbot,
1324
1322
  language: r.leadbot?.language
1325
1323
  })
@@ -1329,7 +1327,7 @@ function Fn(e) {
1329
1327
  //#region ../../src/dataSubmitter.ts
1330
1328
  var In = class {
1331
1329
  constructor(e) {
1332
- this.domainKey = be(e), this.leadbotId = Te(e), this.apiUrl = Ce("/client/submit"), this.client = T({
1330
+ this.domainKey = ye(e), this.leadbotId = Te(e), this.apiUrl = Ce("/client/submit"), this.client = T({
1333
1331
  domainKey: this.domainKey,
1334
1332
  apiBase: Ce("")
1335
1333
  }), this.previewToken = De() ?? void 0, this.preview = this.previewToken ? !0 : void 0, this.visitorId = ee(), k();
@@ -1426,7 +1424,7 @@ function zn(e) {
1426
1424
  let e = Pe(o);
1427
1425
  if (e !== "#" && window.open(e, s, "noopener,noreferrer"), !c) return;
1428
1426
  }
1429
- let a = ye(n.options).map((e) => e.next_step_uuid).filter((e) => !!e);
1427
+ let a = ve(n.options).map((e) => e.next_step_uuid).filter((e) => !!e);
1430
1428
  a.length > 0 && i(a);
1431
1429
  }, u = (e) => e.split(/(\*\*.+?\*\*)/g).map((e, t) => e.startsWith("**") && e.endsWith("**") ? /* @__PURE__ */ h("strong", { children: e.slice(2, -2) }, t) : e), d = n.background_color?.trim(), f = d?.toLowerCase(), p = !d || f === "#fff" || f === "#ffffff" || f === "white" || f === "rgb(255, 255, 255)" || f === "rgba(255, 255, 255, 1)", m = !d, g = Rn(o);
1432
1430
  return /* @__PURE__ */ h("button", {
@@ -2257,18 +2255,18 @@ function Fr(e) {
2257
2255
  _,
2258
2256
  m
2259
2257
  ]);
2260
- let de = F("whatsapp_placeholder", "Type a message"), z = F("whatsapp_phone_placeholder", "Your phone number"), fe = F("whatsapp_phone_prompt", "What is your phone number? Then we will continue in WhatsApp."), B = F("whatsapp_phone_invalid", "Please enter a valid phone number."), me = F("whatsapp_status_online", "Online"), he = () => {
2258
+ let de = F("whatsapp_placeholder", "Type a message"), z = F("whatsapp_phone_placeholder", "Your phone number"), fe = F("whatsapp_phone_prompt", "What is your phone number? Then we will continue in WhatsApp."), B = F("whatsapp_phone_invalid", "Please enter a valid phone number."), me = F("whatsapp_status_online", "Online"), V = () => {
2261
2259
  let e = /* @__PURE__ */ new Date();
2262
2260
  return e.getHours().toString().padStart(2, "0") + ":" + e.getMinutes().toString().padStart(2, "0");
2263
- }, ge = t.attributes?.sender_number || t.attributes?.phone_number || "", _e = F("whatsapp_error_submission", "We could not save your message. You can still continue in WhatsApp."), ve = F("whatsapp_error_phone_missing", "WhatsApp is not configured for this step."), ye = L(window.location.href), be = async (n, r) => {
2261
+ }, he = t.attributes?.sender_number || t.attributes?.phone_number || "", ge = F("whatsapp_error_submission", "We could not save your message. You can still continue in WhatsApp."), _e = F("whatsapp_error_phone_missing", "WhatsApp is not configured for this step."), ve = L(window.location.href), ye = async (n, r) => {
2264
2262
  if (!ce) return null;
2265
2263
  let i = { [ce.uuid]: n };
2266
2264
  r && le && (i[le.uuid] = r);
2267
2265
  let a = await o.submitUserData(Pr, t.uuid, i, c ? { chat_session_id: c } : void 0);
2268
2266
  if (a?.success === !1) throw Error(a.error || "Submission failed");
2269
2267
  return e.onSubmitted?.(i), null;
2270
- }, xe = F("whatsapp_error_redirect", "WhatsApp could not be opened. Please check your pop-up settings."), V = (e, t) => {
2271
- let n = Mr(e, ye, t), r = E(ge, n);
2268
+ }, be = F("whatsapp_error_redirect", "WhatsApp could not be opened. Please check your pop-up settings."), xe = (e, t) => {
2269
+ let n = Mr(e, ve, t), r = E(he, n);
2272
2270
  return r ? (window.open(r, "_blank", "noopener,noreferrer"), !0) : !1;
2273
2271
  }, Se = () => {
2274
2272
  let e = t.options?.[0];
@@ -2292,30 +2290,30 @@ function Fr(e) {
2292
2290
  u(!0);
2293
2291
  try {
2294
2292
  try {
2295
- await be(a, o);
2293
+ await ye(a, o);
2296
2294
  } catch (e) {
2297
- console.error("WhatsApp data submission failed:", e), g(_e);
2295
+ console.error("WhatsApp data submission failed:", e), g(ge);
2298
2296
  }
2299
- if (!ge || !ge.trim()) {
2300
- g(ve);
2297
+ if (!he || !he.trim()) {
2298
+ g(_e);
2301
2299
  return;
2302
2300
  }
2303
2301
  if (M) {
2304
- let n = Mr(a, ye, o), r = E(ge, n), i = D(ge, n);
2302
+ let n = Mr(a, ve, o), r = E(he, n), i = D(he, n);
2305
2303
  if (!r || !i || !Ce(r, i)) {
2306
- g(xe);
2304
+ g(be);
2307
2305
  return;
2308
2306
  }
2309
2307
  e.analyticsTracker?.trackWhatsAppRedirect(t), O.current && (O.current.value = ""), b(null);
2310
2308
  return;
2311
2309
  }
2312
- if (!V(a, o)) {
2313
- g(xe);
2310
+ if (!xe(a, o)) {
2311
+ g(be);
2314
2312
  return;
2315
2313
  }
2316
2314
  e.analyticsTracker?.trackWhatsAppRedirect(t), O.current && (O.current.value = ""), b(null), Se();
2317
2315
  } catch (e) {
2318
- console.error("WhatsApp submission failed:", e), g(_e);
2316
+ console.error("WhatsApp submission failed:", e), g(ge);
2319
2317
  } finally {
2320
2318
  u(!1);
2321
2319
  }
@@ -2359,7 +2357,7 @@ function Fr(e) {
2359
2357
  dangerouslySetInnerHTML: { __html: wn(oe) }
2360
2358
  }), /* @__PURE__ */ h("div", {
2361
2359
  className: "leadbot-whatsapp-message-time",
2362
- children: [he(), /* @__PURE__ */ h("span", {
2360
+ children: [V(), /* @__PURE__ */ h("span", {
2363
2361
  className: "leadbot-whatsapp-checkmarks",
2364
2362
  dangerouslySetInnerHTML: { __html: H.checkDouble }
2365
2363
  })]
@@ -2371,7 +2369,7 @@ function Fr(e) {
2371
2369
  children: y
2372
2370
  }), /* @__PURE__ */ h("div", {
2373
2371
  className: "leadbot-whatsapp-message-time",
2374
- children: he()
2372
+ children: V()
2375
2373
  })]
2376
2374
  }), w ? /* @__PURE__ */ h("div", {
2377
2375
  className: "leadbot-whatsapp-message leadbot-whatsapp-typing",
@@ -4112,7 +4110,7 @@ function $a(e, t) {
4112
4110
  }];
4113
4111
  }
4114
4112
  function eo(e) {
4115
- let { step: t, config: n, isCurrent: r } = e, i = Ln(n), a = t.attributes?.sender_name || "AI Assistant", o = t.attributes?.sender_image?.url || null, c = t.attributes?.initial_message || "", l = oe(t.attributes?.conversation_starters), u = ae(n.leadbot?.language), p = M("chatbot_placeholder", u), m = be(n), [g] = d(() => za(m, t.uuid, t.attributes?.tools)), [_, b] = d(() => g ? g.messages : c ? [{
4113
+ let { step: t, config: n, isCurrent: r } = e, i = Ln(n), a = t.attributes?.sender_name || "AI Assistant", o = t.attributes?.sender_image?.url || null, c = t.attributes?.initial_message || "", l = oe(t.attributes?.conversation_starters), u = ae(n.leadbot?.language), p = M("chatbot_placeholder", u), m = ye(n), [g] = d(() => za(m, t.uuid, t.attributes?.tools)), [_, b] = d(() => g ? g.messages : c ? [{
4116
4114
  role: "assistant",
4117
4115
  content: c
4118
4116
  }] : []), [x, C] = d(!1), [w, T] = d(null), [E, D] = d(!1), [k, A] = d(!1), ee = f(null), j = f(null), te = f(null), ne = f(null), N = f(g?.sessionId ?? null), P = f(_), F = f(!1), I = f(!1), re = f(null), ie = f(null);
@@ -4278,12 +4276,12 @@ function eo(e) {
4278
4276
  let me = (e) => {
4279
4277
  if (!(!r || F.current)) {
4280
4278
  if (e.answer) {
4281
- he(e.question, e.answer);
4279
+ V(e.question, e.answer);
4282
4280
  return;
4283
4281
  }
4284
4282
  pe(e.question);
4285
4283
  }
4286
- }, he = (e, r) => {
4284
+ }, V = (e, r) => {
4287
4285
  let a = ce();
4288
4286
  i.submitChatExchange({
4289
4287
  step_uuid: t.uuid,
@@ -4306,7 +4304,7 @@ function eo(e) {
4306
4304
  ]), se(!0), T("thinking"), ie.current = r, re.current = setTimeout(() => {
4307
4305
  re.current = null, ie.current = null, L((e) => Za(e, r)), se(!1), T(null);
4308
4306
  }, y);
4309
- }, ge = (e, t) => {
4307
+ }, he = (e, t) => {
4310
4308
  let n = P.current, r = n[e];
4311
4309
  if (r?.role !== "tool" || r.status !== "pending") return;
4312
4310
  let i = n.map((n, r) => r === e && n.role === "tool" ? {
@@ -4319,12 +4317,12 @@ function eo(e) {
4319
4317
  return;
4320
4318
  }
4321
4319
  B(i);
4322
- }, _e = (e) => {
4320
+ }, ge = (e) => {
4323
4321
  L((t) => t.map((t, n) => n === e && t.role === "tool" && t.status === "pending" ? {
4324
4322
  ...t,
4325
4323
  status: "dismissed"
4326
4324
  } : t));
4327
- }, ve = (e, n, r) => {
4325
+ }, _e = (e, n, r) => {
4328
4326
  let a = N.current;
4329
4327
  if (!a) return;
4330
4328
  let o = P.current, s = o[e];
@@ -4344,14 +4342,14 @@ function eo(e) {
4344
4342
  comment: r,
4345
4343
  message_content: s.content.slice(0, 5e3)
4346
4344
  }));
4347
- }, ye = (e) => {
4345
+ }, ve = (e) => {
4348
4346
  e.preventDefault();
4349
4347
  let t = j.current?.value?.trim();
4350
4348
  !t || !r || x || (j.current.value = "", A(!1), pe(t));
4351
- }, xe = () => {
4349
+ }, be = () => {
4352
4350
  A(!!j.current?.value?.trim());
4353
- }, V = (e) => {
4354
- e.key === "Enter" && !e.shiftKey && ye(e);
4351
+ }, xe = (e) => {
4352
+ e.key === "Enter" && !e.shiftKey && ve(e);
4355
4353
  }, Se = (e) => {
4356
4354
  e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), D(!1), te.current?.focus({ preventScroll: !0 }));
4357
4355
  }, we = () => {
@@ -4455,8 +4453,8 @@ function eo(e) {
4455
4453
  message: t,
4456
4454
  config: n,
4457
4455
  analyticsTracker: e.analyticsTracker,
4458
- onCompleted: (e) => ge(r, e),
4459
- onDismissed: () => _e(r),
4456
+ onCompleted: (e) => he(r, e),
4457
+ onDismissed: () => ge(r),
4460
4458
  prefillMessage: Ya(_, r)
4461
4459
  })
4462
4460
  }, r);
@@ -4497,7 +4495,7 @@ function eo(e) {
4497
4495
  o && /* @__PURE__ */ h(Wa, {
4498
4496
  feedback: t.feedback,
4499
4497
  language: u,
4500
- onRate: (e, t) => ve(r, e, t),
4498
+ onRate: (e, t) => _e(r, e, t),
4501
4499
  onLayoutChange: le
4502
4500
  })
4503
4501
  ]
@@ -4532,13 +4530,13 @@ function eo(e) {
4532
4530
  type: "text",
4533
4531
  placeholder: p,
4534
4532
  className: "leadbot-chatbot-message-input",
4535
- onKeyDown: V,
4536
- onInput: xe,
4533
+ onKeyDown: xe,
4534
+ onInput: be,
4537
4535
  disabled: !r || x
4538
4536
  }), /* @__PURE__ */ h("button", {
4539
4537
  className: `leadbot-chatbot-send-btn${k && !x ? " leadbot-chatbot-send-btn--active" : ""}`,
4540
4538
  "aria-label": M("chatbot_send_label", u),
4541
- onClick: ye,
4539
+ onClick: ve,
4542
4540
  disabled: !r || x || !k,
4543
4541
  children: /* @__PURE__ */ h("svg", {
4544
4542
  width: "20",
@@ -4661,7 +4659,7 @@ function co(e, t, n) {
4661
4659
  if (!r) return null;
4662
4660
  for (let i = n - 1; i >= 0; i--) {
4663
4661
  let n = e[t[i]];
4664
- if (ye(n?.options ?? []).some((e) => e.next_step_uuid === r)) return i;
4662
+ if (ve(n?.options ?? []).some((e) => e.next_step_uuid === r)) return i;
4665
4663
  }
4666
4664
  return null;
4667
4665
  }
@@ -4728,7 +4726,7 @@ function go(e, t) {
4728
4726
  return r.every((e) => e !== -1) ? r : null;
4729
4727
  }
4730
4728
  function _o({ config: e, active: t, sessionScope: n, restoredStepHistory: r, typingIndicator: i = !0, resetRef: a, openIntent: o, clearOpenIntent: l }) {
4731
- let u = be(e), p = e.leadbot?.keep_open_on_navigation === !0, g = e.leadbot?.hide_historical_steps === !0, [_, v] = d(r ?? []), [y, b] = d(!1), S = f(null), C = f([]), w = f(!1), T = j(), { t: E } = Hn(e.leadbot?.language), D = m(() => e.steps.map((e) => e.uuid), [e.steps]), O = () => {
4729
+ let u = ye(e), p = e.leadbot?.keep_open_on_navigation === !0, g = e.leadbot?.hide_historical_steps === !0, [_, v] = d(r ?? []), [y, b] = d(!1), S = f(null), C = f([]), w = f(!1), T = j(), { t: E } = Hn(e.leadbot?.language), D = m(() => e.steps.map((e) => e.uuid), [e.steps]), O = () => {
4732
4730
  for (let e of C.current) window.clearTimeout(e);
4733
4731
  C.current = [], b(!1);
4734
4732
  }, k = c(() => {
@@ -4764,7 +4762,7 @@ function _o({ config: e, active: t, sessionScope: n, restoredStepHistory: r, typ
4764
4762
  }, [t]), s(() => O, []);
4765
4763
  let M = (e) => {
4766
4764
  if (!e) return;
4767
- let t = io(e.step_type), n = ye(e.options);
4765
+ let t = io(e.step_type), n = ve(e.options);
4768
4766
  if (!t?.autoAdvance || n.length === 0) return;
4769
4767
  let r = e.attributes?.timer_next_action_enabled ? e.attributes.timer_next_action ?? 0 : 0, a = () => {
4770
4768
  let e = n.map((e) => e.next_step_uuid).filter((e) => !!e);
@@ -4829,7 +4827,7 @@ function _o({ config: e, active: t, sessionScope: n, restoredStepHistory: r, typ
4829
4827
  let n = e.steps[r[r.length - 1]];
4830
4828
  if (!n) return;
4831
4829
  let i = new Set(r.map((t) => e.steps[t]?.uuid));
4832
- ye(n.options).some((e) => e.next_step_uuid && i.has(e.next_step_uuid)) || M(n);
4830
+ ve(n.options).some((e) => e.next_step_uuid && i.has(e.next_step_uuid)) || M(n);
4833
4831
  }, [t]), s(() => {
4834
4832
  S.current && (S.current.scrollTop = S.current.scrollHeight);
4835
4833
  }, [_, y]);
@@ -4881,7 +4879,7 @@ function _o({ config: e, active: t, sessionScope: n, restoredStepHistory: r, typ
4881
4879
  }
4882
4880
  let o = P(_[r], r);
4883
4881
  t.push(/* @__PURE__ */ h("div", {
4884
- className: `leadbot-step-wrapper ${o ? "leadbot-step-current" : ""}`,
4882
+ className: `leadbot-step-wrapper ${a.step_type === "chatbot" ? "leadbot-step-wrapper--chat" : ""} ${o ? "leadbot-step-current" : ""}`,
4885
4883
  children: /* @__PURE__ */ h(ao, {
4886
4884
  step: a,
4887
4885
  config: e,
@@ -4969,7 +4967,7 @@ function To({ config: e, sessionScope: t, baseColor: n, typingIndicator: r }) {
4969
4967
  //#endregion
4970
4968
  //#region src/flow.ts
4971
4969
  function Eo(e, t) {
4972
- Do(e, "--leadbot-flow-max-width", t?.maxWidth), Do(e, "--leadbot-flow-align", t?.align);
4970
+ Do(e, "--leadbot-flow-max-width", t?.maxWidth), Do(e, "--leadbot-flow-align", t?.align), Do(e, "--leadbot-powered-by-justify", t?.poweredByAlign);
4973
4971
  }
4974
4972
  function Do(e, t, n) {
4975
4973
  n ? e.style.setProperty(t, n) : e.style.removeProperty(t);
package/dist/flow.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./jsxRuntime.module-CT7yzySL.cjs"),t=require("./flow-BpPqOZAo.cjs");let n=require("@leadbot/core");exports.FLOW_CLASS=t.t,exports.ROOT_CLASS=e.m,Object.defineProperty(exports,"buildAnalytics",{enumerable:!0,get:function(){return n.buildAnalytics}}),exports.init=e._,exports.loadFlow=e.v,exports.mountFlow=t.n,exports.useStep=e.a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./jsxRuntime.module-CT7yzySL.cjs"),t=require("./flow-CDKY8Q1s.cjs");let n=require("@leadbot/core");exports.FLOW_CLASS=t.t,exports.ROOT_CLASS=e.m,Object.defineProperty(exports,"buildAnalytics",{enumerable:!0,get:function(){return n.buildAnalytics}}),exports.init=e._,exports.loadFlow=e.v,exports.mountFlow=t.n,exports.useStep=e.a;
package/dist/flow.d.ts CHANGED
@@ -27,6 +27,11 @@ export interface FlowLayout {
27
27
  * `"stretch"` makes cards fill the container up to `maxWidth`.
28
28
  */
29
29
  align?: "flex-start" | "center" | "flex-end" | "stretch";
30
+ /**
31
+ * Horizontal alignment of the "powered by" line under the first card,
32
+ * independent of `align`. Default `"flex-end"`.
33
+ */
34
+ poweredByAlign?: "flex-start" | "center" | "flex-end";
30
35
  }
31
36
  /** Marks the mount root; the flow rules in styles.css are scoped to it. */
32
37
  export declare const FLOW_CLASS = "leadbot-flow";
@@ -1 +1 @@
1
- {"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,KAAK,gBAAgB,EAGrB,KAAK,WAAW,EAEhB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACpD;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mEAAmE;IACnE,MAAM,CAAC,EAAE,UAAU,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;CACzD;AAqBD,2EAA2E;AAC3E,eAAO,MAAM,UAAU,iBAAiB,CAAC;AA6FzC;;;;;;GAMG;AACH,wBAAgB,SAAS,CACxB,EAAE,EAAE,WAAW,EACf,OAAO,GAAE,WAAgB,GACvB,WAAW,CAAC,WAAW,CAAC,CAsB1B"}
1
+ {"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,KAAK,gBAAgB,EAGrB,KAAK,WAAW,EAEhB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACpD;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mEAAmE;IACnE,MAAM,CAAC,EAAE,UAAU,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IACzD;;;OAGG;IACH,cAAc,CAAC,EAAE,YAAY,GAAG,QAAQ,GAAG,UAAU,CAAC;CACtD;AAsBD,2EAA2E;AAC3E,eAAO,MAAM,UAAU,iBAAiB,CAAC;AA6FzC;;;;;;GAMG;AACH,wBAAgB,SAAS,CACxB,EAAE,EAAE,WAAW,EACf,OAAO,GAAE,WAAgB,GACvB,WAAW,CAAC,WAAW,CAAC,CAsB1B"}
package/dist/flow.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { a as e, h as t, m as n, v as r, y as i } from "./jsxRuntime.module-DsRxbn3o.js";
2
- import { n as a, t as o } from "./flow-BZED8XTR.js";
2
+ import { n as a, t as o } from "./flow-CWEzICID.js";
3
3
  export { o as FLOW_CLASS, n as ROOT_CLASS, t as buildAnalytics, r as init, i as loadFlow, a as mountFlow, e as useStep };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./jsxRuntime.module-CT7yzySL.cjs"),t=require("./i18n-gV6rxSod.cjs"),n=require("./agentChat-DWRE_Le4.cjs"),r=require("./form-Dc8AaZBV.cjs"),i=require("./whatsapp-B3GO1RDT.cjs"),a=require("./flow-BpPqOZAo.cjs"),o=require("./buttons-rml8Kh8z.cjs");let s=require("@leadbot/core");exports.AgentChat=n.t,exports.ComponentsButtons=o.t,exports.ComponentsForm=r.t,exports.ComponentsWhatsApp=i.t,exports.DEFAULT_CHAT_LABELS=n.n,exports.DEFAULT_FORM_LABELS=r.n,exports.DEFAULT_WHATSAPP_LABELS=i.n,exports.FLOW_CLASS=a.t,exports.ROOT_CLASS=e.m,Object.defineProperty(exports,"buildAnalytics",{enumerable:!0,get:function(){return s.buildAnalytics}}),exports.chatLabels=t.t,Object.defineProperty(exports,"clearFlowCache",{enumerable:!0,get:function(){return s.clearFlowCache}}),Object.defineProperty(exports,"closeWidget",{enumerable:!0,get:function(){return s.closeWidget}}),exports.formLabels=t.n,Object.defineProperty(exports,"getActiveChatSession",{enumerable:!0,get:function(){return s.getActiveChatSession}}),Object.defineProperty(exports,"getTracker",{enumerable:!0,get:function(){return s.getTracker}}),exports.init=e._,exports.loadFlow=e.v,exports.mountAgentChat=n.r,exports.mountButtons=o.n,exports.mountCallbackRequest=r.r,exports.mountEmailRequest=r.i,exports.mountFlow=a.n,exports.mountForm=r.a,exports.mountWhatsApp=i.r,Object.defineProperty(exports,"openWidget",{enumerable:!0,get:function(){return s.openWidget}}),Object.defineProperty(exports,"sendChatFeedback",{enumerable:!0,get:function(){return s.sendChatFeedback}}),Object.defineProperty(exports,"toggleWidget",{enumerable:!0,get:function(){return s.toggleWidget}}),Object.defineProperty(exports,"trackClick",{enumerable:!0,get:function(){return s.trackClick}}),Object.defineProperty(exports,"trackPageviewUrlChange",{enumerable:!0,get:function(){return s.trackPageviewUrlChange}}),exports.useLeadbotLanguage=t.i,exports.useStep=e.a,exports.whatsappLabels=t.a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./jsxRuntime.module-CT7yzySL.cjs"),t=require("./i18n-gV6rxSod.cjs"),n=require("./agentChat-DWRE_Le4.cjs"),r=require("./form-Dc8AaZBV.cjs"),i=require("./whatsapp-B3GO1RDT.cjs"),a=require("./flow-CDKY8Q1s.cjs"),o=require("./buttons-rml8Kh8z.cjs");let s=require("@leadbot/core");exports.AgentChat=n.t,exports.ComponentsButtons=o.t,exports.ComponentsForm=r.t,exports.ComponentsWhatsApp=i.t,exports.DEFAULT_CHAT_LABELS=n.n,exports.DEFAULT_FORM_LABELS=r.n,exports.DEFAULT_WHATSAPP_LABELS=i.n,exports.FLOW_CLASS=a.t,exports.ROOT_CLASS=e.m,Object.defineProperty(exports,"buildAnalytics",{enumerable:!0,get:function(){return s.buildAnalytics}}),exports.chatLabels=t.t,Object.defineProperty(exports,"clearFlowCache",{enumerable:!0,get:function(){return s.clearFlowCache}}),Object.defineProperty(exports,"closeWidget",{enumerable:!0,get:function(){return s.closeWidget}}),exports.formLabels=t.n,Object.defineProperty(exports,"getActiveChatSession",{enumerable:!0,get:function(){return s.getActiveChatSession}}),Object.defineProperty(exports,"getTracker",{enumerable:!0,get:function(){return s.getTracker}}),exports.init=e._,exports.loadFlow=e.v,exports.mountAgentChat=n.r,exports.mountButtons=o.n,exports.mountCallbackRequest=r.r,exports.mountEmailRequest=r.i,exports.mountFlow=a.n,exports.mountForm=r.a,exports.mountWhatsApp=i.r,Object.defineProperty(exports,"openWidget",{enumerable:!0,get:function(){return s.openWidget}}),Object.defineProperty(exports,"sendChatFeedback",{enumerable:!0,get:function(){return s.sendChatFeedback}}),Object.defineProperty(exports,"toggleWidget",{enumerable:!0,get:function(){return s.toggleWidget}}),Object.defineProperty(exports,"trackClick",{enumerable:!0,get:function(){return s.trackClick}}),Object.defineProperty(exports,"trackPageviewUrlChange",{enumerable:!0,get:function(){return s.trackPageviewUrlChange}}),exports.useLeadbotLanguage=t.i,exports.useStep=e.a,exports.whatsappLabels=t.a;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { a, i as o, n as s, t as c } from "./i18n-DyDsn-Fk.js";
3
3
  import { n as l, r as u, t as d } from "./agentChat-8s9g6Np1.js";
4
4
  import { a as f, i as p, n as m, r as h, t as g } from "./form-Df53ALbk.js";
5
5
  import { n as _, r as v, t as y } from "./whatsapp-DGnyaume.js";
6
- import { n as b, t as x } from "./flow-BZED8XTR.js";
6
+ import { n as b, t as x } from "./flow-CWEzICID.js";
7
7
  import { n as S, t as C } from "./buttons-ecViBEJ9.js";
8
8
  import { clearFlowCache as w, closeWidget as T, getActiveChatSession as E, getTracker as D, openWidget as O, sendChatFeedback as k, toggleWidget as A, trackClick as j, trackPageviewUrlChange as M } from "@leadbot/core";
9
9
  export { d as AgentChat, C as ComponentsButtons, g as ComponentsForm, y as ComponentsWhatsApp, l as DEFAULT_CHAT_LABELS, m as DEFAULT_FORM_LABELS, _ as DEFAULT_WHATSAPP_LABELS, x as FLOW_CLASS, n as ROOT_CLASS, t as buildAnalytics, c as chatLabels, w as clearFlowCache, T as closeWidget, s as formLabels, E as getActiveChatSession, D as getTracker, r as init, i as loadFlow, u as mountAgentChat, S as mountButtons, h as mountCallbackRequest, p as mountEmailRequest, b as mountFlow, f as mountForm, v as mountWhatsApp, O as openWidget, k as sendChatFeedback, A as toggleWidget, j as trackClick, M as trackPageviewUrlChange, o as useLeadbotLanguage, e as useStep, a as whatsappLabels };
package/dist/styles.css CHANGED
@@ -526,9 +526,18 @@
526
526
  border-radius: var(--leadbot-radius-card);
527
527
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
528
528
  max-width: 360px;
529
- height: min(var(--leadbot-chat-height), max(0px, var(--leadbot-available-height)));
529
+ /* Both tokens are defined on `.leadbot-steps-container` — see the comment
530
+ there for what they mean and why they are not the panel budget. The
531
+ fallbacks are for @leadbot/components, which reuses this partial without
532
+ that container: there the panel keeps its documented fixed height, capped
533
+ by the available height, exactly as before those tokens existed. */
534
+ height: var(--leadbot-chat-fit-height, min(var(--leadbot-chat-height), max(0px, var(--leadbot-available-height))));
530
535
  min-width: 360px;
531
- min-height: 0;
536
+ /* `- 8px` for this card's own bottom margin: `100%` is the wrapper's content
537
+ box, and the margin has to come out of it too or the card sticks out of
538
+ the wrapper the flex layout gave it. */
539
+ max-height: calc(100% - 8px);
540
+ min-height: var(--leadbot-chat-min-height, 180px);
532
541
  overflow: hidden;
533
542
  margin-bottom: 8px;
534
543
  display: flex;
@@ -2242,9 +2251,21 @@
2242
2251
  .leadbot-flow .leadbot-callback-form,
2243
2252
  .leadbot-flow .leadbot-email-request-form,
2244
2253
  .leadbot-flow .leadbot-form {
2254
+ /* The card is scrollable inside, so its height is purely a budget question.
2255
+ Preferred budget: the panel minus 240px, which keeps the message that
2256
+ introduced the form visible above it. That headroom is a luxury a short
2257
+ viewport cannot pay for — with nothing but a subtraction the card
2258
+ collapses to title + button (80px on a 460px-tall viewport) and not one
2259
+ field is in view. So: never below the floor, and never above the room the
2260
+ container actually has, whichever of the two is smaller. Same shape as the
2261
+ chat panel's `fit` height in _content.scss. */
2262
+ --leadbot-form-min-height: 280px;
2263
+ --leadbot-form-room: calc(
2264
+ var(--leadbot-available-height, 100vh) - var(--leadbot-steps-padding-y, 40px)
2265
+ );
2245
2266
  display: flex;
2246
2267
  flex-direction: column;
2247
- max-height: calc(var(--leadbot-available-height, 100vh) - 240px);
2268
+ max-height: max(min(var(--leadbot-form-min-height), var(--leadbot-form-room)), var(--leadbot-available-height, 100vh) - 240px);
2248
2269
  min-height: 0;
2249
2270
  overflow: hidden;
2250
2271
  padding: 0;
@@ -2719,15 +2740,15 @@
2719
2740
  padding: 0;
2720
2741
  width: 100%;
2721
2742
  display: flex;
2722
- justify-content: flex-end;
2743
+ justify-content: var(--leadbot-powered-by-justify, flex-end);
2723
2744
  align-items: center;
2724
2745
  gap: 4px;
2725
2746
  }
2726
2747
  .leadbot-flow .leadbot-powered-by--right {
2727
- justify-content: flex-end;
2748
+ --leadbot-powered-by-justify: flex-end;
2728
2749
  }
2729
2750
  .leadbot-flow .leadbot-powered-by--center {
2730
- justify-content: center;
2751
+ --leadbot-powered-by-justify: center;
2731
2752
  }
2732
2753
  .leadbot-flow .leadbot-powered-by a {
2733
2754
  display: inline-flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leadbot/components",
3
- "version": "2.24.1",
3
+ "version": "2.25.0",
4
4
  "description": "LeadBot Components: mount agent chat, forms, callback/email requests and WhatsApp handoff into your own DOM.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -51,7 +51,7 @@
51
51
  "README.md"
52
52
  ],
53
53
  "dependencies": {
54
- "@leadbot/core": "2.24.1"
54
+ "@leadbot/core": "2.25.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "happy-dom": "^20.11.6",