@inploi/plugin-chatbot 14.13.3 → 14.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ "use strict";var Zr=Object.defineProperty;var Xr=(e,r,t)=>r in e?Zr(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var X=(e,r,t)=>(Xr(e,typeof r!="symbol"?r+"":r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-1b25fb45.cjs"),Yr=require("@inploi/sdk");var Qr="9.10.2",vr=`https://sdk.inploi.com/@inploi/flows@${Qr}/cdn/captcha/index.html`,en=new URL(vr).origin,Pt=3e4,tn=5*6e4,rn=e=>typeof e=="object"&&e!==null&&e.source==="inploi-captcha",mt=new WeakMap,nn=e=>{let r=mt.get(e);return r||(r=e.fetch("/flow/captcha").then(t=>{let n=t==null?void 0:t.site_key;return typeof n=="string"&&n!==""?n:void 0}).catch(t=>{throw mt.delete(e),t}),mt.set(e,r)),r},sn=(e,r={})=>new Promise((t,n)=>{let{signal:a,container:i=null,theme:o,onInteractive:l}=r instanceof AbortSignal?{signal:r}:r,c=!1,d=()=>{},g=k=>{c||(c=!0,clearTimeout(m),a==null||a.removeEventListener("abort",p),d(),k())},b=k=>g(()=>n(new Error(k))),p=()=>b("Captcha aborted"),m,_=k=>{clearTimeout(m),m=setTimeout(()=>b("Captcha timed out"),k)};if(_(Pt),a==null?void 0:a.aborted)return p();a==null||a.addEventListener("abort",p),(async()=>{let k=await nn(e);if(k===void 0)return g(()=>t(void 0));if(c)return;let C=document.createElement("iframe");C.src=`${vr}?${new URLSearchParams({sitekey:k,origin:window.location.origin,...o&&{theme:o}}).toString()}`,C.title="Cloudflare security check",C.style.cssText=`display:block;border:0;width:${i?"100%":"300px"};height:0;color-scheme:normal`,i?i.appendChild(C):(C.style.cssText+=";position:fixed;bottom:16px;right:16px;z-index:2147483647",document.body.appendChild(C));let I=!1,v=T=>{if(!C.contentWindow||T.source!==C.contentWindow||T.origin!==en||!rn(T.data))return;let V=T.data;switch(V.type){case"token":return g(()=>t(V.token));case"resize":C.style.height=`${Math.max(0,Math.ceil(V.height))}px`;return;case"before-interactive":return I=!0,_(tn),l==null?void 0:l();case"after-interactive":return I=!1,_(Pt);case"error":!I&&!V.interactive&&b("Captcha failed");return;case"expired":return b("Captcha expired");case"timeout":return b("Captcha timed out")}};window.addEventListener("message",v),d=()=>{window.removeEventListener("message",v),C.remove()}})().catch(k=>g(()=>n(k)))}),qt=({condition:e,context:r,submissions:t,ifBlock:n})=>{let[a,...i]=e.compareKey.split(".");if(!a)return!1;let o=s.ue({context:r,key:a,path:i,submissions:t});if(!o)return!1;switch(o.type){case"address":{let l=s.D(o.value,i);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 o.value!="object"||Array.isArray(o.value))return!1;let l=s.D(o.value,i),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:r});case"string":return Ze(c,{submissions:{_temp:{value:l,type:"string"}},context:r});case"number":return Ze(c,{submissions:{_temp:{value:l,type:"number"}},context:r});case"object":return Array.isArray(l)&&l.every(d=>typeof d=="string")?Ze(c,{submissions:{_temp:{value:l,type:"enum"}},context:r}):!1}break}case"boolean":{let l=e.compareValue==="true";switch(e.compare){case"equals":return o.value===l;case"notEquals":return o.value!==l}break}case"phone":case"string":{let l=o.type==="phone"?s.pe(o.value):o.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 o.value===l;case"notEquals":return o.value!==l;case"greaterThan":return o.value>l;case"greaterThanOrEqualTo":return o.value>=l;case"lessThan":return o.value<l;case"lessThanOrEqualTo":return o.value<=l}}catch{return console.error(`Failed to parse number in if-block ${n.id}`,o.value),!1}break}case"enum":switch(e.compare){case"equals":return o.value.length===1&&o.value[0]===e.compareValue;case"notEquals":return o.value.length===1&&o.value[0]!==e.compareValue;case"contains":return o.value.includes(e.compareValue);case"notContains":return!o.value.includes(e.compareValue)}break}},Ze=(e,{context:r,submissions:t})=>{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(qt({condition:a,context:r,submissions:t,ifBlock:e}))return!0;return!1}else{for(let a of n)if(!qt({condition:a,context:r,submissions:t,ifBlock:e}))return!1;return!0}},an=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,on=(e,{context:r,submissions:t})=>e.replace(an,(n,a,i="")=>{let[o,...l]=a.trim().split("."),c=s.ue({key:o,path:l,submissions:t,context:r});if(!c)return i;switch(c.type){case"boolean":return c.value===!0?"true":"false";case"file":return c.value.map(d=>`${d.name} (${s.le(d.sizeKb)})`).join(", ");case"enum":return c.value.join(", ");case"address":return Object.values(c.value).filter(d=>d&&d.trim().length>0).join(", ");case"number":case"string":return c.value?c.value.toString():i;case"phone":return s.pe(c.value);case"integration":{if(typeof c.value!="object"||Array.isArray(c.value))break;let d=s.D(c.value,l);switch(typeof d){case"boolean":return d===!0?"true":"false";case"string":return d;case"number":return d.toString();case"object":if(Array.isArray(d)&&d.every(g=>typeof g=="string"))return d.join(", ")}break}}return i});/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ln(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Et(e,r,t=""){const n=ln(e),a=e==null?void 0:e.length,i=r!==void 0;if(!n||i&&a!==r){const o=t&&`"${t}" `,l=i?` of length ${r}`:"",c=n?`length=${a}`:`type=${typeof e}`;throw new Error(o+"expected Uint8Array"+l+", got "+c)}return e}function Ut(e,r=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(r&&e.finished)throw new Error("Hash#digest() has already been called")}function cn(e,r){Et(e,void 0,"digestInto() output");const t=r.outputLen;if(e.length<t)throw new Error('"digestInto() output" expected to be of length >='+t)}function _t(...e){for(let r=0;r<e.length;r++)e[r].fill(0)}function yt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ue(e,r){return e<<32-r|e>>>r}const un=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),dn=Array.from({length:256},(e,r)=>r.toString(16).padStart(2,"0"));function fn(e){if(Et(e),un)return e.toHex();let r="";for(let t=0;t<e.length;t++)r+=dn[e[t]];return r}function hn(e,r={}){const t=(a,i)=>e(i).update(a).digest(),n=e(void 0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=a=>e(a),Object.assign(t,r),Object.freeze(t)}const pn=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function mn(e,r,t){return e&r^~e&t}function yn(e,r,t){return e&r^e&t^r&t}class bn{constructor(r,t,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=r,this.outputLen=t,this.padOffset=n,this.isLE=a,this.buffer=new Uint8Array(r),this.view=yt(this.buffer)}update(r){Ut(this),Et(r);const{view:t,buffer:n,blockLen:a}=this,i=r.length;for(let o=0;o<i;){const l=Math.min(a-this.pos,i-o);if(l===a){const c=yt(r);for(;a<=i-o;o+=a)this.process(c,o);continue}n.set(r.subarray(o,o+l),this.pos),this.pos+=l,o+=l,this.pos===a&&(this.process(t,0),this.pos=0)}return this.length+=r.length,this.roundClean(),this}digestInto(r){Ut(this),cn(r,this),this.finished=!0;const{buffer:t,view:n,blockLen:a,isLE:i}=this;let{pos:o}=this;t[o++]=128,_t(this.buffer.subarray(o)),this.padOffset>a-o&&(this.process(n,0),o=0);for(let b=o;b<a;b++)t[b]=0;n.setBigUint64(a-8,BigInt(this.length*8),i),this.process(n,0);const l=yt(r),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const d=c/4,g=this.get();if(d>g.length)throw new Error("_sha2: outputLen bigger than state");for(let b=0;b<d;b++)l.setUint32(4*b,g[b],i)}digest(){const{buffer:r,outputLen:t}=this;this.digestInto(r);const n=r.slice(0,t);return this.destroy(),n}_cloneInto(r){r||(r=new this.constructor),r.set(...this.get());const{blockLen:t,buffer:n,length:a,finished:i,destroyed:o,pos:l}=this;return r.destroyed=o,r.finished=i,r.length=a,r.pos=l,a%t&&r.buffer.set(n),r}clone(){return this._cloneInto()}}const we=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),gn=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]),_e=new Uint32Array(64);class vn extends bn{constructor(r){super(64,r,8,!1)}get(){const{A:r,B:t,C:n,D:a,E:i,F:o,G:l,H:c}=this;return[r,t,n,a,i,o,l,c]}set(r,t,n,a,i,o,l,c){this.A=r|0,this.B=t|0,this.C=n|0,this.D=a|0,this.E=i|0,this.F=o|0,this.G=l|0,this.H=c|0}process(r,t){for(let b=0;b<16;b++,t+=4)_e[b]=r.getUint32(t,!1);for(let b=16;b<64;b++){const p=_e[b-15],m=_e[b-2],_=ue(p,7)^ue(p,18)^p>>>3,k=ue(m,17)^ue(m,19)^m>>>10;_e[b]=k+_e[b-7]+_+_e[b-16]|0}let{A:n,B:a,C:i,D:o,E:l,F:c,G:d,H:g}=this;for(let b=0;b<64;b++){const p=ue(l,6)^ue(l,11)^ue(l,25),m=g+p+mn(l,c,d)+gn[b]+_e[b]|0,k=(ue(n,2)^ue(n,13)^ue(n,22))+yn(n,a,i)|0;g=d,d=c,c=l,l=o+m|0,o=i,i=a,a=n,n=m+k|0}n=n+this.A|0,a=a+this.B|0,i=i+this.C|0,o=o+this.D|0,l=l+this.E|0,c=c+this.F|0,d=d+this.G|0,g=g+this.H|0,this.set(n,a,i,o,l,c,d,g)}roundClean(){_t(_e)}destroy(){this.set(0,0,0,0,0,0,0,0),_t(this.buffer)}}class xn extends vn{constructor(){super(32);X(this,"A",we[0]|0);X(this,"B",we[1]|0);X(this,"C",we[2]|0);X(this,"D",we[3]|0);X(this,"E",we[4]|0);X(this,"F",we[5]|0);X(this,"G",we[6]|0);X(this,"H",we[7]|0)}}const wn=hn(()=>new xn,pn(1));var xr=e=>{let r=e.find(t=>t.isHead);if(!r)throw new Error("No head node found");return r},Ft=e=>{var r,t;if(!(e.data.isFinished||(r=e.data.startedWriteNodeIds)!=null&&r.length))return(t=[...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:t.groupId},kt=e=>Array.isArray(e)?e.map(kt):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([r],[t])=>r.localeCompare(t)).map(([r,t])=>[r,kt(t)])):typeof e=="function"?void 0:e,_n=e=>fn(wn(new TextEncoder().encode(JSON.stringify(kt(e)))));function kn(e,r,t,n){var a;if(n!=null&&n.aborted)return;let i=_n(t),o=(a=e.data).preApplyFingerprints??(a.preApplyFingerprints=[]);if(o.includes(i))return;o.push(i);let l=new AbortController,c=setTimeout(()=>l.abort(),5e3);r.fetch("/flow/pre-apply",{method:"POST",signal:l.signal,body:JSON.stringify(t)}).catch(()=>{let d=o.indexOf(i);d!==-1&&o.splice(d,1)}).finally(()=>{clearTimeout(c)})}var wr=({context:e,submissions:r})=>({context:e,submissions:r??{}}),ce=(e,r)=>on(e,wr(r)),Cn=(e,r)=>Ze(e,wr(r)),_r=({node:e,nodes:r,stopWhen:t})=>{if((t==null?void 0:t(e))===!0)return e;let n=e.nextId?r.find(a=>a.id===e.nextId):void 0;if(n)return _r({node:n,nodes:r,stopWhen:t})},Sn=({childNode:e,nodes:r})=>{let t=r.filter(n=>n.type==="if-block").find(n=>{if(!n.branchId)return!1;let a=r.find(o=>o.id===n.branchId);if(!a)return!1;let i=_r({node:a,nodes:r,stopWhen:o=>o.id===e.id});return!(!i||i.id!==e.id)});if(t!=null&&t.nextId)return r.find(n=>n.id===t.nextId)},In=3,An=({flow:e,analytics:r,logger:t,talentBankClient:n,context:a,apiClient:i,getSubmissions:o,getApplicationRecovery:l,setApplicationRecovery:c,chatService:d,persistWriteBarrier:g,onSubmitNetworkError:b,closedRoleBehaviour:p,settledOutcomes:m=p,dateEchoLocale:_,onFlowEnd:k,onInterpret:C,forceSubmitConfirmation:I,flowType:v,t:T})=>{var V;let M=new AbortController,Q={submitAccepted:!1};(V=e.data).startedWriteNodeIds??(V.startedWriteNodeIds=e.nodes.flatMap(D=>{var B,E;if(D.type!=="integration-application-submit"||!e.data.nodeHistory.includes(D.id))return[];let R=D.data.key?(B=o())==null?void 0:B[D.data.key]:void 0;return(R==null?void 0:R.type)==="integration"&&((E=s.fe(R.value))==null?void 0:E.verdict)==="not_submitted"?[]:[D.id]}));let N={...r.service,log:D=>r.service.log({...D,customProperties:{...D.customProperties,...r.customProperties}})},K=async(D,R)=>{let B=M.signal;if(B.aborted)return;let E=o(),F=l(),$=(F==null?void 0:F.submitNodeId)===D.id?e.nodes.find(L=>{var U;return L.id===F.fileQuestionNodeId&&L.type==="question-file"&&((U=E==null?void 0:E[L.data.key])==null?void 0:U.type)!=="file"}):void 0;if($)return K($,R);C==null||C(D,R);try{await En({flow:e,analytics:N,logger:t,talentBankClient:n,apiClient:i,context:a,node:D,submissions:E,applicationRecovery:F,setApplicationRecovery:async L=>{if(!B.aborted)try{await c(L)}catch(U){t.error("Failed to persist application recovery",U)}},forceSubmitConfirmation:I||(F==null?void 0:F.submitNodeId)===D.id,run:Q,persistWriteBarrier:g,onSubmitNetworkError:b,settledOutcomes:m,dateEchoLocale:_,flowType:v,signal:B,t:T,chat:{sendMessage:async L=>d.send({groupId:D.id,message:L,signal:B}),userInput:async L=>d.input({input:L,signal:B}),setSubmission:(L,U)=>{B.aborted||d.setSubmission(L,U)},captcha:d.captcha},next:L=>{if(B.aborted)return;let U=(F==null?void 0:F.fileQuestionNodeId)===D.id?F.submitNodeId:L,q=U?e.nodes.find(ee=>ee.id===U):Sn({childNode:D,nodes:e.nodes});return q?K(q,D):k==null?void 0:k(D)},end:()=>{B.aborted||(k==null||k(D))}})}catch(L){if(L instanceof s.T)return;throw L}};return{interpret:async D=>{let R=e.nodes.find(B=>B.id===D)??xr(e.nodes);return K(R)},undo:D=>{var U;if(delete e.data.reviewReplay,((U=e.data.startedWriteNodeIds)==null?void 0:U.length)||e.data.isFinished)return{removed:0};let R=Ft(e),B=R?D.lastIndexOf(R):-1,E=e.nodes.find(q=>q.id===R);if(B===-1||!E)return{removed:0};let F=e.nodes.find(q=>q.id===D[D.length-1]);M.abort();let $=D.splice(B);e.data.messages=e.data.messages.filter(q=>!q.groupId||!$.includes(q.groupId)),e.data.currentInput=null;let L=o();for(let q of $.slice(1)){let ee=e.nodes.find(Z=>Z.id===q);if(!(!ee||!L||ee.id===R)&&("key"in ee.data&&ee.data.key&&delete L[ee.data.key],"keys"in ee.data))for(let Z of Object.values(ee.data.keys))typeof Z=="string"&&delete L[Z]}return M=new AbortController,K(E,F),{removed:$.length}},abort:()=>{M.abort()}}};async function En(e){let r=e.node;switch(r.type){case"flow-section":return await e.chat.sendMessage({type:"system",variant:"info",text:r.data.title}),e.next(r.nextId);case"pre-apply-result":return Xn({...e,node:r});case"text":return Pn({...e,node:r});case"image":return qn({...e,node:r});case"question-text":return Un({...e,node:r});case"question-enum":return Wn({...e,node:r});case"question-number":return zn({...e,node:r});case"question-phone":return Hn({...e,node:r});case"question-boolean":return Kn({...e,node:r});case"question-file":return Jn({...e,node:r});case"question-address":return Gn({...e,node:r});case"end-flow":return Zn({...e,node:r});case"if-block":return $n({...e,node:r});case"jump":return Mn({...e,node:r});case"link":return jn({...e,node:r});case"integration-application-submit":return Bn({...e,node:r});case"add-submission":return Ln({...e,node:r});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"check-duplicate":return Vn({...e,node:r});case"feedback":return Fn({...e,node:r});default:throw new Error(`Unknown node: ${JSON.stringify(r)}`)}}async function Fn({next:e,node:r}){e(r.nextId)}async function Vn({next:e,node:r,talentBankClient:t,submissions:n,flow:a,logger:i,chat:o}){var c;let l={isDuplicate:!1};if(n&&t){let d=r.data.scope==="job"?(c=a.job)==null?void 0:c.id:void 0;if(r.data.scope==="company"||d!=null)try{l=await t.checkDuplicate({email:s.ae({key:r.data.email,submissions:n}).toString(),jobId:d,scope:r.data.scope})}catch(g){i.error("[check-duplicate]",g)}}o.setSubmission(r.data.key,{type:"integration",value:l}),e(r.nextId)}async function Mn({next:e,node:r}){e(r.data.targetId)}async function Ln({next:e,node:r,logger:t,submissions:n,context:a}){if(!n){t.error("Submissions not found");return}n[r.data.key]={type:"string",value:ce(r.data.value,{submissions:n,context:a})},e(r.nextId)}var Tn=5e3,Nn=(e,r)=>r?`${e}@${r.id_type}:${r.id}`:e,Rn=(e,r=Date.now())=>Math.min(e.until,r+(e.maintenance?s.z:e.throttles?s.Z:s.H)),Dn=(e,r,t)=>{let{waitMs:n,throttles:a,maintenance:i}=s.ve(r==null?void 0:r.throttles,t);return{key:e,until:Date.now()+n,...a!==void 0&&{throttles:a},...i&&{maintenance:i}}},On=["ApiError","NotFoundError","UnauthorisedError","SchemaValidationError","ParsingError"],Ct=e=>e instanceof Error&&On.includes(e.name)?e:void 0,zt=e=>{let r=Ct(e);return(r==null?void 0:r.name)==="ApiError"?r:void 0};async function Bn({chat:e,next:r,end:t,node:n,logger:a,apiClient:i,submissions:o,analytics:l,flow:c,applicationRecovery:d,setApplicationRecovery:g,forceSubmitConfirmation:b,flowType:p,run:m,persistWriteBarrier:_,signal:k,onSubmitNetworkError:C,settledOutcomes:I,t:v}){var K,D;let T=async({redirect_url:R,message:B,button_text:E})=>{let{anonymous_id:F,session_id:$}=l.getSessionInfo();await e.sendMessage({type:"text",author:"bot",text:B??v("submission_redirect_message")});try{let L=new URL(R);F&&!L.searchParams.has("anonymous_id")&&L.searchParams.set("anonymous_id",F),await e.sendMessage({type:"link",href:L.toString(),text:E??v("complete_submission"),onClick:()=>{if(!$){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:$,flow_version:c.version,href:L.toString(),job:c.job}})}})}catch(L){a.error(`Invalid redirect URL: ${R}`,L),e.sendMessage({type:"system",variant:"error",text:v("redirect_url_error")})}};if((K=c.data.startedWriteNodeIds)!=null&&K.includes(n.id)&&(d==null?void 0:d.submitNodeId)!==n.id){let R=(D=c.data.submitRedirects)==null?void 0:D[n.id];return R?(await T(R),r(n.nextId)):(await e.sendMessage({type:"system",variant:"warning",text:v("submission_unknown")}),t())}let V=Nn(n.id,c.job),M=0,Q=m.submitAccepted&&n.data.skipConfirmation===!0&&(d==null?void 0:d.submitNodeId)!==n.id,N=async R=>{var We,rt,nt,ft,Ke,u,f,h,w;let B=((We=c.data.submitCooldown)==null?void 0:We.key)===V?c.data.submitCooldown:void 0;B&&(B.until=Rn(B));let E=B==null?void 0:B.until;(c.data.reviewRequiresSend===!0&&!Q||R!==!0||E!==void 0&&E>Date.now())&&await e.userInput({type:"submit",key:void 0,config:{label:n.data.submitLabel,...E!==void 0&&{availableAt:E}}}),Q=!1;let F;if(n.data.captcha){let y=e.captcha,x=!0;try{F=await sn(i,{signal:k,container:(y==null?void 0:y.container())??null,theme:y==null?void 0:y.theme,onInteractive:()=>{e.sendMessage({type:"text",author:"bot",text:v("captcha_check")}).catch(()=>{}).then(()=>{x&&(y==null||y.reveal(!0))})}})}catch(A){if(a.error("Captcha check failed",A),k.aborted)return}finally{x=!1,y==null||y.reveal(!1)}}await e.sendMessage({type:"loading",text:v("submitting")});let{anonymous_id:$,session_id:L}=l.getSessionInfo();if(k.aborted)return;let U=((rt=c.data.startedWriteNodeIds)==null?void 0:rt.includes(n.id))===!0;if((d==null?void 0:d.submitNodeId)===n.id&&await g(void 0),U||(c.data.startedWriteNodeIds=[...c.data.startedWriteNodeIds??[],n.id]),await _().catch(y=>a.error("Failed to persist application write barrier",y)),k.aborted)return;let q,ee=setTimeout(()=>{q=e.sendMessage({type:"loading",semantic:"submission-still-working",text:v("submission_still_working")}).catch(y=>a.error("Failed to send submission progress message",y))},Tn),Z,H=await i.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:n.data.integrationId,anonymous_id:$,session_id:L,job:c.job,flow_build:c.build,...F!==void 0&&{captcha_token:F},submissions:s.C(c.nodes,s.se(o||{},n.data.submitKeys)),pre_apply:s.I(c.nodes,o||{},c.data.flowSessionId)})}).catch(y=>{Z=y;let x=zt(y);return(x==null?void 0:x.data)!==void 0?x.data:y});if(clearTimeout(ee),await q,k.aborted)return;if(Z!==void 0&&!Ct(Z)&&C)return await C(Z,k),N(!0);n.data.key&&e.setSubmission(n.data.key,{type:"integration",value:H});let ze=(nt=zt(Z))==null?void 0:nt.status,Ve=typeof ze=="number"?ze:void 0,O=s.fe(H,Ve),Me=O===void 0&&Ve===429,Le=I==="terminal"&&((O==null?void 0:O.outcome)==="closed"||(O==null?void 0:O.outcome)==="duplicate"),ve=c.data.failedAttemptAt,Se=ve==null?void 0:ve[V];ve&&Se!==void 0&&Se>Date.now()&&(Se=ve[V]=Date.now());let Te=Se!==void 0&&Date.now()-Se<s.ge||((ft=c.data.unconfirmedAttemptKeys)==null?void 0:ft.includes(V))===!0,He=(Ke=Ct(Z))==null?void 0:Ke.status,he=s.Se(H,typeof He=="number"?He:void 0);he&&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:he.service,response:he.response,captured:(H==null?void 0:H.captured)===!0,flow_type:(p==null?void 0:p())??"CHATBOT_DRAWER",job:c.job,...(O==null?void 0:O.outcome)==="duplicate"&&{outcome:Te?"duplicate_after_own_attempt":"duplicate"},...he.outcome&&{outcome:he.outcome}}});let Ne=s.U(H)||(H==null?void 0:H.success)===!0;if((Ne||s.$(H))&&(m.submitAccepted=!0),Ne&&((u=c.data.submitCooldown)==null?void 0:u.throttles)!==void 0&&(delete c.data.submitCooldown.throttles,await _().catch(y=>a.error("Failed to persist submit cooldown reset",y))),s.U(H)){let{redirect_url:y,message:x,button_text:A}=H.integration_response.data,j={redirect_url:y,message:x,button_text:A};return k.aborted?void 0:(c.data.submitRedirects={...c.data.submitRedirects,[n.id]:j},await _().catch(P=>a.error("Failed to persist submit redirect",P)),await T(j),r(n.nextId))}let tt=s.$(H);if(tt)return await e.sendMessage({type:"system",variant:"success",text:tt.message??v("submission_pending")}),r(n.nextId);if((H==null?void 0:H.success)===!0)return n.data.skipConfirmation!==!0&&await e.sendMessage({type:"system",variant:"success",text:v("submission_completed")}),r(n.nextId);let Re=s.Re(O),De=Re!==void 0&&((f=o==null?void 0:o[Re])==null?void 0:f.type)==="file"?Re:void 0,Ie=De===void 0?void 0:c.nodes.find(y=>y.type==="question-file"&&y.data.key===De);if(!Ie&&!Le&&!s.we(O)&&(c.data.submitCooldown=Dn(V,B,O)),(O==null?void 0:O.outcome)!=="duplicate"&&!Me&&(c.data.failedAttemptAt={...c.data.failedAttemptAt,[V]:Date.now()},(h=c.data.unconfirmedAttemptKeys)!=null&&h.includes(V)&&(c.data.unconfirmedAttemptKeys=c.data.unconfirmedAttemptKeys.filter(y=>y!==V))),(O==null?void 0:O.verdict)==="not_submitted"||(O==null?void 0:O.outcome)==="duplicate"||(O==null?void 0:O.outcome)==="closed"||Me||s.me(H,Ve)?(U||(c.data.startedWriteNodeIds=(w=c.data.startedWriteNodeIds)==null?void 0:w.filter(y=>y!==n.id)),(d==null?void 0:d.submitNodeId)===n.id&&await g(d),await _().catch(y=>a.error("Failed to persist application write barrier release",y))):await _().catch(y=>a.error("Failed to persist submit cooldown",y)),O){if(a.error(Z??O.message),Ie&&De!==void 0)return e.setSubmission(De,null),await g({fileQuestionNodeId:Ie.id,submitNodeId:n.id}),await e.sendMessage({type:"system",variant:"error",text:v("submission_unreadable_document")}),r(Ie.id);if(O.outcome==="duplicate")return await e.sendMessage({type:"system",variant:Le?"success":"info",semantic:"submission-duplicate",text:v(Te?"submission_duplicate_earlier_attempt":"submission_duplicate")}),Le?(delete c.data.submitCooldown,t()):N(!1);if(O.outcome==="closed")return await e.sendMessage({type:"system",variant:"info",semantic:"submission-closed",text:v("submission_closed")}),Le?(delete c.data.submitCooldown,t()):N(!1);let y=s.ye(O);return y?(await e.sendMessage({type:"system",variant:"warning",text:y.until===void 0?v("submission_provider_maintenance_later"):v("submission_provider_maintenance",{time:s.be(y.until,void 0)})}),N(!1)):O.outcome==="unknown"?(await e.sendMessage({type:"system",variant:"warning",text:v(s.ke(O)?"submission_unknown_do_not_resubmit":"submission_unknown")}),N(!1)):s.we(O)?s.xe(H)?(await e.sendMessage({type:"text",author:"bot",text:O.message}),N(!1)):(M===0&&await e.sendMessage({type:"system",variant:"warning",text:v("captcha_failed")}),M++,N(M<=In)):s.he(O)?(await e.sendMessage({type:"system",variant:"error",text:v("submission_retryable")}),N(!1)):(await e.sendMessage({type:"system",variant:"error",text:v("submission_failed")}),t())}return a.error(Z??H),Me?(await e.sendMessage({type:"system",variant:"error",text:v("submission_retryable")}),N(!1)):(await e.sendMessage({type:"system",variant:"error",text:v("submission_failed")}),t())};await N(b===!0&&!Q?!1:n.data.skipConfirmation)}async function jn({chat:e,next:r,node:t,submissions:n,context:a}){await e.sendMessage({type:"link",href:ce(t.data.href,{submissions:n,context:a}),text:ce(t.data.cta,{submissions:n,context:a})}),r(t.nextId)}async function $n({submissions:e,next:r,node:t,context:n}){r(Cn(t,{submissions:e,context:n})?t.branchId:t.nextId)}async function Pn({chat:e,next:r,node:t,submissions:n,context:a}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.text,{submissions:n,context:a})}),r(t.nextId)}async function qn({chat:e,next:r,node:t}){await e.sendMessage({author:"bot",type:"image",url:t.data.url,height:t.data.height,width:t.data.width}),r(t.nextId)}async function Un({chat:e,next:r,node:t,submissions:n,context:a,t:i,dateEchoLocale:o}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.question,{submissions:n,context:a})});let l=t.data.format==="phone"?await e.userInput({key:t.data.key,type:"phone",config:{optional:t.data.optional,placeholder:t.data.placeholder,minChars:t.data.minChars,maxChars:t.data.maxChars,submissionFormat:"text",defaultValue:{}}}):await e.userInput({key:t.data.key,type:"text",config:{optional:t.data.optional,placeholder:t.data.placeholder,format:t.data.format,maxChars:t.data.maxChars,minChars:t.data.minChars,multiline:t.data.format==="text"&&t.data.multiline===!0}});l===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:l.type==="phone"?s.pe(l.value):t.data.format==="date"&&o!==void 0?s.Ee(l.value,o):l.value}),r(t.nextId)}async function zn({chat:e,next:r,node:t,submissions:n,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.question,{submissions:n,context:a})});let o=await e.userInput({key:t.data.key,type:"number",config:{max:t.data.max,min:t.data.min,optional:t.data.optional,placeholder:t.data.placeholder,decimalCases:t.data.decimalCases}});o===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.value.toString()}),r(t.nextId)}async function Hn({chat:e,next:r,node:t,submissions:n,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.question,{submissions:n,context:a})});let o=await e.userInput({key:t.data.key,type:"phone",config:{minChars:t.data.minChars,defaultValue:{countryCode:t.data.defaultCountryCode},placeholder:t.data.placeholder,submissionFormat:"phone",optional:t.data.optional}});o===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.type==="phone"?s.pe(o.value):o.value}),r(t.nextId)}async function Wn({chat:e,next:r,node:t,submissions:n,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.question,{submissions:n,context:a})});let o=await e.userInput({key:t.data.key,type:"multiple-choice",config:t.data});o.value.length===0?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:t.data.options.filter(l=>o.value.includes(l.value)).map(l=>l.label).join(", ")}),r(t.nextId)}async function Kn({chat:e,next:r,node:t,submissions:n,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.question,{submissions:n,context:a})});let o=await e.userInput({key:t.data.key,type:"boolean",config:{optional:t.data.optional,labels:{true:t.data.trueLabel,false:t.data.falseLabel}}});o===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.value===!0?t.data.trueLabel:t.data.falseLabel}),r(t.nextId)}async function Gn({chat:e,next:r,node:t,t:n}){await e.sendMessage({author:"bot",type:"text",text:t.data.question});let a=await e.userInput({type:"address",key:t.data.key,config:{optional:t.data.optional,keys:t.data.keys,line2Required:t.data.line2Required,placeholder:t.data.placeholder}});if(a===null)await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:n("skipped")});else{let i=Object.values(a.value).filter(o=>o&&o.trim().length>0).join(", ");await e.sendMessage({author:"user",type:"text",text:i})}return r(t.nextId)}async function Jn({node:e,chat:r,next:t,submissions:n,context:a,t:i}){await r.sendMessage({author:"bot",type:"text",text:ce(e.data.question,{submissions:n,context:a})});let o=await r.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(o===null)await r.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")});else for(let l of o.value)await r.sendMessage({author:"user",type:"file",fileName:l.name,fileSizeKb:l.sizeKb});return t(e.nextId)}async function Zn({chat:e,end:r,node:t}){await e.sendMessage({type:"system",variant:"info",text:t.data.systemMessage}),r()}async function Xn({node:e,flow:r,submissions:t,chat:n,next:a,apiClient:i,analytics:o,signal:l,context:c}){let d=s.N(r.nodes,t||{}),{answers:g,...b}=d;if(n.setSubmission(e.data.key,{type:"integration",value:b}),kn(r,i,{...o.getSessionInfo(),job:r.job,flow_build:r.build,pre_apply:s.I(r.nodes,t||{},r.data.flowSessionId)},l),d.status!=="skipped"){let p=[d.status==="unavailable"?"We could not prepare your pre-apply summary. You can still continue to your application.":d.hasHardConcerns?e.data.messages.hard:d.hasAdvisoryConcerns?e.data.messages.advisory:e.data.messages.matched];for(let m of["hard","advisory"]){let _=g.filter(k=>!k.matched&&k.severity===m);_.length&&p.push((m==="hard"?"Role requirements":"Other things to consider")+`
2
+ `+_.map(k=>`• ${k.message}`).join(`
3
+ `))}await n.sendMessage({type:"text",author:"bot",text:p.join(`
4
+
5
+ `)}),d.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:ce(e.data.continueLabel,{submissions:t,context:c})}})}return a(e.nextId)}const Ht=(e,r,t)=>{var n;return e.log({event:t,properties:{flow_id:r.id,flow_version:r.version,flow_session_id:r.data.flowSessionId,flow_build:r.build,flow_type:"CHATBOT_DRAWER",job:r.job},customProperties:(n=r.analytics)==null?void 0:n.customProperties})},St="resume-prompt",Yn=async({chatService:e,t:r,signal:t})=>{await e.send({message:{type:"text",author:"bot",text:r("resume_prompt")},groupId:St,signal:t});const n=await e.input({input:{type:"boolean",key:void 0,config:{labels:{true:r("resume_continue"),false:r("resume_start_again")},optional:!1}},signal:t});return s.store.removeMessagesSentByNodeIds([St]),(n==null?void 0:n.value)!==!1},Fe=({class:e,...r})=>{const{t}=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",...r,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:t("send")}),s.o("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),s.o("path",{d:"M8 4V13"})]})})};var pe;function ot(e){return{lang:(e==null?void 0:e.lang)??(pe==null?void 0:pe.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(pe==null?void 0:pe.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(pe==null?void 0:pe.abortPipeEarly)}}var bt;function Qn(e){return bt==null?void 0:bt.get(e)}var gt;function es(e){return gt==null?void 0:gt.get(e)}var vt;function ts(e,r){var t;return(t=vt==null?void 0:vt.get(e))==null?void 0:t.get(r)}function Pe(e){var t,n;const r=typeof e;return r==="string"?`"${e}"`:r==="number"||r==="bigint"||r==="boolean"?`${e}`:r==="object"||r==="function"?(e&&((n=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:n.name))??"null":r}function te(e,r,t,n,a){const i=a&&"input"in a?a.input:t.value,o=(a==null?void 0:a.expected)??e.expects??null,l=(a==null?void 0:a.received)??Pe(i),c={kind:e.kind,type:e.type,input:i,expected:o,received:l,message:`Invalid ${r}: ${o?`Expected ${o} 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},d=e.kind==="schema",g=(a==null?void 0:a.message)??e.message??ts(e.reference,c.lang)??(d?es(c.lang):null)??n.message??Qn(c.lang);g!==void 0&&(c.message=typeof g=="function"?g(c):g),d&&(t.typed=!1),t.issues?t.issues.push(c):t.issues=[c]}function fe(e){return{version:1,vendor:"valibot",validate(r){return e["~run"]({value:r},ot())}}}function rs(e,r){return Object.hasOwn(e,r)&&r!=="__proto__"&&r!=="prototype"&&r!=="constructor"}function ns(e,r){const t=[...new Set(e)];return t.length>1?`(${t.join(` ${r} `)})`:t[0]??"never"}function ss(e){if(e.path){let r="";for(const t of e.path)if(typeof t.key=="string"||typeof t.key=="number")r?r+=`.${t.key}`:r+=t.key;else return null;return r}return null}var as=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}},is=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;function kr(e,r){return{kind:"validation",type:"check",reference:kr,async:!1,expects:null,requirement:e,message:r,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&te(this,"input",t,n),t}}}function Cr(e){return{kind:"validation",type:"email",reference:Cr,expects:null,async:!1,requirement:is,message:e,"~run"(r,t){return r.typed&&!this.requirement.test(r.value)&&te(this,"email",r,t),r}}}function Xe(e,r){return{kind:"validation",type:"max_length",reference:Xe,async:!1,expects:`<=${e}`,requirement:e,message:r,"~run"(t,n){return t.typed&&t.value.length>this.requirement&&te(this,"length",t,n,{received:`${t.value.length}`}),t}}}function Sr(e,r){return{kind:"validation",type:"max_value",reference:Sr,async:!1,expects:`<=${e instanceof Date?e.toJSON():Pe(e)}`,requirement:e,message:r,"~run"(t,n){return t.typed&&!(t.value<=this.requirement)&&te(this,"value",t,n,{received:t.value instanceof Date?t.value.toJSON():Pe(t.value)}),t}}}function $e(e,r){return{kind:"validation",type:"min_length",reference:$e,async:!1,expects:`>=${e}`,requirement:e,message:r,"~run"(t,n){return t.typed&&t.value.length<this.requirement&&te(this,"length",t,n,{received:`${t.value.length}`}),t}}}function Ir(e,r){return{kind:"validation",type:"min_value",reference:Ir,async:!1,expects:`>=${e instanceof Date?e.toJSON():Pe(e)}`,requirement:e,message:r,"~run"(t,n){return t.typed&&!(t.value>=this.requirement)&&te(this,"value",t,n,{received:t.value instanceof Date?t.value.toJSON():Pe(t.value)}),t}}}function Vt(e,r){return{kind:"validation",type:"regex",reference:Vt,async:!1,expects:`${e}`,requirement:e,message:r,"~run"(t,n){return t.typed&&!this.requirement.test(t.value)&&te(this,"format",t,n),t}}}function Mt(e){return{kind:"transformation",type:"transform",reference:Mt,async:!1,operation:e,"~run"(r){return r.value=this.operation(r.value),r}}}function Ar(e){return{kind:"validation",type:"url",reference:Ar,async:!1,expects:null,requirement(r){try{return new URL(r),!0}catch{return!1}},message:e,"~run"(r,t){return r.typed&&!this.requirement(r.value)&&te(this,"URL",r,t),r}}}function os(e,r,t){return typeof e.fallback=="function"?e.fallback(r,t):e.fallback}function Er(e,r,t){return typeof e.default=="function"?e.default(r,t):e.default}function Fr(e,r){return{kind:"schema",type:"array",reference:Fr,expects:"Array",async:!1,item:e,message:r,get"~standard"(){return fe(this)},"~run"(t,n){var i;const a=t.value;if(Array.isArray(a)){t.typed=!0,t.value=[];for(let o=0;o<a.length;o++){const l=a[o],c=this.item["~run"]({value:l},n);if(c.issues){const d={type:"array",origin:"value",input:a,key:o,value:l};for(const g of c.issues)g.path?g.path.unshift(d):g.path=[d],(i=t.issues)==null||i.push(g);if(t.issues||(t.issues=c.issues),n.abortEarly){t.typed=!1;break}}c.typed||(t.typed=!1),t.value.push(c.value)}}else te(this,"type",t,n);return t}}}function Vr(e){return{kind:"schema",type:"boolean",reference:Vr,expects:"boolean",async:!1,message:e,get"~standard"(){return fe(this)},"~run"(r,t){return typeof r.value=="boolean"?r.typed=!0:te(this,"type",r,t),r}}}function Mr(e){return{kind:"schema",type:"number",reference:Mr,expects:"number",async:!1,message:e,get"~standard"(){return fe(this)},"~run"(r,t){return typeof r.value=="number"&&!isNaN(r.value)?r.typed=!0:te(this,"type",r,t),r}}}function be(e,r){return{kind:"schema",type:"object",reference:be,expects:"Object",async:!1,entries:e,message:r,get"~standard"(){return fe(this)},"~run"(t,n){var i;const a=t.value;if(a&&typeof a=="object"){t.typed=!0,t.value={};for(const o in this.entries){const l=this.entries[o];if(o in a||(l.type==="exact_optional"||l.type==="optional"||l.type==="nullish")&&l.default!==void 0){const c=o in a?a[o]:Er(l),d=l["~run"]({value:c},n);if(d.issues){const g={type:"object",origin:"value",input:a,key:o,value:c};for(const b of d.issues)b.path?b.path.unshift(g):b.path=[g],(i=t.issues)==null||i.push(b);if(t.issues||(t.issues=d.issues),n.abortEarly){t.typed=!1;break}}d.typed||(t.typed=!1),t.value[o]=d.value}else if(l.fallback!==void 0)t.value[o]=os(l);else if(l.type!=="exact_optional"&&l.type!=="optional"&&l.type!=="nullish"&&(te(this,"key",t,n,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:a,key:o,value:a[o]}]}),n.abortEarly))break}}else te(this,"type",t,n);return t}}}function je(e,r){return{kind:"schema",type:"optional",reference:je,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:r,get"~standard"(){return fe(this)},"~run"(t,n){return t.value===void 0&&(this.default!==void 0&&(t.value=Er(this,t,n)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,n)}}}function Lr(e,r){return{kind:"schema",type:"picklist",reference:Lr,expects:ns(e.map(Pe),"|"),async:!1,options:e,message:r,get"~standard"(){return fe(this)},"~run"(t,n){return this.options.includes(t.value)?t.typed=!0:te(this,"type",t,n),t}}}function Tr(e,r,t){return{kind:"schema",type:"record",reference:Tr,expects:"Object",async:!1,key:e,value:r,message:t,get"~standard"(){return fe(this)},"~run"(n,a){var o,l;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const c in i)if(rs(i,c)){const d=i[c],g=this.key["~run"]({value:c},a);if(g.issues){const p={type:"object",origin:"key",input:i,key:c,value:d};for(const m of g.issues)m.path=[p],(o=n.issues)==null||o.push(m);if(n.issues||(n.issues=g.issues),a.abortEarly){n.typed=!1;break}}const b=this.value["~run"]({value:d},a);if(b.issues){const p={type:"object",origin:"value",input:i,key:c,value:d};for(const m of b.issues)m.path?m.path.unshift(p):m.path=[p],(l=n.issues)==null||l.push(m);if(n.issues||(n.issues=b.issues),a.abortEarly){n.typed=!1;break}}(!g.typed||!b.typed)&&(n.typed=!1),g.typed&&(n.value[g.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 fe(this)},"~run"(r,t){return typeof r.value=="string"?r.typed=!0:te(this,"type",r,t),r}}}function ls(e,r,t){const n=e["~run"]({value:r},ot(t));if(n.issues)throw new as(n.issues);return n.value}function cs(e,r){const t={};for(const n in e.entries)t[n]=!r||r.includes(n)?je(e.entries[n]):e.entries[n];return{...e,entries:t,get"~standard"(){return fe(this)}}}function Ce(...e){return{...e[0],pipe:e,get"~standard"(){return fe(this)},"~run"(r,t){for(const n of e)if(n.kind!=="metadata"){if(r.issues&&(n.kind==="schema"||n.kind==="transformation")){r.typed=!1;break}(!r.issues||!t.abortEarly&&!t.abortPipeEarly)&&(r=n["~run"](r,t))}return r}}}function us(e,r,t){const n=e["~run"]({value:r},ot(t));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}async function ds(e,r,t){const n=await e["~run"]({value:r},ot(t));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}const Ue=({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})]}),ge=({class:e,...r})=>{const{t}=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),...r,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:t("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"})]}),t("skip")]})};var Lt={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"},fs=e=>{if(e==="")return{countryCode:"",phoneNumber:""};let r=Object.values(Lt).find(n=>e.startsWith(n))??"",t=e.replace(r,"");return/^\d+$/.test(t)?{countryCode:r,phoneNumber:t}:{countryCode:"",phoneNumber:""}};const qe=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}}),hs="https://api.mapbox.com/search/searchbox/v1/suggest",ps="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",ms=e=>atob(e).split("").reverse().join(""),me=be({name:ae()}),ys=be({suggestions:Fr(be({feature_type:je(ae()),full_address:je(ae()),place_formatted:je(ae()),name:je(ae()),mapbox_id:ae(),context:cs(be({address:me,street:me,neighborhood:me,locality:me,district:me,place:me,region:me,postcode:me,country:me}))}))}),bs=({logger:e,t:r})=>s.F(()=>{var n;const t=(n=s.store.current$.peek().flow)==null?void 0:n.data.flowSessionId;return t?{enabled:!0,getPredictions:async a=>{var b;const i=new URL(hs);i.searchParams.set("q",a),i.searchParams.set("session_token",t);const o=(b=s.store.current$.peek().flow)==null?void 0:b.locationOrigin;o&&o.lat!==void 0&&o.lng!==void 0&&o.lat>=-90&&o.lat<=90&&o.lng>=-180&&o.lng<=180&&i.searchParams.set("proximity",`${o.lng},${o.lat}`),i.searchParams.set("access_token",ms(ps));const c=await fetch(i);if(!c.ok)return e.error("Failed to get address details",c),{ok:!1,error:r("address_error")};const d=us(ys,await c.json());if(d.success===!1)return e.error("Failed to parse address details",d.issues),{ok:!1,error:r("address_error")};const{suggestions:g}=d.output;return{ok:!0,data:g.map(p=>{var m,_,k,C,I,v,T,V,M;return{label:p.full_address??([p.name,p.place_formatted].filter(Boolean).join(", ")||p.mapbox_id),id:p.mapbox_id,address:{line1:((m=p.context.address)==null?void 0:m.name)??((_=p.context.street)==null?void 0:_.name),line2:void 0,line3:((k=p.context.neighborhood)==null?void 0:k.name)??((C=p.context.locality)==null?void 0:C.name),city:((I=p.context.place)==null?void 0:I.name)??((v=p.context.district)==null?void 0:v.name),state:(T=p.context.region)==null?void 0:T.name,postcode:((V=p.context.postcode)==null?void 0:V.name)??(p.feature_type==="postcode"?p.name:void 0),country:(M=p.context.country)==null?void 0:M.name}}})}}}:{enabled:!1}},[e,r]),Wt=e=>{const{t:r}=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:r("back")})]})},gs=({input:e,onSubmitSuccess:r,logger:t})=>{const{t:n}=s.useTranslation(),[a,i]=s.h(),{enabled:o,getPredictions:l}=bs({logger:t,t:n}),[c,d]=s.h(o?"query":"manual"),[g,b]=s.h(""),[p,m]=s.h(),_=s._(),k=s._(),C=v=>{var V;if(s.invariant(o,"Query state should not be enabled"),v=v.trim(),v===((V=_.current)==null?void 0:V.query)||v===(p==null?void 0:p.query)&&p.status==="done")return;if(b(v),v===""){_.current=void 0,m(void 0);return}const T=_.current={query:v};m({query:v,status:"pending"}),l(v).then(M=>{_.current===T&&(_.current=void 0,m(M.ok?{query:v,status:"done",items:M.data}:{query:v,status:"failed",error:M.error}))},M=>{_.current===T&&(_.current=void 0,t.error("Failed to get address details",M),m({query:v,status:"failed",error:n("address_error")}))})},I=(v,T)=>{i(V=>({...V,[v]:T}))};switch(c){case"query":return s.invariant(o,"Query state should not be enabled"),s.o(vs,{input:e,onSkip:()=>r(null),onAddressSelect:v=>{if(v===""){_.current&&(_.current=void 0,m(void 0)),d("manual");return}const T=(p==null?void 0:p.status)==="done"?p.items.find(V=>V.id===v):void 0;T&&(k.current!==v&&i(T.address),k.current=v,d("details"))},onAddressSearch:C,lookup:p,query:g});case"details":return s.invariant(a!==void 0),s.o(Kt,{input:e,logger:t,onSubmitSuccess:r,addressFields:a,onFieldChange:I,actions:s.o(Wt,{onClick:()=>{d("query")}})});case"manual":return s.o(Kt,{logger:t,input:e,onSubmitSuccess:r,addressFields:a??{},onFieldChange:I,actions:o?s.o(Wt,{onClick:()=>{d("query")}}):e.config.optional?s.o(ge,{onClick:()=>r(null)}):void 0})}},vs=({input:e,onSkip:r,lookup:t,onAddressSelect:n,query:a,onAddressSearch:i})=>{const{t:o}=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 g=new FormData(c.currentTarget).get("address");typeof g=="string"&&i(g)},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||o("address_search"),defaultValue:a,class:qe({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:o("search")})]})]}),e.config.optional&&s.o(ge,{class:"relative",onClick:r})]}),(t==null?void 0:t.status)==="failed"?s.o(Ue,{error:{message:t.error}}):null,s.o("p",{role:"status",class:(t==null?void 0:t.status)==="pending"||(t==null?void 0:t.status)==="done"&&t.items.length===0?"text-neutral-11 flex items-center gap-2 px-4 py-2 text-sm":"sr-only",children:(t==null?void 0:t.status)==="pending"?s.o(s.k,{children:[s.o(s.LoadingIndicator,{"aria-hidden":"true",class:"h-4 w-4 shrink-0"}),o("address_searching")]}):(t==null?void 0:t.status)==="done"&&t.items.length===0?o("address_no_results"):null}),s.o("ul",{children:[((t==null?void 0:t.status)==="done"?t.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:()=>{n(c.id)},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:()=>{n("")},children:s.o("span",{class:"flex-grow",children:o("address_manual")})})},"")]})]})},xt=["line1","line2","line3","city","state","postcode","country"],Kt=({addressFields:e,onFieldChange:r,onSubmitSuccess:t,actions:n,input:a})=>{const i=s._(null);s.y(()=>{if(i.current){const c=i.current.querySelector("input");c&&(c.focus(),c.select())}},[]);const o=Object.keys(Lt),{t:l}=s.useTranslation();return s.o("form",{class:"flex flex-col px-2 pt-2",onSubmit:c=>{c.preventDefault();const d=c.currentTarget,g=[...d.querySelectorAll("input")].filter(m=>m.value!==""&&!m.value.trim());for(const m of g){m.value="";const _=xt.find(k=>a.config.keys[k]===m.name);_&&r(_,"")}if(g.length>0&&!d.checkValidity()){d.reportValidity();return}const b=new FormData(d),p=Object.fromEntries(b.entries());t({type:"address",value:p})},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:i,children:xt.map((c,d)=>{const g=`isdk_${c}`,b=a.config.keys[c];return b?s.o(s.k,{children:[s.o("label",{for:g,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:g,defaultValue:e[c],onChange:p=>r(c,p.currentTarget.value),required:!0,children:[e.country&&!o.includes(e.country)?s.o("option",{value:e[c],children:e[c]}):s.o("option",{value:"",children:l("select_country")}),o.map(p=>s.o("option",{value:p,children:p},p))]}),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:d===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:g,defaultValue:e[c],onInput:p=>r(c,p.currentTarget.value),required:c==="line2"?a.config.line2Required===!0:c!=="line3"}),d===xt.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(Fe,{class:"ml-auto"})]})]})},Tt=()=>{const e=s._(null);return s.p(()=>{var r;(r=e.current)==null||r.focus()},[]),e},Nr=["true","false"],xs=Lr(Nr),ws="answer",Rr="flex items-center flex-wrap gap-2 p-2.5",Dr="min-w-0 max-w-full flex-auto",Or=s.k$1(({label:e,...r},t)=>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",...r,ref:t,children:s.o("p",{class:"text-center text-base",children:e})})),_s=({input:e,onSubmitSuccess:r})=>{const t=Tt();return s.o("form",{noValidate:!0,class:"",onSubmit:n=>{n.preventDefault();const a=s.getFormSubmitter(n).value,i=ls(xs,a);r({type:"boolean",value:i==="true"})},children:[s.o("ul",{class:Rr,children:Nr.map((n,a)=>s.o("li",{class:Dr,children:s.o(Or,{ref:a===0?t:null,type:"submit",name:ws,value:n,label:e.config.labels[n]},n)}))}),e.config.optional&&s.o("div",{class:"px-2 pb-2",children:s.o(ge,{class:"relative w-full",type:"button",onClick:()=>r(null)})})]})},Gt=e=>e.reduce((r,t)=>r+t.sizeKb,0),ks=s.isSubmissionOfType("file"),Jt=3,lt=e=>{const r=e.lastIndexOf(".");return r===-1?[e,""]:[e.slice(0,r),e.slice(r)]},Cs=({file:e,class:r,...t})=>{const{t:n}=s.useTranslation(),[a,i]=lt(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",r),...t,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:i})]}),s.o("p",{class:"text-accent-11",children:[s.o("span",{class:"sr-only",children:[n("file_size"),": "]}),s.le(e.sizeKb)]})]})},Zt=({class:e,...r})=>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),...r}),Ss=(e,r)=>{const[t,n]=lt(e);return`${t.slice(0,r)}${n}`},Xt=e=>({name:Ss(e.name,42),sizeKb:e.size/1e3}),Is=[".heic",".heif",".jpg",".jpeg",".png",".gif",".webp",".txt",".rtf",".odt",".pages",".zip"],As=(e,r,t)=>{const n=lt(r.name)[1].toLowerCase(),a=[...t.map(o=>o.toLowerCase()),...Is],i=n===""?"none":a.includes(n)?n:"other";return`chatbot-file-refused:${e}:${i}`},Es=({input:e,onSubmitSuccess:r,analytics:t})=>{var C;const n=(C=s.store.current$.value.flow)==null?void 0:C.data.submissions[e.key],[a,i]=s.h(ks(n)&&n.value.length?{status:"ready",files:n.value}:{status:"empty"}),o=s._(0),l=a.status==="ready"?a.files:[],c=a.status==="ready"||a.status==="pending"?a.files:[],d=a.status==="error"?a.error:void 0,g=c.length-Jt,b=Gt(c),p=Tt(),{t:m}=s.useTranslation(),_=I=>{if(!I.length)return{reason:"required",error:{type:"required",message:m("validation_file")}};if(!s.ce(I,e.config.extensions))return{reason:"type",file:I.find(v=>!s.ce([v],e.config.extensions)),error:{type:"validate",message:m("validation_file_ext",{ext:e.config.extensions.join(", ")})}};if(I.some(v=>v.sizeKb===0))return{reason:"empty",file:I.find(v=>v.sizeKb===0),error:{type:"validate",message:m("validation_file_empty")}};if(e.config.fileSizeLimitKib&&Gt(I)>e.config.fileSizeLimitKib)return{reason:"size",error:{type:"max",message:m("validation_file_size",{size:s.le(e.config.fileSizeLimitKib)})}};if(!e.config.allowMultiple&&I.length>1)return{reason:"count",error:{type:"invalid",message:m("validation_file_max",{count:1})}}},k=(I,v)=>{var T,V;return t.log({event:"INTERACTION",properties:{tag:As(I,v,e.config.extensions)},customProperties:(V=(T=s.store.current$.peek().flow)==null?void 0:T.analytics)==null?void 0:V.customProperties})};return s.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:I=>{if(I.preventDefault(),a.status==="pending"||a.status==="error")return;const v=_(l);v?i({status:"error",error:v.error}):r({type:"file",value:l})},children:[s.o("div",{class:"flex items-center gap-2",children:[s.o("label",{ref:p,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,Jt).map(I=>{const[v,T]=lt(I.name);return s.o(Zt,{class:"flex overflow-hidden",children:[s.o("span",{class:"block truncate",children:v}),s.o("span",{children:T})]})}),g>0?s.o(Zt,{children:m("file_more",{count:g})}):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:m("upload_file",{count:e.config.allowMultiple?2:1})}),e.config.fileSizeLimitKib?s.o("p",{class:"text-neutral-11 text-xs",children:["(",m("file_max_size",{size:s.le(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:m("file_extensions")}),s.o("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(I=>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:I.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"}),m("file_preparing",{count:c.length})]}):a.status==="ready"?s.o(s.k,{children:[l.length>1?m("file_total_size",{size:s.le(b)}):s.le(b),s.o("span",{class:"sr-only",children:[". ",m("file_ready",{count:l.length})]})]}):null}),s.o("input",{id:"dropzone-file","aria-label":m("upload_file",{count:e.config.allowMultiple?2:1}),onInput:async I=>{s.invariant(I.target instanceof HTMLInputElement);const v=I.target.files?Array.from(I.target.files):[];I.target.value="";const[T]=v;if(!T)return;const V=++o.current,M=a.status==="ready",Q=v.map(Xt),N=_(Q);if(N)return k(N.reason,N.file??T),i({status:"error",error:N.error});i({status:"pending",files:Q});let K;try{const D=await Promise.all(v.map(async R=>{try{return{...Xt(R),data:await s.Fe(R)}}catch(B){throw K??(K=R),B}}));o.current===V&&i({status:"ready",files:D})}catch{if(o.current!==V)return;k("unreadable",K??T),i({status:"error",error:{type:"invalid",message:m(M?"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(Fe,{disabled:l.length===0}),e.config.optional&&s.o(ge,{class:"relative",onClick:()=>r(null)})]})]}),s.o(Ue,{error:d})]})};var et=e=>e.type==="checkbox",Ee=e=>e instanceof Date,se=e=>e==null;const Br=e=>typeof e=="object";var J=e=>!se(e)&&!Array.isArray(e)&&Br(e)&&!Ee(e),Fs=e=>J(e)&&e.target?et(e.target)?e.target.checked:e.target.value:e,Vs=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Ms=(e,r)=>e.has(Vs(r)),Ls=e=>{const r=e.constructor&&e.constructor.prototype;return J(r)&&r.hasOwnProperty("isPrototypeOf")},Nt=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Y(e){if(e instanceof Date)return new Date(e);const r=typeof FileList<"u"&&e instanceof FileList;if(Nt&&(e instanceof Blob||r))return e;const t=Array.isArray(e);if(!t&&!(J(e)&&Ls(e)))return e;const n=t?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=Y(e[a]));return n}var ct=e=>/^\w*$/.test(e),W=e=>e===void 0,Rt=e=>Array.isArray(e)?e.filter(Boolean):[],Dt=e=>Rt(e.replace(/["|']|\]/g,"").split(/\.|\[/)),S=(e,r,t)=>{if(!r||!J(e))return t;const n=(ct(r)?[r]:Dt(r)).reduce((a,i)=>se(a)?a:a[i],e);return W(n)||n===e?W(e[r])?t:e[r]:n},de=e=>typeof e=="boolean",oe=e=>typeof e=="function",z=(e,r,t)=>{let n=-1;const a=ct(r)?[r]:Dt(r),i=a.length,o=i-1;for(;++n<i;){const l=a[n];let c=t;if(n!==o){const d=e[l];c=J(d)||Array.isArray(d)?d:isNaN(+a[n+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const Yt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},le={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ye={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Ts=s.Cn.createContext(null);Ts.displayName="HookFormControlContext";var Ns=(e,r,t,n=!0)=>{const a={defaultValues:r._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return r._proxyFormState[o]!==le.all&&(r._proxyFormState[o]=!n||le.all),t&&(t[o]=!0),e[o]}});return a};const Rs=typeof window<"u"?s.Cn.useLayoutEffect:s.Cn.useEffect;var ie=e=>typeof e=="string",Ds=(e,r,t,n,a)=>ie(e)?(n&&r.watch.add(e),S(t,e,a)):Array.isArray(e)?e.map(i=>(n&&r.watch.add(i),S(t,i))):(n&&(r.watchAll=!0),t),It=e=>se(e)||!Br(e);function ke(e,r,t=new WeakSet){if(It(e)||It(r))return Object.is(e,r);if(Ee(e)&&Ee(r))return Object.is(e.getTime(),r.getTime());const n=Object.keys(e),a=Object.keys(r);if(n.length!==a.length)return!1;if(t.has(e)||t.has(r))return!0;t.add(e),t.add(r);for(const i of n){const o=e[i];if(!a.includes(i))return!1;if(i!=="ref"){const l=r[i];if(Ee(o)&&Ee(l)||J(o)&&J(l)||Array.isArray(o)&&Array.isArray(l)?!ke(o,l,t):!Object.is(o,l))return!1}}return!0}const Os=s.Cn.createContext(null);Os.displayName="HookFormContext";var jr=(e,r,t,n,a)=>r?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[n]:a||!0}}:{},Ye=e=>Array.isArray(e)?e:[e],Qt=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function $r(e,r){const t={};for(const n in e)if(e.hasOwnProperty(n)){const a=e[n],i=r[n];if(a&&J(a)&&i){const o=$r(a,i);J(o)&&(t[n]=o)}else e[n]&&(t[n]=i)}return t}var ne=e=>J(e)&&!Object.keys(e).length,Ot=e=>e.type==="file",at=e=>{if(!Nt)return!1;const r=e?e.ownerDocument:0;return e instanceof(r&&r.defaultView?r.defaultView.HTMLElement:HTMLElement)},Pr=e=>e.type==="select-multiple",Bt=e=>e.type==="radio",Bs=e=>Bt(e)||et(e),wt=e=>at(e)&&e.isConnected;function js(e,r){const t=r.slice(0,-1).length;let n=0;for(;n<t;)e=W(e)?n++:e[r[n++]];return e}function $s(e){for(const r in e)if(e.hasOwnProperty(r)&&!W(e[r]))return!1;return!0}function G(e,r){const t=Array.isArray(r)?r:ct(r)?[r]:Dt(r),n=t.length===1?e:js(e,t),a=t.length-1,i=t[a];return n&&delete n[i],a!==0&&(J(n)&&ne(n)||Array.isArray(n)&&$s(n))&&G(e,t.slice(0,-1)),e}var Ps=e=>{for(const r in e)if(oe(e[r]))return!0;return!1};function qr(e){return Array.isArray(e)||J(e)&&!Ps(e)}function At(e,r={}){for(const t in e){const n=e[t];qr(n)?(r[t]=Array.isArray(n)?[]:{},At(n,r[t])):W(n)||(r[t]=!0)}return r}function Be(e,r,t){t||(t=At(r));for(const n in e){const a=e[n];if(qr(a))W(r)||It(t[n])?t[n]=At(a,Array.isArray(a)?[]:{}):Be(a,se(r)?{}:r[n],t[n]);else{const i=r[n];t[n]=!ke(a,i)}}return t}const er={value:!1,isValid:!1},tr={value:!0,isValid:!0};var Ur=e=>{if(Array.isArray(e)){if(e.length>1){const r=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:r,isValid:!!r.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!W(e[0].attributes.value)?W(e[0].value)||e[0].value===""?tr:{value:e[0].value,isValid:!0}:tr:er}return er},zr=(e,{valueAsNumber:r,valueAsDate:t,setValueAs:n})=>W(e)?e:r?e===""?NaN:e&&+e:t&&ie(e)?new Date(e):n?n(e):e;const rr={isValid:!1,value:null};var Hr=e=>Array.isArray(e)?e.reduce((r,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:r,rr):rr;function nr(e){const r=e.ref;return Ot(r)?r.files:Bt(r)?Hr(e.refs).value:Pr(r)?[...r.selectedOptions].map(({value:t})=>t):et(r)?Ur(e.refs).value:zr(W(r.value)?e.ref.value:r.value,e)}var qs=(e,r,t,n)=>{const a={};for(const i of e){const o=S(r,i);o&&z(a,i,o._f)}return{criteriaMode:t,names:[...e],fields:a,shouldUseNativeValidation:n}},it=e=>e instanceof RegExp,Ge=e=>W(e)?e:it(e)?e.source:J(e)?it(e.value)?e.value.source:e.value:e,sr=e=>({isOnSubmit:!e||e===le.onSubmit,isOnBlur:e===le.onBlur,isOnChange:e===le.onChange,isOnAll:e===le.all,isOnTouch:e===le.onTouched});const ar="AsyncFunction";var Us=e=>!!e&&!!e.validate&&!!(oe(e.validate)&&e.validate.constructor.name===ar||J(e.validate)&&Object.values(e.validate).find(r=>r.constructor.name===ar)),zs=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),ir=(e,r,t)=>!t&&(r.watchAll||r.watch.has(e)||[...r.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Qe=(e,r,t,n)=>{for(const a of t||Object.keys(e)){const i=S(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&r(o.refs[0],a)&&!n)return!0;if(o.ref&&r(o.ref,o.name)&&!n)return!0;if(Qe(l,r))break}else if(J(l)&&Qe(l,r))break}}};function or(e,r,t){const n=S(e,t);if(n||ct(t))return{error:n,name:t};const a=t.split(".");for(;a.length;){const i=a.join("."),o=S(r,i),l=S(e,i);if(o&&!Array.isArray(o)&&t!==i)return{name:t};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:t}}var Hs=(e,r,t,n)=>{t(e);const{name:a,...i}=e;return ne(i)||Object.keys(i).length>=Object.keys(r).length||Object.keys(i).find(o=>r[o]===(!n||le.all))},Ws=(e,r,t)=>!e||!r||e===r||Ye(e).some(n=>n&&(t?n===r:n.startsWith(r)||r.startsWith(n))),Ks=(e,r,t,n,a)=>a.isOnAll?!1:!t&&a.isOnTouch?!(r||e):(t?n.isOnBlur:a.isOnBlur)?!e:(t?n.isOnChange:a.isOnChange)?e:!0,Gs=(e,r)=>!Rt(S(e,r)).length&&G(e,r),Js=(e,r,t)=>{const n=Ye(S(e,t));return z(n,"root",r[t]),z(e,t,n),e};function lr(e,r,t="validate"){if(ie(e)||Array.isArray(e)&&e.every(ie)||de(e)&&!e)return{type:t,message:ie(e)?e:"",ref:r}}var Oe=e=>J(e)&&!it(e)?e:{value:e,message:""},cr=async(e,r,t,n,a,i)=>{const{ref:o,refs:l,required:c,maxLength:d,minLength:g,min:b,max:p,pattern:m,validate:_,name:k,valueAsNumber:C,mount:I}=e._f,v=S(t,k);if(!I||r.has(k))return{};const T=l?l[0]:o,V=E=>{a&&T.reportValidity&&(T.setCustomValidity(de(E)?"":E||""),T.reportValidity())},M={},Q=Bt(o),N=et(o),K=Q||N,D=(C||Ot(o))&&W(o.value)&&W(v)||at(o)&&o.value===""||v===""||Array.isArray(v)&&!v.length,R=jr.bind(null,k,n,M),B=(E,F,$,L=ye.maxLength,U=ye.minLength)=>{const q=E?F:$;M[k]={type:E?L:U,message:q,ref:o,...R(E?L:U,q)}};if(i?!Array.isArray(v)||!v.length:c&&(!K&&(D||se(v))||de(v)&&!v||N&&!Ur(l).isValid||Q&&!Hr(l).isValid)){const{value:E,message:F}=ie(c)?{value:!!c,message:c}:Oe(c);if(E&&(M[k]={type:ye.required,message:F,ref:T,...R(ye.required,F)},!n))return V(F),M}if(!D&&(!se(b)||!se(p))){let E,F;const $=Oe(p),L=Oe(b);if(!se(v)&&!isNaN(v)){const U=o.valueAsNumber||v&&+v;se($.value)||(E=U>$.value),se(L.value)||(F=U<L.value)}else{const U=o.valueAsDate||new Date(v),q=H=>new Date(new Date().toDateString()+" "+H),ee=o.type=="time",Z=o.type=="week";ie($.value)&&v&&(E=ee?q(v)>q($.value):Z?v>$.value:U>new Date($.value)),ie(L.value)&&v&&(F=ee?q(v)<q(L.value):Z?v<L.value:U<new Date(L.value))}if((E||F)&&(B(!!E,$.message,L.message,ye.max,ye.min),!n))return V(M[k].message),M}if((d||g)&&!D&&(ie(v)||i&&Array.isArray(v))){const E=Oe(d),F=Oe(g),$=!se(E.value)&&v.length>+E.value,L=!se(F.value)&&v.length<+F.value;if(($||L)&&(B($,E.message,F.message),!n))return V(M[k].message),M}if(m&&!D&&ie(v)){const{value:E,message:F}=Oe(m);if(it(E)&&!v.match(E)&&(M[k]={type:ye.pattern,message:F,ref:o,...R(ye.pattern,F)},!n))return V(F),M}if(_){if(oe(_)){const E=await _(v,t),F=lr(E,T);if(F&&(M[k]={...F,...R(ye.validate,F.message)},!n))return V(F.message),M}else if(J(_)){let E={};for(const F in _){if(!ne(E)&&!n)break;const $=lr(await _[F](v,t),T,F);$&&(E={...$,...R(F,$.message)},V($.message),n&&(M[k]=E))}if(!ne(E)&&(M[k]={ref:T,...E},!n))return M}}return V(!0),M};const Zs={mode:le.onSubmit,reValidateMode:le.onChange,shouldFocusError:!0};function Xs(e={}){let r={...Zs,...e},t={submitCount:0,isDirty:!1,isReady:!1,isLoading:oe(r.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:r.errors||{},disabled:r.disabled||!1},n={},a=J(r.defaultValues)||J(r.values)?Y(r.defaultValues||r.values)||{}:{},i=r.shouldUnregister?{}:Y(a),o={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,d=0;const g={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},b={...g};let p={...b};const m={array:Qt(),state:Qt()},_=r.criteriaMode===le.all,k=u=>f=>{clearTimeout(d),d=setTimeout(u,f)},C=async u=>{if(!o.keepIsValid&&!r.disabled&&(b.isValid||p.isValid||u)){let f;r.resolver?(f=ne((await K()).errors),I()):f=await R(n,!0),f!==t.isValid&&m.state.next({isValid:f})}},I=(u,f)=>{!r.disabled&&(b.isValidating||b.validatingFields||p.isValidating||p.validatingFields)&&((u||Array.from(l.mount)).forEach(h=>{h&&(f?z(t.validatingFields,h,f):G(t.validatingFields,h))}),m.state.next({validatingFields:t.validatingFields,isValidating:!ne(t.validatingFields)}))},v=(u,f=[],h,w,y=!0,x=!0)=>{if(w&&h&&!r.disabled){if(o.action=!0,x&&Array.isArray(S(n,u))){const A=h(S(n,u),w.argA,w.argB);y&&z(n,u,A)}if(x&&Array.isArray(S(t.errors,u))){const A=h(S(t.errors,u),w.argA,w.argB);y&&z(t.errors,u,A),Gs(t.errors,u)}if((b.touchedFields||p.touchedFields)&&x&&Array.isArray(S(t.touchedFields,u))){const A=h(S(t.touchedFields,u),w.argA,w.argB);y&&z(t.touchedFields,u,A)}(b.dirtyFields||p.dirtyFields)&&(t.dirtyFields=Be(a,i)),m.state.next({name:u,isDirty:E(u,f),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else z(i,u,f)},T=(u,f)=>{z(t.errors,u,f),m.state.next({errors:t.errors})},V=u=>{t.errors=u,m.state.next({errors:t.errors,isValid:!1})},M=(u,f,h,w)=>{const y=S(n,u);if(y){const x=S(i,u,W(h)?S(a,u):h);W(x)||w&&w.defaultChecked||f?z(i,u,f?x:nr(y._f)):L(u,x),o.mount&&!o.action&&C()}},Q=(u,f,h,w,y)=>{let x=!1,A=!1;const j={name:u};if(!r.disabled){if(!h||w){(b.isDirty||p.isDirty)&&(A=t.isDirty,t.isDirty=j.isDirty=E(),x=A!==j.isDirty);const P=ke(S(a,u),f);A=!!S(t.dirtyFields,u),P?G(t.dirtyFields,u):z(t.dirtyFields,u,!0),j.dirtyFields=t.dirtyFields,x=x||(b.dirtyFields||p.dirtyFields)&&A!==!P}if(h){const P=S(t.touchedFields,u);P||(z(t.touchedFields,u,h),j.touchedFields=t.touchedFields,x=x||(b.touchedFields||p.touchedFields)&&P!==h)}x&&y&&m.state.next(j)}return x?j:{}},N=(u,f,h,w)=>{const y=S(t.errors,u),x=(b.isValid||p.isValid)&&de(f)&&t.isValid!==f;if(r.delayError&&h?(c=k(()=>T(u,h)),c(r.delayError)):(clearTimeout(d),c=null,h?z(t.errors,u,h):G(t.errors,u)),(h?!ke(y,h):y)||!ne(w)||x){const A={...w,...x&&de(f)?{isValid:f}:{},errors:t.errors,name:u};t={...t,...A},m.state.next(A)}},K=async u=>(I(u,!0),await r.resolver(i,r.context,qs(u||l.mount,n,r.criteriaMode,r.shouldUseNativeValidation))),D=async u=>{const{errors:f}=await K(u);if(I(u),u)for(const h of u){const w=S(f,h);w?z(t.errors,h,w):G(t.errors,h)}else t.errors=f;return f},R=async(u,f,h={valid:!0})=>{for(const w in u){const y=u[w];if(y){const{_f:x,...A}=y;if(x){const j=l.array.has(x.name),P=y._f&&Us(y._f);P&&b.validatingFields&&I([x.name],!0);const re=await cr(y,l.disabled,i,_,r.shouldUseNativeValidation&&!f,j);if(P&&b.validatingFields&&I([x.name]),re[x.name]&&(h.valid=!1,f||e.shouldUseNativeValidation))break;!f&&(S(re,x.name)?j?Js(t.errors,re,x.name):z(t.errors,x.name,re[x.name]):G(t.errors,x.name))}!ne(A)&&await R(A,f,h)}}return h.valid},B=()=>{for(const u of l.unMount){const f=S(n,u);f&&(f._f.refs?f._f.refs.every(h=>!wt(h)):!wt(f._f.ref))&&Te(u)}l.unMount=new Set},E=(u,f)=>!r.disabled&&(u&&f&&z(i,u,f),!ke(ze(),a)),F=(u,f,h)=>Ds(u,l,{...o.mount?i:W(f)?a:ie(u)?{[u]:f}:f},h,f),$=u=>Rt(S(o.mount?i:a,u,r.shouldUnregister?S(a,u,[]):[])),L=(u,f,h={})=>{const w=S(n,u);let y=f;if(w){const x=w._f;x&&(!x.disabled&&z(i,u,zr(f,x)),y=at(x.ref)&&se(f)?"":f,Pr(x.ref)?[...x.ref.options].forEach(A=>A.selected=y.includes(A.value)):x.refs?et(x.ref)?x.refs.forEach(A=>{(!A.defaultChecked||!A.disabled)&&(Array.isArray(y)?A.checked=!!y.find(j=>j===A.value):A.checked=y===A.value||!!y)}):x.refs.forEach(A=>A.checked=A.value===y):Ot(x.ref)?x.ref.value="":(x.ref.value=y,x.ref.type||m.state.next({name:u,values:Y(i)})))}(h.shouldDirty||h.shouldTouch)&&Q(u,y,h.shouldTouch,h.shouldDirty,!0),h.shouldValidate&&H(u)},U=(u,f,h)=>{for(const w in f){if(!f.hasOwnProperty(w))return;const y=f[w],x=u+"."+w,A=S(n,x);(l.array.has(u)||J(y)||A&&!A._f)&&!Ee(y)?U(x,y,h):L(x,y,h)}},q=(u,f,h={})=>{const w=S(n,u),y=l.array.has(u),x=Y(f);z(i,u,x),y?(m.array.next({name:u,values:Y(i)}),(b.isDirty||b.dirtyFields||p.isDirty||p.dirtyFields)&&h.shouldDirty&&m.state.next({name:u,dirtyFields:Be(a,i),isDirty:E(u,x)})):w&&!w._f&&!se(x)?U(u,x,h):L(u,x,h),ir(u,l)?m.state.next({...t,name:u,values:Y(i)}):m.state.next({name:o.mount?u:void 0,values:Y(i)})},ee=async u=>{o.mount=!0;const f=u.target;let h=f.name,w=!0;const y=S(n,h),x=P=>{w=Number.isNaN(P)||Ee(P)&&isNaN(P.getTime())||ke(P,S(i,h,P))},A=sr(r.mode),j=sr(r.reValidateMode);if(y){let P,re;const Ae=f.type?nr(y._f):Fs(u),xe=u.type===Yt.BLUR||u.type===Yt.FOCUS_OUT,Kr=!zs(y._f)&&!r.resolver&&!S(t.errors,h)&&!y._f.deps||Ks(xe,S(t.touchedFields,h),t.isSubmitted,j,A),ht=ir(h,l,xe);z(i,h,Ae),xe?(!f||!f.readOnly)&&(y._f.onBlur&&y._f.onBlur(u),c&&c(0)):y._f.onChange&&y._f.onChange(u);const pt=Q(h,Ae,xe),Gr=!ne(pt)||ht;if(!xe&&m.state.next({name:h,type:u.type,values:Y(i)}),Kr)return(b.isValid||p.isValid)&&(r.mode==="onBlur"?xe&&C():xe||C()),Gr&&m.state.next({name:h,...ht?{}:pt});if(!xe&&ht&&m.state.next({...t}),r.resolver){const{errors:jt}=await K([h]);if(I([h]),x(Ae),w){const Jr=or(t.errors,n,h),$t=or(jt,n,Jr.name||h);P=$t.error,h=$t.name,re=ne(jt)}}else I([h],!0),P=(await cr(y,l.disabled,i,_,r.shouldUseNativeValidation))[h],I([h]),x(Ae),w&&(P?re=!1:(b.isValid||p.isValid)&&(re=await R(n,!0)));w&&(y._f.deps&&(!Array.isArray(y._f.deps)||y._f.deps.length>0)&&H(y._f.deps),N(h,re,P,pt))}},Z=(u,f)=>{if(S(t.errors,f)&&u.focus)return u.focus(),1},H=async(u,f={})=>{let h,w;const y=Ye(u);if(r.resolver){const x=await D(W(u)?u:y);h=ne(x),w=u?!y.some(A=>S(x,A)):h}else u?(w=(await Promise.all(y.map(async x=>{const A=S(n,x);return await R(A&&A._f?{[x]:A}:A)}))).every(Boolean),!(!w&&!t.isValid)&&C()):w=h=await R(n);return m.state.next({...!ie(u)||(b.isValid||p.isValid)&&h!==t.isValid?{}:{name:u},...r.resolver||!u?{isValid:h}:{},errors:t.errors}),f.shouldFocus&&!w&&Qe(n,Z,u?y:l.mount),w},ze=(u,f)=>{let h={...o.mount?i:a};return f&&(h=$r(f.dirtyFields?t.dirtyFields:t.touchedFields,h)),W(u)?h:ie(u)?S(h,u):u.map(w=>S(h,w))},Ve=(u,f)=>({invalid:!!S((f||t).errors,u),isDirty:!!S((f||t).dirtyFields,u),error:S((f||t).errors,u),isValidating:!!S(t.validatingFields,u),isTouched:!!S((f||t).touchedFields,u)}),O=u=>{const f=u?Ye(u):void 0;f==null||f.forEach(h=>G(t.errors,h)),f?f.forEach(h=>{m.state.next({name:h,errors:t.errors})}):m.state.next({errors:{}})},Me=(u,f,h)=>{const w=(S(n,u,{_f:{}})._f||{}).ref,y=S(t.errors,u)||{},{ref:x,message:A,type:j,...P}=y;z(t.errors,u,{...P,...f,ref:w}),m.state.next({name:u,errors:t.errors,isValid:!1}),h&&h.shouldFocus&&w&&w.focus&&w.focus()},Le=(u,f)=>oe(u)?m.state.subscribe({next:h=>"values"in h&&u(F(void 0,f),h)}):F(u,f,!0),ve=u=>m.state.subscribe({next:f=>{Ws(u.name,f.name,u.exact)&&Hs(f,u.formState||b,nt,u.reRenderRoot)&&u.callback({values:{...i},...t,...f,defaultValues:a})}}).unsubscribe,Se=u=>(o.mount=!0,p={...p,...u.formState},ve({...u,formState:{...g,...u.formState}})),Te=(u,f={})=>{for(const h of u?Ye(u):l.mount)l.mount.delete(h),l.array.delete(h),f.keepValue||(G(n,h),G(i,h)),!f.keepError&&G(t.errors,h),!f.keepDirty&&G(t.dirtyFields,h),!f.keepTouched&&G(t.touchedFields,h),!f.keepIsValidating&&G(t.validatingFields,h),!r.shouldUnregister&&!f.keepDefaultValue&&G(a,h);m.state.next({values:Y(i)}),m.state.next({...t,...f.keepDirty?{isDirty:E()}:{}}),!f.keepIsValid&&C()},He=({disabled:u,name:f})=>{if(de(u)&&o.mount||u||l.disabled.has(f)){const y=l.disabled.has(f)!==!!u;u?l.disabled.add(f):l.disabled.delete(f),y&&o.mount&&!o.action&&C()}},he=(u,f={})=>{let h=S(n,u);const w=de(f.disabled)||de(r.disabled);return z(n,u,{...h||{},_f:{...h&&h._f?h._f:{ref:{name:u}},name:u,mount:!0,...f}}),l.mount.add(u),h?He({disabled:de(f.disabled)?f.disabled:r.disabled,name:u}):M(u,!0,f.value),{...w?{disabled:f.disabled||r.disabled}:{},...r.progressive?{required:!!f.required,min:Ge(f.min),max:Ge(f.max),minLength:Ge(f.minLength),maxLength:Ge(f.maxLength),pattern:Ge(f.pattern)}:{},name:u,onChange:ee,onBlur:ee,ref:y=>{if(y){he(u,f),h=S(n,u);const x=W(y.value)&&y.querySelectorAll&&y.querySelectorAll("input,select,textarea")[0]||y,A=Bs(x),j=h._f.refs||[];if(A?j.find(P=>P===x):x===h._f.ref)return;z(n,u,{_f:{...h._f,...A?{refs:[...j.filter(wt),x,...Array.isArray(S(a,u))?[{}]:[]],ref:{type:x.type,name:u}}:{ref:x}}}),M(u,!1,void 0,x)}else h=S(n,u,{}),h._f&&(h._f.mount=!1),(r.shouldUnregister||f.shouldUnregister)&&!(Ms(l.array,u)&&o.action)&&l.unMount.add(u)}}},Ne=()=>r.shouldFocusError&&Qe(n,Z,l.mount),tt=u=>{de(u)&&(m.state.next({disabled:u}),Qe(n,(f,h)=>{const w=S(n,h);w&&(f.disabled=w._f.disabled||u,Array.isArray(w._f.refs)&&w._f.refs.forEach(y=>{y.disabled=w._f.disabled||u}))},0,!1))},Re=(u,f)=>async h=>{let w;h&&(h.preventDefault&&h.preventDefault(),h.persist&&h.persist());let y=Y(i);if(m.state.next({isSubmitting:!0}),r.resolver){const{errors:x,values:A}=await K();I(),t.errors=x,y=Y(A)}else await R(n);if(l.disabled.size)for(const x of l.disabled)G(y,x);if(G(t.errors,"root"),ne(t.errors)){m.state.next({errors:{}});try{await u(y,h)}catch(x){w=x}}else f&&await f({...t.errors},h),Ne(),setTimeout(Ne);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ne(t.errors)&&!w,submitCount:t.submitCount+1,errors:t.errors}),w)throw w},De=(u,f={})=>{S(n,u)&&(W(f.defaultValue)?q(u,Y(S(a,u))):(q(u,f.defaultValue),z(a,u,Y(f.defaultValue))),f.keepTouched||G(t.touchedFields,u),f.keepDirty||(G(t.dirtyFields,u),t.isDirty=f.defaultValue?E(u,Y(S(a,u))):E()),f.keepError||(G(t.errors,u),b.isValid&&C()),m.state.next({...t}))},Ie=(u,f={})=>{const h=u?Y(u):a,w=Y(h),y=ne(u),x=y?a:w;if(f.keepDefaultValues||(a=h),!f.keepValues){if(f.keepDirtyValues){const A=new Set([...l.mount,...Object.keys(Be(a,i))]);for(const j of Array.from(A)){const P=S(t.dirtyFields,j),re=S(i,j),Ae=S(x,j);P&&!W(re)?z(x,j,re):!P&&!W(Ae)&&q(j,Ae)}}else{if(Nt&&W(u))for(const A of l.mount){const j=S(n,A);if(j&&j._f){const P=Array.isArray(j._f.refs)?j._f.refs[0]:j._f.ref;if(at(P)){const re=P.closest("form");if(re){re.reset();break}}}}if(f.keepFieldsRef)for(const A of l.mount)q(A,S(x,A));else n={}}i=r.shouldUnregister?f.keepDefaultValues?Y(a):{}:Y(x),m.array.next({values:{...x}}),m.state.next({values:{...x}})}l={mount:f.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!b.isValid||!!f.keepIsValid||!!f.keepDirtyValues||!r.shouldUnregister&&!ne(x),o.watch=!!r.shouldUnregister,o.keepIsValid=!!f.keepIsValid,o.action=!1,f.keepErrors||(t.errors={}),m.state.next({submitCount:f.keepSubmitCount?t.submitCount:0,isDirty:y?!1:f.keepDirty?t.isDirty:!!(f.keepDefaultValues&&!ke(u,a)),isSubmitted:f.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:y?{}:f.keepDirtyValues?f.keepDefaultValues&&i?Be(a,i):t.dirtyFields:f.keepDefaultValues&&u?Be(a,u):f.keepDirty?t.dirtyFields:{},touchedFields:f.keepTouched?t.touchedFields:{},errors:f.keepErrors?t.errors:{},isSubmitSuccessful:f.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},We=(u,f)=>Ie(oe(u)?u(i):u,{...r.resetOptions,...f}),rt=(u,f={})=>{const h=S(n,u),w=h&&h._f;if(w){const y=w.refs?w.refs[0]:w.ref;y.focus&&setTimeout(()=>{y.focus(),f.shouldSelect&&oe(y.select)&&y.select()})}},nt=u=>{t={...t,...u}},Ke={control:{register:he,unregister:Te,getFieldState:Ve,handleSubmit:Re,setError:Me,_subscribe:ve,_runSchema:K,_updateIsValidating:I,_focusError:Ne,_getWatch:F,_getDirty:E,_setValid:C,_setFieldArray:v,_setDisabledField:He,_setErrors:V,_getFieldArray:$,_reset:Ie,_resetDefaultValues:()=>oe(r.defaultValues)&&r.defaultValues().then(u=>{We(u,r.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:B,_disableForm:tt,_subjects:m,_proxyFormState:b,get _fields(){return n},get _formValues(){return i},get _state(){return o},set _state(u){o=u},get _defaultValues(){return a},get _names(){return l},set _names(u){l=u},get _formState(){return t},get _options(){return r},set _options(u){r={...r,...u}}},subscribe:Se,trigger:H,register:he,handleSubmit:Re,watch:Le,setValue:q,getValues:ze,reset:We,resetField:De,clearErrors:O,unregister:Te,setError:Me,setFocus:rt,getFieldState:Ve};return{...Ke,formControl:Ke}}function ut(e={}){const r=s.Cn.useRef(void 0),t=s.Cn.useRef(void 0),[n,a]=s.Cn.useState({isDirty:!1,isValidating:!1,isLoading:oe(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:oe(e.defaultValues)?void 0:e.defaultValues});if(!r.current)if(e.formControl)r.current={...e.formControl,formState:n},e.defaultValues&&!oe(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:o,...l}=Xs(e);r.current={...l,formState:n}}const i=r.current.control;return i._options=e,Rs(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState}),reRenderRoot:!0});return a(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),s.Cn.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),s.Cn.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),s.Cn.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),s.Cn.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),s.Cn.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==n.isDirty&&i._subjects.state.next({isDirty:o})}},[i,n.isDirty]),s.Cn.useEffect(()=>{var o;e.values&&!ke(e.values,t.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),t.current=e.values,a(l=>({...l}))):i._resetDefaultValues()},[i,e.values]),s.Cn.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),r.current.formState=s.Cn.useMemo(()=>Ns(n,i),[i,n]),r.current}const ur=(e,r,t)=>{if(e&&"reportValidity"in e){const n=S(t,r);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},Ys=(e,r)=>{for(const t in r.fields){const n=r.fields[t];n&&n.ref&&"reportValidity"in n.ref?ur(n.ref,t,e):n.refs&&n.refs.forEach(a=>ur(a,t,e))}},Qs=(e,r)=>{r.shouldUseNativeValidation&&Ys(e,r);const t={};for(const n in e){const a=S(r.fields,n),i=Object.assign(e[n]||{},{ref:a&&a.ref});if(ea(r.names||Object.keys(e),n)){const o=Object.assign({},S(t,n));z(o,"root",i),z(t,n,o)}else z(t,n,i)}return t},ea=(e,r)=>e.some(t=>t.startsWith(r+"."));var dt=function(e,r,t){return t===void 0&&(t={}),function(n,a,i){try{var o=!i.shouldUseNativeValidation&&i.criteriaMode==="all";return Promise.resolve(ds(e,n,Object.assign({},r,{abortPipeEarly:!o}))).then(function(l){if(l.issues){for(var c={};l.issues.length;){var d=l.issues[0],g=ss(d);if(g&&(c[g]||(c[g]={message:d.message,type:d.type}),o)){var b=c[g].types,p=b&&b[d.type];c[g]=jr(g,o,c,d.type,p?[].concat(p,d.message):d.message)}l.issues.shift()}return{values:{},errors:Qs(c,i)}}return{values:t.raw?n:l.output,errors:{}}})}catch(l){return Promise.reject(l)}}};const dr=27,fr=12,hr=10,ta=s.isSubmissionOfType("enum"),ra=(e,r)=>{const t={min:e.minSelected??0,max:e.maxSelected??e.options.length};return dt(be({checked:Ce(Tr(ae(),Vr()),Mt(n=>Object.entries(n).filter(([a,i])=>i).map(([a,i])=>a)),Xe(t.max,r("validation_multiple_choice_max",{count:t.max})),$e(t.min,r("validation_multiple_choice_min",{count:t.min})))}))},na=s.k$1(({option:e,...r},t)=>s.o(s.k,{children:[s.o("input",{class:"peer sr-only h-full",type:"checkbox",...r,ref:t}),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:r.id,children:e.label})]})),pr=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:Rr}}}),sa=({input:e,onSubmitSuccess:r})=>{var g,b;const t=e.key?(g=s.store.current$.value.flow)==null?void 0:g.data.submissions[e.key]:void 0,n=e.config.maxSelected===1,a=n&&e.config.options.length===2,{t:i}=s.useTranslation(),{register:o,handleSubmit:l,formState:{errors:c}}=ut({defaultValues:{checked:n?{}:ta(t)?Object.fromEntries(t.value.map(p=>[p,!0])):{}},resolver:ra(e.config,i)}),d=Tt();return a?s.o(s.k,{children:[s.o("ul",{style:{maxHeight:6.5*dr+5*fr+2*hr},class:pr({variant:"booleanLike"}),children:e.config.options.map((p,m)=>s.o("li",{class:Dr,children:s.o(Or,{type:"submit",ref:_=>{_&&m===0&&(d.current=_)},label:p.label,value:"true",onClick:()=>r({type:"enum",value:[p.value]})})},p.value))}),e.config.minSelected===0&&s.o("div",{class:"px-2 pb-2",children:s.o(ge,{class:"relative w-full",type:"button",onClick:()=>r({type:"enum",value:[]})})})]}):s.o("form",{noValidate:!0,onSubmit:p=>l(m=>{const _=m.checked;r({type:"enum",value:_})})(p),children:[s.o("div",{class:"flex items-center gap-1",children:[s.o("ul",{style:{maxHeight:6.5*dr+5*fr+2*hr},class:pr({variant:e.config.options.length===1?"singleOption":void 0}),children:e.config.options.map((p,m)=>{const _=`checked.${p.value}`,{ref:k,...C}=o(_);return s.o("li",{class:"relative",children:s.o(na,{option:p,autoFocus:m===0,ref:I=>{I&&m===0&&(d.current=I),k(I)},id:_,...C,onClick:n?()=>r({type:"enum",value:[p.value]}):void 0})},p.value)})}),s.o("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[n?null:s.o(Fe,{}),e.config.minSelected===0&&s.o(ge,{class:"relative",type:"button",onClick:()=>r({type:"enum",value:[]})})]})]}),s.o("div",{class:"px-1",children:s.o(Ue,{error:(b=c.checked)==null?void 0:b.root})})]})},aa=s.isSubmissionOfType("number"),ia=(e,r)=>{const t=e.min??Number.MIN_SAFE_INTEGER,n=e.max??Number.MAX_SAFE_INTEGER,a=e.decimalCases??0;return dt(be({number:Ce(Mr(r("validation_number")),Ir(t,r("validation_number_min",{min:t})),Sr(n,r("validation_number_max",{max:n})),kr(i=>i===Number(i.toFixed(a)),r("validation_number_decimal_cases",{count:a})))}))},oa=({input:e,onSubmitSuccess:r})=>{var b;const t=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:i,handleSubmit:o,formState:{errors:l}}=ut({defaultValues:{number:aa(n)?n.value:t?Number(t):void 0},resolver:ia(e.config,a)}),{ref:c,...d}=i("number",{required:!e.config.optional,valueAsNumber:!0}),g=s._();return s.y(()=>{g.current&&(g.current.focus(),g.current.select())},[]),s.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:o(p=>{p.number!==void 0&&r({type:"number",value:p.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",{...d,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:p=>{p&&(g.current=p),c(p)},type:"text",min:e.config.min,max:e.config.max,class:qe({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(ge,{class:"absolute bottom-0 right-0.5 top-0",onClick:()=>r(null)})]}),s.o(Fe,{})]}),s.o(Ue,{error:l.number})]})},la="44",ca=/^[0-9 ]+$/,ua=s.isSubmissionOfType("string"),da=s.isSubmissionOfType("phone"),fa=e=>{const r=Ce(ae(e("validation_country_code")),Vt(ca,e("validation_country_code"))),t=Ce(ae(e("validation_phone")),$e(1,e("validation_phone")),Mt(n=>n.replace(/[^0-9]/g,"")));return dt(be({countryCode:r,phoneNumber:t}))},ha=({input:e,onSubmitSuccess:r})=>{var k;const t=e.key?(k=s.store.current$.value.flow)==null?void 0:k.data.submissions[e.key]:void 0,{t:n}=s.useTranslation(),[a,i]=s.h(),o=ua(t)?fs(t.value):da(t)?t.value:void 0,{register:l,handleSubmit:c,formState:{errors:d},watch:g}=ut({defaultValues:{countryCode:(o==null?void 0:o.countryCode)??e.config.defaultValue.countryCode??la,phoneNumber:(o==null?void 0:o.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:fa(n)}),{ref:b,...p}=l("phoneNumber",{required:!e.config.optional}),m=s._(),_=g("countryCode");return s.y(()=>{m.current&&(m.current.focus(),m.current.select())},[]),s.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:c(C=>{const I=C.phoneNumber.replace(/[^0-9]/g,""),v=C.countryCode.replace(/[^0-9]/g,"");i(void 0);const T=e.config.minChars??7,V=I.length+v.length;if(V<T)return i(n("validation_phone_min_chars",{count:T}));const M=e.config.maxChars;if(M!=null&&V>M)return i(n("validation_max_chars",{count:M}));e.config.submissionFormat==="phone"?r({type:"phone",value:{countryCode:v,phoneNumber:I}}):r({type:"string",value:_+C.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:["+",_]}),s.o("select",{...l("countryCode",{}),id:`isdk_phone_${e.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(Lt).map(([C,I])=>s.o("option",{value:I,children:[C," (+",I,")"]},C))})]}),s.o("input",{...p,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:C=>{C&&(m.current=C),b(C)},class:qe({optional:e.config.optional,className:"min-w-0 flex-1 rounded-r-full"}),placeholder:e.config.placeholder}),e.config.optional&&s.o(ge,{class:"absolute bottom-0 right-1 top-0",onClick:()=>r(null)})]}),s.o(Fe,{})]}),s.o(Ue,{error:d.countryCode||d.phoneNumber||{message:a}})]})},st=e=>e===void 0?0:Math.max(0,Math.ceil((e-Date.now())/1e3)),mr=(e,r,t,n)=>t!==void 0&&n*1e3>s.Z?e("submission_available_at",{time:s.be(t,r)}):e("submission_cooldown",{count:n}),pa=(e,r)=>{const t=e==null?void 0:e.trim();return t&&t!=="Submit"?t:r("submit")},ma=({input:e,onSubmitSuccess:r})=>{const{t,locale:n}=s.useTranslation(),{availableAt:a}=e.config,[i,o]=s.h(()=>st(a)),[l,c]=s.h("");s.p(()=>{const g=st(a);if(o(g),g===0)return;c(mr(t,n,a,g));const b=setInterval(()=>{const p=st(a);o(p),!(p>0)&&(clearInterval(b),c(t("submission_cooldown_ready")))},250);return()=>clearInterval(b)},[a,n,t]);const d=i>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":d,"aria-describedby":d?"submit-cooldown":void 0,onClick:()=>{st(a)>0||r(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:pa(e.config.label,t)}),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"})]})]})}),d&&s.o("p",{id:"submit-cooldown","aria-hidden":"true",class:"text-neutral-11 text-xs",children:mr(t,n,a,i)}),s.o("p",{role:"status",class:"sr-only",children:l})]})},ya=160,yr=e=>{e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,ya)}px`},ba={date:{type:"date",inputMode:"text"},email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},ga=s.isSubmissionOfType("string"),va=(e,r)=>{const t={maxLength:r("validation_max_chars",{count:e.maxChars??999}),minLength:r("validation_min_chars",{count:e.minChars??1})};return dt(be({text:{date:Ce(ae(r("validation_date")),Vt(/^\d{4}-\d{2}-\d{2}$/,r("validation_date"))),email:Ce(ae(r("validation_email")),Cr(r("validation_email")),$e(e.minChars??1,t.minLength),Xe(e.maxChars??1/0,t.maxLength)),text:Ce(ae(),$e(e.minChars??1,t.minLength),Xe(e.maxChars??1/0,t.maxLength)),url:Ce(ae(r("validation_url")),Ar(r("validation_url")),$e(e.minChars??1,t.minLength),Xe(e.maxChars??1/0,t.maxLength))}[e.format]}))},xa=({input:e,onSubmitSuccess:r})=>{var k;const{t}=s.useTranslation(),n=e.key?(k=s.store.current$.value.flow)==null?void 0:k.data.submissions[e.key]:void 0,a=e.config.defaultValue,i=e.config.multiline===!0&&e.config.format==="text",{register:o,handleSubmit:l,watch:c,formState:{errors:d}}=ut({defaultValues:{text:ga(n)?n.value:a??""},resolver:va(e.config,t)}),{ref:g,...b}=o("text",{required:!e.config.optional}),p=s._();s.y(()=>{p.current&&(p.current instanceof HTMLTextAreaElement&&yr(p.current),p.current.focus(),p.current.select())},[]);const m=e.config.maxChars,_=i&&m!==void 0?c("text").length:void 0;return s.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:l(C=>{r({type:"string",value:C.text})}),children:[s.o("div",{class:i?"flex items-end gap-2":"flex items-center gap-2",children:[s.o("div",{class:"relative min-w-0 flex-1",children:[i?s.o("textarea",{id:"chat-input",...b,rows:2,maxLength:m,autoFocus:!0,"aria-describedby":_!==void 0?"chat-input-count":void 0,onInput:C=>yr(C.currentTarget),onKeyDown:C=>{var I;C.key==="Enter"&&(C.ctrlKey||C.metaKey)&&(C.preventDefault(),(I=C.currentTarget.form)==null||I.requestSubmit())},ref:C=>{C&&(p.current=C),g(C)},placeholder:e.config.placeholder,class:qe({optional:!!e.config.optional,className:"block w-full resize-none overflow-y-auto rounded-2xl"})}):s.o("input",{id:"chat-input",...b,...ba[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:C=>{C&&(p.current=C),g(C)},placeholder:e.config.placeholder,class:qe({optional:!!e.config.optional,className:"w-full rounded-full"})}),e.config.optional&&s.o(ge,{class:i?"absolute bottom-1 right-0.5":"absolute bottom-0 right-0.5 top-0",onClick:()=>r(null)})]}),s.o(Fe,{})]}),_!==void 0&&m!==void 0&&s.o("p",{id:"chat-input-count",class:"text-neutral-10 px-3 text-right text-xs",children:[_,"/",m]}),s.o(Ue,{error:d.text})]})},wa={text:xa,phone:ha,"multiple-choice":sa,boolean:_s,file:Es,submit:ma,address:gs,number:oa},_a=({logger:e,analytics:r})=>{var i;const t=(i=s.store.current$.value.flow)==null?void 0:i.data.currentInput,n=s._(null),a=()=>s.chatStore.onInteractionFn$.value();return s.y(()=>{var o;(o=n.current)==null||o.scrollTo({top:0})},[t]),s.o("div",{ref:n,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:t?a:void 0,onKeyDownCapture:t?a:void 0,children:t?(()=>{const o=wa[t.type];return s.o(o,{logger:e,analytics:r,onSubmitSuccess:s.chatStore.onSubmitSuccessFn$.value,input:t})})():s.o("div",{class:"flex items-center gap-2 p-2.5",children:[s.o("input",{"aria-hidden":"true",id:"chat-input",class:qe({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),s.o(Fe,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};function ka(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ca=function(e){return e instanceof RegExp},Sa=function(r){var t=/[\\^$.*+?()[\]{}|]/g,n=RegExp(t.source);return r&&n.test(r)?r.replace(t,"\\$&"):r},Wr=function(e){return typeof e=="string"},Ia=function(e){var r=[];return e.forEach(function(t){Array.isArray(t)?r=r.concat(t):r.push(t)}),r};function Aa(e,r,t){var n=0,a=0;if(e==="")return e;if(!e||!Wr(e))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var i=r;Ca(i)||(i=new RegExp("("+Sa(i)+")","gi"));for(var o=e.split(i),l=1,c=o.length;l<c;l+=2){if(o[l]===void 0||o[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=o[l].length,n+=o[l-1].length,o[l]=t(o[l],l,n),n+=a}return o}var Ea=function(r,t,n){return Array.isArray(r)||(r=[r]),Ia(r.map(function(a){return Wr(a)?Aa(a,t,n):a}))};const Je=ka(Ea),Fa=/(\[[^\]]+\]\([^)]+\))/g,Va=/\[([^\]]+)\]\(([^)]+)\)/,Ma=/(https?:\/\/[^\s]+)/g,La=/_(.*?)_/g,Ta=/\*\*(.*?)\*\*/g,Na=/(\\n|\n)/g,br="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",Ra=e=>{const r=Je(e,Fa,(l,c)=>{const[,d,g]=l.match(Va)??[];return g?s.o("a",{class:br,href:g,children:d??g},g+c):s.o("span",{children:"INVALID LINK"})}),t=Je(r,Ma,(l,c)=>s.o("a",{class:br,href:l,children:l},l+c)),n=Je(t,La,(l,c)=>s.o("em",{children:l},l+c)),a=Je(n,Ta,(l,c)=>s.o("strong",{children:l},l+c));let i=0;return Je(a,Na,()=>s.o("br",{},`br-${i++}`))},Da=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"}}),Oa=({children:e,className:r,animate:t,side:n,...a})=>s.o("p",{style:{transformOrigin:n==="left"?"0% 50%":"100% 50%"},class:Da({className:r,side:n,animate:t}),...a,children:e}),gr=new Map,Ba=({flow:e,rpcClient:r})=>{const{t}=s.useTranslation(),n=e.data.flowSessionId,a=gr.get(n)??s.d("offer");gr.set(n,a);const i=c=>{const d=e.data.submissions[c];return(d==null?void 0:d.type)==="string"?d.value.trim():void 0},o=i("email")||e.nodes.flatMap(c=>c.type==="question-text"&&c.data.format==="email"?[i(c.data.key)]:[]).find(c=>!!c);if(!o||a.value==="declined")return null;if(a.value==="success")return s.o("p",{role:"status",children:t("job_alerts_success")});const l=async()=>{if(!(a.value!=="offer"&&a.value!=="error")){a.value="saving";try{await Yr.saveClosedRoleJobAlerts(r,{contact:{email:o,first_name:i("first_name"),last_name:i("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:t("job_alerts_offer",{email:o})}),a.value==="error"?s.o("p",{role:"alert",children:t("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:t("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:t("job_alerts_decline")})]}),s.o("p",{class:"text-xs",children:t("job_alerts_privacy")})]})},ja=({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"})})]})}),$a=({className:e,...r})=>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),...r,children:Array.from({length:3},(t,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}),Pa={bot:"left",user:"right"},qa=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"}}}),Ua=({lastSentMessageFooter:e,rpcClient:r})=>{const{t}=s.useTranslation(),n=s.store.current$.value.flow,a=(n==null?void 0:n.data.messages)??[],i=a.findIndex(l=>l.type==="system"&&l.semantic==="submission-closed"),o=n?Ft(n):void 0;return s.o("ol",{"aria-label":t("chat_messages"),"aria-live":"polite",class:"mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[a.map((l,c)=>s.o(s.k,{children:[s.o("li",{class:"flex",tabIndex:c===a.length-1?-1:void 0,children:[o&&l.groupId===o&&!a.slice(c+1).some(d=>d.groupId===o)?e:null,s.M(l).with({type:"system"},d=>s.o("p",{class:qa({variant:d.variant}),children:d.text})).with({type:"text",author:s.z$1.union("bot","user")},d=>{const g=c===a.length-1,b=d.author==="bot"?Ra(d.text):d.text;return s.o(s.k,{children:s.o(Oa,{animate:g,side:Pa[d.author],children:b},c)})}).with({type:"link"},d=>s.o(ja,{message:d})).with({type:"image"},d=>s.o("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:d.url,style:{aspectRatio:d.width/d.height}})).with({type:"file"},d=>s.o(Cs,{class:d.author==="bot"?void 0:"ml-auto",file:{name:d.fileName,sizeKb:d.fileSizeKb}})).with({type:"loading"},d=>{const g=a[a.length-1];return!(d===g)||s.chatStore.isBotTyping$.value||n!=null&&n.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":d.text?"true":void 0,class:"text-neutral-6 h-8 w-8"}),d.text?s.o("p",{role:"status",class:"text-neutral-11 text-sm",children:d.text}):null]})}).exhaustive()]}),c===i&&(n!=null&&n.jobAlerts)&&r?s.o("li",{children:s.o(Ba,{flow:n,rpcClient:r},n.data.flowSessionId)}):null]},c)),s.o("li",{class:s.chatStore.captchaVisible$.value?"flex":"hidden",children:s.o("div",{"data-captcha-slot":!0,tabIndex:-1,role:"group","aria-label":t("captcha_check"),class:"w-full max-w-[min(100%,24rem)] rounded-md"})},"captcha"),s.o($a,{},"typing")]})},za=({logger:e,apiClient:r,rpcClient:t,analytics:n,talentBankClient:a})=>{const{flow:i}=s.store.current$.value;s.invariant(i,"Flow is required to exist to show chatbot body");const o=s.store.viewState$.value,{chatRef:l,chatService:c}=s.useChatService(),{t:d}=s.useTranslation(),[g,b]=s.h();return s.y(()=>{o==="maximised"&&s.chatStore.scrollToEnd()},[o]),s.y(()=>{var Q;const{state:p,flow:m}=s.store.current$.peek();if(p!=="loaded")throw new Error(d("invalid_state"));let _=m.data.nodeHistory.at(-1);if(s.chatStore.scrollToEnd(),s.store.setInput(void 0),m.data.isFinished)return;const k=()=>{const N=s.store.current$.peek().flow;!N||N.data.hasInteracted||(s.store.markAsInteracted(),Ht(n,N,"FLOW_INTERACT"))};s.chatStore.onInteractionFn$.value=k,_===void 0?(_=xr(i.nodes).id,s.store.setCurrentNodeId(_),Ht(n,m,"FLOW_START")):s.store.removeMessagesSentByNodeIds([_,St]);const{interpret:C,abort:I,undo:v}=An({context:i.context,analytics:{service:n,customProperties:(Q=i.analytics)==null?void 0:Q.customProperties},apiClient:r,logger:e,talentBankClient:a,flow:i,chatService:c,t:d,getApplicationRecovery:()=>{var N;return(N=s.store.current$.peek().flow)==null?void 0:N.data.applicationRecovery},setApplicationRecovery:s.store.setApplicationRecovery,persistWriteBarrier:()=>s.store.persistWriteBarrier(m),getSubmissions:()=>{var N;return(N=s.store.current$.peek().flow)==null?void 0:N.data.submissions},onInterpret:N=>s.store.setCurrentNodeId(N.id),onFlowEnd:async()=>{var K;s.store.markAsFinished();const N=s.store.current$.peek().flow;s.invariant(N),n.log({event:"FLOW_END",properties:{flow_id:i.id,flow_version:i.version,flow_session_id:N.data.flowSessionId,flow_build:i.build,job:i.job},customProperties:(K=i.analytics)==null?void 0:K.customProperties})}}),T=_,V=()=>{b(()=>v),C(T)},M=new AbortController;return m.offerResume?Yn({chatService:c,t:d,signal:M.signal}).then(N=>(s.store.settleResume(m),N?V():(s.store.restart(),s.idb.flushStateData()))).catch(N=>{N instanceof s.T||e.error("Resume prompt failed",N)}):V(),()=>{M.abort(),s.chatStore.onInteractionFn$.value===k&&(s.chatStore.onInteractionFn$.value=()=>{}),I()}},[n,r,c,e,i,a,d]),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:l,role:"region","aria-label":d("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(Ua,{rpcClient:t,lastSentMessageFooter:!Ft(i)||!g?null:s.o(Ha,{undoFn:g})})}),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":d("jump_to_current"),onClick:()=>{var m,_;s.chatStore.scrollToEnd(),(_=((m=l.current)==null?void 0:m.querySelector('li[tabindex="-1"]'))??l.current)==null||_.focus({preventScroll:!0})},children:s.o(s.ChevronDown,{})})})]}),s.o(_a,{logger:e,analytics:n})]})},Ha=({undoFn:e})=>{const{t:r}=s.useTranslation();return s.o("div",{class:"flex flex-1 items-center justify-end px-1",children:s.o(s.SvgIconButton,{"aria-label":r("undo"),onClick:async()=>{const{flow:t}=s.store.current$.peek();s.invariant(t),e(t.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=za;
package/dist/chatbot.d.ts CHANGED
@@ -23,6 +23,8 @@ type InternalChatbotPluginParams = {
23
23
  theme: ChatbotTheme;
24
24
  feedback?: ChatbotFeedback;
25
25
  terms?: ChatbotTranslationTerms;
26
+ /** Offer email alerts after a submitted application reports that the role closed. */
27
+ jobAlerts?: boolean;
26
28
  /** @deprecated For internal usage only */
27
29
  _internal_domManager?: ChatbotDomManager;
28
30
  };
@@ -30,6 +32,8 @@ export type ChatbotPlugin = typeof chatbotPlugin;
30
32
  export type ChatbotPluginParams = RemoveInternal<InternalChatbotPluginParams>;
31
33
  export type Chatbot = ReturnType<ReturnType<ChatbotPlugin>>;
32
34
  export type OpenChatbotParams = {
35
+ /** Overrides the plugin's job-alert offer for this application. */
36
+ jobAlerts?: boolean;
33
37
  /** The application flow to be interpreted */
34
38
  flow: Flow;
35
39
  /** Specify the cache keys for restoring this flow from local state.
@@ -62,7 +66,7 @@ export type FetchFlowByJobIdAdditionalProperties = Partial<OpenChatbotParams & {
62
66
  idType: 'inploi' | 'ats';
63
67
  }>;
64
68
  export type FetchFlowByIdAdditionalProperties = Partial<OpenChatbotParams>;
65
- export declare const chatbotPlugin: ({ _internal_domManager: dom, theme, terms, feedback, }: InternalChatbotPluginParams) => ({ apiClient, rpcClient, logger, analytics, publishableKey, env }: {
69
+ export declare const chatbotPlugin: ({ _internal_domManager: dom, theme, terms, feedback, jobAlerts, }: InternalChatbotPluginParams) => ({ apiClient, rpcClient, logger, analytics, publishableKey, env }: {
66
70
  apiClient: import('@inploi/sdk').ApiClient;
67
71
  rpcClient: import('@inploi/sdk').InploiRpcClient;
68
72
  logger: import('@inploi/sdk').Logger;
@@ -5,6 +5,7 @@ import { ChatbotFlowProgress } from './progress';
5
5
 
6
6
  export declare const getCacheKey: (flow: Pick<StartedFlow, "flowKeys" | "id" | "version" | "build" | "context">) => string;
7
7
  export type StartedFlow = Flow & {
8
+ jobAlerts?: boolean;
8
9
  flowKeys: string[];
9
10
  title: string;
10
11
  data: FlowStateData;
@@ -42,6 +43,9 @@ type CurrentFlow = {
42
43
  } | {
43
44
  state: 'loaded';
44
45
  flow: StartedFlow;
46
+ } | {
47
+ state: 'closed';
48
+ flow?: never;
45
49
  }
46
50
  /** The reason is logged; the candidate sees only the translated heading. */
47
51
  | {
@@ -50,8 +54,8 @@ type CurrentFlow = {
50
54
  };
51
55
  export declare const store: {
52
56
  current$: import('@preact/signals').Signal<CurrentFlow>;
53
- viewState$: import('@preact/signals').Signal<"maximised" | "minimised" | "closed">;
54
- prepareFlow: ({ flow, context, flowKeys, title, analytics, job, locationOrigin, }: OpenChatbotParams) => Promise<StartedFlow>;
57
+ viewState$: import('@preact/signals').Signal<"closed" | "maximised" | "minimised">;
58
+ prepareFlow: ({ jobAlerts, flow, context, flowKeys, title, analytics, job, locationOrigin, }: OpenChatbotParams) => Promise<StartedFlow>;
55
59
  commitFlow: (flow: StartedFlow) => void;
56
60
  /** The candidate chose to continue or start again, so this page does not ask about this application again. */
57
61
  settleResume: (flow: StartedFlow) => void;
@@ -1 +1,3 @@
1
- export declare const ChatError: () => import("preact").JSX.Element;
1
+ export declare const ChatError: ({ heading }: {
2
+ heading: "error_heading" | "flow_closed";
3
+ }) => import("preact").JSX.Element;
@@ -1,10 +1,11 @@
1
- import { AnalyticsService, ApiClient, Logger, TalentBankClient } from '@inploi/sdk';
1
+ import { AnalyticsService, ApiClient, Logger, InploiRpcClient, TalentBankClient } from '@inploi/sdk';
2
2
 
3
3
  type ChatbotBodyProps = {
4
+ rpcClient?: InploiRpcClient;
4
5
  apiClient: ApiClient;
5
6
  logger: Logger;
6
7
  analytics: AnalyticsService;
7
8
  talentBankClient?: TalentBankClient;
8
9
  };
9
- export declare const ChatbotBody: ({ logger, apiClient, analytics, talentBankClient }: ChatbotBodyProps) => import("preact").JSX.Element;
10
+ export declare const ChatbotBody: ({ logger, apiClient, rpcClient, analytics, talentBankClient }: ChatbotBodyProps) => import("preact").JSX.Element;
10
11
  export {};
@@ -1,12 +1,13 @@
1
- import { AnalyticsService, ApiClient, Logger, TalentBankClient } from '@inploi/sdk';
1
+ import { AnalyticsService, ApiClient, Logger, InploiRpcClient, TalentBankClient } from '@inploi/sdk';
2
2
  import { ChatbotPluginParams } from '..';
3
3
 
4
4
  type ChatbotProps = {
5
+ rpcClient?: InploiRpcClient;
5
6
  apiClient: ApiClient;
6
7
  logger: Logger;
7
8
  analytics: AnalyticsService;
8
9
  talentBankClient?: TalentBankClient;
9
10
  params: ChatbotPluginParams;
10
11
  };
11
- export declare const Chatbot: ({ logger, apiClient, analytics, talentBankClient, params }: ChatbotProps) => import("preact").JSX.Element;
12
+ export declare const Chatbot: ({ logger, apiClient, rpcClient, analytics, talentBankClient, params }: ChatbotProps) => import("preact").JSX.Element;
12
13
  export {};
@@ -1,5 +1,7 @@
1
+ import { InploiRpcClient } from '@inploi/sdk';
1
2
  import { VNode } from 'preact';
2
3
 
3
- export declare const Conversation: ({ lastSentMessageFooter }: {
4
+ export declare const Conversation: ({ lastSentMessageFooter, rpcClient, }: {
4
5
  lastSentMessageFooter: VNode | null;
6
+ rpcClient?: InploiRpcClient;
5
7
  }) => import("preact").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { InploiRpcClient } from '@inploi/sdk';
2
+ import { StartedFlow } from '../chatbot.state';
3
+
4
+ export declare const JobAlertsOffer: ({ flow, rpcClient }: {
5
+ flow: StartedFlow;
6
+ rpcClient: InploiRpcClient;
7
+ }) => import("preact").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export {};
package/dist/i18n.d.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  export declare const TranslationProvider: (props: {
2
2
  terms?: Partial<import('@inploi/i18n/translation').TranslationDict<{
3
3
  readonly error_heading: "Something unexpected happened";
4
+ readonly flow_closed: "This role is no longer accepting applications.";
4
5
  readonly undo: "Change answer";
5
- readonly submission_closed: "This role is no longer accepting applications.";
6
+ readonly job_alerts_offer: "Want to hear about similar roles? We can email you at {{email}} when new ones open.";
7
+ readonly job_alerts_accept: "Get job alerts";
8
+ readonly job_alerts_decline: "No thanks";
9
+ readonly job_alerts_privacy: "We'll use your email only for these alerts. You can unsubscribe at any time.";
10
+ readonly job_alerts_success: "Done. We'll email you about similar roles.";
11
+ readonly job_alerts_error: "Sorry, we couldn't set that up. Please try again later.";
6
12
  readonly submission_duplicate: "You've already applied for this role, so we haven't submitted a second application. If that doesn't sound right, check your email for a confirmation or try again in a few minutes.";
7
13
  readonly submission_retryable: "We couldn't submit your application. Please try again.";
8
14
  readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
@@ -18,6 +24,7 @@ export declare const TranslationProvider: (props: {
18
24
  readonly submitting: string;
19
25
  readonly skip: string;
20
26
  readonly skipped: string;
27
+ readonly submission_closed: string;
21
28
  readonly submission_duplicate_earlier_attempt: string;
22
29
  readonly submission_failed: string;
23
30
  readonly submission_unknown_do_not_resubmit: string;
@@ -123,8 +130,14 @@ export declare const TranslationProvider: (props: {
123
130
  children?: import('preact').ComponentChildren;
124
131
  }) => import("preact").JSX.Element, useTranslation: <T extends {
125
132
  readonly error_heading: "Something unexpected happened";
133
+ readonly flow_closed: "This role is no longer accepting applications.";
126
134
  readonly undo: "Change answer";
127
- readonly submission_closed: "This role is no longer accepting applications.";
135
+ readonly job_alerts_offer: "Want to hear about similar roles? We can email you at {{email}} when new ones open.";
136
+ readonly job_alerts_accept: "Get job alerts";
137
+ readonly job_alerts_decline: "No thanks";
138
+ readonly job_alerts_privacy: "We'll use your email only for these alerts. You can unsubscribe at any time.";
139
+ readonly job_alerts_success: "Done. We'll email you about similar roles.";
140
+ readonly job_alerts_error: "Sorry, we couldn't set that up. Please try again later.";
128
141
  readonly submission_duplicate: "You've already applied for this role, so we haven't submitted a second application. If that doesn't sound right, check your email for a confirmation or try again in a few minutes.";
129
142
  readonly submission_retryable: "We couldn't submit your application. Please try again.";
130
143
  readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
@@ -140,6 +153,7 @@ export declare const TranslationProvider: (props: {
140
153
  readonly submitting: string;
141
154
  readonly skip: string;
142
155
  readonly skipped: string;
156
+ readonly submission_closed: string;
143
157
  readonly submission_duplicate_earlier_attempt: string;
144
158
  readonly submission_failed: string;
145
159
  readonly submission_unknown_do_not_resubmit: string;
@@ -242,8 +256,14 @@ export declare const TranslationProvider: (props: {
242
256
  readonly optional: "optional";
243
257
  } = {
244
258
  readonly error_heading: "Something unexpected happened";
259
+ readonly flow_closed: "This role is no longer accepting applications.";
245
260
  readonly undo: "Change answer";
246
- readonly submission_closed: "This role is no longer accepting applications.";
261
+ readonly job_alerts_offer: "Want to hear about similar roles? We can email you at {{email}} when new ones open.";
262
+ readonly job_alerts_accept: "Get job alerts";
263
+ readonly job_alerts_decline: "No thanks";
264
+ readonly job_alerts_privacy: "We'll use your email only for these alerts. You can unsubscribe at any time.";
265
+ readonly job_alerts_success: "Done. We'll email you about similar roles.";
266
+ readonly job_alerts_error: "Sorry, we couldn't set that up. Please try again later.";
247
267
  readonly submission_duplicate: "You've already applied for this role, so we haven't submitted a second application. If that doesn't sound right, check your email for a confirmation or try again in a few minutes.";
248
268
  readonly submission_retryable: "We couldn't submit your application. Please try again.";
249
269
  readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
@@ -259,6 +279,7 @@ export declare const TranslationProvider: (props: {
259
279
  readonly submitting: string;
260
280
  readonly skip: string;
261
281
  readonly skipped: string;
282
+ readonly submission_closed: string;
262
283
  readonly submission_duplicate_earlier_attempt: string;
263
284
  readonly submission_failed: string;
264
285
  readonly submission_unknown_do_not_resubmit: string;
@@ -364,8 +385,14 @@ export declare const TranslationProvider: (props: {
364
385
  locale: string | undefined;
365
386
  }, createTFunction: <T extends {
366
387
  readonly error_heading: "Something unexpected happened";
388
+ readonly flow_closed: "This role is no longer accepting applications.";
367
389
  readonly undo: "Change answer";
368
- readonly submission_closed: "This role is no longer accepting applications.";
390
+ readonly job_alerts_offer: "Want to hear about similar roles? We can email you at {{email}} when new ones open.";
391
+ readonly job_alerts_accept: "Get job alerts";
392
+ readonly job_alerts_decline: "No thanks";
393
+ readonly job_alerts_privacy: "We'll use your email only for these alerts. You can unsubscribe at any time.";
394
+ readonly job_alerts_success: "Done. We'll email you about similar roles.";
395
+ readonly job_alerts_error: "Sorry, we couldn't set that up. Please try again later.";
369
396
  readonly submission_duplicate: "You've already applied for this role, so we haven't submitted a second application. If that doesn't sound right, check your email for a confirmation or try again in a few minutes.";
370
397
  readonly submission_retryable: "We couldn't submit your application. Please try again.";
371
398
  readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
@@ -381,6 +408,7 @@ export declare const TranslationProvider: (props: {
381
408
  readonly submitting: string;
382
409
  readonly skip: string;
383
410
  readonly skipped: string;
411
+ readonly submission_closed: string;
384
412
  readonly submission_duplicate_earlier_attempt: string;
385
413
  readonly submission_failed: string;
386
414
  readonly submission_unknown_do_not_resubmit: string;
@@ -483,8 +511,14 @@ export declare const TranslationProvider: (props: {
483
511
  readonly optional: "optional";
484
512
  } = {
485
513
  readonly error_heading: "Something unexpected happened";
514
+ readonly flow_closed: "This role is no longer accepting applications.";
486
515
  readonly undo: "Change answer";
487
- readonly submission_closed: "This role is no longer accepting applications.";
516
+ readonly job_alerts_offer: "Want to hear about similar roles? We can email you at {{email}} when new ones open.";
517
+ readonly job_alerts_accept: "Get job alerts";
518
+ readonly job_alerts_decline: "No thanks";
519
+ readonly job_alerts_privacy: "We'll use your email only for these alerts. You can unsubscribe at any time.";
520
+ readonly job_alerts_success: "Done. We'll email you about similar roles.";
521
+ readonly job_alerts_error: "Sorry, we couldn't set that up. Please try again later.";
488
522
  readonly submission_duplicate: "You've already applied for this role, so we haven't submitted a second application. If that doesn't sound right, check your email for a confirmation or try again in a few minutes.";
489
523
  readonly submission_retryable: "We couldn't submit your application. Please try again.";
490
524
  readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
@@ -500,6 +534,7 @@ export declare const TranslationProvider: (props: {
500
534
  readonly submitting: string;
501
535
  readonly skip: string;
502
536
  readonly skipped: string;
537
+ readonly submission_closed: string;
503
538
  readonly submission_duplicate_earlier_attempt: string;
504
539
  readonly submission_failed: string;
505
540
  readonly submission_unknown_do_not_resubmit: string;
@@ -603,8 +638,14 @@ export declare const TranslationProvider: (props: {
603
638
  }>(options: {
604
639
  overrides: Partial<import('@inploi/i18n/translation').TranslationDict<{
605
640
  readonly error_heading: "Something unexpected happened";
641
+ readonly flow_closed: "This role is no longer accepting applications.";
606
642
  readonly undo: "Change answer";
607
- readonly submission_closed: "This role is no longer accepting applications.";
643
+ readonly job_alerts_offer: "Want to hear about similar roles? We can email you at {{email}} when new ones open.";
644
+ readonly job_alerts_accept: "Get job alerts";
645
+ readonly job_alerts_decline: "No thanks";
646
+ readonly job_alerts_privacy: "We'll use your email only for these alerts. You can unsubscribe at any time.";
647
+ readonly job_alerts_success: "Done. We'll email you about similar roles.";
648
+ readonly job_alerts_error: "Sorry, we couldn't set that up. Please try again later.";
608
649
  readonly submission_duplicate: "You've already applied for this role, so we haven't submitted a second application. If that doesn't sound right, check your email for a confirmation or try again in a few minutes.";
609
650
  readonly submission_retryable: "We couldn't submit your application. Please try again.";
610
651
  readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
@@ -620,6 +661,7 @@ export declare const TranslationProvider: (props: {
620
661
  readonly submitting: string;
621
662
  readonly skip: string;
622
663
  readonly skipped: string;
664
+ readonly submission_closed: string;
623
665
  readonly submission_duplicate_earlier_attempt: string;
624
666
  readonly submission_failed: string;
625
667
  readonly submission_unknown_do_not_resubmit: string;