@inploi/plugin-chatbot 3.6.2 → 3.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cdn/index.js CHANGED
@@ -54,4 +54,4 @@ var Sy=Object.defineProperty;var My=(Et,Je,Ie)=>Je in Et?Sy(Et,Je,{enumerable:!0
54
54
  ${e.flatMap(n=>Object.entries(n.colors).map(([r,o])=>`--i-${n.name}-${r}: ${i1(o)};`).join(`
55
55
  `)).join(`
56
56
  `)}
57
- }`,a1=({_internal_domManager:e=hg(),theme:t})=>Et(({apiClient:n,logger:r,analytics:o})=>{let i=!1;const s=()=>{if(typeof window>"u")return;const a=e.getOrCreateChatbotElement();e.addStyle(fg,"inploi-chatbot-style");const c=s1([{name:"a",colors:xd(t)},{name:"n",colors:xd({hue:t.hue,chroma:.1})}]);e.addStyle(c,"inploi-chatbot-theme"),en(R(Hv,{apiClient:n,logger:r,analytics:o}),a),i=!0};return{prepare:async()=>{if(!(typeof window>"u"))try{if(i)return;s(),r.info("Chatbot plugin prepared")}catch(a){console.error(a),r.error("Error preparing chatbot plugin",a)}},startApplication:async({jobId:a})=>{if(!(typeof window>"u"))try{ne.cancel(),pf(()=>{rt.value="maximised",ne.current$.value={state:"loading"}}),dg({jobId:a,apiClient:n,logger:r}).then(async c=>{c.ok?(await o.log({event:"APPLY_START",attributionKey:`job_${a}`,properties:{job_id:a,flow_id:c.value.flow.id}}).catch(r.error),ne.start(c.value)):ne.current$.value={state:"error",error:c.error}}),i||s()}catch(c){console.error(c),r.error("Error starting application",c)}},closeApplication:async()=>{typeof window>"u"||(r.info("Closing application from an external source"),ne.cancel())}}});if(!window.inploi)throw new Error("Please insert the SDK script tag above the plugins.");window.inploi.chatbotPlugin=a1;const kd=({node:e,nodes:t,stopWhen:n})=>{if((n==null?void 0:n(e))===!0)return e;const r=e.nextId?t.find(o=>o.id===e.nextId):void 0;if(r)return kd({node:r,nodes:t,stopWhen:n})},c1=({childNode:e,nodes:t})=>{const r=t.filter(o=>o.type==="if-block").find(o=>{if(!o.branchId)return!1;const i=t.find(a=>a.id===o.branchId);if(!i)return!1;const s=kd({node:i,nodes:t,stopWhen:a=>a.id===e.id});return!(!s||s.id!==e.id)});if(r!=null&&r.nextId)return t.find(o=>o.id===r.nextId)},l1=({flow:e,analytics:t,logger:n,context:r,apiClient:o,getSubmissions:i,chatService:s,onFlowEnd:a,onInterpret:c})=>{const u=new AbortController,d=async(l,f)=>{const h=i();c==null||c(l,f);try{await u1({analytics:t,logger:n,apiClient:o,context:r,node:l,submissions:h,chat:{sendMessage:async p=>s.send({groupId:l.id,message:p,signal:u.signal}),userInput:async p=>s.input({input:p,signal:u.signal})},next:p=>{const m=p?e.find(y=>y.id===p):c1({childNode:l,nodes:e});return m?d(m,l):a==null?void 0:a(l)},end:()=>a==null?void 0:a(l)})}catch(p){if(p instanceof Jn)return;throw p}};return{interpret:async l=>{const f=e.find(h=>h.id===l)??vu(e);return d(f)},abort:()=>{u.abort()}}};async function u1(e){return await nt(e).with({node:{type:"text"}},p1).with({node:{type:"image"}},m1).with({node:{type:"question-text"}},v1).with({node:{type:"question-enum"}},b1).with({node:{type:"question-number"}},g1).with({node:{type:"question-boolean"}},y1).with({node:{type:"question-file"}},_1).with({node:{type:"question-address"}},w1).with({node:{type:"end-flow"}},x1).with({node:{type:"if-block"}},h1).with({node:{type:"jump"}},({node:t,next:n})=>n(t.data.targetId)).with({node:{type:"link"}},f1).with({node:{type:"integration-application-submit"}},d1).with({node:{type:"integration-workflow-get"}},()=>Error("Unreachable")).exhaustive()}async function d1({chat:e,next:t,node:n,logger:r,apiClient:o,submissions:i,context:s,analytics:a}){await e.userInput({type:"multiple-choice",key:void 0,config:{options:[{label:"Submit my application",value:"submit"}],maxSelected:1,minSelected:1}});const c=()=>{const d=typeof s.jobId=="string"?s.jobId:void 0,l=typeof s.flowId=="string"?s.flowId:void 0;rn(d),rn(l),d&&a.log({event:"APPLY_COMPLETE",attributionKey:`job_${d}`,properties:{job_id:d,flow_id:l}})};await e.sendMessage({type:"system",variant:"info",text:"Submitting your application…"});const u=await o.fetch("/flow/apply",{method:"POST",body:JSON.stringify({...s,type:n.data.type,ats:n.data.ats,integration_id:n.data.integrationId,anonymous_id:a.getAnonymousId(),submissions:Nv(i||{})})}).catch(d=>d);await nt(u).with({ats_data:{redirect_url:Ae.string}},async d=>{await e.sendMessage({type:"text",author:"bot",text:"Almost there! Please finalise your application on our partner’s website."});const l=a.getAnonymousId(),f=new URL(d.ats_data.redirect_url);l&&!f.searchParams.has("anonymous_id")&&f.searchParams.set("anonymous_id",l),c(),await e.sendMessage({type:"link",href:f.toString(),text:"Finalise application on partner"})}).with({success:!0},async()=>{c(),await e.sendMessage({type:"system",variant:"success",text:"Application submitted"}),t(n.nextId)}).otherwise(async d=>{r.error(d),await e.sendMessage({type:"system",variant:"error",text:"Failed to submit application"}),t(n.id)})}async function f1({chat:e,next:t,node:n}){await e.sendMessage({type:"link",href:n.data.href,text:n.data.cta}),t(n.nextId)}async function h1({submissions:e,next:t,node:n}){const r=k1(n,e)?n.branchId:n.nextId;t(r)}async function p1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.text}),t(n.nextId)}async function m1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"image",url:n.data.url,height:n.data.height,width:n.data.width}),t(n.nextId)}async function v1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"text",config:{placeholder:n.data.placeholder,format:n.data.format}});await e.sendMessage({author:"user",type:"text",text:r.value}),t(n.nextId)}async function g1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"text",config:{placeholder:n.data.placeholder,format:"text"}});await e.sendMessage({author:"user",type:"text",text:r.value}),t(n.nextId)}async function b1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"multiple-choice",config:n.data});await e.sendMessage({author:"user",type:"text",text:n.data.options.filter(o=>r.value.includes(o.value)).map(o=>o.label).join(", ")}),t(n.nextId)}async function y1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const o=(await e.userInput({key:n.data.key,type:"boolean",config:{labels:{true:n.data.trueLabel,false:n.data.falseLabel}}})).value,i={true:n.data.trueLabel,false:n.data.falseLabel};await e.sendMessage({author:"user",type:"text",text:i[o]}),t(n.nextId)}async function w1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:"Address questions are not implemented yet"}),t(n.nextId)}async function _1({node:e,chat:t,next:n}){await t.sendMessage({author:"bot",type:"text",text:e.data.question});const r=await t.userInput({key:e.data.key,type:"file",config:{extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb??10*1024,allowMultiple:e.data.multiple===!0}});for await(const o of r.value)await t.sendMessage({author:"user",type:"file",fileName:o.name,fileSizeKb:o.sizeKb});n(e.nextId)}async function x1({chat:e,end:t,node:n}){await e.sendMessage({type:"system",variant:"info",text:n.data.systemMessage||"Conversation finished"}),t()}const $d=Ae.union(Ae.string,Ae.array(Ae.string)),k1=(e,t)=>{const n=t==null?void 0:t[e.data.compareKey];return n?nt({...e.data,answer:n}).with({compare:"equals"},({compareValue:r})=>typeof n.value=="string"||typeof n.value=="boolean"?r===n.value.toString():!1).with({compare:"notEquals"},({compareValue:r})=>typeof n.value=="string"||typeof n.value=="boolean"?r!==n.value.toString():!1).with({compare:"contains",answer:{value:$d}},({compareValue:r,answer:o})=>o.value.includes(r)).with({compare:"notContains",answer:{value:$d}},({compareValue:r,answer:o})=>!o.value.includes(r)).with({answer:{type:"file"}},()=>!1).exhaustive():!1},ko=({class:e,...t})=>b("button",{class:Xt("bg-accent-7 active:bg-accent-10 active:text-accent-2 text-lowest pointer-coarse:touch-hitbox focus-visible:ring-accent-7/50 flex-shrink-0 rounded-full p-2 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:b("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[b("title",{children:"Send"}),b("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),b("path",{d:"M8 4V13"})]})}),Is=()=>{const e=U(null);return G(()=>{var t;(t=e.current)==null||t.focus()},[]),e},Sd=["true","false"],$1=eg(Sd),S1="answer",M1=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{const r=Is();return n(),b("form",{noValidate:!0,class:"flex items-center gap-2",onSubmit:o=>{o.preventDefault();const i=nt(o).with({nativeEvent:{submitter:Ae.select(Ae.union(Ae.instanceOf(HTMLButtonElement),Ae.instanceOf(HTMLInputElement)))}},a=>a.value).otherwise(()=>{throw new Error("invalid form")}),s=rs($1,i);t(s)},children:Sd.map((o,i)=>b("button",{ref:i===0?r:null,type:"submit",name:S1,value:o,class:"bg-lowest ease-expo-out ring-neutral-12/5 text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr duration-snappy block flex-1 overflow-hidden rounded-2xl px-2.5 py-2.5 ring-2 transition-all selection:bg-transparent",children:b("p",{class:"truncate text-center text-base",children:e.config.labels[o]})}))})},Fs=({error:e,onAnimationComplete:t})=>b(to,{children:e&&b(Kn.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},onAnimationComplete:t,role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full p-0.5 px-1 opacity-0",children:[b("svg",{class:"text-error-10",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),b("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),b("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),b("p",{class:"truncate pr-1 text-sm",children:e.message})]})}),T1=e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>r.result?t(r.result.toString()):n("No result from reader"),r.onerror=n}),$o=e=>nt(e).with(Ae.number.lte(1e3),()=>`${Math.round(e)}KB`).with(Ae.number.lt(1e3*10),()=>`${(e/1e3).toFixed(1)}MB`).otherwise(()=>`${Math.round(e/1e3)}MB`),C1=e=>e.reduce((t,n)=>t+n.sizeKb,0),A1=ts("file"),Md=3,P1=({file:e,class:t,...n})=>{const r=e.name.split(".").pop(),o=e.name.replace(new RegExp(`.${r}$`),"");return b("div",{class:Xt("bg-accent-1 outline-neutral-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",t),...n,children:[b("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[b("span",{class:"block truncate",children:o}),b("span",{children:[".",r]})]}),b("p",{"aria-label":"File size",class:"text-neutral-10",children:$o(e.sizeKb)})]})},Td=({class:e,...t})=>b("li",{class:Xt("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...t}),E1=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var l;const r=(l=ne.current$.value.application)==null?void 0:l.data.submissions[e.key],[o,i]=ae(A1(r)?r.value:[]),[s,a]=ae(),c=o.length-Md,u=C1(o),d=Is();return b("form",{class:"flex flex-col gap-1",onSubmit:f=>(f.preventDefault(),a(void 0),o.length===0?a({type:"required",message:"Please select a file"}):e.config.fileSizeLimitKib&&u>e.config.fileSizeLimitKib?a({type:"max",message:`File size exceeds limit of ${$o(e.config.fileSizeLimitKib)}`}):e.config.allowMultiple===!1&&o.length>1?a({type:"invalid",message:"Only one file is allowed"}):t(o)),children:[b("div",{class:"flex items-center gap-2",children:[b("label",{ref:d,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:[o.length>0?b(ue,{children:[b("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[o.slice(0,Md).map(f=>{const h=f.name.split(".").pop(),p=f.name.replace(new RegExp(`.${h}$`),"");return b(Td,{class:"flex overflow-hidden",children:[b("span",{class:"block truncate",children:p}),b("span",{children:[".",h]})]})}),c>0?b(Td,{children:["+",c," file",c!==1?"s":""]}):null]}),b("p",{class:"text-neutral-11 text-xs",children:[$o(u)," ",o.length>1?"total":""]})]}):b("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[b("header",{class:"flex flex-col items-center gap-0",children:[b("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:b("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"})}),b("p",{class:"text-neutral-12 tracking-[-0.01em] dark:text-gray-400",children:[e.config.allowMultiple?"Select files":"Select a file"," to upload"]}),e.config.fileSizeLimitKib?b("p",{class:"text-neutral-10 text-xs",children:["(max ",$o(e.config.fileSizeLimitKib),")"]}):null]}),b("aside",{class:"flex flex-col items-center gap-2",children:[b("p",{id:"accepted-filetypes",class:"sr-only",children:"Accepted file extensions"}),b("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(f=>b("li",{class:"ring-lowest outline-neutral-6 text-neutral-9 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",children:f.replace(".","")}))})]})]}),b("input",{id:"dropzone-file",onInput:async f=>{rn(f.target instanceof HTMLInputElement);const h=f.target.files?Array.from(f.target.files):[],p=await Promise.allSettled(h.map(async y=>{const x=await T1(y);return{name:y.name,data:x,sizeKb:y.size/1e3}}));if(p.some(({status:y})=>y==="rejected"))return a({type:"invalid",message:"Invalid file"});const m=p.map(y=>y.status==="fulfilled"?y.value:null).filter(Boolean);i(m)},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),b(ko,{disabled:o.length===0})]}),s&&b(Fs,{onAnimationComplete:n,error:s})]})};var lr=e=>e.type==="checkbox",Mn=e=>e instanceof Date,Me=e=>e==null;const Cd=e=>typeof e=="object";var fe=e=>!Me(e)&&!Array.isArray(e)&&Cd(e)&&!Mn(e),V1=e=>fe(e)&&e.target?lr(e.target)?e.target.checked:e.target.value:e,O1=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,L1=(e,t)=>e.has(O1(t)),N1=e=>{const t=e.constructor&&e.constructor.prototype;return fe(t)&&t.hasOwnProperty("isPrototypeOf")},Ds=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ct(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Ds&&(e instanceof Blob||e instanceof FileList))&&(n||fe(e)))if(t=n?[]:{},!n&&!N1(e))t=e;else for(const r in e)e.hasOwnProperty(r)&&(t[r]=ct(e[r]));else return e;return t}var ur=e=>Array.isArray(e)?e.filter(Boolean):[],ie=e=>e===void 0,O=(e,t,n)=>{if(!t||!fe(e))return n;const r=ur(t.split(/[,[\].]+?/)).reduce((o,i)=>Me(o)?o:o[i],e);return ie(r)||r===e?ie(e[t])?n:e[t]:r},Tt=e=>typeof e=="boolean";const Ad={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ze={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},lt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};De.createContext(null);var R1=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(o,i,{get:()=>{const s=i;return t._proxyFormState[s]!==ze.all&&(t._proxyFormState[s]=!r||ze.all),n&&(n[s]=!0),e[s]}});return o},Oe=e=>fe(e)&&!Object.keys(e).length,I1=(e,t,n,r)=>{n(e);const{name:o,...i}=e;return Oe(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(s=>t[s]===(!r||ze.all))},zs=e=>Array.isArray(e)?e:[e];function F1(e){const t=De.useRef(e);t.current=e,De.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var Ye=e=>typeof e=="string",D1=(e,t,n,r,o)=>Ye(e)?(r&&t.watch.add(e),O(n,e,o)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),O(n,i))):(r&&(t.watchAll=!0),n),Bs=e=>/^\w*$/.test(e),Pd=e=>ur(e.replace(/["|']|\]/g,"").split(/\.|\[/));function Q(e,t,n){let r=-1;const o=Bs(t)?[t]:Pd(t),i=o.length,s=i-1;for(;++r<i;){const a=o[r];let c=n;if(r!==s){const u=e[a];c=fe(u)||Array.isArray(u)?u:isNaN(+o[r+1])?{}:[]}e[a]=c,e=e[a]}return e}var Ed=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},Vd=e=>({isOnSubmit:!e||e===ze.onSubmit,isOnBlur:e===ze.onBlur,isOnChange:e===ze.onChange,isOnAll:e===ze.all,isOnTouch:e===ze.onTouched}),Od=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const So=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const i=O(e,o);if(i){const{_f:s,...a}=i;if(s){if(s.refs&&s.refs[0]&&t(s.refs[0],o)&&!r)break;if(s.ref&&t(s.ref,s.name)&&!r)break}else fe(a)&&So(a,t)}}};var z1=(e,t,n)=>{const r=ur(O(e,n));return Q(r,"root",t[n]),Q(e,n,r),e},js=e=>e.type==="file",Ct=e=>typeof e=="function",Mo=e=>{if(!Ds)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},To=e=>Ye(e),Hs=e=>e.type==="radio",Co=e=>e instanceof RegExp;const Ld={value:!1,isValid:!1},Nd={value:!0,isValid:!0};var Rd=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ie(e[0].attributes.value)?ie(e[0].value)||e[0].value===""?Nd:{value:e[0].value,isValid:!0}:Nd:Ld}return Ld};const Id={isValid:!1,value:null};var Fd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Id):Id;function Dd(e,t,n="validate"){if(To(e)||Array.isArray(e)&&e.every(To)||Tt(e)&&!e)return{type:n,message:To(e)?e:"",ref:t}}var Tn=e=>fe(e)&&!Co(e)?e:{value:e,message:""},zd=async(e,t,n,r,o)=>{const{ref:i,refs:s,required:a,maxLength:c,minLength:u,min:d,max:l,pattern:f,validate:h,name:p,valueAsNumber:m,mount:y,disabled:x}=e._f,g=O(t,p);if(!y||x)return{};const w=s?s[0]:i,M=j=>{r&&w.reportValidity&&(w.setCustomValidity(Tt(j)?"":j||""),w.reportValidity())},S={},I=Hs(i),N=lr(i),C=I||N,E=(m||js(i))&&ie(i.value)&&ie(g)||Mo(i)&&i.value===""||g===""||Array.isArray(g)&&!g.length,q=Ed.bind(null,p,n,S),K=(j,B,H,X=lt.maxLength,re=lt.minLength)=>{const se=j?B:H;S[p]={type:j?X:re,message:se,ref:i,...q(j?X:re,se)}};if(o?!Array.isArray(g)||!g.length:a&&(!C&&(E||Me(g))||Tt(g)&&!g||N&&!Rd(s).isValid||I&&!Fd(s).isValid)){const{value:j,message:B}=To(a)?{value:!!a,message:a}:Tn(a);if(j&&(S[p]={type:lt.required,message:B,ref:w,...q(lt.required,B)},!n))return M(B),S}if(!E&&(!Me(d)||!Me(l))){let j,B;const H=Tn(l),X=Tn(d);if(!Me(g)&&!isNaN(g)){const re=i.valueAsNumber||g&&+g;Me(H.value)||(j=re>H.value),Me(X.value)||(B=re<X.value)}else{const re=i.valueAsDate||new Date(g),se=ut=>new Date(new Date().toDateString()+" "+ut),Le=i.type=="time",Ne=i.type=="week";Ye(H.value)&&g&&(j=Le?se(g)>se(H.value):Ne?g>H.value:re>new Date(H.value)),Ye(X.value)&&g&&(B=Le?se(g)<se(X.value):Ne?g<X.value:re<new Date(X.value))}if((j||B)&&(K(!!j,H.message,X.message,lt.max,lt.min),!n))return M(S[p].message),S}if((c||u)&&!E&&(Ye(g)||o&&Array.isArray(g))){const j=Tn(c),B=Tn(u),H=!Me(j.value)&&g.length>+j.value,X=!Me(B.value)&&g.length<+B.value;if((H||X)&&(K(H,j.message,B.message),!n))return M(S[p].message),S}if(f&&!E&&Ye(g)){const{value:j,message:B}=Tn(f);if(Co(j)&&!g.match(j)&&(S[p]={type:lt.pattern,message:B,ref:i,...q(lt.pattern,B)},!n))return M(B),S}if(h){if(Ct(h)){const j=await h(g,t),B=Dd(j,w);if(B&&(S[p]={...B,...q(lt.validate,B.message)},!n))return M(B.message),S}else if(fe(h)){let j={};for(const B in h){if(!Oe(j)&&!n)break;const H=Dd(await h[B](g,t),w,B);H&&(j={...H,...q(B,H.message)},M(H.message),n&&(S[p]=j))}if(!Oe(j)&&(S[p]={ref:w,...j},!n))return S}}return M(!0),S};function B1(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=ie(e)?r++:e[t[r++]];return e}function j1(e){for(const t in e)if(e.hasOwnProperty(t)&&!ie(e[t]))return!1;return!0}function ye(e,t){const n=Array.isArray(t)?t:Bs(t)?[t]:Pd(t),r=n.length===1?e:B1(e,n),o=n.length-1,i=n[o];return r&&delete r[i],o!==0&&(fe(r)&&Oe(r)||Array.isArray(r)&&j1(r))&&ye(e,n.slice(0,-1)),e}function Us(){let e=[];return{get observers(){return e},next:o=>{for(const i of e)i.next&&i.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(i=>i!==o)}}),unsubscribe:()=>{e=[]}}}var Ao=e=>Me(e)||!Cd(e);function Yt(e,t){if(Ao(e)||Ao(t))return e===t;if(Mn(e)&&Mn(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const i=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const s=t[o];if(Mn(i)&&Mn(s)||fe(i)&&fe(s)||Array.isArray(i)&&Array.isArray(s)?!Yt(i,s):i!==s)return!1}}return!0}var Bd=e=>e.type==="select-multiple",H1=e=>Hs(e)||lr(e),Xs=e=>Mo(e)&&e.isConnected,jd=e=>{for(const t in e)if(Ct(e[t]))return!0;return!1};function Po(e,t={}){const n=Array.isArray(e);if(fe(e)||n)for(const r in e)Array.isArray(e[r])||fe(e[r])&&!jd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Po(e[r],t[r])):Me(e[r])||(t[r]=!0);return t}function Hd(e,t,n){const r=Array.isArray(e);if(fe(e)||r)for(const o in e)Array.isArray(e[o])||fe(e[o])&&!jd(e[o])?ie(t)||Ao(n[o])?n[o]=Array.isArray(e[o])?Po(e[o],[]):{...Po(e[o])}:Hd(e[o],Me(t)?{}:t[o],n[o]):n[o]=!Yt(e[o],t[o]);return n}var qs=(e,t)=>Hd(e,t,Po(t)),Ud=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ie(e)?e:t?e===""?NaN:e&&+e:n&&Ye(e)?new Date(e):r?r(e):e;function Ws(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return js(t)?t.files:Hs(t)?Fd(e.refs).value:Bd(t)?[...t.selectedOptions].map(({value:n})=>n):lr(t)?Rd(e.refs).value:Ud(ie(t.value)?e.ref.value:t.value,e)}var U1=(e,t,n,r)=>{const o={};for(const i of e){const s=O(t,i);s&&Q(o,i,s._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},dr=e=>ie(e)?e:Co(e)?e.source:fe(e)?Co(e.value)?e.value.source:e.value:e,X1=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Xd(e,t,n){const r=O(e,n);if(r||Bs(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const i=o.join("."),s=O(t,i),a=O(e,i);if(s&&!Array.isArray(s)&&n!==i)return{name:n};if(a&&a.type)return{name:i,error:a};o.pop()}return{name:n}}var q1=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,W1=(e,t)=>!ur(O(e,t)).length&&ye(e,t);const K1={mode:ze.onSubmit,reValidateMode:ze.onChange,shouldFocusError:!0};function Y1(e={},t){let n={...K1,...e},r={submitCount:0,isDirty:!1,isLoading:Ct(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},o={},i=fe(n.defaultValues)||fe(n.values)?ct(n.defaultValues||n.values)||{}:{},s=n.shouldUnregister?{}:ct(i),a={action:!1,mount:!1,watch:!1},c={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,d=0;const l={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Us(),array:Us(),state:Us()},h=e.resetOptions&&e.resetOptions.keepDirtyValues,p=Vd(n.mode),m=Vd(n.reValidateMode),y=n.criteriaMode===ze.all,x=v=>_=>{clearTimeout(d),d=setTimeout(v,_)},g=async v=>{if(l.isValid||v){const _=n.resolver?Oe((await E()).errors):await K(o,!0);_!==r.isValid&&f.state.next({isValid:_})}},w=v=>l.isValidating&&f.state.next({isValidating:v}),M=(v,_=[],k,L,P=!0,T=!0)=>{if(L&&k){if(a.action=!0,T&&Array.isArray(O(o,v))){const F=k(O(o,v),L.argA,L.argB);P&&Q(o,v,F)}if(T&&Array.isArray(O(r.errors,v))){const F=k(O(r.errors,v),L.argA,L.argB);P&&Q(r.errors,v,F),W1(r.errors,v)}if(l.touchedFields&&T&&Array.isArray(O(r.touchedFields,v))){const F=k(O(r.touchedFields,v),L.argA,L.argB);P&&Q(r.touchedFields,v,F)}l.dirtyFields&&(r.dirtyFields=qs(i,s)),f.state.next({name:v,isDirty:B(v,_),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Q(s,v,_)},S=(v,_)=>{Q(r.errors,v,_),f.state.next({errors:r.errors})},I=(v,_,k,L)=>{const P=O(o,v);if(P){const T=O(s,v,ie(k)?O(i,v):k);ie(T)||L&&L.defaultChecked||_?Q(s,v,_?T:Ws(P._f)):re(v,T),a.mount&&g()}},N=(v,_,k,L,P)=>{let T=!1,F=!1;const ee={name:v};if(!k||L){l.isDirty&&(F=r.isDirty,r.isDirty=ee.isDirty=B(),T=F!==ee.isDirty);const le=Yt(O(i,v),_);F=O(r.dirtyFields,v),le?ye(r.dirtyFields,v):Q(r.dirtyFields,v,!0),ee.dirtyFields=r.dirtyFields,T=T||l.dirtyFields&&F!==!le}if(k){const le=O(r.touchedFields,v);le||(Q(r.touchedFields,v,k),ee.touchedFields=r.touchedFields,T=T||l.touchedFields&&le!==k)}return T&&P&&f.state.next(ee),T?ee:{}},C=(v,_,k,L)=>{const P=O(r.errors,v),T=l.isValid&&Tt(_)&&r.isValid!==_;if(e.delayError&&k?(u=x(()=>S(v,k)),u(e.delayError)):(clearTimeout(d),u=null,k?Q(r.errors,v,k):ye(r.errors,v)),(k?!Yt(P,k):P)||!Oe(L)||T){const F={...L,...T&&Tt(_)?{isValid:_}:{},errors:r.errors,name:v};r={...r,...F},f.state.next(F)}w(!1)},E=async v=>n.resolver(s,n.context,U1(v||c.mount,o,n.criteriaMode,n.shouldUseNativeValidation)),q=async v=>{const{errors:_}=await E(v);if(v)for(const k of v){const L=O(_,k);L?Q(r.errors,k,L):ye(r.errors,k)}else r.errors=_;return _},K=async(v,_,k={valid:!0})=>{for(const L in v){const P=v[L];if(P){const{_f:T,...F}=P;if(T){const ee=c.array.has(T.name),le=await zd(P,s,y,n.shouldUseNativeValidation&&!_,ee);if(le[T.name]&&(k.valid=!1,_))break;!_&&(O(le,T.name)?ee?z1(r.errors,le,T.name):Q(r.errors,T.name,le[T.name]):ye(r.errors,T.name))}F&&await K(F,_,k)}}return k.valid},j=()=>{for(const v of c.unMount){const _=O(o,v);_&&(_._f.refs?_._f.refs.every(k=>!Xs(k)):!Xs(_._f.ref))&&Ze(v)}c.unMount=new Set},B=(v,_)=>(v&&_&&Q(s,v,_),!Yt(Re(),i)),H=(v,_,k)=>D1(v,c,{...a.mount?s:ie(_)?i:Ye(v)?{[v]:_}:_},k,_),X=v=>ur(O(a.mount?s:i,v,e.shouldUnregister?O(i,v,[]):[])),re=(v,_,k={})=>{const L=O(o,v);let P=_;if(L){const T=L._f;T&&(!T.disabled&&Q(s,v,Ud(_,T)),P=Mo(T.ref)&&Me(_)?"":_,Bd(T.ref)?[...T.ref.options].forEach(F=>F.selected=P.includes(F.value)):T.refs?lr(T.ref)?T.refs.length>1?T.refs.forEach(F=>(!F.defaultChecked||!F.disabled)&&(F.checked=Array.isArray(P)?!!P.find(ee=>ee===F.value):P===F.value)):T.refs[0]&&(T.refs[0].checked=!!P):T.refs.forEach(F=>F.checked=F.value===P):js(T.ref)?T.ref.value="":(T.ref.value=P,T.ref.type||f.values.next({name:v,values:{...s}})))}(k.shouldDirty||k.shouldTouch)&&N(v,P,k.shouldTouch,k.shouldDirty,!0),k.shouldValidate&&Y(v)},se=(v,_,k)=>{for(const L in _){const P=_[L],T=`${v}.${L}`,F=O(o,T);(c.array.has(v)||!Ao(P)||F&&!F._f)&&!Mn(P)?se(T,P,k):re(T,P,k)}},Le=(v,_,k={})=>{const L=O(o,v),P=c.array.has(v),T=ct(_);Q(s,v,T),P?(f.array.next({name:v,values:{...s}}),(l.isDirty||l.dirtyFields)&&k.shouldDirty&&f.state.next({name:v,dirtyFields:qs(i,s),isDirty:B(v,T)})):L&&!L._f&&!Me(T)?se(v,T,k):re(v,T,k),Od(v,c)&&f.state.next({...r}),f.values.next({name:v,values:{...s}}),!a.mount&&t()},Ne=async v=>{const _=v.target;let k=_.name,L=!0;const P=O(o,k),T=()=>_.type?Ws(P._f):V1(v),F=ee=>{L=Number.isNaN(ee)||ee===O(s,k,ee)};if(P){let ee,le;const Lo=T(),Cn=v.type===Ad.BLUR||v.type===Ad.FOCUS_OUT,xy=!X1(P._f)&&!n.resolver&&!O(r.errors,k)&&!P._f.deps||q1(Cn,O(r.touchedFields,k),r.isSubmitted,m,p),Ks=Od(k,c,Cn);Q(s,k,Lo),Cn?(P._f.onBlur&&P._f.onBlur(v),u&&u(0)):P._f.onChange&&P._f.onChange(v);const Ys=N(k,Lo,Cn,!1),ky=!Oe(Ys)||Ks;if(!Cn&&f.values.next({name:k,type:v.type,values:{...s}}),xy)return l.isValid&&g(),ky&&f.state.next({name:k,...Ks?{}:Ys});if(!Cn&&Ks&&f.state.next({...r}),w(!0),n.resolver){const{errors:ef}=await E([k]);if(F(Lo),L){const $y=Xd(r.errors,o,k),tf=Xd(ef,o,$y.name||k);ee=tf.error,k=tf.name,le=Oe(ef)}}else ee=(await zd(P,s,y,n.shouldUseNativeValidation))[k],F(Lo),L&&(ee?le=!1:l.isValid&&(le=await K(o,!0)));L&&(P._f.deps&&Y(P._f.deps),C(k,le,ee,Ys))}},ut=(v,_)=>{if(O(r.errors,_)&&v.focus)return v.focus(),1},Y=async(v,_={})=>{let k,L;const P=zs(v);if(w(!0),n.resolver){const T=await q(ie(v)?v:P);k=Oe(T),L=v?!P.some(F=>O(T,F)):k}else v?(L=(await Promise.all(P.map(async T=>{const F=O(o,T);return await K(F&&F._f?{[T]:F}:F)}))).every(Boolean),!(!L&&!r.isValid)&&g()):L=k=await K(o);return f.state.next({...!Ye(v)||l.isValid&&k!==r.isValid?{}:{name:v},...n.resolver||!v?{isValid:k}:{},errors:r.errors,isValidating:!1}),_.shouldFocus&&!L&&So(o,ut,v?P:c.mount),L},Re=v=>{const _={...i,...a.mount?s:{}};return ie(v)?_:Ye(v)?O(_,v):v.map(k=>O(_,k))},At=(v,_)=>({invalid:!!O((_||r).errors,v),isDirty:!!O((_||r).dirtyFields,v),isTouched:!!O((_||r).touchedFields,v),error:O((_||r).errors,v)}),Pt=v=>{v&&zs(v).forEach(_=>ye(r.errors,_)),f.state.next({errors:v?r.errors:{}})},Gt=(v,_,k)=>{const L=(O(o,v,{_f:{}})._f||{}).ref;Q(r.errors,v,{..._,ref:L}),f.state.next({name:v,errors:r.errors,isValid:!1}),k&&k.shouldFocus&&L&&L.focus&&L.focus()},Ge=(v,_)=>Ct(v)?f.values.subscribe({next:k=>v(H(void 0,_),k)}):H(v,_,!0),Ze=(v,_={})=>{for(const k of v?zs(v):c.mount)c.mount.delete(k),c.array.delete(k),_.keepValue||(ye(o,k),ye(s,k)),!_.keepError&&ye(r.errors,k),!_.keepDirty&&ye(r.dirtyFields,k),!_.keepTouched&&ye(r.touchedFields,k),!n.shouldUnregister&&!_.keepDefaultValue&&ye(i,k);f.values.next({values:{...s}}),f.state.next({...r,..._.keepDirty?{isDirty:B()}:{}}),!_.keepIsValid&&g()},Vo=({disabled:v,name:_,field:k,fields:L,value:P})=>{if(Tt(v)){const T=v?void 0:ie(P)?Ws(k?k._f:O(L,_)._f):P;Q(s,_,T),N(_,T,!1,!1,!0)}},Zt=(v,_={})=>{let k=O(o,v);const L=Tt(_.disabled);return Q(o,v,{...k||{},_f:{...k&&k._f?k._f:{ref:{name:v}},name:v,mount:!0,..._}}),c.mount.add(v),k?Vo({field:k,disabled:_.disabled,name:v}):I(v,!0,_.value),{...L?{disabled:_.disabled}:{},...n.progressive?{required:!!_.required,min:dr(_.min),max:dr(_.max),minLength:dr(_.minLength),maxLength:dr(_.maxLength),pattern:dr(_.pattern)}:{},name:v,onChange:Ne,onBlur:Ne,ref:P=>{if(P){Zt(v,_),k=O(o,v);const T=ie(P.value)&&P.querySelectorAll&&P.querySelectorAll("input,select,textarea")[0]||P,F=H1(T),ee=k._f.refs||[];if(F?ee.find(le=>le===T):T===k._f.ref)return;Q(o,v,{_f:{...k._f,...F?{refs:[...ee.filter(Xs),T,...Array.isArray(O(i,v))?[{}]:[]],ref:{type:T.type,name:v}}:{ref:T}}}),I(v,!1,void 0,T)}else k=O(o,v,{}),k._f&&(k._f.mount=!1),(n.shouldUnregister||_.shouldUnregister)&&!(L1(c.array,v)&&a.action)&&c.unMount.add(v)}}},Jt=()=>n.shouldFocusError&&So(o,ut,c.mount),dt=v=>{Tt(v)&&(f.state.next({disabled:v}),So(o,_=>{_.disabled=v},0,!1))},fr=(v,_)=>async k=>{k&&(k.preventDefault&&k.preventDefault(),k.persist&&k.persist());let L=ct(s);if(f.state.next({isSubmitting:!0}),n.resolver){const{errors:P,values:T}=await E();r.errors=P,L=T}else await K(o);ye(r.errors,"root"),Oe(r.errors)?(f.state.next({errors:{}}),await v(L,k)):(_&&await _({...r.errors},k),Jt(),setTimeout(Jt)),f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Oe(r.errors),submitCount:r.submitCount+1,errors:r.errors})},Oo=(v,_={})=>{O(o,v)&&(ie(_.defaultValue)?Le(v,O(i,v)):(Le(v,_.defaultValue),Q(i,v,_.defaultValue)),_.keepTouched||ye(r.touchedFields,v),_.keepDirty||(ye(r.dirtyFields,v),r.isDirty=_.defaultValue?B(v,O(i,v)):B()),_.keepError||(ye(r.errors,v),l.isValid&&g()),f.state.next({...r}))},Jd=(v,_={})=>{const k=v?ct(v):i,L=ct(k),P=v&&!Oe(v)?L:i;if(_.keepDefaultValues||(i=k),!_.keepValues){if(_.keepDirtyValues||h)for(const T of c.mount)O(r.dirtyFields,T)?Q(P,T,O(s,T)):Le(T,O(P,T));else{if(Ds&&ie(v))for(const T of c.mount){const F=O(o,T);if(F&&F._f){const ee=Array.isArray(F._f.refs)?F._f.refs[0]:F._f.ref;if(Mo(ee)){const le=ee.closest("form");if(le){le.reset();break}}}}o={}}s=e.shouldUnregister?_.keepDefaultValues?ct(i):{}:ct(P),f.array.next({values:{...P}}),f.values.next({values:{...P}})}c={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!a.mount&&t(),a.mount=!l.isValid||!!_.keepIsValid,a.watch=!!e.shouldUnregister,f.state.next({submitCount:_.keepSubmitCount?r.submitCount:0,isDirty:_.keepDirty?r.isDirty:!!(_.keepDefaultValues&&!Yt(v,i)),isSubmitted:_.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:_.keepDirtyValues?r.dirtyFields:_.keepDefaultValues&&v?qs(i,v):{},touchedFields:_.keepTouched?r.touchedFields:{},errors:_.keepErrors?r.errors:{},isSubmitSuccessful:_.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Qd=(v,_)=>Jd(Ct(v)?v(s):v,_);return{control:{register:Zt,unregister:Ze,getFieldState:At,handleSubmit:fr,setError:Gt,_executeSchema:E,_getWatch:H,_getDirty:B,_updateValid:g,_removeUnmounted:j,_updateFieldArray:M,_updateDisabledField:Vo,_getFieldArray:X,_reset:Jd,_resetDefaultValues:()=>Ct(n.defaultValues)&&n.defaultValues().then(v=>{Qd(v,n.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:v=>{r={...r,...v}},_disableForm:dt,_subjects:f,_proxyFormState:l,get _fields(){return o},get _formValues(){return s},get _state(){return a},set _state(v){a=v},get _defaultValues(){return i},get _names(){return c},set _names(v){c=v},get _formState(){return r},set _formState(v){r=v},get _options(){return n},set _options(v){n={...n,...v}}},trigger:Y,register:Zt,handleSubmit:fr,watch:Ge,setValue:Le,getValues:Re,reset:Qd,resetField:Oo,clearErrors:Pt,unregister:Ze,setError:Gt,setFocus:(v,_={})=>{const k=O(o,v),L=k&&k._f;if(L){const P=L.refs?L.refs[0]:L.ref;P.focus&&(P.focus(),_.shouldSelect&&P.select())}},getFieldState:At}}function qd(e={}){const t=De.useRef(),n=De.useRef(),[r,o]=De.useState({isDirty:!1,isValidating:!1,isLoading:Ct(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:Ct(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Y1(e,()=>o(s=>({...s}))),formState:r});const i=t.current.control;return i._options=e,F1({subject:i._subjects.state,next:s=>{I1(s,i._proxyFormState,i._updateFormState,!0)&&o({...i._formState})}}),De.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),De.useEffect(()=>{if(i._proxyFormState.isDirty){const s=i._getDirty();s!==r.isDirty&&i._subjects.state.next({isDirty:s})}},[i,r.isDirty]),De.useEffect(()=>{e.values&&!Yt(e.values,n.current)?(i._reset(e.values,i._options.resetOptions),n.current=e.values):i._resetDefaultValues()},[e.values,i]),De.useEffect(()=>{i._state.mount||(i._updateValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=R1(r,i),t.current}var Wd=function(e,t,n){if(e&&"reportValidity"in e){var r=O(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},G1=function(e,t){var n=function(o){var i=t.fields[o];i&&i.ref&&"reportValidity"in i.ref?Wd(i.ref,o,e):i.refs&&i.refs.forEach(function(s){return Wd(s,o,e)})};for(var r in t.fields)n(r)},Z1=function(e,t){t.shouldUseNativeValidation&&G1(e,t);var n={};for(var r in e){var o=O(t.fields,r),i=Object.assign(e[r]||{},{ref:o&&o.ref});if(Q1(t.names||Object.keys(e),r)){var s=Object.assign({},J1(O(n,r)));Q(s,"root",i),Q(n,r,s)}else Q(n,r,i)}return n},J1=function(e){return Array.isArray(e)?e.filter(Boolean):[]},Q1=function(e,t){return e.some(function(n){return n.startsWith(t+".")})},ey=function(e,t){for(var n={};e.issues.length;){var r=e.issues[0];if(r.path){var o=r.path.map(function(a){return a.key}).join(".");if(n[o]||(n[o]={message:r.message,type:r.validation}),t){var i=n[o].types,s=i&&i[r.validation];n[o]=Ed(o,t,n,r.validation,s?[].concat(s,r.message):r.message)}e.issues.shift()}}return n},Kd=function(e,t,n){return n===void 0&&(n={}),function(r,o,i){try{return Promise.resolve(function(s,a){try{var c=function(){function u(l){return{values:n.raw?r:l,errors:{}}}var d=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},t);return n.mode==="sync"?u(rs(e,r,d)):Promise.resolve(og(e,r,d)).then(u)}()}catch(u){return a(u)}return c&&c.then?c.then(void 0,a):c}(0,function(s){if(s instanceof so)return{values:{},errors:Z1(ey(s,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw s}))}catch(s){return Promise.reject(s)}}};const ty=e=>{const t=Object.fromEntries(new FormData(e).entries());Object.keys(t).length&&e.dispatchEvent(new Event("submit",{bubbles:!0}))},ny=ts("multiple-choice"),ry=e=>{const t={min:e.minSelected??0,max:e.maxSelected??e.options.length};return Kd(bn({checked:ku(rg(Zv()),n=>Object.entries(n).filter(([r,o])=>o).map(([r,o])=>r),[ag(t.max,`Please select at most ${t.max} option${t.max!==1?"s":""}`),$u(t.min,`Please select at least ${t.min} option${t.min!==1?"s":""}`)])}))},oy=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var u,d;const r=e.key?(u=ne.current$.value.application)==null?void 0:u.data.submissions[e.key]:void 0,{register:o,handleSubmit:i,formState:{errors:s}}=qd({defaultValues:{checked:ny(r)?Object.fromEntries(r.value.map(l=>[l,!0])):{}},resolver:ry(e.config)}),a=Is(),c=e.config.minSelected===1&&e.config.maxSelected===1;return b("form",{noValidate:!0,class:"flex flex-col gap-1",onChange:l=>{c&&ty(l.currentTarget)},onSubmit:i(l=>{const f=l.checked;t(f)}),children:[b("div",{class:"flex items-center gap-2",children:[b("div",{class:Xt("flex w-full flex-1 flex-wrap gap-3 p-1",{"justify-center":e.config.options.length===1}),children:e.config.options.map((l,f)=>{const h=`checked.${l.value}`,{ref:p,...m}=o(h);return b("div",{children:[b("input",{autoFocus:f===0,ref:y=>{y&&f===0&&(a.current=y),p(y)},id:h,...m,class:"peer sr-only",type:"checkbox"}),b("label",{class:"bg-lowest peer-focus-visible:ring-accent-7 active:outline-neutral-10 ease-expo-out outline-neutral-12/5 text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 duration-snappy block rounded-2xl px-2.5 py-1 outline outline-2 ring-0 ring-transparent transition-all selection:bg-transparent peer-focus-visible:ring-4 peer-focus-visible:ring-offset-2",htmlFor:h,children:l.label})]},l.value)})}),!c&&b(ko,{})]}),b(Fs,{onAnimationComplete:n,error:(d=s.checked)==null?void 0:d.root})]})},Eo={email:"That doesn’t look like a valid email address",phone:"That doesn’t look like a valid phone number"},iy=We(Eo.phone,[cg(/^\+?[0-9 -]+$/,Eo.phone)]),sy={email:We(Eo.email,[sg(Eo.email)]),phone:ku(iy,e=>e.replace(/[^0-9]/g,"")),text:We([$u(1,"Please enter some text")]),url:We([lg("That doesn’t look like a valid URL")])},ay={email:{type:"email",inputMode:"email",formNoValidate:!0},phone:{type:"tel",inputMode:"tel"},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},cy=ts("text"),ly=e=>Kd(bn({text:sy[e.format]})),uy=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var d;const r=e.key?(d=ne.current$.value.application)==null?void 0:d.data.submissions[e.key]:void 0,{register:o,handleSubmit:i,formState:{errors:s}}=qd({defaultValues:{text:cy(r)?r.value:""},resolver:ly(e.config)}),{ref:a,...c}=o("text",{required:!0}),u=U();return Be(()=>{u.current&&(u.current.focus(),u.current.select())},[]),b("form",{noValidate:!0,class:"flex flex-col gap-1",onSubmit:i(l=>{t(l.text)}),children:[b("div",{class:"flex items-center gap-2",children:[b("input",{id:"chat-input",...c,...ay[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:l=>{l&&(u.current=l),a(l)},class:"outline-neutral-12/5 ease-expo-out placeholder:text-neutral-5 focus-visible:outline-accent-7 caret-accent-9 duration-snappy flex-grow rounded-full px-3 py-1 text-base outline outline-2 transition-all",placeholder:e.config.placeholder}),b(ko,{})]}),b(Fs,{onAnimationComplete:n,error:s.text})]})},dy=({onSubmit:e,onInputChange:t,input:n})=>{const r=U(null),o=me(()=>{r.current&&(ns.value=r.current.getBoundingClientRect().height)},[]);G(()=>{o(),t(n==null?void 0:n.type)},[n==null?void 0:n.type,t,o]);const i=s=>a=>e({type:s,value:a});return b(Kn.div,{initial:{height:0},animate:{height:ns.value},exit:{height:0,opacity:0},class:"bg-neutral-2/80 absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-md backdrop-saturate-150",children:b("div",{ref:r,class:"border-neutral-12/5 border-t p-2.5",children:nt({application:ne,input:n,onHeightChange:o}).with({input:Ae.nullish},()=>b("div",{class:"flex items-center gap-2",children:[b("input",{"aria-hidden":"true",id:"chat-input",class:"outline-neutral-12/5 placeholder:text-neutral-4 focus-visible:outline-accent-9 caret-accent-9 flex-grow rounded-full px-3 py-1 text-base outline outline-2",disabled:!0}),b(ko,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})).with({input:{type:"text"}},s=>b(uy,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"multiple-choice"}},s=>b(oy,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"boolean"}},s=>b(M1,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"file"}},s=>b(E1,{onSubmitSuccess:i(s.input.type),...s})).exhaustive()})})},Yd=e=>typeof e=="boolean"?"".concat(e):e===0?"0":e,Gd=Xt,Zd=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Gd(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const d=n==null?void 0:n[u],l=i==null?void 0:i[u];if(d===null)return null;const f=Yd(d)||Yd(l);return o[u][f]}),a=n&&Object.entries(n).reduce((u,d)=>{let[l,f]=d;return f===void 0||(u[l]=f),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:l,className:f,...h}=d;return Object.entries(h).every(p=>{let[m,y]=p;return Array.isArray(y)?y.includes({...i,...a}[m]):{...i,...a}[m]===y})?[...u,l,f]:u},[]);return Gd(e,s,c,n==null?void 0:n.class,n==null?void 0:n.className)},fy=Zd("max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink-1 min-w-[2rem] text-md py-2 px-3 rounded-[18px] min-h-[36px] break-words",{variants:{side:{left:"bg-lowest text-neutral-12 shadow-surface-sm outline outline-1 outline-neutral-11/[.08] rounded-bl-md",right:"ml-auto bg-accent-7 text-lowest rounded-br-md bubble-right"},transitionState:{entering:"opacity-0 translate-y-8",entered:"opacity-100 translate-y-0",exiting:"opacity-0 scale-0",exited:""}},defaultVariants:{side:"left"}}),hy={hidden:{y:"100%",scale:.75},shown:{y:0,scale:1}},py=({children:e,className:t,transitionState:n,side:r,...o})=>b(Kn.p,{variants:hy,initial:"hidden",animate:"shown",transition:{type:"spring",damping:25,stiffness:500},"data-transition":n,style:{transformOrigin:r==="left"?"0% 50%":"100% 50%"},class:fy({className:t,side:r,transitionState:n}),...o,children:e}),my=({className:e,...t})=>b("div",{"aria-label":"Typing…",class:Xt("flex gap-1 p-4",e),...t,children:Array.from({length:3},(n,r)=>b("div",{class:"bg-accent-7 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-r*200}ms`}}))}),vy={bot:"left",user:"right"},gy=Zd("w-full select-none py-2 text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_white]",{variants:{variant:{info:"text-neutral-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),by=({messages:e,isBotTyping:t})=>b("ol",{"aria-label":"Chat messages",class:"flex flex-grow flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[b(to,{initial:!1,children:e.map((n,r)=>b("li",{class:"flex",children:nt(n).with({type:"system"},o=>b("p",{class:gy({variant:o.variant}),children:o.text})).with({type:"text",author:Ae.union("bot","user")},o=>b(py,{side:vy[o.author],children:o.text},r)).with({type:"link"},o=>b("div",{class:"bg-accent-8/5 flex w-full items-center justify-center overflow-hidden rounded-xl py-2",children:b("a",{class:"bg-lowest shadow-surface-sm ring-accent-8/20 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 flex items-center gap-1.5 truncate rounded-full py-2 pl-4 pr-2.5 no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:o.href,children:[o.text,b("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b("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"})})]})})).with({type:"image"},o=>b("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:o.url,style:{aspectRatio:o.width/o.height}})).with({type:"file"},o=>b(P1,{class:o.author==="bot"?"":"ml-auto",file:{name:o.fileName,sizeKb:o.fileSizeKb}})).exhaustive()},r))}),b("aside",{"aria-hidden":!0,children:t&&b(my,{})})]}),yy=25,wy=()=>{const e=U(null),[t,n]=ae(!1),[r,o]=ae(()=>()=>{}),i=de(()=>a=>{var c;return(c=e.current)==null?void 0:c.scrollTo({top:e.current.scrollHeight,...a})},[e]),s=de(()=>({send:async({message:a,signal:c,groupId:u})=>{if(await nt(a).with({author:"bot",type:"text"},async d=>{if(c!=null&&c.aborted)throw new Jn;n(!0);const l=Math.min(Math.max(20,d.text.length),100)*yy;await new Promise(f=>setTimeout(f,l,{signal:c})),n(!1)}).otherwise(async()=>{}),c!=null&&c.aborted)throw new Jn;ne.addMessage(a,u)},input:async({input:a,signal:c})=>{if(c!=null&&c.aborted)throw new Jn;return ne.setInput(a),await new Promise(u=>{const d=l=>{if(c!=null&&c.aborted)throw new Jn;ne.setInput(void 0),a.key&&ne.setSubmission(a.key,l),u(l)};o(()=>d)})}}),[]);return{chatRef:e,chatService:s,isBotTyping:t,onSubmitSuccessFn:r,scrollToEnd:i}},_y=Object.freeze(Object.defineProperty({__proto__:null,JobApplicationContent:({currentApplication:e,logger:t,apiClient:n,analytics:r})=>{const{chatRef:o,chatService:i,isBotTyping:s,onSubmitSuccessFn:a,scrollToEnd:c}=wy(),u=rt.value,d=e.flow,l=e.job;return Be(()=>{u==="maximised"&&c({behavior:"instant"})},[c,u]),G(()=>{c({behavior:"smooth"})},[e.data.messages,c]),Be(()=>{const{state:f,application:h}=ne.current$.peek();if(f!=="loaded")throw new Error(Vv.invalid_state);const p=h.data.currentNodeId;if(c({behavior:"instant"}),ne.setInput(void 0),h.data.isFinished)return;ne.removeLastGroupMessagesById(p);const{interpret:m,abort:y}=l1({context:{jobId:l.id,flowId:d.id},analytics:r,apiClient:n,logger:t,flow:d.nodes,chatService:i,getSubmissions:()=>{var x;return(x=ne.current$.peek().application)==null?void 0:x.data.submissions},onInterpret:(x,g)=>{const w=ne.current$.peek().application;rn(w),w.data.sequence=w.data.sequence+1,r.log({event:"FLOW_NODE",attributionKey:`job_${l.id}`,properties:{flow_id:d.id,flow_version:d.version,job_id:l.id,from_node_id:g?g.id:null,to_node_id:x.id,sequence:w.data.sequence,flow_session_id:w.data.flowSessionId}}),ne.setCurrentNodeId(x.id)},onFlowEnd:async()=>{ne.markAsFinished()}});return m(p),y},[r,n,i,t,c,d,l.id,e.startedAt]),b(ue,{children:[b("div",{ref:o,className:"hide-scrollbars relative flex max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:ns.value},children:b(to,{children:b(by,{isBotTyping:s,messages:e.data.messages})})}),b(dy,{input:e.data.currentInput,onInputChange:()=>c({behavior:"smooth"}),onSubmit:a})]})}},Symbol.toStringTag,{value:"Module"}))})();
57
+ }`,a1=({_internal_domManager:e=hg(),theme:t})=>Et(({apiClient:n,logger:r,analytics:o})=>{let i=!1;const s=()=>{if(typeof window>"u")return;const a=e.getOrCreateChatbotElement();e.addStyle(fg,"inploi-chatbot-style");const c=s1([{name:"a",colors:xd(t)},{name:"n",colors:xd({hue:t.hue,chroma:.1})}]);e.addStyle(c,"inploi-chatbot-theme"),en(R(Hv,{apiClient:n,logger:r,analytics:o}),a),i=!0};return{prepare:async()=>{if(!(typeof window>"u"))try{if(i)return;s(),r.info("Chatbot plugin prepared")}catch(a){console.error(a),r.error("Error preparing chatbot plugin",a)}},startApplication:async({jobId:a})=>{if(!(typeof window>"u"))try{ne.cancel(),pf(()=>{rt.value="maximised",ne.current$.value={state:"loading"}}),dg({jobId:a,apiClient:n,logger:r}).then(async c=>{c.ok?(await o.log({event:"APPLY_START",attributionKey:`job_${a}`,properties:{job_id:a,flow_id:c.value.flow.id}}).catch(r.error),ne.start(c.value)):ne.current$.value={state:"error",error:c.error}}),i||s()}catch(c){console.error(c),r.error("Error starting application",c)}},closeApplication:async()=>{typeof window>"u"||(r.info("Closing application from an external source"),ne.cancel())}}});if(!window.inploi)throw new Error("Please insert the SDK script tag above the plugins.");window.inploi.chatbotPlugin=a1;const kd=({node:e,nodes:t,stopWhen:n})=>{if((n==null?void 0:n(e))===!0)return e;const r=e.nextId?t.find(o=>o.id===e.nextId):void 0;if(r)return kd({node:r,nodes:t,stopWhen:n})},c1=({childNode:e,nodes:t})=>{const r=t.filter(o=>o.type==="if-block").find(o=>{if(!o.branchId)return!1;const i=t.find(a=>a.id===o.branchId);if(!i)return!1;const s=kd({node:i,nodes:t,stopWhen:a=>a.id===e.id});return!(!s||s.id!==e.id)});if(r!=null&&r.nextId)return t.find(o=>o.id===r.nextId)},l1=({flow:e,analytics:t,logger:n,context:r,apiClient:o,getSubmissions:i,chatService:s,onFlowEnd:a,onInterpret:c})=>{const u=new AbortController,d=async(l,f)=>{const h=i();c==null||c(l,f);try{await u1({analytics:t,logger:n,apiClient:o,context:r,node:l,submissions:h,chat:{sendMessage:async p=>s.send({groupId:l.id,message:p,signal:u.signal}),userInput:async p=>s.input({input:p,signal:u.signal})},next:p=>{const m=p?e.find(y=>y.id===p):c1({childNode:l,nodes:e});return m?d(m,l):a==null?void 0:a(l)},end:()=>a==null?void 0:a(l)})}catch(p){if(p instanceof Jn)return;throw p}};return{interpret:async l=>{const f=e.find(h=>h.id===l)??vu(e);return d(f)},abort:()=>{u.abort()}}};async function u1(e){return await nt(e).with({node:{type:"text"}},p1).with({node:{type:"image"}},m1).with({node:{type:"question-text"}},v1).with({node:{type:"question-enum"}},b1).with({node:{type:"question-number"}},g1).with({node:{type:"question-boolean"}},y1).with({node:{type:"question-file"}},_1).with({node:{type:"question-address"}},w1).with({node:{type:"end-flow"}},x1).with({node:{type:"if-block"}},h1).with({node:{type:"jump"}},({node:t,next:n})=>n(t.data.targetId)).with({node:{type:"link"}},f1).with({node:{type:"integration-application-submit"}},d1).with({node:{type:"integration-workflow-get"}},()=>Error("Unreachable")).exhaustive()}async function d1({chat:e,next:t,node:n,logger:r,apiClient:o,submissions:i,context:s,analytics:a}){await e.userInput({type:"multiple-choice",key:void 0,config:{options:[{label:"Submit my application",value:"submit"}],maxSelected:1,minSelected:1}});const c=()=>{const d=typeof s.jobId=="string"?s.jobId:void 0,l=typeof s.flowId=="string"?s.flowId:void 0;rn(d),rn(l),d&&a.log({event:"APPLY_COMPLETE",attributionKey:`job_${d}`,properties:{job_id:d,flow_id:l}})};await e.sendMessage({type:"system",variant:"info",text:"Submitting your application…"});const u=await o.fetch("/flow/apply",{method:"POST",body:JSON.stringify({...s,type:n.data.type,ats:n.data.ats,integration_id:n.data.integrationId,anonymous_id:a.getAnonymousId(),submissions:Nv(i||{})})}).catch(d=>d);await nt(u).with({ats_data:{redirect_url:Ae.string}},async d=>{await e.sendMessage({type:"text",author:"bot",text:"Almost there! Please finalise your application on our partner’s website."});const l=a.getAnonymousId(),f=new URL(d.ats_data.redirect_url);l&&!f.searchParams.has("anonymous_id")&&f.searchParams.set("anonymous_id",l),c(),await e.sendMessage({type:"link",href:f.toString(),text:"Finalise application on partner"})}).with({success:!0},async()=>{c(),await e.sendMessage({type:"system",variant:"success",text:"Application submitted"}),t(n.nextId)}).otherwise(async d=>{r.error(d),await e.sendMessage({type:"system",variant:"error",text:"Failed to submit application"}),t(n.id)})}async function f1({chat:e,next:t,node:n}){await e.sendMessage({type:"link",href:n.data.href,text:n.data.cta}),t(n.nextId)}async function h1({submissions:e,next:t,node:n}){const r=k1(n,e)?n.branchId:n.nextId;t(r)}async function p1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.text}),t(n.nextId)}async function m1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"image",url:n.data.url,height:n.data.height,width:n.data.width}),t(n.nextId)}async function v1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"text",config:{placeholder:n.data.placeholder,format:n.data.format}});await e.sendMessage({author:"user",type:"text",text:r.value}),t(n.nextId)}async function g1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"text",config:{placeholder:n.data.placeholder,format:"text"}});await e.sendMessage({author:"user",type:"text",text:r.value}),t(n.nextId)}async function b1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"multiple-choice",config:n.data});await e.sendMessage({author:"user",type:"text",text:n.data.options.filter(o=>r.value.includes(o.value)).map(o=>o.label).join(", ")}),t(n.nextId)}async function y1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const o=(await e.userInput({key:n.data.key,type:"boolean",config:{labels:{true:n.data.trueLabel,false:n.data.falseLabel}}})).value,i={true:n.data.trueLabel,false:n.data.falseLabel};await e.sendMessage({author:"user",type:"text",text:i[o]}),t(n.nextId)}async function w1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:"Address questions are not implemented yet"}),t(n.nextId)}async function _1({node:e,chat:t,next:n}){await t.sendMessage({author:"bot",type:"text",text:e.data.question});const r=await t.userInput({key:e.data.key,type:"file",config:{extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb??10*1024,allowMultiple:e.data.multiple===!0}});for await(const o of r.value)await t.sendMessage({author:"user",type:"file",fileName:o.name,fileSizeKb:o.sizeKb});n(e.nextId)}async function x1({chat:e,end:t,node:n}){var r;await e.sendMessage({type:"system",variant:"info",text:((r=n.data)==null?void 0:r.systemMessage)??"Conversation finished"}),t()}const $d=Ae.union(Ae.string,Ae.array(Ae.string)),k1=(e,t)=>{const n=t==null?void 0:t[e.data.compareKey];return n?nt({...e.data,answer:n}).with({compare:"equals"},({compareValue:r})=>typeof n.value=="string"||typeof n.value=="boolean"?r===n.value.toString():!1).with({compare:"notEquals"},({compareValue:r})=>typeof n.value=="string"||typeof n.value=="boolean"?r!==n.value.toString():!1).with({compare:"contains",answer:{value:$d}},({compareValue:r,answer:o})=>o.value.includes(r)).with({compare:"notContains",answer:{value:$d}},({compareValue:r,answer:o})=>!o.value.includes(r)).with({answer:{type:"file"}},()=>!1).exhaustive():!1},ko=({class:e,...t})=>b("button",{class:Xt("bg-accent-7 active:bg-accent-10 active:text-accent-2 text-lowest pointer-coarse:touch-hitbox focus-visible:ring-accent-7/50 flex-shrink-0 rounded-full p-2 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:b("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[b("title",{children:"Send"}),b("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),b("path",{d:"M8 4V13"})]})}),Is=()=>{const e=U(null);return G(()=>{var t;(t=e.current)==null||t.focus()},[]),e},Sd=["true","false"],$1=eg(Sd),S1="answer",M1=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{const r=Is();return n(),b("form",{noValidate:!0,class:"flex items-center gap-2",onSubmit:o=>{o.preventDefault();const i=nt(o).with({nativeEvent:{submitter:Ae.select(Ae.union(Ae.instanceOf(HTMLButtonElement),Ae.instanceOf(HTMLInputElement)))}},a=>a.value).otherwise(()=>{throw new Error("invalid form")}),s=rs($1,i);t(s)},children:Sd.map((o,i)=>b("button",{ref:i===0?r:null,type:"submit",name:S1,value:o,class:"bg-lowest ease-expo-out ring-neutral-12/5 text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr duration-snappy block flex-1 overflow-hidden rounded-2xl px-2.5 py-2.5 ring-2 transition-all selection:bg-transparent",children:b("p",{class:"truncate text-center text-base",children:e.config.labels[o]})}))})},Fs=({error:e,onAnimationComplete:t})=>b(to,{children:e&&b(Kn.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},onAnimationComplete:t,role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full p-0.5 px-1 opacity-0",children:[b("svg",{class:"text-error-10",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),b("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),b("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),b("p",{class:"truncate pr-1 text-sm",children:e.message})]})}),T1=e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>r.result?t(r.result.toString()):n("No result from reader"),r.onerror=n}),$o=e=>nt(e).with(Ae.number.lte(1e3),()=>`${Math.round(e)}KB`).with(Ae.number.lt(1e3*10),()=>`${(e/1e3).toFixed(1)}MB`).otherwise(()=>`${Math.round(e/1e3)}MB`),C1=e=>e.reduce((t,n)=>t+n.sizeKb,0),A1=ts("file"),Md=3,P1=({file:e,class:t,...n})=>{const r=e.name.split(".").pop(),o=e.name.replace(new RegExp(`.${r}$`),"");return b("div",{class:Xt("bg-accent-1 outline-neutral-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",t),...n,children:[b("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[b("span",{class:"block truncate",children:o}),b("span",{children:[".",r]})]}),b("p",{"aria-label":"File size",class:"text-neutral-10",children:$o(e.sizeKb)})]})},Td=({class:e,...t})=>b("li",{class:Xt("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...t}),E1=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var l;const r=(l=ne.current$.value.application)==null?void 0:l.data.submissions[e.key],[o,i]=ae(A1(r)?r.value:[]),[s,a]=ae(),c=o.length-Md,u=C1(o),d=Is();return b("form",{class:"flex flex-col gap-1",onSubmit:f=>(f.preventDefault(),a(void 0),o.length===0?a({type:"required",message:"Please select a file"}):e.config.fileSizeLimitKib&&u>e.config.fileSizeLimitKib?a({type:"max",message:`File size exceeds limit of ${$o(e.config.fileSizeLimitKib)}`}):e.config.allowMultiple===!1&&o.length>1?a({type:"invalid",message:"Only one file is allowed"}):t(o)),children:[b("div",{class:"flex items-center gap-2",children:[b("label",{ref:d,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:[o.length>0?b(ue,{children:[b("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[o.slice(0,Md).map(f=>{const h=f.name.split(".").pop(),p=f.name.replace(new RegExp(`.${h}$`),"");return b(Td,{class:"flex overflow-hidden",children:[b("span",{class:"block truncate",children:p}),b("span",{children:[".",h]})]})}),c>0?b(Td,{children:["+",c," file",c!==1?"s":""]}):null]}),b("p",{class:"text-neutral-11 text-xs",children:[$o(u)," ",o.length>1?"total":""]})]}):b("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[b("header",{class:"flex flex-col items-center gap-0",children:[b("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:b("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"})}),b("p",{class:"text-neutral-12 tracking-[-0.01em] dark:text-gray-400",children:[e.config.allowMultiple?"Select files":"Select a file"," to upload"]}),e.config.fileSizeLimitKib?b("p",{class:"text-neutral-10 text-xs",children:["(max ",$o(e.config.fileSizeLimitKib),")"]}):null]}),b("aside",{class:"flex flex-col items-center gap-2",children:[b("p",{id:"accepted-filetypes",class:"sr-only",children:"Accepted file extensions"}),b("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(f=>b("li",{class:"ring-lowest outline-neutral-6 text-neutral-9 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",children:f.replace(".","")}))})]})]}),b("input",{id:"dropzone-file",onInput:async f=>{rn(f.target instanceof HTMLInputElement);const h=f.target.files?Array.from(f.target.files):[],p=await Promise.allSettled(h.map(async y=>{const x=await T1(y);return{name:y.name,data:x,sizeKb:y.size/1e3}}));if(p.some(({status:y})=>y==="rejected"))return a({type:"invalid",message:"Invalid file"});const m=p.map(y=>y.status==="fulfilled"?y.value:null).filter(Boolean);i(m)},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),b(ko,{disabled:o.length===0})]}),s&&b(Fs,{onAnimationComplete:n,error:s})]})};var lr=e=>e.type==="checkbox",Mn=e=>e instanceof Date,Me=e=>e==null;const Cd=e=>typeof e=="object";var fe=e=>!Me(e)&&!Array.isArray(e)&&Cd(e)&&!Mn(e),V1=e=>fe(e)&&e.target?lr(e.target)?e.target.checked:e.target.value:e,O1=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,L1=(e,t)=>e.has(O1(t)),N1=e=>{const t=e.constructor&&e.constructor.prototype;return fe(t)&&t.hasOwnProperty("isPrototypeOf")},Ds=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ct(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Ds&&(e instanceof Blob||e instanceof FileList))&&(n||fe(e)))if(t=n?[]:{},!n&&!N1(e))t=e;else for(const r in e)e.hasOwnProperty(r)&&(t[r]=ct(e[r]));else return e;return t}var ur=e=>Array.isArray(e)?e.filter(Boolean):[],ie=e=>e===void 0,O=(e,t,n)=>{if(!t||!fe(e))return n;const r=ur(t.split(/[,[\].]+?/)).reduce((o,i)=>Me(o)?o:o[i],e);return ie(r)||r===e?ie(e[t])?n:e[t]:r},Tt=e=>typeof e=="boolean";const Ad={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ze={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},lt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};De.createContext(null);var R1=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(o,i,{get:()=>{const s=i;return t._proxyFormState[s]!==ze.all&&(t._proxyFormState[s]=!r||ze.all),n&&(n[s]=!0),e[s]}});return o},Oe=e=>fe(e)&&!Object.keys(e).length,I1=(e,t,n,r)=>{n(e);const{name:o,...i}=e;return Oe(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(s=>t[s]===(!r||ze.all))},zs=e=>Array.isArray(e)?e:[e];function F1(e){const t=De.useRef(e);t.current=e,De.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var Ye=e=>typeof e=="string",D1=(e,t,n,r,o)=>Ye(e)?(r&&t.watch.add(e),O(n,e,o)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),O(n,i))):(r&&(t.watchAll=!0),n),Bs=e=>/^\w*$/.test(e),Pd=e=>ur(e.replace(/["|']|\]/g,"").split(/\.|\[/));function Q(e,t,n){let r=-1;const o=Bs(t)?[t]:Pd(t),i=o.length,s=i-1;for(;++r<i;){const a=o[r];let c=n;if(r!==s){const u=e[a];c=fe(u)||Array.isArray(u)?u:isNaN(+o[r+1])?{}:[]}e[a]=c,e=e[a]}return e}var Ed=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},Vd=e=>({isOnSubmit:!e||e===ze.onSubmit,isOnBlur:e===ze.onBlur,isOnChange:e===ze.onChange,isOnAll:e===ze.all,isOnTouch:e===ze.onTouched}),Od=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const So=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const i=O(e,o);if(i){const{_f:s,...a}=i;if(s){if(s.refs&&s.refs[0]&&t(s.refs[0],o)&&!r)break;if(s.ref&&t(s.ref,s.name)&&!r)break}else fe(a)&&So(a,t)}}};var z1=(e,t,n)=>{const r=ur(O(e,n));return Q(r,"root",t[n]),Q(e,n,r),e},js=e=>e.type==="file",Ct=e=>typeof e=="function",Mo=e=>{if(!Ds)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},To=e=>Ye(e),Hs=e=>e.type==="radio",Co=e=>e instanceof RegExp;const Ld={value:!1,isValid:!1},Nd={value:!0,isValid:!0};var Rd=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ie(e[0].attributes.value)?ie(e[0].value)||e[0].value===""?Nd:{value:e[0].value,isValid:!0}:Nd:Ld}return Ld};const Id={isValid:!1,value:null};var Fd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Id):Id;function Dd(e,t,n="validate"){if(To(e)||Array.isArray(e)&&e.every(To)||Tt(e)&&!e)return{type:n,message:To(e)?e:"",ref:t}}var Tn=e=>fe(e)&&!Co(e)?e:{value:e,message:""},zd=async(e,t,n,r,o)=>{const{ref:i,refs:s,required:a,maxLength:c,minLength:u,min:d,max:l,pattern:f,validate:h,name:p,valueAsNumber:m,mount:y,disabled:x}=e._f,g=O(t,p);if(!y||x)return{};const w=s?s[0]:i,M=j=>{r&&w.reportValidity&&(w.setCustomValidity(Tt(j)?"":j||""),w.reportValidity())},S={},I=Hs(i),N=lr(i),C=I||N,E=(m||js(i))&&ie(i.value)&&ie(g)||Mo(i)&&i.value===""||g===""||Array.isArray(g)&&!g.length,q=Ed.bind(null,p,n,S),K=(j,B,H,X=lt.maxLength,re=lt.minLength)=>{const se=j?B:H;S[p]={type:j?X:re,message:se,ref:i,...q(j?X:re,se)}};if(o?!Array.isArray(g)||!g.length:a&&(!C&&(E||Me(g))||Tt(g)&&!g||N&&!Rd(s).isValid||I&&!Fd(s).isValid)){const{value:j,message:B}=To(a)?{value:!!a,message:a}:Tn(a);if(j&&(S[p]={type:lt.required,message:B,ref:w,...q(lt.required,B)},!n))return M(B),S}if(!E&&(!Me(d)||!Me(l))){let j,B;const H=Tn(l),X=Tn(d);if(!Me(g)&&!isNaN(g)){const re=i.valueAsNumber||g&&+g;Me(H.value)||(j=re>H.value),Me(X.value)||(B=re<X.value)}else{const re=i.valueAsDate||new Date(g),se=ut=>new Date(new Date().toDateString()+" "+ut),Le=i.type=="time",Ne=i.type=="week";Ye(H.value)&&g&&(j=Le?se(g)>se(H.value):Ne?g>H.value:re>new Date(H.value)),Ye(X.value)&&g&&(B=Le?se(g)<se(X.value):Ne?g<X.value:re<new Date(X.value))}if((j||B)&&(K(!!j,H.message,X.message,lt.max,lt.min),!n))return M(S[p].message),S}if((c||u)&&!E&&(Ye(g)||o&&Array.isArray(g))){const j=Tn(c),B=Tn(u),H=!Me(j.value)&&g.length>+j.value,X=!Me(B.value)&&g.length<+B.value;if((H||X)&&(K(H,j.message,B.message),!n))return M(S[p].message),S}if(f&&!E&&Ye(g)){const{value:j,message:B}=Tn(f);if(Co(j)&&!g.match(j)&&(S[p]={type:lt.pattern,message:B,ref:i,...q(lt.pattern,B)},!n))return M(B),S}if(h){if(Ct(h)){const j=await h(g,t),B=Dd(j,w);if(B&&(S[p]={...B,...q(lt.validate,B.message)},!n))return M(B.message),S}else if(fe(h)){let j={};for(const B in h){if(!Oe(j)&&!n)break;const H=Dd(await h[B](g,t),w,B);H&&(j={...H,...q(B,H.message)},M(H.message),n&&(S[p]=j))}if(!Oe(j)&&(S[p]={ref:w,...j},!n))return S}}return M(!0),S};function B1(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=ie(e)?r++:e[t[r++]];return e}function j1(e){for(const t in e)if(e.hasOwnProperty(t)&&!ie(e[t]))return!1;return!0}function ye(e,t){const n=Array.isArray(t)?t:Bs(t)?[t]:Pd(t),r=n.length===1?e:B1(e,n),o=n.length-1,i=n[o];return r&&delete r[i],o!==0&&(fe(r)&&Oe(r)||Array.isArray(r)&&j1(r))&&ye(e,n.slice(0,-1)),e}function Us(){let e=[];return{get observers(){return e},next:o=>{for(const i of e)i.next&&i.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(i=>i!==o)}}),unsubscribe:()=>{e=[]}}}var Ao=e=>Me(e)||!Cd(e);function Yt(e,t){if(Ao(e)||Ao(t))return e===t;if(Mn(e)&&Mn(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const i=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const s=t[o];if(Mn(i)&&Mn(s)||fe(i)&&fe(s)||Array.isArray(i)&&Array.isArray(s)?!Yt(i,s):i!==s)return!1}}return!0}var Bd=e=>e.type==="select-multiple",H1=e=>Hs(e)||lr(e),Xs=e=>Mo(e)&&e.isConnected,jd=e=>{for(const t in e)if(Ct(e[t]))return!0;return!1};function Po(e,t={}){const n=Array.isArray(e);if(fe(e)||n)for(const r in e)Array.isArray(e[r])||fe(e[r])&&!jd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Po(e[r],t[r])):Me(e[r])||(t[r]=!0);return t}function Hd(e,t,n){const r=Array.isArray(e);if(fe(e)||r)for(const o in e)Array.isArray(e[o])||fe(e[o])&&!jd(e[o])?ie(t)||Ao(n[o])?n[o]=Array.isArray(e[o])?Po(e[o],[]):{...Po(e[o])}:Hd(e[o],Me(t)?{}:t[o],n[o]):n[o]=!Yt(e[o],t[o]);return n}var qs=(e,t)=>Hd(e,t,Po(t)),Ud=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ie(e)?e:t?e===""?NaN:e&&+e:n&&Ye(e)?new Date(e):r?r(e):e;function Ws(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return js(t)?t.files:Hs(t)?Fd(e.refs).value:Bd(t)?[...t.selectedOptions].map(({value:n})=>n):lr(t)?Rd(e.refs).value:Ud(ie(t.value)?e.ref.value:t.value,e)}var U1=(e,t,n,r)=>{const o={};for(const i of e){const s=O(t,i);s&&Q(o,i,s._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},dr=e=>ie(e)?e:Co(e)?e.source:fe(e)?Co(e.value)?e.value.source:e.value:e,X1=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Xd(e,t,n){const r=O(e,n);if(r||Bs(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const i=o.join("."),s=O(t,i),a=O(e,i);if(s&&!Array.isArray(s)&&n!==i)return{name:n};if(a&&a.type)return{name:i,error:a};o.pop()}return{name:n}}var q1=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,W1=(e,t)=>!ur(O(e,t)).length&&ye(e,t);const K1={mode:ze.onSubmit,reValidateMode:ze.onChange,shouldFocusError:!0};function Y1(e={},t){let n={...K1,...e},r={submitCount:0,isDirty:!1,isLoading:Ct(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},o={},i=fe(n.defaultValues)||fe(n.values)?ct(n.defaultValues||n.values)||{}:{},s=n.shouldUnregister?{}:ct(i),a={action:!1,mount:!1,watch:!1},c={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,d=0;const l={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Us(),array:Us(),state:Us()},h=e.resetOptions&&e.resetOptions.keepDirtyValues,p=Vd(n.mode),m=Vd(n.reValidateMode),y=n.criteriaMode===ze.all,x=v=>_=>{clearTimeout(d),d=setTimeout(v,_)},g=async v=>{if(l.isValid||v){const _=n.resolver?Oe((await E()).errors):await K(o,!0);_!==r.isValid&&f.state.next({isValid:_})}},w=v=>l.isValidating&&f.state.next({isValidating:v}),M=(v,_=[],k,L,P=!0,T=!0)=>{if(L&&k){if(a.action=!0,T&&Array.isArray(O(o,v))){const F=k(O(o,v),L.argA,L.argB);P&&Q(o,v,F)}if(T&&Array.isArray(O(r.errors,v))){const F=k(O(r.errors,v),L.argA,L.argB);P&&Q(r.errors,v,F),W1(r.errors,v)}if(l.touchedFields&&T&&Array.isArray(O(r.touchedFields,v))){const F=k(O(r.touchedFields,v),L.argA,L.argB);P&&Q(r.touchedFields,v,F)}l.dirtyFields&&(r.dirtyFields=qs(i,s)),f.state.next({name:v,isDirty:B(v,_),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Q(s,v,_)},S=(v,_)=>{Q(r.errors,v,_),f.state.next({errors:r.errors})},I=(v,_,k,L)=>{const P=O(o,v);if(P){const T=O(s,v,ie(k)?O(i,v):k);ie(T)||L&&L.defaultChecked||_?Q(s,v,_?T:Ws(P._f)):re(v,T),a.mount&&g()}},N=(v,_,k,L,P)=>{let T=!1,F=!1;const ee={name:v};if(!k||L){l.isDirty&&(F=r.isDirty,r.isDirty=ee.isDirty=B(),T=F!==ee.isDirty);const le=Yt(O(i,v),_);F=O(r.dirtyFields,v),le?ye(r.dirtyFields,v):Q(r.dirtyFields,v,!0),ee.dirtyFields=r.dirtyFields,T=T||l.dirtyFields&&F!==!le}if(k){const le=O(r.touchedFields,v);le||(Q(r.touchedFields,v,k),ee.touchedFields=r.touchedFields,T=T||l.touchedFields&&le!==k)}return T&&P&&f.state.next(ee),T?ee:{}},C=(v,_,k,L)=>{const P=O(r.errors,v),T=l.isValid&&Tt(_)&&r.isValid!==_;if(e.delayError&&k?(u=x(()=>S(v,k)),u(e.delayError)):(clearTimeout(d),u=null,k?Q(r.errors,v,k):ye(r.errors,v)),(k?!Yt(P,k):P)||!Oe(L)||T){const F={...L,...T&&Tt(_)?{isValid:_}:{},errors:r.errors,name:v};r={...r,...F},f.state.next(F)}w(!1)},E=async v=>n.resolver(s,n.context,U1(v||c.mount,o,n.criteriaMode,n.shouldUseNativeValidation)),q=async v=>{const{errors:_}=await E(v);if(v)for(const k of v){const L=O(_,k);L?Q(r.errors,k,L):ye(r.errors,k)}else r.errors=_;return _},K=async(v,_,k={valid:!0})=>{for(const L in v){const P=v[L];if(P){const{_f:T,...F}=P;if(T){const ee=c.array.has(T.name),le=await zd(P,s,y,n.shouldUseNativeValidation&&!_,ee);if(le[T.name]&&(k.valid=!1,_))break;!_&&(O(le,T.name)?ee?z1(r.errors,le,T.name):Q(r.errors,T.name,le[T.name]):ye(r.errors,T.name))}F&&await K(F,_,k)}}return k.valid},j=()=>{for(const v of c.unMount){const _=O(o,v);_&&(_._f.refs?_._f.refs.every(k=>!Xs(k)):!Xs(_._f.ref))&&Ze(v)}c.unMount=new Set},B=(v,_)=>(v&&_&&Q(s,v,_),!Yt(Re(),i)),H=(v,_,k)=>D1(v,c,{...a.mount?s:ie(_)?i:Ye(v)?{[v]:_}:_},k,_),X=v=>ur(O(a.mount?s:i,v,e.shouldUnregister?O(i,v,[]):[])),re=(v,_,k={})=>{const L=O(o,v);let P=_;if(L){const T=L._f;T&&(!T.disabled&&Q(s,v,Ud(_,T)),P=Mo(T.ref)&&Me(_)?"":_,Bd(T.ref)?[...T.ref.options].forEach(F=>F.selected=P.includes(F.value)):T.refs?lr(T.ref)?T.refs.length>1?T.refs.forEach(F=>(!F.defaultChecked||!F.disabled)&&(F.checked=Array.isArray(P)?!!P.find(ee=>ee===F.value):P===F.value)):T.refs[0]&&(T.refs[0].checked=!!P):T.refs.forEach(F=>F.checked=F.value===P):js(T.ref)?T.ref.value="":(T.ref.value=P,T.ref.type||f.values.next({name:v,values:{...s}})))}(k.shouldDirty||k.shouldTouch)&&N(v,P,k.shouldTouch,k.shouldDirty,!0),k.shouldValidate&&Y(v)},se=(v,_,k)=>{for(const L in _){const P=_[L],T=`${v}.${L}`,F=O(o,T);(c.array.has(v)||!Ao(P)||F&&!F._f)&&!Mn(P)?se(T,P,k):re(T,P,k)}},Le=(v,_,k={})=>{const L=O(o,v),P=c.array.has(v),T=ct(_);Q(s,v,T),P?(f.array.next({name:v,values:{...s}}),(l.isDirty||l.dirtyFields)&&k.shouldDirty&&f.state.next({name:v,dirtyFields:qs(i,s),isDirty:B(v,T)})):L&&!L._f&&!Me(T)?se(v,T,k):re(v,T,k),Od(v,c)&&f.state.next({...r}),f.values.next({name:v,values:{...s}}),!a.mount&&t()},Ne=async v=>{const _=v.target;let k=_.name,L=!0;const P=O(o,k),T=()=>_.type?Ws(P._f):V1(v),F=ee=>{L=Number.isNaN(ee)||ee===O(s,k,ee)};if(P){let ee,le;const Lo=T(),Cn=v.type===Ad.BLUR||v.type===Ad.FOCUS_OUT,xy=!X1(P._f)&&!n.resolver&&!O(r.errors,k)&&!P._f.deps||q1(Cn,O(r.touchedFields,k),r.isSubmitted,m,p),Ks=Od(k,c,Cn);Q(s,k,Lo),Cn?(P._f.onBlur&&P._f.onBlur(v),u&&u(0)):P._f.onChange&&P._f.onChange(v);const Ys=N(k,Lo,Cn,!1),ky=!Oe(Ys)||Ks;if(!Cn&&f.values.next({name:k,type:v.type,values:{...s}}),xy)return l.isValid&&g(),ky&&f.state.next({name:k,...Ks?{}:Ys});if(!Cn&&Ks&&f.state.next({...r}),w(!0),n.resolver){const{errors:ef}=await E([k]);if(F(Lo),L){const $y=Xd(r.errors,o,k),tf=Xd(ef,o,$y.name||k);ee=tf.error,k=tf.name,le=Oe(ef)}}else ee=(await zd(P,s,y,n.shouldUseNativeValidation))[k],F(Lo),L&&(ee?le=!1:l.isValid&&(le=await K(o,!0)));L&&(P._f.deps&&Y(P._f.deps),C(k,le,ee,Ys))}},ut=(v,_)=>{if(O(r.errors,_)&&v.focus)return v.focus(),1},Y=async(v,_={})=>{let k,L;const P=zs(v);if(w(!0),n.resolver){const T=await q(ie(v)?v:P);k=Oe(T),L=v?!P.some(F=>O(T,F)):k}else v?(L=(await Promise.all(P.map(async T=>{const F=O(o,T);return await K(F&&F._f?{[T]:F}:F)}))).every(Boolean),!(!L&&!r.isValid)&&g()):L=k=await K(o);return f.state.next({...!Ye(v)||l.isValid&&k!==r.isValid?{}:{name:v},...n.resolver||!v?{isValid:k}:{},errors:r.errors,isValidating:!1}),_.shouldFocus&&!L&&So(o,ut,v?P:c.mount),L},Re=v=>{const _={...i,...a.mount?s:{}};return ie(v)?_:Ye(v)?O(_,v):v.map(k=>O(_,k))},At=(v,_)=>({invalid:!!O((_||r).errors,v),isDirty:!!O((_||r).dirtyFields,v),isTouched:!!O((_||r).touchedFields,v),error:O((_||r).errors,v)}),Pt=v=>{v&&zs(v).forEach(_=>ye(r.errors,_)),f.state.next({errors:v?r.errors:{}})},Gt=(v,_,k)=>{const L=(O(o,v,{_f:{}})._f||{}).ref;Q(r.errors,v,{..._,ref:L}),f.state.next({name:v,errors:r.errors,isValid:!1}),k&&k.shouldFocus&&L&&L.focus&&L.focus()},Ge=(v,_)=>Ct(v)?f.values.subscribe({next:k=>v(H(void 0,_),k)}):H(v,_,!0),Ze=(v,_={})=>{for(const k of v?zs(v):c.mount)c.mount.delete(k),c.array.delete(k),_.keepValue||(ye(o,k),ye(s,k)),!_.keepError&&ye(r.errors,k),!_.keepDirty&&ye(r.dirtyFields,k),!_.keepTouched&&ye(r.touchedFields,k),!n.shouldUnregister&&!_.keepDefaultValue&&ye(i,k);f.values.next({values:{...s}}),f.state.next({...r,..._.keepDirty?{isDirty:B()}:{}}),!_.keepIsValid&&g()},Vo=({disabled:v,name:_,field:k,fields:L,value:P})=>{if(Tt(v)){const T=v?void 0:ie(P)?Ws(k?k._f:O(L,_)._f):P;Q(s,_,T),N(_,T,!1,!1,!0)}},Zt=(v,_={})=>{let k=O(o,v);const L=Tt(_.disabled);return Q(o,v,{...k||{},_f:{...k&&k._f?k._f:{ref:{name:v}},name:v,mount:!0,..._}}),c.mount.add(v),k?Vo({field:k,disabled:_.disabled,name:v}):I(v,!0,_.value),{...L?{disabled:_.disabled}:{},...n.progressive?{required:!!_.required,min:dr(_.min),max:dr(_.max),minLength:dr(_.minLength),maxLength:dr(_.maxLength),pattern:dr(_.pattern)}:{},name:v,onChange:Ne,onBlur:Ne,ref:P=>{if(P){Zt(v,_),k=O(o,v);const T=ie(P.value)&&P.querySelectorAll&&P.querySelectorAll("input,select,textarea")[0]||P,F=H1(T),ee=k._f.refs||[];if(F?ee.find(le=>le===T):T===k._f.ref)return;Q(o,v,{_f:{...k._f,...F?{refs:[...ee.filter(Xs),T,...Array.isArray(O(i,v))?[{}]:[]],ref:{type:T.type,name:v}}:{ref:T}}}),I(v,!1,void 0,T)}else k=O(o,v,{}),k._f&&(k._f.mount=!1),(n.shouldUnregister||_.shouldUnregister)&&!(L1(c.array,v)&&a.action)&&c.unMount.add(v)}}},Jt=()=>n.shouldFocusError&&So(o,ut,c.mount),dt=v=>{Tt(v)&&(f.state.next({disabled:v}),So(o,_=>{_.disabled=v},0,!1))},fr=(v,_)=>async k=>{k&&(k.preventDefault&&k.preventDefault(),k.persist&&k.persist());let L=ct(s);if(f.state.next({isSubmitting:!0}),n.resolver){const{errors:P,values:T}=await E();r.errors=P,L=T}else await K(o);ye(r.errors,"root"),Oe(r.errors)?(f.state.next({errors:{}}),await v(L,k)):(_&&await _({...r.errors},k),Jt(),setTimeout(Jt)),f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Oe(r.errors),submitCount:r.submitCount+1,errors:r.errors})},Oo=(v,_={})=>{O(o,v)&&(ie(_.defaultValue)?Le(v,O(i,v)):(Le(v,_.defaultValue),Q(i,v,_.defaultValue)),_.keepTouched||ye(r.touchedFields,v),_.keepDirty||(ye(r.dirtyFields,v),r.isDirty=_.defaultValue?B(v,O(i,v)):B()),_.keepError||(ye(r.errors,v),l.isValid&&g()),f.state.next({...r}))},Jd=(v,_={})=>{const k=v?ct(v):i,L=ct(k),P=v&&!Oe(v)?L:i;if(_.keepDefaultValues||(i=k),!_.keepValues){if(_.keepDirtyValues||h)for(const T of c.mount)O(r.dirtyFields,T)?Q(P,T,O(s,T)):Le(T,O(P,T));else{if(Ds&&ie(v))for(const T of c.mount){const F=O(o,T);if(F&&F._f){const ee=Array.isArray(F._f.refs)?F._f.refs[0]:F._f.ref;if(Mo(ee)){const le=ee.closest("form");if(le){le.reset();break}}}}o={}}s=e.shouldUnregister?_.keepDefaultValues?ct(i):{}:ct(P),f.array.next({values:{...P}}),f.values.next({values:{...P}})}c={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!a.mount&&t(),a.mount=!l.isValid||!!_.keepIsValid,a.watch=!!e.shouldUnregister,f.state.next({submitCount:_.keepSubmitCount?r.submitCount:0,isDirty:_.keepDirty?r.isDirty:!!(_.keepDefaultValues&&!Yt(v,i)),isSubmitted:_.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:_.keepDirtyValues?r.dirtyFields:_.keepDefaultValues&&v?qs(i,v):{},touchedFields:_.keepTouched?r.touchedFields:{},errors:_.keepErrors?r.errors:{},isSubmitSuccessful:_.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Qd=(v,_)=>Jd(Ct(v)?v(s):v,_);return{control:{register:Zt,unregister:Ze,getFieldState:At,handleSubmit:fr,setError:Gt,_executeSchema:E,_getWatch:H,_getDirty:B,_updateValid:g,_removeUnmounted:j,_updateFieldArray:M,_updateDisabledField:Vo,_getFieldArray:X,_reset:Jd,_resetDefaultValues:()=>Ct(n.defaultValues)&&n.defaultValues().then(v=>{Qd(v,n.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:v=>{r={...r,...v}},_disableForm:dt,_subjects:f,_proxyFormState:l,get _fields(){return o},get _formValues(){return s},get _state(){return a},set _state(v){a=v},get _defaultValues(){return i},get _names(){return c},set _names(v){c=v},get _formState(){return r},set _formState(v){r=v},get _options(){return n},set _options(v){n={...n,...v}}},trigger:Y,register:Zt,handleSubmit:fr,watch:Ge,setValue:Le,getValues:Re,reset:Qd,resetField:Oo,clearErrors:Pt,unregister:Ze,setError:Gt,setFocus:(v,_={})=>{const k=O(o,v),L=k&&k._f;if(L){const P=L.refs?L.refs[0]:L.ref;P.focus&&(P.focus(),_.shouldSelect&&P.select())}},getFieldState:At}}function qd(e={}){const t=De.useRef(),n=De.useRef(),[r,o]=De.useState({isDirty:!1,isValidating:!1,isLoading:Ct(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:Ct(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Y1(e,()=>o(s=>({...s}))),formState:r});const i=t.current.control;return i._options=e,F1({subject:i._subjects.state,next:s=>{I1(s,i._proxyFormState,i._updateFormState,!0)&&o({...i._formState})}}),De.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),De.useEffect(()=>{if(i._proxyFormState.isDirty){const s=i._getDirty();s!==r.isDirty&&i._subjects.state.next({isDirty:s})}},[i,r.isDirty]),De.useEffect(()=>{e.values&&!Yt(e.values,n.current)?(i._reset(e.values,i._options.resetOptions),n.current=e.values):i._resetDefaultValues()},[e.values,i]),De.useEffect(()=>{i._state.mount||(i._updateValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=R1(r,i),t.current}var Wd=function(e,t,n){if(e&&"reportValidity"in e){var r=O(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},G1=function(e,t){var n=function(o){var i=t.fields[o];i&&i.ref&&"reportValidity"in i.ref?Wd(i.ref,o,e):i.refs&&i.refs.forEach(function(s){return Wd(s,o,e)})};for(var r in t.fields)n(r)},Z1=function(e,t){t.shouldUseNativeValidation&&G1(e,t);var n={};for(var r in e){var o=O(t.fields,r),i=Object.assign(e[r]||{},{ref:o&&o.ref});if(Q1(t.names||Object.keys(e),r)){var s=Object.assign({},J1(O(n,r)));Q(s,"root",i),Q(n,r,s)}else Q(n,r,i)}return n},J1=function(e){return Array.isArray(e)?e.filter(Boolean):[]},Q1=function(e,t){return e.some(function(n){return n.startsWith(t+".")})},ey=function(e,t){for(var n={};e.issues.length;){var r=e.issues[0];if(r.path){var o=r.path.map(function(a){return a.key}).join(".");if(n[o]||(n[o]={message:r.message,type:r.validation}),t){var i=n[o].types,s=i&&i[r.validation];n[o]=Ed(o,t,n,r.validation,s?[].concat(s,r.message):r.message)}e.issues.shift()}}return n},Kd=function(e,t,n){return n===void 0&&(n={}),function(r,o,i){try{return Promise.resolve(function(s,a){try{var c=function(){function u(l){return{values:n.raw?r:l,errors:{}}}var d=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},t);return n.mode==="sync"?u(rs(e,r,d)):Promise.resolve(og(e,r,d)).then(u)}()}catch(u){return a(u)}return c&&c.then?c.then(void 0,a):c}(0,function(s){if(s instanceof so)return{values:{},errors:Z1(ey(s,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw s}))}catch(s){return Promise.reject(s)}}};const ty=e=>{const t=Object.fromEntries(new FormData(e).entries());Object.keys(t).length&&e.dispatchEvent(new Event("submit",{bubbles:!0}))},ny=ts("multiple-choice"),ry=e=>{const t={min:e.minSelected??0,max:e.maxSelected??e.options.length};return Kd(bn({checked:ku(rg(Zv()),n=>Object.entries(n).filter(([r,o])=>o).map(([r,o])=>r),[ag(t.max,`Please select at most ${t.max} option${t.max!==1?"s":""}`),$u(t.min,`Please select at least ${t.min} option${t.min!==1?"s":""}`)])}))},oy=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var u,d;const r=e.key?(u=ne.current$.value.application)==null?void 0:u.data.submissions[e.key]:void 0,{register:o,handleSubmit:i,formState:{errors:s}}=qd({defaultValues:{checked:ny(r)?Object.fromEntries(r.value.map(l=>[l,!0])):{}},resolver:ry(e.config)}),a=Is(),c=e.config.minSelected===1&&e.config.maxSelected===1;return b("form",{noValidate:!0,class:"flex flex-col gap-1",onChange:l=>{c&&ty(l.currentTarget)},onSubmit:i(l=>{const f=l.checked;t(f)}),children:[b("div",{class:"flex items-center gap-2",children:[b("div",{class:Xt("flex w-full flex-1 flex-wrap gap-3 p-1",{"justify-center":e.config.options.length===1}),children:e.config.options.map((l,f)=>{const h=`checked.${l.value}`,{ref:p,...m}=o(h);return b("div",{children:[b("input",{autoFocus:f===0,ref:y=>{y&&f===0&&(a.current=y),p(y)},id:h,...m,class:"peer sr-only",type:"checkbox"}),b("label",{class:"bg-lowest peer-focus-visible:ring-accent-7 active:outline-neutral-10 ease-expo-out outline-neutral-12/5 text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 duration-snappy block rounded-2xl px-2.5 py-1 outline outline-2 ring-0 ring-transparent transition-all selection:bg-transparent peer-focus-visible:ring-4 peer-focus-visible:ring-offset-2",htmlFor:h,children:l.label})]},l.value)})}),!c&&b(ko,{})]}),b(Fs,{onAnimationComplete:n,error:(d=s.checked)==null?void 0:d.root})]})},Eo={email:"That doesn’t look like a valid email address",phone:"That doesn’t look like a valid phone number"},iy=We(Eo.phone,[cg(/^\+?[0-9 -]+$/,Eo.phone)]),sy={email:We(Eo.email,[sg(Eo.email)]),phone:ku(iy,e=>e.replace(/[^0-9]/g,"")),text:We([$u(1,"Please enter some text")]),url:We([lg("That doesn’t look like a valid URL")])},ay={email:{type:"email",inputMode:"email",formNoValidate:!0},phone:{type:"tel",inputMode:"tel"},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},cy=ts("text"),ly=e=>Kd(bn({text:sy[e.format]})),uy=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var d;const r=e.key?(d=ne.current$.value.application)==null?void 0:d.data.submissions[e.key]:void 0,{register:o,handleSubmit:i,formState:{errors:s}}=qd({defaultValues:{text:cy(r)?r.value:""},resolver:ly(e.config)}),{ref:a,...c}=o("text",{required:!0}),u=U();return Be(()=>{u.current&&(u.current.focus(),u.current.select())},[]),b("form",{noValidate:!0,class:"flex flex-col gap-1",onSubmit:i(l=>{t(l.text)}),children:[b("div",{class:"flex items-center gap-2",children:[b("input",{id:"chat-input",...c,...ay[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:l=>{l&&(u.current=l),a(l)},class:"outline-neutral-12/5 ease-expo-out placeholder:text-neutral-5 focus-visible:outline-accent-7 caret-accent-9 duration-snappy flex-grow rounded-full px-3 py-1 text-base outline outline-2 transition-all",placeholder:e.config.placeholder}),b(ko,{})]}),b(Fs,{onAnimationComplete:n,error:s.text})]})},dy=({onSubmit:e,onInputChange:t,input:n})=>{const r=U(null),o=me(()=>{r.current&&(ns.value=r.current.getBoundingClientRect().height)},[]);G(()=>{o(),t(n==null?void 0:n.type)},[n==null?void 0:n.type,t,o]);const i=s=>a=>e({type:s,value:a});return b(Kn.div,{initial:{height:0},animate:{height:ns.value},exit:{height:0,opacity:0},class:"bg-neutral-2/80 absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-md backdrop-saturate-150",children:b("div",{ref:r,class:"border-neutral-12/5 border-t p-2.5",children:nt({application:ne,input:n,onHeightChange:o}).with({input:Ae.nullish},()=>b("div",{class:"flex items-center gap-2",children:[b("input",{"aria-hidden":"true",id:"chat-input",class:"outline-neutral-12/5 placeholder:text-neutral-4 focus-visible:outline-accent-9 caret-accent-9 flex-grow rounded-full px-3 py-1 text-base outline outline-2",disabled:!0}),b(ko,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})).with({input:{type:"text"}},s=>b(uy,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"multiple-choice"}},s=>b(oy,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"boolean"}},s=>b(M1,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"file"}},s=>b(E1,{onSubmitSuccess:i(s.input.type),...s})).exhaustive()})})},Yd=e=>typeof e=="boolean"?"".concat(e):e===0?"0":e,Gd=Xt,Zd=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Gd(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const d=n==null?void 0:n[u],l=i==null?void 0:i[u];if(d===null)return null;const f=Yd(d)||Yd(l);return o[u][f]}),a=n&&Object.entries(n).reduce((u,d)=>{let[l,f]=d;return f===void 0||(u[l]=f),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:l,className:f,...h}=d;return Object.entries(h).every(p=>{let[m,y]=p;return Array.isArray(y)?y.includes({...i,...a}[m]):{...i,...a}[m]===y})?[...u,l,f]:u},[]);return Gd(e,s,c,n==null?void 0:n.class,n==null?void 0:n.className)},fy=Zd("max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink-1 min-w-[2rem] text-md py-2 px-3 rounded-[18px] min-h-[36px] break-words",{variants:{side:{left:"bg-lowest text-neutral-12 shadow-surface-sm outline outline-1 outline-neutral-11/[.08] rounded-bl-md",right:"ml-auto bg-accent-7 text-lowest rounded-br-md bubble-right"},transitionState:{entering:"opacity-0 translate-y-8",entered:"opacity-100 translate-y-0",exiting:"opacity-0 scale-0",exited:""}},defaultVariants:{side:"left"}}),hy={hidden:{y:"100%",scale:.75},shown:{y:0,scale:1}},py=({children:e,className:t,transitionState:n,side:r,...o})=>b(Kn.p,{variants:hy,initial:"hidden",animate:"shown",transition:{type:"spring",damping:25,stiffness:500},"data-transition":n,style:{transformOrigin:r==="left"?"0% 50%":"100% 50%"},class:fy({className:t,side:r,transitionState:n}),...o,children:e}),my=({className:e,...t})=>b("div",{"aria-label":"Typing…",class:Xt("flex gap-1 p-4",e),...t,children:Array.from({length:3},(n,r)=>b("div",{class:"bg-accent-7 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-r*200}ms`}}))}),vy={bot:"left",user:"right"},gy=Zd("w-full select-none py-2 text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_white]",{variants:{variant:{info:"text-neutral-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),by=({messages:e,isBotTyping:t})=>b("ol",{"aria-label":"Chat messages",class:"flex flex-grow flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[b(to,{initial:!1,children:e.map((n,r)=>b("li",{class:"flex",children:nt(n).with({type:"system"},o=>b("p",{class:gy({variant:o.variant}),children:o.text})).with({type:"text",author:Ae.union("bot","user")},o=>b(py,{side:vy[o.author],children:o.text},r)).with({type:"link"},o=>b("div",{class:"bg-accent-8/5 flex w-full items-center justify-center overflow-hidden rounded-xl py-2",children:b("a",{class:"bg-lowest shadow-surface-sm ring-accent-8/20 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 flex items-center gap-1.5 truncate rounded-full py-2 pl-4 pr-2.5 no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:o.href,children:[o.text,b("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b("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"})})]})})).with({type:"image"},o=>b("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:o.url,style:{aspectRatio:o.width/o.height}})).with({type:"file"},o=>b(P1,{class:o.author==="bot"?"":"ml-auto",file:{name:o.fileName,sizeKb:o.fileSizeKb}})).exhaustive()},r))}),b("aside",{"aria-hidden":!0,children:t&&b(my,{})})]}),yy=25,wy=()=>{const e=U(null),[t,n]=ae(!1),[r,o]=ae(()=>()=>{}),i=de(()=>a=>{var c;return(c=e.current)==null?void 0:c.scrollTo({top:e.current.scrollHeight,...a})},[e]),s=de(()=>({send:async({message:a,signal:c,groupId:u})=>{if(await nt(a).with({author:"bot",type:"text"},async d=>{if(c!=null&&c.aborted)throw new Jn;n(!0);const l=Math.min(Math.max(20,d.text.length),100)*yy;await new Promise(f=>setTimeout(f,l,{signal:c})),n(!1)}).otherwise(async()=>{}),c!=null&&c.aborted)throw new Jn;ne.addMessage(a,u)},input:async({input:a,signal:c})=>{if(c!=null&&c.aborted)throw new Jn;return ne.setInput(a),await new Promise(u=>{const d=l=>{if(c!=null&&c.aborted)throw new Jn;ne.setInput(void 0),a.key&&ne.setSubmission(a.key,l),u(l)};o(()=>d)})}}),[]);return{chatRef:e,chatService:s,isBotTyping:t,onSubmitSuccessFn:r,scrollToEnd:i}},_y=Object.freeze(Object.defineProperty({__proto__:null,JobApplicationContent:({currentApplication:e,logger:t,apiClient:n,analytics:r})=>{const{chatRef:o,chatService:i,isBotTyping:s,onSubmitSuccessFn:a,scrollToEnd:c}=wy(),u=rt.value,d=e.flow,l=e.job;return Be(()=>{u==="maximised"&&c({behavior:"instant"})},[c,u]),G(()=>{c({behavior:"smooth"})},[e.data.messages,c]),Be(()=>{const{state:f,application:h}=ne.current$.peek();if(f!=="loaded")throw new Error(Vv.invalid_state);const p=h.data.currentNodeId;if(c({behavior:"instant"}),ne.setInput(void 0),h.data.isFinished)return;ne.removeLastGroupMessagesById(p);const{interpret:m,abort:y}=l1({context:{jobId:l.id,flowId:d.id},analytics:r,apiClient:n,logger:t,flow:d.nodes,chatService:i,getSubmissions:()=>{var x;return(x=ne.current$.peek().application)==null?void 0:x.data.submissions},onInterpret:(x,g)=>{const w=ne.current$.peek().application;rn(w),w.data.sequence=w.data.sequence+1,r.log({event:"FLOW_NODE",attributionKey:`job_${l.id}`,properties:{flow_id:d.id,flow_version:d.version,job_id:l.id,from_node_id:g?g.id:null,to_node_id:x.id,sequence:w.data.sequence,flow_session_id:w.data.flowSessionId}}),ne.setCurrentNodeId(x.id)},onFlowEnd:async()=>{ne.markAsFinished()}});return m(p),y},[r,n,i,t,c,d,l.id,e.startedAt]),b(ue,{children:[b("div",{ref:o,className:"hide-scrollbars relative flex max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:ns.value},children:b(to,{children:b(by,{isBotTyping:s,messages:e.data.messages})})}),b(dy,{input:e.data.currentInput,onInputChange:()=>c({behavior:"smooth"}),onSubmit:a})]})}},Symbol.toStringTag,{value:"Module"}))})();
@@ -13,7 +13,7 @@ export declare const getHeadOrThrow: (nodes: FlowNode[]) => {
13
13
  id: string;
14
14
  data: {
15
15
  systemMessage?: string | undefined;
16
- };
16
+ } | null;
17
17
  type: "end-flow";
