@usefillo/dom 0.6.2 → 0.7.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/README.md +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +60 -5
- package/dist/standalone.global.js +1 -1
- package/dist/styles.css +33 -0
- package/dist/styles.unlayered.css +33 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Or drop it in with a single script tag — the bundle exposes a global `Fillo`:
|
|
|
51
51
|
</script>
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
For tiny feedback widgets, set `settings.submitMode: "auto"` on a select/rating/checkbox/dropdown/linear scale form. The default renderer hides the first submit button, submits after a complete discrete answer, and brings the submit button back if that answer opens a text or upload follow-up. Add `
|
|
54
|
+
For tiny feedback widgets, set `settings.submitMode: "auto"` on a select/rating/checkbox/dropdown/linear scale form. The default renderer hides the first submit button, submits after a complete discrete answer, and brings the submit button back if that answer opens a text or upload follow-up. Add `responseLimit: { by: "browser", onRepeat: "keep" }` for browser-scoped one-response feedback.
|
|
55
55
|
|
|
56
56
|
The default stylesheet follows system dark mode for unthemed embeds. Pass `theme: { colorScheme: "dark" }` or `"light"` when the host surface is known.
|
|
57
57
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field, FieldValue, FormSchema, FilloClient, ResponseData, FormStatus as FormStatus$1, FormPage, Block, CodeForm, FormTheme, FieldKind, FilloError, FormControllerOptions, FormController } from '@usefillo/core';
|
|
1
|
+
import { Field, FieldValue, FormSchema, FilloClient, ResponseData, FormStatus as FormStatus$1, FormPage, Block, FilloRespondent, CodeForm, FormTheme, FieldKind, FilloError, FormControllerOptions, FormController } from '@usefillo/core';
|
|
2
2
|
export { CodeForm, Field, FieldKind, FieldValue, FileValue, FilloClient, FilloClientOptions, FilloError, FormController, FormControllerOptions, FormControllerState, FormSchema, FormTheme, ProvisionWorkspaceResult, ResponseData, createClient, defineForm, provisionWorkspace } from '@usefillo/core';
|
|
3
3
|
|
|
4
4
|
type FormStatus = FormStatus$1 | "loading" | "closed";
|
|
@@ -50,6 +50,12 @@ interface RenderFormOptions {
|
|
|
50
50
|
formId?: string;
|
|
51
51
|
theme?: FormTheme;
|
|
52
52
|
initialData?: ResponseData;
|
|
53
|
+
/**
|
|
54
|
+
* identify(): the host app's account context for the person filling the
|
|
55
|
+
* form ({ id, email?, name?, traits? }). Recorded with the response as an
|
|
56
|
+
* unverified claim. Late-bind with setRespondent() once a session loads.
|
|
57
|
+
*/
|
|
58
|
+
respondent?: FilloRespondent;
|
|
53
59
|
className?: string;
|
|
54
60
|
components?: Partial<Record<FieldKind, FieldRenderer>>;
|
|
55
61
|
customComponents?: Record<string, FieldRenderer>;
|
|
@@ -68,6 +74,13 @@ interface FilloDomForm {
|
|
|
68
74
|
next(): void;
|
|
69
75
|
back(): void;
|
|
70
76
|
submit(): Promise<void>;
|
|
77
|
+
/** Late-bind identify() context once the host session loads. */
|
|
78
|
+
setRespondent(respondent: FilloRespondent | undefined): void;
|
|
79
|
+
/** Persist unsaved saved-progress answers now (settings.saveProgress forms).
|
|
80
|
+
* The renderer already flushes on pagehide/visibility-hidden. */
|
|
81
|
+
flushDraft(): void;
|
|
82
|
+
/** Discard the saved draft and reset to a fresh fill ("Start over"). */
|
|
83
|
+
resetDraft(): void;
|
|
71
84
|
destroy(): void;
|
|
72
85
|
}
|
|
73
86
|
declare function renderForm(target: HTMLElement | string, options: RenderFormOptions): FilloDomForm;
|
package/dist/index.js
CHANGED
|
@@ -1150,19 +1150,49 @@ var DomFormController = class {
|
|
|
1150
1150
|
onSubmitted: this.options.onSubmitted,
|
|
1151
1151
|
getHoneypot: () => this.hpValue,
|
|
1152
1152
|
surface: "default",
|
|
1153
|
-
resolveFormId: this.resolveFormIdFn
|
|
1153
|
+
resolveFormId: this.resolveFormIdFn,
|
|
1154
|
+
respondent: this.options.respondent
|
|
1154
1155
|
});
|
|
1155
1156
|
let lastStatus = this.engine.getState().status;
|
|
1157
|
+
let lastResumed = this.engine.getState().resumedDraft;
|
|
1158
|
+
let lastEditing = this.engine.getState().editingPrevious;
|
|
1156
1159
|
this.engine.subscribe(() => {
|
|
1157
|
-
const
|
|
1158
|
-
if (
|
|
1159
|
-
|
|
1160
|
+
const state = this.engine?.getState();
|
|
1161
|
+
if (!state) return;
|
|
1162
|
+
if (state.status !== lastStatus || state.resumedDraft !== lastResumed || state.editingPrevious !== lastEditing) {
|
|
1163
|
+
lastStatus = state.status;
|
|
1164
|
+
lastResumed = state.resumedDraft;
|
|
1165
|
+
lastEditing = state.editingPrevious;
|
|
1160
1166
|
this.queueRender();
|
|
1161
1167
|
}
|
|
1162
1168
|
});
|
|
1169
|
+
this.teardownDraftFlush();
|
|
1170
|
+
if (normalizedSchema.settings.saveProgress && typeof window !== "undefined") {
|
|
1171
|
+
window.addEventListener("pagehide", this.flushDraftBound);
|
|
1172
|
+
document.addEventListener("visibilitychange", this.visibilityFlushBound);
|
|
1173
|
+
this.draftFlushWired = true;
|
|
1174
|
+
}
|
|
1163
1175
|
this.phase = this.closed ? "closed" : "ready";
|
|
1164
1176
|
this.render();
|
|
1165
1177
|
}
|
|
1178
|
+
draftFlushWired = false;
|
|
1179
|
+
flushDraftBound = () => this.engine?.flushDraft();
|
|
1180
|
+
visibilityFlushBound = () => {
|
|
1181
|
+
if (document.visibilityState === "hidden") this.engine?.flushDraft();
|
|
1182
|
+
};
|
|
1183
|
+
teardownDraftFlush() {
|
|
1184
|
+
if (!this.draftFlushWired || typeof window === "undefined") return;
|
|
1185
|
+
window.removeEventListener("pagehide", this.flushDraftBound);
|
|
1186
|
+
document.removeEventListener("visibilitychange", this.visibilityFlushBound);
|
|
1187
|
+
this.draftFlushWired = false;
|
|
1188
|
+
}
|
|
1189
|
+
flushDraft() {
|
|
1190
|
+
this.engine?.flushDraft();
|
|
1191
|
+
}
|
|
1192
|
+
resetDraft() {
|
|
1193
|
+
this.engine?.resetDraft();
|
|
1194
|
+
this.queueRender();
|
|
1195
|
+
}
|
|
1166
1196
|
setValue(fieldId, value) {
|
|
1167
1197
|
this.setValueInternal(fieldId, value);
|
|
1168
1198
|
}
|
|
@@ -1214,6 +1244,12 @@ var DomFormController = class {
|
|
|
1214
1244
|
this.engine?.setContext({ client });
|
|
1215
1245
|
this.render();
|
|
1216
1246
|
}
|
|
1247
|
+
/** Late-bind identify() context once the host session loads. No re-render
|
|
1248
|
+
* needed — identity changes what's recorded, never what's shown. */
|
|
1249
|
+
setRespondent(respondent) {
|
|
1250
|
+
this.options.respondent = respondent;
|
|
1251
|
+
this.engine?.setContext({ respondent });
|
|
1252
|
+
}
|
|
1217
1253
|
async uploadFiles(field, files) {
|
|
1218
1254
|
if (!this.schema) return;
|
|
1219
1255
|
const maxFiles = field.maxFiles ?? 1;
|
|
@@ -1266,6 +1302,7 @@ var DomFormController = class {
|
|
|
1266
1302
|
}
|
|
1267
1303
|
destroy() {
|
|
1268
1304
|
this.destroyed = true;
|
|
1305
|
+
this.teardownDraftFlush();
|
|
1269
1306
|
this.closeOverlays();
|
|
1270
1307
|
this.target.replaceChildren();
|
|
1271
1308
|
}
|
|
@@ -1435,6 +1472,24 @@ var DomFormController = class {
|
|
|
1435
1472
|
event.preventDefault();
|
|
1436
1473
|
advance();
|
|
1437
1474
|
});
|
|
1475
|
+
const restoreState = this.engine?.getState();
|
|
1476
|
+
if (restoreState?.resumedDraft || restoreState?.editingPrevious) {
|
|
1477
|
+
const resume = el("div", { className: "fillo-resume", attrs: { role: "status" } });
|
|
1478
|
+
resume.appendChild(
|
|
1479
|
+
el("span", {
|
|
1480
|
+
className: "fillo-resume-text",
|
|
1481
|
+
text: restoreState.editingPrevious ? "You're updating your earlier response." : "Picked up where you left off."
|
|
1482
|
+
})
|
|
1483
|
+
);
|
|
1484
|
+
const clear = el("button", {
|
|
1485
|
+
className: "fillo-resume-clear",
|
|
1486
|
+
text: "Start over",
|
|
1487
|
+
attrs: { type: "button" }
|
|
1488
|
+
});
|
|
1489
|
+
clear.addEventListener("click", () => this.resetDraft());
|
|
1490
|
+
resume.appendChild(clear);
|
|
1491
|
+
form.appendChild(resume);
|
|
1492
|
+
}
|
|
1438
1493
|
if (api.pageCount > 1 && this.schema?.settings.showProgress !== false) {
|
|
1439
1494
|
const progress = el("div", {
|
|
1440
1495
|
className: "fillo-progress-track",
|
|
@@ -1454,7 +1509,7 @@ var DomFormController = class {
|
|
|
1454
1509
|
}
|
|
1455
1510
|
if (api.pageIndex === 0) {
|
|
1456
1511
|
const header = el("header", { className: "fillo-header" });
|
|
1457
|
-
header.appendChild(el("h1", { className: "fillo-title", text: api.form.title }));
|
|
1512
|
+
if (api.form.title) header.appendChild(el("h1", { className: "fillo-title", text: api.form.title }));
|
|
1458
1513
|
if (api.form.description) header.appendChild(el("p", { className: "fillo-form-description", text: api.form.description }));
|
|
1459
1514
|
form.appendChild(header);
|
|
1460
1515
|
} else if (api.page.title) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Fillo=(()=>{var We=Object.defineProperty;var cn=Object.getOwnPropertyDescriptor;var un=Object.getOwnPropertyNames;var ln=Object.prototype.hasOwnProperty;var dn=(e,t)=>{for(var r in t)We(e,r,{get:t[r],enumerable:!0})},pn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of un(t))!ln.call(e,o)&&o!==r&&We(e,o,{get:()=>t[o],enumerable:!(n=cn(t,o))||n.enumerable});return e};var fn=e=>pn(We({},"__esModule",{value:!0}),e);var oi={};dn(oi,{FilloClient:()=>Ve,FilloError:()=>w,createClient:()=>_e,createFormElement:()=>an,defineForm:()=>At,registerFilloElement:()=>Nt,renderForm:()=>Ke});var Mt;function _(e,t,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let u=s.prototype,l=Object.keys(u);for(let p=0;p<l.length;p++){let f=l[p];f in a||(a[f]=u[f].bind(a))}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let u=r?.Parent?new i:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var K=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(Mt=globalThis).__zod_globalConfig??(Mt.__zod_globalConfig={});var Ge=globalThis.__zod_globalConfig;function J(e){return e&&Object.assign(Ge,e),Ge}function Lt(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Ot(e,t){return typeof t=="bigint"?t.toString():t}function Rt(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Xe(e){return e==null}function Dt(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var Tt=Symbol("evaluating");function X(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Tt)return n===void 0&&(n=Tt,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}var Ye="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qe(e){if(Se(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Se(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function et(e){return Qe(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Ut=new Set(["string","number","symbol"]);function ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tt(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function Z(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function jt(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var mn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function le(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Bt(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Y(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ae(e){return typeof e=="string"?e:e?.message}function Q(e,t,r){let n=e.message?e.message:Ae(e.inst?._zod.def?.error?.(e))??Ae(t?.error?.(e))??Ae(r.customError?.(e))??Ae(r.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=n,t?.reportInput&&(a.input=s),a}function rt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}var Vt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ot,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ht=_("$ZodError",Vt),de=_("$ZodError",Vt,{Parent:Error});var gn=e=>(t,r,n,o)=>{let i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new K;if(s.issues.length){let a=new(o?.Err??e)(s.issues.map(c=>Q(c,i,J())));throw Ye(a,o?.callee),a}return s.value},Ce=gn(de),bn=e=>async(t,r,n,o)=>{let i=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(o?.Err??e)(s.issues.map(c=>Q(c,i,J())));throw Ye(a,o?.callee),a}return s.value},Pe=bn(de),vn=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new K;return i.issues.length?{success:!1,error:new(e??Ht)(i.issues.map(s=>Q(s,o,J())))}:{success:!0,data:i.value}},pe=vn(de),yn=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>Q(s,o,J())))}:{success:!0,data:i.value}},fe=yn(de);var Kt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var _n="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",xn=new RegExp(`^${_n}$`);var qt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var nt=/^-?\d+(?:\.\d+)?$/;var re=_("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),wn={number:"number",bigint:"bigint",object:"date"};var Gt=_("$ZodCheckGreaterThan",(e,t)=>{re.init(e,t);let r=wn[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var Jt=_("$ZodCheckMaxLength",(e,t)=>{var r;re.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Xe(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let s=rt(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Xt=_("$ZodCheckMinLength",(e,t)=>{var r;re.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Xe(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let s=rt(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}});var Yt=_("$ZodCheckStringFormat",(e,t)=>{var r,n;re.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})});var er={major:4,minor:4,patch:3};var L=_("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=er;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,a,c)=>{let u=le(s),l;for(let p of a){if(p._zod.def.when){if(Bt(s)||!p._zod.def.when(s))continue}else if(u)continue;let f=s.issues.length,h=p._zod.check(s);if(h instanceof Promise&&c?.async===!1)throw new K;if(l||h instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await h,s.issues.length!==f&&(u||(u=le(s,f)))});else{if(s.issues.length===f)continue;u||(u=le(s,f))}}return l?l.then(()=>s):s},i=(s,a,c)=>{if(le(s))return s.aborted=!0,s;let u=o(a,n,c);if(u instanceof Promise){if(c.async===!1)throw new K;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>i(l,s,a)):i(u,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new K;return c.then(u=>o(u,n,a))}return o(c,n,a)}}X(e,"~standard",()=>({validate:o=>{try{let i=pe(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return fe(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),ot=_("$ZodString",(e,t)=>{L.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??qt(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),it=_("$ZodStringFormat",(e,t)=>{Yt.init(e,t),ot.init(e,t)});var or=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Kt),it.init(e,t)});var ir=_("$ZodNumber",(e,t)=>{L.init(e,t),e._zod.pattern=e._zod.bag.pattern??nt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}});var sr=_("$ZodUnknown",(e,t)=>{L.init(e,t),e._zod.parse=r=>r});function tr(e,t,r){e.issues.length&&t.issues.push(...Y(r,e.issues)),t.value[r]=e.value}var ar=_("$ZodArray",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let i=[];for(let s=0;s<o.length;s++){let a=o[s],c=t.element._zod.run({value:a,issues:[]},n);c instanceof Promise?i.push(c.then(u=>tr(u,r,s))):tr(c,r,s)}return i.length?Promise.all(i).then(()=>r):r}});function Ze(e,t,r,n,o,i){let s=r in n;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...Y(r,e.issues))}if(!s&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?s&&(t.value[r]=void 0):t.value[r]=e.value}function zn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=jt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function kn(e,t,r,n,o,i){let s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optin==="optional",p=c.optout==="optional";for(let f in t){if(f==="__proto__"||a.has(f))continue;if(u==="never"){s.push(f);continue}let h=c.run({value:t[f],issues:[]},n);h instanceof Promise?e.push(h.then(g=>Ze(g,r,f,t,l,p))):Ze(h,r,f,t,l,p)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var cr=_("$ZodObject",(e,t)=>{if(L.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let n=Rt(()=>zn(t));X(e._zod,"propValues",()=>{let a=t.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let p of l.values)c[u].add(p)}}return c});let o=Se,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=n.value);let u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let l=[],p=s.shape;for(let f of s.keys){let h=p[f],g=h._zod.optin==="optional",b=h._zod.optout==="optional",E=h._zod.run({value:u[f],issues:[]},c);E instanceof Promise?l.push(E.then(H=>Ze(H,a,f,u,g,b))):Ze(E,a,f,u,g,b)}return i?kn(l,u,a,c,n.value,e):l.length?Promise.all(l).then(()=>a):a}});var ur=_("$ZodRecord",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Qe(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let a=new Set;for(let u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let l=t.keyType._zod.run({value:u,issues:[]},n);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(h=>Q(h,n,J())),input:u,path:[u],inst:e});continue}let p=l.value,f=t.valueType._zod.run({value:o[u],issues:[]},n);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&r.issues.push(...Y(u,h.issues)),r.value[p]=h.value})):(f.issues.length&&r.issues.push(...Y(u,f.issues)),r.value[p]=f.value)}let c;for(let u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(o)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&nt.test(a)&&c.issues.length){let p=t.keyType._zod.run({value:Number(a),issues:[]},n);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?r.value[a]=o[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>Q(p,n,J())),input:a,path:[a],inst:e});continue}let l=t.valueType._zod.run({value:o[a],issues:[]},n);l instanceof Promise?i.push(l.then(p=>{p.issues.length&&r.issues.push(...Y(a,p.issues)),r.value[c.value]=p.value})):(l.issues.length&&r.issues.push(...Y(a,l.issues)),r.value[c.value]=l.value)}}return i.length?Promise.all(i).then(()=>r):r}});var lr=_("$ZodEnum",(e,t)=>{L.init(e,t);let r=Lt(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Ut.has(typeof o)).map(o=>typeof o=="string"?ue(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{let s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}}),dr=_("$ZodLiteral",(e,t)=>{if(L.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?ue(n):n?ue(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{let i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}});function rr(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var pr=_("$ZodOptional",(e,t)=>{L.init(e,t),e._zod.optin="optional",e._zod.optout="optional",X(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),X(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Dt(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=r.value,i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(s=>rr(s,o)):rr(i,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var fr=_("$ZodDefault",(e,t)=>{L.init(e,t),e._zod.optin="optional",X(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>nr(i,t)):nr(o,t)}});function nr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function mr(e,t){return new e({type:"string",...Z(t)})}function hr(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Z(t)})}function gr(e,t){return new e({type:"number",checks:[],...Z(t)})}function br(e){return new e({type:"unknown"})}function st(e,t){return new Gt({check:"greater_than",...Z(t),value:e,inclusive:!0})}function at(e){return st(0,e)}function I(e,t){return new Jt({check:"max_length",...Z(t),maximum:e})}function ae(e,t){return new Xt({check:"min_length",...Z(t),minimum:e})}var B=_("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");L.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>Ce(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>pe(e,r,n),e.parseAsync=async(r,n)=>Pe(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>fe(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>tt(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),yr=_("ZodMiniString",(e,t)=>{ot.init(e,t),B.init(e,t)});function N(e){return mr(yr,e)}var An=_("ZodMiniStringFormat",(e,t)=>{it.init(e,t),yr.init(e,t)}),Sn=_("ZodMiniEmail",(e,t)=>{or.init(e,t),An.init(e,t)});function Fe(e){return hr(Sn,e)}var Cn=_("ZodMiniNumber",(e,t)=>{ir.init(e,t),B.init(e,t)});function _r(e){return gr(Cn,e)}var Pn=_("ZodMiniUnknown",(e,t)=>{sr.init(e,t),B.init(e,t)});function Ie(){return br(Pn)}var Zn=_("ZodMiniArray",(e,t)=>{ar.init(e,t),B.init(e,t)});function ee(e,t){return new Zn({type:"array",element:e,...Z(t)})}var xr=_("ZodMiniObject",(e,t)=>{cr.init(e,t),B.init(e,t),X(e,"shape",()=>t.shape)});function me(e,t){let r={type:"object",shape:e??{},...Z(t)};return new xr(r)}function ct(e,t){return new xr({type:"object",shape:e,catchall:Ie(),...Z(t)})}var vr=_("ZodMiniRecord",(e,t)=>{ur.init(e,t),B.init(e,t)});function wr(e,t,r){return!t||!t._zod?new vr({type:"record",keyType:N(),valueType:e,...Z(t)}):new vr({type:"record",keyType:e,valueType:t,...Z(r)})}var Fn=_("ZodMiniEnum",(e,t)=>{lr.init(e,t),B.init(e,t),e.options=Object.values(t.entries)});function $r(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Fn({type:"enum",entries:r,...Z(t)})}var In=_("ZodMiniLiteral",(e,t)=>{dr.init(e,t),B.init(e,t)});function zr(e,t){return new In({type:"literal",values:Array.isArray(e)?e:[e],...Z(t)})}var Nn=_("ZodMiniOptional",(e,t)=>{pr.init(e,t),B.init(e,t)});function O(e){return new Nn({type:"optional",innerType:e})}var Mn=_("ZodMiniDefault",(e,t)=>{fr.init(e,t),B.init(e,t)});function ut(e,t){return new Mn({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():et(t)}})}var On=["heading","paragraph","divider"];function oe(e){return!On.includes(e.kind)}function lt(e){return e==null?!1:typeof e=="string"?e.trim()!=="":Array.isArray(e)?e.length>0:typeof e=="boolean"?e:typeof e=="object"?Object.keys(e).length>0:!0}function kr(e,t){return e===t?!0:typeof e=="number"&&typeof t=="string"&&t.trim()!==""?Number(t)===e:typeof t=="number"&&typeof e=="string"&&e.trim()!==""?Number(e)===t:!1}function Rn(e,t){let r=t(e.fieldId);switch(e.op){case"answered":return lt(r);case"not_answered":return!lt(r);case"eq":return Array.isArray(r)?r.some(n=>n===e.value):kr(r,e.value);case"neq":return lt(r)?Array.isArray(r)?!r.some(n=>n===e.value):!kr(r,e.value):!1;case"contains":return typeof r=="string"?r.toLowerCase().includes(String(e.value??"").toLowerCase()):Array.isArray(r)?r.some(n=>n===e.value):!1;case"gt":return typeof r=="number"&&r>Number(e.value);case"lt":return typeof r=="number"&&r<Number(e.value)}}function Mr(e,t){return!e.visibleIf||e.visibleIf.length===0?!0:e.visibleIf.every(r=>Rn(r,t))}function Tr(e,t,r){return n=>t.has(n)&&!r.has(n)?void 0:e[n]}function Lr(e,t){let r=new Set(e.map(o=>o.id)),n=r;for(let o=0;o<=e.length;o++){let i=Tr(t,r,n),s=new Set;for(let a of e)Mr(a,i)&&s.add(a.id);if(s.size===n.size&&[...s].every(a=>n.has(a)))return s;n=s}return n}function dt(e,t){let r=e.blocks.filter(oe),n=new Set(r.map(i=>i.id)),o=Tr(t,n,Lr(r,t));return e.blocks.filter(i=>Mr(i,o))}function _t(e){return e.pages.flatMap(t=>t.blocks.filter(oe))}function De(e,t){let r=_t(e),n=Lr(r,t);return r.filter(o=>n.has(o.id))}var m=(e,t,r,n=[],o=[],i="")=>({iso2:e,name:t,dialCode:r,lengths:n,groups:o,example:i}),q=[m("US","United States","1",[10],[3,3,4],"2015550123"),m("CA","Canada","1",[10],[3,3,4],"5145550123"),m("GB","United Kingdom","44",[10],[4,6],"7400123456"),m("AU","Australia","61",[9],[3,3,3],"412345678"),m("DE","Germany","49",[10,11],[4,7],"15123456789"),m("FR","France","33",[9],[1,2,2,2,2],"612345678"),m("IN","India","91",[10],[5,5],"8123456789"),m("DK","Denmark","45",[8],[2,2,2,2],"32123456"),m("SE","Sweden","46",[9],[2,3,4],"701234567"),m("NO","Norway","47",[8],[3,2,3],"40612345"),m("FI","Finland","358",[9,10],[2,3,4],"412345678"),m("NL","Netherlands","31",[9],[1,4,4],"612345678"),m("BE","Belgium","32",[9],[3,2,2,2],"470123456"),m("ES","Spain","34",[9],[3,3,3],"612345678"),m("IT","Italy","39",[9,10],[3,3,4],"3123456789"),m("PT","Portugal","351",[9],[3,3,3],"912345678"),m("IE","Ireland","353",[9],[2,3,4],"851234567"),m("CH","Switzerland","41",[9],[2,3,2,2],"781234567"),m("AT","Austria","43",[10,11],[3,7],"6641234567"),m("PL","Poland","48",[9],[3,3,3],"512345678"),m("CZ","Czechia","420",[9],[3,3,3],"601123456"),m("GR","Greece","30",[10],[3,3,4],"6912345678"),m("RO","Romania","40",[9],[3,3,3],"712345678"),m("HU","Hungary","36",[9],[2,3,4],"201234567"),m("UA","Ukraine","380",[9],[2,3,2,2],"501234567"),m("RU","Russia","7",[10],[3,3,2,2],"9123456789"),m("TR","Turkey","90",[10],[3,3,2,2],"5012345678"),m("IL","Israel","972",[9],[2,3,4],"501234567"),m("AE","United Arab Emirates","971",[9],[2,3,4],"501234567"),m("SA","Saudi Arabia","966",[9],[2,3,4],"512345678"),m("ZA","South Africa","27",[9],[2,3,4],"711234567"),m("NG","Nigeria","234",[10],[3,3,4],"8021234567"),m("KE","Kenya","254",[9],[3,3,3],"712123456"),m("EG","Egypt","20",[10],[3,3,4],"1001234567"),m("BR","Brazil","55",[10,11],[2,5,4],"11961234567"),m("MX","Mexico","52",[10],[3,3,4],"2221234567"),m("AR","Argentina","54",[10],[4,6],"1123456789"),m("CL","Chile","56",[9],[1,4,4],"221234567"),m("CO","Colombia","57",[10],[3,3,4],"3211234567"),m("PE","Peru","51",[9],[3,3,3],"912345678"),m("CN","China","86",[11],[3,4,4],"13123456789"),m("JP","Japan","81",[10],[2,4,4],"9012345678"),m("KR","South Korea","82",[9,10],[2,4,4],"1023456789"),m("SG","Singapore","65",[8],[4,4],"81234567"),m("HK","Hong Kong","852",[8],[4,4],"51234567"),m("TW","Taiwan","886",[9],[3,3,3],"912345678"),m("MY","Malaysia","60",[9,10],[2,3,4],"123456789"),m("ID","Indonesia","62",[10,11],[3,4,4],"81234567890"),m("TH","Thailand","66",[9],[2,3,4],"812345678"),m("PH","Philippines","63",[10],[3,3,4],"9171234567"),m("VN","Vietnam","84",[9],[3,3,3],"912345678"),m("PK","Pakistan","92",[10],[3,3,4],"3012345678"),m("BD","Bangladesh","880",[10],[2,4,4],"1812345678"),m("NZ","New Zealand","64",[9,10],[2,3,4],"211234567"),m("SK","Slovakia","421",[9],[3,3,3],"912123456"),m("BG","Bulgaria","359",[9],[2,3,4],"481234567"),m("HR","Croatia","385",[8,9],[2,3,4],"921234567"),m("RS","Serbia","381",[8,9],[2,3,4],"601234567"),m("SI","Slovenia","386",[8],[2,3,3],"31234567"),m("LT","Lithuania","370",[8],[3,2,3],"61234567"),m("LV","Latvia","371",[8],[2,3,3],"21234567"),m("EE","Estonia","372",[7,8],[3,4],"51234567"),m("IS","Iceland","354",[7],[3,4],"6111234"),m("LU","Luxembourg","352",[9],[3,3,3],"628123456"),m("MA","Morocco","212",[9],[3,3,3],"650123456"),m("CR","Costa Rica","506",[8],[4,4],"83123456"),m("EC","Ecuador","593",[9],[2,3,4],"991234567"),m("UY","Uruguay","598",[8],[1,3,4],"94231234"),m("QA","Qatar","974",[8],[4,4],"33123456"),m("KW","Kuwait","965",[8],[4,4],"50012345")],Dn=new Map(q.map(e=>[e.iso2,e])),Un={"Africa/Cairo":"EG","Africa/Casablanca":"MA","Africa/Johannesburg":"ZA","Africa/Lagos":"NG","Africa/Nairobi":"KE","America/Adak":"US","America/Anchorage":"US","America/Argentina/Buenos_Aires":"AR","America/Argentina/Cordoba":"AR","America/Argentina/Mendoza":"AR","America/Bahia":"BR","America/Belem":"BR","America/Bogota":"CO","America/Boise":"US","America/Boa_Vista":"BR","America/Cancun":"MX","America/Chicago":"US","America/Chihuahua":"MX","America/Campo_Grande":"BR","America/Costa_Rica":"CR","America/Cuiaba":"BR","America/Denver":"US","America/Detroit":"US","America/Edmonton":"CA","America/Fortaleza":"BR","America/Guayaquil":"EC","America/Halifax":"CA","America/Hermosillo":"MX","America/Indiana/Indianapolis":"US","America/Indianapolis":"US","America/Juneau":"US","America/Kentucky/Louisville":"US","America/Lima":"PE","America/Los_Angeles":"US","America/Maceio":"BR","America/Manaus":"BR","America/Matamoros":"MX","America/Mazatlan":"MX","America/Merida":"MX","America/Mexico_City":"MX","America/Moncton":"CA","America/Monterrey":"MX","America/Montevideo":"UY","America/New_York":"US","America/Noronha":"BR","America/Nome":"US","America/North_Dakota/Center":"US","America/Ojinaga":"MX","America/Phoenix":"US","America/Porto_Velho":"BR","America/Punta_Arenas":"CL","America/Recife":"BR","America/Regina":"CA","America/Rio_Branco":"BR","America/Santiago":"CL","America/Sao_Paulo":"BR","America/Sitka":"US","America/St_Johns":"CA","America/Tijuana":"MX","America/Toronto":"CA","America/Vancouver":"CA","America/Whitehorse":"CA","America/Winnipeg":"CA","America/Yakutat":"US","Asia/Bangkok":"TH","Asia/Calcutta":"IN","Asia/Dacca":"BD","Asia/Dhaka":"BD","Asia/Dubai":"AE","Asia/Hong_Kong":"HK","Asia/Ho_Chi_Minh":"VN","Asia/Jakarta":"ID","Asia/Jerusalem":"IL","Asia/Karachi":"PK","Asia/Kolkata":"IN","Asia/Kuala_Lumpur":"MY","Asia/Kuwait":"KW","Asia/Manila":"PH","Asia/Qatar":"QA","Asia/Riyadh":"SA","Asia/Seoul":"KR","Asia/Shanghai":"CN","Asia/Saigon":"VN","Asia/Singapore":"SG","Asia/Taipei":"TW","Asia/Tel_Aviv":"IL","Asia/Tokyo":"JP","Asia/Urumqi":"CN","Atlantic/Reykjavik":"IS","Australia/Adelaide":"AU","Australia/Brisbane":"AU","Australia/Darwin":"AU","Australia/Hobart":"AU","Australia/Melbourne":"AU","Australia/Perth":"AU","Australia/Sydney":"AU","Europe/Amsterdam":"NL","Europe/Athens":"GR","Europe/Belgrade":"RS","Europe/Berlin":"DE","Europe/Bratislava":"SK","Europe/Brussels":"BE","Europe/Bucharest":"RO","Europe/Budapest":"HU","Europe/Copenhagen":"DK","Europe/Dublin":"IE","Europe/Helsinki":"FI","Europe/Zagreb":"HR","Europe/Istanbul":"TR","Europe/Kiev":"UA","Europe/Kyiv":"UA","Europe/Lisbon":"PT","Europe/Ljubljana":"SI","Europe/London":"GB","Europe/Luxembourg":"LU","Europe/Madrid":"ES","Europe/Moscow":"RU","Europe/Oslo":"NO","Europe/Paris":"FR","Europe/Prague":"CZ","Europe/Riga":"LV","Europe/Rome":"IT","Europe/Sofia":"BG","Europe/Stockholm":"SE","Europe/Tallinn":"EE","Europe/Vienna":"AT","Europe/Vilnius":"LT","Europe/Warsaw":"PL","Europe/Zurich":"CH","Pacific/Auckland":"NZ"};function xt(e){let t=e.toUpperCase();return/^[A-Z]{2}$/.test(t)?String.fromCodePoint(...[...t].map(r=>127462+r.charCodeAt(0)-65)):"\u{1F3F3}\uFE0F"}function Ue(e){return e?Dn.get(e.toUpperCase()):void 0}function Or(e){return Ue(e?Un[e]:void 0)}function jn(e){let t;for(let r of q)e.startsWith(r.dialCode)&&(!t||r.dialCode.length>t.dialCode.length)&&(t=r);return t}function W(e){return e.replace(/[^\d]/g,"")}function je(e,t){let r=W(t);if(!r)return"";let n=e?.groups?.length?e.groups:[],o=[],i=0;for(let s of n){if(i>=r.length)break;o.push(r.slice(i,i+s)),i+=s}for(;i<r.length;)o.push(r.slice(i,i+3)),i+=3;return o.join(" ")}function Rr(e,t){let r=W(t);return r?`+${e.dialCode}${r}`:""}function Be(e,t){let r=(e??"").trim(),n=r.startsWith("+"),o=W(r);if(!o)return{country:t,national:"",e164:""};if(n){let i=jn(o);if(i){let s=o.slice(i.dialCode.length);return{country:i,national:s,e164:`+${o}`}}return{national:o,e164:`+${o}`}}if(t){let i=o.startsWith(t.dialCode)?o.slice(t.dialCode.length):o;return{country:t,national:i,e164:`+${t.dialCode}${i}`}}return{national:o,e164:`+${o}`}}function Bn(e){let{country:t,national:r,e164:n}=Be(e);if(!n)return!1;let o=W(n).length;return o<8||o>15?!1:t?.lengths.length?t.lengths.includes(r.length):r.length>=4}var Vn=me({fileId:N().check(ae(1)),name:N(),size:_r().check(at()),mime:N(),url:O(N())});function Dr(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="boolean"?e===!1:typeof e=="object"?Object.keys(e).length===0:!1}function Ur(e,t){if(Dr(t))return e.required?"This field is required":null;switch(e.kind){case"short_text":case"long_text":{if(typeof t!="string")return"Expected text";if(e.maxLength&&t.length>e.maxLength)return`Must be at most ${e.maxLength} characters`;let r=e.kind==="long_text"?2e4:2e3;return!e.maxLength&&t.length>r?"Answer is too long":null}case"email":return Fe().safeParse(t).success?null:"Enter a valid email address";case"url":{if(typeof t!="string")return"Enter a valid URL (including https://)";try{let r=new URL(t);if(r.protocol!=="http:"&&r.protocol!=="https:")return"Enter an http(s) URL"}catch{return"Enter a valid URL (including https://)"}return null}case"phone":return typeof t!="string"||!Bn(t)?"Enter a valid phone number":null;case"number":{let r=typeof t=="string"?Number(t):t;return typeof r!="number"||!Number.isFinite(r)?"Enter a number":e.min!==void 0&&r<e.min?`Must be at least ${e.min}`:e.max!==void 0&&r>e.max?`Must be at most ${e.max}`:null}case"select":case"dropdown":return typeof t!="string"||t===""?"Pick an option":e.options.some(r=>r.id===t)||e.allowOther&&t.length<=500?null:"Pick a valid option";case"multi_select":{if(!Array.isArray(t))return"Pick at least one option";let r=new Set(e.options.map(i=>i.id)),n=t,o=0;for(let i of n)if(!r.has(i)){if(e.allowOther!==!0||typeof i!="string"||i.length===0||i.length>500)return"Pick valid options";if(++o>1)return"Only one 'Other' answer is allowed"}return null}case"checkbox":return typeof t=="boolean"?null:"Invalid value";case"rating":{let r=e.max??5,n=typeof t=="string"?Number(t):t;return typeof n!="number"||!Number.isInteger(n)||n<1||n>r?`Pick a rating between 1 and ${r}`:null}case"linear_scale":{let r=e.min??1,n=e.max??10,o=typeof t=="string"?Number(t):t;return typeof o!="number"||!Number.isInteger(o)||o<r||o>n?`Pick a value between ${r} and ${n}`:null}case"ranking":{if(!Array.isArray(t))return"Drag the options into order";let r=e.options.map(o=>o.id).sort(),n=[...t].sort();return r.length!==n.length||r.some((o,i)=>o!==n[i])?"Rank every option":null}case"matrix":{if(typeof t!="object"||t===null||Array.isArray(t))return"Answer the grid";let r=t,n=new Set(e.columns.map(i=>i.id)),o=new Set(e.rows.map(i=>i.id));for(let[i,s]of Object.entries(r))if(!o.has(i)||!n.has(s))return"Invalid grid answer";return e.required&&Object.keys(r).length<e.rows.length?"Answer every row":null}case"signature":return typeof t!="string"||!t.startsWith("data:image/")?"Sign in the box":null;case"hidden":return typeof t=="string"?null:"Invalid value";case"custom":return null;case"date":{if(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t))return"Enter a valid date";let[r,n,o]=t.split("-").map(Number),i=new Date(Date.UTC(r,n-1,o));return i.getUTCFullYear()!==r||i.getUTCMonth()!==n-1||i.getUTCDate()!==o?"Enter a valid date":null}case"file_upload":{let r=ee(Vn).safeParse(t);if(!r.success)return"Upload did not complete";let n=e.maxFiles??1;return r.data.length>n?`At most ${n} file${n===1?"":"s"}`:null}}}function jr(e,t){let r=De(e,t),n={},o={};for(let i of r){let s=Hn(i,t[i.id]),a=Ur(i,s);a?n[i.id]=a:Dr(s)||(o[i.id]=s)}return{ok:Object.keys(n).length===0,errors:n,data:o}}function Hn(e,t){if(t==null)return t;if(e.kind==="number"&&typeof t=="string"&&t.trim()!==""){let r=Number(t);return Number.isNaN(r)?t:r}if((e.kind==="rating"||e.kind==="linear_scale")&&typeof t=="string"){let r=Number(t);return Number.isNaN(r)?t:r}return typeof t=="string"?t.trim():t}var Kn=["short_text","long_text","email","url","phone","number","select","multi_select","dropdown","checkbox","rating","linear_scale","ranking","matrix","signature","date","file_upload","hidden","custom"],qn=["heading","paragraph","divider"],Wn=[...Kn,...qn],wt=N().check(ae(1),I(128)),pt=ct({id:wt,label:N().check(I(1e3)),icon:O(Ie())}),Gn=ct({id:wt,kind:$r(Wn),label:O(N().check(I(2e3))),options:O(ee(pt).check(I(200))),rows:O(ee(pt).check(I(200))),columns:O(ee(pt).check(I(200)))}),Jn=me({id:wt,title:O(N().check(I(500))),blocks:ee(Gn).check(I(500))}),Xn=me({version:zr(1),title:ut(O(N().check(I(2e3))),""),description:O(N().check(I(5e3))),pages:ee(Jn).check(ae(1),I(50)),settings:ut(O(wr(N(),Ie())),{})}),Yn=1,vt=1,yt="0.6.2";function V(e,t,r=""){return typeof e=="string"?e.trim().slice(0,t):r}function F(e,t){let r=V(e,t);return r===""?void 0:r}function ve(e){return typeof e=="boolean"?e:void 0}function be(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function ne(e,t,r,n){let o=be(e);return o===void 0?n:Math.max(t,Math.min(r,Math.round(o)))}function Ne(e,t=200){return Array.isArray(e)?e.slice(0,t).flatMap(r=>{if(!r||typeof r!="object")return[];let n=r,o=V(n.id,128),i=V(n.label,1e3),s=n.icon==="thumbs_up"||n.icon==="thumbs_down"?n.icon:void 0;return o&&i?[S({id:o,label:i,icon:s})]:[]}):[]}function Qn(e){if(!Array.isArray(e))return;let t=e.slice(0,20).flatMap(r=>{if(!r||typeof r!="object")return[];let n=r,o=n.op;if(o!=="eq"&&o!=="neq"&&o!=="contains"&&o!=="gt"&&o!=="lt"&&o!=="answered"&&o!=="not_answered")return[];let i=V(n.fieldId,128);if(!i)return[];let s=n.value,a=typeof s=="string"||typeof s=="number"||typeof s=="boolean"?s:void 0;return[{fieldId:i,op:o,...a!==void 0?{value:a}:{}}]});return t.length?t:void 0}function Br(e){return{id:V(e.id,128),visibleIf:Qn(e.visibleIf)}}function M(e,t){return{...Br(e),kind:t,label:V(e.label,2e3,"Untitled field"),description:F(e.description,5e3),required:ve(e.required),placeholder:F(e.placeholder,500)}}function eo(e){let t=F(e,2e3);if(t)try{let r=new URL(t);return r.protocol==="http:"||r.protocol==="https:"?t:void 0}catch{return}}function to(e){let t=e&&typeof e=="object"?e:{},r=t.submitMode==="button"||t.submitMode==="auto"?t.submitMode:void 0,n=t.submissionLimit==="once_per_visitor"||t.submissionLimit==="multiple"?t.submissionLimit:void 0;return{submitMode:r,submitLabel:F(t.submitLabel,100),successTitle:F(t.successTitle,200),successMessage:F(t.successMessage,5e3),redirectUrl:eo(t.redirectUrl),showProgress:ve(t.showProgress),submissionLimit:n,notifyEmail:Fe().check(I(254)).safeParse(t.notifyEmail).success?t.notifyEmail:void 0,sendReceipt:ve(t.sendReceipt)}}function S(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function ro(e){if(!e||typeof e!="object")return null;let t=e,r=t.kind,n=Br(t);if(!n.id||typeof r!="string")return null;switch(r){case"heading":return S({...n,kind:r,text:V(t.text,2e3,"Section")});case"paragraph":return S({...n,kind:r,text:V(t.text,5e3)});case"divider":return S({...n,kind:r});case"short_text":case"email":case"url":return S({...M(t,r),maxLength:be(t.maxLength)===void 0?void 0:ne(t.maxLength,1,2e3,2e3)});case"phone":{let o=F(t.defaultCountry,2)?.toUpperCase();return S({...M(t,r),defaultCountry:o&&/^[A-Z]{2}$/.test(o)?o:void 0})}case"long_text":return S({...M(t,r),maxLength:be(t.maxLength)===void 0?void 0:ne(t.maxLength,1,2e4,2e4)});case"number":return S({...M(t,r),min:be(t.min),max:be(t.max)});case"select":case"multi_select":case"dropdown":{let o=Ne(t.options);return o.length===0?null:S({...M(t,r),options:o,allowOther:ve(t.allowOther),shuffleOptions:ve(t.shuffleOptions)})}case"checkbox":{let o=t.appearance==="toggle"?"toggle":void 0;return S({...M(t,r),appearance:o})}case"signature":case"date":return S(M(t,r));case"rating":return S({...M(t,r),max:ne(t.max,1,10,5)});case"linear_scale":{let o=ne(t.min,0,9,1),i=ne(t.max,o+1,10,10);return S({...M(t,r),min:o,max:i,minLabel:F(t.minLabel,100),maxLabel:F(t.maxLabel,100)})}case"ranking":{let o=Ne(t.options);return o.length<2?null:S({...M(t,r),options:o})}case"matrix":{let o=Ne(t.rows),i=Ne(t.columns);return o.length===0||i.length===0?null:S({...M(t,r),rows:o,columns:i})}case"hidden":return S({...M(t,r),required:!1,paramName:F(t.paramName,128),defaultValue:F(t.defaultValue,1e3)});case"file_upload":return S({...M(t,r),maxFiles:ne(t.maxFiles,1,20,1),maxFileSizeMb:ne(t.maxFileSizeMb,1,5e3,500),accept:Array.isArray(t.accept)?t.accept.flatMap(o=>{let i=F(o,100);return i?[i]:[]}).slice(0,50):void 0});case"custom":return S({...M(t,r),component:V(t.component,128),config:t.config&&typeof t.config=="object"&&!Array.isArray(t.config)?t.config:void 0});default:return null}}function ye(e){let t=Xn.safeParse(e);if(!t.success){let s=t.error.issues[0],a=s?.path.join(".");return{ok:!1,error:s?`${a?`${a}: `:""}${s.message}`:"Invalid schema"}}if(t.data.version>Yn)return{ok:!1,error:`Unsupported schema version: ${t.data.version}`};let r=t.data.pages.map(s=>{let a=s.blocks.flatMap(c=>{let u=ro(c);return u?[u]:[]});return S({id:s.id,title:F(s.title,500),blocks:a})}),n=new Set;for(let s of r)for(let a of s.blocks){if(n.has(a.id))return{ok:!1,error:`Duplicate block id: ${a.id}`};n.add(a.id)}if(r.every(s=>s.blocks.length===0))return{ok:!1,error:"Schema must contain at least one valid block"};let o={version:vt,title:V(t.data.title,2e3),pages:r,settings:to(t.data.settings)},i=F(t.data.description,5e3);return i&&(o.description=i),{ok:!0,schema:o}}function he(e,t){let r=F(e,t);if(r&&!(/[;{}<>]/.test(r)||/url\s*\(/i.test(r)))return r}function $t(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.colorScheme==="light"||t.colorScheme==="dark"||t.colorScheme==="auto"?t.colorScheme:void 0,n=S({colorScheme:r,primary:he(t.primary,200),background:he(t.background,200),text:he(t.text,200),radius:he(t.radius,64),fontFamily:he(t.fontFamily,200)});return Object.keys(n).length>0?n:null}var no="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Kc=256-256%no.length;var Vr=class{h0=1732584193;h1=4023233417;h2=2562383102;h3=271733878;h4=3285377520;block=new Uint8Array(64);blockLen=0;totalLen=0;w=new Int32Array(80);update(e){this.totalLen+=e.length;let t=0;if(this.blockLen>0){for(;t<e.length&&this.blockLen<64;)this.block[this.blockLen++]=e[t++];this.blockLen===64&&(this.process(this.block),this.blockLen=0)}for(;t+64<=e.length;)this.process(e.subarray(t,t+64)),t+=64;for(;t<e.length;)this.block[this.blockLen++]=e[t++];return this}digest(){let e=Math.floor(this.totalLen/536870912),t=this.totalLen*8>>>0,r=[128],n=this.blockLen+1;for(;n%64!==56;)r.push(0),n++;r.push(e>>>24&255,e>>>16&255,e>>>8&255,e&255),r.push(t>>>24&255,t>>>16&255,t>>>8&255,t&255),this.update(new Uint8Array(r));let o=new Uint8Array(20),i=[this.h0,this.h1,this.h2,this.h3,this.h4];for(let s=0;s<5;s++)o[s*4]=i[s]>>>24&255,o[s*4+1]=i[s]>>>16&255,o[s*4+2]=i[s]>>>8&255,o[s*4+3]=i[s]&255;return o}process(e){let t=this.w;for(let a=0;a<16;a++)t[a]=e[a*4]<<24|e[a*4+1]<<16|e[a*4+2]<<8|e[a*4+3];for(let a=16;a<80;a++){let c=t[a-3]^t[a-8]^t[a-14]^t[a-16];t[a]=c<<1|c>>>31}let r=this.h0,n=this.h1,o=this.h2,i=this.h3,s=this.h4;for(let a=0;a<80;a++){let c,u;a<20?(c=n&o|~n&i,u=1518500249):a<40?(c=n^o^i,u=1859775393):a<60?(c=n&o|n&i|o&i,u=2400959708):(c=n^o^i,u=3395469782);let l=(r<<5|r>>>27)+c+s+u+t[a]|0;s=i,i=o,o=n<<30|n>>>2,n=r,r=l}this.h0=this.h0+r|0,this.h1=this.h1+n|0,this.h2=this.h2+o|0,this.h3=this.h3+i|0,this.h4=this.h4+s|0}},Me="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function zt(e){let t="";for(let r=0;r<e.length;r+=3){let n=e[r],o=r+1<e.length?e[r+1]:0,i=r+2<e.length?e[r+2]:0;t+=Me[n>>2],t+=Me[(n&3)<<4|o>>4],t+=r+1<e.length?Me[(o&15)<<2|i>>6]:"=",t+=r+2<e.length?Me[i&63]:"="}return t}var oo=e=>zt(new Vr().update(e).digest()),w=class extends Error{constructor(e,t,r){super(e),this.status=t,this.retryAfterSec=r,this.name="FilloError"}status;retryAfterSec};function Re(e){return e instanceof Error&&e.name==="FilloError"}async function Er(e,t){try{let r=await e.json();if(typeof r.error=="string"&&r.error)return r.error}catch{}return t}function Ar(e){let t=Number(e.headers.get("retry-after"));return Number.isFinite(t)&&t>0?t:void 0}var Te=3,ge=3e4;function Le(e){return e>=500||e===429||e===408}function Sr(e){return e instanceof DOMException&&e.name==="TimeoutError"?new w("Request timed out",0):e}function io(e,t){let r=e.split(".").map(o=>Number(o)||0),n=t.split(".").map(o=>Number(o)||0);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]??0)-(n[o]??0);if(i!==0)return i}return 0}function so(e){if(e.schemaVersion!==void 0&&e.schemaVersion!==vt)throw new w(`This form uses schema version ${e.schemaVersion}; this SDK supports version ${vt}. Update @usefillo/* to render it.`,426);if(e.minSdkVersion&&io(yt,e.minSdkVersion)<0)throw new w(`This form requires @usefillo/* ${e.minSdkVersion} or newer. Current SDK is ${yt}.`,426)}function ft(e,t){return r=>t.onProgress?.({uploadedBytes:r,totalBytes:e,fraction:e===0?1:r/e})}async function ao(e){let t=globalThis.crypto?.subtle;if(t){let r=await t.digest("SHA-1",e);return zt(new Uint8Array(r))}return oo(e)}var co="https://fillo.so",Cr={"X-Fillo-Client":`@usefillo/core@${yt}`},Ve=class{baseUrl;fetch;key;constructor(e={}){this.baseUrl=e.baseUrl?e.baseUrl.replace(/\/$/,""):e.sameOrigin?"":co,this.key=e.key,this.fetch=e.fetch??((...t)=>globalThis.fetch(...t))}url(e){return`${this.baseUrl}/api/v1${e}`}async json(e,t){let r=t?.body!=null?{"Content-Type":"application/json",...Cr,...t?.headers}:t?.headers,n;try{n=await this.fetch(this.url(e),{...t,headers:r,signal:t?.signal??AbortSignal.timeout(ge)})}catch(o){throw Sr(o)}if(!n.ok){let o=await Er(n,`Request failed: ${n.status}`);throw new w(o,n.status,Ar(n))}return await n.json()}async getForm(e){let t=await this.json(`/forms/${encodeURIComponent(e)}`);return so(t),t}syncForm(e,t,r){if(!this.key)return Promise.reject(new w("createClient needs a `key` (pk_\u2026) to sync code-defined forms",401));let n=ye(t);return n.ok?this.json("/forms/sync",{method:"POST",body:JSON.stringify({key:this.key,id:e,schema:n.schema,theme:$t(r)})}):Promise.reject(new w(`Invalid form schema: ${n.error}`,400))}async submit(e,t,r){let n;try{n=await this.fetch(this.url(`/forms/${encodeURIComponent(e)}/responses`),{method:"POST",headers:{"Content-Type":"application/json",...Cr},body:JSON.stringify({data:t,meta:r}),signal:AbortSignal.timeout(ge)})}catch(i){throw Sr(i)}if(n.status===422)return{ok:!1,errors:(await n.json()).errors};if(!n.ok){let i=await Er(n,`Submit failed: ${n.status}`);throw new w(i,n.status,Ar(n))}let o=await n.json();return{ok:!0,responseId:o.id,duplicate:o.duplicate}}async startSession(e,t){try{let r=await this.fetch(this.url(`/forms/${encodeURIComponent(e)}/sessions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageCount:t}),signal:AbortSignal.timeout(ge)});return r.ok?(await r.json()).id:null}catch{return null}}reportProgress(e,t){try{this.fetch(this.url(`/sessions/${encodeURIComponent(e)}/progress`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0,signal:AbortSignal.timeout(ge)}).catch(()=>{})}catch{}}getUploadSession(e,t){return this.json(`/uploads/${encodeURIComponent(e)}`,t?{headers:{"X-Fillo-Upload-Token":t}}:void 0)}async uploadFile(e,t,r){let n=t instanceof File?t.name:"upload.bin",o=t.type||"application/octet-stream",i;r.sessionId?i=await this.getUploadSession(r.sessionId,r.uploadToken):i=await this.json(`/forms/${encodeURIComponent(e)}/uploads`,{method:"POST",body:JSON.stringify({fieldId:r.fieldId,fileName:n,size:t.size,mime:o})});let s;if(i.transport?.type==="gdrive")await this.driveUploadLoop(i,i.transport.uploadUrl,t,r);else if(i.transport?.type==="s3-put")await this.s3PutUpload(i.transport.uploadUrl,t,r);else if(i.transport?.type==="box")s=await this.boxUpload(i.transport,t,r);else throw new w("This form's storage doesn't support uploads \u2014 connect Drive, S3, or Box.");let a=await this.json(`/uploads/${encodeURIComponent(i.id)}/complete`,{method:"POST",headers:i.token?{"X-Fillo-Upload-Token":i.token}:void 0,...s?{body:JSON.stringify(s)}:{}});if(!a.file)throw new w("Upload completed but no file was returned");return a.file}async boxUpload(e,t,r){let n=ft(t.size,r);n(0);let o={Authorization:`Bearer ${e.token}`};if(e.mode==="simple"){let f=new FormData;f.append("attributes",JSON.stringify({name:e.fileName,parent:{id:e.folderId}})),f.append("file",t,e.fileName);let h=await this.retry(r,async()=>{let b=await this.fetch(e.uploadUrl,{method:"POST",headers:o,body:f,signal:this.uploadSignal(r)});if(!b.ok&&Le(b.status))throw new w(`Box upload failed: ${b.status}`,b.status);return b});if(!h.ok)throw new w(`Box upload failed: ${h.status}`,h.status);let g=await h.json();return n(t.size),{providerFileId:g.entries?.[0]?.id}}if(e.size!==t.size)throw new w(`File size changed since the upload was requested (${t.size} vs ${e.size}).`,400);let i=await this.retry(r,async()=>{let f=await this.fetch(e.sessionUrl,{method:"POST",headers:{...o,"Content-Type":"application/json"},body:JSON.stringify({folder_id:e.folderId,file_size:e.size,file_name:e.fileName}),signal:this.uploadSignal(r)});if(!f.ok&&Le(f.status))throw new w(`Box session failed: ${f.status}`,f.status);return f});if(!i.ok)throw new w(`Box session failed: ${i.status}`,i.status);let s=await i.json(),a=new Vr,c=[],u=0;for(;u<t.size;){r.signal?.throwIfAborted();let f=Math.min(u+s.part_size,t.size),h=new Uint8Array(await t.slice(u,f).arrayBuffer());a.update(h);let g=await ao(h),b=await this.retry(r,async()=>{let E=await this.fetch(s.session_endpoints.upload_part,{method:"PUT",headers:{...o,"Content-Type":"application/octet-stream",Digest:`sha=${g}`,"Content-Range":`bytes ${u}-${f-1}/${t.size}`},body:h,signal:this.uploadSignal(r)});if(!E.ok&&Le(E.status))throw new w(`Box part failed: ${E.status}`,E.status);return E});if(!b.ok)throw new w(`Box part failed: ${b.status}`,b.status);c.push((await b.json()).part),u=f,n(u)}let l=await this.retry(r,async()=>{let f=await this.fetch(s.session_endpoints.commit,{method:"POST",headers:{...o,"Content-Type":"application/json",Digest:`sha=${zt(a.digest())}`},body:JSON.stringify({parts:c}),signal:this.uploadSignal(r)});if(!f.ok&&Le(f.status))throw new w(`Box commit failed: ${f.status}`,f.status);return f});if(!l.ok)throw new w(`Box commit failed: ${l.status}`,l.status);return{providerFileId:(await l.json()).entries?.[0]?.id}}uploadSignal(e){let t=AbortSignal.timeout(ge);return e.signal?AbortSignal.any([e.signal,t]):t}async retry(e,t){let r=0;for(;;)try{return await t()}catch(n){if(e.signal?.aborted||(r+=1,r>=Te))throw n;await new Promise(o=>setTimeout(o,500*2**r))}}async driveUploadLoop(e,t,r,n){let o=e.uploadedBytes,i=ft(r.size,n);i(o);let s=0;for(;o<r.size;){n.signal?.throwIfAborted();let a=o,c=Math.min(o+e.chunkSize,r.size),u=r.slice(o,c),l=0;for(;;)try{let p=await this.fetch(t,{method:"PUT",headers:{"Content-Range":`bytes ${o}-${c-1}/${r.size}`},body:u,signal:this.uploadSignal(n)});if(p.status===308){let f=p.headers.get("Range")??p.headers.get("range"),h=f?.match(/bytes=0-(\d+)/);h?o=Number(h[1])+1:f==null?o=0:o=(await this.getUploadSession(e.id,e.token)).uploadedBytes;break}if(p.ok){o=r.size;break}throw new w(`Drive chunk failed: ${p.status}`,p.status)}catch(p){if(n.signal?.aborted||(l+=1,l>=Te))throw p;if(await new Promise(h=>setTimeout(h,500*2**l)),o=(await this.getUploadSession(e.id,e.token)).uploadedBytes,o>=r.size)break;c=Math.min(o+e.chunkSize,r.size),u=r.slice(o,c)}if(i(o),o<=a){if(++s>=Te)throw new w("Drive upload stalled \u2014 the storage endpoint stopped accepting progress",0)}else s=0}}async s3PutUpload(e,t,r){let n=ft(t.size,r);n(0);let o=0;for(;;)try{let i=await this.fetch(e,{method:"PUT",headers:{"Content-Type":t.type||"application/octet-stream"},body:t,signal:this.uploadSignal(r)});if(!i.ok)throw new w(`S3 upload failed: ${i.status}`,i.status);n(t.size);return}catch(i){if(r.signal?.aborted||(o+=1,o>=Te))throw i;await new Promise(s=>setTimeout(s,500*2**o))}}};function _e(e={}){return new Ve(e)}function mt(e){let t=e.trim();if(!/^-?\d*\.?\d+$/.test(t))return null;let r=Number(t);return Number.isFinite(r)?r:null}function uo(e,t){let r={};for(let n of _t(e)){let o=n.kind==="hidden"?t[n.paramName??n.id]??n.defaultValue:t[n.id];if(!(o===void 0||o===""))switch(n.kind){case"number":{let i=mt(o);if(i===null||n.min!==void 0&&i<n.min||n.max!==void 0&&i>n.max)break;r[n.id]=i;break}case"rating":{let i=mt(o);i!==null&&Number.isInteger(i)&&i>=1&&i<=(n.max??5)&&(r[n.id]=i);break}case"linear_scale":{let i=mt(o),s=n.min??1,a=n.max??10;i!==null&&Number.isInteger(i)&&i>=s&&i<=a&&(r[n.id]=i);break}case"checkbox":r[n.id]=o==="true"||o==="1"||o==="yes";break;case"select":case"dropdown":{n.options.some(i=>i.id===o)&&(r[n.id]=o);break}case"multi_select":{let i=new Set(n.options.map(a=>a.id)),s=o.split(",").filter(a=>i.has(a));s.length>0&&(r[n.id]=s);break}case"file_upload":case"ranking":case"matrix":case"signature":case"custom":break;default:r[n.id]=o}}return r}var lo={id:"empty",blocks:[]},Pr=!1,Zr=!1;function po(){Zr||(Zr=!0,console.warn("[fillo] This form has a client but no submission target \u2014 a bare schema can't sync. Wrap it in defineForm({ id, pages }) (or author it with <Fillo.Form id=\u2026>) so it gets a workspace handle, or pass formId for a dashboard-built form: https://fillo.so/docs"))}function fo(){Pr||(Pr=!0,console.warn("[fillo] This form has no `client`, so responses can't be submitted \u2014 it's render-only. Pass a client (createClient) to collect responses in Fillo, or forward them to your own backend with webhooks: https://fillo.so/docs"))}var Hr=new Map;function Kr(){try{return globalThis.localStorage??null}catch{return null}}function qr(e){return`fillo:submission:${e}`}function kt(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);return e?.getRandomValues?(e.getRandomValues(t),Array.from(t,r=>r.toString(16).padStart(2,"0")).join("")):`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Et(e){let t=Kr();if(!t)return Hr.get(e)??null;try{let r=JSON.parse(t.getItem(qr(e))??"null");if(r&&typeof r.key=="string")return r}catch{}return null}function Wr(e,t){Hr.set(e,t);let r=Kr();if(r)try{r.setItem(qr(e),JSON.stringify(t))}catch{}}function mo(e){let t=Et(e);if(t?.key)return t.key;let r={key:kt()};return Wr(e,r),r.key}function ho(e,t){let r=Et(e);Wr(e,{key:r?.key??kt(),submittedAt:new Date().toISOString(),responseId:t})}function Fr(e,t){return e.settings.submissionLimit!=="once_per_visitor"||!t?!1:!!Et(t)?.submittedAt}function Ir(e){return Re(e)&&e.status&&e.status>0&&e.message?e.message:"Couldn't reach the server \u2014 check your connection and try again. If this keeps happening, a browser extension, firewall, or the site's Content-Security-Policy may be blocking the request."}function Gr(e){let{onChange:t,onSubmitted:r}=e,n=ye(e.form);if(!n.ok)throw new Error(`Invalid form schema: ${n.error}`);let o=n.schema,i=e.formId,s=e.client,a={...e.initialData??{}},c={},u=0,l="idle";queueMicrotask(()=>{if(l==="idle"&&Fr(o,i)&&(l="submitted",A()),typeof location<"u"&&location.search){let v=Object.fromEntries(new URLSearchParams(location.search)),y=null;for(let[$,P]of Object.entries(uo(o,v)))a[$]===void 0&&(y=y??{...a},y[$]=P);y&&l==="idle"&&(a=y,A())}});let p,f=new Set,h=new Set,g=Date.now(),b=kt(),E=null,H=!1;function ie(){let v=o.pages.length,y=Math.min(u,Math.max(v-1,0)),$=o.pages[y]??lo;return{data:a,errors:c,status:l,pageIndex:y,pageCount:v,page:$,blocks:dt($,a),isFirstPage:y===0,isLastPage:y===v-1,uploading:f.size>0,submitError:p}}let U=ie();function A(){U=ie();for(let v of h)v()}function ze(v,y){try{r?.(v,y)}catch($){console.error("[fillo] onSubmitted handler threw:",$)}}function te(v){let y=o.pages[v];if(!y)return{};let $={};for(let P of dt(y,a)){if(!oe(P))continue;let z=Ur(P,a[P.id]);z&&($[P.id]=z)}return $}function ke(v,y){!H&&s&&i&&(H=!0,s.startSession(i,o.pages.length).then($=>E=$)),a={...a,[v]:y},t?.(a),p=void 0,v in c&&(c=Object.fromEntries(Object.entries(c).filter(([$])=>$!==v))),A()}function Ee(v,y){y?f.add(v):f.delete(v),A()}function qe(){let v=o.pages.length,y=Math.min(u,Math.max(v-1,0));if(!e.skipValidation){let $=te(y);if(c=$,Object.keys($).length>0){A();return}}u=Math.min(y+1,v-1),E&&s&&s.reportProgress(E,{furthestPage:u}),A()}function x(){c={},u=Math.max(Math.min(u,o.pages.length-1)-1,0),A()}async function T(){if(l==="submitting"||l==="submitted")return;let v=jr(o,a);if(!v.ok){c=v.errors;let y=o.pages.findIndex($=>dt($,a).some(P=>P.id in v.errors));y>=0&&(u=y),A();return}if(s&&!i&&e.resolveFormId){l="submitting",p=void 0,A();try{i=await e.resolveFormId()}catch(y){throw l="idle",p=Ir(y),A(),y}}if(s&&i){let y=o.settings.submissionLimit==="once_per_visitor"?mo(i):void 0,$=y??b;l="submitting",p=void 0,A();let P;try{P=await s.submit(i,v.data,{hp:e.getHoneypot?.()??"",elapsedMs:Date.now()-g,surface:e.surface??"headless",submissionKey:$})}catch(z){throw l="idle",p=Ir(z),A(),z}if(!P.ok){c=P.errors??{},l="idle",A();return}E&&s.reportProgress(E,{completed:!0}),y&&ho(i,P.responseId),l="submitted",A(),ze(P.responseId,v.data);return}if(e.skipValidation){l="submitted",A(),ze(void 0,v.data);return}s&&!i?po():fo(),l="error",A()}return{getState:()=>U,subscribe(v){return h.add(v),()=>{h.delete(v)}},setValue:ke,setUploading:Ee,next:qe,back:x,submit:T,setContext(v){if("formId"in v&&(i=v.formId),"client"in v&&(s=v.client),v.form&&v.form!==o){let y=ye(v.form);if(!y.ok)throw new Error(`Invalid form schema: ${y.error}`);o=y.schema}l==="idle"&&Fr(o,i)&&(l="submitted"),A()},destroy(){h.clear()}}}function go(e){return oe(e)&&(e.kind==="select"||e.kind==="dropdown"||e.kind==="checkbox"||e.kind==="rating"||e.kind==="linear_scale")}function Jr(e){let t=e.filter(r=>!(oe(r)&&r.kind==="hidden"));return t.length===0?!1:t.length>1?!0:!go(t[0])}function Xr(e,t,r){if(r.form.settings.submitMode!=="auto"||!r.isLastPage||r.status!=="idle"||r.uploading||!(()=>{switch(e.kind){case"select":case"dropdown":return typeof t=="string"&&e.options.some(s=>s.id===t);case"checkbox":return t===!0;case"rating":case"linear_scale":return typeof t=="number";default:return!1}})()||t===r.data[e.id])return!1;let o={...r.data,[e.id]:t},i=De(r.form,o).filter(s=>s.kind!=="hidden");return i.length!==1||i[0]?.id!==e.id?!1:jr(r.form,o).ok}function At(e){return{id:e.id,theme:e.theme,schema:{version:1,title:e.title??"",description:e.description,pages:e.pages,settings:e.settings??{}},__filloCodeForm:!0}}function St(e){return typeof e=="object"&&e!==null&&"__filloCodeForm"in e}var Oe=new Map,bo=e=>new Promise(t=>setTimeout(t,e));async function vo(e,t){let r=800;for(let n=0;;n++)try{return await e.syncForm(t.id,t.schema,t.theme??null)}catch(o){let i=Re(o)?o.status??0:0;if(!(!Re(o)||i===0||i===408||i===429||i>=500)||n>=2)throw o;let a=Re(o)?o.retryAfterSec:void 0;await bo(Math.min(a?a*1e3:r*(1+Math.random()*.5),15e3)),r*=2}}function yo(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)|0;return(t>>>0).toString(36)}function Yr(e,t){return`fillo:sync:${e.baseUrl}|${e.key}|${t}`}function _o(e,t,r){try{let n=globalThis.localStorage?.getItem(Yr(e,t));if(!n)return null;let o=JSON.parse(n);if(typeof o.formId!="string"||o.hash!==r||typeof o.ts!="number")return null;let i=o.status==="published"?36e5:6e4;return Date.now()-o.ts>i?null:o}catch{return null}}function xo(e,t,r,n){try{globalThis.localStorage?.setItem(Yr(e,t),JSON.stringify({formId:n.formId,slug:n.slug,status:n.status,hash:r,ts:Date.now()}))}catch{}}function Ct(e,t,r){let n=JSON.stringify(t.schema)+JSON.stringify(t.theme??null),o=yo(n),i=`${e.baseUrl}:${e.key}:${t.id}:${o}`,s=Oe.get(i);if(s&&!r?.bypassCache)return s;if(!r?.bypassCache){let a=_o(e,t.id,o);if(a)return s=Promise.resolve({formId:a.formId,slug:a.slug,status:a.status}),Oe.set(i,s),s}return s=vo(e,t).then(a=>(xo(e,t.id,o,a),a)),Oe.set(i,s),s.catch(()=>Oe.delete(i)),s}var wo=class extends Error{constructor(e,t){super(`[fillo] ${t} \u2014 https://fillo.so/docs/troubleshooting#jsx-${e.toLowerCase()}`),this.code=e,this.name="FilloJsxError"}code},$o=Symbol.for("fillo.block");var zo=["label","description","required","placeholder"],C=(e,t,r,n={})=>({name:e,kind:t,props:[...zo,...r],...n}),Nr=(e,t,r)=>({name:e,kind:t,props:r?["text"]:[],textChildren:r,content:!0}),ht=["options","allowOther","shuffleOptions"],ko=[C("Text","short_text",["maxLength"]),C("LongText","long_text",["maxLength"]),C("Email","email",["maxLength"]),C("Url","url",["maxLength"]),C("Phone","phone",["defaultCountry"]),C("Number","number",["min","max"]),C("Select","select",ht,{optionChildren:!0}),C("MultiSelect","multi_select",ht,{optionChildren:!0}),C("Dropdown","dropdown",ht,{optionChildren:!0}),C("Checkbox","checkbox",["appearance"]),C("Rating","rating",["max"]),C("Scale","linear_scale",["min","max","minLabel","maxLabel"]),C("Ranking","ranking",["options"],{optionChildren:!0}),C("Matrix","matrix",["rows","columns"]),C("Signature","signature",[]),C("Date","date",[]),C("FileUpload","file_upload",["maxFiles","maxFileSizeMb","accept"]),C("Hidden","hidden",["paramName","defaultValue"]),C("Custom","custom",["component","config"]),Nr("Heading","heading",!0),Nr("Paragraph","paragraph",!0),{name:"Divider",kind:"divider",props:[],content:!0}],Eo={name:"Page",kind:"__page",props:["title"]},Ao={name:"Option",kind:"__option",props:["label","icon"]};function gt(e){let t=()=>{throw new wo("RENDERED_INERT",`<Fillo.${e.name}> was rendered by React. Fillo fields are schema declarations, valid only inside <Fillo.Form> or Fillo.defineForm(). If this form lives in a server component, move it to a client module ("use client")`)};return t[$o]=e,t}var qc=Object.fromEntries([...ko.map(e=>[e.name,gt(e)]),["Page",gt(Eo)],["Option",gt(Ao)]]);var So=/\{\{\s*([\w-]+)\s*\}\}/g;function bt(e,t,r){if(!e.includes("{{"))return e;let n=_t(r);return e.replace(So,(o,i)=>{let s=n.find(u=>u.id===i),a=t[i];if(a==null||a==="")return"";let c=u=>s&&"options"in s?s.options.find(l=>l.id===u)?.label??u:u;return Array.isArray(a)?a.map(u=>c(String(u))).join(", "):typeof a=="string"?c(a):String(a)})}function Qr(e,t,r){let n=o=>o===void 0?o:bt(o,t,r);switch(e.kind){case"heading":case"paragraph":return{...e,text:bt(e.text,t,r)};case"divider":return e;default:return{...e,label:bt(e.label,t,r),description:n(e.description)}}}var Co="fillo-",Po=0,en='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Zo(e,t){let r=`${Co}${e}-${t}`;return{inputId:r,labelId:`${r}-label`,descriptionId:`${r}-desc`,errorId:`${r}-error`,name:r}}function d(e,t={}){let r=document.createElement(e);t.className&&(r.className=t.className),t.text!==void 0&&(r.textContent=t.text);for(let[n,o]of Object.entries(t.attrs??{}))r.setAttribute(n,o);return r}function xe(e,t){let r=$t(t);r&&(r.colorScheme&&e.setAttribute("data-fillo-color-scheme",r.colorScheme),r.primary&&e.style.setProperty("--fillo-primary",r.primary),r.background&&e.style.setProperty("--fillo-bg",r.background),r.text&&e.style.setProperty("--fillo-text",r.text),r.radius&&e.style.setProperty("--fillo-radius",r.radius),r.fontFamily&&e.style.setProperty("--fillo-font",r.fontFamily),(r.primary||r.background||r.text)&&e.setAttribute("data-fillo-has-color-theme",""))}function Fo(e){try{if(!e)return null;let t=new URL(e);return t.protocol!=="http:"&&t.protocol!=="https:"?null:t.toString()}catch{return null}}function Io(e){let t=new URL(Fo(e)??"https://fillo.so");return t.searchParams.set("utm_source","form_badge"),t.toString()}function Zt(e){return typeof e=="string"||typeof e=="number"?String(e):""}function k(e,t){for(let r of t)r&&e.appendChild(r);return e}var tn="http://www.w3.org/2000/svg",No={thumbs_up:"M7 10v10M7 10l4.8-6.1a2 2 0 0 1 3.5 1.7L14.6 10h4.8a2.1 2.1 0 0 1 2 2.5l-1.1 5.4A3 3 0 0 1 17.4 20H7M3 10h4v10H3z",thumbs_down:"M7 14V4M7 14l4.8 6.1a2 2 0 0 0 3.5-1.7L14.6 14h4.8a2.1 2.1 0 0 0 2-2.5l-1.1-5.4A3 3 0 0 0 17.4 4H7M3 4h4v10H3z"};function sn(e){if(!e)return null;let t=document.createElementNS(tn,"svg");t.setAttribute("class","fillo-option-icon"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");let r=document.createElementNS(tn,"path");return r.setAttribute("d",No[e]),t.appendChild(r),t}function R(e,t,r,n){r&&e.setAttribute("aria-invalid","true"),t.required&&e.setAttribute("aria-required","true");let o=[t.description?n.descriptionId:null,r?n.errorId:null].filter(Boolean).join(" ");o&&e.setAttribute("aria-describedby",o)}function D(e,t,r,n){let o=d("div",{className:`fillo-field fillo-field--${e.kind}${t?" fillo-field--error":""}`,attrs:{"data-field":e.id}}),i=d("label",{className:"fillo-label",text:e.label,attrs:{id:n.labelId,for:n.inputId}});return e.required||i.appendChild(d("span",{className:"fillo-optional",text:" (optional)"})),o.appendChild(i),e.description&&o.appendChild(d("p",{className:"fillo-description",text:e.description,attrs:{id:n.descriptionId}})),o.appendChild(r),t&&o.appendChild(d("p",{className:"fillo-error",text:t,attrs:{role:"alert",id:n.errorId}})),o}function we(e,t){let r=d("input",{className:"fillo-input",attrs:{id:t.ids.inputId,type:e}});return r.value=Zt(t.value),t.field.placeholder&&(r.placeholder=t.field.placeholder),r.addEventListener("input",()=>t.setValue(r.value,{render:!1})),r.addEventListener("change",()=>t.setValue(r.value)),R(r,t.field,t.error,t.ids),D(t.field,t.error,r,t.ids)}function Mo(){if(typeof navigator>"u")return;let t=(navigator.languages?.[0]||navigator.language||"").split("-")[1];return t&&/^[A-Za-z]{2}$/.test(t)?t.toUpperCase():void 0}function To(){if(!(typeof Intl>"u"))try{let e=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof e=="string"&&e?e:void 0}catch{return}}function Lo(e,t){if(t<=0)return e.setSelectionRange(0,0);let r=e.value,n=0,o=r.length;for(let i=0;i<r.length;i++)if(/\d/.test(r[i])&&++n===t){o=i+1;break}e.setSelectionRange(o,o)}var Oo=8;function Ro(e,t){if(typeof window>"u")return"below";let r=Oo,n=document.documentElement.clientWidth||window.innerWidth,o=document.documentElement.clientHeight||window.innerHeight,i=e.getBoundingClientRect(),s=Math.max(0,o-i.bottom-r),a=Math.max(0,i.top-r),c=s<t.scrollHeight&&a>s?"above":"below",l=Math.max(0,Math.min(c==="above"?a:s,o-r*2)),p=Math.max(0,n-r*2);t.style.setProperty("--fillo-phone-popover-max-height",`${Math.floor(l)}px`),t.style.setProperty("--fillo-phone-popover-max-width",`${Math.floor(p)}px`),t.style.setProperty("--fillo-phone-popover-offset-x","0px");let f=Math.min(t.offsetWidth,p),h=0,g=i.left+f-(n-r);g>0&&(h-=g);let b=r-(i.left+h);return b>0&&(h+=b),t.style.setProperty("--fillo-phone-popover-offset-x",`${Math.round(h)}px`),c}function Do(e){let t=e.field,r=Be(Zt(e.value)).country??Ue(t.defaultCountry)??Or(To())??Ue(Mo())??q[0],n=d("div",{className:"fillo-phone"}),o=d("div",{className:"fillo-phone-country"}),i=d("button",{className:"fillo-phone-flag",attrs:{type:"button","aria-haspopup":"listbox","aria-expanded":"false"}}),s=d("span",{className:"fillo-phone-flag-emoji",attrs:{"aria-hidden":"true"}}),a=d("span",{className:"fillo-phone-dial"});k(i,[s,a,d("span",{className:"fillo-phone-caret",text:"\u25BE",attrs:{"aria-hidden":"true"}})]),k(o,[i]);let c=d("input",{className:"fillo-input fillo-phone-input",attrs:{id:e.ids.inputId,type:"tel",inputmode:"tel",autocomplete:"tel-national"}});R(c,e.field,e.error,e.ids);let u=()=>{let x=W(Zt(e.value));return x.startsWith(r.dialCode)?x.slice(r.dialCode.length):x},l=()=>{s.textContent=xt(r.iso2),a.textContent=`+${r.dialCode}`,i.setAttribute("aria-label",`Country: ${r.name} (+${r.dialCode})`)},p=()=>{c.value=je(r,u()),c.placeholder=je(r,r.example)},f=x=>e.setValue(x?Rr(r,x):"",{render:!1});l(),p(),c.addEventListener("input",()=>{let x=c.value,T=c.selectionStart??x.length,v=W(x.slice(0,T)).length;if(x.trimStart().startsWith("+")){let y=Be(x);y.country&&(r=y.country,l()),f(y.country?y.national:W(x))}else f(W(x));c.value=je(r,u()),Lo(c,v)});let h=e.registerOverlay,g=null,b=0,E=q,H=null,ie=null,U=`${e.ids.inputId}-countries`,A=()=>{if(!g)return;let x=Ro(o,g);g.classList.toggle("fillo-phone-popover--above",x==="above"),g.classList.toggle("fillo-phone-popover--below",x==="below")},ze=()=>{H?.();let x=()=>A();A(),window.addEventListener("resize",x),window.addEventListener("scroll",x,!0),H=()=>{window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0)}},te=()=>{H?.(),H=null,g?.remove(),g=null,i.setAttribute("aria-expanded","false"),document.removeEventListener("mousedown",ke),ie?.(),ie=null},ke=x=>{o.contains(x.target)||te()},Ee=x=>{x&&(r=x,l(),f(u()),p(),te(),c.focus())},qe=()=>{let x=d("div",{className:"fillo-phone-popover fillo-phone-popover--below"}),T=d("input",{className:"fillo-phone-search",attrs:{type:"text",role:"combobox","aria-expanded":"true","aria-controls":U,"aria-autocomplete":"list",placeholder:"Search country or code"}}),v=d("ul",{className:"fillo-phone-list",attrs:{role:"listbox",id:U,"aria-label":"Country"}}),y=()=>{if(v.replaceChildren(),E.length===0){v.appendChild(d("li",{className:"fillo-phone-empty",text:"No matches"})),A();return}E.forEach((z,j)=>{let G=d("li",{className:`fillo-phone-option${j===b?" fillo-phone-option--active":""}`,attrs:{id:`${U}-opt-${j}`,role:"option","aria-selected":String(z.iso2===r.iso2)}});k(G,[d("span",{className:"fillo-phone-flag-emoji",text:xt(z.iso2),attrs:{"aria-hidden":"true"}}),d("span",{className:"fillo-phone-option-name",text:z.name}),d("span",{className:"fillo-phone-option-dial",text:`+${z.dialCode}`})]),G.addEventListener("mouseenter",()=>{b=j,T.setAttribute("aria-activedescendant",G.id),$()}),G.addEventListener("mousedown",ce=>{ce.preventDefault(),Ee(z)}),v.appendChild(G)}),T.setAttribute("aria-activedescendant",`${U}-opt-${b}`),A()},$=()=>{[...v.children].forEach((z,j)=>z.classList.toggle("fillo-phone-option--active",j===b)),document.getElementById(`${U}-opt-${b}`)?.scrollIntoView({block:"nearest"})},P=z=>{let j=z.trim().toLowerCase(),G=j.replace(/[^\d]/g,"");E=j?q.filter(ce=>ce.name.toLowerCase().includes(j)||ce.iso2.toLowerCase()===j||G.length>0&&ce.dialCode.startsWith(G)):q,b=0,y()};T.addEventListener("input",()=>P(T.value)),T.addEventListener("keydown",z=>{z.key==="ArrowDown"?(z.preventDefault(),b=Math.min(b+1,E.length-1),$(),T.setAttribute("aria-activedescendant",`${U}-opt-${b}`)):z.key==="ArrowUp"?(z.preventDefault(),b=Math.max(b-1,0),$(),T.setAttribute("aria-activedescendant",`${U}-opt-${b}`)):z.key==="Enter"?(z.preventDefault(),Ee(E[b])):z.key==="Escape"&&(z.preventDefault(),te(),i.focus())}),k(x,[T,v]),g=x,o.appendChild(x),i.setAttribute("aria-expanded","true"),E=q,b=Math.max(0,q.indexOf(r)),y(),ze(),$(),document.addEventListener("mousedown",ke),ie=h?.(te)??null,requestAnimationFrame(()=>T.focus())};return i.addEventListener("click",()=>g?te():qe()),k(n,[o,c]),D(e.field,e.error,n,e.ids)}function Uo(e){let t=d("textarea",{className:"fillo-input fillo-textarea",attrs:{id:e.ids.inputId,rows:"4"}});return t.value=typeof e.value=="string"?e.value:"",e.field.placeholder&&(t.placeholder=e.field.placeholder),t.addEventListener("input",()=>e.setValue(t.value,{render:!1})),t.addEventListener("change",()=>e.setValue(t.value)),R(t,e.field,e.error,e.ids),D(e.field,e.error,t,e.ids)}function jo(e){let t=e.field,r=It(t),n=typeof e.value=="string"?e.value:"",o=e.activeOtherFields,i=n!==""&&!t.options.some(c=>c.id===n),s=i||n===""&&o?.has(t.id)===!0,a=d("div",{className:"fillo-options",attrs:{role:"radiogroup","aria-labelledby":e.ids.labelId}});R(a,t,e.error,e.ids);for(let c of r){let u=d("label",{className:`fillo-option${c.icon?" fillo-option--has-icon":""}${n===c.id?" fillo-option--selected":""}`,attrs:{"data-option":c.id}}),l=d("input",{className:"fillo-option-input",attrs:{type:"radio",name:e.ids.name}});l.checked=n===c.id,l.addEventListener("change",()=>{o?.delete(t.id),e.setValue(c.id)}),k(u,[l,sn(c.icon),d("span",{className:"fillo-option-label",text:c.label})]),a.appendChild(u)}if(t.allowOther){let c=d("label",{className:`fillo-option fillo-option--other${s?" fillo-option--selected fillo-option--with-other":""}`}),u=d("input",{className:"fillo-option-input",attrs:{type:"radio",name:e.ids.name}});if(u.checked=s,u.addEventListener("change",()=>{o?.add(t.id),e.setValue("",{render:!0})}),k(c,[k(d("span",{className:"fillo-option-main"}),[u,d("span",{className:"fillo-option-label",text:"Other"})])]),s){let l=d("input",{className:"fillo-input fillo-other-input",attrs:{type:"text"}});l.value=i?n:"",l.placeholder="Your answer",l.addEventListener("input",()=>{o?.add(t.id),e.setValue(l.value,{render:!1})}),l.addEventListener("change",()=>{o?.add(t.id),e.setValue(l.value)}),c.appendChild(l),i||queueMicrotask(()=>l.focus())}a.appendChild(c)}return D(t,e.error,a,e.ids)}function Bo(e){let t=e.field,r=It(t),n=Array.isArray(e.value)?e.value:[],o=new Set(t.options.map(l=>l.id)),i=n.find(l=>!o.has(l)),s=e.activeOtherFields,a=()=>{let l=e.getValue?.()??e.value;return Array.isArray(l)?l:[]},c=d("div",{className:"fillo-options",attrs:{role:"group","aria-labelledby":e.ids.labelId}});R(c,t,e.error,e.ids);let u=l=>e.setValue(l);for(let l of r){let p=d("label",{className:`fillo-option${l.icon?" fillo-option--has-icon":""}${n.includes(l.id)?" fillo-option--selected":""}`,attrs:{"data-option":l.id}}),f=d("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});f.checked=n.includes(l.id),f.addEventListener("change",()=>{let h=a();u(f.checked?[...h,l.id]:h.filter(g=>g!==l.id))}),k(p,[f,sn(l.icon),d("span",{className:"fillo-option-label",text:l.label})]),c.appendChild(p)}if(t.allowOther){let l=i!==void 0||s?.has(t.id)===!0,p=d("label",{className:`fillo-option fillo-option--other${l?" fillo-option--selected fillo-option--with-other":""}`}),f=d("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});if(f.checked=l,f.addEventListener("change",()=>{let h=a().filter(g=>o.has(g));f.checked?(s?.add(t.id),u(h)):(s?.delete(t.id),u(h))}),k(p,[k(d("span",{className:"fillo-option-main"}),[f,d("span",{className:"fillo-option-label",text:"Other"})])]),l){let h=d("input",{className:"fillo-input fillo-other-input",attrs:{type:"text"}});h.value=i??"",h.placeholder="Your answer",h.addEventListener("input",()=>{s?.add(t.id);let g=a().filter(b=>o.has(b));e.setValue(h.value?[...g,h.value]:g,{render:!1})}),h.addEventListener("change",()=>{s?.add(t.id);let g=a().filter(b=>o.has(b));e.setValue(h.value?[...g,h.value]:g)}),p.appendChild(h),i===void 0&&queueMicrotask(()=>h.focus())}c.appendChild(p)}return D(t,e.error,c,e.ids)}var Pt="__fillo_other__";function Vo(e){let t=e.field,r=typeof e.value=="string"?e.value:"",n=e.activeOtherFields,o=r!==""&&!t.options.some(u=>u.id===r),i=o||r===""&&n?.has(t.id)===!0,s=d("div"),a=d("div",{className:"fillo-select-wrap"}),c=d("select",{className:"fillo-input fillo-select",attrs:{id:e.ids.inputId}});c.appendChild(d("option",{text:t.placeholder??"Choose...",attrs:{value:""}}));for(let u of It(t))c.appendChild(d("option",{text:u.label,attrs:{value:u.id}}));if(t.allowOther&&c.appendChild(d("option",{text:"Other...",attrs:{value:Pt}})),c.value=i?Pt:r,c.addEventListener("change",()=>{c.value===Pt?(n?.add(t.id),e.setValue("",{render:!0})):(n?.delete(t.id),e.setValue(c.value||null))}),R(c,t,e.error,e.ids),k(a,[c,d("span",{className:"fillo-select-icon",attrs:{"aria-hidden":"true"}})]),s.appendChild(a),i){let u=d("input",{className:"fillo-input fillo-other-input fillo-other-input--block",attrs:{type:"text"}});u.value=o?r:"",u.placeholder="Your answer",u.addEventListener("input",()=>{n?.add(t.id),e.setValue(u.value,{render:!1})}),u.addEventListener("change",()=>{n?.add(t.id),e.setValue(u.value)}),s.appendChild(u),o||queueMicrotask(()=>u.focus())}return D(t,e.error,s,e.ids)}function Ho(e){if(e.field.kind==="checkbox"&&e.field.appearance==="toggle"){let i=d("div",{className:`fillo-field fillo-field--checkbox fillo-field--toggle${e.error?" fillo-field--error":""}`,attrs:{"data-field":e.field.id}}),s=d("label",{className:"fillo-toggle"}),a=d("span",{className:"fillo-option-label",text:e.field.label});e.field.required||a.appendChild(d("span",{className:"fillo-optional",text:" (optional)"}));let c=d("span",{className:"fillo-toggle-copy"});c.appendChild(a);let u=d("input",{className:"fillo-toggle-input",attrs:{id:e.ids.inputId,type:"checkbox",role:"switch","aria-checked":String(e.value===!0)}});return u.checked=e.value===!0,u.addEventListener("change",()=>{u.setAttribute("aria-checked",String(u.checked)),e.setValue(u.checked)}),R(u,e.field,e.error,e.ids),k(s,[c,u,k(d("span",{className:"fillo-toggle-track",attrs:{"aria-hidden":"true"}}),[d("span",{className:"fillo-toggle-thumb"})])]),i.appendChild(s),e.field.description&&i.appendChild(d("p",{className:"fillo-description",text:e.field.description,attrs:{id:e.ids.descriptionId}})),e.error&&i.appendChild(d("p",{className:"fillo-error",text:e.error,attrs:{role:"alert",id:e.ids.errorId}})),i}let t=d("div",{className:`fillo-field fillo-field--checkbox${e.error?" fillo-field--error":""}`,attrs:{"data-field":e.field.id}}),r=d("label",{className:"fillo-option"}),n=d("input",{className:"fillo-option-input",attrs:{id:e.ids.inputId,type:"checkbox"}});n.checked=e.value===!0,n.addEventListener("change",()=>e.setValue(n.checked)),R(n,e.field,e.error,e.ids);let o=d("span",{className:"fillo-option-label",text:e.field.label});return e.field.required||o.appendChild(d("span",{className:"fillo-optional",text:" (optional)"})),k(r,[n,o]),t.appendChild(r),e.field.description&&t.appendChild(d("p",{className:"fillo-description",text:e.field.description,attrs:{id:e.ids.descriptionId}})),e.error&&t.appendChild(d("p",{className:"fillo-error",text:e.error,attrs:{role:"alert",id:e.ids.errorId}})),t}function Ko(e){if(e.field.kind!=="rating")return d("div");let t=typeof e.field.max=="number"?e.field.max:5,r=typeof e.value=="number"?e.value:0,n=d("div",{className:"fillo-rating",attrs:{role:"group","aria-label":e.field.label}});R(n,e.field,e.error,e.ids);for(let o=1;o<=t;o++){let i=d("button",{className:`fillo-star${o<=r?" fillo-star--active":""}`,text:"*",attrs:{type:"button","aria-label":`${o} of ${t}`,"aria-pressed":String(o===r)}});i.addEventListener("click",()=>e.setValue(o===r?null:o)),n.appendChild(i)}return D(e.field,e.error,n,e.ids)}function qo(e){if(e.field.kind!=="linear_scale")return d("div");let t=typeof e.field.min=="number"?e.field.min:1,r=typeof e.field.max=="number"?e.field.max:10,n=d("div"),o=d("div",{className:"fillo-scale",attrs:{role:"group","aria-label":e.field.label}});R(o,e.field,e.error,e.ids);for(let i=t;i<=r;i++){let s=d("button",{className:`fillo-scale-step${e.value===i?" fillo-scale-step--active":""}`,text:String(i),attrs:{type:"button","aria-pressed":String(e.value===i)}});s.addEventListener("click",()=>e.setValue(e.value===i?null:i)),o.appendChild(s)}return n.appendChild(o),("minLabel"in e.field||"maxLabel"in e.field)&&k(n,[k(d("div",{className:"fillo-scale-labels"}),[d("span",{text:String(e.field.minLabel??"")}),d("span",{text:String(e.field.maxLabel??"")})])]),D(e.field,e.error,n,e.ids)}function Wo(e){let t=e.field;if(t.kind!=="ranking")return null;let r=Array.isArray(e.value)?e.value:[],n=[...r.filter(i=>t.options.some(s=>s.id===i)),...t.options.map(i=>i.id).filter(i=>!r.includes(i))],o=d("ol",{className:"fillo-ranking"});for(let[i,s]of n.entries()){let a=t.options.find(h=>h.id===s);if(!a)continue;let c=d("li",{className:"fillo-ranking-item"}),u=d("span",{className:"fillo-ranking-controls"}),l=h=>{let g=i+h;if(g<0||g>=n.length)return;let b=[...n];[b[i],b[g]]=[b[g],b[i]],e.setValue(b)},p=d("button",{className:"fillo-ranking-move",text:"Up",attrs:{type:"button","data-fillo-rank-opt":s,"data-fillo-rank-dir":"up"}});p.toggleAttribute("disabled",i===0),p.addEventListener("click",()=>l(-1));let f=d("button",{className:"fillo-ranking-move",text:"Down",attrs:{type:"button","data-fillo-rank-opt":s,"data-fillo-rank-dir":"down"}});f.toggleAttribute("disabled",i===n.length-1),f.addEventListener("click",()=>l(1)),k(u,[p,f]),k(c,[d("span",{className:"fillo-ranking-index",text:String(i+1)}),d("span",{className:"fillo-ranking-label",text:a.label}),u]),o.appendChild(c)}return D(e.field,e.error,o,e.ids)}function Go(e){let t=e.field;if(t.kind!=="matrix")return null;let r=e.value&&typeof e.value=="object"&&!Array.isArray(e.value)?e.value:{},n=d("table",{className:"fillo-matrix"}),o=document.createElement("thead"),i=document.createElement("tr");i.appendChild(document.createElement("th"));for(let a of t.columns)i.appendChild(d("th",{text:a.label,attrs:{scope:"col"}}));o.appendChild(i),n.appendChild(o);let s=document.createElement("tbody");for(let a of t.rows){let c=document.createElement("tr");c.appendChild(d("th",{text:a.label,attrs:{scope:"row"}}));for(let u of t.columns){let l=document.createElement("td"),p=d("input",{className:"fillo-option-input",attrs:{type:"radio",name:`${e.ids.name}-${a.id}`,"aria-label":`${a.label}: ${u.label}`}});p.checked=r[a.id]===u.id,p.addEventListener("change",()=>e.setValue({...r,[a.id]:u.id})),l.appendChild(p),c.appendChild(l)}s.appendChild(c)}return n.appendChild(s),D(e.field,e.error,k(d("div",{className:"fillo-matrix-wrap"}),[n]),e.ids)}function Jo(e){let t=d("div",{className:"fillo-signature-field"}),r=d("div",{className:"fillo-signature"}),n=d("canvas",{className:"fillo-signature-canvas",attrs:{"aria-hidden":"true"}}),o=d("button",{className:"fillo-signature-clear",text:"Clear",attrs:{type:"button"}}),i=d("div",{className:"fillo-signature-hint",text:"Sign here",attrs:{"aria-hidden":"true"}});n.width=720,n.height=220;let s=n.getContext("2d"),a=!1,c=typeof e.value=="string"&&e.value.startsWith("data:image/");if(c&&s){let g=new Image;g.onload=()=>s.drawImage(g,0,0,n.width,n.height),g.src=String(e.value),i.style.display="none"}let u=d("input",{className:"fillo-input fillo-signature-type-input",attrs:{id:e.ids.inputId,type:"text",autocomplete:"name",placeholder:"Type your full name to sign"}});R(u,e.field,e.error,e.ids);let l=g=>{s&&(s.clearRect(0,0,n.width,n.height),g.trim()?(s.fillStyle=getComputedStyle(n).color||"#18181b",s.font=`italic ${Math.min(96,n.height*.45)}px "Segoe Script", "Brush Script MT", cursive`,s.textBaseline="middle",s.fillText(g,24,n.height/2),c=!0,i.style.display="none",e.setValue(n.toDataURL("image/png"),{render:!1})):(c=!1,i.style.display="",e.setValue(null,{render:!1})))};u.addEventListener("input",()=>l(u.value));let p=g=>{let b=n.getBoundingClientRect();return{x:(g.clientX-b.left)/b.width*n.width,y:(g.clientY-b.top)/b.height*n.height}};n.addEventListener("pointerdown",g=>{if(!s)return;a=!0,c=!0,i.style.display="none",u.value&&(u.value=""),n.setPointerCapture(g.pointerId);let b=p(g);s.beginPath(),s.moveTo(b.x,b.y)}),n.addEventListener("pointermove",g=>{if(!a||!s)return;let b=p(g);s.lineWidth=2.4,s.lineCap="round",s.strokeStyle=getComputedStyle(n).color||"#18181b",s.lineTo(b.x,b.y),s.stroke()});let f=()=>{a&&(a=!1,c&&e.setValue(n.toDataURL("image/png"),{render:!1}))};n.addEventListener("pointerup",f),n.addEventListener("pointercancel",f),o.addEventListener("click",()=>{s?.clearRect(0,0,n.width,n.height),c=!1,i.style.display="",u.value="",e.setValue(null,{render:!1})}),k(r,[n,i,o]);let h=d("div",{className:"fillo-signature-type"});return h.appendChild(u),k(t,[r,h]),D(e.field,e.error,t,e.ids)}function Xo(e){let t=e.field;if(t.kind!=="file_upload")return null;let r=d("input",{className:"fillo-input",attrs:{id:e.ids.inputId,type:"file"}});(t.maxFiles??1)>1&&(r.multiple=!0),t.accept?.length&&(r.accept=t.accept.join(",")),R(r,t,e.error,e.ids),r.addEventListener("change",()=>{let a=Array.from(r.files??[]);e.uploadFiles?.(t,a)});let n=d("div");n.appendChild(r);let o=e.uploadProgress?.get(t.id);if(o!==void 0){let a=d("div",{className:"fillo-upload-progress"});a.appendChild(d("div",{className:"fillo-upload-progress-fill"})),a.firstElementChild?.style.setProperty("width",`${Math.round(o*100)}%`),n.appendChild(a)}let i=Array.isArray(e.value)?e.value:[];for(let a of i)n.appendChild(d("p",{className:"fillo-description",text:`${a.name} (${Math.round(a.size/1024)} KB)`}));let s=e.uploadNotice;return s&&n.appendChild(d("p",{className:"fillo-upload-notice",text:s,attrs:{role:"status"}})),D(t,e.error,n,e.ids)}var rn=new Map;function It(e){if(!e.shuffleOptions)return e.options;let t=`${e.id}|${e.options.map(i=>i.id).join(",")}`,r=rn.get(t);if(!r){r=e.options.map(i=>i.id);for(let i=r.length-1;i>0;i--){let s=Math.floor(Math.random()*(i+1));[r[i],r[s]]=[r[s],r[i]]}rn.set(t,r)}let n=new Map(e.options.map(i=>[i.id,i])),o=r.flatMap(i=>n.get(i)??[]);return o.length===e.options.length?o:e.options}var Yo={short_text:e=>we("text",e),email:e=>we("email",e),url:e=>we("url",e),phone:Do,number:e=>we("number",e),date:e=>we("date",e),long_text:Uo,select:jo,multi_select:Bo,dropdown:Vo,checkbox:Ho,rating:Ko,linear_scale:qo,ranking:Wo,matrix:Go,signature:Jo,file_upload:Xo};function Qo(e){if(e.field.kind==="hidden"||e.field.kind==="custom")return null;let t=Yo[e.field.kind];return t?t(e):null}var $e=class{constructor(t,r){this.target=t;this.options=r;this.element.className="fillo-dom-root",t.replaceChildren(this.element),this.resolve()}target;options;element=d("div");instanceId=`d${++Po}`;schema=null;theme;formId;closed=!1;fetchedPoweredBy=null;fetchedBrandLabel;fetchedBrandHref;phase="loading";engine=null;destroyed=!1;renderQueued=!1;hpValue="";activeOtherFields=new Set;uploadProgress=new Map;uploadNotices=new Map;focusIntent=null;overlays=new Set;get status(){return this.phase==="ready"?this.engine?.getState().status??"idle":this.phase}get data(){return this.engine?.getState().data??this.options.initialData??{}}get form(){return this.schema}get mutableData(){return this.engine?.getState().data??this.options.initialData??{}}api(){let t=this.schema??{version:1,title:"",pages:[],settings:{}},r=this.engine?.getState(),n=r?.pageCount??t.pages.length;return{form:t,formId:this.formId,client:this.options.client,data:r?.data??this.mutableData,errors:r?.errors??{},status:this.status,pageIndex:r?.pageIndex??0,pageCount:n,page:r?.page??t.pages[0]??{id:"empty",blocks:[]},blocks:r?.blocks??[],isFirstPage:r?.isFirstPage??!0,isLastPage:r?.isLastPage??n<=1,setValue:(o,i,s)=>this.setValueInternal(o,i,s),next:()=>this.next(),back:()=>this.back(),submit:()=>this.submit()}}resolveFormIdFn;notLive=!1;async resolve(){try{let t=St(this.options.form)?this.options.form:null;if(t){let o=this.options.client;o?.key&&(this.resolveFormIdFn=()=>Ct(o,t,{bypassCache:!0}).then(i=>i.formId)),this.setSchema(t.schema,this.options.theme??t.theme,this.options.formId),o?.key&&Ct(o,t).then(({formId:i,branding:s,staged:a,status:c,warning:u})=>{this.formId=i,this.engine?.setContext({formId:i}),u&&console.warn(`[fillo] ${u}`),a?console.info(`[fillo] "${t.id}" changes staged as a draft \u2014 publish them in your Fillo dashboard`):c==="draft"&&(console.info(`[fillo] "${t.id}" is a draft \u2014 it renders here but won't accept responses until published`),on()||(this.notLive=!0,this.render())),s&&(this.fetchedPoweredBy=s.poweredBy,this.fetchedBrandLabel=s.label,this.fetchedBrandHref=s.href,this.render())}).catch(i=>{let s=He(i);console.warn("[fillo] form sync failed:",s.message),this.options.onError?.(s)});return}let r=this.options.form&&!St(this.options.form)?this.options.form:null;if(r){this.setSchema(r,this.options.theme,this.options.formId);return}if(!this.options.formId)throw new w("Provide either `form`, or a `formId`.",0);this.options.client??=_e(),this.render();let n=await this.options.client.getForm(this.options.formId);this.closed=!!n.closed,this.fetchedPoweredBy=n.branding?.poweredBy??null,this.fetchedBrandLabel=n.branding?.label,this.fetchedBrandHref=n.branding?.href,this.setSchema(n.schema,this.options.theme??n.theme??void 0,n.id)}catch(t){this.handleError(He(t))}}setSchema(t,r,n){let o=ye(t);if(!o.ok)throw new w(`This form could not be rendered: ${o.error}`,422);let i=o.schema;this.schema=i,this.theme=r,this.formId=n,this.engine=Gr({form:i,formId:n,client:this.options.client,initialData:this.options.initialData,onChange:this.options.onChange,onSubmitted:this.options.onSubmitted,getHoneypot:()=>this.hpValue,surface:"default",resolveFormId:this.resolveFormIdFn});let s=this.engine.getState().status;this.engine.subscribe(()=>{let a=this.engine?.getState().status;a!==void 0&&a!==s&&(s=a,this.queueRender())}),this.phase=this.closed?"closed":"ready",this.render()}setValue(t,r){this.setValueInternal(t,r)}setValueInternal(t,r,n={}){this.engine?.setValue(t,r),n.render!==!1&&this.queueRender()}next(){if(!this.engine)return;let t=this.engine.getState().pageIndex;this.engine.next(),this.focusIntent=this.engine.getState().pageIndex!==t?"page":"error",this.render()}back(){this.engine&&(this.engine.back(),this.focusIntent="page",this.render())}async submit(){if(!this.engine||this.phase!=="ready")return;let t=this.engine.submit();this.hasErrors()&&(this.focusIntent="error"),this.render();try{await t}catch(r){this.options.onError?.(He(r)),this.focusIntent="error",this.render();return}this.hasErrors()&&(this.focusIntent="error"),this.render()}hasErrors(){return Object.keys(this.engine?.getState().errors??{}).length>0}setTheme(t){this.options.theme=t,this.theme=t,this.render()}setClient(t){this.options.client=t,this.engine?.setContext({client:t}),this.render()}async uploadFiles(t,r){if(!this.schema)return;let n=t.maxFiles??1,o=n>1&&Array.isArray(this.mutableData[t.id])?[...this.mutableData[t.id]]:[],i=Math.max(0,n-o.length),s=r.slice(0,i),a=r.length-s.length;if(a>0?this.uploadNotices.set(t.id,`You can attach up to ${n} file${n===1?"":"s"}. ${a} ${a===1?"file was":"files were"} not added.`):this.uploadNotices.delete(t.id),s.length===0){this.queueRender();return}this.uploadProgress.set(t.id,0),this.queueRender();try{let c=[];for(let[u,l]of s.entries())this.options.client&&this.formId?c.push(await this.options.client.uploadFile(this.formId,l,{fieldId:t.id,onProgress:p=>{this.uploadProgress.set(t.id,(u+p.fraction)/s.length),this.queueRender()}})):c.push({fileId:`local:${l.name}:${l.size}`,name:l.name,size:l.size,mime:l.type||"application/octet-stream"});this.uploadProgress.delete(t.id),this.setValueInternal(t.id,[...o,...c])}catch(c){this.uploadProgress.delete(t.id),this.handleError(He(c))}}destroy(){this.destroyed=!0,this.closeOverlays(),this.target.replaceChildren()}registerOverlay=t=>(this.overlays.add(t),()=>this.overlays.delete(t));closeOverlays(){if(this.overlays.size!==0){for(let t of Array.from(this.overlays))try{t()}catch{}this.overlays.clear()}}captureFocus(){if(typeof document>"u")return null;let t=document.activeElement;if(!t||!this.element.contains(t))return null;let r={};t.id&&(r.id=t.id);let n=t.getAttribute("data-fillo-rank-opt");n&&(r.rankOpt=n,r.rankDir=t.getAttribute("data-fillo-rank-dir")??void 0);let o=t.closest("[data-field]");if(o&&(r.fieldId=o.getAttribute("data-field")??void 0,r.controlIndex=Array.from(o.querySelectorAll(en)).indexOf(t)),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)try{r.selStart=t.selectionStart,r.selEnd=t.selectionEnd}catch{}return r.id||r.rankOpt||r.fieldId?r:null}restoreFocus(t){if(typeof document>"u")return;let r=null;if(t.rankOpt){let n=Array.from(this.element.querySelectorAll("[data-fillo-rank-opt]")).filter(o=>o.getAttribute("data-fillo-rank-opt")===t.rankOpt);r=n.find(o=>o.getAttribute("data-fillo-rank-dir")===t.rankDir&&!o.disabled)??n.find(o=>!o.disabled)??null}if(!r&&t.id&&(r=document.getElementById(t.id)),!r&&t.fieldId!=null&&t.controlIndex!=null&&t.controlIndex>=0){let n=Array.from(this.element.querySelectorAll("[data-field]")).find(o=>o.getAttribute("data-field")===t.fieldId);n&&(r=Array.from(n.querySelectorAll(en))[t.controlIndex]??null)}if(!(!r||typeof r.focus!="function")&&(r.focus(),(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&t.selStart!=null))try{r.setSelectionRange(t.selStart,t.selEnd??t.selStart)}catch{}}applyFocus(t,r){if(!(typeof document>"u")){if(t==="error"){this.element.querySelector('[aria-invalid="true"]')?.focus?.();return}if(t==="page"){let o=this.element.querySelector(".fillo-page-title, .fillo-title")??this.element.querySelector(".fillo-blocks");o&&(o.hasAttribute("tabindex")||o.setAttribute("tabindex","-1"),o.focus?.());return}r&&this.restoreFocus(r)}}handleError(t){this.phase="error",this.options.onError?.(t),this.render(t)}queueRender(){this.renderQueued||this.destroyed||(this.renderQueued=!0,queueMicrotask(()=>{this.renderQueued=!1,this.render()}))}render(t){if(this.destroyed)return;let r=this.focusIntent;this.focusIntent=null;let n=r?null:this.captureFocus();if(this.closeOverlays(),this.element.replaceChildren(),this.phase==="loading"){let o=d("div",{className:`fillo-form fillo-form--loading ${this.options.className??""}`,attrs:{"aria-busy":"true"}});xe(o,this.theme),k(o,[d("div",{className:"fillo-skeleton"}),d("div",{className:"fillo-skeleton"}),d("div",{className:"fillo-skeleton fillo-skeleton--short"})]),this.element.appendChild(o);return}if(this.phase==="error"&&t){this.element.appendChild(this.options.renderError?.(t)??d("div",{className:"fillo-form fillo-form--error",text:t.message}));return}if(this.phase==="closed"){let o=d("div",{className:`fillo-form fillo-form--closed ${this.options.className??""}`});xe(o,this.theme),o.appendChild(d("p",{className:"fillo-closed",text:"This form is no longer accepting responses."})),this.element.appendChild(o);return}if(this.notLive){let o=d("div",{className:`fillo-form fillo-form--closed ${this.options.className??""}`});xe(o,this.theme),o.appendChild(d("p",{className:"fillo-closed",text:"This form isn't live yet."})),this.element.appendChild(o);return}if(this.schema){if(this.engine?.getState().status==="submitted"){let o=this.api(),i=this.options.renderSuccess?.(o)??ti(this.schema);xe(i,this.theme),this.element.appendChild(i),this.brandingVisible()&&this.element.appendChild(nn(this.fetchedBrandLabel,this.fetchedBrandHref));return}!this.options.client&&on()&&this.element.appendChild(ri()),this.element.appendChild(this.renderForm()),this.brandingVisible()&&this.element.appendChild(nn(this.fetchedBrandLabel,this.fetchedBrandHref)),this.applyFocus(r,n)}}brandingVisible(){return this.fetchedPoweredBy??!0}renderForm(){let t=this.api(),r=d("form",{className:`fillo-form ${this.options.className??""}`});xe(r,this.theme),r.noValidate=!0;let n=()=>{t.isLastPage?this.submit():this.next()};if(r.addEventListener("submit",l=>{l.preventDefault(),n()}),t.pageCount>1&&this.schema?.settings.showProgress!==!1){let l=d("div",{className:"fillo-progress-track",attrs:{role:"progressbar","aria-valuemin":"0","aria-valuemax":String(t.pageCount),"aria-valuenow":String(t.pageIndex+1)}});l.appendChild(d("div",{className:"fillo-progress-fill"})),l.firstElementChild?.style.setProperty("--fillo-progress-value",`${(t.pageIndex+1)/t.pageCount*100}%`),r.appendChild(l)}if(t.pageIndex===0){let l=d("header",{className:"fillo-header"});l.appendChild(d("h1",{className:"fillo-title",text:t.form.title})),t.form.description&&l.appendChild(d("p",{className:"fillo-form-description",text:t.form.description})),r.appendChild(l)}else t.page.title&&r.appendChild(d("h2",{className:"fillo-page-title",text:t.page.title}));let o=d("div",{className:"fillo-blocks"});for(let l of t.blocks){let p=this.renderBlock(Qr(l,this.mutableData,t.form),t);p&&o.appendChild(p)}r.appendChild(o);let i=d("input",{className:"fillo-hp",attrs:{type:"text",name:"fillo_hp_field",tabindex:"-1",autocomplete:"off","aria-hidden":"true"}});i.style.position="absolute",i.style.left="-9999px",i.style.top="auto",i.style.width="1px",i.style.height="1px",i.style.opacity="0",i.style.overflow="hidden",i.style.pointerEvents="none",i.addEventListener("input",()=>{this.hpValue=i.value}),r.appendChild(i);let s=t.status==="error"?"This form can't submit right now. Please try again in a moment.":this.engine?.getState().submitError;s&&r.appendChild(d("p",{className:"fillo-submit-error",attrs:{role:"alert"},text:s}));let c=!(t.form.settings.submitMode==="auto")||!t.isLastPage||Jr(De(t.form,t.data));if(c||t.pageCount>1&&!t.isFirstPage){let l=d("footer",{className:"fillo-footer"});if(t.pageCount>1&&!t.isFirstPage){let p=d("button",{className:"fillo-button fillo-button--ghost",text:"Back",attrs:{type:"button"}});p.addEventListener("click",()=>this.back()),l.appendChild(p)}if(c){let p=d("button",{className:"fillo-button fillo-button--primary",text:t.status==="submitting"?"Submitting...":t.isLastPage?t.form.settings.submitLabel??"Submit":"Next",attrs:{type:"submit"}});p.toggleAttribute("disabled",t.status==="submitting"||this.uploadProgress.size>0),p.addEventListener("click",f=>{f.preventDefault(),n()}),l.appendChild(p)}r.appendChild(l)}return r}renderBlock(t,r){if(!oe(t))return ei(t);let n=(s,a)=>{if(this.setValueInternal(t.id,s,a),a?.render===!1)return;let c={form:r.form,data:r.data,status:r.status,isLastPage:r.isLastPage,uploading:this.uploadProgress.size>0};Xr(t,s,c)&&this.submit()},o={field:t,value:r.data[t.id],error:r.errors[t.id],ids:Zo(this.instanceId,t.id),api:r,setValue:n,uploadFiles:(s,a)=>this.uploadFiles(s,a),uploadProgress:this.uploadProgress,activeOtherFields:this.activeOtherFields,getValue:()=>this.engine?.getState().data[t.id],registerOverlay:this.registerOverlay,uploadNotice:this.uploadNotices.get(t.id)};return(t.kind==="custom"?this.options.customComponents?.[t.component]??this.options.components?.custom:this.options.components?.[t.kind]??Qo)?.(o)??null}};function ei(e){switch(e.kind){case"heading":return d("h3",{className:"fillo-heading",text:e.text});case"paragraph":return d("p",{className:"fillo-paragraph",text:e.text});case"divider":return d("hr",{className:"fillo-divider"})}return d("div")}function ti(e){let t=d("div",{className:"fillo-form fillo-form--success"}),r=d("div",{className:"fillo-success"});return k(r,[d("div",{className:"fillo-success-mark",text:"\u2713",attrs:{"aria-hidden":"true"}}),d("h2",{className:"fillo-success-title",text:e.settings.successTitle??"Thanks!"}),d("p",{className:"fillo-success-message",text:e.settings.successMessage??"Your response has been recorded."})]),t.appendChild(r),t}function nn(e,t){return d("a",{className:"fillo-powered",text:e??"Powered by Fillo",attrs:{href:Io(t),target:"_blank",rel:"noopener noreferrer"}})}function on(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function ri(){return d("div",{className:"fillo-devwarning",text:"No Fillo client connected \u2014 this form is render-only and won't save responses. Pass a client to collect them in Fillo, or forward with webhooks. (Shown only in development.)",attrs:{role:"alert"}})}function He(e){return e instanceof w?e:new w(e instanceof Error?e.message:String(e),0)}function Ke(e,t){let r=typeof e=="string"?document.querySelector(e):e;if(!r)throw new w(`Fillo mount target not found: ${String(e)}`,0);return new $e(r,{...t,initialData:t.initialData??{}})}function an(e){let t=d("div");return Ke(t,e),t}var ni=typeof HTMLElement<"u"?HTMLElement:class{},Ft=class extends ni{instance=null;assignedForm;assignedClient;assignedTheme;assignedInitialData;mounted=!1;mountScheduled=!1;static get observedAttributes(){return["publishable-key","form-id"]}connectedCallback(){this.scheduleMount()}disconnectedCallback(){this.instance?.destroy(),this.instance=null,this.mounted=!1}attributeChangedCallback(){this.mounted&&this.isConnected&&this.scheduleMount()}set form(t){this.assignedForm=t,this.mounted&&this.scheduleMount()}get form(){return this.assignedForm}set client(t){this.assignedClient=t,this.mounted&&this.instance instanceof $e&&this.instance.setClient(t)}set theme(t){this.assignedTheme=t,this.mounted&&this.instance instanceof $e&&this.instance.setTheme(t)}set initialData(t){this.assignedInitialData=t,this.mounted&&this.scheduleMount()}scheduleMount(){this.mountScheduled||(this.mountScheduled=!0,queueMicrotask(()=>{this.mountScheduled=!1,this.isConnected&&this.mount()}))}mount(){this.instance?.destroy();let t=this.getAttribute("publishable-key")??void 0,r=this.getAttribute("form-id")??void 0,n=this.assignedClient??(r||t?_e({key:t}):void 0);this.instance=Ke(this,{form:this.assignedForm,client:n,formId:r,theme:this.assignedTheme,initialData:this.assignedInitialData,onChange:o=>this.dispatchEvent(new CustomEvent("fillo-change",{detail:{data:o}})),onSubmitted:(o,i)=>this.dispatchEvent(new CustomEvent("fillo-submit",{detail:{responseId:o,data:i}})),onError:o=>this.dispatchEvent(new CustomEvent("fillo-error",{detail:{error:o}}))}),this.mounted=!0}};function Nt(e="fillo-form"){typeof customElements>"u"||customElements.get(e)||customElements.define(e,Ft)}typeof customElements<"u"&&Nt();return fn(oi);})();
|
|
1
|
+
"use strict";var Fillo=(()=>{var it=Object.defineProperty;var On=Object.getOwnPropertyDescriptor;var Dn=Object.getOwnPropertyNames;var Un=Object.prototype.hasOwnProperty;var jn=(e,t)=>{for(var r in t)it(e,r,{get:t[r],enumerable:!0})},Bn=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Dn(t))!Un.call(e,n)&&n!==r&&it(e,n,{get:()=>t[n],enumerable:!(o=On(t,n))||o.enumerable});return e};var Vn=e=>Bn(it({},"__esModule",{value:!0}),e);var Mi={};jn(Mi,{FilloClient:()=>Qe,FilloError:()=>z,createClient:()=>Pe,createFormElement:()=>Fn,defineForm:()=>Vt,registerFilloElement:()=>Xt,renderForm:()=>tt});var tr;function k(e,t,r){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,d=Object.keys(l);for(let p=0;p<d.length;p++){let f=d[p];f in a||(a[f]=l[f].bind(a))}}let n=r?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=r?.Parent?new i:this;o(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let d of l._zod.deferred)d();return l}return Object.defineProperty(s,"init",{value:o}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var ee=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(tr=globalThis).__zod_globalConfig??(tr.__zod_globalConfig={});var st=globalThis.__zod_globalConfig;function se(e){return e&&Object.assign(st,e),st}function nr(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function or(e,t){return typeof t=="bigint"?t.toString():t}function ir(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function ct(e){return e==null}function sr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var rr=Symbol("evaluating");function ae(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==rr)return o===void 0&&(o=rr,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}var lt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ut(e){if(Le(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Le(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function dt(e){return ut(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ar=new Set(["string","number","symbol"]);function _e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pt(e,t,r){let o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function T(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function cr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Hn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function xe(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function lr(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ce(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function Me(e){return typeof e=="string"?e:e?.message}function le(e,t,r){let o=e.message?e.message:Me(e.inst?._zod.def?.error?.(e))??Me(t?.error?.(e))??Me(r.customError?.(e))??Me(r.localeError?.(e))??"Invalid input",{inst:n,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=o,t?.reportInput&&(a.input=s),a}function ft(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}var ur=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,or,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},dr=k("$ZodError",ur),we=k("$ZodError",ur,{Parent:Error});var qn=e=>(t,r,o,n)=>{let i=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new ee;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map(c=>le(c,i,se())));throw lt(a,n?.callee),a}return s.value},Re=qn(we),Wn=e=>async(t,r,o,n)=>{let i=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(n?.Err??e)(s.issues.map(c=>le(c,i,se())));throw lt(a,n?.callee),a}return s.value},Oe=Wn(we),Gn=e=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new ee;return i.issues.length?{success:!1,error:new(e??dr)(i.issues.map(s=>le(s,n,se())))}:{success:!0,data:i.value}},$e=Gn(we),Jn=e=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>le(s,n,se())))}:{success:!0,data:i.value}},ke=Jn(we);var pr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Xn="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Yn=new RegExp(`^${Xn}$`);var fr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var mt=/^-?\d+(?:\.\d+)?$/;var me=k("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Qn={number:"number",bigint:"bigint",object:"date"};var hr=k("$ZodCheckGreaterThan",(e,t)=>{me.init(e,t);let r=Qn[typeof t.value];e._zod.onattach.push(o=>{let n=o._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var gr=k("$ZodCheckMaxLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!ct(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{let n=o.value;if(n.length<=t.maximum)return;let s=ft(n);o.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),br=k("$ZodCheckMinLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!ct(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{let n=o.value;if(n.length>=t.minimum)return;let s=ft(n);o.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}});var vr=k("$ZodCheckStringFormat",(e,t)=>{var r,o;me.init(e,t),e._zod.onattach.push(n=>{let i=n._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})});var _r={major:4,minor:4,patch:3};var j=k("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_r;let o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(let n of o)for(let i of n._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(s,a,c)=>{let l=xe(s),d;for(let p of a){if(p._zod.def.when){if(lr(s)||!p._zod.def.when(s))continue}else if(l)continue;let f=s.issues.length,m=p._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new ee;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,s.issues.length!==f&&(l||(l=xe(s,f)))});else{if(s.issues.length===f)continue;l||(l=xe(s,f))}}return d?d.then(()=>s):s},i=(s,a,c)=>{if(xe(s))return s.aborted=!0,s;let l=n(a,o,c);if(l instanceof Promise){if(c.async===!1)throw new ee;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let l=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,s,a)):i(l,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new ee;return c.then(l=>n(l,o,a))}return n(c,o,a)}}ae(e,"~standard",()=>({validate:n=>{try{let i=$e(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return ke(e,n).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),ht=k("$ZodString",(e,t)=>{j.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??fr(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),gt=k("$ZodStringFormat",(e,t)=>{vr.init(e,t),ht.init(e,t)});var kr=k("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=pr),gt.init(e,t)});var zr=k("$ZodNumber",(e,t)=>{j.init(e,t),e._zod.pattern=e._zod.bag.pattern??mt,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let i=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}});var Sr=k("$ZodUnknown",(e,t)=>{j.init(e,t),e._zod.parse=r=>r});function xr(e,t,r){e.issues.length&&t.issues.push(...ce(r,e.issues)),t.value[r]=e.value}var Er=k("$ZodArray",(e,t)=>{j.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let i=[];for(let s=0;s<n.length;s++){let a=n[s],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?i.push(c.then(l=>xr(l,r,s))):xr(c,r,s)}return i.length?Promise.all(i).then(()=>r):r}});function De(e,t,r,o,n,i){let s=r in o;if(e.issues.length){if(n&&i&&!s)return;t.issues.push(...ce(r,e.issues))}if(!s&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?s&&(t.value[r]=void 0):t.value[r]=e.value}function to(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);let r=cr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function ro(e,t,r,o,n,i){let s=[],a=n.keySet,c=n.catchall._zod,l=c.def.type,d=c.optin==="optional",p=c.optout==="optional";for(let f in t){if(f==="__proto__"||a.has(f))continue;if(l==="never"){s.push(f);continue}let m=c.run({value:t[f],issues:[]},o);m instanceof Promise?e.push(m.then(b=>De(b,r,f,t,d,p))):De(m,r,f,t,d,p)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var Ar=k("$ZodObject",(e,t)=>{if(j.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=ir(()=>to(t));ae(e._zod,"propValues",()=>{let a=t.shape,c={};for(let l in a){let d=a[l]._zod;if(d.values){c[l]??(c[l]=new Set);for(let p of d.values)c[l].add(p)}}return c});let n=Le,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=o.value);let l=a.value;if(!n(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};let d=[],p=s.shape;for(let f of s.keys){let m=p[f],b=m._zod.optin==="optional",v=m._zod.optout==="optional",F=m._zod.run({value:l[f],issues:[]},c);F instanceof Promise?d.push(F.then(oe=>De(oe,a,f,l,b,v))):De(F,a,f,l,b,v)}return i?ro(d,l,a,c,o.value,e):d.length?Promise.all(d).then(()=>a):a}});var Cr=k("$ZodRecord",(e,t)=>{j.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!ut(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let a=new Set;for(let l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>le(m,o,se())),input:l,path:[l],inst:e});continue}let p=d.value,f=t.valueType._zod.run({value:n[l],issues:[]},o);f instanceof Promise?i.push(f.then(m=>{m.issues.length&&r.issues.push(...ce(l,m.issues)),r.value[p]=m.value})):(f.issues.length&&r.issues.push(...ce(l,f.issues)),r.value[p]=f.value)}let c;for(let l in n)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&mt.test(a)&&c.issues.length){let p=t.keyType._zod.run({value:Number(a),issues:[]},o);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?r.value[a]=n[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>le(p,o,se())),input:a,path:[a],inst:e});continue}let d=t.valueType._zod.run({value:n[a],issues:[]},o);d instanceof Promise?i.push(d.then(p=>{p.issues.length&&r.issues.push(...ce(a,p.issues)),r.value[c.value]=p.value})):(d.issues.length&&r.issues.push(...ce(a,d.issues)),r.value[c.value]=d.value)}}return i.length?Promise.all(i).then(()=>r):r}});var Pr=k("$ZodEnum",(e,t)=>{j.init(e,t);let r=nr(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter(n=>ar.has(typeof n)).map(n=>typeof n=="string"?_e(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let s=n.value;return o.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),Fr=k("$ZodLiteral",(e,t)=>{if(j.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?_e(o):o?_e(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{let i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}});function wr(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Zr=k("$ZodOptional",(e,t)=>{j.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ae(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ae(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${sr(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,i=t.innerType._zod.run(r,o);return i instanceof Promise?i.then(s=>wr(s,n)):wr(i,n)}return r.value===void 0?r:t.innerType._zod.run(r,o)}});var Ir=k("$ZodDefault",(e,t)=>{j.init(e,t),e._zod.optin="optional",ae(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>$r(i,t)):$r(n,t)}});function $r(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function Nr(e,t){return new e({type:"string",...T(t)})}function Tr(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}function Mr(e,t){return new e({type:"number",checks:[],...T(t)})}function Lr(e){return new e({type:"unknown"})}function bt(e,t){return new hr({check:"greater_than",...T(t),value:e,inclusive:!0})}function vt(e){return bt(0,e)}function L(e,t){return new gr({check:"max_length",...T(t),maximum:e})}function ve(e,t){return new br({check:"min_length",...T(t),minimum:e})}var X=k("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");j.init(e,t),e.def=t,e.type=t.type,e.parse=(r,o)=>Re(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>$e(e,r,o),e.parseAsync=async(r,o)=>Oe(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>ke(e,r,o),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]},{parent:!0}),e.with=e.check,e.clone=(r,o)=>pt(e,r,o),e.brand=()=>e,e.register=((r,o)=>(r.add(e,o),e)),e.apply=r=>r(e)}),Or=k("ZodMiniString",(e,t)=>{ht.init(e,t),X.init(e,t)});function R(e){return Nr(Or,e)}var oo=k("ZodMiniStringFormat",(e,t)=>{gt.init(e,t),Or.init(e,t)}),io=k("ZodMiniEmail",(e,t)=>{kr.init(e,t),oo.init(e,t)});function Ue(e){return Tr(io,e)}var so=k("ZodMiniNumber",(e,t)=>{zr.init(e,t),X.init(e,t)});function Dr(e){return Mr(so,e)}var ao=k("ZodMiniUnknown",(e,t)=>{Sr.init(e,t),X.init(e,t)});function je(){return Lr(ao)}var co=k("ZodMiniArray",(e,t)=>{Er.init(e,t),X.init(e,t)});function ue(e,t){return new co({type:"array",element:e,...T(t)})}var Ur=k("ZodMiniObject",(e,t)=>{Ar.init(e,t),X.init(e,t),ae(e,"shape",()=>t.shape)});function ze(e,t){let r={type:"object",shape:e??{},...T(t)};return new Ur(r)}function yt(e,t){return new Ur({type:"object",shape:e,catchall:je(),...T(t)})}var Rr=k("ZodMiniRecord",(e,t)=>{Cr.init(e,t),X.init(e,t)});function jr(e,t,r){return!t||!t._zod?new Rr({type:"record",keyType:R(),valueType:e,...T(t)}):new Rr({type:"record",keyType:e,valueType:t,...T(r)})}var lo=k("ZodMiniEnum",(e,t)=>{Pr.init(e,t),X.init(e,t),e.options=Object.values(t.entries)});function Br(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new lo({type:"enum",entries:r,...T(t)})}var uo=k("ZodMiniLiteral",(e,t)=>{Fr.init(e,t),X.init(e,t)});function Vr(e,t){return new uo({type:"literal",values:Array.isArray(e)?e:[e],...T(t)})}var po=k("ZodMiniOptional",(e,t)=>{Zr.init(e,t),X.init(e,t)});function B(e){return new po({type:"optional",innerType:e})}var fo=k("ZodMiniDefault",(e,t)=>{Ir.init(e,t),X.init(e,t)});function _t(e,t){return new fo({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():dt(t)}})}var go=["heading","paragraph","divider"];function pe(e){return!go.includes(e.kind)}function xt(e){return e==null?!1:typeof e=="string"?e.trim()!=="":Array.isArray(e)?e.length>0:typeof e=="boolean"?e:typeof e=="object"?Object.keys(e).length>0:!0}function Hr(e,t){return e===t?!0:typeof e=="number"&&typeof t=="string"&&t.trim()!==""?Number(t)===e:typeof t=="number"&&typeof e=="string"&&e.trim()!==""?Number(e)===t:!1}function bo(e,t){let r=t(e.fieldId);switch(e.op){case"answered":return xt(r);case"not_answered":return!xt(r);case"eq":return Array.isArray(r)?r.some(o=>o===e.value):Hr(r,e.value);case"neq":return xt(r)?Array.isArray(r)?!r.some(o=>o===e.value):!Hr(r,e.value):!1;case"contains":return typeof r=="string"?r.toLowerCase().includes(String(e.value??"").toLowerCase()):Array.isArray(r)?r.some(o=>o===e.value):!1;case"gt":return typeof r=="number"&&r>Number(e.value);case"lt":return typeof r=="number"&&r<Number(e.value)}}function on(e,t){return!e.visibleIf||e.visibleIf.length===0?!0:e.visibleIf.every(r=>bo(r,t))}function sn(e,t,r){return o=>t.has(o)&&!r.has(o)?void 0:e[o]}function an(e,t){let r=new Set(e.map(n=>n.id)),o=r;for(let n=0;n<=e.length;n++){let i=sn(t,r,o),s=new Set;for(let a of e)on(a,i)&&s.add(a.id);if(s.size===o.size&&[...s].every(a=>o.has(a)))return s;o=s}return o}function wt(e,t){let r=e.blocks.filter(pe),o=new Set(r.map(i=>i.id)),n=sn(t,o,an(r,t));return e.blocks.filter(i=>on(i,n))}function Nt(e){return e.pages.flatMap(t=>t.blocks.filter(pe))}function vo(e,t){let r=e.responseLimit?.scopeField;if(!r)return null;let o=t[r];return typeof o=="string"||typeof o=="number"?String(o):null}function Ge(e,t){let r=Nt(e),o=an(r,t);return r.filter(n=>o.has(n.id))}var h=(e,t,r,o=[],n=[],i="")=>({iso2:e,name:t,dialCode:r,lengths:o,groups:n,example:i}),re=[h("US","United States","1",[10],[3,3,4],"2015550123"),h("CA","Canada","1",[10],[3,3,4],"5145550123"),h("GB","United Kingdom","44",[10],[4,6],"7400123456"),h("AU","Australia","61",[9],[3,3,3],"412345678"),h("DE","Germany","49",[10,11],[4,7],"15123456789"),h("FR","France","33",[9],[1,2,2,2,2],"612345678"),h("IN","India","91",[10],[5,5],"8123456789"),h("DK","Denmark","45",[8],[2,2,2,2],"32123456"),h("SE","Sweden","46",[9],[2,3,4],"701234567"),h("NO","Norway","47",[8],[3,2,3],"40612345"),h("FI","Finland","358",[9,10],[2,3,4],"412345678"),h("NL","Netherlands","31",[9],[1,4,4],"612345678"),h("BE","Belgium","32",[9],[3,2,2,2],"470123456"),h("ES","Spain","34",[9],[3,3,3],"612345678"),h("IT","Italy","39",[9,10],[3,3,4],"3123456789"),h("PT","Portugal","351",[9],[3,3,3],"912345678"),h("IE","Ireland","353",[9],[2,3,4],"851234567"),h("CH","Switzerland","41",[9],[2,3,2,2],"781234567"),h("AT","Austria","43",[10,11],[3,7],"6641234567"),h("PL","Poland","48",[9],[3,3,3],"512345678"),h("CZ","Czechia","420",[9],[3,3,3],"601123456"),h("GR","Greece","30",[10],[3,3,4],"6912345678"),h("RO","Romania","40",[9],[3,3,3],"712345678"),h("HU","Hungary","36",[9],[2,3,4],"201234567"),h("UA","Ukraine","380",[9],[2,3,2,2],"501234567"),h("RU","Russia","7",[10],[3,3,2,2],"9123456789"),h("TR","Turkey","90",[10],[3,3,2,2],"5012345678"),h("IL","Israel","972",[9],[2,3,4],"501234567"),h("AE","United Arab Emirates","971",[9],[2,3,4],"501234567"),h("SA","Saudi Arabia","966",[9],[2,3,4],"512345678"),h("ZA","South Africa","27",[9],[2,3,4],"711234567"),h("NG","Nigeria","234",[10],[3,3,4],"8021234567"),h("KE","Kenya","254",[9],[3,3,3],"712123456"),h("EG","Egypt","20",[10],[3,3,4],"1001234567"),h("BR","Brazil","55",[10,11],[2,5,4],"11961234567"),h("MX","Mexico","52",[10],[3,3,4],"2221234567"),h("AR","Argentina","54",[10],[4,6],"1123456789"),h("CL","Chile","56",[9],[1,4,4],"221234567"),h("CO","Colombia","57",[10],[3,3,4],"3211234567"),h("PE","Peru","51",[9],[3,3,3],"912345678"),h("CN","China","86",[11],[3,4,4],"13123456789"),h("JP","Japan","81",[10],[2,4,4],"9012345678"),h("KR","South Korea","82",[9,10],[2,4,4],"1023456789"),h("SG","Singapore","65",[8],[4,4],"81234567"),h("HK","Hong Kong","852",[8],[4,4],"51234567"),h("TW","Taiwan","886",[9],[3,3,3],"912345678"),h("MY","Malaysia","60",[9,10],[2,3,4],"123456789"),h("ID","Indonesia","62",[10,11],[3,4,4],"81234567890"),h("TH","Thailand","66",[9],[2,3,4],"812345678"),h("PH","Philippines","63",[10],[3,3,4],"9171234567"),h("VN","Vietnam","84",[9],[3,3,3],"912345678"),h("PK","Pakistan","92",[10],[3,3,4],"3012345678"),h("BD","Bangladesh","880",[10],[2,4,4],"1812345678"),h("NZ","New Zealand","64",[9,10],[2,3,4],"211234567"),h("SK","Slovakia","421",[9],[3,3,3],"912123456"),h("BG","Bulgaria","359",[9],[2,3,4],"481234567"),h("HR","Croatia","385",[8,9],[2,3,4],"921234567"),h("RS","Serbia","381",[8,9],[2,3,4],"601234567"),h("SI","Slovenia","386",[8],[2,3,3],"31234567"),h("LT","Lithuania","370",[8],[3,2,3],"61234567"),h("LV","Latvia","371",[8],[2,3,3],"21234567"),h("EE","Estonia","372",[7,8],[3,4],"51234567"),h("IS","Iceland","354",[7],[3,4],"6111234"),h("LU","Luxembourg","352",[9],[3,3,3],"628123456"),h("MA","Morocco","212",[9],[3,3,3],"650123456"),h("CR","Costa Rica","506",[8],[4,4],"83123456"),h("EC","Ecuador","593",[9],[2,3,4],"991234567"),h("UY","Uruguay","598",[8],[1,3,4],"94231234"),h("QA","Qatar","974",[8],[4,4],"33123456"),h("KW","Kuwait","965",[8],[4,4],"50012345")],yo=new Map(re.map(e=>[e.iso2,e])),_o={"Africa/Cairo":"EG","Africa/Casablanca":"MA","Africa/Johannesburg":"ZA","Africa/Lagos":"NG","Africa/Nairobi":"KE","America/Adak":"US","America/Anchorage":"US","America/Argentina/Buenos_Aires":"AR","America/Argentina/Cordoba":"AR","America/Argentina/Mendoza":"AR","America/Bahia":"BR","America/Belem":"BR","America/Bogota":"CO","America/Boise":"US","America/Boa_Vista":"BR","America/Cancun":"MX","America/Chicago":"US","America/Chihuahua":"MX","America/Campo_Grande":"BR","America/Costa_Rica":"CR","America/Cuiaba":"BR","America/Denver":"US","America/Detroit":"US","America/Edmonton":"CA","America/Fortaleza":"BR","America/Guayaquil":"EC","America/Halifax":"CA","America/Hermosillo":"MX","America/Indiana/Indianapolis":"US","America/Indianapolis":"US","America/Juneau":"US","America/Kentucky/Louisville":"US","America/Lima":"PE","America/Los_Angeles":"US","America/Maceio":"BR","America/Manaus":"BR","America/Matamoros":"MX","America/Mazatlan":"MX","America/Merida":"MX","America/Mexico_City":"MX","America/Moncton":"CA","America/Monterrey":"MX","America/Montevideo":"UY","America/New_York":"US","America/Noronha":"BR","America/Nome":"US","America/North_Dakota/Center":"US","America/Ojinaga":"MX","America/Phoenix":"US","America/Porto_Velho":"BR","America/Punta_Arenas":"CL","America/Recife":"BR","America/Regina":"CA","America/Rio_Branco":"BR","America/Santiago":"CL","America/Sao_Paulo":"BR","America/Sitka":"US","America/St_Johns":"CA","America/Tijuana":"MX","America/Toronto":"CA","America/Vancouver":"CA","America/Whitehorse":"CA","America/Winnipeg":"CA","America/Yakutat":"US","Asia/Bangkok":"TH","Asia/Calcutta":"IN","Asia/Dacca":"BD","Asia/Dhaka":"BD","Asia/Dubai":"AE","Asia/Hong_Kong":"HK","Asia/Ho_Chi_Minh":"VN","Asia/Jakarta":"ID","Asia/Jerusalem":"IL","Asia/Karachi":"PK","Asia/Kolkata":"IN","Asia/Kuala_Lumpur":"MY","Asia/Kuwait":"KW","Asia/Manila":"PH","Asia/Qatar":"QA","Asia/Riyadh":"SA","Asia/Seoul":"KR","Asia/Shanghai":"CN","Asia/Saigon":"VN","Asia/Singapore":"SG","Asia/Taipei":"TW","Asia/Tel_Aviv":"IL","Asia/Tokyo":"JP","Asia/Urumqi":"CN","Atlantic/Reykjavik":"IS","Australia/Adelaide":"AU","Australia/Brisbane":"AU","Australia/Darwin":"AU","Australia/Hobart":"AU","Australia/Melbourne":"AU","Australia/Perth":"AU","Australia/Sydney":"AU","Europe/Amsterdam":"NL","Europe/Athens":"GR","Europe/Belgrade":"RS","Europe/Berlin":"DE","Europe/Bratislava":"SK","Europe/Brussels":"BE","Europe/Bucharest":"RO","Europe/Budapest":"HU","Europe/Copenhagen":"DK","Europe/Dublin":"IE","Europe/Helsinki":"FI","Europe/Zagreb":"HR","Europe/Istanbul":"TR","Europe/Kiev":"UA","Europe/Kyiv":"UA","Europe/Lisbon":"PT","Europe/Ljubljana":"SI","Europe/London":"GB","Europe/Luxembourg":"LU","Europe/Madrid":"ES","Europe/Moscow":"RU","Europe/Oslo":"NO","Europe/Paris":"FR","Europe/Prague":"CZ","Europe/Riga":"LV","Europe/Rome":"IT","Europe/Sofia":"BG","Europe/Stockholm":"SE","Europe/Tallinn":"EE","Europe/Vienna":"AT","Europe/Vilnius":"LT","Europe/Warsaw":"PL","Europe/Zurich":"CH","Pacific/Auckland":"NZ"};function Tt(e){let t=e.toUpperCase();return/^[A-Z]{2}$/.test(t)?String.fromCodePoint(...[...t].map(r=>127462+r.charCodeAt(0)-65)):"\u{1F3F3}\uFE0F"}function Je(e){return e?yo.get(e.toUpperCase()):void 0}function cn(e){return Je(e?_o[e]:void 0)}function xo(e){let t;for(let r of re)e.startsWith(r.dialCode)&&(!t||r.dialCode.length>t.dialCode.length)&&(t=r);return t}function ne(e){return e.replace(/[^\d]/g,"")}function Xe(e,t){let r=ne(t);if(!r)return"";let o=e?.groups?.length?e.groups:[],n=[],i=0;for(let s of o){if(i>=r.length)break;n.push(r.slice(i,i+s)),i+=s}for(;i<r.length;)n.push(r.slice(i,i+3)),i+=3;return n.join(" ")}function ln(e,t){let r=ne(t);return r?`+${e.dialCode}${r}`:""}function Ye(e,t){let r=(e??"").trim(),o=r.startsWith("+"),n=ne(r);if(!n)return{country:t,national:"",e164:""};if(o){let i=xo(n);if(i){let s=n.slice(i.dialCode.length);return{country:i,national:s,e164:`+${n}`}}return{national:n,e164:`+${n}`}}if(t){let i=n.startsWith(t.dialCode)?n.slice(t.dialCode.length):n;return{country:t,national:i,e164:`+${t.dialCode}${i}`}}return{national:n,e164:`+${n}`}}function wo(e){let{country:t,national:r,e164:o}=Ye(e);if(!o)return!1;let n=ne(o).length;return n<8||n>15?!1:t?.lengths.length?t.lengths.includes(r.length):r.length>=4}var $o=ze({fileId:R().check(ve(1)),name:R(),size:Dr().check(vt()),mime:R(),url:B(R())});function un(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="boolean"?e===!1:typeof e=="object"?Object.keys(e).length===0:!1}function dn(e,t){if(un(t))return e.required?"This field is required":null;switch(e.kind){case"short_text":case"long_text":{if(typeof t!="string")return"Expected text";if(e.maxLength&&t.length>e.maxLength)return`Must be at most ${e.maxLength} characters`;let r=e.kind==="long_text"?2e4:2e3;return!e.maxLength&&t.length>r?"Answer is too long":null}case"email":return Ue().safeParse(t).success?null:"Enter a valid email address";case"url":{if(typeof t!="string")return"Enter a valid URL (including https://)";try{let r=new URL(t);if(r.protocol!=="http:"&&r.protocol!=="https:")return"Enter an http(s) URL"}catch{return"Enter a valid URL (including https://)"}return null}case"phone":return typeof t!="string"||!wo(t)?"Enter a valid phone number":null;case"number":{let r=typeof t=="string"?Number(t):t;return typeof r!="number"||!Number.isFinite(r)?"Enter a number":e.min!==void 0&&r<e.min?`Must be at least ${e.min}`:e.max!==void 0&&r>e.max?`Must be at most ${e.max}`:null}case"select":case"dropdown":return typeof t!="string"||t===""?"Pick an option":e.options.some(r=>r.id===t)||e.allowOther&&t.length<=500?null:"Pick a valid option";case"multi_select":{if(!Array.isArray(t))return"Pick at least one option";let r=new Set(e.options.map(i=>i.id)),o=t,n=0;for(let i of o)if(!r.has(i)){if(e.allowOther!==!0||typeof i!="string"||i.length===0||i.length>500)return"Pick valid options";if(++n>1)return"Only one 'Other' answer is allowed"}return null}case"checkbox":return typeof t=="boolean"?null:"Invalid value";case"rating":{let r=e.max??5,o=typeof t=="string"?Number(t):t;return typeof o!="number"||!Number.isInteger(o)||o<1||o>r?`Pick a rating between 1 and ${r}`:null}case"linear_scale":{let r=e.min??1,o=e.max??10,n=typeof t=="string"?Number(t):t;return typeof n!="number"||!Number.isInteger(n)||n<r||n>o?`Pick a value between ${r} and ${o}`:null}case"ranking":{if(!Array.isArray(t))return"Drag the options into order";let r=e.options.map(n=>n.id).sort(),o=[...t].sort();return r.length!==o.length||r.some((n,i)=>n!==o[i])?"Rank every option":null}case"matrix":{if(typeof t!="object"||t===null||Array.isArray(t))return"Answer the grid";let r=t,o=new Set(e.columns.map(i=>i.id)),n=new Set(e.rows.map(i=>i.id));for(let[i,s]of Object.entries(r))if(!n.has(i)||!o.has(s))return"Invalid grid answer";return e.required&&Object.keys(r).length<e.rows.length?"Answer every row":null}case"signature":return typeof t!="string"||!t.startsWith("data:image/")?"Sign in the box":null;case"hidden":return typeof t=="string"?null:"Invalid value";case"custom":return null;case"date":{if(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t))return"Enter a valid date";let[r,o,n]=t.split("-").map(Number),i=new Date(Date.UTC(r,o-1,n));return i.getUTCFullYear()!==r||i.getUTCMonth()!==o-1||i.getUTCDate()!==n?"Enter a valid date":null}case"file_upload":{let r=ue($o).safeParse(t);if(!r.success)return"Upload did not complete";let o=e.maxFiles??1;return r.data.length>o?`At most ${o} file${o===1?"":"s"}`:null}}}function pn(e,t){let r=Ge(e,t),o={},n={};for(let i of r){let s=ko(i,t[i.id]),a=dn(i,s);a?o[i.id]=a:un(s)||(n[i.id]=s)}return{ok:Object.keys(o).length===0,errors:o,data:n}}function ko(e,t){if(t==null)return t;if(e.kind==="number"&&typeof t=="string"&&t.trim()!==""){let r=Number(t);return Number.isNaN(r)?t:r}if((e.kind==="rating"||e.kind==="linear_scale")&&typeof t=="string"){let r=Number(t);return Number.isNaN(r)?t:r}return typeof t=="string"?t.trim():t}var zo=["short_text","long_text","email","url","phone","number","select","multi_select","dropdown","checkbox","rating","linear_scale","ranking","matrix","signature","date","file_upload","hidden","custom"],So=["heading","paragraph","divider"],Eo=[...zo,...So],Mt=R().check(ve(1),L(128)),$t=yt({id:Mt,label:R().check(L(1e3)),icon:B(je())}),Ao=yt({id:Mt,kind:Br(Eo),label:B(R().check(L(2e3))),options:B(ue($t).check(L(200))),rows:B(ue($t).check(L(200))),columns:B(ue($t).check(L(200)))}),Co=ze({id:Mt,title:B(R().check(L(500))),blocks:ue(Ao).check(L(500))}),Po=ze({version:Vr(1),title:_t(B(R().check(L(2e3))),""),description:B(R().check(L(5e3))),pages:ue(Co).check(ve(1),L(50)),settings:_t(B(jr(R(),je())),{})}),Fo=1,Ft=1,Zt="0.7.0";function Y(e,t,r=""){return typeof e=="string"?e.trim().slice(0,t):r}function I(e,t){let r=Y(e,t);return r===""?void 0:r}function te(e){return typeof e=="boolean"?e:void 0}function Ae(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function he(e,t,r,o){let n=Ae(e);return n===void 0?o:Math.max(t,Math.min(r,Math.round(n)))}function Be(e,t=200){return Array.isArray(e)?e.slice(0,t).flatMap(r=>{if(!r||typeof r!="object")return[];let o=r,n=Y(o.id,128),i=Y(o.label,1e3),s=o.icon==="thumbs_up"||o.icon==="thumbs_down"?o.icon:void 0;return n&&i?[A({id:n,label:i,icon:s})]:[]}):[]}function Zo(e){if(!Array.isArray(e))return;let t=e.slice(0,20).flatMap(r=>{if(!r||typeof r!="object")return[];let o=r,n=o.op;if(n!=="eq"&&n!=="neq"&&n!=="contains"&&n!=="gt"&&n!=="lt"&&n!=="answered"&&n!=="not_answered")return[];let i=Y(o.fieldId,128);if(!i)return[];let s=o.value,a=typeof s=="string"||typeof s=="number"||typeof s=="boolean"?s:void 0;return[{fieldId:i,op:n,...a!==void 0?{value:a}:{}}]});return t.length?t:void 0}function fn(e){return{id:Y(e.id,128),visibleIf:Zo(e.visibleIf)}}function O(e,t){return{...fn(e),kind:t,label:Y(e.label,2e3,"Untitled field"),description:I(e.description,5e3),required:te(e.required),placeholder:I(e.placeholder,500)}}function Kr(e){let t=I(e,2e3);if(t)try{let r=new URL(t);return r.protocol==="http:"||r.protocol==="https:"?t:void 0}catch{return}}function Io(e){if(!e||typeof e!="object")return;let t=e,r=t.by==="browser"||t.by==="field"||t.by==="identify"?t.by:void 0;if(!r)return;let o=r==="field"?I(t.field,128):void 0;if(r==="field"&&!o)return;let n=I(t.scopeField,128),i=t.onRepeat==="update"&&r==="identify"?"update":"keep";return{by:r,...o?{field:o}:{},...n?{scopeField:n}:{},onRepeat:i}}function No(e){let t=e&&typeof e=="object"?e:{};return{submitMode:t.submitMode==="button"||t.submitMode==="auto"?t.submitMode:void 0,submitLabel:I(t.submitLabel,100),successTitle:I(t.successTitle,200),successMessage:I(t.successMessage,5e3),redirectUrl:Kr(t.redirectUrl),showProgress:te(t.showProgress),responseLimit:Io(t.responseLimit),notifyEmail:Ue().check(L(254)).safeParse(t.notifyEmail).success?t.notifyEmail:void 0,sendReceipt:te(t.sendReceipt),saveProgress:te(t.saveProgress),draftAnswersVisible:te(t.draftAnswersVisible),resumeEmails:te(t.resumeEmails),resumeUrl:Kr(t.resumeUrl),draftDigest:te(t.draftDigest)}}function A(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function To(e){if(!e||typeof e!="object")return null;let t=e,r=t.kind,o=fn(t);if(!o.id||typeof r!="string")return null;switch(r){case"heading":return A({...o,kind:r,text:Y(t.text,2e3,"Section")});case"paragraph":return A({...o,kind:r,text:Y(t.text,5e3)});case"divider":return A({...o,kind:r});case"short_text":case"email":case"url":return A({...O(t,r),maxLength:Ae(t.maxLength)===void 0?void 0:he(t.maxLength,1,2e3,2e3)});case"phone":{let n=I(t.defaultCountry,2)?.toUpperCase();return A({...O(t,r),defaultCountry:n&&/^[A-Z]{2}$/.test(n)?n:void 0})}case"long_text":return A({...O(t,r),maxLength:Ae(t.maxLength)===void 0?void 0:he(t.maxLength,1,2e4,2e4)});case"number":return A({...O(t,r),min:Ae(t.min),max:Ae(t.max)});case"select":case"multi_select":case"dropdown":{let n=Be(t.options);return n.length===0?null:A({...O(t,r),options:n,allowOther:te(t.allowOther),shuffleOptions:te(t.shuffleOptions)})}case"checkbox":{let n=t.appearance==="toggle"?"toggle":void 0;return A({...O(t,r),appearance:n})}case"signature":case"date":return A(O(t,r));case"rating":return A({...O(t,r),max:he(t.max,1,10,5)});case"linear_scale":{let n=he(t.min,0,9,1),i=he(t.max,n+1,10,10);return A({...O(t,r),min:n,max:i,minLabel:I(t.minLabel,100),maxLabel:I(t.maxLabel,100)})}case"ranking":{let n=Be(t.options);return n.length<2?null:A({...O(t,r),options:n})}case"matrix":{let n=Be(t.rows),i=Be(t.columns);return n.length===0||i.length===0?null:A({...O(t,r),rows:n,columns:i})}case"hidden":return A({...O(t,r),required:!1,paramName:I(t.paramName,128),defaultValue:I(t.defaultValue,1e3)});case"file_upload":return A({...O(t,r),maxFiles:he(t.maxFiles,1,20,1),maxFileSizeMb:he(t.maxFileSizeMb,1,5e3,500),accept:Array.isArray(t.accept)?t.accept.flatMap(n=>{let i=I(n,100);return i?[i]:[]}).slice(0,50):void 0});case"custom":return A({...O(t,r),component:Y(t.component,128),config:t.config&&typeof t.config=="object"&&!Array.isArray(t.config)?t.config:void 0});default:return null}}function Ce(e){let t=Po.safeParse(e);if(!t.success){let s=t.error.issues[0],a=s?.path.join(".");return{ok:!1,error:s?`${a?`${a}: `:""}${s.message}`:"Invalid schema"}}if(t.data.version>Fo)return{ok:!1,error:`Unsupported schema version: ${t.data.version}`};let r=t.data.pages.map(s=>{let a=s.blocks.flatMap(c=>{let l=To(c);return l?[l]:[]});return A({id:s.id,title:I(s.title,500),blocks:a})}),o=new Set;for(let s of r)for(let a of s.blocks){if(o.has(a.id))return{ok:!1,error:`Duplicate block id: ${a.id}`};o.add(a.id)}if(r.every(s=>s.blocks.length===0))return{ok:!1,error:"Schema must contain at least one valid block"};let n={version:Ft,title:Y(t.data.title,2e3),pages:r,settings:No(t.data.settings)},i=I(t.data.description,5e3);return i&&(n.description=i),{ok:!0,schema:n}}function Se(e,t){let r=I(e,t);if(r&&!(/[;{}<>]/.test(r)||/url\s*\(/i.test(r)))return r}function Lt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.colorScheme==="light"||t.colorScheme==="dark"||t.colorScheme==="auto"?t.colorScheme:void 0,o=A({colorScheme:r,primary:Se(t.primary,200),background:Se(t.background,200),text:Se(t.text,200),radius:Se(t.radius,64),fontFamily:Se(t.fontFamily,200)});return Object.keys(o).length>0?o:null}var Mo="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",kl=256-256%Mo.length;var mn=class{h0=1732584193;h1=4023233417;h2=2562383102;h3=271733878;h4=3285377520;block=new Uint8Array(64);blockLen=0;totalLen=0;w=new Int32Array(80);update(e){this.totalLen+=e.length;let t=0;if(this.blockLen>0){for(;t<e.length&&this.blockLen<64;)this.block[this.blockLen++]=e[t++];this.blockLen===64&&(this.process(this.block),this.blockLen=0)}for(;t+64<=e.length;)this.process(e.subarray(t,t+64)),t+=64;for(;t<e.length;)this.block[this.blockLen++]=e[t++];return this}digest(){let e=Math.floor(this.totalLen/536870912),t=this.totalLen*8>>>0,r=[128],o=this.blockLen+1;for(;o%64!==56;)r.push(0),o++;r.push(e>>>24&255,e>>>16&255,e>>>8&255,e&255),r.push(t>>>24&255,t>>>16&255,t>>>8&255,t&255),this.update(new Uint8Array(r));let n=new Uint8Array(20),i=[this.h0,this.h1,this.h2,this.h3,this.h4];for(let s=0;s<5;s++)n[s*4]=i[s]>>>24&255,n[s*4+1]=i[s]>>>16&255,n[s*4+2]=i[s]>>>8&255,n[s*4+3]=i[s]&255;return n}process(e){let t=this.w;for(let a=0;a<16;a++)t[a]=e[a*4]<<24|e[a*4+1]<<16|e[a*4+2]<<8|e[a*4+3];for(let a=16;a<80;a++){let c=t[a-3]^t[a-8]^t[a-14]^t[a-16];t[a]=c<<1|c>>>31}let r=this.h0,o=this.h1,n=this.h2,i=this.h3,s=this.h4;for(let a=0;a<80;a++){let c,l;a<20?(c=o&n|~o&i,l=1518500249):a<40?(c=o^n^i,l=1859775393):a<60?(c=o&n|o&i|n&i,l=2400959708):(c=o^n^i,l=3395469782);let d=(r<<5|r>>>27)+c+s+l+t[a]|0;s=i,i=n,n=o<<30|o>>>2,o=r,r=d}this.h0=this.h0+r|0,this.h1=this.h1+o|0,this.h2=this.h2+n|0,this.h3=this.h3+i|0,this.h4=this.h4+s|0}},Ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Rt(e){let t="";for(let r=0;r<e.length;r+=3){let o=e[r],n=r+1<e.length?e[r+1]:0,i=r+2<e.length?e[r+2]:0;t+=Ve[o>>2],t+=Ve[(o&3)<<4|n>>4],t+=r+1<e.length?Ve[(n&15)<<2|i>>6]:"=",t+=r+2<e.length?Ve[i&63]:"="}return t}var Lo=e=>Rt(new mn().update(e).digest()),z=class extends Error{constructor(e,t,r){super(e),this.status=t,this.retryAfterSec=r,this.name="FilloError"}status;retryAfterSec};function de(e){return e instanceof Error&&e.name==="FilloError"}async function qr(e,t){try{let r=await e.json();if(typeof r.error=="string"&&r.error)return r.error}catch{}return t}function Wr(e){let t=Number(e.headers.get("retry-after"));return Number.isFinite(t)&&t>0?t:void 0}var He=3,Ee=3e4;function Ke(e){return e>=500||e===429||e===408}function Gr(e){return e instanceof DOMException&&e.name==="TimeoutError"?new z("Request timed out",0):e}function Ro(e,t){let r=e.split(".").map(n=>Number(n)||0),o=t.split(".").map(n=>Number(n)||0);for(let n=0;n<Math.max(r.length,o.length);n++){let i=(r[n]??0)-(o[n]??0);if(i!==0)return i}return 0}function Oo(e){if(e.schemaVersion!==void 0&&e.schemaVersion!==Ft)throw new z(`This form uses schema version ${e.schemaVersion}; this SDK supports version ${Ft}. Update @usefillo/* to render it.`,426);if(e.minSdkVersion&&Ro(Zt,e.minSdkVersion)<0)throw new z(`This form requires @usefillo/* ${e.minSdkVersion} or newer. Current SDK is ${Zt}.`,426)}function kt(e,t){return r=>t.onProgress?.({uploadedBytes:r,totalBytes:e,fraction:e===0?1:r/e})}async function Do(e){let t=globalThis.crypto?.subtle;if(t){let r=await t.digest("SHA-1",e);return Rt(new Uint8Array(r))}return Lo(e)}var Uo="https://fillo.so",Jr={"X-Fillo-Client":`@usefillo/core@${Zt}`},Qe=class{baseUrl;fetch;key;constructor(e={}){this.baseUrl=e.baseUrl?e.baseUrl.replace(/\/$/,""):e.sameOrigin?"":Uo,this.key=e.key,this.fetch=e.fetch??((...t)=>globalThis.fetch(...t))}url(e){return`${this.baseUrl}/api/v1${e}`}async json(e,t){let r=t?.body!=null?{"Content-Type":"application/json",...Jr,...t?.headers}:t?.headers,o;try{o=await this.fetch(this.url(e),{...t,headers:r,signal:t?.signal??AbortSignal.timeout(Ee)})}catch(n){throw Gr(n)}if(!o.ok){let n=await qr(o,`Request failed: ${o.status}`);throw new z(n,o.status,Wr(o))}return await o.json()}async getForm(e){let t=await this.json(`/forms/${encodeURIComponent(e)}`);return Oo(t),t}syncForm(e,t,r){if(!this.key)return Promise.reject(new z("createClient needs a `key` (pk_\u2026) to sync code-defined forms",401));let o=Ce(t);return o.ok?this.json("/forms/sync",{method:"POST",body:JSON.stringify({key:this.key,id:e,schema:o.schema,theme:Lt(r)})}):Promise.reject(new z(`Invalid form schema: ${o.error}`,400))}async submit(e,t,r){let o;try{o=await this.fetch(this.url(`/forms/${encodeURIComponent(e)}/responses`),{method:"POST",headers:{"Content-Type":"application/json",...Jr},body:JSON.stringify({data:t,meta:r}),signal:AbortSignal.timeout(Ee)})}catch(i){throw Gr(i)}if(o.status===422)return{ok:!1,errors:(await o.json()).errors};if(!o.ok){let i=await qr(o,`Submit failed: ${o.status}`);throw new z(i,o.status,Wr(o))}let n=await o.json();return{ok:!0,responseId:n.id,duplicate:n.duplicate,updated:n.updated}}async fetchOwnResponse(e,t){try{return await this.json(`/forms/${encodeURIComponent(e)}/respondent-response`,{method:"POST",body:JSON.stringify({respondent:t})})}catch(r){if(de(r)&&(r.status===404||r.status===403))return null;throw r}}async startSession(e,t){try{let r=await this.fetch(this.url(`/forms/${encodeURIComponent(e)}/sessions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageCount:t}),signal:AbortSignal.timeout(Ee)});return r.ok?(await r.json()).id:null}catch{return null}}reportProgress(e,t){try{this.fetch(this.url(`/sessions/${encodeURIComponent(e)}/progress`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0,signal:AbortSignal.timeout(Ee)}).catch(()=>{})}catch{}}createDraft(e,t){return this.json(`/forms/${encodeURIComponent(e)}/drafts`,{method:"POST",body:JSON.stringify(t)})}getDraft(e,t,r){return this.json(`/drafts/${encodeURIComponent(e)}`,{headers:r?{"X-Fillo-Draft-Token":t,"X-Fillo-Draft-Adopt":"1"}:{"X-Fillo-Draft-Token":t}})}async saveDraft(e,t,r,o){await this.json(`/drafts/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"X-Fillo-Draft-Token":t},body:JSON.stringify(r),...o?.keepalive?{keepalive:!0}:{}})}async deleteDraft(e,t){await this.json(`/drafts/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-Fillo-Draft-Token":t}})}getUploadSession(e,t){return this.json(`/uploads/${encodeURIComponent(e)}`,t?{headers:{"X-Fillo-Upload-Token":t}}:void 0)}async uploadFile(e,t,r){let o=t instanceof File?t.name:"upload.bin",n=t.type||"application/octet-stream",i;r.sessionId?i=await this.getUploadSession(r.sessionId,r.uploadToken):i=await this.json(`/forms/${encodeURIComponent(e)}/uploads`,{method:"POST",body:JSON.stringify({fieldId:r.fieldId,fileName:o,size:t.size,mime:n})});let s;if(i.transport?.type==="gdrive")await this.driveUploadLoop(i,i.transport.uploadUrl,t,r);else if(i.transport?.type==="s3-put")await this.s3PutUpload(i.transport.uploadUrl,t,r);else if(i.transport?.type==="box")s=await this.boxUpload(i.transport,t,r);else throw new z("This form's storage doesn't support uploads \u2014 connect Drive, S3, or Box.");let a=await this.json(`/uploads/${encodeURIComponent(i.id)}/complete`,{method:"POST",headers:i.token?{"X-Fillo-Upload-Token":i.token}:void 0,...s?{body:JSON.stringify(s)}:{}});if(!a.file)throw new z("Upload completed but no file was returned");return a.file}async boxUpload(e,t,r){let o=kt(t.size,r);o(0);let n={Authorization:`Bearer ${e.token}`};if(e.mode==="simple"){let f=new FormData;f.append("attributes",JSON.stringify({name:e.fileName,parent:{id:e.folderId}})),f.append("file",t,e.fileName);let m=await this.retry(r,async()=>{let v=await this.fetch(e.uploadUrl,{method:"POST",headers:n,body:f,signal:this.uploadSignal(r)});if(!v.ok&&Ke(v.status))throw new z(`Box upload failed: ${v.status}`,v.status);return v});if(!m.ok)throw new z(`Box upload failed: ${m.status}`,m.status);let b=await m.json();return o(t.size),{providerFileId:b.entries?.[0]?.id}}if(e.size!==t.size)throw new z(`File size changed since the upload was requested (${t.size} vs ${e.size}).`,400);let i=await this.retry(r,async()=>{let f=await this.fetch(e.sessionUrl,{method:"POST",headers:{...n,"Content-Type":"application/json"},body:JSON.stringify({folder_id:e.folderId,file_size:e.size,file_name:e.fileName}),signal:this.uploadSignal(r)});if(!f.ok&&Ke(f.status))throw new z(`Box session failed: ${f.status}`,f.status);return f});if(!i.ok)throw new z(`Box session failed: ${i.status}`,i.status);let s=await i.json(),a=new mn,c=[],l=0;for(;l<t.size;){r.signal?.throwIfAborted();let f=Math.min(l+s.part_size,t.size),m=new Uint8Array(await t.slice(l,f).arrayBuffer());a.update(m);let b=await Do(m),v=await this.retry(r,async()=>{let F=await this.fetch(s.session_endpoints.upload_part,{method:"PUT",headers:{...n,"Content-Type":"application/octet-stream",Digest:`sha=${b}`,"Content-Range":`bytes ${l}-${f-1}/${t.size}`},body:m,signal:this.uploadSignal(r)});if(!F.ok&&Ke(F.status))throw new z(`Box part failed: ${F.status}`,F.status);return F});if(!v.ok)throw new z(`Box part failed: ${v.status}`,v.status);c.push((await v.json()).part),l=f,o(l)}let d=await this.retry(r,async()=>{let f=await this.fetch(s.session_endpoints.commit,{method:"POST",headers:{...n,"Content-Type":"application/json",Digest:`sha=${Rt(a.digest())}`},body:JSON.stringify({parts:c}),signal:this.uploadSignal(r)});if(!f.ok&&Ke(f.status))throw new z(`Box commit failed: ${f.status}`,f.status);return f});if(!d.ok)throw new z(`Box commit failed: ${d.status}`,d.status);return{providerFileId:(await d.json()).entries?.[0]?.id}}uploadSignal(e){let t=AbortSignal.timeout(Ee);return e.signal?AbortSignal.any([e.signal,t]):t}async retry(e,t){let r=0;for(;;)try{return await t()}catch(o){if(e.signal?.aborted||(r+=1,r>=He))throw o;await new Promise(n=>setTimeout(n,500*2**r))}}async driveUploadLoop(e,t,r,o){let n=e.uploadedBytes,i=kt(r.size,o);i(n);let s=0;for(;n<r.size;){o.signal?.throwIfAborted();let a=n,c=Math.min(n+e.chunkSize,r.size),l=r.slice(n,c),d=0;for(;;)try{let p=await this.fetch(t,{method:"PUT",headers:{"Content-Range":`bytes ${n}-${c-1}/${r.size}`},body:l,signal:this.uploadSignal(o)});if(p.status===308){let f=p.headers.get("Range")??p.headers.get("range"),m=f?.match(/bytes=0-(\d+)/);m?n=Number(m[1])+1:f==null?n=0:n=(await this.getUploadSession(e.id,e.token)).uploadedBytes;break}if(p.ok){n=r.size;break}throw new z(`Drive chunk failed: ${p.status}`,p.status)}catch(p){if(o.signal?.aborted||(d+=1,d>=He))throw p;if(await new Promise(m=>setTimeout(m,500*2**d)),n=(await this.getUploadSession(e.id,e.token)).uploadedBytes,n>=r.size)break;c=Math.min(n+e.chunkSize,r.size),l=r.slice(n,c)}if(i(n),n<=a){if(++s>=He)throw new z("Drive upload stalled \u2014 the storage endpoint stopped accepting progress",0)}else s=0}}async s3PutUpload(e,t,r){let o=kt(t.size,r);o(0);let n=0;for(;;)try{let i=await this.fetch(e,{method:"PUT",headers:{"Content-Type":t.type||"application/octet-stream"},body:t,signal:this.uploadSignal(r)});if(!i.ok)throw new z(`S3 upload failed: ${i.status}`,i.status);o(t.size);return}catch(i){if(r.signal?.aborted||(n+=1,n>=He))throw i;await new Promise(s=>setTimeout(s,500*2**n))}}};function Pe(e={}){return new Qe(e)}function zt(e){let t=e.trim();if(!/^-?\d*\.?\d+$/.test(t))return null;let r=Number(t);return Number.isFinite(r)?r:null}function Xr(e,t){let r={};for(let o of Nt(e)){let n=o.kind==="hidden"?t[o.paramName??o.id]??o.defaultValue:t[o.id];if(!(n===void 0||n===""))switch(o.kind){case"number":{let i=zt(n);if(i===null||o.min!==void 0&&i<o.min||o.max!==void 0&&i>o.max)break;r[o.id]=i;break}case"rating":{let i=zt(n);i!==null&&Number.isInteger(i)&&i>=1&&i<=(o.max??5)&&(r[o.id]=i);break}case"linear_scale":{let i=zt(n),s=o.min??1,a=o.max??10;i!==null&&Number.isInteger(i)&&i>=s&&i<=a&&(r[o.id]=i);break}case"checkbox":r[o.id]=n==="true"||n==="1"||n==="yes";break;case"select":case"dropdown":{o.options.some(i=>i.id===n)&&(r[o.id]=n);break}case"multi_select":{let i=new Set(o.options.map(a=>a.id)),s=n.split(",").filter(a=>i.has(a));s.length>0&&(r[o.id]=s);break}case"file_upload":case"ranking":case"matrix":case"signature":case"custom":break;default:r[o.id]=n}}return r}var jo={id:"empty",blocks:[]},Yr=!1,Qr=!1;function Bo(){Qr||(Qr=!0,console.warn("[fillo] This form has a client but no submission target \u2014 a bare schema can't sync. Wrap it in defineForm({ id, pages }) (or author it with <Fillo.Form id=\u2026>) so it gets a workspace handle, or pass formId for a dashboard-built form: https://fillo.so/docs"))}function Vo(){Yr||(Yr=!0,console.warn("[fillo] This form has no `client`, so responses can't be submitted \u2014 it's render-only. Pass a client (createClient) to collect responses in Fillo, or forward them to your own backend with webhooks: https://fillo.so/docs"))}var hn=new Map;function Ot(){try{return globalThis.localStorage??null}catch{return null}}function gn(e){return`fillo:submission:${e}`}function Dt(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);return e?.getRandomValues?(e.getRandomValues(t),Array.from(t,r=>r.toString(16).padStart(2,"0")).join("")):`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function bn(e,t,r,o){let n=Ot();if(!n)return e.get(r)??null;try{let i=JSON.parse(n.getItem(t)??"null");if(i&&o(i))return i}catch{}return null}function vn(e,t,r,o){e.set(r,o);let n=Ot();if(n)try{n.setItem(t,JSON.stringify(o))}catch{}}function Ut(e){return bn(hn,gn(e),e,t=>typeof t.key=="string")}function yn(e,t){vn(hn,gn(e),e,t)}function Ho(e){let t=Ut(e);if(t?.key)return t.key;let r={key:Dt()};return yn(e,r),r.key}function Ko(e,t){let r=Ut(e);yn(e,{key:r?.key??Dt(),submittedAt:new Date().toISOString(),responseId:t})}function It(e,t,r){let o=vo(e.settings,r);return o===null?t:`${t}::${o}`}function en(e,t,r){return e.settings.responseLimit?.by!=="browser"||!t?!1:!!Ut(It(e,t,r))?.submittedAt}var jt=new Map;function Bt(e){return`fillo:draft:${e}`}function qe(e){return bn(jt,Bt(e),e,t=>{let r=t;return typeof r.id=="string"&&typeof r.token=="string"})}function St(e,t){vn(jt,Bt(e),e,t)}function Et(e){jt.delete(e);let t=Ot();if(t)try{t.removeItem(Bt(e))}catch{}}function tn(e){return de(e)&&(e.status===401||e.status===403||e.status===404)}var qo=1500;function rn(e){return de(e)&&e.status&&e.status>0&&e.message?e.message:"Couldn't reach the server \u2014 check your connection and try again. If this keeps happening, a browser extension, firewall, or the site's Content-Security-Policy may be blocking the request."}function _n(e){let{onChange:t,onSubmitted:r}=e,o=Ce(e.form);if(!o.ok)throw new Error(`Invalid form schema: ${o.error}`);let n=o.schema,i=e.formId,s=e.client,a=e.respondent,c={...e.initialData??{}},l={},d=0,p="idle",f=!1;queueMicrotask(()=>{if(typeof location<"u"&&location.search){let y=Object.fromEntries(new URLSearchParams(location.search)),_=null;for(let[w,E]of Object.entries(Xr(n,y)))c[w]===void 0&&(_=_??{...c},_[w]=E);_&&p==="idle"&&(c=_,x())}p==="idle"&&en(n,i,c)&&(p="submitted",f=!0,x());let g=!1;if(n.settings.saveProgress&&i&&s&&typeof location<"u"&&location.hash.includes("fillo-draft=")){let y=/fillo-draft=([^&]+)/.exec(location.hash),_=y?.[1]?decodeURIComponent(y[1]):"",w=_.indexOf(".");if(w>0){g=!0;let E=_.slice(0,w),C=_.slice(w+1);s.getDraft(E,C,!0).then(ge=>{St(i,{id:E,token:ge.token??C});try{history.replaceState(null,"",location.pathname+location.search)}catch{}}).catch(()=>{}).finally(()=>nt())}}g||nt()});let m,b=new Set,v=new Set,F=Date.now(),oe=Dt(),Q=null,D=!1,K=!1,ye=!1,ie=!1,Z=null,N=null,Ne=Promise.resolve(),$=!1,M=!1,W=!1,q=!1;function fe(){let g=n.pages.length,y=Math.min(d,Math.max(g-1,0)),_=n.pages[y]??jo;return{data:c,errors:l,status:p,pageIndex:y,pageCount:g,page:_,blocks:wt(_,c),isFirstPage:y===0,isLastPage:y===g-1,uploading:b.size>0,submitError:m,restoredSubmission:f,resumedDraft:K,editingPrevious:ye}}let Te=fe();function x(){Te=fe();for(let g of v)g()}function U(g,y){try{r?.(g,y)}catch(_){console.error("[fillo] onSubmitted handler threw:",_)}}function G(g){let y=n.pages[g];if(!y)return{};let _={};for(let w of wt(y,c)){if(!pe(w))continue;let E=dn(w,c[w.id]);E&&(_[w.id]=E)}return _}function J(){return!!(n.settings.saveProgress&&s&&i&&!M)}function Zn(){let g=new Set;for(let y of n.pages)for(let _ of y.blocks)pe(_)&&g.add(_.id);return g}function rt(g){if(p!=="idle"||D)return;let y=Zn(),_=null;for(let[C,ge]of Object.entries(g.data??{}))c[C]===void 0&&y.has(C)&&(_=_??{...c},_[C]=ge);let w=typeof g.page=="number"&&Number.isFinite(g.page)?Math.max(0,Math.min(Math.floor(g.page),n.pages.length-1)):0,E=w>0&&d===0;!_&&!E||(_&&(c=_),E&&(d=w),K=!0,x())}function nt(){if(p!=="idle")return;if(!J()){Yt();return}let g=i,y=s,_=Z??qe(g);if(_&&!W){W=!0,Z=_,y.getDraft(_.id,_.token).then(rt).catch(w=>{tn(w)&&(Et(g),Z=null)});return}!_&&!q&&a?.hash&&(q=!0,y.createDraft(g,{data:{},page:0,respondent:a}).then(w=>{if(!Z){if(Z={id:w.id,token:w.token},St(g,Z),w.existing)return y.getDraft(w.id,w.token).then(rt);Yt()}}).catch(w=>{de(w)&&w.status!==void 0&&w.status>=400&&w.status<500||(q=!1)}))}function Yt(){if(ie||n.settings.responseLimit?.onRepeat!=="update"||!s||!i||!a?.hash||p!=="idle")return;ie=!0,s.fetchOwnResponse(i,a).then(y=>{!y||p!=="idle"||D||K||(rt({data:y.data,page:0}),K&&(K=!1,ye=!0,x()))}).catch(()=>{})}function ot(g=!1){if(N&&(clearTimeout(N),N=null),!J()||p!=="idle"||!$)return;let y=i,_=s;$=!1,Ne=Ne.then(async()=>{let w={data:c,page:Math.max(0,Math.min(d,n.pages.length-1))},E=Z??qe(y);try{if(E)try{await _.saveDraft(E.id,E.token,w,g?{keepalive:!0}:void 0),Z=E;return}catch(ge){if(!tn(ge))throw ge;Et(y),Z=null}let C=await _.createDraft(y,a?.hash?{...w,respondent:a}:w);Z={id:C.id,token:C.token},St(y,Z),C.existing&&($=!0)}catch(C){de(C)&&C.status!==void 0&&C.status>=400&&C.status<500&&C.status!==429?M=!0:$=!0}})}function In(){!J()||p!=="idle"||($=!0,N&&clearTimeout(N),N=setTimeout(()=>{N=null,ot()},qo))}function Qt(){!J()||!D&&!Z||($=!0,ot())}function er(){N&&(clearTimeout(N),N=null),$=!1,i&&Et(i),Z=null}function Nn(g,y){!D&&s&&i&&(D=!0,s.startSession(i,n.pages.length).then(_=>Q=_)),c={...c,[g]:y},t?.(c),m=void 0,g in l&&(l=Object.fromEntries(Object.entries(l).filter(([_])=>_!==g))),x(),In()}function Tn(g,y){y?b.add(g):b.delete(g),x()}function Mn(){let g=n.pages.length,y=Math.min(d,Math.max(g-1,0));if(!e.skipValidation){let _=G(y);if(l=_,Object.keys(_).length>0){x();return}}d=Math.min(y+1,g-1),Q&&s&&s.reportProgress(Q,{furthestPage:d}),x(),Qt()}function Ln(){l={},d=Math.max(Math.min(d,n.pages.length-1)-1,0),x(),Qt()}async function Rn(){if(p==="submitting"||p==="submitted")return;let g=pn(n,c);if(!g.ok){l=g.errors;let y=n.pages.findIndex(_=>wt(_,c).some(w=>w.id in g.errors));y>=0&&(d=y),x();return}if(s&&!i&&e.resolveFormId){p="submitting",m=void 0,x();try{i=await e.resolveFormId()}catch(y){throw p="idle",m=rn(y),x(),y}}if(s&&i){let y=n.settings.responseLimit?.by==="browser"?Ho(It(n,i,g.data)):void 0,_=y??oe,w=n.settings.saveProgress?Z??qe(i):null;p="submitting",m=void 0,x();let E;try{E=await s.submit(i,g.data,{hp:e.getHoneypot?.()??"",elapsedMs:Date.now()-F,surface:e.surface??"headless",submissionKey:_,draft:w?{id:w.id,token:w.token}:void 0,respondent:a})}catch(C){throw p="idle",m=rn(C),x(),C}if(!E.ok){l=E.errors??{},p="idle",x();return}Q&&s.reportProgress(Q,{completed:!0}),y&&Ko(It(n,i,g.data),E.responseId),er(),p="submitted",x(),U(E.responseId,g.data);return}if(e.skipValidation){p="submitted",x(),U(void 0,g.data);return}s&&!i?Bo():Vo(),p="error",x()}return{getState:()=>Te,subscribe(g){return v.add(g),()=>{v.delete(g)}},setValue:Nn,setUploading:Tn,next:Mn,back:Ln,submit:Rn,setContext(g){if("formId"in g&&(i=g.formId),"client"in g&&(s=g.client),"respondent"in g&&(a=g.respondent),g.form&&g.form!==n){let y=Ce(g.form);if(!y.ok)throw new Error(`Invalid form schema: ${y.error}`);n=y.schema}p==="idle"&&en(n,i,c)&&(p="submitted",f=!0),nt(),x()},flushDraft(){ot(!0)},resetDraft(){if(p==="submitting")return;let g=Z??(i?qe(i):null);if(er(),g&&s&&s.deleteDraft(g.id,g.token).catch(()=>{}),c={...e.initialData??{}},typeof location<"u"&&location.search){let y=Object.fromEntries(new URLSearchParams(location.search));for(let[_,w]of Object.entries(Xr(n,y)))c[_]===void 0&&(c[_]=w)}l={},d=0,m=void 0,K=!1,ye=!1,x()},destroy(){N&&(clearTimeout(N),N=null),v.clear()}}}function Wo(e){return pe(e)&&(e.kind==="select"||e.kind==="dropdown"||e.kind==="checkbox"||e.kind==="rating"||e.kind==="linear_scale")}function xn(e){let t=e.filter(r=>!(pe(r)&&r.kind==="hidden"));return t.length===0?!1:t.length>1?!0:!Wo(t[0])}function wn(e,t,r){if(r.form.settings.submitMode!=="auto"||!r.isLastPage||r.status!=="idle"||r.uploading||!(()=>{switch(e.kind){case"select":case"dropdown":return typeof t=="string"&&e.options.some(s=>s.id===t);case"checkbox":return t===!0;case"rating":case"linear_scale":return typeof t=="number";default:return!1}})()||t===r.data[e.id])return!1;let n={...r.data,[e.id]:t},i=Ge(r.form,n).filter(s=>s.kind!=="hidden");return i.length!==1||i[0]?.id!==e.id?!1:pn(r.form,n).ok}function Vt(e){return{id:e.id,theme:e.theme,schema:{version:1,title:e.title??"",description:e.description,pages:e.pages,settings:e.settings??{}},__filloCodeForm:!0}}function Ht(e){return typeof e=="object"&&e!==null&&"__filloCodeForm"in e}var We=new Map,Go=e=>new Promise(t=>setTimeout(t,e));async function Jo(e,t){let r=800;for(let o=0;;o++)try{return await e.syncForm(t.id,t.schema,t.theme??null)}catch(n){let i=de(n)?n.status??0:0;if(!(!de(n)||i===0||i===408||i===429||i>=500)||o>=2)throw n;let a=de(n)?n.retryAfterSec:void 0;await Go(Math.min(a?a*1e3:r*(1+Math.random()*.5),15e3)),r*=2}}function Xo(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)|0;return(t>>>0).toString(36)}function $n(e,t){return`fillo:sync:${e.baseUrl}|${e.key}|${t}`}function Yo(e,t,r){try{let o=globalThis.localStorage?.getItem($n(e,t));if(!o)return null;let n=JSON.parse(o);if(typeof n.formId!="string"||n.hash!==r||typeof n.ts!="number")return null;let i=n.status==="published"?36e5:6e4;return Date.now()-n.ts>i?null:n}catch{return null}}function Qo(e,t,r,o){try{globalThis.localStorage?.setItem($n(e,t),JSON.stringify({formId:o.formId,slug:o.slug,status:o.status,hash:r,ts:Date.now()}))}catch{}}function Kt(e,t,r){let o=JSON.stringify(t.schema)+JSON.stringify(t.theme??null),n=Xo(o),i=`${e.baseUrl}:${e.key}:${t.id}:${n}`,s=We.get(i);if(s&&!r?.bypassCache)return s;if(!r?.bypassCache){let a=Yo(e,t.id,n);if(a)return s=Promise.resolve({formId:a.formId,slug:a.slug,status:a.status}),We.set(i,s),s}return s=Jo(e,t).then(a=>(Qo(e,t.id,n,a),a)),We.set(i,s),s.catch(()=>We.delete(i)),s}var ei=class extends Error{constructor(e,t){super(`[fillo] ${t} \u2014 https://fillo.so/docs/troubleshooting#jsx-${e.toLowerCase()}`),this.code=e,this.name="FilloJsxError"}code},ti=Symbol.for("fillo.block");var ri=["label","description","required","placeholder"],P=(e,t,r,o={})=>({name:e,kind:t,props:[...ri,...r],...o}),nn=(e,t,r)=>({name:e,kind:t,props:r?["text"]:[],textChildren:r,content:!0}),At=["options","allowOther","shuffleOptions"],ni=[P("Text","short_text",["maxLength"]),P("LongText","long_text",["maxLength"]),P("Email","email",["maxLength"]),P("Url","url",["maxLength"]),P("Phone","phone",["defaultCountry"]),P("Number","number",["min","max"]),P("Select","select",At,{optionChildren:!0}),P("MultiSelect","multi_select",At,{optionChildren:!0}),P("Dropdown","dropdown",At,{optionChildren:!0}),P("Checkbox","checkbox",["appearance"]),P("Rating","rating",["max"]),P("Scale","linear_scale",["min","max","minLabel","maxLabel"]),P("Ranking","ranking",["options"],{optionChildren:!0}),P("Matrix","matrix",["rows","columns"]),P("Signature","signature",[]),P("Date","date",[]),P("FileUpload","file_upload",["maxFiles","maxFileSizeMb","accept"]),P("Hidden","hidden",["paramName","defaultValue"]),P("Custom","custom",["component","config"]),nn("Heading","heading",!0),nn("Paragraph","paragraph",!0),{name:"Divider",kind:"divider",props:[],content:!0}],oi={name:"Page",kind:"__page",props:["title"]},ii={name:"Option",kind:"__option",props:["label","icon"]};function Ct(e){let t=()=>{throw new ei("RENDERED_INERT",`<Fillo.${e.name}> was rendered by React. Fillo fields are schema declarations, valid only inside <Fillo.Form> or Fillo.defineForm(). If this form lives in a server component, move it to a client module ("use client")`)};return t[ti]=e,t}var zl=Object.fromEntries([...ni.map(e=>[e.name,Ct(e)]),["Page",Ct(oi)],["Option",Ct(ii)]]);var si=/\{\{\s*([\w-]+)\s*\}\}/g;function Pt(e,t,r){if(!e.includes("{{"))return e;let o=Nt(r);return e.replace(si,(n,i)=>{let s=o.find(l=>l.id===i),a=t[i];if(a==null||a==="")return"";let c=l=>s&&"options"in s?s.options.find(d=>d.id===l)?.label??l:l;return Array.isArray(a)?a.map(l=>c(String(l))).join(", "):typeof a=="string"?c(a):String(a)})}function kn(e,t,r){let o=n=>n===void 0?n:Pt(n,t,r);switch(e.kind){case"heading":case"paragraph":return{...e,text:Pt(e.text,t,r)};case"divider":return e;default:return{...e,label:Pt(e.label,t,r),description:o(e.description)}}}var ai="fillo-",ci=0,zn='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function li(e,t){let r=`${ai}${e}-${t}`;return{inputId:r,labelId:`${r}-label`,descriptionId:`${r}-desc`,errorId:`${r}-error`,name:r}}function u(e,t={}){let r=document.createElement(e);t.className&&(r.className=t.className),t.text!==void 0&&(r.textContent=t.text);for(let[o,n]of Object.entries(t.attrs??{}))r.setAttribute(o,n);return r}function Fe(e,t){let r=Lt(t);r&&(r.colorScheme&&e.setAttribute("data-fillo-color-scheme",r.colorScheme),r.primary&&e.style.setProperty("--fillo-primary",r.primary),r.background&&e.style.setProperty("--fillo-bg",r.background),r.text&&e.style.setProperty("--fillo-text",r.text),r.radius&&e.style.setProperty("--fillo-radius",r.radius),r.fontFamily&&e.style.setProperty("--fillo-font",r.fontFamily),(r.primary||r.background||r.text)&&e.setAttribute("data-fillo-has-color-theme",""))}function ui(e){try{if(!e)return null;let t=new URL(e);return t.protocol!=="http:"&&t.protocol!=="https:"?null:t.toString()}catch{return null}}function di(e){let t=new URL(ui(e)??"https://fillo.so");return t.searchParams.set("utm_source","form_badge"),t.toString()}function Wt(e){return typeof e=="string"||typeof e=="number"?String(e):""}function S(e,t){for(let r of t)r&&e.appendChild(r);return e}var Sn="http://www.w3.org/2000/svg",pi={thumbs_up:"M7 10v10M7 10l4.8-6.1a2 2 0 0 1 3.5 1.7L14.6 10h4.8a2.1 2.1 0 0 1 2 2.5l-1.1 5.4A3 3 0 0 1 17.4 20H7M3 10h4v10H3z",thumbs_down:"M7 14V4M7 14l4.8 6.1a2 2 0 0 0 3.5-1.7L14.6 14h4.8a2.1 2.1 0 0 0 2-2.5l-1.1-5.4A3 3 0 0 0 17.4 4H7M3 4h4v10H3z"};function Pn(e){if(!e)return null;let t=document.createElementNS(Sn,"svg");t.setAttribute("class","fillo-option-icon"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");let r=document.createElementNS(Sn,"path");return r.setAttribute("d",pi[e]),t.appendChild(r),t}function V(e,t,r,o){r&&e.setAttribute("aria-invalid","true"),t.required&&e.setAttribute("aria-required","true");let n=[t.description?o.descriptionId:null,r?o.errorId:null].filter(Boolean).join(" ");n&&e.setAttribute("aria-describedby",n)}function H(e,t,r,o){let n=u("div",{className:`fillo-field fillo-field--${e.kind}${t?" fillo-field--error":""}`,attrs:{"data-field":e.id}}),i=u("label",{className:"fillo-label",text:e.label,attrs:{id:o.labelId,for:o.inputId}});return e.required||i.appendChild(u("span",{className:"fillo-optional",text:" (optional)"})),n.appendChild(i),e.description&&n.appendChild(u("p",{className:"fillo-description",text:e.description,attrs:{id:o.descriptionId}})),n.appendChild(r),t&&n.appendChild(u("p",{className:"fillo-error",text:t,attrs:{role:"alert",id:o.errorId}})),n}function Ze(e,t){let r=u("input",{className:"fillo-input",attrs:{id:t.ids.inputId,type:e}});return r.value=Wt(t.value),t.field.placeholder&&(r.placeholder=t.field.placeholder),r.addEventListener("input",()=>t.setValue(r.value,{render:!1})),r.addEventListener("change",()=>t.setValue(r.value)),V(r,t.field,t.error,t.ids),H(t.field,t.error,r,t.ids)}function fi(){if(typeof navigator>"u")return;let t=(navigator.languages?.[0]||navigator.language||"").split("-")[1];return t&&/^[A-Za-z]{2}$/.test(t)?t.toUpperCase():void 0}function mi(){if(!(typeof Intl>"u"))try{let e=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof e=="string"&&e?e:void 0}catch{return}}function hi(e,t){if(t<=0)return e.setSelectionRange(0,0);let r=e.value,o=0,n=r.length;for(let i=0;i<r.length;i++)if(/\d/.test(r[i])&&++o===t){n=i+1;break}e.setSelectionRange(n,n)}var gi=8;function bi(e,t){if(typeof window>"u")return"below";let r=gi,o=document.documentElement.clientWidth||window.innerWidth,n=document.documentElement.clientHeight||window.innerHeight,i=e.getBoundingClientRect(),s=Math.max(0,n-i.bottom-r),a=Math.max(0,i.top-r),c=s<t.scrollHeight&&a>s?"above":"below",d=Math.max(0,Math.min(c==="above"?a:s,n-r*2)),p=Math.max(0,o-r*2);t.style.setProperty("--fillo-phone-popover-max-height",`${Math.floor(d)}px`),t.style.setProperty("--fillo-phone-popover-max-width",`${Math.floor(p)}px`),t.style.setProperty("--fillo-phone-popover-offset-x","0px");let f=Math.min(t.offsetWidth,p),m=0,b=i.left+f-(o-r);b>0&&(m-=b);let v=r-(i.left+m);return v>0&&(m+=v),t.style.setProperty("--fillo-phone-popover-offset-x",`${Math.round(m)}px`),c}function vi(e){let t=e.field,r=Ye(Wt(e.value)).country??Je(t.defaultCountry)??cn(mi())??Je(fi())??re[0],o=u("div",{className:"fillo-phone"}),n=u("div",{className:"fillo-phone-country"}),i=u("button",{className:"fillo-phone-flag",attrs:{type:"button","aria-haspopup":"listbox","aria-expanded":"false"}}),s=u("span",{className:"fillo-phone-flag-emoji",attrs:{"aria-hidden":"true"}}),a=u("span",{className:"fillo-phone-dial"});S(i,[s,a,u("span",{className:"fillo-phone-caret",text:"\u25BE",attrs:{"aria-hidden":"true"}})]),S(n,[i]);let c=u("input",{className:"fillo-input fillo-phone-input",attrs:{id:e.ids.inputId,type:"tel",inputmode:"tel",autocomplete:"tel-national"}});V(c,e.field,e.error,e.ids);let l=()=>{let $=ne(Wt(e.value));return $.startsWith(r.dialCode)?$.slice(r.dialCode.length):$},d=()=>{s.textContent=Tt(r.iso2),a.textContent=`+${r.dialCode}`,i.setAttribute("aria-label",`Country: ${r.name} (+${r.dialCode})`)},p=()=>{c.value=Xe(r,l()),c.placeholder=Xe(r,r.example)},f=$=>e.setValue($?ln(r,$):"",{render:!1});d(),p(),c.addEventListener("input",()=>{let $=c.value,M=c.selectionStart??$.length,W=ne($.slice(0,M)).length;if($.trimStart().startsWith("+")){let q=Ye($);q.country&&(r=q.country,d()),f(q.country?q.national:ne($))}else f(ne($));c.value=Xe(r,l()),hi(c,W)});let m=e.registerOverlay,b=null,v=0,F=re,oe=null,Q=null,D=`${e.ids.inputId}-countries`,K=()=>{if(!b)return;let $=bi(n,b);b.classList.toggle("fillo-phone-popover--above",$==="above"),b.classList.toggle("fillo-phone-popover--below",$==="below")},ye=()=>{oe?.();let $=()=>K();K(),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),oe=()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},ie=()=>{oe?.(),oe=null,b?.remove(),b=null,i.setAttribute("aria-expanded","false"),document.removeEventListener("mousedown",Z),Q?.(),Q=null},Z=$=>{n.contains($.target)||ie()},N=$=>{$&&(r=$,d(),f(l()),p(),ie(),c.focus())},Ne=()=>{let $=u("div",{className:"fillo-phone-popover fillo-phone-popover--below"}),M=u("input",{className:"fillo-phone-search",attrs:{type:"text",role:"combobox","aria-expanded":"true","aria-controls":D,"aria-autocomplete":"list",placeholder:"Search country or code"}}),W=u("ul",{className:"fillo-phone-list",attrs:{role:"listbox",id:D,"aria-label":"Country"}}),q=()=>{if(W.replaceChildren(),F.length===0){W.appendChild(u("li",{className:"fillo-phone-empty",text:"No matches"})),K();return}F.forEach((x,U)=>{let G=u("li",{className:`fillo-phone-option${U===v?" fillo-phone-option--active":""}`,attrs:{id:`${D}-opt-${U}`,role:"option","aria-selected":String(x.iso2===r.iso2)}});S(G,[u("span",{className:"fillo-phone-flag-emoji",text:Tt(x.iso2),attrs:{"aria-hidden":"true"}}),u("span",{className:"fillo-phone-option-name",text:x.name}),u("span",{className:"fillo-phone-option-dial",text:`+${x.dialCode}`})]),G.addEventListener("mouseenter",()=>{v=U,M.setAttribute("aria-activedescendant",G.id),fe()}),G.addEventListener("mousedown",J=>{J.preventDefault(),N(x)}),W.appendChild(G)}),M.setAttribute("aria-activedescendant",`${D}-opt-${v}`),K()},fe=()=>{[...W.children].forEach((x,U)=>x.classList.toggle("fillo-phone-option--active",U===v)),document.getElementById(`${D}-opt-${v}`)?.scrollIntoView({block:"nearest"})},Te=x=>{let U=x.trim().toLowerCase(),G=U.replace(/[^\d]/g,"");F=U?re.filter(J=>J.name.toLowerCase().includes(U)||J.iso2.toLowerCase()===U||G.length>0&&J.dialCode.startsWith(G)):re,v=0,q()};M.addEventListener("input",()=>Te(M.value)),M.addEventListener("keydown",x=>{x.key==="ArrowDown"?(x.preventDefault(),v=Math.min(v+1,F.length-1),fe(),M.setAttribute("aria-activedescendant",`${D}-opt-${v}`)):x.key==="ArrowUp"?(x.preventDefault(),v=Math.max(v-1,0),fe(),M.setAttribute("aria-activedescendant",`${D}-opt-${v}`)):x.key==="Enter"?(x.preventDefault(),N(F[v])):x.key==="Escape"&&(x.preventDefault(),ie(),i.focus())}),S($,[M,W]),b=$,n.appendChild($),i.setAttribute("aria-expanded","true"),F=re,v=Math.max(0,re.indexOf(r)),q(),ye(),fe(),document.addEventListener("mousedown",Z),Q=m?.(ie)??null,requestAnimationFrame(()=>M.focus())};return i.addEventListener("click",()=>b?ie():Ne()),S(o,[n,c]),H(e.field,e.error,o,e.ids)}function yi(e){let t=u("textarea",{className:"fillo-input fillo-textarea",attrs:{id:e.ids.inputId,rows:"4"}});return t.value=typeof e.value=="string"?e.value:"",e.field.placeholder&&(t.placeholder=e.field.placeholder),t.addEventListener("input",()=>e.setValue(t.value,{render:!1})),t.addEventListener("change",()=>e.setValue(t.value)),V(t,e.field,e.error,e.ids),H(e.field,e.error,t,e.ids)}function _i(e){let t=e.field,r=Jt(t),o=typeof e.value=="string"?e.value:"",n=e.activeOtherFields,i=o!==""&&!t.options.some(c=>c.id===o),s=i||o===""&&n?.has(t.id)===!0,a=u("div",{className:"fillo-options",attrs:{role:"radiogroup","aria-labelledby":e.ids.labelId}});V(a,t,e.error,e.ids);for(let c of r){let l=u("label",{className:`fillo-option${c.icon?" fillo-option--has-icon":""}${o===c.id?" fillo-option--selected":""}`,attrs:{"data-option":c.id}}),d=u("input",{className:"fillo-option-input",attrs:{type:"radio",name:e.ids.name}});d.checked=o===c.id,d.addEventListener("change",()=>{n?.delete(t.id),e.setValue(c.id)}),S(l,[d,Pn(c.icon),u("span",{className:"fillo-option-label",text:c.label})]),a.appendChild(l)}if(t.allowOther){let c=u("label",{className:`fillo-option fillo-option--other${s?" fillo-option--selected fillo-option--with-other":""}`}),l=u("input",{className:"fillo-option-input",attrs:{type:"radio",name:e.ids.name}});if(l.checked=s,l.addEventListener("change",()=>{n?.add(t.id),e.setValue("",{render:!0})}),S(c,[S(u("span",{className:"fillo-option-main"}),[l,u("span",{className:"fillo-option-label",text:"Other"})])]),s){let d=u("input",{className:"fillo-input fillo-other-input",attrs:{type:"text"}});d.value=i?o:"",d.placeholder="Your answer",d.addEventListener("input",()=>{n?.add(t.id),e.setValue(d.value,{render:!1})}),d.addEventListener("change",()=>{n?.add(t.id),e.setValue(d.value)}),c.appendChild(d),i||queueMicrotask(()=>d.focus())}a.appendChild(c)}return H(t,e.error,a,e.ids)}function xi(e){let t=e.field,r=Jt(t),o=Array.isArray(e.value)?e.value:[],n=new Set(t.options.map(d=>d.id)),i=o.find(d=>!n.has(d)),s=e.activeOtherFields,a=()=>{let d=e.getValue?.()??e.value;return Array.isArray(d)?d:[]},c=u("div",{className:"fillo-options",attrs:{role:"group","aria-labelledby":e.ids.labelId}});V(c,t,e.error,e.ids);let l=d=>e.setValue(d);for(let d of r){let p=u("label",{className:`fillo-option${d.icon?" fillo-option--has-icon":""}${o.includes(d.id)?" fillo-option--selected":""}`,attrs:{"data-option":d.id}}),f=u("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});f.checked=o.includes(d.id),f.addEventListener("change",()=>{let m=a();l(f.checked?[...m,d.id]:m.filter(b=>b!==d.id))}),S(p,[f,Pn(d.icon),u("span",{className:"fillo-option-label",text:d.label})]),c.appendChild(p)}if(t.allowOther){let d=i!==void 0||s?.has(t.id)===!0,p=u("label",{className:`fillo-option fillo-option--other${d?" fillo-option--selected fillo-option--with-other":""}`}),f=u("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});if(f.checked=d,f.addEventListener("change",()=>{let m=a().filter(b=>n.has(b));f.checked?(s?.add(t.id),l(m)):(s?.delete(t.id),l(m))}),S(p,[S(u("span",{className:"fillo-option-main"}),[f,u("span",{className:"fillo-option-label",text:"Other"})])]),d){let m=u("input",{className:"fillo-input fillo-other-input",attrs:{type:"text"}});m.value=i??"",m.placeholder="Your answer",m.addEventListener("input",()=>{s?.add(t.id);let b=a().filter(v=>n.has(v));e.setValue(m.value?[...b,m.value]:b,{render:!1})}),m.addEventListener("change",()=>{s?.add(t.id);let b=a().filter(v=>n.has(v));e.setValue(m.value?[...b,m.value]:b)}),p.appendChild(m),i===void 0&&queueMicrotask(()=>m.focus())}c.appendChild(p)}return H(t,e.error,c,e.ids)}var qt="__fillo_other__";function wi(e){let t=e.field,r=typeof e.value=="string"?e.value:"",o=e.activeOtherFields,n=r!==""&&!t.options.some(l=>l.id===r),i=n||r===""&&o?.has(t.id)===!0,s=u("div"),a=u("div",{className:"fillo-select-wrap"}),c=u("select",{className:"fillo-input fillo-select",attrs:{id:e.ids.inputId}});c.appendChild(u("option",{text:t.placeholder??"Choose...",attrs:{value:""}}));for(let l of Jt(t))c.appendChild(u("option",{text:l.label,attrs:{value:l.id}}));if(t.allowOther&&c.appendChild(u("option",{text:"Other...",attrs:{value:qt}})),c.value=i?qt:r,c.addEventListener("change",()=>{c.value===qt?(o?.add(t.id),e.setValue("",{render:!0})):(o?.delete(t.id),e.setValue(c.value||null))}),V(c,t,e.error,e.ids),S(a,[c,u("span",{className:"fillo-select-icon",attrs:{"aria-hidden":"true"}})]),s.appendChild(a),i){let l=u("input",{className:"fillo-input fillo-other-input fillo-other-input--block",attrs:{type:"text"}});l.value=n?r:"",l.placeholder="Your answer",l.addEventListener("input",()=>{o?.add(t.id),e.setValue(l.value,{render:!1})}),l.addEventListener("change",()=>{o?.add(t.id),e.setValue(l.value)}),s.appendChild(l),n||queueMicrotask(()=>l.focus())}return H(t,e.error,s,e.ids)}function $i(e){if(e.field.kind==="checkbox"&&e.field.appearance==="toggle"){let i=u("div",{className:`fillo-field fillo-field--checkbox fillo-field--toggle${e.error?" fillo-field--error":""}`,attrs:{"data-field":e.field.id}}),s=u("label",{className:"fillo-toggle"}),a=u("span",{className:"fillo-option-label",text:e.field.label});e.field.required||a.appendChild(u("span",{className:"fillo-optional",text:" (optional)"}));let c=u("span",{className:"fillo-toggle-copy"});c.appendChild(a);let l=u("input",{className:"fillo-toggle-input",attrs:{id:e.ids.inputId,type:"checkbox",role:"switch","aria-checked":String(e.value===!0)}});return l.checked=e.value===!0,l.addEventListener("change",()=>{l.setAttribute("aria-checked",String(l.checked)),e.setValue(l.checked)}),V(l,e.field,e.error,e.ids),S(s,[c,l,S(u("span",{className:"fillo-toggle-track",attrs:{"aria-hidden":"true"}}),[u("span",{className:"fillo-toggle-thumb"})])]),i.appendChild(s),e.field.description&&i.appendChild(u("p",{className:"fillo-description",text:e.field.description,attrs:{id:e.ids.descriptionId}})),e.error&&i.appendChild(u("p",{className:"fillo-error",text:e.error,attrs:{role:"alert",id:e.ids.errorId}})),i}let t=u("div",{className:`fillo-field fillo-field--checkbox${e.error?" fillo-field--error":""}`,attrs:{"data-field":e.field.id}}),r=u("label",{className:"fillo-option"}),o=u("input",{className:"fillo-option-input",attrs:{id:e.ids.inputId,type:"checkbox"}});o.checked=e.value===!0,o.addEventListener("change",()=>e.setValue(o.checked)),V(o,e.field,e.error,e.ids);let n=u("span",{className:"fillo-option-label",text:e.field.label});return e.field.required||n.appendChild(u("span",{className:"fillo-optional",text:" (optional)"})),S(r,[o,n]),t.appendChild(r),e.field.description&&t.appendChild(u("p",{className:"fillo-description",text:e.field.description,attrs:{id:e.ids.descriptionId}})),e.error&&t.appendChild(u("p",{className:"fillo-error",text:e.error,attrs:{role:"alert",id:e.ids.errorId}})),t}function ki(e){if(e.field.kind!=="rating")return u("div");let t=typeof e.field.max=="number"?e.field.max:5,r=typeof e.value=="number"?e.value:0,o=u("div",{className:"fillo-rating",attrs:{role:"group","aria-label":e.field.label}});V(o,e.field,e.error,e.ids);for(let n=1;n<=t;n++){let i=u("button",{className:`fillo-star${n<=r?" fillo-star--active":""}`,text:"*",attrs:{type:"button","aria-label":`${n} of ${t}`,"aria-pressed":String(n===r)}});i.addEventListener("click",()=>e.setValue(n===r?null:n)),o.appendChild(i)}return H(e.field,e.error,o,e.ids)}function zi(e){if(e.field.kind!=="linear_scale")return u("div");let t=typeof e.field.min=="number"?e.field.min:1,r=typeof e.field.max=="number"?e.field.max:10,o=u("div"),n=u("div",{className:"fillo-scale",attrs:{role:"group","aria-label":e.field.label}});V(n,e.field,e.error,e.ids);for(let i=t;i<=r;i++){let s=u("button",{className:`fillo-scale-step${e.value===i?" fillo-scale-step--active":""}`,text:String(i),attrs:{type:"button","aria-pressed":String(e.value===i)}});s.addEventListener("click",()=>e.setValue(e.value===i?null:i)),n.appendChild(s)}return o.appendChild(n),("minLabel"in e.field||"maxLabel"in e.field)&&S(o,[S(u("div",{className:"fillo-scale-labels"}),[u("span",{text:String(e.field.minLabel??"")}),u("span",{text:String(e.field.maxLabel??"")})])]),H(e.field,e.error,o,e.ids)}function Si(e){let t=e.field;if(t.kind!=="ranking")return null;let r=Array.isArray(e.value)?e.value:[],o=[...r.filter(i=>t.options.some(s=>s.id===i)),...t.options.map(i=>i.id).filter(i=>!r.includes(i))],n=u("ol",{className:"fillo-ranking"});for(let[i,s]of o.entries()){let a=t.options.find(m=>m.id===s);if(!a)continue;let c=u("li",{className:"fillo-ranking-item"}),l=u("span",{className:"fillo-ranking-controls"}),d=m=>{let b=i+m;if(b<0||b>=o.length)return;let v=[...o];[v[i],v[b]]=[v[b],v[i]],e.setValue(v)},p=u("button",{className:"fillo-ranking-move",text:"Up",attrs:{type:"button","data-fillo-rank-opt":s,"data-fillo-rank-dir":"up"}});p.toggleAttribute("disabled",i===0),p.addEventListener("click",()=>d(-1));let f=u("button",{className:"fillo-ranking-move",text:"Down",attrs:{type:"button","data-fillo-rank-opt":s,"data-fillo-rank-dir":"down"}});f.toggleAttribute("disabled",i===o.length-1),f.addEventListener("click",()=>d(1)),S(l,[p,f]),S(c,[u("span",{className:"fillo-ranking-index",text:String(i+1)}),u("span",{className:"fillo-ranking-label",text:a.label}),l]),n.appendChild(c)}return H(e.field,e.error,n,e.ids)}function Ei(e){let t=e.field;if(t.kind!=="matrix")return null;let r=e.value&&typeof e.value=="object"&&!Array.isArray(e.value)?e.value:{},o=u("table",{className:"fillo-matrix"}),n=document.createElement("thead"),i=document.createElement("tr");i.appendChild(document.createElement("th"));for(let a of t.columns)i.appendChild(u("th",{text:a.label,attrs:{scope:"col"}}));n.appendChild(i),o.appendChild(n);let s=document.createElement("tbody");for(let a of t.rows){let c=document.createElement("tr");c.appendChild(u("th",{text:a.label,attrs:{scope:"row"}}));for(let l of t.columns){let d=document.createElement("td"),p=u("input",{className:"fillo-option-input",attrs:{type:"radio",name:`${e.ids.name}-${a.id}`,"aria-label":`${a.label}: ${l.label}`}});p.checked=r[a.id]===l.id,p.addEventListener("change",()=>e.setValue({...r,[a.id]:l.id})),d.appendChild(p),c.appendChild(d)}s.appendChild(c)}return o.appendChild(s),H(e.field,e.error,S(u("div",{className:"fillo-matrix-wrap"}),[o]),e.ids)}function Ai(e){let t=u("div",{className:"fillo-signature-field"}),r=u("div",{className:"fillo-signature"}),o=u("canvas",{className:"fillo-signature-canvas",attrs:{"aria-hidden":"true"}}),n=u("button",{className:"fillo-signature-clear",text:"Clear",attrs:{type:"button"}}),i=u("div",{className:"fillo-signature-hint",text:"Sign here",attrs:{"aria-hidden":"true"}});o.width=720,o.height=220;let s=o.getContext("2d"),a=!1,c=typeof e.value=="string"&&e.value.startsWith("data:image/");if(c&&s){let b=new Image;b.onload=()=>s.drawImage(b,0,0,o.width,o.height),b.src=String(e.value),i.style.display="none"}let l=u("input",{className:"fillo-input fillo-signature-type-input",attrs:{id:e.ids.inputId,type:"text",autocomplete:"name",placeholder:"Type your full name to sign"}});V(l,e.field,e.error,e.ids);let d=b=>{s&&(s.clearRect(0,0,o.width,o.height),b.trim()?(s.fillStyle=getComputedStyle(o).color||"#18181b",s.font=`italic ${Math.min(96,o.height*.45)}px "Segoe Script", "Brush Script MT", cursive`,s.textBaseline="middle",s.fillText(b,24,o.height/2),c=!0,i.style.display="none",e.setValue(o.toDataURL("image/png"),{render:!1})):(c=!1,i.style.display="",e.setValue(null,{render:!1})))};l.addEventListener("input",()=>d(l.value));let p=b=>{let v=o.getBoundingClientRect();return{x:(b.clientX-v.left)/v.width*o.width,y:(b.clientY-v.top)/v.height*o.height}};o.addEventListener("pointerdown",b=>{if(!s)return;a=!0,c=!0,i.style.display="none",l.value&&(l.value=""),o.setPointerCapture(b.pointerId);let v=p(b);s.beginPath(),s.moveTo(v.x,v.y)}),o.addEventListener("pointermove",b=>{if(!a||!s)return;let v=p(b);s.lineWidth=2.4,s.lineCap="round",s.strokeStyle=getComputedStyle(o).color||"#18181b",s.lineTo(v.x,v.y),s.stroke()});let f=()=>{a&&(a=!1,c&&e.setValue(o.toDataURL("image/png"),{render:!1}))};o.addEventListener("pointerup",f),o.addEventListener("pointercancel",f),n.addEventListener("click",()=>{s?.clearRect(0,0,o.width,o.height),c=!1,i.style.display="",l.value="",e.setValue(null,{render:!1})}),S(r,[o,i,n]);let m=u("div",{className:"fillo-signature-type"});return m.appendChild(l),S(t,[r,m]),H(e.field,e.error,t,e.ids)}function Ci(e){let t=e.field;if(t.kind!=="file_upload")return null;let r=u("input",{className:"fillo-input",attrs:{id:e.ids.inputId,type:"file"}});(t.maxFiles??1)>1&&(r.multiple=!0),t.accept?.length&&(r.accept=t.accept.join(",")),V(r,t,e.error,e.ids),r.addEventListener("change",()=>{let a=Array.from(r.files??[]);e.uploadFiles?.(t,a)});let o=u("div");o.appendChild(r);let n=e.uploadProgress?.get(t.id);if(n!==void 0){let a=u("div",{className:"fillo-upload-progress"});a.appendChild(u("div",{className:"fillo-upload-progress-fill"})),a.firstElementChild?.style.setProperty("width",`${Math.round(n*100)}%`),o.appendChild(a)}let i=Array.isArray(e.value)?e.value:[];for(let a of i)o.appendChild(u("p",{className:"fillo-description",text:`${a.name} (${Math.round(a.size/1024)} KB)`}));let s=e.uploadNotice;return s&&o.appendChild(u("p",{className:"fillo-upload-notice",text:s,attrs:{role:"status"}})),H(t,e.error,o,e.ids)}var En=new Map;function Jt(e){if(!e.shuffleOptions)return e.options;let t=`${e.id}|${e.options.map(i=>i.id).join(",")}`,r=En.get(t);if(!r){r=e.options.map(i=>i.id);for(let i=r.length-1;i>0;i--){let s=Math.floor(Math.random()*(i+1));[r[i],r[s]]=[r[s],r[i]]}En.set(t,r)}let o=new Map(e.options.map(i=>[i.id,i])),n=r.flatMap(i=>o.get(i)??[]);return n.length===e.options.length?n:e.options}var Pi={short_text:e=>Ze("text",e),email:e=>Ze("email",e),url:e=>Ze("url",e),phone:vi,number:e=>Ze("number",e),date:e=>Ze("date",e),long_text:yi,select:_i,multi_select:xi,dropdown:wi,checkbox:$i,rating:ki,linear_scale:zi,ranking:Si,matrix:Ei,signature:Ai,file_upload:Ci};function Fi(e){if(e.field.kind==="hidden"||e.field.kind==="custom")return null;let t=Pi[e.field.kind];return t?t(e):null}var Ie=class{constructor(t,r){this.target=t;this.options=r;this.element.className="fillo-dom-root",t.replaceChildren(this.element),this.resolve()}target;options;element=u("div");instanceId=`d${++ci}`;schema=null;theme;formId;closed=!1;fetchedPoweredBy=null;fetchedBrandLabel;fetchedBrandHref;phase="loading";engine=null;destroyed=!1;renderQueued=!1;hpValue="";activeOtherFields=new Set;uploadProgress=new Map;uploadNotices=new Map;focusIntent=null;overlays=new Set;get status(){return this.phase==="ready"?this.engine?.getState().status??"idle":this.phase}get data(){return this.engine?.getState().data??this.options.initialData??{}}get form(){return this.schema}get mutableData(){return this.engine?.getState().data??this.options.initialData??{}}api(){let t=this.schema??{version:1,title:"",pages:[],settings:{}},r=this.engine?.getState(),o=r?.pageCount??t.pages.length;return{form:t,formId:this.formId,client:this.options.client,data:r?.data??this.mutableData,errors:r?.errors??{},status:this.status,pageIndex:r?.pageIndex??0,pageCount:o,page:r?.page??t.pages[0]??{id:"empty",blocks:[]},blocks:r?.blocks??[],isFirstPage:r?.isFirstPage??!0,isLastPage:r?.isLastPage??o<=1,setValue:(n,i,s)=>this.setValueInternal(n,i,s),next:()=>this.next(),back:()=>this.back(),submit:()=>this.submit()}}resolveFormIdFn;notLive=!1;async resolve(){try{let t=Ht(this.options.form)?this.options.form:null;if(t){let n=this.options.client;n?.key&&(this.resolveFormIdFn=()=>Kt(n,t,{bypassCache:!0}).then(i=>i.formId)),this.setSchema(t.schema,this.options.theme??t.theme,this.options.formId),n?.key&&Kt(n,t).then(({formId:i,branding:s,staged:a,status:c,warning:l})=>{this.formId=i,this.engine?.setContext({formId:i}),l&&console.warn(`[fillo] ${l}`),a?console.info(`[fillo] "${t.id}" changes staged as a draft \u2014 publish them in your Fillo dashboard`):c==="draft"&&(console.info(`[fillo] "${t.id}" is a draft \u2014 it renders here but won't accept responses until published`),Cn()||(this.notLive=!0,this.render())),s&&(this.fetchedPoweredBy=s.poweredBy,this.fetchedBrandLabel=s.label,this.fetchedBrandHref=s.href,this.render())}).catch(i=>{let s=et(i);console.warn("[fillo] form sync failed:",s.message),this.options.onError?.(s)});return}let r=this.options.form&&!Ht(this.options.form)?this.options.form:null;if(r){this.setSchema(r,this.options.theme,this.options.formId);return}if(!this.options.formId)throw new z("Provide either `form`, or a `formId`.",0);this.options.client??=Pe(),this.render();let o=await this.options.client.getForm(this.options.formId);this.closed=!!o.closed,this.fetchedPoweredBy=o.branding?.poweredBy??null,this.fetchedBrandLabel=o.branding?.label,this.fetchedBrandHref=o.branding?.href,this.setSchema(o.schema,this.options.theme??o.theme??void 0,o.id)}catch(t){this.handleError(et(t))}}setSchema(t,r,o){let n=Ce(t);if(!n.ok)throw new z(`This form could not be rendered: ${n.error}`,422);let i=n.schema;this.schema=i,this.theme=r,this.formId=o,this.engine=_n({form:i,formId:o,client:this.options.client,initialData:this.options.initialData,onChange:this.options.onChange,onSubmitted:this.options.onSubmitted,getHoneypot:()=>this.hpValue,surface:"default",resolveFormId:this.resolveFormIdFn,respondent:this.options.respondent});let s=this.engine.getState().status,a=this.engine.getState().resumedDraft,c=this.engine.getState().editingPrevious;this.engine.subscribe(()=>{let l=this.engine?.getState();l&&(l.status!==s||l.resumedDraft!==a||l.editingPrevious!==c)&&(s=l.status,a=l.resumedDraft,c=l.editingPrevious,this.queueRender())}),this.teardownDraftFlush(),i.settings.saveProgress&&typeof window<"u"&&(window.addEventListener("pagehide",this.flushDraftBound),document.addEventListener("visibilitychange",this.visibilityFlushBound),this.draftFlushWired=!0),this.phase=this.closed?"closed":"ready",this.render()}draftFlushWired=!1;flushDraftBound=()=>this.engine?.flushDraft();visibilityFlushBound=()=>{document.visibilityState==="hidden"&&this.engine?.flushDraft()};teardownDraftFlush(){!this.draftFlushWired||typeof window>"u"||(window.removeEventListener("pagehide",this.flushDraftBound),document.removeEventListener("visibilitychange",this.visibilityFlushBound),this.draftFlushWired=!1)}flushDraft(){this.engine?.flushDraft()}resetDraft(){this.engine?.resetDraft(),this.queueRender()}setValue(t,r){this.setValueInternal(t,r)}setValueInternal(t,r,o={}){this.engine?.setValue(t,r),o.render!==!1&&this.queueRender()}next(){if(!this.engine)return;let t=this.engine.getState().pageIndex;this.engine.next(),this.focusIntent=this.engine.getState().pageIndex!==t?"page":"error",this.render()}back(){this.engine&&(this.engine.back(),this.focusIntent="page",this.render())}async submit(){if(!this.engine||this.phase!=="ready")return;let t=this.engine.submit();this.hasErrors()&&(this.focusIntent="error"),this.render();try{await t}catch(r){this.options.onError?.(et(r)),this.focusIntent="error",this.render();return}this.hasErrors()&&(this.focusIntent="error"),this.render()}hasErrors(){return Object.keys(this.engine?.getState().errors??{}).length>0}setTheme(t){this.options.theme=t,this.theme=t,this.render()}setClient(t){this.options.client=t,this.engine?.setContext({client:t}),this.render()}setRespondent(t){this.options.respondent=t,this.engine?.setContext({respondent:t})}async uploadFiles(t,r){if(!this.schema)return;let o=t.maxFiles??1,n=o>1&&Array.isArray(this.mutableData[t.id])?[...this.mutableData[t.id]]:[],i=Math.max(0,o-n.length),s=r.slice(0,i),a=r.length-s.length;if(a>0?this.uploadNotices.set(t.id,`You can attach up to ${o} file${o===1?"":"s"}. ${a} ${a===1?"file was":"files were"} not added.`):this.uploadNotices.delete(t.id),s.length===0){this.queueRender();return}this.uploadProgress.set(t.id,0),this.queueRender();try{let c=[];for(let[l,d]of s.entries())this.options.client&&this.formId?c.push(await this.options.client.uploadFile(this.formId,d,{fieldId:t.id,onProgress:p=>{this.uploadProgress.set(t.id,(l+p.fraction)/s.length),this.queueRender()}})):c.push({fileId:`local:${d.name}:${d.size}`,name:d.name,size:d.size,mime:d.type||"application/octet-stream"});this.uploadProgress.delete(t.id),this.setValueInternal(t.id,[...n,...c])}catch(c){this.uploadProgress.delete(t.id),this.handleError(et(c))}}destroy(){this.destroyed=!0,this.teardownDraftFlush(),this.closeOverlays(),this.target.replaceChildren()}registerOverlay=t=>(this.overlays.add(t),()=>this.overlays.delete(t));closeOverlays(){if(this.overlays.size!==0){for(let t of Array.from(this.overlays))try{t()}catch{}this.overlays.clear()}}captureFocus(){if(typeof document>"u")return null;let t=document.activeElement;if(!t||!this.element.contains(t))return null;let r={};t.id&&(r.id=t.id);let o=t.getAttribute("data-fillo-rank-opt");o&&(r.rankOpt=o,r.rankDir=t.getAttribute("data-fillo-rank-dir")??void 0);let n=t.closest("[data-field]");if(n&&(r.fieldId=n.getAttribute("data-field")??void 0,r.controlIndex=Array.from(n.querySelectorAll(zn)).indexOf(t)),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)try{r.selStart=t.selectionStart,r.selEnd=t.selectionEnd}catch{}return r.id||r.rankOpt||r.fieldId?r:null}restoreFocus(t){if(typeof document>"u")return;let r=null;if(t.rankOpt){let o=Array.from(this.element.querySelectorAll("[data-fillo-rank-opt]")).filter(n=>n.getAttribute("data-fillo-rank-opt")===t.rankOpt);r=o.find(n=>n.getAttribute("data-fillo-rank-dir")===t.rankDir&&!n.disabled)??o.find(n=>!n.disabled)??null}if(!r&&t.id&&(r=document.getElementById(t.id)),!r&&t.fieldId!=null&&t.controlIndex!=null&&t.controlIndex>=0){let o=Array.from(this.element.querySelectorAll("[data-field]")).find(n=>n.getAttribute("data-field")===t.fieldId);o&&(r=Array.from(o.querySelectorAll(zn))[t.controlIndex]??null)}if(!(!r||typeof r.focus!="function")&&(r.focus(),(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&t.selStart!=null))try{r.setSelectionRange(t.selStart,t.selEnd??t.selStart)}catch{}}applyFocus(t,r){if(!(typeof document>"u")){if(t==="error"){this.element.querySelector('[aria-invalid="true"]')?.focus?.();return}if(t==="page"){let n=this.element.querySelector(".fillo-page-title, .fillo-title")??this.element.querySelector(".fillo-blocks");n&&(n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),n.focus?.());return}r&&this.restoreFocus(r)}}handleError(t){this.phase="error",this.options.onError?.(t),this.render(t)}queueRender(){this.renderQueued||this.destroyed||(this.renderQueued=!0,queueMicrotask(()=>{this.renderQueued=!1,this.render()}))}render(t){if(this.destroyed)return;let r=this.focusIntent;this.focusIntent=null;let o=r?null:this.captureFocus();if(this.closeOverlays(),this.element.replaceChildren(),this.phase==="loading"){let n=u("div",{className:`fillo-form fillo-form--loading ${this.options.className??""}`,attrs:{"aria-busy":"true"}});Fe(n,this.theme),S(n,[u("div",{className:"fillo-skeleton"}),u("div",{className:"fillo-skeleton"}),u("div",{className:"fillo-skeleton fillo-skeleton--short"})]),this.element.appendChild(n);return}if(this.phase==="error"&&t){this.element.appendChild(this.options.renderError?.(t)??u("div",{className:"fillo-form fillo-form--error",text:t.message}));return}if(this.phase==="closed"){let n=u("div",{className:`fillo-form fillo-form--closed ${this.options.className??""}`});Fe(n,this.theme),n.appendChild(u("p",{className:"fillo-closed",text:"This form is no longer accepting responses."})),this.element.appendChild(n);return}if(this.notLive){let n=u("div",{className:`fillo-form fillo-form--closed ${this.options.className??""}`});Fe(n,this.theme),n.appendChild(u("p",{className:"fillo-closed",text:"This form isn't live yet."})),this.element.appendChild(n);return}if(this.schema){if(this.engine?.getState().status==="submitted"){let n=this.api(),i=this.options.renderSuccess?.(n)??Ii(this.schema);Fe(i,this.theme),this.element.appendChild(i),this.brandingVisible()&&this.element.appendChild(An(this.fetchedBrandLabel,this.fetchedBrandHref));return}!this.options.client&&Cn()&&this.element.appendChild(Ni()),this.element.appendChild(this.renderForm()),this.brandingVisible()&&this.element.appendChild(An(this.fetchedBrandLabel,this.fetchedBrandHref)),this.applyFocus(r,o)}}brandingVisible(){return this.fetchedPoweredBy??!0}renderForm(){let t=this.api(),r=u("form",{className:`fillo-form ${this.options.className??""}`});Fe(r,this.theme),r.noValidate=!0;let o=()=>{t.isLastPage?this.submit():this.next()};r.addEventListener("submit",p=>{p.preventDefault(),o()});let n=this.engine?.getState();if(n?.resumedDraft||n?.editingPrevious){let p=u("div",{className:"fillo-resume",attrs:{role:"status"}});p.appendChild(u("span",{className:"fillo-resume-text",text:n.editingPrevious?"You're updating your earlier response.":"Picked up where you left off."}));let f=u("button",{className:"fillo-resume-clear",text:"Start over",attrs:{type:"button"}});f.addEventListener("click",()=>this.resetDraft()),p.appendChild(f),r.appendChild(p)}if(t.pageCount>1&&this.schema?.settings.showProgress!==!1){let p=u("div",{className:"fillo-progress-track",attrs:{role:"progressbar","aria-valuemin":"0","aria-valuemax":String(t.pageCount),"aria-valuenow":String(t.pageIndex+1)}});p.appendChild(u("div",{className:"fillo-progress-fill"})),p.firstElementChild?.style.setProperty("--fillo-progress-value",`${(t.pageIndex+1)/t.pageCount*100}%`),r.appendChild(p)}if(t.pageIndex===0){let p=u("header",{className:"fillo-header"});t.form.title&&p.appendChild(u("h1",{className:"fillo-title",text:t.form.title})),t.form.description&&p.appendChild(u("p",{className:"fillo-form-description",text:t.form.description})),r.appendChild(p)}else t.page.title&&r.appendChild(u("h2",{className:"fillo-page-title",text:t.page.title}));let i=u("div",{className:"fillo-blocks"});for(let p of t.blocks){let f=this.renderBlock(kn(p,this.mutableData,t.form),t);f&&i.appendChild(f)}r.appendChild(i);let s=u("input",{className:"fillo-hp",attrs:{type:"text",name:"fillo_hp_field",tabindex:"-1",autocomplete:"off","aria-hidden":"true"}});s.style.position="absolute",s.style.left="-9999px",s.style.top="auto",s.style.width="1px",s.style.height="1px",s.style.opacity="0",s.style.overflow="hidden",s.style.pointerEvents="none",s.addEventListener("input",()=>{this.hpValue=s.value}),r.appendChild(s);let a=t.status==="error"?"This form can't submit right now. Please try again in a moment.":this.engine?.getState().submitError;a&&r.appendChild(u("p",{className:"fillo-submit-error",attrs:{role:"alert"},text:a}));let l=!(t.form.settings.submitMode==="auto")||!t.isLastPage||xn(Ge(t.form,t.data));if(l||t.pageCount>1&&!t.isFirstPage){let p=u("footer",{className:"fillo-footer"});if(t.pageCount>1&&!t.isFirstPage){let f=u("button",{className:"fillo-button fillo-button--ghost",text:"Back",attrs:{type:"button"}});f.addEventListener("click",()=>this.back()),p.appendChild(f)}if(l){let f=u("button",{className:"fillo-button fillo-button--primary",text:t.status==="submitting"?"Submitting...":t.isLastPage?t.form.settings.submitLabel??"Submit":"Next",attrs:{type:"submit"}});f.toggleAttribute("disabled",t.status==="submitting"||this.uploadProgress.size>0),f.addEventListener("click",m=>{m.preventDefault(),o()}),p.appendChild(f)}r.appendChild(p)}return r}renderBlock(t,r){if(!pe(t))return Zi(t);let o=(s,a)=>{if(this.setValueInternal(t.id,s,a),a?.render===!1)return;let c={form:r.form,data:r.data,status:r.status,isLastPage:r.isLastPage,uploading:this.uploadProgress.size>0};wn(t,s,c)&&this.submit()},n={field:t,value:r.data[t.id],error:r.errors[t.id],ids:li(this.instanceId,t.id),api:r,setValue:o,uploadFiles:(s,a)=>this.uploadFiles(s,a),uploadProgress:this.uploadProgress,activeOtherFields:this.activeOtherFields,getValue:()=>this.engine?.getState().data[t.id],registerOverlay:this.registerOverlay,uploadNotice:this.uploadNotices.get(t.id)};return(t.kind==="custom"?this.options.customComponents?.[t.component]??this.options.components?.custom:this.options.components?.[t.kind]??Fi)?.(n)??null}};function Zi(e){switch(e.kind){case"heading":return u("h3",{className:"fillo-heading",text:e.text});case"paragraph":return u("p",{className:"fillo-paragraph",text:e.text});case"divider":return u("hr",{className:"fillo-divider"})}return u("div")}function Ii(e){let t=u("div",{className:"fillo-form fillo-form--success"}),r=u("div",{className:"fillo-success"});return S(r,[u("div",{className:"fillo-success-mark",text:"\u2713",attrs:{"aria-hidden":"true"}}),u("h2",{className:"fillo-success-title",text:e.settings.successTitle??"Thanks!"}),u("p",{className:"fillo-success-message",text:e.settings.successMessage??"Your response has been recorded."})]),t.appendChild(r),t}function An(e,t){return u("a",{className:"fillo-powered",text:e??"Powered by Fillo",attrs:{href:di(t),target:"_blank",rel:"noopener noreferrer"}})}function Cn(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function Ni(){return u("div",{className:"fillo-devwarning",text:"No Fillo client connected \u2014 this form is render-only and won't save responses. Pass a client to collect them in Fillo, or forward with webhooks. (Shown only in development.)",attrs:{role:"alert"}})}function et(e){return e instanceof z?e:new z(e instanceof Error?e.message:String(e),0)}function tt(e,t){let r=typeof e=="string"?document.querySelector(e):e;if(!r)throw new z(`Fillo mount target not found: ${String(e)}`,0);return new Ie(r,{...t,initialData:t.initialData??{}})}function Fn(e){let t=u("div");return tt(t,e),t}var Ti=typeof HTMLElement<"u"?HTMLElement:class{},Gt=class extends Ti{instance=null;assignedForm;assignedClient;assignedTheme;assignedInitialData;mounted=!1;mountScheduled=!1;static get observedAttributes(){return["publishable-key","form-id"]}connectedCallback(){this.scheduleMount()}disconnectedCallback(){this.instance?.destroy(),this.instance=null,this.mounted=!1}attributeChangedCallback(){this.mounted&&this.isConnected&&this.scheduleMount()}set form(t){this.assignedForm=t,this.mounted&&this.scheduleMount()}get form(){return this.assignedForm}set client(t){this.assignedClient=t,this.mounted&&this.instance instanceof Ie&&this.instance.setClient(t)}set theme(t){this.assignedTheme=t,this.mounted&&this.instance instanceof Ie&&this.instance.setTheme(t)}set initialData(t){this.assignedInitialData=t,this.mounted&&this.scheduleMount()}scheduleMount(){this.mountScheduled||(this.mountScheduled=!0,queueMicrotask(()=>{this.mountScheduled=!1,this.isConnected&&this.mount()}))}mount(){this.instance?.destroy();let t=this.getAttribute("publishable-key")??void 0,r=this.getAttribute("form-id")??void 0,o=this.assignedClient??(r||t?Pe({key:t}):void 0);this.instance=tt(this,{form:this.assignedForm,client:o,formId:r,theme:this.assignedTheme,initialData:this.assignedInitialData,onChange:n=>this.dispatchEvent(new CustomEvent("fillo-change",{detail:{data:n}})),onSubmitted:(n,i)=>this.dispatchEvent(new CustomEvent("fillo-submit",{detail:{responseId:n,data:i}})),onError:n=>this.dispatchEvent(new CustomEvent("fillo-error",{detail:{error:n}}))}),this.mounted=!0}};function Xt(e="fillo-form"){typeof customElements>"u"||customElements.get(e)||customElements.define(e,Gt)}typeof customElements<"u"&&Xt();return Vn(Mi);})();
|
package/dist/styles.css
CHANGED
|
@@ -698,4 +698,37 @@
|
|
|
698
698
|
padding: 0.05em 0.3em;
|
|
699
699
|
border-radius: 4px;
|
|
700
700
|
}
|
|
701
|
+
|
|
702
|
+
/* ---------- Saved-progress resume notice ---------- */
|
|
703
|
+
.fillo-resume {
|
|
704
|
+
display: flex;
|
|
705
|
+
align-items: center;
|
|
706
|
+
justify-content: space-between;
|
|
707
|
+
gap: 0.75rem;
|
|
708
|
+
margin-bottom: 1rem;
|
|
709
|
+
padding: 0.6rem 0.9rem;
|
|
710
|
+
border: 1px solid var(--fillo-border);
|
|
711
|
+
border-radius: var(--fillo-radius);
|
|
712
|
+
background: var(--fillo-control-bg);
|
|
713
|
+
color: var(--fillo-muted);
|
|
714
|
+
font-size: 0.82rem;
|
|
715
|
+
line-height: 1.45;
|
|
716
|
+
}
|
|
717
|
+
.fillo-resume-clear {
|
|
718
|
+
border: 0;
|
|
719
|
+
background: none;
|
|
720
|
+
padding: 0;
|
|
721
|
+
color: var(--fillo-primary);
|
|
722
|
+
font: inherit;
|
|
723
|
+
font-weight: 500;
|
|
724
|
+
cursor: pointer;
|
|
725
|
+
text-decoration: underline;
|
|
726
|
+
text-underline-offset: 2px;
|
|
727
|
+
white-space: nowrap;
|
|
728
|
+
}
|
|
729
|
+
.fillo-resume-clear:focus-visible {
|
|
730
|
+
outline: none;
|
|
731
|
+
border-radius: 4px;
|
|
732
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fillo-primary) 15%, transparent);
|
|
733
|
+
}
|
|
701
734
|
}
|
|
@@ -698,3 +698,36 @@
|
|
|
698
698
|
padding: 0.05em 0.3em;
|
|
699
699
|
border-radius: 4px;
|
|
700
700
|
}
|
|
701
|
+
|
|
702
|
+
/* ---------- Saved-progress resume notice ---------- */
|
|
703
|
+
.fillo-resume {
|
|
704
|
+
display: flex;
|
|
705
|
+
align-items: center;
|
|
706
|
+
justify-content: space-between;
|
|
707
|
+
gap: 0.75rem;
|
|
708
|
+
margin-bottom: 1rem;
|
|
709
|
+
padding: 0.6rem 0.9rem;
|
|
710
|
+
border: 1px solid var(--fillo-border);
|
|
711
|
+
border-radius: var(--fillo-radius);
|
|
712
|
+
background: var(--fillo-control-bg);
|
|
713
|
+
color: var(--fillo-muted);
|
|
714
|
+
font-size: 0.82rem;
|
|
715
|
+
line-height: 1.45;
|
|
716
|
+
}
|
|
717
|
+
.fillo-resume-clear {
|
|
718
|
+
border: 0;
|
|
719
|
+
background: none;
|
|
720
|
+
padding: 0;
|
|
721
|
+
color: var(--fillo-primary);
|
|
722
|
+
font: inherit;
|
|
723
|
+
font-weight: 500;
|
|
724
|
+
cursor: pointer;
|
|
725
|
+
text-decoration: underline;
|
|
726
|
+
text-underline-offset: 2px;
|
|
727
|
+
white-space: nowrap;
|
|
728
|
+
}
|
|
729
|
+
.fillo-resume-clear:focus-visible {
|
|
730
|
+
outline: none;
|
|
731
|
+
border-radius: 4px;
|
|
732
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fillo-primary) 15%, transparent);
|
|
733
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usefillo/dom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Framework-agnostic DOM renderer and web component for embedding Fillo forms.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@usefillo/core": "^0.
|
|
38
|
+
"@usefillo/core": "^0.7.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"jsdom": "^25.0.1",
|