@inploi/plugin-chatbot 3.12.4 → 3.12.5
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 +1 -1
- package/dist/{chatbot-body-b22b5a7f.cjs → chatbot-body-1c87450e.cjs} +2 -2
- package/dist/{chatbot-body-716ca8d6.js → chatbot-body-83a30845.js} +2 -2
- package/dist/chatbot.api.d.ts +15 -15
- package/dist/chatbot.utils.d.ts +1 -1
- package/dist/{index-14d43f7c.cjs → index-395856be.cjs} +1 -1
- package/dist/{index-34a0c678.js → index-b4781911.js} +1 -1
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +1 -1
- package/package.json +2 -2
package/cdn/index.js
CHANGED
|
@@ -50,4 +50,4 @@ var dy=Object.defineProperty;var fy=(ht,xe,E)=>xe in ht?dy(ht,xe,{enumerable:!0,
|
|
|
50
50
|
`,Pv=()=>({getOrCreateChatbotElement:()=>{const e=document.getElementById(al);if(e)return e;const t=document.createElement("div");return document.body.appendChild(t),t.id=al,t}});var Ev=["1","2","3","4","5","6","7","8","9","10","11","12"],Tv={light:{1:[98.8,.015],2:[97.8,.018],3:[95.8,.025],4:[92,.04],5:[89,.05],6:[85,.07],7:[80.5,.08],8:[74,.11],9:[60,.22],10:[56,.23],11:[50,.19],12:[25,.18]},dark:{1:[19,.015],2:[21,.018],3:[25.5,.055],4:[29.3,.084],5:[33.5,.098],6:[39.05,.107],7:[45,.11],8:[55,.13],9:[60,.22],10:[67,.18],11:[79.3,.12],12:[95,.04]}},Vv=(e,t=1,r)=>n=>{const[i,o]=Tv[r][n];return"oklch("+i+"% "+o*t+" "+e+")"},ko=e=>{const t=Vv(e.hue,e.chroma,e.mode);return Object.fromEntries(Ev.map(r=>[e.prefix+r,e.transform(t(r))]))},So=e=>e,Mv=e=>{const t=Object.keys(e).flatMap(r=>{const n=e[r];return typeof n=="object"&&n!==null?Object.keys(n).map(i=>{const o=n[i];return[`${String(r)}.${i}`,o]}):[[r,n]]});return Object.fromEntries(t)},On=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Co=(e,...t)=>{if(!t.length)return e;const r=t.shift();if(On(e)&&On(r))for(const n in r){const i=r[n];if(On(i)){e[n]||Object.assign(e,{[n]:{}});const o=e[n];On(o)&&Co(o,i)}else Object.assign(e,{[n]:r[n]})}return Co(e,...t)},Ov=e=>{function t(r,n){const i=[e.prefix,n.toString().replace(/\./g,"-")].join("");return r==="declaration"?`--${i}`:`var(--${i})`}return t},Iv=()=>({core:e=>({semantic:t=>({component:r=>({from:n=>{const{theme:i,getToken:o}=n,s=f=>o("reference",f.toString()),a=e({theme:i}),l=t({theme:i,core:s,raw:{core:a}}),u=r({theme:i,core:s,semantic:s,raw:{core:a,semantic:l}}),d=Mv(Co(a,l,u)),c=([f,p],h)=>{const m=[h,f].filter(Boolean).join(".");return typeof p=="object"?Object.entries(p).flatMap(b=>c(b,m)):[[n.getToken("declaration",m),p]]};return{values:d,declarations:Object.fromEntries(Object.entries(d).flatMap(f=>c(f))),ref:f=>o("reference",f.toString())}}})})})});const[$o,Ao,Al]=["oklch(0% 0 0)","oklch(100% 0 0)","transparent"],Fv=Iv().core(({theme:e})=>({color:{black:$o,white:Ao,lowest:e.mode==="light"?Ao:$o,highest:e.mode==="light"?$o:Ao,...ko({prefix:"a-",hue:e.hue,chroma:e.chroma,mode:e.mode,transform:So}),...ko({prefix:"n-",hue:e.hue,chroma:.05,mode:e.mode,transform:So}),...ko({prefix:"e-",hue:20,chroma:e.chroma,mode:e.mode,transform:So})},typography:{}})).semantic(({core:e,raw:t,theme:r})=>{const n=(i,o)=>t.core.color[i].replace(")",` / ${o})`);return{"font-family":{body:"inherit",headings:"inherit"},"font-style":{body:"normal",headings:"normal"},"font-weight-body":"normal","font-weight-headings":"normal","radius-app":"1.5rem","radius-interactive":"1.5rem",color:{divider:n("n-8",r.mode==="dark"?.4:.2)},"copy-body":e("color.n-12"),"copy-headings":e("color.n-12"),interactive:{copy:e("color.n-11"),"copy-hover":e("color.n-12"),"copy-active":e("color.n-12"),bg:Al,"bg-hover":n("n-10",.4),"bg-active":n("n-10",.5)}}}).component(({raw:e,theme:t,semantic:r,core:n})=>{const i=(o,s)=>e.core.color[o].replace(")",` / ${s})`);return{app:{bg:n(t.mode==="dark"?"color.n-1":"color.n-2")},overlay:{bg:i("black",.4)},bubble:{"weak-bg":n(t.mode==="dark"?"color.n-3":"color.lowest"),"weak-outline":r("color.divider"),"strong-shadow":i("a-9",.05)},"status-bar":{bg:i("n-2",.8),"bg-button":Al,"bg-button-hover":i("n-10",.4),"bg-button-active":i("n-10",.5)},"submit-button":{"bg-active":n(t.mode==="dark"?"color.a-9":"color.a-10")}}}),Dv=Ov({prefix:"i-"}),Nv=e=>{const t=Fv.from({theme:e,getToken:Dv}),r=Object.entries(t.declarations).map(([n,i])=>`${n}: ${i};`);return`#isdk {
|
|
51
51
|
${r.concat(r).join(`
|
|
52
52
|
`)}
|
|
53
|
-
}`},Lv=({_internal_domManager:e=Pv(),theme:t})=>ht(({apiClient:r,logger:n,analytics:i})=>{let o=!1;const s=()=>{if(typeof window>"u")return;const a=[O("style",{id:"inploi-chatbot-styles"},Av),O("style",{id:"inploi-chatbot-theme"},Nv(t))],l=e.getOrCreateChatbotElement();Dt(O(Q,{},[a,O(kv,{apiClient:r,logger:n,analytics:i})]),l),o=!0};return{prepare:async()=>{if(!(typeof window>"u"))try{if(o)return;s(),n.info("Chatbot plugin prepared")}catch(a){n.error("Error preparing chatbot plugin",a)}},fetchFlowByJobId:async a=>r.fetch(`/flow/job/${a}`).then(l=>{const u=ar(Cv,l);return{context:{job_id:u.job.id,flow_id:u.flow.id},flow:u.flow,title:`Applying for “${u.job.title}”`,flowKeys:[u.job.id]}}),fetchFlowById:async a=>r.fetch(`/flow/id/${a}`).then(l=>{const u=ar(Sv,l);return{flow:u.flow,context:{flow_id:u.flow.id},title:"Chatbot",flowKeys:[]}}),open:async a=>{if(!(typeof window>"u"))try{L.cancelCurrentFlow(),L.viewState$.value="maximised",o||s(),a instanceof Promise?(L.current$.value={state:"loading"},a.then(async l=>{const u=ar($v,l);L.startFlow(u)}).catch(l=>{const u=l instanceof Error?l.message:"An error occurred";L.current$.value={state:"error",error:u}})):L.startFlow(a)}catch(l){n.error("Error starting flow",l)}},startApplication:void 0,closeApplication:void 0,close:async()=>{typeof window>"u"||(L.cancelCurrentFlow(),n.info("Closed flow from an external source"))}}});if(!window.inploi)throw new Error("Please insert the SDK script tag above the plugins.");window.inploi.chatbotPlugin=Lv;const Pl=({node:e,nodes:t,stopWhen:r})=>{if((r==null?void 0:r(e))===!0)return e;const n=e.nextId?t.find(i=>i.id===e.nextId):void 0;if(n)return Pl({node:n,nodes:t,stopWhen:r})},Rv=({childNode:e,nodes:t})=>{const n=t.filter(i=>i.type==="if-block").find(i=>{if(!i.branchId)return!1;const o=t.find(a=>a.id===i.branchId);if(!o)return!1;const s=Pl({node:o,nodes:t,stopWhen:a=>a.id===e.id});return!(!s||s.id!==e.id)});if(n!=null&&n.nextId)return t.find(i=>i.id===n.nextId)},Bv=({flow:e,analytics:t,logger:r,context:n,apiClient:i,getSubmissions:o,chatService:s,onFlowEnd:a,onInterpret:l})=>{let u=new AbortController;const d=async(c,f)=>{const p=o();l==null||l(c,f);try{await jv({analytics:t,logger:r,apiClient:i,context:n,node:c,submissions:p,chat:{sendMessage:async h=>s.send({groupId:c.id,message:h,signal:u.signal}),userInput:async h=>s.input({input:h,signal:u.signal})},next:h=>{const m=h?e.find(b=>b.id===h):Rv({childNode:c,nodes:e});return m?d(m,c):a==null?void 0:a(c)},end:()=>a==null?void 0:a(c)})}catch(h){if(h instanceof Er)return;throw h}};return{interpret:async c=>{const f=e.find(p=>p.id===c)??_l(e);return d(f)},undo:c=>{let f=1;const p=e.find(m=>m.id===c[c.length-1]);for(let m=c.length-2;m>0;m--){const b=c[m],x=e.find(y=>y.id===b);if(!x||(f++,x.type.startsWith("question-")))break}u.abort(),u=new AbortController;const h=e.find(m=>m.id===c[c.length-f]);return Xe(h,"Undo failed: new start node not found"),d(h,p),{removed:f}},abort:()=>{u.abort()}}};async function jv(e){return await Ue(e).with({node:{type:"text"}},Wv).with({node:{type:"image"}},Kv).with({node:{type:"question-text"}},qv).with({node:{type:"question-enum"}},Yv).with({node:{type:"question-number"}},Gv).with({node:{type:"question-boolean"}},Zv).with({node:{type:"question-file"}},Jv).with({node:{type:"question-address"}},Qv).with({node:{type:"end-flow"}},eg).with({node:{type:"if-block"}},Hv).with({node:{type:"jump"}},({node:t,next:r})=>r(t.data.targetId)).with({node:{type:"link"}},zv).with({node:{type:"integration-application-submit"}},Uv).with({node:{type:"integration-workflow-get"}},()=>Error("Unreachable")).exhaustive()}async function Uv({chat:e,next:t,node:r,logger:n,apiClient:i,submissions:o,context:s,analytics:a}){r.data.askForConfirmation!==!1&&await e.userInput({type:"submit",key:void 0,config:{label:r.data.submitLabel}}),await e.sendMessage({type:"system",variant:"info",text:"Submitting…"});const{anonymous_id:l,session_id:u}=a.getSessionInfo(),d=await i.fetch("/flow/apply",{method:"POST",body:JSON.stringify({...s,integration_id:r.data.integrationId,anonymous_id:l,session_id:u,submissions:uv(o||{})})}).catch(c=>c);await Ue(d).with({ats_data:{redirect_url:_e.string}},async c=>{await e.sendMessage({type:"text",author:"bot",text:"Almost there! Please complete your submission here:"});const f=new URL(c.ats_data.redirect_url);l&&!f.searchParams.has("anonymous_id")&&f.searchParams.set("anonymous_id",l),await e.sendMessage({type:"link",href:f.toString(),text:"Complete submission"}),t(r.nextId)}).with({success:!0},async()=>{await e.sendMessage({type:"system",variant:"success",text:"Submission completed!"}),t(r.nextId)}).otherwise(async c=>{n.error(c),await e.sendMessage({type:"system",variant:"error",text:"Failed to submit"}),t(r.id)})}async function zv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({type:"link",href:r.data.href,text:Et(r.data.cta,n)}),t(r.nextId)}async function Hv({submissions:e,next:t,node:r}){const n=tg(r,e)?r.branchId:r.nextId;t(n)}async function Wv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({author:"bot",type:"text",text:Et(r.data.text,n)}),t(r.nextId)}async function Kv({chat:e,next:t,node:r}){await e.sendMessage({author:"bot",type:"image",url:r.data.url,height:r.data.height,width:r.data.width}),t(r.nextId)}async function qv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({author:"bot",type:"text",text:Et(r.data.question,n)});const i=await e.userInput({key:r.data.key,type:"text",config:{optional:r.data.optional,placeholder:r.data.placeholder,format:r.data.format,maxChars:r.data.maxChars}});i.value===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:i.value}),t(r.nextId)}async function Gv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({author:"bot",type:"text",text:Et(r.data.question,n)});const i=await e.userInput({key:r.data.key,type:"text",config:{optional:r.data.optional,placeholder:r.data.placeholder,format:"text"}});i.value===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:i.value}),t(r.nextId)}async function Yv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({author:"bot",type:"text",text:Et(r.data.question,n)});const i=await e.userInput({key:r.data.key,type:"multiple-choice",config:r.data});i.value.length===0?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:r.data.options.filter(o=>i.value.includes(o.value)).map(o=>o.label).join(", ")}),t(r.nextId)}async function Zv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({author:"bot",type:"text",text:Et(r.data.question,n)});const o=(await e.userInput({key:r.data.key,type:"boolean",config:{optional:r.data.optional,labels:{true:r.data.trueLabel,false:r.data.falseLabel}}})).value;o===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:{true:r.data.trueLabel,false:r.data.falseLabel}[o]}),t(r.nextId)}const Xv=document.createElement("div"),El={line1:["street_number","floor","room","premise"],line2:["subpremise","street_address","route"],line3:["sublocality","neighborhood"],city:["locality","postal_town"],state:["administrative_area_level_1"],postcode:["postal_code"],country:["country"]},Tl=Object.keys(El);async function Qv({chat:e,next:t,node:r,logger:n}){if(Tl.every(h=>r.data.keys[h]===null))return t(r.nextId);const{google:i}=window;await e.sendMessage({author:"bot",type:"text",text:r.data.question});const o=async h=>{const m=[{label:"Postcode",key:r.data.keys.postcode,optional:!1,defaultValue:h.postcode},{label:"Line 1",key:r.data.keys.line1,optional:!1,defaultValue:h.line1},{label:"Line 2",key:r.data.keys.line2,optional:!0,defaultValue:h.line2},{label:"Line 3",key:r.data.keys.line3,optional:!0,defaultValue:h.line3},{label:"City",key:r.data.keys.city,optional:!1,defaultValue:h.city},{label:"State/County/Province",key:r.data.keys.state,optional:!0,defaultValue:h.state},{label:"Country",key:r.data.keys.country,optional:!1,defaultValue:h.country}];for(const b of m){if(b.key===null)continue;await e.sendMessage({author:"bot",type:"text",text:b.label});const{value:x}=await e.userInput({type:"text",key:b.key,config:{format:"text",optional:b.optional,defaultValue:b.defaultValue}});x===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:x})}};if(!Xn(window,"google")||!Xn(window.google,"maps")||!Xn(window.google.maps,"places"))return n.warn("Google maps not available, falling back to manual input."),n.info("If you’d like to use the address autocomplete, please insert the google maps API snippet in your website and make sure it has access to the *places* library."),await o({}),t(r.nextId);const s=new i.maps.places.AutocompleteService,a=new i.maps.places.PlacesService(Xv),{value:l}=await e.userInput({type:"text",key:"_internal-address-search",config:{format:"text",optional:!1,placeholder:"Search for your address"}});if(l===null)return t(r.id);await e.sendMessage({author:"user",type:"text",text:`Search for “${l}”`});const{predictions:u}=await s.getPlacePredictions({input:l}),{value:[d]}=await e.userInput({type:"multiple-choice",key:void 0,config:{options:u.slice(0,4).map(h=>({label:h.description,value:h.place_id})).concat({label:"None of these",value:"none"}),maxSelected:1,minSelected:1}});if(!d||d==="none")return t(r.id);const c=await new Promise((h,m)=>a.getDetails({placeId:d,fields:["address_components"]},(b,x)=>x!==i.maps.places.PlacesServiceStatus.OK?m(x):b===null?m("ZERO_RESULTS"):h({ok:!0,place:b}))).catch(async h=>(n.error("Failed to get address details",h),{ok:!1}));if(c.ok===!1)return await e.sendMessage({type:"system",variant:"error",text:"Failed to get address details"}),await o({}),t(r.id);const f=c.place.address_components,p=f?Tl.reduce((h,m)=>{const b=El[m],x=f.filter(y=>y.types.some(_=>b.includes(_))).map(y=>y.long_name).join(", ");return x&&(h[m]=x),h},{}):{};return await e.sendMessage({author:"bot",type:"text",text:"Please confirm or adjust your address:"}),await o(p),t(r.nextId)}async function Jv({node:e,chat:t,next:r,submissions:n}){await t.sendMessage({author:"bot",type:"text",text:Et(e.data.question,n)});const i=await t.userInput({key:e.data.key,type:"file",config:{optional:e.data.optional,extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb??10*1024,allowMultiple:e.data.multiple===!0}});if(i.value===null)await t.sendMessage({type:"system",variant:"info",text:"Skipped"});else for(const o of i.value)await t.sendMessage({author:"user",type:"file",fileName:o.name,fileSizeKb:o.sizeKb});r(e.nextId)}async function eg({chat:e,end:t,node:r}){await e.sendMessage({type:"system",variant:"info",text:r.data.systemMessage}),t()}const Vl=_e.union(_e.string,_e.array(_e.string),null),tg=(e,t)=>{const r=t==null?void 0:t[e.data.compareKey];return r?Ue({...e.data,answer:r}).with({compare:"equals"},({compareValue:n})=>typeof r.value=="string"||typeof r.value=="boolean"?n===r.value.toString():!1).with({compare:"notEquals"},({compareValue:n})=>typeof r.value=="string"||typeof r.value=="boolean"?n!==r.value.toString():!1).with({compare:"contains",answer:{value:Vl}},({compareValue:n,answer:i})=>i.value!==null&&i.value.includes(n)).with({compare:"notContains",answer:{value:Vl}},({compareValue:n,answer:i})=>i.value===null||!i.value.includes(n)).with({answer:{type:"file"}},()=>!1).exhaustive():!1},Et=(e,t)=>{const r=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;return e.replace(r,(n,i,o="")=>{i=i.trim();const s=t==null?void 0:t[i];if(!s)return o;switch(s.type){case"boolean":return s.value==="true"?"true":"false";case"file":return s.value?s.value.map(a=>`${a.name} (${Pr(a.sizeKb)})`).join(", "):"no files";case"multiple-choice":return s.value.join(", ");default:return s.value||o}})},In=({class:e,...t})=>g("button",{class:ct("bg-accent-9 active:bg-accent-10 pointer-coarse:touch-hitbox fr flex-shrink-0 rounded-full p-2 text-white transition-all disabled:cursor-not-allowed disabled:opacity-50",e),type:"submit",...t,children:g("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[g("title",{children:"Send"}),g("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),g("path",{d:"M8 4V13"})]})}),rg=25,Po=ot({instant:()=>{},smooth:()=>{}}),Ve={onSubmitSuccessFn$:ot(()=>{}),isBotTyping$:ot(!1),scrollToEnd:{instant:()=>Po.value.instant(),smooth:()=>Po.value.smooth()}},ng=()=>{const e=j(null);Ae(()=>{Po.value={instant:()=>{var r;return(r=e.current)==null?void 0:r.scrollTo({top:e.current.scrollHeight,behavior:"instant"})},smooth:()=>{e.current&&e.current.scrollHeight-e.current.scrollTop<=e.current.clientHeight*1.5&&e.current.scrollTo({top:e.current.scrollHeight,behavior:"smooth"})}}},[e]);const t=se(()=>({send:async({message:r,signal:n,groupId:i})=>{if(await Ue(r).with({author:"bot",type:"text"},async o=>{if(n!=null&&n.aborted)throw new Er;Ve.isBotTyping$.value=!0;const s=Math.min(Math.max(20,o.text.length),100)*rg;await new Promise(a=>setTimeout(a,s,{signal:n})),Ve.isBotTyping$.value=!1}).otherwise(async()=>{}),n!=null&&n.aborted)throw new Er;L.addMessage(r,i)},input:async({input:r,signal:n})=>{if(n!=null&&n.aborted)throw new Er;return L.setInput(r),await new Promise(i=>{const o=s=>{if(n!=null&&n.aborted)throw new Er;L.setInput(void 0),r.key&&L.setSubmission(r.key,s),i(s)};Ve.onSubmitSuccessFn$.value=o})}}),[]);return{chatRef:e,chatService:t}},Fn=({class:e,...t})=>g("button",{type:"button",class:ct("fr text-neutral-9 flex flex-shrink-0 items-center justify-center gap-1 rounded-full py-[6px] pl-2 pr-3 text-sm underline-offset-2 transition-all",e),...t,children:[g("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",children:[g("title",{children:"Skip"}),g("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),g("path",{d:"M13.25 4.5V8.25H9.5"})]}),"Skip"]}),Eo=()=>{const e=j(null);return W(()=>{var t;(t=e.current)==null||t.focus()},[]),e},Ml=["true","false"],ig=xu(Ml),og="answer",sg=({input:e,onSubmitSuccess:t,onHeightChange:r})=>{const n=Eo();return r(),g("form",{noValidate:!0,class:"",onSubmit:i=>{i.preventDefault();const o=Ue(i).with({nativeEvent:{submitter:_e.select(_e.union(_e.instanceOf(HTMLButtonElement),_e.instanceOf(HTMLInputElement)))}},a=>a.value).otherwise(()=>{throw new Error("invalid form")}),s=ar(ig,o);t(s)},children:[g("div",{class:"flex items-center gap-2 p-2.5",children:Ml.map((i,o)=>g("button",{ref:o===0?n:null,type:"submit",name:og,value:i,class:"bg-lowest ease-expo-out ring-divider text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block flex-1 overflow-hidden rounded-2xl px-2.5 py-2.5 ring-2 transition-all selection:bg-transparent",children:g("p",{class:"truncate text-center text-base",children:e.config.labels[i]})}))}),e.config.optional&&g("div",{class:"px-2 pb-2",children:g(Fn,{class:"w-full",type:"button",onClick:()=>t(null)})})]})},To=({error:e,onAnimationComplete:t})=>(Ae(()=>{e&&t()},[e,t]),e?g("div",{role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full px-2 py-2",children:[g("svg",{class:"text-error-9 h-4 w-4",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),g("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),g("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),g("p",{class:"truncate pr-1 text-sm",children:e.message})]}):null),ag=e=>new Promise((t,r)=>{const n=new FileReader;n.readAsDataURL(e),n.onload=()=>n.result?t(n.result.toString()):r("No result from reader"),n.onerror=r}),cg=e=>e.reduce((t,r)=>t+r.sizeKb,0),lg=_o("file"),Ol=3,ug=({file:e,class:t,...r})=>{const n=e.name.split(".").pop(),i=e.name.replace(new RegExp(`.${n}$`),"");return g("div",{class:ct("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",t),...r,children:[g("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[g("span",{class:"block truncate",children:i}),g("span",{children:[".",n]})]}),g("p",{"aria-label":"File size",class:"text-accent-11",children:Pr(e.sizeKb)})]})},Il=({class:e,...t})=>g("li",{class:ct("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...t}),Fl=e=>{const t=e.split(".").pop();if(!t)throw new Error("No file extension found");return t?"."+t:""},dg=({allowedExtensions:e,files:t})=>{const r=e.map(n=>n.toLowerCase());return t.every(n=>r.includes(Fl(n.name).toLowerCase()))},fg=(e,t)=>{const r=Fl(e);return`${e.replace(new RegExp(`${r}$`),"").slice(0,t)}${r}`},hg=({input:e,onSubmitSuccess:t,onHeightChange:r})=>{var c;const n=(c=L.current$.value.flow)==null?void 0:c.data.submissions[e.key],[i,o]=ie(lg(n)&&n.value!==null?n.value:[]),[s,a]=ie(),l=i.length-Ol,u=cg(i),d=Eo();return g("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:f=>(f.preventDefault(),a(void 0),i.length===0?a({type:"required",message:"Please select a file"}):e.config.extensions.length>0&&!dg({allowedExtensions:e.config.extensions,files:i})?a({type:"validate",message:`Please upload ${e.config.extensions.join(", ")} files only`}):e.config.fileSizeLimitKib&&u>e.config.fileSizeLimitKib?a({type:"max",message:`File size exceeds limit of ${Pr(e.config.fileSizeLimitKib)}`}):e.config.allowMultiple===!1&&i.length>1?a({type:"invalid",message:"Only one file is allowed"}):t(i)),children:[g("div",{class:"flex items-center gap-2",children:[g("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:[i.length>0?g(Q,{children:[g("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[i.slice(0,Ol).map(f=>{const p=f.name.split(".").pop(),h=f.name.replace(new RegExp(`.${p}$`),"");return g(Il,{class:"flex overflow-hidden",children:[g("span",{class:"block truncate",children:h}),g("span",{children:[".",p]})]})}),l>0?g(Il,{children:["+",l," file",l!==1?"s":""]}):null]}),g("p",{class:"text-neutral-11 text-xs",children:[Pr(u)," ",i.length>1?"total":""]})]}):g("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[g("header",{class:"flex flex-col items-center gap-0",children:[g("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:g("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"})}),g("p",{class:"text-neutral-12 tracking-[-0.01em]",children:[e.config.allowMultiple?"Select files":"Select a file"," to upload"]}),e.config.fileSizeLimitKib?g("p",{class:"text-neutral-10 text-xs",children:["(max ",Pr(e.config.fileSizeLimitKib),")"]}):null]}),g("aside",{class:"flex flex-col items-center gap-2",children:[g("p",{id:"accepted-filetypes",class:"sr-only",children:"Accepted file extensions"}),g("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(f=>g("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(".","")}))})]})]}),g("input",{id:"dropzone-file",onInput:async f=>{Xe(f.target instanceof HTMLInputElement);const p=f.target.files?Array.from(f.target.files):[],h=await Promise.allSettled(p.map(async b=>{const x=await ag(b);return{name:fg(b.name,42),data:x,sizeKb:b.size/1e3}}));if(h.some(({status:b})=>b==="rejected"))return a({type:"invalid",message:"Invalid file"});const m=h.map(b=>b.status==="fulfilled"?b.value:null).filter(Boolean);o(m)},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),g("div",{class:"flex h-full flex-col items-center gap-2",children:[g(In,{disabled:i.length===0}),e.config.optional&&g(Fn,{onClick:()=>t(null)})]})]}),s&&g(To,{onAnimationComplete:r,error:s})]})};var Mr=e=>e.type==="checkbox",Jt=e=>e instanceof Date,ye=e=>e==null;const Dl=e=>typeof e=="object";var oe=e=>!ye(e)&&!Array.isArray(e)&&Dl(e)&&!Jt(e),pg=e=>oe(e)&&e.target?Mr(e.target)?e.target.checked:e.target.value:e,mg=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,vg=(e,t)=>e.has(mg(t)),gg=e=>{const t=e.constructor&&e.constructor.prototype;return oe(t)&&t.hasOwnProperty("isPrototypeOf")},Vo=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ze(e){let t;const r=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Vo&&(e instanceof Blob||e instanceof FileList))&&(r||oe(e)))if(t=r?[]:{},!r&&!gg(e))t=e;else for(const n in e)e.hasOwnProperty(n)&&(t[n]=ze(e[n]));else return e;return t}var Or=e=>Array.isArray(e)?e.filter(Boolean):[],te=e=>e===void 0,V=(e,t,r)=>{if(!t||!oe(e))return r;const n=Or(t.split(/[,[\].]+?/)).reduce((i,o)=>ye(i)?i:i[o],e);return te(n)||n===e?te(e[t])?r:e[t]:n},lt=e=>typeof e=="boolean";const Nl={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Me={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},He={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};Te.createContext(null);var yg=(e,t,r,n=!0)=>{const i={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(i,o,{get:()=>{const s=o;return t._proxyFormState[s]!==Me.all&&(t._proxyFormState[s]=!n||Me.all),r&&(r[s]=!0),e[s]}});return i},Pe=e=>oe(e)&&!Object.keys(e).length,bg=(e,t,r,n)=>{r(e);const{name:i,...o}=e;return Pe(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(s=>t[s]===(!n||Me.all))},Mo=e=>Array.isArray(e)?e:[e];function wg(e){const t=Te.useRef(e);t.current=e,Te.useEffect(()=>{const r=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{r&&r.unsubscribe()}},[e.disabled])}var Le=e=>typeof e=="string",_g=(e,t,r,n,i)=>Le(e)?(n&&t.watch.add(e),V(r,e,i)):Array.isArray(e)?e.map(o=>(n&&t.watch.add(o),V(r,o))):(n&&(t.watchAll=!0),r),Oo=e=>/^\w*$/.test(e),Ll=e=>Or(e.replace(/["|']|\]/g,"").split(/\.|\[/));function G(e,t,r){let n=-1;const i=Oo(t)?[t]:Ll(t),o=i.length,s=o-1;for(;++n<o;){const a=i[n];let l=r;if(n!==s){const u=e[a];l=oe(u)||Array.isArray(u)?u:isNaN(+i[n+1])?{}:[]}e[a]=l,e=e[a]}return e}var Rl=(e,t,r,n,i)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:i||!0}}:{},Bl=e=>({isOnSubmit:!e||e===Me.onSubmit,isOnBlur:e===Me.onBlur,isOnChange:e===Me.onChange,isOnAll:e===Me.all,isOnTouch:e===Me.onTouched}),jl=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Dn=(e,t,r,n)=>{for(const i of r||Object.keys(e)){const o=V(e,i);if(o){const{_f:s,...a}=o;if(s){if(s.refs&&s.refs[0]&&t(s.refs[0],i)&&!n)break;if(s.ref&&t(s.ref,s.name)&&!n)break}else oe(a)&&Dn(a,t)}}};var xg=(e,t,r)=>{const n=Or(V(e,r));return G(n,"root",t[r]),G(e,r,n),e},Io=e=>e.type==="file",ut=e=>typeof e=="function",Nn=e=>{if(!Vo)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Ln=e=>Le(e),Fo=e=>e.type==="radio",Rn=e=>e instanceof RegExp;const Ul={value:!1,isValid:!1},zl={value:!0,isValid:!0};var Hl=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!te(e[0].attributes.value)?te(e[0].value)||e[0].value===""?zl:{value:e[0].value,isValid:!0}:zl:Ul}return Ul};const Wl={isValid:!1,value:null};var Kl=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,Wl):Wl;function ql(e,t,r="validate"){if(Ln(e)||Array.isArray(e)&&e.every(Ln)||lt(e)&&!e)return{type:r,message:Ln(e)?e:"",ref:t}}var er=e=>oe(e)&&!Rn(e)?e:{value:e,message:""},Gl=async(e,t,r,n,i)=>{const{ref:o,refs:s,required:a,maxLength:l,minLength:u,min:d,max:c,pattern:f,validate:p,name:h,valueAsNumber:m,mount:b,disabled:x}=e._f,y=V(t,h);if(!b||x)return{};const _=s?s[0]:o,C=U=>{n&&_.reportValidity&&(_.setCustomValidity(lt(U)?"":U||""),_.reportValidity())},S={},N=Fo(o),F=Mr(o),A=N||F,T=(m||Io(o))&&te(o.value)&&te(y)||Nn(o)&&o.value===""||y===""||Array.isArray(y)&&!y.length,K=Rl.bind(null,h,r,S),J=(U,R,B,z=He.maxLength,re=He.minLength)=>{const de=U?R:B;S[h]={type:U?z:re,message:de,ref:o,...K(U?z:re,de)}};if(i?!Array.isArray(y)||!y.length:a&&(!A&&(T||ye(y))||lt(y)&&!y||F&&!Hl(s).isValid||N&&!Kl(s).isValid)){const{value:U,message:R}=Ln(a)?{value:!!a,message:a}:er(a);if(U&&(S[h]={type:He.required,message:R,ref:_,...K(He.required,R)},!r))return C(R),S}if(!T&&(!ye(d)||!ye(c))){let U,R;const B=er(c),z=er(d);if(!ye(y)&&!isNaN(y)){const re=o.valueAsNumber||y&&+y;ye(B.value)||(U=re>B.value),ye(z.value)||(R=re<z.value)}else{const re=o.valueAsDate||new Date(y),de=Vt=>new Date(new Date().toDateString()+" "+Vt),We=o.type=="time",dt=o.type=="week";Le(B.value)&&y&&(U=We?de(y)>de(B.value):dt?y>B.value:re>new Date(B.value)),Le(z.value)&&y&&(R=We?de(y)<de(z.value):dt?y<z.value:re<new Date(z.value))}if((U||R)&&(J(!!U,B.message,z.message,He.max,He.min),!r))return C(S[h].message),S}if((l||u)&&!T&&(Le(y)||i&&Array.isArray(y))){const U=er(l),R=er(u),B=!ye(U.value)&&y.length>+U.value,z=!ye(R.value)&&y.length<+R.value;if((B||z)&&(J(B,U.message,R.message),!r))return C(S[h].message),S}if(f&&!T&&Le(y)){const{value:U,message:R}=er(f);if(Rn(U)&&!y.match(U)&&(S[h]={type:He.pattern,message:R,ref:o,...K(He.pattern,R)},!r))return C(R),S}if(p){if(ut(p)){const U=await p(y,t),R=ql(U,_);if(R&&(S[h]={...R,...K(He.validate,R.message)},!r))return C(R.message),S}else if(oe(p)){let U={};for(const R in p){if(!Pe(U)&&!r)break;const B=ql(await p[R](y,t),_,R);B&&(U={...B,...K(R,B.message)},C(B.message),r&&(S[h]=U))}if(!Pe(U)&&(S[h]={ref:_,...U},!r))return S}}return C(!0),S};function kg(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;)e=te(e)?n++:e[t[n++]];return e}function Sg(e){for(const t in e)if(e.hasOwnProperty(t)&&!te(e[t]))return!1;return!0}function ue(e,t){const r=Array.isArray(t)?t:Oo(t)?[t]:Ll(t),n=r.length===1?e:kg(e,r),i=r.length-1,o=r[i];return n&&delete n[o],i!==0&&(oe(n)&&Pe(n)||Array.isArray(n)&&Sg(n))&&ue(e,r.slice(0,-1)),e}function Do(){let e=[];return{get observers(){return e},next:i=>{for(const o of e)o.next&&o.next(i)},subscribe:i=>(e.push(i),{unsubscribe:()=>{e=e.filter(o=>o!==i)}}),unsubscribe:()=>{e=[]}}}var Bn=e=>ye(e)||!Dl(e);function Tt(e,t){if(Bn(e)||Bn(t))return e===t;if(Jt(e)&&Jt(t))return e.getTime()===t.getTime();const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const i of r){const o=e[i];if(!n.includes(i))return!1;if(i!=="ref"){const s=t[i];if(Jt(o)&&Jt(s)||oe(o)&&oe(s)||Array.isArray(o)&&Array.isArray(s)?!Tt(o,s):o!==s)return!1}}return!0}var Yl=e=>e.type==="select-multiple",Cg=e=>Fo(e)||Mr(e),No=e=>Nn(e)&&e.isConnected,Zl=e=>{for(const t in e)if(ut(e[t]))return!0;return!1};function jn(e,t={}){const r=Array.isArray(e);if(oe(e)||r)for(const n in e)Array.isArray(e[n])||oe(e[n])&&!Zl(e[n])?(t[n]=Array.isArray(e[n])?[]:{},jn(e[n],t[n])):ye(e[n])||(t[n]=!0);return t}function Xl(e,t,r){const n=Array.isArray(e);if(oe(e)||n)for(const i in e)Array.isArray(e[i])||oe(e[i])&&!Zl(e[i])?te(t)||Bn(r[i])?r[i]=Array.isArray(e[i])?jn(e[i],[]):{...jn(e[i])}:Xl(e[i],ye(t)?{}:t[i],r[i]):r[i]=!Tt(e[i],t[i]);return r}var Lo=(e,t)=>Xl(e,t,jn(t)),Ql=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>te(e)?e:t?e===""?NaN:e&&+e:r&&Le(e)?new Date(e):n?n(e):e;function Ro(e){const t=e.ref;if(!(e.refs?e.refs.every(r=>r.disabled):t.disabled))return Io(t)?t.files:Fo(t)?Kl(e.refs).value:Yl(t)?[...t.selectedOptions].map(({value:r})=>r):Mr(t)?Hl(e.refs).value:Ql(te(t.value)?e.ref.value:t.value,e)}var $g=(e,t,r,n)=>{const i={};for(const o of e){const s=V(t,o);s&&G(i,o,s._f)}return{criteriaMode:r,names:[...e],fields:i,shouldUseNativeValidation:n}},Ir=e=>te(e)?e:Rn(e)?e.source:oe(e)?Rn(e.value)?e.value.source:e.value:e,Ag=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Jl(e,t,r){const n=V(e,r);if(n||Oo(r))return{error:n,name:r};const i=r.split(".");for(;i.length;){const o=i.join("."),s=V(t,o),a=V(e,o);if(s&&!Array.isArray(s)&&r!==o)return{name:r};if(a&&a.type)return{name:o,error:a};i.pop()}return{name:r}}var Pg=(e,t,r,n,i)=>i.isOnAll?!1:!r&&i.isOnTouch?!(t||e):(r?n.isOnBlur:i.isOnBlur)?!e:(r?n.isOnChange:i.isOnChange)?e:!0,Eg=(e,t)=>!Or(V(e,t)).length&&ue(e,t);const Tg={mode:Me.onSubmit,reValidateMode:Me.onChange,shouldFocusError:!0};function Vg(e={},t){let r={...Tg,...e},n={submitCount:0,isDirty:!1,isLoading:ut(r.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},i={},o=oe(r.defaultValues)||oe(r.values)?ze(r.defaultValues||r.values)||{}:{},s=r.shouldUnregister?{}:ze(o),a={action:!1,mount:!1,watch:!1},l={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,d=0;const c={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Do(),array:Do(),state:Do()},p=e.resetOptions&&e.resetOptions.keepDirtyValues,h=Bl(r.mode),m=Bl(r.reValidateMode),b=r.criteriaMode===Me.all,x=v=>w=>{clearTimeout(d),d=setTimeout(v,w)},y=async v=>{if(c.isValid||v){const w=r.resolver?Pe((await T()).errors):await J(i,!0);w!==n.isValid&&f.state.next({isValid:w})}},_=v=>c.isValidating&&f.state.next({isValidating:v}),C=(v,w=[],k,M,P=!0,$=!0)=>{if(M&&k){if(a.action=!0,$&&Array.isArray(V(i,v))){const I=k(V(i,v),M.argA,M.argB);P&&G(i,v,I)}if($&&Array.isArray(V(n.errors,v))){const I=k(V(n.errors,v),M.argA,M.argB);P&&G(n.errors,v,I),Eg(n.errors,v)}if(c.touchedFields&&$&&Array.isArray(V(n.touchedFields,v))){const I=k(V(n.touchedFields,v),M.argA,M.argB);P&&G(n.touchedFields,v,I)}c.dirtyFields&&(n.dirtyFields=Lo(o,s)),f.state.next({name:v,isDirty:R(v,w),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else G(s,v,w)},S=(v,w)=>{G(n.errors,v,w),f.state.next({errors:n.errors})},N=(v,w,k,M)=>{const P=V(i,v);if(P){const $=V(s,v,te(k)?V(o,v):k);te($)||M&&M.defaultChecked||w?G(s,v,w?$:Ro(P._f)):re(v,$),a.mount&&y()}},F=(v,w,k,M,P)=>{let $=!1,I=!1;const Z={name:v};if(!k||M){c.isDirty&&(I=n.isDirty,n.isDirty=Z.isDirty=R(),$=I!==Z.isDirty);const ne=Tt(V(o,v),w);I=V(n.dirtyFields,v),ne?ue(n.dirtyFields,v):G(n.dirtyFields,v,!0),Z.dirtyFields=n.dirtyFields,$=$||c.dirtyFields&&I!==!ne}if(k){const ne=V(n.touchedFields,v);ne||(G(n.touchedFields,v,k),Z.touchedFields=n.touchedFields,$=$||c.touchedFields&&ne!==k)}return $&&P&&f.state.next(Z),$?Z:{}},A=(v,w,k,M)=>{const P=V(n.errors,v),$=c.isValid&<(w)&&n.isValid!==w;if(e.delayError&&k?(u=x(()=>S(v,k)),u(e.delayError)):(clearTimeout(d),u=null,k?G(n.errors,v,k):ue(n.errors,v)),(k?!Tt(P,k):P)||!Pe(M)||$){const I={...M,...$&<(w)?{isValid:w}:{},errors:n.errors,name:v};n={...n,...I},f.state.next(I)}_(!1)},T=async v=>r.resolver(s,r.context,$g(v||l.mount,i,r.criteriaMode,r.shouldUseNativeValidation)),K=async v=>{const{errors:w}=await T(v);if(v)for(const k of v){const M=V(w,k);M?G(n.errors,k,M):ue(n.errors,k)}else n.errors=w;return w},J=async(v,w,k={valid:!0})=>{for(const M in v){const P=v[M];if(P){const{_f:$,...I}=P;if($){const Z=l.array.has($.name),ne=await Gl(P,s,b,r.shouldUseNativeValidation&&!w,Z);if(ne[$.name]&&(k.valid=!1,w))break;!w&&(V(ne,$.name)?Z?xg(n.errors,ne,$.name):G(n.errors,$.name,ne[$.name]):ue(n.errors,$.name))}I&&await J(I,w,k)}}return k.valid},U=()=>{for(const v of l.unMount){const w=V(i,v);w&&(w._f.refs?w._f.refs.every(k=>!No(k)):!No(w._f.ref))&&rr(v)}l.unMount=new Set},R=(v,w)=>(v&&w&&G(s,v,w),!Tt(ft(),o)),B=(v,w,k)=>_g(v,l,{...a.mount?s:te(w)?o:Le(v)?{[v]:w}:w},k,w),z=v=>Or(V(a.mount?s:o,v,e.shouldUnregister?V(o,v,[]):[])),re=(v,w,k={})=>{const M=V(i,v);let P=w;if(M){const $=M._f;$&&(!$.disabled&&G(s,v,Ql(w,$)),P=Nn($.ref)&&ye(w)?"":w,Yl($.ref)?[...$.ref.options].forEach(I=>I.selected=P.includes(I.value)):$.refs?Mr($.ref)?$.refs.length>1?$.refs.forEach(I=>(!I.defaultChecked||!I.disabled)&&(I.checked=Array.isArray(P)?!!P.find(Z=>Z===I.value):P===I.value)):$.refs[0]&&($.refs[0].checked=!!P):$.refs.forEach(I=>I.checked=I.value===P):Io($.ref)?$.ref.value="":($.ref.value=P,$.ref.type||f.values.next({name:v,values:{...s}})))}(k.shouldDirty||k.shouldTouch)&&F(v,P,k.shouldTouch,k.shouldDirty,!0),k.shouldValidate&&Y(v)},de=(v,w,k)=>{for(const M in w){const P=w[M],$=`${v}.${M}`,I=V(i,$);(l.array.has(v)||!Bn(P)||I&&!I._f)&&!Jt(P)?de($,P,k):re($,P,k)}},We=(v,w,k={})=>{const M=V(i,v),P=l.array.has(v),$=ze(w);G(s,v,$),P?(f.array.next({name:v,values:{...s}}),(c.isDirty||c.dirtyFields)&&k.shouldDirty&&f.state.next({name:v,dirtyFields:Lo(o,s),isDirty:R(v,$)})):M&&!M._f&&!ye($)?de(v,$,k):re(v,$,k),jl(v,l)&&f.state.next({...n}),f.values.next({name:v,values:{...s}}),!a.mount&&t()},dt=async v=>{const w=v.target;let k=w.name,M=!0;const P=V(i,k),$=()=>w.type?Ro(P._f):pg(v),I=Z=>{M=Number.isNaN(Z)||Z===V(s,k,Z)};if(P){let Z,ne;const Wn=$(),nr=v.type===Nl.BLUR||v.type===Nl.FOCUS_OUT,cy=!Ag(P._f)&&!r.resolver&&!V(n.errors,k)&&!P._f.deps||Pg(nr,V(n.touchedFields,k),n.isSubmitted,m,h),Bo=jl(k,l,nr);G(s,k,Wn),nr?(P._f.onBlur&&P._f.onBlur(v),u&&u(0)):P._f.onChange&&P._f.onChange(v);const jo=F(k,Wn,nr,!1),ly=!Pe(jo)||Bo;if(!nr&&f.values.next({name:k,type:v.type,values:{...s}}),cy)return c.isValid&&y(),ly&&f.state.next({name:k,...Bo?{}:jo});if(!nr&&Bo&&f.state.next({...n}),_(!0),r.resolver){const{errors:cu}=await T([k]);if(I(Wn),M){const uy=Jl(n.errors,i,k),lu=Jl(cu,i,uy.name||k);Z=lu.error,k=lu.name,ne=Pe(cu)}}else Z=(await Gl(P,s,b,r.shouldUseNativeValidation))[k],I(Wn),M&&(Z?ne=!1:c.isValid&&(ne=await J(i,!0)));M&&(P._f.deps&&Y(P._f.deps),A(k,ne,Z,jo))}},Vt=(v,w)=>{if(V(n.errors,w)&&v.focus)return v.focus(),1},Y=async(v,w={})=>{let k,M;const P=Mo(v);if(_(!0),r.resolver){const $=await K(te(v)?v:P);k=Pe($),M=v?!P.some(I=>V($,I)):k}else v?(M=(await Promise.all(P.map(async $=>{const I=V(i,$);return await J(I&&I._f?{[$]:I}:I)}))).every(Boolean),!(!M&&!n.isValid)&&y()):M=k=await J(i);return f.state.next({...!Le(v)||c.isValid&&k!==n.isValid?{}:{name:v},...r.resolver||!v?{isValid:k}:{},errors:n.errors,isValidating:!1}),w.shouldFocus&&!M&&Dn(i,Vt,v?P:l.mount),M},ft=v=>{const w={...o,...a.mount?s:{}};return te(v)?w:Le(v)?V(w,v):v.map(k=>V(w,k))},Fr=(v,w)=>({invalid:!!V((w||n).errors,v),isDirty:!!V((w||n).dirtyFields,v),isTouched:!!V((w||n).touchedFields,v),error:V((w||n).errors,v)}),Un=v=>{v&&Mo(v).forEach(w=>ue(n.errors,w)),f.state.next({errors:v?n.errors:{}})},Dr=(v,w,k)=>{const M=(V(i,v,{_f:{}})._f||{}).ref;G(n.errors,v,{...w,ref:M}),f.state.next({name:v,errors:n.errors,isValid:!1}),k&&k.shouldFocus&&M&&M.focus&&M.focus()},Mt=(v,w)=>ut(v)?f.values.subscribe({next:k=>v(B(void 0,w),k)}):B(v,w,!0),rr=(v,w={})=>{for(const k of v?Mo(v):l.mount)l.mount.delete(k),l.array.delete(k),w.keepValue||(ue(i,k),ue(s,k)),!w.keepError&&ue(n.errors,k),!w.keepDirty&&ue(n.dirtyFields,k),!w.keepTouched&&ue(n.touchedFields,k),!r.shouldUnregister&&!w.keepDefaultValue&&ue(o,k);f.values.next({values:{...s}}),f.state.next({...n,...w.keepDirty?{isDirty:R()}:{}}),!w.keepIsValid&&y()},zn=({disabled:v,name:w,field:k,fields:M,value:P})=>{if(lt(v)){const $=v?void 0:te(P)?Ro(k?k._f:V(M,w)._f):P;G(s,w,$),F(w,$,!1,!1,!0)}},Ot=(v,w={})=>{let k=V(i,v);const M=lt(w.disabled);return G(i,v,{...k||{},_f:{...k&&k._f?k._f:{ref:{name:v}},name:v,mount:!0,...w}}),l.mount.add(v),k?zn({field:k,disabled:w.disabled,name:v}):N(v,!0,w.value),{...M?{disabled:w.disabled}:{},...r.progressive?{required:!!w.required,min:Ir(w.min),max:Ir(w.max),minLength:Ir(w.minLength),maxLength:Ir(w.maxLength),pattern:Ir(w.pattern)}:{},name:v,onChange:dt,onBlur:dt,ref:P=>{if(P){Ot(v,w),k=V(i,v);const $=te(P.value)&&P.querySelectorAll&&P.querySelectorAll("input,select,textarea")[0]||P,I=Cg($),Z=k._f.refs||[];if(I?Z.find(ne=>ne===$):$===k._f.ref)return;G(i,v,{_f:{...k._f,...I?{refs:[...Z.filter(No),$,...Array.isArray(V(o,v))?[{}]:[]],ref:{type:$.type,name:v}}:{ref:$}}}),N(v,!1,void 0,$)}else k=V(i,v,{}),k._f&&(k._f.mount=!1),(r.shouldUnregister||w.shouldUnregister)&&!(vg(l.array,v)&&a.action)&&l.unMount.add(v)}}},It=()=>r.shouldFocusError&&Dn(i,Vt,l.mount),Ke=v=>{lt(v)&&(f.state.next({disabled:v}),Dn(i,w=>{w.disabled=v},0,!1))},Nr=(v,w)=>async k=>{k&&(k.preventDefault&&k.preventDefault(),k.persist&&k.persist());let M=ze(s);if(f.state.next({isSubmitting:!0}),r.resolver){const{errors:P,values:$}=await T();n.errors=P,M=$}else await J(i);ue(n.errors,"root"),Pe(n.errors)?(f.state.next({errors:{}}),await v(M,k)):(w&&await w({...n.errors},k),It(),setTimeout(It)),f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Pe(n.errors),submitCount:n.submitCount+1,errors:n.errors})},Hn=(v,w={})=>{V(i,v)&&(te(w.defaultValue)?We(v,V(o,v)):(We(v,w.defaultValue),G(o,v,w.defaultValue)),w.keepTouched||ue(n.touchedFields,v),w.keepDirty||(ue(n.dirtyFields,v),n.isDirty=w.defaultValue?R(v,V(o,v)):R()),w.keepError||(ue(n.errors,v),c.isValid&&y()),f.state.next({...n}))},su=(v,w={})=>{const k=v?ze(v):o,M=ze(k),P=v&&!Pe(v)?M:o;if(w.keepDefaultValues||(o=k),!w.keepValues){if(w.keepDirtyValues||p)for(const $ of l.mount)V(n.dirtyFields,$)?G(P,$,V(s,$)):We($,V(P,$));else{if(Vo&&te(v))for(const $ of l.mount){const I=V(i,$);if(I&&I._f){const Z=Array.isArray(I._f.refs)?I._f.refs[0]:I._f.ref;if(Nn(Z)){const ne=Z.closest("form");if(ne){ne.reset();break}}}}i={}}s=e.shouldUnregister?w.keepDefaultValues?ze(o):{}:ze(P),f.array.next({values:{...P}}),f.values.next({values:{...P}})}l={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!a.mount&&t(),a.mount=!c.isValid||!!w.keepIsValid,a.watch=!!e.shouldUnregister,f.state.next({submitCount:w.keepSubmitCount?n.submitCount:0,isDirty:w.keepDirty?n.isDirty:!!(w.keepDefaultValues&&!Tt(v,o)),isSubmitted:w.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:w.keepDirtyValues?n.dirtyFields:w.keepDefaultValues&&v?Lo(o,v):{},touchedFields:w.keepTouched?n.touchedFields:{},errors:w.keepErrors?n.errors:{},isSubmitSuccessful:w.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},au=(v,w)=>su(ut(v)?v(s):v,w);return{control:{register:Ot,unregister:rr,getFieldState:Fr,handleSubmit:Nr,setError:Dr,_executeSchema:T,_getWatch:B,_getDirty:R,_updateValid:y,_removeUnmounted:U,_updateFieldArray:C,_updateDisabledField:zn,_getFieldArray:z,_reset:su,_resetDefaultValues:()=>ut(r.defaultValues)&&r.defaultValues().then(v=>{au(v,r.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:v=>{n={...n,...v}},_disableForm:Ke,_subjects:f,_proxyFormState:c,get _fields(){return i},get _formValues(){return s},get _state(){return a},set _state(v){a=v},get _defaultValues(){return o},get _names(){return l},set _names(v){l=v},get _formState(){return n},set _formState(v){n=v},get _options(){return r},set _options(v){r={...r,...v}}},trigger:Y,register:Ot,handleSubmit:Nr,watch:Mt,setValue:We,getValues:ft,reset:au,resetField:Hn,clearErrors:Un,unregister:rr,setError:Dr,setFocus:(v,w={})=>{const k=V(i,v),M=k&&k._f;if(M){const P=M.refs?M.refs[0]:M.ref;P.focus&&(P.focus(),w.shouldSelect&&P.select())}},getFieldState:Fr}}function eu(e={}){const t=Te.useRef(),r=Te.useRef(),[n,i]=Te.useState({isDirty:!1,isValidating:!1,isLoading:ut(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:ut(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Vg(e,()=>i(s=>({...s}))),formState:n});const o=t.current.control;return o._options=e,wg({subject:o._subjects.state,next:s=>{bg(s,o._proxyFormState,o._updateFormState,!0)&&i({...o._formState})}}),Te.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),Te.useEffect(()=>{if(o._proxyFormState.isDirty){const s=o._getDirty();s!==n.isDirty&&o._subjects.state.next({isDirty:s})}},[o,n.isDirty]),Te.useEffect(()=>{e.values&&!Tt(e.values,r.current)?(o._reset(e.values,o._options.resetOptions),r.current=e.values):o._resetDefaultValues()},[e.values,o]),Te.useEffect(()=>{o._state.mount||(o._updateValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=yg(n,o),t.current}var tu=function(e,t,r){if(e&&"reportValidity"in e){var n=V(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},Mg=function(e,t){var r=function(i){var o=t.fields[i];o&&o.ref&&"reportValidity"in o.ref?tu(o.ref,i,e):o.refs&&o.refs.forEach(function(s){return tu(s,i,e)})};for(var n in t.fields)r(n)},Og=function(e,t){t.shouldUseNativeValidation&&Mg(e,t);var r={};for(var n in e){var i=V(t.fields,n),o=Object.assign(e[n]||{},{ref:i&&i.ref});if(Fg(t.names||Object.keys(e),n)){var s=Object.assign({},Ig(V(r,n)));G(s,"root",o),G(r,n,s)}else G(r,n,o)}return r},Ig=function(e){return Array.isArray(e)?e.filter(Boolean):[]},Fg=function(e,t){return e.some(function(r){return r.startsWith(t+".")})},Dg=function(e,t){for(var r={};e.issues.length;){var n=e.issues[0];if(n.path){var i=n.path.map(function(a){return a.key}).join(".");if(r[i]||(r[i]={message:n.message,type:n.validation}),t){var o=r[i].types,s=o&&o[n.validation];r[i]=Rl(i,t,r,n.validation,s?[].concat(s,n.message):n.message)}e.issues.shift()}}return r},ru=function(e,t,r){return r===void 0&&(r={}),function(n,i,o){try{return Promise.resolve(function(s,a){try{var l=function(){function u(c){return{values:r.raw?n:c,errors:{}}}var d=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},t);return r.mode==="sync"?u(ar(e,n,d)):Promise.resolve(Cu(e,n,d)).then(u)}()}catch(u){return a(u)}return l&&l.then?l.then(void 0,a):l}(0,function(s){if(s instanceof Zn)return{values:{},errors:Og(Dg(s,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw s}))}catch(s){return Promise.reject(s)}}};const Ng=27,Lg=12,Rg=10,Bg=e=>{const t=Object.fromEntries(new FormData(e).entries());Object.keys(t).length&&e.dispatchEvent(new Event("submit",{bubbles:!0}))},jg=_o("multiple-choice"),Ug=e=>{const t={min:e.minSelected??0,max:e.maxSelected??e.options.length};return ru(Ze({checked:ds(us(wu()),r=>Object.entries(r).filter(([n,i])=>i).map(([n,i])=>n),[cr(t.max,`Please select at most ${t.max} option${t.max!==1?"s":""}`),fs(t.min,`Please select at least ${t.min} option${t.min!==1?"s":""}`)])}))},zg=({input:e,onSubmitSuccess:t,onHeightChange:r})=>{var u,d;const n=e.key?(u=L.current$.value.flow)==null?void 0:u.data.submissions[e.key]:void 0,i=(e.config.minSelected===1||e.config.minSelected===void 0)&&e.config.maxSelected===1,{register:o,handleSubmit:s,formState:{errors:a}}=eu({defaultValues:{checked:i?{}:jg(n)?Object.fromEntries(n.value.map(c=>[c,!0])):{}},resolver:Ug(e.config)}),l=Eo();return g("form",{noValidate:!0,class:"flex flex-col gap-1 pr-2.5",onChange:c=>{i&&Bg(c.currentTarget)},onSubmit:s(c=>{const f=c.checked;t(f)}),children:[g("div",{class:"flex items-center gap-1",children:[g("ul",{style:{maxHeight:6.5*Ng+5*Lg+2*Rg},class:ct("gutter-stable flex w-full flex-1 flex-wrap gap-3 overflow-y-auto rounded-xl p-2.5 pr-4",{"justify-center":e.config.options.length===1}),children:e.config.options.map((c,f)=>{const p=`checked.${c.value}`,{ref:h,...m}=o(p);return g("li",{class:"relative",children:[g("input",{autoFocus:f===0,ref:b=>{b&&f===0&&(l.current=b),h(b)},id:p,...m,class:"peer sr-only h-full",type:"checkbox"}),g("label",{class:"bg-lowest peer-focus-visible:ring-accent-7 active:outline-neutral-10 ease-expo-out outline-divider text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 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:p,children:c.label})]},c.value)})}),g("div",{class:"flex flex-col items-center gap-2",children:[!i&&g(In,{}),e.config.minSelected===0&&g(Fn,{type:"button",onClick:()=>t([])})]})]}),g("div",{class:"px-1",children:g(To,{onAnimationComplete:r,error:(d=a.checked)==null?void 0:d.root})})]})},Hg=({input:e,onSubmitSuccess:t})=>g("div",{class:"flex flex-col items-center py-3",children:g("button",{class:"bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 group flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white shadow-[inset_0px_-6px_2px_-1px_oklch(100_0_0/.45),inset_0px_1px_1px_oklch(100_0_0/.3)] outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:shadow-[inset_0px_0px_2px_-1px_oklch(100_0_0/.45),inset_0px_3px_1px_.5px_oklch(0_0_0/.08)] active:ring-2 active:ring-offset-2",name:e.key,onClick:()=>{t(null)},children:g("span",{class:"relative bottom-[2px] top-[-2px] flex items-center gap-1.5 transition-all duration-300 group-active:bottom-0 group-active:top-0",children:[g("span",{class:"inline-flex items-center text-sm font-medium",children:e.config.label}),g("svg",{stroke:"currentColor","stroke-width":"1.5",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g("path",{d:"M4 8L8 4L12 8"}),g("path",{d:"M8 4V13"})]})]})})}),tr={empty:"Please enter some text",email:"That doesn’t look like a valid email address",phone:"That doesn’t look like a valid phone number",url:"That doesn’t look like a valid URL"},Wg=$e(tr.phone,[Pu(/^\+?[0-9 -]+$/,tr.phone)]),Kg={email:{type:"email",inputMode:"email",formNoValidate:!0},phone:{type:"tel",inputMode:"tel"},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},qg=_o("text"),Gg=e=>{const t=`Please enter no more than ${e.maxChars} characters`;return ru(Ze({text:{email:$e(tr.email,[Au(tr.email),cr(e.maxChars??1/0,t)]),phone:ds(Wg,r=>r.replace(/[^0-9]/g,""),[cr(e.maxChars??1/0,t)]),text:$e([fs(1,tr.empty),cr(e.maxChars??1/0,t)]),url:$e([Eu(tr.url),cr(e.maxChars??1/0,t)])}[e.format]}))},Yg=({input:e,onSubmitSuccess:t,onHeightChange:r})=>{var c;const n=e.key?(c=L.current$.value.flow)==null?void 0:c.data.submissions[e.key]:void 0,i=e.config.defaultValue,{register:o,handleSubmit:s,formState:{errors:a}}=eu({defaultValues:{text:i||(qg(n)?n.value:"")},resolver:Gg(e.config)}),{ref:l,...u}=o("text",{required:!e.config.optional}),d=j();return Ae(()=>{d.current&&(d.current.focus(),d.current.select())},[]),g(Q,{children:g("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:s(f=>{t(f.text)}),children:[g("div",{class:"flex items-center gap-2",children:[g("div",{class:"relative min-w-0 flex-grow",children:[g("input",{id:"chat-input",...u,...Kg[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:f=>{f&&(d.current=f),l(f)},class:"outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest w-full rounded-full px-3 py-1 text-base outline outline-2 transition-all",placeholder:e.config.placeholder}),e.config.optional&&g(Fn,{class:"absolute right-0 top-0",onClick:()=>t(null)})]}),g(In,{})]}),g(To,{onAnimationComplete:r,error:a.text})]})})},Zg=()=>{var i;const e=(i=L.current$.value.flow)==null?void 0:i.data.currentInput,t=j(null),r=ae(()=>{t.current&&(L.inputHeight$.value=t.current.getBoundingClientRect().height)},[]);W(()=>{r()},[e==null?void 0:e.type,r]);const n=o=>s=>Ve.onSubmitSuccessFn$.value({type:o,value:s});return g(kn.div,{initial:{height:0},animate:{height:L.inputHeight$.value},exit:{height:0,opacity:0},onAnimationStart:Ve.scrollToEnd.smooth,onAnimationComplete:Ve.scrollToEnd.smooth,class:"bg-statusbar absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-md backdrop-saturate-150",children:g("div",{ref:t,class:"border-divider border-t",children:Ue({input:e,onHeightChange:r}).with({input:_e.nullish},()=>g("div",{class:"flex items-center gap-2 p-2.5",children:[g("input",{"aria-hidden":"true",id:"chat-input",class:"outline-divider flex-grow rounded-full bg-transparent px-3 py-1 text-base outline outline-2",disabled:!0}),g(In,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})).with({input:{type:"text"}},o=>g(Yg,{onSubmitSuccess:n(o.input.type),...o})).with({input:{type:"multiple-choice"}},o=>g(zg,{onSubmitSuccess:n(o.input.type),...o})).with({input:{type:"boolean"}},o=>g(sg,{onSubmitSuccess:n(o.input.type),...o})).with({input:{type:"file"}},o=>g(hg,{onSubmitSuccess:n(o.input.type),...o})).with({input:{type:"submit"}},o=>g(Hg,{onSubmitSuccess:n(o.input.type),...o})).exhaustive()})})},nu=e=>typeof e=="boolean"?"".concat(e):e===0?"0":e,iu=ct,ou=(e,t)=>r=>{var n;if((t==null?void 0:t.variants)==null)return iu(e,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:i,defaultVariants:o}=t,s=Object.keys(i).map(u=>{const d=r==null?void 0:r[u],c=o==null?void 0:o[u];if(d===null)return null;const f=nu(d)||nu(c);return i[u][f]}),a=r&&Object.entries(r).reduce((u,d)=>{let[c,f]=d;return f===void 0||(u[c]=f),u},{}),l=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,d)=>{let{class:c,className:f,...p}=d;return Object.entries(p).every(h=>{let[m,b]=h;return Array.isArray(b)?b.includes({...o,...a}[m]):{...o,...a}[m]===b})?[...u,c,f]:u},[]);return iu(e,s,l,r==null?void 0:r.class,r==null?void 0:r.className)},Xg=ou("max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative",{variants:{side:{left:"bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",right:"ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"},transitionState:{entering:"opacity-0 translate-y-8",entered:"opacity-100 translate-y-0",exiting:"opacity-0 scale-0",exited:""}},defaultVariants:{side:"left"}}),Qg={hidden:{y:"100%",scale:.75},shown:{y:0,scale:1}},Jg=({children:e,className:t,transitionState:r,side:n,...i})=>g(kn.p,{variants:Qg,initial:"hidden",animate:"shown",transition:{type:"spring",damping:25,stiffness:500},"data-transition":r,style:{transformOrigin:n==="left"?"0% 50%":"100% 50%"},class:Xg({className:t,side:n,transitionState:r}),...i,children:e}),ey=({className:e,...t})=>(W(()=>{Ve.scrollToEnd.smooth()}),g("div",{"aria-hidden":!0,children:Ve.isBotTyping$.value===!0?g("div",{"aria-label":"Typing…",class:ct("flex gap-1 p-4",e),...t,children:Array.from({length:3},(r,n)=>g("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-n*200}ms`}}))}):void 0})),ty={bot:"left",user:"right"},ry=ou("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]",{variants:{variant:{info:"text-neutral-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),ny=({lastSentMessageFooter:e})=>{var r;const t=((r=L.current$.value.flow)==null?void 0:r.data.messages)??[];return W(()=>{Ve.scrollToEnd.smooth()},[t.length]),g("ol",{"aria-label":"Chat messages",class:"flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[g(nl,{initial:!1,children:t.map((n,i)=>g(Q,{children:g("li",{class:"flex",children:Ue(n).with({type:"system"},o=>g("p",{class:ry({variant:o.variant}),children:o.text})).with({type:"text",author:_e.union("bot","user")},o=>{const s=o.author==="user"&&!t.slice(i+1).some(a=>a.type==="text"&&a.author==="user");return g(Jg,{side:ty[o.author],children:[o.text,s?e:null]},i)}).with({type:"link"},o=>g("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:g("a",{class:"bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:o.href,children:[o.text,g("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:g("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=>g("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=>g(ug,{class:o.author==="bot"?"":"ml-auto",file:{name:o.fileName,sizeKb:o.fileSizeKb}})).exhaustive()})},i))}),g(ey,{},"typing")]})},iy=({logger:e,apiClient:t,analytics:r})=>{const{flow:n}=L.current$.value;Xe(n,"Flow is required to exist to show chatbot body");const i=L.viewState$.value,{chatRef:o,chatService:s}=ng(),[a,l]=ie();return Ae(()=>{i==="maximised"&&Ve.scrollToEnd.instant()},[i]),Ae(()=>{const{state:u,flow:d}=L.current$.peek();if(u!=="loaded")throw new Error(Km.invalid_state);let c=d.data.nodeHistory.at(-1);if(Ve.scrollToEnd.instant(),L.setInput(void 0),d.data.isFinished)return;c===void 0?(c=_l(n.nodes).id,L.setCurrentNodeId(c),r.log({event:"FLOW_START",properties:{flow_id:n.id,flow_version:n.version,flow_session_id:d.data.flowSessionId}})):L.removeMessagesSentByNodeIds([c]);const{interpret:f,abort:p,undo:h}=Bv({context:n.context,analytics:r,apiClient:t,logger:e,flow:n.nodes,chatService:s,getSubmissions:()=>{var m;return(m=L.current$.peek().flow)==null?void 0:m.data.submissions},onInterpret:(m,b)=>{const x=L.current$.peek().flow;Xe(x),b&&(x.data.sequence=x.data.sequence+1,r.log({event:"FLOW_NODE",properties:{flow_id:n.id,flow_version:n.version,from_node_id:b.id,to_node_id:m.id,sequence:x.data.sequence,flow_session_id:x.data.flowSessionId},customProperties:n.context})),L.setCurrentNodeId(m.id)},onFlowEnd:async()=>{L.markAsFinished();const m=L.current$.peek().flow;Xe(m),r.log({event:"FLOW_END",properties:{flow_id:n.id,flow_version:n.version,flow_session_id:m.data.flowSessionId},customProperties:n.context})}});return l(()=>h),f(c),p},[r,t,s,e,n]),g(Q,{children:[g("div",{ref:o,className:"hide-scrollbars relative flex w-full max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:L.inputHeight$.value},children:g(ny,{lastSentMessageFooter:n.data.isFinished||!a?null:g(sy,{undoFn:a})})}),g(Zg,{})]})},oy=e=>"key"in e.data&&e.data.key?[e.data.key]:"keys"in e.data?Object.values(e.data.keys).filter(t=>typeof t=="string"):[],sy=({undoFn:e})=>g("div",{class:"absolute bottom-0 right-0 flex w-full translate-y-full justify-end",children:g("button",{class:"fr touch-hitbox text-neutral-9 hover:text-neutral-12 rounded-full p-1 text-right text-xs transition-all",onClick:async()=>{const{flow:t}=L.current$.peek();Xe(t);const{removed:r}=e(t.data.nodeHistory),n=t.data.nodeHistory.splice(-r);n.length!==0&&(L.removeMessagesSentByNodeIds(n),L.setInput(void 0),n.pop(),n.map(i=>t.nodes.find(o=>o.id===i)).filter(Boolean).flatMap(oy).forEach(i=>delete t.data.submissions[i]),L.current$.value={...L.current$.value})},children:"Undo"})}),ay=Object.freeze(Object.defineProperty({__proto__:null,ChatbotBody:iy},Symbol.toStringTag,{value:"Module"}))})();
|
|
53
|
+
}`},Lv=({_internal_domManager:e=Pv(),theme:t})=>ht(({apiClient:r,logger:n,analytics:i})=>{let o=!1;const s=()=>{if(typeof window>"u")return;const a=[O("style",{id:"inploi-chatbot-styles"},Av),O("style",{id:"inploi-chatbot-theme"},Nv(t))],l=e.getOrCreateChatbotElement();Dt(O(Q,{},[a,O(kv,{apiClient:r,logger:n,analytics:i})]),l),o=!0};return{prepare:async()=>{if(!(typeof window>"u"))try{if(o)return;s(),n.info("Chatbot plugin prepared")}catch(a){n.error("Error preparing chatbot plugin",a)}},fetchFlowByJobId:async a=>r.fetch(`/flow/job/${a}`).then(l=>{const u=ar(Cv,l);return{context:{job_id:u.job.id,flow_id:u.flow.id},flow:u.flow,title:`Applying for “${u.job.title}”`,flowKeys:[u.job.id]}}),fetchFlowById:async a=>r.fetch(`/flow/id/${a}`).then(l=>{const u=ar(Sv,l);return{flow:u.flow,context:{flow_id:u.flow.id},title:"Chatbot",flowKeys:[]}}),open:async a=>{if(!(typeof window>"u"))try{L.cancelCurrentFlow(),L.viewState$.value="maximised",o||s(),a instanceof Promise?(L.current$.value={state:"loading"},a.then(async l=>{const u=ar($v,l);L.startFlow(u)}).catch(l=>{const u=l instanceof Error?l.message:"An error occurred";L.current$.value={state:"error",error:u}})):L.startFlow(a)}catch(l){n.error("Error starting flow",l)}},startApplication:void 0,closeApplication:void 0,close:async()=>{typeof window>"u"||(L.cancelCurrentFlow(),n.info("Closed flow from an external source"))}}});if(!window.inploi)throw new Error("Please insert the SDK script tag above the plugins.");window.inploi.chatbotPlugin=Lv;const Pl=({node:e,nodes:t,stopWhen:r})=>{if((r==null?void 0:r(e))===!0)return e;const n=e.nextId?t.find(i=>i.id===e.nextId):void 0;if(n)return Pl({node:n,nodes:t,stopWhen:r})},Rv=({childNode:e,nodes:t})=>{const n=t.filter(i=>i.type==="if-block").find(i=>{if(!i.branchId)return!1;const o=t.find(a=>a.id===i.branchId);if(!o)return!1;const s=Pl({node:o,nodes:t,stopWhen:a=>a.id===e.id});return!(!s||s.id!==e.id)});if(n!=null&&n.nextId)return t.find(i=>i.id===n.nextId)},Bv=({flow:e,analytics:t,logger:r,context:n,apiClient:i,getSubmissions:o,chatService:s,onFlowEnd:a,onInterpret:l})=>{let u=new AbortController;const d=async(c,f)=>{const p=o();l==null||l(c,f);try{await jv({analytics:t,logger:r,apiClient:i,context:n,node:c,submissions:p,chat:{sendMessage:async h=>s.send({groupId:c.id,message:h,signal:u.signal}),userInput:async h=>s.input({input:h,signal:u.signal})},next:h=>{const m=h?e.find(b=>b.id===h):Rv({childNode:c,nodes:e});return m?d(m,c):a==null?void 0:a(c)},end:()=>a==null?void 0:a(c)})}catch(h){if(h instanceof Er)return;throw h}};return{interpret:async c=>{const f=e.find(p=>p.id===c)??_l(e);return d(f)},undo:c=>{let f=1;const p=e.find(m=>m.id===c[c.length-1]);for(let m=c.length-2;m>0;m--){const b=c[m],x=e.find(y=>y.id===b);if(!x||(f++,x.type.startsWith("question-")))break}u.abort(),u=new AbortController;const h=e.find(m=>m.id===c[c.length-f]);return Xe(h,"Undo failed: new start node not found"),d(h,p),{removed:f}},abort:()=>{u.abort()}}};async function jv(e){return await Ue(e).with({node:{type:"text"}},Wv).with({node:{type:"image"}},Kv).with({node:{type:"question-text"}},qv).with({node:{type:"question-enum"}},Yv).with({node:{type:"question-number"}},Gv).with({node:{type:"question-boolean"}},Zv).with({node:{type:"question-file"}},Jv).with({node:{type:"question-address"}},Qv).with({node:{type:"end-flow"}},eg).with({node:{type:"if-block"}},Hv).with({node:{type:"jump"}},({node:t,next:r})=>r(t.data.targetId)).with({node:{type:"link"}},zv).with({node:{type:"integration-application-submit"}},Uv).with({node:{type:"integration-workflow-get"}},()=>Error("Unreachable")).exhaustive()}async function Uv({chat:e,next:t,node:r,logger:n,apiClient:i,submissions:o,context:s,analytics:a}){r.data.skipConfirmation!==!0&&await e.userInput({type:"submit",key:void 0,config:{label:r.data.submitLabel}}),await e.sendMessage({type:"system",variant:"info",text:"Submitting…"});const{anonymous_id:l,session_id:u}=a.getSessionInfo(),d=await i.fetch("/flow/apply",{method:"POST",body:JSON.stringify({...s,integration_id:r.data.integrationId,anonymous_id:l,session_id:u,submissions:uv(o||{})})}).catch(c=>c);await Ue(d).with({ats_data:{redirect_url:_e.string}},async c=>{await e.sendMessage({type:"text",author:"bot",text:"Almost there! Please complete your submission here:"});const f=new URL(c.ats_data.redirect_url);l&&!f.searchParams.has("anonymous_id")&&f.searchParams.set("anonymous_id",l),await e.sendMessage({type:"link",href:f.toString(),text:"Complete submission"}),t(r.nextId)}).with({success:!0},async()=>{await e.sendMessage({type:"system",variant:"success",text:"Submission completed!"}),t(r.nextId)}).otherwise(async c=>{n.error(c),await e.sendMessage({type:"system",variant:"error",text:"Failed to submit"}),t(r.id)})}async function zv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({type:"link",href:r.data.href,text:Et(r.data.cta,n)}),t(r.nextId)}async function Hv({submissions:e,next:t,node:r}){const n=tg(r,e)?r.branchId:r.nextId;t(n)}async function Wv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({author:"bot",type:"text",text:Et(r.data.text,n)}),t(r.nextId)}async function Kv({chat:e,next:t,node:r}){await e.sendMessage({author:"bot",type:"image",url:r.data.url,height:r.data.height,width:r.data.width}),t(r.nextId)}async function qv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({author:"bot",type:"text",text:Et(r.data.question,n)});const i=await e.userInput({key:r.data.key,type:"text",config:{optional:r.data.optional,placeholder:r.data.placeholder,format:r.data.format,maxChars:r.data.maxChars}});i.value===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:i.value}),t(r.nextId)}async function Gv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({author:"bot",type:"text",text:Et(r.data.question,n)});const i=await e.userInput({key:r.data.key,type:"text",config:{optional:r.data.optional,placeholder:r.data.placeholder,format:"text"}});i.value===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:i.value}),t(r.nextId)}async function Yv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({author:"bot",type:"text",text:Et(r.data.question,n)});const i=await e.userInput({key:r.data.key,type:"multiple-choice",config:r.data});i.value.length===0?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:r.data.options.filter(o=>i.value.includes(o.value)).map(o=>o.label).join(", ")}),t(r.nextId)}async function Zv({chat:e,next:t,node:r,submissions:n}){await e.sendMessage({author:"bot",type:"text",text:Et(r.data.question,n)});const o=(await e.userInput({key:r.data.key,type:"boolean",config:{optional:r.data.optional,labels:{true:r.data.trueLabel,false:r.data.falseLabel}}})).value;o===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:{true:r.data.trueLabel,false:r.data.falseLabel}[o]}),t(r.nextId)}const Xv=document.createElement("div"),El={line1:["street_number","floor","room","premise"],line2:["subpremise","street_address","route"],line3:["sublocality","neighborhood"],city:["locality","postal_town"],state:["administrative_area_level_1"],postcode:["postal_code"],country:["country"]},Tl=Object.keys(El);async function Qv({chat:e,next:t,node:r,logger:n}){if(Tl.every(h=>r.data.keys[h]===null))return t(r.nextId);const{google:i}=window;await e.sendMessage({author:"bot",type:"text",text:r.data.question});const o=async h=>{const m=[{label:"Postcode",key:r.data.keys.postcode,optional:!1,defaultValue:h.postcode},{label:"Line 1",key:r.data.keys.line1,optional:!1,defaultValue:h.line1},{label:"Line 2",key:r.data.keys.line2,optional:!0,defaultValue:h.line2},{label:"Line 3",key:r.data.keys.line3,optional:!0,defaultValue:h.line3},{label:"City",key:r.data.keys.city,optional:!1,defaultValue:h.city},{label:"State/County/Province",key:r.data.keys.state,optional:!0,defaultValue:h.state},{label:"Country",key:r.data.keys.country,optional:!1,defaultValue:h.country}];for(const b of m){if(b.key===null)continue;await e.sendMessage({author:"bot",type:"text",text:b.label});const{value:x}=await e.userInput({type:"text",key:b.key,config:{format:"text",optional:b.optional,defaultValue:b.defaultValue}});x===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:x})}};if(!Xn(window,"google")||!Xn(window.google,"maps")||!Xn(window.google.maps,"places"))return n.warn("Google maps not available, falling back to manual input."),n.info("If you’d like to use the address autocomplete, please insert the google maps API snippet in your website and make sure it has access to the *places* library."),await o({}),t(r.nextId);const s=new i.maps.places.AutocompleteService,a=new i.maps.places.PlacesService(Xv),{value:l}=await e.userInput({type:"text",key:"_internal-address-search",config:{format:"text",optional:!1,placeholder:"Search for your address"}});if(l===null)return t(r.id);await e.sendMessage({author:"user",type:"text",text:`Search for “${l}”`});const{predictions:u}=await s.getPlacePredictions({input:l}),{value:[d]}=await e.userInput({type:"multiple-choice",key:void 0,config:{options:u.slice(0,4).map(h=>({label:h.description,value:h.place_id})).concat({label:"None of these",value:"none"}),maxSelected:1,minSelected:1}});if(!d||d==="none")return t(r.id);const c=await new Promise((h,m)=>a.getDetails({placeId:d,fields:["address_components"]},(b,x)=>x!==i.maps.places.PlacesServiceStatus.OK?m(x):b===null?m("ZERO_RESULTS"):h({ok:!0,place:b}))).catch(async h=>(n.error("Failed to get address details",h),{ok:!1}));if(c.ok===!1)return await e.sendMessage({type:"system",variant:"error",text:"Failed to get address details"}),await o({}),t(r.id);const f=c.place.address_components,p=f?Tl.reduce((h,m)=>{const b=El[m],x=f.filter(y=>y.types.some(_=>b.includes(_))).map(y=>y.long_name).join(", ");return x&&(h[m]=x),h},{}):{};return await e.sendMessage({author:"bot",type:"text",text:"Please confirm or adjust your address:"}),await o(p),t(r.nextId)}async function Jv({node:e,chat:t,next:r,submissions:n}){await t.sendMessage({author:"bot",type:"text",text:Et(e.data.question,n)});const i=await t.userInput({key:e.data.key,type:"file",config:{optional:e.data.optional,extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb??10*1024,allowMultiple:e.data.multiple===!0}});if(i.value===null)await t.sendMessage({type:"system",variant:"info",text:"Skipped"});else for(const o of i.value)await t.sendMessage({author:"user",type:"file",fileName:o.name,fileSizeKb:o.sizeKb});r(e.nextId)}async function eg({chat:e,end:t,node:r}){await e.sendMessage({type:"system",variant:"info",text:r.data.systemMessage}),t()}const Vl=_e.union(_e.string,_e.array(_e.string),null),tg=(e,t)=>{const r=t==null?void 0:t[e.data.compareKey];return r?Ue({...e.data,answer:r}).with({compare:"equals"},({compareValue:n})=>typeof r.value=="string"||typeof r.value=="boolean"?n===r.value.toString():!1).with({compare:"notEquals"},({compareValue:n})=>typeof r.value=="string"||typeof r.value=="boolean"?n!==r.value.toString():!1).with({compare:"contains",answer:{value:Vl}},({compareValue:n,answer:i})=>i.value!==null&&i.value.includes(n)).with({compare:"notContains",answer:{value:Vl}},({compareValue:n,answer:i})=>i.value===null||!i.value.includes(n)).with({answer:{type:"file"}},()=>!1).exhaustive():!1},Et=(e,t)=>{const r=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;return e.replace(r,(n,i,o="")=>{i=i.trim();const s=t==null?void 0:t[i];if(!s)return o;switch(s.type){case"boolean":return s.value==="true"?"true":"false";case"file":return s.value?s.value.map(a=>`${a.name} (${Pr(a.sizeKb)})`).join(", "):"no files";case"multiple-choice":return s.value.join(", ");default:return s.value||o}})},In=({class:e,...t})=>g("button",{class:ct("bg-accent-9 active:bg-accent-10 pointer-coarse:touch-hitbox fr flex-shrink-0 rounded-full p-2 text-white transition-all disabled:cursor-not-allowed disabled:opacity-50",e),type:"submit",...t,children:g("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[g("title",{children:"Send"}),g("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),g("path",{d:"M8 4V13"})]})}),rg=25,Po=ot({instant:()=>{},smooth:()=>{}}),Ve={onSubmitSuccessFn$:ot(()=>{}),isBotTyping$:ot(!1),scrollToEnd:{instant:()=>Po.value.instant(),smooth:()=>Po.value.smooth()}},ng=()=>{const e=j(null);Ae(()=>{Po.value={instant:()=>{var r;return(r=e.current)==null?void 0:r.scrollTo({top:e.current.scrollHeight,behavior:"instant"})},smooth:()=>{e.current&&e.current.scrollHeight-e.current.scrollTop<=e.current.clientHeight*1.5&&e.current.scrollTo({top:e.current.scrollHeight,behavior:"smooth"})}}},[e]);const t=se(()=>({send:async({message:r,signal:n,groupId:i})=>{if(await Ue(r).with({author:"bot",type:"text"},async o=>{if(n!=null&&n.aborted)throw new Er;Ve.isBotTyping$.value=!0;const s=Math.min(Math.max(20,o.text.length),100)*rg;await new Promise(a=>setTimeout(a,s,{signal:n})),Ve.isBotTyping$.value=!1}).otherwise(async()=>{}),n!=null&&n.aborted)throw new Er;L.addMessage(r,i)},input:async({input:r,signal:n})=>{if(n!=null&&n.aborted)throw new Er;return L.setInput(r),await new Promise(i=>{const o=s=>{if(n!=null&&n.aborted)throw new Er;L.setInput(void 0),r.key&&L.setSubmission(r.key,s),i(s)};Ve.onSubmitSuccessFn$.value=o})}}),[]);return{chatRef:e,chatService:t}},Fn=({class:e,...t})=>g("button",{type:"button",class:ct("fr text-neutral-9 flex flex-shrink-0 items-center justify-center gap-1 rounded-full py-[6px] pl-2 pr-3 text-sm underline-offset-2 transition-all",e),...t,children:[g("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",children:[g("title",{children:"Skip"}),g("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),g("path",{d:"M13.25 4.5V8.25H9.5"})]}),"Skip"]}),Eo=()=>{const e=j(null);return W(()=>{var t;(t=e.current)==null||t.focus()},[]),e},Ml=["true","false"],ig=xu(Ml),og="answer",sg=({input:e,onSubmitSuccess:t,onHeightChange:r})=>{const n=Eo();return r(),g("form",{noValidate:!0,class:"",onSubmit:i=>{i.preventDefault();const o=Ue(i).with({nativeEvent:{submitter:_e.select(_e.union(_e.instanceOf(HTMLButtonElement),_e.instanceOf(HTMLInputElement)))}},a=>a.value).otherwise(()=>{throw new Error("invalid form")}),s=ar(ig,o);t(s)},children:[g("div",{class:"flex items-center gap-2 p-2.5",children:Ml.map((i,o)=>g("button",{ref:o===0?n:null,type:"submit",name:og,value:i,class:"bg-lowest ease-expo-out ring-divider text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block flex-1 overflow-hidden rounded-2xl px-2.5 py-2.5 ring-2 transition-all selection:bg-transparent",children:g("p",{class:"truncate text-center text-base",children:e.config.labels[i]})}))}),e.config.optional&&g("div",{class:"px-2 pb-2",children:g(Fn,{class:"w-full",type:"button",onClick:()=>t(null)})})]})},To=({error:e,onAnimationComplete:t})=>(Ae(()=>{e&&t()},[e,t]),e?g("div",{role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full px-2 py-2",children:[g("svg",{class:"text-error-9 h-4 w-4",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),g("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),g("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),g("p",{class:"truncate pr-1 text-sm",children:e.message})]}):null),ag=e=>new Promise((t,r)=>{const n=new FileReader;n.readAsDataURL(e),n.onload=()=>n.result?t(n.result.toString()):r("No result from reader"),n.onerror=r}),cg=e=>e.reduce((t,r)=>t+r.sizeKb,0),lg=_o("file"),Ol=3,ug=({file:e,class:t,...r})=>{const n=e.name.split(".").pop(),i=e.name.replace(new RegExp(`.${n}$`),"");return g("div",{class:ct("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",t),...r,children:[g("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[g("span",{class:"block truncate",children:i}),g("span",{children:[".",n]})]}),g("p",{"aria-label":"File size",class:"text-accent-11",children:Pr(e.sizeKb)})]})},Il=({class:e,...t})=>g("li",{class:ct("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...t}),Fl=e=>{const t=e.split(".").pop();if(!t)throw new Error("No file extension found");return t?"."+t:""},dg=({allowedExtensions:e,files:t})=>{const r=e.map(n=>n.toLowerCase());return t.every(n=>r.includes(Fl(n.name).toLowerCase()))},fg=(e,t)=>{const r=Fl(e);return`${e.replace(new RegExp(`${r}$`),"").slice(0,t)}${r}`},hg=({input:e,onSubmitSuccess:t,onHeightChange:r})=>{var c;const n=(c=L.current$.value.flow)==null?void 0:c.data.submissions[e.key],[i,o]=ie(lg(n)&&n.value!==null?n.value:[]),[s,a]=ie(),l=i.length-Ol,u=cg(i),d=Eo();return g("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:f=>(f.preventDefault(),a(void 0),i.length===0?a({type:"required",message:"Please select a file"}):e.config.extensions.length>0&&!dg({allowedExtensions:e.config.extensions,files:i})?a({type:"validate",message:`Please upload ${e.config.extensions.join(", ")} files only`}):e.config.fileSizeLimitKib&&u>e.config.fileSizeLimitKib?a({type:"max",message:`File size exceeds limit of ${Pr(e.config.fileSizeLimitKib)}`}):e.config.allowMultiple===!1&&i.length>1?a({type:"invalid",message:"Only one file is allowed"}):t(i)),children:[g("div",{class:"flex items-center gap-2",children:[g("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:[i.length>0?g(Q,{children:[g("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[i.slice(0,Ol).map(f=>{const p=f.name.split(".").pop(),h=f.name.replace(new RegExp(`.${p}$`),"");return g(Il,{class:"flex overflow-hidden",children:[g("span",{class:"block truncate",children:h}),g("span",{children:[".",p]})]})}),l>0?g(Il,{children:["+",l," file",l!==1?"s":""]}):null]}),g("p",{class:"text-neutral-11 text-xs",children:[Pr(u)," ",i.length>1?"total":""]})]}):g("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[g("header",{class:"flex flex-col items-center gap-0",children:[g("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:g("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"})}),g("p",{class:"text-neutral-12 tracking-[-0.01em]",children:[e.config.allowMultiple?"Select files":"Select a file"," to upload"]}),e.config.fileSizeLimitKib?g("p",{class:"text-neutral-10 text-xs",children:["(max ",Pr(e.config.fileSizeLimitKib),")"]}):null]}),g("aside",{class:"flex flex-col items-center gap-2",children:[g("p",{id:"accepted-filetypes",class:"sr-only",children:"Accepted file extensions"}),g("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(f=>g("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(".","")}))})]})]}),g("input",{id:"dropzone-file",onInput:async f=>{Xe(f.target instanceof HTMLInputElement);const p=f.target.files?Array.from(f.target.files):[],h=await Promise.allSettled(p.map(async b=>{const x=await ag(b);return{name:fg(b.name,42),data:x,sizeKb:b.size/1e3}}));if(h.some(({status:b})=>b==="rejected"))return a({type:"invalid",message:"Invalid file"});const m=h.map(b=>b.status==="fulfilled"?b.value:null).filter(Boolean);o(m)},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),g("div",{class:"flex h-full flex-col items-center gap-2",children:[g(In,{disabled:i.length===0}),e.config.optional&&g(Fn,{onClick:()=>t(null)})]})]}),s&&g(To,{onAnimationComplete:r,error:s})]})};var Mr=e=>e.type==="checkbox",Jt=e=>e instanceof Date,ye=e=>e==null;const Dl=e=>typeof e=="object";var oe=e=>!ye(e)&&!Array.isArray(e)&&Dl(e)&&!Jt(e),pg=e=>oe(e)&&e.target?Mr(e.target)?e.target.checked:e.target.value:e,mg=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,vg=(e,t)=>e.has(mg(t)),gg=e=>{const t=e.constructor&&e.constructor.prototype;return oe(t)&&t.hasOwnProperty("isPrototypeOf")},Vo=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ze(e){let t;const r=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Vo&&(e instanceof Blob||e instanceof FileList))&&(r||oe(e)))if(t=r?[]:{},!r&&!gg(e))t=e;else for(const n in e)e.hasOwnProperty(n)&&(t[n]=ze(e[n]));else return e;return t}var Or=e=>Array.isArray(e)?e.filter(Boolean):[],te=e=>e===void 0,V=(e,t,r)=>{if(!t||!oe(e))return r;const n=Or(t.split(/[,[\].]+?/)).reduce((i,o)=>ye(i)?i:i[o],e);return te(n)||n===e?te(e[t])?r:e[t]:n},lt=e=>typeof e=="boolean";const Nl={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Me={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},He={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};Te.createContext(null);var yg=(e,t,r,n=!0)=>{const i={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(i,o,{get:()=>{const s=o;return t._proxyFormState[s]!==Me.all&&(t._proxyFormState[s]=!n||Me.all),r&&(r[s]=!0),e[s]}});return i},Pe=e=>oe(e)&&!Object.keys(e).length,bg=(e,t,r,n)=>{r(e);const{name:i,...o}=e;return Pe(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(s=>t[s]===(!n||Me.all))},Mo=e=>Array.isArray(e)?e:[e];function wg(e){const t=Te.useRef(e);t.current=e,Te.useEffect(()=>{const r=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{r&&r.unsubscribe()}},[e.disabled])}var Le=e=>typeof e=="string",_g=(e,t,r,n,i)=>Le(e)?(n&&t.watch.add(e),V(r,e,i)):Array.isArray(e)?e.map(o=>(n&&t.watch.add(o),V(r,o))):(n&&(t.watchAll=!0),r),Oo=e=>/^\w*$/.test(e),Ll=e=>Or(e.replace(/["|']|\]/g,"").split(/\.|\[/));function G(e,t,r){let n=-1;const i=Oo(t)?[t]:Ll(t),o=i.length,s=o-1;for(;++n<o;){const a=i[n];let l=r;if(n!==s){const u=e[a];l=oe(u)||Array.isArray(u)?u:isNaN(+i[n+1])?{}:[]}e[a]=l,e=e[a]}return e}var Rl=(e,t,r,n,i)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:i||!0}}:{},Bl=e=>({isOnSubmit:!e||e===Me.onSubmit,isOnBlur:e===Me.onBlur,isOnChange:e===Me.onChange,isOnAll:e===Me.all,isOnTouch:e===Me.onTouched}),jl=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Dn=(e,t,r,n)=>{for(const i of r||Object.keys(e)){const o=V(e,i);if(o){const{_f:s,...a}=o;if(s){if(s.refs&&s.refs[0]&&t(s.refs[0],i)&&!n)break;if(s.ref&&t(s.ref,s.name)&&!n)break}else oe(a)&&Dn(a,t)}}};var xg=(e,t,r)=>{const n=Or(V(e,r));return G(n,"root",t[r]),G(e,r,n),e},Io=e=>e.type==="file",ut=e=>typeof e=="function",Nn=e=>{if(!Vo)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Ln=e=>Le(e),Fo=e=>e.type==="radio",Rn=e=>e instanceof RegExp;const Ul={value:!1,isValid:!1},zl={value:!0,isValid:!0};var Hl=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!te(e[0].attributes.value)?te(e[0].value)||e[0].value===""?zl:{value:e[0].value,isValid:!0}:zl:Ul}return Ul};const Wl={isValid:!1,value:null};var Kl=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,Wl):Wl;function ql(e,t,r="validate"){if(Ln(e)||Array.isArray(e)&&e.every(Ln)||lt(e)&&!e)return{type:r,message:Ln(e)?e:"",ref:t}}var er=e=>oe(e)&&!Rn(e)?e:{value:e,message:""},Gl=async(e,t,r,n,i)=>{const{ref:o,refs:s,required:a,maxLength:l,minLength:u,min:d,max:c,pattern:f,validate:p,name:h,valueAsNumber:m,mount:b,disabled:x}=e._f,y=V(t,h);if(!b||x)return{};const _=s?s[0]:o,C=U=>{n&&_.reportValidity&&(_.setCustomValidity(lt(U)?"":U||""),_.reportValidity())},S={},N=Fo(o),F=Mr(o),A=N||F,T=(m||Io(o))&&te(o.value)&&te(y)||Nn(o)&&o.value===""||y===""||Array.isArray(y)&&!y.length,K=Rl.bind(null,h,r,S),J=(U,R,B,z=He.maxLength,re=He.minLength)=>{const de=U?R:B;S[h]={type:U?z:re,message:de,ref:o,...K(U?z:re,de)}};if(i?!Array.isArray(y)||!y.length:a&&(!A&&(T||ye(y))||lt(y)&&!y||F&&!Hl(s).isValid||N&&!Kl(s).isValid)){const{value:U,message:R}=Ln(a)?{value:!!a,message:a}:er(a);if(U&&(S[h]={type:He.required,message:R,ref:_,...K(He.required,R)},!r))return C(R),S}if(!T&&(!ye(d)||!ye(c))){let U,R;const B=er(c),z=er(d);if(!ye(y)&&!isNaN(y)){const re=o.valueAsNumber||y&&+y;ye(B.value)||(U=re>B.value),ye(z.value)||(R=re<z.value)}else{const re=o.valueAsDate||new Date(y),de=Vt=>new Date(new Date().toDateString()+" "+Vt),We=o.type=="time",dt=o.type=="week";Le(B.value)&&y&&(U=We?de(y)>de(B.value):dt?y>B.value:re>new Date(B.value)),Le(z.value)&&y&&(R=We?de(y)<de(z.value):dt?y<z.value:re<new Date(z.value))}if((U||R)&&(J(!!U,B.message,z.message,He.max,He.min),!r))return C(S[h].message),S}if((l||u)&&!T&&(Le(y)||i&&Array.isArray(y))){const U=er(l),R=er(u),B=!ye(U.value)&&y.length>+U.value,z=!ye(R.value)&&y.length<+R.value;if((B||z)&&(J(B,U.message,R.message),!r))return C(S[h].message),S}if(f&&!T&&Le(y)){const{value:U,message:R}=er(f);if(Rn(U)&&!y.match(U)&&(S[h]={type:He.pattern,message:R,ref:o,...K(He.pattern,R)},!r))return C(R),S}if(p){if(ut(p)){const U=await p(y,t),R=ql(U,_);if(R&&(S[h]={...R,...K(He.validate,R.message)},!r))return C(R.message),S}else if(oe(p)){let U={};for(const R in p){if(!Pe(U)&&!r)break;const B=ql(await p[R](y,t),_,R);B&&(U={...B,...K(R,B.message)},C(B.message),r&&(S[h]=U))}if(!Pe(U)&&(S[h]={ref:_,...U},!r))return S}}return C(!0),S};function kg(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;)e=te(e)?n++:e[t[n++]];return e}function Sg(e){for(const t in e)if(e.hasOwnProperty(t)&&!te(e[t]))return!1;return!0}function ue(e,t){const r=Array.isArray(t)?t:Oo(t)?[t]:Ll(t),n=r.length===1?e:kg(e,r),i=r.length-1,o=r[i];return n&&delete n[o],i!==0&&(oe(n)&&Pe(n)||Array.isArray(n)&&Sg(n))&&ue(e,r.slice(0,-1)),e}function Do(){let e=[];return{get observers(){return e},next:i=>{for(const o of e)o.next&&o.next(i)},subscribe:i=>(e.push(i),{unsubscribe:()=>{e=e.filter(o=>o!==i)}}),unsubscribe:()=>{e=[]}}}var Bn=e=>ye(e)||!Dl(e);function Tt(e,t){if(Bn(e)||Bn(t))return e===t;if(Jt(e)&&Jt(t))return e.getTime()===t.getTime();const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const i of r){const o=e[i];if(!n.includes(i))return!1;if(i!=="ref"){const s=t[i];if(Jt(o)&&Jt(s)||oe(o)&&oe(s)||Array.isArray(o)&&Array.isArray(s)?!Tt(o,s):o!==s)return!1}}return!0}var Yl=e=>e.type==="select-multiple",Cg=e=>Fo(e)||Mr(e),No=e=>Nn(e)&&e.isConnected,Zl=e=>{for(const t in e)if(ut(e[t]))return!0;return!1};function jn(e,t={}){const r=Array.isArray(e);if(oe(e)||r)for(const n in e)Array.isArray(e[n])||oe(e[n])&&!Zl(e[n])?(t[n]=Array.isArray(e[n])?[]:{},jn(e[n],t[n])):ye(e[n])||(t[n]=!0);return t}function Xl(e,t,r){const n=Array.isArray(e);if(oe(e)||n)for(const i in e)Array.isArray(e[i])||oe(e[i])&&!Zl(e[i])?te(t)||Bn(r[i])?r[i]=Array.isArray(e[i])?jn(e[i],[]):{...jn(e[i])}:Xl(e[i],ye(t)?{}:t[i],r[i]):r[i]=!Tt(e[i],t[i]);return r}var Lo=(e,t)=>Xl(e,t,jn(t)),Ql=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>te(e)?e:t?e===""?NaN:e&&+e:r&&Le(e)?new Date(e):n?n(e):e;function Ro(e){const t=e.ref;if(!(e.refs?e.refs.every(r=>r.disabled):t.disabled))return Io(t)?t.files:Fo(t)?Kl(e.refs).value:Yl(t)?[...t.selectedOptions].map(({value:r})=>r):Mr(t)?Hl(e.refs).value:Ql(te(t.value)?e.ref.value:t.value,e)}var $g=(e,t,r,n)=>{const i={};for(const o of e){const s=V(t,o);s&&G(i,o,s._f)}return{criteriaMode:r,names:[...e],fields:i,shouldUseNativeValidation:n}},Ir=e=>te(e)?e:Rn(e)?e.source:oe(e)?Rn(e.value)?e.value.source:e.value:e,Ag=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Jl(e,t,r){const n=V(e,r);if(n||Oo(r))return{error:n,name:r};const i=r.split(".");for(;i.length;){const o=i.join("."),s=V(t,o),a=V(e,o);if(s&&!Array.isArray(s)&&r!==o)return{name:r};if(a&&a.type)return{name:o,error:a};i.pop()}return{name:r}}var Pg=(e,t,r,n,i)=>i.isOnAll?!1:!r&&i.isOnTouch?!(t||e):(r?n.isOnBlur:i.isOnBlur)?!e:(r?n.isOnChange:i.isOnChange)?e:!0,Eg=(e,t)=>!Or(V(e,t)).length&&ue(e,t);const Tg={mode:Me.onSubmit,reValidateMode:Me.onChange,shouldFocusError:!0};function Vg(e={},t){let r={...Tg,...e},n={submitCount:0,isDirty:!1,isLoading:ut(r.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},i={},o=oe(r.defaultValues)||oe(r.values)?ze(r.defaultValues||r.values)||{}:{},s=r.shouldUnregister?{}:ze(o),a={action:!1,mount:!1,watch:!1},l={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,d=0;const c={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Do(),array:Do(),state:Do()},p=e.resetOptions&&e.resetOptions.keepDirtyValues,h=Bl(r.mode),m=Bl(r.reValidateMode),b=r.criteriaMode===Me.all,x=v=>w=>{clearTimeout(d),d=setTimeout(v,w)},y=async v=>{if(c.isValid||v){const w=r.resolver?Pe((await T()).errors):await J(i,!0);w!==n.isValid&&f.state.next({isValid:w})}},_=v=>c.isValidating&&f.state.next({isValidating:v}),C=(v,w=[],k,M,P=!0,$=!0)=>{if(M&&k){if(a.action=!0,$&&Array.isArray(V(i,v))){const I=k(V(i,v),M.argA,M.argB);P&&G(i,v,I)}if($&&Array.isArray(V(n.errors,v))){const I=k(V(n.errors,v),M.argA,M.argB);P&&G(n.errors,v,I),Eg(n.errors,v)}if(c.touchedFields&&$&&Array.isArray(V(n.touchedFields,v))){const I=k(V(n.touchedFields,v),M.argA,M.argB);P&&G(n.touchedFields,v,I)}c.dirtyFields&&(n.dirtyFields=Lo(o,s)),f.state.next({name:v,isDirty:R(v,w),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else G(s,v,w)},S=(v,w)=>{G(n.errors,v,w),f.state.next({errors:n.errors})},N=(v,w,k,M)=>{const P=V(i,v);if(P){const $=V(s,v,te(k)?V(o,v):k);te($)||M&&M.defaultChecked||w?G(s,v,w?$:Ro(P._f)):re(v,$),a.mount&&y()}},F=(v,w,k,M,P)=>{let $=!1,I=!1;const Z={name:v};if(!k||M){c.isDirty&&(I=n.isDirty,n.isDirty=Z.isDirty=R(),$=I!==Z.isDirty);const ne=Tt(V(o,v),w);I=V(n.dirtyFields,v),ne?ue(n.dirtyFields,v):G(n.dirtyFields,v,!0),Z.dirtyFields=n.dirtyFields,$=$||c.dirtyFields&&I!==!ne}if(k){const ne=V(n.touchedFields,v);ne||(G(n.touchedFields,v,k),Z.touchedFields=n.touchedFields,$=$||c.touchedFields&&ne!==k)}return $&&P&&f.state.next(Z),$?Z:{}},A=(v,w,k,M)=>{const P=V(n.errors,v),$=c.isValid&<(w)&&n.isValid!==w;if(e.delayError&&k?(u=x(()=>S(v,k)),u(e.delayError)):(clearTimeout(d),u=null,k?G(n.errors,v,k):ue(n.errors,v)),(k?!Tt(P,k):P)||!Pe(M)||$){const I={...M,...$&<(w)?{isValid:w}:{},errors:n.errors,name:v};n={...n,...I},f.state.next(I)}_(!1)},T=async v=>r.resolver(s,r.context,$g(v||l.mount,i,r.criteriaMode,r.shouldUseNativeValidation)),K=async v=>{const{errors:w}=await T(v);if(v)for(const k of v){const M=V(w,k);M?G(n.errors,k,M):ue(n.errors,k)}else n.errors=w;return w},J=async(v,w,k={valid:!0})=>{for(const M in v){const P=v[M];if(P){const{_f:$,...I}=P;if($){const Z=l.array.has($.name),ne=await Gl(P,s,b,r.shouldUseNativeValidation&&!w,Z);if(ne[$.name]&&(k.valid=!1,w))break;!w&&(V(ne,$.name)?Z?xg(n.errors,ne,$.name):G(n.errors,$.name,ne[$.name]):ue(n.errors,$.name))}I&&await J(I,w,k)}}return k.valid},U=()=>{for(const v of l.unMount){const w=V(i,v);w&&(w._f.refs?w._f.refs.every(k=>!No(k)):!No(w._f.ref))&&rr(v)}l.unMount=new Set},R=(v,w)=>(v&&w&&G(s,v,w),!Tt(ft(),o)),B=(v,w,k)=>_g(v,l,{...a.mount?s:te(w)?o:Le(v)?{[v]:w}:w},k,w),z=v=>Or(V(a.mount?s:o,v,e.shouldUnregister?V(o,v,[]):[])),re=(v,w,k={})=>{const M=V(i,v);let P=w;if(M){const $=M._f;$&&(!$.disabled&&G(s,v,Ql(w,$)),P=Nn($.ref)&&ye(w)?"":w,Yl($.ref)?[...$.ref.options].forEach(I=>I.selected=P.includes(I.value)):$.refs?Mr($.ref)?$.refs.length>1?$.refs.forEach(I=>(!I.defaultChecked||!I.disabled)&&(I.checked=Array.isArray(P)?!!P.find(Z=>Z===I.value):P===I.value)):$.refs[0]&&($.refs[0].checked=!!P):$.refs.forEach(I=>I.checked=I.value===P):Io($.ref)?$.ref.value="":($.ref.value=P,$.ref.type||f.values.next({name:v,values:{...s}})))}(k.shouldDirty||k.shouldTouch)&&F(v,P,k.shouldTouch,k.shouldDirty,!0),k.shouldValidate&&Y(v)},de=(v,w,k)=>{for(const M in w){const P=w[M],$=`${v}.${M}`,I=V(i,$);(l.array.has(v)||!Bn(P)||I&&!I._f)&&!Jt(P)?de($,P,k):re($,P,k)}},We=(v,w,k={})=>{const M=V(i,v),P=l.array.has(v),$=ze(w);G(s,v,$),P?(f.array.next({name:v,values:{...s}}),(c.isDirty||c.dirtyFields)&&k.shouldDirty&&f.state.next({name:v,dirtyFields:Lo(o,s),isDirty:R(v,$)})):M&&!M._f&&!ye($)?de(v,$,k):re(v,$,k),jl(v,l)&&f.state.next({...n}),f.values.next({name:v,values:{...s}}),!a.mount&&t()},dt=async v=>{const w=v.target;let k=w.name,M=!0;const P=V(i,k),$=()=>w.type?Ro(P._f):pg(v),I=Z=>{M=Number.isNaN(Z)||Z===V(s,k,Z)};if(P){let Z,ne;const Wn=$(),nr=v.type===Nl.BLUR||v.type===Nl.FOCUS_OUT,cy=!Ag(P._f)&&!r.resolver&&!V(n.errors,k)&&!P._f.deps||Pg(nr,V(n.touchedFields,k),n.isSubmitted,m,h),Bo=jl(k,l,nr);G(s,k,Wn),nr?(P._f.onBlur&&P._f.onBlur(v),u&&u(0)):P._f.onChange&&P._f.onChange(v);const jo=F(k,Wn,nr,!1),ly=!Pe(jo)||Bo;if(!nr&&f.values.next({name:k,type:v.type,values:{...s}}),cy)return c.isValid&&y(),ly&&f.state.next({name:k,...Bo?{}:jo});if(!nr&&Bo&&f.state.next({...n}),_(!0),r.resolver){const{errors:cu}=await T([k]);if(I(Wn),M){const uy=Jl(n.errors,i,k),lu=Jl(cu,i,uy.name||k);Z=lu.error,k=lu.name,ne=Pe(cu)}}else Z=(await Gl(P,s,b,r.shouldUseNativeValidation))[k],I(Wn),M&&(Z?ne=!1:c.isValid&&(ne=await J(i,!0)));M&&(P._f.deps&&Y(P._f.deps),A(k,ne,Z,jo))}},Vt=(v,w)=>{if(V(n.errors,w)&&v.focus)return v.focus(),1},Y=async(v,w={})=>{let k,M;const P=Mo(v);if(_(!0),r.resolver){const $=await K(te(v)?v:P);k=Pe($),M=v?!P.some(I=>V($,I)):k}else v?(M=(await Promise.all(P.map(async $=>{const I=V(i,$);return await J(I&&I._f?{[$]:I}:I)}))).every(Boolean),!(!M&&!n.isValid)&&y()):M=k=await J(i);return f.state.next({...!Le(v)||c.isValid&&k!==n.isValid?{}:{name:v},...r.resolver||!v?{isValid:k}:{},errors:n.errors,isValidating:!1}),w.shouldFocus&&!M&&Dn(i,Vt,v?P:l.mount),M},ft=v=>{const w={...o,...a.mount?s:{}};return te(v)?w:Le(v)?V(w,v):v.map(k=>V(w,k))},Fr=(v,w)=>({invalid:!!V((w||n).errors,v),isDirty:!!V((w||n).dirtyFields,v),isTouched:!!V((w||n).touchedFields,v),error:V((w||n).errors,v)}),Un=v=>{v&&Mo(v).forEach(w=>ue(n.errors,w)),f.state.next({errors:v?n.errors:{}})},Dr=(v,w,k)=>{const M=(V(i,v,{_f:{}})._f||{}).ref;G(n.errors,v,{...w,ref:M}),f.state.next({name:v,errors:n.errors,isValid:!1}),k&&k.shouldFocus&&M&&M.focus&&M.focus()},Mt=(v,w)=>ut(v)?f.values.subscribe({next:k=>v(B(void 0,w),k)}):B(v,w,!0),rr=(v,w={})=>{for(const k of v?Mo(v):l.mount)l.mount.delete(k),l.array.delete(k),w.keepValue||(ue(i,k),ue(s,k)),!w.keepError&&ue(n.errors,k),!w.keepDirty&&ue(n.dirtyFields,k),!w.keepTouched&&ue(n.touchedFields,k),!r.shouldUnregister&&!w.keepDefaultValue&&ue(o,k);f.values.next({values:{...s}}),f.state.next({...n,...w.keepDirty?{isDirty:R()}:{}}),!w.keepIsValid&&y()},zn=({disabled:v,name:w,field:k,fields:M,value:P})=>{if(lt(v)){const $=v?void 0:te(P)?Ro(k?k._f:V(M,w)._f):P;G(s,w,$),F(w,$,!1,!1,!0)}},Ot=(v,w={})=>{let k=V(i,v);const M=lt(w.disabled);return G(i,v,{...k||{},_f:{...k&&k._f?k._f:{ref:{name:v}},name:v,mount:!0,...w}}),l.mount.add(v),k?zn({field:k,disabled:w.disabled,name:v}):N(v,!0,w.value),{...M?{disabled:w.disabled}:{},...r.progressive?{required:!!w.required,min:Ir(w.min),max:Ir(w.max),minLength:Ir(w.minLength),maxLength:Ir(w.maxLength),pattern:Ir(w.pattern)}:{},name:v,onChange:dt,onBlur:dt,ref:P=>{if(P){Ot(v,w),k=V(i,v);const $=te(P.value)&&P.querySelectorAll&&P.querySelectorAll("input,select,textarea")[0]||P,I=Cg($),Z=k._f.refs||[];if(I?Z.find(ne=>ne===$):$===k._f.ref)return;G(i,v,{_f:{...k._f,...I?{refs:[...Z.filter(No),$,...Array.isArray(V(o,v))?[{}]:[]],ref:{type:$.type,name:v}}:{ref:$}}}),N(v,!1,void 0,$)}else k=V(i,v,{}),k._f&&(k._f.mount=!1),(r.shouldUnregister||w.shouldUnregister)&&!(vg(l.array,v)&&a.action)&&l.unMount.add(v)}}},It=()=>r.shouldFocusError&&Dn(i,Vt,l.mount),Ke=v=>{lt(v)&&(f.state.next({disabled:v}),Dn(i,w=>{w.disabled=v},0,!1))},Nr=(v,w)=>async k=>{k&&(k.preventDefault&&k.preventDefault(),k.persist&&k.persist());let M=ze(s);if(f.state.next({isSubmitting:!0}),r.resolver){const{errors:P,values:$}=await T();n.errors=P,M=$}else await J(i);ue(n.errors,"root"),Pe(n.errors)?(f.state.next({errors:{}}),await v(M,k)):(w&&await w({...n.errors},k),It(),setTimeout(It)),f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Pe(n.errors),submitCount:n.submitCount+1,errors:n.errors})},Hn=(v,w={})=>{V(i,v)&&(te(w.defaultValue)?We(v,V(o,v)):(We(v,w.defaultValue),G(o,v,w.defaultValue)),w.keepTouched||ue(n.touchedFields,v),w.keepDirty||(ue(n.dirtyFields,v),n.isDirty=w.defaultValue?R(v,V(o,v)):R()),w.keepError||(ue(n.errors,v),c.isValid&&y()),f.state.next({...n}))},su=(v,w={})=>{const k=v?ze(v):o,M=ze(k),P=v&&!Pe(v)?M:o;if(w.keepDefaultValues||(o=k),!w.keepValues){if(w.keepDirtyValues||p)for(const $ of l.mount)V(n.dirtyFields,$)?G(P,$,V(s,$)):We($,V(P,$));else{if(Vo&&te(v))for(const $ of l.mount){const I=V(i,$);if(I&&I._f){const Z=Array.isArray(I._f.refs)?I._f.refs[0]:I._f.ref;if(Nn(Z)){const ne=Z.closest("form");if(ne){ne.reset();break}}}}i={}}s=e.shouldUnregister?w.keepDefaultValues?ze(o):{}:ze(P),f.array.next({values:{...P}}),f.values.next({values:{...P}})}l={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!a.mount&&t(),a.mount=!c.isValid||!!w.keepIsValid,a.watch=!!e.shouldUnregister,f.state.next({submitCount:w.keepSubmitCount?n.submitCount:0,isDirty:w.keepDirty?n.isDirty:!!(w.keepDefaultValues&&!Tt(v,o)),isSubmitted:w.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:w.keepDirtyValues?n.dirtyFields:w.keepDefaultValues&&v?Lo(o,v):{},touchedFields:w.keepTouched?n.touchedFields:{},errors:w.keepErrors?n.errors:{},isSubmitSuccessful:w.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},au=(v,w)=>su(ut(v)?v(s):v,w);return{control:{register:Ot,unregister:rr,getFieldState:Fr,handleSubmit:Nr,setError:Dr,_executeSchema:T,_getWatch:B,_getDirty:R,_updateValid:y,_removeUnmounted:U,_updateFieldArray:C,_updateDisabledField:zn,_getFieldArray:z,_reset:su,_resetDefaultValues:()=>ut(r.defaultValues)&&r.defaultValues().then(v=>{au(v,r.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:v=>{n={...n,...v}},_disableForm:Ke,_subjects:f,_proxyFormState:c,get _fields(){return i},get _formValues(){return s},get _state(){return a},set _state(v){a=v},get _defaultValues(){return o},get _names(){return l},set _names(v){l=v},get _formState(){return n},set _formState(v){n=v},get _options(){return r},set _options(v){r={...r,...v}}},trigger:Y,register:Ot,handleSubmit:Nr,watch:Mt,setValue:We,getValues:ft,reset:au,resetField:Hn,clearErrors:Un,unregister:rr,setError:Dr,setFocus:(v,w={})=>{const k=V(i,v),M=k&&k._f;if(M){const P=M.refs?M.refs[0]:M.ref;P.focus&&(P.focus(),w.shouldSelect&&P.select())}},getFieldState:Fr}}function eu(e={}){const t=Te.useRef(),r=Te.useRef(),[n,i]=Te.useState({isDirty:!1,isValidating:!1,isLoading:ut(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:ut(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Vg(e,()=>i(s=>({...s}))),formState:n});const o=t.current.control;return o._options=e,wg({subject:o._subjects.state,next:s=>{bg(s,o._proxyFormState,o._updateFormState,!0)&&i({...o._formState})}}),Te.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),Te.useEffect(()=>{if(o._proxyFormState.isDirty){const s=o._getDirty();s!==n.isDirty&&o._subjects.state.next({isDirty:s})}},[o,n.isDirty]),Te.useEffect(()=>{e.values&&!Tt(e.values,r.current)?(o._reset(e.values,o._options.resetOptions),r.current=e.values):o._resetDefaultValues()},[e.values,o]),Te.useEffect(()=>{o._state.mount||(o._updateValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=yg(n,o),t.current}var tu=function(e,t,r){if(e&&"reportValidity"in e){var n=V(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},Mg=function(e,t){var r=function(i){var o=t.fields[i];o&&o.ref&&"reportValidity"in o.ref?tu(o.ref,i,e):o.refs&&o.refs.forEach(function(s){return tu(s,i,e)})};for(var n in t.fields)r(n)},Og=function(e,t){t.shouldUseNativeValidation&&Mg(e,t);var r={};for(var n in e){var i=V(t.fields,n),o=Object.assign(e[n]||{},{ref:i&&i.ref});if(Fg(t.names||Object.keys(e),n)){var s=Object.assign({},Ig(V(r,n)));G(s,"root",o),G(r,n,s)}else G(r,n,o)}return r},Ig=function(e){return Array.isArray(e)?e.filter(Boolean):[]},Fg=function(e,t){return e.some(function(r){return r.startsWith(t+".")})},Dg=function(e,t){for(var r={};e.issues.length;){var n=e.issues[0];if(n.path){var i=n.path.map(function(a){return a.key}).join(".");if(r[i]||(r[i]={message:n.message,type:n.validation}),t){var o=r[i].types,s=o&&o[n.validation];r[i]=Rl(i,t,r,n.validation,s?[].concat(s,n.message):n.message)}e.issues.shift()}}return r},ru=function(e,t,r){return r===void 0&&(r={}),function(n,i,o){try{return Promise.resolve(function(s,a){try{var l=function(){function u(c){return{values:r.raw?n:c,errors:{}}}var d=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},t);return r.mode==="sync"?u(ar(e,n,d)):Promise.resolve(Cu(e,n,d)).then(u)}()}catch(u){return a(u)}return l&&l.then?l.then(void 0,a):l}(0,function(s){if(s instanceof Zn)return{values:{},errors:Og(Dg(s,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw s}))}catch(s){return Promise.reject(s)}}};const Ng=27,Lg=12,Rg=10,Bg=e=>{const t=Object.fromEntries(new FormData(e).entries());Object.keys(t).length&&e.dispatchEvent(new Event("submit",{bubbles:!0}))},jg=_o("multiple-choice"),Ug=e=>{const t={min:e.minSelected??0,max:e.maxSelected??e.options.length};return ru(Ze({checked:ds(us(wu()),r=>Object.entries(r).filter(([n,i])=>i).map(([n,i])=>n),[cr(t.max,`Please select at most ${t.max} option${t.max!==1?"s":""}`),fs(t.min,`Please select at least ${t.min} option${t.min!==1?"s":""}`)])}))},zg=({input:e,onSubmitSuccess:t,onHeightChange:r})=>{var u,d;const n=e.key?(u=L.current$.value.flow)==null?void 0:u.data.submissions[e.key]:void 0,i=(e.config.minSelected===1||e.config.minSelected===void 0)&&e.config.maxSelected===1,{register:o,handleSubmit:s,formState:{errors:a}}=eu({defaultValues:{checked:i?{}:jg(n)?Object.fromEntries(n.value.map(c=>[c,!0])):{}},resolver:Ug(e.config)}),l=Eo();return g("form",{noValidate:!0,class:"flex flex-col gap-1 pr-2.5",onChange:c=>{i&&Bg(c.currentTarget)},onSubmit:s(c=>{const f=c.checked;t(f)}),children:[g("div",{class:"flex items-center gap-1",children:[g("ul",{style:{maxHeight:6.5*Ng+5*Lg+2*Rg},class:ct("gutter-stable flex w-full flex-1 flex-wrap gap-3 overflow-y-auto rounded-xl p-2.5 pr-4",{"justify-center":e.config.options.length===1}),children:e.config.options.map((c,f)=>{const p=`checked.${c.value}`,{ref:h,...m}=o(p);return g("li",{class:"relative",children:[g("input",{autoFocus:f===0,ref:b=>{b&&f===0&&(l.current=b),h(b)},id:p,...m,class:"peer sr-only h-full",type:"checkbox"}),g("label",{class:"bg-lowest peer-focus-visible:ring-accent-7 active:outline-neutral-10 ease-expo-out outline-divider text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 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:p,children:c.label})]},c.value)})}),g("div",{class:"flex flex-col items-center gap-2",children:[!i&&g(In,{}),e.config.minSelected===0&&g(Fn,{type:"button",onClick:()=>t([])})]})]}),g("div",{class:"px-1",children:g(To,{onAnimationComplete:r,error:(d=a.checked)==null?void 0:d.root})})]})},Hg=({input:e,onSubmitSuccess:t})=>g("div",{class:"flex flex-col items-center py-3",children:g("button",{class:"bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 group flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white shadow-[inset_0px_-6px_2px_-1px_oklch(100_0_0/.45),inset_0px_1px_1px_oklch(100_0_0/.3)] outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:shadow-[inset_0px_0px_2px_-1px_oklch(100_0_0/.45),inset_0px_3px_1px_.5px_oklch(0_0_0/.08)] active:ring-2 active:ring-offset-2",name:e.key,onClick:()=>{t(null)},children:g("span",{class:"relative bottom-[2px] top-[-2px] flex items-center gap-1.5 transition-all duration-300 group-active:bottom-0 group-active:top-0",children:[g("span",{class:"inline-flex items-center text-sm font-medium",children:e.config.label}),g("svg",{stroke:"currentColor","stroke-width":"1.5",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g("path",{d:"M4 8L8 4L12 8"}),g("path",{d:"M8 4V13"})]})]})})}),tr={empty:"Please enter some text",email:"That doesn’t look like a valid email address",phone:"That doesn’t look like a valid phone number",url:"That doesn’t look like a valid URL"},Wg=$e(tr.phone,[Pu(/^\+?[0-9 -]+$/,tr.phone)]),Kg={email:{type:"email",inputMode:"email",formNoValidate:!0},phone:{type:"tel",inputMode:"tel"},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},qg=_o("text"),Gg=e=>{const t=`Please enter no more than ${e.maxChars} characters`;return ru(Ze({text:{email:$e(tr.email,[Au(tr.email),cr(e.maxChars??1/0,t)]),phone:ds(Wg,r=>r.replace(/[^0-9]/g,""),[cr(e.maxChars??1/0,t)]),text:$e([fs(1,tr.empty),cr(e.maxChars??1/0,t)]),url:$e([Eu(tr.url),cr(e.maxChars??1/0,t)])}[e.format]}))},Yg=({input:e,onSubmitSuccess:t,onHeightChange:r})=>{var c;const n=e.key?(c=L.current$.value.flow)==null?void 0:c.data.submissions[e.key]:void 0,i=e.config.defaultValue,{register:o,handleSubmit:s,formState:{errors:a}}=eu({defaultValues:{text:i||(qg(n)?n.value:"")},resolver:Gg(e.config)}),{ref:l,...u}=o("text",{required:!e.config.optional}),d=j();return Ae(()=>{d.current&&(d.current.focus(),d.current.select())},[]),g(Q,{children:g("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:s(f=>{t(f.text)}),children:[g("div",{class:"flex items-center gap-2",children:[g("div",{class:"relative min-w-0 flex-grow",children:[g("input",{id:"chat-input",...u,...Kg[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:f=>{f&&(d.current=f),l(f)},class:"outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest w-full rounded-full px-3 py-1 text-base outline outline-2 transition-all",placeholder:e.config.placeholder}),e.config.optional&&g(Fn,{class:"absolute right-0 top-0",onClick:()=>t(null)})]}),g(In,{})]}),g(To,{onAnimationComplete:r,error:a.text})]})})},Zg=()=>{var i;const e=(i=L.current$.value.flow)==null?void 0:i.data.currentInput,t=j(null),r=ae(()=>{t.current&&(L.inputHeight$.value=t.current.getBoundingClientRect().height)},[]);W(()=>{r()},[e==null?void 0:e.type,r]);const n=o=>s=>Ve.onSubmitSuccessFn$.value({type:o,value:s});return g(kn.div,{initial:{height:0},animate:{height:L.inputHeight$.value},exit:{height:0,opacity:0},onAnimationStart:Ve.scrollToEnd.smooth,onAnimationComplete:Ve.scrollToEnd.smooth,class:"bg-statusbar absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-md backdrop-saturate-150",children:g("div",{ref:t,class:"border-divider border-t",children:Ue({input:e,onHeightChange:r}).with({input:_e.nullish},()=>g("div",{class:"flex items-center gap-2 p-2.5",children:[g("input",{"aria-hidden":"true",id:"chat-input",class:"outline-divider flex-grow rounded-full bg-transparent px-3 py-1 text-base outline outline-2",disabled:!0}),g(In,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})).with({input:{type:"text"}},o=>g(Yg,{onSubmitSuccess:n(o.input.type),...o})).with({input:{type:"multiple-choice"}},o=>g(zg,{onSubmitSuccess:n(o.input.type),...o})).with({input:{type:"boolean"}},o=>g(sg,{onSubmitSuccess:n(o.input.type),...o})).with({input:{type:"file"}},o=>g(hg,{onSubmitSuccess:n(o.input.type),...o})).with({input:{type:"submit"}},o=>g(Hg,{onSubmitSuccess:n(o.input.type),...o})).exhaustive()})})},nu=e=>typeof e=="boolean"?"".concat(e):e===0?"0":e,iu=ct,ou=(e,t)=>r=>{var n;if((t==null?void 0:t.variants)==null)return iu(e,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:i,defaultVariants:o}=t,s=Object.keys(i).map(u=>{const d=r==null?void 0:r[u],c=o==null?void 0:o[u];if(d===null)return null;const f=nu(d)||nu(c);return i[u][f]}),a=r&&Object.entries(r).reduce((u,d)=>{let[c,f]=d;return f===void 0||(u[c]=f),u},{}),l=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,d)=>{let{class:c,className:f,...p}=d;return Object.entries(p).every(h=>{let[m,b]=h;return Array.isArray(b)?b.includes({...o,...a}[m]):{...o,...a}[m]===b})?[...u,c,f]:u},[]);return iu(e,s,l,r==null?void 0:r.class,r==null?void 0:r.className)},Xg=ou("max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative",{variants:{side:{left:"bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",right:"ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"},transitionState:{entering:"opacity-0 translate-y-8",entered:"opacity-100 translate-y-0",exiting:"opacity-0 scale-0",exited:""}},defaultVariants:{side:"left"}}),Qg={hidden:{y:"100%",scale:.75},shown:{y:0,scale:1}},Jg=({children:e,className:t,transitionState:r,side:n,...i})=>g(kn.p,{variants:Qg,initial:"hidden",animate:"shown",transition:{type:"spring",damping:25,stiffness:500},"data-transition":r,style:{transformOrigin:n==="left"?"0% 50%":"100% 50%"},class:Xg({className:t,side:n,transitionState:r}),...i,children:e}),ey=({className:e,...t})=>(W(()=>{Ve.scrollToEnd.smooth()}),g("div",{"aria-hidden":!0,children:Ve.isBotTyping$.value===!0?g("div",{"aria-label":"Typing…",class:ct("flex gap-1 p-4",e),...t,children:Array.from({length:3},(r,n)=>g("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-n*200}ms`}}))}):void 0})),ty={bot:"left",user:"right"},ry=ou("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]",{variants:{variant:{info:"text-neutral-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),ny=({lastSentMessageFooter:e})=>{var r;const t=((r=L.current$.value.flow)==null?void 0:r.data.messages)??[];return W(()=>{Ve.scrollToEnd.smooth()},[t.length]),g("ol",{"aria-label":"Chat messages",class:"flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[g(nl,{initial:!1,children:t.map((n,i)=>g(Q,{children:g("li",{class:"flex",children:Ue(n).with({type:"system"},o=>g("p",{class:ry({variant:o.variant}),children:o.text})).with({type:"text",author:_e.union("bot","user")},o=>{const s=o.author==="user"&&!t.slice(i+1).some(a=>a.type==="text"&&a.author==="user");return g(Jg,{side:ty[o.author],children:[o.text,s?e:null]},i)}).with({type:"link"},o=>g("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:g("a",{class:"bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:o.href,children:[o.text,g("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:g("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=>g("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=>g(ug,{class:o.author==="bot"?"":"ml-auto",file:{name:o.fileName,sizeKb:o.fileSizeKb}})).exhaustive()})},i))}),g(ey,{},"typing")]})},iy=({logger:e,apiClient:t,analytics:r})=>{const{flow:n}=L.current$.value;Xe(n,"Flow is required to exist to show chatbot body");const i=L.viewState$.value,{chatRef:o,chatService:s}=ng(),[a,l]=ie();return Ae(()=>{i==="maximised"&&Ve.scrollToEnd.instant()},[i]),Ae(()=>{const{state:u,flow:d}=L.current$.peek();if(u!=="loaded")throw new Error(Km.invalid_state);let c=d.data.nodeHistory.at(-1);if(Ve.scrollToEnd.instant(),L.setInput(void 0),d.data.isFinished)return;c===void 0?(c=_l(n.nodes).id,L.setCurrentNodeId(c),r.log({event:"FLOW_START",properties:{flow_id:n.id,flow_version:n.version,flow_session_id:d.data.flowSessionId}})):L.removeMessagesSentByNodeIds([c]);const{interpret:f,abort:p,undo:h}=Bv({context:n.context,analytics:r,apiClient:t,logger:e,flow:n.nodes,chatService:s,getSubmissions:()=>{var m;return(m=L.current$.peek().flow)==null?void 0:m.data.submissions},onInterpret:(m,b)=>{const x=L.current$.peek().flow;Xe(x),b&&(x.data.sequence=x.data.sequence+1,r.log({event:"FLOW_NODE",properties:{flow_id:n.id,flow_version:n.version,from_node_id:b.id,to_node_id:m.id,sequence:x.data.sequence,flow_session_id:x.data.flowSessionId},customProperties:n.context})),L.setCurrentNodeId(m.id)},onFlowEnd:async()=>{L.markAsFinished();const m=L.current$.peek().flow;Xe(m),r.log({event:"FLOW_END",properties:{flow_id:n.id,flow_version:n.version,flow_session_id:m.data.flowSessionId},customProperties:n.context})}});return l(()=>h),f(c),p},[r,t,s,e,n]),g(Q,{children:[g("div",{ref:o,className:"hide-scrollbars relative flex w-full max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:L.inputHeight$.value},children:g(ny,{lastSentMessageFooter:n.data.isFinished||!a?null:g(sy,{undoFn:a})})}),g(Zg,{})]})},oy=e=>"key"in e.data&&e.data.key?[e.data.key]:"keys"in e.data?Object.values(e.data.keys).filter(t=>typeof t=="string"):[],sy=({undoFn:e})=>g("div",{class:"absolute bottom-0 right-0 flex w-full translate-y-full justify-end",children:g("button",{class:"fr touch-hitbox text-neutral-9 hover:text-neutral-12 rounded-full p-1 text-right text-xs transition-all",onClick:async()=>{const{flow:t}=L.current$.peek();Xe(t);const{removed:r}=e(t.data.nodeHistory),n=t.data.nodeHistory.splice(-r);n.length!==0&&(L.removeMessagesSentByNodeIds(n),L.setInput(void 0),n.pop(),n.map(i=>t.nodes.find(o=>o.id===i)).filter(Boolean).flatMap(oy).forEach(i=>delete t.data.submissions[i]),L.current$.value={...L.current$.value})},children:"Undo"})}),ay=Object.freeze(Object.defineProperty({__proto__:null,ChatbotBody:iy},Symbol.toStringTag,{value:"Module"}))})();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-395856be.cjs");
|
|
4
4
|
require("@inploi/sdk");
|
|
5
5
|
const followNodes = ({
|
|
6
6
|
node,
|
|
@@ -196,7 +196,7 @@ async function interpretSubmitNode({
|
|
|
196
196
|
context,
|
|
197
197
|
analytics
|
|
198
198
|
}) {
|
|
199
|
-
if (node.data.
|
|
199
|
+
if (node.data.skipConfirmation !== true) {
|
|
200
200
|
await chat.userInput({
|
|
201
201
|
type: "submit",
|
|
202
202
|
key: void 0,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _, g as getHeadOrThrow, i as invariant, A as AbortedError, N, a as getFlowSubmissionsPayload, h as hasProp, k as kbToReadableSize, o as o$1, c as clsx, b as a$2, d as _$1, y, F, s as store, p, e as parse, f as picklist, j as h, l as k, m as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, u as minLength, v as record, w as boolean, x as string, z as email, B as url, D as regex, T, E as m, G as AnimatePresence, H as ERROR_MESSAGES } from "./index-
|
|
1
|
+
import { _, g as getHeadOrThrow, i as invariant, A as AbortedError, N, a as getFlowSubmissionsPayload, h as hasProp, k as kbToReadableSize, o as o$1, c as clsx, b as a$2, d as _$1, y, F, s as store, p, e as parse, f as picklist, j as h, l as k, m as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, u as minLength, v as record, w as boolean, x as string, z as email, B as url, D as regex, T, E as m, G as AnimatePresence, H as ERROR_MESSAGES } from "./index-b4781911.js";
|
|
2
2
|
import "@inploi/sdk";
|
|
3
3
|
const followNodes = ({
|
|
4
4
|
node,
|
|
@@ -194,7 +194,7 @@ async function interpretSubmitNode({
|
|
|
194
194
|
context,
|
|
195
195
|
analytics
|
|
196
196
|
}) {
|
|
197
|
-
if (node.data.
|
|
197
|
+
if (node.data.skipConfirmation !== true) {
|
|
198
198
|
await chat.userInput({
|
|
199
199
|
type: "submit",
|
|
200
200
|
key: void 0,
|
package/dist/chatbot.api.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare const FlowSchema: import("valibot").ObjectSchema<{
|
|
|
35
35
|
id: string;
|
|
36
36
|
data: {
|
|
37
37
|
integrationId: string;
|
|
38
|
-
|
|
38
|
+
skipConfirmation: boolean;
|
|
39
39
|
submitLabel: string;
|
|
40
40
|
};
|
|
41
41
|
type: "integration-application-submit";
|
|
@@ -194,7 +194,7 @@ export declare const FlowSchema: import("valibot").ObjectSchema<{
|
|
|
194
194
|
id: string;
|
|
195
195
|
data: {
|
|
196
196
|
integrationId: string;
|
|
197
|
-
|
|
197
|
+
skipConfirmation: boolean;
|
|
198
198
|
submitLabel: string;
|
|
199
199
|
};
|
|
200
200
|
type: "integration-application-submit";
|
|
@@ -357,7 +357,7 @@ export declare const FlowSchema: import("valibot").ObjectSchema<{
|
|
|
357
357
|
id: string;
|
|
358
358
|
data: {
|
|
359
359
|
integrationId: string;
|
|
360
|
-
|
|
360
|
+
skipConfirmation: boolean;
|
|
361
361
|
submitLabel: string;
|
|
362
362
|
};
|
|
363
363
|
type: "integration-application-submit";
|
|
@@ -522,7 +522,7 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
|
|
|
522
522
|
id: string;
|
|
523
523
|
data: {
|
|
524
524
|
integrationId: string;
|
|
525
|
-
|
|
525
|
+
skipConfirmation: boolean;
|
|
526
526
|
submitLabel: string;
|
|
527
527
|
};
|
|
528
528
|
type: "integration-application-submit";
|
|
@@ -681,7 +681,7 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
|
|
|
681
681
|
id: string;
|
|
682
682
|
data: {
|
|
683
683
|
integrationId: string;
|
|
684
|
-
|
|
684
|
+
skipConfirmation: boolean;
|
|
685
685
|
submitLabel: string;
|
|
686
686
|
};
|
|
687
687
|
type: "integration-application-submit";
|
|
@@ -844,7 +844,7 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
|
|
|
844
844
|
id: string;
|
|
845
845
|
data: {
|
|
846
846
|
integrationId: string;
|
|
847
|
-
|
|
847
|
+
skipConfirmation: boolean;
|
|
848
848
|
submitLabel: string;
|
|
849
849
|
};
|
|
850
850
|
type: "integration-application-submit";
|
|
@@ -1009,7 +1009,7 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
|
|
|
1009
1009
|
id: string;
|
|
1010
1010
|
data: {
|
|
1011
1011
|
integrationId: string;
|
|
1012
|
-
|
|
1012
|
+
skipConfirmation: boolean;
|
|
1013
1013
|
submitLabel: string;
|
|
1014
1014
|
};
|
|
1015
1015
|
type: "integration-application-submit";
|
|
@@ -1180,7 +1180,7 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
|
|
|
1180
1180
|
id: string;
|
|
1181
1181
|
data: {
|
|
1182
1182
|
integrationId: string;
|
|
1183
|
-
|
|
1183
|
+
skipConfirmation: boolean;
|
|
1184
1184
|
submitLabel: string;
|
|
1185
1185
|
};
|
|
1186
1186
|
type: "integration-application-submit";
|
|
@@ -1339,7 +1339,7 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
|
|
|
1339
1339
|
id: string;
|
|
1340
1340
|
data: {
|
|
1341
1341
|
integrationId: string;
|
|
1342
|
-
|
|
1342
|
+
skipConfirmation: boolean;
|
|
1343
1343
|
submitLabel: string;
|
|
1344
1344
|
};
|
|
1345
1345
|
type: "integration-application-submit";
|
|
@@ -1502,7 +1502,7 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
|
|
|
1502
1502
|
id: string;
|
|
1503
1503
|
data: {
|
|
1504
1504
|
integrationId: string;
|
|
1505
|
-
|
|
1505
|
+
skipConfirmation: boolean;
|
|
1506
1506
|
submitLabel: string;
|
|
1507
1507
|
};
|
|
1508
1508
|
type: "integration-application-submit";
|
|
@@ -1674,7 +1674,7 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
|
|
|
1674
1674
|
id: string;
|
|
1675
1675
|
data: {
|
|
1676
1676
|
integrationId: string;
|
|
1677
|
-
|
|
1677
|
+
skipConfirmation: boolean;
|
|
1678
1678
|
submitLabel: string;
|
|
1679
1679
|
};
|
|
1680
1680
|
type: "integration-application-submit";
|
|
@@ -1847,7 +1847,7 @@ export declare const StartFlowSchema: import("valibot").ObjectSchema<{
|
|
|
1847
1847
|
id: string;
|
|
1848
1848
|
data: {
|
|
1849
1849
|
integrationId: string;
|
|
1850
|
-
|
|
1850
|
+
skipConfirmation: boolean;
|
|
1851
1851
|
submitLabel: string;
|
|
1852
1852
|
};
|
|
1853
1853
|
type: "integration-application-submit";
|
|
@@ -2006,7 +2006,7 @@ export declare const StartFlowSchema: import("valibot").ObjectSchema<{
|
|
|
2006
2006
|
id: string;
|
|
2007
2007
|
data: {
|
|
2008
2008
|
integrationId: string;
|
|
2009
|
-
|
|
2009
|
+
skipConfirmation: boolean;
|
|
2010
2010
|
submitLabel: string;
|
|
2011
2011
|
};
|
|
2012
2012
|
type: "integration-application-submit";
|
|
@@ -2169,7 +2169,7 @@ export declare const StartFlowSchema: import("valibot").ObjectSchema<{
|
|
|
2169
2169
|
id: string;
|
|
2170
2170
|
data: {
|
|
2171
2171
|
integrationId: string;
|
|
2172
|
-
|
|
2172
|
+
skipConfirmation: boolean;
|
|
2173
2173
|
submitLabel: string;
|
|
2174
2174
|
};
|
|
2175
2175
|
type: "integration-application-submit";
|
|
@@ -2339,7 +2339,7 @@ export declare const StartFlowSchema: import("valibot").ObjectSchema<{
|
|
|
2339
2339
|
id: string;
|
|
2340
2340
|
data: {
|
|
2341
2341
|
integrationId: string;
|
|
2342
|
-
|
|
2342
|
+
skipConfirmation: boolean;
|
|
2343
2343
|
submitLabel: string;
|
|
2344
2344
|
};
|
|
2345
2345
|
type: "integration-application-submit";
|
package/dist/chatbot.utils.d.ts
CHANGED
|
@@ -9100,7 +9100,7 @@ const StatusBar = ({
|
|
|
9100
9100
|
})
|
|
9101
9101
|
});
|
|
9102
9102
|
};
|
|
9103
|
-
const ChatbotBody = M(() => Promise.resolve().then(() => require("./chatbot-body-
|
|
9103
|
+
const ChatbotBody = M(() => Promise.resolve().then(() => require("./chatbot-body-1c87450e.cjs")).then((module2) => module2.ChatbotBody));
|
|
9104
9104
|
const MotionProvider = ({
|
|
9105
9105
|
children
|
|
9106
9106
|
}) => {
|
|
@@ -9099,7 +9099,7 @@ const StatusBar = ({
|
|
|
9099
9099
|
})
|
|
9100
9100
|
});
|
|
9101
9101
|
};
|
|
9102
|
-
const ChatbotBody = M(() => import("./chatbot-body-
|
|
9102
|
+
const ChatbotBody = M(() => import("./chatbot-body-83a30845.js").then((module) => module.ChatbotBody));
|
|
9103
9103
|
const MotionProvider = ({
|
|
9104
9104
|
children
|
|
9105
9105
|
}) => {
|
package/dist/plugin-chatbot.cjs
CHANGED
package/dist/plugin-chatbot.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inploi/plugin-chatbot",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/plugin-chatbot.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"vite": "^4.4.5",
|
|
66
66
|
"vite-plugin-dts": "^3.7.0",
|
|
67
67
|
"vite-tsconfig-paths": "^4.2.1",
|
|
68
|
-
"@inploi/core": "1.11.
|
|
68
|
+
"@inploi/core": "1.11.10",
|
|
69
69
|
"@inploi/design-tokens": "0.2.1",
|
|
70
70
|
"@inploi/sdk": "1.12.2",
|
|
71
71
|
"eslint-config-custom": "0.1.0",
|