18
18
  isHead?: boolean | undefined;
19
19
  nextId?: string | undefined;
@@ -8298,7 +8298,7 @@ const ChatbotHeader = ({
8298
8298
  })]
8299
8299
  });
8300
8300
  };
8301
- const JobApplicationContent = M$1(() => Promise.resolve().then(() => require("./job-application-content-ff6165e9.cjs")).then((module2) => module2.JobApplicationContent));
8301
+ const JobApplicationContent = M$1(() => Promise.resolve().then(() => require("./job-application-content-a12f00fd.cjs")).then((module2) => module2.JobApplicationContent));
8302
8302
  const MotionProvider = ({
8303
8303
  children
8304
8304
  }) => {
@@ -8297,7 +8297,7 @@ const ChatbotHeader = ({
8297
8297
  })]
8298
8298
  });
8299
8299
  };
8300
- const JobApplicationContent = M$1(() => import("./job-application-content-425367df.js").then((module) => module.JobApplicationContent));
8300
+ const JobApplicationContent = M$1(() => import("./job-application-content-1fe02c86.js").then((module) => module.JobApplicationContent));
8301
8301
  const MotionProvider = ({
8302
8302
  children
8303
8303
  }) => {
@@ -1,4 +1,4 @@
1
- import { _, g as getHeadOrThrow, A as AbortedError, N, a as getApplicationSubmissionsPayload, i as invariant, o as o$1, c as clsx, b as _$1, p, d as parse, e as picklist, m, f as AnimatePresence, h as application, j as h, k, l as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, s as minLength, u as record, v as boolean, w as string, x as email, y as url, z as regex, B as y, T, D as inputHeight, F, E as viewState, G as ERROR_MESSAGES } from "./index-873a3e2d.js";
1
+ import { _, g as getHeadOrThrow, A as AbortedError, N, a as getApplicationSubmissionsPayload, i as invariant, o as o$1, c as clsx, b as _$1, p, d as parse, e as picklist, m, f as AnimatePresence, h as application, j as h, k, l as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, s as minLength, u as record, v as boolean, w as string, x as email, y as url, z as regex, B as y, T, D as inputHeight, F, E as viewState, G as ERROR_MESSAGES } from "./index-716f9049.js";
2
2
  import "@inploi/sdk";
3
3
  const followNodes = ({
4
4
  node,
@@ -455,10 +455,11 @@ async function interpretEndFlowNode({
455
455
  end,
456
456
  node
457
457
  }) {
458
+ var _a;
458
459
  await chat.sendMessage({
459
460
  type: "system",
460
461
  variant: "info",
461
- text: node.data.systemMessage || "Conversation finished"
462
+ text: ((_a = node.data) == null ? void 0 : _a.systemMessage) ?? "Conversation finished"
462
463
  });
463
464
  end();
464
465
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-7659d6f8.cjs");
3
+ const index = require("./index-4fa91c08.cjs");
4
4
  require("@inploi/sdk");
5
5
  const followNodes = ({
6
6
  node,
@@ -457,10 +457,11 @@ async function interpretEndFlowNode({
457
457
  end,
458
458
  node
459
459
  }) {
460
+ var _a;
460
461
  await chat.sendMessage({
461
462
  type: "system",
462
463
  variant: "info",
463
- text: node.data.systemMessage || "Conversation finished"
464
+ text: ((_a = node.data) == null ? void 0 : _a.systemMessage) ?? "Conversation finished"
464
465
  });
465
466
  end();
466
467
  }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-7659d6f8.cjs");
3
+ const index = require("./index-4fa91c08.cjs");
4
4
  require("@inploi/sdk");
5
5
  exports.chatbotPlugin = index.chatbotPlugin;
@@ -1,4 +1,4 @@
1
- import { H } from "./index-873a3e2d.js";
1
+ import { H } from "./index-716f9049.js";
2
2
  import "@inploi/sdk";
3
3
  export {
4
4
  H as chatbotPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inploi/plugin-chatbot",
3
- "version": "3.6.2",
3
+ "version": "3.6.3",
4
4
  "type": "module",
5
5
  "main": "dist/plugin-chatbot.js",
6
6
  "types": "dist/index.d.ts",
@@ -63,8 +63,8 @@
63
63
  "vite": "^4.4.5",
64
64
  "vite-plugin-dts": "^3.7.0",
65
65
  "vite-tsconfig-paths": "^4.2.1",
66
- "@inploi/core": "1.11.1",
67
- "@inploi/sdk": "1.11.2",
66
+ "@inploi/core": "1.11.2",
67
+ "@inploi/sdk": "1.11.3",
68
68
  "eslint-config-custom": "0.1.0",
69
69
  "tsconfig": "0.1.0"
70
70
  },
@@ -78,7 +78,7 @@
78
78
  "build": "concurrently 'pnpm build:npm' 'pnpm run build:cdn'",
79
79
  "setup-local": "cp -n .env.example .env || true",
80
80
  "check": "eslint src --fix --max-warnings 0 && tsc",
81
- "test:unit": "bun test",
81
+ "test": "bun test src/",
82
82
  "test:int": "playwright test",
83
83
  "test:ui": "playwright test --ui",
84
84
  "preview": "vite preview"