@inploi/plugin-chatbot 3.30.0 → 4.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.
- package/cdn/index.js +3 -43
- package/cdn/style.css +1 -1
- package/dist/chatbot-body-2c87c7e2.cjs +1 -0
- package/dist/chatbot-body-c80bdc34.js +4012 -0
- package/dist/chatbot.api.d.ts +2 -2
- package/dist/chatbot.constants.d.ts +2 -7
- package/dist/chatbot.d.ts +23 -13
- package/dist/chatbot.dom.d.ts +1 -1
- package/dist/chatbot.utils.d.ts +1 -1
- package/dist/components/chatbot.d.ts +3 -1
- package/dist/components/status-bar.d.ts +3 -1
- package/dist/i18n.d.ts +271 -0
- package/dist/index-a2c09edd.js +3535 -0
- package/dist/index-dc676e56.cjs +5 -0
- package/dist/interpreter.d.ts +3 -1
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +9 -10
- package/dist/chatbot-body-59b9e18a.js +0 -3951
- package/dist/chatbot-body-7ee64297.cjs +0 -1
- package/dist/index-13d4c822.js +0 -4682
- package/dist/index-d064cfc7.cjs +0 -45
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-d064cfc7.cjs");require("@inploi/sdk");const dt=({condition:e,context:r,submissions:s,ifBlock:n})=>{const[o,...a]=e.compareKey.split(".");if(!o)return!1;const i=Rt({context:r,key:o,path:a,submissions:s});if(!i)return!1;switch(i.type){case"address":{const u=t.get(i.value,a.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 i.value!="object"||Array.isArray(i.value))return!1;const u=t.get(i.value,a.join(".")),c={...n,data:{...n.data,compareKey:"_temp"}};switch(typeof u){case"boolean":return be(c,{submissions:{_temp:{value:u,type:"boolean"}},context:r});case"string":return be(c,{submissions:{_temp:{value:u,type:"string"}},context:r});case"number":return be(c,{submissions:{_temp:{value:u,type:"number"}},context:r});case"object":return Array.isArray(u)&&u.every(t.isString)?be(c,{submissions:{_temp:{value:u,type:"enum"}},context:r}):!1}break}case"boolean":{const u=e.compareValue==="true";switch(e.compare){case"equals":return i.value===u;case"notEquals":return i.value!==u}break}case"phone":case"string":{const u=i.type==="phone"?Ve(i.value):i.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 i.value===u;case"notEquals":return i.value!==u;case"greaterThan":return i.value>u;case"greaterThanOrEqualTo":return i.value>=u;case"lessThan":return i.value<u;case"lessThanOrEqualTo":return i.value<=u}}catch{return console.error(`Failed to parse number in if-block ${n.id}`,i.value),!1}break}case"enum":switch(e.compare){case"equals":return i.value.length===1&&i.value[0]===e.compareValue;case"notEquals":return i.value.length===1&&i.value[0]!==e.compareValue;case"contains":return i.value.includes(e.compareValue);case"notContains":return!i.value.includes(e.compareValue)}break}},be=(e,{context:r,submissions:s})=>{const n="combinator"in e.data?e.data.conditions:[e.data];if(("combinator"in e.data?e.data.combinator:"and")==="or"){for(const a of n)if(dt({condition:a,context:r,submissions:s,ifBlock:e}))return!0;return!1}else{for(const a of n)if(!dt({condition:a,context:r,submissions:s,ifBlock:e}))return!1;return!0}},sr=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,Z=(e,{context:r,submissions:s})=>e.replace(sr,(n,o,a="")=>{const[i,...u]=o.trim().split("."),c=Rt({key:i,path:u,submissions:s,context:r});if(!c)return a;switch(c.type){case"boolean":return c.value===!0?"true":"false";case"file":return c.value.map(g=>`${g.name} (${t.kbToReadableSize(g.sizeKb)})`).join(", ");case"enum":return c.value.join(", ");case"address":return Object.values(c.value).filter(g=>g&&g.trim().length>0).join(", ");case"number":case"string":return c.value?c.value.toString():a;case"phone":return Ve(c.value);case"integration":{if(typeof c.value!="object"||Array.isArray(c.value))break;const g=t.get(c.value,u.join("."));switch(typeof g){case"boolean":return g===!0?"true":"false";case"string":return g;case"number":return g.toString();case"object":if(Array.isArray(g)&&g.every(t.isString))return g.join(", ")}break}}return a}),Nt=({node:e,nodes:r,stopWhen:s})=>{if((s==null?void 0:s(e))===!0)return e;const n=e.nextId?r.find(o=>o.id===e.nextId):void 0;if(n)return Nt({node:n,nodes:r,stopWhen:s})},ar=({childNode:e,nodes:r})=>{const n=r.filter(o=>o.type==="if-block").find(o=>{if(!o.branchId)return!1;const a=r.find(u=>u.id===o.branchId);if(!a)return!1;const i=Nt({node:a,nodes:r,stopWhen:u=>u.id===e.id});return!(!i||i.id!==e.id)});if(n!=null&&n.nextId)return r.find(o=>o.id===n.nextId)},or=({flow:e,analytics:r,logger:s,context:n,apiClient:o,getSubmissions:a,chatService:i,onFlowEnd:u,onInterpret:c})=>{let g=new AbortController;const k={...r.service,log:m=>r.service.log({...m,customProperties:{...m.customProperties,...r.customProperties}})},h=async(m,v)=>{const C=a();c==null||c(m,v);try{await ir({flow:e,analytics:k,logger:s,apiClient:o,context:n,node:m,submissions:C,chat:{sendMessage:async _=>i.send({groupId:m.id,message:_,signal:g.signal}),userInput:async _=>i.input({input:_,signal:g.signal}),addToSubmissions:i.addToSubmissions},next:_=>{const E=_?e.nodes.find(F=>F.id===_):ar({childNode:m,nodes:e.nodes});return E?h(E,m):u==null?void 0:u(m)},end:()=>u==null?void 0:u(m)})}catch(_){if(_ instanceof t.AbortedError)return;throw _}};return{interpret:async m=>{const v=e.nodes.find(C=>C.id===m)??t.getHeadOrThrow(e.nodes);return h(v)},undo:m=>{let v=1;const C=e.nodes.find(E=>E.id===m[m.length-1]);for(let E=m.length-2;E>0;E--){const F=m[E],y=e.nodes.find(V=>V.id===F);if(!y||(v++,y.type.startsWith("question-")))break}g.abort(),g=new AbortController;const _=e.nodes.find(E=>E.id===m[m.length-v]);return t.invariant(_,"Undo failed: new start node not found"),h(_,C),{removed:v}},abort:()=>{g.abort()}}},Ve=e=>`+${e.countryCode} ${e.phoneNumber}`;async function ir(e){const r=e.node;switch(r.type){case"text":return mr({...e,node:r});case"image":return gr({...e,node:r});case"question-text":return br({...e,node:r});case"question-enum":return xr({...e,node:r});case"question-number":return yr({...e,node:r});case"question-phone":return vr({...e,node:r});case"question-boolean":return wr({...e,node:r});case"question-file":return _r({...e,node:r});case"question-address":return kr({...e,node:r});case"end-flow":return Sr({...e,node:r});case"if-block":return pr({...e,node:r});case"jump":return cr({...e,node:r});case"link":return hr({...e,node:r});case"integration-application-submit":return fr({...e,node:r});case"add-submission":return dr({...e,node:r});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"identify":return ur({...e,node:r});case"feedback":return lr({...e,node:r});default:throw new Error(`Unknown node: ${JSON.stringify(r)}`)}}const me=(e,r)=>{var n;const s=(n=e[r])==null?void 0:n.value;if(typeof s!="string"&&typeof s!="number")throw new Error(`Submission at “${r}” is not a string or number`);return s};async function lr({next:e,node:r}){e(r.nextId)}async function ur({next:e,node:r,analytics:s,submissions:n,logger:o}){if(!n)return e(r.nextId);try{s.log({event:"IDENTIFY",properties:{identifier:me(n,r.data.key).toString(),first_name:r.data.firstName?me(n,r.data.firstName).toString():void 0,last_name:r.data.lastName?me(n,r.data.lastName).toString():void 0,email:r.data.email?me(n,r.data.email).toString():void 0,phone_number:r.data.phoneNumber?me(n,r.data.phoneNumber).toString():void 0,custom_traits:r.data.customTraits?Object.fromEntries(r.data.customTraits.map(({key:a,value:i})=>{var u;return[a,(u=n[i])==null?void 0:u.value]})):void 0}})}catch(a){o.error(a)}finally{e(r.nextId)}}async function cr({next:e,node:r}){e(r.data.targetId)}async function dr({next:e,node:r,logger:s,submissions:n,context:o}){if(!n){s.error("Submissions not found");return}n[r.data.key]={type:"string",value:Z(r.data.value,{submissions:n,context:o})},e(r.nextId)}async function fr({chat:e,next:r,node:s,logger:n,apiClient:o,submissions:a,analytics:i,flow:u}){const c=async g=>{g!==!0&&await e.userInput({type:"submit",key:void 0,config:{label:s.data.submitLabel}}),await e.sendMessage({type:"loading"});const{anonymous_id:k,session_id:h}=i.getSessionInfo(),m=await o.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:s.data.integrationId,anonymous_id:k,session_id:h,job:u.job,submissions:t.getFlowSubmissionsPayload(a||{})})}).catch(v=>v);s.data.key&&e.addToSubmissions(s.data.key,{type:"integration",value:m}),t.N(m).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}}))},v=>{i.log({event:"FLOW_SUBMIT",properties:{flow_id:u.id,flow_version:u.version,flow_session_id:u.data.flowSessionId,flow_build:u.build,service:v.service??"INVALID_SERVICE",response:{status:v.status,payload:"data"in v?v.data:v.error.data??null},job:u.job}})}).otherwise(()=>{}),await t.N(m).with(t._.union({ats_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))})},{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 v=>{if(v.redirect!==void 0){await e.sendMessage({type:"text",author:"bot",text:v.redirect.message??"Almost there! Please complete your submission here:"});try{const C=new URL(v.redirect.redirect_url);k&&!C.searchParams.has("anonymous_id")&&C.searchParams.set("anonymous_id",k),await e.sendMessage({type:"link",href:C.toString(),text:v.redirect.button_text??"Complete submission",onClick:()=>{if(!h){n.error("session_id not set, cannot log FLOW_REDIRECT event");return}i.log({event:"FLOW_REDIRECT",properties:{flow_build:u.build,flow_id:u.id,flow_session_id:h,flow_version:u.version,href:C.toString(),job:u.job}})}})}catch(C){n.error(`Invalid redirect URL: ${v.redirect.redirect_url}`,C),e.sendMessage({type:"system",variant:"error",text:"Couldn’t get the redirect URL."})}r(s.nextId)}}).with({success:!0},async()=>{s.data.skipConfirmation!==!0&&await e.sendMessage({type:"system",variant:"success",text:"Submission completed!"}),r(s.nextId)}).with(t._.union({success:!1,ats_data:t._.select("error",{message:t._.string})},{integration_response:{error:t._.select("error",{message:t._.string})}}),async v=>{var C;n.error(v.error),await e.sendMessage({type:"system",variant:"error",text:((C=v.error)==null?void 0:C.message)||"Failed to submit"}),await c(!1)}).otherwise(async v=>{n.error(v),await e.sendMessage({type:"system",variant:"error",text:"Failed to submit"}),await c(!1)})};await c(s.data.skipConfirmation)}async function hr({chat:e,next:r,node:s,submissions:n,context:o}){await e.sendMessage({type:"link",href:Z(s.data.href,{submissions:n,context:o}),text:Z(s.data.cta,{submissions:n,context:o})}),r(s.nextId)}async function pr({submissions:e,next:r,node:s,context:n}){r(be(s,{submissions:e,context:n})?s.branchId:s.nextId)}async function mr({chat:e,next:r,node:s,submissions:n,context:o}){await e.sendMessage({author:"bot",type:"text",text:Z(s.data.text,{submissions:n,context:o})}),r(s.nextId)}async function gr({chat:e,next:r,node:s}){await e.sendMessage({author:"bot",type:"image",url:s.data.url,height:s.data.height,width:s.data.width}),r(s.nextId)}async function br({chat:e,next:r,node:s,submissions:n,context:o}){await e.sendMessage({author:"bot",type:"text",text:Z(s.data.question,{submissions:n,context:o})});const a=s.data.format==="phone"?await e.userInput({key:s.data.key,type:"phone",config:{optional:s.data.optional,placeholder:s.data.placeholder,maxChars:s.data.maxChars,minChars:s.data.minChars,submissionFormat:"text",defaultValue:{}}}):await e.userInput({key:s.data.key,type:"text",config:{optional:s.data.optional,placeholder:s.data.placeholder,format:s.data.format,maxChars:s.data.maxChars,minChars:s.data.minChars}});a===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:a.type==="phone"?Ve(a.value):a.value}),r(s.nextId)}async function yr({chat:e,next:r,node:s,submissions:n,context:o}){await e.sendMessage({author:"bot",type:"text",text:Z(s.data.question,{submissions:n,context:o})});const a=await e.userInput({key:s.data.key,type:"number",config:{max:s.data.max,min:s.data.min,optional:s.data.optional,placeholder:s.data.placeholder,decimalCases:s.data.decimalCases}});a===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:a.value.toString()}),r(s.nextId)}async function vr({chat:e,next:r,node:s,submissions:n,context:o}){await e.sendMessage({author:"bot",type:"text",text:Z(s.data.question,{submissions:n,context:o})});const a=await e.userInput({key:s.data.key,type:"phone",config:{minChars:s.data.minChars,maxChars:s.data.maxChars,defaultValue:{countryCode:s.data.defaultCountryCode},placeholder:s.data.placeholder,submissionFormat:"phone",optional:s.data.optional}});a===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:a.type==="phone"?Ve(a.value):a.value}),r(s.nextId)}async function xr({chat:e,next:r,node:s,submissions:n,context:o}){await e.sendMessage({author:"bot",type:"text",text:Z(s.data.question,{submissions:n,context:o})});const a=await e.userInput({key:s.data.key,type:"multiple-choice",config:s.data});a.value.length===0?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:s.data.options.filter(i=>a.value.includes(i.value)).map(i=>i.label).join(", ")}),r(s.nextId)}async function wr({chat:e,next:r,node:s,submissions:n,context:o}){await e.sendMessage({author:"bot",type:"text",text:Z(s.data.question,{submissions:n,context:o})});const a=await e.userInput({key:s.data.key,type:"boolean",config:{optional:s.data.optional,labels:{true:s.data.trueLabel,false:s.data.falseLabel}}});a===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:a.value===!0?s.data.trueLabel:s.data.falseLabel}),r(s.nextId)}async function kr({chat:e,next:r,node:s}){await e.sendMessage({author:"bot",type:"text",text:s.data.question});const n=await e.userInput({type:"address",key:s.data.key,config:{optional:s.data.optional,keys:s.data.keys,placeholder:s.data.placeholder}});if(n===null)await e.sendMessage({type:"system",variant:"info",text:"Skipped"});else{const o=Object.values(n.value).filter(a=>a&&a.trim().length>0).join(", ");await e.sendMessage({author:"user",type:"text",text:o})}return r(s.nextId)}async function _r({node:e,chat:r,next:s,submissions:n,context:o}){await r.sendMessage({author:"bot",type:"text",text:Z(e.data.question,{submissions:n,context:o})});const a=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(a===null)await r.sendMessage({type:"system",variant:"info",text:"Skipped"});else for(const i of a.value)await r.sendMessage({author:"user",type:"file",fileName:i.name,fileSizeKb:i.sizeKb});s(e.nextId)}async function Sr({chat:e,end:r,node:s}){await e.sendMessage({type:"system",variant:"info",text:s.data.systemMessage}),r()}const Rt=({key:e,path:r,submissions:s,context:n})=>{if(e==="$context"){if(!r)return;const o=t.get(n,r.join("."));switch(typeof o){case"string":return{type:"string",value:o};case"number":return{type:"number",value:o};case"boolean":return{type:"boolean",value:o};default:console.warn(`Unexpected type for $context.${r.join(".")}`,o);return}}return s==null?void 0:s[e]};function Ge(e,r,s){var n,o,a,i,u;r==null&&(r=100);function c(){var k=Date.now()-i;k<r&&k>=0?n=setTimeout(c,r-k):(n=null,s||(u=e.apply(a,o),a=o=null))}var g=function(){a=this,o=arguments,i=Date.now();var k=s&&!n;return n||(n=setTimeout(c,r)),k&&(u=e.apply(a,o),a=o=null),u};return g.clear=function(){n&&(clearTimeout(n),n=null)},g.flush=function(){n&&(u=e.apply(a,o),a=o=null,clearTimeout(n),n=null)},g}Ge.debounce=Ge;var Cr=Ge;const ft=t.getDefaultExportFromCjs(Cr);function Er(e){let{debounce:r,scroll:s,polyfill:n,offsetSize:o}=e===void 0?{debounce:0,scroll:!1,offsetSize:!1}:e;const a=n||(typeof window>"u"?class{}:window.ResizeObserver);if(!a)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[i,u]=t.h({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),c=t._$1({element:null,scrollContainers:null,resizeObserver:null,lastBounds:i}),g=r?typeof r=="number"?r:r.scroll:null,k=r?typeof r=="number"?r:r.resize:null,h=t._$1(!1);t.p(()=>(h.current=!0,()=>void(h.current=!1)));const[m,v,C]=t.F(()=>{const y=()=>{if(!c.current.element)return;const{left:V,top:q,width:R,height:se,bottom:te,right:he,x:U,y:X}=c.current.element.getBoundingClientRect(),B={left:V,top:q,width:R,height:se,bottom:te,right:he,x:U,y:X};c.current.element instanceof HTMLElement&&o&&(B.height=c.current.element.offsetHeight,B.width=c.current.element.offsetWidth),Object.freeze(B),h.current&&!Mr(c.current.lastBounds,B)&&u(c.current.lastBounds=B)};return[y,k?ft(y,k):y,g?ft(y,g):y]},[u,o,g,k]);function _(){c.current.scrollContainers&&(c.current.scrollContainers.forEach(y=>y.removeEventListener("scroll",C,!0)),c.current.scrollContainers=null),c.current.resizeObserver&&(c.current.resizeObserver.disconnect(),c.current.resizeObserver=null)}function E(){c.current.element&&(c.current.resizeObserver=new a(C),c.current.resizeObserver.observe(c.current.element),s&&c.current.scrollContainers&&c.current.scrollContainers.forEach(y=>y.addEventListener("scroll",C,{capture:!0,passive:!0})))}const F=y=>{!y||y===c.current.element||(_(),c.current.element=y,c.current.scrollContainers=Dt(y),E())};return Fr(C,!!s),Ar(v),t.p(()=>{_(),E()},[s,C,v]),t.p(()=>_,[]),[F,i,m]}function Ar(e){t.p(()=>{const r=e;return window.addEventListener("resize",r),()=>void window.removeEventListener("resize",r)},[e])}function Fr(e,r){t.p(()=>{if(r){const s=e;return window.addEventListener("scroll",s,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",s,!0)}},[e,r])}function Dt(e){const r=[];if(!e||e===document.body)return r;const{overflow:s,overflowX:n,overflowY:o}=window.getComputedStyle(e);return[s,n,o].some(a=>a==="auto"||a==="scroll")&&r.push(e),[...r,...Dt(e.parentElement)]}const Ir=["x","y","top","bottom","left","right","width","height"],Mr=(e,r)=>Ir.every(s=>e[s]===r[s]),ie=({class:e,...r})=>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:"Send"}),t.o("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),t.o("path",{d:"M8 4V13"})]})}),Tr=25,He=t.a({instant:()=>{},smooth:()=>{}}),$={onSubmitSuccessFn$:t.a(()=>{}),isBotTyping$:t.a(!1),scrollToEnd:{instant:()=>He.value.instant(),smooth:()=>He.value.smooth()}},Vr=()=>{const e=t._$1(null);t.y(()=>{He.value={instant:()=>{var s;return(s=e.current)==null?void 0:s.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:(n,o)=>t.store.setSubmission(n,o),send:async({message:n,signal:o,groupId:a})=>{if(await t.N(n).with({author:"bot",type:"text"},async i=>{if(o!=null&&o.aborted)throw new t.AbortedError;$.isBotTyping$.value=!0;const u=Math.min(Math.max(20,i.text.length),100)*Tr;await new Promise(c=>setTimeout(c,u,{signal:o})),$.isBotTyping$.value=!1}).otherwise(async()=>{}),o!=null&&o.aborted)throw new t.AbortedError;t.store.addMessage(n,a)},input:({input:n,signal:o})=>{if(o!=null&&o.aborted)throw new t.AbortedError;return t.store.setInput(n),new Promise(a=>{const i=u=>{if(o!=null&&o.aborted)throw new t.AbortedError;t.store.setInput(void 0),n.key&&t.store.setSubmission(n.key,u),a(u)};$.onSubmitSuccessFn$.value=i})}}),[]);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})=>t.o("button",{type:"button",class:t.clsx("fr text-neutral-9 flex h-full 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",{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:"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"})]}),"Skip"]}),Je={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"},ye=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}}),Lr="https://api.mapbox.com/search/searchbox/v1/suggest",Nr="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",Rr=e=>atob(e).split("").reverse().join(""),Y=t.object({name:t.string()}),Dr=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}))}))}),Or=({logger:e})=>t.F(()=>{var s;const r=(s=t.store.current$.peek().flow)==null?void 0:s.data.flowSessionId;return r?{enabled:!0,getPredictions:async n=>{const o=new URL(Lr);o.searchParams.set("q",n),o.searchParams.set("session_token",r),o.searchParams.set("access_token",Rr(Nr));const a=await fetch(o);if(!a.ok)return e.error("Failed to get address details",a),{ok:!1,error:"Something went wrong! Plase continue manually."};const i=t.safeParse(Dr,await a.json());if(i.success===!1)return e.error("Failed to parse address details",i.issues),{ok:!1,error:"Something went wrong! Plase continue manually."};const{suggestions:u}=i.output;return{ok:!0,data:u.map(c=>{var g,k,h,m,v,C,_,E,F;return{label:c.full_address??c.place_formatted??c.name??c.mapbox_id,id:c.mapbox_id,address:{line1:((g=c.context.address)==null?void 0:g.name)??((k=c.context.street)==null?void 0:k.name),line2:void 0,line3:((h=c.context.neighborhood)==null?void 0:h.name)??((m=c.context.locality)==null?void 0:m.name),city:((v=c.context.place)==null?void 0:v.name)??((C=c.context.district)==null?void 0:C.name),state:(_=c.context.region)==null?void 0:_.name,postcode:(E=c.context.postcode)==null?void 0:E.name,country:(F=c.context.country)==null?void 0:F.name}}})}}}:{enabled:!1}},[e]),ht=e=>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:"Back"})]}),Ce={label:"Fill in manually",value:""},Pr=({input:e,onSubmitSuccess:r,logger:s})=>{const[n,o]=t.h(),[a,i]=t.h([]),{enabled:u,getPredictions:c}=Or({logger:s}),[g,k]=t.h(u?"query":"manual"),[h,m]=t.h(""),[v,C]=t.h(),_=E=>{t.invariant(u,"Query state should not be enabled"),E=E.trim(),E!==(h==null?void 0:h.trim())&&(m(E),E===""&&i([]),C(void 0),c(E).then(F=>{if(F.ok===!1){i([]),C(F.error);return}i(F.data)}))};switch(g){case"query":return t.invariant(u,"Query state should not be enabled"),t.o($r,{input:e,onSkip:()=>r(null),onAddressSelect:E=>{if(E===Ce.value){o(void 0),k("manual");return}const F=a.find(y=>y.id===E);F&&(o(F.address),k("details"))},onAddressSearch:E=>{_(E)},suggestions:a,query:h,error:v});case"details":return t.invariant(n!==void 0),t.o(mt,{input:e,logger:s,onSubmitSuccess:r,addressFields:n,actions:t.o(ht,{onClick:()=>{k("query")}})});case"manual":return t.o(mt,{logger:s,input:e,onSubmitSuccess:r,addressFields:{},actions:u?t.o(ht,{onClick:()=>{k("query")}}):void 0})}},$r=({input:e,onSkip:r,suggestions:s,onAddressSelect:n,query:o,onAddressSearch:a,error:i})=>{const u=t._$1(null);return t.y(()=>{u.current&&(u.current.focus(),u.current.select())},[]),t.o(t.k,{children:[t.o("form",{noValidate:!0,onSubmit:c=>{c.preventDefault();const k=new FormData(c.currentTarget).get("address");typeof k=="string"&&a(k)},class:"flex gap-1 p-2.5",children:[t.o("div",{class:"group relative flex-1",children:[t.o("input",{ref:u,name:"address",id:"chat-address",autocomplete:"address-line1 country-name postal-code",autoFocus:!0,placeholder:e.config.placeholder||"Type and search for places...",defaultValue:o,class:ye({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:"Search"})]})})]}),e.config.optional&&t.o(le,{class:"",onClick:r})]}),i?t.o(fe,{error:{message:i}}):null,t.o("ul",{children:[s.map(c=>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:()=>{n(c.id)},children:[t.o("span",{class:"flex-grow",children:c.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"})})]})},c.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:()=>{n(Ce.value)},children:t.o("span",{class:"flex-grow",children:Ce.label})})},Ce.label)]})]})},Br={line1:"Line 1",line2:"Line 2",line3:"Line 3",city:"City",state:"State",postcode:"Postcode",country:"Country"},pt=["line1","line2","line3","city","state","postcode","country"],mt=({addressFields:e,onSubmitSuccess:r,actions:s,input:n})=>{const o=t._$1(null);t.y(()=>{if(o.current){const i=o.current.querySelector("input");i&&(i.focus(),i.select())}},[]);const a=Object.keys(Je);return t.o("form",{class:"bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",onSubmit:i=>{const u=new FormData(i.currentTarget),c=Object.fromEntries(u.entries());r({type:"address",value:c})},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:o,children:pt.map((i,u)=>{const c=`isdk_${i}`,g=n.config.keys[i];return g?t.o(t.k,{children:[t.o("label",{for:c,class:"text-neutral-9 [&:has(+*>input:focus)]:text-neutral-11 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",children:Br[i]}),t.o("div",{class:"flex flex-col items-stretch gap-1.5",children:[i==="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:g,id:c,defaultValue:e[i],required:!0,children:[e.country&&!a.includes(e.country)?t.o("option",{value:e[i],children:e[i]}):t.o("option",{value:"",children:"Select a country"}),a.map(k=>t.o("option",{value:k,children:k},k))]}),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:u===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:g,id:c,defaultValue:e[i],required:!0}),u===pt.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:s}),t.o(ie,{class:"flex items-center justify-center"})]})]})},Ze=()=>{const e=t._$1(null);return t.p(()=>{var r;(r=e.current)==null||r.focus()},[]),e},Ot=["true","false"],jr=t.picklist(Ot),qr="answer",Pt="flex items-center gap-2 p-2.5",$t=t.k$1(({label:e,...r},s)=>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:s,children:t.o("p",{class:"truncate text-center text-base",children:e})})),zr=({input:e,onSubmitSuccess:r})=>{const s=Ze();return t.o("form",{noValidate:!0,class:"",onSubmit:n=>{n.preventDefault();const o=t.getFormSubmitter(n).value,a=t.parse(jr,o);r({type:"boolean",value:a==="true"})},children:[t.o("ul",{class:Pt,children:Ot.map((n,o)=>t.o("li",{class:"flex-1",children:t.o($t,{ref:o===0?s:null,type:"submit",name:qr,value:n,label:e.config.labels[n]},n)}))}),e.config.optional&&t.o("div",{class:"px-2 pb-2",children:t.o(le,{class:"w-full",type:"button",onClick:()=>r(null)})})]})},Ur=e=>new Promise((r,s)=>{const n=new FileReader;n.readAsDataURL(e),n.onload=()=>n.result?r(n.result.toString()):s("No result from reader"),n.onerror=s}),Kr=e=>e.reduce((r,s)=>r+s.sizeKb,0),Gr=t.isSubmissionOfType("file"),gt=3,Hr=({file:e,class:r,...s})=>{const n=e.name.split(".").pop(),o=e.name.replace(new RegExp(`.${n}$`),"");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),...s,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:o}),t.o("span",{children:[".",n]})]}),t.o("p",{"aria-label":"File size",class:"text-accent-11",children:t.kbToReadableSize(e.sizeKb)})]})},bt=({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}),Bt=e=>{const r=e.split(".").pop();if(!r)throw new Error("No file extension found");return r?"."+r:""},Wr=({allowedExtensions:e,files:r})=>{const s=e.map(n=>n.toLowerCase());return r.every(n=>s.includes(Bt(n.name).toLowerCase()))},Jr=(e,r)=>{const s=Bt(e);return`${e.replace(new RegExp(`${s}$`),"").slice(0,r)}${s}`},Zr=({input:e,onSubmitSuccess:r})=>{var k;const s=(k=t.store.current$.value.flow)==null?void 0:k.data.submissions[e.key],[n,o]=t.h(Gr(s)?s.value:[]),[a,i]=t.h(),u=n.length-gt,c=Kr(n),g=Ze();return t.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:h=>(h.preventDefault(),i(void 0),n.length===0?i({type:"required",message:"Please select a file"}):e.config.extensions.length>0&&!Wr({allowedExtensions:e.config.extensions,files:n})?i({type:"validate",message:`Please upload ${e.config.extensions.join(", ")} files only`}):e.config.fileSizeLimitKib&&c>e.config.fileSizeLimitKib?i({type:"max",message:`File size exceeds limit of ${t.kbToReadableSize(e.config.fileSizeLimitKib)}`}):e.config.allowMultiple===!1&&n.length>1?i({type:"invalid",message:"Only one file is allowed"}):r({type:"file",value:n})),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("label",{ref:g,for:"dropzone-file",class:"border-neutral-8 bg-neutral-2 flex h-48 w-full cursor-pointer flex-col items-center justify-center overflow-hidden rounded-2xl border border-dashed p-4",children:[n.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:[n.slice(0,gt).map(h=>{const m=h.name.split(".").pop(),v=h.name.replace(new RegExp(`.${m}$`),"");return t.o(bt,{class:"flex overflow-hidden",children:[t.o("span",{class:"block truncate",children:v}),t.o("span",{children:[".",m]})]})}),u>0?t.o(bt,{children:["+",u," file",u!==1?"s":""]}):null]}),t.o("p",{class:"text-neutral-11 text-xs",children:[t.kbToReadableSize(c)," ",n.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:[e.config.allowMultiple?"Select files":"Select a file"," to upload"]}),e.config.fileSizeLimitKib?t.o("p",{class:"text-neutral-10 text-xs",children:["(max ",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:"Accepted 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 m=h.target.files?Array.from(h.target.files):[],v=await Promise.allSettled(m.map(async _=>{const E=await Ur(_);return{name:Jr(_.name,42),data:E,sizeKb:_.size/1e3}}));if(v.some(({status:_})=>_==="rejected"))return i({type:"invalid",message:"Invalid file"});const C=v.map(_=>_.status==="fulfilled"?_.value:null).filter(Boolean);o(C)},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(ie,{disabled:n.length===0}),e.config.optional&&t.o(le,{onClick:()=>r(null)})]})]}),t.o(fe,{error:a})]})};var ve=e=>e.type==="checkbox",de=e=>e instanceof Date,j=e=>e==null;const jt=e=>typeof e=="object";var O=e=>!j(e)&&!Array.isArray(e)&&jt(e)&&!de(e),Xr=e=>O(e)&&e.target?ve(e.target)?e.target.checked:e.target.value:e,Yr=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Qr=(e,r)=>e.has(Yr(r)),en=e=>{const r=e.constructor&&e.constructor.prototype;return O(r)&&r.hasOwnProperty("isPrototypeOf")},Xe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ee(e){let r;const s=Array.isArray(e);if(e instanceof Date)r=new Date(e);else if(e instanceof Set)r=new Set(e);else if(!(Xe&&(e instanceof Blob||e instanceof FileList))&&(s||O(e)))if(r=s?[]:{},!s&&!en(e))r=e;else for(const n in e)e.hasOwnProperty(n)&&(r[n]=ee(e[n]));else return e;return r}var xe=e=>Array.isArray(e)?e.filter(Boolean):[],N=e=>e===void 0,x=(e,r,s)=>{if(!r||!O(e))return s;const n=xe(r.split(/[,[\].]+?/)).reduce((o,a)=>j(o)?o:o[a],e);return N(n)||n===e?N(e[r])?s:e[r]:n},re=e=>typeof e=="boolean";const yt={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 tn=(e,r,s,n=!0)=>{const o={defaultValues:r._defaultValues};for(const a in e)Object.defineProperty(o,a,{get:()=>{const i=a;return r._proxyFormState[i]!==H.all&&(r._proxyFormState[i]=!n||H.all),s&&(s[i]=!0),e[i]}});return o},G=e=>O(e)&&!Object.keys(e).length,rn=(e,r,s,n)=>{s(e);const{name:o,...a}=e;return G(a)||Object.keys(a).length>=Object.keys(r).length||Object.keys(a).find(i=>r[i]===(!n||H.all))},Be=e=>Array.isArray(e)?e:[e];function nn(e){const r=t.Cn.useRef(e);r.current=e,t.Cn.useEffect(()=>{const s=!e.disabled&&r.current.subject&&r.current.subject.subscribe({next:r.current.next});return()=>{s&&s.unsubscribe()}},[e.disabled])}var J=e=>typeof e=="string",sn=(e,r,s,n,o)=>J(e)?(n&&r.watch.add(e),x(s,e,o)):Array.isArray(e)?e.map(a=>(n&&r.watch.add(a),x(s,a))):(n&&(r.watchAll=!0),s),Ye=e=>/^\w*$/.test(e),qt=e=>xe(e.replace(/["|']|\]/g,"").split(/\.|\[/));function M(e,r,s){let n=-1;const o=Ye(r)?[r]:qt(r),a=o.length,i=a-1;for(;++n<a;){const u=o[n];let c=s;if(n!==i){const g=e[u];c=O(g)||Array.isArray(g)?g:isNaN(+o[n+1])?{}:[]}e[u]=c,e=e[u]}return e}var zt=(e,r,s,n,o)=>r?{...s[e],types:{...s[e]&&s[e].types?s[e].types:{},[n]:o||!0}}:{},vt=e=>({isOnSubmit:!e||e===H.onSubmit,isOnBlur:e===H.onBlur,isOnChange:e===H.onChange,isOnAll:e===H.all,isOnTouch:e===H.onTouched}),xt=(e,r,s)=>!s&&(r.watchAll||r.watch.has(e)||[...r.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Ee=(e,r,s,n)=>{for(const o of s||Object.keys(e)){const a=x(e,o);if(a){const{_f:i,...u}=a;if(i){if(i.refs&&i.refs[0]&&r(i.refs[0],o)&&!n)break;if(i.ref&&r(i.ref,i.name)&&!n)break}else O(u)&&Ee(u,r)}}};var an=(e,r,s)=>{const n=xe(x(e,s));return M(n,"root",r[s]),M(e,s,n),e},Qe=e=>e.type==="file",ne=e=>typeof e=="function",Fe=e=>{if(!Xe)return!1;const r=e?e.ownerDocument:0;return e instanceof(r&&r.defaultView?r.defaultView.HTMLElement:HTMLElement)},Ae=e=>J(e),et=e=>e.type==="radio",Ie=e=>e instanceof RegExp;const wt={value:!1,isValid:!1},kt={value:!0,isValid:!0};var Ut=e=>{if(Array.isArray(e)){if(e.length>1){const r=e.filter(s=>s&&s.checked&&!s.disabled).map(s=>s.value);return{value:r,isValid:!!r.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!N(e[0].attributes.value)?N(e[0].value)||e[0].value===""?kt:{value:e[0].value,isValid:!0}:kt:wt}return wt};const _t={isValid:!1,value:null};var Kt=e=>Array.isArray(e)?e.reduce((r,s)=>s&&s.checked&&!s.disabled?{isValid:!0,value:s.value}:r,_t):_t;function St(e,r,s="validate"){if(Ae(e)||Array.isArray(e)&&e.every(Ae)||re(e)&&!e)return{type:s,message:Ae(e)?e:"",ref:r}}var ce=e=>O(e)&&!Ie(e)?e:{value:e,message:""},Ct=async(e,r,s,n,o)=>{const{ref:a,refs:i,required:u,maxLength:c,minLength:g,min:k,max:h,pattern:m,validate:v,name:C,valueAsNumber:_,mount:E,disabled:F}=e._f,y=x(r,C);if(!E||F)return{};const V=i?i[0]:a,q=I=>{n&&V.reportValidity&&(V.setCustomValidity(re(I)?"":I||""),V.reportValidity())},R={},se=et(a),te=ve(a),he=se||te,U=(_||Qe(a))&&N(a.value)&&N(y)||Fe(a)&&a.value===""||y===""||Array.isArray(y)&&!y.length,X=zt.bind(null,C,s,R),B=(I,A,L,z=Q.maxLength,K=Q.minLength)=>{const W=I?A:L;R[C]={type:I?z:K,message:W,ref:a,...X(I?z:K,W)}};if(o?!Array.isArray(y)||!y.length:u&&(!he&&(U||j(y))||re(y)&&!y||te&&!Ut(i).isValid||se&&!Kt(i).isValid)){const{value:I,message:A}=Ae(u)?{value:!!u,message:u}:ce(u);if(I&&(R[C]={type:Q.required,message:A,ref:V,...X(Q.required,A)},!s))return q(A),R}if(!U&&(!j(k)||!j(h))){let I,A;const L=ce(h),z=ce(k);if(!j(y)&&!isNaN(y)){const K=a.valueAsNumber||y&&+y;j(L.value)||(I=K>L.value),j(z.value)||(A=K<z.value)}else{const K=a.valueAsDate||new Date(y),W=we=>new Date(new Date().toDateString()+" "+we),ae=a.type=="time",pe=a.type=="week";J(L.value)&&y&&(I=ae?W(y)>W(L.value):pe?y>L.value:K>new Date(L.value)),J(z.value)&&y&&(A=ae?W(y)<W(z.value):pe?y<z.value:K<new Date(z.value))}if((I||A)&&(B(!!I,L.message,z.message,Q.max,Q.min),!s))return q(R[C].message),R}if((c||g)&&!U&&(J(y)||o&&Array.isArray(y))){const I=ce(c),A=ce(g),L=!j(I.value)&&y.length>+I.value,z=!j(A.value)&&y.length<+A.value;if((L||z)&&(B(L,I.message,A.message),!s))return q(R[C].message),R}if(m&&!U&&J(y)){const{value:I,message:A}=ce(m);if(Ie(I)&&!y.match(I)&&(R[C]={type:Q.pattern,message:A,ref:a,...X(Q.pattern,A)},!s))return q(A),R}if(v){if(ne(v)){const I=await v(y,r),A=St(I,V);if(A&&(R[C]={...A,...X(Q.validate,A.message)},!s))return q(A.message),R}else if(O(v)){let I={};for(const A in v){if(!G(I)&&!s)break;const L=St(await v[A](y,r),V,A);L&&(I={...L,...X(A,L.message)},q(L.message),s&&(R[C]=I))}if(!G(I)&&(R[C]={ref:V,...I},!s))return R}}return q(!0),R};function on(e,r){const s=r.slice(0,-1).length;let n=0;for(;n<s;)e=N(e)?n++:e[r[n++]];return e}function ln(e){for(const r in e)if(e.hasOwnProperty(r)&&!N(e[r]))return!1;return!0}function P(e,r){const s=Array.isArray(r)?r:Ye(r)?[r]:qt(r),n=s.length===1?e:on(e,s),o=s.length-1,a=s[o];return n&&delete n[a],o!==0&&(O(n)&&G(n)||Array.isArray(n)&&ln(n))&&P(e,s.slice(0,-1)),e}function je(){let e=[];return{get observers(){return e},next:o=>{for(const a of e)a.next&&a.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(a=>a!==o)}}),unsubscribe:()=>{e=[]}}}var Me=e=>j(e)||!jt(e);function oe(e,r){if(Me(e)||Me(r))return e===r;if(de(e)&&de(r))return e.getTime()===r.getTime();const s=Object.keys(e),n=Object.keys(r);if(s.length!==n.length)return!1;for(const o of s){const a=e[o];if(!n.includes(o))return!1;if(o!=="ref"){const i=r[o];if(de(a)&&de(i)||O(a)&&O(i)||Array.isArray(a)&&Array.isArray(i)?!oe(a,i):a!==i)return!1}}return!0}var Gt=e=>e.type==="select-multiple",un=e=>et(e)||ve(e),qe=e=>Fe(e)&&e.isConnected,Ht=e=>{for(const r in e)if(ne(e[r]))return!0;return!1};function Te(e,r={}){const s=Array.isArray(e);if(O(e)||s)for(const n in e)Array.isArray(e[n])||O(e[n])&&!Ht(e[n])?(r[n]=Array.isArray(e[n])?[]:{},Te(e[n],r[n])):j(e[n])||(r[n]=!0);return r}function Wt(e,r,s){const n=Array.isArray(e);if(O(e)||n)for(const o in e)Array.isArray(e[o])||O(e[o])&&!Ht(e[o])?N(r)||Me(s[o])?s[o]=Array.isArray(e[o])?Te(e[o],[]):{...Te(e[o])}:Wt(e[o],j(r)?{}:r[o],s[o]):s[o]=!oe(e[o],r[o]);return s}var ze=(e,r)=>Wt(e,r,Te(r)),Jt=(e,{valueAsNumber:r,valueAsDate:s,setValueAs:n})=>N(e)?e:r?e===""?NaN:e&&+e:s&&J(e)?new Date(e):n?n(e):e;function Ue(e){const r=e.ref;if(!(e.refs?e.refs.every(s=>s.disabled):r.disabled))return Qe(r)?r.files:et(r)?Kt(e.refs).value:Gt(r)?[...r.selectedOptions].map(({value:s})=>s):ve(r)?Ut(e.refs).value:Jt(N(r.value)?e.ref.value:r.value,e)}var cn=(e,r,s,n)=>{const o={};for(const a of e){const i=x(r,a);i&&M(o,a,i._f)}return{criteriaMode:s,names:[...e],fields:o,shouldUseNativeValidation:n}},ge=e=>N(e)?e:Ie(e)?e.source:O(e)?Ie(e.value)?e.value.source:e.value:e,dn=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Et(e,r,s){const n=x(e,s);if(n||Ye(s))return{error:n,name:s};const o=s.split(".");for(;o.length;){const a=o.join("."),i=x(r,a),u=x(e,a);if(i&&!Array.isArray(i)&&s!==a)return{name:s};if(u&&u.type)return{name:a,error:u};o.pop()}return{name:s}}var fn=(e,r,s,n,o)=>o.isOnAll?!1:!s&&o.isOnTouch?!(r||e):(s?n.isOnBlur:o.isOnBlur)?!e:(s?n.isOnChange:o.isOnChange)?e:!0,hn=(e,r)=>!xe(x(e,r)).length&&P(e,r);const pn={mode:H.onSubmit,reValidateMode:H.onChange,shouldFocusError:!0};function mn(e={},r){let s={...pn,...e},n={submitCount:0,isDirty:!1,isLoading:ne(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},o={},a=O(s.defaultValues)||O(s.values)?ee(s.defaultValues||s.values)||{}:{},i=s.shouldUnregister?{}:ee(a),u={action:!1,mount:!1,watch:!1},c={mount:new Set,unMount:new Set,array:new Set,watch:new Set},g,k=0;const h={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},m={values:je(),array:je(),state:je()},v=e.resetOptions&&e.resetOptions.keepDirtyValues,C=vt(s.mode),_=vt(s.reValidateMode),E=s.criteriaMode===H.all,F=l=>d=>{clearTimeout(k),k=setTimeout(l,d)},y=async l=>{if(h.isValid||l){const d=s.resolver?G((await U()).errors):await B(o,!0);d!==n.isValid&&m.state.next({isValid:d})}},V=l=>h.isValidating&&m.state.next({isValidating:l}),q=(l,d=[],f,w,b=!0,p=!0)=>{if(w&&f){if(u.action=!0,p&&Array.isArray(x(o,l))){const S=f(x(o,l),w.argA,w.argB);b&&M(o,l,S)}if(p&&Array.isArray(x(n.errors,l))){const S=f(x(n.errors,l),w.argA,w.argB);b&&M(n.errors,l,S),hn(n.errors,l)}if(h.touchedFields&&p&&Array.isArray(x(n.touchedFields,l))){const S=f(x(n.touchedFields,l),w.argA,w.argB);b&&M(n.touchedFields,l,S)}h.dirtyFields&&(n.dirtyFields=ze(a,i)),m.state.next({name:l,isDirty:A(l,d),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else M(i,l,d)},R=(l,d)=>{M(n.errors,l,d),m.state.next({errors:n.errors})},se=(l,d,f,w)=>{const b=x(o,l);if(b){const p=x(i,l,N(f)?x(a,l):f);N(p)||w&&w.defaultChecked||d?M(i,l,d?p:Ue(b._f)):K(l,p),u.mount&&y()}},te=(l,d,f,w,b)=>{let p=!1,S=!1;const T={name:l};if(!f||w){h.isDirty&&(S=n.isDirty,n.isDirty=T.isDirty=A(),p=S!==T.isDirty);const D=oe(x(a,l),d);S=x(n.dirtyFields,l),D?P(n.dirtyFields,l):M(n.dirtyFields,l,!0),T.dirtyFields=n.dirtyFields,p=p||h.dirtyFields&&S!==!D}if(f){const D=x(n.touchedFields,l);D||(M(n.touchedFields,l,f),T.touchedFields=n.touchedFields,p=p||h.touchedFields&&D!==f)}return p&&b&&m.state.next(T),p?T:{}},he=(l,d,f,w)=>{const b=x(n.errors,l),p=h.isValid&&re(d)&&n.isValid!==d;if(e.delayError&&f?(g=F(()=>R(l,f)),g(e.delayError)):(clearTimeout(k),g=null,f?M(n.errors,l,f):P(n.errors,l)),(f?!oe(b,f):b)||!G(w)||p){const S={...w,...p&&re(d)?{isValid:d}:{},errors:n.errors,name:l};n={...n,...S},m.state.next(S)}V(!1)},U=async l=>s.resolver(i,s.context,cn(l||c.mount,o,s.criteriaMode,s.shouldUseNativeValidation)),X=async l=>{const{errors:d}=await U(l);if(l)for(const f of l){const w=x(d,f);w?M(n.errors,f,w):P(n.errors,f)}else n.errors=d;return d},B=async(l,d,f={valid:!0})=>{for(const w in l){const b=l[w];if(b){const{_f:p,...S}=b;if(p){const T=c.array.has(p.name),D=await Ct(b,i,E,s.shouldUseNativeValidation&&!d,T);if(D[p.name]&&(f.valid=!1,d))break;!d&&(x(D,p.name)?T?an(n.errors,D,p.name):M(n.errors,p.name,D[p.name]):P(n.errors,p.name))}S&&await B(S,d,f)}}return f.valid},I=()=>{for(const l of c.unMount){const d=x(o,l);d&&(d._f.refs?d._f.refs.every(f=>!qe(f)):!qe(d._f.ref))&&De(l)}c.unMount=new Set},A=(l,d)=>(l&&d&&M(i,l,d),!oe(tt(),a)),L=(l,d,f)=>sn(l,c,{...u.mount?i:N(d)?a:J(l)?{[l]:d}:d},f,d),z=l=>xe(x(u.mount?i:a,l,e.shouldUnregister?x(a,l,[]):[])),K=(l,d,f={})=>{const w=x(o,l);let b=d;if(w){const p=w._f;p&&(!p.disabled&&M(i,l,Jt(d,p)),b=Fe(p.ref)&&j(d)?"":d,Gt(p.ref)?[...p.ref.options].forEach(S=>S.selected=b.includes(S.value)):p.refs?ve(p.ref)?p.refs.length>1?p.refs.forEach(S=>(!S.defaultChecked||!S.disabled)&&(S.checked=Array.isArray(b)?!!b.find(T=>T===S.value):b===S.value)):p.refs[0]&&(p.refs[0].checked=!!b):p.refs.forEach(S=>S.checked=S.value===b):Qe(p.ref)?p.ref.value="":(p.ref.value=b,p.ref.type||m.values.next({name:l,values:{...i}})))}(f.shouldDirty||f.shouldTouch)&&te(l,b,f.shouldTouch,f.shouldDirty,!0),f.shouldValidate&&Re(l)},W=(l,d,f)=>{for(const w in d){const b=d[w],p=`${l}.${w}`,S=x(o,p);(c.array.has(l)||!Me(b)||S&&!S._f)&&!de(b)?W(p,b,f):K(p,b,f)}},ae=(l,d,f={})=>{const w=x(o,l),b=c.array.has(l),p=ee(d);M(i,l,p),b?(m.array.next({name:l,values:{...i}}),(h.isDirty||h.dirtyFields)&&f.shouldDirty&&m.state.next({name:l,dirtyFields:ze(a,i),isDirty:A(l,p)})):w&&!w._f&&!j(p)?W(l,p,f):K(l,p,f),xt(l,c)&&m.state.next({...n}),m.values.next({name:l,values:{...i}}),!u.mount&&r()},pe=async l=>{const d=l.target;let f=d.name,w=!0;const b=x(o,f),p=()=>d.type?Ue(b._f):Xr(l),S=T=>{w=Number.isNaN(T)||T===x(i,f,T)};if(b){let T,D;const ke=p(),ue=l.type===yt.BLUR||l.type===yt.FOCUS_OUT,tr=!dn(b._f)&&!s.resolver&&!x(n.errors,f)&&!b._f.deps||fn(ue,x(n.touchedFields,f),n.isSubmitted,_,C),Pe=xt(f,c,ue);M(i,f,ke),ue?(b._f.onBlur&&b._f.onBlur(l),g&&g(0)):b._f.onChange&&b._f.onChange(l);const $e=te(f,ke,ue,!1),rr=!G($e)||Pe;if(!ue&&m.values.next({name:f,type:l.type,values:{...i}}),tr)return h.isValid&&y(),rr&&m.state.next({name:f,...Pe?{}:$e});if(!ue&&Pe&&m.state.next({...n}),V(!0),s.resolver){const{errors:ut}=await U([f]);if(S(ke),w){const nr=Et(n.errors,o,f),ct=Et(ut,o,nr.name||f);T=ct.error,f=ct.name,D=G(ut)}}else T=(await Ct(b,i,E,s.shouldUseNativeValidation))[f],S(ke),w&&(T?D=!1:h.isValid&&(D=await B(o,!0)));w&&(b._f.deps&&Re(b._f.deps),he(f,D,T,$e))}},we=(l,d)=>{if(x(n.errors,d)&&l.focus)return l.focus(),1},Re=async(l,d={})=>{let f,w;const b=Be(l);if(V(!0),s.resolver){const p=await X(N(l)?l:b);f=G(p),w=l?!b.some(S=>x(p,S)):f}else l?(w=(await Promise.all(b.map(async p=>{const S=x(o,p);return await B(S&&S._f?{[p]:S}:S)}))).every(Boolean),!(!w&&!n.isValid)&&y()):w=f=await B(o);return m.state.next({...!J(l)||h.isValid&&f!==n.isValid?{}:{name:l},...s.resolver||!l?{isValid:f}:{},errors:n.errors,isValidating:!1}),d.shouldFocus&&!w&&Ee(o,we,l?b:c.mount),w},tt=l=>{const d={...a,...u.mount?i:{}};return N(l)?d:J(l)?x(d,l):l.map(f=>x(d,f))},rt=(l,d)=>({invalid:!!x((d||n).errors,l),isDirty:!!x((d||n).dirtyFields,l),isTouched:!!x((d||n).touchedFields,l),error:x((d||n).errors,l)}),Xt=l=>{l&&Be(l).forEach(d=>P(n.errors,d)),m.state.next({errors:l?n.errors:{}})},nt=(l,d,f)=>{const w=(x(o,l,{_f:{}})._f||{}).ref;M(n.errors,l,{...d,ref:w}),m.state.next({name:l,errors:n.errors,isValid:!1}),f&&f.shouldFocus&&w&&w.focus&&w.focus()},Yt=(l,d)=>ne(l)?m.values.subscribe({next:f=>l(L(void 0,d),f)}):L(l,d,!0),De=(l,d={})=>{for(const f of l?Be(l):c.mount)c.mount.delete(f),c.array.delete(f),d.keepValue||(P(o,f),P(i,f)),!d.keepError&&P(n.errors,f),!d.keepDirty&&P(n.dirtyFields,f),!d.keepTouched&&P(n.touchedFields,f),!s.shouldUnregister&&!d.keepDefaultValue&&P(a,f);m.values.next({values:{...i}}),m.state.next({...n,...d.keepDirty?{isDirty:A()}:{}}),!d.keepIsValid&&y()},st=({disabled:l,name:d,field:f,fields:w,value:b})=>{if(re(l)){const p=l?void 0:N(b)?Ue(f?f._f:x(w,d)._f):b;M(i,d,p),te(d,p,!1,!1,!0)}},Oe=(l,d={})=>{let f=x(o,l);const w=re(d.disabled);return M(o,l,{...f||{},_f:{...f&&f._f?f._f:{ref:{name:l}},name:l,mount:!0,...d}}),c.mount.add(l),f?st({field:f,disabled:d.disabled,name:l}):se(l,!0,d.value),{...w?{disabled:d.disabled}:{},...s.progressive?{required:!!d.required,min:ge(d.min),max:ge(d.max),minLength:ge(d.minLength),maxLength:ge(d.maxLength),pattern:ge(d.pattern)}:{},name:l,onChange:pe,onBlur:pe,ref:b=>{if(b){Oe(l,d),f=x(o,l);const p=N(b.value)&&b.querySelectorAll&&b.querySelectorAll("input,select,textarea")[0]||b,S=un(p),T=f._f.refs||[];if(S?T.find(D=>D===p):p===f._f.ref)return;M(o,l,{_f:{...f._f,...S?{refs:[...T.filter(qe),p,...Array.isArray(x(a,l))?[{}]:[]],ref:{type:p.type,name:l}}:{ref:p}}}),se(l,!1,void 0,p)}else f=x(o,l,{}),f._f&&(f._f.mount=!1),(s.shouldUnregister||d.shouldUnregister)&&!(Qr(c.array,l)&&u.action)&&c.unMount.add(l)}}},at=()=>s.shouldFocusError&&Ee(o,we,c.mount),Qt=l=>{re(l)&&(m.state.next({disabled:l}),Ee(o,d=>{d.disabled=l},0,!1))},ot=(l,d)=>async f=>{f&&(f.preventDefault&&f.preventDefault(),f.persist&&f.persist());let w=ee(i);if(m.state.next({isSubmitting:!0}),s.resolver){const{errors:b,values:p}=await U();n.errors=b,w=p}else await B(o);P(n.errors,"root"),G(n.errors)?(m.state.next({errors:{}}),await l(w,f)):(d&&await d({...n.errors},f),at(),setTimeout(at)),m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(n.errors),submitCount:n.submitCount+1,errors:n.errors})},er=(l,d={})=>{x(o,l)&&(N(d.defaultValue)?ae(l,x(a,l)):(ae(l,d.defaultValue),M(a,l,d.defaultValue)),d.keepTouched||P(n.touchedFields,l),d.keepDirty||(P(n.dirtyFields,l),n.isDirty=d.defaultValue?A(l,x(a,l)):A()),d.keepError||(P(n.errors,l),h.isValid&&y()),m.state.next({...n}))},it=(l,d={})=>{const f=l?ee(l):a,w=ee(f),b=l&&!G(l)?w:a;if(d.keepDefaultValues||(a=f),!d.keepValues){if(d.keepDirtyValues||v)for(const p of c.mount)x(n.dirtyFields,p)?M(b,p,x(i,p)):ae(p,x(b,p));else{if(Xe&&N(l))for(const p of c.mount){const S=x(o,p);if(S&&S._f){const T=Array.isArray(S._f.refs)?S._f.refs[0]:S._f.ref;if(Fe(T)){const D=T.closest("form");if(D){D.reset();break}}}}o={}}i=e.shouldUnregister?d.keepDefaultValues?ee(a):{}:ee(b),m.array.next({values:{...b}}),m.values.next({values:{...b}})}c={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!u.mount&&r(),u.mount=!h.isValid||!!d.keepIsValid,u.watch=!!e.shouldUnregister,m.state.next({submitCount:d.keepSubmitCount?n.submitCount:0,isDirty:d.keepDirty?n.isDirty:!!(d.keepDefaultValues&&!oe(l,a)),isSubmitted:d.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:d.keepDirtyValues?n.dirtyFields:d.keepDefaultValues&&l?ze(a,l):{},touchedFields:d.keepTouched?n.touchedFields:{},errors:d.keepErrors?n.errors:{},isSubmitSuccessful:d.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},lt=(l,d)=>it(ne(l)?l(i):l,d);return{control:{register:Oe,unregister:De,getFieldState:rt,handleSubmit:ot,setError:nt,_executeSchema:U,_getWatch:L,_getDirty:A,_updateValid:y,_removeUnmounted:I,_updateFieldArray:q,_updateDisabledField:st,_getFieldArray:z,_reset:it,_resetDefaultValues:()=>ne(s.defaultValues)&&s.defaultValues().then(l=>{lt(l,s.resetOptions),m.state.next({isLoading:!1})}),_updateFormState:l=>{n={...n,...l}},_disableForm:Qt,_subjects:m,_proxyFormState:h,get _fields(){return o},get _formValues(){return i},get _state(){return u},set _state(l){u=l},get _defaultValues(){return a},get _names(){return c},set _names(l){c=l},get _formState(){return n},set _formState(l){n=l},get _options(){return s},set _options(l){s={...s,...l}}},trigger:Re,register:Oe,handleSubmit:ot,watch:Yt,setValue:ae,getValues:tt,reset:lt,resetField:er,clearErrors:Xt,unregister:De,setError:nt,setFocus:(l,d={})=>{const f=x(o,l),w=f&&f._f;if(w){const b=w.refs?w.refs[0]:w.ref;b.focus&&(b.focus(),d.shouldSelect&&b.select())}},getFieldState:rt}}function Le(e={}){const r=t.Cn.useRef(),s=t.Cn.useRef(),[n,o]=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={...mn(e,()=>o(i=>({...i}))),formState:n});const a=r.current.control;return a._options=e,nn({subject:a._subjects.state,next:i=>{rn(i,a._proxyFormState,a._updateFormState,!0)&&o({...a._formState})}}),t.Cn.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),t.Cn.useEffect(()=>{if(a._proxyFormState.isDirty){const i=a._getDirty();i!==n.isDirty&&a._subjects.state.next({isDirty:i})}},[a,n.isDirty]),t.Cn.useEffect(()=>{e.values&&!oe(e.values,s.current)?(a._reset(e.values,a._options.resetOptions),s.current=e.values):a._resetDefaultValues()},[e.values,a]),t.Cn.useEffect(()=>{a._state.mount||(a._updateValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),r.current.formState=tn(n,a),r.current}var At=function(e,r,s){if(e&&"reportValidity"in e){var n=x(s,r);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},gn=function(e,r){var s=function(o){var a=r.fields[o];a&&a.ref&&"reportValidity"in a.ref?At(a.ref,o,e):a.refs&&a.refs.forEach(function(i){return At(i,o,e)})};for(var n in r.fields)s(n)},bn=function(e,r){r.shouldUseNativeValidation&&gn(e,r);var s={};for(var n in e){var o=x(r.fields,n),a=Object.assign(e[n]||{},{ref:o&&o.ref});if(vn(r.names||Object.keys(e),n)){var i=Object.assign({},yn(x(s,n)));M(i,"root",a),M(s,n,i)}else M(s,n,a)}return s},yn=function(e){return Array.isArray(e)?e.filter(Boolean):[]},vn=function(e,r){return e.some(function(s){return s.startsWith(r+".")})},xn=function(e,r){for(var s={};e.issues.length;){var n=e.issues[0];if(n.path){var o=n.path.map(function(u){return u.key}).join(".");if(s[o]||(s[o]={message:n.message,type:n.validation}),r){var a=s[o].types,i=a&&a[n.validation];s[o]=zt(o,r,s,n.validation,i?[].concat(i,n.message):n.message)}e.issues.shift()}}return s},Ne=function(e,r,s){return s===void 0&&(s={}),function(n,o,a){try{return Promise.resolve(function(i,u){try{var c=function(){function g(h){return{values:s.raw?n:h,errors:{}}}var k=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},r);return s.mode==="sync"?g(t.parse(e,n,k)):Promise.resolve(t.parseAsync(e,n,k)).then(g)}()}catch(g){return u(g)}return c&&c.then?c.then(void 0,u):c}(0,function(i){if(i instanceof t.ValiError)return{values:{},errors:bn(xn(i,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}}};const Ft=27,It=12,Mt=10,wn=t.isSubmissionOfType("enum"),kn=e=>{const r={min:e.minSelected??0,max:e.maxSelected??e.options.length};return Ne(t.object({checked:t.transform(t.record(t.boolean()),s=>Object.entries(s).filter(([n,o])=>o).map(([n,o])=>n),[t.maxLength(r.max,`Please select at most ${r.max} option${r.max!==1?"s":""}`),t.minLength(r.min,`Please select at least ${r.min} option${r.min!==1?"s":""}`)])}))},_n=t.k$1(({option:e,...r},s)=>t.o(t.k,{children:[t.o("input",{class:"peer sr-only h-full",type:"checkbox",...r,ref:s}),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})]})),Tt=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:Pt}}}),Sn=({input:e,onSubmitSuccess:r})=>{var g,k;const s=e.key?(g=t.store.current$.value.flow)==null?void 0:g.data.submissions[e.key]:void 0,n=(e.config.minSelected===1||e.config.minSelected===void 0)&&e.config.maxSelected===1,o=n&&e.config.options.length===2,{register:a,handleSubmit:i,formState:{errors:u}}=Le({defaultValues:{checked:n?{}:wn(s)?Object.fromEntries(s.value.map(h=>[h,!0])):{}},resolver:kn(e.config)}),c=Ze();return o?t.o("ul",{style:{maxHeight:6.5*Ft+5*It+2*Mt},class:Tt({variant:"booleanLike"}),children:e.config.options.map((h,m)=>t.o("li",{class:"flex-1",children:t.o($t,{type:"submit",ref:v=>{v&&m===0&&(c.current=v)},label:h.label,value:"true",onClick:()=>r({type:"enum",value:[h.value]})})},h.value))}):t.o("form",{noValidate:!0,onSubmit:h=>i(m=>{const v=m.checked;r({type:"enum",value:v})})(h),children:[t.o("div",{class:"flex items-center gap-1",children:[t.o("ul",{style:{maxHeight:6.5*Ft+5*It+2*Mt},class:Tt({variant:e.config.options.length===1?"singleOption":void 0}),children:e.config.options.map((h,m)=>{const v=`checked.${h.value}`,{ref:C,..._}=a(v);return t.o("li",{class:"relative",children:t.o(_n,{option:h,autoFocus:m===0,ref:E=>{E&&m===0&&(c.current=E),C(E)},id:v,..._,onClick:n?()=>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:[n?null:t.o(ie,{}),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:(k=u.checked)==null?void 0:k.root})})]})},Cn=t.isSubmissionOfType("number"),_e={number:()=>"Please enter a valid number",min:e=>`Please enter a number greater than or equal to ${e}`,max:e=>`Please enter a number less than or equal to ${e}`,decimalCases:e=>`Please enter a number with at most ${e} decimal cases`},En=e=>{const r=e.min??Number.MIN_SAFE_INTEGER,s=e.max??Number.MAX_SAFE_INTEGER,n=e.decimalCases??0;return Ne(t.object({number:t.number(_e.number(),[t.minValue(r,_e.min(r)),t.maxValue(s,_e.max(s)),t.custom(o=>o===Number(o.toFixed(n)),_e.decimalCases(n))])}))},An=({input:e,onSubmitSuccess:r})=>{var k;const s=e.config.defaultValue,n=e.key?(k=t.store.current$.value.flow)==null?void 0:k.data.submissions[e.key]:void 0,{register:o,handleSubmit:a,formState:{errors:i}}=Le({defaultValues:{number:s?Number(s):Cn(n)?n.value:void 0},resolver:En(e.config)}),{ref:u,...c}=o("number",{required:!e.config.optional,valueAsNumber:!0}),g=t._$1();return t.y(()=>{g.current&&(g.current.focus(),g.current.select())},[]),t.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:a(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",{...c,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(g.current=h),u(h)},type:"text",min:e.config.min,max:e.config.max,class:ye({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(ie,{})]}),t.o(fe,{error:i.number})]})},Fn=e=>{if(e==="")return{countryCode:"",phoneNumber:""};const r=Object.entries(Je).find(o=>e.startsWith(o[1])),s=r?r[1]:"",n=e.replace(s,"");return/^\d+$/.test(n)?{countryCode:s,phoneNumber:n}:{countryCode:"",phoneNumber:""}},In="44",We="That doesn’t look like a valid phone number",Vt=e=>({min:`The phone number needs to be at least ${e.minChars} digits long.`,max:`The phone number can't be longer than ${e.maxChars} digits.`}),Mn=t.isSubmissionOfType("string"),Tn=t.isSubmissionOfType("phone"),Vn=t.string(We,[t.regex(/^\+?[0-9 -]+$/,We)]),Ln=t.string("Please select a country code",[t.regex(/^\+?[0-9 -]+$/,We)]),Nn=()=>Ne(t.object({countryCode:Ln,phoneNumber:t.transform(Vn,e=>e.replace(/[^0-9]/g,""),[])})),Rn=({input:e,onSubmitSuccess:r})=>{var C;const s=e.key?(C=t.store.current$.value.flow)==null?void 0:C.data.submissions[e.key]:void 0,[n,o]=t.h(),a=Mn(s)?Fn(s.value):Tn(s)?s.value:void 0,{register:i,handleSubmit:u,formState:{errors:c},watch:g}=Le({defaultValues:{countryCode:(a==null?void 0:a.countryCode)??e.config.defaultValue.countryCode??In,phoneNumber:(a==null?void 0:a.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:Nn()}),{ref:k,...h}=i("phoneNumber",{required:!e.config.optional}),m=t._$1(),v=g("countryCode");return t.y(()=>{m.current&&(m.current.focus(),m.current.select())},[]),t.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:u(_=>{const E=_.phoneNumber.replace(/[^0-9]/g,""),F=_.countryCode.replace(/[^0-9]/g,"");if(o(void 0),E.length+F.length>(e.config.maxChars||Number.POSITIVE_INFINITY))return o(Vt(e.config).max);if(E.length+F.length<(e.config.minChars||0))return o(Vt(e.config).min);e.config.submissionFormat==="phone"?r({type:"phone",value:{countryCode:F,phoneNumber:E}}):r({type:"string",value:v+_.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:["+",v]}),t.o("select",{...i("countryCode",{}),id:`isdk_phone_${e.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(Je).map(([_,E])=>t.o("option",{value:E,children:[_," (+",E,")"]},_))})]}),t.o("input",{...h,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:_=>{_&&(m.current=_),k(_)},class:ye({optional:e.config.optional,className:"flex-1 rounded-r-full"}),placeholder:e.config.placeholder}),e.config.optional&&t.o(le,{class:"absolute right-0 top-0",onClick:()=>r(null)})]}),t.o(ie,{})]}),t.o(fe,{error:c.countryCode||c.phoneNumber||{message:n}})]})},Dn=({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"})]})]})})}),Ke={empty:"Please enter some text",email:"That doesn’t look like a valid email address",phone:"That doesn’t look like a valid phone number",url:"That doesn’t look like a valid URL"},On={email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},Pn=t.isSubmissionOfType("string"),$n=e=>{const r={maxLength:`Please enter no more than ${e.maxChars??999} characters`,minLength:`Please enter ${e.minChars??1} or more characters`};return Ne(t.object({text:{email:t.string(Ke.email,[t.email(Ke.email),t.minLength(e.minChars??1,r.minLength),t.maxLength(e.maxChars??1/0,r.maxLength)]),text:t.string([t.minLength(e.minChars??1,r.minLength),t.maxLength(e.maxChars??1/0,r.maxLength)]),url:t.string([t.url(Ke.url),t.minLength(e.minChars??1,r.minLength),t.maxLength(e.maxChars??1/0,r.maxLength)])}[e.format]}))},Bn=({input:e,onSubmitSuccess:r})=>{var k;const s=e.key?(k=t.store.current$.value.flow)==null?void 0:k.data.submissions[e.key]:void 0,n=e.config.defaultValue,{register:o,handleSubmit:a,formState:{errors:i}}=Le({defaultValues:{text:n||(Pn(s)?s.value:"")},resolver:$n(e.config)}),{ref:u,...c}=o("text",{required:!e.config.optional}),g=t._$1();return t.y(()=>{g.current&&(g.current.focus(),g.current.select())},[]),t.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:a(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",...c,...On[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(g.current=h),u(h)},placeholder:e.config.placeholder,class:ye({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(ie,{})]}),t.o(fe,{error:i.text})]})},jn={text:Bn,phone:Rn,"multiple-choice":Sn,boolean:zr,file:Zr,submit:Dn,address:Pr,number:An},qn=({logger:e})=>{var a;const r=(a=t.store.current$.value.flow)==null?void 0:a.data.currentInput,[s,n]=Er(),o=t._$1(null);return t.store.inputHeight$.value=n.height,t.p(()=>{const i=o.current;if(i)return i.addEventListener("transitionstart",$.scrollToEnd.smooth),i.addEventListener("transitioncancel",$.scrollToEnd.smooth),i.addEventListener("transitionend",$.scrollToEnd.smooth),()=>{i.removeEventListener("transitionstart",$.scrollToEnd.smooth),i.removeEventListener("transitioncancel",$.scrollToEnd.smooth),i.removeEventListener("transitionend",$.scrollToEnd.smooth)}},[]),t.o("div",{ref:o,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:n.height},children:t.o("div",{ref:s,class:"border-divider flex flex-col justify-end border-t",children:r?(()=>{const i=jn[r.type];return t.o(i,{logger:e,onSubmitSuccess:$.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:ye({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),t.o(ie,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};var zn=function(e){return e instanceof RegExp},Un=function(r){var s=/[\\^$.*+?()[\]{}|]/g,n=RegExp(s.source);return r&&n.test(r)?r.replace(s,"\\$&"):r},Zt=function(e){return typeof e=="string"},Kn=function(e){var r=[];return e.forEach(function(s){Array.isArray(s)?r=r.concat(s):r.push(s)}),r};function Gn(e,r,s){var n=0,o=0;if(e==="")return e;if(!e||!Zt(e))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var a=r;zn(a)||(a=new RegExp("("+Un(a)+")","gi"));for(var i=e.split(a),u=1,c=i.length;u<c;u+=2){if(i[u]===void 0||i[u-1]===void 0){console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");continue}o=i[u].length,n+=i[u-1].length,i[u]=s(i[u],u,n),n+=o}return i}var Hn=function(r,s,n){return Array.isArray(r)||(r=[r]),Kn(r.map(function(o){return Zt(o)?Gn(o,s,n):o}))};const Se=t.getDefaultExportFromCjs(Hn),Wn=/(\[[^\]]+\]\([^)]+\))/g,Jn=/\[([^\]]+)\]\(([^)]+)\)/,Zn=/(https?:\/\/[^\s]+)/g,Xn=/_(.*?)_/g,Yn=/\*\*(.*?)\*\*/g,Lt="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",Qn=e=>{const r=Se(e,Wn,(a,i)=>{const[,u,c]=a.match(Jn)??[];return c?t.o("a",{class:Lt,href:c,children:u??c},c+i):t.o("span",{children:"INVALID LINK"})}),s=Se(r,Zn,(a,i)=>t.o("a",{class:Lt,href:a,children:a},a+i)),n=Se(s,Xn,(a,i)=>t.o("em",{children:a},a+i));return Se(n,Yn,(a,i)=>t.o("strong",{children:a},a+i))},es=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"}}),ts=({children:e,className:r,animate:s,side:n,...o})=>t.o("p",{style:{transformOrigin:n==="left"?"0% 50%":"100% 50%"},class:es({className:r,side:n,animate:s}),...o,children:e}),rs=({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"})})]})}),ns=({className:e,...r})=>(t.p(()=>{$.scrollToEnd.smooth()}),t.o("div",{"aria-hidden":!0,children:$.isBotTyping$.value===!0?t.o("div",{"aria-label":"Typing…",class:t.clsx("flex gap-1 p-4",e),...r,children:Array.from({length:3},(s,n)=>t.o("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-n*200}ms`}}))}):void 0})),ss={bot:"left",user:"right"},as=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]"}}}),os=({lastSentMessageFooter:e})=>{var s;const r=((s=t.store.current$.value.flow)==null?void 0:s.data.messages)??[];return t.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((n,o)=>t.o(t.k,{children:t.o("li",{class:"flex",children:t.N(n).with({type:"system"},a=>t.o("p",{class:as({variant:a.variant}),children:a.text})).with({type:"text",author:t._.union("bot","user")},a=>{const i=a.author==="user"&&!r.slice(o+1).some(g=>g.type==="text"&&g.author==="user"),u=o===r.length-1,c=a.author==="bot"?Qn(a.text):a.text;return t.o(ts,{animate:u,side:ss[a.author],children:[c,i?e:null]},o)}).with({type:"link"},a=>t.o(rs,{message:a})).with({type:"image"},a=>t.o("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:a.url,style:{aspectRatio:a.width/a.height}})).with({type:"file"},a=>t.o(Hr,{class:a.author==="bot"?void 0:"ml-auto",file:{name:a.fileName,sizeKb:a.fileSizeKb}})).with({type:"loading"},a=>{const i=r[r.length-1];return!(a===i)||$.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()})},o)),t.o(ns,{},"typing")]})},is=({logger:e,apiClient:r,analytics:s})=>{const{flow:n}=t.store.current$.value;t.invariant(n,"Flow is required to exist to show chatbot body");const o=t.store.viewState$.value,{chatRef:a,chatService:i}=Vr(),[u,c]=t.h();return t.y(()=>{o==="maximised"&&$.scrollToEnd.instant()},[o]),t.y(()=>{var _,E;const{state:g,flow:k}=t.store.current$.peek();if(g!=="loaded")throw new Error(t.ERROR_MESSAGES.invalid_state);let h=k.data.nodeHistory.at(-1);if($.scrollToEnd.instant(),t.store.setInput(void 0),k.data.isFinished)return;h===void 0?(h=t.getHeadOrThrow(n.nodes).id,t.store.setCurrentNodeId(h),s.log({event:"FLOW_START",properties:{flow_id:n.id,flow_version:n.version,flow_session_id:k.data.flowSessionId,flow_build:n.build,job:n.job},customProperties:(_=n.analytics)==null?void 0:_.customProperties})):t.store.removeMessagesSentByNodeIds([h]);const{interpret:m,abort:v,undo:C}=or({context:n.context,analytics:{service:s,customProperties:(E=n.analytics)==null?void 0:E.customProperties},apiClient:r,logger:e,flow:n,chatService:i,getSubmissions:()=>{var F;return(F=t.store.current$.peek().flow)==null?void 0:F.data.submissions},onInterpret:(F,y)=>{var q;const V=t.store.current$.peek().flow;t.invariant(V),y&&(V.data.sequence=V.data.sequence+1,s.log({event:"FLOW_NODE",properties:{flow_id:n.id,flow_version:n.version,from_node_id:y.id,flow_build:n.build,to_node_id:F.id,sequence:V.data.sequence,flow_session_id:V.data.flowSessionId,job:n.job},customProperties:(q=n.analytics)==null?void 0:q.customProperties})),t.store.setCurrentNodeId(F.id)},onFlowEnd:async()=>{var y;t.store.markAsFinished();const F=t.store.current$.peek().flow;t.invariant(F),s.log({event:"FLOW_END",properties:{flow_id:n.id,flow_version:n.version,flow_session_id:F.data.flowSessionId,flow_build:n.build,job:n.job},customProperties:(y=n.analytics)==null?void 0:y.customProperties})}});return c(()=>C),m(h),v},[s,r,i,e,n]),t.o(t.k,{children:[t.o("div",{ref:a,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(os,{lastSentMessageFooter:n.data.isFinished||!u?null:t.o(us,{undoFn:u})})}),t.o(qn,{logger:e})]})},ls=e=>"key"in e.data&&e.data.key?[e.data.key]:"keys"in e.data?Object.values(e.data.keys).filter(r=>typeof r=="string"):[],us=({undoFn:e})=>t.o("div",{class:"absolute bottom-0 right-0 flex w-full translate-y-full justify-end",children:t.o("button",{class:"fr touch-hitbox text-neutral-9 hover:text-neutral-12 rounded-full p-1 text-right text-xs transition-all",onClick:async()=>{const{flow:r}=t.store.current$.peek();t.invariant(r);const{removed:s}=e(r.data.nodeHistory),n=r.data.nodeHistory.splice(-s);n.length!==0&&(t.store.removeMessagesSentByNodeIds(n),t.store.setInput(void 0),n.pop(),n.map(o=>r.nodes.find(a=>a.id===o)).filter(Boolean).flatMap(ls).forEach(o=>delete r.data.submissions[o]),t.store.current$.value={...t.store.current$.value})},children:"Undo"})});exports.ChatbotBody=is;
|