@inploi/plugin-chatbot 14.18.1 → 14.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/index.js +10 -10
- package/dist/chatbot-body-B9-4nZ6I.cjs +5 -0
- package/dist/{chatbot-body-DjE1hhPI.js → chatbot-body-nYJfLJVU.js} +1072 -1038
- package/dist/index-BQAeBeON.cjs +21 -0
- package/dist/{index-C8Gr0Ijn.js → index-DZr-JCDW.js} +655 -639
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +1 -1
- package/package.json +3 -3
- package/dist/chatbot-body-Y8XV3f3-.cjs +0 -5
- package/dist/index-DSa7ZKqt.cjs +0 -21
package/dist/plugin-chatbot.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BQAeBeON.cjs");exports.chatbotPlugin=t.chatbotPlugin;
|
package/dist/plugin-chatbot.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inploi/plugin-chatbot",
|
|
3
|
-
"version": "14.18.
|
|
3
|
+
"version": "14.18.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/plugin-chatbot.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"@inploi/colors": "1.0.2",
|
|
69
69
|
"@inploi/core": "1.23.0",
|
|
70
70
|
"@inploi/design-tokens": "0.2.1",
|
|
71
|
-
"@inploi/flows": "9.
|
|
71
|
+
"@inploi/flows": "9.14.1",
|
|
72
72
|
"@inploi/i18n": "0.1.5",
|
|
73
73
|
"@inploi/plugin-feedback": "6.3.0",
|
|
74
|
-
"@inploi/sdk": "2.8.
|
|
74
|
+
"@inploi/sdk": "2.8.1",
|
|
75
75
|
"eslint-config-custom": "0.1.0",
|
|
76
76
|
"tsconfig": "0.1.0"
|
|
77
77
|
},
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";var on=Object.defineProperty;var ln=(e,t,r)=>t in e?on(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var X=(e,t,r)=>ln(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-DSa7ZKqt.cjs"),it=require("@inploi/sdk");var Xe=/\b(?:GIR\s*0AA|[a-z]{1,2}\d[\da-z]?\s*\d[a-z]{2}|[a-z](?:\d{2}|\d[a-z])\s*[\da-z]{4})\b/i,Cr=/^(?:GIR0AA|[A-Z]{1,2}\d[\dA-Z]?\d[A-Z]{2})$/,Sr=/^[A-Z](?:\d{2}|\d[A-Z])[\dA-Z]{4}$/,Ar=({postcode:e,label:t="",state:r,country:n})=>{var l,c,f;const a=((e==null?void 0:e.trim())||((l=t.match(Xe))==null?void 0:l[0])||"").replace(/\s/g,"").toUpperCase();if(Cr.test(a))return a.startsWith("BT")?"ni":"gb";if(Sr.test(a))return"ie";const o=h=>h.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim();if(o(r??"")==="northern ireland"||t.split(",").some(h=>o(h)==="northern ireland"))return"ni";const i=(f=(n==null?void 0:n.trim())||((c=t.split(",").at(-1))==null?void 0:c.trim()))==null?void 0:f.toLowerCase();return i==="united kingdom"||i==="gb"?"gb":i==="ireland"||i==="ie"?"ie":null},cn="https://maps.inploi.com/address",un=e=>e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim(),qt=e=>e.split(",").map(t=>un(t).replace(/^\d+[a-z]?(?:\s*[-/]\s*\d+[a-z]?)?(?:\s+|$)/,"").trim()),zt=e=>Cr.test(e)?`gb:${e.slice(0,-3)}`:Sr.test(e)?`ie:${e.slice(0,3)}`:null,dn=(e,t,r)=>{const[n="",a=""]=qt(e),o=zt(t),i=a.replace(Xe,"").trim(),l=i&&!["united kingdom","ireland","england","scotland","wales","northern ireland"].includes(i);if(!n||!o&&!l)return null;const c=r.slice(0,3).findIndex(f=>{var p;const h=qt(f);if(!h.includes(n))return!1;const b=((p=f.match(Xe))==null?void 0:p[0].replace(/\s/g,"").toUpperCase())??"",g=zt(b);return o&&g?o===g:!!(l&&h.some(v=>v.replace(Xe,"").trim()===i))});return c===-1?null:c+1},fn=async({query:e,country:t,pickedLabel:r,pickedPostcode:n,pickedCountry:a,pickedState:o,log:i})=>{var c,f,h;if(!t||!t.split(",").every(b=>/^(gb|ie)$/i.test(b.trim())))return;let l;try{const b=new AbortController;l=setTimeout(()=>b.abort(),1500);const g=new URL(cn);g.search=new URLSearchParams({q:e,country:t,limit:"5"}).toString();const p=await fetch(g.href,{signal:b.signal});if(!p.ok)return;const v=await p.json();if(typeof v!="object"||v===null||!("results"in v)||!Array.isArray(v.results)||!("source"in v)||v.source!=="photon"&&v.source!=="mapbox")return;const w=v.results,k=[];for(const B of w){if(typeof B!="object"||B===null||!("label"in B)||typeof B.label!="string")return;k.push(B.label)}const E=((n==null?void 0:n.trim())||((c=r.match(Xe))==null?void 0:c[0])||"").replace(/\s/g,"").toUpperCase(),x=dn(r,E,k),N=(h=(f=p.headers.get("Server-Timing"))==null?void 0:f.match(/(?:^|,)\s*lookup\s*;\s*dur=([\d.]+)/))==null?void 0:h[1],O=N===void 0?null:Number(N),T=p.headers.get("X-Geo-Fallback"),H=Ar({postcode:n,label:r,state:o,country:a});await i({hit:x!==null,rank:x,results:k.length,source:v.source,fallback:T&&/^[a-z0-9_-]{1,64}$/i.test(T)?T:null,ms:O!==null&&Number.isFinite(O)?O:null,region:H})}catch{}finally{clearTimeout(l)}},hn="https://maps.inploi.com",pn=async(e,t,r=Date.now()+2500)=>{t==null||t.throwIfAborted();const n=new AbortController,a=()=>n.abort(t==null?void 0:t.reason);t==null||t.addEventListener("abort",a,{once:!0});let o;try{const i=new Promise((c,f)=>{n.signal.addEventListener("abort",()=>f(n.signal.reason),{once:!0}),o=setTimeout(()=>n.abort(),Math.max(0,r-Date.now()))}),l=await Promise.race([e(n.signal),i]);return t==null||t.throwIfAborted(),l}catch{t==null||t.throwIfAborted();return}finally{clearTimeout(o),t==null||t.removeEventListener("abort",a)}},mn=async(e,t,r)=>await pn(async a=>{const{lookupAddress:o}=await Promise.resolve().then(()=>require("./common.geo-transport-CJGUJXTA-DQyNyTXw.cjs"));return a.throwIfAborted(),o({...e,signal:a})},e.signal,r)??{results:await t(),arm:"direct",source:"direct"},yn=e=>{try{const t=new URL("/outcome",hn);t.search=new URLSearchParams({kind:e.kind,surface:e.surface,arm:e.arm,picked:e.picked?"1":"0"}).toString(),t.searchParams.set("source",e.source),e.picked&&e.edited!==void 0&&t.searchParams.set("edited",e.edited?"1":"0"),e.region&&t.searchParams.set("region",e.region),fetch(t.href,{keepalive:!0}).catch(()=>{})}catch{}},bn="9.13.1",Er=`https://sdk.inploi.com/@inploi/flows@${bn}/cdn/captcha/index.html`,gn=new URL(Er).origin,Wt=3e4,vn=5*6e4,xn=e=>typeof e=="object"&&e!==null&&e.source==="inploi-captcha",yt=new WeakMap,wn=e=>{let t=yt.get(e);return t||(t=e.fetch("/flow/captcha").then(r=>{let n=r==null?void 0:r.site_key;return typeof n=="string"&&n!==""?n:void 0}).catch(r=>{throw yt.delete(e),r}),yt.set(e,t)),t},_n=(e,t={})=>new Promise((r,n)=>{let{signal:a,container:o=null,theme:i,onInteractive:l}=t instanceof AbortSignal?{signal:t}:t,c=!1,f=()=>{},h=w=>{c||(c=!0,clearTimeout(p),a==null||a.removeEventListener("abort",g),f(),w())},b=w=>h(()=>n(new Error(w))),g=()=>b("Captcha aborted"),p,v=w=>{clearTimeout(p),p=setTimeout(()=>b("Captcha timed out"),w)};if(v(Wt),a==null?void 0:a.aborted)return g();a==null||a.addEventListener("abort",g),(async()=>{let w=await wn(e);if(w===void 0)return h(()=>r(void 0));if(c)return;let k=document.createElement("iframe");k.src=`${Er}?${new URLSearchParams({sitekey:w,origin:window.location.origin,...i&&{theme:i}}).toString()}`,k.title="Cloudflare security check",k.style.cssText=`display:block;border:0;width:${o?"100%":"300px"};height:0;color-scheme:normal`,o?o.appendChild(k):(k.style.cssText+=";position:fixed;bottom:16px;right:16px;z-index:2147483647",document.body.appendChild(k));let E=!1,x=N=>{if(!k.contentWindow||N.source!==k.contentWindow||N.origin!==gn||!xn(N.data))return;let O=N.data;switch(O.type){case"token":return h(()=>r(O.token));case"resize":k.style.height=`${Math.max(0,Math.ceil(O.height))}px`;return;case"before-interactive":return E=!0,v(vn),l==null?void 0:l();case"after-interactive":return E=!1,v(Wt);case"error":!E&&!O.interactive&&b("Captcha failed");return;case"expired":return b("Captcha expired");case"timeout":return b("Captcha timed out")}};window.addEventListener("message",x),f=()=>{window.removeEventListener("message",x),k.remove()}})().catch(w=>h(()=>n(w)))}),Ht=({condition:e,context:t,submissions:r,ifBlock:n})=>{let[a,...o]=e.compareKey.split(".");if(!a)return!1;let i=s.de({context:t,key:a,path:o,submissions:r});if(!i)return!1;switch(i.type){case"address":{let l=s.L(i.value,o);switch(e.compare){case"equals":return l===e.compareValue;case"contains":return typeof l!="string"?!1:l.includes(e.compareValue);case"notEquals":return l!==e.compareValue;case"notContains":return typeof l!="string"?!0:!l.includes(e.compareValue)}break}case"integration":{if(typeof i.value!="object"||Array.isArray(i.value))return!1;let l=s.L(i.value,o),c={...n,data:{compareKey:"_temp",compare:e.compare,compareValue:e.compareValue}};switch(typeof l){case"boolean":return Ze(c,{submissions:{_temp:{value:l,type:"boolean"}},context:t});case"string":return Ze(c,{submissions:{_temp:{value:l,type:"string"}},context:t});case"number":return Ze(c,{submissions:{_temp:{value:l,type:"number"}},context:t});case"object":return Array.isArray(l)&&l.every(f=>typeof f=="string")?Ze(c,{submissions:{_temp:{value:l,type:"enum"}},context:t}):!1}break}case"boolean":{let l=e.compareValue==="true";switch(e.compare){case"equals":return i.value===l;case"notEquals":return i.value!==l}break}case"phone":case"string":{let l=i.type==="phone"?s.ge(i.value):i.value;switch(e.compare){case"equals":return l===e.compareValue;case"contains":return l?l.includes(e.compareValue):!1;case"notEquals":return l!==e.compareValue;case"notContains":return l?!l.includes(e.compareValue):!0}break}case"number":{try{let l=Number(e.compareValue);switch(e.compare){case"equals":return i.value===l;case"notEquals":return i.value!==l;case"greaterThan":return i.value>l;case"greaterThanOrEqualTo":return i.value>=l;case"lessThan":return i.value<l;case"lessThanOrEqualTo":return i.value<=l}}catch{return console.error(`Failed to parse number in if-block ${n.id}`,i.value),!1}break}case"enum":switch(e.compare){case"equals":return i.value.length===1&&i.value[0]===e.compareValue;case"notEquals":return i.value.length===1&&i.value[0]!==e.compareValue;case"contains":return i.value.includes(e.compareValue);case"notContains":return!i.value.includes(e.compareValue)}break}},Ze=(e,{context:t,submissions:r})=>{let n="combinator"in e.data?e.data.conditions:[e.data];if(("combinator"in e.data?e.data.combinator:"and")==="or"){for(let a of n)if(Ht({condition:a,context:t,submissions:r,ifBlock:e}))return!0;return!1}else{for(let a of n)if(!Ht({condition:a,context:t,submissions:r,ifBlock:e}))return!1;return!0}},kn=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,Cn=(e,{context:t,submissions:r})=>e.replace(kn,(n,a,o="")=>{let[i,...l]=a.trim().split("."),c=s.de({key:i,path:l,submissions:r,context:t});if(!c)return o;switch(c.type){case"boolean":return c.value===!0?"true":"false";case"file":return c.value.map(f=>`${f.name} (${s.fe(f.sizeKb)})`).join(", ");case"enum":return c.value.join(", ");case"address":return Object.values(c.value).filter(f=>f&&f.trim().length>0).join(", ");case"number":case"string":return c.value?c.value.toString():o;case"phone":return s.ge(c.value);case"integration":{if(typeof c.value!="object"||Array.isArray(c.value))break;let f=s.L(c.value,l);switch(typeof f){case"boolean":return f===!0?"true":"false";case"string":return f;case"number":return f.toString();case"object":if(Array.isArray(f)&&f.every(h=>typeof h=="string"))return f.join(", ")}break}}return o});/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Sn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ft(e,t,r=""){const n=Sn(e),a=e==null?void 0:e.length;if(!n||t!==void 0){const i=r&&`"${r}" `,l="",c=n?`length=${a}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+l+", got "+c)}return e}function Kt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function An(e,t){Ft(e,void 0,"digestInto() output");const r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function kt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function bt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function de(e,t){return e<<32-t|e>>>t}const En=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",In=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Fn(e){if(Ft(e),En)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=In[e[r]];return t}function Vn(e,t={}){const r=(a,o)=>e(o).update(a).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=a=>e(a),Object.assign(r,t),Object.freeze(r)}const Ln=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Mn(e,t,r){return e&t^~e&r}function Tn(e,t,r){return e&t^e&r^t&r}class Rn{constructor(t,r,n,a){X(this,"blockLen");X(this,"outputLen");X(this,"padOffset");X(this,"isLE");X(this,"buffer");X(this,"view");X(this,"finished",!1);X(this,"length",0);X(this,"pos",0);X(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=a,this.buffer=new Uint8Array(t),this.view=bt(this.buffer)}update(t){Kt(this),Ft(t);const{view:r,buffer:n,blockLen:a}=this,o=t.length;for(let i=0;i<o;){const l=Math.min(a-this.pos,o-i);if(l===a){const c=bt(t);for(;a<=o-i;i+=a)this.process(c,i);continue}n.set(t.subarray(i,i+l),this.pos),this.pos+=l,i+=l,this.pos===a&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Kt(this),An(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:a,isLE:o}=this;let{pos:i}=this;r[i++]=128,kt(this.buffer.subarray(i)),this.padOffset>a-i&&(this.process(n,0),i=0);for(let b=i;b<a;b++)r[b]=0;n.setBigUint64(a-8,BigInt(this.length*8),o),this.process(n,0);const l=bt(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const f=c/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let b=0;b<f;b++)l.setUint32(4*b,h[b],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:a,finished:o,destroyed:i,pos:l}=this;return t.destroyed=i,t.finished=o,t.length=a,t.pos=l,a%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const _e=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Dn=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ke=new Uint32Array(64);class On extends Rn{constructor(t){super(64,t,8,!1)}get(){const{A:t,B:r,C:n,D:a,E:o,F:i,G:l,H:c}=this;return[t,r,n,a,o,i,l,c]}set(t,r,n,a,o,i,l,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=a|0,this.E=o|0,this.F=i|0,this.G=l|0,this.H=c|0}process(t,r){for(let b=0;b<16;b++,r+=4)ke[b]=t.getUint32(r,!1);for(let b=16;b<64;b++){const g=ke[b-15],p=ke[b-2],v=de(g,7)^de(g,18)^g>>>3,w=de(p,17)^de(p,19)^p>>>10;ke[b]=w+ke[b-7]+v+ke[b-16]|0}let{A:n,B:a,C:o,D:i,E:l,F:c,G:f,H:h}=this;for(let b=0;b<64;b++){const g=de(l,6)^de(l,11)^de(l,25),p=h+g+Mn(l,c,f)+Dn[b]+ke[b]|0,w=(de(n,2)^de(n,13)^de(n,22))+Tn(n,a,o)|0;h=f,f=c,c=l,l=i+p|0,i=o,o=a,a=n,n=p+w|0}n=n+this.A|0,a=a+this.B|0,o=o+this.C|0,i=i+this.D|0,l=l+this.E|0,c=c+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,a,o,i,l,c,f,h)}roundClean(){kt(ke)}destroy(){this.set(0,0,0,0,0,0,0,0),kt(this.buffer)}}class Nn extends On{constructor(){super(32);X(this,"A",_e[0]|0);X(this,"B",_e[1]|0);X(this,"C",_e[2]|0);X(this,"D",_e[3]|0);X(this,"E",_e[4]|0);X(this,"F",_e[5]|0);X(this,"G",_e[6]|0);X(this,"H",_e[7]|0)}}const jn=Vn(()=>new Nn,Ln(1));var Ir=e=>{let t=e.find(r=>r.isHead);if(!t)throw new Error("No head node found");return t},Vt=e=>{var t,r;if(!(e.data.isFinished||(t=e.data.startedWriteNodeIds)!=null&&t.length))return(r=[...e.data.messages].reverse().find(n=>n.groupId&&e.nodes.some(a=>a.id===n.groupId&&a.type.startsWith("question-"))&&(n.type==="system"||"author"in n&&n.author==="user")))==null?void 0:r.groupId},Ct=e=>Array.isArray(e)?e.map(Ct):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>[t,Ct(r)])):typeof e=="function"?void 0:e,Bn=e=>Fn(jn(new TextEncoder().encode(JSON.stringify(Ct(e)))));function Pn(e,t,r,n){var a;if(n!=null&&n.aborted)return;let o=Bn(r),i=(a=e.data).preApplyFingerprints??(a.preApplyFingerprints=[]);if(i.includes(o))return;i.push(o);let l=new AbortController,c=setTimeout(()=>l.abort(),5e3);t.fetch("/flow/pre-apply",{method:"POST",signal:l.signal,body:JSON.stringify(r)}).catch(()=>{let f=i.indexOf(o);f!==-1&&i.splice(f,1)}).finally(()=>{clearTimeout(c)})}var Fr=({context:e,submissions:t})=>({context:e,submissions:t??{}}),ue=(e,t)=>Cn(e,Fr(t)),$n=(e,t)=>Ze(e,Fr(t)),Vr=({node:e,nodes:t,stopWhen:r})=>{if((r==null?void 0:r(e))===!0)return e;let n=e.nextId?t.find(a=>a.id===e.nextId):void 0;if(n)return Vr({node:n,nodes:t,stopWhen:r})},Un=({childNode:e,nodes:t})=>{let r=t.filter(n=>n.type==="if-block").find(n=>{if(!n.branchId)return!1;let a=t.find(i=>i.id===n.branchId);if(!a)return!1;let o=Vr({node:a,nodes:t,stopWhen:i=>i.id===e.id});return!(!o||o.id!==e.id)});if(r!=null&&r.nextId)return t.find(n=>n.id===r.nextId)},qn=3,zn=({flow:e,analytics:t,logger:r,talentBankClient:n,context:a,apiClient:o,getSubmissions:i,getApplicationRecovery:l,setApplicationRecovery:c,chatService:f,persistWriteBarrier:h,onSubmitNetworkError:b,closedRoleBehaviour:g,settledOutcomes:p=g,dateEchoLocale:v,onFlowEnd:w,onInterpret:k,forceSubmitConfirmation:E,flowType:x,t:N})=>{var O;let T=new AbortController,H={submitAccepted:!1};(O=e.data).startedWriteNodeIds??(O.startedWriteNodeIds=e.nodes.flatMap(C=>{var D,V;if(C.type!=="integration-application-submit"||!e.data.nodeHistory.includes(C.id))return[];let L=C.data.key?(D=i())==null?void 0:D[C.data.key]:void 0;return(L==null?void 0:L.type)==="integration"&&((V=s.ye(L.value))==null?void 0:V.verdict)==="not_submitted"?[]:[C.id]}));let B={...t.service,log:C=>t.service.log({...C,customProperties:{...C.customProperties,...t.customProperties}})},A=async(C,L)=>{let D=T.signal;if(D.aborted)return;let V=i(),M=l(),P=(M==null?void 0:M.submitNodeId)===C.id?e.nodes.find(R=>{var z;return R.id===M.fileQuestionNodeId&&R.type==="question-file"&&((z=V==null?void 0:V[R.data.key])==null?void 0:z.type)!=="file"}):void 0;if(P)return A(P,L);k==null||k(C,L);try{await Wn({flow:e,analytics:B,logger:r,talentBankClient:n,apiClient:o,context:a,node:C,submissions:V,applicationRecovery:M,setApplicationRecovery:async R=>{if(!D.aborted)try{await c(R)}catch(z){r.error("Failed to persist application recovery",z)}},forceSubmitConfirmation:E||(M==null?void 0:M.submitNodeId)===C.id,run:H,persistWriteBarrier:h,onSubmitNetworkError:b,settledOutcomes:p,dateEchoLocale:v,flowType:x,signal:D,t:N,chat:{sendMessage:async R=>f.send({groupId:C.id,message:R,signal:D}),userInput:async R=>f.input({input:R,signal:D}),setSubmission:(R,z)=>{D.aborted||f.setSubmission(R,z)},captcha:f.captcha},next:R=>{if(D.aborted)return;let z=(M==null?void 0:M.fileQuestionNodeId)===C.id?M.submitNodeId:R,q=z?e.nodes.find(Q=>Q.id===z):Un({childNode:C,nodes:e.nodes});return q?A(q,C):w==null?void 0:w(C)},end:()=>{D.aborted||(w==null||w(C))}})}catch(R){if(R instanceof s.O)return;throw R}};return{interpret:async C=>{let L=e.nodes.find(D=>D.id===C)??Ir(e.nodes);return A(L)},undo:C=>{var z;if(delete e.data.reviewReplay,((z=e.data.startedWriteNodeIds)==null?void 0:z.length)||e.data.isFinished)return{removed:0};let L=Vt(e),D=L?C.lastIndexOf(L):-1,V=e.nodes.find(q=>q.id===L);if(D===-1||!V)return{removed:0};let M=e.nodes.find(q=>q.id===C[C.length-1]);T.abort();let P=C.splice(D);e.data.messages=e.data.messages.filter(q=>!q.groupId||!P.includes(q.groupId)),e.data.currentInput=null;let R=i();for(let q of P.slice(1)){let Q=e.nodes.find(ie=>ie.id===q);if(!(!Q||!R||Q.id===L)&&("key"in Q.data&&Q.data.key&&delete R[Q.data.key],"keys"in Q.data))for(let ie of Object.values(Q.data.keys))typeof ie=="string"&&delete R[ie]}return T=new AbortController,A(V,M),{removed:P.length}},abort:()=>{T.abort()}}};async function Wn(e){let t=e.node;switch(t.type){case"flow-section":return await e.chat.sendMessage({type:"system",variant:"info",text:t.data.title}),e.next(t.nextId);case"pre-apply-result":return ys({...e,node:t});case"text":return is({...e,node:t});case"image":return os({...e,node:t});case"question-text":return ls({...e,node:t});case"question-enum":return ds({...e,node:t});case"question-number":return cs({...e,node:t});case"question-phone":return us({...e,node:t});case"question-boolean":return fs({...e,node:t});case"question-file":return ps({...e,node:t});case"question-address":return hs({...e,node:t});case"end-flow":return ms({...e,node:t});case"if-block":return as({...e,node:t});case"jump":return Gn({...e,node:t});case"link":return ss({...e,node:t});case"integration-application-submit":return ts({...e,node:t});case"add-submission":return Jn({...e,node:t});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"check-duplicate":return Kn({...e,node:t});case"feedback":return Hn({...e,node:t});default:throw new Error(`Unknown node: ${JSON.stringify(t)}`)}}async function Hn({next:e,node:t}){e(t.nextId)}async function Kn({next:e,node:t,talentBankClient:r,submissions:n,flow:a,logger:o,chat:i}){var c;let l={isDuplicate:!1};if(n&&r){let f=t.data.scope==="job"?(c=a.job)==null?void 0:c.id:void 0;if(t.data.scope==="company"||f!=null)try{l=await r.checkDuplicate({email:s.pe({key:t.data.email,submissions:n}).toString(),jobId:f,scope:t.data.scope})}catch(h){o.error("[check-duplicate]",h)}}i.setSubmission(t.data.key,{type:"integration",value:l}),e(t.nextId)}async function Gn({next:e,node:t}){e(t.data.targetId)}async function Jn({next:e,node:t,logger:r,submissions:n,context:a}){if(!n){r.error("Submissions not found");return}n[t.data.key]={type:"string",value:ue(t.data.value,{submissions:n,context:a})},e(t.nextId)}var Zn=5e3,Xn=(e,t)=>t?`${e}@${t.id_type}:${t.id}`:e,Yn=(e,t=Date.now())=>Math.min(e.until,t+(e.maintenance?s.Q:e.throttles?s.J:s.X)),Qn=(e,t,r)=>{let{waitMs:n,throttles:a,maintenance:o}=s.ke(t==null?void 0:t.throttles,r);return{key:e,until:Date.now()+n,...a!==void 0&&{throttles:a},...o&&{maintenance:o}}},es=["ApiError","NotFoundError","UnauthorisedError","SchemaValidationError","ParsingError"],St=e=>e instanceof Error&&es.includes(e.name)?e:void 0,Gt=e=>{let t=St(e);return(t==null?void 0:t.name)==="ApiError"?t:void 0};async function ts({chat:e,next:t,end:r,node:n,logger:a,apiClient:o,submissions:i,analytics:l,flow:c,applicationRecovery:f,setApplicationRecovery:h,forceSubmitConfirmation:b,flowType:g,run:p,persistWriteBarrier:v,signal:w,onSubmitNetworkError:k,settledOutcomes:E,t:x}){var A,C;let N=async({redirect_url:L,message:D,button_text:V})=>{let{anonymous_id:M,session_id:P}=l.getSessionInfo();await e.sendMessage({type:"text",author:"bot",text:D??x("submission_redirect_message")});try{let R=new URL(L);M&&!R.searchParams.has("anonymous_id")&&R.searchParams.set("anonymous_id",M),await e.sendMessage({type:"link",href:R.toString(),text:V??x("complete_submission"),onClick:()=>{if(!P){a.error("session_id not set, cannot log FLOW_REDIRECT event");return}l.log({event:"FLOW_REDIRECT",properties:{flow_build:c.build,flow_id:c.id,flow_session_id:P,flow_version:c.version,href:R.toString(),job:c.job}})}})}catch(R){a.error(`Invalid redirect URL: ${L}`,R),e.sendMessage({type:"system",variant:"error",text:x("redirect_url_error")})}};if((A=c.data.startedWriteNodeIds)!=null&&A.includes(n.id)&&(f==null?void 0:f.submitNodeId)!==n.id){let L=(C=c.data.submitRedirects)==null?void 0:C[n.id];return L?(await N(L),t(n.nextId)):(await e.sendMessage({type:"system",variant:"warning",text:x("submission_unknown")}),r())}let O=Xn(n.id,c.job),T=0,H=p.submitAccepted&&n.data.skipConfirmation===!0&&(f==null?void 0:f.submitNodeId)!==n.id,B=async L=>{var nt,st,ht,Ke,u,d,m,S,_;let D=((nt=c.data.submitCooldown)==null?void 0:nt.key)===O?c.data.submitCooldown:void 0;D&&(D.until=Yn(D));let V=D==null?void 0:D.until;(c.data.reviewRequiresSend===!0&&!H||L!==!0||V!==void 0&&V>Date.now())&&await e.userInput({type:"submit",key:void 0,config:{label:n.data.submitLabel,...V!==void 0&&{availableAt:V}}}),H=!1;let M;if(n.data.captcha){let y=e.captcha,I=!0;try{M=await _n(o,{signal:w,container:(y==null?void 0:y.container())??null,theme:y==null?void 0:y.theme,onInteractive:()=>{e.sendMessage({type:"text",author:"bot",text:x("captcha_check")}).catch(()=>{}).then(()=>{I&&(y==null||y.reveal(!0))})}})}catch($){if(a.error("Captcha check failed",$),w.aborted)return}finally{I=!1,y==null||y.reveal(!1)}}await e.sendMessage({type:"loading",text:x("submitting")});let{anonymous_id:P,session_id:R}=l.getSessionInfo();if(w.aborted)return;let z=((st=c.data.startedWriteNodeIds)==null?void 0:st.includes(n.id))===!0;if((f==null?void 0:f.submitNodeId)===n.id&&await h(void 0),z||(c.data.startedWriteNodeIds=[...c.data.startedWriteNodeIds??[],n.id]),await v().catch(y=>a.error("Failed to persist application write barrier",y)),w.aborted)return;let q,Q=setTimeout(()=>{q=e.sendMessage({type:"loading",semantic:"submission-still-working",text:x("submission_still_working")}).catch(y=>a.error("Failed to send submission progress message",y))},Zn),ie=s.ue(),ne,K=await o.fetch("/flow/submit",{method:"POST",body:JSON.stringify({...ie!==void 0&&{browser_timezone:ie},log_submit:!1,integration_id:n.data.integrationId,anonymous_id:P,session_id:R,job:c.job,flow_build:c.build,...M!==void 0&&{captcha_token:M},submissions:s.P(c.nodes,s.ce(i||{},n.data.submitKeys)),pre_apply:s.j(c.nodes,i||{},c.data.flowSessionId)})}).catch(y=>{ne=y;let I=Gt(y);return(I==null?void 0:I.data)!==void 0?I.data:y});if(clearTimeout(Q),await q,w.aborted)return;if(ne!==void 0&&!St(ne)&&k)return await k(ne,w),B(!0);c.data.stagingDestination=s.we(K),n.data.key&&e.setSubmission(n.data.key,{type:"integration",value:K});let $e=(ht=Gt(ne))==null?void 0:ht.status,Ue=typeof $e=="number"?$e:void 0,j=s.ye(K,Ue),qe=j===void 0&&Ue===429,Ae=E==="terminal"&&((j==null?void 0:j.outcome)==="closed"||(j==null?void 0:j.outcome)==="duplicate"),Ee=c.data.failedAttemptAt,pe=Ee==null?void 0:Ee[O];Ee&&pe!==void 0&&pe>Date.now()&&(pe=Ee[O]=Date.now());let ze=pe!==void 0&&Date.now()-pe<s.xe||((Ke=c.data.unconfirmedAttemptKeys)==null?void 0:Ke.includes(O))===!0,Te=(u=St(ne))==null?void 0:u.status,me=s.Te(K,typeof Te=="number"?Te:void 0);me&&l.log({event:"FLOW_SUBMIT",properties:{flow_id:c.id,flow_version:c.version,flow_session_id:c.data.flowSessionId,flow_build:c.build,service:me.service,response:me.response,captured:(K==null?void 0:K.captured)===!0,flow_type:(g==null?void 0:g())??"CHATBOT_DRAWER",job:c.job,...(j==null?void 0:j.outcome)==="duplicate"&&{outcome:ze?"duplicate_after_own_attempt":"duplicate"},...me.outcome&&{outcome:me.outcome}}});let rt=s.V(K)||(K==null?void 0:K.success)===!0;if((rt||s.W(K))&&(p.submitAccepted=!0),rt&&((d=c.data.submitCooldown)==null?void 0:d.throttles)!==void 0&&(delete c.data.submitCooldown.throttles,await v().catch(y=>a.error("Failed to persist submit cooldown reset",y))),s.V(K)){let{redirect_url:y,message:I,button_text:$}=K.integration_response.data,U={redirect_url:y,message:I,button_text:$};return w.aborted?void 0:(c.data.submitRedirects={...c.data.submitRedirects,[n.id]:U},await v().catch(ee=>a.error("Failed to persist submit redirect",ee)),await N(U),t(n.nextId))}let We=s.W(K);if(We)return await e.sendMessage({type:"system",variant:"success",text:We.message??x("submission_pending")}),t(n.nextId);if((K==null?void 0:K.success)===!0)return n.data.skipConfirmation!==!0&&await e.sendMessage({type:"system",variant:"success",text:x("submission_completed")}),t(n.nextId);let He=s.Ae(j),Ie=He!==void 0&&((m=i==null?void 0:i[He])==null?void 0:m.type)==="file"?He:void 0,Fe=Ie===void 0?void 0:c.nodes.find(y=>y.type==="question-file"&&y.data.key===Ie);if(!Fe&&!Ae&&!s.Se(j)&&(c.data.submitCooldown=Qn(O,D,j)),(j==null?void 0:j.outcome)!=="duplicate"&&!qe&&(c.data.failedAttemptAt={...c.data.failedAttemptAt,[O]:Date.now()},(S=c.data.unconfirmedAttemptKeys)!=null&&S.includes(O)&&(c.data.unconfirmedAttemptKeys=c.data.unconfirmedAttemptKeys.filter(y=>y!==O))),(j==null?void 0:j.verdict)==="not_submitted"||(j==null?void 0:j.outcome)==="duplicate"||(j==null?void 0:j.outcome)==="closed"||qe||s.ve(K,Ue)?(z||(c.data.startedWriteNodeIds=(_=c.data.startedWriteNodeIds)==null?void 0:_.filter(y=>y!==n.id)),(f==null?void 0:f.submitNodeId)===n.id&&await h(f),await v().catch(y=>a.error("Failed to persist application write barrier release",y))):await v().catch(y=>a.error("Failed to persist submit cooldown",y)),j){if(a.error(ne??j.message),Fe&&Ie!==void 0)return e.setSubmission(Ie,null),await h({fileQuestionNodeId:Fe.id,submitNodeId:n.id}),await e.sendMessage({type:"system",variant:"error",text:x("submission_unreadable_document")}),t(Fe.id);if(j.outcome==="duplicate")return await e.sendMessage({type:"system",variant:Ae?"success":"info",semantic:"submission-duplicate",text:x(ze?"submission_duplicate_earlier_attempt":"submission_duplicate")}),Ae?(delete c.data.submitCooldown,r()):B(!1);if(j.outcome==="closed")return await e.sendMessage({type:"system",variant:"info",semantic:"submission-closed",text:x("submission_closed")}),Ae?(delete c.data.submitCooldown,r()):B(!1);let y=s.he(j);return y?(await e.sendMessage({type:"system",variant:"warning",text:y.until===void 0?x("submission_provider_maintenance_later"):x("submission_provider_maintenance",{time:s._e(y.until,void 0)})}),B(!1)):j.outcome==="unknown"?(await e.sendMessage({type:"system",variant:"warning",text:x(s.Fe(j)?"submission_unknown_do_not_resubmit":"submission_unknown")}),B(!1)):s.Se(j)?s.Re(K)?(await e.sendMessage({type:"text",author:"bot",text:j.message}),B(!1)):(T===0&&await e.sendMessage({type:"system",variant:"warning",text:x("captcha_failed")}),T++,B(T<=qn)):s.Ee(j)?(await e.sendMessage({type:"system",variant:"error",text:x("submission_retryable")}),B(!1)):(await e.sendMessage({type:"system",variant:"error",text:x("submission_failed")}),r())}return a.error(ne??K),qe?(await e.sendMessage({type:"system",variant:"error",text:x("submission_retryable")}),B(!1)):(await e.sendMessage({type:"system",variant:"error",text:x("submission_failed")}),r())};await B(b===!0&&!H?!1:n.data.skipConfirmation)}var rs=/{{\s*\$context\.job\.apply_url\s*(?:\|[^}]*)?}}/,ns=(e,t)=>{if(!rs.test(e))return!1;try{let{protocol:r}=new URL(t);return r==="https:"||r==="http:"}catch{return!1}};async function ss({chat:e,next:t,node:r,submissions:n,context:a,analytics:o,flow:i}){let l=ue(r.data.href,{submissions:n,context:a}),{flowSessionId:c}=i.data;await e.sendMessage({type:"link",href:l,text:ue(r.data.cta,{submissions:n,context:a}),...ns(r.data.href,l)&&{onClick:()=>{o.log({event:"FLOW_REDIRECT",properties:{flow_build:i.build,flow_id:i.id,flow_session_id:c,flow_version:i.version,href:l,job:i.job}})}}}),t(r.nextId)}async function as({submissions:e,next:t,node:r,context:n}){t($n(r,{submissions:e,context:n})?r.branchId:r.nextId)}async function is({chat:e,next:t,node:r,submissions:n,context:a}){await e.sendMessage({author:"bot",type:"text",text:ue(r.data.text,{submissions:n,context:a})}),t(r.nextId)}async function os({chat:e,next:t,node:r}){await e.sendMessage({author:"bot",type:"image",url:r.data.url,height:r.data.height,width:r.data.width}),t(r.nextId)}async function ls({chat:e,next:t,node:r,submissions:n,context:a,t:o,dateEchoLocale:i}){await e.sendMessage({author:"bot",type:"text",text:ue(r.data.question,{submissions:n,context:a})});let l=r.data.format==="phone"?await e.userInput({key:r.data.key,type:"phone",config:{optional:r.data.optional,placeholder:r.data.placeholder,minChars:r.data.minChars,maxChars:r.data.maxChars,submissionFormat:"text",defaultValue:{}}}):await e.userInput({key:r.data.key,type:"text",config:{optional:r.data.optional,placeholder:r.data.placeholder,format:r.data.format,maxChars:r.data.maxChars,minChars:r.data.minChars,multiline:r.data.format==="text"&&r.data.multiline===!0}});l===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:l.type==="phone"?s.ge(l.value):r.data.format==="date"&&i!==void 0?s.je(l.value,i):l.value}),t(r.nextId)}async function cs({chat:e,next:t,node:r,submissions:n,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:ue(r.data.question,{submissions:n,context:a})});let i=await e.userInput({key:r.data.key,type:"number",config:{max:r.data.max,min:r.data.min,optional:r.data.optional,placeholder:r.data.placeholder,decimalCases:r.data.decimalCases}});i===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:i.value.toString()}),t(r.nextId)}async function us({chat:e,next:t,node:r,submissions:n,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:ue(r.data.question,{submissions:n,context:a})});let i=await e.userInput({key:r.data.key,type:"phone",config:{minChars:r.data.minChars,defaultValue:{countryCode:r.data.defaultCountryCode},placeholder:r.data.placeholder,submissionFormat:"phone",optional:r.data.optional}});i===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:i.type==="phone"?s.ge(i.value):i.value}),t(r.nextId)}async function ds({chat:e,next:t,node:r,submissions:n,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:ue(r.data.question,{submissions:n,context:a})});let i=await e.userInput({key:r.data.key,type:"multiple-choice",config:r.data});i.value.length===0?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:r.data.options.filter(l=>i.value.includes(l.value)).map(l=>l.label).join(", ")}),t(r.nextId)}async function fs({chat:e,next:t,node:r,submissions:n,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:ue(r.data.question,{submissions:n,context:a})});let i=await e.userInput({key:r.data.key,type:"boolean",config:{optional:r.data.optional,labels:{true:r.data.trueLabel,false:r.data.falseLabel}}});i===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:i.value===!0?r.data.trueLabel:r.data.falseLabel}),t(r.nextId)}async function hs({chat:e,next:t,node:r,t:n}){await e.sendMessage({author:"bot",type:"text",text:r.data.question});let a=await e.userInput({type:"address",key:r.data.key,config:{optional:r.data.optional,keys:r.data.keys,line2Required:r.data.line2Required,placeholder:r.data.placeholder}});if(a===null)await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:n("skipped")});else{let o=Object.values(a.value).filter(i=>i&&i.trim().length>0).join(", ");await e.sendMessage({author:"user",type:"text",text:o})}return t(r.nextId)}async function ps({node:e,chat:t,next:r,submissions:n,context:a,t:o}){await t.sendMessage({author:"bot",type:"text",text:ue(e.data.question,{submissions:n,context:a})});let i=await t.userInput({key:e.data.key,type:"file",config:{optional:e.data.optional,extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb??10*1024,allowMultiple:e.data.multiple===!0}});if(i===null)await t.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:o("skipped")});else for(let l of i.value)await t.sendMessage({author:"user",type:"file",fileName:l.name,fileSizeKb:l.sizeKb});return r(e.nextId)}async function ms({chat:e,end:t,node:r}){await e.sendMessage({type:"system",variant:"info",text:r.data.systemMessage}),t()}async function ys({node:e,flow:t,submissions:r,chat:n,next:a,apiClient:o,analytics:i,signal:l,context:c}){let f=s.C(t.nodes,r||{}),{answers:h,...b}=f;if(n.setSubmission(e.data.key,{type:"integration",value:b}),Pn(t,o,{...i.getSessionInfo(),job:t.job,flow_build:t.build,pre_apply:s.j(t.nodes,r||{},t.data.flowSessionId)},l),f.status!=="skipped"){let g=[f.status==="unavailable"?"We could not prepare your pre-apply summary. You can still continue to your application.":f.hasHardConcerns?e.data.messages.hard:f.hasAdvisoryConcerns?e.data.messages.advisory:e.data.messages.matched];for(let p of["hard","advisory"]){let v=h.filter(w=>!w.matched&&w.severity===p);v.length&&g.push((p==="hard"?"Role requirements":"Other things to consider")+`
|
|
2
|
-
`+v.map(w=>`• ${w.message}`).join(`
|
|
3
|
-
`))}await n.sendMessage({type:"text",author:"bot",text:g.join(`
|
|
4
|
-
|
|
5
|
-
`)}),f.hasHardConcerns&&e.data.alternativeLink&&await n.sendMessage({type:"link",href:e.data.alternativeLink.href,text:e.data.alternativeLink.label}),await n.userInput({type:"submit",key:void 0,config:{label:ue(e.data.continueLabel,{submissions:r,context:c})}})}return a(e.nextId)}const Jt=(e,t,r)=>{var n;return e.log({event:r,properties:{flow_id:t.id,flow_version:t.version,flow_session_id:t.data.flowSessionId,flow_build:t.build,flow_type:"CHATBOT_DRAWER",job:t.job},customProperties:(n=t.analytics)==null?void 0:n.customProperties})},At="resume-prompt",bs=async({chatService:e,t,signal:r})=>{await e.send({message:{type:"text",author:"bot",text:t("resume_prompt")},groupId:At,signal:r});const n=await e.input({input:{type:"boolean",key:void 0,config:{labels:{true:t("resume_continue"),false:t("resume_start_again")},optional:!1}},signal:r});return s.store.removeMessagesSentByNodeIds([At]),(n==null?void 0:n.value)!==!1},Me=({class:e,...t})=>{const{t:r}=s.useTranslation();return s.o("button",{class:s.clsx("bg-accent-9 active:bg-accent-10 pointer-coarse:touch-hitbox fr flex-shrink-0 rounded-full p-2 text-white transition-all disabled:cursor-not-allowed disabled:opacity-50",e),type:"submit",...t,children:s.o("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[s.o("title",{children:r("send")}),s.o("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),s.o("path",{d:"M8 4V13"})]})})};var ye;function Lt(e){return{lang:(e==null?void 0:e.lang)??(ye==null?void 0:ye.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(ye==null?void 0:ye.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(ye==null?void 0:ye.abortPipeEarly)}}var gt;function gs(e){return gt==null?void 0:gt.get(e)}var vt;function vs(e){return vt==null?void 0:vt.get(e)}var xt;function xs(e,t){var r;return(r=xt==null?void 0:xt.get(e))==null?void 0:r.get(t)}function je(e){var r,n;const t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&((n=(r=Object.getPrototypeOf(e))==null?void 0:r.constructor)==null?void 0:n.name))??"null":t}function te(e,t,r,n,a){const o=a&&"input"in a?a.input:r.value,i=(a==null?void 0:a.expected)??e.expects??null,l=(a==null?void 0:a.received)??je(o),c={kind:e.kind,type:e.type,input:o,expected:i,received:l,message:`Invalid ${t}: ${i?`Expected ${i} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:a==null?void 0:a.path,issues:a==null?void 0:a.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(a==null?void 0:a.message)??e.message??xs(e.reference,c.lang)??(f?vs(c.lang):null)??n.message??gs(c.lang);h!==void 0&&(c.message=typeof h=="function"?h(c):h),f&&(r.typed=!1),r.issues?r.issues.push(c):r.issues=[c]}function he(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},Lt())}}}function ws(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function _s(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}function ks(e){if(e.path){let t="";for(const r of e.path)if(typeof r.key=="string"||typeof r.key=="number")t?t+=`.${r.key}`:t+=r.key;else return null;return t}return null}var Lr=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}},Cs=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;function Mr(e,t){return{kind:"validation",type:"check",reference:Mr,async:!1,expects:null,requirement:e,message:t,"~run"(r,n){return r.typed&&!this.requirement(r.value)&&te(this,"input",r,n),r}}}function Tr(e){return{kind:"validation",type:"email",reference:Tr,expects:null,async:!1,requirement:Cs,message:e,"~run"(t,r){return t.typed&&!this.requirement.test(t.value)&&te(this,"email",t,r),t}}}function Ye(e,t){return{kind:"validation",type:"max_length",reference:Ye,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(r,n){return r.typed&&r.value.length>this.requirement&&te(this,"length",r,n,{received:`${r.value.length}`}),r}}}function Rr(e,t){return{kind:"validation",type:"max_value",reference:Rr,async:!1,expects:`<=${e instanceof Date?e.toJSON():je(e)}`,requirement:e,message:t,"~run"(r,n){return r.typed&&!(r.value<=this.requirement)&&te(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():je(r.value)}),r}}}function Ne(e,t){return{kind:"validation",type:"min_length",reference:Ne,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(r,n){return r.typed&&r.value.length<this.requirement&&te(this,"length",r,n,{received:`${r.value.length}`}),r}}}function Dr(e,t){return{kind:"validation",type:"min_value",reference:Dr,async:!1,expects:`>=${e instanceof Date?e.toJSON():je(e)}`,requirement:e,message:t,"~run"(r,n){return r.typed&&!(r.value>=this.requirement)&&te(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():je(r.value)}),r}}}function Mt(e,t){return{kind:"validation",type:"regex",reference:Mt,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(r,n){return r.typed&&!this.requirement.test(r.value)&&te(this,"format",r,n),r}}}function Tt(e){return{kind:"transformation",type:"transform",reference:Tt,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function Or(e){return{kind:"validation",type:"url",reference:Or,async:!1,expects:null,requirement(t){try{return new URL(t),!0}catch{return!1}},message:e,"~run"(t,r){return t.typed&&!this.requirement(t.value)&&te(this,"URL",t,r),t}}}function Ss(e,t,r){return typeof e.fallback=="function"?e.fallback(t,r):e.fallback}function Nr(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function jr(e,t){return{kind:"schema",type:"array",reference:jr,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return he(this)},"~run"(r,n){var o;const a=r.value;if(Array.isArray(a)){r.typed=!0,r.value=[];for(let i=0;i<a.length;i++){const l=a[i],c=this.item["~run"]({value:l},n);if(c.issues){const f={type:"array",origin:"value",input:a,key:i,value:l};for(const h of c.issues)h.path?h.path.unshift(f):h.path=[f],(o=r.issues)==null||o.push(h);if(r.issues||(r.issues=c.issues),n.abortEarly){r.typed=!1;break}}c.typed||(r.typed=!1),r.value.push(c.value)}}else te(this,"type",r,n);return r}}}function Br(e){return{kind:"schema",type:"boolean",reference:Br,expects:"boolean",async:!1,message:e,get"~standard"(){return he(this)},"~run"(t,r){return typeof t.value=="boolean"?t.typed=!0:te(this,"type",t,r),t}}}function Pr(e){return{kind:"schema",type:"number",reference:Pr,expects:"number",async:!1,message:e,get"~standard"(){return he(this)},"~run"(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:te(this,"type",t,r),t}}}function ve(e,t){return{kind:"schema",type:"object",reference:ve,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return he(this)},"~run"(r,n){var o;const a=r.value;if(a&&typeof a=="object"){r.typed=!0,r.value={};for(const i in this.entries){const l=this.entries[i];if(i in a||(l.type==="exact_optional"||l.type==="optional"||l.type==="nullish")&&l.default!==void 0){const c=i in a?a[i]:Nr(l),f=l["~run"]({value:c},n);if(f.issues){const h={type:"object",origin:"value",input:a,key:i,value:c};for(const b of f.issues)b.path?b.path.unshift(h):b.path=[h],(o=r.issues)==null||o.push(b);if(r.issues||(r.issues=f.issues),n.abortEarly){r.typed=!1;break}}f.typed||(r.typed=!1),r.value[i]=f.value}else if(l.fallback!==void 0)r.value[i]=Ss(l);else if(l.type!=="exact_optional"&&l.type!=="optional"&&l.type!=="nullish"&&(te(this,"key",r,n,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:a,key:i,value:a[i]}]}),n.abortEarly))break}}else te(this,"type",r,n);return r}}}function Oe(e,t){return{kind:"schema",type:"optional",reference:Oe,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return he(this)},"~run"(r,n){return r.value===void 0&&(this.default!==void 0&&(r.value=Nr(this,r,n)),r.value===void 0)?(r.typed=!0,r):this.wrapped["~run"](r,n)}}}function $r(e,t){return{kind:"schema",type:"picklist",reference:$r,expects:_s(e.map(je),"|"),async:!1,options:e,message:t,get"~standard"(){return he(this)},"~run"(r,n){return this.options.includes(r.value)?r.typed=!0:te(this,"type",r,n),r}}}function Ur(e,t,r){return{kind:"schema",type:"record",reference:Ur,expects:"Object",async:!1,key:e,value:t,message:r,get"~standard"(){return he(this)},"~run"(n,a){var i,l;const o=n.value;if(o&&typeof o=="object"){n.typed=!0,n.value={};for(const c in o)if(ws(o,c)){const f=o[c],h=this.key["~run"]({value:c},a);if(h.issues){const g={type:"object",origin:"key",input:o,key:c,value:f};for(const p of h.issues)p.path=[g],(i=n.issues)==null||i.push(p);if(n.issues||(n.issues=h.issues),a.abortEarly){n.typed=!1;break}}const b=this.value["~run"]({value:f},a);if(b.issues){const g={type:"object",origin:"value",input:o,key:c,value:f};for(const p of b.issues)p.path?p.path.unshift(g):p.path=[g],(l=n.issues)==null||l.push(p);if(n.issues||(n.issues=b.issues),a.abortEarly){n.typed=!1;break}}(!h.typed||!b.typed)&&(n.typed=!1),h.typed&&(n.value[h.value]=b.value)}}else te(this,"type",n,a);return n}}}function ae(e){return{kind:"schema",type:"string",reference:ae,expects:"string",async:!1,message:e,get"~standard"(){return he(this)},"~run"(t,r){return typeof t.value=="string"?t.typed=!0:te(this,"type",t,r),t}}}function qr(e,t,r){const n=e["~run"]({value:t},Lt(r));if(n.issues)throw new Lr(n.issues);return n.value}function As(e,t){const r={};for(const n in e.entries)r[n]=Oe(e.entries[n]);return{...e,entries:r,get"~standard"(){return he(this)}}}function Se(...e){return{...e[0],pipe:e,get"~standard"(){return he(this)},"~run"(t,r){for(const n of e)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!r.abortEarly&&!r.abortPipeEarly)&&(t=n["~run"](t,r))}return t}}}async function Es(e,t,r){const n=await e["~run"]({value:t},Lt(r));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}const Pe=({error:e})=>!e||!e.message?null:s.o("div",{role:"alert",class:"text-error-11 flex max-w-full items-start gap-1 overflow-hidden rounded-2xl px-2 py-2",children:[s.o("svg",{class:"text-error-9 mt-0.5 h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.o("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),s.o("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),s.o("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),s.o("p",{class:"break-words pr-1 text-sm",children:e.message})]}),xe=({class:e,...t})=>{const{t:r}=s.useTranslation();return s.o("button",{type:"button",class:s.clsx("fr touch-hitbox text-neutral-11 bg-neutral-1 ring-divider hover:ring-divider active:ring-interactive-bg-hover hover:text-neutral-12 active:text-neutral-12 hover:bg-divider active:bg-interactive-bg-hover flex flex-shrink-0 items-center justify-center gap-1 self-center rounded-full py-1 pl-2 pr-2.5 text-sm ring-1 transition-all",e),...t,children:[s.o("svg",{"aria-hidden":!0,class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",children:[s.o("title",{children:r("skip")}),s.o("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),s.o("path",{d:"M13.25 4.5V8.25H9.5"})]}),r("skip")]})};var Rt={Afghanistan:"93",Albania:"355",Algeria:"213","American Samoa":"1 684",Andorra:"376",Angola:"244",Anguilla:"1 264",Antarctica:"672","Antigua and Barbuda":"1 268",Argentina:"54",Armenia:"374",Aruba:"297",Australia:"61",Austria:"43",Azerbaijan:"994",Bahrain:"973",Bangladesh:"880",Barbados:"1 246",Belarus:"375",Belgium:"32",Belize:"501",Benin:"229",Bermuda:"1 441",Bhutan:"975",Bolivia:"591","Bosnia and Herzegovina":"387",Botswana:"267","Bouvet Island":"47",Brazil:"55","British Indian Ocean Territory":"246","British Virgin Islands":"1 284",Brunei:"673",Bulgaria:"359","Burkina Faso":"226",Burundi:"257","Cabo Verde":"238",Cambodia:"855",Cameroon:"237",Canada:"1","Caribbean Netherlands":"599","Cayman Islands":"1 345","Central African Republic":"236",Chad:"235",Chile:"56",China:"86","Christmas Island":"61","Cocos (Keeling) Islands":"61",Colombia:"57",Comoros:"269","Cook Islands":"682","Costa Rica":"506",Croatia:"385",Cuba:"53",Curaçao:"599",Cyprus:"357",Czechia:"420","Côte d'Ivoire":"225","Democratic Republic of the Congo":"243",Denmark:"45",Djibouti:"253","Dominican Republic":"1 809",Ecuador:"593",Egypt:"20","El Salvador":"503","Equatorial Guinea":"240",Eritrea:"291",Estonia:"372",Eswatini:"268",Ethiopia:"251","Falkland Islands (Islas Malvinas)":"500","Faroe Islands":"298",Fiji:"679",Finland:"358",France:"33","French Guiana":"594","French Polynesia":"689","French Southern and Antarctic Lands":"262",Gabon:"241",Georgia:"995",Germany:"49",Ghana:"233",Gibraltar:"350",Greece:"30",Greenland:"299",Grenada:"1 473",Guadeloupe:"590",Guam:"1 671",Guatemala:"502",Guernsey:"44",Guinea:"224","Guinea-Bissau":"245",Guyana:"592",Haiti:"509",Honduras:"504","Hong Kong":"852",Hungary:"36",Iceland:"354",India:"91",Indonesia:"62",Iran:"98",Iraq:"964",Ireland:"353","Isle of Man":"44",Israel:"972",Italy:"39",Jamaica:"1 876",Japan:"81",Jersey:"44",Jordan:"962",Kazakhstan:"7",Kenya:"254",Kiribati:"686",Kosovo:"383",Kuwait:"965",Kyrgyzstan:"996",Laos:"856",Latvia:"371",Lebanon:"961",Lesotho:"266",Liberia:"231",Libya:"218",Liechtenstein:"423",Lithuania:"370",Luxembourg:"352",Macao:"853",Madagascar:"261",Malawi:"265",Malaysia:"60",Maldives:"960",Mali:"223",Malta:"356","Marshall Islands":"692",Martinique:"596",Mauritania:"222",Mauritius:"230",Mayotte:"262",Mexico:"52",Micronesia:"691",Moldova:"373",Monaco:"377",Mongolia:"976",Montenegro:"382",Montserrat:"1 664",Morocco:"212",Mozambique:"258","Myanmar (Burma)":"95",Namibia:"264",Nauru:"674",Nepal:"977",Netherlands:"31","New Caledonia":"687","New Zealand":"64",Nicaragua:"505",Niger:"227",Nigeria:"234",Niue:"683","Norfolk Island":"672","North Korea":"850","North Macedonia":"389","Northern Mariana Islands":"1 670",Norway:"47",Oman:"968",Pakistan:"92",Palau:"680",Palestine:"970",Panama:"507","Papua New Guinea":"675",Paraguay:"595",Peru:"51",Philippines:"63","Pitcairn Islands":"64",Poland:"48",Portugal:"351","Puerto Rico":"1 787",Qatar:"974",Romania:"40",Russia:"7",Rwanda:"250",Réunion:"262","Saint Barthélemy":"590","Saint Helena, Ascension and Tristan da Cunha":"290","Saint Kitts and Nevis":"1 869","Saint Lucia":"1 758","Saint Martin":"590","Saint Pierre and Miquelon":"508","Saint Vincent and the Grenadines":"1 784",Samoa:"685","San Marino":"378","Saudi Arabia":"966",Senegal:"221",Serbia:"381",Seychelles:"248","Sierra Leone":"232",Singapore:"65","Sint Maarten":"1 721",Slovakia:"421",Slovenia:"386","Solomon Islands":"677",Somalia:"252","South Africa":"27","South Georgia and the South Sandwich Islands":"500","South Korea":"82","South Sudan":"211",Spain:"34","Sri Lanka":"94",Sudan:"249",Suriname:"597","Svalbard and Jan Mayen":"47",Sweden:"46",Switzerland:"41",Syria:"963","São Tomé and Príncipe":"239",Taiwan:"886",Tajikistan:"992",Tanzania:"255",Thailand:"66","The Bahamas":"1 242","The Gambia":"220","Timor-Leste":"670",Togo:"228",Tokelau:"690",Tonga:"676","Trinidad and Tobago":"1 868",Tunisia:"216",Turkmenistan:"993","Turks and Caicos Islands":"1 649",Tuvalu:"688",Türkiye:"90","U.S. Virgin Islands":"1 340",Uganda:"256",Ukraine:"380","United Arab Emirates":"971","United Kingdom":"44","United States":"1","United States Minor Outlying Islands":"1",Uruguay:"598",Uzbekistan:"998",Vanuatu:"678","Vatican City":"379",Venezuela:"58",Vietnam:"84","Wallis and Futuna":"681","Western Sahara":"212",Yemen:"967",Zambia:"260",Zimbabwe:"263","Åland Islands":"358"},Is=e=>{if(e==="")return{countryCode:"",phoneNumber:""};let t=Object.values(Rt).find(n=>e.startsWith(n))??"",r=e.replace(t,"");return/^\d+$/.test(r)?{countryCode:t,phoneNumber:r}:{countryCode:"",phoneNumber:""}};const Be=s.cva("outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest py-1 text-base outline outline-2 transition-all",{variants:{optional:{true:"pr-16 pl-3",false:"pl-3 pr-3"}},defaultVariants:{optional:!1}}),Fs="https://api.mapbox.com/search/searchbox/v1/suggest",Vs="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",Ls=e=>atob(e).split("").reverse().join(""),be=ve({name:ae()}),Ms=ve({suggestions:jr(ve({feature_type:Oe(ae()),full_address:Oe(ae()),place_formatted:Oe(ae()),name:Oe(ae()),mapbox_id:ae(),context:As(ve({address:be,street:be,neighborhood:be,locality:be,district:be,place:be,region:be,postcode:be,country:be}))}))}),Ts=e=>(s.p(()=>{e&&it.addressSearchCountry(e)},[e]),s.F(()=>{var r;const t=(r=s.store.current$.peek().flow)==null?void 0:r.data.flowSessionId;return t?{enabled:!0,getPredictions:async(n,a)=>{var f;const o=e&&it.addressSearchCountry(e),i=(f=s.store.current$.peek().flow)==null?void 0:f.locationOrigin,l=i&&i.lat!==void 0&&i.lng!==void 0&&Number.isFinite(i.lat)&&Number.isFinite(i.lng)&&i.lat>=-90&&i.lat<=90&&i.lng>=-180&&i.lng<=180;return{...await mn({query:n,country:o,session:t,surface:"chatbot",...l?{lat:i.lat,lng:i.lng}:{},signal:a},async()=>{const h=new URL(Fs);h.searchParams.set("q",n),h.searchParams.set("session_token",t),h.searchParams.set("limit","5"),l&&h.searchParams.set("proximity",`${i.lng},${i.lat}`),h.searchParams.set("access_token",Ls(Vs));const b=async p=>{const v=new URL(h);p&&v.searchParams.set("country",p);const w=await fetch(v.href,{signal:a});if(!w.ok)throw new Error(`Address lookup failed with ${w.status}`);return qr(Ms,await w.json()).suggestions};return(await it.searchAddressSuggestions(b,o,a)).map(p=>{var v,w,k,E,x,N,O,T,H;return{country:o,label:p.full_address??([p.name,p.place_formatted].filter(Boolean).join(", ")||p.mapbox_id),id:p.mapbox_id,address:{line1:((v=p.context.address)==null?void 0:v.name)??((w=p.context.street)==null?void 0:w.name),line2:void 0,line3:((k=p.context.neighborhood)==null?void 0:k.name)??((E=p.context.locality)==null?void 0:E.name),city:((x=p.context.place)==null?void 0:x.name)??((N=p.context.district)==null?void 0:N.name),state:(O=p.context.region)==null?void 0:O.name,postcode:((T=p.context.postcode)==null?void 0:T.name)??(p.feature_type==="postcode"?p.name:void 0),country:(H=p.context.country)==null?void 0:H.name}}})}),country:o}}}:{enabled:!1}},[e])),Zt=e=>{const{t}=s.useTranslation();return s.o("button",{type:"button",class:"touch-hitbox text-neutral-11 hover:bg-neutral-4 hover:text-neutral-12 hover:border-neutral-5 relative flex items-center gap-1 rounded-[18px] border border-solid border-transparent px-3 py-1 pl-1.5 text-sm transition-colors",...e,children:[s.o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",stroke:"currentColor","stroke-width":"1.5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.o("path",{d:"M10 3L5 8L10 13"})}),s.o("span",{children:t("back")})]})},Rs=({input:e,onSubmitSuccess:t,logger:r,analytics:n,rpcClient:a})=>{const{t:o}=s.useTranslation(),[i,l]=s.h(),{enabled:c,getPredictions:f}=Ts(a),[h,b]=s.h(c?"query":"manual"),[g,p]=s.h(""),[v,w]=s.h(),k=s._(),E=()=>{var A;(A=k.current)==null||A.controller.abort(),k.current=void 0};s.p(()=>E,[]);const x=s._(),N=s._(),O=s._(!1),T=A=>{const C=A!==null?x.current:void 0,L=(C==null?void 0:C.lookup)??N.current;if(L&&!O.current){O.current=!0;const D=P=>{const R=e.config.keys[P];return A&&R?A.value[R]:void 0},V=D("country")??(C==null?void 0:C.suggestion.address.country)??(C==null?void 0:C.suggestion.country),M=A&&Ar({postcode:D("postcode")??(C!=null&&C.edited||i==null?void 0:i.postcode),label:C!=null&&C.edited||C==null?void 0:C.suggestion.label,state:D("state")??(C!=null&&C.edited||i==null?void 0:i.state),country:V});yn({kind:"address",surface:"chatbot",...L,picked:!!C,...C?{edited:C.edited}:{},region:M??(V!=null&&V.trim()?"other":null)})}t(A)},H=A=>{var L;if(s.invariant(c,"Query state should not be enabled"),A=A.trim(),A===((L=k.current)==null?void 0:L.query)||A===(v==null?void 0:v.query)&&v.status==="done")return;if(E(),p(A),A===""){w(void 0);return}const C=k.current={query:A,controller:new AbortController};w({query:A,status:"pending"}),f(A,C.controller.signal).then(D=>{k.current===C&&(k.current=void 0,N.current={arm:D.arm,source:D.source},w({query:A,status:"done",items:D.results,...N.current,country:D.country}))},D=>{k.current===C&&(k.current=void 0,N.current={arm:"direct",source:"direct"},r.error("Failed to get address details",D instanceof Lr?"Unexpected response":D),w({query:A,status:"failed",error:o("address_error")}))})},B=(A,C)=>{x.current&&(i==null?void 0:i[A])!==C&&(x.current.edited=!0),l(L=>({...L,[A]:C}))};switch(h){case"query":return s.invariant(c,"Query state should not be enabled"),s.o(Ds,{input:e,onSkip:()=>T(null),onAddressSelect:(A,C)=>{var D;if(A===""){k.current&&(E(),w(void 0)),b("manual");return}if((v==null?void 0:v.status)!=="done")return;const L=v.items.find(V=>V.id===A);L&&(v.arm!=="inploi"&&fn({query:C,country:v.country,pickedLabel:L.label,pickedPostcode:L.address.postcode,pickedCountry:L.address.country,pickedState:L.address.state,log:V=>n.log({event:"ADDRESS_SHADOW_COMPARED",properties:V})}),((D=x.current)==null?void 0:D.suggestion.id)!==A?(l(L.address),x.current={suggestion:L,lookup:{arm:v.arm,source:v.source},edited:!1}):x.current.lookup={arm:v.arm,source:v.source},b("details"))},onAddressSearch:H,lookup:v,query:g});case"details":return s.invariant(i!==void 0),s.o(Xt,{input:e,logger:r,onSubmitSuccess:T,addressFields:i,onFieldChange:B,actions:s.o(Zt,{onClick:()=>{b("query")}})});case"manual":return s.o(Xt,{logger:r,input:e,onSubmitSuccess:T,addressFields:i??{},onFieldChange:B,actions:c?s.o(Zt,{onClick:()=>{b("query")}}):e.config.optional?s.o(xe,{onClick:()=>T(null)}):void 0})}},Ds=({input:e,onSkip:t,lookup:r,onAddressSelect:n,query:a,onAddressSearch:o})=>{const{t:i}=s.useTranslation(),l=s._(null);return s.y(()=>{l.current&&(l.current.focus(),l.current.select())},[]),s.o(s.k,{children:[s.o("form",{noValidate:!0,onSubmit:c=>{c.preventDefault();const h=new FormData(c.currentTarget).get("address");typeof h=="string"&&o(h)},class:"flex gap-2 p-2.5",children:[s.o("div",{class:"group relative flex-1",children:[s.o("input",{ref:l,name:"address",id:"chat-address",autocomplete:"address-line1",autoFocus:!0,placeholder:e.config.placeholder||i("address_search"),defaultValue:a,class:Be({optional:!!e.config.optional,className:"w-full rounded-full"})}),s.o("button",{type:"submit",class:"touch-hitbox text-neutral-12 hover:bg-neutral-3 fr absolute bottom-0 right-0 top-0 flex cursor-pointer items-center gap-1 rounded-full px-3 transition-all",children:[s.o("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.o("g",{id:"inploi",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",strokeWidth:"1.5",children:[s.o("circle",{cx:"7",cy:"7",r:"4"}),s.o("path",{d:"M10 10L13 13"})]})}),s.o("span",{class:"sr-only",children:i("search")})]})]}),e.config.optional&&s.o(xe,{class:"relative",onClick:t})]}),(r==null?void 0:r.status)==="failed"?s.o(Pe,{error:{message:r.error}}):null,s.o("p",{role:"status",class:(r==null?void 0:r.status)==="pending"||(r==null?void 0:r.status)==="done"&&r.items.length===0?"text-neutral-11 flex items-center gap-2 px-4 py-2 text-sm":"sr-only",children:(r==null?void 0:r.status)==="pending"?s.o(s.k,{children:[s.o(s.LoadingIndicator,{"aria-hidden":"true",class:"h-4 w-4 shrink-0"}),i("address_searching")]}):(r==null?void 0:r.status)==="done"&&r.items.length===0?i("address_no_results"):null}),s.o("ul",{children:[((r==null?void 0:r.status)==="done"?r.items:[]).map(c=>s.o("li",{children:s.o("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{var f;n(c.id,((f=l.current)==null?void 0:f.value)??a??"")},children:[s.o("span",{class:"flex-grow",children:c.label}),s.o("svg",{class:"flex-none",width:"16",height:"16",viewBox:"0 0 16 16",stroke:"currentColor","stroke-width":"1.5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.o("path",{d:"M6 3L11 8L6 13"})})]})},c.id)),s.o("li",{children:s.o("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{var c;n("",((c=l.current)==null?void 0:c.value)??a??"")},children:s.o("span",{class:"flex-grow",children:i("address_manual")})})},"")]})]})},wt=["line1","line2","line3","city","state","postcode","country"],Xt=({addressFields:e,onFieldChange:t,onSubmitSuccess:r,actions:n,input:a})=>{const o=s._(null);s.y(()=>{if(o.current){const c=o.current.querySelector("input");c&&(c.focus(),c.select())}},[]);const i=Object.keys(Rt),{t:l}=s.useTranslation();return s.o("form",{class:"flex flex-col px-2 pt-2",onSubmit:c=>{c.preventDefault();const f=c.currentTarget,h=[...f.querySelectorAll("input")].filter(p=>p.value!==""&&!p.value.trim());for(const p of h){p.value="";const v=wt.find(w=>a.config.keys[w]===p.name);v&&t(v,"")}if(h.length>0&&!f.checkValidity()){f.reportValidity();return}const b=new FormData(f),g=Object.fromEntries(b.entries());r({type:"address",value:g})},children:[s.o("div",{class:"bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",ref:o,children:wt.map((c,f)=>{const h=`isdk_${c}`,b=a.config.keys[c];return b?s.o(s.k,{children:[s.o("label",{for:h,class:"text-neutral-11 [&:has(+*>input:focus)]:text-neutral-12 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",children:l(c)}),s.o("div",{class:"flex flex-col items-stretch gap-1.5",children:[c==="country"?s.o("div",{class:"relative",children:[s.o("select",{class:"text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",name:b,id:h,defaultValue:e[c],onChange:g=>t(c,g.currentTarget.value),required:!0,children:[e.country&&!i.includes(e.country)?s.o("option",{value:e[c],children:e[c]}):s.o("option",{value:"",children:l("select_country")}),i.map(g=>s.o("option",{value:g,children:g},g))]}),s.o("svg",{class:"text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",width:"16",height:"16",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.o("path",{d:"M4 6.5L8 10.5L12 6.5"})})]}):s.o("input",{autoFocus:f===0?!0:void 0,class:"text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 flex-1 rounded-lg border-solid bg-transparent px-3 py-1.5 text-base transition-colors autofill:shadow-[inset_0_0_0_1000px_hsl(210_16.7%_97.6%)] focus:outline-none",name:b,id:h,defaultValue:e[c],onInput:g=>t(c,g.currentTarget.value),required:c==="line2"?a.config.line2Required===!0:c!=="line3"}),f===wt.length-1?s.o("hr",{class:"m-0 w-full border-b border-b-transparent"}):s.o("hr",{class:"border-b-neutral-5 m-0 w-full border-b border-solid"})]})]}):null})}),s.o("div",{class:"bg-neutral-1 sticky bottom-0 flex items-center py-2",children:[n,s.o(Me,{class:"ml-auto"})]})]})},Dt=()=>{const e=s._(null);return s.p(()=>{var t;(t=e.current)==null||t.focus()},[]),e},zr=["true","false"],Os=$r(zr),Ns="answer",Wr="flex items-center flex-wrap gap-2 p-2.5",Hr="min-w-0 max-w-full flex-auto",Kr=s.k$1(({label:e,...t},r)=>s.o("button",{class:"bg-lowest ease-expo-out ring-divider text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block w-full overflow-hidden rounded-2xl px-2 py-2.5 ring-2 transition-all selection:bg-transparent",...t,ref:r,children:s.o("p",{class:"text-center text-base",children:e})})),js=({input:e,onSubmitSuccess:t})=>{const r=Dt();return s.o("form",{noValidate:!0,class:"",onSubmit:n=>{n.preventDefault();const a=s.getFormSubmitter(n).value,o=qr(Os,a);t({type:"boolean",value:o==="true"})},children:[s.o("ul",{class:Wr,children:zr.map((n,a)=>s.o("li",{class:Hr,children:s.o(Kr,{ref:a===0?r:null,type:"submit",name:Ns,value:n,label:e.config.labels[n]},n)}))}),e.config.optional&&s.o("div",{class:"px-2 pb-2",children:s.o(xe,{class:"relative w-full",type:"button",onClick:()=>t(null)})})]})},Yt=e=>e.reduce((t,r)=>t+r.sizeKb,0),Bs=s.isSubmissionOfType("file"),Qt=3,ct=e=>{const t=e.lastIndexOf(".");return t===-1?[e,""]:[e.slice(0,t),e.slice(t)]},Ps=({file:e,class:t,...r})=>{const{t:n}=s.useTranslation(),[a,o]=ct(e.name);return s.o("div",{class:s.clsx("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",t),...r,children:[s.o("p",{class:"text-accent-12 flex flex-grow overflow-hidden",children:[s.o("span",{class:"sr-only",children:[n("file_name"),": "]}),s.o("span",{class:"block truncate",children:a}),s.o("span",{children:o})]}),s.o("p",{class:"text-accent-11",children:[s.o("span",{class:"sr-only",children:[n("file_size"),": "]}),s.fe(e.sizeKb)]})]})},er=({class:e,...t})=>s.o("li",{class:s.clsx("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...t}),$s=(e,t)=>{const[r,n]=ct(e);return`${r.slice(0,t)}${n}`},tr=e=>({name:$s(e.name,42),sizeKb:e.size/1e3}),Us=[".heic",".heif",".jpg",".jpeg",".png",".gif",".webp",".txt",".rtf",".odt",".pages",".zip"],qs=(e,t,r)=>{const n=ct(t.name)[1].toLowerCase(),a=[...r.map(i=>i.toLowerCase()),...Us],o=n===""?"none":a.includes(n)?n:"other";return`chatbot-file-refused:${e}:${o}`},zs=({input:e,onSubmitSuccess:t,analytics:r})=>{var k;const n=(k=s.store.current$.value.flow)==null?void 0:k.data.submissions[e.key],[a,o]=s.h(Bs(n)&&n.value.length?{status:"ready",files:n.value}:{status:"empty"}),i=s._(0),l=a.status==="ready"?a.files:[],c=a.status==="ready"||a.status==="pending"?a.files:[],f=a.status==="error"?a.error:void 0,h=c.length-Qt,b=Yt(c),g=Dt(),{t:p}=s.useTranslation(),v=E=>{if(!E.length)return{reason:"required",error:{type:"required",message:p("validation_file")}};if(!s.me(E,e.config.extensions))return{reason:"type",file:E.find(x=>!s.me([x],e.config.extensions)),error:{type:"validate",message:p("validation_file_ext",{ext:e.config.extensions.join(", ")})}};if(E.some(x=>x.sizeKb===0))return{reason:"empty",file:E.find(x=>x.sizeKb===0),error:{type:"validate",message:p("validation_file_empty")}};if(e.config.fileSizeLimitKib&&Yt(E)>e.config.fileSizeLimitKib)return{reason:"size",error:{type:"max",message:p("validation_file_size",{size:s.fe(e.config.fileSizeLimitKib)})}};if(!e.config.allowMultiple&&E.length>1)return{reason:"count",error:{type:"invalid",message:p("validation_file_max",{count:1})}}},w=(E,x)=>{var N,O;return r.log({event:"INTERACTION",properties:{tag:qs(E,x,e.config.extensions)},customProperties:(O=(N=s.store.current$.peek().flow)==null?void 0:N.analytics)==null?void 0:O.customProperties})};return s.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:E=>{if(E.preventDefault(),a.status==="pending"||a.status==="error")return;const x=v(l);x?o({status:"error",error:x.error}):t({type:"file",value:l})},children:[s.o("div",{class:"flex items-center gap-2",children:[s.o("label",{ref:g,for:"dropzone-file",class:"border-neutral-8 bg-neutral-2 flex h-48 w-full cursor-pointer flex-col items-center justify-center overflow-hidden rounded-2xl border border-dashed p-4",children:[c.length>0?s.o("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[c.slice(0,Qt).map(E=>{const[x,N]=ct(E.name);return s.o(er,{class:"flex overflow-hidden",children:[s.o("span",{class:"block truncate",children:x}),s.o("span",{children:N})]})}),h>0?s.o(er,{children:p("file_more",{count:h})}):null]}):s.o("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[s.o("header",{class:"flex flex-col items-center gap-0",children:[s.o("svg",{class:"text-neutral-11 mb-1 h-8 w-8","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 16",children:s.o("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"})}),s.o("p",{class:"text-neutral-12 tracking-[-0.01em]",children:p("upload_file",{count:e.config.allowMultiple?2:1})}),e.config.fileSizeLimitKib?s.o("p",{class:"text-neutral-11 text-xs",children:["(",p("file_max_size",{size:s.fe(e.config.fileSizeLimitKib)}),")"]}):null]}),s.o("aside",{class:"flex flex-col items-center gap-2",children:[s.o("p",{id:"accepted-filetypes",class:"sr-only",children:p("file_extensions")}),s.o("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(E=>s.o("li",{class:"ring-lowest outline-neutral-6 text-neutral-11 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",children:E.replace(".","")}))})]})]}),s.o("p",{role:"status",class:s.clsx("text-neutral-11 flex items-center gap-1.5 text-xs",c.length===0&&"sr-only"),children:a.status==="pending"?s.o(s.k,{children:[s.o(s.LoadingIndicator,{"aria-hidden":"true",class:"h-4 w-4"}),p("file_preparing",{count:c.length})]}):a.status==="ready"?s.o(s.k,{children:[l.length>1?p("file_total_size",{size:s.fe(b)}):s.fe(b),s.o("span",{class:"sr-only",children:[". ",p("file_ready",{count:l.length})]})]}):null}),s.o("input",{id:"dropzone-file","aria-label":p("upload_file",{count:e.config.allowMultiple?2:1}),onInput:async E=>{s.invariant(E.target instanceof HTMLInputElement);const x=E.target.files?Array.from(E.target.files):[];E.target.value="";const[N]=x;if(!N)return;const O=++i.current,T=a.status==="ready",H=x.map(tr),B=v(H);if(B)return w(B.reason,B.file??N),o({status:"error",error:B.error});o({status:"pending",files:H});let A;try{const C=await Promise.all(x.map(async L=>{try{return{...tr(L),data:await s.Oe(L)}}catch(D){throw A??(A=L),D}}));i.current===O&&o({status:"ready",files:C})}catch{if(i.current!==O)return;w("unreadable",A??N),o({status:"error",error:{type:"invalid",message:p(T?"file_read_error_replacement":"file_read_error")}})}},multiple:e.config.allowMultiple,accept:e.config.extensions.join(","),type:"file",class:"sr-only"})]}),s.o("div",{class:"flex h-full flex-col items-center gap-2",children:[s.o(Me,{disabled:l.length===0}),e.config.optional&&s.o(xe,{class:"relative",onClick:()=>t(null)})]})]}),s.o(Pe,{error:f})]})};var tt=e=>e.type==="checkbox",Le=e=>e instanceof Date,se=e=>e==null;const Gr=e=>typeof e=="object";var Z=e=>!se(e)&&!Array.isArray(e)&&Gr(e)&&!Le(e),Ws=e=>Z(e)&&e.target?tt(e.target)?e.target.checked:e.target.value:e,Hs=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Ks=(e,t)=>e.has(Hs(t)),Gs=e=>{const t=e.constructor&&e.constructor.prototype;return Z(t)&&t.hasOwnProperty("isPrototypeOf")},Ot=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Y(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Ot&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(Z(e)&&Gs(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=Y(e[a]));return n}var ut=e=>/^\w*$/.test(e),G=e=>e===void 0,Nt=e=>Array.isArray(e)?e.filter(Boolean):[],jt=e=>Nt(e.replace(/["|']|\]/g,"").split(/\.|\[/)),F=(e,t,r)=>{if(!t||!Z(e))return r;const n=(ut(t)?[t]:jt(t)).reduce((a,o)=>se(a)?a:a[o],e);return G(n)||n===e?G(e[t])?r:e[t]:n},fe=e=>typeof e=="boolean",le=e=>typeof e=="function",W=(e,t,r)=>{let n=-1;const a=ut(t)?[t]:jt(t),o=a.length,i=o-1;for(;++n<o;){const l=a[n];let c=r;if(n!==i){const f=e[l];c=Z(f)||Array.isArray(f)?f:isNaN(+a[n+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const rr={BLUR:"blur",FOCUS_OUT:"focusout"},ce={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ge={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Js=s.Cn.createContext(null);Js.displayName="HookFormControlContext";var Zs=(e,t,r,n=!0)=>{const a={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(a,o,{get:()=>{const i=o;return t._proxyFormState[i]!==ce.all&&(t._proxyFormState[i]=!n||ce.all),e[i]}});return a};const Xs=typeof window<"u"?s.Cn.useLayoutEffect:s.Cn.useEffect;var oe=e=>typeof e=="string",Ys=(e,t,r,n,a)=>oe(e)?(n&&t.watch.add(e),F(r,e,a)):Array.isArray(e)?e.map(o=>(n&&t.watch.add(o),F(r,o))):(n&&(t.watchAll=!0),r),Et=e=>se(e)||!Gr(e);function Ce(e,t,r=new WeakSet){if(Et(e)||Et(t))return Object.is(e,t);if(Le(e)&&Le(t))return Object.is(e.getTime(),t.getTime());const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);for(const o of n){const i=e[o];if(!a.includes(o))return!1;if(o!=="ref"){const l=t[o];if(Le(i)&&Le(l)||Z(i)&&Z(l)||Array.isArray(i)&&Array.isArray(l)?!Ce(i,l,r):!Object.is(i,l))return!1}}return!0}const Qs=s.Cn.createContext(null);Qs.displayName="HookFormContext";var Jr=(e,t,r,n,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:a||!0}}:{},Qe=e=>Array.isArray(e)?e:[e],nr=()=>{let e=[];return{get observers(){return e},next:a=>{for(const o of e)o.next&&o.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(o=>o!==a)}}),unsubscribe:()=>{e=[]}}};function Zr(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const a=e[n],o=t[n];if(a&&Z(a)&&o){const i=Zr(a,o);Z(i)&&(r[n]=i)}else e[n]&&(r[n]=o)}return r}var re=e=>Z(e)&&!Object.keys(e).length,Bt=e=>e.type==="file",ot=e=>{if(!Ot)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Xr=e=>e.type==="select-multiple",Pt=e=>e.type==="radio",ea=e=>Pt(e)||tt(e),_t=e=>ot(e)&&e.isConnected;function ta(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;)e=G(e)?n++:e[t[n++]];return e}function ra(e){for(const t in e)if(e.hasOwnProperty(t)&&!G(e[t]))return!1;return!0}function J(e,t){const r=Array.isArray(t)?t:ut(t)?[t]:jt(t),n=r.length===1?e:ta(e,r),a=r.length-1,o=r[a];return n&&delete n[o],a!==0&&(Z(n)&&re(n)||Array.isArray(n)&&ra(n))&&J(e,r.slice(0,-1)),e}var na=e=>{for(const t in e)if(le(e[t]))return!0;return!1};function Yr(e){return Array.isArray(e)||Z(e)&&!na(e)}function It(e,t={}){for(const r in e){const n=e[r];Yr(n)?(t[r]=Array.isArray(n)?[]:{},It(n,t[r])):G(n)||(t[r]=!0)}return t}function De(e,t,r){r||(r=It(t));for(const n in e){const a=e[n];if(Yr(a))G(t)||Et(r[n])?r[n]=It(a,Array.isArray(a)?[]:{}):De(a,se(t)?{}:t[n],r[n]);else{const o=t[n];r[n]=!Ce(a,o)}}return r}const sr={value:!1,isValid:!1},ar={value:!0,isValid:!0};var Qr=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!G(e[0].attributes.value)?G(e[0].value)||e[0].value===""?ar:{value:e[0].value,isValid:!0}:ar:sr}return sr},en=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>G(e)?e:t?e===""?NaN:e&&+e:r&&oe(e)?new Date(e):n?n(e):e;const ir={isValid:!1,value:null};var tn=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,ir):ir;function or(e){const t=e.ref;return Bt(t)?t.files:Pt(t)?tn(e.refs).value:Xr(t)?[...t.selectedOptions].map(({value:r})=>r):tt(t)?Qr(e.refs).value:en(G(t.value)?e.ref.value:t.value,e)}var sa=(e,t,r,n)=>{const a={};for(const o of e){const i=F(t,o);i&&W(a,o,i._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:n}},lt=e=>e instanceof RegExp,Ge=e=>G(e)?e:lt(e)?e.source:Z(e)?lt(e.value)?e.value.source:e.value:e,lr=e=>({isOnSubmit:!e||e===ce.onSubmit,isOnBlur:e===ce.onBlur,isOnChange:e===ce.onChange,isOnAll:e===ce.all,isOnTouch:e===ce.onTouched});const cr="AsyncFunction";var aa=e=>!!e&&!!e.validate&&!!(le(e.validate)&&e.validate.constructor.name===cr||Z(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===cr)),ia=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),ur=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const et=(e,t,r,n)=>{for(const a of r||Object.keys(e)){const o=F(e,a);if(o){const{_f:i,...l}=o;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],a)&&!n)return!0;if(i.ref&&t(i.ref,i.name)&&!n)return!0;if(et(l,t))break}else if(Z(l)&&et(l,t))break}}};function dr(e,t,r){const n=F(e,r);if(n||ut(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),i=F(t,o),l=F(e,o);if(i&&!Array.isArray(i)&&r!==o)return{name:r};if(l&&l.type)return{name:o,error:l};if(l&&l.root&&l.root.type)return{name:`${o}.root`,error:l.root};a.pop()}return{name:r}}var oa=(e,t,r,n)=>{r(e);const{name:a,...o}=e;return re(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(i=>t[i]===(!n||ce.all))},la=(e,t,r)=>!e||!t||e===t||Qe(e).some(n=>n&&(r?n===t:n.startsWith(t)||t.startsWith(n))),ca=(e,t,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(t||e):(r?n.isOnBlur:a.isOnBlur)?!e:(r?n.isOnChange:a.isOnChange)?e:!0,ua=(e,t)=>!Nt(F(e,t)).length&&J(e,t),da=(e,t,r)=>{const n=Qe(F(e,r));return W(n,"root",t[r]),W(e,r,n),e};function fr(e,t,r="validate"){if(oe(e)||Array.isArray(e)&&e.every(oe)||fe(e)&&!e)return{type:r,message:oe(e)?e:"",ref:t}}var Re=e=>Z(e)&&!lt(e)?e:{value:e,message:""},hr=async(e,t,r,n,a,o)=>{const{ref:i,refs:l,required:c,maxLength:f,minLength:h,min:b,max:g,pattern:p,validate:v,name:w,valueAsNumber:k,mount:E}=e._f,x=F(r,w);if(!E||t.has(w))return{};const N=l?l[0]:i,O=V=>{a&&N.reportValidity&&(N.setCustomValidity(fe(V)?"":V||""),N.reportValidity())},T={},H=Pt(i),B=tt(i),A=H||B,C=(k||Bt(i))&&G(i.value)&&G(x)||ot(i)&&i.value===""||x===""||Array.isArray(x)&&!x.length,L=Jr.bind(null,w,n,T),D=(V,M,P,R=ge.maxLength,z=ge.minLength)=>{const q=V?M:P;T[w]={type:V?R:z,message:q,ref:i,...L(V?R:z,q)}};if(o?!Array.isArray(x)||!x.length:c&&(!A&&(C||se(x))||fe(x)&&!x||B&&!Qr(l).isValid||H&&!tn(l).isValid)){const{value:V,message:M}=oe(c)?{value:!!c,message:c}:Re(c);if(V&&(T[w]={type:ge.required,message:M,ref:N,...L(ge.required,M)},!n))return O(M),T}if(!C&&(!se(b)||!se(g))){let V,M;const P=Re(g),R=Re(b);if(!se(x)&&!isNaN(x)){const z=i.valueAsNumber||x&&+x;se(P.value)||(V=z>P.value),se(R.value)||(M=z<R.value)}else{const z=i.valueAsDate||new Date(x),q=ne=>new Date(new Date().toDateString()+" "+ne),Q=i.type=="time",ie=i.type=="week";oe(P.value)&&x&&(V=Q?q(x)>q(P.value):ie?x>P.value:z>new Date(P.value)),oe(R.value)&&x&&(M=Q?q(x)<q(R.value):ie?x<R.value:z<new Date(R.value))}if((V||M)&&(D(!!V,P.message,R.message,ge.max,ge.min),!n))return O(T[w].message),T}if((f||h)&&!C&&(oe(x)||o&&Array.isArray(x))){const V=Re(f),M=Re(h),P=!se(V.value)&&x.length>+V.value,R=!se(M.value)&&x.length<+M.value;if((P||R)&&(D(P,V.message,M.message),!n))return O(T[w].message),T}if(p&&!C&&oe(x)){const{value:V,message:M}=Re(p);if(lt(V)&&!x.match(V)&&(T[w]={type:ge.pattern,message:M,ref:i,...L(ge.pattern,M)},!n))return O(M),T}if(v){if(le(v)){const V=await v(x,r),M=fr(V,N);if(M&&(T[w]={...M,...L(ge.validate,M.message)},!n))return O(M.message),T}else if(Z(v)){let V={};for(const M in v){if(!re(V)&&!n)break;const P=fr(await v[M](x,r),N,M);P&&(V={...P,...L(M,P.message)},O(P.message),n&&(T[w]=V))}if(!re(V)&&(T[w]={ref:N,...V},!n))return T}}return O(!0),T};const fa={mode:ce.onSubmit,reValidateMode:ce.onChange,shouldFocusError:!0};function ha(e={}){let t={...fa,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:le(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},n={},a=Z(t.defaultValues)||Z(t.values)?Y(t.defaultValues||t.values)||{}:{},o=t.shouldUnregister?{}:Y(a),i={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,f=0;const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},b={...h};let g={...b};const p={array:nr(),state:nr()},v=t.criteriaMode===ce.all,w=u=>d=>{clearTimeout(f),f=setTimeout(u,d)},k=async u=>{if(!i.keepIsValid&&!t.disabled&&(b.isValid||g.isValid||u)){let d;t.resolver?(d=re((await A()).errors),E()):d=await L(n,!0),d!==r.isValid&&p.state.next({isValid:d})}},E=(u,d)=>{!t.disabled&&(b.isValidating||b.validatingFields||g.isValidating||g.validatingFields)&&((u||Array.from(l.mount)).forEach(m=>{m&&(d?W(r.validatingFields,m,d):J(r.validatingFields,m))}),p.state.next({validatingFields:r.validatingFields,isValidating:!re(r.validatingFields)}))},x=(u,d=[],m,S,_=!0,y=!0)=>{if(S&&m&&!t.disabled){if(i.action=!0,y&&Array.isArray(F(n,u))){const I=m(F(n,u),S.argA,S.argB);_&&W(n,u,I)}if(y&&Array.isArray(F(r.errors,u))){const I=m(F(r.errors,u),S.argA,S.argB);_&&W(r.errors,u,I),ua(r.errors,u)}if((b.touchedFields||g.touchedFields)&&y&&Array.isArray(F(r.touchedFields,u))){const I=m(F(r.touchedFields,u),S.argA,S.argB);_&&W(r.touchedFields,u,I)}(b.dirtyFields||g.dirtyFields)&&(r.dirtyFields=De(a,o)),p.state.next({name:u,isDirty:V(u,d),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else W(o,u,d)},N=(u,d)=>{W(r.errors,u,d),p.state.next({errors:r.errors})},O=u=>{r.errors=u,p.state.next({errors:r.errors,isValid:!1})},T=(u,d,m,S)=>{const _=F(n,u);if(_){const y=F(o,u,G(m)?F(a,u):m);G(y)||S&&S.defaultChecked||d?W(o,u,d?y:or(_._f)):R(u,y),i.mount&&!i.action&&k()}},H=(u,d,m,S,_)=>{let y=!1,I=!1;const $={name:u};if(!t.disabled){if(!m||S){(b.isDirty||g.isDirty)&&(I=r.isDirty,r.isDirty=$.isDirty=V(),y=I!==$.isDirty);const U=Ce(F(a,u),d);I=!!F(r.dirtyFields,u),U?J(r.dirtyFields,u):W(r.dirtyFields,u,!0),$.dirtyFields=r.dirtyFields,y=y||(b.dirtyFields||g.dirtyFields)&&I!==!U}if(m){const U=F(r.touchedFields,u);U||(W(r.touchedFields,u,m),$.touchedFields=r.touchedFields,y=y||(b.touchedFields||g.touchedFields)&&U!==m)}y&&_&&p.state.next($)}return y?$:{}},B=(u,d,m,S)=>{const _=F(r.errors,u),y=(b.isValid||g.isValid)&&fe(d)&&r.isValid!==d;if(t.delayError&&m?(c=w(()=>N(u,m)),c(t.delayError)):(clearTimeout(f),c=null,m?W(r.errors,u,m):J(r.errors,u)),(m?!Ce(_,m):_)||!re(S)||y){const I={...S,...y&&fe(d)?{isValid:d}:{},errors:r.errors,name:u};r={...r,...I},p.state.next(I)}},A=async u=>(E(u,!0),await t.resolver(o,t.context,sa(u||l.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),C=async u=>{const{errors:d}=await A(u);if(E(u),u)for(const m of u){const S=F(d,m);S?W(r.errors,m,S):J(r.errors,m)}else r.errors=d;return d},L=async(u,d,m={valid:!0})=>{for(const S in u){const _=u[S];if(_){const{_f:y,...I}=_;if(y){const $=l.array.has(y.name),U=_._f&&aa(_._f);U&&b.validatingFields&&E([y.name],!0);const ee=await hr(_,l.disabled,o,v,t.shouldUseNativeValidation&&!d,$);if(U&&b.validatingFields&&E([y.name]),ee[y.name]&&(m.valid=!1,d||e.shouldUseNativeValidation))break;!d&&(F(ee,y.name)?$?da(r.errors,ee,y.name):W(r.errors,y.name,ee[y.name]):J(r.errors,y.name))}!re(I)&&await L(I,d,m)}}return m.valid},D=()=>{for(const u of l.unMount){const d=F(n,u);d&&(d._f.refs?d._f.refs.every(m=>!_t(m)):!_t(d._f.ref))&&pe(u)}l.unMount=new Set},V=(u,d)=>!t.disabled&&(u&&d&&W(o,u,d),!Ce(K(),a)),M=(u,d,m)=>Ys(u,l,{...i.mount?o:G(d)?a:oe(u)?{[u]:d}:d},m,d),P=u=>Nt(F(i.mount?o:a,u,t.shouldUnregister?F(a,u,[]):[])),R=(u,d,m={})=>{const S=F(n,u);let _=d;if(S){const y=S._f;y&&(!y.disabled&&W(o,u,en(d,y)),_=ot(y.ref)&&se(d)?"":d,Xr(y.ref)?[...y.ref.options].forEach(I=>I.selected=_.includes(I.value)):y.refs?tt(y.ref)?y.refs.forEach(I=>{(!I.defaultChecked||!I.disabled)&&(Array.isArray(_)?I.checked=!!_.find($=>$===I.value):I.checked=_===I.value||!!_)}):y.refs.forEach(I=>I.checked=I.value===_):Bt(y.ref)?y.ref.value="":(y.ref.value=_,y.ref.type||p.state.next({name:u,values:Y(o)})))}(m.shouldDirty||m.shouldTouch)&&H(u,_,m.shouldTouch,m.shouldDirty,!0),m.shouldValidate&&ne(u)},z=(u,d,m)=>{for(const S in d){if(!d.hasOwnProperty(S))return;const _=d[S],y=u+"."+S,I=F(n,y);(l.array.has(u)||Z(_)||I&&!I._f)&&!Le(_)?z(y,_,m):R(y,_,m)}},q=(u,d,m={})=>{const S=F(n,u),_=l.array.has(u),y=Y(d);W(o,u,y),_?(p.array.next({name:u,values:Y(o)}),(b.isDirty||b.dirtyFields||g.isDirty||g.dirtyFields)&&m.shouldDirty&&p.state.next({name:u,dirtyFields:De(a,o),isDirty:V(u,y)})):S&&!S._f&&!se(y)?z(u,y,m):R(u,y,m),ur(u,l)?p.state.next({...r,name:u,values:Y(o)}):p.state.next({name:i.mount?u:void 0,values:Y(o)})},Q=async u=>{i.mount=!0;const d=u.target;let m=d.name,S=!0;const _=F(n,m),y=U=>{S=Number.isNaN(U)||Le(U)&&isNaN(U.getTime())||Ce(U,F(o,m,U))},I=lr(t.mode),$=lr(t.reValidateMode);if(_){let U,ee;const Ve=d.type?or(_._f):Ws(u),we=u.type===rr.BLUR||u.type===rr.FOCUS_OUT,nn=!ia(_._f)&&!t.resolver&&!F(r.errors,m)&&!_._f.deps||ca(we,F(r.touchedFields,m),r.isSubmitted,$,I),pt=ur(m,l,we);W(o,m,Ve),we?(!d||!d.readOnly)&&(_._f.onBlur&&_._f.onBlur(u),c&&c(0)):_._f.onChange&&_._f.onChange(u);const mt=H(m,Ve,we),sn=!re(mt)||pt;if(!we&&p.state.next({name:m,type:u.type,values:Y(o)}),nn)return(b.isValid||g.isValid)&&(t.mode==="onBlur"?we&&k():we||k()),sn&&p.state.next({name:m,...pt?{}:mt});if(!we&&pt&&p.state.next({...r}),t.resolver){const{errors:$t}=await A([m]);if(E([m]),y(Ve),S){const an=dr(r.errors,n,m),Ut=dr($t,n,an.name||m);U=Ut.error,m=Ut.name,ee=re($t)}}else E([m],!0),U=(await hr(_,l.disabled,o,v,t.shouldUseNativeValidation))[m],E([m]),y(Ve),S&&(U?ee=!1:(b.isValid||g.isValid)&&(ee=await L(n,!0)));S&&(_._f.deps&&(!Array.isArray(_._f.deps)||_._f.deps.length>0)&&ne(_._f.deps),B(m,ee,U,mt))}},ie=(u,d)=>{if(F(r.errors,d)&&u.focus)return u.focus(),1},ne=async(u,d={})=>{let m,S;const _=Qe(u);if(t.resolver){const y=await C(G(u)?u:_);m=re(y),S=u?!_.some(I=>F(y,I)):m}else u?(S=(await Promise.all(_.map(async y=>{const I=F(n,y);return await L(I&&I._f?{[y]:I}:I)}))).every(Boolean),!(!S&&!r.isValid)&&k()):S=m=await L(n);return p.state.next({...!oe(u)||(b.isValid||g.isValid)&&m!==r.isValid?{}:{name:u},...t.resolver||!u?{isValid:m}:{},errors:r.errors}),d.shouldFocus&&!S&&et(n,ie,u?_:l.mount),S},K=(u,d)=>{let m={...i.mount?o:a};return d&&(m=Zr(d.dirtyFields?r.dirtyFields:r.touchedFields,m)),G(u)?m:oe(u)?F(m,u):u.map(S=>F(m,S))},$e=(u,d)=>({invalid:!!F((d||r).errors,u),isDirty:!!F((d||r).dirtyFields,u),error:F((d||r).errors,u),isValidating:!!F(r.validatingFields,u),isTouched:!!F((d||r).touchedFields,u)}),Ue=u=>{const d=u?Qe(u):void 0;d==null||d.forEach(m=>J(r.errors,m)),d?d.forEach(m=>{p.state.next({name:m,errors:r.errors})}):p.state.next({errors:{}})},j=(u,d,m)=>{const S=(F(n,u,{_f:{}})._f||{}).ref,_=F(r.errors,u)||{},{ref:y,message:I,type:$,...U}=_;W(r.errors,u,{...U,...d,ref:S}),p.state.next({name:u,errors:r.errors,isValid:!1}),m&&m.shouldFocus&&S&&S.focus&&S.focus()},qe=(u,d)=>le(u)?p.state.subscribe({next:m=>"values"in m&&u(M(void 0,d),m)}):M(u,d,!0),Ae=u=>p.state.subscribe({next:d=>{la(u.name,d.name,u.exact)&&oa(d,u.formState||b,st,u.reRenderRoot)&&u.callback({values:{...o},...r,...d,defaultValues:a})}}).unsubscribe,Ee=u=>(i.mount=!0,g={...g,...u.formState},Ae({...u,formState:{...h,...u.formState}})),pe=(u,d={})=>{for(const m of u?Qe(u):l.mount)l.mount.delete(m),l.array.delete(m),d.keepValue||(J(n,m),J(o,m)),!d.keepError&&J(r.errors,m),!d.keepDirty&&J(r.dirtyFields,m),!d.keepTouched&&J(r.touchedFields,m),!d.keepIsValidating&&J(r.validatingFields,m),!t.shouldUnregister&&!d.keepDefaultValue&&J(a,m);p.state.next({values:Y(o)}),p.state.next({...r,...d.keepDirty?{isDirty:V()}:{}}),!d.keepIsValid&&k()},ze=({disabled:u,name:d})=>{if(fe(u)&&i.mount||u||l.disabled.has(d)){const _=l.disabled.has(d)!==!!u;u?l.disabled.add(d):l.disabled.delete(d),_&&i.mount&&!i.action&&k()}},Te=(u,d={})=>{let m=F(n,u);const S=fe(d.disabled)||fe(t.disabled);return W(n,u,{...m||{},_f:{...m&&m._f?m._f:{ref:{name:u}},name:u,mount:!0,...d}}),l.mount.add(u),m?ze({disabled:fe(d.disabled)?d.disabled:t.disabled,name:u}):T(u,!0,d.value),{...S?{disabled:d.disabled||t.disabled}:{},...t.progressive?{required:!!d.required,min:Ge(d.min),max:Ge(d.max),minLength:Ge(d.minLength),maxLength:Ge(d.maxLength),pattern:Ge(d.pattern)}:{},name:u,onChange:Q,onBlur:Q,ref:_=>{if(_){Te(u,d),m=F(n,u);const y=G(_.value)&&_.querySelectorAll&&_.querySelectorAll("input,select,textarea")[0]||_,I=ea(y),$=m._f.refs||[];if(I?$.find(U=>U===y):y===m._f.ref)return;W(n,u,{_f:{...m._f,...I?{refs:[...$.filter(_t),y,...Array.isArray(F(a,u))?[{}]:[]],ref:{type:y.type,name:u}}:{ref:y}}}),T(u,!1,void 0,y)}else m=F(n,u,{}),m._f&&(m._f.mount=!1),(t.shouldUnregister||d.shouldUnregister)&&!(Ks(l.array,u)&&i.action)&&l.unMount.add(u)}}},me=()=>t.shouldFocusError&&et(n,ie,l.mount),rt=u=>{fe(u)&&(p.state.next({disabled:u}),et(n,(d,m)=>{const S=F(n,m);S&&(d.disabled=S._f.disabled||u,Array.isArray(S._f.refs)&&S._f.refs.forEach(_=>{_.disabled=S._f.disabled||u}))},0,!1))},We=(u,d)=>async m=>{let S;m&&(m.preventDefault&&m.preventDefault(),m.persist&&m.persist());let _=Y(o);if(p.state.next({isSubmitting:!0}),t.resolver){const{errors:y,values:I}=await A();E(),r.errors=y,_=Y(I)}else await L(n);if(l.disabled.size)for(const y of l.disabled)J(_,y);if(J(r.errors,"root"),re(r.errors)){p.state.next({errors:{}});try{await u(_,m)}catch(y){S=y}}else d&&await d({...r.errors},m),me(),setTimeout(me);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:re(r.errors)&&!S,submitCount:r.submitCount+1,errors:r.errors}),S)throw S},He=(u,d={})=>{F(n,u)&&(G(d.defaultValue)?q(u,Y(F(a,u))):(q(u,d.defaultValue),W(a,u,Y(d.defaultValue))),d.keepTouched||J(r.touchedFields,u),d.keepDirty||(J(r.dirtyFields,u),r.isDirty=d.defaultValue?V(u,Y(F(a,u))):V()),d.keepError||(J(r.errors,u),b.isValid&&k()),p.state.next({...r}))},Ie=(u,d={})=>{const m=u?Y(u):a,S=Y(m),_=re(u),y=_?a:S;if(d.keepDefaultValues||(a=m),!d.keepValues){if(d.keepDirtyValues){const I=new Set([...l.mount,...Object.keys(De(a,o))]);for(const $ of Array.from(I)){const U=F(r.dirtyFields,$),ee=F(o,$),Ve=F(y,$);U&&!G(ee)?W(y,$,ee):!U&&!G(Ve)&&q($,Ve)}}else{if(Ot&&G(u))for(const I of l.mount){const $=F(n,I);if($&&$._f){const U=Array.isArray($._f.refs)?$._f.refs[0]:$._f.ref;if(ot(U)){const ee=U.closest("form");if(ee){ee.reset();break}}}}if(d.keepFieldsRef)for(const I of l.mount)q(I,F(y,I));else n={}}o=t.shouldUnregister?d.keepDefaultValues?Y(a):{}:Y(y),p.array.next({values:{...y}}),p.state.next({values:{...y}})}l={mount:d.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!b.isValid||!!d.keepIsValid||!!d.keepDirtyValues||!t.shouldUnregister&&!re(y),i.watch=!!t.shouldUnregister,i.keepIsValid=!!d.keepIsValid,i.action=!1,d.keepErrors||(r.errors={}),p.state.next({submitCount:d.keepSubmitCount?r.submitCount:0,isDirty:_?!1:d.keepDirty?r.isDirty:!!(d.keepDefaultValues&&!Ce(u,a)),isSubmitted:d.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:_?{}:d.keepDirtyValues?d.keepDefaultValues&&o?De(a,o):r.dirtyFields:d.keepDefaultValues&&u?De(a,u):d.keepDirty?r.dirtyFields:{},touchedFields:d.keepTouched?r.touchedFields:{},errors:d.keepErrors?r.errors:{},isSubmitSuccessful:d.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Fe=(u,d)=>Ie(le(u)?u(o):u,{...t.resetOptions,...d}),nt=(u,d={})=>{const m=F(n,u),S=m&&m._f;if(S){const _=S.refs?S.refs[0]:S.ref;_.focus&&setTimeout(()=>{_.focus(),d.shouldSelect&&le(_.select)&&_.select()})}},st=u=>{r={...r,...u}},Ke={control:{register:Te,unregister:pe,getFieldState:$e,handleSubmit:We,setError:j,_subscribe:Ae,_runSchema:A,_updateIsValidating:E,_focusError:me,_getWatch:M,_getDirty:V,_setValid:k,_setFieldArray:x,_setDisabledField:ze,_setErrors:O,_getFieldArray:P,_reset:Ie,_resetDefaultValues:()=>le(t.defaultValues)&&t.defaultValues().then(u=>{Fe(u,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:D,_disableForm:rt,_subjects:p,_proxyFormState:b,get _fields(){return n},get _formValues(){return o},get _state(){return i},set _state(u){i=u},get _defaultValues(){return a},get _names(){return l},set _names(u){l=u},get _formState(){return r},get _options(){return t},set _options(u){t={...t,...u}}},subscribe:Ee,trigger:ne,register:Te,handleSubmit:We,watch:qe,setValue:q,getValues:K,reset:Fe,resetField:He,clearErrors:Ue,unregister:pe,setError:j,setFocus:nt,getFieldState:$e};return{...Ke,formControl:Ke}}function dt(e={}){const t=s.Cn.useRef(void 0),r=s.Cn.useRef(void 0),[n,a]=s.Cn.useState({isDirty:!1,isValidating:!1,isLoading:le(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:le(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:n},e.defaultValues&&!le(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:i,...l}=ha(e);t.current={...l,formState:n}}const o=t.current.control;return o._options=e,Xs(()=>{const i=o._subscribe({formState:o._proxyFormState,callback:()=>a({...o._formState}),reRenderRoot:!0});return a(l=>({...l,isReady:!0})),o._formState.isReady=!0,i},[o]),s.Cn.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),s.Cn.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),s.Cn.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),s.Cn.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),s.Cn.useEffect(()=>{if(o._proxyFormState.isDirty){const i=o._getDirty();i!==n.isDirty&&o._subjects.state.next({isDirty:i})}},[o,n.isDirty]),s.Cn.useEffect(()=>{var i;e.values&&!Ce(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((i=o._options.resetOptions)===null||i===void 0)&&i.keepIsValid||o._setValid(),r.current=e.values,a(l=>({...l}))):o._resetDefaultValues()},[o,e.values]),s.Cn.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=s.Cn.useMemo(()=>Zs(n,o),[o,n]),t.current}const pr=(e,t,r)=>{if(e&&"reportValidity"in e){const n=F(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},pa=(e,t)=>{for(const r in t.fields){const n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?pr(n.ref,r,e):n.refs&&n.refs.forEach(a=>pr(a,r,e))}},ma=(e,t)=>{t.shouldUseNativeValidation&&pa(e,t);const r={};for(const n in e){const a=F(t.fields,n),o=Object.assign(e[n]||{},{ref:a&&a.ref});if(ya(t.names||Object.keys(e),n)){const i=Object.assign({},F(r,n));W(i,"root",o),W(r,n,i)}else W(r,n,o)}return r},ya=(e,t)=>e.some(r=>r.startsWith(t+"."));var ft=function(e,t,r){return r===void 0&&(r={}),function(n,a,o){try{var i=!o.shouldUseNativeValidation&&o.criteriaMode==="all";return Promise.resolve(Es(e,n,Object.assign({},t,{abortPipeEarly:!i}))).then(function(l){if(l.issues){for(var c={};l.issues.length;){var f=l.issues[0],h=ks(f);if(h&&(c[h]||(c[h]={message:f.message,type:f.type}),i)){var b=c[h].types,g=b&&b[f.type];c[h]=Jr(h,i,c,f.type,g?[].concat(g,f.message):f.message)}l.issues.shift()}return{values:{},errors:ma(c,o)}}return{values:r.raw?n:l.output,errors:{}}})}catch(l){return Promise.reject(l)}}};const mr=27,yr=12,br=10,ba=s.isSubmissionOfType("enum"),ga=(e,t)=>{const r={min:e.minSelected??0,max:e.maxSelected??e.options.length};return ft(ve({checked:Se(Ur(ae(),Br()),Tt(n=>Object.entries(n).filter(([a,o])=>o).map(([a,o])=>a)),Ye(r.max,t("validation_multiple_choice_max",{count:r.max})),Ne(r.min,t("validation_multiple_choice_min",{count:r.min})))}))},va=s.k$1(({option:e,...t},r)=>s.o(s.k,{children:[s.o("input",{class:"peer sr-only h-full",type:"checkbox",...t,ref:r}),s.o("label",{class:"bg-lowest hover:bg-neutral-2 active:outline-neutral-8 ease-expo-out outline-divider text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 peer-focus-visible:ring-accent-9 peer-focus-visible:ring-offset-accent-7 block cursor-pointer select-none rounded-2xl px-3 py-1.5 outline outline-1 ring-0 ring-transparent transition-all selection:bg-transparent peer-focus-visible:ring-4",htmlFor:t.id,children:e.label})]})),gr=s.cva("gutter-stable flex w-full flex-1 flex-wrap gap-2 overflow-y-auto rounded-xl p-2.5 pr-4",{variants:{variant:{singleOption:"justify-center",booleanLike:Wr}}}),xa=({input:e,onSubmitSuccess:t})=>{var h,b;const r=e.key?(h=s.store.current$.value.flow)==null?void 0:h.data.submissions[e.key]:void 0,n=e.config.maxSelected===1,a=n&&e.config.options.length===2,{t:o}=s.useTranslation(),{register:i,handleSubmit:l,formState:{errors:c}}=dt({defaultValues:{checked:n?{}:ba(r)?Object.fromEntries(r.value.map(g=>[g,!0])):{}},resolver:ga(e.config,o)}),f=Dt();return a?s.o(s.k,{children:[s.o("ul",{style:{maxHeight:6.5*mr+5*yr+2*br},class:gr({variant:"booleanLike"}),children:e.config.options.map((g,p)=>s.o("li",{class:Hr,children:s.o(Kr,{type:"submit",ref:v=>{v&&p===0&&(f.current=v)},label:g.label,value:"true",onClick:()=>t({type:"enum",value:[g.value]})})},g.value))}),e.config.minSelected===0&&s.o("div",{class:"px-2 pb-2",children:s.o(xe,{class:"relative w-full",type:"button",onClick:()=>t({type:"enum",value:[]})})})]}):s.o("form",{noValidate:!0,onSubmit:g=>l(p=>{const v=p.checked;t({type:"enum",value:v})})(g),children:[s.o("div",{class:"flex items-center gap-1",children:[s.o("ul",{style:{maxHeight:6.5*mr+5*yr+2*br},class:gr({variant:e.config.options.length===1?"singleOption":void 0}),children:e.config.options.map((g,p)=>{const v=`checked.${g.value}`,{ref:w,...k}=i(v);return s.o("li",{class:"relative",children:s.o(va,{option:g,autoFocus:p===0,ref:E=>{E&&p===0&&(f.current=E),w(E)},id:v,...k,onClick:n?()=>t({type:"enum",value:[g.value]}):void 0})},g.value)})}),s.o("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[n?null:s.o(Me,{}),e.config.minSelected===0&&s.o(xe,{class:"relative",type:"button",onClick:()=>t({type:"enum",value:[]})})]})]}),s.o("div",{class:"px-1",children:s.o(Pe,{error:(b=c.checked)==null?void 0:b.root})})]})},wa=s.isSubmissionOfType("number"),_a=(e,t)=>{const r=e.min??Number.MIN_SAFE_INTEGER,n=e.max??Number.MAX_SAFE_INTEGER,a=e.decimalCases??0;return ft(ve({number:Se(Pr(t("validation_number")),Dr(r,t("validation_number_min",{min:r})),Rr(n,t("validation_number_max",{max:n})),Mr(o=>o===Number(o.toFixed(a)),t("validation_number_decimal_cases",{count:a})))}))},ka=({input:e,onSubmitSuccess:t})=>{var b;const r=e.config.defaultValue,n=e.key?(b=s.store.current$.value.flow)==null?void 0:b.data.submissions[e.key]:void 0,{t:a}=s.useTranslation(),{register:o,handleSubmit:i,formState:{errors:l}}=dt({defaultValues:{number:wa(n)?n.value:r?Number(r):void 0},resolver:_a(e.config,a)}),{ref:c,...f}=o("number",{required:!e.config.optional,valueAsNumber:!0}),h=s._();return s.y(()=>{h.current&&(h.current.focus(),h.current.select())},[]),s.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:i(g=>{g.number!==void 0&&t({type:"number",value:g.number})}),children:[s.o("div",{class:"flex items-center gap-2",children:[s.o("div",{class:"relative min-w-0 flex-grow",children:[s.o("input",{...f,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:g=>{g&&(h.current=g),c(g)},type:"text",min:e.config.min,max:e.config.max,class:Be({optional:e.config.optional,className:"[type=number:-webkit-inner-spin-button] w-full rounded-full [-webkit-outer-spin-button:none]"}),placeholder:e.config.placeholder}),e.config.optional&&s.o(xe,{class:"absolute bottom-0 right-0.5 top-0",onClick:()=>t(null)})]}),s.o(Me,{})]}),s.o(Pe,{error:l.number})]})},Ca="44",Sa=/^[0-9 ]+$/,Aa=s.isSubmissionOfType("string"),Ea=s.isSubmissionOfType("phone"),Ia=e=>{const t=Se(ae(e("validation_country_code")),Mt(Sa,e("validation_country_code"))),r=Se(ae(e("validation_phone")),Ne(1,e("validation_phone")),Tt(n=>n.replace(/[^0-9]/g,"")));return ft(ve({countryCode:t,phoneNumber:r}))},Fa=({input:e,onSubmitSuccess:t})=>{var w;const r=e.key?(w=s.store.current$.value.flow)==null?void 0:w.data.submissions[e.key]:void 0,{t:n}=s.useTranslation(),[a,o]=s.h(),i=Aa(r)?Is(r.value):Ea(r)?r.value:void 0,{register:l,handleSubmit:c,formState:{errors:f},watch:h}=dt({defaultValues:{countryCode:(i==null?void 0:i.countryCode)??e.config.defaultValue.countryCode??Ca,phoneNumber:(i==null?void 0:i.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:Ia(n)}),{ref:b,...g}=l("phoneNumber",{required:!e.config.optional}),p=s._(),v=h("countryCode");return s.y(()=>{p.current&&(p.current.focus(),p.current.select())},[]),s.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:c(k=>{const E=k.phoneNumber.replace(/[^0-9]/g,""),x=k.countryCode.replace(/[^0-9]/g,"");o(void 0);const N=e.config.minChars??7,O=E.length+x.length;if(O<N)return o(n("validation_phone_min_chars",{count:N}));const T=e.config.maxChars;if(T!=null&&O>T)return o(n("validation_max_chars",{count:T}));e.config.submissionFormat==="phone"?t({type:"phone",value:{countryCode:x,phoneNumber:E}}):t({type:"string",value:v+k.phoneNumber})}),children:[s.o("div",{class:"flex items-center gap-2",children:[s.o("div",{class:"relative flex min-w-0 flex-1 flex-grow gap-2",children:[s.o("label",{class:"text-neutral-12 bg-lowest hover:bg-neutral-5 placeholder:text-neutral-8 focus-visible:outline-accent-7 focus-within:bg-neutral-5 focus-within:outline-accent-7 outline-divider relative flex h-full cursor-pointer appearance-none items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-l-full border-solid px-3 py-1.5 text-center text-base outline outline-2 transition-all focus-within:outline-none",htmlFor:`isdk_phone_${e.key}`,children:[s.o("span",{children:["+",v]}),s.o("select",{...l("countryCode",{}),id:`isdk_phone_${e.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(Rt).map(([k,E])=>s.o("option",{value:E,children:[k," (+",E,")"]},k))})]}),s.o("input",{...g,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:k=>{k&&(p.current=k),b(k)},class:Be({optional:e.config.optional,className:"min-w-0 flex-1 rounded-r-full"}),placeholder:e.config.placeholder}),e.config.optional&&s.o(xe,{class:"absolute bottom-0 right-1 top-0",onClick:()=>t(null)})]}),s.o(Me,{})]}),s.o(Pe,{error:f.countryCode||f.phoneNumber||{message:a}})]})},at=e=>e===void 0?0:Math.max(0,Math.ceil((e-Date.now())/1e3)),vr=(e,t,r,n)=>r!==void 0&&n*1e3>s.J?e("submission_available_at",{time:s._e(r,t)}):e("submission_cooldown",{count:n}),Va=(e,t)=>{const r=e==null?void 0:e.trim();return r&&r!=="Submit"?r:t("submit")},La=({input:e,onSubmitSuccess:t})=>{const{t:r,locale:n}=s.useTranslation(),{availableAt:a}=e.config,[o,i]=s.h(()=>at(a)),[l,c]=s.h("");s.p(()=>{const h=at(a);if(i(h),h===0)return;c(vr(r,n,a,h));const b=setInterval(()=>{const g=at(a);i(g),!(g>0)&&(clearInterval(b),c(r("submission_cooldown_ready")))},250);return()=>clearInterval(b)},[a,n,r]);const f=o>0;return s.o("div",{class:"flex flex-col items-center gap-2 py-3",children:[s.o("button",{class:"bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 aria-disabled:hover:bg-accent-9 aria-disabled:hover:border-accent-9 flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:ring-2 active:ring-offset-2 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:active:ring-1 aria-disabled:active:ring-offset-[1.5px]",name:e.key,"aria-disabled":f,"aria-describedby":f?"submit-cooldown":void 0,onClick:()=>{at(a)>0||t(null)},children:s.o("span",{class:"flex items-center gap-1.5",children:[s.o("span",{class:"inline-flex items-center text-sm font-medium",children:Va(e.config.label,r)}),s.o("svg",{stroke:"currentColor","stroke-width":"1.5",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.o("path",{d:"M4 8L8 4L12 8"}),s.o("path",{d:"M8 4V13"})]})]})}),f&&s.o("p",{id:"submit-cooldown","aria-hidden":"true",class:"text-neutral-11 text-xs",children:vr(r,n,a,o)}),s.o("p",{role:"status",class:"sr-only",children:l})]})},Ma=160,xr=e=>{e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Ma)}px`},Ta={date:{type:"date",inputMode:"text"},email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},Ra=s.isSubmissionOfType("string"),Da=(e,t)=>{const r={maxLength:t("validation_max_chars",{count:e.maxChars??999}),minLength:t("validation_min_chars",{count:e.minChars??1})};return ft(ve({text:{date:Se(ae(t("validation_date")),Mt(/^\d{4}-\d{2}-\d{2}$/,t("validation_date"))),email:Se(ae(t("validation_email")),Tr(t("validation_email")),Ne(e.minChars??1,r.minLength),Ye(e.maxChars??1/0,r.maxLength)),text:Se(ae(),Ne(e.minChars??1,r.minLength),Ye(e.maxChars??1/0,r.maxLength)),url:Se(ae(t("validation_url")),Or(t("validation_url")),Ne(e.minChars??1,r.minLength),Ye(e.maxChars??1/0,r.maxLength))}[e.format]}))},Oa=({input:e,onSubmitSuccess:t})=>{var w;const{t:r}=s.useTranslation(),n=e.key?(w=s.store.current$.value.flow)==null?void 0:w.data.submissions[e.key]:void 0,a=e.config.defaultValue,o=e.config.multiline===!0&&e.config.format==="text",{register:i,handleSubmit:l,watch:c,formState:{errors:f}}=dt({defaultValues:{text:Ra(n)?n.value:a??""},resolver:Da(e.config,r)}),{ref:h,...b}=i("text",{required:!e.config.optional}),g=s._();s.y(()=>{g.current&&(g.current instanceof HTMLTextAreaElement&&xr(g.current),g.current.focus(),g.current.select())},[]);const p=e.config.maxChars,v=o&&p!==void 0?c("text").length:void 0;return s.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:l(k=>{t({type:"string",value:k.text})}),children:[s.o("div",{class:o?"flex items-end gap-2":"flex items-center gap-2",children:[s.o("div",{class:"relative min-w-0 flex-1",children:[o?s.o("textarea",{id:"chat-input",...b,rows:2,maxLength:p,autoFocus:!0,"aria-describedby":v!==void 0?"chat-input-count":void 0,onInput:k=>xr(k.currentTarget),onKeyDown:k=>{var E;k.key==="Enter"&&(k.ctrlKey||k.metaKey)&&(k.preventDefault(),(E=k.currentTarget.form)==null||E.requestSubmit())},ref:k=>{k&&(g.current=k),h(k)},placeholder:e.config.placeholder,class:Be({optional:!!e.config.optional,className:"block w-full resize-none overflow-y-auto rounded-2xl"})}):s.o("input",{id:"chat-input",...b,...Ta[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:k=>{k&&(g.current=k),h(k)},placeholder:e.config.placeholder,class:Be({optional:!!e.config.optional,className:"w-full rounded-full"})}),e.config.optional&&s.o(xe,{class:o?"absolute bottom-1 right-0.5":"absolute bottom-0 right-0.5 top-0",onClick:()=>t(null)})]}),s.o(Me,{})]}),v!==void 0&&p!==void 0&&s.o("p",{id:"chat-input-count",class:"text-neutral-10 px-3 text-right text-xs",children:[v,"/",p]}),s.o(Pe,{error:f.text})]})},Na={text:Oa,phone:Fa,"multiple-choice":xa,boolean:js,file:zs,submit:La,address:Rs,number:ka},ja=({logger:e,analytics:t,rpcClient:r})=>{var i;const n=(i=s.store.current$.value.flow)==null?void 0:i.data.currentInput,a=s._(null),o=()=>s.chatStore.onInteractionFn$.value();return s.y(()=>{var l;(l=a.current)==null||l.scrollTo({top:0})},[n]),s.o("div",{ref:a,class:"border-divider max-h-[calc(100%-var(--header-height)-4rem)] w-full shrink-0 scroll-pb-12 overflow-y-auto overscroll-contain border-t",children:s.o("div",{class:"flex flex-col",onPointerDownCapture:n?o:void 0,onKeyDownCapture:n?o:void 0,children:n?(()=>{const l=Na[n.type];return s.o(l,{logger:e,analytics:t,rpcClient:r,onSubmitSuccess:s.chatStore.onSubmitSuccessFn$.value,input:n})})():s.o("div",{class:"flex items-center gap-2 p-2.5",children:[s.o("input",{"aria-hidden":"true",id:"chat-input",class:Be({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),s.o(Me,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};function Ba(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pa=function(e){return e instanceof RegExp},$a=function(t){var r=/[\\^$.*+?()[\]{}|]/g,n=RegExp(r.source);return t&&n.test(t)?t.replace(r,"\\$&"):t},rn=function(e){return typeof e=="string"},Ua=function(e){var t=[];return e.forEach(function(r){Array.isArray(r)?t=t.concat(r):t.push(r)}),t};function qa(e,t,r){var n=0,a=0;if(e==="")return e;if(!e||!rn(e))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var o=t;Pa(o)||(o=new RegExp("("+$a(o)+")","gi"));for(var i=e.split(o),l=1,c=i.length;l<c;l+=2){if(i[l]===void 0||i[l-1]===void 0){console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");continue}a=i[l].length,n+=i[l-1].length,i[l]=r(i[l],l,n),n+=a}return i}var za=function(t,r,n){return Array.isArray(t)||(t=[t]),Ua(t.map(function(a){return rn(a)?qa(a,r,n):a}))};const Je=Ba(za),Wa=/(\[[^\]]+\]\([^)]+\))/g,Ha=/\[([^\]]+)\]\(([^)]+)\)/,Ka=/(https?:\/\/[^\s]+)/g,Ga=/_(.*?)_/g,Ja=/\*\*(.*?)\*\*/g,Za=/(\\n|\n)/g,wr="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",Xa=e=>{const t=Je(e,Wa,(l,c)=>{const[,f,h]=l.match(Ha)??[];return h?s.o("a",{class:wr,href:h,children:f??h},h+c):s.o("span",{children:"INVALID LINK"})}),r=Je(t,Ka,(l,c)=>s.o("a",{class:wr,href:l,children:l},l+c)),n=Je(r,Ga,(l,c)=>s.o("em",{children:l},l+c)),a=Je(n,Ja,(l,c)=>s.o("strong",{children:l},l+c));let o=0;return Je(a,Za,()=>s.o("br",{},`br-${o++}`))},Ya=s.cva("select-text max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative",{variants:{side:{left:"bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",right:"ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"},animate:{true:"animate-bubble-in",false:""}},defaultVariants:{side:"left"}}),Qa=({children:e,className:t,animate:r,side:n,...a})=>s.o("p",{style:{transformOrigin:n==="left"?"0% 50%":"100% 50%"},class:Ya({className:t,side:n,animate:r}),...a,children:e}),_r=new Map,kr=s.createTFunction({overrides:{},locale:void 0}),ei=(e,t)=>{const r=t==null?void 0:t.trim();if(!r)return e("job_alerts_privacy");const n=e("job_alerts_privacy_sender",{employer:r});return e("job_alerts_privacy")!==kr("job_alerts_privacy")&&n===kr("job_alerts_privacy_sender",{employer:r})?e("job_alerts_privacy"):n},ti=({flow:e,rpcClient:t})=>{const{t:r}=s.useTranslation(),n=e.data.flowSessionId,a=_r.get(n)??s.d("offer");_r.set(n,a);const o=c=>{const f=e.data.submissions[c];return(f==null?void 0:f.type)==="string"?f.value.trim():void 0},i=o("email")||e.nodes.flatMap(c=>c.type==="question-text"&&c.data.format==="email"?[o(c.data.key)]:[]).find(c=>!!c);if(!i||a.value==="declined")return null;if(a.value==="success")return s.o("p",{role:"status",children:r("job_alerts_success")});const l=async()=>{if(!(a.value!=="offer"&&a.value!=="error")){a.value="saving";try{await it.saveClosedRoleJobAlerts(t,{contact:{email:i,first_name:o("first_name"),last_name:o("last_name")},job:e.job}),a.value="success"}catch{a.value="error"}}};return s.o("div",{class:"bg-neutral-2 flex flex-col gap-2 rounded-xl p-3 text-sm",children:[s.o("p",{children:r("job_alerts_offer",{email:i})}),a.value==="error"?s.o("p",{role:"alert",children:r("job_alerts_error")}):null,s.o("div",{class:"flex gap-2",children:[s.o("button",{type:"button",class:"bg-accent-9 min-h-[44px] rounded-lg px-3 py-2 text-white",disabled:a.value==="saving",onClick:l,children:r("job_alerts_accept")}),s.o("button",{type:"button",class:"min-h-[44px] rounded-lg px-3 py-2",disabled:a.value==="saving",onClick:()=>{a.value!=="offer"&&a.value!=="error"||(a.value="declined")},children:r("job_alerts_decline")})]}),s.o("p",{class:"text-xs",children:ei(r,e.employer)})]})},ri=({message:e})=>s.o("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:s.o("a",{onClick:e.onClick,class:"bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:e.href,children:[e.text,s.o("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.o("path",{d:"M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",fill:"currentColor","fill-rule":"evenodd","clip-rule":"evenodd"})})]})}),ni=({className:e,...t})=>s.o("div",{"aria-hidden":!0,children:s.chatStore.isBotTyping$.value===!0?s.o("div",{"data-testid":"typing-indicator",class:s.clsx("flex gap-1 p-4",e),...t,children:Array.from({length:3},(r,n)=>s.o("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-n*200}ms`}}))}):void 0}),si={bot:"left",user:"right"},ai=s.cva("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]",{variants:{variant:{info:"text-neutral-11",warning:"text-system-warning",error:"text-error-11",success:"text-system-success"}}}),ii=({env:e,lastSentMessageFooter:t,rpcClient:r})=>{const{t:n}=s.useTranslation(),a=s.store.current$.value.flow,o=(a==null?void 0:a.data.messages)??[],i=o.findIndex(c=>c.type==="system"&&c.semantic==="submission-closed"),l=a?Vt(a):void 0;return s.o("ol",{"aria-label":n("chat_messages"),"aria-live":"polite",class:"mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[o.map((c,f)=>s.o(s.k,{children:[s.o("li",{class:"flex",tabIndex:f===o.length-1?-1:void 0,children:[l&&c.groupId===l&&!o.slice(f+1).some(h=>h.groupId===l)?t:null,s.M(c).with({type:"system"},h=>s.o("p",{class:ai({variant:h.variant}),children:h.text})).with({type:"text",author:s.z.union("bot","user")},h=>{const b=f===o.length-1,g=h.author==="bot"?Xa(h.text):h.text;return s.o(s.k,{children:s.o(Qa,{animate:b,side:si[h.author],children:g},f)})}).with({type:"link"},h=>s.o(ri,{message:h})).with({type:"image"},h=>s.o("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:h.url,style:{aspectRatio:h.width/h.height}})).with({type:"file"},h=>s.o(Ps,{class:h.author==="bot"?void 0:"ml-auto",file:{name:h.fileName,sizeKb:h.fileSizeKb}})).with({type:"loading"},h=>{const b=o[o.length-1];return!(h===b)||s.chatStore.isBotTyping$.value||a!=null&&a.data.isFinished?null:s.o("div",{class:"flex flex-grow flex-col items-center justify-center gap-2",children:[s.o(s.LoadingIndicator,{"aria-hidden":h.text?"true":void 0,class:"text-neutral-6 h-8 w-8"}),h.text?s.o("p",{role:"status",class:"text-neutral-11 text-sm",children:h.text}):null]})}).exhaustive()]}),f===i&&(a!=null&&a.jobAlerts)&&r?s.o("li",{children:s.o(ti,{flow:a,rpcClient:r},a.data.flowSessionId)}):null]},f)),e&&e!=="production"&&(a==null?void 0:a.data.isFinished)&&a.data.stagingDestination&&s.o("li",{class:"text-neutral-11 text-center text-xs",children:a.data.stagingDestination}),s.o("li",{class:s.chatStore.captchaVisible$.value?"flex":"hidden",children:s.o("div",{"data-captcha-slot":!0,tabIndex:-1,role:"group","aria-label":n("captcha_check"),class:"w-full max-w-[min(100%,24rem)] rounded-md"})},"captcha"),s.o(ni,{},"typing")]})},oi=({logger:e,apiClient:t,rpcClient:r,analytics:n,talentBankClient:a,env:o})=>{const{flow:i}=s.store.current$.value;s.invariant(i,"Flow is required to exist to show chatbot body");const l=s.store.viewState$.value,{chatRef:c,chatService:f}=s.useChatService(),{t:h}=s.useTranslation(),[b,g]=s.h();return s.y(()=>{l==="maximised"&&s.chatStore.scrollToEnd()},[l]),s.y(()=>{var B;const{state:p,flow:v}=s.store.current$.peek();if(p!=="loaded")throw new Error(h("invalid_state"));let w=v.data.nodeHistory.at(-1);if(s.chatStore.scrollToEnd(),s.store.setInput(void 0),v.data.isFinished)return;const k=()=>{const A=s.store.current$.peek().flow;!A||A.data.hasInteracted||(s.store.markAsInteracted(),Jt(n,A,"FLOW_INTERACT"))};s.chatStore.onInteractionFn$.value=k,w===void 0?(w=Ir(i.nodes).id,s.store.setCurrentNodeId(w),Jt(n,v,"FLOW_START")):s.store.removeMessagesSentByNodeIds([w,At]);const{interpret:E,abort:x,undo:N}=zn({context:i.context,analytics:{service:n,customProperties:(B=i.analytics)==null?void 0:B.customProperties},apiClient:t,logger:e,talentBankClient:a,flow:i,chatService:f,t:h,getApplicationRecovery:()=>{var A;return(A=s.store.current$.peek().flow)==null?void 0:A.data.applicationRecovery},setApplicationRecovery:s.store.setApplicationRecovery,persistWriteBarrier:()=>s.store.persistWriteBarrier(v),getSubmissions:()=>{var A;return(A=s.store.current$.peek().flow)==null?void 0:A.data.submissions},onInterpret:A=>s.store.setCurrentNodeId(A.id),onFlowEnd:async()=>{var C;s.store.markAsFinished();const A=s.store.current$.peek().flow;s.invariant(A),n.log({event:"FLOW_END",properties:{flow_id:i.id,flow_version:i.version,flow_session_id:A.data.flowSessionId,flow_build:i.build,job:i.job},customProperties:(C=i.analytics)==null?void 0:C.customProperties})}}),O=w,T=()=>{g(()=>N),E(O)},H=new AbortController;return v.offerResume?bs({chatService:f,t:h,signal:H.signal}).then(A=>(s.store.settleResume(v),A?T():(s.store.restart(),s.idb.flushStateData()))).catch(A=>{A instanceof s.O||e.error("Resume prompt failed",A)}):T(),()=>{H.abort(),s.chatStore.onInteractionFn$.value===k&&(s.chatStore.onInteractionFn$.value=()=>{}),x()}},[n,t,f,e,i,a,h]),s.o(s.k,{children:[s.o("div",{class:"relative flex min-h-0 w-full max-w-full flex-grow flex-col",children:[s.o("div",{ref:c,role:"region","aria-label":h("conversation_history"),tabIndex:0,className:"hide-scrollbars fr flex min-h-0 w-full max-w-full flex-grow flex-col overflow-y-auto ring-inset",style:{WebkitOverflowScrolling:"touch"},children:s.o(ii,{env:o,rpcClient:r,lastSentMessageFooter:!Vt(i)||!b?null:s.o(li,{undoFn:b})})}),s.chatStore.isReadingHistory$.value&&!i.data.isFinished&&!s.chatStore.isBotTyping$.value&&s.o("div",{class:"absolute bottom-2 left-1/2 -translate-x-1/2",children:s.o(s.SvgIconButton,{class:"bg-neutral-1 ring-divider shadow-surface-md ring-1","aria-label":h("jump_to_current"),onClick:()=>{var v,w;s.chatStore.scrollToEnd(),(w=((v=c.current)==null?void 0:v.querySelector('li[tabindex="-1"]'))??c.current)==null||w.focus({preventScroll:!0})},children:s.o(s.ChevronDown,{})})})]}),s.o(ja,{logger:e,analytics:n,rpcClient:r})]})},li=({undoFn:e})=>{const{t}=s.useTranslation();return s.o("div",{class:"flex flex-1 items-center justify-end px-1",children:s.o(s.SvgIconButton,{"aria-label":t("undo"),onClick:async()=>{const{flow:r}=s.store.current$.peek();s.invariant(r),e(r.data.nodeHistory)},children:s.o("path",{d:"M3 13h2.67l6.66-6.67a1.9 1.9 0 0 0 0-2.66 1.91 1.91 0 0 0-2.66 0L3 10.33V13Zm4.6-7.25 2.67 2.67"})})})};exports.ChatbotBody=oi;
|