@inploi/plugin-chatbot 5.1.2 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-97d91e46.cjs");require("@inploi/sdk");const ot=({condition:e,context:r,submissions:n,ifBlock:s})=>{const[a,...i]=e.compareKey.split(".");if(!a)return!1;const o=Mt({context:r,key:a,path:i,submissions:n});if(!o)return!1;switch(o.type){case"address":{const u=t.get(o.value,i.join("."));switch(e.compare){case"equals":return u===e.compareValue;case"contains":return u?u.includes(e.compareValue):!1;case"notEquals":return u!==e.compareValue;case"notContains":return u?!u.includes(e.compareValue):!0}break}case"integration":{if(typeof o.value!="object"||Array.isArray(o.value))return!1;const u=t.get(o.value,i.join(".")),d={...s,data:{...s.data,compareKey:"_temp"}};switch(typeof u){case"boolean":return ye(d,{submissions:{_temp:{value:u,type:"boolean"}},context:r});case"string":return ye(d,{submissions:{_temp:{value:u,type:"string"}},context:r});case"number":return ye(d,{submissions:{_temp:{value:u,type:"number"}},context:r});case"object":return Array.isArray(u)&&u.every(t.isString)?ye(d,{submissions:{_temp:{value:u,type:"enum"}},context:r}):!1}break}case"boolean":{const u=e.compareValue==="true";switch(e.compare){case"equals":return o.value===u;case"notEquals":return o.value!==u}break}case"phone":case"string":{const u=o.type==="phone"?Me(o.value):o.value;switch(e.compare){case"equals":return u===e.compareValue;case"contains":return u?u.includes(e.compareValue):!1;case"notEquals":return u!==e.compareValue;case"notContains":return u?!u.includes(e.compareValue):!0}break}case"number":{try{const u=Number(e.compareValue);switch(e.compare){case"equals":return o.value===u;case"notEquals":return o.value!==u;case"greaterThan":return o.value>u;case"greaterThanOrEqualTo":return o.value>=u;case"lessThan":return o.value<u;case"lessThanOrEqualTo":return o.value<=u}}catch{return console.error(`Failed to parse number in if-block ${s.id}`,o.value),!1}break}case"enum":switch(e.compare){case"equals":return o.value.length===1&&o.value[0]===e.compareValue;case"notEquals":return o.value.length===1&&o.value[0]!==e.compareValue;case"contains":return o.value.includes(e.compareValue);case"notContains":return!o.value.includes(e.compareValue)}break}},ye=(e,{context:r,submissions:n})=>{const s="combinator"in e.data?e.data.conditions:[e.data];if(("combinator"in e.data?e.data.combinator:"and")==="or"){for(const i of s)if(ot({condition:i,context:r,submissions:n,ifBlock:e}))return!0;return!1}else{for(const i of s)if(!ot({condition:i,context:r,submissions:n,ifBlock:e}))return!1;return!0}},Qt=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,Z=(e,{context:r,submissions:n})=>e.replace(Qt,(s,a,i="")=>{const[o,...u]=a.trim().split("."),d=Mt({key:o,path:u,submissions:n,context:r});if(!d)return i;switch(d.type){case"boolean":return d.value===!0?"true":"false";case"file":return d.value.map(p=>`${p.name} (${t.kbToReadableSize(p.sizeKb)})`).join(", ");case"enum":return d.value.join(", ");case"address":return Object.values(d.value).filter(p=>p&&p.trim().length>0).join(", ");case"number":case"string":return d.value?d.value.toString():i;case"phone":return Me(d.value);case"integration":{if(typeof d.value!="object"||Array.isArray(d.value))break;const p=t.get(d.value,u.join("."));switch(typeof p){case"boolean":return p===!0?"true":"false";case"string":return p;case"number":return p.toString();case"object":if(Array.isArray(p)&&p.every(t.isString))return p.join(", ")}break}}return i}),Vt=({node:e,nodes:r,stopWhen:n})=>{if((n==null?void 0:n(e))===!0)return e;const s=e.nextId?r.find(a=>a.id===e.nextId):void 0;if(s)return Vt({node:s,nodes:r,stopWhen:n})},er=({childNode:e,nodes:r})=>{const s=r.filter(a=>a.type==="if-block").find(a=>{if(!a.branchId)return!1;const i=r.find(u=>u.id===a.branchId);if(!i)return!1;const o=Vt({node:i,nodes:r,stopWhen:u=>u.id===e.id});return!(!o||o.id!==e.id)});if(s!=null&&s.nextId)return r.find(a=>a.id===s.nextId)},tr=({flow:e,analytics:r,logger:n,context:s,apiClient:a,getSubmissions:i,chatService:o,onFlowEnd:u,onInterpret:d,t:p})=>{let w=new AbortController;const v={...r.service,log:k=>r.service.log({...k,customProperties:{...k.customProperties,...r.customProperties}})},h=async(k,y)=>{const A=i();d==null||d(k,y);try{await rr({flow:e,analytics:v,logger:n,apiClient:a,context:s,node:k,submissions:A,t:p,chat:{sendMessage:async S=>o.send({groupId:k.id,message:S,signal:w.signal}),userInput:async S=>o.input({input:S,signal:w.signal}),addToSubmissions:o.addToSubmissions},next:S=>{const E=S?e.nodes.find(g=>g.id===S):er({childNode:k,nodes:e.nodes});return E?h(E,k):u==null?void 0:u(k)},end:()=>u==null?void 0:u(k)})}catch(S){if(S instanceof t.AbortedError)return;throw S}};return{interpret:async k=>{const y=e.nodes.find(A=>A.id===k)??t.getHeadOrThrow(e.nodes);return h(y)},undo:k=>{let y=1;const A=e.nodes.find(E=>E.id===k[k.length-1]);for(let E=k.length-2;E>0;E--){const g=k[E],M=e.nodes.find($=>$.id===g);if(!M||(y++,M.type.startsWith("question-")))break}w.abort(),w=new AbortController;const S=e.nodes.find(E=>E.id===k[k.length-y]);return t.invariant(S,"Undo failed: new start node not found"),h(S,A),{removed:y}},abort:()=>{w.abort()}}},Me=e=>`+${e.countryCode} ${e.phoneNumber}`;async function rr(e){const r=e.node;switch(r.type){case"text":return cr({...e,node:r});case"image":return dr({...e,node:r});case"question-text":return fr({...e,node:r});case"question-enum":return mr({...e,node:r});case"question-number":return hr({...e,node:r});case"question-phone":return pr({...e,node:r});case"question-boolean":return gr({...e,node:r});case"question-file":return yr({...e,node:r});case"question-address":return br({...e,node:r});case"end-flow":return vr({...e,node:r});case"if-block":return ur({...e,node:r});case"jump":return ar({...e,node:r});case"link":return lr({...e,node:r});case"integration-application-submit":return or({...e,node:r});case"add-submission":return ir({...e,node:r});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"identify":return sr({...e,node:r});case"feedback":return nr({...e,node:r});default:throw new Error(`Unknown node: ${JSON.stringify(r)}`)}}const me=(e,r)=>{var s;const n=(s=e[r])==null?void 0:s.value;if(typeof n!="string"&&typeof n!="number")throw new Error(`Submission at “${r}” is not a string or number`);return n};async function nr({next:e,node:r}){e(r.nextId)}async function sr({next:e,node:r,analytics:n,submissions:s,logger:a}){if(!s)return e(r.nextId);try{n.log({event:"IDENTIFY",properties:{identifier:me(s,r.data.key).toString(),first_name:r.data.firstName?me(s,r.data.firstName).toString():void 0,last_name:r.data.lastName?me(s,r.data.lastName).toString():void 0,email:r.data.email?me(s,r.data.email).toString():void 0,phone_number:r.data.phoneNumber?me(s,r.data.phoneNumber).toString():void 0,custom_traits:r.data.customTraits?Object.fromEntries(r.data.customTraits.map(({key:i,value:o})=>{var u;return[i,(u=s[o])==null?void 0:u.value]})):void 0}})}catch(i){a.error(i)}finally{e(r.nextId)}}async function ar({next:e,node:r}){e(r.data.targetId)}async function ir({next:e,node:r,logger:n,submissions:s,context:a}){if(!s){n.error("Submissions not found");return}s[r.data.key]={type:"string",value:Z(r.data.value,{submissions:s,context:a})},e(r.nextId)}async function or({chat:e,next:r,node:n,logger:s,apiClient:a,submissions:i,analytics:o,flow:u,t:d}){const p=async w=>{w!==!0&&await e.userInput({type:"submit",key:void 0,config:{label:n.data.submitLabel}}),await e.sendMessage({type:"loading"});const{anonymous_id:v,session_id:h}=o.getSessionInfo(),k=await a.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:n.data.integrationId,anonymous_id:v,session_id:h,job:u.job,submissions:t.getFlowSubmissionsPayload(i||{})})}).catch(y=>y);n.data.key&&e.addToSubmissions(n.data.key,{type:"integration",value:k}),t.N(k).with({integration_response:t._.select(t._.union({service:t._.optional(t._.string),status:t._.number,data:t._.any},{service:t._.optional(t._.string),status:t._.number,error:{message:t._.string,data:t._.any}}))},y=>{o.log({event:"FLOW_SUBMIT",properties:{flow_id:u.id,flow_version:u.version,flow_session_id:u.data.flowSessionId,flow_build:u.build,service:y.service??"INVALID_SERVICE",response:{status:y.status,payload:"data"in y?y.data:y.error.data??null},job:u.job}})}).otherwise(()=>{}),await t.N(k).with({integration_response:{data:t._.select("redirect",{redirect_url:t._.string,message:t._.optional(t._.union(t._.string,t._.nullish)),button_text:t._.optional(t._.union(t._.string,t._.nullish))})}},async y=>{await e.sendMessage({type:"text",author:"bot",text:y.redirect.message??d("submission_redirect_message")});try{const A=new URL(y.redirect.redirect_url);v&&!A.searchParams.has("anonymous_id")&&A.searchParams.set("anonymous_id",v),await e.sendMessage({type:"link",href:A.toString(),text:y.redirect.button_text??d("complete_submission"),onClick:()=>{if(!h){s.error("session_id not set, cannot log FLOW_REDIRECT event");return}o.log({event:"FLOW_REDIRECT",properties:{flow_build:u.build,flow_id:u.id,flow_session_id:h,flow_version:u.version,href:A.toString(),job:u.job}})}})}catch(A){s.error(`Invalid redirect URL: ${y.redirect.redirect_url}`,A),e.sendMessage({type:"system",variant:"error",text:d("redirect_url_error")})}r(n.nextId)}).with({success:!0},async()=>{n.data.skipConfirmation!==!0&&await e.sendMessage({type:"system",variant:"success",text:d("submission_completed")}),r(n.nextId)}).with({integration_response:{error:t._.select("error",{message:t._.string})}},async y=>{s.error(y.error),await e.sendMessage({type:"system",variant:"error",text:y.error.message||d("submission_failed")}),await p(!1)}).otherwise(async y=>{s.error(y),await e.sendMessage({type:"system",variant:"error",text:d("submission_failed")}),await p(!1)})};await p(n.data.skipConfirmation)}async function lr({chat:e,next:r,node:n,submissions:s,context:a}){await e.sendMessage({type:"link",href:Z(n.data.href,{submissions:s,context:a}),text:Z(n.data.cta,{submissions:s,context:a})}),r(n.nextId)}async function ur({submissions:e,next:r,node:n,context:s}){r(ye(n,{submissions:e,context:s})?n.branchId:n.nextId)}async function cr({chat:e,next:r,node:n,submissions:s,context:a}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.text,{submissions:s,context:a})}),r(n.nextId)}async function dr({chat:e,next:r,node:n}){await e.sendMessage({author:"bot",type:"image",url:n.data.url,height:n.data.height,width:n.data.width}),r(n.nextId)}async function fr({chat:e,next:r,node:n,submissions:s,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const o=n.data.format==="phone"?await e.userInput({key:n.data.key,type:"phone",config:{optional:n.data.optional,placeholder:n.data.placeholder,minChars:n.data.minChars,submissionFormat:"text",defaultValue:{}}}):await e.userInput({key:n.data.key,type:"text",config:{optional:n.data.optional,placeholder:n.data.placeholder,format:n.data.format,maxChars:n.data.maxChars,minChars:n.data.minChars}});o===null?await e.sendMessage({type:"system",variant:"info",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.type==="phone"?Me(o.value):o.value}),r(n.nextId)}async function hr({chat:e,next:r,node:n,submissions:s,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const o=await e.userInput({key:n.data.key,type:"number",config:{max:n.data.max,min:n.data.min,optional:n.data.optional,placeholder:n.data.placeholder,decimalCases:n.data.decimalCases}});o===null?await e.sendMessage({type:"system",variant:"info",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.value.toString()}),r(n.nextId)}async function pr({chat:e,next:r,node:n,submissions:s,context:a}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const i=await e.userInput({key:n.data.key,type:"phone",config:{minChars:n.data.minChars,defaultValue:{countryCode:n.data.defaultCountryCode},placeholder:n.data.placeholder,submissionFormat:"phone",optional:n.data.optional}});i===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:i.type==="phone"?Me(i.value):i.value}),r(n.nextId)}async function mr({chat:e,next:r,node:n,submissions:s,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const o=await e.userInput({key:n.data.key,type:"multiple-choice",config:n.data});o.value.length===0?await e.sendMessage({type:"system",variant:"info",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:n.data.options.filter(u=>o.value.includes(u.value)).map(u=>u.label).join(", ")}),r(n.nextId)}async function gr({chat:e,next:r,node:n,submissions:s,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const o=await e.userInput({key:n.data.key,type:"boolean",config:{optional:n.data.optional,labels:{true:n.data.trueLabel,false:n.data.falseLabel}}});o===null?await e.sendMessage({type:"system",variant:"info",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.value===!0?n.data.trueLabel:n.data.falseLabel}),r(n.nextId)}async function br({chat:e,next:r,node:n,t:s}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const a=await e.userInput({type:"address",key:n.data.key,config:{optional:n.data.optional,keys:n.data.keys,placeholder:n.data.placeholder}});if(a===null)await e.sendMessage({type:"system",variant:"info",text:s("skipped")});else{const i=Object.values(a.value).filter(o=>o&&o.trim().length>0).join(", ");await e.sendMessage({author:"user",type:"text",text:i})}return r(n.nextId)}async function yr({node:e,chat:r,next:n,submissions:s,context:a,t:i}){await r.sendMessage({author:"bot",type:"text",text:Z(e.data.question,{submissions:s,context:a})});const o=await r.userInput({key:e.data.key,type:"file",config:{optional:e.data.optional,extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb??10*1024,allowMultiple:e.data.multiple===!0}});if(o===null)await r.sendMessage({type:"system",variant:"info",text:i("skipped")});else for(const u of o.value)await r.sendMessage({author:"user",type:"file",fileName:u.name,fileSizeKb:u.sizeKb});n(e.nextId)}async function vr({chat:e,end:r,node:n}){await e.sendMessage({type:"system",variant:"info",text:n.data.systemMessage}),r()}const Mt=({key:e,path:r,submissions:n,context:s})=>{if(e==="$context"){if(!r)return;const a=t.get(s,r.join("."));switch(typeof a){case"string":return{type:"string",value:a};case"number":return{type:"number",value:a};case"boolean":return{type:"boolean",value:a};default:console.warn(`Unexpected type for $context.${r.join(".")}`,a);return}}return n==null?void 0:n[e]};function Ue(e,r,n){var s,a,i,o,u;r==null&&(r=100);function d(){var w=Date.now()-o;w<r&&w>=0?s=setTimeout(d,r-w):(s=null,n||(u=e.apply(i,a),i=a=null))}var p=function(){i=this,a=arguments,o=Date.now();var w=n&&!s;return s||(s=setTimeout(d,r)),w&&(u=e.apply(i,a),i=a=null),u};return p.clear=function(){s&&(clearTimeout(s),s=null)},p.flush=function(){s&&(u=e.apply(i,a),i=a=null,clearTimeout(s),s=null)},p}Ue.debounce=Ue;var xr=Ue;const lt=t.getDefaultExportFromCjs(xr);function wr(e){let{debounce:r,scroll:n,polyfill:s,offsetSize:a}=e===void 0?{debounce:0,scroll:!1,offsetSize:!1}:e;const i=s||(typeof window>"u"?class{}:window.ResizeObserver);if(!i)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[o,u]=t.h({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),d=t._$1({element:null,scrollContainers:null,resizeObserver:null,lastBounds:o}),p=r?typeof r=="number"?r:r.scroll:null,w=r?typeof r=="number"?r:r.resize:null,v=t._$1(!1);t.p(()=>(v.current=!0,()=>void(v.current=!1)));const[h,k,y]=t.F(()=>{const g=()=>{if(!d.current.element)return;const{left:M,top:$,width:L,height:se,bottom:te,right:he,x:q,y:X}=d.current.element.getBoundingClientRect(),j={left:M,top:$,width:L,height:se,bottom:te,right:he,x:q,y:X};d.current.element instanceof HTMLElement&&a&&(j.height=d.current.element.offsetHeight,j.width=d.current.element.offsetWidth),Object.freeze(j),v.current&&!Cr(d.current.lastBounds,j)&&u(d.current.lastBounds=j)};return[g,w?lt(g,w):g,p?lt(g,p):g]},[u,a,p,w]);function A(){d.current.scrollContainers&&(d.current.scrollContainers.forEach(g=>g.removeEventListener("scroll",y,!0)),d.current.scrollContainers=null),d.current.resizeObserver&&(d.current.resizeObserver.disconnect(),d.current.resizeObserver=null)}function S(){d.current.element&&(d.current.resizeObserver=new i(y),d.current.resizeObserver.observe(d.current.element),n&&d.current.scrollContainers&&d.current.scrollContainers.forEach(g=>g.addEventListener("scroll",y,{capture:!0,passive:!0})))}const E=g=>{!g||g===d.current.element||(A(),d.current.element=g,d.current.scrollContainers=Ft(g),S())};return kr(y,!!n),_r(k),t.p(()=>{A(),S()},[n,y,k]),t.p(()=>A,[]),[E,o,h]}function _r(e){t.p(()=>{const r=e;return window.addEventListener("resize",r),()=>void window.removeEventListener("resize",r)},[e])}function kr(e,r){t.p(()=>{if(r){const n=e;return window.addEventListener("scroll",n,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",n,!0)}},[e,r])}function Ft(e){const r=[];if(!e||e===document.body)return r;const{overflow:n,overflowX:s,overflowY:a}=window.getComputedStyle(e);return[n,s,a].some(i=>i==="auto"||i==="scroll")&&r.push(e),[...r,...Ft(e.parentElement)]}const Sr=["x","y","top","bottom","left","right","width","height"],Cr=(e,r)=>Sr.every(n=>e[n]===r[n]),oe=({class:e,...r})=>{const{t:n}=t.useTranslation();return t.o("button",{class:t.clsx("bg-accent-9 active:bg-accent-10 pointer-coarse:touch-hitbox fr flex-shrink-0 rounded-full p-2 text-white transition-all disabled:cursor-not-allowed disabled:opacity-50",e),type:"submit",...r,children:t.o("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[t.o("title",{children:n("send")}),t.o("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),t.o("path",{d:"M8 4V13"})]})})},Er=25,qe=t.a({instant:()=>{},smooth:()=>{}}),P={onSubmitSuccessFn$:t.a(()=>{}),isBotTyping$:t.a(!1),scrollToEnd:{instant:()=>qe.value.instant(),smooth:()=>qe.value.smooth()}},Ar=()=>{const e=t._$1(null);t.y(()=>{qe.value={instant:()=>{var n;return(n=e.current)==null?void 0:n.scrollTo({top:e.current.scrollHeight,behavior:"instant"})},smooth:()=>{e.current&&e.current.scrollHeight-e.current.scrollTop<=e.current.clientHeight*2&&e.current.scrollTo({top:e.current.scrollHeight,behavior:"smooth"})}}},[e]);const r=t.F(()=>({addToSubmissions:(s,a)=>t.store.setSubmission(s,a),send:async({message:s,signal:a,groupId:i})=>{if(await t.N(s).with({author:"bot",type:"text"},async o=>{if(a!=null&&a.aborted)throw new t.AbortedError;P.isBotTyping$.value=!0;const u=Math.min(Math.max(20,o.text.length),100)*Er;await new Promise(d=>setTimeout(d,u,{signal:a})),P.isBotTyping$.value=!1}).otherwise(async()=>{}),a!=null&&a.aborted)throw new t.AbortedError;t.store.addMessage(s,i)},input:({input:s,signal:a})=>{if(a!=null&&a.aborted)throw new t.AbortedError;return t.store.setInput(s),new Promise(i=>{const o=u=>{if(a!=null&&a.aborted)throw new t.AbortedError;t.store.setInput(void 0),s.key&&t.store.setSubmission(s.key,u),i(u)};P.onSubmitSuccessFn$.value=o})}}),[]);return{chatRef:e,chatService:r}},fe=({error:e})=>!e||!e.message?null:t.o("div",{role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full px-2 py-2",children:[t.o("svg",{class:"text-error-9 h-4 w-4",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.o("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),t.o("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),t.o("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),t.o("p",{class:"truncate pr-1 text-sm",children:e.message})]}),le=({class:e,...r})=>{const{t:n}=t.useTranslation();return t.o("button",{type:"button",class:t.clsx("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),...r,children:[t.o("svg",{"aria-hidden":!0,class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",children:[t.o("title",{children:n("skip")}),t.o("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),t.o("path",{d:"M13.25 4.5V8.25H9.5"})]}),n("skip")]})},Ke={Afghanistan:"93",Albania:"355",Algeria:"213","American Samoa":"1 684",Andorra:"376",Angola:"244",Anguilla:"1 264",Antarctica:"672","Antigua and Barbuda":"1 268",Argentina:"54",Armenia:"374",Aruba:"297",Australia:"61",Austria:"43",Azerbaijan:"994",Bahrain:"973",Bangladesh:"880",Barbados:"1 246",Belarus:"375",Belgium:"32",Belize:"501",Benin:"229",Bermuda:"1 441",Bhutan:"975",Bolivia:"591","Bosnia and Herzegovina":"387",Botswana:"267","Bouvet Island":"47",Brazil:"55","British Indian Ocean Territory":"246","British Virgin Islands":"1 284",Brunei:"673",Bulgaria:"359","Burkina Faso":"226",Burundi:"257","Cabo Verde":"238",Cambodia:"855",Cameroon:"237",Canada:"1","Caribbean Netherlands":"599","Cayman Islands":"1 345","Central African Republic":"236",Chad:"235",Chile:"56",China:"86","Christmas Island":"61","Cocos (Keeling) Islands":"61",Colombia:"57",Comoros:"269","Cook Islands":"682","Costa Rica":"506",Croatia:"385",Cuba:"53",Curaçao:"599",Cyprus:"357",Czechia:"420","Côte d'Ivoire":"225","Democratic Republic of the Congo":"243",Denmark:"45",Djibouti:"253","Dominican Republic":"1 809",Ecuador:"593",Egypt:"20","El Salvador":"503","Equatorial Guinea":"240",Eritrea:"291",Estonia:"372",Eswatini:"268",Ethiopia:"251","Falkland Islands (Islas Malvinas)":"500","Faroe Islands":"298",Fiji:"679",Finland:"358",France:"33","French Guiana":"594","French Polynesia":"689","French Southern and Antarctic Lands":"262",Gabon:"241",Georgia:"995",Germany:"49",Ghana:"233",Gibraltar:"350",Greece:"30",Greenland:"299",Grenada:"1 473",Guadeloupe:"590",Guam:"1 671",Guatemala:"502",Guernsey:"44",Guinea:"224","Guinea-Bissau":"245",Guyana:"592",Haiti:"509",Honduras:"504","Hong Kong":"852",Hungary:"36",Iceland:"354",India:"91",Indonesia:"62",Iran:"98",Iraq:"964",Ireland:"353","Isle of Man":"44",Israel:"972",Italy:"39",Jamaica:"1 876",Japan:"81",Jersey:"44",Jordan:"962",Kazakhstan:"7",Kenya:"254",Kiribati:"686",Kosovo:"383",Kuwait:"965",Kyrgyzstan:"996",Laos:"856",Latvia:"371",Lebanon:"961",Lesotho:"266",Liberia:"231",Libya:"218",Liechtenstein:"423",Lithuania:"370",Luxembourg:"352",Macao:"853",Madagascar:"261",Malawi:"265",Malaysia:"60",Maldives:"960",Mali:"223",Malta:"356","Marshall Islands":"692",Martinique:"596",Mauritania:"222",Mauritius:"230",Mayotte:"262",Mexico:"52",Micronesia:"691",Moldova:"373",Monaco:"377",Mongolia:"976",Montenegro:"382",Montserrat:"1 664",Morocco:"212",Mozambique:"258","Myanmar (Burma)":"95",Namibia:"264",Nauru:"674",Nepal:"977",Netherlands:"31","New Caledonia":"687","New Zealand":"64",Nicaragua:"505",Niger:"227",Nigeria:"234",Niue:"683","Norfolk Island":"672","North Korea":"850","North Macedonia":"389","Northern Mariana Islands":"1 670",Norway:"47",Oman:"968",Pakistan:"92",Palau:"680",Palestine:"970",Panama:"507","Papua New Guinea":"675",Paraguay:"595",Peru:"51",Philippines:"63","Pitcairn Islands":"64",Poland:"48",Portugal:"351","Puerto Rico":"1 787",Qatar:"974",Romania:"40",Russia:"7",Rwanda:"250",Réunion:"262","Saint Barthélemy":"590","Saint Helena, Ascension and Tristan da Cunha":"290","Saint Kitts and Nevis":"1 869","Saint Lucia":"1 758","Saint Martin":"590","Saint Pierre and Miquelon":"508","Saint Vincent and the Grenadines":"1 784",Samoa:"685","San Marino":"378","Saudi Arabia":"966",Senegal:"221",Serbia:"381",Seychelles:"248","Sierra Leone":"232",Singapore:"65","Sint Maarten":"1 721",Slovakia:"421",Slovenia:"386","Solomon Islands":"677",Somalia:"252","South Africa":"27","South Georgia and the South Sandwich Islands":"500","South Korea":"82","South Sudan":"211",Spain:"34","Sri Lanka":"94",Sudan:"249",Suriname:"597","Svalbard and Jan Mayen":"47",Sweden:"46",Switzerland:"41",Syria:"963","São Tomé and Príncipe":"239",Taiwan:"886",Tajikistan:"992",Tanzania:"255",Thailand:"66","The Bahamas":"1 242","The Gambia":"220","Timor-Leste":"670",Togo:"228",Tokelau:"690",Tonga:"676","Trinidad and Tobago":"1 868",Tunisia:"216",Turkmenistan:"993","Turks and Caicos Islands":"1 649",Tuvalu:"688",Türkiye:"90","U.S. Virgin Islands":"1 340",Uganda:"256",Ukraine:"380","United Arab Emirates":"971","United Kingdom":"44","United States":"1","United States Minor Outlying Islands":"1",Uruguay:"598",Uzbekistan:"998",Vanuatu:"678","Vatican City":"379",Venezuela:"58",Vietnam:"84","Wallis and Futuna":"681","Western Sahara":"212",Yemen:"967",Zambia:"260",Zimbabwe:"263","Åland Islands":"358"},ve=t.cva("outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest py-1 text-base outline outline-2 transition-all",{variants:{optional:{true:"pr-16 pl-3",false:"pl-3 pr-3"}},defaultVariants:{optional:!1}}),Tr="https://api.mapbox.com/search/searchbox/v1/suggest",Vr="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",Mr=e=>atob(e).split("").reverse().join(""),Y=t.object({name:t.string()}),Fr=t.object({suggestions:t.array(t.object({full_address:t.optional(t.string()),place_formatted:t.optional(t.string()),name:t.optional(t.string()),mapbox_id:t.string(),context:t.partial(t.object({address:Y,street:Y,neighborhood:Y,locality:Y,district:Y,place:Y,region:Y,postcode:Y,country:Y}))}))}),Ir=({logger:e,t:r})=>t.F(()=>{var s;const n=(s=t.store.current$.peek().flow)==null?void 0:s.data.flowSessionId;return n?{enabled:!0,getPredictions:async a=>{var v;const i=new URL(Tr);i.searchParams.set("q",a),i.searchParams.set("session_token",n);const o=(v=t.store.current$.peek().flow)==null?void 0:v.locationOrigin;o&&o.lat!==void 0&&o.lng!==void 0&&o.lat>=-90&&o.lat<=90&&o.lng>=-180&&o.lng<=180&&i.searchParams.set("proximity",`${o.lng},${o.lat}`),i.searchParams.set("access_token",Mr(Vr));const d=await fetch(i);if(!d.ok)return e.error("Failed to get address details",d),{ok:!1,error:r("address_error")};const p=t.safeParse(Fr,await d.json());if(p.success===!1)return e.error("Failed to parse address details",p.issues),{ok:!1,error:r("address_error")};const{suggestions:w}=p.output;return{ok:!0,data:w.map(h=>{var k,y,A,S,E,g,M,$,L;return{label:h.full_address??h.place_formatted??h.name??h.mapbox_id,id:h.mapbox_id,address:{line1:((k=h.context.address)==null?void 0:k.name)??((y=h.context.street)==null?void 0:y.name),line2:void 0,line3:((A=h.context.neighborhood)==null?void 0:A.name)??((S=h.context.locality)==null?void 0:S.name),city:((E=h.context.place)==null?void 0:E.name)??((g=h.context.district)==null?void 0:g.name),state:(M=h.context.region)==null?void 0:M.name,postcode:($=h.context.postcode)==null?void 0:$.name,country:(L=h.context.country)==null?void 0:L.name}}})}}}:{enabled:!1}},[e,r]),ut=e=>{const{t:r}=t.useTranslation();return t.o("button",{type:"button",class:"text-neutral-10 hover:bg-neutral-4 hover:text-neutral-12 hover:border-neutral-5 flex items-center gap-1 rounded-[18px] border border-solid border-transparent px-3 py-1 pl-1.5 text-sm transition-colors",...e,children:[t.o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",stroke:"currentColor","stroke-width":"1.5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.o("path",{d:"M10 3L5 8L10 13"})}),t.o("span",{children:r("back")})]})},Lr=({input:e,onSubmitSuccess:r,logger:n})=>{const{t:s}=t.useTranslation(),[a,i]=t.h(),[o,u]=t.h([]),{enabled:d,getPredictions:p}=Ir({logger:n,t:s}),[w,v]=t.h(d?"query":"manual"),[h,k]=t.h(""),[y,A]=t.h(),S=E=>{t.invariant(d,"Query state should not be enabled"),E=E.trim(),E!==(h==null?void 0:h.trim())&&(k(E),E===""&&u([]),A(void 0),p(E).then(g=>{if(g.ok===!1){u([]),A(g.error);return}u(g.data)}))};switch(w){case"query":return t.invariant(d,"Query state should not be enabled"),t.o(Nr,{input:e,onSkip:()=>r(null),onAddressSelect:E=>{if(E===""){i(void 0),v("manual");return}const g=o.find(M=>M.id===E);g&&(i(g.address),v("details"))},onAddressSearch:E=>{S(E)},suggestions:o,query:h,error:y});case"details":return t.invariant(a!==void 0),t.o(dt,{input:e,logger:n,onSubmitSuccess:r,addressFields:a,actions:t.o(ut,{onClick:()=>{v("query")}})});case"manual":return t.o(dt,{logger:n,input:e,onSubmitSuccess:r,addressFields:{},actions:d?t.o(ut,{onClick:()=>{v("query")}}):void 0})}},Nr=({input:e,onSkip:r,suggestions:n,onAddressSelect:s,query:a,onAddressSearch:i,error:o})=>{const{t:u}=t.useTranslation(),d=t._$1(null);return t.y(()=>{d.current&&(d.current.focus(),d.current.select())},[]),t.o(t.k,{children:[t.o("form",{noValidate:!0,onSubmit:p=>{p.preventDefault();const v=new FormData(p.currentTarget).get("address");typeof v=="string"&&i(v)},class:"flex gap-1 p-2.5",children:[t.o("div",{class:"group relative flex-1",children:[t.o("input",{ref:d,name:"address",id:"chat-address",autocomplete:"address-line1 country-name postal-code",autoFocus:!0,placeholder:e.config.placeholder||u("address_search"),defaultValue:a,class:ve({optional:!!e.config.optional,className:"w-full rounded-full"})}),t.o("button",{type:"submit",class:"touch-hitbox text-neutral-12 hover:bg-neutral-3 fr absolute bottom-0 right-0 top-0 flex cursor-pointer items-center gap-1 rounded-full px-3 transition-all",children:t.o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.o("g",{id:"inploi",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",strokeWidth:"1.5",children:[t.o("circle",{cx:"7",cy:"7",r:"4"}),t.o("path",{d:"M10 10L13 13"})]}),t.o("span",{class:"sr-only",children:u("search")})]})})]}),e.config.optional&&t.o(le,{class:"",onClick:r})]}),o?t.o(fe,{error:{message:o}}):null,t.o("ul",{children:[n.map(p=>t.o("li",{children:t.o("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{s(p.id)},children:[t.o("span",{class:"flex-grow",children:p.label}),t.o("svg",{class:"flex-none",width:"16",height:"16",viewBox:"0 0 16 16",stroke:"currentColor","stroke-width":"1.5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.o("path",{d:"M6 3L11 8L6 13"})})]})},p.id)),t.o("li",{children:t.o("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{s("")},children:t.o("span",{class:"flex-grow",children:u("address_manual")})})},"")]})]})},ct=["line1","line2","line3","city","state","postcode","country"],dt=({addressFields:e,onSubmitSuccess:r,actions:n,input:s})=>{const a=t._$1(null);t.y(()=>{if(a.current){const u=a.current.querySelector("input");u&&(u.focus(),u.select())}},[]);const i=Object.keys(Ke),{t:o}=t.useTranslation();return t.o("form",{class:"bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",onSubmit:u=>{const d=new FormData(u.currentTarget),p=Object.fromEntries(d.entries());r({type:"address",value:p})},children:[t.o("div",{class:"bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",ref:a,children:ct.map((u,d)=>{const p=`isdk_${u}`,w=s.config.keys[u];return w?t.o(t.k,{children:[t.o("label",{for:p,class:"text-neutral-9 [&:has(+*>input:focus)]:text-neutral-11 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",children:o(u)}),t.o("div",{class:"flex flex-col items-stretch gap-1.5",children:[u==="country"?t.o("div",{class:"relative",children:[t.o("select",{class:"text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",name:w,id:p,defaultValue:e[u],required:!0,children:[e.country&&!i.includes(e.country)?t.o("option",{value:e[u],children:e[u]}):t.o("option",{value:"",children:o("select_country")}),i.map(v=>t.o("option",{value:v,children:v},v))]}),t.o("svg",{class:"text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",width:"16",height:"16",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.o("path",{d:"M4 6.5L8 10.5L12 6.5"})})]}):t.o("input",{autoFocus:d===0?!0:void 0,class:"text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 flex-1 rounded-lg border-solid bg-transparent px-3 py-1.5 text-base transition-colors autofill:shadow-[inset_0_0_0_1000px_hsl(210_16.7%_97.6%)] focus:outline-none",name:w,id:p,defaultValue:e[u],required:!0}),d===ct.length-1?t.o("hr",{class:"m-0 w-full border-b border-b-transparent"}):t.o("hr",{class:"border-b-neutral-5 m-0 w-full border-b border-solid"})]})]}):null})}),t.o("div",{class:"flex w-full flex-1 ",children:[t.o("div",{class:"flex-grow",children:n}),t.o(oe,{class:"flex items-center justify-center"})]})]})},Ge=()=>{const e=t._$1(null);return t.p(()=>{var r;(r=e.current)==null||r.focus()},[]),e},It=["true","false"],Rr=t.picklist(It),Dr="answer",Lt="flex items-center gap-2 p-2.5",Nt=t.k$1(({label:e,...r},n)=>t.o("button",{class:"bg-lowest ease-expo-out ring-divider text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block w-full overflow-hidden rounded-2xl px-2.5 py-2.5 ring-2 transition-all selection:bg-transparent",...r,ref:n,children:t.o("p",{class:"truncate text-center text-base",children:e})})),Or=({input:e,onSubmitSuccess:r})=>{const n=Ge();return t.o("form",{noValidate:!0,class:"",onSubmit:s=>{s.preventDefault();const a=t.getFormSubmitter(s).value,i=t.parse(Rr,a);r({type:"boolean",value:i==="true"})},children:[t.o("ul",{class:Lt,children:It.map((s,a)=>t.o("li",{class:"flex-1",children:t.o(Nt,{ref:a===0?n:null,type:"submit",name:Dr,value:s,label:e.config.labels[s]},s)}))}),e.config.optional&&t.o("div",{class:"px-2 pb-2",children:t.o(le,{class:"w-full",type:"button",onClick:()=>r(null)})})]})},Br=e=>new Promise((r,n)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>s.result?r(s.result.toString()):n("No result from reader"),s.onerror=n}),$r=e=>e.reduce((r,n)=>r+n.sizeKb,0),Pr=t.isSubmissionOfType("file"),ft=3,jr=({file:e,class:r,...n})=>{const s=e.name.split(".").pop(),a=e.name.replace(new RegExp(`.${s}$`),"");return t.o("div",{class:t.clsx("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",r),...n,children:[t.o("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[t.o("span",{class:"block truncate",children:a}),t.o("span",{children:[".",s]})]}),t.o("p",{"aria-label":"File size",class:"text-accent-11",children:t.kbToReadableSize(e.sizeKb)})]})},ht=({class:e,...r})=>t.o("li",{class:t.clsx("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...r}),Rt=e=>{const r=e.split(".").pop();if(!r)throw new Error("No file extension found");return r?"."+r:""},zr=({allowedExtensions:e,files:r})=>{const n=e.map(s=>s.toLowerCase());return r.every(s=>n.includes(Rt(s.name).toLowerCase()))},Ur=(e,r)=>{const n=Rt(e);return`${e.replace(new RegExp(`${n}$`),"").slice(0,r)}${n}`},qr=({input:e,onSubmitSuccess:r})=>{var v;const n=(v=t.store.current$.value.flow)==null?void 0:v.data.submissions[e.key],[s,a]=t.h(Pr(n)?n.value:[]),[i,o]=t.h(),u=s.length-ft,d=$r(s),p=Ge(),{t:w}=t.useTranslation();return t.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:h=>(h.preventDefault(),o(void 0),s.length===0?o({type:"required",message:w("validation_file")}):e.config.extensions.length>0&&!zr({allowedExtensions:e.config.extensions,files:s})?o({type:"validate",message:`${w("validation_file_ext",{ext:e.config.extensions.join(", ")})}`}):e.config.fileSizeLimitKib&&d>e.config.fileSizeLimitKib?o({type:"max",message:`File size exceeds limit of ${t.kbToReadableSize(e.config.fileSizeLimitKib)}`}):e.config.allowMultiple===!1&&s.length>1?o({type:"invalid",message:w("validation_file_max",{count:1})}):r({type:"file",value:s})),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("label",{ref:p,for:"dropzone-file",class:"border-neutral-8 bg-neutral-2 flex h-48 w-full cursor-pointer flex-col items-center justify-center overflow-hidden rounded-2xl border border-dashed p-4",children:[s.length>0?t.o(t.k,{children:[t.o("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[s.slice(0,ft).map(h=>{const k=h.name.split(".").pop(),y=h.name.replace(new RegExp(`.${k}$`),"");return t.o(ht,{class:"flex overflow-hidden",children:[t.o("span",{class:"block truncate",children:y}),t.o("span",{children:[".",k]})]})}),u>0?t.o(ht,{children:["+",u," file",u!==1?"s":""]}):null]}),t.o("p",{class:"text-neutral-11 text-xs",children:[t.kbToReadableSize(d)," ",s.length>1?"total":""]})]}):t.o("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[t.o("header",{class:"flex flex-col items-center gap-0",children:[t.o("svg",{class:"text-neutral-11 mb-1 h-8 w-8","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 16",children:t.o("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"})}),t.o("p",{class:"text-neutral-12 tracking-[-0.01em]",children:w("upload_file",{count:e.config.allowMultiple?2:1})}),e.config.fileSizeLimitKib?t.o("p",{class:"text-neutral-10 text-xs",children:["(",w("file_max_size",{size:t.kbToReadableSize(e.config.fileSizeLimitKib)}),")"]}):null]}),t.o("aside",{class:"flex flex-col items-center gap-2",children:[t.o("p",{id:"accepted-filetypes",class:"sr-only",children:w("file_extensions")}),t.o("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(h=>t.o("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:h.replace(".","")}))})]})]}),t.o("input",{id:"dropzone-file",onInput:async h=>{t.invariant(h.target instanceof HTMLInputElement);const k=h.target.files?Array.from(h.target.files):[],y=await Promise.allSettled(k.map(async S=>{const E=await Br(S);return{name:Ur(S.name,42),data:E,sizeKb:S.size/1e3}}));if(y.some(({status:S})=>S==="rejected"))return o({type:"invalid",message:"Invalid file"});const A=y.map(S=>S.status==="fulfilled"?S.value:null).filter(Boolean);a(A)},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),t.o("div",{class:"flex h-full flex-col items-center gap-2",children:[t.o(oe,{disabled:s.length===0}),e.config.optional&&t.o(le,{onClick:()=>r(null)})]})]}),t.o(fe,{error:i})]})};var xe=e=>e.type==="checkbox",de=e=>e instanceof Date,z=e=>e==null;const Dt=e=>typeof e=="object";var O=e=>!z(e)&&!Array.isArray(e)&&Dt(e)&&!de(e),Kr=e=>O(e)&&e.target?xe(e.target)?e.target.checked:e.target.value:e,Gr=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Hr=(e,r)=>e.has(Gr(r)),Wr=e=>{const r=e.constructor&&e.constructor.prototype;return O(r)&&r.hasOwnProperty("isPrototypeOf")},He=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ee(e){let r;const n=Array.isArray(e);if(e instanceof Date)r=new Date(e);else if(e instanceof Set)r=new Set(e);else if(!(He&&(e instanceof Blob||e instanceof FileList))&&(n||O(e)))if(r=n?[]:{},!n&&!Wr(e))r=e;else for(const s in e)e.hasOwnProperty(s)&&(r[s]=ee(e[s]));else return e;return r}var we=e=>Array.isArray(e)?e.filter(Boolean):[],R=e=>e===void 0,x=(e,r,n)=>{if(!r||!O(e))return n;const s=we(r.split(/[,[\].]+?/)).reduce((a,i)=>z(a)?a:a[i],e);return R(s)||s===e?R(e[r])?n:e[r]:s},re=e=>typeof e=="boolean";const pt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},H={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Q={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};t.Cn.createContext(null);var Jr=(e,r,n,s=!0)=>{const a={defaultValues:r._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return r._proxyFormState[o]!==H.all&&(r._proxyFormState[o]=!s||H.all),n&&(n[o]=!0),e[o]}});return a},G=e=>O(e)&&!Object.keys(e).length,Zr=(e,r,n,s)=>{n(e);const{name:a,...i}=e;return G(i)||Object.keys(i).length>=Object.keys(r).length||Object.keys(i).find(o=>r[o]===(!s||H.all))},Be=e=>Array.isArray(e)?e:[e];function Xr(e){const r=t.Cn.useRef(e);r.current=e,t.Cn.useEffect(()=>{const n=!e.disabled&&r.current.subject&&r.current.subject.subscribe({next:r.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var J=e=>typeof e=="string",Yr=(e,r,n,s,a)=>J(e)?(s&&r.watch.add(e),x(n,e,a)):Array.isArray(e)?e.map(i=>(s&&r.watch.add(i),x(n,i))):(s&&(r.watchAll=!0),n),We=e=>/^\w*$/.test(e),Ot=e=>we(e.replace(/["|']|\]/g,"").split(/\.|\[/));function F(e,r,n){let s=-1;const a=We(r)?[r]:Ot(r),i=a.length,o=i-1;for(;++s<i;){const u=a[s];let d=n;if(s!==o){const p=e[u];d=O(p)||Array.isArray(p)?p:isNaN(+a[s+1])?{}:[]}e[u]=d,e=e[u]}return e}var Bt=(e,r,n,s,a)=>r?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[s]:a||!0}}:{},mt=e=>({isOnSubmit:!e||e===H.onSubmit,isOnBlur:e===H.onBlur,isOnChange:e===H.onChange,isOnAll:e===H.all,isOnTouch:e===H.onTouched}),gt=(e,r,n)=>!n&&(r.watchAll||r.watch.has(e)||[...r.watch].some(s=>e.startsWith(s)&&/^\.\w+/.test(e.slice(s.length))));const Se=(e,r,n,s)=>{for(const a of n||Object.keys(e)){const i=x(e,a);if(i){const{_f:o,...u}=i;if(o){if(o.refs&&o.refs[0]&&r(o.refs[0],a)&&!s)break;if(o.ref&&r(o.ref,o.name)&&!s)break}else O(u)&&Se(u,r)}}};var Qr=(e,r,n)=>{const s=we(x(e,n));return F(s,"root",r[n]),F(e,n,s),e},Je=e=>e.type==="file",ne=e=>typeof e=="function",Ee=e=>{if(!He)return!1;const r=e?e.ownerDocument:0;return e instanceof(r&&r.defaultView?r.defaultView.HTMLElement:HTMLElement)},Ce=e=>J(e),Ze=e=>e.type==="radio",Ae=e=>e instanceof RegExp;const bt={value:!1,isValid:!1},yt={value:!0,isValid:!0};var $t=e=>{if(Array.isArray(e)){if(e.length>1){const r=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:r,isValid:!!r.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!R(e[0].attributes.value)?R(e[0].value)||e[0].value===""?yt:{value:e[0].value,isValid:!0}:yt:bt}return bt};const vt={isValid:!1,value:null};var Pt=e=>Array.isArray(e)?e.reduce((r,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:r,vt):vt;function xt(e,r,n="validate"){if(Ce(e)||Array.isArray(e)&&e.every(Ce)||re(e)&&!e)return{type:n,message:Ce(e)?e:"",ref:r}}var ce=e=>O(e)&&!Ae(e)?e:{value:e,message:""},wt=async(e,r,n,s,a)=>{const{ref:i,refs:o,required:u,maxLength:d,minLength:p,min:w,max:v,pattern:h,validate:k,name:y,valueAsNumber:A,mount:S,disabled:E}=e._f,g=x(r,y);if(!S||E)return{};const M=o?o[0]:i,$=V=>{s&&M.reportValidity&&(M.setCustomValidity(re(V)?"":V||""),M.reportValidity())},L={},se=Ze(i),te=xe(i),he=se||te,q=(A||Je(i))&&R(i.value)&&R(g)||Ee(i)&&i.value===""||g===""||Array.isArray(g)&&!g.length,X=Bt.bind(null,y,n,L),j=(V,T,N,U=Q.maxLength,K=Q.minLength)=>{const W=V?T:N;L[y]={type:V?U:K,message:W,ref:i,...X(V?U:K,W)}};if(a?!Array.isArray(g)||!g.length:u&&(!he&&(q||z(g))||re(g)&&!g||te&&!$t(o).isValid||se&&!Pt(o).isValid)){const{value:V,message:T}=Ce(u)?{value:!!u,message:u}:ce(u);if(V&&(L[y]={type:Q.required,message:T,ref:M,...X(Q.required,T)},!n))return $(T),L}if(!q&&(!z(w)||!z(v))){let V,T;const N=ce(v),U=ce(w);if(!z(g)&&!isNaN(g)){const K=i.valueAsNumber||g&&+g;z(N.value)||(V=K>N.value),z(U.value)||(T=K<U.value)}else{const K=i.valueAsDate||new Date(g),W=_e=>new Date(new Date().toDateString()+" "+_e),ae=i.type=="time",pe=i.type=="week";J(N.value)&&g&&(V=ae?W(g)>W(N.value):pe?g>N.value:K>new Date(N.value)),J(U.value)&&g&&(T=ae?W(g)<W(U.value):pe?g<U.value:K<new Date(U.value))}if((V||T)&&(j(!!V,N.message,U.message,Q.max,Q.min),!n))return $(L[y].message),L}if((d||p)&&!q&&(J(g)||a&&Array.isArray(g))){const V=ce(d),T=ce(p),N=!z(V.value)&&g.length>+V.value,U=!z(T.value)&&g.length<+T.value;if((N||U)&&(j(N,V.message,T.message),!n))return $(L[y].message),L}if(h&&!q&&J(g)){const{value:V,message:T}=ce(h);if(Ae(V)&&!g.match(V)&&(L[y]={type:Q.pattern,message:T,ref:i,...X(Q.pattern,T)},!n))return $(T),L}if(k){if(ne(k)){const V=await k(g,r),T=xt(V,M);if(T&&(L[y]={...T,...X(Q.validate,T.message)},!n))return $(T.message),L}else if(O(k)){let V={};for(const T in k){if(!G(V)&&!n)break;const N=xt(await k[T](g,r),M,T);N&&(V={...N,...X(T,N.message)},$(N.message),n&&(L[y]=V))}if(!G(V)&&(L[y]={ref:M,...V},!n))return L}}return $(!0),L};function en(e,r){const n=r.slice(0,-1).length;let s=0;for(;s<n;)e=R(e)?s++:e[r[s++]];return e}function tn(e){for(const r in e)if(e.hasOwnProperty(r)&&!R(e[r]))return!1;return!0}function B(e,r){const n=Array.isArray(r)?r:We(r)?[r]:Ot(r),s=n.length===1?e:en(e,n),a=n.length-1,i=n[a];return s&&delete s[i],a!==0&&(O(s)&&G(s)||Array.isArray(s)&&tn(s))&&B(e,n.slice(0,-1)),e}function $e(){let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}}var Te=e=>z(e)||!Dt(e);function ie(e,r){if(Te(e)||Te(r))return e===r;if(de(e)&&de(r))return e.getTime()===r.getTime();const n=Object.keys(e),s=Object.keys(r);if(n.length!==s.length)return!1;for(const a of n){const i=e[a];if(!s.includes(a))return!1;if(a!=="ref"){const o=r[a];if(de(i)&&de(o)||O(i)&&O(o)||Array.isArray(i)&&Array.isArray(o)?!ie(i,o):i!==o)return!1}}return!0}var jt=e=>e.type==="select-multiple",rn=e=>Ze(e)||xe(e),Pe=e=>Ee(e)&&e.isConnected,zt=e=>{for(const r in e)if(ne(e[r]))return!0;return!1};function Ve(e,r={}){const n=Array.isArray(e);if(O(e)||n)for(const s in e)Array.isArray(e[s])||O(e[s])&&!zt(e[s])?(r[s]=Array.isArray(e[s])?[]:{},Ve(e[s],r[s])):z(e[s])||(r[s]=!0);return r}function Ut(e,r,n){const s=Array.isArray(e);if(O(e)||s)for(const a in e)Array.isArray(e[a])||O(e[a])&&!zt(e[a])?R(r)||Te(n[a])?n[a]=Array.isArray(e[a])?Ve(e[a],[]):{...Ve(e[a])}:Ut(e[a],z(r)?{}:r[a],n[a]):n[a]=!ie(e[a],r[a]);return n}var je=(e,r)=>Ut(e,r,Ve(r)),qt=(e,{valueAsNumber:r,valueAsDate:n,setValueAs:s})=>R(e)?e:r?e===""?NaN:e&&+e:n&&J(e)?new Date(e):s?s(e):e;function ze(e){const r=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):r.disabled))return Je(r)?r.files:Ze(r)?Pt(e.refs).value:jt(r)?[...r.selectedOptions].map(({value:n})=>n):xe(r)?$t(e.refs).value:qt(R(r.value)?e.ref.value:r.value,e)}var nn=(e,r,n,s)=>{const a={};for(const i of e){const o=x(r,i);o&&F(a,i,o._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:s}},ge=e=>R(e)?e:Ae(e)?e.source:O(e)?Ae(e.value)?e.value.source:e.value:e,sn=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function _t(e,r,n){const s=x(e,n);if(s||We(n))return{error:s,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),o=x(r,i),u=x(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(u&&u.type)return{name:i,error:u};a.pop()}return{name:n}}var an=(e,r,n,s,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(r||e):(n?s.isOnBlur:a.isOnBlur)?!e:(n?s.isOnChange:a.isOnChange)?e:!0,on=(e,r)=>!we(x(e,r)).length&&B(e,r);const ln={mode:H.onSubmit,reValidateMode:H.onChange,shouldFocusError:!0};function un(e={},r){let n={...ln,...e},s={submitCount:0,isDirty:!1,isLoading:ne(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},a={},i=O(n.defaultValues)||O(n.values)?ee(n.defaultValues||n.values)||{}:{},o=n.shouldUnregister?{}:ee(i),u={action:!1,mount:!1,watch:!1},d={mount:new Set,unMount:new Set,array:new Set,watch:new Set},p,w=0;const v={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={values:$e(),array:$e(),state:$e()},k=e.resetOptions&&e.resetOptions.keepDirtyValues,y=mt(n.mode),A=mt(n.reValidateMode),S=n.criteriaMode===H.all,E=l=>c=>{clearTimeout(w),w=setTimeout(l,c)},g=async l=>{if(v.isValid||l){const c=n.resolver?G((await q()).errors):await j(a,!0);c!==s.isValid&&h.state.next({isValid:c})}},M=l=>v.isValidating&&h.state.next({isValidating:l}),$=(l,c=[],f,_,b=!0,m=!0)=>{if(_&&f){if(u.action=!0,m&&Array.isArray(x(a,l))){const C=f(x(a,l),_.argA,_.argB);b&&F(a,l,C)}if(m&&Array.isArray(x(s.errors,l))){const C=f(x(s.errors,l),_.argA,_.argB);b&&F(s.errors,l,C),on(s.errors,l)}if(v.touchedFields&&m&&Array.isArray(x(s.touchedFields,l))){const C=f(x(s.touchedFields,l),_.argA,_.argB);b&&F(s.touchedFields,l,C)}v.dirtyFields&&(s.dirtyFields=je(i,o)),h.state.next({name:l,isDirty:T(l,c),dirtyFields:s.dirtyFields,errors:s.errors,isValid:s.isValid})}else F(o,l,c)},L=(l,c)=>{F(s.errors,l,c),h.state.next({errors:s.errors})},se=(l,c,f,_)=>{const b=x(a,l);if(b){const m=x(o,l,R(f)?x(i,l):f);R(m)||_&&_.defaultChecked||c?F(o,l,c?m:ze(b._f)):K(l,m),u.mount&&g()}},te=(l,c,f,_,b)=>{let m=!1,C=!1;const I={name:l};if(!f||_){v.isDirty&&(C=s.isDirty,s.isDirty=I.isDirty=T(),m=C!==I.isDirty);const D=ie(x(i,l),c);C=x(s.dirtyFields,l),D?B(s.dirtyFields,l):F(s.dirtyFields,l,!0),I.dirtyFields=s.dirtyFields,m=m||v.dirtyFields&&C!==!D}if(f){const D=x(s.touchedFields,l);D||(F(s.touchedFields,l,f),I.touchedFields=s.touchedFields,m=m||v.touchedFields&&D!==f)}return m&&b&&h.state.next(I),m?I:{}},he=(l,c,f,_)=>{const b=x(s.errors,l),m=v.isValid&&re(c)&&s.isValid!==c;if(e.delayError&&f?(p=E(()=>L(l,f)),p(e.delayError)):(clearTimeout(w),p=null,f?F(s.errors,l,f):B(s.errors,l)),(f?!ie(b,f):b)||!G(_)||m){const C={..._,...m&&re(c)?{isValid:c}:{},errors:s.errors,name:l};s={...s,...C},h.state.next(C)}M(!1)},q=async l=>n.resolver(o,n.context,nn(l||d.mount,a,n.criteriaMode,n.shouldUseNativeValidation)),X=async l=>{const{errors:c}=await q(l);if(l)for(const f of l){const _=x(c,f);_?F(s.errors,f,_):B(s.errors,f)}else s.errors=c;return c},j=async(l,c,f={valid:!0})=>{for(const _ in l){const b=l[_];if(b){const{_f:m,...C}=b;if(m){const I=d.array.has(m.name),D=await wt(b,o,S,n.shouldUseNativeValidation&&!c,I);if(D[m.name]&&(f.valid=!1,c))break;!c&&(x(D,m.name)?I?Qr(s.errors,D,m.name):F(s.errors,m.name,D[m.name]):B(s.errors,m.name))}C&&await j(C,c,f)}}return f.valid},V=()=>{for(const l of d.unMount){const c=x(a,l);c&&(c._f.refs?c._f.refs.every(f=>!Pe(f)):!Pe(c._f.ref))&&Ne(l)}d.unMount=new Set},T=(l,c)=>(l&&c&&F(o,l,c),!ie(Xe(),i)),N=(l,c,f)=>Yr(l,d,{...u.mount?o:R(c)?i:J(l)?{[l]:c}:c},f,c),U=l=>we(x(u.mount?o:i,l,e.shouldUnregister?x(i,l,[]):[])),K=(l,c,f={})=>{const _=x(a,l);let b=c;if(_){const m=_._f;m&&(!m.disabled&&F(o,l,qt(c,m)),b=Ee(m.ref)&&z(c)?"":c,jt(m.ref)?[...m.ref.options].forEach(C=>C.selected=b.includes(C.value)):m.refs?xe(m.ref)?m.refs.length>1?m.refs.forEach(C=>(!C.defaultChecked||!C.disabled)&&(C.checked=Array.isArray(b)?!!b.find(I=>I===C.value):b===C.value)):m.refs[0]&&(m.refs[0].checked=!!b):m.refs.forEach(C=>C.checked=C.value===b):Je(m.ref)?m.ref.value="":(m.ref.value=b,m.ref.type||h.values.next({name:l,values:{...o}})))}(f.shouldDirty||f.shouldTouch)&&te(l,b,f.shouldTouch,f.shouldDirty,!0),f.shouldValidate&&Le(l)},W=(l,c,f)=>{for(const _ in c){const b=c[_],m=`${l}.${_}`,C=x(a,m);(d.array.has(l)||!Te(b)||C&&!C._f)&&!de(b)?W(m,b,f):K(m,b,f)}},ae=(l,c,f={})=>{const _=x(a,l),b=d.array.has(l),m=ee(c);F(o,l,m),b?(h.array.next({name:l,values:{...o}}),(v.isDirty||v.dirtyFields)&&f.shouldDirty&&h.state.next({name:l,dirtyFields:je(i,o),isDirty:T(l,m)})):_&&!_._f&&!z(m)?W(l,m,f):K(l,m,f),gt(l,d)&&h.state.next({...s}),h.values.next({name:l,values:{...o}}),!u.mount&&r()},pe=async l=>{const c=l.target;let f=c.name,_=!0;const b=x(a,f),m=()=>c.type?ze(b._f):Kr(l),C=I=>{_=Number.isNaN(I)||I===x(o,f,I)};if(b){let I,D;const ke=m(),ue=l.type===pt.BLUR||l.type===pt.FOCUS_OUT,Zt=!sn(b._f)&&!n.resolver&&!x(s.errors,f)&&!b._f.deps||an(ue,x(s.touchedFields,f),s.isSubmitted,A,y),De=gt(f,d,ue);F(o,f,ke),ue?(b._f.onBlur&&b._f.onBlur(l),p&&p(0)):b._f.onChange&&b._f.onChange(l);const Oe=te(f,ke,ue,!1),Xt=!G(Oe)||De;if(!ue&&h.values.next({name:f,type:l.type,values:{...o}}),Zt)return v.isValid&&g(),Xt&&h.state.next({name:f,...De?{}:Oe});if(!ue&&De&&h.state.next({...s}),M(!0),n.resolver){const{errors:at}=await q([f]);if(C(ke),_){const Yt=_t(s.errors,a,f),it=_t(at,a,Yt.name||f);I=it.error,f=it.name,D=G(at)}}else I=(await wt(b,o,S,n.shouldUseNativeValidation))[f],C(ke),_&&(I?D=!1:v.isValid&&(D=await j(a,!0)));_&&(b._f.deps&&Le(b._f.deps),he(f,D,I,Oe))}},_e=(l,c)=>{if(x(s.errors,c)&&l.focus)return l.focus(),1},Le=async(l,c={})=>{let f,_;const b=Be(l);if(M(!0),n.resolver){const m=await X(R(l)?l:b);f=G(m),_=l?!b.some(C=>x(m,C)):f}else l?(_=(await Promise.all(b.map(async m=>{const C=x(a,m);return await j(C&&C._f?{[m]:C}:C)}))).every(Boolean),!(!_&&!s.isValid)&&g()):_=f=await j(a);return h.state.next({...!J(l)||v.isValid&&f!==s.isValid?{}:{name:l},...n.resolver||!l?{isValid:f}:{},errors:s.errors,isValidating:!1}),c.shouldFocus&&!_&&Se(a,_e,l?b:d.mount),_},Xe=l=>{const c={...i,...u.mount?o:{}};return R(l)?c:J(l)?x(c,l):l.map(f=>x(c,f))},Ye=(l,c)=>({invalid:!!x((c||s).errors,l),isDirty:!!x((c||s).dirtyFields,l),isTouched:!!x((c||s).touchedFields,l),error:x((c||s).errors,l)}),Gt=l=>{l&&Be(l).forEach(c=>B(s.errors,c)),h.state.next({errors:l?s.errors:{}})},Qe=(l,c,f)=>{const _=(x(a,l,{_f:{}})._f||{}).ref;F(s.errors,l,{...c,ref:_}),h.state.next({name:l,errors:s.errors,isValid:!1}),f&&f.shouldFocus&&_&&_.focus&&_.focus()},Ht=(l,c)=>ne(l)?h.values.subscribe({next:f=>l(N(void 0,c),f)}):N(l,c,!0),Ne=(l,c={})=>{for(const f of l?Be(l):d.mount)d.mount.delete(f),d.array.delete(f),c.keepValue||(B(a,f),B(o,f)),!c.keepError&&B(s.errors,f),!c.keepDirty&&B(s.dirtyFields,f),!c.keepTouched&&B(s.touchedFields,f),!n.shouldUnregister&&!c.keepDefaultValue&&B(i,f);h.values.next({values:{...o}}),h.state.next({...s,...c.keepDirty?{isDirty:T()}:{}}),!c.keepIsValid&&g()},et=({disabled:l,name:c,field:f,fields:_,value:b})=>{if(re(l)){const m=l?void 0:R(b)?ze(f?f._f:x(_,c)._f):b;F(o,c,m),te(c,m,!1,!1,!0)}},Re=(l,c={})=>{let f=x(a,l);const _=re(c.disabled);return F(a,l,{...f||{},_f:{...f&&f._f?f._f:{ref:{name:l}},name:l,mount:!0,...c}}),d.mount.add(l),f?et({field:f,disabled:c.disabled,name:l}):se(l,!0,c.value),{..._?{disabled:c.disabled}:{},...n.progressive?{required:!!c.required,min:ge(c.min),max:ge(c.max),minLength:ge(c.minLength),maxLength:ge(c.maxLength),pattern:ge(c.pattern)}:{},name:l,onChange:pe,onBlur:pe,ref:b=>{if(b){Re(l,c),f=x(a,l);const m=R(b.value)&&b.querySelectorAll&&b.querySelectorAll("input,select,textarea")[0]||b,C=rn(m),I=f._f.refs||[];if(C?I.find(D=>D===m):m===f._f.ref)return;F(a,l,{_f:{...f._f,...C?{refs:[...I.filter(Pe),m,...Array.isArray(x(i,l))?[{}]:[]],ref:{type:m.type,name:l}}:{ref:m}}}),se(l,!1,void 0,m)}else f=x(a,l,{}),f._f&&(f._f.mount=!1),(n.shouldUnregister||c.shouldUnregister)&&!(Hr(d.array,l)&&u.action)&&d.unMount.add(l)}}},tt=()=>n.shouldFocusError&&Se(a,_e,d.mount),Wt=l=>{re(l)&&(h.state.next({disabled:l}),Se(a,c=>{c.disabled=l},0,!1))},rt=(l,c)=>async f=>{f&&(f.preventDefault&&f.preventDefault(),f.persist&&f.persist());let _=ee(o);if(h.state.next({isSubmitting:!0}),n.resolver){const{errors:b,values:m}=await q();s.errors=b,_=m}else await j(a);B(s.errors,"root"),G(s.errors)?(h.state.next({errors:{}}),await l(_,f)):(c&&await c({...s.errors},f),tt(),setTimeout(tt)),h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(s.errors),submitCount:s.submitCount+1,errors:s.errors})},Jt=(l,c={})=>{x(a,l)&&(R(c.defaultValue)?ae(l,x(i,l)):(ae(l,c.defaultValue),F(i,l,c.defaultValue)),c.keepTouched||B(s.touchedFields,l),c.keepDirty||(B(s.dirtyFields,l),s.isDirty=c.defaultValue?T(l,x(i,l)):T()),c.keepError||(B(s.errors,l),v.isValid&&g()),h.state.next({...s}))},nt=(l,c={})=>{const f=l?ee(l):i,_=ee(f),b=l&&!G(l)?_:i;if(c.keepDefaultValues||(i=f),!c.keepValues){if(c.keepDirtyValues||k)for(const m of d.mount)x(s.dirtyFields,m)?F(b,m,x(o,m)):ae(m,x(b,m));else{if(He&&R(l))for(const m of d.mount){const C=x(a,m);if(C&&C._f){const I=Array.isArray(C._f.refs)?C._f.refs[0]:C._f.ref;if(Ee(I)){const D=I.closest("form");if(D){D.reset();break}}}}a={}}o=e.shouldUnregister?c.keepDefaultValues?ee(i):{}:ee(b),h.array.next({values:{...b}}),h.values.next({values:{...b}})}d={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!u.mount&&r(),u.mount=!v.isValid||!!c.keepIsValid,u.watch=!!e.shouldUnregister,h.state.next({submitCount:c.keepSubmitCount?s.submitCount:0,isDirty:c.keepDirty?s.isDirty:!!(c.keepDefaultValues&&!ie(l,i)),isSubmitted:c.keepIsSubmitted?s.isSubmitted:!1,dirtyFields:c.keepDirtyValues?s.dirtyFields:c.keepDefaultValues&&l?je(i,l):{},touchedFields:c.keepTouched?s.touchedFields:{},errors:c.keepErrors?s.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?s.isSubmitSuccessful:!1,isSubmitting:!1})},st=(l,c)=>nt(ne(l)?l(o):l,c);return{control:{register:Re,unregister:Ne,getFieldState:Ye,handleSubmit:rt,setError:Qe,_executeSchema:q,_getWatch:N,_getDirty:T,_updateValid:g,_removeUnmounted:V,_updateFieldArray:$,_updateDisabledField:et,_getFieldArray:U,_reset:nt,_resetDefaultValues:()=>ne(n.defaultValues)&&n.defaultValues().then(l=>{st(l,n.resetOptions),h.state.next({isLoading:!1})}),_updateFormState:l=>{s={...s,...l}},_disableForm:Wt,_subjects:h,_proxyFormState:v,get _fields(){return a},get _formValues(){return o},get _state(){return u},set _state(l){u=l},get _defaultValues(){return i},get _names(){return d},set _names(l){d=l},get _formState(){return s},set _formState(l){s=l},get _options(){return n},set _options(l){n={...n,...l}}},trigger:Le,register:Re,handleSubmit:rt,watch:Ht,setValue:ae,getValues:Xe,reset:st,resetField:Jt,clearErrors:Gt,unregister:Ne,setError:Qe,setFocus:(l,c={})=>{const f=x(a,l),_=f&&f._f;if(_){const b=_.refs?_.refs[0]:_.ref;b.focus&&(b.focus(),c.shouldSelect&&b.select())}},getFieldState:Ye}}function Fe(e={}){const r=t.Cn.useRef(),n=t.Cn.useRef(),[s,a]=t.Cn.useState({isDirty:!1,isValidating:!1,isLoading:ne(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:ne(e.defaultValues)?void 0:e.defaultValues});r.current||(r.current={...un(e,()=>a(o=>({...o}))),formState:s});const i=r.current.control;return i._options=e,Xr({subject:i._subjects.state,next:o=>{Zr(o,i._proxyFormState,i._updateFormState,!0)&&a({...i._formState})}}),t.Cn.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),t.Cn.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==s.isDirty&&i._subjects.state.next({isDirty:o})}},[i,s.isDirty]),t.Cn.useEffect(()=>{e.values&&!ie(e.values,n.current)?(i._reset(e.values,i._options.resetOptions),n.current=e.values):i._resetDefaultValues()},[e.values,i]),t.Cn.useEffect(()=>{i._state.mount||(i._updateValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),r.current.formState=Jr(s,i),r.current}var kt=function(e,r,n){if(e&&"reportValidity"in e){var s=x(n,r);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},cn=function(e,r){var n=function(a){var i=r.fields[a];i&&i.ref&&"reportValidity"in i.ref?kt(i.ref,a,e):i.refs&&i.refs.forEach(function(o){return kt(o,a,e)})};for(var s in r.fields)n(s)},dn=function(e,r){r.shouldUseNativeValidation&&cn(e,r);var n={};for(var s in e){var a=x(r.fields,s),i=Object.assign(e[s]||{},{ref:a&&a.ref});if(hn(r.names||Object.keys(e),s)){var o=Object.assign({},fn(x(n,s)));F(o,"root",i),F(n,s,o)}else F(n,s,i)}return n},fn=function(e){return Array.isArray(e)?e.filter(Boolean):[]},hn=function(e,r){return e.some(function(n){return n.startsWith(r+".")})},pn=function(e,r){for(var n={};e.issues.length;){var s=e.issues[0];if(s.path){var a=s.path.map(function(u){return u.key}).join(".");if(n[a]||(n[a]={message:s.message,type:s.validation}),r){var i=n[a].types,o=i&&i[s.validation];n[a]=Bt(a,r,n,s.validation,o?[].concat(o,s.message):s.message)}e.issues.shift()}}return n},Ie=function(e,r,n){return n===void 0&&(n={}),function(s,a,i){try{return Promise.resolve(function(o,u){try{var d=function(){function p(v){return{values:n.raw?s:v,errors:{}}}var w=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},r);return n.mode==="sync"?p(t.parse(e,s,w)):Promise.resolve(t.parseAsync(e,s,w)).then(p)}()}catch(p){return u(p)}return d&&d.then?d.then(void 0,u):d}(0,function(o){if(o instanceof t.ValiError)return{values:{},errors:dn(pn(o,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}}};const St=27,Ct=12,Et=10,mn=t.isSubmissionOfType("enum"),gn=(e,r)=>{const n={min:e.minSelected??0,max:e.maxSelected??e.options.length};return Ie(t.object({checked:t.pipe(t.record(t.string(),t.boolean()),t.transform(s=>Object.entries(s).filter(([a,i])=>i).map(([a,i])=>a)),t.maxLength(n.max,r("validation_multiple_choice_max",{count:n.max})),t.minLength(n.min,r("validation_multiple_choice_min",{count:n.min})))}))},bn=t.k$1(({option:e,...r},n)=>t.o(t.k,{children:[t.o("input",{class:"peer sr-only h-full",type:"checkbox",...r,ref:n}),t.o("label",{class:"bg-lowest hover:bg-neutral-2 active:outline-neutral-8 ease-expo-out outline-divider text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 peer-focus-visible:ring-accent-9 peer-focus-visible:ring-offset-accent-7 block cursor-pointer select-none rounded-2xl px-3 py-1.5 outline outline-1 ring-0 ring-transparent transition-all selection:bg-transparent peer-focus-visible:ring-4",htmlFor:r.id,children:e.label})]})),At=t.cva("gutter-stable flex w-full flex-1 flex-wrap gap-3 overflow-y-auto rounded-xl p-2.5 pr-4",{variants:{variant:{singleOption:"justify-center",booleanLike:Lt}}}),yn=({input:e,onSubmitSuccess:r})=>{var w,v;const n=e.key?(w=t.store.current$.value.flow)==null?void 0:w.data.submissions[e.key]:void 0,s=(e.config.minSelected===1||e.config.minSelected===void 0)&&e.config.maxSelected===1,a=s&&e.config.options.length===2,{t:i}=t.useTranslation(),{register:o,handleSubmit:u,formState:{errors:d}}=Fe({defaultValues:{checked:s?{}:mn(n)?Object.fromEntries(n.value.map(h=>[h,!0])):{}},resolver:gn(e.config,i)}),p=Ge();return a?t.o("ul",{style:{maxHeight:6.5*St+5*Ct+2*Et},class:At({variant:"booleanLike"}),children:e.config.options.map((h,k)=>t.o("li",{class:"flex-1",children:t.o(Nt,{type:"submit",ref:y=>{y&&k===0&&(p.current=y)},label:h.label,value:"true",onClick:()=>r({type:"enum",value:[h.value]})})},h.value))}):t.o("form",{noValidate:!0,onSubmit:h=>u(k=>{const y=k.checked;r({type:"enum",value:y})})(h),children:[t.o("div",{class:"flex items-center gap-1",children:[t.o("ul",{style:{maxHeight:6.5*St+5*Ct+2*Et},class:At({variant:e.config.options.length===1?"singleOption":void 0}),children:e.config.options.map((h,k)=>{const y=`checked.${h.value}`,{ref:A,...S}=o(y);return t.o("li",{class:"relative",children:t.o(bn,{option:h,autoFocus:k===0,ref:E=>{E&&k===0&&(p.current=E),A(E)},id:y,...S,onClick:s?()=>r({type:"enum",value:[h.value]}):void 0})},h.value)})}),t.o("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[s?null:t.o(oe,{}),e.config.minSelected===0&&t.o(le,{type:"button",onClick:()=>r({type:"enum",value:[]})})]})]}),t.o("div",{class:"px-1",children:t.o(fe,{error:(v=d.checked)==null?void 0:v.root})})]})},vn=t.isSubmissionOfType("number"),xn=(e,r)=>{const n=e.min??Number.MIN_SAFE_INTEGER,s=e.max??Number.MAX_SAFE_INTEGER,a=e.decimalCases??0;return Ie(t.object({number:t.pipe(t.number(r("validation_number")),t.minValue(n,r("validation_number_min",{min:n})),t.maxValue(s,r("validation_number_max",{max:s})),t.check(i=>i===Number(i.toFixed(a)),r("validation_number_decimal_cases",{count:a})))}))},wn=({input:e,onSubmitSuccess:r})=>{var v;const n=e.config.defaultValue,s=e.key?(v=t.store.current$.value.flow)==null?void 0:v.data.submissions[e.key]:void 0,{t:a}=t.useTranslation(),{register:i,handleSubmit:o,formState:{errors:u}}=Fe({defaultValues:{number:n?Number(n):vn(s)?s.value:void 0},resolver:xn(e.config,a)}),{ref:d,...p}=i("number",{required:!e.config.optional,valueAsNumber:!0}),w=t._$1();return t.y(()=>{w.current&&(w.current.focus(),w.current.select())},[]),t.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:o(h=>{h.number!==void 0&&r({type:"number",value:h.number})}),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("div",{class:"relative min-w-0 flex-grow",children:[t.o("input",{...p,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(w.current=h),d(h)},type:"text",min:e.config.min,max:e.config.max,class:ve({optional:e.config.optional,className:"[type=number:-webkit-inner-spin-button] w-full rounded-full [-webkit-outer-spin-button:none]"}),placeholder:e.config.placeholder}),e.config.optional&&t.o(le,{class:"absolute right-0 top-0",onClick:()=>r(null)})]}),t.o(oe,{})]}),t.o(fe,{error:u.number})]})},_n=e=>{if(e==="")return{countryCode:"",phoneNumber:""};const r=Object.entries(Ke).find(a=>e.startsWith(a[1])),n=r?r[1]:"",s=e.replace(n,"");return/^\d+$/.test(s)?{countryCode:n,phoneNumber:s}:{countryCode:"",phoneNumber:""}},kn="44",Sn=/^[0-9 ]+$/,Cn=t.isSubmissionOfType("string"),En=t.isSubmissionOfType("phone"),An=e=>{const r=t.pipe(t.string(e("validation_country_code")),t.regex(Sn,e("validation_country_code"))),n=t.pipe(t.string(e("validation_phone")),t.minLength(1,e("validation_phone")),t.transform(s=>s.replace(/[^0-9]/g,"")));return Ie(t.object({countryCode:r,phoneNumber:n}))},Tn=({input:e,onSubmitSuccess:r})=>{var A;const n=e.key?(A=t.store.current$.value.flow)==null?void 0:A.data.submissions[e.key]:void 0,{t:s}=t.useTranslation(),[a,i]=t.h(),o=Cn(n)?_n(n.value):En(n)?n.value:void 0,{register:u,handleSubmit:d,formState:{errors:p},watch:w}=Fe({defaultValues:{countryCode:(o==null?void 0:o.countryCode)??e.config.defaultValue.countryCode??kn,phoneNumber:(o==null?void 0:o.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:An(s)}),{ref:v,...h}=u("phoneNumber",{required:!e.config.optional}),k=t._$1(),y=w("countryCode");return t.y(()=>{k.current&&(k.current.focus(),k.current.select())},[]),t.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:d(S=>{const E=S.phoneNumber.replace(/[^0-9]/g,""),g=S.countryCode.replace(/[^0-9]/g,"");i(void 0);const M=e.config.minChars??7;if(E.length+g.length<M)return i(s("validation_phone_min_chars",{count:M}));e.config.submissionFormat==="phone"?r({type:"phone",value:{countryCode:g,phoneNumber:E}}):r({type:"string",value:y+S.phoneNumber})}),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("div",{class:"relative flex min-w-0 flex-1 flex-grow gap-2",children:[t.o("label",{class:"text-neutral-12 bg-lowest hover:bg-neutral-5 placeholder:text-neutral-8 focus-visible:outline-accent-7 focus-within:bg-neutral-5 focus-within:outline-accent-7 outline-divider relative flex h-full cursor-pointer appearance-none items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-l-full border-solid px-3 py-1.5 text-center text-base outline outline-2 transition-all focus-within:outline-none",htmlFor:`isdk_phone_${e.key}`,children:[t.o("span",{children:["+",y]}),t.o("select",{...u("countryCode",{}),id:`isdk_phone_${e.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(Ke).map(([S,E])=>t.o("option",{value:E,children:[S," (+",E,")"]},S))})]}),t.o("input",{...h,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:S=>{S&&(k.current=S),v(S)},class:ve({optional:e.config.optional,className:"min-w-0 flex-1 rounded-r-full"}),placeholder:e.config.placeholder}),e.config.optional&&t.o(le,{class:"absolute bottom-0 right-0 top-0",onClick:()=>r(null)})]}),t.o(oe,{})]}),t.o(fe,{error:p.countryCode||p.phoneNumber||{message:a}})]})},Vn=({input:e,onSubmitSuccess:r})=>t.o("div",{class:"flex flex-col items-center py-3",children:t.o("button",{class:"bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:ring-2 active:ring-offset-2",name:e.key,onClick:()=>{r(null)},children:t.o("span",{class:"flex items-center gap-1.5",children:[t.o("span",{class:"inline-flex items-center text-sm font-medium",children:e.config.label||"Submit"}),t.o("svg",{stroke:"currentColor","stroke-width":"1.5",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.o("path",{d:"M4 8L8 4L12 8"}),t.o("path",{d:"M8 4V13"})]})]})})}),Mn={email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},Fn=t.isSubmissionOfType("string"),In=(e,r)=>{const n={maxLength:r("validation_max_chars",{count:e.maxChars??999}),minLength:r("validation_min_chars",{count:e.minChars??1})};return Ie(t.object({text:{email:t.pipe(t.string(r("validation_email")),t.email(r("validation_email")),t.minLength(e.minChars??1,n.minLength),t.maxLength(e.maxChars??1/0,n.maxLength)),text:t.pipe(t.string(),t.minLength(e.minChars??1,n.minLength),t.maxLength(e.maxChars??1/0,n.maxLength)),url:t.pipe(t.string(r("validation_url")),t.url(r("validation_url")),t.minLength(e.minChars??1,n.minLength),t.maxLength(e.maxChars??1/0,n.maxLength))}[e.format]}))},Ln=({input:e,onSubmitSuccess:r})=>{var v;const{t:n}=t.useTranslation(),s=e.key?(v=t.store.current$.value.flow)==null?void 0:v.data.submissions[e.key]:void 0,a=e.config.defaultValue,{register:i,handleSubmit:o,formState:{errors:u}}=Fe({defaultValues:{text:a||(Fn(s)?s.value:"")},resolver:In(e.config,n)}),{ref:d,...p}=i("text",{required:!e.config.optional}),w=t._$1();return t.y(()=>{w.current&&(w.current.focus(),w.current.select())},[]),t.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:o(h=>{r({type:"string",value:h.text})}),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("div",{class:"relative min-w-0 flex-1",children:[t.o("input",{id:"chat-input",...p,...Mn[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(w.current=h),d(h)},placeholder:e.config.placeholder,class:ve({optional:!!e.config.optional,className:"w-full rounded-full"})}),e.config.optional&&t.o(le,{class:"absolute right-0 top-0",onClick:()=>r(null)})]}),t.o(oe,{})]}),t.o(fe,{error:u.text})]})},Nn={text:Ln,phone:Tn,"multiple-choice":yn,boolean:Or,file:qr,submit:Vn,address:Lr,number:wn},Rn=({logger:e})=>{var i;const r=(i=t.store.current$.value.flow)==null?void 0:i.data.currentInput,[n,s]=wr(),a=t._$1(null);return t.store.inputHeight$.value=s.height,t.p(()=>{const o=a.current;if(o)return o.addEventListener("transitionstart",P.scrollToEnd.smooth),o.addEventListener("transitioncancel",P.scrollToEnd.smooth),o.addEventListener("transitionend",P.scrollToEnd.smooth),()=>{o.removeEventListener("transitionstart",P.scrollToEnd.smooth),o.removeEventListener("transitioncancel",P.scrollToEnd.smooth),o.removeEventListener("transitionend",P.scrollToEnd.smooth)}},[]),t.o("div",{ref:a,class:"ease-expo-out absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-xl transition-all duration-700 will-change-[height]",style:{height:s.height},children:t.o("div",{ref:n,class:"border-divider flex flex-col justify-end border-t",children:r?(()=>{const o=Nn[r.type];return t.o(o,{logger:e,onSubmitSuccess:P.onSubmitSuccessFn$.value,input:r})})():t.o("div",{class:"flex items-center gap-2 p-2.5",children:[t.o("input",{"aria-hidden":"true",id:"chat-input",class:ve({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),t.o(oe,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};var Dn=function(e){return e instanceof RegExp},On=function(r){var n=/[\\^$.*+?()[\]{}|]/g,s=RegExp(n.source);return r&&s.test(r)?r.replace(n,"\\$&"):r},Kt=function(e){return typeof e=="string"},Bn=function(e){var r=[];return e.forEach(function(n){Array.isArray(n)?r=r.concat(n):r.push(n)}),r};function $n(e,r,n){var s=0,a=0;if(e==="")return e;if(!e||!Kt(e))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var i=r;Dn(i)||(i=new RegExp("("+On(i)+")","gi"));for(var o=e.split(i),u=1,d=o.length;u<d;u+=2){if(o[u]===void 0||o[u-1]===void 0){console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");continue}a=o[u].length,s+=o[u-1].length,o[u]=n(o[u],u,s),s+=a}return o}var Pn=function(r,n,s){return Array.isArray(r)||(r=[r]),Bn(r.map(function(a){return Kt(a)?$n(a,n,s):a}))};const be=t.getDefaultExportFromCjs(Pn),jn=/(\[[^\]]+\]\([^)]+\))/g,zn=/\[([^\]]+)\]\(([^)]+)\)/,Un=/(https?:\/\/[^\s]+)/g,qn=/_(.*?)_/g,Kn=/\*\*(.*?)\*\*/g,Gn=/\\n|\n/g,Tt="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",Hn=e=>{const r=be(e,jn,(o,u)=>{const[,d,p]=o.match(zn)??[];return p?t.o("a",{class:Tt,href:p,children:d??p},p+u):t.o("span",{children:"INVALID LINK"})}),n=be(r,Un,(o,u)=>t.o("a",{class:Tt,href:o,children:o},o+u)),s=be(n,qn,(o,u)=>t.o("em",{children:o},o+u)),a=be(s,Kn,(o,u)=>t.o("strong",{children:o},o+u));return be(a,Gn,(o,u)=>t.o("br",{},`br-${u}`))},Wn=t.cva("select-text max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative",{variants:{side:{left:"bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",right:"ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"},animate:{true:"animate-bubble-in",false:""}},defaultVariants:{side:"left"}}),Jn=({children:e,className:r,animate:n,side:s,...a})=>t.o("p",{style:{transformOrigin:s==="left"?"0% 50%":"100% 50%"},class:Wn({className:r,side:s,animate:n}),...a,children:e}),Zn=({message:e})=>t.o("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:t.o("a",{onClick:e.onClick,class:"bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:e.href,children:[e.text,t.o("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.o("path",{d:"M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",fill:"currentColor","fill-rule":"evenodd","clip-rule":"evenodd"})})]})}),Xn=({className:e,...r})=>(t.p(()=>{P.scrollToEnd.smooth()}),t.o("div",{"aria-hidden":!0,children:P.isBotTyping$.value===!0?t.o("div",{"aria-label":"Typing…",class:t.clsx("flex gap-1 p-4",e),...r,children:Array.from({length:3},(n,s)=>t.o("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-s*200}ms`}}))}):void 0})),Yn={bot:"left",user:"right"},Qn=t.cva("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]",{variants:{variant:{info:"text-neutral-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),es=({lastSentMessageFooter:e})=>{var n;const r=((n=t.store.current$.value.flow)==null?void 0:n.data.messages)??[];return t.p(()=>{P.scrollToEnd.smooth()},[r.length]),t.o("ol",{"aria-label":"Chat messages",class:"mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[r.map((s,a)=>t.o(t.k,{children:t.o("li",{class:"flex",children:t.N(s).with({type:"system"},i=>t.o("p",{class:Qn({variant:i.variant}),children:i.text})).with({type:"text",author:t._.union("bot","user")},i=>{const o=i.author==="user"&&!r.slice(a+1).some(p=>p.type==="text"&&p.author==="user"),u=a===r.length-1,d=i.author==="bot"?Hn(i.text):i.text;return t.o(t.k,{children:[o?e:null,t.o(Jn,{animate:u,side:Yn[i.author],children:d},a)]})}).with({type:"link"},i=>t.o(Zn,{message:i})).with({type:"image"},i=>t.o("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:i.url,style:{aspectRatio:i.width/i.height}})).with({type:"file"},i=>t.o(jr,{class:i.author==="bot"?void 0:"ml-auto",file:{name:i.fileName,sizeKb:i.fileSizeKb}})).with({type:"loading"},i=>{const o=r[r.length-1];return!(i===o)||P.isBotTyping$.value?null:t.o("div",{class:"flex flex-grow flex-col items-center justify-center",children:t.o(t.LoadingIndicator,{class:"text-neutral-6 h-8 w-8"})})}).exhaustive()})},a)),t.o(Xn,{},"typing")]})},ts=({logger:e,apiClient:r,analytics:n})=>{const{flow:s}=t.store.current$.value;t.invariant(s,"Flow is required to exist to show chatbot body");const a=t.store.viewState$.value,{chatRef:i,chatService:o}=Ar(),{t:u}=t.useTranslation(),[d,p]=t.h();return t.y(()=>{a==="maximised"&&P.scrollToEnd.instant()},[a]),t.y(()=>{var S,E;const{state:w,flow:v}=t.store.current$.peek();if(w!=="loaded")throw new Error(u("invalid_state"));let h=v.data.nodeHistory.at(-1);if(P.scrollToEnd.instant(),t.store.setInput(void 0),v.data.isFinished)return;h===void 0?(h=t.getHeadOrThrow(s.nodes).id,t.store.setCurrentNodeId(h),n.log({event:"FLOW_START",properties:{flow_id:s.id,flow_version:s.version,flow_session_id:v.data.flowSessionId,flow_build:s.build,job:s.job},customProperties:(S=s.analytics)==null?void 0:S.customProperties})):t.store.removeMessagesSentByNodeIds([h]);const{interpret:k,abort:y,undo:A}=tr({context:s.context,analytics:{service:n,customProperties:(E=s.analytics)==null?void 0:E.customProperties},apiClient:r,logger:e,flow:s,chatService:o,t:u,getSubmissions:()=>{var g;return(g=t.store.current$.peek().flow)==null?void 0:g.data.submissions},onInterpret:g=>t.store.setCurrentNodeId(g.id),onFlowEnd:async()=>{var M;t.store.markAsFinished();const g=t.store.current$.peek().flow;t.invariant(g),n.log({event:"FLOW_END",properties:{flow_id:s.id,flow_version:s.version,flow_session_id:g.data.flowSessionId,flow_build:s.build,job:s.job},customProperties:(M=s.analytics)==null?void 0:M.customProperties})}});return p(()=>A),k(h),y},[n,r,o,e,s,u]),t.o(t.k,{children:[t.o("div",{ref:i,className:"hide-scrollbars relative flex w-full max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:t.store.inputHeight$.value},children:t.o(es,{lastSentMessageFooter:s.data.isFinished||!d?null:t.o(ns,{undoFn:d})})}),t.o(Rn,{logger:e})]})},rs=e=>e.type==="identify"?[]:"key"in e.data&&e.data.key?[e.data.key]:"keys"in e.data?Object.values(e.data.keys).filter(r=>typeof r=="string"):[],ns=({undoFn:e})=>{const{t:r}=t.useTranslation();return t.o(t.SvgIconButton,{onClick:async()=>{const{flow:n}=t.store.current$.peek();t.invariant(n);const{removed:s}=e(n.data.nodeHistory),a=n.data.nodeHistory.splice(-s);a.length!==0&&(t.store.removeMessagesSentByNodeIds(a),t.store.setInput(void 0),a.pop(),a.map(i=>n.nodes.find(o=>o.id===i)).filter(Boolean).flatMap(rs).forEach(i=>delete n.data.submissions[i]),t.store.current$.value={...t.store.current$.value})},children:[t.o("title",{children:r("undo")}),t.o("path",{d:"M3 13h2.67l6.66-6.67a1.9 1.9 0 0 0 0-2.66 1.91 1.91 0 0 0-2.66 0L3 10.33V13Zm4.6-7.25 2.67 2.67"})]})};exports.ChatbotBody=ts;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-a14b193c.cjs");require("@inploi/sdk");const ot=({condition:e,context:r,submissions:n,ifBlock:s})=>{const[a,...i]=e.compareKey.split(".");if(!a)return!1;const o=Mt({context:r,key:a,path:i,submissions:n});if(!o)return!1;switch(o.type){case"address":{const u=t.get(o.value,i.join("."));switch(e.compare){case"equals":return u===e.compareValue;case"contains":return u?u.includes(e.compareValue):!1;case"notEquals":return u!==e.compareValue;case"notContains":return u?!u.includes(e.compareValue):!0}break}case"integration":{if(typeof o.value!="object"||Array.isArray(o.value))return!1;const u=t.get(o.value,i.join(".")),d={...s,data:{...s.data,compareKey:"_temp"}};switch(typeof u){case"boolean":return ye(d,{submissions:{_temp:{value:u,type:"boolean"}},context:r});case"string":return ye(d,{submissions:{_temp:{value:u,type:"string"}},context:r});case"number":return ye(d,{submissions:{_temp:{value:u,type:"number"}},context:r});case"object":return Array.isArray(u)&&u.every(t.isString)?ye(d,{submissions:{_temp:{value:u,type:"enum"}},context:r}):!1}break}case"boolean":{const u=e.compareValue==="true";switch(e.compare){case"equals":return o.value===u;case"notEquals":return o.value!==u}break}case"phone":case"string":{const u=o.type==="phone"?Me(o.value):o.value;switch(e.compare){case"equals":return u===e.compareValue;case"contains":return u?u.includes(e.compareValue):!1;case"notEquals":return u!==e.compareValue;case"notContains":return u?!u.includes(e.compareValue):!0}break}case"number":{try{const u=Number(e.compareValue);switch(e.compare){case"equals":return o.value===u;case"notEquals":return o.value!==u;case"greaterThan":return o.value>u;case"greaterThanOrEqualTo":return o.value>=u;case"lessThan":return o.value<u;case"lessThanOrEqualTo":return o.value<=u}}catch{return console.error(`Failed to parse number in if-block ${s.id}`,o.value),!1}break}case"enum":switch(e.compare){case"equals":return o.value.length===1&&o.value[0]===e.compareValue;case"notEquals":return o.value.length===1&&o.value[0]!==e.compareValue;case"contains":return o.value.includes(e.compareValue);case"notContains":return!o.value.includes(e.compareValue)}break}},ye=(e,{context:r,submissions:n})=>{const s="combinator"in e.data?e.data.conditions:[e.data];if(("combinator"in e.data?e.data.combinator:"and")==="or"){for(const i of s)if(ot({condition:i,context:r,submissions:n,ifBlock:e}))return!0;return!1}else{for(const i of s)if(!ot({condition:i,context:r,submissions:n,ifBlock:e}))return!1;return!0}},Qt=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,Z=(e,{context:r,submissions:n})=>e.replace(Qt,(s,a,i="")=>{const[o,...u]=a.trim().split("."),d=Mt({key:o,path:u,submissions:n,context:r});if(!d)return i;switch(d.type){case"boolean":return d.value===!0?"true":"false";case"file":return d.value.map(p=>`${p.name} (${t.kbToReadableSize(p.sizeKb)})`).join(", ");case"enum":return d.value.join(", ");case"address":return Object.values(d.value).filter(p=>p&&p.trim().length>0).join(", ");case"number":case"string":return d.value?d.value.toString():i;case"phone":return Me(d.value);case"integration":{if(typeof d.value!="object"||Array.isArray(d.value))break;const p=t.get(d.value,u.join("."));switch(typeof p){case"boolean":return p===!0?"true":"false";case"string":return p;case"number":return p.toString();case"object":if(Array.isArray(p)&&p.every(t.isString))return p.join(", ")}break}}return i}),Vt=({node:e,nodes:r,stopWhen:n})=>{if((n==null?void 0:n(e))===!0)return e;const s=e.nextId?r.find(a=>a.id===e.nextId):void 0;if(s)return Vt({node:s,nodes:r,stopWhen:n})},er=({childNode:e,nodes:r})=>{const s=r.filter(a=>a.type==="if-block").find(a=>{if(!a.branchId)return!1;const i=r.find(u=>u.id===a.branchId);if(!i)return!1;const o=Vt({node:i,nodes:r,stopWhen:u=>u.id===e.id});return!(!o||o.id!==e.id)});if(s!=null&&s.nextId)return r.find(a=>a.id===s.nextId)},tr=({flow:e,analytics:r,logger:n,context:s,apiClient:a,getSubmissions:i,chatService:o,onFlowEnd:u,onInterpret:d,t:p})=>{let w=new AbortController;const v={...r.service,log:k=>r.service.log({...k,customProperties:{...k.customProperties,...r.customProperties}})},h=async(k,y)=>{const A=i();d==null||d(k,y);try{await rr({flow:e,analytics:v,logger:n,apiClient:a,context:s,node:k,submissions:A,t:p,chat:{sendMessage:async S=>o.send({groupId:k.id,message:S,signal:w.signal}),userInput:async S=>o.input({input:S,signal:w.signal}),addToSubmissions:o.addToSubmissions},next:S=>{const E=S?e.nodes.find(g=>g.id===S):er({childNode:k,nodes:e.nodes});return E?h(E,k):u==null?void 0:u(k)},end:()=>u==null?void 0:u(k)})}catch(S){if(S instanceof t.AbortedError)return;throw S}};return{interpret:async k=>{const y=e.nodes.find(A=>A.id===k)??t.getHeadOrThrow(e.nodes);return h(y)},undo:k=>{let y=1;const A=e.nodes.find(E=>E.id===k[k.length-1]);for(let E=k.length-2;E>0;E--){const g=k[E],M=e.nodes.find($=>$.id===g);if(!M||(y++,M.type.startsWith("question-")))break}w.abort(),w=new AbortController;const S=e.nodes.find(E=>E.id===k[k.length-y]);return t.invariant(S,"Undo failed: new start node not found"),h(S,A),{removed:y}},abort:()=>{w.abort()}}},Me=e=>`+${e.countryCode} ${e.phoneNumber}`;async function rr(e){const r=e.node;switch(r.type){case"text":return cr({...e,node:r});case"image":return dr({...e,node:r});case"question-text":return fr({...e,node:r});case"question-enum":return mr({...e,node:r});case"question-number":return hr({...e,node:r});case"question-phone":return pr({...e,node:r});case"question-boolean":return gr({...e,node:r});case"question-file":return yr({...e,node:r});case"question-address":return br({...e,node:r});case"end-flow":return vr({...e,node:r});case"if-block":return ur({...e,node:r});case"jump":return ar({...e,node:r});case"link":return lr({...e,node:r});case"integration-application-submit":return or({...e,node:r});case"add-submission":return ir({...e,node:r});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"identify":return sr({...e,node:r});case"feedback":return nr({...e,node:r});default:throw new Error(`Unknown node: ${JSON.stringify(r)}`)}}const me=(e,r)=>{var s;const n=(s=e[r])==null?void 0:s.value;if(typeof n!="string"&&typeof n!="number")throw new Error(`Submission at “${r}” is not a string or number`);return n};async function nr({next:e,node:r}){e(r.nextId)}async function sr({next:e,node:r,analytics:n,submissions:s,logger:a}){if(!s)return e(r.nextId);try{n.log({event:"IDENTIFY",properties:{identifier:me(s,r.data.key).toString(),first_name:r.data.firstName?me(s,r.data.firstName).toString():void 0,last_name:r.data.lastName?me(s,r.data.lastName).toString():void 0,email:r.data.email?me(s,r.data.email).toString():void 0,phone_number:r.data.phoneNumber?me(s,r.data.phoneNumber).toString():void 0,custom_traits:r.data.customTraits?Object.fromEntries(r.data.customTraits.map(({key:i,value:o})=>{var u;return[i,(u=s[o])==null?void 0:u.value]})):void 0}})}catch(i){a.error(i)}finally{e(r.nextId)}}async function ar({next:e,node:r}){e(r.data.targetId)}async function ir({next:e,node:r,logger:n,submissions:s,context:a}){if(!s){n.error("Submissions not found");return}s[r.data.key]={type:"string",value:Z(r.data.value,{submissions:s,context:a})},e(r.nextId)}async function or({chat:e,next:r,node:n,logger:s,apiClient:a,submissions:i,analytics:o,flow:u,t:d}){const p=async w=>{w!==!0&&await e.userInput({type:"submit",key:void 0,config:{label:n.data.submitLabel}}),await e.sendMessage({type:"loading"});const{anonymous_id:v,session_id:h}=o.getSessionInfo(),k=await a.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:n.data.integrationId,anonymous_id:v,session_id:h,job:u.job,submissions:t.getFlowSubmissionsPayload(i||{})})}).catch(y=>y);n.data.key&&e.addToSubmissions(n.data.key,{type:"integration",value:k}),t.N(k).with({integration_response:t._.select(t._.union({service:t._.optional(t._.string),status:t._.number,data:t._.any},{service:t._.optional(t._.string),status:t._.number,error:{message:t._.string,data:t._.any}}))},y=>{o.log({event:"FLOW_SUBMIT",properties:{flow_id:u.id,flow_version:u.version,flow_session_id:u.data.flowSessionId,flow_build:u.build,service:y.service??"INVALID_SERVICE",response:{status:y.status,payload:"data"in y?y.data:y.error.data??null},job:u.job}})}).otherwise(()=>{}),await t.N(k).with({integration_response:{data:t._.select("redirect",{redirect_url:t._.string,message:t._.optional(t._.union(t._.string,t._.nullish)),button_text:t._.optional(t._.union(t._.string,t._.nullish))})}},async y=>{await e.sendMessage({type:"text",author:"bot",text:y.redirect.message??d("submission_redirect_message")});try{const A=new URL(y.redirect.redirect_url);v&&!A.searchParams.has("anonymous_id")&&A.searchParams.set("anonymous_id",v),await e.sendMessage({type:"link",href:A.toString(),text:y.redirect.button_text??d("complete_submission"),onClick:()=>{if(!h){s.error("session_id not set, cannot log FLOW_REDIRECT event");return}o.log({event:"FLOW_REDIRECT",properties:{flow_build:u.build,flow_id:u.id,flow_session_id:h,flow_version:u.version,href:A.toString(),job:u.job}})}})}catch(A){s.error(`Invalid redirect URL: ${y.redirect.redirect_url}`,A),e.sendMessage({type:"system",variant:"error",text:d("redirect_url_error")})}r(n.nextId)}).with({success:!0},async()=>{n.data.skipConfirmation!==!0&&await e.sendMessage({type:"system",variant:"success",text:d("submission_completed")}),r(n.nextId)}).with({integration_response:{error:t._.select("error",{message:t._.string})}},async y=>{s.error(y.error),await e.sendMessage({type:"system",variant:"error",text:y.error.message||d("submission_failed")}),await p(!1)}).otherwise(async y=>{s.error(y),await e.sendMessage({type:"system",variant:"error",text:d("submission_failed")}),await p(!1)})};await p(n.data.skipConfirmation)}async function lr({chat:e,next:r,node:n,submissions:s,context:a}){await e.sendMessage({type:"link",href:Z(n.data.href,{submissions:s,context:a}),text:Z(n.data.cta,{submissions:s,context:a})}),r(n.nextId)}async function ur({submissions:e,next:r,node:n,context:s}){r(ye(n,{submissions:e,context:s})?n.branchId:n.nextId)}async function cr({chat:e,next:r,node:n,submissions:s,context:a}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.text,{submissions:s,context:a})}),r(n.nextId)}async function dr({chat:e,next:r,node:n}){await e.sendMessage({author:"bot",type:"image",url:n.data.url,height:n.data.height,width:n.data.width}),r(n.nextId)}async function fr({chat:e,next:r,node:n,submissions:s,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const o=n.data.format==="phone"?await e.userInput({key:n.data.key,type:"phone",config:{optional:n.data.optional,placeholder:n.data.placeholder,minChars:n.data.minChars,submissionFormat:"text",defaultValue:{}}}):await e.userInput({key:n.data.key,type:"text",config:{optional:n.data.optional,placeholder:n.data.placeholder,format:n.data.format,maxChars:n.data.maxChars,minChars:n.data.minChars}});o===null?await e.sendMessage({type:"system",variant:"info",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.type==="phone"?Me(o.value):o.value}),r(n.nextId)}async function hr({chat:e,next:r,node:n,submissions:s,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const o=await e.userInput({key:n.data.key,type:"number",config:{max:n.data.max,min:n.data.min,optional:n.data.optional,placeholder:n.data.placeholder,decimalCases:n.data.decimalCases}});o===null?await e.sendMessage({type:"system",variant:"info",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.value.toString()}),r(n.nextId)}async function pr({chat:e,next:r,node:n,submissions:s,context:a}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const i=await e.userInput({key:n.data.key,type:"phone",config:{minChars:n.data.minChars,defaultValue:{countryCode:n.data.defaultCountryCode},placeholder:n.data.placeholder,submissionFormat:"phone",optional:n.data.optional}});i===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:i.type==="phone"?Me(i.value):i.value}),r(n.nextId)}async function mr({chat:e,next:r,node:n,submissions:s,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const o=await e.userInput({key:n.data.key,type:"multiple-choice",config:n.data});o.value.length===0?await e.sendMessage({type:"system",variant:"info",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:n.data.options.filter(u=>o.value.includes(u.value)).map(u=>u.label).join(", ")}),r(n.nextId)}async function gr({chat:e,next:r,node:n,submissions:s,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const o=await e.userInput({key:n.data.key,type:"boolean",config:{optional:n.data.optional,labels:{true:n.data.trueLabel,false:n.data.falseLabel}}});o===null?await e.sendMessage({type:"system",variant:"info",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.value===!0?n.data.trueLabel:n.data.falseLabel}),r(n.nextId)}async function br({chat:e,next:r,node:n,t:s}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const a=await e.userInput({type:"address",key:n.data.key,config:{optional:n.data.optional,keys:n.data.keys,placeholder:n.data.placeholder}});if(a===null)await e.sendMessage({type:"system",variant:"info",text:s("skipped")});else{const i=Object.values(a.value).filter(o=>o&&o.trim().length>0).join(", ");await e.sendMessage({author:"user",type:"text",text:i})}return r(n.nextId)}async function yr({node:e,chat:r,next:n,submissions:s,context:a,t:i}){await r.sendMessage({author:"bot",type:"text",text:Z(e.data.question,{submissions:s,context:a})});const o=await r.userInput({key:e.data.key,type:"file",config:{optional:e.data.optional,extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb??10*1024,allowMultiple:e.data.multiple===!0}});if(o===null)await r.sendMessage({type:"system",variant:"info",text:i("skipped")});else for(const u of o.value)await r.sendMessage({author:"user",type:"file",fileName:u.name,fileSizeKb:u.sizeKb});n(e.nextId)}async function vr({chat:e,end:r,node:n}){await e.sendMessage({type:"system",variant:"info",text:n.data.systemMessage}),r()}const Mt=({key:e,path:r,submissions:n,context:s})=>{if(e==="$context"){if(!r)return;const a=t.get(s,r.join("."));switch(typeof a){case"string":return{type:"string",value:a};case"number":return{type:"number",value:a};case"boolean":return{type:"boolean",value:a};default:console.warn(`Unexpected type for $context.${r.join(".")}`,a);return}}return n==null?void 0:n[e]};function Ue(e,r,n){var s,a,i,o,u;r==null&&(r=100);function d(){var w=Date.now()-o;w<r&&w>=0?s=setTimeout(d,r-w):(s=null,n||(u=e.apply(i,a),i=a=null))}var p=function(){i=this,a=arguments,o=Date.now();var w=n&&!s;return s||(s=setTimeout(d,r)),w&&(u=e.apply(i,a),i=a=null),u};return p.clear=function(){s&&(clearTimeout(s),s=null)},p.flush=function(){s&&(u=e.apply(i,a),i=a=null,clearTimeout(s),s=null)},p}Ue.debounce=Ue;var xr=Ue;const lt=t.getDefaultExportFromCjs(xr);function wr(e){let{debounce:r,scroll:n,polyfill:s,offsetSize:a}=e===void 0?{debounce:0,scroll:!1,offsetSize:!1}:e;const i=s||(typeof window>"u"?class{}:window.ResizeObserver);if(!i)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[o,u]=t.h({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),d=t._$1({element:null,scrollContainers:null,resizeObserver:null,lastBounds:o}),p=r?typeof r=="number"?r:r.scroll:null,w=r?typeof r=="number"?r:r.resize:null,v=t._$1(!1);t.p(()=>(v.current=!0,()=>void(v.current=!1)));const[h,k,y]=t.F(()=>{const g=()=>{if(!d.current.element)return;const{left:M,top:$,width:L,height:se,bottom:te,right:he,x:q,y:X}=d.current.element.getBoundingClientRect(),j={left:M,top:$,width:L,height:se,bottom:te,right:he,x:q,y:X};d.current.element instanceof HTMLElement&&a&&(j.height=d.current.element.offsetHeight,j.width=d.current.element.offsetWidth),Object.freeze(j),v.current&&!Cr(d.current.lastBounds,j)&&u(d.current.lastBounds=j)};return[g,w?lt(g,w):g,p?lt(g,p):g]},[u,a,p,w]);function A(){d.current.scrollContainers&&(d.current.scrollContainers.forEach(g=>g.removeEventListener("scroll",y,!0)),d.current.scrollContainers=null),d.current.resizeObserver&&(d.current.resizeObserver.disconnect(),d.current.resizeObserver=null)}function S(){d.current.element&&(d.current.resizeObserver=new i(y),d.current.resizeObserver.observe(d.current.element),n&&d.current.scrollContainers&&d.current.scrollContainers.forEach(g=>g.addEventListener("scroll",y,{capture:!0,passive:!0})))}const E=g=>{!g||g===d.current.element||(A(),d.current.element=g,d.current.scrollContainers=Ft(g),S())};return kr(y,!!n),_r(k),t.p(()=>{A(),S()},[n,y,k]),t.p(()=>A,[]),[E,o,h]}function _r(e){t.p(()=>{const r=e;return window.addEventListener("resize",r),()=>void window.removeEventListener("resize",r)},[e])}function kr(e,r){t.p(()=>{if(r){const n=e;return window.addEventListener("scroll",n,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",n,!0)}},[e,r])}function Ft(e){const r=[];if(!e||e===document.body)return r;const{overflow:n,overflowX:s,overflowY:a}=window.getComputedStyle(e);return[n,s,a].some(i=>i==="auto"||i==="scroll")&&r.push(e),[...r,...Ft(e.parentElement)]}const Sr=["x","y","top","bottom","left","right","width","height"],Cr=(e,r)=>Sr.every(n=>e[n]===r[n]),oe=({class:e,...r})=>{const{t:n}=t.useTranslation();return t.o("button",{class:t.clsx("bg-accent-9 active:bg-accent-10 pointer-coarse:touch-hitbox fr flex-shrink-0 rounded-full p-2 text-white transition-all disabled:cursor-not-allowed disabled:opacity-50",e),type:"submit",...r,children:t.o("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[t.o("title",{children:n("send")}),t.o("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),t.o("path",{d:"M8 4V13"})]})})},Er=25,qe=t.d({instant:()=>{},smooth:()=>{}}),P={onSubmitSuccessFn$:t.d(()=>{}),isBotTyping$:t.d(!1),scrollToEnd:{instant:()=>qe.value.instant(),smooth:()=>qe.value.smooth()}},Ar=()=>{const e=t._$1(null);t.y(()=>{qe.value={instant:()=>{var n;return(n=e.current)==null?void 0:n.scrollTo({top:e.current.scrollHeight,behavior:"instant"})},smooth:()=>{e.current&&e.current.scrollHeight-e.current.scrollTop<=e.current.clientHeight*2&&e.current.scrollTo({top:e.current.scrollHeight,behavior:"smooth"})}}},[e]);const r=t.F(()=>({addToSubmissions:(s,a)=>t.store.setSubmission(s,a),send:async({message:s,signal:a,groupId:i})=>{if(await t.N(s).with({author:"bot",type:"text"},async o=>{if(a!=null&&a.aborted)throw new t.AbortedError;P.isBotTyping$.value=!0;const u=Math.min(Math.max(20,o.text.length),100)*Er;await new Promise(d=>setTimeout(d,u,{signal:a})),P.isBotTyping$.value=!1}).otherwise(async()=>{}),a!=null&&a.aborted)throw new t.AbortedError;t.store.addMessage(s,i)},input:({input:s,signal:a})=>{if(a!=null&&a.aborted)throw new t.AbortedError;return t.store.setInput(s),new Promise(i=>{const o=u=>{if(a!=null&&a.aborted)throw new t.AbortedError;t.store.setInput(void 0),s.key&&t.store.setSubmission(s.key,u),i(u)};P.onSubmitSuccessFn$.value=o})}}),[]);return{chatRef:e,chatService:r}},fe=({error:e})=>!e||!e.message?null:t.o("div",{role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full px-2 py-2",children:[t.o("svg",{class:"text-error-9 h-4 w-4",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.o("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),t.o("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),t.o("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),t.o("p",{class:"truncate pr-1 text-sm",children:e.message})]}),le=({class:e,...r})=>{const{t:n}=t.useTranslation();return t.o("button",{type:"button",class:t.clsx("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),...r,children:[t.o("svg",{"aria-hidden":!0,class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",children:[t.o("title",{children:n("skip")}),t.o("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),t.o("path",{d:"M13.25 4.5V8.25H9.5"})]}),n("skip")]})},Ke={Afghanistan:"93",Albania:"355",Algeria:"213","American Samoa":"1 684",Andorra:"376",Angola:"244",Anguilla:"1 264",Antarctica:"672","Antigua and Barbuda":"1 268",Argentina:"54",Armenia:"374",Aruba:"297",Australia:"61",Austria:"43",Azerbaijan:"994",Bahrain:"973",Bangladesh:"880",Barbados:"1 246",Belarus:"375",Belgium:"32",Belize:"501",Benin:"229",Bermuda:"1 441",Bhutan:"975",Bolivia:"591","Bosnia and Herzegovina":"387",Botswana:"267","Bouvet Island":"47",Brazil:"55","British Indian Ocean Territory":"246","British Virgin Islands":"1 284",Brunei:"673",Bulgaria:"359","Burkina Faso":"226",Burundi:"257","Cabo Verde":"238",Cambodia:"855",Cameroon:"237",Canada:"1","Caribbean Netherlands":"599","Cayman Islands":"1 345","Central African Republic":"236",Chad:"235",Chile:"56",China:"86","Christmas Island":"61","Cocos (Keeling) Islands":"61",Colombia:"57",Comoros:"269","Cook Islands":"682","Costa Rica":"506",Croatia:"385",Cuba:"53",Curaçao:"599",Cyprus:"357",Czechia:"420","Côte d'Ivoire":"225","Democratic Republic of the Congo":"243",Denmark:"45",Djibouti:"253","Dominican Republic":"1 809",Ecuador:"593",Egypt:"20","El Salvador":"503","Equatorial Guinea":"240",Eritrea:"291",Estonia:"372",Eswatini:"268",Ethiopia:"251","Falkland Islands (Islas Malvinas)":"500","Faroe Islands":"298",Fiji:"679",Finland:"358",France:"33","French Guiana":"594","French Polynesia":"689","French Southern and Antarctic Lands":"262",Gabon:"241",Georgia:"995",Germany:"49",Ghana:"233",Gibraltar:"350",Greece:"30",Greenland:"299",Grenada:"1 473",Guadeloupe:"590",Guam:"1 671",Guatemala:"502",Guernsey:"44",Guinea:"224","Guinea-Bissau":"245",Guyana:"592",Haiti:"509",Honduras:"504","Hong Kong":"852",Hungary:"36",Iceland:"354",India:"91",Indonesia:"62",Iran:"98",Iraq:"964",Ireland:"353","Isle of Man":"44",Israel:"972",Italy:"39",Jamaica:"1 876",Japan:"81",Jersey:"44",Jordan:"962",Kazakhstan:"7",Kenya:"254",Kiribati:"686",Kosovo:"383",Kuwait:"965",Kyrgyzstan:"996",Laos:"856",Latvia:"371",Lebanon:"961",Lesotho:"266",Liberia:"231",Libya:"218",Liechtenstein:"423",Lithuania:"370",Luxembourg:"352",Macao:"853",Madagascar:"261",Malawi:"265",Malaysia:"60",Maldives:"960",Mali:"223",Malta:"356","Marshall Islands":"692",Martinique:"596",Mauritania:"222",Mauritius:"230",Mayotte:"262",Mexico:"52",Micronesia:"691",Moldova:"373",Monaco:"377",Mongolia:"976",Montenegro:"382",Montserrat:"1 664",Morocco:"212",Mozambique:"258","Myanmar (Burma)":"95",Namibia:"264",Nauru:"674",Nepal:"977",Netherlands:"31","New Caledonia":"687","New Zealand":"64",Nicaragua:"505",Niger:"227",Nigeria:"234",Niue:"683","Norfolk Island":"672","North Korea":"850","North Macedonia":"389","Northern Mariana Islands":"1 670",Norway:"47",Oman:"968",Pakistan:"92",Palau:"680",Palestine:"970",Panama:"507","Papua New Guinea":"675",Paraguay:"595",Peru:"51",Philippines:"63","Pitcairn Islands":"64",Poland:"48",Portugal:"351","Puerto Rico":"1 787",Qatar:"974",Romania:"40",Russia:"7",Rwanda:"250",Réunion:"262","Saint Barthélemy":"590","Saint Helena, Ascension and Tristan da Cunha":"290","Saint Kitts and Nevis":"1 869","Saint Lucia":"1 758","Saint Martin":"590","Saint Pierre and Miquelon":"508","Saint Vincent and the Grenadines":"1 784",Samoa:"685","San Marino":"378","Saudi Arabia":"966",Senegal:"221",Serbia:"381",Seychelles:"248","Sierra Leone":"232",Singapore:"65","Sint Maarten":"1 721",Slovakia:"421",Slovenia:"386","Solomon Islands":"677",Somalia:"252","South Africa":"27","South Georgia and the South Sandwich Islands":"500","South Korea":"82","South Sudan":"211",Spain:"34","Sri Lanka":"94",Sudan:"249",Suriname:"597","Svalbard and Jan Mayen":"47",Sweden:"46",Switzerland:"41",Syria:"963","São Tomé and Príncipe":"239",Taiwan:"886",Tajikistan:"992",Tanzania:"255",Thailand:"66","The Bahamas":"1 242","The Gambia":"220","Timor-Leste":"670",Togo:"228",Tokelau:"690",Tonga:"676","Trinidad and Tobago":"1 868",Tunisia:"216",Turkmenistan:"993","Turks and Caicos Islands":"1 649",Tuvalu:"688",Türkiye:"90","U.S. Virgin Islands":"1 340",Uganda:"256",Ukraine:"380","United Arab Emirates":"971","United Kingdom":"44","United States":"1","United States Minor Outlying Islands":"1",Uruguay:"598",Uzbekistan:"998",Vanuatu:"678","Vatican City":"379",Venezuela:"58",Vietnam:"84","Wallis and Futuna":"681","Western Sahara":"212",Yemen:"967",Zambia:"260",Zimbabwe:"263","Åland Islands":"358"},ve=t.cva("outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest py-1 text-base outline outline-2 transition-all",{variants:{optional:{true:"pr-16 pl-3",false:"pl-3 pr-3"}},defaultVariants:{optional:!1}}),Tr="https://api.mapbox.com/search/searchbox/v1/suggest",Vr="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",Mr=e=>atob(e).split("").reverse().join(""),Y=t.object({name:t.string()}),Fr=t.object({suggestions:t.array(t.object({full_address:t.optional(t.string()),place_formatted:t.optional(t.string()),name:t.optional(t.string()),mapbox_id:t.string(),context:t.partial(t.object({address:Y,street:Y,neighborhood:Y,locality:Y,district:Y,place:Y,region:Y,postcode:Y,country:Y}))}))}),Ir=({logger:e,t:r})=>t.F(()=>{var s;const n=(s=t.store.current$.peek().flow)==null?void 0:s.data.flowSessionId;return n?{enabled:!0,getPredictions:async a=>{var v;const i=new URL(Tr);i.searchParams.set("q",a),i.searchParams.set("session_token",n);const o=(v=t.store.current$.peek().flow)==null?void 0:v.locationOrigin;o&&o.lat!==void 0&&o.lng!==void 0&&o.lat>=-90&&o.lat<=90&&o.lng>=-180&&o.lng<=180&&i.searchParams.set("proximity",`${o.lng},${o.lat}`),i.searchParams.set("access_token",Mr(Vr));const d=await fetch(i);if(!d.ok)return e.error("Failed to get address details",d),{ok:!1,error:r("address_error")};const p=t.safeParse(Fr,await d.json());if(p.success===!1)return e.error("Failed to parse address details",p.issues),{ok:!1,error:r("address_error")};const{suggestions:w}=p.output;return{ok:!0,data:w.map(h=>{var k,y,A,S,E,g,M,$,L;return{label:h.full_address??h.place_formatted??h.name??h.mapbox_id,id:h.mapbox_id,address:{line1:((k=h.context.address)==null?void 0:k.name)??((y=h.context.street)==null?void 0:y.name),line2:void 0,line3:((A=h.context.neighborhood)==null?void 0:A.name)??((S=h.context.locality)==null?void 0:S.name),city:((E=h.context.place)==null?void 0:E.name)??((g=h.context.district)==null?void 0:g.name),state:(M=h.context.region)==null?void 0:M.name,postcode:($=h.context.postcode)==null?void 0:$.name,country:(L=h.context.country)==null?void 0:L.name}}})}}}:{enabled:!1}},[e,r]),ut=e=>{const{t:r}=t.useTranslation();return t.o("button",{type:"button",class:"text-neutral-10 hover:bg-neutral-4 hover:text-neutral-12 hover:border-neutral-5 flex items-center gap-1 rounded-[18px] border border-solid border-transparent px-3 py-1 pl-1.5 text-sm transition-colors",...e,children:[t.o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",stroke:"currentColor","stroke-width":"1.5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.o("path",{d:"M10 3L5 8L10 13"})}),t.o("span",{children:r("back")})]})},Lr=({input:e,onSubmitSuccess:r,logger:n})=>{const{t:s}=t.useTranslation(),[a,i]=t.h(),[o,u]=t.h([]),{enabled:d,getPredictions:p}=Ir({logger:n,t:s}),[w,v]=t.h(d?"query":"manual"),[h,k]=t.h(""),[y,A]=t.h(),S=E=>{t.invariant(d,"Query state should not be enabled"),E=E.trim(),E!==(h==null?void 0:h.trim())&&(k(E),E===""&&u([]),A(void 0),p(E).then(g=>{if(g.ok===!1){u([]),A(g.error);return}u(g.data)}))};switch(w){case"query":return t.invariant(d,"Query state should not be enabled"),t.o(Nr,{input:e,onSkip:()=>r(null),onAddressSelect:E=>{if(E===""){i(void 0),v("manual");return}const g=o.find(M=>M.id===E);g&&(i(g.address),v("details"))},onAddressSearch:E=>{S(E)},suggestions:o,query:h,error:y});case"details":return t.invariant(a!==void 0),t.o(dt,{input:e,logger:n,onSubmitSuccess:r,addressFields:a,actions:t.o(ut,{onClick:()=>{v("query")}})});case"manual":return t.o(dt,{logger:n,input:e,onSubmitSuccess:r,addressFields:{},actions:d?t.o(ut,{onClick:()=>{v("query")}}):void 0})}},Nr=({input:e,onSkip:r,suggestions:n,onAddressSelect:s,query:a,onAddressSearch:i,error:o})=>{const{t:u}=t.useTranslation(),d=t._$1(null);return t.y(()=>{d.current&&(d.current.focus(),d.current.select())},[]),t.o(t.k,{children:[t.o("form",{noValidate:!0,onSubmit:p=>{p.preventDefault();const v=new FormData(p.currentTarget).get("address");typeof v=="string"&&i(v)},class:"flex gap-1 p-2.5",children:[t.o("div",{class:"group relative flex-1",children:[t.o("input",{ref:d,name:"address",id:"chat-address",autocomplete:"address-line1 country-name postal-code",autoFocus:!0,placeholder:e.config.placeholder||u("address_search"),defaultValue:a,class:ve({optional:!!e.config.optional,className:"w-full rounded-full"})}),t.o("button",{type:"submit",class:"touch-hitbox text-neutral-12 hover:bg-neutral-3 fr absolute bottom-0 right-0 top-0 flex cursor-pointer items-center gap-1 rounded-full px-3 transition-all",children:t.o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.o("g",{id:"inploi",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",strokeWidth:"1.5",children:[t.o("circle",{cx:"7",cy:"7",r:"4"}),t.o("path",{d:"M10 10L13 13"})]}),t.o("span",{class:"sr-only",children:u("search")})]})})]}),e.config.optional&&t.o(le,{class:"",onClick:r})]}),o?t.o(fe,{error:{message:o}}):null,t.o("ul",{children:[n.map(p=>t.o("li",{children:t.o("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{s(p.id)},children:[t.o("span",{class:"flex-grow",children:p.label}),t.o("svg",{class:"flex-none",width:"16",height:"16",viewBox:"0 0 16 16",stroke:"currentColor","stroke-width":"1.5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.o("path",{d:"M6 3L11 8L6 13"})})]})},p.id)),t.o("li",{children:t.o("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{s("")},children:t.o("span",{class:"flex-grow",children:u("address_manual")})})},"")]})]})},ct=["line1","line2","line3","city","state","postcode","country"],dt=({addressFields:e,onSubmitSuccess:r,actions:n,input:s})=>{const a=t._$1(null);t.y(()=>{if(a.current){const u=a.current.querySelector("input");u&&(u.focus(),u.select())}},[]);const i=Object.keys(Ke),{t:o}=t.useTranslation();return t.o("form",{class:"bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",onSubmit:u=>{const d=new FormData(u.currentTarget),p=Object.fromEntries(d.entries());r({type:"address",value:p})},children:[t.o("div",{class:"bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",ref:a,children:ct.map((u,d)=>{const p=`isdk_${u}`,w=s.config.keys[u];return w?t.o(t.k,{children:[t.o("label",{for:p,class:"text-neutral-9 [&:has(+*>input:focus)]:text-neutral-11 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",children:o(u)}),t.o("div",{class:"flex flex-col items-stretch gap-1.5",children:[u==="country"?t.o("div",{class:"relative",children:[t.o("select",{class:"text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",name:w,id:p,defaultValue:e[u],required:!0,children:[e.country&&!i.includes(e.country)?t.o("option",{value:e[u],children:e[u]}):t.o("option",{value:"",children:o("select_country")}),i.map(v=>t.o("option",{value:v,children:v},v))]}),t.o("svg",{class:"text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",width:"16",height:"16",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.o("path",{d:"M4 6.5L8 10.5L12 6.5"})})]}):t.o("input",{autoFocus:d===0?!0:void 0,class:"text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 flex-1 rounded-lg border-solid bg-transparent px-3 py-1.5 text-base transition-colors autofill:shadow-[inset_0_0_0_1000px_hsl(210_16.7%_97.6%)] focus:outline-none",name:w,id:p,defaultValue:e[u],required:!0}),d===ct.length-1?t.o("hr",{class:"m-0 w-full border-b border-b-transparent"}):t.o("hr",{class:"border-b-neutral-5 m-0 w-full border-b border-solid"})]})]}):null})}),t.o("div",{class:"flex w-full flex-1 ",children:[t.o("div",{class:"flex-grow",children:n}),t.o(oe,{class:"flex items-center justify-center"})]})]})},Ge=()=>{const e=t._$1(null);return t.p(()=>{var r;(r=e.current)==null||r.focus()},[]),e},It=["true","false"],Rr=t.picklist(It),Dr="answer",Lt="flex items-center gap-2 p-2.5",Nt=t.k$1(({label:e,...r},n)=>t.o("button",{class:"bg-lowest ease-expo-out ring-divider text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block w-full overflow-hidden rounded-2xl px-2.5 py-2.5 ring-2 transition-all selection:bg-transparent",...r,ref:n,children:t.o("p",{class:"truncate text-center text-base",children:e})})),Or=({input:e,onSubmitSuccess:r})=>{const n=Ge();return t.o("form",{noValidate:!0,class:"",onSubmit:s=>{s.preventDefault();const a=t.getFormSubmitter(s).value,i=t.parse(Rr,a);r({type:"boolean",value:i==="true"})},children:[t.o("ul",{class:Lt,children:It.map((s,a)=>t.o("li",{class:"flex-1",children:t.o(Nt,{ref:a===0?n:null,type:"submit",name:Dr,value:s,label:e.config.labels[s]},s)}))}),e.config.optional&&t.o("div",{class:"px-2 pb-2",children:t.o(le,{class:"w-full",type:"button",onClick:()=>r(null)})})]})},Br=e=>new Promise((r,n)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>s.result?r(s.result.toString()):n("No result from reader"),s.onerror=n}),$r=e=>e.reduce((r,n)=>r+n.sizeKb,0),Pr=t.isSubmissionOfType("file"),ft=3,jr=({file:e,class:r,...n})=>{const s=e.name.split(".").pop(),a=e.name.replace(new RegExp(`.${s}$`),"");return t.o("div",{class:t.clsx("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",r),...n,children:[t.o("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[t.o("span",{class:"block truncate",children:a}),t.o("span",{children:[".",s]})]}),t.o("p",{"aria-label":"File size",class:"text-accent-11",children:t.kbToReadableSize(e.sizeKb)})]})},ht=({class:e,...r})=>t.o("li",{class:t.clsx("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...r}),Rt=e=>{const r=e.split(".").pop();if(!r)throw new Error("No file extension found");return r?"."+r:""},zr=({allowedExtensions:e,files:r})=>{const n=e.map(s=>s.toLowerCase());return r.every(s=>n.includes(Rt(s.name).toLowerCase()))},Ur=(e,r)=>{const n=Rt(e);return`${e.replace(new RegExp(`${n}$`),"").slice(0,r)}${n}`},qr=({input:e,onSubmitSuccess:r})=>{var v;const n=(v=t.store.current$.value.flow)==null?void 0:v.data.submissions[e.key],[s,a]=t.h(Pr(n)?n.value:[]),[i,o]=t.h(),u=s.length-ft,d=$r(s),p=Ge(),{t:w}=t.useTranslation();return t.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:h=>(h.preventDefault(),o(void 0),s.length===0?o({type:"required",message:w("validation_file")}):e.config.extensions.length>0&&!zr({allowedExtensions:e.config.extensions,files:s})?o({type:"validate",message:`${w("validation_file_ext",{ext:e.config.extensions.join(", ")})}`}):e.config.fileSizeLimitKib&&d>e.config.fileSizeLimitKib?o({type:"max",message:`File size exceeds limit of ${t.kbToReadableSize(e.config.fileSizeLimitKib)}`}):e.config.allowMultiple===!1&&s.length>1?o({type:"invalid",message:w("validation_file_max",{count:1})}):r({type:"file",value:s})),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("label",{ref:p,for:"dropzone-file",class:"border-neutral-8 bg-neutral-2 flex h-48 w-full cursor-pointer flex-col items-center justify-center overflow-hidden rounded-2xl border border-dashed p-4",children:[s.length>0?t.o(t.k,{children:[t.o("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[s.slice(0,ft).map(h=>{const k=h.name.split(".").pop(),y=h.name.replace(new RegExp(`.${k}$`),"");return t.o(ht,{class:"flex overflow-hidden",children:[t.o("span",{class:"block truncate",children:y}),t.o("span",{children:[".",k]})]})}),u>0?t.o(ht,{children:["+",u," file",u!==1?"s":""]}):null]}),t.o("p",{class:"text-neutral-11 text-xs",children:[t.kbToReadableSize(d)," ",s.length>1?"total":""]})]}):t.o("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[t.o("header",{class:"flex flex-col items-center gap-0",children:[t.o("svg",{class:"text-neutral-11 mb-1 h-8 w-8","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 16",children:t.o("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"})}),t.o("p",{class:"text-neutral-12 tracking-[-0.01em]",children:w("upload_file",{count:e.config.allowMultiple?2:1})}),e.config.fileSizeLimitKib?t.o("p",{class:"text-neutral-10 text-xs",children:["(",w("file_max_size",{size:t.kbToReadableSize(e.config.fileSizeLimitKib)}),")"]}):null]}),t.o("aside",{class:"flex flex-col items-center gap-2",children:[t.o("p",{id:"accepted-filetypes",class:"sr-only",children:w("file_extensions")}),t.o("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(h=>t.o("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:h.replace(".","")}))})]})]}),t.o("input",{id:"dropzone-file",onInput:async h=>{t.invariant(h.target instanceof HTMLInputElement);const k=h.target.files?Array.from(h.target.files):[],y=await Promise.allSettled(k.map(async S=>{const E=await Br(S);return{name:Ur(S.name,42),data:E,sizeKb:S.size/1e3}}));if(y.some(({status:S})=>S==="rejected"))return o({type:"invalid",message:"Invalid file"});const A=y.map(S=>S.status==="fulfilled"?S.value:null).filter(Boolean);a(A)},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),t.o("div",{class:"flex h-full flex-col items-center gap-2",children:[t.o(oe,{disabled:s.length===0}),e.config.optional&&t.o(le,{onClick:()=>r(null)})]})]}),t.o(fe,{error:i})]})};var xe=e=>e.type==="checkbox",de=e=>e instanceof Date,z=e=>e==null;const Dt=e=>typeof e=="object";var O=e=>!z(e)&&!Array.isArray(e)&&Dt(e)&&!de(e),Kr=e=>O(e)&&e.target?xe(e.target)?e.target.checked:e.target.value:e,Gr=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Hr=(e,r)=>e.has(Gr(r)),Wr=e=>{const r=e.constructor&&e.constructor.prototype;return O(r)&&r.hasOwnProperty("isPrototypeOf")},He=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ee(e){let r;const n=Array.isArray(e);if(e instanceof Date)r=new Date(e);else if(e instanceof Set)r=new Set(e);else if(!(He&&(e instanceof Blob||e instanceof FileList))&&(n||O(e)))if(r=n?[]:{},!n&&!Wr(e))r=e;else for(const s in e)e.hasOwnProperty(s)&&(r[s]=ee(e[s]));else return e;return r}var we=e=>Array.isArray(e)?e.filter(Boolean):[],R=e=>e===void 0,x=(e,r,n)=>{if(!r||!O(e))return n;const s=we(r.split(/[,[\].]+?/)).reduce((a,i)=>z(a)?a:a[i],e);return R(s)||s===e?R(e[r])?n:e[r]:s},re=e=>typeof e=="boolean";const pt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},H={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Q={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};t.Cn.createContext(null);var Jr=(e,r,n,s=!0)=>{const a={defaultValues:r._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return r._proxyFormState[o]!==H.all&&(r._proxyFormState[o]=!s||H.all),n&&(n[o]=!0),e[o]}});return a},G=e=>O(e)&&!Object.keys(e).length,Zr=(e,r,n,s)=>{n(e);const{name:a,...i}=e;return G(i)||Object.keys(i).length>=Object.keys(r).length||Object.keys(i).find(o=>r[o]===(!s||H.all))},Be=e=>Array.isArray(e)?e:[e];function Xr(e){const r=t.Cn.useRef(e);r.current=e,t.Cn.useEffect(()=>{const n=!e.disabled&&r.current.subject&&r.current.subject.subscribe({next:r.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var J=e=>typeof e=="string",Yr=(e,r,n,s,a)=>J(e)?(s&&r.watch.add(e),x(n,e,a)):Array.isArray(e)?e.map(i=>(s&&r.watch.add(i),x(n,i))):(s&&(r.watchAll=!0),n),We=e=>/^\w*$/.test(e),Ot=e=>we(e.replace(/["|']|\]/g,"").split(/\.|\[/));function F(e,r,n){let s=-1;const a=We(r)?[r]:Ot(r),i=a.length,o=i-1;for(;++s<i;){const u=a[s];let d=n;if(s!==o){const p=e[u];d=O(p)||Array.isArray(p)?p:isNaN(+a[s+1])?{}:[]}e[u]=d,e=e[u]}return e}var Bt=(e,r,n,s,a)=>r?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[s]:a||!0}}:{},mt=e=>({isOnSubmit:!e||e===H.onSubmit,isOnBlur:e===H.onBlur,isOnChange:e===H.onChange,isOnAll:e===H.all,isOnTouch:e===H.onTouched}),gt=(e,r,n)=>!n&&(r.watchAll||r.watch.has(e)||[...r.watch].some(s=>e.startsWith(s)&&/^\.\w+/.test(e.slice(s.length))));const Se=(e,r,n,s)=>{for(const a of n||Object.keys(e)){const i=x(e,a);if(i){const{_f:o,...u}=i;if(o){if(o.refs&&o.refs[0]&&r(o.refs[0],a)&&!s)break;if(o.ref&&r(o.ref,o.name)&&!s)break}else O(u)&&Se(u,r)}}};var Qr=(e,r,n)=>{const s=we(x(e,n));return F(s,"root",r[n]),F(e,n,s),e},Je=e=>e.type==="file",ne=e=>typeof e=="function",Ee=e=>{if(!He)return!1;const r=e?e.ownerDocument:0;return e instanceof(r&&r.defaultView?r.defaultView.HTMLElement:HTMLElement)},Ce=e=>J(e),Ze=e=>e.type==="radio",Ae=e=>e instanceof RegExp;const bt={value:!1,isValid:!1},yt={value:!0,isValid:!0};var $t=e=>{if(Array.isArray(e)){if(e.length>1){const r=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:r,isValid:!!r.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!R(e[0].attributes.value)?R(e[0].value)||e[0].value===""?yt:{value:e[0].value,isValid:!0}:yt:bt}return bt};const vt={isValid:!1,value:null};var Pt=e=>Array.isArray(e)?e.reduce((r,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:r,vt):vt;function xt(e,r,n="validate"){if(Ce(e)||Array.isArray(e)&&e.every(Ce)||re(e)&&!e)return{type:n,message:Ce(e)?e:"",ref:r}}var ce=e=>O(e)&&!Ae(e)?e:{value:e,message:""},wt=async(e,r,n,s,a)=>{const{ref:i,refs:o,required:u,maxLength:d,minLength:p,min:w,max:v,pattern:h,validate:k,name:y,valueAsNumber:A,mount:S,disabled:E}=e._f,g=x(r,y);if(!S||E)return{};const M=o?o[0]:i,$=V=>{s&&M.reportValidity&&(M.setCustomValidity(re(V)?"":V||""),M.reportValidity())},L={},se=Ze(i),te=xe(i),he=se||te,q=(A||Je(i))&&R(i.value)&&R(g)||Ee(i)&&i.value===""||g===""||Array.isArray(g)&&!g.length,X=Bt.bind(null,y,n,L),j=(V,T,N,U=Q.maxLength,K=Q.minLength)=>{const W=V?T:N;L[y]={type:V?U:K,message:W,ref:i,...X(V?U:K,W)}};if(a?!Array.isArray(g)||!g.length:u&&(!he&&(q||z(g))||re(g)&&!g||te&&!$t(o).isValid||se&&!Pt(o).isValid)){const{value:V,message:T}=Ce(u)?{value:!!u,message:u}:ce(u);if(V&&(L[y]={type:Q.required,message:T,ref:M,...X(Q.required,T)},!n))return $(T),L}if(!q&&(!z(w)||!z(v))){let V,T;const N=ce(v),U=ce(w);if(!z(g)&&!isNaN(g)){const K=i.valueAsNumber||g&&+g;z(N.value)||(V=K>N.value),z(U.value)||(T=K<U.value)}else{const K=i.valueAsDate||new Date(g),W=_e=>new Date(new Date().toDateString()+" "+_e),ae=i.type=="time",pe=i.type=="week";J(N.value)&&g&&(V=ae?W(g)>W(N.value):pe?g>N.value:K>new Date(N.value)),J(U.value)&&g&&(T=ae?W(g)<W(U.value):pe?g<U.value:K<new Date(U.value))}if((V||T)&&(j(!!V,N.message,U.message,Q.max,Q.min),!n))return $(L[y].message),L}if((d||p)&&!q&&(J(g)||a&&Array.isArray(g))){const V=ce(d),T=ce(p),N=!z(V.value)&&g.length>+V.value,U=!z(T.value)&&g.length<+T.value;if((N||U)&&(j(N,V.message,T.message),!n))return $(L[y].message),L}if(h&&!q&&J(g)){const{value:V,message:T}=ce(h);if(Ae(V)&&!g.match(V)&&(L[y]={type:Q.pattern,message:T,ref:i,...X(Q.pattern,T)},!n))return $(T),L}if(k){if(ne(k)){const V=await k(g,r),T=xt(V,M);if(T&&(L[y]={...T,...X(Q.validate,T.message)},!n))return $(T.message),L}else if(O(k)){let V={};for(const T in k){if(!G(V)&&!n)break;const N=xt(await k[T](g,r),M,T);N&&(V={...N,...X(T,N.message)},$(N.message),n&&(L[y]=V))}if(!G(V)&&(L[y]={ref:M,...V},!n))return L}}return $(!0),L};function en(e,r){const n=r.slice(0,-1).length;let s=0;for(;s<n;)e=R(e)?s++:e[r[s++]];return e}function tn(e){for(const r in e)if(e.hasOwnProperty(r)&&!R(e[r]))return!1;return!0}function B(e,r){const n=Array.isArray(r)?r:We(r)?[r]:Ot(r),s=n.length===1?e:en(e,n),a=n.length-1,i=n[a];return s&&delete s[i],a!==0&&(O(s)&&G(s)||Array.isArray(s)&&tn(s))&&B(e,n.slice(0,-1)),e}function $e(){let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}}var Te=e=>z(e)||!Dt(e);function ie(e,r){if(Te(e)||Te(r))return e===r;if(de(e)&&de(r))return e.getTime()===r.getTime();const n=Object.keys(e),s=Object.keys(r);if(n.length!==s.length)return!1;for(const a of n){const i=e[a];if(!s.includes(a))return!1;if(a!=="ref"){const o=r[a];if(de(i)&&de(o)||O(i)&&O(o)||Array.isArray(i)&&Array.isArray(o)?!ie(i,o):i!==o)return!1}}return!0}var jt=e=>e.type==="select-multiple",rn=e=>Ze(e)||xe(e),Pe=e=>Ee(e)&&e.isConnected,zt=e=>{for(const r in e)if(ne(e[r]))return!0;return!1};function Ve(e,r={}){const n=Array.isArray(e);if(O(e)||n)for(const s in e)Array.isArray(e[s])||O(e[s])&&!zt(e[s])?(r[s]=Array.isArray(e[s])?[]:{},Ve(e[s],r[s])):z(e[s])||(r[s]=!0);return r}function Ut(e,r,n){const s=Array.isArray(e);if(O(e)||s)for(const a in e)Array.isArray(e[a])||O(e[a])&&!zt(e[a])?R(r)||Te(n[a])?n[a]=Array.isArray(e[a])?Ve(e[a],[]):{...Ve(e[a])}:Ut(e[a],z(r)?{}:r[a],n[a]):n[a]=!ie(e[a],r[a]);return n}var je=(e,r)=>Ut(e,r,Ve(r)),qt=(e,{valueAsNumber:r,valueAsDate:n,setValueAs:s})=>R(e)?e:r?e===""?NaN:e&&+e:n&&J(e)?new Date(e):s?s(e):e;function ze(e){const r=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):r.disabled))return Je(r)?r.files:Ze(r)?Pt(e.refs).value:jt(r)?[...r.selectedOptions].map(({value:n})=>n):xe(r)?$t(e.refs).value:qt(R(r.value)?e.ref.value:r.value,e)}var nn=(e,r,n,s)=>{const a={};for(const i of e){const o=x(r,i);o&&F(a,i,o._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:s}},ge=e=>R(e)?e:Ae(e)?e.source:O(e)?Ae(e.value)?e.value.source:e.value:e,sn=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function _t(e,r,n){const s=x(e,n);if(s||We(n))return{error:s,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),o=x(r,i),u=x(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(u&&u.type)return{name:i,error:u};a.pop()}return{name:n}}var an=(e,r,n,s,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(r||e):(n?s.isOnBlur:a.isOnBlur)?!e:(n?s.isOnChange:a.isOnChange)?e:!0,on=(e,r)=>!we(x(e,r)).length&&B(e,r);const ln={mode:H.onSubmit,reValidateMode:H.onChange,shouldFocusError:!0};function un(e={},r){let n={...ln,...e},s={submitCount:0,isDirty:!1,isLoading:ne(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},a={},i=O(n.defaultValues)||O(n.values)?ee(n.defaultValues||n.values)||{}:{},o=n.shouldUnregister?{}:ee(i),u={action:!1,mount:!1,watch:!1},d={mount:new Set,unMount:new Set,array:new Set,watch:new Set},p,w=0;const v={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={values:$e(),array:$e(),state:$e()},k=e.resetOptions&&e.resetOptions.keepDirtyValues,y=mt(n.mode),A=mt(n.reValidateMode),S=n.criteriaMode===H.all,E=l=>c=>{clearTimeout(w),w=setTimeout(l,c)},g=async l=>{if(v.isValid||l){const c=n.resolver?G((await q()).errors):await j(a,!0);c!==s.isValid&&h.state.next({isValid:c})}},M=l=>v.isValidating&&h.state.next({isValidating:l}),$=(l,c=[],f,_,b=!0,m=!0)=>{if(_&&f){if(u.action=!0,m&&Array.isArray(x(a,l))){const C=f(x(a,l),_.argA,_.argB);b&&F(a,l,C)}if(m&&Array.isArray(x(s.errors,l))){const C=f(x(s.errors,l),_.argA,_.argB);b&&F(s.errors,l,C),on(s.errors,l)}if(v.touchedFields&&m&&Array.isArray(x(s.touchedFields,l))){const C=f(x(s.touchedFields,l),_.argA,_.argB);b&&F(s.touchedFields,l,C)}v.dirtyFields&&(s.dirtyFields=je(i,o)),h.state.next({name:l,isDirty:T(l,c),dirtyFields:s.dirtyFields,errors:s.errors,isValid:s.isValid})}else F(o,l,c)},L=(l,c)=>{F(s.errors,l,c),h.state.next({errors:s.errors})},se=(l,c,f,_)=>{const b=x(a,l);if(b){const m=x(o,l,R(f)?x(i,l):f);R(m)||_&&_.defaultChecked||c?F(o,l,c?m:ze(b._f)):K(l,m),u.mount&&g()}},te=(l,c,f,_,b)=>{let m=!1,C=!1;const I={name:l};if(!f||_){v.isDirty&&(C=s.isDirty,s.isDirty=I.isDirty=T(),m=C!==I.isDirty);const D=ie(x(i,l),c);C=x(s.dirtyFields,l),D?B(s.dirtyFields,l):F(s.dirtyFields,l,!0),I.dirtyFields=s.dirtyFields,m=m||v.dirtyFields&&C!==!D}if(f){const D=x(s.touchedFields,l);D||(F(s.touchedFields,l,f),I.touchedFields=s.touchedFields,m=m||v.touchedFields&&D!==f)}return m&&b&&h.state.next(I),m?I:{}},he=(l,c,f,_)=>{const b=x(s.errors,l),m=v.isValid&&re(c)&&s.isValid!==c;if(e.delayError&&f?(p=E(()=>L(l,f)),p(e.delayError)):(clearTimeout(w),p=null,f?F(s.errors,l,f):B(s.errors,l)),(f?!ie(b,f):b)||!G(_)||m){const C={..._,...m&&re(c)?{isValid:c}:{},errors:s.errors,name:l};s={...s,...C},h.state.next(C)}M(!1)},q=async l=>n.resolver(o,n.context,nn(l||d.mount,a,n.criteriaMode,n.shouldUseNativeValidation)),X=async l=>{const{errors:c}=await q(l);if(l)for(const f of l){const _=x(c,f);_?F(s.errors,f,_):B(s.errors,f)}else s.errors=c;return c},j=async(l,c,f={valid:!0})=>{for(const _ in l){const b=l[_];if(b){const{_f:m,...C}=b;if(m){const I=d.array.has(m.name),D=await wt(b,o,S,n.shouldUseNativeValidation&&!c,I);if(D[m.name]&&(f.valid=!1,c))break;!c&&(x(D,m.name)?I?Qr(s.errors,D,m.name):F(s.errors,m.name,D[m.name]):B(s.errors,m.name))}C&&await j(C,c,f)}}return f.valid},V=()=>{for(const l of d.unMount){const c=x(a,l);c&&(c._f.refs?c._f.refs.every(f=>!Pe(f)):!Pe(c._f.ref))&&Ne(l)}d.unMount=new Set},T=(l,c)=>(l&&c&&F(o,l,c),!ie(Xe(),i)),N=(l,c,f)=>Yr(l,d,{...u.mount?o:R(c)?i:J(l)?{[l]:c}:c},f,c),U=l=>we(x(u.mount?o:i,l,e.shouldUnregister?x(i,l,[]):[])),K=(l,c,f={})=>{const _=x(a,l);let b=c;if(_){const m=_._f;m&&(!m.disabled&&F(o,l,qt(c,m)),b=Ee(m.ref)&&z(c)?"":c,jt(m.ref)?[...m.ref.options].forEach(C=>C.selected=b.includes(C.value)):m.refs?xe(m.ref)?m.refs.length>1?m.refs.forEach(C=>(!C.defaultChecked||!C.disabled)&&(C.checked=Array.isArray(b)?!!b.find(I=>I===C.value):b===C.value)):m.refs[0]&&(m.refs[0].checked=!!b):m.refs.forEach(C=>C.checked=C.value===b):Je(m.ref)?m.ref.value="":(m.ref.value=b,m.ref.type||h.values.next({name:l,values:{...o}})))}(f.shouldDirty||f.shouldTouch)&&te(l,b,f.shouldTouch,f.shouldDirty,!0),f.shouldValidate&&Le(l)},W=(l,c,f)=>{for(const _ in c){const b=c[_],m=`${l}.${_}`,C=x(a,m);(d.array.has(l)||!Te(b)||C&&!C._f)&&!de(b)?W(m,b,f):K(m,b,f)}},ae=(l,c,f={})=>{const _=x(a,l),b=d.array.has(l),m=ee(c);F(o,l,m),b?(h.array.next({name:l,values:{...o}}),(v.isDirty||v.dirtyFields)&&f.shouldDirty&&h.state.next({name:l,dirtyFields:je(i,o),isDirty:T(l,m)})):_&&!_._f&&!z(m)?W(l,m,f):K(l,m,f),gt(l,d)&&h.state.next({...s}),h.values.next({name:l,values:{...o}}),!u.mount&&r()},pe=async l=>{const c=l.target;let f=c.name,_=!0;const b=x(a,f),m=()=>c.type?ze(b._f):Kr(l),C=I=>{_=Number.isNaN(I)||I===x(o,f,I)};if(b){let I,D;const ke=m(),ue=l.type===pt.BLUR||l.type===pt.FOCUS_OUT,Zt=!sn(b._f)&&!n.resolver&&!x(s.errors,f)&&!b._f.deps||an(ue,x(s.touchedFields,f),s.isSubmitted,A,y),De=gt(f,d,ue);F(o,f,ke),ue?(b._f.onBlur&&b._f.onBlur(l),p&&p(0)):b._f.onChange&&b._f.onChange(l);const Oe=te(f,ke,ue,!1),Xt=!G(Oe)||De;if(!ue&&h.values.next({name:f,type:l.type,values:{...o}}),Zt)return v.isValid&&g(),Xt&&h.state.next({name:f,...De?{}:Oe});if(!ue&&De&&h.state.next({...s}),M(!0),n.resolver){const{errors:at}=await q([f]);if(C(ke),_){const Yt=_t(s.errors,a,f),it=_t(at,a,Yt.name||f);I=it.error,f=it.name,D=G(at)}}else I=(await wt(b,o,S,n.shouldUseNativeValidation))[f],C(ke),_&&(I?D=!1:v.isValid&&(D=await j(a,!0)));_&&(b._f.deps&&Le(b._f.deps),he(f,D,I,Oe))}},_e=(l,c)=>{if(x(s.errors,c)&&l.focus)return l.focus(),1},Le=async(l,c={})=>{let f,_;const b=Be(l);if(M(!0),n.resolver){const m=await X(R(l)?l:b);f=G(m),_=l?!b.some(C=>x(m,C)):f}else l?(_=(await Promise.all(b.map(async m=>{const C=x(a,m);return await j(C&&C._f?{[m]:C}:C)}))).every(Boolean),!(!_&&!s.isValid)&&g()):_=f=await j(a);return h.state.next({...!J(l)||v.isValid&&f!==s.isValid?{}:{name:l},...n.resolver||!l?{isValid:f}:{},errors:s.errors,isValidating:!1}),c.shouldFocus&&!_&&Se(a,_e,l?b:d.mount),_},Xe=l=>{const c={...i,...u.mount?o:{}};return R(l)?c:J(l)?x(c,l):l.map(f=>x(c,f))},Ye=(l,c)=>({invalid:!!x((c||s).errors,l),isDirty:!!x((c||s).dirtyFields,l),isTouched:!!x((c||s).touchedFields,l),error:x((c||s).errors,l)}),Gt=l=>{l&&Be(l).forEach(c=>B(s.errors,c)),h.state.next({errors:l?s.errors:{}})},Qe=(l,c,f)=>{const _=(x(a,l,{_f:{}})._f||{}).ref;F(s.errors,l,{...c,ref:_}),h.state.next({name:l,errors:s.errors,isValid:!1}),f&&f.shouldFocus&&_&&_.focus&&_.focus()},Ht=(l,c)=>ne(l)?h.values.subscribe({next:f=>l(N(void 0,c),f)}):N(l,c,!0),Ne=(l,c={})=>{for(const f of l?Be(l):d.mount)d.mount.delete(f),d.array.delete(f),c.keepValue||(B(a,f),B(o,f)),!c.keepError&&B(s.errors,f),!c.keepDirty&&B(s.dirtyFields,f),!c.keepTouched&&B(s.touchedFields,f),!n.shouldUnregister&&!c.keepDefaultValue&&B(i,f);h.values.next({values:{...o}}),h.state.next({...s,...c.keepDirty?{isDirty:T()}:{}}),!c.keepIsValid&&g()},et=({disabled:l,name:c,field:f,fields:_,value:b})=>{if(re(l)){const m=l?void 0:R(b)?ze(f?f._f:x(_,c)._f):b;F(o,c,m),te(c,m,!1,!1,!0)}},Re=(l,c={})=>{let f=x(a,l);const _=re(c.disabled);return F(a,l,{...f||{},_f:{...f&&f._f?f._f:{ref:{name:l}},name:l,mount:!0,...c}}),d.mount.add(l),f?et({field:f,disabled:c.disabled,name:l}):se(l,!0,c.value),{..._?{disabled:c.disabled}:{},...n.progressive?{required:!!c.required,min:ge(c.min),max:ge(c.max),minLength:ge(c.minLength),maxLength:ge(c.maxLength),pattern:ge(c.pattern)}:{},name:l,onChange:pe,onBlur:pe,ref:b=>{if(b){Re(l,c),f=x(a,l);const m=R(b.value)&&b.querySelectorAll&&b.querySelectorAll("input,select,textarea")[0]||b,C=rn(m),I=f._f.refs||[];if(C?I.find(D=>D===m):m===f._f.ref)return;F(a,l,{_f:{...f._f,...C?{refs:[...I.filter(Pe),m,...Array.isArray(x(i,l))?[{}]:[]],ref:{type:m.type,name:l}}:{ref:m}}}),se(l,!1,void 0,m)}else f=x(a,l,{}),f._f&&(f._f.mount=!1),(n.shouldUnregister||c.shouldUnregister)&&!(Hr(d.array,l)&&u.action)&&d.unMount.add(l)}}},tt=()=>n.shouldFocusError&&Se(a,_e,d.mount),Wt=l=>{re(l)&&(h.state.next({disabled:l}),Se(a,c=>{c.disabled=l},0,!1))},rt=(l,c)=>async f=>{f&&(f.preventDefault&&f.preventDefault(),f.persist&&f.persist());let _=ee(o);if(h.state.next({isSubmitting:!0}),n.resolver){const{errors:b,values:m}=await q();s.errors=b,_=m}else await j(a);B(s.errors,"root"),G(s.errors)?(h.state.next({errors:{}}),await l(_,f)):(c&&await c({...s.errors},f),tt(),setTimeout(tt)),h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(s.errors),submitCount:s.submitCount+1,errors:s.errors})},Jt=(l,c={})=>{x(a,l)&&(R(c.defaultValue)?ae(l,x(i,l)):(ae(l,c.defaultValue),F(i,l,c.defaultValue)),c.keepTouched||B(s.touchedFields,l),c.keepDirty||(B(s.dirtyFields,l),s.isDirty=c.defaultValue?T(l,x(i,l)):T()),c.keepError||(B(s.errors,l),v.isValid&&g()),h.state.next({...s}))},nt=(l,c={})=>{const f=l?ee(l):i,_=ee(f),b=l&&!G(l)?_:i;if(c.keepDefaultValues||(i=f),!c.keepValues){if(c.keepDirtyValues||k)for(const m of d.mount)x(s.dirtyFields,m)?F(b,m,x(o,m)):ae(m,x(b,m));else{if(He&&R(l))for(const m of d.mount){const C=x(a,m);if(C&&C._f){const I=Array.isArray(C._f.refs)?C._f.refs[0]:C._f.ref;if(Ee(I)){const D=I.closest("form");if(D){D.reset();break}}}}a={}}o=e.shouldUnregister?c.keepDefaultValues?ee(i):{}:ee(b),h.array.next({values:{...b}}),h.values.next({values:{...b}})}d={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!u.mount&&r(),u.mount=!v.isValid||!!c.keepIsValid,u.watch=!!e.shouldUnregister,h.state.next({submitCount:c.keepSubmitCount?s.submitCount:0,isDirty:c.keepDirty?s.isDirty:!!(c.keepDefaultValues&&!ie(l,i)),isSubmitted:c.keepIsSubmitted?s.isSubmitted:!1,dirtyFields:c.keepDirtyValues?s.dirtyFields:c.keepDefaultValues&&l?je(i,l):{},touchedFields:c.keepTouched?s.touchedFields:{},errors:c.keepErrors?s.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?s.isSubmitSuccessful:!1,isSubmitting:!1})},st=(l,c)=>nt(ne(l)?l(o):l,c);return{control:{register:Re,unregister:Ne,getFieldState:Ye,handleSubmit:rt,setError:Qe,_executeSchema:q,_getWatch:N,_getDirty:T,_updateValid:g,_removeUnmounted:V,_updateFieldArray:$,_updateDisabledField:et,_getFieldArray:U,_reset:nt,_resetDefaultValues:()=>ne(n.defaultValues)&&n.defaultValues().then(l=>{st(l,n.resetOptions),h.state.next({isLoading:!1})}),_updateFormState:l=>{s={...s,...l}},_disableForm:Wt,_subjects:h,_proxyFormState:v,get _fields(){return a},get _formValues(){return o},get _state(){return u},set _state(l){u=l},get _defaultValues(){return i},get _names(){return d},set _names(l){d=l},get _formState(){return s},set _formState(l){s=l},get _options(){return n},set _options(l){n={...n,...l}}},trigger:Le,register:Re,handleSubmit:rt,watch:Ht,setValue:ae,getValues:Xe,reset:st,resetField:Jt,clearErrors:Gt,unregister:Ne,setError:Qe,setFocus:(l,c={})=>{const f=x(a,l),_=f&&f._f;if(_){const b=_.refs?_.refs[0]:_.ref;b.focus&&(b.focus(),c.shouldSelect&&b.select())}},getFieldState:Ye}}function Fe(e={}){const r=t.Cn.useRef(),n=t.Cn.useRef(),[s,a]=t.Cn.useState({isDirty:!1,isValidating:!1,isLoading:ne(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:ne(e.defaultValues)?void 0:e.defaultValues});r.current||(r.current={...un(e,()=>a(o=>({...o}))),formState:s});const i=r.current.control;return i._options=e,Xr({subject:i._subjects.state,next:o=>{Zr(o,i._proxyFormState,i._updateFormState,!0)&&a({...i._formState})}}),t.Cn.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),t.Cn.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==s.isDirty&&i._subjects.state.next({isDirty:o})}},[i,s.isDirty]),t.Cn.useEffect(()=>{e.values&&!ie(e.values,n.current)?(i._reset(e.values,i._options.resetOptions),n.current=e.values):i._resetDefaultValues()},[e.values,i]),t.Cn.useEffect(()=>{i._state.mount||(i._updateValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),r.current.formState=Jr(s,i),r.current}var kt=function(e,r,n){if(e&&"reportValidity"in e){var s=x(n,r);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},cn=function(e,r){var n=function(a){var i=r.fields[a];i&&i.ref&&"reportValidity"in i.ref?kt(i.ref,a,e):i.refs&&i.refs.forEach(function(o){return kt(o,a,e)})};for(var s in r.fields)n(s)},dn=function(e,r){r.shouldUseNativeValidation&&cn(e,r);var n={};for(var s in e){var a=x(r.fields,s),i=Object.assign(e[s]||{},{ref:a&&a.ref});if(hn(r.names||Object.keys(e),s)){var o=Object.assign({},fn(x(n,s)));F(o,"root",i),F(n,s,o)}else F(n,s,i)}return n},fn=function(e){return Array.isArray(e)?e.filter(Boolean):[]},hn=function(e,r){return e.some(function(n){return n.startsWith(r+".")})},pn=function(e,r){for(var n={};e.issues.length;){var s=e.issues[0];if(s.path){var a=s.path.map(function(u){return u.key}).join(".");if(n[a]||(n[a]={message:s.message,type:s.validation}),r){var i=n[a].types,o=i&&i[s.validation];n[a]=Bt(a,r,n,s.validation,o?[].concat(o,s.message):s.message)}e.issues.shift()}}return n},Ie=function(e,r,n){return n===void 0&&(n={}),function(s,a,i){try{return Promise.resolve(function(o,u){try{var d=function(){function p(v){return{values:n.raw?s:v,errors:{}}}var w=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},r);return n.mode==="sync"?p(t.parse(e,s,w)):Promise.resolve(t.parseAsync(e,s,w)).then(p)}()}catch(p){return u(p)}return d&&d.then?d.then(void 0,u):d}(0,function(o){if(o instanceof t.ValiError)return{values:{},errors:dn(pn(o,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}}};const St=27,Ct=12,Et=10,mn=t.isSubmissionOfType("enum"),gn=(e,r)=>{const n={min:e.minSelected??0,max:e.maxSelected??e.options.length};return Ie(t.object({checked:t.pipe(t.record(t.string(),t.boolean()),t.transform(s=>Object.entries(s).filter(([a,i])=>i).map(([a,i])=>a)),t.maxLength(n.max,r("validation_multiple_choice_max",{count:n.max})),t.minLength(n.min,r("validation_multiple_choice_min",{count:n.min})))}))},bn=t.k$1(({option:e,...r},n)=>t.o(t.k,{children:[t.o("input",{class:"peer sr-only h-full",type:"checkbox",...r,ref:n}),t.o("label",{class:"bg-lowest hover:bg-neutral-2 active:outline-neutral-8 ease-expo-out outline-divider text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 peer-focus-visible:ring-accent-9 peer-focus-visible:ring-offset-accent-7 block cursor-pointer select-none rounded-2xl px-3 py-1.5 outline outline-1 ring-0 ring-transparent transition-all selection:bg-transparent peer-focus-visible:ring-4",htmlFor:r.id,children:e.label})]})),At=t.cva("gutter-stable flex w-full flex-1 flex-wrap gap-3 overflow-y-auto rounded-xl p-2.5 pr-4",{variants:{variant:{singleOption:"justify-center",booleanLike:Lt}}}),yn=({input:e,onSubmitSuccess:r})=>{var w,v;const n=e.key?(w=t.store.current$.value.flow)==null?void 0:w.data.submissions[e.key]:void 0,s=(e.config.minSelected===1||e.config.minSelected===void 0)&&e.config.maxSelected===1,a=s&&e.config.options.length===2,{t:i}=t.useTranslation(),{register:o,handleSubmit:u,formState:{errors:d}}=Fe({defaultValues:{checked:s?{}:mn(n)?Object.fromEntries(n.value.map(h=>[h,!0])):{}},resolver:gn(e.config,i)}),p=Ge();return a?t.o("ul",{style:{maxHeight:6.5*St+5*Ct+2*Et},class:At({variant:"booleanLike"}),children:e.config.options.map((h,k)=>t.o("li",{class:"flex-1",children:t.o(Nt,{type:"submit",ref:y=>{y&&k===0&&(p.current=y)},label:h.label,value:"true",onClick:()=>r({type:"enum",value:[h.value]})})},h.value))}):t.o("form",{noValidate:!0,onSubmit:h=>u(k=>{const y=k.checked;r({type:"enum",value:y})})(h),children:[t.o("div",{class:"flex items-center gap-1",children:[t.o("ul",{style:{maxHeight:6.5*St+5*Ct+2*Et},class:At({variant:e.config.options.length===1?"singleOption":void 0}),children:e.config.options.map((h,k)=>{const y=`checked.${h.value}`,{ref:A,...S}=o(y);return t.o("li",{class:"relative",children:t.o(bn,{option:h,autoFocus:k===0,ref:E=>{E&&k===0&&(p.current=E),A(E)},id:y,...S,onClick:s?()=>r({type:"enum",value:[h.value]}):void 0})},h.value)})}),t.o("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[s?null:t.o(oe,{}),e.config.minSelected===0&&t.o(le,{type:"button",onClick:()=>r({type:"enum",value:[]})})]})]}),t.o("div",{class:"px-1",children:t.o(fe,{error:(v=d.checked)==null?void 0:v.root})})]})},vn=t.isSubmissionOfType("number"),xn=(e,r)=>{const n=e.min??Number.MIN_SAFE_INTEGER,s=e.max??Number.MAX_SAFE_INTEGER,a=e.decimalCases??0;return Ie(t.object({number:t.pipe(t.number(r("validation_number")),t.minValue(n,r("validation_number_min",{min:n})),t.maxValue(s,r("validation_number_max",{max:s})),t.check(i=>i===Number(i.toFixed(a)),r("validation_number_decimal_cases",{count:a})))}))},wn=({input:e,onSubmitSuccess:r})=>{var v;const n=e.config.defaultValue,s=e.key?(v=t.store.current$.value.flow)==null?void 0:v.data.submissions[e.key]:void 0,{t:a}=t.useTranslation(),{register:i,handleSubmit:o,formState:{errors:u}}=Fe({defaultValues:{number:n?Number(n):vn(s)?s.value:void 0},resolver:xn(e.config,a)}),{ref:d,...p}=i("number",{required:!e.config.optional,valueAsNumber:!0}),w=t._$1();return t.y(()=>{w.current&&(w.current.focus(),w.current.select())},[]),t.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:o(h=>{h.number!==void 0&&r({type:"number",value:h.number})}),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("div",{class:"relative min-w-0 flex-grow",children:[t.o("input",{...p,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(w.current=h),d(h)},type:"text",min:e.config.min,max:e.config.max,class:ve({optional:e.config.optional,className:"[type=number:-webkit-inner-spin-button] w-full rounded-full [-webkit-outer-spin-button:none]"}),placeholder:e.config.placeholder}),e.config.optional&&t.o(le,{class:"absolute right-0 top-0",onClick:()=>r(null)})]}),t.o(oe,{})]}),t.o(fe,{error:u.number})]})},_n=e=>{if(e==="")return{countryCode:"",phoneNumber:""};const r=Object.entries(Ke).find(a=>e.startsWith(a[1])),n=r?r[1]:"",s=e.replace(n,"");return/^\d+$/.test(s)?{countryCode:n,phoneNumber:s}:{countryCode:"",phoneNumber:""}},kn="44",Sn=/^[0-9 ]+$/,Cn=t.isSubmissionOfType("string"),En=t.isSubmissionOfType("phone"),An=e=>{const r=t.pipe(t.string(e("validation_country_code")),t.regex(Sn,e("validation_country_code"))),n=t.pipe(t.string(e("validation_phone")),t.minLength(1,e("validation_phone")),t.transform(s=>s.replace(/[^0-9]/g,"")));return Ie(t.object({countryCode:r,phoneNumber:n}))},Tn=({input:e,onSubmitSuccess:r})=>{var A;const n=e.key?(A=t.store.current$.value.flow)==null?void 0:A.data.submissions[e.key]:void 0,{t:s}=t.useTranslation(),[a,i]=t.h(),o=Cn(n)?_n(n.value):En(n)?n.value:void 0,{register:u,handleSubmit:d,formState:{errors:p},watch:w}=Fe({defaultValues:{countryCode:(o==null?void 0:o.countryCode)??e.config.defaultValue.countryCode??kn,phoneNumber:(o==null?void 0:o.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:An(s)}),{ref:v,...h}=u("phoneNumber",{required:!e.config.optional}),k=t._$1(),y=w("countryCode");return t.y(()=>{k.current&&(k.current.focus(),k.current.select())},[]),t.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:d(S=>{const E=S.phoneNumber.replace(/[^0-9]/g,""),g=S.countryCode.replace(/[^0-9]/g,"");i(void 0);const M=e.config.minChars??7;if(E.length+g.length<M)return i(s("validation_phone_min_chars",{count:M}));e.config.submissionFormat==="phone"?r({type:"phone",value:{countryCode:g,phoneNumber:E}}):r({type:"string",value:y+S.phoneNumber})}),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("div",{class:"relative flex min-w-0 flex-1 flex-grow gap-2",children:[t.o("label",{class:"text-neutral-12 bg-lowest hover:bg-neutral-5 placeholder:text-neutral-8 focus-visible:outline-accent-7 focus-within:bg-neutral-5 focus-within:outline-accent-7 outline-divider relative flex h-full cursor-pointer appearance-none items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-l-full border-solid px-3 py-1.5 text-center text-base outline outline-2 transition-all focus-within:outline-none",htmlFor:`isdk_phone_${e.key}`,children:[t.o("span",{children:["+",y]}),t.o("select",{...u("countryCode",{}),id:`isdk_phone_${e.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(Ke).map(([S,E])=>t.o("option",{value:E,children:[S," (+",E,")"]},S))})]}),t.o("input",{...h,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:S=>{S&&(k.current=S),v(S)},class:ve({optional:e.config.optional,className:"min-w-0 flex-1 rounded-r-full"}),placeholder:e.config.placeholder}),e.config.optional&&t.o(le,{class:"absolute bottom-0 right-0 top-0",onClick:()=>r(null)})]}),t.o(oe,{})]}),t.o(fe,{error:p.countryCode||p.phoneNumber||{message:a}})]})},Vn=({input:e,onSubmitSuccess:r})=>t.o("div",{class:"flex flex-col items-center py-3",children:t.o("button",{class:"bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:ring-2 active:ring-offset-2",name:e.key,onClick:()=>{r(null)},children:t.o("span",{class:"flex items-center gap-1.5",children:[t.o("span",{class:"inline-flex items-center text-sm font-medium",children:e.config.label||"Submit"}),t.o("svg",{stroke:"currentColor","stroke-width":"1.5",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.o("path",{d:"M4 8L8 4L12 8"}),t.o("path",{d:"M8 4V13"})]})]})})}),Mn={email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},Fn=t.isSubmissionOfType("string"),In=(e,r)=>{const n={maxLength:r("validation_max_chars",{count:e.maxChars??999}),minLength:r("validation_min_chars",{count:e.minChars??1})};return Ie(t.object({text:{email:t.pipe(t.string(r("validation_email")),t.email(r("validation_email")),t.minLength(e.minChars??1,n.minLength),t.maxLength(e.maxChars??1/0,n.maxLength)),text:t.pipe(t.string(),t.minLength(e.minChars??1,n.minLength),t.maxLength(e.maxChars??1/0,n.maxLength)),url:t.pipe(t.string(r("validation_url")),t.url(r("validation_url")),t.minLength(e.minChars??1,n.minLength),t.maxLength(e.maxChars??1/0,n.maxLength))}[e.format]}))},Ln=({input:e,onSubmitSuccess:r})=>{var v;const{t:n}=t.useTranslation(),s=e.key?(v=t.store.current$.value.flow)==null?void 0:v.data.submissions[e.key]:void 0,a=e.config.defaultValue,{register:i,handleSubmit:o,formState:{errors:u}}=Fe({defaultValues:{text:a||(Fn(s)?s.value:"")},resolver:In(e.config,n)}),{ref:d,...p}=i("text",{required:!e.config.optional}),w=t._$1();return t.y(()=>{w.current&&(w.current.focus(),w.current.select())},[]),t.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:o(h=>{r({type:"string",value:h.text})}),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("div",{class:"relative min-w-0 flex-1",children:[t.o("input",{id:"chat-input",...p,...Mn[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(w.current=h),d(h)},placeholder:e.config.placeholder,class:ve({optional:!!e.config.optional,className:"w-full rounded-full"})}),e.config.optional&&t.o(le,{class:"absolute right-0 top-0",onClick:()=>r(null)})]}),t.o(oe,{})]}),t.o(fe,{error:u.text})]})},Nn={text:Ln,phone:Tn,"multiple-choice":yn,boolean:Or,file:qr,submit:Vn,address:Lr,number:wn},Rn=({logger:e})=>{var i;const r=(i=t.store.current$.value.flow)==null?void 0:i.data.currentInput,[n,s]=wr(),a=t._$1(null);return t.store.inputHeight$.value=s.height,t.p(()=>{const o=a.current;if(o)return o.addEventListener("transitionstart",P.scrollToEnd.smooth),o.addEventListener("transitioncancel",P.scrollToEnd.smooth),o.addEventListener("transitionend",P.scrollToEnd.smooth),()=>{o.removeEventListener("transitionstart",P.scrollToEnd.smooth),o.removeEventListener("transitioncancel",P.scrollToEnd.smooth),o.removeEventListener("transitionend",P.scrollToEnd.smooth)}},[]),t.o("div",{ref:a,class:"ease-expo-out absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-xl transition-all duration-700 will-change-[height]",style:{height:s.height},children:t.o("div",{ref:n,class:"border-divider flex flex-col justify-end border-t",children:r?(()=>{const o=Nn[r.type];return t.o(o,{logger:e,onSubmitSuccess:P.onSubmitSuccessFn$.value,input:r})})():t.o("div",{class:"flex items-center gap-2 p-2.5",children:[t.o("input",{"aria-hidden":"true",id:"chat-input",class:ve({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),t.o(oe,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};var Dn=function(e){return e instanceof RegExp},On=function(r){var n=/[\\^$.*+?()[\]{}|]/g,s=RegExp(n.source);return r&&s.test(r)?r.replace(n,"\\$&"):r},Kt=function(e){return typeof e=="string"},Bn=function(e){var r=[];return e.forEach(function(n){Array.isArray(n)?r=r.concat(n):r.push(n)}),r};function $n(e,r,n){var s=0,a=0;if(e==="")return e;if(!e||!Kt(e))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var i=r;Dn(i)||(i=new RegExp("("+On(i)+")","gi"));for(var o=e.split(i),u=1,d=o.length;u<d;u+=2){if(o[u]===void 0||o[u-1]===void 0){console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");continue}a=o[u].length,s+=o[u-1].length,o[u]=n(o[u],u,s),s+=a}return o}var Pn=function(r,n,s){return Array.isArray(r)||(r=[r]),Bn(r.map(function(a){return Kt(a)?$n(a,n,s):a}))};const be=t.getDefaultExportFromCjs(Pn),jn=/(\[[^\]]+\]\([^)]+\))/g,zn=/\[([^\]]+)\]\(([^)]+)\)/,Un=/(https?:\/\/[^\s]+)/g,qn=/_(.*?)_/g,Kn=/\*\*(.*?)\*\*/g,Gn=/\\n|\n/g,Tt="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",Hn=e=>{const r=be(e,jn,(o,u)=>{const[,d,p]=o.match(zn)??[];return p?t.o("a",{class:Tt,href:p,children:d??p},p+u):t.o("span",{children:"INVALID LINK"})}),n=be(r,Un,(o,u)=>t.o("a",{class:Tt,href:o,children:o},o+u)),s=be(n,qn,(o,u)=>t.o("em",{children:o},o+u)),a=be(s,Kn,(o,u)=>t.o("strong",{children:o},o+u));return be(a,Gn,(o,u)=>t.o("br",{},`br-${u}`))},Wn=t.cva("select-text max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative",{variants:{side:{left:"bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",right:"ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"},animate:{true:"animate-bubble-in",false:""}},defaultVariants:{side:"left"}}),Jn=({children:e,className:r,animate:n,side:s,...a})=>t.o("p",{style:{transformOrigin:s==="left"?"0% 50%":"100% 50%"},class:Wn({className:r,side:s,animate:n}),...a,children:e}),Zn=({message:e})=>t.o("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:t.o("a",{onClick:e.onClick,class:"bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:e.href,children:[e.text,t.o("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.o("path",{d:"M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",fill:"currentColor","fill-rule":"evenodd","clip-rule":"evenodd"})})]})}),Xn=({className:e,...r})=>(t.p(()=>{P.scrollToEnd.smooth()}),t.o("div",{"aria-hidden":!0,children:P.isBotTyping$.value===!0?t.o("div",{"aria-label":"Typing…",class:t.clsx("flex gap-1 p-4",e),...r,children:Array.from({length:3},(n,s)=>t.o("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-s*200}ms`}}))}):void 0})),Yn={bot:"left",user:"right"},Qn=t.cva("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]",{variants:{variant:{info:"text-neutral-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),es=({lastSentMessageFooter:e})=>{var n;const r=((n=t.store.current$.value.flow)==null?void 0:n.data.messages)??[];return t.p(()=>{P.scrollToEnd.smooth()},[r.length]),t.o("ol",{"aria-label":"Chat messages",class:"mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[r.map((s,a)=>t.o(t.k,{children:t.o("li",{class:"flex",children:t.N(s).with({type:"system"},i=>t.o("p",{class:Qn({variant:i.variant}),children:i.text})).with({type:"text",author:t._.union("bot","user")},i=>{const o=i.author==="user"&&!r.slice(a+1).some(p=>p.type==="text"&&p.author==="user"),u=a===r.length-1,d=i.author==="bot"?Hn(i.text):i.text;return t.o(t.k,{children:[o?e:null,t.o(Jn,{animate:u,side:Yn[i.author],children:d},a)]})}).with({type:"link"},i=>t.o(Zn,{message:i})).with({type:"image"},i=>t.o("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:i.url,style:{aspectRatio:i.width/i.height}})).with({type:"file"},i=>t.o(jr,{class:i.author==="bot"?void 0:"ml-auto",file:{name:i.fileName,sizeKb:i.fileSizeKb}})).with({type:"loading"},i=>{const o=r[r.length-1];return!(i===o)||P.isBotTyping$.value?null:t.o("div",{class:"flex flex-grow flex-col items-center justify-center",children:t.o(t.LoadingIndicator,{class:"text-neutral-6 h-8 w-8"})})}).exhaustive()})},a)),t.o(Xn,{},"typing")]})},ts=({logger:e,apiClient:r,analytics:n})=>{const{flow:s}=t.store.current$.value;t.invariant(s,"Flow is required to exist to show chatbot body");const a=t.store.viewState$.value,{chatRef:i,chatService:o}=Ar(),{t:u}=t.useTranslation(),[d,p]=t.h();return t.y(()=>{a==="maximised"&&P.scrollToEnd.instant()},[a]),t.y(()=>{var S,E;const{state:w,flow:v}=t.store.current$.peek();if(w!=="loaded")throw new Error(u("invalid_state"));let h=v.data.nodeHistory.at(-1);if(P.scrollToEnd.instant(),t.store.setInput(void 0),v.data.isFinished)return;h===void 0?(h=t.getHeadOrThrow(s.nodes).id,t.store.setCurrentNodeId(h),n.log({event:"FLOW_START",properties:{flow_id:s.id,flow_version:s.version,flow_session_id:v.data.flowSessionId,flow_build:s.build,job:s.job},customProperties:(S=s.analytics)==null?void 0:S.customProperties})):t.store.removeMessagesSentByNodeIds([h]);const{interpret:k,abort:y,undo:A}=tr({context:s.context,analytics:{service:n,customProperties:(E=s.analytics)==null?void 0:E.customProperties},apiClient:r,logger:e,flow:s,chatService:o,t:u,getSubmissions:()=>{var g;return(g=t.store.current$.peek().flow)==null?void 0:g.data.submissions},onInterpret:g=>t.store.setCurrentNodeId(g.id),onFlowEnd:async()=>{var M;t.store.markAsFinished();const g=t.store.current$.peek().flow;t.invariant(g),n.log({event:"FLOW_END",properties:{flow_id:s.id,flow_version:s.version,flow_session_id:g.data.flowSessionId,flow_build:s.build,job:s.job},customProperties:(M=s.analytics)==null?void 0:M.customProperties})}});return p(()=>A),k(h),y},[n,r,o,e,s,u]),t.o(t.k,{children:[t.o("div",{ref:i,className:"hide-scrollbars relative flex w-full max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:t.store.inputHeight$.value},children:t.o(es,{lastSentMessageFooter:s.data.isFinished||!d?null:t.o(ns,{undoFn:d})})}),t.o(Rn,{logger:e})]})},rs=e=>e.type==="identify"?[]:"key"in e.data&&e.data.key?[e.data.key]:"keys"in e.data?Object.values(e.data.keys).filter(r=>typeof r=="string"):[],ns=({undoFn:e})=>{const{t:r}=t.useTranslation();return t.o(t.SvgIconButton,{onClick:async()=>{const{flow:n}=t.store.current$.peek();t.invariant(n);const{removed:s}=e(n.data.nodeHistory),a=n.data.nodeHistory.splice(-s);a.length!==0&&(t.store.removeMessagesSentByNodeIds(a),t.store.setInput(void 0),a.pop(),a.map(i=>n.nodes.find(o=>o.id===i)).filter(Boolean).flatMap(rs).forEach(i=>delete n.data.submissions[i]),t.store.current$.value={...t.store.current$.value})},children:[t.o("title",{children:r("undo")}),t.o("path",{d:"M3 13h2.67l6.66-6.67a1.9 1.9 0 0 0 0-2.66 1.91 1.91 0 0 0-2.66 0L3 10.33V13Zm4.6-7.25 2.67 2.67"})]})};exports.ChatbotBody=ts;
@@ -1,4 +1,4 @@
1
- import { g as Ke, i as er, k as Te, a as tr, b as fe, A as Le, c as Mr, N as Ge, _ as T, d as rr, h as ee, e as re, p as le, F as mt, u as G, o as l, f as Re, j as ft, y as pe, s as I, l as Xe, m as ve, n as Fr, q as he, r as Lr, t as it, v as X, w as Nr, x as nr, z as Tr, B as sr, C as Dr, D as Ce, E as Y, G as Rr, V as Or, H as be, I as De, J as ze, K as ar, L as Br, M as Pr, O as $r, P as jr, Q as zr, R as Ur, S as qr, T as Kr, U as Gr, W as Hr, X as Wr } from "./index-06a5df34.js";
1
+ import { g as Ke, i as er, k as Te, a as tr, b as fe, A as Le, c as Mr, N as Ge, _ as T, d as rr, h as ee, e as re, p as le, F as mt, u as G, o as l, f as Re, j as ft, y as pe, s as I, l as Xe, m as ve, n as Fr, q as he, r as Lr, t as it, v as X, w as Nr, x as nr, z as Tr, B as sr, C as Dr, D as Ce, E as Y, G as Rr, V as Or, H as be, I as De, J as ze, K as ar, L as Br, M as Pr, O as $r, P as jr, Q as zr, R as Ur, S as qr, T as Kr, U as Gr, W as Hr, X as Wr } from "./index-20ae56ee.js";
2
2
  import "@inploi/sdk";
3
3
  const Lt = ({
4
4
  condition: e,