@inploi/plugin-chatbot 5.0.0 → 5.1.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 +1 -1
- package/dist/{chatbot-body-b82a7ac9.js → chatbot-body-81bfa2bc.js} +2 -2
- package/dist/{chatbot-body-007d9cfc.cjs → chatbot-body-f17e1b0d.cjs} +1 -1
- package/dist/{index-f5a052d0.js → index-4da34b43.js} +1 -1
- package/dist/{index-d5d1d0e4.cjs → index-610bb8d8.cjs} +1 -1
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +1 -1
- package/package.json +5 -5
package/cdn/index.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
`,_a="inploi-chatbot",ya=`[data-widget='${_a}']`,Gd=()=>({getOrCreateChatbotElement:()=>{const t=document.querySelector(ya);if(t)return document.body.appendChild(t),t;const e=document.createElement("div");return document.body.appendChild(e),e.dataset.widget=_a,e}});var Ot;function lr(t){return{lang:(t==null?void 0:t.lang)??(Ot==null?void 0:Ot.lang),message:t==null?void 0:t.message,abortEarly:(t==null?void 0:t.abortEarly)??(Ot==null?void 0:Ot.abortEarly),abortPipeEarly:(t==null?void 0:t.abortPipeEarly)??(Ot==null?void 0:Ot.abortPipeEarly)}}var on;function Wd(t){return on==null?void 0:on.get(t)}var sn;function Yd(t){return sn==null?void 0:sn.get(t)}var ln;function Jd(t,e){var r;return(r=ln==null?void 0:ln.get(t))==null?void 0:r.get(e)}function Qt(t){var r,n;const e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&((n=(r=Object.getPrototypeOf(t))==null?void 0:r.constructor)==null?void 0:n.name))??"null":e}function G(t,e,r,n,i){const a=i&&"input"in i?i.input:r.value,o=(i==null?void 0:i.expected)??t.expects??null,s=(i==null?void 0:i.received)??Qt(a),l={kind:t.kind,type:t.type,input:a,expected:o,received:s,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${s}`,requirement:t.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},h=t.kind==="schema",p=(i==null?void 0:i.message)??t.message??Jd(t.reference,l.lang)??(h?Yd(l.lang):null)??n.message??Wd(l.lang);p!==void 0&&(l.message=typeof p=="function"?p(l):p),h&&(r.typed=!1),r.issues?r.issues.push(l):r.issues=[l]}function lt(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},lr())}}}function Zd(t,e){return Object.hasOwn(t,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function xa(t,e){const r=[...new Set(t)];return r.length>1?`(${r.join(` ${e} `)})`:r[0]??"never"}var cn=class extends Error{constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}},Xd=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;function ka(t,e){return{kind:"validation",type:"check",reference:ka,async:!1,expects:null,requirement:t,message:e,"~run"(r,n){return r.typed&&!this.requirement(r.value)&&G(this,"input",r,n),r}}}function Sa(t){return{kind:"validation",type:"email",reference:Sa,expects:null,async:!1,requirement:Xd,message:t,"~run"(e,r){return e.typed&&!this.requirement.test(e.value)&&G(this,"email",e,r),e}}}function Oe(t,e){return{kind:"validation",type:"max_length",reference:Oe,async:!1,expects:`<=${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&r.value.length>this.requirement&&G(this,"length",r,n,{received:`${r.value.length}`}),r}}}function Ca(t,e){return{kind:"validation",type:"max_value",reference:Ca,async:!1,expects:`<=${t instanceof Date?t.toJSON():Qt(t)}`,requirement:t,message:e,"~run"(r,n){return r.typed&&!(r.value<=this.requirement)&&G(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():Qt(r.value)}),r}}}function pe(t,e){return{kind:"validation",type:"min_length",reference:pe,async:!1,expects:`>=${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&r.value.length<this.requirement&&G(this,"length",r,n,{received:`${r.value.length}`}),r}}}function $a(t,e){return{kind:"validation",type:"min_value",reference:$a,async:!1,expects:`>=${t instanceof Date?t.toJSON():Qt(t)}`,requirement:t,message:e,"~run"(r,n){return r.typed&&!(r.value>=this.requirement)&&G(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():Qt(r.value)}),r}}}function Ea(t,e){return{kind:"validation",type:"regex",reference:Ea,async:!1,expects:`${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&!this.requirement.test(r.value)&&G(this,"format",r,n),r}}}function cr(t){return{kind:"transformation",type:"transform",reference:cr,async:!1,operation:t,"~run"(e){return e.value=this.operation(e.value),e}}}function Ia(t){return{kind:"validation",type:"url",reference:Ia,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:t,"~run"(e,r){return e.typed&&!this.requirement(e.value)&&G(this,"URL",e,r),e}}}function Qd(t,e,r){return typeof t.fallback=="function"?t.fallback(e,r):t.fallback}function un(t,e,r){return typeof t.default=="function"?t.default(e,r):t.default}function Ta(){return{kind:"schema",type:"any",reference:Ta,expects:"any",async:!1,get"~standard"(){return lt(this)},"~run"(t){return t.typed=!0,t}}}function dn(t,e){return{kind:"schema",type:"array",reference:dn,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return lt(this)},"~run"(r,n){var a;const i=r.value;if(Array.isArray(i)){r.typed=!0,r.value=[];for(let o=0;o<i.length;o++){const s=i[o],l=this.item["~run"]({value:s},n);if(l.issues){const h={type:"array",origin:"value",input:i,key:o,value:s};for(const p of l.issues)p.path?p.path.unshift(h):p.path=[h],(a=r.issues)==null||a.push(p);if(r.issues||(r.issues=l.issues),n.abortEarly){r.typed=!1;break}}l.typed||(r.typed=!1),r.value.push(l.value)}}else G(this,"type",r,n);return r}}}function ur(t){return{kind:"schema",type:"boolean",reference:ur,expects:"boolean",async:!1,message:t,get"~standard"(){return lt(this)},"~run"(e,r){return typeof e.value=="boolean"?e.typed=!0:G(this,"type",e,r),e}}}function fn(t,e){return{kind:"schema",type:"literal",reference:fn,expects:Qt(t),async:!1,literal:t,message:e,get"~standard"(){return lt(this)},"~run"(r,n){return r.value===this.literal?r.typed=!0:G(this,"type",r,n),r}}}function Aa(t,e){return{kind:"schema",type:"nullable",reference:Aa,expects:`(${t.expects} | null)`,async:!1,wrapped:t,default:e,get"~standard"(){return lt(this)},"~run"(r,n){return r.value===null&&(this.default!==void 0&&(r.value=un(this,r,n)),r.value===null)?(r.typed=!0,r):this.wrapped["~run"](r,n)}}}function Fe(t){return{kind:"schema",type:"number",reference:Fe,expects:"number",async:!1,message:t,get"~standard"(){return lt(this)},"~run"(e,r){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:G(this,"type",e,r),e}}}function rt(t,e){return{kind:"schema",type:"object",reference:rt,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return lt(this)},"~run"(r,n){var a;const i=r.value;if(i&&typeof i=="object"){r.typed=!0,r.value={};for(const o in this.entries){const s=this.entries[o];if(o in i||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){const l=o in i?i[o]:un(s),h=s["~run"]({value:l},n);if(h.issues){const p={type:"object",origin:"value",input:i,key:o,value:l};for(const u of h.issues)u.path?u.path.unshift(p):u.path=[p],(a=r.issues)==null||a.push(u);if(r.issues||(r.issues=h.issues),n.abortEarly){r.typed=!1;break}}h.typed||(r.typed=!1),r.value[o]=h.value}else if(s.fallback!==void 0)r.value[o]=Qd(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"&&(G(this,"key",r,n,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:i,key:o,value:i[o]}]}),n.abortEarly))break}}else G(this,"type",r,n);return r}}}function xt(t,e){return{kind:"schema",type:"optional",reference:xt,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return lt(this)},"~run"(r,n){return r.value===void 0&&(this.default!==void 0&&(r.value=un(this,r,n)),r.value===void 0)?(r.typed=!0,r):this.wrapped["~run"](r,n)}}}function Ma(t,e){return{kind:"schema",type:"picklist",reference:Ma,expects:xa(t.map(Qt),"|"),async:!1,options:t,message:e,get"~standard"(){return lt(this)},"~run"(r,n){return this.options.includes(r.value)?r.typed=!0:G(this,"type",r,n),r}}}function hn(t,e,r){return{kind:"schema",type:"record",reference:hn,expects:"Object",async:!1,key:t,value:e,message:r,get"~standard"(){return lt(this)},"~run"(n,i){var o,s;const a=n.value;if(a&&typeof a=="object"){n.typed=!0,n.value={};for(const l in a)if(Zd(a,l)){const h=a[l],p=this.key["~run"]({value:l},i);if(p.issues){const f={type:"object",origin:"key",input:a,key:l,value:h};for(const b of p.issues)b.path=[f],(o=n.issues)==null||o.push(b);if(n.issues||(n.issues=p.issues),i.abortEarly){n.typed=!1;break}}const u=this.value["~run"]({value:h},i);if(u.issues){const f={type:"object",origin:"value",input:a,key:l,value:h};for(const b of u.issues)b.path?b.path.unshift(f):b.path=[f],(s=n.issues)==null||s.push(b);if(n.issues||(n.issues=u.issues),i.abortEarly){n.typed=!1;break}}(!p.typed||!u.typed)&&(n.typed=!1),p.typed&&(n.value[p.value]=u.value)}}else G(this,"type",n,i);return n}}}function W(t){return{kind:"schema",type:"string",reference:W,expects:"string",async:!1,message:t,get"~standard"(){return lt(this)},"~run"(e,r){return typeof e.value=="string"?e.typed=!0:G(this,"type",e,r),e}}}function Na(t){let e;if(t)for(const r of t)e?e.push(...r.issues):e=r.issues;return e}function pn(t,e){return{kind:"schema",type:"union",reference:pn,expects:xa(t.map(r=>r.expects),"|"),async:!1,options:t,message:e,get"~standard"(){return lt(this)},"~run"(r,n){let i,a,o;for(const s of this.options){const l=s["~run"]({value:r.value},n);if(l.typed)if(l.issues)a?a.push(l):a=[l];else{i=l;break}else o?o.push(l):o=[l]}if(i)return i;if(a){if(a.length===1)return a[0];G(this,"type",r,n,{issues:Na(a)}),r.typed=!0}else{if((o==null?void 0:o.length)===1)return o[0];G(this,"type",r,n,{issues:Na(o)})}return r}}}function Oa(t,e,r){const n=t["~run"]({value:e},lr(r));if(n.issues)throw new cn(n.issues);return n.value}async function tf(t,e,r){const n=await t["~run"]({value:e},lr(r));if(n.issues)throw new cn(n.issues);return n.value}function ef(t,e){const r={};for(const n in t.entries)r[n]=!e||e.includes(n)?xt(t.entries[n]):t.entries[n];return{...t,entries:r,get"~standard"(){return lt(this)}}}function Ht(...t){return{...t[0],pipe:t,get"~standard"(){return lt(this)},"~run"(e,r){for(const n of t)if(n.kind!=="metadata"){if(e.issues&&(n.kind==="schema"||n.kind==="transformation")){e.typed=!1;break}(!e.issues||!r.abortEarly&&!r.abortPipeEarly)&&(e=n["~run"](e,r))}return e}}}function rf(t,e,r){const n=t["~run"]({value:e},lr(r));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}const Fa=Ht(pn([W(),Fe()]),cr(String)),Pa=rt({id:Fa,version:Fe(),build:Fe(),nodes:dn(Ta()),context_schema:xt(Aa(hn(W(),rt({required:ur(),type:pn([fn("string"),fn("number")])}))))}),nf=rt({flow:Pa}),af=rt({company:rt({name:W()}),flow:Pa,job:rt({id:Fa,title:W()}),user:xt(rt({city:xt(W()),country:xt(W()),isEU:xt(ur()),continent:xt(W())}))}),of={pathname:"/flow/job/:id",method:"GET",schema:{searchParams:Do(),response:af}},sf={pathname:"/flow/id/:id",method:"GET",schema:{response:nf}};var lf=["1","2","3","4","5","6","7","8","9","10","11","12"],cf={light:{1:[98.8,.015],2:[97.8,.018],3:[95.8,.025],4:[92,.04],5:[89,.05],6:[85,.07],7:[80.5,.08],8:[74,.11],9:[60,.22],10:[56,.23],11:[50,.19],12:[25,.18]},dark:{1:[19,.015],2:[21,.018],3:[25.5,.055],4:[29.3,.084],5:[33.5,.098],6:[39.05,.107],7:[45,.11],8:[55,.13],9:[60,.22],10:[67,.18],11:[79.3,.12],12:[95,.04]}},uf=(t,e=1,r)=>n=>{const[i,a]=cf[r][n];return"oklch("+i+"% "+a*e+" "+t+")"},gn=t=>{const e=uf(t.hue,t.chroma,t.mode);return Object.fromEntries(lf.map(r=>[t.prefix+r,t.transform(e(r))]))},vn=t=>t,df=t=>{const e=Object.keys(t).flatMap(r=>{const n=t[r];return typeof n=="object"&&n!==null?Object.keys(n).map(i=>{const a=n[i];return[`${String(r)}.${i}`,a]}):[[r,n]]});return Object.fromEntries(e)},dr=t=>!!t&&typeof t=="object"&&!Array.isArray(t),bn=(t,...e)=>{if(!e.length)return t;const r=e.shift();if(dr(t)&&dr(r))for(const n in r){const i=r[n];if(dr(i)){t[n]||Object.assign(t,{[n]:{}});const a=t[n];dr(a)&&bn(a,i)}else Object.assign(t,{[n]:r[n]})}return bn(t,...e)},ff=t=>{function e(r,n){const i=[t.prefix,n.toString().replace(/\./g,"-")].join("");return r==="declaration"?`--${i}`:`var(--${i})`}return e},hf=()=>({core:t=>({semantic:e=>({component:r=>({from:n=>{const{theme:i,getToken:a}=n,o=f=>a("reference",f.toString()),s=t({theme:i}),l=e({theme:i,core:o,raw:{core:s}}),h=r({theme:i,core:o,semantic:o,raw:{core:s,semantic:l}}),p=df(bn(s,l,h)),u=([f,b],v)=>{const y=[v,f].filter(Boolean).join(".");return typeof b=="object"?Object.entries(b).flatMap(S=>u(S,y)):[[n.getToken("declaration",y),b]]};return{values:p,declarations:Object.fromEntries(Object.entries(p).flatMap(f=>u(f))),ref:f=>a("reference",f.toString())}}})})})});const[wn,mn,Da]=["oklch(0% 0 0)","oklch(100% 0 0)","transparent"],pf=hf().core(({theme:t})=>({color:{black:wn,white:mn,lowest:t.mode==="light"?mn:wn,highest:t.mode==="light"?wn:mn,...gn({prefix:"a-",hue:t.hue,chroma:t.chroma,mode:t.mode,transform:vn}),...gn({prefix:"n-",hue:t.hue,chroma:.05,mode:t.mode,transform:vn}),...gn({prefix:"e-",hue:20,chroma:t.chroma,mode:t.mode,transform:vn})},typography:{}})).semantic(({core:t,raw:e,theme:r})=>{const n=(i,a)=>e.core.color[i].replace(")",` / ${a})`);return{"font-family":{body:"inherit",headings:"inherit"},"font-style":{body:"normal",headings:"normal"},"font-weight-body":"normal","font-weight-headings":"normal","radius-app":"1.5rem","radius-interactive":"1.5rem",color:{divider:n("n-8",r.mode==="dark"?.4:.2)},"copy-body":t("color.n-12"),"copy-headings":t("color.n-12"),interactive:{copy:t("color.n-11"),"copy-hover":t("color.n-12"),"copy-active":t("color.n-12"),bg:Da,"bg-hover":n("n-10",.2),"bg-active":n("n-10",.3)}}}).component(({raw:t,theme:e,semantic:r,core:n})=>{const i=(a,o)=>t.core.color[a].replace(")",` / ${o})`);return{app:{bg:n(e.mode==="dark"?"color.n-1":"color.n-2")},overlay:{bg:i("black",.4)},bubble:{"weak-bg":n(e.mode==="dark"?"color.n-3":"color.lowest"),"weak-outline":r("color.divider"),"strong-shadow":i("a-9",.05)},"status-bar":{bg:i("n-2",.8),"bg-button":Da,"bg-button-hover":i("n-10",.4),"bg-button-active":i("n-10",.5)},"submit-button":{"bg-active":n(e.mode==="dark"?"color.a-8":"color.a-11")}}}),gf=ff({prefix:"i-"}),vf=t=>{const e=pf.from({theme:t,getToken:gf}),r=Object.entries(e.declarations).map(([n,i])=>`${n}: ${i};`);return`${ya} {
|
|
3
3
|
${r.concat(r).join(`
|
|
4
4
|
`)}
|
|
5
|
-
}`},La=({context:t,schema:e,logger:r})=>{if(e)for(const n in e){const i=e[n];if(!i)continue;const a=_e(t,n,null);if(i.required&&a===null){const o=`Configuration error in context: ${n} is required`;throw r.error(o),new Error(o)}switch(i.type){case"number":if(typeof a!="number")throw new Error(`Configuration error in context: ${n} is not a number`);break;case"string":if(typeof a!="string")throw new Error(`Configuration error in context: ${n} is not a string`);break;default:i.type}}},bf=({_internal_domManager:t=Gd(),theme:e,terms:r,feedback:n})=>Po(({apiClient:i,rpcClient:a,logger:o,analytics:s})=>{let l=!1;const h=pd({locale:void 0,overrides:r??{}}),p=()=>{var b;if(typeof window>"u")return;const u=[dt("style",{id:"inploi-chatbot-styles"},Kd),dt("style",{id:"inploi-chatbot-theme"},vf(e))],f=t.getOrCreateChatbotElement();if(le(dt(J,{},[u,dt(Hd,{apiClient:i,logger:o,analytics:s,params:{theme:e,terms:r,feedback:n}})]),f),n){const v=f.querySelector("dialog");if(!v)throw new Error("Couldn't find feedback host");if(n.plugin instanceof Promise)n.plugin.then(({feedbackPlugin:y})=>{var x;const S=y()({rpcClient:a,apiClient:i,logger:o,analytics:s});Va({instance:S,theme:e,terms:((x=n.params)==null?void 0:x.terms)??{},host:v})});else{const y=n.plugin({rpcClient:a,apiClient:i,logger:o,analytics:s});Va({instance:y,theme:e,terms:((b=n.params)==null?void 0:b.terms)??{},host:v})}}l=!0};return{prepare:async()=>{if(!(typeof window>"u"))try{if(l)return;p(),o.info("Chatbot plugin prepared")}catch(u){o.error("Error preparing chatbot plugin",u)}},fetchFlowByJobId:async(u,f)=>a.request(of,{params:{id:u},searchParams:{id_type:(f==null?void 0:f.idType)==="inploi"?"internal":"external"}}).then(b=>({flow:b.flow,title:b.job.title,flowKeys:[b.job.id,...(f==null?void 0:f.flowKeys)??[]],job:{id:b.job.id,id_type:"external"},...f,context:{user:b.user,...f==null?void 0:f.context}})),fetchFlowById:async(u,f)=>a.request(sf,{params:{id:u}}).then(b=>{var v;return{flow:b.flow,title:"Chatbot",flowKeys:(f==null?void 0:f.flowKeys)??[],...f,analytics:{customProperties:{flow_id:b.flow.id,flow_version:b.flow.version,...(v=f==null?void 0:f.analytics)==null?void 0:v.customProperties}}}}),open:async u=>{if(!(typeof window>"u"))try{I.cancelCurrentFlow(),I.viewState$.value="maximised",l||p(),u instanceof Promise?(I.current$.value={state:"loading"},u.then(async f=>{La({context:f.context||{},schema:f.flow.context_schema,logger:o}),I.startFlow(f)}).catch(f=>{const b=f instanceof Error?f.message:h("unknown_error");I.current$.value={state:"error",error:b}})):(La({context:u.context||{},schema:u.flow.context_schema,logger:o}),I.startFlow(u))}catch(f){o.error("Error starting flow",f)}},close:async()=>{typeof window>"u"||(I.cancelCurrentFlow(),o.info("Closed flow from an external source"))}}});function Va({instance:t,terms:e,theme:r,host:n}){t.render({key:"chatbot-header",size:"sm",theme:{accent:{chroma:r.chroma??1,hue:r.hue},positive:{hue:180,chroma:1},negative:{hue:33,chroma:1},mode:r.mode,corners:"rounded",highlights:"stroke"},terms:e,host:n})}if(!window.inploi)throw new Error("Please insert the SDK script tag above the plugins.");window.inploi.chatbotPlugin=bf;const ja=({condition:t,context:e,submissions:r,ifBlock:n})=>{const[i,...a]=t.compareKey.split(".");if(!i)return!1;const o=Ra({context:e,key:i,path:a,submissions:r});if(!o)return!1;switch(o.type){case"address":{const s=_e(o.value,a.join("."));switch(t.compare){case"equals":return s===t.compareValue;case"contains":return s?s.includes(t.compareValue):!1;case"notEquals":return s!==t.compareValue;case"notContains":return s?!s.includes(t.compareValue):!0}break}case"integration":{if(typeof o.value!="object"||Array.isArray(o.value))return!1;const s=_e(o.value,a.join(".")),l={...n,data:{...n.data,compareKey:"_temp"}};switch(typeof s){case"boolean":return Pe(l,{submissions:{_temp:{value:s,type:"boolean"}},context:e});case"string":return Pe(l,{submissions:{_temp:{value:s,type:"string"}},context:e});case"number":return Pe(l,{submissions:{_temp:{value:s,type:"number"}},context:e});case"object":return Array.isArray(s)&&s.every(fa)?Pe(l,{submissions:{_temp:{value:s,type:"enum"}},context:e}):!1}break}case"boolean":{const s=t.compareValue==="true";switch(t.compare){case"equals":return o.value===s;case"notEquals":return o.value!==s}break}case"phone":case"string":{const s=o.type==="phone"?fr(o.value):o.value;switch(t.compare){case"equals":return s===t.compareValue;case"contains":return s?s.includes(t.compareValue):!1;case"notEquals":return s!==t.compareValue;case"notContains":return s?!s.includes(t.compareValue):!0}break}case"number":{try{const s=Number(t.compareValue);switch(t.compare){case"equals":return o.value===s;case"notEquals":return o.value!==s;case"greaterThan":return o.value>s;case"greaterThanOrEqualTo":return o.value>=s;case"lessThan":return o.value<s;case"lessThanOrEqualTo":return o.value<=s}}catch{return console.error(`Failed to parse number in if-block ${n.id}`,o.value),!1}break}case"enum":switch(t.compare){case"equals":return o.value.length===1&&o.value[0]===t.compareValue;case"notEquals":return o.value.length===1&&o.value[0]!==t.compareValue;case"contains":return o.value.includes(t.compareValue);case"notContains":return!o.value.includes(t.compareValue)}break}},Pe=(t,{context:e,submissions:r})=>{const n="combinator"in t.data?t.data.conditions:[t.data];if(("combinator"in t.data?t.data.combinator:"and")==="or"){for(const a of n)if(ja({condition:a,context:e,submissions:r,ifBlock:t}))return!0;return!1}else{for(const a of n)if(!ja({condition:a,context:e,submissions:r,ifBlock:t}))return!1;return!0}},wf=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,Et=(t,{context:e,submissions:r})=>t.replace(wf,(n,i,a="")=>{const[o,...s]=i.trim().split("."),l=Ra({key:o,path:s,submissions:r,context:e});if(!l)return a;switch(l.type){case"boolean":return l.value===!0?"true":"false";case"file":return l.value.map(h=>`${h.name} (${Te(h.sizeKb)})`).join(", ");case"enum":return l.value.join(", ");case"address":return Object.values(l.value).filter(h=>h&&h.trim().length>0).join(", ");case"number":case"string":return l.value?l.value.toString():a;case"phone":return fr(l.value);case"integration":{if(typeof l.value!="object"||Array.isArray(l.value))break;const h=_e(l.value,s.join("."));switch(typeof h){case"boolean":return h===!0?"true":"false";case"string":return h;case"number":return h.toString();case"object":if(Array.isArray(h)&&h.every(fa))return h.join(", ")}break}}return a}),za=({node:t,nodes:e,stopWhen:r})=>{if((r==null?void 0:r(t))===!0)return t;const n=t.nextId?e.find(i=>i.id===t.nextId):void 0;if(n)return za({node:n,nodes:e,stopWhen:r})},mf=({childNode:t,nodes:e})=>{const n=e.filter(i=>i.type==="if-block").find(i=>{if(!i.branchId)return!1;const a=e.find(s=>s.id===i.branchId);if(!a)return!1;const o=za({node:a,nodes:e,stopWhen:s=>s.id===t.id});return!(!o||o.id!==t.id)});if(n!=null&&n.nextId)return e.find(i=>i.id===n.nextId)},_f=({flow:t,analytics:e,logger:r,context:n,apiClient:i,getSubmissions:a,chatService:o,onFlowEnd:s,onInterpret:l,t:h})=>{let p=new AbortController;const u={...e.service,log:b=>e.service.log({...b,customProperties:{...b.customProperties,...e.customProperties}})},f=async(b,v)=>{const y=a();l==null||l(b,v);try{await yf({flow:t,analytics:u,logger:r,apiClient:i,context:n,node:b,submissions:y,t:h,chat:{sendMessage:async S=>o.send({groupId:b.id,message:S,signal:p.signal}),userInput:async S=>o.input({input:S,signal:p.signal}),addToSubmissions:o.addToSubmissions},next:S=>{const x=S?t.nodes.find(m=>m.id===S):mf({childNode:b,nodes:t.nodes});return x?f(x,b):s==null?void 0:s(b)},end:()=>s==null?void 0:s(b)})}catch(S){if(S instanceof Ae)return;throw S}};return{interpret:async b=>{const v=t.nodes.find(y=>y.id===b)??da(t.nodes);return f(v)},undo:b=>{let v=1;const y=t.nodes.find(x=>x.id===b[b.length-1]);for(let x=b.length-2;x>0;x--){const m=b[x],A=t.nodes.find(N=>N.id===m);if(!A||(v++,A.type.startsWith("question-")))break}p.abort(),p=new AbortController;const S=t.nodes.find(x=>x.id===b[b.length-v]);return yt(S,"Undo failed: new start node not found"),f(S,y),{removed:v}},abort:()=>{p.abort()}}},fr=t=>`+${t.countryCode} ${t.phoneNumber}`;async function yf(t){const e=t.node;switch(e.type){case"text":return Tf({...t,node:e});case"image":return Af({...t,node:e});case"question-text":return Mf({...t,node:e});case"question-enum":return Ff({...t,node:e});case"question-number":return Nf({...t,node:e});case"question-phone":return Of({...t,node:e});case"question-boolean":return Pf({...t,node:e});case"question-file":return Lf({...t,node:e});case"question-address":return Df({...t,node:e});case"end-flow":return Vf({...t,node:e});case"if-block":return If({...t,node:e});case"jump":return Sf({...t,node:e});case"link":return Ef({...t,node:e});case"integration-application-submit":return $f({...t,node:e});case"add-submission":return Cf({...t,node:e});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"identify":return kf({...t,node:e});case"feedback":return xf({...t,node:e});default:throw new Error(`Unknown node: ${JSON.stringify(e)}`)}}const De=(t,e)=>{var n;const r=(n=t[e])==null?void 0:n.value;if(typeof r!="string"&&typeof r!="number")throw new Error(`Submission at “${e}” is not a string or number`);return r};async function xf({next:t,node:e}){t(e.nextId)}async function kf({next:t,node:e,analytics:r,submissions:n,logger:i}){if(!n)return t(e.nextId);try{r.log({event:"IDENTIFY",properties:{identifier:De(n,e.data.key).toString(),first_name:e.data.firstName?De(n,e.data.firstName).toString():void 0,last_name:e.data.lastName?De(n,e.data.lastName).toString():void 0,email:e.data.email?De(n,e.data.email).toString():void 0,phone_number:e.data.phoneNumber?De(n,e.data.phoneNumber).toString():void 0,custom_traits:e.data.customTraits?Object.fromEntries(e.data.customTraits.map(({key:a,value:o})=>{var s;return[a,(s=n[o])==null?void 0:s.value]})):void 0}})}catch(a){i.error(a)}finally{t(e.nextId)}}async function Sf({next:t,node:e}){t(e.data.targetId)}async function Cf({next:t,node:e,logger:r,submissions:n,context:i}){if(!n){r.error("Submissions not found");return}n[e.data.key]={type:"string",value:Et(e.data.value,{submissions:n,context:i})},t(e.nextId)}async function $f({chat:t,next:e,node:r,logger:n,apiClient:i,submissions:a,analytics:o,flow:s,t:l}){const h=async p=>{p!==!0&&await t.userInput({type:"submit",key:void 0,config:{label:r.data.submitLabel}}),await t.sendMessage({type:"loading"});const{anonymous_id:u,session_id:f}=o.getSessionInfo(),b=await i.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:r.data.integrationId,anonymous_id:u,session_id:f,job:s.job,submissions:Nd(a||{})})}).catch(v=>v);r.data.key&&t.addToSubmissions(r.data.key,{type:"integration",value:b}),Zt(b).with({integration_response:P.select(P.union({service:P.optional(P.string),status:P.number,data:P.any},{service:P.optional(P.string),status:P.number,error:{message:P.string,data:P.any}}))},v=>{o.log({event:"FLOW_SUBMIT",properties:{flow_id:s.id,flow_version:s.version,flow_session_id:s.data.flowSessionId,flow_build:s.build,service:v.service??"INVALID_SERVICE",response:{status:v.status,payload:"data"in v?v.data:v.error.data??null},job:s.job}})}).otherwise(()=>{}),await Zt(b).with({integration_response:{data:P.select("redirect",{redirect_url:P.string,message:P.optional(P.union(P.string,P.nullish)),button_text:P.optional(P.union(P.string,P.nullish))})}},async v=>{await t.sendMessage({type:"text",author:"bot",text:v.redirect.message??l("submission_redirect_message")});try{const y=new URL(v.redirect.redirect_url);u&&!y.searchParams.has("anonymous_id")&&y.searchParams.set("anonymous_id",u),await t.sendMessage({type:"link",href:y.toString(),text:v.redirect.button_text??l("complete_submission"),onClick:()=>{if(!f){n.error("session_id not set, cannot log FLOW_REDIRECT event");return}o.log({event:"FLOW_REDIRECT",properties:{flow_build:s.build,flow_id:s.id,flow_session_id:f,flow_version:s.version,href:y.toString(),job:s.job}})}})}catch(y){n.error(`Invalid redirect URL: ${v.redirect.redirect_url}`,y),t.sendMessage({type:"system",variant:"error",text:l("redirect_url_error")})}e(r.nextId)}).with({success:!0},async()=>{r.data.skipConfirmation!==!0&&await t.sendMessage({type:"system",variant:"success",text:l("submission_completed")}),e(r.nextId)}).with({integration_response:{error:P.select("error",{message:P.string})}},async v=>{n.error(v.error),await t.sendMessage({type:"system",variant:"error",text:v.error.message||l("submission_failed")}),await h(!1)}).otherwise(async v=>{n.error(v),await t.sendMessage({type:"system",variant:"error",text:l("submission_failed")}),await h(!1)})};await h(r.data.skipConfirmation)}async function Ef({chat:t,next:e,node:r,submissions:n,context:i}){await t.sendMessage({type:"link",href:Et(r.data.href,{submissions:n,context:i}),text:Et(r.data.cta,{submissions:n,context:i})}),e(r.nextId)}async function If({submissions:t,next:e,node:r,context:n}){e(Pe(r,{submissions:t,context:n})?r.branchId:r.nextId)}async function Tf({chat:t,next:e,node:r,submissions:n,context:i}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.text,{submissions:n,context:i})}),e(r.nextId)}async function Af({chat:t,next:e,node:r}){await t.sendMessage({author:"bot",type:"image",url:r.data.url,height:r.data.height,width:r.data.width}),e(r.nextId)}async function Mf({chat:t,next:e,node:r,submissions:n,context:i,t:a}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.question,{submissions:n,context:i})});const o=r.data.format==="phone"?await t.userInput({key:r.data.key,type:"phone",config:{optional:r.data.optional,placeholder:r.data.placeholder,minChars:r.data.minChars,submissionFormat:"text",defaultValue:{}}}):await t.userInput({key:r.data.key,type:"text",config:{optional:r.data.optional,placeholder:r.data.placeholder,format:r.data.format,maxChars:r.data.maxChars,minChars:r.data.minChars}});o===null?await t.sendMessage({type:"system",variant:"info",text:a("skipped")}):await t.sendMessage({author:"user",type:"text",text:o.type==="phone"?fr(o.value):o.value}),e(r.nextId)}async function Nf({chat:t,next:e,node:r,submissions:n,context:i,t:a}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.question,{submissions:n,context:i})});const o=await t.userInput({key:r.data.key,type:"number",config:{max:r.data.max,min:r.data.min,optional:r.data.optional,placeholder:r.data.placeholder,decimalCases:r.data.decimalCases}});o===null?await t.sendMessage({type:"system",variant:"info",text:a("skipped")}):await t.sendMessage({author:"user",type:"text",text:o.value.toString()}),e(r.nextId)}async function Of({chat:t,next:e,node:r,submissions:n,context:i}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.question,{submissions:n,context:i})});const a=await t.userInput({key:r.data.key,type:"phone",config:{minChars:r.data.minChars,defaultValue:{countryCode:r.data.defaultCountryCode},placeholder:r.data.placeholder,submissionFormat:"phone",optional:r.data.optional}});a===null?await t.sendMessage({type:"system",variant:"info",text:"Skipped"}):await t.sendMessage({author:"user",type:"text",text:a.type==="phone"?fr(a.value):a.value}),e(r.nextId)}async function Ff({chat:t,next:e,node:r,submissions:n,context:i,t:a}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.question,{submissions:n,context:i})});const o=await t.userInput({key:r.data.key,type:"multiple-choice",config:r.data});o.value.length===0?await t.sendMessage({type:"system",variant:"info",text:a("skipped")}):await t.sendMessage({author:"user",type:"text",text:r.data.options.filter(s=>o.value.includes(s.value)).map(s=>s.label).join(", ")}),e(r.nextId)}async function Pf({chat:t,next:e,node:r,submissions:n,context:i,t:a}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.question,{submissions:n,context:i})});const o=await t.userInput({key:r.data.key,type:"boolean",config:{optional:r.data.optional,labels:{true:r.data.trueLabel,false:r.data.falseLabel}}});o===null?await t.sendMessage({type:"system",variant:"info",text:a("skipped")}):await t.sendMessage({author:"user",type:"text",text:o.value===!0?r.data.trueLabel:r.data.falseLabel}),e(r.nextId)}async function Df({chat:t,next:e,node:r,t:n}){await t.sendMessage({author:"bot",type:"text",text:r.data.question});const i=await t.userInput({type:"address",key:r.data.key,config:{optional:r.data.optional,keys:r.data.keys,placeholder:r.data.placeholder}});if(i===null)await t.sendMessage({type:"system",variant:"info",text:n("skipped")});else{const a=Object.values(i.value).filter(o=>o&&o.trim().length>0).join(", ");await t.sendMessage({author:"user",type:"text",text:a})}return e(r.nextId)}async function Lf({node:t,chat:e,next:r,submissions:n,context:i,t:a}){await e.sendMessage({author:"bot",type:"text",text:Et(t.data.question,{submissions:n,context:i})});const o=await e.userInput({key:t.data.key,type:"file",config:{optional:t.data.optional,extensions:t.data.extensions,fileSizeLimitKib:t.data.maxSizeKb??10*1024,allowMultiple:t.data.multiple===!0}});if(o===null)await e.sendMessage({type:"system",variant:"info",text:a("skipped")});else for(const s of o.value)await e.sendMessage({author:"user",type:"file",fileName:s.name,fileSizeKb:s.sizeKb});r(t.nextId)}async function Vf({chat:t,end:e,node:r}){await t.sendMessage({type:"system",variant:"info",text:r.data.systemMessage}),e()}const Ra=({key:t,path:e,submissions:r,context:n})=>{if(t==="$context"){if(!e)return;const i=_e(n,e.join("."));switch(typeof i){case"string":return{type:"string",value:i};case"number":return{type:"number",value:i};case"boolean":return{type:"boolean",value:i};default:console.warn(`Unexpected type for $context.${e.join(".")}`,i);return}}return r==null?void 0:r[t]};function _n(t,e,r){var n,i,a,o,s;e==null&&(e=100);function l(){var p=Date.now()-o;p<e&&p>=0?n=setTimeout(l,e-p):(n=null,r||(s=t.apply(a,i),a=i=null))}var h=function(){a=this,i=arguments,o=Date.now();var p=r&&!n;return n||(n=setTimeout(l,e)),p&&(s=t.apply(a,i),a=i=null),s};return h.clear=function(){n&&(clearTimeout(n),n=null)},h.flush=function(){n&&(s=t.apply(a,i),a=i=null,clearTimeout(n),n=null)},h}_n.debounce=_n;var jf=_n;const Ba=kr(jf);function zf(t){let{debounce:e,scroll:r,polyfill:n,offsetSize:i}=t===void 0?{debounce:0,scroll:!1,offsetSize:!1}:t;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[o,s]=vt({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),l=ht({element:null,scrollContainers:null,resizeObserver:null,lastBounds:o}),h=e?typeof e=="number"?e:e.scroll:null,p=e?typeof e=="number"?e:e.resize:null,u=ht(!1);_t(()=>(u.current=!0,()=>void(u.current=!1)));const[f,b,v]=Nt(()=>{const m=()=>{if(!l.current.element)return;const{left:A,top:N,width:M,height:H,bottom:it,right:gt,x:L,y:ct}=l.current.element.getBoundingClientRect(),ot={left:A,top:N,width:M,height:H,bottom:it,right:gt,x:L,y:ct};l.current.element instanceof HTMLElement&&i&&(ot.height=l.current.element.offsetHeight,ot.width=l.current.element.offsetWidth),Object.freeze(ot),u.current&&!Hf(l.current.lastBounds,ot)&&s(l.current.lastBounds=ot)};return[m,p?Ba(m,p):m,h?Ba(m,h):m]},[s,i,h,p]);function y(){l.current.scrollContainers&&(l.current.scrollContainers.forEach(m=>m.removeEventListener("scroll",v,!0)),l.current.scrollContainers=null),l.current.resizeObserver&&(l.current.resizeObserver.disconnect(),l.current.resizeObserver=null)}function S(){l.current.element&&(l.current.resizeObserver=new a(v),l.current.resizeObserver.observe(l.current.element),r&&l.current.scrollContainers&&l.current.scrollContainers.forEach(m=>m.addEventListener("scroll",v,{capture:!0,passive:!0})))}const x=m=>{!m||m===l.current.element||(y(),l.current.element=m,l.current.scrollContainers=Ua(m),S())};return Bf(v,!!r),Rf(b),_t(()=>{y(),S()},[r,v,b]),_t(()=>y,[]),[x,o,f]}function Rf(t){_t(()=>{const e=t;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[t])}function Bf(t,e){_t(()=>{if(e){const r=t;return window.addEventListener("scroll",r,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",r,!0)}},[t,e])}function Ua(t){const e=[];if(!t||t===document.body)return e;const{overflow:r,overflowX:n,overflowY:i}=window.getComputedStyle(t);return[r,n,i].some(a=>a==="auto"||a==="scroll")&&e.push(t),[...e,...Ua(t.parentElement)]}const Uf=["x","y","top","bottom","left","right","width","height"],Hf=(t,e)=>Uf.every(r=>t[r]===e[r]),te=({class:t,...e})=>{const{t:r}=et();return c("button",{class:Lt("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",t),type:"submit",...e,children:c("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[c("title",{children:r("send")}),c("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),c("path",{d:"M8 4V13"})]})})},qf=25,yn=Rt({instant:()=>{},smooth:()=>{}}),nt={onSubmitSuccessFn$:Rt(()=>{}),isBotTyping$:Rt(!1),scrollToEnd:{instant:()=>yn.value.instant(),smooth:()=>yn.value.smooth()}},Kf=()=>{const t=ht(null);ft(()=>{yn.value={instant:()=>{var r;return(r=t.current)==null?void 0:r.scrollTo({top:t.current.scrollHeight,behavior:"instant"})},smooth:()=>{t.current&&t.current.scrollHeight-t.current.scrollTop<=t.current.clientHeight*2&&t.current.scrollTo({top:t.current.scrollHeight,behavior:"smooth"})}}},[t]);const e=Nt(()=>({addToSubmissions:(n,i)=>I.setSubmission(n,i),send:async({message:n,signal:i,groupId:a})=>{if(await Zt(n).with({author:"bot",type:"text"},async o=>{if(i!=null&&i.aborted)throw new Ae;nt.isBotTyping$.value=!0;const s=Math.min(Math.max(20,o.text.length),100)*qf;await new Promise(l=>setTimeout(l,s,{signal:i})),nt.isBotTyping$.value=!1}).otherwise(async()=>{}),i!=null&&i.aborted)throw new Ae;I.addMessage(n,a)},input:({input:n,signal:i})=>{if(i!=null&&i.aborted)throw new Ae;return I.setInput(n),new Promise(a=>{const o=s=>{if(i!=null&&i.aborted)throw new Ae;I.setInput(void 0),n.key&&I.setSubmission(n.key,s),a(s)};nt.onSubmitSuccessFn$.value=o})}}),[]);return{chatRef:t,chatService:e}},ge=({error:t})=>!t||!t.message?null:c("div",{role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full px-2 py-2",children:[c("svg",{class:"text-error-9 h-4 w-4",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),c("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),c("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),c("p",{class:"truncate pr-1 text-sm",children:t.message})]}),ee=({class:t,...e})=>{const{t:r}=et();return c("button",{type:"button",class:Lt("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",t),...e,children:[c("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:[c("title",{children:r("skip")}),c("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),c("path",{d:"M13.25 4.5V8.25H9.5"})]}),r("skip")]})},xn={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"},Le=Wt("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}}),Gf="https://api.mapbox.com/search/searchbox/v1/suggest",Wf="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",Yf=t=>atob(t).split("").reverse().join(""),Ft=rt({name:W()}),Jf=rt({suggestions:dn(rt({full_address:xt(W()),place_formatted:xt(W()),name:xt(W()),mapbox_id:W(),context:ef(rt({address:Ft,street:Ft,neighborhood:Ft,locality:Ft,district:Ft,place:Ft,region:Ft,postcode:Ft,country:Ft}))}))}),Zf=({logger:t,t:e})=>Nt(()=>{var n;const r=(n=I.current$.peek().flow)==null?void 0:n.data.flowSessionId;return r?{enabled:!0,getPredictions:async i=>{var u;const a=new URL(Gf);a.searchParams.set("q",i),a.searchParams.set("session_token",r);const o=(u=I.current$.peek().flow)==null?void 0:u.locationOrigin;o&&o.lat!==void 0&&o.lng!==void 0&&o.lat>=-90&&o.lat<=90&&o.lng>=-180&&o.lng<=180&&a.searchParams.set("proximity",`${o.lng},${o.lat}`),a.searchParams.set("access_token",Yf(Wf));const l=await fetch(a);if(!l.ok)return t.error("Failed to get address details",l),{ok:!1,error:e("address_error")};const h=rf(Jf,await l.json());if(h.success===!1)return t.error("Failed to parse address details",h.issues),{ok:!1,error:e("address_error")};const{suggestions:p}=h.output;return{ok:!0,data:p.map(f=>{var b,v,y,S,x,m,A,N,M;return{label:f.full_address??f.place_formatted??f.name??f.mapbox_id,id:f.mapbox_id,address:{line1:((b=f.context.address)==null?void 0:b.name)??((v=f.context.street)==null?void 0:v.name),line2:void 0,line3:((y=f.context.neighborhood)==null?void 0:y.name)??((S=f.context.locality)==null?void 0:S.name),city:((x=f.context.place)==null?void 0:x.name)??((m=f.context.district)==null?void 0:m.name),state:(A=f.context.region)==null?void 0:A.name,postcode:(N=f.context.postcode)==null?void 0:N.name,country:(M=f.context.country)==null?void 0:M.name}}})}}}:{enabled:!1}},[t,e]),Ha=t=>{const{t:e}=et();return c("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",...t,children:[c("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:c("path",{d:"M10 3L5 8L10 13"})}),c("span",{children:e("back")})]})},Xf=({input:t,onSubmitSuccess:e,logger:r})=>{const{t:n}=et(),[i,a]=vt(),[o,s]=vt([]),{enabled:l,getPredictions:h}=Zf({logger:r,t:n}),[p,u]=vt(l?"query":"manual"),[f,b]=vt(""),[v,y]=vt(),S=x=>{yt(l,"Query state should not be enabled"),x=x.trim(),x!==(f==null?void 0:f.trim())&&(b(x),x===""&&s([]),y(void 0),h(x).then(m=>{if(m.ok===!1){s([]),y(m.error);return}s(m.data)}))};switch(p){case"query":return yt(l,"Query state should not be enabled"),c(Qf,{input:t,onSkip:()=>e(null),onAddressSelect:x=>{if(x===""){a(void 0),u("manual");return}const m=o.find(A=>A.id===x);m&&(a(m.address),u("details"))},onAddressSearch:x=>{S(x)},suggestions:o,query:f,error:v});case"details":return yt(i!==void 0),c(Ka,{input:t,logger:r,onSubmitSuccess:e,addressFields:i,actions:c(Ha,{onClick:()=>{u("query")}})});case"manual":return c(Ka,{logger:r,input:t,onSubmitSuccess:e,addressFields:{},actions:l?c(Ha,{onClick:()=>{u("query")}}):void 0})}},Qf=({input:t,onSkip:e,suggestions:r,onAddressSelect:n,query:i,onAddressSearch:a,error:o})=>{const{t:s}=et(),l=ht(null);return ft(()=>{l.current&&(l.current.focus(),l.current.select())},[]),c(J,{children:[c("form",{noValidate:!0,onSubmit:h=>{h.preventDefault();const u=new FormData(h.currentTarget).get("address");typeof u=="string"&&a(u)},class:"flex gap-1 p-2.5",children:[c("div",{class:"group relative flex-1",children:[c("input",{ref:l,name:"address",id:"chat-address",autocomplete:"address-line1 country-name postal-code",autoFocus:!0,placeholder:t.config.placeholder||s("address_search"),defaultValue:i,class:Le({optional:!!t.config.optional,className:"w-full rounded-full"})}),c("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:c("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c("g",{id:"inploi",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",strokeWidth:"1.5",children:[c("circle",{cx:"7",cy:"7",r:"4"}),c("path",{d:"M10 10L13 13"})]}),c("span",{class:"sr-only",children:s("search")})]})})]}),t.config.optional&&c(ee,{class:"",onClick:e})]}),o?c(ge,{error:{message:o}}):null,c("ul",{children:[r.map(h=>c("li",{children:c("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(h.id)},children:[c("span",{class:"flex-grow",children:h.label}),c("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:c("path",{d:"M6 3L11 8L6 13"})})]})},h.id)),c("li",{children:c("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{n("")},children:c("span",{class:"flex-grow",children:s("address_manual")})})},"")]})]})},qa=["line1","line2","line3","city","state","postcode","country"],Ka=({addressFields:t,onSubmitSuccess:e,actions:r,input:n})=>{const i=ht(null);ft(()=>{if(i.current){const s=i.current.querySelector("input");s&&(s.focus(),s.select())}},[]);const a=Object.keys(xn),{t:o}=et();return c("form",{class:"bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",onSubmit:s=>{const l=new FormData(s.currentTarget),h=Object.fromEntries(l.entries());e({type:"address",value:h})},children:[c("div",{class:"bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",ref:i,children:qa.map((s,l)=>{const h=`isdk_${s}`,p=n.config.keys[s];return p?c(J,{children:[c("label",{for:h,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(s)}),c("div",{class:"flex flex-col items-stretch gap-1.5",children:[s==="country"?c("div",{class:"relative",children:[c("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:p,id:h,defaultValue:t[s],required:!0,children:[t.country&&!a.includes(t.country)?c("option",{value:t[s],children:t[s]}):c("option",{value:"",children:o("select_country")}),a.map(u=>c("option",{value:u,children:u},u))]}),c("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:c("path",{d:"M4 6.5L8 10.5L12 6.5"})})]}):c("input",{autoFocus:l===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:p,id:h,defaultValue:t[s],required:!0}),l===qa.length-1?c("hr",{class:"m-0 w-full border-b border-b-transparent"}):c("hr",{class:"border-b-neutral-5 m-0 w-full border-b border-solid"})]})]}):null})}),c("div",{class:"flex w-full flex-1 ",children:[c("div",{class:"flex-grow",children:r}),c(te,{class:"flex items-center justify-center"})]})]})},kn=()=>{const t=ht(null);return _t(()=>{var e;(e=t.current)==null||e.focus()},[]),t},Ga=["true","false"],th=Ma(Ga),eh="answer",Wa="flex items-center gap-2 p-2.5",Ya=zr(({label:t,...e},r)=>c("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",...e,ref:r,children:c("p",{class:"truncate text-center text-base",children:t})})),rh=({input:t,onSubmitSuccess:e})=>{const r=kn();return c("form",{noValidate:!0,class:"",onSubmit:n=>{n.preventDefault();const i=Pd(n).value,a=Oa(th,i);e({type:"boolean",value:a==="true"})},children:[c("ul",{class:Wa,children:Ga.map((n,i)=>c("li",{class:"flex-1",children:c(Ya,{ref:i===0?r:null,type:"submit",name:eh,value:n,label:t.config.labels[n]},n)}))}),t.config.optional&&c("div",{class:"px-2 pb-2",children:c(ee,{class:"w-full",type:"button",onClick:()=>e(null)})})]})},nh=t=>new Promise((e,r)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>n.result?e(n.result.toString()):r("No result from reader"),n.onerror=r}),ih=t=>t.reduce((e,r)=>e+r.sizeKb,0),ah=he("file"),Ja=3,oh=({file:t,class:e,...r})=>{const n=t.name.split(".").pop(),i=t.name.replace(new RegExp(`.${n}$`),"");return c("div",{class:Lt("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",e),...r,children:[c("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[c("span",{class:"block truncate",children:i}),c("span",{children:[".",n]})]}),c("p",{"aria-label":"File size",class:"text-accent-11",children:Te(t.sizeKb)})]})},Za=({class:t,...e})=>c("li",{class:Lt("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",t),...e}),Xa=t=>{const e=t.split(".").pop();if(!e)throw new Error("No file extension found");return e?"."+e:""},sh=({allowedExtensions:t,files:e})=>{const r=t.map(n=>n.toLowerCase());return e.every(n=>r.includes(Xa(n.name).toLowerCase()))},lh=(t,e)=>{const r=Xa(t);return`${t.replace(new RegExp(`${r}$`),"").slice(0,e)}${r}`},ch=({input:t,onSubmitSuccess:e})=>{var u;const r=(u=I.current$.value.flow)==null?void 0:u.data.submissions[t.key],[n,i]=vt(ah(r)?r.value:[]),[a,o]=vt(),s=n.length-Ja,l=ih(n),h=kn(),{t:p}=et();return c("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:f=>(f.preventDefault(),o(void 0),n.length===0?o({type:"required",message:p("validation_file")}):t.config.extensions.length>0&&!sh({allowedExtensions:t.config.extensions,files:n})?o({type:"validate",message:`${p("validation_file_ext",{ext:t.config.extensions.join(", ")})}`}):t.config.fileSizeLimitKib&&l>t.config.fileSizeLimitKib?o({type:"max",message:`File size exceeds limit of ${Te(t.config.fileSizeLimitKib)}`}):t.config.allowMultiple===!1&&n.length>1?o({type:"invalid",message:p("validation_file_max",{count:1})}):e({type:"file",value:n})),children:[c("div",{class:"flex items-center gap-2",children:[c("label",{ref:h,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?c(J,{children:[c("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[n.slice(0,Ja).map(f=>{const b=f.name.split(".").pop(),v=f.name.replace(new RegExp(`.${b}$`),"");return c(Za,{class:"flex overflow-hidden",children:[c("span",{class:"block truncate",children:v}),c("span",{children:[".",b]})]})}),s>0?c(Za,{children:["+",s," file",s!==1?"s":""]}):null]}),c("p",{class:"text-neutral-11 text-xs",children:[Te(l)," ",n.length>1?"total":""]})]}):c("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[c("header",{class:"flex flex-col items-center gap-0",children:[c("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:c("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"})}),c("p",{class:"text-neutral-12 tracking-[-0.01em]",children:p("upload_file",{count:t.config.allowMultiple?2:1})}),t.config.fileSizeLimitKib?c("p",{class:"text-neutral-10 text-xs",children:["(",p("file_max_size",{size:Te(t.config.fileSizeLimitKib)}),")"]}):null]}),c("aside",{class:"flex flex-col items-center gap-2",children:[c("p",{id:"accepted-filetypes",class:"sr-only",children:p("file_extensions")}),c("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:t.config.extensions.map(f=>c("li",{class:"ring-lowest outline-neutral-6 text-neutral-9 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",children:f.replace(".","")}))})]})]}),c("input",{id:"dropzone-file",onInput:async f=>{yt(f.target instanceof HTMLInputElement);const b=f.target.files?Array.from(f.target.files):[],v=await Promise.allSettled(b.map(async S=>{const x=await nh(S);return{name:lh(S.name,42),data:x,sizeKb:S.size/1e3}}));if(v.some(({status:S})=>S==="rejected"))return o({type:"invalid",message:"Invalid file"});const y=v.map(S=>S.status==="fulfilled"?S.value:null).filter(Boolean);i(y)},multiple:t.config.allowMultiple,type:"file",class:"sr-only"})]}),c("div",{class:"flex h-full flex-col items-center gap-2",children:[c(te,{disabled:n.length===0}),t.config.optional&&c(ee,{onClick:()=>e(null)})]})]}),c(ge,{error:a})]})};var Ve=t=>t.type==="checkbox",ve=t=>t instanceof Date,at=t=>t==null;const Qa=t=>typeof t=="object";var Y=t=>!at(t)&&!Array.isArray(t)&&Qa(t)&&!ve(t),uh=t=>Y(t)&&t.target?Ve(t.target)?t.target.checked:t.target.value:t,dh=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,fh=(t,e)=>t.has(dh(e)),hh=t=>{const e=t.constructor&&t.constructor.prototype;return Y(e)&&e.hasOwnProperty("isPrototypeOf")},Sn=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Pt(t){let e;const r=Array.isArray(t);if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set(t);else if(!(Sn&&(t instanceof Blob||t instanceof FileList))&&(r||Y(t)))if(e=r?[]:{},!r&&!hh(t))e=t;else for(const n in t)t.hasOwnProperty(n)&&(e[n]=Pt(t[n]));else return t;return e}var je=t=>Array.isArray(t)?t.filter(Boolean):[],U=t=>t===void 0,$=(t,e,r)=>{if(!e||!Y(t))return r;const n=je(e.split(/[,[\].]+?/)).reduce((i,a)=>at(i)?i:i[a],t);return U(n)||n===t?U(t[e])?r:t[e]:n},qt=t=>typeof t=="boolean";const to={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},kt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Dt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};St.createContext(null);var ph=(t,e,r,n=!0)=>{const i={defaultValues:e._defaultValues};for(const a in t)Object.defineProperty(i,a,{get:()=>{const o=a;return e._proxyFormState[o]!==kt.all&&(e._proxyFormState[o]=!n||kt.all),r&&(r[o]=!0),t[o]}});return i},bt=t=>Y(t)&&!Object.keys(t).length,gh=(t,e,r,n)=>{r(t);const{name:i,...a}=t;return bt(a)||Object.keys(a).length>=Object.keys(e).length||Object.keys(a).find(o=>e[o]===(!n||kt.all))},Cn=t=>Array.isArray(t)?t:[t];function vh(t){const e=St.useRef(t);e.current=t,St.useEffect(()=>{const r=!t.disabled&&e.current.subject&&e.current.subject.subscribe({next:e.current.next});return()=>{r&&r.unsubscribe()}},[t.disabled])}var It=t=>typeof t=="string",bh=(t,e,r,n,i)=>It(t)?(n&&e.watch.add(t),$(r,t,i)):Array.isArray(t)?t.map(a=>(n&&e.watch.add(a),$(r,a))):(n&&(e.watchAll=!0),r),$n=t=>/^\w*$/.test(t),eo=t=>je(t.replace(/["|']|\]/g,"").split(/\.|\[/));function V(t,e,r){let n=-1;const i=$n(e)?[e]:eo(e),a=i.length,o=a-1;for(;++n<a;){const s=i[n];let l=r;if(n!==o){const h=t[s];l=Y(h)||Array.isArray(h)?h:isNaN(+i[n+1])?{}:[]}t[s]=l,t=t[s]}return t}var ro=(t,e,r,n,i)=>e?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:i||!0}}:{},no=t=>({isOnSubmit:!t||t===kt.onSubmit,isOnBlur:t===kt.onBlur,isOnChange:t===kt.onChange,isOnAll:t===kt.all,isOnTouch:t===kt.onTouched}),io=(t,e,r)=>!r&&(e.watchAll||e.watch.has(t)||[...e.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const hr=(t,e,r,n)=>{for(const i of r||Object.keys(t)){const a=$(t,i);if(a){const{_f:o,...s}=a;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],i)&&!n)break;if(o.ref&&e(o.ref,o.name)&&!n)break}else Y(s)&&hr(s,e)}}};var wh=(t,e,r)=>{const n=je($(t,r));return V(n,"root",e[r]),V(t,r,n),t},En=t=>t.type==="file",Kt=t=>typeof t=="function",pr=t=>{if(!Sn)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},gr=t=>It(t),In=t=>t.type==="radio",vr=t=>t instanceof RegExp;const ao={value:!1,isValid:!1},oo={value:!0,isValid:!0};var so=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!U(t[0].attributes.value)?U(t[0].value)||t[0].value===""?oo:{value:t[0].value,isValid:!0}:oo:ao}return ao};const lo={isValid:!1,value:null};var co=t=>Array.isArray(t)?t.reduce((e,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:e,lo):lo;function uo(t,e,r="validate"){if(gr(t)||Array.isArray(t)&&t.every(gr)||qt(t)&&!t)return{type:r,message:gr(t)?t:"",ref:e}}var be=t=>Y(t)&&!vr(t)?t:{value:t,message:""},fo=async(t,e,r,n,i)=>{const{ref:a,refs:o,required:s,maxLength:l,minLength:h,min:p,max:u,pattern:f,validate:b,name:v,valueAsNumber:y,mount:S,disabled:x}=t._f,m=$(e,v);if(!S||x)return{};const A=o?o[0]:a,N=D=>{n&&A.reportValidity&&(A.setCustomValidity(qt(D)?"":D||""),A.reportValidity())},M={},H=In(a),it=Ve(a),gt=H||it,L=(y||En(a))&&U(a.value)&&U(m)||pr(a)&&a.value===""||m===""||Array.isArray(m)&&!m.length,ct=ro.bind(null,v,r,M),ot=(D,O,q,ut=Dt.maxLength,wt=Dt.minLength)=>{const Tt=D?O:q;M[v]={type:D?ut:wt,message:Tt,ref:a,...ct(D?ut:wt,Tt)}};if(i?!Array.isArray(m)||!m.length:s&&(!gt&&(L||at(m))||qt(m)&&!m||it&&!so(o).isValid||H&&!co(o).isValid)){const{value:D,message:O}=gr(s)?{value:!!s,message:s}:be(s);if(D&&(M[v]={type:Dt.required,message:O,ref:A,...ct(Dt.required,O)},!r))return N(O),M}if(!L&&(!at(p)||!at(u))){let D,O;const q=be(u),ut=be(p);if(!at(m)&&!isNaN(m)){const wt=a.valueAsNumber||m&&+m;at(q.value)||(D=wt>q.value),at(ut.value)||(O=wt<ut.value)}else{const wt=a.valueAsDate||new Date(m),Tt=yr=>new Date(new Date().toDateString()+" "+yr),ne=a.type=="time",Be=a.type=="week";It(q.value)&&m&&(D=ne?Tt(m)>Tt(q.value):Be?m>q.value:wt>new Date(q.value)),It(ut.value)&&m&&(O=ne?Tt(m)<Tt(ut.value):Be?m<ut.value:wt<new Date(ut.value))}if((D||O)&&(ot(!!D,q.message,ut.message,Dt.max,Dt.min),!r))return N(M[v].message),M}if((l||h)&&!L&&(It(m)||i&&Array.isArray(m))){const D=be(l),O=be(h),q=!at(D.value)&&m.length>+D.value,ut=!at(O.value)&&m.length<+O.value;if((q||ut)&&(ot(q,D.message,O.message),!r))return N(M[v].message),M}if(f&&!L&&It(m)){const{value:D,message:O}=be(f);if(vr(D)&&!m.match(D)&&(M[v]={type:Dt.pattern,message:O,ref:a,...ct(Dt.pattern,O)},!r))return N(O),M}if(b){if(Kt(b)){const D=await b(m,e),O=uo(D,A);if(O&&(M[v]={...O,...ct(Dt.validate,O.message)},!r))return N(O.message),M}else if(Y(b)){let D={};for(const O in b){if(!bt(D)&&!r)break;const q=uo(await b[O](m,e),A,O);q&&(D={...q,...ct(O,q.message)},N(q.message),r&&(M[v]=D))}if(!bt(D)&&(M[v]={ref:A,...D},!r))return M}}return N(!0),M};function mh(t,e){const r=e.slice(0,-1).length;let n=0;for(;n<r;)t=U(t)?n++:t[e[n++]];return t}function _h(t){for(const e in t)if(t.hasOwnProperty(e)&&!U(t[e]))return!1;return!0}function Q(t,e){const r=Array.isArray(e)?e:$n(e)?[e]:eo(e),n=r.length===1?t:mh(t,r),i=r.length-1,a=r[i];return n&&delete n[a],i!==0&&(Y(n)&&bt(n)||Array.isArray(n)&&_h(n))&&Q(t,r.slice(0,-1)),t}function Tn(){let t=[];return{get observers(){return t},next:i=>{for(const a of t)a.next&&a.next(i)},subscribe:i=>(t.push(i),{unsubscribe:()=>{t=t.filter(a=>a!==i)}}),unsubscribe:()=>{t=[]}}}var br=t=>at(t)||!Qa(t);function re(t,e){if(br(t)||br(e))return t===e;if(ve(t)&&ve(e))return t.getTime()===e.getTime();const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const i of r){const a=t[i];if(!n.includes(i))return!1;if(i!=="ref"){const o=e[i];if(ve(a)&&ve(o)||Y(a)&&Y(o)||Array.isArray(a)&&Array.isArray(o)?!re(a,o):a!==o)return!1}}return!0}var ho=t=>t.type==="select-multiple",yh=t=>In(t)||Ve(t),An=t=>pr(t)&&t.isConnected,po=t=>{for(const e in t)if(Kt(t[e]))return!0;return!1};function wr(t,e={}){const r=Array.isArray(t);if(Y(t)||r)for(const n in t)Array.isArray(t[n])||Y(t[n])&&!po(t[n])?(e[n]=Array.isArray(t[n])?[]:{},wr(t[n],e[n])):at(t[n])||(e[n]=!0);return e}function go(t,e,r){const n=Array.isArray(t);if(Y(t)||n)for(const i in t)Array.isArray(t[i])||Y(t[i])&&!po(t[i])?U(e)||br(r[i])?r[i]=Array.isArray(t[i])?wr(t[i],[]):{...wr(t[i])}:go(t[i],at(e)?{}:e[i],r[i]):r[i]=!re(t[i],e[i]);return r}var Mn=(t,e)=>go(t,e,wr(e)),vo=(t,{valueAsNumber:e,valueAsDate:r,setValueAs:n})=>U(t)?t:e?t===""?NaN:t&&+t:r&&It(t)?new Date(t):n?n(t):t;function Nn(t){const e=t.ref;if(!(t.refs?t.refs.every(r=>r.disabled):e.disabled))return En(e)?e.files:In(e)?co(t.refs).value:ho(e)?[...e.selectedOptions].map(({value:r})=>r):Ve(e)?so(t.refs).value:vo(U(e.value)?t.ref.value:e.value,t)}var xh=(t,e,r,n)=>{const i={};for(const a of t){const o=$(e,a);o&&V(i,a,o._f)}return{criteriaMode:r,names:[...t],fields:i,shouldUseNativeValidation:n}},ze=t=>U(t)?t:vr(t)?t.source:Y(t)?vr(t.value)?t.value.source:t.value:t,kh=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate);function bo(t,e,r){const n=$(t,r);if(n||$n(r))return{error:n,name:r};const i=r.split(".");for(;i.length;){const a=i.join("."),o=$(e,a),s=$(t,a);if(o&&!Array.isArray(o)&&r!==a)return{name:r};if(s&&s.type)return{name:a,error:s};i.pop()}return{name:r}}var Sh=(t,e,r,n,i)=>i.isOnAll?!1:!r&&i.isOnTouch?!(e||t):(r?n.isOnBlur:i.isOnBlur)?!t:(r?n.isOnChange:i.isOnChange)?t:!0,Ch=(t,e)=>!je($(t,e)).length&&Q(t,e);const $h={mode:kt.onSubmit,reValidateMode:kt.onChange,shouldFocusError:!0};function Eh(t={},e){let r={...$h,...t},n={submitCount:0,isDirty:!1,isLoading:Kt(r.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},i={},a=Y(r.defaultValues)||Y(r.values)?Pt(r.defaultValues||r.values)||{}:{},o=r.shouldUnregister?{}:Pt(a),s={action:!1,mount:!1,watch:!1},l={mount:new Set,unMount:new Set,array:new Set,watch:new Set},h,p=0;const u={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Tn(),array:Tn(),state:Tn()},b=t.resetOptions&&t.resetOptions.keepDirtyValues,v=no(r.mode),y=no(r.reValidateMode),S=r.criteriaMode===kt.all,x=d=>g=>{clearTimeout(p),p=setTimeout(d,g)},m=async d=>{if(u.isValid||d){const g=r.resolver?bt((await L()).errors):await ot(i,!0);g!==n.isValid&&f.state.next({isValid:g})}},A=d=>u.isValidating&&f.state.next({isValidating:d}),N=(d,g=[],w,E,k=!0,_=!0)=>{if(E&&w){if(s.action=!0,_&&Array.isArray($(i,d))){const T=w($(i,d),E.argA,E.argB);k&&V(i,d,T)}if(_&&Array.isArray($(n.errors,d))){const T=w($(n.errors,d),E.argA,E.argB);k&&V(n.errors,d,T),Ch(n.errors,d)}if(u.touchedFields&&_&&Array.isArray($(n.touchedFields,d))){const T=w($(n.touchedFields,d),E.argA,E.argB);k&&V(n.touchedFields,d,T)}u.dirtyFields&&(n.dirtyFields=Mn(a,o)),f.state.next({name:d,isDirty:O(d,g),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else V(o,d,g)},M=(d,g)=>{V(n.errors,d,g),f.state.next({errors:n.errors})},H=(d,g,w,E)=>{const k=$(i,d);if(k){const _=$(o,d,U(w)?$(a,d):w);U(_)||E&&E.defaultChecked||g?V(o,d,g?_:Nn(k._f)):wt(d,_),s.mount&&m()}},it=(d,g,w,E,k)=>{let _=!1,T=!1;const j={name:d};if(!w||E){u.isDirty&&(T=n.isDirty,n.isDirty=j.isDirty=O(),_=T!==j.isDirty);const K=re($(a,d),g);T=$(n.dirtyFields,d),K?Q(n.dirtyFields,d):V(n.dirtyFields,d,!0),j.dirtyFields=n.dirtyFields,_=_||u.dirtyFields&&T!==!K}if(w){const K=$(n.touchedFields,d);K||(V(n.touchedFields,d,w),j.touchedFields=n.touchedFields,_=_||u.touchedFields&&K!==w)}return _&&k&&f.state.next(j),_?j:{}},gt=(d,g,w,E)=>{const k=$(n.errors,d),_=u.isValid&&qt(g)&&n.isValid!==g;if(t.delayError&&w?(h=x(()=>M(d,w)),h(t.delayError)):(clearTimeout(p),h=null,w?V(n.errors,d,w):Q(n.errors,d)),(w?!re(k,w):k)||!bt(E)||_){const T={...E,..._&&qt(g)?{isValid:g}:{},errors:n.errors,name:d};n={...n,...T},f.state.next(T)}A(!1)},L=async d=>r.resolver(o,r.context,xh(d||l.mount,i,r.criteriaMode,r.shouldUseNativeValidation)),ct=async d=>{const{errors:g}=await L(d);if(d)for(const w of d){const E=$(g,w);E?V(n.errors,w,E):Q(n.errors,w)}else n.errors=g;return g},ot=async(d,g,w={valid:!0})=>{for(const E in d){const k=d[E];if(k){const{_f:_,...T}=k;if(_){const j=l.array.has(_.name),K=await fo(k,o,S,r.shouldUseNativeValidation&&!g,j);if(K[_.name]&&(w.valid=!1,g))break;!g&&($(K,_.name)?j?wh(n.errors,K,_.name):V(n.errors,_.name,K[_.name]):Q(n.errors,_.name))}T&&await ot(T,g,w)}}return w.valid},D=()=>{for(const d of l.unMount){const g=$(i,d);g&&(g._f.refs?g._f.refs.every(w=>!An(w)):!An(g._f.ref))&&Fn(d)}l.unMount=new Set},O=(d,g)=>(d&&g&&V(o,d,g),!re(Co(),a)),q=(d,g,w)=>bh(d,l,{...s.mount?o:U(g)?a:It(d)?{[d]:g}:g},w,g),ut=d=>je($(s.mount?o:a,d,t.shouldUnregister?$(a,d,[]):[])),wt=(d,g,w={})=>{const E=$(i,d);let k=g;if(E){const _=E._f;_&&(!_.disabled&&V(o,d,vo(g,_)),k=pr(_.ref)&&at(g)?"":g,ho(_.ref)?[..._.ref.options].forEach(T=>T.selected=k.includes(T.value)):_.refs?Ve(_.ref)?_.refs.length>1?_.refs.forEach(T=>(!T.defaultChecked||!T.disabled)&&(T.checked=Array.isArray(k)?!!k.find(j=>j===T.value):k===T.value)):_.refs[0]&&(_.refs[0].checked=!!k):_.refs.forEach(T=>T.checked=T.value===k):En(_.ref)?_.ref.value="":(_.ref.value=k,_.ref.type||f.values.next({name:d,values:{...o}})))}(w.shouldDirty||w.shouldTouch)&&it(d,k,w.shouldTouch,w.shouldDirty,!0),w.shouldValidate&&On(d)},Tt=(d,g,w)=>{for(const E in g){const k=g[E],_=`${d}.${E}`,T=$(i,_);(l.array.has(d)||!br(k)||T&&!T._f)&&!ve(k)?Tt(_,k,w):wt(_,k,w)}},ne=(d,g,w={})=>{const E=$(i,d),k=l.array.has(d),_=Pt(g);V(o,d,_),k?(f.array.next({name:d,values:{...o}}),(u.isDirty||u.dirtyFields)&&w.shouldDirty&&f.state.next({name:d,dirtyFields:Mn(a,o),isDirty:O(d,_)})):E&&!E._f&&!at(_)?Tt(d,_,w):wt(d,_,w),io(d,l)&&f.state.next({...n}),f.values.next({name:d,values:{...o}}),!s.mount&&e()},Be=async d=>{const g=d.target;let w=g.name,E=!0;const k=$(i,w),_=()=>g.type?Nn(k._f):uh(d),T=j=>{E=Number.isNaN(j)||j===$(o,w,j)};if(k){let j,K;const xr=_(),we=d.type===to.BLUR||d.type===to.FOCUS_OUT,$p=!kh(k._f)&&!r.resolver&&!$(n.errors,w)&&!k._f.deps||Sh(we,$(n.touchedFields,w),n.isSubmitted,y,v),Dn=io(w,l,we);V(o,w,xr),we?(k._f.onBlur&&k._f.onBlur(d),h&&h(0)):k._f.onChange&&k._f.onChange(d);const Ln=it(w,xr,we,!1),Ep=!bt(Ln)||Dn;if(!we&&f.values.next({name:w,type:d.type,values:{...o}}),$p)return u.isValid&&m(),Ep&&f.state.next({name:w,...Dn?{}:Ln});if(!we&&Dn&&f.state.next({...n}),A(!0),r.resolver){const{errors:Oo}=await L([w]);if(T(xr),E){const Ip=bo(n.errors,i,w),Fo=bo(Oo,i,Ip.name||w);j=Fo.error,w=Fo.name,K=bt(Oo)}}else j=(await fo(k,o,S,r.shouldUseNativeValidation))[w],T(xr),E&&(j?K=!1:u.isValid&&(K=await ot(i,!0)));E&&(k._f.deps&&On(k._f.deps),gt(w,K,j,Ln))}},yr=(d,g)=>{if($(n.errors,g)&&d.focus)return d.focus(),1},On=async(d,g={})=>{let w,E;const k=Cn(d);if(A(!0),r.resolver){const _=await ct(U(d)?d:k);w=bt(_),E=d?!k.some(T=>$(_,T)):w}else d?(E=(await Promise.all(k.map(async _=>{const T=$(i,_);return await ot(T&&T._f?{[_]:T}:T)}))).every(Boolean),!(!E&&!n.isValid)&&m()):E=w=await ot(i);return f.state.next({...!It(d)||u.isValid&&w!==n.isValid?{}:{name:d},...r.resolver||!d?{isValid:w}:{},errors:n.errors,isValidating:!1}),g.shouldFocus&&!E&&hr(i,yr,d?k:l.mount),E},Co=d=>{const g={...a,...s.mount?o:{}};return U(d)?g:It(d)?$(g,d):d.map(w=>$(g,w))},$o=(d,g)=>({invalid:!!$((g||n).errors,d),isDirty:!!$((g||n).dirtyFields,d),isTouched:!!$((g||n).touchedFields,d),error:$((g||n).errors,d)}),xp=d=>{d&&Cn(d).forEach(g=>Q(n.errors,g)),f.state.next({errors:d?n.errors:{}})},Eo=(d,g,w)=>{const E=($(i,d,{_f:{}})._f||{}).ref;V(n.errors,d,{...g,ref:E}),f.state.next({name:d,errors:n.errors,isValid:!1}),w&&w.shouldFocus&&E&&E.focus&&E.focus()},kp=(d,g)=>Kt(d)?f.values.subscribe({next:w=>d(q(void 0,g),w)}):q(d,g,!0),Fn=(d,g={})=>{for(const w of d?Cn(d):l.mount)l.mount.delete(w),l.array.delete(w),g.keepValue||(Q(i,w),Q(o,w)),!g.keepError&&Q(n.errors,w),!g.keepDirty&&Q(n.dirtyFields,w),!g.keepTouched&&Q(n.touchedFields,w),!r.shouldUnregister&&!g.keepDefaultValue&&Q(a,w);f.values.next({values:{...o}}),f.state.next({...n,...g.keepDirty?{isDirty:O()}:{}}),!g.keepIsValid&&m()},Io=({disabled:d,name:g,field:w,fields:E,value:k})=>{if(qt(d)){const _=d?void 0:U(k)?Nn(w?w._f:$(E,g)._f):k;V(o,g,_),it(g,_,!1,!1,!0)}},Pn=(d,g={})=>{let w=$(i,d);const E=qt(g.disabled);return V(i,d,{...w||{},_f:{...w&&w._f?w._f:{ref:{name:d}},name:d,mount:!0,...g}}),l.mount.add(d),w?Io({field:w,disabled:g.disabled,name:d}):H(d,!0,g.value),{...E?{disabled:g.disabled}:{},...r.progressive?{required:!!g.required,min:ze(g.min),max:ze(g.max),minLength:ze(g.minLength),maxLength:ze(g.maxLength),pattern:ze(g.pattern)}:{},name:d,onChange:Be,onBlur:Be,ref:k=>{if(k){Pn(d,g),w=$(i,d);const _=U(k.value)&&k.querySelectorAll&&k.querySelectorAll("input,select,textarea")[0]||k,T=yh(_),j=w._f.refs||[];if(T?j.find(K=>K===_):_===w._f.ref)return;V(i,d,{_f:{...w._f,...T?{refs:[...j.filter(An),_,...Array.isArray($(a,d))?[{}]:[]],ref:{type:_.type,name:d}}:{ref:_}}}),H(d,!1,void 0,_)}else w=$(i,d,{}),w._f&&(w._f.mount=!1),(r.shouldUnregister||g.shouldUnregister)&&!(fh(l.array,d)&&s.action)&&l.unMount.add(d)}}},To=()=>r.shouldFocusError&&hr(i,yr,l.mount),Sp=d=>{qt(d)&&(f.state.next({disabled:d}),hr(i,g=>{g.disabled=d},0,!1))},Ao=(d,g)=>async w=>{w&&(w.preventDefault&&w.preventDefault(),w.persist&&w.persist());let E=Pt(o);if(f.state.next({isSubmitting:!0}),r.resolver){const{errors:k,values:_}=await L();n.errors=k,E=_}else await ot(i);Q(n.errors,"root"),bt(n.errors)?(f.state.next({errors:{}}),await d(E,w)):(g&&await g({...n.errors},w),To(),setTimeout(To)),f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:bt(n.errors),submitCount:n.submitCount+1,errors:n.errors})},Cp=(d,g={})=>{$(i,d)&&(U(g.defaultValue)?ne(d,$(a,d)):(ne(d,g.defaultValue),V(a,d,g.defaultValue)),g.keepTouched||Q(n.touchedFields,d),g.keepDirty||(Q(n.dirtyFields,d),n.isDirty=g.defaultValue?O(d,$(a,d)):O()),g.keepError||(Q(n.errors,d),u.isValid&&m()),f.state.next({...n}))},Mo=(d,g={})=>{const w=d?Pt(d):a,E=Pt(w),k=d&&!bt(d)?E:a;if(g.keepDefaultValues||(a=w),!g.keepValues){if(g.keepDirtyValues||b)for(const _ of l.mount)$(n.dirtyFields,_)?V(k,_,$(o,_)):ne(_,$(k,_));else{if(Sn&&U(d))for(const _ of l.mount){const T=$(i,_);if(T&&T._f){const j=Array.isArray(T._f.refs)?T._f.refs[0]:T._f.ref;if(pr(j)){const K=j.closest("form");if(K){K.reset();break}}}}i={}}o=t.shouldUnregister?g.keepDefaultValues?Pt(a):{}:Pt(k),f.array.next({values:{...k}}),f.values.next({values:{...k}})}l={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!s.mount&&e(),s.mount=!u.isValid||!!g.keepIsValid,s.watch=!!t.shouldUnregister,f.state.next({submitCount:g.keepSubmitCount?n.submitCount:0,isDirty:g.keepDirty?n.isDirty:!!(g.keepDefaultValues&&!re(d,a)),isSubmitted:g.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:g.keepDirtyValues?n.dirtyFields:g.keepDefaultValues&&d?Mn(a,d):{},touchedFields:g.keepTouched?n.touchedFields:{},errors:g.keepErrors?n.errors:{},isSubmitSuccessful:g.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},No=(d,g)=>Mo(Kt(d)?d(o):d,g);return{control:{register:Pn,unregister:Fn,getFieldState:$o,handleSubmit:Ao,setError:Eo,_executeSchema:L,_getWatch:q,_getDirty:O,_updateValid:m,_removeUnmounted:D,_updateFieldArray:N,_updateDisabledField:Io,_getFieldArray:ut,_reset:Mo,_resetDefaultValues:()=>Kt(r.defaultValues)&&r.defaultValues().then(d=>{No(d,r.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:d=>{n={...n,...d}},_disableForm:Sp,_subjects:f,_proxyFormState:u,get _fields(){return i},get _formValues(){return o},get _state(){return s},set _state(d){s=d},get _defaultValues(){return a},get _names(){return l},set _names(d){l=d},get _formState(){return n},set _formState(d){n=d},get _options(){return r},set _options(d){r={...r,...d}}},trigger:On,register:Pn,handleSubmit:Ao,watch:kp,setValue:ne,getValues:Co,reset:No,resetField:Cp,clearErrors:xp,unregister:Fn,setError:Eo,setFocus:(d,g={})=>{const w=$(i,d),E=w&&w._f;if(E){const k=E.refs?E.refs[0]:E.ref;k.focus&&(k.focus(),g.shouldSelect&&k.select())}},getFieldState:$o}}function mr(t={}){const e=St.useRef(),r=St.useRef(),[n,i]=St.useState({isDirty:!1,isValidating:!1,isLoading:Kt(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:Kt(t.defaultValues)?void 0:t.defaultValues});e.current||(e.current={...Eh(t,()=>i(o=>({...o}))),formState:n});const a=e.current.control;return a._options=t,vh({subject:a._subjects.state,next:o=>{gh(o,a._proxyFormState,a._updateFormState,!0)&&i({...a._formState})}}),St.useEffect(()=>a._disableForm(t.disabled),[a,t.disabled]),St.useEffect(()=>{if(a._proxyFormState.isDirty){const o=a._getDirty();o!==n.isDirty&&a._subjects.state.next({isDirty:o})}},[a,n.isDirty]),St.useEffect(()=>{t.values&&!re(t.values,r.current)?(a._reset(t.values,a._options.resetOptions),r.current=t.values):a._resetDefaultValues()},[t.values,a]),St.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()}),e.current.formState=ph(n,a),e.current}var wo=function(t,e,r){if(t&&"reportValidity"in t){var n=$(r,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},Ih=function(t,e){var r=function(i){var a=e.fields[i];a&&a.ref&&"reportValidity"in a.ref?wo(a.ref,i,t):a.refs&&a.refs.forEach(function(o){return wo(o,i,t)})};for(var n in e.fields)r(n)},Th=function(t,e){e.shouldUseNativeValidation&&Ih(t,e);var r={};for(var n in t){var i=$(e.fields,n),a=Object.assign(t[n]||{},{ref:i&&i.ref});if(Mh(e.names||Object.keys(t),n)){var o=Object.assign({},Ah($(r,n)));V(o,"root",a),V(r,n,o)}else V(r,n,a)}return r},Ah=function(t){return Array.isArray(t)?t.filter(Boolean):[]},Mh=function(t,e){return t.some(function(r){return r.startsWith(e+".")})},Nh=function(t,e){for(var r={};t.issues.length;){var n=t.issues[0];if(n.path){var i=n.path.map(function(s){return s.key}).join(".");if(r[i]||(r[i]={message:n.message,type:n.validation}),e){var a=r[i].types,o=a&&a[n.validation];r[i]=ro(i,e,r,n.validation,o?[].concat(o,n.message):n.message)}t.issues.shift()}}return r},_r=function(t,e,r){return r===void 0&&(r={}),function(n,i,a){try{return Promise.resolve(function(o,s){try{var l=function(){function h(u){return{values:r.raw?n:u,errors:{}}}var p=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},e);return r.mode==="sync"?h(Oa(t,n,p)):Promise.resolve(tf(t,n,p)).then(h)}()}catch(h){return s(h)}return l&&l.then?l.then(void 0,s):l}(0,function(o){if(o instanceof cn)return{values:{},errors:Th(Nh(o,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw o}))}catch(o){return Promise.reject(o)}}};const mo=27,_o=12,yo=10,Oh=he("enum"),Fh=(t,e)=>{const r={min:t.minSelected??0,max:t.maxSelected??t.options.length};return _r(rt({checked:Ht(hn(W(),ur()),cr(n=>Object.entries(n).filter(([i,a])=>a).map(([i,a])=>i)),Oe(r.max,e("validation_multiple_choice_max",{count:r.max})),pe(r.min,e("validation_multiple_choice_min",{count:r.min})))}))},Ph=zr(({option:t,...e},r)=>c(J,{children:[c("input",{class:"peer sr-only h-full",type:"checkbox",...e,ref:r}),c("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:e.id,children:t.label})]})),xo=Wt("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:Wa}}}),Dh=({input:t,onSubmitSuccess:e})=>{var p,u;const r=t.key?(p=I.current$.value.flow)==null?void 0:p.data.submissions[t.key]:void 0,n=(t.config.minSelected===1||t.config.minSelected===void 0)&&t.config.maxSelected===1,i=n&&t.config.options.length===2,{t:a}=et(),{register:o,handleSubmit:s,formState:{errors:l}}=mr({defaultValues:{checked:n?{}:Oh(r)?Object.fromEntries(r.value.map(f=>[f,!0])):{}},resolver:Fh(t.config,a)}),h=kn();return i?c("ul",{style:{maxHeight:6.5*mo+5*_o+2*yo},class:xo({variant:"booleanLike"}),children:t.config.options.map((f,b)=>c("li",{class:"flex-1",children:c(Ya,{type:"submit",ref:v=>{v&&b===0&&(h.current=v)},label:f.label,value:"true",onClick:()=>e({type:"enum",value:[f.value]})})},f.value))}):c("form",{noValidate:!0,onSubmit:f=>s(b=>{const v=b.checked;e({type:"enum",value:v})})(f),children:[c("div",{class:"flex items-center gap-1",children:[c("ul",{style:{maxHeight:6.5*mo+5*_o+2*yo},class:xo({variant:t.config.options.length===1?"singleOption":void 0}),children:t.config.options.map((f,b)=>{const v=`checked.${f.value}`,{ref:y,...S}=o(v);return c("li",{class:"relative",children:c(Ph,{option:f,autoFocus:b===0,ref:x=>{x&&b===0&&(h.current=x),y(x)},id:v,...S,onClick:n?()=>e({type:"enum",value:[f.value]}):void 0})},f.value)})}),c("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[n?null:c(te,{}),t.config.minSelected===0&&c(ee,{type:"button",onClick:()=>e({type:"enum",value:[]})})]})]}),c("div",{class:"px-1",children:c(ge,{error:(u=l.checked)==null?void 0:u.root})})]})},Lh=he("number"),Vh=(t,e)=>{const r=t.min??Number.MIN_SAFE_INTEGER,n=t.max??Number.MAX_SAFE_INTEGER,i=t.decimalCases??0;return _r(rt({number:Ht(Fe(e("validation_number")),$a(r,e("validation_number_min",{min:r})),Ca(n,e("validation_number_max",{max:n})),ka(a=>a===Number(a.toFixed(i)),e("validation_number_decimal_cases",{count:i})))}))},jh=({input:t,onSubmitSuccess:e})=>{var u;const r=t.config.defaultValue,n=t.key?(u=I.current$.value.flow)==null?void 0:u.data.submissions[t.key]:void 0,{t:i}=et(),{register:a,handleSubmit:o,formState:{errors:s}}=mr({defaultValues:{number:r?Number(r):Lh(n)?n.value:void 0},resolver:Vh(t.config,i)}),{ref:l,...h}=a("number",{required:!t.config.optional,valueAsNumber:!0}),p=ht();return ft(()=>{p.current&&(p.current.focus(),p.current.select())},[]),c("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:o(f=>{f.number!==void 0&&e({type:"number",value:f.number})}),children:[c("div",{class:"flex items-center gap-2",children:[c("div",{class:"relative min-w-0 flex-grow",children:[c("input",{...h,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:f=>{f&&(p.current=f),l(f)},type:"text",min:t.config.min,max:t.config.max,class:Le({optional:t.config.optional,className:"[type=number:-webkit-inner-spin-button] w-full rounded-full [-webkit-outer-spin-button:none]"}),placeholder:t.config.placeholder}),t.config.optional&&c(ee,{class:"absolute right-0 top-0",onClick:()=>e(null)})]}),c(te,{})]}),c(ge,{error:s.number})]})},zh=t=>{if(t==="")return{countryCode:"",phoneNumber:""};const e=Object.entries(xn).find(i=>t.startsWith(i[1])),r=e?e[1]:"",n=t.replace(r,"");return/^\d+$/.test(n)?{countryCode:r,phoneNumber:n}:{countryCode:"",phoneNumber:""}},Rh="44",Bh=/^[0-9 ]+$/,Uh=he("string"),Hh=he("phone"),qh=t=>{const e=Ht(W(t("validation_country_code")),Ea(Bh,t("validation_country_code"))),r=Ht(W(t("validation_phone")),pe(1,t("validation_phone")),cr(n=>n.replace(/[^0-9]/g,"")));return _r(rt({countryCode:e,phoneNumber:r}))},Kh=({input:t,onSubmitSuccess:e})=>{var y;const r=t.key?(y=I.current$.value.flow)==null?void 0:y.data.submissions[t.key]:void 0,{t:n}=et(),[i,a]=vt(),o=Uh(r)?zh(r.value):Hh(r)?r.value:void 0,{register:s,handleSubmit:l,formState:{errors:h},watch:p}=mr({defaultValues:{countryCode:(o==null?void 0:o.countryCode)??t.config.defaultValue.countryCode??Rh,phoneNumber:(o==null?void 0:o.phoneNumber)??t.config.defaultValue.phoneNumber??""},resolver:qh(n)}),{ref:u,...f}=s("phoneNumber",{required:!t.config.optional}),b=ht(),v=p("countryCode");return ft(()=>{b.current&&(b.current.focus(),b.current.select())},[]),c("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:l(S=>{const x=S.phoneNumber.replace(/[^0-9]/g,""),m=S.countryCode.replace(/[^0-9]/g,"");a(void 0);const A=t.config.minChars??7;if(x.length+m.length<A)return a(n("validation_phone_min_chars",{count:A}));t.config.submissionFormat==="phone"?e({type:"phone",value:{countryCode:m,phoneNumber:x}}):e({type:"string",value:v+S.phoneNumber})}),children:[c("div",{class:"flex items-center gap-2",children:[c("div",{class:"relative flex min-w-0 flex-1 flex-grow gap-2",children:[c("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_${t.key}`,children:[c("span",{children:["+",v]}),c("select",{...s("countryCode",{}),id:`isdk_phone_${t.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(xn).map(([S,x])=>c("option",{value:x,children:[S," (+",x,")"]},S))})]}),c("input",{...f,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:S=>{S&&(b.current=S),u(S)},class:Le({optional:t.config.optional,className:"min-w-0 flex-1 rounded-r-full"}),placeholder:t.config.placeholder}),t.config.optional&&c(ee,{class:"absolute bottom-0 right-0 top-0",onClick:()=>e(null)})]}),c(te,{})]}),c(ge,{error:h.countryCode||h.phoneNumber||{message:i}})]})},Gh=({input:t,onSubmitSuccess:e})=>c("div",{class:"flex flex-col items-center py-3",children:c("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:t.key,onClick:()=>{e(null)},children:c("span",{class:"flex items-center gap-1.5",children:[c("span",{class:"inline-flex items-center text-sm font-medium",children:t.config.label||"Submit"}),c("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:[c("path",{d:"M4 8L8 4L12 8"}),c("path",{d:"M8 4V13"})]})]})})}),Wh={email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},Yh=he("string"),Jh=(t,e)=>{const r={maxLength:e("validation_max_chars",{count:t.maxChars??999}),minLength:e("validation_min_chars",{count:t.minChars??1})};return _r(rt({text:{email:Ht(W(e("validation_email")),Sa(e("validation_email")),pe(t.minChars??1,r.minLength),Oe(t.maxChars??1/0,r.maxLength)),text:Ht(W(),pe(t.minChars??1,r.minLength),Oe(t.maxChars??1/0,r.maxLength)),url:Ht(W(e("validation_url")),Ia(e("validation_url")),pe(t.minChars??1,r.minLength),Oe(t.maxChars??1/0,r.maxLength))}[t.format]}))},Zh={text:({input:t,onSubmitSuccess:e})=>{var u;const{t:r}=et(),n=t.key?(u=I.current$.value.flow)==null?void 0:u.data.submissions[t.key]:void 0,i=t.config.defaultValue,{register:a,handleSubmit:o,formState:{errors:s}}=mr({defaultValues:{text:i||(Yh(n)?n.value:"")},resolver:Jh(t.config,r)}),{ref:l,...h}=a("text",{required:!t.config.optional}),p=ht();return ft(()=>{p.current&&(p.current.focus(),p.current.select())},[]),c("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:o(f=>{e({type:"string",value:f.text})}),children:[c("div",{class:"flex items-center gap-2",children:[c("div",{class:"relative min-w-0 flex-1",children:[c("input",{id:"chat-input",...h,...Wh[t.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:f=>{f&&(p.current=f),l(f)},placeholder:t.config.placeholder,class:Le({optional:!!t.config.optional,className:"w-full rounded-full"})}),t.config.optional&&c(ee,{class:"absolute right-0 top-0",onClick:()=>e(null)})]}),c(te,{})]}),c(ge,{error:s.text})]})},phone:Kh,"multiple-choice":Dh,boolean:rh,file:ch,submit:Gh,address:Xf,number:jh},Xh=({logger:t})=>{var a;const e=(a=I.current$.value.flow)==null?void 0:a.data.currentInput,[r,n]=zf(),i=ht(null);return I.inputHeight$.value=n.height,_t(()=>{const o=i.current;if(o)return o.addEventListener("transitionstart",nt.scrollToEnd.smooth),o.addEventListener("transitioncancel",nt.scrollToEnd.smooth),o.addEventListener("transitionend",nt.scrollToEnd.smooth),()=>{o.removeEventListener("transitionstart",nt.scrollToEnd.smooth),o.removeEventListener("transitioncancel",nt.scrollToEnd.smooth),o.removeEventListener("transitionend",nt.scrollToEnd.smooth)}},[]),c("div",{ref:i,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:c("div",{ref:r,class:"border-divider flex flex-col justify-end border-t",children:e?(()=>{const o=Zh[e.type];return c(o,{logger:t,onSubmitSuccess:nt.onSubmitSuccessFn$.value,input:e})})():c("div",{class:"flex items-center gap-2 p-2.5",children:[c("input",{"aria-hidden":"true",id:"chat-input",class:Le({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),c(te,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};var Qh=function(t){return t instanceof RegExp},tp=function(e){var r=/[\\^$.*+?()[\]{}|]/g,n=RegExp(r.source);return e&&n.test(e)?e.replace(r,"\\$&"):e},ko=function(t){return typeof t=="string"},ep=function(t){var e=[];return t.forEach(function(r){Array.isArray(r)?e=e.concat(r):e.push(r)}),e};function rp(t,e,r){var n=0,i=0;if(t==="")return t;if(!t||!ko(t))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var a=e;Qh(a)||(a=new RegExp("("+tp(a)+")","gi"));for(var o=t.split(a),s=1,l=o.length;s<l;s+=2){if(o[s]===void 0||o[s-1]===void 0){console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");continue}i=o[s].length,n+=o[s-1].length,o[s]=r(o[s],s,n),n+=i}return o}var np=function(e,r,n){return Array.isArray(e)||(e=[e]),ep(e.map(function(i){return ko(i)?rp(i,r,n):i}))};const Re=kr(np),ip=/(\[[^\]]+\]\([^)]+\))/g,ap=/\[([^\]]+)\]\(([^)]+)\)/,op=/(https?:\/\/[^\s]+)/g,sp=/_(.*?)_/g,lp=/\*\*(.*?)\*\*/g,cp=/\\n|\n/g,So="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",up=t=>{const e=Re(t,ip,(o,s)=>{const[,l,h]=o.match(ap)??[];return h?c("a",{class:So,href:h,children:l??h},h+s):c("span",{children:"INVALID LINK"})}),r=Re(e,op,(o,s)=>c("a",{class:So,href:o,children:o},o+s)),n=Re(r,sp,(o,s)=>c("em",{children:o},o+s)),i=Re(n,lp,(o,s)=>c("strong",{children:o},o+s));return Re(i,cp,(o,s)=>c("br",{},`br-${s}`))},dp=Wt("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"}}),fp=({children:t,className:e,animate:r,side:n,...i})=>c("p",{style:{transformOrigin:n==="left"?"0% 50%":"100% 50%"},class:dp({className:e,side:n,animate:r}),...i,children:t}),hp=({message:t})=>c("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:c("a",{onClick:t.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:t.href,children:[t.text,c("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:c("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"})})]})}),pp=({className:t,...e})=>(_t(()=>{nt.scrollToEnd.smooth()}),c("div",{"aria-hidden":!0,children:nt.isBotTyping$.value===!0?c("div",{"aria-label":"Typing…",class:Lt("flex gap-1 p-4",t),...e,children:Array.from({length:3},(r,n)=>c("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-n*200}ms`}}))}):void 0})),gp={bot:"left",user:"right"},vp=Wt("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]"}}}),bp=({lastSentMessageFooter:t})=>{var r;const e=((r=I.current$.value.flow)==null?void 0:r.data.messages)??[];return _t(()=>{nt.scrollToEnd.smooth()},[e.length]),c("ol",{"aria-label":"Chat messages",class:"mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[e.map((n,i)=>c(J,{children:c("li",{class:"flex",children:Zt(n).with({type:"system"},a=>c("p",{class:vp({variant:a.variant}),children:a.text})).with({type:"text",author:P.union("bot","user")},a=>{const o=a.author==="user"&&!e.slice(i+1).some(h=>h.type==="text"&&h.author==="user"),s=i===e.length-1,l=a.author==="bot"?up(a.text):a.text;return c(J,{children:[o?t:null,c(fp,{animate:s,side:gp[a.author],children:l},i)]})}).with({type:"link"},a=>c(hp,{message:a})).with({type:"image"},a=>c("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=>c(oh,{class:a.author==="bot"?void 0:"ml-auto",file:{name:a.fileName,sizeKb:a.fileSizeKb}})).with({type:"loading"},a=>{const o=e[e.length-1];return!(a===o)||nt.isBotTyping$.value?null:c("div",{class:"flex flex-grow flex-col items-center justify-center",children:c(va,{class:"text-neutral-6 h-8 w-8"})})}).exhaustive()})},i)),c(pp,{},"typing")]})},wp=({logger:t,apiClient:e,analytics:r})=>{const{flow:n}=I.current$.value;yt(n,"Flow is required to exist to show chatbot body");const i=I.viewState$.value,{chatRef:a,chatService:o}=Kf(),{t:s}=et(),[l,h]=vt();return ft(()=>{i==="maximised"&&nt.scrollToEnd.instant()},[i]),ft(()=>{var S,x;const{state:p,flow:u}=I.current$.peek();if(p!=="loaded")throw new Error(s("invalid_state"));let f=u.data.nodeHistory.at(-1);if(nt.scrollToEnd.instant(),I.setInput(void 0),u.data.isFinished)return;f===void 0?(f=da(n.nodes).id,I.setCurrentNodeId(f),r.log({event:"FLOW_START",properties:{flow_id:n.id,flow_version:n.version,flow_session_id:u.data.flowSessionId,flow_build:n.build,job:n.job},customProperties:(S=n.analytics)==null?void 0:S.customProperties})):I.removeMessagesSentByNodeIds([f]);const{interpret:b,abort:v,undo:y}=_f({context:n.context,analytics:{service:r,customProperties:(x=n.analytics)==null?void 0:x.customProperties},apiClient:e,logger:t,flow:n,chatService:o,t:s,getSubmissions:()=>{var m;return(m=I.current$.peek().flow)==null?void 0:m.data.submissions},onInterpret:(m,A)=>{var M;const N=I.current$.peek().flow;yt(N),A&&(N.data.sequence=N.data.sequence+1,r.log({event:"FLOW_NODE",properties:{flow_id:n.id,flow_version:n.version,from_node_id:A.id,flow_build:n.build,to_node_id:m.id,sequence:N.data.sequence,flow_session_id:N.data.flowSessionId,job:n.job},customProperties:(M=n.analytics)==null?void 0:M.customProperties})),I.setCurrentNodeId(m.id)},onFlowEnd:async()=>{var A;I.markAsFinished();const m=I.current$.peek().flow;yt(m),r.log({event:"FLOW_END",properties:{flow_id:n.id,flow_version:n.version,flow_session_id:m.data.flowSessionId,flow_build:n.build,job:n.job},customProperties:(A=n.analytics)==null?void 0:A.customProperties})}});return h(()=>y),b(f),v},[r,e,o,t,n,s]),c(J,{children:[c("div",{ref:a,className:"hide-scrollbars relative flex w-full max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:I.inputHeight$.value},children:c(bp,{lastSentMessageFooter:n.data.isFinished||!l?null:c(_p,{undoFn:l})})}),c(Xh,{logger:t})]})},mp=t=>"key"in t.data&&t.data.key?[t.data.key]:"keys"in t.data?Object.values(t.data.keys).filter(e=>typeof e=="string"):[],_p=({undoFn:t})=>{const{t:e}=et();return c(sr,{onClick:async()=>{const{flow:r}=I.current$.peek();yt(r);const{removed:n}=t(r.data.nodeHistory),i=r.data.nodeHistory.splice(-n);i.length!==0&&(I.removeMessagesSentByNodeIds(i),I.setInput(void 0),i.pop(),i.map(a=>r.nodes.find(o=>o.id===a)).filter(Boolean).flatMap(mp).forEach(a=>delete r.data.submissions[a]),I.current$.value={...I.current$.value})},children:[c("title",{children:e("undo")}),c("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"})]})},yp=Object.freeze(Object.defineProperty({__proto__:null,ChatbotBody:wp},Symbol.toStringTag,{value:"Module"}))})();
|
|
5
|
+
}`},La=({context:t,schema:e,logger:r})=>{if(e)for(const n in e){const i=e[n];if(!i)continue;const a=_e(t,n,null);if(i.required&&a===null){const o=`Configuration error in context: ${n} is required`;throw r.error(o),new Error(o)}switch(i.type){case"number":if(typeof a!="number")throw new Error(`Configuration error in context: ${n} is not a number`);break;case"string":if(typeof a!="string")throw new Error(`Configuration error in context: ${n} is not a string`);break;default:i.type}}},bf=({_internal_domManager:t=Gd(),theme:e,terms:r,feedback:n})=>Po(({apiClient:i,rpcClient:a,logger:o,analytics:s})=>{let l=!1;const h=pd({locale:void 0,overrides:r??{}}),p=()=>{var b;if(typeof window>"u")return;const u=[dt("style",{id:"inploi-chatbot-styles"},Kd),dt("style",{id:"inploi-chatbot-theme"},vf(e))],f=t.getOrCreateChatbotElement();if(le(dt(J,{},[u,dt(Hd,{apiClient:i,logger:o,analytics:s,params:{theme:e,terms:r,feedback:n}})]),f),n){const v=f.querySelector("dialog");if(!v)throw new Error("Couldn't find feedback host");if(n.plugin instanceof Promise)n.plugin.then(({feedbackPlugin:y})=>{var x;const S=y()({rpcClient:a,apiClient:i,logger:o,analytics:s});Va({instance:S,theme:e,terms:((x=n.params)==null?void 0:x.terms)??{},host:v})});else{const y=n.plugin({rpcClient:a,apiClient:i,logger:o,analytics:s});Va({instance:y,theme:e,terms:((b=n.params)==null?void 0:b.terms)??{},host:v})}}l=!0};return{prepare:async()=>{if(!(typeof window>"u"))try{if(l)return;p(),o.info("Chatbot plugin prepared")}catch(u){o.error("Error preparing chatbot plugin",u)}},fetchFlowByJobId:async(u,f)=>a.request(of,{params:{id:u},searchParams:{id_type:(f==null?void 0:f.idType)==="inploi"?"internal":"external"}}).then(b=>({flow:b.flow,title:b.job.title,flowKeys:[b.job.id,...(f==null?void 0:f.flowKeys)??[]],job:{id:b.job.id,id_type:"external"},...f,context:{user:b.user,...f==null?void 0:f.context}})),fetchFlowById:async(u,f)=>a.request(sf,{params:{id:u}}).then(b=>{var v;return{flow:b.flow,title:"Chatbot",flowKeys:(f==null?void 0:f.flowKeys)??[],...f,analytics:{customProperties:{flow_id:b.flow.id,flow_version:b.flow.version,...(v=f==null?void 0:f.analytics)==null?void 0:v.customProperties}}}}),open:async u=>{if(!(typeof window>"u"))try{I.cancelCurrentFlow(),I.viewState$.value="maximised",l||p(),u instanceof Promise?(I.current$.value={state:"loading"},u.then(async f=>{La({context:f.context||{},schema:f.flow.context_schema,logger:o}),I.startFlow(f)}).catch(f=>{const b=f instanceof Error?f.message:h("unknown_error");I.current$.value={state:"error",error:b}})):(La({context:u.context||{},schema:u.flow.context_schema,logger:o}),I.startFlow(u))}catch(f){o.error("Error starting flow",f)}},close:async()=>{typeof window>"u"||(I.cancelCurrentFlow(),o.info("Closed flow from an external source"))}}});function Va({instance:t,terms:e,theme:r,host:n}){t.render({key:"chatbot-header",size:"sm",theme:{accent:{chroma:r.chroma??1,hue:r.hue},positive:{hue:180,chroma:1},negative:{hue:33,chroma:1},mode:r.mode,corners:"rounded",highlights:"stroke"},terms:e,host:n})}if(!window.inploi)throw new Error("Please insert the SDK script tag above the plugins.");window.inploi.chatbotPlugin=bf;const ja=({condition:t,context:e,submissions:r,ifBlock:n})=>{const[i,...a]=t.compareKey.split(".");if(!i)return!1;const o=Ra({context:e,key:i,path:a,submissions:r});if(!o)return!1;switch(o.type){case"address":{const s=_e(o.value,a.join("."));switch(t.compare){case"equals":return s===t.compareValue;case"contains":return s?s.includes(t.compareValue):!1;case"notEquals":return s!==t.compareValue;case"notContains":return s?!s.includes(t.compareValue):!0}break}case"integration":{if(typeof o.value!="object"||Array.isArray(o.value))return!1;const s=_e(o.value,a.join(".")),l={...n,data:{...n.data,compareKey:"_temp"}};switch(typeof s){case"boolean":return Pe(l,{submissions:{_temp:{value:s,type:"boolean"}},context:e});case"string":return Pe(l,{submissions:{_temp:{value:s,type:"string"}},context:e});case"number":return Pe(l,{submissions:{_temp:{value:s,type:"number"}},context:e});case"object":return Array.isArray(s)&&s.every(fa)?Pe(l,{submissions:{_temp:{value:s,type:"enum"}},context:e}):!1}break}case"boolean":{const s=t.compareValue==="true";switch(t.compare){case"equals":return o.value===s;case"notEquals":return o.value!==s}break}case"phone":case"string":{const s=o.type==="phone"?fr(o.value):o.value;switch(t.compare){case"equals":return s===t.compareValue;case"contains":return s?s.includes(t.compareValue):!1;case"notEquals":return s!==t.compareValue;case"notContains":return s?!s.includes(t.compareValue):!0}break}case"number":{try{const s=Number(t.compareValue);switch(t.compare){case"equals":return o.value===s;case"notEquals":return o.value!==s;case"greaterThan":return o.value>s;case"greaterThanOrEqualTo":return o.value>=s;case"lessThan":return o.value<s;case"lessThanOrEqualTo":return o.value<=s}}catch{return console.error(`Failed to parse number in if-block ${n.id}`,o.value),!1}break}case"enum":switch(t.compare){case"equals":return o.value.length===1&&o.value[0]===t.compareValue;case"notEquals":return o.value.length===1&&o.value[0]!==t.compareValue;case"contains":return o.value.includes(t.compareValue);case"notContains":return!o.value.includes(t.compareValue)}break}},Pe=(t,{context:e,submissions:r})=>{const n="combinator"in t.data?t.data.conditions:[t.data];if(("combinator"in t.data?t.data.combinator:"and")==="or"){for(const a of n)if(ja({condition:a,context:e,submissions:r,ifBlock:t}))return!0;return!1}else{for(const a of n)if(!ja({condition:a,context:e,submissions:r,ifBlock:t}))return!1;return!0}},wf=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,Et=(t,{context:e,submissions:r})=>t.replace(wf,(n,i,a="")=>{const[o,...s]=i.trim().split("."),l=Ra({key:o,path:s,submissions:r,context:e});if(!l)return a;switch(l.type){case"boolean":return l.value===!0?"true":"false";case"file":return l.value.map(h=>`${h.name} (${Te(h.sizeKb)})`).join(", ");case"enum":return l.value.join(", ");case"address":return Object.values(l.value).filter(h=>h&&h.trim().length>0).join(", ");case"number":case"string":return l.value?l.value.toString():a;case"phone":return fr(l.value);case"integration":{if(typeof l.value!="object"||Array.isArray(l.value))break;const h=_e(l.value,s.join("."));switch(typeof h){case"boolean":return h===!0?"true":"false";case"string":return h;case"number":return h.toString();case"object":if(Array.isArray(h)&&h.every(fa))return h.join(", ")}break}}return a}),za=({node:t,nodes:e,stopWhen:r})=>{if((r==null?void 0:r(t))===!0)return t;const n=t.nextId?e.find(i=>i.id===t.nextId):void 0;if(n)return za({node:n,nodes:e,stopWhen:r})},mf=({childNode:t,nodes:e})=>{const n=e.filter(i=>i.type==="if-block").find(i=>{if(!i.branchId)return!1;const a=e.find(s=>s.id===i.branchId);if(!a)return!1;const o=za({node:a,nodes:e,stopWhen:s=>s.id===t.id});return!(!o||o.id!==t.id)});if(n!=null&&n.nextId)return e.find(i=>i.id===n.nextId)},_f=({flow:t,analytics:e,logger:r,context:n,apiClient:i,getSubmissions:a,chatService:o,onFlowEnd:s,onInterpret:l,t:h})=>{let p=new AbortController;const u={...e.service,log:b=>e.service.log({...b,customProperties:{...b.customProperties,...e.customProperties}})},f=async(b,v)=>{const y=a();l==null||l(b,v);try{await yf({flow:t,analytics:u,logger:r,apiClient:i,context:n,node:b,submissions:y,t:h,chat:{sendMessage:async S=>o.send({groupId:b.id,message:S,signal:p.signal}),userInput:async S=>o.input({input:S,signal:p.signal}),addToSubmissions:o.addToSubmissions},next:S=>{const x=S?t.nodes.find(m=>m.id===S):mf({childNode:b,nodes:t.nodes});return x?f(x,b):s==null?void 0:s(b)},end:()=>s==null?void 0:s(b)})}catch(S){if(S instanceof Ae)return;throw S}};return{interpret:async b=>{const v=t.nodes.find(y=>y.id===b)??da(t.nodes);return f(v)},undo:b=>{let v=1;const y=t.nodes.find(x=>x.id===b[b.length-1]);for(let x=b.length-2;x>0;x--){const m=b[x],A=t.nodes.find(N=>N.id===m);if(!A||(v++,A.type.startsWith("question-")))break}p.abort(),p=new AbortController;const S=t.nodes.find(x=>x.id===b[b.length-v]);return yt(S,"Undo failed: new start node not found"),f(S,y),{removed:v}},abort:()=>{p.abort()}}},fr=t=>`+${t.countryCode} ${t.phoneNumber}`;async function yf(t){const e=t.node;switch(e.type){case"text":return Tf({...t,node:e});case"image":return Af({...t,node:e});case"question-text":return Mf({...t,node:e});case"question-enum":return Ff({...t,node:e});case"question-number":return Nf({...t,node:e});case"question-phone":return Of({...t,node:e});case"question-boolean":return Pf({...t,node:e});case"question-file":return Lf({...t,node:e});case"question-address":return Df({...t,node:e});case"end-flow":return Vf({...t,node:e});case"if-block":return If({...t,node:e});case"jump":return Sf({...t,node:e});case"link":return Ef({...t,node:e});case"integration-application-submit":return $f({...t,node:e});case"add-submission":return Cf({...t,node:e});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"identify":return kf({...t,node:e});case"feedback":return xf({...t,node:e});default:throw new Error(`Unknown node: ${JSON.stringify(e)}`)}}const De=(t,e)=>{var n;const r=(n=t[e])==null?void 0:n.value;if(typeof r!="string"&&typeof r!="number")throw new Error(`Submission at “${e}” is not a string or number`);return r};async function xf({next:t,node:e}){t(e.nextId)}async function kf({next:t,node:e,analytics:r,submissions:n,logger:i}){if(!n)return t(e.nextId);try{r.log({event:"IDENTIFY",properties:{identifier:De(n,e.data.key).toString(),first_name:e.data.firstName?De(n,e.data.firstName).toString():void 0,last_name:e.data.lastName?De(n,e.data.lastName).toString():void 0,email:e.data.email?De(n,e.data.email).toString():void 0,phone_number:e.data.phoneNumber?De(n,e.data.phoneNumber).toString():void 0,custom_traits:e.data.customTraits?Object.fromEntries(e.data.customTraits.map(({key:a,value:o})=>{var s;return[a,(s=n[o])==null?void 0:s.value]})):void 0}})}catch(a){i.error(a)}finally{t(e.nextId)}}async function Sf({next:t,node:e}){t(e.data.targetId)}async function Cf({next:t,node:e,logger:r,submissions:n,context:i}){if(!n){r.error("Submissions not found");return}n[e.data.key]={type:"string",value:Et(e.data.value,{submissions:n,context:i})},t(e.nextId)}async function $f({chat:t,next:e,node:r,logger:n,apiClient:i,submissions:a,analytics:o,flow:s,t:l}){const h=async p=>{p!==!0&&await t.userInput({type:"submit",key:void 0,config:{label:r.data.submitLabel}}),await t.sendMessage({type:"loading"});const{anonymous_id:u,session_id:f}=o.getSessionInfo(),b=await i.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:r.data.integrationId,anonymous_id:u,session_id:f,job:s.job,submissions:Nd(a||{})})}).catch(v=>v);r.data.key&&t.addToSubmissions(r.data.key,{type:"integration",value:b}),Zt(b).with({integration_response:P.select(P.union({service:P.optional(P.string),status:P.number,data:P.any},{service:P.optional(P.string),status:P.number,error:{message:P.string,data:P.any}}))},v=>{o.log({event:"FLOW_SUBMIT",properties:{flow_id:s.id,flow_version:s.version,flow_session_id:s.data.flowSessionId,flow_build:s.build,service:v.service??"INVALID_SERVICE",response:{status:v.status,payload:"data"in v?v.data:v.error.data??null},job:s.job}})}).otherwise(()=>{}),await Zt(b).with({integration_response:{data:P.select("redirect",{redirect_url:P.string,message:P.optional(P.union(P.string,P.nullish)),button_text:P.optional(P.union(P.string,P.nullish))})}},async v=>{await t.sendMessage({type:"text",author:"bot",text:v.redirect.message??l("submission_redirect_message")});try{const y=new URL(v.redirect.redirect_url);u&&!y.searchParams.has("anonymous_id")&&y.searchParams.set("anonymous_id",u),await t.sendMessage({type:"link",href:y.toString(),text:v.redirect.button_text??l("complete_submission"),onClick:()=>{if(!f){n.error("session_id not set, cannot log FLOW_REDIRECT event");return}o.log({event:"FLOW_REDIRECT",properties:{flow_build:s.build,flow_id:s.id,flow_session_id:f,flow_version:s.version,href:y.toString(),job:s.job}})}})}catch(y){n.error(`Invalid redirect URL: ${v.redirect.redirect_url}`,y),t.sendMessage({type:"system",variant:"error",text:l("redirect_url_error")})}e(r.nextId)}).with({success:!0},async()=>{r.data.skipConfirmation!==!0&&await t.sendMessage({type:"system",variant:"success",text:l("submission_completed")}),e(r.nextId)}).with({integration_response:{error:P.select("error",{message:P.string})}},async v=>{n.error(v.error),await t.sendMessage({type:"system",variant:"error",text:v.error.message||l("submission_failed")}),await h(!1)}).otherwise(async v=>{n.error(v),await t.sendMessage({type:"system",variant:"error",text:l("submission_failed")}),await h(!1)})};await h(r.data.skipConfirmation)}async function Ef({chat:t,next:e,node:r,submissions:n,context:i}){await t.sendMessage({type:"link",href:Et(r.data.href,{submissions:n,context:i}),text:Et(r.data.cta,{submissions:n,context:i})}),e(r.nextId)}async function If({submissions:t,next:e,node:r,context:n}){e(Pe(r,{submissions:t,context:n})?r.branchId:r.nextId)}async function Tf({chat:t,next:e,node:r,submissions:n,context:i}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.text,{submissions:n,context:i})}),e(r.nextId)}async function Af({chat:t,next:e,node:r}){await t.sendMessage({author:"bot",type:"image",url:r.data.url,height:r.data.height,width:r.data.width}),e(r.nextId)}async function Mf({chat:t,next:e,node:r,submissions:n,context:i,t:a}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.question,{submissions:n,context:i})});const o=r.data.format==="phone"?await t.userInput({key:r.data.key,type:"phone",config:{optional:r.data.optional,placeholder:r.data.placeholder,minChars:r.data.minChars,submissionFormat:"text",defaultValue:{}}}):await t.userInput({key:r.data.key,type:"text",config:{optional:r.data.optional,placeholder:r.data.placeholder,format:r.data.format,maxChars:r.data.maxChars,minChars:r.data.minChars}});o===null?await t.sendMessage({type:"system",variant:"info",text:a("skipped")}):await t.sendMessage({author:"user",type:"text",text:o.type==="phone"?fr(o.value):o.value}),e(r.nextId)}async function Nf({chat:t,next:e,node:r,submissions:n,context:i,t:a}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.question,{submissions:n,context:i})});const o=await t.userInput({key:r.data.key,type:"number",config:{max:r.data.max,min:r.data.min,optional:r.data.optional,placeholder:r.data.placeholder,decimalCases:r.data.decimalCases}});o===null?await t.sendMessage({type:"system",variant:"info",text:a("skipped")}):await t.sendMessage({author:"user",type:"text",text:o.value.toString()}),e(r.nextId)}async function Of({chat:t,next:e,node:r,submissions:n,context:i}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.question,{submissions:n,context:i})});const a=await t.userInput({key:r.data.key,type:"phone",config:{minChars:r.data.minChars,defaultValue:{countryCode:r.data.defaultCountryCode},placeholder:r.data.placeholder,submissionFormat:"phone",optional:r.data.optional}});a===null?await t.sendMessage({type:"system",variant:"info",text:"Skipped"}):await t.sendMessage({author:"user",type:"text",text:a.type==="phone"?fr(a.value):a.value}),e(r.nextId)}async function Ff({chat:t,next:e,node:r,submissions:n,context:i,t:a}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.question,{submissions:n,context:i})});const o=await t.userInput({key:r.data.key,type:"multiple-choice",config:r.data});o.value.length===0?await t.sendMessage({type:"system",variant:"info",text:a("skipped")}):await t.sendMessage({author:"user",type:"text",text:r.data.options.filter(s=>o.value.includes(s.value)).map(s=>s.label).join(", ")}),e(r.nextId)}async function Pf({chat:t,next:e,node:r,submissions:n,context:i,t:a}){await t.sendMessage({author:"bot",type:"text",text:Et(r.data.question,{submissions:n,context:i})});const o=await t.userInput({key:r.data.key,type:"boolean",config:{optional:r.data.optional,labels:{true:r.data.trueLabel,false:r.data.falseLabel}}});o===null?await t.sendMessage({type:"system",variant:"info",text:a("skipped")}):await t.sendMessage({author:"user",type:"text",text:o.value===!0?r.data.trueLabel:r.data.falseLabel}),e(r.nextId)}async function Df({chat:t,next:e,node:r,t:n}){await t.sendMessage({author:"bot",type:"text",text:r.data.question});const i=await t.userInput({type:"address",key:r.data.key,config:{optional:r.data.optional,keys:r.data.keys,placeholder:r.data.placeholder}});if(i===null)await t.sendMessage({type:"system",variant:"info",text:n("skipped")});else{const a=Object.values(i.value).filter(o=>o&&o.trim().length>0).join(", ");await t.sendMessage({author:"user",type:"text",text:a})}return e(r.nextId)}async function Lf({node:t,chat:e,next:r,submissions:n,context:i,t:a}){await e.sendMessage({author:"bot",type:"text",text:Et(t.data.question,{submissions:n,context:i})});const o=await e.userInput({key:t.data.key,type:"file",config:{optional:t.data.optional,extensions:t.data.extensions,fileSizeLimitKib:t.data.maxSizeKb??10*1024,allowMultiple:t.data.multiple===!0}});if(o===null)await e.sendMessage({type:"system",variant:"info",text:a("skipped")});else for(const s of o.value)await e.sendMessage({author:"user",type:"file",fileName:s.name,fileSizeKb:s.sizeKb});r(t.nextId)}async function Vf({chat:t,end:e,node:r}){await t.sendMessage({type:"system",variant:"info",text:r.data.systemMessage}),e()}const Ra=({key:t,path:e,submissions:r,context:n})=>{if(t==="$context"){if(!e)return;const i=_e(n,e.join("."));switch(typeof i){case"string":return{type:"string",value:i};case"number":return{type:"number",value:i};case"boolean":return{type:"boolean",value:i};default:console.warn(`Unexpected type for $context.${e.join(".")}`,i);return}}return r==null?void 0:r[t]};function _n(t,e,r){var n,i,a,o,s;e==null&&(e=100);function l(){var p=Date.now()-o;p<e&&p>=0?n=setTimeout(l,e-p):(n=null,r||(s=t.apply(a,i),a=i=null))}var h=function(){a=this,i=arguments,o=Date.now();var p=r&&!n;return n||(n=setTimeout(l,e)),p&&(s=t.apply(a,i),a=i=null),s};return h.clear=function(){n&&(clearTimeout(n),n=null)},h.flush=function(){n&&(s=t.apply(a,i),a=i=null,clearTimeout(n),n=null)},h}_n.debounce=_n;var jf=_n;const Ba=kr(jf);function zf(t){let{debounce:e,scroll:r,polyfill:n,offsetSize:i}=t===void 0?{debounce:0,scroll:!1,offsetSize:!1}:t;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[o,s]=vt({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),l=ht({element:null,scrollContainers:null,resizeObserver:null,lastBounds:o}),h=e?typeof e=="number"?e:e.scroll:null,p=e?typeof e=="number"?e:e.resize:null,u=ht(!1);_t(()=>(u.current=!0,()=>void(u.current=!1)));const[f,b,v]=Nt(()=>{const m=()=>{if(!l.current.element)return;const{left:A,top:N,width:M,height:H,bottom:it,right:gt,x:L,y:ct}=l.current.element.getBoundingClientRect(),ot={left:A,top:N,width:M,height:H,bottom:it,right:gt,x:L,y:ct};l.current.element instanceof HTMLElement&&i&&(ot.height=l.current.element.offsetHeight,ot.width=l.current.element.offsetWidth),Object.freeze(ot),u.current&&!Hf(l.current.lastBounds,ot)&&s(l.current.lastBounds=ot)};return[m,p?Ba(m,p):m,h?Ba(m,h):m]},[s,i,h,p]);function y(){l.current.scrollContainers&&(l.current.scrollContainers.forEach(m=>m.removeEventListener("scroll",v,!0)),l.current.scrollContainers=null),l.current.resizeObserver&&(l.current.resizeObserver.disconnect(),l.current.resizeObserver=null)}function S(){l.current.element&&(l.current.resizeObserver=new a(v),l.current.resizeObserver.observe(l.current.element),r&&l.current.scrollContainers&&l.current.scrollContainers.forEach(m=>m.addEventListener("scroll",v,{capture:!0,passive:!0})))}const x=m=>{!m||m===l.current.element||(y(),l.current.element=m,l.current.scrollContainers=Ua(m),S())};return Bf(v,!!r),Rf(b),_t(()=>{y(),S()},[r,v,b]),_t(()=>y,[]),[x,o,f]}function Rf(t){_t(()=>{const e=t;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[t])}function Bf(t,e){_t(()=>{if(e){const r=t;return window.addEventListener("scroll",r,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",r,!0)}},[t,e])}function Ua(t){const e=[];if(!t||t===document.body)return e;const{overflow:r,overflowX:n,overflowY:i}=window.getComputedStyle(t);return[r,n,i].some(a=>a==="auto"||a==="scroll")&&e.push(t),[...e,...Ua(t.parentElement)]}const Uf=["x","y","top","bottom","left","right","width","height"],Hf=(t,e)=>Uf.every(r=>t[r]===e[r]),te=({class:t,...e})=>{const{t:r}=et();return c("button",{class:Lt("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",t),type:"submit",...e,children:c("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[c("title",{children:r("send")}),c("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),c("path",{d:"M8 4V13"})]})})},qf=25,yn=Rt({instant:()=>{},smooth:()=>{}}),nt={onSubmitSuccessFn$:Rt(()=>{}),isBotTyping$:Rt(!1),scrollToEnd:{instant:()=>yn.value.instant(),smooth:()=>yn.value.smooth()}},Kf=()=>{const t=ht(null);ft(()=>{yn.value={instant:()=>{var r;return(r=t.current)==null?void 0:r.scrollTo({top:t.current.scrollHeight,behavior:"instant"})},smooth:()=>{t.current&&t.current.scrollHeight-t.current.scrollTop<=t.current.clientHeight*2&&t.current.scrollTo({top:t.current.scrollHeight,behavior:"smooth"})}}},[t]);const e=Nt(()=>({addToSubmissions:(n,i)=>I.setSubmission(n,i),send:async({message:n,signal:i,groupId:a})=>{if(await Zt(n).with({author:"bot",type:"text"},async o=>{if(i!=null&&i.aborted)throw new Ae;nt.isBotTyping$.value=!0;const s=Math.min(Math.max(20,o.text.length),100)*qf;await new Promise(l=>setTimeout(l,s,{signal:i})),nt.isBotTyping$.value=!1}).otherwise(async()=>{}),i!=null&&i.aborted)throw new Ae;I.addMessage(n,a)},input:({input:n,signal:i})=>{if(i!=null&&i.aborted)throw new Ae;return I.setInput(n),new Promise(a=>{const o=s=>{if(i!=null&&i.aborted)throw new Ae;I.setInput(void 0),n.key&&I.setSubmission(n.key,s),a(s)};nt.onSubmitSuccessFn$.value=o})}}),[]);return{chatRef:t,chatService:e}},ge=({error:t})=>!t||!t.message?null:c("div",{role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full px-2 py-2",children:[c("svg",{class:"text-error-9 h-4 w-4",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),c("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),c("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),c("p",{class:"truncate pr-1 text-sm",children:t.message})]}),ee=({class:t,...e})=>{const{t:r}=et();return c("button",{type:"button",class:Lt("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",t),...e,children:[c("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:[c("title",{children:r("skip")}),c("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),c("path",{d:"M13.25 4.5V8.25H9.5"})]}),r("skip")]})},xn={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"},Le=Wt("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}}),Gf="https://api.mapbox.com/search/searchbox/v1/suggest",Wf="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",Yf=t=>atob(t).split("").reverse().join(""),Ft=rt({name:W()}),Jf=rt({suggestions:dn(rt({full_address:xt(W()),place_formatted:xt(W()),name:xt(W()),mapbox_id:W(),context:ef(rt({address:Ft,street:Ft,neighborhood:Ft,locality:Ft,district:Ft,place:Ft,region:Ft,postcode:Ft,country:Ft}))}))}),Zf=({logger:t,t:e})=>Nt(()=>{var n;const r=(n=I.current$.peek().flow)==null?void 0:n.data.flowSessionId;return r?{enabled:!0,getPredictions:async i=>{var u;const a=new URL(Gf);a.searchParams.set("q",i),a.searchParams.set("session_token",r);const o=(u=I.current$.peek().flow)==null?void 0:u.locationOrigin;o&&o.lat!==void 0&&o.lng!==void 0&&o.lat>=-90&&o.lat<=90&&o.lng>=-180&&o.lng<=180&&a.searchParams.set("proximity",`${o.lng},${o.lat}`),a.searchParams.set("access_token",Yf(Wf));const l=await fetch(a);if(!l.ok)return t.error("Failed to get address details",l),{ok:!1,error:e("address_error")};const h=rf(Jf,await l.json());if(h.success===!1)return t.error("Failed to parse address details",h.issues),{ok:!1,error:e("address_error")};const{suggestions:p}=h.output;return{ok:!0,data:p.map(f=>{var b,v,y,S,x,m,A,N,M;return{label:f.full_address??f.place_formatted??f.name??f.mapbox_id,id:f.mapbox_id,address:{line1:((b=f.context.address)==null?void 0:b.name)??((v=f.context.street)==null?void 0:v.name),line2:void 0,line3:((y=f.context.neighborhood)==null?void 0:y.name)??((S=f.context.locality)==null?void 0:S.name),city:((x=f.context.place)==null?void 0:x.name)??((m=f.context.district)==null?void 0:m.name),state:(A=f.context.region)==null?void 0:A.name,postcode:(N=f.context.postcode)==null?void 0:N.name,country:(M=f.context.country)==null?void 0:M.name}}})}}}:{enabled:!1}},[t,e]),Ha=t=>{const{t:e}=et();return c("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",...t,children:[c("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:c("path",{d:"M10 3L5 8L10 13"})}),c("span",{children:e("back")})]})},Xf=({input:t,onSubmitSuccess:e,logger:r})=>{const{t:n}=et(),[i,a]=vt(),[o,s]=vt([]),{enabled:l,getPredictions:h}=Zf({logger:r,t:n}),[p,u]=vt(l?"query":"manual"),[f,b]=vt(""),[v,y]=vt(),S=x=>{yt(l,"Query state should not be enabled"),x=x.trim(),x!==(f==null?void 0:f.trim())&&(b(x),x===""&&s([]),y(void 0),h(x).then(m=>{if(m.ok===!1){s([]),y(m.error);return}s(m.data)}))};switch(p){case"query":return yt(l,"Query state should not be enabled"),c(Qf,{input:t,onSkip:()=>e(null),onAddressSelect:x=>{if(x===""){a(void 0),u("manual");return}const m=o.find(A=>A.id===x);m&&(a(m.address),u("details"))},onAddressSearch:x=>{S(x)},suggestions:o,query:f,error:v});case"details":return yt(i!==void 0),c(Ka,{input:t,logger:r,onSubmitSuccess:e,addressFields:i,actions:c(Ha,{onClick:()=>{u("query")}})});case"manual":return c(Ka,{logger:r,input:t,onSubmitSuccess:e,addressFields:{},actions:l?c(Ha,{onClick:()=>{u("query")}}):void 0})}},Qf=({input:t,onSkip:e,suggestions:r,onAddressSelect:n,query:i,onAddressSearch:a,error:o})=>{const{t:s}=et(),l=ht(null);return ft(()=>{l.current&&(l.current.focus(),l.current.select())},[]),c(J,{children:[c("form",{noValidate:!0,onSubmit:h=>{h.preventDefault();const u=new FormData(h.currentTarget).get("address");typeof u=="string"&&a(u)},class:"flex gap-1 p-2.5",children:[c("div",{class:"group relative flex-1",children:[c("input",{ref:l,name:"address",id:"chat-address",autocomplete:"address-line1 country-name postal-code",autoFocus:!0,placeholder:t.config.placeholder||s("address_search"),defaultValue:i,class:Le({optional:!!t.config.optional,className:"w-full rounded-full"})}),c("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:c("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c("g",{id:"inploi",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",strokeWidth:"1.5",children:[c("circle",{cx:"7",cy:"7",r:"4"}),c("path",{d:"M10 10L13 13"})]}),c("span",{class:"sr-only",children:s("search")})]})})]}),t.config.optional&&c(ee,{class:"",onClick:e})]}),o?c(ge,{error:{message:o}}):null,c("ul",{children:[r.map(h=>c("li",{children:c("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(h.id)},children:[c("span",{class:"flex-grow",children:h.label}),c("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:c("path",{d:"M6 3L11 8L6 13"})})]})},h.id)),c("li",{children:c("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{n("")},children:c("span",{class:"flex-grow",children:s("address_manual")})})},"")]})]})},qa=["line1","line2","line3","city","state","postcode","country"],Ka=({addressFields:t,onSubmitSuccess:e,actions:r,input:n})=>{const i=ht(null);ft(()=>{if(i.current){const s=i.current.querySelector("input");s&&(s.focus(),s.select())}},[]);const a=Object.keys(xn),{t:o}=et();return c("form",{class:"bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",onSubmit:s=>{const l=new FormData(s.currentTarget),h=Object.fromEntries(l.entries());e({type:"address",value:h})},children:[c("div",{class:"bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",ref:i,children:qa.map((s,l)=>{const h=`isdk_${s}`,p=n.config.keys[s];return p?c(J,{children:[c("label",{for:h,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(s)}),c("div",{class:"flex flex-col items-stretch gap-1.5",children:[s==="country"?c("div",{class:"relative",children:[c("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:p,id:h,defaultValue:t[s],required:!0,children:[t.country&&!a.includes(t.country)?c("option",{value:t[s],children:t[s]}):c("option",{value:"",children:o("select_country")}),a.map(u=>c("option",{value:u,children:u},u))]}),c("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:c("path",{d:"M4 6.5L8 10.5L12 6.5"})})]}):c("input",{autoFocus:l===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:p,id:h,defaultValue:t[s],required:!0}),l===qa.length-1?c("hr",{class:"m-0 w-full border-b border-b-transparent"}):c("hr",{class:"border-b-neutral-5 m-0 w-full border-b border-solid"})]})]}):null})}),c("div",{class:"flex w-full flex-1 ",children:[c("div",{class:"flex-grow",children:r}),c(te,{class:"flex items-center justify-center"})]})]})},kn=()=>{const t=ht(null);return _t(()=>{var e;(e=t.current)==null||e.focus()},[]),t},Ga=["true","false"],th=Ma(Ga),eh="answer",Wa="flex items-center gap-2 p-2.5",Ya=zr(({label:t,...e},r)=>c("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",...e,ref:r,children:c("p",{class:"truncate text-center text-base",children:t})})),rh=({input:t,onSubmitSuccess:e})=>{const r=kn();return c("form",{noValidate:!0,class:"",onSubmit:n=>{n.preventDefault();const i=Pd(n).value,a=Oa(th,i);e({type:"boolean",value:a==="true"})},children:[c("ul",{class:Wa,children:Ga.map((n,i)=>c("li",{class:"flex-1",children:c(Ya,{ref:i===0?r:null,type:"submit",name:eh,value:n,label:t.config.labels[n]},n)}))}),t.config.optional&&c("div",{class:"px-2 pb-2",children:c(ee,{class:"w-full",type:"button",onClick:()=>e(null)})})]})},nh=t=>new Promise((e,r)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>n.result?e(n.result.toString()):r("No result from reader"),n.onerror=r}),ih=t=>t.reduce((e,r)=>e+r.sizeKb,0),ah=he("file"),Ja=3,oh=({file:t,class:e,...r})=>{const n=t.name.split(".").pop(),i=t.name.replace(new RegExp(`.${n}$`),"");return c("div",{class:Lt("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",e),...r,children:[c("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[c("span",{class:"block truncate",children:i}),c("span",{children:[".",n]})]}),c("p",{"aria-label":"File size",class:"text-accent-11",children:Te(t.sizeKb)})]})},Za=({class:t,...e})=>c("li",{class:Lt("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",t),...e}),Xa=t=>{const e=t.split(".").pop();if(!e)throw new Error("No file extension found");return e?"."+e:""},sh=({allowedExtensions:t,files:e})=>{const r=t.map(n=>n.toLowerCase());return e.every(n=>r.includes(Xa(n.name).toLowerCase()))},lh=(t,e)=>{const r=Xa(t);return`${t.replace(new RegExp(`${r}$`),"").slice(0,e)}${r}`},ch=({input:t,onSubmitSuccess:e})=>{var u;const r=(u=I.current$.value.flow)==null?void 0:u.data.submissions[t.key],[n,i]=vt(ah(r)?r.value:[]),[a,o]=vt(),s=n.length-Ja,l=ih(n),h=kn(),{t:p}=et();return c("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:f=>(f.preventDefault(),o(void 0),n.length===0?o({type:"required",message:p("validation_file")}):t.config.extensions.length>0&&!sh({allowedExtensions:t.config.extensions,files:n})?o({type:"validate",message:`${p("validation_file_ext",{ext:t.config.extensions.join(", ")})}`}):t.config.fileSizeLimitKib&&l>t.config.fileSizeLimitKib?o({type:"max",message:`File size exceeds limit of ${Te(t.config.fileSizeLimitKib)}`}):t.config.allowMultiple===!1&&n.length>1?o({type:"invalid",message:p("validation_file_max",{count:1})}):e({type:"file",value:n})),children:[c("div",{class:"flex items-center gap-2",children:[c("label",{ref:h,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?c(J,{children:[c("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[n.slice(0,Ja).map(f=>{const b=f.name.split(".").pop(),v=f.name.replace(new RegExp(`.${b}$`),"");return c(Za,{class:"flex overflow-hidden",children:[c("span",{class:"block truncate",children:v}),c("span",{children:[".",b]})]})}),s>0?c(Za,{children:["+",s," file",s!==1?"s":""]}):null]}),c("p",{class:"text-neutral-11 text-xs",children:[Te(l)," ",n.length>1?"total":""]})]}):c("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[c("header",{class:"flex flex-col items-center gap-0",children:[c("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:c("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"})}),c("p",{class:"text-neutral-12 tracking-[-0.01em]",children:p("upload_file",{count:t.config.allowMultiple?2:1})}),t.config.fileSizeLimitKib?c("p",{class:"text-neutral-10 text-xs",children:["(",p("file_max_size",{size:Te(t.config.fileSizeLimitKib)}),")"]}):null]}),c("aside",{class:"flex flex-col items-center gap-2",children:[c("p",{id:"accepted-filetypes",class:"sr-only",children:p("file_extensions")}),c("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:t.config.extensions.map(f=>c("li",{class:"ring-lowest outline-neutral-6 text-neutral-9 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",children:f.replace(".","")}))})]})]}),c("input",{id:"dropzone-file",onInput:async f=>{yt(f.target instanceof HTMLInputElement);const b=f.target.files?Array.from(f.target.files):[],v=await Promise.allSettled(b.map(async S=>{const x=await nh(S);return{name:lh(S.name,42),data:x,sizeKb:S.size/1e3}}));if(v.some(({status:S})=>S==="rejected"))return o({type:"invalid",message:"Invalid file"});const y=v.map(S=>S.status==="fulfilled"?S.value:null).filter(Boolean);i(y)},multiple:t.config.allowMultiple,type:"file",class:"sr-only"})]}),c("div",{class:"flex h-full flex-col items-center gap-2",children:[c(te,{disabled:n.length===0}),t.config.optional&&c(ee,{onClick:()=>e(null)})]})]}),c(ge,{error:a})]})};var Ve=t=>t.type==="checkbox",ve=t=>t instanceof Date,at=t=>t==null;const Qa=t=>typeof t=="object";var Y=t=>!at(t)&&!Array.isArray(t)&&Qa(t)&&!ve(t),uh=t=>Y(t)&&t.target?Ve(t.target)?t.target.checked:t.target.value:t,dh=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,fh=(t,e)=>t.has(dh(e)),hh=t=>{const e=t.constructor&&t.constructor.prototype;return Y(e)&&e.hasOwnProperty("isPrototypeOf")},Sn=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Pt(t){let e;const r=Array.isArray(t);if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set(t);else if(!(Sn&&(t instanceof Blob||t instanceof FileList))&&(r||Y(t)))if(e=r?[]:{},!r&&!hh(t))e=t;else for(const n in t)t.hasOwnProperty(n)&&(e[n]=Pt(t[n]));else return t;return e}var je=t=>Array.isArray(t)?t.filter(Boolean):[],U=t=>t===void 0,$=(t,e,r)=>{if(!e||!Y(t))return r;const n=je(e.split(/[,[\].]+?/)).reduce((i,a)=>at(i)?i:i[a],t);return U(n)||n===t?U(t[e])?r:t[e]:n},qt=t=>typeof t=="boolean";const to={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},kt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Dt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};St.createContext(null);var ph=(t,e,r,n=!0)=>{const i={defaultValues:e._defaultValues};for(const a in t)Object.defineProperty(i,a,{get:()=>{const o=a;return e._proxyFormState[o]!==kt.all&&(e._proxyFormState[o]=!n||kt.all),r&&(r[o]=!0),t[o]}});return i},bt=t=>Y(t)&&!Object.keys(t).length,gh=(t,e,r,n)=>{r(t);const{name:i,...a}=t;return bt(a)||Object.keys(a).length>=Object.keys(e).length||Object.keys(a).find(o=>e[o]===(!n||kt.all))},Cn=t=>Array.isArray(t)?t:[t];function vh(t){const e=St.useRef(t);e.current=t,St.useEffect(()=>{const r=!t.disabled&&e.current.subject&&e.current.subject.subscribe({next:e.current.next});return()=>{r&&r.unsubscribe()}},[t.disabled])}var It=t=>typeof t=="string",bh=(t,e,r,n,i)=>It(t)?(n&&e.watch.add(t),$(r,t,i)):Array.isArray(t)?t.map(a=>(n&&e.watch.add(a),$(r,a))):(n&&(e.watchAll=!0),r),$n=t=>/^\w*$/.test(t),eo=t=>je(t.replace(/["|']|\]/g,"").split(/\.|\[/));function V(t,e,r){let n=-1;const i=$n(e)?[e]:eo(e),a=i.length,o=a-1;for(;++n<a;){const s=i[n];let l=r;if(n!==o){const h=t[s];l=Y(h)||Array.isArray(h)?h:isNaN(+i[n+1])?{}:[]}t[s]=l,t=t[s]}return t}var ro=(t,e,r,n,i)=>e?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:i||!0}}:{},no=t=>({isOnSubmit:!t||t===kt.onSubmit,isOnBlur:t===kt.onBlur,isOnChange:t===kt.onChange,isOnAll:t===kt.all,isOnTouch:t===kt.onTouched}),io=(t,e,r)=>!r&&(e.watchAll||e.watch.has(t)||[...e.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const hr=(t,e,r,n)=>{for(const i of r||Object.keys(t)){const a=$(t,i);if(a){const{_f:o,...s}=a;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],i)&&!n)break;if(o.ref&&e(o.ref,o.name)&&!n)break}else Y(s)&&hr(s,e)}}};var wh=(t,e,r)=>{const n=je($(t,r));return V(n,"root",e[r]),V(t,r,n),t},En=t=>t.type==="file",Kt=t=>typeof t=="function",pr=t=>{if(!Sn)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},gr=t=>It(t),In=t=>t.type==="radio",vr=t=>t instanceof RegExp;const ao={value:!1,isValid:!1},oo={value:!0,isValid:!0};var so=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!U(t[0].attributes.value)?U(t[0].value)||t[0].value===""?oo:{value:t[0].value,isValid:!0}:oo:ao}return ao};const lo={isValid:!1,value:null};var co=t=>Array.isArray(t)?t.reduce((e,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:e,lo):lo;function uo(t,e,r="validate"){if(gr(t)||Array.isArray(t)&&t.every(gr)||qt(t)&&!t)return{type:r,message:gr(t)?t:"",ref:e}}var be=t=>Y(t)&&!vr(t)?t:{value:t,message:""},fo=async(t,e,r,n,i)=>{const{ref:a,refs:o,required:s,maxLength:l,minLength:h,min:p,max:u,pattern:f,validate:b,name:v,valueAsNumber:y,mount:S,disabled:x}=t._f,m=$(e,v);if(!S||x)return{};const A=o?o[0]:a,N=D=>{n&&A.reportValidity&&(A.setCustomValidity(qt(D)?"":D||""),A.reportValidity())},M={},H=In(a),it=Ve(a),gt=H||it,L=(y||En(a))&&U(a.value)&&U(m)||pr(a)&&a.value===""||m===""||Array.isArray(m)&&!m.length,ct=ro.bind(null,v,r,M),ot=(D,O,q,ut=Dt.maxLength,wt=Dt.minLength)=>{const Tt=D?O:q;M[v]={type:D?ut:wt,message:Tt,ref:a,...ct(D?ut:wt,Tt)}};if(i?!Array.isArray(m)||!m.length:s&&(!gt&&(L||at(m))||qt(m)&&!m||it&&!so(o).isValid||H&&!co(o).isValid)){const{value:D,message:O}=gr(s)?{value:!!s,message:s}:be(s);if(D&&(M[v]={type:Dt.required,message:O,ref:A,...ct(Dt.required,O)},!r))return N(O),M}if(!L&&(!at(p)||!at(u))){let D,O;const q=be(u),ut=be(p);if(!at(m)&&!isNaN(m)){const wt=a.valueAsNumber||m&&+m;at(q.value)||(D=wt>q.value),at(ut.value)||(O=wt<ut.value)}else{const wt=a.valueAsDate||new Date(m),Tt=yr=>new Date(new Date().toDateString()+" "+yr),ne=a.type=="time",Be=a.type=="week";It(q.value)&&m&&(D=ne?Tt(m)>Tt(q.value):Be?m>q.value:wt>new Date(q.value)),It(ut.value)&&m&&(O=ne?Tt(m)<Tt(ut.value):Be?m<ut.value:wt<new Date(ut.value))}if((D||O)&&(ot(!!D,q.message,ut.message,Dt.max,Dt.min),!r))return N(M[v].message),M}if((l||h)&&!L&&(It(m)||i&&Array.isArray(m))){const D=be(l),O=be(h),q=!at(D.value)&&m.length>+D.value,ut=!at(O.value)&&m.length<+O.value;if((q||ut)&&(ot(q,D.message,O.message),!r))return N(M[v].message),M}if(f&&!L&&It(m)){const{value:D,message:O}=be(f);if(vr(D)&&!m.match(D)&&(M[v]={type:Dt.pattern,message:O,ref:a,...ct(Dt.pattern,O)},!r))return N(O),M}if(b){if(Kt(b)){const D=await b(m,e),O=uo(D,A);if(O&&(M[v]={...O,...ct(Dt.validate,O.message)},!r))return N(O.message),M}else if(Y(b)){let D={};for(const O in b){if(!bt(D)&&!r)break;const q=uo(await b[O](m,e),A,O);q&&(D={...q,...ct(O,q.message)},N(q.message),r&&(M[v]=D))}if(!bt(D)&&(M[v]={ref:A,...D},!r))return M}}return N(!0),M};function mh(t,e){const r=e.slice(0,-1).length;let n=0;for(;n<r;)t=U(t)?n++:t[e[n++]];return t}function _h(t){for(const e in t)if(t.hasOwnProperty(e)&&!U(t[e]))return!1;return!0}function Q(t,e){const r=Array.isArray(e)?e:$n(e)?[e]:eo(e),n=r.length===1?t:mh(t,r),i=r.length-1,a=r[i];return n&&delete n[a],i!==0&&(Y(n)&&bt(n)||Array.isArray(n)&&_h(n))&&Q(t,r.slice(0,-1)),t}function Tn(){let t=[];return{get observers(){return t},next:i=>{for(const a of t)a.next&&a.next(i)},subscribe:i=>(t.push(i),{unsubscribe:()=>{t=t.filter(a=>a!==i)}}),unsubscribe:()=>{t=[]}}}var br=t=>at(t)||!Qa(t);function re(t,e){if(br(t)||br(e))return t===e;if(ve(t)&&ve(e))return t.getTime()===e.getTime();const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const i of r){const a=t[i];if(!n.includes(i))return!1;if(i!=="ref"){const o=e[i];if(ve(a)&&ve(o)||Y(a)&&Y(o)||Array.isArray(a)&&Array.isArray(o)?!re(a,o):a!==o)return!1}}return!0}var ho=t=>t.type==="select-multiple",yh=t=>In(t)||Ve(t),An=t=>pr(t)&&t.isConnected,po=t=>{for(const e in t)if(Kt(t[e]))return!0;return!1};function wr(t,e={}){const r=Array.isArray(t);if(Y(t)||r)for(const n in t)Array.isArray(t[n])||Y(t[n])&&!po(t[n])?(e[n]=Array.isArray(t[n])?[]:{},wr(t[n],e[n])):at(t[n])||(e[n]=!0);return e}function go(t,e,r){const n=Array.isArray(t);if(Y(t)||n)for(const i in t)Array.isArray(t[i])||Y(t[i])&&!po(t[i])?U(e)||br(r[i])?r[i]=Array.isArray(t[i])?wr(t[i],[]):{...wr(t[i])}:go(t[i],at(e)?{}:e[i],r[i]):r[i]=!re(t[i],e[i]);return r}var Mn=(t,e)=>go(t,e,wr(e)),vo=(t,{valueAsNumber:e,valueAsDate:r,setValueAs:n})=>U(t)?t:e?t===""?NaN:t&&+t:r&&It(t)?new Date(t):n?n(t):t;function Nn(t){const e=t.ref;if(!(t.refs?t.refs.every(r=>r.disabled):e.disabled))return En(e)?e.files:In(e)?co(t.refs).value:ho(e)?[...e.selectedOptions].map(({value:r})=>r):Ve(e)?so(t.refs).value:vo(U(e.value)?t.ref.value:e.value,t)}var xh=(t,e,r,n)=>{const i={};for(const a of t){const o=$(e,a);o&&V(i,a,o._f)}return{criteriaMode:r,names:[...t],fields:i,shouldUseNativeValidation:n}},ze=t=>U(t)?t:vr(t)?t.source:Y(t)?vr(t.value)?t.value.source:t.value:t,kh=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate);function bo(t,e,r){const n=$(t,r);if(n||$n(r))return{error:n,name:r};const i=r.split(".");for(;i.length;){const a=i.join("."),o=$(e,a),s=$(t,a);if(o&&!Array.isArray(o)&&r!==a)return{name:r};if(s&&s.type)return{name:a,error:s};i.pop()}return{name:r}}var Sh=(t,e,r,n,i)=>i.isOnAll?!1:!r&&i.isOnTouch?!(e||t):(r?n.isOnBlur:i.isOnBlur)?!t:(r?n.isOnChange:i.isOnChange)?t:!0,Ch=(t,e)=>!je($(t,e)).length&&Q(t,e);const $h={mode:kt.onSubmit,reValidateMode:kt.onChange,shouldFocusError:!0};function Eh(t={},e){let r={...$h,...t},n={submitCount:0,isDirty:!1,isLoading:Kt(r.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},i={},a=Y(r.defaultValues)||Y(r.values)?Pt(r.defaultValues||r.values)||{}:{},o=r.shouldUnregister?{}:Pt(a),s={action:!1,mount:!1,watch:!1},l={mount:new Set,unMount:new Set,array:new Set,watch:new Set},h,p=0;const u={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Tn(),array:Tn(),state:Tn()},b=t.resetOptions&&t.resetOptions.keepDirtyValues,v=no(r.mode),y=no(r.reValidateMode),S=r.criteriaMode===kt.all,x=d=>g=>{clearTimeout(p),p=setTimeout(d,g)},m=async d=>{if(u.isValid||d){const g=r.resolver?bt((await L()).errors):await ot(i,!0);g!==n.isValid&&f.state.next({isValid:g})}},A=d=>u.isValidating&&f.state.next({isValidating:d}),N=(d,g=[],w,E,k=!0,_=!0)=>{if(E&&w){if(s.action=!0,_&&Array.isArray($(i,d))){const T=w($(i,d),E.argA,E.argB);k&&V(i,d,T)}if(_&&Array.isArray($(n.errors,d))){const T=w($(n.errors,d),E.argA,E.argB);k&&V(n.errors,d,T),Ch(n.errors,d)}if(u.touchedFields&&_&&Array.isArray($(n.touchedFields,d))){const T=w($(n.touchedFields,d),E.argA,E.argB);k&&V(n.touchedFields,d,T)}u.dirtyFields&&(n.dirtyFields=Mn(a,o)),f.state.next({name:d,isDirty:O(d,g),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else V(o,d,g)},M=(d,g)=>{V(n.errors,d,g),f.state.next({errors:n.errors})},H=(d,g,w,E)=>{const k=$(i,d);if(k){const _=$(o,d,U(w)?$(a,d):w);U(_)||E&&E.defaultChecked||g?V(o,d,g?_:Nn(k._f)):wt(d,_),s.mount&&m()}},it=(d,g,w,E,k)=>{let _=!1,T=!1;const j={name:d};if(!w||E){u.isDirty&&(T=n.isDirty,n.isDirty=j.isDirty=O(),_=T!==j.isDirty);const K=re($(a,d),g);T=$(n.dirtyFields,d),K?Q(n.dirtyFields,d):V(n.dirtyFields,d,!0),j.dirtyFields=n.dirtyFields,_=_||u.dirtyFields&&T!==!K}if(w){const K=$(n.touchedFields,d);K||(V(n.touchedFields,d,w),j.touchedFields=n.touchedFields,_=_||u.touchedFields&&K!==w)}return _&&k&&f.state.next(j),_?j:{}},gt=(d,g,w,E)=>{const k=$(n.errors,d),_=u.isValid&&qt(g)&&n.isValid!==g;if(t.delayError&&w?(h=x(()=>M(d,w)),h(t.delayError)):(clearTimeout(p),h=null,w?V(n.errors,d,w):Q(n.errors,d)),(w?!re(k,w):k)||!bt(E)||_){const T={...E,..._&&qt(g)?{isValid:g}:{},errors:n.errors,name:d};n={...n,...T},f.state.next(T)}A(!1)},L=async d=>r.resolver(o,r.context,xh(d||l.mount,i,r.criteriaMode,r.shouldUseNativeValidation)),ct=async d=>{const{errors:g}=await L(d);if(d)for(const w of d){const E=$(g,w);E?V(n.errors,w,E):Q(n.errors,w)}else n.errors=g;return g},ot=async(d,g,w={valid:!0})=>{for(const E in d){const k=d[E];if(k){const{_f:_,...T}=k;if(_){const j=l.array.has(_.name),K=await fo(k,o,S,r.shouldUseNativeValidation&&!g,j);if(K[_.name]&&(w.valid=!1,g))break;!g&&($(K,_.name)?j?wh(n.errors,K,_.name):V(n.errors,_.name,K[_.name]):Q(n.errors,_.name))}T&&await ot(T,g,w)}}return w.valid},D=()=>{for(const d of l.unMount){const g=$(i,d);g&&(g._f.refs?g._f.refs.every(w=>!An(w)):!An(g._f.ref))&&Fn(d)}l.unMount=new Set},O=(d,g)=>(d&&g&&V(o,d,g),!re(Co(),a)),q=(d,g,w)=>bh(d,l,{...s.mount?o:U(g)?a:It(d)?{[d]:g}:g},w,g),ut=d=>je($(s.mount?o:a,d,t.shouldUnregister?$(a,d,[]):[])),wt=(d,g,w={})=>{const E=$(i,d);let k=g;if(E){const _=E._f;_&&(!_.disabled&&V(o,d,vo(g,_)),k=pr(_.ref)&&at(g)?"":g,ho(_.ref)?[..._.ref.options].forEach(T=>T.selected=k.includes(T.value)):_.refs?Ve(_.ref)?_.refs.length>1?_.refs.forEach(T=>(!T.defaultChecked||!T.disabled)&&(T.checked=Array.isArray(k)?!!k.find(j=>j===T.value):k===T.value)):_.refs[0]&&(_.refs[0].checked=!!k):_.refs.forEach(T=>T.checked=T.value===k):En(_.ref)?_.ref.value="":(_.ref.value=k,_.ref.type||f.values.next({name:d,values:{...o}})))}(w.shouldDirty||w.shouldTouch)&&it(d,k,w.shouldTouch,w.shouldDirty,!0),w.shouldValidate&&On(d)},Tt=(d,g,w)=>{for(const E in g){const k=g[E],_=`${d}.${E}`,T=$(i,_);(l.array.has(d)||!br(k)||T&&!T._f)&&!ve(k)?Tt(_,k,w):wt(_,k,w)}},ne=(d,g,w={})=>{const E=$(i,d),k=l.array.has(d),_=Pt(g);V(o,d,_),k?(f.array.next({name:d,values:{...o}}),(u.isDirty||u.dirtyFields)&&w.shouldDirty&&f.state.next({name:d,dirtyFields:Mn(a,o),isDirty:O(d,_)})):E&&!E._f&&!at(_)?Tt(d,_,w):wt(d,_,w),io(d,l)&&f.state.next({...n}),f.values.next({name:d,values:{...o}}),!s.mount&&e()},Be=async d=>{const g=d.target;let w=g.name,E=!0;const k=$(i,w),_=()=>g.type?Nn(k._f):uh(d),T=j=>{E=Number.isNaN(j)||j===$(o,w,j)};if(k){let j,K;const xr=_(),we=d.type===to.BLUR||d.type===to.FOCUS_OUT,$p=!kh(k._f)&&!r.resolver&&!$(n.errors,w)&&!k._f.deps||Sh(we,$(n.touchedFields,w),n.isSubmitted,y,v),Dn=io(w,l,we);V(o,w,xr),we?(k._f.onBlur&&k._f.onBlur(d),h&&h(0)):k._f.onChange&&k._f.onChange(d);const Ln=it(w,xr,we,!1),Ep=!bt(Ln)||Dn;if(!we&&f.values.next({name:w,type:d.type,values:{...o}}),$p)return u.isValid&&m(),Ep&&f.state.next({name:w,...Dn?{}:Ln});if(!we&&Dn&&f.state.next({...n}),A(!0),r.resolver){const{errors:Oo}=await L([w]);if(T(xr),E){const Ip=bo(n.errors,i,w),Fo=bo(Oo,i,Ip.name||w);j=Fo.error,w=Fo.name,K=bt(Oo)}}else j=(await fo(k,o,S,r.shouldUseNativeValidation))[w],T(xr),E&&(j?K=!1:u.isValid&&(K=await ot(i,!0)));E&&(k._f.deps&&On(k._f.deps),gt(w,K,j,Ln))}},yr=(d,g)=>{if($(n.errors,g)&&d.focus)return d.focus(),1},On=async(d,g={})=>{let w,E;const k=Cn(d);if(A(!0),r.resolver){const _=await ct(U(d)?d:k);w=bt(_),E=d?!k.some(T=>$(_,T)):w}else d?(E=(await Promise.all(k.map(async _=>{const T=$(i,_);return await ot(T&&T._f?{[_]:T}:T)}))).every(Boolean),!(!E&&!n.isValid)&&m()):E=w=await ot(i);return f.state.next({...!It(d)||u.isValid&&w!==n.isValid?{}:{name:d},...r.resolver||!d?{isValid:w}:{},errors:n.errors,isValidating:!1}),g.shouldFocus&&!E&&hr(i,yr,d?k:l.mount),E},Co=d=>{const g={...a,...s.mount?o:{}};return U(d)?g:It(d)?$(g,d):d.map(w=>$(g,w))},$o=(d,g)=>({invalid:!!$((g||n).errors,d),isDirty:!!$((g||n).dirtyFields,d),isTouched:!!$((g||n).touchedFields,d),error:$((g||n).errors,d)}),xp=d=>{d&&Cn(d).forEach(g=>Q(n.errors,g)),f.state.next({errors:d?n.errors:{}})},Eo=(d,g,w)=>{const E=($(i,d,{_f:{}})._f||{}).ref;V(n.errors,d,{...g,ref:E}),f.state.next({name:d,errors:n.errors,isValid:!1}),w&&w.shouldFocus&&E&&E.focus&&E.focus()},kp=(d,g)=>Kt(d)?f.values.subscribe({next:w=>d(q(void 0,g),w)}):q(d,g,!0),Fn=(d,g={})=>{for(const w of d?Cn(d):l.mount)l.mount.delete(w),l.array.delete(w),g.keepValue||(Q(i,w),Q(o,w)),!g.keepError&&Q(n.errors,w),!g.keepDirty&&Q(n.dirtyFields,w),!g.keepTouched&&Q(n.touchedFields,w),!r.shouldUnregister&&!g.keepDefaultValue&&Q(a,w);f.values.next({values:{...o}}),f.state.next({...n,...g.keepDirty?{isDirty:O()}:{}}),!g.keepIsValid&&m()},Io=({disabled:d,name:g,field:w,fields:E,value:k})=>{if(qt(d)){const _=d?void 0:U(k)?Nn(w?w._f:$(E,g)._f):k;V(o,g,_),it(g,_,!1,!1,!0)}},Pn=(d,g={})=>{let w=$(i,d);const E=qt(g.disabled);return V(i,d,{...w||{},_f:{...w&&w._f?w._f:{ref:{name:d}},name:d,mount:!0,...g}}),l.mount.add(d),w?Io({field:w,disabled:g.disabled,name:d}):H(d,!0,g.value),{...E?{disabled:g.disabled}:{},...r.progressive?{required:!!g.required,min:ze(g.min),max:ze(g.max),minLength:ze(g.minLength),maxLength:ze(g.maxLength),pattern:ze(g.pattern)}:{},name:d,onChange:Be,onBlur:Be,ref:k=>{if(k){Pn(d,g),w=$(i,d);const _=U(k.value)&&k.querySelectorAll&&k.querySelectorAll("input,select,textarea")[0]||k,T=yh(_),j=w._f.refs||[];if(T?j.find(K=>K===_):_===w._f.ref)return;V(i,d,{_f:{...w._f,...T?{refs:[...j.filter(An),_,...Array.isArray($(a,d))?[{}]:[]],ref:{type:_.type,name:d}}:{ref:_}}}),H(d,!1,void 0,_)}else w=$(i,d,{}),w._f&&(w._f.mount=!1),(r.shouldUnregister||g.shouldUnregister)&&!(fh(l.array,d)&&s.action)&&l.unMount.add(d)}}},To=()=>r.shouldFocusError&&hr(i,yr,l.mount),Sp=d=>{qt(d)&&(f.state.next({disabled:d}),hr(i,g=>{g.disabled=d},0,!1))},Ao=(d,g)=>async w=>{w&&(w.preventDefault&&w.preventDefault(),w.persist&&w.persist());let E=Pt(o);if(f.state.next({isSubmitting:!0}),r.resolver){const{errors:k,values:_}=await L();n.errors=k,E=_}else await ot(i);Q(n.errors,"root"),bt(n.errors)?(f.state.next({errors:{}}),await d(E,w)):(g&&await g({...n.errors},w),To(),setTimeout(To)),f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:bt(n.errors),submitCount:n.submitCount+1,errors:n.errors})},Cp=(d,g={})=>{$(i,d)&&(U(g.defaultValue)?ne(d,$(a,d)):(ne(d,g.defaultValue),V(a,d,g.defaultValue)),g.keepTouched||Q(n.touchedFields,d),g.keepDirty||(Q(n.dirtyFields,d),n.isDirty=g.defaultValue?O(d,$(a,d)):O()),g.keepError||(Q(n.errors,d),u.isValid&&m()),f.state.next({...n}))},Mo=(d,g={})=>{const w=d?Pt(d):a,E=Pt(w),k=d&&!bt(d)?E:a;if(g.keepDefaultValues||(a=w),!g.keepValues){if(g.keepDirtyValues||b)for(const _ of l.mount)$(n.dirtyFields,_)?V(k,_,$(o,_)):ne(_,$(k,_));else{if(Sn&&U(d))for(const _ of l.mount){const T=$(i,_);if(T&&T._f){const j=Array.isArray(T._f.refs)?T._f.refs[0]:T._f.ref;if(pr(j)){const K=j.closest("form");if(K){K.reset();break}}}}i={}}o=t.shouldUnregister?g.keepDefaultValues?Pt(a):{}:Pt(k),f.array.next({values:{...k}}),f.values.next({values:{...k}})}l={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!s.mount&&e(),s.mount=!u.isValid||!!g.keepIsValid,s.watch=!!t.shouldUnregister,f.state.next({submitCount:g.keepSubmitCount?n.submitCount:0,isDirty:g.keepDirty?n.isDirty:!!(g.keepDefaultValues&&!re(d,a)),isSubmitted:g.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:g.keepDirtyValues?n.dirtyFields:g.keepDefaultValues&&d?Mn(a,d):{},touchedFields:g.keepTouched?n.touchedFields:{},errors:g.keepErrors?n.errors:{},isSubmitSuccessful:g.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},No=(d,g)=>Mo(Kt(d)?d(o):d,g);return{control:{register:Pn,unregister:Fn,getFieldState:$o,handleSubmit:Ao,setError:Eo,_executeSchema:L,_getWatch:q,_getDirty:O,_updateValid:m,_removeUnmounted:D,_updateFieldArray:N,_updateDisabledField:Io,_getFieldArray:ut,_reset:Mo,_resetDefaultValues:()=>Kt(r.defaultValues)&&r.defaultValues().then(d=>{No(d,r.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:d=>{n={...n,...d}},_disableForm:Sp,_subjects:f,_proxyFormState:u,get _fields(){return i},get _formValues(){return o},get _state(){return s},set _state(d){s=d},get _defaultValues(){return a},get _names(){return l},set _names(d){l=d},get _formState(){return n},set _formState(d){n=d},get _options(){return r},set _options(d){r={...r,...d}}},trigger:On,register:Pn,handleSubmit:Ao,watch:kp,setValue:ne,getValues:Co,reset:No,resetField:Cp,clearErrors:xp,unregister:Fn,setError:Eo,setFocus:(d,g={})=>{const w=$(i,d),E=w&&w._f;if(E){const k=E.refs?E.refs[0]:E.ref;k.focus&&(k.focus(),g.shouldSelect&&k.select())}},getFieldState:$o}}function mr(t={}){const e=St.useRef(),r=St.useRef(),[n,i]=St.useState({isDirty:!1,isValidating:!1,isLoading:Kt(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:Kt(t.defaultValues)?void 0:t.defaultValues});e.current||(e.current={...Eh(t,()=>i(o=>({...o}))),formState:n});const a=e.current.control;return a._options=t,vh({subject:a._subjects.state,next:o=>{gh(o,a._proxyFormState,a._updateFormState,!0)&&i({...a._formState})}}),St.useEffect(()=>a._disableForm(t.disabled),[a,t.disabled]),St.useEffect(()=>{if(a._proxyFormState.isDirty){const o=a._getDirty();o!==n.isDirty&&a._subjects.state.next({isDirty:o})}},[a,n.isDirty]),St.useEffect(()=>{t.values&&!re(t.values,r.current)?(a._reset(t.values,a._options.resetOptions),r.current=t.values):a._resetDefaultValues()},[t.values,a]),St.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()}),e.current.formState=ph(n,a),e.current}var wo=function(t,e,r){if(t&&"reportValidity"in t){var n=$(r,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},Ih=function(t,e){var r=function(i){var a=e.fields[i];a&&a.ref&&"reportValidity"in a.ref?wo(a.ref,i,t):a.refs&&a.refs.forEach(function(o){return wo(o,i,t)})};for(var n in e.fields)r(n)},Th=function(t,e){e.shouldUseNativeValidation&&Ih(t,e);var r={};for(var n in t){var i=$(e.fields,n),a=Object.assign(t[n]||{},{ref:i&&i.ref});if(Mh(e.names||Object.keys(t),n)){var o=Object.assign({},Ah($(r,n)));V(o,"root",a),V(r,n,o)}else V(r,n,a)}return r},Ah=function(t){return Array.isArray(t)?t.filter(Boolean):[]},Mh=function(t,e){return t.some(function(r){return r.startsWith(e+".")})},Nh=function(t,e){for(var r={};t.issues.length;){var n=t.issues[0];if(n.path){var i=n.path.map(function(s){return s.key}).join(".");if(r[i]||(r[i]={message:n.message,type:n.validation}),e){var a=r[i].types,o=a&&a[n.validation];r[i]=ro(i,e,r,n.validation,o?[].concat(o,n.message):n.message)}t.issues.shift()}}return r},_r=function(t,e,r){return r===void 0&&(r={}),function(n,i,a){try{return Promise.resolve(function(o,s){try{var l=function(){function h(u){return{values:r.raw?n:u,errors:{}}}var p=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},e);return r.mode==="sync"?h(Oa(t,n,p)):Promise.resolve(tf(t,n,p)).then(h)}()}catch(h){return s(h)}return l&&l.then?l.then(void 0,s):l}(0,function(o){if(o instanceof cn)return{values:{},errors:Th(Nh(o,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw o}))}catch(o){return Promise.reject(o)}}};const mo=27,_o=12,yo=10,Oh=he("enum"),Fh=(t,e)=>{const r={min:t.minSelected??0,max:t.maxSelected??t.options.length};return _r(rt({checked:Ht(hn(W(),ur()),cr(n=>Object.entries(n).filter(([i,a])=>a).map(([i,a])=>i)),Oe(r.max,e("validation_multiple_choice_max",{count:r.max})),pe(r.min,e("validation_multiple_choice_min",{count:r.min})))}))},Ph=zr(({option:t,...e},r)=>c(J,{children:[c("input",{class:"peer sr-only h-full",type:"checkbox",...e,ref:r}),c("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:e.id,children:t.label})]})),xo=Wt("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:Wa}}}),Dh=({input:t,onSubmitSuccess:e})=>{var p,u;const r=t.key?(p=I.current$.value.flow)==null?void 0:p.data.submissions[t.key]:void 0,n=(t.config.minSelected===1||t.config.minSelected===void 0)&&t.config.maxSelected===1,i=n&&t.config.options.length===2,{t:a}=et(),{register:o,handleSubmit:s,formState:{errors:l}}=mr({defaultValues:{checked:n?{}:Oh(r)?Object.fromEntries(r.value.map(f=>[f,!0])):{}},resolver:Fh(t.config,a)}),h=kn();return i?c("ul",{style:{maxHeight:6.5*mo+5*_o+2*yo},class:xo({variant:"booleanLike"}),children:t.config.options.map((f,b)=>c("li",{class:"flex-1",children:c(Ya,{type:"submit",ref:v=>{v&&b===0&&(h.current=v)},label:f.label,value:"true",onClick:()=>e({type:"enum",value:[f.value]})})},f.value))}):c("form",{noValidate:!0,onSubmit:f=>s(b=>{const v=b.checked;e({type:"enum",value:v})})(f),children:[c("div",{class:"flex items-center gap-1",children:[c("ul",{style:{maxHeight:6.5*mo+5*_o+2*yo},class:xo({variant:t.config.options.length===1?"singleOption":void 0}),children:t.config.options.map((f,b)=>{const v=`checked.${f.value}`,{ref:y,...S}=o(v);return c("li",{class:"relative",children:c(Ph,{option:f,autoFocus:b===0,ref:x=>{x&&b===0&&(h.current=x),y(x)},id:v,...S,onClick:n?()=>e({type:"enum",value:[f.value]}):void 0})},f.value)})}),c("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[n?null:c(te,{}),t.config.minSelected===0&&c(ee,{type:"button",onClick:()=>e({type:"enum",value:[]})})]})]}),c("div",{class:"px-1",children:c(ge,{error:(u=l.checked)==null?void 0:u.root})})]})},Lh=he("number"),Vh=(t,e)=>{const r=t.min??Number.MIN_SAFE_INTEGER,n=t.max??Number.MAX_SAFE_INTEGER,i=t.decimalCases??0;return _r(rt({number:Ht(Fe(e("validation_number")),$a(r,e("validation_number_min",{min:r})),Ca(n,e("validation_number_max",{max:n})),ka(a=>a===Number(a.toFixed(i)),e("validation_number_decimal_cases",{count:i})))}))},jh=({input:t,onSubmitSuccess:e})=>{var u;const r=t.config.defaultValue,n=t.key?(u=I.current$.value.flow)==null?void 0:u.data.submissions[t.key]:void 0,{t:i}=et(),{register:a,handleSubmit:o,formState:{errors:s}}=mr({defaultValues:{number:r?Number(r):Lh(n)?n.value:void 0},resolver:Vh(t.config,i)}),{ref:l,...h}=a("number",{required:!t.config.optional,valueAsNumber:!0}),p=ht();return ft(()=>{p.current&&(p.current.focus(),p.current.select())},[]),c("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:o(f=>{f.number!==void 0&&e({type:"number",value:f.number})}),children:[c("div",{class:"flex items-center gap-2",children:[c("div",{class:"relative min-w-0 flex-grow",children:[c("input",{...h,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:f=>{f&&(p.current=f),l(f)},type:"text",min:t.config.min,max:t.config.max,class:Le({optional:t.config.optional,className:"[type=number:-webkit-inner-spin-button] w-full rounded-full [-webkit-outer-spin-button:none]"}),placeholder:t.config.placeholder}),t.config.optional&&c(ee,{class:"absolute right-0 top-0",onClick:()=>e(null)})]}),c(te,{})]}),c(ge,{error:s.number})]})},zh=t=>{if(t==="")return{countryCode:"",phoneNumber:""};const e=Object.entries(xn).find(i=>t.startsWith(i[1])),r=e?e[1]:"",n=t.replace(r,"");return/^\d+$/.test(n)?{countryCode:r,phoneNumber:n}:{countryCode:"",phoneNumber:""}},Rh="44",Bh=/^[0-9 ]+$/,Uh=he("string"),Hh=he("phone"),qh=t=>{const e=Ht(W(t("validation_country_code")),Ea(Bh,t("validation_country_code"))),r=Ht(W(t("validation_phone")),pe(1,t("validation_phone")),cr(n=>n.replace(/[^0-9]/g,"")));return _r(rt({countryCode:e,phoneNumber:r}))},Kh=({input:t,onSubmitSuccess:e})=>{var y;const r=t.key?(y=I.current$.value.flow)==null?void 0:y.data.submissions[t.key]:void 0,{t:n}=et(),[i,a]=vt(),o=Uh(r)?zh(r.value):Hh(r)?r.value:void 0,{register:s,handleSubmit:l,formState:{errors:h},watch:p}=mr({defaultValues:{countryCode:(o==null?void 0:o.countryCode)??t.config.defaultValue.countryCode??Rh,phoneNumber:(o==null?void 0:o.phoneNumber)??t.config.defaultValue.phoneNumber??""},resolver:qh(n)}),{ref:u,...f}=s("phoneNumber",{required:!t.config.optional}),b=ht(),v=p("countryCode");return ft(()=>{b.current&&(b.current.focus(),b.current.select())},[]),c("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:l(S=>{const x=S.phoneNumber.replace(/[^0-9]/g,""),m=S.countryCode.replace(/[^0-9]/g,"");a(void 0);const A=t.config.minChars??7;if(x.length+m.length<A)return a(n("validation_phone_min_chars",{count:A}));t.config.submissionFormat==="phone"?e({type:"phone",value:{countryCode:m,phoneNumber:x}}):e({type:"string",value:v+S.phoneNumber})}),children:[c("div",{class:"flex items-center gap-2",children:[c("div",{class:"relative flex min-w-0 flex-1 flex-grow gap-2",children:[c("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_${t.key}`,children:[c("span",{children:["+",v]}),c("select",{...s("countryCode",{}),id:`isdk_phone_${t.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(xn).map(([S,x])=>c("option",{value:x,children:[S," (+",x,")"]},S))})]}),c("input",{...f,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:S=>{S&&(b.current=S),u(S)},class:Le({optional:t.config.optional,className:"min-w-0 flex-1 rounded-r-full"}),placeholder:t.config.placeholder}),t.config.optional&&c(ee,{class:"absolute bottom-0 right-0 top-0",onClick:()=>e(null)})]}),c(te,{})]}),c(ge,{error:h.countryCode||h.phoneNumber||{message:i}})]})},Gh=({input:t,onSubmitSuccess:e})=>c("div",{class:"flex flex-col items-center py-3",children:c("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:t.key,onClick:()=>{e(null)},children:c("span",{class:"flex items-center gap-1.5",children:[c("span",{class:"inline-flex items-center text-sm font-medium",children:t.config.label||"Submit"}),c("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:[c("path",{d:"M4 8L8 4L12 8"}),c("path",{d:"M8 4V13"})]})]})})}),Wh={email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},Yh=he("string"),Jh=(t,e)=>{const r={maxLength:e("validation_max_chars",{count:t.maxChars??999}),minLength:e("validation_min_chars",{count:t.minChars??1})};return _r(rt({text:{email:Ht(W(e("validation_email")),Sa(e("validation_email")),pe(t.minChars??1,r.minLength),Oe(t.maxChars??1/0,r.maxLength)),text:Ht(W(),pe(t.minChars??1,r.minLength),Oe(t.maxChars??1/0,r.maxLength)),url:Ht(W(e("validation_url")),Ia(e("validation_url")),pe(t.minChars??1,r.minLength),Oe(t.maxChars??1/0,r.maxLength))}[t.format]}))},Zh={text:({input:t,onSubmitSuccess:e})=>{var u;const{t:r}=et(),n=t.key?(u=I.current$.value.flow)==null?void 0:u.data.submissions[t.key]:void 0,i=t.config.defaultValue,{register:a,handleSubmit:o,formState:{errors:s}}=mr({defaultValues:{text:i||(Yh(n)?n.value:"")},resolver:Jh(t.config,r)}),{ref:l,...h}=a("text",{required:!t.config.optional}),p=ht();return ft(()=>{p.current&&(p.current.focus(),p.current.select())},[]),c("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:o(f=>{e({type:"string",value:f.text})}),children:[c("div",{class:"flex items-center gap-2",children:[c("div",{class:"relative min-w-0 flex-1",children:[c("input",{id:"chat-input",...h,...Wh[t.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:f=>{f&&(p.current=f),l(f)},placeholder:t.config.placeholder,class:Le({optional:!!t.config.optional,className:"w-full rounded-full"})}),t.config.optional&&c(ee,{class:"absolute right-0 top-0",onClick:()=>e(null)})]}),c(te,{})]}),c(ge,{error:s.text})]})},phone:Kh,"multiple-choice":Dh,boolean:rh,file:ch,submit:Gh,address:Xf,number:jh},Xh=({logger:t})=>{var a;const e=(a=I.current$.value.flow)==null?void 0:a.data.currentInput,[r,n]=zf(),i=ht(null);return I.inputHeight$.value=n.height,_t(()=>{const o=i.current;if(o)return o.addEventListener("transitionstart",nt.scrollToEnd.smooth),o.addEventListener("transitioncancel",nt.scrollToEnd.smooth),o.addEventListener("transitionend",nt.scrollToEnd.smooth),()=>{o.removeEventListener("transitionstart",nt.scrollToEnd.smooth),o.removeEventListener("transitioncancel",nt.scrollToEnd.smooth),o.removeEventListener("transitionend",nt.scrollToEnd.smooth)}},[]),c("div",{ref:i,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:c("div",{ref:r,class:"border-divider flex flex-col justify-end border-t",children:e?(()=>{const o=Zh[e.type];return c(o,{logger:t,onSubmitSuccess:nt.onSubmitSuccessFn$.value,input:e})})():c("div",{class:"flex items-center gap-2 p-2.5",children:[c("input",{"aria-hidden":"true",id:"chat-input",class:Le({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),c(te,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};var Qh=function(t){return t instanceof RegExp},tp=function(e){var r=/[\\^$.*+?()[\]{}|]/g,n=RegExp(r.source);return e&&n.test(e)?e.replace(r,"\\$&"):e},ko=function(t){return typeof t=="string"},ep=function(t){var e=[];return t.forEach(function(r){Array.isArray(r)?e=e.concat(r):e.push(r)}),e};function rp(t,e,r){var n=0,i=0;if(t==="")return t;if(!t||!ko(t))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var a=e;Qh(a)||(a=new RegExp("("+tp(a)+")","gi"));for(var o=t.split(a),s=1,l=o.length;s<l;s+=2){if(o[s]===void 0||o[s-1]===void 0){console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");continue}i=o[s].length,n+=o[s-1].length,o[s]=r(o[s],s,n),n+=i}return o}var np=function(e,r,n){return Array.isArray(e)||(e=[e]),ep(e.map(function(i){return ko(i)?rp(i,r,n):i}))};const Re=kr(np),ip=/(\[[^\]]+\]\([^)]+\))/g,ap=/\[([^\]]+)\]\(([^)]+)\)/,op=/(https?:\/\/[^\s]+)/g,sp=/_(.*?)_/g,lp=/\*\*(.*?)\*\*/g,cp=/\\n|\n/g,So="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",up=t=>{const e=Re(t,ip,(o,s)=>{const[,l,h]=o.match(ap)??[];return h?c("a",{class:So,href:h,children:l??h},h+s):c("span",{children:"INVALID LINK"})}),r=Re(e,op,(o,s)=>c("a",{class:So,href:o,children:o},o+s)),n=Re(r,sp,(o,s)=>c("em",{children:o},o+s)),i=Re(n,lp,(o,s)=>c("strong",{children:o},o+s));return Re(i,cp,(o,s)=>c("br",{},`br-${s}`))},dp=Wt("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"}}),fp=({children:t,className:e,animate:r,side:n,...i})=>c("p",{style:{transformOrigin:n==="left"?"0% 50%":"100% 50%"},class:dp({className:e,side:n,animate:r}),...i,children:t}),hp=({message:t})=>c("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:c("a",{onClick:t.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:t.href,children:[t.text,c("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:c("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"})})]})}),pp=({className:t,...e})=>(_t(()=>{nt.scrollToEnd.smooth()}),c("div",{"aria-hidden":!0,children:nt.isBotTyping$.value===!0?c("div",{"aria-label":"Typing…",class:Lt("flex gap-1 p-4",t),...e,children:Array.from({length:3},(r,n)=>c("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-n*200}ms`}}))}):void 0})),gp={bot:"left",user:"right"},vp=Wt("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]"}}}),bp=({lastSentMessageFooter:t})=>{var r;const e=((r=I.current$.value.flow)==null?void 0:r.data.messages)??[];return _t(()=>{nt.scrollToEnd.smooth()},[e.length]),c("ol",{"aria-label":"Chat messages",class:"mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[e.map((n,i)=>c(J,{children:c("li",{class:"flex",children:Zt(n).with({type:"system"},a=>c("p",{class:vp({variant:a.variant}),children:a.text})).with({type:"text",author:P.union("bot","user")},a=>{const o=a.author==="user"&&!e.slice(i+1).some(h=>h.type==="text"&&h.author==="user"),s=i===e.length-1,l=a.author==="bot"?up(a.text):a.text;return c(J,{children:[o?t:null,c(fp,{animate:s,side:gp[a.author],children:l},i)]})}).with({type:"link"},a=>c(hp,{message:a})).with({type:"image"},a=>c("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=>c(oh,{class:a.author==="bot"?void 0:"ml-auto",file:{name:a.fileName,sizeKb:a.fileSizeKb}})).with({type:"loading"},a=>{const o=e[e.length-1];return!(a===o)||nt.isBotTyping$.value?null:c("div",{class:"flex flex-grow flex-col items-center justify-center",children:c(va,{class:"text-neutral-6 h-8 w-8"})})}).exhaustive()})},i)),c(pp,{},"typing")]})},wp=({logger:t,apiClient:e,analytics:r})=>{const{flow:n}=I.current$.value;yt(n,"Flow is required to exist to show chatbot body");const i=I.viewState$.value,{chatRef:a,chatService:o}=Kf(),{t:s}=et(),[l,h]=vt();return ft(()=>{i==="maximised"&&nt.scrollToEnd.instant()},[i]),ft(()=>{var S,x;const{state:p,flow:u}=I.current$.peek();if(p!=="loaded")throw new Error(s("invalid_state"));let f=u.data.nodeHistory.at(-1);if(nt.scrollToEnd.instant(),I.setInput(void 0),u.data.isFinished)return;f===void 0?(f=da(n.nodes).id,I.setCurrentNodeId(f),r.log({event:"FLOW_START",properties:{flow_id:n.id,flow_version:n.version,flow_session_id:u.data.flowSessionId,flow_build:n.build,job:n.job},customProperties:(S=n.analytics)==null?void 0:S.customProperties})):I.removeMessagesSentByNodeIds([f]);const{interpret:b,abort:v,undo:y}=_f({context:n.context,analytics:{service:r,customProperties:(x=n.analytics)==null?void 0:x.customProperties},apiClient:e,logger:t,flow:n,chatService:o,t:s,getSubmissions:()=>{var m;return(m=I.current$.peek().flow)==null?void 0:m.data.submissions},onInterpret:(m,A)=>{var M;const N=I.current$.peek().flow;yt(N),A&&(N.data.sequence=N.data.sequence+1,r.log({event:"FLOW_NODE",properties:{flow_id:n.id,flow_version:n.version,from_node_id:A.id,flow_build:n.build,to_node_id:m.id,sequence:N.data.sequence,flow_session_id:N.data.flowSessionId,job:n.job},customProperties:(M=n.analytics)==null?void 0:M.customProperties})),I.setCurrentNodeId(m.id)},onFlowEnd:async()=>{var A;I.markAsFinished();const m=I.current$.peek().flow;yt(m),r.log({event:"FLOW_END",properties:{flow_id:n.id,flow_version:n.version,flow_session_id:m.data.flowSessionId,flow_build:n.build,job:n.job},customProperties:(A=n.analytics)==null?void 0:A.customProperties})}});return h(()=>y),b(f),v},[r,e,o,t,n,s]),c(J,{children:[c("div",{ref:a,className:"hide-scrollbars relative flex w-full max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:I.inputHeight$.value},children:c(bp,{lastSentMessageFooter:n.data.isFinished||!l?null:c(_p,{undoFn:l})})}),c(Xh,{logger:t})]})},mp=t=>t.type==="identify"?[]:"key"in t.data&&t.data.key?[t.data.key]:"keys"in t.data?Object.values(t.data.keys).filter(e=>typeof e=="string"):[],_p=({undoFn:t})=>{const{t:e}=et();return c(sr,{onClick:async()=>{const{flow:r}=I.current$.peek();yt(r);const{removed:n}=t(r.data.nodeHistory),i=r.data.nodeHistory.splice(-n);i.length!==0&&(I.removeMessagesSentByNodeIds(i),I.setInput(void 0),i.pop(),i.map(a=>r.nodes.find(o=>o.id===a)).filter(Boolean).flatMap(mp).forEach(a=>delete r.data.submissions[a]),I.current$.value={...I.current$.value})},children:[c("title",{children:e("undo")}),c("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"})]})},yp=Object.freeze(Object.defineProperty({__proto__:null,ChatbotBody:wp},Symbol.toStringTag,{value:"Module"}))})();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as Ke, i as er, k as Te, a as tr, b as le, A as Le, c as Mr, N as Ge, _ as D, d as rr, h as ee, e as re, p as ue, 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 qr, S as Ur, T as Kr, U as Gr, W as Hr, X as Wr } from "./index-
|
|
1
|
+
import { g as Ke, i as er, k as Te, a as tr, b as le, A as Le, c as Mr, N as Ge, _ as D, d as rr, h as ee, e as re, p as ue, 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 qr, S as Ur, T as Kr, U as Gr, W as Hr, X as Wr } from "./index-4da34b43.js";
|
|
2
2
|
import "@inploi/sdk";
|
|
3
3
|
const Lt = ({
|
|
4
4
|
condition: e,
|
|
@@ -3963,7 +3963,7 @@ const Fe = /* @__PURE__ */ rr(Rs), Os = /(\[[^\]]+\]\([^)]+\))/g, Bs = /\[([^\]]
|
|
|
3963
3963
|
logger: e
|
|
3964
3964
|
})]
|
|
3965
3965
|
});
|
|
3966
|
-
}, Xs = (e) => "key" in e.data && e.data.key ? [e.data.key] : "keys" in e.data ? Object.values(e.data.keys).filter((t) => typeof t == "string") : [], Qs = ({
|
|
3966
|
+
}, Xs = (e) => e.type === "identify" ? [] : "key" in e.data && e.data.key ? [e.data.key] : "keys" in e.data ? Object.values(e.data.keys).filter((t) => typeof t == "string") : [], Qs = ({
|
|
3967
3967
|
undoFn: e
|
|
3968
3968
|
}) => {
|
|
3969
3969
|
const {
|