grapesjs-forms 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
1
  var Et = Object.defineProperty;
2
2
  var _t = (i, e, t) => e in i ? Et(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var T = (i, e, t) => _t(i, typeof e != "symbol" ? e + "" : e, t);
3
+ var O = (i, e, t) => _t(i, typeof e != "symbol" ? e + "" : e, t);
4
4
  const et = /\{\{\s*([A-Za-z_][\w.\-]*)\s*\}\}/g, kt = /* @__PURE__ */ new Set(["form", "page"]);
5
5
  function Ct(i, e = {}) {
6
6
  return String(i ?? "").replace(et, (t, s) => {
7
- const [a, ...r] = s.split(".");
8
- if (!kt.has(a)) return t;
9
- const l = a === "form" ? e.form : e.page;
10
- if (a === "page" && !l) return t;
7
+ const [n, ...r] = s.split(".");
8
+ if (!kt.has(n)) return t;
9
+ const l = n === "form" ? e.form : e.page;
10
+ if (n === "page" && !l) return t;
11
11
  let o = l;
12
12
  for (const u of r) o = o && typeof o == "object" ? o[u] : void 0;
13
13
  return o == null || typeof o == "object" ? "" : String(o);
@@ -52,7 +52,7 @@ const At = (i) => !!i && new RegExp(et.source).test(i), Lt = [
52
52
  "color",
53
53
  "file",
54
54
  "hidden"
55
- ], fe = ["heading", "paragraph"], Ft = [...je, ...fe], me = ["select", "radio", "checkboxes"], we = ["text", "email", "tel", "url", "password", "textarea"], $t = ["number", "range", "date", "time", "datetime"], O = (i) => fe.includes(i), tt = (i) => me.includes(i), st = ["full", "1/2", "1/3", "2/3", "1/4", "3/4"], Tt = /^[A-Za-z_][A-Za-z0-9_.\-[\]]{0,63}$/, Ot = /^[A-Za-z_:][A-Za-z0-9_:.-]*$/, Nt = /* @__PURE__ */ new Set(["id", "name", "type", "value", "for", "form", "formaction", "srcdoc", "action", "method"]);
55
+ ], fe = ["heading", "paragraph"], Ft = [...je, ...fe], me = ["select", "radio", "checkboxes"], we = ["text", "email", "tel", "url", "password", "textarea"], $t = ["number", "range", "date", "time", "datetime"], N = (i) => fe.includes(i), tt = (i) => me.includes(i), st = ["full", "1/2", "1/3", "2/3", "1/4", "3/4"], Tt = /^[A-Za-z_][A-Za-z0-9_.\-[\]]{0,63}$/, Ot = /^[A-Za-z_:][A-Za-z0-9_:.-]*$/, Nt = /* @__PURE__ */ new Set(["id", "name", "type", "value", "for", "form", "formaction", "srcdoc", "action", "method"]);
56
56
  function W(i) {
57
57
  const e = String(i || "").normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 64);
58
58
  return e ? /^[a-z_]/.test(e) ? e : `f_${e}`.slice(0, 64) : "";
@@ -66,35 +66,35 @@ function re(i, e) {
66
66
  function ke(i, e = Nt) {
67
67
  if (!i || typeof i != "object" || Array.isArray(i)) return;
68
68
  const t = {};
69
- return Object.entries(i).forEach(([s, a]) => {
69
+ return Object.entries(i).forEach(([s, n]) => {
70
70
  const r = String(s).trim();
71
- if (!Ot.test(r) || /^on/i.test(r) || e.has(r.toLowerCase()) || a == null || typeof a == "object") return;
72
- const l = String(a);
71
+ if (!Ot.test(r) || /^on/i.test(r) || e.has(r.toLowerCase()) || n == null || typeof n == "object") return;
72
+ const l = String(n);
73
73
  /^\s*(javascript|vbscript|data:text\/html)/i.test(l) || (t[r] = l);
74
74
  }), Object.keys(t).length ? t : void 0;
75
75
  }
76
76
  let It = 0;
77
- const Y = () => `f${Date.now().toString(36)}${(It++).toString(36)}${Math.random().toString(36).slice(2, 6)}`, ae = (i) => i == null || i === "" ? void 0 : typeof i == "string" ? i : typeof i == "number" || typeof i == "boolean" ? String(i) : void 0, Rt = (i) => {
77
+ const Y = () => `f${Date.now().toString(36)}${(It++).toString(36)}${Math.random().toString(36).slice(2, 6)}`, ne = (i) => i == null || i === "" ? void 0 : typeof i == "string" ? i : typeof i == "number" || typeof i == "boolean" ? String(i) : void 0, Rt = (i) => {
78
78
  const e = typeof i == "number" ? i : typeof i == "string" && i.trim() ? Number(i) : NaN;
79
79
  return Number.isInteger(e) && e >= 0 ? e : void 0;
80
80
  };
81
- function Dt(i) {
81
+ function Mt(i) {
82
82
  const e = typeof i == "string" ? i.split(/\r?\n/) : Array.isArray(i) ? i : [], t = [], s = /* @__PURE__ */ new Set();
83
- return e.forEach((a) => {
83
+ return e.forEach((n) => {
84
84
  let r, l;
85
- if (typeof a == "string" || typeof a == "number") {
86
- const o = String(a).trim(), u = o.indexOf("|");
85
+ if (typeof n == "string" || typeof n == "number") {
86
+ const o = String(n).trim(), u = o.indexOf("|");
87
87
  u > 0 ? (l = o.slice(0, u).trim(), r = o.slice(u + 1).trim()) : l = r = o;
88
- } else a && typeof a == "object" && (l = ae(a.value ?? a.label ?? a.text), r = ae(a.label ?? a.text ?? a.value));
88
+ } else n && typeof n == "object" && (l = ne(n.value ?? n.label ?? n.text), r = ne(n.label ?? n.text ?? n.value));
89
89
  l == null || l === "" || s.has(l) || (s.add(l), t.push({ label: r || l, value: l }));
90
90
  }), t;
91
91
  }
92
- function Mt(i) {
92
+ function Dt(i) {
93
93
  if (!i || typeof i != "object") return null;
94
94
  const e = Ft.includes(i.type) ? i.type : "text", t = { id: typeof i.id == "string" && i.id ? i.id : Y(), type: e, name: "" };
95
- O(e) || (t.name = typeof i.name == "string" && Tt.test(i.name) ? i.name : W(i.name || i.label || "") || e);
95
+ N(e) || (t.name = typeof i.name == "string" && Tt.test(i.name) ? i.name : W(i.name || i.label || "") || e);
96
96
  const s = (r) => {
97
- const l = ae(i[r]);
97
+ const l = ne(i[r]);
98
98
  l !== void 0 && (t[r] = l);
99
99
  };
100
100
  ["label", "placeholder", "help", "value", "min", "max", "step", "pattern", "accept", "autocomplete", "text"].forEach(s), ["required", "multiple", "readonly", "disabled"].forEach((r) => {
@@ -102,87 +102,87 @@ function Mt(i) {
102
102
  }), ["minLength", "maxLength", "rows"].forEach((r) => {
103
103
  const l = Rt(i[r]);
104
104
  l !== void 0 && (t[r] = l);
105
- }), st.includes(i.width) && i.width !== "full" && (t.width = i.width), tt(e) && (t.options = Dt(i.options));
106
- const a = ke(i.attrs);
107
- return a && (t.attrs = a), e === "hidden" && (delete t.required, delete t.placeholder, delete t.width), O(e) && (["required", "placeholder", "value", "help"].forEach((r) => delete t[r]), t.text === void 0 && t.label && (t.text = t.label), delete t.label), t;
105
+ }), st.includes(i.width) && i.width !== "full" && (t.width = i.width), tt(e) && (t.options = Mt(i.options));
106
+ const n = ke(i.attrs);
107
+ return n && (t.attrs = n), e === "hidden" && (delete t.required, delete t.placeholder, delete t.width), N(e) && (["required", "placeholder", "value", "help"].forEach((r) => delete t[r]), t.text === void 0 && t.label && (t.text = t.label), delete t.label), t;
108
108
  }
109
109
  function Pt(i) {
110
110
  const e = [], t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
111
- return (Array.isArray(i) ? i : []).forEach((a) => {
112
- const r = Mt(a);
113
- r && (s.has(r.id) && (r.id = Y()), s.add(r.id), O(r.type) || (r.name = re(r.name, t), t.add(r.name)), e.push(r));
111
+ return (Array.isArray(i) ? i : []).forEach((n) => {
112
+ const r = Dt(n);
113
+ r && (s.has(r.id) && (r.id = Y()), s.add(r.id), N(r.type) || (r.name = re(r.name, t), t.add(r.name)), e.push(r));
114
114
  }), e;
115
115
  }
116
116
  function Ut(i) {
117
117
  const e = i && typeof i == "object" ? i : {}, t = {};
118
118
  return ["endpoint", "successMessage", "errorMessage", "redirect", "submitLabel"].forEach((s) => {
119
- const a = ae(e[s]);
120
- a !== void 0 && a.trim() && (t[s] = a.trim());
119
+ const n = ne(e[s]);
120
+ n !== void 0 && n.trim() && (t[s] = n.trim());
121
121
  }), t.endpoint && !$e(t.endpoint) && delete t.endpoint, t.redirect && !$e(t.redirect) && delete t.redirect, e.reset === !1 && (t.reset = !1), e.honeypot === !1 && (t.honeypot = !1), t;
122
122
  }
123
123
  const $e = (i) => /^(https?:\/\/|\/|\.{0,2}\/|\?|#)/i.test(i.trim()) || !/^[a-z][a-z0-9+.-]*:/i.test(i.trim());
124
124
  function V(i) {
125
125
  const e = i && typeof i == "object" ? i : {}, t = {
126
- id: ae(e.id) || "",
127
- name: (ae(e.name) || "").trim() || "Form",
126
+ id: ne(e.id) || "",
127
+ name: (ne(e.name) || "").trim() || "Form",
128
128
  fields: Pt(e.fields),
129
129
  settings: Ut(e.settings)
130
130
  }, s = ke(e.attrs);
131
131
  return s && (t.attrs = s), e.version !== void 0 && e.version !== null && (t.version = e.version), typeof e.updatedAt == "string" && (t.updatedAt = e.updatedAt), t;
132
132
  }
133
- const it = (i) => i.fields.filter((e) => !O(e.type)), Te = (i) => i.label || i.text || i.name || i.type, Se = "_gjsf_hp", Jt = /^[^\s@<>()[\],;:"]+@[^\s@<>()[\],;:"]+\.[^\s@<>()[\],;:"]{2,}$/, Ht = /^\d{4}-\d{2}-\d{2}$/, zt = /^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/, Bt = /^\d{4}-\d{2}-\d{2}T([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/, Vt = /^#[0-9a-f]{6}$/i, Oe = (i) => i == null || i === "" || Array.isArray(i) && i.length === 0 || i === !1, qt = (i) => i == null || i === "" ? [] : Array.isArray(i) ? i.map((e) => String(e)).filter((e) => e !== "") : String(i).split(",").map((e) => e.trim()).filter(Boolean), Yt = (i) => i === !0 || i === 1 || typeof i == "string" && /^(1|true|on|yes)$/i.test(i.trim());
133
+ const it = (i) => i.fields.filter((e) => !N(e.type)), Te = (i) => i.label || i.text || i.name || i.type, Se = "_gjsf_hp", Jt = /^[^\s@<>()[\],;:"]+@[^\s@<>()[\],;:"]+\.[^\s@<>()[\],;:"]{2,}$/, Ht = /^\d{4}-\d{2}-\d{2}$/, zt = /^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/, Bt = /^\d{4}-\d{2}-\d{2}T([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/, Vt = /^#[0-9a-f]{6}$/i, Oe = (i) => i == null || i === "" || Array.isArray(i) && i.length === 0 || i === !1, qt = (i) => i == null || i === "" ? [] : Array.isArray(i) ? i.map((e) => String(e)).filter((e) => e !== "") : String(i).split(",").map((e) => e.trim()).filter(Boolean), Yt = (i) => i === !0 || i === 1 || typeof i == "string" && /^(1|true|on|yes)$/i.test(i.trim());
134
134
  function Kt(i, e = {}) {
135
- const t = [], s = {}, a = (o, u) => void t.push({ field: o, code: u }), r = !!e && typeof e[Se] == "string" && e[Se].trim() !== "";
135
+ const t = [], s = {}, n = (o, u) => void t.push({ field: o, code: u }), r = !!e && typeof e[Se] == "string" && e[Se].trim() !== "";
136
136
  it(i).forEach((o) => {
137
137
  const u = e == null ? void 0 : e[o.name];
138
138
  if (o.type === "checkbox") {
139
139
  const h = Yt(u);
140
- o.required && !h && a(o.name, "required"), s[o.name] = h;
140
+ o.required && !h && n(o.name, "required"), s[o.name] = h;
141
141
  return;
142
142
  }
143
143
  if (o.type === "checkboxes" || o.type === "select" && o.multiple) {
144
144
  const h = qt(u);
145
145
  if (!h.length) {
146
- o.required && a(o.name, "required"), s[o.name] = [];
146
+ o.required && n(o.name, "required"), s[o.name] = [];
147
147
  return;
148
148
  }
149
149
  const y = new Set((o.options || []).map((p) => p.value));
150
- y.size && h.some((p) => !y.has(p)) && a(o.name, "option"), s[o.name] = h;
150
+ y.size && h.some((p) => !y.has(p)) && n(o.name, "option"), s[o.name] = h;
151
151
  return;
152
152
  }
153
153
  if (o.type === "file") {
154
154
  if (Oe(u)) {
155
- o.required && a(o.name, "required");
155
+ o.required && n(o.name, "required");
156
156
  return;
157
157
  }
158
158
  s[o.name] = u;
159
159
  return;
160
160
  }
161
- const n = Oe(u) ? "" : Array.isArray(u) ? String(u[0] ?? "") : String(u), d = o.type === "textarea" || o.type === "password" ? n : n.trim();
161
+ const a = Oe(u) ? "" : Array.isArray(u) ? String(u[0] ?? "") : String(u), d = o.type === "textarea" || o.type === "password" ? a : a.trim();
162
162
  if (!d) {
163
- o.required && a(o.name, "required"), s[o.name] = o.type === "number" || o.type === "range" ? null : "";
163
+ o.required && n(o.name, "required"), s[o.name] = o.type === "number" || o.type === "range" ? null : "";
164
164
  return;
165
165
  }
166
- if (we.includes(o.type) && (o.minLength != null && d.length < o.minLength && a(o.name, "minLength"), o.maxLength != null && d.length > o.maxLength && a(o.name, "maxLength")), o.type === "email" && !Jt.test(d) && a(o.name, "email"), o.type === "url" && !/^https?:\/\/[^\s]+\.[^\s]+/i.test(d) && a(o.name, "url"), o.type === "color" && !Vt.test(d) && a(o.name, "color"), o.pattern && we.includes(o.type))
166
+ if (we.includes(o.type) && (o.minLength != null && d.length < o.minLength && n(o.name, "minLength"), o.maxLength != null && d.length > o.maxLength && n(o.name, "maxLength")), o.type === "email" && !Jt.test(d) && n(o.name, "email"), o.type === "url" && !/^https?:\/\/[^\s]+\.[^\s]+/i.test(d) && n(o.name, "url"), o.type === "color" && !Vt.test(d) && n(o.name, "color"), o.pattern && we.includes(o.type))
167
167
  try {
168
- new RegExp(`^(?:${o.pattern})$`, "u").test(d) || a(o.name, "pattern");
168
+ new RegExp(`^(?:${o.pattern})$`, "u").test(d) || n(o.name, "pattern");
169
169
  } catch {
170
170
  }
171
171
  if (tt(o.type)) {
172
172
  const h = new Set((o.options || []).map((y) => y.value));
173
- h.size && !h.has(d) && a(o.name, "option");
173
+ h.size && !h.has(d) && n(o.name, "option");
174
174
  }
175
175
  if (o.type === "number" || o.type === "range") {
176
176
  const h = Number(d.replace(",", "."));
177
177
  if (!Number.isFinite(h)) {
178
- a(o.name, "number"), s[o.name] = d;
178
+ n(o.name, "number"), s[o.name] = d;
179
179
  return;
180
180
  }
181
- o.min != null && o.min !== "" && h < Number(o.min) && a(o.name, "min"), o.max != null && o.max !== "" && h > Number(o.max) && a(o.name, "max"), s[o.name] = h;
181
+ o.min != null && o.min !== "" && h < Number(o.min) && n(o.name, "min"), o.max != null && o.max !== "" && h > Number(o.max) && n(o.name, "max"), s[o.name] = h;
182
182
  return;
183
183
  }
184
- const b = o.type === "date" ? Ht : o.type === "time" ? zt : o.type === "datetime" ? Bt : null;
185
- b && (b.test(d) ? (o.min && d < o.min && a(o.name, "min"), o.max && d > o.max && a(o.name, "max")) : a(o.name, o.type === "time" ? "time" : "date")), s[o.name] = d;
184
+ const g = o.type === "date" ? Ht : o.type === "time" ? zt : o.type === "datetime" ? Bt : null;
185
+ g && (g.test(d) ? (o.min && d < o.min && n(o.name, "min"), o.max && d > o.max && n(o.name, "max")) : n(o.name, o.type === "time" ? "time" : "date")), s[o.name] = d;
186
186
  });
187
187
  const l = {};
188
188
  return t.forEach((o) => {
@@ -222,37 +222,37 @@ function rt(i, e = {}) {
222
222
  "data-gjsf-success": t.successMessage || ((r = e.texts) == null ? void 0 : r.success) || "",
223
223
  "data-gjsf-error": t.errorMessage || ((l = e.texts) == null ? void 0 : l.error) || ""
224
224
  });
225
- const a = t.endpoint || e.action || "";
226
- return a && (s.action = a), i.version != null && (s["data-gjsf-version"] = String(i.version)), t.redirect && (s["data-gjsf-redirect"] = t.redirect), t.reset === !1 && (s["data-gjsf-reset"] = "false"), it(i).some((o) => o.type === "file") && (s.enctype = "multipart/form-data"), e.codes && Object.keys(e.codes).length && (s["data-gjsf-codes"] = JSON.stringify(e.codes)), e.pageId && (s["data-gjsf-page"] = e.pageId), s;
225
+ const n = t.endpoint || e.action || "";
226
+ return n && (s.action = n), i.version != null && (s["data-gjsf-version"] = String(i.version)), t.redirect && (s["data-gjsf-redirect"] = t.redirect), t.reset === !1 && (s["data-gjsf-reset"] = "false"), it(i).some((o) => o.type === "file") && (s.enctype = "multipart/form-data"), e.codes && Object.keys(e.codes).length && (s["data-gjsf-codes"] = JSON.stringify(e.codes)), e.pageId && (s["data-gjsf-page"] = e.pageId), s;
227
227
  }
228
- function at(i, e = {}) {
228
+ function nt(i, e = {}) {
229
229
  var l, o, u;
230
- const t = { form: { id: i.id, name: i.name }, ...e.ctx || {} }, s = (e.key || i.id.slice(0, 8)).replace(/[^\w-]/g, ""), a = (n, d) => `gjsf-${s}-${n.name.replace(/[^\w-]/g, "_")}${d == null ? "" : `-${d}`}`, r = [];
231
- return i.fields.forEach((n) => {
232
- if (O(n.type)) {
233
- const { attrs: E, classes: x } = be(n);
230
+ const t = { form: { id: i.id, name: i.name }, ...e.ctx || {} }, s = (e.key || i.id.slice(0, 8)).replace(/[^\w-]/g, ""), n = (a, d) => `gjsf-${s}-${a.name.replace(/[^\w-]/g, "_")}${d == null ? "" : `-${d}`}`, r = [];
231
+ return i.fields.forEach((a) => {
232
+ if (N(a.type)) {
233
+ const { attrs: _, classes: x } = be(a);
234
234
  r.push(
235
- n.type === "heading" ? { tag: "h3", part: "heading", classes: [L.heading, ...x], attrs: E, kids: [n.text || ""] } : { tag: "p", part: "text", classes: [L.text, ...x], attrs: E, kids: [n.text || ""] }
235
+ a.type === "heading" ? { tag: "h3", part: "heading", classes: [L.heading, ...x], attrs: _, kids: [a.text || ""] } : { tag: "p", part: "text", classes: [L.text, ...x], attrs: _, kids: [a.text || ""] }
236
236
  );
237
237
  return;
238
238
  }
239
- let d = Ct(n.value || "", t);
240
- const b = At(d) ? d : "";
241
- if (b && (d = ""), n.type === "hidden") {
242
- const { attrs: E } = be(n);
239
+ let d = Ct(a.value || "", t);
240
+ const g = At(d) ? d : "";
241
+ if (g && (d = ""), a.type === "hidden") {
242
+ const { attrs: _ } = be(a);
243
243
  r.push({
244
244
  tag: "input",
245
245
  void: !0,
246
246
  part: "hidden",
247
- attrs: { ...E, type: "hidden", name: n.name, value: d, ...b ? { "data-gjsf-value": b } : {} }
247
+ attrs: { ..._, type: "hidden", name: a.name, value: d, ...g ? { "data-gjsf-value": g } : {} }
248
248
  });
249
249
  return;
250
250
  }
251
- const { attrs: h, classes: y } = be(n), p = a(n), _ = [L.field, `${L.field}--${n.type}`, ...n.width && Ne[n.width] ? [Ne[n.width]] : [], ...n.required ? ["is-required"] : []], $ = [n.label || n.name];
252
- n.required && $.push({ tag: "span", part: "req", classes: [L.req], attrs: { "aria-hidden": "true" }, kids: ["*"] });
253
- const M = n.help ? { tag: "div", part: "help", classes: [L.help], attrs: { id: `${p}-help` }, kids: [n.help] } : null, B = { tag: "div", part: "error", classes: [L.error], attrs: { "data-gjsf-error-for": n.name, "aria-live": "polite" } }, P = {};
254
- if (n.required && (P.required = ""), n.readonly && (P.readonly = ""), n.disabled && (P.disabled = ""), n.help && (P["aria-describedby"] = `${p}-help`), b && (P["data-gjsf-value"] = b), n.type === "radio" || n.type === "checkboxes") {
255
- const E = n.type === "checkboxes", x = new Set(d.split(",").map((w) => w.trim()).filter(Boolean)), v = (n.options || []).map((w, j) => ({
251
+ const { attrs: h, classes: y } = be(a), p = n(a), w = [L.field, `${L.field}--${a.type}`, ...a.width && Ne[a.width] ? [Ne[a.width]] : [], ...a.required ? ["is-required"] : []], $ = [a.label || a.name];
252
+ a.required && $.push({ tag: "span", part: "req", classes: [L.req], attrs: { "aria-hidden": "true" }, kids: ["*"] });
253
+ const T = a.help ? { tag: "div", part: "help", classes: [L.help], attrs: { id: `${p}-help` }, kids: [a.help] } : null, J = { tag: "div", part: "error", classes: [L.error], attrs: { "data-gjsf-error-for": a.name, "aria-live": "polite" } }, P = {};
254
+ if (a.required && (P.required = ""), a.readonly && (P.readonly = ""), a.disabled && (P.disabled = ""), a.help && (P["aria-describedby"] = `${p}-help`), g && (P["data-gjsf-value"] = g), a.type === "radio" || a.type === "checkboxes") {
255
+ const _ = a.type === "checkboxes", x = new Set(d.split(",").map((S) => S.trim()).filter(Boolean)), v = (a.options || []).map((S, j) => ({
256
256
  tag: "label",
257
257
  part: "option",
258
258
  classes: [L.option],
@@ -264,35 +264,35 @@ function at(i, e = {}) {
264
264
  classes: [L.check, ...y],
265
265
  attrs: {
266
266
  ...h,
267
- type: E ? "checkbox" : "radio",
268
- name: n.name,
269
- value: w.value,
270
- id: a(n, j),
271
- ...x.has(w.value) ? { checked: "" } : {},
267
+ type: _ ? "checkbox" : "radio",
268
+ name: a.name,
269
+ value: S.value,
270
+ id: n(a, j),
271
+ ...x.has(S.value) ? { checked: "" } : {},
272
272
  // A required radio group: one input is enough; checkboxes are checked by the script.
273
- ...n.required && (!E && j === 0) ? { required: "" } : {},
274
- ...n.disabled ? { disabled: "" } : {},
275
- ...b ? { "data-gjsf-value": b } : {}
273
+ ...a.required && (!_ && j === 0) ? { required: "" } : {},
274
+ ...a.disabled ? { disabled: "" } : {},
275
+ ...g ? { "data-gjsf-value": g } : {}
276
276
  }
277
277
  },
278
- { tag: "span", part: "option-label", classes: [L.optionLabel], kids: [w.label] }
278
+ { tag: "span", part: "option-label", classes: [L.optionLabel], kids: [S.label] }
279
279
  ]
280
280
  }));
281
281
  r.push({
282
282
  tag: "fieldset",
283
283
  part: "field",
284
- classes: _,
285
- attrs: { "data-gjsf-field": n.name, ...E && n.required ? { "data-gjsf-required": "" } : {}, ...n.help ? { "aria-describedby": `${p}-help` } : {} },
286
- kids: [{ tag: "legend", part: "label", classes: [L.label], kids: $ }, { tag: "div", part: "options", classes: [L.options], kids: v }, ...M ? [M] : [], B]
284
+ classes: w,
285
+ attrs: { "data-gjsf-field": a.name, ..._ && a.required ? { "data-gjsf-required": "" } : {}, ...a.help ? { "aria-describedby": `${p}-help` } : {} },
286
+ kids: [{ tag: "legend", part: "label", classes: [L.label], kids: $ }, { tag: "div", part: "options", classes: [L.options], kids: v }, ...T ? [T] : [], J]
287
287
  });
288
288
  return;
289
289
  }
290
- if (n.type === "checkbox") {
290
+ if (a.type === "checkbox") {
291
291
  r.push({
292
292
  tag: "div",
293
293
  part: "field",
294
- classes: _,
295
- attrs: { "data-gjsf-field": n.name },
294
+ classes: w,
295
+ attrs: { "data-gjsf-field": a.name },
296
296
  kids: [
297
297
  {
298
298
  tag: "label",
@@ -304,55 +304,55 @@ function at(i, e = {}) {
304
304
  void: !0,
305
305
  part: "check",
306
306
  classes: [L.check, ...y],
307
- attrs: { ...h, ...P, type: "checkbox", name: n.name, value: "1", id: p, .../^(1|true|on|yes)$/i.test(d) ? { checked: "" } : {} }
307
+ attrs: { ...h, ...P, type: "checkbox", name: a.name, value: "1", id: p, .../^(1|true|on|yes)$/i.test(d) ? { checked: "" } : {} }
308
308
  },
309
309
  { tag: "span", part: "option-label", classes: [L.optionLabel], kids: $ }
310
310
  ]
311
311
  },
312
- ...M ? [M] : [],
313
- B
312
+ ...T ? [T] : [],
313
+ J
314
314
  ]
315
315
  });
316
316
  return;
317
317
  }
318
- let J;
319
- if (n.type === "textarea")
320
- J = {
318
+ let H;
319
+ if (a.type === "textarea")
320
+ H = {
321
321
  tag: "textarea",
322
322
  part: "input",
323
323
  classes: [L.input, ...y],
324
324
  attrs: {
325
325
  ...h,
326
326
  ...P,
327
- name: n.name,
327
+ name: a.name,
328
328
  id: p,
329
- ...n.placeholder ? { placeholder: n.placeholder } : {},
330
- ...n.rows ? { rows: String(n.rows) } : {},
331
- ...n.minLength != null ? { minlength: String(n.minLength) } : {},
332
- ...n.maxLength != null ? { maxlength: String(n.maxLength) } : {},
333
- ...n.autocomplete ? { autocomplete: n.autocomplete } : {}
329
+ ...a.placeholder ? { placeholder: a.placeholder } : {},
330
+ ...a.rows ? { rows: String(a.rows) } : {},
331
+ ...a.minLength != null ? { minlength: String(a.minLength) } : {},
332
+ ...a.maxLength != null ? { maxlength: String(a.maxLength) } : {},
333
+ ...a.autocomplete ? { autocomplete: a.autocomplete } : {}
334
334
  },
335
335
  kids: d ? [d] : []
336
336
  };
337
- else if (n.type === "select") {
338
- const E = new Set(d.split(",").map((v) => v.trim()).filter(Boolean)), x = [];
339
- n.multiple || x.push({ tag: "option", part: "choice", attrs: { value: "", ...E.size ? {} : { selected: "" }, ...n.required ? { disabled: "" } : {} }, kids: [n.placeholder || "—"] }), (n.options || []).forEach((v) => x.push({ tag: "option", part: "choice", attrs: { value: v.value, ...E.has(v.value) ? { selected: "" } : {} }, kids: [v.label] })), J = {
337
+ else if (a.type === "select") {
338
+ const _ = new Set(d.split(",").map((v) => v.trim()).filter(Boolean)), x = [];
339
+ a.multiple || x.push({ tag: "option", part: "choice", attrs: { value: "", ..._.size ? {} : { selected: "" }, ...a.required ? { disabled: "" } : {} }, kids: [a.placeholder || "—"] }), (a.options || []).forEach((v) => x.push({ tag: "option", part: "choice", attrs: { value: v.value, ..._.has(v.value) ? { selected: "" } : {} }, kids: [v.label] })), H = {
340
340
  tag: "select",
341
341
  part: "input",
342
342
  classes: [L.input, ...y],
343
- attrs: { ...h, ...P, name: n.name, id: p, ...n.multiple ? { multiple: "" } : {}, ...n.autocomplete ? { autocomplete: n.autocomplete } : {} },
343
+ attrs: { ...h, ...P, name: a.name, id: p, ...a.multiple ? { multiple: "" } : {}, ...a.autocomplete ? { autocomplete: a.autocomplete } : {} },
344
344
  kids: x
345
345
  };
346
346
  } else {
347
- const E = { ...h, ...P, type: Wt[n.type] || n.type, name: n.name, id: p };
348
- n.placeholder && !["range", "color", "file", "date", "time", "datetime"].includes(n.type) && (E.placeholder = n.placeholder), d && n.type !== "file" && n.type !== "password" && (E.value = d), n.min && (E.min = n.min), n.max && (E.max = n.max), n.step && (E.step = n.step), n.minLength != null && (E.minlength = String(n.minLength)), n.maxLength != null && (E.maxlength = String(n.maxLength)), n.pattern && (E.pattern = n.pattern), n.accept && n.type === "file" && (E.accept = n.accept), n.multiple && n.type === "file" && (E.multiple = ""), n.autocomplete && (E.autocomplete = n.autocomplete), J = { tag: "input", void: !0, part: "input", classes: [L.input, ...y], attrs: E };
347
+ const _ = { ...h, ...P, type: Wt[a.type] || a.type, name: a.name, id: p };
348
+ a.placeholder && !["range", "color", "file", "date", "time", "datetime"].includes(a.type) && (_.placeholder = a.placeholder), d && a.type !== "file" && a.type !== "password" && (_.value = d), a.min && (_.min = a.min), a.max && (_.max = a.max), a.step && (_.step = a.step), a.minLength != null && (_.minlength = String(a.minLength)), a.maxLength != null && (_.maxlength = String(a.maxLength)), a.pattern && (_.pattern = a.pattern), a.accept && a.type === "file" && (_.accept = a.accept), a.multiple && a.type === "file" && (_.multiple = ""), a.autocomplete && (_.autocomplete = a.autocomplete), H = { tag: "input", void: !0, part: "input", classes: [L.input, ...y], attrs: _ };
349
349
  }
350
350
  r.push({
351
351
  tag: "div",
352
352
  part: "field",
353
- classes: _,
354
- attrs: { "data-gjsf-field": n.name },
355
- kids: [{ tag: "label", part: "label", classes: [L.label], attrs: { for: p }, kids: $ }, J, ...M ? [M] : [], B]
353
+ classes: w,
354
+ attrs: { "data-gjsf-field": a.name },
355
+ kids: [{ tag: "label", part: "label", classes: [L.label], attrs: { for: p }, kids: $ }, H, ...T ? [T] : [], J]
356
356
  });
357
357
  }), ((l = i.settings) == null ? void 0 : l.honeypot) !== !1 && r.push({
358
358
  tag: "div",
@@ -368,20 +368,20 @@ function at(i, e = {}) {
368
368
  kids: [{ tag: "button", part: "submit", classes: [L.submit], attrs: { type: "submit" }, kids: [((o = i.settings) == null ? void 0 : o.submitLabel) || ((u = e.texts) == null ? void 0 : u.submit) || "Send"] }]
369
369
  }), r.push({ tag: "div", part: "message", classes: [L.message], attrs: { role: "status", "aria-live": "polite" } }), r;
370
370
  }
371
- const Gt = (i) => i.replace(/[&<>]/g, (e) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;" })[e]), Zt = (i) => i.replace(/[&<>"]/g, (e) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[e]), nt = (i, e) => {
371
+ const Gt = (i) => i.replace(/[&<>]/g, (e) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;" })[e]), Zt = (i) => i.replace(/[&<>"]/g, (e) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[e]), at = (i, e) => {
372
372
  var s;
373
373
  const t = { ...(s = i.classes) != null && s.length ? { class: i.classes.join(" ") } : {}, ...i.attrs || {} };
374
- return e && (t["data-gjsf-part"] = e), i.style && (t.style = Object.entries(i.style).map(([a, r]) => `${a}:${r}`).join(";")), Object.entries(t).map(([a, r]) => r === "" && !["value", "action"].includes(a) ? ` ${a}` : ` ${a}="${Zt(r)}"`).join("");
374
+ return e && (t["data-gjsf-part"] = e), i.style && (t.style = Object.entries(i.style).map(([n, r]) => `${n}:${r}`).join(";")), Object.entries(t).map(([n, r]) => r === "" && !["value", "action"].includes(n) ? ` ${n}` : ` ${n}="${Zt(r)}"`).join("");
375
375
  };
376
376
  function ot(i) {
377
377
  if (typeof i == "string") return Gt(i);
378
- const e = `<${i.tag}${nt(i, i.part)}>`;
378
+ const e = `<${i.tag}${at(i, i.part)}>`;
379
379
  return i.void ? e : `${e}${(i.kids || []).map(ot).join("")}</${i.tag}>`;
380
380
  }
381
381
  function Ie(i, e = {}) {
382
382
  var s;
383
383
  const t = [L.form, ...(((s = i.attrs) == null ? void 0 : s.class) || "").split(/\s+/).filter(Boolean), ...e.classes || []];
384
- return `<form${nt({ classes: t, attrs: rt(i, e) })}>${at(i, e).map(ot).join("")}</form>`;
384
+ return `<form${at({ classes: t, attrs: rt(i, e) })}>${nt(i, e).map(ot).join("")}</form>`;
385
385
  }
386
386
  const Re = Symbol.for("grapesjs.plugin-controls"), Qt = "plugin:options";
387
387
  function Xt(i, e) {
@@ -399,15 +399,15 @@ function es(i) {
399
399
  return t || (t = /* @__PURE__ */ new Map(), Object.defineProperty(e, Re, { value: t, configurable: !0 })), t;
400
400
  }
401
401
  function ts(i, e, t, s) {
402
- const a = new Set((e.options || []).filter((o) => o.live).map((o) => o.key)), r = {
402
+ const n = new Set((e.options || []).filter((o) => o.live).map((o) => o.key)), r = {
403
403
  meta: e,
404
404
  getOptions: () => t(),
405
405
  setOptions(o) {
406
406
  var d;
407
- const u = { applied: [], reload: [] }, n = {};
408
- return Object.keys(o || {}).forEach((b) => {
409
- a.has(b) ? (n[b] = o[b], u.applied.push(b)) : u.reload.push(b);
410
- }), u.applied.length && s(n), (d = i.trigger) == null || d.call(i, Qt, { id: e.id, patch: o, result: u }), u;
407
+ const u = { applied: [], reload: [] }, a = {};
408
+ return Object.keys(o || {}).forEach((g) => {
409
+ n.has(g) ? (a[g] = o[g], u.applied.push(g)) : u.reload.push(g);
410
+ }), u.applied.length && s(a), (d = i.trigger) == null || d.call(i, Qt, { id: e.id, patch: o, result: u }), u;
411
411
  }
412
412
  }, l = es(i);
413
413
  return l.set(e.id, r), () => {
@@ -418,18 +418,18 @@ function Ce(i) {
418
418
  const e = this;
419
419
  if (!e || e.__gjsf || e.tagName !== "FORM") return;
420
420
  e.__gjsf = !0;
421
- const t = e.ownerDocument, s = t.defaultView || window, a = s.location, r = (x) => Array.prototype.slice.call(e.querySelectorAll(x)), l = (x) => e.getAttribute(x) || "";
421
+ const t = e.ownerDocument, s = t.defaultView || window, n = s.location, r = (x) => Array.prototype.slice.call(e.querySelectorAll(x)), l = (x) => e.getAttribute(x) || "";
422
422
  let o = {};
423
423
  try {
424
424
  o = JSON.parse(l("data-gjsf-codes") || "{}") || {};
425
425
  } catch {
426
426
  o = {};
427
427
  }
428
- const u = (x) => (x < 10 ? "0" : "") + x, n = (x) => {
428
+ const u = (x) => (x < 10 ? "0" : "") + x, a = (x) => {
429
429
  const v = (t.cookie || "").split(";");
430
- for (let w = 0; w < v.length; w++) {
431
- const j = v[w].trim(), R = j.indexOf("=");
432
- if (R > 0 && decodeURIComponent(j.slice(0, R)) === x) return decodeURIComponent(j.slice(R + 1));
430
+ for (let S = 0; S < v.length; S++) {
431
+ const j = v[S].trim(), M = j.indexOf("=");
432
+ if (M > 0 && decodeURIComponent(j.slice(0, M)) === x) return decodeURIComponent(j.slice(M + 1));
433
433
  }
434
434
  return "";
435
435
  }, d = () => {
@@ -440,24 +440,24 @@ function Ce(i) {
440
440
  } catch {
441
441
  }
442
442
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (v) => {
443
- const w = Math.random() * 16 | 0;
444
- return (v === "x" ? w : w & 3 | 8).toString(16);
443
+ const S = Math.random() * 16 | 0;
444
+ return (v === "x" ? S : S & 3 | 8).toString(16);
445
445
  });
446
- }, b = (x) => String(x || "").replace(/\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/g, (v, w) => {
447
- const j = w.indexOf("."), R = j < 0 ? w : w.slice(0, j), F = j < 0 ? "" : w.slice(j + 1), N = /* @__PURE__ */ new Date();
446
+ }, g = (x) => String(x || "").replace(/\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/g, (v, S) => {
447
+ const j = S.indexOf("."), M = j < 0 ? S : S.slice(0, j), F = j < 0 ? "" : S.slice(j + 1), I = /* @__PURE__ */ new Date();
448
448
  let U = null;
449
449
  try {
450
- U = new URLSearchParams(a.search);
450
+ U = new URLSearchParams(n.search);
451
451
  } catch {
452
452
  U = null;
453
453
  }
454
- switch (R) {
454
+ switch (M) {
455
455
  case "url":
456
- return a.href;
456
+ return n.href;
457
457
  case "path":
458
- return a.pathname;
458
+ return n.pathname;
459
459
  case "host":
460
- return a.host;
460
+ return n.host;
461
461
  case "referrer":
462
462
  return t.referrer || "";
463
463
  case "title":
@@ -467,7 +467,7 @@ function Ce(i) {
467
467
  case "query":
468
468
  return U && U.get(F) || "";
469
469
  case "cookie":
470
- return n(F);
470
+ return a(F);
471
471
  case "storage":
472
472
  try {
473
473
  return s.localStorage.getItem(F) || "";
@@ -475,125 +475,125 @@ function Ce(i) {
475
475
  return "";
476
476
  }
477
477
  case "date":
478
- return N.getFullYear() + "-" + u(N.getMonth() + 1) + "-" + u(N.getDate());
478
+ return I.getFullYear() + "-" + u(I.getMonth() + 1) + "-" + u(I.getDate());
479
479
  case "time":
480
- return u(N.getHours()) + ":" + u(N.getMinutes());
480
+ return u(I.getHours()) + ":" + u(I.getMinutes());
481
481
  case "datetime":
482
- return N.toISOString();
482
+ return I.toISOString();
483
483
  case "timestamp":
484
- return String(N.getTime());
484
+ return String(I.getTime());
485
485
  case "uuid":
486
486
  return d();
487
487
  case "page":
488
- return F === "url" ? a.href : F === "path" || F === "slug" ? a.pathname : (F === "name" || F === "title") && t.title || "";
488
+ return F === "url" ? n.href : F === "path" || F === "slug" ? n.pathname : (F === "name" || F === "title") && t.title || "";
489
489
  default:
490
490
  return "";
491
491
  }
492
492
  }), h = (x) => {
493
493
  r("[data-gjsf-value]").forEach((v) => {
494
- const w = b(v.getAttribute("data-gjsf-value") || ""), j = (v.getAttribute("type") || "").toLowerCase();
495
- if (j === "hidden") v.value = w;
494
+ const S = g(v.getAttribute("data-gjsf-value") || ""), j = (v.getAttribute("type") || "").toLowerCase();
495
+ if (j === "hidden") v.value = S;
496
496
  else {
497
497
  if (x) return;
498
498
  if (j === "checkbox" || j === "radio") {
499
- const R = w.split(",").map((F) => F.trim());
500
- v.checked = v.value === "1" && j === "checkbox" ? /^(1|true|on|yes)$/i.test(w) : R.indexOf(v.value) >= 0;
499
+ const M = S.split(",").map((F) => F.trim());
500
+ v.checked = v.value === "1" && j === "checkbox" ? /^(1|true|on|yes)$/i.test(S) : M.indexOf(v.value) >= 0;
501
501
  } else if (v.tagName === "SELECT") {
502
- const R = w.split(",").map((F) => F.trim());
503
- Array.prototype.forEach.call(v.options, (F) => F.selected = R.indexOf(F.value) >= 0);
504
- } else v.value || (v.value = w);
502
+ const M = S.split(",").map((F) => F.trim());
503
+ Array.prototype.forEach.call(v.options, (F) => F.selected = M.indexOf(F.value) >= 0);
504
+ } else v.value || (v.value = S);
505
505
  }
506
506
  });
507
507
  };
508
508
  h(!1);
509
- const y = e.querySelector(".gjsf-message"), p = r('[type="submit"]'), _ = (x, v) => {
510
- e.classList.remove("is-sending", "is-success", "is-error"), x && e.classList.add("is-" + x), e.setAttribute("aria-busy", x === "sending" ? "true" : "false"), p.forEach((w) => w.disabled = x === "sending"), y && (y.textContent = v || "", v ? y.removeAttribute("hidden") : y.setAttribute("hidden", ""));
511
- }, $ = (x) => x.replace(/["\\]/g, "\\$&"), M = (x) => e.querySelector('[data-gjsf-field="' + $(x) + '"]'), B = (x) => {
512
- const v = M(x);
509
+ const y = e.querySelector(".gjsf-message"), p = r('[type="submit"]'), w = (x, v) => {
510
+ e.classList.remove("is-sending", "is-success", "is-error"), x && e.classList.add("is-" + x), e.setAttribute("aria-busy", x === "sending" ? "true" : "false"), p.forEach((S) => S.disabled = x === "sending"), y && (y.textContent = v || "", v ? y.removeAttribute("hidden") : y.setAttribute("hidden", ""));
511
+ }, $ = (x) => x.replace(/["\\]/g, "\\$&"), T = (x) => e.querySelector('[data-gjsf-field="' + $(x) + '"]'), J = (x) => {
512
+ const v = T(x);
513
513
  v && v.classList.remove("has-error");
514
- const w = e.querySelector('[data-gjsf-error-for="' + $(x) + '"]');
515
- w && (w.textContent = ""), r('[name="' + $(x) + '"]').forEach((j) => j.removeAttribute("aria-invalid"));
514
+ const S = e.querySelector('[data-gjsf-error-for="' + $(x) + '"]');
515
+ S && (S.textContent = ""), r('[name="' + $(x) + '"]').forEach((j) => j.removeAttribute("aria-invalid"));
516
516
  }, P = () => {
517
- r("[data-gjsf-field]").forEach((x) => B(x.getAttribute("data-gjsf-field") || ""));
518
- }, J = (x) => {
519
- let v = null, w = !1;
517
+ r("[data-gjsf-field]").forEach((x) => J(x.getAttribute("data-gjsf-field") || ""));
518
+ }, H = (x) => {
519
+ let v = null, S = !1;
520
520
  return Object.keys(x || {}).forEach((j) => {
521
- const R = [].concat(x[j]).map((U) => o[U] || U), F = M(j), N = e.querySelector('[data-gjsf-error-for="' + $(j) + '"]');
522
- !F && !N || (w = !0, F && F.classList.add("has-error"), N && (N.textContent = R.join(" ")), r('[name="' + $(j) + '"]').forEach((U) => {
521
+ const M = [].concat(x[j]).map((U) => o[U] || U), F = T(j), I = e.querySelector('[data-gjsf-error-for="' + $(j) + '"]');
522
+ !F && !I || (S = !0, F && F.classList.add("has-error"), I && (I.textContent = M.join(" ")), r('[name="' + $(j) + '"]').forEach((U) => {
523
523
  U.setAttribute("aria-invalid", "true"), v || (v = U);
524
524
  }));
525
- }), v && v.focus(), w;
525
+ }), v && v.focus(), S;
526
526
  };
527
527
  e.addEventListener("input", (x) => {
528
528
  const v = x.target;
529
- v && v.name && B(v.name);
529
+ v && v.name && J(v.name);
530
530
  }), e.addEventListener("change", (x) => {
531
531
  const v = x.target;
532
- v && v.name && B(v.name);
532
+ v && v.name && J(v.name);
533
533
  });
534
- const E = (x, v, w) => {
535
- const j = new (s.CustomEvent || CustomEvent)(x, { bubbles: !0, cancelable: !!w, detail: v });
534
+ const _ = (x, v, S) => {
535
+ const j = new (s.CustomEvent || CustomEvent)(x, { bubbles: !0, cancelable: !!S, detail: v });
536
536
  return e.dispatchEvent(j), j;
537
537
  };
538
538
  e.addEventListener("submit", (x) => {
539
539
  if (x.preventDefault(), e.classList.contains("is-sending")) return;
540
540
  P(), h(!0);
541
541
  const v = {};
542
- if (r("[data-gjsf-required]").forEach((S) => {
543
- const C = S.getAttribute("data-gjsf-field") || "";
544
- S.querySelector("input:checked") || (v[C] = ["required"]);
542
+ if (r("[data-gjsf-required]").forEach((E) => {
543
+ const C = E.getAttribute("data-gjsf-field") || "";
544
+ E.querySelector("input:checked") || (v[C] = ["required"]);
545
545
  }), typeof e.checkValidity == "function" && !e.checkValidity()) {
546
546
  typeof e.reportValidity == "function" && e.reportValidity();
547
547
  return;
548
548
  }
549
549
  if (Object.keys(v).length) {
550
- J(v);
550
+ H(v);
551
551
  return;
552
552
  }
553
- const w = new FormData(e), j = {};
554
- let R = !1;
555
- w.forEach((S, C) => {
556
- if (typeof S != "string") {
557
- if (!S.name && !S.size) return;
558
- R = !0;
553
+ const S = new FormData(e), j = {};
554
+ let M = !1;
555
+ S.forEach((E, C) => {
556
+ if (typeof E != "string") {
557
+ if (!E.name && !E.size) return;
558
+ M = !0;
559
559
  }
560
- C in j ? j[C] = [].concat(j[C], S) : j[C] = S;
561
- }), r("[data-gjsf-field]").forEach((S) => {
562
- const C = S.getAttribute("data-gjsf-field") || "", X = S.classList;
563
- X.contains("gjsf-field--checkboxes") || S.querySelector("select[multiple]") ? j[C] = C in j ? [].concat(j[C]) : [] : X.contains("gjsf-field--checkbox") && (j[C] = C in j);
560
+ C in j ? j[C] = [].concat(j[C], E) : j[C] = E;
561
+ }), r("[data-gjsf-field]").forEach((E) => {
562
+ const C = E.getAttribute("data-gjsf-field") || "", X = E.classList;
563
+ X.contains("gjsf-field--checkboxes") || E.querySelector("select[multiple]") ? j[C] = C in j ? [].concat(j[C]) : [] : X.contains("gjsf-field--checkbox") && (j[C] = C in j);
564
564
  });
565
- const F = { url: a.href, referrer: t.referrer || "", lang: t.documentElement.lang || "" };
565
+ const F = { url: n.href, referrer: t.referrer || "", lang: t.documentElement.lang || "" };
566
566
  l("data-gjsf-page") && (F.page_id = l("data-gjsf-page"));
567
- const N = l("data-gjsf-form"), U = (S) => {
568
- E("gjsf:success", { formId: N, data: j, response: S });
569
- const C = S && S.redirect || l("data-gjsf-redirect");
567
+ const I = l("data-gjsf-form"), U = (E) => {
568
+ _("gjsf:success", { formId: I, data: j, response: E });
569
+ const C = E && E.redirect || l("data-gjsf-redirect");
570
570
  if (C) {
571
- _("success", ""), a.assign(C);
571
+ w("success", ""), n.assign(C);
572
572
  return;
573
573
  }
574
- l("data-gjsf-reset") !== "false" && (e.reset(), h(!1)), _("success", S && S.message || l("data-gjsf-success"));
575
- }, Z = (S, C) => {
576
- C && C.errors && J(C.errors), E("gjsf:error", { formId: N, data: j, status: S, response: C }), _("error", C && (C.error || C.message) || l("data-gjsf-error"));
577
- }, K = { formId: N, data: j, meta: F, formData: w, promise: null }, Q = E("gjsf:submit", K, !0);
578
- _("sending");
579
- let H;
580
- if (K.promise) H = Promise.resolve(K.promise);
574
+ l("data-gjsf-reset") !== "false" && (e.reset(), h(!1)), w("success", E && E.message || l("data-gjsf-success"));
575
+ }, Z = (E, C) => {
576
+ C && C.errors && H(C.errors), _("gjsf:error", { formId: I, data: j, status: E, response: C }), w("error", C && (C.error || C.message) || l("data-gjsf-error"));
577
+ }, K = { formId: I, data: j, meta: F, formData: S, promise: null }, Q = _("gjsf:submit", K, !0);
578
+ w("sending");
579
+ let z;
580
+ if (K.promise) z = Promise.resolve(K.promise);
581
581
  else if (Q.defaultPrevented) {
582
- _("");
582
+ w("");
583
583
  return;
584
584
  } else {
585
- const S = e.getAttribute("action");
586
- if (!S) {
585
+ const E = e.getAttribute("action");
586
+ if (!E) {
587
587
  Z(0, {});
588
588
  return;
589
589
  }
590
590
  let C;
591
591
  const X = { Accept: "application/json" };
592
- R ? (w.append("_meta", JSON.stringify(F)), C = w) : (X["Content-Type"] = "application/json", C = JSON.stringify({ data: j, meta: F })), H = s.fetch(S, { method: "POST", headers: X, body: C, credentials: "same-origin" }).then(
593
- (se) => se.text().then((ne) => {
592
+ M ? (S.append("_meta", JSON.stringify(F)), C = S) : (X["Content-Type"] = "application/json", C = JSON.stringify({ data: j, meta: F })), z = s.fetch(E, { method: "POST", headers: X, body: C, credentials: "same-origin" }).then(
593
+ (se) => se.text().then((ae) => {
594
594
  let ee = {};
595
595
  try {
596
- ee = ne ? JSON.parse(ne) : {};
596
+ ee = ae ? JSON.parse(ae) : {};
597
597
  } catch {
598
598
  ee = {};
599
599
  }
@@ -602,13 +602,13 @@ function Ce(i) {
602
602
  })
603
603
  );
604
604
  }
605
- H.then(
606
- (S) => U(S || {}),
607
- (S) => Z(S && S.status || 0, S && (S.body || (S.errors ? S : null)) || {})
605
+ z.then(
606
+ (E) => U(E || {}),
607
+ (E) => Z(E && E.status || 0, E && (E.body || (E.errors ? E : null)) || {})
608
608
  );
609
609
  });
610
610
  }
611
- const q = "gjsf-form", Ee = "gjsf-part", pe = "data-gjsf-form", lt = "data-gjsf-part", ct = {
611
+ const q = "gjsf-form", Ee = "gjsf-part", ce = "data-gjsf-form", lt = "data-gjsf-part", ct = {
612
612
  removable: !1,
613
613
  draggable: !1,
614
614
  copyable: !1,
@@ -619,6 +619,19 @@ const q = "gjsf-form", Ee = "gjsf-part", pe = "data-gjsf-form", lt = "data-gjsf-
619
619
  hoverable: !0,
620
620
  layerable: !0
621
621
  }, ss = ["action", "method", "enctype", "data-gjsf-success", "data-gjsf-error", "data-gjsf-redirect", "data-gjsf-reset", "data-gjsf-version", "data-gjsf-codes", "data-gjsf-page", "data-gjsf-missing"];
622
+ function is(i, e) {
623
+ const t = (r) => r.replace(/[^\w-]/g, "_"), s = /* @__PURE__ */ new Map(), n = (r, l) => {
624
+ var a, d;
625
+ if (typeof r == "string") return;
626
+ const o = (a = r.attrs) == null ? void 0 : a["data-gjsf-field"], u = o ? t(o) : l;
627
+ if (!((d = r.attrs) != null && d.id)) {
628
+ const g = `gjsf-${e}-${u}-${t(r.part)}`, h = s.get(g) || 0;
629
+ s.set(g, h + 1), r.attrs = { ...r.attrs || {}, id: h ? `${g}-${h}` : g };
630
+ }
631
+ (r.kids || []).forEach((g) => n(g, u));
632
+ };
633
+ return i.forEach((r) => n(r, "form")), i;
634
+ }
622
635
  function dt(i) {
623
636
  return typeof i == "string" ? { type: "textnode", content: i } : {
624
637
  type: Ee,
@@ -630,24 +643,24 @@ function dt(i) {
630
643
  ...ct
631
644
  };
632
645
  }
633
- const De = () => Math.random().toString(36).slice(2, 7), is = `.${L.hp}{position:absolute!important;left:-10000px!important;width:1px;height:1px;overflow:hidden}`, rs = `
646
+ const Me = () => Math.random().toString(36).slice(2, 7), rs = `.${L.hp}{position:absolute!important;left:-10000px!important;width:1px;height:1px;overflow:hidden}`, ns = `
634
647
  form.${L.form}:empty{min-height:64px;outline:1px dashed rgba(127,127,127,.6);display:flex;align-items:center;justify-content:center}
635
648
  form.${L.form}:empty::before{content:attr(data-gjsf-placeholder);opacity:.6;font:13px/1.3 sans-serif}
636
649
  form.${L.form}[data-gjsf-missing]{outline:1px dashed #e57373}
637
650
  `;
638
651
  class as {
639
652
  constructor(e, t) {
640
- T(this, "offs", []);
653
+ O(this, "offs", []);
641
654
  this.editor = e, this.host = t;
642
- const s = e.DomComponents, a = this;
655
+ const s = e.DomComponents, n = this;
643
656
  s.addType(Ee, {
644
- isComponent: (n) => {
657
+ isComponent: (a) => {
645
658
  var d;
646
- return (d = n == null ? void 0 : n.getAttribute) != null && d.call(n, lt) ? { type: Ee } : !1;
659
+ return (d = a == null ? void 0 : a.getAttribute) != null && d.call(a, lt) ? { type: Ee } : !1;
647
660
  },
648
661
  model: { defaults: { ...ct } }
649
662
  }), s.addType(q, {
650
- isComponent: (n) => (n == null ? void 0 : n.tagName) === "FORM" && n.hasAttribute(pe) ? { type: q, formId: n.getAttribute(pe) || "" } : !1,
663
+ isComponent: (a) => (a == null ? void 0 : a.tagName) === "FORM" && a.hasAttribute(ce) ? { type: q, formId: a.getAttribute(ce) || "" } : !1,
651
664
  model: {
652
665
  defaults: {
653
666
  tagName: "form",
@@ -661,7 +674,7 @@ class as {
661
674
  traits: []
662
675
  },
663
676
  init() {
664
- this.get("gjsfKey") || this.set("gjsfKey", De()), this.set("traits", a.traits()), this.on("change:formId", () => a.rebuild(this));
677
+ this.get("gjsfKey") || this.set("gjsfKey", Me()), this.set("traits", n.traits()), this.on("change:formId", () => n.rebuild(this));
665
678
  }
666
679
  },
667
680
  view: {
@@ -669,29 +682,29 @@ class as {
669
682
  dblclick: "onEdit",
670
683
  submit: "onSubmit"
671
684
  },
672
- onEdit(n) {
685
+ onEdit(a) {
673
686
  var d;
674
- (d = n == null ? void 0 : n.stopPropagation) == null || d.call(n), e.runCommand(t.editCommand, { component: this.model });
687
+ (d = a == null ? void 0 : a.stopPropagation) == null || d.call(a), e.runCommand(t.editCommand, { component: this.model });
675
688
  },
676
- onSubmit(n) {
677
- n.preventDefault();
689
+ onSubmit(a) {
690
+ a.preventDefault();
678
691
  }
679
692
  }
680
693
  });
681
- const r = (n) => {
682
- if (!(!n || n.__gjsfGuard) && (n.__gjsfGuard = !0, n.addEventListener(
694
+ const r = (a) => {
695
+ if (!(!a || a.__gjsfGuard) && (a.__gjsfGuard = !0, a.addEventListener(
683
696
  "submit",
684
697
  (d) => {
685
698
  d.preventDefault(), d.stopPropagation();
686
699
  },
687
700
  !0
688
- ), !n.getElementById("gjsf-canvas-style"))) {
689
- const d = n.createElement("style");
690
- d.id = "gjsf-canvas-style", d.textContent = rs, (n.head || n.documentElement).appendChild(d);
701
+ ), !a.getElementById("gjsf-canvas-style"))) {
702
+ const d = a.createElement("style");
703
+ d.id = "gjsf-canvas-style", d.textContent = ns, (a.head || a.documentElement).appendChild(d);
691
704
  }
692
- }, l = (n) => {
693
- var d, b, h, y;
694
- return r(((d = n == null ? void 0 : n.window) == null ? void 0 : d.document) || ((y = (h = (b = n == null ? void 0 : n.frame) == null ? void 0 : b.view) == null ? void 0 : h.getDoc) == null ? void 0 : y.call(h)) || e.Canvas.getDocument());
705
+ }, l = (a) => {
706
+ var d, g, h, y;
707
+ return r(((d = a == null ? void 0 : a.window) == null ? void 0 : d.document) || ((y = (h = (g = a == null ? void 0 : a.frame) == null ? void 0 : g.view) == null ? void 0 : h.getDoc) == null ? void 0 : y.call(h)) || e.Canvas.getDocument());
695
708
  };
696
709
  e.on("canvas:frame:load", l), this.offs.push(() => e.off("canvas:frame:load", l)), e.onReady(() => {
697
710
  try {
@@ -699,14 +712,14 @@ class as {
699
712
  } catch {
700
713
  }
701
714
  });
702
- const o = (n) => {
715
+ const o = (a) => {
703
716
  var d;
704
- ((d = n == null ? void 0 : n.get) == null ? void 0 : d.call(n, "type")) === q && (n.get("gjsfCreate") ? (n.unset("gjsfCreate"), t.onCreate(n)) : n.get("formId") && !n.components().length && this.rebuild(n), this.ensureCss());
717
+ ((d = a == null ? void 0 : a.get) == null ? void 0 : d.call(a, "type")) === q && (a.get("gjsfCreate") ? (a.unset("gjsfCreate"), t.onCreate(a)) : a.get("formId") && !a.components().length && this.rebuild(a), this.ensureCss());
705
718
  };
706
719
  e.on("component:add", o), this.offs.push(() => e.off("component:add", o));
707
- const u = (n) => {
720
+ const u = (a) => {
708
721
  var d;
709
- ((d = n == null ? void 0 : n.get) == null ? void 0 : d.call(n, "type")) === q && this.refreshTraits(n);
722
+ ((d = a == null ? void 0 : a.get) == null ? void 0 : d.call(a, "type")) === q && this.refreshTraits(a);
710
723
  };
711
724
  e.on("component:selected", u), this.offs.push(() => e.off("component:selected", u));
712
725
  }
@@ -733,15 +746,15 @@ class as {
733
746
  }
734
747
  /** All form components of the open project. */
735
748
  all() {
736
- const e = [], t = (a) => {
737
- a.get("type") === q && e.push(a), a.components().forEach(t);
749
+ const e = [], t = (n) => {
750
+ n.get("type") === q && e.push(n), n.components().forEach(t);
738
751
  }, s = this.editor.getWrapper();
739
752
  return s && t(s), e;
740
753
  }
741
754
  /** Adds the rules the site needs once (in the project CSS). */
742
755
  ensureCss() {
743
756
  const e = this.editor.Css;
744
- e.getRule(`.${L.hp}`) || e.addRules(is);
757
+ e.getRule(`.${L.hp}`) || e.addRules(rs);
745
758
  }
746
759
  /**
747
760
  * Rebuilds a form component from its form: its parts are replaced, the
@@ -750,39 +763,51 @@ class as {
750
763
  * whose form is gone keeps its parts (a copy) and is marked.
751
764
  */
752
765
  rebuild(e) {
753
- const t = String(e.get("formId") || ""), s = this.host.form(t), a = { "data-gjsf-placeholder": this.host.labels.noForm() }, r = () => {
754
- var h;
766
+ const t = String(e.get("formId") || ""), s = this.host.form(t), n = { "data-gjsf-placeholder": this.host.labels.noForm() }, r = () => {
767
+ var w, $;
755
768
  const o = { ...e.getAttributes() }, u = e.get("gjsfOwnAttrs") || [];
756
- if ([...ss, ...u].forEach((y) => delete o[y]), !t) {
757
- delete o[pe], e.setAttributes({ ...o, ...a }), e.components().reset();
769
+ if ([...ss, ...u].forEach((T) => delete o[T]), !t) {
770
+ delete o[ce], e.setAttributes({ ...o, ...n }), e.components().reset();
758
771
  return;
759
772
  }
760
773
  if (!s) {
761
- e.setAttributes({ ...o, [pe]: t, "data-gjsf-missing": "", "data-gjsf-placeholder": this.host.labels.missingForm() });
774
+ e.setAttributes({ ...o, [ce]: t, "data-gjsf-missing": "", "data-gjsf-placeholder": this.host.labels.missingForm() });
762
775
  return;
763
776
  }
764
- const n = this.host.buildOptions(s, e), d = rt(s, n);
777
+ const a = this.host.buildOptions(s, e), d = rt(s, a);
765
778
  delete o["data-gjsf-placeholder"];
766
- const b = Object.keys(s.attrs || {}).filter((y) => y !== "class");
767
- e.set("gjsfOwnAttrs", b), e.setAttributes({ ...o, ...d, ...a }), (((h = s.attrs) == null ? void 0 : h.class) || "").split(/\s+/).filter(Boolean).forEach((y) => e.addClass(y)), e.components().reset(), e.components().add(at(s, { ...n, key: e.get("gjsfKey") || De() }).map(dt)), this.ensureCss();
779
+ const g = Object.keys(s.attrs || {}).filter((T) => T !== "class");
780
+ e.set("gjsfOwnAttrs", g), e.setAttributes({ ...o, ...d, ...n }), (((w = s.attrs) == null ? void 0 : w.class) || "").split(/\s+/).filter(Boolean).forEach((T) => e.addClass(T));
781
+ const h = this.editor.getSelected(), y = h && h !== e && (($ = h.closest) == null ? void 0 : $.call(h, `[${ce}]`)) === e ? h.getId() : "", p = e.get("gjsfKey") || Me();
782
+ if (e.components().reset(is(nt(s, { ...a, key: p }), String(p).replace(/[^\w-]/g, "")).map(dt)), this.ensureCss(), y) {
783
+ const T = this.find(e, (J) => J.getId() === y);
784
+ T && this.editor.select(T);
785
+ }
768
786
  }, l = this.editor.UndoManager;
769
787
  l != null && l.skip ? l.skip(r) : r();
770
788
  }
789
+ find(e, t) {
790
+ let s;
791
+ const n = (r) => {
792
+ s || (t(r) ? s = r : r.components().forEach(n));
793
+ };
794
+ return e.components().forEach(n), s;
795
+ }
771
796
  /** Rebuilds the components of one form (all when no id); `stale` — only those built from another version or for another page. */
772
797
  rebuildAll(e, t) {
773
798
  let s = 0;
774
- return this.all().forEach((a) => {
775
- const r = String(a.get("formId") || "");
799
+ return this.all().forEach((n) => {
800
+ const r = String(n.get("formId") || "");
776
801
  if (e && r !== e) return;
777
802
  const l = this.host.form(r);
778
- t && l && !t(a, l) || t && !l && !r || (this.rebuild(a), s++);
803
+ t && l && !t(n, l) || t && !l && !r || (this.rebuild(n), s++);
779
804
  }), s;
780
805
  }
781
806
  destroy() {
782
807
  this.offs.splice(0).forEach((e) => e());
783
808
  }
784
809
  }
785
- const ce = {
810
+ const de = {
786
811
  /** The forms were (re)read or one changed. Payload: `FormDef[]`. */
787
812
  forms: "forms:list",
788
813
  /** A form was written. Payload: `FormDef`. */
@@ -796,7 +821,7 @@ const ce = {
796
821
  open: "forms:open",
797
822
  /** Opens the editor on the form of the selected component (or `{ component }`). */
798
823
  edit: "forms:edit"
799
- }, Cs = {
824
+ }, As = {
800
825
  submit: "gjsf:submit",
801
826
  success: "gjsf:success",
802
827
  error: "gjsf:error"
@@ -932,7 +957,7 @@ const ce = {
932
957
  defaultName: "Name",
933
958
  defaultEmail: "E-mail",
934
959
  defaultMessage: "Message"
935
- }, ns = {
960
+ }, os = {
936
961
  forms: "Формы",
937
962
  newForm: "Новая форма",
938
963
  defaultFormName: "Форма",
@@ -1064,7 +1089,7 @@ const ce = {
1064
1089
  defaultName: "Имя",
1065
1090
  defaultEmail: "E-mail",
1066
1091
  defaultMessage: "Сообщение"
1067
- }, os = {
1092
+ }, ls = {
1068
1093
  forms: "Форми",
1069
1094
  newForm: "Нова форма",
1070
1095
  defaultFormName: "Форма",
@@ -1196,30 +1221,30 @@ const ce = {
1196
1221
  defaultName: "Імʼя",
1197
1222
  defaultEmail: "E-mail",
1198
1223
  defaultMessage: "Повідомлення"
1199
- }, ut = "gjsForms", mt = { en: pt, ru: ns, uk: os }, ls = Object.keys(mt);
1200
- function cs(i) {
1224
+ }, ut = "gjsForms", mt = { en: pt, ru: os, uk: ls }, cs = Object.keys(mt);
1225
+ function ds(i) {
1201
1226
  const e = i.I18n;
1202
1227
  if (!e || typeof e.addMessages != "function") return;
1203
1228
  const t = {};
1204
- ls.forEach((s) => {
1229
+ cs.forEach((s) => {
1205
1230
  t[s] = { [ut]: { ...mt[s] } };
1206
1231
  }), e.addMessages(t);
1207
1232
  }
1208
- function ds(i, e = {}) {
1233
+ function ps(i, e = {}) {
1209
1234
  return (t) => {
1210
1235
  var r;
1211
1236
  const s = e[t];
1212
1237
  if (typeof s == "string" && s) return s;
1213
- let a;
1238
+ let n;
1214
1239
  try {
1215
- a = (r = i.I18n) == null ? void 0 : r.t(`${ut}.${t}`, { params: { form: "{form}", page: "{page}" } });
1240
+ n = (r = i.I18n) == null ? void 0 : r.t(`${ut}.${t}`, { params: { form: "{form}", page: "{page}" } });
1216
1241
  } catch {
1217
- a = void 0;
1242
+ n = void 0;
1218
1243
  }
1219
- return typeof a == "string" && a ? a : pt[t];
1244
+ return typeof n == "string" && n ? n : pt[t];
1220
1245
  };
1221
1246
  }
1222
- const te = (i, ...e) => e.reduce((t, s) => t.replace("%s", String(s)), i), I = (i) => i === void 0 ? i : JSON.parse(JSON.stringify(i)), _e = () => {
1247
+ const te = (i, ...e) => e.reduce((t, s) => t.replace("%s", String(s)), i), R = (i) => i === void 0 ? i : JSON.parse(JSON.stringify(i)), _e = () => {
1223
1248
  const i = typeof globalThis < "u" ? globalThis.crypto : void 0;
1224
1249
  if (i && typeof i.randomUUID == "function")
1225
1250
  try {
@@ -1232,13 +1257,13 @@ const te = (i, ...e) => e.reduce((t, s) => t.replace("%s", String(s)), i), I = (
1232
1257
  e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
1233
1258
  const t = [...e].map((s) => s.toString(16).padStart(2, "0")).join("");
1234
1259
  return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
1235
- }, Me = (i) => {
1260
+ }, De = (i) => {
1236
1261
  console.error("[grapesjs-forms]", i);
1237
1262
  };
1238
1263
  class Ae extends Error {
1239
1264
  constructor(t = "The form was changed elsewhere (412)") {
1240
1265
  super(t);
1241
- T(this, "status", 412);
1266
+ O(this, "status", 412);
1242
1267
  this.name = "ConflictError";
1243
1268
  }
1244
1269
  }
@@ -1249,25 +1274,25 @@ class G extends Error {
1249
1274
  }
1250
1275
  class ft {
1251
1276
  constructor() {
1252
- T(this, "forms", /* @__PURE__ */ new Map());
1253
- T(this, "submissions", /* @__PURE__ */ new Map());
1277
+ O(this, "forms", /* @__PURE__ */ new Map());
1278
+ O(this, "submissions", /* @__PURE__ */ new Map());
1254
1279
  }
1255
1280
  /** Hook of persistent subclasses: a key changed (`null` value — deleted). */
1256
1281
  async changed(e, t) {
1257
1282
  }
1258
1283
  async listForms() {
1259
- return [...this.forms.values()].map(I);
1284
+ return [...this.forms.values()].map(R);
1260
1285
  }
1261
1286
  async getForm(e) {
1262
1287
  const t = this.forms.get(e);
1263
- return t ? I(t) : void 0;
1288
+ return t ? R(t) : void 0;
1264
1289
  }
1265
1290
  async saveForm(e, t) {
1266
1291
  if (!e.id) throw new G("A form needs an id", 422, { id: ["required"] });
1267
1292
  const s = this.forms.get(e.id);
1268
1293
  if (t != null && s && String(s.version) !== String(t)) throw new Ae();
1269
- const a = V({ ...e, version: (Number(s == null ? void 0 : s.version) || 0) + 1, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
1270
- return this.forms.set(a.id, a), await this.changed(`form:${a.id}`, a), I(a);
1294
+ const n = V({ ...e, version: (Number(s == null ? void 0 : s.version) || 0) + 1, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
1295
+ return this.forms.set(n.id, n), await this.changed(`form:${n.id}`, n), R(n);
1271
1296
  }
1272
1297
  async deleteForm(e) {
1273
1298
  if (this.forms.delete(e)) {
@@ -1277,36 +1302,36 @@ class ft {
1277
1302
  }
1278
1303
  }
1279
1304
  async submit(e, t, s) {
1280
- const a = this.forms.get(e);
1281
- if (!a) throw new G("No such form", 404);
1282
- const r = Kt(a, t);
1305
+ const n = this.forms.get(e);
1306
+ if (!n) throw new G("No such form", 404);
1307
+ const r = Kt(n, t);
1283
1308
  if (r.spam) return {};
1284
1309
  if (!r.ok) throw new G("The given data was invalid.", 422, r.errors);
1285
- const l = (d) => typeof Blob < "u" && d instanceof Blob, o = (d) => l(d) ? { name: d.name || "", size: d.size, type: d.type } : Array.isArray(d) ? d.map(o) : d, u = Object.fromEntries(Object.entries(r.data).map(([d, b]) => [d, o(b)])), n = { id: _e(), formId: e, data: u, createdAt: (/* @__PURE__ */ new Date()).toISOString(), ...s ? { meta: I(s) } : {} };
1286
- return this.submissions.set(n.id, n), await this.changed(`submission:${n.id}`, n), { id: n.id, createdAt: n.createdAt };
1310
+ const l = (d) => typeof Blob < "u" && d instanceof Blob, o = (d) => l(d) ? { name: d.name || "", size: d.size, type: d.type } : Array.isArray(d) ? d.map(o) : d, u = Object.fromEntries(Object.entries(r.data).map(([d, g]) => [d, o(g)])), a = { id: _e(), formId: e, data: u, createdAt: (/* @__PURE__ */ new Date()).toISOString(), ...s ? { meta: R(s) } : {} };
1311
+ return this.submissions.set(a.id, a), await this.changed(`submission:${a.id}`, a), { id: a.id, createdAt: a.createdAt };
1287
1312
  }
1288
1313
  async listSubmissions(e, t = {}) {
1289
- const s = [...this.submissions.values()].filter((l) => l.formId === e).sort((l, o) => l.createdAt < o.createdAt ? 1 : l.createdAt > o.createdAt ? -1 : 0), a = Math.max(0, t.offset || 0), r = Math.max(1, t.limit || 50);
1290
- return { items: s.slice(a, a + r).map(I), total: s.length };
1314
+ const s = [...this.submissions.values()].filter((l) => l.formId === e).sort((l, o) => l.createdAt < o.createdAt ? 1 : l.createdAt > o.createdAt ? -1 : 0), n = Math.max(0, t.offset || 0), r = Math.max(1, t.limit || 50);
1315
+ return { items: s.slice(n, n + r).map(R), total: s.length };
1291
1316
  }
1292
1317
  async deleteSubmission(e, t) {
1293
1318
  const s = this.submissions.get(t);
1294
1319
  !s || s.formId !== e || (this.submissions.delete(t), await this.changed(`submission:${t}`, null));
1295
1320
  }
1296
1321
  }
1297
- const ie = "forms", ps = 1;
1322
+ const ie = "forms", us = 1;
1298
1323
  class ht extends ft {
1299
1324
  constructor(t = "gjs-forms", s = typeof indexedDB < "u" ? indexedDB : void 0) {
1300
1325
  super();
1301
- T(this, "dbp", null);
1302
- T(this, "loaded", null);
1326
+ O(this, "dbp", null);
1327
+ O(this, "loaded", null);
1303
1328
  this.dbName = t, this.factory = s;
1304
1329
  }
1305
1330
  open() {
1306
1331
  if (this.dbp) return this.dbp;
1307
1332
  const t = this.factory;
1308
- return t ? (this.dbp = new Promise((s, a) => {
1309
- const r = t.open(this.dbName, ps);
1333
+ return t ? (this.dbp = new Promise((s, n) => {
1334
+ const r = t.open(this.dbName, us);
1310
1335
  r.onupgradeneeded = () => {
1311
1336
  r.result.objectStoreNames.contains(ie) || r.result.createObjectStore(ie, { keyPath: "key" });
1312
1337
  }, r.onsuccess = () => {
@@ -1314,26 +1339,26 @@ class ht extends ft {
1314
1339
  l.onversionchange = () => {
1315
1340
  l.close(), this.dbp = null;
1316
1341
  }, s(l);
1317
- }, r.onerror = () => a(r.error);
1342
+ }, r.onerror = () => n(r.error);
1318
1343
  }), this.dbp.catch(() => this.dbp = null), this.dbp) : Promise.reject(new Error("IndexedDB is not available"));
1319
1344
  }
1320
1345
  /** Loads the database into memory once. */
1321
1346
  load() {
1322
1347
  return this.loaded || (this.loaded = this.open().then(
1323
- (t) => new Promise((s, a) => {
1348
+ (t) => new Promise((s, n) => {
1324
1349
  const r = t.transaction(ie, "readonly").objectStore(ie).getAll();
1325
1350
  r.onsuccess = () => {
1326
1351
  r.result.forEach(({ key: l, value: o }) => {
1327
1352
  l.startsWith("form:") ? this.forms.set(l.slice(5), o) : l.startsWith("submission:") && this.submissions.set(l.slice(11), o);
1328
1353
  }), s();
1329
- }, r.onerror = () => a(r.error);
1354
+ }, r.onerror = () => n(r.error);
1330
1355
  })
1331
1356
  ), this.loaded.catch(() => this.loaded = null)), this.loaded;
1332
1357
  }
1333
1358
  async changed(t, s) {
1334
- const a = await this.open();
1359
+ const n = await this.open();
1335
1360
  await new Promise((r, l) => {
1336
- const o = a.transaction(ie, "readwrite"), u = o.objectStore(ie);
1361
+ const o = n.transaction(ie, "readwrite"), u = o.objectStore(ie);
1337
1362
  s === null ? u.delete(t) : u.put({ key: t, value: s }), o.oncomplete = () => r(), o.onerror = () => l(o.error);
1338
1363
  });
1339
1364
  }
@@ -1348,7 +1373,7 @@ for (const i of ["listForms", "getForm", "saveForm", "deleteForm", "submit", "li
1348
1373
  return await this.load(), e.apply(this, t);
1349
1374
  };
1350
1375
  }
1351
- const ye = (i) => V({ ...i, updatedAt: i.updated_at }), us = (i) => {
1376
+ const ye = (i) => V({ ...i, updatedAt: i.updated_at }), ms = (i) => {
1352
1377
  if (!i) return;
1353
1378
  const { page_id: e, ...t } = i;
1354
1379
  return { ...t, ...e != null ? { pageId: String(e) } : {} };
@@ -1356,24 +1381,24 @@ const ye = (i) => V({ ...i, updatedAt: i.updated_at }), us = (i) => {
1356
1381
  if (!i) return;
1357
1382
  const { pageId: e, ...t } = i;
1358
1383
  return { ...t, ...e != null ? { page_id: e } : {} };
1359
- }, ms = (i) => ({
1384
+ }, fs = (i) => ({
1360
1385
  id: i.id,
1361
1386
  formId: i.form_id,
1362
1387
  data: i.data || {},
1363
1388
  createdAt: i.created_at,
1364
- ...i.meta ? { meta: us(i.meta) } : {}
1389
+ ...i.meta ? { meta: ms(i.meta) } : {}
1365
1390
  }), gt = (i) => typeof Blob < "u" && i instanceof Blob || Array.isArray(i) && i.some(gt), Ue = (i, e) => `${(i || "").trim().replace(/\/+$/, "")}/forms/${encodeURIComponent(e)}/submissions`;
1366
- class fs {
1391
+ class hs {
1367
1392
  constructor(e) {
1368
1393
  this.opts = e;
1369
1394
  }
1370
1395
  get base() {
1371
1396
  return (this.opts.url || "").trim().replace(/\/+$/, "");
1372
1397
  }
1373
- async request(e, t, { body: s, version: a, raw: r } = {}) {
1374
- var d, b;
1398
+ async request(e, t, { body: s, version: n, raw: r } = {}) {
1399
+ var d, g;
1375
1400
  const l = { Accept: "application/json" };
1376
- s !== void 0 && (l["Content-Type"] = "application/json"), a != null && (l["If-Match"] = `"${a}"`), Object.assign(l, ((b = (d = this.opts).headers) == null ? void 0 : b.call(d)) || {});
1401
+ s !== void 0 && (l["Content-Type"] = "application/json"), n != null && (l["If-Match"] = `"${n}"`), Object.assign(l, ((g = (d = this.opts).headers) == null ? void 0 : g.call(d)) || {});
1377
1402
  const u = await (this.opts.fetch || globalThis.fetch.bind(globalThis))(this.base + t, {
1378
1403
  method: e,
1379
1404
  headers: l,
@@ -1391,8 +1416,8 @@ class fs {
1391
1416
  throw new G(h, u.status, y);
1392
1417
  }
1393
1418
  if (u.status === 204) return null;
1394
- const n = await u.text();
1395
- return n ? JSON.parse(n) : null;
1419
+ const a = await u.text();
1420
+ return a ? JSON.parse(a) : null;
1396
1421
  }
1397
1422
  async listForms() {
1398
1423
  const e = await this.request("GET", "/forms");
@@ -1419,12 +1444,12 @@ class fs {
1419
1444
  }
1420
1445
  /** JSON `{ data, meta }`; with files `multipart/form-data` (fields by name, `_meta` as JSON). */
1421
1446
  async submit(e, t, s) {
1422
- const a = `/forms/${encodeURIComponent(e)}/submissions`;
1447
+ const n = `/forms/${encodeURIComponent(e)}/submissions`;
1423
1448
  let r;
1424
1449
  if (Object.values(t).some(gt)) {
1425
1450
  const l = new FormData();
1426
- Object.entries(t).forEach(([o, u]) => (Array.isArray(u) ? u : [u]).forEach((n) => n instanceof Blob ? l.append(o, n) : n != null && l.append(o, String(n)))), s && l.append("_meta", JSON.stringify(Pe(s))), r = await this.request("POST", a, { raw: l });
1427
- } else r = await this.request("POST", a, { body: { data: t, ...s ? { meta: Pe(s) } : {} } });
1451
+ Object.entries(t).forEach(([o, u]) => (Array.isArray(u) ? u : [u]).forEach((a) => a instanceof Blob ? l.append(o, a) : a != null && l.append(o, String(a)))), s && l.append("_meta", JSON.stringify(Pe(s))), r = await this.request("POST", n, { raw: l });
1452
+ } else r = await this.request("POST", n, { body: { data: t, ...s ? { meta: Pe(s) } : {} } });
1428
1453
  return {
1429
1454
  ...r != null && r.id ? { id: r.id } : {},
1430
1455
  ...r != null && r.created_at ? { createdAt: r.created_at } : {},
@@ -1435,7 +1460,7 @@ class fs {
1435
1460
  async listSubmissions(e, t = {}) {
1436
1461
  const s = new URLSearchParams();
1437
1462
  t.limit && s.set("limit", String(t.limit)), t.offset && s.set("offset", String(t.offset));
1438
- const a = s.toString(), r = await this.request("GET", `/forms/${encodeURIComponent(e)}/submissions${a ? `?${a}` : ""}`), l = ((r == null ? void 0 : r.items) || []).map(ms);
1463
+ const n = s.toString(), r = await this.request("GET", `/forms/${encodeURIComponent(e)}/submissions${n ? `?${n}` : ""}`), l = ((r == null ? void 0 : r.items) || []).map(fs);
1439
1464
  return { items: l, total: typeof (r == null ? void 0 : r.total) == "number" ? r.total : l.length };
1440
1465
  }
1441
1466
  async deleteSubmission(e, t) {
@@ -1446,7 +1471,7 @@ class fs {
1446
1471
  }
1447
1472
  }
1448
1473
  }
1449
- const z = (i) => {
1474
+ const B = (i) => {
1450
1475
  if (i != null) {
1451
1476
  if (typeof i == "string") return i;
1452
1477
  if (typeof i == "object") {
@@ -1455,9 +1480,9 @@ const z = (i) => {
1455
1480
  }
1456
1481
  return String(i);
1457
1482
  }
1458
- }, xe = (i) => i == null ? void 0 : i.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim() || void 0, de = (i) => (Array.isArray(i) ? i : []).map(
1459
- (e) => e && typeof e == "object" ? { value: String(e.value ?? z(e.text) ?? ""), label: z(e.text) ?? String(e.value ?? "") } : { value: String(e), label: String(e) }
1460
- ), hs = {
1483
+ }, xe = (i) => i == null ? void 0 : i.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim() || void 0, pe = (i) => (Array.isArray(i) ? i : []).map(
1484
+ (e) => e && typeof e == "object" ? { value: String(e.value ?? B(e.text) ?? ""), label: B(e.text) ?? String(e.value ?? "") } : { value: String(e), label: String(e) }
1485
+ ), gs = {
1461
1486
  text: "text",
1462
1487
  email: "email",
1463
1488
  tel: "tel",
@@ -1470,29 +1495,29 @@ const z = (i) => {
1470
1495
  range: "range",
1471
1496
  color: "color"
1472
1497
  };
1473
- function gs(i) {
1474
- const e = [], t = (s) => (Array.isArray(s) ? s : []).forEach((a) => {
1475
- if (!(!a || typeof a != "object"))
1476
- if (a.type === "panel" || a.type === "flowpanel") {
1477
- const r = z(a.title);
1478
- r && e.push({ type: "html", html: r, __heading: !0 }), t(a.elements || a.questions);
1479
- } else e.push(a);
1498
+ function bs(i) {
1499
+ const e = [], t = (s) => (Array.isArray(s) ? s : []).forEach((n) => {
1500
+ if (!(!n || typeof n != "object"))
1501
+ if (n.type === "panel" || n.type === "flowpanel") {
1502
+ const r = B(n.title);
1503
+ r && e.push({ type: "html", html: r, __heading: !0 }), t(n.elements || n.questions);
1504
+ } else e.push(n);
1480
1505
  });
1481
1506
  return Array.isArray(i.pages) && i.pages.forEach((s) => t((s == null ? void 0 : s.elements) || (s == null ? void 0 : s.questions))), t(i.elements || i.questions), e;
1482
1507
  }
1483
1508
  function Je(i, e = "") {
1484
1509
  const t = [], s = [];
1485
- gs(i || {}).forEach((r) => {
1486
- const l = { id: Y(), name: r.name, label: z(r.title) ?? r.name };
1510
+ bs(i || {}).forEach((r) => {
1511
+ const l = { id: Y(), name: r.name, label: B(r.title) ?? r.name };
1487
1512
  r.isRequired && (l.required = !0);
1488
- const o = z(r.placeholder ?? r.placeHolder);
1513
+ const o = B(r.placeholder ?? r.placeHolder);
1489
1514
  o && (l.placeholder = o);
1490
- const u = z(r.description);
1515
+ const u = B(r.description);
1491
1516
  u && (l.help = u), r.defaultValue != null && (l.value = Array.isArray(r.defaultValue) ? r.defaultValue.join(",") : String(r.defaultValue)), r.readOnly && (l.readonly = !0);
1492
- const n = typeof r.width == "string" ? r.width.trim() : "";
1493
- switch (n === "50%" ? l.width = "1/2" : /^33(\.3+)?%$/.test(n) ? l.width = "1/3" : n === "25%" && (l.width = "1/4"), r.type) {
1517
+ const a = typeof r.width == "string" ? r.width.trim() : "";
1518
+ switch (a === "50%" ? l.width = "1/2" : /^33(\.3+)?%$/.test(a) ? l.width = "1/3" : a === "25%" && (l.width = "1/4"), r.type) {
1494
1519
  case "text": {
1495
- const d = hs[r.inputType || "text"];
1520
+ const d = gs[r.inputType || "text"];
1496
1521
  if (!d) {
1497
1522
  t.push(`${r.name} (text/${r.inputType})`);
1498
1523
  return;
@@ -1501,34 +1526,34 @@ function Je(i, e = "") {
1501
1526
  s.push({ id: l.id, type: "hidden", name: r.name, value: l.value });
1502
1527
  return;
1503
1528
  }
1504
- const b = { ...l, type: d };
1505
- r.min != null && (b.min = String(r.min)), r.max != null && (b.max = String(r.max)), r.step != null && (b.step = String(r.step)), r.maxLength > 0 && (b.maxLength = r.maxLength), r.autocomplete && (b.autocomplete = r.autocomplete);
1529
+ const g = { ...l, type: d };
1530
+ r.min != null && (g.min = String(r.min)), r.max != null && (g.max = String(r.max)), r.step != null && (g.step = String(r.step)), r.maxLength > 0 && (g.maxLength = r.maxLength), r.autocomplete && (g.autocomplete = r.autocomplete);
1506
1531
  const h = (r.validators || []).find((p) => (p == null ? void 0 : p.type) === "regex" && p.regex);
1507
- h && (b.pattern = String(h.regex).replace(/^\^|\$$/g, ""));
1532
+ h && (g.pattern = String(h.regex).replace(/^\^|\$$/g, ""));
1508
1533
  const y = (r.validators || []).find((p) => (p == null ? void 0 : p.type) === "text");
1509
- (y == null ? void 0 : y.minLength) > 0 && (b.minLength = y.minLength), (y == null ? void 0 : y.maxLength) > 0 && (b.maxLength = y.maxLength), s.push(b);
1534
+ (y == null ? void 0 : y.minLength) > 0 && (g.minLength = y.minLength), (y == null ? void 0 : y.maxLength) > 0 && (g.maxLength = y.maxLength), s.push(g);
1510
1535
  return;
1511
1536
  }
1512
1537
  case "comment":
1513
1538
  s.push({ ...l, type: "textarea", ...r.rows ? { rows: r.rows } : {}, ...r.maxLength > 0 ? { maxLength: r.maxLength } : {} });
1514
1539
  return;
1515
1540
  case "dropdown":
1516
- s.push({ ...l, type: "select", options: de(r.choices) });
1541
+ s.push({ ...l, type: "select", options: pe(r.choices) });
1517
1542
  return;
1518
1543
  case "tagbox":
1519
- s.push({ ...l, type: "select", multiple: !0, options: de(r.choices) });
1544
+ s.push({ ...l, type: "select", multiple: !0, options: pe(r.choices) });
1520
1545
  return;
1521
1546
  case "radiogroup":
1522
- s.push({ ...l, type: "radio", options: de(r.choices) });
1547
+ s.push({ ...l, type: "radio", options: pe(r.choices) });
1523
1548
  return;
1524
1549
  case "checkbox":
1525
- s.push({ ...l, type: "checkboxes", options: de(r.choices) });
1550
+ s.push({ ...l, type: "checkboxes", options: pe(r.choices) });
1526
1551
  return;
1527
1552
  case "boolean":
1528
- s.push({ ...l, type: "checkbox", label: z(r.label) ?? l.label, value: r.defaultValue === !0 ? "1" : void 0 });
1553
+ s.push({ ...l, type: "checkbox", label: B(r.label) ?? l.label, value: r.defaultValue === !0 ? "1" : void 0 });
1529
1554
  return;
1530
1555
  case "rating": {
1531
- const d = Array.isArray(r.rateValues) && r.rateValues.length ? de(r.rateValues) : null, b = Number(r.rateMin ?? 1), h = Number(r.rateMax ?? 5), y = Number(r.rateStep ?? 1) || 1, p = d || Array.from({ length: Math.max(0, Math.floor((h - b) / y) + 1) }, (_, $) => String(b + $ * y)).map((_) => ({ value: _, label: _ }));
1556
+ const d = Array.isArray(r.rateValues) && r.rateValues.length ? pe(r.rateValues) : null, g = Number(r.rateMin ?? 1), h = Number(r.rateMax ?? 5), y = Number(r.rateStep ?? 1) || 1, p = d || Array.from({ length: Math.max(0, Math.floor((h - g) / y) + 1) }, (w, $) => String(g + $ * y)).map((w) => ({ value: w, label: w }));
1532
1557
  s.push({ ...l, type: "radio", options: p });
1533
1558
  return;
1534
1559
  }
@@ -1536,8 +1561,8 @@ function Je(i, e = "") {
1536
1561
  s.push({ ...l, type: "file", ...r.allowMultiple ? { multiple: !0 } : {}, ...r.acceptedTypes ? { accept: r.acceptedTypes } : {} });
1537
1562
  return;
1538
1563
  case "html": {
1539
- const d = xe(z(r.html));
1540
- d && s.push({ id: l.id, type: r.__heading || /^\s*<h[1-6][\s>]/i.test(z(r.html) || "") ? "heading" : "paragraph", name: "", text: d });
1564
+ const d = xe(B(r.html));
1565
+ d && s.push({ id: l.id, type: r.__heading || /^\s*<h[1-6][\s>]/i.test(B(r.html) || "") ? "heading" : "paragraph", name: "", text: d });
1541
1566
  return;
1542
1567
  }
1543
1568
  case "expression":
@@ -1547,23 +1572,23 @@ function Je(i, e = "") {
1547
1572
  t.push(`${r.name || "?"} (${r.type})`);
1548
1573
  }
1549
1574
  });
1550
- const a = V({
1575
+ const n = V({
1551
1576
  id: e,
1552
- name: z(i == null ? void 0 : i.title) || "Form",
1577
+ name: B(i == null ? void 0 : i.title) || "Form",
1553
1578
  fields: s,
1554
1579
  settings: {
1555
- submitLabel: z(i == null ? void 0 : i.completeText),
1556
- successMessage: xe(z(i == null ? void 0 : i.completedHtml)),
1580
+ submitLabel: B(i == null ? void 0 : i.completeText),
1581
+ successMessage: xe(B(i == null ? void 0 : i.completedHtml)),
1557
1582
  redirect: i == null ? void 0 : i.navigateToUrl
1558
1583
  }
1559
1584
  });
1560
- return i != null && i.description && a.fields.unshift({ id: Y(), type: "paragraph", name: "", text: xe(z(i.description)) || "" }), { form: a, skipped: t };
1585
+ return i != null && i.description && n.fields.unshift({ id: Y(), type: "paragraph", name: "", text: xe(B(i.description)) || "" }), { form: n, skipped: t };
1561
1586
  }
1562
1587
  function He(i) {
1563
1588
  const e = [];
1564
1589
  i.fields.forEach((s) => {
1565
- const a = { name: s.name };
1566
- s.label && (a.title = s.label), s.required && (a.isRequired = !0), s.placeholder && (a.placeholder = s.placeholder), s.help && (a.description = s.help), s.readonly && (a.readOnly = !0), s.value && (a.defaultValue = s.type === "checkboxes" ? s.value.split(",").map((l) => l.trim()) : s.type === "checkbox" ? /^(1|true|on|yes)$/i.test(s.value) : s.value), s.width === "1/2" && (a.width = "50%");
1590
+ const n = { name: s.name };
1591
+ s.label && (n.title = s.label), s.required && (n.isRequired = !0), s.placeholder && (n.placeholder = s.placeholder), s.help && (n.description = s.help), s.readonly && (n.readOnly = !0), s.value && (n.defaultValue = s.type === "checkboxes" ? s.value.split(",").map((l) => l.trim()) : s.type === "checkbox" ? /^(1|true|on|yes)$/i.test(s.value) : s.value), s.width === "1/2" && (n.width = "50%");
1567
1592
  const r = (s.options || []).map((l) => l.label === l.value ? l.value : { value: l.value, text: l.label });
1568
1593
  switch (s.type) {
1569
1594
  case "heading":
@@ -1574,25 +1599,25 @@ function He(i) {
1574
1599
  e.push({ type: "text", name: s.name, visible: !1, ...s.value ? { defaultValue: s.value } : {} });
1575
1600
  return;
1576
1601
  case "textarea":
1577
- e.push({ ...a, type: "comment", ...s.rows ? { rows: s.rows } : {}, ...s.maxLength ? { maxLength: s.maxLength } : {} });
1602
+ e.push({ ...n, type: "comment", ...s.rows ? { rows: s.rows } : {}, ...s.maxLength ? { maxLength: s.maxLength } : {} });
1578
1603
  return;
1579
1604
  case "select":
1580
- e.push({ ...a, type: s.multiple ? "tagbox" : "dropdown", choices: r });
1605
+ e.push({ ...n, type: s.multiple ? "tagbox" : "dropdown", choices: r });
1581
1606
  return;
1582
1607
  case "radio":
1583
- e.push({ ...a, type: "radiogroup", choices: r });
1608
+ e.push({ ...n, type: "radiogroup", choices: r });
1584
1609
  return;
1585
1610
  case "checkboxes":
1586
- e.push({ ...a, type: "checkbox", choices: r });
1611
+ e.push({ ...n, type: "checkbox", choices: r });
1587
1612
  return;
1588
1613
  case "checkbox":
1589
- e.push({ ...a, type: "boolean", renderAs: "checkbox", ...s.label ? { label: s.label } : {} });
1614
+ e.push({ ...n, type: "boolean", renderAs: "checkbox", ...s.label ? { label: s.label } : {} });
1590
1615
  return;
1591
1616
  case "file":
1592
- e.push({ ...a, type: "file", ...s.multiple ? { allowMultiple: !0 } : {}, ...s.accept ? { acceptedTypes: s.accept } : {}, storeDataAsText: !1 });
1617
+ e.push({ ...n, type: "file", ...s.multiple ? { allowMultiple: !0 } : {}, ...s.accept ? { acceptedTypes: s.accept } : {}, storeDataAsText: !1 });
1593
1618
  return;
1594
1619
  default: {
1595
- const l = s.type === "datetime" ? "datetime-local" : s.type, o = { ...a, type: "text", ...l !== "text" ? { inputType: l } : {} };
1620
+ const l = s.type === "datetime" ? "datetime-local" : s.type, o = { ...n, type: "text", ...l !== "text" ? { inputType: l } : {} };
1596
1621
  s.min && (o.min = s.min), s.max && (o.max = s.max), s.step && (o.step = s.step), s.maxLength && (o.maxLength = s.maxLength), s.autocomplete && (o.autocomplete = s.autocomplete);
1597
1622
  const u = [];
1598
1623
  s.pattern && u.push({ type: "regex", regex: `^${s.pattern}$` }), s.minLength && u.push({ type: "text", minLength: s.minLength }), u.length && (o.validators = u), e.push(o);
@@ -1608,11 +1633,11 @@ function f(i, e = {}, ...t) {
1608
1633
  Object.entries(e).forEach(([r, l]) => {
1609
1634
  l === !1 || l == null || (r === "class" ? s.className = String(l) : r.startsWith("on") && typeof l == "function" ? s.addEventListener(r.slice(2), l) : s.setAttribute(r, l === !0 ? "" : String(l)));
1610
1635
  });
1611
- const a = (r) => {
1612
- if (Array.isArray(r)) return r.forEach(a);
1636
+ const n = (r) => {
1637
+ if (Array.isArray(r)) return r.forEach(n);
1613
1638
  r === !1 || r == null || s.append(r instanceof Node ? r : document.createTextNode(String(r)));
1614
1639
  };
1615
- return t.forEach(a), s;
1640
+ return t.forEach(n), s;
1616
1641
  }
1617
1642
  const ze = {
1618
1643
  text: "T",
@@ -1635,21 +1660,21 @@ const ze = {
1635
1660
  hidden: "👁",
1636
1661
  heading: "H",
1637
1662
  paragraph: "≡"
1638
- }, bs = 50;
1639
- class ys {
1663
+ }, ys = 50;
1664
+ class xs {
1640
1665
  constructor(e) {
1641
- T(this, "root");
1642
- T(this, "cur", null);
1643
- T(this, "tab", "fields");
1644
- T(this, "selField", null);
1645
- T(this, "statusEl", null);
1646
- T(this, "body", null);
1647
- T(this, "listEl", null);
1648
- T(this, "propsEl", null);
1649
- T(this, "sideEl", null);
1650
- T(this, "subs", []);
1651
- T(this, "subsTotal", 0);
1652
- T(this, "flashTimer", null);
1666
+ O(this, "root");
1667
+ O(this, "cur", null);
1668
+ O(this, "tab", "fields");
1669
+ O(this, "selField", null);
1670
+ O(this, "statusEl", null);
1671
+ O(this, "body", null);
1672
+ O(this, "listEl", null);
1673
+ O(this, "propsEl", null);
1674
+ O(this, "sideEl", null);
1675
+ O(this, "subs", []);
1676
+ O(this, "subsTotal", 0);
1677
+ O(this, "flashTimer", null);
1653
1678
  this.d = e, this.root = f("div", { class: "gjsf gjsf-ed" });
1654
1679
  }
1655
1680
  get t() {
@@ -1657,9 +1682,9 @@ class ys {
1657
1682
  }
1658
1683
  /** Opens on a form (the first when none given). */
1659
1684
  show(e) {
1660
- var a;
1685
+ var n;
1661
1686
  const t = this.d.forms(), s = e && this.d.form(e) || this.cur && this.d.form(this.cur.id) || t[0] || null;
1662
- this.cur = s ? I(s) : null, this.cur && !this.cur.fields.some((r) => r.id === this.selField) && (this.selField = ((a = this.cur.fields[0]) == null ? void 0 : a.id) || null), this.render();
1687
+ this.cur = s ? R(s) : null, this.cur && !this.cur.fields.some((r) => r.id === this.selField) && (this.selField = ((n = this.cur.fields[0]) == null ? void 0 : n.id) || null), this.render();
1663
1688
  }
1664
1689
  get currentId() {
1665
1690
  var e;
@@ -1669,7 +1694,7 @@ class ys {
1669
1694
  setForms(e = !1) {
1670
1695
  if (this.cur && e) {
1671
1696
  const t = this.d.form(this.cur.id);
1672
- this.cur = t ? I(t) : this.d.forms()[0] ? I(this.d.forms()[0]) : null, this.render();
1697
+ this.cur = t ? R(t) : this.d.forms()[0] ? R(this.d.forms()[0]) : null, this.render();
1673
1698
  return;
1674
1699
  }
1675
1700
  if (this.cur && !this.d.form(this.cur.id)) {
@@ -1686,7 +1711,7 @@ class ys {
1686
1711
  }
1687
1712
  /* ------------------------------------------------------------------ */
1688
1713
  changed() {
1689
- this.cur && this.d.change(I(this.cur));
1714
+ this.cur && this.d.change(R(this.cur));
1690
1715
  }
1691
1716
  render() {
1692
1717
  const e = this.t;
@@ -1698,14 +1723,14 @@ class ys {
1698
1723
  t.append(f("div", { class: "gjsf-empty" }, e("noForms")));
1699
1724
  return;
1700
1725
  }
1701
- const a = f("input", { class: "gjsf-input", value: s.name, "aria-label": e("formName"), "data-role": "form-name" });
1702
- a.addEventListener("input", () => {
1703
- s.name = a.value, this.changed(), this.renderSide();
1726
+ const n = f("input", { class: "gjsf-input", value: s.name, "aria-label": e("formName"), "data-role": "form-name" });
1727
+ n.addEventListener("input", () => {
1728
+ s.name = n.value, this.changed(), this.renderSide();
1704
1729
  }), this.statusEl = f("span", { class: "gjsf-status", "aria-live": "polite" });
1705
1730
  const r = f(
1706
1731
  "div",
1707
1732
  { class: "gjsf-head" },
1708
- a,
1733
+ n,
1709
1734
  this.statusEl,
1710
1735
  f("button", { class: "gjsf-btn", type: "button", "data-role": "duplicate", title: e("duplicateForm"), onclick: () => this.duplicate() }, "⧉"),
1711
1736
  f("button", { class: "gjsf-btn is-danger", type: "button", "data-role": "remove-form", title: e("removeForm"), onclick: () => this.removeForm() }, "🗑")
@@ -1719,7 +1744,7 @@ class ys {
1719
1744
  ["submissions", "submissions"],
1720
1745
  ["json", "json"]
1721
1746
  ].map(
1722
- ([u, n]) => f(
1747
+ ([u, a]) => f(
1723
1748
  "button",
1724
1749
  {
1725
1750
  class: `gjsf-tab${this.tab === u ? " is-active" : ""}`,
@@ -1731,7 +1756,7 @@ class ys {
1731
1756
  this.tab = u, this.render();
1732
1757
  }
1733
1758
  },
1734
- e(n)
1759
+ e(a)
1735
1760
  )
1736
1761
  )
1737
1762
  );
@@ -1744,7 +1769,7 @@ class ys {
1744
1769
  { class: "gjsf-side-list" },
1745
1770
  ...this.d.forms().map((s) => {
1746
1771
  var r;
1747
- const a = this.cur && s.id === this.cur.id ? this.cur.name : s.name;
1772
+ const n = this.cur && s.id === this.cur.id ? this.cur.name : s.name;
1748
1773
  return f(
1749
1774
  "li",
1750
1775
  {
@@ -1754,7 +1779,7 @@ class ys {
1754
1779
  onclick: () => this.show(s.id),
1755
1780
  onkeydown: (l) => l.key === "Enter" && this.show(s.id)
1756
1781
  },
1757
- a || s.id
1782
+ n || s.id
1758
1783
  );
1759
1784
  })
1760
1785
  );
@@ -1802,9 +1827,9 @@ class ys {
1802
1827
  }
1803
1828
  addField(e) {
1804
1829
  var o, u;
1805
- const t = this.cur, s = O(e) ? "" : this.t(`type_${e}`), a = new Set(t.fields.map((n) => n.name)), r = { id: Y(), type: e, name: O(e) ? "" : re(W(s) || e, a) };
1806
- O(e) ? r.text = this.t(`type_${e}`) : e !== "hidden" && (r.label = s), me.includes(e) && (r.options = [1, 2, 3].map((n) => ({ label: `${this.t("optionLabel")} ${n}`, value: `option_${n}` })));
1807
- const l = this.selField ? t.fields.findIndex((n) => n.id === this.selField) + 1 : t.fields.length;
1830
+ const t = this.cur, s = N(e) ? "" : this.t(`type_${e}`), n = new Set(t.fields.map((a) => a.name)), r = { id: Y(), type: e, name: N(e) ? "" : re(W(s) || e, n) };
1831
+ N(e) ? r.text = this.t(`type_${e}`) : e !== "hidden" && (r.label = s), me.includes(e) && (r.options = [1, 2, 3].map((a) => ({ label: `${this.t("optionLabel")} ${a}`, value: `option_${a}` })));
1832
+ const l = this.selField ? t.fields.findIndex((a) => a.id === this.selField) + 1 : t.fields.length;
1808
1833
  t.fields.splice(l > 0 ? l : t.fields.length, 0, r), this.selField = r.id, this.changed(), this.renderList(), this.renderProps(), (u = (o = this.propsEl) == null ? void 0 : o.querySelector("input,textarea")) == null || u.focus();
1809
1834
  }
1810
1835
  renderList() {
@@ -1814,44 +1839,44 @@ class ys {
1814
1839
  this.listEl.replaceChildren(f("p", { class: "gjsf-hint" }, e("noFields")));
1815
1840
  return;
1816
1841
  }
1817
- const s = (a, r) => {
1818
- const l = a + r;
1819
- l < 0 || l >= t.length || ([t[a], t[l]] = [t[l], t[a]], this.changed(), this.renderList());
1842
+ const s = (n, r) => {
1843
+ const l = n + r;
1844
+ l < 0 || l >= t.length || ([t[n], t[l]] = [t[l], t[n]], this.changed(), this.renderList());
1820
1845
  };
1821
1846
  this.listEl.replaceChildren(
1822
1847
  ...t.map(
1823
- (a, r) => f(
1848
+ (n, r) => f(
1824
1849
  "div",
1825
1850
  {
1826
- class: `gjsf-row${a.id === this.selField ? " is-active" : ""}`,
1827
- "data-field": a.id,
1851
+ class: `gjsf-row${n.id === this.selField ? " is-active" : ""}`,
1852
+ "data-field": n.id,
1828
1853
  tabindex: "0",
1829
1854
  onclick: () => {
1830
- this.selField = a.id, this.renderList(), this.renderProps();
1855
+ this.selField = n.id, this.renderList(), this.renderProps();
1831
1856
  }
1832
1857
  },
1833
- f("span", { class: "gjsf-ico", title: e(`type_${a.type}`) }, ze[a.type]),
1858
+ f("span", { class: "gjsf-ico", title: e(`type_${n.type}`) }, ze[n.type]),
1834
1859
  f(
1835
1860
  "div",
1836
1861
  { class: "gjsf-row-main" },
1837
- f("div", { class: "gjsf-row-title" }, Te(a), a.required ? " *" : ""),
1838
- f("div", { class: "gjsf-row-sub" }, O(a.type) ? e(`type_${a.type}`) : `${a.name} · ${a.type}`)
1862
+ f("div", { class: "gjsf-row-title" }, Te(n), n.required ? " *" : ""),
1863
+ f("div", { class: "gjsf-row-sub" }, N(n.type) ? e(`type_${n.type}`) : `${n.name} · ${n.type}`)
1839
1864
  ),
1840
1865
  this.act("↑", e("moveUp"), r === 0, () => s(r, -1)),
1841
1866
  this.act("↓", e("moveDown"), r === t.length - 1, () => s(r, 1)),
1842
1867
  this.act("⧉", e("duplicate"), !1, () => {
1843
- const l = { ...I(a), id: Y() };
1844
- O(a.type) || (l.name = re(a.name, new Set(t.map((o) => o.name)))), t.splice(r + 1, 0, l), this.selField = l.id, this.changed(), this.renderList(), this.renderProps();
1868
+ const l = { ...R(n), id: Y() };
1869
+ N(n.type) || (l.name = re(n.name, new Set(t.map((o) => o.name)))), t.splice(r + 1, 0, l), this.selField = l.id, this.changed(), this.renderList(), this.renderProps();
1845
1870
  }),
1846
1871
  this.act("✕", e("remove"), !1, () => {
1847
1872
  var l;
1848
- t.splice(r, 1), this.selField === a.id && (this.selField = ((l = t[Math.min(r, t.length - 1)]) == null ? void 0 : l.id) || null), this.changed(), this.renderList(), this.renderProps();
1873
+ t.splice(r, 1), this.selField === n.id && (this.selField = ((l = t[Math.min(r, t.length - 1)]) == null ? void 0 : l.id) || null), this.changed(), this.renderList(), this.renderProps();
1849
1874
  })
1850
1875
  )
1851
1876
  )
1852
1877
  );
1853
1878
  }
1854
- act(e, t, s, a) {
1879
+ act(e, t, s, n) {
1855
1880
  return f(
1856
1881
  "button",
1857
1882
  {
@@ -1861,7 +1886,7 @@ class ys {
1861
1886
  "aria-label": t,
1862
1887
  disabled: s,
1863
1888
  onclick: (r) => {
1864
- r.stopPropagation(), a();
1889
+ r.stopPropagation(), n();
1865
1890
  }
1866
1891
  },
1867
1892
  e
@@ -1872,31 +1897,31 @@ class ys {
1872
1897
  var r;
1873
1898
  const t = (r = this.listEl) == null ? void 0 : r.querySelector(`[data-field="${e.id}"]`);
1874
1899
  if (!t) return;
1875
- const s = t.querySelector(".gjsf-row-title"), a = t.querySelector(".gjsf-row-sub");
1876
- s && (s.textContent = Te(e) + (e.required ? " *" : "")), a && !O(e.type) && (a.textContent = `${e.name} · ${e.type}`);
1900
+ const s = t.querySelector(".gjsf-row-title"), n = t.querySelector(".gjsf-row-sub");
1901
+ s && (s.textContent = Te(e) + (e.required ? " *" : "")), n && !N(e.type) && (n.textContent = `${e.name} · ${e.type}`);
1877
1902
  }
1878
1903
  /** A labelled input bound to `obj[key]`. */
1879
- text(e, t, s, a = {}) {
1904
+ text(e, t, s, n = {}) {
1880
1905
  const r = t[s], l = {
1881
- class: `gjsf-input${a.code ? " gjsf-code" : ""}`,
1906
+ class: `gjsf-input${n.code ? " gjsf-code" : ""}`,
1882
1907
  "data-prop": s,
1883
- ...a.placeholder ? { placeholder: a.placeholder } : {}
1884
- }, o = a.area ? f("textarea", { ...l, rows: "3" }) : f("input", { ...l, type: a.type || "text" });
1908
+ ...n.placeholder ? { placeholder: n.placeholder } : {}
1909
+ }, o = n.area ? f("textarea", { ...l, rows: "3" }) : f("input", { ...l, type: n.type || "text" });
1885
1910
  return o.value = r == null ? "" : String(r), o.addEventListener("input", () => {
1886
- var n;
1911
+ var a;
1887
1912
  const u = o.value;
1888
- if (a.num) {
1913
+ if (n.num) {
1889
1914
  const d = u.trim() === "" ? NaN : Number(u);
1890
1915
  Number.isInteger(d) && d >= 0 ? t[s] = d : delete t[s];
1891
1916
  } else u === "" ? delete t[s] : t[s] = u;
1892
- (n = a.onChange) == null || n.call(a), this.changed();
1893
- }), f("label", { class: "gjsf-f" }, f("span", {}, e), o, a.hint ? f("small", {}, a.hint) : null);
1917
+ (a = n.onChange) == null || a.call(n), this.changed();
1918
+ }), f("label", { class: "gjsf-f" }, f("span", {}, e), o, n.hint ? f("small", {}, n.hint) : null);
1894
1919
  }
1895
- check(e, t, s, a = {}) {
1920
+ check(e, t, s, n = {}) {
1896
1921
  const r = f("input", { type: "checkbox", "data-prop": s });
1897
- return r.checked = a.invert ? t[s] !== !1 : t[s] === !0, r.addEventListener("change", () => {
1922
+ return r.checked = n.invert ? t[s] !== !1 : t[s] === !0, r.addEventListener("change", () => {
1898
1923
  var l;
1899
- a.invert ? r.checked ? delete t[s] : t[s] = !1 : r.checked ? t[s] = !0 : delete t[s], (l = a.onChange) == null || l.call(a), this.changed();
1924
+ n.invert ? r.checked ? delete t[s] : t[s] = !1 : r.checked ? t[s] = !0 : delete t[s], (l = n.onChange) == null || l.call(n), this.changed();
1900
1925
  }), f("label", { class: "gjsf-check" }, r, e);
1901
1926
  }
1902
1927
  /** Placeholder chips that insert into an input. */
@@ -1917,10 +1942,10 @@ class ys {
1917
1942
  type: "button",
1918
1943
  "data-token": s.token,
1919
1944
  onclick: () => {
1920
- const a = e();
1921
- if (!a) return;
1922
- const r = a.selectionStart ?? a.value.length, l = a.selectionEnd ?? r;
1923
- a.value = a.value.slice(0, r) + s.token + a.value.slice(l), a.dispatchEvent(new Event("input", { bubbles: !0 })), a.focus();
1945
+ const n = e();
1946
+ if (!n) return;
1947
+ const r = n.selectionStart ?? n.value.length, l = n.selectionEnd ?? r;
1948
+ n.value = n.value.slice(0, r) + s.token + n.value.slice(l), n.dispatchEvent(new Event("input", { bubbles: !0 })), n.focus();
1924
1949
  }
1925
1950
  },
1926
1951
  s.token
@@ -1931,26 +1956,26 @@ class ys {
1931
1956
  }
1932
1957
  /** `{ name: value }` rows. */
1933
1958
  kv(e, t, s) {
1934
- const a = this.t, r = f("div", { class: "gjsf-kvs", "data-prop": s }), l = Object.entries(t[s] || {}), o = () => {
1935
- const n = {};
1936
- l.forEach(([d, b]) => {
1937
- d.trim() && (n[d.trim()] = b);
1938
- }), Object.keys(n).length ? t[s] = n : delete t[s], this.changed();
1959
+ const n = this.t, r = f("div", { class: "gjsf-kvs", "data-prop": s }), l = Object.entries(t[s] || {}), o = () => {
1960
+ const a = {};
1961
+ l.forEach(([d, g]) => {
1962
+ d.trim() && (a[d.trim()] = g);
1963
+ }), Object.keys(a).length ? t[s] = a : delete t[s], this.changed();
1939
1964
  }, u = () => {
1940
1965
  r.replaceChildren(
1941
1966
  f("div", { class: "gjsf-sec" }, e),
1942
- ...l.map((n, d) => {
1943
- const b = f("input", { class: "gjsf-input gjsf-code", placeholder: a("attrName"), value: n[0], "aria-label": a("attrName") }), h = f("input", { class: "gjsf-input", placeholder: a("attrValue"), value: n[1], "aria-label": a("attrValue") });
1944
- return b.addEventListener("input", () => {
1945
- n[0] = b.value, o();
1967
+ ...l.map((a, d) => {
1968
+ const g = f("input", { class: "gjsf-input gjsf-code", placeholder: n("attrName"), value: a[0], "aria-label": n("attrName") }), h = f("input", { class: "gjsf-input", placeholder: n("attrValue"), value: a[1], "aria-label": n("attrValue") });
1969
+ return g.addEventListener("input", () => {
1970
+ a[0] = g.value, o();
1946
1971
  }), h.addEventListener("input", () => {
1947
- n[1] = h.value, o();
1972
+ a[1] = h.value, o();
1948
1973
  }), f(
1949
1974
  "div",
1950
1975
  { class: "gjsf-kv" },
1951
- b,
1976
+ g,
1952
1977
  h,
1953
- this.act("✕", a("remove"), !1, () => {
1978
+ this.act("✕", n("remove"), !1, () => {
1954
1979
  l.splice(d, 1), o(), u();
1955
1980
  })
1956
1981
  );
@@ -1962,38 +1987,38 @@ class ys {
1962
1987
  type: "button",
1963
1988
  "data-role": "add-attr",
1964
1989
  onclick: () => {
1965
- var n;
1966
- l.push(["data-", ""]), u(), (n = r.querySelectorAll(".gjsf-kv input")[l.length * 2 - 2]) == null || n.focus();
1990
+ var a;
1991
+ l.push(["data-", ""]), u(), (a = r.querySelectorAll(".gjsf-kv input")[l.length * 2 - 2]) == null || a.focus();
1967
1992
  }
1968
1993
  },
1969
- `+ ${a("addAttr")}`
1994
+ `+ ${n("addAttr")}`
1970
1995
  )
1971
1996
  );
1972
1997
  };
1973
1998
  return u(), r;
1974
1999
  }
1975
2000
  optionsEditor(e) {
1976
- const t = this.t, s = f("div", { class: "gjsf-opts", "data-prop": "options" }), a = e.options || (e.options = []), r = () => {
2001
+ const t = this.t, s = f("div", { class: "gjsf-opts", "data-prop": "options" }), n = e.options || (e.options = []), r = () => {
1977
2002
  s.replaceChildren(
1978
2003
  f("div", { class: "gjsf-sec" }, t("options")),
1979
2004
  f("small", { class: "gjsf-hint" }, t("optionsHint")),
1980
- ...a.map((l, o) => {
1981
- const u = f("input", { class: "gjsf-input", value: l.label, placeholder: t("optionLabel"), "aria-label": t("optionLabel") }), n = f("input", { class: "gjsf-input gjsf-code", value: l.value, placeholder: t("optionValue"), "aria-label": t("optionValue") });
2005
+ ...n.map((l, o) => {
2006
+ const u = f("input", { class: "gjsf-input", value: l.label, placeholder: t("optionLabel"), "aria-label": t("optionLabel") }), a = f("input", { class: "gjsf-input gjsf-code", value: l.value, placeholder: t("optionValue"), "aria-label": t("optionValue") });
1982
2007
  let d = l.value === W(l.label) || /^option_\d+$/.test(l.value);
1983
2008
  return u.addEventListener("input", () => {
1984
- l.label = u.value, d && (l.value = W(u.value) || l.value, n.value = l.value), this.changed();
1985
- }), n.addEventListener("input", () => {
1986
- d = !1, l.value = n.value, this.changed();
2009
+ l.label = u.value, d && (l.value = W(u.value) || l.value, a.value = l.value), this.changed();
2010
+ }), a.addEventListener("input", () => {
2011
+ d = !1, l.value = a.value, this.changed();
1987
2012
  }), f(
1988
2013
  "div",
1989
2014
  { class: "gjsf-kv" },
1990
2015
  u,
1991
- n,
2016
+ a,
1992
2017
  this.act("↑", t("moveUp"), o === 0, () => {
1993
- [a[o - 1], a[o]] = [a[o], a[o - 1]], this.changed(), r();
2018
+ [n[o - 1], n[o]] = [n[o], n[o - 1]], this.changed(), r();
1994
2019
  }),
1995
2020
  this.act("✕", t("remove"), !1, () => {
1996
- a.splice(o, 1), this.changed(), r();
2021
+ n.splice(o, 1), this.changed(), r();
1997
2022
  })
1998
2023
  );
1999
2024
  }),
@@ -2004,8 +2029,8 @@ class ys {
2004
2029
  type: "button",
2005
2030
  "data-role": "add-option",
2006
2031
  onclick: () => {
2007
- const l = a.length + 1;
2008
- a.push({ label: `${t("optionLabel")} ${l}`, value: `option_${l}` }), this.changed(), r();
2032
+ const l = n.length + 1;
2033
+ n.push({ label: `${t("optionLabel")} ${l}`, value: `option_${l}` }), this.changed(), r();
2009
2034
  }
2010
2035
  },
2011
2036
  `+ ${t("addOption")}`
@@ -2021,18 +2046,18 @@ class ys {
2021
2046
  this.propsEl.replaceChildren(f("p", { class: "gjsf-hint" }, e("noFieldSelected")));
2022
2047
  return;
2023
2048
  }
2024
- const s = () => this.refreshRow(t), a = f(
2049
+ const s = () => this.refreshRow(t), n = f(
2025
2050
  "select",
2026
2051
  { class: "gjsf-input", "data-prop": "type", "aria-label": e("fieldType") },
2027
2052
  ...[...je, ...fe].map((h) => f("option", { value: h, selected: h === t.type }, e(`type_${h}`)))
2028
2053
  );
2029
- a.addEventListener("change", () => {
2054
+ n.addEventListener("change", () => {
2030
2055
  var p;
2031
- const h = a.value, y = t.type;
2032
- t.type = h, O(h) && !O(y) ? (t.text = t.label || t.text || "", t.name = "") : !O(h) && O(y) && (t.label = t.text || e(`type_${h}`), t.name = re(W(t.label) || h, new Set(this.cur.fields.filter((_) => _ !== t).map((_) => _.name)))), me.includes(h) && !((p = t.options) != null && p.length) && (t.options = [1, 2].map((_) => ({ label: `${e("optionLabel")} ${_}`, value: `option_${_}` }))), this.changed(), this.renderList(), this.renderProps();
2056
+ const h = n.value, y = t.type;
2057
+ t.type = h, N(h) && !N(y) ? (t.text = t.label || t.text || "", t.name = "") : !N(h) && N(y) && (t.label = t.text || e(`type_${h}`), t.name = re(W(t.label) || h, new Set(this.cur.fields.filter((w) => w !== t).map((w) => w.name)))), me.includes(h) && !((p = t.options) != null && p.length) && (t.options = [1, 2].map((w) => ({ label: `${e("optionLabel")} ${w}`, value: `option_${w}` }))), this.changed(), this.renderList(), this.renderProps();
2033
2058
  });
2034
- const r = [f("label", { class: "gjsf-f" }, f("span", {}, e("fieldType")), a)];
2035
- if (O(t.type)) {
2059
+ const r = [f("label", { class: "gjsf-f" }, f("span", {}, e("fieldType")), n)];
2060
+ if (N(t.type)) {
2036
2061
  r.push(this.text(e("text"), t, "text", { area: t.type === "paragraph", onChange: s })), r.push(this.kv(e("attrs"), t, "attrs")), this.propsEl.replaceChildren(...r.filter(Boolean));
2037
2062
  return;
2038
2063
  }
@@ -2045,42 +2070,42 @@ class ys {
2045
2070
  }
2046
2071
  }), u = o.querySelector("input");
2047
2072
  u.addEventListener("change", () => {
2048
- const h = new Set(this.cur.fields.filter((p) => p !== t && !O(p.type)).map((p) => p.name)), y = re(W(u.value) || (/^[A-Za-z_]/.test(u.value) ? u.value : "") || t.type, h);
2073
+ const h = new Set(this.cur.fields.filter((p) => p !== t && !N(p.type)).map((p) => p.name)), y = re(W(u.value) || (/^[A-Za-z_]/.test(u.value) ? u.value : "") || t.type, h);
2049
2074
  (y !== t.name || u.value !== y) && (t.name = y, u.value = y, this.changed(), s());
2050
2075
  }), t.type !== "hidden" && r.push(
2051
2076
  this.text(e("fieldLabel"), t, "label", {
2052
2077
  onChange: () => {
2053
2078
  if (!l) {
2054
- const h = new Set(this.cur.fields.filter((p) => p !== t && !O(p.type)).map((p) => p.name)), y = W(t.label || "");
2079
+ const h = new Set(this.cur.fields.filter((p) => p !== t && !N(p.type)).map((p) => p.name)), y = W(t.label || "");
2055
2080
  y && (t.name = re(y, h), u.value = t.name);
2056
2081
  }
2057
2082
  s();
2058
2083
  }
2059
2084
  })
2060
2085
  ), r.push(o);
2061
- const n = this.text(t.type === "hidden" ? e("hiddenValue") : e("defaultValue"), t, "value", { code: t.type === "hidden" }), d = () => n.querySelector("input");
2086
+ const a = this.text(t.type === "hidden" ? e("hiddenValue") : e("defaultValue"), t, "value", { code: t.type === "hidden" }), d = () => a.querySelector("input");
2062
2087
  if (t.type === "hidden") {
2063
- r.push(n, this.chips(d)), r.push(this.kv(e("attrs"), t, "attrs")), this.propsEl.replaceChildren(...r.filter(Boolean));
2088
+ r.push(a, this.chips(d)), r.push(this.kv(e("attrs"), t, "attrs")), this.propsEl.replaceChildren(...r.filter(Boolean));
2064
2089
  return;
2065
2090
  }
2066
- if (["checkbox", "radio", "checkboxes", "range", "color", "file", "date", "time", "datetime"].includes(t.type) || r.push(this.text(e("placeholder"), t, "placeholder")), r.push(this.text(e("help"), t, "help")), r.push(this.check(e("required"), t, "required", { onChange: s })), me.includes(t.type) && r.push(this.optionsEditor(t)), (t.type === "select" || t.type === "file") && r.push(this.check(e("multiple"), t, "multiple")), t.type !== "file" && t.type !== "password" && r.push(n, this.chips(d)), $t.includes(t.type)) {
2091
+ if (["checkbox", "radio", "checkboxes", "range", "color", "file", "date", "time", "datetime"].includes(t.type) || r.push(this.text(e("placeholder"), t, "placeholder")), r.push(this.text(e("help"), t, "help")), r.push(this.check(e("required"), t, "required", { onChange: s })), me.includes(t.type) && r.push(this.optionsEditor(t)), (t.type === "select" || t.type === "file") && r.push(this.check(e("multiple"), t, "multiple")), t.type !== "file" && t.type !== "password" && r.push(a, this.chips(d)), $t.includes(t.type)) {
2067
2092
  const h = t.type === "number" || t.type === "range" ? "number" : t.type === "datetime" ? "datetime-local" : t.type;
2068
2093
  r.push(f("div", { class: "gjsf-grid" }, this.text(e("min"), t, "min", { type: h }), this.text(e("max"), t, "max", { type: h }), this.text(e("step"), t, "step", { type: "number" })));
2069
2094
  }
2070
2095
  we.includes(t.type) && (r.push(f("div", { class: "gjsf-grid2" }, this.text(e("minLength"), t, "minLength", { type: "number", num: !0 }), this.text(e("maxLength"), t, "maxLength", { type: "number", num: !0 }))), t.type !== "textarea" && r.push(this.text(e("pattern"), t, "pattern", { code: !0, placeholder: "[0-9]{5}" }))), t.type === "textarea" && r.push(this.text(e("rows"), t, "rows", { type: "number", num: !0 })), t.type === "file" && r.push(this.text(e("accept"), t, "accept", { code: !0, placeholder: "image/*,.pdf" })), ["checkbox", "radio", "checkboxes", "file", "range", "color"].includes(t.type) || r.push(this.text(e("autocomplete"), t, "autocomplete", { code: !0, placeholder: t.type === "email" ? "email" : t.type === "tel" ? "tel" : "name" }));
2071
- const b = f("select", { class: "gjsf-input", "data-prop": "width", "aria-label": e("width") }, ...st.map((h) => f("option", { value: h, selected: (t.width || "full") === h }, h === "full" ? "100%" : h)));
2072
- b.addEventListener("change", () => {
2073
- b.value === "full" ? delete t.width : t.width = b.value, this.changed();
2074
- }), r.push(f("label", { class: "gjsf-f" }, f("span", {}, e("width")), b)), r.push(f("div", { class: "gjsf-grid2" }, this.check(e("readonly"), t, "readonly"), this.check(e("disabled"), t, "disabled"))), r.push(this.kv(e("attrs"), t, "attrs")), this.propsEl.replaceChildren(...r.filter(Boolean));
2096
+ const g = f("select", { class: "gjsf-input", "data-prop": "width", "aria-label": e("width") }, ...st.map((h) => f("option", { value: h, selected: (t.width || "full") === h }, h === "full" ? "100%" : h)));
2097
+ g.addEventListener("change", () => {
2098
+ g.value === "full" ? delete t.width : t.width = g.value, this.changed();
2099
+ }), r.push(f("label", { class: "gjsf-f" }, f("span", {}, e("width")), g)), r.push(f("div", { class: "gjsf-grid2" }, this.check(e("readonly"), t, "readonly"), this.check(e("disabled"), t, "disabled"))), r.push(this.kv(e("attrs"), t, "attrs")), this.propsEl.replaceChildren(...r.filter(Boolean));
2075
2100
  }
2076
2101
  /* ----------------------------- settings ---------------------------- */
2077
2102
  renderSettings() {
2078
- const e = this.t, t = this.cur, s = t.settings, a = this.d.defaultAction(t);
2103
+ const e = this.t, t = this.cur, s = t.settings, n = this.d.defaultAction(t);
2079
2104
  this.body.replaceChildren(
2080
2105
  f(
2081
2106
  "div",
2082
2107
  { class: "gjsf-pane" },
2083
- this.text(e("endpoint"), s, "endpoint", { code: !0, placeholder: a || "https://…", hint: te(e("endpointHint"), a || e("noEndpoint")) }),
2108
+ this.text(e("endpoint"), s, "endpoint", { code: !0, placeholder: n || "https://…", hint: te(e("endpointHint"), n || e("noEndpoint")) }),
2084
2109
  this.text(e("submitLabel"), s, "submitLabel", { placeholder: e("submit") }),
2085
2110
  this.text(e("successMessage"), s, "successMessage", { area: !0, placeholder: e("success") }),
2086
2111
  this.text(e("errorMessage"), s, "errorMessage", { area: !0, placeholder: e("error") }),
@@ -2093,27 +2118,27 @@ class ys {
2093
2118
  }
2094
2119
  /* ------------------------------ preview ---------------------------- */
2095
2120
  renderPreview() {
2096
- const e = this.t, t = this.cur, { css: s, links: a } = this.d.previewStyles(), r = f("iframe", { class: "gjsf-frame", title: e("preview") }), l = f("span", {}, e("previewHint"));
2121
+ const e = this.t, t = this.cur, { css: s, links: n } = this.d.previewStyles(), r = f("iframe", { class: "gjsf-frame", title: e("preview") }), l = f("span", {}, e("previewHint"));
2097
2122
  this.body.replaceChildren(f("div", { class: "gjsf-frame-bar" }, l), r);
2098
- const o = (b) => b.replace(/"/g, "&quot;"), u = `<!DOCTYPE html><html><head><meta charset="utf-8">${a.map((b) => `<link rel="stylesheet" href="${o(b)}">`).join("")}<style>${s.replace(/<\/style/gi, "<\\/style")}</style><style>body{padding:16px}</style></head><body>${this.d.previewHtml(t)}</body></html>`, n = () => {
2099
- const b = r.contentDocument, h = b == null ? void 0 : b.querySelector("form[data-gjsf-form]");
2123
+ const o = (g) => g.replace(/"/g, "&quot;"), u = `<!DOCTYPE html><html><head><meta charset="utf-8">${n.map((g) => `<link rel="stylesheet" href="${o(g)}">`).join("")}<style>${s.replace(/<\/style/gi, "<\\/style")}</style><style>body{padding:16px}</style></head><body>${this.d.previewHtml(t)}</body></html>`, a = () => {
2124
+ const g = r.contentDocument, h = g == null ? void 0 : g.querySelector("form[data-gjsf-form]");
2100
2125
  !h || h.__gjsf || (h.addEventListener("gjsf:submit", (y) => {
2101
2126
  const p = y.detail;
2102
- p.promise = this.d.submit(t.id, p.data, { ...p.meta, url: "editor:preview" }).then((_) => (l.textContent = e("previewSent"), { ..._, message: _.message })).catch((_) => {
2103
- throw _ instanceof G ? { status: _.status, body: { error: _.message, errors: _.errors } } : { status: 0, body: { error: _ == null ? void 0 : _.message } };
2127
+ p.promise = this.d.submit(t.id, p.data, { ...p.meta, url: "editor:preview" }).then((w) => (l.textContent = e("previewSent"), { ...w, message: w.message })).catch((w) => {
2128
+ throw w instanceof G ? { status: w.status, body: { error: w.message, errors: w.errors } } : { status: 0, body: { error: w == null ? void 0 : w.message } };
2104
2129
  });
2105
2130
  }), Ce.call(h));
2106
2131
  }, d = r.contentDocument;
2107
- d && (d.open(), d.write(u), d.close(), n(), r.addEventListener("load", n));
2132
+ d && (d.open(), d.write(u), d.close(), a(), r.addEventListener("load", a));
2108
2133
  }
2109
2134
  /* ---------------------------- submissions -------------------------- */
2110
2135
  async renderSubmissions(e) {
2111
2136
  var y;
2112
- const t = this.t, s = this.cur, a = f("div", { class: "gjsf-pane", style: "max-width:none" });
2113
- this.body.replaceChildren(a);
2114
- const r = this.d.submissions(s.id, { limit: bs, offset: e ? 0 : this.subs.length });
2137
+ const t = this.t, s = this.cur, n = f("div", { class: "gjsf-pane", style: "max-width:none" });
2138
+ this.body.replaceChildren(n);
2139
+ const r = this.d.submissions(s.id, { limit: ys, offset: e ? 0 : this.subs.length });
2115
2140
  if (!r) {
2116
- a.append(f("p", { class: "gjsf-hint" }, t("submissionsUnsupported")));
2141
+ n.append(f("p", { class: "gjsf-hint" }, t("submissionsUnsupported")));
2117
2142
  return;
2118
2143
  }
2119
2144
  try {
@@ -2121,10 +2146,10 @@ class ys {
2121
2146
  if (((y = this.cur) == null ? void 0 : y.id) !== s.id || this.tab !== "submissions") return;
2122
2147
  this.subs = e ? p.items : [...this.subs, ...p.items], this.subsTotal = p.total;
2123
2148
  } catch (p) {
2124
- a.append(f("p", { class: "gjsf-err" }, p.message));
2149
+ n.append(f("p", { class: "gjsf-err" }, p.message));
2125
2150
  return;
2126
2151
  }
2127
- const l = s.fields.filter((p) => !O(p.type)), o = new Set(l.map((p) => p.name)), u = [...new Set(this.subs.flatMap((p) => Object.keys(p.data || {})))].filter((p) => !o.has(p)), n = [...l.map((p) => ({ key: p.name, title: p.label || p.name })), ...u.map((p) => ({ key: p, title: p }))], d = (p) => p == null ? "" : Array.isArray(p) ? p.join(", ") : typeof p == "boolean" ? p ? "✓" : "" : typeof p == "object" ? JSON.stringify(p) : String(p), b = f(
2152
+ const l = s.fields.filter((p) => !N(p.type)), o = new Set(l.map((p) => p.name)), u = [...new Set(this.subs.flatMap((p) => Object.keys(p.data || {})))].filter((p) => !o.has(p)), a = [...l.map((p) => ({ key: p.name, title: p.label || p.name })), ...u.map((p) => ({ key: p, title: p }))], d = (p) => p == null ? "" : Array.isArray(p) ? p.join(", ") : typeof p == "boolean" ? p ? "✓" : "" : typeof p == "object" ? JSON.stringify(p) : String(p), g = f(
2128
2153
  "div",
2129
2154
  { class: "gjsf-bar" },
2130
2155
  f("button", { class: "gjsf-btn", type: "button", "data-role": "refresh", onclick: () => void this.renderSubmissions(!0) }, `↻ ${t("refresh")}`),
@@ -2135,36 +2160,36 @@ class ys {
2135
2160
  type: "button",
2136
2161
  "data-role": "csv",
2137
2162
  disabled: !this.subs.length,
2138
- onclick: () => Be(`${s.name || s.id}.csv`, xs([t("date"), ...n.map((p) => p.title)], this.subs.map((p) => [p.createdAt, ...n.map((_) => {
2163
+ onclick: () => Be(`${s.name || s.id}.csv`, vs([t("date"), ...a.map((p) => p.title)], this.subs.map((p) => [p.createdAt, ...a.map((w) => {
2139
2164
  var $;
2140
- return d(($ = p.data) == null ? void 0 : $[_.key]);
2165
+ return d(($ = p.data) == null ? void 0 : $[w.key]);
2141
2166
  })])), "text/csv")
2142
2167
  },
2143
2168
  `⇩ ${t("downloadCsv")}`
2144
2169
  ),
2145
2170
  f("span", { class: "gjsf-hint" }, te(t("shownOf"), this.subs.length, this.subsTotal))
2146
2171
  );
2147
- if (a.append(b), !this.subs.length) {
2148
- a.append(f("p", { class: "gjsf-hint" }, t("noSubmissions")));
2172
+ if (n.append(g), !this.subs.length) {
2173
+ n.append(f("p", { class: "gjsf-hint" }, t("noSubmissions")));
2149
2174
  return;
2150
2175
  }
2151
2176
  const h = f(
2152
2177
  "table",
2153
2178
  { class: "gjsf-table" },
2154
- f("thead", {}, f("tr", {}, f("th", {}, t("date")), ...n.map((p) => f("th", {}, p.title)), f("th", {}, ""))),
2179
+ f("thead", {}, f("tr", {}, f("th", {}, t("date")), ...a.map((p) => f("th", {}, p.title)), f("th", {}, ""))),
2155
2180
  f(
2156
2181
  "tbody",
2157
2182
  {},
2158
2183
  ...this.subs.map(
2159
2184
  (p) => {
2160
- var _;
2185
+ var w;
2161
2186
  return f(
2162
2187
  "tr",
2163
2188
  { "data-submission": p.id },
2164
- f("td", { title: String(((_ = p.meta) == null ? void 0 : _.url) || "") }, new Date(p.createdAt).toLocaleString()),
2165
- ...n.map(($) => {
2166
- var M;
2167
- return f("td", {}, d((M = p.data) == null ? void 0 : M[$.key]));
2189
+ f("td", { title: String(((w = p.meta) == null ? void 0 : w.url) || "") }, new Date(p.createdAt).toLocaleString()),
2190
+ ...a.map(($) => {
2191
+ var T;
2192
+ return f("td", {}, d((T = p.data) == null ? void 0 : T[$.key]));
2168
2193
  }),
2169
2194
  f(
2170
2195
  "td",
@@ -2178,11 +2203,11 @@ class ys {
2178
2203
  )
2179
2204
  )
2180
2205
  );
2181
- a.append(f("div", { class: "gjsf-table-wrap" }, h)), this.subs.length < this.subsTotal && a.append(f("button", { class: "gjsf-btn", type: "button", "data-role": "more", onclick: () => void this.renderSubmissions(!1) }, t("loadMore")));
2206
+ n.append(f("div", { class: "gjsf-table-wrap" }, h)), this.subs.length < this.subsTotal && n.append(f("button", { class: "gjsf-btn", type: "button", "data-role": "more", onclick: () => void this.renderSubmissions(!1) }, t("loadMore")));
2182
2207
  }
2183
2208
  /* ------------------------------- JSON ------------------------------ */
2184
2209
  renderJson() {
2185
- const e = this.t, t = this.cur, { id: s, version: a, updatedAt: r, ...l } = t, o = f("textarea", { class: "gjsf-input gjsf-code", rows: "22", "data-role": "json", spellcheck: "false" });
2210
+ const e = this.t, t = this.cur, { id: s, version: n, updatedAt: r, ...l } = t, o = f("textarea", { class: "gjsf-input gjsf-code", rows: "22", "data-role": "json", spellcheck: "false" });
2186
2211
  o.value = JSON.stringify(l, null, 2);
2187
2212
  const u = f("p", { class: "gjsf-hint", "aria-live": "polite" });
2188
2213
  this.body.replaceChildren(
@@ -2201,16 +2226,16 @@ class ys {
2201
2226
  type: "button",
2202
2227
  "data-role": "apply-json",
2203
2228
  onclick: () => {
2204
- let n;
2229
+ let a;
2205
2230
  try {
2206
- n = JSON.parse(o.value);
2231
+ a = JSON.parse(o.value);
2207
2232
  } catch (d) {
2208
2233
  u.textContent = te(e("jsonError"), d.message), u.className = "gjsf-err";
2209
2234
  return;
2210
2235
  }
2211
- this.d.applyJson(t.id, n).then((d) => {
2212
- var b;
2213
- this.cur = I(this.d.form(t.id) || t), this.selField = ((b = this.cur.fields[0]) == null ? void 0 : b.id) || null, this.render(), d.length ? this.flash(te(e("skipped"), d.join(", ")), !0) : this.flash(e("saved"));
2236
+ this.d.applyJson(t.id, a).then((d) => {
2237
+ var g;
2238
+ this.cur = R(this.d.form(t.id) || t), this.selField = ((g = this.cur.fields[0]) == null ? void 0 : g.id) || null, this.render(), d.length ? this.flash(te(e("skipped"), d.join(", ")), !0) : this.flash(e("saved"));
2214
2239
  }).catch(this.d.onError);
2215
2240
  }
2216
2241
  },
@@ -2232,19 +2257,19 @@ class ys {
2232
2257
  );
2233
2258
  }
2234
2259
  }
2235
- function xs(i, e) {
2260
+ function vs(i, e) {
2236
2261
  const t = (s) => /[",\r\n;]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
2237
- return "\uFEFF" + [i, ...e].map((s) => s.map((a) => t(String(a ?? ""))).join(",")).join(`\r
2262
+ return "\uFEFF" + [i, ...e].map((s) => s.map((n) => t(String(n ?? ""))).join(",")).join(`\r
2238
2263
  `);
2239
2264
  }
2240
2265
  function Be(i, e, t) {
2241
2266
  try {
2242
- const s = URL.createObjectURL(new Blob([e], { type: t })), a = f("a", { href: s, download: i.replace(/[\\/:*?"<>|]+/g, "_") });
2243
- document.body.append(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(s), 1e3);
2267
+ const s = URL.createObjectURL(new Blob([e], { type: t })), n = f("a", { href: s, download: i.replace(/[\\/:*?"<>|]+/g, "_") });
2268
+ document.body.append(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(s), 1e3);
2244
2269
  } catch {
2245
2270
  }
2246
2271
  }
2247
- const Ve = "gjsf-style", vs = `
2272
+ const Ve = "gjsf-style", js = `
2248
2273
  .gjsf-modal .gjs-mdl-dialog{max-width:1180px;width:96%}
2249
2274
  .gjsf-modal .gjs-mdl-content{padding:0}
2250
2275
  .gjsf-ed{display:flex;height:min(78vh,760px);font-size:13px;text-align:start;font-family:var(--gjs-main-font,Helvetica,sans-serif)}
@@ -2318,7 +2343,7 @@ textarea.gjsf-input{resize:vertical;min-height:54px}
2318
2343
  function qe(i = document) {
2319
2344
  if (i.getElementById(Ve)) return;
2320
2345
  const e = i.createElement("style");
2321
- e.id = Ve, e.textContent = vs, i.head.appendChild(e);
2346
+ e.id = Ve, e.textContent = js, i.head.appendChild(e);
2322
2347
  }
2323
2348
  const Ye = `
2324
2349
  .gjsf-form{display:flex;flex-wrap:wrap;gap:16px;position:relative}
@@ -2347,11 +2372,11 @@ const Ye = `
2347
2372
  .gjsf-form.is-sending{opacity:.7}
2348
2373
  .gjsf-form.is-error .gjsf-message{color:#c62828}
2349
2374
  `, Ke = "gjsf-forms", We = "gjsf-new", Ge = (i) => `gjsf-form-${i}`;
2350
- function As(i) {
2375
+ function Ls(i) {
2351
2376
  return i.Forms;
2352
2377
  }
2353
2378
  function Ze(i = {}) {
2354
- const e = (s, a) => typeof s == "number" && Number.isFinite(s) && s >= 0 ? s : a, t = i.rest && i.rest.url ? i.rest : null;
2379
+ const e = (s, n) => typeof s == "number" && Number.isFinite(s) && s >= 0 ? s : n, t = i.rest && i.rest.url ? i.rest : null;
2355
2380
  return {
2356
2381
  store: i.store ?? null,
2357
2382
  rest: t,
@@ -2365,116 +2390,116 @@ function Ze(i = {}) {
2365
2390
  injectCss: i.injectCss !== !1
2366
2391
  };
2367
2392
  }
2368
- const Qe = (i) => `<svg viewBox="0 0 24 24" style="display:block;width:${i}px;height:${i}px"><path fill="currentColor" d="M4 4h16v2H4zm0 4h10v2H4zm0 5h16v3H4zm0 5h7v2H4zm11 0h5v2h-5z"/></svg>`, Xe = '<svg viewBox="0 0 24 24"><path fill="currentColor" d="M3 4h18v2H3zm0 4h11v2H3zm0 5h18v3H3zm0 5h8v3H3zm11 0h7v3h-7z"/></svg>', js = ["required", "email", "url", "number", "min", "max", "minLength", "maxLength", "pattern", "option", "date", "time", "color"];
2369
- function ws(i, e = {}) {
2393
+ const Qe = (i) => `<svg viewBox="0 0 24 24" style="display:block;width:${i}px;height:${i}px"><path fill="currentColor" d="M4 4h16v2H4zm0 4h10v2H4zm0 5h16v3H4zm0 5h7v2H4zm11 0h5v2h-5z"/></svg>`, Xe = '<svg viewBox="0 0 24 24"><path fill="currentColor" d="M3 4h18v2H3zm0 4h11v2H3zm0 5h18v3H3zm0 5h8v3H3zm11 0h7v3h-7z"/></svg>', ws = ["required", "email", "url", "number", "min", "max", "minLength", "maxLength", "pattern", "option", "date", "time", "color"];
2394
+ function Ss(i, e = {}) {
2370
2395
  var Fe;
2371
2396
  const t = i;
2372
2397
  (Fe = t.__gjsfCleanup) == null || Fe.call(t);
2373
2398
  const s = Ze(e);
2374
- cs(i);
2375
- const a = ds(i, s.labels), r = s.store || (s.rest ? new fs(s.rest) : new ht(s.dbName)), l = () => t.PagesManager;
2376
- let o = [], u = null, n = null, d = !1;
2377
- const b = [], h = (c, m) => {
2378
- i.on(c, m), b.push(() => i.off(c, m));
2399
+ ds(i);
2400
+ const n = ps(i, s.labels), r = s.store || (s.rest ? new hs(s.rest) : new ht(s.dbName)), l = () => t.PagesManager;
2401
+ let o = [], u = null, a = null, d = !1;
2402
+ const g = [], h = (c, m) => {
2403
+ i.on(c, m), g.push(() => i.off(c, m));
2379
2404
  }, y = (c, ...m) => {
2380
2405
  d || i.trigger(c, ...m);
2381
- }, p = (c) => c ? o.find((m) => m.id === c) : void 0, _ = () => void o.sort((c, m) => c.name.localeCompare(m.name) || c.id.localeCompare(m.id)), $ = (c) => {
2382
- n == null || n.flash(te(a("saveError"), (c == null ? void 0 : c.message) || String(c)), !0), Me(c);
2383
- }, M = (c) => {
2384
- var g;
2406
+ }, p = (c) => c ? o.find((m) => m.id === c) : void 0, w = () => void o.sort((c, m) => c.name.localeCompare(m.name) || c.id.localeCompare(m.id)), $ = (c) => {
2407
+ a == null || a.flash(te(n("saveError"), (c == null ? void 0 : c.message) || String(c)), !0), De(c);
2408
+ }, T = (c) => {
2409
+ var b;
2385
2410
  const m = typeof c == "string" ? p(c) : c;
2386
- return m ? ((g = m.settings) == null ? void 0 : g.endpoint) || (s.submitUrl ? Ue(s.submitUrl, m.id) : "") : "";
2387
- }, B = () => Object.fromEntries(js.map((c) => [c, a(`problem_${c}`)])), P = () => ({ submit: a("submit"), success: a("success"), error: a("error") }), J = () => u && typeof u.id == "string" ? u.id : null, E = new as(i, {
2411
+ return m ? ((b = m.settings) == null ? void 0 : b.endpoint) || (s.submitUrl ? Ue(s.submitUrl, m.id) : "") : "";
2412
+ }, J = () => Object.fromEntries(ws.map((c) => [c, n(`problem_${c}`)])), P = () => ({ submit: n("submit"), success: n("success"), error: n("error") }), H = () => u && typeof u.id == "string" ? u.id : null, _ = new as(i, {
2388
2413
  form: p,
2389
2414
  formOptions: () => o.map((c) => ({ id: c.id, name: c.name })),
2390
- buildOptions: (c) => ({ action: M(c), ctx: { page: u }, texts: P(), codes: B(), pageId: J() }),
2391
- labels: { chooseForm: () => a("chooseForm"), editForm: () => a("editForm"), noForm: () => a("noForm"), missingForm: () => a("missingForm") },
2415
+ buildOptions: (c) => ({ action: T(c), ctx: { page: u }, texts: P(), codes: J(), pageId: H() }),
2416
+ labels: { chooseForm: () => n("chooseForm"), editForm: () => n("editForm"), noForm: () => n("noForm"), missingForm: () => n("missingForm") },
2392
2417
  editCommand: ue.edit,
2393
2418
  onCreate: (c) => void Q().then((m) => {
2394
2419
  c.set("formId", m.id), oe(m.id);
2395
2420
  }).catch($)
2396
2421
  }), x = (c, m) => {
2397
- const g = c.getAttributes();
2398
- if (g["data-gjsf-version"] !== String(m.version ?? "") || "data-gjsf-missing" in g) return !0;
2399
- const k = J();
2400
- return (g["data-gjsf-page"] || null) !== k;
2422
+ const b = c.getAttributes();
2423
+ if (b["data-gjsf-version"] !== String(m.version ?? "") || "data-gjsf-missing" in b) return !0;
2424
+ const k = H();
2425
+ return (b["data-gjsf-page"] || null) !== k;
2401
2426
  }, v = () => {
2402
- d || E.rebuildAll(null, x);
2427
+ d || _.rebuildAll(null, x);
2403
2428
  };
2404
- let w = !1;
2429
+ let S = !1;
2405
2430
  const j = () => {
2406
2431
  var m;
2407
- if (!s.baseCss || w || !E.all().length) return;
2408
- w = !0;
2432
+ if (!s.baseCss || S || !_.all().length) return;
2433
+ S = !0;
2409
2434
  const c = i.Css.getRule(".gjsf-input");
2410
2435
  (!c || !Object.keys(((m = c.getStyle) == null ? void 0 : m.call(c)) || {}).length) && i.Css.addRules(Ye);
2411
- }, R = () => {
2436
+ }, M = () => {
2412
2437
  if (!s.blocks || d) return;
2413
- const c = i.Blocks, m = a("blocksCategory"), g = /* @__PURE__ */ new Set([We, ...o.map((A) => Ge(A.id))]);
2414
- c.getAll().filter((A) => String(A.id).startsWith("gjsf-") && !g.has(A.id)).forEach((A) => c.remove(A.id));
2438
+ const c = i.Blocks, m = n("blocksCategory"), b = /* @__PURE__ */ new Set([We, ...o.map((A) => Ge(A.id))]);
2439
+ c.getAll().filter((A) => String(A.id).startsWith("gjsf-") && !b.has(A.id)).forEach((A) => c.remove(A.id));
2415
2440
  const k = (A, D) => {
2416
2441
  const le = c.get(A);
2417
2442
  le ? le.set(D) : c.add(A, D);
2418
2443
  };
2419
- k(We, { label: `+ ${a("newFormBlock")}`, category: m, media: Xe, content: { type: q, gjsfCreate: !0 }, select: !0 }), o.forEach((A) => k(Ge(A.id), { label: A.name, category: m, media: Xe, content: { type: q, formId: A.id }, select: !0 }));
2444
+ k(We, { label: `+ ${n("newFormBlock")}`, category: m, media: Xe, content: { type: q, gjsfCreate: !0 }, select: !0 }), o.forEach((A) => k(Ge(A.id), { label: A.name, category: m, media: Xe, content: { type: q, formId: A.id }, select: !0 }));
2420
2445
  }, F = () => {
2421
2446
  if (d) return;
2422
- _(), R();
2447
+ w(), M();
2423
2448
  const c = i.getSelected();
2424
- (c == null ? void 0 : c.get("type")) === q && E.refreshTraits(c), y(ce.forms, o);
2425
- }, N = async () => (o = (await r.listForms()).map(V), F(), n == null || n.setForms(!0), v(), o), U = () => [
2426
- { id: Y(), type: "text", name: "name", label: a("defaultName"), required: !0, autocomplete: "name", width: "1/2" },
2427
- { id: Y(), type: "email", name: "email", label: a("defaultEmail"), required: !0, autocomplete: "email", width: "1/2" },
2428
- { id: Y(), type: "textarea", name: "message", label: a("defaultMessage"), rows: 5 }
2449
+ (c == null ? void 0 : c.get("type")) === q && _.refreshTraits(c), y(de.forms, o);
2450
+ }, I = async () => (o = (await r.listForms()).map(V), F(), a == null || a.setForms(!0), v(), o), U = () => [
2451
+ { id: Y(), type: "text", name: "name", label: n("defaultName"), required: !0, autocomplete: "name", width: "1/2" },
2452
+ { id: Y(), type: "email", name: "email", label: n("defaultEmail"), required: !0, autocomplete: "email", width: "1/2" },
2453
+ { id: Y(), type: "textarea", name: "message", label: n("defaultMessage"), rows: 5 }
2429
2454
  ], Z = (c) => ({ id: c.id, name: c.name, fields: c.fields, settings: c.settings, ...c.attrs ? { attrs: c.attrs } : {} }), K = (c) => {
2430
2455
  const m = V(c);
2431
- o = p(m.id) ? o.map((g) => g.id === m.id ? m : g) : [...o, m];
2456
+ o = p(m.id) ? o.map((b) => b.id === m.id ? m : b) : [...o, m];
2432
2457
  }, Q = async (c = {}) => {
2433
- const m = a("defaultFormName");
2434
- let g = o.length + 1;
2435
- for (; o.some((D) => D.name === `${m} ${g}`); ) g++;
2436
- const k = V({ id: c.id || _e(), name: c.name || `${m} ${g}`, fields: c.fields || U(), settings: c.settings || {}, attrs: c.attrs }), A = await r.saveForm(Z(k));
2437
- return K(A), F(), n == null || n.setForms(), y(ce.saved, p(A.id)), p(A.id);
2438
- }, H = /* @__PURE__ */ new Map();
2439
- let S = null;
2458
+ const m = n("defaultFormName");
2459
+ let b = o.length + 1;
2460
+ for (; o.some((D) => D.name === `${m} ${b}`); ) b++;
2461
+ const k = V({ id: c.id || _e(), name: c.name || `${m} ${b}`, fields: c.fields || U(), settings: c.settings || {}, attrs: c.attrs }), A = await r.saveForm(Z(k));
2462
+ return K(A), F(), a == null || a.setForms(), y(de.saved, p(A.id)), p(A.id);
2463
+ }, z = /* @__PURE__ */ new Map();
2464
+ let E = null;
2440
2465
  const C = async () => {
2441
- S && clearTimeout(S), S = null;
2442
- const c = [...H.values()];
2443
- H.clear();
2466
+ E && clearTimeout(E), E = null;
2467
+ const c = [...z.values()];
2468
+ z.clear();
2444
2469
  for (const m of c) {
2445
- const g = p(m.id);
2446
- n == null || n.flash(a("saving"));
2470
+ const b = p(m.id);
2471
+ a == null || a.flash(n("saving"));
2447
2472
  try {
2448
- const k = await r.saveForm(Z(V(m)), (g == null ? void 0 : g.version) ?? null);
2449
- K(k), n == null || n.flash(a("saved")), y(ce.saved, p(k.id)), E.rebuildAll(k.id);
2473
+ const k = await r.saveForm(Z(V(m)), (b == null ? void 0 : b.version) ?? null);
2474
+ K(k), a == null || a.flash(n("saved")), y(de.saved, p(k.id)), _.rebuildAll(k.id);
2450
2475
  } catch (k) {
2451
2476
  if (k instanceof Ae) {
2452
2477
  const A = await r.getForm(m.id).catch(() => {
2453
2478
  });
2454
- A && K(A), n == null || n.setForms(!0), n == null || n.flash(a("conflict"), !0), E.rebuildAll(m.id);
2479
+ A && K(A), a == null || a.setForms(!0), a == null || a.flash(n("conflict"), !0), _.rebuildAll(m.id);
2455
2480
  } else throw k;
2456
2481
  }
2457
2482
  }
2458
- c.length && F(), n == null || n.setForms();
2483
+ c.length && F(), a == null || a.setForms();
2459
2484
  }, X = (c) => {
2460
2485
  const m = p(c.id);
2461
- m && K({ ...I(c), version: m.version, updatedAt: m.updatedAt }), H.set(c.id, I(c)), S && clearTimeout(S), S = setTimeout(() => void C().catch($), s.autosaveDelay);
2486
+ m && K({ ...R(c), version: m.version, updatedAt: m.updatedAt }), z.set(c.id, R(c)), E && clearTimeout(E), E = setTimeout(() => void C().catch($), s.autosaveDelay);
2462
2487
  }, se = async (c, m) => {
2463
- H.has(c) && await C();
2464
- const g = p(c);
2465
- if (!g) throw new Error(`grapesjs-forms: no form ${c}`);
2466
- return H.set(c, V({ ...I(g), ...I(m), id: c })), await C(), p(c);
2467
- }, ne = async (c) => {
2468
- H.delete(c), await r.deleteForm(c), o = o.filter((m) => m.id !== c), F(), n == null || n.setForms(), E.rebuildAll(c), y(ce.removed, c);
2488
+ z.has(c) && await C();
2489
+ const b = p(c);
2490
+ if (!b) throw new Error(`grapesjs-forms: no form ${c}`);
2491
+ return z.set(c, V({ ...R(b), ...R(m), id: c })), await C(), p(c);
2492
+ }, ae = async (c) => {
2493
+ z.delete(c), await r.deleteForm(c), o = o.filter((m) => m.id !== c), F(), a == null || a.setForms(), _.rebuildAll(c), y(de.removed, c);
2469
2494
  }, ee = async (c) => {
2470
- H.has(c) && await C();
2495
+ z.has(c) && await C();
2471
2496
  const m = p(c);
2472
2497
  if (!m) throw new Error(`grapesjs-forms: no form ${c}`);
2473
- return Q({ name: te(a("copyOf"), m.name), fields: I(m.fields).map((g) => ({ ...g, id: Y() })), settings: I(m.settings), attrs: m.attrs && I(m.attrs) });
2498
+ return Q({ name: te(n("copyOf"), m.name), fields: R(m.fields).map((b) => ({ ...b, id: Y() })), settings: R(m.settings), attrs: m.attrs && R(m.attrs) });
2474
2499
  }, he = async (c, m) => {
2475
- const g = !Array.isArray(m.fields) && (Array.isArray(m.pages) || Array.isArray(m.elements) || Array.isArray(m.questions));
2500
+ const b = !Array.isArray(m.fields) && (Array.isArray(m.pages) || Array.isArray(m.elements) || Array.isArray(m.questions));
2476
2501
  let k, A = [];
2477
- if (g) {
2502
+ if (b) {
2478
2503
  const D = Je(m, c);
2479
2504
  k = D.form, A = D.skipped;
2480
2505
  } else k = V({ ...m, id: c });
@@ -2492,57 +2517,57 @@ function ws(i, e = {}) {
2492
2517
  const D = typeof A == "string" ? A : A == null ? void 0 : A.href;
2493
2518
  D && !c.includes(D) && c.push(D);
2494
2519
  });
2495
- let g = "";
2520
+ let b = "";
2496
2521
  try {
2497
- g = i.getCss() || "";
2522
+ b = i.getCss() || "";
2498
2523
  } catch {
2499
- g = "";
2524
+ b = "";
2500
2525
  }
2501
- return s.baseCss && !/\.gjsf-form\s*\{/.test(g) && (g = Ye + g), { css: g, links: c };
2502
- }, xt = () => new ys({
2503
- t: a,
2526
+ return s.baseCss && !/\.gjsf-form\s*\{/.test(b) && (b = Ye + b), { css: b, links: c };
2527
+ }, xt = () => new xs({
2528
+ t: n,
2504
2529
  forms: () => o,
2505
2530
  form: p,
2506
2531
  create: () => Q(),
2507
2532
  duplicate: ee,
2508
- remove: ne,
2533
+ remove: ae,
2509
2534
  change: X,
2510
2535
  defaultAction: (c) => s.submitUrl ? Ue(s.submitUrl, c.id) : "",
2511
- previewHtml: (c) => Ie(V(c), { action: "", ctx: { page: u }, texts: P(), codes: B(), key: "preview" }),
2536
+ previewHtml: (c) => Ie(V(c), { action: "", ctx: { page: u }, texts: P(), codes: J(), key: "preview" }),
2512
2537
  previewStyles: yt,
2513
- submit: async (c, m, g) => {
2514
- H.has(c) && await C();
2515
- const k = await r.submit(c, m, { ...g || {}, ...J() ? { pageId: J() } : {} });
2516
- return y(ce.submitted, { formId: c, result: k }), k;
2538
+ submit: async (c, m, b) => {
2539
+ z.has(c) && await C();
2540
+ const k = await r.submit(c, m, { ...b || {}, ...H() ? { pageId: H() } : {} });
2541
+ return y(de.submitted, { formId: c, result: k }), k;
2517
2542
  },
2518
2543
  submissions: (c, m) => r.listSubmissions ? r.listSubmissions(c, m) : null,
2519
2544
  deleteSubmission: (c, m) => {
2520
- var g;
2521
- return ((g = r.deleteSubmission) == null ? void 0 : g.call(r, c, m)) ?? Promise.resolve();
2545
+ var b;
2546
+ return ((b = r.deleteSubmission) == null ? void 0 : b.call(r, c, m)) ?? Promise.resolve();
2522
2547
  },
2523
2548
  applyJson: he,
2524
2549
  exportSurveyJs: (c) => He(p(c) || V({ id: c })),
2525
2550
  onError: $
2526
2551
  }), oe = (c) => {
2527
- var g;
2552
+ var b;
2528
2553
  if (d) return;
2529
- s.injectCss && qe(), n || (n = xt()), n.show(c || null);
2554
+ s.injectCss && qe(), a || (a = xt()), a.show(c || null);
2530
2555
  const m = i.Modal;
2531
- m.open({ title: a("forms"), content: n.root, attributes: { class: "gjsf-modal" } }), (g = m.onceClose) == null || g.call(m, () => {
2556
+ m.open({ title: n("forms"), content: a.root, attributes: { class: "gjsf-modal" } }), (b = m.onceClose) == null || b.call(m, () => {
2532
2557
  C().catch($);
2533
2558
  });
2534
2559
  }, vt = () => {
2535
2560
  var c, m;
2536
- n && ((m = (c = i.Modal).isOpen) != null && m.call(c)) && i.Modal.close();
2561
+ a && ((m = (c = i.Modal).isOpen) != null && m.call(c)) && i.Modal.close();
2537
2562
  };
2538
2563
  i.Commands.add(ue.open, {
2539
- run(c, m, g = {}) {
2540
- oe(g == null ? void 0 : g.id);
2564
+ run(c, m, b = {}) {
2565
+ oe(b == null ? void 0 : b.id);
2541
2566
  }
2542
2567
  }), i.Commands.add(ue.edit, {
2543
- run(c, m, g = {}) {
2568
+ run(c, m, b = {}) {
2544
2569
  var D, le;
2545
- const k = (g == null ? void 0 : g.component) || ((D = g == null ? void 0 : g.trait) == null ? void 0 : D.target) || c.getSelected(), A = (g == null ? void 0 : g.id) || (((le = k == null ? void 0 : k.get) == null ? void 0 : le.call(k, "type")) === q ? String(k.get("formId") || "") : "");
2570
+ const k = (b == null ? void 0 : b.component) || ((D = b == null ? void 0 : b.trait) == null ? void 0 : D.target) || c.getSelected(), A = (b == null ? void 0 : b.id) || (((le = k == null ? void 0 : k.get) == null ? void 0 : le.call(k, "type")) === q ? String(k.get("formId") || "") : "");
2546
2571
  oe(A || null);
2547
2572
  }
2548
2573
  });
@@ -2550,28 +2575,28 @@ function ws(i, e = {}) {
2550
2575
  store: r,
2551
2576
  list: () => o,
2552
2577
  get: (c) => p(c),
2553
- reload: N,
2578
+ reload: I,
2554
2579
  create: Q,
2555
2580
  update: se,
2556
- remove: ne,
2581
+ remove: ae,
2557
2582
  duplicate: ee,
2558
2583
  open: (c) => oe(c),
2559
2584
  close: vt,
2560
- actionOf: M,
2585
+ actionOf: T,
2561
2586
  html: (c, m = {}) => {
2562
- const g = p(c);
2563
- if (!g) throw new Error(`grapesjs-forms: no form ${c}`);
2564
- return Ie(g, { action: M(g), ctx: { page: u }, texts: P(), codes: B(), pageId: J(), ...m });
2587
+ const b = p(c);
2588
+ if (!b) throw new Error(`grapesjs-forms: no form ${c}`);
2589
+ return Ie(b, { action: T(b), ctx: { page: u }, texts: P(), codes: J(), pageId: H(), ...m });
2565
2590
  },
2566
- submit: async (c, m, g) => (H.has(c) && await C(), r.submit(c, m, g)),
2567
- rebuild: (c) => E.rebuildAll(c || null),
2591
+ submit: async (c, m, b) => (z.has(c) && await C(), r.submit(c, m, b)),
2592
+ rebuild: (c) => _.rebuildAll(c || null),
2568
2593
  importSurveyJs: async (c, m) => {
2569
2594
  if (m) {
2570
2595
  const A = await he(m, c);
2571
2596
  return { form: p(m), skipped: A };
2572
2597
  }
2573
- const g = Je(c, _e());
2574
- return { form: await Q({ id: g.form.id, name: g.form.name, fields: g.form.fields, settings: g.form.settings }), skipped: g.skipped };
2598
+ const b = Je(c, _e());
2599
+ return { form: await Q({ id: b.form.id, name: b.form.name, fields: b.form.fields, settings: b.form.settings }), skipped: b.skipped };
2575
2600
  },
2576
2601
  exportSurveyJs: (c) => {
2577
2602
  const m = p(c);
@@ -2598,8 +2623,8 @@ function ws(i, e = {}) {
2598
2623
  label: Qe(18),
2599
2624
  command: ue.open,
2600
2625
  togglable: !1,
2601
- attributes: { title: a("forms") }
2602
- }), b.push(() => {
2626
+ attributes: { title: n("forms") }
2627
+ }), g.push(() => {
2603
2628
  try {
2604
2629
  c.removeButton(m.id, Ke);
2605
2630
  } catch {
@@ -2607,46 +2632,46 @@ function ws(i, e = {}) {
2607
2632
  });
2608
2633
  return;
2609
2634
  }
2610
- const g = i.getContainer();
2611
- if (!g) return;
2635
+ const b = i.getContainer();
2636
+ if (!b) return;
2612
2637
  s.injectCss && qe();
2613
- const k = f("button", { class: "gjsf-toggle", type: "button", title: a("forms"), onclick: () => oe() });
2614
- k.innerHTML = Qe(14), getComputedStyle(g).position === "static" && (g.style.position = "relative"), g.appendChild(k), b.push(() => k.remove());
2638
+ const k = f("button", { class: "gjsf-toggle", type: "button", title: n("forms"), onclick: () => oe() });
2639
+ k.innerHTML = Qe(14), getComputedStyle(b).position === "static" && (b.style.position = "relative"), b.appendChild(k), g.push(() => k.remove());
2615
2640
  };
2616
2641
  h(
2617
2642
  "i18n:locale i18n:update",
2618
2643
  () => setTimeout(() => {
2619
- var m, g;
2644
+ var m, b;
2620
2645
  if (d) return;
2621
- R();
2646
+ M();
2622
2647
  const c = i.getSelected();
2623
- (c == null ? void 0 : c.get("type")) === q && E.refreshTraits(c), n && ((g = (m = i.Modal).isOpen) != null && g.call(m)) && n.render();
2648
+ (c == null ? void 0 : c.get("type")) === q && _.refreshTraits(c), a && ((b = (m = i.Modal).isOpen) != null && b.call(m)) && a.render();
2624
2649
  }, 0)
2625
2650
  );
2626
2651
  const ge = () => {
2627
- d || (d = !0, S && clearTimeout(S), E.destroy(), n == null || n.destroy(), b.splice(0).forEach((c) => c()), t.__gjsfCleanup === ge && delete t.__gjsfCleanup);
2652
+ d || (d = !0, E && clearTimeout(E), _.destroy(), a == null || a.destroy(), g.splice(0).forEach((c) => c()), t.__gjsfCleanup === ge && delete t.__gjsfCleanup);
2628
2653
  };
2629
2654
  t.__gjsfCleanup = ge;
2630
- const St = ts(i, bt, () => _s(s), (c) => {
2655
+ const St = ts(i, bt, () => ks(s), (c) => {
2631
2656
  var m;
2632
- "autosaveDelay" in c && (s.autosaveDelay = Ze({ autosaveDelay: c.autosaveDelay }).autosaveDelay), "submitUrl" in c && (s.submitUrl = c.submitUrl || ((m = s.rest) == null ? void 0 : m.url) || null, E.rebuildAll(null));
2657
+ "autosaveDelay" in c && (s.autosaveDelay = Ze({ autosaveDelay: c.autosaveDelay }).autosaveDelay), "submitUrl" in c && (s.submitUrl = c.submitUrl || ((m = s.rest) == null ? void 0 : m.url) || null, _.rebuildAll(null));
2633
2658
  });
2634
2659
  h("destroy", St), h("destroy", ge);
2635
- const Le = () => void C().catch(Me);
2636
- window.addEventListener("beforeunload", Le), b.push(() => window.removeEventListener("beforeunload", Le)), i.onReady(() => {
2637
- d || (wt(), N().then(async () => {
2638
- var g;
2660
+ const Le = () => void C().catch(De);
2661
+ window.addEventListener("beforeunload", Le), g.push(() => window.removeEventListener("beforeunload", Le)), i.onReady(() => {
2662
+ d || (wt(), I().then(async () => {
2663
+ var b;
2639
2664
  const c = l();
2640
2665
  c != null && c.whenReady && await c.whenReady();
2641
- const m = (g = c == null ? void 0 : c.getActiveId) == null ? void 0 : g.call(c);
2666
+ const m = (b = c == null ? void 0 : c.getActiveId) == null ? void 0 : b.call(c);
2642
2667
  c && m && !u && (u = await c.store.get(m).catch(() => {
2643
2668
  }) || null), d || (v(), j());
2644
2669
  }).catch($));
2645
2670
  });
2646
2671
  }
2647
- const Ss = "grapesjs-forms", Es = "0.1.0", bt = {
2648
- id: Ss,
2649
- version: Es,
2672
+ const Es = "grapesjs-forms", _s = "0.1.1", bt = {
2673
+ id: Es,
2674
+ version: _s,
2650
2675
  title: "Forms",
2651
2676
  description: "A form editor of its own; a form is a component styled by the site; submissions go to a REST API.",
2652
2677
  options: [
@@ -2661,7 +2686,7 @@ const Ss = "grapesjs-forms", Es = "0.1.0", bt = {
2661
2686
  { key: "injectCss", type: "boolean", default: !0, title: "Inject CSS", advanced: !0 }
2662
2687
  ]
2663
2688
  };
2664
- function _s(i) {
2689
+ function ks(i) {
2665
2690
  return {
2666
2691
  rest: i.rest ? { url: i.rest.url, ...i.rest.credentials ? { credentials: i.rest.credentials } : {} } : null,
2667
2692
  submitUrl: i.submitUrl || "",
@@ -2674,8 +2699,8 @@ function _s(i) {
2674
2699
  injectCss: i.injectCss
2675
2700
  };
2676
2701
  }
2677
- const Ls = Xt(ws, bt);
2678
- function Fs(i = document) {
2702
+ const Fs = Xt(Ss, bt);
2703
+ function $s(i = document) {
2679
2704
  let e = 0;
2680
2705
  return i.querySelectorAll("form[data-gjsf-form]").forEach((t) => {
2681
2706
  t.__gjsf || (Ce.call(t), e++);
@@ -2688,10 +2713,10 @@ export {
2688
2713
  ue as COMMANDS,
2689
2714
  fe as CONTENT_TYPES,
2690
2715
  Ae as ConflictError,
2691
- Cs as DOM_EVENTS,
2692
- ce as EVENTS,
2716
+ As as DOM_EVENTS,
2717
+ de as EVENTS,
2693
2718
  Ft as FIELD_TYPES,
2694
- pe as FORM_ATTR,
2719
+ ce as FORM_ATTR,
2695
2720
  q as FORM_TYPE,
2696
2721
  as as FormComponents,
2697
2722
  Se as HONEYPOT,
@@ -2706,47 +2731,47 @@ export {
2706
2731
  lt as PART_ATTR,
2707
2732
  Ee as PART_TYPE,
2708
2733
  Lt as PLACEHOLDERS,
2709
- Ss as PLUGIN_ID,
2734
+ Es as PLUGIN_ID,
2710
2735
  $t as RANGE_TYPES,
2711
- fs as RestFormStore,
2712
- ls as SUPPORTED_LOCALES,
2736
+ hs as RestFormStore,
2737
+ cs as SUPPORTED_LOCALES,
2713
2738
  G as StoreError,
2714
2739
  we as TEXT_LIKE,
2715
2740
  et as TOKEN_RE,
2716
- Es as VERSION,
2741
+ _s as VERSION,
2717
2742
  st as WIDTHS,
2718
2743
  Ge as blockIdOf,
2719
- at as buildChildren,
2744
+ nt as buildChildren,
2720
2745
  ke as cleanAttrs,
2721
- Ls as default,
2746
+ Fs as default,
2722
2747
  ot as elHtml,
2723
- Fs as enhanceForms,
2748
+ $s as enhanceForms,
2724
2749
  Y as fieldId,
2725
2750
  W as fieldName,
2726
2751
  Te as fieldTitle,
2727
2752
  rt as formAttrs,
2728
2753
  Ie as formHtml,
2729
2754
  Ce as formScript,
2730
- Ls as formsPlugin,
2755
+ Fs as formsPlugin,
2731
2756
  Je as fromSurveyJs,
2732
- As as getForms,
2757
+ Ls as getForms,
2733
2758
  tt as hasOptions,
2734
2759
  At as hasTokens,
2735
2760
  it as inputFields,
2736
- O as isContent,
2761
+ N as isContent,
2737
2762
  $e as isSafeUrl,
2738
2763
  mt as locales,
2739
- Mt as normalizeField,
2764
+ Dt as normalizeField,
2740
2765
  Pt as normalizeFields,
2741
2766
  V as normalizeForm,
2742
- Dt as normalizeOptions,
2767
+ Mt as normalizeOptions,
2743
2768
  Ut as normalizeSettings,
2744
- _s as publicOptions,
2769
+ ks as publicOptions,
2745
2770
  Ct as resolveBuild,
2746
2771
  Ze as resolveOptions,
2747
2772
  Ue as submitUrlOf,
2748
2773
  dt as toComponent,
2749
- xs as toCsv,
2774
+ vs as toCsv,
2750
2775
  He as toSurveyJs,
2751
2776
  re as uniqueName,
2752
2777
  Kt as validateSubmission